@moonbeam-foundation/sdk 0.11.0 → 0.13.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 (110) hide show
  1. package/README.md +79 -70
  2. package/bin/moonbeam.mjs +18 -1
  3. package/dist/actors/track-record.d.ts +1 -1
  4. package/dist/actors/track-record.js +1 -1
  5. package/dist/arbitration/index.d.ts +10 -4
  6. package/dist/arbitration/index.d.ts.map +1 -1
  7. package/dist/arbitration/index.js +14 -2
  8. package/dist/arbitration/index.js.map +1 -1
  9. package/dist/assurance/assurance-shared.d.ts +85 -132
  10. package/dist/assurance/assurance-shared.js +46 -90
  11. package/dist/cover/index.d.ts +3 -3
  12. package/dist/cover/index.d.ts.map +1 -1
  13. package/dist/devnet/index.d.ts +3 -3
  14. package/dist/devnet/index.d.ts.map +1 -1
  15. package/dist/devnet/index.js +4 -4
  16. package/dist/devnet/index.js.map +1 -1
  17. package/dist/devnet/profile.d.ts +1 -1
  18. package/dist/devnet/profile.d.ts.map +1 -1
  19. package/dist/erc8183/index.d.ts +1 -1
  20. package/dist/errors/index.d.ts +5 -5
  21. package/dist/errors/index.d.ts.map +1 -1
  22. package/dist/errors/index.js +3 -3
  23. package/dist/jobs/index.d.ts +4 -4
  24. package/dist/jobs/index.d.ts.map +1 -1
  25. package/dist/jobs/index.js +1 -1
  26. package/dist/jobs/index.js.map +1 -1
  27. package/dist/market/cohorts.d.ts +106 -0
  28. package/dist/market/cohorts.d.ts.map +1 -0
  29. package/dist/market/cohorts.js +70 -0
  30. package/dist/market/cohorts.js.map +1 -0
  31. package/dist/market/http.d.ts +13 -0
  32. package/dist/market/http.d.ts.map +1 -0
  33. package/dist/market/http.js +29 -0
  34. package/dist/market/http.js.map +1 -0
  35. package/dist/market/index.d.ts +43 -20
  36. package/dist/market/index.d.ts.map +1 -1
  37. package/dist/market/index.js +19 -36
  38. package/dist/market/index.js.map +1 -1
  39. package/dist/market/journey.d.ts +174 -0
  40. package/dist/market/journey.d.ts.map +1 -0
  41. package/dist/market/journey.js +179 -0
  42. package/dist/market/journey.js.map +1 -0
  43. package/dist/market/listed.d.ts +228 -0
  44. package/dist/market/listed.d.ts.map +1 -0
  45. package/dist/market/listed.js +168 -0
  46. package/dist/market/listed.js.map +1 -0
  47. package/dist/market/sale-stops.d.ts +29 -0
  48. package/dist/market/sale-stops.d.ts.map +1 -0
  49. package/dist/market/sale-stops.js +29 -0
  50. package/dist/market/sale-stops.js.map +1 -0
  51. package/dist/market/sale.d.ts +98 -0
  52. package/dist/market/sale.d.ts.map +1 -0
  53. package/dist/market/sale.js +64 -0
  54. package/dist/market/sale.js.map +1 -0
  55. package/dist/market/venues-data.d.ts +3 -0
  56. package/dist/market/venues-data.d.ts.map +1 -0
  57. package/dist/market/venues-data.js +1035 -0
  58. package/dist/market/venues-data.js.map +1 -0
  59. package/dist/market/venues.d.ts +143 -0
  60. package/dist/market/venues.d.ts.map +1 -0
  61. package/dist/market/venues.js +123 -0
  62. package/dist/market/venues.js.map +1 -0
  63. package/dist/onboard/index.d.ts +214 -33
  64. package/dist/onboard/index.d.ts.map +1 -1
  65. package/dist/onboard/index.js +340 -31
  66. package/dist/onboard/index.js.map +1 -1
  67. package/dist/onboard/send.d.ts +43 -0
  68. package/dist/onboard/send.d.ts.map +1 -0
  69. package/dist/onboard/send.js +65 -0
  70. package/dist/onboard/send.js.map +1 -0
  71. package/dist/pools/index.d.ts +18 -7
  72. package/dist/pools/index.d.ts.map +1 -1
  73. package/dist/pools/index.js +31 -9
  74. package/dist/pools/index.js.map +1 -1
  75. package/dist/proof/index.d.ts +5 -5
  76. package/dist/proof/index.d.ts.map +1 -1
  77. package/dist/proof/index.js +1 -1
  78. package/dist/resale/index.d.ts +13 -13
  79. package/dist/resale/index.d.ts.map +1 -1
  80. package/dist/resale/index.js +17 -17
  81. package/dist/resale/index.js.map +1 -1
  82. package/dist/resale/payment-scheme.d.mts +2 -5
  83. package/dist/resale/payment-scheme.mjs +16 -116
  84. package/dist/resale/payment-scheme.pin.json +1 -2
  85. package/dist/resale/settle-rule.d.ts +3 -3
  86. package/dist/resale/settle-rule.d.ts.map +1 -1
  87. package/dist/resale/settle-rule.js +3 -3
  88. package/dist/resale/settle-rule.js.map +1 -1
  89. package/dist/rpc/index.js +1 -1
  90. package/dist/workflows/index.js +1 -1
  91. package/dist/workflows/steps.d.ts +4 -4
  92. package/dist/workflows/steps.d.ts.map +1 -1
  93. package/dist/workflows/steps.js +4 -4
  94. package/dist/workflows/steps.js.map +1 -1
  95. package/dist/workflows/types.d.ts +1 -1
  96. package/dist/x402/index.d.ts +2 -2
  97. package/dist/x402/index.d.ts.map +1 -1
  98. package/dist/x402/index.js +2 -2
  99. package/dist/x402/index.js.map +1 -1
  100. package/docs/REFERENCE.md +52 -19
  101. package/docs/VENUES.md +209 -0
  102. package/docs/WORKFLOWS.md +3 -3
  103. package/examples/24-resell-on-base.mjs +1 -1
  104. package/examples/51-read-a-proof.mjs +2 -2
  105. package/examples/70-every-venue.mjs +19 -0
  106. package/examples/README.md +2 -1
  107. package/examples/data/cross-list.recorded.json +1 -1
  108. package/package.json +7 -3
  109. package/dist/assurance/assurance-shared.d.ts.map +0 -1
  110. package/dist/assurance/assurance-shared.js.map +0 -1
