@ai-sdk/harness 1.0.133 → 1.0.134
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 +14 -0
- package/dist/agent/index.d.ts +1546 -1509
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +4419 -5044
- package/dist/agent/index.js.map +1 -1
- package/dist/bridge/index.d.ts +141 -139
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +579 -650
- package/dist/bridge/index.js.map +1 -1
- package/dist/index.d.ts +1447 -1422
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +703 -668
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +551 -522
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +1910 -2465
- package/dist/utils/index.js.map +1 -1
- package/package.json +9 -9
- package/src/bridge/index.ts +1 -1
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
event: 'reconnect-attempt';
|
|
14
|
+
attempt: number;
|
|
15
|
+
lastSeenEventId: number;
|
|
14
16
|
} | {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
event: 'reconnected';
|
|
18
|
+
attempt: number;
|
|
19
|
+
lastSeenEventId: number;
|
|
18
20
|
} | {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
event: 'reconnect-failed';
|
|
22
|
+
attempts: number;
|
|
23
|
+
lastSeenEventId: number;
|
|
24
|
+
cause: unknown;
|
|
23
25
|
};
|
|
24
26
|
interface SandboxChannelReconnectOptions {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
38
|
+
readonly abortSignal: AbortSignal;
|
|
37
39
|
}
|
|
38
40
|
interface SandboxChannelOptions<TOut> {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
75
|
+
type: string;
|
|
74
76
|
}> = TOut['type'];
|
|
75
77
|
type Listener<TOut extends {
|
|
76
|
-
|
|
78
|
+
type: string;
|
|
77
79
|
}, T extends EventTypeOf<TOut>> = (event: Extract<TOut, {
|
|
78
|
-
|
|
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
|
-
|
|
105
|
+
export declare class SandboxChannel<TOut extends {
|
|
106
|
+
type: string;
|
|
105
107
|
}, TIn extends {
|
|
106
|
-
|
|
108
|
+
type: string;
|
|
107
109
|
} = {
|
|
108
|
-
|
|
110
|
+
type: string;
|
|
109
111
|
}> {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
+
type: 'user-message';
|
|
227
|
+
messageId: string;
|
|
228
|
+
text: string;
|
|
226
229
|
};
|
|
227
230
|
type Experimental_BridgeUserMessageResponse = {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
237
|
-
|
|
239
|
+
submit(text: string): Promise<void>;
|
|
240
|
+
close(error?: unknown): void;
|
|
238
241
|
};
|
|
239
|
-
declare function experimental_createBridgeUserMessageSubmitter(options: {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
266
|
-
|
|
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
|
-
|
|
269
|
-
|
|
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
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
declare function parseJwtPayload({ token
|
|
290
|
-
|
|
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
|
-
|
|
298
|
+
export declare function getJwtExpiresAt({ token }: {
|
|
299
|
+
token: string;
|
|
294
300
|
}): Promise<number | undefined>;
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
-
|
|
312
|
-
|
|
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
|
-
|
|
317
|
-
|
|
318
|
-
|
|
327
|
+
readonly accessToken: string;
|
|
328
|
+
readonly refreshToken: string;
|
|
329
|
+
readonly expiresAt: number;
|
|
319
330
|
};
|
|
320
331
|
type RefreshOAuthAccessTokenResult = {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
332
|
+
readonly accessToken: string;
|
|
333
|
+
readonly expiresAt: number;
|
|
334
|
+
readonly refreshToken?: string;
|
|
324
335
|
};
|
|
325
|
-
declare function isAccessTokenExpiringSoon({ expiresAt, now, refreshWindowMs
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
-
|
|
340
|
-
declare function
|
|
341
|
-
declare function
|
|
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
|
-
|
|
349
|
-
|
|
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
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
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
|
-
|
|
481
|
+
mode: 'allow-all';
|
|
469
482
|
} | {
|
|
470
|
-
|
|
483
|
+
mode: 'deny-all';
|
|
471
484
|
} | {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
485
|
+
mode: 'custom';
|
|
486
|
+
allowedHosts: ReadonlyArray<string>;
|
|
487
|
+
allowedCIDRs?: ReadonlyArray<string>;
|
|
488
|
+
deniedCIDRs?: ReadonlyArray<string>;
|
|
476
489
|
} | {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
490
|
+
mode: 'custom';
|
|
491
|
+
allowedHosts?: ReadonlyArray<string>;
|
|
492
|
+
allowedCIDRs: ReadonlyArray<string>;
|
|
493
|
+
deniedCIDRs?: ReadonlyArray<string>;
|
|
481
494
|
};
|
|
482
495
|
type HarnessV1RequestTransformationPathMatcher = {
|
|
483
|
-
|
|
496
|
+
exact: string;
|
|
484
497
|
} | {
|
|
485
|
-
|
|
498
|
+
startsWith: string;
|
|
486
499
|
} | {
|
|
487
|
-
|
|
500
|
+
regex: string;
|
|
488
501
|
};
|
|
489
502
|
type HarnessV1RequestTransformationKeyValuePartMatcher = {
|
|
490
|
-
|
|
503
|
+
exact: string;
|
|
491
504
|
} | {
|
|
492
|
-
|
|
505
|
+
startsWith: string;
|
|
493
506
|
} | {
|
|
494
|
-
|
|
507
|
+
regex: string;
|
|
495
508
|
};
|
|
496
509
|
type HarnessV1RequestTransformationKeyValueMatcher = {
|
|
497
|
-
|
|
498
|
-
|
|
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
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
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
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
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
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
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
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
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
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
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
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
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
|
-
|
|
589
|
-
declare function
|
|
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
|
-
|
|
596
|
-
|
|
597
|
-
|
|
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
|
-
|
|
601
|
-
|
|
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
|
-
|
|
605
|
-
|
|
606
|
-
|
|
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
|
-
|
|
610
|
-
|
|
611
|
-
|
|
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
|
-
|
|
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
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
637
|
+
sandbox: Experimental_SandboxSession;
|
|
638
|
+
homePath: string;
|
|
639
|
+
instructionsFile: string;
|
|
640
|
+
instructions?: string;
|
|
641
|
+
abortSignal?: AbortSignal;
|
|
622
642
|
};
|
|
623
643
|
type WriteInstructionsResult = {
|
|
624
|
-
|
|
625
|
-
|
|
644
|
+
changed: boolean;
|
|
645
|
+
filePath: string;
|
|
626
646
|
};
|
|
627
|
-
declare function writeInstructions({ sandbox, homePath, instructionsFile, instructions, abortSignal
|
|
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
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
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
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
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
|
|
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
|
-
|
|
658
|
-
|
|
679
|
+
proc: Experimental_SandboxProcess;
|
|
680
|
+
stdoutTail: string[];
|
|
659
681
|
};
|
|
660
682
|
type WaitForBridgeReadyOptions = {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
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
|
-
|
|
673
|
-
|
|
674
|
-
|
|
694
|
+
port: number;
|
|
695
|
+
source: BridgeReadySource;
|
|
696
|
+
stdoutTail: string[];
|
|
675
697
|
};
|
|
676
|
-
declare function markBridgeStarting({ sandbox, bridgeStateDir, bridgeType, abortSignal
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
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
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
declare function
|
|
686
|
-
|
|
687
|
-
|
|
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
|
-
|
|
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
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
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
|
-
|
|
703
|
-
|
|
726
|
+
export declare function createBridgeErrorHandler({ harnessId, sessionId }: {
|
|
727
|
+
harnessId: string;
|
|
728
|
+
sessionId?: string;
|
|
704
729
|
}): (event: {
|
|
705
|
-
|
|
706
|
-
|
|
730
|
+
type: 'error';
|
|
731
|
+
error: unknown;
|
|
707
732
|
}) => void;
|
|
708
|
-
declare function createBridgeStartupError({ message, proc, stdoutTail, stderrTail, stderrDone
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
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
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
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
|
-
|
|
725
|
-
|
|
726
|
-
|
|
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
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
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 {
|
|
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
|