@tea-agent/loop-agent 0.51.0 → 0.52.0-next.10
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 +123 -5
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +1 -75
- package/dist/cli/help.js +1 -1
- package/dist/cli/program.js +1 -28
- package/dist/commands/init-accepted-merge.js +46 -0
- package/dist/commands/init-upgrade.js +115 -2
- package/dist/commands/init.js +79 -12
- package/dist/executors/pi-sdk-executor.js +3 -3
- package/dist/governance/path-guard.js +2 -0
- package/dist/records/harvest.js +1 -1
- package/dist/shared/git-progress.js +3 -0
- package/dist/shared/operator/capabilities.js +0 -122
- package/dist/shared/pi-context-pressure/checkpoint.js +94 -24
- package/dist/shared/pi-context-pressure/compaction-policy.js +152 -66
- package/dist/shared/pi-context-pressure/extension.js +25 -8
- package/dist/shared/pi-context-pressure/index.js +1 -1
- package/dist/shared/pi-context-pressure/telemetry.js +10 -0
- package/dist/shared/update/npm-client.js +14 -3
- package/dist/task/config-types.js +5 -10
- package/dist/task/delegate.js +1 -1
- package/dist/task/read-model.js +0 -4
- package/dist/task/runtime.js +0 -1
- package/dist/task/worktree.js +1 -1
- package/dist/worker/console/chat/api-workbench-core.js +17 -6
- package/dist/worker/console/chat/api-workbench.js +2 -0
- package/dist/worker/console/chat/assistant-content.js +21 -3
- package/dist/worker/console/chat/chat-event-projection.js +6 -0
- package/dist/worker/console/chat/chat-event-store.js +32 -2
- package/dist/worker/console/chat/chat-references.js +4 -0
- package/dist/worker/console/chat/compaction-errors.js +14 -2
- package/dist/worker/console/chat/context-insights.js +41 -4
- package/dist/worker/console/chat/context-usage.js +4 -1
- package/dist/worker/console/chat/pi-runtime/custom-tools/apiworkbench-tools.js +65 -3
- package/dist/worker/console/chat/pi-runtime/custom-tools/browser-tools.js +2 -2
- package/dist/worker/console/chat/pi-runtime/extension-bindings.js +39 -0
- package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +4 -0
- package/dist/worker/console/chat/pi-runtime.js +389 -191
- package/dist/worker/console/chat/repo-browser.js +5 -2
- package/dist/worker/console/chat/repo-preview-kind.js +16 -6
- package/dist/worker/console/chat/routes.js +299 -25
- package/dist/worker/console/chat/scheduled-goal-request.js +1 -1
- package/dist/worker/console/chat/subagents/jobs.js +115 -4
- package/dist/worker/console/chat/terminal-sessions.js +52 -6
- package/dist/worker/console/chat/tool-exposure-catalog.js +1 -1
- package/dist/worker/console/chat/tool-presentation.js +17 -10
- package/dist/worker/console/chat/tool-preview.js +22 -0
- package/dist/worker/console/chat/turn-process.js +49 -0
- package/dist/worker/console/chat/vcp-prompt.js +14 -9
- package/dist/worker/console/chat/workspace-changes.js +17 -0
- package/dist/worker/console/console-update-runtime.js +5 -1
- package/dist/worker/console/operator-actions.js +7 -6
- package/dist/worker/console/operator-user-error.js +5 -1
- package/dist/worker/console/pi-compaction-settings.js +220 -0
- package/dist/worker/console/routes.js +1 -1
- package/dist/worker/console/server.js +148 -6
- package/dist/worker/console/static/assets/FilePreviewDocx-ybM3ZqSl.js +9 -0
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-CT26sIgH.js +1 -0
- package/dist/worker/console/static/assets/{arc-Bkf_oc0_.js → arc-CPwLqDB0.js} +1 -1
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-CzTSMPU_.js +36 -0
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-D62uVvbI.js → blockDiagram-VBNYF7ZC-BfgbtJLH.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-Iq0Y8Afx.js → c4Diagram-5PPSVZJV-B9pTjB8U.js} +1 -1
- package/dist/worker/console/static/assets/channel-DtYRMDck.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-D1TxRE3k.js → chunk-2GRJ4B5K-xORV8QsC.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-BE-DHkAO.js → chunk-2Q5K7J3B-BzpYWAHK.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-t0iYO8Cc.js → chunk-5RXB4S5H-D8zcRP6c.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-Clo2nExi.js → chunk-5VM5RSS4-DVEXxzQJ.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-C7bSpo-3.js → chunk-6Q2QTUOP-CKZOJU2z.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-DorZaymh.js → chunk-GF5L2VYU-Cgx34Dj8.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-Ch_4HvyJ.js → chunk-JWPE2WC7-ehcSKOcx.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-yaSoFe-3.js → chunk-KBJHAD2P-CiY9emCG.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-QpjaXecS.js → chunk-RYQCIY6F-Bk9X-ksQ.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-B3t6cycg.js → chunk-XXDRQBXY-DC0xXfHy.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-DyesHbs5.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-DyesHbs5.js +1 -0
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-C_EVg5l9.js +1 -0
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CP8LtrOl.js → cynefin-VYW2F7L2-BIFL8KrA.js} +1 -1
- package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-DjtUYOlE.js +62 -0
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BK0ua9V8.js → dagre-VZM6K2ZE-D2aN2V9t.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-t9-HP13j.js → diagram-7IWD3JNH-D_twhmFi.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-L5Sg9jMD.js → diagram-B4RE2ZJO-ChzncqLV.js} +1 -1
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-B6LO-bF2.js +24 -0
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-GrzM7AFc.js +24 -0
- package/dist/worker/console/static/assets/diagram-UB23O5K3-Bv-lntaq.js +41 -0
- package/dist/worker/console/static/assets/docx-preview-CAbT0VNs.js +23 -0
- package/dist/worker/console/static/assets/docxPreview-D_T4B7qe.js +1 -0
- package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-BvD2jkO_.js +1 -0
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-CNOuj3BO.js → erDiagram-JOGREHBK-BirPCcmA.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-h_Cyayai.js → flowDiagram-UKHOOZJN-Chu1YnGQ.js} +1 -1
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-Djn17xhB.js +292 -0
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-Bx1qbGHx.js +106 -0
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-D-TLMqmb.js +2 -0
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DAdf5lHp.js → ishikawaDiagram-WSZJBQD7-DbJoh-6T.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-BQbGtg66.js → journeyDiagram-NVQOT4AX-DsyokZ6e.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-CetLubYc.js → kanban-definition-27J2QSJJ-DlzXTxic.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DLZOjaVz.js → linear-ClnZn3vw.js} +1 -1
- package/dist/worker/console/static/assets/main-D-ZQ4gLb.css +1 -0
- package/dist/worker/console/static/assets/main-fc3P1HID.js +645 -0
- package/dist/worker/console/static/assets/{mermaid.core-B_xZl_gM.js → mermaid.core-DqSlcvbf.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Dzo3dzp0.js → mindmap-definition-FAOFIHXS-CSFbzpiX.js} +1 -1
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-DK80yQqe.js +1 -0
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-Cp3YrVzQ.js → pieDiagram-7S7Q4E2Y-DWX7SFGb.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-4tI5mUgW.js → quadrantDiagram-CIZ2JOQS-BEPPhtXs.js} +1 -1
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-Ck_s6fQn.js +1 -0
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-DY-0JqdT.js → requirementDiagram-LRYGKXZP-CYig27Rj.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-DuJIzRKC.js → sankeyDiagram-W5VNT64P-u-0aSx5s.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-BTbVJ85l.js → sequenceDiagram-SI44F4Z6-NsEJI9sM.js} +1 -1
- package/dist/worker/console/static/assets/{sheet-workbook-BPPh1uLw.js → sheet-workbook-kZ_HK4Sg.js} +2 -2
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-8vneVM5U.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-CMIobUBh.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Bd0pHHKP.js +1 -0
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-D4Qzt6ug.js +2 -0
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-BzmSZnl_.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-GR6lxokn.js → timeline-definition-Z64GVDOM-DMb1LpED.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-DEkwyzsF.js → vennDiagram-T6HMQDX7-C_9eFOs3.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-W5jnvEJ3.js → wardleyDiagram-T6FBY63Y-DJYMe3uT.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-cqsloioo.js → xychartDiagram-ELKLHX3M-Cv_1Mi3u.js} +1 -1
- package/dist/worker/console/static/docx-preview.html +25 -0
- package/dist/worker/console/static/index.html +3 -2
- package/dist/worker/console/static/vcp/fonts/README.md +28 -0
- package/dist/worker/console/static/vcp/vendor/vcp-engine-v1.js +4 -4
- package/dist/worker/console/static-src/operator-chat/StateDot.js +17 -0
- package/dist/worker/console/static-src/operator-chat/changed-file-diff.js +15 -0
- 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/dist/worker/console/static-src/operator-chat/chat-sse-events.js +8 -1
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +4 -0
- package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +2 -0
- package/dist/worker/console/static-src/operator-chat/file-touch.js +107 -0
- package/dist/worker/console/static-src/operator-chat/format-file-size.js +26 -0
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +44 -0
- package/dist/worker/console/static-src/operator-chat/reference-display.js +7 -1
- package/dist/worker/console/static-src/operator-chat/tasks-auto-open.js +100 -0
- package/dist/worker/console/static-src/operator-chat/tasks-layout-tween.js +103 -0
- package/dist/worker/console/static-src/operator-chat/tasks-model.js +657 -0
- package/dist/worker/console/static-src/operator-chat/tasks-view-glide.js +96 -0
- package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +1 -0
- package/dist/worker/console/static-src/operator-chat/use-auto-animate.js +61 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +194 -47
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +4 -0
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +18 -0
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +111 -21
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +91 -47
- package/dist/worker/console/static-src/operator-chat/useVcpPreferences.js +1 -1
- package/dist/worker/console/static-src/operator-chat/user-turn-anchors-merge.js +50 -0
- package/dist/worker/console/static-src/operator-chat/vcp-fonts.js +180 -22
- package/dist/worker/console/static-src/operator-chat/vcp-frame.js +3 -3
- package/dist/worker/console/static-src/shell/console-update-progress.js +16 -0
- package/dist/worker/console/static-src/shell/console-update-reload.js +4 -1
- package/dist/worker/console/static-src/shell/workspace-route.js +0 -2
- package/dist/worker/console/vite.config.js +5 -1
- package/dist/worker/console/workspace-registry.js +62 -19
- package/dist/worker/observe/static/operator-chrome.js +0 -1
- package/dist/worker/scheduler/git-base.js +3 -0
- package/dist/worker/scheduler/night-git-finalizer.js +1 -1
- package/dist/worker/scheduler/night-harvest.js +1 -1
- package/dist/worker/scheduler/prepared-attempt-recovery.js +1 -1
- package/dist/worker/scheduler/scheduled-goal-evidence.js +1 -1
- package/dist/workflows/dag/backend-test-scenario-param.js +60 -4
- package/dist/workflows/dag/dynamic-runtime/reduction.js +7 -2
- package/dist/workflows/dag/frontend-test-framework-adapters.js +11 -2
- package/dist/workflows/script/windows/guest.js +13 -2
- package/dist/workflows/script/windows/native.js +21 -3
- package/docs/architecture/dag-execution.md +2 -13
- package/docs/architecture/facts-and-state.md +2 -3
- package/docs/architecture/runtime-boundaries.md +2 -2
- package/package.json +9 -7
- package/resource-catalog.v1.json +6 -6
- package/scripts/patch-pi-sdk-windows-hide.mjs +3 -3
- package/skills/loop-agent/references/command-reference.md +2 -41
- package/skills/loop-agent/references/harness-policy.md +3 -30
- package/skills/loop-agent/references/long-running-loop.md +6 -54
- package/dist/application/loop/run-action.js +0 -19
- package/dist/commands/dag-workflow-compile.js +0 -93
- package/dist/commands/dag-workflow-plan.js +0 -132
- package/dist/commands/dag-workflow-validate.js +0 -68
- package/dist/commands/loop-benchmark.js +0 -74
- package/dist/commands/loop.js +0 -251
- package/dist/commands/workflow.js +0 -259
- package/dist/infrastructure/harness/loop-store.js +0 -41
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-FQePHM07.js +0 -1
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-p_mwm8cd.js +0 -36
- package/dist/worker/console/static/assets/channel-CIBAg8WF.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-B4xQrSmv.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-B4xQrSmv.js +0 -1
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-BPXf8ZYr.js +0 -1
- package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-CNsL9N2-.js +0 -62
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-BipWFRgs.js +0 -24
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-T2p4xa38.js +0 -24
- package/dist/worker/console/static/assets/diagram-UB23O5K3-CVwz6LVu.js +0 -41
- package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-CybQrGSA.js +0 -1
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-D411_55h.js +0 -292
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-DpVtzs9z.js +0 -106
- package/dist/worker/console/static/assets/index-B7cwOTL9.js +0 -649
- package/dist/worker/console/static/assets/index-CATbSkPc.css +0 -1
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-D74Uvx6K.js +0 -2
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-CSwoBOpM.js +0 -1
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-n0Mt3Yia.js +0 -1
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-Dmf1pC7B.js +0 -1
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-4-jdPUHD.js +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DojWfYnC.js +0 -1
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-DNhjjaAU.js +0 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CJo4AKWH.js +0 -8
- package/dist/worker/console/static/vcp/fonts/Lanxi-/345/217/257/345/256/213.woff2 +0 -0
- package/dist/worker/console/static/vcp/fonts/Lanxi-/346/234/227/345/256/213.woff2 +0 -0
- package/dist/worker/console/static/vcp/fonts/Lanxi-/350/266/205/347/262/227/351/273/221.woff2 +0 -0
- package/dist/workflows/dynamic/compile.js +0 -371
- package/dist/workflows/dynamic/compileTypes.js +0 -1
- package/dist/workflows/dynamic/errors.js +0 -5
- package/dist/workflows/dynamic/profiles.js +0 -156
- package/dist/workflows/dynamic/spec.js +0 -115
- package/dist/workflows/dynamic/validate.js +0 -275
- package/dist/workflows/loop/actions/dag-action.js +0 -129
- package/dist/workflows/loop/actions/pi-review.js +0 -267
- package/dist/workflows/loop/actions/shared.js +0 -157
- package/dist/workflows/loop/actions/shell-verify.js +0 -82
- package/dist/workflows/loop/actions/types.js +0 -1
- package/dist/workflows/loop/actions/workflow-action.js +0 -255
- package/dist/workflows/loop/actions.js +0 -160
- package/dist/workflows/loop/benchmark.js +0 -513
- package/dist/workflows/loop/closeout.js +0 -135
- package/dist/workflows/loop/context.js +0 -47
- package/dist/workflows/loop/events.js +0 -26
- package/dist/workflows/loop/hash.js +0 -32
- package/dist/workflows/loop/index.js +0 -8
- package/dist/workflows/loop/paths.js +0 -17
- package/dist/workflows/loop/policy/auto-policy.js +0 -112
- package/dist/workflows/loop/policy/path-patterns.js +0 -13
- package/dist/workflows/loop/rounds.js +0 -81
- package/dist/workflows/loop/signals.js +0 -52
- package/dist/workflows/loop/state.js +0 -116
- package/dist/workflows/loop/templates.js +0 -54
- package/dist/workflows/loop/types.js +0 -28
- /package/dist/workflows/{dynamic/artifacts.js → dag/dynamic-runtime/reduction-artifacts.js} +0 -0
|
@@ -1,371 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { parseDagSpec } from "../dag/types.js";
|
|
3
|
-
import { assertValidWorkflowSpec } from "./validate.js";
|
|
4
|
-
import { workflowNodeSchema, } from "./spec.js";
|
|
5
|
-
const READ_ONLY_FORBIDDEN_PATHS = ["artifacts/**", ".harness/**"];
|
|
6
|
-
export function defaultCompileManifestPath(outputPath) {
|
|
7
|
-
const parsed = path.parse(outputPath);
|
|
8
|
-
const base = parsed.base.endsWith(".dag.json")
|
|
9
|
-
? parsed.base.slice(0, -".dag.json".length)
|
|
10
|
-
: parsed.name;
|
|
11
|
-
return path.join(parsed.dir, `${base}.compile-manifest.json`);
|
|
12
|
-
}
|
|
13
|
-
function stringifyOutputSchema(outputSchema) {
|
|
14
|
-
if (outputSchema === undefined)
|
|
15
|
-
return undefined;
|
|
16
|
-
return `Workflow outputSchema:\n${JSON.stringify(outputSchema, null, 2)}`;
|
|
17
|
-
}
|
|
18
|
-
function compileTemplate(value, inputs) {
|
|
19
|
-
return value.replace(/\{\{\s*inputs\.([A-Za-z0-9_-]+)\s*\}\}/g, (_match, key) => {
|
|
20
|
-
const replacement = inputs[key];
|
|
21
|
-
if (typeof replacement === "string" ||
|
|
22
|
-
typeof replacement === "number" ||
|
|
23
|
-
typeof replacement === "boolean") {
|
|
24
|
-
return String(replacement);
|
|
25
|
-
}
|
|
26
|
-
return "";
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function dagRoleForNode(node) {
|
|
30
|
-
if (node.type === "reduce_agent")
|
|
31
|
-
return "closeout";
|
|
32
|
-
if (node.type === "verify_agent")
|
|
33
|
-
return "verifier";
|
|
34
|
-
if (node.type === "human_gate")
|
|
35
|
-
return "supervisor";
|
|
36
|
-
if (node.type === "agent" || node.type === "map_agent")
|
|
37
|
-
return "reviewer";
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
function executorForAgentLikeNode(node) {
|
|
41
|
-
return node.executor ?? "pi";
|
|
42
|
-
}
|
|
43
|
-
function nodeSkillsField(node) {
|
|
44
|
-
return node.skills && node.skills.length > 0 ? { skills: node.skills } : {};
|
|
45
|
-
}
|
|
46
|
-
function dagWriteFields(spec, node) {
|
|
47
|
-
if (node?.writePolicy === "none") {
|
|
48
|
-
return {
|
|
49
|
-
writePolicy: "none",
|
|
50
|
-
allowedPaths: [],
|
|
51
|
-
forbiddenPaths: [],
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
if (node?.writePolicy === "read-only") {
|
|
55
|
-
return {
|
|
56
|
-
writePolicy: "read-only",
|
|
57
|
-
allowedPaths: [],
|
|
58
|
-
forbiddenPaths: READ_ONLY_FORBIDDEN_PATHS,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (spec.permissions.edits === "deny") {
|
|
62
|
-
return {
|
|
63
|
-
writePolicy: "read-only",
|
|
64
|
-
allowedPaths: [],
|
|
65
|
-
forbiddenPaths: READ_ONLY_FORBIDDEN_PATHS,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
writePolicy: "exclusive",
|
|
70
|
-
allowedPaths: spec.permissions.allowedPaths ?? [],
|
|
71
|
-
forbiddenPaths: spec.permissions.forbiddenPaths ?? [],
|
|
72
|
-
writeSet: spec.permissions.writeSet ?? [],
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
function buildAgentPrompt(node) {
|
|
76
|
-
const role = node.role ? `Workflow role: ${node.role}\n` : "";
|
|
77
|
-
const prompt = node.prompt ?? `Execute workflow node ${node.id}.`;
|
|
78
|
-
return [
|
|
79
|
-
`Workflow node: ${node.id}`,
|
|
80
|
-
`Workflow primitive: ${node.type}`,
|
|
81
|
-
role.trim(),
|
|
82
|
-
prompt,
|
|
83
|
-
]
|
|
84
|
-
.filter(Boolean)
|
|
85
|
-
.join("\n\n");
|
|
86
|
-
}
|
|
87
|
-
function compileCommandNode(spec, node) {
|
|
88
|
-
const command = node.command ?? "";
|
|
89
|
-
return {
|
|
90
|
-
id: node.id,
|
|
91
|
-
depends_on: node.dependsOn,
|
|
92
|
-
complexity: "LOW",
|
|
93
|
-
subtask_prompt: `Run workflow command node ${node.id}.`,
|
|
94
|
-
executor: "shell",
|
|
95
|
-
writePolicy: "none",
|
|
96
|
-
allowedPaths: [],
|
|
97
|
-
forbiddenPaths: [],
|
|
98
|
-
shell: {
|
|
99
|
-
commands: [compileTemplate(command, spec.inputs)],
|
|
100
|
-
},
|
|
101
|
-
outputContract: stringifyOutputSchema(node.outputSchema),
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function compileHumanGateNode(spec, node) {
|
|
105
|
-
return {
|
|
106
|
-
id: node.id,
|
|
107
|
-
depends_on: node.dependsOn,
|
|
108
|
-
complexity: "LOW",
|
|
109
|
-
subtask_prompt: [
|
|
110
|
-
`Workflow human gate: ${node.id}`,
|
|
111
|
-
node.reason ?? "Review upstream workflow outputs and decide whether execution may continue.",
|
|
112
|
-
"Return a decision envelope. Set requiresHuman=true when explicit approval is needed.",
|
|
113
|
-
].join("\n\n"),
|
|
114
|
-
executor: "pi",
|
|
115
|
-
role: "supervisor",
|
|
116
|
-
...dagWriteFields(spec, node),
|
|
117
|
-
...nodeSkillsField(node),
|
|
118
|
-
decisionGate: { enabled: true, mode: "pause-on-human" },
|
|
119
|
-
outputContract: node.approvalSchema
|
|
120
|
-
? `Workflow approvalSchema:\n${JSON.stringify(node.approvalSchema, null, 2)}`
|
|
121
|
-
: undefined,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function compileArtifactTransformNode(node) {
|
|
125
|
-
return {
|
|
126
|
-
id: node.id,
|
|
127
|
-
depends_on: node.dependsOn,
|
|
128
|
-
complexity: "LOW",
|
|
129
|
-
subtask_prompt: `Apply deterministic artifact transform ${node.id}.`,
|
|
130
|
-
executor: "static",
|
|
131
|
-
writePolicy: "none",
|
|
132
|
-
allowedPaths: [],
|
|
133
|
-
forbiddenPaths: [],
|
|
134
|
-
static: {
|
|
135
|
-
resultMarkdown: node.transform?.template ?? "artifact transform completed",
|
|
136
|
-
},
|
|
137
|
-
outputContract: stringifyOutputSchema(node.outputSchema),
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function compileConditionNode(node) {
|
|
141
|
-
return {
|
|
142
|
-
id: node.id,
|
|
143
|
-
depends_on: node.dependsOn,
|
|
144
|
-
complexity: "LOW",
|
|
145
|
-
subtask_prompt: `Evaluate workflow condition ${node.id}.`,
|
|
146
|
-
executor: "static",
|
|
147
|
-
writePolicy: "none",
|
|
148
|
-
allowedPaths: [],
|
|
149
|
-
forbiddenPaths: [],
|
|
150
|
-
static: {
|
|
151
|
-
resultMarkdown: `Dynamic condition barrier for ${node.id}.`,
|
|
152
|
-
},
|
|
153
|
-
outputContract: stringifyOutputSchema(node.outputSchema),
|
|
154
|
-
dynamicCondition: {
|
|
155
|
-
workflowNodeId: node.id,
|
|
156
|
-
cases: node.cases ?? [],
|
|
157
|
-
default: node.default,
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
function stopWhenAnyExpressions(stopWhen) {
|
|
162
|
-
if (typeof stopWhen === "string")
|
|
163
|
-
return [stopWhen];
|
|
164
|
-
if (stopWhen && typeof stopWhen === "object") {
|
|
165
|
-
const any = stopWhen.any;
|
|
166
|
-
if (Array.isArray(any)) {
|
|
167
|
-
return any.filter((entry) => typeof entry === "string");
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return [];
|
|
171
|
-
}
|
|
172
|
-
function compileLoopBodyTask(spec, node) {
|
|
173
|
-
const executor = executorForAgentLikeNode(node);
|
|
174
|
-
return {
|
|
175
|
-
id: node.id,
|
|
176
|
-
dependsOn: node.dependsOn,
|
|
177
|
-
executor,
|
|
178
|
-
role: dagRoleForNode(node),
|
|
179
|
-
...nodeSkillsField(node),
|
|
180
|
-
complexity: node.type === "reduce_agent" ? "MED" : "LOW",
|
|
181
|
-
subtaskPromptTemplate: buildAgentPrompt(node),
|
|
182
|
-
staticResultTemplate: node.staticResultTemplate ?? node.transform?.template ?? undefined,
|
|
183
|
-
outputContract: stringifyOutputSchema(node.outputSchema),
|
|
184
|
-
...dagWriteFields(spec, node),
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
function compileLoopUntilNode(spec, node) {
|
|
188
|
-
const bodyTasks = (node.body ?? []).map((entry) => compileLoopBodyTask(spec, workflowNodeSchema.parse(entry)));
|
|
189
|
-
return {
|
|
190
|
-
id: node.id,
|
|
191
|
-
depends_on: node.dependsOn,
|
|
192
|
-
complexity: "MED",
|
|
193
|
-
subtask_prompt: buildAgentPrompt(node),
|
|
194
|
-
executor: "static",
|
|
195
|
-
role: dagRoleForNode(node),
|
|
196
|
-
...dagWriteFields(spec, node),
|
|
197
|
-
...nodeSkillsField(node),
|
|
198
|
-
static: {
|
|
199
|
-
resultMarkdown: `Dynamic loop_until barrier for ${node.id}.`,
|
|
200
|
-
},
|
|
201
|
-
outputContract: stringifyOutputSchema(node.outputSchema),
|
|
202
|
-
dynamicLoopUntil: {
|
|
203
|
-
workflowNodeId: node.id,
|
|
204
|
-
maxIterations: node.maxIterations ?? spec.limits.maxIterations,
|
|
205
|
-
stopWhenAny: stopWhenAnyExpressions(node.stopWhen),
|
|
206
|
-
bodyTasks,
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
function compileAgentLikeNode(spec, node) {
|
|
211
|
-
const executor = executorForAgentLikeNode(node);
|
|
212
|
-
if (executor === "static") {
|
|
213
|
-
return {
|
|
214
|
-
id: node.id,
|
|
215
|
-
depends_on: node.dependsOn,
|
|
216
|
-
complexity: node.type === "reduce_agent" ? "MED" : "LOW",
|
|
217
|
-
subtask_prompt: buildAgentPrompt(node),
|
|
218
|
-
executor: "static",
|
|
219
|
-
role: dagRoleForNode(node),
|
|
220
|
-
...dagWriteFields(spec, node),
|
|
221
|
-
...nodeSkillsField(node),
|
|
222
|
-
static: {
|
|
223
|
-
resultMarkdown: node.staticResultTemplate ?? `Workflow node ${node.id} completed.`,
|
|
224
|
-
},
|
|
225
|
-
outputContract: stringifyOutputSchema(node.outputSchema),
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
return {
|
|
229
|
-
id: node.id,
|
|
230
|
-
depends_on: node.dependsOn,
|
|
231
|
-
complexity: node.type === "reduce_agent" ? "MED" : "LOW",
|
|
232
|
-
subtask_prompt: buildAgentPrompt(node),
|
|
233
|
-
executor: "pi",
|
|
234
|
-
role: dagRoleForNode(node),
|
|
235
|
-
...dagWriteFields(spec, node),
|
|
236
|
-
...nodeSkillsField(node),
|
|
237
|
-
outputContract: stringifyOutputSchema(node.outputSchema),
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
function compileNode(spec, node) {
|
|
241
|
-
if (node.type === "command")
|
|
242
|
-
return compileCommandNode(spec, node);
|
|
243
|
-
if (node.type === "human_gate")
|
|
244
|
-
return compileHumanGateNode(spec, node);
|
|
245
|
-
if (node.type === "artifact_transform")
|
|
246
|
-
return compileArtifactTransformNode(node);
|
|
247
|
-
if (node.type === "condition")
|
|
248
|
-
return compileConditionNode(node);
|
|
249
|
-
if (node.type === "loop_until")
|
|
250
|
-
return compileLoopUntilNode(spec, node);
|
|
251
|
-
if (node.type === "map_agent" || node.type === "verify_agent") {
|
|
252
|
-
return compileDynamicExpansionNode(spec, node);
|
|
253
|
-
}
|
|
254
|
-
if (node.type === "reduce_agent" && node.reducer) {
|
|
255
|
-
return compileDynamicReductionNode(spec, node);
|
|
256
|
-
}
|
|
257
|
-
return compileAgentLikeNode(spec, node);
|
|
258
|
-
}
|
|
259
|
-
function compileDynamicExpansionNode(spec, node) {
|
|
260
|
-
if (node.type !== "map_agent" && node.type !== "verify_agent") {
|
|
261
|
-
throw new Error(`unsupported dynamic expansion node type: ${node.type}`);
|
|
262
|
-
}
|
|
263
|
-
const expansionType = node.type;
|
|
264
|
-
const childExecutor = executorForAgentLikeNode(node);
|
|
265
|
-
const childPrompt = buildAgentPrompt(node);
|
|
266
|
-
const childTask = {
|
|
267
|
-
executor: childExecutor,
|
|
268
|
-
role: dagRoleForNode(node),
|
|
269
|
-
...nodeSkillsField(node),
|
|
270
|
-
complexity: "LOW",
|
|
271
|
-
subtaskPromptTemplate: childPrompt,
|
|
272
|
-
staticResultTemplate: node.staticResultTemplate,
|
|
273
|
-
outputContract: stringifyOutputSchema(node.outputSchema),
|
|
274
|
-
...dagWriteFields(spec, node),
|
|
275
|
-
};
|
|
276
|
-
return {
|
|
277
|
-
id: node.id,
|
|
278
|
-
depends_on: node.dependsOn,
|
|
279
|
-
complexity: "LOW",
|
|
280
|
-
subtask_prompt: `Expand workflow map_agent node ${node.id}.`,
|
|
281
|
-
executor: "static",
|
|
282
|
-
writePolicy: "none",
|
|
283
|
-
allowedPaths: [],
|
|
284
|
-
forbiddenPaths: [],
|
|
285
|
-
...nodeSkillsField(node),
|
|
286
|
-
static: {
|
|
287
|
-
resultMarkdown: `Dynamic ${node.type} expansion barrier for ${node.id}.`,
|
|
288
|
-
},
|
|
289
|
-
outputContract: stringifyOutputSchema(node.outputSchema),
|
|
290
|
-
dynamicExpansion: {
|
|
291
|
-
type: expansionType,
|
|
292
|
-
workflowNodeId: node.id,
|
|
293
|
-
itemsFrom: node.itemsFrom ?? "",
|
|
294
|
-
itemName: node.itemName ?? "item",
|
|
295
|
-
maxItems: node.maxItems ?? spec.limits.maxExpandedNodes,
|
|
296
|
-
maxExpandedNodes: spec.limits.maxExpandedNodes,
|
|
297
|
-
workspaceTemplate: node.workspaceTemplate,
|
|
298
|
-
childIdPrefix: node.id,
|
|
299
|
-
childTask,
|
|
300
|
-
},
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
function compileDynamicReductionNode(spec, node) {
|
|
304
|
-
return {
|
|
305
|
-
id: node.id,
|
|
306
|
-
depends_on: node.dependsOn,
|
|
307
|
-
complexity: "MED",
|
|
308
|
-
subtask_prompt: buildAgentPrompt(node),
|
|
309
|
-
executor: "static",
|
|
310
|
-
role: dagRoleForNode(node),
|
|
311
|
-
...dagWriteFields(spec, node),
|
|
312
|
-
...nodeSkillsField(node),
|
|
313
|
-
static: {
|
|
314
|
-
resultMarkdown: `Dynamic reducer ${node.reducer?.type ?? "unknown"} for ${node.id}.`,
|
|
315
|
-
},
|
|
316
|
-
outputContract: stringifyOutputSchema(node.outputSchema),
|
|
317
|
-
dynamicReduction: node.reducer
|
|
318
|
-
? {
|
|
319
|
-
type: node.reducer.type,
|
|
320
|
-
workflowNodeId: node.id,
|
|
321
|
-
findingsFrom: node.reducer.findingsFrom,
|
|
322
|
-
verificationsFrom: node.reducer.verificationsFrom,
|
|
323
|
-
refutedFindingsArtifactName: "refuted-findings.json",
|
|
324
|
-
}
|
|
325
|
-
: undefined,
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
export function compileWorkflowToDag(spec, options = {}) {
|
|
329
|
-
assertValidWorkflowSpec(spec);
|
|
330
|
-
const tasks = spec.nodes.map((node) => compileNode(spec, node));
|
|
331
|
-
const dag = parseDagSpec({
|
|
332
|
-
version: 2,
|
|
333
|
-
title: `Workflow: ${spec.meta.name}`,
|
|
334
|
-
objective: spec.meta.description,
|
|
335
|
-
successCriteria: [`Workflow final node completed: ${spec.final.from}`],
|
|
336
|
-
globalConstraints: [
|
|
337
|
-
"Compiled from Dynamic Workflow DAG Engine WorkflowSpec.",
|
|
338
|
-
"Workflow origin is recorded in the sidecar compile manifest.",
|
|
339
|
-
],
|
|
340
|
-
tasks,
|
|
341
|
-
});
|
|
342
|
-
const manifest = {
|
|
343
|
-
version: 1,
|
|
344
|
-
workflow: {
|
|
345
|
-
name: spec.meta.name,
|
|
346
|
-
version: spec.version,
|
|
347
|
-
kind: spec.kind,
|
|
348
|
-
sourcePath: options.sourcePath,
|
|
349
|
-
final: spec.final.from,
|
|
350
|
-
},
|
|
351
|
-
limits: spec.limits,
|
|
352
|
-
permissions: spec.permissions,
|
|
353
|
-
nodes: Object.fromEntries(spec.nodes.map((node) => [
|
|
354
|
-
node.id,
|
|
355
|
-
{
|
|
356
|
-
workflowNodeId: node.id,
|
|
357
|
-
workflowNodeType: node.type,
|
|
358
|
-
dagTaskIds: [node.id],
|
|
359
|
-
commandAllowlist: node.type === "command" ? spec.permissions.shell.commands : undefined,
|
|
360
|
-
outputSchema: node.outputSchema,
|
|
361
|
-
dynamic: node.type === "map_agent" ||
|
|
362
|
-
node.type === "verify_agent" ||
|
|
363
|
-
node.type === "condition" ||
|
|
364
|
-
node.type === "loop_until"
|
|
365
|
-
? true
|
|
366
|
-
: undefined,
|
|
367
|
-
},
|
|
368
|
-
])),
|
|
369
|
-
};
|
|
370
|
-
return { dag, manifest };
|
|
371
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
export const WORKFLOW_PLAN_PROFILES = [
|
|
2
|
-
"pr-review",
|
|
3
|
-
];
|
|
4
|
-
function buildDiscoverFilesOutput(files) {
|
|
5
|
-
return JSON.stringify({
|
|
6
|
-
files: files.map((file, index) => ({
|
|
7
|
-
path: file,
|
|
8
|
-
findingId: `finding-${index + 1}`,
|
|
9
|
-
expectedStatus: "verified",
|
|
10
|
-
expectedReason: `review finding for ${file} is present in the mapped artifact`,
|
|
11
|
-
})),
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
export function buildPrReviewWorkflowSpec(options) {
|
|
15
|
-
const base = options.base ?? "main";
|
|
16
|
-
const head = options.head ?? "HEAD";
|
|
17
|
-
const files = options.changedFiles && options.changedFiles.length > 0
|
|
18
|
-
? options.changedFiles
|
|
19
|
-
: ["README.md"];
|
|
20
|
-
return {
|
|
21
|
-
version: "0.1",
|
|
22
|
-
kind: "dynamic-agent-workflow",
|
|
23
|
-
meta: {
|
|
24
|
-
name: "pr-review",
|
|
25
|
-
description: `Read-only PR review workflow for task ${options.taskId}.`,
|
|
26
|
-
riskLevel: "low",
|
|
27
|
-
},
|
|
28
|
-
inputs: {
|
|
29
|
-
taskId: options.taskId,
|
|
30
|
-
base,
|
|
31
|
-
head,
|
|
32
|
-
},
|
|
33
|
-
limits: {
|
|
34
|
-
maxConcurrency: 4,
|
|
35
|
-
maxAgentRuns: 50,
|
|
36
|
-
maxExpandedNodes: 50,
|
|
37
|
-
maxRetriesPerNode: 0,
|
|
38
|
-
maxIterations: 3,
|
|
39
|
-
maxWallClockMinutes: 15,
|
|
40
|
-
},
|
|
41
|
-
permissions: {
|
|
42
|
-
filesystem: "read_only",
|
|
43
|
-
shell: {
|
|
44
|
-
mode: "deny",
|
|
45
|
-
commands: [],
|
|
46
|
-
},
|
|
47
|
-
network: "deny",
|
|
48
|
-
edits: "deny",
|
|
49
|
-
},
|
|
50
|
-
nodes: [
|
|
51
|
-
{
|
|
52
|
-
id: "discover-changed-files",
|
|
53
|
-
type: "artifact_transform",
|
|
54
|
-
dependsOn: [],
|
|
55
|
-
transform: {
|
|
56
|
-
type: "markdown_template",
|
|
57
|
-
template: buildDiscoverFilesOutput(files),
|
|
58
|
-
},
|
|
59
|
-
outputSchema: {
|
|
60
|
-
type: "object",
|
|
61
|
-
required: ["files"],
|
|
62
|
-
properties: {
|
|
63
|
-
files: { type: "array" },
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
id: "review-each-file",
|
|
69
|
-
type: "map_agent",
|
|
70
|
-
dependsOn: ["discover-changed-files"],
|
|
71
|
-
itemsFrom: "$.nodes['discover-changed-files'].output.files",
|
|
72
|
-
itemName: "file",
|
|
73
|
-
executor: "static",
|
|
74
|
-
role: "reviewer",
|
|
75
|
-
prompt: "Review {{file.path}} and emit one structured finding.",
|
|
76
|
-
staticResultTemplate: "{\"id\":\"{{file.findingId}}\",\"sourceNodeId\":\"review-each-file\",\"targetRef\":\"{{file.path}}\",\"title\":\"Review finding for {{file.path}}\",\"severity\":\"medium\",\"evidence\":[{\"path\":\"{{file.path}}\",\"summary\":\"deterministic profile finding\"}],\"recommendation\":\"Inspect {{file.path}} before merging\",\"expectedStatus\":\"{{file.expectedStatus}}\",\"expectedReason\":\"{{file.expectedReason}}\"}",
|
|
77
|
-
outputSchema: {
|
|
78
|
-
type: "object",
|
|
79
|
-
required: [
|
|
80
|
-
"id",
|
|
81
|
-
"sourceNodeId",
|
|
82
|
-
"targetRef",
|
|
83
|
-
"title",
|
|
84
|
-
"severity",
|
|
85
|
-
"evidence",
|
|
86
|
-
"recommendation",
|
|
87
|
-
],
|
|
88
|
-
properties: {
|
|
89
|
-
id: { type: "string" },
|
|
90
|
-
sourceNodeId: { type: "string" },
|
|
91
|
-
targetRef: { type: "string" },
|
|
92
|
-
title: { type: "string" },
|
|
93
|
-
severity: { type: "string" },
|
|
94
|
-
evidence: { type: "array" },
|
|
95
|
-
recommendation: { type: "string" },
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
id: "verify-findings",
|
|
101
|
-
type: "verify_agent",
|
|
102
|
-
dependsOn: ["review-each-file"],
|
|
103
|
-
producerNodeId: "review-each-file",
|
|
104
|
-
itemsFrom: "$.nodes['review-each-file'].output.children",
|
|
105
|
-
itemName: "finding",
|
|
106
|
-
executor: "static",
|
|
107
|
-
role: "adversarial-verifier",
|
|
108
|
-
prompt: "Independently verify {{finding.output.id}} using only the finding artifact.",
|
|
109
|
-
staticResultTemplate: "{\"findingId\":\"{{finding.output.id}}\",\"verifierNodeId\":\"verify-findings\",\"status\":\"{{finding.output.expectedStatus}}\",\"reason\":\"{{finding.output.expectedReason}}\",\"evidence\":[{\"path\":\"{{finding.output.targetRef}}\",\"summary\":\"independent verifier checked mapped finding\"}]}",
|
|
110
|
-
outputSchema: {
|
|
111
|
-
type: "object",
|
|
112
|
-
required: ["findingId", "verifierNodeId", "status", "reason", "evidence"],
|
|
113
|
-
properties: {
|
|
114
|
-
findingId: { type: "string" },
|
|
115
|
-
verifierNodeId: { type: "string" },
|
|
116
|
-
status: { type: "string" },
|
|
117
|
-
reason: { type: "string" },
|
|
118
|
-
evidence: { type: "array" },
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
id: "final-ranked-summary",
|
|
124
|
-
type: "reduce_agent",
|
|
125
|
-
dependsOn: ["verify-findings"],
|
|
126
|
-
role: "closeout",
|
|
127
|
-
prompt: "Create a verified-first PR review report.",
|
|
128
|
-
reducer: {
|
|
129
|
-
type: "verified_findings_report",
|
|
130
|
-
findingsFrom: "$.nodes['review-each-file'].output.children",
|
|
131
|
-
verificationsFrom: "$.nodes['verify-findings'].output.children",
|
|
132
|
-
},
|
|
133
|
-
outputSchema: {
|
|
134
|
-
type: "object",
|
|
135
|
-
required: ["summary", "verifiedFindings", "uncertainFindings", "evidenceRefs"],
|
|
136
|
-
properties: {
|
|
137
|
-
summary: { type: "string" },
|
|
138
|
-
verifiedFindings: { type: "array" },
|
|
139
|
-
uncertainFindings: { type: "array" },
|
|
140
|
-
refutedFindingsRef: { type: "string" },
|
|
141
|
-
evidenceRefs: { type: "array" },
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
final: {
|
|
147
|
-
from: "final-ranked-summary",
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
export function buildWorkflowSpecForProfile(input) {
|
|
152
|
-
if (input.profile === "pr-review") {
|
|
153
|
-
return buildPrReviewWorkflowSpec(input);
|
|
154
|
-
}
|
|
155
|
-
throw new Error(`unsupported workflow profile: ${input.profile}`);
|
|
156
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export const WORKFLOW_NODE_ID_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
3
|
-
export const workflowVersionSchema = z.literal("0.1");
|
|
4
|
-
export const workflowKindSchema = z.literal("dynamic-agent-workflow");
|
|
5
|
-
export const workflowRiskLevelSchema = z.enum(["low", "medium", "high", "critical"]);
|
|
6
|
-
export const workflowNodeTypeSchema = z.enum([
|
|
7
|
-
"agent",
|
|
8
|
-
"map_agent",
|
|
9
|
-
"verify_agent",
|
|
10
|
-
"reduce_agent",
|
|
11
|
-
"command",
|
|
12
|
-
"condition",
|
|
13
|
-
"loop_until",
|
|
14
|
-
"human_gate",
|
|
15
|
-
"artifact_transform",
|
|
16
|
-
]);
|
|
17
|
-
export const workflowLimitsSchema = z
|
|
18
|
-
.object({
|
|
19
|
-
maxConcurrency: z.number().int().positive().max(32).default(8),
|
|
20
|
-
maxAgentRuns: z.number().int().positive().max(500).default(100),
|
|
21
|
-
maxExpandedNodes: z.number().int().positive().max(1000).default(200),
|
|
22
|
-
maxRetriesPerNode: z.number().int().nonnegative().max(5).default(1),
|
|
23
|
-
maxIterations: z.number().int().positive().max(20).default(3),
|
|
24
|
-
maxWallClockMinutes: z.number().int().positive().max(24 * 60).default(30),
|
|
25
|
-
})
|
|
26
|
-
.default({});
|
|
27
|
-
export const workflowPermissionsSchema = z
|
|
28
|
-
.object({
|
|
29
|
-
filesystem: z.enum(["read_only", "workspace"]).default("read_only"),
|
|
30
|
-
shell: z
|
|
31
|
-
.object({
|
|
32
|
-
mode: z.enum(["deny", "allowlist"]).default("deny"),
|
|
33
|
-
commands: z.array(z.string().min(1)).default([]),
|
|
34
|
-
})
|
|
35
|
-
.default({}),
|
|
36
|
-
network: z.enum(["deny", "allow"]).default("deny"),
|
|
37
|
-
edits: z.enum(["deny", "allow"]).default("deny"),
|
|
38
|
-
allowedPaths: z.array(z.string().min(1)).optional(),
|
|
39
|
-
forbiddenPaths: z.array(z.string().min(1)).optional(),
|
|
40
|
-
writeSet: z.array(z.string().min(1)).optional(),
|
|
41
|
-
})
|
|
42
|
-
.default({});
|
|
43
|
-
export const workflowNodeSchema = z.object({
|
|
44
|
-
id: z.string().regex(WORKFLOW_NODE_ID_PATTERN, "node id must be kebab-case"),
|
|
45
|
-
type: workflowNodeTypeSchema,
|
|
46
|
-
dependsOn: z.array(z.string()).default([]),
|
|
47
|
-
executor: z.enum(["pi", "static"]).optional(),
|
|
48
|
-
role: z.string().optional(),
|
|
49
|
-
skills: z.array(z.string().min(1)).optional(),
|
|
50
|
-
prompt: z.string().optional(),
|
|
51
|
-
staticResultTemplate: z.string().optional(),
|
|
52
|
-
writePolicy: z.enum(["none", "read-only", "exclusive"]).optional(),
|
|
53
|
-
outputSchema: z.unknown().optional(),
|
|
54
|
-
command: z.string().optional(),
|
|
55
|
-
itemsFrom: z.string().optional(),
|
|
56
|
-
items: z.array(z.unknown()).optional(),
|
|
57
|
-
itemName: z.string().optional(),
|
|
58
|
-
producerNodeId: z.string().optional(),
|
|
59
|
-
maxItems: z.number().int().positive().optional(),
|
|
60
|
-
concurrency: z.number().int().positive().optional(),
|
|
61
|
-
workspaceTemplate: z.string().min(1).optional(),
|
|
62
|
-
reason: z.string().optional(),
|
|
63
|
-
approvalSchema: z.unknown().optional(),
|
|
64
|
-
cases: z
|
|
65
|
-
.array(z.object({
|
|
66
|
-
when: z.string().min(1),
|
|
67
|
-
then: z.string().min(1),
|
|
68
|
-
}))
|
|
69
|
-
.optional(),
|
|
70
|
-
default: z.string().optional(),
|
|
71
|
-
maxIterations: z.number().int().positive().optional(),
|
|
72
|
-
stopWhen: z.unknown().optional(),
|
|
73
|
-
body: z.array(z.unknown()).optional(),
|
|
74
|
-
transform: z
|
|
75
|
-
.object({
|
|
76
|
-
type: z.literal("markdown_template"),
|
|
77
|
-
template: z.string().min(1),
|
|
78
|
-
})
|
|
79
|
-
.optional(),
|
|
80
|
-
reducer: z
|
|
81
|
-
.object({
|
|
82
|
-
type: z.literal("verified_findings_report"),
|
|
83
|
-
findingsFrom: z.string().min(1),
|
|
84
|
-
verificationsFrom: z.string().min(1),
|
|
85
|
-
})
|
|
86
|
-
.optional(),
|
|
87
|
-
});
|
|
88
|
-
export const workflowSpecSchema = z.object({
|
|
89
|
-
version: workflowVersionSchema,
|
|
90
|
-
kind: workflowKindSchema,
|
|
91
|
-
meta: z
|
|
92
|
-
.object({
|
|
93
|
-
name: z.string().min(1),
|
|
94
|
-
description: z.string().optional(),
|
|
95
|
-
riskLevel: workflowRiskLevelSchema.optional().default("low"),
|
|
96
|
-
})
|
|
97
|
-
.default({ name: "unnamed-workflow", riskLevel: "low" }),
|
|
98
|
-
inputs: z.record(z.string(), z.unknown()).default({}),
|
|
99
|
-
limits: workflowLimitsSchema,
|
|
100
|
-
permissions: workflowPermissionsSchema,
|
|
101
|
-
nodes: z.array(workflowNodeSchema).min(1),
|
|
102
|
-
final: z.object({
|
|
103
|
-
from: z.string().min(1),
|
|
104
|
-
}),
|
|
105
|
-
});
|
|
106
|
-
export const AGENT_LIKE_WORKFLOW_NODE_TYPES = new Set([
|
|
107
|
-
"agent",
|
|
108
|
-
"map_agent",
|
|
109
|
-
"verify_agent",
|
|
110
|
-
"reduce_agent",
|
|
111
|
-
]);
|
|
112
|
-
export const ITEM_SELECTOR_WORKFLOW_NODE_TYPES = new Set([
|
|
113
|
-
"map_agent",
|
|
114
|
-
"verify_agent",
|
|
115
|
-
]);
|