@botanary/agent 0.1.0-alpha.1 → 0.1.0-alpha.12

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 (59) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +43 -5
  3. package/dist/errors.d.ts +1 -38
  4. package/dist/exact-action.d.ts +61 -8
  5. package/dist/fingerprint.d.ts +0 -15
  6. package/dist/generated/routes.d.ts +0 -1
  7. package/dist/generated/schema.d.ts +8 -1092
  8. package/dist/http-path.d.ts +0 -81
  9. package/dist/index.d.ts +1 -2
  10. package/dist/index.js +2 -7
  11. package/dist/pairing-code.d.ts +0 -23
  12. package/dist/registration.d.ts +0 -3
  13. package/dist/runtime.d.ts +3 -128
  14. package/dist/signer.d.ts +0 -7
  15. package/dist/transport.d.ts +0 -3
  16. package/dist/validation.d.ts +4 -3
  17. package/dist/views.d.ts +0 -54
  18. package/package.json +6 -2
  19. package/dist/errors.d.ts.map +0 -1
  20. package/dist/errors.js +0 -40
  21. package/dist/errors.js.map +0 -1
  22. package/dist/exact-action.d.ts.map +0 -1
  23. package/dist/exact-action.js +0 -178
  24. package/dist/exact-action.js.map +0 -1
  25. package/dist/fingerprint.d.ts.map +0 -1
  26. package/dist/fingerprint.js +0 -47
  27. package/dist/fingerprint.js.map +0 -1
  28. package/dist/generated/routes.d.ts.map +0 -1
  29. package/dist/generated/routes.js +0 -92
  30. package/dist/generated/routes.js.map +0 -1
  31. package/dist/generated/schema.d.ts.map +0 -1
  32. package/dist/generated/schema.js +0 -2
  33. package/dist/generated/schema.js.map +0 -1
  34. package/dist/http-path.d.ts.map +0 -1
  35. package/dist/http-path.js +0 -201
  36. package/dist/http-path.js.map +0 -1
  37. package/dist/index.d.ts.map +0 -1
  38. package/dist/index.js.map +0 -1
  39. package/dist/pairing-code.d.ts.map +0 -1
  40. package/dist/pairing-code.js +0 -60
  41. package/dist/pairing-code.js.map +0 -1
  42. package/dist/registration.d.ts.map +0 -1
  43. package/dist/registration.js +0 -62
  44. package/dist/registration.js.map +0 -1
  45. package/dist/runtime.d.ts.map +0 -1
  46. package/dist/runtime.js +0 -559
  47. package/dist/runtime.js.map +0 -1
  48. package/dist/signer.d.ts.map +0 -1
  49. package/dist/signer.js +0 -13
  50. package/dist/signer.js.map +0 -1
  51. package/dist/transport.d.ts.map +0 -1
  52. package/dist/transport.js +0 -135
  53. package/dist/transport.js.map +0 -1
  54. package/dist/validation.d.ts.map +0 -1
  55. package/dist/validation.js +0 -108
  56. package/dist/validation.js.map +0 -1
  57. package/dist/views.d.ts.map +0 -1
  58. package/dist/views.js +0 -2
  59. package/dist/views.js.map +0 -1
package/dist/views.d.ts CHANGED
@@ -4,18 +4,12 @@ type HexFields<T> = {
4
4
  [K in keyof T]: K extends 'sender' | 'entryPoint' | 'callData' | 'signature' | 'factory' | 'factoryData' | 'paymaster' | 'paymasterData' ? Hex | Extract<T[K], null | undefined> : T[K];
5
5
  };
6
6
  export type UnsignedUserOp = HexFields<components['schemas']['UnsignedUserOp']>;
7
- /** An UNSIGNED userOp build response shape (`POST /delegations/{delegationId}/actions`, the ONLY build
8
- * lane whose op a session-key signature can actually validate - see `buildDelegatedAction`'s own doc
9
- * comment) - the UserOp wire fields are generated from the reviewed API contract. Compatibility views below
10
- * retain the historical MCP fields while the transport contract supplies the complete wire types. */
11
7
  export interface UserOpBuildResult {
12
8
  intentType: string;
13
9
  userOp: UnsignedUserOp;
14
10
  userOpHash: Hex;
15
11
  [key: string]: unknown;
16
12
  }
