oneie 5.2.0 → 5.2.2

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.
@@ -0,0 +1,270 @@
1
+ /**
2
+ * key.ts — `one key new | recover | public | verify`, the text/key.md door on a terminal.
3
+ *
4
+ * A VERB OVER WALLET KEYGEN, NOT A SECOND DERIVATION. Every address comes from
5
+ * `@oneie/sdk/wallet` — the same core `one wallet keygen`, packages/recover and
6
+ * the browser (by parity test) derive with. The public identity is the SDK's
7
+ * `@oneie/sdk/key-identity`, byte-identical to one.ie/web's `deriveUserIdPub`.
8
+ *
9
+ * THE KEY NEVER LEAVES THIS MACHINE.
10
+ * • new · recover · public make no network call at all.
11
+ * • verify makes one kind of call — `fetchReferences(base, apiKey)` — and it is
12
+ * structurally unable to send the key: its only inputs are a URL and the API
13
+ * key. It reads the public identities the server holds and the comparison
14
+ * happens HERE, so not even the public identity is transmitted.
15
+ * • The words never come from argv (shell history, `ps`): env or stdin, or a
16
+ * hidden prompt on a terminal. An argv token is never echoed — it may BE the
17
+ * phrase.
18
+ * • Under --json the words never reach stdout (an agent's stdout is a model
19
+ * context and a session log). They reach disk only behind keygen's own
20
+ * --yes-i-accept-plaintext-file, at 0600.
21
+ */
22
+ import { Command } from 'commander';
23
+ import { existsSync, readFileSync } from 'node:fs';
24
+ import { generateWallet, recoverWallet } from '@oneie/sdk/wallet';
25
+ import { userIdPubFromPhrase } from '@oneie/sdk/key-identity';
26
+ import { jsonMode, resolveBase, resolveKey } from './lib/client.js';
27
+ import { promptSecret, writeKeysFile } from './wallet.js';
28
+ const REFUSE_ARGV_SECRET = 'A secret on the command line is refused on purpose: it is written to your shell history and is ' +
29
+ 'visible in `ps` to every user on this machine. Set ONE_WALLET_MNEMONIC or pipe the words on stdin.';
30
+ const REFUSE_ARGV = 'Unrecognised argument. It is not repeated here on purpose — it may BE your recovery phrase. ' +
31
+ 'Words go on stdin or in ONE_WALLET_MNEMONIC, never on the command line. Run --help.';
32
+ const INVALID_PHRASE = 'That is not a valid 24-word BIP-39 recovery phrase. Nothing was derived.';
33
+ // text/key.md, verbatim in substance: the difference is silent and it costs money.
34
+ const NOT_SUI = 'These 24 words are not a Sui wallet mnemonic under v1: ONE derives every chain by HKDF from their ' +
35
+ '32 bytes of entropy, while a standard wallet derives by BIP-44/SLIP-0010 from the same phrase. ' +
36
+ 'Both succeed; the standard one shows different, empty addresses. Recover them here, at /key, or with @oneie/recover.';
37
+ const PAPER = 'Write these on paper. The paper is the only backup — ONE never holds this key and cannot recover it.';
38
+ function labelFor(d) {
39
+ return d === 'v2'
40
+ ? 'v2 — standard paths (BIP-44 / SLIP-0010). Any BIP-39 wallet recovers these.'
41
+ : 'v1 — original ONE derivation (HKDF labels). Only one.ie and @oneie/recover derive these.';
42
+ }
43
+ /** Field by field from the four chains — a private key has no route into the value. */
44
+ function addressesOf(w) {
45
+ const pick = (c) => w.keys.find((k) => k.chain === c)?.address ?? '';
46
+ return { sui: pick('sui'), evm: pick('evm'), sol: pick('sol'), btc: pick('btc') };
47
+ }
48
+ function fail(cmd, error) {
49
+ if (jsonMode(cmd))
50
+ process.stdout.write(JSON.stringify({ ok: false, error }) + '\n');
51
+ else
52
+ process.stderr.write(`error ${error}\n`);
53
+ process.exitCode = 1;
54
+ }
55
+ function done(cmd, data) {
56
+ if (jsonMode(cmd)) {
57
+ process.stdout.write(JSON.stringify(data) + '\n');
58
+ return;
59
+ }
60
+ const lines = Object.entries(data)
61
+ .filter(([k]) => k !== 'ok')
62
+ .map(([k, v]) => ` ${k}: ${typeof v === 'string' ? v : JSON.stringify(v)}`);
63
+ process.stdout.write(`ok\n${lines.join('\n')}\n`);
64
+ }
65
+ function readDerivationOpt(v) {
66
+ if (v === undefined || v === 'v1')
67
+ return 'v1';
68
+ if (v === 'v2')
69
+ return 'v2';
70
+ return null;
71
+ }
72
+ /** Refuse a secret-bearing flag or any stray argv token, never echoing it. */
73
+ function refuseArgv(cmd, opts, rest) {
74
+ if (opts.phrase !== undefined || opts.mnemonic !== undefined) {
75
+ fail(cmd, REFUSE_ARGV_SECRET);
76
+ return true;
77
+ }
78
+ if (rest.length > 0) {
79
+ fail(cmd, REFUSE_ARGV);
80
+ return true;
81
+ }
82
+ return false;
83
+ }
84
+ /** The words: ONE_WALLET_MNEMONIC, else stdin when piped, else a hidden prompt. '' = none given. */
85
+ async function readWords() {
86
+ const fromEnv = process.env.ONE_WALLET_MNEMONIC?.trim();
87
+ if (fromEnv)
88
+ return fromEnv;
89
+ if (!process.stdin.isTTY) {
90
+ try {
91
+ return readFileSync(0, 'utf8').trim();
92
+ }
93
+ catch {
94
+ return '';
95
+ }
96
+ }
97
+ return (await promptSecret('Your 24 words (hidden): ')).trim();
98
+ }
99
+ /** Adds the two refused secret flags and the argv catch-all every word-reading verb shares. */
100
+ function wordsCommand(name, description) {
101
+ return new Command(name)
102
+ .description(description)
103
+ .argument('[refused...]')
104
+ .allowUnknownOption()
105
+ .option('--phrase [words]', 'REFUSED — never put the words on the command line')
106
+ .option('--mnemonic [words]', 'REFUSED — never put the words on the command line');
107
+ }
108
+ /**
109
+ * The public identities the server holds for the caller: `vault_blob.user_id_pub`
110
+ * and every `vault_passkey_hints.user_id_pub` (the same two sources /keys reads).
111
+ * Its only inputs are a URL and the API key — nothing derived from the key can
112
+ * reach the request, by signature.
113
+ */
114
+ async function fetchReferences(base, apiKey) {
115
+ const out = [];
116
+ for (const path of ['/api/vault/sync', '/api/vault/devices']) {
117
+ try {
118
+ const res = await fetch(base + path, { headers: { Authorization: `Bearer ${apiKey}` } });
119
+ if (path === '/api/vault/sync' && res.status === 404) {
120
+ out.push({ answered: true, ids: [] });
121
+ continue;
122
+ }
123
+ if (!res.ok) {
124
+ out.push({ answered: false, ids: [] });
125
+ continue;
126
+ }
127
+ const body = (await res.json());
128
+ const raw = path === '/api/vault/sync' ? [body.userIdPub] : (body.devices ?? []).map((d) => d?.userIdPub);
129
+ out.push({ answered: true, ids: raw.filter((r) => typeof r === 'string' && r.length > 0) });
130
+ }
131
+ catch {
132
+ out.push({ answered: false, ids: [] });
133
+ }
134
+ }
135
+ return out;
136
+ }
137
+ function verdictOf(local, refs) {
138
+ if (!local)
139
+ return 'locked';
140
+ if (refs.length === 0)
141
+ return 'unregistered';
142
+ return refs.includes(local) ? 'verified' : 'mismatch';
143
+ }
144
+ // ── the command ──────────────────────────────────────────────────────────────
145
+ export function keyCmd() {
146
+ const cmd = new Command('key').description('One key — new · recover · public · verify. Offline except verify, which sends only your API key');
147
+ cmd.command('new')
148
+ .description('Mint a key on this machine: 24 words, printed ONCE, for paper. No network')
149
+ .option('--derivation <v>', 'v1 (default — what one.ie mints) or v2 (standard BIP-44 paths)', 'v1')
150
+ .option('--out <file>', 'Write the words + keys to a file at mode 0600 instead of printing them')
151
+ .option('--yes-i-accept-plaintext-file', 'Required with --out — acknowledge that unencrypted key material will be written to disk')
152
+ .action(async (opts, sub) => {
153
+ const derivation = readDerivationOpt(opts.derivation);
154
+ if (!derivation)
155
+ return fail(sub, '--derivation must be v1 or v2');
156
+ // Refuse BEFORE minting: words that exist only in a process about to exit are lost money.
157
+ if (opts.out && !opts.yesIAcceptPlaintextFile) {
158
+ return fail(sub, 'refusing to write plaintext key material to disk — pass --yes-i-accept-plaintext-file to override');
159
+ }
160
+ if (opts.out && existsSync(opts.out))
161
+ return fail(sub, 'that file already exists — move it aside first; a key file is never overwritten');
162
+ if (!opts.out && jsonMode(sub)) {
163
+ return fail(sub, 'refusing to print the words under --json — stdout may be a log or a model context. Use --out <file> --yes-i-accept-plaintext-file');
164
+ }
165
+ const wallet = await generateWallet(derivation);
166
+ const addresses = addressesOf(wallet);
167
+ const userIdPub = await userIdPubFromPhrase(wallet.mnemonic);
168
+ if (opts.out) {
169
+ const contents = JSON.stringify({ mnemonic: wallet.mnemonic, derivation, userIdPub, addresses, keys: wallet.keys }, null, 2) + '\n';
170
+ writeKeysFile(opts.out, contents, true);
171
+ return done(sub, { ok: true, out: opts.out, derivation, label: labelFor(derivation), addresses, userIdPub });
172
+ }
173
+ // Straight to stdout, never through a JSON receipt (refused above).
174
+ const words = wallet.mnemonic.split(' ');
175
+ const sheet = words.map((w, i) => `${String(i + 1).padStart(4)}. ${w}`).join('\n');
176
+ process.stdout.write(`\n${PAPER}\n\n${sheet}\n\n${NOT_SUI}\n\n` +
177
+ `derivation ${labelFor(derivation)}\n` +
178
+ Object.entries(addresses).map(([c, a]) => `${c.padEnd(11)} ${a}`).join('\n') +
179
+ `\nidentity ${userIdPub}\n\nThis is the only time the words are shown. Close the terminal when they are on paper.\n`);
180
+ });
181
+ cmd.addCommand(wordsCommand('recover', 'Rebuild a key from its 24 words (stdin or ONE_WALLET_MNEMONIC) — both address sets, no network')
182
+ .option('--derivation <v>', 'which set --out writes: v1 (default) or v2', 'v1')
183
+ .option('--out <file>', 'Write the words + keys to a file at mode 0600')
184
+ .option('--yes-i-accept-plaintext-file', 'Required with --out')
185
+ .action(async (rest, opts, sub) => {
186
+ if (refuseArgv(sub, opts, rest))
187
+ return;
188
+ const derivation = readDerivationOpt(opts.derivation);
189
+ if (!derivation)
190
+ return fail(sub, '--derivation must be v1 or v2');
191
+ if (opts.out && !opts.yesIAcceptPlaintextFile) {
192
+ return fail(sub, 'refusing to write plaintext key material to disk — pass --yes-i-accept-plaintext-file to override');
193
+ }
194
+ const words = await readWords();
195
+ let v1, v2, userIdPub;
196
+ try {
197
+ v1 = await recoverWallet(words, 'v1');
198
+ v2 = await recoverWallet(words, 'v2');
199
+ userIdPub = await userIdPubFromPhrase(words);
200
+ }
201
+ catch {
202
+ return fail(sub, INVALID_PHRASE);
203
+ }
204
+ if (opts.out) {
205
+ if (existsSync(opts.out))
206
+ return fail(sub, 'that file already exists — move it aside first; a key file is never overwritten');
207
+ const w = derivation === 'v2' ? v2 : v1;
208
+ writeKeysFile(opts.out, JSON.stringify({ mnemonic: w.mnemonic, derivation, userIdPub, addresses: addressesOf(w), keys: w.keys }, null, 2) + '\n', true);
209
+ }
210
+ done(sub, {
211
+ ok: true,
212
+ userIdPub,
213
+ v1: { label: labelFor('v1'), addresses: addressesOf(v1) },
214
+ v2: { label: labelFor('v2'), addresses: addressesOf(v2) },
215
+ ...(opts.out ? { out: opts.out, wrote: derivation } : {}),
216
+ });
217
+ }));
218
+ cmd.addCommand(wordsCommand('public', 'The public identity + the four chain addresses for your words — nothing secret, no network')
219
+ .option('--derivation <v>', 'v1 (default) or v2', 'v1')
220
+ .action(async (rest, opts, sub) => {
221
+ if (refuseArgv(sub, opts, rest))
222
+ return;
223
+ const derivation = readDerivationOpt(opts.derivation);
224
+ if (!derivation)
225
+ return fail(sub, '--derivation must be v1 or v2');
226
+ const words = await readWords();
227
+ let wallet, userIdPub;
228
+ try {
229
+ wallet = await recoverWallet(words, derivation);
230
+ userIdPub = await userIdPubFromPhrase(words);
231
+ }
232
+ catch {
233
+ return fail(sub, INVALID_PHRASE);
234
+ }
235
+ done(sub, { ok: true, derivation, label: labelFor(derivation), addresses: addressesOf(wallet), userIdPub });
236
+ }));
237
+ cmd.addCommand(wordsCommand('verify', "Compare this key's public identity with what the server holds — locked | verified | mismatch | unregistered")
238
+ .option('--api <url>', 'API base URL (default https://one.ie)')
239
+ .action(async (rest, opts, sub) => {
240
+ if (refuseArgv(sub, opts, rest))
241
+ return;
242
+ const words = await readWords();
243
+ if (!words) {
244
+ done(sub, { ok: true, verdict: 'locked', note: 'no words given — nothing to compare, and no request was made' });
245
+ process.exitCode = 1;
246
+ return;
247
+ }
248
+ let local;
249
+ try {
250
+ local = await userIdPubFromPhrase(words);
251
+ }
252
+ catch {
253
+ return fail(sub, INVALID_PHRASE);
254
+ }
255
+ const apiKey = resolveKey();
256
+ if (!apiKey)
257
+ return fail(sub, 'no API key — set ONE_API_KEY or run: one login');
258
+ const refs = await fetchReferences(resolveBase({ api: opts.api }, 'https://one.ie'), apiKey);
259
+ const verdict = verdictOf(local, refs.flatMap((r) => r.ids));
260
+ // `unregistered` is a claim about ABSENCE: believable only when every source
261
+ // answered. A refused or failed probe is inconclusive, never "not registered".
262
+ if (verdict === 'unregistered' && refs.some((r) => !r.answered)) {
263
+ return fail(sub, 'inconclusive — the server did not answer (auth refused or unreachable), so absence cannot be claimed. A key that is not a person\'s own login also reads as nothing here');
264
+ }
265
+ done(sub, { ok: true, verdict, userIdPub: local });
266
+ if (verdict === 'mismatch')
267
+ process.exitCode = 1;
268
+ }));
269
+ return cmd;
270
+ }
@@ -0,0 +1,34 @@
1
+ import { type Asker } from '@oneie/sdk/tasks-bulk';
2
+ export interface AskFailure {
3
+ retryable: boolean;
4
+ httpStatus: number;
5
+ error: string;
6
+ }
7
+ /** EX_TEMPFAIL — the exit code a caller can branch on to retry. */
8
+ export declare const RETRYABLE_EXIT = 75;
9
+ export declare class AskError extends Error {
10
+ readonly retryable: boolean;
11
+ readonly httpStatus: number;
12
+ readonly receiver: string;
13
+ constructor(receiver: string, f: AskFailure);
14
+ }
15
+ export declare function isRetryableStatus(status: number): boolean;
16
+ export declare function classifyResponse(receiver: string, status: number, text: string): {
17
+ ok: true;
18
+ body: unknown;
19
+ } | {
20
+ ok: false;
21
+ failure: AskFailure;
22
+ };
23
+ /**
24
+ * The verdict to attach to a message, or none. The CLI keeps the last failure in one
25
+ * slot; a message that does not carry that failure's text is about something else,
26
+ * and a stale 502 must never turn an unrelated refusal into "retry me".
27
+ */
28
+ export declare function failureFor(msg: string, last: AskFailure | undefined): AskFailure | undefined;
29
+ export declare function exitCodeFor(f: AskFailure | undefined): number;
30
+ export declare function makeAsker(base: string, opts: {
31
+ fetchImpl?: typeof fetch;
32
+ headers: Record<string, string>;
33
+ onFailure?: (f: AskFailure) => void;
34
+ }): Asker;
@@ -0,0 +1,126 @@
1
+ import { unwrapAsk } from '@oneie/sdk/tasks-bulk';
2
+ import { askPath } from './api-path.js';
3
+ /** EX_TEMPFAIL — the exit code a caller can branch on to retry. */
4
+ export const RETRYABLE_EXIT = 75;
5
+ export class AskError extends Error {
6
+ retryable;
7
+ httpStatus;
8
+ receiver;
9
+ constructor(receiver, f) {
10
+ super(f.error);
11
+ this.name = 'AskError';
12
+ this.retryable = f.retryable;
13
+ this.httpStatus = f.httpStatus;
14
+ this.receiver = receiver;
15
+ }
16
+ }
17
+ export function isRetryableStatus(status) {
18
+ if (status === 0 || status === 408 || status === 429)
19
+ return true;
20
+ if (status === 502 || status === 503 || status === 504)
21
+ return true;
22
+ if (status >= 520 && status <= 529)
23
+ return true;
24
+ return false;
25
+ }
26
+ function extractTitleLabel(text) {
27
+ // Remove all HTML tags to get raw text
28
+ const noTags = text.replace(/<[^>]*>/g, '');
29
+ // Collapse whitespace
30
+ const collapsed = noTags.replace(/\s+/g, ' ').trim();
31
+ if (!collapsed)
32
+ return '';
33
+ // Try to extract title from original HTML
34
+ const titleMatch = text.match(/<title[^>]*>([^<]*)<\/title>/i);
35
+ if (titleMatch) {
36
+ const title = titleMatch[1].trim();
37
+ if (title)
38
+ return title.slice(0, 60);
39
+ }
40
+ return collapsed.slice(0, 60);
41
+ }
42
+ export function classifyResponse(receiver, status, text) {
43
+ let body;
44
+ let parseOk = false;
45
+ try {
46
+ body = text.length === 0 ? undefined : JSON.parse(text);
47
+ parseOk = true;
48
+ }
49
+ catch {
50
+ // not JSON
51
+ }
52
+ if (parseOk) {
53
+ // The door's own error envelope ({ ok:false, outcome, retryable, httpStatus },
54
+ // feat/collab-receivers 9623fe50b) carries `outcome` too — read its verdict
55
+ // before the pass-through below mistakes it for a receiver refusal.
56
+ const e = body;
57
+ if (e && typeof e === 'object' && e.ok === false && typeof e.retryable === 'boolean') {
58
+ const httpStatus = typeof e.httpStatus === 'number' ? e.httpStatus : status;
59
+ return { ok: false, failure: { retryable: e.retryable, httpStatus, error: `${receiver} → ${status} ${typeof e.error === 'string' ? e.error : 'error'}` } };
60
+ }
61
+ if (typeof body === 'object' && body !== null && 'outcome' in body) {
62
+ return { ok: true, body };
63
+ }
64
+ if (status >= 200 && status < 300) {
65
+ return { ok: true, body };
66
+ }
67
+ // failure: use body fields if present
68
+ const b = body;
69
+ const retryable = typeof b?.retryable === 'boolean' ? b.retryable : isRetryableStatus(status);
70
+ const httpStatus = typeof b?.httpStatus === 'number' ? b.httpStatus : status;
71
+ const errorMsg = typeof b?.error === 'string' ? b.error : 'error';
72
+ return {
73
+ ok: false,
74
+ failure: { retryable, httpStatus, error: `${receiver} → ${status} ${errorMsg}` },
75
+ };
76
+ }
77
+ // Non-JSON response
78
+ const label = extractTitleLabel(text);
79
+ const error = `${receiver} → ${status} non-JSON response (${label})`;
80
+ // Ensure no raw '<html>' appears
81
+ const cleanError = error.replace(/<html>/gi, '[html]');
82
+ return {
83
+ ok: false,
84
+ failure: { retryable: isRetryableStatus(status), httpStatus: status, error: cleanError },
85
+ };
86
+ }
87
+ /**
88
+ * The verdict to attach to a message, or none. The CLI keeps the last failure in one
89
+ * slot; a message that does not carry that failure's text is about something else,
90
+ * and a stale 502 must never turn an unrelated refusal into "retry me".
91
+ */
92
+ export function failureFor(msg, last) {
93
+ return last && msg.includes(last.error) ? last : undefined;
94
+ }
95
+ export function exitCodeFor(f) {
96
+ return f?.retryable ? RETRYABLE_EXIT : 1;
97
+ }
98
+ export function makeAsker(base, opts) {
99
+ return async (receiver, data) => {
100
+ const url = askPath(base, receiver);
101
+ let res;
102
+ try {
103
+ res = await (opts.fetchImpl ?? fetch)(url, {
104
+ method: 'POST',
105
+ headers: opts.headers,
106
+ body: JSON.stringify({ data }),
107
+ });
108
+ }
109
+ catch (e) {
110
+ const failure = {
111
+ retryable: true,
112
+ httpStatus: 0,
113
+ error: `${receiver} → network: ${e instanceof Error ? e.message : String(e)}`,
114
+ };
115
+ opts.onFailure?.(failure);
116
+ throw new AskError(receiver, failure);
117
+ }
118
+ const text = await res.text();
119
+ const classified = classifyResponse(receiver, res.status, text);
120
+ if (!classified.ok) {
121
+ opts.onFailure?.(classified.failure);
122
+ throw new AskError(receiver, classified.failure);
123
+ }
124
+ return unwrapAsk(receiver, classified.body);
125
+ };
126
+ }
@@ -0,0 +1,86 @@
1
+ import { type Asker, type BoardRes, type BulkRes } from '@oneie/sdk/tasks-bulk';
2
+ /** All valid Flow IDs */
3
+ export declare const FLOWS: readonly ["card", "page", "write", "secure", "decide", "operate", "recon", "rollup"];
4
+ export type FlowId = (typeof FLOWS)[number];
5
+ /** Row metadata used to derive a flow */
6
+ export interface FlowRow {
7
+ role?: string | null;
8
+ family?: string | null;
9
+ rung?: string | null;
10
+ }
11
+ /** Valid role values (labels and signals) */
12
+ export declare const ROLES: readonly ["leaf", "epic", "operate", "decision", "recon", "settle", "dupe"];
13
+ /** Valid rung values */
14
+ export declare const RUNGS: readonly ["trivial", "contained", "shaped", "irreversible"];
15
+ /** Valid family values */
16
+ export declare const FAMILIES: readonly ["copy", "doc", "chain", "security", "schema", "astro-page", "puck-block", "ts-lib", "react-component", "react-hook", "receiver", "interface", "worker", "d1", "workflow", "eval", "test-gate", "perf"];
17
+ /** Compute the FlowId from a FlowRow (exact spec port) */
18
+ export declare function flowOf(row: FlowRow): FlowId | null;
19
+ /** Format a flow line for notes */
20
+ export declare function flowNote(flow: FlowId): string;
21
+ /** Check if notes already contain a Flow: line */
22
+ export declare function hasFlowLine(notes: string | null | undefined): boolean;
23
+ /** Append a flow line to notes (never modify existing text) */
24
+ export declare function appendFlowNote(notes: string | null | undefined, flow: FlowId): string;
25
+ export type SignalSource = 'notes' | 'tags' | 'classified';
26
+ export interface BoardRowIn {
27
+ tid: string;
28
+ name?: string;
29
+ status?: string;
30
+ notes?: string | null;
31
+ tags?: string[];
32
+ }
33
+ export interface ClassifiedRow {
34
+ tid: string;
35
+ role?: string | null;
36
+ family?: string | null;
37
+ rung?: string | null;
38
+ flow?: string | null;
39
+ }
40
+ /** Read signals from notes, tags, and classified data in priority order */
41
+ export declare function readSignals(row: BoardRowIn, classified?: ClassifiedRow): {
42
+ signals: FlowRow;
43
+ sources: SignalSource[];
44
+ };
45
+ export interface FlowPlanEdit {
46
+ tid: string;
47
+ notes: string;
48
+ addTags: string[];
49
+ }
50
+ export interface FlowPlan {
51
+ counts: Record<FlowId, number>;
52
+ placed: number;
53
+ unplaced: string[];
54
+ alreadyTagged: string[];
55
+ mismatches: {
56
+ tid: string;
57
+ computed: FlowId | null;
58
+ file: string;
59
+ }[];
60
+ bySource: Record<SignalSource, number>;
61
+ edits: FlowPlanEdit[];
62
+ }
63
+ /** Build a plan for applying flow tags to board rows */
64
+ export declare function planFlowTags(rows: BoardRowIn[], classified?: ClassifiedRow[]): FlowPlan;
65
+ export interface RunFlowOpts {
66
+ workspace?: string;
67
+ tree?: boolean;
68
+ status?: string;
69
+ apply?: boolean;
70
+ maxAgeSec?: number;
71
+ now?: number;
72
+ board?: BoardRes;
73
+ fresh?: boolean;
74
+ }
75
+ export interface RunFlowResult {
76
+ ok: boolean;
77
+ dryRun: boolean;
78
+ plan?: FlowPlan;
79
+ total?: number;
80
+ asOf?: string;
81
+ truncated?: unknown;
82
+ applied?: BulkRes;
83
+ error?: string;
84
+ }
85
+ /** Orchestrate the flow tag operation: plan and optionally apply */
86
+ export declare function runFlow(ask: Asker, classified: ClassifiedRow[], opts: RunFlowOpts): Promise<RunFlowResult>;