gcf-board 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +14 -12
  2. package/dist/server/app.js +166 -20
  3. package/dist/server/chat.js +42 -1
  4. package/dist/server/files.js +5 -2
  5. package/dist/server/mcp.js +28 -0
  6. package/dist/server/moves.js +11 -0
  7. package/dist/server/propose.js +96 -0
  8. package/dist/server/runs.js +28 -120
  9. package/dist/server/talks.js +553 -0
  10. package/dist/web/assets/golos-text-cyrillic-ext-wght-normal-hICkpzq7.woff2 +0 -0
  11. package/dist/web/assets/golos-text-cyrillic-wght-normal-mKek_fSS.woff2 +0 -0
  12. package/dist/web/assets/golos-text-latin-ext-wght-normal-B-I5lbAQ.woff2 +0 -0
  13. package/dist/web/assets/golos-text-latin-wght-normal-BS5oQT7X.woff2 +0 -0
  14. package/dist/web/assets/index-B3u-VrJK.css +1 -0
  15. package/dist/web/assets/index-BB3i2FaE.js +39 -0
  16. package/dist/web/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  17. package/dist/web/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  18. package/dist/web/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  19. package/dist/web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  20. package/dist/web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  21. package/dist/web/index.html +2 -2
  22. package/node_modules/gcf-session/lib/activity.js +371 -0
  23. package/node_modules/gcf-session/lib/adapter/claude.js +226 -0
  24. package/node_modules/gcf-session/lib/adapter/index.js +33 -0
  25. package/node_modules/gcf-session/lib/chat-input.js +260 -0
  26. package/node_modules/gcf-session/lib/chat.js +834 -0
  27. package/node_modules/gcf-session/lib/cli.js +52 -0
  28. package/node_modules/gcf-session/lib/cost.js +29 -0
  29. package/node_modules/gcf-session/lib/index.js +58 -0
  30. package/node_modules/gcf-session/lib/job.js +437 -0
  31. package/node_modules/gcf-session/lib/limit.js +132 -0
  32. package/node_modules/gcf-session/lib/lock.js +81 -0
  33. package/node_modules/gcf-session/lib/proc.js +93 -0
  34. package/node_modules/gcf-session/lib/session.js +320 -0
  35. package/node_modules/gcf-session/lib/store.js +28 -0
  36. package/node_modules/gcf-session/lib/thread.js +423 -0
  37. package/node_modules/gcf-session/lib/windows.js +46 -0
  38. package/node_modules/gcf-session/package.json +23 -0
  39. package/node_modules/gcf-session/types/index.d.ts +152 -0
  40. package/package.json +12 -3
  41. package/dist/web/assets/index-BYAEKw51.css +0 -1
  42. package/dist/web/assets/index-DpzFCrLV.js +0 -36
@@ -27,10 +27,7 @@ const active = new Set();
27
27
  const queues = new Map();
28
28
  // Projects whose queue waits after a failure the next run would repeat (`stalled`).
29
29
  const paused = new Set();
30
- // shortcut: the scheduled resume after a usage limit lives in memory, like the queue: a board
31
- // restart loses it, and the operator resumes by hand; persist it if restarts become common.
32
- const scheduled = new Map();
33
- // The paused projects whose pause the usage limit set: its reset may lift it, nothing else.
30
+ // The paused projects whose pause the usage limit set: a run that ended paused by it (AD-19).
34
31
  const limitPaused = new Set();
35
32
  // Runs going on for a project the operator removed: their end touches no project state.
36
33
  const forgotten = new WeakSet();
