@haven_ai/connect 0.1.16-alpha.0 → 0.1.17-alpha.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/dist/cli.js CHANGED
@@ -230,9 +230,9 @@ var MCP_RUNTIME_MANIFEST = {
230
230
  mcpPackage: "@haven_ai/mcp",
231
231
  mcpVersion: MCP_VERSION,
232
232
  sdkPackage: "@haven_ai/sdk",
233
- sdkVersion: "0.1.16-alpha.0",
233
+ sdkVersion: "0.1.17-alpha.0",
234
234
  signerPackage: "@haven_ai/signer",
235
- signerVersion: "0.1.16-alpha.0",
235
+ signerVersion: "0.1.17-alpha.0",
236
236
  minimumNodeVersion: "20.0.0",
237
237
  supportedClients: ["codex-cli", "codex-desktop", "claude-code"],
238
238
  requiredTools: registeredToolNames()
@@ -247,117 +247,6 @@ function signerPackageSpec() {
247
247
  return `${MCP_RUNTIME_MANIFEST.signerPackage}@${MCP_RUNTIME_MANIFEST.signerVersion}`;
248
248
  }
249
249
 
250
- // src/runtime-registry.ts
251
- var RUNTIME_PROFILES = {
252
- "claude-code": {
253
- id: "claude-code",
254
- label: "Claude Code",
255
- restartMode: "restart-session",
256
- canWriteRuntimeConfig: true
257
- },
258
- "codex-cli": {
259
- id: "codex-cli",
260
- label: "Codex CLI",
261
- restartMode: "restart-session",
262
- canWriteRuntimeConfig: true
263
- },
264
- "codex-desktop": {
265
- id: "codex-desktop",
266
- label: "Codex Desktop",
267
- restartMode: "restart-session",
268
- canWriteRuntimeConfig: true
269
- },
270
- cursor: {
271
- id: "cursor",
272
- label: "Cursor",
273
- restartMode: "hot-reload",
274
- canWriteRuntimeConfig: true
275
- },
276
- vscode: {
277
- id: "vscode",
278
- label: "VS Code",
279
- restartMode: "hot-reload",
280
- canWriteRuntimeConfig: true
281
- },
282
- "vscode-insiders": {
283
- id: "vscode-insiders",
284
- label: "VS Code Insiders",
285
- restartMode: "hot-reload",
286
- canWriteRuntimeConfig: true
287
- },
288
- "claude-desktop": {
289
- id: "claude-desktop",
290
- label: "Claude Desktop",
291
- restartMode: "restart-app",
292
- canWriteRuntimeConfig: true
293
- },
294
- other: {
295
- id: "other",
296
- label: "Other agent runtime",
297
- restartMode: "manual",
298
- canWriteRuntimeConfig: false
299
- }
300
- };
301
- var RUNTIME_ALIASES = {
302
- claude: "claude-code",
303
- "claude-code": "claude-code",
304
- claudecode: "claude-code",
305
- "claude_code": "claude-code",
306
- codex: "codex-cli",
307
- "codex-cli": "codex-cli",
308
- codexcli: "codex-cli",
309
- "codex_cli": "codex-cli",
310
- "codex-desktop": "codex-desktop",
311
- "codex_desktop": "codex-desktop",
312
- codexdesktop: "codex-desktop",
313
- "codex-app": "codex-desktop",
314
- "codex_app": "codex-desktop",
315
- codexapp: "codex-desktop",
316
- cursor: "cursor",
317
- vscode: "vscode",
318
- "vs-code": "vscode",
319
- "vs_code": "vscode",
320
- code: "vscode",
321
- "vscode-insiders": "vscode-insiders",
322
- "vscode_insiders": "vscode-insiders",
323
- vscodeinsiders: "vscode-insiders",
324
- "vs-code-insiders": "vscode-insiders",
325
- "code-insiders": "vscode-insiders",
326
- insiders: "vscode-insiders",
327
- "claude-desktop": "claude-desktop",
328
- "claude_desktop": "claude-desktop",
329
- claudesktop: "claude-desktop",
330
- desktop: "claude-desktop",
331
- other: "other",
332
- manual: "other"
333
- };
334
- function runtimeProfile(runtime, env = process.env) {
335
- return RUNTIME_PROFILES[normalizeRuntime(runtime, env)];
336
- }
337
- function normalizeRuntime(runtime, env = process.env) {
338
- const explicit = normalizeRuntimeName(runtime);
339
- if (explicit) return explicit;
340
- return detectRuntime(env) ?? "other";
341
- }
342
- function restartRequiredForRuntime(runtime, env = process.env) {
343
- const mode = runtimeProfile(runtime, env).restartMode;
344
- return mode === "restart-session" || mode === "restart-app";
345
- }
346
- function runtimeRequiresHardRestart(runtime) {
347
- return runtime === "claude-desktop" || runtime === "codex-desktop";
348
- }
349
- function normalizeRuntimeName(runtime) {
350
- const key = runtime?.trim().toLowerCase();
351
- if (!key) return null;
352
- return RUNTIME_ALIASES[key.replace(/\s+/g, "-")] ?? null;
353
- }
354
- function detectRuntime(env) {
355
- if (env.CLAUDECODE || env.CLAUDE_CODE || env.CLAUDECODE_CWD) return "claude-code";
356
- if (env.CODEX_SANDBOX || env.CODEX_HOME || env.CODEX_CWD) return "codex-cli";
357
- if (env.VSCODE_CWD || env.VSCODE_IPC_HOOK_CLI || env.TERM_PROGRAM === "vscode") return "vscode";
358
- return null;
359
- }
360
-
361
250
  // src/config-writers.ts
362
251
  var InvalidCodexTomlError = class extends Error {
363
252
  constructor(message) {
@@ -504,7 +393,6 @@ async function writeJsonRuntimeConfig(input, target, serverRoot) {
504
393
  async function writeCodexConfig(input) {
505
394
  const target = codexConfigPath(input.homeDir);
506
395
  const local = input.mode === "local";
507
- const restartMessage = runtimeRequiresHardRestart(input.runtime) ? "After Haven approval, restart Codex Desktop so it can load Haven tools." : "After Haven approval, Haven tools should appear in your next Codex message. If they don't, restart Codex to load them.";
508
396
  try {
509
397
  const existing = await readOptional(target);
510
398
  if (local) {
@@ -522,11 +410,7 @@ async function writeCodexConfig(input) {
522
410
  changed: existing !== merged2,
523
411
  restartRequired: true,
524
412
  messages: [
525
- `Updated local Haven MCP entry in ${configTargetLabel(input.runtime)}.`,
526
- // Codex Desktop loads MCP servers at app launch; Codex CLI typically
527
- // picks them up in the next session. Branch the copy so desktop users
528
- // get the unambiguous instruction.
529
- restartMessage
413
+ `Updated local Haven MCP entry in ${configTargetLabel(input.runtime)}.`
530
414
  ]
531
415
  };
532
416
  }
@@ -541,8 +425,7 @@ async function writeCodexConfig(input) {
541
425
  changed: existing !== merged,
542
426
  restartRequired: true,
543
427
  messages: [
544
- `Updated Haven MCP entries in ${configTargetLabel(input.runtime)}.`,
545
- restartMessage
428
+ `Updated Haven MCP entries in ${configTargetLabel(input.runtime)}.`
546
429
  ]
547
430
  };
548
431
  } catch (err) {
@@ -1095,23 +978,29 @@ function parseNodeVersion(value) {
1095
978
  ];
1096
979
  }
1097
980
  async function installRuntimePackages(runtimeDirectory, npmCacheDirectory, runCommand) {
1098
- const args = [
981
+ const baseArgs = [
1099
982
  "install",
1100
983
  "--prefix",
1101
984
  runtimeDirectory,
1102
- "--cache",
1103
- npmCacheDirectory,
1104
985
  "--no-audit",
1105
986
  "--no-fund",
1106
987
  "--omit=dev",
988
+ "--prefer-offline",
1107
989
  mcpPackageSpec(),
1108
990
  sdkPackageSpec()
1109
991
  ];
1110
- try {
992
+ const run = async (args) => {
1111
993
  if (runCommand) await runCommand("npm", args);
1112
994
  else await execFileAsync("npm", args, { timeout: 12e4, maxBuffer: 1024 * 1024 });
1113
- } catch (err) {
1114
- throw new Error(`Could not install local Haven MCP runtime ${mcpPackageSpec()}: ${err instanceof Error ? err.message : String(err)}`);
995
+ };
996
+ try {
997
+ await run(baseArgs);
998
+ } catch {
999
+ try {
1000
+ await run([...baseArgs, "--cache", npmCacheDirectory]);
1001
+ } catch (err) {
1002
+ throw new Error(`Could not install local Haven MCP runtime ${mcpPackageSpec()}: ${err instanceof Error ? err.message : String(err)}`);
1003
+ }
1115
1004
  }
1116
1005
  }
1117
1006
  async function installedRuntimeMatches(runtimeDirectory, cliPath) {
@@ -1215,25 +1104,31 @@ async function prepareSignerRuntime(input, deps = {}) {
1215
1104
  };
1216
1105
  }
1217
1106
  async function installRuntimePackages2(runtimeDirectory, npmCacheDirectory, runCommand) {
1218
- const args = [
1107
+ const baseArgs = [
1219
1108
  "install",
1220
1109
  "--prefix",
1221
1110
  runtimeDirectory,
1222
- "--cache",
1223
- npmCacheDirectory,
1224
1111
  "--no-audit",
1225
1112
  "--no-fund",
1226
1113
  "--omit=dev",
1114
+ "--prefer-offline",
1227
1115
  signerPackageSpec(),
1228
1116
  sdkPackageSpec()
1229
1117
  ];
1230
- try {
1118
+ const run = async (args) => {
1231
1119
  if (runCommand) await runCommand("npm", args);
1232
1120
  else await execFileAsync2("npm", args, { timeout: 12e4, maxBuffer: 1024 * 1024 });
1233
- } catch (err) {
1234
- throw new Error(
1235
- `Could not install local Haven signer runtime ${signerPackageSpec()}: ${err instanceof Error ? err.message : String(err)}`
1236
- );
1121
+ };
1122
+ try {
1123
+ await run(baseArgs);
1124
+ } catch {
1125
+ try {
1126
+ await run([...baseArgs, "--cache", npmCacheDirectory]);
1127
+ } catch (err) {
1128
+ throw new Error(
1129
+ `Could not install local Haven signer runtime ${signerPackageSpec()}: ${err instanceof Error ? err.message : String(err)}`
1130
+ );
1131
+ }
1237
1132
  }
1238
1133
  }
1239
1134
  async function installedRuntimeMatches2(runtimeDirectory, cliPath) {
@@ -1296,6 +1191,117 @@ async function assertFileExists2(path, label) {
1296
1191
  throw new Error(`Missing ${label}: ${path}`);
1297
1192
  }
1298
1193
  }
1194
+
1195
+ // src/runtime-registry.ts
1196
+ var RUNTIME_PROFILES = {
1197
+ "claude-code": {
1198
+ id: "claude-code",
1199
+ label: "Claude Code",
1200
+ restartMode: "restart-session",
1201
+ canWriteRuntimeConfig: true
1202
+ },
1203
+ "codex-cli": {
1204
+ id: "codex-cli",
1205
+ label: "Codex CLI",
1206
+ restartMode: "restart-session",
1207
+ canWriteRuntimeConfig: true
1208
+ },
1209
+ "codex-desktop": {
1210
+ id: "codex-desktop",
1211
+ label: "Codex Desktop",
1212
+ restartMode: "restart-session",
1213
+ canWriteRuntimeConfig: true
1214
+ },
1215
+ cursor: {
1216
+ id: "cursor",
1217
+ label: "Cursor",
1218
+ restartMode: "hot-reload",
1219
+ canWriteRuntimeConfig: true
1220
+ },
1221
+ vscode: {
1222
+ id: "vscode",
1223
+ label: "VS Code",
1224
+ restartMode: "hot-reload",
1225
+ canWriteRuntimeConfig: true
1226
+ },
1227
+ "vscode-insiders": {
1228
+ id: "vscode-insiders",
1229
+ label: "VS Code Insiders",
1230
+ restartMode: "hot-reload",
1231
+ canWriteRuntimeConfig: true
1232
+ },
1233
+ "claude-desktop": {
1234
+ id: "claude-desktop",
1235
+ label: "Claude Desktop",
1236
+ restartMode: "restart-app",
1237
+ canWriteRuntimeConfig: true
1238
+ },
1239
+ other: {
1240
+ id: "other",
1241
+ label: "Other agent runtime",
1242
+ restartMode: "manual",
1243
+ canWriteRuntimeConfig: false
1244
+ }
1245
+ };
1246
+ var RUNTIME_ALIASES = {
1247
+ claude: "claude-code",
1248
+ "claude-code": "claude-code",
1249
+ claudecode: "claude-code",
1250
+ "claude_code": "claude-code",
1251
+ codex: "codex-cli",
1252
+ "codex-cli": "codex-cli",
1253
+ codexcli: "codex-cli",
1254
+ "codex_cli": "codex-cli",
1255
+ "codex-desktop": "codex-desktop",
1256
+ "codex_desktop": "codex-desktop",
1257
+ codexdesktop: "codex-desktop",
1258
+ "codex-app": "codex-desktop",
1259
+ "codex_app": "codex-desktop",
1260
+ codexapp: "codex-desktop",
1261
+ cursor: "cursor",
1262
+ vscode: "vscode",
1263
+ "vs-code": "vscode",
1264
+ "vs_code": "vscode",
1265
+ code: "vscode",
1266
+ "vscode-insiders": "vscode-insiders",
1267
+ "vscode_insiders": "vscode-insiders",
1268
+ vscodeinsiders: "vscode-insiders",
1269
+ "vs-code-insiders": "vscode-insiders",
1270
+ "code-insiders": "vscode-insiders",
1271
+ insiders: "vscode-insiders",
1272
+ "claude-desktop": "claude-desktop",
1273
+ "claude_desktop": "claude-desktop",
1274
+ claudesktop: "claude-desktop",
1275
+ desktop: "claude-desktop",
1276
+ other: "other",
1277
+ manual: "other"
1278
+ };
1279
+ function runtimeProfile(runtime, env = process.env) {
1280
+ return RUNTIME_PROFILES[normalizeRuntime(runtime, env)];
1281
+ }
1282
+ function normalizeRuntime(runtime, env = process.env) {
1283
+ const explicit = normalizeRuntimeName(runtime);
1284
+ if (explicit) return explicit;
1285
+ return detectRuntime(env) ?? "other";
1286
+ }
1287
+ function restartRequiredForRuntime(runtime, env = process.env) {
1288
+ const mode = runtimeProfile(runtime, env).restartMode;
1289
+ return mode === "restart-session" || mode === "restart-app";
1290
+ }
1291
+ function runtimeRequiresHardRestart(runtime) {
1292
+ return runtime === "claude-desktop" || runtime === "codex-desktop";
1293
+ }
1294
+ function normalizeRuntimeName(runtime) {
1295
+ const key = runtime?.trim().toLowerCase();
1296
+ if (!key) return null;
1297
+ return RUNTIME_ALIASES[key.replace(/\s+/g, "-")] ?? null;
1298
+ }
1299
+ function detectRuntime(env) {
1300
+ if (env.CLAUDECODE || env.CLAUDE_CODE || env.CLAUDECODE_CWD) return "claude-code";
1301
+ if (env.CODEX_SANDBOX || env.CODEX_HOME || env.CODEX_CWD) return "codex-cli";
1302
+ if (env.VSCODE_CWD || env.VSCODE_IPC_HOOK_CLI || env.TERM_PROGRAM === "vscode") return "vscode";
1303
+ return null;
1304
+ }
1299
1305
  async function acknowledgeLocalSignerConsent(signerPath, log) {
1300
1306
  try {
1301
1307
  const input = await buildSignerConsentInput(signerPath);
@@ -1371,6 +1377,7 @@ var execFileAsync3 = promisify(execFile);
1371
1377
  async function installRuntime(input, deps = {}) {
1372
1378
  const runtime = normalizeRuntime(input.runtime, deps.env);
1373
1379
  const profile = runtimeProfile(runtime, deps.env);
1380
+ const progress = deps.onProgress ?? (() => void 0);
1374
1381
  const localRuntime = input.localMcp === true && supportsLocalMcp(runtime);
1375
1382
  const consentMessages = [];
1376
1383
  const localMcpConsent = localRuntime ? await resolveLocalMcpConsent(input, consentMessages) : void 0;
@@ -1430,6 +1437,7 @@ async function installRuntime(input, deps = {}) {
1430
1437
  }
1431
1438
  let signerCommand;
1432
1439
  if (!localRuntime) {
1440
+ progress("Getting the signer ready\u2026");
1433
1441
  try {
1434
1442
  const signerRuntime = await prepareSignerForRuntime(input, deps);
1435
1443
  signerCommand = { command: signerRuntime.command, args: signerRuntime.args };
@@ -1441,6 +1449,7 @@ async function installRuntime(input, deps = {}) {
1441
1449
  }
1442
1450
  }
1443
1451
  const signerRuntimePrepared = localRuntime ? void 0 : signerCommand !== void 0;
1452
+ progress("Setting up your Haven tools\u2026");
1444
1453
  const configResult = runtime === "claude-code" ? localRuntime ? await configureClaudeCode(deps, localRuntimeInstall?.command ?? "") : await configureClaudeCodeHosted(deps, input, signerCommand) : await writeRuntimeConfig({
1445
1454
  runtime,
1446
1455
  hostedMcpUrl: input.hostedMcpUrl,
@@ -1453,6 +1462,7 @@ async function installRuntime(input, deps = {}) {
1453
1462
  homeDir: deps.homeDir,
1454
1463
  mode: localRuntime ? "local" : "hosted"
1455
1464
  });
1465
+ progress("Almost there \u2014 just confirming everything connects\u2026");
1456
1466
  const localProbePromise = configResult.runtimeMcpMode === "local_stdio" && localRuntimeInstall ? runLocalMcpProbe(localRuntimeInstall, deps) : Promise.resolve(void 0);
1457
1467
  const [hostedProbe, signerCredentialReady, localMcpProbe] = await Promise.all([
1458
1468
  configResult.hostedConfigured ? probeHostedMcpTools(input.apiKey, input.hostedMcpUrl, deps.fetch) : Promise.resolve({ status: "bad_response" }),
@@ -1517,8 +1527,7 @@ async function configureClaudeCode(deps, localMcpCommand) {
1517
1527
  restartRequired: true,
1518
1528
  messages: [
1519
1529
  "Updated local Haven MCP entry with Claude Code.",
1520
- ...verified ? ["Verified Claude Code MCP entry."] : [],
1521
- "After Haven approval, Haven tools should appear in your next Claude Code message. If they don't, restart the session to load them."
1530
+ ...verified ? ["Verified Claude Code MCP entry."] : []
1522
1531
  ]
1523
1532
  };
1524
1533
  } catch (err) {
@@ -1567,8 +1576,7 @@ async function configureClaudeCodeHosted(deps, input, signerCommand) {
1567
1576
  restartRequired: true,
1568
1577
  messages: [
1569
1578
  "Updated hosted Haven MCP and local signer entries with Claude Code.",
1570
- ...verified ? ["Verified Claude Code MCP entry."] : [],
1571
- "After Haven approval, Haven tools should appear in your next Claude Code message. If they don't, restart the session to load them."
1579
+ ...verified ? ["Verified Claude Code MCP entry."] : []
1572
1580
  ]
1573
1581
  };
1574
1582
  } catch (err) {
@@ -1696,7 +1704,7 @@ function localRuntimePrepareErrorCode(err) {
1696
1704
  }
1697
1705
 
1698
1706
  // src/runtime.ts
1699
- var CONNECTOR_VERSION = "0.1.16-alpha.0";
1707
+ var CONNECTOR_VERSION = "0.1.17-alpha.0";
1700
1708
  async function runConnect(options, deps = {}) {
1701
1709
  const connectorVersion = options.connectorVersion ?? CONNECTOR_VERSION;
1702
1710
  const api = deps.api ?? createConnectApiClient(options.apiBaseUrl);
@@ -1716,6 +1724,7 @@ async function runConnect(options, deps = {}) {
1716
1724
  );
1717
1725
  }
1718
1726
  }
1727
+ log("Warming up your connection to Haven\u2026");
1719
1728
  const setup = await api.resolveSetup({
1720
1729
  setupToken: options.setupToken,
1721
1730
  connectorVersion,
@@ -1723,12 +1732,12 @@ async function runConnect(options, deps = {}) {
1723
1732
  });
1724
1733
  printSetupSummary(setup, log);
1725
1734
  await preflightStorage({ baseDir: options.credentialsDir, warn: log });
1726
- log("Checked local credential storage.");
1735
+ log("Checked local credential storage \u2014 all clear.");
1727
1736
  const localKey = generateKey();
1728
1737
  const localApiKey = generateLocalApiKey();
1729
- log("Generated local signing key.");
1730
- log("Generated local Haven API key.");
1738
+ log("Minting a fresh signing key and API key \u2014 both stay on this machine.");
1731
1739
  const proofSignature = await localKey.signChallenge(setup.challenge.message);
1740
+ log("Introducing your agent to Haven\u2026");
1732
1741
  const registration = await api.registerSetup({
1733
1742
  setupToken: options.setupToken,
1734
1743
  connectorVersion,
@@ -1745,6 +1754,7 @@ async function runConnect(options, deps = {}) {
1745
1754
  installCapabilities
1746
1755
  });
1747
1756
  log(`Registered signing address with Haven: ${shortAddress(registration.delegate_address)}.`);
1757
+ log("Tucking your credentials away safely on disk\u2026");
1748
1758
  const credentialPaths = await writeCredentials({
1749
1759
  baseDir: options.credentialsDir,
1750
1760
  agentId: registration.agent_id,
@@ -1785,8 +1795,14 @@ async function runConnect(options, deps = {}) {
1785
1795
  ackSigner: options.ackSigner,
1786
1796
  ackLocalTools: options.ackLocalTools,
1787
1797
  localMcp: options.localMcp
1788
- });
1798
+ }, { onProgress: log });
1789
1799
  printRuntimeInstall(runtimeInstall, log);
1800
+ if (runtimeInstall.errorCode) {
1801
+ log("Haven setup needs a couple more steps on this machine \u2014 see the notes above.");
1802
+ } else {
1803
+ log("Haven setup on this machine is complete.");
1804
+ }
1805
+ printNextSteps(runtimeInstall, log);
1790
1806
  try {
1791
1807
  await api.updateInstallStatus(registration.setup_id, localApiKey, {
1792
1808
  runtime: runtimeInstall.runtime,
@@ -1809,14 +1825,6 @@ async function runConnect(options, deps = {}) {
1809
1825
  } catch (err) {
1810
1826
  log(`Could not report install status to Haven: ${err instanceof Error ? err.message : String(err)}`);
1811
1827
  }
1812
- log("Return to Haven to approve the agent rules.");
1813
- if (runtimeInstall.restartRequired) {
1814
- if (runtimeRequiresHardRestart(runtimeInstall.runtime)) {
1815
- log("After approval, restart this agent so it can load Haven tools.");
1816
- } else {
1817
- log("After approval, Haven tools should appear in your next message. If they don't, restart this agent to load them.");
1818
- }
1819
- }
1820
1828
  return {
1821
1829
  setupId: registration.setup_id,
1822
1830
  agentId: registration.agent_id,
@@ -1854,6 +1862,18 @@ function printRuntimeInstall(result, log) {
1854
1862
  log("Local Haven signer still needs runtime setup.");
1855
1863
  }
1856
1864
  }
1865
+ function printNextSteps(result, log) {
1866
+ log("Next: approve the agent rules in Haven. No Haven tools appear until you approve \u2014 restart or not.");
1867
+ if (result.restartRequired) {
1868
+ if (runtimeRequiresHardRestart(result.runtime)) {
1869
+ log("After you approve, restart this agent so it can load Haven tools.");
1870
+ } else {
1871
+ log("After you approve, restart this agent \u2014 your current session won't load the Haven tools until you do.");
1872
+ }
1873
+ } else {
1874
+ log("After you approve, the Haven tools should appear in this runtime shortly.");
1875
+ }
1876
+ }
1857
1877
 
1858
1878
  // src/args.ts
1859
1879
  function parseArgs(argv, env = process.env) {