@the-vibe-company/armada 0.2.42 → 0.2.43
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/dist/armada.js +174 -25
- package/package.json +1 -1
package/dist/armada.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/main.ts
|
|
4
|
-
import { spawn as
|
|
4
|
+
import { spawn as spawn3, spawnSync } from "node:child_process";
|
|
5
5
|
import { createReadStream } from "node:fs";
|
|
6
6
|
import { open as open2, readFile as readFile4, writeFile as writeFile3 } from "node:fs/promises";
|
|
7
7
|
import { hostname as hostname2 } from "node:os";
|
|
@@ -10156,7 +10156,7 @@ ${attachments.join(`
|
|
|
10156
10156
|
};
|
|
10157
10157
|
}
|
|
10158
10158
|
// package.json
|
|
10159
|
-
var version = "0.2.
|
|
10159
|
+
var version = "0.2.43";
|
|
10160
10160
|
|
|
10161
10161
|
// src/attach.ts
|
|
10162
10162
|
import { resolve } from "node:path";
|
|
@@ -11990,12 +11990,12 @@ function localHarnesses(config) {
|
|
|
11990
11990
|
return [...new Set(Object.values(config.herdr?.profiles ?? {}).map((profile) => profile.harness))];
|
|
11991
11991
|
}
|
|
11992
11992
|
function localModelProfiles(config) {
|
|
11993
|
-
return Object.entries(config.herdr?.profiles ?? {}).flatMap(([name, profile]) => profile.harness === "opencode" || profile.harness === "deepseek" ? [{ name, harness: profile.harness, model: profile.model ?? "" }] : []);
|
|
11993
|
+
return Object.entries(config.herdr?.profiles ?? {}).flatMap(([name, profile]) => profile.model || profile.harness === "opencode" || profile.harness === "deepseek" ? [{ name, harness: profile.harness, model: profile.model ?? "" }] : []);
|
|
11994
11994
|
}
|
|
11995
|
-
async function probe(io, command, args) {
|
|
11995
|
+
async function probe(io, command, args, limits = {}) {
|
|
11996
11996
|
if (!io.exec)
|
|
11997
11997
|
return null;
|
|
11998
|
-
return io.exec(command, args, { cwd: io.cwd }).catch(() => null);
|
|
11998
|
+
return io.exec(command, args, { cwd: io.cwd, ...limits }).catch(() => null);
|
|
11999
11999
|
}
|
|
12000
12000
|
function versionOf(result) {
|
|
12001
12001
|
if (result.code !== 0)
|
|
@@ -12097,8 +12097,37 @@ async function openCodeModels(io) {
|
|
|
12097
12097
|
`).map((line) => line.trim()).filter((line) => /^[^\s/#]+\/[^\s#]+$/.test(line)))
|
|
12098
12098
|
];
|
|
12099
12099
|
}
|
|
12100
|
+
async function claudeModels(io) {
|
|
12101
|
+
const result = await probe(io, "claude", ["--help"], { timeoutMs: 5000, maxOutputBytes: 262144 });
|
|
12102
|
+
if (result?.code !== 0)
|
|
12103
|
+
return null;
|
|
12104
|
+
const help = stripVTControlCharacters2(result.stdout);
|
|
12105
|
+
const option = help.match(/(?:^|\n)\s+--model\s+<model>([\s\S]*?)(?=\n\s+--?[a-zA-Z]|$)/)?.[1];
|
|
12106
|
+
if (!option)
|
|
12107
|
+
return null;
|
|
12108
|
+
return [
|
|
12109
|
+
...new Set([...option.matchAll(/['"]([a-z][a-z0-9.[\]-]*)['"]/g)].flatMap((match) => match[1] ? [match[1]] : []))
|
|
12110
|
+
];
|
|
12111
|
+
}
|
|
12112
|
+
function modelsFor(detected, profile) {
|
|
12113
|
+
return detected.availableModels[profile.harness === "deepseek" ? "opencode" : profile.harness] ?? null;
|
|
12114
|
+
}
|
|
12100
12115
|
function modelCheck(profile, available) {
|
|
12101
12116
|
const model = profile.model;
|
|
12117
|
+
if (profile.harness === "claude" || profile.harness === "codex") {
|
|
12118
|
+
const claude = profile.harness === "claude";
|
|
12119
|
+
const ready = !!model && !!available?.includes(model);
|
|
12120
|
+
const section = profile.name ? ` under [herdr.profiles.${profile.name}]` : "";
|
|
12121
|
+
const suggested = claude ? available?.find((id) => id === "opus") ?? available?.[0] : available?.[0];
|
|
12122
|
+
const line = `model = ${JSON.stringify(suggested ?? "<exact model id>")}${section}`;
|
|
12123
|
+
return {
|
|
12124
|
+
id: `local-${profile.harness}-model:${profile.name || model}`,
|
|
12125
|
+
level: ready ? "ok" : "error",
|
|
12126
|
+
message: `${profile.harness}${profile.name ? ` profile ${profile.name}` : ""}: ${ready ? claude ? `the installed CLI advertises ${model} in --help` : `model/list lists ${model} for this sign-in (catalog check only)` : claude ? `could not verify ${model} with the installed CLI; --help is not a complete model catalog` : available === null ? "could not read the installed CLI's model/list catalog for this sign-in" : `${model} is not listed by the installed CLI for this sign-in`}${!claude && !ready && available?.length ? `
|
|
12127
|
+
Available models: ${available.map((id, i) => `${i + 1}. ${id} — model = ${JSON.stringify(id)}`).join("; ")}` : ""}`,
|
|
12128
|
+
fix: ready ? null : claude ? `add ${line}${suggested ? " (an advertised alias or model)" : "; choose an alias from `claude --help` or the owner's `/model` picker"}; or run \`claude update\` and retry doctor` : `pick a listed model and add ${line}; or update with \`npm i -g @openai/codex\`; if the model requires API access, the owner signs in using \`codex login --with-api-key\` and retries doctor; Armada never runs sign-in`
|
|
12129
|
+
};
|
|
12130
|
+
}
|
|
12102
12131
|
const matching = available?.filter((id) => profile.harness !== "deepseek" || isDeepseekModel(id)) ?? [];
|
|
12103
12132
|
const ready = !!model && matching.includes(model);
|
|
12104
12133
|
const label = profile.harness === "deepseek" ? "deepseek (OpenCode + DeepSeek model)" : "opencode";
|
|
@@ -12111,13 +12140,14 @@ ${ready ? "" : `Available models: ${matching.length ? matching.map((id, i) => `$
|
|
|
12111
12140
|
};
|
|
12112
12141
|
}
|
|
12113
12142
|
async function offerLocalModels(io, detected, configPath, options = {}) {
|
|
12114
|
-
if (detected.availableModels === null)
|
|
12115
|
-
return detected;
|
|
12116
12143
|
let changed = false;
|
|
12117
12144
|
for (const profile of detected.profiles) {
|
|
12118
|
-
if (
|
|
12145
|
+
if (profile.harness === "claude")
|
|
12119
12146
|
continue;
|
|
12120
|
-
const
|
|
12147
|
+
const available = modelsFor(detected, profile);
|
|
12148
|
+
if (!available || modelCheck(profile, available).level === "ok")
|
|
12149
|
+
continue;
|
|
12150
|
+
const models = available.filter((id) => profile.harness !== "deepseek" || isDeepseekModel(id));
|
|
12121
12151
|
if (!models.length || options.readOnly || !io.interactive || io.env.CI || !io.prompt || !io.writeFile || !configPath || !profile.name)
|
|
12122
12152
|
continue;
|
|
12123
12153
|
io.stderr(`Choose a model for [herdr.profiles.${profile.name}]:
|
|
@@ -12170,7 +12200,7 @@ async function detectLocalTools(io, harnesses, configured = []) {
|
|
|
12170
12200
|
if ((harness === "opencode" || harness === "deepseek") && !profiles.some((profile) => profile.harness === harness))
|
|
12171
12201
|
profiles.push({ name: "", harness, model: "" });
|
|
12172
12202
|
}
|
|
12173
|
-
|
|
12203
|
+
const availableModels = {};
|
|
12174
12204
|
const tools = [];
|
|
12175
12205
|
const checks = [];
|
|
12176
12206
|
const binaries = new Set(harnesses.map((harness) => harness === "deepseek" ? "opencode" : harness));
|
|
@@ -12179,11 +12209,13 @@ async function detectLocalTools(io, harnesses, configured = []) {
|
|
|
12179
12209
|
tools.push(tool);
|
|
12180
12210
|
checks.push(toolCheck(tool));
|
|
12181
12211
|
if (name !== "herdr" && tool.state === "ready") {
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
|
|
12212
|
+
const signIn = name !== "opencode" ? await signInCheck(io, name) : null;
|
|
12213
|
+
if (signIn)
|
|
12214
|
+
checks.push(signIn);
|
|
12215
|
+
const selected = profiles.filter((profile) => (profile.harness === "deepseek" ? "opencode" : profile.harness) === name);
|
|
12216
|
+
if (selected.length) {
|
|
12217
|
+
availableModels[name] = name === "opencode" ? await openCodeModels(io) : name === "claude" ? await claudeModels(io) : signIn?.level === "error" ? null : await io.codexModels?.(io.cwd).catch(() => null) ?? null;
|
|
12218
|
+
checks.push(...selected.map((profile) => modelCheck(profile, availableModels[name] ?? null)));
|
|
12187
12219
|
}
|
|
12188
12220
|
}
|
|
12189
12221
|
}
|
|
@@ -14566,6 +14598,109 @@ ${next ? `Next: ${next}
|
|
|
14566
14598
|
}
|
|
14567
14599
|
}
|
|
14568
14600
|
|
|
14601
|
+
// src/codex-models.ts
|
|
14602
|
+
import { spawn } from "node:child_process";
|
|
14603
|
+
var system = {
|
|
14604
|
+
start: (cwd) => spawn("codex", ["app-server"], { cwd, stdio: ["pipe", "pipe", "ignore"] }),
|
|
14605
|
+
deadline: (expire) => {
|
|
14606
|
+
const timer = setTimeout(expire, 1e4);
|
|
14607
|
+
return () => clearTimeout(timer);
|
|
14608
|
+
}
|
|
14609
|
+
};
|
|
14610
|
+
function readCodexModels(cwd, io = system) {
|
|
14611
|
+
return new Promise((resolve) => {
|
|
14612
|
+
let child;
|
|
14613
|
+
try {
|
|
14614
|
+
child = io.start(cwd);
|
|
14615
|
+
} catch {
|
|
14616
|
+
resolve(null);
|
|
14617
|
+
return;
|
|
14618
|
+
}
|
|
14619
|
+
let settled = false;
|
|
14620
|
+
let cancel = () => {};
|
|
14621
|
+
const finish = (models) => {
|
|
14622
|
+
if (settled)
|
|
14623
|
+
return;
|
|
14624
|
+
settled = true;
|
|
14625
|
+
cancel();
|
|
14626
|
+
child.stdin.destroy();
|
|
14627
|
+
child.kill("SIGKILL");
|
|
14628
|
+
resolve(models);
|
|
14629
|
+
};
|
|
14630
|
+
cancel = io.deadline(() => finish(null));
|
|
14631
|
+
let buffer = "";
|
|
14632
|
+
let bytes = 0;
|
|
14633
|
+
let requestId = 0;
|
|
14634
|
+
const models = new Set;
|
|
14635
|
+
const cursors = new Set;
|
|
14636
|
+
const send = (message) => {
|
|
14637
|
+
if (!settled)
|
|
14638
|
+
child.stdin.write(`${JSON.stringify(message)}
|
|
14639
|
+
`);
|
|
14640
|
+
};
|
|
14641
|
+
const list = (cursor) => {
|
|
14642
|
+
requestId++;
|
|
14643
|
+
send({ id: requestId, method: "model/list", params: { limit: 100, includeHidden: true, cursor } });
|
|
14644
|
+
};
|
|
14645
|
+
child.on("error", () => finish(null));
|
|
14646
|
+
child.on("close", () => finish(null));
|
|
14647
|
+
child.stdin.on("error", () => finish(null));
|
|
14648
|
+
child.stdout.setEncoding("utf8").on("data", (chunk) => {
|
|
14649
|
+
if (settled)
|
|
14650
|
+
return;
|
|
14651
|
+
bytes += Buffer.byteLength(chunk);
|
|
14652
|
+
if (bytes > 1048576)
|
|
14653
|
+
return finish(null);
|
|
14654
|
+
buffer += chunk;
|
|
14655
|
+
while (!settled) {
|
|
14656
|
+
const newline = buffer.indexOf(`
|
|
14657
|
+
`);
|
|
14658
|
+
if (newline === -1)
|
|
14659
|
+
break;
|
|
14660
|
+
const line = buffer.slice(0, newline);
|
|
14661
|
+
buffer = buffer.slice(newline + 1);
|
|
14662
|
+
if (!line.trim())
|
|
14663
|
+
continue;
|
|
14664
|
+
try {
|
|
14665
|
+
const message = JSON.parse(line);
|
|
14666
|
+
if (!message || typeof message !== "object")
|
|
14667
|
+
return finish(null);
|
|
14668
|
+
if (message.id !== requestId)
|
|
14669
|
+
continue;
|
|
14670
|
+
if (message.error || !message.result || typeof message.result !== "object")
|
|
14671
|
+
return finish(null);
|
|
14672
|
+
if (requestId === 0) {
|
|
14673
|
+
send({ method: "initialized", params: {} });
|
|
14674
|
+
list(null);
|
|
14675
|
+
continue;
|
|
14676
|
+
}
|
|
14677
|
+
const { data, nextCursor } = message.result;
|
|
14678
|
+
if (!Array.isArray(data) || nextCursor != null && typeof nextCursor !== "string")
|
|
14679
|
+
return finish(null);
|
|
14680
|
+
for (const entry of data) {
|
|
14681
|
+
if (!entry || typeof entry.model !== "string" || !entry.model.trim() || entry.model.length > 4096 || /\p{Cc}/u.test(entry.model))
|
|
14682
|
+
return finish(null);
|
|
14683
|
+
models.add(entry.model);
|
|
14684
|
+
}
|
|
14685
|
+
if (nextCursor == null)
|
|
14686
|
+
return finish([...models]);
|
|
14687
|
+
if (!nextCursor || cursors.has(nextCursor) || cursors.size >= 100)
|
|
14688
|
+
return finish(null);
|
|
14689
|
+
cursors.add(nextCursor);
|
|
14690
|
+
list(nextCursor);
|
|
14691
|
+
} catch {
|
|
14692
|
+
return finish(null);
|
|
14693
|
+
}
|
|
14694
|
+
}
|
|
14695
|
+
});
|
|
14696
|
+
send({
|
|
14697
|
+
id: 0,
|
|
14698
|
+
method: "initialize",
|
|
14699
|
+
params: { clientInfo: { name: "armada_doctor", version: "1" }, capabilities: { explicitGatewayOAuth: true } }
|
|
14700
|
+
});
|
|
14701
|
+
});
|
|
14702
|
+
}
|
|
14703
|
+
|
|
14569
14704
|
// src/line.ts
|
|
14570
14705
|
var emptyLine = () => ({ answer: "", sequence: "none" });
|
|
14571
14706
|
function feedLine(line, chunk) {
|
|
@@ -14645,11 +14780,11 @@ async function inspectProcess(exec, pid, system = {
|
|
|
14645
14780
|
}
|
|
14646
14781
|
|
|
14647
14782
|
// src/spawn.ts
|
|
14648
|
-
import { spawn } from "node:child_process";
|
|
14783
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
14649
14784
|
import { constants } from "node:os";
|
|
14650
14785
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
14651
14786
|
var spawnInherited = (command, args, { cwd, env }) => new Promise((done, fail) => {
|
|
14652
|
-
const child =
|
|
14787
|
+
const child = spawn2(command, args, { cwd, env, stdio: "inherit" });
|
|
14653
14788
|
const fromTerminal = process.stdin.isTTY === true;
|
|
14654
14789
|
const handlers = SIGNALS.map((signal) => {
|
|
14655
14790
|
const handler = () => {
|
|
@@ -14675,7 +14810,7 @@ var spawnInherited = (command, args, { cwd, env }) => new Promise((done, fail) =
|
|
|
14675
14810
|
var startBackground = (args) => new Promise((resolve) => {
|
|
14676
14811
|
if (process.platform === "win32")
|
|
14677
14812
|
return resolve(false);
|
|
14678
|
-
const child =
|
|
14813
|
+
const child = spawn2(process.execPath, [...process.execArgv, process.argv[1], ...args], {
|
|
14679
14814
|
cwd: process.cwd(),
|
|
14680
14815
|
env: process.env,
|
|
14681
14816
|
detached: true,
|
|
@@ -14757,7 +14892,7 @@ function openUrl(url) {
|
|
|
14757
14892
|
return false;
|
|
14758
14893
|
const [command, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", url]] : ["xdg-open", [url]];
|
|
14759
14894
|
try {
|
|
14760
|
-
const child =
|
|
14895
|
+
const child = spawn3(command, args, { stdio: "ignore", detached: true });
|
|
14761
14896
|
child.on("error", () => {});
|
|
14762
14897
|
child.unref();
|
|
14763
14898
|
return true;
|
|
@@ -14765,16 +14900,29 @@ function openUrl(url) {
|
|
|
14765
14900
|
return false;
|
|
14766
14901
|
}
|
|
14767
14902
|
}
|
|
14768
|
-
var exec = (command, args, { cwd, timeoutMs }) => new Promise((done, fail) => {
|
|
14769
|
-
const child =
|
|
14903
|
+
var exec = (command, args, { cwd, timeoutMs, maxOutputBytes }) => new Promise((done, fail) => {
|
|
14904
|
+
const child = spawn3(command, args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
14770
14905
|
const timer = timeoutMs ? setTimeout(() => child.kill("SIGKILL"), timeoutMs) : null;
|
|
14771
14906
|
let stdout = "";
|
|
14772
14907
|
let stderr = "";
|
|
14908
|
+
let bytes = 0;
|
|
14909
|
+
let oversized = false;
|
|
14910
|
+
const accept = (text) => {
|
|
14911
|
+
bytes += Buffer.byteLength(text);
|
|
14912
|
+
if (maxOutputBytes !== undefined && bytes > maxOutputBytes) {
|
|
14913
|
+
oversized = true;
|
|
14914
|
+
stdout = stderr = "";
|
|
14915
|
+
child.kill("SIGKILL");
|
|
14916
|
+
}
|
|
14917
|
+
return !oversized;
|
|
14918
|
+
};
|
|
14773
14919
|
child.stdout.setEncoding("utf8").on("data", (d) => {
|
|
14774
|
-
|
|
14920
|
+
if (accept(d))
|
|
14921
|
+
stdout += d;
|
|
14775
14922
|
});
|
|
14776
14923
|
child.stderr.setEncoding("utf8").on("data", (d) => {
|
|
14777
|
-
|
|
14924
|
+
if (accept(d))
|
|
14925
|
+
stderr += d;
|
|
14778
14926
|
});
|
|
14779
14927
|
child.on("error", (err) => {
|
|
14780
14928
|
if (timer)
|
|
@@ -14784,7 +14932,7 @@ var exec = (command, args, { cwd, timeoutMs }) => new Promise((done, fail) => {
|
|
|
14784
14932
|
child.on("close", (code) => {
|
|
14785
14933
|
if (timer)
|
|
14786
14934
|
clearTimeout(timer);
|
|
14787
|
-
done({ code: code ?? 1, stdout, stderr });
|
|
14935
|
+
done({ code: oversized ? 1 : code ?? 1, stdout, stderr });
|
|
14788
14936
|
});
|
|
14789
14937
|
});
|
|
14790
14938
|
var stopped = false;
|
|
@@ -14794,6 +14942,7 @@ if (process.argv.includes("heartbeat") && !process.argv.includes("--background")
|
|
|
14794
14942
|
stopped = true;
|
|
14795
14943
|
});
|
|
14796
14944
|
var code = await run(process.argv.slice(2), {
|
|
14945
|
+
codexModels: readCodexModels,
|
|
14797
14946
|
platform: process.platform,
|
|
14798
14947
|
machineName: hostname2(),
|
|
14799
14948
|
ttyName: process.stdin.isTTY ? spawnSync("tty", [], { encoding: "utf8", stdio: ["inherit", "pipe", "ignore"] }).stdout?.trim() || null : null,
|
|
@@ -14858,7 +15007,7 @@ var code = await run(process.argv.slice(2), {
|
|
|
14858
15007
|
readStdin,
|
|
14859
15008
|
exec,
|
|
14860
15009
|
detach: (command, args, { cwd, env }) => new Promise((resolve) => {
|
|
14861
|
-
const child =
|
|
15010
|
+
const child = spawn3(command, args, { cwd, env, stdio: "ignore", detached: true });
|
|
14862
15011
|
child.once("error", () => resolve(false));
|
|
14863
15012
|
child.once("spawn", () => {
|
|
14864
15013
|
child.unref();
|