Skip to content

v0.8.59: Add TypeScript/JavaScript workflow authoring for WhaleFlow-backed headless agents #3097

@Hmbown

Description

@Hmbown

Problem

CodeWhale needs a workflow authoring surface that is powerful enough for the parent agent to plan real dynamic orchestration instead of issuing ad hoc agent_open calls turn by turn. The existing WhaleFlow direction is solid at the execution boundary, but its documented authoring path is currently Starlark/YAML. If the goal is maximum agent capability and broad developer familiarity, TypeScript/JavaScript should be evaluated as the first-class workflow authoring language rather than treating it as an afterthought.

The important boundary is that JavaScript/TypeScript should author workflows, not become an unsupervised second runtime that secretly owns files, shell, network, cancellation, or provider calls. CodeWhale should compile or lower the authored workflow into typed WhaleFlow IR, then execute it through the Rust scheduler and the headless worker runtime tracked in #3096.

Evidence

Proposed direction

Make TypeScript/JavaScript the first-class high-capability workflow authoring option for CodeWhale, while keeping WhaleFlow typed IR and the Rust executor as the canonical runtime boundary.

A good target shape:

  • Support agent-authored .workflow.ts and/or .workflow.js files using a small CodeWhale workflow SDK: workflow, sequence, branch, agent, reduce, loopUntil, cond, budget, permissions, modelPolicy, and artifacts.
  • The JS/TS code should produce a declarative WorkflowSpec or equivalent JSON IR. The Rust side validates it before launch.
  • No direct workflow-script access to shell, filesystem mutation, network, provider clients, or TUI state by default. Those remain explicit worker/tool permissions in the IR.
  • Keep Starlark/YAML as compatibility and low-dependency authoring routes if useful, but do not let them block a more capable JS/TS authoring path.
  • Reuse v0.8.59: Split sub-agents into a headless worker runtime with lightweight TUI projections #3096's future AgentWorkerSpec / AgentWorkerEvent contract for LeafSpec execution so WhaleFlow does not create a second sub-agent scheduler.
  • Integrate with whaleflow: real async executor — replace MockWorkflowExecutor #2973 and whaleflow: wire codewhale-whaleflow into tui/cli (currently zero dependents) #2974 rather than bypassing them: author -> compile/lower -> validate typed IR -> scheduler executes headless workers -> TUI/CLI render events.
  • If Node is embedded or invoked, it should run as a compile/authoring step with a constrained host API, not as a long-running unsupervised process that owns cancellation or hidden side effects.

Acceptance criteria

  • A design note compares Starlark, YAML, JavaScript, and TypeScript for CodeWhale workflow authoring, and explicitly chooses the default first-class path.
  • The chosen path includes a TypeScript/JavaScript authoring contract or a clearly documented reason for rejecting it despite its capability advantage.
  • At least one .workflow.ts or .workflow.js example can declare a multi-agent branch/reduce workflow and lower to the existing WhaleFlow WorkflowSpec shape.
  • Lowered workflow specs are validated by Rust before execution, including budgets, permissions, model policy, dependency ordering, and leaf IDs.
  • Workflow scripts cannot directly mutate files, run shell commands, make network calls, or call model/provider clients unless those effects are represented as explicit typed worker/tool permissions.
  • Workflow leaves execute through the same headless worker contract planned in v0.8.59: Split sub-agents into a headless worker runtime with lightweight TUI projections #3096; no duplicate sub-agent runtime is introduced.
  • Safety regressions observed in feat: add WhaleFlow — declarative multi-agent workflow orchestration #2482/Feat/whaleflow cost tracking #2486 are covered before live execution: abort cancels spawned work, max_steps and timeout_secs are model-visible, phase ordering is deterministic, worktree changes are not silently dropped, same-phase result dependencies are rejected or sequenced, and token/cost usage is actually propagated.
  • TUI/CLI can show the authored workflow source language, compiled IR summary, queued/running/completed worker counts, cancellation state, and per-worker cost/budget status.

Verification

  • cargo test -p codewhale-whaleflow --locked
  • cargo test -p codewhale-whaleflow starlark --locked
  • Add focused tests for the JS/TS lowering layer once introduced.
  • Manual: ask CodeWhale to plan a four-agent audit workflow; it should author a workflow script, lower it to typed IR, validate it, run via the headless scheduler, and show progress without spawning a wall of opaque sub-agent cards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestsubagentsSub-agent orchestration, lifecycle, and completion handlingtuiTerminal UI behavior, rendering, or interactionv0.8.59Targeting v0.8.59whaleflowWhaleFlow branch/leaf workflow runtime and workflow modeworkflow-runtimeWorkflow IR, executor, control flow, and replay runtime

    Projects

    Status
    Backlog

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions