@ai-sdk/harness 1.0.72 → 1.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +23 -0
- package/dist/agent/index.d.ts +58 -14
- package/dist/agent/index.js +180 -22
- package/dist/agent/index.js.map +1 -1
- package/dist/bridge/index.js +14 -20
- package/dist/bridge/index.js.map +1 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/index.js +11 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/src/agent/harness-agent-session.ts +27 -7
- package/src/agent/harness-agent-settings.ts +8 -0
- package/src/agent/harness-agent.ts +74 -23
- package/src/agent/internal/harness-stream-text-result.ts +251 -59
- package/src/agent/internal/run-prompt.ts +10 -2
- package/src/bridge/index.ts +41 -37
- package/src/v1/harness-v1-bridge-protocol.ts +13 -0
- package/src/v1/harness-v1-response-format.ts +32 -0
- package/src/v1/harness-v1-session.ts +13 -0
- package/src/v1/index.ts +8 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/v1/harness-v1-builtin-tool.ts","../src/v1/harness-v1-stream-part.ts","../src/v1/harness-v1-bridge-protocol.ts","../src/v1/harness-v1-diagnostic.ts","../src/v1/harness-v1-tool-filtering.ts","../src/errors/harness-error.ts","../src/errors/harness-capability-unsupported-error.ts","../src/errors/harness-sandbox-authentication-error.ts"],"sourcesContent":["import { tool, type FlexibleSchema, type Tool } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n/**\n * Cross-harness vocabulary of common built-in tool names with their baseline\n * input schemas. Adapters that declare a built-in with one of these\n * `commonName`s must accept (at least) every input the baseline schema\n * accepts. Extra optional fields are encouraged.\n *\n * Used both as runtime values (spread into `ToolSet`s for inspection) and as\n * a vocabulary source — `HarnessV1BuiltinToolName` is derived from its keys.\n */\nexport const HARNESS_V1_BUILTIN_TOOLS = {\n read: tool({\n description: 'Read file contents',\n inputSchema: z.object({ file_path: z.string() }),\n outputSchema: z.unknown(),\n }),\n write: tool({\n description: 'Write content to a file',\n inputSchema: z.object({ file_path: z.string(), content: z.string() }),\n outputSchema: z.unknown(),\n }),\n edit: tool({\n description: 'Edit a file by replacing text',\n inputSchema: z.object({\n file_path: z.string(),\n old_string: z.string(),\n new_string: z.string(),\n }),\n outputSchema: z.unknown(),\n }),\n bash: tool({\n description: 'Execute a shell command',\n inputSchema: z.object({ command: z.string() }),\n outputSchema: z.unknown(),\n }),\n grep: tool({\n description: 'Search file contents with regex',\n inputSchema: z.object({ pattern: z.string() }),\n outputSchema: z.unknown(),\n }),\n glob: tool({\n description: 'Find files matching a glob pattern',\n inputSchema: z.object({ pattern: z.string() }),\n outputSchema: z.unknown(),\n }),\n webSearch: tool({\n description: 'Search the web',\n inputSchema: z.object({ query: z.string() }),\n outputSchema: z.unknown(),\n }),\n} as const;\n\nexport type HarnessV1BuiltinToolName = keyof typeof HARNESS_V1_BUILTIN_TOOLS;\n\nexport const HARNESS_V1_BUILTIN_TOOL_NAMES = Object.keys(\n HARNESS_V1_BUILTIN_TOOLS,\n) as ReadonlyArray<HarnessV1BuiltinToolName>;\n\nexport type HarnessV1BuiltinToolUseKind = 'readonly' | 'edit' | 'bash';\n\n/**\n * A tool that the adapter's underlying runtime exposes natively. Extends the\n * AI SDK `Tool` shape with two optional harness-specific fields:\n *\n * - `nativeName`: the name as the underlying runtime knows it. Required\n * only when the tool's key in the harness's `builtinTools` is not the\n * native name — i.e. when the tool maps to a `commonName` (e.g. key\n * `'bash'` for Claude Code's native `'Bash'`). Tools without a common\n * equivalent are keyed by their native name directly, so `nativeName`\n * is redundant and omitted.\n * - `commonName`: cross-harness label drawn from\n * `HARNESS_V1_BUILTIN_TOOL_NAMES`. Set when the tool maps to a familiar\n * capability; consumers use it to recognize, e.g., that Claude Code's\n * `Bash` and Codex's `shell` are the same kind of tool.\n *\n * Always set both fields together via the `commonTool` helper, or neither\n * (declare the tool with the AI SDK's `tool()` directly).\n */\nexport type HarnessV1BuiltinTool<INPUT = unknown, OUTPUT = unknown> = Tool<\n INPUT,\n OUTPUT,\n any\n> & {\n readonly nativeName?: string;\n readonly commonName?: HarnessV1BuiltinToolName;\n readonly toolUseKind?: HarnessV1BuiltinToolUseKind;\n};\n\ntype InputOf<T> = T extends Tool<infer I, any, any> ? I : never;\n\ntype StandardInputOf<N extends HarnessV1BuiltinToolName> = InputOf<\n (typeof HARNESS_V1_BUILTIN_TOOLS)[N]\n>;\n\n/*\n * Type-level superset check. If `TStandard` is assignable to `TAdapter`\n * (i.e. the adapter accepts every input the standard accepts), the return\n * type is `TOk`. Otherwise it's a tagged error tuple that surfaces a clear\n * TypeScript error at the call site.\n */\ntype SupersetCheck<TStandard, TAdapter, TOk> = TStandard extends TAdapter\n ? TOk\n : [\n 'ERROR: adapter input schema must be a superset of the standard schema',\n { expected: TStandard; got: TAdapter },\n ];\n\n/**\n * Declare a built-in tool that maps to a cross-harness common name. The\n * adapter's input schema must accept every input the standard schema for\n * `commonName` accepts. Extra optional fields are encouraged.\n *\n * If the schema is missing a field the standard requires (or has an\n * incompatible type), the return type collapses to a tagged error tuple,\n * which fails the surrounding `as const satisfies ToolSet` assignment and\n * surfaces a readable TypeScript error at the offending entry.\n */\nexport function commonTool<TName extends HarnessV1BuiltinToolName, TInput>(\n commonName: TName,\n opts: {\n readonly nativeName: string;\n readonly toolUseKind?: HarnessV1BuiltinToolUseKind;\n readonly description?: string;\n readonly inputSchema: FlexibleSchema<TInput>;\n },\n): SupersetCheck<StandardInputOf<TName>, TInput, HarnessV1BuiltinTool<TInput>> {\n return {\n ...tool({\n description: opts.description,\n inputSchema: opts.inputSchema as FlexibleSchema<TInput>,\n }),\n nativeName: opts.nativeName,\n commonName,\n toolUseKind: opts.toolUseKind,\n } as never;\n}\n","import type {\n JSONValue,\n LanguageModelV4FinishReason,\n LanguageModelV4ToolApprovalRequest,\n LanguageModelV4ToolCall,\n LanguageModelV4ToolResult,\n LanguageModelV4Usage,\n SharedV4ProviderMetadata,\n} from '@ai-sdk/provider';\nimport { z } from 'zod/v4';\nimport type { HarnessV1CallWarning } from './harness-v1-call-warning';\nimport type { HarnessV1Metadata } from './harness-v1-metadata';\n\n/**\n * One event emitted by a harness adapter during a prompt turn.\n *\n * Mirrors `LanguageModelV4StreamPart` on the variants it shares so a\n * `HarnessAgent` can pipe events through to AI SDK consumers with minimal\n * translation. Primitive types from the V4 spec (`LanguageModelV4ToolCall`,\n * `LanguageModelV4ToolResult`, `LanguageModelV4ToolApprovalRequest`,\n * `LanguageModelV4Usage`, `LanguageModelV4FinishReason`) are reused\n * verbatim — type-compat tests assert this stays the case.\n *\n * The metadata field is named `harnessMetadata` (not `providerMetadata`)\n * because a harness is a peer to a provider, not a kind of provider. The\n * agent rebinds it when forwarding to AI SDK consumers.\n */\nexport type HarnessV1StreamPart =\n | {\n type: 'stream-start';\n warnings?: ReadonlyArray<HarnessV1CallWarning>;\n /**\n * The model the runtime actually resolved to for this turn, when the\n * adapter learns it at stream start (e.g. Claude Code's `init` message\n * reports the resolved/default model). Surfaced into telemetry as\n * `gen_ai.request.model`. Omitted when the adapter doesn't know it here.\n */\n modelId?: string;\n }\n\n // Text blocks\n | { type: 'text-start'; id: string; harnessMetadata?: HarnessV1Metadata }\n | {\n type: 'text-delta';\n id: string;\n delta: string;\n harnessMetadata?: HarnessV1Metadata;\n }\n | { type: 'text-end'; id: string; harnessMetadata?: HarnessV1Metadata }\n\n // Reasoning blocks\n | { type: 'reasoning-start'; id: string; harnessMetadata?: HarnessV1Metadata }\n | {\n type: 'reasoning-delta';\n id: string;\n delta: string;\n harnessMetadata?: HarnessV1Metadata;\n }\n | { type: 'reasoning-end'; id: string; harnessMetadata?: HarnessV1Metadata }\n\n // Tool calls, approvals, results — reuse V4 primitives.\n //\n // `nativeName` is the only harness-only extension on `tool-call`. It lets\n // adapters surface the runtime's native name for a builtin when it differs\n // from the wire `toolName` (e.g. `toolName: 'bash'`, `nativeName: 'Bash'`).\n //\n // Whether the call was executed by the underlying runtime (Claude Code's\n // built-in `Bash`, Codex's `shell`) vs. needs host dispatch is signalled by\n // the standard `providerExecuted` field on `LanguageModelV4ToolCall` —\n // `true` for runtime-executed builtins, false/undefined for host tools.\n | (LanguageModelV4ToolCall & {\n nativeName?: string;\n })\n | LanguageModelV4ToolApprovalRequest\n | LanguageModelV4ToolResult\n\n // Step boundary inside a multi-step turn.\n | {\n type: 'finish-step';\n finishReason: LanguageModelV4FinishReason;\n usage: LanguageModelV4Usage;\n harnessMetadata?: HarnessV1Metadata;\n }\n\n // Turn end.\n | {\n type: 'finish';\n finishReason: LanguageModelV4FinishReason;\n totalUsage: LanguageModelV4Usage;\n harnessMetadata?: HarnessV1Metadata;\n }\n\n // Workspace file mutation that occurred through an opaque underlying\n // mechanism (one with no visible `tool-call` carrying the same data, e.g.\n // Codex's internal `apply_patch`). Emitted per changed path. Path-only by\n // design — when the mutation goes through a visible tool call, the\n // tool-call/tool-result pair already carries the information.\n | {\n type: 'file-change';\n event: 'create' | 'modify' | 'delete';\n path: string;\n harnessMetadata?: HarnessV1Metadata;\n }\n\n // Context compaction performed by the underlying runtime (Claude Code's\n // native compaction, Pi's summarization). Observation only — the runtime\n // owns the compaction; the harness neither implements nor schedules it.\n // Emitted once, on completion, since `summary`/`tokensAfter` only exist then.\n | {\n type: 'compaction';\n trigger: 'manual' | 'auto';\n summary: string;\n tokensBefore?: number;\n tokensAfter?: number;\n harnessMetadata?: HarnessV1Metadata;\n }\n\n // Errors. Multiple may be emitted in a single turn.\n | { type: 'error'; error: unknown }\n\n // Adapter-specific passthrough. Consumers can opt in to receive these via\n // `HarnessAgent` settings; otherwise they are dropped.\n | { type: 'raw'; rawValue: unknown };\n\n/*\n * Runtime (Zod) encoding of `HarnessV1StreamPart`.\n *\n * `HarnessV1StreamPart` is a compile-time type built on `LanguageModelV4*`\n * types that ship no runtime validator. Bridge adapters receive these parts as\n * JSON across a trust boundary (the sandbox WebSocket), so they need a runtime\n * schema. These schemas ARE that encoding — one source of truth, kept from\n * diverging from the type by the `_assignable` guard below and the mutual\n * `toEqualTypeOf` assertion in `harness-v1-stream-part.test-d.ts`.\n *\n * Members are exported individually so `harness-v1-bridge-protocol.ts` can\n * compose them into the bridge outbound union alongside the transport frames.\n */\n\nconst harnessV1JsonValueSchema: z.ZodType<JSONValue> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(harnessV1JsonValueSchema),\n z.record(z.string(), harnessV1JsonValueSchema),\n ]),\n);\n\n/*\n * Tool-result values. The inferred type is the spec's `NonNullable<JSONValue>`\n * (matching `LanguageModelV4ToolResult`), but the runtime validator\n * deliberately also accepts `null`: adapters emit `result: <value> ?? null` for\n * tools that produced no output, and that `null` must survive the trust\n * boundary unchanged (it reaches consumers exactly as it did before this schema\n * existed, when a cast hid it). Leniency at runtime, strictness in the type.\n */\nconst harnessV1ToolResultValueSchema =\n harnessV1JsonValueSchema as unknown as z.ZodType<NonNullable<JSONValue>>;\n\nconst harnessV1JsonObjectSchema = z.record(\n z.string(),\n harnessV1JsonValueSchema,\n) as unknown as z.ZodType<Record<string, JSONValue>>;\n\nconst harnessV1MetadataSchema = z.record(\n z.string(),\n z.record(z.string(), harnessV1JsonValueSchema),\n) as unknown as z.ZodType<HarnessV1Metadata>;\n\nconst harnessV1ProviderMetadataSchema = z.record(\n z.string(),\n z.record(z.string(), harnessV1JsonValueSchema),\n) as unknown as z.ZodType<SharedV4ProviderMetadata>;\n\nconst harnessV1CallWarningSchema = z.union([\n z.object({\n type: z.literal('unsupported-setting'),\n setting: z.string(),\n details: z.string().optional(),\n }),\n z.object({\n type: z.literal('unsupported-tool'),\n tool: z.string(),\n details: z.string().optional(),\n }),\n z.object({ type: z.literal('other'), message: z.string() }),\n]) as z.ZodType<HarnessV1CallWarning>;\n\nconst harnessV1UsageSchema = z.object({\n inputTokens: z.object({\n total: z.number().optional(),\n noCache: z.number().optional(),\n cacheRead: z.number().optional(),\n cacheWrite: z.number().optional(),\n }),\n outputTokens: z.object({\n total: z.number().optional(),\n text: z.number().optional(),\n reasoning: z.number().optional(),\n }),\n raw: harnessV1JsonObjectSchema.optional(),\n}) as unknown as z.ZodType<LanguageModelV4Usage>;\n\nconst harnessV1FinishReasonSchema = z.object({\n unified: z.enum([\n 'stop',\n 'length',\n 'content-filter',\n 'tool-calls',\n 'error',\n 'other',\n ]),\n raw: z.string().optional(),\n}) as unknown as z.ZodType<LanguageModelV4FinishReason>;\n\nexport const harnessV1StreamStartPartSchema = z.object({\n type: z.literal('stream-start'),\n warnings: z.array(harnessV1CallWarningSchema).readonly().optional(),\n modelId: z.string().optional(),\n});\n\nexport const harnessV1TextStartPartSchema = z.object({\n type: z.literal('text-start'),\n id: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1TextDeltaPartSchema = z.object({\n type: z.literal('text-delta'),\n id: z.string(),\n delta: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1TextEndPartSchema = z.object({\n type: z.literal('text-end'),\n id: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1ReasoningStartPartSchema = z.object({\n type: z.literal('reasoning-start'),\n id: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1ReasoningDeltaPartSchema = z.object({\n type: z.literal('reasoning-delta'),\n id: z.string(),\n delta: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1ReasoningEndPartSchema = z.object({\n type: z.literal('reasoning-end'),\n id: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1ToolCallPartSchema = z.object({\n type: z.literal('tool-call'),\n toolCallId: z.string(),\n toolName: z.string(),\n input: z.string(),\n providerExecuted: z.boolean().optional(),\n dynamic: z.boolean().optional(),\n providerMetadata: harnessV1ProviderMetadataSchema.optional(),\n nativeName: z.string().optional(),\n});\n\nexport const harnessV1ToolApprovalRequestPartSchema = z.object({\n type: z.literal('tool-approval-request'),\n approvalId: z.string(),\n toolCallId: z.string(),\n providerMetadata: harnessV1ProviderMetadataSchema.optional(),\n});\n\nexport const harnessV1ToolResultPartSchema = z.object({\n type: z.literal('tool-result'),\n toolCallId: z.string(),\n toolName: z.string(),\n result: harnessV1ToolResultValueSchema,\n isError: z.boolean().optional(),\n preliminary: z.boolean().optional(),\n dynamic: z.boolean().optional(),\n providerMetadata: harnessV1ProviderMetadataSchema.optional(),\n});\n\nexport const harnessV1FinishStepPartSchema = z.object({\n type: z.literal('finish-step'),\n finishReason: harnessV1FinishReasonSchema,\n usage: harnessV1UsageSchema,\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1FinishPartSchema = z.object({\n type: z.literal('finish'),\n finishReason: harnessV1FinishReasonSchema,\n totalUsage: harnessV1UsageSchema,\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1FileChangePartSchema = z.object({\n type: z.literal('file-change'),\n event: z.enum(['create', 'modify', 'delete']),\n path: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1CompactionPartSchema = z.object({\n type: z.literal('compaction'),\n trigger: z.enum(['manual', 'auto']),\n summary: z.string(),\n tokensBefore: z.number().optional(),\n tokensAfter: z.number().optional(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1ErrorPartSchema = z.object({\n type: z.literal('error'),\n error: z.unknown(),\n});\n\nexport const harnessV1RawPartSchema = z.object({\n type: z.literal('raw'),\n rawValue: z.unknown(),\n});\n\n/**\n * Assembled discriminated union over every `HarnessV1StreamPart` variant. Left\n * un-annotated so it keeps its precise inferred type — the protocol layer\n * composes the individual member schemas, and the type test asserts the\n * inferred union equals `HarnessV1StreamPart`.\n */\nexport const harnessV1StreamPartSchema = z.discriminatedUnion('type', [\n harnessV1StreamStartPartSchema,\n harnessV1TextStartPartSchema,\n harnessV1TextDeltaPartSchema,\n harnessV1TextEndPartSchema,\n harnessV1ReasoningStartPartSchema,\n harnessV1ReasoningDeltaPartSchema,\n harnessV1ReasoningEndPartSchema,\n harnessV1ToolCallPartSchema,\n harnessV1ToolApprovalRequestPartSchema,\n harnessV1ToolResultPartSchema,\n harnessV1FinishStepPartSchema,\n harnessV1FinishPartSchema,\n harnessV1FileChangePartSchema,\n harnessV1CompactionPartSchema,\n harnessV1ErrorPartSchema,\n harnessV1RawPartSchema,\n]);\n\n/*\n * Fail-fast guard at the definition site: the schema's output must be\n * assignable to `HarnessV1StreamPart` (catches a schema variant inventing a\n * shape the type does not allow). The reverse direction — the type being a\n * subset of the schema — is covered by the `toEqualTypeOf` assertion in the\n * type test.\n */\nconst _assignable: z.ZodType<HarnessV1StreamPart> = harnessV1StreamPartSchema;\nvoid _assignable;\n","import { z } from 'zod/v4';\nimport {\n harnessV1DebugConfigSchema,\n harnessV1DebugLevelSchema,\n type HarnessV1Diagnostic,\n} from './harness-v1-diagnostic';\nimport {\n harnessV1CompactionPartSchema,\n harnessV1ErrorPartSchema,\n harnessV1FileChangePartSchema,\n harnessV1FinishPartSchema,\n harnessV1FinishStepPartSchema,\n harnessV1RawPartSchema,\n harnessV1ReasoningDeltaPartSchema,\n harnessV1ReasoningEndPartSchema,\n harnessV1ReasoningStartPartSchema,\n harnessV1StreamStartPartSchema,\n harnessV1TextDeltaPartSchema,\n harnessV1TextEndPartSchema,\n harnessV1TextStartPartSchema,\n harnessV1ToolApprovalRequestPartSchema,\n harnessV1ToolCallPartSchema,\n harnessV1ToolResultPartSchema,\n} from './harness-v1-stream-part';\n\n/*\n * The bridge wire protocol shared by every bridge-backed harness adapter.\n *\n * This is the serialization of the host<->runtime contract for adapters that\n * run the agent runtime inside the sandbox and talk to the host over a\n * WebSocket. It exists ONLY because of that transport: untrusted JSON frames\n * crossing the sandbox boundary need runtime validation, the connection needs\n * a handshake, and the host drives turns with serialized commands. Every export\n * here is therefore prefixed `harnessV1Bridge…`.\n *\n * It has three tiers:\n *\n * 1. The OUTBOUND events — `HarnessV1StreamPart` re-expressed as Zod (imported\n * member schemas from `harness-v1-stream-part.ts`), because the part type is\n * compile-time only and the frames need runtime validation at the boundary.\n * 2. The transport/control frames that are NOT consumer events — `bridge-hello`\n * (handshake), `bridge-stop` (runtime resume data), `bridge-thread` (a resume\n * coordinate some runtimes announce). These ride the same socket.\n * 3. The INBOUND command vocabulary the host sends back: the shared commands\n * live here; the per-adapter `start` payload extends\n * `harnessV1BridgeStartBaseSchema` and assembles the final inbound union in\n * the adapter package.\n *\n * Non-bridge adapters (e.g. Pi) do not use this layer at all — they have no\n * serialization boundary and target the universal `HarnessV1StreamPart` type\n * directly. That is the deliberate split: `harness-v1-stream-part.ts` is the\n * transport-agnostic event vocabulary; this file is the bridge transport.\n */\n\n/**\n * The subset of a host-defined tool that travels on the `start` message. The\n * runtime only needs the name, description, and JSON-Schema input to surface\n * the tool; `execute` stays on the host.\n */\nexport const harnessV1BridgeToolWireSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n inputSchema: z.unknown().optional(),\n});\n\nexport type HarnessV1BridgeToolWire = z.infer<\n typeof harnessV1BridgeToolWireSchema\n>;\n\nexport const harnessV1BridgePermissionModeSchema = z.enum([\n 'allow-reads',\n 'allow-edits',\n 'allow-all',\n]);\n\nexport const harnessV1BridgeBuiltinToolFilteringSchema = z.discriminatedUnion(\n 'mode',\n [\n z.object({\n mode: z.literal('allow'),\n toolNames: z.array(z.string()),\n }),\n z.object({\n mode: z.literal('deny'),\n toolNames: z.array(z.string()),\n }),\n ],\n);\n\n/**\n * Common fields of the inbound `start` message. Each adapter extends this with\n * its runtime-specific configuration (e.g. `thinking`/`continue` for Claude\n * Code, `reasoningEffort`/`webSearch`/`skills`/`resumeThreadId` for Codex) and\n * assembles the final inbound union from the shared command members below.\n *\n * `debug` carries the general `HarnessV1DebugConfig` — diagnostics config is not\n * a bridge concept, it just happens to ride the `start` frame for bridge-backed\n * adapters.\n */\nexport const harnessV1BridgeStartBaseSchema = z.object({\n type: z.literal('start'),\n prompt: z.string(),\n tools: z.array(harnessV1BridgeToolWireSchema).optional(),\n model: z.string().optional(),\n debug: harnessV1DebugConfigSchema.optional(),\n permissionMode: harnessV1BridgePermissionModeSchema.optional(),\n builtinToolFiltering: harnessV1BridgeBuiltinToolFilteringSchema.optional(),\n});\n\n// --- Transport / control frames (outbound, not consumer events) ---\n\n/**\n * Sent the instant the bridge accepts an authenticated WS connection. The host\n * waits for it before sending `start`/`resume`, because some sandbox runtimes\n * complete the upstream WS handshake before the connection is wired through to\n * the bridge process — anything sent in that gap is dropped. Carries the\n * bridge's lifecycle `state` and highest emitted `seq` for reconnect.\n */\nexport const harnessV1BridgeHelloSchema = z.object({\n type: z.literal('bridge-hello'),\n state: z.string().optional(),\n lastSeq: z.number().optional(),\n});\n\n/**\n * The bridge's reply to an inbound `stop`. Carries the adapter-specific\n * payload the host serializes into lifecycle state `data`.\n */\nexport const harnessV1BridgeStopSchema = z.object({\n type: z.literal('bridge-stop'),\n data: z.unknown(),\n});\n\n/**\n * A resume coordinate the bridge proactively announces (e.g. Codex's thread id)\n * so the host can cache it for a later resume without waiting for `stop`.\n */\nexport const harnessV1BridgeThreadSchema = z.object({\n type: z.literal('bridge-thread'),\n threadId: z.string(),\n});\n\n// --- Diagnostics frames (outbound, not consumer events) ---\n\n/**\n * One captured console line from inside the sandbox. The bridge line-buffers\n * `process.stdout`/`process.stderr` and emits one of these per complete line.\n * Routed host-side to the diagnostics sink, never to the consumer stream.\n */\nexport const harnessV1BridgeSandboxLogSchema = z.object({\n type: z.literal('sandbox-log'),\n source: z.string(),\n stream: z.enum(['stdout', 'stderr']),\n line: z.string(),\n});\n\n/**\n * A structured diagnostic an adapter emits from inside the bridge via\n * `turn.bridgeLog(...)`. Gated by the session's debug level + subsystem filter.\n */\nexport const harnessV1BridgeDebugEventSchema = z.object({\n type: z.literal('debug-event'),\n level: harnessV1DebugLevelSchema,\n subsystem: z.string(),\n message: z.string(),\n attrs: z.record(z.string(), z.unknown()).optional(),\n error: z\n .object({\n name: z.string().optional(),\n message: z.string(),\n stack: z.string().optional(),\n })\n .optional(),\n});\n\n/**\n * Every frame a bridge can send to the host: the stream-part events plus the\n * transport/control frames. This is the schema the host `SandboxChannel`\n * validates inbound frames against.\n */\nexport const harnessV1BridgeOutboundMessageSchema = z.discriminatedUnion(\n 'type',\n [\n harnessV1StreamStartPartSchema,\n harnessV1TextStartPartSchema,\n harnessV1TextDeltaPartSchema,\n harnessV1TextEndPartSchema,\n harnessV1ReasoningStartPartSchema,\n harnessV1ReasoningDeltaPartSchema,\n harnessV1ReasoningEndPartSchema,\n harnessV1ToolCallPartSchema,\n harnessV1ToolApprovalRequestPartSchema,\n harnessV1ToolResultPartSchema,\n harnessV1FinishStepPartSchema,\n harnessV1FinishPartSchema,\n harnessV1FileChangePartSchema,\n harnessV1CompactionPartSchema,\n harnessV1ErrorPartSchema,\n harnessV1RawPartSchema,\n harnessV1BridgeHelloSchema,\n harnessV1BridgeStopSchema,\n harnessV1BridgeThreadSchema,\n harnessV1BridgeSandboxLogSchema,\n harnessV1BridgeDebugEventSchema,\n ],\n);\n\nexport type HarnessV1BridgeOutboundMessage = z.infer<\n typeof harnessV1BridgeOutboundMessageSchema\n>;\n\nexport type HarnessV1BridgeSandboxLog = z.infer<\n typeof harnessV1BridgeSandboxLogSchema\n>;\n\nexport type HarnessV1BridgeDebugEvent = z.infer<\n typeof harnessV1BridgeDebugEventSchema\n>;\n\n/**\n * Normalize a bridge diagnostics wire frame into the transport-agnostic\n * `HarnessV1Diagnostic` an adapter reports to the framework. A captured console\n * line maps `stderr` → `warn` and `stdout` → `info`; a structured event passes\n * its fields through. This is the seam where the bridge's serialization is\n * lifted into the general emission shape every harness shares.\n */\nexport function harnessV1DiagnosticFromBridgeFrame(\n frame: HarnessV1BridgeSandboxLog | HarnessV1BridgeDebugEvent,\n context: { sessionId?: string; timestamp: number },\n): HarnessV1Diagnostic {\n if (frame.type === 'sandbox-log') {\n return {\n level: frame.stream === 'stderr' ? 'warn' : 'info',\n message: frame.line,\n subsystem: `sandbox.log.${frame.source}`,\n kind: 'log',\n source: frame.source,\n stream: frame.stream,\n sessionId: context.sessionId,\n timestamp: context.timestamp,\n };\n }\n return {\n level: frame.level,\n message: frame.message,\n subsystem: frame.subsystem,\n kind: 'event',\n attrs: frame.attrs,\n error: frame.error,\n sessionId: context.sessionId,\n timestamp: context.timestamp,\n };\n}\n\n// --- Shared inbound command members (host -> bridge) ---\n\nexport const harnessV1BridgeToolResultInboundSchema = z.object({\n type: z.literal('tool-result'),\n toolCallId: z.string(),\n output: z.unknown(),\n isError: z.boolean().optional(),\n});\n\nexport const harnessV1BridgeToolApprovalResponseInboundSchema = z.object({\n type: z.literal('tool-approval-response'),\n approvalId: z.string(),\n approved: z.boolean(),\n reason: z.string().optional(),\n});\n\nexport const harnessV1BridgeUserMessageInboundSchema = z.object({\n type: z.literal('user-message'),\n text: z.string(),\n});\n\nexport const harnessV1BridgeAbortInboundSchema = z.object({\n type: z.literal('abort'),\n});\n\nexport const harnessV1BridgeDestroyInboundSchema = z.object({\n type: z.literal('destroy'),\n});\n\n/**\n * Reconnect: after re-establishing the socket the host asks the bridge to\n * replay every buffered event with `seq > lastSeenEventId`.\n */\nexport const harnessV1BridgeResumeInboundSchema = z.object({\n type: z.literal('resume'),\n lastSeenEventId: z.number(),\n});\n\n/**\n * The bridge replies with `bridge-stop` carrying any runtime resume data,\n * then exits.\n */\nexport const harnessV1BridgeStopInboundSchema = z.object({\n type: z.literal('stop'),\n});\n\n/**\n * The inbound command members shared by every bridge adapter. Spread these\n * alongside the adapter's own `start` schema to build the final inbound union:\n * `z.discriminatedUnion('type', [adapterStartSchema, ...harnessV1BridgeInboundCommandSchemas])`.\n */\nexport const harnessV1BridgeInboundCommandSchemas = [\n harnessV1BridgeToolResultInboundSchema,\n harnessV1BridgeToolApprovalResponseInboundSchema,\n harnessV1BridgeUserMessageInboundSchema,\n harnessV1BridgeAbortInboundSchema,\n harnessV1BridgeDestroyInboundSchema,\n harnessV1BridgeResumeInboundSchema,\n harnessV1BridgeStopInboundSchema,\n] as const;\n\n/**\n * The JSON line the bridge writes to stdout once its WebSocket server is bound,\n * announcing the port the host should connect to.\n */\nexport const harnessV1BridgeReadySchema = z.object({\n type: z.literal('bridge-ready'),\n port: z.number(),\n});\n\nexport type HarnessV1BridgeReady = z.infer<typeof harnessV1BridgeReadySchema>;\n","import { z } from 'zod/v4';\n\n/*\n * Diagnostics EMISSION contract — part of the `HarnessV1` spec.\n *\n * These are the types a harness adapter produces and receives: an adapter\n * reports a `HarnessV1Diagnostic` to the framework (a bridge adapter normalizes\n * its wire frames into one; a non-bridge adapter constructs one directly), and\n * receives a `HarnessV1DebugConfig` to gate what it emits. They are distinct\n * from the unaffixed host-facing `HarnessDiagnostic` / `HarnessDebugConfig`\n * (the external/telemetry surface) — the framework maps between the two at the\n * boundary, so the emission and consumption surfaces can evolve independently.\n */\n\n/** Severity of a diagnostic, ordered most → least severe. */\nexport const harnessV1DebugLevelSchema = z.enum([\n 'error',\n 'warn',\n 'info',\n 'debug',\n 'trace',\n]);\n\nexport type HarnessV1DebugLevel = z.infer<typeof harnessV1DebugLevelSchema>;\n\n/**\n * Per-session diagnostics configuration the framework hands an adapter (and the\n * host sends on `start.debug`). When absent or `enabled` is false the adapter\n * captures and emits nothing. `subsystems` filters structured events by dotted\n * prefix; console capture is independent of the subsystem filter.\n */\nexport const harnessV1DebugConfigSchema = z.object({\n enabled: z.boolean().optional(),\n level: harnessV1DebugLevelSchema.optional(),\n subsystems: z.array(z.string()).optional(),\n});\n\nexport type HarnessV1DebugConfig = z.infer<typeof harnessV1DebugConfigSchema>;\n\n/**\n * A diagnostic as emitted by a harness adapter. Structurally identical to the\n * host-facing `HarnessDiagnostic` today, but kept separate: this is the spec's\n * emission shape, that is the external consumption shape.\n */\nexport type HarnessV1Diagnostic = {\n /** Severity. */\n readonly level: HarnessV1DebugLevel;\n /** Human-readable line (console capture) or message (structured event). */\n readonly message: string;\n /** Dotted subsystem (`sandbox.log.<source>` for console capture). */\n readonly subsystem: string;\n /** `'log'` = captured console line; `'event'` = structured emission. */\n readonly kind: 'log' | 'event';\n /** Originating source label (console capture). */\n readonly source?: string;\n /** Which standard stream the line came from (console capture). */\n readonly stream?: 'stdout' | 'stderr';\n /** Structured attributes (structured events only). */\n readonly attrs?: Record<string, unknown>;\n /** Error payload (structured events only). */\n readonly error?: { name?: string; message: string; stack?: string };\n /** The harness session this diagnostic originated from. */\n readonly sessionId?: string;\n /** Emission time (epoch ms). */\n readonly timestamp: number;\n};\n","export type HarnessV1BuiltinToolFiltering =\n | {\n mode: 'allow';\n toolNames: string[];\n }\n | {\n mode: 'deny';\n toolNames: string[];\n };\n\nexport function isHarnessV1BuiltinToolIncluded(input: {\n toolName: string;\n toolFiltering: HarnessV1BuiltinToolFiltering | undefined;\n}): boolean {\n if (input.toolFiltering == null) return true;\n return input.toolFiltering.mode === 'allow'\n ? input.toolFiltering.toolNames.includes(input.toolName)\n : !input.toolFiltering.toolNames.includes(input.toolName);\n}\n\nexport function getHarnessV1BuiltinToolFilteringDenialReason(input: {\n toolName: string;\n}): string {\n return `Tool '${input.toolName}' is inactive due to the HarnessAgent tool filtering policy.`;\n}\n","import { AISDKError } from '@ai-sdk/provider';\n\nconst name = 'AI_HarnessError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Base error type for failures originating in or signalled by a harness\n * adapter. Specific failure modes (e.g. unsupported capability) extend this\n * class.\n */\nexport class HarnessError extends AISDKError {\n private readonly [symbol] = true;\n\n constructor({ message, cause }: { message: string; cause?: unknown }) {\n super({ name, message, cause });\n }\n\n static isInstance(error: unknown): error is HarnessError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from '@ai-sdk/provider';\nimport { HarnessError } from './harness-error';\n\nconst name = 'AI_HarnessCapabilityUnsupportedError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown when a caller asks the harness to do something the adapter (or the\n * supplied sandbox) does not support, e.g. requesting manual compaction from\n * an adapter that only auto-compacts, or invoking `getPortEndpoint` on a\n * sandbox that does not expose one.\n *\n * The caller supplies the full human-readable message. Optional `harnessId`\n * is recorded as structured context for tooling.\n */\nexport class HarnessCapabilityUnsupportedError extends HarnessError {\n private readonly [symbol] = true;\n\n readonly harnessId?: string;\n\n constructor({\n message,\n harnessId,\n cause,\n }: {\n message: string;\n harnessId?: string;\n cause?: unknown;\n }) {\n super({ message, cause });\n Object.defineProperty(this, 'name', { value: name });\n this.harnessId = harnessId;\n }\n\n static isInstance(\n error: unknown,\n ): error is HarnessCapabilityUnsupportedError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from '@ai-sdk/provider';\nimport { HarnessError } from './harness-error';\n\nconst name = 'AI_HarnessSandboxAuthenticationError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown when a sandbox provider cannot authenticate or authorize the\n * operation needed to create or resume a harness sandbox. Providers should\n * preserve the underlying SDK failure as `cause` and supply a message that\n * explains how the consumer can configure credentials.\n */\nexport class HarnessSandboxAuthenticationError extends HarnessError {\n private readonly [symbol] = true;\n\n readonly sandboxProviderId: string;\n\n constructor({\n message,\n sandboxProviderId,\n cause,\n }: {\n message: string;\n sandboxProviderId: string;\n cause?: unknown;\n }) {\n super({ message, cause });\n Object.defineProperty(this, 'name', { value: name });\n this.sandboxProviderId = sandboxProviderId;\n }\n\n static isInstance(\n error: unknown,\n ): error is HarnessSandboxAuthenticationError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n"],"mappings":";AAAA,SAAS,YAA4C;AACrD,SAAS,SAAS;AAWX,IAAM,2BAA2B;AAAA,EACtC,MAAM,KAAK;AAAA,IACT,aAAa;AAAA,IACb,aAAa,EAAE,O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symbol","_a","_b","AISDKError"]}
|
|
1
|
+
{"version":3,"sources":["../src/v1/harness-v1-builtin-tool.ts","../src/v1/harness-v1-stream-part.ts","../src/v1/harness-v1-bridge-protocol.ts","../src/v1/harness-v1-diagnostic.ts","../src/v1/harness-v1-tool-filtering.ts","../src/errors/harness-error.ts","../src/errors/harness-capability-unsupported-error.ts","../src/errors/harness-sandbox-authentication-error.ts"],"sourcesContent":["import { tool, type FlexibleSchema, type Tool } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n/**\n * Cross-harness vocabulary of common built-in tool names with their baseline\n * input schemas. Adapters that declare a built-in with one of these\n * `commonName`s must accept (at least) every input the baseline schema\n * accepts. Extra optional fields are encouraged.\n *\n * Used both as runtime values (spread into `ToolSet`s for inspection) and as\n * a vocabulary source — `HarnessV1BuiltinToolName` is derived from its keys.\n */\nexport const HARNESS_V1_BUILTIN_TOOLS = {\n read: tool({\n description: 'Read file contents',\n inputSchema: z.object({ file_path: z.string() }),\n outputSchema: z.unknown(),\n }),\n write: tool({\n description: 'Write content to a file',\n inputSchema: z.object({ file_path: z.string(), content: z.string() }),\n outputSchema: z.unknown(),\n }),\n edit: tool({\n description: 'Edit a file by replacing text',\n inputSchema: z.object({\n file_path: z.string(),\n old_string: z.string(),\n new_string: z.string(),\n }),\n outputSchema: z.unknown(),\n }),\n bash: tool({\n description: 'Execute a shell command',\n inputSchema: z.object({ command: z.string() }),\n outputSchema: z.unknown(),\n }),\n grep: tool({\n description: 'Search file contents with regex',\n inputSchema: z.object({ pattern: z.string() }),\n outputSchema: z.unknown(),\n }),\n glob: tool({\n description: 'Find files matching a glob pattern',\n inputSchema: z.object({ pattern: z.string() }),\n outputSchema: z.unknown(),\n }),\n webSearch: tool({\n description: 'Search the web',\n inputSchema: z.object({ query: z.string() }),\n outputSchema: z.unknown(),\n }),\n} as const;\n\nexport type HarnessV1BuiltinToolName = keyof typeof HARNESS_V1_BUILTIN_TOOLS;\n\nexport const HARNESS_V1_BUILTIN_TOOL_NAMES = Object.keys(\n HARNESS_V1_BUILTIN_TOOLS,\n) as ReadonlyArray<HarnessV1BuiltinToolName>;\n\nexport type HarnessV1BuiltinToolUseKind = 'readonly' | 'edit' | 'bash';\n\n/**\n * A tool that the adapter's underlying runtime exposes natively. Extends the\n * AI SDK `Tool` shape with two optional harness-specific fields:\n *\n * - `nativeName`: the name as the underlying runtime knows it. Required\n * only when the tool's key in the harness's `builtinTools` is not the\n * native name — i.e. when the tool maps to a `commonName` (e.g. key\n * `'bash'` for Claude Code's native `'Bash'`). Tools without a common\n * equivalent are keyed by their native name directly, so `nativeName`\n * is redundant and omitted.\n * - `commonName`: cross-harness label drawn from\n * `HARNESS_V1_BUILTIN_TOOL_NAMES`. Set when the tool maps to a familiar\n * capability; consumers use it to recognize, e.g., that Claude Code's\n * `Bash` and Codex's `shell` are the same kind of tool.\n *\n * Always set both fields together via the `commonTool` helper, or neither\n * (declare the tool with the AI SDK's `tool()` directly).\n */\nexport type HarnessV1BuiltinTool<INPUT = unknown, OUTPUT = unknown> = Tool<\n INPUT,\n OUTPUT,\n any\n> & {\n readonly nativeName?: string;\n readonly commonName?: HarnessV1BuiltinToolName;\n readonly toolUseKind?: HarnessV1BuiltinToolUseKind;\n};\n\ntype InputOf<T> = T extends Tool<infer I, any, any> ? I : never;\n\ntype StandardInputOf<N extends HarnessV1BuiltinToolName> = InputOf<\n (typeof HARNESS_V1_BUILTIN_TOOLS)[N]\n>;\n\n/*\n * Type-level superset check. If `TStandard` is assignable to `TAdapter`\n * (i.e. the adapter accepts every input the standard accepts), the return\n * type is `TOk`. Otherwise it's a tagged error tuple that surfaces a clear\n * TypeScript error at the call site.\n */\ntype SupersetCheck<TStandard, TAdapter, TOk> = TStandard extends TAdapter\n ? TOk\n : [\n 'ERROR: adapter input schema must be a superset of the standard schema',\n { expected: TStandard; got: TAdapter },\n ];\n\n/**\n * Declare a built-in tool that maps to a cross-harness common name. The\n * adapter's input schema must accept every input the standard schema for\n * `commonName` accepts. Extra optional fields are encouraged.\n *\n * If the schema is missing a field the standard requires (or has an\n * incompatible type), the return type collapses to a tagged error tuple,\n * which fails the surrounding `as const satisfies ToolSet` assignment and\n * surfaces a readable TypeScript error at the offending entry.\n */\nexport function commonTool<TName extends HarnessV1BuiltinToolName, TInput>(\n commonName: TName,\n opts: {\n readonly nativeName: string;\n readonly toolUseKind?: HarnessV1BuiltinToolUseKind;\n readonly description?: string;\n readonly inputSchema: FlexibleSchema<TInput>;\n },\n): SupersetCheck<StandardInputOf<TName>, TInput, HarnessV1BuiltinTool<TInput>> {\n return {\n ...tool({\n description: opts.description,\n inputSchema: opts.inputSchema as FlexibleSchema<TInput>,\n }),\n nativeName: opts.nativeName,\n commonName,\n toolUseKind: opts.toolUseKind,\n } as never;\n}\n","import type {\n JSONValue,\n LanguageModelV4FinishReason,\n LanguageModelV4ToolApprovalRequest,\n LanguageModelV4ToolCall,\n LanguageModelV4ToolResult,\n LanguageModelV4Usage,\n SharedV4ProviderMetadata,\n} from '@ai-sdk/provider';\nimport { z } from 'zod/v4';\nimport type { HarnessV1CallWarning } from './harness-v1-call-warning';\nimport type { HarnessV1Metadata } from './harness-v1-metadata';\n\n/**\n * One event emitted by a harness adapter during a prompt turn.\n *\n * Mirrors `LanguageModelV4StreamPart` on the variants it shares so a\n * `HarnessAgent` can pipe events through to AI SDK consumers with minimal\n * translation. Primitive types from the V4 spec (`LanguageModelV4ToolCall`,\n * `LanguageModelV4ToolResult`, `LanguageModelV4ToolApprovalRequest`,\n * `LanguageModelV4Usage`, `LanguageModelV4FinishReason`) are reused\n * verbatim — type-compat tests assert this stays the case.\n *\n * The metadata field is named `harnessMetadata` (not `providerMetadata`)\n * because a harness is a peer to a provider, not a kind of provider. The\n * agent rebinds it when forwarding to AI SDK consumers.\n */\nexport type HarnessV1StreamPart =\n | {\n type: 'stream-start';\n warnings?: ReadonlyArray<HarnessV1CallWarning>;\n /**\n * The model the runtime actually resolved to for this turn, when the\n * adapter learns it at stream start (e.g. Claude Code's `init` message\n * reports the resolved/default model). Surfaced into telemetry as\n * `gen_ai.request.model`. Omitted when the adapter doesn't know it here.\n */\n modelId?: string;\n }\n\n // Text blocks\n | { type: 'text-start'; id: string; harnessMetadata?: HarnessV1Metadata }\n | {\n type: 'text-delta';\n id: string;\n delta: string;\n harnessMetadata?: HarnessV1Metadata;\n }\n | { type: 'text-end'; id: string; harnessMetadata?: HarnessV1Metadata }\n\n // Reasoning blocks\n | { type: 'reasoning-start'; id: string; harnessMetadata?: HarnessV1Metadata }\n | {\n type: 'reasoning-delta';\n id: string;\n delta: string;\n harnessMetadata?: HarnessV1Metadata;\n }\n | { type: 'reasoning-end'; id: string; harnessMetadata?: HarnessV1Metadata }\n\n // Tool calls, approvals, results — reuse V4 primitives.\n //\n // `nativeName` is the only harness-only extension on `tool-call`. It lets\n // adapters surface the runtime's native name for a builtin when it differs\n // from the wire `toolName` (e.g. `toolName: 'bash'`, `nativeName: 'Bash'`).\n //\n // Whether the call was executed by the underlying runtime (Claude Code's\n // built-in `Bash`, Codex's `shell`) vs. needs host dispatch is signalled by\n // the standard `providerExecuted` field on `LanguageModelV4ToolCall` —\n // `true` for runtime-executed builtins, false/undefined for host tools.\n | (LanguageModelV4ToolCall & {\n nativeName?: string;\n })\n | LanguageModelV4ToolApprovalRequest\n | LanguageModelV4ToolResult\n\n // Step boundary inside a multi-step turn.\n | {\n type: 'finish-step';\n finishReason: LanguageModelV4FinishReason;\n usage: LanguageModelV4Usage;\n harnessMetadata?: HarnessV1Metadata;\n }\n\n // Turn end.\n | {\n type: 'finish';\n finishReason: LanguageModelV4FinishReason;\n totalUsage: LanguageModelV4Usage;\n harnessMetadata?: HarnessV1Metadata;\n }\n\n // Workspace file mutation that occurred through an opaque underlying\n // mechanism (one with no visible `tool-call` carrying the same data, e.g.\n // Codex's internal `apply_patch`). Emitted per changed path. Path-only by\n // design — when the mutation goes through a visible tool call, the\n // tool-call/tool-result pair already carries the information.\n | {\n type: 'file-change';\n event: 'create' | 'modify' | 'delete';\n path: string;\n harnessMetadata?: HarnessV1Metadata;\n }\n\n // Context compaction performed by the underlying runtime (Claude Code's\n // native compaction, Pi's summarization). Observation only — the runtime\n // owns the compaction; the harness neither implements nor schedules it.\n // Emitted once, on completion, since `summary`/`tokensAfter` only exist then.\n | {\n type: 'compaction';\n trigger: 'manual' | 'auto';\n summary: string;\n tokensBefore?: number;\n tokensAfter?: number;\n harnessMetadata?: HarnessV1Metadata;\n }\n\n // Errors. Multiple may be emitted in a single turn.\n | { type: 'error'; error: unknown }\n\n // Adapter-specific passthrough. Consumers can opt in to receive these via\n // `HarnessAgent` settings; otherwise they are dropped.\n | { type: 'raw'; rawValue: unknown };\n\n/*\n * Runtime (Zod) encoding of `HarnessV1StreamPart`.\n *\n * `HarnessV1StreamPart` is a compile-time type built on `LanguageModelV4*`\n * types that ship no runtime validator. Bridge adapters receive these parts as\n * JSON across a trust boundary (the sandbox WebSocket), so they need a runtime\n * schema. These schemas ARE that encoding — one source of truth, kept from\n * diverging from the type by the `_assignable` guard below and the mutual\n * `toEqualTypeOf` assertion in `harness-v1-stream-part.test-d.ts`.\n *\n * Members are exported individually so `harness-v1-bridge-protocol.ts` can\n * compose them into the bridge outbound union alongside the transport frames.\n */\n\nconst harnessV1JsonValueSchema: z.ZodType<JSONValue> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(harnessV1JsonValueSchema),\n z.record(z.string(), harnessV1JsonValueSchema),\n ]),\n);\n\n/*\n * Tool-result values. The inferred type is the spec's `NonNullable<JSONValue>`\n * (matching `LanguageModelV4ToolResult`), but the runtime validator\n * deliberately also accepts `null`: adapters emit `result: <value> ?? null` for\n * tools that produced no output, and that `null` must survive the trust\n * boundary unchanged (it reaches consumers exactly as it did before this schema\n * existed, when a cast hid it). Leniency at runtime, strictness in the type.\n */\nconst harnessV1ToolResultValueSchema =\n harnessV1JsonValueSchema as unknown as z.ZodType<NonNullable<JSONValue>>;\n\nconst harnessV1JsonObjectSchema = z.record(\n z.string(),\n harnessV1JsonValueSchema,\n) as unknown as z.ZodType<Record<string, JSONValue>>;\n\nconst harnessV1MetadataSchema = z.record(\n z.string(),\n z.record(z.string(), harnessV1JsonValueSchema),\n) as unknown as z.ZodType<HarnessV1Metadata>;\n\nconst harnessV1ProviderMetadataSchema = z.record(\n z.string(),\n z.record(z.string(), harnessV1JsonValueSchema),\n) as unknown as z.ZodType<SharedV4ProviderMetadata>;\n\nconst harnessV1CallWarningSchema = z.union([\n z.object({\n type: z.literal('unsupported-setting'),\n setting: z.string(),\n details: z.string().optional(),\n }),\n z.object({\n type: z.literal('unsupported-tool'),\n tool: z.string(),\n details: z.string().optional(),\n }),\n z.object({ type: z.literal('other'), message: z.string() }),\n]) as z.ZodType<HarnessV1CallWarning>;\n\nconst harnessV1UsageSchema = z.object({\n inputTokens: z.object({\n total: z.number().optional(),\n noCache: z.number().optional(),\n cacheRead: z.number().optional(),\n cacheWrite: z.number().optional(),\n }),\n outputTokens: z.object({\n total: z.number().optional(),\n text: z.number().optional(),\n reasoning: z.number().optional(),\n }),\n raw: harnessV1JsonObjectSchema.optional(),\n}) as unknown as z.ZodType<LanguageModelV4Usage>;\n\nconst harnessV1FinishReasonSchema = z.object({\n unified: z.enum([\n 'stop',\n 'length',\n 'content-filter',\n 'tool-calls',\n 'error',\n 'other',\n ]),\n raw: z.string().optional(),\n}) as unknown as z.ZodType<LanguageModelV4FinishReason>;\n\nexport const harnessV1StreamStartPartSchema = z.object({\n type: z.literal('stream-start'),\n warnings: z.array(harnessV1CallWarningSchema).readonly().optional(),\n modelId: z.string().optional(),\n});\n\nexport const harnessV1TextStartPartSchema = z.object({\n type: z.literal('text-start'),\n id: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1TextDeltaPartSchema = z.object({\n type: z.literal('text-delta'),\n id: z.string(),\n delta: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1TextEndPartSchema = z.object({\n type: z.literal('text-end'),\n id: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1ReasoningStartPartSchema = z.object({\n type: z.literal('reasoning-start'),\n id: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1ReasoningDeltaPartSchema = z.object({\n type: z.literal('reasoning-delta'),\n id: z.string(),\n delta: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1ReasoningEndPartSchema = z.object({\n type: z.literal('reasoning-end'),\n id: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1ToolCallPartSchema = z.object({\n type: z.literal('tool-call'),\n toolCallId: z.string(),\n toolName: z.string(),\n input: z.string(),\n providerExecuted: z.boolean().optional(),\n dynamic: z.boolean().optional(),\n providerMetadata: harnessV1ProviderMetadataSchema.optional(),\n nativeName: z.string().optional(),\n});\n\nexport const harnessV1ToolApprovalRequestPartSchema = z.object({\n type: z.literal('tool-approval-request'),\n approvalId: z.string(),\n toolCallId: z.string(),\n providerMetadata: harnessV1ProviderMetadataSchema.optional(),\n});\n\nexport const harnessV1ToolResultPartSchema = z.object({\n type: z.literal('tool-result'),\n toolCallId: z.string(),\n toolName: z.string(),\n result: harnessV1ToolResultValueSchema,\n isError: z.boolean().optional(),\n preliminary: z.boolean().optional(),\n dynamic: z.boolean().optional(),\n providerMetadata: harnessV1ProviderMetadataSchema.optional(),\n});\n\nexport const harnessV1FinishStepPartSchema = z.object({\n type: z.literal('finish-step'),\n finishReason: harnessV1FinishReasonSchema,\n usage: harnessV1UsageSchema,\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1FinishPartSchema = z.object({\n type: z.literal('finish'),\n finishReason: harnessV1FinishReasonSchema,\n totalUsage: harnessV1UsageSchema,\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1FileChangePartSchema = z.object({\n type: z.literal('file-change'),\n event: z.enum(['create', 'modify', 'delete']),\n path: z.string(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1CompactionPartSchema = z.object({\n type: z.literal('compaction'),\n trigger: z.enum(['manual', 'auto']),\n summary: z.string(),\n tokensBefore: z.number().optional(),\n tokensAfter: z.number().optional(),\n harnessMetadata: harnessV1MetadataSchema.optional(),\n});\n\nexport const harnessV1ErrorPartSchema = z.object({\n type: z.literal('error'),\n error: z.unknown(),\n});\n\nexport const harnessV1RawPartSchema = z.object({\n type: z.literal('raw'),\n rawValue: z.unknown(),\n});\n\n/**\n * Assembled discriminated union over every `HarnessV1StreamPart` variant. Left\n * un-annotated so it keeps its precise inferred type — the protocol layer\n * composes the individual member schemas, and the type test asserts the\n * inferred union equals `HarnessV1StreamPart`.\n */\nexport const harnessV1StreamPartSchema = z.discriminatedUnion('type', [\n harnessV1StreamStartPartSchema,\n harnessV1TextStartPartSchema,\n harnessV1TextDeltaPartSchema,\n harnessV1TextEndPartSchema,\n harnessV1ReasoningStartPartSchema,\n harnessV1ReasoningDeltaPartSchema,\n harnessV1ReasoningEndPartSchema,\n harnessV1ToolCallPartSchema,\n harnessV1ToolApprovalRequestPartSchema,\n harnessV1ToolResultPartSchema,\n harnessV1FinishStepPartSchema,\n harnessV1FinishPartSchema,\n harnessV1FileChangePartSchema,\n harnessV1CompactionPartSchema,\n harnessV1ErrorPartSchema,\n harnessV1RawPartSchema,\n]);\n\n/*\n * Fail-fast guard at the definition site: the schema's output must be\n * assignable to `HarnessV1StreamPart` (catches a schema variant inventing a\n * shape the type does not allow). The reverse direction — the type being a\n * subset of the schema — is covered by the `toEqualTypeOf` assertion in the\n * type test.\n */\nconst _assignable: z.ZodType<HarnessV1StreamPart> = harnessV1StreamPartSchema;\nvoid _assignable;\n","import { z } from 'zod/v4';\nimport {\n harnessV1DebugConfigSchema,\n harnessV1DebugLevelSchema,\n type HarnessV1Diagnostic,\n} from './harness-v1-diagnostic';\nimport type { HarnessV1ResponseFormat } from './harness-v1-response-format';\nimport {\n harnessV1CompactionPartSchema,\n harnessV1ErrorPartSchema,\n harnessV1FileChangePartSchema,\n harnessV1FinishPartSchema,\n harnessV1FinishStepPartSchema,\n harnessV1RawPartSchema,\n harnessV1ReasoningDeltaPartSchema,\n harnessV1ReasoningEndPartSchema,\n harnessV1ReasoningStartPartSchema,\n harnessV1StreamStartPartSchema,\n harnessV1TextDeltaPartSchema,\n harnessV1TextEndPartSchema,\n harnessV1TextStartPartSchema,\n harnessV1ToolApprovalRequestPartSchema,\n harnessV1ToolCallPartSchema,\n harnessV1ToolResultPartSchema,\n} from './harness-v1-stream-part';\n\n/*\n * The bridge wire protocol shared by every bridge-backed harness adapter.\n *\n * This is the serialization of the host<->runtime contract for adapters that\n * run the agent runtime inside the sandbox and talk to the host over a\n * WebSocket. It exists ONLY because of that transport: untrusted JSON frames\n * crossing the sandbox boundary need runtime validation, the connection needs\n * a handshake, and the host drives turns with serialized commands. Every export\n * here is therefore prefixed `harnessV1Bridge…`.\n *\n * It has three tiers:\n *\n * 1. The OUTBOUND events — `HarnessV1StreamPart` re-expressed as Zod (imported\n * member schemas from `harness-v1-stream-part.ts`), because the part type is\n * compile-time only and the frames need runtime validation at the boundary.\n * 2. The transport/control frames that are NOT consumer events — `bridge-hello`\n * (handshake), `bridge-stop` (runtime resume data), `bridge-thread` (a resume\n * coordinate some runtimes announce). These ride the same socket.\n * 3. The INBOUND command vocabulary the host sends back: the shared commands\n * live here; the per-adapter `start` payload extends\n * `harnessV1BridgeStartBaseSchema` and assembles the final inbound union in\n * the adapter package.\n *\n * Non-bridge adapters (e.g. Pi) do not use this layer at all — they have no\n * serialization boundary and target the universal `HarnessV1StreamPart` type\n * directly. That is the deliberate split: `harness-v1-stream-part.ts` is the\n * transport-agnostic event vocabulary; this file is the bridge transport.\n */\n\n/**\n * The subset of a host-defined tool that travels on the `start` message. The\n * runtime only needs the name, description, and JSON-Schema input to surface\n * the tool; `execute` stays on the host.\n */\nexport const harnessV1BridgeToolWireSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n inputSchema: z.unknown().optional(),\n});\n\nexport type HarnessV1BridgeToolWire = z.infer<\n typeof harnessV1BridgeToolWireSchema\n>;\n\nexport const harnessV1BridgePermissionModeSchema = z.enum([\n 'allow-reads',\n 'allow-edits',\n 'allow-all',\n]);\n\nexport const harnessV1BridgeBuiltinToolFilteringSchema = z.discriminatedUnion(\n 'mode',\n [\n z.object({\n mode: z.literal('allow'),\n toolNames: z.array(z.string()),\n }),\n z.object({\n mode: z.literal('deny'),\n toolNames: z.array(z.string()),\n }),\n ],\n);\n\nexport const harnessV1BridgeResponseFormatSchema: z.ZodType<HarnessV1ResponseFormat> =\n z.discriminatedUnion('type', [\n z.object({ type: z.literal('text') }),\n z.object({\n type: z.literal('json'),\n schema: z.record(z.string(), z.json()).optional(),\n name: z.string().optional(),\n description: z.string().optional(),\n }),\n ]);\n\n/**\n * Common fields of the inbound `start` message. Each adapter extends this with\n * its runtime-specific configuration (e.g. `thinking`/`continue` for Claude\n * Code, `reasoningEffort`/`webSearch`/`skills`/`resumeThreadId` for Codex) and\n * assembles the final inbound union from the shared command members below.\n *\n * `debug` carries the general `HarnessV1DebugConfig` — diagnostics config is not\n * a bridge concept, it just happens to ride the `start` frame for bridge-backed\n * adapters.\n */\nexport const harnessV1BridgeStartBaseSchema = z.object({\n type: z.literal('start'),\n prompt: z.string(),\n tools: z.array(harnessV1BridgeToolWireSchema).optional(),\n model: z.string().optional(),\n debug: harnessV1DebugConfigSchema.optional(),\n permissionMode: harnessV1BridgePermissionModeSchema.optional(),\n builtinToolFiltering: harnessV1BridgeBuiltinToolFilteringSchema.optional(),\n responseFormat: harnessV1BridgeResponseFormatSchema.optional(),\n});\n\n// --- Transport / control frames (outbound, not consumer events) ---\n\n/**\n * Sent the instant the bridge accepts an authenticated WS connection. The host\n * waits for it before sending `start`/`resume`, because some sandbox runtimes\n * complete the upstream WS handshake before the connection is wired through to\n * the bridge process — anything sent in that gap is dropped. Carries the\n * bridge's lifecycle `state` and highest emitted `seq` for reconnect.\n */\nexport const harnessV1BridgeHelloSchema = z.object({\n type: z.literal('bridge-hello'),\n state: z.string().optional(),\n lastSeq: z.number().optional(),\n});\n\n/**\n * The bridge's reply to an inbound `stop`. Carries the adapter-specific\n * payload the host serializes into lifecycle state `data`.\n */\nexport const harnessV1BridgeStopSchema = z.object({\n type: z.literal('bridge-stop'),\n data: z.unknown(),\n});\n\n/**\n * A resume coordinate the bridge proactively announces (e.g. Codex's thread id)\n * so the host can cache it for a later resume without waiting for `stop`.\n */\nexport const harnessV1BridgeThreadSchema = z.object({\n type: z.literal('bridge-thread'),\n threadId: z.string(),\n});\n\n// --- Diagnostics frames (outbound, not consumer events) ---\n\n/**\n * One captured console line from inside the sandbox. The bridge line-buffers\n * `process.stdout`/`process.stderr` and emits one of these per complete line.\n * Routed host-side to the diagnostics sink, never to the consumer stream.\n */\nexport const harnessV1BridgeSandboxLogSchema = z.object({\n type: z.literal('sandbox-log'),\n source: z.string(),\n stream: z.enum(['stdout', 'stderr']),\n line: z.string(),\n});\n\n/**\n * A structured diagnostic an adapter emits from inside the bridge via\n * `turn.bridgeLog(...)`. Gated by the session's debug level + subsystem filter.\n */\nexport const harnessV1BridgeDebugEventSchema = z.object({\n type: z.literal('debug-event'),\n level: harnessV1DebugLevelSchema,\n subsystem: z.string(),\n message: z.string(),\n attrs: z.record(z.string(), z.unknown()).optional(),\n error: z\n .object({\n name: z.string().optional(),\n message: z.string(),\n stack: z.string().optional(),\n })\n .optional(),\n});\n\n/**\n * Every frame a bridge can send to the host: the stream-part events plus the\n * transport/control frames. This is the schema the host `SandboxChannel`\n * validates inbound frames against.\n */\nexport const harnessV1BridgeOutboundMessageSchema = z.discriminatedUnion(\n 'type',\n [\n harnessV1StreamStartPartSchema,\n harnessV1TextStartPartSchema,\n harnessV1TextDeltaPartSchema,\n harnessV1TextEndPartSchema,\n harnessV1ReasoningStartPartSchema,\n harnessV1ReasoningDeltaPartSchema,\n harnessV1ReasoningEndPartSchema,\n harnessV1ToolCallPartSchema,\n harnessV1ToolApprovalRequestPartSchema,\n harnessV1ToolResultPartSchema,\n harnessV1FinishStepPartSchema,\n harnessV1FinishPartSchema,\n harnessV1FileChangePartSchema,\n harnessV1CompactionPartSchema,\n harnessV1ErrorPartSchema,\n harnessV1RawPartSchema,\n harnessV1BridgeHelloSchema,\n harnessV1BridgeStopSchema,\n harnessV1BridgeThreadSchema,\n harnessV1BridgeSandboxLogSchema,\n harnessV1BridgeDebugEventSchema,\n ],\n);\n\nexport type HarnessV1BridgeOutboundMessage = z.infer<\n typeof harnessV1BridgeOutboundMessageSchema\n>;\n\nexport type HarnessV1BridgeSandboxLog = z.infer<\n typeof harnessV1BridgeSandboxLogSchema\n>;\n\nexport type HarnessV1BridgeDebugEvent = z.infer<\n typeof harnessV1BridgeDebugEventSchema\n>;\n\n/**\n * Normalize a bridge diagnostics wire frame into the transport-agnostic\n * `HarnessV1Diagnostic` an adapter reports to the framework. A captured console\n * line maps `stderr` → `warn` and `stdout` → `info`; a structured event passes\n * its fields through. This is the seam where the bridge's serialization is\n * lifted into the general emission shape every harness shares.\n */\nexport function harnessV1DiagnosticFromBridgeFrame(\n frame: HarnessV1BridgeSandboxLog | HarnessV1BridgeDebugEvent,\n context: { sessionId?: string; timestamp: number },\n): HarnessV1Diagnostic {\n if (frame.type === 'sandbox-log') {\n return {\n level: frame.stream === 'stderr' ? 'warn' : 'info',\n message: frame.line,\n subsystem: `sandbox.log.${frame.source}`,\n kind: 'log',\n source: frame.source,\n stream: frame.stream,\n sessionId: context.sessionId,\n timestamp: context.timestamp,\n };\n }\n return {\n level: frame.level,\n message: frame.message,\n subsystem: frame.subsystem,\n kind: 'event',\n attrs: frame.attrs,\n error: frame.error,\n sessionId: context.sessionId,\n timestamp: context.timestamp,\n };\n}\n\n// --- Shared inbound command members (host -> bridge) ---\n\nexport const harnessV1BridgeToolResultInboundSchema = z.object({\n type: z.literal('tool-result'),\n toolCallId: z.string(),\n output: z.unknown(),\n isError: z.boolean().optional(),\n});\n\nexport const harnessV1BridgeToolApprovalResponseInboundSchema = z.object({\n type: z.literal('tool-approval-response'),\n approvalId: z.string(),\n approved: z.boolean(),\n reason: z.string().optional(),\n});\n\nexport const harnessV1BridgeUserMessageInboundSchema = z.object({\n type: z.literal('user-message'),\n text: z.string(),\n});\n\nexport const harnessV1BridgeAbortInboundSchema = z.object({\n type: z.literal('abort'),\n});\n\nexport const harnessV1BridgeDestroyInboundSchema = z.object({\n type: z.literal('destroy'),\n});\n\n/**\n * Reconnect: after re-establishing the socket the host asks the bridge to\n * replay every buffered event with `seq > lastSeenEventId`.\n */\nexport const harnessV1BridgeResumeInboundSchema = z.object({\n type: z.literal('resume'),\n lastSeenEventId: z.number(),\n});\n\n/**\n * The bridge replies with `bridge-stop` carrying any runtime resume data,\n * then exits.\n */\nexport const harnessV1BridgeStopInboundSchema = z.object({\n type: z.literal('stop'),\n});\n\n/**\n * The inbound command members shared by every bridge adapter. Spread these\n * alongside the adapter's own `start` schema to build the final inbound union:\n * `z.discriminatedUnion('type', [adapterStartSchema, ...harnessV1BridgeInboundCommandSchemas])`.\n */\nexport const harnessV1BridgeInboundCommandSchemas = [\n harnessV1BridgeToolResultInboundSchema,\n harnessV1BridgeToolApprovalResponseInboundSchema,\n harnessV1BridgeUserMessageInboundSchema,\n harnessV1BridgeAbortInboundSchema,\n harnessV1BridgeDestroyInboundSchema,\n harnessV1BridgeResumeInboundSchema,\n harnessV1BridgeStopInboundSchema,\n] as const;\n\n/**\n * The JSON line the bridge writes to stdout once its WebSocket server is bound,\n * announcing the port the host should connect to.\n */\nexport const harnessV1BridgeReadySchema = z.object({\n type: z.literal('bridge-ready'),\n port: z.number(),\n});\n\nexport type HarnessV1BridgeReady = z.infer<typeof harnessV1BridgeReadySchema>;\n","import { z } from 'zod/v4';\n\n/*\n * Diagnostics EMISSION contract — part of the `HarnessV1` spec.\n *\n * These are the types a harness adapter produces and receives: an adapter\n * reports a `HarnessV1Diagnostic` to the framework (a bridge adapter normalizes\n * its wire frames into one; a non-bridge adapter constructs one directly), and\n * receives a `HarnessV1DebugConfig` to gate what it emits. They are distinct\n * from the unaffixed host-facing `HarnessDiagnostic` / `HarnessDebugConfig`\n * (the external/telemetry surface) — the framework maps between the two at the\n * boundary, so the emission and consumption surfaces can evolve independently.\n */\n\n/** Severity of a diagnostic, ordered most → least severe. */\nexport const harnessV1DebugLevelSchema = z.enum([\n 'error',\n 'warn',\n 'info',\n 'debug',\n 'trace',\n]);\n\nexport type HarnessV1DebugLevel = z.infer<typeof harnessV1DebugLevelSchema>;\n\n/**\n * Per-session diagnostics configuration the framework hands an adapter (and the\n * host sends on `start.debug`). When absent or `enabled` is false the adapter\n * captures and emits nothing. `subsystems` filters structured events by dotted\n * prefix; console capture is independent of the subsystem filter.\n */\nexport const harnessV1DebugConfigSchema = z.object({\n enabled: z.boolean().optional(),\n level: harnessV1DebugLevelSchema.optional(),\n subsystems: z.array(z.string()).optional(),\n});\n\nexport type HarnessV1DebugConfig = z.infer<typeof harnessV1DebugConfigSchema>;\n\n/**\n * A diagnostic as emitted by a harness adapter. Structurally identical to the\n * host-facing `HarnessDiagnostic` today, but kept separate: this is the spec's\n * emission shape, that is the external consumption shape.\n */\nexport type HarnessV1Diagnostic = {\n /** Severity. */\n readonly level: HarnessV1DebugLevel;\n /** Human-readable line (console capture) or message (structured event). */\n readonly message: string;\n /** Dotted subsystem (`sandbox.log.<source>` for console capture). */\n readonly subsystem: string;\n /** `'log'` = captured console line; `'event'` = structured emission. */\n readonly kind: 'log' | 'event';\n /** Originating source label (console capture). */\n readonly source?: string;\n /** Which standard stream the line came from (console capture). */\n readonly stream?: 'stdout' | 'stderr';\n /** Structured attributes (structured events only). */\n readonly attrs?: Record<string, unknown>;\n /** Error payload (structured events only). */\n readonly error?: { name?: string; message: string; stack?: string };\n /** The harness session this diagnostic originated from. */\n readonly sessionId?: string;\n /** Emission time (epoch ms). */\n readonly timestamp: number;\n};\n","export type HarnessV1BuiltinToolFiltering =\n | {\n mode: 'allow';\n toolNames: string[];\n }\n | {\n mode: 'deny';\n toolNames: string[];\n };\n\nexport function isHarnessV1BuiltinToolIncluded(input: {\n toolName: string;\n toolFiltering: HarnessV1BuiltinToolFiltering | undefined;\n}): boolean {\n if (input.toolFiltering == null) return true;\n return input.toolFiltering.mode === 'allow'\n ? input.toolFiltering.toolNames.includes(input.toolName)\n : !input.toolFiltering.toolNames.includes(input.toolName);\n}\n\nexport function getHarnessV1BuiltinToolFilteringDenialReason(input: {\n toolName: string;\n}): string {\n return `Tool '${input.toolName}' is inactive due to the HarnessAgent tool filtering policy.`;\n}\n","import { AISDKError } from '@ai-sdk/provider';\n\nconst name = 'AI_HarnessError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Base error type for failures originating in or signalled by a harness\n * adapter. Specific failure modes (e.g. unsupported capability) extend this\n * class.\n */\nexport class HarnessError extends AISDKError {\n private readonly [symbol] = true;\n\n constructor({ message, cause }: { message: string; cause?: unknown }) {\n super({ name, message, cause });\n }\n\n static isInstance(error: unknown): error is HarnessError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from '@ai-sdk/provider';\nimport { HarnessError } from './harness-error';\n\nconst name = 'AI_HarnessCapabilityUnsupportedError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown when a caller asks the harness to do something the adapter (or the\n * supplied sandbox) does not support, e.g. requesting manual compaction from\n * an adapter that only auto-compacts, or invoking `getPortEndpoint` on a\n * sandbox that does not expose one.\n *\n * The caller supplies the full human-readable message. Optional `harnessId`\n * is recorded as structured context for tooling.\n */\nexport class HarnessCapabilityUnsupportedError extends HarnessError {\n private readonly [symbol] = true;\n\n readonly harnessId?: string;\n\n constructor({\n message,\n harnessId,\n cause,\n }: {\n message: string;\n harnessId?: string;\n cause?: unknown;\n }) {\n super({ message, cause });\n Object.defineProperty(this, 'name', { value: name });\n this.harnessId = harnessId;\n }\n\n static isInstance(\n error: unknown,\n ): error is HarnessCapabilityUnsupportedError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from '@ai-sdk/provider';\nimport { HarnessError } from './harness-error';\n\nconst name = 'AI_HarnessSandboxAuthenticationError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown when a sandbox provider cannot authenticate or authorize the\n * operation needed to create or resume a harness sandbox. Providers should\n * preserve the underlying SDK failure as `cause` and supply a message that\n * explains how the consumer can configure credentials.\n */\nexport class HarnessSandboxAuthenticationError extends HarnessError {\n private readonly [symbol] = true;\n\n readonly sandboxProviderId: string;\n\n constructor({\n message,\n sandboxProviderId,\n cause,\n }: {\n message: string;\n sandboxProviderId: string;\n cause?: unknown;\n }) {\n super({ message, cause });\n Object.defineProperty(this, 'name', { value: name });\n this.sandboxProviderId = sandboxProviderId;\n }\n\n static isInstance(\n error: unknown,\n ): error is HarnessSandboxAuthenticationError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n"],"mappings":";AAAA,SAAS,YAA4C;AACrD,SAAS,SAAS;AAWX,IAAM,2BAA2B;AAAA,EACtC,MAAM,KAAK;AAAA,IACT,aAAa;AAAA,IACb,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;AAAA,IAC/C,cAAc,EAAE,QAAQ;AAAA,EAC1B,CAAC;AAAA,EACD,OAAO,KAAK;AAAA,IACV,aAAa;AAAA,IACb,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC;AAAA,IACpE,cAAc,EAAE,QAAQ;AAAA,EAC1B,CAAC;AAAA,EACD,MAAM,KAAK;AAAA,IACT,aAAa;AAAA,IACb,aAAa,EAAE,OAAO;AAAA,MACpB,WAAW,EAAE,OAAO;AAAA,MACpB,YAAY,EAAE,OAAO;AAAA,MACrB,YAAY,EAAE,OAAO;AA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MAAM,CAAC;AAHhC,SAAkB,MAAU;AAAA,EAI5B;AAAA,EAEA,OAAO,WAAW,OAAuC;AACvD,WAAO,WAAW,UAAU,OAAO,MAAM;AAAA,EAC3C;AACF;;;ACrBA,SAAS,cAAAC,mBAAkB;AAG3B,IAAMC,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AALhC,IAAAE,KAAAC;AAgBO,IAAM,oCAAN,eAAgDA,MAAA,cACnCD,MAAAD,SADmCE,KAAa;AAAA,EAKlE,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,EAAE,SAAS,MAAM,CAAC;AAb1B,SAAkBD,OAAU;AAc1B,WAAO,eAAe,MAAM,QAAQ,EAAE,OAAOH,MAAK,CAAC;AACnD,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,OAAO,WACL,OAC4C;AAC5C,WAAOK,YAAW,UAAU,OAAOJ,OAAM;AAAA,EAC3C;AACF;;;ACxCA,SAAS,cAAAK,mBAAkB;AAG3B,IAAMC,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AALhC,IAAAE,KAAAC;AAaO,IAAM,oCAAN,eAAgDA,MAAA,cACnCD,MAAAD,SADmCE,KAAa;AAAA,EAKlE,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,EAAE,SAAS,MAAM,CAAC;AAb1B,SAAkBD,OAAU;AAc1B,WAAO,eAAe,MAAM,QAAQ,EAAE,OAAOH,MAAK,CAAC;AACnD,SAAK,oBAAoB;AAAA,EAC3B;AAAA,EAEA,OAAO,WACL,OAC4C;AAC5C,WAAOK,YAAW,UAAU,OAAOJ,OAAM;AAAA,EAC3C;AACF;","names":["z","z","z","z","AISDKError","name","marker","symbol","_a","_b","AISDKError","AISDKError","name","marker","symbol","_a","_b","AISDKError"]}
|
package/dist/utils/index.js
CHANGED
|
@@ -751,6 +751,15 @@ var harnessV1BridgeBuiltinToolFilteringSchema = z3.discriminatedUnion(
|
|
|
751
751
|
})
|
|
752
752
|
]
|
|
753
753
|
);
|
|
754
|
+
var harnessV1BridgeResponseFormatSchema = z3.discriminatedUnion("type", [
|
|
755
|
+
z3.object({ type: z3.literal("text") }),
|
|
756
|
+
z3.object({
|
|
757
|
+
type: z3.literal("json"),
|
|
758
|
+
schema: z3.record(z3.string(), z3.json()).optional(),
|
|
759
|
+
name: z3.string().optional(),
|
|
760
|
+
description: z3.string().optional()
|
|
761
|
+
})
|
|
762
|
+
]);
|
|
754
763
|
var harnessV1BridgeStartBaseSchema = z3.object({
|
|
755
764
|
type: z3.literal("start"),
|
|
756
765
|
prompt: z3.string(),
|
|
@@ -758,7 +767,8 @@ var harnessV1BridgeStartBaseSchema = z3.object({
|
|
|
758
767
|
model: z3.string().optional(),
|
|
759
768
|
debug: harnessV1DebugConfigSchema.optional(),
|
|
760
769
|
permissionMode: harnessV1BridgePermissionModeSchema.optional(),
|
|
761
|
-
builtinToolFiltering: harnessV1BridgeBuiltinToolFilteringSchema.optional()
|
|
770
|
+
builtinToolFiltering: harnessV1BridgeBuiltinToolFilteringSchema.optional(),
|
|
771
|
+
responseFormat: harnessV1BridgeResponseFormatSchema.optional()
|
|
762
772
|
});
|
|
763
773
|
var harnessV1BridgeHelloSchema = z3.object({
|
|
764
774
|
type: z3.literal("bridge-hello"),
|