@temporalabs/treasury 0.1.1 → 0.1.3

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.
Files changed (103) hide show
  1. package/NOTICE +4 -2
  2. package/README.md +100 -44
  3. package/THIRD_PARTY_NOTICES.connect-page.md +7836 -0
  4. package/THIRD_PARTY_NOTICES.md +543 -162
  5. package/dist/cli.d.ts +6 -0
  6. package/dist/cli.js +243 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/client.d.ts +366 -239
  9. package/dist/client.js +202 -25
  10. package/dist/client.js.map +1 -1
  11. package/dist/config/earn.d.ts +48 -12
  12. package/dist/config/earn.js +48 -12
  13. package/dist/config/earn.js.map +1 -1
  14. package/dist/connect/ack.d.ts +76 -0
  15. package/dist/connect/ack.js +147 -0
  16. package/dist/connect/ack.js.map +1 -0
  17. package/dist/connect/commands.d.ts +81 -0
  18. package/dist/connect/commands.js +555 -0
  19. package/dist/connect/commands.js.map +1 -0
  20. package/dist/connect/config.d.ts +24 -0
  21. package/dist/connect/config.js +35 -0
  22. package/dist/connect/config.js.map +1 -0
  23. package/dist/connect/gate-solana.d.ts +8 -0
  24. package/dist/connect/gate-solana.js +147 -0
  25. package/dist/connect/gate-solana.js.map +1 -0
  26. package/dist/connect/gate.d.ts +37 -0
  27. package/dist/connect/gate.js +115 -0
  28. package/dist/connect/gate.js.map +1 -0
  29. package/dist/connect/http.d.ts +60 -0
  30. package/dist/connect/http.js +235 -0
  31. package/dist/connect/http.js.map +1 -0
  32. package/dist/connect/open.d.ts +2 -0
  33. package/dist/connect/open.js +35 -0
  34. package/dist/connect/open.js.map +1 -0
  35. package/dist/connect/page.d.ts +5 -0
  36. package/dist/connect/page.js +69 -0
  37. package/dist/connect/page.js.map +1 -0
  38. package/dist/connect/session.d.ts +39 -0
  39. package/dist/connect/session.js +198 -0
  40. package/dist/connect/session.js.map +1 -0
  41. package/dist/connect/solana.d.ts +73 -0
  42. package/dist/connect/solana.js +267 -0
  43. package/dist/connect/solana.js.map +1 -0
  44. package/dist/connect/verify.d.ts +37 -0
  45. package/dist/connect/verify.js +89 -0
  46. package/dist/connect/verify.js.map +1 -0
  47. package/dist/connect-page.js +5143 -0
  48. package/dist/disclosures.d.ts +22 -6
  49. package/dist/disclosures.js +34 -8
  50. package/dist/disclosures.js.map +1 -1
  51. package/dist/earn/commands.d.ts +46 -0
  52. package/dist/earn/commands.js +556 -0
  53. package/dist/earn/commands.js.map +1 -0
  54. package/dist/earn/solana.d.ts +278 -0
  55. package/dist/earn/solana.js +302 -0
  56. package/dist/earn/solana.js.map +1 -0
  57. package/dist/guide.d.ts +15 -0
  58. package/dist/guide.js +50 -0
  59. package/dist/guide.js.map +1 -0
  60. package/dist/links.d.ts +2 -0
  61. package/dist/links.js +40 -14
  62. package/dist/links.js.map +1 -1
  63. package/dist/position.d.ts +9 -6
  64. package/dist/position.js +39 -19
  65. package/dist/position.js.map +1 -1
  66. package/dist/preflight.d.ts +9 -0
  67. package/dist/preflight.js +14 -3
  68. package/dist/preflight.js.map +1 -1
  69. package/dist/quote.js +24 -7
  70. package/dist/quote.js.map +1 -1
  71. package/dist/redact.d.ts +3 -3
  72. package/dist/redact.js +3 -3
  73. package/dist/redact.js.map +1 -1
  74. package/dist/registry-schema.d.ts +82 -5
  75. package/dist/registry-schema.js +105 -15
  76. package/dist/registry-schema.js.map +1 -1
  77. package/dist/registry.d.ts +50 -7
  78. package/dist/registry.js +122 -21
  79. package/dist/registry.js.map +1 -1
  80. package/dist/solana/constants.d.ts +49 -0
  81. package/dist/solana/constants.js +50 -0
  82. package/dist/solana/constants.js.map +1 -0
  83. package/dist/solana/kvault.d.ts +99 -0
  84. package/dist/solana/kvault.js +192 -0
  85. package/dist/solana/kvault.js.map +1 -0
  86. package/dist/solana/layout.d.ts +143 -0
  87. package/dist/solana/layout.js +209 -0
  88. package/dist/solana/layout.js.map +1 -0
  89. package/dist/solana/rpc.d.ts +24 -0
  90. package/dist/solana/rpc.js +66 -0
  91. package/dist/solana/rpc.js.map +1 -0
  92. package/dist/solana/vault.d.ts +153 -0
  93. package/dist/solana/vault.js +324 -0
  94. package/dist/solana/vault.js.map +1 -0
  95. package/dist/{mcp-server.mjs → treasury.mjs} +41101 -49486
  96. package/dist/version.js +5 -10
  97. package/dist/version.js.map +1 -1
  98. package/llms.txt +621 -0
  99. package/package.json +12 -9
  100. package/registry/vaults.json +218 -4
  101. package/dist/mcp/server.d.ts +0 -8
  102. package/dist/mcp/server.js +0 -368
  103. package/dist/mcp/server.js.map +0 -1
