borgmcp 4.3.0 → 4.4.0

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/src/index.ts CHANGED
@@ -172,6 +172,9 @@ import {
172
172
  runEvictDroneTool,
173
173
  runReassignDroneTool,
174
174
  } from './drone-management.js';
175
+
176
+ const OPEN_CODE_IDENTITY_HANDSHAKE_TIMEOUT_MS = 5_000;
177
+
175
178
  /**
176
179
  * Apply a template's roles + message_taxonomy to a cube.
177
180
  *
@@ -392,8 +395,25 @@ export async function main() {
392
395
 
393
396
  let openCodeIdentityFailure: OpenCodeSeatIdentityError | null = null;
394
397
  let finishOpenCodeIdentity: (() => void) | null = null;
398
+ let openCodeIdentityTimeout: ReturnType<typeof setTimeout> | null = null;
399
+ const settleOpenCodeIdentity = () => {
400
+ if (openCodeIdentityTimeout) clearTimeout(openCodeIdentityTimeout);
401
+ openCodeIdentityTimeout = null;
402
+ const finish = finishOpenCodeIdentity;
403
+ finishOpenCodeIdentity = null;
404
+ finish?.();
405
+ };
395
406
  const openCodeIdentityReady = openCodeRuntime && !readinessProbe
396
- ? new Promise<void>((resolveIdentity) => { finishOpenCodeIdentity = resolveIdentity; })
407
+ ? new Promise<void>((resolveIdentity) => {
408
+ finishOpenCodeIdentity = resolveIdentity;
409
+ openCodeIdentityTimeout = setTimeout(() => {
410
+ openCodeIdentityFailure = new OpenCodeSeatIdentityError(
411
+ 'IDENTITY_HANDSHAKE_TIMEOUT',
412
+ 'OpenCode identity handshake did not complete within 5 seconds.',
413
+ );
414
+ settleOpenCodeIdentity();
415
+ }, OPEN_CODE_IDENTITY_HANDSHAKE_TIMEOUT_MS);
416
+ })
397
417
  : null;
398
418
  const waitForOpenCodeIdentity = async (): Promise<OpenCodeSeatIdentityError | null> => {
399
419
  if (openCodeIdentityReady) await openCodeIdentityReady;
@@ -1663,7 +1683,7 @@ export async function main() {
1663
1683
  ? error
1664
1684
  : new OpenCodeSeatIdentityError('ROOTS_UNAVAILABLE', String(error));
1665
1685
  }).finally(() => {
1666
- finishOpenCodeIdentity?.();
1686
+ settleOpenCodeIdentity();
1667
1687
  });
1668
1688
  };
1669
1689
  }
@@ -1674,7 +1694,7 @@ export async function main() {
1674
1694
  if (openCodeIdentityReady) {
1675
1695
  await openCodeIdentityReady;
1676
1696
  if (openCodeIdentityFailure) {
1677
- console.error(formatOpenCodeSeatIdentityError(openCodeIdentityFailure, process.cwd()));
1697
+ throw new Error(formatOpenCodeSeatIdentityError(openCodeIdentityFailure, process.cwd()));
1678
1698
  } else {
1679
1699
  await runMcpStartupServices(false, startupServices, { openCodeFirst: true });
1680
1700
  }