@haven_ai/connect 0.1.3-alpha → 0.1.4-alpha

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
@@ -6,7 +6,7 @@ import { homedir, platform } from 'os';
6
6
  import { join, resolve, dirname } from 'path';
7
7
  import { execFile, spawn } from 'child_process';
8
8
  import { promisify } from 'util';
9
- import { MCP_VERSION, ensureConsent, computeConsentHash, loadCredentials, consentInputFromClient, registeredToolNames } from '@haven_ai/mcp';
9
+ import { registeredToolNames, MCP_VERSION, ensureConsent, computeConsentHash, loadCredentials, consentInputFromClient } from '@haven_ai/mcp';
10
10
  import { ensureSignerConsent, computeSignerConsentHash, loadSignerCredentials, createEdgeSigner, toolSchemas } from '@haven_ai/signer';
11
11
 
12
12
  // src/api.ts
@@ -206,24 +206,12 @@ var MCP_RUNTIME_MANIFEST = {
206
206
  mcpPackage: "@haven_ai/mcp",
207
207
  mcpVersion: MCP_VERSION,
208
208
  sdkPackage: "@haven_ai/sdk",
209
- sdkVersion: "0.1.6",
209
+ sdkVersion: "0.1.7",
210
210
  signerPackage: "@haven_ai/signer",
211
211
  signerVersion: "0.1.0-alpha",
212
212
  minimumNodeVersion: "20.0.0",
213
213
  supportedClients: ["codex-cli", "codex-desktop", "claude-code"],
214
- requiredTools: [
215
- "haven_quote_x402",
216
- "haven_pay_x402_quote",
217
- "haven_resume_x402_payment",
218
- "haven_quote_mpp",
219
- "haven_pay_mpp_challenge",
220
- "haven_resume_mpp_payment",
221
- "haven_get_payment_status",
222
- "haven_get_resume_state",
223
- "haven_get_agent",
224
- "haven_get_allowances",
225
- "haven_list_receipts"
226
- ]
214
+ requiredTools: registeredToolNames()
227
215
  };
