@ai-sdk/harness 1.0.130 → 1.0.133

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/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
2
  import { Experimental_SandboxSession, UserModelMessage, ToolResultPart, ProviderOptions, ToolSet, FlexibleSchema, Tool, FunctionTool } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod/v4';
4
4
  import * as _ai_sdk_provider from '@ai-sdk/provider';
5
- import { JSONSchema7, JSONValue, LanguageModelV4StreamPart, LanguageModelV4ToolCall, LanguageModelV4ToolApprovalRequest, LanguageModelV4ToolResult, LanguageModelV4FinishReason, LanguageModelV4Usage, SharedV4ProviderMetadata, AISDKError } from '@ai-sdk/provider';
5
+ import { JSONSchema7, JSONValue, LanguageModelV4StreamPart, LanguageModelV4ToolCall, LanguageModelV4ToolApprovalRequest, LanguageModelV4ToolResult, LanguageModelV4FinishReason, LanguageModelV4Usage, SharedV4ProviderMetadata, LanguageModelV4TextPart, LanguageModelV4FilePart, LanguageModelV4CustomPart, LanguageModelV4ReasoningPart, LanguageModelV4ReasoningFilePart, LanguageModelV4ToolCallPart, LanguageModelV4ToolResultPart, LanguageModelV4ToolResultOutput, LanguageModelV4ToolApprovalResponsePart, AISDKError } from '@ai-sdk/provider';
6
6
 
