otto-execute 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 (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +151 -0
  3. package/dist/cdp-signer.d.ts +2 -0
  4. package/dist/cdp-signer.js +3 -0
  5. package/dist/cdp.d.ts +7 -0
  6. package/dist/cdp.js +8 -0
  7. package/dist/chain.d.ts +2 -0
  8. package/dist/chain.js +3 -0
  9. package/dist/cli.d.ts +17 -0
  10. package/dist/cli.js +400 -0
  11. package/dist/delegate.d.ts +117 -0
  12. package/dist/delegate.js +394 -0
  13. package/dist/eoa-signer.d.ts +94 -0
  14. package/dist/eoa-signer.js +289 -0
  15. package/dist/erc20.d.ts +2 -0
  16. package/dist/erc20.js +3 -0
  17. package/dist/index.d.ts +16 -0
  18. package/dist/index.js +19 -0
  19. package/dist/lifi-decode.d.ts +2 -0
  20. package/dist/lifi-decode.js +3 -0
  21. package/dist/mutations.d.ts +55 -0
  22. package/dist/mutations.js +363 -0
  23. package/dist/refusal.d.ts +2 -0
  24. package/dist/refusal.js +3 -0
  25. package/dist/vendor/otto-intel-mcp/VENDORED.json +52 -0
  26. package/dist/vendor/otto-intel-mcp/adapter/cdp-signer.d.ts +133 -0
  27. package/dist/vendor/otto-intel-mcp/adapter/cdp-signer.js +356 -0
  28. package/dist/vendor/otto-intel-mcp/adapter/chain.d.ts +36 -0
  29. package/dist/vendor/otto-intel-mcp/adapter/chain.js +65 -0
  30. package/dist/vendor/otto-intel-mcp/adapter/erc20.d.ts +39 -0
  31. package/dist/vendor/otto-intel-mcp/adapter/erc20.js +17 -0
  32. package/dist/vendor/otto-intel-mcp/adapter/lifi-decode.d.ts +52 -0
  33. package/dist/vendor/otto-intel-mcp/adapter/lifi-decode.js +149 -0
  34. package/dist/vendor/otto-intel-mcp/adapter/refusal.d.ts +21 -0
  35. package/dist/vendor/otto-intel-mcp/adapter/refusal.js +55 -0
  36. package/dist/vendor/otto-intel-mcp/adapter/sent-step.d.ts +15 -0
  37. package/dist/vendor/otto-intel-mcp/adapter/sent-step.js +6 -0
  38. package/dist/vendor/otto-intel-mcp/adapter/verify.d.ts +149 -0
  39. package/dist/vendor/otto-intel-mcp/adapter/verify.js +432 -0
  40. package/dist/vendor/otto-intel-mcp/adapter-cdp-index.d.ts +6 -0
  41. package/dist/vendor/otto-intel-mcp/adapter-cdp-index.js +7 -0
  42. package/dist/vendor/otto-intel-mcp/adapter-index.d.ts +15 -0
  43. package/dist/vendor/otto-intel-mcp/adapter-index.js +15 -0
  44. package/dist/vendor/otto-intel-mcp/artifact-id.d.ts +16 -0
  45. package/dist/vendor/otto-intel-mcp/artifact-id.js +60 -0
  46. package/dist/vendor/otto-intel-mcp/execution-config.d.ts +232 -0
  47. package/dist/vendor/otto-intel-mcp/execution-config.js +443 -0
  48. package/dist/vendor/otto-intel-mcp/execution-delegated-definition.d.ts +165 -0
  49. package/dist/vendor/otto-intel-mcp/execution-delegated-definition.js +116 -0
  50. package/dist/vendor/otto-intel-mcp/execution-delegation-admin-definition.d.ts +208 -0
  51. package/dist/vendor/otto-intel-mcp/execution-delegation-admin-definition.js +170 -0
  52. package/dist/vendor/otto-intel-mcp/execution-delegation-policy.d.ts +257 -0
  53. package/dist/vendor/otto-intel-mcp/execution-delegation-policy.js +279 -0
  54. package/dist/vendor/otto-intel-mcp/execution-errors.d.ts +9 -0
  55. package/dist/vendor/otto-intel-mcp/execution-errors.js +134 -0
  56. package/dist/vendor/otto-intel-mcp/execution-index.d.ts +17 -0
  57. package/dist/vendor/otto-intel-mcp/execution-index.js +16 -0
  58. package/dist/vendor/otto-intel-mcp/execution-intent.d.ts +14 -0
  59. package/dist/vendor/otto-intel-mcp/execution-intent.js +36 -0
  60. package/dist/vendor/otto-intel-mcp/execution-tool-definitions.d.ts +1103 -0
  61. package/dist/vendor/otto-intel-mcp/execution-tool-definitions.js +1051 -0
  62. package/dist/vendor/otto-intel-mcp/execution-types.d.ts +274 -0
  63. package/dist/vendor/otto-intel-mcp/execution-types.js +157 -0
  64. package/dist/verify.d.ts +2 -0
  65. package/dist/verify.js +3 -0
  66. package/dist/x402-table.d.ts +99 -0
  67. package/dist/x402-table.js +221 -0
  68. package/package.json +97 -0
@@ -0,0 +1,134 @@
1
+ export const EXECUTION_REFUSAL_CODES = [
2
+ 'ATTRIBUTION_MISSING',
3
+ /**
4
+ * The total take on the route exceeds the configured aggregate cap, while Otto's own
5
+ * attribution is present, exactly-valued, and correctly addressed.
6
+ *
7
+ * Kept distinct from `ATTRIBUTION_MISSING` on purpose: the configured cap sits exactly on the
8
+ * live aggregate (LI.FI platform 15 bps + Otto 10 bps = the 25 bps cap), so any upstream
9
+ * pricing move — a platform rate change, a relay fee appearing on a route, a new finality
10
+ * tier — takes the route over the cap. That is an upstream repricing to investigate, not a
11
+ * fee-integrity attack, and reporting both under one code would make a total outage
12
+ * indistinguishable from someone tampering with Otto's fee.
13
+ */
14
+ 'LIFI_FEE_CAP_EXCEEDED',
15
+ 'ACCOUNT_BINDING_MISMATCH',
16
+ 'DIGEST_MISMATCH',
17
+ 'ARTIFACT_INVALID',
18
+ 'STALE_ARTIFACT',
19
+ 'EXECUTION_RATE_LIMITED',
20
+ 'EXECUTION_CONCURRENCY_FULL',
21
+ 'UNSUPPORTED_ACCOUNT_PROFILE',
22
+ 'LIFI_QUOTE_FAILED',
23
+ 'LIFI_QUOTE_INVALID',
24
+ 'UNSUPPORTED_LIFI_ROUTE',
25
+ /** A public Polymarket CLOB metadata read failed outright (transport, HTTP, or non-JSON). */
26
+ 'POLYMARKET_METADATA_FAILED',
27
+ /** The read succeeded but the body is not a shape the constructor may act on. */
28
+ 'POLYMARKET_METADATA_INVALID',
29
+ /** The market, tick size, price, or size is outside what this constructor supports by name. */
30
+ 'UNSUPPORTED_POLYMARKET_MARKET',
31
+ /** The constructed order failed a decode-back assertion on the exact bytes to be signed. */
32
+ 'POLYMARKET_ORDER_INVALID',
33
+ /**
34
+ * The live builder registry no longer carries the RULED rates. Distinct from
35
+ * `ATTRIBUTION_MISSING` on purpose: Otto's attribution is present and enabled, but the rate value
36
+ * in force is not the one the config version documents, and the value itself is a Founder ruling
37
+ * (spec §13 — the taker-rate flip waits on the `/builder/trades` volume pull). The constructor
38
+ * refuses rather than guessing which rate the caller is about to pay.
39
+ */
40
+ 'POLYMARKET_BUILDER_FEE_UNRULED',
41
+ /** A public Hyperliquid info read failed outright (transport, HTTP, or non-JSON). */
42
+ 'HYPERLIQUID_META_FAILED',
43
+ /** The read succeeded but the perp universe is not a shape the constructor may act on. */
44
+ 'HYPERLIQUID_META_INVALID',
45
+ /**
46
+ * The asset, price, or size is outside what the venue accepts, by name: an unknown or delisted
47
+ * perp, a price off the venue's own significant-figure/decimal grid, or a size finer than the
48
+ * asset's `szDecimals`. Refused rather than rounded — a rounded price is a different order than
49
+ * the one the caller asked for, and this constructor never signs the caller into one.
50
+ */
51
+ 'UNSUPPORTED_HYPERLIQUID_MARKET',
52
+ /**
53
+ * The constructed L1 action failed a decode-back assertion against the SDK's own normalized
54
+ * action, its canonical msgpack key order, or the declared EIP-712 signing fields.
55
+ *
56
+ * NOTE for the Hyperliquid rail: `ATTRIBUTION_MISSING` is deliberately NOT raised for an absent
57
+ * builder field. The builder `{b, f}` is spec'd and VALUELESS today (spec §7.2/§12, Founder-ruled
58
+ * 2026-08-17): its value waits on the Step-0 `approveBuilderFee` reversal. An absent builder is
59
+ * therefore the ruled state, not a defect, and refusing a well-formed order over it would violate
60
+ * P0 liveness (§7.0). The pending state is disclosed in the envelope instead.
61
+ */
62
+ 'HYPERLIQUID_ORDER_INVALID',
63
+ /* ── Delegated send (`otto_submit_under_delegation`, Model B browser plane) ─────────────────── */
64
+ /** The server holds no CDP developer credentials; the tool does not register without them. */
65
+ 'DELEGATION_UNAVAILABLE',
66
+ /** The per-request caller header is missing or not accepted — refused before anything is parsed or read. */
67
+ 'DELEGATION_UNAUTHORIZED',
68
+ /** The input does not satisfy the delegated-send schema (floor stated, Base, EOA). */
69
+ 'DELEGATION_INPUT_INVALID',
70
+ /** One delegated plan at a time per end user; another is in flight. */
71
+ 'DELEGATION_BUSY',
72
+ /** The SAME artifact is being submitted right now (a retry raced its first submission). */
73
+ 'DELEGATION_ARTIFACT_IN_FLIGHT',
74
+ /**
75
+ * The artifact was not prepared by THIS server process (or its freshness window has passed): the submission
76
+ * record that makes a retry safe cannot exist here — prepare again. Fail-closed across a rolling replacement.
77
+ */
78
+ 'ARTIFACT_NOT_PREPARED_HERE',
79
+ /**
80
+ * The prepare was refused: this process already holds its maximum of LIVE prepared artifacts (the delegated
81
+ * tool's prepared-here registry). Nothing already issued is dropped to make room — retry after some expire.
82
+ */
83
+ 'PREPARED_ARTIFACT_CAPACITY',
84
+ /** The prepare minted an id this process already holds for DIFFERENT content (an entropy collision): refused, never issued unregistered. */
85
+ 'ARTIFACT_ID_COLLISION',
86
+ /** The artifact was already submitted on this server with a DIFFERENT request (user, account or intent); nothing is re-sent — prepare again. */
87
+ 'DELEGATION_REPLAY_MISMATCH',
88
+ /** The Model-B project policy is not in force — absent, renamed, or its rules no longer digest to v1. */
89
+ 'DELEGATION_FENCE_ABSENT',
90
+ /** A DIFFERENT project-scope policy is installed (Coinbase allows one); never overwritten or deleted — refused by name. */
91
+ 'DELEGATION_FENCE_FOREIGN',
92
+ /** More than one project-scope policy read back (Coinbase allows one): an anomalous snapshot — nothing judged, nothing written. */
93
+ 'DELEGATION_FENCE_AMBIGUOUS',
94
+ /** The installed fence is a NEWER version of our lineage than this server knows; never downgraded. */
95
+ 'DELEGATION_FENCE_NEWER',
96
+ /** The CDP access token does not resolve to an end user; no upstream detail is relayed. */
97
+ 'DELEGATION_TOKEN_INVALID',
98
+ /** The revoke was issued but the grant still reads back; the user is fail-closed on this server regardless. */
99
+ 'DELEGATION_REVOKE_NOT_CONFIRMED',
100
+ /** No active delegation for the end user, or it expires before the envelope does, or revocation was requested here. */
101
+ 'DELEGATION_NOT_ACTIVE',
102
+ /**
103
+ * The grant's REMAINING validity is longer than the ruled maximum. The mint happens browser→Coinbase with
104
+ * no Otto hop, so a modified client or a skewed clock can mint any expiry Coinbase accepts; the bound is
105
+ * therefore enforceable only here, at use.
106
+ */
107
+ 'DELEGATION_EXPIRY_EXCEEDS_BOUND',
108
+ /** CDP reports no end user with this id. */
109
+ 'DELEGATION_USER_UNKNOWN',
110
+ /** A verified plan the fence would refuse anyway: input token not allow-listed, spender not the reviewed diamond, gross over the per-swap cap. */
111
+ 'DELEGATION_OUTSIDE_FENCE',
112
+ /** The user-side verifier refused the envelope with an adapter code the constructor does not share; the message carries `[CODE]`. */
113
+ 'DELEGATED_PLAN_REFUSED',
114
+ /** The plan halted mid-way; the message reports the failed step and whether the allowance clear read back zero. */
115
+ 'DELEGATED_PLAN_HALTED',
116
+ /** A CDP or chain read/write failed outright; no upstream body is relayed. */
117
+ 'DELEGATION_UPSTREAM_FAILED',
118
+ ];
119
+ /** A fail-closed, machine-readable refusal. No upstream response bodies or secrets are retained. */
120
+ export class ExecutionRefusal extends Error {
121
+ code;
122
+ constructor(code, message) {
123
+ super(message);
124
+ this.code = code;
125
+ this.name = 'ExecutionRefusal';
126
+ }
127
+ }
128
+ export function refuse(code, message) {
129
+ throw new ExecutionRefusal(code, message);
130
+ }
131
+ export function isExecutionRefusal(error) {
132
+ return error instanceof ExecutionRefusal;
133
+ }
134
+ //# sourceMappingURL=execution-errors.js.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * execution-index.ts — the CONSUMER-SIDE entry (`otto-intel-mcp/execution`): what a signing adapter
3
+ * needs to verify and bind a prepare-only artifact — schemas, digest/commitment/freshness/binding
4
+ * assertions, the refusal class, the ruled attribution constants, and the intent normalizer — and
5
+ * NOTHING that constructs: no tool catalog, no prepare functions, no quote clients, no venue SDKs.
6
+ * (The root index pulls the hosted app and is not importable from a published install.)
7
+ */
8
+ export { EXECUTION_ARTIFACT_SCHEMA, EXECUTION_ENVELOPE_SCHEMA, PREPARE_SWAP_INPUT_SCHEMA, } from './execution-tool-definitions.js';
9
+ export type { PrepareSwapInput } from './execution-tool-definitions.js';
10
+ export { swapIntentDigestInput } from './execution-intent.js';
11
+ export { artifactCommitmentDigest, assertArtifactAccountBinding, assertArtifactCommitment, assertArtifactEnvelope, assertArtifactFresh, assertArtifactPayloadDigest, executionDigest, MAX_ARTIFACT_TTL_MS, } from './execution-types.js';
12
+ export type { AccountProfile, ExecutionArtifact, ExecutionEnvelope, ExecutionPayload, } from './execution-types.js';
13
+ export { ExecutionRefusal, EXECUTION_REFUSAL_CODES } from './execution-errors.js';
14
+ export { MODEL_B_DELEGATION_EXPIRY_DEFAULT_DAYS, MODEL_B_DELEGATION_EXPIRY_MAX_DAYS, MODEL_B_INPUT_TOKENS_V1, MODEL_B_PER_SWAP_CAP_USD, boundedDelegationExpiry, MODEL_B_POLICY_DIGEST_V1, MODEL_B_POLICY_NAME_V1, modelBProjectPolicyBody, modelBProjectPolicyRules, policyRulesDigest, readBackModelBFence, type DelegationPolicyRecord, type ModelBFenceReadBack, } from './execution-delegation-policy.js';
15
+ export { DELEGATED_EXECUTION_TOOL_NAME, DELEGATION_AUTH_HEADER, SUBMIT_UNDER_DELEGATION_INPUT_SCHEMA, DELEGATED_SEND_RESULT_SCHEMA, type DelegatedSendResult, type SubmitUnderDelegationInput, } from './execution-delegated-definition.js';
16
+ export { DEFAULT_LIFI_AGGREGATE_FEE_CAP_RATE, DEFAULT_LIFI_FEE_BPS, DEFAULT_LIFI_FEE_CONFIG_VERSION, DEFAULT_LIFI_PLATFORM_FEE_RECIPIENT, DEFAULT_OTTO_LIFI_FEE_RECIPIENT, LIFI_DIAMOND_ADDRESS, LIFI_FEE_FORWARDERS_BY_CHAIN, LIFI_FEE_FORWARDER_V1, LIFI_FEE_FORWARDER_V1_MAINNET, LIFI_FEE_FORWARDER_V2, LIFI_INTEGRATOR, isReviewedLiFiFeeForwarder, reviewedLiFiFeeForwarders, unreviewedFeeForwarderMessage, } from './execution-config.js';
17
+ export { DELEGATION_ADMIN_TOOL_NAMES, DELEGATION_FENCE_INPUT_SCHEMA, DELEGATION_FENCE_RESULT_SCHEMA, DELEGATION_FENCE_STATUS_INPUT_SCHEMA, DELEGATION_FENCE_STATUS_RESULT_SCHEMA, DELEGATION_FENCE_STATUS_TOOL_NAME, DELEGATION_FENCE_TOOL_NAME, DELEGATION_REVOKE_INPUT_SCHEMA, DELEGATION_REVOKE_RESULT_SCHEMA, DELEGATION_REVOKE_TOOL_NAME, DELEGATION_STATUS_INPUT_SCHEMA, DELEGATION_STATUS_RESULT_SCHEMA, DELEGATION_STATUS_TOOL_NAME, type DelegationFenceResult, type DelegationFenceStatusResult, type DelegationRevokeResult, type DelegationStatusResult, } from './execution-delegation-admin-definition.js';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * execution-index.ts — the CONSUMER-SIDE entry (`otto-intel-mcp/execution`): what a signing adapter
3
+ * needs to verify and bind a prepare-only artifact — schemas, digest/commitment/freshness/binding
4
+ * assertions, the refusal class, the ruled attribution constants, and the intent normalizer — and
5
+ * NOTHING that constructs: no tool catalog, no prepare functions, no quote clients, no venue SDKs.
6
+ * (The root index pulls the hosted app and is not importable from a published install.)
7
+ */
8
+ export { EXECUTION_ARTIFACT_SCHEMA, EXECUTION_ENVELOPE_SCHEMA, PREPARE_SWAP_INPUT_SCHEMA, } from './execution-tool-definitions.js';
9
+ export { swapIntentDigestInput } from './execution-intent.js';
10
+ export { artifactCommitmentDigest, assertArtifactAccountBinding, assertArtifactCommitment, assertArtifactEnvelope, assertArtifactFresh, assertArtifactPayloadDigest, executionDigest, MAX_ARTIFACT_TTL_MS, } from './execution-types.js';
11
+ export { ExecutionRefusal, EXECUTION_REFUSAL_CODES } from './execution-errors.js';
12
+ export { MODEL_B_DELEGATION_EXPIRY_DEFAULT_DAYS, MODEL_B_DELEGATION_EXPIRY_MAX_DAYS, MODEL_B_INPUT_TOKENS_V1, MODEL_B_PER_SWAP_CAP_USD, boundedDelegationExpiry, MODEL_B_POLICY_DIGEST_V1, MODEL_B_POLICY_NAME_V1, modelBProjectPolicyBody, modelBProjectPolicyRules, policyRulesDigest, readBackModelBFence, } from './execution-delegation-policy.js';
13
+ export { DELEGATED_EXECUTION_TOOL_NAME, DELEGATION_AUTH_HEADER, SUBMIT_UNDER_DELEGATION_INPUT_SCHEMA, DELEGATED_SEND_RESULT_SCHEMA, } from './execution-delegated-definition.js';
14
+ export { DEFAULT_LIFI_AGGREGATE_FEE_CAP_RATE, DEFAULT_LIFI_FEE_BPS, DEFAULT_LIFI_FEE_CONFIG_VERSION, DEFAULT_LIFI_PLATFORM_FEE_RECIPIENT, DEFAULT_OTTO_LIFI_FEE_RECIPIENT, LIFI_DIAMOND_ADDRESS, LIFI_FEE_FORWARDERS_BY_CHAIN, LIFI_FEE_FORWARDER_V1, LIFI_FEE_FORWARDER_V1_MAINNET, LIFI_FEE_FORWARDER_V2, LIFI_INTEGRATOR, isReviewedLiFiFeeForwarder, reviewedLiFiFeeForwarders, unreviewedFeeForwarderMessage, } from './execution-config.js';
15
+ export { DELEGATION_ADMIN_TOOL_NAMES, DELEGATION_FENCE_INPUT_SCHEMA, DELEGATION_FENCE_RESULT_SCHEMA, DELEGATION_FENCE_STATUS_INPUT_SCHEMA, DELEGATION_FENCE_STATUS_RESULT_SCHEMA, DELEGATION_FENCE_STATUS_TOOL_NAME, DELEGATION_FENCE_TOOL_NAME, DELEGATION_REVOKE_INPUT_SCHEMA, DELEGATION_REVOKE_RESULT_SCHEMA, DELEGATION_REVOKE_TOOL_NAME, DELEGATION_STATUS_INPUT_SCHEMA, DELEGATION_STATUS_RESULT_SCHEMA, DELEGATION_STATUS_TOOL_NAME, } from './execution-delegation-admin-definition.js';
16
+ //# sourceMappingURL=execution-index.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * execution-intent.ts — the normalized swap intent whose digest is the envelope's `intent_digest`.
3
+ *
4
+ * Dependency-light on purpose (schema + viem address normalization only) so a consuming adapter can
5
+ * import it through `otto-intel-mcp/execution` without pulling the constructor's quote clients or
6
+ * venue SDKs. The constructor (`execution-tools.ts`) uses THIS function, so there is exactly one
7
+ * implementation of the normalization on both sides of the seam.
8
+ */
9
+ /**
10
+ * Parse the raw `otto_prepare_swap` input exactly as the constructor does (strict schema, trimmed
11
+ * strings, checksummed addresses) and return the object the constructor digests. A caller that kept
12
+ * its exact request can recompute `intent_digest` from it.
13
+ */
14
+ export declare function swapIntentDigestInput(rawInput: unknown): Record<string, unknown>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * execution-intent.ts — the normalized swap intent whose digest is the envelope's `intent_digest`.
3
+ *
4
+ * Dependency-light on purpose (schema + viem address normalization only) so a consuming adapter can
5
+ * import it through `otto-intel-mcp/execution` without pulling the constructor's quote clients or
6
+ * venue SDKs. The constructor (`execution-tools.ts`) uses THIS function, so there is exactly one
7
+ * implementation of the normalization on both sides of the seam.
8
+ */
9
+ import { getAddress } from 'viem';
10
+ import { PREPARE_SWAP_INPUT_SCHEMA } from './execution-tool-definitions.js';
11
+ /**
12
+ * Parse the raw `otto_prepare_swap` input exactly as the constructor does (strict schema, trimmed
13
+ * strings, checksummed addresses) and return the object the constructor digests. A caller that kept
14
+ * its exact request can recompute `intent_digest` from it.
15
+ */
16
+ export function swapIntentDigestInput(rawInput) {
17
+ const input = PREPARE_SWAP_INPUT_SCHEMA.parse(rawInput);
18
+ const address = getAddress(input.accountProfile.address);
19
+ return {
20
+ accountProfile: {
21
+ kind: input.accountProfile.kind,
22
+ address,
23
+ chainId: input.accountProfile.chainId,
24
+ },
25
+ chainId: input.chainId,
26
+ fromToken: getAddress(input.fromToken),
27
+ toToken: getAddress(input.toToken),
28
+ fromAmount: input.fromAmount,
29
+ slippage: {
30
+ maxBps: input.slippage.maxBps,
31
+ ...(input.slippage.minAmountOut ? { minAmountOut: input.slippage.minAmountOut } : {}),
32
+ },
33
+ ...(input.client_ref ? { client_ref: input.client_ref } : {}),
34
+ };
35
+ }
36
+ //# sourceMappingURL=execution-intent.js.map