@ai-sdk/harness 1.0.133 → 1.0.135

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.
@@ -1,6 +1,8 @@
1
- import { FlexibleSchema, Experimental_SandboxSession, Experimental_SandboxProcess } from '@ai-sdk/provider-utils';
2
- import { WebSocket } from 'ws';
3
-
1
+ import { Experimental_SandboxProcess, Experimental_SandboxSession, FlexibleSchema } from "@ai-sdk/provider-utils";
2
+ import { z } from "zod/v4";
3
+ import { WebSocket } from "ws";
4
+ import "@ai-sdk/provider";
5
+ //#region src/utils/sandbox-channel.d.ts
4
6
  /**
5
7
  * Diagnostic event surfaced by {@link SandboxChannel} during its connection
6
8
  * lifecycle. Silent unless a consumer wires `onDebug`. Reconnects are otherwise
@@ -8,74 +10,74 @@ import { WebSocket } from 'ws';
8
10
  * streaming.
9
11
  */
10
12
  type SandboxChannelDebugEvent = {
11
- event: 'reconnect-attempt';
12
- attempt: number;
13
- lastSeenEventId: number;
13
+ event: 'reconnect-attempt';
14
+ attempt: number;
15
+ lastSeenEventId: number;
14
16
  } | {
15
- event: 'reconnected';
16
- attempt: number;
17
- lastSeenEventId: number;
17
+ event: 'reconnected';
18
+ attempt: number;
19
+ lastSeenEventId: number;
18
20
  } | {
19
- event: 'reconnect-failed';
20
- attempts: number;
21
- lastSeenEventId: number;
22
- cause: unknown;
21
+ event: 'reconnect-failed';
22
+ attempts: number;
23
+ lastSeenEventId: number;
24
+ cause: unknown;
23
25
  };
24
26
  interface SandboxChannelReconnectOptions {
25
- /**
26
- * Give up reconnecting after this many milliseconds, including connection
27
- * establishment and backoff delays. Default 30_000.
28
- */
29
- readonly maxElapsedMs?: number;
30
- /** First backoff delay. Default 50. */
31
- readonly initialDelayMs?: number;
32
- /** Backoff ceiling. Default 2_000. */
33
- readonly maxDelayMs?: number;
27
+ /**
28
+ * Give up reconnecting after this many milliseconds, including connection
29
+ * establishment and backoff delays. Default 30_000.
30
+ */
31
+ readonly maxElapsedMs?: number;
32
+ /** First backoff delay. Default 50. */
33
+ readonly initialDelayMs?: number;
34
+ /** Backoff ceiling. Default 2_000. */
35
+ readonly maxDelayMs?: number;
34
36
  }
35
37
  interface SandboxChannelConnectOptions {
36
- readonly abortSignal: AbortSignal;
38
+ readonly abortSignal: AbortSignal;
37
39
  }
38
40
  interface SandboxChannelOptions<TOut> {
39
- /**
40
- * Open a fresh WebSocket to the bridge and resolve once it is ready to carry
41
- * frames (i.e. after any adapter-specific handshake such as Claude Code's
42
- * `bridge-hello`). Called once by {@link SandboxChannel.open} and again on
43
- * every transient reconnect. Must reject if the connection cannot be
44
- * established.
45
- */
46
- connect: (options: SandboxChannelConnectOptions) => Promise<WebSocket>;
47
- /** Schema validating inbound (bridge → host) frames. */
48
- outboundSchema: FlexibleSchema<TOut>;
49
- reconnect?: SandboxChannelReconnectOptions;
50
- onDebug?: (event: SandboxChannelDebugEvent) => void;
51
- /**
52
- * Sink for forwarded bridge diagnostics — `sandbox-log` (captured
53
- * console lines) and `debug-event` (structured) frames. When set, these
54
- * frame types are routed here instead of the per-type listener dispatch, so
55
- * they never reach the consumer's stream. Typed to the diagnostic members of
56
- * `TOut`, so it is a no-op union for channels whose protocol has none.
57
- */
58
- onDiagnostic?: (event: Extract<TOut, {
59
- type: 'sandbox-log' | 'debug-event';
60
- }>) => void;
61
- onBridgeError?: (event: Extract<TOut, {
62
- type: 'error';
63
- }>) => void;
64
- /**
65
- * Seed the host-side cursor before the first connect. Pass the
66
- * `lastSeenEventId` persisted from a prior process so the bridge replays only
67
- * events past it when this channel opens with `{ resume: true }` — the
68
- * cross-process attach handshake. Defaults to `0` (fresh session).
69
- */
70
- initialLastSeenEventId?: number;
41
+ /**
42
+ * Open a fresh WebSocket to the bridge and resolve once it is ready to carry
43
+ * frames (i.e. after any adapter-specific handshake such as Claude Code's
44
+ * `bridge-hello`). Called once by {@link SandboxChannel.open} and again on
45
+ * every transient reconnect. Must reject if the connection cannot be
46
+ * established.
47
+ */
48
+ connect: (options: SandboxChannelConnectOptions) => Promise<WebSocket>;
49
+ /** Schema validating inbound (bridge → host) frames. */
50
+ outboundSchema: FlexibleSchema<TOut>;
51
+ reconnect?: SandboxChannelReconnectOptions;
52
+ onDebug?: (event: SandboxChannelDebugEvent) => void;
53
+ /**
54
+ * Sink for forwarded bridge diagnostics — `sandbox-log` (captured
55
+ * console lines) and `debug-event` (structured) frames. When set, these
56
+ * frame types are routed here instead of the per-type listener dispatch, so
57
+ * they never reach the consumer's stream. Typed to the diagnostic members of
58
+ * `TOut`, so it is a no-op union for channels whose protocol has none.
59
+ */
60
+ onDiagnostic?: (event: Extract<TOut, {
61
+ type: 'sandbox-log' | 'debug-event';
62
+ }>) => void;
63
+ onBridgeError?: (event: Extract<TOut, {
64
+ type: 'error';
65
+ }>) => void;
66
+ /**
67
+ * Seed the host-side cursor before the first connect. Pass the
68
+ * `lastSeenEventId` persisted from a prior process so the bridge replays only
69
+ * events past it when this channel opens with `{ resume: true }` — the
70
+ * cross-process attach handshake. Defaults to `0` (fresh session).
71
+ */
72
+ initialLastSeenEventId?: number;
71
73
  }
72
74
  type EventTypeOf<TOut extends {
73
- type: string;
75
+ type: string;
74
76
  }> = TOut['type'];
75
77
  type Listener<TOut extends {
76
- type: string;
78
+ type: string;
77
79
  }, T extends EventTypeOf<TOut>> = (event: Extract<TOut, {
78
- type: T;
80
+ type: T;
79
81
  }>) => void;
80
82
  /**
81
83
  * Host-side typed wrapper around the bridge WebSocket connection.
@@ -100,148 +102,150 @@ type Listener<TOut extends {
100
102
  * in-flight turn never observes the blip — `onClose` fires only after a
101
103
  * host-initiated close or once the reconnect budget is exhausted.
102
104
  */
