@intent-engine/cli 0.0.0-stage → 0.1.1

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 (102) hide show
  1. package/LICENSE +202 -0
  2. package/dist/src/accounts.d.ts +112 -0
  3. package/dist/src/accounts.js +162 -0
  4. package/dist/src/accounts.js.map +1 -0
  5. package/dist/src/agent/actions.d.ts +45 -0
  6. package/dist/src/agent/actions.js +43 -0
  7. package/dist/src/agent/actions.js.map +1 -0
  8. package/dist/src/agent/budget.d.ts +22 -0
  9. package/dist/src/agent/budget.js +31 -0
  10. package/dist/src/agent/budget.js.map +1 -0
  11. package/dist/src/agent/claims.d.ts +15 -0
  12. package/dist/src/agent/claims.js +47 -0
  13. package/dist/src/agent/claims.js.map +1 -0
  14. package/dist/src/agent/create.d.ts +56 -0
  15. package/dist/src/agent/create.js +119 -0
  16. package/dist/src/agent/create.js.map +1 -0
  17. package/dist/src/agent/mandate.d.ts +30 -0
  18. package/dist/src/agent/mandate.js +480 -0
  19. package/dist/src/agent/mandate.js.map +1 -0
  20. package/dist/src/agent/mcp.d.ts +17 -0
  21. package/dist/src/agent/mcp.js +53 -0
  22. package/dist/src/agent/mcp.js.map +1 -0
  23. package/dist/src/agent/names.d.ts +1 -0
  24. package/dist/src/agent/names.js +3 -0
  25. package/dist/src/agent/names.js.map +1 -0
  26. package/dist/src/agent/owner.d.ts +40 -0
  27. package/dist/src/agent/owner.js +123 -0
  28. package/dist/src/agent/owner.js.map +1 -0
  29. package/dist/src/agent/prepare.d.ts +14 -0
  30. package/dist/src/agent/prepare.js +32 -0
  31. package/dist/src/agent/prepare.js.map +1 -0
  32. package/dist/src/agent/problems.d.ts +120 -0
  33. package/dist/src/agent/problems.js +189 -0
  34. package/dist/src/agent/problems.js.map +1 -0
  35. package/dist/src/agent/read.d.ts +13 -0
  36. package/dist/src/agent/read.js +210 -0
  37. package/dist/src/agent/read.js.map +1 -0
  38. package/dist/src/agent/registry.d.ts +2 -0
  39. package/dist/src/agent/registry.js +24 -0
  40. package/dist/src/agent/registry.js.map +1 -0
  41. package/dist/src/agent/relay.d.ts +20 -0
  42. package/dist/src/agent/relay.js +43 -0
  43. package/dist/src/agent/relay.js.map +1 -0
  44. package/dist/src/agent/schema.d.ts +68 -0
  45. package/dist/src/agent/schema.js +210 -0
  46. package/dist/src/agent/schema.js.map +1 -0
  47. package/dist/src/agent/settle.d.ts +5 -0
  48. package/dist/src/agent/settle.js +145 -0
  49. package/dist/src/agent/settle.js.map +1 -0
  50. package/dist/src/agent/shapes.d.ts +165 -0
  51. package/dist/src/agent/shapes.js +163 -0
  52. package/dist/src/agent/shapes.js.map +1 -0
  53. package/dist/src/agent/signed.d.ts +21 -0
  54. package/dist/src/agent/signed.js +363 -0
  55. package/dist/src/agent/signed.js.map +1 -0
  56. package/dist/src/agent/wallet.d.ts +18 -0
  57. package/dist/src/agent/wallet.js +186 -0
  58. package/dist/src/agent/wallet.js.map +1 -0
  59. package/dist/src/args.d.ts +491 -0
  60. package/dist/src/args.js +1124 -0
  61. package/dist/src/args.js.map +1 -0
  62. package/dist/src/bin.d.ts +2 -0
  63. package/dist/src/bin.js +4 -0
  64. package/dist/src/bin.js.map +1 -0
  65. package/dist/src/commands.d.ts +51 -0
  66. package/dist/src/commands.js +451 -0
  67. package/dist/src/commands.js.map +1 -0
  68. package/dist/src/compute.d.ts +19 -0
  69. package/dist/src/compute.js +81 -0
  70. package/dist/src/compute.js.map +1 -0
  71. package/dist/src/crank.d.ts +39 -0
  72. package/dist/src/crank.js +171 -0
  73. package/dist/src/crank.js.map +1 -0
  74. package/dist/src/events.d.ts +8 -0
  75. package/dist/src/events.js +43 -0
  76. package/dist/src/events.js.map +1 -0
  77. package/dist/src/flows.d.ts +23 -0
  78. package/dist/src/flows.js +128 -0
  79. package/dist/src/flows.js.map +1 -0
  80. package/dist/src/main.d.ts +32 -0
  81. package/dist/src/main.js +99 -0
  82. package/dist/src/main.js.map +1 -0
  83. package/dist/src/render.d.ts +5 -0
  84. package/dist/src/render.js +46 -0
  85. package/dist/src/render.js.map +1 -0
  86. package/dist/src/tokens.d.ts +11 -0
  87. package/dist/src/tokens.js +20 -0
  88. package/dist/src/tokens.js.map +1 -0
  89. package/dist/src/transport.d.ts +155 -0
  90. package/dist/src/transport.js +173 -0
  91. package/dist/src/transport.js.map +1 -0
  92. package/dist/src/treasury.d.ts +27 -0
  93. package/dist/src/treasury.js +85 -0
  94. package/dist/src/treasury.js.map +1 -0
  95. package/dist/src/version.d.ts +1 -0
  96. package/dist/src/version.js +2 -0
  97. package/dist/src/version.js.map +1 -0
  98. package/dist/src/wallet.d.ts +30 -0
  99. package/dist/src/wallet.js +109 -0
  100. package/dist/src/wallet.js.map +1 -0
  101. package/package.json +37 -3
  102. package/README.md +0 -3
