@the-vibe-company/armada 0.2.72 → 0.2.73
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 +75 -18
- package/package.json +1 -1
package/dist/armada.js
CHANGED
|
@@ -9743,13 +9743,23 @@ var init_driver = __esm(() => {
|
|
|
9743
9743
|
import { spawn } from "node:child_process";
|
|
9744
9744
|
import { createInterface } from "node:readline";
|
|
9745
9745
|
const options = JSON.parse(process.argv[1]);
|
|
9746
|
+
// The grace after a final result; tests shorten it, production keeps one second.
|
|
9747
|
+
const retireMs = Number.isSafeInteger(options.retireMs) && options.retireMs > 0 ? options.retireMs : 1000;
|
|
9746
9748
|
let child;
|
|
9747
9749
|
let session;
|
|
9748
9750
|
let finishing = false;
|
|
9749
9751
|
let failed = false;
|
|
9750
9752
|
let closed = false;
|
|
9753
|
+
let results = 0;
|
|
9751
9754
|
let completed = 0;
|
|
9755
|
+
// Set while the current process may take one more line: its first turn, or a held process.
|
|
9756
|
+
let accept;
|
|
9757
|
+
// Ends the current process's input once, from any path.
|
|
9758
|
+
let endInput;
|
|
9752
9759
|
const waiting = [];
|
|
9760
|
+
// Frames that mean the process is running a turn again after a result.
|
|
9761
|
+
const turnFrames = new Set(["assistant", "user", "stream_event"]);
|
|
9762
|
+
const turnSystem = new Set(["init", "thinking_tokens", "turn_starting"]);
|
|
9753
9763
|
const emit = (value) => console.log(JSON.stringify(value));
|
|
9754
9764
|
const failure = () => {
|
|
9755
9765
|
failed = true;
|
|
@@ -9757,15 +9767,15 @@ const failure = () => {
|
|
|
9757
9767
|
};
|
|
9758
9768
|
function send(line) {
|
|
9759
9769
|
if (failed) return;
|
|
9760
|
-
if (child
|
|
9761
|
-
if (!child) start();
|
|
9770
|
+
if (!child && !finishing) start();
|
|
9762
9771
|
if (!child || failed) return;
|
|
9763
|
-
|
|
9772
|
+
if (accept) accept(line);
|
|
9773
|
+
else waiting.push(line);
|
|
9764
9774
|
}
|
|
9765
9775
|
function start() {
|
|
9766
|
-
if (
|
|
9776
|
+
if (results && !session) { failure(); return; }
|
|
9767
9777
|
// A resumed print process starts fresh cumulative usage counters.
|
|
9768
|
-
if (
|
|
9778
|
+
if (results) emit({ type: "armada_turn_start" });
|
|
9769
9779
|
const cli = spawn(options.command, [...options.args, ...(session ? ["--resume", session] : [])], {
|
|
9770
9780
|
stdio: ["pipe", "pipe", "pipe"], shell: false,
|
|
9771
9781
|
});
|
|
@@ -9775,22 +9785,63 @@ function start() {
|
|
|
9775
9785
|
let retire;
|
|
9776
9786
|
let kill;
|
|
9777
9787
|
let retired = false;
|
|
9788
|
+
let lines = 0;
|
|
9789
|
+
let open = true;
|
|
9790
|
+
let held = false;
|
|
9791
|
+
// A result arrived and no turn has started since.
|
|
9792
|
+
let quiet = false;
|
|
9793
|
+
let lateLine = false;
|
|
9794
|
+
const tasks = new Set();
|
|
9795
|
+
const into = (line) => {
|
|
9796
|
+
lines++;
|
|
9797
|
+
if (held) lateLine = true;
|
|
9798
|
+
cli.stdin.write(line + "\n", (error) => { if (error) failure(); });
|
|
9799
|
+
};
|
|
9800
|
+
endInput = () => { if (open) { open = false; cli.stdin.end(); } };
|
|
9801
|
+
// No more input for this process; retire it unless another turn begins first.
|
|
9802
|
+
const settle = () => {
|
|
9803
|
+
held = false;
|
|
9804
|
+
accept = undefined;
|
|
9805
|
+
finishing = true;
|
|
9806
|
+
endInput();
|
|
9807
|
+
// Some print CLIs retain an idle process after their final result and EOF.
|
|
9808
|
+
// Retire only this completed subprocess; the supervisor's group pin stays alive.
|
|
9809
|
+
// A line written while held may start its turn after the CLI's own: allow it longer.
|
|
9810
|
+
if (!retire && !retired && !tasks.size) retire = setTimeout(() => {
|
|
9811
|
+
retired = true;
|
|
9812
|
+
cli.kill("SIGTERM");
|
|
9813
|
+
kill = setTimeout(() => cli.kill("SIGKILL"), retireMs);
|
|
9814
|
+
}, lateLine ? retireMs * 30 : retireMs);
|
|
9815
|
+
};
|
|
9816
|
+
// One line per turn: later input waits in the driver for this turn's result.
|
|
9817
|
+
const once = (line) => { accept = undefined; into(line); };
|
|
9818
|
+
accept = once;
|
|
9778
9819
|
const event = (line) => {
|
|
9779
9820
|
try {
|
|
9780
9821
|
const value = JSON.parse(line);
|
|
9781
9822
|
if (typeof value.session_id === "string" && value.session_id) session = value.session_id;
|
|
9823
|
+
if (value.type === "system" && value.subtype === "background_tasks_changed" && Array.isArray(value.tasks)) {
|
|
9824
|
+
tasks.clear();
|
|
9825
|
+
for (const task of value.tasks) if (typeof task?.task_id === "string") tasks.add(task.task_id);
|
|
9826
|
+
// Tasks that end without a turn of their own leave nothing to hold for.
|
|
9827
|
+
if (quiet && !tasks.size) settle();
|
|
9828
|
+
} else if (!retired && (turnFrames.has(value.type) || (value.type === "system" && turnSystem.has(value.subtype)))) {
|
|
9829
|
+
// Another turn began before the retire fired: neither SIGTERM nor SIGKILL is scheduled now.
|
|
9830
|
+
clearTimeout(retire);
|
|
9831
|
+
retire = undefined;
|
|
9832
|
+
held = false;
|
|
9833
|
+
quiet = false;
|
|
9834
|
+
}
|
|
9782
9835
|
if (value.type === "result") {
|
|
9783
9836
|
result = true;
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
kill = setTimeout(() => cli.kill("SIGKILL"), 1000);
|
|
9793
|
-
}, 1000);
|
|
9837
|
+
quiet = true;
|
|
9838
|
+
results++;
|
|
9839
|
+
if (tasks.size && open && !closed) {
|
|
9840
|
+
// Held: background work continues in this process, and input reaches it directly.
|
|
9841
|
+
held = true;
|
|
9842
|
+
if (waiting.length) for (const queued of waiting.splice(0)) into(queued);
|
|
9843
|
+
else accept = once;
|
|
9844
|
+
} else settle();
|
|
9794
9845
|
}
|
|
9795
9846
|
emit(value);
|
|
9796
9847
|
if (value.type === "result") emit({ type: "armada_turn_state", completed });
|
|
@@ -9812,8 +9863,13 @@ function start() {
|
|
|
9812
9863
|
clearTimeout(retire);
|
|
9813
9864
|
clearTimeout(kill);
|
|
9814
9865
|
child = undefined;
|
|
9866
|
+
accept = undefined;
|
|
9867
|
+
endInput = undefined;
|
|
9815
9868
|
finishing = false;
|
|
9816
9869
|
if ((!retired && code !== 0) || !result) failure();
|
|
9870
|
+
// Every line this process took is settled once it ends.
|
|
9871
|
+
completed += lines;
|
|
9872
|
+
emit({ type: "armada_turn_state", completed });
|
|
9817
9873
|
if (failed) { process.exitCode = 1; input.close(); return; }
|
|
9818
9874
|
for (const line of waiting.splice(0)) send(line);
|
|
9819
9875
|
if (closed && !child) process.exit(0);
|
|
@@ -9829,7 +9885,7 @@ input.on("line", (line) => {
|
|
|
9829
9885
|
});
|
|
9830
9886
|
input.on("close", () => {
|
|
9831
9887
|
closed = true;
|
|
9832
|
-
if (child)
|
|
9888
|
+
if (child) endInput?.();
|
|
9833
9889
|
else process.exit(failed ? 1 : 0);
|
|
9834
9890
|
});
|
|
9835
9891
|
`;
|
|
@@ -58167,6 +58223,7 @@ You are a worker. You own exactly one ticket, named in your launch brief. You tu
|
|
|
58167
58223
|
- **A listing is not an answer.** The coordinator's watch reminds about unanswered questions, plans and hand-backs after doubling intervals. Only the coordinator can \`armada ack\` a dismissible notice with a reason; it cannot skip your question, plan or hand-back. A ticket comment saying \`note: acknowledged\` does not change your phase or answer you.
|
|
58168
58224
|
- **The ticket is the source of truth.** On a local V2 worker, run \`armada ticket\` (or \`armada ticket <your-id>\`) to read it through your capability; \`--json\` prints the protocol Ticket. Another ticket id is refused. Internal tickets include all recorded comments; Linear tickets include the folded comments, with older comments linked in Linear. Read it, its parent spec and the hand-back comments of its merged blockers in full before planning.
|
|
58169
58225
|
- **Report a milestone once.** A second report with nothing new is noise; the heartbeat proves you are alive. Use the report vocabulary below for the plan, real implementation progress, blockers, tests, shipping and the hand-back.
|
|
58226
|
+
- **A turn is the unit of work** on a local worker (launched by the Armada daemon, for example through the Claude runtime): never end a turn to wait for a background task or subagent, because a turn that ends can stop them and nothing resumes you until a message arrives. Run \`verify\`, CI watches (\`gh run watch\`, \`gh pr checks --watch\`) and reviews in the foreground with a timeout, or poll them within the same turn, and end the turn only with a report, a question or a hand-back.
|
|
58170
58227
|
- **Keep going on setup choices.** When setup needs a choice (an install fallback, a retry, a missing tool), take the safe option, say which in your next report, and go on. Never stop to ask about it.
|
|
58171
58228
|
- **Stop by impact, not effort.** There is no budget of attempts. Failing tests, many files and layout defects are reasons to keep going. Stop and ask only when the fix breaks a contract another ticket or caller relies on, moves a module's responsibility, or a design choice the ticket does not settle remains; name the interface and who it affects. Never widen the ticket to avoid asking. Decide reversible technical choices yourself and record each one, with its reason, on the ticket and in the pull request.
|
|
58172
58229
|
- **Work only in your own branch and worktree.** Never touch another agent's checkout, and stop only the processes you started.
|
|
@@ -58195,7 +58252,7 @@ Reporting any phase other than \`ready-to-merge\` clears your previous hand-back
|
|
|
58195
58252
|
## Steps
|
|
58196
58253
|
|
|
58197
58254
|
1. **Install, sign in and claim**, with the exact commands your brief starts with. Install the Armada version it names; if npm refuses it, use the brief's fallback command, else the newest published one, and say so in your first report. Run \`armada skill armada-worker\` to read this skill, then the brief's \`armada login --launch-token <token>\` once, before the claim: it signs this workspace in for your ticket only, and Armada then gives your commands their keys (do not ask for one). The token works once, within the hour. If it is refused, or a later command says you were cut off from Armada, stop and say so in your reply. A token shown as \`armada_launch_••••\` is masked and signs nobody in. Then run the brief's \`armada claim …\`. A claim refused because another worker holds the ticket: stop, the older claim wins. After the claim, Armada checks that you can read the repository, push your branch and sign commits; if it reports \`blocked\`, keep the claim, stop and quote the reason.
|
|
58198
|
-
2. **Start the heartbeat** with the brief's line, right after the claim. It pings Armada only, never Linear, so you do not need reports to stay alive. Pass the agent's PID (\`$PPID\` in its command shell), never the shell's \`$$\`; it stops when that process exits or your session ends. \`--background\` detaches it on Conductor and
|
|
58255
|
+
2. **Start the heartbeat** with the brief's line, right after the claim. It pings Armada only, never Linear, so you do not need reports to stay alive. Pass the agent's PID (\`$PPID\` in its command shell), never the shell's \`$$\`; it stops when that process exits or your session ends. \`--background\` detaches it on Conductor, herdr and local workers; on guided Claude Code (a coordinator's subagent), run it in the subagent's background Bash without \`--background\`. While you wait in \`awaiting-approval\`, \`blocked\` or \`awaiting-validation\`, no heartbeat or report is needed. On resume, report your working phase and run the heartbeat line again with the current \`$PPID\`. If the runtime cannot keep a background process, report at least every 15 minutes during active work and say so on the ticket.
|
|
58199
58256
|
3. **Branch.** Use the branch named after the ticket (the brief names it), from the latest default branch.
|
|
58200
58257
|
4. **Plan.** Write what changes, how it is tested, and the checks a person could observe when it is done. Declare the paths you will change with \`--paths "packages/core/src/file.ts,skills/**"\` (at most 50, relative, no \`..\`). Armada prints the overlaps with other workers in flight. **Declare them in your plan and proceed additively; ask the coordinator only when you must change a contract another in-flight ticket relies on.** Reserve any migration number or shared name now. Your brief's "Plan" line says whether the plan needs approval; follow it:
|
|
58201
58258
|
- Pre-approved: \`armada report implementing --message "progress: plan ready" --plan-file -\` (or \`--plan-file <path>\`), then go on.
|
|
@@ -62580,7 +62637,7 @@ ${attachments.join(`
|
|
|
62580
62637
|
};
|
|
62581
62638
|
}
|
|
62582
62639
|
// package.json
|
|
62583
|
-
var version2 = "0.2.
|
|
62640
|
+
var version2 = "0.2.73";
|
|
62584
62641
|
|
|
62585
62642
|
// src/io.ts
|
|
62586
62643
|
class UsageError extends Error {
|