feat(workflow): item 25A 最小 workflow 执行 runtime (CC 2.1.229) - #105
Merged
Conversation
WorkflowTool.execute() 原为纯验证桩,从不执行脚本。落地最小可执行
runtime: agent()/parallel()/pipeline()/phase()/log() 原语 + runId
传播 transcript+telemetry。
- runtime.ts (NEW): executeWorkflow() + evaluateScript() (Bun.Transpiler
剥 TS → 花括号平衡抽 meta → new Function async IIFE 封装) + 并发信号量
池 min(16,cpu-2) + isWorkflowRuntimeEnabled()。agent() 用 runAgent
drain → getAssistantMessageText, transcriptSubdir=workflows/<runId>。
- WorkflowTool.ts: 双门禁分支 feature("WORKFLOW_SCRIPTS") 编译期 AND
FUSION_WORKFLOW_RUNTIME_ENABLED=1 运行期。去下划线接 context/
canUseTool/onProgress。activeRuns 转 completed/error。emitPerfettoInstant
runId。禁用时 byte-identical 桩。
- build.ts: WORKFLOW_SCRIPTS 加入 fullExperimentalFeatures (dev:full 启用)。
- workflowRuntime.test.ts (NEW): 23 单测 (env gate, meta 抽取嵌套/字符串,
eval 顶层 return/await/TS 剥类型, parallel 并发/throw→null, pipeline,
log/phase/budget/workflow-NotImplemented/args/残留 export 抛错)。
DEFERRED v1: schema (返回纯文本), 嵌套 workflow() (抛 NotImplemented),
budget (stub)。默认 off, 全 env-gated。
验证: typecheck 0, 23/23 workflowRuntime, 210/210 全套, build+build:dev:full
pass, dev:full bundle 含 runtime, standard bundle DCE runtime。
Closes #104
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
dahai80
added a commit
that referenced
this pull request
Aug 20, 2026
补 item 25A (PR #105) 配套文档 docs/workflow-runtime.md: 双门禁启用法、 脚本契约、原语表、DEFERRED v1 限制、eval 路径、安全注意、runId 传播、 关键文件。 Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Closes #104
WorkflowTool.execute()是纯验证桩——生成runId、检查export const meta存在、写activeRunsMap、立即返回status:"started",从不执行脚本。无parallel()/pipeline()/agent()/phase()runtime。transcriptSubdir通道全连通但 0 caller。onProgress接入但被忽略。activeRuns只写不转 completed/error。方案 (L-size, 双门禁 default-off)
落地最小可执行 runtime:脚本能跑
agent()/parallel()/pipeline()/phase()/log(),产出结果,runId 传播 transcript + telemetry。变更
src/tools/WorkflowTool/runtime.ts(NEW, ~300 行)executeWorkflow()入口 +evaluateScript()eval 流水线:export const meta→const __meta__→ 包async function _w(){...}→Bun.Transpiler(loader:ts)剥 TS 类型 → 拆包 → 花括号平衡抽 meta →new Function(8 params, "return (async()=>{<body>})();")agent()(runAgent drain →getAssistantMessageText,transcriptSubdir=workflows/<runId>)、parallel()/pipeline()(并发信号量池min(16,cpu-2), throw→null)、phase()/log()/workflow()(NotImplemented)/budget(stub)isWorkflowRuntimeEnabled()=process.env.FUSION_WORKFLOW_RUNTIME_ENABLED === "1"src/tools/WorkflowTool/WorkflowTool.ts(MODIFY)feature("WORKFLOW_SCRIPTS")编译期 ANDFUSION_WORKFLOW_RUNTIME_ENABLED=1运行期。两层满足才跑 runtime,否则 byte-identical 桩emitPerfettoInstantrunIdscripts/build.ts:WORKFLOW_SCRIPTS加入fullExperimentalFeatures(dev:full 启用)src/__tests__/workflowRuntime.test.ts(NEW, 23 tests): env gate、meta 抽取 (嵌套花括号/字符串含}/缺 meta 抛错)、eval 顶层 return/await/TS 类型剥除、parallel 并发/throw→null、pipeline 每 item 独立穿 stage、log/phase/budget/workflow-NotImplemented/args 透传/残留 export 抛错DEFERRED v1
schema(agent() 返回纯文本, 记 warn 忽略)workflow()(抛 NotImplemented)budget(stub, 无真实 token 预算)安全
model-authored 脚本经
new Function在全局作用域跑。双门禁 (编译+运行) 防护,对齐 CC 自身 Workflow 工具风险接受。完整沙箱超 v1 范围。验证
bun run typecheck— 0 errorsbun test src/__tests__/workflowRuntime.test.ts— 23/23 passbun test src/__tests__/— 210/210 pass (无回归)bun run build— pass (WORKFLOW_SCRIPTS off → runtime DCE, standard bundle grepworkflow_run_started= 0)bun run build:dev:full— pass (WORKFLOW_SCRIPTS on → runtime 入包, dev:full bundle grepworkflow_run_started= 2)biome checkchanged files — 仅 build.ts pre-existing 无关 lint (未触碰)Co-Authored-By: Claude Fable 5 noreply@anthropic.com