@@ -0,0 +1,145 @@
1
+ import { createNoopSigner } from "@solana/kit";
2
+ import { buildCancelIntent, buildCloseIntent, decodeParamsLoose, describeTerms, findVaultPda, formatAmount, getIntentDecoder, tokenOf, } from "@intent-engine/core";
3
+ import { chainTime, loadIntent, tokenProgramOf } from "../accounts.js";
4
+ import { closing, CostlyFunding, crankAction, expiring, UnfundedAccount, vaultBalance } from "../crank.js";
5
+ import { define } from "./actions.js";
6
+ import { tool } from "./names.js";
7
+ import { prepare } from "./prepare.js";
8
+ import { AgentRefusal } from "./problems.js";
9
+ import { preparedSchema, preparedView } from "./shapes.js";
10
+ import { account, amount, choice, flag, integer, list, object, optional, text } from "./schema.js";
11
+ import { TOKEN_NAMES, tokenNames } from "../tokens.js";
12
+ import { decimalsFor, SOL_DECIMALS } from "./read.js";
13
+ export const WORK_LIMIT = 100;
14
+ export const OWNER_ACCOUNT_MISSING = "the owner has no token account that can take the refund; set fund_accounts to create one for them at the cranker's cost";
15
+ const intentRef = {
16
+ owner: account("the wallet that created the intent"),
17
+ nonce: amount("the intent's nonce under that owner"),
18
+ };
19
+ export const prepareCancel = define({
20
+ name: tool("prepare_cancel"),
21
+ title: "Prepare a cancel",
22
+ description: "Build the transaction that cancels an open intent and returns what is left in escrow to the owner's token account. The intent account stays readable as cancelled and keeps its rent and bounty until whoever paid them closes it; if the owner paid them, set close to close it in the same transaction and get them back now. Only the owner can sign it.",
23
+ effect: "prepare",
24
+ input: object({
25
+ ...intentRef,
26
+ close: optional(flag("also close the intent account and return its rent and bounty to the owner, who must have paid them; it can no longer be read afterwards")),
27
+ }),
28
+ output: object({
29
+ intent: account(),
30
+ refund: amount("raw input units returned to the owner"),
31
+ summary: list(text(), 16, "what signing does, in plain words"),
32
+ warnings: list(text(), 8, "anything to check before signing"),
33
+ prepared: preparedSchema,
34
+ }),
35
+ run: async ({ transport }, input) => {
36
+ const { address, intent } = await loadIntent(transport, input.owner, input.nonce);
37
+ const owner = createNoopSigner(input.owner);
38
+ const ref = {
39
+ owner: input.owner,
40
+ nonce: input.nonce,
41
+ inputMint: intent.inputMint,
42
+ tokenProgram: await tokenProgramOf(transport, intent.inputMint),
43
+ };
44
+ const ix = await buildCancelIntent({ ...ref, owner });
45
+ const ownPaid = intent.rentPayer === input.owner;
46
+ const andClose = input.close ?? false;
47
+ if (andClose && !ownPaid) {
48
+ throw new AgentRefusal("NotRentPayer", `${intent.rentPayer} paid this intent's rent and bounty, so only it can close the intent; cancel without close`);
49
+ }
50
+ const close = andClose ? [await buildCloseIntent({ ...ref, cranker: owner, rentPayer: input.owner })] : [];
51
+ const [vault] = await findVaultPda({ intent: address });
52
+ let held = 0n;
53
+ for (const account of [address, vault]) {
54
+ held += (await transport.getAccount(account))?.lamports ?? 0n;
55
+ }
56
+ const rent = `${held} lamports (${formatAmount(held, SOL_DECIMALS)} SOL)`;
57
+ const refund = await vaultBalance(transport, address);
58
+ const decimals = await decimalsFor(transport, new Map(), intent.inputMint, intent.outputMint);
59
+ const params = decodeParamsLoose(intent.kind, Uint8Array.from(intent.params));
60
+ const terms = "unknown" in params
61
+ ? []
62
+ : describeTerms({ kind: intent.kind, params: Uint8Array.from(intent.params), inputMint: intent.inputMint, outputMint: intent.outputMint }, { ...decimals, ...tokenNames(intent.inputMint, intent.outputMint) });
63
+ return {
64
+ intent: address,
65
+ refund,
66
+ summary: [
67
+ `Cancels intent ${address} (nonce ${intent.nonce}); nobody can fill it afterwards`,
68
+ ...terms.map((line) => `Cancelled terms: ${line}`),
69
+ `Returns ${formatAmount(refund, decimals.inputDecimals)} of ${tokenOf(intent.inputMint, TOKEN_NAMES[intent.inputMint])} to your token account`,
70
+ andClose
71
+ ? `Closes the intent and its escrow account in the same transaction and returns their ${rent} of rent and bounty to you; the intent can no longer be read afterwards`
72
+ : ownPaid
73
+ ? `The intent and its escrow account stay readable as cancelled and hold ${rent} of rent and bounty that are yours; set close to get them back in this transaction, or close it later with ${tool("prepare_crank")}`
74
+ : `The intent and its escrow account stay until ${intent.rentPayer}, who paid for them, closes them; that returns their ${rent} to them`,
75
+ ],
76
+ warnings: [],
77
+ prepared: preparedView(await prepare(transport, [ix, ...close], input.owner)),
78
+ };
79
+ },
80
+ });
81
+ export const findCrankWork = define({
82
+ name: tool("find_crank_work"),
83
+ title: "Find crank work",
84
+ description: "List intents anyone may settle now for their bounty: open intents past their expiry (expire refunds the owner) and filled or expired intents waiting to be closed (close returns their rent to whoever paid it, or to the cranker when that payer has since become a program). A cancelled intent's bounty goes back to its payer, so it is listed only for that payer, given as cranker. Each comes with the bounty in lamports.",
85
+ effect: "read",
86
+ input: object({
87
+ cranker: optional(account("include the cancelled intents this wallet paid for, whose bounty and rent return to it")),
88
+ limit: optional(integer(1, WORK_LIMIT)),
89
+ }),
90
+ output: object({
91
+ now: amount("chain time in unix seconds"),
92
+ work: list(object({ intent: account(), owner: account(), nonce: amount(), action: choice(["expire", "close"]), bounty: amount() }), WORK_LIMIT),
93
+ more: flag(),
94
+ }),
95
+ run: async ({ transport }, input) => {
96
+ const now = await chainTime(transport);
97
+ const work = [];
98
+ for (const { address, data } of await transport.intents()) {
99
+ const intent = getIntentDecoder().decode(data);
100
+ const action = crankAction(intent, now, input.cranker);
101
+ if (action !== undefined) {
102
+ work.push({ intent: address, owner: intent.owner, nonce: intent.nonce, action, bounty: BigInt(intent.bounty) });
103
+ }
104
+ }
105
+ const limit = input.limit ?? WORK_LIMIT;
106
+ return { now, work: work.slice(0, limit), more: work.length > limit };
107
+ },
108
+ });
109
+ export const prepareCrank = define({
110
+ name: tool("prepare_crank"),
111
+ title: "Prepare a crank",
112
+ description: "Build the transaction that expires an overdue intent (refunding its owner) and closes it, or closes an already settled one, paying the intent's bounty to the cranker. The cranker signs and pays the fee. If the owner's token account is gone or cannot take the refund, set fund_accounts to create one for the owner at the cranker's cost; that is refused when its rent exceeds the bounty.",
113
+ effect: "prepare",
114
+ input: object({
115
+ cranker: account("the wallet that signs, pays the fee and receives the bounty"),
116
+ ...intentRef,
117
+ fund_accounts: optional(flag("recreate the owner's missing token account at the cranker's cost, only when the bounty covers its rent")),
118
+ }),
119
+ output: object({ intent: account(), action: choice(["expire", "close"]), bounty: amount(), prepared: preparedSchema }),
120
+ run: async ({ transport }, input) => {
121
+ const { address, intent } = await loadIntent(transport, input.owner, input.nonce);
122
+ const action = crankAction(intent, await chainTime(transport), input.cranker);
123
+ if (action === undefined) {
124
+ throw new AgentRefusal("NothingToCrank", "this intent is still open and not yet expired, was cancelled and pays nothing to this cranker, or is not one this client can read", true);
125
+ }
126
+ const cranker = createNoopSigner(input.cranker);
127
+ const fund = (input.fund_accounts ?? false) ? "covered" : "never";
128
+ try {
129
+ const ixs = action === "expire"
130
+ ? await expiring(transport, cranker, address, intent, fund, true)
131
+ : await closing(transport, cranker, address, intent, fund);
132
+ return { intent: address, action, bounty: BigInt(intent.bounty), prepared: preparedView(await prepare(transport, ixs, input.cranker)) };
133
+ }
134
+ catch (error) {
135
+ if (error instanceof CostlyFunding) {
136
+ throw new AgentRefusal("FundingExceedsBounty", error.message);
137
+ }
138
+ if (error instanceof UnfundedAccount) {
139
+ throw new AgentRefusal("OwnerAccountMissing", OWNER_ACCOUNT_MISSING);
140
+ }
141
+ throw error;
142
+ }
143
+ },
144
+ });
145
+ //# sourceMappingURL=settle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settle.js","sourceRoot":"","sources":["../../../src/agent/settle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,OAAO,GACR,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAgB,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEtD,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC;AAE9B,MAAM,CAAC,MAAM,qBAAqB,GAChC,yHAAyH,CAAC;AAE5H,MAAM,SAAS,GAAG;IAChB,KAAK,EAAE,OAAO,CAAC,oCAAoC,CAAC;IACpD,KAAK,EAAE,MAAM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,MAAM,IAAI,YAAY,CACpB,gBAAgB,EAChB,mIAAmI,EACnI,IAAI,CACL,CAAC;QACJ,CAAC;QACD,MAAM,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,IAAI,GAAY,CAAC,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;QAC3E,IAAI,CAAC;YACH,MAAM,GAAG,GACP,MAAM,KAAK,QAAQ;gBACjB,CAAC,CAAC,MAAM,QAAQ,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC;gBACjE,CAAC,CAAC,MAAM,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;YAC/D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,MAAM,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QAC1I,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,aAAa,EAAE,CAAC;gBACnC,MAAM,IAAI,YAAY,CAAC,sBAAsB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YAChE,CAAC;YACD,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;gBACrC,MAAM,IAAI,YAAY,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;YACvE,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,165 @@
1
+ import type { Address } from "@solana/kit";
2
+ import { type Intent, type IntentParams, Kind } from "@intent-engine/core";
3
+ import type { Prepared } from "./prepare.js";
4
+ import { type Infer } from "./schema.js";
5
+ export declare const orderSchema: import("./schema.js").Schema<({
6
+ kind: "attested";
7
+ } & {
8
+ amount_in: bigint;
9
+ min_result: bigint;
10
+ max_result: bigint;
11
+ attestor: Address;
12
+ } & {}) | ({
13
+ kind: "dutch";
14
+ } & {
15
+ amount_in: bigint;
16
+ start_out: bigint;
17
+ end_out: bigint;
18
+ start_time: bigint;
19
+ end_time: bigint;
20
+ } & {}) | ({
21
+ kind: "limit";
22
+ } & {
23
+ make_amount: bigint;
24
+ take_amount: bigint;
25
+ } & {}) | ({
26
+ kind: "swap";
27
+ } & {
28
+ amount_in: bigint;
29
+ min_out: bigint;
30
+ } & {})>;
31
+ export type Order = Infer<typeof orderSchema>;
32
+ export declare function paramsOf(order: Order): IntentParams;
33
+ export declare function orderOf(params: IntentParams): Order;
34
+ export declare const KIND_NAMES: {
35
+ readonly 1: "swap";
36
+ readonly 2: "limit";
37
+ readonly 3: "dutch";
38
+ readonly 4: "attested";
39
+ };
40
+ export declare const KINDS: readonly [Kind.SwapExactIn, Kind.LimitOrder, Kind.DutchAuction, Kind.AttestedResult];
41
+ export declare const partnerSchema: import("./schema.js").Schema<{
42
+ account: Address;
43
+ bps: number;
44
+ } & {}>;
45
+ export declare const STATUSES: readonly ["open", "filled", "cancelled", "expired", "filling", "unknown"];
46
+ export declare const intentSchema: import("./schema.js").Schema<{
47
+ address: Address;
48
+ owner: Address;
49
+ input_mint: Address;
50
+ output_mint: Address;
51
+ receiver: Address;
52
+ nonce: bigint;
53
+ status: "cancelled" | "expired" | "filled" | "filling" | "open" | "unknown";
54
+ escrowed: bigint;
55
+ filled: bigint;
56
+ remaining: bigint;
57
+ created_at: bigint;
58
+ expires_at: bigint;
59
+ order: ({
60
+ kind: "attested";
61
+ } & {
62
+ amount_in: bigint;
63
+ min_result: bigint;
64
+ max_result: bigint;
65
+ attestor: Address;
66
+ } & {}) | ({
67
+ kind: "dutch";
68
+ } & {
69
+ amount_in: bigint;
70
+ start_out: bigint;
71
+ end_out: bigint;
72
+ start_time: bigint;
73
+ end_time: bigint;
74
+ } & {}) | ({
75
+ kind: "limit";
76
+ } & {
77
+ make_amount: bigint;
78
+ take_amount: bigint;
79
+ } & {}) | ({
80
+ kind: "swap";
81
+ } & {
82
+ amount_in: bigint;
83
+ min_out: bigint;
84
+ } & {}) | null;
85
+ partner: ({
86
+ account: Address;
87
+ bps: number;
88
+ } & {}) | null;
89
+ bounty: bigint;
90
+ mandate: Address | null;
91
+ agent_fee: bigint;
92
+ summary: string[];
93
+ } & {}>;
94
+ export type Decimals = {
95
+ inputDecimals?: number;
96
+ outputDecimals?: number;
97
+ };
98
+ export declare const SETTLED: ReadonlySet<number>;
99
+ export declare const SETTLED_LINE = "No longer open: its escrow was refunded or paid out, so nothing is locked in it; escrowed only records what was locked at creation";
100
+ export declare function intentView(address: Address, intent: Intent, decimals?: Decimals): {
101
+ address: Address;
102
+ owner: Address;
103
+ input_mint: Address;
104
+ output_mint: Address;
105
+ receiver: Address;
106
+ nonce: bigint;
107
+ status: string;
108
+ escrowed: bigint;
109
+ filled: bigint;
110
+ remaining: bigint;
111
+ created_at: bigint;
112
+ expires_at: bigint;
113
+ order: ({
114
+ kind: "attested";
115
+ } & {
116
+ amount_in: bigint;
117
+ min_result: bigint;
118
+ max_result: bigint;
119
+ attestor: Address;
120
+ } & {}) | ({
121
+ kind: "dutch";
122
+ } & {
123
+ amount_in: bigint;
124
+ start_out: bigint;
125
+ end_out: bigint;
126
+ start_time: bigint;
127
+ end_time: bigint;
128
+ } & {}) | ({
129
+ kind: "limit";
130
+ } & {
131
+ make_amount: bigint;
132
+ take_amount: bigint;
133
+ } & {}) | ({
134
+ kind: "swap";
135
+ } & {
136
+ amount_in: bigint;
137
+ min_out: bigint;
138
+ } & {}) | null;
139
+ partner: {
140
+ account: Address;
141
+ bps: number;
142
+ } | null;
143
+ bounty: bigint;
144
+ mandate: Address | null;
145
+ agent_fee: bigint;
146
+ summary: string[];
147
+ };
148
+ export declare const preparedSchema: import("./schema.js").Schema<{
149
+ transaction: string;
150
+ fee_payer: Address;
151
+ signers: Address[];
152
+ last_valid_block_height: bigint;
153
+ units_consumed: bigint | null;
154
+ priority_fee_lamports: bigint;
155
+ logs: string[];
156
+ } & {}>;
157
+ export declare function preparedView(p: Prepared): {
158
+ transaction: string;
159
+ fee_payer: Address;
160
+ signers: Address[];
161
+ last_valid_block_height: bigint;
162
+ units_consumed: bigint | null;
163
+ priority_fee_lamports: bigint;
164
+ logs: string[];
165
+ };
@@ -0,0 +1,163 @@
1
+ import { decodeParamsLoose, describeTerms, INTENT_VERSION, Kind, MAX_PARTNER_BPS, NO_MANDATE, IntentStatus, remainingOf, } from "@intent-engine/core";
2
+ import { STATUS } from "../accounts.js";
3
+ import { tokenNames } from "../tokens.js";
4
+ import { account, amount, choice, integer, list, nullable, object, text, time, variants, } from "./schema.js";
5
+ export const orderSchema = variants("kind", {
6
+ swap: object({
7
+ amount_in: amount("exact raw units of the input token to sell"),
8
+ min_out: amount("least raw units of the output token to receive for the whole amount"),
9
+ }),
10
+ limit: object({
11
+ make_amount: amount("raw units of the input token offered; a fill always takes all of it at once"),
12
+ take_amount: amount("least raw units of the output token wanted for the whole make_amount"),
13
+ }),
14
+ dutch: object({
15
+ amount_in: amount("exact raw units of the input token to sell"),
16
+ start_out: amount("output wanted at start_time; the requirement falls linearly from here"),
17
+ end_out: amount("output wanted from end_time on"),
18
+ start_time: time("unix seconds when the price starts falling"),
19
+ end_time: time("unix seconds when the price stops falling; at or before the expiry"),
20
+ }),
21
+ attested: object({
22
+ amount_in: amount("exact raw units of the input token to sell"),
23
+ min_result: amount("least attested result that settles the intent"),
24
+ max_result: amount("greatest attested result that settles the intent"),
25
+ attestor: account("the key whose signature alone decides the result"),
26
+ }),
27
+ }, "what to sell and the least to receive");
28
+ export function paramsOf(order) {
29
+ switch (order.kind) {
30
+ case "swap":
31
+ return { kind: Kind.SwapExactIn, amountIn: order.amount_in, minOut: order.min_out };
32
+ case "limit":
33
+ return { kind: Kind.LimitOrder, makeAmount: order.make_amount, takeAmount: order.take_amount };
34
+ case "dutch":
35
+ return {
36
+ kind: Kind.DutchAuction,
37
+ amountIn: order.amount_in,
38
+ startOut: order.start_out,
39
+ endOut: order.end_out,
40
+ startTs: order.start_time,
41
+ endTs: order.end_time,
42
+ };
43
+ case "attested":
44
+ return {
45
+ kind: Kind.AttestedResult,
46
+ amountIn: order.amount_in,
47
+ minResult: order.min_result,
48
+ maxResult: order.max_result,
49
+ attestor: order.attestor,
50
+ };
51
+ }
52
+ }
53
+ export function orderOf(params) {
54
+ switch (params.kind) {
55
+ case Kind.SwapExactIn:
56
+ return { kind: "swap", amount_in: params.amountIn, min_out: params.minOut };
57
+ case Kind.LimitOrder:
58
+ return { kind: "limit", make_amount: params.makeAmount, take_amount: params.takeAmount };
59
+ case Kind.DutchAuction:
60
+ return {
61
+ kind: "dutch",
62
+ amount_in: params.amountIn,
63
+ start_out: params.startOut,
64
+ end_out: params.endOut,
65
+ start_time: params.startTs,
66
+ end_time: params.endTs,
67
+ };
68
+ case Kind.AttestedResult:
69
+ return {
70
+ kind: "attested",
71
+ amount_in: params.amountIn,
72
+ min_result: params.minResult,
73
+ max_result: params.maxResult,
74
+ attestor: params.attestor,
75
+ };
76
+ }
77
+ }
78
+ export const KIND_NAMES = { [Kind.SwapExactIn]: "swap", [Kind.LimitOrder]: "limit", [Kind.DutchAuction]: "dutch", [Kind.AttestedResult]: "attested" };
79
+ export const KINDS = [Kind.SwapExactIn, Kind.LimitOrder, Kind.DutchAuction, Kind.AttestedResult];
80
+ export const partnerSchema = object({
81
+ account: account("the integrator paid the partner fee"),
82
+ bps: integer(1, MAX_PARTNER_BPS, "partner fee in basis points of the sold amount"),
83
+ }, "an integrator fee taken from the sold amount at fill time");
84
+ export const STATUSES = [...STATUS, "unknown"];
85
+ export const intentSchema = object({
86
+ address: account(),
87
+ owner: account(),
88
+ input_mint: account(),
89
+ output_mint: account(),
90
+ receiver: account(),
91
+ nonce: amount(),
92
+ status: choice(STATUSES),
93
+ escrowed: amount("raw input units locked when the intent was created"),
94
+ filled: amount("raw input units already sold"),
95
+ remaining: amount("raw input units still for sale; 0 once the intent is no longer open, its escrow refunded or paid out"),
96
+ created_at: time(),
97
+ expires_at: time(),
98
+ order: nullable(orderSchema),
99
+ partner: nullable(partnerSchema),
100
+ bounty: amount("lamports paid to whoever expires or closes the intent"),
101
+ mandate: nullable(account("the mandate an agent created this under; fills stop once it is revoked")),
102
+ agent_fee: amount("raw input units held for the agent that created it, paid only when it fills"),
103
+ summary: list(text(), 16, "the terms in plain words"),
104
+ });
105
+ function termsOf(intent, raw) {
106
+ if (intent.version !== INTENT_VERSION) {
107
+ return `unsupported intent version ${intent.version}`;
108
+ }
109
+ const params = decodeParamsLoose(intent.kind, raw);
110
+ return "unknown" in params ? params.reason : params;
111
+ }
112
+ export const SETTLED = new Set([IntentStatus.Filled, IntentStatus.Cancelled, IntentStatus.Expired]);
113
+ export const SETTLED_LINE = "No longer open: its escrow was refunded or paid out, so nothing is locked in it; escrowed only records what was locked at creation";
114
+ export function intentView(address, intent, decimals = {}) {
115
+ const raw = Uint8Array.from(intent.params);
116
+ const params = termsOf(intent, raw);
117
+ return {
118
+ address,
119
+ owner: intent.owner,
120
+ input_mint: intent.inputMint,
121
+ output_mint: intent.outputMint,
122
+ receiver: intent.receiver,
123
+ nonce: intent.nonce,
124
+ status: STATUS[intent.status] ?? "unknown",
125
+ escrowed: intent.escrowed,
126
+ filled: intent.filled,
127
+ remaining: intent.status === IntentStatus.Open ? remainingOf(intent) : 0n,
128
+ created_at: intent.createdAt,
129
+ expires_at: intent.expiresAt,
130
+ order: typeof params === "string" ? null : orderOf(params),
131
+ partner: intent.partnerBps === 0 ? null : { account: intent.partner, bps: intent.partnerBps },
132
+ bounty: BigInt(intent.bounty),
133
+ mandate: intent.mandate === NO_MANDATE ? null : intent.mandate,
134
+ agent_fee: intent.agentFee,
135
+ summary: [
136
+ ...(typeof params === "string"
137
+ ? [`Unreadable terms: ${params}`]
138
+ : describeTerms({ kind: params.kind, params: raw, inputMint: intent.inputMint, outputMint: intent.outputMint }, { ...decimals, ...tokenNames(intent.inputMint, intent.outputMint) })),
139
+ ...(SETTLED.has(intent.status) ? [SETTLED_LINE] : []),
140
+ ],
141
+ };
142
+ }
143
+ export const preparedSchema = object({
144
+ transaction: text("base64 wire transaction with empty signature slots; sign it with the wallets in signers"),
145
+ fee_payer: account(),
146
+ signers: list(account(), 4, "every wallet that must sign before sending"),
147
+ last_valid_block_height: amount("send before the cluster passes this block height"),
148
+ units_consumed: nullable(amount("compute units the simulation used")),
149
+ priority_fee_lamports: amount("lamports of priority fee the fee payer pays on top of the network fee"),
150
+ logs: list(text(), 16, "the last simulation log lines"),
151
+ }, "an unsigned transaction that simulated successfully");
152
+ export function preparedView(p) {
153
+ return {
154
+ transaction: p.transaction,
155
+ fee_payer: p.feePayer,
156
+ signers: p.signers,
157
+ last_valid_block_height: p.lastValidBlockHeight,
158
+ units_consumed: p.unitsConsumed,
159
+ priority_fee_lamports: p.priorityLamports,
160
+ logs: p.logs,
161
+ };
162
+ }
163
+ //# sourceMappingURL=shapes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shapes.js","sourceRoot":"","sources":["../../../src/agent/shapes.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,aAAa,EAGb,cAAc,EACd,IAAI,EACJ,eAAe,EACf,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,OAAO,EACP,MAAM,EACN,MAAM,EAEN,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,QAAQ,GACT,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,C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AE,GAAG,QAAQ,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACvL,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACtD;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAClC;IACE,WAAW,EAAE,IAAI,CAAC,yFAAyF,CAAC;IAC5G,SAAS,EAAE,OAAO,EAAE;IACpB,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,4CAA4C,CAAC;IACzE,uBAAuB,EAAE,MAAM,CAAC,kDAAkD,CAAC;IACnF,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC;IACrE,qBAAqB,EAAE,MAAM,CAAC,uEAAuE,CAAC;IACtG,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,+BAA+B,CAAC;CACxD,EACD,qDAAqD,CACtD,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,CAAW;IACtC,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,WAAW;QAC1B,SAAS,EAAE,CAAC,CAAC,QAAQ;QACrB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,uBAAuB,EAAE,CAAC,CAAC,oBAAoB;QAC/C,cAAc,EAAE,CAAC,CAAC,aAAa;QAC/B,qBAAqB,EAAE,CAAC,CAAC,gBAAgB;QACzC,IAAI,EAAE,CAAC,CAAC,IAAI;KACb,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { type Address, type Instruction, type SignatureBytes } from "@solana/kit";
2
+ import { type Intent, type SignedIntentFields } from "@intent-engine/core";
3
+ import { type Transport } from "../transport.js";
4
+ import { type Relay } from "./relay.js";
5
+ export declare const DEFAULT_SUBMIT_WITHIN: number;
6
+ export declare const MAX_SUBMIT_WITHIN: number;
7
+ export declare const SIGNATURE_PATTERN = "^[1-9A-HJ-NP-Za-km-z]{64,88}$";
8
+ export declare function relayFloor(relay: Relay, mint: Address): bigint;
9
+ export declare const RELAY_TOO_LARGE = "this server's relayer cannot fit these signed terms in one Solana transaction; drop the partner fee or use a relayer that adds no priority fee";
10
+ export declare function relayFits(transport: Transport, relay: Relay, instructions: readonly Instruction[]): Promise<boolean>;
11
+ export declare function offeredFee(floor: bigint, offered: bigint | undefined): bigint;
12
+ export declare const prepareSignedIntent: import("./actions.js").AnyAction;
13
+ export declare const submitSignedIntent: import("./actions.js").AnyAction;
14
+ export declare function paying<T>(paid: {
15
+ any: boolean;
16
+ }, sending: Promise<T>): Promise<T>;
17
+ export declare const repriced: (admitted: bigint, now: bigint) => string;
18
+ export declare function refuseRepricing(admitted: bigint, now: bigint): void;
19
+ export declare const previewSignedIntent: import("./actions.js").AnyAction;
20
+ export declare function sameTerms(stored: Intent, fields: SignedIntentFields): boolean;
21
+ export declare function signatureBytes(text: string): SignatureBytes;