codex-taskflow 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/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/bin.d.ts +2 -1
- package/dist/mcp/bin.d.ts.map +1 -1
- package/dist/mcp/bin.js +3 -2
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/server.d.ts +8 -24
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +12 -392
- package/dist/mcp/server.js.map +1 -1
- package/package.json +22 -9
- package/dist/codex-runner.d.ts +0 -59
- package/dist/codex-runner.d.ts.map +0 -1
- package/dist/codex-runner.js +0 -332
- package/dist/codex-runner.js.map +0 -1
- package/dist/mcp/jsonrpc.d.ts +0 -54
- package/dist/mcp/jsonrpc.d.ts.map +0 -1
- package/dist/mcp/jsonrpc.js +0 -118
- package/dist/mcp/jsonrpc.js.map +0 -1
- package/dist/mcp/svg.d.ts +0 -50
- package/dist/mcp/svg.d.ts.map +0 -1
- package/dist/mcp/svg.js +0 -310
- package/dist/mcp/svg.js.map +0 -1
package/dist/mcp/server.js
CHANGED
|
@@ -1,403 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The Codex binding of the host-neutral MCP server (taskflow-mcp-core/server).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the whole thing closes the loop with no pi process required.
|
|
9
|
-
*
|
|
10
|
-
* Protocol: MCP over stdio, JSON-RPC 2.0 (newline-delimited). Implemented on the
|
|
11
|
-
* dependency-free transport in ./jsonrpc.ts — pi-taskflow keeps its zero-runtime
|
|
12
|
-
* -deps guarantee; we do NOT use @modelcontextprotocol/sdk.
|
|
13
|
-
*
|
|
14
|
-
* Tools exposed:
|
|
15
|
-
* - taskflow_run : run an inline or saved flow, return the final output
|
|
16
|
-
* - taskflow_list : list saved flows discoverable in this cwd
|
|
17
|
-
* - taskflow_show : show a saved flow's definition
|
|
18
|
-
* - taskflow_verify : statically verify a flow (no execution)
|
|
19
|
-
* - taskflow_compile : render a flow as a DAG diagram (SVG image) + status line
|
|
20
|
-
*/
|
|
21
|
-
import { RpcError, RPC, serveStdio } from "./jsonrpc.js";
|
|
22
|
-
import { codexSubagentRunner } from "../codex-runner.js";
|
|
23
|
-
import { renderFlowSvg, renderFlowOutline, svgToBase64 } from "./svg.js";
|
|
24
|
-
import { discoverAgents, executeTaskflow, getFlow, listFlows, newRunId, peekRun, saveRun, DEFAULT_KEPT_RUNS, DEFAULT_RUN_AGE_DAYS, compileTaskflow, verifyTaskflow, desugar, isShorthand, validateTaskflow, readSubagentSettings, } from "taskflow-core";
|
|
25
|
-
const PROTOCOL_VERSION = "2025-06-18";
|
|
26
|
-
const SERVER_INFO = { name: "taskflow", title: "Taskflow", version: "0.1.3" };
|
|
27
|
-
/**
|
|
28
|
-
* MCP tools/call result with a single text block.
|
|
29
|
-
*
|
|
30
|
-
* IMPORTANT (Codex rendering): the Codex desktop app renders a `text` content
|
|
31
|
-
* block as a fixed grey "plaintext" <pre> box — it does NOT parse markdown or
|
|
32
|
-
* highlight code, wraps on whitespace, and caps the box at ~192px tall with an
|
|
33
|
-
* inner scroll. So text here is written as *plain text*: no ```fences```, no
|
|
34
|
-
* markdown tables, conclusion-first, and near-duplicate lines collapsed. Rich
|
|
35
|
-
* rendering (structuredContent/_meta) is gated to Codex's first-party "Apps"
|
|
36
|
-
* server, so third-party MCP output can't opt into it. See docs/codex-mcp.md.
|
|
37
|
-
*/
|
|
38
|
-
function textContent(text, isError = false) {
|
|
39
|
-
return { content: [{ type: "text", text }], isError };
|
|
40
|
-
}
|
|
41
|
-
/** An MCP `image` content block, optionally followed by text blocks. Codex's
|
|
42
|
-
* desktop app renders the image as `<img src="data:…">` (an inline SVG shows as
|
|
43
|
-
* a real diagram) and shows the trailing text as a caption. The CLI/TUI can't
|
|
44
|
-
* render images — it prints a bare `<image content>` placeholder — so the
|
|
45
|
-
* trailing text MUST be self-sufficient there (and for vision-less models). */
|
|
46
|
-
function imageContent(base64, mimeType, texts, isError = false) {
|
|
47
|
-
const content = [{ type: "image", data: base64, mimeType }];
|
|
48
|
-
for (const t of texts)
|
|
49
|
-
if (t)
|
|
50
|
-
content.push({ type: "text", text: t });
|
|
51
|
-
return { content, isError };
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Collapse near-identical validation messages so N phases hitting the same rule
|
|
55
|
-
* render as one line with a count instead of N wall-of-text repeats (the exact
|
|
56
|
-
* ugliness this file is fighting). Strips a leading `Phase '<id>': ` / `Phase
|
|
57
|
-
* '<id>' ` prefix, groups by the remaining message, and lists the affected ids.
|
|
58
|
-
*/
|
|
59
|
-
function dedupeMessages(msgs) {
|
|
60
|
-
const groups = new Map();
|
|
61
|
-
const order = [];
|
|
62
|
-
for (const raw of msgs) {
|
|
63
|
-
const m = raw.match(/^Phase '([^']+)':?\s+(.*)$/s);
|
|
64
|
-
const key = m ? m[2] : raw;
|
|
65
|
-
const id = m ? m[1] : "";
|
|
66
|
-
if (!groups.has(key)) {
|
|
67
|
-
groups.set(key, []);
|
|
68
|
-
order.push(key);
|
|
69
|
-
}
|
|
70
|
-
if (id)
|
|
71
|
-
groups.get(key).push(id);
|
|
72
|
-
}
|
|
73
|
-
return order.map((key) => {
|
|
74
|
-
const ids = groups.get(key);
|
|
75
|
-
if (ids.length === 0)
|
|
76
|
-
return key;
|
|
77
|
-
if (ids.length === 1)
|
|
78
|
-
return `${key} (phase ${ids[0]})`;
|
|
79
|
-
const shown = ids.slice(0, 4).join(", ");
|
|
80
|
-
const more = ids.length > 4 ? ` +${ids.length - 4} more` : "";
|
|
81
|
-
return `${key} (${ids.length} phases: ${shown}${more})`;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Render verification issues as deduped, conclusion-friendly "Errors:" /
|
|
86
|
-
* "Warnings:" plaintext blocks. `extraErrors`/`extraWarnings` fold in the raw
|
|
87
|
-
* string messages from `validateTaskflow` so structural + quality issues share
|
|
88
|
-
* one deduped view. Shared by taskflow_verify and taskflow_compile's fallback.
|
|
89
|
-
*/
|
|
90
|
-
function issueBlocks(issues, extraErrors = [], extraWarnings = []) {
|
|
91
|
-
const toStr = (i) =>
|
|
92
|
-
// verifyTaskflow messages already embed the phase id in prose ("Phase 'x'
|
|
93
|
-
// is a terminal phase…"); only prepend the id for messages that don't, so
|
|
94
|
-
// dedupeMessages can strip one consistent prefix and collapse same-rule hits.
|
|
95
|
-
i.phaseId && !/^Phase '/.test(i.message) ? `Phase '${i.phaseId}': ${i.message}` : i.message;
|
|
96
|
-
const rawErrors = [...extraErrors, ...issues.filter((i) => i.severity === "error").map(toStr)];
|
|
97
|
-
const rawWarnings = [...extraWarnings, ...issues.filter((i) => i.severity === "warning").map(toStr)];
|
|
98
|
-
// Count reflects the true number of issues; the lines below are the *deduped*
|
|
99
|
-
// compact view (N same-rule hits collapse to one line + a phase list).
|
|
100
|
-
const errors = dedupeMessages(rawErrors);
|
|
101
|
-
const warnings = dedupeMessages(rawWarnings);
|
|
102
|
-
const errBlock = errors.length ? `\n\nErrors:\n${errors.map((e) => `- ${e}`).join("\n")}` : "";
|
|
103
|
-
const warnBlock = warnings.length ? `\n\nWarnings:\n${warnings.map((w) => `- ${w}`).join("\n")}` : "";
|
|
104
|
-
return { errorCount: rawErrors.length, warningCount: rawWarnings.length, text: `${errBlock}${warnBlock}` };
|
|
105
|
-
}
|
|
106
|
-
/** Pluralize a count for a compact status line. */
|
|
107
|
-
function count(n, noun) {
|
|
108
|
-
return `${n} ${noun}${n === 1 ? "" : "s"}`;
|
|
109
|
-
}
|
|
110
|
-
const TOOLS = [
|
|
111
|
-
{
|
|
112
|
-
name: "taskflow_run",
|
|
113
|
-
title: "Run a taskflow",
|
|
114
|
-
description: "Run a taskflow DAG and return its final output. Provide EITHER `name` (a saved flow) OR `define` (an inline flow definition: {name, phases:[…]} or a shorthand {task} / {tasks} / {chain}). Subagents execute as codex sessions. Intermediate phase outputs stay in the runtime; only the final phase output is returned — the reported runId can be passed to taskflow_peek to inspect intermediate phase outputs afterwards.",
|
|
115
|
-
inputSchema: {
|
|
116
|
-
type: "object",
|
|
117
|
-
additionalProperties: false,
|
|
118
|
-
properties: {
|
|
119
|
-
name: { type: "string", description: "Name of a saved flow to run." },
|
|
120
|
-
define: { type: "object", description: "Inline flow definition (full DAG or shorthand)." },
|
|
121
|
-
args: { type: "object", description: "Invocation arguments interpolated as {args.X}." },
|
|
122
|
-
incremental: { type: "boolean", description: "Default every phase to cross-run cache reuse." },
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
name: "taskflow_list",
|
|
128
|
-
title: "List saved taskflows",
|
|
129
|
-
description: "List the saved taskflows discoverable from the current working directory (user + project scope).",
|
|
130
|
-
inputSchema: { type: "object", additionalProperties: false, properties: {} },
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: "taskflow_show",
|
|
134
|
-
title: "Show a saved taskflow",
|
|
135
|
-
description: "Show a saved flow's full definition as JSON.",
|
|
136
|
-
inputSchema: {
|
|
137
|
-
type: "object",
|
|
138
|
-
additionalProperties: false,
|
|
139
|
-
properties: { name: { type: "string", description: "Name of the saved flow." } },
|
|
140
|
-
required: ["name"],
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: "taskflow_verify",
|
|
145
|
-
title: "Verify a taskflow",
|
|
146
|
-
description: "Statically verify a flow (cycles, missing deps, undefined refs, …) WITHOUT executing it. Provide `name` or `define`.",
|
|
147
|
-
inputSchema: {
|
|
148
|
-
type: "object",
|
|
149
|
-
additionalProperties: false,
|
|
150
|
-
properties: {
|
|
151
|
-
name: { type: "string" },
|
|
152
|
-
define: { type: "object" },
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
name: "taskflow_compile",
|
|
158
|
-
title: "Compile a taskflow to a diagram",
|
|
159
|
-
description: "Render a flow's DAG as a diagram (an inline SVG image) with issues overlaid (red=error, amber=warning, green=final), plus a compact status line. No execution. Provide `name` or `define`.",
|
|
160
|
-
inputSchema: {
|
|
161
|
-
type: "object",
|
|
162
|
-
additionalProperties: false,
|
|
163
|
-
properties: {
|
|
164
|
-
name: { type: "string" },
|
|
165
|
-
define: { type: "object" },
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
name: "taskflow_peek",
|
|
171
|
-
title: "Peek at a run's phase output",
|
|
172
|
-
description: "Inspect one phase's intermediate output from a stored run (post-hoc debugging). Use the runId reported by taskflow_run. Omit `phaseId` to list the run's phases. Output is hard-truncated (default 4000 chars) so a peek never floods the context window. Read-only.",
|
|
173
|
-
inputSchema: {
|
|
174
|
-
type: "object",
|
|
175
|
-
additionalProperties: false,
|
|
176
|
-
properties: {
|
|
177
|
-
runId: { type: "string", description: "The run to inspect (from a prior taskflow_run or the runs index)." },
|
|
178
|
-
phaseId: { type: "string", description: "Phase to peek at. Omit to list all phases with status + output size." },
|
|
179
|
-
json: { type: "boolean", description: "Return the phase's parsed JSON instead of its text output." },
|
|
180
|
-
item: { type: "number", description: "For map/parallel phases: the 1-based item section to extract." },
|
|
181
|
-
limit: { type: "number", description: "Truncation cap in chars (default 4000, max 32000)." },
|
|
182
|
-
},
|
|
183
|
-
required: ["runId"],
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
];
|
|
187
|
-
/** Resolve a flow from params: inline `define` (desugared) or saved `name`. */
|
|
188
|
-
function resolveFlow(cwd, params) {
|
|
189
|
-
if (params.define !== undefined && params.define !== null) {
|
|
190
|
-
return isShorthand(params.define) ? desugar(params.define) : params.define;
|
|
191
|
-
}
|
|
192
|
-
if (params.name) {
|
|
193
|
-
const saved = getFlow(cwd, params.name);
|
|
194
|
-
if (!saved)
|
|
195
|
-
throw new RpcError(RPC.INVALID_PARAMS, `No saved flow named "${params.name}" found from ${cwd}.`);
|
|
196
|
-
return saved.def;
|
|
197
|
-
}
|
|
198
|
-
throw new RpcError(RPC.INVALID_PARAMS, "Provide either `name` (a saved flow) or `define` (an inline flow).");
|
|
199
|
-
}
|
|
200
|
-
function mkRunState(def, args, cwd) {
|
|
201
|
-
return {
|
|
202
|
-
runId: newRunId(def.name ?? "flow"),
|
|
203
|
-
flowName: def.name ?? "flow",
|
|
204
|
-
def,
|
|
205
|
-
args,
|
|
206
|
-
status: "running",
|
|
207
|
-
phases: {},
|
|
208
|
-
createdAt: Date.now(),
|
|
209
|
-
updatedAt: Date.now(),
|
|
210
|
-
cwd,
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Build the per-call tool handlers. `cwd` is the directory the server was
|
|
215
|
-
* launched in (where saved flows + agents are discovered, and where codex
|
|
216
|
-
* subagents run).
|
|
4
|
+
* The protocol layer, tool schemas, and handlers all live in core; this shim
|
|
5
|
+
* only closes the loop for Codex: every subagent a flow spawns is itself a
|
|
6
|
+
* `codex exec` process (via codexSubagentRunner). Kept as a module (not just
|
|
7
|
+
* bin.ts) so tests and embedders get the same pre-bound surface the bin runs.
|
|
217
8
|
*/
|
|
9
|
+
import { makeMcpHandlers as coreMakeMcpHandlers, makeToolHandlers as coreMakeToolHandlers, startMcpServer as coreStartMcpServer, } from "taskflow-mcp-core/server";
|
|
10
|
+
import { codexSubagentRunner } from "taskflow-hosts";
|
|
11
|
+
/** Per-call tool handlers with codex subagent execution bound in. */
|
|
218
12
|
export function makeToolHandlers(cwd) {
|
|
219
|
-
return
|
|
220
|
-
taskflow_run: async (args) => {
|
|
221
|
-
const def = resolveFlow(cwd, args);
|
|
222
|
-
const v = validateTaskflow(def);
|
|
223
|
-
if (!v.ok)
|
|
224
|
-
return textContent(`Flow is invalid:\n- ${v.errors.join("\n- ")}`, true);
|
|
225
|
-
// Resolve model roles (e.g. {{fast}} -> a real model id) so the built-in
|
|
226
|
-
// agents' placeholder models map to something codex can launch. This is
|
|
227
|
-
// the same lookup the pi adapter does; without it every phase fails with
|
|
228
|
-
// "Model metadata for {{fast}} not found".
|
|
229
|
-
const settings = readSubagentSettings();
|
|
230
|
-
const { agents } = discoverAgents(cwd, "both", settings.modelRoles, settings.taskflow);
|
|
231
|
-
const deps = {
|
|
232
|
-
cwd,
|
|
233
|
-
agents,
|
|
234
|
-
runTask: codexSubagentRunner.runTask,
|
|
235
|
-
};
|
|
236
|
-
const state = mkRunState(def, args.args ?? {}, cwd);
|
|
237
|
-
if (args.incremental === true)
|
|
238
|
-
deps.cacheScopeDefault = "cross-run";
|
|
239
|
-
// Persist run state (throttled + final) so taskflow_peek / resume can read
|
|
240
|
-
// intermediate phase outputs after the run — same contract as the pi adapter.
|
|
241
|
-
const cleanupConfig = { maxKeep: DEFAULT_KEPT_RUNS, maxAgeDays: DEFAULT_RUN_AGE_DAYS };
|
|
242
|
-
let lastPersist = 0;
|
|
243
|
-
deps.persist = (s) => {
|
|
244
|
-
const now = Date.now();
|
|
245
|
-
if (now - lastPersist >= 1000) {
|
|
246
|
-
lastPersist = now;
|
|
247
|
-
saveRun(s, cleanupConfig);
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
const res = await executeTaskflow(state, deps).finally(() => {
|
|
251
|
-
// Terminal persist must survive a throwing runtime ("never lose work") —
|
|
252
|
-
// and persistence itself must never sink a completed run.
|
|
253
|
-
try {
|
|
254
|
-
saveRun(state, cleanupConfig);
|
|
255
|
-
}
|
|
256
|
-
catch {
|
|
257
|
-
/* fail-open */
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
const header = res.ok ? "✓ taskflow complete" : "✗ taskflow did not fully succeed";
|
|
261
|
-
const u = res.totalUsage;
|
|
262
|
-
const usageLine = `\n\n— ${u.turns} turns · in ${u.input} · out ${u.output} tokens · run ${state.runId}`;
|
|
263
|
-
return textContent(`${header}\n\n${res.finalOutput}${usageLine}`, !res.ok);
|
|
264
|
-
},
|
|
265
|
-
taskflow_peek: async (args) => {
|
|
266
|
-
const runId = String(args.runId ?? "");
|
|
267
|
-
if (!runId)
|
|
268
|
-
return textContent("taskflow_peek requires `runId`.", true);
|
|
269
|
-
const res = peekRun(cwd, runId, {
|
|
270
|
-
phaseId: typeof args.phaseId === "string" ? args.phaseId : undefined,
|
|
271
|
-
json: args.json === true,
|
|
272
|
-
item: typeof args.item === "number" ? args.item : undefined,
|
|
273
|
-
limit: typeof args.limit === "number" ? args.limit : undefined,
|
|
274
|
-
});
|
|
275
|
-
return textContent(res.text, !res.ok);
|
|
276
|
-
},
|
|
277
|
-
taskflow_list: async () => {
|
|
278
|
-
const flows = listFlows(cwd);
|
|
279
|
-
if (flows.length === 0)
|
|
280
|
-
return textContent("No saved taskflows found from this directory.");
|
|
281
|
-
const lines = flows.map((f) => `- ${f.name} (${f.scope}) — ${f.def.phases.length} phase(s)`);
|
|
282
|
-
return textContent(`Saved taskflows:\n${lines.join("\n")}`);
|
|
283
|
-
},
|
|
284
|
-
taskflow_show: async (args) => {
|
|
285
|
-
const name = String(args.name ?? "");
|
|
286
|
-
const saved = getFlow(cwd, name);
|
|
287
|
-
if (!saved)
|
|
288
|
-
return textContent(`No saved flow named "${name}".`, true);
|
|
289
|
-
// No ```json``` fence: Codex shows text blocks as raw plaintext, so a fence
|
|
290
|
-
// would render as literal backticks. The JSON is already monospaced there.
|
|
291
|
-
return textContent(JSON.stringify(saved.def, null, 2));
|
|
292
|
-
},
|
|
293
|
-
taskflow_verify: async (args) => {
|
|
294
|
-
const def = resolveFlow(cwd, args);
|
|
295
|
-
const val = validateTaskflow(def);
|
|
296
|
-
// verifyTaskflow iterates flow.phases and throws if it isn't an array
|
|
297
|
-
// (e.g. a missing `phases`). Only skip it in that unsafe case; otherwise
|
|
298
|
-
// run it so its static-quality warnings (e.g. terminal-not-final) still
|
|
299
|
-
// surface alongside validateTaskflow's structural errors.
|
|
300
|
-
const phasesIterable = Array.isArray(def.phases);
|
|
301
|
-
const result = phasesIterable
|
|
302
|
-
? verifyTaskflow(def)
|
|
303
|
-
: { ok: false, issues: [] };
|
|
304
|
-
const { errorCount, warningCount, text } = issueBlocks(result.issues, val.errors, val.warnings);
|
|
305
|
-
const passed = val.ok && result.ok && errorCount === 0;
|
|
306
|
-
// Conclusion-first (the plaintext box is short + scrolls): verdict + counts
|
|
307
|
-
// on line 1, deduped detail below.
|
|
308
|
-
const head = passed
|
|
309
|
-
? warningCount
|
|
310
|
-
? `✓ verification PASSED — ${count(warningCount, "warning")}`
|
|
311
|
-
: "✓ verification PASSED"
|
|
312
|
-
: `✗ verification FAILED — ${count(errorCount, "error")}, ${count(warningCount, "warning")}`;
|
|
313
|
-
return textContent(`${head}${text}`, !passed);
|
|
314
|
-
},
|
|
315
|
-
taskflow_compile: async (args) => {
|
|
316
|
-
const def = resolveFlow(cwd, args);
|
|
317
|
-
const val = validateTaskflow(def);
|
|
318
|
-
// compileTaskflow / verifyTaskflow / renderFlowSvg all assume phases is an
|
|
319
|
-
// array of objects that each have a string id (they iterate it and index
|
|
320
|
-
// id.replace(...)). A hard-malformed def (non-array phases, a phase missing
|
|
321
|
-
// its id) would throw, so when the shape isn't renderable we return the
|
|
322
|
-
// structured validation errors as text instead of rendering.
|
|
323
|
-
const phases = def.phases;
|
|
324
|
-
const renderable = Array.isArray(phases) && phases.every((p) => p != null && typeof p.id === "string");
|
|
325
|
-
if (!renderable) {
|
|
326
|
-
const { errorCount, warningCount, text } = issueBlocks([], val.errors, val.warnings);
|
|
327
|
-
const caption = `${def.name ?? "taskflow"} — ${count(errorCount, "error")} · ${count(warningCount, "warning")} · ✗ FAIL`;
|
|
328
|
-
return textContent(`${caption}${text}`, true);
|
|
329
|
-
}
|
|
330
|
-
// Merge structural validation into the compile report. compileTaskflow's
|
|
331
|
-
// own verification.ok is true even for a structurally-invalid (but
|
|
332
|
-
// renderable) flow, so a validate-clean check is what stops a false ✓ PASS.
|
|
333
|
-
// We still render the diagram + outline so such a flow can be inspected
|
|
334
|
-
// visually; truncate coerces non-string fields so the renderer won't throw.
|
|
335
|
-
const result = compileTaskflow(def);
|
|
336
|
-
const v = result.verification;
|
|
337
|
-
const { errorCount, warningCount, text } = issueBlocks(v.issues, val.errors, val.warnings);
|
|
338
|
-
const passed = val.ok && v.ok && errorCount === 0;
|
|
339
|
-
const status = passed ? "✓ PASS" : "✗ FAIL";
|
|
340
|
-
const caption = `${def.name ?? "taskflow"} — ${count(def.phases?.length ?? 0, "phase")} · ${count(errorCount, "error")} · ${count(warningCount, "warning")} · ${status}`;
|
|
341
|
-
// A text outline that stands on its own — the CLI/TUI can't render images
|
|
342
|
-
// (it shows a bare `<image content>` placeholder), and a vision-less model
|
|
343
|
-
// would otherwise see nothing. Includes the layered DAG + deduped issues.
|
|
344
|
-
const outline = renderFlowOutline(def, v);
|
|
345
|
-
const textReport = `${caption}\n\n${outline}${text}`;
|
|
346
|
-
// Fold validation errors into the issue set the SVG colors by, so node
|
|
347
|
-
// coloring matches the text report (a phase with only a validation error
|
|
348
|
-
// still shows red). Validation messages start with `Phase '<id>':`.
|
|
349
|
-
const mergedVerification = {
|
|
350
|
-
...v,
|
|
351
|
-
ok: passed,
|
|
352
|
-
issues: [
|
|
353
|
-
...v.issues,
|
|
354
|
-
...val.errors.map((message) => {
|
|
355
|
-
const m = /^Phase '([^']+)'/.exec(message);
|
|
356
|
-
return { phaseId: m?.[1], message, severity: "error", category: "ref-integrity" };
|
|
357
|
-
}),
|
|
358
|
-
],
|
|
359
|
-
};
|
|
360
|
-
// Desktop app: the SVG image renders as a real diagram; the outline rides
|
|
361
|
-
// along as its caption/fallback. Oversized graphs skip the image and rely
|
|
362
|
-
// on the text report alone.
|
|
363
|
-
const svg = renderFlowSvg(def, mergedVerification);
|
|
364
|
-
if (svg)
|
|
365
|
-
return imageContent(svgToBase64(svg), "image/svg+xml", [textReport], !passed);
|
|
366
|
-
return textContent(textReport, !passed);
|
|
367
|
-
},
|
|
368
|
-
};
|
|
13
|
+
return coreMakeToolHandlers(cwd, codexSubagentRunner);
|
|
369
14
|
}
|
|
370
|
-
/**
|
|
15
|
+
/** Full MCP method dispatch table (protocol + tools), codex-bound. */
|
|
371
16
|
export function makeMcpHandlers(cwd) {
|
|
372
|
-
|
|
373
|
-
let initialized = false;
|
|
374
|
-
return {
|
|
375
|
-
initialize: () => {
|
|
376
|
-
initialized = true;
|
|
377
|
-
return {
|
|
378
|
-
protocolVersion: PROTOCOL_VERSION,
|
|
379
|
-
capabilities: { tools: { listChanged: false } },
|
|
380
|
-
serverInfo: SERVER_INFO,
|
|
381
|
-
};
|
|
382
|
-
},
|
|
383
|
-
// Client tells us it's ready — notification, no response.
|
|
384
|
-
"notifications/initialized": () => {
|
|
385
|
-
initialized = true;
|
|
386
|
-
},
|
|
387
|
-
ping: () => ({}),
|
|
388
|
-
"tools/list": () => ({ tools: TOOLS }),
|
|
389
|
-
"tools/call": async (params) => {
|
|
390
|
-
const p = (params ?? {});
|
|
391
|
-
const tool = tools[p.name ?? ""];
|
|
392
|
-
if (!tool)
|
|
393
|
-
throw new RpcError(RPC.INVALID_PARAMS, `Unknown tool: ${p.name}`);
|
|
394
|
-
void initialized; // tolerant: we don't hard-gate on initialize ordering
|
|
395
|
-
return await tool(p.arguments ?? {});
|
|
396
|
-
},
|
|
397
|
-
};
|
|
17
|
+
return coreMakeMcpHandlers(cwd, codexSubagentRunner);
|
|
398
18
|
}
|
|
399
19
|
/** Start the stdio MCP server. Resolves when the client disconnects. */
|
|
400
20
|
export function startMcpServer(cwd = process.cwd()) {
|
|
401
|
-
return
|
|
21
|
+
return coreStartMcpServer(codexSubagentRunner, cwd);
|
|
402
22
|
}
|
|
403
23
|
//# sourceMappingURL=server.js.map
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","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AAI,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAC7E,KAAK,WAAW,CAAC,CAAC,sDAAsD;YACxE,OAAO,MAAM,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QACtC,CAAC;KACD,CAAC;AACH,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,cAAc,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;IACzD,OAAO,UAAU,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,eAAe,IAAI,mBAAmB,EACtC,gBAAgB,IAAI,oBAAoB,EACxC,cAAc,IAAI,kBAAkB,GACpC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,qEAAqE;AACrE,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC3C,OAAO,oBAAoB,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;AACvD,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,GAAW;IAC1C,OAAO,mBAAmB,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;AACtD,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,cAAc,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;IACzD,OAAO,kBAAkB,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;AACrD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-taskflow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Run taskflow on OpenAI Codex: a Codex subagent runner plus an MCP server (and a plug-and-play Codex plugin) that exposes the taskflow_* tools to Codex users.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codex",
|
|
@@ -26,22 +26,35 @@
|
|
|
26
26
|
"engines": {
|
|
27
27
|
"node": ">=22.19.0"
|
|
28
28
|
},
|
|
29
|
-
"main": "./dist/
|
|
30
|
-
"types": "./dist/
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"development": "./src/index.ts",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./mcp/server": {
|
|
38
|
+
"development": "./src/mcp/server.ts",
|
|
39
|
+
"types": "./dist/mcp/server.d.ts",
|
|
40
|
+
"default": "./dist/mcp/server.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
31
43
|
"bin": {
|
|
32
44
|
"codex-taskflow-mcp": "./dist/mcp/bin.js"
|
|
33
45
|
},
|
|
34
46
|
"files": [
|
|
35
47
|
"dist"
|
|
36
48
|
],
|
|
37
|
-
"scripts": {
|
|
38
|
-
"build": "tsc -p tsconfig.build.json && node ../../scripts/copy-readme.mjs codex-taskflow",
|
|
39
|
-
"prepublishOnly": "npm run build"
|
|
40
|
-
},
|
|
41
49
|
"publishConfig": {
|
|
42
50
|
"access": "public"
|
|
43
51
|
},
|
|
44
52
|
"dependencies": {
|
|
45
|
-
"taskflow-core": "0.1.
|
|
53
|
+
"taskflow-core": "0.1.7",
|
|
54
|
+
"taskflow-hosts": "0.1.7",
|
|
55
|
+
"taskflow-mcp-core": "0.1.7"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && node ../../scripts/copy-readme.mjs codex-taskflow"
|
|
46
59
|
}
|
|
47
|
-
}
|
|
60
|
+
}
|
package/dist/codex-runner.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codex subagent runner — the Codex host's `SubagentRunner` implementation.
|
|
3
|
-
*
|
|
4
|
-
* Spawns an isolated `codex exec --json` process per task and folds its JSONL
|
|
5
|
-
* event stream into the same host-neutral `RunResult` the pi runner produces,
|
|
6
|
-
* so the engine (runtime.ts) treats a Codex subagent identically to a pi one.
|
|
7
|
-
*
|
|
8
|
-
* Real codex JSONL schema (codex-cli ≥ 0.142), observed empirically:
|
|
9
|
-
* {"type":"thread.started","thread_id":"…"}
|
|
10
|
-
* {"type":"turn.started"}
|
|
11
|
-
* {"type":"item.started", "item":{"id","type":"command_execution","command","status":"in_progress",…}}
|
|
12
|
-
* {"type":"item.completed","item":{"id","type":"command_execution","command","exit_code","status":"completed",…}}
|
|
13
|
-
* {"type":"item.completed","item":{"id","type":"agent_message","text":"…"}} ← final answer
|
|
14
|
-
* {"type":"item.completed","item":{"id","type":"error","message":"…"}} ← warning OR fatal
|
|
15
|
-
* {"type":"turn.completed","usage":{"input_tokens","cached_input_tokens","output_tokens","reasoning_output_tokens"}}
|
|
16
|
-
*
|
|
17
|
-
* Mapping to the pi contract:
|
|
18
|
-
* - output = text of the LAST `agent_message` item
|
|
19
|
-
* - usage.input = input_tokens; usage.output = output_tokens + reasoning_output_tokens;
|
|
20
|
-
* usage.cacheRead = cached_input_tokens; turns = number of `turn.completed`
|
|
21
|
-
* - lastActivity for streaming = latest agent_message text or a one-line
|
|
22
|
-
* command summary
|
|
23
|
-
* - benign warnings (the "Under-development features" / "Skill descriptions"
|
|
24
|
-
* notices) are NOT treated as failures — only a fatal error item or a
|
|
25
|
-
* non-zero exit is.
|
|
26
|
-
*
|
|
27
|
-
* Process handling (idle watchdog, abort, signal-kill detection, stderr cap,
|
|
28
|
-
* error sanitization) mirrors the pi runner so behavior is uniform across hosts.
|
|
29
|
-
*/
|
|
30
|
-
import { type AgentConfig, type LiveUpdate, type RunOptions, type RunResult, type SubagentRunner, type UsageStats } from "taskflow-core";
|
|
31
|
-
/** Accumulated state folded from a codex JSONL event stream. */
|
|
32
|
-
export interface CodexAccumulator {
|
|
33
|
-
usage: UsageStats;
|
|
34
|
-
model?: string;
|
|
35
|
-
/** Final answer = text of the last agent_message item seen. */
|
|
36
|
-
finalText: string;
|
|
37
|
-
lastActivity: string;
|
|
38
|
-
/** Set when a fatal (non-benign) error item is seen. */
|
|
39
|
-
fatalError?: string;
|
|
40
|
-
}
|
|
41
|
-
export declare function newCodexAccumulator(model?: string): CodexAccumulator;
|
|
42
|
-
/**
|
|
43
|
-
* Fold one codex JSONL line into the accumulator. Returns a LiveUpdate when the
|
|
44
|
-
* stream produced new activity (for streaming), else null. Empty/malformed
|
|
45
|
-
* lines are ignored — robust to partial buffers and noise, unit-testable
|
|
46
|
-
* without spawning a process.
|
|
47
|
-
*/
|
|
48
|
-
export declare function foldCodexEventLine(acc: CodexAccumulator, line: string): LiveUpdate | null;
|
|
49
|
-
/**
|
|
50
|
-
* Run a single subagent task via `codex exec --json`. Resolves the agent from
|
|
51
|
-
* `agents` by name; returns the same structured `RunResult` the pi runner does.
|
|
52
|
-
*/
|
|
53
|
-
export declare function runCodexAgentTask(defaultCwd: string, agents: AgentConfig[], agentName: string, task: string, opts: RunOptions, globalThinking?: string): Promise<RunResult>;
|
|
54
|
-
/**
|
|
55
|
-
* The Codex host's `SubagentRunner`. Drops into `RuntimeDeps.runTask` exactly
|
|
56
|
-
* like `piSubagentRunner`, so the engine runs unchanged on Codex.
|
|
57
|
-
*/
|
|
58
|
-
export declare const codexSubagentRunner: SubagentRunner<AgentConfig>;
|
|
59
|
-
//# sourceMappingURL=codex-runner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codex-runner.d.ts","sourceRoot":"","sources":["../src/codex-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAKN,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,MAAM,eAAe,CAAC;AAwBvB,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAEpE;AAOD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CA+CzF;AAqBD;;;GAGG;AACH,wBAAsB,iBAAiB,CACtC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,WAAW,EAAE,EACrB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,cAAc,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,SAAS,CAAC,CAuLpB;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAAC,WAAW,CAE3D,CAAC"}
|