@tea-agent/loop-agent 0.40.0-next.1 → 0.40.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/AGENTS.md +1 -1
- package/CHANGELOG.md +12 -3
- package/README.md +2 -2
- package/dist/application/task-lifecycle/advance.js +12 -0
- package/dist/build-stamp.json +3 -3
- package/dist/cli/update/runtime-activity.js +1 -29
- package/dist/commands/dag-rerun.js +1 -1
- package/dist/executors/shell-executor.js +1 -1
- package/dist/shared/dag-prompt-override.js +4 -5
- package/dist/shared/update/npm-client.js +33 -11
- package/dist/task/contract/apply.js +11 -1
- package/dist/task/contract/constants.js +2 -0
- package/dist/task/contract/hash.js +3 -0
- package/dist/task/contract/observe.js +25 -4
- package/dist/task/contract/paths.js +2 -1
- package/dist/task/contract/project.js +15 -1
- package/dist/task/contract/schema.js +2 -0
- package/dist/task/contract/transaction.js +12 -0
- package/dist/task/source-prepare/completeness.js +188 -0
- package/dist/task/source-prepare/fragment-inventory.js +474 -0
- package/dist/task/source-prepare/index.js +3 -0
- package/dist/task/source-prepare/ledger-reconciliation.js +127 -0
- package/dist/task/source-prepare/ledger-review.js +214 -0
- package/dist/task/source-prepare/ledger.js +545 -0
- package/dist/task/source-prepare/prepare.js +262 -1
- package/dist/task/source-prepare/semantic-intake.js +19 -3
- package/dist/task/source-prepare/source-fidelity-pi.js +384 -0
- package/dist/task/source-prepare/types.js +22 -0
- package/dist/worker/cli.js +12 -26
- package/dist/worker/console/console-handoff.js +82 -0
- package/dist/worker/console/console-update-and-init.js +115 -0
- package/dist/worker/console/console-update-runtime.js +84 -0
- package/dist/worker/console/draft-store.js +49 -0
- package/dist/worker/console/operation-store.js +1 -1
- package/dist/worker/console/operator-actions.js +129 -4
- package/dist/worker/console/operator-surface-health.js +1 -0
- package/dist/worker/console/prd-intake-bridge.js +13 -0
- package/dist/worker/console/routes.js +3 -0
- package/dist/worker/console/server.js +73 -5
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-Br92EGb7.js → abnfDiagram-N423BO3Z-CTx1TrNa.js} +1 -1
- package/dist/worker/console/static/assets/{arc-oulImtQq.js → arc-B4i9cVxX.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-tyHc6aqO.js → architectureDiagram-T3A2C74G-BAXE8_Rl.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CY86BSpT.js → blockDiagram-VBNYF7ZC-C5Xh59at.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BKKsDmNs.js → c4Diagram-5PPSVZJV-B_asOzAu.js} +1 -1
- package/dist/worker/console/static/assets/channel-Dj_4Moei.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-CXZdjl3B.js → chunk-2GRJ4B5K-wRO_iRNc.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B-aIFDQ5.js → chunk-2Q5K7J3B-ByOaSh_G.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-BDgAW_B2.js → chunk-5RXB4S5H-DjLzudan.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-DABa4UPR.js → chunk-5VM5RSS4-JCNGkXYT.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-aGbysVOx.js → chunk-6Q2QTUOP-BhrPXXMZ.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-B8MSZDVs.js → chunk-GF5L2VYU-TJ5JuEBT.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-CpelV73g.js → chunk-JWPE2WC7-VVthn_mD.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-BE04ty3z.js → chunk-KBJHAD2P-D60-Mny4.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-BUxTkaaR.js → chunk-RYQCIY6F-zXv7aVye.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-CYYBVKfX.js → chunk-XXDRQBXY-By9VQoi1.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-C0YYAyCa.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-C0YYAyCa.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-CEQF_xmQ.js → cose-bilkent-JH36ORCC-C4zQLe-M.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CqpxN5IT.js → cynefin-VYW2F7L2-wh5N2ReN.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-B3PzanVi.js → cynefinDiagram-MW4NZA55-Dlu5wIqs.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BSUGCNx1.js → dagre-VZM6K2ZE-CrDgthc6.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-CdLevU5T.js → diagram-7IWD3JNH-zN1clg27.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-BjpF_Kok.js → diagram-B4RE2ZJO-BN-o7J7-.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-C4I6NJny.js → diagram-LBJQPF4R-C8SuPt0d.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-C8hecCr5.js → diagram-Q27KOJAE-BoizuHbZ.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-Daod6tOS.js → diagram-UB23O5K3-BzUzXixG.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BvvmazGv.js → ebnfDiagram-BXEA7PRR-Ev3lA4Cf.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-DeN_vfV4.js → erDiagram-JOGREHBK-GALUzRbs.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-D6dq1t9z.js → flowDiagram-UKHOOZJN-CZJN65Sb.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-DziIdNY4.js → ganttDiagram-PKOTCBZU-JLB9OESl.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Dy4s5CXr.js → gitGraphDiagram-DS77QQ5N-CcvCr4GD.js} +1 -1
- package/dist/worker/console/static/assets/{index-Ci8ksvBm.js → index-CW88Fjbw.js} +81 -81
- package/dist/worker/console/static/assets/index-DP0ZJl39.css +1 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-Czv5eYx2.js → infoDiagram-6WML65LV-HG5z7aVg.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-Bsk3nFRT.js → ishikawaDiagram-WSZJBQD7-BHEu9chR.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-DxGmNj5K.js → journeyDiagram-NVQOT4AX-Cp_Up8-a.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-CYCFqkO_.js → kanban-definition-27J2QSJJ-DvVeY-em.js} +1 -1
- package/dist/worker/console/static/assets/{linear-B0YzRwrd.js → linear-aGmcjgTn.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-t3EZtIGh.js → mermaid.core-Biyo-tqA.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-BTXpTv0T.js → mindmap-definition-FAOFIHXS-DyxY2pIb.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-DU8UkKqA.js → pegDiagram-VL7TDLO6-CkdGuc50.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-DP4y8ohp.js → pieDiagram-7S7Q4E2Y-NNQI9xVR.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-B07vNaYR.js → quadrantDiagram-CIZ2JOQS-PAJkuz_G.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-xDWktb2i.js → railroadDiagram-AXF67PYL-ZwrQod0O.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-BLNMKqeS.js → requirementDiagram-LRYGKXZP-D3ZfrzM2.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-n0adalxH.js → sankeyDiagram-W5VNT64P-DDGFmWk5.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-BbnS-2DL.js → sequenceDiagram-SI44F4Z6-DO6mmXTA.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-B4uPpCLu.js → sizeCapture-X5ZJPWSS-DMbCQiJt.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA--MMbB0fX.js → stateDiagram-OKZ733FA-Di_YUEfC.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DrdDvela.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-BXUgp2QY.js → swimlanes-SLNWSIFB-Bn2PphNJ.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DPkEAULl.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-CsaMxki7.js → timeline-definition-Z64GVDOM-DPh8pRsp.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-C2IuG9iH.js → vennDiagram-T6HMQDX7-GMfl26pW.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-CmEWOXCW.js → wardleyDiagram-T6FBY63Y-DTlmVrmF.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-D_9LE0MG.js → xychartDiagram-ELKLHX3M-YGBjKAS5.js} +1 -1
- package/dist/worker/console/static/index.html +2 -2
- package/dist/worker/console/static-src/app/console-types.js +40 -1
- package/dist/worker/console/static-src/app/useOperatorActions.js +5 -0
- package/dist/worker/console/static-src/app/useTaskWizard.js +73 -1
- package/dist/worker/observability/init-runtime-activity.js +26 -0
- package/dist/worker/observe/node-input.js +88 -2
- package/dist/worker/observe/routes.js +188 -0
- package/dist/worker/observe/static/api.js +3 -3
- package/dist/worker/observe/static/dag-node-purpose.d.ts +6 -0
- package/dist/worker/observe/static/dag-node-purpose.js +203 -0
- package/dist/worker/observe/static/format.js +37 -0
- package/dist/worker/observe/static/index.html +5 -0
- package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
- package/dist/worker/observe/static/prompt-restart-candidates.js +36 -0
- package/dist/worker/observe/static/state.js +2 -2
- package/dist/worker/observe/static/styles.css +338 -35
- package/dist/worker/observe/static/views/dag-graph.js +4 -2
- package/dist/worker/observe/static/views/dag-inspector.js +531 -78
- package/dist/worker/observe/static/views/dag.d.ts +13 -0
- package/dist/worker/observe/static/views/dag.js +4 -3
- package/dist/worker/observe/static/views/task.js +55 -0
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +29 -1
- package/dist/workflows/dag/backend-test-markdown-workflow.js +176 -1
- package/dist/workflows/dag/backend-test-pytest-collection.js +87 -4
- package/dist/workflows/dag/backend-test-writer-completeness.js +10 -5
- package/dist/workflows/dag/frontend-implementation-contract.js +88 -2
- package/dist/workflows/dag/frontend-plan-render.js +24 -0
- package/dist/workflows/dag/frontend-prewrite-gate.js +197 -0
- package/dist/workflows/dag/frontend-review-context.js +92 -10
- package/dist/workflows/dag/init-hybrid.js +125 -4
- package/dist/workflows/dag/node-execution.js +45 -0
- package/dist/workflows/dag/types.js +42 -11
- package/docs/README.md +1 -0
- package/docs/architecture/evolution.md +45 -0
- package/docs/init-surface.manifest.json +1 -0
- package/docs/templates/README.md +1 -1
- package/docs/templates/frontend-implementation-contract.schema.json +681 -24
- package/package.json +1 -1
- package/skills/loop-agent/references/hybrid-dag.md +7 -0
- package/dist/worker/console/static/assets/channel-TY36zt-i.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-Dk7QCChM.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-Dk7QCChM.js +0 -1
- package/dist/worker/console/static/assets/index-C3GgHg-g.css +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-BqOigMQ4.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-Caxz9UA2.js +0 -8
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import { readPackageVersion } from "../../shared/package-metadata.js";
|
|
3
|
+
import { createNpmUpdateClient } from "../../shared/update/npm-client.js";
|
|
4
|
+
import { acquireUpdateLock, updateLockPath } from "../../shared/update/state.js";
|
|
5
|
+
import { readInitRuntimeActivity } from "../observability/init-runtime-activity.js";
|
|
6
|
+
import { performConsoleUpdateAndInit, } from "./console-update-and-init.js";
|
|
7
|
+
import { TERMINAL_OPERATION_STATES } from "./operation-store.js";
|
|
8
|
+
export function createConsoleUpdateExecutor(input) {
|
|
9
|
+
return async (channel) => {
|
|
10
|
+
const currentVersion = readPackageVersion(input.packageRoot);
|
|
11
|
+
if (!currentVersion) {
|
|
12
|
+
return {
|
|
13
|
+
state: "failed",
|
|
14
|
+
errorCode: "PACKAGE_IDENTITY_UNAVAILABLE",
|
|
15
|
+
errorMessage: "Console package version cannot be proven",
|
|
16
|
+
maintenance: {
|
|
17
|
+
package: { status: "failed", channel },
|
|
18
|
+
initialization: { status: "not-run", pendingPaths: [] },
|
|
19
|
+
handoff: { status: "not-needed" },
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const npm = createNpmUpdateClient({
|
|
24
|
+
currentVersion,
|
|
25
|
+
packageRoot: input.packageRoot,
|
|
26
|
+
cwd: input.repoRoot,
|
|
27
|
+
});
|
|
28
|
+
return performConsoleUpdateAndInit({
|
|
29
|
+
currentVersion,
|
|
30
|
+
preflight: async () => {
|
|
31
|
+
const [activity, operations] = await Promise.all([
|
|
32
|
+
readInitRuntimeActivity(input.repoRoot),
|
|
33
|
+
input.operations.list(),
|
|
34
|
+
]);
|
|
35
|
+
if (activity.workerProjectionError ||
|
|
36
|
+
activity.activeDagRunIds.length > 0 ||
|
|
37
|
+
activity.activeWorkerTasks > 0 ||
|
|
38
|
+
activity.activeWorkerBatches > 0) {
|
|
39
|
+
return {
|
|
40
|
+
ok: false,
|
|
41
|
+
code: "ACTIVE_RUNTIME",
|
|
42
|
+
message: "active DAG/Worker runtime exists or cannot be proven inactive",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (input.activeChatTurnCount() > 0) {
|
|
46
|
+
return {
|
|
47
|
+
ok: false,
|
|
48
|
+
code: "CHAT_TURN_ACTIVE",
|
|
49
|
+
message: "an Operator Chat turn is active",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const liveOtherOperation = operations.some((operation) => operation.action !== "consoleUpdateAndInit" &&
|
|
53
|
+
!TERMINAL_OPERATION_STATES.has(operation.state));
|
|
54
|
+
return liveOtherOperation
|
|
55
|
+
? {
|
|
56
|
+
ok: false,
|
|
57
|
+
code: "OPERATION_ACTIVE",
|
|
58
|
+
message: "another Console operation is active",
|
|
59
|
+
}
|
|
60
|
+
: { ok: true };
|
|
61
|
+
},
|
|
62
|
+
acquireLock: () => acquireUpdateLock(updateLockPath(os.homedir())),
|
|
63
|
+
resolveVersion: (selectedChannel) => npm.distTagVersionCheck(selectedChannel),
|
|
64
|
+
canAutoInstall: () => npm.canAutoInstall(),
|
|
65
|
+
installExact: (version, selectedChannel) => npm.installExact(version, selectedChannel),
|
|
66
|
+
verifyInstalled: (version) => npm.verifyInstalled(version),
|
|
67
|
+
applySafeInit: async () => {
|
|
68
|
+
const result = await input.client.runExternal("loop-agent", ["init", "update", "--apply-safe", "--repo-root", input.repoRoot], {
|
|
69
|
+
cwd: input.repoRoot,
|
|
70
|
+
artifactName: "console-update-safe-init",
|
|
71
|
+
timeoutMs: 120_000,
|
|
72
|
+
});
|
|
73
|
+
return result.ok
|
|
74
|
+
? { ok: true, pendingPaths: [] }
|
|
75
|
+
: {
|
|
76
|
+
ok: false,
|
|
77
|
+
message: result.stderr || result.stdout || "safe initialization failed",
|
|
78
|
+
pendingPaths: [],
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
requestHandoff: async ({ targetVersion }) => input.requestHandoff(targetVersion),
|
|
82
|
+
}, channel);
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { readJsonIfExists, sha256Json, writeSecureJson, } from "./app-data.js";
|
|
3
|
+
/**
|
|
4
|
+
* 从任意上游载荷安全投影 ledger 摘要(未知形状丢弃,绝不抛错、绝不信任字段外的数据)。
|
|
5
|
+
* 供 DraftStore / prd-intake-bridge 把 prepare/advance 结果中的 ledger 摘要带入草稿。
|
|
6
|
+
*/
|
|
7
|
+
export function summarizeLedgerPayload(value) {
|
|
8
|
+
if (!value || typeof value !== "object")
|
|
9
|
+
return undefined;
|
|
10
|
+
const record = value;
|
|
11
|
+
if (record.present !== true)
|
|
12
|
+
return undefined;
|
|
13
|
+
const num = (key) => {
|
|
14
|
+
const raw = record[key];
|
|
15
|
+
return typeof raw === "number" && Number.isFinite(raw) ? raw : 0;
|
|
16
|
+
};
|
|
17
|
+
const gateRaw = record.gateStatus;
|
|
18
|
+
const gateStatus = gateRaw === "pass" || gateRaw === "fail" || gateRaw === "unknown"
|
|
19
|
+
? gateRaw
|
|
20
|
+
: "unknown";
|
|
21
|
+
const failureCode = typeof record.failureCode === "string" && record.failureCode
|
|
22
|
+
? record.failureCode
|
|
23
|
+
: null;
|
|
24
|
+
const rawExclusions = Array.isArray(record.exclusions) ? record.exclusions : [];
|
|
25
|
+
const exclusions = [];
|
|
26
|
+
for (const item of rawExclusions) {
|
|
27
|
+
if (!item || typeof item !== "object")
|
|
28
|
+
continue;
|
|
29
|
+
const entry = item;
|
|
30
|
+
const fragmentId = typeof entry.fragmentId === "string" ? entry.fragmentId : "";
|
|
31
|
+
const reason = typeof entry.reason === "string" ? entry.reason : "";
|
|
32
|
+
if (!fragmentId)
|
|
33
|
+
continue;
|
|
34
|
+
exclusions.push({ fragmentId, reason });
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
present: true,
|
|
38
|
+
fragmentCount: num("fragmentCount"),
|
|
39
|
+
canonicalRequirementCount: num("canonicalRequirementCount"),
|
|
40
|
+
contextOnlyCount: num("contextOnlyCount"),
|
|
41
|
+
duplicateCount: num("duplicateCount"),
|
|
42
|
+
unresolvedCount: num("unresolvedCount"),
|
|
43
|
+
conflictCount: num("conflictCount"),
|
|
44
|
+
gateStatus,
|
|
45
|
+
failureCode,
|
|
46
|
+
exclusions,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
3
49
|
function draftPath(appData, taskId) {
|
|
4
50
|
const safe = taskId.replace(/[^a-zA-Z0-9._-]+/g, "_");
|
|
5
51
|
return path.join(appData.drafts, `${safe}.json`);
|
|
@@ -86,6 +132,9 @@ export function toCanonicalDraftForCli(draft) {
|
|
|
86
132
|
if (draft.interviewAssessmentRef) {
|
|
87
133
|
canonical.interviewAssessmentRef = draft.interviewAssessmentRef;
|
|
88
134
|
}
|
|
135
|
+
// AC-BLOCK-002:canonical draft JSON 绝不携带 ledgerSummary 字段(strict
|
|
136
|
+
// taskContractDraftSchema 拒绝未知键)。摘要仅留在 prd-intake-bridge 响应与
|
|
137
|
+
// console-types 的 LedgerSummaryView(UI 视图模型),不进入持久化 draft。
|
|
89
138
|
return canonical;
|
|
90
139
|
}
|
|
91
140
|
export class DraftStore {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { listJsonFiles, readJsonIfExists, sha256Json, writeSecureJson, } from "./app-data.js";
|
|
4
|
-
export const TERMINAL_OPERATION_STATES = new Set(["succeeded", "failed", "timed-out"]);
|
|
4
|
+
export const TERMINAL_OPERATION_STATES = new Set(["succeeded", "failed", "timed-out", "restarting"]);
|
|
5
5
|
function operationFile(appData, operationId) {
|
|
6
6
|
return path.join(appData.operations, `${operationId}.json`);
|
|
7
7
|
}
|
|
@@ -536,6 +536,106 @@ async function acceptOperation(ctx, input) {
|
|
|
536
536
|
},
|
|
537
537
|
};
|
|
538
538
|
}
|
|
539
|
+
async function acceptConsoleUpdateAndInit(ctx, clientRequestId, channel) {
|
|
540
|
+
if (!ctx.consoleUpdateExecutor) {
|
|
541
|
+
return {
|
|
542
|
+
kind: "error",
|
|
543
|
+
status: 503,
|
|
544
|
+
body: operatorFailed({
|
|
545
|
+
command: "consoleUpdateAndInit",
|
|
546
|
+
outcome: "blocked",
|
|
547
|
+
code: "CONSOLE_UPDATE_UNAVAILABLE",
|
|
548
|
+
message: "Console update runtime is unavailable",
|
|
549
|
+
}),
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
const created = await ctx.operations.create({
|
|
553
|
+
clientRequestId,
|
|
554
|
+
action: "consoleUpdateAndInit",
|
|
555
|
+
actionParams: { channel },
|
|
556
|
+
});
|
|
557
|
+
if (created.kind === "conflict") {
|
|
558
|
+
return {
|
|
559
|
+
kind: "error",
|
|
560
|
+
status: 409,
|
|
561
|
+
body: operatorFailed({
|
|
562
|
+
command: "consoleUpdateAndInit",
|
|
563
|
+
outcome: "conflict",
|
|
564
|
+
code: "REQUEST_ID_REUSE_CONFLICT",
|
|
565
|
+
message: created.message,
|
|
566
|
+
}),
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
if (created.kind === "idempotent") {
|
|
570
|
+
return {
|
|
571
|
+
kind: "accepted",
|
|
572
|
+
status: 202,
|
|
573
|
+
body: {
|
|
574
|
+
operationId: created.operation.operationId,
|
|
575
|
+
state: created.operation.state,
|
|
576
|
+
clientRequestId: created.operation.clientRequestId,
|
|
577
|
+
action: created.operation.action,
|
|
578
|
+
},
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
queueMicrotask(() => {
|
|
582
|
+
void (async () => {
|
|
583
|
+
const operationId = created.operation.operationId;
|
|
584
|
+
await ctx.operations.update(operationId, {
|
|
585
|
+
state: "running",
|
|
586
|
+
startedAt: new Date().toISOString(),
|
|
587
|
+
});
|
|
588
|
+
ctx.events.append(operationId, {
|
|
589
|
+
at: new Date().toISOString(),
|
|
590
|
+
kind: "state",
|
|
591
|
+
state: "running",
|
|
592
|
+
message: `checking runtime, npm ${channel}, and safe initialization`,
|
|
593
|
+
});
|
|
594
|
+
try {
|
|
595
|
+
const result = await ctx.consoleUpdateExecutor(channel);
|
|
596
|
+
const state = result.state;
|
|
597
|
+
const next = await ctx.operations.update(operationId, {
|
|
598
|
+
state,
|
|
599
|
+
finishedAt: new Date().toISOString(),
|
|
600
|
+
result: result,
|
|
601
|
+
...(result.errorCode ? { errorCode: result.errorCode } : {}),
|
|
602
|
+
...(result.errorMessage ? { errorMessage: result.errorMessage } : {}),
|
|
603
|
+
});
|
|
604
|
+
ctx.events.append(operationId, {
|
|
605
|
+
at: new Date().toISOString(),
|
|
606
|
+
kind: "state",
|
|
607
|
+
state: next.state,
|
|
608
|
+
message: result.errorMessage ?? `console maintenance ${next.state}`,
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
catch (error) {
|
|
612
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
613
|
+
const next = await ctx.operations.update(operationId, {
|
|
614
|
+
state: "needs-reconcile",
|
|
615
|
+
finishedAt: new Date().toISOString(),
|
|
616
|
+
errorCode: "CONSOLE_UPDATE_EXCEPTION",
|
|
617
|
+
errorMessage: message,
|
|
618
|
+
});
|
|
619
|
+
ctx.events.append(operationId, {
|
|
620
|
+
at: new Date().toISOString(),
|
|
621
|
+
kind: "error",
|
|
622
|
+
state: next.state,
|
|
623
|
+
message,
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
})();
|
|
627
|
+
});
|
|
628
|
+
return {
|
|
629
|
+
kind: "accepted",
|
|
630
|
+
status: 202,
|
|
631
|
+
body: {
|
|
632
|
+
operationId: created.operation.operationId,
|
|
633
|
+
state: created.operation.state,
|
|
634
|
+
clientRequestId: created.operation.clientRequestId,
|
|
635
|
+
action: created.operation.action,
|
|
636
|
+
},
|
|
637
|
+
};
|
|
638
|
+
}
|
|
539
639
|
export async function dispatchOperatorAction(ctx, req) {
|
|
540
640
|
const action = req.action?.trim();
|
|
541
641
|
if (!action) {
|
|
@@ -566,6 +666,31 @@ export async function dispatchOperatorAction(ctx, req) {
|
|
|
566
666
|
};
|
|
567
667
|
}
|
|
568
668
|
const p = paramsOf(req);
|
|
669
|
+
if (action === "consoleUpdateAndInit") {
|
|
670
|
+
if (req.source !== "human-ui") {
|
|
671
|
+
return {
|
|
672
|
+
kind: "error",
|
|
673
|
+
status: 403,
|
|
674
|
+
body: operatorFailed({
|
|
675
|
+
command: action,
|
|
676
|
+
outcome: "blocked",
|
|
677
|
+
code: "HUMAN_UI_REQUIRED",
|
|
678
|
+
message: "consoleUpdateAndInit is available only from the Operate UI",
|
|
679
|
+
}),
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
if (!req.clientRequestId?.trim()) {
|
|
683
|
+
return invalid(action, "clientRequestId is required");
|
|
684
|
+
}
|
|
685
|
+
if (Object.keys(p).some((key) => key !== "channel")) {
|
|
686
|
+
return invalid(action, "only channel may be provided");
|
|
687
|
+
}
|
|
688
|
+
const channel = p.channel ?? "latest";
|
|
689
|
+
if (channel !== "latest" && channel !== "next") {
|
|
690
|
+
return invalid(action, "channel must be latest or next");
|
|
691
|
+
}
|
|
692
|
+
return acceptConsoleUpdateAndInit(ctx, req.clientRequestId, channel);
|
|
693
|
+
}
|
|
569
694
|
switch (action) {
|
|
570
695
|
case "operatorCapabilities": {
|
|
571
696
|
const doc = buildOperatorCapabilitiesDocument();
|
|
@@ -2159,8 +2284,8 @@ export async function dispatchOperatorAction(ctx, req) {
|
|
|
2159
2284
|
return accepted;
|
|
2160
2285
|
}
|
|
2161
2286
|
case "dagPromptOverrideConfig": {
|
|
2162
|
-
//
|
|
2163
|
-
//
|
|
2287
|
+
// The prompt-edit entry is visible by default. The internal environment
|
|
2288
|
+
// switch remains an emergency kill switch and is reflected here.
|
|
2164
2289
|
return {
|
|
2165
2290
|
kind: "sync",
|
|
2166
2291
|
status: 200,
|
|
@@ -2182,7 +2307,7 @@ export async function dispatchOperatorAction(ctx, req) {
|
|
|
2182
2307
|
}
|
|
2183
2308
|
if (parsedOverrides.overrides.length > 0 &&
|
|
2184
2309
|
!isDagRerunPromptOverrideEnabled()) {
|
|
2185
|
-
return invalid(action, `prompt override rerun is disabled
|
|
2310
|
+
return invalid(action, `prompt override rerun is disabled by ${DAG_RERUN_PROMPT_OVERRIDE_ENV}; unset it or use a value other than 0, false, or off to enable this experimental capability`);
|
|
2186
2311
|
}
|
|
2187
2312
|
const overrideArgs = parsedOverrides.overrides.length > 0
|
|
2188
2313
|
? await buildPromptOverrideCliArgs(ctx, parsedOverrides.overrides)
|
|
@@ -2215,7 +2340,7 @@ export async function dispatchOperatorAction(ctx, req) {
|
|
|
2215
2340
|
}
|
|
2216
2341
|
if (parsedOverrides.overrides.length > 0 &&
|
|
2217
2342
|
!isDagRerunPromptOverrideEnabled()) {
|
|
2218
|
-
return invalid(action, `prompt override rerun is disabled
|
|
2343
|
+
return invalid(action, `prompt override rerun is disabled by ${DAG_RERUN_PROMPT_OVERRIDE_ENV}; unset it or use a value other than 0, false, or off to enable this experimental capability`);
|
|
2219
2344
|
}
|
|
2220
2345
|
const overrideArgs = parsedOverrides.overrides.length > 0
|
|
2221
2346
|
? await buildPromptOverrideCliArgs(ctx, parsedOverrides.overrides)
|
|
@@ -12,6 +12,7 @@ export function buildOperatorSurfaceHealthV1(input) {
|
|
|
12
12
|
repoName: input.repoRoot.split(/[\\/]/).filter(Boolean).pop() ?? "repository",
|
|
13
13
|
packageName,
|
|
14
14
|
packageVersion,
|
|
15
|
+
consoleInstanceId: input.consoleInstanceId,
|
|
15
16
|
piReadiness: input.piReadiness,
|
|
16
17
|
inspect: {
|
|
17
18
|
ready: input.inspectReady,
|
|
@@ -9,6 +9,7 @@ import { getTaskPaths } from "../../task/runtime.js";
|
|
|
9
9
|
import { SEMANTIC_INTAKE_ARTIFACT_REL, } from "../../task/source-prepare/semantic-intake.js";
|
|
10
10
|
import { extractRequirementFactsFromMarkdown } from "../../task/source-prepare/parse-intent.js";
|
|
11
11
|
import { filterPlaceholderPaths, isNonPlaceholderPath, } from "../../task/source-prepare/placeholder-paths.js";
|
|
12
|
+
import { summarizeLedgerPayload, } from "./draft-store.js";
|
|
12
13
|
import { emptyDraft } from "./interview/grill-me.js";
|
|
13
14
|
import { normalizeConsoleWorkflowKind } from "./workflow-kinds.js";
|
|
14
15
|
function asStringList(value) {
|
|
@@ -219,6 +220,15 @@ export async function buildDraftFromTaskIntake(input) {
|
|
|
219
220
|
const paths = getTaskPaths(input.repoRoot, input.taskId);
|
|
220
221
|
const warnings = warningList(input.advanceJson);
|
|
221
222
|
const lifecycleState = lifecycleFromAdvanceJson(input.advanceJson);
|
|
223
|
+
// Source fidelity ledger 安全摘要透传(AC-009):来自 advance/prepare 结果,
|
|
224
|
+
// 未知形状安全丢弃,绝不携带未截断原文。
|
|
225
|
+
const advanceRoot = input.advanceJson && typeof input.advanceJson === "object"
|
|
226
|
+
? input.advanceJson
|
|
227
|
+
: {};
|
|
228
|
+
const ledgerSummary = summarizeLedgerPayload(advanceRoot.ledgerSummary) ??
|
|
229
|
+
summarizeLedgerPayload(advanceRoot.result && typeof advanceRoot.result === "object"
|
|
230
|
+
? advanceRoot.result.ledgerSummary
|
|
231
|
+
: undefined);
|
|
222
232
|
const semanticApplied = warnings.some((w) => w.code === "SEMANTIC_INTAKE_APPLIED");
|
|
223
233
|
const semanticFailed = warnings.find((w) => w.code === "SEMANTIC_INTAKE_PI_FAILED" ||
|
|
224
234
|
w.code === "SEMANTIC_INTAKE_INVALID_OUTPUT" ||
|
|
@@ -427,11 +437,14 @@ export async function buildDraftFromTaskIntake(input) {
|
|
|
427
437
|
if (input.engineering) {
|
|
428
438
|
draft = applyEngineeringBoundaryToDraft(draft, input.engineering);
|
|
429
439
|
}
|
|
440
|
+
// AC-BLOCK-002:摘要仅经响应返回 UI 视图模型,不写入 draft(防止 strict
|
|
441
|
+
// taskContractDraftSchema 因未知 ledgerSummary 键拒绝 canonical draft)。
|
|
430
442
|
return {
|
|
431
443
|
draft,
|
|
432
444
|
parseStatus,
|
|
433
445
|
semanticIntake,
|
|
434
446
|
gaps,
|
|
447
|
+
...(ledgerSummary ? { ledgerSummary } : {}),
|
|
435
448
|
lifecycleState,
|
|
436
449
|
};
|
|
437
450
|
}
|
|
@@ -67,6 +67,7 @@ export async function handleConsoleHealthRequest(_req, res, ctx) {
|
|
|
67
67
|
piReadiness: ctx.operator?.getReadiness().state ?? "setup-required",
|
|
68
68
|
inspectReady: ctx.inspect.ready,
|
|
69
69
|
routes: ROUTES,
|
|
70
|
+
consoleInstanceId: ctx.consoleInstanceId,
|
|
70
71
|
}));
|
|
71
72
|
}
|
|
72
73
|
catch {
|
|
@@ -77,6 +78,7 @@ export async function handleConsoleHealthRequest(_req, res, ctx) {
|
|
|
77
78
|
repoFingerprint: "unavailable",
|
|
78
79
|
packageName: "unknown",
|
|
79
80
|
packageVersion: "0.0.0",
|
|
81
|
+
consoleInstanceId: ctx.consoleInstanceId,
|
|
80
82
|
piReadiness: ctx.operator?.getReadiness().state ?? "setup-required",
|
|
81
83
|
inspect: {
|
|
82
84
|
ready: ctx.inspect.ready,
|
|
@@ -217,6 +219,7 @@ async function handleCreateOperation(req, res, ctx) {
|
|
|
217
219
|
action,
|
|
218
220
|
actionParams,
|
|
219
221
|
clientRequestId,
|
|
222
|
+
source: "human-ui",
|
|
220
223
|
});
|
|
221
224
|
sendJson(res, result.status, result.body);
|
|
222
225
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
2
3
|
import { existsSync } from "node:fs";
|
|
3
4
|
import { createServer } from "node:http";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { LoopAgentClient } from "../loop-agent/loop-agent-client.js";
|
|
8
|
+
import { readPackageVersion } from "../../shared/package-metadata.js";
|
|
7
9
|
import { DAG_ABSOLUTE_MAX_WALL_CLOCK_MS } from "../../shared/timeout-policy.js";
|
|
8
10
|
import { openConsoleAppData } from "./app-data.js";
|
|
9
11
|
import { DagConfirmationStore } from "./dag-confirmation.js";
|
|
@@ -22,11 +24,13 @@ import { OperationStore } from "./operation-store.js";
|
|
|
22
24
|
import { probePiReadiness, } from "./pi-readiness.js";
|
|
23
25
|
import { handleConsoleHealthRequest, handleConsoleOperatorRequest, sendJson, serveConsoleStatic, } from "./routes.js";
|
|
24
26
|
import { issueBootCapabilityToken, injectConfirmationTokenScript, } from "./security.js";
|
|
25
|
-
import { resolveSiblingLoopAgentBin } from "./sibling-controller.js";
|
|
27
|
+
import { resolvePackageRootFromConsole, resolveSiblingLoopAgentBin, } from "./sibling-controller.js";
|
|
26
28
|
import { isDagRerunPromptOverrideEnabled } from "../../shared/dag-prompt-override.js";
|
|
27
29
|
import { NightAuxTicker } from "./night-aux-ticker.js";
|
|
28
30
|
import { deriveObserveRouteCapabilities } from "../observe/health.js";
|
|
29
31
|
import { createObserveRouteContext, defaultObserveStaticDir, handleMatchedObserveRoute, matchObserveGetRoute, ROUTES, serveObserveStatic, } from "../observe/routes.js";
|
|
32
|
+
import { createConsoleUpdateExecutor } from "./console-update-runtime.js";
|
|
33
|
+
import { createConsoleHandoff } from "./console-handoff.js";
|
|
30
34
|
/**
|
|
31
35
|
* Default hard timeout for the Console-owned LoopAgentClient.
|
|
32
36
|
*
|
|
@@ -76,6 +80,7 @@ export async function createConsoleServer(options) {
|
|
|
76
80
|
staticDir: inspectStaticDir,
|
|
77
81
|
});
|
|
78
82
|
const operatorSessionId = `sess_${randomBytes(16).toString("hex")}`;
|
|
83
|
+
const consoleInstanceId = options.consoleInstanceId ?? `console_${randomBytes(16).toString("hex")}`;
|
|
79
84
|
const appData = openConsoleAppData({
|
|
80
85
|
repoRoot,
|
|
81
86
|
appDataRoot: options.appDataRoot,
|
|
@@ -150,6 +155,7 @@ export async function createConsoleServer(options) {
|
|
|
150
155
|
refreshReadiness,
|
|
151
156
|
observeBaseUrl: options.observeBaseUrl,
|
|
152
157
|
fetchImpl: options.fetchImpl,
|
|
158
|
+
consoleUpdateExecutor: options.consoleUpdateExecutor,
|
|
153
159
|
getConsoleOrigin: () => `http://${boundHost}:${boundPort}`,
|
|
154
160
|
};
|
|
155
161
|
let boundHost = host;
|
|
@@ -165,6 +171,68 @@ export async function createConsoleServer(options) {
|
|
|
165
171
|
const chatEventEpoch = randomBytes(12).toString("hex");
|
|
166
172
|
const chatEvents = createChatEventStore({ appData, epoch: chatEventEpoch });
|
|
167
173
|
const chatTurnExecutions = createChatTurnExecutionRegistry();
|
|
174
|
+
const requestConsoleHandoff = async (targetVersion) => {
|
|
175
|
+
// The maintenance preflight proves this running Console was loaded from
|
|
176
|
+
// the global package. npm replaces that package in place, so resolve the
|
|
177
|
+
// replacement worker from that same package root rather than trusting the
|
|
178
|
+
// ambient PATH (which could point at another installation).
|
|
179
|
+
const packageRoot = resolvePackageRootFromConsole();
|
|
180
|
+
const agentWorkerBin = path.join(packageRoot, "bin", "agent-worker.js");
|
|
181
|
+
if (readPackageVersion(packageRoot) !== targetVersion ||
|
|
182
|
+
!existsSync(agentWorkerBin)) {
|
|
183
|
+
return {
|
|
184
|
+
ok: false,
|
|
185
|
+
message: "verified global package no longer contains the target Console worker",
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const { handoff, env } = createConsoleHandoff({
|
|
189
|
+
oldPid: process.pid,
|
|
190
|
+
repoRoot,
|
|
191
|
+
host: boundHost,
|
|
192
|
+
port: boundPort,
|
|
193
|
+
...(options.appDataRoot ? { appDataRoot: options.appDataRoot } : {}),
|
|
194
|
+
targetVersion,
|
|
195
|
+
});
|
|
196
|
+
try {
|
|
197
|
+
const child = spawn(process.execPath, [
|
|
198
|
+
agentWorkerBin,
|
|
199
|
+
"console",
|
|
200
|
+
"--repo",
|
|
201
|
+
repoRoot,
|
|
202
|
+
"--host",
|
|
203
|
+
boundHost,
|
|
204
|
+
"--port",
|
|
205
|
+
String(boundPort),
|
|
206
|
+
...(options.appDataRoot
|
|
207
|
+
? ["--app-data", options.appDataRoot]
|
|
208
|
+
: []),
|
|
209
|
+
"--no-open",
|
|
210
|
+
], { detached: true, stdio: "ignore", env: { ...process.env, ...env } });
|
|
211
|
+
await new Promise((resolve, reject) => {
|
|
212
|
+
child.once("spawn", resolve);
|
|
213
|
+
child.once("error", reject);
|
|
214
|
+
});
|
|
215
|
+
child.unref();
|
|
216
|
+
setTimeout(() => process.kill(process.pid, "SIGTERM"), 100).unref();
|
|
217
|
+
return { ok: true, consoleInstanceId: handoff.consoleInstanceId };
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
return {
|
|
221
|
+
ok: false,
|
|
222
|
+
message: error instanceof Error ? error.message : String(error),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
actionContext.consoleUpdateExecutor =
|
|
227
|
+
options.consoleUpdateExecutor ??
|
|
228
|
+
createConsoleUpdateExecutor({
|
|
229
|
+
repoRoot,
|
|
230
|
+
packageRoot: resolvePackageRootFromConsole(),
|
|
231
|
+
client,
|
|
232
|
+
operations,
|
|
233
|
+
activeChatTurnCount: () => chatTurnExecutions.size(),
|
|
234
|
+
requestHandoff: requestConsoleHandoff,
|
|
235
|
+
});
|
|
168
236
|
const chatOperationLinker = createChatOperationLinker({
|
|
169
237
|
chatEvents,
|
|
170
238
|
operations,
|
|
@@ -211,6 +279,7 @@ export async function createConsoleServer(options) {
|
|
|
211
279
|
ready: existsSync(path.join(inspectStaticDir, "index.html")),
|
|
212
280
|
routeCapabilities: deriveObserveRouteCapabilities(ROUTES),
|
|
213
281
|
},
|
|
282
|
+
consoleInstanceId,
|
|
214
283
|
operator: {
|
|
215
284
|
actionContext,
|
|
216
285
|
operations,
|
|
@@ -294,11 +363,10 @@ export async function createConsoleServer(options) {
|
|
|
294
363
|
}
|
|
295
364
|
}
|
|
296
365
|
if (pathname.startsWith("/inspect")) {
|
|
297
|
-
//
|
|
298
|
-
//
|
|
366
|
+
// Prompt-override rerun is enabled by default. Unless the emergency
|
|
367
|
+
// kill switch disables it, hand the inspect page SCOPED mutation
|
|
299
368
|
// credentials (separate cookie + token, only strong enough for
|
|
300
|
-
// INSPECT_MUTATION_ALLOWED_ACTIONS — see routes.ts).
|
|
301
|
-
// strictly read-only: no token, no cookie, no tab.
|
|
369
|
+
// INSPECT_MUTATION_ALLOWED_ACTIONS — see routes.ts).
|
|
302
370
|
const htmlEnhancer = isDagRerunPromptOverrideEnabled()
|
|
303
371
|
? (html) => ({
|
|
304
372
|
content: injectConfirmationTokenScript(html, routeContext.inspectBootToken?.confirmationToken ??
|
|
@@ -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-BhrPXXMZ.js";import{p as f}from"./chunk-JWPE2WC7-VVthn_mD.js";import{_ as n,l as o}from"./mermaid.core-Biyo-tqA.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-wh5N2ReN.js";import"./index-CW88Fjbw.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-Biyo-tqA.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};
|