@moonbeam-foundation/sdk 0.7.0 → 0.11.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 (132) hide show
  1. package/README.md +78 -432
  2. package/bin/moonbeam.mjs +15 -2
  3. package/dist/acp/moonbeam-acp.generated.d.ts +7 -2
  4. package/dist/acp/moonbeam-acp.generated.d.ts.map +1 -1
  5. package/dist/acp/moonbeam-acp.generated.js +6 -3
  6. package/dist/acp/moonbeam-acp.generated.js.map +1 -1
  7. package/dist/acp/outcome.d.ts +5 -1
  8. package/dist/acp/outcome.d.ts.map +1 -1
  9. package/dist/acp/outcome.js +3 -2
  10. package/dist/acp/outcome.js.map +1 -1
  11. package/dist/adapters/stamp.d.ts +1 -1
  12. package/dist/adapters/stamp.d.ts.map +1 -1
  13. package/dist/adapters/stamp.js +6 -6
  14. package/dist/adapters/stamp.js.map +1 -1
  15. package/dist/assurance/assurance-shared.d.ts.map +1 -1
  16. package/dist/assurance/assurance-shared.js +3 -1
  17. package/dist/assurance/assurance-shared.js.map +1 -1
  18. package/dist/cover/index.d.ts +65 -0
  19. package/dist/cover/index.d.ts.map +1 -0
  20. package/dist/cover/index.js +61 -0
  21. package/dist/cover/index.js.map +1 -0
  22. package/dist/devnet/edge.d.ts +207 -0
  23. package/dist/devnet/edge.d.ts.map +1 -0
  24. package/dist/devnet/edge.js +209 -0
  25. package/dist/devnet/edge.js.map +1 -0
  26. package/dist/devnet/index.d.ts +403 -0
  27. package/dist/devnet/index.d.ts.map +1 -0
  28. package/dist/devnet/index.js +420 -0
  29. package/dist/devnet/index.js.map +1 -0
  30. package/dist/devnet/profile.d.ts +110 -0
  31. package/dist/devnet/profile.d.ts.map +1 -0
  32. package/dist/devnet/profile.js +145 -0
  33. package/dist/devnet/profile.js.map +1 -0
  34. package/dist/erc8004/registry.generated.d.ts.map +1 -1
  35. package/dist/erc8004/registry.generated.js +0 -1
  36. package/dist/erc8004/registry.generated.js.map +1 -1
  37. package/dist/errors/index.d.ts +51 -0
  38. package/dist/errors/index.d.ts.map +1 -0
  39. package/dist/errors/index.js +63 -0
  40. package/dist/errors/index.js.map +1 -0
  41. package/dist/index.d.ts +6 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +6 -1
  44. package/dist/index.js.map +1 -1
  45. package/dist/jobs/index.d.ts +62 -0
  46. package/dist/jobs/index.d.ts.map +1 -0
  47. package/dist/jobs/index.js +59 -0
  48. package/dist/jobs/index.js.map +1 -0
  49. package/dist/judge/index.d.ts +109 -1
  50. package/dist/judge/index.d.ts.map +1 -1
  51. package/dist/judge/index.js +97 -3
  52. package/dist/judge/index.js.map +1 -1
  53. package/dist/market/index.d.ts +281 -0
  54. package/dist/market/index.d.ts.map +1 -0
  55. package/dist/market/index.js +211 -0
  56. package/dist/market/index.js.map +1 -0
  57. package/dist/onboard/index.d.ts +4 -4
  58. package/dist/onboard/index.d.ts.map +1 -1
  59. package/dist/onboard/index.js +9 -15
  60. package/dist/onboard/index.js.map +1 -1
  61. package/dist/pools/index.d.ts +29 -5
  62. package/dist/pools/index.d.ts.map +1 -1
  63. package/dist/pools/index.js +34 -15
  64. package/dist/pools/index.js.map +1 -1
  65. package/dist/proof/index.d.ts +8 -4
  66. package/dist/proof/index.d.ts.map +1 -1
  67. package/dist/proof/index.js +10 -7
  68. package/dist/proof/index.js.map +1 -1
  69. package/dist/resale/index.d.ts +22 -6
  70. package/dist/resale/index.d.ts.map +1 -1
  71. package/dist/resale/index.js +29 -15
  72. package/dist/resale/index.js.map +1 -1
  73. package/dist/resale/payment-scheme.pin.json +1 -1
  74. package/dist/resale/settle-rule.d.ts +49 -0
  75. package/dist/resale/settle-rule.d.ts.map +1 -0
  76. package/dist/resale/settle-rule.js +53 -0
  77. package/dist/resale/settle-rule.js.map +1 -0
  78. package/dist/workflows/data.d.ts +3 -0
  79. package/dist/workflows/data.d.ts.map +1 -0
  80. package/dist/workflows/data.js +829 -0
  81. package/dist/workflows/data.js.map +1 -0
  82. package/dist/workflows/index.d.ts +40 -0
  83. package/dist/workflows/index.d.ts.map +1 -0
  84. package/dist/workflows/index.js +79 -0
  85. package/dist/workflows/index.js.map +1 -0
  86. package/dist/workflows/steps.d.ts +48 -0
  87. package/dist/workflows/steps.d.ts.map +1 -0
  88. package/dist/workflows/steps.js +62 -0
  89. package/dist/workflows/steps.js.map +1 -0
  90. package/dist/workflows/types.d.ts +26 -0
  91. package/dist/workflows/types.d.ts.map +1 -0
  92. package/dist/workflows/types.js +2 -0
  93. package/dist/workflows/types.js.map +1 -0
  94. package/dist/workflows/verified.d.ts +17 -0
  95. package/dist/workflows/verified.d.ts.map +1 -0
  96. package/dist/workflows/verified.js +219 -0
  97. package/dist/workflows/verified.js.map +1 -0
  98. package/dist/x402/index.d.ts +80 -17
  99. package/dist/x402/index.d.ts.map +1 -1
  100. package/dist/x402/index.js +95 -27
  101. package/dist/x402/index.js.map +1 -1
  102. package/docs/REFERENCE.md +511 -0
  103. package/docs/WORKFLOWS.md +164 -0
  104. package/docs/studio/hire-from-chat.png +0 -0
  105. package/docs/studio/list-business.png +0 -0
  106. package/docs/studio/onboard-batch.png +0 -0
  107. package/docs/studio/onboard.png +0 -0
  108. package/docs/studio/publish.png +0 -0
  109. package/docs/studio/resell.png +0 -0
  110. package/docs/studio/sell-edge.png +0 -0
  111. package/docs/workflows/hire-from-chat.png +0 -0
  112. package/docs/workflows/hire-from-chat.svg +102 -0
  113. package/docs/workflows/list-business.png +0 -0
  114. package/docs/workflows/list-business.svg +116 -0
  115. package/docs/workflows/onboard-batch.png +0 -0
  116. package/docs/workflows/onboard-batch.svg +66 -0
  117. package/docs/workflows/onboard.png +0 -0
  118. package/docs/workflows/onboard.svg +76 -0
  119. package/docs/workflows/publish.png +0 -0
  120. package/docs/workflows/publish.svg +86 -0
  121. package/docs/workflows/resell.png +0 -0
  122. package/docs/workflows/resell.svg +116 -0
  123. package/docs/workflows/sell-edge.png +0 -0
  124. package/docs/workflows/sell-edge.svg +46 -0
  125. package/examples/40-the-article.mjs +1 -1
  126. package/examples/50-x402-pay-a-wall.mjs +22 -11
  127. package/examples/51-read-a-proof.mjs +5 -4
  128. package/examples/60-cross-list-a-seller.mjs +36 -0
  129. package/examples/README.md +11 -2
  130. package/examples/data/cross-list.recorded.json +10 -0
  131. package/examples/data/x402-wall-402.json +85 -0
  132. package/package.json +56 -15
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/devnet/edge.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAExD,eAAO,MAAM,cAAc,8BAA8C,CAAC;AAC1E,eAAO,MAAM,kBAAkB;yBAA+B,KAAK;kBAAO,KAAK;EAAY,CAAC;AAC5F,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AACrD,eAAO,MAAM,UAAU,yDAAyE,CAAC;AACjG,4EAA4E;AAC5E,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,KAAK,GAAG,KAAK,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AASD,MAAM,WAAW,OAAO;IAAG,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AAEpH,uHAAuH;AACvH,wBAAsB,OAAO,CAAC,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE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AAI,EAAE,GAAG,CAAC;QAAC,SAAS,EAAE,GAAG,GAAG,IAAI,CAAA;KAAE,CAAC;IAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;CAAE,GAAG,QAAQ,CAUjQ"}
@@ -0,0 +1,209 @@
1
+ /**
2
+ * The edge of an onboarded seller, as pure data: its ids, the check task and the rule its answer must pass, the agreement's
3
+ * typed data and hash, and the body the coordination API stores.
4
+ *
5
+ * An edge is four records: a lambda, a pool behind the edge's own seller of record, a meter row, and one agreement (an
6
+ * EIP-712 acceptance signed by the seller of record). The ids are pure functions of the tenant, the chain and the seller, the
7
+ * same derivation the API uses, so a repeat names the same edge.
8
+ *
9
+ * Nothing here signs, reads a clock or fetches. sha256 comes from Web Crypto (Node 20+ and every browser); keccak and the
10
+ * EIP-712 hash are this package's own.
11
+ */
12
+ import { bytesToHex, isAddress, isHex32, keccak256, utf8 } from '../onboard/index.js';
13
+ export const AGREEMENT_DOCS = Object.freeze(['TSUL-1.1', 'TAT']);
14
+ export const AGREEMENT_VERSIONS = Object.freeze({ 'TSUL-1.1': '1.1', TAT: '1.0' });
15
+ export const AGREEMENT_DOMAIN = 'Moonbeam Workflows';
16
+ export const METER_LEGS = Object.freeze(['seller_share', 'our_fee', 'reseller_markup']);
17
+ /** The class an onboarding edge sells: a reply on the seller's own wire. */
18
+ export const EDGE_CLASS = 'wire.reply';
19
+ export const TENANT = 'moonbeam';
20
+ const hex = (b) => bytesToHex(b).slice(2);
21
+ async function sha256hex(s) {
22
+ const subtle = globalThis.crypto?.subtle;
23
+ if (!subtle)
24
+ throw new Error('sha256 needs Web Crypto (crypto.subtle): Node 20+ or a browser');
25
+ return hex(new Uint8Array(await subtle.digest('SHA-256', utf8(s))));
26
+ }
27
+ /** The ids of one seller's edge. `edge_id` is the idempotency key: a repeat of the same seller names the same edge. */
28
+ export async function edgeIds(p) {
29
+ const tenant = p.tenant ?? TENANT;
30
+ const cls = p.cls ?? EDGE_CLASS;
31
+ const edge16 = (await sha256hex(`${tenant}|${p.chainId}|${p.seller.chain_id}:${p.seller.agent_id}`)).slice(0, 16);
32
+ return { edge16, edge_id: `edge_${edge16}`, exchange_id: `exchange:${cls}.${edge16}`, lambda: `lambda:exchange-${tenant}-${edge16}`, meter_row: `meter:exchange-${tenant}-${edge16}` };
33
+ }
34
+ /** The code a check task asks the seller to repeat: MB- and 8 hex characters of the edge and the run. */
35
+ export async function checkCode(edge16, run) {
36
+ return `MB-${(await sha256hex(`${edge16}|${run}`)).slice(0, 8).toUpperCase()}`;
37
+ }
38
+ const hostOf = (u) => { try {
39
+ return new URL(u).host.toLowerCase();
40
+ }
41
+ catch {
42
+ return '';
43
+ } };
44
+ /** An endpoint's identity across chains: host + path, lower case, no trailing slash. */
45
+ export const endpointKey = (u) => { try {
46
+ const x = new URL(u);
47
+ return `${x.host}${x.pathname}`.toLowerCase().replace(/\/+$/, '');
48
+ }
49
+ catch {
50
+ return String(u).toLowerCase();
51
+ } };
52
+ /** A worklist row as a seller, or why it cannot be one. */
53
+ export function sellerOfRow(r) {
54
+ const owner = String(r.owner ?? r.wallet ?? '');
55
+ const endpoint = String(r.endpoint ?? '');
56
+ const protocol = String(r.protocol ?? r.kind ?? '');
57
+ if (!isAddress(owner))
58
+ return { ok: false, why: 'no owner address on record' };
59
+ if (!/^https:\/\//.test(endpoint))
60
+ return { ok: false, why: 'no public https endpoint' };
61
+ if (protocol !== 'a2a' && protocol !== 'mcp')
62
+ return { ok: false, why: `tasks are not handed over in "${protocol || 'no protocol'}"` };
63
+ const chain_id = Number(r.chain_id);
64
+ const agent_id = String(r.agent_id ?? '');
65
+ if (!Number.isInteger(chain_id) || chain_id <= 0 || !/^\d{1,12}$/.test(agent_id))
66
+ return { ok: false, why: 'no agent id on a chain' };
67
+ return { ok: true, seller: { chain_id, agent_id, owner: owner.toLowerCase(), endpoint, protocol, name: typeof r.name === 'string' ? r.name.slice(0, 120) : null,
68
+ skills: Array.isArray(r.skills) ? r.skills.map(String).slice(0, 12) : [], host: hostOf(endpoint) } };
69
+ }
70
+ /** The check task: a short job the seller's card says it does, plus a code it must repeat. */
71
+ export function checkTask(s, code) {
72
+ const skill = (s.skills ?? []).find((k) => k.length >= 3) ?? 'your main skill';
73
+ return `Onboarding check for Moonbeam workflows. Begin your answer with the exact code ${code}. Then, in two or three sentences, say what your service does for "${skill.replace(/-/g, ' ')}" and give one concrete example of its output.`;
74
+ }
75
+ /** The MCP tool a check calls: one that takes a request in words, with at most one required input, a string. */
76
+ export function textTool(tools, task) {
77
+ const WORDS = /^(chat|ask|ask[_-].+|.+[_-]ask|query|prompt|message|question|assistant|ask[_-]?agent|ask[_-]sales[_-]agent|talk|converse|run[_-]?task|do[_-]?task|task)$/i;
78
+ const ARG = /^(message|prompt|query|question|text|input|task|request|content|q)$/i;
79
+ for (const t of tools ?? []) {
80
+ if (!WORDS.test(t.name) || /^(echo|ping|health)$/i.test(t.name))
81
+ continue;
82
+ const props = t.properties ?? {};
83
+ const req = t.required ?? [];
84
+ const strArgs = Object.entries(props).filter(([, v]) => !v?.type || v.type === 'string').map(([k]) => k);
85
+ if (req.length > 1)
86
+ continue;
87
+ const arg = req[0] ?? strArgs.find((k) => ARG.test(k)) ?? strArgs[0];
88
+ if (!arg || (props[arg]?.type && props[arg].type !== 'string'))
89
+ continue;
90
+ return { name: t.name, args: { [arg]: task } };
91
+ }
92
+ return null;
93
+ }
94
+ /** The words of an answer: an A2A message's text parts, an MCP result's text content, else the raw text. Never throws. */
95
+ export function answerText(head) {
96
+ try {
97
+ const j = JSON.parse(head);
98
+ const out = [];
99
+ const walk = (v, depth = 0) => {
100
+ if (depth > 6 || v == null)
101
+ return;
102
+ if (Array.isArray(v)) {
103
+ v.forEach((x) => walk(x, depth + 1));
104
+ return;
105
+ }
106
+ if (typeof v === 'object') {
107
+ const o = v;
108
+ if (typeof o.text === 'string')
109
+ out.push(o.text);
110
+ for (const k of ['parts', 'content', 'result', 'message', 'artifacts', 'status'])
111
+ if (k in o)
112
+ walk(o[k], depth + 1);
113
+ }
114
+ };
115
+ walk(j);
116
+ return out.length ? out.join('\n') : head;
117
+ }
118
+ catch {
119
+ return head;
120
+ }
121
+ }
122
+ const LIVENESS = /^(?:ok|ready|pong|ping|ack|received|accepted|alive|hello|hi)[.!]?$/i;
123
+ /**
124
+ * The rule an onboarding answer must pass (onboard.task-answer@1), after the delivery floor (generic@1): text that carries
125
+ * the task's code once the task itself is taken out, with work around it; not a liveness reply, not the task sent back.
126
+ */
127
+ export function onboardCheck(d, ask) {
128
+ const rules = [];
129
+ if (!d)
130
+ return { ok: false, rules, why: 'the task was not delivered' };
131
+ if (d.x402)
132
+ return { ok: false, rules, why: 'the seller asks for payment before answering; onboarding pays nothing' };
133
+ if (d.status !== 'ready')
134
+ return { ok: false, rules, why: `the seller did not answer (${d.status ?? 'no status'})` };
135
+ const floor = d.content_check;
136
+ if (!floor || floor.ok !== true)
137
+ return { ok: false, rules, why: `the answer fails the delivery floor${floor?.why ? `: ${floor.why}` : ''}` };
138
+ rules.push(floor.rule ?? 'generic@1');
139
+ if (!isHex32(d.reply_digest))
140
+ return { ok: false, rules, why: 'the answer has no digest to seal' };
141
+ const text = answerText(String(d.reply_head ?? ''));
142
+ if (!text.trim())
143
+ return { ok: false, rules, why: 'the answer holds no text' };
144
+ if (LIVENESS.test(text.trim()) || /"response"\s*:\s*"pong"/i.test(text) || (/\bpong\b/i.test(text) && text.length < 200))
145
+ return { ok: false, rules, why: 'a liveness reply ("pong"), not an answer to the task' };
146
+ const norm = (x) => x.replace(/\s+/g, ' ').trim().toLowerCase();
147
+ const code = ask.code.toLowerCase();
148
+ const echoed = norm(text).includes(norm(ask.task).slice(0, 60));
149
+ const rest = norm(text).split(norm(ask.task)).join(' ').split(`the exact code ${code}`).join(' ').split(`exact code ${code}`).join(' ');
150
+ if (!rest.includes(code))
151
+ return { ok: false, rules, why: echoed ? 'the answer sends the task back instead of answering it' : `the answer does not carry the task's code ${ask.code}` };
152
+ if (rest.split(code).join(' ').replace(/[^a-z0-9]+/g, ' ').trim().length < 40)
153
+ return { ok: false, rules, why: 'the answer is the code alone, with no work around it' };
154
+ rules.push('onboard.task-answer@1');
155
+ return { ok: true, rules, why: `a ${text.length}-character answer that carries ${ask.code}` };
156
+ }
157
+ // ── the agreement: one EIP-712 acceptance by the seller of record ────────────────────────────────────────────────────────
158
+ export const ACCEPTANCE_TYPES = Object.freeze({
159
+ Acceptance: Object.freeze([
160
+ { name: 'edge', type: 'string' }, { name: 'sellerOfRecord', type: 'address' }, { name: 'party', type: 'string' }, { name: 'product', type: 'string' },
161
+ { name: 'documents', type: 'string' }, { name: 'resells', type: 'string' }, { name: 'resellsOwner', type: 'address' },
162
+ ]),
163
+ });
164
+ /** The typed data a seller of record signs to accept the edge's agreement (TSUL-1.1 + TAT), naming the seller it resells. */
165
+ export function agreementTyped(p) {
166
+ if (!isAddress(p.sellerOfRecord) || !isAddress(p.seller.owner))
167
+ throw new Error('agreementTyped: the seller of record and the seller owner are addresses');
168
+ return {
169
+ domain: { name: AGREEMENT_DOMAIN, version: '1', chainId: p.chainId },
170
+ types: ACCEPTANCE_TYPES,
171
+ primaryType: 'Acceptance',
172
+ message: { edge: p.edgeId, sellerOfRecord: p.sellerOfRecord, party: 'onchain_seller', product: 'sell',
173
+ documents: AGREEMENT_DOCS.map((d) => `${d}@${AGREEMENT_VERSIONS[d]}`).join(','), resells: `${p.seller.chain_id}:${p.seller.agent_id}`, resellsOwner: p.seller.owner },
174
+ };
175
+ }
176
+ const cat = (...parts) => { const n = parts.reduce((a, x) => a + x.length, 0); const o = new Uint8Array(n); let i = 0; for (const x of parts) {
177
+ o.set(x, i);
178
+ i += x.length;
179
+ } return o; };
180
+ const kStr = (s) => keccak256(utf8(s));
181
+ const addr32 = (a) => { const o = new Uint8Array(32); const h = a.slice(2); for (let i = 0; i < 20; i++)
182
+ o[12 + i] = parseInt(h.slice(i * 2, i * 2 + 2), 16); return o; };
183
+ const u256 = (n) => { const o = new Uint8Array(32); let v = BigInt(n); for (let i = 31; i >= 0 && v > 0n; i--) {
184
+ o[i] = Number(v & 0xffn);
185
+ v >>= 8n;
186
+ } return o; };
187
+ /** The EIP-712 hash of an acceptance (what the seller of record signs), computed here byte for byte. */
188
+ export function agreementHash(t) {
189
+ const domainType = kStr('EIP712Domain(string name,string version,uint256 chainId)');
190
+ const domain = keccak256(cat(domainType, kStr(t.domain.name), kStr(t.domain.version), u256(t.domain.chainId)));
191
+ const typeStr = `Acceptance(${ACCEPTANCE_TYPES.Acceptance.map((f) => `${f.type} ${f.name}`).join(',')})`;
192
+ const m = t.message;
193
+ const struct = keccak256(cat(kStr(typeStr), kStr(m.edge), addr32(m.sellerOfRecord), kStr(m.party), kStr(m.product), kStr(m.documents), kStr(m.resells), addr32(m.resellsOwner)));
194
+ return bytesToHex(keccak256(cat(new Uint8Array([0x19, 0x01]), domain, struct)));
195
+ }
196
+ export const agreementId = (hash) => `agr_${hash.slice(2, 18)}`;
197
+ /** The body of `POST /exchanges/edge`. The API derives the ids again from it. */
198
+ export function edgeBody(p) {
199
+ return {
200
+ tenant: p.tenant ?? TENANT, chain_id: p.chainId, class: p.cls ?? EDGE_CLASS,
201
+ seller: { chain_id: p.seller.chain_id, agent_id: p.seller.agent_id, owner: p.seller.owner, endpoint: p.seller.endpoint, protocol: p.seller.protocol },
202
+ seller_of_record: p.sellerOfRecord,
203
+ check: { handshake_id: p.check.handshake_id, status: p.check.status, reply_digest: p.check.reply_digest, passed: p.check.passed, rules: [...p.check.rules] },
204
+ quote: { ...p.quote }, pool: { ...p.pool },
205
+ agreement: { docs: [...AGREEMENT_DOCS], party: 'onchain_seller', how: 'eip712', hash: p.agreement.hash, signature: p.agreement.signature, signer: p.sellerOfRecord },
206
+ state: p.state ?? 'live',
207
+ };
208
+ }
209
+ //# sourceMappingURL=edge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edge.js","sourceRoot":"","sources":["../../src/devnet/edge.ts"],"names":[],"mappings":"AAAA;;;;;;;;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,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QAC5J,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE;QAC1C,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,cAAc,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,cAAc,EAAE;QACpK,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,MAAM;KACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,403 @@
1
+ import type { Address, Hex, OnboardTransport, UnsignedCall } from '../onboard/index.js';
2
+ import { edgeBody } from './edge.js';
3
+ import type { AgreementTyped, CheckVerdict, EdgeBody, EdgeIds, EdgePool, EdgeQuote, McpTool, Seller } from './edge.js';
4
+ import type { DevnetProfile } from './profile.js';
5
+ export * from './profile.js';
6
+ export * from './edge.js';
7
+ /** One devnet GLMR job's price, in the token's 18 decimals: one test GLMR. */
8
+ export declare const DEVNET_JOB_PRICE: bigint;
9
+ /** The smallest pool backing an onboarding funds (ten test GLMR), the ./pools minimum deposit. */
10
+ export declare const DEVNET_POOL_BACKING: bigint;
11
+ /** An unsigned devnet call; the evaluator signs the ending of a graded job. */
12
+ export type DevnetCall = Omit<UnsignedCall, 'signer'> & {
13
+ signer: UnsignedCall['signer'] | 'evaluator';
14
+ };
15
+ /** Chains with value: a devnet profile never names one, and no call here is built for one. */
16
+ export declare const MAINNET_CHAIN_IDS: readonly number[];
17
+ /** Refuse a call aimed anywhere but the profile's chain, and any profile that names a chain with value. */
18
+ export declare function assertDevnet(p: Pick<DevnetProfile, 'chainId'>, chainId?: number): void;
19
+ export interface WorklistRow {
20
+ chain_id: number;
21
+ agent_id: string | number;
22
+ owner?: string;
23
+ wallet?: string;
24
+ endpoint?: string;
25
+ kind?: string;
26
+ protocol?: string;
27
+ name?: string;
28
+ skills?: string[];
29
+ stage?: string;
30
+ }
31
+ /**
32
+ * Find sellers ready to onboard: `GET /onboard/worklist` (stages first-job and list by default, paged), folded to sellers.
33
+ * `skip` takes edge ids or endpoint keys already onboarded; their sellers are left out.
34
+ */
35
+ export declare function findSellers(t: OnboardTransport, p: Pick<DevnetProfile, 'chainId'>, o?: {
36
+ stages?: string[];
37
+ limit?: number;
38
+ skip?: ReadonlySet<string>;
39
+ pages?: number;
40
+ }): Promise<{
41
+ sellers: (Seller & {
42
+ ids: EdgeIds;
43
+ })[];
44
+ skipped: {
45
+ key: string;
46
+ why: string;
47
+ }[];
48
+ read: number;
49
+ }>;
50
+ /** MCP initialize → tools/list at a seller's own endpoint (a read; nothing is called). Null when the list cannot be read. */
51
+ export declare function mcpTools(fetchFn: (url: string, init: {
52
+ method: string;
53
+ headers: Record<string, string>;
54
+ body: string;
55
+ signal?: AbortSignal;
56
+ }) => Promise<{
57
+ text(): Promise<string>;
58
+ headers: {
59
+ get(n: string): string | null;
60
+ };
61
+ }>, url: string): Promise<McpTool[] | null>;
62
+ export interface SellerCheck extends CheckVerdict {
63
+ passed: boolean;
64
+ handshake_id: string | null;
65
+ status: string;
66
+ reply_digest: Hex | null;
67
+ task: string;
68
+ code: string;
69
+ tool: string | null;
70
+ args: Record<string, string> | null;
71
+ protocol: string;
72
+ }
73
+ /**
74
+ * Check a seller: hand it a short task in its own protocol (`POST /handshake`, dispatch) and hold its answer to the
75
+ * onboarding rule. An MCP seller needs a tool that takes a request in words: pass its `tools` (see `mcpTools`).
76
+ */
77
+ export declare function checkSeller(t: OnboardTransport, s: Seller & {
78
+ ids?: EdgeIds;
79
+ }, o: {
80
+ chainId: number;
81
+ run: string | number;
82
+ tools?: readonly McpTool[] | null;
83
+ }): Promise<SellerCheck>;
84
+ export interface QuoteReply {
85
+ ok?: boolean;
86
+ line?: {
87
+ key?: string;
88
+ name?: string;
89
+ hook?: string;
90
+ factory?: string;
91
+ token?: string;
92
+ evaluator_adapter?: string;
93
+ } | null;
94
+ token?: {
95
+ symbol?: string;
96
+ address?: string;
97
+ } | null;
98
+ price?: string;
99
+ deposit?: string;
100
+ premium?: string | null;
101
+ premium_ratio?: number | null;
102
+ pool_id?: string | null;
103
+ pool_free?: string | null;
104
+ pool?: {
105
+ vault?: string;
106
+ free?: string;
107
+ total?: string;
108
+ encumbered?: string;
109
+ } | null;
110
+ why?: string[];
111
+ record?: {
112
+ n?: number;
113
+ settled?: number;
114
+ incorrect?: number;
115
+ } | null;
116
+ }
117
+ export interface EdgeTerms {
118
+ quote: EdgeQuote;
119
+ pool: {
120
+ vault: Address | null;
121
+ total: bigint;
122
+ free: bigint;
123
+ } | null;
124
+ why: string[];
125
+ raw: QuoteReply;
126
+ }
127
+ /** The edge's terms: `POST /pools/quote` (tenant moonbeam, settled through the layer). Nothing is reserved. */
128
+ export declare function quoteEdge(t: OnboardTransport, p: Pick<DevnetProfile, 'chainId'>, a: {
129
+ sellerOfRecord: Address;
130
+ price?: bigint;
131
+ }): Promise<EdgeTerms>;
132
+ /** The fold behind `quoteEdge`, exported for tests. */
133
+ export declare function termsOf(q: QuoteReply): EdgeTerms;
134
+ export interface PoolOpenPlan {
135
+ state: 'plan' | 'exists';
136
+ factory: Address;
137
+ pool: Address | null;
138
+ call: DevnetCall | null;
139
+ }
140
+ /** The pool behind the edge's seller of record: `POST /pools/open` on the profile's GLMR line. A plan to sign, or the pool that exists. */
141
+ export declare function openPoolPlan(t: OnboardTransport, p: Pick<DevnetProfile, 'chainId' | 'line'>, a: {
142
+ sellerOfRecord: Address;
143
+ edge16: string;
144
+ }): Promise<PoolOpenPlan>;
145
+ /** The pool a sent createPool made, read back through the API (`GET /pools/open/:chain/:tx`). `state` pending means retry. */
146
+ export declare function poolOpened(t: OnboardTransport, p: Pick<DevnetProfile, 'chainId'>, tx: Hex): Promise<{
147
+ state: string;
148
+ pool: Address | null;
149
+ retryAfter: number | null;
150
+ }>;
151
+ /** The agreement the seller of record signs (typed data) and its hash and id. */
152
+ export declare function edgeAgreement(p: Pick<DevnetProfile, 'chainId'>, a: {
153
+ edgeId: string;
154
+ sellerOfRecord: Address;
155
+ seller: Pick<Seller, 'chain_id' | 'agent_id' | 'owner'>;
156
+ }): {
157
+ typed: AgreementTyped;
158
+ hash: Hex;
159
+ id: string;
160
+ };
161
+ export interface ExchangeRow {
162
+ edge_id: string;
163
+ id: string;
164
+ tenant: string;
165
+ chain_id: number;
166
+ class: string;
167
+ state: string;
168
+ seller_of_record: string;
169
+ pool: {
170
+ address: string | null;
171
+ tx: string | null;
172
+ line: string;
173
+ state: string;
174
+ };
175
+ lambda: {
176
+ id: string;
177
+ vault: string;
178
+ acts: unknown[];
179
+ };
180
+ meter_row: {
181
+ id: string;
182
+ legs: string[];
183
+ };
184
+ agreement: {
185
+ id: string;
186
+ hash: string;
187
+ signer: string;
188
+ signature: string | null;
189
+ enforced?: boolean;
190
+ };
191
+ }
192
+ /** Store the edge: `POST /exchanges/edge` (idempotent on the edge id; a repeat answers created false). */
193
+ export declare function writeEdge(t: OnboardTransport, body: EdgeBody): Promise<{
194
+ created: boolean;
195
+ exchange: ExchangeRow;
196
+ }>;
197
+ /** Read one edge back: `GET /exchanges?id=`. Null when the API holds none. */
198
+ export declare function readEdge(t: OnboardTransport, edgeId: string): Promise<ExchangeRow | null>;
199
+ export { edgeBody };
200
+ export type { EdgeBody, EdgePool, EdgeQuote };
201
+ export declare const MINT_SIGNATURE = "mint(address,uint256)";
202
+ /**
203
+ * The faucet's test GLMR: the devnet token mints to anyone. One unsigned `mint(to, amount)` on the profile's token. Refused on
204
+ * any chain but the profile's (a mainnet GLMR cannot be minted, and this call is never built for one).
205
+ */
206
+ export declare function faucetMintCalls(p: Pick<DevnetProfile, 'chainId' | 'token'>, a: {
207
+ to: Address;
208
+ amount: bigint;
209
+ }): DevnetCall[];
210
+ /** Gas from the devnet faucet: `POST <faucet>/claim { address }`. The faucet URL comes from the profile (options or env). */
211
+ export declare function claimGas(p: Pick<DevnetProfile, 'faucet'>, address: Address, f: OnboardTransport['fetch']): Promise<{
212
+ ok: boolean;
213
+ status: number;
214
+ body: unknown;
215
+ }>;
216
+ /**
217
+ * The calls that back a pool: the API's plan (`POST /pools/vault`, deposit: an exact approve when the allowance is short,
218
+ * then deposit) — it reads the backer's balance and allowance first. When the API does not plan it, ./pools `depositCalls`
219
+ * builds the same two calls.
220
+ */
221
+ export declare function fundPoolPlan(t: OnboardTransport, p: Pick<DevnetProfile, 'chainId' | 'token'>, a: {
222
+ pool: Address;
223
+ from: Address;
224
+ assets: bigint;
225
+ }): Promise<{
226
+ calls: DevnetCall[];
227
+ short: {
228
+ needs: string;
229
+ has: string;
230
+ } | null;
231
+ source: 'layer' | 'sdk';
232
+ }>;
233
+ export interface SettlePlanCall {
234
+ action: string;
235
+ step?: string;
236
+ signer: string;
237
+ to: string;
238
+ data: string;
239
+ effect?: string;
240
+ }
241
+ export interface SettlePlan {
242
+ jobId: Hex;
243
+ ending: 'post-complete' | 'post-reject' | 'held';
244
+ hook: Address;
245
+ adapter: Address;
246
+ token: Address;
247
+ deposit: string;
248
+ price: string;
249
+ deadline: number;
250
+ calls: SettlePlanCall[];
251
+ held_reason?: unknown;
252
+ }
253
+ export interface HireAsk {
254
+ buyer: Address;
255
+ sellerOfRecord: Address;
256
+ price?: bigint;
257
+ evidence: Hex;
258
+ refId: string;
259
+ task: string;
260
+ specUri?: string;
261
+ deadline: number;
262
+ }
263
+ /** Who signs a plan's call: the buyer, the seller (of record) or the evaluator. */
264
+ export declare const signerOf: (s: string) => 'buyer' | 'seller' | 'evaluator' | null;
265
+ /** The phases of a plan's calls: the buyer's hire, the seller's acceptance, the delivery, and the evaluator's ending. */
266
+ export declare function phasesOf(plan: Pick<SettlePlan, 'calls'>, chainId: number): {
267
+ hire: DevnetCall[];
268
+ accept: DevnetCall[];
269
+ deliver: DevnetCall[];
270
+ settle: DevnetCall[];
271
+ };
272
+ /**
273
+ * Hire: the plan of one job on the profile's GLMR line, settled through the layer, with no verdict yet. Its calls are
274
+ * the buyer's approve and open (`hire`), the seller's deposit approve and accept (`accept`), and the delivery (`deliver`).
275
+ * The same ask later gives the same job id (the salt is the kind, the reference and the evidence).
276
+ */
277
+ export declare function hire(t: OnboardTransport, p: Pick<DevnetProfile, 'chainId'>, a: HireAsk): Promise<{
278
+ plan: SettlePlan;
279
+ hire: DevnetCall[];
280
+ accept: DevnetCall[];
281
+ deliver: DevnetCall[];
282
+ }>;
283
+ /** Deliver: the delivery call of a hire (the seller's submit with the answer's digest). */
284
+ export declare const deliver: (h: {
285
+ deliver: DevnetCall[];
286
+ }) => DevnetCall[];
287
+ export declare const BINARY_THRESHOLDS: Readonly<{
288
+ specMetAbove: number;
289
+ cheatShapedBelow: number;
290
+ }>;
291
+ export declare const BINARY_RULE_ID = "moonbeam.binary-verdict@1";
292
+ export interface Grade {
293
+ decided: 'complete' | 'reject';
294
+ by: 'grader' | 'rule';
295
+ raw_verdict: string | null;
296
+ spec_met: number | null;
297
+ cheat_shaped: number | null;
298
+ decision_id: string | null;
299
+ why: string;
300
+ rule_id: string;
301
+ }
302
+ /** spec_met and cheat_shaped P(yes) from a grade's scores or answers (an object by id, or a list of { id, … }). */
303
+ export declare function scoresOf(src: unknown): {
304
+ spec_met: number | null;
305
+ cheat_shaped: number | null;
306
+ };
307
+ /**
308
+ * A grade is binary: complete or reject. The grader's own complete or reject stands; any other grade completes when
309
+ * spec_met > THRESHOLDS_v1.rejectSpecMax and cheat_shaped < THRESHOLDS_v1.cheatShapedMin, and rejects otherwise. The raw
310
+ * verdict is kept beside the decision.
311
+ */
312
+ export declare function binaryVerdict(g: {
313
+ verdict?: string | null;
314
+ hard_fail?: boolean | null;
315
+ scores?: unknown;
316
+ answers?: unknown;
317
+ decision_id?: string | null;
318
+ } | null): Grade;
319
+ /** Where grades come from: a grading workflow of the Studio (its URL and token are the caller's, never shipped). */
320
+ export interface GradeEndpoint {
321
+ url: string;
322
+ token: string;
323
+ fetch?: OnboardTransport['fetch'];
324
+ }
325
+ /**
326
+ * Grade a delivery: the Studio's grade workflow over the dispatched answer (`{ handshake_id }`), recorded on the devnet.
327
+ * Returns the binary decision with the decision id the settle plan names.
328
+ */
329
+ export declare function grade(e: GradeEndpoint, a: {
330
+ handshake_id: string;
331
+ }): Promise<Grade>;
332
+ /** The recorded decision's digest (`GET /judge/decisions/:id`), which the evaluator posts with the verdict. */
333
+ export declare function decisionDigest(t: OnboardTransport, decisionId: string): Promise<Hex>;
334
+ /**
335
+ * Settle: the evaluator's ending for a graded job, from the same ask (same job id) plus the binary decision. Returns the
336
+ * evaluator's calls only; the hire, acceptance and delivery were sent before the grade.
337
+ */
338
+ export declare function settle(t: OnboardTransport, p: Pick<DevnetProfile, 'chainId'>, a: HireAsk, g: Grade & {
339
+ digest: Hex;
340
+ }): Promise<{
341
+ plan: SettlePlan;
342
+ settle: DevnetCall[];
343
+ }>;
344
+ export interface MeterLine {
345
+ id: string;
346
+ edge_id: string;
347
+ at: string;
348
+ class: string;
349
+ handshake_id: string | null;
350
+ status: string;
351
+ legs: Record<string, string>;
352
+ unit: string;
353
+ price?: string;
354
+ rule?: string;
355
+ }
356
+ export interface AgreementState {
357
+ edge_id: string;
358
+ id?: string;
359
+ enforced: boolean;
360
+ signed: boolean;
361
+ signature_valid: boolean;
362
+ recovered: string | null;
363
+ signer: string;
364
+ seller_of_record: string;
365
+ scope: {
366
+ tenant: string;
367
+ class: string;
368
+ chain_id: number;
369
+ };
370
+ state: string;
371
+ refusals?: number;
372
+ }
373
+ /**
374
+ * One call through the edge: `POST /exchanges/:edge_id/call { class, task }`. The layer enforces the edge's agreement (a call
375
+ * outside it is refused, `refused` names why) and writes one meter line per call it takes.
376
+ */
377
+ export declare function callEdge(t: OnboardTransport, edgeId: string, a: {
378
+ task: string;
379
+ class?: string;
380
+ tool?: string | null;
381
+ args?: Record<string, string> | null;
382
+ }): Promise<{
383
+ ok: true;
384
+ line: MeterLine;
385
+ reply_digest: string | null;
386
+ } | {
387
+ ok: false;
388
+ status: number;
389
+ code: string;
390
+ why: string;
391
+ pending?: true;
392
+ }>;
393
+ /** The edge's meter lines: `GET /exchanges/:edge_id/meter`. `pending` when the API does not route it yet. */
394
+ export declare function meterLines(t: OnboardTransport, edgeId: string): Promise<{
395
+ lines: MeterLine[];
396
+ pending: boolean;
397
+ }>;
398
+ /** The edge's agreement as the API enforces it: `GET /exchanges/:edge_id/agreement`. `pending` when not routed yet. */
399
+ export declare function agreementState(t: OnboardTransport, edgeId: string): Promise<{
400
+ state: AgreementState | null;
401
+ pending: boolean;
402
+ }>;
403
+ //# sourceMappingURL=index.d.ts.map