Refresh the SSH account branch from master

Keep the SSH base current so the stacked Tailscale migrations can follow the
latest upstream schema sequence. The merge preserves managed SSH account
selection, host-auth compatibility, and the PATH-only ACP prerequisite check.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Devin FoleyandPaperclip committed 2026-11-13 09:03:27 -08:00
commit e8a0316483
262 files changed
+13201 -1135

No files matched your search

+8
View File
@@ -385,6 +385,14 @@ export const INSTANCE_FEATURE_CATALOG: Record<InstanceFeatureKey, FeatureCatalog
cloudDefault: true,
selfHostedDefault: false,
},
enableMcpTasks: {
title: "Durable app actions (MCP Tasks)",
description:
"Let connected apps run long actions, such as CI runs or deploys, as tasks that Paperclip keeps track of across timeouts, restarts, and deploys, so the work is never started twice.",
tier: "managed",
cloudDefault: false,
selfHostedDefault: false,
},
enableSandboxDuplexBridge: {
title: "Sandbox Duplex Bridge",
description:
+3 -1
View File
@@ -1601,6 +1601,8 @@ export type {
ToolApplication,
ToolConnection,
ToolCatalogEntry,
ProviderToolIconEntry,
ProviderToolIconsResponse,
ToolRuntimeSlot,
ToolConnectionHealthCheckResult,
ToolCatalogRefreshResult,
@@ -2852,7 +2854,7 @@ export {
} from "./runtime-exposure/loopback-bind.js";
export { ACCOUNT_HANDLE_MAX_LENGTH, toAccountHandle } from "./account-handle.js";
export type { ExecutionContinuationEnvelope } from "./types/execution-continuation.js";
export type { ExecutionProjection, ExecutionReconciliation, ExecutionBlocker, TaskInterruptionPresentation } from "./types/execution-projection.js";
export type { ExecutionAgentQueue, ExecutionProjection, ExecutionReconciliation, ExecutionBlocker, TaskInterruptionPresentation } from "./types/execution-projection.js";
export { EXECUTION_RECONCILIATION_CAUSES, requiresExecutionReconciliation } from "./types/execution-projection.js";
export * from "./types/voice-sessions.js";
+176
View File
@@ -221,3 +221,179 @@ export function buildMcpAppCsp(csp: McpAppResourceCsp): string {
"form-action 'none'",
].join("; ");
}
/* ------------------------------------------------------------------------- */
/* View-to-chat messages (`ui/message`) */
/* ------------------------------------------------------------------------- */
/** Longest message a view may propose to the task chat. */
export const MCP_APP_MESSAGE_MAX_CHARS = 8_000;
/**
* The text of a `ui/message` request (`{ role: "user", content: ContentBlock[] }`).
* Only text blocks are kept. Returns null when there is no text, the role is
* not "user", or the text is too long.
*/
export function readMcpAppMessageText(params: unknown): string | null {
const value = record(params);
if (!value || (value.role !== undefined && value.role !== "user")) return null;
const blocks = Array.isArray(value.content) ? value.content : record(value.content) ? [value.content] : [];
const text = blocks
.map((block) => record(block))
.filter((block): block is Record<string, unknown> => block?.type === "text" && typeof block.text === "string")
.map((block) => block.text as string)
.join("\n\n")
.trim();
if (!text || text.length > MCP_APP_MESSAGE_MAX_CHARS) return null;
return text;
}
/**
* Body of `POST /api/issues/:issueId/mcp-app-views/:viewId/messages`. The
* viewer has already sent the comment through the task's normal comment path;
* this records that it came from the view.
*/
export const mcpAppMessageSentSchema = z.object({
/** The `clientRequestId` the viewer's comment was sent with. */
clientRequestId: z.string().uuid(),
}).strict();
export type McpAppMessageSentRequest = z.infer<typeof mcpAppMessageSentSchema>;
/* ------------------------------------------------------------------------- */
/* View context for the agent (`ui/update-model-context`) */
/* ------------------------------------------------------------------------- */
/** Largest stored context per view, in UTF-8 bytes of its JSON. */
export const MCP_APP_MODEL_CONTEXT_MAX_BYTES = 16 * 1024;
/** The latest context a view gave the agent. Untrusted app data, never instructions. */
export interface McpAppModelContext {
text: string | null;
structuredContent: Record<string, unknown> | null;
}
/** Body of `PUT /api/issues/:issueId/mcp-app-views/:viewId/model-context`. */
export const mcpAppModelContextUpdateSchema = z.object({
content: z.array(z.unknown()).max(64).optional(),
structuredContent: z.record(z.string(), z.unknown()).optional(),
}).strict();
export type McpAppModelContextUpdate = z.infer<typeof mcpAppModelContextUpdateSchema>;
/**
* Normalizes `ui/update-model-context` params: text blocks only, plus the
* structured content. Returns null for an empty update (which clears the
* context) and throws a RangeError when the result exceeds the size limit.
*/
export function normalizeMcpAppModelContext(params: unknown): McpAppModelContext | null {
const value = record(params) ?? {};
const blocks = Array.isArray(value.content) ? value.content : [];
const text = blocks
.map((block) => record(block))
.filter((block): block is Record<string, unknown> => block?.type === "text" && typeof block.text === "string")
.map((block) => block.text as string)
.join("\n\n")
.trim();
const structuredContent = record(value.structuredContent);
const context: McpAppModelContext = {
text: text || null,
structuredContent: structuredContent && Object.keys(structuredContent).length > 0 ? structuredContent : null,
};
if (!context.text && !context.structuredContent) return null;
if (utf8Length(JSON.stringify(context)) > MCP_APP_MODEL_CONTEXT_MAX_BYTES) {
throw new RangeError(`App context is larger than ${MCP_APP_MODEL_CONTEXT_MAX_BYTES} bytes`);
}
return context;
}
function utf8Length(value: string): number {
return new TextEncoder().encode(value).length;
}
/* ------------------------------------------------------------------------- */
/* Tool icons (SEP-973) */
/* ------------------------------------------------------------------------- */
/** A provider icon for a tool, resource or prompt, after sanitizing. */
export interface McpIcon {
src: string;
mimeType?: string;
sizes?: string[];
theme?: "light" | "dark";
}
export const MCP_ICON_MAX_COUNT = 4;
export const MCP_ICON_MAX_URL_LENGTH = 2048;
/** A `data:` icon larger than this is dropped. */
export const MCP_ICON_MAX_DATA_URI_LENGTH = 32 * 1024;
const RASTER_ICON_MIME_TYPES = new Set(["image/png", "image/jpeg", "image/gif", "image/webp", "image/x-icon", "image/vnd.microsoft.icon"]);
const SVG_MIME_TYPE = "image/svg+xml";
/**
* Accepts only `https:` raster images and `data:image/*` URIs. SVG is allowed
* only inline as `data:`: a remote SVG could change after review. Icons are
* always rendered as `<img referrerPolicy="no-referrer">`, never inlined, so
* an SVG's scripts never run.
*/
export function sanitizeMcpIconSrc(src: unknown, mimeType?: string | null): string | null {
if (typeof src !== "string") return null;
const trimmed = src.trim();
if (/^data:/i.test(trimmed)) {
if (trimmed.length > MCP_ICON_MAX_DATA_URI_LENGTH) return null;
const match = /^data:(image\/[a-z0-9.+-]+)(;[a-z0-9=.+-]+)*,/i.exec(trimmed);
if (!match) return null;
const type = match[1]!.toLowerCase();
return type === SVG_MIME_TYPE || RASTER_ICON_MIME_TYPES.has(type) ? trimmed : null;
}
if (trimmed.length > MCP_ICON_MAX_URL_LENGTH) return null;
let url: URL;
try {
url = new URL(trimmed);
} catch {
return null;
}
if (url.protocol !== "https:" || url.username || url.password) return null;
if (mimeType && mimeType.toLowerCase() === SVG_MIME_TYPE) return null;
if (/\.svgz?$/i.test(url.pathname)) return null;
return url.toString();
}
/** Reads and sanitizes an MCP `icons` array. Returns null when none survive. */
export function readMcpIcons(value: unknown): McpIcon[] | null {
if (!Array.isArray(value)) return null;
const icons: McpIcon[] = [];
for (const item of value) {
if (icons.length >= MCP_ICON_MAX_COUNT) break;
const icon = record(item);
if (!icon) continue;
const rawMime = typeof icon.mimeType === "string" ? icon.mimeType.trim().toLowerCase() : null;
const mimeType = rawMime && (rawMime === SVG_MIME_TYPE || RASTER_ICON_MIME_TYPES.has(rawMime)) ? rawMime : null;
if (rawMime && !mimeType) continue;
const src = sanitizeMcpIconSrc(icon.src, mimeType);
if (!src) continue;
const sizes = Array.isArray(icon.sizes)
? icon.sizes.filter((size): size is string => typeof size === "string" && /^(any|\d{1,4}x\d{1,4})$/i.test(size)).slice(0, 8)
: [];
icons.push({
src,
...(mimeType ? { mimeType } : {}),
...(sizes.length > 0 ? { sizes } : {}),
...(icon.theme === "light" || icon.theme === "dark" ? { theme: icon.theme } : {}),
});
}
return icons.length > 0 ? icons : null;
}
/** The icon to show for a theme: a matching or theme-less icon, preferring small sizes. */
export function pickMcpIcon(icons: readonly McpIcon[] | null | undefined, theme: "light" | "dark"): McpIcon | null {
if (!icons?.length) return null;
const candidates = icons.filter((icon) => !icon.theme || icon.theme === theme);
const pool = candidates.length > 0 ? candidates : icons;
const smallest = (icon: McpIcon) => Math.min(...(icon.sizes ?? ["any"]).map((size) => {
const match = /^(\d+)x/i.exec(size);
return match ? Math.abs(Number(match[1]) - 32) : 1_000;
}));
return [...pool].sort((a, b) => smallest(a) - smallest(b))[0] ?? null;
}
+65
View File
@@ -0,0 +1,65 @@
import { describe, expect, it } from "vitest";
import {
MCP_ICON_MAX_COUNT,
MCP_ICON_MAX_DATA_URI_LENGTH,
pickMcpIcon,
readMcpIcons,
sanitizeMcpIconSrc,
} from "./mcp-apps.js";
const PNG = "https://cdn.example.com/icons/tool.png";
const SVG_DATA = "data:image/svg+xml;base64,PHN2Zy8+";
describe("sanitizeMcpIconSrc", () => {
it("keeps https raster images and data:image URIs, including inline SVG", () => {
expect(sanitizeMcpIconSrc(PNG)).toBe(PNG);
expect(sanitizeMcpIconSrc(SVG_DATA)).toBe(SVG_DATA);
expect(sanitizeMcpIconSrc("data:image/png;base64,iVBORw0KGgo=")).toBe("data:image/png;base64,iVBORw0KGgo=");
});
it("drops other schemes, remote SVG, credentials and oversize data", () => {
expect(sanitizeMcpIconSrc("http://cdn.example.com/tool.png")).toBeNull();
expect(sanitizeMcpIconSrc("javascript:alert(1)")).toBeNull();
expect(sanitizeMcpIconSrc("data:text/html;base64,PHNjcmlwdD4=")).toBeNull();
expect(sanitizeMcpIconSrc("https://cdn.example.com/tool.svg")).toBeNull();
expect(sanitizeMcpIconSrc("https://cdn.example.com/tool", "image/svg+xml")).toBeNull();
expect(sanitizeMcpIconSrc("https://user:pw@cdn.example.com/tool.png")).toBeNull();
expect(sanitizeMcpIconSrc(`data:image/png;base64,${"A".repeat(MCP_ICON_MAX_DATA_URI_LENGTH)}`)).toBeNull();
expect(sanitizeMcpIconSrc(42)).toBeNull();
});
});
describe("readMcpIcons", () => {
it("keeps valid icons with their metadata and drops the rest", () => {
expect(readMcpIcons([
{ src: PNG, mimeType: "image/png", sizes: ["32x32", "bogus"], theme: "dark" },
{ src: "http://insecure.example.com/a.png" },
{ src: "https://cdn.example.com/b", mimeType: "text/html" },
{ src: SVG_DATA, mimeType: "image/svg+xml", theme: "neon" },
])).toEqual([
{ src: PNG, mimeType: "image/png", sizes: ["32x32"], theme: "dark" },
{ src: SVG_DATA, mimeType: "image/svg+xml" },
]);
});
it("bounds the count and returns null when nothing survives", () => {
const many = Array.from({ length: 10 }, (_, i) => ({ src: `https://cdn.example.com/${i}.png` }));
expect(readMcpIcons(many)).toHaveLength(MCP_ICON_MAX_COUNT);
expect(readMcpIcons([{ src: "javascript:1" }])).toBeNull();
expect(readMcpIcons("nope")).toBeNull();
expect(readMcpIcons(undefined)).toBeNull();
});
});
describe("pickMcpIcon", () => {
it("prefers the theme's icon and a size near 32px", () => {
const icons = [
{ src: "https://a.example.com/light.png", theme: "light" as const },
{ src: "https://a.example.com/dark-512.png", theme: "dark" as const, sizes: ["512x512"] },
{ src: "https://a.example.com/dark-32.png", theme: "dark" as const, sizes: ["32x32"] },
];
expect(pickMcpIcon(icons, "dark")?.src).toBe("https://a.example.com/dark-32.png");
expect(pickMcpIcon(icons, "light")?.src).toBe("https://a.example.com/light.png");
expect(pickMcpIcon(null, "light")).toBeNull();
});
});
+2
View File
@@ -3,6 +3,8 @@ export interface ActivityEvent {
companyId: string;
actorType: "agent" | "user" | "system" | "plugin";
actorId: string;
/** Person-facing name of the actor, such as an agent's or member's name, or "Board". */
actorName?: string;
action: string;
entityType: string;
entityId: string;
@@ -26,6 +26,23 @@ export interface ExecutionBlocker {
};
}
/**
* Where a queued, never-started run waits while its agent's concurrency limit
* is full. Position follows the order the server starts the agent's queued runs.
*/
export interface ExecutionAgentQueue {
agentId: string;
agentName: string;
/** The agent's concurrency limit (runtimeConfig.heartbeat.maxConcurrentRuns, as enforced). */
maxConcurrentRuns: number;
/** The agent's runs that are running now. */
runningCount: number;
/** 1-based place among the agent's queued runs; 1 starts when the next slot frees. */
position: number;
/** All of the agent's queued runs. */
queuedCount: number;
}
/** Presentation of existing execution records, not a second task status machine. */
export interface ExecutionProjection {
/** The board can Stop this run now: any queued or running run, or a failed native run whose retry is still pending. */
@@ -53,6 +70,8 @@ export interface ExecutionProjection {
permittedActions: Array<"inspect_run" | "inspect_recovery">;
predecessorRunId: string | null;
successorRunId: string | null;
/** Set when phase is "queued" because the agent's concurrency limit is full (cause "agent_at_capacity"). */
agentQueue?: ExecutionAgentQueue | null;
}
/** These incidents require an explicit reconciliation, never a generic Retry. */
@@ -145,6 +164,7 @@ export interface TaskInterruptionPresentation {
state: "working" | "retry_scheduled" | "failed" | "waiting_for_user" | "resolved";
nextRetryAt: string | null;
canRetry: boolean;
retryAction?: "move_forward";
userAction: "approval" | "reconnect" | "assign_agent" | "choose_model" | "resume" | "budget" | "project_access"
/** Board confirms that a previous server, which can no longer report, stopped its workspace copyback. */
| "confirm_owner_stop"
+2
View File
@@ -541,6 +541,8 @@ export type {
ToolAuditOutcome,
ToolCallEvent,
ToolCatalogEntry,
ProviderToolIconEntry,
ProviderToolIconsResponse,
ToolCatalogEntryKind,
ToolCatalogEntryStatus,
ToolAppAttentionItem,
+6
View File
@@ -146,6 +146,12 @@ export interface InstanceExperimentalSettings {
* redeploy.
*/
enableSandboxDuplexBridge: boolean;
/**
* MCP Tasks: long provider tool calls become durable tasks that survive
* timeouts, restarts, and deploys. Default off: the extension is not
* declared, so behavior matches a client without it.
*/
enableMcpTasks: boolean;
/**
* @deprecated Compatibility-only. Provider WebSocket ingress now follows
* enableNativeRunner and this value has no runtime effect.
+4
View File
@@ -1001,6 +1001,8 @@ export interface Issue {
watchdog?: IssueWatchdogSummary | null;
scheduledRetry?: IssueScheduledRetry | null;
liveDescendantCount?: number;
/** Descendants whose run started; excludes runs still waiting for an agent slot. */
runningDescendantCount?: number;
relatedWork?: IssueRelatedWorkSummary;
referencedIssueIdentifiers?: string[];
planDocument?: IssueDocument | null;
@@ -1076,6 +1078,8 @@ export type CompactIssue = Pick<
blockedInboxAttention?: IssueBlockedInboxAttention | null;
scheduledRetry?: IssueScheduledRetry | null;
liveDescendantCount?: number;
/** Descendants whose run started; excludes runs still waiting for an agent slot. */
runningDescendantCount?: number;
myLastTouchAt?: Date | null;
lastExternalCommentAt?: Date | null;
lastActivityAt?: Date | null;
+17 -1
View File
@@ -1,4 +1,4 @@
import type { McpAppToolUi } from "../mcp-apps.js";
import type { McpAppToolUi, McpIcon } from "../mcp-apps.js";
import type {
ConnectionTokenIssuanceOutcome,
ConnectionTokenIssuancePath,
@@ -571,6 +571,8 @@ export interface ToolCatalogEntry {
annotations: Record<string, unknown> | null;
/** MCP Apps view declaration (`_meta.ui`), when the tool renders one. */
uiMeta?: McpAppToolUi | null;
/** Sanitized provider icons (SEP-973), when the tool declares any. */
icons?: McpIcon[] | null;
riskLevel: ToolRiskLevel;
isReadOnly: boolean;
isWrite: boolean;
@@ -1761,3 +1763,17 @@ export interface ToolConnectionTestCallStatus {
/** ISO timestamp the request was resolved (approved/denied/cancelled), when applicable. */
resolvedAt?: string | null;
}
/** A connected tool's provider icons, keyed by its tool gateway name. */
export interface ProviderToolIconEntry {
/** `mcp.<app>-<connection>:<tool>`, as agents see the tool. */
gatewayToolName: string;
/** `app_<name>_<digest>`, the name native runners (and so their transcripts) use. */
nativeToolName?: string;
icons: McpIcon[];
}
/** `GET /api/companies/:companyId/tool-icons` */
export interface ProviderToolIconsResponse {
icons: ProviderToolIconEntry[];
}
@@ -93,6 +93,9 @@ export const instanceExperimentalSettingsSchema = z.object({
// off the host keeps the file bridge for every run with no manifest change and
// no redeploy. The host reads this per run before it selects the transport.
enableSandboxDuplexBridge: z.boolean().default(false),
// MCP Tasks (io.modelcontextprotocol/tasks): durable long provider calls.
// Off: Paperclip never declares the extension, so servers never return tasks.
enableMcpTasks: z.boolean().default(false),
// Deprecated compatibility key. Runner ingress follows enableNativeRunner;
// this remains accepted so older stored rows and managed configs keep loading.
enableRunnerPreviewIngress: z.boolean().default(false),
+1
View File
@@ -646,6 +646,7 @@ export const retryWorkspaceExportSchema = z.object({
export const taskRetrySchema = z.object({
idempotencyKey: z.string().guid(),
observedRunId: z.string().guid().nullable(),
retryAction: z.literal("move_forward").optional(),
}).strict();
export const recoverWorkspaceSchema = z.object({