Skip to content

item 25A: 最小 workflow 执行 runtime (CC 2.1.229) #104

Closed

Description

@dahai80

背景

enhance-0819.md item 25。现况 WorkflowTool.execute() 是纯验证桩——生成 runId、检查 export const meta、写 activeRuns、立即返回 status:"started",从不执行脚本。无 parallel/pipeline/agent/phase runtime。transcriptSubdir 通道 (runAgent.ts) 全连通但 0 caller。onProgress 接入但被忽略 (_onProgress)。activeRuns 只写不转 completed/error。

缺口

无执行 runtime = workflow 脚本不可跑。transcriptSubdir 死桩。runId 不传播 telemetry。

方案 (L-size, 双门禁 default-off)

  1. 新 src/tools/WorkflowTool/runtime.ts — executeWorkflow() + evaluateScript() (Bun.Transpiler 剥 TS → 花括号平衡抽 meta → new Function async IIFE 封装) + 原语 (agent/parallel/pipeline/phase/log/workflow/budget) + 并发信号量 + isWorkflowRuntimeEnabled()。
  2. 改 WorkflowTool.ts:execute() — 双门禁分支 (feature("WORKFLOW_SCRIPTS") 编译期 AND FUSION_WORKFLOW_RUNTIME_ENABLED=1 运行期);去下划线接 context/canUseTool/onProgress;activeRuns 转 completed/error;emitPerfettoInstant runId。
  3. agent() 用 runAgent (async generator) drain → getAssistantMessageText 取最终文本;transcriptSubdir = workflows/<runId>。
  4. 默认 off,禁用时 byte-identical 桩。schema/nested-workflow/budget DEFERRED v1。

v1 限制

  • schema (StructuredOutput) 不支持,agent() 返回纯文本,传 schema 记 warn 忽略
  • 嵌套 workflow() 抛 NotImplemented
  • budget stub {total:null, spent:0, remaining:Infinity}

安全

model-authored 脚本经 new Function eval (全局作用域)。双门禁 (编译+运行) 防护,对齐 CC 自身 Workflow 工具风险接受。完整沙箱超 v1 范围 (Bun 无 Node vm 等价)。

验证

typecheck 0 + 单测 + 全测无回归 + build (桩 byte-identical) + build:dev:full (runtime 入包) + lint。手工双门禁全开真实加载验证。

Closes part of item 25.

Activity

  1. added a commit that references this issue on Aug 20, 2026
    5d580d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions