geneseed 6.0.0 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/SHIPPED.md +1 -1
- package/docs/concepts/agents.md +3 -1
- package/harness.config.json +1 -1
- package/js/README.md +2 -0
- package/js/build/emit-claude.mjs +2 -2
- package/js/build/emit-opencode.mjs +4 -2
- package/js/build/source.mjs +1 -1
- package/js/cli-table.json +1 -1
- package/js/hosts/native.mjs +62 -26
- package/js/hosts/opencode.mjs +3 -2
- package/js/inspect/checks-build.mjs +2 -2
- package/js/web/agent-models-api.mjs +207 -0
- package/js/web/api.mjs +3 -0
- package/js/web/model-catalog.mjs +324 -0
- package/js/web/routes.mjs +7 -1
- package/package.json +1 -1
- package/web/dist/assets/{ActiveLoops-DOJCPPPc.js → ActiveLoops-BWkImeYa.js} +1 -1
- package/web/dist/assets/{Activity-bUSPM3Dl.js → Activity-DJlPhk8q.js} +1 -1
- package/web/dist/assets/{ActivityDetail-AHRoXeFN.js → ActivityDetail-Dk7UPnE_.js} +1 -1
- package/web/dist/assets/{Bonsai-B5XY9pid.js → Bonsai-Bry-kOFb.js} +1 -1
- package/web/dist/assets/{CopyButton-C0wwRR9H.js → CopyButton-Cnnvjgkg.js} +1 -1
- package/web/dist/assets/{Dashboard-DPAA96EI.js → Dashboard-CWhh_GSc.js} +2 -2
- package/web/dist/assets/{Docs-CpGDq165.js → Docs-BJ23-fIx.js} +1 -1
- package/web/dist/assets/{Factories-cNhETa5Q.js → Factories-CjsIACyi.js} +1 -1
- package/web/dist/assets/{GreenhouseView-DO3ADmT9.js → GreenhouseView-VL_ZKJUR.js} +1 -1
- package/web/dist/assets/Installs-qcfOZNzF.js +3 -0
- package/web/dist/assets/{JournalView--W-Lw_V9.js → JournalView-KrmFUC-X.js} +1 -1
- package/web/dist/assets/{Kits-ChfehxY6.js → Kits-DDSerkJk.js} +1 -1
- package/web/dist/assets/{Laws-CNxYmV36.js → Laws-DDffPs6O.js} +1 -1
- package/web/dist/assets/{LibRows-CiPvsRYB.js → LibRows-QsUBjOF7.js} +1 -1
- package/web/dist/assets/Library-DzT3Mebh.js +3 -0
- package/web/dist/assets/{Loops-DAblKkyq.js → Loops-CjsX3brz.js} +1 -1
- package/web/dist/assets/Models-DPrAv3FG.js +1 -0
- package/web/dist/assets/{OperatorHudView-QtSaSyYm.js → OperatorHudView-Bdupodlc.js} +1 -1
- package/web/dist/assets/{Personal-DxSGv638.js → Personal-D-dpCUU5.js} +1 -1
- package/web/dist/assets/{Settings-CgTbhvRv.js → Settings-Dz33_Sys.js} +1 -1
- package/web/dist/assets/{Tabs-Cf4X1hdz.js → Tabs-qY40S34V.js} +1 -1
- package/web/dist/assets/api-C8nMUU1i.js +1 -0
- package/web/dist/assets/{index-B_pTwZra.js → index-BhT94v2q.js} +3 -3
- package/web/dist/assets/index-DcusoHzF.css +1 -0
- package/web/dist/index.html +3 -3
- package/web/dist/assets/Installs-D3dDyq10.js +0 -3
- package/web/dist/assets/Library-BxQvbwVU.js +0 -3
- package/web/dist/assets/api-CZ-x0iWG.js +0 -1
- package/web/dist/assets/index-CzfImiYb.css +0 -1
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The models one install can run a sub-agent on — what `GET /api/agent-models` lists as `models`.
|
|
3
|
+
*
|
|
4
|
+
* ONE READER PER HOST, files and local probes only, and NEVER A SECRET (spec D3): an API key is
|
|
5
|
+
* never returned, logged or sent. Only its presence is a boolean, and only where a catalogue
|
|
6
|
+
* provider's `env` names it or `auth.json` holds an entry for it; a custom provider's `options`
|
|
7
|
+
* (`apiKey`, headers, `{env:X}`) is never looked at, and no remote or private `/v1/models` is ever
|
|
8
|
+
* called. The one network use is `GET` on `127.0.0.1` (Ollama 11434, LM Studio 1234), no header,
|
|
9
|
+
* one second. Whitelist the fields you copy; a row is built from named fields, never spread.
|
|
10
|
+
*
|
|
11
|
+
* A COMPANY SETUP COMES FIRST. A private URL, a private key and in-house model names are known to
|
|
12
|
+
* no catalogue, so a custom provider's own `models` map is the primary source (with the `name`,
|
|
13
|
+
* `limit`, `cost`, `variants` the config itself gives) and `models.dev` is enrichment only, for an
|
|
14
|
+
* id that matches. A missing catalogue, `auth.json` or runtime is not an error and says nothing.
|
|
15
|
+
* OpenClaude, whose profile names a base URL, reuses the OpenCode custom provider on the same
|
|
16
|
+
* endpoint, so the in-house names reach it without calling the endpoint.
|
|
17
|
+
*
|
|
18
|
+
* A row: `{ id, name, provider, providerName, source, note, local, available, reason?, context?,
|
|
19
|
+
* output?, cost?, reasoning?, variants? }`; `id` is the value written into `model:`. A group
|
|
20
|
+
* (`groups`) is one provider with its source line and availability, so a local runtime that is not
|
|
21
|
+
* running still shows. `inherit` is the first row on every host.
|
|
22
|
+
*/
|
|
23
|
+
import os from 'node:os';
|
|
24
|
+
import path from 'node:path';
|
|
25
|
+
|
|
26
|
+
import { isFile, readText } from '../lib/fs.mjs';
|
|
27
|
+
import { isDict, isTruthy } from '../lib/json.mjs';
|
|
28
|
+
import { loadJsonObject } from '../hosts/settings.mjs';
|
|
29
|
+
import { loadAgentOverrides } from '../hosts/native.mjs';
|
|
30
|
+
|
|
31
|
+
/** How many agents of the install at `dir` carry a model pin: the Installs panel's one-line summary. */
|
|
32
|
+
export function pinCountOf(dir) {
|
|
33
|
+
return Object.values(loadAgentOverrides(dir, () => {})).filter((e) => isDict(e) && isTruthy(e.model)).length;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const PROBE_MS = 1000;
|
|
37
|
+
/** The aliases a Claude Code sub-agent accepts; `default`/`best`/`opusplan` are not agent values. */
|
|
38
|
+
const CLAUDE_ALIASES = [['opus', 'Opus'], ['sonnet', 'Sonnet'], ['haiku', 'Haiku'], ['fable', 'Fable']];
|
|
39
|
+
|
|
40
|
+
const SESSION = { provider: 'session', providerName: 'Session model', source: 'session' };
|
|
41
|
+
|
|
42
|
+
/** Lower-cased host, no trailing `/`, no `/v1`: two spellings of one endpoint compare equal. */
|
|
43
|
+
export function normalizeUrl(u) {
|
|
44
|
+
if (typeof u !== 'string' || !u.trim()) return '';
|
|
45
|
+
let s = u.trim();
|
|
46
|
+
const m = /^([a-z][a-z0-9+.-]*:\/\/)([^/?#]*)(.*)$/i.exec(s);
|
|
47
|
+
if (m) s = `${m[1].toLowerCase()}${m[2].toLowerCase()}${m[3]}`;
|
|
48
|
+
s = s.replace(/\/+$/, '').replace(/\/v1$/i, '').replace(/\/+$/, '');
|
|
49
|
+
return s;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const isLocalUrl = (u) => /^https?:\/\/(127\.0\.0\.1|localhost|\[::1\])([:/]|$)/i.test(String(u ?? '').trim());
|
|
53
|
+
// The JSONC reader hands a number back as `parseJson`'s wrapper object, so `+v` reads both forms.
|
|
54
|
+
const num = (v) => {
|
|
55
|
+
if (typeof v === 'boolean' || v === null || v === undefined || Array.isArray(v) || isDict(v)) return undefined;
|
|
56
|
+
return typeof v === 'number' || typeof v === 'object' ? (Number.isFinite(+v) ? +v : undefined) : undefined;
|
|
57
|
+
};
|
|
58
|
+
const text = (v) => (typeof v === 'string' && v.trim() ? v.trim() : undefined);
|
|
59
|
+
|
|
60
|
+
/** A row from named fields only. `extra` is `{ name, limit, cost, reasoning, variants }` from a config or catalogue. */
|
|
61
|
+
function row(id, base, extra = {}) {
|
|
62
|
+
const r = { id, name: text(extra.name) ?? id, ...base, available: base.available ?? true };
|
|
63
|
+
if (r.available) delete r.reason;
|
|
64
|
+
const context = num(extra.limit?.context); if (context !== undefined) r.context = context;
|
|
65
|
+
const output = num(extra.limit?.output); if (output !== undefined) r.output = output;
|
|
66
|
+
const ci = num(extra.cost?.input); const co = num(extra.cost?.output);
|
|
67
|
+
if (ci !== undefined || co !== undefined) r.cost = { input: ci ?? null, output: co ?? null };
|
|
68
|
+
if (typeof extra.reasoning === 'boolean') r.reasoning = extra.reasoning;
|
|
69
|
+
const v = isDict(extra.variants) ? Object.keys(extra.variants) : Array.isArray(extra.variants) ? extra.variants.filter((x) => typeof x === 'string') : null;
|
|
70
|
+
if (v && v.length) r.variants = v;
|
|
71
|
+
return r;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Fill what a row lacks from a catalogue model of the same id; never overwrite what the config said. */
|
|
75
|
+
function enrich(r, cat) {
|
|
76
|
+
if (!isDict(cat)) return r;
|
|
77
|
+
const from = row(r.id, {}, cat);
|
|
78
|
+
for (const k of ['context', 'output', 'cost', 'reasoning', 'variants']) if (r[k] === undefined && from[k] !== undefined) r[k] = from[k];
|
|
79
|
+
return r;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function readJson(p) {
|
|
83
|
+
try { const d = JSON.parse(readText(p)); return isDict(d) ? d : null; } catch { return null; }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** `GET url` on loopback, no header at all, `PROBE_MS`; the parsed body or null. */
|
|
87
|
+
async function probe(fetchFn, url) {
|
|
88
|
+
try {
|
|
89
|
+
const res = await fetchFn(url, { signal: AbortSignal.timeout(PROBE_MS), redirect: 'error' });
|
|
90
|
+
if (!res || !res.ok) return null;
|
|
91
|
+
return await res.json();
|
|
92
|
+
} catch { return null; }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** `{ name, ids }` of the local runtime, `ids` null when it does not answer. */
|
|
96
|
+
async function localRuntime(fetchFn, which) {
|
|
97
|
+
if (which === 'ollama') {
|
|
98
|
+
const d = await probe(fetchFn, 'http://127.0.0.1:11434/api/tags');
|
|
99
|
+
const ids = Array.isArray(d?.models) ? d.models.map((m) => text(m?.name) ?? text(m?.model)).filter(Boolean) : null;
|
|
100
|
+
return { id: 'ollama', name: 'Ollama', ids };
|
|
101
|
+
}
|
|
102
|
+
let d = await probe(fetchFn, 'http://127.0.0.1:1234/api/v1/models');
|
|
103
|
+
if (!d) d = await probe(fetchFn, 'http://127.0.0.1:1234/api/v0/models');
|
|
104
|
+
const list = Array.isArray(d?.models) ? d.models : Array.isArray(d?.data) ? d.data : null;
|
|
105
|
+
const ids = list ? list.filter((m) => !/embed/i.test(String(m?.type ?? ''))).map((m) => text(m?.key) ?? text(m?.id)).filter(Boolean) : null;
|
|
106
|
+
return { id: 'lmstudio', name: 'LM Studio', ids };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Both local runtimes, probed together. */
|
|
110
|
+
const localRuntimes = (fetchFn) => Promise.all([localRuntime(fetchFn, 'ollama'), localRuntime(fetchFn, 'lmstudio')]);
|
|
111
|
+
|
|
112
|
+
// ---- OpenCode ------------------------------------------------------------------------------------
|
|
113
|
+
|
|
114
|
+
const xdg = (env, home, name, dflt) => env[name] || path.join(home, dflt);
|
|
115
|
+
|
|
116
|
+
/** The opencode config files that apply: the user's, then the project's. Order is merge order. */
|
|
117
|
+
function opencodeConfigFiles({ host, scope, root, dir, env, home }) {
|
|
118
|
+
const dirs = [];
|
|
119
|
+
const add = (d) => { if (d && !dirs.includes(d)) dirs.push(d); };
|
|
120
|
+
add(env.OPENCODE_CONFIG_DIR);
|
|
121
|
+
add(path.join(xdg(env, home, 'XDG_CONFIG_HOME', '.config'), 'opencode'));
|
|
122
|
+
const projectDirs = scope === 'project' ? [root, path.join(root, '.opencode')] : [];
|
|
123
|
+
if (scope === 'global' && host === 'opencode') add(dir);
|
|
124
|
+
return [...dirs, ...projectDirs].flatMap((d) => [path.join(d, 'opencode.json'), path.join(d, 'opencode.jsonc')]);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** A whole-string `{env:X}` reference resolved against the env; a URL is not a secret. Anything else as written. */
|
|
128
|
+
const envRef = (v, env) => {
|
|
129
|
+
const m = typeof v === 'string' ? /^\{env:([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(v) : null;
|
|
130
|
+
return m ? text(env[m[1]]) : v;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The custom providers the OpenCode configs define (`provider` V1, `providers` V2), the two
|
|
135
|
+
* `*_providers` lists and the files read. Of `options` only `baseURL` is read; a key may sit beside it.
|
|
136
|
+
*/
|
|
137
|
+
export function readOpencodeConfig(ctx) {
|
|
138
|
+
const providers = new Map();
|
|
139
|
+
let enabled = null;
|
|
140
|
+
const disabled = new Set();
|
|
141
|
+
const files = [];
|
|
142
|
+
for (const f of opencodeConfigFiles(ctx)) {
|
|
143
|
+
const { state, data } = loadJsonObject(f);
|
|
144
|
+
if (state !== 'ok') continue;
|
|
145
|
+
files.push(f);
|
|
146
|
+
for (const key of ['provider', 'providers']) {
|
|
147
|
+
if (!isDict(data[key])) continue;
|
|
148
|
+
for (const [id, p] of Object.entries(data[key])) {
|
|
149
|
+
if (id === '__proto__' || !isDict(p)) continue;
|
|
150
|
+
const baseURL = envRef(text(p.options?.baseURL) ?? text(p.options?.baseUrl) ?? text(p.baseURL), ctx.env);
|
|
151
|
+
providers.set(id, { id, name: text(p.name) ?? id, baseURL, models: isDict(p.models) ? p.models : {}, file: path.basename(f) });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (Array.isArray(data.enabled_providers)) enabled = new Set(data.enabled_providers.filter((x) => typeof x === 'string'));
|
|
155
|
+
if (Array.isArray(data.disabled_providers)) for (const x of data.disabled_providers) if (typeof x === 'string') disabled.add(x);
|
|
156
|
+
}
|
|
157
|
+
for (const id of [...providers.keys()]) if (disabled.has(id) || (enabled && !enabled.has(id))) providers.delete(id);
|
|
158
|
+
return { providers, enabled, disabled, files };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function opencodeModels(ctx, add, group) {
|
|
162
|
+
const { env, home, fetchFn } = ctx;
|
|
163
|
+
const cfg = readOpencodeConfig(ctx);
|
|
164
|
+
const catFile = env.OPENCODE_MODELS_PATH || path.join(xdg(env, home, 'XDG_CACHE_HOME', '.cache'), 'opencode', 'models.json');
|
|
165
|
+
const catalogue = isFile(catFile) ? readJson(catFile) : null;
|
|
166
|
+
for (const p of cfg.providers.values()) {
|
|
167
|
+
const note = `configured in ${p.file}`;
|
|
168
|
+
group({ provider: p.id, providerName: p.name, source: 'config', note, local: false });
|
|
169
|
+
for (const [mid, m] of Object.entries(p.models)) {
|
|
170
|
+
if (mid === '__proto__') continue;
|
|
171
|
+
const r = row(`${p.id}/${mid}`, { provider: p.id, providerName: p.name, source: 'config', note, local: false }, { name: mid, ...(isDict(m) ? m : {}) });
|
|
172
|
+
add(enrich(r, catalogue?.[p.id]?.models?.[mid]));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (catalogue) {
|
|
176
|
+
const auth = readJson(path.join(xdg(env, home, 'XDG_DATA_HOME', '.local/share'), 'opencode', 'auth.json'));
|
|
177
|
+
for (const [pid, p] of Object.entries(catalogue)) {
|
|
178
|
+
if (pid === '__proto__' || !isDict(p) || cfg.providers.has(pid) || cfg.disabled.has(pid)) continue;
|
|
179
|
+
if (cfg.enabled && !cfg.enabled.has(pid)) continue;
|
|
180
|
+
const saved = !!auth && Object.hasOwn(auth, pid);
|
|
181
|
+
const envKey = Array.isArray(p.env) && p.env.some((n) => typeof n === 'string' && String(env[n] ?? '').trim());
|
|
182
|
+
if (!saved && !envKey) continue;
|
|
183
|
+
const note = `catalogue · ${saved ? 'credentials saved' : 'key found'}`;
|
|
184
|
+
const name = text(p.name) ?? pid;
|
|
185
|
+
group({ provider: pid, providerName: name, source: 'catalogue', note, local: false });
|
|
186
|
+
for (const [mid, m] of Object.entries(isDict(p.models) ? p.models : {})) {
|
|
187
|
+
if (!isDict(m) || m.status === 'alpha' || m.status === 'deprecated') continue;
|
|
188
|
+
add(row(`${pid}/${mid}`, { provider: pid, providerName: name, source: 'catalogue', note, local: false }, { name: mid, ...m }));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
for (const rt of await localRuntimes(fetchFn)) {
|
|
193
|
+
if (cfg.disabled.has(rt.id)) continue;
|
|
194
|
+
const up = rt.ids !== null;
|
|
195
|
+
group({ provider: rt.id, providerName: rt.name, source: 'local', note: up ? 'local · running' : 'local · not running', local: true, available: up, ...(up ? {} : { reason: `${rt.name} not running` }) });
|
|
196
|
+
for (const id of rt.ids ?? []) add(row(`${rt.id}/${id}`, { provider: rt.id, providerName: rt.name, source: 'local', note: 'local · running', local: true }, { name: id }));
|
|
197
|
+
}
|
|
198
|
+
return cfg;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ---- OpenClaude ----------------------------------------------------------------------------------
|
|
202
|
+
|
|
203
|
+
const on = (v) => { const s = String(v ?? '').trim().toLowerCase(); return s !== '' && s !== '0' && s !== 'false'; };
|
|
204
|
+
const PROFILE_KEYS = ['CLAUDE_CODE_USE_OPENAI', 'CLAUDE_CODE_USE_GEMINI', 'CLAUDE_CODE_USE_MISTRAL', 'OPENAI_BASE_URL', 'OPENAI_MODEL', 'GEMINI_MODEL', 'MISTRAL_MODEL'];
|
|
205
|
+
const KEY_VARS = ['OPENAI_API_KEY', 'GEMINI_API_KEY', 'GOOGLE_API_KEY', 'MISTRAL_API_KEY'];
|
|
206
|
+
|
|
207
|
+
/** The active OpenClaude provider: env first, then `.openclaude-profile.json`, then `.openclaude.json`. */
|
|
208
|
+
function openclaudeActive({ env, home }) {
|
|
209
|
+
const configHome = env.OPENCLAUDE_CONFIG_DIR || path.join(home, '.openclaude');
|
|
210
|
+
const pf = readJson(path.join(configHome, '.openclaude-profile.json'));
|
|
211
|
+
const fileEnv = isDict(pf?.env) ? pf.env : {};
|
|
212
|
+
// Named keys only; the secrets that file holds stay where they are, reduced to one boolean.
|
|
213
|
+
const get = (k) => (text(env[k]) ?? text(fileEnv[k]));
|
|
214
|
+
const settled = Object.fromEntries(PROFILE_KEYS.map((k) => [k, get(k)]));
|
|
215
|
+
const prof = readJson(path.join(env.OPENCLAUDE_CONFIG_DIR || home, '.openclaude.json'));
|
|
216
|
+
const entry = Array.isArray(prof?.providerProfiles)
|
|
217
|
+
? prof.providerProfiles.find((p) => isDict(p) && p.id === prof.activeProviderProfileId) : null;
|
|
218
|
+
const flag = on(settled.CLAUDE_CODE_USE_OPENAI) ? 'openai' : on(settled.CLAUDE_CODE_USE_GEMINI) ? 'gemini'
|
|
219
|
+
: on(settled.CLAUDE_CODE_USE_MISTRAL) ? 'mistral' : null;
|
|
220
|
+
const kind = flag ?? (text(entry?.provider) && entry.provider !== 'anthropic' ? entry.provider : null);
|
|
221
|
+
const modelVar = { openai: 'OPENAI_MODEL', gemini: 'GEMINI_MODEL', mistral: 'MISTRAL_MODEL' }[flag];
|
|
222
|
+
return {
|
|
223
|
+
configHome, kind, anthropic: kind === null,
|
|
224
|
+
model: (modelVar ? settled[modelVar] : null) ?? text(entry?.model) ?? null,
|
|
225
|
+
baseUrl: settled.OPENAI_BASE_URL ?? text(entry?.baseUrl) ?? null,
|
|
226
|
+
hasKey: KEY_VARS.some((k) => !!get(k)) || !!entry?.apiKey,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async function openclaudeModels(ctx, add, group) {
|
|
231
|
+
const { fetchFn, dir } = ctx;
|
|
232
|
+
const a = openclaudeActive(ctx);
|
|
233
|
+
// The company's own names: the OpenCode custom provider on the same endpoint (never called).
|
|
234
|
+
const want = normalizeUrl(a.baseUrl);
|
|
235
|
+
if (want) {
|
|
236
|
+
for (const p of readOpencodeConfig(ctx).providers.values()) {
|
|
237
|
+
if (normalizeUrl(p.baseURL) !== want) continue;
|
|
238
|
+
const note = `same endpoint as OpenCode provider ${p.id}`;
|
|
239
|
+
group({ provider: p.id, providerName: p.name, source: 'config', note, local: false });
|
|
240
|
+
for (const [mid, m] of Object.entries(p.models)) {
|
|
241
|
+
if (mid !== '__proto__') add(row(mid, { provider: p.id, providerName: p.name, source: 'config', note, local: false }, isDict(m) ? m : {}));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (a.model) {
|
|
246
|
+
const p = a.kind ?? 'provider';
|
|
247
|
+
group({ provider: p, providerName: a.kind ?? 'Active provider', source: 'provider', note: 'active provider', local: false });
|
|
248
|
+
add(row(a.model, { provider: p, providerName: a.kind ?? 'Active provider', source: 'provider', note: 'active provider', local: isLocalUrl(a.baseUrl), available: a.hasKey || isLocalUrl(a.baseUrl), reason: 'no key found' }));
|
|
249
|
+
}
|
|
250
|
+
if (isLocalUrl(a.baseUrl)) {
|
|
251
|
+
for (const rt of await localRuntimes(fetchFn)) {
|
|
252
|
+
const up = rt.ids !== null;
|
|
253
|
+
group({ provider: rt.id, providerName: rt.name, source: 'local', note: up ? 'local · running' : 'local · not running', local: true, available: up, ...(up ? {} : { reason: `${rt.name} not running` }) });
|
|
254
|
+
for (const id of rt.ids ?? []) add(row(id, { provider: rt.id, providerName: rt.name, source: 'local', note: 'local · running', local: true }));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const seen = new Set();
|
|
258
|
+
for (const d of [a.configHome, dir]) {
|
|
259
|
+
if (!d || seen.has(d)) continue;
|
|
260
|
+
seen.add(d);
|
|
261
|
+
const { state, data } = loadJsonObject(path.join(d, 'settings.json'));
|
|
262
|
+
if (state !== 'ok' || !isDict(data.agentModels)) continue;
|
|
263
|
+
group({ provider: 'route', providerName: 'Routes', source: 'route', note: 'route', local: false });
|
|
264
|
+
for (const k of Object.keys(data.agentModels)) {
|
|
265
|
+
if (k !== '__proto__') add(row(k, { provider: 'route', providerName: 'Routes', source: 'route', note: 'route', local: false }));
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (a.anthropic) {
|
|
269
|
+
group({ provider: 'anthropic', providerName: 'Anthropic aliases', source: 'alias', note: 'Anthropic aliases', local: false });
|
|
270
|
+
for (const [id, name] of [...CLAUDE_ALIASES.slice(0, 3)]) add(row(id, { provider: 'anthropic', providerName: 'Anthropic aliases', source: 'alias', note: 'Anthropic aliases', local: false }, { name }));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// ---- Claude Code ---------------------------------------------------------------------------------
|
|
275
|
+
|
|
276
|
+
/** `availableModels` of the install's settings (local over shared), or null when none is set. */
|
|
277
|
+
function claudeAvailable({ dir }) {
|
|
278
|
+
let list = null;
|
|
279
|
+
for (const f of ['settings.json', 'settings.local.json']) {
|
|
280
|
+
const { state, data } = loadJsonObject(path.join(dir, f));
|
|
281
|
+
if (state === 'ok' && Array.isArray(data.availableModels)) list = data.availableModels.filter((x) => typeof x === 'string').map((x) => x.trim()).filter(Boolean);
|
|
282
|
+
}
|
|
283
|
+
return list;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** An alias is allowed by an entry that is the family, or a version/full id of it. */
|
|
287
|
+
const aliasAllowed = (alias, list) => list === null || list.map((x) => x.toLowerCase()).some((e) => e === alias || e.startsWith(`${alias}-`) || e.startsWith(`claude-${alias}`) || e.startsWith(`${alias}[`));
|
|
288
|
+
|
|
289
|
+
function claudeModels(ctx, add, group) {
|
|
290
|
+
const list = claudeAvailable(ctx);
|
|
291
|
+
const base = { provider: 'anthropic', providerName: 'Claude Code aliases', source: 'alias', note: list ? 'aliases allowed by availableModels' : 'Claude Code aliases', local: false };
|
|
292
|
+
group(base);
|
|
293
|
+
for (const [id, name] of CLAUDE_ALIASES) if (aliasAllowed(id, list)) add(row(id, base, { name }));
|
|
294
|
+
for (const e of list ?? []) {
|
|
295
|
+
const l = e.toLowerCase();
|
|
296
|
+
if (CLAUDE_ALIASES.some(([a]) => l === a || l.startsWith(`${a}-`) || l.startsWith(`claude-${a}`))) continue;
|
|
297
|
+
add(row(e, { ...base, note: 'availableModels' }));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* `{ models, groups, notes }` for one install. `ctx`: `{ host, scope, dir, root, inUse?, env?, home?,
|
|
303
|
+
* fetchFn? }`: `dir` the install's config dir, `inUse` the model ids its `agent-overrides.json` holds.
|
|
304
|
+
*/
|
|
305
|
+
export async function readModelCatalog(ctx0) {
|
|
306
|
+
const ctx = { env: process.env, home: os.homedir(), fetchFn: globalThis.fetch, inUse: [], ...ctx0 };
|
|
307
|
+
const models = [];
|
|
308
|
+
const ids = new Set();
|
|
309
|
+
const groups = [];
|
|
310
|
+
const add = (r) => { if (!ids.has(r.id)) { ids.add(r.id); models.push(r); } };
|
|
311
|
+
const group = (g) => { if (!groups.some((x) => x.provider === g.provider && x.note === g.note)) groups.push(g); };
|
|
312
|
+
group({ ...SESSION, note: 'inherit', local: false, available: true });
|
|
313
|
+
add({ id: 'inherit', name: 'Session model (inherit)', ...SESSION, note: 'inherit', local: false, available: true });
|
|
314
|
+
if (ctx.host === 'claude') claudeModels(ctx, add, group);
|
|
315
|
+
else if (ctx.host === 'opencode') await opencodeModels(ctx, add, group);
|
|
316
|
+
else if (ctx.host === 'openclaude') await openclaudeModels(ctx, add, group);
|
|
317
|
+
const listed = new Set(ids);
|
|
318
|
+
const inUse = [...new Set(ctx.inUse.filter((x) => typeof x === 'string' && x.trim()))];
|
|
319
|
+
if (inUse.length) group({ provider: 'in-use', providerName: 'In use', source: 'in-use', note: 'written in agent-overrides.json', local: false, available: true });
|
|
320
|
+
for (const id of inUse) {
|
|
321
|
+
models.push({ id, name: id, provider: 'in-use', providerName: 'In use', source: 'in-use', note: 'written in agent-overrides.json', local: false, available: true, detected: listed.has(id) });
|
|
322
|
+
}
|
|
323
|
+
return { models, groups };
|
|
324
|
+
}
|
package/js/web/routes.mjs
CHANGED
|
@@ -28,6 +28,7 @@ import { apiUsage } from './usage-api.mjs';
|
|
|
28
28
|
import { apiProfiles } from './profiles-api.mjs';
|
|
29
29
|
import { fleetSort } from './state.mjs';
|
|
30
30
|
import { apiGates } from './gates-api.mjs';
|
|
31
|
+
import { apiAgentModels, apiAgentModelsFull, apiAgentModelsSave } from './agent-models-api.mjs';
|
|
31
32
|
import { migratePreview } from '../maintain/migrate.mjs';
|
|
32
33
|
import { apiProfile, apiProfileSave, apiRules, apiRulesDecide, apiRulesMutate, apiRulesPromote } from './user-files.mjs';
|
|
33
34
|
|
|
@@ -64,6 +65,8 @@ export const POST_ROUTES = new Map([
|
|
|
64
65
|
// ever consulted — the same shape as `/api/memory/delete` and `/api/activity` above.
|
|
65
66
|
['/api/loops/preset', [apiLoopsPresetMutate, false]],
|
|
66
67
|
['/api/autostart', [apiAutostart, true]],
|
|
68
|
+
// The `tiers` map and the per-agent model pins of one install's agent-overrides.json (any host but Bob).
|
|
69
|
+
['/api/agent-models', [apiAgentModelsSave, true]],
|
|
67
70
|
]);
|
|
68
71
|
|
|
69
72
|
/**
|
|
@@ -74,7 +77,7 @@ export const POST_ROUTES = new Map([
|
|
|
74
77
|
* are the only actions that read the request's install.
|
|
75
78
|
*/
|
|
76
79
|
export const VIEW_POSTS = new Set(['/api/activity', '/api/memory/delete', '/api/rules',
|
|
77
|
-
'/api/rules/promote', '/api/rules/decide', '/api/profile', '/api/actions/restore', '/api/actions/build']);
|
|
80
|
+
'/api/rules/promote', '/api/rules/decide', '/api/profile', '/api/actions/restore', '/api/actions/build', '/api/agent-models']);
|
|
78
81
|
|
|
79
82
|
/**
|
|
80
83
|
* The GETs that answer for the whole machine, not one install: they IGNORE a `?host=&path=`
|
|
@@ -229,6 +232,9 @@ export const STATE_ROUTES = {
|
|
|
229
232
|
// answers — a daemon whose POST worked and whose GET 501'd would have no way to obtain one.
|
|
230
233
|
'/api/rules': apiRules,
|
|
231
234
|
'/api/loadout': (state) => apiLoadout(state),
|
|
235
|
+
// `?models=0`: the per-agent view alone, for a page that does not list models (no probe of a runtime).
|
|
236
|
+
'/api/agent-models': (state, url = '') => (/[?&]models=0(&|$)/.test(String(url))
|
|
237
|
+
? apiAgentModels(state) : apiAgentModelsFull(state)),
|
|
232
238
|
'/api/mcp': apiMcp,
|
|
233
239
|
'/api/loops': apiLoops,
|
|
234
240
|
'/api/loops/active': apiLoopsActive,
|
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`, `exports` 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": "6.0.
|
|
4
|
+
"version": "6.0.2",
|
|
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",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-C1iE8mnY.js";import{t as r}from"./api-CZ-x0iWG.js";import{n as i,t as a}from"./usePoll-D5c_qIFZ.js";import{t as o}from"./DataTable-b9zTShqJ.js";var s=e(t(),1),c={x:260,y:190},l=110,u=28,d=14,f=44,p=e=>e*Math.PI/180,m=e=>Math.round(e*10)/10,h=(e,t=l,n=c)=>({x:m(n.x+t*Math.cos(p(e))),y:m(n.y+t*Math.sin(p(e)))}),g=e=>e/l*(180/Math.PI)+3,_=(e,t,n,r=0)=>`M${t.x},${t.y} A${e},${e} 0 ${r} 1 ${n.x},${n.y}`,v=m(h(205).x-6),y=e=>e.length*6.4,b=e=>({x:e.x-y(e.name)/2,y:e.y-7,w:y(e.name),h:14}),x=(e,t)=>e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h,S=(e,t)=>e.some((n,r)=>[...e.slice(r+1),...t.filter(e=>!e.gate)].some(e=>x(b(n),b(e))));function C(e){return e?.gate===`human`?e.gateOn?.length?`Human gate on ${e.gateOn.join(`, `)}`:`Human gate`:null}function w(e,t=[]){let n=T(e,t,0);if(n.mode!==`ring`)return n;let r=Math.min(...n.entry.map(e=>e.y-30),...n.nodes.map(e=>e.y-e.r-12),...n.inner.map(e=>e.cy-e.r-12),...n.exit?[n.exit.y-24]:[]);return r<0?T(e,t,Math.ceil(-r)):n}function T(e,t,n){let r={x:c.x,y:c.y+n},i=(e,t=l)=>h(e,t,r),a=e=>t.find(t=>t.name===e),o=e=>a(e)?.effect??null,s=e=>C(a(e)),p=e.loops||[],v=p.find(e=>e.iteration);if(!v||v.nodes.length>8)return E(e,o,s);let b=Math.max(...e.nodes.map(e=>p.filter(t=>t.nodes.includes(e)).length)),x=p.filter(e=>e!==v);if(b>3||x.some(e=>!e.nodes.every(e=>v.nodes.includes(e))))return E(e,o,s);let w=v.nodes[0],T=new Set(e.edges.filter(e=>e.to===w).map(e=>e.from)),D=new Map;for(let e of[...x].sort((e,t)=>e.nodes.length-t.nodes.length))for(let t of e.nodes.slice(1))t!==w&&!T.has(t)&&!D.has(t)&&D.set(t,e);let O=v.nodes.filter(e=>!D.has(e));if(O.length<2||x.some(e=>D.has(e.nodes[0])))return E(e,o,s);let k=360/O.length,A=O.map((e,t)=>({name:e,a:-90+t*k,r:u})),j=A.findIndex(e=>o(e.name)===`mutate`);j>=0&&A.splice(j,0,{name:`validate`,a:A[j].a-k/2,r:d,gate:!0});let M=A.map(e=>({name:e.name,...i(e.a),r:e.r,effect:e.gate?null:o(e.name),gate:!!e.gate,inner:!1,human:e.gate?null:s(e.name)})),N=A.map((e,t)=>{let n=A[(t+1)%A.length],r=(t+1===A.length?n.a+360:n.a)-g(n.r)-2,a=e.a+g(e.r);return{d:_(l,i(a),i(r),+(r-a>180)),kind:`ring`}}),P=[],F=new Map;for(let e of x)F.set(e.nodes[0],[...F.get(e.nodes[0])||[],e]);for(let[e,t]of F){let n=A.find(t=>t.name===e),r=i(n.a),a=t.length>1;t.sort((e,t)=>e.nodes.length-t.nodes.length).forEach((e,t)=>{let d=i(n.a+(a?t?18:-18:0),l+(a?54:44)),p=Math.atan2(d.y-r.y,d.x-r.x)*(180/Math.PI),g=e.nodes.filter(t=>D.get(t)===e),v=e=>g.map((t,n)=>({name:t,...h(p+(n-(g.length-1)/2)*e,f,d)})),y=105;for(;y<150&&S(v(y),M);)y+=5;v(y).forEach(({name:e,...t})=>{M.push({name:e,...t,r:u,effect:o(e),gate:!1,inner:!0,human:s(e)})});let b=p+180;N.push({d:_(f,h(b+42,f,d),h(b+138,f,d)),kind:`inner`}),N.push({d:_(f,h(b+222,f,d),h(b+318,f,d)),kind:`inner`});let x=`${e.nodes.join(e.nodes.length===2?` ⇄ `:` → `)} · max ${e.max}`,C={lx:d.x,ly:d.y+f+20,anchor:`middle`};if(a){let e=d.x>=c.x,t=Math.max(f,...g.map(e=>{let t=M.find(t=>t.name===e);return Math.abs(t.x-d.x)+u}));C={lx:m(d.x+(e?t+8:-t-8)),ly:m(d.y+4),anchor:e?`start`:`end`}}P.push({loop:e.name,cx:d.x,cy:d.y,r:f,label:x,...C})})}let I=i(205).y,L=e.nodes.filter(e=>!v.nodes.includes(e)),R=L.map((e,t)=>({name:e,x:40,y:m(I-44*(L.length-1-t)),human:s(e)})),z=e.edges.find(e=>e.to===`$close`)?.from,B=M.find(e=>e.name===z),V=B?{from:z,x:B.x+200,y:B.y-30,d:`M${B.x+u},${B.y-6} C${B.x+90},${B.y-40} ${B.x+170},${B.y-40} ${B.x+200},${B.y-30}`}:null,H=Math.max(540,...M.map(e=>e.x+e.r+8),...V?[V.x+6+y(`close`)+8]:[],...P.map(e=>e.cx+e.r+8),...P.map(e=>e.anchor===`start`?e.lx+y(e.label)+8:e.lx+y(e.label)/2+8)),U=Math.max(300,...M.map(e=>e.y+e.r+12),...P.map(e=>Math.max(e.cy+e.r,e.ly)+12));return{mode:`ring`,width:Math.ceil(H),height:Math.ceil(U),center:{x:r.x,y:r.y,r:l},nodes:M,arcs:N,inner:P,entry:R,exit:V}}function E(e,t,n){let r=e.loops||[],i=e=>36+16*r.filter(t=>t!==e&&t.nodes.every(t=>e.nodes.includes(t))).length,a=Math.max(u,...r.map(i))+30,o=new Map(e.nodes.map((e,t)=>[e,60+t*100])),s=e.nodes.map(e=>({name:e,x:o.get(e),y:a,r:u,effect:t(e),gate:!1,inner:!1,human:n(e)})),c=e.nodes.slice(1).map((t,n)=>({d:`M${o.get(e.nodes[n])+u},${a} L${o.get(t)-u-4},${a}`,kind:`flow`})),l=r.map(e=>{let t=i(e),n=Math.min(...e.nodes.map(e=>o.get(e))),r=Math.max(...e.nodes.map(e=>o.get(e))),s={x:n-t,y:a-t,w:r-n+2*t,h:2*t};return c.push({d:`M${r},${s.y+s.h} L${n+4},${s.y+s.h}`,kind:`flow`}),{loop:e.name,label:`${e.name} · max ${e.max}`,box:s}});return{mode:`flow`,width:60+e.nodes.length*100,height:2*a,center:null,nodes:s,arcs:c,inner:l,entry:[],exit:null}}var D=n();function O({x:e,y:t,label:n}){return(0,D.jsxs)(`g`,{className:`lr-human`,children:[(0,D.jsx)(`title`,{children:n}),(0,D.jsx)(`circle`,{cx:e,cy:t,r:`9`}),(0,D.jsx)(`circle`,{cx:e,cy:t-2.4,r:`2.6`,className:`lr-human-fig`}),(0,D.jsx)(`path`,{d:`M${e-4.6},${t+5.6} a4.6,4.6 0 0 1 9.2,0 Z`,className:`lr-human-fig`})]})}function k({graph:e,bricks:t,onSelect:n,highlight:r}){let i=w(e,t),a=(e.loops||[]).find(e=>e.iteration),o=e=>`${e.name} brick${e.human?`, ${e.human.toLowerCase()}`:``}`,s=e=>t=>{(t.type===`click`||t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n?.(e))};return(0,D.jsxs)(`svg`,{className:`loop-ring`,viewBox:`0 0 ${i.width} ${i.height}`,style:{"--loop-w":`${i.width}px`},role:`group`,"aria-label":`${e.name} loop: ${e.nodes.join(`, `)}`,children:[(0,D.jsx)(`defs`,{children:[`ring`,`inner`,`flow`].map(e=>(0,D.jsx)(`marker`,{id:`lr-arrow-${e}`,markerWidth:`10`,markerHeight:`10`,refX:`7`,refY:`4`,orient:`auto`,children:(0,D.jsx)(`path`,{d:`M0,0 L8,4 L0,8 Z`,className:`lr-head-${e}`})},e))}),i.mode===`ring`&&i.inner.map(e=>(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`circle`,{cx:e.cx,cy:e.cy,r:e.r,className:`lr-inner`}),(0,D.jsx)(`text`,{x:e.lx,y:e.ly,textAnchor:e.anchor,className:`lr-sub lr-good`,children:e.label})]},e.loop)),i.mode===`flow`&&i.inner.map(e=>(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`rect`,{x:e.box.x,y:e.box.y,width:e.box.w,height:e.box.h,rx:`14`,className:`lr-box`}),(0,D.jsx)(`text`,{x:e.box.x+10,y:e.box.y-6,className:`lr-sub lr-good`,children:e.label})]},e.loop)),i.arcs.map((e,t)=>(0,D.jsx)(`path`,{d:e.d,className:`lr-${e.kind}`,markerEnd:`url(#lr-arrow-${e.kind})`},t)),i.entry.length>0&&(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`path`,{d:`M40,${i.entry.at(-1).y} L${v},${i.entry.at(-1).y}`,className:`lr-flow`,markerEnd:`url(#lr-arrow-flow)`}),i.entry.map(e=>(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`text`,{x:e.x,y:e.y-10,className:`lr-lbl`,children:e.name}),(0,D.jsx)(`text`,{x:e.x,y:e.y+18,className:`lr-sub`,children:`setup · 1×`}),e.human?(0,D.jsx)(O,{x:e.x-14,y:e.y-14,label:e.human}):null]},e.name))]}),i.nodes.map(e=>e.gate?(0,D.jsxs)(`g`,{className:`lr-gate`,children:[(0,D.jsx)(`title`,{children:`validate — the engine scores the change before the first mutate step`}),(0,D.jsx)(`circle`,{cx:e.x,cy:e.y,r:e.r}),(0,D.jsx)(`text`,{x:e.x,y:e.y+5,textAnchor:`middle`,children:`⛨`}),(0,D.jsx)(`text`,{x:e.x+20,y:e.y-10,className:`lr-sub lr-warn`,children:`validate`})]},e.name):(0,D.jsxs)(`g`,{className:`lr-node${e.inner?` inner`:``}${e.effect===`mutate`?` mutate`:``}${e.name===r?` current`:``}`,"aria-current":e.name===r?`step`:void 0,...n?{role:`button`,tabIndex:0,"aria-label":o(e),onClick:s(e.name),onKeyDown:s(e.name)}:{role:`img`,"aria-label":`${o(e)}${e.name===r?`, current step`:``}`},children:[(0,D.jsx)(`circle`,{cx:e.x,cy:e.y,r:e.r}),(0,D.jsx)(`text`,{x:e.x,y:e.y+4,textAnchor:`middle`,children:e.name}),e.human?(0,D.jsx)(O,{x:e.x+e.r*.74,y:e.y-e.r*.74,label:e.human}):null]},e.name)),i.exit&&(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`path`,{d:i.exit.d,className:`lr-flow`,markerEnd:`url(#lr-arrow-flow)`}),(0,D.jsx)(`text`,{x:i.exit.x+6,y:i.exit.y+4,className:`lr-lbl`,children:`close`}),(0,D.jsx)(`text`,{x:i.exit.x-90,y:i.exit.y-10,textAnchor:`middle`,className:`lr-sub`,children:`done`})]}),i.center&&a&&(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`text`,{x:i.center.x,y:i.center.y-4,textAnchor:`middle`,className:`lr-title`,children:e.name}),(0,D.jsxs)(`text`,{x:i.center.x,y:i.center.y+16,textAnchor:`middle`,className:`lr-sub lr-acc`,children:[`iterations · max `,a.max]})]})]})}var A=5e3,j=[`prudent`,`balanced`,`aggressive`],M={running:`acc`,awaiting:`warn`,unreadable:`bad`},N=e=>!!e.graph;function P(){let[e,t]=(0,s.useState)(null),[n,o]=(0,s.useState)(null),[c,l]=(0,s.useState)(null),[u,d]=(0,s.useState)(0);return i(e=>r.activeLoops().then(n=>e()&&(t(a(n)),o(null)),t=>e()&&o(t.message)),A,[u]),{loops:e?.loops??null,error:c||n,onPreset:(e,t)=>(l(null),r.setLoopPreset(e,t).then(()=>d(e=>e+1),e=>l(e.message)))}}var F=e=>({key:e,label:e,align:`right`,render:t=>(0,D.jsx)(`span`,{className:`num`,children:t[e]})}),I=[F(`iteration`),{key:`intent`,label:`intent`},F(`declared`),F(`actual`),{key:`decision`,label:`decision`},{key:`tests`,label:`tests`}];function L({history:e}){return e.length?(0,D.jsx)(`div`,{className:`loop-history`,children:(0,D.jsx)(o,{caption:`Iterations`,captionHidden:!0,columns:I,rows:e,rowKey:e=>e.iteration})}):(0,D.jsx)(`p`,{className:`panel-note`,children:`No iteration finished yet.`})}function R({loop:e,bricks:t,onPreset:n}){let r=N(e)?(e.graph.loops||[]).find(e=>e.iteration):null,[i,a]=(0,s.useState)(!1);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`reader-tags`,children:[(0,D.jsx)(`span`,{className:`tag acc`,children:`Active loop`}),(0,D.jsx)(`span`,{className:`tag${M[e.status]?` ${M[e.status]}`:``}`,children:e.status})]}),(0,D.jsx)(`h2`,{className:`reader-title`,children:e.title}),(0,D.jsxs)(`p`,{className:`mono dim reader-src`,children:[e.branch,` · `,e.root]}),N(e)?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`p`,{className:`reader-lede`,children:[`Iteration `,e.iteration,r?` / ${r.max}`:``,` · at `,e.node]}),e.awaiting?(0,D.jsxs)(`p`,{className:`loop-run-wait t-warn`,children:[(0,D.jsxs)(`b`,{children:[`Awaiting `,e.awaiting.kind,e.awaiting.kind===`gate`?` at ${e.awaiting.node}`:``]}),` `,`— Answer in the agent's session.`]}):null,(0,D.jsxs)(`label`,{className:`panel-note loop-run-preset`,children:[`preset`,(0,D.jsx)(`select`,{className:`sel`,"aria-label":`Preset for ${e.title}`,value:e.preset,disabled:i,onChange:t=>{a(!0),Promise.resolve(n(e.root,t.target.value)).finally(()=>a(!1))},children:j.map(e=>(0,D.jsx)(`option`,{children:e},e))})]}),(0,D.jsx)(`a`,{href:`#/docs/loop-risk`,children:`What presets mean →`}),(0,D.jsx)(`hr`,{className:`hr`}),(0,D.jsx)(`div`,{className:`loop-graph`,children:(0,D.jsx)(k,{graph:e.graph,bricks:t,highlight:e.node})}),(0,D.jsx)(`h3`,{className:`loop-h2`,children:`Iterations`}),(0,D.jsx)(L,{history:e.history})]}):(0,D.jsx)(`p`,{className:`reader-lede`,children:e.status===`unreadable`?`Its LOOP.md cannot be read, so there is no state to show.`:`Its LOOP.md is gone: the loop closed and its state went with it.`})]})}export{O as a,w as c,P as i,M as n,k as o,N as r,C as s,R as t};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-C1iE8mnY.js";import{t as r}from"./api-C8nMUU1i.js";import{n as i,t as a}from"./usePoll-D5c_qIFZ.js";import{t as o}from"./DataTable-b9zTShqJ.js";var s=e(t(),1),c={x:260,y:190},l=110,u=28,d=14,f=44,p=e=>e*Math.PI/180,m=e=>Math.round(e*10)/10,h=(e,t=l,n=c)=>({x:m(n.x+t*Math.cos(p(e))),y:m(n.y+t*Math.sin(p(e)))}),g=e=>e/l*(180/Math.PI)+3,_=(e,t,n,r=0)=>`M${t.x},${t.y} A${e},${e} 0 ${r} 1 ${n.x},${n.y}`,v=m(h(205).x-6),y=e=>e.length*6.4,b=e=>({x:e.x-y(e.name)/2,y:e.y-7,w:y(e.name),h:14}),x=(e,t)=>e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h,S=(e,t)=>e.some((n,r)=>[...e.slice(r+1),...t.filter(e=>!e.gate)].some(e=>x(b(n),b(e))));function C(e){return e?.gate===`human`?e.gateOn?.length?`Human gate on ${e.gateOn.join(`, `)}`:`Human gate`:null}function w(e,t=[]){let n=T(e,t,0);if(n.mode!==`ring`)return n;let r=Math.min(...n.entry.map(e=>e.y-30),...n.nodes.map(e=>e.y-e.r-12),...n.inner.map(e=>e.cy-e.r-12),...n.exit?[n.exit.y-24]:[]);return r<0?T(e,t,Math.ceil(-r)):n}function T(e,t,n){let r={x:c.x,y:c.y+n},i=(e,t=l)=>h(e,t,r),a=e=>t.find(t=>t.name===e),o=e=>a(e)?.effect??null,s=e=>C(a(e)),p=e.loops||[],v=p.find(e=>e.iteration);if(!v||v.nodes.length>8)return E(e,o,s);let b=Math.max(...e.nodes.map(e=>p.filter(t=>t.nodes.includes(e)).length)),x=p.filter(e=>e!==v);if(b>3||x.some(e=>!e.nodes.every(e=>v.nodes.includes(e))))return E(e,o,s);let w=v.nodes[0],T=new Set(e.edges.filter(e=>e.to===w).map(e=>e.from)),D=new Map;for(let e of[...x].sort((e,t)=>e.nodes.length-t.nodes.length))for(let t of e.nodes.slice(1))t!==w&&!T.has(t)&&!D.has(t)&&D.set(t,e);let O=v.nodes.filter(e=>!D.has(e));if(O.length<2||x.some(e=>D.has(e.nodes[0])))return E(e,o,s);let k=360/O.length,A=O.map((e,t)=>({name:e,a:-90+t*k,r:u})),j=A.findIndex(e=>o(e.name)===`mutate`);j>=0&&A.splice(j,0,{name:`validate`,a:A[j].a-k/2,r:d,gate:!0});let M=A.map(e=>({name:e.name,...i(e.a),r:e.r,effect:e.gate?null:o(e.name),gate:!!e.gate,inner:!1,human:e.gate?null:s(e.name)})),N=A.map((e,t)=>{let n=A[(t+1)%A.length],r=(t+1===A.length?n.a+360:n.a)-g(n.r)-2,a=e.a+g(e.r);return{d:_(l,i(a),i(r),+(r-a>180)),kind:`ring`}}),P=[],F=new Map;for(let e of x)F.set(e.nodes[0],[...F.get(e.nodes[0])||[],e]);for(let[e,t]of F){let n=A.find(t=>t.name===e),r=i(n.a),a=t.length>1;t.sort((e,t)=>e.nodes.length-t.nodes.length).forEach((e,t)=>{let d=i(n.a+(a?t?18:-18:0),l+(a?54:44)),p=Math.atan2(d.y-r.y,d.x-r.x)*(180/Math.PI),g=e.nodes.filter(t=>D.get(t)===e),v=e=>g.map((t,n)=>({name:t,...h(p+(n-(g.length-1)/2)*e,f,d)})),y=105;for(;y<150&&S(v(y),M);)y+=5;v(y).forEach(({name:e,...t})=>{M.push({name:e,...t,r:u,effect:o(e),gate:!1,inner:!0,human:s(e)})});let b=p+180;N.push({d:_(f,h(b+42,f,d),h(b+138,f,d)),kind:`inner`}),N.push({d:_(f,h(b+222,f,d),h(b+318,f,d)),kind:`inner`});let x=`${e.nodes.join(e.nodes.length===2?` ⇄ `:` → `)} · max ${e.max}`,C={lx:d.x,ly:d.y+f+20,anchor:`middle`};if(a){let e=d.x>=c.x,t=Math.max(f,...g.map(e=>{let t=M.find(t=>t.name===e);return Math.abs(t.x-d.x)+u}));C={lx:m(d.x+(e?t+8:-t-8)),ly:m(d.y+4),anchor:e?`start`:`end`}}P.push({loop:e.name,cx:d.x,cy:d.y,r:f,label:x,...C})})}let I=i(205).y,L=e.nodes.filter(e=>!v.nodes.includes(e)),R=L.map((e,t)=>({name:e,x:40,y:m(I-44*(L.length-1-t)),human:s(e)})),z=e.edges.find(e=>e.to===`$close`)?.from,B=M.find(e=>e.name===z),V=B?{from:z,x:B.x+200,y:B.y-30,d:`M${B.x+u},${B.y-6} C${B.x+90},${B.y-40} ${B.x+170},${B.y-40} ${B.x+200},${B.y-30}`}:null,H=Math.max(540,...M.map(e=>e.x+e.r+8),...V?[V.x+6+y(`close`)+8]:[],...P.map(e=>e.cx+e.r+8),...P.map(e=>e.anchor===`start`?e.lx+y(e.label)+8:e.lx+y(e.label)/2+8)),U=Math.max(300,...M.map(e=>e.y+e.r+12),...P.map(e=>Math.max(e.cy+e.r,e.ly)+12));return{mode:`ring`,width:Math.ceil(H),height:Math.ceil(U),center:{x:r.x,y:r.y,r:l},nodes:M,arcs:N,inner:P,entry:R,exit:V}}function E(e,t,n){let r=e.loops||[],i=e=>36+16*r.filter(t=>t!==e&&t.nodes.every(t=>e.nodes.includes(t))).length,a=Math.max(u,...r.map(i))+30,o=new Map(e.nodes.map((e,t)=>[e,60+t*100])),s=e.nodes.map(e=>({name:e,x:o.get(e),y:a,r:u,effect:t(e),gate:!1,inner:!1,human:n(e)})),c=e.nodes.slice(1).map((t,n)=>({d:`M${o.get(e.nodes[n])+u},${a} L${o.get(t)-u-4},${a}`,kind:`flow`})),l=r.map(e=>{let t=i(e),n=Math.min(...e.nodes.map(e=>o.get(e))),r=Math.max(...e.nodes.map(e=>o.get(e))),s={x:n-t,y:a-t,w:r-n+2*t,h:2*t};return c.push({d:`M${r},${s.y+s.h} L${n+4},${s.y+s.h}`,kind:`flow`}),{loop:e.name,label:`${e.name} · max ${e.max}`,box:s}});return{mode:`flow`,width:60+e.nodes.length*100,height:2*a,center:null,nodes:s,arcs:c,inner:l,entry:[],exit:null}}var D=n();function O({x:e,y:t,label:n}){return(0,D.jsxs)(`g`,{className:`lr-human`,children:[(0,D.jsx)(`title`,{children:n}),(0,D.jsx)(`circle`,{cx:e,cy:t,r:`9`}),(0,D.jsx)(`circle`,{cx:e,cy:t-2.4,r:`2.6`,className:`lr-human-fig`}),(0,D.jsx)(`path`,{d:`M${e-4.6},${t+5.6} a4.6,4.6 0 0 1 9.2,0 Z`,className:`lr-human-fig`})]})}function k({graph:e,bricks:t,onSelect:n,highlight:r}){let i=w(e,t),a=(e.loops||[]).find(e=>e.iteration),o=e=>`${e.name} brick${e.human?`, ${e.human.toLowerCase()}`:``}`,s=e=>t=>{(t.type===`click`||t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n?.(e))};return(0,D.jsxs)(`svg`,{className:`loop-ring`,viewBox:`0 0 ${i.width} ${i.height}`,style:{"--loop-w":`${i.width}px`},role:`group`,"aria-label":`${e.name} loop: ${e.nodes.join(`, `)}`,children:[(0,D.jsx)(`defs`,{children:[`ring`,`inner`,`flow`].map(e=>(0,D.jsx)(`marker`,{id:`lr-arrow-${e}`,markerWidth:`10`,markerHeight:`10`,refX:`7`,refY:`4`,orient:`auto`,children:(0,D.jsx)(`path`,{d:`M0,0 L8,4 L0,8 Z`,className:`lr-head-${e}`})},e))}),i.mode===`ring`&&i.inner.map(e=>(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`circle`,{cx:e.cx,cy:e.cy,r:e.r,className:`lr-inner`}),(0,D.jsx)(`text`,{x:e.lx,y:e.ly,textAnchor:e.anchor,className:`lr-sub lr-good`,children:e.label})]},e.loop)),i.mode===`flow`&&i.inner.map(e=>(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`rect`,{x:e.box.x,y:e.box.y,width:e.box.w,height:e.box.h,rx:`14`,className:`lr-box`}),(0,D.jsx)(`text`,{x:e.box.x+10,y:e.box.y-6,className:`lr-sub lr-good`,children:e.label})]},e.loop)),i.arcs.map((e,t)=>(0,D.jsx)(`path`,{d:e.d,className:`lr-${e.kind}`,markerEnd:`url(#lr-arrow-${e.kind})`},t)),i.entry.length>0&&(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`path`,{d:`M40,${i.entry.at(-1).y} L${v},${i.entry.at(-1).y}`,className:`lr-flow`,markerEnd:`url(#lr-arrow-flow)`}),i.entry.map(e=>(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`text`,{x:e.x,y:e.y-10,className:`lr-lbl`,children:e.name}),(0,D.jsx)(`text`,{x:e.x,y:e.y+18,className:`lr-sub`,children:`setup · 1×`}),e.human?(0,D.jsx)(O,{x:e.x-14,y:e.y-14,label:e.human}):null]},e.name))]}),i.nodes.map(e=>e.gate?(0,D.jsxs)(`g`,{className:`lr-gate`,children:[(0,D.jsx)(`title`,{children:`validate — the engine scores the change before the first mutate step`}),(0,D.jsx)(`circle`,{cx:e.x,cy:e.y,r:e.r}),(0,D.jsx)(`text`,{x:e.x,y:e.y+5,textAnchor:`middle`,children:`⛨`}),(0,D.jsx)(`text`,{x:e.x+20,y:e.y-10,className:`lr-sub lr-warn`,children:`validate`})]},e.name):(0,D.jsxs)(`g`,{className:`lr-node${e.inner?` inner`:``}${e.effect===`mutate`?` mutate`:``}${e.name===r?` current`:``}`,"aria-current":e.name===r?`step`:void 0,...n?{role:`button`,tabIndex:0,"aria-label":o(e),onClick:s(e.name),onKeyDown:s(e.name)}:{role:`img`,"aria-label":`${o(e)}${e.name===r?`, current step`:``}`},children:[(0,D.jsx)(`circle`,{cx:e.x,cy:e.y,r:e.r}),(0,D.jsx)(`text`,{x:e.x,y:e.y+4,textAnchor:`middle`,children:e.name}),e.human?(0,D.jsx)(O,{x:e.x+e.r*.74,y:e.y-e.r*.74,label:e.human}):null]},e.name)),i.exit&&(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`path`,{d:i.exit.d,className:`lr-flow`,markerEnd:`url(#lr-arrow-flow)`}),(0,D.jsx)(`text`,{x:i.exit.x+6,y:i.exit.y+4,className:`lr-lbl`,children:`close`}),(0,D.jsx)(`text`,{x:i.exit.x-90,y:i.exit.y-10,textAnchor:`middle`,className:`lr-sub`,children:`done`})]}),i.center&&a&&(0,D.jsxs)(`g`,{children:[(0,D.jsx)(`text`,{x:i.center.x,y:i.center.y-4,textAnchor:`middle`,className:`lr-title`,children:e.name}),(0,D.jsxs)(`text`,{x:i.center.x,y:i.center.y+16,textAnchor:`middle`,className:`lr-sub lr-acc`,children:[`iterations · max `,a.max]})]})]})}var A=5e3,j=[`prudent`,`balanced`,`aggressive`],M={running:`acc`,awaiting:`warn`,unreadable:`bad`},N=e=>!!e.graph;function P(){let[e,t]=(0,s.useState)(null),[n,o]=(0,s.useState)(null),[c,l]=(0,s.useState)(null),[u,d]=(0,s.useState)(0);return i(e=>r.activeLoops().then(n=>e()&&(t(a(n)),o(null)),t=>e()&&o(t.message)),A,[u]),{loops:e?.loops??null,error:c||n,onPreset:(e,t)=>(l(null),r.setLoopPreset(e,t).then(()=>d(e=>e+1),e=>l(e.message)))}}var F=e=>({key:e,label:e,align:`right`,render:t=>(0,D.jsx)(`span`,{className:`num`,children:t[e]})}),I=[F(`iteration`),{key:`intent`,label:`intent`},F(`declared`),F(`actual`),{key:`decision`,label:`decision`},{key:`tests`,label:`tests`}];function L({history:e}){return e.length?(0,D.jsx)(`div`,{className:`loop-history`,children:(0,D.jsx)(o,{caption:`Iterations`,captionHidden:!0,columns:I,rows:e,rowKey:e=>e.iteration})}):(0,D.jsx)(`p`,{className:`panel-note`,children:`No iteration finished yet.`})}function R({loop:e,bricks:t,onPreset:n}){let r=N(e)?(e.graph.loops||[]).find(e=>e.iteration):null,[i,a]=(0,s.useState)(!1);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`reader-tags`,children:[(0,D.jsx)(`span`,{className:`tag acc`,children:`Active loop`}),(0,D.jsx)(`span`,{className:`tag${M[e.status]?` ${M[e.status]}`:``}`,children:e.status})]}),(0,D.jsx)(`h2`,{className:`reader-title`,children:e.title}),(0,D.jsxs)(`p`,{className:`mono dim reader-src`,children:[e.branch,` · `,e.root]}),N(e)?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`p`,{className:`reader-lede`,children:[`Iteration `,e.iteration,r?` / ${r.max}`:``,` · at `,e.node]}),e.awaiting?(0,D.jsxs)(`p`,{className:`loop-run-wait t-warn`,children:[(0,D.jsxs)(`b`,{children:[`Awaiting `,e.awaiting.kind,e.awaiting.kind===`gate`?` at ${e.awaiting.node}`:``]}),` `,`— Answer in the agent's session.`]}):null,(0,D.jsxs)(`label`,{className:`panel-note loop-run-preset`,children:[`preset`,(0,D.jsx)(`select`,{className:`sel`,"aria-label":`Preset for ${e.title}`,value:e.preset,disabled:i,onChange:t=>{a(!0),Promise.resolve(n(e.root,t.target.value)).finally(()=>a(!1))},children:j.map(e=>(0,D.jsx)(`option`,{children:e},e))})]}),(0,D.jsx)(`a`,{href:`#/docs/loop-risk`,children:`What presets mean →`}),(0,D.jsx)(`hr`,{className:`hr`}),(0,D.jsx)(`div`,{className:`loop-graph`,children:(0,D.jsx)(k,{graph:e.graph,bricks:t,highlight:e.node})}),(0,D.jsx)(`h3`,{className:`loop-h2`,children:`Iterations`}),(0,D.jsx)(L,{history:e.history})]}):(0,D.jsx)(`p`,{className:`reader-lede`,children:e.status===`unreadable`?`Its LOOP.md cannot be read, so there is no state to show.`:`Its LOOP.md is gone: the loop closed and its state went with it.`})]})}export{O as a,w as c,P as i,M as n,k as o,N as r,C as s,R as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-C1iE8mnY.js";import{t as r}from"./api-CZ-x0iWG.js";import{A as i,D as a,E as o,F as s,H as c,L as l,M as u,N as d,O as f,P as p,St as m,T as h,_t as g,et as _,j as v,o as ee,rt as te,tt as y,w as b,wt as x}from"./index-B_pTwZra.js";import{t as S}from"./EmptyState-CY5Pm2xy.js";import{_ as C,a as w,c as T,f as E,g as D,h as O,i as k,l as A,m as ne,n as j,o as M,p as N,r as P,s as F,t as I,u as L,v as R}from"./Bonsai-B5XY9pid.js";import{s as re}from"./motion-RlUl1osO.js";import{n as ie,t as ae}from"./usePoll-D5c_qIFZ.js";var z=e(t(),1),B=n(),V=4,H=56*V,U=24,W=165,G=188,K=(e,t)=>e>0?Math.max(1,Math.floor((e-32+U)/(H+U))):Math.max(1,t),q=e=>e.status===`blocked`?`bad`:u(e)?`warn`:e.status===`busy`?`ok`:``,J=e=>{let t=A(e);return t==null?null:Math.round(t*100)};function Y(e,t,n){let r=b[e.status]||b.idle,i=t.pads.filter(e=>e.key!=null),a=t.pads.reduce((e,t)=>e+t.files.length,0)+t.fallen.reduce((e,t)=>e+t.files.length,0),o=J(e);return[`${e.title||f(e.cwd)||e.session_id}, ${e.chip||e.host||`unknown host`}, ${r.label}${e.phase?`, ${e.phase}`:``}`,`${e.turns||0} turns${o==null?``:`, context ${o} %`}${e.compactions?`, ${e.compactions} compactions`:``}`,i.length?`${i.length} sub-agent${i.length===1?``:`s`} running: ${i.map(e=>`${e.type||`agent`} (${e.files.length} file${e.files.length===1?``:`s`})`).join(`, `)}`:``,t.fallen.length?`${t.fallen.length} finished`:``,`${a} file${a===1?``:`s`} changed`,n.length?`shares ${n.length} file${n.length===1?``:`s`} with another session`:``,e.error?`error: ${e.error}`:``].filter(Boolean).join(`. `)}function X({s:e,t,mine:n}){let r=J(e);return(0,B.jsxs)(`div`,{className:`card gd-card`,children:[(0,B.jsxs)(`dl`,{className:`gd-facts`,children:[e.model&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`model`}),(0,B.jsx)(`dd`,{className:`mono`,children:e.model})]}),(0,B.jsx)(`dt`,{children:`turns`}),(0,B.jsx)(`dd`,{children:e.turns||0}),(0,B.jsx)(`dt`,{children:`context`}),(0,B.jsx)(`dd`,{children:r==null?`unknown`:`${r} %`}),(0,B.jsx)(`dt`,{children:`compactions`}),(0,B.jsx)(`dd`,{children:e.compactions||0})]}),t.fallen.length>0&&(0,B.jsxs)(`div`,{className:`dim act-xs`,children:[`finished: `,t.fallen.map(e=>`${e.type||`agent`} (${e.files.length})`).join(`, `)]}),n.map(e=>(0,B.jsxs)(`div`,{className:`act-xs ${e.kind===`same-worktree`?`t-bad`:`t-warn`}`,children:[`same file`,e.kind===`same-worktree`?``:`, other worktree`,`: `,e.path]},`${e.kind}:${e.path}`))]})}function Z({s:e,worktree:t,sakura:n,mine:r,pad:i,onHover:a}){let o=R(e,n),s=(0,z.useMemo)(()=>E(e,{sakura:n}),[o]),c=b[e.status]||b.idle,l=Array.isArray(e.loops)?e.loops[0]:null,d=e.status!==`idle`,p=F(e),m=e.title||f(e.cwd)||e.session_id,h=J(e),g=(0,z.useRef)(null),_=(0,z.useCallback)(e=>a(p,e,Q(g.current)),[a,p]);return(0,B.jsxs)(`a`,{ref:g,className:`gd-tree${u(e)?` gd-needs`:``}`,href:e.href||L(e.session_id),"aria-label":Y(e,s,r),"data-sid":e.session_id,onMouseEnter:e=>a(p,null,Q(e.currentTarget)),onMouseLeave:()=>a(null,null),onFocus:e=>a(p,null,Q(e.currentTarget)),onBlur:()=>a(null,null),onKeyDown:e=>k(e,s.pads.length,i,_),children:[(0,B.jsx)(P,{t:s,pad:i,swaying:d,onPad:_,px:V}),(0,B.jsxs)(`div`,{className:`gd-cap`,children:[(0,B.jsx)(`div`,{className:`gd-title`,title:m,children:m}),(0,B.jsxs)(`div`,{className:`row wrap gd-pills`,children:[(0,B.jsx)(`span`,{className:`badge mono`,title:`The install this session runs in`,children:e.chip||e.host||`?`}),(0,B.jsx)(`span`,{className:`badge ${q(e)}`,children:c.label}),t&&(0,B.jsxs)(`span`,{className:`badge mono`,children:[`⎇ `,t]}),l&&(0,B.jsxs)(`span`,{className:`badge`,children:[`↻ `,l.title,l.iteration==null?``:` ${l.iteration}`]}),e.attribution===!1&&(0,B.jsx)(`span`,{className:`badge`,title:`attribution unavailable on ${e.host}`,children:`no attrib.`})]}),(0,B.jsxs)(`div`,{className:`mono gd-meta`,children:[e.turns||0,` turns`,h==null?``:` · ${h}%`]})]})]})}function oe({pairs:e,count:t}){if(!e.length)return null;let n=t*H+(t-1)*U,r=e=>e*(H+U)+H/2;return(0,B.jsx)(`svg`,{className:`gd-threads`,width:n,height:56*V+20,"aria-hidden":`true`,children:e.map(({a:e,b:t,kind:n})=>{let[i,a]=e<t?[e,t]:[t,e],o=`gd-thread ${n===`same-worktree`?`red`:`amber`}`;if(a-i===1){let e=r(i)+30,t=r(a)-30,n=(e+t)/2;return(0,B.jsxs)(`g`,{className:o,children:[(0,B.jsx)(`path`,{d:`M${e} ${W} C${n} 179 ${n} 159 ${t} 169`}),(0,B.jsx)(`path`,{d:`M${e} 169 C${n} 159 ${n} 179 ${t} ${W}`})]},`${i}-${a}`)}return(0,B.jsx)(`g`,{className:o,children:(0,B.jsx)(`path`,{d:`M${r(i)} ${G} Q${(r(i)+r(a))/2} 222 ${r(a)} ${G}`})},`${i}-${a}`)})})}var Q=e=>e.offsetLeft;function se({sessions:e,collisions:t}){let[n,r]=(0,z.useState)(M),[i,a]=(0,z.useState)(()=>new Set),o=()=>{let e=!n;r(e);try{window.localStorage.setItem(j,e?`1`:`0`)}catch{}},s=Array.isArray(t)?t:[],c=T(N(e)).map(e=>i.has(e.key)?{...e,collapsed:!1}:e),l=c.filter(e=>e.collapsed),u=e=>D(e,s);return(0,B.jsxs)(`section`,{className:`gd`,"aria-label":`Garden`,children:[(0,B.jsxs)(`div`,{className:`row between wrap gap-8 gd-head`,children:[(0,B.jsxs)(`span`,{className:`dim act-sm`,children:[e.length,` tree`,e.length===1?``:`s`,` · `,c.length,` `,c.length===1?`shelf`:`shelves`,` · a tree opens its session; hover or focus shows its details, and a tap or the arrow keys walk its pads`]}),(0,B.jsx)(`button`,{type:`button`,className:n?`chip-f on`:`chip-f`,"aria-pressed":n,onClick:o,children:`Pink blossom`})]}),l.length>0&&(0,B.jsx)(`div`,{className:`row wrap gap-8 gd-chips`,role:`group`,"aria-label":`Folded shelves`,children:l.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`chip-f`,"aria-expanded":!1,onClick:()=>a(t=>new Set(t).add(e.key)),children:[e.name,` · `,e.trees.length]},e.key))}),c.filter(e=>!e.collapsed).map(e=>(0,B.jsx)(ce,{sh:e,sakura:n,cols:s,mineOf:u},e.key))]})}function ce({sh:e,sakura:t,cols:n,mineOf:r}){let[i,a]=(0,z.useState)({sid:null,pad:null,x:0}),o=(0,z.useCallback)((e,t,n)=>a(r=>({sid:e,pad:t,x:n??(r.sid===e?r.x:0)})),[]),s=(0,z.useRef)(null),[c,l]=(0,z.useState)(0);(0,z.useLayoutEffect)(()=>{let e=s.current,t=()=>l(e.clientWidth);if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let u=K(c,e.trees.length),d=C(e.trees,n),f=[];for(let t=0;t<e.trees.length;t+=u)f.push(t);let p=e.trees.findIndex(e=>F(e.s)===i.sid),m=p<0?null:e.trees[p].s,h=m?E(m,{sakura:t}):null,g=h&&i.pad!=null?h.pads[i.pad]:null,_=e.trees.length;return(0,B.jsxs)(`section`,{className:`gd-shelf`,"aria-label":`${e.name} shelf`,ref:s,children:[f.map(n=>{let a=e.trees.slice(n,n+u),s=n+a.length,c=d.filter(e=>e.a>=n&&e.a<s&&e.b>=n&&e.b<s).map(e=>({...e,a:e.a-n,b:e.b-n}));return(0,B.jsxs)(`div`,{className:`gd-row`,children:[(0,B.jsx)(`div`,{className:`gd-plank`,children:n===0&&(0,B.jsxs)(`h3`,{className:`gd-plate`,children:[e.name,` · `,_,` session`,_===1?``:`s`]})}),a.map(({s:e,worktree:n})=>(0,B.jsx)(Z,{s:e,worktree:n,sakura:t,mine:r(F(e)),pad:F(e)===i.sid?i.pad:null,onHover:o},F(e))),(0,B.jsx)(oe,{pairs:c,count:a.length}),m&&p>=n&&p<s&&(0,B.jsx)(`div`,{className:`gd-info`,"aria-hidden":`true`,style:{left:Math.max(0,i.x)},children:g?(0,B.jsx)(I,{pad:g}):(0,B.jsx)(X,{s:m,t:h,mine:r(F(m))})})]},n)}),(0,B.jsx)(`span`,{className:`sr-only`,role:`status`,children:w(g)})]})}var $=e=>e.catch(()=>null);function le({s:e}){let t=(0,z.useId)(),n=e.todos,r=v(e);return(0,B.jsxs)(`a`,{className:`card pad-md act-card`,href:e.href||L(e.session_id),"aria-labelledby":`${t}-t ${t}-st`,"aria-describedby":r?`${t}-c`:void 0,children:[(0,B.jsxs)(h,{s:e,id:t,heading:e.title||f(e.cwd)||e.session_id,children:[e.chip&&(0,B.jsx)(`span`,{className:`badge mono`,title:`The install this session runs in`,children:e.chip}),(0,B.jsx)(g,{name:`chevron`,className:`glyph act-chev`})]}),n&&n.total>0&&(0,B.jsx)(`div`,{className:`act-foot`,children:(0,B.jsxs)(`span`,{className:`row gap-8 dim act-sm`,children:[(0,B.jsx)(a,{done:n.done,total:n.total}),`plan `,n.done,`/`,n.total]})}),(0,B.jsxs)(`div`,{className:`dim mono act-updated`,children:[`updated `,m(e.updated_at),` ago`]})]})}var ue={blocked:`is blocked`,"waiting-input":`waits for your answer`};function de(e,t){if(!Array.isArray(t))return``;let n=t.filter(u),r=e.current;return e.current=new Set(n.map(e=>`${F(e)}:${e.status}`)),r?n.filter(e=>!r.has(`${F(e)}:${e.status}`)).map(e=>`${e.title||f(e.cwd)||e.session_id} ${ue[e.status]}`).join(`. `):``}var fe=[[`all`,`All`],[`needs`,`Needs you`],[`runs`,`Runs`],[`gates`,`Gate asks`]];function pe(){let e=new URLSearchParams(window.location.hash.split(`?`)[1]||``),t=e.get(`f`);return{f:fe.some(([e])=>e===t)?t:`all`,host:e.get(`host`)||``,project:e.get(`project`)||``,v:e.get(`v`)===`list`?`list`:`garden`}}function me(e){let t=new URLSearchParams;e.f!==`all`&&t.set(`f`,e.f),e.v===`list`&&t.set(`v`,`list`),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 he({enabled:e,installs:t,onToggle:n}){let r=ne(t);return(0,B.jsxs)(`section`,{className:`card pad-md act-track`,"aria-labelledby":`act-track-h`,children:[(0,B.jsx)(g,{name:`activity`,className:`glyph act-fixed`}),(0,B.jsxs)(`div`,{className:`act-grow`,children:[(0,B.jsx)(`h2`,{id:`act-track-h`,className:`act-track-title`,children:e?`Live sessions are on`:`Live sessions are off`}),!e&&(0,B.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,B.jsxs)(`ul`,{className:`stack gap-8 act-fixed act-sm`,"aria-label":`Tracking per install`,children:[t.length===0&&(0,B.jsx)(`li`,{className:`dim`,children:`No active install to track.`}),t.map((e,t)=>(0,B.jsxs)(`li`,{className:`row gap-10`,children:[(0,B.jsxs)(`span`,{id:`act-track-l${t}`,title:e.path,children:[`Track live sessions in `,(0,B.jsx)(`span`,{className:`mono`,children:r.get(e.install)})]}),(0,B.jsx)(`div`,{className:`sw-toggle${e.enabled?` on`:``}`,role:`switch`,"aria-checked":e.enabled,"aria-labelledby":`act-track-l${t}`,tabIndex:0,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.key===` `&&t.preventDefault(),n(e))}})]},e.install))]})]})}function ge({jobs:e,loading:t}){let n=typeof e?.cap==`number`?e.cap:void 0,r=d(e?.jobs,{days:14,cap:n}),i=s(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),c=r.find(e=>!e.nodata),l=r.some(e=>e.nodata),u=`Runs per day: ${r.filter(e=>e.n).map(e=>`${e.n} on ${p(e.key)}`).join(`, `)||`none`}.`+(l?c?` Days before ${p(c.key)} are older than the runs the log keeps.`:` No run is in the log yet.`:``);return(0,B.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-runs-h`,children:[(0,B.jsxs)(`div`,{className:`act-stat-head`,children:[(0,B.jsx)(`h2`,{id:`act-runs-h`,className:`act-lbl`,children:`Runs per day · 14 days`}),e&&(0,B.jsx)(`span`,{className:`act-big`,children:o})]}),t?(0,B.jsx)(y,{label:`Reading the job log…`}):e?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`act-runs`,role:`img`,"aria-label":u,ref:i,children:r.map(e=>e.nodata?(0,B.jsx)(`i`,{className:`nodata`},e.key):e.n?(0,B.jsx)(`i`,{"data-sweep":!0,style:{height:`${e.n/a*100}%`},title:`${p(e.key)}: ${e.n}`},e.key):(0,B.jsx)(`i`,{className:`zero`},e.key))}),(0,B.jsxs)(`div`,{className:`mono act-axis`,"aria-hidden":`true`,children:[(0,B.jsx)(`span`,{children:p(r[0].key)}),(0,B.jsx)(`span`,{children:p(r[7].key)}),(0,B.jsx)(`span`,{children:`today`})]}),l&&(0,B.jsxs)(`span`,{className:`dim act-xs`,children:[`Hatched: older than the runs the log keeps`,n?` (last ${n})`:``,`.`]})]}):(0,B.jsx)(`p`,{className:`dim act-sm`,children:`The job log could not be read.`})]})}function _e({rows:e,gates:t,loading:n}){let r=e.reduce((e,t)=>e+t.n,0);return(0,B.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-gates-h`,children:[(0,B.jsxs)(`div`,{className:`act-stat-head`,children:[(0,B.jsx)(`h2`,{id:`act-gates-h`,className:`act-lbl`,children:`Gate asks by rule · 30 days`}),t&&(0,B.jsx)(`span`,{className:`act-big`,children:r})]}),n?(0,B.jsx)(y,{label:`Reading the gate ledger…`}):e.length?(0,B.jsx)(`ul`,{className:`gate-rows`,children:e.slice(0,6).map((e,t)=>(0,B.jsxs)(`li`,{children:[(0,B.jsxs)(`span`,{className:`act-ell`,children:[e.name,` `,(0,B.jsx)(`span`,{className:`mono dim act-xs`,children:e.rule})]}),(0,B.jsx)(o,{vals:e.per_day,i:t,sweep:!0}),(0,B.jsx)(`span`,{className:`mono`,children:e.n})]},e.rule))}):(0,B.jsx)(`p`,{className:`dim act-sm`,children:t?`No gate asked in 30 days.`:`The gate ledger could not be read.`})]})}var ve={done:[`ok`,`done`],failed:[`bad`,`failed`],running:[``,`running`]};function ye({job:e,longest:t}){let n=l(e),r=e.duration?Math.round(e.duration*10)/10:0,[i,a]=ve[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,B.jsxs)(`li`,{className:`act-row`,children:[(0,B.jsx)(`span`,{className:`mono dim act-xs`,children:s}),(0,B.jsx)(g,{name:`play`,className:`glyph act-glyph`}),(0,B.jsxs)(`span`,{className:`act-what`,children:[(0,B.jsx)(`span`,{className:`act-row-title`,children:n.verb}),n.scope&&(0,B.jsx)(`span`,{className:`dim act-xs act-ell`,title:n.command,children:n.scope})]}),(0,B.jsx)(`span`,{className:`act-dur`,role:`img`,"aria-label":o,children:(0,B.jsx)(`span`,{"data-sweep":!0,style:{width:t>0?`${(e.duration||0)/t*100}%`:`0%`}})}),(0,B.jsx)(`span`,{className:`badge ${i}`,children:a})]})}function be({gate:e}){return(0,B.jsxs)(`li`,{className:`act-row gate`,children:[(0,B.jsx)(`span`,{className:`mono dim act-xs`,children:`—`}),(0,B.jsx)(g,{name:`rule`,className:`glyph act-glyph t-warn`}),(0,B.jsxs)(`span`,{className:`act-what`,children:[(0,B.jsx)(`span`,{className:`act-row-title`,children:e.title}),(0,B.jsx)(`span`,{className:`dim act-xs`,children:`Gate ledger`})]}),(0,B.jsx)(`span`,{className:`act-dur-none`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:`badge warn`,children:`asked`})]})}var xe=5,Se=(e,t)=>[...new Set([...e.filter(Boolean),t].filter(Boolean))];function Ce(){let[e,t]=(0,z.useState)(null),[n,a]=(0,z.useState)(``),[o,l]=(0,z.useState)(pe),[d,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(``),g=(0,z.useRef)(null),v=e=>{let t={...o,...e};l(t),me(t)};ie(e=>r.activity().then(n=>{if(e()){t(ae(n)),a(``);let e=de(g,n?.activity);e&&h(t=>t===e?e+`\xA0`:e)}},t=>{e()&&a(t.message)}),2e3,[]);let b=x(()=>$(r.jobs()),[]),C=x(()=>$(r.gates()),[]),w=x(()=>$(r.catalog(`laws`)),[]),T=!e||e.enabled!==!1,E=Array.isArray(e?.installs)?e.installs:[],D=O(e?.activity,E).sort((e,t)=>e.session_id<t.session_id?-1:+(e.session_id>t.session_id)),k=re(),A=T&&e?D.filter(u).length:null,ne=new Set(D.map(F)),j=o.v===`list`?O(e?.ended,E).filter(e=>!ne.has(F(e))):[],M=Se([...D,...j].map(e=>e.host),o.host),N=Se([...D,...j].map(e=>f(e.cwd)),o.project),P=o.host&&o.project?`host or project`:o.host?`host`:o.project?`project`:``,I=e=>(!o.host||e.host===o.host)&&(!o.project||f(e.cwd)===o.project),L=D.filter(e=>I(e)&&(o.f!==`needs`||u(e))),R=o.f===`all`||o.f===`needs`,V=o.f===`all`&&T?j.filter(I):[],H=d?V:V.slice(0,xe),U=!P&&(o.f===`all`||o.f===`runs`),W=!P&&(o.f===`all`||o.f===`gates`),G=b.data?.jobs||[],K=ee(C.data,w.data),q=i(G,K,C.data?.days).map(e=>({...e,runs:U?e.runs:[],gate:W?e.gate:null})).filter(e=>e.runs.length||e.gate),J=Math.max(0,...G.map(e=>e.duration||0)),Y=s(q.flatMap(e=>e.runs.map(e=>`${e.id}:${e.duration}`)).join(`,`),`scaleX`),X=async e=>{let n=!e.enabled;try{let i=await r.activityToggle(n,{host:e.host,path:e.path});if(i.ok===!1){a(i.error||`Could not change tracking`);return}let o=t=>i.enabled?t||[]:(t||[]).flatMap(t=>{let n=(t.installs||[t.install]).filter(t=>t!==e.install);return n.length?[{...t,install:n[0],installs:n}]:[]});t(t=>{let n=(t?.installs||[]).map(t=>t.install===e.install?{...t,enabled:i.enabled}:t);return{...t||{},installs:n,enabled:n.length===0||n.some(e=>e.enabled),activity:o(t?.activity),ended:o(t?.ended)}}),a(``)}catch(e){a(e.message)}},Z=(e,t,n)=>(0,B.jsxs)(`span`,{className:`row gap-8 act-sm`,children:[(0,B.jsx)(`label`,{htmlFor:`act-f-${e}`,children:t}),(0,B.jsxs)(`select`,{id:`act-f-${e}`,className:`sel`,value:o[e],disabled:n.length===0,title:n.length===0?`No source carries a ${e} yet`:void 0,onChange:t=>v({[e]:t.target.value}),children:[(0,B.jsxs)(`option`,{value:``,children:[`All `,e===`host`?`hosts`:`projects`]}),n.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]});return(0,B.jsxs)(`div`,{className:`page-fill`,children:[(0,B.jsx)(c,{title:`Activity`,sub:`What your agents ran, what the gates asked, and which sessions are waiting on you.`}),(0,B.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,children:m}),n&&(0,B.jsx)(`div`,{className:`act-gap`,children:(0,B.jsx)(_,{error:n})}),e&&(0,B.jsx)(he,{enabled:T,installs:E,onToggle:X}),(0,B.jsxs)(`div`,{className:`act-today`,children:[(0,B.jsx)(ge,{jobs:b.data,loading:b.loading}),(0,B.jsx)(_e,{rows:K,gates:C.data,loading:C.loading}),(0,B.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-wait-h`,children:[(0,B.jsx)(`h2`,{id:`act-wait-h`,className:`act-lbl`,children:`Waiting on you`}),!e&&!n?(0,B.jsx)(y,{}):e?(0,B.jsxs)(B.Fragment,{children:[T?(0,B.jsxs)(`span`,{className:`act-big act-wait`,children:[A,` `,(0,B.jsx)(`span`,{className:`dim act-sm`,children:A===1?`session`:`sessions`})]}):null,(0,B.jsx)(`p`,{className:`dim act-sm`,children:T?`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,B.jsx)(`p`,{className:`dim act-sm`,children:`The sessions could not be read.`})]})]}),(0,B.jsxs)(`div`,{className:`row wrap gap-8 act-filters`,children:[(0,B.jsx)(`div`,{role:`group`,"aria-label":`Filter`,className:`row wrap gap-8`,children:fe.map(([e,t])=>(0,B.jsxs)(`button`,{type:`button`,className:o.f===e?`chip-f on`:`chip-f`,"aria-pressed":o.f===e,onClick:()=>v({f:e}),children:[t,e===`needs`&&A>0?(0,B.jsxs)(`span`,{className:`mono`,children:[` `,A]}):null]},e))}),Z(`host`,`Host`,M),Z(`project`,`Project`,N),(0,B.jsx)(te,{"aria-label":`Live sessions view`,children:[[`list`,`List`],[`garden`,`Garden`]].map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,className:o.v===e?`on`:``,"aria-pressed":o.v===e,onClick:()=>v({v:e}),children:t},e))})]}),P&&o.f!==`needs`&&(0,B.jsxs)(`p`,{className:`dim act-sm`,children:[`Runs and gate asks carry no `,P,`; showing sessions only.`]}),R&&(e?!T&&o.f!==`needs`?null:L.length===0?o.f===`needs`?(0,B.jsx)(S,{title:`Nothing waits on you`}):(0,B.jsx)(S,{title:`No active sessions`,children:`Start an agent session and it appears here.`}):o.v===`garden`?(0,B.jsx)(se,{sessions:L,collisions:e.collisions}):(0,B.jsx)(`div`,{className:`stack gap-12 act-live`,ref:k,children:L.map(e=>(0,B.jsx)(`div`,{"data-flip":F(e),children:(0,B.jsx)(le,{s:e})},F(e)))}):(0,B.jsx)(y,{label:`Reading live sessions…`})),V.length>0&&(0,B.jsxs)(`section`,{className:`stack gap-12 act-live act-ended`,"aria-labelledby":`act-ended-h`,children:[(0,B.jsx)(`h2`,{id:`act-ended-h`,className:`act-lbl`,children:`Recently ended`}),H.map(e=>(0,B.jsx)(`div`,{children:(0,B.jsx)(le,{s:e})},F(e))),V.length>xe&&(0,B.jsx)(`button`,{type:`button`,className:`btn ghost sm`,"aria-expanded":d,onClick:()=>p(e=>!e),children:d?`Show fewer`:`Show all ${V.length}`})]}),o.f!==`needs`&&(0,B.jsx)(`section`,{"aria-label":`Feed`,className:`stack gap-16 act-feed`,ref:Y,children:q.map(e=>(0,B.jsxs)(`section`,{className:`card act-day`,children:[(0,B.jsxs)(`h3`,{className:`act-day-h`,children:[(0,B.jsx)(`span`,{children:e.title}),(0,B.jsx)(`span`,{className:`mono dim`,children:e.sum})]}),(0,B.jsxs)(`ul`,{className:`act-rows`,children:[e.runs.map(e=>(0,B.jsx)(ye,{job:e,longest:J},e.id)),e.gate&&(0,B.jsx)(be,{gate:e.gate})]})]},e.key))})]})}export{Ce as default};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-C1iE8mnY.js";import{t as r}from"./api-C8nMUU1i.js";import{A as i,D as a,E as o,F as s,H as c,L as l,M as u,N as d,O as f,P as p,St as m,T as h,_t as g,et as _,j as v,o as ee,rt as te,tt as y,w as b,wt as x}from"./index-BhT94v2q.js";import{t as S}from"./EmptyState-CY5Pm2xy.js";import{_ as C,a as w,c as T,f as E,g as D,h as O,i as k,l as A,m as ne,n as j,o as M,p as N,r as P,s as F,t as I,u as L,v as R}from"./Bonsai-Bry-kOFb.js";import{s as re}from"./motion-RlUl1osO.js";import{n as ie,t as ae}from"./usePoll-D5c_qIFZ.js";var z=e(t(),1),B=n(),V=4,H=56*V,U=24,W=165,G=188,K=(e,t)=>e>0?Math.max(1,Math.floor((e-32+U)/(H+U))):Math.max(1,t),q=e=>e.status===`blocked`?`bad`:u(e)?`warn`:e.status===`busy`?`ok`:``,J=e=>{let t=A(e);return t==null?null:Math.round(t*100)};function Y(e,t,n){let r=b[e.status]||b.idle,i=t.pads.filter(e=>e.key!=null),a=t.pads.reduce((e,t)=>e+t.files.length,0)+t.fallen.reduce((e,t)=>e+t.files.length,0),o=J(e);return[`${e.title||f(e.cwd)||e.session_id}, ${e.chip||e.host||`unknown host`}, ${r.label}${e.phase?`, ${e.phase}`:``}`,`${e.turns||0} turns${o==null?``:`, context ${o} %`}${e.compactions?`, ${e.compactions} compactions`:``}`,i.length?`${i.length} sub-agent${i.length===1?``:`s`} running: ${i.map(e=>`${e.type||`agent`} (${e.files.length} file${e.files.length===1?``:`s`})`).join(`, `)}`:``,t.fallen.length?`${t.fallen.length} finished`:``,`${a} file${a===1?``:`s`} changed`,n.length?`shares ${n.length} file${n.length===1?``:`s`} with another session`:``,e.error?`error: ${e.error}`:``].filter(Boolean).join(`. `)}function X({s:e,t,mine:n}){let r=J(e);return(0,B.jsxs)(`div`,{className:`card gd-card`,children:[(0,B.jsxs)(`dl`,{className:`gd-facts`,children:[e.model&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`model`}),(0,B.jsx)(`dd`,{className:`mono`,children:e.model})]}),(0,B.jsx)(`dt`,{children:`turns`}),(0,B.jsx)(`dd`,{children:e.turns||0}),(0,B.jsx)(`dt`,{children:`context`}),(0,B.jsx)(`dd`,{children:r==null?`unknown`:`${r} %`}),(0,B.jsx)(`dt`,{children:`compactions`}),(0,B.jsx)(`dd`,{children:e.compactions||0})]}),t.fallen.length>0&&(0,B.jsxs)(`div`,{className:`dim act-xs`,children:[`finished: `,t.fallen.map(e=>`${e.type||`agent`} (${e.files.length})`).join(`, `)]}),n.map(e=>(0,B.jsxs)(`div`,{className:`act-xs ${e.kind===`same-worktree`?`t-bad`:`t-warn`}`,children:[`same file`,e.kind===`same-worktree`?``:`, other worktree`,`: `,e.path]},`${e.kind}:${e.path}`))]})}function Z({s:e,worktree:t,sakura:n,mine:r,pad:i,onHover:a}){let o=R(e,n),s=(0,z.useMemo)(()=>E(e,{sakura:n}),[o]),c=b[e.status]||b.idle,l=Array.isArray(e.loops)?e.loops[0]:null,d=e.status!==`idle`,p=F(e),m=e.title||f(e.cwd)||e.session_id,h=J(e),g=(0,z.useRef)(null),_=(0,z.useCallback)(e=>a(p,e,Q(g.current)),[a,p]);return(0,B.jsxs)(`a`,{ref:g,className:`gd-tree${u(e)?` gd-needs`:``}`,href:e.href||L(e.session_id),"aria-label":Y(e,s,r),"data-sid":e.session_id,onMouseEnter:e=>a(p,null,Q(e.currentTarget)),onMouseLeave:()=>a(null,null),onFocus:e=>a(p,null,Q(e.currentTarget)),onBlur:()=>a(null,null),onKeyDown:e=>k(e,s.pads.length,i,_),children:[(0,B.jsx)(P,{t:s,pad:i,swaying:d,onPad:_,px:V}),(0,B.jsxs)(`div`,{className:`gd-cap`,children:[(0,B.jsx)(`div`,{className:`gd-title`,title:m,children:m}),(0,B.jsxs)(`div`,{className:`row wrap gd-pills`,children:[(0,B.jsx)(`span`,{className:`badge mono`,title:`The install this session runs in`,children:e.chip||e.host||`?`}),(0,B.jsx)(`span`,{className:`badge ${q(e)}`,children:c.label}),t&&(0,B.jsxs)(`span`,{className:`badge mono`,children:[`⎇ `,t]}),l&&(0,B.jsxs)(`span`,{className:`badge`,children:[`↻ `,l.title,l.iteration==null?``:` ${l.iteration}`]}),e.attribution===!1&&(0,B.jsx)(`span`,{className:`badge`,title:`attribution unavailable on ${e.host}`,children:`no attrib.`})]}),(0,B.jsxs)(`div`,{className:`mono gd-meta`,children:[e.turns||0,` turns`,h==null?``:` · ${h}%`]})]})]})}function oe({pairs:e,count:t}){if(!e.length)return null;let n=t*H+(t-1)*U,r=e=>e*(H+U)+H/2;return(0,B.jsx)(`svg`,{className:`gd-threads`,width:n,height:56*V+20,"aria-hidden":`true`,children:e.map(({a:e,b:t,kind:n})=>{let[i,a]=e<t?[e,t]:[t,e],o=`gd-thread ${n===`same-worktree`?`red`:`amber`}`;if(a-i===1){let e=r(i)+30,t=r(a)-30,n=(e+t)/2;return(0,B.jsxs)(`g`,{className:o,children:[(0,B.jsx)(`path`,{d:`M${e} ${W} C${n} 179 ${n} 159 ${t} 169`}),(0,B.jsx)(`path`,{d:`M${e} 169 C${n} 159 ${n} 179 ${t} ${W}`})]},`${i}-${a}`)}return(0,B.jsx)(`g`,{className:o,children:(0,B.jsx)(`path`,{d:`M${r(i)} ${G} Q${(r(i)+r(a))/2} 222 ${r(a)} ${G}`})},`${i}-${a}`)})})}var Q=e=>e.offsetLeft;function se({sessions:e,collisions:t}){let[n,r]=(0,z.useState)(M),[i,a]=(0,z.useState)(()=>new Set),o=()=>{let e=!n;r(e);try{window.localStorage.setItem(j,e?`1`:`0`)}catch{}},s=Array.isArray(t)?t:[],c=T(N(e)).map(e=>i.has(e.key)?{...e,collapsed:!1}:e),l=c.filter(e=>e.collapsed),u=e=>D(e,s);return(0,B.jsxs)(`section`,{className:`gd`,"aria-label":`Garden`,children:[(0,B.jsxs)(`div`,{className:`row between wrap gap-8 gd-head`,children:[(0,B.jsxs)(`span`,{className:`dim act-sm`,children:[e.length,` tree`,e.length===1?``:`s`,` · `,c.length,` `,c.length===1?`shelf`:`shelves`,` · a tree opens its session; hover or focus shows its details, and a tap or the arrow keys walk its pads`]}),(0,B.jsx)(`button`,{type:`button`,className:n?`chip-f on`:`chip-f`,"aria-pressed":n,onClick:o,children:`Pink blossom`})]}),l.length>0&&(0,B.jsx)(`div`,{className:`row wrap gap-8 gd-chips`,role:`group`,"aria-label":`Folded shelves`,children:l.map(e=>(0,B.jsxs)(`button`,{type:`button`,className:`chip-f`,"aria-expanded":!1,onClick:()=>a(t=>new Set(t).add(e.key)),children:[e.name,` · `,e.trees.length]},e.key))}),c.filter(e=>!e.collapsed).map(e=>(0,B.jsx)(ce,{sh:e,sakura:n,cols:s,mineOf:u},e.key))]})}function ce({sh:e,sakura:t,cols:n,mineOf:r}){let[i,a]=(0,z.useState)({sid:null,pad:null,x:0}),o=(0,z.useCallback)((e,t,n)=>a(r=>({sid:e,pad:t,x:n??(r.sid===e?r.x:0)})),[]),s=(0,z.useRef)(null),[c,l]=(0,z.useState)(0);(0,z.useLayoutEffect)(()=>{let e=s.current,t=()=>l(e.clientWidth);if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let u=K(c,e.trees.length),d=C(e.trees,n),f=[];for(let t=0;t<e.trees.length;t+=u)f.push(t);let p=e.trees.findIndex(e=>F(e.s)===i.sid),m=p<0?null:e.trees[p].s,h=m?E(m,{sakura:t}):null,g=h&&i.pad!=null?h.pads[i.pad]:null,_=e.trees.length;return(0,B.jsxs)(`section`,{className:`gd-shelf`,"aria-label":`${e.name} shelf`,ref:s,children:[f.map(n=>{let a=e.trees.slice(n,n+u),s=n+a.length,c=d.filter(e=>e.a>=n&&e.a<s&&e.b>=n&&e.b<s).map(e=>({...e,a:e.a-n,b:e.b-n}));return(0,B.jsxs)(`div`,{className:`gd-row`,children:[(0,B.jsx)(`div`,{className:`gd-plank`,children:n===0&&(0,B.jsxs)(`h3`,{className:`gd-plate`,children:[e.name,` · `,_,` session`,_===1?``:`s`]})}),a.map(({s:e,worktree:n})=>(0,B.jsx)(Z,{s:e,worktree:n,sakura:t,mine:r(F(e)),pad:F(e)===i.sid?i.pad:null,onHover:o},F(e))),(0,B.jsx)(oe,{pairs:c,count:a.length}),m&&p>=n&&p<s&&(0,B.jsx)(`div`,{className:`gd-info`,"aria-hidden":`true`,style:{left:Math.max(0,i.x)},children:g?(0,B.jsx)(I,{pad:g}):(0,B.jsx)(X,{s:m,t:h,mine:r(F(m))})})]},n)}),(0,B.jsx)(`span`,{className:`sr-only`,role:`status`,children:w(g)})]})}var $=e=>e.catch(()=>null);function le({s:e}){let t=(0,z.useId)(),n=e.todos,r=v(e);return(0,B.jsxs)(`a`,{className:`card pad-md act-card`,href:e.href||L(e.session_id),"aria-labelledby":`${t}-t ${t}-st`,"aria-describedby":r?`${t}-c`:void 0,children:[(0,B.jsxs)(h,{s:e,id:t,heading:e.title||f(e.cwd)||e.session_id,children:[e.chip&&(0,B.jsx)(`span`,{className:`badge mono`,title:`The install this session runs in`,children:e.chip}),(0,B.jsx)(g,{name:`chevron`,className:`glyph act-chev`})]}),n&&n.total>0&&(0,B.jsx)(`div`,{className:`act-foot`,children:(0,B.jsxs)(`span`,{className:`row gap-8 dim act-sm`,children:[(0,B.jsx)(a,{done:n.done,total:n.total}),`plan `,n.done,`/`,n.total]})}),(0,B.jsxs)(`div`,{className:`dim mono act-updated`,children:[`updated `,m(e.updated_at),` ago`]})]})}var ue={blocked:`is blocked`,"waiting-input":`waits for your answer`};function de(e,t){if(!Array.isArray(t))return``;let n=t.filter(u),r=e.current;return e.current=new Set(n.map(e=>`${F(e)}:${e.status}`)),r?n.filter(e=>!r.has(`${F(e)}:${e.status}`)).map(e=>`${e.title||f(e.cwd)||e.session_id} ${ue[e.status]}`).join(`. `):``}var fe=[[`all`,`All`],[`needs`,`Needs you`],[`runs`,`Runs`],[`gates`,`Gate asks`]];function pe(){let e=new URLSearchParams(window.location.hash.split(`?`)[1]||``),t=e.get(`f`);return{f:fe.some(([e])=>e===t)?t:`all`,host:e.get(`host`)||``,project:e.get(`project`)||``,v:e.get(`v`)===`list`?`list`:`garden`}}function me(e){let t=new URLSearchParams;e.f!==`all`&&t.set(`f`,e.f),e.v===`list`&&t.set(`v`,`list`),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 he({enabled:e,installs:t,onToggle:n}){let r=ne(t);return(0,B.jsxs)(`section`,{className:`card pad-md act-track`,"aria-labelledby":`act-track-h`,children:[(0,B.jsx)(g,{name:`activity`,className:`glyph act-fixed`}),(0,B.jsxs)(`div`,{className:`act-grow`,children:[(0,B.jsx)(`h2`,{id:`act-track-h`,className:`act-track-title`,children:e?`Live sessions are on`:`Live sessions are off`}),!e&&(0,B.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,B.jsxs)(`ul`,{className:`stack gap-8 act-fixed act-sm`,"aria-label":`Tracking per install`,children:[t.length===0&&(0,B.jsx)(`li`,{className:`dim`,children:`No active install to track.`}),t.map((e,t)=>(0,B.jsxs)(`li`,{className:`row gap-10`,children:[(0,B.jsxs)(`span`,{id:`act-track-l${t}`,title:e.path,children:[`Track live sessions in `,(0,B.jsx)(`span`,{className:`mono`,children:r.get(e.install)})]}),(0,B.jsx)(`div`,{className:`sw-toggle${e.enabled?` on`:``}`,role:`switch`,"aria-checked":e.enabled,"aria-labelledby":`act-track-l${t}`,tabIndex:0,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.key===` `&&t.preventDefault(),n(e))}})]},e.install))]})]})}function ge({jobs:e,loading:t}){let n=typeof e?.cap==`number`?e.cap:void 0,r=d(e?.jobs,{days:14,cap:n}),i=s(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),c=r.find(e=>!e.nodata),l=r.some(e=>e.nodata),u=`Runs per day: ${r.filter(e=>e.n).map(e=>`${e.n} on ${p(e.key)}`).join(`, `)||`none`}.`+(l?c?` Days before ${p(c.key)} are older than the runs the log keeps.`:` No run is in the log yet.`:``);return(0,B.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-runs-h`,children:[(0,B.jsxs)(`div`,{className:`act-stat-head`,children:[(0,B.jsx)(`h2`,{id:`act-runs-h`,className:`act-lbl`,children:`Runs per day · 14 days`}),e&&(0,B.jsx)(`span`,{className:`act-big`,children:o})]}),t?(0,B.jsx)(y,{label:`Reading the job log…`}):e?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`act-runs`,role:`img`,"aria-label":u,ref:i,children:r.map(e=>e.nodata?(0,B.jsx)(`i`,{className:`nodata`},e.key):e.n?(0,B.jsx)(`i`,{"data-sweep":!0,style:{height:`${e.n/a*100}%`},title:`${p(e.key)}: ${e.n}`},e.key):(0,B.jsx)(`i`,{className:`zero`},e.key))}),(0,B.jsxs)(`div`,{className:`mono act-axis`,"aria-hidden":`true`,children:[(0,B.jsx)(`span`,{children:p(r[0].key)}),(0,B.jsx)(`span`,{children:p(r[7].key)}),(0,B.jsx)(`span`,{children:`today`})]}),l&&(0,B.jsxs)(`span`,{className:`dim act-xs`,children:[`Hatched: older than the runs the log keeps`,n?` (last ${n})`:``,`.`]})]}):(0,B.jsx)(`p`,{className:`dim act-sm`,children:`The job log could not be read.`})]})}function _e({rows:e,gates:t,loading:n}){let r=e.reduce((e,t)=>e+t.n,0);return(0,B.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-gates-h`,children:[(0,B.jsxs)(`div`,{className:`act-stat-head`,children:[(0,B.jsx)(`h2`,{id:`act-gates-h`,className:`act-lbl`,children:`Gate asks by rule · 30 days`}),t&&(0,B.jsx)(`span`,{className:`act-big`,children:r})]}),n?(0,B.jsx)(y,{label:`Reading the gate ledger…`}):e.length?(0,B.jsx)(`ul`,{className:`gate-rows`,children:e.slice(0,6).map((e,t)=>(0,B.jsxs)(`li`,{children:[(0,B.jsxs)(`span`,{className:`act-ell`,children:[e.name,` `,(0,B.jsx)(`span`,{className:`mono dim act-xs`,children:e.rule})]}),(0,B.jsx)(o,{vals:e.per_day,i:t,sweep:!0}),(0,B.jsx)(`span`,{className:`mono`,children:e.n})]},e.rule))}):(0,B.jsx)(`p`,{className:`dim act-sm`,children:t?`No gate asked in 30 days.`:`The gate ledger could not be read.`})]})}var ve={done:[`ok`,`done`],failed:[`bad`,`failed`],running:[``,`running`]};function ye({job:e,longest:t}){let n=l(e),r=e.duration?Math.round(e.duration*10)/10:0,[i,a]=ve[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,B.jsxs)(`li`,{className:`act-row`,children:[(0,B.jsx)(`span`,{className:`mono dim act-xs`,children:s}),(0,B.jsx)(g,{name:`play`,className:`glyph act-glyph`}),(0,B.jsxs)(`span`,{className:`act-what`,children:[(0,B.jsx)(`span`,{className:`act-row-title`,children:n.verb}),n.scope&&(0,B.jsx)(`span`,{className:`dim act-xs act-ell`,title:n.command,children:n.scope})]}),(0,B.jsx)(`span`,{className:`act-dur`,role:`img`,"aria-label":o,children:(0,B.jsx)(`span`,{"data-sweep":!0,style:{width:t>0?`${(e.duration||0)/t*100}%`:`0%`}})}),(0,B.jsx)(`span`,{className:`badge ${i}`,children:a})]})}function be({gate:e}){return(0,B.jsxs)(`li`,{className:`act-row gate`,children:[(0,B.jsx)(`span`,{className:`mono dim act-xs`,children:`—`}),(0,B.jsx)(g,{name:`rule`,className:`glyph act-glyph t-warn`}),(0,B.jsxs)(`span`,{className:`act-what`,children:[(0,B.jsx)(`span`,{className:`act-row-title`,children:e.title}),(0,B.jsx)(`span`,{className:`dim act-xs`,children:`Gate ledger`})]}),(0,B.jsx)(`span`,{className:`act-dur-none`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:`badge warn`,children:`asked`})]})}var xe=5,Se=(e,t)=>[...new Set([...e.filter(Boolean),t].filter(Boolean))];function Ce(){let[e,t]=(0,z.useState)(null),[n,a]=(0,z.useState)(``),[o,l]=(0,z.useState)(pe),[d,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(``),g=(0,z.useRef)(null),v=e=>{let t={...o,...e};l(t),me(t)};ie(e=>r.activity().then(n=>{if(e()){t(ae(n)),a(``);let e=de(g,n?.activity);e&&h(t=>t===e?e+`\xA0`:e)}},t=>{e()&&a(t.message)}),2e3,[]);let b=x(()=>$(r.jobs()),[]),C=x(()=>$(r.gates()),[]),w=x(()=>$(r.catalog(`laws`)),[]),T=!e||e.enabled!==!1,E=Array.isArray(e?.installs)?e.installs:[],D=O(e?.activity,E).sort((e,t)=>e.session_id<t.session_id?-1:+(e.session_id>t.session_id)),k=re(),A=T&&e?D.filter(u).length:null,ne=new Set(D.map(F)),j=o.v===`list`?O(e?.ended,E).filter(e=>!ne.has(F(e))):[],M=Se([...D,...j].map(e=>e.host),o.host),N=Se([...D,...j].map(e=>f(e.cwd)),o.project),P=o.host&&o.project?`host or project`:o.host?`host`:o.project?`project`:``,I=e=>(!o.host||e.host===o.host)&&(!o.project||f(e.cwd)===o.project),L=D.filter(e=>I(e)&&(o.f!==`needs`||u(e))),R=o.f===`all`||o.f===`needs`,V=o.f===`all`&&T?j.filter(I):[],H=d?V:V.slice(0,xe),U=!P&&(o.f===`all`||o.f===`runs`),W=!P&&(o.f===`all`||o.f===`gates`),G=b.data?.jobs||[],K=ee(C.data,w.data),q=i(G,K,C.data?.days).map(e=>({...e,runs:U?e.runs:[],gate:W?e.gate:null})).filter(e=>e.runs.length||e.gate),J=Math.max(0,...G.map(e=>e.duration||0)),Y=s(q.flatMap(e=>e.runs.map(e=>`${e.id}:${e.duration}`)).join(`,`),`scaleX`),X=async e=>{let n=!e.enabled;try{let i=await r.activityToggle(n,{host:e.host,path:e.path});if(i.ok===!1){a(i.error||`Could not change tracking`);return}let o=t=>i.enabled?t||[]:(t||[]).flatMap(t=>{let n=(t.installs||[t.install]).filter(t=>t!==e.install);return n.length?[{...t,install:n[0],installs:n}]:[]});t(t=>{let n=(t?.installs||[]).map(t=>t.install===e.install?{...t,enabled:i.enabled}:t);return{...t||{},installs:n,enabled:n.length===0||n.some(e=>e.enabled),activity:o(t?.activity),ended:o(t?.ended)}}),a(``)}catch(e){a(e.message)}},Z=(e,t,n)=>(0,B.jsxs)(`span`,{className:`row gap-8 act-sm`,children:[(0,B.jsx)(`label`,{htmlFor:`act-f-${e}`,children:t}),(0,B.jsxs)(`select`,{id:`act-f-${e}`,className:`sel`,value:o[e],disabled:n.length===0,title:n.length===0?`No source carries a ${e} yet`:void 0,onChange:t=>v({[e]:t.target.value}),children:[(0,B.jsxs)(`option`,{value:``,children:[`All `,e===`host`?`hosts`:`projects`]}),n.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]});return(0,B.jsxs)(`div`,{className:`page-fill`,children:[(0,B.jsx)(c,{title:`Activity`,sub:`What your agents ran, what the gates asked, and which sessions are waiting on you.`}),(0,B.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,children:m}),n&&(0,B.jsx)(`div`,{className:`act-gap`,children:(0,B.jsx)(_,{error:n})}),e&&(0,B.jsx)(he,{enabled:T,installs:E,onToggle:X}),(0,B.jsxs)(`div`,{className:`act-today`,children:[(0,B.jsx)(ge,{jobs:b.data,loading:b.loading}),(0,B.jsx)(_e,{rows:K,gates:C.data,loading:C.loading}),(0,B.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-wait-h`,children:[(0,B.jsx)(`h2`,{id:`act-wait-h`,className:`act-lbl`,children:`Waiting on you`}),!e&&!n?(0,B.jsx)(y,{}):e?(0,B.jsxs)(B.Fragment,{children:[T?(0,B.jsxs)(`span`,{className:`act-big act-wait`,children:[A,` `,(0,B.jsx)(`span`,{className:`dim act-sm`,children:A===1?`session`:`sessions`})]}):null,(0,B.jsx)(`p`,{className:`dim act-sm`,children:T?`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,B.jsx)(`p`,{className:`dim act-sm`,children:`The sessions could not be read.`})]})]}),(0,B.jsxs)(`div`,{className:`row wrap gap-8 act-filters`,children:[(0,B.jsx)(`div`,{role:`group`,"aria-label":`Filter`,className:`row wrap gap-8`,children:fe.map(([e,t])=>(0,B.jsxs)(`button`,{type:`button`,className:o.f===e?`chip-f on`:`chip-f`,"aria-pressed":o.f===e,onClick:()=>v({f:e}),children:[t,e===`needs`&&A>0?(0,B.jsxs)(`span`,{className:`mono`,children:[` `,A]}):null]},e))}),Z(`host`,`Host`,M),Z(`project`,`Project`,N),(0,B.jsx)(te,{"aria-label":`Live sessions view`,children:[[`list`,`List`],[`garden`,`Garden`]].map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,className:o.v===e?`on`:``,"aria-pressed":o.v===e,onClick:()=>v({v:e}),children:t},e))})]}),P&&o.f!==`needs`&&(0,B.jsxs)(`p`,{className:`dim act-sm`,children:[`Runs and gate asks carry no `,P,`; showing sessions only.`]}),R&&(e?!T&&o.f!==`needs`?null:L.length===0?o.f===`needs`?(0,B.jsx)(S,{title:`Nothing waits on you`}):(0,B.jsx)(S,{title:`No active sessions`,children:`Start an agent session and it appears here.`}):o.v===`garden`?(0,B.jsx)(se,{sessions:L,collisions:e.collisions}):(0,B.jsx)(`div`,{className:`stack gap-12 act-live`,ref:k,children:L.map(e=>(0,B.jsx)(`div`,{"data-flip":F(e),children:(0,B.jsx)(le,{s:e})},F(e)))}):(0,B.jsx)(y,{label:`Reading live sessions…`})),V.length>0&&(0,B.jsxs)(`section`,{className:`stack gap-12 act-live act-ended`,"aria-labelledby":`act-ended-h`,children:[(0,B.jsx)(`h2`,{id:`act-ended-h`,className:`act-lbl`,children:`Recently ended`}),H.map(e=>(0,B.jsx)(`div`,{children:(0,B.jsx)(le,{s:e})},F(e))),V.length>xe&&(0,B.jsx)(`button`,{type:`button`,className:`btn ghost sm`,"aria-expanded":d,onClick:()=>p(e=>!e),children:d?`Show fewer`:`Show all ${V.length}`})]}),o.f!==`needs`&&(0,B.jsx)(`section`,{"aria-label":`Feed`,className:`stack gap-16 act-feed`,ref:Y,children:q.map(e=>(0,B.jsxs)(`section`,{className:`card act-day`,children:[(0,B.jsxs)(`h3`,{className:`act-day-h`,children:[(0,B.jsx)(`span`,{children:e.title}),(0,B.jsx)(`span`,{className:`mono dim`,children:e.sum})]}),(0,B.jsxs)(`ul`,{className:`act-rows`,children:[e.runs.map(e=>(0,B.jsx)(ye,{job:e,longest:J},e.id)),e.gate&&(0,B.jsx)(be,{gate:e.gate})]})]},e.key))})]})}export{Ce as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-C1iE8mnY.js";import{t as r}from"./api-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-C1iE8mnY.js";import{t as r}from"./api-C8nMUU1i.js";import{H as i,M as a,O as o,St as s,T as c,_t as l,et as u,k as d,tt as f}from"./index-BhT94v2q.js";import{a as p,d as m,f as h,i as g,l as _,o as v,r as y,t as b,v as x}from"./Bonsai-Bry-kOFb.js";import{t as S}from"./EmptyState-CY5Pm2xy.js";import{n as C,t as w}from"./usePoll-D5c_qIFZ.js";var T=e(t(),1),E=n();function D(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 O({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(`${d(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,E.jsxs)(`div`,{className:`row gap-10 act-line`,children:[(0,E.jsx)(`span`,{className:`badge act-who ${t?``:`acc`}`,children:t?`you`:`agent`}),(0,E.jsxs)(`div`,{className:`act-grow act-sm`,children:[!t&&(0,E.jsx)(`span`,{className:`feed-dot act-inline-dot ${D(e)||`acc`}`}),e.kind===`thinking`&&(0,E.jsx)(`span`,{className:`dim`,children:`thinking: `}),r?(0,E.jsx)(`span`,{className:`dim`,children:i}):t?i:(0,E.jsx)(`b`,{children:i}),e.error&&(0,E.jsxs)(`span`,{className:`dim`,children:[`: `,e.error]})]}),n.length>0&&(0,E.jsx)(`span`,{className:`dim mono act-xs act-fixed`,children:n.join(` · `)}),e.t?(0,E.jsx)(`time`,{className:`mono dim act-xs act-fixed`,dateTime:new Date(e.t).toISOString(),title:`${s(e.t/1e3)} ago`,children:new Date(e.t).toTimeString().slice(0,8)}):null]})}function k({turns:e}){return!e||e.length===0?(0,E.jsx)(`div`,{className:`dim act-sm`,children:`No conversation captured yet.`}):(0,E.jsx)(`div`,{className:`stack gap-12`,children:e.map((e,t)=>{let n=e.role===`user`;return(0,E.jsxs)(`div`,{className:`row gap-10 act-line`,children:[(0,E.jsx)(`span`,{className:`badge act-who ${n?``:`acc`}`,children:n?`you`:`agent`}),(0,E.jsx)(`div`,{className:`act-min act-sm${n?``:` muted`}`,children:e.text})]},t)})})}var A=5;function j({s:e}){let[t]=(0,T.useState)(v),[n,r]=(0,T.useState)(null),i=!!e.ended,o=i?{...e,status:a(e)?`busy`:e.status,error:null}:e,s=x(o,t),c=(0,T.useMemo)(()=>h(o,{sakura:t}),[s]),l=(0,T.useCallback)(e=>r(e),[]),u=_(e),d=Number(e.turns)||0,f=Number(e.compactions)||0,m=[`${d} turn${d===1?``:`s`}`,`context ${u==null?`unknown`:`${Math.round(u*100)} %`}`,`${f} compaction${f===1?``:`s`}`,`sub-agents: ${c.pads.filter(e=>e.key!=null).length} ${i?`unfinished`:`running`}, ${c.fallen.length} finished`].join(` · `),S=n==null?null:c.pads[n];return(0,E.jsxs)(`div`,{className:`card pad-md act-mt gd-detail${!i&&a(e)?` gd-needs`:``}`,children:[(0,E.jsx)(`div`,{role:`group`,tabIndex:0,"aria-label":`Bonsai pads, arrow keys walk them`,onKeyDown:e=>g(e,c.pads.length,n,l),children:(0,E.jsx)(y,{t:c,pad:n,swaying:!i&&e.status!==`idle`,onPad:l,px:A,label:`Bonsai of this session${i?`, ended`:``}: ${m}`})}),(0,E.jsxs)(`div`,{className:`stack gap-8 act-min`,children:[i&&(0,E.jsx)(`span`,{className:`dim act-xs`,children:`ended`}),(0,E.jsx)(`div`,{className:`dim act-sm`,children:m}),(0,E.jsx)(`span`,{className:`sr-only`,role:`status`,children:p(S)}),S?(0,E.jsx)(b,{pad:S}):(0,E.jsx)(`div`,{className:`dim act-xs`,children:`Hover or tap a pad, or use the arrow keys, for its files.`})]})]})}function M({sid:e}){let{sid:t,install:n}=m(e,window.location.hash),[a,d]=(0,T.useState)(null),[p,h]=(0,T.useState)(``),[g,_]=(0,T.useState)(!1),[v,y]=(0,T.useState)(!1),b=(0,T.useId)();C(e=>g?void 0:r.activityDetail(t,n).then(t=>{e()&&(d(w(t)),h(``),_(!1))},t=>{e()&&(t.status===404?_(!0):h(t.message))}),2e3,[t,g]);let x=(0,E.jsxs)(`a`,{className:`btn ghost sm act-back`,href:`#/activity`,children:[(0,E.jsx)(l,{name:`arrow`}),` Activity`]});if(g)return(0,E.jsxs)(`div`,{className:`page-fill`,children:[x,(0,E.jsx)(S,{title:`Session ended`,action:(0,E.jsx)(`a`,{href:`#/activity`,children:`Back to Activity`}),children:`It's no longer live.`})]});if(!a)return(0,E.jsxs)(`div`,{className:`page-fill`,children:[x,p?(0,E.jsx)(u,{error:p}):(0,E.jsx)(f,{label:`Loading session…`})]});let D=a.session,A=D.files,M=D.todos,N=!!(A&&A.items&&A.items.length>0),P=!!(M&&M.items&&M.items.length>0),F=a.conversation||[],I=a.timeline||[],L=[...F.filter(e=>e.role===`user`).map(e=>({who:`you`,text:e.text,t:e.t||0})),...I.map(e=>({...e,who:`agent`}))].sort((e,t)=>(e.t||0)-(t.t||0));return(0,E.jsxs)(`div`,{className:`page-fill`,children:[x,(0,E.jsx)(i,{title:D.title||o(D.cwd)||D.session_id,sub:D.cwd?(0,E.jsx)(`span`,{className:`mono act-cwd`,title:D.cwd,children:D.cwd}):null}),p&&(0,E.jsx)(`div`,{className:`act-gap`,children:(0,E.jsx)(u,{error:p})}),(0,E.jsxs)(`div`,{className:`card pad-md`,children:[(0,E.jsx)(c,{s:D}),(0,E.jsxs)(`div`,{className:`dim act-updated`,children:[`updated `,s(D.updated_at),` ago`]})]}),(0,E.jsx)(j,{s:D}),(N||P)&&(0,E.jsxs)(`div`,{className:`grid gap-12 act-panels${N&&P?` two`:``}`,children:[N&&(0,E.jsxs)(`div`,{className:`card pad-md`,children:[(0,E.jsx)(`div`,{className:`card-head`,children:(0,E.jsxs)(`h2`,{children:[`Files touched `,(0,E.jsxs)(`span`,{className:`dim`,children:[`(`,A.count,`)`]})]})}),(0,E.jsx)(`div`,{className:`stack act-list`,children:A.items.map(e=>(0,E.jsxs)(`div`,{className:`row between gap-12 act-sm`,children:[(0,E.jsx)(`span`,{className:`mono act-ell act-grow`,title:e.file,children:e.file}),(0,E.jsxs)(`span`,{className:`act-fixed`,children:[(0,E.jsxs)(`span`,{className:`t-good`,children:[`+`,e.additions]}),` `,(0,E.jsxs)(`span`,{className:`t-bad`,children:[`−`,e.deletions]})]})]},e.file))})]}),P&&(0,E.jsxs)(`div`,{className:`card pad-md`,children:[(0,E.jsx)(`div`,{className:`card-head`,children:(0,E.jsxs)(`h2`,{children:[`Plan`,` `,(0,E.jsxs)(`span`,{className:`dim`,children:[`(`,M.done,`/`,M.total,`)`]})]})}),(0,E.jsx)(`div`,{className:`stack act-list`,children:M.items.map((e,t)=>(0,E.jsxs)(`div`,{className:`row gap-8 act-sm`,children:[(0,E.jsx)(`span`,{className:`feed-dot ${e.status===`completed`?`ok`:e.status===`in_progress`?`acc`:``}`}),(0,E.jsx)(`span`,{className:e.status===`completed`?`act-done`:void 0,children:e.content})]},t))})]})]}),(0,E.jsxs)(`div`,{className:`card pad-md act-mt`,children:[(0,E.jsxs)(`div`,{className:`card-head act-tl-head`,children:[(0,E.jsx)(`h2`,{children:`Timeline`}),I.length>0&&(0,E.jsx)(`button`,{className:`btn ghost sm`,"aria-expanded":v,"aria-controls":b,onClick:()=>y(e=>!e),children:v?`Show conversation`:`Show full stream (${L.length})`})]}),(0,E.jsx)(`div`,{id:b,children:v?(0,E.jsx)(`div`,{className:`stack gap-12`,children:L.map((e,t)=>(0,E.jsx)(O,{rec:e},t))}):(0,E.jsx)(k,{turns:F})})]})]})}export{j as SessionTree,M as default};
|