frizz-server 0.15.41 → 0.15.42
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/dev-child.js +1156 -367
- package/package.json +1 -1
- package/runtime/cc-worker/bin/frizzctl.mjs +1 -1
- package/runtime/cc-worker/lib/frizz-tools.mjs +302 -7
- package/web-dist/assets/{abnfDiagram-VRR7QNED-DZgIn5ff.js → abnfDiagram-VRR7QNED-R4fnqpL_.js} +1 -1
- package/web-dist/assets/{arc-DwPpA8R3.js → arc-D7SIyyY_.js} +1 -1
- package/web-dist/assets/architecture-TIHT7OUA-CiN6_7kZ.js +1 -0
- package/web-dist/assets/{architectureDiagram-ZJ3FMSHR-DbP9lkjM.js → architectureDiagram-ZJ3FMSHR-D22HkIR4.js} +1 -1
- package/web-dist/assets/{blockDiagram-677ZJIJ3-DwQN1M8B.js → blockDiagram-677ZJIJ3-BYSQJXJL.js} +1 -1
- package/web-dist/assets/{c4Diagram-LMCZKHZV-BF5QrD37.js → c4Diagram-LMCZKHZV-SjlUwA7R.js} +1 -1
- package/web-dist/assets/channel-DMQMWHKq.js +1 -0
- package/web-dist/assets/{chunk-32BRIVSS-CA8c9JxF.js → chunk-32BRIVSS-B6CWPyBg.js} +1 -1
- package/web-dist/assets/{chunk-52WLFC77-CdYcy5t0.js → chunk-52WLFC77-CPot8sRW.js} +1 -1
- package/web-dist/assets/{chunk-C7G6YPKG-4uxANQmd.js → chunk-C7G6YPKG-yG-A9TmK.js} +1 -1
- package/web-dist/assets/{chunk-EX3LRPZG-4wMgoywY.js → chunk-EX3LRPZG-UAuz2xkd.js} +1 -1
- package/web-dist/assets/{chunk-FWX5IMBZ-BH3kLM9J.js → chunk-FWX5IMBZ-CSJBWLcY.js} +2 -2
- package/web-dist/assets/{chunk-HOUHSVGY-C6s3cxko.js → chunk-HOUHSVGY-CGGIln55.js} +1 -1
- package/web-dist/assets/{chunk-ICXQ74PX-9fUt4TuP.js → chunk-ICXQ74PX-DPvO3p3l.js} +1 -1
- package/web-dist/assets/{chunk-MOJQB5TN-CXZbnRJB.js → chunk-MOJQB5TN-cR_XVznl.js} +1 -1
- package/web-dist/assets/{chunk-OGEWGWER-kBUaZg1h.js → chunk-OGEWGWER-DgJ4Na7c.js} +1 -1
- package/web-dist/assets/{chunk-PUDLZKDR-T8I9vJeW.js → chunk-PUDLZKDR-PVkKiizt.js} +1 -1
- package/web-dist/assets/{chunk-Q4XR5HBZ-Bc1e-VQ6.js → chunk-Q4XR5HBZ-BiE_9prp.js} +1 -1
- package/web-dist/assets/{chunk-RYQCIY6F-ExoEx5xU.js → chunk-RYQCIY6F-Dfd2lI97.js} +1 -1
- package/web-dist/assets/{chunk-V7JOEXUC-BejALgmS.js → chunk-V7JOEXUC-MSd34shk.js} +1 -1
- package/web-dist/assets/{chunk-VAUOI2AC-DCxTR7U8.js → chunk-VAUOI2AC-_LdsfMm9.js} +1 -1
- package/web-dist/assets/{chunk-VR4S4FIN-BukySeYi.js → chunk-VR4S4FIN-DgNM8Q2U.js} +1 -1
- package/web-dist/assets/{chunk-WYO6CB5R-Bws7hxsV.js → chunk-WYO6CB5R-DvwyN_Z1.js} +1 -1
- package/web-dist/assets/{chunk-XXDRQBXY-DjA78QDQ.js → chunk-XXDRQBXY-C0vY3rJT.js} +1 -1
- package/web-dist/assets/{chunk-ZGVPDNZ5-DKIh9xod.js → chunk-ZGVPDNZ5-Ca-iIrGH.js} +1 -1
- package/web-dist/assets/classDiagram-OUVF2IWQ-DTyv6Ys_.js +1 -0
- package/web-dist/assets/classDiagram-v2-EOCWNBFH-DTyv6Ys_.js +1 -0
- package/web-dist/assets/{cose-bilkent-JH36ORCC-C9L1n6fr.js → cose-bilkent-JH36ORCC-BLE-b6JZ.js} +1 -1
- package/web-dist/assets/{cynefin-VYW2F7L2-DI26e4Tc.js → cynefin-VYW2F7L2-DbgUjSrw.js} +1 -1
- package/web-dist/assets/{cynefinDiagram-TSTJHNR4-Cp57PoPj.js → cynefinDiagram-TSTJHNR4-DRmXMjB5.js} +1 -1
- package/web-dist/assets/{dagre-VKFMJZFB-DBADVTqD.js → dagre-VKFMJZFB-BXVJTmZ5.js} +1 -1
- package/web-dist/assets/{diagram-FQU43EPY-0HlOV1mt.js → diagram-FQU43EPY-NURkTSwG.js} +1 -1
- package/web-dist/assets/{diagram-G47NLZAW-DgR5-Pxg.js → diagram-G47NLZAW-Cj3RSicU.js} +1 -1
- package/web-dist/assets/{diagram-NH7WQ7WH-DoGKoxYE.js → diagram-NH7WQ7WH-WL3LSlQV.js} +1 -1
- package/web-dist/assets/{diagram-OA4YK3LP-D5GrLhaq.js → diagram-OA4YK3LP-BDgiFton.js} +1 -1
- package/web-dist/assets/{diagram-WEI45ONY-DPj7-RdX.js → diagram-WEI45ONY-fOXZHugt.js} +1 -1
- package/web-dist/assets/{dist-Bo2PwwGZ.js → dist-CdXepqKz.js} +1 -1
- package/web-dist/assets/{ebnfDiagram-CCIWWBDH-DIXYEkGD.js → ebnfDiagram-CCIWWBDH-C3rumWt2.js} +1 -1
- package/web-dist/assets/{erDiagram-Q63AITRT-Dg3MGwWR.js → erDiagram-Q63AITRT-fXC5vjIx.js} +1 -1
- package/web-dist/assets/eventmodeling-45OFAUF4-O_wbqgIy.js +1 -0
- package/web-dist/assets/flowDiagram-23GEKE2U-DPWulizP.js +1 -0
- package/web-dist/assets/{ganttDiagram-NO4QXBWP-BIcCVXZQ.js → ganttDiagram-NO4QXBWP-C_YYhYTS.js} +1 -1
- package/web-dist/assets/{gitGraph-TEB2WS4Q-B5RytoFn.js → gitGraph-TEB2WS4Q-BzIRwr8p.js} +1 -1
- package/web-dist/assets/{gitGraphDiagram-IHSO6WYX-Cb-dT-cW.js → gitGraphDiagram-IHSO6WYX-BOAG2hkd.js} +1 -1
- package/web-dist/assets/index-BZoI3aqA.css +2 -0
- package/web-dist/assets/{index-B5PLhSPz.js → index-CfGKCD_6.js} +120 -117
- package/web-dist/assets/{info-DKCQHKI2-GIyDtSFf.js → info-DKCQHKI2-DiYenczO.js} +1 -1
- package/web-dist/assets/{infoDiagram-FWYZ7A6U-hajuuFGe.js → infoDiagram-FWYZ7A6U-bY5uPyPk.js} +1 -1
- package/web-dist/assets/{ishikawaDiagram-FXEZZL3T-DFX-Hnma.js → ishikawaDiagram-FXEZZL3T-XWRtGb2K.js} +1 -1
- package/web-dist/assets/{journeyDiagram-5HDEW3XC-DCAhU4Cx.js → journeyDiagram-5HDEW3XC-CHNPHjLQ.js} +1 -1
- package/web-dist/assets/{kanban-definition-HUTT4EX6-C3WHlUdK.js → kanban-definition-HUTT4EX6-DyZmBgdz.js} +1 -1
- package/web-dist/assets/{line-CSYf7CnT.js → line-B7I8Db8G.js} +1 -1
- package/web-dist/assets/{linear-Di1L0vVF.js → linear-BYlHJE0j.js} +1 -1
- package/web-dist/assets/{mermaid-parser.core-CudEuGod.js → mermaid-parser.core-1DKULFlf.js} +3 -3
- package/web-dist/assets/{mermaid.core-D2s3bQBM.js → mermaid.core-DS92P-bA.js} +3 -3
- package/web-dist/assets/{mindmap-definition-LN4V7U3C-yXCjhQFg.js → mindmap-definition-LN4V7U3C-CDhSXmFL.js} +1 -1
- package/web-dist/assets/{packet-7NZHBO7P-3EcXllio.js → packet-7NZHBO7P-gxHCLGcb.js} +1 -1
- package/web-dist/assets/{pegDiagram-2B236MQR-CvS28grz.js → pegDiagram-2B236MQR-B2WHH9TM.js} +1 -1
- package/web-dist/assets/{pie-RZYD4A2V-CAmA2Snx.js → pie-RZYD4A2V-CJfSfoox.js} +1 -1
- package/web-dist/assets/{pieDiagram-ENE6RG2P-BYuB33BI.js → pieDiagram-ENE6RG2P-Cg0kblQs.js} +1 -1
- package/web-dist/assets/{quadrantDiagram-ABIIQ3AL-CDnklrlY.js → quadrantDiagram-ABIIQ3AL-BEF0HFg0.js} +1 -1
- package/web-dist/assets/{radar-I7S5WNFK-Bz7Vyy1A.js → radar-I7S5WNFK-BD-NCKAZ.js} +1 -1
- package/web-dist/assets/{railroad-3IZDKUUU-CAUAJCaq.js → railroad-3IZDKUUU-6euojYMA.js} +1 -1
- package/web-dist/assets/railroad-abnf-AHOZXSZD-BxRR4FEv.js +1 -0
- package/web-dist/assets/railroad-ebnf-EBAXGLYW-DYynHpjS.js +1 -0
- package/web-dist/assets/railroad-peg-LSFZ7HO6-wOmjP52W.js +1 -0
- package/web-dist/assets/{railroadDiagram-RFXS5EU6-DZaYV9Io.js → railroadDiagram-RFXS5EU6-CXsPEV9p.js} +1 -1
- package/web-dist/assets/{requirementDiagram-TGXJPOKE-BFlpQunS.js → requirementDiagram-TGXJPOKE-m_jpRKM1.js} +1 -1
- package/web-dist/assets/{sankeyDiagram-HTMAVEWB-DIOr2M-C.js → sankeyDiagram-HTMAVEWB-cvi4BPq1.js} +1 -1
- package/web-dist/assets/{sequenceDiagram-DBY2YBRQ-DpYJiT1u.js → sequenceDiagram-DBY2YBRQ-tRc--AQc.js} +1 -1
- package/web-dist/assets/{src-BkVLS0R9.js → src-CkPXvRdk.js} +1 -1
- package/web-dist/assets/{stateDiagram-2N3HPSRC-C4UYGg5g.js → stateDiagram-2N3HPSRC-DpFbxWsG.js} +1 -1
- package/web-dist/assets/stateDiagram-v2-6OUMAXLB-CrP44Mxj.js +1 -0
- package/web-dist/assets/{swimlanes-5IMT3BWC-cJ6KOezW.js → swimlanes-5IMT3BWC-CmuQ3olM.js} +1 -1
- package/web-dist/assets/swimlanesDiagram-G3AALYLV-gsPqoddO.js +8 -0
- package/web-dist/assets/{timeline-definition-FHXFAJF6-yi-2X9QL.js → timeline-definition-FHXFAJF6-yuDa2CuK.js} +1 -1
- package/web-dist/assets/{treeView-QDETBFTQ-Bnlc02cs.js → treeView-QDETBFTQ-rO5Wh8Eu.js} +1 -1
- package/web-dist/assets/{treemap-6X3UGDF4-DUWj2eOS.js → treemap-6X3UGDF4-wNat2V0h.js} +1 -1
- package/web-dist/assets/{vennDiagram-L72KCM5P-jPHNRI-h.js → vennDiagram-L72KCM5P-CNDV0uDF.js} +1 -1
- package/web-dist/assets/{wardley-OPB4EBWU-CPbgZ6M1.js → wardley-OPB4EBWU-Bahki8cs.js} +1 -1
- package/web-dist/assets/{wardleyDiagram-EHGQE667-CrExyaRO.js → wardleyDiagram-EHGQE667-B87eSsOa.js} +1 -1
- package/web-dist/assets/{xychartDiagram-FW5EYKEG-CN06Wt1I.js → xychartDiagram-FW5EYKEG-Cajd3Ik6.js} +1 -1
- package/web-dist/index.html +2 -2
- package/web-dist/assets/architecture-TIHT7OUA-DaAFvFkn.js +0 -1
- package/web-dist/assets/channel-B1iPbzai.js +0 -1
- package/web-dist/assets/classDiagram-OUVF2IWQ-DQlurrbL.js +0 -1
- package/web-dist/assets/classDiagram-v2-EOCWNBFH-DQlurrbL.js +0 -1
- package/web-dist/assets/eventmodeling-45OFAUF4-CeTMJyik.js +0 -1
- package/web-dist/assets/flowDiagram-23GEKE2U-QhaJlS-W.js +0 -1
- package/web-dist/assets/index-D_uxez2a.css +0 -2
- package/web-dist/assets/railroad-abnf-AHOZXSZD-B9RdcI3r.js +0 -1
- package/web-dist/assets/railroad-ebnf-EBAXGLYW-Cimw_4Xu.js +0 -1
- package/web-dist/assets/railroad-peg-LSFZ7HO6-DJTpn0sf.js +0 -1
- package/web-dist/assets/stateDiagram-v2-6OUMAXLB-CO0mbUgI.js +0 -1
- package/web-dist/assets/swimlanesDiagram-G3AALYLV-AkPUIZ-W.js +0 -8
package/dist/dev-child.js
CHANGED
|
@@ -14398,6 +14398,58 @@ function commandWatchCancelledWakeMessage(input) {
|
|
|
14398
14398
|
COMMAND_WATCH_CANCELLED_TRAILER
|
|
14399
14399
|
].join("\n");
|
|
14400
14400
|
}
|
|
14401
|
+
function monitorLabel(input) {
|
|
14402
|
+
const described = input.description?.trim().replace(/\s+/g, " ");
|
|
14403
|
+
if (described) return described;
|
|
14404
|
+
const command = input.command.trim().replace(/\s+/g, " ");
|
|
14405
|
+
return command.length > 80 ? `${command.slice(0, 79)}\u2026` : command;
|
|
14406
|
+
}
|
|
14407
|
+
function monitorEventWakeMessage(input) {
|
|
14408
|
+
const shown = input.lines.length;
|
|
14409
|
+
const more = input.more ?? 0;
|
|
14410
|
+
const total = shown + more;
|
|
14411
|
+
return [
|
|
14412
|
+
`\u{1F4DF} Your monitor \`${input.id}\` printed ${total} line${total === 1 ? "" : "s"} (event ${input.event}) \u2014 ${input.label}`,
|
|
14413
|
+
"",
|
|
14414
|
+
codeBlock(input.lines.join("\n")),
|
|
14415
|
+
...more > 0 ? ["", `\u2026and ${more} more line${more === 1 ? "" : "s"} in the same burst, not shown.`] : [],
|
|
14416
|
+
"",
|
|
14417
|
+
MONITOR_EVENT_TRAILER.replace("<id>", input.id)
|
|
14418
|
+
].join("\n");
|
|
14419
|
+
}
|
|
14420
|
+
function monitorExitedWakeMessage(input) {
|
|
14421
|
+
const how = input.run.outcome === "exit" ? `exited ${input.run.exitCode ?? "?"}` : input.run.outcome === "error" ? "could not be started" : "was killed by a signal";
|
|
14422
|
+
const output = input.run.output.trim();
|
|
14423
|
+
return [
|
|
14424
|
+
`\u23F9\uFE0F Your monitor \`${input.id}\` ${how} after ${input.events} event${input.events === 1 ? "" : "s"} and is no longer armed \u2014 ${input.label}`,
|
|
14425
|
+
"",
|
|
14426
|
+
codeBlock(input.command, "sh"),
|
|
14427
|
+
"",
|
|
14428
|
+
output ? `Its output ended (stderr included):
|
|
14429
|
+
|
|
14430
|
+
${codeBlock(output)}` : "It printed nothing more.",
|
|
14431
|
+
"",
|
|
14432
|
+
MONITOR_EXITED_TRAILER
|
|
14433
|
+
].join("\n");
|
|
14434
|
+
}
|
|
14435
|
+
function monitorExpiredWakeMessage(input) {
|
|
14436
|
+
return [
|
|
14437
|
+
`\u23F0 Your monitor \`${input.id}\` ran out its \`for\` after ${input.events} event${input.events === 1 ? "" : "s"} and was stopped \u2014 ${input.label}`,
|
|
14438
|
+
"",
|
|
14439
|
+
codeBlock(input.command, "sh"),
|
|
14440
|
+
"",
|
|
14441
|
+
MONITOR_EXPIRED_TRAILER
|
|
14442
|
+
].join("\n");
|
|
14443
|
+
}
|
|
14444
|
+
function monitorCancelledWakeMessage(input) {
|
|
14445
|
+
return [
|
|
14446
|
+
`\u26A0\uFE0F Frizz stopped your monitor \`${input.id}\` after ${input.events} event${input.events === 1 ? "" : "s"}: ${input.reason}`,
|
|
14447
|
+
"",
|
|
14448
|
+
codeBlock(input.command, "sh"),
|
|
14449
|
+
"",
|
|
14450
|
+
MONITOR_CANCELLED_TRAILER
|
|
14451
|
+
].join("\n");
|
|
14452
|
+
}
|
|
14401
14453
|
function questionFencesLive(spawnedAt) {
|
|
14402
14454
|
if (spawnedAt === void 0 || spawnedAt === null) return true;
|
|
14403
14455
|
const at2 = typeof spawnedAt === "number" ? spawnedAt : Date.parse(spawnedAt);
|
|
@@ -14573,6 +14625,38 @@ function activeBandThreadAt(t, nowMs) {
|
|
|
14573
14625
|
if (t.kind !== "session" || t.foreign === true) return false;
|
|
14574
14626
|
return sectionAt(t, nowMs) === "active" && inActiveBand(t);
|
|
14575
14627
|
}
|
|
14628
|
+
function displayTitle(t) {
|
|
14629
|
+
if (t.foreign === true && t.title.trim()) return t.title.trim();
|
|
14630
|
+
if (titleIsProvisional(t)) return SPINNING_UP_TITLE;
|
|
14631
|
+
if (t.aiTitle?.trim() && !titleIsHumanOwned(t)) return readableMachineTitle(t.aiTitle);
|
|
14632
|
+
if (t.backend === "codex" && t.titleAuto === true && !t.aiTitle?.trim()) return UNTITLED_THREAD_TITLE;
|
|
14633
|
+
if (t.titleAuto === false && t.title.trim()) return t.title;
|
|
14634
|
+
if (t.title.trim() && !(t.titleAuto === true && t.title.trim() === t.id)) {
|
|
14635
|
+
return t.titleAuto === true ? readableMachineTitle(t.title) : t.title.trim();
|
|
14636
|
+
}
|
|
14637
|
+
return t.titleAuto === true ? UNTITLED_THREAD_TITLE : t.id;
|
|
14638
|
+
}
|
|
14639
|
+
function titleIsHumanOwned(t) {
|
|
14640
|
+
return t.titleLocked ?? t.titleAuto === false;
|
|
14641
|
+
}
|
|
14642
|
+
function readableMachineTitle(raw2) {
|
|
14643
|
+
const title = raw2.trim();
|
|
14644
|
+
if (!/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/i.test(title)) return title;
|
|
14645
|
+
const words = title.split(/[-_]+/).filter(Boolean);
|
|
14646
|
+
if (words.length === 0) return title;
|
|
14647
|
+
const joined = words.join(" ").toLowerCase();
|
|
14648
|
+
return joined.charAt(0).toUpperCase() + joined.slice(1);
|
|
14649
|
+
}
|
|
14650
|
+
function titleIsProvisional(t) {
|
|
14651
|
+
if (!t.titleAuto || t.aiTitle) return false;
|
|
14652
|
+
if (t.backend === "codex") {
|
|
14653
|
+
if (t.runtime === "spawning") return true;
|
|
14654
|
+
const spawned2 = Date.parse(t.spawnedAt ?? "");
|
|
14655
|
+
return Number.isFinite(spawned2) && Date.now() - spawned2 < CODEX_TITLE_SIGNAL_GRACE_MS;
|
|
14656
|
+
}
|
|
14657
|
+
const spawned = Date.parse(t.spawnedAt ?? "");
|
|
14658
|
+
return Number.isFinite(spawned) && Date.now() - spawned < SPIN_UP_MS;
|
|
14659
|
+
}
|
|
14576
14660
|
function hasStandingQuestion(t) {
|
|
14577
14661
|
return (t.questions ?? []).some((q2) => q2.standing !== false);
|
|
14578
14662
|
}
|
|
@@ -14598,6 +14682,14 @@ function requireEffortOutsideAcp(profile, ctx) {
|
|
|
14598
14682
|
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["effort"], message: `effort is required for a ${profile.backend} profile` });
|
|
14599
14683
|
}
|
|
14600
14684
|
}
|
|
14685
|
+
function threadBandAt(t, nowMs) {
|
|
14686
|
+
if (t.kind !== "session" || t.foreign === true) return null;
|
|
14687
|
+
const section = sectionAt(t, nowMs);
|
|
14688
|
+
if (section === "inactive") return "done";
|
|
14689
|
+
if (section === "snoozed") return "snoozed";
|
|
14690
|
+
if (section === "active") return inActiveBand(t) ? "active" : "rested";
|
|
14691
|
+
return null;
|
|
14692
|
+
}
|
|
14601
14693
|
function formatElapsed(ms) {
|
|
14602
14694
|
if (!Number.isFinite(ms) || ms < 0) return "an unknown time";
|
|
14603
14695
|
const s = Math.floor(ms / 1e3);
|
|
@@ -14846,7 +14938,7 @@ function parseGithubWakeSteer(text2) {
|
|
|
14846
14938
|
function frizzRoute(path3) {
|
|
14847
14939
|
return `${FRIZZ_ROUTE_PREFIX}${path3.startsWith("/") ? path3 : `/${path3}`}`;
|
|
14848
14940
|
}
|
|
14849
|
-
var import_yaml2, ATTACHMENT_IMAGE_EXTENSIONS, ATTACHMENT_TEXT_EXTENSIONS, ATTACHMENT_OFFICE_EXTENSIONS, ATTACHMENT_DATA_EXTENSIONS, ATTACHMENT_ARCHIVE_EXTENSIONS, ATTACHMENT_DOC_EXTENSIONS, ATTACHMENT_EXTENSIONS, ATTACHMENT_MAX_BASE64_CHARS, ATTACHMENT_MAX_BYTES, ATTACHMENT_EXT_SET, ATTACHMENT_ACCEPT, FrizzStatus, BlockMechanism, RuntimeState, Backend, CodexModel, ClaudeModel, CODEX_MODELS_FALLBACK, AcpAgent, ACP_MODEL_PREFIX, AcpAgentModel, AcpAgentModels, AcpAgentModelsInput, ThreadProfileOption, ThreadAgent, SubAgentView, BgShellView, CompletionHoldOp, CompletionHold, AskOption, AskQuestion, PendingAsk, AwaitingHint, RETIRED_AWAITING_KINDS, RETIRED_LINE_RE, RETIRED_AWAITING_REPLACEMENT, AWAITING_KEY_RE, AWAITING_YAML_KEYS, AWAITING_SEQUENCE_KEYS, AWAITING_HINT_MAX, AWAITING_HINT_VALUE_MAX, AWAITING_SCALAR_KINDS, AWAITING_STEPS_MAX, AWAITING_STEP_VALUE_MAX, AWAITING_QUESTIONS_MAX, AWAITING_TITLE_MAX, FENCE_DELIMITER_RE, AWAITING_STATUSES, AWAITING_ITEM_KINDS, AWAITING_DURATION_RE, DURATION_UNIT_MS, AWAITING_FOR_MAX_MS, SnoozeUntil, SNOOZE_PROMPT_MAX, SnoozePrompt, RECURRING_PROMPT_MAX, RECURRING_MIN_INTERVAL_SECONDS, RECURRING_MAX_INTERVAL_SECONDS, RecurringPromptText, RecurringIntervalSeconds, ThreadRecurringPrompt, INTERRUPT_MARKERS, ALLDONE_SENTINEL, OPT_OUT_NOTE, OVER_QUESTION_NOTE, TIMER_PROMPT_MAX, TIMER_MAX_DELAY_SECONDS, TIMER_MAX_ARMED, TimerPromptText, PR_WATCH_SPENT_TRAILER, PR_WATCH_ARMED_TRAILER, SHELL_DONE_TRAILER, ISSUE_WATCH_SPENT_TRAILER, ISSUE_WATCH_ARMED_TRAILER, LEGACY_PR_WATCH_ARMED_TRAILER, LEGACY_ISSUE_WATCH_ARMED_TRAILER, INTERRUPT_ENDED_LEAD, SIGNOFF_NUDGE_MARKER, SIGNOFF_NUDGE_MESSAGE, SIGNOFF_NUDGE_MESSAGE_NEEDS_INPUT, PARK_CORRECTION_NAMES_LEAD, PARK_CORRECTION_RETIRED_LEAD, PARK_CORRECTION_QUESTION_LEAD, PARK_CORRECTION_NEEDS_INPUT_LEAD, QUESTION_FENCE_CORRECTION_LEAD, DONE_FENCE_CORRECTION_LEAD, ThreadWatchKind, GithubChecksState, GithubMergeState, GithubWatchStatus, GithubIssueStatus, CommandWatchRun, ThreadWatchView, PR_WATCH_FOR_MAX_MS, PR_WATCH_DEFAULT_FOR_MS, PR_WATCH_MAX_ARMED, PrWatchView, AddOwnPrWatchInput, AddOwnPrWatchResult, DropOwnPrWatchInput, DropOwnPrWatchResult, OwnWatchKind, AddOwnWatchInput, OwnWatchView, AddOwnWatchResult, DropOwnWatchInput, DropOwnWatchResult, OWN_WATCH_MAX_ARMED, COMMAND_WATCH_EVERY_MIN_MS, COMMAND_WATCH_EVERY_MAX_MS, COMMAND_WATCH_FOR_MAX_MS, COMMAND_WATCH_MAX_ARMED, COMMAND_WATCH_COMMAND_MAX, COMMAND_WATCH_OUTPUT_MAX_BYTES, COMMAND_WATCH_RUN_TIMEOUT_MS, CommandWatchState, CommandWatchView, AddOwnCommandWatchInput, AddOwnCommandWatchResult, DropOwnCommandWatchInput, DropOwnCommandWatchResult, ListOwnCommandWatchesInput, OwnCommandWatchesResult, COMMAND_WATCH_FALLBACK, COMMAND_WATCH_PASSED_TRAILER, COMMAND_WATCH_EXPIRED_TRAILER, COMMAND_WATCH_CANCELLED_TRAILER, QUESTION_FENCE_RETIRED_AT, NEEDS_INPUT_REQUIRED_AT, AskQuestionKind, ASK_MAX_DEPTH, AskedOptionSchema, AskedQuestionSchema, AskInput, RegisteredQuestionView, QuestionFenceFaultView, ClosedQuestionView, SECRET_ANSWER_PREFIX, SECRET_TTL_MS, AskResult, UnaskInput, UnaskResult, QuestionAnswerSchema, AnswerQuestionsInput, AnswerQuestionsResult, DismissQuestionsInput, DismissQuestionsResult, SettledQuestionView, ThreadSettledQuestionsResult, BURIED_ANSWERS_HEADER, ANSWER_FOLLOW_UP_MARKER, ANSWER_CONTINUATION_INDENT, indentAnswerContinuation, ANSWER_PICK_PREFIX, DISMISSED_ANSWER, ANSWER_ROW_ID_PATTERN, ANSWER_ROW_ID, answerRowId, ANSWERS_NOTE_HEADER, MarkOwnDoneInput, MarkOwnDoneResult, ListOwnPrWatchesInput, OwnPrWatchesResult, ThreadTimerView, ThreadFence, LimitWindow, LimitPause, ProviderError, ThreadLinkView, UpsertOwnLinkInput, UpsertOwnLinkResult, DropOwnLinkInput, DropOwnLinkResult, LiveTool, ThreadView, BoardErrorItem, BoardSnapshot, BoardState, QuotaWindow, ProviderQuota, QuotaSnapshot, ProviderAuth, AccountEmails, AuthSnapshot, AccountBackend, AccountLogoutInput, AccountLogoutResult, PermissionMode, LocalFileOpener, Settings, DispatchProviderPreferences, DispatchPreferences, DispatchProfileSnapshotShape, DispatchProfileSnapshot, SetDispatchPreferenceInput, DispatchInput, ADOPT_THREAD_MESSAGE_MAX_CHARS, AdoptThreadInput, AdoptThreadResult, AdoptSessionInput, FollowUpInput, SteerThreadInput, SteerThreadResult, SpawnThreadInput, SpawnThreadResult, DismissFailedFollowUpInput, DismissFailedFollowUpResult, UnqueueFollowUpInput, UnqueueFollowUpResult, DeliverQueuedNowInput, DeliverQueuedNowResult, CompactThreadInput, SetThreadSnoozeInput, SetThreadPinnedInput, ReorderPinnedThreadsInput, SetThreadConsolePinnedInput, ReorderConsolePinnedThreadsInput, SetThreadRecurringPromptInput, SetOwnThreadRecurringPromptInput, SetOwnThreadRecurringPromptResult, GetOwnThreadRecurringPromptInput, OwnThreadRecurringPromptResult, SetOwnThreadTimerInput, CancelOwnThreadTimerInput, ListOwnThreadTimersInput, OwnThreadTimersResult, ThreadActivityItem, ListOwnThreadActivityInput, OwnThreadActivityResult, SetOwnThreadTimerResult, CancelOwnThreadTimerResult, SetOwnThreadStopHookInput, SetOwnThreadHeartbeatInput, RenameThreadInput, AiRenameThreadInput, AiRenameThreadResult, SetOwnThreadTitleInput, SetOwnThreadTitleResult, SetThreadPermissionInput, SetThreadPermissionResult, ThreadProfileOptionsInput, ThreadProfileOptionsResult, ThreadSkillSource, ThreadSkill, ThreadSkillsInput, ThreadSkillsResult, McpTarget, McpServerState, McpServerReading, McpStatusInput, McpStatusResult, McpSignInInput, McpSignInState, McpSignInResult, McpSignInAttemptInput, McpSignInPollResult, McpSignInFinishInput, SetThreadProfileInput, SetThreadProfileResult, UpgradeThreadModelInput, UpgradeThreadModelResult, DISPATCH_TASK_BANNER, DISPATCH_TASK_BANNER_MARKER, GITHUB_DISPATCH_UI_BOUNDARY, WAKE_TIME_HEADER_TAIL, WAKE_TRAILERS, HUMAN_GAP_FLOOR_MS, HUMAN_GAP_NOTE_TAIL, WAKE_DELIVERY_TOKEN_TAIL, WAKE_DELIVERY_TOKEN_LINE, MERGED_WAKE_LEAD, MERGED_WAKE_HEADING, NOISE_PREFIXES, AGENT_MESSAGE_WRAPPER, CROSS_SESSION_PREAMBLE, CROSS_SESSION_WRAPPER, CROSS_SESSION_GUIDANCE, XML_ATTRIBUTE, THREAD_MESSAGE_OPEN, THREAD_MESSAGE_CLOSE, THREAD_MESSAGE_GUIDANCE, RETRY_FOLLOW_UP, GithubWakeItem, GithubWakeSteer, WAKE_SCOPE, WAKE_REVIEW_LEAD, WAKE_BACKLOG_TAIL, WAKE_REF, WAKE_SINGLE, WAKE_MULTI_HEAD, WAKE_ITEM, WAKE_MORE, PR_WATCH_FINISHED, PR_WATCH_CI_PASSED, PR_WATCH_CI_GATED, PR_WATCH_STATE, PR_WATCH_CI_FAILED, GithubStatus, GithubRefCard, GithubRefPreviewInput, GithubRefPreviewResult, GithubItem, GithubListInput, GithubListResult, GithubBatchInput, GithubBatchResult, BoardMeta, BoardDeltaEvent, ServerEvent, BoardDeltasInput, BoardDeltasResult, TranscriptEdit, TranscriptTodo, TranscriptToolCall, TranscriptPart, TranscriptMessage, TranscriptPageCursor, EditedFile, TranscriptPage, TranscriptEarlierInput, SocketTranscriptSlug, SocketFilePath, SocketTranscriptClientMsg, SocketFileClientMsg, SocketBoardClientMsg, SocketClientMsg, ProjectCard, ProjectRailCounts, PROJECT_ICON_EXTENSIONS, PROJECT_ICON_MAX_BASE64_CHARS, DirectoryPickResult, ThreadLocation, FRIZZ_ROUTE_PREFIX, DEFAULT_PORT, threadIdentityName;
|
|
14941
|
+
var import_yaml2, ATTACHMENT_IMAGE_EXTENSIONS, ATTACHMENT_TEXT_EXTENSIONS, ATTACHMENT_OFFICE_EXTENSIONS, ATTACHMENT_DATA_EXTENSIONS, ATTACHMENT_ARCHIVE_EXTENSIONS, ATTACHMENT_DOC_EXTENSIONS, ATTACHMENT_EXTENSIONS, ATTACHMENT_MAX_BASE64_CHARS, ATTACHMENT_MAX_BYTES, ATTACHMENT_EXT_SET, ATTACHMENT_ACCEPT, FrizzStatus, BlockMechanism, RuntimeState, Backend, CodexModel, ClaudeModel, CODEX_MODELS_FALLBACK, AcpAgent, ACP_MODEL_PREFIX, AcpAgentModel, AcpAgentModels, AcpAgentModelsInput, ThreadProfileOption, ThreadAgent, SubAgentView, BgShellView, CompletionHoldOp, CompletionHold, AskOption, AskQuestion, PendingAsk, AwaitingHint, RETIRED_AWAITING_KINDS, RETIRED_LINE_RE, RETIRED_AWAITING_REPLACEMENT, AWAITING_KEY_RE, AWAITING_YAML_KEYS, AWAITING_SEQUENCE_KEYS, AWAITING_HINT_MAX, AWAITING_HINT_VALUE_MAX, AWAITING_SCALAR_KINDS, AWAITING_STEPS_MAX, AWAITING_STEP_VALUE_MAX, AWAITING_QUESTIONS_MAX, AWAITING_TITLE_MAX, FENCE_DELIMITER_RE, AWAITING_STATUSES, AWAITING_ITEM_KINDS, AWAITING_DURATION_RE, DURATION_UNIT_MS, AWAITING_FOR_MAX_MS, SnoozeUntil, SNOOZE_PROMPT_MAX, SnoozePrompt, RECURRING_PROMPT_MAX, RECURRING_MIN_INTERVAL_SECONDS, RECURRING_MAX_INTERVAL_SECONDS, RecurringPromptText, RecurringIntervalSeconds, ThreadRecurringPrompt, INTERRUPT_MARKERS, ALLDONE_SENTINEL, OPT_OUT_NOTE, OVER_QUESTION_NOTE, TIMER_PROMPT_MAX, TIMER_MAX_DELAY_SECONDS, TIMER_MAX_ARMED, TimerPromptText, PR_WATCH_SPENT_TRAILER, PR_WATCH_ARMED_TRAILER, SHELL_DONE_TRAILER, ISSUE_WATCH_SPENT_TRAILER, ISSUE_WATCH_ARMED_TRAILER, LEGACY_PR_WATCH_ARMED_TRAILER, LEGACY_ISSUE_WATCH_ARMED_TRAILER, INTERRUPT_ENDED_LEAD, SIGNOFF_NUDGE_MARKER, SIGNOFF_NUDGE_MESSAGE, SIGNOFF_NUDGE_MESSAGE_NEEDS_INPUT, PARK_CORRECTION_NAMES_LEAD, PARK_CORRECTION_RETIRED_LEAD, PARK_CORRECTION_QUESTION_LEAD, PARK_CORRECTION_NEEDS_INPUT_LEAD, QUESTION_FENCE_CORRECTION_LEAD, DONE_FENCE_CORRECTION_LEAD, ThreadWatchKind, GithubChecksState, GithubMergeState, GithubWatchStatus, GithubIssueStatus, CommandWatchRun, MonitorStatus, ThreadWatchView, PR_WATCH_FOR_MAX_MS, PR_WATCH_DEFAULT_FOR_MS, PR_WATCH_MAX_ARMED, PrWatchView, AddOwnPrWatchInput, AddOwnPrWatchResult, DropOwnPrWatchInput, DropOwnPrWatchResult, OwnWatchKind, AddOwnWatchInput, OwnWatchView, AddOwnWatchResult, DropOwnWatchInput, DropOwnWatchResult, OWN_WATCH_MAX_ARMED, COMMAND_WATCH_EVERY_MIN_MS, COMMAND_WATCH_EVERY_MAX_MS, COMMAND_WATCH_FOR_MAX_MS, COMMAND_WATCH_MAX_ARMED, COMMAND_WATCH_COMMAND_MAX, COMMAND_WATCH_OUTPUT_MAX_BYTES, COMMAND_WATCH_RUN_TIMEOUT_MS, CommandWatchState, CommandWatchView, AddOwnCommandWatchInput, AddOwnCommandWatchResult, DropOwnCommandWatchInput, DropOwnCommandWatchResult, ListOwnCommandWatchesInput, OwnCommandWatchesResult, COMMAND_WATCH_FALLBACK, COMMAND_WATCH_PASSED_TRAILER, COMMAND_WATCH_EXPIRED_TRAILER, COMMAND_WATCH_CANCELLED_TRAILER, MONITOR_BATCH_MS, MONITOR_LINE_MAX_CHARS, MONITOR_EVENT_MAX_LINES, MONITOR_FLOOD_MAX_EVENTS, MONITOR_FLOOD_WINDOW_MS, MONITOR_REGISTRATION_WINDOW_MS, MONITOR_DESCRIPTION_MAX, MONITOR_SERVER_MAX_RUNNING, AddOwnMonitorInput, AddOwnMonitorResult, MONITOR_FALLBACK, MONITOR_EVENT_TRAILER, MONITOR_EXITED_TRAILER, MONITOR_EXPIRED_TRAILER, MONITOR_CANCELLED_TRAILER, MONITOR_FLOOD_REASON, QUESTION_FENCE_RETIRED_AT, NEEDS_INPUT_REQUIRED_AT, AskQuestionKind, ASK_MAX_DEPTH, AskedOptionSchema, AskedQuestionSchema, AskInput, RegisteredQuestionView, QuestionFenceFaultView, ClosedQuestionView, SECRET_ANSWER_PREFIX, SECRET_TTL_MS, AskResult, UnaskInput, UnaskResult, QuestionAnswerSchema, AnswerQuestionsInput, AnswerQuestionsResult, DismissQuestionsInput, DismissQuestionsResult, SettledQuestionView, ThreadSettledQuestionsResult, BURIED_ANSWERS_HEADER, ANSWER_FOLLOW_UP_MARKER, ANSWER_CONTINUATION_INDENT, indentAnswerContinuation, ANSWER_PICK_PREFIX, DISMISSED_ANSWER, ANSWER_ROW_ID_PATTERN, ANSWER_ROW_ID, answerRowId, ANSWERS_NOTE_HEADER, MarkOwnDoneInput, MarkOwnDoneResult, ListOwnPrWatchesInput, OwnPrWatchesResult, ThreadTimerView, ThreadFence, LimitWindow, LimitPause, ProviderError, ThreadLinkView, UpsertOwnLinkInput, UpsertOwnLinkResult, DropOwnLinkInput, DropOwnLinkResult, LiveTool, ThreadView, SPINNING_UP_TITLE, UNTITLED_THREAD_TITLE, SPIN_UP_MS, CODEX_TITLE_SIGNAL_GRACE_MS, BoardErrorItem, BoardSnapshot, BoardState, QuotaWindow, ProviderQuota, QuotaSnapshot, ProviderAuth, AccountEmails, AuthSnapshot, AccountBackend, AccountLogoutInput, AccountLogoutResult, PermissionMode, LocalFileOpener, Settings, DispatchProviderPreferences, DispatchPreferences, DispatchProfileSnapshotShape, DispatchProfileSnapshot, SetDispatchPreferenceInput, DispatchInput, ADOPT_THREAD_MESSAGE_MAX_CHARS, AdoptThreadInput, AdoptThreadResult, AdoptSessionInput, FollowUpInput, SteerThreadInput, SteerThreadResult, SpawnThreadInput, SpawnThreadResult, DismissFailedFollowUpInput, DismissFailedFollowUpResult, UnqueueFollowUpInput, UnqueueFollowUpResult, DeliverQueuedNowInput, DeliverQueuedNowResult, CompactThreadInput, SetThreadSnoozeInput, SetThreadPinnedInput, ReorderPinnedThreadsInput, SetThreadConsolePinnedInput, ReorderConsolePinnedThreadsInput, SetThreadRecurringPromptInput, SetOwnThreadRecurringPromptInput, SetOwnThreadRecurringPromptResult, GetOwnThreadRecurringPromptInput, OwnThreadRecurringPromptResult, SetOwnThreadTimerInput, CancelOwnThreadTimerInput, ListOwnThreadTimersInput, OwnThreadTimersResult, ThreadActivityItem, ListOwnThreadActivityInput, OwnThreadActivityResult, ThreadBand, ThreadListing, ListThreadsInput, ListThreadsResult, SetOwnThreadTimerResult, CancelOwnThreadTimerResult, SetOwnThreadStopHookInput, SetOwnThreadHeartbeatInput, RenameThreadInput, AiRenameThreadInput, AiRenameThreadResult, SetOwnThreadTitleInput, SetOwnThreadTitleResult, SetThreadPermissionInput, SetThreadPermissionResult, ThreadProfileOptionsInput, ThreadProfileOptionsResult, ThreadSkillSource, ThreadSkill, ThreadSkillsInput, ThreadSkillsResult, McpTarget, McpServerState, McpServerReading, McpStatusInput, McpStatusResult, McpSignInInput, McpSignInState, McpSignInResult, McpSignInAttemptInput, McpSignInPollResult, McpSignInFinishInput, SetThreadProfileInput, SetThreadProfileResult, UpgradeThreadModelInput, UpgradeThreadModelResult, DISPATCH_TASK_BANNER, DISPATCH_TASK_BANNER_MARKER, GITHUB_DISPATCH_UI_BOUNDARY, WAKE_TIME_HEADER_TAIL, WAKE_TRAILERS, HUMAN_GAP_FLOOR_MS, HUMAN_GAP_NOTE_TAIL, WAKE_DELIVERY_TOKEN_TAIL, WAKE_DELIVERY_TOKEN_LINE, MERGED_WAKE_LEAD, MERGED_WAKE_HEADING, NOISE_PREFIXES, AGENT_MESSAGE_WRAPPER, CROSS_SESSION_PREAMBLE, CROSS_SESSION_WRAPPER, CROSS_SESSION_GUIDANCE, XML_ATTRIBUTE, THREAD_MESSAGE_OPEN, THREAD_MESSAGE_CLOSE, THREAD_MESSAGE_GUIDANCE, RETRY_FOLLOW_UP, GithubWakeItem, GithubWakeSteer, WAKE_SCOPE, WAKE_REVIEW_LEAD, WAKE_BACKLOG_TAIL, WAKE_REF, WAKE_SINGLE, WAKE_MULTI_HEAD, WAKE_ITEM, WAKE_MORE, PR_WATCH_FINISHED, PR_WATCH_CI_PASSED, PR_WATCH_CI_GATED, PR_WATCH_STATE, PR_WATCH_CI_FAILED, GithubStatus, GithubRefCard, GithubRefPreviewInput, GithubRefPreviewResult, GithubItem, GithubListInput, GithubListResult, GithubBatchInput, GithubBatchResult, BoardMeta, BoardDeltaEvent, ServerEvent, BoardDeltasInput, BoardDeltasResult, TranscriptEdit, TranscriptTodo, TranscriptToolCall, TranscriptPart, TranscriptMessage, TranscriptPageCursor, EditedFile, TranscriptPage, TranscriptEarlierInput, SocketTranscriptSlug, SocketFilePath, SocketTranscriptClientMsg, SocketFileClientMsg, SocketBoardClientMsg, SocketClientMsg, ProjectCard, ProjectRailCounts, PROJECT_ICON_EXTENSIONS, PROJECT_ICON_MAX_BASE64_CHARS, DirectoryPickResult, ThreadLocation, FRIZZ_ROUTE_PREFIX, DEFAULT_PORT, threadIdentityName;
|
|
14850
14942
|
var init_src = __esm({
|
|
14851
14943
|
"packages/shared/src/index.ts"() {
|
|
14852
14944
|
"use strict";
|
|
@@ -15368,6 +15460,14 @@ var init_src = __esm({
|
|
|
15368
15460
|
exitCode: external_exports.number().int().nullable(),
|
|
15369
15461
|
output: external_exports.string()
|
|
15370
15462
|
}).strict();
|
|
15463
|
+
MonitorStatus = external_exports.object({
|
|
15464
|
+
/** The worker's own words for what it watches ("errors in deploy.log"), when it gave any. */
|
|
15465
|
+
description: external_exports.string().optional(),
|
|
15466
|
+
/** Events printed so far: each batch of lines that woke (or will wake) the thread is one. */
|
|
15467
|
+
events: external_exports.number().int().nonnegative(),
|
|
15468
|
+
/** The newest event's text, trimmed, and when it was printed. */
|
|
15469
|
+
lastEvent: external_exports.object({ at: external_exports.string(), text: external_exports.string() }).strict().optional()
|
|
15470
|
+
}).strict();
|
|
15371
15471
|
ThreadWatchView = external_exports.object({
|
|
15372
15472
|
id: external_exports.string(),
|
|
15373
15473
|
kind: ThreadWatchKind,
|
|
@@ -15400,7 +15500,10 @@ var init_src = __esm({
|
|
|
15400
15500
|
every: external_exports.string(),
|
|
15401
15501
|
expiresAt: external_exports.string(),
|
|
15402
15502
|
runs: external_exports.number().int().nonnegative(),
|
|
15403
|
-
lastRun: CommandWatchRun.optional()
|
|
15503
|
+
lastRun: CommandWatchRun.optional(),
|
|
15504
|
+
/** A MONITOR's own reading (`frizzctl monitor`), and present on nothing else: the row is a running
|
|
15505
|
+
* script, so its status is how many events it has printed, not a cadence. */
|
|
15506
|
+
monitor: MonitorStatus.optional()
|
|
15404
15507
|
}).strict().optional()
|
|
15405
15508
|
}).strict();
|
|
15406
15509
|
PR_WATCH_FOR_MAX_MS = 365 * 24 * 60 * 60 * 1e3;
|
|
@@ -15551,7 +15654,11 @@ var init_src = __esm({
|
|
|
15551
15654
|
expiresAt: external_exports.string(),
|
|
15552
15655
|
/** How many checks have run since it was armed, the registration's own first check included. */
|
|
15553
15656
|
runs: external_exports.number().int().nonnegative(),
|
|
15554
|
-
lastRun: CommandWatchRun.optional()
|
|
15657
|
+
lastRun: CommandWatchRun.optional(),
|
|
15658
|
+
/** Present on a MONITOR (`frizzctl monitor`) and nothing else: a script the server keeps RUNNING, whose
|
|
15659
|
+
* every printed line is a wake. A monitor has no cadence and no checks, so `every` reads `0s` and
|
|
15660
|
+
* `runs` 0 on one; read this instead. */
|
|
15661
|
+
monitor: MonitorStatus.optional()
|
|
15555
15662
|
}).strict();
|
|
15556
15663
|
AddOwnCommandWatchInput = external_exports.object({
|
|
15557
15664
|
slug: ThreadSlug,
|
|
@@ -15596,6 +15703,47 @@ var init_src = __esm({
|
|
|
15596
15703
|
COMMAND_WATCH_PASSED_TRAILER = "The watch is settled and runs no more. Carry on with whatever you were waiting on it for.";
|
|
15597
15704
|
COMMAND_WATCH_EXPIRED_TRAILER = "If you still mean to wait, find out why it never passed, then register it again with `frizzctl watch-command add` and a fresh `--for`. If you do not, and it was the only thing you were waiting on, end in a proper terminal state instead of parking on it again.";
|
|
15598
15705
|
COMMAND_WATCH_CANCELLED_TRAILER = "Nothing about it will wake you now. If you still need the wait, run the check in a background shell instead.";
|
|
15706
|
+
MONITOR_BATCH_MS = 200;
|
|
15707
|
+
MONITOR_LINE_MAX_CHARS = 1e3;
|
|
15708
|
+
MONITOR_EVENT_MAX_LINES = 40;
|
|
15709
|
+
MONITOR_FLOOD_MAX_EVENTS = 30;
|
|
15710
|
+
MONITOR_FLOOD_WINDOW_MS = 10 * 6e4;
|
|
15711
|
+
MONITOR_REGISTRATION_WINDOW_MS = 2e3;
|
|
15712
|
+
MONITOR_DESCRIPTION_MAX = 120;
|
|
15713
|
+
MONITOR_SERVER_MAX_RUNNING = 32;
|
|
15714
|
+
AddOwnMonitorInput = external_exports.object({
|
|
15715
|
+
slug: ThreadSlug,
|
|
15716
|
+
/** Run with `/bin/sh -c` in the project root, with the server's environment. Each stdout line is an event. */
|
|
15717
|
+
command: external_exports.string().trim().min(1).max(COMMAND_WATCH_COMMAND_MAX),
|
|
15718
|
+
/** What it watches, in the worker's words — the label on every wake and on the board row. */
|
|
15719
|
+
description: external_exports.string().trim().max(MONITOR_DESCRIPTION_MAX).optional(),
|
|
15720
|
+
/** How long to keep it running, as a DURATION. Clamped to COMMAND_WATCH_FOR_MAX_MS and reported. */
|
|
15721
|
+
for: external_exports.string().trim().min(1).max(16)
|
|
15722
|
+
}).strict();
|
|
15723
|
+
AddOwnMonitorResult = external_exports.object({
|
|
15724
|
+
/** Present when the call was REFUSED: the gate, the caps, or a script that could not run here. Nothing
|
|
15725
|
+
* is armed, and the text says why and what to use instead. */
|
|
15726
|
+
refused: external_exports.string().optional(),
|
|
15727
|
+
id: external_exports.string().optional(),
|
|
15728
|
+
/** This exact command already runs as a monitor on this thread; nothing new was registered. */
|
|
15729
|
+
alreadyArmed: external_exports.boolean().default(false),
|
|
15730
|
+
/** Still running when registration stopped watching it (MONITOR_REGISTRATION_WINDOW_MS). */
|
|
15731
|
+
running: external_exports.boolean().default(false),
|
|
15732
|
+
/** The events it printed while registration watched — handed back here rather than woken. */
|
|
15733
|
+
events: external_exports.array(external_exports.string()).default([]),
|
|
15734
|
+
/** It EXITED while registration watched: how, and the end of what it printed. Nothing stays armed. */
|
|
15735
|
+
exited: CommandWatchRun.optional(),
|
|
15736
|
+
expiresAt: external_exports.string().optional(),
|
|
15737
|
+
/** The `for` the worker wrote, present ONLY when it was clamped. */
|
|
15738
|
+
clamped: external_exports.object({ for: external_exports.string() }).strict().optional(),
|
|
15739
|
+
watches: external_exports.array(CommandWatchView)
|
|
15740
|
+
}).strict();
|
|
15741
|
+
MONITOR_FALLBACK = "Run the script with Claude Code's Monitor tool, or in a background shell, instead.";
|
|
15742
|
+
MONITOR_EVENT_TRAILER = "The monitor is still running and wakes you again on its next line. Drop it with `frizzctl monitor drop <id>` once you no longer need it.";
|
|
15743
|
+
MONITOR_EXITED_TRAILER = "Its script ended, so nothing more will come from it. If you still need the watch, find out why it stopped and register it again with `frizzctl monitor add`.";
|
|
15744
|
+
MONITOR_EXPIRED_TRAILER = "If you still need the watch, register it again with `frizzctl monitor add` and a fresh `--for`. If it was the only thing you were waiting on, end in a proper terminal state instead of parking on it again.";
|
|
15745
|
+
MONITOR_CANCELLED_TRAILER = "Nothing about it will wake you now.";
|
|
15746
|
+
MONITOR_FLOOD_REASON = `it printed ${MONITOR_FLOOD_MAX_EVENTS} events inside ${formatElapsed(MONITOR_FLOOD_WINDOW_MS)}, and every event is a turn of yours. Register it again with a tighter filter: print only the lines you would act on (\`grep --line-buffered\`), never raw logs.`;
|
|
15599
15747
|
QUESTION_FENCE_RETIRED_AT = "2026-09-11T17:30:00Z";
|
|
15600
15748
|
NEEDS_INPUT_REQUIRED_AT = "2026-10-02T00:48:00Z";
|
|
15601
15749
|
AskQuestionKind = external_exports.enum(["question", "multi"]);
|
|
@@ -16127,6 +16275,10 @@ ${ANSWER_CONTINUATION_INDENT}`);
|
|
|
16127
16275
|
// `tokens` legitimately DROPS after a compaction — the context really did get smaller.
|
|
16128
16276
|
context: external_exports.object({ tokens: external_exports.number(), window: external_exports.number() }).optional()
|
|
16129
16277
|
});
|
|
16278
|
+
SPINNING_UP_TITLE = "Spinning up a thread\u2026";
|
|
16279
|
+
UNTITLED_THREAD_TITLE = "Untitled thread";
|
|
16280
|
+
SPIN_UP_MS = 6e4;
|
|
16281
|
+
CODEX_TITLE_SIGNAL_GRACE_MS = 15e3;
|
|
16130
16282
|
BoardErrorItem = external_exports.object({
|
|
16131
16283
|
file: external_exports.string(),
|
|
16132
16284
|
kind: external_exports.enum(["no-frontmatter", "other"]),
|
|
@@ -16618,6 +16770,59 @@ ${ANSWER_CONTINUATION_INDENT}`);
|
|
|
16618
16770
|
* agent to read out the current set of watchers and questions?"). */
|
|
16619
16771
|
questions: external_exports.array(RegisteredQuestionView).default([])
|
|
16620
16772
|
}).strict();
|
|
16773
|
+
ThreadBand = external_exports.enum(["rested", "active", "snoozed", "done"]);
|
|
16774
|
+
ThreadListing = external_exports.object({
|
|
16775
|
+
slug: ThreadSlug,
|
|
16776
|
+
/** The title the sidebar shows (displayTitle). */
|
|
16777
|
+
title: external_exports.string(),
|
|
16778
|
+
band: ThreadBand,
|
|
16779
|
+
runtime: RuntimeState,
|
|
16780
|
+
backend: Backend.optional(),
|
|
16781
|
+
model: external_exports.string().optional(),
|
|
16782
|
+
/** The human pinned it to the top of this board's sidebar. */
|
|
16783
|
+
pinned: external_exports.literal(true).optional(),
|
|
16784
|
+
/** The caption of the tool call in flight, while a turn is running ("Running the focused tests"). */
|
|
16785
|
+
doing: external_exports.string().optional(),
|
|
16786
|
+
/** The first line of its newest message — the verdict line of a handoff. Capped. */
|
|
16787
|
+
lastLine: external_exports.string().optional(),
|
|
16788
|
+
/** The signal fence its last rest ended on, while the board still reads it. */
|
|
16789
|
+
fence: external_exports.enum(["done", "awaiting"]).optional(),
|
|
16790
|
+
/** Questions standing at its current rest (hasStandingQuestion's rule), plus a native ask or a
|
|
16791
|
+
* permission prompt the human has not answered. */
|
|
16792
|
+
questions: external_exports.number().int(),
|
|
16793
|
+
/** Its own sub-agents still running (direct children only, as the board counts them). */
|
|
16794
|
+
subAgents: external_exports.number().int(),
|
|
16795
|
+
/** Background shells still running. */
|
|
16796
|
+
shells: external_exports.number().int(),
|
|
16797
|
+
/** What its armed watches are on: `owner/repo#N` for a PR or issue, the prompt for a timer, the
|
|
16798
|
+
* command for a command watch. */
|
|
16799
|
+
watches: external_exports.array(external_exports.string()),
|
|
16800
|
+
/** Killed by a usage limit, waiting for the window to reset. */
|
|
16801
|
+
limited: external_exports.literal(true).optional(),
|
|
16802
|
+
/** Its process is gone with the turn unfinished. */
|
|
16803
|
+
crashed: external_exports.literal(true).optional(),
|
|
16804
|
+
spawnedAt: external_exports.string().optional(),
|
|
16805
|
+
/** When its own turn last came to rest (ThreadView.lastAssistantAt). */
|
|
16806
|
+
restedAt: external_exports.string().optional(),
|
|
16807
|
+
lastActivityAt: external_exports.string().optional(),
|
|
16808
|
+
/** A wall-clock snooze still in the future. */
|
|
16809
|
+
snoozedUntil: external_exports.string().optional(),
|
|
16810
|
+
archivedAt: external_exports.string().optional()
|
|
16811
|
+
}).strict();
|
|
16812
|
+
ListThreadsInput = external_exports.object({
|
|
16813
|
+
/** Another project's board — its slug, id or registered name — instead of the one the call lands on. */
|
|
16814
|
+
project: external_exports.string().trim().min(1).optional(),
|
|
16815
|
+
/** Include the Done band (archived threads), which on a long-lived board is nearly every thread. */
|
|
16816
|
+
all: external_exports.boolean().optional()
|
|
16817
|
+
}).strict();
|
|
16818
|
+
ListThreadsResult = external_exports.object({
|
|
16819
|
+
/** The board's project: its URL slug, its registry id, and the name the board shows. */
|
|
16820
|
+
project: external_exports.object({ slug: external_exports.string(), id: external_exports.string(), name: external_exports.string() }).strict(),
|
|
16821
|
+
/** Rested, then active, then snoozed, then done; newest activity first within each. */
|
|
16822
|
+
threads: external_exports.array(ThreadListing),
|
|
16823
|
+
/** Every band's size, the Done band's included when its threads are not listed. */
|
|
16824
|
+
counts: external_exports.object({ rested: external_exports.number().int(), active: external_exports.number().int(), snoozed: external_exports.number().int(), done: external_exports.number().int() }).strict()
|
|
16825
|
+
}).strict();
|
|
16621
16826
|
SetOwnThreadTimerResult = external_exports.object({
|
|
16622
16827
|
id: external_exports.string(),
|
|
16623
16828
|
fireAt: external_exports.string(),
|
|
@@ -21365,7 +21570,18 @@ function ensureStorageSchema(db2) {
|
|
|
21365
21570
|
} catch {
|
|
21366
21571
|
}
|
|
21367
21572
|
}
|
|
21368
|
-
for (const [table, column] of [
|
|
21573
|
+
for (const [table, column] of [
|
|
21574
|
+
["pr_watch", "kind TEXT NOT NULL DEFAULT 'pull'"],
|
|
21575
|
+
["thread_question", "delivery_id TEXT"],
|
|
21576
|
+
["thread_question", "handle TEXT"],
|
|
21577
|
+
["command_watch", "kind TEXT NOT NULL DEFAULT 'check'"],
|
|
21578
|
+
["command_watch", "description TEXT"],
|
|
21579
|
+
["command_watch", "events INTEGER NOT NULL DEFAULT 0"],
|
|
21580
|
+
["command_watch", "last_event_at INTEGER"],
|
|
21581
|
+
["command_watch", "last_event TEXT"],
|
|
21582
|
+
["command_watch", "pid INTEGER"],
|
|
21583
|
+
["command_watch", "pid_started_at INTEGER"]
|
|
21584
|
+
]) {
|
|
21369
21585
|
try {
|
|
21370
21586
|
db2.exec(`ALTER TABLE ${table} ADD COLUMN ${column}`);
|
|
21371
21587
|
} catch {
|
|
@@ -21887,6 +22103,25 @@ function createStorage(source, projectId) {
|
|
|
21887
22103
|
WHERE project_id = @project_id AND id = ? AND state = 'armed'
|
|
21888
22104
|
`);
|
|
21889
22105
|
const delCommandWatches = scope.prepare("DELETE FROM command_watch WHERE project_id = @project_id AND thread_slug = ?");
|
|
22106
|
+
const armMonitorStmt = scope.prepare(`
|
|
22107
|
+
INSERT INTO command_watch (project_id, id, thread_slug, command, every_ms, state, created_at, expires_at, settled_at,
|
|
22108
|
+
runs, kind, description, events)
|
|
22109
|
+
VALUES (@project_id, @id, @slug, @command, 0, 'armed', @createdAtMs, @expiresAtMs, NULL, 0, 'monitor', @description, 0)
|
|
22110
|
+
RETURNING *
|
|
22111
|
+
`);
|
|
22112
|
+
const noteMonitorStartStmt = scope.prepare(`
|
|
22113
|
+
UPDATE command_watch SET runs = runs + 1, pid = ?, pid_started_at = ?
|
|
22114
|
+
WHERE project_id = @project_id AND id = ? AND state = 'armed' AND kind = 'monitor'
|
|
22115
|
+
`);
|
|
22116
|
+
const recordMonitorEventStmt = scope.prepare(`
|
|
22117
|
+
UPDATE command_watch SET events = events + 1, last_event_at = ?, last_event = ?
|
|
22118
|
+
WHERE project_id = @project_id AND id = ? AND state = 'armed' AND kind = 'monitor'
|
|
22119
|
+
RETURNING events
|
|
22120
|
+
`);
|
|
22121
|
+
const recordMonitorExitStmt = scope.prepare(`
|
|
22122
|
+
UPDATE command_watch SET pid = NULL, pid_started_at = NULL, last_run_at = ?, last_outcome = ?, last_exit = ?, last_output = ?
|
|
22123
|
+
WHERE project_id = @project_id AND id = ? AND kind = 'monitor'
|
|
22124
|
+
`);
|
|
21890
22125
|
const upsertThreadLinkStmt = scope.prepare(`
|
|
21891
22126
|
INSERT INTO thread_link (project_id, id, thread_slug, kind, label, target, created_at)
|
|
21892
22127
|
VALUES (@project_id, @id, @slug, @kind, @label, @target, @createdAtMs)
|
|
@@ -22535,6 +22770,17 @@ function createStorage(source, projectId) {
|
|
|
22535
22770
|
recordCommandWatchRun: (id2, run3) => recordCommandWatchRunStmt.run(run3.atMs, run3.outcome, run3.exitCode, run3.output, id2).changes === 1,
|
|
22536
22771
|
dropCommandWatch: (slug, id2, settledAtMs) => dropCommandWatchStmt.run(settledAtMs, id2, slug).changes === 1,
|
|
22537
22772
|
settleCommandWatch: (id2, state, settledAtMs) => settleCommandWatchStmt.run(state, settledAtMs, id2).changes === 1,
|
|
22773
|
+
armMonitor: (monitor) => armMonitorStmt.get({
|
|
22774
|
+
id: monitor.id,
|
|
22775
|
+
slug: monitor.slug,
|
|
22776
|
+
command: monitor.command,
|
|
22777
|
+
description: monitor.description?.trim() || null,
|
|
22778
|
+
createdAtMs: monitor.createdAtMs,
|
|
22779
|
+
expiresAtMs: monitor.expiresAtMs
|
|
22780
|
+
}),
|
|
22781
|
+
noteMonitorStart: (id2, pid, startedAtMs) => noteMonitorStartStmt.run(pid, pid === null ? null : startedAtMs, id2).changes === 1,
|
|
22782
|
+
recordMonitorEvent: (id2, event) => recordMonitorEventStmt.get(event.atMs, event.text, id2)?.events,
|
|
22783
|
+
recordMonitorExit: (id2, run3) => recordMonitorExitStmt.run(run3.atMs, run3.outcome, run3.exitCode, run3.output, id2).changes === 1,
|
|
22538
22784
|
upsertThreadLink: (link) => upsertThreadLinkStmt.get(link),
|
|
22539
22785
|
listThreadLinks: (slug) => threadLinksBySlugStmt.all(slug),
|
|
22540
22786
|
threadLinksBySlug: () => registryBySlug("thread_link", () => groupBySlug(threadLinksStmt.all()), sameRows),
|
|
@@ -39867,11 +40113,415 @@ var init_question_fences = __esm({
|
|
|
39867
40113
|
}
|
|
39868
40114
|
});
|
|
39869
40115
|
|
|
40116
|
+
// packages/server/src/command-watch.ts
|
|
40117
|
+
import { execFileSync as execFileSync5, spawn as spawn5 } from "node:child_process";
|
|
40118
|
+
import { existsSync as existsSync11, readFileSync as readFileSync20 } from "node:fs";
|
|
40119
|
+
import { homedir as homedir11, userInfo } from "node:os";
|
|
40120
|
+
import { join as join30 } from "node:path";
|
|
40121
|
+
import { StringDecoder as StringDecoder4 } from "node:string_decoder";
|
|
40122
|
+
function killGroup(pid, signal) {
|
|
40123
|
+
if (!pid) return;
|
|
40124
|
+
try {
|
|
40125
|
+
process.kill(-pid, signal);
|
|
40126
|
+
} catch {
|
|
40127
|
+
}
|
|
40128
|
+
}
|
|
40129
|
+
function outputTail(chunks, max = COMMAND_WATCH_OUTPUT_MAX_BYTES) {
|
|
40130
|
+
const all = Buffer.concat(chunks);
|
|
40131
|
+
if (all.length <= max) return all.toString("utf8");
|
|
40132
|
+
let start = all.length - max;
|
|
40133
|
+
while (start < all.length && (all[start] & 192) === 128) start++;
|
|
40134
|
+
return `\u2026${all.subarray(start).toString("utf8")}`;
|
|
40135
|
+
}
|
|
40136
|
+
function runWatchCommand(spec) {
|
|
40137
|
+
const startedAtMs = Date.now();
|
|
40138
|
+
const timeoutMs = spec.timeoutMs ?? COMMAND_WATCH_RUN_TIMEOUT_MS;
|
|
40139
|
+
return new Promise((resolve14) => {
|
|
40140
|
+
const chunks = [];
|
|
40141
|
+
let held = 0;
|
|
40142
|
+
const keep = (chunk2) => {
|
|
40143
|
+
chunks.push(chunk2);
|
|
40144
|
+
held += chunk2.length;
|
|
40145
|
+
while (held - chunks[0].length >= COMMAND_WATCH_OUTPUT_MAX_BYTES && chunks.length > 1) held -= chunks.shift().length;
|
|
40146
|
+
};
|
|
40147
|
+
let settled = false;
|
|
40148
|
+
let timedOut2 = false;
|
|
40149
|
+
let aborted = false;
|
|
40150
|
+
let exit = null;
|
|
40151
|
+
const timers = [];
|
|
40152
|
+
const finish = (result, extra) => {
|
|
40153
|
+
if (settled) return;
|
|
40154
|
+
settled = true;
|
|
40155
|
+
for (const t of timers) clearTimeout(t);
|
|
40156
|
+
spec.signal?.removeEventListener("abort", onAbort);
|
|
40157
|
+
const output = outputTail(extra ? [...chunks, Buffer.from(extra)] : chunks);
|
|
40158
|
+
resolve14({ ...result, output, startedAtMs, finishedAtMs: Date.now() });
|
|
40159
|
+
};
|
|
40160
|
+
let child;
|
|
40161
|
+
try {
|
|
40162
|
+
child = spawn5("/bin/sh", ["-c", spec.command], {
|
|
40163
|
+
cwd: spec.cwd,
|
|
40164
|
+
env: spec.env,
|
|
40165
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
40166
|
+
detached: true,
|
|
40167
|
+
windowsHide: true
|
|
40168
|
+
});
|
|
40169
|
+
} catch (err) {
|
|
40170
|
+
finish({ outcome: "error", exitCode: null }, `could not start /bin/sh: ${err instanceof Error ? err.message : String(err)}`);
|
|
40171
|
+
return;
|
|
40172
|
+
}
|
|
40173
|
+
const onAbort = () => {
|
|
40174
|
+
aborted = true;
|
|
40175
|
+
killGroup(child.pid, "SIGKILL");
|
|
40176
|
+
};
|
|
40177
|
+
if (spec.signal?.aborted) onAbort();
|
|
40178
|
+
else spec.signal?.addEventListener("abort", onAbort, { once: true });
|
|
40179
|
+
child.stdout?.on("data", keep);
|
|
40180
|
+
child.stderr?.on("data", keep);
|
|
40181
|
+
child.on("error", (err) => {
|
|
40182
|
+
finish({ outcome: "error", exitCode: null }, `could not start /bin/sh: ${err.message}`);
|
|
40183
|
+
});
|
|
40184
|
+
timers.push(setTimeout(() => {
|
|
40185
|
+
timedOut2 = true;
|
|
40186
|
+
killGroup(child.pid, "SIGTERM");
|
|
40187
|
+
timers.push(setTimeout(() => killGroup(child.pid, "SIGKILL"), KILL_GRACE_MS));
|
|
40188
|
+
}, timeoutMs));
|
|
40189
|
+
const conclude = () => {
|
|
40190
|
+
if (!exit) return;
|
|
40191
|
+
if (timedOut2) finish({ outcome: "timeout", exitCode: null });
|
|
40192
|
+
else if (aborted || exit.signal) finish({ outcome: "signal", exitCode: null });
|
|
40193
|
+
else finish({ outcome: "exit", exitCode: exit.code });
|
|
40194
|
+
};
|
|
40195
|
+
child.on("exit", (code, signal) => {
|
|
40196
|
+
exit = { code, signal };
|
|
40197
|
+
killGroup(child.pid, "SIGKILL");
|
|
40198
|
+
timers.push(setTimeout(() => {
|
|
40199
|
+
child.stdout?.destroy();
|
|
40200
|
+
child.stderr?.destroy();
|
|
40201
|
+
conclude();
|
|
40202
|
+
}, DRAIN_AFTER_EXIT_MS));
|
|
40203
|
+
});
|
|
40204
|
+
child.on("close", conclude);
|
|
40205
|
+
});
|
|
40206
|
+
}
|
|
40207
|
+
function createRunLimiter(limit) {
|
|
40208
|
+
let active = 0;
|
|
40209
|
+
const waiting = [];
|
|
40210
|
+
return async (fn) => {
|
|
40211
|
+
if (active < limit) active++;
|
|
40212
|
+
else await new Promise((resolve14) => waiting.push(resolve14));
|
|
40213
|
+
try {
|
|
40214
|
+
return await fn();
|
|
40215
|
+
} finally {
|
|
40216
|
+
const next = waiting.shift();
|
|
40217
|
+
if (next) next();
|
|
40218
|
+
else active--;
|
|
40219
|
+
}
|
|
40220
|
+
};
|
|
40221
|
+
}
|
|
40222
|
+
function claudeManagedPreferencePaths() {
|
|
40223
|
+
let user = "";
|
|
40224
|
+
try {
|
|
40225
|
+
user = userInfo().username;
|
|
40226
|
+
} catch {
|
|
40227
|
+
}
|
|
40228
|
+
return [
|
|
40229
|
+
...user ? [`/Library/Managed Preferences/${user}/com.anthropic.claudecode.plist`] : [],
|
|
40230
|
+
"/Library/Managed Preferences/com.anthropic.claudecode.plist"
|
|
40231
|
+
];
|
|
40232
|
+
}
|
|
40233
|
+
function plistAsJson(path3) {
|
|
40234
|
+
return execFileSync5("/usr/bin/plutil", ["-convert", "json", "-o", "-", "--", path3], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] });
|
|
40235
|
+
}
|
|
40236
|
+
function sandboxInSettings(raw2, file) {
|
|
40237
|
+
let parsed;
|
|
40238
|
+
try {
|
|
40239
|
+
parsed = JSON.parse(raw2);
|
|
40240
|
+
} catch {
|
|
40241
|
+
return `\`${file}\` is not valid JSON, so Frizz cannot tell whether it turns Claude Code's sandbox on for this thread`;
|
|
40242
|
+
}
|
|
40243
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return void 0;
|
|
40244
|
+
const sandbox = parsed.sandbox;
|
|
40245
|
+
if (sandbox === void 0 || sandbox === null || sandbox === false) return void 0;
|
|
40246
|
+
if (typeof sandbox === "object" && !Array.isArray(sandbox)) {
|
|
40247
|
+
const enabled = sandbox.enabled;
|
|
40248
|
+
if (enabled === void 0 || enabled === false) return void 0;
|
|
40249
|
+
}
|
|
40250
|
+
return `Claude Code's sandbox is on for this thread (\`sandbox\` in \`${file}\`), and a command watch would run your command outside it`;
|
|
40251
|
+
}
|
|
40252
|
+
function claudeSettingsFiles(where) {
|
|
40253
|
+
const env = where.env ?? process.env;
|
|
40254
|
+
const configDir = env.CLAUDE_CONFIG_DIR?.trim() ? env.CLAUDE_CONFIG_DIR.trim() : join30(where.home ?? homedir11(), ".claude");
|
|
40255
|
+
return [
|
|
40256
|
+
...where.managedPaths ?? CLAUDE_MANAGED_SETTINGS_PATHS,
|
|
40257
|
+
join30(where.cwd, ".claude", "settings.local.json"),
|
|
40258
|
+
join30(where.cwd, ".claude", "settings.json"),
|
|
40259
|
+
join30(configDir, "settings.json")
|
|
40260
|
+
];
|
|
40261
|
+
}
|
|
40262
|
+
function claudeSandboxRefusal(where) {
|
|
40263
|
+
for (const file of claudeSettingsFiles(where)) {
|
|
40264
|
+
let raw2;
|
|
40265
|
+
try {
|
|
40266
|
+
raw2 = readFileSync20(file, "utf8");
|
|
40267
|
+
} catch (err) {
|
|
40268
|
+
if (err?.code === "ENOENT" || err?.code === "ENOTDIR") continue;
|
|
40269
|
+
return `Frizz could not read \`${file}\` to check whether Claude Code's sandbox is on for this thread`;
|
|
40270
|
+
}
|
|
40271
|
+
const refusal = sandboxInSettings(raw2, file);
|
|
40272
|
+
if (refusal) return refusal;
|
|
40273
|
+
}
|
|
40274
|
+
const preferences = where.managedPreferencePaths ?? (process.platform === "darwin" ? claudeManagedPreferencePaths() : []);
|
|
40275
|
+
for (const file of preferences) {
|
|
40276
|
+
if (!existsSync11(file)) continue;
|
|
40277
|
+
let raw2;
|
|
40278
|
+
try {
|
|
40279
|
+
raw2 = (where.readPlistJson ?? plistAsJson)(file);
|
|
40280
|
+
} catch {
|
|
40281
|
+
return `Frizz could not read \`${file}\` to check whether Claude Code's sandbox is on for this thread`;
|
|
40282
|
+
}
|
|
40283
|
+
const refusal = sandboxInSettings(raw2, file);
|
|
40284
|
+
if (refusal) return refusal;
|
|
40285
|
+
}
|
|
40286
|
+
return void 0;
|
|
40287
|
+
}
|
|
40288
|
+
function commandWatchRefusal(row, opts) {
|
|
40289
|
+
const refuse = (reason) => `${reason}. ${COMMAND_WATCH_FALLBACK}`;
|
|
40290
|
+
if ((opts.platform ?? process.platform) === "win32") {
|
|
40291
|
+
return refuse("command watches run under `/bin/sh`, which this machine does not have");
|
|
40292
|
+
}
|
|
40293
|
+
const backend = row.backend ?? "claude";
|
|
40294
|
+
if (backend !== "claude") {
|
|
40295
|
+
return refuse(
|
|
40296
|
+
`command watches are for Claude threads only, and this one runs on ${backend === "codex" ? "Codex" : "an ACP agent"}: Frizz cannot tell whether your thread's own sandbox would have let the command run`
|
|
40297
|
+
);
|
|
40298
|
+
}
|
|
40299
|
+
if (row.permission_mode !== "bypassPermissions") {
|
|
40300
|
+
return refuse(
|
|
40301
|
+
`this thread runs in \`${row.permission_mode ?? "an unrecorded"}\` permission mode, and the server runs a watched command with no permission check at all \u2014 so Frizz runs one only for a thread in \`bypassPermissions\` mode`
|
|
40302
|
+
);
|
|
40303
|
+
}
|
|
40304
|
+
if (row.permission_pending && row.permission_pending !== "bypassPermissions") {
|
|
40305
|
+
return refuse(`this thread's permission mode is being changed to \`${row.permission_pending}\``);
|
|
40306
|
+
}
|
|
40307
|
+
const sandbox = claudeSandboxRefusal({ cwd: opts.cwd, env: opts.env, home: opts.home, managedPaths: opts.managedPaths, managedPreferencePaths: opts.managedPreferencePaths, readPlistJson: opts.readPlistJson });
|
|
40308
|
+
if (sandbox) return refuse(sandbox);
|
|
40309
|
+
return void 0;
|
|
40310
|
+
}
|
|
40311
|
+
function startMonitorProcess(spec) {
|
|
40312
|
+
const startedAtMs = Date.now();
|
|
40313
|
+
const batchMs = spec.batchMs ?? MONITOR_BATCH_MS;
|
|
40314
|
+
const tail = [];
|
|
40315
|
+
let tailHeld = 0;
|
|
40316
|
+
const keepTail = (chunk2) => {
|
|
40317
|
+
tail.push(chunk2);
|
|
40318
|
+
tailHeld += chunk2.length;
|
|
40319
|
+
while (tailHeld - tail[0].length >= COMMAND_WATCH_OUTPUT_MAX_BYTES && tail.length > 1) tailHeld -= tail.shift().length;
|
|
40320
|
+
};
|
|
40321
|
+
let batch = [];
|
|
40322
|
+
let more = 0;
|
|
40323
|
+
let batchTimer = null;
|
|
40324
|
+
const flush = () => {
|
|
40325
|
+
if (batchTimer) clearTimeout(batchTimer);
|
|
40326
|
+
batchTimer = null;
|
|
40327
|
+
if (batch.length === 0 && more === 0) return;
|
|
40328
|
+
const event = { lines: batch, more };
|
|
40329
|
+
batch = [];
|
|
40330
|
+
more = 0;
|
|
40331
|
+
try {
|
|
40332
|
+
spec.onEvent(event);
|
|
40333
|
+
} catch {
|
|
40334
|
+
}
|
|
40335
|
+
};
|
|
40336
|
+
const pushLine = (raw2) => {
|
|
40337
|
+
const line = raw2.replace(/\r$/, "");
|
|
40338
|
+
if (!line.trim()) return;
|
|
40339
|
+
if (batch.length < MONITOR_EVENT_MAX_LINES) {
|
|
40340
|
+
batch.push(line.length > MONITOR_LINE_MAX_CHARS ? `${line.slice(0, MONITOR_LINE_MAX_CHARS)}\u2026` : line);
|
|
40341
|
+
} else {
|
|
40342
|
+
more++;
|
|
40343
|
+
}
|
|
40344
|
+
if (!batchTimer) batchTimer = setTimeout(flush, batchMs);
|
|
40345
|
+
};
|
|
40346
|
+
const decoder = new StringDecoder4("utf8");
|
|
40347
|
+
let partial = "";
|
|
40348
|
+
let overlong = false;
|
|
40349
|
+
const readStdout = (text2) => {
|
|
40350
|
+
let rest = text2;
|
|
40351
|
+
for (; ; ) {
|
|
40352
|
+
const nl2 = rest.indexOf("\n");
|
|
40353
|
+
if (nl2 === -1) break;
|
|
40354
|
+
const piece = rest.slice(0, nl2);
|
|
40355
|
+
rest = rest.slice(nl2 + 1);
|
|
40356
|
+
if (overlong) {
|
|
40357
|
+
overlong = false;
|
|
40358
|
+
pushLine(partial);
|
|
40359
|
+
} else {
|
|
40360
|
+
pushLine(partial + piece);
|
|
40361
|
+
}
|
|
40362
|
+
partial = "";
|
|
40363
|
+
}
|
|
40364
|
+
if (overlong) return;
|
|
40365
|
+
partial += rest;
|
|
40366
|
+
if (partial.length > MONITOR_LINE_MAX_CHARS) {
|
|
40367
|
+
partial = partial.slice(0, MONITOR_LINE_MAX_CHARS + 1);
|
|
40368
|
+
overlong = true;
|
|
40369
|
+
}
|
|
40370
|
+
};
|
|
40371
|
+
let child;
|
|
40372
|
+
let resolveDone;
|
|
40373
|
+
const done = new Promise((resolve14) => {
|
|
40374
|
+
resolveDone = resolve14;
|
|
40375
|
+
});
|
|
40376
|
+
let settled = false;
|
|
40377
|
+
let stopping = false;
|
|
40378
|
+
const timers = [];
|
|
40379
|
+
const finish = (outcome, exitCode, extra) => {
|
|
40380
|
+
if (settled) return;
|
|
40381
|
+
settled = true;
|
|
40382
|
+
for (const t of timers) clearTimeout(t);
|
|
40383
|
+
const last = partial + (overlong ? "" : decoder.end());
|
|
40384
|
+
partial = "";
|
|
40385
|
+
if (last) pushLine(last);
|
|
40386
|
+
flush();
|
|
40387
|
+
if (extra) keepTail(Buffer.from(extra));
|
|
40388
|
+
resolveDone({ outcome, exitCode, output: outputTail(tail), startedAtMs, finishedAtMs: Date.now() });
|
|
40389
|
+
};
|
|
40390
|
+
try {
|
|
40391
|
+
child = spawn5("/bin/sh", ["-c", spec.command], {
|
|
40392
|
+
cwd: spec.cwd,
|
|
40393
|
+
env: spec.env,
|
|
40394
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
40395
|
+
detached: true,
|
|
40396
|
+
windowsHide: true
|
|
40397
|
+
});
|
|
40398
|
+
} catch (err) {
|
|
40399
|
+
finish("error", null, `could not start /bin/sh: ${err instanceof Error ? err.message : String(err)}`);
|
|
40400
|
+
return { pid: void 0, stop: () => {
|
|
40401
|
+
}, done };
|
|
40402
|
+
}
|
|
40403
|
+
child.stdout?.on("data", (chunk2) => {
|
|
40404
|
+
keepTail(chunk2);
|
|
40405
|
+
readStdout(decoder.write(chunk2));
|
|
40406
|
+
});
|
|
40407
|
+
child.stderr?.on("data", keepTail);
|
|
40408
|
+
child.on("error", (err) => finish("error", null, `could not start /bin/sh: ${err.message}`));
|
|
40409
|
+
let exit = null;
|
|
40410
|
+
const conclude = () => {
|
|
40411
|
+
if (!exit) return;
|
|
40412
|
+
if (stopping || exit.signal) finish("signal", null);
|
|
40413
|
+
else finish("exit", exit.code);
|
|
40414
|
+
};
|
|
40415
|
+
child.on("exit", (code, signal) => {
|
|
40416
|
+
exit = { code, signal };
|
|
40417
|
+
killGroup(child.pid, "SIGKILL");
|
|
40418
|
+
timers.push(setTimeout(() => {
|
|
40419
|
+
child.stdout?.destroy();
|
|
40420
|
+
child.stderr?.destroy();
|
|
40421
|
+
conclude();
|
|
40422
|
+
}, DRAIN_AFTER_EXIT_MS));
|
|
40423
|
+
});
|
|
40424
|
+
child.on("close", conclude);
|
|
40425
|
+
return {
|
|
40426
|
+
pid: child.pid,
|
|
40427
|
+
stop() {
|
|
40428
|
+
if (settled || stopping) return;
|
|
40429
|
+
stopping = true;
|
|
40430
|
+
killGroup(child.pid, "SIGTERM");
|
|
40431
|
+
timers.push(setTimeout(() => killGroup(child.pid, "SIGKILL"), KILL_GRACE_MS));
|
|
40432
|
+
},
|
|
40433
|
+
done
|
|
40434
|
+
};
|
|
40435
|
+
}
|
|
40436
|
+
function reapStaleMonitor(pid, startedAtMs, readPs = psLine, nowMs = Date.now()) {
|
|
40437
|
+
if (!Number.isInteger(pid) || pid <= 1 || !Number.isFinite(startedAtMs)) return false;
|
|
40438
|
+
const line = readPs(pid)?.trim();
|
|
40439
|
+
if (!line) return false;
|
|
40440
|
+
const match2 = /^(\d+)\s+(\S+)$/.exec(line);
|
|
40441
|
+
if (!match2 || Number(match2[1]) !== pid) return false;
|
|
40442
|
+
const elapsed = psElapsedMs(match2[2]);
|
|
40443
|
+
if (elapsed === void 0 || Math.abs(nowMs - elapsed - startedAtMs) > MONITOR_START_TOLERANCE_MS) return false;
|
|
40444
|
+
killGroup(pid, "SIGKILL");
|
|
40445
|
+
return true;
|
|
40446
|
+
}
|
|
40447
|
+
function psElapsedMs(etime) {
|
|
40448
|
+
const match2 = /^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)$/.exec(etime.trim());
|
|
40449
|
+
if (!match2) return void 0;
|
|
40450
|
+
const [, d = "0", h2 = "0", m, s] = match2;
|
|
40451
|
+
return (((Number(d) * 24 + Number(h2)) * 60 + Number(m)) * 60 + Number(s)) * 1e3;
|
|
40452
|
+
}
|
|
40453
|
+
function psLine(pid) {
|
|
40454
|
+
try {
|
|
40455
|
+
return execFileSync5("/bin/ps", ["-o", "pgid=,etime=", "-p", String(pid)], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] });
|
|
40456
|
+
} catch {
|
|
40457
|
+
return void 0;
|
|
40458
|
+
}
|
|
40459
|
+
}
|
|
40460
|
+
function monitorStatusOf(w) {
|
|
40461
|
+
return {
|
|
40462
|
+
...w.description ? { description: w.description } : {},
|
|
40463
|
+
events: w.events,
|
|
40464
|
+
...w.last_event_at !== null && w.last_event !== null ? { lastEvent: { at: new Date(w.last_event_at).toISOString(), text: w.last_event } } : {}
|
|
40465
|
+
};
|
|
40466
|
+
}
|
|
40467
|
+
function createCommandWatchService(opts) {
|
|
40468
|
+
const runner = opts.runner ?? runWatchCommand;
|
|
40469
|
+
const limiter = opts.limiter ?? serverRunLimiter;
|
|
40470
|
+
let probesActive = 0;
|
|
40471
|
+
return {
|
|
40472
|
+
refusal: (row) => commandWatchRefusal(row, { cwd: opts.cwd, ...opts.gate }),
|
|
40473
|
+
run: (slug, command, runOpts) => limiter(() => runner({ command, cwd: opts.cwd, env: opts.env(slug), timeoutMs: COMMAND_WATCH_RUN_TIMEOUT_MS, signal: runOpts?.signal })),
|
|
40474
|
+
async probe(slug, command) {
|
|
40475
|
+
if (probesActive >= PROBE_CONCURRENCY) return void 0;
|
|
40476
|
+
probesActive++;
|
|
40477
|
+
try {
|
|
40478
|
+
return await runner({ command, cwd: opts.cwd, env: opts.env(slug), timeoutMs: COMMAND_WATCH_PROBE_TIMEOUT_MS });
|
|
40479
|
+
} finally {
|
|
40480
|
+
probesActive--;
|
|
40481
|
+
}
|
|
40482
|
+
},
|
|
40483
|
+
startMonitor(slug, command, onEvent) {
|
|
40484
|
+
if (monitorsRunning >= MONITOR_SERVER_MAX_RUNNING) return void 0;
|
|
40485
|
+
monitorsRunning++;
|
|
40486
|
+
const proc = (opts.startMonitorProcess ?? startMonitorProcess)({ command, cwd: opts.cwd, env: opts.env(slug), onEvent, batchMs: opts.monitorBatchMs });
|
|
40487
|
+
void proc.done.finally(() => {
|
|
40488
|
+
monitorsRunning--;
|
|
40489
|
+
});
|
|
40490
|
+
return proc;
|
|
40491
|
+
},
|
|
40492
|
+
monitorsRunning: () => monitorsRunning,
|
|
40493
|
+
reapStaleMonitor: (pid, startedAtMs) => reapStaleMonitor(pid, startedAtMs, opts.readPs)
|
|
40494
|
+
};
|
|
40495
|
+
}
|
|
40496
|
+
function commandWatchEnvironment(base, frizz) {
|
|
40497
|
+
const { FRIZZ_THREAD: _tag, ...rest } = base;
|
|
40498
|
+
return { ...rest, ...frizz, GIT_TERMINAL_PROMPT: "0", GH_PROMPT_DISABLED: "1" };
|
|
40499
|
+
}
|
|
40500
|
+
var KILL_GRACE_MS, DRAIN_AFTER_EXIT_MS, COMMAND_WATCH_SERVER_CONCURRENCY, serverRunLimiter, COMMAND_WATCH_PROBE_TIMEOUT_MS, PROBE_CONCURRENCY, CLAUDE_MANAGED_SETTINGS_PATHS, monitorsRunning, MONITOR_START_TOLERANCE_MS;
|
|
40501
|
+
var init_command_watch = __esm({
|
|
40502
|
+
"packages/server/src/command-watch.ts"() {
|
|
40503
|
+
"use strict";
|
|
40504
|
+
init_src();
|
|
40505
|
+
KILL_GRACE_MS = 2e3;
|
|
40506
|
+
DRAIN_AFTER_EXIT_MS = 1e3;
|
|
40507
|
+
COMMAND_WATCH_SERVER_CONCURRENCY = 4;
|
|
40508
|
+
serverRunLimiter = createRunLimiter(COMMAND_WATCH_SERVER_CONCURRENCY);
|
|
40509
|
+
COMMAND_WATCH_PROBE_TIMEOUT_MS = 15e3;
|
|
40510
|
+
PROBE_CONCURRENCY = 2;
|
|
40511
|
+
CLAUDE_MANAGED_SETTINGS_PATHS = [
|
|
40512
|
+
"/Library/Application Support/ClaudeCode/managed-settings.json",
|
|
40513
|
+
"/etc/claude-code/managed-settings.json"
|
|
40514
|
+
];
|
|
40515
|
+
monitorsRunning = 0;
|
|
40516
|
+
MONITOR_START_TOLERANCE_MS = 5e3;
|
|
40517
|
+
}
|
|
40518
|
+
});
|
|
40519
|
+
|
|
39870
40520
|
// packages/server/src/local-file.ts
|
|
39871
|
-
import { spawn as
|
|
39872
|
-
import { closeSync as closeSync13, existsSync as
|
|
39873
|
-
import { homedir as
|
|
39874
|
-
import { basename as basename5, dirname as dirname12, isAbsolute as isAbsolute5, join as
|
|
40521
|
+
import { spawn as spawn6 } from "node:child_process";
|
|
40522
|
+
import { closeSync as closeSync13, existsSync as existsSync12, fstatSync as fstatSync2, openSync as openSync14, readFileSync as readFileSync21, readSync as readSync7, realpathSync as realpathSync7, statSync as statSync15 } from "node:fs";
|
|
40523
|
+
import { homedir as homedir12 } from "node:os";
|
|
40524
|
+
import { basename as basename5, dirname as dirname12, isAbsolute as isAbsolute5, join as join31, resolve as resolve5, sep as sep2 } from "node:path";
|
|
39875
40525
|
function isUnder(real, root) {
|
|
39876
40526
|
let rootReal;
|
|
39877
40527
|
try {
|
|
@@ -39914,10 +40564,10 @@ function resolveLocalFile(rawPath, roots) {
|
|
|
39914
40564
|
}
|
|
39915
40565
|
return real;
|
|
39916
40566
|
}
|
|
39917
|
-
function resolveOpenableFile(raw2, projectDir, roots, home =
|
|
40567
|
+
function resolveOpenableFile(raw2, projectDir, roots, home = homedir12()) {
|
|
39918
40568
|
const trimmed = raw2.trim().replace(/:\d+(?::\d+)?$/, "");
|
|
39919
40569
|
if (!trimmed) return null;
|
|
39920
|
-
const abs = trimmed === "~" ? home : /^~[\/\\]/.test(trimmed) ?
|
|
40570
|
+
const abs = trimmed === "~" ? home : /^~[\/\\]/.test(trimmed) ? join31(home, trimmed.slice(2)) : isAbsolute5(trimmed) ? trimmed : resolve5(projectDir, trimmed);
|
|
39921
40571
|
try {
|
|
39922
40572
|
return resolveLocalFile(abs, roots);
|
|
39923
40573
|
} catch {
|
|
@@ -39983,7 +40633,7 @@ function readLocalMarkdown(rawPath, roots) {
|
|
|
39983
40633
|
if (!MARKDOWN_FILE_EXT.test(rawPath.trim())) throw new Error("Local file is not a Markdown file");
|
|
39984
40634
|
const path3 = resolveLocalFile(rawPath, roots);
|
|
39985
40635
|
if (!MARKDOWN_FILE_EXT.test(path3)) throw new Error("Local file is not a Markdown file");
|
|
39986
|
-
const bytes =
|
|
40636
|
+
const bytes = readFileSync21(path3);
|
|
39987
40637
|
if (bytes.length <= MARKDOWN_READ_LIMIT) return { path: path3, markdown: bytes.toString("utf8"), truncated: false };
|
|
39988
40638
|
const head = bytes.subarray(0, MARKDOWN_READ_LIMIT);
|
|
39989
40639
|
const lastBreak = head.lastIndexOf(10);
|
|
@@ -39997,7 +40647,7 @@ function resolveWatchableLocalFile(rawPath, roots) {
|
|
|
39997
40647
|
return path3;
|
|
39998
40648
|
}
|
|
39999
40649
|
function defaultSpawn(command, args, options) {
|
|
40000
|
-
return
|
|
40650
|
+
return spawn6(command, [...args], options);
|
|
40001
40651
|
}
|
|
40002
40652
|
async function awaitOpenerStart(child, command) {
|
|
40003
40653
|
child.unref();
|
|
@@ -40018,10 +40668,10 @@ function localFileOpenCommand(path3, selected, options = {}) {
|
|
|
40018
40668
|
if (selected === "finder") return { command: "explorer.exe", args: [`/select,${path3}`] };
|
|
40019
40669
|
const editor = WINDOWS_EDITOR_EXE[selected];
|
|
40020
40670
|
const env = options.env ?? process.env;
|
|
40021
|
-
const exists = options.exists ??
|
|
40671
|
+
const exists = options.exists ?? existsSync12;
|
|
40022
40672
|
const localAppData = env.LOCALAPPDATA;
|
|
40023
40673
|
if (localAppData) {
|
|
40024
|
-
const exe2 =
|
|
40674
|
+
const exe2 = join31(localAppData, ...editor.exe);
|
|
40025
40675
|
if (exists(exe2)) return { command: exe2, args: [path3] };
|
|
40026
40676
|
}
|
|
40027
40677
|
if (/["%\r\n]/u.test(path3)) throw new Error(`cannot hand ${path3} to the ${editor.shim} shim through cmd.exe`);
|
|
@@ -40033,7 +40683,8 @@ async function openLocalFile(rawPath, opener, roots, options = {}) {
|
|
|
40033
40683
|
const path3 = resolveLocalFile(rawPath, roots);
|
|
40034
40684
|
const chosen = options.forceSystem ? "system" : opener;
|
|
40035
40685
|
if (chosen === "copy") return { action: "copy", path: path3 };
|
|
40036
|
-
const
|
|
40686
|
+
const editor = chosen === "cursor" || chosen === "vscode";
|
|
40687
|
+
const selected = editor && (HTML_FILE_EXT.test(path3) || isBinaryLocalFile(path3)) ? "system" : chosen;
|
|
40037
40688
|
const spec = localFileOpenCommand(path3, selected, options);
|
|
40038
40689
|
const child = (options.spawn ?? defaultSpawn)(spec.command, spec.args, {
|
|
40039
40690
|
detached: true,
|
|
@@ -40045,7 +40696,7 @@ async function openLocalFile(rawPath, opener, roots, options = {}) {
|
|
|
40045
40696
|
await awaitOpenerStart(child, spec.command);
|
|
40046
40697
|
return { action: "opened", path: path3 };
|
|
40047
40698
|
}
|
|
40048
|
-
var MARKDOWN_FILE_EXT, MARKDOWN_READ_LIMIT, PDF_FILE_EXT, SNIFF_BYTES, WINDOWS_EDITOR_EXE;
|
|
40699
|
+
var MARKDOWN_FILE_EXT, MARKDOWN_READ_LIMIT, PDF_FILE_EXT, HTML_FILE_EXT, SNIFF_BYTES, WINDOWS_EDITOR_EXE;
|
|
40049
40700
|
var init_local_file = __esm({
|
|
40050
40701
|
"packages/server/src/local-file.ts"() {
|
|
40051
40702
|
"use strict";
|
|
@@ -40053,6 +40704,7 @@ var init_local_file = __esm({
|
|
|
40053
40704
|
MARKDOWN_FILE_EXT = /\.(?:md|mdx|markdown)$/i;
|
|
40054
40705
|
MARKDOWN_READ_LIMIT = 1024 * 1024;
|
|
40055
40706
|
PDF_FILE_EXT = /\.pdf$/i;
|
|
40707
|
+
HTML_FILE_EXT = /\.html?$/i;
|
|
40056
40708
|
SNIFF_BYTES = 8192;
|
|
40057
40709
|
WINDOWS_EDITOR_EXE = {
|
|
40058
40710
|
cursor: { exe: ["Programs", "cursor", "Cursor.exe"], shim: "cursor" },
|
|
@@ -40290,7 +40942,7 @@ var init_claude_model_upgrade = __esm({
|
|
|
40290
40942
|
// packages/server/src/frizz.ts
|
|
40291
40943
|
import { execFile as execFile6 } from "node:child_process";
|
|
40292
40944
|
import { lstatSync as lstatSync3, realpathSync as realpathSync8 } from "node:fs";
|
|
40293
|
-
import { basename as basename6, dirname as dirname13, join as
|
|
40945
|
+
import { basename as basename6, dirname as dirname13, join as join32, resolve as resolve6 } from "node:path";
|
|
40294
40946
|
import { promisify as promisify5 } from "node:util";
|
|
40295
40947
|
function frizzScriptsDir() {
|
|
40296
40948
|
if (process.env.FRIZZ_SCRIPTS_DIR) return process.env.FRIZZ_SCRIPTS_DIR;
|
|
@@ -40299,7 +40951,7 @@ function frizzScriptsDir() {
|
|
|
40299
40951
|
function directFrizzRoot(projectDir) {
|
|
40300
40952
|
try {
|
|
40301
40953
|
const projectRoot = realpathSync8(projectDir);
|
|
40302
|
-
const path3 =
|
|
40954
|
+
const path3 = join32(projectRoot, ".frizz");
|
|
40303
40955
|
const stat2 = lstatSync3(path3);
|
|
40304
40956
|
if (!stat2.isDirectory() || stat2.isSymbolicLink()) return null;
|
|
40305
40957
|
const real = realpathSync8(path3);
|
|
@@ -40313,7 +40965,7 @@ function frizzDirExists(projectDir) {
|
|
|
40313
40965
|
}
|
|
40314
40966
|
async function readBoard(projectDir, scriptsDir = frizzScriptsDir()) {
|
|
40315
40967
|
if (!directFrizzRoot(projectDir)) throw new Error("unsafe or missing .frizz directory");
|
|
40316
|
-
const { stdout } = await execFileP("node", [
|
|
40968
|
+
const { stdout } = await execFileP("node", [join32(scriptsDir, "index.mjs"), "--json"], {
|
|
40317
40969
|
cwd: projectDir,
|
|
40318
40970
|
env: { ...process.env, CLAUDE_PROJECT_DIR: projectDir },
|
|
40319
40971
|
maxBuffer: 32 * 1024 * 1024
|
|
@@ -40338,7 +40990,7 @@ async function readBoard(projectDir, scriptsDir = frizzScriptsDir()) {
|
|
|
40338
40990
|
};
|
|
40339
40991
|
}
|
|
40340
40992
|
async function runThreadUpdate(projectDir, slug, args, scriptsDir = frizzScriptsDir()) {
|
|
40341
|
-
await execFileP("node", [
|
|
40993
|
+
await execFileP("node", [join32(scriptsDir, "thread-update.mjs"), slug, ...args], {
|
|
40342
40994
|
cwd: projectDir,
|
|
40343
40995
|
env: { ...process.env, CLAUDE_PROJECT_DIR: projectDir }
|
|
40344
40996
|
});
|
|
@@ -40488,12 +41140,12 @@ var init_awaiting = __esm({
|
|
|
40488
41140
|
});
|
|
40489
41141
|
|
|
40490
41142
|
// packages/server/src/backend/project-mcp-servers.ts
|
|
40491
|
-
import { readFileSync as
|
|
40492
|
-
import { homedir as
|
|
40493
|
-
import { join as
|
|
41143
|
+
import { readFileSync as readFileSync22 } from "node:fs";
|
|
41144
|
+
import { homedir as homedir13 } from "node:os";
|
|
41145
|
+
import { join as join33 } from "node:path";
|
|
40494
41146
|
function readJsonObject(path3) {
|
|
40495
41147
|
try {
|
|
40496
|
-
const parsed = JSON.parse(
|
|
41148
|
+
const parsed = JSON.parse(readFileSync22(path3, "utf8"));
|
|
40497
41149
|
return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
|
|
40498
41150
|
} catch {
|
|
40499
41151
|
return void 0;
|
|
@@ -40596,17 +41248,17 @@ function userScopeRemoteServers(account, cwd, env) {
|
|
|
40596
41248
|
}
|
|
40597
41249
|
function projectMcpServers(cwd, options = {}) {
|
|
40598
41250
|
const env = options.env ?? process.env;
|
|
40599
|
-
const home = options.home ??
|
|
41251
|
+
const home = options.home ?? homedir13();
|
|
40600
41252
|
const configOverride = options.claudeConfigDir ?? (env.CLAUDE_CONFIG_DIR?.trim() ? env.CLAUDE_CONFIG_DIR.trim() : void 0);
|
|
40601
|
-
const accountFile = configOverride ?
|
|
40602
|
-
const userSettingsFile =
|
|
41253
|
+
const accountFile = configOverride ? join33(configOverride, ".claude.json") : join33(home, ".claude.json");
|
|
41254
|
+
const userSettingsFile = join33(configOverride ?? join33(home, ".claude"), "settings.json");
|
|
40603
41255
|
const account = readJsonObject(accountFile);
|
|
40604
41256
|
const out = userScopeRemoteServers(account, cwd, env);
|
|
40605
|
-
const declared = objectField(readJsonObject(
|
|
41257
|
+
const declared = objectField(readJsonObject(join33(cwd, ".mcp.json")), "mcpServers");
|
|
40606
41258
|
if (!declared) return out;
|
|
40607
41259
|
const approval = collectApproval([
|
|
40608
|
-
readJsonObject(
|
|
40609
|
-
readJsonObject(
|
|
41260
|
+
readJsonObject(join33(cwd, ".claude", "settings.json")),
|
|
41261
|
+
readJsonObject(join33(cwd, ".claude", "settings.local.json")),
|
|
40610
41262
|
readJsonObject(userSettingsFile),
|
|
40611
41263
|
objectField(objectField(account, "projects"), cwd)
|
|
40612
41264
|
]);
|
|
@@ -40630,17 +41282,17 @@ var init_project_mcp_servers = __esm({
|
|
|
40630
41282
|
});
|
|
40631
41283
|
|
|
40632
41284
|
// packages/server/src/worker-plugin-dir.ts
|
|
40633
|
-
import { existsSync as
|
|
40634
|
-
import { dirname as dirname14, join as
|
|
41285
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
41286
|
+
import { dirname as dirname14, join as join34 } from "node:path";
|
|
40635
41287
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
40636
41288
|
function resolveWorkerPluginDir(moduleUrl = import.meta.url, env = process.env) {
|
|
40637
41289
|
const override = env.FRIZZ_WORKER_PLUGIN_DIR;
|
|
40638
|
-
if (override &&
|
|
41290
|
+
if (override && existsSync13(join34(override, ".claude-plugin", "plugin.json")))
|
|
40639
41291
|
return override;
|
|
40640
41292
|
let current = dirname14(fileURLToPath3(moduleUrl));
|
|
40641
41293
|
for (; ; ) {
|
|
40642
|
-
const candidate =
|
|
40643
|
-
if (
|
|
41294
|
+
const candidate = join34(current, "cc-worker");
|
|
41295
|
+
if (existsSync13(join34(candidate, ".claude-plugin", "plugin.json"))) return candidate;
|
|
40644
41296
|
const parent = dirname14(current);
|
|
40645
41297
|
if (parent === current) return void 0;
|
|
40646
41298
|
current = parent;
|
|
@@ -40654,14 +41306,14 @@ var init_worker_plugin_dir = __esm({
|
|
|
40654
41306
|
|
|
40655
41307
|
// packages/server/src/stable-plugin-path.ts
|
|
40656
41308
|
import { createHash as createHash16 } from "node:crypto";
|
|
40657
|
-
import { cpSync, lstatSync as lstatSync4, mkdirSync as mkdirSync17, readFileSync as
|
|
40658
|
-
import { homedir as
|
|
40659
|
-
import { dirname as dirname15, isAbsolute as isAbsolute7, join as
|
|
40660
|
-
function defaultPluginStageRoot(home =
|
|
40661
|
-
return
|
|
41309
|
+
import { cpSync, lstatSync as lstatSync4, mkdirSync as mkdirSync17, readFileSync as readFileSync23, readdirSync as readdirSync9, readlinkSync, realpathSync as realpathSync9, renameSync as renameSync7, rmSync as rmSync10, statSync as statSync16, symlinkSync as symlinkSync2 } from "node:fs";
|
|
41310
|
+
import { homedir as homedir14 } from "node:os";
|
|
41311
|
+
import { dirname as dirname15, isAbsolute as isAbsolute7, join as join35, resolve as resolve7 } from "node:path";
|
|
41312
|
+
function defaultPluginStageRoot(home = homedir14()) {
|
|
41313
|
+
return join35(frizzPaths({ home }).cache, "plugins");
|
|
40662
41314
|
}
|
|
40663
|
-
function defaultStablePluginRoot(home =
|
|
40664
|
-
return
|
|
41315
|
+
function defaultStablePluginRoot(home = homedir14()) {
|
|
41316
|
+
return join35(frizzPaths({ home }).cache, "current");
|
|
40665
41317
|
}
|
|
40666
41318
|
function ensureSymlink(link, target) {
|
|
40667
41319
|
mkdirSync17(dirname15(link), { recursive: true });
|
|
@@ -40697,31 +41349,31 @@ function stageStablePluginDir(opts) {
|
|
|
40697
41349
|
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(opts.version)) {
|
|
40698
41350
|
throw new Error(`unsafe plugin version identity: ${opts.version}`);
|
|
40699
41351
|
}
|
|
40700
|
-
const home = opts.home ??
|
|
41352
|
+
const home = opts.home ?? homedir14();
|
|
40701
41353
|
const stageRoot = opts.stageRoot ?? defaultPluginStageRoot(home);
|
|
40702
41354
|
const stableRoot = opts.stableRoot ?? defaultStablePluginRoot(home);
|
|
40703
|
-
const stagedPath =
|
|
41355
|
+
const stagedPath = join35(stageRoot, opts.version, name);
|
|
40704
41356
|
const staged = [name, ...siblings].every((entry) => {
|
|
40705
41357
|
try {
|
|
40706
|
-
lstatSync4(
|
|
41358
|
+
lstatSync4(join35(stageRoot, opts.version, entry));
|
|
40707
41359
|
return true;
|
|
40708
41360
|
} catch {
|
|
40709
41361
|
return false;
|
|
40710
41362
|
}
|
|
40711
41363
|
});
|
|
40712
41364
|
if (!staged) {
|
|
40713
|
-
const pending =
|
|
41365
|
+
const pending = join35(stageRoot, `.${opts.version}.pending-${process.pid}`);
|
|
40714
41366
|
rmSync10(pending, { recursive: true, force: true });
|
|
40715
41367
|
mkdirSync17(pending, { recursive: true });
|
|
40716
41368
|
try {
|
|
40717
41369
|
for (const sibling of siblings) {
|
|
40718
|
-
cpSync(
|
|
41370
|
+
cpSync(join35(dirname15(opts.source), sibling), join35(pending, sibling), { recursive: true, dereference: true });
|
|
40719
41371
|
}
|
|
40720
|
-
cpSync(opts.source,
|
|
40721
|
-
mkdirSync17(
|
|
41372
|
+
cpSync(opts.source, join35(pending, name), { recursive: true, dereference: true });
|
|
41373
|
+
mkdirSync17(join35(stageRoot, opts.version), { recursive: true });
|
|
40722
41374
|
for (const entry of [...siblings, name]) {
|
|
40723
41375
|
try {
|
|
40724
|
-
renameSync7(
|
|
41376
|
+
renameSync7(join35(pending, entry), join35(stageRoot, opts.version, entry));
|
|
40725
41377
|
} catch (error) {
|
|
40726
41378
|
const code = error?.code;
|
|
40727
41379
|
if (code !== "ENOTEMPTY" && code !== "EEXIST") throw error;
|
|
@@ -40731,7 +41383,7 @@ function stageStablePluginDir(opts) {
|
|
|
40731
41383
|
rmSync10(pending, { recursive: true, force: true });
|
|
40732
41384
|
}
|
|
40733
41385
|
}
|
|
40734
|
-
const stablePath =
|
|
41386
|
+
const stablePath = join35(stableRoot, name);
|
|
40735
41387
|
const outcome = ensureSymlink(stablePath, realpathSync9(stagedPath));
|
|
40736
41388
|
return { stablePath, stagedPath, outcome };
|
|
40737
41389
|
}
|
|
@@ -40740,7 +41392,7 @@ function pluginFiles(root) {
|
|
|
40740
41392
|
const walk = (dir, prefix) => {
|
|
40741
41393
|
for (const name of readdirSync9(dir).sort()) {
|
|
40742
41394
|
const rel = prefix ? `${prefix}/${name}` : name;
|
|
40743
|
-
if (statSync16(
|
|
41395
|
+
if (statSync16(join35(dir, name)).isDirectory()) walk(join35(dir, name), rel);
|
|
40744
41396
|
else files.push(rel);
|
|
40745
41397
|
}
|
|
40746
41398
|
};
|
|
@@ -40749,9 +41401,9 @@ function pluginFiles(root) {
|
|
|
40749
41401
|
}
|
|
40750
41402
|
function pluginContentDigest(dir, siblings = []) {
|
|
40751
41403
|
const hash = createHash16("sha256");
|
|
40752
|
-
const roots = [[dir, ""], ...siblings.map((s) => [
|
|
41404
|
+
const roots = [[dir, ""], ...siblings.map((s) => [join35(dirname15(dir), s), `../${s}/`])];
|
|
40753
41405
|
for (const [root, prefix] of roots) {
|
|
40754
|
-
for (const rel of pluginFiles(root)) hash.update(prefix + rel).update("\0").update(
|
|
41406
|
+
for (const rel of pluginFiles(root)) hash.update(prefix + rel).update("\0").update(readFileSync23(join35(root, rel))).update("\0");
|
|
40755
41407
|
}
|
|
40756
41408
|
return hash.digest("hex").slice(0, 16);
|
|
40757
41409
|
}
|
|
@@ -40806,7 +41458,9 @@ var init_workerPrompt = __esm({
|
|
|
40806
41458
|
COMMANDS_KEY_CLAUDE = `
|
|
40807
41459
|
- \`commands:\` \u2014 command watches you REGISTERED with \`frizzctl watch-command add\`, by their \`cmw_\u2026\`
|
|
40808
41460
|
id: a shell command the SERVER re-runs on a cadence until it exits 0, then wakes you once with its
|
|
40809
|
-
output.
|
|
41461
|
+
output. A monitor from \`frizzctl monitor add\` is named here too: a script the server keeps
|
|
41462
|
+
running, waking you on every line it prints. Only in \`bypassPermissions\` mode with Claude Code's
|
|
41463
|
+
sandbox off; Frizz refuses both otherwise.`;
|
|
40810
41464
|
COMMANDS_FOR_CLAUDE = `, and one naming
|
|
40811
41465
|
\`commands:\` with nothing but those, where it runs to a week`;
|
|
40812
41466
|
COMMANDS_CI_CLAUDE = `;
|
|
@@ -41312,7 +41966,7 @@ folder.
|
|
|
41312
41966
|
**A UI CONCEPT IS NOT A PICTURE \u2014 IT IS A PAGE, AND YOU LINK IT.** Pictures are evidence: something
|
|
41313
41967
|
broken on screen, or a LANDED change rendering correctly. A design that does not exist yet \u2014 a mockup,
|
|
41314
41968
|
a set of options, a layout, a terminal readout, copy variants \u2014 goes to the human as ONE self-contained
|
|
41315
|
-
HTML page carrying every candidate, linked in your message as \`[name](file:///abs/path.html)
|
|
41969
|
+
HTML page carrying every candidate, linked in your message as \`[name](file:///abs/path.html)\`, which Frizz opens in their default browser. Do not
|
|
41316
41970
|
screenshot it, judge the screenshots, or put them in a lightbox or a question option in its place: the
|
|
41317
41971
|
human reads the real page in their own browser faster and better than any picture of it (maintainer
|
|
41318
41972
|
2026-10-06: *"you should always just generate an artifact or an HTML page or whatever and just link me
|
|
@@ -41894,14 +42548,19 @@ sub-agent alone does not.
|
|
|
41894
42548
|
it with \`status: watching\`. A Bash call that names no \`timeout\` moves to the background at the
|
|
41895
42549
|
tool's default, so the watcher names one sized to the wait (up to 24h) and loops until its terminal
|
|
41896
42550
|
condition. A helper must not hand back while its own watcher is still live.
|
|
42551
|
+
- **Woken on every occurrence, not once** (each new comment on a PR, each ERROR in a log, each CI step
|
|
42552
|
+
as it lands) \u2192 \`frizzctl monitor add "<script printing one line per event>" --description "<what>"
|
|
42553
|
+
--for 1d\`, then rest on its id (\`commands: [cmw_\u2026]\`) with \`status: watching\`. The server keeps the
|
|
42554
|
+
script running across your turns, and every line it prints wakes you. Where Frizz refuses it (the
|
|
42555
|
+
same gate as above), use Claude Code's \`Monitor\` instead.
|
|
41897
42556
|
- **Working alongside a process you launched** (dev server, log tail) \u2192 \`Bash\` with
|
|
41898
42557
|
\`run_in_background: true\`. Never put shell job control (\`&\`, \`nohup \u2026 &\`, \`disown\`) inside the
|
|
41899
42558
|
command to imitate the native flag: frizz's hook rejects an escaping job, because the process could
|
|
41900
42559
|
survive without a lifecycle id or wake.
|
|
41901
42560
|
- \`Monitor\` streams events INTO an active turn (\`persistent: true\` runs until \`TaskStop\` or session
|
|
41902
|
-
end); it is not something to park a rest on. \`TaskOutput\` is deprecated \u2014
|
|
41903
|
-
path for diagnostics. \`TaskStop\` is only for your own monitor after its
|
|
41904
|
-
cut off a sub-agent.
|
|
42561
|
+
end); it is not something to park a rest on \u2014 \`frizzctl monitor\` is. \`TaskOutput\` is deprecated \u2014
|
|
42562
|
+
use \`Read\` on that output path for diagnostics. \`TaskStop\` is only for your own monitor after its
|
|
42563
|
+
terminal handoff, never to cut off a sub-agent.
|
|
41905
42564
|
|
|
41906
42565
|
These live tasks do not survive the session ending. Never fake a wait with \`echo waiting\` or repeated
|
|
41907
42566
|
foreground sleeps.
|
|
@@ -42158,6 +42817,10 @@ complete, self-contained message, not a drip. It reaches a thread in ANY project
|
|
|
42158
42817
|
not only yours: pass the thread's full link (\`/project/<project>/thread/<slug>\`), or add
|
|
42159
42818
|
\`--project <project>\` to a bare slug.
|
|
42160
42819
|
|
|
42820
|
+
\`frizzctl threads\` lists every thread on your board \u2014 its slug, the title the human sees, and where it
|
|
42821
|
+
sits: spinning, in the human's queue, parked or done \u2014 and \`frizzctl threads <project>\` another
|
|
42822
|
+
project's. It is how you find the thread to send to, and whether one is already on the work in front of you.
|
|
42823
|
+
|
|
42161
42824
|
A message wrapped in \`<thread-message>\` came from another thread, which it names: a colleague's
|
|
42162
42825
|
message, not the human's. Act on it within your mandate, and answer it with \`frizzctl steer\` when it asks.`;
|
|
42163
42826
|
THREAD_EXECUTION = {
|
|
@@ -42256,7 +42919,7 @@ checks. Depth scales with blast radius and yields to the project's conventions.`
|
|
|
42256
42919
|
|
|
42257
42920
|
// packages/server/src/backend/acp-agents.ts
|
|
42258
42921
|
import { accessSync as accessSync3, constants as constants2, statSync as statSync17 } from "node:fs";
|
|
42259
|
-
import { delimiter as delimiter2, isAbsolute as isAbsolute8, join as
|
|
42922
|
+
import { delimiter as delimiter2, isAbsolute as isAbsolute8, join as join36 } from "node:path";
|
|
42260
42923
|
function isExecutableFile(path3) {
|
|
42261
42924
|
try {
|
|
42262
42925
|
if (!statSync17(path3).isFile()) return false;
|
|
@@ -42272,9 +42935,9 @@ function findOnPath(command, env = process.env) {
|
|
|
42272
42935
|
const exts = process.platform === "win32" ? ["", ...(env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";")] : [""];
|
|
42273
42936
|
for (const dir of dirs) {
|
|
42274
42937
|
for (const ext of exts) {
|
|
42275
|
-
const candidate =
|
|
42938
|
+
const candidate = join36(dir, command + ext.toLowerCase());
|
|
42276
42939
|
if (isExecutableFile(candidate)) return candidate;
|
|
42277
|
-
if (ext && isExecutableFile(
|
|
42940
|
+
if (ext && isExecutableFile(join36(dir, command + ext))) return join36(dir, command + ext);
|
|
42278
42941
|
}
|
|
42279
42942
|
}
|
|
42280
42943
|
return void 0;
|
|
@@ -42628,11 +43291,11 @@ var init_claude_broker_client = __esm({
|
|
|
42628
43291
|
});
|
|
42629
43292
|
|
|
42630
43293
|
// packages/server/src/backend/claude-permission-interactions.ts
|
|
42631
|
-
import { homedir as
|
|
43294
|
+
import { homedir as homedir15 } from "node:os";
|
|
42632
43295
|
function clip(text2, max) {
|
|
42633
43296
|
return text2.length > max ? `${text2.slice(0, max - 1)}\u2026` : text2;
|
|
42634
43297
|
}
|
|
42635
|
-
function tildePath(path3, home =
|
|
43298
|
+
function tildePath(path3, home = homedir15()) {
|
|
42636
43299
|
if (!path3.startsWith(home)) return path3;
|
|
42637
43300
|
const rest = path3.slice(home.length);
|
|
42638
43301
|
return rest === "" ? "~" : /^[\\/]/.test(rest) ? `~${rest}` : path3;
|
|
@@ -43323,8 +43986,8 @@ var init_claude_agent_broker_bridge = __esm({
|
|
|
43323
43986
|
});
|
|
43324
43987
|
|
|
43325
43988
|
// packages/server/src/dispatch.ts
|
|
43326
|
-
import { closeSync as closeSync14, constants as constants3, existsSync as
|
|
43327
|
-
import { basename as basename7, join as
|
|
43989
|
+
import { closeSync as closeSync14, constants as constants3, existsSync as existsSync14, fstatSync as fstatSync3, lstatSync as lstatSync5, openSync as openSync15, readFileSync as readFileSync24, realpathSync as realpathSync10, statSync as statSync18, writeFileSync as writeFileSync13, mkdirSync as mkdirSync18, rmSync as rmSync11 } from "node:fs";
|
|
43990
|
+
import { basename as basename7, join as join37, dirname as dirname16 } from "node:path";
|
|
43328
43991
|
import { createHash as createHash17, randomUUID as randomUUID14 } from "node:crypto";
|
|
43329
43992
|
function fallbackTitle(prompt) {
|
|
43330
43993
|
const firstLine2 = prompt.trim().split("\n", 1)[0].trim();
|
|
@@ -43343,7 +44006,7 @@ function fallbackTitle(prompt) {
|
|
|
43343
44006
|
}
|
|
43344
44007
|
function resolveSlug(frizzDir, base, taken) {
|
|
43345
44008
|
base = ThreadSlug.parse(base);
|
|
43346
|
-
const isTaken = (slug) =>
|
|
44009
|
+
const isTaken = (slug) => existsSync14(join37(frizzDir, `${slug}.md`)) || (taken?.(slug) ?? false);
|
|
43347
44010
|
if (!isTaken(base)) return base;
|
|
43348
44011
|
for (let n = 2; ; n++) {
|
|
43349
44012
|
const suffix = `-${n}`;
|
|
@@ -43360,12 +44023,12 @@ function resolveLegacyThreadFile(projectDir, value) {
|
|
|
43360
44023
|
if (!parsed.success) return null;
|
|
43361
44024
|
try {
|
|
43362
44025
|
const projectRoot = realpathSync10(projectDir);
|
|
43363
|
-
const frizzPath =
|
|
44026
|
+
const frizzPath = join37(projectRoot, ".frizz");
|
|
43364
44027
|
const frizzStat = lstatSync5(frizzPath);
|
|
43365
44028
|
if (!frizzStat.isDirectory() || frizzStat.isSymbolicLink()) return null;
|
|
43366
44029
|
const realFrizz = realpathSync10(frizzPath);
|
|
43367
44030
|
if (dirname16(realFrizz) !== projectRoot || basename7(realFrizz) !== ".frizz") return null;
|
|
43368
|
-
const path3 =
|
|
44031
|
+
const path3 = join37(realFrizz, `${parsed.data}.md`);
|
|
43369
44032
|
const before = lstatSync5(path3);
|
|
43370
44033
|
if (!before.isFile() || before.isSymbolicLink()) return null;
|
|
43371
44034
|
const realPath = realpathSync10(path3);
|
|
@@ -43376,7 +44039,7 @@ function resolveLegacyThreadFile(projectDir, value) {
|
|
|
43376
44039
|
const fd2 = openSync15(path3, constants3.O_RDONLY | constants3.O_NOFOLLOW);
|
|
43377
44040
|
try {
|
|
43378
44041
|
openedBefore = fstatSync3(fd2);
|
|
43379
|
-
contents =
|
|
44042
|
+
contents = readFileSync24(fd2);
|
|
43380
44043
|
openedAfter = fstatSync3(fd2);
|
|
43381
44044
|
} finally {
|
|
43382
44045
|
closeSync14(fd2);
|
|
@@ -43409,7 +44072,7 @@ function boardAuthorizesAdoption(board, slug) {
|
|
|
43409
44072
|
return !board.errorItems.some((item) => item.file === `${slug}.md`);
|
|
43410
44073
|
}
|
|
43411
44074
|
function ensureSafeDirectDirectory(parent, name) {
|
|
43412
|
-
const path3 =
|
|
44075
|
+
const path3 = join37(parent, name);
|
|
43413
44076
|
try {
|
|
43414
44077
|
mkdirSync18(path3);
|
|
43415
44078
|
} catch (error) {
|
|
@@ -43439,8 +44102,8 @@ function loadWorkerPrompt(kind = "claude") {
|
|
|
43439
44102
|
function monitorScriptsDir() {
|
|
43440
44103
|
const plugin = workerPluginDir();
|
|
43441
44104
|
if (!plugin) return void 0;
|
|
43442
|
-
const dir =
|
|
43443
|
-
return
|
|
44105
|
+
const dir = join37(plugin, "skills", "gh", "scripts");
|
|
44106
|
+
return existsSync14(join37(dir, "ci-watch.mjs")) ? dir : void 0;
|
|
43444
44107
|
}
|
|
43445
44108
|
function codexScratchpadHookConfig(hookScript, sessionId) {
|
|
43446
44109
|
if (!hookScript || !sessionId) return {};
|
|
@@ -43452,7 +44115,7 @@ function codexScratchpadHookConfig(hookScript, sessionId) {
|
|
|
43452
44115
|
}
|
|
43453
44116
|
]
|
|
43454
44117
|
});
|
|
43455
|
-
const bashBackgroundHook =
|
|
44118
|
+
const bashBackgroundHook = join37(dirname16(hookScript), "bash-background.mjs");
|
|
43456
44119
|
return {
|
|
43457
44120
|
bypass_hook_trust: true,
|
|
43458
44121
|
hooks: {
|
|
@@ -43485,7 +44148,7 @@ function codexWorkerThreadConfig(sessionId) {
|
|
|
43485
44148
|
}
|
|
43486
44149
|
function scratchpadHookScript() {
|
|
43487
44150
|
const plugin = workerPluginDir();
|
|
43488
|
-
return plugin ?
|
|
44151
|
+
return plugin ? join37(plugin, "hooks", "scratchpad.mjs") : void 0;
|
|
43489
44152
|
}
|
|
43490
44153
|
function composePrompt(sessionId, prompt, kind = "claude") {
|
|
43491
44154
|
const children2 = kind === "codex" ? "Native sub-agents share it \u2014 have each write its OWN file rather than all editing one." : "Name it in a sub-agent's prompt when you want its notes to land somewhere you can read; give each child its OWN file rather than having them all edit one.";
|
|
@@ -43510,12 +44173,12 @@ function scratchpadOrientation(sessionId, kind = "claude") {
|
|
|
43510
44173
|
return `SCRATCH DIRECTORY: .frizz/threads/${sessionId}/ \u2014 yours, free-form, as many files as you like, and nothing is expected in it. A single direct task usually needs none; writing notes is never a substitute for doing the work (${children2}). Nothing in this directory is read automatically; if you want a note back after a compaction, \`frizzctl goal start --post-compaction\` re-sends a prompt of your choosing.`;
|
|
43511
44174
|
}
|
|
43512
44175
|
function frizzConfigBlock(projectDir) {
|
|
43513
|
-
const path3 =
|
|
44176
|
+
const path3 = join37(projectDir, "FRIZZ.md");
|
|
43514
44177
|
let body;
|
|
43515
44178
|
try {
|
|
43516
44179
|
const st2 = statSync18(path3);
|
|
43517
44180
|
if (!st2.isFile() || st2.size > FRIZZ_MD_MAX_BYTES) return "";
|
|
43518
|
-
body =
|
|
44181
|
+
body = readFileSync24(path3, "utf8").trim();
|
|
43519
44182
|
} catch {
|
|
43520
44183
|
return "";
|
|
43521
44184
|
}
|
|
@@ -43553,8 +44216,8 @@ function systemPromptFlags(sessionId, system) {
|
|
|
43553
44216
|
function resolveFrizzCli(target, pluginDir = workerPluginDir()) {
|
|
43554
44217
|
const { stateDir, serverLock, projectId } = typeof target === "string" ? { stateDir: target } : target;
|
|
43555
44218
|
if (!pluginDir) return void 0;
|
|
43556
|
-
const binDir =
|
|
43557
|
-
if (!
|
|
44219
|
+
const binDir = join37(pluginDir, "bin");
|
|
44220
|
+
if (!existsSync14(join37(binDir, FRIZZ_CLI.name))) return void 0;
|
|
43558
44221
|
return {
|
|
43559
44222
|
binDir,
|
|
43560
44223
|
stateDir,
|
|
@@ -43566,8 +44229,8 @@ function resolveFrizzMcp(target, moduleUrl = import.meta.url, env = process.env,
|
|
|
43566
44229
|
const { stateDir, serverLock, projectId } = typeof target === "string" ? { stateDir: target } : target;
|
|
43567
44230
|
const pluginDir = resolveWorkerPluginDir(moduleUrl, env);
|
|
43568
44231
|
if (!pluginDir) return void 0;
|
|
43569
|
-
const scriptPath =
|
|
43570
|
-
if (!
|
|
44232
|
+
const scriptPath = join37(pluginDir, "bin", FRIZZ_MCP.script);
|
|
44233
|
+
if (!existsSync14(scriptPath)) return void 0;
|
|
43571
44234
|
return {
|
|
43572
44235
|
scriptPath,
|
|
43573
44236
|
stateDir,
|
|
@@ -43667,7 +44330,7 @@ function buildClaudeResumeCommand(opts) {
|
|
|
43667
44330
|
}
|
|
43668
44331
|
function createDispatcher(deps) {
|
|
43669
44332
|
const readBoardSource = deps.readBoard ?? readBoard;
|
|
43670
|
-
const frizzDir =
|
|
44333
|
+
const frizzDir = join37(deps.project.dir, ".frizz");
|
|
43671
44334
|
const adoptionRuntime = deps.adoptionRuntime ?? productionRuntime;
|
|
43672
44335
|
const inFlightSlugs = /* @__PURE__ */ new Set();
|
|
43673
44336
|
function cleanupPrewrites(built) {
|
|
@@ -43681,7 +44344,7 @@ function createDispatcher(deps) {
|
|
|
43681
44344
|
function cleanupDispatchFiles(scratchRel, built, sessionId) {
|
|
43682
44345
|
cleanupPrewrites(built);
|
|
43683
44346
|
try {
|
|
43684
|
-
rmSync11(
|
|
44347
|
+
rmSync11(join37(deps.project.dir, scratchRel), { force: true, recursive: true });
|
|
43685
44348
|
} catch {
|
|
43686
44349
|
}
|
|
43687
44350
|
cleanupAdoptionSessionFiles(deps.project.dir, sessionId);
|
|
@@ -43908,7 +44571,7 @@ function createDispatcher(deps) {
|
|
|
43908
44571
|
throw new Error("that session is already a frizz thread");
|
|
43909
44572
|
}
|
|
43910
44573
|
}
|
|
43911
|
-
const
|
|
44574
|
+
const displayTitle2 = title?.trim() || `Session ${externalId.slice(0, 8)}`;
|
|
43912
44575
|
const slug = externalId;
|
|
43913
44576
|
const sessionId = externalId;
|
|
43914
44577
|
writeScratchDir(deps.project.dir, sessionId);
|
|
@@ -43926,7 +44589,7 @@ function createDispatcher(deps) {
|
|
|
43926
44589
|
// either way, not the dispatch chop, so it is not marked provisional. It stays replaceable:
|
|
43927
44590
|
// the worker's own later title for the task is nearly always the more informative one.
|
|
43928
44591
|
title_auto: 0,
|
|
43929
|
-
title:
|
|
44592
|
+
title: displayTitle2,
|
|
43930
44593
|
transcript_id: null,
|
|
43931
44594
|
state: "open",
|
|
43932
44595
|
meta: null,
|
|
@@ -44175,8 +44838,8 @@ import {
|
|
|
44175
44838
|
realpathSync as realpathSync11,
|
|
44176
44839
|
watch as fsWatch
|
|
44177
44840
|
} from "node:fs";
|
|
44178
|
-
import { homedir as
|
|
44179
|
-
import { dirname as dirname17, join as
|
|
44841
|
+
import { homedir as homedir16 } from "node:os";
|
|
44842
|
+
import { dirname as dirname17, join as join38 } from "node:path";
|
|
44180
44843
|
import watcher from "@parcel/watcher";
|
|
44181
44844
|
function appServerTurnStalled(liveness, lastActivityAt, nowMs) {
|
|
44182
44845
|
if (!liveness) return false;
|
|
@@ -44461,7 +45124,10 @@ function fenceWatchViews(slug, tele, fenceAt, github = {}, registered = [], arme
|
|
|
44461
45124
|
every: formatElapsed(w.every_ms),
|
|
44462
45125
|
expiresAt: new Date(w.expires_at).toISOString(),
|
|
44463
45126
|
runs: w.runs,
|
|
44464
|
-
...w.last_run_at !== null && w.last_outcome ? { lastRun: { at: new Date(w.last_run_at).toISOString(), outcome: w.last_outcome, exitCode: w.last_exit, output: w.last_output ?? "" } } : {}
|
|
45127
|
+
...w.last_run_at !== null && w.last_outcome ? { lastRun: { at: new Date(w.last_run_at).toISOString(), outcome: w.last_outcome, exitCode: w.last_exit, output: w.last_output ?? "" } } : {},
|
|
45128
|
+
// A MONITOR (`frizzctl monitor`, 2026-11-02) is a running script, not a check on a cadence: its
|
|
45129
|
+
// row reads its events instead. The same projection as the worker's read-back.
|
|
45130
|
+
...w.kind === "monitor" ? { monitor: monitorStatusOf(w) } : {}
|
|
44465
45131
|
}
|
|
44466
45132
|
});
|
|
44467
45133
|
}
|
|
@@ -45196,7 +45862,7 @@ function createBoard(project, storage, bus, tailer, bootId, deps = {}) {
|
|
|
45196
45862
|
...project.githubRepo ? { githubRepo: project.githubRepo } : {},
|
|
45197
45863
|
projectSlug: findByPath(project.dir)?.slug,
|
|
45198
45864
|
// So the client can expand a `~` a worker wrote in prose (see BoardSnapshot.homeDir).
|
|
45199
|
-
homeDir:
|
|
45865
|
+
homeDir: homedir16()
|
|
45200
45866
|
};
|
|
45201
45867
|
const sessionThreads = buildSessionThreads(assembledAtMs);
|
|
45202
45868
|
stampRunningSince(sessionThreads, assembledAtMs);
|
|
@@ -45303,7 +45969,7 @@ function createBoard(project, storage, bus, tailer, bootId, deps = {}) {
|
|
|
45303
45969
|
if (parcelSub || stopped) return Promise.resolve();
|
|
45304
45970
|
if (watchSetup) return watchSetup;
|
|
45305
45971
|
const setup = (async () => {
|
|
45306
|
-
const dir =
|
|
45972
|
+
const dir = join38(project.dir, ".frizz");
|
|
45307
45973
|
const roots = /* @__PURE__ */ new Set([dir]);
|
|
45308
45974
|
try {
|
|
45309
45975
|
roots.add(realpathSync11(dir));
|
|
@@ -45318,7 +45984,7 @@ function createBoard(project, storage, bus, tailer, bootId, deps = {}) {
|
|
|
45318
45984
|
}
|
|
45319
45985
|
if (events.some((event) => isBoardRelevantFrizzPath(roots, event.path))) scheduleRebuild();
|
|
45320
45986
|
},
|
|
45321
|
-
{ ignore: FRIZZ_WATCH_IGNORED_DIRS.map((name) =>
|
|
45987
|
+
{ ignore: FRIZZ_WATCH_IGNORED_DIRS.map((name) => join38(dir, name)) }
|
|
45322
45988
|
);
|
|
45323
45989
|
if (stopped) {
|
|
45324
45990
|
await next.unsubscribe();
|
|
@@ -45407,6 +46073,7 @@ var init_board = __esm({
|
|
|
45407
46073
|
init_question_fences();
|
|
45408
46074
|
init_src();
|
|
45409
46075
|
init_storage();
|
|
46076
|
+
init_command_watch();
|
|
45410
46077
|
init_thread_links();
|
|
45411
46078
|
init_thread_profiles();
|
|
45412
46079
|
init_claude_model_upgrade();
|
|
@@ -45472,13 +46139,13 @@ var init_board = __esm({
|
|
|
45472
46139
|
});
|
|
45473
46140
|
|
|
45474
46141
|
// packages/server/src/session-peer.ts
|
|
45475
|
-
import { mkdirSync as mkdirSync19, readFileSync as
|
|
45476
|
-
import { homedir as
|
|
45477
|
-
import { dirname as dirname18, join as
|
|
45478
|
-
function claudeSessionDirs(env = process.env, home =
|
|
45479
|
-
const dirs = [
|
|
46142
|
+
import { mkdirSync as mkdirSync19, readFileSync as readFileSync25, renameSync as renameSync9, writeFileSync as writeFileSync14 } from "node:fs";
|
|
46143
|
+
import { homedir as homedir17 } from "node:os";
|
|
46144
|
+
import { dirname as dirname18, join as join39 } from "node:path";
|
|
46145
|
+
function claudeSessionDirs(env = process.env, home = homedir17()) {
|
|
46146
|
+
const dirs = [join39(home, ".claude", "sessions")];
|
|
45480
46147
|
const override = env.CLAUDE_CONFIG_DIR?.trim();
|
|
45481
|
-
if (override) dirs.unshift(
|
|
46148
|
+
if (override) dirs.unshift(join39(override, "sessions"));
|
|
45482
46149
|
return [...new Set(dirs)];
|
|
45483
46150
|
}
|
|
45484
46151
|
function sessionIdForPeerSocket(peer, dirs) {
|
|
@@ -45488,7 +46155,7 @@ function sessionIdForPeerSocket(peer, dirs) {
|
|
|
45488
46155
|
for (const dir of dirs) {
|
|
45489
46156
|
let entry;
|
|
45490
46157
|
try {
|
|
45491
|
-
entry = JSON.parse(
|
|
46158
|
+
entry = JSON.parse(readFileSync25(join39(dir, `${pid}.json`), "utf8"));
|
|
45492
46159
|
} catch {
|
|
45493
46160
|
continue;
|
|
45494
46161
|
}
|
|
@@ -45506,7 +46173,7 @@ function createSessionPeerResolver(deps) {
|
|
|
45506
46173
|
remembered = {};
|
|
45507
46174
|
if (deps.memoryFile) {
|
|
45508
46175
|
try {
|
|
45509
|
-
const parsed = JSON.parse(
|
|
46176
|
+
const parsed = JSON.parse(readFileSync25(deps.memoryFile, "utf8"));
|
|
45510
46177
|
if (parsed && typeof parsed === "object") {
|
|
45511
46178
|
for (const [k2, v] of Object.entries(parsed)) if (typeof v === "string") remembered[k2] = v;
|
|
45512
46179
|
}
|
|
@@ -45784,7 +46451,16 @@ var init_wake_store = __esm({
|
|
|
45784
46451
|
"park:dead:",
|
|
45785
46452
|
"park:needs-input:",
|
|
45786
46453
|
"park:question-fence:",
|
|
45787
|
-
"park:done-open-question:"
|
|
46454
|
+
"park:done-open-question:",
|
|
46455
|
+
"cmdwatch:",
|
|
46456
|
+
"cmdwatch-expired:",
|
|
46457
|
+
"cmdwatch-cancelled:",
|
|
46458
|
+
// A MONITOR's three endings (2026-11-02), for the same reason: each settles the row and ends the park.
|
|
46459
|
+
// Its EVENTS (`cmdmon:`) are NOT here — the row stays armed under them, so the park keeps holding, and a
|
|
46460
|
+
// monitor printing every minute is exactly the burst the window exists to merge into one turn.
|
|
46461
|
+
"cmdmon-exited:",
|
|
46462
|
+
"cmdmon-expired:",
|
|
46463
|
+
"cmdmon-cancelled:"
|
|
45788
46464
|
];
|
|
45789
46465
|
OUTBOX_CAP = 2e3;
|
|
45790
46466
|
WAKE_DELIVERY_TABLES = ["wake_delivery"];
|
|
@@ -46710,7 +47386,7 @@ function armedCommandWatchIdsOf(storage, slug) {
|
|
|
46710
47386
|
return new Set(storage.listCommandWatches(slug, { armedOnly: true }).map((w) => w.id));
|
|
46711
47387
|
}
|
|
46712
47388
|
function commandWatchOps(storage, slug) {
|
|
46713
|
-
return storage.listCommandWatches(slug, { armedOnly: true }).map((w) => ({ id: w.id, label: w.command.trim().replace(/\s+/g, " ").slice(0, 80) }));
|
|
47389
|
+
return storage.listCommandWatches(slug, { armedOnly: true }).map((w) => ({ id: w.id, label: w.kind === "monitor" ? `monitor: ${monitorLabel(w)}` : w.command.trim().replace(/\s+/g, " ").slice(0, 80) }));
|
|
46714
47390
|
}
|
|
46715
47391
|
function armedSchedule(row) {
|
|
46716
47392
|
const prompt = row.recurring_prompt?.trim();
|
|
@@ -46786,7 +47462,7 @@ function isOwnWatchExpiredFenceId(fenceId) {
|
|
|
46786
47462
|
return fenceId.startsWith(`${OWN_WATCH_EXPIRED_FENCE_PREFIX}:`);
|
|
46787
47463
|
}
|
|
46788
47464
|
function isCommandWatchFenceId(fenceId) {
|
|
46789
|
-
return fenceId.startsWith(`${COMMAND_WATCH_FENCE_PREFIX}:`) || fenceId.startsWith(`${COMMAND_WATCH_EXPIRED_FENCE_PREFIX}:`) || fenceId.startsWith(`${COMMAND_WATCH_CANCELLED_FENCE_PREFIX}:`);
|
|
47465
|
+
return fenceId.startsWith(`${COMMAND_WATCH_FENCE_PREFIX}:`) || fenceId.startsWith(`${COMMAND_WATCH_EXPIRED_FENCE_PREFIX}:`) || fenceId.startsWith(`${COMMAND_WATCH_CANCELLED_FENCE_PREFIX}:`) || fenceId.startsWith(`${MONITOR_EVENT_FENCE_PREFIX}:`) || fenceId.startsWith(`${MONITOR_EXITED_FENCE_PREFIX}:`) || fenceId.startsWith(`${MONITOR_EXPIRED_FENCE_PREFIX}:`) || fenceId.startsWith(`${MONITOR_CANCELLED_FENCE_PREFIX}:`);
|
|
46790
47466
|
}
|
|
46791
47467
|
function questionAnswerFenceId(ids) {
|
|
46792
47468
|
return `${QUESTION_ANSWER_FENCE_PREFIX}:${createHash18("sha256").update([...ids].sort().join(",")).digest("hex").slice(0, 16)}`;
|
|
@@ -47509,13 +48185,15 @@ ${wakeTimeHeader(nowMs, spokeAt)}`,
|
|
|
47509
48185
|
awaitingNeedsInput(tele.lastFence.hints) === false ? idlePrs : void 0
|
|
47510
48186
|
);
|
|
47511
48187
|
const settledCommands = new Map(
|
|
47512
|
-
deps.storage.listCommandWatches(row.slug).filter((w) => w.state !== "armed").map((w) => [w.id, w
|
|
48188
|
+
deps.storage.listCommandWatches(row.slug).filter((w) => w.state !== "armed").map((w) => [w.id, w])
|
|
47513
48189
|
);
|
|
47514
48190
|
const deadAll = unaccountedItems(park.items, live2);
|
|
47515
48191
|
const ownWakeInFlight = (i) => {
|
|
47516
48192
|
if (i.kind !== "command") return false;
|
|
47517
|
-
const
|
|
47518
|
-
const
|
|
48193
|
+
const watch2 = settledCommands.get(i.value);
|
|
48194
|
+
const settled = watch2?.state;
|
|
48195
|
+
const monitor = watch2?.kind === "monitor";
|
|
48196
|
+
const prefix = settled === "passed" ? monitor ? MONITOR_EXITED_FENCE_PREFIX : COMMAND_WATCH_FENCE_PREFIX : settled === "expired" ? monitor ? MONITOR_EXPIRED_FENCE_PREFIX : COMMAND_WATCH_EXPIRED_FENCE_PREFIX : settled === "cancelled" ? monitor ? MONITOR_CANCELLED_FENCE_PREFIX : COMMAND_WATCH_CANCELLED_FENCE_PREFIX : void 0;
|
|
47519
48197
|
if (!prefix) return false;
|
|
47520
48198
|
const wake = outbox.get(wakeDeliveryId(row.slug, row.session_id, `${prefix}:${i.value}`));
|
|
47521
48199
|
return wake?.state === "pending" || wake?.state === "leased";
|
|
@@ -47603,10 +48281,10 @@ ${wakeTimeHeader(nowMs, spokeAt)}`,
|
|
|
47603
48281
|
const firedTimers = new Set(
|
|
47604
48282
|
deps.storage.listThreadTimers(row.slug).filter((t) => t.state === "fired").map((t) => t.id)
|
|
47605
48283
|
);
|
|
47606
|
-
const finishedItem = (i) => finishedHandles.has(i.value) || i.kind === "timer" && firedTimers.has(i.value) || i.kind === "command" && settledCommands.get(i.value) === "passed";
|
|
48284
|
+
const finishedItem = (i) => finishedHandles.has(i.value) || i.kind === "timer" && firedTimers.has(i.value) || i.kind === "command" && settledCommands.get(i.value)?.state === "passed";
|
|
47607
48285
|
const status = park.items.map((i) => {
|
|
47608
48286
|
const gone = deadAll.some((d) => d.kind === i.kind && d.value === i.value);
|
|
47609
|
-
const note = !gone ? "still running" : i.kind === "timer" && firedTimers.has(i.value) ? "already FIRED \u2014 its wake was delivered; there is nothing left to wait on" : i.kind === "command" && settledCommands.get(i.value) === "passed" ? "already PASSED \u2014 its wake was delivered; there is nothing left to wait on" : i.kind === "command" && settledCommands.has(i.value) ? `no longer armed (${settledCommands.get(i.value)}) \u2014 register it again with \`frizzctl watch-command add\` if you still need the wait` : finishedItem(i) ? "FINISHED \u2014 its result is waiting for you" : i.kind === "shell" && staleShellHandles.has(i.value) ? "GONE WITHOUT A COMPLETION NOTICE \u2014 frizz knows this shell, but nothing holds its output file and no process it could be is still running; read its output to see how it ended" : i.kind === "pr" ? "NOT REGISTERED \u2014 register it with `frizzctl watch-pr add` first, then name it here" : i.kind === "issue" ? "NOT REGISTERED \u2014 register it with `frizzctl watch-issue add` first, then name it here" : i.kind === "command" ? "NOT REGISTERED \u2014 register it with `frizzctl watch-command add` first, then name the id it gives you here" : "NOT RUNNING (nothing by that name)";
|
|
48287
|
+
const note = !gone ? "still running" : i.kind === "timer" && firedTimers.has(i.value) ? "already FIRED \u2014 its wake was delivered; there is nothing left to wait on" : i.kind === "command" && settledCommands.get(i.value)?.state === "passed" ? settledCommands.get(i.value)?.kind === "monitor" ? "already ENDED \u2014 its script exited and that wake was delivered; there is nothing left to wait on" : "already PASSED \u2014 its wake was delivered; there is nothing left to wait on" : i.kind === "command" && settledCommands.has(i.value) ? `no longer armed (${settledCommands.get(i.value)?.state}) \u2014 register it again with \`frizzctl ${settledCommands.get(i.value)?.kind === "monitor" ? "monitor" : "watch-command"} add\` if you still need the wait` : finishedItem(i) ? "FINISHED \u2014 its result is waiting for you" : i.kind === "shell" && staleShellHandles.has(i.value) ? "GONE WITHOUT A COMPLETION NOTICE \u2014 frizz knows this shell, but nothing holds its output file and no process it could be is still running; read its output to see how it ended" : i.kind === "pr" ? "NOT REGISTERED \u2014 register it with `frizzctl watch-pr add` first, then name it here" : i.kind === "issue" ? "NOT REGISTERED \u2014 register it with `frizzctl watch-issue add` first, then name it here" : i.kind === "command" ? "NOT REGISTERED \u2014 register it with `frizzctl watch-command add` first, then name the id it gives you here" : "NOT RUNNING (nothing by that name)";
|
|
47610
48288
|
return `- \`${AWAITING_KEY_OF[i.kind]}: [${i.value}]\` \u2014 ${note}`;
|
|
47611
48289
|
});
|
|
47612
48290
|
if (park.steps.length > 0) {
|
|
@@ -48240,6 +48918,10 @@ ${clock}`;
|
|
|
48240
48918
|
}
|
|
48241
48919
|
function evalCommandWatches(nowMs) {
|
|
48242
48920
|
for (const w of deps.storage.expiredCommandWatches(nowMs)) {
|
|
48921
|
+
if (w.kind === "monitor") {
|
|
48922
|
+
expireMonitor(w, nowMs);
|
|
48923
|
+
continue;
|
|
48924
|
+
}
|
|
48243
48925
|
commandRuns.get(w.id)?.abort.abort();
|
|
48244
48926
|
const row = deps.storage.getSession(w.thread_slug);
|
|
48245
48927
|
if (threadIsLive(row)) {
|
|
@@ -48257,9 +48939,14 @@ ${clock}`;
|
|
|
48257
48939
|
const armed = deps.storage.armedCommandWatches();
|
|
48258
48940
|
const armedIds = new Set(armed.map((w) => w.id));
|
|
48259
48941
|
for (const [id2, run3] of commandRuns) if (!armedIds.has(id2)) run3.abort.abort();
|
|
48942
|
+
for (const [id2, live2] of monitors) if (!armedIds.has(id2)) stopMonitor(live2, "dropped");
|
|
48260
48943
|
const service = deps.commandWatches;
|
|
48261
48944
|
if (!service) return;
|
|
48262
48945
|
for (const w of armed) {
|
|
48946
|
+
if (w.kind === "monitor") {
|
|
48947
|
+
evalMonitor(service, w, nowMs);
|
|
48948
|
+
continue;
|
|
48949
|
+
}
|
|
48263
48950
|
if (commandRuns.has(w.id)) continue;
|
|
48264
48951
|
const dueAt = w.last_run_at !== null ? w.last_run_at + w.every_ms : w.created_at;
|
|
48265
48952
|
if (nowMs < dueAt) continue;
|
|
@@ -48322,6 +49009,166 @@ ${clock}`;
|
|
|
48322
49009
|
log3(`waker: settled ${w.thread_slug} \u2014 command watch ${w.id} passed`);
|
|
48323
49010
|
kick();
|
|
48324
49011
|
}
|
|
49012
|
+
const MONITOR_GATE_RECHECK_MS = 6e4;
|
|
49013
|
+
const monitors = /* @__PURE__ */ new Map();
|
|
49014
|
+
function nextWakeAt(live2) {
|
|
49015
|
+
live2.lastWakeAtMs = Math.max(now(), live2.lastWakeAtMs + 1);
|
|
49016
|
+
return live2.lastWakeAtMs;
|
|
49017
|
+
}
|
|
49018
|
+
function stopMonitor(live2, why) {
|
|
49019
|
+
if (live2.stopping) return;
|
|
49020
|
+
live2.stopping = why;
|
|
49021
|
+
live2.proc?.stop();
|
|
49022
|
+
}
|
|
49023
|
+
function evalMonitor(service, w, nowMs) {
|
|
49024
|
+
const live2 = monitors.get(w.id);
|
|
49025
|
+
const row = deps.storage.getSession(w.thread_slug);
|
|
49026
|
+
if (!threadIsLive(row)) {
|
|
49027
|
+
if (live2) stopMonitor(live2, "archived");
|
|
49028
|
+
return;
|
|
49029
|
+
}
|
|
49030
|
+
if (live2?.stopping) return;
|
|
49031
|
+
if (!live2 || nowMs - live2.gateCheckedAt >= MONITOR_GATE_RECHECK_MS) {
|
|
49032
|
+
const refusal = service.refusal(row);
|
|
49033
|
+
if (refusal) {
|
|
49034
|
+
cancelMonitor(row, w, refusal, nowMs);
|
|
49035
|
+
return;
|
|
49036
|
+
}
|
|
49037
|
+
if (live2) live2.gateCheckedAt = nowMs;
|
|
49038
|
+
}
|
|
49039
|
+
if (!live2) launchMonitor(service, w, nowMs);
|
|
49040
|
+
}
|
|
49041
|
+
function launchMonitor(service, w, nowMs, registration) {
|
|
49042
|
+
if (!service.startMonitor) return "this server cannot run monitors";
|
|
49043
|
+
if (w.pid !== null && w.pid_started_at !== null && service.reapStaleMonitor?.(w.pid, w.pid_started_at)) {
|
|
49044
|
+
log3(`waker: killed monitor ${w.id}'s stale process group ${w.pid}, left running by an earlier server`);
|
|
49045
|
+
}
|
|
49046
|
+
const live2 = { id: w.id, slug: w.thread_slug, gateCheckedAt: nowMs, recent: [], ...registration ? { registration } : {}, ended: Promise.resolve(), lastWakeAtMs: 0 };
|
|
49047
|
+
const proc = service.startMonitor(w.thread_slug, w.command, (event) => onMonitorEvent(live2, event));
|
|
49048
|
+
if (!proc) {
|
|
49049
|
+
log3(`waker: monitor ${w.id} not started \u2014 the server already runs ${service.monitorsRunning?.() ?? "its limit of"} monitors`);
|
|
49050
|
+
return "the server already runs as many monitors as it allows at once";
|
|
49051
|
+
}
|
|
49052
|
+
live2.proc = proc;
|
|
49053
|
+
monitors.set(w.id, live2);
|
|
49054
|
+
deps.storage.noteMonitorStart(w.id, proc.pid ?? null, Date.now());
|
|
49055
|
+
live2.ended = proc.done.then((run3) => onMonitorExit(live2, run3)).catch((err) => log3(`waker: monitor ${w.id} exit failed to record: ${err instanceof Error ? err.message : String(err)}`)).finally(() => {
|
|
49056
|
+
if (monitors.get(w.id) === live2) monitors.delete(w.id);
|
|
49057
|
+
});
|
|
49058
|
+
log3(`waker: started monitor ${w.id} for ${w.thread_slug} (pid ${proc.pid ?? "?"})`);
|
|
49059
|
+
return live2;
|
|
49060
|
+
}
|
|
49061
|
+
function onMonitorEvent(live2, event) {
|
|
49062
|
+
if (stopped || live2.stopping) return;
|
|
49063
|
+
const atMs = nextWakeAt(live2);
|
|
49064
|
+
const text2 = event.lines.join("\n");
|
|
49065
|
+
const n = deps.storage.recordMonitorEvent(live2.id, { atMs, text: text2.slice(0, 500) });
|
|
49066
|
+
if (n === void 0) {
|
|
49067
|
+
stopMonitor(live2, "dropped");
|
|
49068
|
+
return;
|
|
49069
|
+
}
|
|
49070
|
+
if (live2.registration) {
|
|
49071
|
+
live2.registration.events.push(event.more > 0 ? `${text2}
|
|
49072
|
+
\u2026and ${event.more} more line${event.more === 1 ? "" : "s"}` : text2);
|
|
49073
|
+
return;
|
|
49074
|
+
}
|
|
49075
|
+
const w = deps.storage.getCommandWatch(live2.id);
|
|
49076
|
+
const row = deps.storage.getSession(live2.slug);
|
|
49077
|
+
if (!w || !threadIsLive(row)) return;
|
|
49078
|
+
enqueueCommandWatchWake(
|
|
49079
|
+
row,
|
|
49080
|
+
`${MONITOR_EVENT_FENCE_PREFIX}:${live2.id}:${n}`,
|
|
49081
|
+
monitorEventWakeMessage({ id: live2.id, label: monitorLabel(w), lines: event.lines, more: event.more, event: n }),
|
|
49082
|
+
`monitor ${live2.id} event ${n}`,
|
|
49083
|
+
atMs
|
|
49084
|
+
);
|
|
49085
|
+
live2.recent = live2.recent.filter((t) => atMs - t < MONITOR_FLOOD_WINDOW_MS);
|
|
49086
|
+
live2.recent.push(atMs);
|
|
49087
|
+
if (live2.recent.length >= MONITOR_FLOOD_MAX_EVENTS) cancelMonitor(row, deps.storage.getCommandWatch(live2.id) ?? w, MONITOR_FLOOD_REASON, atMs);
|
|
49088
|
+
kick();
|
|
49089
|
+
}
|
|
49090
|
+
function onMonitorExit(live2, run3) {
|
|
49091
|
+
const atMs = nextWakeAt(live2);
|
|
49092
|
+
deps.storage.recordMonitorExit(live2.id, { atMs, outcome: run3.outcome, exitCode: run3.exitCode, output: run3.output });
|
|
49093
|
+
if (live2.stopping || stopped) return;
|
|
49094
|
+
const w = deps.storage.getCommandWatch(live2.id);
|
|
49095
|
+
if (!w || w.state !== "armed") return;
|
|
49096
|
+
if (live2.registration) {
|
|
49097
|
+
live2.registration.exited = { at: new Date(run3.finishedAtMs).toISOString(), outcome: run3.outcome, exitCode: run3.exitCode, output: run3.output };
|
|
49098
|
+
deps.storage.settleCommandWatch(live2.id, "passed", atMs);
|
|
49099
|
+
return;
|
|
49100
|
+
}
|
|
49101
|
+
const row = deps.storage.getSession(live2.slug);
|
|
49102
|
+
if (threadIsLive(row)) {
|
|
49103
|
+
enqueueCommandWatchWake(
|
|
49104
|
+
row,
|
|
49105
|
+
`${MONITOR_EXITED_FENCE_PREFIX}:${live2.id}`,
|
|
49106
|
+
monitorExitedWakeMessage({ id: live2.id, label: monitorLabel(w), command: w.command, events: w.events, run: run3 }),
|
|
49107
|
+
`monitor ${live2.id} ended (${run3.outcome === "exit" ? `exit ${run3.exitCode}` : run3.outcome}) after ${w.events} event(s)`,
|
|
49108
|
+
atMs
|
|
49109
|
+
);
|
|
49110
|
+
}
|
|
49111
|
+
deps.storage.settleCommandWatch(live2.id, "passed", atMs);
|
|
49112
|
+
log3(`waker: settled ${live2.slug} \u2014 monitor ${live2.id} ended on its own`);
|
|
49113
|
+
kick();
|
|
49114
|
+
}
|
|
49115
|
+
function expireMonitor(w, at2) {
|
|
49116
|
+
const live2 = monitors.get(w.id);
|
|
49117
|
+
if (live2) stopMonitor(live2, "expired");
|
|
49118
|
+
const nowMs = live2 ? Math.max(at2, nextWakeAt(live2)) : at2;
|
|
49119
|
+
const row = deps.storage.getSession(w.thread_slug);
|
|
49120
|
+
if (threadIsLive(row)) {
|
|
49121
|
+
enqueueCommandWatchWake(
|
|
49122
|
+
row,
|
|
49123
|
+
`${MONITOR_EXPIRED_FENCE_PREFIX}:${w.id}`,
|
|
49124
|
+
monitorExpiredWakeMessage({ id: w.id, label: monitorLabel(w), command: w.command, events: w.events }),
|
|
49125
|
+
`monitor ${w.id} expired after ${w.events} event(s)`,
|
|
49126
|
+
nowMs
|
|
49127
|
+
);
|
|
49128
|
+
}
|
|
49129
|
+
deps.storage.settleCommandWatch(w.id, "expired", nowMs);
|
|
49130
|
+
log3(`waker: settled ${w.thread_slug} \u2014 monitor ${w.id} expired`);
|
|
49131
|
+
}
|
|
49132
|
+
function cancelMonitor(row, w, reason, at2) {
|
|
49133
|
+
const live2 = monitors.get(w.id);
|
|
49134
|
+
if (live2) stopMonitor(live2, "cancelled");
|
|
49135
|
+
const nowMs = live2 ? Math.max(at2, nextWakeAt(live2)) : at2;
|
|
49136
|
+
enqueueCommandWatchWake(
|
|
49137
|
+
row,
|
|
49138
|
+
`${MONITOR_CANCELLED_FENCE_PREFIX}:${w.id}`,
|
|
49139
|
+
monitorCancelledWakeMessage({ id: w.id, command: w.command, events: w.events, reason }),
|
|
49140
|
+
`monitor ${w.id} cancelled: ${reason}`,
|
|
49141
|
+
nowMs
|
|
49142
|
+
);
|
|
49143
|
+
deps.storage.settleCommandWatch(w.id, "cancelled", nowMs);
|
|
49144
|
+
log3(`waker: settled ${w.thread_slug} \u2014 monitor ${w.id} cancelled: ${reason}`);
|
|
49145
|
+
}
|
|
49146
|
+
async function startMonitor(id2, windowMs = MONITOR_REGISTRATION_WINDOW_MS) {
|
|
49147
|
+
const w = deps.storage.getCommandWatch(id2);
|
|
49148
|
+
if (!w || w.state !== "armed" || w.kind !== "monitor") return { running: false, events: [], refused: `no armed monitor ${id2}` };
|
|
49149
|
+
if (monitors.has(id2)) return { running: true, events: [] };
|
|
49150
|
+
const service = deps.commandWatches;
|
|
49151
|
+
if (!service) return { running: false, events: [], refused: "this server cannot run monitors" };
|
|
49152
|
+
const live2 = launchMonitor(service, w, now(), { events: [] });
|
|
49153
|
+
if (typeof live2 === "string") return { running: false, events: [], refused: live2 };
|
|
49154
|
+
let timer2;
|
|
49155
|
+
await Promise.race([live2.ended, new Promise((resolve14) => {
|
|
49156
|
+
timer2 = setTimeout(resolve14, windowMs);
|
|
49157
|
+
})]);
|
|
49158
|
+
if (timer2) clearTimeout(timer2);
|
|
49159
|
+
const seen = live2.registration ?? { events: [] };
|
|
49160
|
+
delete live2.registration;
|
|
49161
|
+
if (seen.exited) return { running: false, events: seen.events, exited: seen.exited };
|
|
49162
|
+
return { running: true, events: seen.events };
|
|
49163
|
+
}
|
|
49164
|
+
async function releaseMonitor(id2) {
|
|
49165
|
+
const live2 = monitors.get(id2);
|
|
49166
|
+
if (!live2) return;
|
|
49167
|
+
const w = deps.storage.getCommandWatch(id2);
|
|
49168
|
+
if (w && w.state === "armed") return;
|
|
49169
|
+
stopMonitor(live2, "dropped");
|
|
49170
|
+
await live2.ended;
|
|
49171
|
+
}
|
|
48325
49172
|
function evalQuestionAnswers(nowMs) {
|
|
48326
49173
|
const bySlug = /* @__PURE__ */ new Map();
|
|
48327
49174
|
for (const q2 of deps.storage.undeliveredSettlements()) {
|
|
@@ -48891,13 +49738,18 @@ ${wakeTimeHeader(now(), spokeAt)}`;
|
|
|
48891
49738
|
if (draining) await draining;
|
|
48892
49739
|
for (const run3 of commandRuns.values()) run3.abort.abort();
|
|
48893
49740
|
await commandRunsIdle();
|
|
49741
|
+
const ending = [...monitors.values()];
|
|
49742
|
+
for (const live2 of ending) stopMonitor(live2, "server");
|
|
49743
|
+
await Promise.all(ending.map((live2) => live2.ended));
|
|
48894
49744
|
},
|
|
48895
49745
|
tick,
|
|
48896
49746
|
kick,
|
|
48897
|
-
commandRunsIdle
|
|
49747
|
+
commandRunsIdle,
|
|
49748
|
+
startMonitor,
|
|
49749
|
+
releaseMonitor
|
|
48898
49750
|
};
|
|
48899
49751
|
}
|
|
48900
|
-
var execFileAsync5, PR_REF_RE2, OFF_MERGE_PATHS, MERGING_PERMISSIONS, LIMIT_FENCE_PREFIX, LIMIT_HINT_PREFIX, LIMIT_RESUME_GRACE_MS, LIMIT_RESUME_HEADROOM_PERCENT, LIMIT_HEADROOM_MIN_FAULT_AGE_MS, REPORT_FENCE_PREFIX, REPORT_HINT_PREFIX, SNOOZE_FENCE_PREFIX, SNOOZE_HINT_PREFIX, HEARTBEAT_FENCE_PREFIX, HEARTBEAT_HINT_PREFIX, STOP_HOOK_FENCE_PREFIX, STOP_HOOK_HINT_KEY, COMPACT_FENCE_PREFIX, COMPACT_HINT_KEY, TIMER_FENCE_PREFIX, TIMER_HINT_PREFIX, SHELL_FENCE_PREFIX, INTERRUPT_ENDED_FENCE_PREFIX, PR_WATCH_FENCE_PREFIX, PR_WATCH_EXPIRED_FENCE_PREFIX, OWN_WATCH_EXPIRED_FENCE_PREFIX, COMMAND_WATCH_FENCE_PREFIX, COMMAND_WATCH_EXPIRED_FENCE_PREFIX, COMMAND_WATCH_CANCELLED_FENCE_PREFIX, QUESTION_ANSWER_FENCE_PREFIX, ANSWER_REOFFER_BACKOFF_MS, CONTEXT_SUPERSEDED, PR_WATCH_POLL_MS, PR_WATCH_GONE_MS, PR_STATUS_FALLBACK_LIMIT, SIGNOFF_FENCE_PREFIX, SIGNOFF_HINT_KEY, SIGNOFF_NUDGE_MAX, PARK_BUMP_MAX, SIGNOFF_NUDGE_SETTING, PARK_FENCE_PREFIX, QUESTION_FENCE_CAUSE, DONE_OVER_QUESTION_CAUSE, DONE_GATE_FROM_MS, FAULTS_OUTLIVE_HUMAN_FROM_MS, GITHUB_STATUS_CAP, REVIEW_SEEN_CAP, REVIEW_STEER_CAP, AWAITING_KEY_OF, MID_TURN_HOLD_MAX_MS, WAKE_HOLD_DEFERRAL;
|
|
49752
|
+
var execFileAsync5, PR_REF_RE2, OFF_MERGE_PATHS, MERGING_PERMISSIONS, LIMIT_FENCE_PREFIX, LIMIT_HINT_PREFIX, LIMIT_RESUME_GRACE_MS, LIMIT_RESUME_HEADROOM_PERCENT, LIMIT_HEADROOM_MIN_FAULT_AGE_MS, REPORT_FENCE_PREFIX, REPORT_HINT_PREFIX, SNOOZE_FENCE_PREFIX, SNOOZE_HINT_PREFIX, HEARTBEAT_FENCE_PREFIX, HEARTBEAT_HINT_PREFIX, STOP_HOOK_FENCE_PREFIX, STOP_HOOK_HINT_KEY, COMPACT_FENCE_PREFIX, COMPACT_HINT_KEY, TIMER_FENCE_PREFIX, TIMER_HINT_PREFIX, SHELL_FENCE_PREFIX, INTERRUPT_ENDED_FENCE_PREFIX, PR_WATCH_FENCE_PREFIX, PR_WATCH_EXPIRED_FENCE_PREFIX, OWN_WATCH_EXPIRED_FENCE_PREFIX, COMMAND_WATCH_FENCE_PREFIX, COMMAND_WATCH_EXPIRED_FENCE_PREFIX, COMMAND_WATCH_CANCELLED_FENCE_PREFIX, MONITOR_EVENT_FENCE_PREFIX, MONITOR_EXITED_FENCE_PREFIX, MONITOR_EXPIRED_FENCE_PREFIX, MONITOR_CANCELLED_FENCE_PREFIX, QUESTION_ANSWER_FENCE_PREFIX, ANSWER_REOFFER_BACKOFF_MS, CONTEXT_SUPERSEDED, PR_WATCH_POLL_MS, PR_WATCH_GONE_MS, PR_STATUS_FALLBACK_LIMIT, SIGNOFF_FENCE_PREFIX, SIGNOFF_HINT_KEY, SIGNOFF_NUDGE_MAX, PARK_BUMP_MAX, SIGNOFF_NUDGE_SETTING, PARK_FENCE_PREFIX, QUESTION_FENCE_CAUSE, DONE_OVER_QUESTION_CAUSE, DONE_GATE_FROM_MS, FAULTS_OUTLIVE_HUMAN_FROM_MS, GITHUB_STATUS_CAP, REVIEW_SEEN_CAP, REVIEW_STEER_CAP, AWAITING_KEY_OF, MID_TURN_HOLD_MAX_MS, WAKE_HOLD_DEFERRAL;
|
|
48901
49753
|
var init_scheduler = __esm({
|
|
48902
49754
|
"packages/server/src/scheduler.ts"() {
|
|
48903
49755
|
"use strict";
|
|
@@ -48944,6 +49796,10 @@ var init_scheduler = __esm({
|
|
|
48944
49796
|
COMMAND_WATCH_FENCE_PREFIX = "cmdwatch";
|
|
48945
49797
|
COMMAND_WATCH_EXPIRED_FENCE_PREFIX = "cmdwatch-expired";
|
|
48946
49798
|
COMMAND_WATCH_CANCELLED_FENCE_PREFIX = "cmdwatch-cancelled";
|
|
49799
|
+
MONITOR_EVENT_FENCE_PREFIX = "cmdmon";
|
|
49800
|
+
MONITOR_EXITED_FENCE_PREFIX = "cmdmon-exited";
|
|
49801
|
+
MONITOR_EXPIRED_FENCE_PREFIX = "cmdmon-expired";
|
|
49802
|
+
MONITOR_CANCELLED_FENCE_PREFIX = "cmdmon-cancelled";
|
|
48947
49803
|
QUESTION_ANSWER_FENCE_PREFIX = "answers";
|
|
48948
49804
|
ANSWER_REOFFER_BACKOFF_MS = 30 * 6e4;
|
|
48949
49805
|
CONTEXT_SUPERSEDED = "the exact awaiting fence or session was superseded";
|
|
@@ -49052,7 +49908,7 @@ var init_resume = __esm({
|
|
|
49052
49908
|
});
|
|
49053
49909
|
|
|
49054
49910
|
// packages/server/src/backend/claude.ts
|
|
49055
|
-
import { join as
|
|
49911
|
+
import { join as join40 } from "node:path";
|
|
49056
49912
|
function toolResultText2(content) {
|
|
49057
49913
|
if (typeof content === "string") return content;
|
|
49058
49914
|
if (!Array.isArray(content)) return "";
|
|
@@ -49143,7 +49999,7 @@ function createClaudeBackend(opts) {
|
|
|
49143
49999
|
return { argv, env: claudeWorkerEnvironment(), prewrite: [] };
|
|
49144
50000
|
},
|
|
49145
50001
|
transcriptPath(sessionId) {
|
|
49146
|
-
return
|
|
50002
|
+
return join40(opts.logDir, `${sessionId}.jsonl`);
|
|
49147
50003
|
},
|
|
49148
50004
|
parseLine(line) {
|
|
49149
50005
|
return parseClaudeLine(line);
|
|
@@ -49168,10 +50024,10 @@ var init_claude = __esm({
|
|
|
49168
50024
|
});
|
|
49169
50025
|
|
|
49170
50026
|
// packages/server/src/backend/acp-transcript.ts
|
|
49171
|
-
import { appendFileSync as appendFileSync4, existsSync as
|
|
49172
|
-
import { dirname as dirname19, join as
|
|
50027
|
+
import { appendFileSync as appendFileSync4, existsSync as existsSync16, mkdirSync as mkdirSync20, readFileSync as readFileSync26 } from "node:fs";
|
|
50028
|
+
import { dirname as dirname19, join as join41 } from "node:path";
|
|
49173
50029
|
function acpTranscriptPath(stateDir, sessionId) {
|
|
49174
|
-
return
|
|
50030
|
+
return join41(stateDir, ACP_TRANSCRIPT_DIR, `${sessionId}.jsonl`);
|
|
49175
50031
|
}
|
|
49176
50032
|
function parseAcpRecord(line) {
|
|
49177
50033
|
if (!line.trim()) return void 0;
|
|
@@ -49195,7 +50051,7 @@ function parseAcpLine(line) {
|
|
|
49195
50051
|
function acpContractOwed(path3) {
|
|
49196
50052
|
let text2;
|
|
49197
50053
|
try {
|
|
49198
|
-
text2 =
|
|
50054
|
+
text2 = readFileSync26(path3, "utf8");
|
|
49199
50055
|
} catch {
|
|
49200
50056
|
return false;
|
|
49201
50057
|
}
|
|
@@ -49404,7 +50260,7 @@ var init_acp_transcript = __esm({
|
|
|
49404
50260
|
constructor(path3) {
|
|
49405
50261
|
this.path = path3;
|
|
49406
50262
|
mkdirSync20(dirname19(path3), { recursive: true });
|
|
49407
|
-
if (!
|
|
50263
|
+
if (!existsSync16(path3)) appendFileSync4(path3, "");
|
|
49408
50264
|
}
|
|
49409
50265
|
append(record) {
|
|
49410
50266
|
appendFileSync4(this.path, JSON.stringify(record) + "\n");
|
|
@@ -49566,14 +50422,14 @@ var init_acp_types = __esm({
|
|
|
49566
50422
|
});
|
|
49567
50423
|
|
|
49568
50424
|
// packages/server/src/backend/acp-rpc.ts
|
|
49569
|
-
import { spawn as
|
|
49570
|
-
import { StringDecoder as
|
|
50425
|
+
import { spawn as spawn7 } from "node:child_process";
|
|
50426
|
+
import { StringDecoder as StringDecoder5 } from "node:string_decoder";
|
|
49571
50427
|
var spawnAcpChild, AcpRequestError, AcpRemoteError, AcpConnectionClosed, AcpRequestTimeout, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_LINE_BYTES, AcpConnection;
|
|
49572
50428
|
var init_acp_rpc = __esm({
|
|
49573
50429
|
"packages/server/src/backend/acp-rpc.ts"() {
|
|
49574
50430
|
"use strict";
|
|
49575
50431
|
init_acp_types();
|
|
49576
|
-
spawnAcpChild = ({ command, args, cwd, env }) =>
|
|
50432
|
+
spawnAcpChild = ({ command, args, cwd, env }) => spawn7(command, args, { cwd, env, stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
|
|
49577
50433
|
AcpRequestError = class extends Error {
|
|
49578
50434
|
constructor(code, message, data) {
|
|
49579
50435
|
super(message);
|
|
@@ -49650,7 +50506,7 @@ var init_acp_rpc = __esm({
|
|
|
49650
50506
|
}
|
|
49651
50507
|
nextId = 1;
|
|
49652
50508
|
pending = /* @__PURE__ */ new Map();
|
|
49653
|
-
decoder = new
|
|
50509
|
+
decoder = new StringDecoder5("utf8");
|
|
49654
50510
|
buffer = "";
|
|
49655
50511
|
overflowing = false;
|
|
49656
50512
|
closedReason;
|
|
@@ -49791,18 +50647,18 @@ var init_acp_rpc = __esm({
|
|
|
49791
50647
|
});
|
|
49792
50648
|
|
|
49793
50649
|
// packages/server/src/backend/acp-host.ts
|
|
49794
|
-
import { spawn as
|
|
50650
|
+
import { spawn as spawn8 } from "node:child_process";
|
|
49795
50651
|
import { createConnection as createConnection2 } from "node:net";
|
|
49796
50652
|
import { createHash as createHash19, randomUUID as randomUUID16 } from "node:crypto";
|
|
49797
|
-
import { existsSync as
|
|
49798
|
-
import { join as
|
|
50653
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync21, readFileSync as readFileSync27, readdirSync as readdirSync10, unlinkSync as unlinkSync4 } from "node:fs";
|
|
50654
|
+
import { join as join42 } from "node:path";
|
|
49799
50655
|
import { PassThrough as PassThrough3, Writable as Writable3 } from "node:stream";
|
|
49800
|
-
import { StringDecoder as
|
|
50656
|
+
import { StringDecoder as StringDecoder6 } from "node:string_decoder";
|
|
49801
50657
|
function daemonDir2(stateDir) {
|
|
49802
|
-
return
|
|
50658
|
+
return join42(stateDir, "acp-daemon");
|
|
49803
50659
|
}
|
|
49804
50660
|
function acpDaemonRecordPath(stateDir, sessionId) {
|
|
49805
|
-
return
|
|
50661
|
+
return join42(daemonDir2(stateDir), `${sessionId}.json`);
|
|
49806
50662
|
}
|
|
49807
50663
|
function acpDaemonSocketPath(stateDir, sessionId) {
|
|
49808
50664
|
const key = createHash19("sha256").update(stateDir).update("\0").update(sessionId).digest("hex").slice(0, 16);
|
|
@@ -49818,7 +50674,7 @@ function pidAlive4(pid) {
|
|
|
49818
50674
|
}
|
|
49819
50675
|
function readAcpDaemonRecord(stateDir, sessionId) {
|
|
49820
50676
|
try {
|
|
49821
|
-
const value = JSON.parse(
|
|
50677
|
+
const value = JSON.parse(readFileSync27(acpDaemonRecordPath(stateDir, sessionId), "utf8"));
|
|
49822
50678
|
if (typeof value.daemonPid !== "number" || typeof value.socketPath !== "string" || typeof value.generation !== "string") return null;
|
|
49823
50679
|
return {
|
|
49824
50680
|
threadSlug: typeof value.threadSlug === "string" ? value.threadSlug : "",
|
|
@@ -49887,7 +50743,7 @@ function forkDaemon2(options) {
|
|
|
49887
50743
|
...options.reachabilityCheckMs === void 0 ? {} : { reachabilityCheckMs: options.reachabilityCheckMs },
|
|
49888
50744
|
...options.idleExitMs === void 0 ? {} : { idleExitMs: options.idleExitMs }
|
|
49889
50745
|
});
|
|
49890
|
-
const child =
|
|
50746
|
+
const child = spawn8(process.execPath, [options.daemonEntry ?? daemonEntry2()], {
|
|
49891
50747
|
cwd: options.cwd,
|
|
49892
50748
|
// The daemon's OWN environment only needs the handoff; the agent's environment travels in the
|
|
49893
50749
|
// payload and is applied by the daemon, keeping the audited env allowlist authoritative.
|
|
@@ -49974,7 +50830,7 @@ function attach3(record, timeoutMs) {
|
|
|
49974
50830
|
} catch {
|
|
49975
50831
|
}
|
|
49976
50832
|
};
|
|
49977
|
-
const decoder = new
|
|
50833
|
+
const decoder = new StringDecoder6("utf8");
|
|
49978
50834
|
let buffer = "";
|
|
49979
50835
|
socket.on("data", (chunk2) => {
|
|
49980
50836
|
buffer += decoder.write(chunk2);
|
|
@@ -50060,7 +50916,7 @@ var init_acp_host = __esm({
|
|
|
50060
50916
|
}
|
|
50061
50917
|
if (process.platform !== "win32") {
|
|
50062
50918
|
const stale = acpDaemonSocketPath(stateDir, sessionId);
|
|
50063
|
-
if (
|
|
50919
|
+
if (existsSync17(stale) && !liveAcpDaemonRecord(stateDir, sessionId)) {
|
|
50064
50920
|
try {
|
|
50065
50921
|
unlinkSync4(stale);
|
|
50066
50922
|
} catch {
|
|
@@ -80035,240 +80891,6 @@ var init_claude_agent_sdk = __esm({
|
|
|
80035
80891
|
}
|
|
80036
80892
|
});
|
|
80037
80893
|
|
|
80038
|
-
// packages/server/src/command-watch.ts
|
|
80039
|
-
import { execFileSync as execFileSync5, spawn as spawn8 } from "node:child_process";
|
|
80040
|
-
import { existsSync as existsSync18, readFileSync as readFileSync28 } from "node:fs";
|
|
80041
|
-
import { homedir as homedir17, userInfo } from "node:os";
|
|
80042
|
-
import { join as join43 } from "node:path";
|
|
80043
|
-
function killGroup(pid, signal) {
|
|
80044
|
-
if (!pid) return;
|
|
80045
|
-
try {
|
|
80046
|
-
process.kill(-pid, signal);
|
|
80047
|
-
} catch {
|
|
80048
|
-
}
|
|
80049
|
-
}
|
|
80050
|
-
function outputTail(chunks, max = COMMAND_WATCH_OUTPUT_MAX_BYTES) {
|
|
80051
|
-
const all = Buffer.concat(chunks);
|
|
80052
|
-
if (all.length <= max) return all.toString("utf8");
|
|
80053
|
-
let start = all.length - max;
|
|
80054
|
-
while (start < all.length && (all[start] & 192) === 128) start++;
|
|
80055
|
-
return `\u2026${all.subarray(start).toString("utf8")}`;
|
|
80056
|
-
}
|
|
80057
|
-
function runWatchCommand(spec) {
|
|
80058
|
-
const startedAtMs = Date.now();
|
|
80059
|
-
const timeoutMs = spec.timeoutMs ?? COMMAND_WATCH_RUN_TIMEOUT_MS;
|
|
80060
|
-
return new Promise((resolve14) => {
|
|
80061
|
-
const chunks = [];
|
|
80062
|
-
let held = 0;
|
|
80063
|
-
const keep = (chunk2) => {
|
|
80064
|
-
chunks.push(chunk2);
|
|
80065
|
-
held += chunk2.length;
|
|
80066
|
-
while (held - chunks[0].length >= COMMAND_WATCH_OUTPUT_MAX_BYTES && chunks.length > 1) held -= chunks.shift().length;
|
|
80067
|
-
};
|
|
80068
|
-
let settled = false;
|
|
80069
|
-
let timedOut2 = false;
|
|
80070
|
-
let aborted = false;
|
|
80071
|
-
let exit = null;
|
|
80072
|
-
const timers = [];
|
|
80073
|
-
const finish = (result, extra) => {
|
|
80074
|
-
if (settled) return;
|
|
80075
|
-
settled = true;
|
|
80076
|
-
for (const t of timers) clearTimeout(t);
|
|
80077
|
-
spec.signal?.removeEventListener("abort", onAbort);
|
|
80078
|
-
const output = outputTail(extra ? [...chunks, Buffer.from(extra)] : chunks);
|
|
80079
|
-
resolve14({ ...result, output, startedAtMs, finishedAtMs: Date.now() });
|
|
80080
|
-
};
|
|
80081
|
-
let child;
|
|
80082
|
-
try {
|
|
80083
|
-
child = spawn8("/bin/sh", ["-c", spec.command], {
|
|
80084
|
-
cwd: spec.cwd,
|
|
80085
|
-
env: spec.env,
|
|
80086
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
80087
|
-
detached: true,
|
|
80088
|
-
windowsHide: true
|
|
80089
|
-
});
|
|
80090
|
-
} catch (err) {
|
|
80091
|
-
finish({ outcome: "error", exitCode: null }, `could not start /bin/sh: ${err instanceof Error ? err.message : String(err)}`);
|
|
80092
|
-
return;
|
|
80093
|
-
}
|
|
80094
|
-
const onAbort = () => {
|
|
80095
|
-
aborted = true;
|
|
80096
|
-
killGroup(child.pid, "SIGKILL");
|
|
80097
|
-
};
|
|
80098
|
-
if (spec.signal?.aborted) onAbort();
|
|
80099
|
-
else spec.signal?.addEventListener("abort", onAbort, { once: true });
|
|
80100
|
-
child.stdout?.on("data", keep);
|
|
80101
|
-
child.stderr?.on("data", keep);
|
|
80102
|
-
child.on("error", (err) => {
|
|
80103
|
-
finish({ outcome: "error", exitCode: null }, `could not start /bin/sh: ${err.message}`);
|
|
80104
|
-
});
|
|
80105
|
-
timers.push(setTimeout(() => {
|
|
80106
|
-
timedOut2 = true;
|
|
80107
|
-
killGroup(child.pid, "SIGTERM");
|
|
80108
|
-
timers.push(setTimeout(() => killGroup(child.pid, "SIGKILL"), KILL_GRACE_MS));
|
|
80109
|
-
}, timeoutMs));
|
|
80110
|
-
const conclude = () => {
|
|
80111
|
-
if (!exit) return;
|
|
80112
|
-
if (timedOut2) finish({ outcome: "timeout", exitCode: null });
|
|
80113
|
-
else if (aborted || exit.signal) finish({ outcome: "signal", exitCode: null });
|
|
80114
|
-
else finish({ outcome: "exit", exitCode: exit.code });
|
|
80115
|
-
};
|
|
80116
|
-
child.on("exit", (code, signal) => {
|
|
80117
|
-
exit = { code, signal };
|
|
80118
|
-
killGroup(child.pid, "SIGKILL");
|
|
80119
|
-
timers.push(setTimeout(() => {
|
|
80120
|
-
child.stdout?.destroy();
|
|
80121
|
-
child.stderr?.destroy();
|
|
80122
|
-
conclude();
|
|
80123
|
-
}, DRAIN_AFTER_EXIT_MS));
|
|
80124
|
-
});
|
|
80125
|
-
child.on("close", conclude);
|
|
80126
|
-
});
|
|
80127
|
-
}
|
|
80128
|
-
function createRunLimiter(limit) {
|
|
80129
|
-
let active = 0;
|
|
80130
|
-
const waiting = [];
|
|
80131
|
-
return async (fn) => {
|
|
80132
|
-
if (active < limit) active++;
|
|
80133
|
-
else await new Promise((resolve14) => waiting.push(resolve14));
|
|
80134
|
-
try {
|
|
80135
|
-
return await fn();
|
|
80136
|
-
} finally {
|
|
80137
|
-
const next = waiting.shift();
|
|
80138
|
-
if (next) next();
|
|
80139
|
-
else active--;
|
|
80140
|
-
}
|
|
80141
|
-
};
|
|
80142
|
-
}
|
|
80143
|
-
function claudeManagedPreferencePaths() {
|
|
80144
|
-
let user = "";
|
|
80145
|
-
try {
|
|
80146
|
-
user = userInfo().username;
|
|
80147
|
-
} catch {
|
|
80148
|
-
}
|
|
80149
|
-
return [
|
|
80150
|
-
...user ? [`/Library/Managed Preferences/${user}/com.anthropic.claudecode.plist`] : [],
|
|
80151
|
-
"/Library/Managed Preferences/com.anthropic.claudecode.plist"
|
|
80152
|
-
];
|
|
80153
|
-
}
|
|
80154
|
-
function plistAsJson(path3) {
|
|
80155
|
-
return execFileSync5("/usr/bin/plutil", ["-convert", "json", "-o", "-", "--", path3], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] });
|
|
80156
|
-
}
|
|
80157
|
-
function sandboxInSettings(raw2, file) {
|
|
80158
|
-
let parsed;
|
|
80159
|
-
try {
|
|
80160
|
-
parsed = JSON.parse(raw2);
|
|
80161
|
-
} catch {
|
|
80162
|
-
return `\`${file}\` is not valid JSON, so Frizz cannot tell whether it turns Claude Code's sandbox on for this thread`;
|
|
80163
|
-
}
|
|
80164
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return void 0;
|
|
80165
|
-
const sandbox = parsed.sandbox;
|
|
80166
|
-
if (sandbox === void 0 || sandbox === null || sandbox === false) return void 0;
|
|
80167
|
-
if (typeof sandbox === "object" && !Array.isArray(sandbox)) {
|
|
80168
|
-
const enabled = sandbox.enabled;
|
|
80169
|
-
if (enabled === void 0 || enabled === false) return void 0;
|
|
80170
|
-
}
|
|
80171
|
-
return `Claude Code's sandbox is on for this thread (\`sandbox\` in \`${file}\`), and a command watch would run your command outside it`;
|
|
80172
|
-
}
|
|
80173
|
-
function claudeSettingsFiles(where) {
|
|
80174
|
-
const env = where.env ?? process.env;
|
|
80175
|
-
const configDir = env.CLAUDE_CONFIG_DIR?.trim() ? env.CLAUDE_CONFIG_DIR.trim() : join43(where.home ?? homedir17(), ".claude");
|
|
80176
|
-
return [
|
|
80177
|
-
...where.managedPaths ?? CLAUDE_MANAGED_SETTINGS_PATHS,
|
|
80178
|
-
join43(where.cwd, ".claude", "settings.local.json"),
|
|
80179
|
-
join43(where.cwd, ".claude", "settings.json"),
|
|
80180
|
-
join43(configDir, "settings.json")
|
|
80181
|
-
];
|
|
80182
|
-
}
|
|
80183
|
-
function claudeSandboxRefusal(where) {
|
|
80184
|
-
for (const file of claudeSettingsFiles(where)) {
|
|
80185
|
-
let raw2;
|
|
80186
|
-
try {
|
|
80187
|
-
raw2 = readFileSync28(file, "utf8");
|
|
80188
|
-
} catch (err) {
|
|
80189
|
-
if (err?.code === "ENOENT" || err?.code === "ENOTDIR") continue;
|
|
80190
|
-
return `Frizz could not read \`${file}\` to check whether Claude Code's sandbox is on for this thread`;
|
|
80191
|
-
}
|
|
80192
|
-
const refusal = sandboxInSettings(raw2, file);
|
|
80193
|
-
if (refusal) return refusal;
|
|
80194
|
-
}
|
|
80195
|
-
const preferences = where.managedPreferencePaths ?? (process.platform === "darwin" ? claudeManagedPreferencePaths() : []);
|
|
80196
|
-
for (const file of preferences) {
|
|
80197
|
-
if (!existsSync18(file)) continue;
|
|
80198
|
-
let raw2;
|
|
80199
|
-
try {
|
|
80200
|
-
raw2 = (where.readPlistJson ?? plistAsJson)(file);
|
|
80201
|
-
} catch {
|
|
80202
|
-
return `Frizz could not read \`${file}\` to check whether Claude Code's sandbox is on for this thread`;
|
|
80203
|
-
}
|
|
80204
|
-
const refusal = sandboxInSettings(raw2, file);
|
|
80205
|
-
if (refusal) return refusal;
|
|
80206
|
-
}
|
|
80207
|
-
return void 0;
|
|
80208
|
-
}
|
|
80209
|
-
function commandWatchRefusal(row, opts) {
|
|
80210
|
-
const refuse = (reason) => `${reason}. ${COMMAND_WATCH_FALLBACK}`;
|
|
80211
|
-
if ((opts.platform ?? process.platform) === "win32") {
|
|
80212
|
-
return refuse("command watches run under `/bin/sh`, which this machine does not have");
|
|
80213
|
-
}
|
|
80214
|
-
const backend = row.backend ?? "claude";
|
|
80215
|
-
if (backend !== "claude") {
|
|
80216
|
-
return refuse(
|
|
80217
|
-
`command watches are for Claude threads only, and this one runs on ${backend === "codex" ? "Codex" : "an ACP agent"}: Frizz cannot tell whether your thread's own sandbox would have let the command run`
|
|
80218
|
-
);
|
|
80219
|
-
}
|
|
80220
|
-
if (row.permission_mode !== "bypassPermissions") {
|
|
80221
|
-
return refuse(
|
|
80222
|
-
`this thread runs in \`${row.permission_mode ?? "an unrecorded"}\` permission mode, and the server runs a watched command with no permission check at all \u2014 so Frizz runs one only for a thread in \`bypassPermissions\` mode`
|
|
80223
|
-
);
|
|
80224
|
-
}
|
|
80225
|
-
if (row.permission_pending && row.permission_pending !== "bypassPermissions") {
|
|
80226
|
-
return refuse(`this thread's permission mode is being changed to \`${row.permission_pending}\``);
|
|
80227
|
-
}
|
|
80228
|
-
const sandbox = claudeSandboxRefusal({ cwd: opts.cwd, env: opts.env, home: opts.home, managedPaths: opts.managedPaths, managedPreferencePaths: opts.managedPreferencePaths, readPlistJson: opts.readPlistJson });
|
|
80229
|
-
if (sandbox) return refuse(sandbox);
|
|
80230
|
-
return void 0;
|
|
80231
|
-
}
|
|
80232
|
-
function createCommandWatchService(opts) {
|
|
80233
|
-
const runner = opts.runner ?? runWatchCommand;
|
|
80234
|
-
const limiter = opts.limiter ?? serverRunLimiter;
|
|
80235
|
-
let probesActive = 0;
|
|
80236
|
-
return {
|
|
80237
|
-
refusal: (row) => commandWatchRefusal(row, { cwd: opts.cwd, ...opts.gate }),
|
|
80238
|
-
run: (slug, command, runOpts) => limiter(() => runner({ command, cwd: opts.cwd, env: opts.env(slug), timeoutMs: COMMAND_WATCH_RUN_TIMEOUT_MS, signal: runOpts?.signal })),
|
|
80239
|
-
async probe(slug, command) {
|
|
80240
|
-
if (probesActive >= PROBE_CONCURRENCY) return void 0;
|
|
80241
|
-
probesActive++;
|
|
80242
|
-
try {
|
|
80243
|
-
return await runner({ command, cwd: opts.cwd, env: opts.env(slug), timeoutMs: COMMAND_WATCH_PROBE_TIMEOUT_MS });
|
|
80244
|
-
} finally {
|
|
80245
|
-
probesActive--;
|
|
80246
|
-
}
|
|
80247
|
-
}
|
|
80248
|
-
};
|
|
80249
|
-
}
|
|
80250
|
-
function commandWatchEnvironment(base, frizz) {
|
|
80251
|
-
const { FRIZZ_THREAD: _tag, ...rest } = base;
|
|
80252
|
-
return { ...rest, ...frizz, GIT_TERMINAL_PROMPT: "0", GH_PROMPT_DISABLED: "1" };
|
|
80253
|
-
}
|
|
80254
|
-
var KILL_GRACE_MS, DRAIN_AFTER_EXIT_MS, COMMAND_WATCH_SERVER_CONCURRENCY, serverRunLimiter, COMMAND_WATCH_PROBE_TIMEOUT_MS, PROBE_CONCURRENCY, CLAUDE_MANAGED_SETTINGS_PATHS;
|
|
80255
|
-
var init_command_watch = __esm({
|
|
80256
|
-
"packages/server/src/command-watch.ts"() {
|
|
80257
|
-
"use strict";
|
|
80258
|
-
init_src();
|
|
80259
|
-
KILL_GRACE_MS = 2e3;
|
|
80260
|
-
DRAIN_AFTER_EXIT_MS = 1e3;
|
|
80261
|
-
COMMAND_WATCH_SERVER_CONCURRENCY = 4;
|
|
80262
|
-
serverRunLimiter = createRunLimiter(COMMAND_WATCH_SERVER_CONCURRENCY);
|
|
80263
|
-
COMMAND_WATCH_PROBE_TIMEOUT_MS = 15e3;
|
|
80264
|
-
PROBE_CONCURRENCY = 2;
|
|
80265
|
-
CLAUDE_MANAGED_SETTINGS_PATHS = [
|
|
80266
|
-
"/Library/Application Support/ClaudeCode/managed-settings.json",
|
|
80267
|
-
"/etc/claude-code/managed-settings.json"
|
|
80268
|
-
];
|
|
80269
|
-
}
|
|
80270
|
-
});
|
|
80271
|
-
|
|
80272
80894
|
// packages/server/src/backend/claude-models.ts
|
|
80273
80895
|
function resolveClaudeModels(rows) {
|
|
80274
80896
|
const byAlias = /* @__PURE__ */ new Map();
|
|
@@ -85025,7 +85647,7 @@ var init_bash_background = __esm({
|
|
|
85025
85647
|
// packages/server/src/transcript.ts
|
|
85026
85648
|
import { closeSync as closeSync16, existsSync as existsSync20, fstatSync as fstatSync4, mkdirSync as mkdirSync25, openSync as openSync17, readdirSync as readdirSync13, readFileSync as readFileSync33, readSync as readSync9, renameSync as renameSync13, statSync as statSync21, unlinkSync as unlinkSync7, writeFileSync as writeFileSync17 } from "node:fs";
|
|
85027
85649
|
import { createHash as createHash21 } from "node:crypto";
|
|
85028
|
-
import { StringDecoder as
|
|
85650
|
+
import { StringDecoder as StringDecoder7 } from "node:string_decoder";
|
|
85029
85651
|
import { join as join48 } from "node:path";
|
|
85030
85652
|
import { homedir as homedir19 } from "node:os";
|
|
85031
85653
|
function compactionMessage(sourceId, at2) {
|
|
@@ -86152,7 +86774,7 @@ function retainedFoldEntry(path3, identityPrefix, fileId, size) {
|
|
|
86152
86774
|
}
|
|
86153
86775
|
const hit = entry !== void 0;
|
|
86154
86776
|
if (!entry) {
|
|
86155
|
-
entry = { identityPrefix, fold: createTranscriptFold(identityPrefix), bytesRead: 0, decoder: new
|
|
86777
|
+
entry = { identityPrefix, fold: createTranscriptFold(identityPrefix), bytesRead: 0, decoder: new StringDecoder7("utf8"), fileId };
|
|
86156
86778
|
} else {
|
|
86157
86779
|
transcriptCache.delete(path3);
|
|
86158
86780
|
}
|
|
@@ -87819,6 +88441,72 @@ var init_open_external = __esm({
|
|
|
87819
88441
|
}
|
|
87820
88442
|
});
|
|
87821
88443
|
|
|
88444
|
+
// packages/server/src/thread-listing.ts
|
|
88445
|
+
function threadListing(t, nowMs) {
|
|
88446
|
+
const band = threadBandAt(t, nowMs);
|
|
88447
|
+
if (!band) return null;
|
|
88448
|
+
const inFlight2 = t.runtime === "running" || t.runtime === "spawning";
|
|
88449
|
+
const asked = (t.questions ?? []).filter((q2) => q2.standing !== false).length;
|
|
88450
|
+
const unregistered = (t.pendingAsk ? 1 : 0) + (t.pendingQuestion && !hasStandingQuestion(t) ? 1 : 0) + (t.runtime === "perm-prompt" ? 1 : 0);
|
|
88451
|
+
const lastLine = t.lastAssistantLine?.trim();
|
|
88452
|
+
const snoozedUntil = futureSnoozedUntil(t, nowMs);
|
|
88453
|
+
return {
|
|
88454
|
+
slug: t.id,
|
|
88455
|
+
title: displayTitle(t),
|
|
88456
|
+
band,
|
|
88457
|
+
runtime: t.runtime,
|
|
88458
|
+
...t.backend ? { backend: t.backend } : {},
|
|
88459
|
+
...t.model ? { model: t.model } : {},
|
|
88460
|
+
...t.pinnedAt ? { pinned: true } : {},
|
|
88461
|
+
...inFlight2 && t.liveTool ? { doing: t.liveTool.desc?.trim() || t.liveTool.name } : {},
|
|
88462
|
+
...lastLine ? { lastLine: lastLine.length > LAST_LINE_MAX ? `${lastLine.slice(0, LAST_LINE_MAX - 1)}\u2026` : lastLine } : {},
|
|
88463
|
+
...t.lastFence ? { fence: t.lastFence.kind } : {},
|
|
88464
|
+
questions: asked + unregistered,
|
|
88465
|
+
subAgents: (t.subAgents ?? []).filter((a) => isDirectSubAgent(a) && a.state === "running").length,
|
|
88466
|
+
shells: (t.bgShells ?? []).filter((s) => s.state === "running").length,
|
|
88467
|
+
watches: (t.watches ?? []).filter((w) => w.state === "armed" && w.kind !== "shell").map(watchLabel),
|
|
88468
|
+
...t.limitPause ? { limited: true } : {},
|
|
88469
|
+
...t.crashed ? { crashed: true } : {},
|
|
88470
|
+
...t.spawnedAt ? { spawnedAt: t.spawnedAt } : {},
|
|
88471
|
+
...t.lastAssistantAt ? { restedAt: t.lastAssistantAt } : {},
|
|
88472
|
+
...t.lastActivityAt ? { lastActivityAt: t.lastActivityAt } : {},
|
|
88473
|
+
...snoozedUntil ? { snoozedUntil } : {},
|
|
88474
|
+
...t.archivedAt ? { archivedAt: t.archivedAt } : {}
|
|
88475
|
+
};
|
|
88476
|
+
}
|
|
88477
|
+
function watchLabel(w) {
|
|
88478
|
+
if (w.kind === "timer" && w.timer) return `timer at ${w.timer.fireAt}`;
|
|
88479
|
+
return w.target;
|
|
88480
|
+
}
|
|
88481
|
+
function recency(row) {
|
|
88482
|
+
const at2 = row.band === "done" ? row.archivedAt ?? row.lastActivityAt : row.lastActivityAt ?? row.restedAt ?? row.spawnedAt;
|
|
88483
|
+
const ms = Date.parse(at2 ?? "");
|
|
88484
|
+
return Number.isFinite(ms) ? ms : 0;
|
|
88485
|
+
}
|
|
88486
|
+
function listBoardThreads(threads, project, opts = {}) {
|
|
88487
|
+
const nowMs = opts.nowMs ?? Date.now();
|
|
88488
|
+
const counts = { rested: 0, active: 0, snoozed: 0, done: 0 };
|
|
88489
|
+
const rows = [];
|
|
88490
|
+
for (const t of threads) {
|
|
88491
|
+
const row = threadListing(t, nowMs);
|
|
88492
|
+
if (!row) continue;
|
|
88493
|
+
counts[row.band] += 1;
|
|
88494
|
+
if (row.band === "done" && !opts.all) continue;
|
|
88495
|
+
rows.push(row);
|
|
88496
|
+
}
|
|
88497
|
+
rows.sort((a, b) => BAND_ORDER.indexOf(a.band) - BAND_ORDER.indexOf(b.band) || recency(b) - recency(a) || a.slug.localeCompare(b.slug));
|
|
88498
|
+
return { project, threads: rows, counts };
|
|
88499
|
+
}
|
|
88500
|
+
var BAND_ORDER, LAST_LINE_MAX;
|
|
88501
|
+
var init_thread_listing = __esm({
|
|
88502
|
+
"packages/server/src/thread-listing.ts"() {
|
|
88503
|
+
"use strict";
|
|
88504
|
+
init_src();
|
|
88505
|
+
BAND_ORDER = ["rested", "active", "snoozed", "done"];
|
|
88506
|
+
LAST_LINE_MAX = 200;
|
|
88507
|
+
}
|
|
88508
|
+
});
|
|
88509
|
+
|
|
87822
88510
|
// packages/server/src/github-hovercard.ts
|
|
87823
88511
|
function parseRef(ref) {
|
|
87824
88512
|
const match2 = REF_PATTERN.exec(ref);
|
|
@@ -90066,7 +90754,8 @@ ${gapNote}` : input.message;
|
|
|
90066
90754
|
createdAt: new Date(w.created_at).toISOString(),
|
|
90067
90755
|
expiresAt: new Date(w.expires_at).toISOString(),
|
|
90068
90756
|
runs: w.runs,
|
|
90069
|
-
...w.last_run_at !== null && w.last_outcome ? { lastRun: { at: new Date(w.last_run_at).toISOString(), outcome: w.last_outcome, exitCode: w.last_exit, output: w.last_output ?? "" } } : {}
|
|
90757
|
+
...w.last_run_at !== null && w.last_outcome ? { lastRun: { at: new Date(w.last_run_at).toISOString(), outcome: w.last_outcome, exitCode: w.last_exit, output: w.last_output ?? "" } } : {},
|
|
90758
|
+
...w.kind === "monitor" ? { monitor: monitorStatusOf(w) } : {}
|
|
90070
90759
|
};
|
|
90071
90760
|
}
|
|
90072
90761
|
function armedCommandWatchViews(slug) {
|
|
@@ -91528,6 +92217,23 @@ ${gapNote}` : input.message;
|
|
|
91528
92217
|
return { activity, questions: openQuestionViews(input.slug), links: ctx.storage.listThreadLinks(input.slug).map(threadLinkView) };
|
|
91529
92218
|
}
|
|
91530
92219
|
}),
|
|
92220
|
+
// `frizzctl threads`: every thread on a board — this project's, or another one this Frizz serves — by
|
|
92221
|
+
// slug, shown title and band (thread-listing.ts), so a worker can see who else is working where
|
|
92222
|
+
// without the multi-megabyte board snapshot. A READ, so it verifies no caller: anything that can reach
|
|
92223
|
+
// this surface can already read the whole board through `board`. A mutation only because a worker's
|
|
92224
|
+
// command line POSTs every call (frizz-tools.mjs callRpc), as listOwnThreadActivity is. A project
|
|
92225
|
+
// that is registered but not open here is refused with openProjectNamed's reason rather than opened:
|
|
92226
|
+
// a read has no business starting another project's tailer and scheduler.
|
|
92227
|
+
listThreads: mutation({
|
|
92228
|
+
input: ListThreadsInput,
|
|
92229
|
+
output: ListThreadsResult,
|
|
92230
|
+
handler: async ({ input }) => {
|
|
92231
|
+
const open = input.project ? openProjectNamed(input.project, "its threads cannot be listed from here") : void 0;
|
|
92232
|
+
const project = open?.project ?? ctx.project;
|
|
92233
|
+
const { threads } = await (open?.board ?? ctx.board).snapshot();
|
|
92234
|
+
return listBoardThreads(threads, { slug: projectSlugOf(project.id), id: project.id, name: project.name }, { all: input.all });
|
|
92235
|
+
}
|
|
92236
|
+
}),
|
|
91531
92237
|
// THE WATCHER REGISTRY WAS DELETED ON 2026-08-14 AND CAME BACK ON 2026-08-26, under two narrow verbs
|
|
91532
92238
|
// rather than the four it had. It was removed because a wait had become a `watch:` line in the
|
|
91533
92239
|
// worker's own ```awaiting fence, which was BOTH the park and the wake — leaving nothing to register.
|
|
@@ -91718,9 +92424,90 @@ ${gapNote}` : input.message;
|
|
|
91718
92424
|
handler: async ({ input }) => {
|
|
91719
92425
|
const dropped = ctx.storage.dropCommandWatch(input.slug, input.id, Date.now());
|
|
91720
92426
|
if (dropped) ctx.board.refresh();
|
|
92427
|
+
if (dropped) await ctx.scheduler?.releaseMonitor?.(input.id);
|
|
91721
92428
|
return { dropped, watches: armedCommandWatchViews(input.slug) };
|
|
91722
92429
|
}
|
|
91723
92430
|
}),
|
|
92431
|
+
// ---- THE WORKER'S MONITORS (`frizzctl monitor add`, 2026-11-02) --------------------------------
|
|
92432
|
+
// A script the server keeps RUNNING, each stdout line a wake (scheduler SOURCE 13, command-watch.ts).
|
|
92433
|
+
// A command watch row of kind `monitor`, so `drop` and `list` are the command watch's own RPCs above.
|
|
92434
|
+
// Same gate first, for the same reason; then the caps; then the row is armed and the script started,
|
|
92435
|
+
// and registration watches it for a moment so a script that cannot run is reported here.
|
|
92436
|
+
addOwnMonitor: mutation({
|
|
92437
|
+
input: AddOwnMonitorInput,
|
|
92438
|
+
output: AddOwnMonitorResult,
|
|
92439
|
+
handler: async ({ input }) => {
|
|
92440
|
+
const row = ctx.storage.getSession(input.slug);
|
|
92441
|
+
if (!row) throw new Error(`thread ${input.slug} is not registered`);
|
|
92442
|
+
if (row.state === "archived" || row.archived === 1) {
|
|
92443
|
+
throw new Error("Reopen this thread before registering a monitor on it");
|
|
92444
|
+
}
|
|
92445
|
+
const refuse = (refused) => ({ refused, alreadyArmed: false, running: false, events: [], watches: armedCommandWatchViews(input.slug) });
|
|
92446
|
+
const service = ctx.commandWatches;
|
|
92447
|
+
const gate = service ? service.refusal(row) : `this server cannot run monitors. ${MONITOR_FALLBACK}`;
|
|
92448
|
+
if (gate) return refuse(`Frizz will not run a monitor for this thread: ${gate.replace(COMMAND_WATCH_FALLBACK, MONITOR_FALLBACK)}`);
|
|
92449
|
+
if (!service?.startMonitor || !ctx.scheduler?.startMonitor) return refuse(`Frizz will not run a monitor for this thread: this server cannot run monitors. ${MONITOR_FALLBACK}`);
|
|
92450
|
+
const command = input.command.trim();
|
|
92451
|
+
const description = input.description?.trim().replace(/\s+/g, " ") || void 0;
|
|
92452
|
+
const armed = ctx.storage.listCommandWatches(input.slug, { armedOnly: true });
|
|
92453
|
+
const existing = armed.find((w) => w.kind === "monitor" && w.command === command);
|
|
92454
|
+
if (existing) {
|
|
92455
|
+
return {
|
|
92456
|
+
id: existing.id,
|
|
92457
|
+
alreadyArmed: true,
|
|
92458
|
+
running: true,
|
|
92459
|
+
events: [],
|
|
92460
|
+
expiresAt: new Date(existing.expires_at).toISOString(),
|
|
92461
|
+
watches: armedCommandWatchViews(input.slug)
|
|
92462
|
+
};
|
|
92463
|
+
}
|
|
92464
|
+
if (armed.length >= COMMAND_WATCH_MAX_ARMED) {
|
|
92465
|
+
throw new Error(`this thread already has ${armed.length} command watches and monitors armed (the limit is ${COMMAND_WATCH_MAX_ARMED}) \u2014 drop one first`);
|
|
92466
|
+
}
|
|
92467
|
+
if ((service.monitorsRunning?.() ?? 0) >= MONITOR_SERVER_MAX_RUNNING) {
|
|
92468
|
+
return refuse(`Frizz already runs ${MONITOR_SERVER_MAX_RUNNING} monitors across every project, its limit. ${MONITOR_FALLBACK}`);
|
|
92469
|
+
}
|
|
92470
|
+
const forAsked = parseAwaitingDurationRaw(input.for);
|
|
92471
|
+
if (forAsked === null) throw new Error(`\`--for ${input.for}\` is not a duration \u2014 give one like \`2h\` or \`3d\` (max 7d)`);
|
|
92472
|
+
const forMs = Math.min(forAsked, COMMAND_WATCH_FOR_MAX_MS);
|
|
92473
|
+
const now = Date.now();
|
|
92474
|
+
const id2 = `cmw_${randomUUID20().replace(/-/g, "").slice(0, 12)}`;
|
|
92475
|
+
ctx.storage.clearThreadDone(input.slug);
|
|
92476
|
+
ctx.storage.armMonitor({ id: id2, slug: input.slug, command, description, createdAtMs: now, expiresAtMs: now + forMs });
|
|
92477
|
+
const started = await ctx.scheduler.startMonitor(id2);
|
|
92478
|
+
ctx.board.refresh();
|
|
92479
|
+
const clamped = forMs !== forAsked ? { clamped: { for: input.for } } : {};
|
|
92480
|
+
if (started.refused) {
|
|
92481
|
+
ctx.storage.settleCommandWatch(id2, "cancelled", Date.now());
|
|
92482
|
+
ctx.board.refresh();
|
|
92483
|
+
return refuse(`Frizz could not start your monitor: ${started.refused}. ${MONITOR_FALLBACK}`);
|
|
92484
|
+
}
|
|
92485
|
+
if (started.exited) {
|
|
92486
|
+
const notHere = started.exited.outcome === "error" || started.exited.outcome === "exit" && (started.exited.exitCode === 126 || started.exited.exitCode === 127);
|
|
92487
|
+
return {
|
|
92488
|
+
id: id2,
|
|
92489
|
+
alreadyArmed: false,
|
|
92490
|
+
running: false,
|
|
92491
|
+
events: started.events,
|
|
92492
|
+
exited: started.exited,
|
|
92493
|
+
...notHere ? {
|
|
92494
|
+
refused: `Your script could not run here (${started.exited.outcome === "error" ? "the shell did not start" : `\`/bin/sh\` exited ${started.exited.exitCode}`}). The server runs it with \`/bin/sh -c\` in ${ctx.project.dir}, with the server's own PATH, not your shell's: use absolute paths, or ${MONITOR_FALLBACK.charAt(0).toLowerCase()}${MONITOR_FALLBACK.slice(1)}`
|
|
92495
|
+
} : {},
|
|
92496
|
+
...clamped,
|
|
92497
|
+
watches: armedCommandWatchViews(input.slug)
|
|
92498
|
+
};
|
|
92499
|
+
}
|
|
92500
|
+
return {
|
|
92501
|
+
id: id2,
|
|
92502
|
+
alreadyArmed: false,
|
|
92503
|
+
running: true,
|
|
92504
|
+
events: started.events,
|
|
92505
|
+
expiresAt: new Date(now + forMs).toISOString(),
|
|
92506
|
+
...clamped,
|
|
92507
|
+
watches: armedCommandWatchViews(input.slug)
|
|
92508
|
+
};
|
|
92509
|
+
}
|
|
92510
|
+
}),
|
|
91724
92511
|
listOwnCommandWatches: mutation({
|
|
91725
92512
|
input: ListOwnCommandWatchesInput,
|
|
91726
92513
|
output: OwnCommandWatchesResult,
|
|
@@ -92685,6 +93472,7 @@ var init_router5 = __esm({
|
|
|
92685
93472
|
init_src();
|
|
92686
93473
|
init_context();
|
|
92687
93474
|
init_secret_files();
|
|
93475
|
+
init_command_watch();
|
|
92688
93476
|
init_acp_agents();
|
|
92689
93477
|
init_storage();
|
|
92690
93478
|
init_usage_limit();
|
|
@@ -92700,6 +93488,7 @@ var init_router5 = __esm({
|
|
|
92700
93488
|
init_local_file();
|
|
92701
93489
|
init_project();
|
|
92702
93490
|
init_thread_links();
|
|
93491
|
+
init_thread_listing();
|
|
92703
93492
|
init_github();
|
|
92704
93493
|
init_github_hovercard();
|
|
92705
93494
|
init_dispatch();
|