@ai-sdk/harness-codex 1.0.178 → 1.0.181

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.
@@ -24,7 +24,8 @@ import {
24
24
  import {
25
25
  applyCredentialForwarding,
26
26
  classifyDiskLog,
27
- createBridgeToken,
27
+ BRIDGE_AUTH_PUBLIC_KEY_ENV,
28
+ createBridgeAuthKeyPair,
28
29
  createBridgeWebSocketConnect,
29
30
  resolveSandboxCredentialEnvironment,
30
31
  createBridgeErrorHandler,
@@ -42,6 +43,7 @@ import {
42
43
  shellQuote,
43
44
  validateBridgeSandboxSettings,
44
45
  warnCredentialBrokeringUnavailable,
46
+ warnMintBridgeTokenIgnored,
45
47
  waitForBridgeReady,
46
48
  writeSkills,
47
49
  type SandboxChannelReconnectOptions,
@@ -150,9 +152,10 @@ export type CodexHarnessSettings = {
150
152
  * milliseconds up to 2 seconds.
151
153
  */
152
154
  readonly reconnect?: SandboxChannelReconnectOptions;
155
+ // TODO: Remove in the next major version.
153
156
  /**
154
- * Creates the authentication token used by the sandbox bridge. Defaults to
155
- * a random 32-byte hexadecimal token.
157
+ * @deprecated Sandbox bridge authentication now uses adapter-generated
158
+ * Ed25519 keys. This setting is ignored and emits a warning.
156
159
  */
157
160
  readonly mintBridgeToken?: HarnessV1MintBridgeTokenCallback;
158
161
  };
@@ -206,7 +209,7 @@ const CODEX_BUILTIN_TOOLS = {
206
209
  */
207
210
  const codexBridgeCoordsSchema = z.object({
208
211
  port: z.number(),
209
- token: z.string(),
212
+ privateKey: z.string(),
210
213
  lastSeenEventId: z.number(),
211
214
  sandboxId: z.string().optional(),
212
215
  });
@@ -231,6 +234,10 @@ type CodexBridgeCoords = z.infer<typeof codexBridgeCoordsSchema>;
231
234
  export function createCodex(
232
235
  settings: CodexHarnessSettings = {},
233
236
  ): HarnessV1<typeof CODEX_BUILTIN_TOOLS> {
237
+ warnMintBridgeTokenIgnored({
238
+ harnessId: 'codex',
239
+ mintBridgeToken: settings.mintBridgeToken,
240
+ });
234
241
  return {
235
242
  specificationVersion: 'harness-v1',
236
243
  harnessId: 'codex',
@@ -257,10 +264,8 @@ export function createCodex(
257
264
  const sandboxId = 'id' in sandboxSession ? sandboxSession.id : undefined;
258
265
  validateBridgeSandboxSettings({
259
266
  sandboxSession,
260
- sandboxId,
261
267
  portOverride: settings.port,
262
268
  portEndpointOverride: settings.portEndpoint,
263
- mintBridgeToken: settings.mintBridgeToken,
264
269
  });
265
270
  const lifecycleState = startOpts.continueFrom ?? startOpts.resumeFrom;
266
271
  const isResume = lifecycleState != null;
@@ -378,7 +383,7 @@ export function createCodex(
378
383
  * Rung 1 — ATTACH. With live coordinates, reopen a socket to the
379
384
  * still-running bridge. Parked between-turn sessions just attach and wait
380
385
  * for the next `start`; suspended in-flight turns request replay of
381
- * everything past the persisted cursor. No spawn, no fresh token. If the
386
+ * everything past the persisted cursor. No spawn, no fresh key. If the
382
387
  * bridge is gone the open throws and we fall through to a spawn-based
383
388
  * recovery.
384
389
  */
@@ -388,11 +393,11 @@ export function createCodex(
388
393
  sandboxSession,
389
394
  port: coords.port,
390
395
  portEndpointOverride: settings.portEndpoint,
391
- token: coords.token,
392
396
  });
393
397
  const attachChannel: CodexChannel = new SandboxChannel({
394
398
  connect: createBridgeWebSocketConnect({
395
399
  endpoint: attachEndpoint,
400
+ privateKey: coords.privateKey,
396
401
  webSocketConstructor: WebSocket,
397
402
  }),
398
403
  outboundSchema: outboundMessageSchema,
@@ -419,7 +424,7 @@ export function createCodex(
419
424
  seedResumeThreadOnFirstPrompt: false,
420
425
  rerunContinue: false,
421
426
  bridgePort: coords.port,
422
- bridgeToken: coords.token,
427
+ bridgePrivateKey: coords.privateKey,
423
428
  sandboxId,
424
429
  sandboxCredentialEnvironment,
425
430
  debug: startOpts.observability?.debug,
@@ -460,10 +465,7 @@ export function createCodex(
460
465
  sandboxSession,
461
466
  portOverride: settings.port,
462
467
  });
463
- const token =
464
- settings.mintBridgeToken == null
465
- ? createBridgeToken()
466
- : settings.mintBridgeToken(sandboxId!);
468
+ const bridgeAuth = createBridgeAuthKeyPair();
467
469
  const forwardedAuthEnvironment = credentialsBrokered
468
470
  ? sandboxAuthEnvironment
469
471
  : await applyCredentialForwarding({
@@ -483,7 +485,7 @@ export function createCodex(
483
485
  const env = {
484
486
  ...forwardedAuthEnvironment,
485
487
  AI_SDK_HARNESS_CLIENT_APP: CODEX_CLIENT_APP,
486
- BRIDGE_CHANNEL_TOKEN: token,
488
+ [BRIDGE_AUTH_PUBLIC_KEY_ENV]: bridgeAuth.publicKey,
487
489
  BRIDGE_WS_PORT: String(port),
488
490
  ...(respawnStrategy === 'replay'
489
491
  ? { BRIDGE_REPLAY_FROM_DISK: '1' }
@@ -547,12 +549,12 @@ export function createCodex(
547
549
  sandboxSession,
548
550
  port: boundPort,
549
551
  portEndpointOverride: settings.portEndpoint,
550
- token,
551
552
  });
552
553
 
553
554
  const channel: CodexChannel = new SandboxChannel({
554
555
  connect: createBridgeWebSocketConnect({
555
556
  endpoint: bridgeEndpoint,
557
+ privateKey: bridgeAuth.privateKey,
556
558
  webSocketConstructor: WebSocket,
557
559
  openRetryTimeoutMs: timeoutMs,
558
560
  startAbortSignal: startOpts.abortSignal,
@@ -588,7 +590,7 @@ export function createCodex(
588
590
  seedResumeThreadOnFirstPrompt: respawnStrategy !== undefined,
589
591
  rerunContinue: respawnStrategy === 'rerun',
590
592
  bridgePort: boundPort,
591
- bridgeToken: token,
593
+ bridgePrivateKey: bridgeAuth.privateKey,
592
594
  sandboxId,
593
595
  sandboxCredentialEnvironment,
594
596
  debug: startOpts.observability?.debug,
@@ -617,7 +619,7 @@ function createSession({
617
619
  seedResumeThreadOnFirstPrompt,
618
620
  rerunContinue,
619
621
  bridgePort,
620
- bridgeToken,
622
+ bridgePrivateKey,
621
623
  sandboxId,
622
624
  sandboxCredentialEnvironment,
623
625
  debug,
@@ -642,7 +644,7 @@ function createSession({
642
644
  seedResumeThreadOnFirstPrompt: boolean;
643
645
  rerunContinue: boolean;
644
646
  bridgePort: number;
645
- bridgeToken: string;
647
+ bridgePrivateKey: string;
646
648
  sandboxId: string | undefined;
647
649
  sandboxCredentialEnvironment: Record<string, string> | undefined;
648
650
  debug: HarnessV1DebugConfig | undefined;
@@ -1060,7 +1062,7 @@ function createSession({
1060
1062
  : { sandboxCredentialEnvironment }),
1061
1063
  bridge: {
1062
1064
  port: bridgePort,
1063
- token: bridgeToken,
1065
+ privateKey: bridgePrivateKey,
1064
1066
  lastSeenEventId,
1065
1067
  ...(sandboxId == null ? {} : { sandboxId }),
1066
1068
  },
@@ -1222,7 +1224,7 @@ function createSession({
1222
1224
  : { sandboxCredentialEnvironment }),
1223
1225
  bridge: {
1224
1226
  port: bridgePort,
1225
- token: bridgeToken,
1227
+ privateKey: bridgePrivateKey,
1226
1228
  lastSeenEventId,
1227
1229
  ...(sandboxId == null ? {} : { sandboxId }),
1228
1230
  },