@@ -0,0 +1,147 @@
1
+ /**
2
+ * The operator's acknowledgement, which `connect deposit` and `connect withdraw` require before the
3
+ * signing page opens.
4
+ *
5
+ * Run without `--ack`, either command builds and gate-checks its calls, records them as pending, and
6
+ * returns `acknowledgement`: one fixed text, written here and not by the agent, naming the action,
7
+ * amount, chain, vault, its explorer link, the receiver, the vault's warning and the disclosures in
8
+ * plain words (`DISCLOSURES.plain`; the full text stays in `earn terms`). The agent posts it to the
9
+ * operator and waits for an explicit yes. Run again
10
+ * with `--ack <code>`, the page opens only if the code names the pending acknowledgement, it has not
11
+ * expired, and the calls are exactly the ones it described. The code is then spent, so every page
12
+ * open is preceded by its own acknowledgement.
13
+ *
14
+ * The code is not a secret and does not need to be: it ties the second run to the text the operator
15
+ * read. An amount, vault, chain, receiver or account that changes in between gives different calls,
16
+ * and the code no longer matches them.
17
+ */
18
+ import { formatUnits, keccak256, stringToHex } from "viem";
19
+ import { CHAIN_INFO } from "../client.js";
20
+ import { DISCLOSURES } from "../disclosures.js";
21
+ import { linksFor } from "../links.js";
22
+ /** How long an acknowledgement stays usable: long enough to read it and answer, not long enough to forget it. */
23
+ export const ACK_TTL_MS = 15 * 60_000;
24
+ /** What the calls ARE: the connected account and each call's chain, destination, calldata and value. */
25
+ export function callsDigest(calls, account) {
26
+ return keccak256(stringToHex(JSON.stringify([account, calls.map((c) => [c.chainId, c.to, c.data, c.value])])));
27
+ }
28
+ export function issueAck(calls, account, now) {
29
+ return issueAckForDigest(callsDigest(calls, account), now);
30
+ }
31
+ /**
32
+ * What a Solana intent IS: the connected account, the vault, the action and its raw amount. Not the
33
+ * transaction's bytes — those name a blockhash that expires in about a minute, so the page builds a fresh
34
+ * transaction for the same intent, and the gate holds every one of them to it. A withdrawal by amount is
35
+ * `withdraw-assets` with the asset's raw amount: the shares worth it change as the vault earns, so they are
36
+ * worked out only once the acknowledgement is accepted.
37
+ */
38
+ export function solanaIntentDigest(account, vault, action, raw) {
39
+ return keccak256(stringToHex(JSON.stringify(["solana", account, vault, action, raw.toString()])));
40
+ }
41
+ export function issueAckForDigest(digest, now) {
42
+ const issuedAtIso = now.toISOString();
43
+ return {
44
+ code: keccak256(stringToHex(`${digest}|${issuedAtIso}`)).slice(2, 10),
45
+ digest,
46
+ issuedAtIso,
47
+ expiresAtIso: new Date(now.getTime() + ACK_TTL_MS).toISOString(),
48
+ };
49
+ }
50
+ /** Throws unless `code` names `pending`, it is unexpired, and it was issued for exactly these calls. */
51
+ export function checkAck(code, pending, calls, account, now) {
52
+ checkAckDigest(code, pending, callsDigest(calls, account), now);
53
+ }
54
+ /** `checkAck` against a digest computed by the caller (a Solana intent's). */
55
+ export function checkAckDigest(code, pending, digest, now) {
56
+ const again = "run the same command without --ack, post its `acknowledgement` to the operator, and wait for their yes";
57
+ if (!pending)
58
+ throw new Error(`refused: no acknowledgement is pending; ${again}`);
59
+ if (code.trim().toLowerCase() !== pending.code)
60
+ throw new Error(`refused: --ack ${code} is not the pending acknowledgement's code; ${again}`);
61
+ const expires = Date.parse(pending.expiresAtIso);
62
+ // A missing or unreadable expiry counts as expired, never as no expiry.
63
+ if (!Number.isFinite(expires) || now.getTime() > expires)
64
+ throw new Error(`refused: the acknowledgement expired at ${pending.expiresAtIso}; ${again}`);
65
+ if (digest !== pending.digest) {
66
+ throw new Error(`refused: these calls are not the ones the operator acknowledged (the amount, vault, chain, receiver or connected account changed); ${again}`);
67
+ }
68
+ }
69
+ /**
70
+ * The registry's `warning` is written for both audiences, so it ends with an instruction to the agent
71
+ * ("Show this warning before preparing any deposit."). The operator is reading the warning itself, so
72
+ * that sentence is dropped here. The registry text is unchanged: `earn` output and the registry check use it.
73
+ */
74
+ export function operatorWarning(w, action = "deposit") {
75
+ const s = w.replace(/\s*Show this warning before preparing any deposit\.\s*$/, "").trim();
76
+ // Before a withdrawal, advice on how much to deposit does not apply.
77
+ return action === "withdraw" ? s.replace(/\s*Deposit only .*?\.(?=\s|$)/g, "").trim() : s;
78
+ }
79
+ export function summarize(action, calls, admitted, receiver) {
80
+ const main = admitted.find((a) => a.kind !== "approve");
81
+ const v = main.vault;
82
+ const chainId = calls[0].chainId;
83
+ const amount = main.kind === "redeem"
84
+ ? `${formatUnits(main.amount, v.shareDecimals)} ${v.symbol} shares (the amount given; it is the whole position only if it equals the account's share balance, which is not checked here)`
85
+ : `${formatUnits(main.amount, v.asset.decimals)} ${v.asset.symbol}`;
86
+ return {
87
+ action,
88
+ amount,
89
+ asset: v.asset.symbol,
90
+ chain: CHAIN_INFO[chainId].name,
91
+ chainId,
92
+ vault: { symbol: v.symbol, name: v.name, address: v.address, explorer: linksFor(v).explorer },
93
+ receiver,
94
+ warning: operatorWarning(v.warning, action),
95
+ // The disclosures in plain words (`DISCLOSURES.plain`): the operator reads this before every page,
96
+ // so it is the short form. Before a withdrawal, only what holds for every action.
97
+ disclosures: action === "deposit"
98
+ ? [...DISCLOSURES.plain.deposit, ...(v.depositOpen.open ? [] : [DISCLOSURES.plain.gatedDeposit]), ...DISCLOSURES.plain.always]
99
+ : [...DISCLOSURES.plain.always],
100
+ };
101
+ }
102
+ /** The summary for a Solana intent: one transaction, no approve, and shares only ever to the account itself. */
103
+ export function summarizeSolana(action, v, amountText, account) {
104
+ return {
105
+ action,
106
+ amount: amountText,
107
+ asset: v.asset.symbol,
108
+ chain: "Solana",
109
+ chainId: null,
110
+ vault: { symbol: v.symbol, name: v.name, address: v.address, explorer: `https://solscan.io/account/${v.address}` },
111
+ receiver: account,
112
+ warning: operatorWarning(v.warning, action),
113
+ prompts: action === "deposit"
114
+ ? "Your wallet will ask you once, to make the deposit. A first deposit also opens your share account, which takes about 0.002 SOL of rent."
115
+ : "Your wallet will ask you once, to make the withdrawal. Kamino keeps up to 0.001 USDC of each withdraw instruction in the vault, a charge it sets and can change.",
116
+ disclosures: action === "deposit"
117
+ ? [...DISCLOSURES.plain.deposit, ...(v.depositOpen.open ? [] : [DISCLOSURES.plain.gatedDeposit]), ...DISCLOSURES.plain.always]
118
+ : [...DISCLOSURES.plain.always],
119
+ };
120
+ }
121
+ /** The text the operator reads. Generated, never paraphrased: the same calls always produce the same words. */
122
+ export function acknowledgementText(s) {
123
+ const lands = s.action === "deposit" ? "Shares go to" : `${s.asset} goes to`;
124
+ const prompts = s.prompts ??
125
+ (s.action === "deposit"
126
+ ? `Your wallet will ask you twice: first to approve ${s.amount} to the vault, then to make the deposit.`
127
+ : `Your wallet will ask you once, to make the withdrawal.`);
128
+ return [
129
+ `Confirm before the signing page opens. Nothing has been sent.`,
130
+ ``,
131
+ ` ${s.action === "deposit" ? "Deposit" : "Withdraw"}: ${s.amount}`,
132
+ s.chainId === null ? ` Chain: ${s.chain} (mainnet-beta)` : ` Chain: ${s.chain} (chainId ${s.chainId})`,
133
+ ` Vault: ${s.vault.name} (${s.vault.symbol})`,
134
+ ` ${s.vault.explorer}`,
135
+ ` ${lands}: ${s.receiver} (the connected wallet)`,
136
+ ` ${prompts}`,
137
+ ``,
138
+ `WARNING: ${s.warning}`,
139
+ ``,
140
+ `Before you agree:`,
141
+ ...s.disclosures.map((d) => ` - ${d}`),
142
+ ` ${DISCLOSURES.plain.fullTerms}`,
143
+ ``,
144
+ `Do you acknowledge and want the signing page opened for exactly this ${s.action}? Reply yes or no.`,
145
+ ].join("\n");
146
+ }
147
+ //# sourceMappingURL=ack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ack.js","sourceRoot":"","sources":["../../src/connect/ack.ts"],"names":[],"mappings":"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AAE;QACF,YAAY,CAAC,CAAC,OAAO,EAAE;QACvB,EAAE;QACF,mBAAmB;QACnB,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,KAAK,WAAW,CAAC,KAAK,CAAC,SAAS,EAAE;QAClC,EAAE;QACF,wEAAwE,CAAC,CAAC,MAAM,oBAAoB;KACrG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Agent Treasury — the connect commands, run by `src/cli.ts` as `treasury connect <command>`.
3
+ *
4
+ * connect_status which account is connected, if any
5
+ * connect_wallet open the sign-in page; the operator connects a browser wallet, or signs in
6
+ * with email / Google / Apple / X and gets a Privy embedded wallet
7
+ * connect_deposit build a deposit and admit it through the gate; without --ack, return the
8
+ * operator's acknowledgement (`ack.ts`) and open nothing; with the code, hand
9
+ * each call to the connected wallet through the confirm page
10
+ * connect_withdraw the same for a withdrawal
11
+ * connect_disconnect forget the connected account
12
+ *
13
+ * Nothing here signs. The page asks the operator's own wallet (an extension, or Privy's embedded
14
+ * wallet with its own confirmation dialog) to send each call, after the operator has read it; this
15
+ * process only checks what landed (`verify.ts`). Both sign-in paths prove the account the same way:
16
+ * the wallet signs a free sign-in message whose nonce is this flow's secret, checked here.
17
+ */
18
+ import { type Address, type Hex } from "viem";
19
+ import { type UnsignedCall } from "../build.js";
20
+ import { makePublicClient } from "../client.js";
21
+ import type { Command } from "../earn/commands.js";
22
+ import { type SolanaFlowDeps } from "./solana.js";
23
+ import { type Settled } from "./http.js";
24
+ import { type Session } from "./session.js";
25
+ import { type Verdict } from "./verify.js";
26
+ export declare function signInMessage(a: {
27
+ address: string;
28
+ origin: string;
29
+ nonce: string;
30
+ issuedAt: string;
31
+ }): string;
32
+ export interface ConnectDeps {
33
+ verifySignature?: (a: {
34
+ address: Address;
35
+ message: string;
36
+ signature: Hex;
37
+ }) => Promise<boolean>;
38
+ open?: (url: string) => boolean;
39
+ /** The confirm flow's chain reads (receipts, allowance, balances), injectable for tests. */
40
+ client?: (chainId: number) => Pick<ReturnType<typeof makePublicClient>, "getTransactionReceipt" | "readContract"> & Partial<Pick<ReturnType<typeof makePublicClient>, "getBalance" | "getBlockNumber">>;
41
+ verifyOpts?: {
42
+ attempts?: number;
43
+ delayMs?: number;
44
+ };
45
+ /** Overrides the flow's time limit and the cancel grace period (tests). */
46
+ ttlMs?: number;
47
+ cancelGraceMs?: number;
48
+ /** How long the balance read may hold the page back before it opens without balances (tests). */
49
+ balanceTimeoutMs?: number;
50
+ /** The clock acknowledgements are issued and checked against (tests). */
51
+ now?: () => Date;
52
+ /** The Solana flows' chain reads (tests). */
53
+ solanaRpc?: SolanaFlowDeps["rpc"];
54
+ }
55
+ export declare function runConnect(deps?: ConnectDeps): Promise<{
56
+ result: Settled<Session>;
57
+ url: string;
58
+ opened: boolean;
59
+ }>;
60
+ interface TxOutcome extends Verdict {
61
+ step: number;
62
+ description: string;
63
+ hash: string;
64
+ }
65
+ export declare function runConfirm(calls: UnsignedCall[], session: Session, deps?: ConnectDeps): Promise<{
66
+ result: Settled<TxOutcome[]>;
67
+ url: string;
68
+ opened: boolean;
69
+ done: TxOutcome[];
70
+ total: number;
71
+ stopReason?: string;
72
+ }>;
73
+ export declare function outcome(chainId: number, account: string, r: {
74
+ result: Settled<TxOutcome[]>;
75
+ opened: boolean;
76
+ done: TxOutcome[];
77
+ total: number;
78
+ stopReason?: string;
79
+ }): string;
80
+ export declare function buildConnectCommands(deps?: ConnectDeps): Record<string, Command>;
81
+ export {};