@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.
- package/LICENSE +202 -0
- package/dist/src/accounts.d.ts +112 -0
- package/dist/src/accounts.js +162 -0
- package/dist/src/accounts.js.map +1 -0
- package/dist/src/agent/actions.d.ts +45 -0
- package/dist/src/agent/actions.js +43 -0
- package/dist/src/agent/actions.js.map +1 -0
- package/dist/src/agent/budget.d.ts +22 -0
- package/dist/src/agent/budget.js +31 -0
- package/dist/src/agent/budget.js.map +1 -0
- package/dist/src/agent/claims.d.ts +15 -0
- package/dist/src/agent/claims.js +47 -0
- package/dist/src/agent/claims.js.map +1 -0
- package/dist/src/agent/create.d.ts +56 -0
- package/dist/src/agent/create.js +118 -0
- package/dist/src/agent/create.js.map +1 -0
- package/dist/src/agent/mandate.d.ts +30 -0
- package/dist/src/agent/mandate.js +478 -0
- package/dist/src/agent/mandate.js.map +1 -0
- package/dist/src/agent/mcp.d.ts +17 -0
- package/dist/src/agent/mcp.js +53 -0
- package/dist/src/agent/mcp.js.map +1 -0
- package/dist/src/agent/names.d.ts +1 -0
- package/dist/src/agent/names.js +3 -0
- package/dist/src/agent/names.js.map +1 -0
- package/dist/src/agent/owner.d.ts +40 -0
- package/dist/src/agent/owner.js +123 -0
- package/dist/src/agent/owner.js.map +1 -0
- package/dist/src/agent/prepare.d.ts +14 -0
- package/dist/src/agent/prepare.js +32 -0
- package/dist/src/agent/prepare.js.map +1 -0
- package/dist/src/agent/problems.d.ts +120 -0
- package/dist/src/agent/problems.js +189 -0
- package/dist/src/agent/problems.js.map +1 -0
- package/dist/src/agent/read.d.ts +13 -0
- package/dist/src/agent/read.js +210 -0
- package/dist/src/agent/read.js.map +1 -0
- package/dist/src/agent/registry.d.ts +2 -0
- package/dist/src/agent/registry.js +24 -0
- package/dist/src/agent/registry.js.map +1 -0
- package/dist/src/agent/relay.d.ts +20 -0
- package/dist/src/agent/relay.js +43 -0
- package/dist/src/agent/relay.js.map +1 -0
- package/dist/src/agent/schema.d.ts +68 -0
- package/dist/src/agent/schema.js +210 -0
- package/dist/src/agent/schema.js.map +1 -0
- package/dist/src/agent/settle.d.ts +5 -0
- package/dist/src/agent/settle.js +144 -0
- package/dist/src/agent/settle.js.map +1 -0
- package/dist/src/agent/shapes.d.ts +165 -0
- package/dist/src/agent/shapes.js +162 -0
- package/dist/src/agent/shapes.js.map +1 -0
- package/dist/src/agent/signed.d.ts +21 -0
- package/dist/src/agent/signed.js +360 -0
- package/dist/src/agent/signed.js.map +1 -0
- package/dist/src/agent/wallet.d.ts +18 -0
- package/dist/src/agent/wallet.js +186 -0
- package/dist/src/agent/wallet.js.map +1 -0
- package/dist/src/args.d.ts +491 -0
- package/dist/src/args.js +1124 -0
- package/dist/src/args.js.map +1 -0
- package/dist/src/bin.d.ts +2 -0
- package/dist/src/bin.js +4 -0
- package/dist/src/bin.js.map +1 -0
- package/dist/src/commands.d.ts +51 -0
- package/dist/src/commands.js +451 -0
- package/dist/src/commands.js.map +1 -0
- package/dist/src/compute.d.ts +19 -0
- package/dist/src/compute.js +81 -0
- package/dist/src/compute.js.map +1 -0
- package/dist/src/crank.d.ts +39 -0
- package/dist/src/crank.js +171 -0
- package/dist/src/crank.js.map +1 -0
- package/dist/src/events.d.ts +8 -0
- package/dist/src/events.js +43 -0
- package/dist/src/events.js.map +1 -0
- package/dist/src/flows.d.ts +23 -0
- package/dist/src/flows.js +128 -0
- package/dist/src/flows.js.map +1 -0
- package/dist/src/main.d.ts +32 -0
- package/dist/src/main.js +99 -0
- package/dist/src/main.js.map +1 -0
- package/dist/src/render.d.ts +5 -0
- package/dist/src/render.js +46 -0
- package/dist/src/render.js.map +1 -0
- package/dist/src/tokens.d.ts +6 -0
- package/dist/src/tokens.js +15 -0
- package/dist/src/tokens.js.map +1 -0
- package/dist/src/transport.d.ts +155 -0
- package/dist/src/transport.js +173 -0
- package/dist/src/transport.js.map +1 -0
- package/dist/src/treasury.d.ts +27 -0
- package/dist/src/treasury.js +85 -0
- package/dist/src/treasury.js.map +1 -0
- package/dist/src/version.d.ts +1 -0
- package/dist/src/version.js +2 -0
- package/dist/src/version.js.map +1 -0
- package/dist/src/wallet.d.ts +29 -0
- package/dist/src/wallet.js +108 -0
- package/dist/src/wallet.js.map +1 -0
- package/package.json +37 -3
- package/README.md +0 -3
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { getTokenDecoder } from "@solana-program/token";
|
|
2
|
+
import { feeBpsFor, findAssociatedTokenAddress, findDelegatePda, formatAmount, getIntentDecoder, IntentStatus, kindBit, PAUSE_CREATE, PAUSE_FILL, remainingOf, } from "@intent-engine/core";
|
|
3
|
+
import { chainTime, clusterDomain, createdAccount, loadConfig, loadIntent, mintOf, quoteOf, sameBytes, STATUS } from "../accounts.js";
|
|
4
|
+
import { define } from "./actions.js";
|
|
5
|
+
import { tool } from "./names.js";
|
|
6
|
+
import { intentSchema, intentView, KIND_NAMES, KINDS } from "./shapes.js";
|
|
7
|
+
import { account, amount, choice, flag, integer, list, object, optional, text, time } from "./schema.js";
|
|
8
|
+
export const LIST_LIMIT = 100;
|
|
9
|
+
export const LIST_DEFAULT = 20;
|
|
10
|
+
const intentRef = {
|
|
11
|
+
owner: account("the wallet that created the intent"),
|
|
12
|
+
nonce: amount("the intent's nonce under that owner"),
|
|
13
|
+
};
|
|
14
|
+
export const getConfig = define({
|
|
15
|
+
name: tool("get_config"),
|
|
16
|
+
title: "Engine settings",
|
|
17
|
+
description: "Read the engine's live settings: which order kinds are enabled, fees per kind, the partner cut, the create fee and crank bounty in lamports, and whether creating or filling is paused.",
|
|
18
|
+
effect: "read",
|
|
19
|
+
input: object({}),
|
|
20
|
+
output: object({
|
|
21
|
+
address: account(),
|
|
22
|
+
admin: account(),
|
|
23
|
+
guardian: account(),
|
|
24
|
+
fee_recipient: account(),
|
|
25
|
+
paused: object({ create: flag(), fill: flag() }),
|
|
26
|
+
kinds: list(object({
|
|
27
|
+
kind: choice(Object.values(KIND_NAMES)),
|
|
28
|
+
enabled: flag("intents of this kind can be created"),
|
|
29
|
+
fills_stopped: flag("fills of this kind are stopped"),
|
|
30
|
+
fee_bps: integer(0, 10_000),
|
|
31
|
+
}), 4),
|
|
32
|
+
partner_cut_bps: integer(0, 10_000, "share of every partner fee kept by the protocol"),
|
|
33
|
+
crank_bounty: amount("lamports escrowed in each new intent for whoever expires or closes it"),
|
|
34
|
+
create_fee: amount("lamports paid to the treasury for each new intent"),
|
|
35
|
+
domain_matches_cluster: flag("false means this RPC is a different cluster than the engine was configured for"),
|
|
36
|
+
}),
|
|
37
|
+
run: async ({ transport }) => {
|
|
38
|
+
const { address, config } = await loadConfig(transport);
|
|
39
|
+
return {
|
|
40
|
+
address,
|
|
41
|
+
admin: config.admin,
|
|
42
|
+
guardian: config.guardian,
|
|
43
|
+
fee_recipient: config.feeRecipient,
|
|
44
|
+
paused: { create: (config.paused & PAUSE_CREATE) !== 0, fill: (config.paused & PAUSE_FILL) !== 0 },
|
|
45
|
+
kinds: KINDS.map((kind) => ({
|
|
46
|
+
kind: KIND_NAMES[kind],
|
|
47
|
+
enabled: (config.enabledKinds & kindBit(kind)) !== 0n,
|
|
48
|
+
fills_stopped: (config.fillDisabledKinds & kindBit(kind)) !== 0n,
|
|
49
|
+
fee_bps: feeBpsFor(config, kind),
|
|
50
|
+
})),
|
|
51
|
+
partner_cut_bps: config.partnerCutBps,
|
|
52
|
+
crank_bounty: BigInt(config.crankBounty),
|
|
53
|
+
create_fee: BigInt(config.createFee),
|
|
54
|
+
domain_matches_cluster: sameBytes(config.domain, await clusterDomain(transport)),
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
export const getIntent = define({
|
|
59
|
+
name: tool("get_intent"),
|
|
60
|
+
title: "Read one intent",
|
|
61
|
+
description: "Read one intent by owner and nonce: its status, what is escrowed and still for sale, its terms in plain words, expiry, partner fee and crank bounty.",
|
|
62
|
+
effect: "read",
|
|
63
|
+
input: object(intentRef),
|
|
64
|
+
output: intentSchema,
|
|
65
|
+
run: async ({ transport }, input) => {
|
|
66
|
+
const { address, intent } = await loadIntent(transport, input.owner, input.nonce);
|
|
67
|
+
return intentView(address, intent, await decimalsFor(transport, new Map(), intent.inputMint, intent.outputMint));
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
export const listIntents = define({
|
|
71
|
+
name: tool("list_intents"),
|
|
72
|
+
title: "List intents",
|
|
73
|
+
description: `List intents, optionally only one owner's or only one status. Returns at most limit intents (default ${LIST_DEFAULT}, up to ${LIST_LIMIT}); more is true when others matched too.`,
|
|
74
|
+
effect: "read",
|
|
75
|
+
input: object({
|
|
76
|
+
owner: optional(account("only intents created by this wallet")),
|
|
77
|
+
status: optional(choice(STATUS, "only intents in this status")),
|
|
78
|
+
limit: optional(integer(1, LIST_LIMIT)),
|
|
79
|
+
}),
|
|
80
|
+
output: object({
|
|
81
|
+
intents: list(intentSchema, LIST_LIMIT),
|
|
82
|
+
more: flag(),
|
|
83
|
+
unreadable: integer(0, Number.MAX_SAFE_INTEGER, "intents skipped because their account could not be read"),
|
|
84
|
+
}),
|
|
85
|
+
run: async ({ transport }, input) => {
|
|
86
|
+
const limit = input.limit ?? LIST_DEFAULT;
|
|
87
|
+
const views = [];
|
|
88
|
+
let unreadable = 0;
|
|
89
|
+
const cache = new Map();
|
|
90
|
+
for (const { address, data } of await transport.intents(input.owner)) {
|
|
91
|
+
let intent;
|
|
92
|
+
try {
|
|
93
|
+
intent = getIntentDecoder().decode(data);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
unreadable += 1;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const decimals = await decimalsFor(transport, cache, intent.inputMint, intent.outputMint);
|
|
100
|
+
try {
|
|
101
|
+
views.push(intentView(address, intent, decimals));
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
unreadable += 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const matching = views.filter((view) => (input.owner === undefined || view.owner === input.owner) && (input.status === undefined || view.status === input.status));
|
|
108
|
+
return { intents: matching.slice(0, limit), more: matching.length > limit, unreadable };
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
export const BALANCE_MINTS = 8;
|
|
112
|
+
export const SOL_DECIMALS = 9;
|
|
113
|
+
async function decimalsOf(transport, cache, mint) {
|
|
114
|
+
if (!cache.has(mint)) {
|
|
115
|
+
cache.set(mint, await mintOf(transport, mint).then((t) => t.decimals, () => null));
|
|
116
|
+
}
|
|
117
|
+
return cache.get(mint) ?? null;
|
|
118
|
+
}
|
|
119
|
+
export async function decimalsFor(transport, cache, inputMint, outputMint) {
|
|
120
|
+
const input = await decimalsOf(transport, cache, inputMint);
|
|
121
|
+
const output = await decimalsOf(transport, cache, outputMint);
|
|
122
|
+
return { ...(input === null ? {} : { inputDecimals: input }), ...(output === null ? {} : { outputDecimals: output }) };
|
|
123
|
+
}
|
|
124
|
+
export const getBalances = define({
|
|
125
|
+
name: tool("get_balances"),
|
|
126
|
+
title: "Token balances",
|
|
127
|
+
description: "Read a wallet's SOL and its holdings of the given tokens: each token's decimals (every amount in these tools is in raw units, so one whole token is 10^decimals raw units), the wallet's canonical token account and balance, the spending allowance it gives the engine, and how much is still escrowed in its open intents. Use it to turn amounts a person names into raw units and to check that tokens came back.",
|
|
128
|
+
effect: "read",
|
|
129
|
+
input: object({
|
|
130
|
+
owner: account("the wallet to read"),
|
|
131
|
+
mints: list(account(), BALANCE_MINTS, "the tokens to read", 1),
|
|
132
|
+
}),
|
|
133
|
+
output: object({
|
|
134
|
+
owner: account(),
|
|
135
|
+
lamports: amount("SOL the wallet holds, in lamports (one SOL is 1000000000); it pays network fees and rent"),
|
|
136
|
+
sol: text("the same in whole SOL"),
|
|
137
|
+
tokens: list(object({
|
|
138
|
+
mint: account(),
|
|
139
|
+
decimals: integer(0, 255),
|
|
140
|
+
account: account("the wallet's canonical token account for this mint"),
|
|
141
|
+
exists: flag("false when the wallet has no such token account yet"),
|
|
142
|
+
balance: amount("raw units held"),
|
|
143
|
+
balance_tokens: text("the balance in whole tokens"),
|
|
144
|
+
engine_allowance: amount("raw units the engine may still draw for signed and agent intents"),
|
|
145
|
+
escrowed: amount("raw units still locked in this wallet's open intents selling this token"),
|
|
146
|
+
}), BALANCE_MINTS),
|
|
147
|
+
}),
|
|
148
|
+
run: async ({ transport }, input) => {
|
|
149
|
+
const [engine] = await findDelegatePda({ owner: input.owner });
|
|
150
|
+
const open = (await transport.intents(input.owner))
|
|
151
|
+
.map(({ data }) => getIntentDecoder().decode(data))
|
|
152
|
+
.filter((intent) => intent.owner === input.owner && intent.status === IntentStatus.Open);
|
|
153
|
+
const tokens = [];
|
|
154
|
+
for (const mint of input.mints) {
|
|
155
|
+
const token = await mintOf(transport, mint);
|
|
156
|
+
const address = await findAssociatedTokenAddress({ owner: input.owner, mint, tokenProgram: token.tokenProgram });
|
|
157
|
+
const view = await createdAccount(transport, address);
|
|
158
|
+
const state = view === null ? null : getTokenDecoder().decode(view.data);
|
|
159
|
+
const delegate = state !== null && state.delegate.__option === "Some" ? state.delegate.value : null;
|
|
160
|
+
const balance = state?.amount ?? 0n;
|
|
161
|
+
tokens.push({
|
|
162
|
+
mint,
|
|
163
|
+
decimals: token.decimals,
|
|
164
|
+
account: address,
|
|
165
|
+
exists: state !== null,
|
|
166
|
+
balance,
|
|
167
|
+
balance_tokens: formatAmount(balance, token.decimals),
|
|
168
|
+
engine_allowance: delegate === engine ? (state?.delegatedAmount ?? 0n) : 0n,
|
|
169
|
+
escrowed: open.filter((intent) => intent.inputMint === mint).reduce((sum, intent) => sum + remainingOf(intent), 0n),
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
const lamports = (await transport.getAccount(input.owner))?.lamports ?? 0n;
|
|
173
|
+
return { owner: input.owner, lamports, sol: formatAmount(lamports, SOL_DECIMALS), tokens };
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
export const quote = define({
|
|
177
|
+
name: tool("quote"),
|
|
178
|
+
title: "Quote an intent",
|
|
179
|
+
description: "Work out what filling an intent requires: the least output the owner must receive at a given time (default: now on chain) and how the remaining input splits into protocol fee, partner fee and the net a solver gets to sell. Attested intents have no output minimum and cannot be quoted.",
|
|
180
|
+
effect: "read",
|
|
181
|
+
input: object({ ...intentRef, at: optional(time("unix seconds to price at; defaults to the chain's current time")) }),
|
|
182
|
+
output: object({
|
|
183
|
+
address: account(),
|
|
184
|
+
at: time(),
|
|
185
|
+
amount_in: amount("raw input units a fill sells"),
|
|
186
|
+
required_out: amount("least raw output units the receiver must get"),
|
|
187
|
+
fee_bps: integer(0, 10_000),
|
|
188
|
+
partner_bps: integer(0, 10_000),
|
|
189
|
+
protocol_fee: amount(),
|
|
190
|
+
partner_fee: amount(),
|
|
191
|
+
net_in: amount("raw input units the solver receives to sell"),
|
|
192
|
+
}),
|
|
193
|
+
run: async ({ transport }, input) => {
|
|
194
|
+
const { address, intent } = await loadIntent(transport, input.owner, input.nonce);
|
|
195
|
+
const { config } = await loadConfig(transport);
|
|
196
|
+
const q = quoteOf(intent, config, input.at ?? (await chainTime(transport)));
|
|
197
|
+
return {
|
|
198
|
+
address,
|
|
199
|
+
at: q.at,
|
|
200
|
+
amount_in: q.amountIn,
|
|
201
|
+
required_out: q.requiredOut,
|
|
202
|
+
fee_bps: q.feeBps,
|
|
203
|
+
partner_bps: q.partnerBps,
|
|
204
|
+
protocol_fee: q.protocolFee,
|
|
205
|
+
partner_fee: q.partnerFee,
|
|
206
|
+
net_in: q.net,
|
|
207
|
+
};
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/agent/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EACL,SAAS,EACT,0BAA0B,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AU;YACzB,MAAM,EAAE,CAAC,CAAC,GAAG;SACd,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { prepareCreate } from "./create.js";
|
|
2
|
+
import { agentCreate, getMandate, prepareAgentCreate, prepareMandate, prepareRevokeMandate } from "./mandate.js";
|
|
3
|
+
import { getBalances, getConfig, getIntent, listIntents, quote } from "./read.js";
|
|
4
|
+
import { findCrankWork, prepareCancel, prepareCrank } from "./settle.js";
|
|
5
|
+
import { prepareSignedIntent, submitSignedIntent } from "./signed.js";
|
|
6
|
+
export const ACTIONS = [
|
|
7
|
+
getConfig,
|
|
8
|
+
getIntent,
|
|
9
|
+
listIntents,
|
|
10
|
+
getBalances,
|
|
11
|
+
quote,
|
|
12
|
+
prepareCreate,
|
|
13
|
+
prepareCancel,
|
|
14
|
+
findCrankWork,
|
|
15
|
+
prepareCrank,
|
|
16
|
+
prepareSignedIntent,
|
|
17
|
+
submitSignedIntent,
|
|
18
|
+
prepareMandate,
|
|
19
|
+
getMandate,
|
|
20
|
+
prepareRevokeMandate,
|
|
21
|
+
prepareAgentCreate,
|
|
22
|
+
agentCreate,
|
|
23
|
+
];
|
|
24
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/agent/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACjH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtE,MAAM,CAAC,MAAM,OAAO,GAAyB;IAC3C,SAAS;IACT,SAAS;IACT,WAAW;IACX,WAAW;IACX,KAAK;IACL,aAAa;IACb,aAAa;IACb,aAAa;IACb,YAAY;IACZ,mBAAmB;IACnB,kBAAkB;IAClB,cAAc;IACd,UAAU;IACV,oBAAoB;IACpB,kBAAkB;IAClB,WAAW;CACZ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Address, TransactionSigner } from "@solana/kit";
|
|
2
|
+
import { type Budget } from "./budget.js";
|
|
3
|
+
export declare const RATE_WINDOW = 3600n;
|
|
4
|
+
export type RelayPolicy = {
|
|
5
|
+
maxLamports: bigint;
|
|
6
|
+
maxTtl: bigint;
|
|
7
|
+
perHour: number;
|
|
8
|
+
hourlyLamports: bigint;
|
|
9
|
+
fees: ReadonlyMap<Address, bigint>;
|
|
10
|
+
};
|
|
11
|
+
export type Relay = RelayPolicy & {
|
|
12
|
+
signer: TransactionSigner;
|
|
13
|
+
recent: Map<Address, bigint[]>;
|
|
14
|
+
budget: Budget;
|
|
15
|
+
};
|
|
16
|
+
export type Ticket = {
|
|
17
|
+
cancel(): void;
|
|
18
|
+
};
|
|
19
|
+
export declare function relayOf(signer: TransactionSigner, policy: RelayPolicy): Relay;
|
|
20
|
+
export declare function admitRelay(relay: Relay, owner: Address, charges: bigint, total: bigint, expiresAt: bigint, now: bigint): Ticket;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { budgetOf, release, reserve } from "./budget.js";
|
|
2
|
+
import { AgentRefusal } from "./problems.js";
|
|
3
|
+
export const RATE_WINDOW = 3600n;
|
|
4
|
+
export function relayOf(signer, policy) {
|
|
5
|
+
return { ...policy, signer, recent: new Map(), budget: budgetOf(policy.hourlyLamports) };
|
|
6
|
+
}
|
|
7
|
+
function prune(relay, now) {
|
|
8
|
+
for (const [owner, times] of relay.recent) {
|
|
9
|
+
const live = times.filter((t) => t > now - RATE_WINDOW);
|
|
10
|
+
if (live.length === 0) {
|
|
11
|
+
relay.recent.delete(owner);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
relay.recent.set(owner, live);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function admitRelay(relay, owner, charges, total, expiresAt, now) {
|
|
19
|
+
if (charges > relay.maxLamports) {
|
|
20
|
+
throw new AgentRefusal("RelayTooCostly", `relaying this intent costs ${charges} lamports in create fee, crank bounty and priority fee; this relayer pays at most ${relay.maxLamports}`);
|
|
21
|
+
}
|
|
22
|
+
if (expiresAt - now > relay.maxTtl) {
|
|
23
|
+
throw new AgentRefusal("RelayTooLong", `this relayer only relays intents that expire within ${relay.maxTtl} seconds; sign one with an earlier expiry`);
|
|
24
|
+
}
|
|
25
|
+
prune(relay, now);
|
|
26
|
+
const times = relay.recent.get(owner) ?? [];
|
|
27
|
+
if (times.length >= relay.perHour) {
|
|
28
|
+
throw new AgentRefusal("RelayRateLimited", `this relayer relays at most ${relay.perHour} intents per owner per hour`, true);
|
|
29
|
+
}
|
|
30
|
+
const spend = reserve(relay.budget, total, now);
|
|
31
|
+
relay.recent.set(owner, [...times, now]);
|
|
32
|
+
return {
|
|
33
|
+
cancel: () => {
|
|
34
|
+
release(relay.budget, spend);
|
|
35
|
+
const current = relay.recent.get(owner) ?? [];
|
|
36
|
+
const at = current.lastIndexOf(now);
|
|
37
|
+
if (at >= 0) {
|
|
38
|
+
current.splice(at, 1);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=relay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay.js","sourceRoot":"","sources":["../../../src/agent/relay.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,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CAAC,CAAC;IAClB,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC5C,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClC,MAAM,IAAI,YAAY,CAAC,kBAAkB,EAAE,+BAA+B,KAAK,CAAC,OAAO,6BAA6B,EAAE,IAAI,CAAC,CAAC;IAC9H,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAChD,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IACzC,OAAO;QACL,MAAM,EAAE,GAAG,EAAE;YACX,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAC9C,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACpC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;gBACZ,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type Address } from "@solana/kit";
|
|
2
|
+
export type Issue = {
|
|
3
|
+
path: string;
|
|
4
|
+
message: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class InvalidInput extends Error {
|
|
7
|
+
readonly issues: Issue[];
|
|
8
|
+
constructor(issues: Issue[]);
|
|
9
|
+
}
|
|
10
|
+
export type Json = Record<string, unknown>;
|
|
11
|
+
export type Schema<T> = {
|
|
12
|
+
json: Json;
|
|
13
|
+
read(value: unknown, path: string): T;
|
|
14
|
+
};
|
|
15
|
+
export type Infer<S> = S extends Schema<infer T> ? T : never;
|
|
16
|
+
export declare function text(description?: string): Schema<string>;
|
|
17
|
+
export declare function flag(description?: string): Schema<boolean>;
|
|
18
|
+
export declare const ADDRESS_PATTERN = "^[1-9A-HJ-NP-Za-km-z]{32,44}$";
|
|
19
|
+
export declare function account(description?: string): Schema<Address>;
|
|
20
|
+
export declare const AMOUNT_PATTERN = "^(0|[1-9][0-9]{0,19})$";
|
|
21
|
+
export declare function amount(description?: string): Schema<bigint>;
|
|
22
|
+
export declare const TIME_PATTERN = "^-?(0|[1-9][0-9]{0,18})$";
|
|
23
|
+
export declare function time(description?: string): Schema<bigint>;
|
|
24
|
+
export declare function integer(min: number, max: number, description?: string): Schema<number>;
|
|
25
|
+
export declare function choice<const T extends string>(values: readonly T[], description?: string): Schema<T>;
|
|
26
|
+
export declare function list<T>(item: Schema<T>, maxItems: number, description?: string, minItems?: number): Schema<T[]>;
|
|
27
|
+
export declare function nullable<T>(inner: Schema<T>): Schema<T | null>;
|
|
28
|
+
export type Optional<T> = {
|
|
29
|
+
optional: Schema<T>;
|
|
30
|
+
};
|
|
31
|
+
export declare function optional<T>(inner: Schema<T>): Optional<T>;
|
|
32
|
+
type Field = Schema<unknown> | Optional<unknown>;
|
|
33
|
+
type Shape = Record<string, Field>;
|
|
34
|
+
type Parsed<S extends Shape> = {
|
|
35
|
+
[K in keyof S as S[K] extends Optional<unknown> ? never : K]: S[K] extends Schema<infer T> ? T : never;
|
|
36
|
+
} & {
|
|
37
|
+
[K in keyof S as S[K] extends Optional<unknown> ? K : never]?: S[K] extends Optional<infer T> ? T : never;
|
|
38
|
+
};
|
|
39
|
+
export declare function object<S extends Shape>(shape: S, description?: string): Schema<Parsed<S>>;
|
|
40
|
+
export declare function variants<const K extends string, V extends Record<string, Schema<object>>>(tag: K, options: V, description?: string): Schema<{
|
|
41
|
+
[N in keyof V]: {
|
|
42
|
+
[T in K]: N;
|
|
43
|
+
} & Infer<V[N]>;
|
|
44
|
+
}[keyof V]>;
|
|
45
|
+
export type StandardIssue = {
|
|
46
|
+
message: string;
|
|
47
|
+
path?: PropertyKey[];
|
|
48
|
+
};
|
|
49
|
+
export type Standard<T> = {
|
|
50
|
+
"~standard": {
|
|
51
|
+
version: 1;
|
|
52
|
+
vendor: string;
|
|
53
|
+
validate(value: unknown): {
|
|
54
|
+
value: T;
|
|
55
|
+
issues?: undefined;
|
|
56
|
+
} | {
|
|
57
|
+
issues: StandardIssue[];
|
|
58
|
+
};
|
|
59
|
+
jsonSchema: {
|
|
60
|
+
input(options: unknown): Json;
|
|
61
|
+
output(options: unknown): Json;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export declare const VENDOR = "intent-engine";
|
|
66
|
+
export declare function passThrough(json: Json): Standard<unknown>;
|
|
67
|
+
export declare function checked<T>(schema: Schema<T>): Standard<T>;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { isAddress } from "@solana/kit";
|
|
2
|
+
import { I64_MAX, I64_MIN, U64_MAX } from "@intent-engine/core";
|
|
3
|
+
export class InvalidInput extends Error {
|
|
4
|
+
issues;
|
|
5
|
+
constructor(issues) {
|
|
6
|
+
super(issues.map((i) => (i.path === "" ? i.message : `${i.path}: ${i.message}`)).join("; "));
|
|
7
|
+
this.name = "InvalidInput";
|
|
8
|
+
this.issues = issues;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const fail = (path, message) => {
|
|
12
|
+
throw new InvalidInput([{ path, message }]);
|
|
13
|
+
};
|
|
14
|
+
const at = (path, key) => (path === "" ? String(key) : `${path}.${key}`);
|
|
15
|
+
const described = (json, description) => description === undefined ? json : { ...json, description };
|
|
16
|
+
export function text(description) {
|
|
17
|
+
return {
|
|
18
|
+
json: described({ type: "string" }, description),
|
|
19
|
+
read: (value, path) => (typeof value === "string" ? value : fail(path, "must be a string")),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function flag(description) {
|
|
23
|
+
return {
|
|
24
|
+
json: described({ type: "boolean" }, description),
|
|
25
|
+
read: (value, path) => (typeof value === "boolean" ? value : fail(path, "must be true or false")),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export const ADDRESS_PATTERN = "^[1-9A-HJ-NP-Za-km-z]{32,44}$";
|
|
29
|
+
export function account(description) {
|
|
30
|
+
return {
|
|
31
|
+
json: described({ type: "string", pattern: ADDRESS_PATTERN }, description),
|
|
32
|
+
read: (value, path) => typeof value === "string" && isAddress(value) ? value : fail(path, "must be a base58 Solana address"),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export const AMOUNT_PATTERN = "^(0|[1-9][0-9]{0,19})$";
|
|
36
|
+
export function amount(description) {
|
|
37
|
+
return {
|
|
38
|
+
json: described({ type: "string", pattern: AMOUNT_PATTERN }, description),
|
|
39
|
+
read: (value, path) => {
|
|
40
|
+
if (typeof value !== "string" || !new RegExp(AMOUNT_PATTERN).test(value)) {
|
|
41
|
+
return fail(path, "must be a whole number of raw token units written as a decimal string");
|
|
42
|
+
}
|
|
43
|
+
const parsed = BigInt(value);
|
|
44
|
+
return parsed <= U64_MAX ? parsed : fail(path, `must be at most ${U64_MAX}`);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export const TIME_PATTERN = "^-?(0|[1-9][0-9]{0,18})$";
|
|
49
|
+
export function time(description) {
|
|
50
|
+
return {
|
|
51
|
+
json: described({ type: "string", pattern: TIME_PATTERN }, description),
|
|
52
|
+
read: (value, path) => {
|
|
53
|
+
if (typeof value !== "string" || !new RegExp(TIME_PATTERN).test(value)) {
|
|
54
|
+
return fail(path, "must be whole unix seconds written as a decimal string");
|
|
55
|
+
}
|
|
56
|
+
const parsed = BigInt(value);
|
|
57
|
+
return parsed >= I64_MIN && parsed <= I64_MAX ? parsed : fail(path, `must be from ${I64_MIN} to ${I64_MAX}`);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export function integer(min, max, description) {
|
|
62
|
+
return {
|
|
63
|
+
json: described({ type: "integer", minimum: min, maximum: max }, description),
|
|
64
|
+
read: (value, path) => typeof value === "number" && Number.isSafeInteger(value) && value >= min && value <= max
|
|
65
|
+
? value
|
|
66
|
+
: fail(path, `must be an integer from ${min} to ${max}`),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export function choice(values, description) {
|
|
70
|
+
return {
|
|
71
|
+
json: described({ type: "string", enum: [...values] }, description),
|
|
72
|
+
read: (value, path) => typeof value === "string" && values.includes(value)
|
|
73
|
+
? value
|
|
74
|
+
: fail(path, `must be one of ${values.join(", ")}`),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function list(item, maxItems, description, minItems = 0) {
|
|
78
|
+
return {
|
|
79
|
+
json: described({ type: "array", items: item.json, minItems, maxItems }, description),
|
|
80
|
+
read: (value, path) => {
|
|
81
|
+
if (!Array.isArray(value)) {
|
|
82
|
+
return fail(path, "must be a list");
|
|
83
|
+
}
|
|
84
|
+
if (value.length > maxItems || value.length < minItems) {
|
|
85
|
+
return fail(path, `must hold ${minItems} to ${maxItems} items`);
|
|
86
|
+
}
|
|
87
|
+
return value.map((v, i) => item.read(v, at(path, i)));
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function nullable(inner) {
|
|
92
|
+
return {
|
|
93
|
+
json: { anyOf: [inner.json, { type: "null" }] },
|
|
94
|
+
read: (value, path) => (value === null ? null : inner.read(value, path)),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function optional(inner) {
|
|
98
|
+
return { optional: inner };
|
|
99
|
+
}
|
|
100
|
+
const isOptional = (field) => "optional" in field;
|
|
101
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
102
|
+
export function object(shape, description) {
|
|
103
|
+
const keys = Object.keys(shape);
|
|
104
|
+
const required = keys.filter((k) => !isOptional(shape[k]));
|
|
105
|
+
return {
|
|
106
|
+
json: described({
|
|
107
|
+
type: "object",
|
|
108
|
+
properties: Object.fromEntries(keys.map((k) => {
|
|
109
|
+
const field = shape[k];
|
|
110
|
+
return [k, isOptional(field) ? field.optional.json : field.json];
|
|
111
|
+
})),
|
|
112
|
+
required,
|
|
113
|
+
additionalProperties: false,
|
|
114
|
+
}, description),
|
|
115
|
+
read: (value, path) => {
|
|
116
|
+
if (!isRecord(value)) {
|
|
117
|
+
return fail(path, "must be an object");
|
|
118
|
+
}
|
|
119
|
+
const issues = Object.keys(value)
|
|
120
|
+
.filter((k) => !keys.includes(k))
|
|
121
|
+
.map((k) => ({ path: at(path, k), message: "is not a known field" }));
|
|
122
|
+
const out = {};
|
|
123
|
+
for (const k of keys) {
|
|
124
|
+
const field = shape[k];
|
|
125
|
+
const present = value[k] !== undefined;
|
|
126
|
+
try {
|
|
127
|
+
if (present) {
|
|
128
|
+
out[k] = (isOptional(field) ? field.optional : field).read(value[k], at(path, k));
|
|
129
|
+
}
|
|
130
|
+
else if (!isOptional(field)) {
|
|
131
|
+
issues.push({ path: at(path, k), message: "is required" });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
if (!(error instanceof InvalidInput)) {
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
issues.push(...error.issues);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (issues.length > 0) {
|
|
142
|
+
throw new InvalidInput(issues);
|
|
143
|
+
}
|
|
144
|
+
return out;
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
export function variants(tag, options, description) {
|
|
149
|
+
const names = Object.keys(options);
|
|
150
|
+
return {
|
|
151
|
+
json: described({
|
|
152
|
+
oneOf: names.map((name) => {
|
|
153
|
+
const json = options[name].json;
|
|
154
|
+
const properties = json["properties"];
|
|
155
|
+
const required = json["required"];
|
|
156
|
+
return {
|
|
157
|
+
...json,
|
|
158
|
+
properties: { [tag]: { const: name }, ...properties },
|
|
159
|
+
required: [tag, ...required],
|
|
160
|
+
};
|
|
161
|
+
}),
|
|
162
|
+
}, description),
|
|
163
|
+
read: (value, path) => {
|
|
164
|
+
if (!isRecord(value)) {
|
|
165
|
+
return fail(path, "must be an object");
|
|
166
|
+
}
|
|
167
|
+
const name = value[tag];
|
|
168
|
+
const option = typeof name === "string" && names.includes(name) ? options[name] : undefined;
|
|
169
|
+
if (option === undefined) {
|
|
170
|
+
return fail(at(path, tag), `must be one of ${names.join(", ")}`);
|
|
171
|
+
}
|
|
172
|
+
const { [tag]: _, ...rest } = value;
|
|
173
|
+
return { [tag]: name, ...option.read(rest, path) };
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
export const VENDOR = "intent-engine";
|
|
178
|
+
export function passThrough(json) {
|
|
179
|
+
return {
|
|
180
|
+
"~standard": {
|
|
181
|
+
version: 1,
|
|
182
|
+
vendor: VENDOR,
|
|
183
|
+
validate: (value) => ({ value }),
|
|
184
|
+
jsonSchema: { input: () => json, output: () => json },
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
export function checked(schema) {
|
|
189
|
+
return {
|
|
190
|
+
"~standard": {
|
|
191
|
+
version: 1,
|
|
192
|
+
vendor: VENDOR,
|
|
193
|
+
validate: (value) => {
|
|
194
|
+
try {
|
|
195
|
+
return { value: schema.read(value, "") };
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
if (!(error instanceof InvalidInput)) {
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
issues: error.issues.map((i) => ({ message: i.message, ...(i.path === "" ? {} : { path: i.path.split(".") }) })),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
jsonSchema: { input: () => schema.json, output: () => schema.json },
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
//# source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,CAAC;YACD,UAAU,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE;SACpE;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const WORK_LIMIT = 100;
|
|
2
|
+
export declare 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";
|
|
3
|
+
export declare const prepareCancel: import("./actions.js").AnyAction;
|
|
4
|
+
export declare const findCrankWork: import("./actions.js").AnyAction;
|
|
5
|
+
export declare const prepareCrank: import("./actions.js").AnyAction;
|