import { X402ExpectedAuth, X402PaymentRequired, X402PaymentOption, SweepAuthorization, SweepExpectedAuth, PermissionLog, HavenClientUpdate } from '@haven_ai/sdk/edge'; export { PermissionLog, PermissiveFile, deriveDelegateAccountAddress, permissiveMode, readAccountAddressEnv, readAccountAddressField } from '@haven_ai/sdk/edge'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { z as z$1 } from 'zod/v3'; import { Stats } from 'node:fs'; import { z } from 'zod'; /** * The edge signer core. * * Holds the delegate key in this process and exposes the signing operations a * hosted-MCP flow needs — six, none of them a raw-hash primitive (#3169): each * takes a payload something can check — a Haven binding verified here, typed * data the account validates on-chain, a sweep authorization, or (since * #3728) an EIP-4361 SIWX message composed in-package from grammar-validated * challenge fields. It performs no network I/O and never * returns the key — only signatures and the standard x402 header. See * docs/architecture/07-edge-signer.md. */ interface EdgeSigner { /** Address derived from the delegate key. */ readonly delegateAddress: string; /** * Sign a DIRECT delegation-rail payment's EIP-712 typed data (#1254) — the * non-x402 counterpart of `signX402FundingTypedData`. The Hybrid account * validates the typed data, not the bare ERC-4337 hash; raw-signing the * hash produced AA24 on-chain (found live, #908 mainnet canary). Signed * VERBATIM (#829): the exact structure the hosted result carried — and, * unlike a blind hash, a structure whose recipient/amount/account are * visible to this process's audit log. */ signDelegationTypedData(typedData: Record): Promise; /** * Sign a delegation-rail x402 funding intent's EIP-712 typed data (#1138) and * remember the funded merchant-header context — every x402 funding intent * now takes this path (#3272 criterion 8: the bare-hash v1 rail is * retired). * * The account validates this typed data, NOT a bare hash, so the expected * context must be v2/v3 and commit to its digest — see * `assertExpectedBinding`. `typedData` is `undefined` when the caller had * none to supply; that is itself refused (a v1 context that needed no typed * data is refused earlier, by the version check). */ signX402FundingTypedData(typedData: X402FundingTypedData | undefined, expected: X402ExpectedPayment): Promise; /** Build + sign the EIP-3009 X-PAYMENT header for the merchant leg of x402. */ buildX402PaymentHeader(paymentRequired: X402PaymentRequired, x402Binding: string): Promise; /** * Sign a Haven-prepared EIP-3009 sweep authorization (gasless USDC recovery * delegate → the agent's account (Haven wallet)). Verifies the authorization * came from Haven and pays out to the agent's account (Haven wallet) — the * account belongs to the agent, not the delegate — before signing; the * relayer broadcasts it and pays gas. Never broadcasts — pure signing. */ signSweepAuthorization(input: SweepSignatureInput): Promise; /** * Sign an EIP-4361 (SIWE) message with EIP-191 `personal_sign` (#3728) — * the x402 Sign-In-With-X extension. The message ALWAYS reaches this method * composed in-package by the tool layer (`siwx.ts`) from grammar-validated * challenge fields, with the address taken from this key — never a * caller-supplied string, hash or byte payload. The name is deliberately * SIWX-scoped, not a generic `signMessage`: the delegate key's EIP-191 * surface on this interface stays single-purpose. Breaking for * out-of-package `EdgeSigner` implementers (open question in #3728, * decided: acceptable — the only implementation is `createEdgeSigner`). */ signSiwxMessage(message: string): Promise; } interface SweepSignatureInput { /** The authorization fields prepared by the backend. */ authorization: SweepAuthorization; /** Haven's signature over the authorization context (binding). */ expectedAuth: SweepExpectedAuth; /** Optional account (Haven wallet) address from the local credential, cross-checked against `to` when present. */ expectedSafe?: string; } interface SweepSignatureResult { /** EIP-712 signature over the TransferWithAuthorization, by the delegate key. */ signature: string; } /** EIP-712 payload the delegation-rail account validates (#1138). */ interface X402FundingTypedData { domain: Record; types: Record; primaryType: string; message: Record; } interface X402ExpectedPayment { /** Haven payment id for the funding transfer. */ paymentId: string; /** Funding hash this expected context authenticates. */ payloadHash: string; /** * EIP-712 digest of the typed data the account validates (#1138). Present ⇒ * the binding is v2 and the delegation-rail typed-data path is the ONLY * signing path allowed for this intent. */ typedDataHash?: string; /** * Resource URL of the x402 payment Haven prepared. On the hosted surface * that is `haven_pay_x402_quote` — `buildX402SigningContext` in * `mcp-server/src/tools/support/mcp-context.ts` (called from the * `haven_pay_x402_quote` handler, which is still in `tools.ts`) relays * `intent.resourceUrl` here, and * `haven_resume_x402_payment` re-emits the same context. Checked against * the merchant header's resource in `assertX402MatchesExpected`. */ resourceUrl: string; /** * Merchant recipient of that same prepared payment (`intent.merchantTo`, * same source). Checked against the header's `payTo` in * `assertX402MatchesExpected` and, for an erc7710 settlement child, * against the child's payee caveat in `verifySettlementChild`. */ merchantTo: string; /** Atomic amount funded for the merchant header. */ amount: string; /** Token contract funded for the merchant header. */ asset: string; /** x402 network funded for the merchant header. */ network: string; /** ISO expiry for the funding/quote window. When present, the signer refuses stale merchant headers. */ expiresAt?: string; /** * The delegate address this quote was created FOR (#1690). Present ⇒ the * context is **version 3**, and the signer refuses to sign when it is not * its own delegate. Inside the Haven-signed message, so it cannot be * stripped or forged without breaking the binding signature. */ payerDelegate?: string; /** The paying agent's id — carried for the refusal's diagnosis (#1690). */ payerAgentId?: string; /** Haven signature over the expected funding context. */ auth: X402ExpectedAuth; } interface X402HeaderResult { /** The merchant-verifiable X-PAYMENT header value. */ paymentHeader: string; /** The x402 option this header pays. */ accepted: X402PaymentOption; } interface X402FundingSignatureResult { /** EIP-712 signature over the Haven-committed funding typed data. */ signature: string; /** Opaque process-local binding for the later merchant header signing step. */ x402Binding: string; } interface EdgeSignerOptions { /** Address allowed to authenticate x402 expected-context messages from Haven. */ x402BindingSigner?: string; /** * This signer's OWN agent id, from the local credential (#1690). Used only * to make the payer-mismatch refusal name both sides; the guard itself * compares delegate addresses and works without it. */ agentId?: string; } declare function createEdgeSigner(delegateKey: string, options?: EdgeSignerOptions): EdgeSigner; declare function assertX402MatchesExpected(paymentRequired: X402PaymentRequired, option: X402PaymentOption, expected: X402ExpectedPayment): void; /** * Expected-context binding versions THIS signer understands (#1143). * * The backend deploys continuously from `dev`; a signer reaches users only on a * merge to `main` (the publish workflow). So a signer that is one release behind * a context bump is a structural state, not an accident, and it needs to report * itself as one. These sets are the signer's authority on what it will sign — * the tool schemas deliberately accept any positive integer so an unknown * version arrives *here* instead of dying at the schema boundary with a raw * validation string. * * **Adding a version here is not sufficient to support it.** The rules in * `assertExpectedBinding` derive the expected version from the context's * *contents* (`payerDelegate` present ⇒ 3, else 2 — `typedDataHash` is * required unconditionally, #3272), not from `auth.version`, so a v4 that * carries anything new needs that derivation extended in the same change. * Widening this array alone would admit a v4 context to the v2/v3 rule set: * the array announces what this signer can evaluate, it does not define it. */ declare const SUPPORTED_X402_EXPECTED_VERSIONS: readonly number[]; declare const SUPPORTED_SWEEP_BINDING_VERSIONS: readonly number[]; /** * Fail closed on a binding version this signer does not understand, with an * error that names the received version, the ceiling this signer supports, and * the fix — both as PROSE (`message`, unchanged since #1143) and, since #1309, * as MACHINE-READABLE fields on the thrown error itself * (`HavenUnsupportedSignerVersionError`): `code`, `supportedVersions`, * `receivedVersion`, `fallback`. The tool boundary (`normalizeError` in * `tools.ts`) relays those fields verbatim instead of leaving an agent to * regex-parse this prose, which is the diagnosability gap * `docs/operations/mcp-runtime-compatibility.md` documents. * * `supportedVersions`/`receivedVersion` are DERIVED from this call's own * arguments — never a second literal — so they cannot drift from * `SUPPORTED_X402_EXPECTED_VERSIONS` / `SUPPORTED_SWEEP_BINDING_VERSIONS`, * which is what the signing path always passes in. * * The version travels inside the Haven-signed binding message, so the message * also tells the caller not to "fix" it by rewriting the field — an agent that * does would invalidate the signature and misrepresent what Haven declared. * That instruction is NOT weakened by structuring the refusal: this function * still throws before any content check runs, and nothing is ever signed. * * #2347: that word was "authorised" until this change, and the reading was * always the correct one — Haven does sign this message. It is now "declared", * the word the settlement-child verifier (`@haven_ai/sdk`'s `settlement-child.ts`) already uses for this exact binding ("proves * Haven *declared* a payload … it says nothing about what the payload MEANS"), * because on an agent-facing refusal inside a payment flow the broader word * invites the #2334 misreading that Haven is what authorises the spend. It is * not; the owner-signed delegation and its on-chain caveat are. The property * claimed is unchanged — only the verb naming it. Full argument in * `docs/regulatory/casp-changelog/2026-09-01-2347.md`. * * Exported so a test can pin the historical case (a v2 context against a signer * whose set was `{1}`) that this signer can no longer produce on its own. The * signing path always passes the module constants above. */ declare function assertSupportedBindingVersion(received: number, supported: readonly number[], context: 'x402 expected context' | 'sweep authorization binding'): void; /** * Pre-payment skew detection (#1155). * * #1143 made a stale signer say so — but only at the signing step, after the * agent had already quoted and was one call away from funding. This module * moves the same information to the `initialize` handshake, so the set of * expected-context versions this signer understands is observable *before* a * payment is attempted. * * **The check is necessarily agent-mediated.** The signer and the hosted Haven * MCP are two separate servers connected to the same client; neither can * introspect the other. The signer's Haven reads (#1263's read-only * `GET /x402/:payment_id/sign-context` and #3271's direct-payment * `GET /payments/:payment_id/sign-context`, both in `sign-context.ts`) do not help * here: each fetches one payment's signing bytes, not the hosted server's * handshake, and it happens at signing time — after the quote this module * exists to get ahead of. So only the agent sees both handshakes, and what * ships here is the *information* plus the prompt to compare it — never a * server-side gate. A mismatch is advisory: the enforcement point remains the * #1143 signing-time guard, which is unchanged. * * Everything below is DERIVED from the two constants in `core.ts` that the * signing path actually enforces. A second hand-maintained literal is the one * way this feature could become a lie, so there isn't one — including inside * the human-readable `instructions` string, which renders the same arrays. */ /** * Vendor-prefixed key under MCP's `capabilities.experimental`. * * `experimental` rather than the newer `extensions` field deliberately: both are * `Record` in `@modelcontextprotocol/sdk@1.29`, but a client on * an older SDK parses the `initialize` result with a `ServerCapabilities` schema * that has no `extensions` key, and Zod's default object behaviour would strip * it. `experimental` has been in the schema since the beginning, so it survives * an old client — which is precisely the population this feature exists for. */ declare const SIGNER_CAPABILITY_KEY = "haven/signer-compatibility"; interface SignerCompatibility { /** Expected-context versions this signer will verify (`SUPPORTED_X402_EXPECTED_VERSIONS`). */ x402_expected_context_versions: number[]; /** Sweep-binding versions this signer will verify (`SUPPORTED_SWEEP_BINDING_VERSIONS`). */ sweep_binding_versions: number[]; /** * #3271: `direct_sign_context_version`s this signer will fetch and verify * from `GET /payments/:id/sign-context` — derived from the SDK's * `DIRECT_SIGN_CONTEXT_VERSION` via `SUPPORTED_DIRECT_SIGN_CONTEXT_VERSIONS`, * never a second literal. */ direct_sign_context_versions: number[]; /** * #3329: `task_sign_context_version`s this signer will fetch and verify * from `GET /task-budgets/:id/sign-context` — derived from * `SUPPORTED_TASK_SIGN_CONTEXT_VERSIONS`, never a second literal, same * discipline as `direct_sign_context_versions`. */ task_sign_context_versions: number[]; /** * #3506: `sub_budget_sign_context_version`s this signer will fetch and * verify from `GET /sub-budgets/:id/sign-context` — derived from * `SUPPORTED_SUB_BUDGET_SIGN_CONTEXT_VERSIONS`, never a second literal. * Additive: 0.7.0 already signed sub-budgets but did not say so here. */ sub_budget_sign_context_versions: number[]; } /** The supported sets this signer enforces, as a plain serialisable object. */ declare function signerCompatibility(): SignerCompatibility; /** * The machine-readable half: `capabilities.experimental['haven/signer-compatibility']`, * returned verbatim in the `initialize` result. * * `ServerCapabilities.experimental` is typed `z.record(z.string(), )` * and the SDK's `mergeCapabilities` deep-merges per top-level key, so declaring * this at construction survives the `tools` capability `McpServer` registers * when the first tool is added. */ declare function signerCapabilityAdvertisement(): { experimental: Record; }; interface SignerIdentity { /** The credential file's `agent_id`, or `HAVEN_AGENT_ID`; absent when neither is set. */ agentId?: string; /** The delegate key's address — always known, since the signer holds the key. */ delegateAddress?: string; } /** * The agent-readable half: MCP `instructions`, which clients surface to the * model. The machine-readable capability above is the precise statement, but * most agent runtimes never expose `capabilities.experimental` to the model — * this string is what actually reaches the reader who has to make the call. * * It names the same fix as #1143 so an agent that hits either surface — the * handshake here or the signing-time error there — tells the user the same * thing. * * Since #3738 it also states the agent id and delegate address this signer is * bound to, when `identity` is given. */ declare function signerInstructions(identity?: SignerIdentity): string; /** * The edge signer's own credential requires *only* `delegate_key` — unlike * `@haven_ai/mcp`, no `api_key` belongs in this file. * * That is a claim about this credential, not about the process, and the * difference matters: the sentence that used to stand here ("it does not call * the Haven API") was retired by #1263. The MCP server layer does make at * most two authenticated reads per signing call — a read-only * `GET /x402/:payment_id/sign-context` and, for a direct payment via * `haven_sign` since #3271, then `GET /payments/:payment_id/sign-context`, see * `sign-context.ts` — and it reads the `api_url` / `api_key` for them from a * SEPARATE `identity.json` in the same directory as the credential file * resolved here. That is why `sourcePath` below is load-bearing rather than * diagnostic, and why a key supplied through `HAVEN_DELEGATE_KEY` alone (no * file, so no directory) leaves that path with no identity to load and the * process making no network calls at all. The delegate key read here is never * part of any request or response either way. */ interface SignerCredentials { delegateKey: string; agentId?: string; /** The Haven account (smart account) the agent spends from. */ accountAddress?: string; chainId?: number; network?: string; x402BindingSigner?: string; /** Absolute path the key was loaded from, if a file was used. */ sourcePath?: string; } /** * Resolve the delegate key for the edge signer. * * Order — earlier wins: * 1. Explicit `path` (e.g. `--credentials `). * 2. `HAVEN_CREDENTIALS` env var pointing at a credential JSON file. * 3. `HAVEN_DELEGATE_KEY` env var. * * The same credential JSON the dashboard emits works here — we just read its * `delegate_key` and ignore the rest. */ declare function loadSignerCredentials(path?: string | undefined): Promise; /** * Warn (best-effort, POSIX only) when the credential file is readable beyond * its owner. The check itself is shared with `@haven_ai/mcp` (#4792); the * `haven-signer:` prefix and the exact message are unchanged. * * Exported for testing. */ declare function warnIfCredentialFilePermissive(path: string, log?: (message: string) => void, platform?: NodeJS.Platform): Promise; /** Owner-only: the mode every file this package writes beside a credential gets. */ declare const OWNER_ONLY_MODE = 384; /** * Warn (best-effort, POSIX only) when a file this signer READS is readable * beyond its owner. The signer does not own the credential, so it tells the * operator what to run rather than changing a file it was handed. Follows a * symlink, as the pre-#3172 `stat` did: a link to a 0600 credential is fine. */ declare function warnIfFilePermissive(kind: string, path: string, log?: PermissionLog, platform?: NodeJS.Platform): Promise; type TightenOutcome = 'owner-only' | 'tightened' | 'warned' | 'skipped'; /** * Tighten a file this signer WRITES to owner-only when it finds it * permissive (#3172): the audit sidecar was created with the default mode * (0644 under the usual umask 022) by every release before this one, so an * existing sidecar is fixed in place rather than warned about. Judged with * `lstat`. Falls back to the warning when the path is not a regular file (a * symlink would make chmod hit whatever it points at) or when chmod is * refused (a file owned by another user). Outcomes: `tightened` / `warned` * as above; `owner-only` when there is nothing to tighten (owner-only file, * or no file at that path); `skipped` on Windows only. */ declare function tightenIfFilePermissive(kind: string, path: string, log?: PermissionLog, platform?: NodeJS.Platform, stats?: Stats): Promise; /** * #3172: the sidecar is bounded. When it reaches this size the current file is * renamed to `.1` (replacing the previous `.1`) and a fresh file starts, * so at most two generations — the live file and one predecessor — ever exist. * 8 MiB is roughly 30 000 entries at the ~270-byte row size; nothing in the * signer reads the file back, so the bound protects the disk and the reader's * patience, never a signing decision. */ declare const AUDIT_ROTATE_BYTES: number; interface AppendAuditOptions { /** Where permission notices go; defaults to stderr. */ log?: PermissionLog; /** Rotation threshold in bytes; exported default `AUDIT_ROTATE_BYTES`. */ rotateAtBytes?: number; platform?: NodeJS.Platform; } interface SigningAuditEntry { version: 1; timestamp: string; tool: SignerToolName; payload_hash: string; delegate_address: string; /** * Serialized key kept as `safe_address` deliberately (#2914 review): this * is a persisted JSONL field, and an audit log written by an earlier * release never rewrites itself — renaming the key here would fork the * format mid-file. `SigningAuditContext.accountAddress` (the in-memory * field this is built from) carries the account-vocabulary name; only the * on-disk spelling stays put. */ safe_address?: string; chain_id?: number; /** * #3728, additive like `chain_id` and the persisted serialized key declared * above: present on SIWX entries only — the challenge domain and nonce the * composed message committed to. The `payload_hash` already pins the exact * composed message (its sha256, pre-signature), so an entry is replayable * without these; they make a sign-in row scannable without re-deriving the * message. No existing key renamed (#2914). */ domain?: string; nonce?: string; } interface SigningAuditContext { delegateAddress: string; accountAddress?: string; chainId?: number; auditPath?: string; /** #3728, SIWX entries only: the challenge domain, emitted onto the row. */ domain?: string; /** #3728, SIWX entries only: the challenge nonce, emitted onto the row. */ nonce?: string; } declare function defaultSigningAuditPath(credentialsPath?: string): string; declare function appendSigningAuditEntry(entry: SigningAuditEntry, path: string, options?: AppendAuditOptions): Promise; declare function createSigningAuditEntry(tool: SignerToolName, payloadHash: string, context: SigningAuditContext, now?: Date): SigningAuditEntry; declare function hashPayloadForAudit(payload: unknown): string; interface HavenIdentity { apiUrl: string; apiKey: string; } /** * #3103 (epic #3105, slice 4/5): the signer's typed next step. * * The signer decides a `next_action` on its refusals and, until this module, * never said which tool to call. It cannot know the client's server names * (#2550), so the handoff is expressed through the role fields the SDK * builder renders — `next_tool_server_role: hosted`, `next_tool_name` — from * a bare tool name. The signer must not import the hosted server (it is an * npm package installed on user machines; the hosted server is a Docker * deployment), so the hosted tools it hands off to are DECLARED here as the * argument shape the signer actually emits, and `next-step-signer-parity` * in the hosted server's own suite pins them to the hosted schemas at test * time — the mirror of how the hosted server declares the signer's shapes. */ declare const SIGNER_HOSTED_HANDOFF_SHAPES: { readonly haven_get_payment_status: { readonly payment_id: z.ZodString; }; readonly 'haven_submit#task_budget': { readonly task_budget_id: z.ZodString; readonly signature: z.ZodString; }; readonly 'haven_submit#sub_budget': { readonly sub_budget_id: z.ZodString; readonly signature: z.ZodString; }; readonly 'haven_submit#payment': { readonly payment_id: z.ZodString; readonly signature: z.ZodString; }; readonly 'haven_sweep_delegate#sweep': { readonly authorization: z.ZodObject<{ from: z.ZodString; to: z.ZodString; value: z.ZodString; validAfter: z.ZodString; validBefore: z.ZodString; nonce: z.ZodString; token: z.ZodString; chainId: z.ZodNumber; }, "strip", z.ZodTypeAny, { value: string; from: string; to: string; validAfter: string; validBefore: string; nonce: string; token: string; chainId: number; }, { value: string; from: string; to: string; validAfter: string; validBefore: string; nonce: string; token: string; chainId: number; }>; readonly signature: z.ZodString; }; }; /** * The signer's wire identity. Declared HERE, in the tools/handlers module — * `server.ts` (the MCP wiring) imports them from this module, keeping the * import graph one-directional (tools.ts ← server.ts, never the reverse); * `server.ts` re-exports them, so the package's public API is unchanged. */ declare const SIGNER_NAME = "@haven_ai/signer"; declare const SIGNER_VERSION = "0.14.0-alpha.0"; /** * #3419: the marker the tool layer prefixes the undeclared-argument refusal * with. The strict re-parse lives in THIS module (`parseStrictFor`, below) — * the same module as the `normalizeError` branch that shapes the refusal — so * the marker, the message and the structured fields are one unit and cannot * drift. The registration in `server.ts` is passthrough (the issue's "schema * that keeps unknown keys"): the SDK layer lets an undeclared key through and * the tool layer refuses it here, where the full structured refusal * (`UNSUPPORTED_ARGUMENT` with `unknown_arguments`, `signer_version`, * `fallback`) is still expressible as JSON on the result. */ declare const UNSUPPORTED_ARGUMENT_MARKER = "HavenSignerUnsupportedArgument:"; /** * Local signer tool set. These run on the agent's machine, next to the key, * and pair with the hosted server's construct/relay tools (#183). They sign; * they never call the Haven API and never emit the key. */ type SignerToolName = 'haven_sign' | 'haven_sign_siwx' | 'haven_x402_sign_header' | 'haven_sign_x402' | 'haven_sign_sweep_delegate'; declare const toolSchemas: { readonly haven_sign_sweep_delegate: { readonly authorization: z$1.ZodObject<{ from: z$1.ZodString; to: z$1.ZodString; value: z$1.ZodString; validAfter: z$1.ZodString; validBefore: z$1.ZodString; nonce: z$1.ZodString; token: z$1.ZodString; chainId: z$1.ZodNumber; }, "strip", z$1.ZodTypeAny, { value: string; from: string; to: string; validAfter: string; validBefore: string; nonce: string; token: string; chainId: number; }, { value: string; from: string; to: string; validAfter: string; validBefore: string; nonce: string; token: string; chainId: number; }>; readonly expected_auth: z$1.ZodObject<{ version: z$1.ZodNumber; message: z$1.ZodString; signature: z$1.ZodString; signer: z$1.ZodString; }, "strip", z$1.ZodTypeAny, { message: string; signature: string; signer: string; version: number; }, { message: string; signature: string; signer: string; version: number; }>; }; readonly haven_sign: { readonly payment_id: z$1.ZodOptional; readonly payload_hash: z$1.ZodOptional; readonly x402_expected: z$1.ZodOptional; payer_delegate: z$1.ZodOptional; payer_agent_id: z$1.ZodOptional; auth: z$1.ZodObject<{ version: z$1.ZodNumber; message: z$1.ZodString; signature: z$1.ZodString; signer: z$1.ZodString; }, "strip", z$1.ZodTypeAny, { message: string; signature: string; signer: string; version: number; }, { message: string; signature: string; signer: string; version: number; }>; }, "strip", z$1.ZodTypeAny, { payment_id: string; network: string; expires_at: string; payload_hash: string; resource_url: string; merchant_to: string; amount: string; asset: string; auth: { message: string; signature: string; signer: string; version: number; }; typed_data_hash?: string | undefined; payer_delegate?: string | undefined; payer_agent_id?: string | undefined; }, { payment_id: string; network: string; expires_at: string; payload_hash: string; resource_url: string; merchant_to: string; amount: string; asset: string; auth: { message: string; signature: string; signer: string; version: number; }; typed_data_hash?: string | undefined; payer_delegate?: string | undefined; payer_agent_id?: string | undefined; }>>; readonly typed_data: z$1.ZodOptional>; readonly typed_data_b64: z$1.ZodOptional; readonly task_budget_id: z$1.ZodOptional; readonly sub_budget_id: z$1.ZodOptional; }; readonly haven_x402_sign_header: { readonly payment_required: z$1.ZodRecord; readonly x402_binding: z$1.ZodString; }; readonly haven_sign_x402: { readonly payment_id: z$1.ZodOptional; readonly payload_hash: z$1.ZodOptional; readonly x402_expected: z$1.ZodOptional; payer_delegate: z$1.ZodOptional; payer_agent_id: z$1.ZodOptional; auth: z$1.ZodObject<{ version: z$1.ZodNumber; message: z$1.ZodString; signature: z$1.ZodString; signer: z$1.ZodString; }, "strip", z$1.ZodTypeAny, { message: string; signature: string; signer: string; version: number; }, { message: string; signature: string; signer: string; version: number; }>; }, "strip", z$1.ZodTypeAny, { payment_id: string; network: string; expires_at: string; payload_hash: string; resource_url: string; merchant_to: string; amount: string; asset: string; auth: { message: string; signature: string; signer: string; version: number; }; typed_data_hash?: string | undefined; payer_delegate?: string | undefined; payer_agent_id?: string | undefined; }, { payment_id: string; network: string; expires_at: string; payload_hash: string; resource_url: string; merchant_to: string; amount: string; asset: string; auth: { message: string; signature: string; signer: string; version: number; }; typed_data_hash?: string | undefined; payer_delegate?: string | undefined; payer_agent_id?: string | undefined; }>>; readonly payment_required: z$1.ZodOptional>; readonly typed_data: z$1.ZodOptional>; readonly typed_data_b64: z$1.ZodOptional; }; readonly haven_sign_siwx: { readonly url: z$1.ZodString; readonly challenge: z$1.ZodRecord; }; }; declare const toolDescriptions: Record; interface ToolSuccess { success: true; data: T; } interface ToolFailure { success: false; code: string; message: string; statusCode?: number; paymentId?: string; next_action?: string; retry_with_new_quote?: boolean; suggested_tool?: string; /** #3101 (epic #3105, decision 7): the typed next-step family, additive; `next_tool` never null. */ next_tool?: string; next_tool_server?: string; next_tool_name?: string; next_tool_server_role?: 'hosted' | 'signer'; next_arguments?: Record; next_tool_omitted_reason?: string; /** * #1309: present on `UNSUPPORTED_EXPECTED_CONTEXT_VERSION` / * `UNSUPPORTED_SWEEP_BINDING_VERSION` refusals — the exact version set this * signer install enforces, derived from `SUPPORTED_X402_EXPECTED_VERSIONS` / * `SUPPORTED_SWEEP_BINDING_VERSIONS` at the throw site. */ supported_versions?: number[]; /** #1309: the version Haven sent that triggered the refusal above. */ received_version?: number; /** * #1309: precise recovery guidance as DATA, not just prose inside `message` * — the same text the hosted quote's advisory `signer_compatibility.fallback` * carries when the refusal is an out-of-date signer. #3001 reuses this same * field for every sign-context refusal (`'typed_data_b64'`). */ fallback?: string; /** * #3419: present on `UNSUPPORTED_ARGUMENT` — the undeclared top-level * argument names the caller sent (the strict schema's `unrecognized_keys`), * so an agent can see exactly what this signer does not accept. */ unknown_arguments?: string[]; /** #3419: present on `UNSUPPORTED_ARGUMENT` — this signer's own package version. */ signer_version?: string; /** * #3001: present on `SIGN_CONTEXT_REFUSED` — the HTTP status the backend * answered the sign-context fetch with (404, 410, …) — the x402 fetch, or * the direct `/payments/:id/sign-context` fetch since #3271. */ http_status?: number; /** #3001: the backend's own `error_code` on `SIGN_CONTEXT_REFUSED` (`expired`, `already_executed`, `not_signable`, `sign_context_unavailable`, and since #3303 `client_outdated`). */ backend_error_code?: string; /** #3303: on `client_outdated`, the backend's update hint — `upgrade_command` starts the update (the doctor, then its repair line — #3412). */ client_update?: HavenClientUpdate; } type ToolPayload = ToolSuccess | ToolFailure; interface ToolHandlerOptions { audit?: SigningAuditContext & { auditPath: string; }; /** * #1263: how the payment_id signing path reaches Haven. Lives at the MCP * server layer (the core stays network-free); absent → payment_id calls * refuse with a message naming the typed_data_b64 fallback. */ signContext?: { loadIdentity: () => Promise; fetchImpl?: typeof fetch; /** #3303: `@haven_ai/signer/`, sent as `X-Haven-Client` on every sign-context read. */ clientIdentity?: string; }; } declare function createToolHandlers(signer: EdgeSigner, options?: ToolHandlerOptions): Record Promise>; interface SignerConsentInput { delegateAddress: string; accountAddress?: string; agentId?: string; chainId?: number; network?: string; toolNames: readonly SignerToolName[]; } interface SignerConsentDecision { ok: boolean; hash: string; reason: 'env_var_match' | 'ack_file_match' | 'wrote_ack_file' | 'env_var_mismatch' | 'no_acknowledgement'; } interface SignerConsentOptions { credentialsPath?: string; writeAck?: boolean; env?: Record; out?: { write: (chunk: string) => unknown; }; } declare const SIGNER_ACK_ENV = "HAVEN_SIGNER_ACK"; declare function computeSignerConsentHash(input: SignerConsentInput): string; declare function renderSignerConsentBlock(input: SignerConsentInput, hash: string): string; declare function ensureSignerConsent(input: SignerConsentInput, options?: SignerConsentOptions): Promise; interface SignerOptions { /** Path to a Haven credential JSON file (delegate_key is read from it). */ credentialsPath?: string; /** Pre-resolved delegate key (skips credential loading). */ delegateKey?: string; /** Append local signing audit entries here. Defaults to a credential sidecar or ~/.haven. */ auditPath?: string; /** Overridable so the Node-floor refusal is testable without spawning a Node. */ nodeVersion?: string; /** * When true, write the consent sidecar file (`.signer-ack.json`) * with the current consent hash and proceed. Surfaced via the `--ack` CLI flag. */ writeAck?: boolean; /** * When true, skip the consent gate entirely. Reserved for tests and controlled * embedding — production CLIs should not set this. */ skipConsent?: boolean; /** Override consent environment lookup. Reserved for tests and controlled embedding. */ consentEnv?: Record; /** Override the stream the consent block is printed to. Reserved for tests. */ consentOut?: { write: (chunk: string) => unknown; }; /** Trusted Haven signer address for x402 expected-context bindings. */ x402BindingSigner?: string; } declare function resolveEdgeSigner(options?: SignerOptions): Promise; interface ResolvedSignerRuntime { signer: EdgeSigner; credentials?: SignerCredentials; } declare function resolveSignerRuntime(options?: SignerOptions): Promise; /** * Build a local stdio MCP server exposing the sign-only tools, bound to an * edge signer that holds the delegate key. It exposes no construct/relay * tools — it only signs. Its ONE network capability (#1263) is an * authenticated READ: fetching a payment's exact signing context from Haven * by payment_id, so agents never have to relay multi-KB signing payloads * through a model context. The signer CORE below it stays network-free, and * fetched bytes pass the same verification as tool-argument bytes. */ declare function buildSignerMcpServer(signer: EdgeSigner, options?: Pick & { credentials?: SignerCredentials; }): McpServer; /** * Refuse to start on an unsupported Node (#1161). * * Asserted at STARTUP, not only at install, because the two can diverge: a user * upgrades Node, connects successfully, then downgrades — or a version manager * hands the agent runtime a different Node than the shell that ran setup. Only a * startup check sees the version this process is actually running on. * * This is the signer, so refusing is the conservative answer rather than the * aggressive one. It holds the delegate key and produces every payment * signature; on an unsupported runtime the plausible failure is a wrong or * absent signature, which is worse than not starting. The consent gate below * takes the same posture for the same reason. */ declare function assertSupportedNodeVersion(nodeVersion?: string): void; declare function runSignerStdioServer(options?: SignerOptions): Promise; declare function runSignerConsentGate(signer: EdgeSigner, credentials: SignerCredentials | undefined, options: SignerOptions): Promise; export { AUDIT_ROTATE_BYTES, type AppendAuditOptions, type EdgeSigner, OWNER_ONLY_MODE, type ResolvedSignerRuntime, SIGNER_ACK_ENV, SIGNER_CAPABILITY_KEY, SIGNER_HOSTED_HANDOFF_SHAPES, SIGNER_NAME, SIGNER_VERSION, SUPPORTED_SWEEP_BINDING_VERSIONS, SUPPORTED_X402_EXPECTED_VERSIONS, type SignerCompatibility, type SignerConsentDecision, type SignerConsentInput, type SignerConsentOptions, type SignerCredentials, type SignerIdentity, type SignerOptions, type SignerToolName, type SigningAuditContext, type SigningAuditEntry, type TightenOutcome, type ToolFailure, type ToolPayload, type ToolSuccess, UNSUPPORTED_ARGUMENT_MARKER, 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, tightenIfFilePermissive, toolDescriptions, toolSchemas, warnIfCredentialFilePermissive, warnIfFilePermissive };