gcf-board 0.7.0 → 0.8.2
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.
- package/README.md +3 -2
- package/dist/server/app.js +37 -6
- package/dist/server/talks.js +45 -4
- package/dist/web/assets/index-D8JZaQgt.js +39 -0
- package/dist/web/assets/{index-B3u-VrJK.css → index-aCBpVSeA.css} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/gcf-session/lib/adapter/claude.js +13 -0
- package/node_modules/gcf-session/lib/adapter/index.js +6 -0
- package/node_modules/gcf-session/lib/chat.js +16 -6
- package/node_modules/gcf-session/lib/cli.js +2 -0
- package/node_modules/gcf-session/lib/index.js +4 -1
- package/node_modules/gcf-session/lib/job.js +2 -0
- package/node_modules/gcf-session/lib/session.js +33 -6
- package/node_modules/gcf-session/lib/thread.js +151 -25
- package/node_modules/gcf-session/package.json +1 -1
- package/node_modules/gcf-session/types/index.d.ts +33 -3
- package/package.json +1 -1
- package/dist/web/assets/index-BB3i2FaE.js +0 -39
package/README.md
CHANGED
|
@@ -56,7 +56,8 @@ The board knows no domain by name: the project's board read gives its columns, m
|
|
|
56
56
|
- **Settings**: the keys of `gcf/config.yml` and the agents' language (`language.ui`, `language.artifacts` of `.ai-factory/config.yaml`), by the core's groups, each a `gcf config set` commit.
|
|
57
57
|
- **Agent**: the deny groups to tick, the rules the ticked groups add, the operator's own deny rules (add, remove) and the allow rules of `agent.allow`, apart; the context limits, read only.
|
|
58
58
|
- **An item's chat** (its drawer's **Chat** tab; harness 0.11.1, core 0.11.1): every run the board starts keeps its agent sessions open; the project's `chat:` settings (Settings: `chat.ask`, `chat.answer_timeout_min`) say what the agent asks and how long a question waits. The tab shows the run's chat, then the item's own thread of the project chat: the talk, question cards (picks, several questions, **Submit**), the run's milestones, its sessions, the limit wait, the context share. A message goes where the server puts it: the live run (its limit wait too), else the item's thread, and the line under the box says where it went. `GET /api/p/<project>/chat/<id>` follows the item's chat from its start, in raw chunks of JSON lines (the page splits them). `POST` there sends `{type: 'say', text, images?, attach?}`, `{type: 'interrupt'}` or `{type: 'answer', request_id, answers}` through `gcf-harness chat`; with no live run a message goes to the item's thread (answer `{talk}`), else a message with no session to read it gets 409, bad input 400. `attach` (`[{kind: item | file, ref}]`) goes into the message's text as a line the agent reads. `GET /api/p/<project>/chat/<id>/att/<file>` serves a chat picture; **attach to item…** under a picture gives it to an item (`gcf item attach`).
|
|
59
|
-
- **
|
|
59
|
+
- **Model and effort** (board 0.8.0, core 0.12.3): pickers in the New item form, in the drawer (**change** beside the model and effort, and **model / effort** under **More**) and in a thread's composer: **default** (the agent picks), the agent's presets, or an own word. An item's next run takes them; a thread's next session does (`chats/<t>/agent.json`), and its line in the chat says so.
|
|
60
|
+
- **Project chat** (the **Chat** screen; core 0.12): threads of an agent in the project's folder, listed newest first and filtered by their item; a new thread is made when its first message is sent. Each thread is run by the bundled session engine (`gcf-session`) through the same detached relay as runs. It asks a card before each edit, git command and framework move (**allow once**, **always** — saved in `.claude/settings.local.json`; the card says saved only when it was — or **deny**); a new item it proposes through the board's MCP server `gcf` (tool `propose_item_new`, asked with no card: the proposal card is the question), the proposal card shows every field it proposed, and the operator's **Create** makes it with `POST /move` (`proposal: {talk, id}`), **Edit…** first in the new-item form. A thread's list entry names the card that waits in it and its limit wait (`card`, `limit_until`); a running item names the card of its run's chat (`chat_card`). A long talk hands over to a fresh agent from a summary; an idle agent closes after `chat.answer_timeout_min` (0 means 15) and the next message resumes it. Each item has at most one thread: a message to an item with no live run goes there. `GET /api/p/<project>/talks[?item=]` lists the threads with their proposals' states; `POST` there makes one (`{item?}`); `GET /api/p/<project>/talk/<t>` follows a thread's events; `POST` there sends `say`, `interrupt`, `answer`, `allow`, `deny` or `handoff`; `POST …/talk/<t>/stop` is the composer's **close agent** (board 0.8.1): the thread's agent ends with everything it started, or its limit wait does, and what it had not taken in is dropped with a "not sent" line; the next message resumes the talk; `GET …/talk/<t>/att/<file>` serves its pictures. The files live in `.gcf-session/chats/` (docs/Chat-Plan.md §3).
|
|
60
61
|
- **Inbox**: add an entry (Enter adds, Shift+Enter breaks the line; its source and tags), tag it, erase it, or turn it into an item (its first line the title, the rest the note); search the entries, filter them by tag and by lesson kind. The D1 questions and the agent's D2 assumptions are listed there too.
|
|
61
62
|
- **Lessons** (core 0.7.10, harness 0.9.2): what got in an agent's way, asked at the end of each session, lands in the inbox with its kind (`tool`, `rules`, `framework`, `template`, `other`) and its item. The inbox filters them; a card shows `N lessons`, and the drawer lists the item's lessons with the inbox's buttons. A run's report line ends with `, N lessons`, and with `— code written outside aif-implement` when a session skipped that skill.
|
|
62
63
|
- **Playtest**: `gcf playtest session` with the checklist grouped by subsystem; keep, tune or kill each item from the list. **Build** runs `dod.build`. A note goes to the inbox as `--source playtest`.
|
|
@@ -89,7 +90,7 @@ Do not put the port on a network. Remote and phone access is planned for v2, beh
|
|
|
89
90
|
|
|
90
91
|
## Roadmap (v2)
|
|
91
92
|
|
|
92
|
-
- **The chat**: a
|
|
93
|
+
- **The chat**: a design unit picked by name as a message's attachment (today a project path).
|
|
93
94
|
- **Phone and remote access**: Tailscale or Claude Remote Control, with their own authentication; push notifications when an item blocks or waits for a verdict.
|
|
94
95
|
|
|
95
96
|
## Develop
|
package/dist/server/app.js
CHANGED
|
@@ -19,7 +19,7 @@ import { HttpError } from './http-error.js';
|
|
|
19
19
|
import { isCenterMove, moveArgs, moveInput, runIds } from './moves.js';
|
|
20
20
|
import { addProject, listProjects, projectOf, removeProject } from './registry.js';
|
|
21
21
|
import { adoptRuns, closeReport, forgetProject, resumeQueue, runsOf, startRun, unqueue, } from './runs.js';
|
|
22
|
-
import { acceptProposal, chatCard, chatOf, listTalks, openTalk, prepareTalk, startTalk, talkId, talkLive, talkWaits, watchTalks, writeTalk, } from './talks.js';
|
|
22
|
+
import { acceptProposal, agentPresets, chatCard, chatOf, listTalks, openTalk, pickTalk, prepareTalk, startTalk, stopTalk, talkId, talkLive, talkWaits, watchTalks, writeTalk, } from './talks.js';
|
|
23
23
|
import { threadDir } from 'gcf-session';
|
|
24
24
|
const send = (res, status, body) => {
|
|
25
25
|
res.writeHead(status, { 'content-type': 'application/json; charset=utf-8' });
|
|
@@ -185,15 +185,16 @@ export function createApp(o) {
|
|
|
185
185
|
};
|
|
186
186
|
/**
|
|
187
187
|
* A message to item `item`'s thread of the project chat (AD-49), when the project has one and
|
|
188
|
-
* the board read knows the item: the thread's id,
|
|
188
|
+
* the board read knows the item: the answer that says so (the thread, the input line's id),
|
|
189
|
+
* else null.
|
|
189
190
|
*/
|
|
190
191
|
const toThread = async (p, item, line) => {
|
|
191
192
|
const board = await boardOf(p).catch(() => null);
|
|
192
193
|
if (!board?.domain.chat || !board.agent?.rules || !idsOf(board).has(item))
|
|
193
194
|
return null;
|
|
194
195
|
const t = openTalk(p, item).id;
|
|
195
|
-
await sendTalk(p, t, line, board);
|
|
196
|
-
return t;
|
|
196
|
+
const sent = await sendTalk(p, t, line, board);
|
|
197
|
+
return { ok: true, talk: t, ...(typeof sent.id === 'string' ? { id: sent.id } : {}) };
|
|
197
198
|
};
|
|
198
199
|
const routes = [
|
|
199
200
|
['GET', /^\/api\/events$/, async (_req, res) => subscribe(res)],
|
|
@@ -235,6 +236,7 @@ export function createApp(o) {
|
|
|
235
236
|
plans_rev: planRev(p.name),
|
|
236
237
|
board_version: o.version,
|
|
237
238
|
quota: await lastQuota(),
|
|
239
|
+
presets: agentPresets(),
|
|
238
240
|
};
|
|
239
241
|
const board = await boardOf(p);
|
|
240
242
|
// A running item's last log write tells a working session from a stuck one; a run's
|
|
@@ -319,7 +321,7 @@ export function createApp(o) {
|
|
|
319
321
|
// No harness, so no run: a message goes to the item's thread all the same.
|
|
320
322
|
const t = line.type === 'say' ? await toThread(p, m[2], line) : null;
|
|
321
323
|
if (t)
|
|
322
|
-
return send(res, 202,
|
|
324
|
+
return send(res, 202, t);
|
|
323
325
|
throw e;
|
|
324
326
|
}
|
|
325
327
|
const chat = [harness, 'chat', m[2]];
|
|
@@ -347,7 +349,7 @@ export function createApp(o) {
|
|
|
347
349
|
// An item the board read knows: a stale or mistyped id gets no thread.
|
|
348
350
|
const t = r.code === 3 && line.type === 'say' ? await toThread(p, m[2], line) : null;
|
|
349
351
|
if (t)
|
|
350
|
-
return send(res, 202,
|
|
352
|
+
return send(res, 202, t);
|
|
351
353
|
const why = briefError(r.err || r.out).replace(/^[\w-]+ chat: /, '');
|
|
352
354
|
if (/unknown command 'chat'/.test(why))
|
|
353
355
|
throw new HttpError(400, 'the chat needs gcf-harness-aif-ext 0.11.0 or later');
|
|
@@ -410,6 +412,35 @@ export function createApp(o) {
|
|
|
410
412
|
send(res, 202, { ok: true, ...(typeof line.id === 'string' ? { id: line.id } : {}) });
|
|
411
413
|
},
|
|
412
414
|
],
|
|
415
|
+
[
|
|
416
|
+
// Close a thread's agent with all it started (AD-52); the board hears its end by its files.
|
|
417
|
+
'POST',
|
|
418
|
+
/^\/api\/p\/([^/]+)\/talk\/([^/]+)\/stop$/,
|
|
419
|
+
async (_req, res, m) => {
|
|
420
|
+
const p = await projectOf(m[1]);
|
|
421
|
+
const t = talkId(m[2]);
|
|
422
|
+
if (!existsSync(threadDir(p.path, t)))
|
|
423
|
+
throw new HttpError(404, `no thread ${t}`);
|
|
424
|
+
if (!talkLive(p, t))
|
|
425
|
+
throw new HttpError(409, `thread ${t} has no live agent to close`);
|
|
426
|
+
stopTalk(p, t);
|
|
427
|
+
send(res, 202, { ok: true });
|
|
428
|
+
},
|
|
429
|
+
],
|
|
430
|
+
[
|
|
431
|
+
// The model and effort of a thread's next sessions (Board-PRD decision 24).
|
|
432
|
+
'POST',
|
|
433
|
+
/^\/api\/p\/([^/]+)\/talk\/([^/]+)\/agent$/,
|
|
434
|
+
async (req, res, m) => {
|
|
435
|
+
const p = await projectOf(m[1]);
|
|
436
|
+
const t = talkId(m[2]);
|
|
437
|
+
if (!existsSync(threadDir(p.path, t)))
|
|
438
|
+
throw new HttpError(404, `no thread ${t}`);
|
|
439
|
+
const pick = pickTalk(p, t, await bodyOf(req));
|
|
440
|
+
broadcast({ type: 'talks', project: p.name });
|
|
441
|
+
send(res, 200, { ok: true, ...pick });
|
|
442
|
+
},
|
|
443
|
+
],
|
|
413
444
|
[
|
|
414
445
|
// A picture of a thread (`att/`, where the board put it); never through a link.
|
|
415
446
|
'GET',
|
package/dist/server/talks.js
CHANGED
|
@@ -11,7 +11,7 @@ import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, statSyn
|
|
|
11
11
|
import os from 'node:os';
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
|
-
import { THREAD_ID, createThread, listThreads, readThread, threadDir, threadOf, } from 'gcf-session';
|
|
14
|
+
import { THREAD_ID, createThread, listThreads, presetsOf, readThread, setThreadAgent, threadAgent, threadDir, threadOf, } from 'gcf-session';
|
|
15
15
|
import { writeAtomic } from './atomic.js';
|
|
16
16
|
import { alive } from './events.js';
|
|
17
17
|
import { HttpError } from './http-error.js';
|
|
@@ -30,6 +30,31 @@ const ASK = [
|
|
|
30
30
|
{ kind: 'edit', pattern: '' },
|
|
31
31
|
{ kind: 'shell', pattern: 'git *' },
|
|
32
32
|
];
|
|
33
|
+
/** What the operator picks a model and effort from: the agent's presets (Board-PRD decision 24). */
|
|
34
|
+
export const agentPresets = () => presetsOf(process.env.GCF_SESSION_AGENT ?? DEFAULT_AGENT);
|
|
35
|
+
/**
|
|
36
|
+
* Pick thread `t`'s model and effort (`default` or none: the agent's own); its next session
|
|
37
|
+
* takes them. A word that is not plain is a 400.
|
|
38
|
+
*/
|
|
39
|
+
export function pickTalk(p, t, body) {
|
|
40
|
+
writeDir(p, t);
|
|
41
|
+
const pick = {};
|
|
42
|
+
for (const k of ['model', 'effort']) {
|
|
43
|
+
const v = body[k];
|
|
44
|
+
if (v !== undefined && v !== null && typeof v !== 'string')
|
|
45
|
+
throw new HttpError(400, `${k} must be text`);
|
|
46
|
+
pick[k] = v;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
return setThreadAgent(p.path, t, pick);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
// The engine's word check; a failed write is the server's own.
|
|
53
|
+
if (e instanceof RangeError)
|
|
54
|
+
throw new HttpError(400, e.message);
|
|
55
|
+
throw e;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
33
58
|
/** A thread's id, or a 404. */
|
|
34
59
|
export function talkId(t) {
|
|
35
60
|
if (!THREAD_ID.test(t))
|
|
@@ -196,9 +221,12 @@ export async function prepareTalk(p, board, t) {
|
|
|
196
221
|
await writeAtomic(path.join(td, 'context.md'), contextOf(p, board, readThread(p.path, t).item));
|
|
197
222
|
await writeAtomic(path.join(td, 'spec.json'), `${JSON.stringify(spec, null, 2)}\n`);
|
|
198
223
|
}
|
|
199
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* Whether thread `t` waits for the usage limit's reset: its last session event is `limit`, not
|
|
226
|
+
* the operator's close after it.
|
|
227
|
+
*/
|
|
200
228
|
export function talkWaits(p, t) {
|
|
201
|
-
const last = eventsOf(dirOf(p, t)).findLast((e) => ['session', 'session_end', 'limit'].includes(e.type));
|
|
229
|
+
const last = eventsOf(dirOf(p, t)).findLast((e) => ['session', 'session_end', 'limit', 'closed'].includes(e.type));
|
|
202
230
|
return last?.type === 'limit';
|
|
203
231
|
}
|
|
204
232
|
/** Whether a session of thread `t` lives: its `open` holds the thread's lock. */
|
|
@@ -260,6 +288,16 @@ export function writeTalk(p, t, input) {
|
|
|
260
288
|
appendFileSync(path.join(td, 'chat-in.jsonl'), `${JSON.stringify(line)}\n`);
|
|
261
289
|
return line;
|
|
262
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Close thread `t`'s agent with all it started, or end its wait for the limit (AD-52): the
|
|
293
|
+
* engine's stop mark. A mark the engine never reads (it ended meanwhile) goes at its next open.
|
|
294
|
+
*/
|
|
295
|
+
export function stopTalk(p, t) {
|
|
296
|
+
const stop = path.join(writeDir(p, t), 'stop');
|
|
297
|
+
if (existsSync(stop) && lstatSync(stop).isSymbolicLink())
|
|
298
|
+
throw new HttpError(400, `${t}'s stop mark goes through a link: refused`);
|
|
299
|
+
writeFileSync(stop, '');
|
|
300
|
+
}
|
|
263
301
|
/** A thread's chat events; a line that is not one is skipped. */
|
|
264
302
|
function eventsOf(td) {
|
|
265
303
|
return chatEvents(path.join(td, 'chat.jsonl'));
|
|
@@ -433,7 +471,7 @@ export function cardIn(events) {
|
|
|
433
471
|
}
|
|
434
472
|
/** When a thread's agent wakes after the usage limit: its last session event is the wait. */
|
|
435
473
|
export function limitIn(events) {
|
|
436
|
-
const last = events.findLast((e) => e.type === 'limit' || e.type === 'session');
|
|
474
|
+
const last = events.findLast((e) => e.type === 'limit' || e.type === 'session' || e.type === 'closed');
|
|
437
475
|
return last?.type === 'limit' ? last.until : null;
|
|
438
476
|
}
|
|
439
477
|
/** The text of the operator's first message to a thread, as written; null before one. */
|
|
@@ -466,6 +504,7 @@ async function talkOf(p, th, ids) {
|
|
|
466
504
|
const live = talkLive(p, th.id);
|
|
467
505
|
// A dead engine's card went with it: no one takes its answer (a new session drops it too).
|
|
468
506
|
const card = live ? cardIn(events) : null;
|
|
507
|
+
const pick = threadAgent(p.path, th.id);
|
|
469
508
|
const cost = events.reduce((sum, e) => sum + (e.type === 'session_end' ? (e.cost_usd ?? 0) : 0), 0);
|
|
470
509
|
return {
|
|
471
510
|
id: th.id,
|
|
@@ -474,6 +513,8 @@ async function talkOf(p, th, ids) {
|
|
|
474
513
|
created_at: th.created_at,
|
|
475
514
|
last_at: events.at(-1)?.at ?? null,
|
|
476
515
|
cost_usd: Math.round(cost * 100) / 100,
|
|
516
|
+
model: pick.model ?? null,
|
|
517
|
+
effort: pick.effort ?? null,
|
|
477
518
|
live,
|
|
478
519
|
waiting: Boolean(card),
|
|
479
520
|
card,
|