@hexdecimal16/nexo 0.4.14 → 0.4.16

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.
@@ -234,12 +234,31 @@ export function parseReply(raw, tools) {
234
234
  for (const c of obj.tool_calls) {
235
235
  if (typeof c?.name !== "string" || !known.has(c.name))
236
236
  return undefined;
237
- const args = typeof c.arguments === "object" && c.arguments !== null && !Array.isArray(c.arguments) ? c.arguments : {};
237
+ const args = callArguments(c.arguments);
238
+ // Arguments that are not an object would reach the tool as {} and fail validation ("command: missing");
239
+ // treating the reply as unusable sends it through the format-failure retry instead.
240
+ if (!args)
241
+ return undefined;
238
242
  calls.push({ type: "toolCall", id: toolCallId(), name: c.name, arguments: args });
239
243
  }
240
244
  }
241
245
  return { text: typeof obj.text === "string" ? obj.text : "", calls };
242
246
  }
247
+ /** A tool call's arguments as an object: absent means none, a JSON-encoded string is decoded, anything else is unusable. */
248
+ function callArguments(value) {
249
+ if (value === undefined || value === null)
250
+ return {};
251
+ let parsed = value;
252
+ if (typeof value === "string") {
253
+ try {
254
+ parsed = JSON.parse(value);
255
+ }
256
+ catch {
257
+ return undefined;
258
+ }
259
+ }
260
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : undefined;
261
+ }
243
262
  function effortFlag(reasoning) {
244
263
  if (!reasoning)
245
264
  return undefined;
@@ -1,10 +1,12 @@
1
1
  import { builtinModels } from "@earendil-works/pi-ai/providers/all";
2
+ import { agyPProvider } from "./agy-p.js";
2
3
  import { claudePProvider } from "./claude-p.js";
3
4
  import { codexPProvider } from "./codex-p.js";
4
5
  import { kiroPProvider } from "./kiro-p.js";
5
- /** pi-ai's built-in providers plus nexo's own (`claude-p`, `codex-p`, `kiro-p`). */
6
+ /** pi-ai's built-in providers plus nexo's own (`agy-p`, `claude-p`, `codex-p`, `kiro-p`). */
6
7
  export function nexoModels() {
7
8
  const models = builtinModels();
9
+ models.setProvider(agyPProvider());
8
10
  models.setProvider(claudePProvider());
9
11
  models.setProvider(codexPProvider());
10
12
  models.setProvider(kiroPProvider());
@@ -3,6 +3,7 @@ import { isSearchProvider, SEARCH_PROVIDER_IDS, SEARCH_PROVIDERS } from "../../.
3
3
  import { createMutableRedactor, createRedactor, createSecretSet, containsSecret, MIN_SECRET_LENGTH, NexoError, toErrorPayload, } from "../../../telemetry/src/index.js";
4
4
  import { configErrors, deepMerge, loadConfig } from "../config/load.js";
5
5
  import { EDITABLE_SETTINGS, findSetting, mergedLayers, parseSettingInput, readConfigLayers, resetSetting, settingView, writeSetting, } from "./config-edit.js";
6
+ import { AGY_P_PROVIDER } from "../providers/agy-p.js";
6
7
  import { CLAUDE_P_PROVIDER } from "../providers/claude-p.js";
7
8
  import { CODEX_P_PROVIDER } from "../providers/codex-p.js";
8
9
  import { KIRO_P_PROVIDER } from "../providers/kiro-p.js";
@@ -143,8 +144,8 @@ export function createSettings(options) {
143
144
  const purpose = isSearchProvider(provider) ? "search" : isBrowserProfileKey(provider) ? "browser" : "model";
144
145
  if (optionKeys.has(provider))
145
146
  return { provider, purpose, state: "option", envVar: null, last4: null, inFile };
146
- // claude-p, codex-p and kiro-p run a local CLI that brings its own login: ambient credentials, like AWS or Google ADC.
147
- if (provider === CLAUDE_P_PROVIDER || provider === CODEX_P_PROVIDER || provider === KIRO_P_PROVIDER)
147
+ // agy-p, claude-p, codex-p and kiro-p run a local CLI that brings its own login: ambient credentials, like AWS or Google ADC.
148
+ if (provider === AGY_P_PROVIDER || provider === CLAUDE_P_PROVIDER || provider === CODEX_P_PROVIDER || provider === KIRO_P_PROVIDER)
148
149
  return { provider, purpose, state: "env", envVar: null, last4: null, inFile };
149
150
  if (envKey(provider) !== undefined)
150
151
  return { provider, purpose, state: "env", envVar: envVarOf(provider), last4: null, inFile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexdecimal16/nexo",
3
- "version": "0.4.14",
3
+ "version": "0.4.16",
4
4
  "description": "nexo agent engine",
5
5
  "license": "PolyForm-Noncommercial-1.0.0",
6
6
  "repository": {
@@ -0,0 +1,27 @@
1
+ -- nexo:foreign-keys-off
2
+ -- Project-scoped memories (scope 'project:<hash>', from projectScope) were accepted by the store but rejected by the
3
+ -- CHECK from 006, so every curator delta holding one failed as a whole. SQLite cannot widen a CHECK in place, so the
4
+ -- table is rebuilt. Rowids are copied explicitly because memories_fts is keyed by the memories rowid.
5
+ -- memory_embeddings references memories(id), so the runner switches foreign keys off and runs foreign_key_check.
6
+ CREATE TABLE memories_new (
7
+ id TEXT PRIMARY KEY,
8
+ scope TEXT NOT NULL CHECK (scope IN ('user', 'global') OR (scope GLOB 'skill:?*') OR (scope GLOB 'project:?*')),
9
+ type TEXT NOT NULL CHECK (type IN ('fact', 'preference', 'lesson', 'workflow')),
10
+ content TEXT NOT NULL,
11
+ importance REAL NOT NULL CHECK (importance >= 0 AND importance <= 1),
12
+ source TEXT NOT NULL CHECK (source IN ('ace', 'human', 'user')),
13
+ source_run_id TEXT,
14
+ superseded_by TEXT REFERENCES memories(id),
15
+ retired_at TEXT,
16
+ created_at TEXT NOT NULL,
17
+ last_used_at TEXT
18
+ );
19
+ INSERT INTO memories_new (rowid, id, scope, type, content, importance, source, source_run_id, superseded_by, retired_at, created_at, last_used_at)
20
+ SELECT rowid, id, scope, type, content, importance, source, source_run_id, superseded_by, retired_at, created_at, last_used_at FROM memories;
21
+ DROP TABLE memories;
22
+ ALTER TABLE memories_new RENAME TO memories;
23
+ CREATE INDEX memories_live ON memories(scope) WHERE superseded_by IS NULL AND retired_at IS NULL;
24
+ CREATE INDEX memories_source_run ON memories(source_run_id);
25
+ CREATE TRIGGER memories_fts_insert AFTER INSERT ON memories BEGIN
26
+ INSERT INTO memories_fts (rowid, content) VALUES (new.rowid, new.content);
27
+ END;
@@ -12,9 +12,9 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html" aria-current="page">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Home</a><a href="/runs.html">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
16
16
  <main id="main" tabindex="-1">
17
- <p class="muted"><a href="/home.html">&larr; Home</a></p>
17
+ <p class="muted"><a href="/">&larr; Home</a></p>
18
18
  <h1 id="area-title">Area</h1>
19
19
  <div id="error"></div>
20
20
  <div id="area"></div>
@@ -12,7 +12,7 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Home</a><a href="/runs.html">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
16
16
  <main id="main" tabindex="-1">
17
17
  <h1>Cost</h1>
18
18
  <form id="cost-form" class="filters">
@@ -4,37 +4,20 @@
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <meta name="nexo-token" content="{{NEXO_TOKEN}}">
7
- <title>nexo · runs</title>
7
+ <title>nexo · home</title>
8
8
  <link rel="stylesheet" href="/style.css">
9
9
  <script type="module" src="/lib/theme.ts"></script>
10
10
  <script type="module" src="/pages/companion.ts"></script>
11
- <script type="module" src="/pages/runs.ts"></script>
11
+ <script type="module" src="/pages/home.ts"></script>
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Home</a><a href="/runs.html">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
16
16
  <main id="main" tabindex="-1">
17
- <h1>Runs</h1>
18
- <div id="session-filter"></div>
19
- <div class="tabs" role="tablist">
20
- <button type="button" role="tab" data-tab="all" aria-selected="true">All runs</button>
21
- <button type="button" role="tab" data-tab="review" aria-selected="false">Review queue</button>
22
- </div>
23
- <form id="filters" class="filters">
24
- <label>Status <select name="status" id="status-filter"><option value="">any</option></select></label>
25
- <label>Skill <input name="skill" type="text" placeholder="any"></label>
26
- <label>Since <input name="since" type="date"></label>
27
- <label>Scored <select name="scored"><option value="">any</option><option value="true">scored</option><option value="false">not scored</option></select></label>
28
- <button type="submit">Apply</button>
29
- </form>
17
+ <div class="home-head"><h1 id="greeting">Home</h1><p class="home-date" id="home-date"></p></div>
30
18
  <div id="error"></div>
31
- <div class="table-wrap">
32
- <table class="runs">
33
- <thead><tr><th>Started (UTC)</th><th>Instruction</th><th>Skill</th><th>Status</th><th>Model</th><th class="num">Duration</th><th class="num">Cost</th><th>Score</th><th>Verdict</th></tr></thead>
34
- <tbody id="runs-body"></tbody>
35
- </table>
36
- </div>
37
- <div id="pager"></div>
19
+ <input id="home-search" class="home-search" type="search" placeholder="Search areas, wikis, recent activity and decisions" aria-label="Search">
20
+ <div id="home"><p class="muted">Loading…</p></div>
38
21
  </main>
39
22
  </body>
40
23
  </html>
@@ -12,7 +12,7 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Home</a><a href="/runs.html">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
16
16
  <main id="main" tabindex="-1">
17
17
  <h1>Judge calibration</h1>
18
18
  <div id="error"></div>
@@ -12,7 +12,7 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Home</a><a href="/runs.html">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
16
16
  <main id="main" tabindex="-1">
17
17
  <h1>Learning</h1>
18
18
  <div id="error"></div>
@@ -7,7 +7,7 @@ export function runLink(id: string): string {
7
7
 
8
8
  /** The runs list filtered to one session's turns. */
9
9
  export function sessionLink(sessionId: string): string {
10
- return `/?session=${encodeURIComponent(sessionId)}`;
10
+ return `/runs.html?session=${encodeURIComponent(sessionId)}`;
11
11
  }
12
12
 
13
13
  const STATUS_GLYPH = new Map([
@@ -29,7 +29,7 @@ export function renderRunHeader(detail: RunDetailResponse, nowMs: number): SafeH
29
29
  const { run, runJson } = detail;
30
30
  const model = runJson?.model;
31
31
  return html`<header class="run-header ${stateClass(run.status)}">
32
- <div class="crumbs">${run.parentRunId ? html`<a href="${runLink(run.parentRunId)}">← parent run ${shortId(run.parentRunId)}</a>` : html`<a href="/">← runs</a>`}</div>
32
+ <div class="crumbs">${run.parentRunId ? html`<a href="${runLink(run.parentRunId)}">← parent run ${shortId(run.parentRunId)}</a>` : html`<a href="/runs.html">← runs</a>`}</div>
33
33
  <h1>${truncate(run.instruction.split("\n")[0] ?? "", 200)}</h1>
34
34
  <div class="facts">
35
35
  ${statusBadge(run.status)} ${verdictBadge(run.verdict)}
@@ -68,7 +68,7 @@ export function renderRunRows(runs: RunSummary[], nowMs: number): SafeHtml {
68
68
  /** The active session filter, with a link back to all runs; empty without one. */
69
69
  export function renderSessionFilter(sessionId: string, title: string | null): SafeHtml {
70
70
  if (!sessionId) return html``;
71
- return html`<p class="session-filter">Turns of session <a class="mono" href="${sessionLink(sessionId)}">${title || sessionId}</a> <span class="muted mono">${sessionId}</span> · <a href="/">show all runs</a></p>`;
71
+ return html`<p class="session-filter">Turns of session <a class="mono" href="${sessionLink(sessionId)}">${title || sessionId}</a> <span class="muted mono">${sessionId}</span> · <a href="/runs.html">show all runs</a></p>`;
72
72
  }
73
73
 
74
74
  /** On the default view (all tabs, no session filter) chat turns are not listed; a muted line points to the Sessions page. */
@@ -20,7 +20,7 @@ function apply(choice: Choice): void {
20
20
 
21
21
  function markActive(nav: Element): void {
22
22
  const path = location.pathname;
23
- const target = path === '/' || path === '/index.html' || path === '/run.html' ? '/' : path;
23
+ const target = path === '/index.html' ? '/' : path === '/run.html' ? '/runs.html' : path;
24
24
  for (const a of nav.querySelectorAll('a:not(.brand)')) {
25
25
  if (a.getAttribute('href') === target) a.setAttribute('aria-current', 'page');
26
26
  }
@@ -12,7 +12,7 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Home</a><a href="/runs.html">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
16
16
  <main id="main" tabindex="-1">
17
17
  <h1>Optimization</h1>
18
18
  <div id="error"></div>
@@ -12,9 +12,9 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Home</a><a href="/runs.html">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
16
16
  <main id="main" tabindex="-1">
17
- <p class="muted" id="page-crumbs"><a href="/home.html">Home</a></p>
17
+ <p class="muted" id="page-crumbs"><a href="/">Home</a></p>
18
18
  <h1 id="page-title">Page</h1>
19
19
  <p class="muted" id="page-meta"></p>
20
20
  <div id="error"></div>
@@ -27,7 +27,7 @@ function render(d: Home, id: string): void {
27
27
  const a = d.areas.find((x) => x.id === id);
28
28
  if (!a) {
29
29
  title.textContent = "Area not found";
30
- box.innerHTML = html`<p class="muted">No active area "${id}". <a href="/home.html">Back to Home</a>.</p>`.value;
30
+ box.innerHTML = html`<p class="muted">No active area "${id}". <a href="/">Back to Home</a>.</p>`.value;
31
31
  return;
32
32
  }
33
33
  title.textContent = a.name;
@@ -38,11 +38,11 @@ function render(d: Home, id: string): void {
38
38
  const pages = a.wikis.reduce((n, w) => n + w.pageCount, 0);
39
39
  const wikis = a.wikis.map((w) => html`<a class="area-card" href="/page.html?path=${encodeURIComponent(`${w.path}/index.html`)}"><strong>${w.name}</strong><span class="muted">${String(w.pageCount)} pages</span>${w.summary ? html`<span class="area-card-text">${w.summary}</span>` : ""}</a>`);
40
40
  const timeline = feed.map((f) => {
41
- const link = f.sessionId ? html`<a href="/?session=${encodeURIComponent(f.sessionId)}">session</a>` : html`<a href="/run.html?id=${encodeURIComponent(f.runId)}">run</a>`;
41
+ const link = f.sessionId ? html`<a href="/runs.html?session=${encodeURIComponent(f.sessionId)}">session</a>` : html`<a href="/run.html?id=${encodeURIComponent(f.runId)}">run</a>`;
42
42
  return html`<li><time>${formatTime(f.at)}${f.wiki ? ` · ${f.wiki}` : ""}</time>${f.text}${f.verified ? "" : html` <span class="home-tag">unverified</span>`} ${pageLinks(f)} ${link}</li>`;
43
43
  });
44
44
  const decisionCards = decisions.map((x) => html`<div class="area-decision"><strong>${x.choice}</strong>${x.reason ? html`<span class="muted">Because ${x.reason}</span>` : ""}<time class="muted">${formatTime(x.at)}</time></div>`);
45
- const rows = sessions.map((s) => html`<tr><td><a href="/?session=${encodeURIComponent(s.id)}">${s.title || s.id}</a></td><td class="mono muted">${s.cwd}</td><td class="muted">${formatTime(s.updatedAt)}</td></tr>`);
45
+ const rows = sessions.map((s) => html`<tr><td><a href="/runs.html?session=${encodeURIComponent(s.id)}">${s.title || s.id}</a></td><td class="mono muted">${s.cwd}</td><td class="muted">${formatTime(s.updatedAt)}</td></tr>`);
46
46
  box.innerHTML = html`<p class="home-note">${a.scope}</p>
47
47
  <div class="area-stats">${stat(a.wikis.length, "wikis")}${stat(pages, "pages")}${stat(a.recent, "filed this week")}${stat(decisions.length, "decisions")}</div>
48
48
  <section><h2>Wikis</h2>${wikis.length > 0 ? html`<div class="area-grid">${wikis}</div>` : empty("No wikis in this area yet.")}</section>
@@ -219,7 +219,7 @@ function render(state: CompanionState, reviewCount: number): void {
219
219
  const first = state.running[0];
220
220
  if (first) action(state.running.length > 1 ? `Watch the oldest of ${state.running.length} running runs` : "Watch the running run", runLink(first.id));
221
221
  if (state.lastFailed) action("Open the last failure", runLink(state.lastFailed.id));
222
- if (reviewCount > 0) action(`Review queue (${reviewCount})`, "/?tab=review");
222
+ if (reviewCount > 0) action(`Review queue (${reviewCount})`, "/runs.html?tab=review");
223
223
  if (state.latest && state.latest !== state.lastFailed) action("Open the latest run", runLink(state.latest.id));
224
224
  action("Where the money went", "/cost.html");
225
225
  }
@@ -1,5 +1,7 @@
1
- import { renderError } from "../lib/common-view.ts";
2
- import { formatTime } from "../lib/format.ts";
1
+ // Home: what is running and what needs you, the life areas as tiles, and one timeline of filed work and decisions.
2
+ import type { RunListResponse } from "../lib/api-types.ts";
3
+ import { renderError, runLink, sessionLink } from "../lib/common-view.ts";
4
+ import { formatTime, truncate } from "../lib/format.ts";
3
5
  import { html, type SafeHtml } from "../lib/html.ts";
4
6
  import { asErrorBody, el, getJson } from "./api.ts";
5
7
 
@@ -9,14 +11,53 @@ interface HomeFeedItem { at: string; text: string; areaId: string | null; wiki:
9
11
  interface HomeDecision { at: string; choice: string; reason: string; areaId: string | null; wiki: string | null; sessionId: string | null; runId: string }
10
12
  interface HomeSession { id: string; title: string; cwd: string; updatedAt: string; areaId: string | null }
11
13
  interface Home { areas: HomeArea[]; proposed: { id: string; name: string }[]; unsorted: number; feed: HomeFeedItem[]; decisions: HomeDecision[]; sessions: HomeSession[] }
14
+ interface ReviewItem { runId: string; instruction: string; status: string; score: number | null; startedAt: string }
15
+ interface Entry { at: string; kind: "done" | "decision"; body: SafeHtml; meta: SafeHtml; text: string }
12
16
 
17
+ const HUES = 6;
13
18
  const box = el<HTMLDivElement>("#home");
14
19
  const errorBox = el<HTMLDivElement>("#error");
15
20
  const search = el<HTMLInputElement>("#home-search");
21
+ const greeting = el<HTMLHeadingElement>("#greeting");
22
+ const dateLine = el<HTMLParagraphElement>("#home-date");
16
23
  let data: Home | null = null;
24
+ let running: RunListResponse["runs"] = [];
25
+ let review: ReviewItem[] = [];
17
26
 
18
27
  const hit = (q: string, ...parts: (string | null | undefined)[]) => !q || parts.some((p) => (p ?? "").toLowerCase().includes(q));
19
28
  const areaName = (id: string | null) => data?.areas.find((a) => a.id === id)?.name ?? "unsorted";
29
+ const hueOf = (id: string | null): string => {
30
+ const i = data ? data.areas.findIndex((a) => a.id === id) : -1;
31
+ return i < 0 ? "none" : String(i % HUES);
32
+ };
33
+ const chip = (id: string | null): SafeHtml => html`<span class="chip" data-hue="${hueOf(id)}">${areaName(id)}</span>`;
34
+ const dayKey = (d: Date): string => `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;
35
+ const clock = (iso: string): string => new Date(iso).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
36
+
37
+ function dayLabel(d: Date): string {
38
+ const today = new Date();
39
+ const yesterday = new Date();
40
+ yesterday.setDate(today.getDate() - 1);
41
+ if (dayKey(d) === dayKey(today)) return "Today";
42
+ if (dayKey(d) === dayKey(yesterday)) return "Yesterday";
43
+ return d.toLocaleDateString(undefined, { weekday: "long", day: "numeric", month: "short" });
44
+ }
45
+
46
+ function ago(iso: string): string {
47
+ const m = Math.round((Date.now() - Date.parse(iso)) / 60_000);
48
+ if (!(m >= 0)) return formatTime(iso);
49
+ if (m < 1) return "just now";
50
+ if (m < 60) return `${m}m ago`;
51
+ const h = Math.round(m / 60);
52
+ return h < 24 ? `${h}h ago` : `${Math.round(h / 24)}d ago`;
53
+ }
54
+
55
+ function header(): void {
56
+ const now = new Date();
57
+ const h = now.getHours();
58
+ greeting.textContent = h < 12 ? "Good morning" : h < 18 ? "Good afternoon" : "Good evening";
59
+ dateLine.textContent = now.toLocaleDateString(undefined, { weekday: "long", day: "numeric", month: "long", year: "numeric" });
60
+ }
20
61
 
21
62
  function pageLinks(f: { pages?: string[]; wiki: string | null; areaId: string | null }): SafeHtml {
22
63
  const pages = (f.pages ?? []).filter((p) => p.endsWith(".html") && p.includes("/") && !p.includes(".."));
@@ -24,37 +65,66 @@ function pageLinks(f: { pages?: string[]; wiki: string | null; areaId: string |
24
65
  return f.wiki && f.areaId ? html`<a class="feed-page" href="/page.html?path=${encodeURIComponent(`${f.areaId}/${f.wiki}/index.html`)}">${f.wiki}</a>` : html``;
25
66
  }
26
67
 
27
- function feedItem(f: HomeFeedItem): SafeHtml {
28
- const link = f.sessionId ? html`<a href="/?session=${encodeURIComponent(f.sessionId)}">session</a>` : html`<a href="/run.html?id=${encodeURIComponent(f.runId)}">run</a>`;
29
- return html`<li><span class="muted mono">${formatTime(f.at)}</span> ${f.text}${f.verified ? "" : html` <span class="home-tag">unverified</span>`} <span class="muted">· ${areaName(f.areaId)}${f.wiki ? ` · ${f.wiki}` : ""}</span> ${pageLinks(f)} ${link}</li>`;
68
+ function panel(title: SafeHtml | string, count: number | null, state: string, items: SafeHtml[], empty: string): SafeHtml {
69
+ return html`<section class="today-panel" data-state="${state}"><h2><span>${title}</span>${count === null ? "" : html`<span class="today-count">${String(count)}</span>`}</h2>${items.length > 0 ? html`<ul class="today-list">${items}</ul>` : html`<p class="today-empty">${empty}</p>`}</section>`;
30
70
  }
31
71
 
32
- function list(items: SafeHtml[], empty: string): SafeHtml {
33
- return items.length > 0 ? html`<ul class="home-list">${items}</ul>` : html`<p class="muted">${empty}</p>`;
72
+ function strip(d: Home, q: string): SafeHtml {
73
+ const live = running.filter((r) => hit(q, r.instruction));
74
+ const runItems = live.slice(0, 4).map((r) => html`<li class="live"><a href="${runLink(r.id)}">${truncate(r.instruction, 90)}</a></li>`);
75
+ const proposals = d.proposed.length > 0 ? [html`<li>${String(d.proposed.length)} proposed area${d.proposed.length === 1 ? "" : "s"} to approve: ${d.proposed.map((p) => p.name).join(", ")}. Run <code>nexo areas list</code>.</li>`] : [];
76
+ const toReview = review.filter((r) => hit(q, r.instruction)).slice(0, 4).map((r) => html`<li><a href="${runLink(r.runId)}">${truncate(r.instruction, 80)}</a> <span class="muted">${r.score === null ? "unscored" : `score ${Math.round(r.score * 100) / 100}`}</span></li>`);
77
+ const needs = review.length + d.proposed.length;
78
+ const sessions = d.sessions.filter((s) => hit(q, s.title, s.cwd, areaName(s.areaId))).slice(0, 4).map((s) => html`<li><a href="${sessionLink(s.id)}">${truncate(s.title || s.id, 70)}</a> <span class="muted">${ago(s.updatedAt)}</span></li>`);
79
+ return html`${panel("Running", live.length, live.length > 0 ? "running" : "idle", runItems, "No runs in progress.")}${panel(html`<a href="/runs.html?tab=review">Needs you</a>`, needs, needs > 0 ? "attention" : "idle", [...proposals, ...toReview], "Nothing waiting for a verdict or an approval.")}${panel("Pick up", null, "idle", sessions, "No recent sessions.")}`;
34
80
  }
35
81
 
36
- function areaCard(a: HomeArea): SafeHtml {
37
- return html`<a class="home-area" href="/area.html?id=${encodeURIComponent(a.id)}"><strong>${a.name}</strong> <span class="muted">${String(a.recent)} this week · ${String(a.wikis.length)} wikis</span><span class="home-scope muted">${a.scope}</span></a>`;
82
+ function tile(d: Home, a: HomeArea): SafeHtml {
83
+ const week = Array.from({ length: 7 }, (_, k) => {
84
+ const day = new Date();
85
+ day.setDate(day.getDate() - (6 - k));
86
+ const key = dayKey(day);
87
+ return d.feed.filter((f) => f.areaId === a.id && dayKey(new Date(f.at)) === key).length;
88
+ });
89
+ const total = week.reduce((s, n) => s + n, 0);
90
+ const cells = week.map((n) => html`<span data-level="${String(Math.min(n, 3))}"></span>`);
91
+ const wikis = [...a.wikis].sort((x, y) => y.pageCount - x.pageCount).slice(0, 4).map((w) => html`<li><a href="/page.html?path=${encodeURIComponent(`${w.path}/index.html`)}">${w.name}</a></li>`);
92
+ return html`<article class="tile" data-hue="${hueOf(a.id)}"><h3><a href="/area.html?id=${encodeURIComponent(a.id)}">${a.name}</a></h3><p class="tile-scope">${a.scope}</p>${wikis.length > 0 ? html`<ul class="tile-wikis" aria-label="Wikis">${wikis}</ul>` : html`<p class="tile-scope">No wikis yet.</p>`}<div class="tile-foot"><span>${String(a.recent)} this week · ${String(a.wikis.length)} ${a.wikis.length === 1 ? "wiki" : "wikis"}</span><span class="week" role="img" aria-label="${`${total} tasks filed in the last 7 days`}" title="Tasks filed per day, last 7 days">${cells}</span></div></article>`;
93
+ }
94
+
95
+ function timeline(d: Home, q: string): SafeHtml {
96
+ const entries: Entry[] = [
97
+ ...d.feed.map((f): Entry => {
98
+ const link = f.sessionId ? html`<a href="${sessionLink(f.sessionId)}">session</a>` : html`<a href="${runLink(f.runId)}">run</a>`;
99
+ return { at: f.at, kind: "done", text: `${f.text} ${f.wiki ?? ""} ${areaName(f.areaId)}`, body: html`${f.text}${f.verified ? "" : html` <span class="home-tag">unverified</span>`}`, meta: html`${chip(f.areaId)} ${pageLinks(f)} ${link}` };
100
+ }),
101
+ ...d.decisions.map((x): Entry => ({ at: x.at, kind: "decision", text: `${x.choice} ${x.reason} ${x.wiki ?? ""} ${areaName(x.areaId)}`, body: html`<span class="tl-kind">Decided</span> <strong>${x.choice}</strong>${x.reason ? ` because ${x.reason}` : ""}`, meta: html`${chip(x.areaId)}${x.wiki ? html` <span>${x.wiki}</span>` : ""}` })),
102
+ ]
103
+ .filter((e) => hit(q, e.text))
104
+ .sort((a, b) => Date.parse(b.at) - Date.parse(a.at))
105
+ .slice(0, 40);
106
+ if (entries.length === 0) return html`<p class="muted">${q ? "Nothing in the timeline matches." : "No activity yet. Each finished task adds a line here after it is scored."}</p>`;
107
+ const days: { label: string; items: Entry[] }[] = [];
108
+ for (const e of entries) {
109
+ const label = dayLabel(new Date(e.at));
110
+ const last = days[days.length - 1];
111
+ if (last && last.label === label) last.items.push(e);
112
+ else days.push({ label, items: [e] });
113
+ }
114
+ return html`${days.map((g) => html`<div class="tl-day"><h3>${g.label}</h3><ol class="tl">${g.items.map((e) => html`<li data-kind="${e.kind}"><time datetime="${e.at}">${clock(e.at)}</time><div class="tl-body">${e.body}<div class="tl-meta">${e.meta}</div></div></li>`)}</ol></div>`)}`;
38
115
  }
39
116
 
40
117
  function render(): void {
41
118
  if (!data) return;
42
119
  const d = data;
43
120
  const q = search.value.trim().toLowerCase();
44
- const feed = d.feed.filter((f) => hit(q, f.text, f.wiki, areaName(f.areaId)));
45
- const decisions = d.decisions.filter((x) => hit(q, x.choice, x.reason, x.wiki, areaName(x.areaId)));
46
- const areas = d.areas.filter((a) => hit(q, a.name, a.scope, ...a.wikis.map((w) => `${w.name} ${w.summary ?? ""}`)) || (q !== "" && feed.some((f) => f.areaId === a.id)));
47
- const sessions = d.sessions.filter((s) => hit(q, s.title, s.cwd, areaName(s.areaId)));
48
- const pending = d.proposed.length > 0 ? html`<p class="home-note">${String(d.proposed.length)} proposed area(s) waiting for approval: ${d.proposed.map((p) => p.name).join(", ")}. Run <code>nexo areas list</code>.</p>` : "";
49
- const decisionItems = decisions.slice(0, 20).map((x) => html`<li><span class="muted mono">${formatTime(x.at)}</span> <strong>${x.choice}</strong>${x.reason ? html` <span class="muted">because ${x.reason}</span>` : ""} <span class="muted">· ${areaName(x.areaId)}</span></li>`);
50
- const sessionItems = sessions.map((s) => html`<li><a href="/?session=${encodeURIComponent(s.id)}">${s.title || s.id}</a> <span class="muted">${s.cwd} · ${formatTime(s.updatedAt)}</span></li>`);
51
- box.innerHTML = html`${pending}
52
- <section><h2>Areas</h2><div class="home-areas">${areas.map((a) => areaCard(a))}</div></section>
53
- <section><h2>Recent</h2>${list(feed.slice(0, 20).map(feedItem), "No activity yet. Each finished task adds a line here after it is scored.")}</section>
54
- <section><h2>Decisions</h2>${list(decisionItems, "No decisions recorded yet.")}</section>
55
- <section><h2>Recent sessions</h2>${list(sessionItems, "No sessions.")}</section>`.value;
121
+ const areas = d.areas.filter((a) => hit(q, a.name, a.scope, ...a.wikis.map((w) => `${w.name} ${w.summary ?? ""}`)) || (q !== "" && d.feed.some((f) => f.areaId === a.id && hit(q, f.text))));
122
+ box.innerHTML = html`<div class="today">${strip(d, q)}</div>
123
+ <section><h2>Areas</h2>${areas.length > 0 ? html`<div class="tiles">${areas.map((a) => tile(d, a))}</div>` : html`<p class="muted">No areas match.</p>`}</section>
124
+ <section class="tl-wrap"><h2>Timeline</h2>${timeline(d, q)}</section>`.value;
56
125
  }
57
126
 
127
+ header();
58
128
  search.addEventListener("input", render);
59
129
  getJson<Home>("/api/home")
60
130
  .then((d) => {
@@ -62,5 +132,18 @@ getJson<Home>("/api/home")
62
132
  render();
63
133
  })
64
134
  .catch((error) => {
135
+ box.innerHTML = "";
65
136
  errorBox.innerHTML = renderError(asErrorBody(error)).value;
66
137
  });
138
+ getJson<RunListResponse>("/api/runs?limit=25")
139
+ .then((r) => {
140
+ running = r.runs.filter((x) => x.status === "running");
141
+ render();
142
+ })
143
+ .catch(() => undefined);
144
+ getJson<{ items: ReviewItem[] }>("/api/review-queue?limit=5")
145
+ .then((r) => {
146
+ review = r.items;
147
+ render();
148
+ })
149
+ .catch(() => undefined);
@@ -49,7 +49,7 @@ function mount(page: HomePage): void {
49
49
 
50
50
  const path = new URLSearchParams(location.search).get("path") ?? "";
51
51
  const [area = "", folder = ""] = path.split("/");
52
- crumbs.replaceChildren(link("Home", "/home.html"), " / ", link(area, `/area.html?id=${encodeURIComponent(area)}`), " / ", link(folder, `/page.html?path=${encodeURIComponent(`${area}/${folder}/index.html`)}`));
52
+ crumbs.replaceChildren(link("Home", "/"), " / ", link(area, `/area.html?id=${encodeURIComponent(area)}`), " / ", link(folder, `/page.html?path=${encodeURIComponent(`${area}/${folder}/index.html`)}`));
53
53
  getJson<HomePage>(`/api/home/page?path=${encodeURIComponent(path)}`)
54
54
  .then((page) => {
55
55
  titleEl.textContent = page.title;
@@ -12,7 +12,7 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Home</a><a href="/runs.html">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
16
16
  <main id="main" tabindex="-1">
17
17
  <nav class="run-nav" aria-label="Run sections"><a href="#sec-timeline">Timeline</a><a href="#sec-spans">Spans</a><a href="#sec-scores">Scores</a><a href="#sec-memories">Memories</a><a href="#sec-subagents">Subagents</a><a href="#sec-files">Files</a><a href="#sec-review">Review</a></nav>
18
18
  <div id="error"></div>
@@ -0,0 +1,40 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta name="nexo-token" content="{{NEXO_TOKEN}}">
7
+ <title>nexo · runs</title>
8
+ <link rel="stylesheet" href="/style.css">
9
+ <script type="module" src="/lib/theme.ts"></script>
10
+ <script type="module" src="/pages/companion.ts"></script>
11
+ <script type="module" src="/pages/runs.ts"></script>
12
+ </head>
13
+ <body>
14
+ <a class="skip" href="#main">Skip to content</a>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Home</a><a href="/runs.html">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
16
+ <main id="main" tabindex="-1">
17
+ <h1>Runs</h1>
18
+ <div id="session-filter"></div>
19
+ <div class="tabs" role="tablist">
20
+ <button type="button" role="tab" data-tab="all" aria-selected="true">All runs</button>
21
+ <button type="button" role="tab" data-tab="review" aria-selected="false">Review queue</button>
22
+ </div>
23
+ <form id="filters" class="filters">
24
+ <label>Status <select name="status" id="status-filter"><option value="">any</option></select></label>
25
+ <label>Skill <input name="skill" type="text" placeholder="any"></label>
26
+ <label>Since <input name="since" type="date"></label>
27
+ <label>Scored <select name="scored"><option value="">any</option><option value="true">scored</option><option value="false">not scored</option></select></label>
28
+ <button type="submit">Apply</button>
29
+ </form>
30
+ <div id="error"></div>
31
+ <div class="table-wrap">
32
+ <table class="runs">
33
+ <thead><tr><th>Started (UTC)</th><th>Instruction</th><th>Skill</th><th>Status</th><th>Model</th><th class="num">Duration</th><th class="num">Cost</th><th>Score</th><th>Verdict</th></tr></thead>
34
+ <tbody id="runs-body"></tbody>
35
+ </table>
36
+ </div>
37
+ <div id="pager"></div>
38
+ </main>
39
+ </body>
40
+ </html>
@@ -12,7 +12,7 @@
12
12
  </head>
13
13
  <body>
14
14
  <a class="skip" href="#main">Skip to content</a>
15
- <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/home.html">Home</a><a href="/">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
15
+ <nav class="top" aria-label="Primary"><a href="/" class="brand">nexo</a><a href="/">Home</a><a href="/runs.html">Runs</a><a href="/sessions.html">Sessions</a><a href="/cost.html">Cost</a><a href="/learning.html">Learning</a><a href="/judge.html">Judge</a><a href="/optim.html">Optimization</a></nav>
16
16
  <main id="main" tabindex="-1">
17
17
  <h1>Sessions</h1>
18
18
  <p class="muted">Each chat message is a turn. Open a session to see its turns and review them.</p>