@ai-sdk/harness 1.0.163 → 1.0.164
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +4 -24
- package/dist/agent/index.js.map +1 -1
- package/dist/utils/index.d.ts +106 -4
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +280 -61
- package/dist/utils/index.js.map +1 -1
- package/package.json +5 -5
- package/src/utils/bridge-endpoint.ts +106 -0
- package/src/utils/bridge-web-socket.ts +286 -0
- package/src/utils/index.ts +11 -1
- package/src/utils/sandbox-channel.ts +11 -1
package/dist/utils/index.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ interface SandboxChannelReconnectOptions {
|
|
|
36
36
|
}
|
|
37
37
|
interface SandboxChannelConnectOptions {
|
|
38
38
|
readonly abortSignal: AbortSignal;
|
|
39
|
+
/**
|
|
40
|
+
* Why the channel is connecting: `'open'` for the initial
|
|
41
|
+
* {@link SandboxChannel.open} call, `'reconnect'` for an attempt to recover
|
|
42
|
+
* from a transient disconnect.
|
|
43
|
+
*/
|
|
44
|
+
readonly reason: 'open' | 'reconnect';
|
|
39
45
|
}
|
|
40
46
|
interface SandboxChannelOptions<TOut> {
|
|
41
47
|
/**
|
|
@@ -625,6 +631,31 @@ type HarnessV1CredentialForwarding = (options: {
|
|
|
625
631
|
readonly environmentVariableName: string;
|
|
626
632
|
}) => string | PromiseLike<string>;
|
|
627
633
|
//#endregion
|
|
634
|
+
//#region src/v1/harness-v1-mint-bridge-token.d.ts
|
|
635
|
+
/**
|
|
636
|
+
* Creates the authentication token a bridge-backed harness adapter uses to
|
|
637
|
+
* secure its sandbox bridge channel for one session. Defaults to a random
|
|
638
|
+
* 32-byte hexadecimal token when omitted.
|
|
639
|
+
*/
|
|
640
|
+
type HarnessV1MintBridgeTokenCallback = (sandboxId: string) => string;
|
|
641
|
+
//#endregion
|
|
642
|
+
//#region src/v1/harness-v1-bridge-protocol.d.ts
|
|
643
|
+
/**
|
|
644
|
+
* Sent the instant the bridge accepts an authenticated WS connection. The host
|
|
645
|
+
* waits for it before sending `start`/`resume`, because some sandbox runtimes
|
|
646
|
+
* complete the upstream WS handshake before the connection is wired through to
|
|
647
|
+
* the bridge process — anything sent in that gap is dropped. Carries the
|
|
648
|
+
* bridge's lifecycle `state` and highest emitted `seq` for reconnect.
|
|
649
|
+
*/
|
|
650
|
+
declare const harnessV1BridgeHelloSchema: z.ZodObject<{
|
|
651
|
+
type: z.ZodLiteral<"bridge-hello">;
|
|
652
|
+
state: z.ZodOptional<z.ZodString>;
|
|
653
|
+
lastSeq: z.ZodOptional<z.ZodNumber>;
|
|
654
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
655
|
+
experimental_userMessageResponses: z.ZodOptional<z.ZodBoolean>;
|
|
656
|
+
}, z.core.$strip>>;
|
|
657
|
+
}, z.core.$strip>;
|
|
658
|
+
//#endregion
|
|
628
659
|
//#region src/utils/credential-forwarding.d.ts
|
|
629
660
|
export declare function applyCredentialForwarding({ environment, credentialEnvironmentVariables, credentialForwarding }: {
|
|
630
661
|
environment: Readonly<Record<string, string>>;
|
|
@@ -742,10 +773,81 @@ export declare function waitForBridgeReady({ proc, sandbox, bridgeStateDir, brid
|
|
|
742
773
|
//#endregion
|
|
743
774
|
//#region src/utils/bridge-token.d.ts
|
|
744
775
|
export declare function createBridgeToken(): string;
|
|
745
|
-
|
|
746
|
-
|
|
776
|
+
//#endregion
|
|
777
|
+
//#region src/utils/bridge-endpoint.d.ts
|
|
778
|
+
/**
|
|
779
|
+
* Validates the bridge connection settings against the sandbox session before
|
|
780
|
+
* any bridge work starts.
|
|
781
|
+
*
|
|
782
|
+
* Basic sandbox sessions cannot expose ports, so they need both an explicit
|
|
783
|
+
* `port` and `portEndpoint` setting. A custom `mintBridgeToken` callback needs
|
|
784
|
+
* a sandbox id to mint the token for.
|
|
785
|
+
*/
|
|
786
|
+
export declare function validateBridgeSandboxSettings({ sandboxSession, sandboxId, portOverride, portEndpointOverride, mintBridgeToken }: {
|
|
787
|
+
sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
|
|
788
|
+
sandboxId: string | undefined;
|
|
789
|
+
portOverride: number | undefined;
|
|
790
|
+
portEndpointOverride: HarnessV1PortEndpoint | undefined;
|
|
791
|
+
mintBridgeToken: HarnessV1MintBridgeTokenCallback | undefined;
|
|
792
|
+
}): void;
|
|
793
|
+
/**
|
|
794
|
+
* Resolves the port the bridge listens on inside the sandbox: the `port`
|
|
795
|
+
* setting if present, otherwise the first port the sandbox exposes.
|
|
796
|
+
*/
|
|
797
|
+
export declare function resolveBridgePort({ sandboxSession, portOverride }: {
|
|
798
|
+
sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
|
|
799
|
+
portOverride: number | undefined;
|
|
800
|
+
}): number;
|
|
801
|
+
/**
|
|
802
|
+
* Resolves the host-reachable WebSocket endpoint for a bridge port and
|
|
803
|
+
* authenticates it with the bridge token.
|
|
804
|
+
*
|
|
805
|
+
* A `portEndpoint` setting takes precedence and is used as-is regardless of
|
|
806
|
+
* `port`, so it must point at the port the bridge actually listens on.
|
|
807
|
+
*/
|
|
808
|
+
export declare function resolveBridgeEndpoint({ sandboxSession, port, portEndpointOverride, token }: {
|
|
809
|
+
sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
|
|
810
|
+
port: number;
|
|
811
|
+
portEndpointOverride: HarnessV1PortEndpoint | undefined;
|
|
747
812
|
token: string;
|
|
748
|
-
}): HarnessV1PortEndpoint
|
|
813
|
+
}): Promise<HarnessV1PortEndpoint>;
|
|
814
|
+
//#endregion
|
|
815
|
+
//#region src/utils/bridge-web-socket.d.ts
|
|
816
|
+
type BridgeHello = z.infer<typeof harnessV1BridgeHelloSchema>;
|
|
817
|
+
interface CreateBridgeWebSocketConnectOptions {
|
|
818
|
+
/** Bridge endpoint, already authenticated with the bridge token. */
|
|
819
|
+
endpoint: HarnessV1PortEndpoint;
|
|
820
|
+
/**
|
|
821
|
+
* `WebSocket` class from the `ws` package. Passed in by the adapter because
|
|
822
|
+
* `ws` is an optional peer dependency of `@ai-sdk/harness`.
|
|
823
|
+
*/
|
|
824
|
+
webSocketConstructor: typeof WebSocket;
|
|
825
|
+
/**
|
|
826
|
+
* Retry budget in milliseconds for the channel's initial open (connect
|
|
827
|
+
* reason `'open'`). Omit for a single attempt. Reconnects always make a
|
|
828
|
+
* single attempt, because the channel retries them itself.
|
|
829
|
+
*/
|
|
830
|
+
openRetryTimeoutMs?: number;
|
|
831
|
+
/**
|
|
832
|
+
* Abort signal that additionally cancels the channel's initial open, e.g.
|
|
833
|
+
* the abort signal of the harness start call. Not applied to reconnects.
|
|
834
|
+
*/
|
|
835
|
+
startAbortSignal?: AbortSignal;
|
|
836
|
+
/** Called with the `bridge-hello` frame after every successful connect. */
|
|
837
|
+
onHello?: (hello: BridgeHello) => void;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Creates the `connect` function for a bridge `SandboxChannel`.
|
|
841
|
+
*
|
|
842
|
+
* A connection only counts as established once the socket is open and the
|
|
843
|
+
* bridge has sent `bridge-hello`. Some sandbox runtimes complete the host-side
|
|
844
|
+
* WebSocket upgrade before the connection reaches the bridge process, and
|
|
845
|
+
* frames sent in that gap are dropped. The bridge sends `bridge-hello` the
|
|
846
|
+
* instant it accepts a connection, and sends nothing else until the host sends
|
|
847
|
+
* `start` or `resume`, so no frame is lost between the handshake and the
|
|
848
|
+
* channel wiring the socket.
|
|
849
|
+
*/
|
|
850
|
+
export declare function createBridgeWebSocketConnect({ endpoint, webSocketConstructor, openRetryTimeoutMs, startAbortSignal, onHello }: CreateBridgeWebSocketConnectOptions): (options: SandboxChannelConnectOptions) => Promise<WebSocket>;
|
|
749
851
|
//#endregion
|
|
750
852
|
//#region src/utils/bridge-asset.d.ts
|
|
751
853
|
export declare function createReadBridgeAsset<const ASSET_URLS extends Record<string, URL>>(assetUrls: ASSET_URLS): (name: Extract<keyof ASSET_URLS, string>) => Promise<string>;
|
|
@@ -842,5 +944,5 @@ export declare function convertHarnessToolModelOutput({ output }: {
|
|
|
842
944
|
isError: boolean;
|
|
843
945
|
};
|
|
844
946
|
//#endregion
|
|
845
|
-
export type { BridgeReadyErrorContext, BridgeReadySource, DiskLogRecoveryMode, Experimental_BridgeUserMessageRequest, Experimental_BridgeUserMessageResponse, Experimental_BridgeUserMessageSubmitter, HarnessPromptContent, HarnessPromptContentPart, HarnessToolModelOutputContent, OAuthCredential, RefreshOAuthAccessTokenResult, SandboxChannelConnectOptions, SandboxChannelDebugEvent, SandboxChannelOptions, SandboxChannelReconnectOptions, SkillFilePathMode, WaitForBridgeReadyOptions, WaitForBridgeReadyResult, WriteInstructionsOptions, WriteInstructionsResult, WriteSkillsOptions, WriteSkillsResult };
|
|
947
|
+
export type { BridgeHello, BridgeReadyErrorContext, BridgeReadySource, CreateBridgeWebSocketConnectOptions, DiskLogRecoveryMode, Experimental_BridgeUserMessageRequest, Experimental_BridgeUserMessageResponse, Experimental_BridgeUserMessageSubmitter, HarnessPromptContent, HarnessPromptContentPart, HarnessToolModelOutputContent, OAuthCredential, RefreshOAuthAccessTokenResult, SandboxChannelConnectOptions, SandboxChannelDebugEvent, SandboxChannelOptions, SandboxChannelReconnectOptions, SkillFilePathMode, WaitForBridgeReadyOptions, WaitForBridgeReadyResult, WriteInstructionsOptions, WriteInstructionsResult, WriteSkillsOptions, WriteSkillsResult };
|
|
846
948
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["SandboxSession","SandboxSession","SandboxSession"],"sources":["../../src/utils/sandbox-channel.ts","../../src/utils/bridge-user-message-submitter.ts","../../src/utils/classify-disk-log.ts","../../src/utils/ai-gateway-auth.ts","../../src/v1/harness-authentication.ts","../../src/utils/authentication-environment.ts","../../src/utils/native-subscription/jwt.ts","../../src/utils/native-subscription/linux-secret-service.ts","../../src/utils/native-subscription/macos-keychain.ts","../../src/utils/native-subscription/should-resolve-native.ts","../../src/utils/native-subscription/windows-credential-manager.ts","../../src/utils/oauth-access-token.ts","../../src/utils/os.ts","../../src/v1/harness-v1-network-sandbox-session.ts","../../src/v1/harness-v1-prompt.ts","../../src/v1/harness-v1-skill.ts","../../src/v1/harness-v1-call-warning.ts","../../src/v1/harness-v1-credential-forwarding.ts","../../src/utils/credential-forwarding.ts","../../src/utils/sandbox-credential-brokering.ts","../../src/utils/sandbox-home-dir.ts","../../src/utils/shell-quote.ts","../../src/utils/write-instructions.ts","../../src/utils/write-skills.ts","../../src/utils/bridge-ready.ts","../../src/utils/bridge-token.ts","../../src/utils/bridge-asset.ts","../../src/utils/bridge-diagnostics.ts","../../src/utils/resolve-sandbox-default-working-directory.ts","../../src/utils/get-restricted-sandbox-session.ts","../../src/utils/sleep.ts","../../src/utils/normalize-harness-tool-model-output.ts","../../src/utils/extract-harness-prompt-content.ts","../../src/utils/convert-harness-tool-model-output.ts"],"mappings":";;;;;;;;;;;KAcY;EACN;EAA4B;EAAiB;;EAC7C;EAAsB;EAAiB;;EAEvC;EACA;EACA;EACA;;UAGW;;;;;WAKN;;WAEA;;WAEA;;UAGM;WACN,aAAa;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["SandboxSession","SandboxSession","SandboxSession","SandboxSession"],"sources":["../../src/utils/sandbox-channel.ts","../../src/utils/bridge-user-message-submitter.ts","../../src/utils/classify-disk-log.ts","../../src/utils/ai-gateway-auth.ts","../../src/v1/harness-authentication.ts","../../src/utils/authentication-environment.ts","../../src/utils/native-subscription/jwt.ts","../../src/utils/native-subscription/linux-secret-service.ts","../../src/utils/native-subscription/macos-keychain.ts","../../src/utils/native-subscription/should-resolve-native.ts","../../src/utils/native-subscription/windows-credential-manager.ts","../../src/utils/oauth-access-token.ts","../../src/utils/os.ts","../../src/v1/harness-v1-network-sandbox-session.ts","../../src/v1/harness-v1-prompt.ts","../../src/v1/harness-v1-skill.ts","../../src/v1/harness-v1-call-warning.ts","../../src/v1/harness-v1-credential-forwarding.ts","../../src/v1/harness-v1-mint-bridge-token.ts","../../src/v1/harness-v1-bridge-protocol.ts","../../src/utils/credential-forwarding.ts","../../src/utils/sandbox-credential-brokering.ts","../../src/utils/sandbox-home-dir.ts","../../src/utils/shell-quote.ts","../../src/utils/write-instructions.ts","../../src/utils/write-skills.ts","../../src/utils/bridge-ready.ts","../../src/utils/bridge-token.ts","../../src/utils/bridge-endpoint.ts","../../src/utils/bridge-web-socket.ts","../../src/utils/bridge-asset.ts","../../src/utils/bridge-diagnostics.ts","../../src/utils/resolve-sandbox-default-working-directory.ts","../../src/utils/get-restricted-sandbox-session.ts","../../src/utils/sleep.ts","../../src/utils/normalize-harness-tool-model-output.ts","../../src/utils/extract-harness-prompt-content.ts","../../src/utils/convert-harness-tool-model-output.ts"],"mappings":";;;;;;;;;;;KAcY;EACN;EAA4B;EAAiB;;EAC7C;EAAsB;EAAiB;;EAEvC;EACA;EACA;EACA;;UAGW;;;;;WAKN;;WAEA;;WAEA;;UAGM;WACN,aAAa;;;;;;WAOb;;UAGM,sBAAsB;;;;;;;;EAQrC,UAAU,SAAS,iCAAiC,QAAQ;;EAG5D,gBAAgB,eAAe;EAE/B,YAAY;EAEZ,WAAW,OAAO;;;;;;;;EASlB,gBACE,OAAO,QAAQ;IAAQ;;EAGzB,iBAAiB,OAAO,QAAQ;IAAQ;;;;;;;;EAQxC;;KAGG,YAAY;EAAe;KAAkB;KAE7C,SAAS;EAAe;GAAgB,UAAU,YAAY,UACjE,OAAO,QAAQ;EAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;qBAqHlB,eACX;EAAe;GACf;EAAc;;EAAmB;;mBAEhB;mBAIA;mBACA;UACT;UACA;UACA;UACA;mBACS;mBAGA;mBAEA;mBAGA;mBACA;mBAGA;mBAGA;mBAGA;mBACA;mBACA;UAET;UACA;;UAEA;;;;;;;UAOA;UACA;;UAIA;UACA;mBACS;UACT;UACA;UACA;EAEI,YAAA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;EACd;EAAe;EAAc;;wBAsBnB,gCACd;EAEA,QAAQ;;EACJ,SAAS;EAAiC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import { promisify } from "node:util";
|
|
|
4
4
|
import { createHash, randomBytes } from "node:crypto";
|
|
5
5
|
import path, { posix } from "node:path";
|
|
6
6
|
import { z } from "zod/v4";
|
|
7
|
-
import { readFile } from "node:fs/promises";
|
|
8
7
|
import { AISDKError } from "@ai-sdk/provider";
|
|
8
|
+
import { readFile } from "node:fs/promises";
|
|
9
9
|
//#region src/utils/sleep.ts
|
|
10
10
|
function sleep({ ms, abortSignal }) {
|
|
11
11
|
return new Promise((resolve) => {
|
|
@@ -33,7 +33,7 @@ function sleep({ ms, abortSignal }) {
|
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/utils/sandbox-channel.ts
|
|
35
35
|
const sandboxChannelEventCheckpointSymbol = Symbol.for("vercel.ai.harness.sandboxChannelEventCheckpoint");
|
|
36
|
-
function getAbortReason({ abortSignal }) {
|
|
36
|
+
function getAbortReason$1({ abortSignal }) {
|
|
37
37
|
return abortSignal.reason ?? /* @__PURE__ */ new Error("SandboxChannel connection aborted");
|
|
38
38
|
}
|
|
39
39
|
function closeWebSocket({ ws }) {
|
|
@@ -50,18 +50,18 @@ function closeWebSocket({ ws }) {
|
|
|
50
50
|
async function awaitWebSocketConnection({ connection, abortSignal }) {
|
|
51
51
|
if (abortSignal.aborted) {
|
|
52
52
|
connection.then((ws) => closeWebSocket({ ws })).catch(() => {});
|
|
53
|
-
throw getAbortReason({ abortSignal });
|
|
53
|
+
throw getAbortReason$1({ abortSignal });
|
|
54
54
|
}
|
|
55
55
|
let onAbort;
|
|
56
56
|
const aborted = new Promise((_, reject) => {
|
|
57
|
-
onAbort = () => reject(getAbortReason({ abortSignal }));
|
|
57
|
+
onAbort = () => reject(getAbortReason$1({ abortSignal }));
|
|
58
58
|
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
59
59
|
});
|
|
60
60
|
try {
|
|
61
61
|
const ws = await Promise.race([connection, aborted]);
|
|
62
62
|
if (abortSignal.aborted) {
|
|
63
63
|
closeWebSocket({ ws });
|
|
64
|
-
throw getAbortReason({ abortSignal });
|
|
64
|
+
throw getAbortReason$1({ abortSignal });
|
|
65
65
|
}
|
|
66
66
|
return ws;
|
|
67
67
|
} catch (error) {
|
|
@@ -146,7 +146,10 @@ var SandboxChannel = class {
|
|
|
146
146
|
const abortController = new AbortController();
|
|
147
147
|
this.activeConnectAbortController = abortController;
|
|
148
148
|
try {
|
|
149
|
-
const ws = await this.connect({
|
|
149
|
+
const ws = await this.connect({
|
|
150
|
+
abortSignal: abortController.signal,
|
|
151
|
+
reason: "open"
|
|
152
|
+
});
|
|
150
153
|
this.wire(ws);
|
|
151
154
|
this.ws = ws;
|
|
152
155
|
this.connected = true;
|
|
@@ -314,7 +317,10 @@ var SandboxChannel = class {
|
|
|
314
317
|
}, remaining);
|
|
315
318
|
timeout.unref?.();
|
|
316
319
|
try {
|
|
317
|
-
const ws = await this.connect({
|
|
320
|
+
const ws = await this.connect({
|
|
321
|
+
abortSignal: abortController.signal,
|
|
322
|
+
reason: "reconnect"
|
|
323
|
+
});
|
|
318
324
|
if (this.terminal || this.closing) {
|
|
319
325
|
closeWebSocket({ ws });
|
|
320
326
|
return;
|
|
@@ -359,9 +365,12 @@ var SandboxChannel = class {
|
|
|
359
365
|
if (this.reconnectAbortController === reconnectAbortController) this.reconnectAbortController = void 0;
|
|
360
366
|
}
|
|
361
367
|
}
|
|
362
|
-
connect({ abortSignal }) {
|
|
368
|
+
connect({ abortSignal, reason }) {
|
|
363
369
|
return awaitWebSocketConnection({
|
|
364
|
-
connection: Promise.resolve().then(() => this.connectThunk({
|
|
370
|
+
connection: Promise.resolve().then(() => this.connectThunk({
|
|
371
|
+
abortSignal,
|
|
372
|
+
reason
|
|
373
|
+
})),
|
|
365
374
|
abortSignal
|
|
366
375
|
});
|
|
367
376
|
}
|
|
@@ -1886,6 +1895,267 @@ function withBridgeToken({ endpoint, token }) {
|
|
|
1886
1895
|
};
|
|
1887
1896
|
}
|
|
1888
1897
|
//#endregion
|
|
1898
|
+
//#region src/errors/harness-error.ts
|
|
1899
|
+
const name$2 = "AI_HarnessError";
|
|
1900
|
+
const marker$1 = `vercel.ai.error.${name$2}`;
|
|
1901
|
+
const symbol$1 = Symbol.for(marker$1);
|
|
1902
|
+
/**
|
|
1903
|
+
* Base error type for failures originating in or signalled by a harness
|
|
1904
|
+
* adapter. Specific failure modes (e.g. unsupported capability) extend this
|
|
1905
|
+
* class.
|
|
1906
|
+
*/
|
|
1907
|
+
var HarnessError = class extends AISDKError {
|
|
1908
|
+
constructor({ message, cause }) {
|
|
1909
|
+
super({
|
|
1910
|
+
name: name$2,
|
|
1911
|
+
message,
|
|
1912
|
+
cause
|
|
1913
|
+
});
|
|
1914
|
+
this[symbol$1] = true;
|
|
1915
|
+
}
|
|
1916
|
+
static isInstance(error) {
|
|
1917
|
+
return AISDKError.hasMarker(error, marker$1);
|
|
1918
|
+
}
|
|
1919
|
+
};
|
|
1920
|
+
//#endregion
|
|
1921
|
+
//#region src/errors/harness-capability-unsupported-error.ts
|
|
1922
|
+
const name$1 = "AI_HarnessCapabilityUnsupportedError";
|
|
1923
|
+
const marker = `vercel.ai.error.${name$1}`;
|
|
1924
|
+
const symbol = Symbol.for(marker);
|
|
1925
|
+
/**
|
|
1926
|
+
* Thrown when a caller asks the harness to do something the adapter (or the
|
|
1927
|
+
* supplied sandbox) does not support, e.g. requesting manual compaction from
|
|
1928
|
+
* an adapter that only auto-compacts, or invoking `getPortEndpoint` on a
|
|
1929
|
+
* sandbox that does not expose one.
|
|
1930
|
+
*
|
|
1931
|
+
* The caller supplies the full human-readable message. Optional `harnessId`
|
|
1932
|
+
* is recorded as structured context for tooling.
|
|
1933
|
+
*/
|
|
1934
|
+
var HarnessCapabilityUnsupportedError = class extends HarnessError {
|
|
1935
|
+
constructor({ message, harnessId, cause }) {
|
|
1936
|
+
super({
|
|
1937
|
+
message,
|
|
1938
|
+
cause
|
|
1939
|
+
});
|
|
1940
|
+
this[symbol] = true;
|
|
1941
|
+
Object.defineProperty(this, "name", { value: name$1 });
|
|
1942
|
+
this.harnessId = harnessId;
|
|
1943
|
+
}
|
|
1944
|
+
static isInstance(error) {
|
|
1945
|
+
return AISDKError.hasMarker(error, marker);
|
|
1946
|
+
}
|
|
1947
|
+
};
|
|
1948
|
+
//#endregion
|
|
1949
|
+
//#region src/utils/bridge-endpoint.ts
|
|
1950
|
+
/**
|
|
1951
|
+
* Validates the bridge connection settings against the sandbox session before
|
|
1952
|
+
* any bridge work starts.
|
|
1953
|
+
*
|
|
1954
|
+
* Basic sandbox sessions cannot expose ports, so they need both an explicit
|
|
1955
|
+
* `port` and `portEndpoint` setting. A custom `mintBridgeToken` callback needs
|
|
1956
|
+
* a sandbox id to mint the token for.
|
|
1957
|
+
*/
|
|
1958
|
+
function validateBridgeSandboxSettings({ sandboxSession, sandboxId, portOverride, portEndpointOverride, mintBridgeToken }) {
|
|
1959
|
+
if (!("getPortEndpoint" in sandboxSession)) {
|
|
1960
|
+
if (portOverride == null) throw new HarnessCapabilityUnsupportedError({ message: "The harness requires an explicit `port` setting when using a basic sandbox session." });
|
|
1961
|
+
if (portEndpointOverride == null) throw createMissingPortEndpointError();
|
|
1962
|
+
}
|
|
1963
|
+
if (mintBridgeToken != null && sandboxId == null) throw new HarnessCapabilityUnsupportedError({ message: "The harness cannot use `mintBridgeToken` with a sandbox session that does not expose an id." });
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* Resolves the port the bridge listens on inside the sandbox: the `port`
|
|
1967
|
+
* setting if present, otherwise the first port the sandbox exposes.
|
|
1968
|
+
*/
|
|
1969
|
+
function resolveBridgePort({ sandboxSession, portOverride }) {
|
|
1970
|
+
if (portOverride !== void 0) return portOverride;
|
|
1971
|
+
if ("ports" in sandboxSession && sandboxSession.ports.length > 0) return sandboxSession.ports[0];
|
|
1972
|
+
throw new HarnessCapabilityUnsupportedError({ message: "The harness needs a TCP port exposed by the sandbox. Create the sandbox with `ports: [<port>]` or configure the harness `port` setting." });
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Resolves the host-reachable WebSocket endpoint for a bridge port and
|
|
1976
|
+
* authenticates it with the bridge token.
|
|
1977
|
+
*
|
|
1978
|
+
* A `portEndpoint` setting takes precedence and is used as-is regardless of
|
|
1979
|
+
* `port`, so it must point at the port the bridge actually listens on.
|
|
1980
|
+
*/
|
|
1981
|
+
async function resolveBridgeEndpoint({ sandboxSession, port, portEndpointOverride, token }) {
|
|
1982
|
+
let endpoint;
|
|
1983
|
+
if (portEndpointOverride != null) endpoint = portEndpointOverride;
|
|
1984
|
+
else if ("getPortEndpoint" in sandboxSession) endpoint = await sandboxSession.getPortEndpoint({
|
|
1985
|
+
port,
|
|
1986
|
+
protocol: "ws"
|
|
1987
|
+
});
|
|
1988
|
+
else throw createMissingPortEndpointError();
|
|
1989
|
+
return withBridgeToken({
|
|
1990
|
+
endpoint,
|
|
1991
|
+
token
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
function createMissingPortEndpointError() {
|
|
1995
|
+
return new HarnessCapabilityUnsupportedError({ message: "The harness requires an explicit `portEndpoint` setting when using a basic sandbox session." });
|
|
1996
|
+
}
|
|
1997
|
+
//#endregion
|
|
1998
|
+
//#region src/utils/bridge-web-socket.ts
|
|
1999
|
+
const OPEN_TIMEOUT_MS = 1e4;
|
|
2000
|
+
const HELLO_TIMEOUT_MS = 5e3;
|
|
2001
|
+
const UNAUTHORIZED_CLOSE_CODE = 1008;
|
|
2002
|
+
/**
|
|
2003
|
+
* Creates the `connect` function for a bridge `SandboxChannel`.
|
|
2004
|
+
*
|
|
2005
|
+
* A connection only counts as established once the socket is open and the
|
|
2006
|
+
* bridge has sent `bridge-hello`. Some sandbox runtimes complete the host-side
|
|
2007
|
+
* WebSocket upgrade before the connection reaches the bridge process, and
|
|
2008
|
+
* frames sent in that gap are dropped. The bridge sends `bridge-hello` the
|
|
2009
|
+
* instant it accepts a connection, and sends nothing else until the host sends
|
|
2010
|
+
* `start` or `resume`, so no frame is lost between the handshake and the
|
|
2011
|
+
* channel wiring the socket.
|
|
2012
|
+
*/
|
|
2013
|
+
function createBridgeWebSocketConnect({ endpoint, webSocketConstructor, openRetryTimeoutMs, startAbortSignal, onHello }) {
|
|
2014
|
+
return async ({ abortSignal, reason }) => {
|
|
2015
|
+
const isInitialOpen = reason === "open";
|
|
2016
|
+
const connectAbortSignal = isInitialOpen && startAbortSignal != null ? AbortSignal.any([abortSignal, startAbortSignal]) : abortSignal;
|
|
2017
|
+
const { ws, hello } = isInitialOpen && openRetryTimeoutMs != null ? await openBridgeWebSocketWithRetry({
|
|
2018
|
+
endpoint,
|
|
2019
|
+
webSocketConstructor,
|
|
2020
|
+
abortSignal: connectAbortSignal,
|
|
2021
|
+
retryTimeoutMs: openRetryTimeoutMs
|
|
2022
|
+
}) : await openBridgeWebSocket({
|
|
2023
|
+
endpoint,
|
|
2024
|
+
webSocketConstructor,
|
|
2025
|
+
abortSignal: connectAbortSignal,
|
|
2026
|
+
openTimeoutMs: OPEN_TIMEOUT_MS,
|
|
2027
|
+
getHelloTimeoutMs: () => HELLO_TIMEOUT_MS
|
|
2028
|
+
});
|
|
2029
|
+
onHello?.(hello);
|
|
2030
|
+
return ws;
|
|
2031
|
+
};
|
|
2032
|
+
}
|
|
2033
|
+
var BridgeWebSocketUnauthorizedError = class extends Error {};
|
|
2034
|
+
async function openBridgeWebSocketWithRetry({ endpoint, webSocketConstructor, abortSignal, retryTimeoutMs }) {
|
|
2035
|
+
const deadline = Date.now() + retryTimeoutMs;
|
|
2036
|
+
let attempt = 0;
|
|
2037
|
+
let lastError;
|
|
2038
|
+
while (!abortSignal.aborted && Date.now() < deadline) {
|
|
2039
|
+
attempt++;
|
|
2040
|
+
try {
|
|
2041
|
+
const remaining = Math.max(1, deadline - Date.now());
|
|
2042
|
+
return await openBridgeWebSocket({
|
|
2043
|
+
endpoint,
|
|
2044
|
+
webSocketConstructor,
|
|
2045
|
+
abortSignal,
|
|
2046
|
+
openTimeoutMs: Math.min(OPEN_TIMEOUT_MS, remaining),
|
|
2047
|
+
getHelloTimeoutMs: () => Math.min(HELLO_TIMEOUT_MS, Math.max(1, deadline - Date.now()))
|
|
2048
|
+
});
|
|
2049
|
+
} catch (error) {
|
|
2050
|
+
if (abortSignal.aborted) throw getAbortReason({ abortSignal });
|
|
2051
|
+
if (error instanceof BridgeWebSocketUnauthorizedError) throw error;
|
|
2052
|
+
lastError = error;
|
|
2053
|
+
const remaining = deadline - Date.now();
|
|
2054
|
+
if (remaining <= 0) break;
|
|
2055
|
+
await sleep({
|
|
2056
|
+
ms: Math.min(250 * attempt, 1e3, remaining),
|
|
2057
|
+
abortSignal
|
|
2058
|
+
});
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
if (abortSignal.aborted) throw getAbortReason({ abortSignal });
|
|
2062
|
+
throw new HarnessError({
|
|
2063
|
+
message: `The harness bridge did not complete the WebSocket handshake within ${retryTimeoutMs}ms after ${attempt} attempt(s).`,
|
|
2064
|
+
cause: lastError
|
|
2065
|
+
});
|
|
2066
|
+
}
|
|
2067
|
+
function openBridgeWebSocket({ endpoint, webSocketConstructor, abortSignal, openTimeoutMs, getHelloTimeoutMs }) {
|
|
2068
|
+
return new Promise((resolve, reject) => {
|
|
2069
|
+
if (abortSignal.aborted) {
|
|
2070
|
+
reject(getAbortReason({ abortSignal }));
|
|
2071
|
+
return;
|
|
2072
|
+
}
|
|
2073
|
+
const ws = new webSocketConstructor(endpoint.url, { headers: endpoint.headers == null ? void 0 : { ...endpoint.headers } });
|
|
2074
|
+
let opened = false;
|
|
2075
|
+
let hello;
|
|
2076
|
+
let settled = false;
|
|
2077
|
+
let openTimer;
|
|
2078
|
+
let helloTimer;
|
|
2079
|
+
const cleanup = () => {
|
|
2080
|
+
clearTimeout(openTimer);
|
|
2081
|
+
clearTimeout(helloTimer);
|
|
2082
|
+
ws.off("open", onOpen);
|
|
2083
|
+
ws.off("message", onMessage);
|
|
2084
|
+
ws.off("close", onClose);
|
|
2085
|
+
ws.off("error", onError);
|
|
2086
|
+
abortSignal.removeEventListener("abort", onAbort);
|
|
2087
|
+
};
|
|
2088
|
+
const fail = (error) => {
|
|
2089
|
+
if (settled) return;
|
|
2090
|
+
settled = true;
|
|
2091
|
+
cleanup();
|
|
2092
|
+
ws.on("error", () => {});
|
|
2093
|
+
try {
|
|
2094
|
+
ws.terminate();
|
|
2095
|
+
} catch {
|
|
2096
|
+
try {
|
|
2097
|
+
ws.close();
|
|
2098
|
+
} catch {}
|
|
2099
|
+
}
|
|
2100
|
+
reject(error);
|
|
2101
|
+
};
|
|
2102
|
+
const tryResolve = () => {
|
|
2103
|
+
if (settled || !opened || hello == null) return;
|
|
2104
|
+
settled = true;
|
|
2105
|
+
cleanup();
|
|
2106
|
+
resolve({
|
|
2107
|
+
ws,
|
|
2108
|
+
hello
|
|
2109
|
+
});
|
|
2110
|
+
};
|
|
2111
|
+
const onOpen = () => {
|
|
2112
|
+
opened = true;
|
|
2113
|
+
clearTimeout(openTimer);
|
|
2114
|
+
const helloTimeoutMs = getHelloTimeoutMs();
|
|
2115
|
+
helloTimer = setTimeout(() => fail(/* @__PURE__ */ new Error(`The harness bridge did not send bridge-hello within ${helloTimeoutMs}ms.`)), helloTimeoutMs);
|
|
2116
|
+
unrefTimer(helloTimer);
|
|
2117
|
+
tryResolve();
|
|
2118
|
+
};
|
|
2119
|
+
const onMessage = (raw) => {
|
|
2120
|
+
(async () => {
|
|
2121
|
+
const parsed = await safeParseJSON({
|
|
2122
|
+
text: webSocketMessageToString(raw),
|
|
2123
|
+
schema: harnessV1BridgeHelloSchema
|
|
2124
|
+
});
|
|
2125
|
+
if (!parsed.success || settled) return;
|
|
2126
|
+
hello = parsed.value;
|
|
2127
|
+
tryResolve();
|
|
2128
|
+
})();
|
|
2129
|
+
};
|
|
2130
|
+
const onClose = (code) => {
|
|
2131
|
+
fail(code === UNAUTHORIZED_CLOSE_CODE ? new BridgeWebSocketUnauthorizedError(`The harness bridge rejected the WebSocket connection as unauthorized (code ${code}).`) : /* @__PURE__ */ new Error(`The harness bridge closed the WebSocket (code ${code}) before sending bridge-hello.`));
|
|
2132
|
+
};
|
|
2133
|
+
const onError = (error) => fail(error);
|
|
2134
|
+
const onAbort = () => fail(getAbortReason({ abortSignal }));
|
|
2135
|
+
ws.on("open", onOpen);
|
|
2136
|
+
ws.on("message", onMessage);
|
|
2137
|
+
ws.on("close", onClose);
|
|
2138
|
+
ws.on("error", onError);
|
|
2139
|
+
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
2140
|
+
openTimer = setTimeout(() => fail(/* @__PURE__ */ new Error(`The harness bridge WebSocket did not open within ${openTimeoutMs}ms.`)), openTimeoutMs);
|
|
2141
|
+
unrefTimer(openTimer);
|
|
2142
|
+
});
|
|
2143
|
+
}
|
|
2144
|
+
function getAbortReason({ abortSignal }) {
|
|
2145
|
+
return abortSignal.reason ?? /* @__PURE__ */ new Error("WebSocket connection aborted");
|
|
2146
|
+
}
|
|
2147
|
+
function unrefTimer(timer) {
|
|
2148
|
+
timer.unref?.();
|
|
2149
|
+
}
|
|
2150
|
+
function webSocketMessageToString(raw) {
|
|
2151
|
+
if (typeof raw === "string") return raw;
|
|
2152
|
+
if (Buffer.isBuffer(raw)) return raw.toString("utf8");
|
|
2153
|
+
if (Array.isArray(raw)) return Buffer.concat(raw).toString("utf8");
|
|
2154
|
+
if (raw instanceof ArrayBuffer) return Buffer.from(raw).toString("utf8");
|
|
2155
|
+
if (ArrayBuffer.isView(raw)) return Buffer.from(raw.buffer, raw.byteOffset, raw.byteLength).toString("utf8");
|
|
2156
|
+
return String(raw);
|
|
2157
|
+
}
|
|
2158
|
+
//#endregion
|
|
1889
2159
|
//#region src/utils/bridge-asset.ts
|
|
1890
2160
|
function createReadBridgeAsset(assetUrls) {
|
|
1891
2161
|
return async (name) => readFile(assetUrls[name], "utf8");
|
|
@@ -2018,57 +2288,6 @@ function getRestrictedSandboxSession(sandboxSession) {
|
|
|
2018
2288
|
return "restricted" in sandboxSession ? sandboxSession.restricted() : sandboxSession;
|
|
2019
2289
|
}
|
|
2020
2290
|
//#endregion
|
|
2021
|
-
//#region src/errors/harness-error.ts
|
|
2022
|
-
const name$2 = "AI_HarnessError";
|
|
2023
|
-
const marker$1 = `vercel.ai.error.${name$2}`;
|
|
2024
|
-
const symbol$1 = Symbol.for(marker$1);
|
|
2025
|
-
/**
|
|
2026
|
-
* Base error type for failures originating in or signalled by a harness
|
|
2027
|
-
* adapter. Specific failure modes (e.g. unsupported capability) extend this
|
|
2028
|
-
* class.
|
|
2029
|
-
*/
|
|
2030
|
-
var HarnessError = class extends AISDKError {
|
|
2031
|
-
constructor({ message, cause }) {
|
|
2032
|
-
super({
|
|
2033
|
-
name: name$2,
|
|
2034
|
-
message,
|
|
2035
|
-
cause
|
|
2036
|
-
});
|
|
2037
|
-
this[symbol$1] = true;
|
|
2038
|
-
}
|
|
2039
|
-
static isInstance(error) {
|
|
2040
|
-
return AISDKError.hasMarker(error, marker$1);
|
|
2041
|
-
}
|
|
2042
|
-
};
|
|
2043
|
-
//#endregion
|
|
2044
|
-
//#region src/errors/harness-capability-unsupported-error.ts
|
|
2045
|
-
const name$1 = "AI_HarnessCapabilityUnsupportedError";
|
|
2046
|
-
const marker = `vercel.ai.error.${name$1}`;
|
|
2047
|
-
const symbol = Symbol.for(marker);
|
|
2048
|
-
/**
|
|
2049
|
-
* Thrown when a caller asks the harness to do something the adapter (or the
|
|
2050
|
-
* supplied sandbox) does not support, e.g. requesting manual compaction from
|
|
2051
|
-
* an adapter that only auto-compacts, or invoking `getPortEndpoint` on a
|
|
2052
|
-
* sandbox that does not expose one.
|
|
2053
|
-
*
|
|
2054
|
-
* The caller supplies the full human-readable message. Optional `harnessId`
|
|
2055
|
-
* is recorded as structured context for tooling.
|
|
2056
|
-
*/
|
|
2057
|
-
var HarnessCapabilityUnsupportedError = class extends HarnessError {
|
|
2058
|
-
constructor({ message, harnessId, cause }) {
|
|
2059
|
-
super({
|
|
2060
|
-
message,
|
|
2061
|
-
cause
|
|
2062
|
-
});
|
|
2063
|
-
this[symbol] = true;
|
|
2064
|
-
Object.defineProperty(this, "name", { value: name$1 });
|
|
2065
|
-
this.harnessId = harnessId;
|
|
2066
|
-
}
|
|
2067
|
-
static isInstance(error) {
|
|
2068
|
-
return AISDKError.hasMarker(error, marker);
|
|
2069
|
-
}
|
|
2070
|
-
};
|
|
2071
|
-
//#endregion
|
|
2072
2291
|
//#region src/utils/normalize-harness-tool-model-output.ts
|
|
2073
2292
|
function normalizeHarnessToolModelOutput({ output }) {
|
|
2074
2293
|
try {
|
|
@@ -2260,6 +2479,6 @@ function convertHarnessToolModelOutput({ output }) {
|
|
|
2260
2479
|
}
|
|
2261
2480
|
}
|
|
2262
2481
|
//#endregion
|
|
2263
|
-
export { SandboxChannel, applyCredentialForwarding, classifyDiskLog, convertHarnessToolModelOutput, createBridgeErrorHandler, createBridgeStartupError, createBridgeToken, createCredentialRequestTransformation, createReadBridgeAsset, drainBridgeProcessStream, experimental_createBridgeUserMessageSubmitter, extractHarnessPromptContent, formatBridgeError, forwardBridgeProcessStream, generateSandboxCredentialPlaceholder, getAiGatewayAuthFromEnv, getJwtExpiresAt, getRestrictedSandboxSession, harnessPromptContentSchema, isAccessTokenExpiringSoon, isHarnessAuthenticationEnvironment, isLinux, isMacOS, isSandboxCredentialPlaceholder, isWindows, logBridgeError, markBridgeStarting, maskSandboxCredentials, normalizeHarnessToolModelOutput, parseJwtPayload, readLinuxSecretServicePassword, readMacOSKeychainPassword, readWindowsCredentialManagerPassword, refreshOAuthAccessToken, resolveSandboxCredentialEnvironment, resolveSandboxDefaultWorkingDirectory, resolveSandboxHomeDir, shellQuote, shouldResolveNativeSubscription, sleep, waitForBridgeReady, warnCredentialBrokeringUnavailable,
|
|
2482
|
+
export { SandboxChannel, applyCredentialForwarding, classifyDiskLog, convertHarnessToolModelOutput, createBridgeErrorHandler, createBridgeStartupError, createBridgeToken, createBridgeWebSocketConnect, createCredentialRequestTransformation, createReadBridgeAsset, drainBridgeProcessStream, experimental_createBridgeUserMessageSubmitter, extractHarnessPromptContent, formatBridgeError, forwardBridgeProcessStream, generateSandboxCredentialPlaceholder, getAiGatewayAuthFromEnv, getJwtExpiresAt, getRestrictedSandboxSession, harnessPromptContentSchema, isAccessTokenExpiringSoon, isHarnessAuthenticationEnvironment, isLinux, isMacOS, isSandboxCredentialPlaceholder, isWindows, logBridgeError, markBridgeStarting, maskSandboxCredentials, normalizeHarnessToolModelOutput, parseJwtPayload, readLinuxSecretServicePassword, readMacOSKeychainPassword, readWindowsCredentialManagerPassword, refreshOAuthAccessToken, resolveBridgeEndpoint, resolveBridgePort, resolveSandboxCredentialEnvironment, resolveSandboxDefaultWorkingDirectory, resolveSandboxHomeDir, shellQuote, shouldResolveNativeSubscription, sleep, validateBridgeSandboxSettings, waitForBridgeReady, warnCredentialBrokeringUnavailable, writeInstructions, writeSkills };
|
|
2264
2483
|
|
|
2265
2484
|
//# sourceMappingURL=index.js.map
|