fwdloop 0.26.2 → 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/bin/fwdloop +46 -7
- package/package.json +2 -2
- package/src/authoring.js +21 -1
- package/src/canrun.js +23 -0
- package/src/config.js +18 -0
- package/src/declaration.js +129 -3
- package/src/drafter.js +38 -10
- package/src/flow.js +2 -1
- package/src/launcher.js +4 -2
- package/src/learnstore.js +3 -2
- package/src/mcp-checks.js +50 -0
- package/src/mcp-pick.js +33 -0
- package/src/mcp-sources.js +84 -0
- package/src/mcp-use.js +54 -0
- package/src/natural.js +23 -0
- package/src/panel/author.js +17 -1
- package/src/panel/authorcard.js +35 -0
- package/src/panel/authorflows.js +15 -6
- package/src/panel/authorstart.js +10 -6
- package/src/panel/authortrigger.js +263 -82
- package/src/panel/data.js +127 -9
- package/src/panel/index.html +945 -94
- package/src/panel/jobgrid.js +127 -0
- package/src/panel/scheduler.js +48 -6
- package/src/panel/server.js +33 -8
- package/src/panel/settings.js +119 -4
- package/src/panel/tickets.js +118 -0
- package/src/primitives.js +34 -5
- package/src/runner.js +129 -15
- package/src/schedule.js +5 -0
- package/src/summary-words.js +27 -7
- package/src/ticket-draft.js +85 -0
- package/src/ticket-labels.js +75 -0
- package/src/ticket-mcp.js +89 -0
- package/src/ticket-next.js +33 -0
- package/src/ticket-shape.js +33 -0
- package/src/trigger-clock.js +4 -4
- package/src/trigger-files.js +4 -4
- package/src/trigger-line.js +2 -1
- package/src/trigger-tickets.js +238 -0
- package/types/authoring.d.ts +5 -1
- package/types/canrun.d.ts +7 -0
- package/types/config.d.ts +6 -0
- package/types/declaration.d.ts +8 -0
- package/types/drafter.d.ts +552 -21
- package/types/mcp-checks.d.ts +8 -0
- package/types/mcp-pick.d.ts +23 -0
- package/types/mcp-sources.d.ts +51 -0
- package/types/mcp-use.d.ts +12 -0
- package/types/natural.d.ts +2 -0
- package/types/panel/author.d.ts +44 -0
- package/types/panel/authorcard.d.ts +11 -0
- package/types/panel/authorflows.d.ts +11 -1
- package/types/panel/authorstart.d.ts +3 -1
- package/types/panel/authortrigger.d.ts +83 -7
- package/types/panel/data.d.ts +78 -5
- package/types/panel/jobgrid.d.ts +109 -0
- package/types/panel/scheduler.d.ts +7 -2
- package/types/panel/server.d.ts +13 -2
- package/types/panel/settings.d.ts +3 -2
- package/types/panel/tickets.d.ts +103 -0
- package/types/primitives.d.ts +15 -2
- package/types/runner.d.ts +133 -75
- package/types/summary-words.d.ts +24 -4
- package/types/ticket-draft.d.ts +104 -0
- package/types/ticket-labels.d.ts +42 -0
- package/types/ticket-mcp.d.ts +57 -0
- package/types/ticket-next.d.ts +23 -0
- package/types/ticket-shape.d.ts +30 -0
- package/types/trigger-clock.d.ts +4 -3
- package/types/trigger-files.d.ts +3 -1
- package/types/trigger-line.d.ts +7 -0
- package/types/trigger-tickets.d.ts +105 -0
package/src/panel/authorflows.js
CHANGED
|
@@ -14,6 +14,8 @@ import { lstatSync, realpathSync } from 'node:fs';
|
|
|
14
14
|
import { join } from 'node:path';
|
|
15
15
|
|
|
16
16
|
import { scrub } from '../authoring.js';
|
|
17
|
+
import { ticketSourcesOf } from '../ticket-draft.js';
|
|
18
|
+
import { flowTypeOf } from '../declaration.js';
|
|
17
19
|
import { endRow, readHistory } from '../books.js';
|
|
18
20
|
import { canFlowRun, willNotRunSay } from '../canrun.js';
|
|
19
21
|
import { loadCatalogue } from '../catalogue.js';
|
|
@@ -298,11 +300,11 @@ export function createFlowsDoor(opts) {
|
|
|
298
300
|
const last = lastSources(flowDir, roles, pageAddressesOf(read.arbiter));
|
|
299
301
|
const { passed, stats } = runsOf(flowDir, name, read, roles);
|
|
300
302
|
return {
|
|
301
|
-
flow: name, capUsd: read.arbiter.capUsd, roles, pages: pageAddressesOf(read.arbiter), nextRunId: nextRunId(flowDir), lastRunId: last.runId, lastSources: last.sources, leftThisMonth: left,
|
|
303
|
+
flow: name, capUsd: read.arbiter.capUsd, roles, pages: pageAddressesOf(read.arbiter), tickets: flowTypeOf(read.declaration) === 'tickets' ? ticketSourcesOf(read.arbiter.sources).map((x) => x.role) : [], flowType: flowTypeOf(read.declaration), mcp: read.declaration?.mcp?.server ?? null, nextRunId: nextRunId(flowDir), lastRunId: last.runId, lastSources: last.sources, leftThisMonth: left,
|
|
302
304
|
runs: passed, stats,
|
|
303
305
|
...formFacts(read, home, flowDir),
|
|
304
306
|
// M6 am5/am6: the job as the card Reuse workflow opens (`ok:true, card`), or why the card cannot hold it (`ok:false, say`). Nothing blocks it: a reuse never changes the job it is opened from.
|
|
305
|
-
edit: (() => { const c = cardFromSigned(read); return c.ok ? { ok: true, card: c.card } : c; })(),
|
|
307
|
+
edit: (() => { const c = cardFromSigned(read); return c.ok ? { ok: true, card: { ...c.card, ...(flowTypeOf(read.declaration) === 'plain' ? {} : { flowType: flowTypeOf(read.declaration), mcp: read.declaration?.mcp?.server ?? '' }) } } : c; })(),
|
|
306
308
|
};
|
|
307
309
|
}
|
|
308
310
|
|
|
@@ -320,7 +322,7 @@ export function createFlowsDoor(opts) {
|
|
|
320
322
|
},
|
|
321
323
|
|
|
322
324
|
/**
|
|
323
|
-
* M6 am9: is this run red, as the panel's glyph rule reads it (`[✗]` and nothing else; stopped `[■]` and waiting are not)? The server decides this itself,
|
|
325
|
+
* M6 am9: is this run red, as the panel's glyph rule reads it (`[✗]` and nothing else; stopped `[■]` and waiting are not; M13 9b.2: not a run that failed preflight)? The server decides this itself,
|
|
324
326
|
* never from the page's word. False for a run that does not resolve.
|
|
325
327
|
* @param {string} flow @param {unknown} runId
|
|
326
328
|
*/
|
|
@@ -329,7 +331,10 @@ export function createFlowsDoor(opts) {
|
|
|
329
331
|
if (realRoot === null || !checkFlowName(flow).ok || typeof runId !== 'string' || runId === '') return false;
|
|
330
332
|
const cat = loadCatalogue();
|
|
331
333
|
if (!cat.ok) return false;
|
|
332
|
-
|
|
334
|
+
if (getRunGlyph({ root: realRoot, flow, runId, catalogue: cat.primitives })?.glyph !== '[✗]') return false;
|
|
335
|
+
// M13 item 9b.2: a run that failed preflight never ran its plan (no step, $0), so its plan did not fail: reusing it unchanged is Run now, not a paid redraft
|
|
336
|
+
const end = endRow(readHistory(join(realRoot, flow)), join(realRoot, flow, 'runs', runId), runId);
|
|
337
|
+
return end?.outcome !== 'preflight-red';
|
|
333
338
|
},
|
|
334
339
|
|
|
335
340
|
/**
|
|
@@ -351,11 +356,15 @@ export function createFlowsDoor(opts) {
|
|
|
351
356
|
* @param {any} body
|
|
352
357
|
*/
|
|
353
358
|
reuseCheck(body) {
|
|
354
|
-
|
|
359
|
+
// M13 am4 item 1: `flowType` and `mcp` are job fields like the lines; read here, never reach the run door. An absent field = unchanged; plain has no server.
|
|
360
|
+
const { job, fromRun, flowType, mcp, ...rest } = body && typeof body === 'object' ? body : /** @type {any} */ ({});
|
|
355
361
|
const realRoot = realRootOrNull();
|
|
356
362
|
if (realRoot !== null && typeof job === 'string' && typeof rest.flow === 'string' && checkFlowName(rest.flow).ok) {
|
|
357
363
|
const read = readSigned(realRoot, rest.flow);
|
|
358
|
-
|
|
364
|
+
const signedType = read.ok ? flowTypeOf(read.declaration) : 'plain';
|
|
365
|
+
const typeChanged = typeof flowType === 'string' && flowType !== signedType;
|
|
366
|
+
const mcpChanged = typeof mcp === 'string' && (flowType ?? signedType) !== 'plain' && mcp !== (read.ok ? read.declaration?.mcp?.server ?? '' : '');
|
|
367
|
+
if (read.ok && (jobKeyOfCard(job) !== jobKeyOfSigned(read) || typeChanged || mcpChanged)) {
|
|
359
368
|
return { status: 200, body: { ok: true, kind: 'draft', suggestedName: suggestFlowName(realRoot, rest.flow) } };
|
|
360
369
|
}
|
|
361
370
|
// M6 am9: a RED run always drafts. The job is unchanged here, so the new plan is the next run of the SAME workflow (no new name). Only `[✗]` is red.
|
package/src/panel/authorstart.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// starting the child is alive and the run dir has no book row yet
|
|
17
17
|
// started the run dir has its first book row (`pids.jsonl`, written by the run itself before its first step); `state` is
|
|
18
18
|
// working / parked / ended from `runLiveness` + `ask.json` (M4c's one "is it running?" rule), never a timer
|
|
19
|
-
// refused the child is dead and the run dir never got a book row: `say` = the CLI's own sentence (scrubbed) + "Nothing spent."
|
|
19
|
+
// refused the child is dead and the run dir never got a book row (a skipped run's history row counts as one, it ended): `say` = the CLI's own sentence (scrubbed) + "Nothing spent."
|
|
20
20
|
//
|
|
21
21
|
// One click, one start: `start` is fully synchronous (check -> mkdir -> spawn -> write pid.json, no await), so two requests that
|
|
22
22
|
// arrive together run one after the other and the second sees the first's `starting` start and is refused.
|
|
@@ -29,7 +29,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
29
29
|
|
|
30
30
|
import { loadCatalogue } from '../catalogue.js';
|
|
31
31
|
import { scrub } from '../authoring.js';
|
|
32
|
-
import { readPidRows } from '../books.js';
|
|
32
|
+
import { readHistory, readPidRows } from '../books.js';
|
|
33
33
|
import {
|
|
34
34
|
PANEL_STARTS_DIR, checkRunId, claimRunId, freeRunId, readFileInside, readdirInside, resolveRunDir, runOwnsPlan, copyRunPlan, RUN_PLAN_MARKER,
|
|
35
35
|
} from '../flow.js';
|
|
@@ -77,7 +77,8 @@ export function createStarter(opts) {
|
|
|
77
77
|
const st = readJsonFile(dir, 'start.json');
|
|
78
78
|
if (!st || typeof st.flow !== 'string' || typeof st.runId !== 'string') return null;
|
|
79
79
|
const base = { startId: id, kind: st.kind, flow: st.flow, runId: st.runId };
|
|
80
|
-
const
|
|
80
|
+
const flowDir = join(realpathSync(root), st.flow);
|
|
81
|
+
const resolved = resolveRunDir(flowDir, st.runId);
|
|
81
82
|
if (!resolved.ok) return null;
|
|
82
83
|
// alive FIRST, then the book row: a child that writes its row and exits between the two reads as started, never refused
|
|
83
84
|
const alive = childRunning(dir);
|
|
@@ -97,6 +98,8 @@ export function createStarter(opts) {
|
|
|
97
98
|
} else if (readPidRows(resolved.runDir).length > 0) {
|
|
98
99
|
return { ...base, phase: 'started', state: carriedOn() };
|
|
99
100
|
} else if (alive) return { ...base, phase: 'starting' };
|
|
101
|
+
// a SKIPPED run (hamr 2026-10-30) ends before its first pid row, but its history row is a real ending: a grey one, never a refusal
|
|
102
|
+
if (readHistory(flowDir).some((h) => h.runId === st.runId && h.outcome === 'skipped')) return { ...base, phase: 'started', state: 'ended' };
|
|
100
103
|
const log = readFileInside(dir, 'child.log');
|
|
101
104
|
const tail = log.ok ? scrub(log.text, keys).trim().slice(-LOG_TAIL_CHARS).replace(/^fwdloop: /, '') : '';
|
|
102
105
|
const say = tail === '' ? ENDED_SAY : (tail.includes(NOTHING_SPENT) ? tail : `${tail}\n${NOTHING_SPENT}`);
|
|
@@ -171,7 +174,7 @@ export function createStarter(opts) {
|
|
|
171
174
|
* folder as `signed-values.json` BEFORE the spawn; the run then uses them (`pickRunValues`). None = the flow's own.
|
|
172
175
|
* `trigger` (M9): `{kind, reason, catchUp, ...}` for a start a trigger fired (kind 'trigger'): written once into the run's own folder as `trigger.json`
|
|
173
176
|
* BEFORE the spawn; `appendHistory` copies it into the run's history row (the catch-up mark, am2 item 1).
|
|
174
|
-
* @param {{ kind: 'run'|'sign'|'trigger', flow: string, runId: string, sources: {role: string, path: string}[], planRun?: boolean, planOf?: string|null, values?: any, pick?: {slot: string, model: string}|null, trigger?: Record<string, any>|null }} a
|
|
177
|
+
* @param {{ kind: 'run'|'sign'|'trigger', flow: string, runId: string, sources: {role: string, path: string, ticket?: number, anyway?: boolean}[], planRun?: boolean, planOf?: string|null, values?: any, pick?: {slot: string, model: string}|null, trigger?: Record<string, any>|null }} a
|
|
175
178
|
* @param {{ env: Record<string, string|undefined>, keyNames?: string[] }} loaded the keys load: its env is the child's env AND (with its key names) the scrub list
|
|
176
179
|
* @returns {{ status: number, body: any }}
|
|
177
180
|
*/
|
|
@@ -230,7 +233,8 @@ export function createStarter(opts) {
|
|
|
230
233
|
writeFileSync(join(dir, 'start.json'), `${JSON.stringify({
|
|
231
234
|
kind, flow, runId, sources, startedAt: new Date().toISOString(),
|
|
232
235
|
}, null, 2)}\n`, { mode: 0o600 });
|
|
233
|
-
|
|
236
|
+
// M12: `--ticket N` (the one ticket of the list this run reads) follows the sources
|
|
237
|
+
const argv = ['run', flow, '--root', realpathSync(root), ...sources.flatMap((s) => ['--source', `${s.role}=${s.path}`]), ...sources.flatMap((s) => (s.ticket === undefined ? [] : ['--ticket', String(s.ticket), ...(s.anyway === true ? ['--anyway'] : [])])), '--run-id', runId, ...(pick ? ['--model', pick.model, '--provider', pick.slot] : [])]; // M4d am7b: a flow with no record runs with the model picked in Chat
|
|
234
238
|
let child;
|
|
235
239
|
try {
|
|
236
240
|
child = spawnDetached({
|
|
@@ -290,7 +294,7 @@ export function createStarter(opts) {
|
|
|
290
294
|
for (const id of readdirInside(sd, '.').filter((n) => ID_RE.test(n)).sort().reverse()) {
|
|
291
295
|
if (readFileInside(join(sd, id), 'cleared.json').ok) continue;
|
|
292
296
|
const v = readStart(join(sd, id), id, keys);
|
|
293
|
-
if (v === null) continue;
|
|
297
|
+
if (v === null || v.kind === 'trigger') continue; // the Chat card never shows a start it did not make
|
|
294
298
|
return v.phase === 'started' ? null : v;
|
|
295
299
|
}
|
|
296
300
|
return null;
|