@ai-sdk/harness 1.0.53 → 1.0.55

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.
@@ -0,0 +1,38 @@
1
+ import { AISDKError } from '@ai-sdk/provider';
2
+ import { HarnessError } from './harness-error';
3
+
4
+ const name = 'AI_HarnessSandboxAuthenticationError';
5
+ const marker = `vercel.ai.error.${name}`;
6
+ const symbol = Symbol.for(marker);
7
+
8
+ /**
9
+ * Thrown when a sandbox provider cannot authenticate or authorize the
10
+ * operation needed to create or resume a harness sandbox. Providers should
11
+ * preserve the underlying SDK failure as `cause` and supply a message that
12
+ * explains how the consumer can configure credentials.
13
+ */
14
+ export class HarnessSandboxAuthenticationError extends HarnessError {
15
+ private readonly [symbol] = true;
16
+
17
+ readonly sandboxProviderId: string;
18
+
19
+ constructor({
20
+ message,
21
+ sandboxProviderId,
22
+ cause,
23
+ }: {
24
+ message: string;
25
+ sandboxProviderId: string;
26
+ cause?: unknown;
27
+ }) {
28
+ super({ message, cause });
29
+ Object.defineProperty(this, 'name', { value: name });
30
+ this.sandboxProviderId = sandboxProviderId;
31
+ }
32
+
33
+ static isInstance(
34
+ error: unknown,
35
+ ): error is HarnessSandboxAuthenticationError {
36
+ return AISDKError.hasMarker(error, marker);
37
+ }
38
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './v1';
2
2
  export * from './errors/harness-error';
3
3
  export * from './errors/harness-capability-unsupported-error';
4
+ export * from './errors/harness-sandbox-authentication-error';
@@ -259,8 +259,8 @@ export class SandboxChannel<
259
259
  /**
260
260
  * Mark that the host is tearing the session down. The next socket close is
261
261
  * then treated as terminal rather than triggering a reconnect. Call before
262
- * sending a `shutdown` / `detach` message whose ack the bridge follows with a
263
- * socket close.
262
+ * sending a `stop` / `destroy` message whose completion closes the bridge
263
+ * socket.
264
264
  */
265
265
  beginClose(): void {
266
266
  this.closing = true;
@@ -16,12 +16,6 @@ export interface HarnessV1BootstrapFile {
16
16
  */
17
17
  export interface HarnessV1BootstrapCommand {
18
18
  readonly command: string;
19
- /**
20
- * Absolute working directories are used as-is. Relative working directories
21
- * are resolved against the sandbox's default working directory. When
22
- * omitted, the command runs from the recipe's bootstrap directory.
23
- */
24
- readonly workingDirectory?: string;
25
19
  }
26
20
 
27
21
  /**
@@ -39,7 +39,7 @@ import {
39
39
  * member schemas from `harness-v1-stream-part.ts`), because the part type is
40
40
  * compile-time only and the frames need runtime validation at the boundary.
41
41
  * 2. The transport/control frames that are NOT consumer events — `bridge-hello`
42
- * (handshake), `bridge-detach` (resume payload), `bridge-thread` (a resume
42
+ * (handshake), `bridge-stop` (runtime resume data), `bridge-thread` (a resume
43
43
  * coordinate some runtimes announce). These ride the same socket.
44
44
  * 3. The INBOUND command vocabulary the host sends back: the shared commands
45
45
  * live here; the per-adapter `start` payload extends
@@ -123,17 +123,17 @@ export const harnessV1BridgeHelloSchema = z.object({
123
123
  });
124
124
 
125
125
  /**
126
- * The bridge's reply to an inbound `detach`. Carries the adapter-specific
126
+ * The bridge's reply to an inbound `stop`. Carries the adapter-specific
127
127
  * payload the host serializes into lifecycle state `data`.
128
128
  */
129
- export const harnessV1BridgeDetachSchema = z.object({
130
- type: z.literal('bridge-detach'),
129
+ export const harnessV1BridgeStopSchema = z.object({
130
+ type: z.literal('bridge-stop'),
131
131
  data: z.unknown(),
132
132
  });
133
133
 
134
134
  /**
135
135
  * A resume coordinate the bridge proactively announces (e.g. Codex's thread id)
136
- * so the host can cache it for a later resume without waiting for `detach`.
136
+ * so the host can cache it for a later resume without waiting for `stop`.
137
137
  */
138
138
  export const harnessV1BridgeThreadSchema = z.object({
139
139
  type: z.literal('bridge-thread'),
@@ -198,7 +198,7 @@ export const harnessV1BridgeOutboundMessageSchema = z.discriminatedUnion(
198
198
  harnessV1ErrorPartSchema,
199
199
  harnessV1RawPartSchema,
200
200
  harnessV1BridgeHelloSchema,
201
- harnessV1BridgeDetachSchema,
201
+ harnessV1BridgeStopSchema,
202
202
  harnessV1BridgeThreadSchema,
203
203
  harnessV1BridgeSandboxLogSchema,
204
204
  harnessV1BridgeDebugEventSchema,
@@ -277,8 +277,8 @@ export const harnessV1BridgeAbortInboundSchema = z.object({
277
277
  type: z.literal('abort'),
278
278
  });
279
279
 
280
- export const harnessV1BridgeShutdownInboundSchema = z.object({
281
- type: z.literal('shutdown'),
280
+ export const harnessV1BridgeDestroyInboundSchema = z.object({
281
+ type: z.literal('destroy'),
282
282
  });
283
283
 
284
284
  /**
@@ -291,11 +291,11 @@ export const harnessV1BridgeResumeInboundSchema = z.object({
291
291
  });
292
292
 
293
293
  /**
294
- * The bridge replies with `bridge-detach` carrying any cached resume payload,
294
+ * The bridge replies with `bridge-stop` carrying any runtime resume data,
295
295
  * then exits.
296
296
  */
297
- export const harnessV1BridgeDetachInboundSchema = z.object({
298
- type: z.literal('detach'),
297
+ export const harnessV1BridgeStopInboundSchema = z.object({
298
+ type: z.literal('stop'),
299
299
  });
300
300
 
301
301
  /**
@@ -308,9 +308,9 @@ export const harnessV1BridgeInboundCommandSchemas = [
308
308
  harnessV1BridgeToolApprovalResponseInboundSchema,
309
309
  harnessV1BridgeUserMessageInboundSchema,
310
310
  harnessV1BridgeAbortInboundSchema,
311
- harnessV1BridgeShutdownInboundSchema,
311
+ harnessV1BridgeDestroyInboundSchema,
312
312
  harnessV1BridgeResumeInboundSchema,
313
- harnessV1BridgeDetachInboundSchema,
313
+ harnessV1BridgeStopInboundSchema,
314
314
  ] as const;
315
315
 
316
316
  /**
@@ -23,6 +23,12 @@ export interface HarnessV1SandboxProvider {
23
23
  */
24
24
  readonly bridgePorts?: ReadonlyArray<number>;
25
25
 
26
+ /**
27
+ * Providers should throw `HarnessSandboxAuthenticationError` when sandbox
28
+ * acquisition fails because credentials are missing, invalid, or not
29
+ * authorized. This lets framework integrations distinguish configuration
30
+ * failures from general sandbox infrastructure errors.
31
+ */
26
32
  readonly createSession: (options?: {
27
33
  /**
28
34
  * Stable per-session identifier. When supplied, the provider names the
package/src/v1/index.ts CHANGED
@@ -61,15 +61,15 @@ export {
61
61
  harnessV1BridgeAbortInboundSchema,
62
62
  harnessV1BridgeBuiltinToolFilteringSchema,
63
63
  harnessV1BridgeDebugEventSchema,
64
- harnessV1BridgeDetachInboundSchema,
65
- harnessV1BridgeDetachSchema,
64
+ harnessV1BridgeDestroyInboundSchema,
66
65
  harnessV1BridgeHelloSchema,
67
66
  harnessV1BridgeInboundCommandSchemas,
68
67
  harnessV1BridgeOutboundMessageSchema,
69
68
  harnessV1BridgeReadySchema,
70
69
  harnessV1BridgeResumeInboundSchema,
71
70
  harnessV1BridgeSandboxLogSchema,
72
- harnessV1BridgeShutdownInboundSchema,
71
+ harnessV1BridgeStopInboundSchema,
72
+ harnessV1BridgeStopSchema,
73
73
  harnessV1BridgeStartBaseSchema,
74
74
  harnessV1BridgeThreadSchema,
75
75
  harnessV1BridgeToolApprovalResponseInboundSchema,