@the-vibe-company/armada 0.2.34 → 0.2.36
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 +704 -61
- package/package.json +1 -1
package/dist/armada.js
CHANGED
|
@@ -8,7 +8,7 @@ import { hostname as hostname2 } from "node:os";
|
|
|
8
8
|
import { isatty } from "node:tty";
|
|
9
9
|
|
|
10
10
|
// src/cli.ts
|
|
11
|
-
import { dirname as
|
|
11
|
+
import { dirname as dirname8, join as join7, resolve as resolve3 } from "node:path";
|
|
12
12
|
|
|
13
13
|
// ../core/src/types.ts
|
|
14
14
|
var LABEL_PHASES = [
|
|
@@ -998,6 +998,21 @@ function waitingPullRequests(m, prs) {
|
|
|
998
998
|
return prs.filter((p) => p.state === "open").map((pr) => ({ pr, ticket: ticketOf.get(pr.url) ?? null })).sort((a, b) => a.pr.number - b.pr.number);
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
|
+
// ../core/src/herdr-profile.ts
|
|
1002
|
+
function herdrChoice(choice) {
|
|
1003
|
+
return {
|
|
1004
|
+
...choice,
|
|
1005
|
+
profile: {
|
|
1006
|
+
runtime: "herdr",
|
|
1007
|
+
agent: choice.profile.harness,
|
|
1008
|
+
model: choice.profile.model,
|
|
1009
|
+
effort: choice.profile.effort,
|
|
1010
|
+
fastMode: false
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
var herdrClaimHandle = (handle) => JSON.stringify({ workspace: handle.workspace, pane: handle.pane, agent: handle.agent });
|
|
1015
|
+
|
|
1001
1016
|
// ../core/src/npm.ts
|
|
1002
1017
|
var ARMADA_PACKAGE = CLI_PACKAGE;
|
|
1003
1018
|
var NPM_REGISTRY_URL = `https://registry.npmjs.org/${ARMADA_PACKAGE.replace("/", "%2f")}`;
|
|
@@ -2006,12 +2021,13 @@ var CONFIG_FILE = "armada.toml";
|
|
|
2006
2021
|
var PLAN_POLICIES = ["approve", "pre-approved"];
|
|
2007
2022
|
var routingLabelKey = (name) => name.normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{M}\p{N}]/gu, "");
|
|
2008
2023
|
var PROFILE_RUNTIMES = ["conductor", "claude-code"];
|
|
2024
|
+
var HERDR_HARNESSES = ["claude", "codex", "opencode"];
|
|
2009
2025
|
var CONFIG_DEFAULTS = {
|
|
2010
2026
|
language: "en",
|
|
2011
2027
|
readyLabel: "ready-for-agent",
|
|
2012
2028
|
phaseGroup: "Agent phase",
|
|
2013
2029
|
runtimeGroup: "Agent runtime",
|
|
2014
|
-
runtimes: ["Claude Code", "Codex", "Conductor"],
|
|
2030
|
+
runtimes: ["Claude Code", "Codex", "Conductor", "Herdr"],
|
|
2015
2031
|
silentAfterMinutes: 15,
|
|
2016
2032
|
quietAfterMinutes: 45,
|
|
2017
2033
|
coordinatorMinutes: 10,
|
|
@@ -2120,6 +2136,14 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
2120
2136
|
if (!isTable(profilesRaw))
|
|
2121
2137
|
problems.push(`"conductor.profiles" must be a table of profiles`);
|
|
2122
2138
|
const profilesT = isTable(profilesRaw) ? profilesRaw : {};
|
|
2139
|
+
const herdr = raw.herdr === undefined ? {} : raw.herdr;
|
|
2140
|
+
if (!isTable(herdr))
|
|
2141
|
+
problems.push(`"herdr" must be a table`);
|
|
2142
|
+
const herdrT = isTable(herdr) ? herdr : {};
|
|
2143
|
+
const herdrProfilesRaw = herdrT.profiles === undefined ? {} : herdrT.profiles;
|
|
2144
|
+
if (!isTable(herdrProfilesRaw))
|
|
2145
|
+
problems.push(`"herdr.profiles" must be a table of profiles`);
|
|
2146
|
+
const herdrProfilesT = isTable(herdrProfilesRaw) ? herdrProfilesRaw : {};
|
|
2123
2147
|
const known = [
|
|
2124
2148
|
["project", project, ["name", "slug"]],
|
|
2125
2149
|
["tracker", tracker, ["program_root", "language", "ready_label", "labels"]],
|
|
@@ -2147,7 +2171,8 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
2147
2171
|
],
|
|
2148
2172
|
["brief", briefT, ["extra"]],
|
|
2149
2173
|
["secrets", secretsT, ["names"]],
|
|
2150
|
-
["conductor", conductorT, ["default_profile", "profiles", "routing"]]
|
|
2174
|
+
["conductor", conductorT, ["default_profile", "profiles", "routing"]],
|
|
2175
|
+
["herdr", herdrT, ["default_profile", "profiles", "routing"]]
|
|
2151
2176
|
];
|
|
2152
2177
|
const profiles = {};
|
|
2153
2178
|
for (const [name, p] of Object.entries(profilesT)) {
|
|
@@ -2207,6 +2232,70 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
2207
2232
|
}
|
|
2208
2233
|
if (Array.isArray(routingRaw) && routingRaw.length && conductorT.default_profile === undefined && !Object.values(profiles).some((profile) => profile.when))
|
|
2209
2234
|
problems.push(`"conductor.default_profile" is required with [[conductor.routing]], for tickets no rule matches`);
|
|
2235
|
+
const herdrProfiles = {};
|
|
2236
|
+
for (const [name, p] of Object.entries(herdrProfilesT)) {
|
|
2237
|
+
const path = `herdr.profiles.${name}`;
|
|
2238
|
+
if (!isTable(p)) {
|
|
2239
|
+
problems.push(`"${path}" must be a table`);
|
|
2240
|
+
continue;
|
|
2241
|
+
}
|
|
2242
|
+
if (name === "__proto__") {
|
|
2243
|
+
problems.push(`"${path}" is not a usable profile name`);
|
|
2244
|
+
continue;
|
|
2245
|
+
}
|
|
2246
|
+
known.push([path, p, ["harness", "model", "effort", "extra_args", "when"]]);
|
|
2247
|
+
let harness = "claude";
|
|
2248
|
+
if (p.harness === undefined)
|
|
2249
|
+
problems.push(`missing required key "${path}.harness"`);
|
|
2250
|
+
else if (HERDR_HARNESSES.includes(p.harness))
|
|
2251
|
+
harness = p.harness;
|
|
2252
|
+
else
|
|
2253
|
+
problems.push(`"${path}.harness" must be one of ${HERDR_HARNESSES.map((h) => `"${h}"`).join(", ")}`);
|
|
2254
|
+
let extraArgs = [];
|
|
2255
|
+
if (p.extra_args !== undefined) {
|
|
2256
|
+
if (Array.isArray(p.extra_args) && p.extra_args.every((arg) => typeof arg === "string" && arg.trim()))
|
|
2257
|
+
extraArgs = [...p.extra_args];
|
|
2258
|
+
else
|
|
2259
|
+
problems.push(`"${path}.extra_args" must be a list of non-empty argument strings`);
|
|
2260
|
+
}
|
|
2261
|
+
herdrProfiles[name] = {
|
|
2262
|
+
...p.when !== undefined ? { when: str(p, path, "when") } : {},
|
|
2263
|
+
harness,
|
|
2264
|
+
model: str(p, path, "model"),
|
|
2265
|
+
effort: str(p, path, "effort"),
|
|
2266
|
+
extraArgs
|
|
2267
|
+
};
|
|
2268
|
+
}
|
|
2269
|
+
let herdrDefaultProfile = null;
|
|
2270
|
+
if (herdrT.default_profile !== undefined) {
|
|
2271
|
+
herdrDefaultProfile = str(herdrT, "herdr", "default_profile") || null;
|
|
2272
|
+
if (herdrDefaultProfile && !Object.hasOwn(herdrProfiles, herdrDefaultProfile))
|
|
2273
|
+
problems.push(`"herdr.default_profile" is "${herdrDefaultProfile}", but there is no [herdr.profiles.${herdrDefaultProfile}]`);
|
|
2274
|
+
}
|
|
2275
|
+
const herdrRouting = [];
|
|
2276
|
+
const herdrRoutingRaw = herdrT.routing ?? [];
|
|
2277
|
+
if (!Array.isArray(herdrRoutingRaw))
|
|
2278
|
+
problems.push(`"herdr.routing" must be a list of [[herdr.routing]] rules`);
|
|
2279
|
+
else
|
|
2280
|
+
for (const [i, r] of herdrRoutingRaw.entries()) {
|
|
2281
|
+
const path = `herdr.routing[${i + 1}]`;
|
|
2282
|
+
if (!isTable(r)) {
|
|
2283
|
+
problems.push(`"${path}" must be a table`);
|
|
2284
|
+
continue;
|
|
2285
|
+
}
|
|
2286
|
+
known.push([path, r, ["labels", "profile"]]);
|
|
2287
|
+
const labels = r.labels;
|
|
2288
|
+
const ok = Array.isArray(labels) && labels.length && labels.every((l) => typeof l === "string" && routingLabelKey(l));
|
|
2289
|
+
if (!ok)
|
|
2290
|
+
problems.push(`"${path}.labels" must be a non-empty list of Linear label names, each with a letter or digit`);
|
|
2291
|
+
const profile = str(r, path, "profile");
|
|
2292
|
+
if (profile && !Object.hasOwn(herdrProfiles, profile))
|
|
2293
|
+
problems.push(`"${path}.profile" is "${profile}", but there is no [herdr.profiles.${profile}]`);
|
|
2294
|
+
if (ok && profile)
|
|
2295
|
+
herdrRouting.push({ labels: labels.map((l) => l.trim()), profile });
|
|
2296
|
+
}
|
|
2297
|
+
if (Array.isArray(herdrRoutingRaw) && herdrRoutingRaw.length && herdrT.default_profile === undefined && !Object.values(herdrProfiles).some((profile) => profile.when))
|
|
2298
|
+
problems.push(`"herdr.default_profile" is required with [[herdr.routing]], for tickets no rule matches`);
|
|
2210
2299
|
for (const [path, t, keys] of known)
|
|
2211
2300
|
for (const key of Object.keys(t))
|
|
2212
2301
|
if (!keys.includes(key))
|
|
@@ -2368,7 +2457,8 @@ function parseConfig(text, source = CONFIG_FILE) {
|
|
|
2368
2457
|
},
|
|
2369
2458
|
brief: { extra },
|
|
2370
2459
|
secrets: { names: secretNames },
|
|
2371
|
-
conductor: { defaultProfile, profiles, routing }
|
|
2460
|
+
conductor: { defaultProfile, profiles, routing },
|
|
2461
|
+
herdr: { defaultProfile: herdrDefaultProfile, profiles: herdrProfiles, routing: herdrRouting }
|
|
2372
2462
|
};
|
|
2373
2463
|
if (problems.length)
|
|
2374
2464
|
throw new ConfigError(source, problems);
|
|
@@ -2392,7 +2482,7 @@ ready_label = "ready-for-agent"
|
|
|
2392
2482
|
[tracker.labels]
|
|
2393
2483
|
phase_group = "Agent phase"
|
|
2394
2484
|
runtime_group = "Agent runtime"
|
|
2395
|
-
runtimes = ["Claude Code", "Codex", "Conductor"]
|
|
2485
|
+
runtimes = ["Claude Code", "Codex", "Conductor", "Herdr"]
|
|
2396
2486
|
|
|
2397
2487
|
[github]
|
|
2398
2488
|
repository = ${q(p.repository)}
|
|
@@ -2469,6 +2559,23 @@ profile = "codex"
|
|
|
2469
2559
|
[[conductor.routing]]
|
|
2470
2560
|
labels = ["Bug"]
|
|
2471
2561
|
profile = "debug"
|
|
2562
|
+
|
|
2563
|
+
# Herdr profiles use one of its supported harnesses and are selected with the
|
|
2564
|
+
# same label and \`when\` rules as Conductor. Every extra argument is passed to
|
|
2565
|
+
# the selected harness exactly as written.
|
|
2566
|
+
# [herdr]
|
|
2567
|
+
# default_profile = "claude"
|
|
2568
|
+
|
|
2569
|
+
# [herdr.profiles.claude]
|
|
2570
|
+
# harness = "claude" # "claude", "codex" or "opencode"
|
|
2571
|
+
# model = "sonnet"
|
|
2572
|
+
# effort = "high"
|
|
2573
|
+
# extra_args = ["--verbose"]
|
|
2574
|
+
# when = "a ticket best handled by Claude"
|
|
2575
|
+
|
|
2576
|
+
# [[herdr.routing]]
|
|
2577
|
+
# labels = ["herdr"]
|
|
2578
|
+
# profile = "claude"
|
|
2472
2579
|
`;
|
|
2473
2580
|
}
|
|
2474
2581
|
function slugify(name) {
|
|
@@ -2562,44 +2669,49 @@ var checkProblems = (checks, requiredChecks) => checkIssues(checks, requiredChec
|
|
|
2562
2669
|
class ProfileError extends Error {
|
|
2563
2670
|
name = "ProfileError";
|
|
2564
2671
|
}
|
|
2565
|
-
var
|
|
2566
|
-
var
|
|
2567
|
-
|
|
2568
|
-
|
|
2672
|
+
var profileSection = (config, runtime) => runtime === "herdr" ? config.herdr : config.conductor;
|
|
2673
|
+
var runtimeName = (runtime) => runtime === "herdr" ? "Herdr" : "Conductor";
|
|
2674
|
+
var hasProfileRules = (config, runtime = "conductor") => Object.values(profileSection(config, runtime).profiles).some((profile) => !!profile.when);
|
|
2675
|
+
var profileChoiceHint = (ticket, runtime = "conductor") => `Choose ${runtime === "herdr" ? "a Herdr profile" : "a profile"}: read the ticket and its parent, match the profiles' when rules, then run armada ${runtime === "herdr" ? "launch" : "brief"} ${ticket}${runtime === "herdr" ? " --runtime herdr" : ""} --profile <name> --reason "<why>"`;
|
|
2676
|
+
function routeProfile(config, labels, runtime = "conductor") {
|
|
2677
|
+
const { routing, defaultProfile, profiles } = profileSection(config, runtime);
|
|
2569
2678
|
for (const [i, rule] of routing.entries()) {
|
|
2570
2679
|
const keys = rule.labels.map(routingLabelKey);
|
|
2571
2680
|
const label = labels.find((l) => keys.includes(routingLabelKey(l)));
|
|
2572
2681
|
if (label !== undefined)
|
|
2573
2682
|
return { name: rule.profile, source: "rule", rule: { index: i + 1, labels: rule.labels, label } };
|
|
2574
2683
|
}
|
|
2575
|
-
if (hasProfileRules(config))
|
|
2684
|
+
if (hasProfileRules(config, runtime))
|
|
2576
2685
|
return null;
|
|
2577
2686
|
if (defaultProfile)
|
|
2578
2687
|
return { name: defaultProfile, source: "default", rule: null };
|
|
2579
2688
|
const names = Object.keys(profiles);
|
|
2580
2689
|
return names.length === 1 && names[0] ? { name: names[0], source: "only", rule: null } : null;
|
|
2581
2690
|
}
|
|
2582
|
-
function describeRoute(route, config) {
|
|
2691
|
+
function describeRoute(route, config, runtime = "conductor") {
|
|
2692
|
+
const section = profileSection(config, runtime);
|
|
2693
|
+
const sectionName = runtime === "herdr" ? "herdr" : "conductor";
|
|
2583
2694
|
if (route.rule)
|
|
2584
|
-
return `rule ${route.rule.index} of [[
|
|
2695
|
+
return `rule ${route.rule.index} of [[${sectionName}.routing]] (label "${route.rule.label}")`;
|
|
2585
2696
|
if (route.source === "default")
|
|
2586
|
-
return
|
|
2587
|
-
return "the only profile in armada.toml";
|
|
2697
|
+
return section.routing.length ? `${sectionName}.default_profile (no routing rule matched)` : `${sectionName}.default_profile`;
|
|
2698
|
+
return runtime === "herdr" ? "the only Herdr profile in armada.toml" : "the only profile in armada.toml";
|
|
2588
2699
|
}
|
|
2589
|
-
function checkRequestedProfile(config, requested) {
|
|
2590
|
-
|
|
2700
|
+
function checkRequestedProfile(config, requested, runtime = "conductor") {
|
|
2701
|
+
const { profiles } = profileSection(config, runtime);
|
|
2702
|
+
if (requested === null || Object.hasOwn(profiles, requested))
|
|
2591
2703
|
return;
|
|
2592
|
-
const names = Object.keys(
|
|
2593
|
-
throw new ProfileError(`no
|
|
2704
|
+
const names = Object.keys(profiles);
|
|
2705
|
+
throw new ProfileError(`no ${runtimeName(runtime)} profile "${requested}" (available: ${names.join(", ") || "none"})`);
|
|
2594
2706
|
}
|
|
2595
|
-
function chooseProfile(config, input) {
|
|
2596
|
-
checkRequestedProfile(config, input.requested);
|
|
2597
|
-
const { profiles } = config
|
|
2707
|
+
function chooseProfile(config, input, runtime = "conductor") {
|
|
2708
|
+
checkRequestedProfile(config, input.requested, runtime);
|
|
2709
|
+
const { profiles } = profileSection(config, runtime);
|
|
2598
2710
|
const reason = input.reason?.replace(/\s+/g, " ").trim() || null;
|
|
2599
|
-
const route = routeProfile(config, input.labels);
|
|
2600
|
-
const semantic = !route && hasProfileRules(config);
|
|
2711
|
+
const route = routeProfile(config, input.labels, runtime);
|
|
2712
|
+
const semantic = !route && hasProfileRules(config, runtime);
|
|
2601
2713
|
if (semantic && (input.requested === null || !reason))
|
|
2602
|
-
throw new ProfileError(profileChoiceHint(input.ticket));
|
|
2714
|
+
throw new ProfileError(profileChoiceHint(input.ticket, runtime));
|
|
2603
2715
|
if (input.requested === null) {
|
|
2604
2716
|
if (route && Object.hasOwn(profiles, route.name))
|
|
2605
2717
|
return {
|
|
@@ -2609,12 +2721,12 @@ function chooseProfile(config, input) {
|
|
|
2609
2721
|
rule: route.rule,
|
|
2610
2722
|
routed: route.name,
|
|
2611
2723
|
reason,
|
|
2612
|
-
why: describeRoute(route, config)
|
|
2724
|
+
why: describeRoute(route, config, runtime)
|
|
2613
2725
|
};
|
|
2614
2726
|
const names = Object.keys(profiles);
|
|
2615
2727
|
if (!names.length)
|
|
2616
2728
|
return null;
|
|
2617
|
-
throw new ProfileError(`several
|
|
2729
|
+
throw new ProfileError(`several ${runtimeName(runtime)} profiles and no ${runtime}.default_profile; pass --profile (${names.join(", ")})`);
|
|
2618
2730
|
}
|
|
2619
2731
|
const name = input.requested;
|
|
2620
2732
|
const profile = profiles[name];
|
|
@@ -2626,11 +2738,11 @@ function chooseProfile(config, input) {
|
|
|
2626
2738
|
rule: route.rule,
|
|
2627
2739
|
routed: name,
|
|
2628
2740
|
reason,
|
|
2629
|
-
why: describeRoute(route, config)
|
|
2741
|
+
why: describeRoute(route, config, runtime)
|
|
2630
2742
|
};
|
|
2631
|
-
if (route && !reason && config.
|
|
2632
|
-
throw new ProfileError(`${input.ticket} is routed to "${route.name}" by ${describeRoute(route, config)}; say why "${name}" instead with --reason "<why>"`);
|
|
2633
|
-
const why = semantic ? `Chosen by the coordinator: ${reason}` : `--profile${route ? `, instead of "${route.name}" from ${describeRoute(route, config)}` : ""}${reason ? `: ${reason}` : ""}`;
|
|
2743
|
+
if (route && !reason && profileSection(config, runtime).routing.length)
|
|
2744
|
+
throw new ProfileError(`${input.ticket} is routed to "${route.name}" by ${describeRoute(route, config, runtime)}; say why "${name}" instead with --reason "<why>"`);
|
|
2745
|
+
const why = semantic ? `Chosen by the coordinator: ${reason}` : `--profile${route ? `, instead of "${route.name}" from ${describeRoute(route, config, runtime)}` : ""}${reason ? `: ${reason}` : ""}`;
|
|
2634
2746
|
return { name, profile, source: "requested", rule: null, routed: route?.name ?? null, reason, why };
|
|
2635
2747
|
}
|
|
2636
2748
|
|
|
@@ -2869,12 +2981,15 @@ async function claimTicket(ctx, input) {
|
|
|
2869
2981
|
throw new Refusal(`${ticket.id} already carries the agent phase "${ticket.agentPhase}"`, another);
|
|
2870
2982
|
if (input.profile)
|
|
2871
2983
|
try {
|
|
2872
|
-
|
|
2984
|
+
const selection = {
|
|
2873
2985
|
ticket: ticket.id,
|
|
2874
2986
|
labels: ticket.labels.map((l) => l.name),
|
|
2875
2987
|
requested: input.profile,
|
|
2876
2988
|
reason: input.reason ?? null
|
|
2877
|
-
}
|
|
2989
|
+
};
|
|
2990
|
+
const local = input.runtime.toLowerCase() === "herdr";
|
|
2991
|
+
const choice = local ? chooseProfile(config, selection, "herdr") : null;
|
|
2992
|
+
profile = local ? choice ? herdrChoice(choice) : null : chooseProfile(config, selection);
|
|
2878
2993
|
} catch (err) {
|
|
2879
2994
|
if (err instanceof ProfileError)
|
|
2880
2995
|
throw new Refusal(err.message, `armada brief ${ticket.id}, which shows the profile the ticket routes to`);
|
|
@@ -3150,7 +3265,7 @@ function buildBrief(input) {
|
|
|
3150
3265
|
const warnings = [...new Set([...ticket.warnings, ...program.warnings])];
|
|
3151
3266
|
let choice;
|
|
3152
3267
|
try {
|
|
3153
|
-
choice = chooseProfile(config, {
|
|
3268
|
+
choice = input.herdr ? herdrChoice(input.herdr.choice) : chooseProfile(config, {
|
|
3154
3269
|
ticket: ticket.id,
|
|
3155
3270
|
labels: ticket.labels,
|
|
3156
3271
|
requested: input.profile,
|
|
@@ -3190,10 +3305,10 @@ function buildBrief(input) {
|
|
|
3190
3305
|
const pkg = `${ARMADA_PACKAGE}@${pinned}`;
|
|
3191
3306
|
const branch = ticket.branchName;
|
|
3192
3307
|
const runtime = choice?.profile.runtime ?? "conductor";
|
|
3193
|
-
const handle = runtime === "claude-code" ? subagentName(ticket.id) : CONDUCTOR_HANDLE;
|
|
3308
|
+
const handle = input.herdr ? shellWord(input.herdr.handle) : runtime === "claude-code" ? subagentName(ticket.id) : CONDUCTOR_HANDLE;
|
|
3194
3309
|
const claimCommand = [
|
|
3195
3310
|
`armada claim ${ticket.id} --runtime ${runtime} --handle ${handle}`,
|
|
3196
|
-
branch ? ` --branch ${branch}` : "",
|
|
3311
|
+
branch ? ` --branch ${shellWord(branch)}` : "",
|
|
3197
3312
|
choice ? ` --profile ${shellWord(choice.name)}` : "",
|
|
3198
3313
|
choice?.reason ? ` --reason ${shellWord(choice.reason)}` : "",
|
|
3199
3314
|
...input.validation?.rules.length ? [
|
|
@@ -3245,6 +3360,7 @@ function buildBrief(input) {
|
|
|
3245
3360
|
install: `npm install -g ${pkg}`,
|
|
3246
3361
|
fallback: `npm exec --yes --package=${pkg} -- armada`,
|
|
3247
3362
|
claimCommand,
|
|
3363
|
+
...input.herdr ? { handle: input.herdr.handle } : {},
|
|
3248
3364
|
launch: launch ? {
|
|
3249
3365
|
command: `armada login --launch-token ${shellWord(launch.token)}${launch.apiUrl ? ` --api-url ${shellWord(launch.apiUrl)}` : ""}`,
|
|
3250
3366
|
expiresAt: launch.expiresAt
|
|
@@ -3306,7 +3422,7 @@ function renderPrompt(b) {
|
|
|
3306
3422
|
b.install,
|
|
3307
3423
|
...b.launch ? [b.launch.command] : [],
|
|
3308
3424
|
b.claimCommand,
|
|
3309
|
-
`armada heartbeat --every 5m --ticket ${t.id} --handle ${subagent ? subagentName(t.id) : CONDUCTOR_HANDLE} --parent "$PPID"${subagent ? "" : " --background"}`,
|
|
3425
|
+
`armada heartbeat --every 5m --ticket ${t.id} --handle ${b.handle ? shellWord(b.handle) : subagent ? subagentName(t.id) : CONDUCTOR_HANDLE} --parent "$PPID"${subagent ? "" : " --background"}`,
|
|
3310
3426
|
"```",
|
|
3311
3427
|
"",
|
|
3312
3428
|
subagent ? "Keep this Bash heartbeat in the subagent's background: it dies with the subagent, which is intended. Do not detach it from the subagent. If background processes are unavailable, report manually at least every 15 minutes." : "The heartbeat detaches from the short-lived command shell (a new process group, like nohup + setsid), keeps a PID file under ~/.config/armada/watch/, and stays alive between turns and while waiting for messages. Its parent is the persistent agent PID ($PPID in the command shell), never the shell PID ($$). If startup fails or the runtime cannot keep a background process, report manually at least every 15 minutes instead.",
|
|
@@ -3321,8 +3437,12 @@ function renderPrompt(b) {
|
|
|
3321
3437
|
"",
|
|
3322
3438
|
"## Branch",
|
|
3323
3439
|
"",
|
|
3324
|
-
t.branch ? `Work on \`${t.branch}\`. Your ${subagent ? "worktree starts on a branch Claude Code" : "workspace starts on a branch Conductor"} named; rename it before your first commit: \`git branch -m ${t.branch}\`.` : "Linear suggests no branch name for this ticket; name yours after the ticket id.",
|
|
3440
|
+
b.runtime === "herdr" ? `Herdr already created your own worktree on \`${t.branch}\`. Work only there. Before editing, check \`git branch --show-current\` and \`git rev-parse --show-toplevel\`; do not rename the branch or switch the coordinator's checkout. Your runtime handle is \`${b.handle}\`.` : t.branch ? `Work on \`${t.branch}\`. Your ${subagent ? "worktree starts on a branch Claude Code" : "workspace starts on a branch Conductor"} named; rename it before your first commit: \`git branch -m ${t.branch}\`.` : "Linear suggests no branch name for this ticket; name yours after the ticket id.",
|
|
3325
3441
|
"",
|
|
3442
|
+
...b.runtime === "herdr" ? [
|
|
3443
|
+
`You share the coordinator's machine, but own only ${t.id}. Pass \`--ticket ${t.id}\` to every \`armada report\`, \`ask\`, \`release\` and \`validate\`; an inherited \`ARMADA_TICKET\` may name the coordinator's ticket. Herdr keeps your terminal alive when the coordinator disconnects.`,
|
|
3444
|
+
""
|
|
3445
|
+
] : [],
|
|
3326
3446
|
...subagent ? [
|
|
3327
3447
|
`You share the coordinator's machine and environment: its \`ARMADA_TICKET\`, if it has one, is not yours. Pass \`--ticket ${t.id}\` to every \`armada report\`, \`ask\` and \`release\`. You end when the coordinator's session ends: report at every step, so the ticket always says where you are.`,
|
|
3328
3448
|
""
|
|
@@ -9901,7 +10021,7 @@ ${attachments.join(`
|
|
|
9901
10021
|
};
|
|
9902
10022
|
}
|
|
9903
10023
|
// package.json
|
|
9904
|
-
var version = "0.2.
|
|
10024
|
+
var version = "0.2.36";
|
|
9905
10025
|
|
|
9906
10026
|
// src/attach.ts
|
|
9907
10027
|
import { resolve } from "node:path";
|
|
@@ -10559,7 +10679,7 @@ async function claim(io, config, credentials, a) {
|
|
|
10559
10679
|
if (reason && !profile)
|
|
10560
10680
|
throw new UsageError("--reason goes with --profile: it says why the routed profile is not used");
|
|
10561
10681
|
try {
|
|
10562
|
-
checkRequestedProfile(config, profile);
|
|
10682
|
+
checkRequestedProfile(config, profile, a.options.runtime?.toLowerCase() === "herdr" ? "herdr" : "conductor");
|
|
10563
10683
|
} catch (err) {
|
|
10564
10684
|
if (err instanceof ProfileError)
|
|
10565
10685
|
throw new UsageError(err.message);
|
|
@@ -11230,6 +11350,187 @@ ${next.line}
|
|
|
11230
11350
|
return 0;
|
|
11231
11351
|
}
|
|
11232
11352
|
|
|
11353
|
+
// src/local-tools.ts
|
|
11354
|
+
import { stripVTControlCharacters } from "node:util";
|
|
11355
|
+
var MINIMUM_HERDR_VERSION = "0.9.1";
|
|
11356
|
+
var TOOLS = {
|
|
11357
|
+
herdr: { command: "herdr", install: "curl -fsSL https://herdr.dev/install.sh | sh" },
|
|
11358
|
+
claude: { command: "claude", install: "curl -fsSL https://claude.ai/install.sh | bash" },
|
|
11359
|
+
codex: { command: "codex", install: "npm i -g @openai/codex" },
|
|
11360
|
+
opencode: { command: "opencode", install: "curl -fsSL https://opencode.ai/install | bash" },
|
|
11361
|
+
deepseek: { command: "dsh", install: "npm i -g @deepseek-ai/dsh" }
|
|
11362
|
+
};
|
|
11363
|
+
function localHarnesses(config) {
|
|
11364
|
+
return [...new Set(Object.values(config.herdr?.profiles ?? {}).map((profile) => profile.harness))];
|
|
11365
|
+
}
|
|
11366
|
+
async function probe(io, command, args) {
|
|
11367
|
+
if (!io.exec)
|
|
11368
|
+
return null;
|
|
11369
|
+
return io.exec(command, args, { cwd: io.cwd }).catch(() => null);
|
|
11370
|
+
}
|
|
11371
|
+
function versionOf(result) {
|
|
11372
|
+
if (result.code !== 0)
|
|
11373
|
+
return null;
|
|
11374
|
+
for (const line of `${result.stdout}
|
|
11375
|
+
${result.stderr}`.split(`
|
|
11376
|
+
`)) {
|
|
11377
|
+
const match = line.trim().match(/^(?:(?:herdr|claude|codex(?:-cli)?|opencode|dsh)\s+)?v?(\d+\.\d+\.\d+)(-[\w.-]+)?(?:\+[\w.-]+)?(?:\s|\(|$)/i);
|
|
11378
|
+
if (match?.[1])
|
|
11379
|
+
return { version: match[1], prerelease: !!match[2] };
|
|
11380
|
+
}
|
|
11381
|
+
return null;
|
|
11382
|
+
}
|
|
11383
|
+
async function detectTool(io, name) {
|
|
11384
|
+
const definition = TOOLS[name];
|
|
11385
|
+
const base = { name, ...definition, version: null };
|
|
11386
|
+
if (!io.exec)
|
|
11387
|
+
return { ...base, state: "unknown" };
|
|
11388
|
+
let result;
|
|
11389
|
+
try {
|
|
11390
|
+
result = await io.exec(definition.command, ["--version"], { cwd: io.cwd });
|
|
11391
|
+
} catch (error) {
|
|
11392
|
+
const missing = typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
11393
|
+
return { ...base, state: missing ? "missing" : "unusable" };
|
|
11394
|
+
}
|
|
11395
|
+
const found = versionOf(result);
|
|
11396
|
+
if (!found)
|
|
11397
|
+
return { ...base, state: "unusable" };
|
|
11398
|
+
const old = name === "herdr" && (found.prerelease || compareVersions(found.version, MINIMUM_HERDR_VERSION) < 0);
|
|
11399
|
+
return { ...base, version: found.version, state: old ? "old" : "ready" };
|
|
11400
|
+
}
|
|
11401
|
+
function toolCheck(tool) {
|
|
11402
|
+
const { command, state, version } = tool;
|
|
11403
|
+
const message = state === "ready" ? `${command} ${version} is on PATH${tool.name === "herdr" ? ` (minimum ${MINIMUM_HERDR_VERSION})` : ""}` : state === "missing" ? `${command} is not installed` : state === "old" ? `herdr needs stable ${MINIMUM_HERDR_VERSION} or newer; found ${version}` : state === "unknown" ? `${command}: could not check installation` : `${command} could not report a usable version`;
|
|
11404
|
+
return {
|
|
11405
|
+
id: `local-${command}`,
|
|
11406
|
+
level: state === "ready" ? "ok" : "error",
|
|
11407
|
+
message,
|
|
11408
|
+
fix: state === "ready" ? null : `\`${tool.install}\`${state === "unusable" ? `; then check \`${command} --version\` and PATH` : ""}`
|
|
11409
|
+
};
|
|
11410
|
+
}
|
|
11411
|
+
function installerEnv(env) {
|
|
11412
|
+
const names = [
|
|
11413
|
+
"PATH",
|
|
11414
|
+
"HOME",
|
|
11415
|
+
"USER",
|
|
11416
|
+
"LOGNAME",
|
|
11417
|
+
"SHELL",
|
|
11418
|
+
"TMPDIR",
|
|
11419
|
+
"TMP",
|
|
11420
|
+
"TEMP",
|
|
11421
|
+
"XDG_CONFIG_HOME",
|
|
11422
|
+
"XDG_DATA_HOME",
|
|
11423
|
+
"npm_config_prefix",
|
|
11424
|
+
"NPM_CONFIG_PREFIX"
|
|
11425
|
+
];
|
|
11426
|
+
return Object.fromEntries(names.filter((name) => env[name] !== undefined).map((name) => [name, env[name]]));
|
|
11427
|
+
}
|
|
11428
|
+
async function signInCheck(io, harness) {
|
|
11429
|
+
const command = TOOLS[harness].command;
|
|
11430
|
+
let state = "unknown";
|
|
11431
|
+
let login;
|
|
11432
|
+
if (harness === "claude") {
|
|
11433
|
+
login = "claude auth login";
|
|
11434
|
+
const result = await probe(io, command, ["auth", "status"]);
|
|
11435
|
+
if (result && (result.code === 0 || result.code === 1)) {
|
|
11436
|
+
try {
|
|
11437
|
+
const status = JSON.parse(result.stdout);
|
|
11438
|
+
if (typeof status === "object" && status !== null && "loggedIn" in status) {
|
|
11439
|
+
if (status.loggedIn === true && result.code === 0)
|
|
11440
|
+
state = "ready";
|
|
11441
|
+
if (status.loggedIn === false)
|
|
11442
|
+
state = "missing";
|
|
11443
|
+
}
|
|
11444
|
+
} catch {}
|
|
11445
|
+
}
|
|
11446
|
+
} else if (harness === "codex") {
|
|
11447
|
+
login = "codex login";
|
|
11448
|
+
const result = await probe(io, command, ["login", "status"]);
|
|
11449
|
+
if (result?.code === 0)
|
|
11450
|
+
state = "ready";
|
|
11451
|
+
else if (result?.code === 1 && /(?:^|\n)Not logged in\s*(?:\n|$)/i.test(`${result.stdout}
|
|
11452
|
+
${result.stderr}`))
|
|
11453
|
+
state = "missing";
|
|
11454
|
+
} else if (harness === "opencode") {
|
|
11455
|
+
login = "opencode auth login";
|
|
11456
|
+
const result = await probe(io, command, ["auth", "list"]);
|
|
11457
|
+
if (result?.code === 0) {
|
|
11458
|
+
const text = stripVTControlCharacters(`${result.stdout}
|
|
11459
|
+
${result.stderr}`);
|
|
11460
|
+
const count = text.match(/\b(\d+) credentials\b/);
|
|
11461
|
+
const environment = text.match(/\b(\d+) environment variables?\b/);
|
|
11462
|
+
if (count)
|
|
11463
|
+
state = Number(count[1]) > 0 || Number(environment?.[1] ?? 0) > 0 ? "ready" : "missing";
|
|
11464
|
+
}
|
|
11465
|
+
} else {
|
|
11466
|
+
login = "dsh web";
|
|
11467
|
+
}
|
|
11468
|
+
return {
|
|
11469
|
+
id: `local-${command}-sign-in`,
|
|
11470
|
+
level: state === "ready" ? "ok" : state === "missing" ? "error" : "warning",
|
|
11471
|
+
message: state === "ready" ? `${command} reports credentials are present${harness === "opencode" ? "; the owner must check the selected provider" : ""}` : state === "missing" ? `${command} is not signed in` : `${command}: could not check sign-in`,
|
|
11472
|
+
fix: state === "ready" ? null : `the owner runs \`${login}\`${harness === "deepseek" ? " and configures the provider in Settings → Models" : ""}; Armada never runs sign-in`
|
|
11473
|
+
};
|
|
11474
|
+
}
|
|
11475
|
+
async function detectLocalTools(io, harnesses) {
|
|
11476
|
+
const tools = [];
|
|
11477
|
+
const checks = [];
|
|
11478
|
+
for (const name of ["herdr", ...new Set(harnesses)]) {
|
|
11479
|
+
const tool = await detectTool(io, name);
|
|
11480
|
+
tools.push(tool);
|
|
11481
|
+
checks.push(toolCheck(tool));
|
|
11482
|
+
if (name !== "herdr" && tool.state === "ready")
|
|
11483
|
+
checks.push(await signInCheck(io, name));
|
|
11484
|
+
}
|
|
11485
|
+
return { tools, checks, ready: !checks.some((check) => check.level === "error") };
|
|
11486
|
+
}
|
|
11487
|
+
async function offerLocalInstalls(io, detected, options = {}) {
|
|
11488
|
+
const platform = io.platform ?? process.platform;
|
|
11489
|
+
if (options.readOnly || !io.interactive || io.env.CI || !io.prompt || !io.spawn || platform !== "darwin" && platform !== "linux")
|
|
11490
|
+
return detected;
|
|
11491
|
+
let attempted = false;
|
|
11492
|
+
for (const tool of detected.tools) {
|
|
11493
|
+
if (tool.state === "ready" || tool.state === "unknown")
|
|
11494
|
+
continue;
|
|
11495
|
+
const check = toolCheck(tool);
|
|
11496
|
+
const answer = await io.prompt(`${check.message}: \`${tool.install}\` — install now? [y/N] `, { hidden: false });
|
|
11497
|
+
if (answer === null)
|
|
11498
|
+
break;
|
|
11499
|
+
if (!/^(y|yes)$/i.test(answer.trim()))
|
|
11500
|
+
continue;
|
|
11501
|
+
attempted = true;
|
|
11502
|
+
const definition = TOOLS[tool.name];
|
|
11503
|
+
const npm = tool.name === "codex" || tool.name === "deepseek";
|
|
11504
|
+
const code = await io.spawn(npm ? "npm" : "sh", npm ? ["i", "-g", tool.name === "codex" ? "@openai/codex" : "@deepseek-ai/dsh"] : ["-c", definition.install], { cwd: io.cwd, env: installerEnv(io.env) }).catch(() => null);
|
|
11505
|
+
if (code !== 0)
|
|
11506
|
+
io.stderr(`${tool.command} installation failed${code === null ? "" : ` (exit ${code})`}. Run \`${definition.install}\` yourself.
|
|
11507
|
+
`);
|
|
11508
|
+
}
|
|
11509
|
+
if (!attempted)
|
|
11510
|
+
return detected;
|
|
11511
|
+
const result = await detectLocalTools(io, detected.tools.filter((tool) => tool.name !== "herdr").map((tool) => tool.name));
|
|
11512
|
+
if (result.tools.some((tool) => tool.state !== "ready"))
|
|
11513
|
+
io.stderr(`Some local tools still cannot run. Check PATH, open a new terminal if needed, and retry.
|
|
11514
|
+
`);
|
|
11515
|
+
return result;
|
|
11516
|
+
}
|
|
11517
|
+
async function ensureLocalTools(io, harness) {
|
|
11518
|
+
const print = (detected) => {
|
|
11519
|
+
for (const check of detected.checks) {
|
|
11520
|
+
if (check.level === "ok")
|
|
11521
|
+
continue;
|
|
11522
|
+
io.stderr(`${check.message}${check.fix ? `: ${check.fix}` : ""}
|
|
11523
|
+
`);
|
|
11524
|
+
}
|
|
11525
|
+
};
|
|
11526
|
+
const detected = await detectLocalTools(io, [harness]);
|
|
11527
|
+
print(detected);
|
|
11528
|
+
const result = await offerLocalInstalls(io, detected);
|
|
11529
|
+
if (result !== detected)
|
|
11530
|
+
print(result);
|
|
11531
|
+
return result.ready;
|
|
11532
|
+
}
|
|
11533
|
+
|
|
11233
11534
|
// src/repo.ts
|
|
11234
11535
|
import { lstat, mkdir as mkdir2, readdir, readFile as readFile2, readlink, rm as rm2, symlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
11235
11536
|
import { dirname as dirname4, join as join3, relative, sep } from "node:path";
|
|
@@ -11445,7 +11746,7 @@ function versionChecks(host, api, armadaVersion, outdated) {
|
|
|
11445
11746
|
];
|
|
11446
11747
|
}
|
|
11447
11748
|
var BUNDLED_CONDUCTOR = "/Applications/Conductor.app/Contents/Resources/bin/conductor";
|
|
11448
|
-
async function
|
|
11749
|
+
async function versionOf2(io, command) {
|
|
11449
11750
|
if (!io.exec)
|
|
11450
11751
|
return null;
|
|
11451
11752
|
try {
|
|
@@ -11459,7 +11760,7 @@ async function versionOf(io, command) {
|
|
|
11459
11760
|
async function conductorChecks(io, config) {
|
|
11460
11761
|
if (!io.exec || !Object.values(config?.conductor.profiles ?? {}).some((p) => p.runtime === "conductor"))
|
|
11461
11762
|
return [];
|
|
11462
|
-
const onPath = await
|
|
11763
|
+
const onPath = await versionOf2(io, "conductor");
|
|
11463
11764
|
if (onPath !== null)
|
|
11464
11765
|
return [
|
|
11465
11766
|
{ id: "conductor-cli", level: "ok", message: `conductor ${onPath ? `${onPath} ` : ""}is on PATH`, fix: null }
|
|
@@ -11470,7 +11771,7 @@ async function conductorChecks(io, config) {
|
|
|
11470
11771
|
const link = (dir) => `ln -s "${BUNDLED_CONDUCTOR}" ${dir}/conductor`;
|
|
11471
11772
|
const pathLine = `export PATH="${BUNDLED_CONDUCTOR.slice(0, -"/conductor".length)}:$PATH"`;
|
|
11472
11773
|
const fix = userBin ? link(`~/${userBin}`) : `add \`${pathLine}\` to your shell profile (~/.zshrc), or \`sudo ${link("/usr/local/bin")}\``;
|
|
11473
|
-
if (await
|
|
11774
|
+
if (await versionOf2(io, BUNDLED_CONDUCTOR) !== null)
|
|
11474
11775
|
return [
|
|
11475
11776
|
{
|
|
11476
11777
|
id: "conductor-cli",
|
|
@@ -11553,7 +11854,13 @@ async function secretChecks(api, config, credentials) {
|
|
|
11553
11854
|
return [{ id: "secrets", level: "ok", message: `the secrets the project expects are set: ${list}`, fix: null }];
|
|
11554
11855
|
return warning(`the project expects the secrets ${list}; not set in Armada: ${missing.join(", ")}`, "an owner or admin runs `armada secrets set <NAME>` for each (or sets it on the Keys page of Armada)");
|
|
11555
11856
|
}
|
|
11556
|
-
async function
|
|
11857
|
+
async function localRuntimeChecks(io, config, options = { readOnly: true }) {
|
|
11858
|
+
const harnesses = config ? localHarnesses(config) : [];
|
|
11859
|
+
if (!harnesses.length)
|
|
11860
|
+
return [];
|
|
11861
|
+
return (await offerLocalInstalls(io, await detectLocalTools(io, harnesses), options)).checks;
|
|
11862
|
+
}
|
|
11863
|
+
async function buildDoctor(io, armadaVersion, options = { readOnly: true }) {
|
|
11557
11864
|
const root = (io.exec ? await gitRoot(io.exec, io.cwd) : null) ?? io.cwd;
|
|
11558
11865
|
const upgrade = (err) => err instanceof ArmadaApiError && err.upgrade ? err : null;
|
|
11559
11866
|
let outdated = null;
|
|
@@ -11584,6 +11891,7 @@ async function buildDoctor(io, armadaVersion) {
|
|
|
11584
11891
|
...keyFileChecks(machine, credentials),
|
|
11585
11892
|
...await labelChecks(io, config, credentials),
|
|
11586
11893
|
...await conductorChecks(io, config),
|
|
11894
|
+
...await localRuntimeChecks(io, config, options),
|
|
11587
11895
|
...config ? await reviewRuntimeChecks(io, root) : [],
|
|
11588
11896
|
...await secretChecks(api, config, credentials)
|
|
11589
11897
|
];
|
|
@@ -11621,7 +11929,7 @@ function renderDoctor(r) {
|
|
|
11621
11929
|
`;
|
|
11622
11930
|
}
|
|
11623
11931
|
async function doctor(io, json, armadaVersion) {
|
|
11624
|
-
const report = await buildDoctor(io, armadaVersion);
|
|
11932
|
+
const report = await buildDoctor(io, armadaVersion, { readOnly: json });
|
|
11625
11933
|
io.stdout(json ? `${JSON.stringify(report, null, 2)}
|
|
11626
11934
|
` : renderDoctor(report));
|
|
11627
11935
|
return report.errors ? 1 : 0;
|
|
@@ -11924,7 +12232,172 @@ async function init(io, opts) {
|
|
|
11924
12232
|
}
|
|
11925
12233
|
|
|
11926
12234
|
// src/launch.ts
|
|
11927
|
-
|
|
12235
|
+
import { dirname as dirname5, join as join5 } from "node:path";
|
|
12236
|
+
|
|
12237
|
+
// src/herdr.ts
|
|
12238
|
+
var harnessArgs = (p) => [
|
|
12239
|
+
"--model",
|
|
12240
|
+
p.harness === "opencode" ? `${p.model.split("#")[0]}#${p.effort}` : p.model,
|
|
12241
|
+
...p.harness === "codex" ? ["-c", `model_reasoning_effort=${JSON.stringify(p.effort)}`] : p.harness === "claude" ? ["--effort", p.effort] : [],
|
|
12242
|
+
...p.extraArgs
|
|
12243
|
+
];
|
|
12244
|
+
var object = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : null;
|
|
12245
|
+
var id = (v) => typeof v === "string" && /^[a-zA-Z0-9:_-]{1,128}$/.test(v);
|
|
12246
|
+
var runtimeEnvironment = (env) => Object.fromEntries(Object.entries(env).filter(([name]) => /^(PATH|HOME|USER|LOGNAME|SHELL|TMPDIR|TMP|TEMP|LANG|TERM|LC_[A-Z_]+|XDG_(CONFIG_HOME|DATA_HOME|STATE_HOME|CACHE_HOME|RUNTIME_DIR)|HERDR_(SESSION|SOCKET_PATH|CONFIG_PATH))$/.test(name)));
|
|
12247
|
+
var credentialNames = (env, extra) => [
|
|
12248
|
+
...new Set([
|
|
12249
|
+
"LINEAR_API_KEY",
|
|
12250
|
+
"GITHUB_TOKEN",
|
|
12251
|
+
"GH_TOKEN",
|
|
12252
|
+
"ARMADA_API_KEY",
|
|
12253
|
+
"ARMADA_SESSION_TOKEN",
|
|
12254
|
+
"ARMADA_SIGNED_IN_TO",
|
|
12255
|
+
"ARMADA_API_URL",
|
|
12256
|
+
"OPENAI_API_KEY",
|
|
12257
|
+
"ANTHROPIC_API_KEY",
|
|
12258
|
+
...Object.keys(env).filter((name) => /^(ARMADA_|CONDUCTOR_)|(?:KEY|TOKEN|SECRET|PASSWORD)$/.test(name)),
|
|
12259
|
+
...extra
|
|
12260
|
+
])
|
|
12261
|
+
].filter((name) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(name)).sort();
|
|
12262
|
+
|
|
12263
|
+
class Herdr {
|
|
12264
|
+
io;
|
|
12265
|
+
constructor(io) {
|
|
12266
|
+
this.io = io;
|
|
12267
|
+
}
|
|
12268
|
+
async call(args, timeoutMs = 40000) {
|
|
12269
|
+
const operation = args.slice(0, 2).join(" ");
|
|
12270
|
+
let reply;
|
|
12271
|
+
let code;
|
|
12272
|
+
try {
|
|
12273
|
+
if (!this.io.exec)
|
|
12274
|
+
throw new Error("no exec");
|
|
12275
|
+
const out = await this.io.exec("herdr", args, { cwd: this.io.cwd, timeoutMs });
|
|
12276
|
+
code = out.code;
|
|
12277
|
+
reply = object(JSON.parse(out.stdout || out.stderr));
|
|
12278
|
+
} catch {
|
|
12279
|
+
throw new UsageError(`herdr ${operation} failed; inspect the runtime with herdr agent list`);
|
|
12280
|
+
}
|
|
12281
|
+
const error = object(reply?.error);
|
|
12282
|
+
if (code !== 0 || error) {
|
|
12283
|
+
const reason = typeof error?.code === "string" && /^[a-z_]{1,64}$/.test(error.code) ? ` (${error.code})` : "";
|
|
12284
|
+
throw new UsageError(`herdr ${operation} failed${reason}; inspect the runtime with herdr agent list`);
|
|
12285
|
+
}
|
|
12286
|
+
if (!reply)
|
|
12287
|
+
throw new UsageError(`herdr ${operation} returned invalid JSON`);
|
|
12288
|
+
return reply;
|
|
12289
|
+
}
|
|
12290
|
+
async ensureServer() {
|
|
12291
|
+
const status = async (timeoutMs) => {
|
|
12292
|
+
const server = object((await this.call(["status", "--json"], timeoutMs)).server);
|
|
12293
|
+
if (!server || typeof server.running !== "boolean")
|
|
12294
|
+
throw new UsageError("invalid herdr server status response");
|
|
12295
|
+
if (server.running && (server.compatible === false || server.endpoint_compatible === false))
|
|
12296
|
+
throw new UsageError("the running herdr server is incompatible; update or restart it before launching");
|
|
12297
|
+
return server.running;
|
|
12298
|
+
};
|
|
12299
|
+
if (await status(5000))
|
|
12300
|
+
return;
|
|
12301
|
+
if (!this.io.detach || !await this.io.detach("herdr", ["server"], { cwd: this.io.cwd, env: runtimeEnvironment(this.io.env) }))
|
|
12302
|
+
throw new UsageError("could not start herdr server; start it headless with herdr server");
|
|
12303
|
+
const now = this.io.now ?? (() => new Date);
|
|
12304
|
+
const deadline = now().getTime() + 5000;
|
|
12305
|
+
for (let attempt = 0;attempt < 20; attempt++) {
|
|
12306
|
+
const remaining = deadline - now().getTime();
|
|
12307
|
+
if (remaining <= 0)
|
|
12308
|
+
break;
|
|
12309
|
+
if (await status(Math.min(1000, remaining)))
|
|
12310
|
+
return;
|
|
12311
|
+
const delay = Math.min(250, deadline - now().getTime());
|
|
12312
|
+
if (delay > 0)
|
|
12313
|
+
await (this.io.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms))))(delay);
|
|
12314
|
+
}
|
|
12315
|
+
throw new UsageError("herdr server did not become ready; inspect herdr status");
|
|
12316
|
+
}
|
|
12317
|
+
async create(input) {
|
|
12318
|
+
const agent = input.ticket.toLowerCase();
|
|
12319
|
+
if (!/^[a-z][a-z0-9_-]{0,31}$/.test(agent))
|
|
12320
|
+
throw new UsageError("ticket cannot be used as a herdr agent name");
|
|
12321
|
+
const r = object((await this.call([
|
|
12322
|
+
"worktree",
|
|
12323
|
+
"create",
|
|
12324
|
+
"--cwd",
|
|
12325
|
+
input.repo,
|
|
12326
|
+
"--branch",
|
|
12327
|
+
input.branch,
|
|
12328
|
+
"--base",
|
|
12329
|
+
input.base,
|
|
12330
|
+
"--no-focus"
|
|
12331
|
+
])).result);
|
|
12332
|
+
const workspace = object(r?.workspace)?.workspace_id;
|
|
12333
|
+
const rootPane = object(r?.root_pane)?.pane_id;
|
|
12334
|
+
const path = object(r?.worktree)?.path;
|
|
12335
|
+
if (!id(workspace) || !id(rootPane) || typeof path !== "string" || !path.startsWith("/") || object(r?.root_pane)?.workspace_id !== workspace)
|
|
12336
|
+
throw new UsageError("invalid herdr worktree response; inspect herdr worktree list before retrying");
|
|
12337
|
+
const tab = object((await this.call([
|
|
12338
|
+
"tab",
|
|
12339
|
+
"create",
|
|
12340
|
+
"--workspace",
|
|
12341
|
+
workspace,
|
|
12342
|
+
"--cwd",
|
|
12343
|
+
path,
|
|
12344
|
+
"--no-focus",
|
|
12345
|
+
...credentialNames(this.io.env, input.secrets ?? []).flatMap((name) => ["--env", `${name}=`]),
|
|
12346
|
+
"--env",
|
|
12347
|
+
`ARMADA_TICKET=${input.ticket}`
|
|
12348
|
+
])).result);
|
|
12349
|
+
const pane = object(tab?.root_pane)?.pane_id;
|
|
12350
|
+
if (!id(pane) || pane === rootPane || object(tab?.root_pane)?.workspace_id !== workspace)
|
|
12351
|
+
throw new UsageError("invalid herdr worker pane response; inspect herdr pane list before retrying");
|
|
12352
|
+
await this.call(["pane", "close", rootPane]);
|
|
12353
|
+
return { workspace, pane, agent, path };
|
|
12354
|
+
}
|
|
12355
|
+
async start(handle, profile) {
|
|
12356
|
+
const r = await this.call([
|
|
12357
|
+
"agent",
|
|
12358
|
+
"start",
|
|
12359
|
+
handle.agent,
|
|
12360
|
+
"--kind",
|
|
12361
|
+
profile.harness,
|
|
12362
|
+
"--pane",
|
|
12363
|
+
handle.pane,
|
|
12364
|
+
"--timeout",
|
|
12365
|
+
"30000",
|
|
12366
|
+
"--",
|
|
12367
|
+
...harnessArgs(profile)
|
|
12368
|
+
]);
|
|
12369
|
+
this.checkAgent(r, handle);
|
|
12370
|
+
}
|
|
12371
|
+
async prompt(handle, prompt) {
|
|
12372
|
+
const r = await this.call([
|
|
12373
|
+
"agent",
|
|
12374
|
+
"prompt",
|
|
12375
|
+
handle.agent,
|
|
12376
|
+
prompt,
|
|
12377
|
+
"--wait",
|
|
12378
|
+
"--until",
|
|
12379
|
+
"working",
|
|
12380
|
+
"--timeout",
|
|
12381
|
+
"30000"
|
|
12382
|
+
]);
|
|
12383
|
+
const agent = this.checkAgent(r, handle);
|
|
12384
|
+
if (agent.agent_status !== "working")
|
|
12385
|
+
throw new UsageError("herdr did not confirm the worker is working");
|
|
12386
|
+
}
|
|
12387
|
+
checkAgent(reply, handle) {
|
|
12388
|
+
const agent = object(object(reply.result)?.agent);
|
|
12389
|
+
if (!agent || agent.name !== handle.agent || agent.pane_id !== handle.pane || agent.workspace_id !== handle.workspace)
|
|
12390
|
+
throw new UsageError("invalid herdr agent response; inspect herdr agent list before retrying");
|
|
12391
|
+
return agent;
|
|
12392
|
+
}
|
|
12393
|
+
}
|
|
12394
|
+
|
|
12395
|
+
// src/launch.ts
|
|
12396
|
+
async function launch(io, config, credentials, args, version, configPath) {
|
|
12397
|
+
if (args.rest[0] !== "revoke")
|
|
12398
|
+
return launchLocal(io, config, credentials, args, version, configPath);
|
|
12399
|
+
if (Object.keys(args.options).length)
|
|
12400
|
+
throw new UsageError("launch revoke does not take runtime or profile options");
|
|
11928
12401
|
const [operation, ticket, ...extra] = args.rest;
|
|
11929
12402
|
if (operation !== "revoke" || !ticket || extra.length || !/^[A-Za-z][A-Za-z0-9]{0,15}-\d{1,9}$/.test(ticket))
|
|
11930
12403
|
throw new UsageError("launch needs a ticket to revoke: armada launch revoke <ticket>");
|
|
@@ -11943,12 +12416,156 @@ ${watch.line}
|
|
|
11943
12416
|
`);
|
|
11944
12417
|
return 0;
|
|
11945
12418
|
}
|
|
12419
|
+
async function launchLocal(io, config, credentials, args, version, configPath) {
|
|
12420
|
+
const [input, ...extra] = args.rest;
|
|
12421
|
+
const o = args.options;
|
|
12422
|
+
if (!input || extra.length || !/^[A-Za-z][A-Za-z0-9]{0,15}-\d{1,9}$/.test(input) || o.runtime !== "herdr")
|
|
12423
|
+
throw new UsageError("launch needs a ticket and runtime: armada launch <ticket> --runtime herdr [--harness claude|codex|opencode]");
|
|
12424
|
+
const requested = o.profile?.trim() || null;
|
|
12425
|
+
const reason = o.reason?.trim() || null;
|
|
12426
|
+
if (reason && !requested)
|
|
12427
|
+
throw new UsageError("--reason goes with --profile");
|
|
12428
|
+
if (o.harness && !HERDR_HARNESSES.includes(o.harness))
|
|
12429
|
+
throw new UsageError("--harness must be claude, codex or opencode");
|
|
12430
|
+
try {
|
|
12431
|
+
checkRequestedProfile(config, requested, "herdr");
|
|
12432
|
+
} catch (error) {
|
|
12433
|
+
if (error instanceof ProfileError)
|
|
12434
|
+
throw new UsageError(error.message);
|
|
12435
|
+
throw error;
|
|
12436
|
+
}
|
|
12437
|
+
const signIn = requireSignIn(credentials);
|
|
12438
|
+
if (!credentials.linearApiKey)
|
|
12439
|
+
throw missingKey(LINEAR_KEY);
|
|
12440
|
+
if (!io.exec)
|
|
12441
|
+
throw new UsageError("local launch needs process execution");
|
|
12442
|
+
const ticketId = input.toUpperCase();
|
|
12443
|
+
const now = io.now ?? (() => new Date);
|
|
12444
|
+
const linear = { apiKey: credentials.linearApiKey, fetch: io.fetch ?? fetch };
|
|
12445
|
+
const [ticket, program] = await Promise.all([
|
|
12446
|
+
fetchBriefTicket(linear, ticketId),
|
|
12447
|
+
fetchProgram({ ...linear, rootId: config.tracker.programRoot, labels: config.tracker.labels, now })
|
|
12448
|
+
]);
|
|
12449
|
+
if (!ticket)
|
|
12450
|
+
throw new UsageError(`ticket ${ticketId} not found in Linear`);
|
|
12451
|
+
if (ticket.statusType === "completed" || ticket.statusType === "canceled")
|
|
12452
|
+
throw new UsageError(`${ticketId} is ${ticket.status}; there is nothing to launch`);
|
|
12453
|
+
if (!program.issues.some((i) => i.id === ticketId))
|
|
12454
|
+
throw new UsageError(`${ticketId} is not under program root ${config.tracker.programRoot}`);
|
|
12455
|
+
if (ticket.blockers.some((b) => b.statusType !== "completed" && b.statusType !== "canceled"))
|
|
12456
|
+
throw new UsageError(`${ticketId} has open blockers; resolve them before launching`);
|
|
12457
|
+
if (inFlight(buildModel(program.issues, program.rootId), program.comments, {
|
|
12458
|
+
now: now().getTime(),
|
|
12459
|
+
silentAfterMinutes: config.policy.silentAfterMinutes
|
|
12460
|
+
}).some((lane) => lane.issue.id === ticketId))
|
|
12461
|
+
throw new UsageError(`${ticketId} is already in flight; inspect its worker before launching again`);
|
|
12462
|
+
const branch = ticket.branchName;
|
|
12463
|
+
if (!branch)
|
|
12464
|
+
throw new UsageError(`${ticketId} has no suggested branch in Linear`);
|
|
12465
|
+
let choice;
|
|
12466
|
+
let validation;
|
|
12467
|
+
try {
|
|
12468
|
+
choice = chooseProfile(config, { ticket: ticketId, labels: ticket.labels, requested, reason }, "herdr");
|
|
12469
|
+
validation = chooseValidations(config.policy.validations, {
|
|
12470
|
+
ticket: ticketId,
|
|
12471
|
+
requested: o.validation ?? null,
|
|
12472
|
+
reason: o["validation-reason"] ?? null,
|
|
12473
|
+
command: `armada launch ${ticketId} --runtime herdr`
|
|
12474
|
+
});
|
|
12475
|
+
} catch (error) {
|
|
12476
|
+
if (error instanceof ProfileError)
|
|
12477
|
+
throw new UsageError(error.message);
|
|
12478
|
+
if (error instanceof ValidationChoiceError)
|
|
12479
|
+
throw new UsageError(error.message, error.next);
|
|
12480
|
+
throw error;
|
|
12481
|
+
}
|
|
12482
|
+
if (!choice)
|
|
12483
|
+
throw new UsageError("local launch needs a [herdr.profiles.<name>] with harness, model and effort");
|
|
12484
|
+
if (o.harness && o.harness !== choice.profile.harness)
|
|
12485
|
+
throw new UsageError(`profile "${choice.name}" uses ${choice.profile.harness}; choose a matching --profile with --reason to change harness`);
|
|
12486
|
+
const execute = io.exec;
|
|
12487
|
+
const preflight = {
|
|
12488
|
+
...io,
|
|
12489
|
+
interactive: args.json ? false : io.interactive,
|
|
12490
|
+
exec: (command, argv, options) => execute(command, argv, { ...options, timeoutMs: options.timeoutMs ?? 1e4 })
|
|
12491
|
+
};
|
|
12492
|
+
if (!await ensureLocalTools(preflight, choice.profile.harness))
|
|
12493
|
+
return 1;
|
|
12494
|
+
const root = await io.exec("git", ["rev-parse", "--show-toplevel"], { cwd: io.cwd, timeoutMs: 1e4 });
|
|
12495
|
+
if (root.code !== 0 || !root.stdout.trim().startsWith("/"))
|
|
12496
|
+
throw new UsageError("local launch must run in a git repository");
|
|
12497
|
+
const repo = root.stdout.trim();
|
|
12498
|
+
const remote = await io.exec("git", ["ls-remote", "--symref", "origin", "HEAD"], { cwd: repo, timeoutMs: 20000 });
|
|
12499
|
+
const base = remote.code === 0 ? remote.stdout.match(/^ref:\s+refs\/heads\/(\S+)\s+HEAD/m)?.[1] : null;
|
|
12500
|
+
if (!base)
|
|
12501
|
+
throw new UsageError("could not read the default branch of origin");
|
|
12502
|
+
const conventions = config.brief.extra ? { path: config.brief.extra, text: await io.readFile(join5(dirname5(configPath), config.brief.extra)) } : null;
|
|
12503
|
+
const npm = await checkPublished(version, io.fetch ?? fetch);
|
|
12504
|
+
if (npm.state === "missing")
|
|
12505
|
+
throw new UsageError(`armada ${version} is not on npm yet; publish this version before launching local workers`);
|
|
12506
|
+
const api = apiOf(io, credentials.armadaApi.url);
|
|
12507
|
+
const launch = await api.launchToken(signIn, { project: config.project.slug, ticket: ticketId });
|
|
12508
|
+
const runtime = new Herdr(io);
|
|
12509
|
+
let handle;
|
|
12510
|
+
try {
|
|
12511
|
+
await runtime.ensureServer();
|
|
12512
|
+
handle = await runtime.create({ repo, branch, base, ticket: ticketId, secrets: config.secrets.names });
|
|
12513
|
+
const b = buildBrief({
|
|
12514
|
+
config,
|
|
12515
|
+
ticket,
|
|
12516
|
+
program,
|
|
12517
|
+
profile: null,
|
|
12518
|
+
version,
|
|
12519
|
+
npm,
|
|
12520
|
+
env: io.env,
|
|
12521
|
+
now: now(),
|
|
12522
|
+
conventions,
|
|
12523
|
+
validation,
|
|
12524
|
+
launch: {
|
|
12525
|
+
token: launch.token,
|
|
12526
|
+
expiresAt: launch.expiresAt,
|
|
12527
|
+
apiUrl: armadaAddress(credentials.armadaApi.url) === armadaAddress(DEFAULT_ARMADA_API_URL) ? null : armadaAddress(credentials.armadaApi.url)
|
|
12528
|
+
},
|
|
12529
|
+
herdr: { choice, handle: herdrClaimHandle(handle) }
|
|
12530
|
+
});
|
|
12531
|
+
await runtime.start(handle, choice.profile);
|
|
12532
|
+
await runtime.prompt(handle, b.prompt);
|
|
12533
|
+
} catch (error) {
|
|
12534
|
+
if (handle)
|
|
12535
|
+
io.stderr(`armada: local workspace retained: ${herdrClaimHandle(handle)}
|
|
12536
|
+
`);
|
|
12537
|
+
throw new UsageError(error instanceof UsageError || error instanceof BriefError ? error.message : "local worker launch failed", `inspect herdr agent list; revoke the pending token with armada launch revoke ${ticketId} before retrying`);
|
|
12538
|
+
}
|
|
12539
|
+
const known = (await watchOf(io, config.project.slug)).state?.inFlight ?? [];
|
|
12540
|
+
const inFlightTickets = [...new Set([...known, ticketId])].sort();
|
|
12541
|
+
await remember(io, config.project.slug, { inFlight: inFlightTickets, readAt: now().toISOString() });
|
|
12542
|
+
const watch = await rearmFor(io, config.project.slug, { inFlight: inFlightTickets, open: null });
|
|
12543
|
+
const result = {
|
|
12544
|
+
ticket: ticketId,
|
|
12545
|
+
runtime: "herdr",
|
|
12546
|
+
profile: choice.name,
|
|
12547
|
+
harness: choice.profile.harness,
|
|
12548
|
+
branch,
|
|
12549
|
+
handle: herdrClaimHandle(handle),
|
|
12550
|
+
path: handle.path,
|
|
12551
|
+
state: "working",
|
|
12552
|
+
watch
|
|
12553
|
+
};
|
|
12554
|
+
io.stdout(args.json ? `${JSON.stringify(result, null, 2)}
|
|
12555
|
+
` : `Launched ${ticketId} with ${result.harness} on profile ${choice.name}.
|
|
12556
|
+
Worktree: ${handle.path}
|
|
12557
|
+
Handle: ${result.handle}
|
|
12558
|
+
The worker signs in and claims its ticket from the brief.
|
|
12559
|
+
${watch.line}
|
|
12560
|
+
`);
|
|
12561
|
+
return 0;
|
|
12562
|
+
}
|
|
11946
12563
|
|
|
11947
12564
|
// src/merge.ts
|
|
11948
12565
|
import { randomUUID } from "node:crypto";
|
|
11949
12566
|
import { rm as rm4 } from "node:fs/promises";
|
|
11950
12567
|
import { hostname, tmpdir as tmpdir2 } from "node:os";
|
|
11951
|
-
import { dirname as
|
|
12568
|
+
import { dirname as dirname6, join as join6 } from "node:path";
|
|
11952
12569
|
var TRANSIENT = /\bHTTP 5\d\d\b|\b5\d\d (?:Bad Gateway|Service Unavailable|Gateway Time-?out|Internal Server Error)\b|Bad Gateway|Service Unavailable|Gateway Time-?out|ECONNRESET|ETIMEDOUT|connection reset|i\/o timeout|TLS handshake timeout/i;
|
|
11953
12570
|
var tail = (text, lines = 30) => text.trimEnd().split(`
|
|
11954
12571
|
`).slice(-lines).join(`
|
|
@@ -12026,7 +12643,7 @@ function gitRepo(exec, cwd) {
|
|
|
12026
12643
|
},
|
|
12027
12644
|
async testMerge({ branch, base, head, number, commands }) {
|
|
12028
12645
|
await must(["fetch", "--quiet", "origin", branch, `refs/pull/${number}/head`]);
|
|
12029
|
-
const dir =
|
|
12646
|
+
const dir = join6(tmpdir2(), `armada-merge-${number}-${randomUUID().slice(0, 8)}`);
|
|
12030
12647
|
const remove = async () => {
|
|
12031
12648
|
await git(["worktree", "remove", "--force", dir]);
|
|
12032
12649
|
await git(["worktree", "prune"]);
|
|
@@ -12135,7 +12752,7 @@ async function merge(io, config, credentials, a, configPath) {
|
|
|
12135
12752
|
if (!exec)
|
|
12136
12753
|
throw new UsageError("armada merge needs to run git and gh");
|
|
12137
12754
|
const linearApiKey = credentials.linearApiKey;
|
|
12138
|
-
const repoDir =
|
|
12755
|
+
const repoDir = dirname6(configPath);
|
|
12139
12756
|
const fetchOpt = io.fetch ? { fetch: io.fetch } : {};
|
|
12140
12757
|
const gh = { token, repository: config.github.repository, ...fetchOpt };
|
|
12141
12758
|
const linearOpts = { apiKey: linearApiKey, labels: config.tracker.labels, ...fetchOpt };
|
|
@@ -12170,7 +12787,7 @@ async function merge(io, config, credentials, a, configPath) {
|
|
|
12170
12787
|
`),
|
|
12171
12788
|
installedSkill: async (name) => {
|
|
12172
12789
|
for (const dir of [AGENTS_SKILLS_DIR, CLAUDE_SKILLS_DIR])
|
|
12173
|
-
if (await io.readFile(
|
|
12790
|
+
if (await io.readFile(join6(repoDir, dir, name, "SKILL.md")) !== null)
|
|
12174
12791
|
return true;
|
|
12175
12792
|
return false;
|
|
12176
12793
|
}
|
|
@@ -12386,7 +13003,7 @@ ${"─".repeat(60)}
|
|
|
12386
13003
|
}
|
|
12387
13004
|
|
|
12388
13005
|
// src/secrets.ts
|
|
12389
|
-
import { dirname as
|
|
13006
|
+
import { dirname as dirname7, relative as relative3, resolve as resolve2 } from "node:path";
|
|
12390
13007
|
var NAME_HINT = "upper snake case, e.g. OPENAI_API_KEY";
|
|
12391
13008
|
var hhmm2 = (iso) => `${iso.slice(0, 16).replace("T", " ")} UTC`;
|
|
12392
13009
|
function signInOf(config, credentials) {
|
|
@@ -12466,7 +13083,7 @@ Next: armada secrets set <NAME> (an owner or admin), or the Keys page of Armada
|
|
|
12466
13083
|
async function exportRefusal(io, path) {
|
|
12467
13084
|
if (!io.exec)
|
|
12468
13085
|
return "git cannot be run here to check that the file is ignored";
|
|
12469
|
-
const cwd =
|
|
13086
|
+
const cwd = dirname7(path);
|
|
12470
13087
|
const tracked = await io.exec("git", ["ls-files", "--error-unmatch", "--", path], { cwd }).catch(() => null);
|
|
12471
13088
|
if (tracked?.code === 0)
|
|
12472
13089
|
return `git tracks ${path}: secrets written there would be committed`;
|
|
@@ -12727,7 +13344,9 @@ var COMMAND_HELP = {
|
|
|
12727
13344
|
status --all The same for every project registered by \`armada init\`
|
|
12728
13345
|
`,
|
|
12729
13346
|
doctor: ` doctor What this repository lacks to be run by Armada, with the fix for each,
|
|
12730
|
-
and whether this terminal is signed in to Armada
|
|
13347
|
+
and whether this terminal is signed in to Armada. Local herdr profiles
|
|
13348
|
+
check tools and harness sign-in; offers official installs with y/N.
|
|
13349
|
+
No terminal, CI and --json only print fixes and never install
|
|
12731
13350
|
`,
|
|
12732
13351
|
init: ` init [--program-root <ISSUE-ID>] [--name <name>] [--slug <slug>] [--no-stop-hook]
|
|
12733
13352
|
Open one pull request that installs or updates it all, create the
|
|
@@ -12827,7 +13446,11 @@ var COMMAND_HELP = {
|
|
|
12827
13446
|
A pull request the owner was asked about merges only once they approved
|
|
12828
13447
|
that exact head (or it with only the base merged in).
|
|
12829
13448
|
`,
|
|
12830
|
-
launch: ` launch
|
|
13449
|
+
launch: ` launch <ticket> --runtime herdr [--harness claude|codex|opencode]
|
|
13450
|
+
[--profile <name> [--reason <why>]] [--validation <n|none>]
|
|
13451
|
+
Create the ticket's worktree and start a persistent local worker
|
|
13452
|
+
with its launch-token brief. Profiles follow [[herdr.routing]]
|
|
13453
|
+
launch revoke <ticket>
|
|
12831
13454
|
Cancel the newest pending launch through Armada, including a worker
|
|
12832
13455
|
signed in but not claimed. A claimed launch needs armada release instead
|
|
12833
13456
|
`,
|
|
@@ -12970,6 +13593,7 @@ var VALUE_OPTIONS = [
|
|
|
12970
13593
|
"every",
|
|
12971
13594
|
"parent",
|
|
12972
13595
|
"runtime",
|
|
13596
|
+
"harness",
|
|
12973
13597
|
"handle",
|
|
12974
13598
|
"branch",
|
|
12975
13599
|
"ticket",
|
|
@@ -13028,6 +13652,7 @@ var COMMAND_OPTIONS = {
|
|
|
13028
13652
|
init: ["program-root", "name", "slug", "no-stop-hook"],
|
|
13029
13653
|
merge: ["ticket", "no-ticket", "dry-run", "no-lock", "wait", "timeout", "reason", "ask-owner"],
|
|
13030
13654
|
brief: ["profile", "reason", "prompt", "profile-line", "validation", "validation-reason"],
|
|
13655
|
+
launch: ["runtime", "harness", "profile", "reason", "validation", "validation-reason"],
|
|
13031
13656
|
validate: ["ticket", "attach", "caption", "choices", "message", "message-file"],
|
|
13032
13657
|
"ask-owner": ["choices"],
|
|
13033
13658
|
login: ["api-key", "launch-token", "api-url"],
|
|
@@ -13093,12 +13718,12 @@ async function findConfig(io, explicit, command = "status") {
|
|
|
13093
13718
|
throw new UsageError(`${path} does not exist`, `armada ${command} --config <file>, with the path of an ${CONFIG_FILE}`);
|
|
13094
13719
|
return { path, text };
|
|
13095
13720
|
}
|
|
13096
|
-
for (let dir = resolve3(io.cwd);; dir =
|
|
13097
|
-
const path =
|
|
13721
|
+
for (let dir = resolve3(io.cwd);; dir = dirname8(dir)) {
|
|
13722
|
+
const path = join7(dir, CONFIG_FILE);
|
|
13098
13723
|
const text = await io.readFile(path);
|
|
13099
13724
|
if (text !== null)
|
|
13100
13725
|
return { path, text };
|
|
13101
|
-
if (
|
|
13726
|
+
if (dirname8(dir) === dir)
|
|
13102
13727
|
break;
|
|
13103
13728
|
}
|
|
13104
13729
|
throw new UsageError(`no ${CONFIG_FILE} found in ${io.cwd} or any parent directory, so this is not a repository Armada runs`, `armada init to set this repository up, armada ${command} --config <file> to use another ${CONFIG_FILE}, or armada status --all to see the registered projects`);
|
|
@@ -13119,7 +13744,7 @@ async function status(io, args) {
|
|
|
13119
13744
|
...io.fetch ? { fetch: io.fetch } : {},
|
|
13120
13745
|
...io.now ? { now: io.now } : {}
|
|
13121
13746
|
});
|
|
13122
|
-
const behind = await skillsBehind(fsRepoView(
|
|
13747
|
+
const behind = await skillsBehind(fsRepoView(dirname8(path))).catch(() => null);
|
|
13123
13748
|
if (behind)
|
|
13124
13749
|
report.warnings.push(skillsBehindLine(behind, version));
|
|
13125
13750
|
io.stdout(args.json ? `${JSON.stringify(report, null, 2)}
|
|
@@ -13276,7 +13901,7 @@ async function dispatch(argv, io) {
|
|
|
13276
13901
|
const { path, text } = await findConfig(io, args.config, "launch");
|
|
13277
13902
|
const config = parseConfig(text, path);
|
|
13278
13903
|
const { credentials } = await loadCredentials(io, { project: config.project.slug });
|
|
13279
|
-
return await launch(io, config, credentials, args);
|
|
13904
|
+
return await launch(io, config, credentials, args, version, path);
|
|
13280
13905
|
}
|
|
13281
13906
|
if (args.command === "status") {
|
|
13282
13907
|
noExtra(args.rest);
|
|
@@ -13535,8 +14160,9 @@ function openUrl(url) {
|
|
|
13535
14160
|
return false;
|
|
13536
14161
|
}
|
|
13537
14162
|
}
|
|
13538
|
-
var exec = (command, args, { cwd }) => new Promise((done, fail) => {
|
|
14163
|
+
var exec = (command, args, { cwd, timeoutMs }) => new Promise((done, fail) => {
|
|
13539
14164
|
const child = spawn2(command, args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
14165
|
+
const timer = timeoutMs ? setTimeout(() => child.kill("SIGKILL"), timeoutMs) : null;
|
|
13540
14166
|
let stdout = "";
|
|
13541
14167
|
let stderr = "";
|
|
13542
14168
|
child.stdout.setEncoding("utf8").on("data", (d) => {
|
|
@@ -13545,8 +14171,16 @@ var exec = (command, args, { cwd }) => new Promise((done, fail) => {
|
|
|
13545
14171
|
child.stderr.setEncoding("utf8").on("data", (d) => {
|
|
13546
14172
|
stderr += d;
|
|
13547
14173
|
});
|
|
13548
|
-
child.on("error",
|
|
13549
|
-
|
|
14174
|
+
child.on("error", (err) => {
|
|
14175
|
+
if (timer)
|
|
14176
|
+
clearTimeout(timer);
|
|
14177
|
+
fail(err);
|
|
14178
|
+
});
|
|
14179
|
+
child.on("close", (code) => {
|
|
14180
|
+
if (timer)
|
|
14181
|
+
clearTimeout(timer);
|
|
14182
|
+
done({ code: code ?? 1, stdout, stderr });
|
|
14183
|
+
});
|
|
13550
14184
|
});
|
|
13551
14185
|
var stopped = false;
|
|
13552
14186
|
if (process.argv.includes("heartbeat") && !process.argv.includes("--background"))
|
|
@@ -13555,6 +14189,7 @@ if (process.argv.includes("heartbeat") && !process.argv.includes("--background")
|
|
|
13555
14189
|
stopped = true;
|
|
13556
14190
|
});
|
|
13557
14191
|
var code = await run(process.argv.slice(2), {
|
|
14192
|
+
platform: process.platform,
|
|
13558
14193
|
machineName: hostname2(),
|
|
13559
14194
|
ttyName: process.stdin.isTTY ? spawnSync("tty", [], { encoding: "utf8", stdio: ["inherit", "pipe", "ignore"] }).stdout?.trim() || null : null,
|
|
13560
14195
|
cwd: process.cwd(),
|
|
@@ -13616,6 +14251,14 @@ var code = await run(process.argv.slice(2), {
|
|
|
13616
14251
|
gitBranch,
|
|
13617
14252
|
readStdin,
|
|
13618
14253
|
exec,
|
|
14254
|
+
detach: (command, args, { cwd, env }) => new Promise((resolve) => {
|
|
14255
|
+
const child = spawn2(command, args, { cwd, env, stdio: "ignore", detached: true });
|
|
14256
|
+
child.once("error", () => resolve(false));
|
|
14257
|
+
child.once("spawn", () => {
|
|
14258
|
+
child.unref();
|
|
14259
|
+
resolve(true);
|
|
14260
|
+
});
|
|
14261
|
+
}),
|
|
13619
14262
|
spawn: spawnInherited,
|
|
13620
14263
|
startBackground,
|
|
13621
14264
|
stopped: () => stopped,
|