@ai-sdk/harness-opencode 1.0.119 → 1.0.121

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.
@@ -5,8 +5,8 @@
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "@modelcontextprotocol/sdk": "1.29.0",
8
- "@opencode-ai/sdk": "1.18.23",
9
- "opencode-ai": "1.18.23",
8
+ "@opencode-ai/sdk": "1.18.31",
9
+ "opencode-ai": "1.18.31",
10
10
  "ws": "8.21.0",
11
11
  "zod": "3.25.76"
12
12
  }
@@ -12,11 +12,11 @@ importers:
12
12
  specifier: 1.29.0
13
13
  version: 1.29.0(zod@3.25.76)
14
14
  '@opencode-ai/sdk':
15
- specifier: 1.18.23
16
- version: 1.18.23
15
+ specifier: 1.18.31
16
+ version: 1.18.31
17
17
  opencode-ai:
18
- specifier: 1.18.23
19
- version: 1.18.23
18
+ specifier: 1.18.31
19
+ version: 1.18.31
20
20
  ws:
21
21
  specifier: 8.21.0
22
22
  version: 8.21.0
@@ -42,8 +42,8 @@ packages:
42
42
  '@cfworker/json-schema':
43
43
  optional: true
44
44
 
45
- '@opencode-ai/sdk@1.18.23':
46
- resolution: {integrity: sha512-VouYbL8O2ynLq0atr5fjzCv8YLtFi/zKLQ/uYkCvTJ4CmUdA01XwPn8om+u3TvxnGEfQsBfmThGU141vt3sg5w==}
45
+ '@opencode-ai/sdk@1.18.31':
46
+ resolution: {integrity: sha512-Raouthf8Lhe9edjvYeeSK7SgvdoU6bBjH9qV3f70dHoa6h+z0X2TMz/e22/wKp/StlFUZ4kIRpYYxFnY8/k01w==}
47
47
 
48
48
  accepts@2.0.0:
49
49
  resolution: {integrity: sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==}
@@ -286,72 +286,72 @@ packages:
286
286
  once@1.4.0:
287
287
  resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
288
288
 
289
- opencode-ai@1.18.23:
290
- resolution: {integrity: sha512-3NkT0XINL7d0HYkTyGV1SPChHXhvRgKqNaTgKRTGb0TXUWszXA7MW/y3zMZw29y1AQuUDAzRvVYmQ9KGRQhroA==}
289
+ opencode-ai@1.18.31:
290
+ resolution: {integrity: sha512-J95feefeWwtIaw3irx76WjzWcgQXxmuHmDVphvs5ep9X30fBJ6T6bFhw50i9Kx50MG/xPn5w2pafXIfNtdry9w==}
291
291
  cpu: [arm64, x64]
292
292
  os: [darwin, linux, win32]
293
293
  hasBin: true
294
294
 
