gcf-board 0.27.0 → 0.28.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.
- package/dist/server/app.js +25 -8
- package/dist/server/runs.js +34 -4
- package/dist/server/talks.js +18 -13
- package/dist/web/assets/index-CcsKtA2D.js +119 -0
- package/dist/web/index.html +1 -1
- package/node_modules/gcf-session/lib/chat.js +12 -0
- package/node_modules/gcf-session/lib/usage.js +8 -0
- package/node_modules/gcf-session/package.json +1 -1
- package/package.json +2 -2
- package/dist/web/assets/index-Ds32enMs.js +0 -116
package/dist/server/app.js
CHANGED
|
@@ -24,8 +24,8 @@ import { isUpload, saveUpload, UPLOAD_MAX } from './upload.js';
|
|
|
24
24
|
import { addProject, homeDir, listProjects, projectOf, removeProject, yoloFile, } from './registry.js';
|
|
25
25
|
import { allThemes } from './themes.js';
|
|
26
26
|
import { askIfDue, askUsage, configureUsage, lastUsage } from './usage.js';
|
|
27
|
-
import { activeRuns, adoptRuns, busyCheck, keepProjects, sweepRuns, closeReport, forgetProject, resumeQueue, holdProject, retryWaiting, runsOf, setAutopilot, startRun, unqueue, ticketState, watchTickets, } from './runs.js';
|
|
28
|
-
import { acceptProposal, agentDefaults, agentPresets, chatCard,
|
|
27
|
+
import { activeRuns, adoptRuns, busyCheck, keepProjects, sweepRuns, closeReport, forgetProject, resumeQueue, holdProject, retryWaiting, runsOf, setAutopilot, startRun, allowOf, whileAllowing, unqueue, ticketState, watchTickets, } from './runs.js';
|
|
28
|
+
import { acceptProposal, agentDefaults, agentPresets, chatCard, deniedRuleIn, lastDeniedOf, lastRunEnd, chatOf, entryTalk, listTalks, openTalk, pickTalk, prepareTalk, startDesign, startTalk, stopTalk, talkEntry, talkId, talkLive, talkSaid, talkWaits, watchTalks, writeTalk, } from './talks.js';
|
|
29
29
|
import { accountSettings, saveAccountSettings, threadDir, threadOfEntry } from 'gcf-session';
|
|
30
30
|
const send = (res, status, body) => {
|
|
31
31
|
res.writeHead(status, { 'content-type': 'application/json; charset=utf-8' });
|
|
@@ -502,12 +502,12 @@ export function createApp(o) {
|
|
|
502
502
|
i.chat_card = chatCard(chat);
|
|
503
503
|
if (i.running_kind === 'run')
|
|
504
504
|
i.running_kind = mine.has(i.id) ? 'board' : 'console';
|
|
505
|
-
// A block for a refused
|
|
506
|
-
//
|
|
505
|
+
// A block for a refused call: the deny rule its run's last refusal named, for "Allow
|
|
506
|
+
// <rule> for one run" (docs/Permission-Stop-Plan.md, d3). Never git-history.
|
|
507
507
|
if (i.status === 'blocked' && /needs permission/.test(i.blocked ?? '')) {
|
|
508
|
-
const
|
|
509
|
-
if (
|
|
510
|
-
i.
|
|
508
|
+
const rule = deniedRuleIn(chat);
|
|
509
|
+
if (rule)
|
|
510
|
+
i.denied_rule = rule;
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
send(res, 200, { ...board, ...own });
|
|
@@ -1235,12 +1235,29 @@ export function createApp(o) {
|
|
|
1235
1235
|
const ids = runIds(body);
|
|
1236
1236
|
const fresh = body.fresh === true;
|
|
1237
1237
|
const agent = runAgent(body);
|
|
1238
|
+
if (body.allow !== undefined && !allowOf(body.allow))
|
|
1239
|
+
throw new HttpError(400, 'allow is a list of up to 8 one-line deny rules');
|
|
1240
|
+
const allow = allowOf(body.allow) ?? undefined;
|
|
1238
1241
|
// One run per mode: a main one queues behind the main run going, a worktree one starts.
|
|
1239
1242
|
const parts = Map.groupBy(ids, (id) => runModeOf(board, id, body.mode));
|
|
1240
1243
|
// Each part checks first: a refused one starts no other.
|
|
1241
1244
|
for (const part of parts.values())
|
|
1242
1245
|
busyCheck(p, part);
|
|
1243
|
-
const
|
|
1246
|
+
const start = () => [...parts].map(([mode, part]) => startRun(o.entry, p, part, mode, { fresh, harness, agent, allow }));
|
|
1247
|
+
// "Allow for one run" (Permission-Stop-Plan d3): the unblock and the start as one step,
|
|
1248
|
+
// the autopilot held off between them, so no run takes the card without its allowance.
|
|
1249
|
+
const started = body.unblock === true && allow
|
|
1250
|
+
? await whileAllowing(p.name, async () => {
|
|
1251
|
+
for (const id of ids) {
|
|
1252
|
+
const args = moveArgs({ cmd: 'unblock', id }, board.domain.moves);
|
|
1253
|
+
const r = await cli(p, args);
|
|
1254
|
+
if (!r.ok)
|
|
1255
|
+
throw new HttpError(409, `unblock ${id}: ${briefError(r.err)}`);
|
|
1256
|
+
}
|
|
1257
|
+
broadcast({ type: 'board', project: p.name });
|
|
1258
|
+
return start();
|
|
1259
|
+
})
|
|
1260
|
+
: start();
|
|
1244
1261
|
send(res, 202, {
|
|
1245
1262
|
started: started.flatMap((s) => s.started ?? []),
|
|
1246
1263
|
queued: started.flatMap((s) => s.queued ?? []),
|
package/dist/server/runs.js
CHANGED
|
@@ -122,6 +122,19 @@ const paused = new Set();
|
|
|
122
122
|
// The projects the operator holds (Hold-Plan d20): no queued or autopilot run starts; the
|
|
123
123
|
// operator's own Run goes at once. Apart from `paused`: Release resumes the queue, nothing else.
|
|
124
124
|
const projectHolds = new Set();
|
|
125
|
+
// Projects where the operator's "Allow for one run" unblocks a card (Permission-Stop-Plan d3):
|
|
126
|
+
// no autopilot run starts in the gap, or it would take the card without the allowance.
|
|
127
|
+
const allowing = new Set();
|
|
128
|
+
/** Hold off the autopilot while `fn` unblocks and starts a card with its allowance. */
|
|
129
|
+
export async function whileAllowing(project, fn) {
|
|
130
|
+
allowing.add(project);
|
|
131
|
+
try {
|
|
132
|
+
return await fn();
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
allowing.delete(project);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
125
138
|
// The paused projects whose pause the usage limit set: a run that ended paused by it (AD-19).
|
|
126
139
|
const limitPaused = new Set();
|
|
127
140
|
// When the usage limit that paused a project's queue resets, ISO; none when it was not one.
|
|
@@ -252,6 +265,16 @@ const WORD = /^[A-Za-z0-9][\w.-]*$/;
|
|
|
252
265
|
const isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
253
266
|
const list = (v) => (Array.isArray(v) ? v : []);
|
|
254
267
|
const pick = (v) => (typeof v === 'string' && WORD.test(v) ? v : null);
|
|
268
|
+
/**
|
|
269
|
+
* The deny rules a run goes without, or null: a short list of one-line rules. Whether each is a
|
|
270
|
+
* rule in force is the harness's check; here only what reaches its command line is bounded.
|
|
271
|
+
*/
|
|
272
|
+
export function allowOf(v) {
|
|
273
|
+
if (!Array.isArray(v) || !v.length || v.length > 8)
|
|
274
|
+
return null;
|
|
275
|
+
const ok = v.every((r) => typeof r === 'string' && r.trim() && r.length <= 200 && !/[\r\n]/.test(r));
|
|
276
|
+
return ok ? v : null;
|
|
277
|
+
}
|
|
255
278
|
/**
|
|
256
279
|
* A queued request as `queue.json` holds it, or null: its ids go to the harness's command line,
|
|
257
280
|
* so each must be an item id; its mode one of the two; its pick plain words.
|
|
@@ -274,6 +297,7 @@ function queuedOf(v) {
|
|
|
274
297
|
mode: v.mode,
|
|
275
298
|
harness: v.harness,
|
|
276
299
|
...(v.fresh === true ? { fresh: true } : {}),
|
|
300
|
+
...(allowOf(v.allow) ? { allow: allowOf(v.allow) } : {}),
|
|
277
301
|
...(v.waitLimit === true ? { waitLimit: true } : {}),
|
|
278
302
|
...(typeof v.waited === 'string' ? { waited: v.waited } : {}),
|
|
279
303
|
...(agent ? { agent } : {}),
|
|
@@ -610,6 +634,8 @@ function spawnRun(q, mode) {
|
|
|
610
634
|
if (q.kind !== 'card') {
|
|
611
635
|
if (q.fresh)
|
|
612
636
|
args.push('--fresh');
|
|
637
|
+
for (const rule of q.allow ?? [])
|
|
638
|
+
args.push('--allow', rule);
|
|
613
639
|
// This run's pick: the items keep their own (Board-V2-Data-Plan §2.5).
|
|
614
640
|
if (model)
|
|
615
641
|
args.push('--model', model);
|
|
@@ -933,8 +959,9 @@ export function busyCheck(p, ids) {
|
|
|
933
959
|
* `fresh` starts new agent sessions where the harness would resume the interrupted ones.
|
|
934
960
|
* `harness` is the domain's (`domain.harness`); the tests take GCF's. Its sessions are open to
|
|
935
961
|
* the operator's chat. `agent`: a model and effort for this run only, over each item's own.
|
|
962
|
+
* `allow`: deny rules in force this run goes without (docs/Permission-Stop-Plan.md, d2).
|
|
936
963
|
*/
|
|
937
|
-
export function startRun(entry, p, ids, mode = 'worktree', fresh = false, harness = 'gcf-harness', agent) {
|
|
964
|
+
export function startRun(entry, p, ids, mode = 'worktree', { fresh = false, harness = 'gcf-harness', agent, allow, } = {}) {
|
|
938
965
|
// A second click on the same card: the harness would refuse it on its lock, noisily.
|
|
939
966
|
paths.set(p.name, p.path);
|
|
940
967
|
busyCheck(p, ids);
|
|
@@ -944,12 +971,13 @@ export function startRun(entry, p, ids, mode = 'worktree', fresh = false, harnes
|
|
|
944
971
|
if (mode === 'main' && (held || going.some((r) => r.mode === 'main'))) {
|
|
945
972
|
queues.set(p.name, [
|
|
946
973
|
...(queues.get(p.name) ?? []),
|
|
947
|
-
{ entry, p, ids, mode, fresh, harness, agent },
|
|
974
|
+
{ entry, p, ids, mode, fresh, harness, agent, ...(allow?.length ? { allow } : {}) },
|
|
948
975
|
]);
|
|
949
976
|
changed(p.name);
|
|
950
977
|
return { queued: ids };
|
|
951
978
|
}
|
|
952
|
-
|
|
979
|
+
const q = { entry, p, ids, mode, fresh, harness, agent, ...(allow?.length ? { allow } : {}) };
|
|
980
|
+
return { started: spawnRun(q, mode) };
|
|
953
981
|
}
|
|
954
982
|
const pilots = new Map();
|
|
955
983
|
// The projects whose autopilot is asking the harness now: one ask at a time.
|
|
@@ -1097,8 +1125,10 @@ export const reserveText = (r) => r?.weekly
|
|
|
1097
1125
|
? "the quota is at its reserve: the automation stands until the week's reset"
|
|
1098
1126
|
: `the quota is at its reserve: the automation waits for the reset${r?.until ? ` at ${r.until}` : ''}`;
|
|
1099
1127
|
/** Whether the project is idle for the autopilot: no run, no queue to go, no pause. */
|
|
1100
|
-
|
|
1128
|
+
/** Whether nothing goes or waits in the project: the autopilot starts only then. */
|
|
1129
|
+
export const idle = (project) => !paused.has(project) &&
|
|
1101
1130
|
!projectHolds.has(project) &&
|
|
1131
|
+
!allowing.has(project) &&
|
|
1102
1132
|
!clickBuilding(project) &&
|
|
1103
1133
|
!activeRuns(project).length &&
|
|
1104
1134
|
!queues.get(project)?.some((q) => !q.waiting);
|
package/dist/server/talks.js
CHANGED
|
@@ -493,7 +493,7 @@ function eventsOf(td) {
|
|
|
493
493
|
return chatEvents(path.join(td, 'chat.jsonl'));
|
|
494
494
|
}
|
|
495
495
|
const runs = new Map();
|
|
496
|
-
const NONE = { stamp: '', card: null, end: null, denied: null,
|
|
496
|
+
const NONE = { stamp: '', card: null, end: null, denied: null, rule: null };
|
|
497
497
|
/** A run's chat file's facts, read again only when the file changed. */
|
|
498
498
|
function runChat(file) {
|
|
499
499
|
let stamp = '';
|
|
@@ -517,7 +517,7 @@ function runChat(file) {
|
|
|
517
517
|
card: cardIn(events),
|
|
518
518
|
end,
|
|
519
519
|
denied: lastDenied(events),
|
|
520
|
-
|
|
520
|
+
rule: deniedRuleOf(events),
|
|
521
521
|
};
|
|
522
522
|
runs.set(file, facts);
|
|
523
523
|
return facts;
|
|
@@ -526,8 +526,8 @@ function runChat(file) {
|
|
|
526
526
|
export const chatCard = (file) => runChat(file).card;
|
|
527
527
|
/** How the last run in a run's chat file ended (`run_end`), or null. */
|
|
528
528
|
export const lastRunEnd = (file) => runChat(file).end;
|
|
529
|
-
/** The deny
|
|
530
|
-
export const
|
|
529
|
+
/** The deny rule the last refusal of a run's chat file named (deniedRuleOf), or null. */
|
|
530
|
+
export const deniedRuleIn = (file) => runChat(file).rule;
|
|
531
531
|
/** The last call a deny rule refused in a run's chat file, or null. */
|
|
532
532
|
export const lastDeniedOf = (file) => runChat(file).denied;
|
|
533
533
|
/**
|
|
@@ -547,18 +547,23 @@ export function lastDenied(events) {
|
|
|
547
547
|
}
|
|
548
548
|
/** The events of a chat file: a thread's, or a run's `<id>.chat.jsonl`; none without one. */
|
|
549
549
|
/**
|
|
550
|
-
* The deny
|
|
551
|
-
*
|
|
552
|
-
*
|
|
550
|
+
* The deny rule the last session of a run's chat was refused by, for "Allow <rule> for one run"
|
|
551
|
+
* (docs/Permission-Stop-Plan.md, d3): its last refusal's, none from an older run, none when two
|
|
552
|
+
* rules held (the event names no rule then). Never a rule of a group that guards history or the
|
|
553
|
+
* operator's own moves.
|
|
553
554
|
*/
|
|
554
|
-
export function
|
|
555
|
+
export function deniedRuleOf(events) {
|
|
555
556
|
const start = events.findLastIndex((e) => e.type === 'session' && e.kind === 'start');
|
|
556
|
-
const
|
|
557
|
-
|
|
557
|
+
const last = events
|
|
558
|
+
.slice(Math.max(0, start))
|
|
559
|
+
.findLast((e) => e.type === 'denied' && e.by === 'rule');
|
|
560
|
+
const { rule, group } = (last ?? {});
|
|
561
|
+
if (!rule)
|
|
562
|
+
return null;
|
|
558
563
|
// `run-play`: a run builds by the harness, never by its agent (Play-Setup-Plan d32).
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
564
|
+
if (group && ['git-history', 'git-destroy', 'human-moves', 'run-play'].includes(group))
|
|
565
|
+
return null;
|
|
566
|
+
return group ? { rule, group } : { rule };
|
|
562
567
|
}
|
|
563
568
|
export function chatEvents(file) {
|
|
564
569
|
let text = '';
|