@@ -56,65 +53,20 @@ export function closeReport(project, id) {
56
53
  export const activeRuns = (project) => [...active].filter((r) => r.project === project);
57
54
  /** What runs and what waits, for a project; a paused queue waits for `resumeQueue`. */
58
55
  export function runsOf(project) {
59
- const s = scheduled.get(project);
60
56
  return {
61
57
  active: activeRuns(project),
62
58
  queued: (queues.get(project) ?? []).flatMap((q) => q.ids),
63
59
  paused: paused.has(project),
64
- // Why it waits: the usage limit (its reset may lift it) or a failure (only the operator).
60
+ // Why it waits: a run the usage limit ended paused, or a failure; the operator resumes it.
65
61
  paused_by: paused.has(project) ? (limitPaused.has(project) ? 'limit' : 'failure') : null,
66
- // When the items a usage limit stopped run again by themselves, and the queue with them.
67
- resume: s ? { at: s.at.toISOString(), ids: s.run.ids } : null,
68
62
  reports: reports.get(project) ?? [],
69
63
  acts: acts.get(project) ?? [],
70
64
  };
71
65
  }
72
- /**
73
- * The time a usage limit resets, as Claude names it (`3am`, `3:30pm`, `15:00`, with or without
74
- * `(Europe/Berlin)`): its next occurrence after `now`, a minute late to be safe; null when the
75
- * text is no such time.
76
- */
77
- export function resetAt(text, now = new Date()) {
78
- // shortcut: the time is read on this machine's clock and the zone it names is ignored: the
79
- // board runs where the operator's claude does; convert through Intl if a zone ever differs.
80
- const m = /^\s*(\d{1,2})(?::(\d{2}))?\s*([ap]m)?\s*(\(.*\))?\s*$/i.exec(text);
81
- if (!m || (!m[2] && !m[3]))
82
- return null;
83
- let hour = Number(m[1]);
84
- const minute = Number(m[2] ?? 0);
85
- if (m[3]) {
86
- if (hour < 1 || hour > 12)
87
- return null;
88
- hour = (hour % 12) + (m[3].toLowerCase() === 'pm' ? 12 : 0);
89
- }
90
- if (hour > 23 || minute > 59)
91
- return null;
92
- const at = new Date(now);
93
- at.setHours(hour, minute + 1, 0, 0);
94
- if (at <= now)
95
- at.setDate(at.getDate() + 1);
96
- return at;
97
- }
98
- /** Drop the scheduled resume; the queue stays as it is. */
99
- export function cancelResume(project) {
100
- const s = scheduled.get(project);
101
- if (s?.run.ids.length)
102
- trace(project, 'resume-cancelled', `the resume of ${s.run.ids.join(', ')} is cancelled`);
103
- clearTimeout(s?.timer);
104
- scheduled.delete(project);
105
- broadcast({ type: 'board', project });
106
- }
107
- /** Lift a pause the usage limit set; a pause for another cause waits for the operator. */
108
- function liftLimitPause(project) {
109
- if (limitPaused.delete(project))
110
- paused.delete(project);
111
- }
112
- /** A project left the board: nothing of it may run or fire any more. */
66
+ /** A project left the board: nothing of it may run any more. */
113
67
  export function forgetProject(project) {
114
68
  for (const r of activeRuns(project))
115
69
  forgotten.add(r);
116
- clearTimeout(scheduled.get(project)?.timer);
117
- scheduled.delete(project);
118
70
  queues.delete(project);
119
71
  paused.delete(project);
120
72
  limitPaused.delete(project);
@@ -122,44 +74,9 @@ export function forgetProject(project) {
122
74
  acts.delete(project);
123
75
  }
124
76
  /**
125
- * At the reset: run the stopped items again (the harness resumes their sessions), then the queue.
126
- * A second limited run joins the first: all their items go, at the later reset.
127
- */
128
- function schedule(run, at) {
129
- const project = run.p.name;
130
- const before = scheduled.get(project);
131
- clearTimeout(before?.timer);
132
- const ids = [...new Set([...(before?.run.ids ?? []), ...run.ids])];
133
- const when = before && before.at > at ? before.at : at;
134
- const timer = setTimeout(() => {
135
- const s = scheduled.get(project);
136
- scheduled.delete(project);
137
- liftLimitPause(project);
138
- try {
139
- if (s) {
140
- const { entry, p, ids, mode, harness } = s.run;
141
- const r = startRun(entry, p, ids, mode, false, harness);
142
- const how = 'queued' in r ? 'wait in the queue' : 'run again';
143
- trace(project, 'resume', `the usage limit reset: ${s.run.ids.join(', ')} ${how}`);
144
- }
145
- }
146
- catch (e) {
147
- // The board's own run of an item takes it out of the schedule first, so this is rare;
148
- // the queue still goes on.
149
- const why = e instanceof Error ? e.message : String(e);
150
- if (s)
151
- trace(project, 'resume-failed', `${s.run.ids.join(', ')}: ${why}`);
152
- advance(project);
153
- }
154
- broadcast({ type: 'board', project });
155
- }, when.getTime() - Date.now());
156
- timer.unref();
157
- scheduled.set(project, { at: when, run: { ...run, ids }, timer });
158
- }
159
- /**
160
- * A run some of whose items hit the usage limit: the main queue would hit it too, so it pauses,
161
- * and those items run again at the reset when the message names a time. The reason, for its
162
- * report.
77
+ * A run some of whose items the usage limit ended paused: the harness waits for a reset it
78
+ * knows (AD-19), so these are the week's limit, an unknown reset, one too far, or a third
79
+ * limit. The main queue would meet it too: it pauses. The reason, for its report.
163
80
  */
164
81
  function limited(run, result) {
165
82
  const hit = (result?.items ?? []).filter((i) => i.limit_resets !== undefined);
@@ -171,12 +88,12 @@ function limited(run, result) {
171
88
  limitPaused.add(project);
172
89
  }
173
90
  const resets = hit.find((i) => i.limit_resets)?.limit_resets ?? '';
174
- const at = resetAt(resets);
175
- if (at)
176
- schedule({ ...run, ids: hit.map((i) => i.id), fresh: false }, at);
177
- const when = at ? `they resume at ${at.toTimeString().slice(0, 5)}` : 'run them after the reset';
91
+ // A harness before 0.12 does not wait for the reset by itself.
92
+ const old = result?.limit_wait
93
+ ? ''
94
+ : '; gcf-harness-aif-ext 0.12 waits for the reset by itself: update it in the project';
178
95
  const queue = run.mode === 'main' ? ', the queue is paused' : '';
179
- const reason = `usage limit${resets ? `, resets ${resets}` : ''}${queue}: ${when}`;
96
+ const reason = `usage limit${resets ? `, resets ${resets}` : ''}${queue}: run them after the reset${old}`;
180
97
  trace(project, 'limit', `${hit.map((i) => i.id).join(', ')}: ${reason}`);
181
98
  return reason;
182
99
  }
@@ -188,14 +105,11 @@ function advance(project) {
188
105
  if (!next)
189
106
  return;
190
107
  trace(project, 'queue-run', `the queue starts ${next.ids.join(', ')}`);
191
- spawnRun(next, next.mode);
108
+ // Nobody clicked it now: it waits while the usage limit's reset is ahead.
109
+ spawnRun({ ...next, waitLimit: true }, next.mode);
192
110
  }
193
111
  /** The operator resumes a paused queue (after fixing what stopped it). */
194
112
  export function resumeQueue(project) {
195
- // The limit still holds until its reset: the next run would hit it again.
196
- const s = scheduled.get(project);
197
- if (s && limitPaused.has(project))
198
- throw new HttpError(409, `the queue resumes by itself at ${s.at.toTimeString().slice(0, 5)}, after the usage limit; cancel that first to resume now`);
199
113
  if (paused.has(project))
200
114
  trace(project, 'queue-resumed', 'the operator resumed the queue');
201
115
  paused.delete(project);
@@ -243,7 +157,7 @@ export function harnessReport(out) {
243
157
  ? r
244
158
  : null;
245
159
  }
246
- // The fields read as more than text: the id, and the reset a resume is scheduled at.
160
+ // The fields read as more than text: the id, and the usage limit's reset.
247
161
  function isItem(i) {
248
162
  if (typeof i !== 'object' || i === null)
249
163
  return false;
@@ -257,11 +171,13 @@ function spawnRun(q, mode) {
257
171
  const args = [entry, harness, 'run', ...ids, '--json'];
258
172
  if (q.fresh)
259
173
  args.push('--fresh');
260
- // A board's run is always open to the operator: its chat settings say who waits for whom.
261
- // shortcut: the page shows no chat yet, so nobody could answer a question there: the run
262
- // waits for none (as `answer_timeout_min: 0`); drop the timeout when the chat screen ships.
263
- // GCF_BOARD_CHAT_TIMEOUT: the scenario tests, which answer through the API, wait.
264
- args.push('--chat', '--chat-timeout', process.env.GCF_BOARD_CHAT_TIMEOUT ?? '0');
174
+ if (q.waitLimit)
175
+ args.push('--wait-limit');
176
+ // A board's run is always open to the operator: its chat waits the project's answer time
177
+ // (`chat.answer_timeout_min`), which the harness reads. GCF_BOARD_CHAT_TIMEOUT: the tests'.
178
+ args.push('--chat');
179
+ if (process.env.GCF_BOARD_CHAT_TIMEOUT)
180
+ args.push('--chat-timeout', process.env.GCF_BOARD_CHAT_TIMEOUT);
265
181
  const rid = randomUUID();
266
182
  const relay = spawn(process.execPath, [RELAY, recordOf(rid), endOf(rid), ...args], {
267
183
  cwd: p.path,
@@ -345,7 +261,7 @@ function land(q, run, rid, live, message = '') {
345
261
  const result = harnessReport(end?.out ?? '');
346
262
  if (!end && !message)
347
263
  message = "the run's relay ended without a result";
348
- // A run of a project removed meanwhile only reports: it pauses and schedules nothing.
264
+ // A run of a project removed meanwhile only reports: it pauses nothing.
349
265
  const kept = !forgotten.has(run);
350
266
  const acting = kept && live;
351
267
  const stop = acting && mode === 'main' && queues.get(p.name)?.length && stalled(ok, result);
@@ -356,7 +272,7 @@ function land(q, run, rid, live, message = '') {
356
272
  const note = !kept
357
273
  ? ''
358
274
  : !live
359
- ? 'it ended while the board was stopped: nothing was paused or scheduled'
275
+ ? 'it ended while the board was stopped: nothing was paused'
360
276
  : limited(q, result) ||
361
277
  (stop ? 'the queue is paused: fix the cause, then resume it on the board' : '');
362
278
  if (stop)
@@ -364,13 +280,16 @@ function land(q, run, rid, live, message = '') {
364
280
  for (const i of result?.items ?? [])
365
281
  if (acting && i.handoffs)
366
282
  trace(p.name, 'handoff', `${i.id}: ${i.handoffs} context handoff(s) to a fresh session`);
367
- // A harness before 0.11 refuses the chat flags every board run passes: say what to update.
283
+ // A harness before 0.11 refuses the chat flags every board run passes, one before 0.12 the
284
+ // limit wait of a queued start: say what to update.
368
285
  const old = /unknown option '--chat|--chat-timeout is a number of minutes above 0/;
369
286
  const brief = !end?.err
370
287
  ? ''
371
288
  : old.test(end.err)
372
289
  ? 'board runs need gcf-harness-aif-ext 0.11 or later: update it in the project'
373
- : briefError(end.err);
290
+ : /unknown option '--wait-limit'/.test(end.err)
291
+ ? 'queued runs need gcf-harness-aif-ext 0.12 or later: update it in the project'
292
+ : briefError(end.err);
374
293
  const report = {
375
294
  id: `r${++reportSeq}`,
376
295
  at: new Date().toISOString(),
@@ -465,17 +384,6 @@ export function startRun(entry, p, ids, mode = 'worktree', fresh = false, harnes
465
384
  const busy = ids.filter((id) => queued.includes(id) || going.some((r) => r.ids.includes(id)));
466
385
  if (busy.length)
467
386
  throw new HttpError(409, `already running from this board: ${busy.join(', ')}`);
468
- // The operator runs an item the limit stopped before its reset: they know better, so it goes
469
- // now, and the limit's pause with it; the rest of the schedule stays.
470
- const s = scheduled.get(p.name);
471
- if (s?.run.ids.some((id) => ids.includes(id))) {
472
- const early = s.run.ids.filter((id) => ids.includes(id));
473
- trace(p.name, 'resume-cancelled', `${early.join(', ')}: the operator runs them before the reset`);
474
- s.run = { ...s.run, ids: s.run.ids.filter((id) => !ids.includes(id)) };
475
- if (!s.run.ids.length)
476
- cancelResume(p.name);
477
- liftLimitPause(p.name);
478
- }
479
387
  // A paused queue holds a new main run too: it would repeat the failure, and jump the queue.
480
388
  if (mode === 'main' && (paused.has(p.name) || going.some((r) => r.mode === 'main'))) {
481
389
  queues.set(p.name, [...(queues.get(p.name) ?? []), { entry, p, ids, mode, fresh, harness }]);