295
- opencode-darwin-arm64@1.18.23:
296
- resolution: {integrity: sha512-QP9PjwpHtZoLVXw2WvUmPZecz7mWbQkT4t3K36B//fCaDG+zWa+SsztIeaW5azujNwwtUemLA5icE/zINng48Q==}
295
+ opencode-darwin-arm64@1.18.31:
296
+ resolution: {integrity: sha512-IN642oFENleWVDNqMnXi8NQLsZnA8hMswJ6X+GWz+CfBFuCpotjDb5OHgE2HBdC6r5wjG6v0mATb+Mn8xXCp1A==}
297
297
  cpu: [arm64]
298
298
  os: [darwin]
299
299
 
300
- opencode-darwin-x64-baseline@1.18.23:
301
- resolution: {integrity: sha512-QGx6I/nFYur7qJ/Nx2L3fC4XYQt44cyDsm7p8twNA+cdjGX3ndnPbMdAl5ikdZyAfSMUGYK8VWY2JMxv0rmfjw==}
300
+ opencode-darwin-x64-baseline@1.18.31:
301
+ resolution: {integrity: sha512-4/4UMyPhsIeHln3AT3bxBvrWC+cmbOcdGOeBfoeOQIWcNZ3ycSvFnoJdLX969p9CtR6oNtroaQoNKZHgzSqg6A==}
302
302
  cpu: [x64]
303
303
  os: [darwin]
304
304
 
305
- opencode-darwin-x64@1.18.23:
306
- resolution: {integrity: sha512-R9nWP3edz/0FnEfwmuxtiWBB7bS4NtZCyCffJyiMlrbwdDC+bIXYrWxWXVrzaP1mJujs6g2MAwTCUSx/qpBhDw==}
305
+ opencode-darwin-x64@1.18.31:
306
+ resolution: {integrity: sha512-xrw512dou9Drxs/1yH4CHEt/kvrSl8j1Ulez0wTOsW0lWZaATJMnlfHBjagWzv+QWIC4nz/cBgYzjn3JvxS7zQ==}
307
307
  cpu: [x64]
308
308
  os: [darwin]
309
309
 
310
- opencode-linux-arm64-musl@1.18.23:
311
- resolution: {integrity: sha512-VyDkzUJfJgkx9h9RhazTW9xeTgSXBmVFPblsbPGBW9tR612f6gjQxfOfu4cpHnQHK1qjuW9ClzLKHWqv3EcJTA==}
310
+ opencode-linux-arm64-musl@1.18.31:
311
+ resolution: {integrity: sha512-qeEg7HsYupDeLkFqr+QNIgcE4kVRPycb/7ymyYUffSg+z2A6fU065pvU6uaZ+LjIzdJaZHUe1wDQvrSP/EJAqg==}
312
312
  cpu: [arm64]
313
313
  os: [linux]
314
314
  libc: [musl]
315
315
 
316
- opencode-linux-arm64@1.18.23:
317
- resolution: {integrity: sha512-g1zDFhuE9FOYwjSGderlu69wfd4GQzS0xsDiIY11QUciuBmM6DrHqLvmhlLFsUVHYVnCPY1YeN1pq5ewE3x72Q==}
316
+ opencode-linux-arm64@1.18.31:
317
+ resolution: {integrity: sha512-tLTZlOeWz4u48WQWg7PhKTn4gIXPHf7xaiWSHcmci1O3qKXEDLv/TaMzmqIuMChdwtflu2PSNIC00W+Hij/IkA==}
318
318
  cpu: [arm64]
319
319
  os: [linux]
320
320
 
321
- opencode-linux-x64-baseline-musl@1.18.23:
322
- resolution: {integrity: sha512-c1DPxauhzAurlIBhJBr/rokDpc65l084T4qTl36gDDT9Xzc/Nk5Q5yMDaPm1DDI3WeHKDt11MDlxT5AjQW5gtw==}
321
+ opencode-linux-x64-baseline-musl@1.18.31:
322
+ resolution: {integrity: sha512-gZ9TkeoIkckNZjDRreHj0sQk91uRQTgeuMCIZgSKewHN1fq/jjQHMzSAI0HevPEov9O2cDRRzPBF4cppzc+AYg==}
323
323
  cpu: [x64]
324
324
  os: [linux]
325
325
  libc: [musl]
326
326
 
327
- opencode-linux-x64-baseline@1.18.23:
328
- resolution: {integrity: sha512-yUhBOXfTQour2JCdAkwD3DDqSnyxB0grefwdPqEhYmJHIkYxfJIIzyy6V//pyouvkE0XMouFtiuZXw8S6Wo0iQ==}
327
+ opencode-linux-x64-baseline@1.18.31:
328
+ resolution: {integrity: sha512-T/hyCHb7gSCuJzLDXs8YfEhjelUes2zkWFPTGEdBPqV/eKrKbEo9U1YdA/WvntjXv0I6k+blZEID54QIcF7Djw==}
329
329
  cpu: [x64]
330
330
  os: [linux]
331
331
 
332
- opencode-linux-x64-musl@1.18.23:
333
- resolution: {integrity: sha512-t/5mlnTBZKdZpqKHwdwxlWqGakntauvMSmXtyJc17M7XJRmZaaGHtNSaSefbbYFIL4agoQCXTvIkhhyxOvr7zQ==}
332
+ opencode-linux-x64-musl@1.18.31:
333
+ resolution: {integrity: sha512-TxKfcJII53MZ17NSrJ0p51wx0dJtZrX8By60N5O5/M+eP0oO4jCXKIkdBpP/Bku44gm8QZkTNLBWpPc2OTJweg==}
334
334
  cpu: [x64]
335
335
  os: [linux]
336
336
  libc: [musl]
337
337
 
338
- opencode-linux-x64@1.18.23:
339
- resolution: {integrity: sha512-5x9d1Cm/YtqzR6lAlNbgVprTQ3R3hx7qGTWCzm5l5u6lBNkhYTrhy2s8k25dxKKuxqZ9Kngqz9JYWvSVHy2Lmw==}
338
+ opencode-linux-x64@1.18.31:
339
+ resolution: {integrity: sha512-gTJ5nGNq+KJblwmeusEdz8YFwvkV7a3xTOV9EKKEmsv0Lkbajq/oQO9jEC0sMiS66mjHDOrhLgIUxSVqfLBM8g==}
340
340
  cpu: [x64]
341
341
  os: [linux]
342
342
 
343
- opencode-windows-arm64@1.18.23:
344
- resolution: {integrity: sha512-QtJQcLU0yPz6on3jjks3f/EHgZuIDFw7FvAKu3wsHhL09NYDh7GczfRXDPRHa3NgqnU8dkB8p9mhqgaPRPogoQ==}
343
+ opencode-windows-arm64@1.18.31:
344
+ resolution: {integrity: sha512-K+Dh5r5yLQJ6Maeo1+JhQr27Un6lzUIWEp3LGoeXSfLkcSqi7ueTecGbg7HAbtEIY5a9j3yNCS3//AjgTcZa+w==}
345
345
  cpu: [arm64]
346
346
  os: [win32]
347
347
 
348
- opencode-windows-x64-baseline@1.18.23:
349
- resolution: {integrity: sha512-AqXsTKaPcDx3rrid5bLUwJbQ/3vr9rJ6fvOStIznTzwrbOgP8wy5G4jCoIzu6KB/WxGx/d1MrV4cGaJ73qnjBA==}
348
+ opencode-windows-x64-baseline@1.18.31:
349
+ resolution: {integrity: sha512-wz5K8SpL+GTKez4BpYX1AbhRwBY7AVt+95ijWZrow84ibLTDoZ1skEsN5UUcQJ8LYeC+o1Vq0xi4A5kLGfvQ0w==}
350
350
  cpu: [x64]
351
351
  os: [win32]
352
352
 
353
- opencode-windows-x64@1.18.23:
354
- resolution: {integrity: sha512-mMaIITuXzkNfjdcYL8uZaZuMDjulFyH/UCq9bxblam2mUZf9uWisoi5J6CXFsS/mkN7CZfTAt6PttSp4n3PH4g==}
353
+ opencode-windows-x64@1.18.31:
354
+ resolution: {integrity: sha512-1Za7uKeGLonNUkUIGHD7xfV5omi7ju/7z2WYfS5YvDLTr1iU/W1PPVHzHXiwiyV4gMxsWGwHHLubWdH99D7pSA==}
355
355
  cpu: [x64]
356
356
  os: [win32]
357
357
 
@@ -508,7 +508,7 @@ snapshots:
508
508
  transitivePeerDependencies:
509
509
  - supports-color
510
510
 
511
- '@opencode-ai/sdk@1.18.23':
511
+ '@opencode-ai/sdk@1.18.31':
512
512
  dependencies:
513
513
  cross-spawn: 7.0.6
514
514
 
@@ -752,55 +752,55 @@ snapshots:
752
752
  dependencies:
753
753
  wrappy: 1.0.2
754
754
 
755
- opencode-ai@1.18.23:
755
+ opencode-ai@1.18.31:
756
756
  optionalDependencies:
757
- opencode-darwin-arm64: 1.18.23
758
- opencode-darwin-x64: 1.18.23
759
- opencode-darwin-x64-baseline: 1.18.23
760
- opencode-linux-arm64: 1.18.23
761
- opencode-linux-arm64-musl: 1.18.23
762
- opencode-linux-x64: 1.18.23
763
- opencode-linux-x64-baseline: 1.18.23
764
- opencode-linux-x64-baseline-musl: 1.18.23
765
- opencode-linux-x64-musl: 1.18.23
766
- opencode-windows-arm64: 1.18.23
767
- opencode-windows-x64: 1.18.23
768
- opencode-windows-x64-baseline: 1.18.23
769
-
770
- opencode-darwin-arm64@1.18.23:
757
+ opencode-darwin-arm64: 1.18.31
758
+ opencode-darwin-x64: 1.18.31
759
+ opencode-darwin-x64-baseline: 1.18.31
760
+ opencode-linux-arm64: 1.18.31
761
+ opencode-linux-arm64-musl: 1.18.31
762
+ opencode-linux-x64: 1.18.31
763
+ opencode-linux-x64-baseline: 1.18.31
764
+ opencode-linux-x64-baseline-musl: 1.18.31
765
+ opencode-linux-x64-musl: 1.18.31
766
+ opencode-windows-arm64: 1.18.31
767
+ opencode-windows-x64: 1.18.31
768
+ opencode-windows-x64-baseline: 1.18.31
769
+
770
+ opencode-darwin-arm64@1.18.31:
771
771
  optional: true
772
772
 
773
- opencode-darwin-x64-baseline@1.18.23:
773
+ opencode-darwin-x64-baseline@1.18.31:
774
774
  optional: true
775
775
 
776
- opencode-darwin-x64@1.18.23:
776
+ opencode-darwin-x64@1.18.31:
777
777
  optional: true
778
778
 
779
- opencode-linux-arm64-musl@1.18.23:
779
+ opencode-linux-arm64-musl@1.18.31:
780
780
  optional: true
781
781
 
782
- opencode-linux-arm64@1.18.23:
782
+ opencode-linux-arm64@1.18.31:
783
783
  optional: true
784
784
 
785
- opencode-linux-x64-baseline-musl@1.18.23:
785
+ opencode-linux-x64-baseline-musl@1.18.31:
786
786
  optional: true
787
787
 
788
- opencode-linux-x64-baseline@1.18.23:
788
+ opencode-linux-x64-baseline@1.18.31:
789
789
  optional: true
790
790
 
791
- opencode-linux-x64-musl@1.18.23:
791
+ opencode-linux-x64-musl@1.18.31:
792
792
  optional: true
793
793
 
794
- opencode-linux-x64@1.18.23:
794
+ opencode-linux-x64@1.18.31:
795
795
  optional: true
796
796
 
797
- opencode-windows-arm64@1.18.23:
797
+ opencode-windows-arm64@1.18.31:
798
798
  optional: true
799
799
 
800
- opencode-windows-x64-baseline@1.18.23:
800
+ opencode-windows-x64-baseline@1.18.31:
801
801
  optional: true
802
802
 
803
- opencode-windows-x64@1.18.23:
803
+ opencode-windows-x64@1.18.31:
804
804
  optional: true
805
805
 
806
806
  parseurl@1.3.3: {}
@@ -1,2 +1,2 @@
1
1
  allowBuilds:
2
- 'opencode-ai@1.18.23': true
2
+ 'opencode-ai@1.18.31': true
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { HarnessV1Authentication, HarnessV1CredentialForwarding, HarnessV1PortEn
3
3
  import * as _ai_sdk_provider from '@ai-sdk/provider';
4
4
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
5
5
  import { Experimental_SandboxSession } from '@ai-sdk/provider-utils';
6
+ import { SandboxChannelReconnectOptions } from '@ai-sdk/harness/utils';
6
7
 
7
8
  type OpenCodeAuthenticationMode = HarnessV1Authentication<'anthropic' | 'openai'>;
8
9
 
@@ -39,6 +40,13 @@ type OpenCodeHarnessSettings = {
39
40
  */
40
41
  readonly portEndpoint?: HarnessV1PortEndpoint;
41
42
  readonly startupTimeoutMs?: number;
43
+ /**
44
+ * Configures reconnection attempts after an established bridge connection
45
+ * drops. The reconnect window includes connection establishment and
46
+ * backoff delays. Defaults to 30 seconds with exponential backoff from 50
47
+ * milliseconds up to 2 seconds.
48
+ */
49
+ readonly reconnect?: SandboxChannelReconnectOptions;
42
50
  /**
43
51
  * Creates the authentication token used by the sandbox bridge. Defaults to
44
52
  * a random 32-byte hexadecimal token.
package/dist/index.js CHANGED
@@ -909,7 +909,7 @@ var inboundMessageSchema = z.discriminatedUnion("type", [
909
909
  ]);
910
910
 
911
911
  // src/version.ts
912
- var VERSION = true ? "1.0.119" : "0.0.0-test";
912
+ var VERSION = true ? "1.0.121" : "0.0.0-test";
913
913
 
914
914
  // src/opencode-harness.ts
915
915
  var OPENCODE_CLIENT_APP = `ai-sdk/harness-opencode/${VERSION}`;
@@ -1166,9 +1166,10 @@ function createOpenCode(settings = {}) {
1166
1166
  });
1167
1167
  let supportsUserMessageResponses2 = false;
1168
1168
  const attachChannel = new SandboxChannel({
1169
- connect: () => openWebSocket({
1169
+ connect: ({ abortSignal }) => openWebSocket({
1170
1170
  endpoint: attachEndpoint,
1171
1171
  helloTimeoutMs: Math.min(timeoutMs, 5e3),
1172
+ abortSignal,
1172
1173
  onHello: (supported) => {
1173
1174
  supportsUserMessageResponses2 = supported;
1174
1175
  }
@@ -1176,7 +1177,8 @@ function createOpenCode(settings = {}) {
1176
1177
  outboundSchema: outboundMessageSchema,
1177
1178
  initialLastSeenEventId: coords.lastSeenEventId,
1178
1179
  onDiagnostic,
1179
- onBridgeError
1180
+ onBridgeError,
1181
+ reconnect: settings.reconnect
1180
1182
  });
1181
1183
  await attachChannel.open(isContinue ? { resume: true } : void 0);
1182
1184
  return createSession({
@@ -1310,9 +1312,10 @@ function createOpenCode(settings = {}) {
1310
1312
  const bridgeEndpoint = withBridgeToken({ endpoint, token });
1311
1313
  let supportsUserMessageResponses = false;
1312
1314
  const channel = new SandboxChannel({
1313
- connect: () => openWebSocket({
1315
+ connect: ({ abortSignal }) => openWebSocket({
1314
1316
  endpoint: bridgeEndpoint,
1315
1317
  helloTimeoutMs: Math.min(timeoutMs, 5e3),
1318
+ abortSignal,
1316
1319
  onHello: (supported) => {
1317
1320
  supportsUserMessageResponses = supported;
1318
1321
  }
@@ -1320,6 +1323,7 @@ function createOpenCode(settings = {}) {
1320
1323
  outboundSchema: outboundMessageSchema,
1321
1324
  onDiagnostic,
1322
1325
  onBridgeError,
1326
+ reconnect: settings.reconnect,
1323
1327
  ...respawnStrategy === "replay" ? { initialLastSeenEventId: coords?.lastSeenEventId ?? 0 } : {}
1324
1328
  });
1325
1329
  await channel.open(
@@ -1402,21 +1406,32 @@ async function resolveBridgeEndpoint({
1402
1406
  function openWebSocket({
1403
1407
  endpoint,
1404
1408
  helloTimeoutMs,
1409
+ abortSignal,
1405
1410
  onHello
1406
1411
  }) {
1407
1412
  return new Promise((resolve, reject) => {
1413
+ const abortReason = () => abortSignal.reason ?? new Error("WebSocket connection aborted");
1414
+ if (abortSignal.aborted) {
1415
+ reject(abortReason());
1416
+ return;
1417
+ }
1408
1418
  const ws = new WebSocket(endpoint.url, {
1409
1419
  headers: endpoint.headers == null ? void 0 : { ...endpoint.headers }
1410
1420
  });
1411
1421
  let opened = false;
1412
1422
  let receivedHello = false;
1413
1423
  let settled = false;
1424
+ let helloTimer;
1425
+ let onAbort;
1414
1426
  const cleanup = () => {
1415
1427
  clearTimeout(helloTimer);
1416
1428
  ws.off("open", onOpen);
1417
1429
  ws.off("message", onMessage);
1418
1430
  ws.off("close", onClose);
1419
1431
  ws.off("error", onError);
1432
+ if (onAbort != null) {
1433
+ abortSignal.removeEventListener("abort", onAbort);
1434
+ }
1420
1435
  };
1421
1436
  const settle = (error) => {
1422
1437
  if (settled) return;
@@ -1425,6 +1440,18 @@ function openWebSocket({
1425
1440
  if (error == null) {
1426
1441
  resolve(ws);
1427
1442
  } else {
1443
+ const suppressError = () => {
1444
+ };
1445
+ const socketWithOnce = ws;
1446
+ socketWithOnce.once?.("error", suppressError);
1447
+ try {
1448
+ ws.terminate();
1449
+ } catch {
1450
+ try {
1451
+ ws.close();
1452
+ } catch {
1453
+ }
1454
+ }
1428
1455
  reject(error);
1429
1456
  }
1430
1457
  };
@@ -1455,11 +1482,17 @@ function openWebSocket({
1455
1482
  const onError = (err) => {
1456
1483
  settle(err);
1457
1484
  };
1485
+ onAbort = () => settle(abortReason());
1458
1486
  ws.on("open", onOpen);
1459
1487
  ws.on("message", onMessage);
1460
1488
  ws.on("close", onClose);
1461
1489
  ws.on("error", onError);
1462
- const helloTimer = setTimeout(
1490
+ abortSignal.addEventListener("abort", onAbort, { once: true });
1491
+ if (abortSignal.aborted) {
1492
+ onAbort();
1493
+ return;
1494
+ }
1495
+ helloTimer = setTimeout(
1463
1496
  () => settle(
1464
1497
  new Error(
1465
1498
  `OpenCode bridge did not send bridge-hello within ${helloTimeoutMs}ms.`