7
7
  /**
8
8
  * One file to write into the sandbox as part of an adapter's bootstrap recipe.
@@ -904,6 +904,66 @@ declare const harnessV1StreamPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
904
904
  rawValue: z.ZodUnknown;
905
905
  }, z.core.$strip>]>;
906
906
 
907
+ type LanguageModelV4ToolResultContentPart = Extract<LanguageModelV4ToolResultOutput, {
908
+ type: 'content';
909
+ }>['value'][number];
910
+ type HarnessV1TextPart = Omit<LanguageModelV4TextPart, 'providerOptions'>;
911
+ type HarnessV1FilePart = Omit<LanguageModelV4FilePart, 'providerOptions'>;
912
+ type HarnessV1CustomPart = Omit<LanguageModelV4CustomPart, 'providerOptions'>;
913
+ type HarnessV1ReasoningPart = Omit<LanguageModelV4ReasoningPart, 'providerOptions'>;
914
+ type HarnessV1ReasoningFilePart = Omit<LanguageModelV4ReasoningFilePart, 'providerOptions'>;
915
+ type HarnessV1ToolCallPart = Omit<LanguageModelV4ToolCallPart, 'providerOptions'> & {
916
+ nativeName?: string;
917
+ };
918
+ type HarnessV1ToolResultOutput = Omit<Extract<LanguageModelV4ToolResultOutput, {
919
+ type: 'text';
920
+ }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultOutput, {
921
+ type: 'json';
922
+ }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultOutput, {
923
+ type: 'execution-denied';
924
+ }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultOutput, {
925
+ type: 'error-text';
926
+ }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultOutput, {
927
+ type: 'error-json';
928
+ }>, 'providerOptions'> | {
929
+ type: 'content';
930
+ value: Array<Omit<Extract<LanguageModelV4ToolResultContentPart, {
931
+ type: 'text';
932
+ }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultContentPart, {
933
+ type: 'file';
934
+ }>, 'providerOptions'> | Omit<Extract<LanguageModelV4ToolResultContentPart, {
935
+ type: 'custom';
936
+ }>, 'providerOptions'>>;
937
+ };
938
+ type HarnessV1ToolResultPart = Omit<LanguageModelV4ToolResultPart, 'output' | 'providerOptions'> & {
939
+ output: HarnessV1ToolResultOutput;
940
+ };
941
+ type HarnessV1ToolApprovalResponsePart = Omit<LanguageModelV4ToolApprovalResponsePart, 'providerOptions'>;
942
+ type HarnessV1MessagePart = HarnessV1TextPart | HarnessV1FilePart | HarnessV1CustomPart | HarnessV1ReasoningPart | HarnessV1ReasoningFilePart | HarnessV1ToolCallPart | HarnessV1ToolResultPart | HarnessV1ToolApprovalResponsePart;
943
+ type HarnessV1UserMessage = {
944
+ readonly role: 'user';
945
+ readonly content: Array<HarnessV1TextPart | HarnessV1FilePart>;
946
+ readonly at?: string;
947
+ readonly harnessMetadata?: HarnessV1Metadata;
948
+ };
949
+ type HarnessV1AssistantMessage = {
950
+ readonly role: 'assistant';
951
+ readonly content: Array<HarnessV1TextPart | HarnessV1FilePart | HarnessV1CustomPart | HarnessV1ReasoningPart | HarnessV1ReasoningFilePart | HarnessV1ToolCallPart | HarnessV1ToolResultPart>;
952
+ readonly at?: string;
953
+ readonly harnessMetadata?: HarnessV1Metadata;
954
+ };
955
+ type HarnessV1ToolMessage = {
956
+ readonly role: 'tool';
957
+ readonly content: Array<HarnessV1ToolResultPart | HarnessV1ToolApprovalResponsePart>;
958
+ readonly at?: string;
959
+ readonly harnessMetadata?: HarnessV1Metadata;
960
+ };
961
+ /**
962
+ * A persisted harness message using V4 prompt content shapes and metadata
963
+ * scoped to the adapter that produced it.
964
+ */
965
+ type HarnessV1Message = HarnessV1UserMessage | HarnessV1AssistantMessage | HarnessV1ToolMessage;
966
+
907
967
  type HarnessV1BuiltinToolFiltering = {
908
968
  mode: 'allow';
909
969
  toolNames: string[];
@@ -987,6 +1047,14 @@ type HarnessV1StartOptions = {
987
1047
  */
988
1048
  readonly sessionWorkDir: string;
989
1049
  };
1050
+ /**
1051
+ * Result of `HarnessV1Session.doReadHistory`.
1052
+ */
1053
+ type HarnessV1ReadHistoryResult = {
1054
+ readonly messages: ReadonlyArray<HarnessV1Message>;
1055
+ /** Opaque position; pass back as `since` to read only what follows. */
1056
+ readonly cursor: string;
1057
+ };
990
1058
  /**
991
1059
  * Options passed to `HarnessV1Session.doPromptTurn`.
992
1060
  */
@@ -1076,6 +1144,33 @@ type HarnessV1Session = {
1076
1144
  * `customInstructions`, when supported, steer the compaction summary.
1077
1145
  */
1078
1146
  doCompact(customInstructions?: string): PromiseLike<void>;
1147
+ /**
1148
+ * Read the conversation history the runtime itself persisted, normalized
1149
+ * to `HarnessV1Message`.
1150
+ *
1151
+ * The session's history can grow outside the harness contract: the same
1152
+ * runtime conversation may be continued interactively (`claude --resume`),
1153
+ * by another process, or before this session attached. Hosts that render a
1154
+ * continuous record of the conversation — not just the turns they drove —
1155
+ * need to read that history back, and the runtime's own store is the only
1156
+ * source that has it. The adapter owns its runtime's persistence format,
1157
+ * so the read belongs here rather than in every host.
1158
+ *
1159
+ * `since` is the `cursor` from a previous read; the result then contains
1160
+ * only messages recorded after it. The cursor is adapter-owned and opaque
1161
+ * to the host.
1162
+ *
1163
+ * Optional capability: adapters that cannot read their runtime's store
1164
+ * omit the method entirely, and the agent surfaces that as
1165
+ * `HarnessCapabilityUnsupportedError`. An adapter that implements it but
1166
+ * cannot reach the store from the current environment (e.g. it lives
1167
+ * inside a remote sandbox) throws `HarnessHistoryUnavailableError`. A
1168
+ * conversation with no recorded messages yet is not an error — it resolves
1169
+ * to an empty `messages` array.
1170
+ */
1171
+ doReadHistory?(options: {
1172
+ readonly since?: string;
1173
+ }): PromiseLike<HarnessV1ReadHistoryResult>;
1079
1174
  /**
1080
1175
  * Continue the in-flight turn **without a new user prompt**, returning the
1081
1176
  * same control surface as `doPromptTurn`. Used to keep consuming a turn that
@@ -1923,14 +2018,14 @@ declare const harnessV1BridgeReadySchema: z.ZodObject<{
1923
2018
  }, z.core.$strip>;
1924
2019
  type HarnessV1BridgeReady = z.infer<typeof harnessV1BridgeReadySchema>;
1925
2020
 
1926
- declare const symbol$2: unique symbol;
2021
+ declare const symbol$3: unique symbol;
1927
2022
  /**
1928
2023
  * Base error type for failures originating in or signalled by a harness
1929
2024
  * adapter. Specific failure modes (e.g. unsupported capability) extend this
1930
2025
  * class.
1931
2026
  */
1932
2027
  declare class HarnessError extends AISDKError {
1933
- private readonly [symbol$2];
2028
+ private readonly [symbol$3];
1934
2029
  constructor({ message, cause }: {
1935
2030
  message: string;
1936
2031
  cause?: unknown;
@@ -1938,7 +2033,7 @@ declare class HarnessError extends AISDKError {
1938
2033
  static isInstance(error: unknown): error is HarnessError;
1939
2034
  }
1940
2035
 
1941
- declare const symbol$1: unique symbol;
2036
+ declare const symbol$2: unique symbol;
1942
2037
  /**
1943
2038
  * Thrown when a caller asks the harness to do something the adapter (or the
1944
2039
  * supplied sandbox) does not support, e.g. requesting manual compaction from
@@ -1949,7 +2044,7 @@ declare const symbol$1: unique symbol;
1949
2044
  * is recorded as structured context for tooling.
1950
2045
  */
1951
2046
  declare class HarnessCapabilityUnsupportedError extends HarnessError {
1952
- private readonly [symbol$1];
2047
+ private readonly [symbol$2];
1953
2048
  readonly harnessId?: string;
1954
2049
  constructor({ message, harnessId, cause, }: {
1955
2050
  message: string;
@@ -1959,6 +2054,29 @@ declare class HarnessCapabilityUnsupportedError extends HarnessError {
1959
2054
  static isInstance(error: unknown): error is HarnessCapabilityUnsupportedError;
1960
2055
  }
1961
2056
 
2057
+ declare const symbol$1: unique symbol;
2058
+ /**
2059
+ * Thrown by `readHistory` when the adapter supports history reads but cannot
2060
+ * reach the runtime's store from the current environment — for example the
2061
+ * store lives inside a remote sandbox, or the transcript directory is
2062
+ * missing or unreadable.
2063
+ *
2064
+ * Distinct from `HarnessCapabilityUnsupportedError` (the adapter does not
2065
+ * implement history reads at all) so hosts can retry or degrade differently.
2066
+ * A conversation with no recorded messages yet is not an error; it resolves
2067
+ * to an empty result instead.
2068
+ */
2069
+ declare class HarnessHistoryUnavailableError extends HarnessError {
2070
+ private readonly [symbol$1];
2071
+ readonly harnessId?: string;
2072
+ constructor({ message, harnessId, cause, }: {
2073
+ message: string;
2074
+ harnessId?: string;
2075
+ cause?: unknown;
2076
+ });
2077
+ static isInstance(error: unknown): error is HarnessHistoryUnavailableError;
2078
+ }
2079
+
1962
2080
  declare const symbol: unique symbol;
1963
2081
  /**
1964
2082
  * Thrown when a sandbox provider cannot authenticate or authorize the
@@ -1977,4 +2095,4 @@ declare class HarnessSandboxAuthenticationError extends HarnessError {
1977
2095
  static isInstance(error: unknown): error is HarnessSandboxAuthenticationError;
1978
2096
  }
1979
2097
 
1980
- export { type Experimental_HarnessV1BridgeUserMessageResponse, HARNESS_V1_BUILTIN_TOOLS, HARNESS_V1_BUILTIN_TOOL_NAMES, HarnessCapabilityUnsupportedError, HarnessError, HarnessSandboxAuthenticationError, type HarnessV1, type HarnessV1Authentication, type HarnessV1AuthenticationEnvironment, 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 HarnessV1CredentialForwarding, type HarnessV1DebugConfig, type HarnessV1DebugLevel, type HarnessV1Diagnostic, type HarnessV1JSONArray, type HarnessV1JSONObject, type HarnessV1JSONSchema, type HarnessV1JSONValue, type HarnessV1LifecycleState, type HarnessV1Metadata, type HarnessV1MintBridgeTokenCallback, type HarnessV1NetworkPolicy, type HarnessV1NetworkSandboxSession, type HarnessV1Observability, type HarnessV1PendingToolApproval, type HarnessV1PendingToolResult, type HarnessV1PermissionMode, type HarnessV1PortEndpoint, type HarnessV1Prompt, type HarnessV1PromptControl, type HarnessV1PromptTurnOptions, type HarnessV1QuestionsTool, type HarnessV1QuestionsToolInput, type HarnessV1QuestionsToolOutput, type HarnessV1RequestTransformation, type HarnessV1RequestTransformationSources, type HarnessV1ResponseFormat, type HarnessV1ResumeSessionState, type HarnessV1SandboxProvider, type HarnessV1SandboxSessionCreateOptions, type HarnessV1SandboxSessionResumeOptions, type HarnessV1SandboxTemplate, type HarnessV1Session, type HarnessV1Skill, type HarnessV1StartOptions, type HarnessV1StreamPart, type HarnessV1ToolSpec, type HarnessV1TurnSettings, commonTool, experimental_harnessV1BridgeUserMessageInboundSchema, experimental_harnessV1BridgeUserMessageResponseSchema, getHarnessV1BuiltinToolFilteringDenialReason, harnessSessionDataDirectoryPath, harnessStateDirectoryPath, harnessV1BridgeAbortInboundSchema, harnessV1BridgeBuiltinToolFilteringSchema, harnessV1BridgeDebugEventSchema, harnessV1BridgeDestroyInboundSchema, harnessV1BridgeHelloSchema, harnessV1BridgeInboundCommandSchemas, harnessV1BridgeOutboundMessageSchema, harnessV1BridgePermissionModeSchema, harnessV1BridgeReadySchema, harnessV1BridgeResponseFormatSchema, harnessV1BridgeResumeInboundSchema, harnessV1BridgeSandboxLogSchema, harnessV1BridgeStartBaseSchema, harnessV1BridgeStopInboundSchema, harnessV1BridgeStopSchema, harnessV1BridgeThreadSchema, harnessV1BridgeToolApprovalResponseInboundSchema, harnessV1BridgeToolResultInboundSchema, harnessV1BridgeToolWireSchema, harnessV1BridgeUserMessageInboundSchema, harnessV1DebugConfigSchema, harnessV1DebugLevelSchema, harnessV1DiagnosticFromBridgeFrame, harnessV1ErrorPartSchema, harnessV1FileChangePartSchema, harnessV1FinishPartSchema, harnessV1FinishStepPartSchema, harnessV1QuestionsToolInputSchema, harnessV1QuestionsToolOutputSchema, harnessV1RawPartSchema, harnessV1ReasoningDeltaPartSchema, harnessV1ReasoningEndPartSchema, harnessV1ReasoningStartPartSchema, harnessV1StreamPartSchema, harnessV1StreamStartPartSchema, harnessV1TextDeltaPartSchema, harnessV1TextEndPartSchema, harnessV1TextStartPartSchema, harnessV1ToolApprovalRequestPartSchema, harnessV1ToolCallPartSchema, harnessV1ToolResultPartSchema, isHarnessV1BuiltinToolIncluded };
2098
+ export { type Experimental_HarnessV1BridgeUserMessageResponse, HARNESS_V1_BUILTIN_TOOLS, HARNESS_V1_BUILTIN_TOOL_NAMES, HarnessCapabilityUnsupportedError, HarnessError, HarnessHistoryUnavailableError, HarnessSandboxAuthenticationError, type HarnessV1, type HarnessV1AssistantMessage, type HarnessV1Authentication, type HarnessV1AuthenticationEnvironment, 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 HarnessV1CredentialForwarding, type HarnessV1CustomPart, type HarnessV1DebugConfig, type HarnessV1DebugLevel, type HarnessV1Diagnostic, type HarnessV1FilePart, type HarnessV1JSONArray, type HarnessV1JSONObject, type HarnessV1JSONSchema, type HarnessV1JSONValue, type HarnessV1LifecycleState, type HarnessV1Message, type HarnessV1MessagePart, type HarnessV1Metadata, type HarnessV1MintBridgeTokenCallback, type HarnessV1NetworkPolicy, type HarnessV1NetworkSandboxSession, type HarnessV1Observability, type HarnessV1PendingToolApproval, type HarnessV1PendingToolResult, type HarnessV1PermissionMode, type HarnessV1PortEndpoint, type HarnessV1Prompt, type HarnessV1PromptControl, type HarnessV1PromptTurnOptions, type HarnessV1QuestionsTool, type HarnessV1QuestionsToolInput, type HarnessV1QuestionsToolOutput, type HarnessV1ReadHistoryResult, type HarnessV1ReasoningFilePart, type HarnessV1ReasoningPart, type HarnessV1RequestTransformation, type HarnessV1RequestTransformationSources, type HarnessV1ResponseFormat, type HarnessV1ResumeSessionState, type HarnessV1SandboxProvider, type HarnessV1SandboxSessionCreateOptions, type HarnessV1SandboxSessionResumeOptions, type HarnessV1SandboxTemplate, type HarnessV1Session, type HarnessV1Skill, type HarnessV1StartOptions, type HarnessV1StreamPart, type HarnessV1TextPart, type HarnessV1ToolApprovalResponsePart, type HarnessV1ToolCallPart, type HarnessV1ToolMessage, type HarnessV1ToolResultOutput, type HarnessV1ToolResultPart, type HarnessV1ToolSpec, type HarnessV1TurnSettings, type HarnessV1UserMessage, commonTool, experimental_harnessV1BridgeUserMessageInboundSchema, experimental_harnessV1BridgeUserMessageResponseSchema, getHarnessV1BuiltinToolFilteringDenialReason, harnessSessionDataDirectoryPath, harnessStateDirectoryPath, harnessV1BridgeAbortInboundSchema, harnessV1BridgeBuiltinToolFilteringSchema, harnessV1BridgeDebugEventSchema, harnessV1BridgeDestroyInboundSchema, harnessV1BridgeHelloSchema, harnessV1BridgeInboundCommandSchemas, harnessV1BridgeOutboundMessageSchema, harnessV1BridgePermissionModeSchema, harnessV1BridgeReadySchema, harnessV1BridgeResponseFormatSchema, harnessV1BridgeResumeInboundSchema, harnessV1BridgeSandboxLogSchema, harnessV1BridgeStartBaseSchema, harnessV1BridgeStopInboundSchema, harnessV1BridgeStopSchema, harnessV1BridgeThreadSchema, harnessV1BridgeToolApprovalResponseInboundSchema, harnessV1BridgeToolResultInboundSchema, harnessV1BridgeToolWireSchema, harnessV1BridgeUserMessageInboundSchema, harnessV1DebugConfigSchema, harnessV1DebugLevelSchema, harnessV1DiagnosticFromBridgeFrame, harnessV1ErrorPartSchema, harnessV1FileChangePartSchema, harnessV1FinishPartSchema, harnessV1FinishStepPartSchema, harnessV1QuestionsToolInputSchema, harnessV1QuestionsToolOutputSchema, harnessV1RawPartSchema, harnessV1ReasoningDeltaPartSchema, harnessV1ReasoningEndPartSchema, harnessV1ReasoningStartPartSchema, harnessV1StreamPartSchema, harnessV1StreamStartPartSchema, harnessV1TextDeltaPartSchema, harnessV1TextEndPartSchema, harnessV1TextStartPartSchema, harnessV1ToolApprovalRequestPartSchema, harnessV1ToolCallPartSchema, harnessV1ToolResultPartSchema, isHarnessV1BuiltinToolIncluded };
package/dist/index.js CHANGED
@@ -593,32 +593,55 @@ var HarnessCapabilityUnsupportedError = class extends (_b2 = HarnessError, _a2 =
593
593
  }
594
594
  };
595
595
 
596
- // src/errors/harness-sandbox-authentication-error.ts
596
+ // src/errors/harness-history-unavailable-error.ts
597
597
  import { AISDKError as AISDKError3 } from "@ai-sdk/provider";
598
- var name3 = "AI_HarnessSandboxAuthenticationError";
598
+ var name3 = "AI_HarnessHistoryUnavailableError";
599
599
  var marker3 = `vercel.ai.error.${name3}`;
600
600
  var symbol3 = Symbol.for(marker3);
601
601
  var _a3, _b3;
602
- var HarnessSandboxAuthenticationError = class extends (_b3 = HarnessError, _a3 = symbol3, _b3) {
602
+ var HarnessHistoryUnavailableError = class extends (_b3 = HarnessError, _a3 = symbol3, _b3) {
603
603
  constructor({
604
604
  message,
605
- sandboxProviderId,
605
+ harnessId,
606
606
  cause
607
607
  }) {
608
608
  super({ message, cause });
609
609
  this[_a3] = true;
610
610
  Object.defineProperty(this, "name", { value: name3 });
611
- this.sandboxProviderId = sandboxProviderId;
611
+ this.harnessId = harnessId;
612
612
  }
613
613
  static isInstance(error) {
614
614
  return AISDKError3.hasMarker(error, marker3);
615
615
  }
616
616
  };
617
+
618
+ // src/errors/harness-sandbox-authentication-error.ts
619
+ import { AISDKError as AISDKError4 } from "@ai-sdk/provider";
620
+ var name4 = "AI_HarnessSandboxAuthenticationError";
621
+ var marker4 = `vercel.ai.error.${name4}`;
622
+ var symbol4 = Symbol.for(marker4);
623
+ var _a4, _b4;
624
+ var HarnessSandboxAuthenticationError = class extends (_b4 = HarnessError, _a4 = symbol4, _b4) {
625
+ constructor({
626
+ message,
627
+ sandboxProviderId,
628
+ cause
629
+ }) {
630
+ super({ message, cause });
631
+ this[_a4] = true;
632
+ Object.defineProperty(this, "name", { value: name4 });
633
+ this.sandboxProviderId = sandboxProviderId;
634
+ }
635
+ static isInstance(error) {
636
+ return AISDKError4.hasMarker(error, marker4);
637
+ }
638
+ };
617
639
  export {
618
640
  HARNESS_V1_BUILTIN_TOOLS,
619
641
  HARNESS_V1_BUILTIN_TOOL_NAMES,
620
642
  HarnessCapabilityUnsupportedError,
621
643
  HarnessError,
644
+ HarnessHistoryUnavailableError,
622
645
  HarnessSandboxAuthenticationError,
623
646
  commonTool,
624
647
  experimental_harnessV1BridgeUserMessageInboundSchema,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/v1/harness-v1-builtin-tool.ts","../src/v1/harness-v1-questions-tool.ts","../src/v1/harness-v1-network-sandbox-session.ts","../src/v1/harness-session-data-directory-path.ts","../src/v1/harness-v1-stream-part.ts","../src/v1/harness-v1-bridge-protocol.ts","../src/v1/harness-v1-diagnostic.ts","../src/v1/harness-v1-tool-filtering.ts","../src/errors/harness-error.ts","../src/errors/harness-capability-unsupported-error.ts","../src/errors/harness-sandbox-authentication-error.ts"],"sourcesContent":["import { tool, type FlexibleSchema, type Tool } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { harnessV1QuestionsTool } from './harness-v1-questions-tool';\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 askUserQuestions: harnessV1QuestionsTool,\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 { FunctionTool } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst harnessV1QuestionSchema = z.object({\n id: z.string().min(1),\n question: z.string().min(1),\n header: z.string().optional(),\n options: z\n .array(\n z.object({\n id: z.string().min(1),\n label: z.string().min(1),\n description: z.string().optional(),\n preview: z.string().optional(),\n }),\n )\n .optional(),\n allowMultiple: z.boolean().optional(),\n allowFreeForm: z\n .union([\n z.boolean(),\n z.object({\n secret: z.boolean(),\n }),\n ])\n .optional(),\n});\n\nexport const harnessV1QuestionsToolInputSchema = z.object({\n allowPartialAnswers: z.boolean(),\n questions: z.array(harnessV1QuestionSchema).min(1),\n});\n\nconst harnessV1QuestionAnswerSchema = z.object({\n optionIds: z.array(z.string()),\n freeform: z.string().optional(),\n});\n\nexport const harnessV1QuestionsToolOutputSchema = z.discriminatedUnion(\n 'action',\n [\n z.object({\n action: z.literal('answered'),\n answers: z.record(z.string(), harnessV1QuestionAnswerSchema),\n }),\n z.object({\n action: z.literal('partially-answered'),\n answers: z.record(z.string(), harnessV1QuestionAnswerSchema),\n }),\n z.object({ action: z.literal('declined') }),\n z.object({ action: z.literal('cancelled') }),\n ],\n);\n\nexport type HarnessV1QuestionsToolInput = z.infer<\n typeof harnessV1QuestionsToolInputSchema\n>;\n\nexport type HarnessV1QuestionsToolOutput = z.infer<\n typeof harnessV1QuestionsToolOutputSchema\n>;\n\nexport const harnessV1QuestionsTool: FunctionTool<\n HarnessV1QuestionsToolInput,\n HarnessV1QuestionsToolOutput\n> = {\n description: 'Ask the user one or more questions',\n inputSchema: harnessV1QuestionsToolInputSchema,\n outputSchema: harnessV1QuestionsToolOutputSchema,\n};\n\nexport type HarnessV1QuestionsTool = typeof harnessV1QuestionsTool;\n","import { posix } from 'node:path';\nimport type { Experimental_SandboxSession as SandboxSession } from '@ai-sdk/provider-utils';\n\n/**\n * Connection details for a sandbox-exposed port. Headers are scoped to the\n * returned URL and must be included when opening the connection.\n */\nexport type HarnessV1PortEndpoint = {\n readonly url: string;\n readonly headers?: Readonly<Record<string, string>>;\n};\n\n/**\n * Fixed directory, relative to the sandbox's own HOME, that holds every\n * piece of state the harness machinery generates.\n */\nconst HARNESS_V1_STATE_DIRECTORY_NAME = '.ai-sdk-harness';\n\n/**\n * Fixed, non-configurable path for harness-generated state (bootstrap files,\n * markers, and `.agent-runs`) under the sandbox's own HOME, never under\n * {@link HarnessV1NetworkSandboxSession.defaultWorkingDirectory}. Resolve HOME\n * with `resolveSandboxHomeDir` when it is not already known. This works from\n * provider creation hooks that only have a plain sandbox session. The\n * framework also calls this with a symbolic `$HOME` when hashing bootstrap\n * recipes, so changes to the state path invalidate existing templates.\n */\nexport function harnessStateDirectoryPath({\n sandboxHomeDir,\n}: {\n sandboxHomeDir: string;\n}): string {\n return posix.join(sandboxHomeDir, HARNESS_V1_STATE_DIRECTORY_NAME);\n}\n\n/**\n * Network sandbox session returned by sandbox adapter creation and resume\n * functions. The harness keeps this for the lifetime of a session. It is itself a\n * {@link SandboxSession} (file I/O, exec, spawn) and adds the infra surface on\n * top: port resolution, lifecycle, and network-policy mutation.\n *\n * Code that should only touch the filesystem and spawn processes receives the\n * reduced view from {@link HarnessV1NetworkSandboxSession.restricted}, never the\n * network sandbox session itself — so it cannot stop the sandbox, change\n * network access, or transform requests.\n */\nexport interface HarnessV1NetworkSandboxSession extends SandboxSession {\n /**\n * Identifier for the sandbox session. Persist this separately from the\n * harness session ID and resume state when reattaching across processes.\n */\n readonly id: string;\n\n /**\n * The sandbox's default working directory — the absolute path that\n * `run`/`spawn` resolve relative commands against when no `workingDirectory`\n * is given. Read from the live sandbox, never hardcoded.\n *\n * The framework composes each session's working directory underneath this\n * path (`<defaultWorkingDirectory>/<harnessId>-<sessionId>`) so adapters do\n * not bake a provider-specific base into their own paths.\n */\n readonly defaultWorkingDirectory: string;\n\n /** Ports the sandbox exposes; resolvable via `getPortEndpoint`. */\n readonly ports: ReadonlyArray<number>;\n\n /**\n * Resolve the connection details for a sandbox-exposed port. Bridge-backed\n * adapters call this to open their WebSocket to the in-sandbox bridge.\n */\n readonly getPortEndpoint: (options: {\n port: number;\n protocol?: 'http' | 'https' | 'ws';\n }) => PromiseLike<HarnessV1PortEndpoint>;\n\n /**\n * Resolve a publicly-reachable URL for a sandbox-exposed port.\n *\n * @deprecated Use `getPortEndpoint` instead.\n */\n readonly getPortUrl: (options: {\n port: number;\n protocol?: 'http' | 'https' | 'ws';\n }) => PromiseLike<string>;\n\n /** Stop the sandbox. Idempotent. */\n readonly stop: () => PromiseLike<void>;\n\n /**\n * Stop the sandbox session, then perform any additional cleanup necessary\n * to destroy it, such as deleting its backing resource or freeing resources.\n * Implementations with no cleanup beyond stopping may delegate to `stop()`.\n * Implementations must handle both a still-running sandbox and a previously\n * stopped sandbox.\n */\n readonly destroy: () => PromiseLike<void>;\n\n /**\n * Update the sandbox's outbound network policy. Optional — implementations\n * without a local enforcement primitive omit this. Callers\n * use optional-call (`sandboxSession.setNetworkPolicy?.(policy)`); a\n * missing implementation is a no-op.\n */\n readonly setNetworkPolicy?: (\n policy: HarnessV1NetworkPolicy,\n ) => PromiseLike<void>;\n\n /**\n * Replace the sandbox's outbound request-transformation rules. Optional —\n * implementations expose this only when credentials can be injected outside\n * the sandbox security boundary. Calling this method assumes authority over\n * the complete transformation set; harness adapters should normally use\n * `addRequestTransformations` instead. Adapters may preserve legacy\n * credential-forwarding behavior when additive request transformations are\n * unavailable.\n */\n readonly setRequestTransformations?: (\n transformations: ReadonlyArray<HarnessV1RequestTransformation>,\n ) => PromiseLike<void>;\n\n /**\n * Add outbound request-transformation rules without replacing rules already\n * managed by the sandbox session. Optional for the same reason as\n * `setRequestTransformations`. Harness adapters should use this additive\n * capability unless they explicitly own the complete transformation set.\n */\n readonly addRequestTransformations?: (\n transformations: ReadonlyArray<HarnessV1RequestTransformation>,\n ) => PromiseLike<void>;\n\n /**\n * Replace the set of ports exposed by the sandbox. Full-replacement\n * semantics: ports omitted from the array are deregistered. Optional —\n * implementations that cannot expose ports omit this.\n */\n readonly setPorts?: (\n ports: ReadonlyArray<number>,\n options?: { abortSignal?: AbortSignal },\n ) => PromiseLike<void>;\n\n /**\n * Reduced view of this session, typed as the bare {@link SandboxSession}\n * (file I/O, exec, spawn) — nothing that could stop the sandbox or change\n * its network policy. Pass this to user-tool `execute()` calls and other\n * code that must not reach the infra surface.\n *\n * The returned object points at exactly the same underlying sandbox\n * resource as the network sandbox session it was produced from; it is only a\n * narrower surface over the same resource, not a separate sandbox. In\n * particular, it cannot mutate network access or request transformations.\n */\n readonly restricted: () => SandboxSession;\n}\n\n/**\n * Outbound network policy applied by the sandbox runtime.\n *\n * `'allow-all'` and `'deny-all'` are convenience presets. `'custom'` is an\n * allow-list with an optional CIDR deny-list that takes precedence:\n *\n * - Reachable hosts are the union of `allowedHosts` and `allowedCIDRs`.\n * - `deniedCIDRs` wins over both, useful for blocking cloud-metadata IPs while\n * otherwise allowing broad access.\n *\n * The two `'custom'` branches share the same discriminator but each requires\n * a different allow field. Specifying `'custom'` with only `deniedCIDRs`\n * (deny-only) is rejected at compile time — functionally it would be\n * equivalent to `'deny-all'`.\n */\nexport type HarnessV1NetworkPolicy =\n | { mode: 'allow-all' }\n | { mode: 'deny-all' }\n | {\n mode: 'custom';\n allowedHosts: ReadonlyArray<string>;\n allowedCIDRs?: ReadonlyArray<string>;\n deniedCIDRs?: ReadonlyArray<string>;\n }\n | {\n mode: 'custom';\n allowedHosts?: ReadonlyArray<string>;\n allowedCIDRs: ReadonlyArray<string>;\n deniedCIDRs?: ReadonlyArray<string>;\n };\n\ntype HarnessV1RequestTransformationPathMatcher =\n | { exact: string }\n | { startsWith: string }\n | { regex: string };\n\ntype HarnessV1RequestTransformationKeyValuePartMatcher =\n | { exact: string }\n | { startsWith: string }\n | { regex: string };\n\ntype HarnessV1RequestTransformationKeyValueMatcher = {\n readonly key?: HarnessV1RequestTransformationKeyValuePartMatcher;\n readonly value?: HarnessV1RequestTransformationKeyValuePartMatcher;\n};\n\n/**\n * Outbound HTTPS request transformation applied outside the sandbox security\n * boundary. The host is part of the match so each rule is self-contained and\n * several rules, including several for the same host, can be installed at\n * once.\n *\n * Credential values belong in `transform.headers`, while the sandbox process\n * receives only a non-secret placeholder. Implementations must overwrite\n * matching request headers after the request leaves the sandbox rather than\n * making transformed values available inside it.\n */\nexport type HarnessV1RequestTransformation = {\n readonly match: {\n readonly host: string;\n readonly path?: HarnessV1RequestTransformationPathMatcher;\n readonly method?: ReadonlyArray<string>;\n readonly queryString?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;\n readonly headers?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;\n };\n readonly transform: {\n readonly headers: Readonly<Record<string, string>>;\n };\n};\n\nexport type HarnessV1RequestTransformationSources<AuthenticationMode> = {\n env: Record<string, string>;\n sandboxEnv: Record<string, string>;\n auth: AuthenticationMode;\n};\n","import { posix } from 'node:path';\n\nexport function encodeHarnessPathSegment(value: string): string {\n const encoded = encodeURIComponent(value);\n if (encoded === '') return '%';\n if (encoded === '.') return '%2E';\n if (encoded === '..') return '%2E%2E';\n return encoded;\n}\n\n/**\n * Return the per-session harness state path under `.agent-runs`. Session IDs\n * occupy one encoded path segment, so path separators and parent-directory\n * references cannot move session data outside the harness state directory.\n */\nexport function harnessSessionDataDirectoryPath({\n stateDirectory,\n sessionId,\n}: {\n stateDirectory: string;\n sessionId: string;\n}): string {\n return posix.join(\n stateDirectory,\n '.agent-runs',\n encodeHarnessPathSegment(sessionId),\n );\n}\n","import type {\n JSONValue,\n LanguageModelV4FinishReason,\n LanguageModelV4StreamPart,\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 inputs, calls, approvals, results — reuse V4 primitives.\n //\n // `nativeName` lets adapters surface the runtime's native name for a builtin\n // when it differs from the wire `toolName` (e.g. `toolName: 'bash'`,\n // `nativeName: 'Bash'`).\n //\n // `stepToolCallCount` lets adapters that know a step's complete tool-call\n // set up front report its cardinality. The host uses it to collect every\n // approval/result request from the step before pausing; adapters that cannot\n // know the count omit it and retain pause-on-first behavior.\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 | Extract<LanguageModelV4StreamPart, { type: 'tool-input-start' }>\n | Extract<LanguageModelV4StreamPart, { type: 'tool-input-delta' }>\n | Extract<LanguageModelV4StreamPart, { type: 'tool-input-end' }>\n | (LanguageModelV4ToolCall & {\n nativeName?: string;\n /**\n * Total tool calls in the current model step, when known before tool\n * execution begins. Populate this on every tool call in the step.\n */\n stepToolCallCount?: number;\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 harnessV1ToolInputStartPartSchema = z.object({\n type: z.literal('tool-input-start'),\n id: z.string(),\n toolName: z.string(),\n providerMetadata: harnessV1ProviderMetadataSchema.optional(),\n providerExecuted: z.boolean().optional(),\n dynamic: z.boolean().optional(),\n title: z.string().optional(),\n});\n\nexport const harnessV1ToolInputDeltaPartSchema = z.object({\n type: z.literal('tool-input-delta'),\n id: z.string(),\n delta: z.string(),\n providerMetadata: harnessV1ProviderMetadataSchema.optional(),\n});\n\nexport const harnessV1ToolInputEndPartSchema = z.object({\n type: z.literal('tool-input-end'),\n id: z.string(),\n providerMetadata: harnessV1ProviderMetadataSchema.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 stepToolCallCount: z.number().int().positive().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 harnessV1ToolInputStartPartSchema,\n harnessV1ToolInputDeltaPartSchema,\n harnessV1ToolInputEndPartSchema,\n harnessV1ToolCallPartSchema,\n harnessV1ToolApprovalRequestPartSchema,\n harnessV1ToolResultPartSchema,\n harnessV1FinishStepPartSchema,\n harnessV1FinishPartSchema,\n harnessV1FileChangePartSchema,\n harnessV1CompactionPartSchema,\n harnessV1ErrorPartSchema,\n harnessV1RawPartSchema,\n]);\n\n/*\n * Fail-fast guard at the definition site: the schema's output must be\n * assignable to `HarnessV1StreamPart` (catches a schema variant inventing a\n * shape the type does not allow). The reverse direction — the type being a\n * subset of the schema — is covered by the `toEqualTypeOf` assertion in the\n * type test.\n */\nconst _assignable: z.ZodType<HarnessV1StreamPart> = harnessV1StreamPartSchema;\nvoid _assignable;\n","import { z } from 'zod/v4';\nimport {\n harnessV1DebugConfigSchema,\n harnessV1DebugLevelSchema,\n type HarnessV1Diagnostic,\n} from './harness-v1-diagnostic';\nimport type { HarnessV1ResponseFormat } from './harness-v1-response-format';\nimport {\n harnessV1CompactionPartSchema,\n harnessV1ErrorPartSchema,\n harnessV1FileChangePartSchema,\n harnessV1FinishPartSchema,\n harnessV1FinishStepPartSchema,\n harnessV1RawPartSchema,\n harnessV1ReasoningDeltaPartSchema,\n harnessV1ReasoningEndPartSchema,\n harnessV1ReasoningStartPartSchema,\n harnessV1StreamStartPartSchema,\n harnessV1TextDeltaPartSchema,\n harnessV1TextEndPartSchema,\n harnessV1TextStartPartSchema,\n harnessV1ToolApprovalRequestPartSchema,\n harnessV1ToolCallPartSchema,\n harnessV1ToolInputDeltaPartSchema,\n harnessV1ToolInputEndPartSchema,\n harnessV1ToolInputStartPartSchema,\n harnessV1ToolResultPartSchema,\n} from './harness-v1-stream-part';\n\n/*\n * The bridge wire protocol shared by every bridge-backed harness adapter.\n *\n * This is the serialization of the host<->runtime contract for adapters that\n * run the agent runtime inside the sandbox and talk to the host over a\n * WebSocket. It exists ONLY because of that transport: untrusted JSON frames\n * crossing the sandbox boundary need runtime validation, the connection needs\n * a handshake, and the host drives turns with serialized commands. Every export\n * here is therefore prefixed `harnessV1Bridge…`.\n *\n * It has three tiers:\n *\n * 1. The OUTBOUND events — `HarnessV1StreamPart` re-expressed as Zod (imported\n * member schemas from `harness-v1-stream-part.ts`), because the part type is\n * compile-time only and the frames need runtime validation at the boundary.\n * 2. The transport/control frames that are NOT consumer events — `bridge-hello`\n * (handshake), `bridge-stop` (runtime resume data), `bridge-thread` (a resume\n * coordinate some runtimes announce). These ride the same socket.\n * 3. The INBOUND command vocabulary the host sends back: the shared commands\n * live here; the per-adapter `start` payload extends\n * `harnessV1BridgeStartBaseSchema` and assembles the final inbound union in\n * the adapter package.\n *\n * Non-bridge adapters (e.g. Pi) do not use this layer at all — they have no\n * serialization boundary and target the universal `HarnessV1StreamPart` type\n * directly. That is the deliberate split: `harness-v1-stream-part.ts` is the\n * transport-agnostic event vocabulary; this file is the bridge transport.\n */\n\n/**\n * The subset of a host-defined tool that travels on the `start` message. The\n * runtime only needs the name, description, and JSON-Schema input to surface\n * the tool; `execute` stays on the host.\n */\nexport const harnessV1BridgeToolWireSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n inputSchema: z.unknown().optional(),\n});\n\nexport type HarnessV1BridgeToolWire = z.infer<\n typeof harnessV1BridgeToolWireSchema\n>;\n\nexport const harnessV1BridgePermissionModeSchema = z.enum([\n 'allow-reads',\n 'allow-edits',\n 'allow-all',\n]);\n\nexport const harnessV1BridgeBuiltinToolFilteringSchema = z.discriminatedUnion(\n 'mode',\n [\n z.object({\n mode: z.literal('allow'),\n toolNames: z.array(z.string()),\n }),\n z.object({\n mode: z.literal('deny'),\n toolNames: z.array(z.string()),\n }),\n ],\n);\n\nexport const harnessV1BridgeResponseFormatSchema: z.ZodType<HarnessV1ResponseFormat> =\n z.discriminatedUnion('type', [\n z.object({ type: z.literal('text') }),\n z.object({\n type: z.literal('json'),\n schema: z.record(z.string(), z.json()).optional(),\n name: z.string().optional(),\n description: z.string().optional(),\n }),\n ]);\n\n/**\n * Common fields of the inbound `start` message. Each adapter extends this with\n * its runtime-specific configuration (e.g. `thinking`/`continue` for Claude\n * Code, `reasoningEffort`/`webSearch`/`skills`/`resumeThreadId` for Codex) and\n * assembles the final inbound union from the shared command members below.\n *\n * `debug` carries the general `HarnessV1DebugConfig` — diagnostics config is not\n * a bridge concept, it just happens to ride the `start` frame for bridge-backed\n * adapters.\n */\nexport const harnessV1BridgeStartBaseSchema = z.object({\n type: z.literal('start'),\n prompt: z.string(),\n tools: z.array(harnessV1BridgeToolWireSchema).optional(),\n model: z.string().optional(),\n debug: harnessV1DebugConfigSchema.optional(),\n permissionMode: harnessV1BridgePermissionModeSchema.optional(),\n builtinToolFiltering: harnessV1BridgeBuiltinToolFilteringSchema.optional(),\n responseFormat: harnessV1BridgeResponseFormatSchema.optional(),\n});\n\n// --- Transport / control frames (outbound, not consumer events) ---\n\n/**\n * Sent the instant the bridge accepts an authenticated WS connection. The host\n * waits for it before sending `start`/`resume`, because some sandbox runtimes\n * complete the upstream WS handshake before the connection is wired through to\n * the bridge process — anything sent in that gap is dropped. Carries the\n * bridge's lifecycle `state` and highest emitted `seq` for reconnect.\n */\nexport const harnessV1BridgeHelloSchema = z.object({\n type: z.literal('bridge-hello'),\n state: z.string().optional(),\n lastSeq: z.number().optional(),\n capabilities: z\n .object({\n experimental_userMessageResponses: z.boolean().optional(),\n })\n .optional(),\n});\n\nexport const experimental_harnessV1BridgeUserMessageResponseSchema = z.object({\n type: z.literal('user-message-response'),\n messageId: z.string(),\n accepted: z.boolean(),\n error: z.object({ message: z.string() }).optional(),\n});\n\n/**\n * The bridge's reply to an inbound `stop`. Carries the adapter-specific\n * payload the host serializes into lifecycle state `data`.\n */\nexport const harnessV1BridgeStopSchema = z.object({\n type: z.literal('bridge-stop'),\n data: z.unknown(),\n});\n\n/**\n * A resume coordinate the bridge proactively announces (e.g. Codex's thread id)\n * so the host can cache it for a later resume without waiting for `stop`.\n */\nexport const harnessV1BridgeThreadSchema = z.object({\n type: z.literal('bridge-thread'),\n threadId: z.string(),\n});\n\n// --- Diagnostics frames (outbound, not consumer events) ---\n\n/**\n * One captured console line from inside the sandbox. The bridge line-buffers\n * `process.stdout`/`process.stderr` and emits one of these per complete line.\n * Routed host-side to the diagnostics sink, never to the consumer stream.\n */\nexport const harnessV1BridgeSandboxLogSchema = z.object({\n type: z.literal('sandbox-log'),\n source: z.string(),\n stream: z.enum(['stdout', 'stderr']),\n line: z.string(),\n});\n\n/**\n * A structured diagnostic an adapter emits from inside the bridge via\n * `turn.bridgeLog(...)`. Gated by the session's debug level + subsystem filter.\n */\nexport const harnessV1BridgeDebugEventSchema = z.object({\n type: z.literal('debug-event'),\n level: harnessV1DebugLevelSchema,\n subsystem: z.string(),\n message: z.string(),\n attrs: z.record(z.string(), z.unknown()).optional(),\n error: z\n .object({\n name: z.string().optional(),\n message: z.string(),\n stack: z.string().optional(),\n })\n .optional(),\n});\n\n/**\n * Every frame a bridge can send to the host: the stream-part events plus the\n * transport/control frames. This is the schema the host `SandboxChannel`\n * validates inbound frames against.\n */\nexport const harnessV1BridgeOutboundMessageSchema = z.discriminatedUnion(\n 'type',\n [\n harnessV1StreamStartPartSchema,\n harnessV1TextStartPartSchema,\n harnessV1TextDeltaPartSchema,\n harnessV1TextEndPartSchema,\n harnessV1ReasoningStartPartSchema,\n harnessV1ReasoningDeltaPartSchema,\n harnessV1ReasoningEndPartSchema,\n harnessV1ToolInputStartPartSchema,\n harnessV1ToolInputDeltaPartSchema,\n harnessV1ToolInputEndPartSchema,\n harnessV1ToolCallPartSchema,\n harnessV1ToolApprovalRequestPartSchema,\n harnessV1ToolResultPartSchema,\n harnessV1FinishStepPartSchema,\n harnessV1FinishPartSchema,\n harnessV1FileChangePartSchema,\n harnessV1CompactionPartSchema,\n harnessV1ErrorPartSchema,\n harnessV1RawPartSchema,\n harnessV1BridgeHelloSchema,\n experimental_harnessV1BridgeUserMessageResponseSchema,\n harnessV1BridgeStopSchema,\n harnessV1BridgeThreadSchema,\n harnessV1BridgeSandboxLogSchema,\n harnessV1BridgeDebugEventSchema,\n ],\n);\n\nexport type HarnessV1BridgeOutboundMessage = z.infer<\n typeof harnessV1BridgeOutboundMessageSchema\n>;\n\nexport type Experimental_HarnessV1BridgeUserMessageResponse = z.infer<\n typeof experimental_harnessV1BridgeUserMessageResponseSchema\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 toolResult: z.unknown().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 messageId: z.string().optional(),\n text: z.string(),\n});\n\nexport const experimental_harnessV1BridgeUserMessageInboundSchema =\n harnessV1BridgeUserMessageInboundSchema.extend({\n messageId: z.string(),\n });\n\nexport const harnessV1BridgeAbortInboundSchema = z.object({\n type: z.literal('abort'),\n});\n\nexport const harnessV1BridgeDestroyInboundSchema = z.object({\n type: z.literal('destroy'),\n});\n\n/**\n * Reconnect: after re-establishing the socket the host asks the bridge to\n * replay every buffered event with `seq > lastSeenEventId`.\n */\nexport const harnessV1BridgeResumeInboundSchema = z.object({\n type: z.literal('resume'),\n lastSeenEventId: z.number(),\n});\n\n/**\n * The bridge replies with `bridge-stop` carrying any runtime resume data,\n * then exits.\n */\nexport const harnessV1BridgeStopInboundSchema = z.object({\n type: z.literal('stop'),\n});\n\n/**\n * The inbound command members shared by every bridge adapter. Spread these\n * alongside the adapter's own `start` schema to build the final inbound union:\n * `z.discriminatedUnion('type', [adapterStartSchema, ...harnessV1BridgeInboundCommandSchemas])`.\n */\nexport const harnessV1BridgeInboundCommandSchemas = [\n harnessV1BridgeToolResultInboundSchema,\n harnessV1BridgeToolApprovalResponseInboundSchema,\n harnessV1BridgeUserMessageInboundSchema,\n harnessV1BridgeAbortInboundSchema,\n harnessV1BridgeDestroyInboundSchema,\n harnessV1BridgeResumeInboundSchema,\n harnessV1BridgeStopInboundSchema,\n] as const;\n\n/**\n * The JSON line the bridge writes to stdout once its WebSocket server is bound,\n * announcing the port the host should connect to.\n */\nexport const harnessV1BridgeReadySchema = z.object({\n type: z.literal('bridge-ready'),\n port: z.number(),\n});\n\nexport type HarnessV1BridgeReady = z.infer<typeof harnessV1BridgeReadySchema>;\n","import { z } from 'zod/v4';\n\n/*\n * Diagnostics EMISSION contract — part of the `HarnessV1` spec.\n *\n * These are the types a harness adapter produces and receives: an adapter\n * reports a `HarnessV1Diagnostic` to the framework (a bridge adapter normalizes\n * its wire frames into one; a non-bridge adapter constructs one directly), and\n * receives a `HarnessV1DebugConfig` to gate what it emits. They are distinct\n * from the unaffixed host-facing `HarnessDiagnostic` / `HarnessDebugConfig`\n * (the external/telemetry surface) — the framework maps between the two at the\n * boundary, so the emission and consumption surfaces can evolve independently.\n */\n\n/** Severity of a diagnostic, ordered most → least severe. */\nexport const harnessV1DebugLevelSchema = z.enum([\n 'error',\n 'warn',\n 'info',\n 'debug',\n 'trace',\n]);\n\nexport type HarnessV1DebugLevel = z.infer<typeof harnessV1DebugLevelSchema>;\n\n/**\n * Per-session diagnostics configuration the framework hands an adapter (and the\n * host sends on `start.debug`). When absent or `enabled` is false the adapter\n * captures and emits nothing. `subsystems` filters structured events by dotted\n * prefix; console capture is independent of the subsystem filter.\n */\nexport const harnessV1DebugConfigSchema = z.object({\n enabled: z.boolean().optional(),\n level: harnessV1DebugLevelSchema.optional(),\n subsystems: z.array(z.string()).optional(),\n});\n\nexport type HarnessV1DebugConfig = z.infer<typeof harnessV1DebugConfigSchema>;\n\n/**\n * A diagnostic as emitted by a harness adapter. Structurally identical to the\n * host-facing `HarnessDiagnostic` today, but kept separate: this is the spec's\n * emission shape, that is the external consumption shape.\n */\nexport type HarnessV1Diagnostic = {\n /** Severity. */\n readonly level: HarnessV1DebugLevel;\n /** Human-readable line (console capture) or message (structured event). */\n readonly message: string;\n /** Dotted subsystem (`sandbox.log.<source>` for console capture). */\n readonly subsystem: string;\n /** `'log'` = captured console line; `'event'` = structured emission. */\n readonly kind: 'log' | 'event';\n /** Originating source label (console capture). */\n readonly source?: string;\n /** Which standard stream the line came from (console capture). */\n readonly stream?: 'stdout' | 'stderr';\n /** Structured attributes (structured events only). */\n readonly attrs?: Record<string, unknown>;\n /** Error payload (structured events only). */\n readonly error?: { name?: string; message: string; stack?: string };\n /** The harness session this diagnostic originated from. */\n readonly sessionId?: string;\n /** Emission time (epoch ms). */\n readonly timestamp: number;\n};\n","export type HarnessV1BuiltinToolFiltering =\n | {\n mode: 'allow';\n toolNames: string[];\n }\n | {\n mode: 'deny';\n toolNames: string[];\n };\n\nexport function isHarnessV1BuiltinToolIncluded(input: {\n toolName: string;\n toolFiltering: HarnessV1BuiltinToolFiltering | undefined;\n}): boolean {\n if (input.toolFiltering == null) return true;\n return input.toolFiltering.mode === 'allow'\n ? input.toolFiltering.toolNames.includes(input.toolName)\n : !input.toolFiltering.toolNames.includes(input.toolName);\n}\n\nexport function getHarnessV1BuiltinToolFilteringDenialReason(input: {\n toolName: string;\n}): string {\n return `Tool '${input.toolName}' is inactive due to the HarnessAgent tool filtering policy.`;\n}\n","import { AISDKError } from '@ai-sdk/provider';\n\nconst name = 'AI_HarnessError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Base error type for failures originating in or signalled by a harness\n * adapter. Specific failure modes (e.g. unsupported capability) extend this\n * class.\n */\nexport class HarnessError extends AISDKError {\n private readonly [symbol] = true;\n\n constructor({ message, cause }: { message: string; cause?: unknown }) {\n super({ name, message, cause });\n }\n\n static isInstance(error: unknown): error is HarnessError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from '@ai-sdk/provider';\nimport { HarnessError } from './harness-error';\n\nconst name = 'AI_HarnessCapabilityUnsupportedError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown when a caller asks the harness to do something the adapter (or the\n * supplied sandbox) does not support, e.g. requesting manual compaction from\n * an adapter that only auto-compacts, or invoking `getPortEndpoint` on a\n * sandbox that does not expose one.\n *\n * The caller supplies the full human-readable message. Optional `harnessId`\n * is recorded as structured context for tooling.\n */\nexport class HarnessCapabilityUnsupportedError extends HarnessError {\n private readonly [symbol] = true;\n\n readonly harnessId?: string;\n\n constructor({\n message,\n harnessId,\n cause,\n }: {\n message: string;\n harnessId?: string;\n cause?: unknown;\n }) {\n super({ message, cause });\n Object.defineProperty(this, 'name', { value: name });\n this.harnessId = harnessId;\n }\n\n static isInstance(\n error: unknown,\n ): error is HarnessCapabilityUnsupportedError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from '@ai-sdk/provider';\nimport { HarnessError } from './harness-error';\n\nconst name = 'AI_HarnessSandboxAuthenticationError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown when a sandbox provider cannot authenticate or authorize the\n * operation needed to create or resume a harness sandbox. Providers should\n * preserve the underlying SDK failure as `cause` and supply a message that\n * explains how the consumer can configure credentials.\n */\nexport class HarnessSandboxAuthenticationError extends HarnessError {\n private readonly [symbol] = true;\n\n readonly sandboxProviderId: string;\n\n constructor({\n message,\n sandboxProviderId,\n cause,\n }: {\n message: string;\n sandboxProviderId: string;\n cause?: unknown;\n }) {\n super({ message, cause });\n Object.defineProperty(this, 'name', { value: name });\n this.sandboxProviderId = sandboxProviderId;\n }\n\n static isInstance(\n error: unknown,\n ): error is HarnessSandboxAuthenticationError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n"],"mappings":";AAAA,SAAS,YAA4C;AACrD,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAElB,IAAM,0BAA0B,EAAE,OAAO;AAAA,EACvC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACpB,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC1B,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,SAAS,EACN;AAAA,IACC,EAAE,OAAO;AAAA,MACP,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,MACpB,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,MACvB,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,MACjC,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,IAC/B,CAAC;AAAA,EACH,EACC,SAAS;AAAA,EACZ,eAAe,EAAE,QAAQ,EAAE,SAAS;AAAA,EACpC,eAAe,EACZ,MAAM;AAAA,IACL,EAAE,QAAQ;AAAA,IACV,E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,SAAS,MAAM,CAAC;AAb1B,SAAkBD,OAAU;AAc1B,WAAO,eAAe,MAAM,QAAQ,EAAE,OAAOH,MAAK,CAAC;AACnD,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,OAAO,WACL,OAC4C;AAC5C,WAAOK,YAAW,UAAU,OAAOJ,OAAM;AAAA,EAC3C;AACF;;;ACxCA,SAAS,cAAAK,mBAAkB;AAG3B,IAAMC,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AALhC,IAAAE,KAAAC;AAaO,IAAM,oCAAN,eAAgDA,MAAA,cACnCD,MAAAD,SADmCE,KAAa;AAAA,EAKlE,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,EAAE,SAAS,MAAM,CAAC;AAb1B,SAAkBD,OAAU;AAc1B,WAAO,eAAe,MAAM,QAAQ,EAAE,OAAOH,MAAK,CAAC;AACnD,SAAK,oBAAoB;AAAA,EAC3B;AAAA,EAEA,OAAO,WACL,OAC4C;AAC5C,WAAOK,YAAW,UAAU,OAAOJ,OAAM;AAAA,EAC3C;AACF;","names":["z","z","posix","z","z","z","z","AISDKError","name","marker","symbol","_a","_b","AISDKError","AISDKError","name","marker","symbol","_a","_b","AISDKError"]}
1
+ {"version":3,"sources":["../src/v1/harness-v1-builtin-tool.ts","../src/v1/harness-v1-questions-tool.ts","../src/v1/harness-v1-network-sandbox-session.ts","../src/v1/harness-session-data-directory-path.ts","../src/v1/harness-v1-stream-part.ts","../src/v1/harness-v1-bridge-protocol.ts","../src/v1/harness-v1-diagnostic.ts","../src/v1/harness-v1-tool-filtering.ts","../src/errors/harness-error.ts","../src/errors/harness-capability-unsupported-error.ts","../src/errors/harness-history-unavailable-error.ts","../src/errors/harness-sandbox-authentication-error.ts"],"sourcesContent":["import { tool, type FlexibleSchema, type Tool } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { harnessV1QuestionsTool } from './harness-v1-questions-tool';\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 askUserQuestions: harnessV1QuestionsTool,\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 { FunctionTool } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst harnessV1QuestionSchema = z.object({\n id: z.string().min(1),\n question: z.string().min(1),\n header: z.string().optional(),\n options: z\n .array(\n z.object({\n id: z.string().min(1),\n label: z.string().min(1),\n description: z.string().optional(),\n preview: z.string().optional(),\n }),\n )\n .optional(),\n allowMultiple: z.boolean().optional(),\n allowFreeForm: z\n .union([\n z.boolean(),\n z.object({\n secret: z.boolean(),\n }),\n ])\n .optional(),\n});\n\nexport const harnessV1QuestionsToolInputSchema = z.object({\n allowPartialAnswers: z.boolean(),\n questions: z.array(harnessV1QuestionSchema).min(1),\n});\n\nconst harnessV1QuestionAnswerSchema = z.object({\n optionIds: z.array(z.string()),\n freeform: z.string().optional(),\n});\n\nexport const harnessV1QuestionsToolOutputSchema = z.discriminatedUnion(\n 'action',\n [\n z.object({\n action: z.literal('answered'),\n answers: z.record(z.string(), harnessV1QuestionAnswerSchema),\n }),\n z.object({\n action: z.literal('partially-answered'),\n answers: z.record(z.string(), harnessV1QuestionAnswerSchema),\n }),\n z.object({ action: z.literal('declined') }),\n z.object({ action: z.literal('cancelled') }),\n ],\n);\n\nexport type HarnessV1QuestionsToolInput = z.infer<\n typeof harnessV1QuestionsToolInputSchema\n>;\n\nexport type HarnessV1QuestionsToolOutput = z.infer<\n typeof harnessV1QuestionsToolOutputSchema\n>;\n\nexport const harnessV1QuestionsTool: FunctionTool<\n HarnessV1QuestionsToolInput,\n HarnessV1QuestionsToolOutput\n> = {\n description: 'Ask the user one or more questions',\n inputSchema: harnessV1QuestionsToolInputSchema,\n outputSchema: harnessV1QuestionsToolOutputSchema,\n};\n\nexport type HarnessV1QuestionsTool = typeof harnessV1QuestionsTool;\n","import { posix } from 'node:path';\nimport type { Experimental_SandboxSession as SandboxSession } from '@ai-sdk/provider-utils';\n\n/**\n * Connection details for a sandbox-exposed port. Headers are scoped to the\n * returned URL and must be included when opening the connection.\n */\nexport type HarnessV1PortEndpoint = {\n readonly url: string;\n readonly headers?: Readonly<Record<string, string>>;\n};\n\n/**\n * Fixed directory, relative to the sandbox's own HOME, that holds every\n * piece of state the harness machinery generates.\n */\nconst HARNESS_V1_STATE_DIRECTORY_NAME = '.ai-sdk-harness';\n\n/**\n * Fixed, non-configurable path for harness-generated state (bootstrap files,\n * markers, and `.agent-runs`) under the sandbox's own HOME, never under\n * {@link HarnessV1NetworkSandboxSession.defaultWorkingDirectory}. Resolve HOME\n * with `resolveSandboxHomeDir` when it is not already known. This works from\n * provider creation hooks that only have a plain sandbox session. The\n * framework also calls this with a symbolic `$HOME` when hashing bootstrap\n * recipes, so changes to the state path invalidate existing templates.\n */\nexport function harnessStateDirectoryPath({\n sandboxHomeDir,\n}: {\n sandboxHomeDir: string;\n}): string {\n return posix.join(sandboxHomeDir, HARNESS_V1_STATE_DIRECTORY_NAME);\n}\n\n/**\n * Network sandbox session returned by sandbox adapter creation and resume\n * functions. The harness keeps this for the lifetime of a session. It is itself a\n * {@link SandboxSession} (file I/O, exec, spawn) and adds the infra surface on\n * top: port resolution, lifecycle, and network-policy mutation.\n *\n * Code that should only touch the filesystem and spawn processes receives the\n * reduced view from {@link HarnessV1NetworkSandboxSession.restricted}, never the\n * network sandbox session itself — so it cannot stop the sandbox, change\n * network access, or transform requests.\n */\nexport interface HarnessV1NetworkSandboxSession extends SandboxSession {\n /**\n * Identifier for the sandbox session. Persist this separately from the\n * harness session ID and resume state when reattaching across processes.\n */\n readonly id: string;\n\n /**\n * The sandbox's default working directory — the absolute path that\n * `run`/`spawn` resolve relative commands against when no `workingDirectory`\n * is given. Read from the live sandbox, never hardcoded.\n *\n * The framework composes each session's working directory underneath this\n * path (`<defaultWorkingDirectory>/<harnessId>-<sessionId>`) so adapters do\n * not bake a provider-specific base into their own paths.\n */\n readonly defaultWorkingDirectory: string;\n\n /** Ports the sandbox exposes; resolvable via `getPortEndpoint`. */\n readonly ports: ReadonlyArray<number>;\n\n /**\n * Resolve the connection details for a sandbox-exposed port. Bridge-backed\n * adapters call this to open their WebSocket to the in-sandbox bridge.\n */\n readonly getPortEndpoint: (options: {\n port: number;\n protocol?: 'http' | 'https' | 'ws';\n }) => PromiseLike<HarnessV1PortEndpoint>;\n\n /**\n * Resolve a publicly-reachable URL for a sandbox-exposed port.\n *\n * @deprecated Use `getPortEndpoint` instead.\n */\n readonly getPortUrl: (options: {\n port: number;\n protocol?: 'http' | 'https' | 'ws';\n }) => PromiseLike<string>;\n\n /** Stop the sandbox. Idempotent. */\n readonly stop: () => PromiseLike<void>;\n\n /**\n * Stop the sandbox session, then perform any additional cleanup necessary\n * to destroy it, such as deleting its backing resource or freeing resources.\n * Implementations with no cleanup beyond stopping may delegate to `stop()`.\n * Implementations must handle both a still-running sandbox and a previously\n * stopped sandbox.\n */\n readonly destroy: () => PromiseLike<void>;\n\n /**\n * Update the sandbox's outbound network policy. Optional — implementations\n * without a local enforcement primitive omit this. Callers\n * use optional-call (`sandboxSession.setNetworkPolicy?.(policy)`); a\n * missing implementation is a no-op.\n */\n readonly setNetworkPolicy?: (\n policy: HarnessV1NetworkPolicy,\n ) => PromiseLike<void>;\n\n /**\n * Replace the sandbox's outbound request-transformation rules. Optional —\n * implementations expose this only when credentials can be injected outside\n * the sandbox security boundary. Calling this method assumes authority over\n * the complete transformation set; harness adapters should normally use\n * `addRequestTransformations` instead. Adapters may preserve legacy\n * credential-forwarding behavior when additive request transformations are\n * unavailable.\n */\n readonly setRequestTransformations?: (\n transformations: ReadonlyArray<HarnessV1RequestTransformation>,\n ) => PromiseLike<void>;\n\n /**\n * Add outbound request-transformation rules without replacing rules already\n * managed by the sandbox session. Optional for the same reason as\n * `setRequestTransformations`. Harness adapters should use this additive\n * capability unless they explicitly own the complete transformation set.\n */\n readonly addRequestTransformations?: (\n transformations: ReadonlyArray<HarnessV1RequestTransformation>,\n ) => PromiseLike<void>;\n\n /**\n * Replace the set of ports exposed by the sandbox. Full-replacement\n * semantics: ports omitted from the array are deregistered. Optional —\n * implementations that cannot expose ports omit this.\n */\n readonly setPorts?: (\n ports: ReadonlyArray<number>,\n options?: { abortSignal?: AbortSignal },\n ) => PromiseLike<void>;\n\n /**\n * Reduced view of this session, typed as the bare {@link SandboxSession}\n * (file I/O, exec, spawn) — nothing that could stop the sandbox or change\n * its network policy. Pass this to user-tool `execute()` calls and other\n * code that must not reach the infra surface.\n *\n * The returned object points at exactly the same underlying sandbox\n * resource as the network sandbox session it was produced from; it is only a\n * narrower surface over the same resource, not a separate sandbox. In\n * particular, it cannot mutate network access or request transformations.\n */\n readonly restricted: () => SandboxSession;\n}\n\n/**\n * Outbound network policy applied by the sandbox runtime.\n *\n * `'allow-all'` and `'deny-all'` are convenience presets. `'custom'` is an\n * allow-list with an optional CIDR deny-list that takes precedence:\n *\n * - Reachable hosts are the union of `allowedHosts` and `allowedCIDRs`.\n * - `deniedCIDRs` wins over both, useful for blocking cloud-metadata IPs while\n * otherwise allowing broad access.\n *\n * The two `'custom'` branches share the same discriminator but each requires\n * a different allow field. Specifying `'custom'` with only `deniedCIDRs`\n * (deny-only) is rejected at compile time — functionally it would be\n * equivalent to `'deny-all'`.\n */\nexport type HarnessV1NetworkPolicy =\n | { mode: 'allow-all' }\n | { mode: 'deny-all' }\n | {\n mode: 'custom';\n allowedHosts: ReadonlyArray<string>;\n allowedCIDRs?: ReadonlyArray<string>;\n deniedCIDRs?: ReadonlyArray<string>;\n }\n | {\n mode: 'custom';\n allowedHosts?: ReadonlyArray<string>;\n allowedCIDRs: ReadonlyArray<string>;\n deniedCIDRs?: ReadonlyArray<string>;\n };\n\ntype HarnessV1RequestTransformationPathMatcher =\n | { exact: string }\n | { startsWith: string }\n | { regex: string };\n\ntype HarnessV1RequestTransformationKeyValuePartMatcher =\n | { exact: string }\n | { startsWith: string }\n | { regex: string };\n\ntype HarnessV1RequestTransformationKeyValueMatcher = {\n readonly key?: HarnessV1RequestTransformationKeyValuePartMatcher;\n readonly value?: HarnessV1RequestTransformationKeyValuePartMatcher;\n};\n\n/**\n * Outbound HTTPS request transformation applied outside the sandbox security\n * boundary. The host is part of the match so each rule is self-contained and\n * several rules, including several for the same host, can be installed at\n * once.\n *\n * Credential values belong in `transform.headers`, while the sandbox process\n * receives only a non-secret placeholder. Implementations must overwrite\n * matching request headers after the request leaves the sandbox rather than\n * making transformed values available inside it.\n */\nexport type HarnessV1RequestTransformation = {\n readonly match: {\n readonly host: string;\n readonly path?: HarnessV1RequestTransformationPathMatcher;\n readonly method?: ReadonlyArray<string>;\n readonly queryString?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;\n readonly headers?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;\n };\n readonly transform: {\n readonly headers: Readonly<Record<string, string>>;\n };\n};\n\nexport type HarnessV1RequestTransformationSources<AuthenticationMode> = {\n env: Record<string, string>;\n sandboxEnv: Record<string, string>;\n auth: AuthenticationMode;\n};\n","import { posix } from 'node:path';\n\nexport function encodeHarnessPathSegment(value: string): string {\n const encoded = encodeURIComponent(value);\n if (encoded === '') return '%';\n if (encoded === '.') return '%2E';\n if (encoded === '..') return '%2E%2E';\n return encoded;\n}\n\n/**\n * Return the per-session harness state path under `.agent-runs`. Session IDs\n * occupy one encoded path segment, so path separators and parent-directory\n * references cannot move session data outside the harness state directory.\n */\nexport function harnessSessionDataDirectoryPath({\n stateDirectory,\n sessionId,\n}: {\n stateDirectory: string;\n sessionId: string;\n}): string {\n return posix.join(\n stateDirectory,\n '.agent-runs',\n encodeHarnessPathSegment(sessionId),\n );\n}\n","import type {\n JSONValue,\n LanguageModelV4FinishReason,\n LanguageModelV4StreamPart,\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 inputs, calls, approvals, results — reuse V4 primitives.\n //\n // `nativeName` lets adapters surface the runtime's native name for a builtin\n // when it differs from the wire `toolName` (e.g. `toolName: 'bash'`,\n // `nativeName: 'Bash'`).\n //\n // `stepToolCallCount` lets adapters that know a step's complete tool-call\n // set up front report its cardinality. The host uses it to collect every\n // approval/result request from the step before pausing; adapters that cannot\n // know the count omit it and retain pause-on-first behavior.\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 | Extract<LanguageModelV4StreamPart, { type: 'tool-input-start' }>\n | Extract<LanguageModelV4StreamPart, { type: 'tool-input-delta' }>\n | Extract<LanguageModelV4StreamPart, { type: 'tool-input-end' }>\n | (LanguageModelV4ToolCall & {\n nativeName?: string;\n /**\n * Total tool calls in the current model step, when known before tool\n * execution begins. Populate this on every tool call in the step.\n */\n stepToolCallCount?: number;\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 harnessV1ToolInputStartPartSchema = z.object({\n type: z.literal('tool-input-start'),\n id: z.string(),\n toolName: z.string(),\n providerMetadata: harnessV1ProviderMetadataSchema.optional(),\n providerExecuted: z.boolean().optional(),\n dynamic: z.boolean().optional(),\n title: z.string().optional(),\n});\n\nexport const harnessV1ToolInputDeltaPartSchema = z.object({\n type: z.literal('tool-input-delta'),\n id: z.string(),\n delta: z.string(),\n providerMetadata: harnessV1ProviderMetadataSchema.optional(),\n});\n\nexport const harnessV1ToolInputEndPartSchema = z.object({\n type: z.literal('tool-input-end'),\n id: z.string(),\n providerMetadata: harnessV1ProviderMetadataSchema.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 stepToolCallCount: z.number().int().positive().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 harnessV1ToolInputStartPartSchema,\n harnessV1ToolInputDeltaPartSchema,\n harnessV1ToolInputEndPartSchema,\n harnessV1ToolCallPartSchema,\n harnessV1ToolApprovalRequestPartSchema,\n harnessV1ToolResultPartSchema,\n harnessV1FinishStepPartSchema,\n harnessV1FinishPartSchema,\n harnessV1FileChangePartSchema,\n harnessV1CompactionPartSchema,\n harnessV1ErrorPartSchema,\n harnessV1RawPartSchema,\n]);\n\n/*\n * Fail-fast guard at the definition site: the schema's output must be\n * assignable to `HarnessV1StreamPart` (catches a schema variant inventing a\n * shape the type does not allow). The reverse direction — the type being a\n * subset of the schema — is covered by the `toEqualTypeOf` assertion in the\n * type test.\n */\nconst _assignable: z.ZodType<HarnessV1StreamPart> = harnessV1StreamPartSchema;\nvoid _assignable;\n","import { z } from 'zod/v4';\nimport {\n harnessV1DebugConfigSchema,\n harnessV1DebugLevelSchema,\n type HarnessV1Diagnostic,\n} from './harness-v1-diagnostic';\nimport type { HarnessV1ResponseFormat } from './harness-v1-response-format';\nimport {\n harnessV1CompactionPartSchema,\n harnessV1ErrorPartSchema,\n harnessV1FileChangePartSchema,\n harnessV1FinishPartSchema,\n harnessV1FinishStepPartSchema,\n harnessV1RawPartSchema,\n harnessV1ReasoningDeltaPartSchema,\n harnessV1ReasoningEndPartSchema,\n harnessV1ReasoningStartPartSchema,\n harnessV1StreamStartPartSchema,\n harnessV1TextDeltaPartSchema,\n harnessV1TextEndPartSchema,\n harnessV1TextStartPartSchema,\n harnessV1ToolApprovalRequestPartSchema,\n harnessV1ToolCallPartSchema,\n harnessV1ToolInputDeltaPartSchema,\n harnessV1ToolInputEndPartSchema,\n harnessV1ToolInputStartPartSchema,\n harnessV1ToolResultPartSchema,\n} from './harness-v1-stream-part';\n\n/*\n * The bridge wire protocol shared by every bridge-backed harness adapter.\n *\n * This is the serialization of the host<->runtime contract for adapters that\n * run the agent runtime inside the sandbox and talk to the host over a\n * WebSocket. It exists ONLY because of that transport: untrusted JSON frames\n * crossing the sandbox boundary need runtime validation, the connection needs\n * a handshake, and the host drives turns with serialized commands. Every export\n * here is therefore prefixed `harnessV1Bridge…`.\n *\n * It has three tiers:\n *\n * 1. The OUTBOUND events — `HarnessV1StreamPart` re-expressed as Zod (imported\n * member schemas from `harness-v1-stream-part.ts`), because the part type is\n * compile-time only and the frames need runtime validation at the boundary.\n * 2. The transport/control frames that are NOT consumer events — `bridge-hello`\n * (handshake), `bridge-stop` (runtime resume data), `bridge-thread` (a resume\n * coordinate some runtimes announce). These ride the same socket.\n * 3. The INBOUND command vocabulary the host sends back: the shared commands\n * live here; the per-adapter `start` payload extends\n * `harnessV1BridgeStartBaseSchema` and assembles the final inbound union in\n * the adapter package.\n *\n * Non-bridge adapters (e.g. Pi) do not use this layer at all — they have no\n * serialization boundary and target the universal `HarnessV1StreamPart` type\n * directly. That is the deliberate split: `harness-v1-stream-part.ts` is the\n * transport-agnostic event vocabulary; this file is the bridge transport.\n */\n\n/**\n * The subset of a host-defined tool that travels on the `start` message. The\n * runtime only needs the name, description, and JSON-Schema input to surface\n * the tool; `execute` stays on the host.\n */\nexport const harnessV1BridgeToolWireSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n inputSchema: z.unknown().optional(),\n});\n\nexport type HarnessV1BridgeToolWire = z.infer<\n typeof harnessV1BridgeToolWireSchema\n>;\n\nexport const harnessV1BridgePermissionModeSchema = z.enum([\n 'allow-reads',\n 'allow-edits',\n 'allow-all',\n]);\n\nexport const harnessV1BridgeBuiltinToolFilteringSchema = z.discriminatedUnion(\n 'mode',\n [\n z.object({\n mode: z.literal('allow'),\n toolNames: z.array(z.string()),\n }),\n z.object({\n mode: z.literal('deny'),\n toolNames: z.array(z.string()),\n }),\n ],\n);\n\nexport const harnessV1BridgeResponseFormatSchema: z.ZodType<HarnessV1ResponseFormat> =\n z.discriminatedUnion('type', [\n z.object({ type: z.literal('text') }),\n z.object({\n type: z.literal('json'),\n schema: z.record(z.string(), z.json()).optional(),\n name: z.string().optional(),\n description: z.string().optional(),\n }),\n ]);\n\n/**\n * Common fields of the inbound `start` message. Each adapter extends this with\n * its runtime-specific configuration (e.g. `thinking`/`continue` for Claude\n * Code, `reasoningEffort`/`webSearch`/`skills`/`resumeThreadId` for Codex) and\n * assembles the final inbound union from the shared command members below.\n *\n * `debug` carries the general `HarnessV1DebugConfig` — diagnostics config is not\n * a bridge concept, it just happens to ride the `start` frame for bridge-backed\n * adapters.\n */\nexport const harnessV1BridgeStartBaseSchema = z.object({\n type: z.literal('start'),\n prompt: z.string(),\n tools: z.array(harnessV1BridgeToolWireSchema).optional(),\n model: z.string().optional(),\n debug: harnessV1DebugConfigSchema.optional(),\n permissionMode: harnessV1BridgePermissionModeSchema.optional(),\n builtinToolFiltering: harnessV1BridgeBuiltinToolFilteringSchema.optional(),\n responseFormat: harnessV1BridgeResponseFormatSchema.optional(),\n});\n\n// --- Transport / control frames (outbound, not consumer events) ---\n\n/**\n * Sent the instant the bridge accepts an authenticated WS connection. The host\n * waits for it before sending `start`/`resume`, because some sandbox runtimes\n * complete the upstream WS handshake before the connection is wired through to\n * the bridge process — anything sent in that gap is dropped. Carries the\n * bridge's lifecycle `state` and highest emitted `seq` for reconnect.\n */\nexport const harnessV1BridgeHelloSchema = z.object({\n type: z.literal('bridge-hello'),\n state: z.string().optional(),\n lastSeq: z.number().optional(),\n capabilities: z\n .object({\n experimental_userMessageResponses: z.boolean().optional(),\n })\n .optional(),\n});\n\nexport const experimental_harnessV1BridgeUserMessageResponseSchema = z.object({\n type: z.literal('user-message-response'),\n messageId: z.string(),\n accepted: z.boolean(),\n error: z.object({ message: z.string() }).optional(),\n});\n\n/**\n * The bridge's reply to an inbound `stop`. Carries the adapter-specific\n * payload the host serializes into lifecycle state `data`.\n */\nexport const harnessV1BridgeStopSchema = z.object({\n type: z.literal('bridge-stop'),\n data: z.unknown(),\n});\n\n/**\n * A resume coordinate the bridge proactively announces (e.g. Codex's thread id)\n * so the host can cache it for a later resume without waiting for `stop`.\n */\nexport const harnessV1BridgeThreadSchema = z.object({\n type: z.literal('bridge-thread'),\n threadId: z.string(),\n});\n\n// --- Diagnostics frames (outbound, not consumer events) ---\n\n/**\n * One captured console line from inside the sandbox. The bridge line-buffers\n * `process.stdout`/`process.stderr` and emits one of these per complete line.\n * Routed host-side to the diagnostics sink, never to the consumer stream.\n */\nexport const harnessV1BridgeSandboxLogSchema = z.object({\n type: z.literal('sandbox-log'),\n source: z.string(),\n stream: z.enum(['stdout', 'stderr']),\n line: z.string(),\n});\n\n/**\n * A structured diagnostic an adapter emits from inside the bridge via\n * `turn.bridgeLog(...)`. Gated by the session's debug level + subsystem filter.\n */\nexport const harnessV1BridgeDebugEventSchema = z.object({\n type: z.literal('debug-event'),\n level: harnessV1DebugLevelSchema,\n subsystem: z.string(),\n message: z.string(),\n attrs: z.record(z.string(), z.unknown()).optional(),\n error: z\n .object({\n name: z.string().optional(),\n message: z.string(),\n stack: z.string().optional(),\n })\n .optional(),\n});\n\n/**\n * Every frame a bridge can send to the host: the stream-part events plus the\n * transport/control frames. This is the schema the host `SandboxChannel`\n * validates inbound frames against.\n */\nexport const harnessV1BridgeOutboundMessageSchema = z.discriminatedUnion(\n 'type',\n [\n harnessV1StreamStartPartSchema,\n harnessV1TextStartPartSchema,\n harnessV1TextDeltaPartSchema,\n harnessV1TextEndPartSchema,\n harnessV1ReasoningStartPartSchema,\n harnessV1ReasoningDeltaPartSchema,\n harnessV1ReasoningEndPartSchema,\n harnessV1ToolInputStartPartSchema,\n harnessV1ToolInputDeltaPartSchema,\n harnessV1ToolInputEndPartSchema,\n harnessV1ToolCallPartSchema,\n harnessV1ToolApprovalRequestPartSchema,\n harnessV1ToolResultPartSchema,\n harnessV1FinishStepPartSchema,\n harnessV1FinishPartSchema,\n harnessV1FileChangePartSchema,\n harnessV1CompactionPartSchema,\n harnessV1ErrorPartSchema,\n harnessV1RawPartSchema,\n harnessV1BridgeHelloSchema,\n experimental_harnessV1BridgeUserMessageResponseSchema,\n harnessV1BridgeStopSchema,\n harnessV1BridgeThreadSchema,\n harnessV1BridgeSandboxLogSchema,\n harnessV1BridgeDebugEventSchema,\n ],\n);\n\nexport type HarnessV1BridgeOutboundMessage = z.infer<\n typeof harnessV1BridgeOutboundMessageSchema\n>;\n\nexport type Experimental_HarnessV1BridgeUserMessageResponse = z.infer<\n typeof experimental_harnessV1BridgeUserMessageResponseSchema\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 toolResult: z.unknown().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 messageId: z.string().optional(),\n text: z.string(),\n});\n\nexport const experimental_harnessV1BridgeUserMessageInboundSchema =\n harnessV1BridgeUserMessageInboundSchema.extend({\n messageId: z.string(),\n });\n\nexport const harnessV1BridgeAbortInboundSchema = z.object({\n type: z.literal('abort'),\n});\n\nexport const harnessV1BridgeDestroyInboundSchema = z.object({\n type: z.literal('destroy'),\n});\n\n/**\n * Reconnect: after re-establishing the socket the host asks the bridge to\n * replay every buffered event with `seq > lastSeenEventId`.\n */\nexport const harnessV1BridgeResumeInboundSchema = z.object({\n type: z.literal('resume'),\n lastSeenEventId: z.number(),\n});\n\n/**\n * The bridge replies with `bridge-stop` carrying any runtime resume data,\n * then exits.\n */\nexport const harnessV1BridgeStopInboundSchema = z.object({\n type: z.literal('stop'),\n});\n\n/**\n * The inbound command members shared by every bridge adapter. Spread these\n * alongside the adapter's own `start` schema to build the final inbound union:\n * `z.discriminatedUnion('type', [adapterStartSchema, ...harnessV1BridgeInboundCommandSchemas])`.\n */\nexport const harnessV1BridgeInboundCommandSchemas = [\n harnessV1BridgeToolResultInboundSchema,\n harnessV1BridgeToolApprovalResponseInboundSchema,\n harnessV1BridgeUserMessageInboundSchema,\n harnessV1BridgeAbortInboundSchema,\n harnessV1BridgeDestroyInboundSchema,\n harnessV1BridgeResumeInboundSchema,\n harnessV1BridgeStopInboundSchema,\n] as const;\n\n/**\n * The JSON line the bridge writes to stdout once its WebSocket server is bound,\n * announcing the port the host should connect to.\n */\nexport const harnessV1BridgeReadySchema = z.object({\n type: z.literal('bridge-ready'),\n port: z.number(),\n});\n\nexport type HarnessV1BridgeReady = z.infer<typeof harnessV1BridgeReadySchema>;\n","import { z } from 'zod/v4';\n\n/*\n * Diagnostics EMISSION contract — part of the `HarnessV1` spec.\n *\n * These are the types a harness adapter produces and receives: an adapter\n * reports a `HarnessV1Diagnostic` to the framework (a bridge adapter normalizes\n * its wire frames into one; a non-bridge adapter constructs one directly), and\n * receives a `HarnessV1DebugConfig` to gate what it emits. They are distinct\n * from the unaffixed host-facing `HarnessDiagnostic` / `HarnessDebugConfig`\n * (the external/telemetry surface) — the framework maps between the two at the\n * boundary, so the emission and consumption surfaces can evolve independently.\n */\n\n/** Severity of a diagnostic, ordered most → least severe. */\nexport const harnessV1DebugLevelSchema = z.enum([\n 'error',\n 'warn',\n 'info',\n 'debug',\n 'trace',\n]);\n\nexport type HarnessV1DebugLevel = z.infer<typeof harnessV1DebugLevelSchema>;\n\n/**\n * Per-session diagnostics configuration the framework hands an adapter (and the\n * host sends on `start.debug`). When absent or `enabled` is false the adapter\n * captures and emits nothing. `subsystems` filters structured events by dotted\n * prefix; console capture is independent of the subsystem filter.\n */\nexport const harnessV1DebugConfigSchema = z.object({\n enabled: z.boolean().optional(),\n level: harnessV1DebugLevelSchema.optional(),\n subsystems: z.array(z.string()).optional(),\n});\n\nexport type HarnessV1DebugConfig = z.infer<typeof harnessV1DebugConfigSchema>;\n\n/**\n * A diagnostic as emitted by a harness adapter. Structurally identical to the\n * host-facing `HarnessDiagnostic` today, but kept separate: this is the spec's\n * emission shape, that is the external consumption shape.\n */\nexport type HarnessV1Diagnostic = {\n /** Severity. */\n readonly level: HarnessV1DebugLevel;\n /** Human-readable line (console capture) or message (structured event). */\n readonly message: string;\n /** Dotted subsystem (`sandbox.log.<source>` for console capture). */\n readonly subsystem: string;\n /** `'log'` = captured console line; `'event'` = structured emission. */\n readonly kind: 'log' | 'event';\n /** Originating source label (console capture). */\n readonly source?: string;\n /** Which standard stream the line came from (console capture). */\n readonly stream?: 'stdout' | 'stderr';\n /** Structured attributes (structured events only). */\n readonly attrs?: Record<string, unknown>;\n /** Error payload (structured events only). */\n readonly error?: { name?: string; message: string; stack?: string };\n /** The harness session this diagnostic originated from. */\n readonly sessionId?: string;\n /** Emission time (epoch ms). */\n readonly timestamp: number;\n};\n","export type HarnessV1BuiltinToolFiltering =\n | {\n mode: 'allow';\n toolNames: string[];\n }\n | {\n mode: 'deny';\n toolNames: string[];\n };\n\nexport function isHarnessV1BuiltinToolIncluded(input: {\n toolName: string;\n toolFiltering: HarnessV1BuiltinToolFiltering | undefined;\n}): boolean {\n if (input.toolFiltering == null) return true;\n return input.toolFiltering.mode === 'allow'\n ? input.toolFiltering.toolNames.includes(input.toolName)\n : !input.toolFiltering.toolNames.includes(input.toolName);\n}\n\nexport function getHarnessV1BuiltinToolFilteringDenialReason(input: {\n toolName: string;\n}): string {\n return `Tool '${input.toolName}' is inactive due to the HarnessAgent tool filtering policy.`;\n}\n","import { AISDKError } from '@ai-sdk/provider';\n\nconst name = 'AI_HarnessError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Base error type for failures originating in or signalled by a harness\n * adapter. Specific failure modes (e.g. unsupported capability) extend this\n * class.\n */\nexport class HarnessError extends AISDKError {\n private readonly [symbol] = true;\n\n constructor({ message, cause }: { message: string; cause?: unknown }) {\n super({ name, message, cause });\n }\n\n static isInstance(error: unknown): error is HarnessError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from '@ai-sdk/provider';\nimport { HarnessError } from './harness-error';\n\nconst name = 'AI_HarnessCapabilityUnsupportedError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown when a caller asks the harness to do something the adapter (or the\n * supplied sandbox) does not support, e.g. requesting manual compaction from\n * an adapter that only auto-compacts, or invoking `getPortEndpoint` on a\n * sandbox that does not expose one.\n *\n * The caller supplies the full human-readable message. Optional `harnessId`\n * is recorded as structured context for tooling.\n */\nexport class HarnessCapabilityUnsupportedError extends HarnessError {\n private readonly [symbol] = true;\n\n readonly harnessId?: string;\n\n constructor({\n message,\n harnessId,\n cause,\n }: {\n message: string;\n harnessId?: string;\n cause?: unknown;\n }) {\n super({ message, cause });\n Object.defineProperty(this, 'name', { value: name });\n this.harnessId = harnessId;\n }\n\n static isInstance(\n error: unknown,\n ): error is HarnessCapabilityUnsupportedError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from '@ai-sdk/provider';\nimport { HarnessError } from './harness-error';\n\nconst name = 'AI_HarnessHistoryUnavailableError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown by `readHistory` when the adapter supports history reads but cannot\n * reach the runtime's store from the current environment — for example the\n * store lives inside a remote sandbox, or the transcript directory is\n * missing or unreadable.\n *\n * Distinct from `HarnessCapabilityUnsupportedError` (the adapter does not\n * implement history reads at all) so hosts can retry or degrade differently.\n * A conversation with no recorded messages yet is not an error; it resolves\n * to an empty result instead.\n */\nexport class HarnessHistoryUnavailableError 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(error: unknown): error is HarnessHistoryUnavailableError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from '@ai-sdk/provider';\nimport { HarnessError } from './harness-error';\n\nconst name = 'AI_HarnessSandboxAuthenticationError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown when a sandbox provider cannot authenticate or authorize the\n * operation needed to create or resume a harness sandbox. Providers should\n * preserve the underlying SDK failure as `cause` and supply a message that\n * explains how the consumer can configure credentials.\n */\nexport class HarnessSandboxAuthenticationError extends HarnessError {\n private readonly [symbol] = true;\n\n readonly sandboxProviderId: string;\n\n constructor({\n message,\n sandboxProviderId,\n cause,\n }: {\n message: string;\n sandboxProviderId: string;\n cause?: unknown;\n }) {\n super({ message, cause });\n Object.defineProperty(this, 'name', { value: name });\n this.sandboxProviderId = sandboxProviderId;\n }\n\n static isInstance(\n error: unknown,\n ): error is HarnessSandboxAuthenticationError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n"],"mappings":";AAAA,SAAS,YAA4C;AACrD,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAElB,IAAM,0BAA0B,EAAE,OAAO;AAAA,EACvC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACpB,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC1B,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,SAAS,EACN;AAAA,IACC,EAAE,OAAO;AAAA,MACP,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,M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;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,EAAE,SAAS,MAAM,CAAC;AAb1B,SAAkBD,OAAU;AAc1B,WAAO,eAAe,MAAM,QAAQ,EAAE,OAAOH,MAAK,CAAC;AACnD,SAAK,oBAAoB;AAAA,EAC3B;AAAA,EAEA,OAAO,WACL,OAC4C;AAC5C,WAAOK,YAAW,UAAU,OAAOJ,OAAM;AAAA,EAC3C;AACF;","names":["z","z","posix","z","z","z","z","AISDKError","name","marker","symbol","_a","_b","AISDKError","AISDKError","name","marker","symbol","_a","_b","AISDKError","AISDKError","name","marker","symbol","_a","_b","AISDKError"]}
@@ -578,10 +578,11 @@ declare function applyCredentialForwarding({ environment, credentialEnvironmentV
578
578
  credentialEnvironmentVariables: ReadonlyArray<string>;
579
579
  credentialForwarding: HarnessV1CredentialForwarding | undefined;
580
580
  }): Promise<Record<string, string>>;
581
- declare function createSandboxCredentialEnvironment({ environment, credentialEnvironmentVariables, credentialForwarding, }: {
581
+ declare function resolveSandboxCredentialEnvironment({ environment, credentialEnvironmentVariables, credentialForwarding, previousSandboxCredentialEnvironment, }: {
582
582
  environment: Readonly<Record<string, string>>;
583
583
  credentialEnvironmentVariables: ReadonlyArray<string>;
584
584
  credentialForwarding: HarnessV1CredentialForwarding | undefined;
585
+ previousSandboxCredentialEnvironment?: Readonly<Record<string, string>>;
585
586
  }): Promise<Record<string, string>>;
586
587
 
587
588
  declare function generateSandboxCredentialPlaceholder(): string;
@@ -732,4 +733,4 @@ declare function sleep({ ms, abortSignal, }: {
732
733
  abortSignal?: AbortSignal;
733
734
  }): Promise<void>;
734
735
 
735
- export { type BridgeReadyErrorContext, type BridgeReadySource, type DiskLogRecoveryMode, type Experimental_BridgeUserMessageRequest, type Experimental_BridgeUserMessageResponse, type Experimental_BridgeUserMessageSubmitter, type OAuthCredential, type RefreshOAuthAccessTokenResult, SandboxChannel, type SandboxChannelConnectOptions, type SandboxChannelDebugEvent, type SandboxChannelOptions, type SandboxChannelReconnectOptions, type SkillFilePathMode, type WaitForBridgeReadyOptions, type WaitForBridgeReadyResult, type WriteInstructionsOptions, type WriteInstructionsResult, type WriteSkillsOptions, type WriteSkillsResult, applyCredentialForwarding, classifyDiskLog, createBridgeErrorHandler, createBridgeStartupError, createBridgeToken, createCredentialRequestTransformation, createReadBridgeAsset, createSandboxCredentialEnvironment, drainBridgeProcessStream, experimental_createBridgeUserMessageSubmitter, formatBridgeError, forwardBridgeProcessStream, generateSandboxCredentialPlaceholder, getAiGatewayAuthFromEnv, getJwtExpiresAt, getRestrictedSandboxSession, isAccessTokenExpiringSoon, isHarnessAuthenticationEnvironment, isLinux, isMacOS, isSandboxCredentialPlaceholder, isWindows, logBridgeError, markBridgeStarting, maskSandboxCredentials, parseJwtPayload, readLinuxSecretServicePassword, readMacOSKeychainPassword, readWindowsCredentialManagerPassword, refreshOAuthAccessToken, resolveSandboxDefaultWorkingDirectory, resolveSandboxHomeDir, shellQuote, shouldResolveNativeSubscription, sleep, waitForBridgeReady, warnCredentialBrokeringUnavailable, withBridgeToken, writeInstructions, writeSkills };
736
+ export { type BridgeReadyErrorContext, type BridgeReadySource, type DiskLogRecoveryMode, type Experimental_BridgeUserMessageRequest, type Experimental_BridgeUserMessageResponse, type Experimental_BridgeUserMessageSubmitter, type OAuthCredential, type RefreshOAuthAccessTokenResult, SandboxChannel, type SandboxChannelConnectOptions, type SandboxChannelDebugEvent, type SandboxChannelOptions, type SandboxChannelReconnectOptions, type SkillFilePathMode, type WaitForBridgeReadyOptions, type WaitForBridgeReadyResult, type WriteInstructionsOptions, type WriteInstructionsResult, type WriteSkillsOptions, type WriteSkillsResult, applyCredentialForwarding, classifyDiskLog, createBridgeErrorHandler, createBridgeStartupError, createBridgeToken, createCredentialRequestTransformation, createReadBridgeAsset, drainBridgeProcessStream, experimental_createBridgeUserMessageSubmitter, formatBridgeError, forwardBridgeProcessStream, generateSandboxCredentialPlaceholder, getAiGatewayAuthFromEnv, getJwtExpiresAt, getRestrictedSandboxSession, isAccessTokenExpiringSoon, isHarnessAuthenticationEnvironment, isLinux, isMacOS, isSandboxCredentialPlaceholder, isWindows, logBridgeError, markBridgeStarting, maskSandboxCredentials, parseJwtPayload, readLinuxSecretServicePassword, readMacOSKeychainPassword, readWindowsCredentialManagerPassword, refreshOAuthAccessToken, resolveSandboxCredentialEnvironment, resolveSandboxDefaultWorkingDirectory, resolveSandboxHomeDir, shellQuote, shouldResolveNativeSubscription, sleep, waitForBridgeReady, warnCredentialBrokeringUnavailable, withBridgeToken, writeInstructions, writeSkills };