gcf-board 0.30.0 → 0.31.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.
@@ -26,7 +26,7 @@ import { addProject, homeDir, listProjects, projectOf, removeProject, yoloFile,
26
26
  import { allThemes } from './themes.js';
27
27
  import { askIfDue, askUsage, configureUsage, lastUsage } from './usage.js';
28
28
  import { activeRuns, adoptRuns, busyCheck, keepProjects, sweepRuns, closeReport, forgetProject, resumeQueue, holdProject, retryWaiting, runsOf, setAutopilot, startRun, allowOf, whileAllowing, unqueue, ticketState, watchTickets, } from './runs.js';
29
- import { acceptProposal, agentDefaults, agentPresets, chatCard, deniedRuleIn, lastDeniedOf, lastRunEnd, chatOf, entryTalk, listTalks, openTalk, pickTalk, prepareTalk, startDesign, startTalk, stopTalk, wakeTalk, talkEntry, talkId, talkLive, talkSaid, talkWaits, watchTalks, writeTalk, } from './talks.js';
29
+ import { acceptProposal, agentDefaults, agentPresets, chatCard, deniedRuleIn, lastDeniedOf, lastRunEnd, chatOf, entryTalk, listTalks, openTalk, pickTalk, prepareTalk, startDesign, startTalk, stopTalk, wakeTalk, talkEntry, talkId, talkLive, talkPending, talkSaid, talkWaits, watchTalks, writeTalk, } from './talks.js';
30
30
  import { accountSettings, saveAccountSettings, threadDir, threadOfEntry } from 'gcf-session';
31
31
  const send = (res, status, body) => {
32
32
  res.writeHead(status, { 'content-type': 'application/json; charset=utf-8' });
@@ -755,6 +755,18 @@ export function createApp(o) {
755
755
  send(res, 202, { ok: true, ...(typeof line.id === 'string' ? { id: line.id } : {}) });
756
756
  },
757
757
  ],
758
+ [
759
+ // The operator's messages a thread waiting for the limit has not read yet (Round15-Plan d3).
760
+ 'GET',
761
+ /^\/api\/p\/([^/]+)\/talk\/([^/]+)\/pending$/,
762
+ async (_req, res, m) => {
763
+ const p = await projectOf(m[1]);
764
+ const t = talkId(m[2]);
765
+ if (!existsSync(threadDir(p.path, t)))
766
+ throw new HttpError(404, `no thread ${t}`);
767
+ send(res, 200, { lines: talkPending(p, t) });
768
+ },
769
+ ],
758
770
  [
759
771
  // Close a thread's agent with all it started (AD-52); the board hears its end by its files.
760
772
  'POST',
@@ -172,24 +172,34 @@ export function pendingInput(root, id) {
172
172
  const rec = JSON.parse(readFileSync(path.join(runs, `${id}.agent.json`), 'utf8'));
173
173
  if (!rec.resets || !Number.isInteger(rec.chat_in_at))
174
174
  return [];
175
- const bytes = readFileSync(path.join(runs, `${id}.chat-in.jsonl`));
176
- return bytes
177
- .subarray(rec.chat_in_at)
178
- .toString('utf8')
179
- .split('\n')
180
- .flatMap((l) => {
181
- try {
182
- const e = JSON.parse(l);
183
- return e?.type === 'say' && typeof e.id === 'string' && typeof e.text === 'string'
184
- ? [{ id: e.id, text: e.text }]
185
- : [];
186
- }
187
- catch {
188
- return [];
189
- }
190
- });
175
+ return saysPast(path.join(runs, `${id}.chat-in.jsonl`), rec.chat_in_at);
191
176
  }
192
177
  catch {
193
178
  return [];
194
179
  }
195
180
  }
181
+ /** The operator's messages in input file `file` past byte `at`; none when it is missing. */
182
+ export function saysPast(file, at) {
183
+ let bytes;
184
+ try {
185
+ bytes = readFileSync(file);
186
+ }
187
+ catch {
188
+ return [];
189
+ }
190
+ return bytes
191
+ .subarray(at)
192
+ .toString('utf8')
193
+ .split('\n')
194
+ .flatMap((l) => {
195
+ try {
196
+ const e = JSON.parse(l);
197
+ return e?.type === 'say' && typeof e.id === 'string' && typeof e.text === 'string'
198
+ ? [{ id: e.id, text: e.text }]
199
+ : [];
200
+ }
201
+ catch {
202
+ return [];
203
+ }
204
+ });
205
+ }
@@ -17,7 +17,7 @@ import { writeAtomic } from './atomic.js';
17
17
  import { briefError, refusalOf } from './cli.js';
18
18
  import { alive } from './events.js';
19
19
  import { HttpError } from './http-error.js';
20
- import { IMAGE_EXT } from './chat.js';
20
+ import { IMAGE_EXT, saysPast } from './chat.js';
21
21
  import { homeDir, yoloFile } from './registry.js';
22
22
  // The source runs the .ts files, the package its build beside this file.
23
23
  const own = (name) => fileURLToPath(new URL(import.meta.url.endsWith('.ts') ? `${name}.ts` : `${name}.js`, import.meta.url));
@@ -814,6 +814,17 @@ export function limitIn(events) {
814
814
  const last = events.findLast((e) => ['limit', 'limit_end', 'session', 'closed'].includes(e.type));
815
815
  return last?.type === 'limit' ? last.until : null;
816
816
  }
817
+ /**
818
+ * The operator's messages thread `t` waits to read (Round15-Plan d3): its input past the record's
819
+ * `in_at`, which the engine writes as the cut session ends, before the limit's wait. None while
820
+ * no live engine waits for the limit.
821
+ */
822
+ export function talkPending(p, t) {
823
+ const td = dirOf(p, t);
824
+ if (!talkLive(p, t) || !limitIn(eventsOf(td)))
825
+ return [];
826
+ return saysPast(path.join(td, 'chat-in.jsonl'), Number(readThread(p.path, talkId(t)).in_at) || 0);
827
+ }
817
828
  /** The text of the operator's first message to a thread, as written; null before one. */
818
829
  function sayOf(td) {
819
830
  let text = '';