228
216
  function mcpPackageSpec() {
229
217
  return `${MCP_RUNTIME_MANIFEST.mcpPackage}@${MCP_RUNTIME_MANIFEST.mcpVersion}`;
@@ -235,6 +223,117 @@ function signerPackageSpec() {
235
223
  return `${MCP_RUNTIME_MANIFEST.signerPackage}@${MCP_RUNTIME_MANIFEST.signerVersion}`;
236
224
  }
237
225
 
226
+ // src/runtime-registry.ts
227
+ var RUNTIME_PROFILES = {
228
+ "claude-code": {
229
+ id: "claude-code",
230
+ label: "Claude Code",
231
+ restartMode: "restart-session",
232
+ canWriteRuntimeConfig: true
233
+ },
234
+ "codex-cli": {
235
+ id: "codex-cli",
236
+ label: "Codex CLI",
237
+ restartMode: "restart-session",
238
+ canWriteRuntimeConfig: true
239
+ },
240
+ "codex-desktop": {
241
+ id: "codex-desktop",
242
+ label: "Codex Desktop",
243
+ restartMode: "restart-session",
244
+ canWriteRuntimeConfig: true
245
+ },
246
+ cursor: {
247
+ id: "cursor",
248
+ label: "Cursor",
249
+ restartMode: "hot-reload",
250
+ canWriteRuntimeConfig: true
251
+ },
252
+ vscode: {
253
+ id: "vscode",
254
+ label: "VS Code",
255
+ restartMode: "hot-reload",
256
+ canWriteRuntimeConfig: true
257
+ },
258
+ "vscode-insiders": {
259
+ id: "vscode-insiders",
260
+ label: "VS Code Insiders",
261
+ restartMode: "hot-reload",
262
+ canWriteRuntimeConfig: true
263
+ },
264
+ "claude-desktop": {
265
+ id: "claude-desktop",
266
+ label: "Claude Desktop",
267
+ restartMode: "restart-app",
268
+ canWriteRuntimeConfig: true
269
+ },
270
+ other: {
271
+ id: "other",
272
+ label: "Other agent runtime",
273
+ restartMode: "manual",
274
+ canWriteRuntimeConfig: false
275
+ }
276
+ };
277
+ var RUNTIME_ALIASES = {
278
+ claude: "claude-code",
279
+ "claude-code": "claude-code",
280
+ claudecode: "claude-code",
281
+ "claude_code": "claude-code",
282
+ codex: "codex-cli",
283
+ "codex-cli": "codex-cli",
284
+ codexcli: "codex-cli",
285
+ "codex_cli": "codex-cli",
286
+ "codex-desktop": "codex-desktop",
287
+ "codex_desktop": "codex-desktop",
288
+ codexdesktop: "codex-desktop",
289
+ "codex-app": "codex-desktop",
290
+ "codex_app": "codex-desktop",
291
+ codexapp: "codex-desktop",
292
+ cursor: "cursor",
293
+ vscode: "vscode",
294
+ "vs-code": "vscode",
295
+ "vs_code": "vscode",
296
+ code: "vscode",
297
+ "vscode-insiders": "vscode-insiders",
298
+ "vscode_insiders": "vscode-insiders",
299
+ vscodeinsiders: "vscode-insiders",
300
+ "vs-code-insiders": "vscode-insiders",
301
+ "code-insiders": "vscode-insiders",
302
+ insiders: "vscode-insiders",
303
+ "claude-desktop": "claude-desktop",
304
+ "claude_desktop": "claude-desktop",
305
+ claudesktop: "claude-desktop",
306
+ desktop: "claude-desktop",
307
+ other: "other",
308
+ manual: "other"
309
+ };
310
+ function runtimeProfile(runtime, env = process.env) {
311
+ return RUNTIME_PROFILES[normalizeRuntime(runtime, env)];
312
+ }
313
+ function normalizeRuntime(runtime, env = process.env) {
314
+ const explicit = normalizeRuntimeName(runtime);
315
+ if (explicit) return explicit;
316
+ return detectRuntime(env) ?? "other";
317
+ }
318
+ function restartRequiredForRuntime(runtime, env = process.env) {
319
+ const mode = runtimeProfile(runtime, env).restartMode;
320
+ return mode === "restart-session" || mode === "restart-app";
321
+ }
322
+ function runtimeRequiresHardRestart(runtime) {
323
+ return runtime === "claude-desktop" || runtime === "codex-desktop";
324
+ }
325
+ function normalizeRuntimeName(runtime) {
326
+ const key = runtime?.trim().toLowerCase();
327
+ if (!key) return null;
328
+ return RUNTIME_ALIASES[key.replace(/\s+/g, "-")] ?? null;
329
+ }
330
+ function detectRuntime(env) {
331
+ if (env.CLAUDECODE || env.CLAUDE_CODE || env.CLAUDECODE_CWD) return "claude-code";
332
+ if (env.CODEX_SANDBOX || env.CODEX_HOME || env.CODEX_CWD) return "codex-cli";
333
+ if (env.VSCODE_CWD || env.VSCODE_IPC_HOOK_CLI || env.TERM_PROGRAM === "vscode") return "vscode";
334
+ return null;
335
+ }
336
+
238
337
  // src/config-writers.ts
239
338
  var InvalidCodexTomlError = class extends Error {
240
339
  constructor(message) {
@@ -251,6 +350,8 @@ async function writeRuntimeConfig(input) {
251
350
  return writeJsonRuntimeConfig(input, cursorConfigPath(input.homeDir), "mcpServers");
252
351
  case "vscode":
253
352
  return writeJsonRuntimeConfig(input, vscodeConfigPath(input.homeDir), "servers");
353
+ case "vscode-insiders":
354
+ return writeJsonRuntimeConfig(input, vscodeInsidersConfigPath(input.homeDir), "servers");
254
355
  case "claude-desktop":
255
356
  return writeJsonRuntimeConfig(input, claudeDesktopConfigPath(input.homeDir), "mcpServers");
256
357
  default:
@@ -268,7 +369,7 @@ async function writeRuntimeConfig(input) {
268
369
  }
269
370
  }
270
371
  function buildHostedServer(hostedMcpUrl, apiKey, runtime) {
271
- if (runtime === "vscode") {
372
+ if (runtime === "vscode" || runtime === "vscode-insiders") {
272
373
  return {
273
374
  type: "http",
274
375
  url: hostedMcpUrl,
@@ -285,7 +386,7 @@ function buildSignerServer(signerPath, runtime) {
285
386
  command: "npx",
286
387
  args: ["-y", signerPackageName(), "--credentials", signerPath]
287
388
  };
288
- if (runtime === "vscode") return { type: "stdio", ...server };
389
+ if (runtime === "vscode" || runtime === "vscode-insiders") return { type: "stdio", ...server };
289
390
  return server;
290
391
  }
291
392
  function mergeJsonMcpConfig(existingJson, serverRoot, hostedServer, signerServer) {
@@ -369,7 +470,10 @@ async function writeCodexConfig(input) {
369
470
  restartRequired: true,
370
471
  messages: [
371
472
  `Updated local Haven MCP entry in ${configTargetLabel(input.runtime)}.`,
372
- "After Haven approval, restart Codex normally so it can load Haven tools."
473
+ // Codex Desktop loads MCP servers at app launch; Codex CLI typically
474
+ // picks them up in the next session. Branch the copy so desktop users
475
+ // get the unambiguous instruction.
476
+ 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."
373
477
  ]
374
478
  };
375
479
  } catch (err) {
@@ -608,6 +712,13 @@ function vscodeConfigPath(homeDir = homedir()) {
608
712
  }
609
713
  return resolve(homeDir, ".config", "Code", "User", "mcp.json");
610
714
  }
715
+ function vscodeInsidersConfigPath(homeDir = homedir()) {
716
+ if (platform() === "darwin") return resolve(homeDir, "Library", "Application Support", "Code - Insiders", "User", "mcp.json");
717
+ if (platform() === "win32") {
718
+ return resolve(process.env.APPDATA ?? join(homeDir, "AppData", "Roaming"), "Code - Insiders", "User", "mcp.json");
719
+ }
720
+ return resolve(homeDir, ".config", "Code - Insiders", "User", "mcp.json");
721
+ }
611
722
  function claudeDesktopConfigPath(homeDir = homedir()) {
612
723
  if (platform() === "darwin") {
613
724
  return resolve(homeDir, "Library", "Application Support", "Claude", "claude_desktop_config.json");
@@ -627,6 +738,8 @@ function configTargetLabel(runtime) {
627
738
  return "Cursor MCP config";
628
739
  case "vscode":
629
740
  return "VS Code MCP config";
741
+ case "vscode-insiders":
742
+ return "VS Code Insiders MCP config";
630
743
  case "claude-desktop":
631
744
  return "Claude Desktop config";
632
745
  default:
@@ -997,102 +1110,6 @@ async function assertFileExists(path, label) {
997
1110
  throw new Error(`Missing ${label}: ${path}`);
998
1111
  }
999
1112
  }
1000
-
1001
- // src/runtime-registry.ts
1002
- var RUNTIME_PROFILES = {
1003
- "claude-code": {
1004
- id: "claude-code",
1005
- label: "Claude Code",
1006
- restartMode: "restart-session",
1007
- canWriteRuntimeConfig: true
1008
- },
1009
- "codex-cli": {
1010
- id: "codex-cli",
1011
- label: "Codex CLI",
1012
- restartMode: "restart-session",
1013
- canWriteRuntimeConfig: true
1014
- },
1015
- "codex-desktop": {
1016
- id: "codex-desktop",
1017
- label: "Codex Desktop",
1018
- restartMode: "restart-session",
1019
- canWriteRuntimeConfig: true
1020
- },
1021
- cursor: {
1022
- id: "cursor",
1023
- label: "Cursor",
1024
- restartMode: "hot-reload",
1025
- canWriteRuntimeConfig: true
1026
- },
1027
- vscode: {
1028
- id: "vscode",
1029
- label: "VS Code",
1030
- restartMode: "hot-reload",
1031
- canWriteRuntimeConfig: true
1032
- },
1033
- "claude-desktop": {
1034
- id: "claude-desktop",
1035
- label: "Claude Desktop",
1036
- restartMode: "restart-app",
1037
- canWriteRuntimeConfig: true
1038
- },
1039
- other: {
1040
- id: "other",
1041
- label: "Other agent runtime",
1042
- restartMode: "manual",
1043
- canWriteRuntimeConfig: false
1044
- }
1045
- };
1046
- var RUNTIME_ALIASES = {
1047
- claude: "claude-code",
1048
- "claude-code": "claude-code",
1049
- claudecode: "claude-code",
1050
- "claude_code": "claude-code",
1051
- codex: "codex-cli",
1052
- "codex-cli": "codex-cli",
1053
- codexcli: "codex-cli",
1054
- "codex_cli": "codex-cli",
1055
- "codex-desktop": "codex-desktop",
1056
- "codex_desktop": "codex-desktop",
1057
- codexdesktop: "codex-desktop",
1058
- "codex-app": "codex-desktop",
1059
- "codex_app": "codex-desktop",
1060
- codexapp: "codex-desktop",
1061
- cursor: "cursor",
1062
- vscode: "vscode",
1063
- "vs-code": "vscode",
1064
- "vs_code": "vscode",
1065
- code: "vscode",
1066
- "claude-desktop": "claude-desktop",
1067
- "claude_desktop": "claude-desktop",
1068
- claudesktop: "claude-desktop",
1069
- desktop: "claude-desktop",
1070
- other: "other",
1071
- manual: "other"
1072
- };
1073
- function runtimeProfile(runtime, env = process.env) {
1074
- return RUNTIME_PROFILES[normalizeRuntime(runtime, env)];
1075
- }
1076
- function normalizeRuntime(runtime, env = process.env) {
1077
- const explicit = normalizeRuntimeName(runtime);
1078
- if (explicit) return explicit;
1079
- return detectRuntime(env) ?? "other";
1080
- }
1081
- function restartRequiredForRuntime(runtime, env = process.env) {
1082
- const mode = runtimeProfile(runtime, env).restartMode;
1083
- return mode === "restart-session" || mode === "restart-app";
1084
- }
1085
- function normalizeRuntimeName(runtime) {
1086
- const key = runtime?.trim().toLowerCase();
1087
- if (!key) return null;
1088
- return RUNTIME_ALIASES[key.replace(/\s+/g, "-")] ?? null;
1089
- }
1090
- function detectRuntime(env) {
1091
- if (env.CLAUDECODE || env.CLAUDE_CODE || env.CLAUDECODE_CWD) return "claude-code";
1092
- if (env.CODEX_SANDBOX || env.CODEX_HOME || env.CODEX_CWD) return "codex-cli";
1093
- if (env.VSCODE_CWD || env.VSCODE_IPC_HOOK_CLI || env.TERM_PROGRAM === "vscode") return "vscode";
1094
- return null;
1095
- }
1096
1113
  async function acknowledgeLocalSignerConsent(signerPath, log) {
1097
1114
  try {
1098
1115
  const input = await buildSignerConsentInput(signerPath);
@@ -1297,7 +1314,7 @@ async function configureClaudeCode(deps, localMcpCommand) {
1297
1314
  messages: [
1298
1315
  "Updated local Haven MCP entry with Claude Code.",
1299
1316
  ...verified ? ["Verified Claude Code MCP entry."] : [],
1300
- "After Haven approval, restart Claude Code normally so it can load Haven tools."
1317
+ "After Haven approval, Haven tools should appear in your next Claude Code message. If they don't, restart the session to load them."
1301
1318
  ]
1302
1319
  };
1303
1320
  } catch (err) {
@@ -1497,7 +1514,11 @@ async function runConnect(options, deps = {}) {
1497
1514
  }
1498
1515
  log("Return to Haven to approve the agent rules.");
1499
1516
  if (runtimeInstall.restartRequired) {
1500
- log("After approval, restart this agent normally so it can load Haven tools.");
1517
+ if (runtimeRequiresHardRestart(runtimeInstall.runtime)) {
1518
+ log("After approval, restart this agent so it can load Haven tools.");
1519
+ } else {
1520
+ log("After approval, Haven tools should appear in your next message. If they don't, restart this agent to load them.");
1521
+ }
1501
1522
  }
1502
1523
  return {
1503
1524
  setupId: registration.setup_id,