@tea-agent/loop-agent 0.52.0-next.2 → 0.52.0-next.3
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/CHANGELOG.md +1 -1
- package/dist/build-stamp.json +3 -3
- package/dist/commands/init-accepted-merge.js +46 -0
- package/dist/commands/init-upgrade.js +114 -2
- package/dist/commands/init.js +79 -12
- package/dist/worker/console/chat/pi-runtime.js +36 -5
- package/dist/worker/console/chat/terminal-sessions.js +9 -0
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BJkTFDSU.js → abnfDiagram-N423BO3Z-CM5ocMUs.js} +1 -1
- package/dist/worker/console/static/assets/{arc-BJoqB-FK.js → arc-CDapwdTN.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-Dnks_tKL.js → architectureDiagram-T3A2C74G-Ogy4GOqS.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CYfXZ-MS.js → blockDiagram-VBNYF7ZC-DsiaOIgU.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-C8QUVTzH.js → c4Diagram-5PPSVZJV-B84hhgSe.js} +1 -1
- package/dist/worker/console/static/assets/channel-BCVzSVXD.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-BeQTq_mP.js → chunk-2GRJ4B5K-SPqOhMla.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-Cz8TULTz.js → chunk-2Q5K7J3B-BL0Q4ZV3.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-DTGsDFfs.js → chunk-5RXB4S5H-CJpOcFAh.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-D3xtdDtx.js → chunk-5VM5RSS4-DQC6vqVW.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-CFcH1dmG.js → chunk-6Q2QTUOP-D4dq_L0l.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-D1oWTPzh.js → chunk-GF5L2VYU-DVNZmiVo.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-DQ1784gP.js → chunk-JWPE2WC7-B1yOfAhr.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-BUa9gwx1.js → chunk-KBJHAD2P-BEPc1N6N.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-u-ANrNSL.js → chunk-RYQCIY6F-Da_-gMwh.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-Daj0bhib.js → chunk-XXDRQBXY-C75eW9DT.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BRlRsJR0.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BRlRsJR0.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-Bk1oZEJ1.js → cose-bilkent-JH36ORCC-C4Gn7eYB.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-C4Ev_fka.js → cynefinDiagram-MW4NZA55--CBwVt18.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-D0n24UDZ.js → dagre-VZM6K2ZE-B8dBxboB.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-C1FlRrys.js → diagram-7IWD3JNH-hKtlE0w-.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-CWpeId5Y.js → diagram-B4RE2ZJO-BKirx0F3.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-CeEU1CTn.js → diagram-LBJQPF4R-bkx-oUrD.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-DgpFxfNH.js → diagram-Q27KOJAE-D7sFtSjr.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3--9JrEf2p.js → diagram-UB23O5K3-BPjzGBV_.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-D7E9C_OC.js → ebnfDiagram-BXEA7PRR-DODv-GbM.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-OYp4ZJQC.js → erDiagram-JOGREHBK-DbfVp5uI.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-Cyf8gGYJ.js → flowDiagram-UKHOOZJN-BHWWThbx.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-B7gUfjoR.js → ganttDiagram-PKOTCBZU-SWY_8oU3.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-mirrpSLp.js → gitGraphDiagram-DS77QQ5N-CJdhHY-i.js} +1 -1
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-gRb5KI0B.js → infoDiagram-6WML65LV-CLC4mTWX.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-v3JGPZ1t.js → ishikawaDiagram-WSZJBQD7-CiJDWOmX.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-jJLc06Q0.js → journeyDiagram-NVQOT4AX-eIQfMD0f.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-BJ7qkdrx.js → kanban-definition-27J2QSJJ-3d6r1cG7.js} +1 -1
- package/dist/worker/console/static/assets/{linear-B8iMATOq.js → linear-BjbmxxDk.js} +1 -1
- package/dist/worker/console/static/assets/main-B9ZnQejR.css +1 -0
- package/dist/worker/console/static/assets/{main-BA6TGEgV.js → main-D4knTr0R.js} +129 -129
- package/dist/worker/console/static/assets/{mermaid.core-C-6iih3_.js → mermaid.core-CD2GFYrr.js} +4 -4
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-kUxtuaLJ.js → mindmap-definition-FAOFIHXS-D0ORXhx-.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-CWscAnG2.js → pegDiagram-VL7TDLO6-BqNbcp7_.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-B4P97R-G.js → pieDiagram-7S7Q4E2Y-CGO0Y13N.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-TK_kx3AZ.js → quadrantDiagram-CIZ2JOQS-vH4fdvTV.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-BvoUgYhv.js → railroadDiagram-AXF67PYL-B_sbmiFS.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-DD-OVcGf.js → requirementDiagram-LRYGKXZP-DbHtPigL.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-C_d-co8f.js → sankeyDiagram-W5VNT64P-BcqNS0Ko.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-DEDF0c92.js → sequenceDiagram-SI44F4Z6-5Zf3xJfg.js} +1 -1
- package/dist/worker/console/static/assets/{sheet-workbook-BI2AD1uG.js → sheet-workbook-Bvq6WFll.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-C9N-yQxX.js → sizeCapture-X5ZJPWSS-BoO7GXeG.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-BXgVo9RE.js → stateDiagram-OKZ733FA-3suojNXT.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Bq6cg1c9.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DsJnGMMG.js → swimlanes-SLNWSIFB-B5CyFSLq.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-VvJzDuB_.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-BHQjX5sj.js → timeline-definition-Z64GVDOM-BuZ_HcXz.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-Cq_lSjge.js → vennDiagram-T6HMQDX7-CJ_IDS7Q.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-BEX8BDY-.js → wardleyDiagram-T6FBY63Y-BpKLb-Su.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-BTyfZdAf.js → xychartDiagram-ELKLHX3M-Mdo6gaIk.js} +1 -1
- package/dist/worker/console/static/index.html +2 -2
- package/dist/worker/console/static-src/operator-chat/chat-font-size.js +90 -0
- package/dist/worker/console/static-src/operator-chat/chat-session-order.js +96 -0
- package/package.json +3 -3
- package/dist/worker/console/static/assets/channel-gvXtLBqv.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-DQ5hdEfB.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-DQ5hdEfB.js +0 -1
- package/dist/worker/console/static/assets/main-BWBC5cML.css +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-CPyYpg4o.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-BECT1jaq.js +0 -8
package/CHANGELOG.md
CHANGED
package/dist/build-stamp.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"version": "0.52.0-next.
|
|
4
|
-
"gitSha": "
|
|
5
|
-
"builtAt": "2026-10-
|
|
3
|
+
"version": "0.52.0-next.3",
|
|
4
|
+
"gitSha": "efc6c72c8ea89d7165092ee5b6e4c5e969edaeaa",
|
|
5
|
+
"builtAt": "2026-10-19T16:20:53.523Z"
|
|
6
6
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accepted-merge normalization for `harness.json`.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `init.ts` so the edge-following rule can be tested directly:
|
|
5
|
+
* a wrong rule here does not fail loudly, it silently forces every
|
|
6
|
+
* `init upgrade` run back into the same merge task forever.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Actions that rewrite `harness.json` in place.
|
|
10
|
+
*
|
|
11
|
+
* `migrate-harness-governance-root` and `migrate-harness-model-fields` were
|
|
12
|
+
* missing here. A legacy project receives the governance-root migration and
|
|
13
|
+
* the structural reconciliation in the same apply-safe batch, so the first
|
|
14
|
+
* action moves the file off the accepted hash and the second no longer
|
|
15
|
+
* matches it. The chain then stopped at the original hash, the recorded
|
|
16
|
+
* acceptance never matched the on-disk file, and every run regenerated the
|
|
17
|
+
* same merge task.
|
|
18
|
+
*
|
|
19
|
+
* Any future action that rewrites `harness.json` must be registered here.
|
|
20
|
+
*/
|
|
21
|
+
export const HARNESS_REWRITE_ACTIONS = new Set([
|
|
22
|
+
"migrate-harness-governance-root",
|
|
23
|
+
"migrate-harness-model-fields",
|
|
24
|
+
"reconcile-harness-structure",
|
|
25
|
+
]);
|
|
26
|
+
/**
|
|
27
|
+
* Follow exact controller normalization edges, never infer acceptance from
|
|
28
|
+
* shape equality.
|
|
29
|
+
*
|
|
30
|
+
* A receipt advances the chain only when it targets `harness.json`, is a
|
|
31
|
+
* registered rewrite action, and its `beforeSha256` equals the hash reached
|
|
32
|
+
* so far. Receipts without a `beforeSha256` cannot be proven consecutive and
|
|
33
|
+
* are ignored rather than trusted.
|
|
34
|
+
*/
|
|
35
|
+
export function normalizedAcceptedHarnessHash(acceptedHash, actions) {
|
|
36
|
+
let current = acceptedHash;
|
|
37
|
+
for (const action of actions) {
|
|
38
|
+
if (action.path === "harness.json" &&
|
|
39
|
+
HARNESS_REWRITE_ACTIONS.has(action.type) &&
|
|
40
|
+
action.beforeSha256 === current &&
|
|
41
|
+
action.afterSha256) {
|
|
42
|
+
current = action.afterSha256;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return current;
|
|
46
|
+
}
|
|
@@ -545,6 +545,62 @@ function runDirectory(repoRoot, runId) {
|
|
|
545
545
|
throw new Error("invalid init upgrade run id");
|
|
546
546
|
return path.join(runRoot(repoRoot), runId);
|
|
547
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* Pick the single interrupted run for `--continue` when `--run-id` is absent.
|
|
550
|
+
*
|
|
551
|
+
* Repeated interrupted attempts leave several directories under
|
|
552
|
+
* `.harness/init-upgrades`, and asking the user to copy a run id out of a
|
|
553
|
+
* state file is both error-prone and pointless when only one run can be
|
|
554
|
+
* resumed. This never guesses among candidates: two live runs mean the caller
|
|
555
|
+
* must decide, so the error lists them instead of picking the newest.
|
|
556
|
+
*
|
|
557
|
+
* Only `in-progress` runs qualify; a `failed` run stays opt-in so a broken
|
|
558
|
+
* run cannot be resumed by accident.
|
|
559
|
+
*/
|
|
560
|
+
/**
|
|
561
|
+
* Decide which interrupted run `--continue` should resume.
|
|
562
|
+
*
|
|
563
|
+
* Exported as a pure decision so the 0/1/many cases are testable without
|
|
564
|
+
* building a fixture repository. Never guesses: two live runs mean the caller
|
|
565
|
+
* must choose, and a `failed` run stays opt-in.
|
|
566
|
+
*/
|
|
567
|
+
export function selectInterruptedRun(candidates) {
|
|
568
|
+
if (candidates.length === 0) {
|
|
569
|
+
return {
|
|
570
|
+
error: "init upgrade --continue found no interrupted run; run `loop-agent init upgrade` to start one, or pass --run-id",
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
if (candidates.length === 1)
|
|
574
|
+
return { runId: candidates[0].runId };
|
|
575
|
+
const sorted = [...candidates].sort((left, right) => String(right.updatedAt ?? "").localeCompare(String(left.updatedAt ?? "")));
|
|
576
|
+
const listed = sorted
|
|
577
|
+
.map((candidate) => ` ${candidate.runId}${candidate.phase ? ` (${candidate.phase})` : ""}${candidate.updatedAt ? ` updated ${candidate.updatedAt}` : ""}`)
|
|
578
|
+
.join("\n");
|
|
579
|
+
return {
|
|
580
|
+
error: `init upgrade --continue found ${candidates.length} interrupted runs; pass --run-id with one of:\n${listed}`,
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
async function resolveInterruptedRunId(repoRoot) {
|
|
584
|
+
const root = runRoot(repoRoot);
|
|
585
|
+
const entries = await readdir(root, { withFileTypes: true }).catch(() => []);
|
|
586
|
+
const candidates = [];
|
|
587
|
+
for (const entry of entries) {
|
|
588
|
+
if (!entry.isDirectory() || !validRunId(entry.name))
|
|
589
|
+
continue;
|
|
590
|
+
const state = await readState(repoRoot, entry.name).catch(() => undefined);
|
|
591
|
+
if (!state || state.status !== "in-progress")
|
|
592
|
+
continue;
|
|
593
|
+
candidates.push({
|
|
594
|
+
runId: entry.name,
|
|
595
|
+
...(typeof state.phase === "string" ? { phase: state.phase } : {}),
|
|
596
|
+
...(typeof state.updatedAt === "string" ? { updatedAt: state.updatedAt } : {}),
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
const selection = selectInterruptedRun(candidates);
|
|
600
|
+
if ("error" in selection)
|
|
601
|
+
throw new Error(selection.error);
|
|
602
|
+
return selection.runId;
|
|
603
|
+
}
|
|
548
604
|
async function exists(filePath) {
|
|
549
605
|
return Boolean(await stat(filePath).catch(() => undefined));
|
|
550
606
|
}
|
|
@@ -1182,6 +1238,46 @@ async function assertSafeMergePath(repoRoot, relativePath) {
|
|
|
1182
1238
|
throw new Error(`init upgrade merge realpath escapes repo: ${normalized}`);
|
|
1183
1239
|
}
|
|
1184
1240
|
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Directories whose contents never participate in the merge guard.
|
|
1243
|
+
*
|
|
1244
|
+
* The guard exists to prove that a merge touched only its declared paths, so
|
|
1245
|
+
* it only needs the governance surface. Walking dependency trees and build
|
|
1246
|
+
* output turned `DISCOVER` into a multi-minute scan on real projects (a
|
|
1247
|
+
* `node_modules` alone is tens of thousands of entries), which surfaced as an
|
|
1248
|
+
* external timeout with the run stuck in `DISCOVER`.
|
|
1249
|
+
*
|
|
1250
|
+
* Matching is by directory *name* only, so a file such as `src/dist.ts` or
|
|
1251
|
+
* `src/node_modules.ts` is still hashed normally. Skipping a directory also
|
|
1252
|
+
* excludes the directory entry itself from the snapshot, so no baseline bloat.
|
|
1253
|
+
*/
|
|
1254
|
+
const SNAPSHOT_SKIP_DIRECTORY_NAMES = new Set(["node_modules",
|
|
1255
|
+
"dist",
|
|
1256
|
+
"build",
|
|
1257
|
+
"coverage",
|
|
1258
|
+
".next",
|
|
1259
|
+
".nuxt",
|
|
1260
|
+
".turbo",
|
|
1261
|
+
".cache",
|
|
1262
|
+
".venv",
|
|
1263
|
+
"venv",
|
|
1264
|
+
"__pycache__",
|
|
1265
|
+
".pytest_cache",
|
|
1266
|
+
".mypy_cache",
|
|
1267
|
+
"target",
|
|
1268
|
+
".gradle",
|
|
1269
|
+
"vendor",
|
|
1270
|
+
]);
|
|
1271
|
+
/**
|
|
1272
|
+
* Whether a directory entry should be pruned from the workspace snapshot.
|
|
1273
|
+
*
|
|
1274
|
+
* Matches by directory name so `src/node_modules.ts` is still hashed. Exported
|
|
1275
|
+
* for direct testing: the guard's correctness depends on this staying narrow,
|
|
1276
|
+
* and an over-broad rule would silently stop protecting real files.
|
|
1277
|
+
*/
|
|
1278
|
+
export function shouldSkipSnapshotDirectory(entry) {
|
|
1279
|
+
return entry.isDirectory() && SNAPSHOT_SKIP_DIRECTORY_NAMES.has(entry.name);
|
|
1280
|
+
}
|
|
1185
1281
|
async function snapshotWorkspace(repoRoot) {
|
|
1186
1282
|
const snapshot = {};
|
|
1187
1283
|
async function visit(directory) {
|
|
@@ -1200,6 +1296,10 @@ async function snapshotWorkspace(repoRoot) {
|
|
|
1200
1296
|
continue;
|
|
1201
1297
|
if (relative === RUN_ROOT || relative.startsWith(`${RUN_ROOT}/`))
|
|
1202
1298
|
continue;
|
|
1299
|
+
// Prune dependency/build directories before recording or descending,
|
|
1300
|
+
// so neither their entry nor their contents enter the baseline.
|
|
1301
|
+
if (shouldSkipSnapshotDirectory(entry))
|
|
1302
|
+
continue;
|
|
1203
1303
|
if (entry.isSymbolicLink()) {
|
|
1204
1304
|
snapshot[relative] = `symlink:${await readlink(absolute)}`;
|
|
1205
1305
|
continue;
|
|
@@ -3594,7 +3694,19 @@ async function executeUpgrade(directory, state, input) {
|
|
|
3594
3694
|
});
|
|
3595
3695
|
}
|
|
3596
3696
|
export async function runInitUpgrade(input) {
|
|
3597
|
-
|
|
3697
|
+
// Canonicalize exactly once, the same way the decision-resume authority and
|
|
3698
|
+
// the controller anchor do. `path.resolve` alone keeps the Windows 8.3
|
|
3699
|
+
// short form (`MICROS~1`) that `realpath` expands, so the repo root
|
|
3700
|
+
// recorded into a pending decision never matched the one checked on
|
|
3701
|
+
// resume — the run then failed as "resume authority does not match
|
|
3702
|
+
// pending actions" even though every other field agreed.
|
|
3703
|
+
// Canonicalize exactly once, the same way the decision-resume authority and
|
|
3704
|
+
// the controller anchor do. `path.resolve` alone keeps the Windows 8.3
|
|
3705
|
+
// short form (`MICROS~1`) that `fs.promises.realpath` expands, so the repo
|
|
3706
|
+
// root recorded into a pending decision never matched the one checked on
|
|
3707
|
+
// resume — the run then failed as "resume authority does not match pending
|
|
3708
|
+
// actions" even though every other field agreed.
|
|
3709
|
+
const repoRoot = await realpath(path.resolve(input.repoRoot)).catch(() => path.resolve(input.repoRoot));
|
|
3598
3710
|
const mode = input.mode ?? "start";
|
|
3599
3711
|
if (input.decisionFile && mode !== "continue") {
|
|
3600
3712
|
throw new Error("init upgrade --decision-file requires --continue and --run-id");
|
|
@@ -3621,7 +3733,7 @@ export async function runInitUpgrade(input) {
|
|
|
3621
3733
|
};
|
|
3622
3734
|
}
|
|
3623
3735
|
const runId = mode === "continue"
|
|
3624
|
-
? input.runId
|
|
3736
|
+
? input.runId ?? (await resolveInterruptedRunId(repoRoot))
|
|
3625
3737
|
: input.runId ??
|
|
3626
3738
|
`init-upgrade-${new Date().toISOString().replace(/[-:.TZ]/g, "").slice(0, 14)}-${randomUUID().slice(0, 8)}`;
|
|
3627
3739
|
if (!runId)
|
package/dist/commands/init.js
CHANGED
|
@@ -3,6 +3,7 @@ import { access, copyFile, lstat, mkdir, readdir, readFile, realpath, rename, rm
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { isDeepStrictEqual } from "node:util";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { normalizedAcceptedHarnessHash } from "./init-accepted-merge.js";
|
|
6
7
|
import { GITIGNORE_BLOCK_END, GITIGNORE_BLOCK_START, buildManagedGitignoreBlock, extractGitignoreManagedBlock, mergeGitignoreManagedBlock, } from "../shared/gitignore-managed-block.js";
|
|
7
8
|
import { isInitRuntimeActive, } from "../shared/runtime-activity.js";
|
|
8
9
|
import { loadHarnessManifest } from "../governance/harness.js";
|
|
@@ -1657,16 +1658,8 @@ async function buildCurrentSurfaceState(input) {
|
|
|
1657
1658
|
};
|
|
1658
1659
|
}
|
|
1659
1660
|
/** Follow only exact controller normalization edges, never infer acceptance
|
|
1660
|
-
* from shape equality. Persisted edges recover an interrupted surface refresh.
|
|
1661
|
-
|
|
1662
|
-
let current = acceptedHash;
|
|
1663
|
-
for (const action of actions) {
|
|
1664
|
-
if (action.path === "harness.json" && action.type === "reconcile-harness-structure" &&
|
|
1665
|
-
action.beforeSha256 === current && action.afterSha256)
|
|
1666
|
-
current = action.afterSha256;
|
|
1667
|
-
}
|
|
1668
|
-
return current;
|
|
1669
|
-
}
|
|
1661
|
+
* from shape equality. Persisted edges recover an interrupted surface refresh.
|
|
1662
|
+
* See `init-accepted-merge.ts` for the rewrite-action set and its history. */
|
|
1670
1663
|
async function writeInitSurfaceState(input) {
|
|
1671
1664
|
const state = await buildCurrentSurfaceState(input);
|
|
1672
1665
|
state.dispositions = [
|
|
@@ -2752,7 +2745,59 @@ function actionForMissing(pathName, state) {
|
|
|
2752
2745
|
reason: "managed block file is missing or stale",
|
|
2753
2746
|
};
|
|
2754
2747
|
}
|
|
2755
|
-
|
|
2748
|
+
/**
|
|
2749
|
+
* Fields that carry verification authority.
|
|
2750
|
+
*
|
|
2751
|
+
* The controller preserves these from the project during reconciliation
|
|
2752
|
+
* (`buildHarness` keeps `existing.verification` etc.), so a merge that
|
|
2753
|
+
* rewrites them does not just change configuration — it changes which
|
|
2754
|
+
* checks gate the project. Callers need to know this before editing.
|
|
2755
|
+
*/
|
|
2756
|
+
const HARNESS_AUTHORITY_LOCKED_FIELDS = [
|
|
2757
|
+
"verification",
|
|
2758
|
+
"workflowPolicy",
|
|
2759
|
+
"executors",
|
|
2760
|
+
];
|
|
2761
|
+
/**
|
|
2762
|
+
* Compare two JSON documents and report the differing key paths.
|
|
2763
|
+
*
|
|
2764
|
+
* Values are never emitted: the caller only needs to know *which* paths to
|
|
2765
|
+
* reconcile. Arrays compare as whole values because element-wise paths are
|
|
2766
|
+
* noisy for configuration and rarely actionable.
|
|
2767
|
+
*
|
|
2768
|
+
* Exported so the key-path diff can be tested directly; a wrong diff misleads
|
|
2769
|
+
* the merge more than no diff at all.
|
|
2770
|
+
*/
|
|
2771
|
+
export function diffJsonKeyPaths(current, desired) {
|
|
2772
|
+
const added = [];
|
|
2773
|
+
const removed = [];
|
|
2774
|
+
const changed = [];
|
|
2775
|
+
const walk = (left, right, prefix) => {
|
|
2776
|
+
const leftIsRecord = isRecord(left);
|
|
2777
|
+
const rightIsRecord = isRecord(right);
|
|
2778
|
+
if (leftIsRecord && rightIsRecord) {
|
|
2779
|
+
for (const key of new Set([...Object.keys(left), ...Object.keys(right)])) {
|
|
2780
|
+
const nextPrefix = prefix ? `${prefix}.${key}` : key;
|
|
2781
|
+
const inLeft = Object.hasOwn(left, key);
|
|
2782
|
+
const inRight = Object.hasOwn(right, key);
|
|
2783
|
+
if (!inLeft && inRight)
|
|
2784
|
+
added.push(nextPrefix);
|
|
2785
|
+
else if (inLeft && !inRight)
|
|
2786
|
+
removed.push(nextPrefix);
|
|
2787
|
+
else
|
|
2788
|
+
walk(left[key], right[key], nextPrefix);
|
|
2789
|
+
}
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
if (leftIsRecord !== rightIsRecord || !isDeepStrictEqual(left, right)) {
|
|
2793
|
+
if (prefix)
|
|
2794
|
+
changed.push(prefix);
|
|
2795
|
+
}
|
|
2796
|
+
};
|
|
2797
|
+
walk(current, desired, "");
|
|
2798
|
+
return { added: added.sort(), removed: removed.sort(), changed: changed.sort() };
|
|
2799
|
+
}
|
|
2800
|
+
function modelMergeTaskFor(pathName, state, allPaths, recordedState, desiredPatch) {
|
|
2756
2801
|
return {
|
|
2757
2802
|
taskId: `init-merge-${sha256Text(pathName).slice(0, 12)}`,
|
|
2758
2803
|
path: pathName,
|
|
@@ -2774,12 +2819,25 @@ function modelMergeTaskFor(pathName, state, allPaths, recordedState) {
|
|
|
2774
2819
|
verification: [
|
|
2775
2820
|
`git diff --check -- ${pathName}`,
|
|
2776
2821
|
],
|
|
2822
|
+
// A merge task that only says "complete this task" leaves the caller to
|
|
2823
|
+
// rediscover the authority rules. That is a fact the controller already
|
|
2824
|
+
// holds, so state it in a slot call sites do not overwrite.
|
|
2825
|
+
...(pathName === "harness.json"
|
|
2826
|
+
? {
|
|
2827
|
+
authorityLockedFields: [...HARNESS_AUTHORITY_LOCKED_FIELDS],
|
|
2828
|
+
mergeGuidance: [
|
|
2829
|
+
`Keep the project values of these authority fields: ${HARNESS_AUTHORITY_LOCKED_FIELDS.join(", ")}.`,
|
|
2830
|
+
"`.harness/init-surface.json` is rewritten by the controller after a successful merge; do not edit it by hand.",
|
|
2831
|
+
],
|
|
2832
|
+
}
|
|
2833
|
+
: {}),
|
|
2777
2834
|
evidence: {
|
|
2778
2835
|
baseSha256: recordedState?.files[pathName]?.currentSha256,
|
|
2779
2836
|
currentSha256: state?.currentSha256,
|
|
2780
2837
|
desiredSha256: state?.sourceSha256,
|
|
2781
2838
|
sourceAnchorSha256: state?.sourceAnchorSha256,
|
|
2782
2839
|
},
|
|
2840
|
+
...(desiredPatch ? { desiredPatch } : {}),
|
|
2783
2841
|
};
|
|
2784
2842
|
}
|
|
2785
2843
|
function recommendedNextFor(report) {
|
|
@@ -3056,7 +3114,16 @@ export async function checkInitUpdate(input) {
|
|
|
3056
3114
|
}
|
|
3057
3115
|
else if (modelMigration.kind === "ambiguous") {
|
|
3058
3116
|
const state = currentState.files["harness.json"];
|
|
3059
|
-
|
|
3117
|
+
// The desired structure is computable here, so the caller does
|
|
3118
|
+
// not have to infer which key paths differ.
|
|
3119
|
+
const template = await readJsonIfExists(path.join(assetRoot, "harness.json"));
|
|
3120
|
+
const desiredStructure = buildHarness({
|
|
3121
|
+
existing: harness,
|
|
3122
|
+
template,
|
|
3123
|
+
projectName,
|
|
3124
|
+
governanceRoot,
|
|
3125
|
+
});
|
|
3126
|
+
const mergeTask = modelMergeTaskFor("harness.json", state, allPaths, recordedState, diffJsonKeyPaths(harness, desiredStructure));
|
|
3060
3127
|
mergeTask.reason = `legacy model configuration requires a human/model merge: ${modelMigration.reason}`;
|
|
3061
3128
|
mergeTask.mergeRules = [
|
|
3062
3129
|
"Preserve every existing harness.json field unless the user explicitly approves its migration.",
|
|
@@ -187,6 +187,13 @@ export function OPERATOR_CHAT_ACTIVE_TOOL_NAMES() {
|
|
|
187
187
|
export function computeOperatorChatActiveToolNames(session, sessionMode = DEFAULT_CONSOLE_CHAT_SESSION_MODE) {
|
|
188
188
|
return computeChatActiveToolNames(session, sessionMode);
|
|
189
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Last-resort window when neither the provider nor `models.json` declares one.
|
|
192
|
+
* Matches the default the Console model editor writes for a new model, so a
|
|
193
|
+
* gateway that reports nothing still gets proactive compaction instead of
|
|
194
|
+
* running until it rejects the request.
|
|
195
|
+
*/
|
|
196
|
+
const DEFAULT_CONTEXT_WINDOW = 128_000;
|
|
190
197
|
const OPERATOR_CHAT_SESSION_EXCLUDE_TOOLS = Object.freeze([
|
|
191
198
|
"apply_patch",
|
|
192
199
|
"apply-patch",
|
|
@@ -874,6 +881,31 @@ export class ConsolePiRuntime {
|
|
|
874
881
|
});
|
|
875
882
|
void sessionId;
|
|
876
883
|
}
|
|
884
|
+
/**
|
|
885
|
+
* Pick the context window to gate proactive compaction on.
|
|
886
|
+
*
|
|
887
|
+
* `getSessionStats().contextUsage.contextWindow` is what the provider
|
|
888
|
+
* reported for the live request, and a private/self-hosted gateway
|
|
889
|
+
* routinely reports `0`, `-1` or nothing at all — it has no obligation to
|
|
890
|
+
* tell us its limit. Gating only on that value silently disabled
|
|
891
|
+
* proactive compaction on such gateways: every session ran until the
|
|
892
|
+
* provider rejected the request, then fell back to the local checkpoint.
|
|
893
|
+
*
|
|
894
|
+
* The model definition in `models.json` (`session.model.contextWindow`)
|
|
895
|
+
* is the configured window and is authoritative when present. The
|
|
896
|
+
* reported value wins only when it is a usable positive number, because
|
|
897
|
+
* a gateway may enforce a tighter limit than the declared window.
|
|
898
|
+
*/
|
|
899
|
+
resolveContextWindow(session, reportedWindow) {
|
|
900
|
+
if (typeof reportedWindow === "number" && reportedWindow > 0) {
|
|
901
|
+
return reportedWindow;
|
|
902
|
+
}
|
|
903
|
+
const configured = session.model?.contextWindow;
|
|
904
|
+
if (typeof configured === "number" && configured > 0) {
|
|
905
|
+
return configured;
|
|
906
|
+
}
|
|
907
|
+
return DEFAULT_CONTEXT_WINDOW;
|
|
908
|
+
}
|
|
877
909
|
async runPrePromptCompaction(sessionId, session, promptText, imageCount, onEvent, signal) {
|
|
878
910
|
const policy = parseCompactionPolicy();
|
|
879
911
|
if (signal?.aborted)
|
|
@@ -882,8 +914,9 @@ export class ConsolePiRuntime {
|
|
|
882
914
|
return;
|
|
883
915
|
const controller = this.getCompactionController(sessionId);
|
|
884
916
|
const stats = session.getSessionStats?.();
|
|
885
|
-
const
|
|
917
|
+
const reportedWindow = stats?.contextUsage?.contextWindow;
|
|
886
918
|
const tokens = stats?.contextUsage?.tokens;
|
|
919
|
+
const window = this.resolveContextWindow(session, reportedWindow);
|
|
887
920
|
if (typeof window === "number" && window > 0) {
|
|
888
921
|
this.applySessionRecoveryOverrides(sessionId, this.serviceScopes.get(sessionId) ?? {}, session);
|
|
889
922
|
}
|
|
@@ -896,10 +929,8 @@ export class ConsolePiRuntime {
|
|
|
896
929
|
incrementPressureCounter(controller.counters, "usage-unavailable");
|
|
897
930
|
return;
|
|
898
931
|
}
|
|
899
|
-
const effective =
|
|
900
|
-
|
|
901
|
-
: undefined;
|
|
902
|
-
if (!effective || projection.projected < effective.triggerTokens) {
|
|
932
|
+
const effective = deriveEffectiveWindow(window, policy);
|
|
933
|
+
if (projection.projected < effective.triggerTokens) {
|
|
903
934
|
controller.pruneArmed = false;
|
|
904
935
|
return;
|
|
905
936
|
}
|
|
@@ -231,6 +231,15 @@ export class TerminalSessionRegistry {
|
|
|
231
231
|
rows: options.rows ?? 30,
|
|
232
232
|
env: process.env ?? {},
|
|
233
233
|
encoding: "utf8",
|
|
234
|
+
/*
|
|
235
|
+
* ConPTY was an implicit default, and when node-pty falls back to
|
|
236
|
+
* winpty on Windows it allocates a REAL console host window — the
|
|
237
|
+
* black "node" box that flashed on every terminal session. Asking
|
|
238
|
+
* for ConPTY explicitly (available on Windows 10 1809+) keeps the
|
|
239
|
+
* session headless. Left undefined on other platforms so node-pty
|
|
240
|
+
* keeps its own default there.
|
|
241
|
+
*/
|
|
242
|
+
...(IS_WINDOWS ? { useConpty: true } : {}),
|
|
234
243
|
});
|
|
235
244
|
}
|
|
236
245
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-
|
|
1
|
+
import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-D4dq_L0l.js";import{p as f}from"./chunk-JWPE2WC7-B1yOfAhr.js";import{_ as n,l as o}from"./mermaid.core-CD2GFYrr.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-BIFL8KrA.js";import"./FilePreviewDocx-ybM3ZqSl.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Y as ln,$ as an,a0 as F,a1 as q,a2 as j,a3 as un,a4 as y,a5 as tn,a6 as J,a7 as _,a8 as rn,a9 as o,aa as on,ab as sn,ac as fn}from"./mermaid.core-
|
|
1
|
+
import{Y as ln,$ as an,a0 as F,a1 as q,a2 as j,a3 as un,a4 as y,a5 as tn,a6 as J,a7 as _,a8 as rn,a9 as o,aa as on,ab as sn,ac as fn}from"./mermaid.core-CD2GFYrr.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,z,a){var O=I-l,i=D-h,n=z-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function U(l,h,I,D,v,A,z){var a=l-I,O=h-D,i=(z?A:-A)/J(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,B=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*J(on(0,T*T*R-P*P)),Y=(P*g-m*S)/R,$=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=Y-B,e=$-t,r=w-B,C=p-t;return x*x+e*e>r*r+C*C&&(Y=w,$=p),{cx:Y,cy:$,x01:-n,y01:-d,x11:Y*(v/T-1),y11:$*(v/T-1)}}function hn(){var l=cn,h=yn,I=j(0),D=null,v=gn,A=dn,z=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,B=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(B>tn-y)a.moveTo(s*F(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*F(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=B,S=B,Y=z.apply(this,arguments)/2,$=Y>y&&(D?+D.apply(this,arguments):J(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if($>y){var C=sn($/u*q(Y)),K=sn($/s*q(Y));(P-=C*2)>y?(C*=t?1:-1,R+=C,T-=C):(P=0,R=T=(f+c)/2),(S-=K*2)>y?(K*=t?1:-1,m+=K,g-=K):(S=0,m=g=(f+c)/2)}var G=s*F(m),H=s*q(m),L=u*F(T),M=u*q(T);if(w>y){var N=s*F(g),Q=s*q(g),V=u*F(R),W=u*q(R),E;if(B<an)if(E=pn(G,H,V,W,N,Q,L,M)){var X=G-E[0],Z=H-E[1],b=N-E[0],k=Q-E[1],nn=1/q(fn((X*b+Z*k)/(J(X*X+Z*Z)*J(b*b+k*k)))/2),en=J(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=U(V,W,G,H,s,x,t),r=U(N,Q,L,M,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(G,H),a.arc(0,0,s,m,g,!t)):a.moveTo(G,H),!(u>y)||!(P>y)?a.lineTo(L,M):p>y?(e=U(L,M,N,Q,u,-p,t),r=U(G,H,V,W,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[F(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:j(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:j(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:j(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:j(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:j(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:j(+n),i):A},i.padAngle=function(n){return arguments.length?(z=typeof n=="function"?n:j(+n),i):z},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|