@haven_ai/signer 0.1.36-alpha.0 → 0.2.0-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/index.d.cts CHANGED
@@ -79,7 +79,9 @@ interface X402ExpectedPayment {
79
79
  /**
80
80
  * Resource URL of the x402 payment Haven prepared. On the hosted surface
81
81
  * that is `haven_pay_x402_quote` — `buildX402SigningContext` in
82
- * `mcp-server/src/tools.ts` relays `intent.resourceUrl` here, and
82
+ * `mcp-server/src/tools/support/mcp-context.ts` (called from the
83
+ * `haven_pay_x402_quote` handler, which is still in `tools.ts`) relays
84
+ * `intent.resourceUrl` here, and
83
85
  * `haven_resume_x402_payment` re-emits the same context. Checked against
84
86
  * the merchant header's resource in `assertX402MatchesExpected`.
85
87
  */
@@ -280,6 +282,17 @@ declare function signerInstructions(): string;
280
282
  interface SignerCredentials {
281
283
  delegateKey: string;
282
284
  agentId?: string;
285
+ /**
286
+ * The Haven account (smart account) the agent spends from — #2908, the
287
+ * account-vocabulary name. Same value as `safeAddress`.
288
+ */
289
+ accountAddress?: string;
290
+ /**
291
+ * @deprecated #2908 — same value as {@link SignerCredentials.accountAddress}.
292
+ * Removed from this shape in the release after the one carrying #2908
293
+ * (#2914). The credential-FILE keys it was read from are a different
294
+ * matter — see `readAccountAddressField`.
295
+ */
283
296
  safeAddress?: string;
284
297
  chainId?: number;
285
298
  network?: string;
@@ -287,6 +300,23 @@ interface SignerCredentials {
287
300
  /** Absolute path the key was loaded from, if a file was used. */
288
301
  sourcePath?: string;
289
302
  }
303
+ interface RawCredentialFile {
304
+ delegate_key?: unknown;
305
+ delegateKey?: unknown;
306
+ agent_id?: unknown;
307
+ agentId?: unknown;
308
+ /** #2908: what `@haven_ai/connect` writes from this release on. */
309
+ account_address?: unknown;
310
+ /** Pre-#2908 spelling — read PERMANENTLY, see `readAccountAddressField`. */
311
+ safe_address?: unknown;
312
+ /** Pre-#2908 spelling — read PERMANENTLY, see `readAccountAddressField`. */
313
+ safeAddress?: unknown;
314
+ chain_id?: unknown;
315
+ chainId?: unknown;
316
+ network?: unknown;
317
+ x402_binding_signer?: unknown;
318
+ x402BindingSigner?: unknown;
319
+ }
290
320
  /**
291
321
  * Resolve the delegate key for the edge signer.
292
322
  *
@@ -299,6 +329,30 @@ interface SignerCredentials {
299
329
  * `delegate_key` and ignore the rest.
300
330
  */
301
331
  declare function loadSignerCredentials(path?: string | undefined): Promise<SignerCredentials>;
332
+ /**
333
+ * The account address off a credential FILE: `account_address` (what
334
+ * `@haven_ai/connect` writes from #2908 on) first, then the two pre-#2908
335
+ * spellings.
336
+ *
337
+ * The two old fallbacks are PERMANENT, not part of the one-release naming
338
+ * window (#2906, decision 2a): a credential file on disk was written once and
339
+ * never rewrites itself, so a signer that stopped reading `safe_address`
340
+ * would silently lose the address for every agent connected before this
341
+ * release — the consent hash would change and the spend-context prompt would
342
+ * say "not provided". Two lines, kept for as long as the file format exists.
343
+ *
344
+ * Exported for the mutation tests: dropping `account_address` fails the
345
+ * new-shape test, dropping either old key fails the old-shape test.
346
+ */
347
+ declare function readAccountAddressField(raw: Pick<RawCredentialFile, 'account_address' | 'safe_address' | 'safeAddress'>): string | undefined;
348
+ /**
349
+ * The account address off the process environment, new name first:
350
+ * `HAVEN_ACCOUNT_ADDRESS` (the survivor, decided on #2906) then the two
351
+ * names the dashboard handoff emitted before #2908 — `HAVEN_WALLET_ADDRESS`
352
+ * and `HAVEN_SAFE_ADDRESS`. Unlike the file fallbacks these two ARE
353
+ * window-scoped: they are dropped at #2914, one release after this one.
354
+ */
355
+ declare function readAccountAddressEnv(env: NodeJS.ProcessEnv): string | undefined;
302
356
  /**
303
357
  * Warn (best-effort, POSIX only) when the credential file is readable beyond
304
358
  * its owner. Mirrors `@haven_ai/mcp`'s check — the delegate key is the most
@@ -414,7 +468,7 @@ declare function renderSignerConsentBlock(input: SignerConsentInput, hash: strin
414
468
  declare function ensureSignerConsent(input: SignerConsentInput, options?: SignerConsentOptions): Promise<SignerConsentDecision>;
415
469
 
416
470
  declare const SIGNER_NAME = "@haven_ai/signer";
417
- declare const SIGNER_VERSION = "0.1.36-alpha.0";
471
+ declare const SIGNER_VERSION = "0.2.0-alpha.0";
418
472
  interface SignerOptions {
419
473
  /** Path to a Haven credential JSON file (delegate_key is read from it). */
420
474
  credentialsPath?: string;
@@ -479,4 +533,4 @@ declare function assertSupportedNodeVersion(nodeVersion?: string): void;
479
533
  declare function runSignerStdioServer(options?: SignerOptions): Promise<void>;
480
534
  declare function runSignerConsentGate(signer: EdgeSigner, credentials: SignerCredentials | undefined, options: SignerOptions): Promise<SignerConsentDecision>;
481
535
 
482
- export { type EdgeSigner, type ResolvedSignerRuntime, SIGNER_ACK_ENV, SIGNER_CAPABILITY_KEY, SIGNER_NAME, SIGNER_VERSION, SUPPORTED_SWEEP_BINDING_VERSIONS, SUPPORTED_X402_EXPECTED_VERSIONS, type SignerCompatibility, type SignerConsentDecision, type SignerConsentInput, type SignerConsentOptions, type SignerCredentials, type SignerOptions, type SignerToolName, type SigningAuditContext, type SigningAuditEntry, type ToolFailure, type ToolPayload, type ToolSuccess, type X402ExpectedPayment, type X402FundingSignatureResult, type X402HeaderResult, appendSigningAuditEntry, assertSupportedBindingVersion, assertSupportedNodeVersion, assertX402MatchesExpected, buildSignerMcpServer, computeSignerConsentHash, createEdgeSigner, createSigningAuditEntry, createToolHandlers, defaultSigningAuditPath, ensureSignerConsent, hashPayloadForAudit, loadSignerCredentials, renderSignerConsentBlock, resolveEdgeSigner, resolveSignerRuntime, runSignerConsentGate, runSignerStdioServer, signerCapabilityAdvertisement, signerCompatibility, signerInstructions, toolDescriptions, toolSchemas, warnIfCredentialFilePermissive };
536
+ export { type EdgeSigner, type ResolvedSignerRuntime, SIGNER_ACK_ENV, SIGNER_CAPABILITY_KEY, SIGNER_NAME, SIGNER_VERSION, SUPPORTED_SWEEP_BINDING_VERSIONS, SUPPORTED_X402_EXPECTED_VERSIONS, type SignerCompatibility, type SignerConsentDecision, type SignerConsentInput, type SignerConsentOptions, type SignerCredentials, type SignerOptions, type SignerToolName, type SigningAuditContext, type SigningAuditEntry, type ToolFailure, type ToolPayload, type ToolSuccess, type X402ExpectedPayment, type X402FundingSignatureResult, type X402HeaderResult, appendSigningAuditEntry, assertSupportedBindingVersion, assertSupportedNodeVersion, assertX402MatchesExpected, buildSignerMcpServer, computeSignerConsentHash, createEdgeSigner, createSigningAuditEntry, createToolHandlers, defaultSigningAuditPath, ensureSignerConsent, hashPayloadForAudit, loadSignerCredentials, readAccountAddressEnv, readAccountAddressField, renderSignerConsentBlock, resolveEdgeSigner, resolveSignerRuntime, runSignerConsentGate, runSignerStdioServer, signerCapabilityAdvertisement, signerCompatibility, signerInstructions, toolDescriptions, toolSchemas, warnIfCredentialFilePermissive };
package/dist/index.d.ts CHANGED
@@ -79,7 +79,9 @@ interface X402ExpectedPayment {
79
79
  /**
80
80
  * Resource URL of the x402 payment Haven prepared. On the hosted surface
81
81
  * that is `haven_pay_x402_quote` — `buildX402SigningContext` in
82
- * `mcp-server/src/tools.ts` relays `intent.resourceUrl` here, and
82
+ * `mcp-server/src/tools/support/mcp-context.ts` (called from the
83
+ * `haven_pay_x402_quote` handler, which is still in `tools.ts`) relays
84
+ * `intent.resourceUrl` here, and
83
85
  * `haven_resume_x402_payment` re-emits the same context. Checked against
84
86
  * the merchant header's resource in `assertX402MatchesExpected`.
85
87
  */
@@ -280,6 +282,17 @@ declare function signerInstructions(): string;
280
282
  interface SignerCredentials {
281
283
  delegateKey: string;
282
284
  agentId?: string;
285
+ /**
286
+ * The Haven account (smart account) the agent spends from — #2908, the
287
+ * account-vocabulary name. Same value as `safeAddress`.
288
+ */
289
+ accountAddress?: string;
290
+ /**
291
+ * @deprecated #2908 — same value as {@link SignerCredentials.accountAddress}.
292
+ * Removed from this shape in the release after the one carrying #2908
293
+ * (#2914). The credential-FILE keys it was read from are a different
294
+ * matter — see `readAccountAddressField`.
295
+ */
283
296
  safeAddress?: string;
284
297
  chainId?: number;
285
298
  network?: string;
@@ -287,6 +300,23 @@ interface SignerCredentials {
287
300
  /** Absolute path the key was loaded from, if a file was used. */
288
301
  sourcePath?: string;
289
302
  }
303
+ interface RawCredentialFile {
304
+ delegate_key?: unknown;
305
+ delegateKey?: unknown;
306
+ agent_id?: unknown;
307
+ agentId?: unknown;
308
+ /** #2908: what `@haven_ai/connect` writes from this release on. */
309
+ account_address?: unknown;
310
+ /** Pre-#2908 spelling — read PERMANENTLY, see `readAccountAddressField`. */
311
+ safe_address?: unknown;
312
+ /** Pre-#2908 spelling — read PERMANENTLY, see `readAccountAddressField`. */
313
+ safeAddress?: unknown;
314
+ chain_id?: unknown;
315
+ chainId?: unknown;
316
+ network?: unknown;
317
+ x402_binding_signer?: unknown;
318
+ x402BindingSigner?: unknown;
319
+ }
290
320
  /**
291
321
  * Resolve the delegate key for the edge signer.
292
322
  *
@@ -299,6 +329,30 @@ interface SignerCredentials {
299
329
  * `delegate_key` and ignore the rest.
300
330
  */
301
331
  declare function loadSignerCredentials(path?: string | undefined): Promise<SignerCredentials>;
332
+ /**
333
+ * The account address off a credential FILE: `account_address` (what
334
+ * `@haven_ai/connect` writes from #2908 on) first, then the two pre-#2908
335
+ * spellings.
336
+ *
337
+ * The two old fallbacks are PERMANENT, not part of the one-release naming
338
+ * window (#2906, decision 2a): a credential file on disk was written once and
339
+ * never rewrites itself, so a signer that stopped reading `safe_address`
340
+ * would silently lose the address for every agent connected before this
341
+ * release — the consent hash would change and the spend-context prompt would
342
+ * say "not provided". Two lines, kept for as long as the file format exists.
343
+ *
344
+ * Exported for the mutation tests: dropping `account_address` fails the
345
+ * new-shape test, dropping either old key fails the old-shape test.
346
+ */
347
+ declare function readAccountAddressField(raw: Pick<RawCredentialFile, 'account_address' | 'safe_address' | 'safeAddress'>): string | undefined;
348
+ /**
349
+ * The account address off the process environment, new name first:
350
+ * `HAVEN_ACCOUNT_ADDRESS` (the survivor, decided on #2906) then the two
351
+ * names the dashboard handoff emitted before #2908 — `HAVEN_WALLET_ADDRESS`
352
+ * and `HAVEN_SAFE_ADDRESS`. Unlike the file fallbacks these two ARE
353
+ * window-scoped: they are dropped at #2914, one release after this one.
354
+ */
355
+ declare function readAccountAddressEnv(env: NodeJS.ProcessEnv): string | undefined;
302
356
  /**
303
357
  * Warn (best-effort, POSIX only) when the credential file is readable beyond
304
358
  * its owner. Mirrors `@haven_ai/mcp`'s check — the delegate key is the most
@@ -414,7 +468,7 @@ declare function renderSignerConsentBlock(input: SignerConsentInput, hash: strin
414
468
  declare function ensureSignerConsent(input: SignerConsentInput, options?: SignerConsentOptions): Promise<SignerConsentDecision>;
415
469
 
416
470
  declare const SIGNER_NAME = "@haven_ai/signer";
417
- declare const SIGNER_VERSION = "0.1.36-alpha.0";
471
+ declare const SIGNER_VERSION = "0.2.0-alpha.0";
418
472
  interface SignerOptions {
419
473
  /** Path to a Haven credential JSON file (delegate_key is read from it). */
420
474
  credentialsPath?: string;
@@ -479,4 +533,4 @@ declare function assertSupportedNodeVersion(nodeVersion?: string): void;
479
533
  declare function runSignerStdioServer(options?: SignerOptions): Promise<void>;
480
534
  declare function runSignerConsentGate(signer: EdgeSigner, credentials: SignerCredentials | undefined, options: SignerOptions): Promise<SignerConsentDecision>;
481
535
 
482
- export { type EdgeSigner, type ResolvedSignerRuntime, SIGNER_ACK_ENV, SIGNER_CAPABILITY_KEY, SIGNER_NAME, SIGNER_VERSION, SUPPORTED_SWEEP_BINDING_VERSIONS, SUPPORTED_X402_EXPECTED_VERSIONS, type SignerCompatibility, type SignerConsentDecision, type SignerConsentInput, type SignerConsentOptions, type SignerCredentials, type SignerOptions, type SignerToolName, type SigningAuditContext, type SigningAuditEntry, type ToolFailure, type ToolPayload, type ToolSuccess, type X402ExpectedPayment, type X402FundingSignatureResult, type X402HeaderResult, appendSigningAuditEntry, assertSupportedBindingVersion, assertSupportedNodeVersion, assertX402MatchesExpected, buildSignerMcpServer, computeSignerConsentHash, createEdgeSigner, createSigningAuditEntry, createToolHandlers, defaultSigningAuditPath, ensureSignerConsent, hashPayloadForAudit, loadSignerCredentials, renderSignerConsentBlock, resolveEdgeSigner, resolveSignerRuntime, runSignerConsentGate, runSignerStdioServer, signerCapabilityAdvertisement, signerCompatibility, signerInstructions, toolDescriptions, toolSchemas, warnIfCredentialFilePermissive };
536
+ export { type EdgeSigner, type ResolvedSignerRuntime, SIGNER_ACK_ENV, SIGNER_CAPABILITY_KEY, SIGNER_NAME, SIGNER_VERSION, SUPPORTED_SWEEP_BINDING_VERSIONS, SUPPORTED_X402_EXPECTED_VERSIONS, type SignerCompatibility, type SignerConsentDecision, type SignerConsentInput, type SignerConsentOptions, type SignerCredentials, type SignerOptions, type SignerToolName, type SigningAuditContext, type SigningAuditEntry, type ToolFailure, type ToolPayload, type ToolSuccess, type X402ExpectedPayment, type X402FundingSignatureResult, type X402HeaderResult, appendSigningAuditEntry, assertSupportedBindingVersion, assertSupportedNodeVersion, assertX402MatchesExpected, buildSignerMcpServer, computeSignerConsentHash, createEdgeSigner, createSigningAuditEntry, createToolHandlers, defaultSigningAuditPath, ensureSignerConsent, hashPayloadForAudit, loadSignerCredentials, readAccountAddressEnv, readAccountAddressField, renderSignerConsentBlock, resolveEdgeSigner, resolveSignerRuntime, runSignerConsentGate, runSignerStdioServer, signerCapabilityAdvertisement, signerCompatibility, signerInstructions, toolDescriptions, toolSchemas, warnIfCredentialFilePermissive };
package/dist/index.js CHANGED
@@ -501,10 +501,12 @@ async function loadSignerCredentials(path = process.env.HAVEN_CREDENTIALS) {
501
501
  if (path) return loadFromFile(path);
502
502
  const envKey = stringField(process.env.HAVEN_DELEGATE_KEY);
503
503
  if (envKey) {
504
+ const accountAddress = readAccountAddressEnv(process.env);
504
505
  return {
505
506
  delegateKey: envKey,
506
507
  agentId: stringField(process.env.HAVEN_AGENT_ID),
507
- safeAddress: stringField(process.env.HAVEN_SAFE_ADDRESS),
508
+ accountAddress,
509
+ safeAddress: accountAddress,
508
510
  chainId: chainIdField(process.env.HAVEN_CHAIN_ID, "HAVEN_CHAIN_ID"),
509
511
  network: stringField(process.env.HAVEN_NETWORK),
510
512
  x402BindingSigner: stringField(process.env.HAVEN_X402_BINDING_SIGNER)
@@ -534,10 +536,12 @@ async function loadFromFile(path) {
534
536
  if (!delegateKey) {
535
537
  throw new Error("Haven credentials are missing delegate_key \u2014 the edge signer needs it to sign.");
536
538
  }
539
+ const accountAddress = readAccountAddressField(raw);
537
540
  return {
538
541
  delegateKey,
539
542
  agentId: stringField(raw.agent_id ?? raw.agentId),
540
- safeAddress: stringField(raw.safe_address ?? raw.safeAddress),
543
+ accountAddress,
544
+ safeAddress: accountAddress,
541
545
  chainId: chainIdField(raw.chain_id ?? raw.chainId, "chain_id"),
542
546
  network: stringField(raw.network),
543
547
  x402BindingSigner: stringField(
@@ -546,6 +550,12 @@ async function loadFromFile(path) {
546
550
  sourcePath: path
547
551
  };
548
552
  }
553
+ function readAccountAddressField(raw) {
554
+ return stringField(raw.account_address ?? raw.safe_address ?? raw.safeAddress);
555
+ }
556
+ function readAccountAddressEnv(env) {
557
+ return stringField(env.HAVEN_ACCOUNT_ADDRESS ?? env.HAVEN_WALLET_ADDRESS ?? env.HAVEN_SAFE_ADDRESS);
558
+ }
549
559
  function stringField(value) {
550
560
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
551
561
  }
@@ -1231,7 +1241,7 @@ async function writeAckFile(path, hash) {
1231
1241
  );
1232
1242
  }
1233
1243
  var SIGNER_NAME = "@haven_ai/signer";
1234
- var SIGNER_VERSION = "0.1.36-alpha.0";
1244
+ var SIGNER_VERSION = "0.2.0-alpha.0";
1235
1245
  async function resolveEdgeSigner(options = {}) {
1236
1246
  const { signer } = await resolveSignerRuntime(options);
1237
1247
  return signer;
@@ -1270,7 +1280,7 @@ function buildSignerMcpServer(signer, options = {}) {
1270
1280
  audit: {
1271
1281
  auditPath: options.auditPath ?? defaultSigningAuditPath(credentialsPath),
1272
1282
  delegateAddress: signer.delegateAddress,
1273
- safeAddress: options.credentials?.safeAddress,
1283
+ safeAddress: options.credentials?.accountAddress ?? options.credentials?.safeAddress,
1274
1284
  chainId: options.credentials?.chainId
1275
1285
  },
1276
1286
  // #1263: the payment_id signing path — the ONLY network call this server
@@ -1320,7 +1330,7 @@ async function runSignerConsentGate(signer, credentials, options) {
1320
1330
  return ensureSignerConsent(
1321
1331
  {
1322
1332
  delegateAddress: signer.delegateAddress,
1323
- safeAddress: credentials?.safeAddress,
1333
+ safeAddress: credentials?.accountAddress ?? credentials?.safeAddress,
1324
1334
  agentId: credentials?.agentId,
1325
1335
  chainId: credentials?.chainId,
1326
1336
  network: credentials?.network,
@@ -1341,6 +1351,6 @@ function toMcpResult(payload) {
1341
1351
  };
1342
1352
  }
1343
1353
 
1344
- export { SIGNER_ACK_ENV, SIGNER_CAPABILITY_KEY, SIGNER_NAME, SIGNER_VERSION, SUPPORTED_SWEEP_BINDING_VERSIONS, SUPPORTED_X402_EXPECTED_VERSIONS, appendSigningAuditEntry, assertSupportedBindingVersion, assertSupportedNodeVersion, assertX402MatchesExpected, buildSignerMcpServer, computeSignerConsentHash, createEdgeSigner, createSigningAuditEntry, createToolHandlers, defaultSigningAuditPath, ensureSignerConsent, hashPayloadForAudit, loadSignerCredentials, renderSignerConsentBlock, resolveEdgeSigner, resolveSignerRuntime, runSignerConsentGate, runSignerStdioServer, signerCapabilityAdvertisement, signerCompatibility, signerInstructions, toolDescriptions, toolSchemas, warnIfCredentialFilePermissive };
1354
+ export { SIGNER_ACK_ENV, SIGNER_CAPABILITY_KEY, SIGNER_NAME, SIGNER_VERSION, SUPPORTED_SWEEP_BINDING_VERSIONS, SUPPORTED_X402_EXPECTED_VERSIONS, appendSigningAuditEntry, assertSupportedBindingVersion, assertSupportedNodeVersion, assertX402MatchesExpected, buildSignerMcpServer, computeSignerConsentHash, createEdgeSigner, createSigningAuditEntry, createToolHandlers, defaultSigningAuditPath, ensureSignerConsent, hashPayloadForAudit, loadSignerCredentials, readAccountAddressEnv, readAccountAddressField, renderSignerConsentBlock, resolveEdgeSigner, resolveSignerRuntime, runSignerConsentGate, runSignerStdioServer, signerCapabilityAdvertisement, signerCompatibility, signerInstructions, toolDescriptions, toolSchemas, warnIfCredentialFilePermissive };
1345
1355
  //# sourceMappingURL=index.js.map
1346
1356
  //# sourceMappingURL=index.js.map