103
- declare class SandboxChannel<TOut extends {
104
- type: string;
105
+ export declare class SandboxChannel<TOut extends {
106
+ type: string;
105
107
  }, TIn extends {
106
- type: string;
108
+ type: string;
107
109
  } = {
108
- type: string;
110
+ type: string;
109
111
  }> {
110
- private readonly listeners;
111
- private readonly buffered;
112
- private readonly bufferedByType;
113
- private bufferedOffset;
114
- private flushingBuffered;
115
- private bufferedFlushScheduled;
116
- private listenerAttachmentDepth;
117
- private readonly onCloseHandlers;
118
- private readonly onReconnectHandlers;
119
- private readonly connectThunk;
120
- private readonly outboundSchema;
121
- private readonly onDebug;
122
- private readonly onDiagnostic;
123
- private readonly onBridgeError;
124
- private readonly maxElapsedMs;
125
- private readonly initialDelayMs;
126
- private readonly maxDelayMs;
127
- private ws;
128
- private connected;
129
- /** Host has begun teardown; suppresses reconnect so a bridge-side close finalises. */
130
- private closing;
131
- /**
132
- * Host has gracefully suspended (slice boundary). Inbound frames are ignored
133
- * from this point so the cursor stops advancing exactly at the last delivered
134
- * event — the bridge keeps the turn running and the not-yet-delivered tail is
135
- * replayed to the next process on `resume`.
136
- */
137
- private suspended;
138
- private pinnedSuspensionCursor;
139
- /** Channel is fully torn down; `send` throws and `onClose` has fired. */
140
- private terminal;
141
- private _lastSeenEventId;
142
- private readonly pendingSends;
143
- private dispatchChain;
144
- private activeConnectAbortController;
145
- private reconnectAbortController;
146
- constructor(options: SandboxChannelOptions<TOut>);
147
- /**
148
- * Highest bridge event `seq` this channel has observed. Persist it (e.g. via
149
- * the adapter's resume handle) so a future process can seed
150
- * {@link SandboxChannelOptions.initialLastSeenEventId} and attach.
151
- */
152
- get lastSeenEventId(): number;
153
- /**
154
- * Establish the initial connection. A single attempt — startup failures
155
- * reject so the caller can fail `doStart` cleanly. Reconnect retries apply
156
- * only to drops after a successful open.
157
- *
158
- * Pass `{ resume: true }` to attach to a bridge that is already mid-session:
159
- * after the socket opens, the channel sends `{ type: 'resume', lastSeenEventId }`
160
- * so the bridge replays everything past the seeded cursor. This is the
161
- * cross-process attach handshake — identical to what a transient reconnect
162
- * does, but triggered by the initial open from a new process.
163
- */
164
- open(opts?: {
165
- resume?: boolean;
166
- }): Promise<void>;
167
- on<T extends EventTypeOf<TOut>>(type: T, listener: Listener<TOut, T>): () => void;
168
- /**
169
- * Hold buffered event delivery while a consumer attaches a related set of
170
- * listeners, including across asynchronous boundaries. Call the returned
171
- * function once registration is complete. Buffered events are then replayed
172
- * in arrival order; event types that remain unhandled are retained
173
- * independently so they do not block subscribed types.
174
- */
175
- beginListenerAttachment(): () => void;
176
- onClose(handler: (code: number, reason: string) => void): void;
177
- onReconnect(handler: () => void): () => void;
178
- send(message: TIn): void;
179
- /**
180
- * Mark that the host is tearing the session down. The next socket close is
181
- * then treated as terminal rather than triggering a reconnect. Call before
182
- * sending a `stop` / `destroy` message whose completion closes the bridge
183
- * socket.
184
- */
185
- beginClose(): void;
186
- close(): void;
187
- /**
188
- * Gracefully suspend at a slice boundary: stop processing inbound frames
189
- * (so the cursor freezes at the last delivered event), drain any frames
190
- * already queued for dispatch, then close the socket and finalise with the
191
- * close reason `'suspended'`. Resolves with the final `lastSeenEventId`.
192
- *
193
- * The bridge keeps the in-flight turn running (a host socket close never
194
- * aborts it) and accumulates events past the cursor for the next process to
195
- * `resume`. Unlike {@link close}, the consumer's active turn is wound down
196
- * cleanly — adapters distinguish a suspend from an unexpected drop via the
197
- * `'suspended'` close reason and resolve `done` successfully. When an event
198
- * checkpoint is pinned, the returned cursor points to that event so any
199
- * already-dispatched tail is replayed by the next process.
200
- */
201
- suspend(): Promise<number>;
202
- isClosed(): boolean;
203
- private wire;
204
- private reconnectLoop;
205
- private connect;
206
- private abortActiveConnect;
207
- private failReconnect;
208
- private rawSend;
209
- private flushPending;
210
- private enqueue;
211
- private handleIncoming;
212
- private dispatch;
213
- private flushBuffered;
214
- private captureBufferedListeners;
215
- private flushBufferedType;
216
- private scheduleSelectiveBufferedFlush;
217
- private hasListeners;
218
- private attachEventCheckpoint;
219
- private finalizeClose;
112
+ private readonly listeners;
113
+ private readonly buffered;
114
+ private readonly bufferedByType;
115
+ private bufferedOffset;
116
+ private flushingBuffered;
117
+ private bufferedFlushScheduled;
118
+ private listenerAttachmentDepth;
119
+ private readonly onCloseHandlers;
120
+ private readonly onReconnectHandlers;
121
+ private readonly connectThunk;
122
+ private readonly outboundSchema;
123
+ private readonly onDebug;
124
+ private readonly onDiagnostic;
125
+ private readonly onBridgeError;
126
+ private readonly maxElapsedMs;
127
+ private readonly initialDelayMs;
128
+ private readonly maxDelayMs;
129
+ private ws;
130
+ private connected;
131
+ /** Host has begun teardown; suppresses reconnect so a bridge-side close finalises. */
132
+ private closing;
133
+ /**
134
+ * Host has gracefully suspended (slice boundary). Inbound frames are ignored
135
+ * from this point so the cursor stops advancing exactly at the last delivered
136
+ * event — the bridge keeps the turn running and the not-yet-delivered tail is
137
+ * replayed to the next process on `resume`.
138
+ */
139
+ private suspended;
140
+ private pinnedSuspensionCursor;
141
+ /** Channel is fully torn down; `send` throws and `onClose` has fired. */
142
+ private terminal;
143
+ private _lastSeenEventId;
144
+ private readonly pendingSends;
145
+ private dispatchChain;
146
+ private activeConnectAbortController;
147
+ private reconnectAbortController;
148
+ constructor(options: SandboxChannelOptions<TOut>);
149
+ /**
150
+ * Highest bridge event `seq` this channel has observed. Persist it (e.g. via
151
+ * the adapter's resume handle) so a future process can seed
152
+ * {@link SandboxChannelOptions.initialLastSeenEventId} and attach.
153
+ */
154
+ get lastSeenEventId(): number;
155
+ /**
156
+ * Establish the initial connection. A single attempt — startup failures
157
+ * reject so the caller can fail `doStart` cleanly. Reconnect retries apply
158
+ * only to drops after a successful open.
159
+ *
160
+ * Pass `{ resume: true }` to attach to a bridge that is already mid-session:
161
+ * after the socket opens, the channel sends `{ type: 'resume', lastSeenEventId }`
162
+ * so the bridge replays everything past the seeded cursor. This is the
163
+ * cross-process attach handshake — identical to what a transient reconnect
164
+ * does, but triggered by the initial open from a new process.
165
+ */
166
+ open(opts?: {
167
+ resume?: boolean;
168
+ }): Promise<void>;
169
+ on<T extends EventTypeOf<TOut>>(type: T, listener: Listener<TOut, T>): () => void;
170
+ /**
171
+ * Hold buffered event delivery while a consumer attaches a related set of
172
+ * listeners, including across asynchronous boundaries. Call the returned
173
+ * function once registration is complete. Buffered events are then replayed
174
+ * in arrival order; event types that remain unhandled are retained
175
+ * independently so they do not block subscribed types.
176
+ */
177
+ beginListenerAttachment(): () => void;
178
+ onClose(handler: (code: number, reason: string) => void): void;
179
+ onReconnect(handler: () => void): () => void;
180
+ send(message: TIn): void;
181
+ /**
182
+ * Mark that the host is tearing the session down. The next socket close is
183
+ * then treated as terminal rather than triggering a reconnect. Call before
184
+ * sending a `stop` / `destroy` message whose completion closes the bridge
185
+ * socket.
186
+ */
187
+ beginClose(): void;
188
+ close(): void;
189
+ /**
190
+ * Gracefully suspend at a slice boundary: stop processing inbound frames
191
+ * (so the cursor freezes at the last delivered event), drain any frames
192
+ * already queued for dispatch, then close the socket and finalise with the
193
+ * close reason `'suspended'`. Resolves with the final `lastSeenEventId`.
194
+ *
195
+ * The bridge keeps the in-flight turn running (a host socket close never
196
+ * aborts it) and accumulates events past the cursor for the next process to
197
+ * `resume`. Unlike {@link close}, the consumer's active turn is wound down
198
+ * cleanly — adapters distinguish a suspend from an unexpected drop via the
199
+ * `'suspended'` close reason and resolve `done` successfully. When an event
200
+ * checkpoint is pinned, the returned cursor points to that event so any
201
+ * already-dispatched tail is replayed by the next process.
202
+ */
203
+ suspend(): Promise<number>;
204
+ isClosed(): boolean;
205
+ private wire;
206
+ private reconnectLoop;
207
+ private connect;
208
+ private abortActiveConnect;
209
+ private failReconnect;
210
+ private rawSend;
211
+ private flushPending;
212
+ private enqueue;
213
+ private handleIncoming;
214
+ private dispatch;
215
+ private flushBuffered;
216
+ private captureBufferedListeners;
217
+ private flushBufferedType;
218
+ private scheduleSelectiveBufferedFlush;
219
+ private hasListeners;
220
+ private attachEventCheckpoint;
221
+ private finalizeClose;
220
222
  }
221
-
223
+ //#endregion
224
+ //#region src/utils/bridge-user-message-submitter.d.ts
222
225
  type Experimental_BridgeUserMessageRequest = {
223
- type: 'user-message';
224
- messageId: string;
225
- text: string;
226
+ type: 'user-message';
227
+ messageId: string;
228
+ text: string;
226
229
  };
227
230
  type Experimental_BridgeUserMessageResponse = {
228
- type: 'user-message-response';
229
- messageId: string;
230
- accepted: boolean;
231
- error?: {
232
- message: string;
233
- };
231
+ type: 'user-message-response';
232
+ messageId: string;
233
+ accepted: boolean;
234
+ error?: {
235
+ message: string;
236
+ };
234
237
  };
235
238
  type Experimental_BridgeUserMessageSubmitter = {
236
- submit(text: string): Promise<void>;
237
- close(error?: unknown): void;
239
+ submit(text: string): Promise<void>;
240
+ close(error?: unknown): void;
238
241
  };
239
- declare function experimental_createBridgeUserMessageSubmitter(options: {
240
- send(message: Experimental_BridgeUserMessageRequest): void;
241
- onResponse(listener: (response: Experimental_BridgeUserMessageResponse) => void): () => void;
242
- onReconnect(listener: () => void): () => void;
242
+ export declare function experimental_createBridgeUserMessageSubmitter(options: {
243
+ send(message: Experimental_BridgeUserMessageRequest): void;
244
+ onResponse(listener: (response: Experimental_BridgeUserMessageResponse) => void): () => void;
245
+ onReconnect(listener: () => void): () => void;
243
246
  }): Experimental_BridgeUserMessageSubmitter;
244
-
247
+ //#endregion
248
+ //#region src/utils/classify-disk-log.d.ts
245
249
  /**
246
250
  * Recovery rung selected from an on-disk bridge event log when attach is not
247
251
  * possible (the bridge process is gone): `'replay'` when the log holds a
@@ -260,15 +264,17 @@ type DiskLogRecoveryMode = 'replay' | 'rerun';
260
264
  * @param eventLog Raw contents of `event-log.ndjson` (newline-delimited JSON),
261
265
  * or `null`/`undefined`/empty when the file is absent.
262
266
  */
263
- declare function classifyDiskLog(eventLog: string | null | undefined): Promise<DiskLogRecoveryMode>;
264
-
265
- declare function getAiGatewayAuthFromEnv({ env, }: {
266
- env: Record<string, string | undefined>;
267
+ export declare function classifyDiskLog(eventLog: string | null | undefined): Promise<DiskLogRecoveryMode>;
268
+ //#endregion
269
+ //#region src/utils/ai-gateway-auth.d.ts
270
+ export declare function getAiGatewayAuthFromEnv({ env }: {
271
+ env: Record<string, string | undefined>;
267
272
  }): {
268
- apiKey: string | undefined;
269
- baseUrl: string;
273
+ apiKey: string | undefined;
274
+ baseUrl: string;
270
275
  };
271
-
276
+ //#endregion
277
+ //#region src/v1/harness-authentication.d.ts
272
278
  /**
273
279
  * Authentication-related environment variables supplied directly to a harness.
274
280
  *
@@ -280,73 +286,80 @@ type HarnessV1AuthenticationEnvironment = Readonly<Record<string, string>>;
280
286
  * Authentication options shared by harness adapters. Adapter choices must be
281
287
  * a non-empty union of concrete string values.
282
288
  */
283
- type HarnessV1Authentication<ADAPTER_CHOICES extends string = 'direct'> = [
284
- ADAPTER_CHOICES
285
- ] extends [never] ? never : string extends ADAPTER_CHOICES ? never : 'auto' | 'ai-gateway' | ADAPTER_CHOICES | HarnessV1AuthenticationEnvironment;
286
-
287
- declare function isHarnessAuthenticationEnvironment(value: unknown): value is HarnessV1AuthenticationEnvironment;
288
-
289
- declare function parseJwtPayload({ token, }: {
290
- token: string;
289
+ type HarnessV1Authentication<ADAPTER_CHOICES extends string = 'direct'> = [ADAPTER_CHOICES] extends [never] ? never : string extends ADAPTER_CHOICES ? never : 'auto' | 'ai-gateway' | ADAPTER_CHOICES | HarnessV1AuthenticationEnvironment;
290
+ //#endregion
291
+ //#region src/utils/authentication-environment.d.ts
292
+ export declare function isHarnessAuthenticationEnvironment(value: unknown): value is HarnessV1AuthenticationEnvironment;
293
+ //#endregion
294
+ //#region src/utils/native-subscription/jwt.d.ts
295
+ export declare function parseJwtPayload({ token }: {
296
+ token: string;
291
297
  }): Promise<Readonly<Record<string, unknown>> | undefined>;
292
- declare function getJwtExpiresAt({ token, }: {
293
- token: string;
298
+ export declare function getJwtExpiresAt({ token }: {
299
+ token: string;
294
300
  }): Promise<number | undefined>;
295
-
296
- declare function readLinuxSecretServicePassword({ attributes, }: {
297
- attributes: Readonly<Record<string, string>>;
301
+ //#endregion
302
+ //#region src/utils/native-subscription/linux-secret-service.d.ts
303
+ export declare function readLinuxSecretServicePassword({ attributes }: {
304
+ attributes: Readonly<Record<string, string>>;
298
305
  }): Promise<string | undefined>;
299
-
300
- declare function readMacOSKeychainPassword({ service, account, }: {
301
- service: string;
302
- account: string;
306
+ //#endregion
307
+ //#region src/utils/native-subscription/macos-keychain.d.ts
308
+ export declare function readMacOSKeychainPassword({ service, account }: {
309
+ service: string;
310
+ account: string;
303
311
  }): Promise<string | undefined>;
304
-
305
- declare function shouldResolveNativeSubscription({ auth, env, hasDirectCredential, }: {
306
- auth: Extract<HarnessV1Authentication, string> | undefined;
307
- env: Readonly<Record<string, string | undefined>>;
308
- hasDirectCredential: boolean;
312
+ //#endregion
313
+ //#region src/utils/native-subscription/should-resolve-native.d.ts
314
+ export declare function shouldResolveNativeSubscription({ auth, env, hasDirectCredential }: {
315
+ auth: Extract<HarnessV1Authentication, string> | undefined;
316
+ env: Readonly<Record<string, string | undefined>>;
317
+ hasDirectCredential: boolean;
309
318
  }): boolean;
310
-
311
- declare function readWindowsCredentialManagerPassword({ targetName, }: {
312
- targetName: string;
319
+ //#endregion
320
+ //#region src/utils/native-subscription/windows-credential-manager.d.ts
321
+ export declare function readWindowsCredentialManagerPassword({ targetName }: {
322
+ targetName: string;
313
323
  }): Promise<string | undefined>;
314
-
324
+ //#endregion
325
+ //#region src/utils/oauth-access-token.d.ts
315
326
  type OAuthCredential = {
316
- readonly accessToken: string;
317
- readonly refreshToken: string;
318
- readonly expiresAt: number;
327
+ readonly accessToken: string;
328
+ readonly refreshToken: string;
329
+ readonly expiresAt: number;
319
330
  };
320
331
  type RefreshOAuthAccessTokenResult = {
321
- readonly accessToken: string;
322
- readonly expiresAt: number;
323
- readonly refreshToken?: string;
332
+ readonly accessToken: string;
333
+ readonly expiresAt: number;
334
+ readonly refreshToken?: string;
324
335
  };
325
- declare function isAccessTokenExpiringSoon({ expiresAt, now, refreshWindowMs, }: {
326
- readonly expiresAt: number;
327
- readonly now?: number;
328
- readonly refreshWindowMs?: number;
336
+ export declare function isAccessTokenExpiringSoon({ expiresAt, now, refreshWindowMs }: {
337
+ readonly expiresAt: number;
338
+ readonly now?: number;
339
+ readonly refreshWindowMs?: number;
329
340
  }): boolean;
330
- declare function refreshOAuthAccessToken({ tokenUrl, clientId, refreshToken, requestFormat, headers, fetch: fetchImplementation, }: {
331
- readonly tokenUrl: string;
332
- readonly clientId: string;
333
- readonly refreshToken: string;
334
- readonly requestFormat?: 'json' | 'form';
335
- readonly headers?: Record<string, string>;
336
- readonly fetch?: typeof globalThis.fetch;
341
+ export declare function refreshOAuthAccessToken({ tokenUrl, clientId, refreshToken, requestFormat, headers, fetch: fetchImplementation }: {
342
+ readonly tokenUrl: string;
343
+ readonly clientId: string;
344
+ readonly refreshToken: string;
345
+ readonly requestFormat?: 'json' | 'form';
346
+ readonly headers?: Record<string, string>;
347
+ readonly fetch?: typeof globalThis.fetch;
337
348
  }): Promise<RefreshOAuthAccessTokenResult>;
338
-
339
- declare function isMacOS(platform: NodeJS.Platform): boolean;
340
- declare function isLinux(platform: NodeJS.Platform): boolean;
341
- declare function isWindows(platform: NodeJS.Platform): boolean;
342
-
349
+ //#endregion
350
+ //#region src/utils/os.d.ts
351
+ export declare function isMacOS(platform: NodeJS.Platform): boolean;
352
+ export declare function isLinux(platform: NodeJS.Platform): boolean;
353
+ export declare function isWindows(platform: NodeJS.Platform): boolean;
354
+ //#endregion
355
+ //#region src/v1/harness-v1-network-sandbox-session.d.ts
343
356
  /**
344
357
  * Connection details for a sandbox-exposed port. Headers are scoped to the
345
358
  * returned URL and must be included when opening the connection.
346
359
  */
347
360
  type HarnessV1PortEndpoint = {
348
- readonly url: string;
349
- readonly headers?: Readonly<Record<string, string>>;
361
+ readonly url: string;
362
+ readonly headers?: Readonly<Record<string, string>>;
350
363
  };
351
364
  /**
352
365
  * Network sandbox session returned by sandbox adapter creation and resume
@@ -360,94 +373,94 @@ type HarnessV1PortEndpoint = {
360
373
  * network access, or transform requests.
361
374
  */
362
375
  interface HarnessV1NetworkSandboxSession extends Experimental_SandboxSession {
363
- /**
364
- * Identifier for the sandbox session. Persist this separately from the
365
- * harness session ID and resume state when reattaching across processes.
366
- */
367
- readonly id: string;
368
- /**
369
- * The sandbox's default working directory — the absolute path that
370
- * `run`/`spawn` resolve relative commands against when no `workingDirectory`
371
- * is given. Read from the live sandbox, never hardcoded.
372
- *
373
- * The framework composes each session's working directory underneath this
374
- * path (`<defaultWorkingDirectory>/<harnessId>-<sessionId>`) so adapters do
375
- * not bake a provider-specific base into their own paths.
376
- */
377
- readonly defaultWorkingDirectory: string;
378
- /** Ports the sandbox exposes; resolvable via `getPortEndpoint`. */
379
- readonly ports: ReadonlyArray<number>;
380
- /**
381
- * Resolve the connection details for a sandbox-exposed port. Bridge-backed
382
- * adapters call this to open their WebSocket to the in-sandbox bridge.
383
- */
384
- readonly getPortEndpoint: (options: {
385
- port: number;
386
- protocol?: 'http' | 'https' | 'ws';
387
- }) => PromiseLike<HarnessV1PortEndpoint>;
388
- /**
389
- * Resolve a publicly-reachable URL for a sandbox-exposed port.
390
- *
391
- * @deprecated Use `getPortEndpoint` instead.
392
- */
393
- readonly getPortUrl: (options: {
394
- port: number;
395
- protocol?: 'http' | 'https' | 'ws';
396
- }) => PromiseLike<string>;
397
- /** Stop the sandbox. Idempotent. */
398
- readonly stop: () => PromiseLike<void>;
399
- /**
400
- * Stop the sandbox session, then perform any additional cleanup necessary
401
- * to destroy it, such as deleting its backing resource or freeing resources.
402
- * Implementations with no cleanup beyond stopping may delegate to `stop()`.
403
- * Implementations must handle both a still-running sandbox and a previously
404
- * stopped sandbox.
405
- */
406
- readonly destroy: () => PromiseLike<void>;
407
- /**
408
- * Update the sandbox's outbound network policy. Optional — implementations
409
- * without a local enforcement primitive omit this. Callers
410
- * use optional-call (`sandboxSession.setNetworkPolicy?.(policy)`); a
411
- * missing implementation is a no-op.
412
- */
413
- readonly setNetworkPolicy?: (policy: HarnessV1NetworkPolicy) => PromiseLike<void>;
414
- /**
415
- * Replace the sandbox's outbound request-transformation rules. Optional —
416
- * implementations expose this only when credentials can be injected outside
417
- * the sandbox security boundary. Calling this method assumes authority over
418
- * the complete transformation set; harness adapters should normally use
419
- * `addRequestTransformations` instead. Adapters may preserve legacy
420
- * credential-forwarding behavior when additive request transformations are
421
- * unavailable.
422
- */
423
- readonly setRequestTransformations?: (transformations: ReadonlyArray<HarnessV1RequestTransformation>) => PromiseLike<void>;
424
- /**
425
- * Add outbound request-transformation rules without replacing rules already
426
- * managed by the sandbox session. Optional for the same reason as
427
- * `setRequestTransformations`. Harness adapters should use this additive
428
- * capability unless they explicitly own the complete transformation set.
429
- */
430
- readonly addRequestTransformations?: (transformations: ReadonlyArray<HarnessV1RequestTransformation>) => PromiseLike<void>;
431
- /**
432
- * Replace the set of ports exposed by the sandbox. Full-replacement
433
- * semantics: ports omitted from the array are deregistered. Optional —
434
- * implementations that cannot expose ports omit this.
435
- */
436
- readonly setPorts?: (ports: ReadonlyArray<number>, options?: {
437
- abortSignal?: AbortSignal;
438
- }) => PromiseLike<void>;
439
- /**
440
- * Reduced view of this session, typed as the bare {@link SandboxSession}
441
- * (file I/O, exec, spawn) — nothing that could stop the sandbox or change
442
- * its network policy. Pass this to user-tool `execute()` calls and other
443
- * code that must not reach the infra surface.
444
- *
445
- * The returned object points at exactly the same underlying sandbox
446
- * resource as the network sandbox session it was produced from; it is only a
447
- * narrower surface over the same resource, not a separate sandbox. In
448
- * particular, it cannot mutate network access or request transformations.
449
- */
450
- readonly restricted: () => Experimental_SandboxSession;
376
+ /**
377
+ * Identifier for the sandbox session. Persist this separately from the
378
+ * harness session ID and resume state when reattaching across processes.
379
+ */
380
+ readonly id: string;
381
+ /**
382
+ * The sandbox's default working directory — the absolute path that
383
+ * `run`/`spawn` resolve relative commands against when no `workingDirectory`
384
+ * is given. Read from the live sandbox, never hardcoded.
385
+ *
386
+ * The framework composes each session's working directory underneath this
387
+ * path (`<defaultWorkingDirectory>/<harnessId>-<sessionId>`) so adapters do
388
+ * not bake a provider-specific base into their own paths.
389
+ */
390
+ readonly defaultWorkingDirectory: string;
391
+ /** Ports the sandbox exposes; resolvable via `getPortEndpoint`. */
392
+ readonly ports: ReadonlyArray<number>;
393
+ /**
394
+ * Resolve the connection details for a sandbox-exposed port. Bridge-backed
395
+ * adapters call this to open their WebSocket to the in-sandbox bridge.
396
+ */
397
+ readonly getPortEndpoint: (options: {
398
+ port: number;
399
+ protocol?: 'http' | 'https' | 'ws';
400
+ }) => PromiseLike<HarnessV1PortEndpoint>;
401
+ /**
402
+ * Resolve a publicly-reachable URL for a sandbox-exposed port.
403
+ *
404
+ * @deprecated Use `getPortEndpoint` instead.
405
+ */
406
+ readonly getPortUrl: (options: {
407
+ port: number;
408
+ protocol?: 'http' | 'https' | 'ws';
409
+ }) => PromiseLike<string>;
410
+ /** Stop the sandbox. Idempotent. */
411
+ readonly stop: () => PromiseLike<void>;
412
+ /**
413
+ * Stop the sandbox session, then perform any additional cleanup necessary
414
+ * to destroy it, such as deleting its backing resource or freeing resources.
415
+ * Implementations with no cleanup beyond stopping may delegate to `stop()`.
416
+ * Implementations must handle both a still-running sandbox and a previously
417
+ * stopped sandbox.
418
+ */
419
+ readonly destroy: () => PromiseLike<void>;
420
+ /**
421
+ * Update the sandbox's outbound network policy. Optional — implementations
422
+ * without a local enforcement primitive omit this. Callers
423
+ * use optional-call (`sandboxSession.setNetworkPolicy?.(policy)`); a
424
+ * missing implementation is a no-op.
425
+ */
426
+ readonly setNetworkPolicy?: (policy: HarnessV1NetworkPolicy) => PromiseLike<void>;
427
+ /**
428
+ * Replace the sandbox's outbound request-transformation rules. Optional —
429
+ * implementations expose this only when credentials can be injected outside
430
+ * the sandbox security boundary. Calling this method assumes authority over
431
+ * the complete transformation set; harness adapters should normally use
432
+ * `addRequestTransformations` instead. Adapters may preserve legacy
433
+ * credential-forwarding behavior when additive request transformations are
434
+ * unavailable.
435
+ */
436
+ readonly setRequestTransformations?: (transformations: ReadonlyArray<HarnessV1RequestTransformation>) => PromiseLike<void>;
437
+ /**
438
+ * Add outbound request-transformation rules without replacing rules already
439
+ * managed by the sandbox session. Optional for the same reason as
440
+ * `setRequestTransformations`. Harness adapters should use this additive
441
+ * capability unless they explicitly own the complete transformation set.
442
+ */
443
+ readonly addRequestTransformations?: (transformations: ReadonlyArray<HarnessV1RequestTransformation>) => PromiseLike<void>;
444
+ /**
445
+ * Replace the set of ports exposed by the sandbox. Full-replacement
446
+ * semantics: ports omitted from the array are deregistered. Optional —
447
+ * implementations that cannot expose ports omit this.
448
+ */
449
+ readonly setPorts?: (ports: ReadonlyArray<number>, options?: {
450
+ abortSignal?: AbortSignal;
451
+ }) => PromiseLike<void>;
452
+ /**
453
+ * Reduced view of this session, typed as the bare {@link SandboxSession}
454
+ * (file I/O, exec, spawn) — nothing that could stop the sandbox or change
455
+ * its network policy. Pass this to user-tool `execute()` calls and other
456
+ * code that must not reach the infra surface.
457
+ *
458
+ * The returned object points at exactly the same underlying sandbox
459
+ * resource as the network sandbox session it was produced from; it is only a
460
+ * narrower surface over the same resource, not a separate sandbox. In
461
+ * particular, it cannot mutate network access or request transformations.
462
+ */
463
+ readonly restricted: () => Experimental_SandboxSession;
451
464
  }
452
465
  /**
453
466
  * Outbound network policy applied by the sandbox runtime.
@@ -465,37 +478,37 @@ interface HarnessV1NetworkSandboxSession extends Experimental_SandboxSession {
465
478
  * equivalent to `'deny-all'`.
466
479
  */
467
480
  type HarnessV1NetworkPolicy = {
468
- mode: 'allow-all';
481
+ mode: 'allow-all';
469
482
  } | {
470
- mode: 'deny-all';
483
+ mode: 'deny-all';
471
484
  } | {
472
- mode: 'custom';
473
- allowedHosts: ReadonlyArray<string>;
474
- allowedCIDRs?: ReadonlyArray<string>;
475
- deniedCIDRs?: ReadonlyArray<string>;
485
+ mode: 'custom';
486
+ allowedHosts: ReadonlyArray<string>;
487
+ allowedCIDRs?: ReadonlyArray<string>;
488
+ deniedCIDRs?: ReadonlyArray<string>;
476
489
  } | {
477
- mode: 'custom';
478
- allowedHosts?: ReadonlyArray<string>;
479
- allowedCIDRs: ReadonlyArray<string>;
480
- deniedCIDRs?: ReadonlyArray<string>;
490
+ mode: 'custom';
491
+ allowedHosts?: ReadonlyArray<string>;
492
+ allowedCIDRs: ReadonlyArray<string>;
493
+ deniedCIDRs?: ReadonlyArray<string>;
481
494
  };
482
495
  type HarnessV1RequestTransformationPathMatcher = {
483
- exact: string;
496
+ exact: string;
484
497
  } | {
485
- startsWith: string;
498
+ startsWith: string;
486
499
  } | {
487
- regex: string;
500
+ regex: string;
488
501
  };
489
502
  type HarnessV1RequestTransformationKeyValuePartMatcher = {
490
- exact: string;
503
+ exact: string;
491
504
  } | {
492
- startsWith: string;
505
+ startsWith: string;
493
506
  } | {
494
- regex: string;
507
+ regex: string;
495
508
  };
496
509
  type HarnessV1RequestTransformationKeyValueMatcher = {
497
- readonly key?: HarnessV1RequestTransformationKeyValuePartMatcher;
498
- readonly value?: HarnessV1RequestTransformationKeyValuePartMatcher;
510
+ readonly key?: HarnessV1RequestTransformationKeyValuePartMatcher;
511
+ readonly value?: HarnessV1RequestTransformationKeyValuePartMatcher;
499
512
  };
500
513
  /**
501
514
  * Outbound HTTPS request transformation applied outside the sandbox security
@@ -509,50 +522,52 @@ type HarnessV1RequestTransformationKeyValueMatcher = {
509
522
  * making transformed values available inside it.
510
523
  */
511
524
  type HarnessV1RequestTransformation = {
512
- readonly match: {
513
- readonly host: string;
514
- readonly path?: HarnessV1RequestTransformationPathMatcher;
515
- readonly method?: ReadonlyArray<string>;
516
- readonly queryString?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;
517
- readonly headers?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;
518
- };
519
- readonly transform: {
520
- readonly headers: Readonly<Record<string, string>>;
521
- };
525
+ readonly match: {
526
+ readonly host: string;
527
+ readonly path?: HarnessV1RequestTransformationPathMatcher;
528
+ readonly method?: ReadonlyArray<string>;
529
+ readonly queryString?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;
530
+ readonly headers?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;
531
+ };
532
+ readonly transform: {
533
+ readonly headers: Readonly<Record<string, string>>;
534
+ };
522
535
  };
523
-
536
+ //#endregion
537
+ //#region src/v1/harness-v1-skill.d.ts
524
538
  /**
525
539
  * A self-contained instruction bundle the underlying runtime can load into
526
540
  * its context. Adapters decide how to surface skills to the runtime.
527
541
  */
528
542
  type HarnessV1Skill = {
529
- /** Stable identifier for the skill (kebab-case slug). */
530
- readonly name: string;
531
- /**
532
- * Short, model-facing description. This is what the runtime sees to
533
- * decide whether the skill is relevant.
534
- */
535
- readonly description: string;
536
- /** Full skill content the model loads when the skill is active. */
537
- readonly content: string;
538
- /**
539
- * Additional files that belong to this skill. Adapters with native skill
540
- * directories materialize these next to `SKILL.md`; adapters without native
541
- * skill files include them with the skill content.
542
- */
543
- readonly files?: ReadonlyArray<HarnessV1SkillFile>;
543
+ /** Stable identifier for the skill (kebab-case slug). */
544
+ readonly name: string;
545
+ /**
546
+ * Short, model-facing description. This is what the runtime sees to
547
+ * decide whether the skill is relevant.
548
+ */
549
+ readonly description: string;
550
+ /** Full skill content the model loads when the skill is active. */
551
+ readonly content: string;
552
+ /**
553
+ * Additional files that belong to this skill. Adapters with native skill
554
+ * directories materialize these next to `SKILL.md`; adapters without native
555
+ * skill files include them with the skill content.
556
+ */
557
+ readonly files?: ReadonlyArray<HarnessV1SkillFile>;
544
558
  };
545
559
  type HarnessV1SkillFile = {
546
- /**
547
- * Skill-relative POSIX path, for example `reference.md` or
548
- * `references/codes.md`. Absolute paths and `..` segments are rejected by
549
- * adapters before writing.
550
- */
551
- readonly path: string;
552
- /** UTF-8 text content for the file. */
553
- readonly content: string;
560
+ /**
561
+ * Skill-relative POSIX path, for example `reference.md` or
562
+ * `references/codes.md`. Absolute paths and `..` segments are rejected by
563
+ * adapters before writing.
564
+ */
565
+ readonly path: string;
566
+ /** UTF-8 text content for the file. */
567
+ readonly content: string;
554
568
  };
555
-
569
+ //#endregion
570
+ //#region src/v1/harness-v1-credential-forwarding.d.ts
556
571
  /**
557
572
  * Customizes a credential value immediately before a harness adapter forwards
558
573
  * it into a sandbox process.
@@ -562,175 +577,189 @@ type HarnessV1SkillFile = {
562
577
  * otherwise access in the host process.
563
578
  */
564
579
  type HarnessV1CredentialForwarding = (options: {
565
- /**
566
- * The credential value that the adapter would otherwise forward. This is a
567
- * generated sandbox placeholder when credential brokering is available and
568
- * the real credential otherwise. Use `isSandboxCredentialPlaceholder` from
569
- * `@ai-sdk/harness/utils` to distinguish generated placeholders.
570
- */
571
- readonly credential: string;
572
- /** The environment variable name used to expose the value in the sandbox. */
573
- readonly environmentVariableName: string;
580
+ /**
581
+ * The credential value that the adapter would otherwise forward. This is a
582
+ * generated sandbox placeholder when credential brokering is available and
583
+ * the real credential otherwise. Use `isSandboxCredentialPlaceholder` from
584
+ * `@ai-sdk/harness/utils` to distinguish generated placeholders.
585
+ */
586
+ readonly credential: string;
587
+ /** The environment variable name used to expose the value in the sandbox. */
588
+ readonly environmentVariableName: string;
574
589
  }) => string | PromiseLike<string>;
575
-
576
- declare function applyCredentialForwarding({ environment, credentialEnvironmentVariables, credentialForwarding, }: {
577
- environment: Readonly<Record<string, string>>;
578
- credentialEnvironmentVariables: ReadonlyArray<string>;
579
- credentialForwarding: HarnessV1CredentialForwarding | undefined;
590
+ //#endregion
591
+ //#region src/utils/credential-forwarding.d.ts
592
+ export declare function applyCredentialForwarding({ environment, credentialEnvironmentVariables, credentialForwarding }: {
593
+ environment: Readonly<Record<string, string>>;
594
+ credentialEnvironmentVariables: ReadonlyArray<string>;
595
+ credentialForwarding: HarnessV1CredentialForwarding | undefined;
580
596
  }): Promise<Record<string, string>>;
581
- declare function resolveSandboxCredentialEnvironment({ environment, credentialEnvironmentVariables, credentialForwarding, previousSandboxCredentialEnvironment, }: {
582
- environment: Readonly<Record<string, string>>;
583
- credentialEnvironmentVariables: ReadonlyArray<string>;
584
- credentialForwarding: HarnessV1CredentialForwarding | undefined;
585
- previousSandboxCredentialEnvironment?: Readonly<Record<string, string>>;
597
+ export declare function resolveSandboxCredentialEnvironment({ environment, credentialEnvironmentVariables, credentialForwarding, previousSandboxCredentialEnvironment }: {
598
+ environment: Readonly<Record<string, string>>;
599
+ credentialEnvironmentVariables: ReadonlyArray<string>;
600
+ credentialForwarding: HarnessV1CredentialForwarding | undefined;
601
+ previousSandboxCredentialEnvironment?: Readonly<Record<string, string>>;
586
602
  }): Promise<Record<string, string>>;
587
-
588
- declare function generateSandboxCredentialPlaceholder(): string;
589
- declare function isSandboxCredentialPlaceholder(value: string): boolean;
603
+ //#endregion
604
+ //#region src/utils/sandbox-credential-brokering.d.ts
605
+ export declare function generateSandboxCredentialPlaceholder(): string;
606
+ export declare function isSandboxCredentialPlaceholder(value: string): boolean;
590
607
  /**
591
608
  * Warns when credential brokering is unavailable, but only if real credentials
592
609
  * remain among the credentials forwarded into the sandbox.
593
610
  */
594
- declare function warnCredentialBrokeringUnavailable(options: {
595
- environment: Readonly<Record<string, string>>;
596
- forwardedEnvironment: Readonly<Record<string, string>>;
597
- credentialEnvironmentVariables: ReadonlyArray<string>;
611
+ export declare function warnCredentialBrokeringUnavailable(options: {
612
+ environment: Readonly<Record<string, string>>;
613
+ forwardedEnvironment: Readonly<Record<string, string>>;
614
+ credentialEnvironmentVariables: ReadonlyArray<string>;
598
615
  }): void;
599
- declare function maskSandboxCredentials({ environment, credentialEnvironmentVariables, }: {
600
- environment: Readonly<Record<string, string>>;
601
- credentialEnvironmentVariables: ReadonlyArray<string>;
616
+ export declare function maskSandboxCredentials({ environment, credentialEnvironmentVariables }: {
617
+ environment: Readonly<Record<string, string>>;
618
+ credentialEnvironmentVariables: ReadonlyArray<string>;
602
619
  }): Record<string, string>;
603
- declare function createCredentialRequestTransformation({ matchUrl, matchHeaders, transformHeaders, }: {
604
- matchUrl: string;
605
- matchHeaders: Readonly<Record<string, string>>;
606
- transformHeaders: Readonly<Record<string, string>>;
620
+ export declare function createCredentialRequestTransformation({ matchUrl, matchHeaders, transformHeaders }: {
621
+ matchUrl: string;
622
+ matchHeaders: Readonly<Record<string, string>>;
623
+ transformHeaders: Readonly<Record<string, string>>;
607
624
  }): HarnessV1RequestTransformation;
608
-
609
- declare function resolveSandboxHomeDir({ sandbox, abortSignal, }: {
610
- sandbox: Experimental_SandboxSession;
611
- abortSignal?: AbortSignal;
625
+ //#endregion
626
+ //#region src/utils/sandbox-home-dir.d.ts
627
+ export declare function resolveSandboxHomeDir({ sandbox, abortSignal }: {
628
+ sandbox: Experimental_SandboxSession;
629
+ abortSignal?: AbortSignal;
612
630
  }): Promise<string>;
613
-
614
- declare function shellQuote(value: string): string;
615
-
631
+ //#endregion
632
+ //#region src/utils/shell-quote.d.ts
633
+ export declare function shellQuote(value: string): string;
634
+ //#endregion
635
+ //#region src/utils/write-instructions.d.ts
616
636
  type WriteInstructionsOptions = {
617
- sandbox: Experimental_SandboxSession;
618
- homePath: string;
619
- instructionsFile: string;
620
- instructions?: string;
621
- abortSignal?: AbortSignal;
637
+ sandbox: Experimental_SandboxSession;
638
+ homePath: string;
639
+ instructionsFile: string;
640
+ instructions?: string;
641
+ abortSignal?: AbortSignal;
622
642
  };
623
643
  type WriteInstructionsResult = {
624
- changed: boolean;
625
- filePath: string;
644
+ changed: boolean;
645
+ filePath: string;
626
646
  };
627
- declare function writeInstructions({ sandbox, homePath, instructionsFile, instructions, abortSignal, }: WriteInstructionsOptions): Promise<WriteInstructionsResult>;
628
-
647
+ export declare function writeInstructions({ sandbox, homePath, instructionsFile, instructions, abortSignal }: WriteInstructionsOptions): Promise<WriteInstructionsResult>;
648
+ //#endregion
649
+ //#region src/utils/write-skills.d.ts
629
650
  type SkillFilePathMode = 'relative' | 'strip-leading-slashes';
630
651
  type WriteSkillsOptions = {
631
- sandbox: Experimental_SandboxSession;
632
- homePath: string;
633
- skillsDir: string;
634
- skills: ReadonlyArray<HarnessV1Skill>;
635
- abortSignal?: AbortSignal;
636
- skillNamePattern?: RegExp;
637
- invalidSkillNameMessage?: (input: {
638
- name: string;
639
- }) => string;
640
- filePathMode?: SkillFilePathMode;
641
- invalidSkillFilePathMessage?: (input: {
642
- skillName: string;
643
- filePath: string;
644
- }) => string;
645
- trailingNewline?: boolean;
652
+ sandbox: Experimental_SandboxSession;
653
+ homePath: string;
654
+ skillsDir: string;
655
+ skills: ReadonlyArray<HarnessV1Skill>;
656
+ abortSignal?: AbortSignal;
657
+ skillNamePattern?: RegExp;
658
+ invalidSkillNameMessage?: (input: {
659
+ name: string;
660
+ }) => string;
661
+ filePathMode?: SkillFilePathMode;
662
+ invalidSkillFilePathMessage?: (input: {
663
+ skillName: string;
664
+ filePath: string;
665
+ }) => string;
666
+ trailingNewline?: boolean;
646
667
  };
647
668
  type WriteSkillsResult = {
648
- changed: boolean;
649
- written: string[];
650
- removed: string[];
651
- unchanged: string[];
669
+ changed: boolean;
670
+ written: string[];
671
+ removed: string[];
672
+ unchanged: string[];
652
673
  };
653
- declare function writeSkills({ sandbox, homePath, skillsDir, skills, abortSignal, skillNamePattern, invalidSkillNameMessage, filePathMode, invalidSkillFilePathMessage, trailingNewline, }: WriteSkillsOptions): Promise<WriteSkillsResult>;
654
-
674
+ export declare function writeSkills({ sandbox, homePath, skillsDir, skills, abortSignal, skillNamePattern, invalidSkillNameMessage, filePathMode, invalidSkillFilePathMessage, trailingNewline }: WriteSkillsOptions): Promise<WriteSkillsResult>;
675
+ //#endregion
676
+ //#region src/utils/bridge-ready.d.ts
655
677
  type BridgeReadySource = 'stdout' | 'metadata';
656
678
  type BridgeReadyErrorContext = {
657
- proc: Experimental_SandboxProcess;
658
- stdoutTail: string[];
679
+ proc: Experimental_SandboxProcess;
680
+ stdoutTail: string[];
659
681
  };
660
682
  type WaitForBridgeReadyOptions = {
661
- proc: Experimental_SandboxProcess;
662
- sandbox: Experimental_SandboxSession;
663
- bridgeStateDir: string;
664
- bridgeType: string;
665
- timeoutMs: number;
666
- abortSignal?: AbortSignal;
667
- pollIntervalMs?: number;
668
- createTimeoutError?: (context: BridgeReadyErrorContext) => Error | Promise<Error>;
669
- createExitError?: (context: BridgeReadyErrorContext) => Error | Promise<Error>;
683
+ proc: Experimental_SandboxProcess;
684
+ sandbox: Experimental_SandboxSession;
685
+ bridgeStateDir: string;
686
+ bridgeType: string;
687
+ timeoutMs: number;
688
+ abortSignal?: AbortSignal;
689
+ pollIntervalMs?: number;
690
+ createTimeoutError?: (context: BridgeReadyErrorContext) => Error | Promise<Error>;
691
+ createExitError?: (context: BridgeReadyErrorContext) => Error | Promise<Error>;
670
692
  };
671
693
  type WaitForBridgeReadyResult = {
672
- port: number;
673
- source: BridgeReadySource;
674
- stdoutTail: string[];
694
+ port: number;
695
+ source: BridgeReadySource;
696
+ stdoutTail: string[];
675
697
  };
676
- declare function markBridgeStarting({ sandbox, bridgeStateDir, bridgeType, abortSignal, }: {
677
- sandbox: Experimental_SandboxSession;
678
- bridgeStateDir: string;
679
- bridgeType: string;
680
- abortSignal?: AbortSignal;
698
+ export declare function markBridgeStarting({ sandbox, bridgeStateDir, bridgeType, abortSignal }: {
699
+ sandbox: Experimental_SandboxSession;
700
+ bridgeStateDir: string;
701
+ bridgeType: string;
702
+ abortSignal?: AbortSignal;
681
703
  }): Promise<void>;
682
- declare function waitForBridgeReady({ proc, sandbox, bridgeStateDir, bridgeType, timeoutMs, abortSignal, pollIntervalMs, createTimeoutError, createExitError, }: WaitForBridgeReadyOptions): Promise<WaitForBridgeReadyResult>;
683
-
684
- declare function createBridgeToken(): string;
685
- declare function withBridgeToken({ endpoint, token, }: {
686
- endpoint: HarnessV1PortEndpoint;
687
- token: string;
704
+ export declare function waitForBridgeReady({ proc, sandbox, bridgeStateDir, bridgeType, timeoutMs, abortSignal, pollIntervalMs, createTimeoutError, createExitError }: WaitForBridgeReadyOptions): Promise<WaitForBridgeReadyResult>;
705
+ //#endregion
706
+ //#region src/utils/bridge-token.d.ts
707
+ export declare function createBridgeToken(): string;
708
+ export declare function withBridgeToken({ endpoint, token }: {
709
+ endpoint: HarnessV1PortEndpoint;
710
+ token: string;
688
711
  }): HarnessV1PortEndpoint;
689
-
690
- declare function createReadBridgeAsset<const ASSET_URLS extends Record<string, URL>>(assetUrls: ASSET_URLS): (name: Extract<keyof ASSET_URLS, string>) => Promise<string>;
691
-
712
+ //#endregion
713
+ //#region src/utils/bridge-asset.d.ts
714
+ export declare function createReadBridgeAsset<const ASSET_URLS extends Record<string, URL>>(assetUrls: ASSET_URLS): (name: Extract<keyof ASSET_URLS, string>) => Promise<string>;
715
+ //#endregion
716
+ //#region src/utils/bridge-diagnostics.d.ts
692
717
  type BridgeProcessStreamName = 'stdout' | 'stderr';
693
- declare function formatBridgeError(error: unknown): string;
694
- declare function logBridgeError({ harnessId, sessionId, context, error, write, }: {
695
- harnessId: string;
696
- sessionId?: string;
697
- context?: string;
698
- error: unknown;
699
- write?: (line: string) => void;
718
+ export declare function formatBridgeError(error: unknown): string;
719
+ export declare function logBridgeError({ harnessId, sessionId, context, error, write }: {
720
+ harnessId: string;
721
+ sessionId?: string;
722
+ context?: string;
723
+ error: unknown;
724
+ write?: (line: string) => void;
700
725
  }): void;
701
- declare function createBridgeErrorHandler({ harnessId, sessionId, }: {
702
- harnessId: string;
703
- sessionId?: string;
726
+ export declare function createBridgeErrorHandler({ harnessId, sessionId }: {
727
+ harnessId: string;
728
+ sessionId?: string;
704
729
  }): (event: {
705
- type: 'error';
706
- error: unknown;
730
+ type: 'error';
731
+ error: unknown;
707
732
  }) => void;
708
- declare function createBridgeStartupError({ message, proc, stdoutTail, stderrTail, stderrDone, }: {
709
- message: string;
710
- proc: Experimental_SandboxProcess;
711
- stdoutTail: string[];
712
- stderrTail: string[];
713
- stderrDone?: Promise<void>;
733
+ export declare function createBridgeStartupError({ message, proc, stdoutTail, stderrTail, stderrDone }: {
734
+ message: string;
735
+ proc: Experimental_SandboxProcess;
736
+ stdoutTail: string[];
737
+ stderrTail: string[];
738
+ stderrDone?: Promise<void>;
714
739
  }): Promise<Error>;
715
- declare function forwardBridgeProcessStream({ stream, streamName, source, collectTail, tailLimit, }: {
716
- stream: ReadableStream<Uint8Array>;
717
- streamName: BridgeProcessStreamName;
718
- source?: string;
719
- collectTail?: string[];
720
- tailLimit?: number;
740
+ export declare function forwardBridgeProcessStream({ stream, streamName, source, collectTail, tailLimit }: {
741
+ stream: ReadableStream<Uint8Array>;
742
+ streamName: BridgeProcessStreamName;
743
+ source?: string;
744
+ collectTail?: string[];
745
+ tailLimit?: number;
721
746
  }): Promise<void>;
722
- declare function drainBridgeProcessStream(stream: ReadableStream<Uint8Array>): Promise<void>;
723
-
724
- declare function resolveSandboxDefaultWorkingDirectory({ sandboxSession, abortSignal, }: {
725
- readonly sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
726
- readonly abortSignal?: AbortSignal;
747
+ export declare function drainBridgeProcessStream(stream: ReadableStream<Uint8Array>): Promise<void>;
748
+ //#endregion
749
+ //#region src/utils/resolve-sandbox-default-working-directory.d.ts
750
+ export declare function resolveSandboxDefaultWorkingDirectory({ sandboxSession, abortSignal }: {
751
+ readonly sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession;
752
+ readonly abortSignal?: AbortSignal;
727
753
  }): Promise<string>;
728
-
729
- declare function getRestrictedSandboxSession(sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession): Experimental_SandboxSession;
730
-
731
- declare function sleep({ ms, abortSignal, }: {
732
- ms: number;
733
- abortSignal?: AbortSignal;
754
+ //#endregion
755
+ //#region src/utils/get-restricted-sandbox-session.d.ts
756
+ export declare function getRestrictedSandboxSession(sandboxSession: HarnessV1NetworkSandboxSession | Experimental_SandboxSession): Experimental_SandboxSession;
757
+ //#endregion
758
+ //#region src/utils/sleep.d.ts
759
+ export declare function sleep({ ms, abortSignal }: {
760
+ ms: number;
761
+ abortSignal?: AbortSignal;
734
762
  }): Promise<void>;
735
-
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 };
763
+ //#endregion
764
+ export type { BridgeReadyErrorContext, BridgeReadySource, DiskLogRecoveryMode, Experimental_BridgeUserMessageRequest, Experimental_BridgeUserMessageResponse, Experimental_BridgeUserMessageSubmitter, OAuthCredential, RefreshOAuthAccessTokenResult, SandboxChannelConnectOptions, SandboxChannelDebugEvent, SandboxChannelOptions, SandboxChannelReconnectOptions, SkillFilePathMode, WaitForBridgeReadyOptions, WaitForBridgeReadyResult, WriteInstructionsOptions, WriteInstructionsResult, WriteSkillsOptions, WriteSkillsResult };
765
+ //# sourceMappingURL=index.d.ts.map