geneseed 4.20.0 → 4.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/DESIGN.md +1 -1
  3. package/README.md +2 -2
  4. package/SHIPPED.md +1 -1
  5. package/adapters/bob/README.md +5 -0
  6. package/adapters/claude-code/README.md +4 -0
  7. package/adapters/openclaude/README.md +2 -1
  8. package/adapters/opencode/plugins/geneseed-activity.js +2 -2
  9. package/adapters/opencode/plugins/geneseed-guard.js +1 -1
  10. package/bin/geneseed-cli.mjs +1 -1
  11. package/bin/geneseed-hook.mjs +44 -3
  12. package/docs/concepts/hooks.md +4 -0
  13. package/docs/concepts/host-matrix.md +1 -0
  14. package/docs/guides/upgrade.md +1 -1
  15. package/docs/reference/environment.md +1 -0
  16. package/docs/reference/plugin-activity.md +7 -3
  17. package/docs/web-ui.md +13 -11
  18. package/harness.config.json +1 -1
  19. package/js/README.md +3 -2
  20. package/js/cli-table.json +39 -0
  21. package/js/hosts/activity.mjs +429 -0
  22. package/js/hosts/hooks-prims.mjs +47 -4
  23. package/js/hosts/hooks.mjs +6 -9
  24. package/js/hosts/settings.mjs +9 -0
  25. package/js/web/actions.mjs +39 -0
  26. package/js/web/activity.mjs +76 -108
  27. package/js/web/api.mjs +24 -2
  28. package/js/web/handler.mjs +20 -1
  29. package/js/web/jobs.mjs +6 -6
  30. package/js/web/server.mjs +6 -0
  31. package/js/web/usage-api.mjs +24 -3
  32. package/package.json +1 -1
  33. package/src/modes/foreman.md +2 -1
  34. package/src/skills/pipeline.md +2 -2
  35. package/src/skills/rule.md +3 -3
  36. package/web/dist/assets/Activity-DsKkFGhT.js +1 -0
  37. package/web/dist/assets/{ActivityDetail-CMeNtKIN.js → ActivityDetail-BWY-vaiK.js} +1 -1
  38. package/web/dist/assets/Dashboard-BZmw2a7d.js +2 -0
  39. package/web/dist/assets/Docs-CNuRuMin.js +4 -0
  40. package/web/dist/assets/GreenhouseView-BCiZP9f9.js +1 -0
  41. package/web/dist/assets/Installs-xkBX6OjK.js +3 -0
  42. package/web/dist/assets/JournalView-BSR51TKR.js +1 -0
  43. package/web/dist/assets/{KitApply-DZGqaZpV.js → KitApply-BR8AcZ62.js} +1 -1
  44. package/web/dist/assets/{Kits-C1VS-BtR.js → Kits-e0DCj9sT.js} +1 -1
  45. package/web/dist/assets/{Laws-Cu3pj44B.js → Laws-BuG2_HFE.js} +2 -2
  46. package/web/dist/assets/Library-BYfB4mhf.js +2 -0
  47. package/web/dist/assets/Loops-r6L7a1g1.js +2 -0
  48. package/web/dist/assets/OperatorHudView-BLXm0zzn.js +1 -0
  49. package/web/dist/assets/Personal-kEfKCxlh.js +1 -0
  50. package/web/dist/assets/{StackBar-CXARiXzd.js → StackBar-Y_gkoC3t.js} +1 -1
  51. package/web/dist/assets/Tabs-2uMB511T.js +1 -0
  52. package/web/dist/assets/activity-BEWV9er4.js +1 -0
  53. package/web/dist/assets/drawable-ixCquffB.js +1 -0
  54. package/web/dist/assets/{index-BJlfPvpv.css → index-CDSHv_7s.css} +1 -1
  55. package/web/dist/assets/index-Dwo3Gxek.js +2 -0
  56. package/web/dist/assets/jobBuckets-Dpjvbfm1.js +2 -0
  57. package/web/dist/index.html +2 -2
  58. package/web/dist/assets/Activity-nRkdnrgE.js +0 -1
  59. package/web/dist/assets/Dashboard-B5-wUlXC.js +0 -3
  60. package/web/dist/assets/Docs-QmZs08QG.js +0 -4
  61. package/web/dist/assets/GreenhouseView-tHIvpI6U.js +0 -1
  62. package/web/dist/assets/Installs-DDWjgFDY.js +0 -3
  63. package/web/dist/assets/JournalView-DO0pPutM.js +0 -1
  64. package/web/dist/assets/Library-CrTK5XsD.js +0 -2
  65. package/web/dist/assets/Loops-C7DPrKbV.js +0 -2
  66. package/web/dist/assets/OperatorHudView-BN27gXFS.js +0 -1
  67. package/web/dist/assets/Personal-Cz2rcqYw.js +0 -1
  68. package/web/dist/assets/Tabs-ChiCgm2F.js +0 -1
  69. package/web/dist/assets/activity-BGy8Bb_l.js +0 -1
  70. package/web/dist/assets/drawable-r1qCgRMK.js +0 -1
  71. package/web/dist/assets/index-osXUqzdX.js +0 -2
@@ -1,27 +1,29 @@
1
1
  /**
2
- * The live-activity surface — the one web endpoint that
3
- * DELETES.
2
+ * The live-activity surface. A GET reads; it never deletes or moves a file.
4
3
  *
5
- * It reads the per-session JSON files the `geneseed-activity` OpenCode plugin writes into
6
- * `<opencode-cfg>/activity/`, prunes the dead and the stale ones (unlinking them, so the
7
- * directory self-cleans), and returns what is left. Writer and reader share only that
8
- * directory: no RPC, crash-isolated, and cross-tool by construction.
4
+ * It reads the per-session JSON files two writers put into `<cfg>/activity/`: the
5
+ * `geneseed-activity` OpenCode plugin, and the hook-side writer for Claude Code, OpenClaude
6
+ * and Bob (`js/hosts/activity.mjs`). Writers and reader share only that directory: no RPC,
7
+ * crash-isolated, and cross-tool by construction. A live session is in `activity`; a stale,
8
+ * dead or ended one — in the directory still, or already swept into `activity/archive/` — is
9
+ * in `ended`, marked `ended: true`, and the live copy wins a duplicate.
10
+ *
11
+ * WHY THE GET STOPPED PRUNING. It used to unlink every snapshot that failed the liveness test,
12
+ * which made a page view the one web read that deleted, and left nothing to show of a session
13
+ * that had just finished. Moving belongs to `sweepActivity`, which the hook writer runs on
14
+ * SessionStart and SessionEnd and which archives instead of deleting. The OpenCode plugin never
15
+ * sweeps, so its dead snapshots stay in place: `ended` is therefore capped HERE, in what is
16
+ * returned, to the archive's own rule (the newest `ARCHIVE_KEEP`, none older than
17
+ * `ARCHIVE_MAX_AGE_SECONDS`) — without touching a file.
9
18
  *
10
19
  * `/api/activity` answers a GET through `apiActivity` and a POST through `apiActivityToggle`
11
20
  * at the bottom of this file. It is the one POST route whose result is sent at 200 whatever
12
21
  * `ok` says, which is why `POST_ROUTES` in `js/web/routes.mjs` carries a 409 COLUMN rather
13
22
  * than a rule — and giving this row the 409 treatment is mutation M22.
14
23
  *
15
- * `process.kill(pid, 0)` PROBES LIVENESS WITHOUT A SPAWN — it is a core `process` API, not
16
- * `child_process`, so it stays clear of the spawn ban. libuv's `uv_kill` opens the process
17
- * for query and answers `ESRCH` when the pid is free and `EPERM` when it cannot tell —
18
- * "no such process" vs "err toward alive".
19
- *
20
- * `process.kill` alone cannot tell a truly-dead pid from one that EXITED but whose handle is
21
- * still held: it reports the latter alive too. The staleness backstop (below) is what prunes
22
- * it, thirty minutes later — reproducing an exit-code read would need a native binding, not
23
- * worth it for a best-effort probe that already errs toward "alive" on any inconclusive
24
- * answer.
24
+ * Liveness (`isLive`) is owned by `js/hosts/activity.mjs`, because the sweep needs the same
25
+ * answer: a hook snapshot carries `pid: null` and is live by staleness alone; a plugin one is
26
+ * also probed with `process.kill(pid, 0)`, which is a core `process` API, not `child_process`.
25
27
  *
26
28
  * `parseJson`, NOT `JSON.parse` — NOT a style choice. These files are written by a third
27
29
  * party and carry `cost` as a float. `JSON.parse` collapses `1.0` to the bare integer `1`,
@@ -33,28 +35,22 @@
33
35
  * `0.0` instead of collapsing to the fallback `0`. `isTruthy` is what makes a wrapped zero
34
36
  * read as falsy, so a `"cost": 0.0` entry correctly comes back `0`.
35
37
  */
36
- import { mkdirSync, readdirSync, unlinkSync } from 'node:fs';
38
+ import { mkdirSync, readdirSync } from 'node:fs';
37
39
  import path from 'node:path';
38
40
 
39
41
  import { readText, writeText, isDir, isFile } from '../lib/fs.mjs';
40
42
  import { parseJson, isTruthy } from '../lib/json.mjs';
41
43
  import { normcase } from '../lib/paths.mjs';
42
- import { parseIntStrict, stripWhitespace } from '../lib/text.mjs';
44
+ import { stripWhitespace } from '../lib/text.mjs';
45
+ import { ARCHIVE_KEEP, ARCHIVE_MAX_AGE_SECONDS, isLive, safeStem } from '../hosts/activity.mjs';
43
46
  import { NotFound, stemOf } from './catalog.mjs';
44
47
 
45
- /**
46
- * A session whose writer is gone, or that has not been touched in this long, is pruned.
47
- * pid-liveness is the real signal; the staleness backstop covers a reused pid and a
48
- * platform where the probe cannot tell. Generous on purpose: streaming bumps `updated_at`
49
- * constantly, so only a genuinely abandoned (process-still-alive) session ages out.
50
- */
51
- const ACTIVITY_STALE_SECONDS = 1800;
52
-
53
48
  const nowSeconds = () => Date.now() / 1000;
54
49
 
55
50
  /**
56
- * `<target>/activity`. `state.target` is ALREADY the OpenCode config dir, so this must not
57
- * append `opencode/` again; that double-join is the classic seam bug.
51
+ * `<target>/activity`. `state.target` is ALREADY the viewed install's config dir (OpenCode's, or
52
+ * a Claude-shaped host's), so this must not append `opencode/` again; that double-join is the
53
+ * classic seam bug.
58
54
  */
59
55
  const activityDir = (state) => path.join(state.target, 'activity');
60
56
 
@@ -76,40 +72,6 @@ function activityEnabled(state) {
76
72
  return !['off', '0', 'false', 'no'].includes(stripWhitespace(raw).toLowerCase());
77
73
  }
78
74
 
