@haven_ai/sdk 0.0.0-dev.202609182134.2018100 → 0.0.0-dev.202609190328.55ffe63
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/README.md +1 -0
- package/dist/index.cjs +60 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -3
- package/dist/index.d.ts +82 -3
- package/dist/index.js +60 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,6 +79,7 @@ shows up in your Haven dashboard activity feed.
|
|
|
79
79
|
- The delegate key signs payment payloads locally. Haven's backend never receives it.
|
|
80
80
|
- The agent's on-chain budget delegation enforces the agent budget: budget, recipient and expiry are checked by audited caveat enforcers at redemption, not by an off-chain rules engine.
|
|
81
81
|
- `getAllowances()` / `get_allowances` is the right path for budget, remaining amount, reset period, or "what can I spend?" questions.
|
|
82
|
+
- `checkFunds()` / `haven_check_funds` answers the different question of whether the account actually holds funds behind the budget — as a sufficiency signal (`covered` true/false/null), never as a balance.
|
|
82
83
|
- If an API key is exposed or lost, rotate it from the Haven agent detail page. The new key is shown once and the old key stops working.
|
|
83
84
|
- If a delegate key is exposed or lost, a delegation-rail agent is **re-keyed** rather than replaced — same agent, new signing key, budget remainder carried. See [Replacing an agent's signing key](../../docs/product/agent-key-rotation.md).
|
|
84
85
|
|
package/dist/index.cjs
CHANGED
|
@@ -1810,6 +1810,33 @@ var AccountReads = class {
|
|
|
1810
1810
|
}))
|
|
1811
1811
|
};
|
|
1812
1812
|
}
|
|
1813
|
+
/**
|
|
1814
|
+
* #3126 — the sufficiency signal behind {@link HavenBalanceCoverage}.
|
|
1815
|
+
*
|
|
1816
|
+
* Deliberately NOT a balance read: the endpoint answers whether the
|
|
1817
|
+
* account HOLDS at least the checked amount, as `covered
|
|
1818
|
+
* true/false/null`, and never returns the balance itself. The camelCase
|
|
1819
|
+
* mapping is permissive (raw fields flow through; the server owns the
|
|
1820
|
+
* wire shape, pinned by the backend's `expectMatchesSpec` assertion), so
|
|
1821
|
+
* an older server that has not deployed the endpoint surfaces its 404 as
|
|
1822
|
+
* a thrown error rather than a fabricated answer.
|
|
1823
|
+
*/
|
|
1824
|
+
async checkFunds(input) {
|
|
1825
|
+
const query = `token=${encodeURIComponent(input.token)}&amount_atomic=${encodeURIComponent(input.amountAtomic)}`;
|
|
1826
|
+
const raw = await this.transport.get(
|
|
1827
|
+
`/machine-payments/balance-coverage?${query}`
|
|
1828
|
+
);
|
|
1829
|
+
return {
|
|
1830
|
+
covered: raw.covered,
|
|
1831
|
+
...raw.coverage_error !== void 0 ? { coverageError: raw.coverage_error } : {},
|
|
1832
|
+
chainId: raw.chain_id,
|
|
1833
|
+
tokenAddress: raw.token_address,
|
|
1834
|
+
tokenSymbol: raw.token_symbol,
|
|
1835
|
+
checkedAmountAtomic: raw.checked_amount_atomic,
|
|
1836
|
+
budgetRemainingAtomic: raw.budget_remaining_atomic,
|
|
1837
|
+
...raw.budget_remaining_is_from_chain !== void 0 ? { budgetRemainingIsFromChain: raw.budget_remaining_is_from_chain } : {}
|
|
1838
|
+
};
|
|
1839
|
+
}
|
|
1813
1840
|
async getPostPurchaseAllowanceSummary(paymentId) {
|
|
1814
1841
|
const unavailable = (detail, payment2 = null) => ({
|
|
1815
1842
|
payment: payment2,
|
|
@@ -3541,6 +3568,21 @@ var HavenClient = class {
|
|
|
3541
3568
|
async getAllowances() {
|
|
3542
3569
|
return this.accountReads.getAllowances();
|
|
3543
3570
|
}
|
|
3571
|
+
/**
|
|
3572
|
+
* #3126 — is the checked amount of the token actually HELD on the
|
|
3573
|
+
* agent's own account?
|
|
3574
|
+
*
|
|
3575
|
+
* This is the companion to {@link getAllowances}, not a variant of it:
|
|
3576
|
+
* allowances answer what the agent is PERMITTED to spend this period;
|
|
3577
|
+
* this answers whether the account HOLDS funds behind that permission,
|
|
3578
|
+
* as a sufficiency signal — `covered: true | false | null` — never as a
|
|
3579
|
+
* balance. `covered: null` means the chain read failed: treat it as
|
|
3580
|
+
* unverifiable, not as absence (`coverageError` says why). The account's
|
|
3581
|
+
* balance itself is deliberately not returned.
|
|
3582
|
+
*/
|
|
3583
|
+
async checkFunds(input) {
|
|
3584
|
+
return this.accountReads.checkFunds(input);
|
|
3585
|
+
}
|
|
3544
3586
|
/**
|
|
3545
3587
|
* `POST /machine-payments/budget-precheck` (#3054): ask Haven to decide —
|
|
3546
3588
|
* server-side — whether `amountAtomic` of `token` fits the agent's
|
|
@@ -4339,10 +4381,18 @@ var toolDescriptions = {
|
|
|
4339
4381
|
},
|
|
4340
4382
|
getAllowances: {
|
|
4341
4383
|
summary: "Return configured and on-chain allowance state for the authenticated agent. On-chain allowance is the real spend gate.",
|
|
4342
|
-
selectionGuidance: "Use this when the user asks about allowance, budget, spend limit, remaining amount, remaining allowance, remaining budget, daily limit, reset period, what can I spend, or what the agent can still spend.",
|
|
4384
|
+
selectionGuidance: "Use this when the user asks about allowance, budget, spend limit, remaining amount, remaining allowance, remaining budget, daily limit, reset period, what can I spend, or what the agent can still spend. For whether the account actually HOLDS funds behind the budget use haven_check_funds.",
|
|
4343
4385
|
behavior: "Returns the per-token spend authority for the account: the active budget delegation (remaining = the period budget, which re-arms natively at the period boundary), each with id, onchain.remaining, remainingDisplay. An over-budget payment is declined before any money moves; nothing queues. Configured amounts from Haven are returned alongside.",
|
|
4344
4386
|
nextActionGuidance: ""
|
|
4345
4387
|
},
|
|
4388
|
+
// #3126 — the sufficiency signal, deliberately NOT a balance tool. The
|
|
4389
|
+
// constrained actor reads a boolean, never the treasury total.
|
|
4390
|
+
checkFunds: {
|
|
4391
|
+
summary: "Check whether the agent's account actually holds at least the given amount of a token \u2014 funds held, not spend permitted.",
|
|
4392
|
+
selectionGuidance: "Use this before attempting a payment when it matters whether the money is really there: allowance answers say what you are PERMITTED to spend, never whether the account HOLDS it. For allowance, budget, spend-limit, remaining-budget, reset-period, or what-can-I-spend questions use the allowance lookup tool instead.",
|
|
4393
|
+
behavior: "Returns covered: true (the account holds at least the checked amount), false (a live chain read reports less \u2014 the budget is backed by an empty account; stop and tell the user funds are missing), or null (the chain read failed \u2014 unverifiable, never treat it as absence; coverageError says why). The account balance itself is deliberately not returned: this is a sufficiency signal, not a balance read. budget_remaining_atomic is the permitted figure from the allowance lookup (the SDK spells it budgetRemainingAtomic), named so it can never be confused with holdings.",
|
|
4394
|
+
nextActionGuidance: "On covered=false, do not attempt the payment \u2014 tell the user the account is short and let them fund it; on covered=null, retry the check shortly or proceed knowing the payment may fail on-chain."
|
|
4395
|
+
},
|
|
4346
4396
|
listReceipts: {
|
|
4347
4397
|
summary: "List machine-payment receipts, newest first, by page.",
|
|
4348
4398
|
selectionGuidance: "For transaction history or payment evidence; use the allowance tool instead for remaining allowance or what-can-I-spend questions.",
|
|
@@ -4375,13 +4425,13 @@ var toolDescriptions = {
|
|
|
4375
4425
|
},
|
|
4376
4426
|
sweep_delegate: {
|
|
4377
4427
|
summary: "Sweep stranded USDC and/or ETH from the delegate wallet back to the originating account.",
|
|
4378
|
-
selectionGuidance: "Use this when the user instructs you to recover stranded funds on the delegate wallet, or when a payment status returns nextAction=sweep_stranded_funds. Do NOT use for normal payments \u2014 use haven_pay_x402. Do NOT use to read balances only \u2014 use haven_get_allowances.",
|
|
4428
|
+
selectionGuidance: "Use this when the user instructs you to recover stranded funds on the delegate wallet, or when a payment status returns nextAction=sweep_stranded_funds. Do NOT use for normal payments \u2014 use haven_pay_x402. Do NOT use to read balances only \u2014 use haven_get_allowances, or haven_check_funds for whether the account holds funds.",
|
|
4379
4429
|
behavior: `Reads the delegate EOA's on-chain USDC and ETH balances. For each non-zero balance, signs and submits a transfer from the delegate EOA to the originating account (hardcoded destination). The delegate key signs locally \u2014 Haven never sees it and the backend never constructs signed transactions (CASP/MiCA Red Line #2). Returns tx hashes and recovered amounts. Returns an empty transfers list when nothing is stranded. Each transfer carries confirmation: "confirmed" (a receipt was seen \u2014 the funds are in the account) or "unconfirmed" (broadcast but not confirmed within 90 seconds \u2014 still in the mempool, may still land). The top-level unconfirmed flag is true when any transfer is unconfirmed.`,
|
|
4380
4430
|
nextActionGuidance: 'If transfers is non-empty, confirm the amounts with the user. Report a transfer as recovered ONLY when its confirmation is "confirmed". For an "unconfirmed" transfer, tell the user it was submitted but not yet confirmed, give them its txHash and explorerUrl to check, and do not re-run the sweep immediately \u2014 a re-run after it lands will simply find nothing stranded.'
|
|
4381
4431
|
},
|
|
4382
4432
|
send: {
|
|
4383
4433
|
summary: "Send ETH or USDC directly from the agent's Haven wallet to a recipient address.",
|
|
4384
|
-
selectionGuidance: "Use this for plain transfers \u2014 refunding a user, paying a freelancer, topping up a co-agent's wallet, or moving funds between addresses. Do NOT use for x402 paid endpoints \u2014 use haven_pay_x402 instead. Do NOT use for read-only allowance, budget, or what-can-I-spend questions \u2014 use haven_get_allowances.",
|
|
4434
|
+
selectionGuidance: "Use this for plain transfers \u2014 refunding a user, paying a freelancer, topping up a co-agent's wallet, or moving funds between addresses. Do NOT use for x402 paid endpoints \u2014 use haven_pay_x402 instead. Do NOT use for read-only allowance, budget, or what-can-I-spend questions \u2014 use haven_get_allowances. Do NOT use to check whether funds are held before sending \u2014 use haven_check_funds.",
|
|
4385
4435
|
behavior: "Sends the requested amount by redeeming the agent's on-chain budget delegation, account to recipient with no funding leg. Budget, recipient and expiry are enforced on-chain while the transfer is prepared, so a request outside them is declined before any money moves and before the agent is asked to sign \u2014 it is never queued for a human to approve later. The agent's signing key signs the account's typed data; Haven never receives the key.",
|
|
4386
4436
|
nextActionGuidance: "On a decline, report the reason to the user and ask them to grant or raise the budget in Haven \u2014 there is nothing to poll and no approval will arrive. After a successful send, poll haven_get_payment_status until nextAction=none."
|
|
4387
4437
|
},
|
|
@@ -4850,6 +4900,13 @@ spending:
|
|
|
4850
4900
|
local signer; the signer is verified by calling any signer tool.
|
|
4851
4901
|
- \`mcp__haven__haven_get_allowances\` \u2014 detailed per-token breakdown
|
|
4852
4902
|
(configured, spent, reset window) when you need more than the summary.
|
|
4903
|
+
- \`mcp__haven__haven_check_funds\` \u2014 whether the account actually HOLDS at
|
|
4904
|
+
least a given amount of a token. Allowance answers above say what you are
|
|
4905
|
+
permitted to spend; this one says whether the money is really there,
|
|
4906
|
+
answered as \`covered\` true/false/null \u2014 never as a balance. On
|
|
4907
|
+
\`covered: false\`, stop and tell the user the account is short; on
|
|
4908
|
+
\`covered: null\` (the chain read failed), treat it as unverifiable rather
|
|
4909
|
+
than as absence.
|
|
4853
4910
|
|
|
4854
4911
|
Budgets reset on a period the user chose. If a payment exceeds the remaining
|
|
4855
4912
|
budget it is declined before any money moves \u2014 tell the user; they can raise
|