taskflow-core 0.1.5 → 0.1.7
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/LICENSE +21 -0
- package/README.md +122 -30
- package/dist/agents.d.ts +20 -0
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +51 -2
- package/dist/agents.js.map +1 -1
- package/dist/deterministic.d.ts +33 -0
- package/dist/deterministic.d.ts.map +1 -0
- package/dist/deterministic.js +56 -0
- package/dist/deterministic.js.map +1 -0
- package/dist/flowir/translate.d.ts.map +1 -1
- package/dist/flowir/translate.js +25 -7
- package/dist/flowir/translate.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/interpolate.d.ts +18 -0
- package/dist/interpolate.d.ts.map +1 -1
- package/dist/interpolate.js +45 -0
- package/dist/interpolate.js.map +1 -1
- package/dist/jsonc.d.ts +30 -0
- package/dist/jsonc.d.ts.map +1 -0
- package/dist/jsonc.js +108 -0
- package/dist/jsonc.js.map +1 -0
- package/dist/library/meta.d.ts +31 -0
- package/dist/library/meta.d.ts.map +1 -0
- package/dist/library/meta.js +154 -0
- package/dist/library/meta.js.map +1 -0
- package/dist/library/search.d.ts +33 -0
- package/dist/library/search.d.ts.map +1 -0
- package/dist/library/search.js +299 -0
- package/dist/library/search.js.map +1 -0
- package/dist/library/types.d.ts +121 -0
- package/dist/library/types.d.ts.map +1 -0
- package/dist/library/types.js +18 -0
- package/dist/library/types.js.map +1 -0
- package/dist/replay.d.ts +75 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/replay.js +25 -0
- package/dist/replay.js.map +1 -0
- package/dist/runner-core.d.ts +54 -4
- package/dist/runner-core.d.ts.map +1 -1
- package/dist/runner-core.js +237 -10
- package/dist/runner-core.js.map +1 -1
- package/dist/runtime.d.ts +8 -11
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +170 -43
- package/dist/runtime.js.map +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +13 -0
- package/dist/schema.js.map +1 -1
- package/dist/scorers.d.ts +11 -3
- package/dist/scorers.d.ts.map +1 -1
- package/dist/scorers.js +38 -7
- package/dist/scorers.js.map +1 -1
- package/dist/store.d.ts +80 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +249 -39
- package/dist/store.js.map +1 -1
- package/dist/trace.d.ts +150 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +191 -0
- package/dist/trace.js.map +1 -0
- package/package.json +6 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 heggria
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
<img src="https://raw.githubusercontent.com/heggria/taskflow/main/assets/hero.png" alt="taskflow — a declarative, verifiable graph of task nodes for coding-agent subagents: stateful, resumable, context-isolated" width="900">
|
|
4
4
|
|
|
5
5
|
<p>
|
|
6
|
-
<a href="https://www.npmjs.com/package/pi-taskflow"><img src="https://img.shields.io/npm/v/pi-taskflow?style=flat-square&color=
|
|
7
|
-
<a href="https://www.npmjs.com/package/pi-taskflow"><img src="https://img.shields.io/npm/dm/pi-taskflow?style=flat-square&color=
|
|
8
|
-
<a href="https://github.com/heggria/taskflow/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-
|
|
9
|
-
<a href="#whats-inside"><img src="https://img.shields.io/badge/runtime%20deps-0-
|
|
6
|
+
<a href="https://www.npmjs.com/package/pi-taskflow"><img src="https://img.shields.io/npm/v/pi-taskflow?style=flat-square&color=4B4ACF&label=npm" alt="npm version"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/pi-taskflow"><img src="https://img.shields.io/npm/dm/pi-taskflow?style=flat-square&color=5A5D63&label=downloads" alt="npm downloads"></a>
|
|
8
|
+
<a href="https://github.com/heggria/taskflow/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-0E8A66?style=flat-square" alt="MIT license"></a>
|
|
9
|
+
<a href="#whats-inside"><img src="https://img.shields.io/badge/runtime%20deps-0-0E8A66?style=flat-square" alt="zero runtime dependencies"></a>
|
|
10
10
|
<a href="https://github.com/heggria/taskflow/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/heggria/taskflow/ci.yml?branch=main&style=flat-square&label=CI" alt="CI status"></a>
|
|
11
|
-
<a href="#whats-inside"><img src="https://img.shields.io/badge/tests-
|
|
12
|
-
<a href="#whats-inside"><img src="https://img.shields.io/badge/dogfooded-%E2%9C%93-
|
|
13
|
-
<a href="#run-it-on-your-agent"><img src="https://img.shields.io/badge/runs%20on-Pi%20%2B%20Codex-
|
|
11
|
+
<a href="#whats-inside"><img src="https://img.shields.io/badge/tests-1140-4B4ACF?style=flat-square" alt="1140 tests"></a>
|
|
12
|
+
<a href="#whats-inside"><img src="https://img.shields.io/badge/dogfooded-%E2%9C%93-0E8A66?style=flat-square" alt="dogfooded"></a>
|
|
13
|
+
<a href="#run-it-on-your-agent"><img src="https://img.shields.io/badge/runs%20on-Pi%20%2B%20Codex%20%2B%20Claude%20Code%20%2B%20OpenCode-4B4ACF?style=flat-square" alt="runs on Pi, Codex, Claude Code, and OpenCode"></a>
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
16
|
<p align="center">
|
|
@@ -18,9 +18,13 @@
|
|
|
18
18
|
<a href="https://github.com/heggria/taskflow/blob/main/README.zh-CN.md">简体中文</a>
|
|
19
19
|
</p>
|
|
20
20
|
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="https://heggria.github.io/taskflow/en"><img src="https://img.shields.io/badge/📖_Read_the_docs-heggria.github.io%2Ftaskflow-4B4ACF?style=for-the-badge&labelColor=2D2F5A" alt="Read the docs — heggria.github.io/taskflow"></a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
21
25
|
<p><strong>A declarative, verifiable <em>graph of tasks</em> for coding-agent subagents.</strong><br/>
|
|
22
26
|
Not a workflow you script — a DAG you declare. Fan out · gate · loop · tournament · resume · save as a command — intermediate results stay out of your context.<br/>
|
|
23
|
-
Runs on the <a href="https://pi.dev">Pi</a> coding agent
|
|
27
|
+
Runs on the <a href="https://pi.dev">Pi</a> coding agent, on <a href="https://github.com/openai/codex">OpenAI Codex</a>, on <a href="https://claude.com/product/claude-code">Claude Code</a>, and on <a href="https://opencode.ai">OpenCode</a>.</p>
|
|
24
28
|
|
|
25
29
|
</div>
|
|
26
30
|
|
|
@@ -31,13 +35,20 @@ pi install npm:pi-taskflow
|
|
|
31
35
|
# Codex
|
|
32
36
|
codex plugin marketplace add heggria/taskflow
|
|
33
37
|
codex plugin add taskflow@taskflow
|
|
38
|
+
|
|
39
|
+
# Claude Code
|
|
40
|
+
claude plugin marketplace add heggria/taskflow
|
|
41
|
+
claude plugin install claude-taskflow@taskflow
|
|
42
|
+
|
|
43
|
+
# OpenCode — add the MCP server to opencode.json (see the OpenCode guide)
|
|
44
|
+
opencode mcp add taskflow -- npx -y -p opencode-taskflow opencode-taskflow-mcp
|
|
34
45
|
```
|
|
35
46
|
|
|
36
47
|
---
|
|
37
48
|
|
|
38
49
|
**A `workflow` flows. A `taskflow` is a *graph*.** Other orchestrators let the model *script* the work — imperative code that flows step by step, with the graph hidden inside control flow. `taskflow` does the opposite: you **declare** the work as a graph of discrete, named **task** nodes connected by `dependsOn` edges — and the runtime *verifies that graph before it spends a single token.*
|
|
39
50
|
|
|
40
|
-
You already know your agent's built-in subagent shorthand — `task` / `tasks` / `chain`. `taskflow` speaks the *same* shorthand — so your existing delegations instantly become **tracked, resumable, and saveable by name** (on Pi, a saved flow becomes a one-word `/tf:<name>` command; on Codex you run it by name through `taskflow_run`). When you outgrow the shorthand, the full DSL gives you a real DAG: dynamic fan-out over dozens of items, conditional routing, quality gates, human approvals, retries, loops, tournaments, and a hard spend ceiling.
|
|
51
|
+
You already know your agent's built-in subagent shorthand — `task` / `tasks` / `chain`. `taskflow` speaks the *same* shorthand — so your existing delegations instantly become **tracked, resumable, and saveable by name** (on Pi, a saved flow becomes a one-word `/tf:<name>` command; on Codex, Claude Code, and OpenCode you run it by name through `taskflow_run`). When you outgrow the shorthand, the full DSL gives you a real DAG: dynamic fan-out over dozens of items, conditional routing, quality gates, human approvals, retries, loops, tournaments, and a hard spend ceiling.
|
|
41
52
|
|
|
42
53
|
And the whole time, **only the final phase reaches your conversation.** Every intermediate transcript stays in the runtime, never your context window.
|
|
43
54
|
|
|
@@ -173,6 +184,41 @@ codex plugin add taskflow@taskflow
|
|
|
173
184
|
|
|
174
185
|
The plugin's MCP server runs via `npx` (a version-pinned `codex-taskflow`), so there's nothing else to install globally and the plugin version binds the exact code that runs. Then just ask Codex to run a multi-phase or fan-out job and it calls the tools. See the [Codex guide](https://github.com/heggria/taskflow/blob/main/docs/codex-mcp.md).
|
|
175
186
|
|
|
187
|
+
### On Claude Code
|
|
188
|
+
|
|
189
|
+
taskflow ships as a Claude Code **plugin** too — install it once and the `taskflow_*` MCP tools plus a routing skill light up automatically, no manual `mcp add` and no config editing:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
claude plugin marketplace add heggria/taskflow
|
|
193
|
+
claude plugin install claude-taskflow@taskflow
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The plugin's MCP server runs via `npx` (a version-pinned `claude-taskflow`), so there's nothing else to install globally and the plugin version binds the exact code that runs. Each phase's subagent then runs as an isolated `claude -p` session. Just ask Claude Code to run a multi-phase or fan-out job and it calls the tools. See the [Claude Code guide](https://github.com/heggria/taskflow/blob/main/docs/claude-mcp.md).
|
|
197
|
+
|
|
198
|
+
### On OpenCode
|
|
199
|
+
|
|
200
|
+
OpenCode reaches taskflow through the same MCP server. Register it once — either with the CLI or by adding an `mcp` entry to your `opencode.json`:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
opencode mcp add taskflow -- npx -y -p opencode-taskflow opencode-taskflow-mcp
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
```jsonc
|
|
207
|
+
// opencode.json
|
|
208
|
+
{
|
|
209
|
+
"$schema": "https://opencode.ai/config.json",
|
|
210
|
+
"mcp": {
|
|
211
|
+
"taskflow": {
|
|
212
|
+
"type": "local",
|
|
213
|
+
"command": ["npx", "-y", "-p", "opencode-taskflow", "opencode-taskflow-mcp"],
|
|
214
|
+
"enabled": true
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The server runs via `npx` (a version-pinned `opencode-taskflow`), and each phase's subagent runs as an isolated `opencode run` session. OpenCode also auto-discovers the bundled routing skill (`**/SKILL.md`). Then just ask OpenCode to run a multi-phase or fan-out job and it calls the tools. See the [OpenCode guide](https://github.com/heggria/taskflow/blob/main/docs/opencode-mcp.md).
|
|
221
|
+
|
|
176
222
|
### The shorthand (same shape as the built-in tool)
|
|
177
223
|
|
|
178
224
|
```jsonc
|
|
@@ -413,6 +459,46 @@ with the run — flows that don't opt in behave exactly as before.
|
|
|
413
459
|
"task": "ctx_read 'endpoints' for shared context, then audit {item} for missing auth." }
|
|
414
460
|
```
|
|
415
461
|
|
|
462
|
+
### Library: search before author
|
|
463
|
+
|
|
464
|
+
A flow that took work to generalize is an asset — but only if you can find it
|
|
465
|
+
again. Phase 1 of the **taskflow library** adds sidecar `.meta.json` metadata
|
|
466
|
+
(`purpose`, `tags`, `phaseSignature`, `generality`, `reuseCount`) to saved
|
|
467
|
+
flows, plus a search tool that surfaces reusable flows before you write a new
|
|
468
|
+
one:
|
|
469
|
+
|
|
470
|
+
```jsonc
|
|
471
|
+
// MCP
|
|
472
|
+
{ "name": "taskflow_search", "arguments": { "query": "audit API endpoints for missing auth" } }
|
|
473
|
+
// Pi tool
|
|
474
|
+
{ "action": "search", "query": "审计接口鉴权" }
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
Search is **structural + keyword** by default (zero dependencies, zero tokens):
|
|
478
|
+
`phaseSignature` (`agent→map→reduce`) and phase-count similarity are blended
|
|
479
|
+
with keyword overlap. It is **CJK-aware**, so a Chinese query like
|
|
480
|
+
`"检查接口安全性 鉴权 缺失"` still matches a purpose containing
|
|
481
|
+
`"审计...是否缺少鉴权检查"`. Embedding-based semantic search is Phase 2 —
|
|
482
|
+
the `embedder` seam is already in place and search degrades gracefully when it
|
|
483
|
+
is not configured.
|
|
484
|
+
|
|
485
|
+
When you run a flow you discovered via search, pass `reusedFromSearch: true`
|
|
486
|
+
(`taskflow_run` MCP, or `action=run` in Pi). That bumps the flow's
|
|
487
|
+
`reuseCount`, so high-quality reusable patterns rank higher over time. When you
|
|
488
|
+
write a new reusable flow, save it with metadata:
|
|
489
|
+
|
|
490
|
+
```jsonc
|
|
491
|
+
{ "name": "taskflow_save",
|
|
492
|
+
"arguments": {
|
|
493
|
+
"name": "audit-endpoints",
|
|
494
|
+
"definition": { ... },
|
|
495
|
+
"purpose": "Audit API endpoints for missing auth checks",
|
|
496
|
+
"tags": ["audit", "security", "auth"] } }
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
See `docs/rfc-library-reuse.md` for the design and `skills-src/taskflow/library.md`
|
|
500
|
+
for the agent-facing search→reuse→generalize→re-save workflow.
|
|
501
|
+
|
|
416
502
|
### Control flow & reliability
|
|
417
503
|
|
|
418
504
|
- **`when`** — skip a phase unless an expression is truthy. Supports `{refs}`, `== != < > <= >=`, `&& || !`, parentheses, and quoted strings/numbers. Pair with `join: "any"` on the merge phase for real if/else routing. Parse errors **fail open** (the phase runs — never silently dropped).
|
|
@@ -420,7 +506,7 @@ with the run — flows that don't opt in behave exactly as before.
|
|
|
420
506
|
- **`retry`** — `{ "max": 2, "backoffMs": 500, "factor": 2 }` retries a failing subagent with fixed or exponential backoff; usage is summed and the attempt count shows as `↻N` in the TUI. Transient provider errors (rate-limit / 5xx / timeout) **auto-retry even without an explicit policy**; hard errors don't.
|
|
421
507
|
- **`onBlock`** — `"halt"` (default) stops the run when a gate blocks. `"retry"` retries upstream phases when a gate blocks, instead of halting — a self-healing rework loop with budget and idle-watchdog guards and a nested recursion depth cap.
|
|
422
508
|
- **`eval`** — zero-token machine-checkable criteria that run *before* the LLM gate. If the eval check fails, the gate blocks without spawning an agent.
|
|
423
|
-
- **`score`** — graded, composable quality gates: deterministic scorers (`exact-match`, `contains`, `regex`, `json-schema`, `length-range`, `code-compiles`) run against a target string at **zero tokens** and combine via `all`/`any`/`weighted` against a `threshold`. Deterministic pass → auto-PASS with no LLM call **when the judge cannot veto** — no judge configured, or `weighted` where the deterministic score is a *lower bound* already clearing the threshold. With `all`/`any` + a judge, the judge always runs (its verdict is authoritative — it may check what scorers cannot, e.g. factuality). Deterministic fail → the optional LLM `judge` decides (fail-
|
|
509
|
+
- **`score`** — graded, composable quality gates: deterministic scorers (`exact-match`, `contains`, `regex`, `json-schema`, `length-range`, `code-compiles`) run against a target string at **zero tokens** and combine via `all`/`any`/`weighted` against a `threshold`. Deterministic pass → auto-PASS with no LLM call **when the judge cannot veto** — no judge configured, or `weighted` where the deterministic score is a *lower bound* already clearing the threshold. With `all`/`any` + a judge, the judge always runs (its verdict is authoritative — it may check what scorers cannot, e.g. factuality). Deterministic fail → the optional LLM `judge` decides (**fail-closed** on unparseable output — issue #54), or the gate `task` runs with the scorer report appended, or — with no fallback — the gate **blocks explicitly**. The structured result is the gate's `.json` (`{steps.<gate>.json.combined}`, `.json.results`), so downstream phases can route on quality, not just pass/fail. LLM-generated dynamic sub-flows may not use `code-compiles` (compiler execution) or `regex` (ReDoS) scorers — same hardening class as the `script` block.
|
|
424
510
|
- **`idempotent: false`** — side-effect classification for phases with **irreversible effects** (webhook POSTs, deploys, DB writes): the implicit transient auto-retry is suppressed (an explicit `retry{}` is still honored — it's the author's declaration that repeats are acceptable) and the result is **never cached** in any scope (within-run resume, cross-run, `incremental`) — the phase re-runs every time. The phase state records `sideEffect: true` (rendered as ⚡). Default `true` — existing flows are unchanged.
|
|
425
511
|
- **`approval`** — pause for a human (Approve / Reject / Edit). Reject halts the flow; Edit injects the typed note as the phase output for downstream steps. Non-interactive runs (detached / CI) **auto-reject** (safety: approval gates are never bypassed).
|
|
426
512
|
- **`flow`** — `{ "type": "flow", "use": "deep-research", "with": { "topic": "{item}" } }` runs a **saved** flow as a phase (recursion is detected and rejected). Or **generate the sub-flow at runtime**: `{ "type": "flow", "def": "{steps.plan.json}" }` resolves an upstream phase's JSON output into a sub-flow, **validates it (cycles / dangling refs / duplicate ids / dead-ends), then runs it** — the number and shape of the generated phases is decided at runtime, not authored in advance. A malformed plan fails *open* (the phase is skipped with a `defError`, the run continues). This is how a planner decides *at runtime* what work to spawn — the declarative answer to a code-mode `for` loop, with each generated plan checked before it spends a token. Security hardening for LLM-generated sub-flows: breadth caps (100 phases, 200 map items, 16 concurrency), `cwd` containment, budget clamped to `min(child, parent)`, nesting cap (5 levels), and prototype-pollution defense (deep-cloned, `__proto__`/`constructor`/`prototype` stripped). Pair it with `loop` for **data-dependent iterative replanning** (round N's plan depends on round N-1's result). See [`examples/dynamic-plan-execute.json`](https://github.com/heggria/taskflow/blob/main/examples/dynamic-plan-execute.json) and [`examples/iterative-replan.json`](https://github.com/heggria/taskflow/blob/main/examples/iterative-replan.json).
|
|
@@ -464,7 +550,7 @@ For open-ended work, the best result often comes from generating several candida
|
|
|
464
550
|
```
|
|
465
551
|
|
|
466
552
|
- **Competitors** — either `variants: N` copies of one `task` (diversity comes from model nondeterminism), or distinct `branches: [{task, agent?}, …]` when you want to pit *different approaches* against each other.
|
|
467
|
-
- **Judge** — after the fan-out, one judge agent sees every variant (numbered) plus your `judge` rubric and picks a winner
|
|
553
|
+
- **Judge** — after the fan-out, one judge agent sees every variant (numbered) plus your `judge` rubric and picks a winner. Prefer a JSON pick `{"winner": n}` (most robust); the runtime also reads a `WINNER: <n>` line (`#n` and Markdown emphasis like `WINNER: **n**` are tolerated — issue #54). An unreadable verdict **fails open** to variant 1; a failed judge falls back too — the work is never lost.
|
|
468
554
|
- **`mode`** — `best` returns the winning variant **verbatim**; `aggregate` returns the judge's **synthesized** answer combining the strongest parts.
|
|
469
555
|
- **Short-circuits:** if only one competitor survives, it wins with no judge call; if all fail, the phase fails. The TUI shows `⚑ N→#k`; usage sums variants + judge. Like `gate`, it's **excluded from `cross-run` cache**.
|
|
470
556
|
|
|
@@ -476,7 +562,7 @@ Not every step needs a model. A `script` phase runs a **shell command** directly
|
|
|
476
562
|
{
|
|
477
563
|
"id": "build",
|
|
478
564
|
"type": "script",
|
|
479
|
-
"run": "
|
|
565
|
+
"run": "pnpm run build", // string → runs in a shell
|
|
480
566
|
"timeout": 120000 // optional ms cap (1000–300000, default 60000)
|
|
481
567
|
},
|
|
482
568
|
{
|
|
@@ -517,12 +603,12 @@ Every phase is already content-addressed: within a single run's **resume**, a ph
|
|
|
517
603
|
|
|
518
604
|
### Gate phases (quality control)
|
|
519
605
|
|
|
520
|
-
A `gate` runs an agent to review upstream output and can **block the rest of the workflow.**
|
|
606
|
+
A `gate` runs an agent to review upstream output and can **block the rest of the workflow.** Provide a verdict the runtime can read — **preferably via a JSON contract** (`output: "json"` + `expect: { properties: { verdict: { enum: ["pass","block"] } } }`), which machine-validates the output so a verdict can never be silently misread. Otherwise:
|
|
521
607
|
|
|
522
|
-
- a final line `VERDICT: PASS` or `VERDICT: BLOCK` (also accepts `OK`, `FAIL`, `STOP`, `REJECT`, `HALT` — last occurrence wins), or
|
|
608
|
+
- a final line `VERDICT: PASS` or `VERDICT: BLOCK` (also accepts `OK`, `FAIL`, `STOP`, `REJECT`, `HALT` — last occurrence wins; common Markdown emphasis like `VERDICT: **BLOCK**` is tolerated), or
|
|
523
609
|
- JSON like `{"continue": false, "reason": "missing auth checks"}` / `{"verdict": "block", "reason": "..."}`.
|
|
524
610
|
|
|
525
|
-
On **BLOCK**, downstream phases skip and the run ends as `blocked` with the reason surfaced. **
|
|
611
|
+
If a free-text gate's task doesn't already ask for a `VERDICT:` marker, the runtime **auto-appends** the exact format instruction. On **BLOCK**, downstream phases skip and the run ends as `blocked` with the reason surfaced. **Unparseable gate model output fails closed** (treated as BLOCK) — a gate that cannot reach a verdict cannot be trusted to pass (issue #54). Config slips (unresolved `score.target`, malformed `scorers`) still fail **open** with a warning.
|
|
526
612
|
|
|
527
613
|
```
|
|
528
614
|
Review the audit below. If any endpoint is missing auth, end with
|
|
@@ -552,7 +638,7 @@ Condition grammar (for `when`): `== != < > <= >=`, `&& || !`, parentheses, quote
|
|
|
552
638
|
|
|
553
639
|
## Commands
|
|
554
640
|
|
|
555
|
-
Saved flows become CLI shortcuts. **These `/tf` commands are Pi-only** (they run in the Pi session). On Codex, use the `taskflow_*` MCP tools instead — `taskflow_list` / `taskflow_show` / `taskflow_run` (by `name`) / `taskflow_verify` / `taskflow_compile`.
|
|
641
|
+
Saved flows become CLI shortcuts. **These `/tf` commands are Pi-only** (they run in the Pi session). On Codex, Claude Code, and OpenCode, use the `taskflow_*` MCP tools instead — `taskflow_list` / `taskflow_show` / `taskflow_run` (by `name`) / `taskflow_verify` / `taskflow_compile` / `taskflow_peek`.
|
|
556
642
|
|
|
557
643
|
| Command | What it does |
|
|
558
644
|
|---|---|
|
|
@@ -562,10 +648,12 @@ Saved flows become CLI shortcuts. **These `/tf` commands are Pi-only** (they run
|
|
|
562
648
|
| `/tf compile <name> [lr\|td]` | **Render the flow as a Mermaid diagram + verification overlay** — 0 tokens, no LLM; paste into a README/issue/PR |
|
|
563
649
|
| `/tf runs` | Browse recent run history (interactive TUI — **live auto-refreshes** while any run is active) |
|
|
564
650
|
| `/tf resume <runId>` | Continue a paused/failed run — cached phases skip automatically |
|
|
651
|
+
| `/tf peek <runId> [phaseId]` | Inspect a phase's intermediate output (the debugging escape hatch) |
|
|
652
|
+
| `/tf trace <runId> [--json]` | Show a run's **deterministic-replay event trace** (each subagent call + runtime decisions) |
|
|
565
653
|
| `/tf init` | **Interactively map model roles** to your enabled models (writes `~/.pi/agent/settings.json`) |
|
|
566
654
|
| `/tf:<name> [args]` | Shortcut — runs the flow in one tap |
|
|
567
655
|
|
|
568
|
-
Tool actions (used by the model on Pi): `run` (inline `define` or saved `name`), `save`, `resume`, `list`, `agents`, `init`, `verify`, `compile`, `ir`, `provenance`, `why-stale`, `recompute`, `cache-clear`. On Codex the exposed MCP tools are `taskflow_run` / `taskflow_list` / `taskflow_show` / `taskflow_verify` / `taskflow_compile`.
|
|
656
|
+
Tool actions (used by the model on Pi): `run` (inline `define` or saved `name`), `save`, `resume`, `list`, `agents`, `init`, `verify`, `compile`, `ir`, `provenance`, `trace`, `why-stale`, `recompute`, `cache-clear`, `search`. On Codex, Claude Code, and OpenCode the exposed MCP tools are `taskflow_run` / `taskflow_list` / `taskflow_show` / `taskflow_verify` / `taskflow_compile` / `taskflow_peek` / `taskflow_trace` / `taskflow_why_stale` / `taskflow_recompute` (dry-run only) / `taskflow_save` / `taskflow_search`.
|
|
569
657
|
|
|
570
658
|
## Background (detached) execution
|
|
571
659
|
|
|
@@ -779,12 +867,12 @@ Copy one into `.pi/taskflows/<name>.json` (or `~/.pi/agent/taskflows/`) and it r
|
|
|
779
867
|
|
|
780
868
|
<div align="center">
|
|
781
869
|
|
|
782
|
-
**0 runtime dependencies** · **
|
|
870
|
+
**0 runtime dependencies** · **1140 tests** · **10 phase types** · **shared context tree** · **cross-session resume** · **cross-run memoization** · **per-item map caching** · **incremental recompute** · **FlowIR compile seam** · **detached execution** · **`compile` Mermaid renderer** · **~9k LOC runtime**
|
|
783
871
|
|
|
784
872
|
</div>
|
|
785
873
|
|
|
786
874
|
- **Zero runtime dependencies.** No `dependencies` field — the runtime is built entirely on Node built-ins (`fs` / `path` / `os` / `child_process` / `crypto`). The file lock is `fs.openSync("wx")`, not a third-party library.
|
|
787
|
-
- **
|
|
875
|
+
- **1140 tests across 70 test files** covering concurrency, atomic file locking (8-process race regressions), path-traversal hardening, cross-session resume, cross-run cache freshness (flow/thinking/tools key isolation, fingerprint invalidation, TTL/LRU eviction), backward-compatible cache-key migration (4-tier legacy fallback), per-phase structural sub-fingerprint (v3:phasefp — editing one phase invalidates only it and its dependents), per-item map caching (one changed item re-executes, N−1 cache hits), the `incremental` flag (run-wide cross-run default), reuse reporting, the FlowIR compile seam (determinism, declared-plane synthesis), incremental recompute (early-cutoff propagation, partial cascade strictly < full, observed ∪ declared union frontier), gate verdicts, budget caps, retry/backoff, approval flows, loop termination, tournament judging, sub-flow composition, the shared context tree (blackboard reuse, supervision spawn, subflow validation/nesting), workspace isolation (temp/dedicated/worktree lifecycle, fail-open degrade, dynamic-flow rejection), dynamic sub-flow security hardening, detached execution (PID persistence, stale detection, crash→failed, resume after failure), live run-history refresh, callback isolation, the idle watchdog, model-role init config, parseModelFromLabel with parenthesized-model-name regression, multi-fence `safeParse` recovery, host argv-contract locking (codex/claude/opencode `buildXxxArgs`), the `compile` Mermaid renderer (id-collision disambiguation, markdown-injection hardening, and full verify-overlay category coverage), plus the library Phase 1 metadata/search/store layer (phaseSignature, generality, CJK text scoring, staleness detection, sidecar persistence, A1 ghost-flow guard).
|
|
788
876
|
- **Hardened by design.** Path-traversal defense (lexical + `realpath` containment check), runId validation, HTML/error sanitization, atomic writes, stale-lock stealing via `rename`, and an idle watchdog that kills wedged subagents (SIGTERM → SIGKILL after 5 minutes of silence). Dynamic sub-flows additionally get breadth caps, `cwd` containment, budget clamping, nesting depth caps, and prototype-pollution defense.
|
|
789
877
|
- **Dogfooded.** Every new feature has to survive the project's own `self-improve` taskflow before it ships.
|
|
790
878
|
|
|
@@ -809,7 +897,7 @@ Our `self-improve` flow is a 10-phase DAG — it audits the codebase, patches de
|
|
|
809
897
|
|
|
810
898
|
## Status & limits
|
|
811
899
|
|
|
812
|
-
**v0.1.
|
|
900
|
+
**v0.1.7** (current release) — **file loaders now report *why* a file failed with the parse position** (line/column) instead of a merged "not found or unparseable" message — `defineFile`, saved flows, run records, and library sidecars all distinguish *missing* from *malformed*, so a stray bare newline in a hand-authored flow is diagnosable in seconds; `safeParse` stays lenient for LLM output. Also fixes a pi-taskflow hint that re-printed every session. **Gate safety hardening (issue #54)**: a shared emphasis-tolerant marker factory now covers **all three decision markers** — `VERDICT`, `WINNER`, and `SCORE` — so Markdown-wrapped tokens (`VERDICT: **BLOCK**`, `WINNER: __3__`, `SCORE: `0.8``) are never silently mis-read (a genuine BLOCK no longer becomes PASS; a judge's pick no longer silently reverts to variant 1); **unparseable gate *model output now fails closed* (BLOCK)** instead of rubber-stamping PASS — a gate that cannot reach a verdict cannot be trusted to pass, while *config* slips (unresolved `score.target`, malformed `scorers`) stay fail-open with a warning; and free-text gates whose task omits a `VERDICT:` instruction now get the exact format suffix **auto-appended**. For the most robust decision phases, use `output: "json"` + `expect` to machine-validate the output (now the documented default for gate verdicts, tournament winners, and router branches). **v0.1.6** added **library Phase 1** (search-before-author + reusable-flow sidecar metadata), the **`defineFile`** parameter (verify/compile/run a flow from a path on disk), and **JSONC comment support** in flow definition files (`//` and `/* */` comments + trailing commas, parsed by the new zero-dependency `parseJsonc`). **v0.1.5** added **Claude Code and OpenCode as hosts**, **extracted the MCP server into its own `taskflow-mcp-core` package**, and **de-duplicated the three host runners** into a shared `runSubagentProcess`. See [CHANGELOG](https://github.com/heggria/taskflow/blob/main/CHANGELOG.md) for the full history. Baseline: **multi-host monorepo of seven packages** — the host-neutral `taskflow-core` engine, the host-neutral `taskflow-mcp-core` MCP server, the shared host-runner `taskflow-hosts`, plus `pi-taskflow` (Pi adapter), `codex-taskflow`, `claude-taskflow`, and `opencode-taskflow` (the three delivery packages re-export their runners from `taskflow-hosts` and each ships an MCP bin + plugin/config), all sharing the host-neutral MCP server in `taskflow-mcp-core`. **Library Phase 1**: save flows with `purpose`+`tags` via `taskflow_save` (MCP) or `action=save` (Pi), search them with structural + CJK-aware keyword scoring via `taskflow_search`/`action=search`, and track `reuseCount` via `reusedFromSearch`. **`defineFile`**: pass a `defineFile` path (or `{defineFile, name}`) to `action=run` (Pi) or `taskflow_run`/`taskflow_verify`/`taskflow_compile` (MCP) instead of an inline `define`, and the engine reads the flow from disk — pair it with JSONC comments to annotate saved flows. **JSONC**: flow-definition `.json` files may now carry `//` and `/* */` comments and trailing commas (parsed by `parseJsonc`, re-exported from the `taskflow-core` barrel); LLM-output parsing via `safeParse` stays strict. **Shared Context Tree**: opt-in (`shareContext` / `contextSharing`) blackboard + supervision tools (`ctx_read`/`ctx_write` horizontal reuse, `ctx_report`/`ctx_spawn` vertical supervision); `ctx_spawn` accepts a flat task **or** a dependency-bearing `subflow` (a runtime-validated nested DAG), depth-capped on a unified nesting counter with budget accounting. **Workspace isolation**: a phase's `cwd` accepts reserved keywords `temp`/`dedicated`/`worktree` — the runtime allocates an isolated dir (or a git worktree on a throwaway branch) and tears it down after the phase, fail-open, rejected in LLM-authored sub-flows. **Detached execution**: runs can execute in the background, detached from the Pi session. Prior: loop-until-done (`loop`), tournament (best-of-N with a judge), cross-run memoization (content-addressed cache with git/file/glob/env fingerprints and TTL), interactive `/tf init`, configurable built-in agents, 18 built-in agents with 6 model roles. Full control-flow & reliability layer (`when` guards, `join: any`, `retry`/backoff, `approval`, `flow` composition, `budget` caps, `onBlock: "retry"`, `eval` machine gates, idle watchdog) on top of the DSL + DAG runtime (`agent`/`parallel`/`map`/`gate`/`reduce`). Inline + saved flows, cross-session resume, live progress, and isolated context. A run executes as one streaming tool call.
|
|
813
901
|
|
|
814
902
|
Known boundaries (tracked, bounded — no surprises mid-flow):
|
|
815
903
|
|
|
@@ -823,22 +911,26 @@ Known boundaries (tracked, bounded — no surprises mid-flow):
|
|
|
823
911
|
|
|
824
912
|
## Development
|
|
825
913
|
|
|
826
|
-
`taskflow` is
|
|
914
|
+
`taskflow` is a pnpm-workspace monorepo of seven published packages:
|
|
827
915
|
|
|
828
916
|
| Package | Role |
|
|
829
917
|
|---------|------|
|
|
830
|
-
| [`taskflow-core`](https://github.com/heggria/taskflow/blob/main/packages/taskflow-core) | Host-neutral orchestration engine (zero host-SDK deps; only `typebox`) |
|
|
918
|
+
| [`taskflow-core`](https://github.com/heggria/taskflow/blob/main/packages/taskflow-core) | Host-neutral orchestration engine (zero host-SDK deps; only `typebox`) — runtime, DSL, cache, verify |
|
|
919
|
+
| [`taskflow-mcp-core`](https://github.com/heggria/taskflow/blob/main/packages/taskflow-mcp-core) | Host-neutral MCP server (stdio JSON-RPC + `taskflow_*` tools + DAG renderer); depends on core |
|
|
920
|
+
| [`taskflow-hosts`](https://github.com/heggria/taskflow/blob/main/packages/taskflow-hosts) | Shared host-runner collection — the codex/claude/opencode `SubagentRunner` impls + their argv builders + event-stream parsers; depends on core |
|
|
831
921
|
| [`pi-taskflow`](https://github.com/heggria/taskflow/blob/main/packages/pi-taskflow) | Pi extension adapter — `taskflow` tool + `/tf` commands (what `pi install npm:pi-taskflow` gives you) |
|
|
832
|
-
| [`codex-taskflow`](https://github.com/heggria/taskflow/blob/main/packages/codex-taskflow) | Codex
|
|
922
|
+
| [`codex-taskflow`](https://github.com/heggria/taskflow/blob/main/packages/codex-taskflow) | Codex MCP server + bin + [Codex plugin](https://github.com/heggria/taskflow/blob/main/packages/codex-taskflow/plugin) (re-exports the runner from `taskflow-hosts`) ([guide](https://github.com/heggria/taskflow/blob/main/docs/codex-mcp.md)) |
|
|
923
|
+
| [`claude-taskflow`](https://github.com/heggria/taskflow/blob/main/packages/claude-taskflow) | Claude Code MCP server + bin + [Claude Code plugin](https://github.com/heggria/taskflow/blob/main/packages/claude-taskflow/plugin) (re-exports the runner from `taskflow-hosts`) ([guide](https://github.com/heggria/taskflow/blob/main/docs/claude-mcp.md)) |
|
|
924
|
+
| [`opencode-taskflow`](https://github.com/heggria/taskflow/blob/main/packages/opencode-taskflow) | OpenCode MCP server + bin + [OpenCode config scaffold](https://github.com/heggria/taskflow/blob/main/packages/opencode-taskflow/plugin) (re-exports the runner from `taskflow-hosts`) ([guide](https://github.com/heggria/taskflow/blob/main/docs/opencode-mcp.md)) |
|
|
833
925
|
|
|
834
926
|
```bash
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
927
|
+
pnpm install
|
|
928
|
+
pnpm run typecheck # tsc --noEmit across all packages (no build needed)
|
|
929
|
+
pnpm test # unit tests — no network, no process spawning
|
|
930
|
+
pnpm run test:hosts # host-runner tests only (also: test:pi, test:codex, test:claude, test:opencode)
|
|
931
|
+
pnpm run build # emit dist/*.js + .d.ts for all seven packages
|
|
932
|
+
pnpm run test:e2e-codex # codex executor e2e (needs `codex` + model access)
|
|
933
|
+
pnpm run test:e2e-codex-mcp # codex MCP server e2e
|
|
842
934
|
```
|
|
843
935
|
|
|
844
936
|
The pi end-to-end suites spawn live `pi` subagents and are run directly (they use
|
package/dist/agents.d.ts
CHANGED
|
@@ -13,9 +13,29 @@ export interface TaskflowSettings {
|
|
|
13
13
|
maxKeptRuns: number;
|
|
14
14
|
/** Maximum age (days) for completed/failed runs. 0 disables age cleanup. */
|
|
15
15
|
maxRunAgeDays: number;
|
|
16
|
+
/** Library (reusable-flow asset layer) settings. RFC: docs/rfc-library-reuse.md */
|
|
17
|
+
library: LibrarySettings;
|
|
18
|
+
/** Optional embedding backend for semantic search (Phase 2). Undefined = structural/keyword fallback. */
|
|
19
|
+
embedder?: EmbedderConfig;
|
|
16
20
|
}
|
|
21
|
+
import { type LibrarySettings } from "./library/types.ts";
|
|
17
22
|
export declare const DEFAULT_TASKFLOW_SETTINGS: TaskflowSettings;
|
|
18
23
|
export declare function normalizeTaskflowSettings(raw: unknown): TaskflowSettings;
|
|
24
|
+
/** RFC §4.2 config shapes: { kind: "http", url, model, apiKey?, dimensions? } or
|
|
25
|
+
* { kind: "command", command: string[], timeoutMs? }. */
|
|
26
|
+
export type EmbedderConfig = {
|
|
27
|
+
kind: "http";
|
|
28
|
+
url: string;
|
|
29
|
+
model: string;
|
|
30
|
+
apiKey?: string;
|
|
31
|
+
dimensions?: number;
|
|
32
|
+
} | {
|
|
33
|
+
kind: "command";
|
|
34
|
+
command: string[];
|
|
35
|
+
timeoutMs?: number;
|
|
36
|
+
};
|
|
37
|
+
export declare function normalizeLibrarySettings(raw: unknown): LibrarySettings;
|
|
38
|
+
export declare function normalizeEmbedderConfig(raw: unknown): EmbedderConfig | undefined;
|
|
19
39
|
export declare function shouldLoadBuiltinAgents(settings?: TaskflowSettings): boolean;
|
|
20
40
|
export declare function shouldSyncBuiltinAgentsToProject(settings?: TaskflowSettings): boolean;
|
|
21
41
|
export interface AgentConfig {
|
package/dist/agents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,MAAM,UAAU,GAAG,MAAM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ANGED
|
@@ -8,18 +8,22 @@ import * as path from "node:path";
|
|
|
8
8
|
import { getAgentDir } from "./paths.js";
|
|
9
9
|
import { parseFrontmatter } from "./frontmatter.js";
|
|
10
10
|
import { DEFAULT_KEPT_RUNS, DEFAULT_RUN_AGE_DAYS, writeFileAtomic } from "./store.js";
|
|
11
|
+
import { DEFAULT_LIBRARY_SETTINGS } from "./library/types.js";
|
|
11
12
|
export const DEFAULT_TASKFLOW_SETTINGS = {
|
|
12
13
|
builtInAgents: true,
|
|
13
14
|
syncBuiltinAgentsToProject: false,
|
|
14
15
|
maxKeptRuns: DEFAULT_KEPT_RUNS,
|
|
15
16
|
maxRunAgeDays: DEFAULT_RUN_AGE_DAYS,
|
|
17
|
+
library: { ...DEFAULT_LIBRARY_SETTINGS },
|
|
16
18
|
};
|
|
17
19
|
export function normalizeTaskflowSettings(raw) {
|
|
18
20
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
19
|
-
|
|
21
|
+
const base = { ...DEFAULT_TASKFLOW_SETTINGS, library: { ...DEFAULT_LIBRARY_SETTINGS } };
|
|
22
|
+
return base;
|
|
20
23
|
}
|
|
21
24
|
const rec = raw;
|
|
22
|
-
|
|
25
|
+
const embedder = normalizeEmbedderConfig(rec.embedder);
|
|
26
|
+
const base = {
|
|
23
27
|
builtInAgents: typeof rec.builtInAgents === "boolean"
|
|
24
28
|
? rec.builtInAgents
|
|
25
29
|
: DEFAULT_TASKFLOW_SETTINGS.builtInAgents,
|
|
@@ -32,8 +36,53 @@ export function normalizeTaskflowSettings(raw) {
|
|
|
32
36
|
maxRunAgeDays: typeof rec.maxRunAgeDays === "number" && rec.maxRunAgeDays >= 0 && Number.isInteger(rec.maxRunAgeDays)
|
|
33
37
|
? rec.maxRunAgeDays
|
|
34
38
|
: DEFAULT_TASKFLOW_SETTINGS.maxRunAgeDays,
|
|
39
|
+
library: normalizeLibrarySettings(rec.library),
|
|
40
|
+
};
|
|
41
|
+
if (embedder)
|
|
42
|
+
base.embedder = embedder;
|
|
43
|
+
return base;
|
|
44
|
+
}
|
|
45
|
+
export function normalizeLibrarySettings(raw) {
|
|
46
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
47
|
+
return { ...DEFAULT_LIBRARY_SETTINGS };
|
|
48
|
+
}
|
|
49
|
+
const rec = raw;
|
|
50
|
+
const scope = rec.scope === "project" || rec.scope === "user" || rec.scope === "both" ? rec.scope : "both";
|
|
51
|
+
const searchWeights = rec.searchWeights && typeof rec.searchWeights === "object"
|
|
52
|
+
? rec.searchWeights
|
|
53
|
+
: undefined;
|
|
54
|
+
const maxFlows = typeof rec.maxFlows === "number" && rec.maxFlows > 0 ? rec.maxFlows : undefined;
|
|
55
|
+
return {
|
|
56
|
+
enabled: typeof rec.enabled === "boolean" ? rec.enabled : true,
|
|
57
|
+
scope,
|
|
58
|
+
searchWeights,
|
|
59
|
+
maxFlows,
|
|
35
60
|
};
|
|
36
61
|
}
|
|
62
|
+
export function normalizeEmbedderConfig(raw) {
|
|
63
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
64
|
+
return undefined;
|
|
65
|
+
const rec = raw;
|
|
66
|
+
if (rec.kind === "http" && typeof rec.url === "string" && typeof rec.model === "string") {
|
|
67
|
+
const cfg = {
|
|
68
|
+
kind: "http",
|
|
69
|
+
url: rec.url,
|
|
70
|
+
model: rec.model,
|
|
71
|
+
};
|
|
72
|
+
if (typeof rec.apiKey === "string")
|
|
73
|
+
cfg.apiKey = rec.apiKey;
|
|
74
|
+
if (typeof rec.dimensions === "number")
|
|
75
|
+
cfg.dimensions = rec.dimensions;
|
|
76
|
+
return cfg;
|
|
77
|
+
}
|
|
78
|
+
if (rec.kind === "command" && Array.isArray(rec.command) && rec.command.every((c) => typeof c === "string")) {
|
|
79
|
+
const cfg = { kind: "command", command: rec.command };
|
|
80
|
+
if (typeof rec.timeoutMs === "number")
|
|
81
|
+
cfg.timeoutMs = rec.timeoutMs;
|
|
82
|
+
return cfg;
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
37
86
|
export function shouldLoadBuiltinAgents(settings = DEFAULT_TASKFLOW_SETTINGS) {
|
|
38
87
|
return settings.builtInAgents;
|
|
39
88
|
}
|
package/dist/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAepD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEtF,MAAM,CAAC,MAAM,yBAAyB,GAAqB;IAC1D,aAAa,EAAE,IAAI;IACnB,0BAA0B,EAAE,KAAK;IACjC,WAAW,EAAE,iBAAiB;IAC9B,aAAa,EAAE,oBAAoB;CACnC,CAAC;AAEF,MAAM,UAAU,yBAAyB,CAAC,GAAY;IACrD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACnE,OAAO,EAAE,GAAG,yBAAyB,EAAE,CAAC;IACzC,CAAC;IACD,MAAM,GAAG,GAAG,GAA8B,CAAC;IAC3C,OAAO;QACN,aAAa,EACZ,OAAO,GAAG,CAAC,aAAa,KAAK,SAAS;YACrC,CAAC,CAAC,GAAG,CAAC,aAAa;YACnB,CAAC,CAAC,yBAAyB,CAAC,aAAa;QAC3C,0BAA0B,EACzB,OAAO,GAAG,CAAC,0BAA0B,KAAK,SAAS;YAClD,CAAC,CAAC,GAAG,CAAC,0BAA0B;YAChC,CAAC,CAAC,yBAAyB,CAAC,0BA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CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAEpD,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC;YAAC,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,SAAS;QAAC,CAAC;QAEhE,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC;YAAC,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,2BAA2B,CAAC,CAAC;QAElF,sEAAsE;QACtE,IAAI,QAAQ,IAAI,QAAQ;YAAE,SAAS;QAEnC,IAAI,CAAC;YACJ,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC9C,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACR,sDAAsD;QACvD,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure decision functions a deterministic replay can call **without importing
|
|
3
|
+
* `runtime.ts`** (which drags in the process-spawning runner). These are the
|
|
4
|
+
* only runtime decisions that are (a) deterministic and (b) re-evaluable against
|
|
5
|
+
* recorded data: a gate verdict parsed from text, and a budget check tallied
|
|
6
|
+
* against recorded usage.
|
|
7
|
+
*
|
|
8
|
+
* Extracted from `runtime.ts` as a preparatory seam for 0.2.0 replay. The
|
|
9
|
+
* originals are re-exported from `runtime.ts` for backward compatibility; new
|
|
10
|
+
* pure consumers (replay) import from here.
|
|
11
|
+
*/
|
|
12
|
+
import { type UsageStats } from "./usage.ts";
|
|
13
|
+
/** A gate verdict parsed from a (possibly JSON, possibly free-text) output. */
|
|
14
|
+
export declare function parseGateVerdict(output: string): {
|
|
15
|
+
verdict: "pass" | "block";
|
|
16
|
+
reason?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Budget check against accumulated usage. Decoupled from `RunState`: takes the
|
|
20
|
+
* minimal structural input replay can assemble from a trace, so this module
|
|
21
|
+
* never imports `runtime.ts`.
|
|
22
|
+
*/
|
|
23
|
+
export interface BudgetCheckInput {
|
|
24
|
+
maxUSD?: number;
|
|
25
|
+
maxTokens?: number;
|
|
26
|
+
/** Per-phase recorded usage; summed with `aggregateUsage`. */
|
|
27
|
+
usages: (UsageStats | undefined)[];
|
|
28
|
+
}
|
|
29
|
+
export declare function overBudget(input: BudgetCheckInput): {
|
|
30
|
+
over: boolean;
|
|
31
|
+
reason: string;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=deterministic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deterministic.d.ts","sourceRoot":"","sources":["../src/deterministic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAA8B,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzE,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAwB/F;AAMD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,MAAM,EAAE,CAAC,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC;CACnC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,gBAAgB,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAUrF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure decision functions a deterministic replay can call **without importing
|
|
3
|
+
* `runtime.ts`** (which drags in the process-spawning runner). These are the
|
|
4
|
+
* only runtime decisions that are (a) deterministic and (b) re-evaluable against
|
|
5
|
+
* recorded data: a gate verdict parsed from text, and a budget check tallied
|
|
6
|
+
* against recorded usage.
|
|
7
|
+
*
|
|
8
|
+
* Extracted from `runtime.ts` as a preparatory seam for 0.2.0 replay. The
|
|
9
|
+
* originals are re-exported from `runtime.ts` for backward compatibility; new
|
|
10
|
+
* pure consumers (replay) import from here.
|
|
11
|
+
*/
|
|
12
|
+
import { safeParse } from "./interpolate.js";
|
|
13
|
+
import { VERDICT_TOKEN_RE } from "./scorers.js";
|
|
14
|
+
import { aggregateUsage, emptyUsage } from "./usage.js";
|
|
15
|
+
/** A gate verdict parsed from a (possibly JSON, possibly free-text) output. */
|
|
16
|
+
export function parseGateVerdict(output) {
|
|
17
|
+
const json = safeParse(output);
|
|
18
|
+
if (json && typeof json === "object") {
|
|
19
|
+
const o = json;
|
|
20
|
+
if (typeof o.continue === "boolean")
|
|
21
|
+
return { verdict: o.continue ? "pass" : "block", reason: asReason(o.reason) };
|
|
22
|
+
if (typeof o.pass === "boolean")
|
|
23
|
+
return { verdict: o.pass ? "pass" : "block", reason: asReason(o.reason) };
|
|
24
|
+
if (typeof o.verdict === "string") {
|
|
25
|
+
// Note: do NOT include standalone "no" — natural-language verdicts like
|
|
26
|
+
// "No issues found" / "no errors" would otherwise be false-positive BLOCK.
|
|
27
|
+
// An explicit non-blocking verdict word is a semantic PASS, not ambiguity:
|
|
28
|
+
// fail-closed below only applies when NO verdict could be parsed at all.
|
|
29
|
+
const block = /block|fail|stop|reject|halt/i.test(o.verdict);
|
|
30
|
+
return { verdict: block ? "block" : "pass", reason: asReason(o.reason) };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const matches = [...output.matchAll(VERDICT_TOKEN_RE)];
|
|
34
|
+
if (matches.length) {
|
|
35
|
+
const v = matches[matches.length - 1][1].toUpperCase();
|
|
36
|
+
const pass = v === "PASS" || v === "OK";
|
|
37
|
+
return { verdict: pass ? "pass" : "block" };
|
|
38
|
+
}
|
|
39
|
+
return { verdict: "block", reason: "unparseable gate verdict (fail-closed)" };
|
|
40
|
+
}
|
|
41
|
+
function asReason(v) {
|
|
42
|
+
return typeof v === "string" && v.trim() ? v.trim() : undefined;
|
|
43
|
+
}
|
|
44
|
+
export function overBudget(input) {
|
|
45
|
+
if (input.maxUSD === undefined && input.maxTokens === undefined)
|
|
46
|
+
return { over: false, reason: "" };
|
|
47
|
+
const u = aggregateUsage(input.usages.map((u) => u ?? emptyUsage()));
|
|
48
|
+
if (input.maxUSD !== undefined && u.cost > input.maxUSD) {
|
|
49
|
+
return { over: true, reason: `cost $${u.cost.toFixed(3)} exceeded cap $${input.maxUSD}` };
|
|
50
|
+
}
|
|
51
|
+
if (input.maxTokens !== undefined && u.input + u.output > input.maxTokens) {
|
|
52
|
+
return { over: true, reason: `tokens ${u.input + u.output} exceeded cap ${input.maxTokens}` };
|
|
53
|
+
}
|
|
54
|
+
return { over: false, reason: "" };
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=deterministic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deterministic.js","sourceRoot":"","sources":["../src/deterministic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAmB,MAAM,YAAY,CAAC;AAEzE,+EAA+E;AAC/E,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC9C,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAC/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E,CAAC;IAC/F,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/flowir/translate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EACX,YAAY,EACZ,cAAc,EAEd,MAAM,EAEN,cAAc,EACd,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/flowir/translate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EACX,YAAY,EACZ,cAAc,EAEd,MAAM,EAEN,cAAc,EACd,MAAM,WAAW,CAAC;AAoEnB;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,GAAG;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;CAC1B,CAoEA"}
|