@oneie/cli 5.7.6 → 5.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -1
- package/dist/package.json +7 -8
- package/dist/src/age-yefbe8pe.js +1 -0
- package/dist/src/evm-tx-ee2q0e3w.js +1 -0
- package/dist/src/hl-run-tgrkrk69.js +1 -0
- package/dist/src/index-0rj9wdk9.js +4 -0
- package/dist/src/index-91y484c2.js +2052 -0
- package/dist/src/index-940y3rnv.js +12 -0
- package/dist/src/index.js +1047 -121
- package/dist/src/message-key-db1xjdkw.js +1 -0
- package/dist/src/message-lock-5vr8079x.js +5 -0
- package/dist/src/sweep-order-c2p6rk8c.js +1 -0
- package/dist/src/sweep-runner-t68xe7vx.js +1 -0
- package/package.json +7 -8
- package/dist/src/agent.d.ts +0 -75
- package/dist/src/agent.js +0 -1334
- package/dist/src/agentverse.d.ts +0 -26
- package/dist/src/agentverse.js +0 -171
- package/dist/src/args.d.ts +0 -9
- package/dist/src/args.js +0 -61
- package/dist/src/auth.d.ts +0 -6
- package/dist/src/auth.js +0 -121
- package/dist/src/balances.d.ts +0 -89
- package/dist/src/balances.js +0 -202
- package/dist/src/banner.d.ts +0 -1
- package/dist/src/banner.js +0 -17
- package/dist/src/broadcast.d.ts +0 -8
- package/dist/src/broadcast.js +0 -175
- package/dist/src/catalog.d.ts +0 -12
- package/dist/src/catalog.js +0 -76
- package/dist/src/chat.d.ts +0 -2
- package/dist/src/chat.js +0 -92
- package/dist/src/client.d.ts +0 -5
- package/dist/src/client.js +0 -157
- package/dist/src/compiler.d.ts +0 -36
- package/dist/src/compiler.js +0 -366
- package/dist/src/config.d.ts +0 -24
- package/dist/src/config.js +0 -70
- package/dist/src/connect.d.ts +0 -2
- package/dist/src/connect.js +0 -64
- package/dist/src/coordinate.d.ts +0 -3
- package/dist/src/coordinate.js +0 -58
- package/dist/src/create.d.ts +0 -2
- package/dist/src/create.js +0 -113
- package/dist/src/deploy.d.ts +0 -2
- package/dist/src/deploy.js +0 -19
- package/dist/src/dev.d.ts +0 -2
- package/dist/src/dev.js +0 -75
- package/dist/src/device-flow.d.ts +0 -57
- package/dist/src/device-flow.js +0 -173
- package/dist/src/doctor.d.ts +0 -26
- package/dist/src/doctor.js +0 -146
- package/dist/src/draw.d.ts +0 -18
- package/dist/src/draw.js +0 -156
- package/dist/src/endpoint.d.ts +0 -2
- package/dist/src/endpoint.js +0 -250
- package/dist/src/env.d.ts +0 -3
- package/dist/src/env.js +0 -37
- package/dist/src/eval.d.ts +0 -2
- package/dist/src/eval.js +0 -43
- package/dist/src/fn.d.ts +0 -2
- package/dist/src/fn.js +0 -70
- package/dist/src/group.d.ts +0 -2
- package/dist/src/group.js +0 -117
- package/dist/src/hl-run.d.ts +0 -119
- package/dist/src/hl-run.js +0 -480
- package/dist/src/hl.d.ts +0 -17
- package/dist/src/hl.js +0 -148
- package/dist/src/index.d.ts +0 -2
- package/dist/src/init.d.ts +0 -76
- package/dist/src/init.js +0 -278
- package/dist/src/join.d.ts +0 -11
- package/dist/src/join.js +0 -293
- package/dist/src/key-publish.d.ts +0 -40
- package/dist/src/key-publish.js +0 -232
- package/dist/src/key-seal.d.ts +0 -21
- package/dist/src/key-seal.js +0 -142
- package/dist/src/key-sweep.d.ts +0 -93
- package/dist/src/key-sweep.js +0 -263
- package/dist/src/key.d.ts +0 -26
- package/dist/src/key.js +0 -338
- package/dist/src/lib/age-plugin.d.ts +0 -51
- package/dist/src/lib/age-plugin.js +0 -130
- package/dist/src/lib/agent-env.d.ts +0 -12
- package/dist/src/lib/agent-env.js +0 -48
- package/dist/src/lib/api-path.d.ts +0 -2
- package/dist/src/lib/api-path.js +0 -40
- package/dist/src/lib/asker.d.ts +0 -34
- package/dist/src/lib/asker.js +0 -126
- package/dist/src/lib/client.d.ts +0 -20
- package/dist/src/lib/client.js +0 -71
- package/dist/src/lib/env-sealed.d.ts +0 -53
- package/dist/src/lib/env-sealed.js +0 -184
- package/dist/src/lib/flow-tag.d.ts +0 -86
- package/dist/src/lib/flow-tag.js +0 -230
- package/dist/src/lib/hl-core/actions.d.ts +0 -99
- package/dist/src/lib/hl-core/actions.js +0 -69
- package/dist/src/lib/hl-core/eip712.d.ts +0 -33
- package/dist/src/lib/hl-core/eip712.js +0 -107
- package/dist/src/lib/hl-core/errors.d.ts +0 -10
- package/dist/src/lib/hl-core/errors.js +0 -15
- package/dist/src/lib/hl-core/exchange.d.ts +0 -24
- package/dist/src/lib/hl-core/exchange.js +0 -47
- package/dist/src/lib/hl-core/index.d.ts +0 -13
- package/dist/src/lib/hl-core/index.js +0 -14
- package/dist/src/lib/hl-core/meta.d.ts +0 -57
- package/dist/src/lib/hl-core/meta.js +0 -110
- package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
- package/dist/src/lib/hl-core/msgpack.js +0 -136
- package/dist/src/lib/hl-core/net.d.ts +0 -2
- package/dist/src/lib/hl-core/net.js +0 -7
- package/dist/src/lib/hl-core/signing.d.ts +0 -103
- package/dist/src/lib/hl-core/signing.js +0 -295
- package/dist/src/lib/hl-core/wire.d.ts +0 -34
- package/dist/src/lib/hl-core/wire.js +0 -81
- package/dist/src/lib/invoked-as.d.ts +0 -2
- package/dist/src/lib/invoked-as.js +0 -24
- package/dist/src/lib/journey-words.d.ts +0 -84
- package/dist/src/lib/journey-words.js +0 -360
- package/dist/src/lib/journey.d.ts +0 -148
- package/dist/src/lib/journey.js +0 -245
- package/dist/src/lib/key-receipt.d.ts +0 -48
- package/dist/src/lib/key-receipt.js +0 -116
- package/dist/src/lib/key-source.d.ts +0 -9
- package/dist/src/lib/key-source.js +0 -33
- package/dist/src/lib/keyfile.d.ts +0 -136
- package/dist/src/lib/keyfile.js +0 -397
- package/dist/src/lib/launch-claude.d.ts +0 -5
- package/dist/src/lib/launch-claude.js +0 -45
- package/dist/src/lib/lock-lookup.d.ts +0 -40
- package/dist/src/lib/lock-lookup.js +0 -92
- package/dist/src/lib/message-seal.d.ts +0 -63
- package/dist/src/lib/message-seal.js +0 -150
- package/dist/src/lib/network.d.ts +0 -15
- package/dist/src/lib/network.js +0 -41
- package/dist/src/lib/paths.d.ts +0 -41
- package/dist/src/lib/paths.js +0 -91
- package/dist/src/lib/plan-draw.d.ts +0 -56
- package/dist/src/lib/plan-draw.js +0 -219
- package/dist/src/lib/plan-live.d.ts +0 -20
- package/dist/src/lib/plan-live.js +0 -192
- package/dist/src/lib/qr.d.ts +0 -21
- package/dist/src/lib/qr.js +0 -402
- package/dist/src/lib/roster.d.ts +0 -20
- package/dist/src/lib/roster.js +0 -79
- package/dist/src/lib/sale-card.d.ts +0 -117
- package/dist/src/lib/sale-card.js +0 -261
- package/dist/src/lib/shop-init.d.ts +0 -62
- package/dist/src/lib/shop-init.js +0 -63
- package/dist/src/lib/sui-grpc-send.d.ts +0 -50
- package/dist/src/lib/sui-grpc-send.js +0 -89
- package/dist/src/lib/swap-core.d.ts +0 -163
- package/dist/src/lib/swap-core.js +0 -405
- package/dist/src/lib/tasks-digest.d.ts +0 -66
- package/dist/src/lib/tasks-digest.js +0 -200
- package/dist/src/lib/tasks-graph.d.ts +0 -79
- package/dist/src/lib/tasks-graph.js +0 -463
- package/dist/src/lib/tasks-lens.d.ts +0 -31
- package/dist/src/lib/tasks-lens.js +0 -47
- package/dist/src/lib/tasks-next.d.ts +0 -25
- package/dist/src/lib/tasks-next.js +0 -103
- package/dist/src/lib/tasks-prove.d.ts +0 -15
- package/dist/src/lib/tasks-prove.js +0 -68
- package/dist/src/lib/tasks-route.d.ts +0 -29
- package/dist/src/lib/tasks-route.js +0 -151
- package/dist/src/lib/tasks-score.d.ts +0 -36
- package/dist/src/lib/tasks-score.js +0 -152
- package/dist/src/lib/tasks-workspace.d.ts +0 -18
- package/dist/src/lib/tasks-workspace.js +0 -73
- package/dist/src/lib/vault-read.d.ts +0 -24
- package/dist/src/lib/vault-read.js +0 -77
- package/dist/src/lib/vaultfile.d.ts +0 -88
- package/dist/src/lib/vaultfile.js +0 -222
- package/dist/src/lib/wallet-money.d.ts +0 -222
- package/dist/src/lib/wallet-money.js +0 -578
- package/dist/src/lib/wallet-request.d.ts +0 -50
- package/dist/src/lib/wallet-request.js +0 -86
- package/dist/src/links.d.ts +0 -5
- package/dist/src/links.js +0 -45
- package/dist/src/media.d.ts +0 -29
- package/dist/src/media.js +0 -487
- package/dist/src/message-receipt.d.ts +0 -25
- package/dist/src/message-receipt.js +0 -71
- package/dist/src/message.d.ts +0 -13
- package/dist/src/message.js +0 -92
- package/dist/src/onboard.d.ts +0 -16
- package/dist/src/onboard.js +0 -149
- package/dist/src/plugin.d.ts +0 -2
- package/dist/src/plugin.js +0 -193
- package/dist/src/push.d.ts +0 -2
- package/dist/src/push.js +0 -115
- package/dist/src/render.d.ts +0 -21
- package/dist/src/render.js +0 -32
- package/dist/src/secrets-device.d.ts +0 -32
- package/dist/src/secrets-device.js +0 -127
- package/dist/src/secrets-give.d.ts +0 -125
- package/dist/src/secrets-give.js +0 -236
- package/dist/src/secrets-list.d.ts +0 -27
- package/dist/src/secrets-list.js +0 -84
- package/dist/src/secrets-run.d.ts +0 -31
- package/dist/src/secrets-run.js +0 -182
- package/dist/src/secrets.d.ts +0 -33
- package/dist/src/secrets.js +0 -200
- package/dist/src/setup.d.ts +0 -6
- package/dist/src/setup.js +0 -127
- package/dist/src/ship.d.ts +0 -2
- package/dist/src/ship.js +0 -18
- package/dist/src/shop.d.ts +0 -10
- package/dist/src/shop.js +0 -110
- package/dist/src/skill-parser.d.ts +0 -14
- package/dist/src/skill-parser.js +0 -113
- package/dist/src/skill.d.ts +0 -2
- package/dist/src/skill.js +0 -493
- package/dist/src/slug.d.ts +0 -2
- package/dist/src/slug.js +0 -6
- package/dist/src/social.d.ts +0 -2
- package/dist/src/social.js +0 -106
- package/dist/src/staff.d.ts +0 -2
- package/dist/src/staff.js +0 -104
- package/dist/src/start.d.ts +0 -15
- package/dist/src/start.js +0 -203
- package/dist/src/status.d.ts +0 -2
- package/dist/src/status.js +0 -52
- package/dist/src/substrate.d.ts +0 -2
- package/dist/src/substrate.js +0 -258
- package/dist/src/swap.d.ts +0 -93
- package/dist/src/swap.js +0 -622
- package/dist/src/tasks.d.ts +0 -2
- package/dist/src/tasks.js +0 -743
- package/dist/src/templates.d.ts +0 -1
- package/dist/src/templates.js +0 -213
- package/dist/src/trade.d.ts +0 -2
- package/dist/src/trade.js +0 -91
- package/dist/src/trail.d.ts +0 -2
- package/dist/src/trail.js +0 -41
- package/dist/src/validate.d.ts +0 -13
- package/dist/src/validate.js +0 -35
- package/dist/src/wallet-money.d.ts +0 -152
- package/dist/src/wallet-money.js +0 -564
- package/dist/src/wallet.d.ts +0 -167
- package/dist/src/wallet.js +0 -855
- package/dist/src/workflow.d.ts +0 -2
- package/dist/src/workflow.js +0 -166
- package/dist/src/write.d.ts +0 -43
- package/dist/src/write.js +0 -180
package/dist/src/lib/roster.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// roster — where a seat's stake is read from, for `brief --as` / `route` / `next`.
|
|
2
|
-
//
|
|
3
|
-
// The stake is the persona's `subscribes:` and its place in the chart is `reports_to:`.
|
|
4
|
-
// Both are served by ONE route, GET /api/agents/roster (one.ie/web — the same parse of
|
|
5
|
-
// `{slug}/agents/*.md` that world:sync-subscriptions turns into follows rows), so the
|
|
6
|
-
// lens and the router read one declaration. Three facts measured 2026-09-28 shape this:
|
|
7
|
-
// - the route lives on the web host only: api.one.ie answers it 404, so the base is
|
|
8
|
-
// rewritten to one.ie whatever --api says;
|
|
9
|
-
// - `source=workspace` needs authority over the group (403 for a key that lacks it),
|
|
10
|
-
// `source=fleet` needs only a world key — so we fall back to the bundled fleet and SAY
|
|
11
|
-
// so, because fleet is not what the router reads for a group with its own personas;
|
|
12
|
-
// - the shared gateway service key is not a world key (401 no_session on both), so
|
|
13
|
-
// `--roster <file>` (a saved response) is the door for a caller holding only that.
|
|
14
|
-
import { readFileSync } from 'node:fs';
|
|
15
|
-
/** Keep only well-formed seats; a role with no id is not addressable. */
|
|
16
|
-
export function toSeats(raw) {
|
|
17
|
-
const list = Array.isArray(raw) ? raw : raw && typeof raw === 'object' && Array.isArray(raw.roles) ? raw.roles : [];
|
|
18
|
-
const out = [];
|
|
19
|
-
for (const r of list) {
|
|
20
|
-
if (!r || typeof r.id !== 'string' || !r.id)
|
|
21
|
-
continue;
|
|
22
|
-
out.push({
|
|
23
|
-
id: r.id,
|
|
24
|
-
...(typeof r.tier === 'string' ? { tier: r.tier } : {}),
|
|
25
|
-
reportsTo: typeof r.reportsTo === 'string' && r.reportsTo ? r.reportsTo : null,
|
|
26
|
-
subscribes: Array.isArray(r.subscribes) ? r.subscribes.filter((t) => typeof t === 'string') : [],
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return out;
|
|
30
|
-
}
|
|
31
|
-
/** The roster route answers on the web host only — never the gateway. */
|
|
32
|
-
export function webBase(base) {
|
|
33
|
-
return new URL(base).hostname === 'api.one.ie' ? 'https://one.ie' : base;
|
|
34
|
-
}
|
|
35
|
-
export async function loadRoster(opts) {
|
|
36
|
-
if (opts.file) {
|
|
37
|
-
try {
|
|
38
|
-
const seats = toSeats(JSON.parse(readFileSync(opts.file, 'utf8')));
|
|
39
|
-
if (!seats.length)
|
|
40
|
-
return { ok: false, error: `--roster ${opts.file}: no roles in it (want {roles:[{id,reportsTo,subscribes}]})` };
|
|
41
|
-
return { ok: true, seats, source: `file ${opts.file}` };
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
return { ok: false, error: `--roster: ${e instanceof Error ? e.message : String(e)}` };
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (!opts.workspace)
|
|
48
|
-
return { ok: false, error: 'reading a seat lens needs --workspace (whose roster?), --roster <file>, or --tags' };
|
|
49
|
-
const f = opts.fetchImpl ?? fetch;
|
|
50
|
-
const web = webBase(opts.base);
|
|
51
|
-
const url = (source) => `${web}/api/agents/roster?slug=${encodeURIComponent(opts.workspace)}${source ? `&source=${source}` : ''}`;
|
|
52
|
-
const refusals = [];
|
|
53
|
-
for (const source of [undefined, 'fleet']) {
|
|
54
|
-
let res;
|
|
55
|
-
try {
|
|
56
|
-
res = await f(url(source), { headers: opts.headers });
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
refusals.push(`${source ?? 'workspace'}: ${e instanceof Error ? e.message : String(e)}`);
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
const text = await res.text();
|
|
63
|
-
if (!res.ok) {
|
|
64
|
-
refusals.push(`${source ?? 'workspace'}: ${res.status} ${text.slice(0, 80)}`);
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
const seats = toSeats(JSON.parse(text));
|
|
69
|
-
if (seats.length) {
|
|
70
|
-
return { ok: true, seats, source: source === 'fleet' ? 'fleet (bundled agents — NOT this group\'s own personas; the router reads those)' : `workspace ${opts.workspace}` };
|
|
71
|
-
}
|
|
72
|
-
refusals.push(`${source ?? 'workspace'}: empty roster`);
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
refusals.push(`${source ?? 'workspace'}: ${res.status} not JSON`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return { ok: false, error: `could not read the roster (${refusals.join('; ')}) — pass --roster <file> or --tags` };
|
|
79
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
export type SaleKind = 'product' | 'service' | 'subscription' | 'course';
|
|
2
|
-
export type SaleRail = 'card' | 'crypto';
|
|
3
|
-
export type SaleChannel = 'web' | 'chat' | 'whatsapp' | 'instagram' | 'sms' | 'email';
|
|
4
|
-
export type SalePhase = 'idle' | 'paid';
|
|
5
|
-
export interface SaleOffer {
|
|
6
|
-
kind: SaleKind;
|
|
7
|
-
kindLabel: string;
|
|
8
|
-
name: string;
|
|
9
|
-
detail: string;
|
|
10
|
-
price: string;
|
|
11
|
-
cents: number;
|
|
12
|
-
cadence: string;
|
|
13
|
-
verb: string;
|
|
14
|
-
stamp: string;
|
|
15
|
-
link: string;
|
|
16
|
-
live: boolean;
|
|
17
|
-
rails: readonly SaleRail[];
|
|
18
|
-
}
|
|
19
|
-
export declare const SALE_OFFERS: readonly SaleOffer[];
|
|
20
|
-
export interface SaleRailCopy {
|
|
21
|
-
id: SaleRail;
|
|
22
|
-
label: string;
|
|
23
|
-
issuer: string;
|
|
24
|
-
lands: string;
|
|
25
|
-
}
|
|
26
|
-
export declare const SALE_RAILS: readonly SaleRailCopy[];
|
|
27
|
-
export interface SaleChannelCopy {
|
|
28
|
-
id: SaleChannel;
|
|
29
|
-
label: string;
|
|
30
|
-
bar: string;
|
|
31
|
-
native: boolean;
|
|
32
|
-
}
|
|
33
|
-
export declare const SALE_CHANNELS: readonly SaleChannelCopy[];
|
|
34
|
-
export declare const SALE_COPY: {
|
|
35
|
-
readonly opens: "the link opens on the card";
|
|
36
|
-
readonly cardOnly: "Monthly is card only.";
|
|
37
|
-
readonly example: "Example sale. Nothing here is a real payment.";
|
|
38
|
-
readonly exampleOffer: "Example price.";
|
|
39
|
-
readonly address: "0x5a1e…0e01";
|
|
40
|
-
readonly settled: "On Sui";
|
|
41
|
-
readonly shop: "Your shop";
|
|
42
|
-
readonly from: "hello@yourshop.example";
|
|
43
|
-
readonly ask: "How much is it?";
|
|
44
|
-
readonly time: "10:02";
|
|
45
|
-
readonly emailFrom: "From";
|
|
46
|
-
readonly emailSubject: "Subject";
|
|
47
|
-
readonly emailPay: "Pay";
|
|
48
|
-
};
|
|
49
|
-
export declare const SALE_KIND_IDS: SaleKind[];
|
|
50
|
-
export declare const SALE_RAIL_IDS: SaleRail[];
|
|
51
|
-
export declare const SALE_CHANNEL_IDS: SaleChannel[];
|
|
52
|
-
export declare const saleOffer: (kind: SaleKind) => SaleOffer;
|
|
53
|
-
export declare const saleRail: (id: SaleRail) => SaleRailCopy;
|
|
54
|
-
export declare const saleChannel: (id: SaleChannel) => SaleChannelCopy;
|
|
55
|
-
/** Asking a card-only offer for crypto gives card — the same rule the web face follows. */
|
|
56
|
-
export declare const saleRailFor: (offer: SaleOffer, rail: SaleRail) => SaleRail;
|
|
57
|
-
export declare const salePrice: (offer: SaleOffer) => string;
|
|
58
|
-
export declare const salePay: (offer: SaleOffer) => string;
|
|
59
|
-
/** From cents, so a dollar price never rounds into a different coin amount. */
|
|
60
|
-
export declare function saleUsdc(offer: SaleOffer): string;
|
|
61
|
-
export declare const salePayOn: (offer: SaleOffer, rail: SaleRail) => string;
|
|
62
|
-
export declare function saleMessage(channel: SaleChannel, offer: SaleOffer): string;
|
|
63
|
-
export declare const saleSubject: (offer: SaleOffer) => string;
|
|
64
|
-
/** The `?via=` tag is how /sales counts which channel a sale came through. */
|
|
65
|
-
export declare const saleLink: (offer: SaleOffer, channel: SaleChannel) => string;
|
|
66
|
-
/** A string from a flag, or null: the CLI refuses a word it does not know rather than drawing the default. */
|
|
67
|
-
export declare const saleKindOf: (v: unknown) => SaleKind | null;
|
|
68
|
-
export declare const saleRailOf: (v: unknown) => SaleRail | null;
|
|
69
|
-
export declare const saleChannelOf: (v: unknown) => SaleChannel | null;
|
|
70
|
-
/** The skill's limit (.claude/skills/ascii): every line fits a phone and a chat panel. */
|
|
71
|
-
export declare const SALE_MAX_WIDTH = 70;
|
|
72
|
-
export interface SaleDrawOpts {
|
|
73
|
-
rail?: SaleRail;
|
|
74
|
-
channel?: SaleChannel;
|
|
75
|
-
phase?: SalePhase;
|
|
76
|
-
/** Plain ASCII: a pipe, a log or NO_COLOR. */
|
|
77
|
-
ascii?: boolean;
|
|
78
|
-
}
|
|
79
|
-
/** One offer as a payment card, on the rail it can really take. */
|
|
80
|
-
export declare function saleCardLines(kind: SaleKind, opts?: SaleDrawOpts): string[];
|
|
81
|
-
/** The card inside a channel's thread: who, the agent's words and link, then the card it opens on. */
|
|
82
|
-
export declare function saleFrameLines(kind: SaleKind, channel: SaleChannel, opts?: SaleDrawOpts): string[];
|
|
83
|
-
/** The whole drawing: one offer or several, framed or bare, with the example line once at the end. */
|
|
84
|
-
export declare function drawSale(kinds: readonly SaleKind[], opts?: SaleDrawOpts): string;
|
|
85
|
-
/** The same sale as data, for --json and for an agent: what would be drawn, never a payment. */
|
|
86
|
-
export declare function saleJson(kinds: readonly SaleKind[], opts?: SaleDrawOpts): {
|
|
87
|
-
ok: boolean;
|
|
88
|
-
example: boolean;
|
|
89
|
-
note: "Example sale. Nothing here is a real payment.";
|
|
90
|
-
offers: ({
|
|
91
|
-
channel: SaleChannel;
|
|
92
|
-
message: string;
|
|
93
|
-
link: string;
|
|
94
|
-
lands: string;
|
|
95
|
-
stamp?: string | undefined;
|
|
96
|
-
pay: string;
|
|
97
|
-
cardOnly?: "Monthly is card only." | undefined;
|
|
98
|
-
kind: SaleKind;
|
|
99
|
-
name: string;
|
|
100
|
-
price: string;
|
|
101
|
-
cents: number;
|
|
102
|
-
live: boolean;
|
|
103
|
-
rail: SaleRail;
|
|
104
|
-
} | {
|
|
105
|
-
link: string;
|
|
106
|
-
lands: string;
|
|
107
|
-
stamp?: string | undefined;
|
|
108
|
-
pay: string;
|
|
109
|
-
cardOnly?: "Monthly is card only." | undefined;
|
|
110
|
-
kind: SaleKind;
|
|
111
|
-
name: string;
|
|
112
|
-
price: string;
|
|
113
|
-
cents: number;
|
|
114
|
-
live: boolean;
|
|
115
|
-
rail: SaleRail;
|
|
116
|
-
})[];
|
|
117
|
-
};
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The sale, drawn for a terminal — `one shop card`. The same four offers, two rails and six channels the
|
|
3
|
-
* home band, the chat and the film draw, as text no wider than 70 characters.
|
|
4
|
-
*
|
|
5
|
-
* SOURCE: one.ie/web/src/lib/sale/showcase.ts. The CLI is published on its own and cannot import the web
|
|
6
|
-
* package at runtime, so the words are copied here. tests/sale-card.test.ts reads that file as text and
|
|
7
|
-
* goes red when a name, price, cadence, rail or channel label drifts — change both together.
|
|
8
|
-
*
|
|
9
|
-
* Every line is a picture: nothing here mints, fetches or charges. A monthly subscription is card only.
|
|
10
|
-
* Card money goes to the seller's Stripe; USDC to the seller's own wallet. ONE holds neither.
|
|
11
|
-
*/
|
|
12
|
-
import { asciiOf } from './journey-words.js';
|
|
13
|
-
// Copied from showcase.ts SALE_OFFERS (href dropped: a terminal never opens a route).
|
|
14
|
-
export const SALE_OFFERS = [
|
|
15
|
-
{
|
|
16
|
-
kind: 'product', kindLabel: 'Product', name: 'Sold, the book', detail: 'The playbook, every chapter',
|
|
17
|
-
price: '$20', cents: 2000, cadence: '', verb: 'Buy', stamp: 'Paid',
|
|
18
|
-
link: 'one.ie/books/sold', live: false, rails: ['card', 'crypto'],
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
kind: 'service', kindLabel: 'Service', name: 'Strategy call', detail: '30 minutes · Thursday 10:00',
|
|
22
|
-
price: '$100', cents: 10000, cadence: '', verb: 'Book', stamp: 'Booked',
|
|
23
|
-
link: 'one.ie/call', live: false, rails: ['card', 'crypto'],
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
kind: 'subscription', kindLabel: 'Subscription', name: 'The Sold community', detail: 'People and agents, selling together',
|
|
27
|
-
price: '$100', cents: 10000, cadence: '/month', verb: 'Join', stamp: 'Joined',
|
|
28
|
-
link: 'one.ie/sold', live: true, rails: ['card'],
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
kind: 'course', kindLabel: 'Course', name: 'Sold', detail: 'The course, with a month of the community',
|
|
32
|
-
price: '$100', cents: 10000, cadence: '', verb: 'Enrol', stamp: 'Enrolled',
|
|
33
|
-
link: 'one.ie/sold', live: true, rails: ['card', 'crypto'],
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
export const SALE_RAILS = [
|
|
37
|
-
{ id: 'card', label: 'Card', issuer: 'ONE', lands: "Paid into the seller's Stripe" },
|
|
38
|
-
{ id: 'crypto', label: 'USDC', issuer: 'USDC · Sui', lands: "Paid to the seller's own wallet" },
|
|
39
|
-
];
|
|
40
|
-
export const SALE_CHANNELS = [
|
|
41
|
-
{ id: 'web', label: 'Web page', bar: 'yourshop.example', native: true },
|
|
42
|
-
{ id: 'chat', label: 'Chat', bar: 'Chat', native: true },
|
|
43
|
-
{ id: 'whatsapp', label: 'WhatsApp', bar: 'WhatsApp', native: false },
|
|
44
|
-
{ id: 'instagram', label: 'Instagram', bar: 'Instagram', native: false },
|
|
45
|
-
{ id: 'sms', label: 'SMS', bar: 'Messages', native: false },
|
|
46
|
-
{ id: 'email', label: 'Email', bar: 'Inbox', native: false },
|
|
47
|
-
];
|
|
48
|
-
export const SALE_COPY = {
|
|
49
|
-
opens: 'the link opens on the card',
|
|
50
|
-
cardOnly: 'Monthly is card only.',
|
|
51
|
-
example: 'Example sale. Nothing here is a real payment.',
|
|
52
|
-
exampleOffer: 'Example price.',
|
|
53
|
-
address: '0x5a1e…0e01',
|
|
54
|
-
settled: 'On Sui',
|
|
55
|
-
shop: 'Your shop',
|
|
56
|
-
from: 'hello@yourshop.example',
|
|
57
|
-
ask: 'How much is it?',
|
|
58
|
-
time: '10:02',
|
|
59
|
-
emailFrom: 'From',
|
|
60
|
-
emailSubject: 'Subject',
|
|
61
|
-
emailPay: 'Pay',
|
|
62
|
-
};
|
|
63
|
-
export const SALE_KIND_IDS = SALE_OFFERS.map((o) => o.kind);
|
|
64
|
-
export const SALE_RAIL_IDS = SALE_RAILS.map((r) => r.id);
|
|
65
|
-
export const SALE_CHANNEL_IDS = SALE_CHANNELS.map((c) => c.id);
|
|
66
|
-
export const saleOffer = (kind) => SALE_OFFERS.find((o) => o.kind === kind) ?? SALE_OFFERS[0];
|
|
67
|
-
export const saleRail = (id) => SALE_RAILS.find((r) => r.id === id) ?? SALE_RAILS[0];
|
|
68
|
-
export const saleChannel = (id) => SALE_CHANNELS.find((c) => c.id === id) ?? SALE_CHANNELS[0];
|
|
69
|
-
/** Asking a card-only offer for crypto gives card — the same rule the web face follows. */
|
|
70
|
-
export const saleRailFor = (offer, rail) => (offer.rails.includes(rail) ? rail : offer.rails[0]);
|
|
71
|
-
export const salePrice = (offer) => `${offer.price}${offer.cadence}`;
|
|
72
|
-
export const salePay = (offer) => `${offer.verb} · ${salePrice(offer)}`;
|
|
73
|
-
/** From cents, so a dollar price never rounds into a different coin amount. */
|
|
74
|
-
export function saleUsdc(offer) {
|
|
75
|
-
const whole = offer.cents % 100 === 0;
|
|
76
|
-
return `${whole ? offer.cents / 100 : (offer.cents / 100).toFixed(2)} USDC`;
|
|
77
|
-
}
|
|
78
|
-
export const salePayOn = (offer, rail) => saleRailFor(offer, rail) === 'crypto' ? `${offer.verb} · ${saleUsdc(offer)}` : salePay(offer);
|
|
79
|
-
export function saleMessage(channel, offer) {
|
|
80
|
-
const p = salePrice(offer);
|
|
81
|
-
switch (channel) {
|
|
82
|
-
case 'chat': return `${offer.name} is ${p}. Pay here.`;
|
|
83
|
-
case 'email': return `${offer.name}, ${p}. Pay with the button below.`;
|
|
84
|
-
case 'sms': return `${offer.name} is ${p}. Pay here:`;
|
|
85
|
-
case 'instagram': return `It's ${p}. Here's the link:`;
|
|
86
|
-
case 'whatsapp': return `${offer.name} is ${p}. Pay here:`;
|
|
87
|
-
default: return `${offer.name}, ${p}.`;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
export const saleSubject = (offer) => `Your ${offer.kindLabel.toLowerCase()}: ${offer.name}`;
|
|
91
|
-
/** The `?via=` tag is how /sales counts which channel a sale came through. */
|
|
92
|
-
export const saleLink = (offer, channel) => channel === 'web' || channel === 'chat' ? offer.link : `${offer.link}?via=${channel}`;
|
|
93
|
-
/** A string from a flag, or null: the CLI refuses a word it does not know rather than drawing the default. */
|
|
94
|
-
export const saleKindOf = (v) => pick(v, SALE_KIND_IDS);
|
|
95
|
-
export const saleRailOf = (v) => pick(v, SALE_RAIL_IDS);
|
|
96
|
-
export const saleChannelOf = (v) => pick(v, SALE_CHANNEL_IDS);
|
|
97
|
-
function pick(v, ids) {
|
|
98
|
-
const s = typeof v === 'string' ? v.trim().toLowerCase() : '';
|
|
99
|
-
return ids.includes(s) ? s : null;
|
|
100
|
-
}
|
|
101
|
-
// ── drawing ──────────────────────────────────────────────────────────────────
|
|
102
|
-
/** The skill's limit (.claude/skills/ascii): every line fits a phone and a chat panel. */
|
|
103
|
-
export const SALE_MAX_WIDTH = 70;
|
|
104
|
-
const CARD_IN = 44; // card content; the card is 48 wide
|
|
105
|
-
const FRAME_IN = 62; // frame content; the frame is 66 wide
|
|
106
|
-
const INDENT = ' ';
|
|
107
|
-
const len = (s) => [...s].length;
|
|
108
|
-
function wrap(text, width) {
|
|
109
|
-
const lines = [];
|
|
110
|
-
let line = '';
|
|
111
|
-
for (const w of text.split(' ')) {
|
|
112
|
-
if (line && len(line) + 1 + len(w) > width) {
|
|
113
|
-
lines.push(line);
|
|
114
|
-
line = w;
|
|
115
|
-
}
|
|
116
|
-
else
|
|
117
|
-
line = line ? `${line} ${w}` : w;
|
|
118
|
-
}
|
|
119
|
-
if (line)
|
|
120
|
-
lines.push(line);
|
|
121
|
-
return lines;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Boxes are padded AFTER each cell is made ASCII, so "…" becoming "..." widens the cell, not the border.
|
|
125
|
-
*/
|
|
126
|
-
function boxer(inner, ascii) {
|
|
127
|
-
const g = (s) => (ascii ? asciiOf(s) : s);
|
|
128
|
-
const [tl, tr, bl, br, h, v] = ascii ? ['+', '+', '+', '+', '-', '|'] : ['╭', '╮', '╰', '╯', '─', '│'];
|
|
129
|
-
const fit = (s) => {
|
|
130
|
-
const t = g(s);
|
|
131
|
-
return len(t) > inner ? [...t].slice(0, inner).join('') : t;
|
|
132
|
-
};
|
|
133
|
-
const row = (s = '') => { const t = fit(s); return `${v} ${t}${' '.repeat(inner - len(t))} ${v}`; };
|
|
134
|
-
return {
|
|
135
|
-
top: `${tl}${h.repeat(inner + 2)}${tr}`,
|
|
136
|
-
bottom: `${bl}${h.repeat(inner + 2)}${br}`,
|
|
137
|
-
row,
|
|
138
|
-
/** Left and right in one row, at least two spaces apart. */
|
|
139
|
-
split: (l, r) => {
|
|
140
|
-
const a = g(l), b = g(r);
|
|
141
|
-
return row(`${a}${' '.repeat(Math.max(2, inner - len(a) - len(b)))}${b}`);
|
|
142
|
-
},
|
|
143
|
-
right: (s) => { const t = fit(s); return `${v} ${' '.repeat(inner - len(t))}${t} ${v}`; },
|
|
144
|
-
center: (s) => {
|
|
145
|
-
const t = fit(s), pad = inner - len(t), left = Math.floor(pad / 2);
|
|
146
|
-
return `${v} ${' '.repeat(left)}${t}${' '.repeat(pad - left)} ${v}`;
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
/** One offer as a payment card, on the rail it can really take. */
|
|
151
|
-
export function saleCardLines(kind, opts = {}) {
|
|
152
|
-
const offer = saleOffer(kind);
|
|
153
|
-
const asked = opts.rail ?? 'card';
|
|
154
|
-
const rail = saleRailFor(offer, asked);
|
|
155
|
-
const copy = saleRail(rail);
|
|
156
|
-
const b = boxer(CARD_IN, Boolean(opts.ascii));
|
|
157
|
-
const crypto = rail === 'crypto';
|
|
158
|
-
const price = crypto ? saleUsdc(offer) : salePrice(offer);
|
|
159
|
-
const paid = opts.phase === 'paid';
|
|
160
|
-
const stamp = `✓ ${offer.stamp}${paid && crypto ? ` · ${SALE_COPY.settled}` : ''}`;
|
|
161
|
-
return [
|
|
162
|
-
b.top,
|
|
163
|
-
b.split(copy.issuer, offer.kindLabel),
|
|
164
|
-
b.row(),
|
|
165
|
-
b.row(offer.name),
|
|
166
|
-
...wrap(offer.detail, CARD_IN).map((l) => b.row(l)),
|
|
167
|
-
b.row(),
|
|
168
|
-
offer.live ? b.row(price) : b.split(price, SALE_COPY.exampleOffer),
|
|
169
|
-
...(crypto ? [b.row(SALE_COPY.address)] : []),
|
|
170
|
-
b.row(),
|
|
171
|
-
b.row(paid ? stamp : `[ ${salePayOn(offer, rail)} ]`),
|
|
172
|
-
b.row(),
|
|
173
|
-
// Asked for USDC on a monthly offer: say why the card face is drawn, not silently swap.
|
|
174
|
-
...(rail !== asked ? [b.row(SALE_COPY.cardOnly)] : []),
|
|
175
|
-
b.row(`${copy.label} · ${copy.lands}`),
|
|
176
|
-
b.bottom,
|
|
177
|
-
];
|
|
178
|
-
}
|
|
179
|
-
/** The card inside a channel's thread: who, the agent's words and link, then the card it opens on. */
|
|
180
|
-
export function saleFrameLines(kind, channel, opts = {}) {
|
|
181
|
-
const offer = saleOffer(kind);
|
|
182
|
-
const c = saleChannel(channel);
|
|
183
|
-
const b = boxer(FRAME_IN, Boolean(opts.ascii));
|
|
184
|
-
const msg = saleMessage(channel, offer);
|
|
185
|
-
const link = saleLink(offer, channel);
|
|
186
|
-
const said = (text) => wrap(text, FRAME_IN).map((l) => b.row(l));
|
|
187
|
-
const head = (() => {
|
|
188
|
-
switch (channel) {
|
|
189
|
-
case 'web': return [b.row(c.bar)];
|
|
190
|
-
case 'chat': return [b.row(c.bar)];
|
|
191
|
-
case 'sms': return [b.center(SALE_COPY.shop), b.center(c.bar)];
|
|
192
|
-
case 'email': return [b.split(c.bar, SALE_COPY.time)];
|
|
193
|
-
default: return [b.row(`${SALE_COPY.shop} · ${c.bar}`)];
|
|
194
|
-
}
|
|
195
|
-
})();
|
|
196
|
-
const body = (() => {
|
|
197
|
-
switch (channel) {
|
|
198
|
-
case 'web': return [];
|
|
199
|
-
case 'chat': return said(msg);
|
|
200
|
-
case 'whatsapp':
|
|
201
|
-
case 'instagram':
|
|
202
|
-
return [b.right(SALE_COPY.ask), b.row(), ...said(msg), b.row(link), b.row(SALE_COPY.time)];
|
|
203
|
-
case 'sms':
|
|
204
|
-
return [b.center(SALE_COPY.time), b.row(), ...said(msg), b.row(link)];
|
|
205
|
-
case 'email':
|
|
206
|
-
return [
|
|
207
|
-
b.row(`${SALE_COPY.emailFrom.padEnd(8)}${SALE_COPY.shop} ${SALE_COPY.from}`),
|
|
208
|
-
b.row(`${SALE_COPY.emailSubject.padEnd(8)}${saleSubject(offer)}`),
|
|
209
|
-
b.row(),
|
|
210
|
-
...said(msg),
|
|
211
|
-
...said(offer.detail),
|
|
212
|
-
b.row(),
|
|
213
|
-
b.row(`[ ${SALE_COPY.emailPay} ${salePrice(offer)} ] ${link}`),
|
|
214
|
-
];
|
|
215
|
-
}
|
|
216
|
-
})();
|
|
217
|
-
return [
|
|
218
|
-
b.top,
|
|
219
|
-
...head,
|
|
220
|
-
b.row(),
|
|
221
|
-
...body,
|
|
222
|
-
...(body.length ? [b.row()] : []),
|
|
223
|
-
...(c.native ? [] : [b.row(`↓ ${SALE_COPY.opens}`), b.row()]),
|
|
224
|
-
...saleCardLines(kind, opts).map((l) => b.row(INDENT + l)),
|
|
225
|
-
b.bottom,
|
|
226
|
-
];
|
|
227
|
-
}
|
|
228
|
-
/** The whole drawing: one offer or several, framed or bare, with the example line once at the end. */
|
|
229
|
-
export function drawSale(kinds, opts = {}) {
|
|
230
|
-
const blocks = kinds.map((k) => (opts.channel ? saleFrameLines(k, opts.channel, opts) : saleCardLines(k, opts)).join('\n'));
|
|
231
|
-
return [...blocks, opts.ascii ? asciiOf(SALE_COPY.example) : SALE_COPY.example].join('\n\n') + '\n';
|
|
232
|
-
}
|
|
233
|
-
/** The same sale as data, for --json and for an agent: what would be drawn, never a payment. */
|
|
234
|
-
export function saleJson(kinds, opts = {}) {
|
|
235
|
-
const asked = opts.rail ?? 'card';
|
|
236
|
-
return {
|
|
237
|
-
ok: true,
|
|
238
|
-
example: true,
|
|
239
|
-
note: SALE_COPY.example,
|
|
240
|
-
offers: kinds.map((k) => {
|
|
241
|
-
const offer = saleOffer(k);
|
|
242
|
-
const rail = saleRailFor(offer, asked);
|
|
243
|
-
return {
|
|
244
|
-
kind: offer.kind,
|
|
245
|
-
name: offer.name,
|
|
246
|
-
price: salePrice(offer),
|
|
247
|
-
cents: offer.cents,
|
|
248
|
-
live: offer.live,
|
|
249
|
-
rail,
|
|
250
|
-
...(rail !== asked ? { cardOnly: SALE_COPY.cardOnly } : {}),
|
|
251
|
-
pay: salePayOn(offer, rail),
|
|
252
|
-
// --paid must change the data too, or an agent reading --json sees a flag it passed do nothing.
|
|
253
|
-
...(opts.phase === 'paid' ? { stamp: `${offer.stamp}${rail === 'crypto' ? ` · ${SALE_COPY.settled}` : ''}` } : {}),
|
|
254
|
-
lands: saleRail(rail).lands,
|
|
255
|
-
...(opts.channel
|
|
256
|
-
? { channel: opts.channel, message: saleMessage(opts.channel, offer), link: saleLink(offer, opts.channel) }
|
|
257
|
-
: { link: offer.link }),
|
|
258
|
-
};
|
|
259
|
-
}),
|
|
260
|
-
};
|
|
261
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `one shop init` — the terminal half of the shop pack.
|
|
3
|
-
*
|
|
4
|
-
* Pure on purpose: every round trip arrives through `deps.ask`, so the whole
|
|
5
|
-
* command is exercised without a network and without a key. `src/shop.ts` is
|
|
6
|
-
* the commander wiring and holds no logic of its own.
|
|
7
|
-
*
|
|
8
|
-
* TWO RECEIVERS, ONE OF WHICH MAY NOT BE THERE YET.
|
|
9
|
-
* `pages:instantiate-shop-pack` ships. `pages:fill-shop-pack` is C9.3 of
|
|
10
|
-
* `text/ecommerce-site-todo.md` and lands in parallel with this — and an
|
|
11
|
-
* unknown receiver DISSOLVES, which answers HTTP 200. So the fill leg is read
|
|
12
|
-
* for its outcome and reported separately: `seeded` and `filled` are two facts,
|
|
13
|
-
* and a shop whose pages exist but carry no facts must not report as either a
|
|
14
|
-
* clean success or a total failure.
|
|
15
|
-
*/
|
|
16
|
-
export interface AskEnvelope {
|
|
17
|
-
outcome?: string;
|
|
18
|
-
result?: {
|
|
19
|
-
ok?: boolean;
|
|
20
|
-
slug?: string;
|
|
21
|
-
error?: string;
|
|
22
|
-
pages?: Array<{
|
|
23
|
-
pageSlug?: string;
|
|
24
|
-
slug?: string;
|
|
25
|
-
}>;
|
|
26
|
-
filled?: number;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export interface ShopInitDeps {
|
|
30
|
-
ask(receiver: string, data: unknown): Promise<AskEnvelope>;
|
|
31
|
-
}
|
|
32
|
-
export interface ShopInitResult {
|
|
33
|
-
ok: boolean;
|
|
34
|
-
workspace: string;
|
|
35
|
-
/** The page slugs the seed reported, first one first. */
|
|
36
|
-
pages: string[];
|
|
37
|
-
/** Was a fill asked for, and did it happen. */
|
|
38
|
-
filled: boolean;
|
|
39
|
-
fillRequested: boolean;
|
|
40
|
-
error?: string;
|
|
41
|
-
fillError?: string;
|
|
42
|
-
}
|
|
43
|
-
/** One reading of an `/api/ask` answer. A dissolve and a refusal both arrive as 200. */
|
|
44
|
-
export declare function readEnvelope(env: AskEnvelope, receiver: string): {
|
|
45
|
-
ok: true;
|
|
46
|
-
result: NonNullable<AskEnvelope['result']>;
|
|
47
|
-
} | {
|
|
48
|
-
ok: false;
|
|
49
|
-
error: string;
|
|
50
|
-
};
|
|
51
|
-
/** Parse a facts file. A file that is not an object is refused by name, never coerced. */
|
|
52
|
-
export declare function parseFacts(raw: string): {
|
|
53
|
-
ok: true;
|
|
54
|
-
facts: Record<string, unknown>;
|
|
55
|
-
} | {
|
|
56
|
-
ok: false;
|
|
57
|
-
error: string;
|
|
58
|
-
};
|
|
59
|
-
export declare function shopInit(deps: ShopInitDeps, opts: {
|
|
60
|
-
workspace: string;
|
|
61
|
-
facts?: Record<string, unknown>;
|
|
62
|
-
}): Promise<ShopInitResult>;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `one shop init` — the terminal half of the shop pack.
|
|
3
|
-
*
|
|
4
|
-
* Pure on purpose: every round trip arrives through `deps.ask`, so the whole
|
|
5
|
-
* command is exercised without a network and without a key. `src/shop.ts` is
|
|
6
|
-
* the commander wiring and holds no logic of its own.
|
|
7
|
-
*
|
|
8
|
-
* TWO RECEIVERS, ONE OF WHICH MAY NOT BE THERE YET.
|
|
9
|
-
* `pages:instantiate-shop-pack` ships. `pages:fill-shop-pack` is C9.3 of
|
|
10
|
-
* `text/ecommerce-site-todo.md` and lands in parallel with this — and an
|
|
11
|
-
* unknown receiver DISSOLVES, which answers HTTP 200. So the fill leg is read
|
|
12
|
-
* for its outcome and reported separately: `seeded` and `filled` are two facts,
|
|
13
|
-
* and a shop whose pages exist but carry no facts must not report as either a
|
|
14
|
-
* clean success or a total failure.
|
|
15
|
-
*/
|
|
16
|
-
/** One reading of an `/api/ask` answer. A dissolve and a refusal both arrive as 200. */
|
|
17
|
-
export function readEnvelope(env, receiver) {
|
|
18
|
-
if (env.outcome && env.outcome !== 'result')
|
|
19
|
-
return { ok: false, error: `${receiver} ${env.outcome}` };
|
|
20
|
-
const result = env.result;
|
|
21
|
-
if (!result?.ok)
|
|
22
|
-
return { ok: false, error: result?.error ?? `${receiver} returned no result` };
|
|
23
|
-
return { ok: true, result };
|
|
24
|
-
}
|
|
25
|
-
/** Parse a facts file. A file that is not an object is refused by name, never coerced. */
|
|
26
|
-
export function parseFacts(raw) {
|
|
27
|
-
let parsed;
|
|
28
|
-
try {
|
|
29
|
-
parsed = JSON.parse(raw);
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
return { ok: false, error: `facts file is not valid JSON: ${e.message}` };
|
|
33
|
-
}
|
|
34
|
-
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
35
|
-
return { ok: false, error: 'facts file must be a JSON object of ShopBusinessFacts' };
|
|
36
|
-
}
|
|
37
|
-
return { ok: true, facts: parsed };
|
|
38
|
-
}
|
|
39
|
-
export async function shopInit(deps, opts) {
|
|
40
|
-
const fillRequested = opts.facts !== undefined;
|
|
41
|
-
const base = { ok: false, workspace: opts.workspace, pages: [], filled: false, fillRequested };
|
|
42
|
-
if (!opts.workspace)
|
|
43
|
-
return { ...base, error: 'no workspace — pass --workspace <slug>' };
|
|
44
|
-
const seedEnv = await deps.ask('pages:instantiate-shop-pack', { slug: opts.workspace });
|
|
45
|
-
const seed = readEnvelope(seedEnv, 'pages:instantiate-shop-pack');
|
|
46
|
-
if (!seed.ok)
|
|
47
|
-
return { ...base, error: seed.error };
|
|
48
|
-
// The receiver answers with all twelve role pages in `pages`; the bare `slug`
|
|
49
|
-
// (the home page) is the fallback for an older worker that predates them.
|
|
50
|
-
const listed = Array.isArray(seed.result.pages) ? seed.result.pages : [];
|
|
51
|
-
const pages = listed.map(p => p.slug).filter((s) => typeof s === 'string' && s.length > 0);
|
|
52
|
-
if (!pages.length && seed.result.slug)
|
|
53
|
-
pages.push(seed.result.slug);
|
|
54
|
-
if (!pages.length)
|
|
55
|
-
return { ...base, error: 'the pack seeded no pages' };
|
|
56
|
-
if (!fillRequested)
|
|
57
|
-
return { ...base, ok: true, pages };
|
|
58
|
-
const fillEnv = await deps.ask('pages:fill-shop-pack', { slug: opts.workspace, facts: opts.facts });
|
|
59
|
-
const fill = readEnvelope(fillEnv, 'pages:fill-shop-pack');
|
|
60
|
-
if (!fill.ok)
|
|
61
|
-
return { ...base, ok: true, pages, fillError: fill.error };
|
|
62
|
-
return { ...base, ok: true, pages, filled: true };
|
|
63
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* sui-grpc-send.ts — one Sui transfer (SUI or any coin type) over gRPC.
|
|
3
|
-
*
|
|
4
|
-
* Sui JSON-RPC is switched off on every public fullnode ("JSON-RPC on public fullnodes has
|
|
5
|
-
* been deprecated"), so the send goes over Mysten's gRPC fullnodes — the same endpoints and
|
|
6
|
-
* `client.core.executeTransaction` shape one.ie/web/src/lib/sui-transport.ts uses (copied, never
|
|
7
|
-
* imported: the CLI ships alone). `@mysten/sui` loads on demand so a command that never sends
|
|
8
|
-
* pays nothing for it.
|
|
9
|
-
*
|
|
10
|
-
* Never hangs, never re-sends: the digest is known BEFORE the node is asked (it is the hash of
|
|
11
|
-
* the bytes we signed), so a node that goes quiet is refused by name with that digest in hand.
|
|
12
|
-
*/
|
|
13
|
-
import type { Net } from './wallet-money.js';
|
|
14
|
-
export declare const SUI_GRPC: Record<Net, string>;
|
|
15
|
-
export interface SuiSendReq {
|
|
16
|
-
asset: 'SUI' | 'USDC' | 'ETH';
|
|
17
|
-
coinType: string;
|
|
18
|
-
from: string;
|
|
19
|
-
to: string;
|
|
20
|
-
amountUnits: bigint;
|
|
21
|
-
privateKeyHex: string;
|
|
22
|
-
/** An optional gRPC base URL override; default is Mysten's public fullnode for `net`. */
|
|
23
|
-
rpc?: string;
|
|
24
|
-
net: Net;
|
|
25
|
-
}
|
|
26
|
-
export interface SuiSendDone {
|
|
27
|
-
digest: string;
|
|
28
|
-
/** computation + storage − rebate, in MIST (never below 0). */
|
|
29
|
-
gasMist: bigint;
|
|
30
|
-
/** Wall-clock from signing to the node returning the certified effects, in ms. */
|
|
31
|
-
finalMs: number;
|
|
32
|
-
}
|
|
33
|
-
type Loader = (spec: string) => Promise<Record<string, unknown>>;
|
|
34
|
-
/** A variable specifier: no bundler or typechecker pulls @mysten/sui in; it loads from the person's own install. */
|
|
35
|
-
export declare const loadSpec: Loader;
|
|
36
|
-
/** A named failure that may carry the digest of a transaction that might still land. */
|
|
37
|
-
export declare class SuiSendError extends Error {
|
|
38
|
-
code: string;
|
|
39
|
-
digest?: string | undefined;
|
|
40
|
-
constructor(code: string, message: string, digest?: string | undefined);
|
|
41
|
-
}
|
|
42
|
-
export declare const gasMistOf: (g: {
|
|
43
|
-
computationCost?: string;
|
|
44
|
-
storageCost?: string;
|
|
45
|
-
storageRebate?: string;
|
|
46
|
-
} | undefined) => bigint;
|
|
47
|
-
export declare function suiSendGrpc(r: SuiSendReq, load?: Loader, deadlineMs?: number): Promise<SuiSendDone>;
|
|
48
|
-
/** 1_234_000_000 MIST → "1.234 SUI" (trailing zeros trimmed, at least one digit). */
|
|
49
|
-
export declare function mistToSui(mist: bigint): string;
|
|
50
|
-
export {};
|