gcf-board 0.18.7 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>GCF board</title>
7
- <script type="module" crossorigin src="/assets/index-JQbwhhY5.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-BckF9M34.css">
7
+ <script type="module" crossorigin src="/assets/index-DHyOKvbO.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-BrufSede.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
@@ -201,10 +201,15 @@ export const kindOf = (tool) => KINDS[tool] ?? (/^mcp__/.test(tool) ? 'mcp' : 'o
201
201
  * | {type: 'cancel', request_id: string}
202
202
  * | {type: 'result', subtype?: string, total_cost_usd: number | null}
203
203
  * | {type: 'background', tasks: {id: string, description: string}[]}
204
+ * | {type: 'task', phase: 'start' | 'progress' | 'end', id: string, kind: string | null,
205
+ * agent: string | null, description: string | null, doing: string | null,
206
+ * prompt: string | null, calls: number | null, ms: number | null, status: string | null,
207
+ * summary: string | null, call: string | null, background: boolean}
204
208
  * | {type: 'compacted'}} Neutral
205
209
  * The events a session's work is read by, the same from any agent: what the main agent (or a
206
210
  * subagent, `sub`) said and called, the results, the operator's messages it took in, the
207
- * question and permission requests, a turn's end, the background tasks, a compaction.
211
+ * question and permission requests, a turn's end, the background tasks, each task's start,
212
+ * progress and end, a compaction.
208
213
  */
209
214
 
210
215
  /** @returns {Neutral[]} */
@@ -319,6 +324,9 @@ function systemEvents(e) {
319
324
  reason: String(e.message ?? ''),
320
325
  },
321
326
  ];
327
+ // An ambient task (claude's own, e.g. a memory pass) is none of the agent's work.
328
+ if (Object.hasOwn(TASK_PHASE, e.subtype))
329
+ return e.ambient === true ? [] : [taskOf(e, TASK_PHASE[e.subtype])];
322
330
  if (e.subtype !== 'background_tasks_changed') return [];
