oneie 5.8.0 → 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/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 -134
- 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/ceiling.d.ts +0 -36
- package/dist/src/ceiling.js +0 -189
- package/dist/src/chat.d.ts +0 -2
- package/dist/src/chat.js +0 -92
- package/dist/src/check.d.ts +0 -11
- package/dist/src/check.js +0 -53
- 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/credits.d.ts +0 -29
- package/dist/src/credits.js +0 -88
- 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 -297
- 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 -270
- 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/check-words.d.ts +0 -57
- package/dist/src/lib/check-words.js +0 -144
- 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 -363
- package/dist/src/lib/journey.d.ts +0 -150
- package/dist/src/lib/journey.js +0 -264
- 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/net-choice.d.ts +0 -28
- package/dist/src/lib/net-choice.js +0 -72
- package/dist/src/lib/network.d.ts +0 -22
- package/dist/src/lib/network.js +0 -50
- package/dist/src/lib/next-words.d.ts +0 -105
- package/dist/src/lib/next-words.js +0 -298
- 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 -90
- package/dist/src/lib/sui-grpc-send.js +0 -128
- 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/timed-fetch.d.ts +0 -33
- package/dist/src/lib/timed-fetch.js +0 -59
- 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 -103
- package/dist/src/lib/vaultfile.js +0 -249
- 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/move.d.ts +0 -36
- package/dist/src/move.js +0 -152
- package/dist/src/network-cmd.d.ts +0 -17
- package/dist/src/network-cmd.js +0 -74
- package/dist/src/next.d.ts +0 -12
- package/dist/src/next.js +0 -67
- 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-buy.d.ts +0 -16
- package/dist/src/shop-buy.js +0 -101
- package/dist/src/shop.d.ts +0 -10
- package/dist/src/shop.js +0 -112
- 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 -27
- package/dist/src/start.js +0 -225
- 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/thread.d.ts +0 -2
- package/dist/src/thread.js +0 -52
- 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 -158
- package/dist/src/wallet-money.js +0 -664
- package/dist/src/wallet.d.ts +0 -169
- package/dist/src/wallet.js +0 -973
- package/dist/src/workflow.d.ts +0 -2
- package/dist/src/workflow.js +0 -169
- package/dist/src/write.d.ts +0 -43
- package/dist/src/write.js +0 -180
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
export function acceptOf(notes) {
|
|
5
|
-
const acceptLine = notes.split('\n').find(line => line.startsWith('Accept:'));
|
|
6
|
-
if (!acceptLine)
|
|
7
|
-
return null;
|
|
8
|
-
return acceptLine.slice('Accept:'.length).trim();
|
|
9
|
-
}
|
|
10
|
-
export function isHermetic(accept) {
|
|
11
|
-
const falsePatterns = ['curl', 'proof.sh route', '--window', '--since-ship'];
|
|
12
|
-
for (const pat of falsePatterns) {
|
|
13
|
-
if (accept.includes(pat))
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return accept.startsWith('bash .claude/scripts/proof.sh test ') || accept.includes('--self-test');
|
|
17
|
-
}
|
|
18
|
-
export function proveRows(rows, run) {
|
|
19
|
-
return rows.map(row => {
|
|
20
|
-
const accept = row.notes ? acceptOf(row.notes) : null;
|
|
21
|
-
if (accept && isHermetic(accept)) {
|
|
22
|
-
const exitCode = run(accept);
|
|
23
|
-
const verdict = exitCode === 0 ? 'proof-green — close?' : 'red';
|
|
24
|
-
return { tid: row.tid, verdict };
|
|
25
|
-
}
|
|
26
|
-
return { tid: row.tid, verdict: 'unproven' };
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
export function renderProve(results) {
|
|
30
|
-
return results.map(r => `${r.tid} ${r.verdict}`).join('\n');
|
|
31
|
-
}
|
|
32
|
-
export async function proveBoard(rows) {
|
|
33
|
-
const TOP = spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8' }).stdout.trim();
|
|
34
|
-
const pid = process.pid;
|
|
35
|
-
const worktreeName = `prove-${pid}`;
|
|
36
|
-
const worktreePath = join(TOP, '.claude', 'worktrees', worktreeName);
|
|
37
|
-
const upResult = spawnSync('bash', [
|
|
38
|
-
'-c',
|
|
39
|
-
`bash .claude/scripts/worktree-up.sh ${worktreeName} --no-dev --base origin/dev`
|
|
40
|
-
], {
|
|
41
|
-
cwd: TOP,
|
|
42
|
-
encoding: 'utf8',
|
|
43
|
-
});
|
|
44
|
-
if (upResult.status !== 0) {
|
|
45
|
-
if (upResult.stderr) {
|
|
46
|
-
process.stderr.write(upResult.stderr);
|
|
47
|
-
}
|
|
48
|
-
if (existsSync(worktreePath)) {
|
|
49
|
-
spawnSync('git', ['worktree', 'remove', '--force', worktreePath]);
|
|
50
|
-
}
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
const run = (accept) => {
|
|
55
|
-
const result = spawnSync('bash', ['-c', accept], {
|
|
56
|
-
cwd: worktreePath,
|
|
57
|
-
encoding: 'utf8',
|
|
58
|
-
});
|
|
59
|
-
return result.status ?? 1;
|
|
60
|
-
};
|
|
61
|
-
const results = proveRows(rows, run);
|
|
62
|
-
const output = renderProve(results);
|
|
63
|
-
process.stdout.write(output + '\n');
|
|
64
|
-
}
|
|
65
|
-
finally {
|
|
66
|
-
spawnSync('git', ['worktree', 'remove', '--force', worktreePath]);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type Row } from './tasks-digest.js';
|
|
2
|
-
import type { Seat } from './tasks-lens.js';
|
|
3
|
-
export interface Proposal {
|
|
4
|
-
tid: string;
|
|
5
|
-
assignee: string;
|
|
6
|
-
matched: string[];
|
|
7
|
-
workspace: string;
|
|
8
|
-
why: string;
|
|
9
|
-
}
|
|
10
|
-
export interface Unrouted {
|
|
11
|
-
tid: string;
|
|
12
|
-
tags: string[];
|
|
13
|
-
reason: 'no-stake' | 'tie';
|
|
14
|
-
candidates?: string[];
|
|
15
|
-
}
|
|
16
|
-
export interface RoutePlan {
|
|
17
|
-
unassigned: number;
|
|
18
|
-
proposals: Proposal[];
|
|
19
|
-
unrouted: Unrouted[];
|
|
20
|
-
unroutedByTag: Record<string, number>;
|
|
21
|
-
}
|
|
22
|
-
export declare function proposeOwners(rows: Row[], seats: Seat[]): RoutePlan;
|
|
23
|
-
export interface RouteEdit {
|
|
24
|
-
tid: string;
|
|
25
|
-
assignee: string;
|
|
26
|
-
workspace: string;
|
|
27
|
-
comment: string;
|
|
28
|
-
}
|
|
29
|
-
export declare function routeEdits(plan: RoutePlan): RouteEdit[];
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { CLOSED } from './tasks-digest.js';
|
|
2
|
-
/** The one tied seat every other tied seat reports up to (walking reportsTo), if any. */
|
|
3
|
-
function managerOf(tied, seats) {
|
|
4
|
-
const byId = new Map(seats.map((s) => [s.id, s]));
|
|
5
|
-
const reachesUp = (from, to) => {
|
|
6
|
-
const seen = new Set();
|
|
7
|
-
let cur = from.reportsTo;
|
|
8
|
-
while (cur && !seen.has(cur)) {
|
|
9
|
-
if (cur === to)
|
|
10
|
-
return true;
|
|
11
|
-
seen.add(cur);
|
|
12
|
-
cur = byId.get(cur)?.reportsTo ?? null;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
};
|
|
16
|
-
return tied.find((m) => tied.every((o) => o.id === m.id || reachesUp(o, m.id)));
|
|
17
|
-
}
|
|
18
|
-
// WHY: never guesses — zero overlap stays unassigned, and N + unrouted == unassigned.
|
|
19
|
-
export function proposeOwners(rows, seats) {
|
|
20
|
-
const eligibleSeats = seats.filter((s) => s.tier !== 'chairman' && s.tier !== 'ceo');
|
|
21
|
-
const stakeBySeat = new Map();
|
|
22
|
-
for (const s of eligibleSeats) {
|
|
23
|
-
stakeBySeat.set(s.id, s.subscribes.filter((x) => x !== '*'));
|
|
24
|
-
}
|
|
25
|
-
const inScope = rows.filter((r) => {
|
|
26
|
-
if (CLOSED.has(r.status))
|
|
27
|
-
return false;
|
|
28
|
-
if (r.assignee && r.assignee !== '')
|
|
29
|
-
return false;
|
|
30
|
-
const tags = r.tags ?? [];
|
|
31
|
-
if (tags.includes('approval'))
|
|
32
|
-
return false;
|
|
33
|
-
return true;
|
|
34
|
-
});
|
|
35
|
-
const unassigned = inScope.length;
|
|
36
|
-
const proposals = [];
|
|
37
|
-
const unrouted = [];
|
|
38
|
-
const unroutedByTag = {};
|
|
39
|
-
const incTag = (tag) => {
|
|
40
|
-
unroutedByTag[tag] = (unroutedByTag[tag] ?? 0) + 1;
|
|
41
|
-
};
|
|
42
|
-
for (const r of inScope) {
|
|
43
|
-
const tags = r.tags ?? [];
|
|
44
|
-
const candidates = [];
|
|
45
|
-
for (const s of eligibleSeats) {
|
|
46
|
-
const stake = stakeBySeat.get(s.id);
|
|
47
|
-
const matched = tags.filter((t) => stake.includes(t));
|
|
48
|
-
if (matched.length > 0) {
|
|
49
|
-
const dedup = [...new Set(matched)].sort();
|
|
50
|
-
candidates.push({ seat: s, matched: dedup });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (candidates.length === 0) {
|
|
54
|
-
unrouted.push({ tid: r.tid, tags, reason: 'no-stake' });
|
|
55
|
-
if (tags.length === 0) {
|
|
56
|
-
incTag('(untagged)');
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
for (const t of tags)
|
|
60
|
-
incTag(t);
|
|
61
|
-
}
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
let remaining = candidates;
|
|
65
|
-
// rule 5: if row has 'goal' or 'story' and at least one director candidate
|
|
66
|
-
if ((tags.includes('goal') || tags.includes('story')) &&
|
|
67
|
-
remaining.some((c) => c.seat.tier === 'director')) {
|
|
68
|
-
remaining = remaining.filter((c) => c.seat.tier === 'director');
|
|
69
|
-
}
|
|
70
|
-
// rule 6: keep only highest matched.length; then if tie among directors, keep directors
|
|
71
|
-
{
|
|
72
|
-
const maxLen = Math.max(...remaining.map((c) => c.matched.length));
|
|
73
|
-
remaining = remaining.filter((c) => c.matched.length === maxLen);
|
|
74
|
-
}
|
|
75
|
-
if (remaining.length > 1 && remaining.some((c) => c.seat.tier === 'director')) {
|
|
76
|
-
remaining = remaining.filter((c) => c.seat.tier === 'director');
|
|
77
|
-
}
|
|
78
|
-
if (remaining.length === 1) {
|
|
79
|
-
const { seat, matched } = remaining[0];
|
|
80
|
-
proposals.push({
|
|
81
|
-
tid: r.tid,
|
|
82
|
-
assignee: seat.id,
|
|
83
|
-
matched,
|
|
84
|
-
workspace: r.workspace,
|
|
85
|
-
why: `overlap ${matched.length}`,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else if (remaining.length > 1 && managerOf(remaining.map((c) => c.seat), seats)) {
|
|
89
|
-
// A tied seat that manages every other tied seat takes it — it can hand it down.
|
|
90
|
-
const mgr = managerOf(remaining.map((c) => c.seat), seats);
|
|
91
|
-
proposals.push({
|
|
92
|
-
tid: r.tid,
|
|
93
|
-
assignee: mgr.id,
|
|
94
|
-
matched: [...new Set(remaining.flatMap((c) => c.matched))].sort(),
|
|
95
|
-
workspace: r.workspace,
|
|
96
|
-
why: `tie; @${mgr.id} manages the other ${remaining.length - 1}`,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
else if (remaining.length > 1) {
|
|
100
|
-
// rule 8: check if they all report to same eligible seat
|
|
101
|
-
const reportsTo = remaining[0].seat.reportsTo;
|
|
102
|
-
const allSame = reportsTo !== null && remaining.every((c) => c.seat.reportsTo === reportsTo);
|
|
103
|
-
let managerEligible = false;
|
|
104
|
-
if (allSame) {
|
|
105
|
-
const mgr = seats.find((s) => s.id === reportsTo);
|
|
106
|
-
managerEligible =
|
|
107
|
-
mgr !== undefined &&
|
|
108
|
-
mgr.tier !== 'chairman' &&
|
|
109
|
-
mgr.tier !== 'ceo';
|
|
110
|
-
}
|
|
111
|
-
if (allSame && managerEligible) {
|
|
112
|
-
// union of matched
|
|
113
|
-
const union = [
|
|
114
|
-
...new Set(remaining.flatMap((c) => c.matched)),
|
|
115
|
-
].sort();
|
|
116
|
-
proposals.push({
|
|
117
|
-
tid: r.tid,
|
|
118
|
-
assignee: reportsTo,
|
|
119
|
-
matched: union,
|
|
120
|
-
workspace: r.workspace,
|
|
121
|
-
why: `tie among ${remaining.length} reports of ${reportsTo}`,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
// rule 9: tie unrouted
|
|
126
|
-
const candidateIds = remaining.map((c) => c.seat.id).sort();
|
|
127
|
-
unrouted.push({
|
|
128
|
-
tid: r.tid,
|
|
129
|
-
tags,
|
|
130
|
-
reason: 'tie',
|
|
131
|
-
candidates: candidateIds,
|
|
132
|
-
});
|
|
133
|
-
// do NOT touch unroutedByTag
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
unassigned,
|
|
139
|
-
proposals,
|
|
140
|
-
unrouted,
|
|
141
|
-
unroutedByTag,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
export function routeEdits(plan) {
|
|
145
|
-
return plan.proposals.map((p) => ({
|
|
146
|
-
tid: p.tid,
|
|
147
|
-
assignee: p.assignee,
|
|
148
|
-
workspace: p.workspace,
|
|
149
|
-
comment: `routed by stake (one tasks route): tags [${p.matched.join(', ')}] match @${p.assignee}'s subscribes — ${p.why}`,
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type Row } from './tasks-digest.js';
|
|
2
|
-
export interface ScoreSnapshot {
|
|
3
|
-
seq: number;
|
|
4
|
-
asOf?: string;
|
|
5
|
-
unassigned: number;
|
|
6
|
-
orphans: number;
|
|
7
|
-
staleReady: number;
|
|
8
|
-
widestTag: {
|
|
9
|
-
tag: string;
|
|
10
|
-
count: number;
|
|
11
|
-
share: number;
|
|
12
|
-
};
|
|
13
|
-
closedBySeat: Record<string, number>;
|
|
14
|
-
readyStreak: Record<string, number>;
|
|
15
|
-
openOwner: Record<string, string>;
|
|
16
|
-
}
|
|
17
|
-
export type Metric = 'unassigned' | 'orphans' | 'staleReady' | 'widestShare' | 'closed';
|
|
18
|
-
export interface Delta {
|
|
19
|
-
metric: Metric;
|
|
20
|
-
now: number;
|
|
21
|
-
prev?: number;
|
|
22
|
-
delta?: number;
|
|
23
|
-
red: boolean;
|
|
24
|
-
}
|
|
25
|
-
export interface Score {
|
|
26
|
-
snap: ScoreSnapshot;
|
|
27
|
-
deltas: Delta[];
|
|
28
|
-
}
|
|
29
|
-
export declare function scoreboard(rows: Row[], prev: ScoreSnapshot | undefined, opts?: {
|
|
30
|
-
staleAfter?: number;
|
|
31
|
-
asOf?: string;
|
|
32
|
-
}): Score;
|
|
33
|
-
export declare function renderScore(s: Score, opts: {
|
|
34
|
-
color: boolean;
|
|
35
|
-
staleAfter?: number;
|
|
36
|
-
}): string;
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
// tasks-score — the orchestration scoreboard `brief --as ceo` prints and remembers.
|
|
2
|
-
// Locked rule 3 (deterministic results): the chairman grades from these five numbers,
|
|
3
|
-
// not from prose. Time is structural: 'older than N' means N consecutive briefs.
|
|
4
|
-
import { CLOSED, kindOf } from './tasks-digest.js';
|
|
5
|
-
export function scoreboard(rows, prev, opts = {}) {
|
|
6
|
-
const staleAfter = opts.staleAfter ?? 3;
|
|
7
|
-
const work = rows.filter(r => kindOf(r) === 'work');
|
|
8
|
-
const open = work.filter(r => !CLOSED.has(r.status));
|
|
9
|
-
const unassigned = open.filter(r => !r.assignee).length;
|
|
10
|
-
const orphans = open.filter(r => !r.parent).length;
|
|
11
|
-
// readyStreak
|
|
12
|
-
const readyStreak = {};
|
|
13
|
-
for (const r of open) {
|
|
14
|
-
if (r.status === 'open' && r.ready === true && !r.assignee) {
|
|
15
|
-
const prevStreak = prev?.readyStreak?.[r.tid] ?? 0;
|
|
16
|
-
readyStreak[r.tid] = prevStreak + 1;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const staleReady = Object.values(readyStreak).filter(v => v >= staleAfter).length;
|
|
20
|
-
// widestTag
|
|
21
|
-
let widestTag = { tag: '', count: 0, share: 0 };
|
|
22
|
-
if (open.length > 0) {
|
|
23
|
-
const tagCounts = {};
|
|
24
|
-
for (const r of open) {
|
|
25
|
-
for (const tag of r.tags ?? []) {
|
|
26
|
-
tagCounts[tag] = (tagCounts[tag] || 0) + 1;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
let bestTag = '';
|
|
30
|
-
let bestCount = 0;
|
|
31
|
-
for (const [tag, count] of Object.entries(tagCounts)) {
|
|
32
|
-
if (count > bestCount || (count === bestCount && tag < bestTag)) {
|
|
33
|
-
bestTag = tag;
|
|
34
|
-
bestCount = count;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (bestTag !== '') {
|
|
38
|
-
widestTag = { tag: bestTag, count: bestCount, share: bestCount / open.length };
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// closedBySeat — based on prev openOwner
|
|
42
|
-
const closedBySeat = {};
|
|
43
|
-
if (prev?.openOwner) {
|
|
44
|
-
const byTid = new Map(work.map((r) => [r.tid, r]));
|
|
45
|
-
for (const [tid, owner] of Object.entries(prev.openOwner)) {
|
|
46
|
-
const row = byTid.get(tid);
|
|
47
|
-
if (row && CLOSED.has(row.status)) {
|
|
48
|
-
const seat = owner || '(unassigned)';
|
|
49
|
-
closedBySeat[seat] = (closedBySeat[seat] || 0) + 1;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// openOwner for next time
|
|
54
|
-
const openOwner = {};
|
|
55
|
-
for (const r of open) {
|
|
56
|
-
openOwner[r.tid] = r.assignee ?? '';
|
|
57
|
-
}
|
|
58
|
-
const seq = (prev?.seq ?? 0) + 1;
|
|
59
|
-
const snap = {
|
|
60
|
-
seq,
|
|
61
|
-
asOf: opts.asOf,
|
|
62
|
-
unassigned,
|
|
63
|
-
orphans,
|
|
64
|
-
staleReady,
|
|
65
|
-
widestTag,
|
|
66
|
-
closedBySeat,
|
|
67
|
-
readyStreak,
|
|
68
|
-
openOwner,
|
|
69
|
-
};
|
|
70
|
-
// delta helpers
|
|
71
|
-
const closedNow = Object.values(closedBySeat).reduce((a, b) => a + b, 0);
|
|
72
|
-
const prevClosed = prev ? Object.values(prev.closedBySeat).reduce((a, b) => a + b, 0) : 0;
|
|
73
|
-
const deltas = [];
|
|
74
|
-
const metrics = [
|
|
75
|
-
{ metric: 'unassigned', now: unassigned, prevNow: prev?.unassigned },
|
|
76
|
-
{ metric: 'orphans', now: orphans, prevNow: prev?.orphans },
|
|
77
|
-
{ metric: 'staleReady', now: staleReady, prevNow: prev?.staleReady },
|
|
78
|
-
{ metric: 'widestShare', now: widestTag.share, prevNow: prev?.widestTag?.share },
|
|
79
|
-
{ metric: 'closed', now: closedNow, prevPrev: prevClosed },
|
|
80
|
-
];
|
|
81
|
-
for (const m of metrics) {
|
|
82
|
-
if (!prev) {
|
|
83
|
-
deltas.push({ metric: m.metric, now: m.now, red: false });
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
const p = m.metric === 'closed' ? m.prevPrev : m.prevNow;
|
|
87
|
-
const delta = m.now - p;
|
|
88
|
-
const red = m.metric === 'closed' ? delta < 0 : delta > 0;
|
|
89
|
-
deltas.push({ metric: m.metric, now: m.now, prev: p, delta, red });
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return { snap, deltas };
|
|
93
|
-
}
|
|
94
|
-
function RED(text, color) {
|
|
95
|
-
return color ? `\u001b[31m${text}\u001b[0m` : text;
|
|
96
|
-
}
|
|
97
|
-
function formatDelta(d, isShare) {
|
|
98
|
-
if (d === 0)
|
|
99
|
-
return '=';
|
|
100
|
-
const sign = d > 0 ? '+' : '';
|
|
101
|
-
if (isShare) {
|
|
102
|
-
// d is already a fraction (e.g. 0.015), convert to percentage points
|
|
103
|
-
const pt = (d * 100).toFixed(1);
|
|
104
|
-
return `${sign}${pt}pt`;
|
|
105
|
-
}
|
|
106
|
-
return `${sign}${d}`;
|
|
107
|
-
}
|
|
108
|
-
export function renderScore(s, opts) {
|
|
109
|
-
const { snap, deltas } = s;
|
|
110
|
-
const staleAfter = opts.staleAfter ?? 3;
|
|
111
|
-
const color = opts.color;
|
|
112
|
-
// prefix
|
|
113
|
-
const prefix = snap.seq === 1
|
|
114
|
-
? `scoreboard #${snap.seq} (first — deltas from the next brief)`
|
|
115
|
-
: `scoreboard #${snap.seq} vs #${snap.seq - 1}`;
|
|
116
|
-
// build parts
|
|
117
|
-
const parts = [];
|
|
118
|
-
for (const delta of deltas) {
|
|
119
|
-
const now = delta.now;
|
|
120
|
-
const isShare = delta.metric === 'widestShare';
|
|
121
|
-
const d = delta.prev === undefined ? '' : ` (${formatDelta(delta.delta, isShare)}${delta.red ? ' RED' : ''})`;
|
|
122
|
-
const finalPart = delta.red ? RED(`${now}${d}`, color) : `${now}${d}`;
|
|
123
|
-
switch (delta.metric) {
|
|
124
|
-
case 'unassigned':
|
|
125
|
-
parts.push(`unassigned ${finalPart}`);
|
|
126
|
-
break;
|
|
127
|
-
case 'orphans':
|
|
128
|
-
parts.push(`orphans ${finalPart}`);
|
|
129
|
-
break;
|
|
130
|
-
case 'staleReady':
|
|
131
|
-
parts.push(`ready-unclaimed ≥${staleAfter} briefs ${finalPart}`);
|
|
132
|
-
break;
|
|
133
|
-
case 'widestShare': {
|
|
134
|
-
const tag = snap.widestTag.tag || '-';
|
|
135
|
-
const share = (snap.widestTag.share * 100).toFixed(1);
|
|
136
|
-
parts.push(`widest tag ${tag} ${share}%${delta.red ? RED(d, color) : d}`);
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
case 'closed':
|
|
140
|
-
parts.push(`closed since last brief ${finalPart}`);
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
// closedBySeat suffix
|
|
145
|
-
const closedEntries = Object.entries(snap.closedBySeat);
|
|
146
|
-
if (closedEntries.length > 0) {
|
|
147
|
-
const sorted = closedEntries.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
|
|
148
|
-
const suffix = sorted.map(([k, v]) => `${k}=${v}`).join(' ');
|
|
149
|
-
parts.push(`[${suffix}]`);
|
|
150
|
-
}
|
|
151
|
-
return prefix + ' · ' + parts.join(' · ');
|
|
152
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type Asker, type BulkEdit, type BulkReq } from '@oneie/sdk/tasks-bulk';
|
|
2
|
-
import type { Row } from './tasks-digest.js';
|
|
3
|
-
export declare function workspaceSpread(rows: Row[]): Record<string, number>;
|
|
4
|
-
export declare function spreadWarning(spread: Record<string, number>): string | undefined;
|
|
5
|
-
export declare function fillEditWorkspaces(edits: BulkEdit[], rows: Row[]): {
|
|
6
|
-
edits: BulkEdit[];
|
|
7
|
-
filled: number;
|
|
8
|
-
unknown: string[];
|
|
9
|
-
};
|
|
10
|
-
export declare function resolveBulkWorkspaces(ask: Asker, req: BulkReq): Promise<{
|
|
11
|
-
ok: true;
|
|
12
|
-
req: BulkReq;
|
|
13
|
-
filled: number;
|
|
14
|
-
unknown: string[];
|
|
15
|
-
} | {
|
|
16
|
-
ok: false;
|
|
17
|
-
error: string;
|
|
18
|
-
}>;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// tasks-workspace — A tid carries no workspace, so the board row is the only place a client can learn it; the receiver accepts a per-edit workspace override.
|
|
2
|
-
import { boardAllWith } from '@oneie/sdk/tasks-bulk';
|
|
3
|
-
export function workspaceSpread(rows) {
|
|
4
|
-
const counts = {};
|
|
5
|
-
for (const row of rows) {
|
|
6
|
-
counts[row.workspace] = (counts[row.workspace] ?? 0) + 1;
|
|
7
|
-
}
|
|
8
|
-
return counts;
|
|
9
|
-
}
|
|
10
|
-
export function spreadWarning(spread) {
|
|
11
|
-
const keys = Object.keys(spread);
|
|
12
|
-
if (keys.length < 2)
|
|
13
|
-
return undefined;
|
|
14
|
-
const n = keys.length;
|
|
15
|
-
const pairs = keys
|
|
16
|
-
.sort((a, b) => {
|
|
17
|
-
const diff = spread[b] - spread[a];
|
|
18
|
-
if (diff !== 0)
|
|
19
|
-
return diff;
|
|
20
|
-
return a.localeCompare(b);
|
|
21
|
-
})
|
|
22
|
-
.map((k) => `${k}=${spread[k]}`)
|
|
23
|
-
.join(' ');
|
|
24
|
-
return `warning this read spans ${n} workspaces (${pairs}) — an edit sent with one --workspace answers not_found for rows in the others; tasks bulk resolves each row's own`;
|
|
25
|
-
}
|
|
26
|
-
export function fillEditWorkspaces(edits, rows) {
|
|
27
|
-
const rowMap = new Map();
|
|
28
|
-
for (const row of rows) {
|
|
29
|
-
rowMap.set(row.tid, row);
|
|
30
|
-
}
|
|
31
|
-
const resultEdits = [];
|
|
32
|
-
let filled = 0;
|
|
33
|
-
const unknown = [];
|
|
34
|
-
for (const edit of edits) {
|
|
35
|
-
if (edit.workspace && edit.workspace.length > 0) {
|
|
36
|
-
resultEdits.push(edit);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
const row = rowMap.get(edit.tid);
|
|
40
|
-
if (row) {
|
|
41
|
-
resultEdits.push({ ...edit, workspace: row.workspace });
|
|
42
|
-
filled++;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
resultEdits.push(edit);
|
|
46
|
-
unknown.push(edit.tid);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return { edits: resultEdits, filled, unknown };
|
|
51
|
-
}
|
|
52
|
-
export async function resolveBulkWorkspaces(ask, req) {
|
|
53
|
-
const missingWorkspace = req.edits?.some((e) => !e.workspace || e.workspace.length === 0);
|
|
54
|
-
if (!missingWorkspace) {
|
|
55
|
-
return { ok: true, req, filled: 0, unknown: [] };
|
|
56
|
-
}
|
|
57
|
-
const boardReq = {
|
|
58
|
-
...(req.workspace ? { workspace: req.workspace } : {}),
|
|
59
|
-
scope: 'tree',
|
|
60
|
-
status: 'all',
|
|
61
|
-
limit: 2000,
|
|
62
|
-
};
|
|
63
|
-
const res = await boardAllWith(ask, boardReq);
|
|
64
|
-
if (res.ok === false) {
|
|
65
|
-
return {
|
|
66
|
-
ok: false,
|
|
67
|
-
error: `could not read the board to resolve each edit's workspace: ${res.error ?? 'tasks:board failed'} — nothing sent`,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
const tasks = res.tasks ?? [];
|
|
71
|
-
const f = fillEditWorkspaces(req.edits, tasks);
|
|
72
|
-
return { ok: true, req: { ...req, edits: f.edits }, filled: f.filled, unknown: f.unknown };
|
|
73
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A fetch that cannot wait forever.
|
|
3
|
-
*
|
|
4
|
-
* Bare `npx oneie` made every round trip with a plain `fetch` and no signal, so one
|
|
5
|
-
* connection that opened and never answered held the run until undici gave up (about
|
|
6
|
-
* five minutes), with nothing on screen after "Picking up where you left off".
|
|
7
|
-
* Reproduced 2026-11-12 against a server that accepts and never replies: killed at
|
|
8
|
-
* 75 s, still waiting. A re-run makes about ten calls while it waits for the test
|
|
9
|
-
* sale, so on a link that drops one connect in ten, the third run is the one that
|
|
10
|
-
* stops.
|
|
11
|
-
*
|
|
12
|
-
* Every call on the journey path goes through here, so a silent server becomes a
|
|
13
|
-
* named answer ("… did not answer in 15 s") instead of a hang.
|
|
14
|
-
*/
|
|
15
|
-
/** One read or one receiver call. Measured answers are under 3.1 s, even with the Mac at load 150. */
|
|
16
|
-
export declare const ASK_TIMEOUT_MS = 15000;
|
|
17
|
-
/** `/api/provision/agent` registers, bootstraps, publishes and invites: 6.7–10.2 s measured. A write: never retried. */
|
|
18
|
-
export declare const PROVISION_TIMEOUT_MS = 60000;
|
|
19
|
-
export declare class NoAnswerError extends Error {
|
|
20
|
-
readonly what: string;
|
|
21
|
-
readonly ms: number;
|
|
22
|
-
constructor(what: string, ms: number);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* `f(url, init)` bounded by `ms` — headers AND body. Returns the parsed JSON body
|
|
26
|
-
* (or `{}` when the body is not JSON) with the status, so the caller never holds a
|
|
27
|
-
* half-read stream past the deadline.
|
|
28
|
-
*/
|
|
29
|
-
export declare function fetchJson(f: typeof fetch, url: string, init: RequestInit, ms: number, what: string): Promise<{
|
|
30
|
-
ok: boolean;
|
|
31
|
-
status: number;
|
|
32
|
-
json: Record<string, unknown>;
|
|
33
|
-
}>;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A fetch that cannot wait forever.
|
|
3
|
-
*
|
|
4
|
-
* Bare `npx oneie` made every round trip with a plain `fetch` and no signal, so one
|
|
5
|
-
* connection that opened and never answered held the run until undici gave up (about
|
|
6
|
-
* five minutes), with nothing on screen after "Picking up where you left off".
|
|
7
|
-
* Reproduced 2026-11-12 against a server that accepts and never replies: killed at
|
|
8
|
-
* 75 s, still waiting. A re-run makes about ten calls while it waits for the test
|
|
9
|
-
* sale, so on a link that drops one connect in ten, the third run is the one that
|
|
10
|
-
* stops.
|
|
11
|
-
*
|
|
12
|
-
* Every call on the journey path goes through here, so a silent server becomes a
|
|
13
|
-
* named answer ("… did not answer in 15 s") instead of a hang.
|
|
14
|
-
*/
|
|
15
|
-
/** One read or one receiver call. Measured answers are under 3.1 s, even with the Mac at load 150. */
|
|
16
|
-
export const ASK_TIMEOUT_MS = 15_000;
|
|
17
|
-
/** `/api/provision/agent` registers, bootstraps, publishes and invites: 6.7–10.2 s measured. A write: never retried. */
|
|
18
|
-
export const PROVISION_TIMEOUT_MS = 60_000;
|
|
19
|
-
export class NoAnswerError extends Error {
|
|
20
|
-
what;
|
|
21
|
-
ms;
|
|
22
|
-
constructor(what, ms) {
|
|
23
|
-
super(`${what} did not answer in ${Math.round(ms / 1000)} s`);
|
|
24
|
-
this.what = what;
|
|
25
|
-
this.ms = ms;
|
|
26
|
-
this.name = 'NoAnswerError';
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const isAbort = (e) => {
|
|
30
|
-
const n = e?.name;
|
|
31
|
-
return n === 'TimeoutError' || n === 'AbortError';
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* `f(url, init)` bounded by `ms` — headers AND body. Returns the parsed JSON body
|
|
35
|
-
* (or `{}` when the body is not JSON) with the status, so the caller never holds a
|
|
36
|
-
* half-read stream past the deadline.
|
|
37
|
-
*/
|
|
38
|
-
export async function fetchJson(f, url, init, ms, what) {
|
|
39
|
-
const signal = AbortSignal.timeout(ms);
|
|
40
|
-
try {
|
|
41
|
-
const res = await f(url, { ...init, signal });
|
|
42
|
-
const text = await res.text();
|
|
43
|
-
let json = {};
|
|
44
|
-
try {
|
|
45
|
-
const parsed = JSON.parse(text);
|
|
46
|
-
if (parsed && typeof parsed === 'object')
|
|
47
|
-
json = parsed;
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
/* not JSON: an empty body stands in */
|
|
51
|
-
}
|
|
52
|
-
return { ok: res.ok, status: res.status, json };
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
if (isAbort(e) || signal.aborted)
|
|
56
|
-
throw new NoAnswerError(what, ms);
|
|
57
|
-
throw e;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vault-read.ts — what the owner's vault says about a sealed file (text/secrets-plan.md
|
|
3
|
-
* Interface Contract #7). `one run` asks it one question: "which sha256 of `.env.sealed`
|
|
4
|
-
* do you know?" — the `sealed_hash` the owner set with `set_sealed_hash` (C14).
|
|
5
|
-
*
|
|
6
|
-
* `vaultLoaders.read` is the seam, swapped in tests like message-seal.ts's `loaders`.
|
|
7
|
-
* The default reads:
|
|
8
|
-
* • ONE_SECRETS_VAULT_FIXTURE — a JSON file `{ "<vaultId>": { "sealedHash": "<64 hex>" } }`
|
|
9
|
-
* (the vault contract is not on testnet yet), else
|
|
10
|
-
* • Sui JSON-RPC `sui_getObject` (showContent) on ONE_SUI_RPC, 10 s deadline, reading the
|
|
11
|
-
* vault's `sealed_hash` (vector<u8>, 32 bytes) as lowercase hex.
|
|
12
|
-
*
|
|
13
|
-
* A vault that has no hash set is `{ sealedHash: null }`; a read that fails, times out or
|
|
14
|
-
* returns something that is not 32 bytes is a Fail. The caller refuses on both.
|
|
15
|
-
*/
|
|
16
|
-
import type { Fail } from './message-seal.js';
|
|
17
|
-
export interface VaultRead {
|
|
18
|
-
sealedHash: string | null;
|
|
19
|
-
}
|
|
20
|
-
/** Swappable in tests; the default is the fixture file or the Sui node. */
|
|
21
|
-
export declare const vaultLoaders: {
|
|
22
|
-
read: (id: string) => Promise<VaultRead | Fail>;
|
|
23
|
-
};
|
|
24
|
-
export declare const readVault: (id: string) => Promise<VaultRead | Fail>;
|