@intent-engine/cli 0.0.0-stage → 0.1.0

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 +118 -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 +478 -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 +144 -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 +162 -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 +360 -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 +6 -0
  87. package/dist/src/tokens.js +15 -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 +29 -0
  99. package/dist/src/wallet.js +108 -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,40 @@
1
+ import { type Address, type Instruction, type TransactionSigner } from "@solana/kit";
2
+ import type { Transport } from "../transport.js";
3
+ export type UserWindow = {
4
+ nonceBase: bigint;
5
+ nonceBitmap: readonly bigint[];
6
+ epoch: bigint;
7
+ };
8
+ export declare function userOf(transport: Transport, owner: Address): Promise<UserWindow | null>;
9
+ export declare const NONCE_WINDOW = 256n;
10
+ export declare function pickNonce(user: UserWindow | null, requested: bigint | undefined, reserved?: ReadonlySet<bigint>): bigint;
11
+ export declare function initUserIfMissing(user: UserWindow | null, owner: Address): Promise<Instruction[]>;
12
+ export declare function tokenAccountIfMissing(transport: Transport, payer: TransactionSigner, owner: Address, mint: Address, tokenProgram: Address): Promise<{
13
+ address: Address;
14
+ create: Instruction[];
15
+ }>;
16
+ export type Wrap = {
17
+ instructions: Instruction[];
18
+ lamports: bigint;
19
+ };
20
+ export declare function wrapIfShort(transport: Transport, owner: Address, mint: Address, tokenProgram: Address, needed: bigint): Promise<Wrap>;
21
+ export declare function unusedIntent(transport: Transport, owner: Address, nonce: bigint): Promise<Address>;
22
+ export type Allowance = {
23
+ account: Address;
24
+ before: bigint;
25
+ after: bigint;
26
+ replaces: Address | null;
27
+ };
28
+ export declare function raiseAllowance(transport: Transport, owner: Address, account: Address, by: bigint): Promise<Allowance>;
29
+ export declare function lowerAllowance(transport: Transport, owner: Address, account: Address, by: bigint): Promise<Allowance>;
30
+ export declare const WARN_REPLACES_DELEGATE = "the setup replaces another app's spending approval on your token account";
31
+ export declare function setupLines(o: {
32
+ registers: boolean;
33
+ creates: Address[];
34
+ allowance: Allowance | null;
35
+ decimals?: number;
36
+ wraps?: bigint;
37
+ }): {
38
+ lines: string[];
39
+ warnings: string[];
40
+ };
@@ -0,0 +1,123 @@
1
+ import { createNoopSigner, isSome } from "@solana/kit";
2
+ import { getTransferSolInstruction } from "@solana-program/system";
3
+ import { getCreateAssociatedTokenIdempotentInstructionAsync, getSyncNativeInstruction, getTokenDecoder, TOKEN_PROGRAM_ADDRESS, } from "@solana-program/token";
4
+ import { buildInitUser, findAssociatedTokenAddress, findDelegatePda, formatAmount, INTENT_ENGINE_PROGRAM_ADDRESS, U64_MAX, findIntentPda, findUserStatePda, getUserStateDecoder, } from "@intent-engine/core";
5
+ import { createdAccount, TOKEN_PROGRAMS } from "../accounts.js";
6
+ import { NATIVE_MINT } from "../tokens.js";
7
+ import { AgentRefusal, ENGINE_PROBLEMS } from "./problems.js";
8
+ import { SOL_DECIMALS } from "./read.js";
9
+ export async function userOf(transport, owner) {
10
+ const [address] = await findUserStatePda({ owner });
11
+ const view = await createdAccount(transport, address);
12
+ if (view === null) {
13
+ return null;
14
+ }
15
+ if (view.owner !== INTENT_ENGINE_PROGRAM_ADDRESS) {
16
+ throw new Error(`${address} is not an engine user account`);
17
+ }
18
+ return getUserStateDecoder().decode(view.data);
19
+ }
20
+ export const NONCE_WINDOW = 256n;
21
+ export function pickNonce(user, requested, reserved = new Set()) {
22
+ if (requested !== undefined) {
23
+ return requested;
24
+ }
25
+ const base = user?.nonceBase ?? 0n;
26
+ for (let offset = 0n; offset < NONCE_WINDOW && base + offset <= U64_MAX; offset++) {
27
+ const word = user?.nonceBitmap[Number(offset / 64n)] ?? 0n;
28
+ const used = ((word >> offset % 64n) & 1n) === 1n;
29
+ if (!used && !reserved.has(base + offset)) {
30
+ return base + offset;
31
+ }
32
+ }
33
+ throw new AgentRefusal("NoFreeNonce", "every nonce in the owner's window is used or promised to a pending signature; the owner must advance the nonce window first");
34
+ }
35
+ export async function initUserIfMissing(user, owner) {
36
+ return user === null ? [await buildInitUser({ owner: createNoopSigner(owner) })] : [];
37
+ }
38
+ export async function tokenAccountIfMissing(transport, payer, owner, mint, tokenProgram) {
39
+ const address = await findAssociatedTokenAddress({ owner, mint, tokenProgram });
40
+ const create = (await createdAccount(transport, address)) === null
41
+ ? [
42
+ await getCreateAssociatedTokenIdempotentInstructionAsync({
43
+ payer,
44
+ owner,
45
+ mint,
46
+ tokenProgram,
47
+ }),
48
+ ]
49
+ : [];
50
+ return { address, create };
51
+ }
52
+ export async function wrapIfShort(transport, owner, mint, tokenProgram, needed) {
53
+ if (mint !== NATIVE_MINT || tokenProgram !== TOKEN_PROGRAM_ADDRESS) {
54
+ return { instructions: [], lamports: 0n };
55
+ }
56
+ const account = await findAssociatedTokenAddress({ owner, mint, tokenProgram });
57
+ const view = await createdAccount(transport, account);
58
+ const held = view === null ? 0n : getTokenDecoder().decode(view.data).amount;
59
+ if (held >= needed) {
60
+ return { instructions: [], lamports: 0n };
61
+ }
62
+ const payer = createNoopSigner(owner);
63
+ return {
64
+ instructions: [
65
+ ...(view === null ? [await getCreateAssociatedTokenIdempotentInstructionAsync({ payer, owner, mint, tokenProgram })] : []),
66
+ getTransferSolInstruction({ source: payer, destination: account, amount: needed - held }),
67
+ getSyncNativeInstruction({ account }),
68
+ ],
69
+ lamports: needed - held,
70
+ };
71
+ }
72
+ export async function unusedIntent(transport, owner, nonce) {
73
+ const [intent] = await findIntentPda({ owner, nonce });
74
+ if ((await createdAccount(transport, intent)) !== null) {
75
+ throw new AgentRefusal("NonceUsed", ENGINE_PROBLEMS.NonceUsed.hint);
76
+ }
77
+ return intent;
78
+ }
79
+ export async function raiseAllowance(transport, owner, account, by) {
80
+ const view = await createdAccount(transport, account);
81
+ if (view !== null && !TOKEN_PROGRAMS.includes(view.owner)) {
82
+ throw new Error(`${account} is not a token account`);
83
+ }
84
+ const token = view === null ? null : getTokenDecoder().decode(view.data);
85
+ const [engine] = await findDelegatePda({ owner });
86
+ const current = token !== null && isSome(token.delegate) ? token.delegate.value : null;
87
+ const before = current === engine && token !== null ? token.delegatedAmount : 0n;
88
+ return {
89
+ account,
90
+ before,
91
+ after: before > U64_MAX - by ? U64_MAX : before + by,
92
+ replaces: current === null || current === engine ? null : current,
93
+ };
94
+ }
95
+ export async function lowerAllowance(transport, owner, account, by) {
96
+ const view = await createdAccount(transport, account);
97
+ const token = view === null || !TOKEN_PROGRAMS.includes(view.owner) ? null : getTokenDecoder().decode(view.data);
98
+ const [engine] = await findDelegatePda({ owner });
99
+ const current = token !== null && isSome(token.delegate) ? token.delegate.value : null;
100
+ const before = current === engine && token !== null ? token.delegatedAmount : 0n;
101
+ return { account, before, after: before > by ? before - by : 0n, replaces: null };
102
+ }
103
+ export const WARN_REPLACES_DELEGATE = "the setup replaces another app's spending approval on your token account";
104
+ export function setupLines(o) {
105
+ const a = o.allowance;
106
+ return {
107
+ lines: [
108
+ ...(o.registers ? ["Setup: registers you with the engine (a one-time account you pay rent for)"] : []),
109
+ ...o.creates.map((mint) => `Setup: creates your token account for ${mint} (you pay its rent)`),
110
+ ...(o.wraps === undefined || o.wraps === 0n
111
+ ? []
112
+ : [`Setup: wraps ${formatAmount(o.wraps, SOL_DECIMALS)} of your SOL into your wrapped SOL account`]),
113
+ ...(a === null
114
+ ? []
115
+ : [
116
+ `Setup: sets the engine's spending allowance on ${a.account} to ${formatAmount(a.after, o.decimals)} (now ${formatAmount(a.before, o.decimals)})`,
117
+ ...(a.replaces === null ? [] : [`Setup: removes the approval ${a.replaces} holds on ${a.account}`]),
118
+ ]),
119
+ ],
120
+ warnings: a !== null && a.replaces !== null ? [WARN_REPLACES_DELEGATE] : [],
121
+ };
122
+ }
123
+ //# sourceMappingURL=owner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner.js","sourceRoot":"","sources":["../../../src/agent/owner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAoB,MAAM,EAA0B,MAAM,aAAa,CAAC;AAC/G,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EACL,kDAAkD,EAClD,wBAAwB,EACxB,eAAe,EACf,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,aAAa,EACb,0BAA0B,EAC1B,eAAe,EACf,YAAY,EACZ,6BAA6B,EAC7B,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAIzC,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,SAAoB,EAAE,KAAc;IAC/D,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,KAAK,6BAA6B,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,gCAAgC,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,mBAAmB,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CA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CAAC,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,QAAQ,aAAa,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;iBACpG,CAAC;SACP;QACD,QAAQ,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,EAAE;KAC5E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type Address, type Instruction } from "@solana/kit";
2
+ import type { Transport } from "../transport.js";
3
+ export type Prepared = {
4
+ transaction: string;
5
+ instructions: Instruction[];
6
+ priorityLamports: bigint;
7
+ feePayer: Address;
8
+ signers: Address[];
9
+ lastValidBlockHeight: bigint;
10
+ unitsConsumed: bigint | null;
11
+ logs: string[];
12
+ };
13
+ export declare function transactionSize(transport: Transport, instructions: readonly Instruction[], feePayer: Address): Promise<number>;
14
+ export declare function prepare(transport: Transport, instructions: readonly Instruction[], feePayer: Address): Promise<Prepared>;
@@ -0,0 +1,32 @@
1
+ import { appendTransactionMessageInstructions, compileTransaction, getTransactionEncoder, partiallySignTransactionMessageWithSigners, createTransactionMessage, getBase64EncodedWireTransaction, pipe, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, } from "@solana/kit";
2
+ import { priorityLamports } from "../compute.js";
3
+ import { LOG_LINE_LIMIT, LOG_TAIL, SimulationFailed, simulationProblem, untrusted } from "./problems.js";
4
+ export async function transactionSize(transport, instructions, feePayer) {
5
+ const latest = await transport.latestBlockhash();
6
+ const message = pipe(createTransactionMessage({ version: 0 }), (m) => setTransactionMessageFeePayer(feePayer, m), (m) => setTransactionMessageLifetimeUsingBlockhash(latest, m), (m) => appendTransactionMessageInstructions(instructions, m));
7
+ return getTransactionEncoder().encode(compileTransaction(message)).length;
8
+ }
9
+ export async function prepare(transport, instructions, feePayer) {
10
+ const budgeted = await transport.budget(instructions, feePayer);
11
+ const latest = await transport.latestBlockhash();
12
+ const message = pipe(createTransactionMessage({ version: 0 }), (m) => setTransactionMessageFeePayer(feePayer, m), (m) => setTransactionMessageLifetimeUsingBlockhash(latest, m), (m) => appendTransactionMessageInstructions(budgeted, m));
13
+ const compiled = await partiallySignTransactionMessageWithSigners(message);
14
+ const transaction = getBase64EncodedWireTransaction(compiled);
15
+ const simulation = await transport.simulate(transaction);
16
+ if (simulation.err !== null) {
17
+ throw new SimulationFailed(simulationProblem(simulation.err, simulation.logs));
18
+ }
19
+ return {
20
+ transaction,
21
+ instructions: budgeted,
22
+ priorityLamports: priorityLamports(budgeted),
23
+ feePayer,
24
+ signers: Object.entries(compiled.signatures)
25
+ .filter(([, signature]) => signature === null)
26
+ .map(([signer]) => signer),
27
+ lastValidBlockHeight: latest.lastValidBlockHeight,
28
+ unitsConsumed: simulation.unitsConsumed,
29
+ logs: simulation.logs.slice(-LOG_TAIL).map((line) => untrusted(line).slice(0, LOG_LINE_LIMIT)),
30
+ };
31
+ }
32
+ //# sourceMappingURL=prepare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../../src/agent/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oCAAoC,EACpC,kBAAkB,EAClB,qBAAqB,EACrB,0CAA0C,EAC1C,wBAAwB,EACxB,+BAA+B,EAE/B,IAAI,EACJ,6BAA6B,EAC7B,2CAA2C,GAC5C,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAazG,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,SAAoB,EACpB,YAAoC,EACpC,QAAiB;IAEjB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,eAAe,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,CAClB,wBAAwB,CAAC,EAAE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CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,OAAO;QACL,WAAW;QACX,YAAY,EAAE,QAAQ;QACtB,gBAAgB,EAAE,gBAAgB,CAAC,QAAQ,CAAC;QAC5C,QAAQ;QACR,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;aACzC,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC;aAC7C,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,MAAiB,CAAC;QACvC,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;QACjD,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;KAC/F,CAAC;AACJ,CAAC"}
@@ -0,0 +1,120 @@
1
+ import type { Address } from "@solana/kit";
2
+ import { type Issue } from "./schema.js";
3
+ export type Problem = {
4
+ code: string;
5
+ retryable: boolean;
6
+ hint: string;
7
+ programError?: number;
8
+ program?: Address;
9
+ issues?: Issue[];
10
+ logs?: string[];
11
+ };
12
+ type Entry = {
13
+ retryable: boolean;
14
+ hint: string;
15
+ };
16
+ export declare const ENGINE_PROBLEMS: {
17
+ readonly Overflow: Entry;
18
+ readonly DivideByZero: Entry;
19
+ readonly Truncated: Entry;
20
+ readonly NonCanonical: Entry;
21
+ readonly UnknownKind: Entry;
22
+ readonly UnknownStatus: Entry;
23
+ readonly InvalidParams: Entry;
24
+ readonly AmountMismatch: Entry;
25
+ readonly InsufficientOutput: Entry;
26
+ readonly InvalidTransition: Entry;
27
+ readonly IntentExpired: Entry;
28
+ readonly NotExpired: Entry;
29
+ readonly NonceUsed: Entry;
30
+ readonly NonceOutOfWindow: Entry;
31
+ readonly NonceRegression: Entry;
32
+ readonly Unauthorized: Entry;
33
+ readonly CreatePaused: Entry;
34
+ readonly KindDisabled: Entry;
35
+ readonly UnknownKindBits: Entry;
36
+ readonly InvalidPauseFlags: Entry;
37
+ readonly FeeTooHigh: Entry;
38
+ readonly NotPendingAdmin: Entry;
39
+ readonly ExpiryNotInFuture: Entry;
40
+ readonly SameMint: Entry;
41
+ readonly MintNotAllowed: Entry;
42
+ readonly RefundNotCanonical: Entry;
43
+ readonly ReceiverNotAllowed: Entry;
44
+ readonly AuctionOutlivesExpiry: Entry;
45
+ readonly FillPaused: Entry;
46
+ readonly FeeAccountNotCanonical: Entry;
47
+ readonly FeeAccountMissing: Entry;
48
+ readonly SolverOutputNotAllowed: Entry;
49
+ readonly SigProgram: Entry;
50
+ readonly SigHeader: Entry;
51
+ readonly SigPubkey: Entry;
52
+ readonly SigMessage: Entry;
53
+ readonly KindMismatch: Entry;
54
+ readonly ResultOutOfBounds: Entry;
55
+ readonly SigMissing: Entry;
56
+ readonly InvalidDomain: Entry;
57
+ readonly SignatureExpired: Entry;
58
+ readonly FlashCpi: Entry;
59
+ readonly FlashEndProgram: Entry;
60
+ readonly FlashEndDiscriminator: Entry;
61
+ readonly FlashEndIntent: Entry;
62
+ readonly FlashEndOrder: Entry;
63
+ readonly ReceiverCannotReceive: Entry;
64
+ readonly RefundCannotReceive: Entry;
65
+ readonly FeeAboveBound: Entry;
66
+ readonly ExtTooLong: Entry;
67
+ readonly ExtMalformed: Entry;
68
+ readonly ExtUnknown: Entry;
69
+ readonly FlagsUnknown: Entry;
70
+ readonly FillKindDisabled: Entry;
71
+ readonly UnsupportedVersion: Entry;
72
+ readonly AmountInMismatch: Entry;
73
+ readonly EpochRegression: Entry;
74
+ readonly TreasuryMismatch: Entry;
75
+ readonly CrankBountyTooHigh: Entry;
76
+ readonly CreateFeeTooHigh: Entry;
77
+ readonly PartnerCutTooHigh: Entry;
78
+ readonly PartnerFeeTooHigh: Entry;
79
+ readonly PartnerAccountMissing: Entry;
80
+ readonly PartnerAccountNotCanonical: Entry;
81
+ readonly MandateInvalid: Entry;
82
+ readonly MandateExpired: Entry;
83
+ readonly MandateKind: Entry;
84
+ readonly MandateTtl: Entry;
85
+ readonly MandateCap: Entry;
86
+ readonly MandateBudget: Entry;
87
+ readonly MandateCount: Entry;
88
+ readonly MandatePrice: Entry;
89
+ readonly MandateRevoked: Entry;
90
+ readonly MandateMismatch: Entry;
91
+ readonly CreateCostAboveCeiling: Entry;
92
+ readonly NonceJumpTooLarge: Entry;
93
+ readonly EpochJumpTooLarge: Entry;
94
+ };
95
+ export type EngineErrorName = keyof typeof ENGINE_PROBLEMS;
96
+ export declare const ENGINE_ERROR_BASE = 6000;
97
+ export declare const ENGINE_ERROR_NAMES: EngineErrorName[];
98
+ export declare const TOKEN_PROGRAMS: Address[];
99
+ export declare const TOKEN_PROBLEMS: Record<number, {
100
+ code: string;
101
+ } & Entry>;
102
+ export declare function failureOf(logs: readonly string[]): {
103
+ program: Address;
104
+ code: number;
105
+ } | null;
106
+ export declare const LOG_TAIL = 12;
107
+ export declare const LOG_LINE_LIMIT = 200;
108
+ export declare function simulationProblem(err: string, logs: readonly string[]): Problem;
109
+ export declare class SimulationFailed extends Error {
110
+ readonly problem: Problem;
111
+ constructor(problem: Problem);
112
+ }
113
+ export declare class AgentRefusal extends Error {
114
+ readonly problem: Problem;
115
+ constructor(code: string, hint: string, retryable?: boolean);
116
+ }
117
+ export declare const HINT_LIMIT = 300;
118
+ export declare const untrusted: (text: string) => string;
119
+ export declare function problemOf(error: unknown): Problem;
120
+ export {};
@@ -0,0 +1,189 @@
1
+ import { tool } from "./names.js";
2
+ import { BPS_DENOMINATOR, INTENT_ENGINE_PROGRAM_ADDRESS, IntentCoreError, MAX_PARTNER_BPS } from "@intent-engine/core";
3
+ import { MissingAccount, NotAMint } from "../accounts.js";
4
+ import { rateLimited } from "../transport.js";
5
+ import { InvalidInput } from "./schema.js";
6
+ const never = (hint) => ({ retryable: false, hint });
7
+ const later = (hint) => ({ retryable: true, hint });
8
+ export const ENGINE_PROBLEMS = {
9
+ Overflow: never("an amount is too large for the arithmetic; use smaller amounts"),
10
+ DivideByZero: never("the arithmetic divided by zero; validated order terms never reach this, so rebuild the transaction with this server"),
11
+ Truncated: never("the instruction data was cut short; rebuild the transaction with this server"),
12
+ NonCanonical: never("the instruction data was not encoded canonically; rebuild the transaction with this server"),
13
+ UnknownKind: never("the intent kind is not one the program knows; use swap, limit, dutch or attested"),
14
+ UnknownStatus: never(`the intent holds a status this client does not know; read it again with ${tool("get_intent")}`),
15
+ InvalidParams: never("the order terms are inconsistent; check amounts are non-zero and the auction times are ordered"),
16
+ AmountMismatch: never("the amounts do not match what the intent escrows; read the intent again and use its remaining amount"),
17
+ InsufficientOutput: later(`the fill pays less than the intent requires right now; quote again with ${tool("quote")}`),
18
+ InvalidTransition: never(`the intent is not in a state that allows this; read it with ${tool("get_intent")}`),
19
+ IntentExpired: never(`the intent has expired and can no longer be filled; its owner can still cancel it, and anyone can expire and close it (${tool("prepare_crank")})`),
20
+ NotExpired: later("the intent has not expired yet; wait until its expiry time and try again"),
21
+ NonceUsed: never("this nonce is already used; omit the nonce so the next free one is chosen"),
22
+ NonceOutOfWindow: never("this nonce is outside the owner's 256-nonce window or inside the agent nonce lanes; omit the nonce so the next free one is chosen"),
23
+ NonceRegression: never("the nonce base can only move forward"),
24
+ Unauthorized: never("a signer or a named account does not match the one recorded on-chain (owner, rent payer, mandate agent, admin, guardian or upgrade authority); let this server pick the accounts and sign with the recorded key"),
25
+ CreatePaused: later(`creating intents is paused by the guardian or admin; check paused.create in ${tool("get_config")} and try again later`),
26
+ KindDisabled: never(`this intent kind is not enabled; see kinds[].enabled in ${tool("get_config")}`),
27
+ UnknownKindBits: never("the kind mask names kinds the program does not know"),
28
+ InvalidPauseFlags: never("the pause flags are empty or name pauses the program does not know; use create, fill or all"),
29
+ FeeTooHigh: never("the configured fee exceeds the program's maximum"),
30
+ NotPendingAdmin: never("only the proposed admin can accept the admin role"),
31
+ ExpiryNotInFuture: never("the expiry must be later than the current chain time; use a later expiry"),
32
+ SameMint: never("the input and output mints must differ"),
33
+ MintNotAllowed: never("this mint cannot be used: it has a token extension the program refuses"),
34
+ RefundNotCanonical: never("refunds go only to the owner's canonical token account; let this server pick accounts"),
35
+ ReceiverNotAllowed: never("the receiver account is not owned by the named receiver authority, the authority is an engine account, or (for a mandate) the receiver is not an account the owner controls"),
36
+ AuctionOutlivesExpiry: never("the dutch auction must end at or before the intent expires"),
37
+ FillPaused: later(`fills are paused by the guardian or admin; check paused.fill in ${tool("get_config")} and try again later`),
38
+ FeeAccountNotCanonical: never("a fee must go to its payee's canonical token account (the treasury's, or the agent's); let this server pick it"),
39
+ FeeAccountMissing: never("a fee account was not passed: the treasury's or agent's at fill, or the relayer's at a signed create; create that token account and pass it"),
40
+ SolverOutputNotAllowed: never("the solver's output account is not acceptable for this fill"),
41
+ SigProgram: never("the signature instruction must come from the Ed25519 program"),
42
+ SigHeader: never("the Ed25519 instruction is malformed; rebuild it with this server"),
43
+ SigPubkey: never("the signature was made by a different key than the owner"),
44
+ SigMessage: never(`the signed message does not match this intent; sign the exact message from ${tool("prepare_signed_intent")}`),
45
+ KindMismatch: never("the instruction does not match the intent's kind"),
46
+ ResultOutOfBounds: never("the attested result is outside the intent's bounds"),
47
+ SigMissing: never("the Ed25519 signature instruction is missing; rebuild the transaction with this server"),
48
+ InvalidDomain: never("the config domain must not be zero; pass this cluster's genesis hash to init-config"),
49
+ SignatureExpired: never("the signed intent passed its submit-by time; ask the owner to sign a new one"),
50
+ FlashCpi: never("a flash fill cannot be started from inside another program"),
51
+ FlashEndProgram: never("the flash fill must end with this program's end_fill"),
52
+ FlashEndDiscriminator: never("the flash fill's closing instruction is not end_fill"),
53
+ FlashEndIntent: never("the flash fill ends a different intent than it began"),
54
+ FlashEndOrder: never("the flash fill's begin and end are out of order"),
55
+ ReceiverCannotReceive: never("the receiver token account cannot receive: frozen, closed, not initialized, for another mint or owner, or with an extension other than ImmutableOwner; use another receiver"),
56
+ RefundCannotReceive: never("the refund account cannot take the refund: frozen, for another mint or owner, or with a foreign delegate, close authority or extension; refund to another account the owner controls, or wait for a frozen one to be thawed"),
57
+ FeeAboveBound: never("the current fees exceed the bound the solver accepted"),
58
+ ExtTooLong: never("the extension data is too long"),
59
+ ExtMalformed: never("the extension data is malformed: badly encoded, tags unsorted or repeated, or a partner with a zero key or zero bps"),
60
+ ExtUnknown: never("the extension data holds a field the program does not know"),
61
+ FlagsUnknown: never("the intent flags name options the program does not know; leave flags unset"),
62
+ FillKindDisabled: never(`the admin stopped fills of this kind; see kinds[].fills_stopped in ${tool("get_config")}`),
63
+ UnsupportedVersion: never("an account has a version this program does not support"),
64
+ AmountInMismatch: never("the fill must sell exactly the intent's remaining amount; read the intent again"),
65
+ EpochRegression: never("the signing epoch can only move forward"),
66
+ TreasuryMismatch: never("the treasury account must be the configured fee recipient; let this server pick it"),
67
+ CrankBountyTooHigh: never("the crank bounty exceeds the program's maximum"),
68
+ CreateFeeTooHigh: never("the create fee exceeds the program's maximum"),
69
+ PartnerCutTooHigh: never(`the partner cut must be at most ${BPS_DENOMINATOR} bps`),
70
+ PartnerFeeTooHigh: never(`a partner fee can be at most ${MAX_PARTNER_BPS} bps`),
71
+ PartnerAccountMissing: later("the partner has no token account for the input mint yet; it must be created before a fill"),
72
+ PartnerAccountNotCanonical: never("the partner fee must go to the partner's canonical token account"),
73
+ MandateInvalid: never("the mandate's terms are unsound: kinds must be swap, limit or dutch; per-intent cap above the agent fee; total at least the per-intent cap; max intents, max lifetime and floors non-zero; valid until a future time; a partner needs both key and bps; the agent neither empty nor the owner; or the owner has used every grant lane"),
74
+ MandateExpired: never(`the mandate has expired; the owner must grant a new one with ${tool("prepare_mandate")}`),
75
+ MandateKind: never("the mandate does not allow this kind of intent"),
76
+ MandateTtl: never("the intent lives longer than the mandate allows; choose an earlier expiry within it"),
77
+ MandateCap: never("the intent draws more than the mandate's per-intent cap (amount sold plus agent fee); the owner set that cap, so stay within it or ask the owner, and never split or reword an order to get around it"),
78
+ MandateBudget: never(`the mandate's total budget would be exceeded; check what remains with ${tool("get_mandate")}`),
79
+ MandateCount: never("the mandate has already created as many intents as it allows"),
80
+ MandatePrice: never("the minimum output is below the price floor the owner set; do not weaken the person's price on your own: tell them the order is cheaper than the owner allows, or ask for at least the floor"),
81
+ MandateRevoked: never("this mandate no longer stands: the owner revoked it, granted that id again, or advanced their signing epoch; the owner must grant a new one"),
82
+ MandateMismatch: never("the intent differs from the mandate's fixed terms: same mints, no flags, the owner's partner only, and proceeds to an account the owner holds"),
83
+ CreateCostAboveCeiling: later("the engine's create fee or crank bounty rose above what this transaction allows; prepare it again and check the new cost before signing"),
84
+ NonceJumpTooLarge: never("one advance may move the nonce base at most 2^32 past its current value and never into the agent nonce lanes; advance in smaller steps"),
85
+ EpochJumpTooLarge: never("one advance may raise the signing epoch at most 2^48; pick a smaller next epoch"),
86
+ };
87
+ export const ENGINE_ERROR_BASE = 6000;
88
+ export const ENGINE_ERROR_NAMES = Object.keys(ENGINE_PROBLEMS);
89
+ export const TOKEN_PROGRAMS = [
90
+ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
91
+ "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb",
92
+ ];
93
+ export const TOKEN_PROBLEMS = {
94
+ 1: { code: "InsufficientFunds", ...never("a token account, or the allowance a signed or agent create draws through, holds less than the amount; lower the amount or fund the account") },
95
+ 3: { code: "MintMismatch", ...never("a token account belongs to a different mint than the intent uses") },
96
+ 4: { code: "OwnerMismatch", ...never("a token account is not owned by the expected wallet") },
97
+ 17: { code: "AccountFrozen", ...later("a token account is frozen by its issuer; try again once it is thawed") },
98
+ 36: { code: "NoMemo", ...never("a token account requires a memo on incoming transfers; its owner must turn that off before it can receive") },
99
+ 42: {
100
+ code: "CpiGuardTransferBlocked",
101
+ ...never(`the owner's token account has CPI Guard on, which stops the engine moving tokens on the owner's signature; use ${tool("prepare_signed_intent")}, which draws through the engine's allowance, or turn CPI Guard off`),
102
+ },
103
+ };
104
+ const FAILED = /^Program (\w{32,44}) failed: custom program error: 0x([0-9a-f]+)$/;
105
+ export function failureOf(logs) {
106
+ for (const line of logs) {
107
+ const match = FAILED.exec(line);
108
+ if (match !== null) {
109
+ return { program: match[1], code: Number.parseInt(match[2] ?? "", 16) };
110
+ }
111
+ }
112
+ return null;
113
+ }
114
+ const engineProblem = (name) => ({
115
+ code: name,
116
+ programError: ENGINE_ERROR_BASE + ENGINE_ERROR_NAMES.indexOf(name),
117
+ program: INTENT_ENGINE_PROGRAM_ADDRESS,
118
+ ...ENGINE_PROBLEMS[name],
119
+ });
120
+ export const LOG_TAIL = 12;
121
+ export const LOG_LINE_LIMIT = 200;
122
+ export function simulationProblem(err, logs) {
123
+ const tail = logs.slice(-LOG_TAIL).map((line) => untrusted(line).slice(0, LOG_LINE_LIMIT));
124
+ const failure = failureOf(logs);
125
+ if (failure !== null && failure.program === INTENT_ENGINE_PROGRAM_ADDRESS) {
126
+ const name = ENGINE_ERROR_NAMES[failure.code - ENGINE_ERROR_BASE];
127
+ if (name !== undefined) {
128
+ return { ...engineProblem(name), logs: tail };
129
+ }
130
+ }
131
+ if (failure !== null && TOKEN_PROGRAMS.includes(failure.program)) {
132
+ const known = TOKEN_PROBLEMS[failure.code];
133
+ if (known !== undefined) {
134
+ return { ...known, programError: failure.code, program: failure.program, logs: tail };
135
+ }
136
+ }
137
+ return {
138
+ code: "TransactionFailed",
139
+ retryable: false,
140
+ hint: `the transaction would fail (${untrusted(err)}); read the logs for the cause`,
141
+ ...(failure === null ? {} : { programError: failure.code, program: failure.program }),
142
+ logs: tail,
143
+ };
144
+ }
145
+ export class SimulationFailed extends Error {
146
+ problem;
147
+ constructor(problem) {
148
+ super(problem.hint);
149
+ this.name = "SimulationFailed";
150
+ this.problem = problem;
151
+ }
152
+ }
153
+ export class AgentRefusal extends Error {
154
+ problem;
155
+ constructor(code, hint, retryable = false) {
156
+ super(hint);
157
+ this.name = "AgentRefusal";
158
+ this.problem = { code, retryable, hint };
159
+ }
160
+ }
161
+ export const HINT_LIMIT = 300;
162
+ export const untrusted = (text) => text.replace(/[^ -~]+/g, " ").slice(0, HINT_LIMIT);
163
+ export function problemOf(error) {
164
+ if (error instanceof InvalidInput) {
165
+ return { code: "InvalidInput", retryable: false, hint: "fix the listed fields and call again", issues: error.issues };
166
+ }
167
+ if (error instanceof SimulationFailed || error instanceof AgentRefusal) {
168
+ return error.problem;
169
+ }
170
+ if (error instanceof IntentCoreError) {
171
+ return engineProblem(error.code);
172
+ }
173
+ if (error instanceof MissingAccount) {
174
+ return { code: "NotFound", retryable: false, hint: error.message };
175
+ }
176
+ if (error instanceof NotAMint) {
177
+ return {
178
+ code: "NotAMint",
179
+ retryable: false,
180
+ hint: `${error.address} is not a token mint; pass the mint of the token itself, not a wallet or a token account`,
181
+ };
182
+ }
183
+ if (rateLimited(error)) {
184
+ return { code: "RateLimited", retryable: true, hint: "the RPC node is rate limiting; wait a few seconds and call again" };
185
+ }
186
+ const message = error instanceof Error ? error.message : String(error);
187
+ return { code: "Failed", retryable: false, hint: untrusted(message) };
188
+ }
189
+ //# sourceMappingURL=problems.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"problems.js","sourceRoot":"","sources":["../../../src/agent/problems.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACvH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAc,MAAM,aAAa,CAAC;AAcvD,M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AAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,kEAAkE,EAAE,CAAC;IAC5H,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;AACxE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Address } from "@solana/kit";
2
+ import type { Transport } from "../transport.js";
3
+ import { type Decimals } from "./shapes.js";
4
+ export declare const LIST_LIMIT = 100;
5
+ export declare const LIST_DEFAULT = 20;
6
+ export declare const getConfig: import("./actions.js").AnyAction;
7
+ export declare const getIntent: import("./actions.js").AnyAction;
8
+ export declare const listIntents: import("./actions.js").AnyAction;
9
+ export declare const BALANCE_MINTS = 8;
10
+ export declare const SOL_DECIMALS = 9;
11
+ export declare function decimalsFor(transport: Transport, cache: Map<Address, number | null>, inputMint: Address, outputMint: Address): Promise<Decimals>;
12
+ export declare const getBalances: import("./actions.js").AnyAction;
13
+ export declare const quote: import("./actions.js").AnyAction;