@ai-sdk/harness 1.0.10 → 1.0.12
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/agent/index.ts +1 -0
- package/dist/agent/index.d.ts +57 -11
- package/dist/agent/index.js +151 -15
- package/dist/agent/index.js.map +1 -1
- package/dist/index.d.ts +46 -1
- package/dist/index.js +28 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +60 -2
- package/dist/utils/index.js +144 -2
- package/dist/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/src/agent/harness-agent-session.ts +9 -0
- package/src/agent/harness-agent-settings.ts +23 -2
- package/src/agent/harness-agent-tool-types.ts +15 -0
- package/src/agent/harness-agent.ts +29 -18
- package/src/agent/internal/run-prompt.ts +67 -10
- package/src/agent/internal/tool-filtering.ts +114 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/sandbox-home-dir.ts +22 -0
- package/src/utils/shell-quote.ts +3 -0
- package/src/utils/write-skills.ts +141 -0
- package/src/v1/harness-v1-bridge-protocol.ts +15 -0
- package/src/v1/harness-v1-session.ts +8 -0
- package/src/v1/harness-v1-tool-filtering.ts +25 -0
- package/src/v1/harness-v1.ts +11 -0
- package/src/v1/index.ts +6 -0
package/dist/index.d.ts
CHANGED
|
@@ -704,6 +704,21 @@ type HarnessV1ToolSpec = {
|
|
|
704
704
|
readonly inputSchema?: JSONSchema7;
|
|
705
705
|
};
|
|
706
706
|
|
|
707
|
+
type HarnessV1BuiltinToolFiltering = {
|
|
708
|
+
mode: 'allow';
|
|
709
|
+
toolNames: string[];
|
|
710
|
+
} | {
|
|
711
|
+
mode: 'deny';
|
|
712
|
+
toolNames: string[];
|
|
713
|
+
};
|
|
714
|
+
declare function isHarnessV1BuiltinToolIncluded(input: {
|
|
715
|
+
toolName: string;
|
|
716
|
+
toolFiltering: HarnessV1BuiltinToolFiltering | undefined;
|
|
717
|
+
}): boolean;
|
|
718
|
+
declare function getHarnessV1BuiltinToolFilteringDenialReason(input: {
|
|
719
|
+
toolName: string;
|
|
720
|
+
}): string;
|
|
721
|
+
|
|
707
722
|
/**
|
|
708
723
|
* Options passed to `HarnessV1.doStart`.
|
|
709
724
|
*
|
|
@@ -741,6 +756,12 @@ type HarnessV1StartOptions = {
|
|
|
741
756
|
* the adapter.
|
|
742
757
|
*/
|
|
743
758
|
readonly permissionMode?: HarnessV1PermissionMode;
|
|
759
|
+
/**
|
|
760
|
+
* Adapter-native built-in tools that should be available for this session.
|
|
761
|
+
* Custom host-executed tools are filtered by the framework before they reach
|
|
762
|
+
* the adapter.
|
|
763
|
+
*/
|
|
764
|
+
readonly builtinToolFiltering?: HarnessV1BuiltinToolFiltering;
|
|
744
765
|
/**
|
|
745
766
|
* Signal that aborts startup. The adapter must propagate cancellation to
|
|
746
767
|
* any spawned processes or network calls.
|
|
@@ -977,6 +998,16 @@ type HarnessV1<TBuiltinTools extends ToolSet = ToolSet> = {
|
|
|
977
998
|
* only describes adapter-native tool approval support.
|
|
978
999
|
*/
|
|
979
1000
|
readonly supportsBuiltinToolApprovals?: boolean;
|
|
1001
|
+
/**
|
|
1002
|
+
* Whether the adapter can prevent its underlying runtime from seeing or
|
|
1003
|
+
* calling inactive built-in tools for every tool in `builtinTools`.
|
|
1004
|
+
*
|
|
1005
|
+
* Adapters without native filtering can still support `activeTools` and
|
|
1006
|
+
* `inactiveTools` for built-ins when `supportsBuiltinToolApprovals` is
|
|
1007
|
+
* `true`: the framework routes inactive built-in tool calls through the
|
|
1008
|
+
* approval path and auto-denies them before they execute.
|
|
1009
|
+
*/
|
|
1010
|
+
readonly supportsBuiltinToolFiltering?: boolean;
|
|
980
1011
|
/**
|
|
981
1012
|
* Optional schema for the adapter-defined `data` payload returned by session
|
|
982
1013
|
* lifecycle methods. When present, the adapter promises that exported state
|
|
@@ -1179,6 +1210,13 @@ declare const harnessV1BridgePermissionModeSchema: z.ZodEnum<{
|
|
|
1179
1210
|
"allow-reads": "allow-reads";
|
|
1180
1211
|
"allow-edits": "allow-edits";
|
|
1181
1212
|
}>;
|
|
1213
|
+
declare const harnessV1BridgeBuiltinToolFilteringSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1214
|
+
mode: z.ZodLiteral<"allow">;
|
|
1215
|
+
toolNames: z.ZodArray<z.ZodString>;
|
|
1216
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1217
|
+
mode: z.ZodLiteral<"deny">;
|
|
1218
|
+
toolNames: z.ZodArray<z.ZodString>;
|
|
1219
|
+
}, z.core.$strip>]>;
|
|
1182
1220
|
/**
|
|
1183
1221
|
* Common fields of the inbound `start` message. Each adapter extends this with
|
|
1184
1222
|
* its runtime-specific configuration (e.g. `thinking`/`continue` for Claude
|
|
@@ -1214,6 +1252,13 @@ declare const harnessV1BridgeStartBaseSchema: z.ZodObject<{
|
|
|
1214
1252
|
"allow-reads": "allow-reads";
|
|
1215
1253
|
"allow-edits": "allow-edits";
|
|
1216
1254
|
}>>;
|
|
1255
|
+
builtinToolFiltering: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1256
|
+
mode: z.ZodLiteral<"allow">;
|
|
1257
|
+
toolNames: z.ZodArray<z.ZodString>;
|
|
1258
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1259
|
+
mode: z.ZodLiteral<"deny">;
|
|
1260
|
+
toolNames: z.ZodArray<z.ZodString>;
|
|
1261
|
+
}, z.core.$strip>]>>;
|
|
1217
1262
|
}, z.core.$strip>;
|
|
1218
1263
|
/**
|
|
1219
1264
|
* Sent the instant the bridge accepts an authenticated WS connection. The host
|
|
@@ -1533,4 +1578,4 @@ declare class HarnessCapabilityUnsupportedError extends HarnessError {
|
|
|
1533
1578
|
static isInstance(error: unknown): error is HarnessCapabilityUnsupportedError;
|
|
1534
1579
|
}
|
|
1535
1580
|
|
|
1536
|
-
export { HARNESS_V1_BUILTIN_TOOLS, HARNESS_V1_BUILTIN_TOOL_NAMES, HarnessCapabilityUnsupportedError, HarnessError, type HarnessV1, type HarnessV1Bootstrap, type HarnessV1BootstrapCommand, type HarnessV1BootstrapFile, type HarnessV1BridgeDebugEvent, type HarnessV1BridgeOutboundMessage, type HarnessV1BridgeReady, type HarnessV1BridgeSandboxLog, type HarnessV1BridgeToolWire, type HarnessV1BuiltinTool, type HarnessV1BuiltinToolName, type HarnessV1BuiltinToolUseKind, type HarnessV1CallWarning, type HarnessV1ContinueTurnOptions, type HarnessV1ContinueTurnState, type HarnessV1DebugConfig, type HarnessV1DebugLevel, type HarnessV1Diagnostic, type HarnessV1LifecycleState, type HarnessV1Metadata, type HarnessV1NetworkPolicy, type HarnessV1NetworkSandboxSession, type HarnessV1Observability, type HarnessV1PendingToolApproval, type HarnessV1PermissionMode, type HarnessV1Prompt, type HarnessV1PromptControl, type HarnessV1PromptTurnOptions, type HarnessV1ResumeSessionState, type HarnessV1SandboxProvider, type HarnessV1Session, type HarnessV1Skill, type HarnessV1StartOptions, type HarnessV1StreamPart, type HarnessV1ToolSpec, commonTool, harnessV1BridgeAbortInboundSchema, harnessV1BridgeDebugEventSchema, harnessV1BridgeDetachInboundSchema, harnessV1BridgeDetachSchema, harnessV1BridgeHelloSchema, harnessV1BridgeInboundCommandSchemas, harnessV1BridgeOutboundMessageSchema, harnessV1BridgePermissionModeSchema, harnessV1BridgeReadySchema, harnessV1BridgeResumeInboundSchema, harnessV1BridgeSandboxLogSchema, harnessV1BridgeShutdownInboundSchema, harnessV1BridgeStartBaseSchema, harnessV1BridgeThreadSchema, harnessV1BridgeToolApprovalResponseInboundSchema, harnessV1BridgeToolResultInboundSchema, harnessV1BridgeToolWireSchema, harnessV1BridgeUserMessageInboundSchema, harnessV1DebugConfigSchema, harnessV1DebugLevelSchema, harnessV1DiagnosticFromBridgeFrame, harnessV1ErrorPartSchema, harnessV1FileChangePartSchema, harnessV1FinishPartSchema, harnessV1FinishStepPartSchema, harnessV1RawPartSchema, harnessV1ReasoningDeltaPartSchema, harnessV1ReasoningEndPartSchema, harnessV1ReasoningStartPartSchema, harnessV1StreamPartSchema, harnessV1StreamStartPartSchema, harnessV1TextDeltaPartSchema, harnessV1TextEndPartSchema, harnessV1TextStartPartSchema, harnessV1ToolApprovalRequestPartSchema, harnessV1ToolCallPartSchema, harnessV1ToolResultPartSchema };
|
|
1581
|
+
export { HARNESS_V1_BUILTIN_TOOLS, HARNESS_V1_BUILTIN_TOOL_NAMES, HarnessCapabilityUnsupportedError, HarnessError, type HarnessV1, type HarnessV1Bootstrap, type HarnessV1BootstrapCommand, type HarnessV1BootstrapFile, type HarnessV1BridgeDebugEvent, type HarnessV1BridgeOutboundMessage, type HarnessV1BridgeReady, type HarnessV1BridgeSandboxLog, type HarnessV1BridgeToolWire, type HarnessV1BuiltinTool, type HarnessV1BuiltinToolFiltering, type HarnessV1BuiltinToolName, type HarnessV1BuiltinToolUseKind, type HarnessV1CallWarning, type HarnessV1ContinueTurnOptions, type HarnessV1ContinueTurnState, type HarnessV1DebugConfig, type HarnessV1DebugLevel, type HarnessV1Diagnostic, type HarnessV1LifecycleState, type HarnessV1Metadata, type HarnessV1NetworkPolicy, type HarnessV1NetworkSandboxSession, type HarnessV1Observability, type HarnessV1PendingToolApproval, type HarnessV1PermissionMode, type HarnessV1Prompt, type HarnessV1PromptControl, type HarnessV1PromptTurnOptions, type HarnessV1ResumeSessionState, type HarnessV1SandboxProvider, type HarnessV1Session, type HarnessV1Skill, type HarnessV1StartOptions, type HarnessV1StreamPart, type HarnessV1ToolSpec, commonTool, getHarnessV1BuiltinToolFilteringDenialReason, harnessV1BridgeAbortInboundSchema, harnessV1BridgeBuiltinToolFilteringSchema, harnessV1BridgeDebugEventSchema, harnessV1BridgeDetachInboundSchema, harnessV1BridgeDetachSchema, harnessV1BridgeHelloSchema, harnessV1BridgeInboundCommandSchemas, harnessV1BridgeOutboundMessageSchema, harnessV1BridgePermissionModeSchema, harnessV1BridgeReadySchema, harnessV1BridgeResumeInboundSchema, harnessV1BridgeSandboxLogSchema, harnessV1BridgeShutdownInboundSchema, harnessV1BridgeStartBaseSchema, harnessV1BridgeThreadSchema, harnessV1BridgeToolApprovalResponseInboundSchema, harnessV1BridgeToolResultInboundSchema, harnessV1BridgeToolWireSchema, harnessV1BridgeUserMessageInboundSchema, harnessV1DebugConfigSchema, harnessV1DebugLevelSchema, harnessV1DiagnosticFromBridgeFrame, harnessV1ErrorPartSchema, harnessV1FileChangePartSchema, harnessV1FinishPartSchema, harnessV1FinishStepPartSchema, harnessV1RawPartSchema, harnessV1ReasoningDeltaPartSchema, harnessV1ReasoningEndPartSchema, harnessV1ReasoningStartPartSchema, harnessV1StreamPartSchema, harnessV1StreamStartPartSchema, harnessV1TextDeltaPartSchema, harnessV1TextEndPartSchema, harnessV1TextStartPartSchema, harnessV1ToolApprovalRequestPartSchema, harnessV1ToolCallPartSchema, harnessV1ToolResultPartSchema, isHarnessV1BuiltinToolIncluded };
|
package/dist/index.js
CHANGED
|
@@ -265,13 +265,27 @@ var harnessV1BridgePermissionModeSchema = z4.enum([
|
|
|
265
265
|
"allow-edits",
|
|
266
266
|
"allow-all"
|
|
267
267
|
]);
|
|
268
|
+
var harnessV1BridgeBuiltinToolFilteringSchema = z4.discriminatedUnion(
|
|
269
|
+
"mode",
|
|
270
|
+
[
|
|
271
|
+
z4.object({
|
|
272
|
+
mode: z4.literal("allow"),
|
|
273
|
+
toolNames: z4.array(z4.string())
|
|
274
|
+
}),
|
|
275
|
+
z4.object({
|
|
276
|
+
mode: z4.literal("deny"),
|
|
277
|
+
toolNames: z4.array(z4.string())
|
|
278
|
+
})
|
|
279
|
+
]
|
|
280
|
+
);
|
|
268
281
|
var harnessV1BridgeStartBaseSchema = z4.object({
|
|
269
282
|
type: z4.literal("start"),
|
|
270
283
|
prompt: z4.string(),
|
|
271
284
|
tools: z4.array(harnessV1BridgeToolWireSchema).optional(),
|
|
272
285
|
model: z4.string().optional(),
|
|
273
286
|
debug: harnessV1DebugConfigSchema.optional(),
|
|
274
|
-
permissionMode: harnessV1BridgePermissionModeSchema.optional()
|
|
287
|
+
permissionMode: harnessV1BridgePermissionModeSchema.optional(),
|
|
288
|
+
builtinToolFiltering: harnessV1BridgeBuiltinToolFilteringSchema.optional()
|
|
275
289
|
});
|
|
276
290
|
var harnessV1BridgeHelloSchema = z4.object({
|
|
277
291
|
type: z4.literal("bridge-hello"),
|
|
@@ -397,6 +411,15 @@ var harnessV1BridgeReadySchema = z4.object({
|
|
|
397
411
|
port: z4.number()
|
|
398
412
|
});
|
|
399
413
|
|
|
414
|
+
// src/v1/harness-v1-tool-filtering.ts
|
|
415
|
+
function isHarnessV1BuiltinToolIncluded(input) {
|
|
416
|
+
if (input.toolFiltering == null) return true;
|
|
417
|
+
return input.toolFiltering.mode === "allow" ? input.toolFiltering.toolNames.includes(input.toolName) : !input.toolFiltering.toolNames.includes(input.toolName);
|
|
418
|
+
}
|
|
419
|
+
function getHarnessV1BuiltinToolFilteringDenialReason(input) {
|
|
420
|
+
return `Tool '${input.toolName}' is inactive due to the HarnessAgent tool filtering policy.`;
|
|
421
|
+
}
|
|
422
|
+
|
|
400
423
|
// src/errors/harness-error.ts
|
|
401
424
|
import { AISDKError } from "@ai-sdk/provider";
|
|
402
425
|
var name = "AI_HarnessError";
|
|
@@ -440,7 +463,9 @@ export {
|
|
|
440
463
|
HarnessCapabilityUnsupportedError,
|
|
441
464
|
HarnessError,
|
|
442
465
|
commonTool,
|
|
466
|
+
getHarnessV1BuiltinToolFilteringDenialReason,
|
|
443
467
|
harnessV1BridgeAbortInboundSchema,
|
|
468
|
+
harnessV1BridgeBuiltinToolFilteringSchema,
|
|
444
469
|
harnessV1BridgeDebugEventSchema,
|
|
445
470
|
harnessV1BridgeDetachInboundSchema,
|
|
446
471
|
harnessV1BridgeDetachSchema,
|
|
@@ -476,6 +501,7 @@ export {
|
|
|
476
501
|
harnessV1TextStartPartSchema,
|
|
477
502
|
harnessV1ToolApprovalRequestPartSchema,
|
|
478
503
|
harnessV1ToolCallPartSchema,
|
|
479
|
-
harnessV1ToolResultPartSchema
|
|
504
|
+
harnessV1ToolResultPartSchema,
|
|
505
|
+
isHarnessV1BuiltinToolIncluded
|
|
480
506
|
};
|
|
481
507
|
//# sourceMappingURL=index.js.map
|
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/errors/harness-error.ts","../src/errors/harness-capability-unsupported-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-detach` (resume payload), `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\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});\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 `detach`. Carries the adapter-specific\n * payload the host serializes into lifecycle state `data`.\n */\nexport const harnessV1BridgeDetachSchema = z.object({\n type: z.literal('bridge-detach'),\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 `detach`.\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 harnessV1BridgeDetachSchema,\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 harnessV1BridgeShutdownInboundSchema = z.object({\n type: z.literal('shutdown'),\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-detach` carrying any cached resume payload,\n * then exits.\n */\nexport const harnessV1BridgeDetachInboundSchema = z.object({\n type: z.literal('detach'),\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 harnessV1BridgeShutdownInboundSchema,\n harnessV1BridgeResumeInboundSchema,\n harnessV1BridgeDetachInboundSchema,\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","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 `getPortUrl` on a sandbox\n * 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"],"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;AAAA,IACvB,CAAC;AAAA,IACD,cAAc,EAAE,QAAQ;AAAA,EAC1B,CAAC;AAAA,EACD,MAAM,KAAK;AAAA,IACT,aAA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,eAA2B,iBACd,aADc,IAAW;AAAA,EAG3C,YAAY,EAAE,SAAS,MAAM,GAAyC;AACpE,UAAM,EAAE,MAAM,SAAS,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;","names":["z","z","z","z","AISDKError","name","marker","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"],"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-detach` (resume payload), `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 `detach`. Carries the adapter-specific\n * payload the host serializes into lifecycle state `data`.\n */\nexport const harnessV1BridgeDetachSchema = z.object({\n type: z.literal('bridge-detach'),\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 `detach`.\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 harnessV1BridgeDetachSchema,\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 harnessV1BridgeShutdownInboundSchema = z.object({\n type: z.literal('shutdown'),\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-detach` carrying any cached resume payload,\n * then exits.\n */\nexport const harnessV1BridgeDetachInboundSchema = z.object({\n type: z.literal('detach'),\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 harnessV1BridgeShutdownInboundSchema,\n harnessV1BridgeResumeInboundSchema,\n harnessV1BridgeDetachInboundSchema,\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 `getPortUrl` on a sandbox\n * 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"],"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;AAAA,IACvB,CAAC;AAAA,IACD,cAAc,EAAE,QAAQ;AAAA,EAC1B,CAAC;AAAA,EACD,MAAM,K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AQ,EAAE,OAAOH,MAAK,CAAC;AACnD,SAAK,YAAY;AAAA,EACnB;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"]}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FlexibleSchema,
|
|
1
|
+
import { FlexibleSchema, Experimental_SandboxSession, Experimental_SandboxProcess } from '@ai-sdk/provider-utils';
|
|
2
2
|
import { WebSocket } from 'ws';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -200,6 +200,64 @@ declare function getAiGatewayAuthFromEnv({ env, }: {
|
|
|
200
200
|
baseUrl: string;
|
|
201
201
|
};
|
|
202
202
|
|
|
203
|
+
declare function resolveSandboxHomeDir({ sandbox, abortSignal, }: {
|
|
204
|
+
sandbox: Experimental_SandboxSession;
|
|
205
|
+
abortSignal?: AbortSignal;
|
|
206
|
+
}): Promise<string>;
|
|
207
|
+
|
|
208
|
+
declare function shellQuote(value: string): string;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* A self-contained instruction bundle the underlying runtime can load into
|
|
212
|
+
* its context. Adapters decide how to surface skills to the runtime.
|
|
213
|
+
*/
|
|
214
|
+
type HarnessV1Skill = {
|
|
215
|
+
/** Stable identifier for the skill (kebab-case slug). */
|
|
216
|
+
readonly name: string;
|
|
217
|
+
/**
|
|
218
|
+
* Short, model-facing description. This is what the runtime sees to
|
|
219
|
+
* decide whether the skill is relevant.
|
|
220
|
+
*/
|
|
221
|
+
readonly description: string;
|
|
222
|
+
/** Full skill content the model loads when the skill is active. */
|
|
223
|
+
readonly content: string;
|
|
224
|
+
/**
|
|
225
|
+
* Additional files that belong to this skill. Adapters with native skill
|
|
226
|
+
* directories materialize these next to `SKILL.md`; adapters without native
|
|
227
|
+
* skill files include them with the skill content.
|
|
228
|
+
*/
|
|
229
|
+
readonly files?: ReadonlyArray<HarnessV1SkillFile>;
|
|
230
|
+
};
|
|
231
|
+
type HarnessV1SkillFile = {
|
|
232
|
+
/**
|
|
233
|
+
* Skill-relative POSIX path, for example `reference.md` or
|
|
234
|
+
* `references/codes.md`. Absolute paths and `..` segments are rejected by
|
|
235
|
+
* adapters before writing.
|
|
236
|
+
*/
|
|
237
|
+
readonly path: string;
|
|
238
|
+
/** UTF-8 text content for the file. */
|
|
239
|
+
readonly content: string;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
type SkillFilePathMode = 'relative' | 'strip-leading-slashes';
|
|
243
|
+
type WriteSkillsOptions = {
|
|
244
|
+
sandbox: Experimental_SandboxSession;
|
|
245
|
+
rootDir: string;
|
|
246
|
+
skills: ReadonlyArray<HarnessV1Skill>;
|
|
247
|
+
abortSignal?: AbortSignal;
|
|
248
|
+
skillNamePattern?: RegExp;
|
|
249
|
+
invalidSkillNameMessage?: (input: {
|
|
250
|
+
name: string;
|
|
251
|
+
}) => string;
|
|
252
|
+
filePathMode?: SkillFilePathMode;
|
|
253
|
+
invalidSkillFilePathMessage?: (input: {
|
|
254
|
+
skillName: string;
|
|
255
|
+
filePath: string;
|
|
256
|
+
}) => string;
|
|
257
|
+
trailingNewline?: boolean;
|
|
258
|
+
};
|
|
259
|
+
declare function writeSkills({ sandbox, rootDir, skills, abortSignal, skillNamePattern, invalidSkillNameMessage, filePathMode, invalidSkillFilePathMessage, trailingNewline, }: WriteSkillsOptions): Promise<void>;
|
|
260
|
+
|
|
203
261
|
type BridgeReadySource = 'stdout' | 'metadata';
|
|
204
262
|
type BridgeReadyErrorContext = {
|
|
205
263
|
proc: Experimental_SandboxProcess;
|
|
@@ -229,4 +287,4 @@ declare function markBridgeStarting({ sandbox, bridgeStateDir, bridgeType, abort
|
|
|
229
287
|
}): Promise<void>;
|
|
230
288
|
declare function waitForBridgeReady({ proc, sandbox, bridgeStateDir, bridgeType, timeoutMs, abortSignal, pollIntervalMs, createTimeoutError, createExitError, }: WaitForBridgeReadyOptions): Promise<WaitForBridgeReadyResult>;
|
|
231
289
|
|
|
232
|
-
export { type BridgeReadyErrorContext, type BridgeReadySource, type DiskLogRecoveryMode, SandboxChannel, type SandboxChannelDebugEvent, type SandboxChannelOptions, type SandboxChannelReconnectOptions, type WaitForBridgeReadyOptions, type WaitForBridgeReadyResult, classifyDiskLog, getAiGatewayAuthFromEnv, markBridgeStarting, waitForBridgeReady };
|
|
290
|
+
export { type BridgeReadyErrorContext, type BridgeReadySource, type DiskLogRecoveryMode, SandboxChannel, type SandboxChannelDebugEvent, type SandboxChannelOptions, type SandboxChannelReconnectOptions, type SkillFilePathMode, type WaitForBridgeReadyOptions, type WaitForBridgeReadyResult, type WriteSkillsOptions, classifyDiskLog, getAiGatewayAuthFromEnv, markBridgeStarting, resolveSandboxHomeDir, shellQuote, waitForBridgeReady, writeSkills };
|
package/dist/utils/index.js
CHANGED
|
@@ -333,6 +333,131 @@ function getAiGatewayAuthFromEnv({
|
|
|
333
333
|
};
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
+
// src/utils/sandbox-home-dir.ts
|
|
337
|
+
import path from "path";
|
|
338
|
+
async function resolveSandboxHomeDir({
|
|
339
|
+
sandbox,
|
|
340
|
+
abortSignal
|
|
341
|
+
}) {
|
|
342
|
+
const result = await sandbox.run({
|
|
343
|
+
command: 'printf "%s" "$HOME"',
|
|
344
|
+
abortSignal
|
|
345
|
+
});
|
|
346
|
+
const homeDir = result.stdout.trim();
|
|
347
|
+
if (result.exitCode !== 0 || !homeDir || !path.posix.isAbsolute(homeDir)) {
|
|
348
|
+
throw new Error(
|
|
349
|
+
`Unable to resolve sandbox HOME directory: ${result.stderr || result.stdout}`
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
return homeDir;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// src/utils/shell-quote.ts
|
|
356
|
+
function shellQuote(value) {
|
|
357
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// src/utils/write-skills.ts
|
|
361
|
+
import path2 from "path";
|
|
362
|
+
async function writeSkills({
|
|
363
|
+
sandbox,
|
|
364
|
+
rootDir,
|
|
365
|
+
skills,
|
|
366
|
+
abortSignal,
|
|
367
|
+
skillNamePattern = /^[A-Za-z0-9._-]+$/,
|
|
368
|
+
invalidSkillNameMessage = ({ name }) => `Invalid skill name: ${name}`,
|
|
369
|
+
filePathMode = "relative",
|
|
370
|
+
invalidSkillFilePathMessage = ({ skillName, filePath }) => `Invalid skill file path for ${skillName}: ${filePath}`,
|
|
371
|
+
trailingNewline = false
|
|
372
|
+
}) {
|
|
373
|
+
var _a, _b;
|
|
374
|
+
for (const skill of skills) {
|
|
375
|
+
validateSkillName({
|
|
376
|
+
name: skill.name,
|
|
377
|
+
pattern: skillNamePattern,
|
|
378
|
+
message: invalidSkillNameMessage
|
|
379
|
+
});
|
|
380
|
+
for (const file of (_a = skill.files) != null ? _a : []) {
|
|
381
|
+
normalizeSkillFilePath({
|
|
382
|
+
skillName: skill.name,
|
|
383
|
+
filePath: file.path,
|
|
384
|
+
mode: filePathMode,
|
|
385
|
+
message: invalidSkillFilePathMessage
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
await sandbox.run({
|
|
390
|
+
command: `mkdir -p ${shellQuote(rootDir)}`,
|
|
391
|
+
abortSignal
|
|
392
|
+
});
|
|
393
|
+
for (const skill of skills) {
|
|
394
|
+
const name = validateSkillName({
|
|
395
|
+
name: skill.name,
|
|
396
|
+
pattern: skillNamePattern,
|
|
397
|
+
message: invalidSkillNameMessage
|
|
398
|
+
});
|
|
399
|
+
const skillDir = path2.posix.join(rootDir, name);
|
|
400
|
+
await sandbox.writeTextFile({
|
|
401
|
+
path: path2.posix.join(skillDir, "SKILL.md"),
|
|
402
|
+
content: renderSkillFile({ skill, trailingNewline }),
|
|
403
|
+
abortSignal
|
|
404
|
+
});
|
|
405
|
+
for (const file of (_b = skill.files) != null ? _b : []) {
|
|
406
|
+
const filePath = normalizeSkillFilePath({
|
|
407
|
+
skillName: skill.name,
|
|
408
|
+
filePath: file.path,
|
|
409
|
+
mode: filePathMode,
|
|
410
|
+
message: invalidSkillFilePathMessage
|
|
411
|
+
});
|
|
412
|
+
await sandbox.writeTextFile({
|
|
413
|
+
path: path2.posix.join(skillDir, filePath),
|
|
414
|
+
content: file.content,
|
|
415
|
+
abortSignal
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
function validateSkillName({
|
|
421
|
+
name,
|
|
422
|
+
pattern,
|
|
423
|
+
message
|
|
424
|
+
}) {
|
|
425
|
+
var _a;
|
|
426
|
+
if (!pattern.test(name) || name === "." || name === "..") {
|
|
427
|
+
throw new Error((_a = message == null ? void 0 : message({ name })) != null ? _a : `Invalid skill name: ${name}`);
|
|
428
|
+
}
|
|
429
|
+
return name;
|
|
430
|
+
}
|
|
431
|
+
function normalizeSkillFilePath({
|
|
432
|
+
skillName,
|
|
433
|
+
filePath,
|
|
434
|
+
mode,
|
|
435
|
+
message
|
|
436
|
+
}) {
|
|
437
|
+
var _a;
|
|
438
|
+
const normalized = mode === "strip-leading-slashes" ? filePath.replace(/^\/+/, "") : path2.posix.normalize(filePath);
|
|
439
|
+
const invalid = normalized === "" || mode === "relative" && normalized === "." || normalized.startsWith("../") || normalized.includes("/../") || normalized.endsWith("/..") || mode === "relative" && path2.posix.isAbsolute(normalized);
|
|
440
|
+
if (invalid) {
|
|
441
|
+
throw new Error(
|
|
442
|
+
(_a = message == null ? void 0 : message({ skillName: skillName != null ? skillName : "", filePath })) != null ? _a : `Invalid skill file path for ${skillName}: ${filePath}`
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
return normalized;
|
|
446
|
+
}
|
|
447
|
+
function renderSkillFile({
|
|
448
|
+
skill,
|
|
449
|
+
trailingNewline
|
|
450
|
+
}) {
|
|
451
|
+
const content = `---
|
|
452
|
+
name: ${skill.name}
|
|
453
|
+
description: ${skill.description}
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
${skill.content}`;
|
|
457
|
+
return trailingNewline ? `${content}
|
|
458
|
+
` : content;
|
|
459
|
+
}
|
|
460
|
+
|
|
336
461
|
// src/utils/bridge-ready.ts
|
|
337
462
|
import {
|
|
338
463
|
safeParseJSON as safeParseJSON3
|
|
@@ -547,13 +672,27 @@ var harnessV1BridgePermissionModeSchema = z3.enum([
|
|
|
547
672
|
"allow-edits",
|
|
548
673
|
"allow-all"
|
|
549
674
|
]);
|
|
675
|
+
var harnessV1BridgeBuiltinToolFilteringSchema = z3.discriminatedUnion(
|
|
676
|
+
"mode",
|
|
677
|
+
[
|
|
678
|
+
z3.object({
|
|
679
|
+
mode: z3.literal("allow"),
|
|
680
|
+
toolNames: z3.array(z3.string())
|
|
681
|
+
}),
|
|
682
|
+
z3.object({
|
|
683
|
+
mode: z3.literal("deny"),
|
|
684
|
+
toolNames: z3.array(z3.string())
|
|
685
|
+
})
|
|
686
|
+
]
|
|
687
|
+
);
|
|
550
688
|
var harnessV1BridgeStartBaseSchema = z3.object({
|
|
551
689
|
type: z3.literal("start"),
|
|
552
690
|
prompt: z3.string(),
|
|
553
691
|
tools: z3.array(harnessV1BridgeToolWireSchema).optional(),
|
|
554
692
|
model: z3.string().optional(),
|
|
555
693
|
debug: harnessV1DebugConfigSchema.optional(),
|
|
556
|
-
permissionMode: harnessV1BridgePermissionModeSchema.optional()
|
|
694
|
+
permissionMode: harnessV1BridgePermissionModeSchema.optional(),
|
|
695
|
+
builtinToolFiltering: harnessV1BridgeBuiltinToolFilteringSchema.optional()
|
|
557
696
|
});
|
|
558
697
|
var harnessV1BridgeHelloSchema = z3.object({
|
|
559
698
|
type: z3.literal("bridge-hello"),
|
|
@@ -855,6 +994,9 @@ export {
|
|
|
855
994
|
classifyDiskLog,
|
|
856
995
|
getAiGatewayAuthFromEnv,
|
|
857
996
|
markBridgeStarting,
|
|
858
|
-
|
|
997
|
+
resolveSandboxHomeDir,
|
|
998
|
+
shellQuote,
|
|
999
|
+
waitForBridgeReady,
|
|
1000
|
+
writeSkills
|
|
859
1001
|
};
|
|
860
1002
|
//# sourceMappingURL=index.js.map
|