seoanything-cli 2.0.0 → 2.1.0
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/README.md +1 -1
- package/package.json +1 -1
- package/src/cli.js +1 -1
- package/src/cli.test.js +2 -1
- package/src/connect.js +43 -18
- package/src/connect.test.js +28 -5
- package/src/mcp.js +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ Environment overrides for CI: `SEOANYTHING_SERVER`, `SEOANYTHING_API_KEY` (an `s
|
|
|
43
43
|
seoanything connect
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
Links this computer to your SEOAnything account. The web app's chat and blog studio can then run on the AI CLIs installed here (Claude Code `claude`, Codex `codex`,
|
|
46
|
+
Links this computer to your SEOAnything account. The web app's chat and blog studio can then run on the AI CLIs installed here (Claude Code `claude`, Codex `codex`, Antigravity `agy`) with their own logins, instead of the shared cloud models and their daily limits. Pick the default engine under Settings, "your cli". Keep the window open; close it (Ctrl+C) and the app falls back to the cloud models. The cloud sends prompts and receives text; no credential file is read or sent, tools stay off, and each call runs in an empty temporary folder. Needs Node 22 or newer. Disconnect a computer from Settings at any time.
|
|
47
47
|
|
|
48
48
|
## MCP
|
|
49
49
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seoanything-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "SEOAnything CLI: trends, keywords, SEO chat, blog studio, audits, a local MCP server, and `connect` to run the web app on the Claude/Codex/Gemini/Antigravity CLI on your own computer. https://www.seoanything.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/cli.js
CHANGED
|
@@ -41,7 +41,7 @@ usage: seoanything <command> [options]
|
|
|
41
41
|
blog list | blog get <id> [--format md|html|mdx] | blog publish <id> --target github
|
|
42
42
|
audit <path|url> [--cloud] local auditor, or cloud audit saved to history
|
|
43
43
|
mcp local stdio MCP server
|
|
44
|
-
connect [--no-browser] run your own claude/codex/
|
|
44
|
+
connect [--no-browser] run your own claude/codex/agy for your web chats and posts
|
|
45
45
|
config get|set <key> [value] server, defaultGeo, defaultModel …
|
|
46
46
|
init | install | schema | llms-txt | sitemap | menu seoanything v1 commands, unchanged
|
|
47
47
|
|
package/src/cli.test.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
1
2
|
import { describe, expect, it } from "vitest";
|
|
2
3
|
import { EXIT, main, parse } from "./cli.js";
|
|
3
4
|
import { exitCodeFor } from "./api.js";
|
|
@@ -25,7 +26,7 @@ describe("exit codes (TRD §17.1)", () => {
|
|
|
25
26
|
expect((await run(["trends"])).code).toBe(2);
|
|
26
27
|
expect((await run(["keywords", "suggest"])).code).toBe(2);
|
|
27
28
|
expect((await run(["--help"])).code).toBe(0);
|
|
28
|
-
expect((await run(["--version"])).out).toContain("
|
|
29
|
+
expect((await run(["--version"])).out).toContain(JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version);
|
|
29
30
|
});
|
|
30
31
|
it("whoami without credentials exits 3; unreachable server exits 5", async () => {
|
|
31
32
|
const env = { ...process.env }; delete process.env.SEOANYTHING_API_KEY; delete process.env.SEOANYTHING_TOKEN;
|
package/src/connect.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// `seoanything connect`: keep one outbound WebSocket to the cloud and run the AI CLIs installed on this computer
|
|
2
|
-
// (claude, codex,
|
|
2
|
+
// (claude, codex, agy) for your own chats and blog posts. The cloud sends a prompt, this process runs the
|
|
3
3
|
// CLI with its own login and sends the text back. No credential file is ever read or sent. Zero dependencies
|
|
4
4
|
// (Node 22+ for the built-in WebSocket).
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
@@ -7,6 +7,7 @@ import { randomBytes } from "node:crypto";
|
|
|
7
7
|
import { accessSync, constants, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
8
8
|
import os from "node:os";
|
|
9
9
|
import path from "node:path";
|
|
10
|
+
import { StringDecoder } from "node:string_decoder";
|
|
10
11
|
import { CliError, client } from "./api.js";
|
|
11
12
|
import { loadConfig, saveConfig } from "./config.js";
|
|
12
13
|
import { VERSION } from "./mcp.js";
|
|
@@ -14,7 +15,6 @@ import { VERSION } from "./mcp.js";
|
|
|
14
15
|
export const KINDS = {
|
|
15
16
|
claude: { label: "Claude Code", command: "claude" },
|
|
16
17
|
codex: { label: "Codex", command: "codex" },
|
|
17
|
-
gemini: { label: "Gemini CLI", command: "gemini" },
|
|
18
18
|
agy: { label: "Antigravity", command: "agy" },
|
|
19
19
|
};
|
|
20
20
|
export const MAX_JOBS = 2;
|
|
@@ -23,8 +23,6 @@ const MAX_STDOUT = 8 * 1024 * 1024;
|
|
|
23
23
|
const MAX_STDERR = 256 * 1024;
|
|
24
24
|
const IDLE_MS = 180_000;
|
|
25
25
|
const MODEL = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/;
|
|
26
|
-
// gemini takes an instruction as -p and the real prompt on stdin, like the council connector does
|
|
27
|
-
const GEMINI_INSTRUCTION = "Follow the request supplied on stdin and answer it directly.";
|
|
28
26
|
|
|
29
27
|
export class JobError extends Error {
|
|
30
28
|
constructor(code, message) { super(message); this.code = code; }
|
|
@@ -75,18 +73,18 @@ export function checkJob(job) {
|
|
|
75
73
|
if (job.system !== undefined && (typeof job.system !== "string" || Buffer.byteLength(job.system) > 64 * 1024)) throw new JobError("rejected", "invalid system prompt.");
|
|
76
74
|
if (job.model && (typeof job.model !== "string" || !MODEL.test(job.model))) throw new JobError("rejected", "invalid model name.");
|
|
77
75
|
if (!Number.isInteger(job.timeout) || job.timeout < 10 || job.timeout > 600) throw new JobError("rejected", "invalid timeout.");
|
|
78
|
-
if (job.prompt.startsWith("-")) throw new JobError("rejected", "a prompt may not start with a dash."); // never reads as a flag for agy
|
|
76
|
+
if (job.prompt.startsWith("-")) throw new JobError("rejected", "a prompt may not start with a dash."); // never reads as a flag for agy
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
/** Argument array + stdin for one call. `root` is a fresh empty folder. Tools stay off: the CLI only writes text. */
|
|
82
80
|
export function buildArgs(kind, job, root, binary = KINDS[kind].command) {
|
|
83
|
-
const model = job.model ? [kind === "codex"
|
|
81
|
+
const model = job.model ? [kind === "codex" ? "-m" : "--model", job.model] : [];
|
|
84
82
|
const full = job.system ? `${job.system}\n\n${job.prompt}` : job.prompt;
|
|
85
83
|
if (kind === "claude") {
|
|
86
84
|
const mcp = path.join(root, "empty-mcp.json");
|
|
87
85
|
writeFileSync(mcp, '{"mcpServers":{}}');
|
|
88
86
|
return {
|
|
89
|
-
argv: [binary, "-p", ...model, "--output-format", "json", "--tools", "", "--disallowedTools", "mcp__*", "--strict-mcp-config", "--mcp-config", mcp,
|
|
87
|
+
argv: [binary, "-p", ...model, "--output-format", "stream-json", "--verbose", "--include-partial-messages", "--tools", "", "--disallowedTools", "mcp__*", "--strict-mcp-config", "--mcp-config", mcp,
|
|
90
88
|
"--no-session-persistence", "--disable-slash-commands", "--permission-mode", "plan", "--setting-sources", "", "--settings", '{"disableAllHooks":true}',
|
|
91
89
|
...(job.system ? ["--system-prompt", job.system] : [])],
|
|
92
90
|
stdin: job.prompt,
|
|
@@ -100,11 +98,24 @@ export function buildArgs(kind, job, root, binary = KINDS[kind].command) {
|
|
|
100
98
|
after: () => { try { return readFileSync(last, "utf8"); } catch { return ""; } },
|
|
101
99
|
};
|
|
102
100
|
}
|
|
103
|
-
|
|
104
|
-
return { argv: [binary, "--print", full, ...model, "--output-format", "json", "--
|
|
101
|
+
// no --mode plan: in agy that writes a plan file instead of answering. print mode already denies every tool action.
|
|
102
|
+
return { argv: [binary, "--print", full, ...model, "--output-format", "stream-json", "--sandbox", "--disable-slash-commands", "--print-timeout", `${job.timeout}s`], stdin: "" };
|
|
105
103
|
}
|
|
106
104
|
|
|
107
105
|
const safeJson = (s) => { try { return JSON.parse(s); } catch { return null; } };
|
|
106
|
+
const jsonLines = (s) => s.split("\n").map((l) => safeJson(l.trim())).filter(Boolean);
|
|
107
|
+
|
|
108
|
+
/** Answer text (or reasoning) in one line of a CLI's streaming output, for the live preview. Codex prints its answer only at the end. */
|
|
109
|
+
export function deltaOf(kind, line) {
|
|
110
|
+
const e = safeJson(line.trim());
|
|
111
|
+
if (kind === "claude" && e?.type === "stream_event" && e.event?.type === "content_block_delta") {
|
|
112
|
+
const d = e.event.delta;
|
|
113
|
+
if (d?.type === "text_delta" && d.text) return { text: d.text };
|
|
114
|
+
if (d?.type === "thinking_delta" && d.thinking) return { thinking: d.thinking };
|
|
115
|
+
}
|
|
116
|
+
if (kind === "agy" && e?.event === "step_update" && e.step_update?.step_type === "agent_response" && e.step_update.text_delta) return { text: e.step_update.text_delta };
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
108
119
|
|
|
109
120
|
/** The answer text (and usage when the CLI reports it) out of a finished process. */
|
|
110
121
|
export function parseOutput(kind, { stdout, stderr, code }, lastMessage = "") {
|
|
@@ -112,6 +123,7 @@ export function parseOutput(kind, { stdout, stderr, code }, lastMessage = "") {
|
|
|
112
123
|
if (kind === "claude") {
|
|
113
124
|
let j = safeJson(stdout.trim());
|
|
114
125
|
if (Array.isArray(j)) j = j.find((e) => e?.type === "result") ?? null;
|
|
126
|
+
if (!j) j = jsonLines(stdout).findLast((e) => e?.type === "result") ?? null; // stream-json: one event per line, the result last
|
|
115
127
|
if (j?.is_error) throw new JobError("cli_failed", String(j.result ?? "claude reported an error").slice(0, 300));
|
|
116
128
|
text = typeof j?.result === "string" ? j.result : "";
|
|
117
129
|
tokensIn = j?.usage?.input_tokens; tokensOut = j?.usage?.output_tokens;
|
|
@@ -125,10 +137,11 @@ export function parseOutput(kind, { stdout, stderr, code }, lastMessage = "") {
|
|
|
125
137
|
}
|
|
126
138
|
if (lastMessage.trim()) text = lastMessage;
|
|
127
139
|
} else {
|
|
128
|
-
|
|
140
|
+
let j = safeJson(stdout.trim()) ?? jsonLines(stdout).findLast((e) => e?.event === "result") ?? null;
|
|
141
|
+
if (j?.event === "result") j = j.result; // stream-json wraps the final answer
|
|
142
|
+
tokensIn = j?.usage?.input_tokens; tokensOut = j?.usage?.output_tokens;
|
|
129
143
|
if (kind === "agy" && j?.status && j.status !== "SUCCESS") throw new JobError("cli_failed", String(j.error ?? j.message ?? j.status).slice(0, 300));
|
|
130
144
|
text = typeof j?.response === "string" ? j.response : typeof j?.result === "string" ? j.result : "";
|
|
131
|
-
if (kind === "gemini" && j?.stats?.models) { const m = Object.entries(j.stats.models)[0]; if (m) { model = m[0]; tokensIn = m[1]?.tokens?.prompt; tokensOut = m[1]?.tokens?.candidates; } }
|
|
132
145
|
}
|
|
133
146
|
text = text.trim();
|
|
134
147
|
if (!text) {
|
|
@@ -141,7 +154,7 @@ export function parseOutput(kind, { stdout, stderr, code }, lastMessage = "") {
|
|
|
141
154
|
}
|
|
142
155
|
|
|
143
156
|
/** Run argv with no shell, in its own process group, with wall/idle timeouts and output caps. */
|
|
144
|
-
export function runProcess(argv, { cwd, env, input = "", timeoutMs = 60_000, idleMs = IDLE_MS, signal } = {}) {
|
|
157
|
+
export function runProcess(argv, { cwd, env, input = "", timeoutMs = 60_000, idleMs = IDLE_MS, signal, onStdout } = {}) {
|
|
145
158
|
return new Promise((resolve, reject) => {
|
|
146
159
|
let child;
|
|
147
160
|
try { child = spawn(argv[0], argv.slice(1), { cwd, env, shell: false, detached: process.platform !== "win32", windowsHide: true, stdio: ["pipe", "pipe", "pipe"] }); }
|
|
@@ -157,7 +170,7 @@ export function runProcess(argv, { cwd, env, input = "", timeoutMs = 60_000, idl
|
|
|
157
170
|
const idle = setInterval(() => { if (Date.now() - last > idleMs) fail("idle_timeout", `the CLI printed nothing for ${Math.round(idleMs / 1000)} s.`); }, 1000);
|
|
158
171
|
const onAbort = () => fail("cancelled", "the call was cancelled.");
|
|
159
172
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
160
|
-
child.stdout.on("data", (chunk) => { last = Date.now(); if ((outBytes += chunk.length) > MAX_STDOUT) return fail("output_limit", "the CLI printed too much."); out.push(chunk); });
|
|
173
|
+
child.stdout.on("data", (chunk) => { last = Date.now(); if ((outBytes += chunk.length) > MAX_STDOUT) return fail("output_limit", "the CLI printed too much."); out.push(chunk); onStdout?.(chunk); });
|
|
161
174
|
child.stderr.on("data", (chunk) => { last = Date.now(); if ((errBytes += chunk.length) > MAX_STDERR) return fail("output_limit", "the CLI printed too much."); err.push(chunk); });
|
|
162
175
|
child.stdin.on("error", () => {});
|
|
163
176
|
child.stdin.end(input);
|
|
@@ -172,14 +185,21 @@ export function runProcess(argv, { cwd, env, input = "", timeoutMs = 60_000, idl
|
|
|
172
185
|
}
|
|
173
186
|
|
|
174
187
|
/** One job end to end in a throwaway folder. */
|
|
175
|
-
export async function runJob(job, { binaries, env = ownEnv(), signal, run = runProcess } = {}) {
|
|
188
|
+
export async function runJob(job, { binaries, env = ownEnv(), signal, run = runProcess, onDelta } = {}) {
|
|
176
189
|
checkJob(job);
|
|
177
190
|
const binary = binaries[job.kind];
|
|
178
191
|
if (!binary) throw new JobError("unavailable", `${KINDS[job.kind].label} is not installed on this computer.`);
|
|
179
192
|
const root = mkdtempSync(path.join(os.tmpdir(), "seoanything-"));
|
|
180
193
|
try {
|
|
181
194
|
const { argv, stdin, after } = buildArgs(job.kind, job, root, binary);
|
|
182
|
-
const
|
|
195
|
+
const dec = new StringDecoder("utf8");
|
|
196
|
+
let buf = "";
|
|
197
|
+
// split stdout into whole lines (a chunk can end mid-line or mid-character) and pass on the answer text in them
|
|
198
|
+
const onStdout = onDelta && ((chunk) => {
|
|
199
|
+
buf += dec.write(chunk);
|
|
200
|
+
for (let i; (i = buf.indexOf("\n")) >= 0; buf = buf.slice(i + 1)) { const d = deltaOf(job.kind, buf.slice(0, i)); if (d) onDelta(d); }
|
|
201
|
+
});
|
|
202
|
+
const res = await run(argv, { cwd: root, env, input: stdin, timeoutMs: job.timeout * 1000, signal, onStdout });
|
|
183
203
|
return parseOutput(job.kind, res, after?.());
|
|
184
204
|
} finally { rmSync(root, { recursive: true, force: true }); }
|
|
185
205
|
}
|
|
@@ -193,7 +213,7 @@ export async function connect({ server, token, log = console.error, hostname = o
|
|
|
193
213
|
if (!cfg.deviceId) saveConfig({ ...cfg, deviceId });
|
|
194
214
|
const env = ownEnv();
|
|
195
215
|
const found = await detect(env);
|
|
196
|
-
if (!found.length) throw new CliError("no AI CLI found on PATH. install claude, codex
|
|
216
|
+
if (!found.length) throw new CliError("no AI CLI found on PATH. install claude, codex or agy, sign in to it once, then run connect again.", 1);
|
|
197
217
|
for (const f of found) log(`✓ found ${KINDS[f.kind].label} ${f.version} at ${f.path}`);
|
|
198
218
|
const binaries = Object.fromEntries(found.map((f) => [f.kind, f.path]));
|
|
199
219
|
const jobs = new Map();
|
|
@@ -211,15 +231,20 @@ export async function connect({ server, token, log = console.error, hostname = o
|
|
|
211
231
|
jobs.set(job.id, ac);
|
|
212
232
|
const t0 = Date.now();
|
|
213
233
|
log(`→ ${label}: running a call…`);
|
|
234
|
+
// the browser shows the answer as it is written: batch the deltas so one call is a few messages a second, not one per token
|
|
235
|
+
let pend = { text: "", thinking: "" }, flushTimer = null;
|
|
236
|
+
const flush = () => { flushTimer = null; if (pend.text || pend.thinking) { send(ws, { type: "delta", id: job.id, ...pend }); pend = { text: "", thinking: "" }; } };
|
|
237
|
+
const onDelta = job.stream ? (d) => { pend.text += d.text ?? ""; pend.thinking += d.thinking ?? ""; flushTimer ??= setTimeout(flush, 150); } : undefined;
|
|
214
238
|
try {
|
|
215
|
-
const r = await runJob(job, { binaries, env, signal: ac.signal });
|
|
239
|
+
const r = await runJob(job, { binaries, env, signal: ac.signal, onDelta });
|
|
240
|
+
if (flushTimer) { clearTimeout(flushTimer); flush(); }
|
|
216
241
|
send(ws, { type: "result", id: job.id, ...r });
|
|
217
242
|
log(`✓ ${label} answered in ${((Date.now() - t0) / 1000).toFixed(1)} s`);
|
|
218
243
|
} catch (e) {
|
|
219
244
|
if (e.code === "cancelled") return;
|
|
220
245
|
send(ws, { type: "failed", id: job.id, code: e instanceof JobError ? e.code : "cli_failed", message: String(e.message ?? "the CLI failed").slice(0, 300) });
|
|
221
246
|
log(`✗ ${label}: ${e.message}`);
|
|
222
|
-
} finally { jobs.delete(job.id); }
|
|
247
|
+
} finally { clearTimeout(flushTimer); jobs.delete(job.id); }
|
|
223
248
|
}
|
|
224
249
|
|
|
225
250
|
async function open() {
|
package/src/connect.test.js
CHANGED
|
@@ -2,7 +2,7 @@ import { mkdtempSync, rmSync } from "node:fs";
|
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { afterEach, describe, expect, it } from "vitest";
|
|
5
|
-
import { buildArgs, checkJob, ownEnv, parseOutput, runJob } from "./connect.js";
|
|
5
|
+
import { buildArgs, checkJob, deltaOf, ownEnv, parseOutput, runJob } from "./connect.js";
|
|
6
6
|
|
|
7
7
|
const job = { kind: "claude", prompt: "say ok", system: "be brief", timeout: 60 };
|
|
8
8
|
let root;
|
|
@@ -30,13 +30,36 @@ describe("buildArgs", () => {
|
|
|
30
30
|
expect(argv).toEqual(expect.arrayContaining(["exec", "-m", "gpt-5", "--sandbox", "read-only", "--ephemeral", "-"]));
|
|
31
31
|
expect(stdin).toBe("be brief\n\nsay ok"); expect(after()).toBe("");
|
|
32
32
|
});
|
|
33
|
-
it("passes agy the prompt as an argument with
|
|
33
|
+
it("passes agy the prompt as an argument, streaming, sandboxed, with a print timeout and no plan mode", () => {
|
|
34
34
|
const { argv, stdin } = buildArgs("agy", { ...job, kind: "agy" }, "/tmp", "agy");
|
|
35
|
-
expect(argv).toEqual(expect.arrayContaining(["--print", "be brief\n\nsay ok", "--
|
|
35
|
+
expect(argv).toEqual(expect.arrayContaining(["--print", "be brief\n\nsay ok", "--output-format", "stream-json", "--sandbox", "--print-timeout", "60s"]));
|
|
36
|
+
expect(argv).not.toContain("--mode");
|
|
36
37
|
expect(stdin).toBe("");
|
|
37
38
|
});
|
|
38
39
|
});
|
|
39
40
|
|
|
41
|
+
describe("streaming output", () => {
|
|
42
|
+
const claude = ['{"type":"system","subtype":"init"}', '{"type":"stream_event","event":{"type":"content_block_delta","delta":{"type":"thinking_delta","thinking":"hmm"}}}', '{"type":"stream_event","event":{"type":"content_block_delta","delta":{"type":"text_delta","text":"o"}}}', '{"type":"stream_event","event":{"type":"content_block_delta","delta":{"type":"text_delta","text":"k"}}}', '{"type":"result","is_error":false,"result":"ok","usage":{"input_tokens":4,"output_tokens":1}}'];
|
|
43
|
+
const agy = ['{"event":"init"}', '{"event":"step_update","step_update":{"step_type":"agent_response","state":"ACTIVE","text_delta":"he"}}', '{"event":"step_update","step_update":{"step_type":"agent_response","state":"DONE","text_delta":"y"}}', '{"event":"result","result":{"status":"SUCCESS","response":"hey","usage":{"input_tokens":9,"output_tokens":2}}}'];
|
|
44
|
+
it("pulls answer text and reasoning out of claude and agy lines, nothing out of the rest", () => {
|
|
45
|
+
expect(claude.map((l) => deltaOf("claude", l))).toEqual([null, { thinking: "hmm" }, { text: "o" }, { text: "k" }, null]);
|
|
46
|
+
expect(agy.map((l) => deltaOf("agy", l))).toEqual([null, { text: "he" }, { text: "y" }, null]);
|
|
47
|
+
expect(deltaOf("codex", '{"type":"item.completed"}')).toBeNull();
|
|
48
|
+
});
|
|
49
|
+
it("reads the final answer and usage from stream-json", () => {
|
|
50
|
+
expect(parseOutput("claude", { stdout: claude.join("\n"), stderr: "", code: 0 })).toMatchObject({ text: "ok", tokensIn: 4, tokensOut: 1 });
|
|
51
|
+
expect(parseOutput("agy", { stdout: agy.join("\n"), stderr: "", code: 0 })).toMatchObject({ text: "hey", tokensIn: 9, tokensOut: 2 });
|
|
52
|
+
});
|
|
53
|
+
it("hands runJob's deltas over line by line, even when a chunk splits a line", async () => {
|
|
54
|
+
const out = claude.join("\n") + "\n";
|
|
55
|
+
const fake = async (_argv, { onStdout }) => { onStdout(Buffer.from(out.slice(0, 150))); onStdout(Buffer.from(out.slice(150))); return { stdout: out, stderr: "", code: 0 }; };
|
|
56
|
+
const seen = [];
|
|
57
|
+
const r = await runJob({ ...job, kind: "claude" }, { binaries: { claude: "/bin/claude" }, run: fake, onDelta: (d) => seen.push(d) });
|
|
58
|
+
expect(seen).toEqual([{ thinking: "hmm" }, { text: "o" }, { text: "k" }]);
|
|
59
|
+
expect(r.text).toBe("ok");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
40
63
|
describe("checkJob", () => {
|
|
41
64
|
it("refuses unknown kinds, flag-like prompts and bad timeouts", () => {
|
|
42
65
|
expect(() => checkJob({ ...job, kind: "bash" })).toThrow("unknown CLI");
|
|
@@ -60,10 +83,10 @@ describe("parseOutput", () => {
|
|
|
60
83
|
expect(parseOutput("codex", { stdout, stderr: "", code: 0 }, "from file\n")).toEqual({ text: "from file", model: "gpt-5", tokensIn: 5, tokensOut: 2 });
|
|
61
84
|
expect(parseOutput("codex", { stdout, stderr: "", code: 0 }, "").text).toBe("from events");
|
|
62
85
|
});
|
|
63
|
-
it("reads agy
|
|
86
|
+
it("reads agy responses and fails on agy errors", () => {
|
|
64
87
|
expect(parseOutput("agy", { stdout: '{"status":"SUCCESS","response":"hi"}', stderr: "", code: 0 }).text).toBe("hi");
|
|
65
88
|
expect(() => parseOutput("agy", { stdout: '{"status":"ERROR","error":"quota"}', stderr: "", code: 1 })).toThrow("quota");
|
|
66
|
-
expect(
|
|
89
|
+
expect(() => checkJob({ kind: "gemini", prompt: "hi", timeout: 60 })).toThrow("unknown CLI");
|
|
67
90
|
});
|
|
68
91
|
it("falls back to raw stdout, and reports the exit code when there is none", () => {
|
|
69
92
|
expect(parseOutput("claude", { stdout: "plain text", stderr: "", code: 0 }).text).toBe("plain text");
|
package/src/mcp.js
CHANGED
|
@@ -3,7 +3,7 @@ import fs from "node:fs";
|
|
|
3
3
|
import { CliError } from "./api.js";
|
|
4
4
|
import { resolveCreds } from "./config.js";
|
|
5
5
|
|
|
6
|
-
export const VERSION = "2.
|
|
6
|
+
export const VERSION = "2.1.0";
|
|
7
7
|
|
|
8
8
|
export async function mcp(flags) {
|
|
9
9
|
const [major, minor] = process.versions.node.split(".").map(Number);
|