17
- /** One entry of `AgentSelf.grant.policySet.spentToDate` (backend's `SpendMeter`) - what tells a caller
18
- * how much of a budgeted token is left before it tries to spend more than a grant allows. */
19
13
  export interface SpendMeterView {
20
14
  token: {
21
15
  symbol: string;
@@ -28,27 +22,15 @@ export interface SpendMeterView {
28
22
  remaining: number;
29
23
  expiresAt?: string | null;
30
24
  }
31
- /** The SWAP venue a grant pins, when it was granted swap authority at all (backend's
32
- * `PolicySet.swapVenue`). ABSENT - not null - on a transfer-only grant, which is exactly what makes it
33
- * answerable: the compiled Smart Sessions session is not readable back from a `permissionId`, so this
34
- * recorded fact is the only way either side can know whether the session carries an allowance action.
35
- * `maxAllowance` is DISPLAY units (the backend scales it by the token's own resolution), so it compares
36
- * directly against `propose_swap`'s `amountIn`. */
37
25
  export interface GrantSwapVenueView {
38
- /** The one router this grant may approve AND call - the allowance entrypoint has one `(token, target)`. */
39
26
  router: string;
40
- /** The one token this grant may sell. */
41
27
  token: {
42
28
  symbol: string;
43
29
  chainId?: number | null;
44
30
  address?: string | null;
45
31
  };
46
- /** Ceiling on a SINGLE swap's allowance, in display units. Not a budget: the grant's own budget meters
47
- * separately, and both apply. */
48
32
  maxAllowance: number;
49
33
  }
50
- /** The live grant `GET /agents/me` reports, when one exists - mirrors the backend's `Delegation` (only
51
- * the fields this package reads). */
52
34
  export interface AgentGrantView {
53
35
  id: string;
54
36
  permissionId: Hex;
@@ -57,11 +39,6 @@ export interface AgentGrantView {
57
39
  chain: string;
58
40
  chainId: number;
59
41
  policySet: {
60
- /** `token.assetRef` is stamped on at READ time by the backend's `withGrantAssetRefs`
61
- * (`grant-asset-refs.ts`) - CAIP-19, e.g. `eip155:8453/erc20:0x...` - and is what
62
- * `findBudgetMeter`/`checkSendBounds` match a resolved send against, never the symbol. `null`
63
- * means this build could not resolve an on-chain address for the token (honestly undecodable,
64
- * never guessed); absent (older backend) means "not reported". */
65
42
  budgets: Array<{
66
43
  token: {
67
44
  symbol: string;
@@ -83,16 +60,12 @@ export interface AgentGrantView {
83
60
  name?: string | null;
84
61
  }>;
85
62
  expiresAt?: string | null;
86
- /** Absent unless this grant was given swap authority - see `GrantSwapVenueView`. */
87
63
  swapVenue?: GrantSwapVenueView | null;
88
64
  [key: string]: unknown;
89
65
  };
90
66
  spentToDate: SpendMeterView[];
91
67
  [key: string]: unknown;
92
68
  }
93
- /** `GET /agents/me`'s response - who this agent is, what account it is bound to, and its live grant if
94
- * any. `grant: null` is an honest, explicit answer (see agents.controller.ts's own doc comment), never
95
- * an error and never fabricated by this package. */
96
69
  export interface AgentSelf {
97
70
  id: string;
98
71
  name: string;
@@ -100,32 +73,20 @@ export interface AgentSelf {
100
73
  fingerprint: string;
101
74
  connectedAt: string;
102
75
  accountId: string;
103
- /** The bound account's own on-chain address - the one identifier the owner actually recognises, since
104
- * `accountId` is an opaque row id that appears nowhere in the Botanary app. Without it, an agent
105
- * paired to a DIFFERENT login than the one the owner has open reports itself connected and gives
106
- * them nothing to notice the mismatch with. Optional here because an older backend does not send it;
107
- * this package never fabricates one. */
108
76
  accountAddress?: Hex | null;
109
77
  grant: AgentGrantView | null;
110
- /** Whether the grant's own chain has every setup module the account needs. Optional because an older
111
- * backend does not send it - absent means "not reported", which this package treats as "no evidence
112
- * of a problem" rather than inventing either answer. */
113
78
  accountSetup?: {
114
79
  ready: boolean;
115
80
  missing: string[];
116
81
  chainId: number;
117
82
  } | null;
118
83
  }
119
- /** A submitted call, exactly the shape `POST /agents/requests`'s `calls` field and a money/swap build's
120
- * own callData/value/to already share. */
121
84
  export interface UnsignedCallView {
122
85
  to: string;
123
86
  data: string;
124
87
  value: string;
125
88
  chainId: number;
126
89
  }
127
- /** `POST /agents/requests`'s response - the raised request, including which bound was crossed and the
128
- * deadline, exactly as the backend reports them (never fabricated here). */
129
90
  export interface AgentRequestView {
130
91
  id: string;
131
92
  agentId: string;
@@ -138,12 +99,6 @@ export interface AgentRequestView {
138
99
  status: string;
139
100
  [key: string]: unknown;
140
101
  }
141
- /** The exact EIP-3009 tuple this lane's `X402PaymentValidator` verifies, field order load-bearing - it
142
- * must match `IX402PaymentValidator.Authorization` in botanary-contracts exactly (reorder a field and
143
- * every signature stops verifying; see that interface's own doc comment). Decimal-string value fields,
144
- * mirroring the backend's own `X402Authorization` wire shape (`src/modules/x402/x402-authorization.ts`)
145
- * rather than a bigint: JSON has no integer wide enough for a uint256, and this package never imports
146
- * across the BE boundary to reuse that type directly (deploy-isolated - see the workspace AGENTS.md). */
147
102
  export interface X402AuthorizationView {
148
103
  from: Hex;
149
104
  to: Hex;
@@ -153,10 +108,6 @@ export interface X402AuthorizationView {
153
108
  nonce: Hex;
154
109
  [key: string]: unknown;
155
110
  }
156
- /** `POST /apis/calls/requirements`'s `ready` branch (Task 13) - everything `callApi` needs to build the
157
- * Kernel ERC-1271 envelope. `validator` is the `X402PaymentValidator` address on THIS call's chain,
158
- * read from here and never hardcoded: deployment addresses are nonce-shifted between chains, so the
159
- * same address means something different on another chain. */
160
111
  export interface ApiCallRequirementsReady {
161
112
  requirementId: string;
162
113
  status: 'ready';
@@ -166,10 +117,6 @@ export interface ApiCallRequirementsReady {
166
117
  validator: Hex;
167
118
  [key: string]: unknown;
168
119
  }
169
- /** `POST /apis/calls/requirements`'s `pending_approval` branch (Task 11's confirmation threshold) -
170
- * carries NONE of `payload`/`authorization`/`index`/`validator`, structurally, not merely empty: the
171
- * digest is deliberately withheld until the owner answers. `callApi` must never try to sign off this
172
- * shape - see its own handling below. */
173
120
  export interface ApiCallRequirementsPending {
174
121
  requirementId: string;
175
122
  status: 'pending_approval';
@@ -179,4 +126,3 @@ export interface ApiCallRequirementsPending {
179
126
  }
180
127
  export type ApiCallRequirementsResponse = ApiCallRequirementsReady | ApiCallRequirementsPending;
181
128
  export {};
182
- //# sourceMappingURL=views.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botanary/agent",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.12",
4
4
  "description": "Botanary agent session and execution runtime with an injected signer",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,8 +27,11 @@
27
27
  "scripts": {
28
28
  "generate": "node scripts/generate.mjs",
29
29
  "check:generated": "node scripts/generate.mjs --check",
30
+ "check:inventory": "node ../protected-boundary/check-inventory.mjs agent",
30
31
  "typecheck": "tsc --noEmit",
31
- "build": "tsc",
32
+ "build": "node ../protected-boundary/release-build.mjs agent",
33
+ "build:tsc": "tsc",
34
+ "audit:artifact": "node ../protected-boundary/audit-artifact.mjs agent",
32
35
  "test": "vitest run",
33
36
  "prepack": "pnpm check:generated && pnpm typecheck && pnpm build",
34
37
  "test:packed": "node scripts/verify-packed.mjs"
@@ -39,6 +42,7 @@
39
42
  },
40
43
  "devDependencies": {
41
44
  "@types/node": "22.19.15",
45
+ "esbuild": "0.25.12",
42
46
  "openapi-typescript": "7.13.0",
43
47
  "typescript": "5.9.3",
44
48
  "vitest": "2.1.9",
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;+DAG+D;AAC/D,qBAAa,gBAAiB,SAAQ,KAAK;IASvC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAChD;;;;;;;OAOG;IACH,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI;IAzB3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,UAAS;gBAEhB,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM;IACvB;;;;;;OAMG;IACM,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAW;IACvD;;;;;;;OAOG;IACM,iBAAiB,GAAE,MAAM,GAAG,IAAW;CAKnD"}
package/dist/errors.js DELETED
@@ -1,40 +0,0 @@
1
- /** Thrown for any non-2xx response, carrying the HTTP status alongside the SERVER's own message (never a
2
- * generic one - whoever built this agent needs the reason, §6-40 one layer up from the chain). The
3
- * status is what lets `AgentRuntime` tell "this session token is stale, re-mint and retry" (401) apart
4
- * from every other failure, which it should surface as-is. */
5
- export class BotanaryApiError extends Error {
6
- status;
7
- details;
8
- retryAfterSeconds;
9
- requestId;
10
- code;
11
- operationId;
12
- userOpHash;
13
- requirementId;
14
- ambiguous = false;
15
- constructor(message, status,
16
- /**
17
- * The backend's own `error.details` blob, carried through rather than flattened into the message.
18
- * Some refusals are ACTIONABLE and say so in structured fields - `missingModule` names a setup module
19
- * the account lacks - and a tool that can only read prose has to pattern-match on wording to notice.
20
- * Keeping the object means a handler keys off a field the backend guarantees instead of a sentence it
21
- * is free to reword. Null whenever the response carried none.
22
- */
23
- details = null,
24
- /**
25
- * The `Retry-After` header's value in SECONDS, when the server sent one (429/503 carry it). Null
26
- * otherwise. Kept as a first-class field because a caller that wants to survive a rate limit -
27
- * `wallet/login.ts`'s poll loop is the one that must - cannot see response headers otherwise, and
28
- * guessing a backoff when the server told you the exact number is how a retry storm starts.
29
- * Only the numeric (delta-seconds) form is parsed; the HTTP-date form yields null, and the caller
30
- * falls back to its own backoff rather than mis-parsing a date as a duration.
31
- */
32
- retryAfterSeconds = null) {
33
- super(message);
34
- this.status = status;
35
- this.details = details;
36
- this.retryAfterSeconds = retryAfterSeconds;
37
- this.name = 'BotanaryApiError';
38
- }
39
- }
40
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;+DAG+D;AAC/D,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAS9B;IAQA;IASA;IAzBX,SAAS,CAAU;IACnB,IAAI,CAAU;IACd,WAAW,CAAU;IACrB,UAAU,CAAU;IACpB,aAAa,CAAU;IACvB,SAAS,GAAG,KAAK,CAAC;IAClB,YACE,OAAe,EACN,MAAc;IACvB;;;;;;OAMG;IACM,UAA0C,IAAI;IACvD;;;;;;;OAOG;IACM,oBAAmC,IAAI;QAEhD,KAAK,CAAC,OAAO,CAAC,CAAC;QAnBN,WAAM,GAAN,MAAM,CAAQ;QAQd,Y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AC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/E;AACD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IAClD,0FAA0F;IAC1F,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3C,4EAA4E;IAC5E,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC/C;AAkBD,wGAAwG;AACxG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,CAkB1E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,GAAG,kBAAkB,GAAG,gBAAgB,CAU3I;AAED,sGAAsG;AACtG,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;IAC1I,MAAM,EAAE,cAAc,CAAC;IAAC,UAAU,EAAE,GAAG,CAAC;IAAC,SAAS,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAC;CACnF,CAAC,CA0ED;AAED,qGAAqG;AACrG,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYrF"}
@@ -1,178 +0,0 @@
1
- import { BotanaryApiError } from './errors.js';
2
- import { encodeFunctionData, encodePacked, decodeFunctionData, parseAbi, getAddress, zeroAddress, zeroHash } from 'viem';
3
- import { entryPoint07Address, getUserOperationHash } from 'viem/account-abstraction';
4
- import { hex, invalidResponse, record, resourceId, unsignedUserOp, userOpQuantity } from './validation.js';
5
- const kernelAbi = parseAbi(['function execute(bytes32 mode, bytes executionCalldata) payable']);
6
- const grantAbi = parseAbi([
7
- 'function executeUnderGrant(bytes32 permissionId, address target, uint256 value, bytes callData)',
8
- 'function executeUnderGrantWithAllowance(bytes32 permissionId, address target, uint256 value, address token, uint256 allowance, bytes callData)',
9
- ]);
10
- const transferAbi = parseAbi(['function transfer(address to, uint256 amount) returns (bool)']);
11
- const swapAbi = parseAbi(['function swapExactIn(address tokenIn, address tokenOut, uint256 amountIn, uint256 minOut, address to) returns (uint256 amountOut)']);
12
- const sessionKey = BigInt('0x000100000000008bdaba73cd9815d79069c247eb4bda0000');
13
- function same(left, right) { return typeof left === 'string' && left.toLowerCase() === right.toLowerCase(); }
14
- function integer(value, positive = true) {
15
- if (typeof value !== 'string' || !/^(0|[1-9][0-9]{0,77})$/.test(value))
16
- return invalidResponse();
17
- const result = BigInt(value);
18
- if (result >= 2n ** 256n || (positive && result === 0n))
19
- return invalidResponse();
20
- return result;
21
- }
22
- /** Copy and validate before awaiting transport, so caller mutations cannot change the signed intent. */
23
- export function exactActionInput(value) {
24
- const input = record(value);
25
- const allowed = ['accountId', 'accountAddress', 'chainId', 'action', 'tokenAddress', 'amount', 'recipient', 'tokenOutAddress', 'maxSlippageBps'];
26
- if (Object.keys(input).some(key => !allowed.includes(key)))
27
- invalidResponse();
28
- resourceId(input.accountId);
29
- hex(input.accountAddress, 20);
30
- hex(input.tokenAddress, 20);
31
- integer(input.amount);
32
- if (!Number.isSafeInteger(input.chainId) || Number(input.chainId) <= 0)
33
- invalidResponse();
34
- if (input.action === 'transfer') {
35
- hex(input.recipient, 20);
36
- if (input.tokenOutAddress !== undefined || input.maxSlippageBps !== undefined)
37
- invalidResponse();
38
- }
39
- else if (input.action === 'swap') {
40
- hex(input.tokenOutAddress, 20);
41
- if (input.recipient !== undefined || (input.maxSlippageBps !== undefined &&
42
- (!Number.isInteger(input.maxSlippageBps) || Number(input.maxSlippageBps) < 1 || Number(input.maxSlippageBps) > 1000)))
43
- invalidResponse();
44
- }
45
- else
46
- invalidResponse();
47
- return Object.freeze({ ...value, accountAddress: getAddress(value.accountAddress), tokenAddress: getAddress(value.tokenAddress),
48
- ...(value.recipient !== undefined ? { recipient: getAddress(value.recipient) } : {}),
49
- ...(value.tokenOutAddress !== undefined ? { tokenOutAddress: getAddress(value.tokenOutAddress) } : {}),
50
- });
51
- }
52
- export function actionBinding(value, action) {
53
- resourceId(value.delegationId);
54
- hex(value.permissionId, 32);
55
- hex(value.executorAddress, 20);
56
- integer(value.maxGasCostWei);
57
- if (action.action === 'swap') {
58
- const swap = value;
59
- hex(swap.routerAddress, 20);
60
- integer(swap.minAmountOut);
61
- if (swap.verifyRoute !== undefined && typeof swap.verifyRoute !== 'function')
62
- invalidResponse();
63
- }
64
- return Object.freeze({ ...value, executorAddress: getAddress(value.executorAddress),
65
- ...(action.action === 'swap' ? { routerAddress: getAddress(value.routerAddress) } : {}),
66
- });
67
- }
68
- /** Validate the actual call and recompute its chain-bound v0.7 hash before handing it to a signer. */
69
- export async function validateExactAction(value, input, binding) {
70
- try {
71
- const build = record(value);
72
- const context = record(build.execution);
73
- const wire = unsignedUserOp(build.userOp);
74
- const op = Object.freeze({ ...wire, sender: getAddress(wire.sender), entryPoint: getAddress(wire.entryPoint) });
75
- hex(build.userOpHash, 32);
76
- if (build.intentType !== 'delegated_action' || record(build.simulation).willSucceed !== true ||
77
- context.accountId !== input.accountId || !same(context.accountAddress, input.accountAddress) ||
78
- context.chainId !== input.chainId || context.action !== input.action || context.amount !== input.amount ||
79
- !same(context.tokenAddress, input.tokenAddress) || context.delegationId !== binding.delegationId ||
80
- !same(context.permissionId, binding.permissionId) || context.gasMethod !== 'native' ||
81
- !same(op.sender, input.accountAddress) || op.chainId !== input.chainId || !same(op.entryPoint, entryPoint07Address) ||
82
- op.factory != null || op.factoryData != null || op.paymaster != null || op.paymasterData != null ||
83
- op.paymasterVerificationGasLimit != null || op.paymasterPostOpGasLimit != null)
84
- invalidResponse();
85
- const nonce = userOpQuantity(op.nonce);
86
- if (nonce >> 64n !== sessionKey)
87
- invalidResponse();
88
- const callGasLimit = userOpQuantity(op.callGasLimit, 128);
89
- const verificationGasLimit = userOpQuantity(op.verificationGasLimit, 128);
90
- const preVerificationGas = userOpQuantity(op.preVerificationGas);
91
- const maxFeePerGas = userOpQuantity(op.maxFeePerGas, 128);
92
- const maxPriorityFeePerGas = userOpQuantity(op.maxPriorityFeePerGas, 128);
93
- if (maxPriorityFeePerGas > maxFeePerGas ||
94
- (callGasLimit + verificationGasLimit + preVerificationGas) * maxFeePerGas > integer(binding.maxGasCostWei))
95
- invalidResponse();
96
- // Smart Sessions requires raw Kernel execute, without an owner executeUserOp wrapper.
97
- const rawCallData = op.callData;
98
- let inner;
99
- if (input.action === 'transfer') {
100
- if (!same(context.recipient, input.recipient) || context.tokenOutAddress !== undefined || context.maxSlippageBps !== undefined)
101
- invalidResponse();
102
- const native = same(input.tokenAddress, zeroAddress);
103
- inner = encodeFunctionData({ abi: grantAbi, functionName: 'executeUnderGrant', args: [binding.permissionId,
104
- (native ? input.recipient : input.tokenAddress), native ? integer(input.amount) : 0n,
105
- native ? '0x' : encodeFunctionData({ abi: transferAbi, functionName: 'transfer', args: [input.recipient, integer(input.amount)] }),
106
- ] });
107
- }
108
- else {
109
- const swap = binding;
110
- if (!same(context.tokenOutAddress, input.tokenOutAddress) || context.recipient !== undefined ||
111
- context.maxSlippageBps !== (input.maxSlippageBps ?? 50))
112
- invalidResponse();
113
- const kernel = decodeFunctionData({ abi: kernelAbi, data: rawCallData });
114
- const packed = kernel.args[1];
115
- const decoded = decodeFunctionData({ abi: grantAbi, data: `0x${packed.slice(106)}` });
116
- if (decoded.functionName !== 'executeUnderGrantWithAllowance')
117
- invalidResponse();
118
- const routeData = decoded.args[5];
119
- const facts = Object.freeze({ chainId: input.chainId, accountAddress: input.accountAddress,
120
- routerAddress: swap.routerAddress, tokenAddress: input.tokenAddress, tokenOutAddress: input.tokenOutAddress,
121
- amount: input.amount, minAmountOut: swap.minAmountOut, callData: routeData });
122
- if (swap.verifyRoute) {
123
- if (await swap.verifyRoute(facts) !== true)
124
- invalidResponse();
125
- }
126
- else {
127
- const route = decodeFunctionData({ abi: swapAbi, data: routeData });
128
- const [from, to, amount, minOut, recipient] = route.args;
129
- if (!same(from, input.tokenAddress) || !same(to, input.tokenOutAddress) || amount !== integer(input.amount) ||
130
- minOut < integer(swap.minAmountOut) || !same(recipient, input.accountAddress) ||
131
- !same(encodeFunctionData({ abi: swapAbi, functionName: 'swapExactIn', args: route.args }), routeData))
132
- invalidResponse();
133
- }
134
- inner = encodeFunctionData({ abi: grantAbi, functionName: 'executeUnderGrantWithAllowance', args: [binding.permissionId,
135
- swap.routerAddress, 0n, input.tokenAddress, integer(input.amount), routeData] });
136
- }
137
- const expected = encodeFunctionData({ abi: kernelAbi, functionName: 'execute', args: [zeroHash,
138
- encodePacked(['address', 'uint256', 'bytes'], [binding.executorAddress, 0n, inner])] });
139
- if (!same(rawCallData, expected))
140
- invalidResponse();
141
- const hash = getUserOperationHash({ entryPointAddress: entryPoint07Address, entryPointVersion: '0.7', chainId: input.chainId,
142
- userOperation: { sender: op.sender, nonce, callData: op.callData, callGasLimit, verificationGasLimit, preVerificationGas,
143
- maxFeePerGas, maxPriorityFeePerGas, signature: '0x' } });
144
- if (!same(hash, build.userOpHash))
145
- invalidResponse();
146
- const execution = Object.freeze({ ...input, delegationId: binding.delegationId, permissionId: binding.permissionId,
147
- gasMethod: 'native', ...(input.action === 'swap' ? { maxSlippageBps: input.maxSlippageBps ?? 50 } : {}) });
148
- // Whitelist fields instead of forwarding extra server-controlled authorization extensions.
149
- const userOp = Object.freeze({ sender: op.sender, chainId: op.chainId, entryPoint: op.entryPoint,
150
- nonce: op.nonce, callData: op.callData, callGasLimit: op.callGasLimit, verificationGasLimit: op.verificationGasLimit,
151
- preVerificationGas: op.preVerificationGas, maxFeePerGas: op.maxFeePerGas, maxPriorityFeePerGas: op.maxPriorityFeePerGas,
152
- signature: '0x' });
153
- return { userOp, userOpHash: hash, execution };
154
- }
155
- catch {
156
- return invalidResponse();
157
- }
158
- }
159
- /** Receipt validation happens after submission, so failure must retain the reconciliation handle. */
160
- export function exactActionReceipt(value, hash) {
161
- try {
162
- const receipt = record(value);
163
- resourceId(receipt.id);
164
- if (!same(receipt.userOpHash, hash) || !['pending', 'included', 'failed'].includes(String(receipt.status)))
165
- throw new Error();
166
- if (receipt.txHash != null)
167
- hex(receipt.txHash, 32);
168
- return receipt;
169
- }
170
- catch {
171
- const error = new BotanaryApiError('Botanary returned an invalid receipt. Reconcile using the original operation hash.', 0);
172
- error.code = 'invalid_response';
173
- error.userOpHash = hash;
174
- error.ambiguous = true;
175
- throw error;
176
- }
177
- }
178
- //# sourceMappingURL=exact-action.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exact-action.js","sourceRoot":"","sources":["../src/exact-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,kBAAkB,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAY,MAAM,MAAM,CAAC;AACnI,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAqC3G,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,iEAAiE,CAAC,CAAC,CAAC;AAChG,MAAM,QAAQ,GAAG,QAAQ,CAAC;IACxB,iGAAiG;IACjG,gJAAgJ;CACjJ,CAAC,CAAC;AACH,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,8DAA8D,CAAC,CAAC,CAAC;AAC/F,MAAM,OAAO,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AC,OAAO,CAAC,MAAM,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,EAAE,CAAC;QAC9H,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI;YAAE,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACpD,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAAC,oFAAoF,EAAE,CAAC,CAAC,CAAC;QAC5H,KAAK,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC;QAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;QACjF,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAOhC;;+EAE+E;AAC/E,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAgBzD;AAED;;;;;;kFAMkF;AAClF,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,WAAW,IAAI,CAAC;AAE7B;oGACoG;AACpG,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAGtD;AAED;uDACuD;AACvD,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C"}
@@ -1,47 +0,0 @@
1
- import { randomBytes } from 'node:crypto';
2
- import { hexToBytes } from 'viem';
3
- // Crockford Base32: 32 symbols, excludes I/L/O/U so nothing is ambiguous when read aloud or typed by
4
- // hand (no risk of confusing 0/O, 1/I/L), case-insensitive by convention. This is the same alphabet
5
- // family used by ULIDs and plenty of other human-facing codes for exactly this reason.
6
- const ALPHABET = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
7
- /** Encode `bytes` as Crockford Base32. Not meant to round-trip (no decoder here, and slicing the
8
- * result to a shorter display length - see below - deliberately drops the tail) - this is a display
9
- * transform for short human-facing codes, not a data-interchange encoding. */
10
- export function crockfordBase32(bytes) {
11
- let bitBuffer = 0;
12
- let bitCount = 0;
13
- let output = '';
14
- for (const byte of bytes) {
15
- bitBuffer = (bitBuffer << 8) | byte;
16
- bitCount += 8;
17
- while (bitCount >= 5) {
18
- output += ALPHABET[(bitBuffer >>> (bitCount - 5)) & 0x1f];
19
- bitCount -= 5;
20
- }
21
- }
22
- if (bitCount > 0) {
23
- output += ALPHABET[(bitBuffer << (5 - bitCount)) & 0x1f];
24
- }
25
- return output;
26
- }
27
- /** Bytes of address fingerprint / pairing nonce - chosen for "short to type" over "cryptographically
28
- * weighty", since neither is a secret (see README's "why intercepting the code alone grants nothing").
29
- * FINGERPRINT_BYTES: ~24 bits, purely a human recognition aid - the full address is always available
30
- * via get_identity for exact verification, so collisions here cost nothing but a moment's "hm, two
31
- * agents look similar", not a security property.
32
- * NONCE_BYTES: ~40 bits of fresh randomness per pairing code, the thing that actually makes each code
33
- * single-use in practice (combined with the short TTL - see pairing-code.ts). */
34
- export const FINGERPRINT_BYTES = 3;
35
- export const NONCE_BYTES = 5;
36
- /** A short, deterministic, human-typable id for an address - always the same for the same address.
37
- * Purely a display/recognition aid (see module doc); the address itself is the real identifier. */
38
- export function deriveFingerprint(address) {
39
- const bytes = hexToBytes(address);
40
- return crockfordBase32(bytes.slice(0, FINGERPRINT_BYTES));
41
- }
42
- /** A fresh random nonce for one pairing code. Never derived from the key - pure randomness, so a new
43
- * call can never be predicted from a previous one. */
44
- export function generatePairingNonce() {
45
- return crockfordBase32(randomBytes(NONCE_BYTES));
46
- }
47
- //# sourceMappingURL=fingerprint.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,O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C,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;AACnD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/generated/routes.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyFf,CAAC"}
@@ -1,92 +0,0 @@
1
- // Generated from reviewed operations in openapi/botanary-v1.yaml. Do not edit by hand.
2
- export const AGENT_ROUTES = [
3
- {
4
- "method": "post",
5
- "path": "/agents/pair"
6
- },
7
- {
8
- "method": "post",
9
- "path": "/agents/session/nonce"
10
- },
11
- {
12
- "method": "post",
13
- "path": "/agents/session"
14
- },
15
- {
16
- "method": "get",
17
- "path": "/agents/me"
18
- },
19
- {
20
- "method": "get",
21
- "path": "/agents/requests"
22
- },
23
- {
24
- "method": "post",
25
- "path": "/agents/requests"
26
- },
27
- {
28
- "method": "get",
29
- "path": "/balance"
30
- },
31
- {
32
- "method": "get",
33
- "path": "/chains"
34
- },
35
- {
36
- "method": "get",
37
- "path": "/gas/methods"
38
- },
39
- {
40
- "method": "get",
41
- "path": "/account"
42
- },
43
- {
44
- "method": "post",
45
- "path": "/delegations/{delegationId}/actions"
46
- },
47
- {
48
- "method": "post",
49
- "path": "/delegations/{delegationId}/actions/exact"
50
- },
51
- {
52
- "method": "post",
53
- "path": "/userops"
54
- },
55
- {
56
- "method": "get",
57
- "path": "/userops/{userOpId}"
58
- },
59
- {
60
- "method": "get",
61
- "path": "/userops/by-hash/{chainId}/{userOpHash}"
62
- },
63
- {
64
- "method": "get",
65
- "path": "/apis/providers"
66
- },
67
- {
68
- "method": "get",
69
- "path": "/apis/providers/{providerId}"
70
- },
71
- {
72
- "method": "get",
73
- "path": "/apis/budget"
74
- },
75
- {
76
- "method": "post",
77
- "path": "/apis/calls/requirements"
78
- },
79
- {
80
- "method": "get",
81
- "path": "/apis/calls/requirements/{id}"
82
- },
83
- {
84
- "method": "post",
85
- "path": "/apis/calls/relay"
86
- },
87
- {
88
- "method": "get",
89
- "path": "/apis/calls/relay/{id}"
90
- }
91
- ];
92
- //# sourceMappingURL=routes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/generated/routes.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B;QACE,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,cAAc;KACvB;IACD;QACE,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,uBAAuB;KAChC;IACD;QACE,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,iBAAiB;KAC1B;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,YAAY;KACrB;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,kBAAkB;KAC3B;IACD;QACE,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,kBAAkB;KAC3B;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,UAAU;KACnB;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,SAAS;KAClB;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,cAAc;KACvB;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,UAAU;KACnB;IACD;QACE,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,qCAAqC;KAC9C;IACD;QACE,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,2CAA2C;KACpD;IACD;QACE,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,UAAU;KACnB;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,qBAAqB;KAC9B;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,yCAAyC;KAClD;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,iBAAiB;K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