oneie 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/workflow.d.ts
DELETED
package/dist/src/workflow.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
|
-
import { resolve } from 'node:path';
|
|
5
|
-
import { askPath } from './lib/api-path.js';
|
|
6
|
-
const DEFAULT_API = 'https://api.one.ie';
|
|
7
|
-
const KEY_FILE = resolve(homedir(), '.config', 'oneie', 'key');
|
|
8
|
-
function readApiKey() {
|
|
9
|
-
// ONE_API_KEY is canonical, ONEIE_API_KEY legacy — same order lib/client.ts uses.
|
|
10
|
-
if (process.env.ONE_API_KEY)
|
|
11
|
-
return process.env.ONE_API_KEY;
|
|
12
|
-
if (process.env.ONEIE_API_KEY)
|
|
13
|
-
return process.env.ONEIE_API_KEY;
|
|
14
|
-
if (existsSync(KEY_FILE))
|
|
15
|
-
return readFileSync(KEY_FILE, 'utf8').trim() || null;
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
// Every workspace op hits an EXISTING workflow:* receiver via the ask door — no new
|
|
19
|
-
// HTTP route (cli/CLAUDE.md no-new-endpoints). pull writes the workflow:get graph
|
|
20
|
-
// verbatim as <name>/workflow.json; push takes a diff-JSON file and applies it
|
|
21
|
-
// (simulate by default, --commit persists). Mirrors the agent group's file round-trip.
|
|
22
|
-
export function workflowCmd() {
|
|
23
|
-
const cmd = new Command('workflow').description('List, pull, push (diff), and run workflows');
|
|
24
|
-
const call = async (api, slug, receiver, data) => {
|
|
25
|
-
const key = readApiKey();
|
|
26
|
-
if (!key)
|
|
27
|
-
return { ok: false, error: 'no API key — run `oneie auth login --key <key>` or set ONEIE_API_KEY' };
|
|
28
|
-
const url = askPath(api.replace(/\/$/, ''), receiver);
|
|
29
|
-
const res = await fetch(url, {
|
|
30
|
-
method: 'POST',
|
|
31
|
-
// Bearer <key> — NOT `<slug>:<key>`. The world key carries its own ownerSlug;
|
|
32
|
-
// prefixing the slug made the gateway read the whole string as an unknown key
|
|
33
|
-
// and every workflow subcommand 403'd with "authentication required".
|
|
34
|
-
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` },
|
|
35
|
-
body: JSON.stringify({ data }),
|
|
36
|
-
});
|
|
37
|
-
const text = await res.text();
|
|
38
|
-
if (!text)
|
|
39
|
-
return {};
|
|
40
|
-
const body = JSON.parse(text);
|
|
41
|
-
// The ask door answers with an ENVELOPE — { outcome, result, signalId }. Every
|
|
42
|
-
// subcommand below reads the receiver's own fields (r.id, r.ok, r.runId), so
|
|
43
|
-
// unwrap here. Reading them off the envelope made `pull` report not_found for
|
|
44
|
-
// a workflow that exists, and `push` report ok=false on a successful apply.
|
|
45
|
-
if (body && typeof body === 'object' && 'outcome' in body) {
|
|
46
|
-
const inner = (body.result ?? {});
|
|
47
|
-
if (body.outcome === 'failure')
|
|
48
|
-
return { error: inner.error ?? 'failure', ...inner };
|
|
49
|
-
return { ...inner, ...(body.simulated ? { simulated: true } : {}) };
|
|
50
|
-
}
|
|
51
|
-
return body;
|
|
52
|
-
};
|
|
53
|
-
cmd.command('list')
|
|
54
|
-
.description('List workflows in a workspace')
|
|
55
|
-
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
56
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
57
|
-
.action(async (opts) => {
|
|
58
|
-
const r = await call(opts.api, opts.slug, 'workflow:list', {});
|
|
59
|
-
out(cmd, { ok: !r.error, ...r });
|
|
60
|
-
});
|
|
61
|
-
cmd.command('pull <id>')
|
|
62
|
-
.description('Download a workflow graph to <name>/workflow.json')
|
|
63
|
-
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
64
|
-
.option('--out <dir>', 'Output directory (defaults to the workflow name)')
|
|
65
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
66
|
-
.action(async (id, opts) => {
|
|
67
|
-
const r = await call(opts.api, opts.slug, 'workflow:get', { workflowId: id });
|
|
68
|
-
if (r.error || !r.id) {
|
|
69
|
-
out(cmd, { ok: false, error: r.error ?? 'not_found' });
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const dir = opts.out ?? String(r.name ?? id).toLowerCase().replace(/[^a-z0-9]+/g, '-');
|
|
73
|
-
mkdirSync(dir, { recursive: true });
|
|
74
|
-
const path = `${dir}/workflow.json`;
|
|
75
|
-
writeFileSync(path, JSON.stringify(r, null, 2));
|
|
76
|
-
out(cmd, { ok: true, path, steps: (r.steps ?? []).length });
|
|
77
|
-
});
|
|
78
|
-
cmd.command('push <id> <file>')
|
|
79
|
-
.description('Apply a diff-JSON file to a workflow (simulate by default)')
|
|
80
|
-
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
81
|
-
.option('--commit', 'Persist the diff (default simulates)')
|
|
82
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
83
|
-
.action(async (id, file, opts) => {
|
|
84
|
-
if (!existsSync(file)) {
|
|
85
|
-
out(cmd, { ok: false, error: `not found: ${file}` });
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const diff = JSON.parse(readFileSync(file, 'utf8'));
|
|
89
|
-
const r = await call(opts.api, opts.slug, 'workflow:apply-diff', { workflowId: id, diff, simulate: opts.commit !== true });
|
|
90
|
-
out(cmd, { ok: !!r.ok, simulated: opts.commit !== true, ...r });
|
|
91
|
-
});
|
|
92
|
-
cmd.command('run <id>')
|
|
93
|
-
.description('Start a run of a workflow')
|
|
94
|
-
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
95
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
96
|
-
.action(async (id, opts) => {
|
|
97
|
-
const r = await call(opts.api, opts.slug, 'workflow:run', { workflowId: id });
|
|
98
|
-
out(cmd, { ok: !!r.runId, ...r });
|
|
99
|
-
});
|
|
100
|
-
// publish takes the workflow ID, like every sibling above — `loadOwned` looks
|
|
101
|
-
// up by id deliberately ("not name, to prevent name-guessing"), and `workflow
|
|
102
|
-
// list` is the door from a name to an id. The seller is NOT passed: the
|
|
103
|
-
// receiver derives it from the key's own attested workspace, so --slug here
|
|
104
|
-
// only picks the API host's workspace context, exactly as the siblings use it.
|
|
105
|
-
cmd.command('publish <id>')
|
|
106
|
-
.description('List a workflow you own on the marketplace at a price (credits; 0 = free)')
|
|
107
|
-
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
108
|
-
.option('--price <n>', 'Price in credits', (v) => Number(v))
|
|
109
|
-
.option('--name <name>', "Listing title (defaults to the workflow's own name)")
|
|
110
|
-
.option('--tags <csv>', 'Comma-separated tags (workflow is always added)')
|
|
111
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
112
|
-
.action(async (id, opts) => {
|
|
113
|
-
const tags = opts.tags ? opts.tags.split(',').map((t) => t.trim()).filter(Boolean) : undefined;
|
|
114
|
-
const r = await call(opts.api, opts.slug, 'workflow:publish', {
|
|
115
|
-
workflowId: id,
|
|
116
|
-
...(opts.price !== undefined ? { price: opts.price } : {}),
|
|
117
|
-
...(opts.name ? { name: opts.name } : {}),
|
|
118
|
-
...(tags ? { tags } : {}),
|
|
119
|
-
});
|
|
120
|
-
out(cmd, { ok: !!r.ok, ...r });
|
|
121
|
-
});
|
|
122
|
-
cmd.command('validate <id> <file>')
|
|
123
|
-
.description('Validate a diff-JSON file against a workflow (§9 gate, never persists)')
|
|
124
|
-
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
125
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
126
|
-
.action(async (id, file, opts) => {
|
|
127
|
-
if (!existsSync(file)) {
|
|
128
|
-
out(cmd, { ok: false, error: `not found: ${file}` });
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
const diff = JSON.parse(readFileSync(file, 'utf8'));
|
|
132
|
-
const r = await call(opts.api, opts.slug, 'workflow:validate', { workflowId: id, diff });
|
|
133
|
-
out(cmd, { ok: !!r.ok, ...r });
|
|
134
|
-
});
|
|
135
|
-
cmd.command('resolve <runId> <stepId>')
|
|
136
|
-
.description('Resolve a suspended human step in a run (--decision approved|rejected)')
|
|
137
|
-
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
138
|
-
.option('--decision <d>', 'approved | rejected')
|
|
139
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
140
|
-
.action(async (runId, stepId, opts) => {
|
|
141
|
-
const r = await call(opts.api, opts.slug, 'human:resolve', { runId, stepId, ...(opts.decision ? { decision: opts.decision } : {}) });
|
|
142
|
-
out(cmd, { ok: !!r.ok, ...r });
|
|
143
|
-
});
|
|
144
|
-
cmd.command('logs <id>')
|
|
145
|
-
.description("List recent runs of a workflow; --run <runId> for one run's step-event timeline")
|
|
146
|
-
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
147
|
-
.option('--run <runId>', "Return this run's event timeline")
|
|
148
|
-
.option('--limit <n>', 'Max runs to list', (v) => parseInt(v, 10))
|
|
149
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
150
|
-
.action(async (id, opts) => {
|
|
151
|
-
const r = await call(opts.api, opts.slug, 'workflow:runs', { workflowId: id, ...(opts.run ? { runId: opts.run } : {}), ...(opts.limit ? { limit: opts.limit } : {}) });
|
|
152
|
-
out(cmd, { ok: !r.error, ...r });
|
|
153
|
-
});
|
|
154
|
-
return cmd;
|
|
155
|
-
}
|
|
156
|
-
// out() mirrors agent.ts — human `✓ k=v` or --json. W3: reuse the shared helper if
|
|
157
|
-
// one is exported; otherwise copy agent.ts's local out().
|
|
158
|
-
function out(cmd, data) {
|
|
159
|
-
const json = cmd.parent?.opts()?.json ?? false;
|
|
160
|
-
if (json) {
|
|
161
|
-
process.stdout.write(JSON.stringify(data) + '\n');
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const line = Object.entries(data).map(([k, v]) => `${k}=${typeof v === 'object' ? JSON.stringify(v) : v}`).join(' ');
|
|
165
|
-
process.stdout.write((data.ok ? '✓ ' : '✗ ') + line + '\n');
|
|
166
|
-
}
|
package/dist/src/write.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* write.ts — `one write <slug> --to age1… [file|-]`: seal a note HERE, on this machine,
|
|
3
|
-
* and drop the ciphertext in a holder's inbox through the door already live on one.ie.
|
|
4
|
-
*
|
|
5
|
-
* POST <web base>/api/write { ws, sealed, from? }
|
|
6
|
-
*
|
|
7
|
-
* THE PLAINTEXT NEVER LEAVES THIS PROCESS. The note is sealed to the `--to` lock(s)
|
|
8
|
-
* before any request is built, and the request body is built from the armored block and
|
|
9
|
-
* the slug alone — `sealNote` takes the plaintext, `postSealed` takes only what is
|
|
10
|
-
* already sealed, and a test pins that the posted body does not contain the note.
|
|
11
|
-
* The door itself refuses anything that is not one armored age block.
|
|
12
|
-
*
|
|
13
|
-
* `/api/write` is a WEB route (one.ie), not a gateway receiver, so this does not go
|
|
14
|
-
* through `askPath`. An env base that points at the gateway (api.one.ie) would 404, so
|
|
15
|
-
* unless `--api` names a host explicitly, that base is replaced with https://one.ie.
|
|
16
|
-
*
|
|
17
|
-
* `--to` is the literal `age1…` the holder gave you, used as given — no lookup, no check.
|
|
18
|
-
* Leave `--to` off and the name's PUBLISHED lock is looked up and verified here first
|
|
19
|
-
* (lib/lock-lookup.ts: GET /api/lock/<slug>, the Sui signature re-checked locally). An
|
|
20
|
-
* unpublished name, a lookup that is not live or unreachable, or a lock that does not
|
|
21
|
-
* verify stops the note before anything is sealed or posted — it never falls back to a
|
|
22
|
-
* lock nobody checked.
|
|
23
|
-
*/
|
|
24
|
-
import { Command } from 'commander';
|
|
25
|
-
import { type Fail } from './lib/message-seal.js';
|
|
26
|
-
/** The door's own limits (one.ie/web pages/api/write.ts + lib/key/sealed-post.ts). */
|
|
27
|
-
export declare const SEALED_MAX_CHARS = 8000;
|
|
28
|
-
export declare function writeBase(explicit?: string, env?: NodeJS.ProcessEnv): string;
|
|
29
|
-
/** Plaintext in, armored block out — or a plain refusal. Nothing here touches the network. */
|
|
30
|
-
export declare function sealNote(note: Uint8Array, locks: string[]): Promise<{
|
|
31
|
-
ok: true;
|
|
32
|
-
sealed: string;
|
|
33
|
-
} | Fail>;
|
|
34
|
-
export interface PostResult {
|
|
35
|
-
ok: true;
|
|
36
|
-
workspace: string;
|
|
37
|
-
threadId: string | null;
|
|
38
|
-
messageId: string | null;
|
|
39
|
-
sealedChars: number;
|
|
40
|
-
}
|
|
41
|
-
/** Post an ALREADY SEALED block. Its inputs carry no plaintext, by signature. */
|
|
42
|
-
export declare function postSealed(base: string, ws: string, sealed: string, from: string | undefined, fetchImpl?: typeof fetch): Promise<PostResult | Fail>;
|
|
43
|
-
export declare function writeCmd(): Command;
|
package/dist/src/write.js
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* write.ts — `one write <slug> --to age1… [file|-]`: seal a note HERE, on this machine,
|
|
3
|
-
* and drop the ciphertext in a holder's inbox through the door already live on one.ie.
|
|
4
|
-
*
|
|
5
|
-
* POST <web base>/api/write { ws, sealed, from? }
|
|
6
|
-
*
|
|
7
|
-
* THE PLAINTEXT NEVER LEAVES THIS PROCESS. The note is sealed to the `--to` lock(s)
|
|
8
|
-
* before any request is built, and the request body is built from the armored block and
|
|
9
|
-
* the slug alone — `sealNote` takes the plaintext, `postSealed` takes only what is
|
|
10
|
-
* already sealed, and a test pins that the posted body does not contain the note.
|
|
11
|
-
* The door itself refuses anything that is not one armored age block.
|
|
12
|
-
*
|
|
13
|
-
* `/api/write` is a WEB route (one.ie), not a gateway receiver, so this does not go
|
|
14
|
-
* through `askPath`. An env base that points at the gateway (api.one.ie) would 404, so
|
|
15
|
-
* unless `--api` names a host explicitly, that base is replaced with https://one.ie.
|
|
16
|
-
*
|
|
17
|
-
* `--to` is the literal `age1…` the holder gave you, used as given — no lookup, no check.
|
|
18
|
-
* Leave `--to` off and the name's PUBLISHED lock is looked up and verified here first
|
|
19
|
-
* (lib/lock-lookup.ts: GET /api/lock/<slug>, the Sui signature re-checked locally). An
|
|
20
|
-
* unpublished name, a lookup that is not live or unreachable, or a lock that does not
|
|
21
|
-
* verify stops the note before anything is sealed or posted — it never falls back to a
|
|
22
|
-
* lock nobody checked.
|
|
23
|
-
*/
|
|
24
|
-
import { Command } from 'commander';
|
|
25
|
-
import { jsonMode } from './lib/client.js';
|
|
26
|
-
import { exitFor, lookupLock } from './lib/lock-lookup.js';
|
|
27
|
-
import { ageModule, readNote } from './lib/message-seal.js';
|
|
28
|
-
/** The door's own limits (one.ie/web pages/api/write.ts + lib/key/sealed-post.ts). */
|
|
29
|
-
export const SEALED_MAX_CHARS = 8000;
|
|
30
|
-
const SLUG_RE = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
31
|
-
const AGENT_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
32
|
-
const FROM_MAX = 60;
|
|
33
|
-
const DEADLINE_MS = 15_000;
|
|
34
|
-
const WEB = 'https://one.ie';
|
|
35
|
-
export function writeBase(explicit, env = process.env) {
|
|
36
|
-
const pick = explicit ?? env.ONE_API_URL ?? env.ONEIE_BASE_URL ?? WEB;
|
|
37
|
-
const base = pick.replace(/\/$/, '');
|
|
38
|
-
if (!explicit) {
|
|
39
|
-
try {
|
|
40
|
-
if (new URL(base).hostname === 'api.one.ie')
|
|
41
|
-
return WEB;
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
/* an unparseable env base falls through and fails at fetch with a plain sentence */
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return base;
|
|
48
|
-
}
|
|
49
|
-
const collect = (v, prev = []) => [...prev, v];
|
|
50
|
-
/** Plaintext in, armored block out — or a plain refusal. Nothing here touches the network. */
|
|
51
|
-
export async function sealNote(note, locks) {
|
|
52
|
-
if (locks.length === 0)
|
|
53
|
-
return { ok: false, error: 'seal it to someone — pass --to age1…', code: 'no_recipient' };
|
|
54
|
-
const age = await ageModule();
|
|
55
|
-
for (const l of locks) {
|
|
56
|
-
try {
|
|
57
|
-
age.decodeRecipient(l);
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
return { ok: false, error: `${l} is not an age lock — it starts age1…`, code: 'bad_key' };
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return { ok: true, sealed: age.armor(age.encrypt(note, [...new Set(locks.map((l) => l.trim()))])) };
|
|
64
|
-
}
|
|
65
|
-
/** Post an ALREADY SEALED block. Its inputs carry no plaintext, by signature. */
|
|
66
|
-
export async function postSealed(base, ws, sealed, from, fetchImpl = fetch) {
|
|
67
|
-
// The door reads `name` (writerLabel → "Sam (not verified)") and ignores `from`; sending
|
|
68
|
-
// `from` made every CLI note arrive as "Someone with your lock".
|
|
69
|
-
const body = { ws, sealed };
|
|
70
|
-
if (from)
|
|
71
|
-
body.name = from;
|
|
72
|
-
const ctl = new AbortController();
|
|
73
|
-
const timer = setTimeout(() => ctl.abort(), DEADLINE_MS);
|
|
74
|
-
let res;
|
|
75
|
-
try {
|
|
76
|
-
res = await fetchImpl(`${base}/api/write`, {
|
|
77
|
-
method: 'POST',
|
|
78
|
-
headers: { 'content-type': 'application/json' },
|
|
79
|
-
body: JSON.stringify(body),
|
|
80
|
-
signal: ctl.signal,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return { ok: false, error: `could not reach ${base} — the note was sealed but not sent`, code: 'unreachable' };
|
|
85
|
-
}
|
|
86
|
-
finally {
|
|
87
|
-
clearTimeout(timer);
|
|
88
|
-
}
|
|
89
|
-
let j = {};
|
|
90
|
-
try {
|
|
91
|
-
j = (await res.json());
|
|
92
|
-
}
|
|
93
|
-
catch {
|
|
94
|
-
/* a non-JSON body is reported by status below */
|
|
95
|
-
}
|
|
96
|
-
if (res.status === 429 && j.error === 'inbox_busy')
|
|
97
|
-
return { ok: false, error: 'this inbox is busy — it has taken its 60 notes for these ten minutes; wait a minute and try again', code: 'inbox_busy' };
|
|
98
|
-
if (res.status === 429)
|
|
99
|
-
return { ok: false, error: 'too many notes from this address — the door takes ten a minute; wait and try again', code: 'rate_limited' };
|
|
100
|
-
if (res.ok && j.ok)
|
|
101
|
-
return { ok: true, workspace: ws, threadId: j.threadId ?? null, messageId: j.messageId ?? null, sealedChars: sealed.length };
|
|
102
|
-
switch (j.error) {
|
|
103
|
-
case 'bad_workspace':
|
|
104
|
-
return { ok: false, error: `"${ws}" is not a workspace name`, code: 'bad_workspace' };
|
|
105
|
-
case 'unknown_workspace':
|
|
106
|
-
return { ok: false, error: `there is no workspace called "${ws}" on ${base}`, code: 'unknown_workspace' };
|
|
107
|
-
case 'too_large':
|
|
108
|
-
return { ok: false, error: 'the door refused it — the sealed note is over its size cap', code: 'too_large' };
|
|
109
|
-
case 'not_sealed':
|
|
110
|
-
return { ok: false, error: 'the door refused it — it is not one armored age block', code: 'not_sealed' };
|
|
111
|
-
default:
|
|
112
|
-
return { ok: false, error: `the door answered ${res.status}${j.error ? ` (${j.error})` : ''} — nothing was delivered`, code: j.error ?? 'failed' };
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
export function writeCmd() {
|
|
116
|
-
return new Command('write')
|
|
117
|
-
.description("Seal a note on this machine to someone's age1… lock and drop it in their inbox on one.ie (/api/write). Plaintext never leaves")
|
|
118
|
-
.argument('<slug>', "The holder's workspace name, or <workspace>/<agent-id> for an agent's own lock (the note still lands in the workspace's sealed notes)")
|
|
119
|
-
.argument('[file]', 'The note to send; omit or "-" to read stdin')
|
|
120
|
-
.option('--to <lock>', 'The holder\'s age1… lock (repeat to seal to several). Omit it to use the lock <slug> has PUBLISHED, checked here first', collect)
|
|
121
|
-
.option('--from <name>', `A display name for you, up to ${FROM_MAX} characters — a label, never proof of who you are`)
|
|
122
|
-
.option('--api <url>', 'Web base (default https://one.ie; /api/write is a web route, not on the gateway)')
|
|
123
|
-
.action(async (nameArg, file, o, c) => {
|
|
124
|
-
const refuse = (f) => {
|
|
125
|
-
if (jsonMode(c))
|
|
126
|
-
process.stdout.write(JSON.stringify(f) + '\n');
|
|
127
|
-
else
|
|
128
|
-
process.stderr.write(`error ${f.error}\n`);
|
|
129
|
-
process.exitCode = 1;
|
|
130
|
-
};
|
|
131
|
-
// `sam` or `sam/scout`: the workspace half is where the note lands; the whole name
|
|
132
|
-
// is what gets looked up, so an agent's lock is checked against ITS name, never sam's.
|
|
133
|
-
const name = nameArg.trim();
|
|
134
|
-
const ws = name.split('/')[0].toLowerCase();
|
|
135
|
-
if (!SLUG_RE.test(ws))
|
|
136
|
-
return refuse({ ok: false, error: `"${nameArg}" is not a workspace name — lowercase letters, digits and dashes`, code: 'bad_workspace' });
|
|
137
|
-
const agentPart = name.includes('/') ? name.slice(name.indexOf('/') + 1) : undefined;
|
|
138
|
-
if (agentPart !== undefined && !AGENT_NAME_RE.test(agentPart)) {
|
|
139
|
-
return refuse({ ok: false, error: `"${nameArg}" is not an agent name — <workspace>/<agent-id>`, code: 'bad_agent' });
|
|
140
|
-
}
|
|
141
|
-
const from = o.from?.trim();
|
|
142
|
-
if (from && from.length > FROM_MAX)
|
|
143
|
-
return refuse({ ok: false, error: `--from is ${from.length} characters; the door keeps ${FROM_MAX}`, code: 'from_too_long' });
|
|
144
|
-
// No --to: seal to the name's published lock, but only one that verifies HERE.
|
|
145
|
-
let locks = o.to ?? [];
|
|
146
|
-
let checked;
|
|
147
|
-
if (locks.length === 0) {
|
|
148
|
-
const found = await lookupLock(writeBase(o.api), agentPart === undefined ? ws : `${ws}/${agentPart}`);
|
|
149
|
-
if (!found.ok) {
|
|
150
|
-
refuse(found);
|
|
151
|
-
process.exitCode = exitFor(found.code);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
checked = found;
|
|
155
|
-
locks = [found.lock];
|
|
156
|
-
}
|
|
157
|
-
const note = await readNote(file);
|
|
158
|
-
if ('ok' in note)
|
|
159
|
-
return refuse(note);
|
|
160
|
-
const sealed = await sealNote(note, locks);
|
|
161
|
-
if (!sealed.ok)
|
|
162
|
-
return refuse(sealed);
|
|
163
|
-
if (sealed.sealed.length > SEALED_MAX_CHARS) {
|
|
164
|
-
return refuse({
|
|
165
|
-
ok: false,
|
|
166
|
-
error: `sealed, this note is ${sealed.sealed.length} characters and the door takes ${SEALED_MAX_CHARS} — send a shorter note, or fewer locks. Nothing was sent`,
|
|
167
|
-
code: 'too_long',
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
const r = await postSealed(writeBase(o.api), ws, sealed.sealed, from);
|
|
171
|
-
if (!r.ok)
|
|
172
|
-
return refuse(r);
|
|
173
|
-
if (jsonMode(c))
|
|
174
|
-
process.stdout.write(JSON.stringify(checked ? { ...r, name: checked.name, lock: checked.lock, suiAddress: checked.suiAddress, lockChecked: true } : r) + '\n');
|
|
175
|
-
else if (checked)
|
|
176
|
-
process.stdout.write(`sent sealed to ${checked.name}'s published lock (signature checked, signed by Sui address ${checked.suiAddress}), ${r.sealedChars} characters, into ${ws}'s sealed notes\n`);
|
|
177
|
-
else
|
|
178
|
-
process.stdout.write(`sent sealed to ${new Set(o.to).size} lock(s), ${r.sealedChars} characters, into ${ws}'s sealed notes\n`);
|
|
179
|
-
});
|
|
180
|
-
}
|