323
331
  const tasks = (Array.isArray(e.tasks) ? e.tasks : []).map((t) => ({
324
332
  id: String(t.task_id ?? t.id ?? ''),
@@ -328,6 +336,42 @@ function systemEvents(e) {
328
336
  return [{ type: 'background', tasks }];
329
337
  }
330
338
 
339
+ // A task of the session (a subagent, a background shell), claude 2.1.317: its start, its
340
+ // progress after each call it makes, its end.
341
+ const TASK_PHASE = { task_started: 'start', task_progress: 'progress', task_notification: 'end' };
342
+ // claude's task types, as the operator reads them.
343
+ const TASK_KIND = { local_agent: 'agent', local_bash: 'shell' };
344
+
345
+ /**
346
+ * One phase of a task: what it is (`kind`, the subagent's type `agent`), what it was started
347
+ * for (`description`, a subagent's `prompt`), what it does now (`doing`, from a progress), the
348
+ * calls it made and how long it took so far (`calls`, `ms`), how it ended (`status`, `summary`),
349
+ * the main agent's call that started it (`call`) and whether it runs in the background.
350
+ * @returns {Neutral}
351
+ */
352
+ function taskOf(e, phase) {
353
+ const str = (v) => (typeof v === 'string' && v ? v : null);
354
+ const num = (v) => (typeof v === 'number' ? v : null);
355
+
356
+ return {
357
+ type: 'task',
358
+ phase,
359
+ id: String(e.task_id ?? ''),
360
+ kind: TASK_KIND[e.task_type] ?? str(e.task_type),
361
+ agent: str(e.subagent_type),
362
+ // A progress's description says what the task does now, not what it was started for.
363
+ description: phase === 'progress' ? null : str(e.description),
364
+ doing: phase === 'progress' ? str(e.description) : null,
365
+ prompt: str(e.prompt),
366
+ calls: num(e.usage?.tool_uses),
367
+ ms: num(e.usage?.duration_ms),
368
+ status: str(e.status),
369
+ summary: str(e.summary),
370
+ call: str(e.tool_use_id),
371
+ background: e.is_backgrounded === true,
372
+ };
373
+ }
374
+
331
375
  /**
332
376
  * The account's usage-limit state as the stream gives it, raw: kept to learn its fields before
333
377
  * the board shows the quota (Board-PRD decision 17). Any other event gives nothing.
@@ -63,6 +63,11 @@ const PATH_GLOB = { '**/': '(?:.*/)?', '**': '.*', '*': '[^/]*' };
63
63
  // How much of a refused call the chat keeps: its command or file, and what it was for.
64
64
  const TITLE_MAX = 2000;
65
65
  const WHY_MAX = 500;
66
+ // A task's start keeps the head of what it was told, its end the head of its report; one
67
+ // progress in TASK_EVERY_MS per task reaches the chat (one comes after each call it makes).
68
+ const TASK_PROMPT_MAX = 1000;
69
+ const TASK_SUMMARY_MAX = 4000;
70
+ const TASK_EVERY_MS = 2000;
66
71
  const cut = (s, max) => (s.length > max ? `${s.slice(0, max)}…` : s);
67
72
 
68
73
  // A shell line's pieces: a quoted string whole (an unclosed one to the end), a separator, a run
@@ -730,6 +735,47 @@ function permit(c, e) {
730
735
  waitCards(c);
731
736
  }
732
737
 
738
+ /**
739
+ * Whether a task's event (`{phase, id}`) reaches the chat at `now`: one progress per
740
+ * TASK_EVERY_MS per task. Within the gap the last one waits, and `later` posts it as the gap
741
+ * ends: a long step after it keeps its words. Any event that goes now drops the one held, which
742
+ * is older: a late timer would post it over the newer (the audit of 2026-11-03).
743
+ * `c` holds `taskAt` and `taskHeld` (maps by task id).
744
+ */
745
+ export function taskGate(c, e, now, later) {
746
+ const held = c.taskHeld.get(e.id);
747
+ if (e.phase === 'progress') {
748
+ const left = (c.taskAt.get(e.id) ?? 0) + TASK_EVERY_MS - now;
749
+ if (left > 0) {
750
+ if (held) held.e = e;
751
+ else {
752
+ const h = { e, timer: setTimeout(later, left) };
753
+ h.timer.unref?.();
754
+ c.taskHeld.set(e.id, h);
755
+ }
756
+
757
+ return false;
758
+ }
759
+ c.taskAt.set(e.id, now);
760
+ }
761
+ if (held) {
762
+ clearTimeout(held.timer);
763
+ c.taskHeld.delete(e.id);
764
+ }
765
+ if (e.phase === 'end') c.taskAt.delete(e.id);
766
+
767
+ return true;
768
+ }
769
+
770
+ /** The progress a task held back, taken out once its gap is over: it is posted now. */
771
+ function flushed(c, id) {
772
+ const { e } = c.taskHeld.get(id);
773
+ c.taskHeld.delete(id);
774
+ c.taskAt.set(id, 0);
775
+
776
+ return e;
777
+ }
778
+
733
779
  /** Refuse a tool call (`{request_id, tool}`) by the engine's own word, with no card before it. */
734
780
  function refuse(c, { request_id: requestId, tool }, message, more = {}) {
735
781
  send(c, c.encode.deny(requestId, message));
@@ -792,6 +838,31 @@ const SEEN = {
792
838
  },
793
839
  cancel: (c, e) => dropCard(c, e.request_id),
794
840
  result: (c, e) => turnEnd(c, e),
841
+ // A subagent or a background shell: what it was started for, what it does, how it ended. A
842
+ // progress comes after each call it makes: one in TASK_EVERY_MS reaches the chat.
843
+ task: (c, e) => {
844
+ const later = () => {
845
+ const last = flushed(c, e.id);
846
+ if (!c.closed) SEEN.task(c, last);
847
+ };
848
+ if (!taskGate(c, e, Date.now(), later)) return;
849
+ const prompt = e.phase === 'start' ? e.prompt : null;
850
+ post(c, {
851
+ type: 'task',
852
+ phase: e.phase,
853
+ id: e.id,
854
+ ...(e.kind ? { kind: e.kind } : {}),
855
+ ...(e.agent ? { agent: e.agent } : {}),
856
+ ...(e.description ? { description: cut(e.description, WHY_MAX) } : {}),
857
+ ...(e.doing ? { doing: cut(e.doing, WHY_MAX) } : {}),
858
+ ...(prompt ? { prompt: cut(prompt, TASK_PROMPT_MAX) } : {}),
859
+ ...(e.calls !== null ? { calls: e.calls } : {}),
860
+ ...(e.ms !== null ? { ms: e.ms } : {}),
861
+ ...(e.status ? { status: e.status } : {}),
862
+ ...(e.summary ? { summary: cut(e.summary, TASK_SUMMARY_MAX) } : {}),
863
+ ...(e.background ? { background: true } : {}),
864
+ });
865
+ },
795
866
  // While they run, no answer is waited for; claude starts a turn itself as they end. Their end
796
867
  // with no new turn after the grace settles the session, so it is not held for good.
797
868
  background: (c, e) => {
@@ -911,6 +982,9 @@ function chatState(opts) {
911
982
  ...{ sent: 0, read: 0, cards: new Map(), wait: null, defaulted: false, closed: false },
912
983
  ...{ stopped: false, grace: null, idle: false, inTurn: true, tasks: [] },
913
984
  ...{ proposals: new Map(), calls: new Map(), heard: false, summary: null, wanted: null },
985
+ // When each task's last progress reached the chat; the last one it held back since.
986
+ taskAt: new Map(),
987
+ taskHeld: new Map(),
914
988
  why: null,
915
989
  ...{ hold: false, late: false, pending: [], echoes: [] },
916
990
  };
@@ -39,12 +39,18 @@ function absorb(seen, a) {
39
39
  /**
40
40
  * The handoff watch of one session (see `runSession`): `see(a, model)` takes each activity,
41
41
  * flags the session past its share or at a compaction (`handoff.flag`), and calls `stop` once it
42
- * works on past more. `windowOf(model)` is the window the share is taken of.
42
+ * works on past more. `windowOf(model)` is the window the share is taken of. A run's `fresh`
43
+ * session (no resume) over the share at its first reading starts there: a fresh one after it,
44
+ * on the same prompt, would too, so the share does not hand it over (a live run at 10%, 2026-11-03: three sessions of 19% each
45
+ * handed over before any work, and the item blocked); a compaction still does.
43
46
  */
44
- function handoffWatch(handoff, windowOf, write, { stop, onFlag }) {
47
+ function handoffWatch(handoff, windowOf, write, { stop, onFlag, fresh = false }) {
45
48
  /** @type {{flagged: boolean, after: number, context: number, turn?: string, unknown: boolean,
46
- * info?: object}} */
47
- const w = { flagged: false, after: 0, context: 0, turn: undefined, unknown: false };
49
+ * info?: object, readings: number, under: boolean}} */
50
+ const w = {
51
+ ...{ flagged: false, after: 0, context: 0, turn: undefined, unknown: false },
52
+ ...{ readings: 0, under: false },
53
+ };
48
54
  const unknownOnce = (model) => {
49
55
  if (w.unknown) return;
50
56
  w.unknown = true;
@@ -69,7 +75,16 @@ function handoffWatch(handoff, windowOf, write, { stop, onFlag }) {
69
75
  // No share is under every threshold: a session of an unknown window hands over at a compaction.
70
76
  const share = pct ?? 0;
71
77
  if (pct === null && !compacted) unknownOnce(model);
72
- if (!w.flagged && (compacted || share >= handoff.pct)) flag(win, pct, compacted);
78
+ // A run's fresh session starts from the same prompt; a project chat's, from a summary.
79
+ const under = fresh && !handoff.soft && w.readings === 1 && share >= handoff.pct;
80
+ if (under && !compacted && !w.under) {
81
+ w.under = true;
82
+ write([
83
+ `[${clock()}] handoff: off, the session starts at ${pct}% of the window, over ` +
84
+ `context_handoff_pct ${handoff.pct}: a fresh session would start there too; raise it`,
85
+ ]);
86
+ }
87
+ if (!w.flagged && (compacted || (share >= handoff.pct && !w.under))) flag(win, pct, compacted);
73
88
  // A project chat hands over by its summary turn, which goes on past the flag (AD-42).
74
89
  if (handoff.soft) return;
75
90
  if (w.flagged && (w.after > HARD_TURNS || share >= handoff.pct + HARD_OVER)) {
@@ -83,6 +98,7 @@ function handoffWatch(handoff, windowOf, write, { stop, onFlag }) {
83
98
  see(a, model) {
84
99
  if (a.context !== undefined) {
85
100
  w.context = a.context;
101
+ w.readings++;
86
102
  if (w.flagged && a.turn !== w.turn) w.after++;
87
103
  w.turn = a.turn;
88
104
  }
@@ -292,6 +308,7 @@ export function runSession(s) {
292
308
  const watch = handoffWatch(handoff, windowOf, write, {
293
309
  stop: stop('handoff'),
294
310
  onFlag: flagged,
311
+ fresh: !s.resume,
295
312
  });
296
313
  const limit = sessionTimeout(timeoutMs, stop('timeout'), { halt, stop: stop('stopped') });
297
314
  /** @type {((tokens: number, model?: string) => void) | null} */
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcf-session",
3
- "version": "0.17.6",
3
+ "version": "0.18.0",
4
4
  "private": true,
5
5
  "description": "The session engine of GCF: one agent session and a run as a chain of them, the chat protocol, the provider adapters. Bundled by gcf-harness-aif-ext and gcf-board, never published.",
6
6
  "type": "module",
@@ -46,6 +46,22 @@ export type ChatEvent = At &
46
46
  /** `id`: the input line of the operator's message it did not send, when it has one. */
47
47
  | { type: 'error'; text: string; id?: string }
48
48
  | { type: 'background'; tasks: { id: string; description: string }[] }
49
+ /** A subagent's or a background shell's start, progress (one in 2 s) or end. */
50
+ | {
51
+ type: 'task';
52
+ phase: 'start' | 'progress' | 'end';
53
+ id: string;
54
+ kind?: string;
55
+ agent?: string;
56
+ description?: string;
57
+ doing?: string;
58
+ prompt?: string;
59
+ calls?: number;
60
+ ms?: number;
61
+ status?: string;
62
+ summary?: string;
63
+ background?: boolean;
64
+ }
49
65
  | {
50
66
  type: 'question';
51
67
  request_id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcf-board",
3
- "version": "0.18.7",
3
+ "version": "0.19.1",
4
4
  "description": "A local web board for GCF game projects: shows `gcf board --json` and runs the same ai-factory gcf commands an operator runs in a console",
5
5
  "type": "module",
6
6
  "license": "MIT",