gcf-board 0.34.0 → 0.36.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.
@@ -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-WMT9LmvP.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-Fq42leVT.css">
7
+ <script type="module" crossorigin src="/assets/index-CGnD6bzB.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-Blx3Arwz.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
@@ -19,7 +19,10 @@ const AFTER_MS = 10 * 60_000;
19
19
  /**
20
20
  * @typedef {object} Policy What the work is, for the engine.
21
21
  * @property {any} adapter the provider adapter of `agent`
22
- * @property {string} agent the agent command
22
+ * @property {string | ((kind: string, env: Record<string, string> | undefined) => string)} agent
23
+ * the agent command, or a function of the session's kind and env that gives it at each
24
+ * session's start (a run's phase picks its model, Plan-Review-Rework-Plan d10); the
25
+ * after-session turn runs with its session's
23
26
  * @property {string} dir where the sessions work
24
27
  * @property {string} id the work's id: the name of its chat files
25
28
  * @property {string} logs the folder of its chat files and windows
@@ -47,11 +50,11 @@ const AFTER_MS = 10 * 60_000;
47
50
  * @property {(ran: any, kind: string) => void} [onSession] a session ended: its result
48
51
  * @property {(n: number) => void} [onHandoff] the `n`th fresh session is about to start
49
52
  * @property {(ran: any, ask: Ask) => Promise<any>} [afterSession] the turn after a session
50
- * @property {(now: number, o: {woke: 'operator' | 'usage' | null}) => Gate | Promise<Gate>}
51
- * [beforeSession] the gate before each session (Hold-Plan d7): `{go}`, `{wait, until,
52
- * reserve?, pct?}` (a usage-limit reset still ahead, AD-19, or the quota's reserve) or `{stop,
53
- * why}`; a Date is a wait, null a go. `woke`: the wait before it ended early (t1 d3), so the
54
- * last quota state is still the cut session's
53
+ * @property {(now: number, o: {woke: 'operator' | 'usage' | null, kind: string}) => Gate |
54
+ * Promise<Gate>} [beforeSession] the gate before each session of `kind` (Hold-Plan d7):
55
+ * `{go}`, `{wait, until, reserve?, pct?}` (a usage-limit reset still ahead, AD-19, or the
56
+ * quota's reserve) or `{stop, why}`; a Date is a wait, null a go. `woke`: the wait before it
57
+ * ended early (t1 d3), so the last quota state is still the cut session's
55
58
  * @property {import('./wake.js').Wake} [wake] what ends a limit wait early (t1 d1)
56
59
  * @property {() => string | null} [hold] why the work is to stop now, its sessions handing over
57
60
  * (`hold`, `reserve`): a live session is flagged, a wait ends
@@ -112,7 +115,7 @@ async function capped(j) {
112
115
  */
113
116
  const common = (p, kind = 'after') => ({
114
117
  adapter: p.adapter,
115
- agent: p.agent,
118
+ agent: typeof p.agent === 'function' ? undefined : p.agent,
116
119
  dir: p.dir,
117
120
  flags: typeof p.flags === 'function' ? p.flags(kind) : p.flags,
118
121
  fd: p.fd,
@@ -268,7 +271,8 @@ function decisionOf(d) {
268
271
  async function gate(j, kind, rec) {
269
272
  const holding = heldNow(j.p);
270
273
  if (holding) return { held: holding };
271
- const d = decisionOf(await j.p.beforeSession?.((j.p.clock ?? realClock).now(), { woke: j.woke }));
274
+ const now = (j.p.clock ?? realClock).now();
275
+ const d = decisionOf(await j.p.beforeSession?.(now, { woke: j.woke, kind }));
272
276
  if ('stop' in d && d.stop) return { held: d.why };
273
277
  if (!('wait' in d) || !d.wait) return true;
274
278
  const reserve = Boolean(d.reserve);
@@ -298,6 +302,9 @@ function waitState(j, kind, rec) {
298
302
  };
299
303
  }
300
304
 
305
+ /** A policy value that may be a function of the session's kind (and env): its value. */
306
+ const ofKind = (v, ...args) => (typeof v === 'function' ? v(...args) : v);
307
+
301
308
  /** A session the job did not start: stopped at its gate, or held there (`held`). */
302
309
  const notStarted = (kind, rec, held) => ({
303
310
  code: 'stopped',
@@ -321,13 +328,15 @@ async function session(j, kind, rec) {
321
328
  if (go !== true) return notStarted(kind, rec, go.held);
322
329
  p.handoff?.clear?.();
323
330
  const watch = p.watch?.();
324
- const env = typeof p.env === 'function' ? await p.env(kind) : p.env;
325
- // The after-session turn resumes this session: it runs with its env.
331
+ const env = await ofKind(p.env, kind);
332
+ // The after-session turn resumes this session: it runs with its env and agent command.
326
333
  j.env = env;
334
+ j.agent = ofKind(p.agent, kind, env);
327
335
  const woke = j.woke;
328
336
  j.woke = null;
329
337
  const ran = await runSession({
330
338
  ...common(p, kind),
339
+ agent: j.agent,
331
340
  env,
332
341
  ...first(j, kind, rec),
333
342
  timeoutMs: Math.max(j.deadline - Date.now(), 1000),
@@ -416,6 +425,7 @@ async function after(j, ran, base) {
416
425
  const ask = async (prompt, { timeoutMs = AFTER_MS } = {}) => {
417
426
  turn = await runSession({
418
427
  ...common(p),
428
+ agent: j.agent ?? common(p).agent,
419
429
  env: j.env ?? common(p).env,
420
430
  prompt,
421
431
  resume: ran.session_id,
@@ -31,8 +31,9 @@ export function usageCommand(agent) {
31
31
  * The wake of a limit wait. `mark` is the operator's file (`<logs>/<id>.wake`,
32
32
  * `chats/<t>/wake`); `reading()` gives the reading another watch already keeps (automation's
33
33
  * reserve), else `command` is asked every `pollMs` while a wait lives; neither: the mark alone.
34
- * `onWake(by, until)` hears each wake.
35
- * @param {{mark: string, model?: string | null, command?: string | null,
34
+ * `onWake(by, until)` hears each wake. `model` may be a function: the model of the session the
35
+ * wait is for, read at each look.
36
+ * @param {{mark: string, model?: string | null | (() => string | null), command?: string | null,
36
37
  * reading?: (() => any) | null, pollMs?: number,
37
38
  * onWake?: (by: 'operator' | 'usage', until: Date) => void}} o
38
39
  * @returns {Wake}
@@ -86,7 +87,9 @@ export function wakeWatch({
86
87
  return woke('operator');
87
88
  }
88
89
 
89
- return usage && limitBack(reading ? reading() : own, since, { model, pct, now })
90
+ const m = typeof model === 'function' ? model() : model;
91
+
92
+ return usage && limitBack(reading ? reading() : own, since, { model: m, pct, now })
90
93
  ? woke('usage')
91
94
  : null;
92
95
  },
@@ -144,6 +144,8 @@ export type ChatEvent = At &
144
144
  unticked: number | null;
145
145
  lessons: number;
146
146
  process: string | null;
147
+ // The run changed the agent's instructions (Lessons-Review-Plan d9); absent: none.
148
+ instructions?: { paths: string[]; from: string; to: string; uncommitted: string[] };
147
149
  }
148
150
  /** The planning phase's end: converged in `passes`, or `stalled` with each pass's count. */
149
151
  | { type: 'step'; step: 'plan'; passes: number; stalled?: number[] }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcf-board",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
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",