@@ -0,0 +1,179 @@
1
+ import { jsonOf } from '../errors/index.js';
2
+ import { MarketError, call, needKey, query, seg } from './http.js';
3
+ import { jobCalls, publishListing, readListing } from './index.js';
4
+ // ── list ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
5
+ /** The markets the list step lists on: the agent's ERC-8004 record on Base, the official MCP Registry and the A2A Registry. */
6
+ export const LIST_MARKETS = Object.freeze(['erc8004', 'mcp_registry', 'a2a_registry']);
7
+ const AGENT_REF = /^8453:\d{1,12}$/;
8
+ const agentRef = (ref) => { const r = String(ref ?? '').trim(); if (!AGENT_REF.test(r))
9
+ throw new RangeError(`an agent is 8453:<its ERC-8004 id>: ${ref}`); return r; };
10
+ const listOf = (j, what) => {
11
+ if (!j.list || typeof j.list.id !== 'string' || !j.list.markets)
12
+ throw new MarketError(502, what, j);
13
+ return j.list;
14
+ };
15
+ /** The list step's id of an agent, derived the way Moonbeam derives it: `lst_` + the first 16 hex of sha256("list:<ref>"). */
16
+ export async function listIdOf(ref) {
17
+ const d = await globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(`list:${agentRef(ref)}`));
18
+ return `lst_${[...new Uint8Array(d)].map((b) => b.toString(16).padStart(2, '0')).join('').slice(0, 16)}`;
19
+ }
20
+ /**
21
+ * List an agent on the markets where agents are found (`POST /list`): its ERC-8004 record on Base, the MCP Registry and the
22
+ * A2A Registry, all three unless named. Runs on a plan key and is part of the plan (no per-listing price is set). Moonbeam serves the agent's MCP door and A2A
23
+ * card and publishes each market; asking again returns the same record, read anew. `ref` is the agent's ERC-8004 id on Base,
24
+ * whose card names the class it sells.
25
+ */
26
+ export async function listOn(t, ref, markets = LIST_MARKETS) {
27
+ const agent = agentRef(ref);
28
+ const bad = markets.filter((m) => !LIST_MARKETS.includes(m));
29
+ if (!markets.length || bad.length)
30
+ throw new RangeError(`the list step lists on ${LIST_MARKETS.join(', ')}${bad.length ? `, not ${bad.join(', ')}` : ''}`);
31
+ needKey(t, 'POST /list');
32
+ return listOf(await call(t, 'POST', '/list', { agent, markets: [...new Set(markets)] }), 'POST /list');
33
+ }
34
+ /** Where an agent stands on each of the three markets (`GET /list/:id`), or null when it was never listed. Public. */
35
+ export async function listStatus(t, ref) {
36
+ const id = await listIdOf(ref);
37
+ try {
38
+ return listOf(await call(t, 'GET', `/list/${seg(id)}`), 'GET /list/:id');
39
+ }
40
+ catch (e) {
41
+ if (e instanceof MarketError && e.status === 404)
42
+ return null;
43
+ throw e;
44
+ }
45
+ }
46
+ // ── manage ────────────────────────────────────────────────────────────────────────────────────────────────────────────
47
+ const AL = /^al_[0-9a-f]{16}$/;
48
+ const alId = (id) => { if (!AL.test(id))
49
+ throw new RangeError(`not an agent listing id (al_ and 16 hex): ${id}`); return id; };
50
+ const statusTo = async (t, id, status) => {
51
+ needKey(t, 'POST /agent-listings/:id');
52
+ const j = await call(t, 'POST', `/agent-listings/${alId(id)}`, { status });
53
+ if (!j.listing || typeof j.listing.id !== 'string')
54
+ throw new MarketError(502, 'POST /agent-listings/:id', j);
55
+ return { listing: j.listing, body: j };
56
+ };
57
+ /** Pause a live listing (`POST /agent-listings/:id { status: paused }`): it is not sold until it goes live again. On its owner's key. */
58
+ export const pauseListing = (t, id) => statusTo(t, id, 'paused');
59
+ /** Go live again (`POST /agent-listings/:id/publish`): one graded task per job, each job it passes is sold again. On its owner's key. */
60
+ export const resumeListing = (t, id) => publishListing(t, id);
61
+ /** Delist for good (`POST /agent-listings/:id { status: archived }`): kept for the record, never sold again. `confirm` must repeat the id. */
62
+ export async function delistListing(t, id, o) {
63
+ if (o?.confirm !== id)
64
+ throw new RangeError('delisting is for good: pass { confirm: <the listing id> }');
65
+ return statusTo(t, id, 'archived');
66
+ }
67
+ // ── register on ERC-8004 ──────────────────────────────────────────────────────────────────────────────────────────────
68
+ /** Moonbeam's register-8004 builder takes an agentURI of at most this many characters. */
69
+ export const MAX_INLINE_URI = 2048;
70
+ const base64 = (s) => { let b = ''; for (const c of new TextEncoder().encode(s))
71
+ b += String.fromCharCode(c); return btoa(b); };
72
+ /** A listing's registration file as an inline `data:` URI (nothing is hosted), or why it cannot be. Pure. */
73
+ export function inlineRegistration(x) {
74
+ if (!x || !x.registration)
75
+ return { ok: false, why: 'the listing carries no registration file' };
76
+ if (!x.exportable)
77
+ return { ok: false, why: (x.why ?? []).join('; ') || 'this listing has no registration file yet' };
78
+ const uri = `data:application/json;base64,${base64(JSON.stringify(x.registration))}`;
79
+ if (uri.length > MAX_INLINE_URI)
80
+ return { ok: false, why: `its file is ${uri.length} characters inline, over ${MAX_INLINE_URI}: shorten its description, or host the file at an https URL and register that` };
81
+ return { ok: true, uri, file: x.registration };
82
+ }
83
+ /**
84
+ * Your agent's own ERC-8004 id on Base, as unsigned calls: the listing's registration file (`export.erc8004` of
85
+ * `GET /agent-listings/:id`) inlined as a data: URI, and `register(agentURI)` built by Moonbeam (`POST /assurance/call`).
86
+ * Your wallet signs and owns the id; the receipt's `Registered` event names it. Nothing is signed or sent here.
87
+ */
88
+ export async function register8004Calls(t, listingId) {
89
+ const view = await readListing(t, listingId);
90
+ const x = view.export?.erc8004;
91
+ const f = inlineRegistration(x);
92
+ if (!f.ok)
93
+ throw new MarketError(422, 'register8004Calls', { ok: false, code: 'not_registrable', error: f.why });
94
+ const { calls } = await jobCalls(t, { chainId: 8453, action: { kind: 'register-8004', agentURI: f.uri } });
95
+ const reg = calls.filter((c) => c.action === undefined || c.action === 'register-8004');
96
+ if (!reg.length || !reg.every((c) => /^0x[0-9a-fA-F]{40}$/.test(String(c.to ?? '')) && /^0x[0-9a-fA-F]+$/.test(String(c.data ?? ''))))
97
+ throw new MarketError(502, 'POST /assurance/call', { ok: false, code: 'no_call', error: 'the register call could not be built' });
98
+ return { uri: f.uri, file: f.file, calls: reg, signer: 'your wallet: the account that will own the agent\'s ERC-8004 id', sent: false };
99
+ }
100
+ // ── measure ───────────────────────────────────────────────────────────────────────────────────────────────────────────
101
+ /** What your key (or your whole tenant) used over a window (`GET /access/usage`): calls and spend per product family, by day and by key. Keyed. */
102
+ export async function usage(t, o = {}) {
103
+ needKey(t, 'GET /access/usage');
104
+ const window = o.window ?? 'month';
105
+ const scope = o.scope ?? 'tenant';
106
+ const j = await call(t, 'GET', `/access/usage${query({ window, scope })}`);
107
+ return { window: j.window ?? window, scope: j.scope ?? scope, families: j.families ?? {}, total: j.total ?? null, byDay: j.by_day ?? [], keys: j.keys ?? [], body: j };
108
+ }
109
+ /** Your tenant's keys and the recent changes to them (`GET /tenant/keys`): who created, rotated or revoked a key, and when. Keyed. */
110
+ export async function tenantKeys(t) {
111
+ needKey(t, 'GET /tenant/keys');
112
+ const j = await call(t, 'GET', '/tenant/keys');
113
+ return { keys: j.keys ?? [], recentChanges: j.recent_changes ?? [], body: j };
114
+ }
115
+ /**
116
+ * The plans and the top-up, as Moonbeam's own 402 answer names them (`POST /access/subscribe` with no key and no payment):
117
+ * nothing is minted and nothing is paid. Buying one is the same POST with a payment, from your wallet.
118
+ */
119
+ export async function planOffers(t) {
120
+ const what = 'POST /access/subscribe';
121
+ // no key and no create_key: Moonbeam answers its terms with 402 and mints nothing
122
+ const r = await t.fetch(`${t.base}/access/subscribe`, { method: 'POST', headers: { accept: 'application/json', 'content-type': 'application/json' }, body: '{}' });
123
+ const j = (await jsonOf(r));
124
+ if (r.status !== 402 || !j || j.code !== 'payment_required')
125
+ throw new MarketError(r.status === 402 ? 502 : r.status, what, j);
126
+ const plans = (j.monthly?.plans ?? []).filter((p) => typeof p.plan === 'string' && typeof p.usdc === 'number')
127
+ .map((p) => ({ plan: p.plan, usdc: p.usdc, includes_usdc: p.includes_usdc ?? null, per_minute: p.per_minute ?? null, days: p.days ?? 30 }));
128
+ const o = j.offer;
129
+ return { topup: o && typeof o.usdc === 'number' ? { usdc: o.usdc, units: String(o.units ?? ''), what: o.what ?? null } : null, plans,
130
+ networks: [...new Set((j.accepts ?? []).map((a) => a.network).filter((n) => typeof n === 'string'))] };
131
+ }
132
+ const OWN_HOST = /taifoon|n8n|genie/i;
133
+ const OURS = 'ours';
134
+ const keyOfRef = (ref) => {
135
+ const r = String(ref ?? '').trim().toLowerCase();
136
+ if (/^(class|seller):[a-z0-9._-]{2,253}$/.test(r))
137
+ return r;
138
+ if (/^[a-z0-9_]+(\.[a-z0-9_]+){1,3}$/.test(r))
139
+ return `class:${r}`;
140
+ try {
141
+ const h = new URL(r).hostname;
142
+ if (h)
143
+ return `seller:${h}`;
144
+ }
145
+ catch { /* not a URL */ }
146
+ throw new RangeError(`an agent's sales are read by its class (mcp.digest), class:<class>, seller:<host> or its endpoint URL: ${ref}`);
147
+ };
148
+ /**
149
+ * What an agent sold, as the sale run counts it: the slice of its class wall or of its seller host, every sale by day and buying
150
+ * market, and where each seller share stands (paid, kept, held, owed, refunded). The sale run is a published file: pass its URL
151
+ * as `salesUrl` or set MOONBEAM_SALES_URL (it comes with your key). The operator's own seller hosts are said as `ours`.
152
+ * null when the agent has no sale.
153
+ */
154
+ export async function agentSales(t, ref, o = {}) {
155
+ const key = keyOfRef(ref);
156
+ const url = (o.salesUrl ?? (typeof process !== 'undefined' ? process.env?.['MOONBEAM_SALES_URL'] : undefined) ?? '').trim();
157
+ if (!/^https:\/\//.test(url))
158
+ throw new RangeError('agentSales reads the sale run: pass { salesUrl } or set MOONBEAM_SALES_URL (https)');
159
+ const r = await t.fetch(url, { method: 'GET', headers: { accept: 'application/json' } });
160
+ const j = (await jsonOf(r));
161
+ const b = j?.by_agent;
162
+ if (!r.ok || !b || b.rule !== 'SALE_SLICES_v1' || !Array.isArray(b.slices))
163
+ throw new MarketError(r.ok ? 502 : r.status, 'GET sale run', j);
164
+ const scrub = (s) => ({ ...s, key: s.kind === 'seller' && OWN_HOST.test(s.key) ? `seller:${OURS}` : s.key, recent: (s.recent ?? []).map((x) => (x.seller && OWN_HOST.test(x.seller) ? { ...x, seller: OURS } : x)) });
165
+ const slice = b.slices.map(scrub).find((s) => s.key === key) ?? null;
166
+ if (!slice || !slice.sales)
167
+ return null;
168
+ return { slice, days: (b.days ?? []).filter((d) => typeof d === 'string'), readAt: j?.generated_at ?? new Date().toISOString() };
169
+ }
170
+ // ── a venue's own job ─────────────────────────────────────────────────────────────────────────────────────────────────
171
+ /** One Olas Mech request on Base as its evidence reads (`GET /judge/evidence/olas/:requestId`, the marketplace's 32-byte request id):
172
+ * the prompt, tool, mech, fee and response, its request and delivery transactions, and the grade call to make. Public. */
173
+ export async function olasRequest(t, requestId) {
174
+ const id = String(requestId ?? '').trim();
175
+ if (!/^0x[0-9a-fA-F]{64}$/.test(id))
176
+ throw new RangeError(`an Olas request id is 0x and 64 hex: ${requestId}`);
177
+ return call(t, 'GET', `/judge/evidence/olas/${seg(id)}`);
178
+ }
179
+ //# sourceMappingURL=journey.js.map
@@ -0,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AC;IACxC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,YAAY,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;AAChJ,CAAC;AAED,yHAAyH;AAEzH;2HAC2H;AAC3H,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,CAAmB,EAAE,SAAiB;IACtE,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1C,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,wCAAwC,SAAS,EAAE,CAAC,CAAC;IAC/G,OAAO,IAAI,CAA0B,CAAC,EAAE,KAAK,EAAE,wBAAwB,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACpF,CAAC"}
@@ -0,0 +1,228 @@
1
+ import type { OnboardTransport } from '../onboard/index.js';
2
+ import { type VenueId } from './venues.js';
3
+ export declare const JOURNEY_SCHEMA = "listed.journey.v1";
4
+ /** The five LEDs of an agent on a venue: its offer is up, a buyer can hire it, it is listed, the listing reads back, it was paid. */
5
+ export declare const JOURNEY_LEDS: readonly ["offer", "hire", "list", "read_back", "paid"];
6
+ export type JourneyLed = (typeof JOURNEY_LEDS)[number];
7
+ /** An LED's state. `unread`: the read behind it did not answer, so it is neither on nor off. */
8
+ export type LedState = 'on' | 'partial' | 'off' | 'unread';
9
+ /** Where the agent stands on a venue. */
10
+ export type JourneyStanding = 'listed_by_owner' | 'listed_by_moonbeam' | 'listable' | 'not_yet' | 'closed' | 'unread';
11
+ /** The next step's kind. */
12
+ export type JourneyAct = 'list' | 'probe' | 'hire' | 'paid' | 'improve' | 'reread' | 'identity' | 'none';
13
+ /** One read behind an LED: its kind, what it read, and when. */
14
+ export type JourneyEvidence = {
15
+ kind: string;
16
+ ref: string;
17
+ read_at: string | null;
18
+ };
19
+ /** One LED: its state, one plain line on why, the reads that lit it (an LED is on only with one), and what would move it. */
20
+ export type JourneyLight = {
21
+ state: LedState;
22
+ why: string;
23
+ evidence: JourneyEvidence[];
24
+ moves_when: string;
25
+ };
26
+ /** The numbered steps a person takes on a venue, only where no machine path exists; the last step is the venue's own URL. */
27
+ export type JourneyHuman = {
28
+ where: string;
29
+ steps: string[];
30
+ url: string;
31
+ why: string;
32
+ };
33
+ export type JourneyPrefill = {
34
+ ref: string;
35
+ class: string | null;
36
+ resource: string | null;
37
+ venue: string;
38
+ step: string;
39
+ };
40
+ /** The one next step: in the Studio, by the machine, by a person (with numbered steps), or none. */
41
+ export type JourneyNext = {
42
+ by: 'studio' | 'genie' | 'human' | 'none';
43
+ act: JourneyAct;
44
+ studio?: {
45
+ step: string;
46
+ chat?: string;
47
+ label: string;
48
+ prefill: JourneyPrefill;
49
+ };
50
+ genie?: {
51
+ op: string;
52
+ prefill: JourneyPrefill;
53
+ };
54
+ human?: JourneyHuman;
55
+ why: string;
56
+ };
57
+ /** The agent on one venue. `agent_paid_7d` is the agent's own money there; `market` is everyone's money on that venue. */
58
+ export type JourneyVenue = {
59
+ [k: string]: unknown;
60
+ venue_id: VenueId;
61
+ venue: string;
62
+ mark: string;
63
+ leds: Record<JourneyLed, JourneyLight>;
64
+ standing: JourneyStanding;
65
+ proof?: {
66
+ kind: string;
67
+ url: string | null;
68
+ ref?: string;
69
+ read_at: string | null;
70
+ };
71
+ agent_paid_7d?: {
72
+ usd: number | null;
73
+ buyers: number | null;
74
+ jobs?: number | null;
75
+ window: '7d';
76
+ from: 'board_row' | 'seller_profile';
77
+ read_at: string | null;
78
+ };
79
+ market?: {
80
+ usd_7d: number | null;
81
+ payments_7d: number | null;
82
+ buyers_7d: number | null;
83
+ sellers: number | null;
84
+ class_usd_7d?: number;
85
+ from: 'venue_sides';
86
+ read_at: string | null;
87
+ };
88
+ next: JourneyNext;
89
+ why: string;
90
+ flags?: string[];
91
+ };
92
+ /** listed.journey.v1, with the venues keyed by id: every venue of `VENUE_IDS` is there, or the read is refused. */
93
+ export type Journey = {
94
+ schema: typeof JOURNEY_SCHEMA;
95
+ agent: {
96
+ ref: string;
97
+ name: string;
98
+ kind: 'outside' | 'house';
99
+ class: string | null;
100
+ host?: string;
101
+ page?: {
102
+ state: string;
103
+ read_at: string | null;
104
+ };
105
+ };
106
+ read_at: string;
107
+ headline: {
108
+ text: string | null;
109
+ from: '402' | 'class' | 'unread';
110
+ resource: string | null;
111
+ class: string | null;
112
+ class_mismatch: string[] | 'unread';
113
+ };
114
+ /** the class probe and the grade after it; no grade is on before the probe */
115
+ checks: Record<'probe' | 'grade', JourneyLight>;
116
+ venues: Record<VenueId, JourneyVenue>;
117
+ /** the reads the answer was made from, each ok, unread or kept (the last good read stands) */
118
+ reads: {
119
+ kind: string;
120
+ state: 'ok' | 'unread' | 'kept';
121
+ read_at: string | null;
122
+ why?: string;
123
+ }[];
124
+ /** what could not be read, in words */
125
+ unread: string[];
126
+ /** venue ids the answer holds that this SDK does not know yet (their rows stay in `body`) */
127
+ extra: string[];
128
+ body: Record<string, unknown>;
129
+ };
130
+ /**
131
+ * One agent on every venue (`GET /listed?agent=<ref>&view=journey`): where it stands, its five LEDs with why, evidence and
132
+ * what would move each, and the one next step (a Studio step, a machine step, or a person's numbered steps where no machine
133
+ * path exists). Public. A ref is `8453:<ERC-8004 id>`, `erc8004:<chain>:<id>`, or a board row (`x402:<12 hex>`, `x402:host:<host>`,
134
+ * `virtuals:`, `bitagent:`, `near:`, `olas:` + 12 hex).
135
+ */
136
+ export declare function journey(t: OnboardTransport, ref: string): Promise<Journey>;
137
+ /** A listed.journey.v1 body as the typed answer, its venues keyed by id. Pure; throws a MarketError when the body breaks the schema. */
138
+ export declare function journeyOf(j: Record<string, unknown>, what?: string): Journey;
139
+ export declare const LIST_SCHEMA = "genie.list.virtuals.v1";
140
+ /** The venues `list` plans a listing on: Virtuals ACP. Every other venue's next step is in `journey(t, ref).venues[id].next`. */
141
+ export declare const LIST_VENUES: readonly ["erc8183-base"];
142
+ export type ListVenue = (typeof LIST_VENUES)[number];
143
+ /** The steps of a Virtuals ACP listing, in the order the Studio's list step runs them. */
144
+ export declare const LIST_STEPS: readonly ["agent", "signer", "register", "seller", "offerings", "readback"];
145
+ export type ListStepId = (typeof LIST_STEPS)[number];
146
+ /** A step's state. `waiting_approval` appears only in the Studio's run, with the approval's link. */
147
+ export type ListStepState = 'done' | 'running' | 'waiting' | 'waiting_approval' | 'refused' | 'skipped';
148
+ /** Whose move a step is. */
149
+ export type ListWho = 'machine' | 'owner' | 'builder';
150
+ export type ListStep = {
151
+ step: ListStepId;
152
+ state: ListStepState;
153
+ who: ListWho;
154
+ read_at: string;
155
+ evidence: {
156
+ kind: string;
157
+ ref?: string;
158
+ url?: string;
159
+ why?: string;
160
+ };
161
+ };
162
+ export type ListOffering = {
163
+ name: string;
164
+ priceUsdc: number | null;
165
+ shown: boolean;
166
+ held?: string;
167
+ };
168
+ /** The one thing a person does, for whoever holds the venue account. `url` is null until the Studio's run asks the venue for the link. */
169
+ export type ListHuman = {
170
+ kind: 'approval';
171
+ for: 'owner' | 'builder';
172
+ url: string | null;
173
+ page: string;
174
+ expires_at: string | null;
175
+ chat: string;
176
+ };
177
+ /** genie.list.virtuals.v1: the listing as it stands, step by step. */
178
+ export type ListPlan = {
179
+ schema: typeof LIST_SCHEMA;
180
+ ref: string;
181
+ venue: ListVenue;
182
+ /** whose Virtuals account the agent is in: Moonbeam's own, or a builder's */
183
+ account: 'house:moonbeam' | 'builder';
184
+ agent: {
185
+ id: string;
186
+ name: string | null;
187
+ page: string;
188
+ chains: {
189
+ chainId: number;
190
+ erc8004AgentId: number | null;
191
+ }[];
192
+ };
193
+ erc8004AgentId: number | null;
194
+ steps: ListStep[];
195
+ offerings: ListOffering[];
196
+ human: ListHuman | null;
197
+ done: boolean;
198
+ };
199
+ /** What a run would set: the agent's name and description, and per offering (by name) its description and price. */
200
+ export type ListCustom = {
201
+ name?: string;
202
+ description?: string;
203
+ offerings?: {
204
+ name: string;
205
+ description?: string;
206
+ priceUsdc?: number;
207
+ }[];
208
+ };
209
+ /** Moonbeam's own agent on Virtuals ACP. Any other agent id is read as a builder's, in its own account. */
210
+ export declare const HOUSE_AGENTS: Readonly<Record<'moonbeam', string>>;
211
+ /**
212
+ * The listing of an agent on a venue, step by step as it stands now (genie.list.virtuals.v1). Read and plan only: the SDK never
213
+ * asks for a signer, registers, shows an offering or approves anything, and never moves money. The Moonbeam Studio's list step
214
+ * runs the steps; `human` names the one approval a person gives there (the venue account's holder: the owner for Moonbeam's own
215
+ * agent, the builder for theirs), and is returned, never acted on.
216
+ *
217
+ * `agent` is `moonbeam` (Moonbeam's own Virtuals agent) or a Virtuals agent id. `custom` is what the run would set: the agent's
218
+ * name and description, and per offering its description and price; the plan shows those offerings and says what would change.
219
+ * The venue's own public record is read through the transport's fetch (`o.api`, default https://api.acp.virtuals.io).
220
+ */
221
+ export declare function list(t: OnboardTransport, o: {
222
+ venue: ListVenue;
223
+ agent: string;
224
+ custom?: ListCustom;
225
+ now?: () => string;
226
+ api?: string;
227
+ }): Promise<ListPlan>;
228
+ //# sourceMappingURL=listed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listed.d.ts","sourceRoot":"","sources":["../../src/market/listed.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAItD,eAAO,MAAM,cAAc,sBAAsB,CAAC;AAClD,qIAAqI;AACrI,eAAO,MAAM,YAAY,yDAAyE,CAAC;AACnG,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AACvD,gGAAgG;AAChG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CAAC;AACF,oHAAoH;AACpH,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAAC;AAE3I,2GAA2G;AAC3G,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAuE,CAAC;AAmFtI;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAUhK"}
@@ -0,0 +1,168 @@
1
+ import { jsonOf } from '../errors/index.js';
2
+ import { MarketError, call, query } from './http.js';
3
+ import { VENUE_IDS } from './venues.js';
4
+ // ── journey ───────────────────────────────────────────────────────────────────────────────────────────────────────────
5
+ export const JOURNEY_SCHEMA = 'listed.journey.v1';
6
+ /** The five LEDs of an agent on a venue: its offer is up, a buyer can hire it, it is listed, the listing reads back, it was paid. */
7
+ export const JOURNEY_LEDS = Object.freeze(['offer', 'hire', 'list', 'read_back', 'paid']);
8
+ /** The refs a journey takes: an agent's ERC-8004 id (`8453:<id>` or `erc8004:<chain>:<id>`), or its row on a market's board. */
9
+ const JOURNEY_REF = /^(?:(?:x402|virtuals|bitagent|near|olas):[0-9a-f]{12}|x402:host:[a-z0-9.-]{3,253}|(?:erc8004:)?\d{1,10}:\d{1,12})$/;
10
+ /**
11
+ * One agent on every venue (`GET /listed?agent=<ref>&view=journey`): where it stands, its five LEDs with why, evidence and
12
+ * what would move each, and the one next step (a Studio step, a machine step, or a person's numbered steps where no machine
13
+ * path exists). Public. A ref is `8453:<ERC-8004 id>`, `erc8004:<chain>:<id>`, or a board row (`x402:<12 hex>`, `x402:host:<host>`,
14
+ * `virtuals:`, `bitagent:`, `near:`, `olas:` + 12 hex).
15
+ */
16
+ export async function journey(t, ref) {
17
+ const r = String(ref ?? '').trim();
18
+ if (!JOURNEY_REF.test(r))
19
+ throw new RangeError(`not an agent ref: ${ref} (8453:<id>, erc8004:<chain>:<id>, x402:<12 hex>, x402:host:<host>, or virtuals: / bitagent: / near: / olas: + 12 hex)`);
20
+ const what = 'GET /listed?view=journey';
21
+ const j = await call(t, 'GET', `/listed${query({ agent: r, view: 'journey' })}`);
22
+ return journeyOf(j, what);
23
+ }
24
+ /** A listed.journey.v1 body as the typed answer, its venues keyed by id. Pure; throws a MarketError when the body breaks the schema. */
25
+ export function journeyOf(j, what = 'listed.journey.v1') {
26
+ const rows = j['venues'];
27
+ if (j['schema'] !== JOURNEY_SCHEMA || !Array.isArray(rows) || !j['agent'] || !j['checks'])
28
+ throw new MarketError(502, what, { ok: false, code: 'bad_answer', error: `${what} did not answer ${JOURNEY_SCHEMA}` });
29
+ const by = new Map(rows.map((v) => [v.venue_id, v]));
30
+ const missing = VENUE_IDS.filter((id) => !by.has(id) || !by.get(id)?.leds);
31
+ if (missing.length)
32
+ throw new MarketError(502, what, { ok: false, code: 'bad_answer', error: `${what} has no row for ${missing.join(', ')}` });
33
+ const venues = Object.fromEntries(VENUE_IDS.map((id) => [id, by.get(id)]));
34
+ return {
35
+ schema: JOURNEY_SCHEMA,
36
+ agent: j['agent'],
37
+ read_at: String(j['read_at'] ?? ''),
38
+ headline: j['headline'],
39
+ checks: j['checks'],
40
+ venues,
41
+ reads: Array.isArray(j['reads']) ? j['reads'] : [],
42
+ unread: Array.isArray(j['unread']) ? j['unread'] : [],
43
+ extra: [...by.keys()].filter((id) => !VENUE_IDS.includes(id)),
44
+ body: j,
45
+ };
46
+ }
47
+ // ── list ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
48
+ export const LIST_SCHEMA = 'genie.list.virtuals.v1';
49
+ /** The venues `list` plans a listing on: Virtuals ACP. Every other venue's next step is in `journey(t, ref).venues[id].next`. */
50
+ export const LIST_VENUES = Object.freeze(['erc8183-base']);
51
+ /** The steps of a Virtuals ACP listing, in the order the Studio's list step runs them. */
52
+ export const LIST_STEPS = Object.freeze(['agent', 'signer', 'register', 'seller', 'offerings', 'readback']);
53
+ /** Moonbeam's own agent on Virtuals ACP. Any other agent id is read as a builder's, in its own account. */
54
+ export const HOUSE_AGENTS = Object.freeze({ moonbeam: '01a1cc7f-97ae-74da-8f87-b25514174a22' });
55
+ const AGENT_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
56
+ const BASE = 8453;
57
+ const VIRTUALS_API = 'https://api.acp.virtuals.io';
58
+ const VIRTUALS_APP = 'https://app.virtuals.io/acp/agents';
59
+ const checkCustom = (c) => {
60
+ if (!c)
61
+ return null;
62
+ const line = (s, max, what) => { if (s !== undefined && (typeof s !== 'string' || !s.trim() || s.length > max))
63
+ throw new RangeError(`${what} is 1 to ${max} characters`); };
64
+ line(c.name, 80, 'custom.name');
65
+ line(c.description, 1000, 'custom.description');
66
+ for (const o of c.offerings ?? []) {
67
+ line(o.name, 80, 'an offering name');
68
+ line(o.description, 1000, `${o.name}: its description`);
69
+ if (o.priceUsdc !== undefined && !(Number.isFinite(o.priceUsdc) && o.priceUsdc > 0))
70
+ throw new RangeError(`${o.name}: priceUsdc is a positive number of USDC`);
71
+ }
72
+ return c;
73
+ };
74
+ /** Virtuals ACP: the plan from the agent's own public record (its chains, its ERC-8004 id, its offerings shown or hidden). */
75
+ const planVirtuals = async (t, { agent, account, custom, now, api }) => {
76
+ const page = `${VIRTUALS_APP}/${agent}`;
77
+ const url = `${api}/agents/${agent}`;
78
+ const r = await t.fetch(url, { method: 'GET', headers: { accept: 'application/json' } });
79
+ const body = await jsonOf(r);
80
+ if (!r.ok && r.status !== 404)
81
+ throw new MarketError(r.status, 'GET virtuals /agents/:id', body);
82
+ const rec = r.ok && body && typeof body === 'object' ? (body.data ?? body) : null;
83
+ const at = now();
84
+ const steps = [];
85
+ const step = (s, state, who, evidence) => steps.push({ step: s, state, who, read_at: at, evidence });
86
+ const person = account === 'house:moonbeam' ? 'owner' : 'builder';
87
+ const chains = (rec?.chains ?? []).map((c) => ({ chainId: Number(c.chainId), erc8004AgentId: c.erc8004AgentId ?? null }));
88
+ const erc8004AgentId = chains.find((c) => c.chainId === BASE)?.erc8004AgentId ?? null;
89
+ const record = (rec?.offerings ?? []).filter((o) => typeof o.name === 'string');
90
+ const shownNames = new Set(record.filter((o) => !o.isHidden).map((o) => o.name));
91
+ // the offerings a run would show: the custom ones by name where given, else the record's own
92
+ const want = custom?.offerings?.length ? custom.offerings.map((o) => o.name) : record.map((o) => o.name);
93
+ const priceOf = (name) => custom?.offerings?.find((o) => o.name === name)?.priceUsdc ?? record.find((o) => o.name === name)?.priceValue ?? null;
94
+ const offerings = want.map((name) => ({ name, priceUsdc: priceOf(name), shown: shownNames.has(name) }));
95
+ const plan = (human) => ({
96
+ schema: LIST_SCHEMA, ref: agent, venue: 'erc8183-base', account,
97
+ agent: { id: agent, name: rec?.name ?? null, page, chains }, erc8004AgentId, steps, offerings, human,
98
+ done: steps.length > 0 && steps.every((s) => s.state === 'done' || s.state === 'skipped'),
99
+ });
100
+ // 1. the agent
101
+ if (!rec || (!rec.id && !rec.name)) {
102
+ step('agent', 'refused', 'machine', { kind: 'virtuals.agent', ref: agent, url, why: 'no such agent on Virtuals' });
103
+ return plan(null);
104
+ }
105
+ step('agent', 'done', 'machine', { kind: 'virtuals.agent', ref: agent, url });
106
+ // 2. the signer, and 3. the ERC-8004 identity on Base: the register call runs through the agent's signer
107
+ let human = null;
108
+ if (erc8004AgentId) {
109
+ step('signer', 'done', 'machine', { kind: 'virtuals.chains', ref: `${BASE}`, why: 'registered on Base, which runs through the agent\'s signer' });
110
+ step('register', 'done', 'machine', { kind: 'erc8004.identity', ref: String(erc8004AgentId) });
111
+ }
112
+ else {
113
+ step('signer', 'waiting', person, { kind: 'virtuals.signer', why: 'the agent has no identity on Base yet: the list step first asks for Moonbeam\'s signer, and its holder approves it once' });
114
+ step('register', 'waiting', 'machine', { kind: 'erc8004.register_call', why: 'registered on Base once the signer is approved (one transaction, no value)' });
115
+ human = { kind: 'approval', for: person, url: null, page, expires_at: null,
116
+ chat: `Approve Moonbeam's signer for this agent. Run the list step in the Moonbeam Studio: it shows the approval link, which lasts five minutes. The agent: ${page}` };
117
+ }
118
+ // 4. the seller: an offering is shown only once the agent's seller answers
119
+ if (shownNames.size)
120
+ step('seller', 'done', 'machine', { kind: 'virtuals.offerings', ref: `${shownNames.size} shown`, why: 'an offering is shown only once the agent\'s seller answers' });
121
+ else
122
+ step('seller', 'waiting', 'machine', { kind: 'seller.unit', why: 'no offering is shown, so the agent\'s seller is not shown to answer yet' });
123
+ // 5. the offerings a run would show, with the custom words and prices
124
+ const changes = custom ? [
125
+ ...(custom.name && custom.name !== rec.name ? ['the name'] : []),
126
+ ...(custom.description && custom.description !== rec.description ? ['the description'] : []),
127
+ ...(custom.offerings ?? []).filter((o) => {
128
+ const x = record.find((y) => y.name === o.name);
129
+ return !x || (o.description !== undefined && o.description !== x.description) || (o.priceUsdc !== undefined && o.priceUsdc !== x.priceValue);
130
+ }).map((o) => o.name),
131
+ ] : [];
132
+ const hidden = offerings.filter((o) => !o.shown).map((o) => o.name);
133
+ if (!want.length)
134
+ step('offerings', 'waiting', 'machine', { kind: 'virtuals.offerings', why: 'the agent has no offering yet' });
135
+ else if (changes.length || hidden.length)
136
+ step('offerings', 'waiting', 'machine', { kind: 'virtuals.offerings', ref: `${want.length - hidden.length} of ${want.length} shown`, why: [...(changes.length ? [`the run sets ${changes.join(', ')}`] : []), ...(hidden.length ? [`not shown yet: ${hidden.join(', ')}`] : [])].join('; ') });
137
+ else
138
+ step('offerings', 'done', 'machine', { kind: 'virtuals.offerings', ref: `${want.length} shown` });
139
+ // 6. the read back: this plan is itself a read of the agent's record
140
+ step('readback', hidden.length || !want.length ? 'running' : 'done', 'machine', { kind: 'virtuals.agent', ref: `${shownNames.size} shown`, url, ...(hidden.length ? { why: `not shown yet: ${hidden.join(', ')}` } : {}) });
141
+ return plan(human);
142
+ };
143
+ const PLANNERS = { 'erc8183-base': planVirtuals };
144
+ /**
145
+ * The listing of an agent on a venue, step by step as it stands now (genie.list.virtuals.v1). Read and plan only: the SDK never
146
+ * asks for a signer, registers, shows an offering or approves anything, and never moves money. The Moonbeam Studio's list step
147
+ * runs the steps; `human` names the one approval a person gives there (the venue account's holder: the owner for Moonbeam's own
148
+ * agent, the builder for theirs), and is returned, never acted on.
149
+ *
150
+ * `agent` is `moonbeam` (Moonbeam's own Virtuals agent) or a Virtuals agent id. `custom` is what the run would set: the agent's
151
+ * name and description, and per offering its description and price; the plan shows those offerings and says what would change.
152
+ * The venue's own public record is read through the transport's fetch (`o.api`, default https://api.acp.virtuals.io).
153
+ */
154
+ export async function list(t, o) {
155
+ const planner = PLANNERS[o?.venue];
156
+ if (!planner)
157
+ throw new RangeError(`list plans a listing on ${LIST_VENUES.join(', ')}; the next step on ${o?.venue} is in journey(t, ref).venues['${o?.venue}'].next`);
158
+ const a = String(o.agent ?? '').trim();
159
+ const house = Object.keys(HOUSE_AGENTS).find((k) => k === a || HOUSE_AGENTS[k] === a);
160
+ const agent = house ? HOUSE_AGENTS[house] : a;
161
+ if (!AGENT_ID.test(agent))
162
+ throw new RangeError(`an agent on Virtuals ACP is 'moonbeam' or its agent id (a UUID): ${o.agent}`);
163
+ const api = (o.api ?? VIRTUALS_API).replace(/\/+$/, '');
164
+ if (!/^https:\/\//.test(api))
165
+ throw new RangeError('the venue API is https');
166
+ return planner(t, { agent, account: house ? 'house:moonbeam' : 'builder', custom: checkCustom(o.custom), now: o.now ?? (() => new Date().toISOString()), api });
167
+ }
168
+ //# sourceMappingURL=listed.js.map