@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,47 @@
1
+ import { AgentRefusal } from "./problems.js";
2
+ export const PREPARED_TTL = 120n;
3
+ export const MAX_PENDING_PER_OWNER = 16;
4
+ export const claimsOf = () => ({ held: new Map(), busy: new Set() });
5
+ export const callOf = () => ({ undo: [] });
6
+ export function claimedBy(claims, owner, now) {
7
+ const held = claims.held.get(owner);
8
+ if (held === undefined) {
9
+ return new Set();
10
+ }
11
+ for (const [nonce, until] of held) {
12
+ if (until < now) {
13
+ held.delete(nonce);
14
+ }
15
+ }
16
+ if (held.size === 0) {
17
+ claims.held.delete(owner);
18
+ }
19
+ return new Set(held.keys());
20
+ }
21
+ export function claim(claims, call, owner, nonce, until, now) {
22
+ const pending = claimedBy(claims, owner, now);
23
+ if (pending.has(nonce)) {
24
+ throw new AgentRefusal("NoncePromised", `nonce ${nonce} of ${owner} is already handed to another pending request; leave nonce out to get a free one, or ask again once that request expires`, true);
25
+ }
26
+ if (pending.size >= MAX_PENDING_PER_OWNER) {
27
+ throw new AgentRefusal("TooManyPending", `${owner} already has ${MAX_PENDING_PER_OWNER} prepared requests waiting; submit some or let them expire (a signed intent holds its nonce until its submit_by), then ask again`, true);
28
+ }
29
+ const held = claims.held.get(owner) ?? new Map();
30
+ held.set(nonce, until);
31
+ claims.held.set(owner, held);
32
+ call.undo.push(() => {
33
+ if (held.get(nonce) === until) {
34
+ held.delete(nonce);
35
+ }
36
+ });
37
+ }
38
+ export function enter(claims, key) {
39
+ if (claims.busy.has(key)) {
40
+ throw new AgentRefusal("SubmitInFlight", "this intent is being relayed by another request right now; ask again in a moment to see whether it landed", true);
41
+ }
42
+ claims.busy.add(key);
43
+ return () => {
44
+ claims.busy.delete(key);
45
+ };
46
+ }
47
+ //# sourceMappingURL=claims.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claims.js","sourceRoot":"","sources":["../../../src/agent/claims.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAMxC,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAW,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC;AAE7E,MAAM,CAAC,MAAM,MAAM,GAAG,GAAS,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;AAEjD,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,KAAc,EAAE,GAAW;IACnE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;IACD,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;QAClC,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACr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c,EAAE,GAAW;IAC/C,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,YAAY,CACpB,gBAAgB,EAChB,2GAA2G,EAC3G,IAAI,CACL,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACrB,OAAO,GAAG,EAAE;QACV,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { Kind } from "@intent-engine/core";
2
+ export declare const MAX_EXPIRES_IN: number;
3
+ export declare const MIN_EXPIRES_IN = 60;
4
+ export declare function expiryOf(input: {
5
+ expires_at?: bigint;
6
+ expires_in?: number;
7
+ }, now: bigint): bigint;
8
+ export declare const termsInput: {
9
+ owner: import("./schema.js").Schema<import("@solana/kit").Address>;
10
+ input_mint: import("./schema.js").Schema<import("@solana/kit").Address>;
11
+ output_mint: import("./schema.js").Schema<import("@solana/kit").Address>;
12
+ order: import("./schema.js").Schema<({
13
+ kind: "attested";
14
+ } & {
15
+ amount_in: bigint;
16
+ min_result: bigint;
17
+ max_result: bigint;
18
+ attestor: import("@solana/kit").Address;
19
+ } & {}) | ({
20
+ kind: "dutch";
21
+ } & {
22
+ amount_in: bigint;
23
+ start_out: bigint;
24
+ end_out: bigint;
25
+ start_time: bigint;
26
+ end_time: bigint;
27
+ } & {}) | ({
28
+ kind: "limit";
29
+ } & {
30
+ make_amount: bigint;
31
+ take_amount: bigint;
32
+ } & {}) | ({
33
+ kind: "swap";
34
+ } & {
35
+ amount_in: bigint;
36
+ min_out: bigint;
37
+ } & {})>;
38
+ expires_at: import("./schema.js").Optional<bigint>;
39
+ expires_in: import("./schema.js").Optional<number>;
40
+ nonce: import("./schema.js").Optional<bigint>;
41
+ partner: import("./schema.js").Optional<{
42
+ account: import("@solana/kit").Address;
43
+ bps: number;
44
+ } & {}>;
45
+ };
46
+ export declare const termsOutput: {
47
+ intent: import("./schema.js").Schema<import("@solana/kit").Address>;
48
+ nonce: import("./schema.js").Schema<bigint>;
49
+ expires_at: import("./schema.js").Schema<bigint>;
50
+ escrow: import("./schema.js").Schema<bigint>;
51
+ summary: import("./schema.js").Schema<string[]>;
52
+ warnings: import("./schema.js").Schema<string[]>;
53
+ };
54
+ export declare const WARN_SCALED = "a token here scales the amounts wallets display (interest-bearing or scaled UI amount); the amounts shown are base units at its decimals";
55
+ export declare function warningsOf(kind: Kind, expiresAt: bigint, now: bigint, scaled: boolean): string[];
56
+ export declare const prepareCreate: import("./actions.js").AnyAction;
@@ -0,0 +1,119 @@
1
+ import { createNoopSigner } from "@solana/kit";
2
+ import { buildCreateIntent, describeTerms, encodeParams, escrowAmount, formatTime, Kind, LONG_LIVED_SECONDS, validate, WARN_ATTESTOR, WARN_LONG_LIVED, } from "@intent-engine/core";
3
+ import { chainTime, loadConfig, mintOf } from "../accounts.js";
4
+ import { define } from "./actions.js";
5
+ import { tool } from "./names.js";
6
+ import { claim, claimedBy, PREPARED_TTL } from "./claims.js";
7
+ import { initUserIfMissing, pickNonce, setupLines, tokenAccountIfMissing, unusedIntent, userOf, wrapIfShort } from "./owner.js";
8
+ import { prepare } from "./prepare.js";
9
+ import { InvalidInput } from "./schema.js";
10
+ import { orderSchema, paramsOf, partnerSchema, preparedSchema, preparedView } from "./shapes.js";
11
+ import { tokenNames } from "../tokens.js";
12
+ import { account, amount, integer, list, object, optional, text, time } from "./schema.js";
13
+ export const MAX_EXPIRES_IN = 365 * 24 * 60 * 60;
14
+ export const MIN_EXPIRES_IN = 60;
15
+ export function expiryOf(input, now) {
16
+ if (input.expires_at !== undefined && input.expires_in === undefined) {
17
+ return input.expires_at;
18
+ }
19
+ if (input.expires_in !== undefined && input.expires_at === undefined) {
20
+ return now + BigInt(input.expires_in);
21
+ }
22
+ throw new InvalidInput([{ path: "expires_at", message: "give exactly one of expires_at or expires_in" }]);
23
+ }
24
+ export const termsInput = {
25
+ owner: account("the wallet that sells and signs; it pays the fees and rent"),
26
+ input_mint: account("the token to sell"),
27
+ output_mint: account("the token to receive"),
28
+ order: orderSchema,
29
+ expires_at: optional(time("unix seconds after which nobody can fill the intent; give exactly one of expires_at and expires_in")),
30
+ expires_in: optional(integer(MIN_EXPIRES_IN, MAX_EXPIRES_IN, "seconds from now until the intent expires; give exactly one of expires_at and expires_in")),
31
+ nonce: optional(amount("leave out to use the owner's next free nonce")),
32
+ partner: optional(partnerSchema),
33
+ };
34
+ export const termsOutput = {
35
+ intent: account("the address the intent will have"),
36
+ nonce: amount(),
37
+ expires_at: time(),
38
+ escrow: amount("raw input units locked until the intent is filled, cancelled or expired"),
39
+ summary: list(text(), 24, "the terms in plain words; show these to the owner before signing"),
40
+ warnings: list(text(), 16),
41
+ };
42
+ export const WARN_SCALED = "a token here scales the amounts wallets display (interest-bearing or scaled UI amount); the amounts shown are base units at its decimals";
43
+ export function warningsOf(kind, expiresAt, now, scaled) {
44
+ return [
45
+ ...(kind === Kind.AttestedResult ? [WARN_ATTESTOR] : []),
46
+ ...(expiresAt - now > LONG_LIVED_SECONDS ? [WARN_LONG_LIVED] : []),
47
+ ...(scaled ? [WARN_SCALED] : []),
48
+ ];
49
+ }
50
+ export const prepareCreate = define({
51
+ name: tool("prepare_create"),
52
+ title: "Prepare a new intent",
53
+ description: "Build the transaction that escrows the owner's tokens in a new intent: sell exactly the given amount and receive at least the given output before the expiry (for attested orders, an amount set by the attested result), or get everything back. Returns an unsigned transaction that already simulated successfully; the owner's wallet must sign and send it. Nothing moves until then.",
54
+ effect: "prepare",
55
+ input: object(termsInput),
56
+ output: object({
57
+ ...termsOutput,
58
+ create_fee: amount("lamports the owner pays the treasury"),
59
+ crank_bounty: amount("lamports the owner escrows for whoever later expires or closes the intent"),
60
+ wraps: amount("lamports of the owner's SOL wrapped first so the escrow can be drawn from their wrapped SOL account; 0 for other tokens"),
61
+ prepared: preparedSchema,
62
+ }),
63
+ run: async ({ transport, claims }, input, call) => {
64
+ const now = await chainTime(transport);
65
+ const expiresAt = expiryOf(input, now);
66
+ const params = validate(paramsOf(input.order));
67
+ const { config } = await loadConfig(transport);
68
+ const [inputToken, outputToken] = [await mintOf(transport, input.input_mint), await mintOf(transport, input.output_mint)];
69
+ const user = await userOf(transport, input.owner);
70
+ if (input.nonce !== undefined) {
71
+ await unusedIntent(transport, input.owner, input.nonce);
72
+ }
73
+ const nonce = pickNonce(user, input.nonce, claimedBy(claims, input.owner, now));
74
+ claim(claims, call, input.owner, nonce, now + PREPARED_TTL, now);
75
+ const intent = await unusedIntent(transport, input.owner, nonce);
76
+ const owner = createNoopSigner(input.owner);
77
+ const receiver = await tokenAccountIfMissing(transport, owner, input.owner, input.output_mint, outputToken.tokenProgram);
78
+ const create = await buildCreateIntent({
79
+ owner,
80
+ treasury: config.feeRecipient,
81
+ maxCreateFee: config.createFee,
82
+ maxBounty: config.crankBounty,
83
+ nonce,
84
+ params,
85
+ expiresAt,
86
+ ...(input.partner === undefined ? {} : { partner: { key: input.partner.account, bps: input.partner.bps } }),
87
+ inputMint: input.input_mint,
88
+ outputMint: input.output_mint,
89
+ inputTokenProgram: inputToken.tokenProgram,
90
+ outputTokenProgram: outputToken.tokenProgram,
91
+ });
92
+ const register = await initUserIfMissing(user, input.owner);
93
+ const wrap = await wrapIfShort(transport, input.owner, input.input_mint, inputToken.tokenProgram, escrowAmount(params));
94
+ const prepared = await prepare(transport, [...register, ...receiver.create, ...wrap.instructions, create], input.owner);
95
+ return {
96
+ intent,
97
+ nonce,
98
+ expires_at: expiresAt,
99
+ escrow: escrowAmount(params),
100
+ summary: [
101
+ ...describeTerms({ kind: params.kind, params: encodeParams(params), inputMint: input.input_mint, outputMint: input.output_mint }, { inputDecimals: inputToken.decimals, outputDecimals: outputToken.decimals, ...tokenNames(input.input_mint, input.output_mint) }),
102
+ `Expires: ${formatTime(expiresAt)}`,
103
+ ...(input.partner === undefined ? [] : [`Partner fee: ${input.partner.bps} bps of the sold amount to ${input.partner.account}`]),
104
+ ...setupLines({
105
+ registers: register.length > 0,
106
+ creates: receiver.create.length > 0 ? [input.output_mint] : [],
107
+ allowance: null,
108
+ wraps: wrap.lamports,
109
+ }).lines,
110
+ ],
111
+ warnings: warningsOf(params.kind, expiresAt, now, inputToken.scaled || outputToken.scaled),
112
+ create_fee: BigInt(config.createFee),
113
+ crank_bounty: BigInt(config.crankBounty),
114
+ wraps: wrap.lamports,
115
+ prepared: preparedView(prepared),
116
+ };
117
+ },
118
+ });
119
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/agent/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,kBAAkB,EAClB,QAAQ,EACR,aAAa,EACb,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChI,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjG,OAA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YACxC,KAAK,EAAE,IAAI,CAAC,QAAQ;YACpB,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC;SACjC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { type Address } from "@solana/kit";
2
+ import { type Mandate } from "@intent-engine/core";
3
+ import type { Transport } from "../transport.js";
4
+ import { type Call, type Claims } from "./claims.js";
5
+ export declare const MANDATE_KIND_NAMES: readonly ["swap", "limit", "dutch"];
6
+ export declare const MAX_MANDATE_SECONDS: number;
7
+ export declare const MAX_MANDATE_INTENTS = 1000000;
8
+ export declare const MANDATE_ID_PROBES = 64;
9
+ export declare const REVOKE_CANCELS = 6;
10
+ export declare const NO_MANDATE_HINT = "it was never granted, or the owner revoked it, which closes it";
11
+ export declare const WARN_STILL_OPEN = "some of the agent's intents stay open after this; they can no longer be filled, but their escrow stays locked until you cancel them";
12
+ export declare function loadMandate(transport: Transport, owner: Address, agent: Address, id: bigint): Promise<{
13
+ address: Address<string>;
14
+ mandate: Mandate;
15
+ }>;
16
+ export declare function limitsOf(m: Mandate): string;
17
+ export declare function explained(m: Mandate): (error: unknown) => never;
18
+ export declare const AGENT_NONCE_PROBES = 64n;
19
+ export type Holding = {
20
+ claims: Claims;
21
+ call: Call;
22
+ now: bigint;
23
+ };
24
+ export declare function agentNonce(transport: Transport, owner: Address, serial: bigint, used: number, hold: Holding): Promise<bigint>;
25
+ export declare function freeMandateId(transport: Transport, owner: Address, agent: Address): Promise<bigint>;
26
+ export declare const prepareMandate: import("./actions.js").AnyAction;
27
+ export declare const getMandate: import("./actions.js").AnyAction;
28
+ export declare const prepareRevokeMandate: import("./actions.js").AnyAction;
29
+ export declare const prepareAgentCreate: import("./actions.js").AnyAction;
30
+ export declare const agentCreate: import("./actions.js").AnyAction;