@haven_ai/sdk 0.0.0-dev.202609181927.cd4620a → 0.0.0-dev.202609182134.2018100
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.cjs +33 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -8
- package/dist/index.d.ts +50 -8
- package/dist/index.js +33 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1737,6 +1737,10 @@ function deriveReadiness(status, allowances) {
|
|
|
1737
1737
|
if (status !== "active") return "revoked";
|
|
1738
1738
|
return allowances.some((allowance) => safeBigInt(allowance.remainingAtomic) > 0n) ? "ready" : "needs_approval";
|
|
1739
1739
|
}
|
|
1740
|
+
function formatRemainingDisplay(tokenAddress, tokenSymbol, remainingAtomic) {
|
|
1741
|
+
const token = resolveTokenFromAddress(tokenAddress);
|
|
1742
|
+
return token ? `${formatAtomicAmount(safeBigInt(remainingAtomic), token.decimals)} ${tokenSymbol}` : `${remainingAtomic} ${tokenSymbol} (atomic; unknown decimals)`;
|
|
1743
|
+
}
|
|
1740
1744
|
var AccountReads = class {
|
|
1741
1745
|
transport;
|
|
1742
1746
|
getPaymentStatus;
|
|
@@ -1758,12 +1762,12 @@ var AccountReads = class {
|
|
|
1758
1762
|
async getAgentSummary() {
|
|
1759
1763
|
const [agent, allowanceSummary] = await Promise.all([this.getAgent(), this.getAllowances()]);
|
|
1760
1764
|
const allowances = allowanceSummary.allowances.map((allowance) => {
|
|
1761
|
-
const token = resolveTokenFromAddress(allowance.tokenAddress);
|
|
1762
|
-
const remainingDisplay = token ? `${formatAtomicAmount(safeBigInt(allowance.onchain.remaining), token.decimals)} ${allowance.tokenSymbol}` : `${allowance.onchain.remaining} ${allowance.tokenSymbol} (atomic; unknown decimals)`;
|
|
1763
1765
|
return {
|
|
1766
|
+
id: allowance.id,
|
|
1764
1767
|
tokenSymbol: allowance.tokenSymbol,
|
|
1768
|
+
tokenAddress: allowance.tokenAddress,
|
|
1765
1769
|
remainingAtomic: allowance.onchain.remaining,
|
|
1766
|
-
remainingDisplay,
|
|
1770
|
+
remainingDisplay: allowance.remainingDisplay,
|
|
1767
1771
|
configuredAmount: allowance.configuredAmount,
|
|
1768
1772
|
resetPeriodMin: allowance.resetPeriodMin,
|
|
1769
1773
|
isResetPending: allowance.onchain.isResetPending
|
|
@@ -1791,6 +1795,7 @@ var AccountReads = class {
|
|
|
1791
1795
|
tokenSymbol: allowance.token_symbol,
|
|
1792
1796
|
configuredAmount: allowance.configured_amount,
|
|
1793
1797
|
resetPeriodMin: allowance.reset_period_min,
|
|
1798
|
+
remainingDisplay: formatRemainingDisplay(allowance.token_address, allowance.token_symbol, allowance.onchain.remaining),
|
|
1794
1799
|
onchain: {
|
|
1795
1800
|
amount: allowance.onchain.amount,
|
|
1796
1801
|
spent: allowance.onchain.spent,
|
|
@@ -1856,10 +1861,23 @@ var AccountReads = class {
|
|
|
1856
1861
|
return unavailable(error instanceof Error ? error.message : String(error));
|
|
1857
1862
|
}
|
|
1858
1863
|
}
|
|
1864
|
+
/** The first page's receipts as a bare array — the pre-#3128 shape, kept for callers that never page. */
|
|
1859
1865
|
async listReceipts(options = {}) {
|
|
1860
|
-
|
|
1866
|
+
return (await this.listReceiptsPage(options)).receipts;
|
|
1867
|
+
}
|
|
1868
|
+
/** #3128: one page with `total`, `hasMore` and `nextCursor` — see {@link HavenPaymentReceiptsPage}. */
|
|
1869
|
+
async listReceiptsPage(options = {}) {
|
|
1870
|
+
const params = new URLSearchParams();
|
|
1871
|
+
if (options.limit) params.set("limit", String(options.limit));
|
|
1872
|
+
if (options.cursor) params.set("cursor", options.cursor);
|
|
1873
|
+
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
1861
1874
|
const raw = await this.transport.get(`/machine-payments/receipts${query}`);
|
|
1862
|
-
return
|
|
1875
|
+
return {
|
|
1876
|
+
receipts: raw.receipts.map(mapPaymentReceipt),
|
|
1877
|
+
total: typeof raw.total === "number" ? raw.total : null,
|
|
1878
|
+
hasMore: typeof raw.has_more === "boolean" ? raw.has_more : null,
|
|
1879
|
+
nextCursor: typeof raw.next_cursor === "string" ? raw.next_cursor : null
|
|
1880
|
+
};
|
|
1863
1881
|
}
|
|
1864
1882
|
async getReceipt(paymentId) {
|
|
1865
1883
|
const { receipt } = await this.transport.get(`/payments/${paymentId}/receipt`);
|
|
@@ -3673,6 +3691,10 @@ var HavenClient = class {
|
|
|
3673
3691
|
async listReceipts(options = {}) {
|
|
3674
3692
|
return this.accountReads.listReceipts(options);
|
|
3675
3693
|
}
|
|
3694
|
+
/** #3128: one page of receipts with `total`, `hasMore` and `nextCursor`. */
|
|
3695
|
+
async listReceiptsPage(options = {}) {
|
|
3696
|
+
return this.accountReads.listReceiptsPage(options);
|
|
3697
|
+
}
|
|
3676
3698
|
/**
|
|
3677
3699
|
* Fetch the verifiable receipt bundle for a settled payment and verify it
|
|
3678
3700
|
* locally. The server's own verification is ignored — the receipt is verified
|
|
@@ -4310,21 +4332,21 @@ var toolDescriptions = {
|
|
|
4310
4332
|
nextActionGuidance: ""
|
|
4311
4333
|
},
|
|
4312
4334
|
getAgent: {
|
|
4313
|
-
summary: "Return the authenticated agent identity AND its live spend authority in one call: Haven wallet, delegate, chain, raw status, spend_authority_readiness,
|
|
4314
|
-
selectionGuidance: "Use this as the
|
|
4315
|
-
behavior:
|
|
4335
|
+
summary: "Return the authenticated agent identity AND its live spend authority in one call: Haven wallet, delegate, chain, raw status, spend_authority_readiness, per-token remaining allowance (atomic + human-readable). The recommended first call in a new session.",
|
|
4336
|
+
selectionGuidance: "Use this as the session bootstrap, or to confirm identity together with whether the agent can spend right now. For per-token detail (configured vs spent vs reset window) use haven_get_allowances.",
|
|
4337
|
+
behavior: 'Reads identity plus the live spend-authority snapshot \u2014 the active on-chain budget delegation. spend_authority_readiness (readiness is a deprecated alias, same value) is "ready" when at least one token has remaining spend authority, "needs_approval" when the agent is active but has none, and "revoked" when the credential is not active. It covers hosted identity + on-chain spend authority ONLY \u2014 the hosted server cannot see the LOCAL signer, so "ready" does not mean the signer can start; verify the signer with a signer tool call or connect --doctor. An over-budget payment is declined before any money moves; there is no approval queue \u2014 ask the owner to grant or raise the budget in Haven. allowances[] carries id, tokenAddress, remainingAtomic, remainingDisplay per token. Identity fields: id, name, status, accountAddress, delegateAddress, chainId.',
|
|
4316
4338
|
nextActionGuidance: ""
|
|
4317
4339
|
},
|
|
4318
4340
|
getAllowances: {
|
|
4319
4341
|
summary: "Return configured and on-chain allowance state for the authenticated agent. On-chain allowance is the real spend gate.",
|
|
4320
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.",
|
|
4321
|
-
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). An over-budget payment is declined before any money moves; nothing queues. Configured amounts from Haven are returned alongside.",
|
|
4343
|
+
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.",
|
|
4322
4344
|
nextActionGuidance: ""
|
|
4323
4345
|
},
|
|
4324
4346
|
listReceipts: {
|
|
4325
|
-
summary: "List
|
|
4347
|
+
summary: "List machine-payment receipts, newest first, by page.",
|
|
4326
4348
|
selectionGuidance: "For transaction history or payment evidence; use the allowance tool instead for remaining allowance or what-can-I-spend questions.",
|
|
4327
|
-
behavior: "parties.treasuryAccount is Haven's authoritative payer. protocolReceiptPayload is the merchant's PAYMENT-RESPONSE, relayed verbatim: merchant-controlled, unverified, not Haven's record; payer may differ from payerAddress. Proof header values are omitted.",
|
|
4349
|
+
behavior: "Page: { receipts, total, hasMore, nextCursor }; total 0 = none exist (no indexing delay); hasMore = cut at limit, send nextCursor as cursor. parties.treasuryAccount is Haven's authoritative payer. protocolReceiptPayload is the merchant's PAYMENT-RESPONSE, relayed verbatim: merchant-controlled, unverified, not Haven's record; payer may differ from payerAddress. Proof header values are omitted.",
|
|
4328
4350
|
nextActionGuidance: ""
|
|
4329
4351
|
},
|
|
4330
4352
|
verifyReceipt: {
|