79
- /**
80
- * Coerces a raw pid value to an integer, or `null` for anything unusable.
81
- *
82
- * The value came out of `parseJson`, so a JSON number may arrive wrapped in `JsonNumber`,
83
- * which this module cannot import by name (only `parseJson`/`isTruthy`/etc are exported). It
84
- * is recognised by the only thing the wrapper promises: a numeric `valueOf`. A plain
85
- * object's `valueOf` returns itself (rejected by the `typeof n !== 'number'` check below)
86
- * and an array is excluded outright. Also handles a decimal string, a boolean (`true` → 1),
87
- * and a float (truncated) — whatever a hand-edited snapshot can produce.
88
- */
89
- function toIntOr(raw) {
90
- if (raw === true) return 1;
91
- if (raw === false) return 0;
92
- if (typeof raw === 'string') return parseIntStrict(stripWhitespace(raw));
93
- const n = (raw !== null && typeof raw === 'object' && !Array.isArray(raw))
94
- ? raw.valueOf() : raw;
95
- if (typeof n !== 'number' || !Number.isFinite(n)) return null;
96
- return Math.trunc(n);
97
- }
98
-
99
- /** Best-effort liveness for the writer process. See this file's header. */
100
- function pidAlive(raw) {
101
- const pid = toIntOr(raw);
102
- if (pid === null || pid <= 0) return false;
103
- try {
104
- process.kill(pid, 0);
105
- return true;
106
- } catch (e) {
107
- // ESRCH → dead. Anything else (`EPERM`, and whatever a locked-down host answers) →
108
- // alive, and the staleness backstop decides.
109
- return !(e && e.code === 'ESRCH');
110
- }
111
- }
112
-
113
75
  /**
114
76
  * One session snapshot normalised into the stable shape the UI consumes. v1 writers omit
115
77
  * the enrichment keys, so those default to null/0 and the UI hides what is absent. The KEY
@@ -148,24 +110,12 @@ function readEntry(p) {
148
110
  return (entry !== null && typeof entry === 'object' && !Array.isArray(entry)) ? entry : null;
149
111
  }
150
112
 
151
- /** The writer's pid is alive AND the snapshot is not stale. */
152
- function isLive(entry, now) {
153
- const updated = isTruthy(Object.hasOwn(entry, 'updated_at') ? entry.updated_at : null)
154
- ? entry.updated_at : 0;
155
- return (now - Number(updated)) <= ACTIVITY_STALE_SECONDS && pidAlive(
156
- Object.hasOwn(entry, 'pid') ? entry.pid : null);
157
- }
158
-
159
113
  /**
160
- * Every live session, dead and stale ones pruned AND their files removed. Never throws: a
161
- * missing dir is `[]`, a garbage file is skipped (and kept — only a snapshot that PARSED and
162
- * failed the liveness test is unlinked), newest first.
114
+ * `[name, entry]` for every snapshot that parses in `d`, sorted by name. Never throws: a
115
+ * missing dir is `[]`, and a garbage file is skipped and left where it is.
163
116
  */
164
- function activityEntries(state) {
165
- const d = activityDir(state);
117
+ function snapshots(d) {
166
118
  if (!isDir(d)) return [];
167
- const now = nowSeconds();
168
- const out = [];
169
119
  let names;
170
120
  try {
171
121
  names = readdirSync(d);
@@ -175,48 +125,66 @@ function activityEntries(state) {
175
125
  // Case-INSENSITIVE for the `.json` suffix (matches Windows filesystem behaviour); the
176
126
  // `.detail.json` check below is case-SENSITIVE on both platforms. Two different rules,
177
127
  // deliberately.
178
- for (const name of names.filter((n) => normcase(n).endsWith('.json')).sort()) {
179
- if (name.endsWith('.detail.json')) continue;
180
- const p = path.join(d, name);
181
- const entry = readEntry(p);
182
- if (entry === null) continue;
183
- if (!isLive(entry, now)) {
184
- try {
185
- unlinkSync(p); // crashed / abandoned writer
186
- unlinkSync(path.join(d, `${stemOf(name)}.detail.json`)); // its detail file too
187
- } catch { /* both unlinks are best-effort; a lingering file next scan is harmless */ }
188
- continue;
189
- }
190
- out.push(normalizeEntry(entry, stemOf(name)));
128
+ return names.filter((n) => normcase(n).endsWith('.json') && !n.endsWith('.detail.json')).sort()
129
+ .map((name) => [name, readEntry(path.join(d, name))]).filter(([, e]) => e !== null);
130
+ }
131
+
132
+ // STABLE sort matters when `updated_at` ties: a `b - a` comparator over ES2019's
133
+ // guaranteed-stable `Array.sort` preserves the original (directory-listing) order for equal keys.
134
+ const newestFirst = (list) => list.sort((a, b) => Number(b.updated_at) - Number(a.updated_at));
135
+
136
+ /**
137
+ * `{activity, ended}`: the live sessions, and the ones that are not — still in the directory
138
+ * or already archived — each listed once, the live copy and then the directory's winning.
139
+ */
140
+ function activityEntries(state) {
141
+ const d = activityDir(state);
142
+ const now = nowSeconds();
143
+ const live = [];
144
+ const ended = [];
145
+ const seen = new Set();
146
+ const rest = [];
147
+ for (const [name, entry] of snapshots(d)) {
148
+ const e = normalizeEntry(entry, stemOf(name));
149
+ if (isLive(entry, now)) { live.push(e); seen.add(String(e.session_id)); } else rest.push(e);
191
150
  }
192
- // STABLE sort matters when `updated_at` ties: a `b - a` comparator over ES2019's
193
- // guaranteed-stable `Array.sort` preserves the original (directory-listing) order for
194
- // equal keys.
195
- out.sort((a, b) => Number(b.updated_at) - Number(a.updated_at));
196
- return out;
151
+ for (const [name, entry] of snapshots(path.join(d, 'archive'))) {
152
+ rest.push(normalizeEntry(entry, stemOf(name)));
153
+ }
154
+ for (const e of rest) {
155
+ if (seen.has(String(e.session_id))) continue;
156
+ seen.add(String(e.session_id));
157
+ if (now - Number(e.updated_at) > ARCHIVE_MAX_AGE_SECONDS) continue;
158
+ ended.push({ ...e, ended: true });
159
+ }
160
+ return { activity: newestFirst(live), ended: newestFirst(ended).slice(0, ARCHIVE_KEEP) };
197
161
  }
198
162
 
199
163
  export function apiActivity(state) {
200
164
  const enabled = activityEnabled(state);
201
- return { enabled, activity: enabled ? activityEntries(state) : [] };
165
+ return { enabled, ...(enabled ? activityEntries(state) : { activity: [], ended: [] }) };
202
166
  }
203
167
 
204
168
  /**
205
- * One session's snapshot plus its step timeline and its UNCAPPED files/todos. 404 if the
206
- * session is absent or has aged out; a missing or garbage detail file degrades to an empty
207
- * timeline rather than a 500.
169
+ * One session's snapshot plus its step timeline and its UNCAPPED files/todos. A session that is
170
+ * no longer live — still in the directory, or archived — is returned too, with `ended: true`.
171
+ * 404 only if neither holds it; a missing or garbage detail file degrades to an empty timeline
172
+ * rather than a 500.
208
173
  */
209
174
  export function apiActivityDetail(state, sid) {
210
- const d = activityDir(state);
211
- // Resolve by the writer's safe-name scheme, which is also what keeps the read inside the
212
- // directory: every separator, `..` and drive colon becomes `_`, so there is no join to
213
- // steer. The `u` flag makes an astral character ONE replacement rather than one per
214
- // surrogate half.
215
- const stem = sid.replace(/[^A-Za-z0-9_.-]/gu, '_');
216
- const snap = path.join(d, `${stem}.json`);
217
- const entry = isFile(snap) ? readEntry(snap) : null;
218
- if (entry === null || !isLive(entry, nowSeconds())) throw new NotFound(sid);
175
+ // Resolve by the writer's safe-name scheme (`safeStem`), which is also what keeps the read
176
+ // inside the directory: every separator, `..` and drive colon becomes `_`, so there is no
177
+ // join to steer.
178
+ const stem = safeStem(sid);
179
+ let d = activityDir(state);
180
+ let entry = isFile(path.join(d, `${stem}.json`)) ? readEntry(path.join(d, `${stem}.json`)) : null;
181
+ if (entry === null) {
182
+ d = path.join(d, 'archive');
183
+ entry = isFile(path.join(d, `${stem}.json`)) ? readEntry(path.join(d, `${stem}.json`)) : null;
184
+ }
185
+ if (entry === null) throw new NotFound(sid);
219
186
  const session = normalizeEntry(entry, stem);
187
+ if (!isLive(entry, nowSeconds())) session.ended = true;
220
188
  let timeline = [];
221
189
  let full = {};
222
190
  const det = readEntry(path.join(d, `${stem}.detail.json`));
package/js/web/api.mjs CHANGED
@@ -8,7 +8,7 @@
8
8
  * bind paths to these functions are `routes.mjs`. This file imports none of its route siblings,
9
9
  * which is what keeps the old `api ↔ actions` and `api ↔ activity` cycles from coming back.
10
10
  */
11
- import { readdirSync, statSync } from 'node:fs';
11
+ import { existsSync, readdirSync, statSync } from 'node:fs';
12
12
  import path from 'node:path';
13
13
 
14
14
  import { CONFIG, CREDIT_RE, ROOT, SRC, THEMES, discoverNames, loadKits, makeCfg, upstreamOf } from '../build/source.mjs';
@@ -19,6 +19,7 @@ import { installProfile } from '../build/generate.mjs';
19
19
  import { diffCollect, renderMemo } from '../inspect/diff.mjs';
20
20
  import { excludesSnapshot } from '../inspect/excludes.mjs';
21
21
  import { VERSION_MARKER, resolvePath } from '../hosts/hosts.mjs';
22
+ import { autostartPaths } from '../hosts/shim.mjs';
22
23
  import {
23
24
  footprintOfDir, gatesOfDir, installState, installTargets, legacyProcessCarrierOfDir, modeOfDir,
24
25
  trustOfDir,
@@ -236,7 +237,27 @@ export function apiFleet(state) {
236
237
  cost: alwaysOnCost({ host, root, dir, footprint: footprintOfDir(root) }),
237
238
  });
238
239
  }
239
- return { installs, source_fp: sourceFp, doctor: state.doctor };
240
+ // `version` is the source's release label, the "Behind 4.19.0" a behind row names; the same
241
+ // reader `/api/overview` uses, so the two never name different releases.
242
+ return { installs, source_fp: sourceFp, doctor: state.doctor, version: releaseLabel() };
243
+ }
244
+
245
+ /**
246
+ * What the Server tab says about the process answering it — built FIELD BY FIELD, never from the
247
+ * daemon record, which holds the write token: a GET is readable by anything that passes the Host
248
+ * check, and the token is the only guard on a POST. `started` is the process's own start (the
249
+ * server is the process), in epoch seconds. `autostart` is whether the hand-written login
250
+ * launcher the install guide describes (`autostartPaths`) is on disk for THIS platform; null
251
+ * where that guide names none.
252
+ */
253
+ function serverFacts() {
254
+ const [vbs, plist] = autostartPaths();
255
+ const launcher = { win32: vbs, darwin: plist }[process.platform];
256
+ return {
257
+ pid: process.pid,
258
+ started: Math.floor(Date.now() / 1000 - process.uptime()),
259
+ autostart: launcher ? existsSync(launcher) : null,
260
+ };
240
261
  }
241
262
 
242
263
  /** Source files of a kit member: `<dir>/<name>.md`, or every `.md` in a `<dir>/<name>/` folder. */
@@ -357,6 +378,7 @@ export function apiOverview(state) {
357
378
  // True when the files on disk changed under this server since it started (an upgrade).
358
379
  // `serve` installs the comparison; a state built without a server has none and is false.
359
380
  daemon_stale: Boolean(state.daemonStale?.()),
381
+ server: serverFacts(),
360
382
  counts: {
361
383
  agents: inv.agents.length,
362
384
  skills: inv.skills.length,
@@ -14,7 +14,9 @@
14
14
  import { resolvePath } from '../hosts/hosts.mjs';
15
15
  import { isTruthy, jsonDumpsCompact } from '../lib/json.mjs';
16
16
  import { parseIntStrict, percentDecode } from '../lib/text.mjs';
17
- import { apiDeployCmd, apiInstallCmd, apiPickFolder, apiRestore, buildActionCmds, mcpTargetPaths } from './actions.mjs';
17
+ import {
18
+ apiDeployCmd, apiInstallCmd, apiPickFolder, apiRestore, buildActionCmds, mcpTargetPaths, rebuildCmds,
19
+ } from './actions.mjs';
18
20
  import { BadRequest, NotFound } from './catalog.mjs';
19
21
  import { openUrl, requestRestart } from './daemon.mjs';
20
22
  import { apiDocs, apiDocsPage } from './docs.mjs';
@@ -312,6 +314,11 @@ export function makeHandler(state, jm, token, dist, holder = null) {
312
314
  * means the world changed under the client) and 400 for deploy (its path came from the body,
313
315
  * so a refusal means the body was wrong). Unifying the two would be wrong for one of them.
314
316
  *
317
+ * `rebuild` follows them: the named installs' argv (`rebuildCmds`), 409 on a refusal for the
318
+ * install reason, and the build-all restart on a stale server. Its job is several steps, and
319
+ * `_run` stops at the first failed one where `rebuild-all` is best-effort: a click names the
320
+ * installs it wants, so a failure should stop and be read rather than be stepped past.
321
+ *
315
322
  * `update` COMES NEXT AND IS INLINE: it is gated on a LOCAL-ONLY preflight before a job is
316
323
  * ever started, so a dirty tree or a zip-download install gets a friendly 422 the UI renders
317
324
  * as an info popup instead of a job that spawns and then fails. Its finish handler is its own
@@ -336,6 +343,18 @@ export function makeHandler(state, jm, token, dist, holder = null) {
336
343
  if (Object.hasOwn(plan, 'error')) return sendJson(res, plan, 400, ae);
337
344
  return startJob(res, 'deploy', [plan.cmd], ae);
338
345
  }
346
+ if (action === 'rebuild') {
347
+ const plan = rebuildCmds(body);
348
+ if (Object.hasOwn(plan, 'error')) return sendJson(res, plan, 409, ae);
349
+ // A STALE server is refused, not restarted afterwards as build-all is: `rebuildCmds` built
350
+ // each argv with THIS (old) process's `installProfile`, while the build-driver it spawns is
351
+ // the new code on disk, so an axis or marker the pull added would be dropped. build-all
352
+ // spawns the new CLI, which builds every profile with the new code; this path cannot.
353
+ if (state.daemonStale?.()) {
354
+ return sendJson(res, { error: 'the console is running older code than the disk — restart it first (Installs › Server › Restart), then rebuild' }, 422, ae);
355
+ }
356
+ return startJob(res, 'rebuild', plan.cmds, ae);
357
+ }
339
358
  if (action === 'update') {
340
359
  // The route follows the install (`updatePlan`); a refusal is the same friendly 422.
341
360
  // The daily background `git fetch` still running would hold `.git` locks the update's own
package/js/web/jobs.mjs CHANGED
@@ -45,7 +45,7 @@
45
45
  *
46
46
  * ---------------------------------------------------------------------------------------
47
47
  * THE ACTION SURFACE — `doctor`, `build`, `build-all`, `export`, `update`, `link` and
48
- * `unlink` each name a verb `bin/geneseed-cli.mjs` runs, plus the three `INLINE_ACTIONS` the
48
+ * `unlink` each name a verb `bin/geneseed-cli.mjs` runs, plus the four `INLINE_ACTIONS` the
49
49
  * dispatcher answers without the table. `tests/unit/web_jobs.test.mjs` holds the union against
50
50
  * a written-out list, so an eighth action cannot appear unchecked.
51
51
  *
@@ -413,12 +413,12 @@ const CLI = () => path.join(ROOT, 'bin', 'geneseed-cli.mjs');
413
413
  const GEN = () => path.join(ROOT, 'bin', 'build-driver.mjs');
414
414
 
415
415
  /**
416
- * The three actions the dispatcher answers INLINE, without consulting the table above:
417
- * `restore` is synchronous and returns a result rather than a job id, and `install`/`deploy`
418
- * resolve their argv from the request body first. Declared so the surface check covers every
419
- * action the dispatcher answers, not only the table's keys.
416
+ * The four actions the dispatcher answers INLINE, without consulting the table above:
417
+ * `restore` is synchronous and returns a result rather than a job id, and `install`/`deploy`/
418
+ * `rebuild` resolve their argv from the request body first. Declared so the surface check
419
+ * covers every action the dispatcher answers, not only the table's keys.
420
420
  */
421
- export const INLINE_ACTIONS = ['restore', 'install', 'deploy'];
421
+ export const INLINE_ACTIONS = ['restore', 'install', 'deploy', 'rebuild'];
422
422
 
423
423
  /**
424
424
  * ⚠ `doctrines` DEFAULTS TO THE FULL SET, and it is the one axis here whose default is not the
package/js/web/server.mjs CHANGED
@@ -37,6 +37,7 @@ import { existsSync } from 'node:fs';
37
37
  import { createServer } from 'node:http';
38
38
  import { join, resolve as pathResolve } from 'node:path';
39
39
  import { fileURLToPath } from 'node:url';
40
+ import { sweepActivity } from '../hosts/activity.mjs';
40
41
 
41
42
  const ROOT = pathResolve(import.meta.dirname, '..', '..');
42
43
 
@@ -153,6 +154,11 @@ export async function serve({ theme = null, port = 4747, openBrowser = true,
153
154
  // Read by `/api/update`, whose background `git fetch` must not race a running update's pull.
154
155
  state.jobBusy = () => jm.busy;
155
156
  const srv = createServer(makeHandler(state, jm, token, dist, holder));
157
+ // A GET only reads, and the OpenCode plugin never sweeps: ended sessions are archived here,
158
+ // once at start and every 10 minutes. Best-effort — a sweep failure never stops the console.
159
+ const sweep = () => { try { sweepActivity(join(state.target, 'activity')); } catch { /* best-effort */ } };
160
+ sweep();
161
+ setInterval(sweep, 600_000).unref();
156
162
  // A client trickling headers or a body (slowloris) would hold a socket forever otherwise; every
157
163
  // real request here is a few KB from the same machine.
158
164
  srv.requestTimeout = 30_000;
@@ -3,7 +3,15 @@
3
3
  * `notebook/usage.jsonl` (the writer is js/hosts/usage.mjs, and the OpenCode guard plugin's copy).
4
4
  *
5
5
  * `{ enabled, since, days_counted, per_day[30], rows[{install, kind, name, n}],
6
- * never[{install, kind, name}] }`, the window being the last 30 days including today.
6
+ * never[{install, kind, name}], names[{kind, name, n, installs, per_day[30], last}] }`, the
7
+ * window being the last 30 days including today.
8
+ *
9
+ * `names` is the Library's view, fleet-wide: one entry per distinct kind+name, summed over every
10
+ * install, because a skill fired daily on claude and never on opencode IS used — reading
11
+ * `never` (per install) for that was the OV-2 bug. `installs` names those with a call in the
12
+ * window; `last` is the latest day across installs, day-granular and bounded by the 90-day read,
13
+ * so a name whose only lines are older than the window still appears, with n 0 and its `last`.
14
+ * Bounded: distinct names × 30.
7
15
  *
8
16
  * `since` is the oldest day any ledger holds and `days_counted` how many of the 30 it covers:
9
17
  * the console keeps the never-fired claim back until a full 30 are counted, so a fresh install
@@ -53,6 +61,7 @@ export function usageSummary({ now = Date.now(), targets = installTargets() } =
53
61
  const first = days[0];
54
62
  const perDay = new Array(WINDOW).fill(0);
55
63
  const counts = new Map();
64
+ const names = new Map();
56
65
  const never = [];
57
66
  let since = null;
58
67
  let enabled = !process.env.GENESEED_NO_USAGE;
@@ -63,9 +72,18 @@ export function usageSummary({ now = Date.now(), targets = installTargets() } =
63
72
  const fired = new Set();
64
73
  for (const e of entries) {
65
74
  if (since === null || e.ts < since) since = e.ts;
75
+ const nk = `${e.kind}\u0000${e.name}`;
76
+ let it = names.get(nk);
77
+ if (!it) names.set(nk, it = { kind: e.kind, name: e.name, n: 0, installs: [], per_day: new Array(WINDOW).fill(0), last: e.ts });
78
+ if (e.ts > it.last) it.last = e.ts;
66
79
  if (e.ts < first) continue;
67
80
  const i = days.indexOf(e.ts);
68
- if (i >= 0) perDay[i] += 1;
81
+ if (i >= 0) {
82
+ perDay[i] += 1;
83
+ it.per_day[i] += 1;
84
+ it.n += 1;
85
+ if (!it.installs.includes(install)) it.installs.push(install);
86
+ }
69
87
  const key = `${install}\u0000${e.kind}\u0000${e.name}`;
70
88
  counts.set(key, (counts.get(key) || 0) + 1);
71
89
  fired.add(`${e.kind}\u0000${e.name}`);
@@ -86,7 +104,10 @@ export function usageSummary({ now = Date.now(), targets = installTargets() } =
86
104
  }).sort((a, b) => b.n - a.n || a.name.localeCompare(b.name));
87
105
  const daysCounted = since === null ? 0
88
106
  : Math.min(WINDOW, Math.floor((Date.parse(day(now)) - Date.parse(since)) / DAY_MS) + 1);
89
- return { enabled, since, days_counted: daysCounted, per_day: perDay, rows, never };
107
+ return {
108
+ enabled, since, days_counted: daysCounted, per_day: perDay, rows, never,
109
+ names: [...names.values()].sort((a, b) => b.n - a.n || a.name.localeCompare(b.name)),
110
+ };
90
111
  }
91
112
 
92
113
  export const apiUsage = () => usageSummary();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "//": "Every field here is argued and gated in tests/unit/package_manifest.test.mjs. `files`, `bin` and `engines` each have a test that fails when reality drifts from this file; `version` mirrors harness.config.json and is gated too. Read that docblock before editing this one.",
3
3
  "name": "geneseed",
4
- "version": "4.20.0",
4
+ "version": "4.22.0",
5
5
  "description": "A portable, theme-able harness you implant once and use everywhere to grow a disciplined AI coding agent.",
6
6
  "keywords": [
7
7
  "ai",
@@ -24,4 +24,5 @@ crews for what's substantial, and keeps answering the user without blocking.
24
24
  commits and merges only once the user accepts ({{DOCTRINE:consent-before-push}}). Commit, push and
25
25
  merge stay the parent's alone.
26
26
  - **Report.** Surface pipeline completions, failures, and merges to the user as
27
- they happen.
27
+ they happen; a crew that returns no proof, or goes silent, is handled as the
28
+ pipeline {{SKILL}}'s step 2 says.
@@ -26,8 +26,8 @@ The minimum roster per task type. The crew lead chooses the crew from the whole
26
26
  ## Procedure
27
27
 
28
28
  1. Take the triage as given. Under foreman mode the task reached you because it met the mode's count; invoked directly, the user's request is the trigger. Do not weigh it again and fall back to doing the work yourself.
29
- 2. **Dispatch the crew lead** in the background, using the host's general-purpose {{AGENT}}. Before dispatch, record BASE and set the crew's **write set**; check it against every other pipeline in flight ({{DOCTRINE:one-writer-per-file}}) — two crews whose sets overlap do not run at once. The brief carries: the task as the user stated it, the task type, BASE, the write set, the proof commands, a pointer to this {{SKILL}}, and the rule that it never commits, pushes or merges. Tell the user the pipeline is running, then go back to the user. Do not wait on the crew lead.
30
- 3. **The crew lead composes the crew** from the floor above and adds any {{AGENT}} the task needs. It dispatches each crew member as its own subagent, each handed what the previous one produced. Where the crew lead holds no dispatch tool (see *Hosts* below), it plays each role in turn itself, with the same hand-offs and the same envelope. Steps 4 to 7 are the crew lead's, except where they name the parent.
29
+ 2. **Dispatch the crew lead** in the background, using the host's general-purpose {{AGENT}}. Before dispatch, record BASE and set the crew's **write set**; check it against every other pipeline in flight ({{DOCTRINE:one-writer-per-file}}) — two crews whose sets overlap do not run at once. The brief carries: the task as the user stated it, the task type, BASE, the write set, the proof commands, a pointer to this {{SKILL}}, and the rule that it never commits, pushes or merges. Tell the user the pipeline is running, then go back to the user. Do not wait on the crew lead. **Then watch what you dispatched.** An envelope without proof, or one that says the crew is still waiting, is a failure: act on it at once — resume the crew lead (`SendMessage` on Claude Code) or take over its worktree — never wait for a notification it promised. A crew member's report that reaches you directly means its crew lead has already ended; act on it the same way. Before you end a turn with a crew still out, set a check where the host offers one (`CronCreate` on Claude Code, top level only); elsewhere, check at the start of every turn. A crew is stalled when its transcript and output have not grown for 15 minutes **and** it has no live child process: ping it once; if the next check shows no change, stop it, then take over from its worktree. A crew whose output still grows, or that runs a child process, is never taken over — a long suite or canary is not a stall.
30
+ 3. **The crew lead composes the crew** from the floor above and adds any {{AGENT}} the task needs. It dispatches each crew member as its own subagent, each handed what the previous one produced. **The crew lead never ends with a member unresolved.** Its last message is its result: once it ends, nothing wakes it, and a member that outlives it reports past it, to the parent. It may run members in parallel, but holds every member's result before it ends — returned, or failed and then redone or named as failed in the envelope. A member that returns nothing has failed. Where the crew lead holds no dispatch tool (see *Hosts* below), it plays each role in turn itself, with the same hand-offs and the same envelope. Steps 4 to 7 are the crew lead's, except where they name the parent.
31
31
  4. Isolate the crew's work in its own git worktree/branch. Where worktrees are unavailable, fall back to a single tree, one pipeline at a time, and say so. The crew writes only inside its write set; shared append files (registries, index tables, lockfiles, generated bundles) are the parent's to apply, never a crew's.
32
32
  5. **The dev↔tester loop:** the developer implements, the tester validates — runs the tests and lint, produces raw logs. On failure, the findings go back to the developer — two repair rounds at most, then one fresh developer (a higher model tier where the host offers one) carrying the tester's findings ({{DOCTRINE:bound-the-loop}}); if that fails too, stop, do not merge, and report the failure with the branch left in place for inspection. A conflict or ambiguity between the plan, the findings and the code is yours to decide: decide it, record `Ruling: <choice> — <why> — <cost if wrong>` in the worklog, and continue. Stop only for what {{LAW:echo-the-intent}}, {{LAW:deletion-is-deliberate}} or {{DOCTRINE:consent-before-push}} names; every ruling goes in the final report ({{DOCTRINE:declare-the-judgment-calls}}). When the plan names a `Spec:`, the analyst reads it once; the spec outranks the plan.
33
33
  6. **Pick the shape by host** (table below). Where the host offers a workflow tool the {{SKILL}} may use without a fresh opt-in, a saved script may stand in for the crew lead: analyst → developer → (tester ⇄ developer)×≤2 → fresh developer → proof ([workflow {{SKILL}}](workflow.md)). Everywhere else the crew lead runs the same stages, with the same hand-offs and the same delivery contract.
@@ -72,13 +72,13 @@ re-derived. Then take exactly one branch.
72
72
  5. **Destination.** Scope decides the file: a rule that holds across all the user's
73
73
  work goes to the *global* install's `user-rules.md`, a rule bound to this
74
74
  codebase to the project's. Tag it to match: `scope: project` — this repo, committable,
75
- binds the team; `scope: global` — every repository on the machine; `scope: user` —
76
- a personal preference, kept in the global file too, never the team's. Read the target first ({{LAW:verify-before-asserting}} — the real current
75
+ binds the team; `scope: global` — every repository on the machine. `user` is still read
76
+ as `global`. Read the target first ({{LAW:verify-before-asserting}} — the real current
77
77
  rules, not a remembered copy). The build seeds it once and never overwrites it;
78
78
  if it is genuinely absent, create it with a `# User rules` header and note that a
79
79
  rebuild would have seeded it.
80
80
  6. **Draft in the file's own format**: the next free `## R<n> — Title` heading, an
81
- optional `(scope: project|global|user | source: …)` metadata line, then the rule in one
81
+ optional `(scope: project|global | source: …)` metadata line, then the rule in one
82
82
  short paragraph, plain and testable. For a rule the user stated, `source:` keeps
83
83
  their own words and the day they said them — `source: user 2026-10-16 "never push
84
84
  red"` — one sentence at most: it is what later tells a stale rule from a changed
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-DlYQp10C.js";import{t as r}from"./api-BfpZmUMI.js";import{A as i,J as a,K as o,T as s,V as c,k as l,st as u,u as d}from"./index-Dwo3Gxek.js";import{n as f}from"./jobBuckets-Dpjvbfm1.js";import{c as p,d as m,i as h,l as g,n as _,o as v,r as y,s as b,t as x,u as S}from"./activity-BEWV9er4.js";import{t as C}from"./EmptyState-1sPNleqv.js";import{t as w}from"./usePoll-bDFN-Hr6.js";var T=e(t(),1),E=n(),D=e=>e.catch(()=>null);function O({s:e}){let t=(0,T.useId)(),n=e.todos,r=b(e);return(0,E.jsxs)(`a`,{className:`card pad-md act-card`,href:`#/activity/${encodeURIComponent(e.session_id)}`,"aria-labelledby":`${t}-t ${t}-st`,"aria-describedby":r?`${t}-c`:void 0,children:[(0,E.jsx)(x,{s:e,id:t,heading:e.title||h(e.cwd)||e.session_id,children:(0,E.jsx)(c,{name:`chevron`,className:`glyph act-chev`})}),n&&n.total>0&&(0,E.jsx)(`div`,{className:`act-foot`,children:(0,E.jsxs)(`span`,{className:`row gap-8 dim act-sm`,children:[(0,E.jsx)(y,{done:n.done,total:n.total}),`plan `,n.done,`/`,n.total]})}),(0,E.jsxs)(`div`,{className:`dim mono act-updated`,children:[`updated `,o(e.updated_at),` ago`]})]})}var k=[[`all`,`All`],[`needs`,`Needs you`],[`runs`,`Runs`],[`gates`,`Gate asks`]];function A(){let e=new URLSearchParams(window.location.hash.split(`?`)[1]||``),t=e.get(`f`);return{f:k.some(([e])=>e===t)?t:`all`,host:e.get(`host`)||``,project:e.get(`project`)||``}}function j(e){let t=new URLSearchParams;e.f!==`all`&&t.set(`f`,e.f),e.host&&t.set(`host`,e.host),e.project&&t.set(`project`,e.project);let n=t.toString();window.history.replaceState(null,``,`#/activity${n?`?${n}`:``}`)}function M({enabled:e,onToggle:t}){return(0,E.jsxs)(`section`,{className:`card pad-md act-track`,"aria-labelledby":`act-track-h`,children:[(0,E.jsx)(c,{name:`activity`,className:`glyph act-fixed`}),(0,E.jsxs)(`div`,{className:`act-grow`,children:[(0,E.jsx)(`h2`,{id:`act-track-h`,className:`act-track-title`,children:e?`Live sessions are on`:`Live sessions are off`}),!e&&(0,E.jsx)(`p`,{className:`dim act-sm act-track-p`,children:`Runs and gate asks below come from the job log and the gate ledger. Turn tracking on to see what each session is doing now.`})]}),(0,E.jsxs)(`div`,{className:`row gap-10 act-fixed act-sm`,children:[(0,E.jsx)(`span`,{id:`act-track-l`,children:`Track live sessions`}),(0,E.jsx)(`div`,{className:`sw-toggle${e?` on`:``}`,role:`switch`,"aria-checked":e,"aria-labelledby":`act-track-l`,tabIndex:0,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.key===` `&&e.preventDefault(),t())}})]})]})}function N({jobs:e,loading:t}){let n=typeof e?.cap==`number`?e.cap:void 0,r=g(e?.jobs,{days:14,cap:n}),i=m(r.map(e=>e.nodata?`-`:e.n).join(`,`),`scaleY`),a=Math.max(1,...r.map(e=>e.n)),o=r.reduce((e,t)=>e+t.n,0),s=r.find(e=>!e.nodata),c=r.some(e=>e.nodata),l=`Runs per day: ${r.filter(e=>e.n).map(e=>`${e.n} on ${S(e.key)}`).join(`, `)||`none`}.`+(c?s?` Days before ${S(s.key)} are older than the runs the log keeps.`:` No run is in the log yet.`:``);return(0,E.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-runs-h`,children:[(0,E.jsxs)(`div`,{className:`act-stat-head`,children:[(0,E.jsx)(`h2`,{id:`act-runs-h`,className:`act-lbl`,children:`Runs per day · 14 days`}),e&&(0,E.jsx)(`span`,{className:`act-big`,children:o})]}),t?(0,E.jsx)(`p`,{className:`dim act-sm`,children:`Reading the job log…`}):e?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`act-runs`,role:`img`,"aria-label":l,ref:i,children:r.map(e=>e.nodata?(0,E.jsx)(`i`,{className:`nodata`},e.key):e.n?(0,E.jsx)(`i`,{"data-sweep":!0,style:{height:`${e.n/a*100}%`},title:`${S(e.key)}: ${e.n}`},e.key):(0,E.jsx)(`i`,{className:`zero`},e.key))}),(0,E.jsxs)(`div`,{className:`mono act-axis`,"aria-hidden":`true`,children:[(0,E.jsx)(`span`,{children:S(r[0].key)}),(0,E.jsx)(`span`,{children:S(r[7].key)}),(0,E.jsx)(`span`,{children:`today`})]}),c&&(0,E.jsxs)(`span`,{className:`dim act-xs`,children:[`Hatched: older than the runs the log keeps`,n?` (last ${n})`:``,`.`]})]}):(0,E.jsx)(`p`,{className:`dim act-sm`,children:`The job log could not be read.`})]})}function ee({rows:e,gates:t,loading:n}){let r=e.reduce((e,t)=>e+t.n,0);return(0,E.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-gates-h`,children:[(0,E.jsxs)(`div`,{className:`act-stat-head`,children:[(0,E.jsx)(`h2`,{id:`act-gates-h`,className:`act-lbl`,children:`Gate asks by rule · 30 days`}),t&&(0,E.jsx)(`span`,{className:`act-big`,children:r})]}),n?(0,E.jsx)(`p`,{className:`dim act-sm`,children:`Reading the gate ledger…`}):e.length?(0,E.jsx)(`ul`,{className:`gate-rows`,children:e.slice(0,6).map((e,t)=>(0,E.jsxs)(`li`,{children:[(0,E.jsxs)(`span`,{className:`act-ell`,children:[e.name,` `,(0,E.jsx)(`span`,{className:`mono dim act-xs`,children:e.rule})]}),(0,E.jsx)(_,{vals:e.per_day,i:t,sweep:!0}),(0,E.jsx)(`span`,{className:`mono`,children:e.n})]},e.rule))}):(0,E.jsx)(`p`,{className:`dim act-sm`,children:t?`No gate asked in 30 days.`:`The gate ledger could not be read.`})]})}var P={done:[`ok`,`done`],failed:[`bad`,`failed`],running:[``,`running`]};function F({job:e,longest:t}){let n=f(e),r=e.duration?Math.round(e.duration*10)/10:0,[i,a]=P[e.status]||[``,e.status||`…`],o=e.status===`running`?`Still running`:r?`Took ${r} second${r===1?``:`s`}`:`No duration`,s=e.started?new Date(e.started*1e3).toLocaleTimeString(`en-GB`,{hour:`2-digit`,minute:`2-digit`}):`—`;return(0,E.jsxs)(`li`,{className:`act-row`,children:[(0,E.jsx)(`span`,{className:`mono dim act-xs`,children:s}),(0,E.jsx)(c,{name:`play`,className:`glyph act-glyph`}),(0,E.jsxs)(`span`,{className:`act-what`,children:[(0,E.jsx)(`span`,{className:`act-row-title`,children:n.verb}),n.scope&&(0,E.jsx)(`span`,{className:`dim act-xs act-ell`,title:n.command,children:n.scope})]}),(0,E.jsx)(`span`,{className:`act-dur`,role:`img`,"aria-label":o,children:(0,E.jsx)(`span`,{"data-sweep":!0,style:{width:t>0?`${(e.duration||0)/t*100}%`:`0%`}})}),(0,E.jsx)(`span`,{className:`badge ${i}`,children:a})]})}function I({gate:e}){return(0,E.jsxs)(`li`,{className:`act-row gate`,children:[(0,E.jsx)(`span`,{className:`mono dim act-xs`,children:`—`}),(0,E.jsx)(c,{name:`rule`,className:`glyph act-glyph t-warn`}),(0,E.jsxs)(`span`,{className:`act-what`,children:[(0,E.jsx)(`span`,{className:`act-row-title`,children:e.title}),(0,E.jsx)(`span`,{className:`dim act-xs`,children:`Gate ledger`})]}),(0,E.jsx)(`span`,{className:`act-dur-none`,"aria-hidden":`true`}),(0,E.jsx)(`span`,{className:`badge warn`,children:`asked`})]})}var L=(e,t)=>[...new Set([...e.filter(Boolean),t].filter(Boolean))];function R(){let[e,t]=(0,T.useState)(null),[n,o]=(0,T.useState)(``),[c,f]=(0,T.useState)(A),g=e=>{let t={...c,...e};f(t),j(t)};w(e=>r.activity().then(n=>{e()&&(t(n),o(``))},t=>{e()&&o(t.message)}),2e3,[]);let _=a(()=>D(r.jobs()),[]),y=a(()=>D(r.gates()),[]),b=a(()=>D(r.catalog(`laws`)),[]),x=!e||e.enabled!==!1,S=[...e?.activity||[]].sort((e,t)=>e.session_id<t.session_id?-1:+(e.session_id>t.session_id)),P=u(),R=x&&e?S.filter(p).length:null,z=L(S.map(e=>e.host),c.host),B=L(S.map(e=>h(e.cwd)),c.project),V=c.host&&c.project?`host or project`:c.host?`host`:c.project?`project`:``,H=e=>(!c.host||e.host===c.host)&&(!c.project||h(e.cwd)===c.project),U=S.filter(e=>H(e)&&(c.f!==`needs`||p(e))),W=c.f===`all`||c.f===`needs`,G=!V&&(c.f===`all`||c.f===`runs`),K=!V&&(c.f===`all`||c.f===`gates`),q=_.data?.jobs||[],J=d(y.data,b.data),Y=v(q,J,y.data?.days).map(e=>({...e,runs:G?e.runs:[],gate:K?e.gate:null})).filter(e=>e.runs.length||e.gate),X=Math.max(0,...q.map(e=>e.duration||0)),Z=m(Y.flatMap(e=>e.runs.map(e=>`${e.id}:${e.duration}`)).join(`,`),`scaleX`),Q=async()=>{let e=!x;try{let n=await r.activityToggle(e);if(n.ok===!1){o(n.error||`Could not change tracking`);return}t(e=>({...e||{},enabled:n.enabled,activity:n.enabled&&e?.activity||[]})),o(``)}catch(e){o(e.message)}},$=(e,t,n)=>(0,E.jsxs)(`span`,{className:`row gap-8 act-sm`,children:[(0,E.jsx)(`label`,{htmlFor:`act-f-${e}`,children:t}),(0,E.jsxs)(`select`,{id:`act-f-${e}`,className:`sel`,value:c[e],disabled:n.length===0,title:n.length===0?`No source carries a ${e} yet`:void 0,onChange:t=>g({[e]:t.target.value}),children:[(0,E.jsxs)(`option`,{value:``,children:[`All `,e===`host`?`hosts`:`projects`]}),n.map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))]})]});return(0,E.jsxs)(`div`,{className:`narrow`,children:[(0,E.jsx)(s,{title:`Activity`,sub:`What your agents ran, what the gates asked, and which sessions are waiting on you.`}),n&&(0,E.jsx)(`div`,{className:`act-gap`,children:(0,E.jsx)(l,{error:n})}),e&&(0,E.jsx)(M,{enabled:x,onToggle:Q}),(0,E.jsxs)(`div`,{className:`act-today`,children:[(0,E.jsx)(N,{jobs:_.data,loading:_.loading}),(0,E.jsx)(ee,{rows:J,gates:y.data,loading:y.loading}),(0,E.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-wait-h`,children:[(0,E.jsx)(`h2`,{id:`act-wait-h`,className:`act-lbl`,children:`Waiting on you`}),(0,E.jsxs)(`span`,{className:`act-big act-wait`,children:[R??`—`,` `,(0,E.jsx)(`span`,{className:`dim act-sm`,children:`sessions`})]}),(0,E.jsx)(`p`,{className:`dim act-sm`,children:x?`A session that waits on an approval or on your answer counts here.`:`Turn tracking on to count the sessions that wait on you.`})]})]}),(0,E.jsxs)(`div`,{className:`row wrap gap-8 act-filters`,children:[(0,E.jsx)(`div`,{role:`group`,"aria-label":`Filter`,className:`row wrap gap-8`,children:k.map(([e,t])=>(0,E.jsxs)(`button`,{type:`button`,className:c.f===e?`chip-f on`:`chip-f`,"aria-pressed":c.f===e,onClick:()=>g({f:e}),children:[t,e===`needs`&&R>0?(0,E.jsxs)(`span`,{className:`mono`,children:[` `,R]}):null]},e))}),$(`host`,`Host`,z),$(`project`,`Project`,B)]}),V&&c.f!==`needs`&&(0,E.jsxs)(`p`,{className:`dim act-sm`,children:[`Runs and gate asks carry no `,V,`; showing sessions only.`]}),W&&(e?!x&&c.f!==`needs`?null:U.length===0?c.f===`needs`?(0,E.jsx)(C,{title:`Nothing waits on you`}):(0,E.jsxs)(C,{title:`No active sessions`,children:[`Run `,(0,E.jsx)(`code`,{children:`opencode`}),` and the sessions it spins up appear here.`]}):(0,E.jsx)(`div`,{className:`stack gap-12 act-live`,ref:P,children:U.map(e=>(0,E.jsx)(`div`,{"data-flip":e.session_id,children:(0,E.jsx)(O,{s:e})},e.session_id))}):(0,E.jsx)(i,{label:`Reading live sessions…`})),c.f!==`needs`&&(0,E.jsx)(`section`,{"aria-label":`Feed`,className:`stack gap-16 act-feed`,ref:Z,children:Y.map(e=>(0,E.jsxs)(`section`,{className:`card act-day`,children:[(0,E.jsxs)(`h3`,{className:`act-day-h`,children:[(0,E.jsx)(`span`,{children:e.title}),(0,E.jsx)(`span`,{className:`mono dim`,children:e.sum})]}),(0,E.jsxs)(`ul`,{className:`act-rows`,children:[e.runs.map(e=>(0,E.jsx)(F,{job:e,longest:X},e.id)),e.gate&&(0,E.jsx)(I,{gate:e.gate})]})]},e.key))})]})}export{R as default};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-DlYQp10C.js";import{t as r}from"./api-BfpZmUMI.js";import{B as i,G as a,O as o,k as s,w as c}from"./index-osXUqzdX.js";import{i as l,r as u,t as d}from"./activity-BGy8Bb_l.js";import{t as f}from"./EmptyState-1sPNleqv.js";import{t as p}from"./usePoll-bDFN-Hr6.js";var m=e(t(),1),h=n();function g(e){return e.kind===`tool`?e.status===`error`?`bad`:e.status===`completed`?`ok`:`acc`:{retry:`warn`,error:`bad`,subtask:`acc`,text:`acc`}[e.kind]||``}function _({rec:e}){let t=e.who===`you`,n=[];t||(e.kind===`tool`&&e.ms!=null&&n.push(`${(e.ms/1e3).toFixed(1)}s`),e.kind===`step`&&(e.tokens&&n.push(`${l(e.tokens)} tok`),e.cost&&n.push(`$${e.cost.toFixed(2)}`)),e.kind===`subtask`&&e.agent&&n.unshift(e.agent));let r=!t&&(e.kind===`text`||e.kind===`thinking`||e.kind===`step`),i=t?e.text:e.label||e.snippet||e.kind;return(0,h.jsxs)(`div`,{className:`row gap-10 act-line`,children:[(0,h.jsx)(`span`,{className:`badge act-who ${t?``:`acc`}`,children:t?`you`:`agent`}),(0,h.jsxs)(`div`,{className:`act-grow act-sm`,children:[!t&&(0,h.jsx)(`span`,{className:`feed-dot act-inline-dot ${g(e)||`acc`}`}),e.kind===`thinking`&&(0,h.jsx)(`span`,{className:`dim`,children:`thinking: `}),r?(0,h.jsx)(`span`,{className:`dim`,children:i}):t?i:(0,h.jsx)(`b`,{children:i}),e.error&&(0,h.jsxs)(`span`,{className:`dim`,children:[`: `,e.error]})]}),n.length>0&&(0,h.jsx)(`span`,{className:`dim mono act-xs act-fixed`,children:n.join(` · `)}),e.t?(0,h.jsx)(`time`,{className:`mono dim act-xs act-fixed`,dateTime:new Date(e.t).toISOString(),title:`${a(e.t/1e3)} ago`,children:new Date(e.t).toTimeString().slice(0,8)}):null]})}function v({turns:e}){return!e||e.length===0?(0,h.jsx)(`div`,{className:`dim act-sm`,children:`No conversation captured yet.`}):(0,h.jsx)(`div`,{className:`stack gap-12`,children:e.map((e,t)=>{let n=e.role===`user`;return(0,h.jsxs)(`div`,{className:`row gap-10 act-line`,children:[(0,h.jsx)(`span`,{className:`badge act-who ${n?``:`acc`}`,children:n?`you`:`agent`}),(0,h.jsx)(`div`,{className:`act-min act-sm${n?``:` muted`}`,children:e.text})]},t)})})}function y({sid:e}){let[t,n]=(0,m.useState)(null),[l,g]=(0,m.useState)(``),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(!1),C=(0,m.useId)();p(t=>y?void 0:r.activityDetail(e).then(e=>{t()&&(n(e),g(``),b(!1))},e=>{t()&&(e.status===404?b(!0):g(e.message))}),2e3,[e,y]);let w=(0,h.jsxs)(`a`,{className:`btn ghost sm act-back`,href:`#/activity`,children:[(0,h.jsx)(i,{name:`arrow`}),` Activity`]});if(y)return(0,h.jsxs)(`div`,{className:`narrow`,children:[w,(0,h.jsx)(f,{title:`Session ended`,action:(0,h.jsx)(`a`,{href:`#/activity`,children:`Back to Activity`}),children:`It's no longer live.`})]});if(!t)return(0,h.jsxs)(`div`,{className:`narrow`,children:[w,l?(0,h.jsx)(o,{error:l}):(0,h.jsx)(s,{label:`Loading session…`})]});let T=t.session,E=T.files,D=T.todos,O=!!(E&&E.items&&E.items.length>0),k=!!(D&&D.items&&D.items.length>0),A=t.conversation||[],j=t.timeline||[],M=[...A.filter(e=>e.role===`user`).map(e=>({who:`you`,text:e.text,t:e.t||0})),...j.map(e=>({...e,who:`agent`}))].sort((e,t)=>(e.t||0)-(t.t||0));return(0,h.jsxs)(`div`,{className:`narrow`,children:[w,(0,h.jsx)(c,{title:T.title||u(T.cwd)||T.session_id,sub:T.cwd?(0,h.jsx)(`span`,{className:`mono act-cwd`,title:T.cwd,children:T.cwd}):null}),l&&(0,h.jsx)(`div`,{className:`act-gap`,children:(0,h.jsx)(o,{error:l})}),(0,h.jsxs)(`div`,{className:`card pad-md`,children:[(0,h.jsx)(d,{s:T}),(0,h.jsxs)(`div`,{className:`dim act-updated`,children:[`updated `,a(T.updated_at),` ago`]})]}),(O||k)&&(0,h.jsxs)(`div`,{className:`grid gap-12 act-panels${O&&k?` two`:``}`,children:[O&&(0,h.jsxs)(`div`,{className:`card pad-md`,children:[(0,h.jsx)(`div`,{className:`card-head`,children:(0,h.jsxs)(`h2`,{children:[`Files touched `,(0,h.jsxs)(`span`,{className:`dim`,children:[`(`,E.count,`)`]})]})}),(0,h.jsx)(`div`,{className:`stack act-list`,children:E.items.map(e=>(0,h.jsxs)(`div`,{className:`row between gap-12 act-sm`,children:[(0,h.jsx)(`span`,{className:`mono act-ell act-grow`,title:e.file,children:e.file}),(0,h.jsxs)(`span`,{className:`act-fixed`,children:[(0,h.jsxs)(`span`,{className:`t-good`,children:[`+`,e.additions]}),` `,(0,h.jsxs)(`span`,{className:`t-bad`,children:[`−`,e.deletions]})]})]},e.file))})]}),k&&(0,h.jsxs)(`div`,{className:`card pad-md`,children:[(0,h.jsx)(`div`,{className:`card-head`,children:(0,h.jsxs)(`h2`,{children:[`Plan`,` `,(0,h.jsxs)(`span`,{className:`dim`,children:[`(`,D.done,`/`,D.total,`)`]})]})}),(0,h.jsx)(`div`,{className:`stack act-list`,children:D.items.map((e,t)=>(0,h.jsxs)(`div`,{className:`row gap-8 act-sm`,children:[(0,h.jsx)(`span`,{className:`feed-dot ${e.status===`completed`?`ok`:e.status===`in_progress`?`acc`:``}`}),(0,h.jsx)(`span`,{className:e.status===`completed`?`act-done`:void 0,children:e.content})]},t))})]})]}),(0,h.jsxs)(`div`,{className:`card pad-md act-mt`,children:[(0,h.jsxs)(`div`,{className:`card-head act-tl-head`,children:[(0,h.jsx)(`h2`,{children:`Timeline`}),j.length>0&&(0,h.jsx)(`button`,{className:`btn ghost sm`,"aria-expanded":x,"aria-controls":C,onClick:()=>S(e=>!e),children:x?`Show conversation`:`Show full stream (${M.length})`})]}),(0,h.jsx)(`div`,{id:C,children:x?(0,h.jsx)(`div`,{className:`stack gap-12`,children:M.map((e,t)=>(0,h.jsx)(_,{rec:e},t))}):(0,h.jsx)(v,{turns:A})})]})]})}export{y as default};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-DlYQp10C.js";import{t as r}from"./api-BfpZmUMI.js";import{A as i,K as a,T as o,V as s,k as c}from"./index-Dwo3Gxek.js";import{a as l,i as u,t as d}from"./activity-BEWV9er4.js";import{t as f}from"./EmptyState-1sPNleqv.js";import{t as p}from"./usePoll-bDFN-Hr6.js";var m=e(t(),1),h=n();function g(e){return e.kind===`tool`?e.status===`error`?`bad`:e.status===`completed`?`ok`:`acc`:{retry:`warn`,error:`bad`,subtask:`acc`,text:`acc`}[e.kind]||``}function _({rec:e}){let t=e.who===`you`,n=[];t||(e.kind===`tool`&&e.ms!=null&&n.push(`${(e.ms/1e3).toFixed(1)}s`),e.kind===`step`&&(e.tokens&&n.push(`${l(e.tokens)} tok`),e.cost&&n.push(`$${e.cost.toFixed(2)}`)),e.kind===`subtask`&&e.agent&&n.unshift(e.agent));let r=!t&&(e.kind===`text`||e.kind===`thinking`||e.kind===`step`),i=t?e.text:e.label||e.snippet||e.kind;return(0,h.jsxs)(`div`,{className:`row gap-10 act-line`,children:[(0,h.jsx)(`span`,{className:`badge act-who ${t?``:`acc`}`,children:t?`you`:`agent`}),(0,h.jsxs)(`div`,{className:`act-grow act-sm`,children:[!t&&(0,h.jsx)(`span`,{className:`feed-dot act-inline-dot ${g(e)||`acc`}`}),e.kind===`thinking`&&(0,h.jsx)(`span`,{className:`dim`,children:`thinking: `}),r?(0,h.jsx)(`span`,{className:`dim`,children:i}):t?i:(0,h.jsx)(`b`,{children:i}),e.error&&(0,h.jsxs)(`span`,{className:`dim`,children:[`: `,e.error]})]}),n.length>0&&(0,h.jsx)(`span`,{className:`dim mono act-xs act-fixed`,children:n.join(` · `)}),e.t?(0,h.jsx)(`time`,{className:`mono dim act-xs act-fixed`,dateTime:new Date(e.t).toISOString(),title:`${a(e.t/1e3)} ago`,children:new Date(e.t).toTimeString().slice(0,8)}):null]})}function v({turns:e}){return!e||e.length===0?(0,h.jsx)(`div`,{className:`dim act-sm`,children:`No conversation captured yet.`}):(0,h.jsx)(`div`,{className:`stack gap-12`,children:e.map((e,t)=>{let n=e.role===`user`;return(0,h.jsxs)(`div`,{className:`row gap-10 act-line`,children:[(0,h.jsx)(`span`,{className:`badge act-who ${n?``:`acc`}`,children:n?`you`:`agent`}),(0,h.jsx)(`div`,{className:`act-min act-sm${n?``:` muted`}`,children:e.text})]},t)})})}function y({sid:e}){let[t,n]=(0,m.useState)(null),[l,g]=(0,m.useState)(``),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(!1),C=(0,m.useId)();p(t=>y?void 0:r.activityDetail(e).then(e=>{t()&&(n(e),g(``),b(!1))},e=>{t()&&(e.status===404?b(!0):g(e.message))}),2e3,[e,y]);let w=(0,h.jsxs)(`a`,{className:`btn ghost sm act-back`,href:`#/activity`,children:[(0,h.jsx)(s,{name:`arrow`}),` Activity`]});if(y)return(0,h.jsxs)(`div`,{className:`narrow`,children:[w,(0,h.jsx)(f,{title:`Session ended`,action:(0,h.jsx)(`a`,{href:`#/activity`,children:`Back to Activity`}),children:`It's no longer live.`})]});if(!t)return(0,h.jsxs)(`div`,{className:`narrow`,children:[w,l?(0,h.jsx)(c,{error:l}):(0,h.jsx)(i,{label:`Loading session…`})]});let T=t.session,E=T.files,D=T.todos,O=!!(E&&E.items&&E.items.length>0),k=!!(D&&D.items&&D.items.length>0),A=t.conversation||[],j=t.timeline||[],M=[...A.filter(e=>e.role===`user`).map(e=>({who:`you`,text:e.text,t:e.t||0})),...j.map(e=>({...e,who:`agent`}))].sort((e,t)=>(e.t||0)-(t.t||0));return(0,h.jsxs)(`div`,{className:`narrow`,children:[w,(0,h.jsx)(o,{title:T.title||u(T.cwd)||T.session_id,sub:T.cwd?(0,h.jsx)(`span`,{className:`mono act-cwd`,title:T.cwd,children:T.cwd}):null}),l&&(0,h.jsx)(`div`,{className:`act-gap`,children:(0,h.jsx)(c,{error:l})}),(0,h.jsxs)(`div`,{className:`card pad-md`,children:[(0,h.jsx)(d,{s:T}),(0,h.jsxs)(`div`,{className:`dim act-updated`,children:[`updated `,a(T.updated_at),` ago`]})]}),(O||k)&&(0,h.jsxs)(`div`,{className:`grid gap-12 act-panels${O&&k?` two`:``}`,children:[O&&(0,h.jsxs)(`div`,{className:`card pad-md`,children:[(0,h.jsx)(`div`,{className:`card-head`,children:(0,h.jsxs)(`h2`,{children:[`Files touched `,(0,h.jsxs)(`span`,{className:`dim`,children:[`(`,E.count,`)`]})]})}),(0,h.jsx)(`div`,{className:`stack act-list`,children:E.items.map(e=>(0,h.jsxs)(`div`,{className:`row between gap-12 act-sm`,children:[(0,h.jsx)(`span`,{className:`mono act-ell act-grow`,title:e.file,children:e.file}),(0,h.jsxs)(`span`,{className:`act-fixed`,children:[(0,h.jsxs)(`span`,{className:`t-good`,children:[`+`,e.additions]}),` `,(0,h.jsxs)(`span`,{className:`t-bad`,children:[`−`,e.deletions]})]})]},e.file))})]}),k&&(0,h.jsxs)(`div`,{className:`card pad-md`,children:[(0,h.jsx)(`div`,{className:`card-head`,children:(0,h.jsxs)(`h2`,{children:[`Plan`,` `,(0,h.jsxs)(`span`,{className:`dim`,children:[`(`,D.done,`/`,D.total,`)`]})]})}),(0,h.jsx)(`div`,{className:`stack act-list`,children:D.items.map((e,t)=>(0,h.jsxs)(`div`,{className:`row gap-8 act-sm`,children:[(0,h.jsx)(`span`,{className:`feed-dot ${e.status===`completed`?`ok`:e.status===`in_progress`?`acc`:``}`}),(0,h.jsx)(`span`,{className:e.status===`completed`?`act-done`:void 0,children:e.content})]},t))})]})]}),(0,h.jsxs)(`div`,{className:`card pad-md act-mt`,children:[(0,h.jsxs)(`div`,{className:`card-head act-tl-head`,children:[(0,h.jsx)(`h2`,{children:`Timeline`}),j.length>0&&(0,h.jsx)(`button`,{className:`btn ghost sm`,"aria-expanded":x,"aria-controls":C,onClick:()=>S(e=>!e),children:x?`Show conversation`:`Show full stream (${M.length})`})]}),(0,h.jsx)(`div`,{id:C,children:x?(0,h.jsx)(`div`,{className:`stack gap-12`,children:M.map((e,t)=>(0,h.jsx)(_,{rec:e},t))}):(0,h.jsx)(v,{turns:A})})]})]})}export{y as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GreenhouseView-BCiZP9f9.js","assets/rolldown-runtime-hePW80VL.js","assets/react-DlYQp10C.js","assets/sections-ChwaobfW.js","assets/index-Dwo3Gxek.js","assets/api-BfpZmUMI.js","assets/index-CDSHv_7s.css","assets/jobBuckets-Dpjvbfm1.js","assets/OperatorHudView-BLXm0zzn.js","assets/JournalView-BSR51TKR.js","assets/drawable-ixCquffB.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n,t as r}from"./react-DlYQp10C.js";import{t as i}from"./api-BfpZmUMI.js";import{t as a}from"./drawable-ixCquffB.js";import{n as o,r as s}from"./sections-ChwaobfW.js";import{A as c,G as l,J as u,K as d,M as f,O as p,U as m,V as h,W as g,at as _,ft as v,it as y,k as b,l as x,lt as S,ot as C,rt as w,t as T,tt as E,w as D}from"./index-Dwo3Gxek.js";import{r as O}from"./jobBuckets-Dpjvbfm1.js";var k=t(n(),1),A=r();function j({segments:e,value:t,max:n,size:r=120,stroke:i=12,label:o,sweepMs:s=650}){let c=n>0?n:0,l=e||[{key:`v`,label:o,n:Math.min(Math.max(t||0,0),c),tone:`accent`}],u=e?l.reduce((e,t)=>e+t.n,0):c,d=e?l.map(e=>`${e.label}: ${e.n} of ${u}`).join(`, `):`${l[0].n} of ${u}`,f=r/2-i/2,p=r/2,m=e=>[p+f*Math.cos(e),p+f*Math.sin(e)],h=[],g=0;for(let e of l)h.push(g),g+=e.n;let b=(0,k.useRef)(null),x=l.map(e=>e.n).join(`,`);return(0,k.useLayoutEffect)(()=>{let e=b.current?.querySelectorAll(`path.ring-arc`);if(!s||!e?.length||!y())return;let t=l.map(e=>e.n/u).filter(e=>e>0),n=t.map((e,n)=>t.slice(0,n).reduce((e,t)=>e+t,0)),r=a(e);S(r,{draw:`0 0`});let i=v(r,{draw:[`0 0`,`0 1`],duration:(e,n)=>Math.max(s*t[n],60),delay:(e,t)=>s*n[t],ease:`linear`});return _(i,s)},[x,s]),(0,A.jsxs)(`svg`,{className:`ring`,width:r,height:r,viewBox:`0 0 ${r} ${r}`,role:`img`,"aria-label":o?`${o}: ${d}`:d,children:[(0,A.jsx)(`circle`,{className:`ring-track`,cx:p,cy:p,r:f,fill:`none`,strokeWidth:i}),(0,A.jsx)(`g`,{ref:b,children:u>0?l.map((e,t)=>{let n=e.n/u;if(!(n>0))return null;let r=h[t]/u*2*Math.PI-Math.PI/2,a=r+n*2*Math.PI,[o,s]=m(r),[c,l]=m(a),d=n>=.9999?`M ${o} ${s} A ${f} ${f} 0 1 1 ${2*p-o} ${2*p-s} A ${f} ${f} 0 1 1 ${o} ${s}`:`M ${o} ${s} A ${f} ${f} 0 ${+(n>.5)} 1 ${c} ${l}`;return(0,A.jsx)(`path`,{className:`ring-arc tone-${e.tone||`muted`}`,d,fill:`none`,strokeWidth:i,children:(0,A.jsxs)(`title`,{children:[e.label,`: `,e.n]})},e.key)}):null})]})}var M={neutral:`Loaded & ready`,imperial:`The Codex in force`,military:`The unit stands ready`,cyberpunk:`Jacked in`,wizard:`Wards in place`,pirate:`The crew stands ready`,gamer:`Game loaded`,sports:`The squad takes the field`,biker:`The crew rolls out`,commentator:`Lights out, away we go`,verstappen:`Setup's in`,joker:`Mic check`,mean:`Rules are up`,marvin:`Online. Reluctantly.`},N=(e,t)=>e.deployed?t===void 0||t===`good`?M[e.theme]||`Loaded & ready`:`Deployed`:`Not deployed`,P={good:`ok`,warn:`warn`,bad:`bad`};function F({verdict:e}){return e?(0,A.jsxs)(`span`,{className:`badge ${P[e.tone]}`,role:`status`,style:{alignSelf:`flex-start`},children:[(0,A.jsx)(`span`,{className:`dot`}),e.head]}):null}function I({overview:e,dataRev:t}){let{data:n}=u(()=>Promise.resolve().then(()=>i.catalog(`laws`)),[t],`catalog:laws`),r=m(e.diff),a=e.counts||{},o=[{key:`agents`,label:`Agents`,hash:`#/agents`},{key:`skills`,label:`Skills`,hash:`#/skills`},{key:`laws`,label:n?.nouns?.laws||`Dictates`,hash:`#/laws`}];return(0,A.jsxs)(`div`,{className:`card kpiband rise mb-16`,children:[o.map(e=>{let t=a[e.key];return(0,A.jsxs)(`a`,{className:`kseg`,href:e.hash,title:`Open ${e.label}`,children:[(0,A.jsx)(`span`,{className:`kseg-n`+(t===0?` zero`:``),children:t==null?`—`:(0,A.jsx)(w,{value:t})}),(0,A.jsx)(`span`,{className:`kseg-l`,children:e.label})]},e.key)}),(0,A.jsx)(`div`,{className:`kseg-spacer`}),(0,A.jsxs)(`button`,{className:`kseg`+(r>0?` hot`:``),onClick:()=>E(`#/diff`),title:`Open changes`,children:[(0,A.jsx)(`span`,{className:`kseg-n`+(r===0?` zero`:``),children:(0,A.jsx)(w,{value:r})}),(0,A.jsx)(`span`,{className:`kseg-l`,children:`Local edits`}),r>0&&(0,A.jsx)(`span`,{className:`delta up`,children:`▲`})]})]})}function L({overview:e}){return(0,A.jsx)(`div`,{className:`genome`,children:s.map((t,n)=>{let r=o[t],i=e.counts?.[t];return(0,A.jsxs)(`div`,{className:`card gcell rise`,style:{"--i":n},onClick:()=>E(`#/section/`+t),children:[(0,A.jsxs)(`div`,{className:`gtop`,children:[(0,A.jsx)(`span`,{className:`gname`,children:r.label}),(0,A.jsx)(h,{name:r.icon,className:`gicon`})]}),(0,A.jsx)(`div`,{className:`gcount`+(i===0?` zero`:``),children:i==null?`—`:(0,A.jsx)(w,{value:i})}),(0,A.jsx)(`div`,{className:`gdesc`,children:r.desc})]},t)})})}function R({jobs:e}){if(!e||e.length===0)return(0,A.jsx)(`div`,{className:`feed`,children:(0,A.jsxs)(`div`,{className:`empty`,children:[(0,A.jsx)(`div`,{className:`big`,children:`No activity yet`}),`Actions you run appear here.`]})});let t={done:`ok`,running:`acc`,failed:`bad`},n=O(e,8);return(0,A.jsx)(`div`,{className:`feed`,children:n.map(e=>(0,A.jsxs)(`div`,{className:`feed-row`,children:[(0,A.jsx)(`span`,{className:`feed-dot ${t[e.status]||`ok`}`}),(0,A.jsx)(`span`,{className:`feed-txt`,children:(0,A.jsx)(`b`,{children:e.action})}),(0,A.jsxs)(`span`,{className:`feed-when`,children:[d(e.started),` ago`]})]},e.id))})}function z({value:e}){let t=C(e,1100)??0,n=Math.round(t*100);return(0,A.jsxs)(`div`,{className:`ring-box`,children:[(0,A.jsx)(j,{value:n,max:100,label:`germination`,size:232,stroke:10,sweepMs:0}),(0,A.jsxs)(`div`,{className:`ring-center`,children:[(0,A.jsxs)(`div`,{className:`pct`,children:[n,(0,A.jsx)(`span`,{className:`pct-unit`,children:`%`})]}),(0,A.jsx)(`div`,{className:`lbl`,children:`germination`})]})]})}function B({overview:e,sigil:t,setup:n,jobs:r,lens:i,dataRev:a}){let o=N(e,i?.tone),c=l(e,n,i?.tone);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`card pad-lg rise mb-16`,children:(0,A.jsxs)(`div`,{className:`hero`,children:[(0,A.jsx)(z,{value:c}),(0,A.jsxs)(`div`,{className:`hero-facts`,children:[(0,A.jsx)(`div`,{className:`ttl`,children:o}),(0,A.jsx)(F,{verdict:i?.verdict}),t&&(0,A.jsxs)(`div`,{className:`voice-readout`,children:[(0,A.jsx)(`span`,{className:`vr-cur`,children:`▕`}),(0,A.jsx)(`span`,{className:`vr-txt`,children:t})]},e.theme),(0,A.jsxs)(`p`,{className:`sub`,children:[`One source rendered into `,(0,A.jsx)(`code`,{children:e.target}),`. Every repo on this machine inherits it.`]}),(0,A.jsxs)(`div`,{className:`hero-chips`,children:[(0,A.jsxs)(`span`,{className:`chip`,children:[(0,A.jsx)(`span`,{className:`ck`,children:`voice`}),(0,A.jsx)(`span`,{className:`cv t-cap`,children:e.theme})]}),(0,A.jsxs)(`span`,{className:`chip`,children:[(0,A.jsx)(`span`,{className:`ck`,children:`mode`}),(0,A.jsx)(`span`,{className:`cv`,children:e.emit})]}),(0,A.jsxs)(`span`,{className:`chip`,children:[(0,A.jsx)(`span`,{className:`ck`,children:`footprint`}),(0,A.jsx)(`span`,{className:`cv`,children:e.footprint})]}),(0,A.jsxs)(`span`,{className:`chip`,children:[(0,A.jsx)(`span`,{className:`ck`,children:`built`}),(0,A.jsx)(`span`,{className:`cv`,children:e.build_time||`unknown`})]}),(0,A.jsxs)(`span`,{className:`chip`,children:[(0,A.jsx)(`span`,{className:`ck`,children:`fp`}),(0,A.jsx)(`span`,{className:`cv`,children:n?.installed_fp||`—`})]})]})]})]})}),(0,A.jsx)(I,{overview:e,dataRev:a}),(0,A.jsxs)(`div`,{className:`grid split-status`,children:[(0,A.jsxs)(`div`,{className:`card pad-lg`,children:[(0,A.jsxs)(`div`,{className:`card-head`,children:[(0,A.jsx)(`h3`,{children:`Capability genome`}),(0,A.jsx)(`div`,{className:`right`,children:(0,A.jsxs)(`span`,{className:`tick`,children:[s.length,` sections`]})})]}),(0,A.jsx)(L,{overview:e})]}),(0,A.jsxs)(`div`,{className:`card pad-lg`,children:[(0,A.jsxs)(`div`,{className:`card-head`,children:[(0,A.jsx)(`h3`,{children:`Recent activity`}),(0,A.jsx)(`div`,{className:`right`,children:(0,A.jsxs)(`span`,{className:`badge acc`,children:[(0,A.jsx)(`span`,{className:`dot`}),`live`]})})]}),(0,A.jsx)(R,{jobs:r})]})]})]})}function V({k:e,overview:t,max:n}){let r=o[e],i=t.counts?.[e]??0;return(0,A.jsxs)(`div`,{className:`strand`,children:[(0,A.jsxs)(`span`,{className:`strand-name`,children:[(0,A.jsx)(`span`,{className:`strand-dot`}),(0,A.jsx)(`a`,{href:`#/section/`+e,className:`strand-link stretch-link`,children:r.label})]}),(0,A.jsx)(`div`,{className:`hbar`,children:(0,A.jsx)(`i`,{style:{width:`${i/n*100}%`}})}),(0,A.jsx)(`span`,{className:`strand-val`,children:i})]})}function H(e){return e?e.includes(`up to date`)?{label:`in sync`,tone:`ok`}:e.includes(`no Geneseed install`)?{label:`not installed`,tone:``}:{label:`behind source`,tone:`warn`}:null}function U({overview:e,sigil:t,setup:n,jobs:r,lens:i}){let a=g(e.counts),o=n?.version_verdict||``,c=H(o),l=m(e.diff),u=[[`Source`,`src/, the canonical genetic material`,n?.source_fp||`—`,!0],[`Render`,`geneseed build → ${e.emit}`,e.theme+` voice`,!0],[`Deployed`,e.target,`inherited by every repo`,!1]];return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`mb-16`,children:(0,A.jsxs)(`div`,{className:`card pad-lg rise`,style:{position:`relative`,overflow:`hidden`},children:[(0,A.jsx)(`h2`,{className:`h`,style:{fontSize:22,margin:`0 0 18px`},children:`Gene-seed lineage`}),(0,A.jsxs)(`div`,{className:`lineage-track`,children:[(0,A.jsx)(`div`,{className:`spine`}),u.map(([e,t,n,r],i)=>(0,A.jsxs)(`div`,{className:`lineage-step`,children:[(0,A.jsx)(`span`,{className:`node ${r?`on`:``}`}),(0,A.jsx)(`div`,{className:`lt`,children:e}),(0,A.jsx)(`div`,{className:`ld`,children:t}),(0,A.jsx)(`div`,{className:`ltag`,children:n})]},i))]}),(0,A.jsx)(`hr`,{className:`hr`}),t&&(0,A.jsxs)(`div`,{className:`voice-readout`,style:{marginBottom:14},children:[(0,A.jsx)(`span`,{className:`vr-cur`,children:`▕`}),(0,A.jsx)(`span`,{className:`vr-txt`,children:t})]},e.theme),(0,A.jsxs)(`div`,{className:`row wrap gap-10`,children:[(0,A.jsx)(F,{verdict:i?.verdict}),c&&(0,A.jsxs)(`span`,{className:`badge ${c.tone}`,title:o,children:[(0,A.jsx)(`span`,{className:`dot`}),c.label]}),(0,A.jsxs)(`span`,{className:`badge`,children:[(0,A.jsx)(`span`,{className:`dot`}),l,` local edits`]})]})]})}),(0,A.jsxs)(`div`,{className:`grid split-even`,children:[(0,A.jsxs)(`div`,{className:`card pad-lg`,children:[(0,A.jsxs)(`div`,{className:`card-head`,children:[(0,A.jsx)(`h3`,{children:`Genome strand`}),(0,A.jsx)(`div`,{className:`right`,children:(0,A.jsx)(`span`,{className:`tick`,children:`by volume`})})]}),s.map(t=>(0,A.jsx)(V,{k:t,overview:e,max:a},t))]}),(0,A.jsxs)(`div`,{className:`card pad-lg`,children:[(0,A.jsx)(`div`,{className:`card-head`,children:(0,A.jsx)(`h3`,{children:`Recent activity`})}),(0,A.jsx)(R,{jobs:r})]})]})]})}function W({overview:e,setup:t,jobs:n,lens:r}){let i=s.reduce((t,n)=>t+(e.counts?.[n]??0),0),a=g(e.counts),c=e.doctor?.ok,l=e.doctor?.problems?.length??0,u=m(e.diff);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`card pad-md rise mb-16`,children:(0,A.jsx)(`div`,{className:`row wrap between gap-16`,children:(0,A.jsxs)(`div`,{className:`row`,style:{gap:20,flexWrap:`wrap`},children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`tick`,children:`status`}),(0,A.jsxs)(`div`,{className:`row`,style:{gap:8,marginTop:4},children:[(0,A.jsxs)(`span`,{className:`badge ${e.deployed?`ok`:`warn`}`,children:[(0,A.jsx)(`span`,{className:`dot`}),e.deployed?`deployed`:`not deployed`]}),(0,A.jsx)(F,{verdict:r?.verdict})]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`tick`,children:`voice`}),(0,A.jsx)(`div`,{className:`metric`,style:{fontSize:18,marginTop:6,textTransform:`capitalize`},children:e.theme})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`tick`,children:`mode`}),(0,A.jsx)(`div`,{className:`mono`,style:{fontSize:14,marginTop:6},children:e.emit})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`tick`,children:`fingerprint`}),(0,A.jsx)(`div`,{className:`mono`,style:{fontSize:14,marginTop:6,color:`var(--accent)`},children:t?.installed_fp||`—`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`tick`,children:`doctor`}),(0,A.jsx)(`div`,{className:`row`,style:{gap:8,marginTop:4},children:c?(0,A.jsxs)(`span`,{className:`badge ok`,children:[(0,A.jsx)(`span`,{className:`dot`}),`clean`]}):(0,A.jsxs)(`span`,{className:`badge warn`,children:[(0,A.jsx)(`span`,{className:`dot`}),l,` issue`,l===1?``:`s`]})})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`tick`,children:`edits`}),(0,A.jsx)(`div`,{className:`metric`,style:{fontSize:18,marginTop:6},children:u})]})]})})}),(0,A.jsxs)(`div`,{className:`grid split-operator`,children:[(0,A.jsxs)(`div`,{className:`card rise`,style:{"--i":1},children:[(0,A.jsxs)(`div`,{className:`card-head pad-lg`,style:{padding:`18px 20px 0`,marginBottom:14},children:[(0,A.jsx)(`h3`,{children:`Sections`}),(0,A.jsx)(`div`,{className:`right`,children:(0,A.jsxs)(`span`,{className:`tick`,children:[i,` entries total`]})})]}),(0,A.jsxs)(`table`,{className:`tbl`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`th`,{children:`Section`}),(0,A.jsx)(`th`,{children:`Detail`}),(0,A.jsx)(`th`,{style:{width:130},children:`Share`}),(0,A.jsx)(`th`,{className:`num`,children:`Count`})]})}),(0,A.jsx)(`tbody`,{children:s.map(t=>{let n=o[t],r=e.counts?.[t]??0;return(0,A.jsxs)(`tr`,{className:`clickable`,children:[(0,A.jsx)(`td`,{className:`name`,children:(0,A.jsx)(`a`,{href:`#/section/`+t,className:`stretch-link`,children:n.label})}),(0,A.jsx)(`td`,{className:`muted`,children:n.desc}),(0,A.jsx)(`td`,{children:(0,A.jsx)(`div`,{className:`hbar`,children:(0,A.jsx)(`i`,{style:{width:`${r/a*100}%`}})})}),(0,A.jsx)(`td`,{className:`num`,children:r})]},t)})})]})]}),(0,A.jsxs)(`div`,{className:`card pad-lg rise`,style:{"--i":2},children:[(0,A.jsx)(`div`,{className:`card-head`,children:(0,A.jsx)(`h3`,{children:`Run log`})}),(0,A.jsx)(R,{jobs:n})]})]})]})}var G=Symbol(`failed`),K=e=>Promise.resolve().then(e).catch(()=>G);function q({dataRev:e,needDoctor:t}){let n=u(()=>K(()=>i.fleet()),[e]),r=u(()=>t?K(()=>i.doctor()):Promise.resolve(null),[t,e]),a=n.data,o=a==null?`loading`:a===G?`failed`:`ok`,s=o===`ok`?a:null,c=s?x(s):null,l=r.data,d=t?l==null?`loading`:l===G?`failed`:`ok`:`idle`;return{fleet:s,fleetState:o,verdict:c,tone:o===`failed`?`failed`:c?.tone,doctor:{state:d,data:d===`ok`?r.data:null}}}var J=e({default:()=>Q}),Y=(0,k.lazy)(()=>T(()=>import(`./GreenhouseView-BCiZP9f9.js`),__vite__mapDeps([0,1,2,3,4,5,6,7]))),X=(0,k.lazy)(()=>T(()=>import(`./OperatorHudView-BLXm0zzn.js`),__vite__mapDeps([8,1,2,3,4,5,6,7]))),Z=(0,k.lazy)(()=>T(()=>import(`./JournalView-BSR51TKR.js`),__vite__mapDeps([9,1,2,5,10,4,3,6])));function Q({overview:e,overviewError:t,onRetry:n,themes:r,setup:a,runs:o,onAction:s,layout:l=`cultivar`,dataRev:d}){let m=l,[h,g]=(0,k.useState)(`status`),_=e&&r.find(t=>t.name===e.theme)?.sigil||``,v=q({dataRev:d,needDoctor:m===`greenhouse`||m===`operator`}),{data:y}=u(()=>m===`journal`?i.recent().catch(()=>null):Promise.resolve(null),[m,d]);if(!e)return t?(0,A.jsx)(b,{error:`Could not load the harness overview: ${t}`,onRetry:n}):(0,A.jsx)(c,{});let x=e.daemon_stale?(0,A.jsx)(p,{}):null;return e.deployed?h===`status`&&m===`journal`?(0,A.jsxs)(k.Suspense,{fallback:(0,A.jsx)(c,{}),children:[x,(0,A.jsx)(Z,{overview:e,recent:y,lens:v,onDirection:g,dataRev:d})]}):(0,A.jsxs)(A.Fragment,{children:[x,(0,A.jsx)(`div`,{className:`head-row`,children:(0,A.jsx)(f,{"aria-label":`Dashboard view`,children:[[`status`,`Status`],[`lineage`,`Lineage`],[`operator`,`Operator`,`Operator data`]].map(([e,t,n])=>(0,A.jsx)(`button`,{className:h===e?`on`:``,onClick:()=>g(e),"aria-pressed":h===e,"aria-label":n,children:t},e))})}),(0,A.jsxs)(`div`,{className:`view-in`,children:[h===`status`&&m===`cultivar`&&(0,A.jsx)(B,{overview:e,sigil:_,setup:a,jobs:o,lens:v,dataRev:d}),h===`status`&&m===`greenhouse`&&(0,A.jsx)(k.Suspense,{fallback:(0,A.jsx)(c,{}),children:(0,A.jsx)(Y,{overview:e,sigil:_,jobs:o,lens:v,onAction:s})}),h===`status`&&m===`operator`&&(0,A.jsx)(k.Suspense,{fallback:(0,A.jsx)(c,{}),children:(0,A.jsx)(X,{overview:e,jobs:o,lens:v})}),h===`lineage`&&(0,A.jsx)(U,{overview:e,sigil:_,setup:a,jobs:o,lens:v}),h===`operator`&&(0,A.jsx)(W,{overview:e,setup:a,jobs:o,lens:v})]},h)]}):(0,A.jsxs)(A.Fragment,{children:[x,(0,A.jsx)(D,{onAction:s})]})}export{Q as default,j as i,F as n,N as r,J as t};