@dirgha/code 1.42.14 → 1.43.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cli/config.d.ts +17 -0
- package/dist/cli/config.js +14 -16
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/first-run.js +1 -1
- package/dist/cli/first-run.js.map +1 -1
- package/dist/cli/flows/wizard.js +1 -1
- package/dist/cli/flows/wizard.js.map +1 -1
- package/dist/cli/interactive.js +1 -1
- package/dist/cli/interactive.js.map +1 -1
- package/dist/cli/main.js +26 -28
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/setup.js +1 -1
- package/dist/cli/setup.js.map +1 -1
- package/dist/cli/subcommands/ask.js +3 -3
- package/dist/cli/subcommands/ask.js.map +1 -1
- package/dist/cli/subcommands/index.js +1 -1
- package/dist/cli/subcommands/index.js.map +1 -1
- package/dist/cli/subcommands/verify.js +3 -3
- package/dist/cli/subcommands/verify.js.map +1 -1
- package/dist/fleet/worktree.js +49 -2
- package/dist/fleet/worktree.js.map +1 -1
- package/dist/gpu/market.js +43 -17
- package/dist/gpu/market.js.map +1 -1
- package/dist/intelligence/prices.js +2 -5
- package/dist/intelligence/prices.js.map +1 -1
- package/dist/kernel/agent-loop.d.ts +18 -0
- package/dist/kernel/agent-loop.js +84 -64
- package/dist/kernel/agent-loop.js.map +1 -1
- package/dist/kernel/message.js +10 -0
- package/dist/kernel/message.js.map +1 -1
- package/dist/orchestra/agent/dirgha.d.ts +21 -0
- package/dist/orchestra/agent/dirgha.js +36 -0
- package/dist/orchestra/agent/dirgha.js.map +1 -0
- package/dist/orchestra/agent/manager.d.ts +44 -0
- package/dist/orchestra/agent/manager.js +154 -0
- package/dist/orchestra/agent/manager.js.map +1 -0
- package/dist/orchestra/bin.d.ts +23 -0
- package/dist/orchestra/bin.js +225 -0
- package/dist/orchestra/bin.js.map +1 -0
- package/dist/orchestra/core/registry.d.ts +27 -0
- package/dist/orchestra/core/registry.js +100 -0
- package/dist/orchestra/core/registry.js.map +1 -0
- package/dist/orchestra/core/store.d.ts +15 -0
- package/dist/orchestra/core/store.js +44 -0
- package/dist/orchestra/core/store.js.map +1 -0
- package/dist/orchestra/core/types.d.ts +62 -0
- package/dist/orchestra/core/types.js +10 -0
- package/dist/orchestra/core/types.js.map +1 -0
- package/dist/orchestra/orchestration/log.d.ts +21 -0
- package/dist/orchestra/orchestration/log.js +68 -0
- package/dist/orchestra/orchestration/log.js.map +1 -0
- package/dist/providers/deepseek-catalogue.js +6 -4
- package/dist/providers/deepseek-catalogue.js.map +1 -1
- package/dist/providers/dispatch.js +3 -5
- package/dist/providers/dispatch.js.map +1 -1
- package/dist/subagents/delegator.d.ts +10 -1
- package/dist/subagents/delegator.js +28 -6
- package/dist/subagents/delegator.js.map +1 -1
- package/dist/tools/shell.js +21 -8
- package/dist/tools/shell.js.map +1 -1
- package/dist/tui/ink/App.js +70 -34
- package/dist/tui/ink/App.js.map +1 -1
- package/dist/tui/ink/components/ApprovalPrompt.js +1 -1
- package/dist/tui/ink/components/ApprovalPrompt.js.map +1 -1
- package/dist/tui/ink/components/InputBox.d.ts +2 -3
- package/dist/tui/ink/components/InputBox.js +75 -57
- package/dist/tui/ink/components/InputBox.js.map +1 -1
- package/dist/tui/ink/components/KeySetOverlay.js +1 -1
- package/dist/tui/ink/components/KeySetOverlay.js.map +1 -1
- package/dist/tui/ink/components/ModelPicker.js +11 -1
- package/dist/tui/ink/components/ModelPicker.js.map +1 -1
- package/dist/tui/ink/components/OpenRouterCompanyPicker.js +3 -1
- package/dist/tui/ink/components/OpenRouterCompanyPicker.js.map +1 -1
- package/dist/tui/ink/components/PasteCollapse.d.ts +1 -1
- package/dist/tui/ink/components/PasteCollapse.js +3 -1
- package/dist/tui/ink/components/PasteCollapse.js.map +1 -1
- package/dist/tui/ink/components/ProviderPicker.js +11 -1
- package/dist/tui/ink/components/ProviderPicker.js.map +1 -1
- package/dist/tui/ink/components/SlashComplete.js +5 -6
- package/dist/tui/ink/components/SlashComplete.js.map +1 -1
- package/dist/tui/ink/components/SubagentDashboard.d.ts +20 -0
- package/dist/tui/ink/components/SubagentDashboard.js +159 -0
- package/dist/tui/ink/components/SubagentDashboard.js.map +1 -0
- package/dist/tui/ink/components/VirtualTranscript.d.ts +6 -5
- package/dist/tui/ink/components/VirtualTranscript.js +12 -10
- package/dist/tui/ink/components/VirtualTranscript.js.map +1 -1
- package/dist/tui/ink/use-event-projection.js +45 -15
- package/dist/tui/ink/use-event-projection.js.map +1 -1
- package/dist/tui/ink/use-tool-progress.d.ts +1 -0
- package/dist/tui/ink/use-tool-progress.js +63 -23
- package/dist/tui/ink/use-tool-progress.js.map +1 -1
- package/dist/tui/ink/use-transcript-scroll.d.ts +14 -5
- package/dist/tui/ink/use-transcript-scroll.js +46 -28
- package/dist/tui/ink/use-transcript-scroll.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dirgha.js","sourceRoot":"","sources":["../../../src/orchestra/agent/dirgha.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAqB,MAAM,cAAc,CAAC;AAS7D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,SAAiB,EACjB,KAAa,EACb,IAAY,EACZ,OAA2B,EAAE;IAE7B,MAAM,IAAI,GAAa,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACnD,IAAI,IAAI,CAAC,SAAS;QAAE,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;IACjD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEhB,MAAM,SAAS,GAAiB;QAC9B,OAAO,EAAE,QAAQ;QACjB,IAAI;QACJ,GAAG,EAAE,IAAI,CAAC,GAAG;KACd,CAAC;IAEF,OAAO,UAAU,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,SAAiB,EACjB,KAAe,EACf,OAA2B,EAAE;IAE7B,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,IAAI,CAAC,CAAC;QACzE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orchestra/agent/manager.ts — Agent subprocess lifecycle manager.
|
|
3
|
+
*
|
|
4
|
+
* Spawns, tracks, and terminates agent child processes. Each agent runs
|
|
5
|
+
* as a forked subprocess (e.g. `dirgha ask <task>`). Output is streamed
|
|
6
|
+
* to the session registry and the NDJSON log. The manager provides a
|
|
7
|
+
* single `SpawnResult` per agent so the caller can await completion or
|
|
8
|
+
* kill on demand.
|
|
9
|
+
*
|
|
10
|
+
* Architecture: agents are "dumb pipes" — stdin/stdout only. The parent
|
|
11
|
+
* (dirgha orchestra) is the multiplexer. No tmux, no side channels.
|
|
12
|
+
*/
|
|
13
|
+
import { type ChildProcess } from "node:child_process";
|
|
14
|
+
import type { AgentSlot, OrchestraSession } from "../core/types.js";
|
|
15
|
+
export interface SpawnResult {
|
|
16
|
+
agentId: string;
|
|
17
|
+
process: ChildProcess;
|
|
18
|
+
/** Promise that resolves with exit code when the process ends. */
|
|
19
|
+
done: Promise<number>;
|
|
20
|
+
}
|
|
21
|
+
export interface SpawnOptions {
|
|
22
|
+
/** The command to run (default: "dirgha"). */
|
|
23
|
+
command?: string;
|
|
24
|
+
/** Args after the command (e.g. ["ask", "refactor auth"]). */
|
|
25
|
+
args?: string[];
|
|
26
|
+
/** Working directory for the subprocess. */
|
|
27
|
+
cwd?: string;
|
|
28
|
+
/** Environment variables. */
|
|
29
|
+
env?: Record<string, string | undefined>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Spawn an agent subprocess and wire it into the session registry + log.
|
|
33
|
+
* Returns the agent id and the child process handle.
|
|
34
|
+
*/
|
|
35
|
+
export declare function spawnAgent(sessionId: string, label: string, task: string, adapter: AgentSlot["adapter"], opts?: SpawnOptions): Promise<SpawnResult | null>;
|
|
36
|
+
/**
|
|
37
|
+
* Kill a running agent by session + agent id. Sends SIGTERM, then
|
|
38
|
+
* SIGKILL after 3 seconds.
|
|
39
|
+
*/
|
|
40
|
+
export declare function killAgent(sessionId: string, agentId: string): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Kill all agents in a session and return the updated session.
|
|
43
|
+
*/
|
|
44
|
+
export declare function killAll(sessionId: string): Promise<OrchestraSession | undefined>;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orchestra/agent/manager.ts — Agent subprocess lifecycle manager.
|
|
3
|
+
*
|
|
4
|
+
* Spawns, tracks, and terminates agent child processes. Each agent runs
|
|
5
|
+
* as a forked subprocess (e.g. `dirgha ask <task>`). Output is streamed
|
|
6
|
+
* to the session registry and the NDJSON log. The manager provides a
|
|
7
|
+
* single `SpawnResult` per agent so the caller can await completion or
|
|
8
|
+
* kill on demand.
|
|
9
|
+
*
|
|
10
|
+
* Architecture: agents are "dumb pipes" — stdin/stdout only. The parent
|
|
11
|
+
* (dirgha orchestra) is the multiplexer. No tmux, no side channels.
|
|
12
|
+
*/
|
|
13
|
+
import { spawn } from "node:child_process";
|
|
14
|
+
import { randomUUID } from "node:crypto";
|
|
15
|
+
import { safeEnvironment } from "../../utils/env.js";
|
|
16
|
+
import { registry } from "../core/registry.js";
|
|
17
|
+
import { writeLog } from "../orchestration/log.js";
|
|
18
|
+
/**
|
|
19
|
+
* Spawn an agent subprocess and wire it into the session registry + log.
|
|
20
|
+
* Returns the agent id and the child process handle.
|
|
21
|
+
*/
|
|
22
|
+
export async function spawnAgent(sessionId, label, task, adapter, opts = {}) {
|
|
23
|
+
const session = registry.get(sessionId);
|
|
24
|
+
if (!session)
|
|
25
|
+
return null;
|
|
26
|
+
const agentId = `agent-${session.agents.length + 1}-${randomUUID().slice(0, 4)}`;
|
|
27
|
+
const now = Date.now();
|
|
28
|
+
const slot = {
|
|
29
|
+
id: agentId,
|
|
30
|
+
label,
|
|
31
|
+
task,
|
|
32
|
+
adapter,
|
|
33
|
+
pid: 0,
|
|
34
|
+
status: "spawning",
|
|
35
|
+
exitCode: null,
|
|
36
|
+
startedAt: now,
|
|
37
|
+
elapsedMs: null,
|
|
38
|
+
outputBuffer: [],
|
|
39
|
+
hasFocus: false,
|
|
40
|
+
};
|
|
41
|
+
registry.addAgent(sessionId, slot);
|
|
42
|
+
writeLog(sessionId, agentId, "spawn", { task, adapter, label });
|
|
43
|
+
const command = opts.command ?? "dirgha";
|
|
44
|
+
const args = opts.args ?? ["ask", "--no-interactive", task];
|
|
45
|
+
let child;
|
|
46
|
+
try {
|
|
47
|
+
child = spawn(command, args, {
|
|
48
|
+
cwd: opts.cwd,
|
|
49
|
+
env: { ...safeEnvironment(), ...opts.env },
|
|
50
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
registry.updateAgent(sessionId, agentId, {
|
|
55
|
+
status: "failed",
|
|
56
|
+
exitCode: -1,
|
|
57
|
+
elapsedMs: Date.now() - now,
|
|
58
|
+
});
|
|
59
|
+
writeLog(sessionId, agentId, "error", {
|
|
60
|
+
message: err.message,
|
|
61
|
+
});
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
registry.updateAgent(sessionId, agentId, {
|
|
65
|
+
pid: child.pid ?? 0,
|
|
66
|
+
status: "running",
|
|
67
|
+
});
|
|
68
|
+
// Wire stdout: each line → registry buffer + log.
|
|
69
|
+
child.stdout?.on("data", (chunk) => {
|
|
70
|
+
const lines = chunk.toString("utf-8").split("\n").filter(Boolean);
|
|
71
|
+
for (const line of lines) {
|
|
72
|
+
registry.appendOutput(sessionId, agentId, line);
|
|
73
|
+
writeLog(sessionId, agentId, "output", { line });
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
// Wire stderr similarly.
|
|
77
|
+
child.stderr?.on("data", (chunk) => {
|
|
78
|
+
const lines = chunk.toString("utf-8").split("\n").filter(Boolean);
|
|
79
|
+
for (const line of lines) {
|
|
80
|
+
registry.appendOutput(sessionId, agentId, `[stderr] ${line}`);
|
|
81
|
+
writeLog(sessionId, agentId, "output", { line, stream: "stderr" });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
// Wait for exit.
|
|
85
|
+
const done = new Promise((resolve) => {
|
|
86
|
+
child.on("exit", (code) => {
|
|
87
|
+
const elapsed = Date.now() - now;
|
|
88
|
+
registry.updateAgent(sessionId, agentId, {
|
|
89
|
+
status: code === 0 ? "done" : "failed",
|
|
90
|
+
exitCode: code ?? -1,
|
|
91
|
+
elapsedMs: elapsed,
|
|
92
|
+
});
|
|
93
|
+
writeLog(sessionId, agentId, "exit", { code, elapsedMs: elapsed });
|
|
94
|
+
resolve(code ?? -1);
|
|
95
|
+
});
|
|
96
|
+
child.on("error", (err) => {
|
|
97
|
+
registry.updateAgent(sessionId, agentId, {
|
|
98
|
+
status: "failed",
|
|
99
|
+
exitCode: -2,
|
|
100
|
+
});
|
|
101
|
+
writeLog(sessionId, agentId, "error", { message: err.message });
|
|
102
|
+
resolve(-2);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
return { agentId, process: child, done };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Kill a running agent by session + agent id. Sends SIGTERM, then
|
|
109
|
+
* SIGKILL after 3 seconds.
|
|
110
|
+
*/
|
|
111
|
+
export async function killAgent(sessionId, agentId) {
|
|
112
|
+
const agent = registry.getAgent(sessionId, agentId);
|
|
113
|
+
if (!agent || (agent.status !== "running" && agent.status !== "spawning")) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
// Only send signals if the process actually exists (pid > 0).
|
|
117
|
+
// PID 0 would mean a still-spawning agent whose process hasn't been
|
|
118
|
+
// registered yet; process.kill(0, ...) hits the caller's process group.
|
|
119
|
+
if (agent.pid > 0) {
|
|
120
|
+
try {
|
|
121
|
+
process.kill(agent.pid, "SIGTERM");
|
|
122
|
+
// Give it 3 seconds then SIGKILL.
|
|
123
|
+
setTimeout(() => {
|
|
124
|
+
try {
|
|
125
|
+
process.kill(agent.pid, "SIGKILL");
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// Already dead.
|
|
129
|
+
}
|
|
130
|
+
}, 3000);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// Process may already be dead.
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
registry.updateAgent(sessionId, agentId, { status: "killed" });
|
|
137
|
+
writeLog(sessionId, agentId, "exit", { code: -1, killed: true });
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Kill all agents in a session and return the updated session.
|
|
142
|
+
*/
|
|
143
|
+
export async function killAll(sessionId) {
|
|
144
|
+
const session = registry.get(sessionId);
|
|
145
|
+
if (!session)
|
|
146
|
+
return undefined;
|
|
147
|
+
const kills = session.agents
|
|
148
|
+
.filter((a) => a.status === "running" || a.status === "spawning")
|
|
149
|
+
.map((a) => killAgent(sessionId, a.id));
|
|
150
|
+
await Promise.all(kills);
|
|
151
|
+
registry.update(sessionId, { active: false });
|
|
152
|
+
return registry.get(sessionId);
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=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|
+
* Parses the verb and dispatches to the appropriate handler.
|
|
6
|
+
*
|
|
7
|
+
* Verbs:
|
|
8
|
+
* up <task...> Spawn N agents, start dashboard
|
|
9
|
+
* list [--json] List active sessions
|
|
10
|
+
* attach <id> Resume watching a session
|
|
11
|
+
* kill <agent-id> Kill one agent by label/id
|
|
12
|
+
* down <session-id> Kill all agents in a session
|
|
13
|
+
* log <session-id> Tail orchestration log
|
|
14
|
+
*/
|
|
15
|
+
export interface OrchestraOpts {
|
|
16
|
+
json?: boolean;
|
|
17
|
+
cwd?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Main dispatch: called from main.ts when user types `dirgha orchestra …`.
|
|
21
|
+
* `argv` is everything after "orchestra". Returns exit code.
|
|
22
|
+
*/
|
|
23
|
+
export declare function orchestraCommand(argv: string[], opts?: OrchestraOpts): Promise<number>;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* orchestra/bin.ts — CLI entry point for `dirgha orchestra`.
|
|
4
|
+
*
|
|
5
|
+
* Parses the verb and dispatches to the appropriate handler.
|
|
6
|
+
*
|
|
7
|
+
* Verbs:
|
|
8
|
+
* up <task...> Spawn N agents, start dashboard
|
|
9
|
+
* list [--json] List active sessions
|
|
10
|
+
* attach <id> Resume watching a session
|
|
11
|
+
* kill <agent-id> Kill one agent by label/id
|
|
12
|
+
* down <session-id> Kill all agents in a session
|
|
13
|
+
* log <session-id> Tail orchestration log
|
|
14
|
+
*/
|
|
15
|
+
import { exit, stdout, stderr } from "node:process";
|
|
16
|
+
import { registry } from "./core/registry.js";
|
|
17
|
+
import { logPath, readLog } from "./orchestration/log.js";
|
|
18
|
+
import { loadSessions, saveSessions, removeStoredSession } from "./core/store.js";
|
|
19
|
+
import { spawnDirghaFleet } from "./agent/dirgha.js";
|
|
20
|
+
import { killAll, killAgent } from "./agent/manager.js";
|
|
21
|
+
const HELP = `dirgha orchestra — multi-agent task orchestration
|
|
22
|
+
|
|
23
|
+
USAGE:
|
|
24
|
+
dirgha orchestra up <task...> Spawn N agents, one per task
|
|
25
|
+
dirgha orchestra list [--json] List active sessions
|
|
26
|
+
dirgha orchestra attach <id> Attach to a running session
|
|
27
|
+
dirgha orchestra kill <agent-id> Kill a specific agent
|
|
28
|
+
dirgha orchestra down <session-id> Tear down a session
|
|
29
|
+
dirgha orchestra log <session-id> Show orchestration log
|
|
30
|
+
|
|
31
|
+
EXAMPLES:
|
|
32
|
+
dirgha orchestra up "refactor auth" "add tests"
|
|
33
|
+
dirgha orchestra list
|
|
34
|
+
dirgha orchestra kill agent-1
|
|
35
|
+
dirgha orchestra down orchestra-a1b2
|
|
36
|
+
`;
|
|
37
|
+
/**
|
|
38
|
+
* Find a session by id: check in-memory registry first, then persisted store.
|
|
39
|
+
*/
|
|
40
|
+
function findSession(id) {
|
|
41
|
+
return registry.get(id) ?? loadSessions().find((s) => s.id === id);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Main dispatch: called from main.ts when user types `dirgha orchestra …`.
|
|
45
|
+
* `argv` is everything after "orchestra". Returns exit code.
|
|
46
|
+
*/
|
|
47
|
+
export async function orchestraCommand(argv, opts = {}) {
|
|
48
|
+
// Parse --json (--flag as positional from the raw argv).
|
|
49
|
+
const rest = argv.filter((a) => a !== "--json");
|
|
50
|
+
const hasJson = argv.includes("--json") || opts.json === true;
|
|
51
|
+
const mergedOpts = { ...opts, json: hasJson };
|
|
52
|
+
const [verb, ...verbArgs] = rest;
|
|
53
|
+
// Handle help before the typed switch so "--help"/"-h"/"help" don't
|
|
54
|
+
// need to be members of the OrchestraVerb union.
|
|
55
|
+
if (verb === undefined || verb === "--help" || verb === "-h" || verb === "help") {
|
|
56
|
+
stdout.write(HELP);
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
switch (verb) {
|
|
60
|
+
case "up":
|
|
61
|
+
return cmdUp(verbArgs, mergedOpts);
|
|
62
|
+
case "list":
|
|
63
|
+
return cmdList(mergedOpts);
|
|
64
|
+
case "attach":
|
|
65
|
+
return cmdAttach(verbArgs, mergedOpts);
|
|
66
|
+
case "kill":
|
|
67
|
+
return cmdKill(verbArgs, mergedOpts);
|
|
68
|
+
case "down":
|
|
69
|
+
return cmdDown(verbArgs, mergedOpts);
|
|
70
|
+
case "log":
|
|
71
|
+
return cmdLog(verbArgs, mergedOpts);
|
|
72
|
+
default:
|
|
73
|
+
stderr.write(`orchestra: unknown verb "${verb}". See dirgha orchestra --help\n`);
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** `orchestra up <task...>` — spawn N agents and persist the session. */
|
|
78
|
+
async function cmdUp(tasks, _opts) {
|
|
79
|
+
if (tasks.length === 0) {
|
|
80
|
+
stderr.write("orchestra up: at least one task required\n");
|
|
81
|
+
stderr.write(" dirgha orchestra up \"refactor auth\" \"add tests\"\n");
|
|
82
|
+
return 1;
|
|
83
|
+
}
|
|
84
|
+
const session = registry.create({ active: true });
|
|
85
|
+
saveSessions([session]);
|
|
86
|
+
stdout.write(`orchestra: starting session ${session.id} with ${tasks.length} agent(s)\n`);
|
|
87
|
+
stdout.write(`orchestra: log → ${logPath(session.id)}\n`);
|
|
88
|
+
const results = await spawnDirghaFleet(session.id, tasks);
|
|
89
|
+
let spawned = 0;
|
|
90
|
+
for (const r of results) {
|
|
91
|
+
if (r) {
|
|
92
|
+
stdout.write(` ${r.agentId}: spawned as PID ${r.process.pid}\n`);
|
|
93
|
+
spawned++;
|
|
94
|
+
r.done.then((code) => {
|
|
95
|
+
stdout.write(` ${r.agentId}: exited with code ${code}\n`);
|
|
96
|
+
const hasRunning = registry.get(session.id)?.agents.some((a) => a.status === "running") ?? false;
|
|
97
|
+
registry.update(session.id, { active: hasRunning });
|
|
98
|
+
const s = registry.get(session.id);
|
|
99
|
+
if (s)
|
|
100
|
+
saveSessions([s]);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
stdout.write(`orchestra: ${spawned}/${tasks.length} agents spawned\n`);
|
|
105
|
+
const s = registry.get(session.id);
|
|
106
|
+
if (s)
|
|
107
|
+
saveSessions([s]);
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
/** `orchestra list [--json]` — list all sessions. */
|
|
111
|
+
async function cmdList(opts) {
|
|
112
|
+
const sessions = registry.list();
|
|
113
|
+
const persisted = loadSessions();
|
|
114
|
+
const allIds = new Set(sessions.map((s) => s.id));
|
|
115
|
+
for (const s of persisted) {
|
|
116
|
+
if (!allIds.has(s.id))
|
|
117
|
+
sessions.push(s);
|
|
118
|
+
}
|
|
119
|
+
if (opts.json) {
|
|
120
|
+
stdout.write(JSON.stringify(sessions, null, 2) + "\n");
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
if (sessions.length === 0) {
|
|
124
|
+
stdout.write("orchestra: no sessions\n");
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
for (const s of sessions) {
|
|
128
|
+
const running = s.agents.filter((a) => a.status === "running").length;
|
|
129
|
+
const done = s.agents.filter((a) => a.status === "done").length;
|
|
130
|
+
const failed = s.agents.filter((a) => a.status === "failed").length;
|
|
131
|
+
const status = s.active ? "ACTIVE" : "INACTIVE";
|
|
132
|
+
stdout.write(` ${s.id} ${s.title.padEnd(20)} ${status} ` +
|
|
133
|
+
`${s.agents.length} agents (${running} running, ${done} done, ${failed} failed)\n`);
|
|
134
|
+
}
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
/** `orchestra attach <id>` — show session status + log path. */
|
|
138
|
+
async function cmdAttach(args, _opts) {
|
|
139
|
+
const id = args[0];
|
|
140
|
+
if (!id) {
|
|
141
|
+
stderr.write("orchestra attach: session id required\n");
|
|
142
|
+
return 1;
|
|
143
|
+
}
|
|
144
|
+
const session = findSession(id);
|
|
145
|
+
if (!session) {
|
|
146
|
+
stderr.write(`orchestra: session "${id}" not found\n`);
|
|
147
|
+
return 1;
|
|
148
|
+
}
|
|
149
|
+
stdout.write(`Session: ${session.id} (${session.title})\n`);
|
|
150
|
+
stdout.write(`Status: ${session.active ? "ACTIVE" : "INACTIVE"}\n`);
|
|
151
|
+
stdout.write(`Log: ${logPath(session.id)}\n`);
|
|
152
|
+
stdout.write(`Agents:\n`);
|
|
153
|
+
for (const agent of session.agents) {
|
|
154
|
+
stdout.write(` ${agent.id.padEnd(16)} ${agent.status.padEnd(10)} ` +
|
|
155
|
+
`PID ${String(agent.pid).padEnd(6)} ` +
|
|
156
|
+
`${agent.outputBuffer.length} output lines\n`);
|
|
157
|
+
}
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
160
|
+
/** `orchestra kill <agent-id>` — kill a specific agent. */
|
|
161
|
+
async function cmdKill(args, _opts) {
|
|
162
|
+
const target = args[0];
|
|
163
|
+
if (!target) {
|
|
164
|
+
stderr.write("orchestra kill: agent id required (e.g. agent-1)\n");
|
|
165
|
+
return 1;
|
|
166
|
+
}
|
|
167
|
+
for (const session of registry.list()) {
|
|
168
|
+
const agent = session.agents.find((a) => a.id === target || a.label === target);
|
|
169
|
+
if (agent) {
|
|
170
|
+
await killAgent(session.id, agent.id);
|
|
171
|
+
stdout.write(`orchestra: killed ${agent.id} in session ${session.id}\n`);
|
|
172
|
+
const s = registry.get(session.id);
|
|
173
|
+
if (s)
|
|
174
|
+
saveSessions([s]);
|
|
175
|
+
return 0;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
stderr.write(`orchestra: agent "${target}" not found in any active session\n`);
|
|
179
|
+
return 1;
|
|
180
|
+
}
|
|
181
|
+
/** `orchestra down <session-id>` — kill all agents in a session. */
|
|
182
|
+
async function cmdDown(args, _opts) {
|
|
183
|
+
const id = args[0];
|
|
184
|
+
if (!id) {
|
|
185
|
+
stderr.write("orchestra down: session id required\n");
|
|
186
|
+
return 1;
|
|
187
|
+
}
|
|
188
|
+
const session = findSession(id);
|
|
189
|
+
if (!session) {
|
|
190
|
+
stderr.write(`orchestra: session "${id}" not found\n`);
|
|
191
|
+
return 1;
|
|
192
|
+
}
|
|
193
|
+
await killAll(session.id);
|
|
194
|
+
removeStoredSession(session.id);
|
|
195
|
+
stdout.write(`orchestra: session ${session.id} torn down\n`);
|
|
196
|
+
return 0;
|
|
197
|
+
}
|
|
198
|
+
/** `orchestra log <session-id>` — show the orchestration log. */
|
|
199
|
+
async function cmdLog(args, _opts) {
|
|
200
|
+
const id = args[0];
|
|
201
|
+
if (!id) {
|
|
202
|
+
stderr.write("orchestra log: session id required\n");
|
|
203
|
+
return 1;
|
|
204
|
+
}
|
|
205
|
+
const session = findSession(id);
|
|
206
|
+
if (!session) {
|
|
207
|
+
stderr.write(`orchestra: session "${id}" not found\n`);
|
|
208
|
+
return 1;
|
|
209
|
+
}
|
|
210
|
+
const entries = readLog(id);
|
|
211
|
+
if (entries.length === 0) {
|
|
212
|
+
stdout.write(`orchestra: no log entries for session ${id}\n`);
|
|
213
|
+
return 0;
|
|
214
|
+
}
|
|
215
|
+
for (const entry of entries.slice(-100)) {
|
|
216
|
+
stdout.write(`[${entry.timestamp}] ${entry.agentId} ${entry.event} ` +
|
|
217
|
+
`${JSON.stringify(entry.payload)}\n`);
|
|
218
|
+
}
|
|
219
|
+
return 0;
|
|
220
|
+
}
|
|
221
|
+
// Direct execution (for testing).
|
|
222
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
223
|
+
orchestraCommand(process.argv.slice(3)).then(exit);
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=bin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/orchestra/bin.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,OAAO,EAA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AAC,CAAC;IACX,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;QACxC,MAAM,CAAC,KAAK,CACV,IAAI,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,KAAK,GAAG;YACvD,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CACrC,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,kCAAkC;AAClC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpD,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orchestra/core/registry.ts — In-memory registry of orchestra sessions.
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for all active orchestrations. Each session
|
|
5
|
+
* holds N AgentSlots that reflect live subprocess state. The registry is
|
|
6
|
+
* mutated by: agent manager (on spawn/exit), TUI (on user input), and
|
|
7
|
+
* coordinator (on task assignment). No tmux, no external state.
|
|
8
|
+
*/
|
|
9
|
+
import type { OrchestraSession, AgentSlot } from "./types.js";
|
|
10
|
+
declare class OrchestraRegistry {
|
|
11
|
+
#private;
|
|
12
|
+
create(overrides?: Partial<OrchestraSession>): OrchestraSession;
|
|
13
|
+
get(id: string): OrchestraSession | undefined;
|
|
14
|
+
list(): OrchestraSession[];
|
|
15
|
+
update(id: string, patch: Partial<OrchestraSession>): OrchestraSession | undefined;
|
|
16
|
+
remove(id: string): OrchestraSession | undefined;
|
|
17
|
+
addAgent(sessionId: string, agent: AgentSlot): boolean;
|
|
18
|
+
removeAgent(sessionId: string, agentId: string): boolean;
|
|
19
|
+
getAgent(sessionId: string, agentId: string): AgentSlot | undefined;
|
|
20
|
+
updateAgent(sessionId: string, agentId: string, patch: Partial<AgentSlot>): AgentSlot | undefined;
|
|
21
|
+
/** Append a line to an agent's output ring buffer (last 200 lines). */
|
|
22
|
+
appendOutput(sessionId: string, agentId: string, line: string): void;
|
|
23
|
+
clear(): void;
|
|
24
|
+
get size(): number;
|
|
25
|
+
}
|
|
26
|
+
export declare const registry: OrchestraRegistry;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orchestra/core/registry.ts — In-memory registry of orchestra sessions.
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for all active orchestrations. Each session
|
|
5
|
+
* holds N AgentSlots that reflect live subprocess state. The registry is
|
|
6
|
+
* mutated by: agent manager (on spawn/exit), TUI (on user input), and
|
|
7
|
+
* coordinator (on task assignment). No tmux, no external state.
|
|
8
|
+
*/
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
class OrchestraRegistry {
|
|
11
|
+
#sessions = new Map();
|
|
12
|
+
create(overrides) {
|
|
13
|
+
const id = overrides?.id ?? randomUUID().slice(0, 8);
|
|
14
|
+
const now = Date.now();
|
|
15
|
+
const session = {
|
|
16
|
+
id,
|
|
17
|
+
title: `orchestra-${id}`,
|
|
18
|
+
agents: [],
|
|
19
|
+
active: false,
|
|
20
|
+
createdAt: now,
|
|
21
|
+
updatedAt: now,
|
|
22
|
+
...overrides,
|
|
23
|
+
};
|
|
24
|
+
this.#sessions.set(id, session);
|
|
25
|
+
return session;
|
|
26
|
+
}
|
|
27
|
+
get(id) {
|
|
28
|
+
return this.#sessions.get(id);
|
|
29
|
+
}
|
|
30
|
+
list() {
|
|
31
|
+
return Array.from(this.#sessions.values());
|
|
32
|
+
}
|
|
33
|
+
update(id, patch) {
|
|
34
|
+
const s = this.#sessions.get(id);
|
|
35
|
+
if (!s)
|
|
36
|
+
return undefined;
|
|
37
|
+
Object.assign(s, patch, { updatedAt: Date.now() });
|
|
38
|
+
return s;
|
|
39
|
+
}
|
|
40
|
+
remove(id) {
|
|
41
|
+
const s = this.#sessions.get(id);
|
|
42
|
+
if (s)
|
|
43
|
+
this.#sessions.delete(id);
|
|
44
|
+
return s;
|
|
45
|
+
}
|
|
46
|
+
addAgent(sessionId, agent) {
|
|
47
|
+
const s = this.#sessions.get(sessionId);
|
|
48
|
+
if (!s)
|
|
49
|
+
return false;
|
|
50
|
+
s.agents.push(agent);
|
|
51
|
+
s.updatedAt = Date.now();
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
removeAgent(sessionId, agentId) {
|
|
55
|
+
const s = this.#sessions.get(sessionId);
|
|
56
|
+
if (!s)
|
|
57
|
+
return false;
|
|
58
|
+
const idx = s.agents.findIndex((a) => a.id === agentId);
|
|
59
|
+
if (idx === -1)
|
|
60
|
+
return false;
|
|
61
|
+
s.agents.splice(idx, 1);
|
|
62
|
+
s.updatedAt = Date.now();
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
getAgent(sessionId, agentId) {
|
|
66
|
+
const s = this.#sessions.get(sessionId);
|
|
67
|
+
if (!s)
|
|
68
|
+
return undefined;
|
|
69
|
+
return s.agents.find((a) => a.id === agentId);
|
|
70
|
+
}
|
|
71
|
+
updateAgent(sessionId, agentId, patch) {
|
|
72
|
+
const s = this.#sessions.get(sessionId);
|
|
73
|
+
if (!s)
|
|
74
|
+
return undefined;
|
|
75
|
+
const agent = s.agents.find((a) => a.id === agentId);
|
|
76
|
+
if (!agent)
|
|
77
|
+
return undefined;
|
|
78
|
+
Object.assign(agent, patch);
|
|
79
|
+
s.updatedAt = Date.now();
|
|
80
|
+
return agent;
|
|
81
|
+
}
|
|
82
|
+
/** Append a line to an agent's output ring buffer (last 200 lines). */
|
|
83
|
+
appendOutput(sessionId, agentId, line) {
|
|
84
|
+
const agent = this.getAgent(sessionId, agentId);
|
|
85
|
+
if (!agent)
|
|
86
|
+
return;
|
|
87
|
+
agent.outputBuffer.push(line);
|
|
88
|
+
if (agent.outputBuffer.length > 200) {
|
|
89
|
+
agent.outputBuffer.splice(0, agent.outputBuffer.length - 200);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
clear() {
|
|
93
|
+
this.#sessions.clear();
|
|
94
|
+
}
|
|
95
|
+
get size() {
|
|
96
|
+
return this.#sessions.size;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export const registry = new OrchestraRegistry();
|
|
100
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/orchestra/core/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,iBAAiB;IACrB,SAAS,GAAG,IAAI,GAAG,EAA4B,CAAC;IAEhD,MAAM,CAAC,SAAqC;QAC1C,MAAM,EAAE,GAAG,SAAS,EAAE,EAAE,IAAI,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACrD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,OAAO,GAAqB;YAChC,EAAE;YACF,KAAK,EAAE,aAAa,EAAE,EAAE;YACxB,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,KAAK;YACb,SAAS,EAAE,GAAG;YACd,SAAS,EAAE,GAAG;YACd,GAAG,SAAS;SACb,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,C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C,CAAC;QAC9B,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YACpC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orchestra/core/store.ts — Orchestration state persistence.
|
|
3
|
+
*
|
|
4
|
+
* Persists sessions to ~/.dirgha/orchestra.json so they survive CLI restarts.
|
|
5
|
+
* P1 enhancement: SQLite-backed with history replay.
|
|
6
|
+
*/
|
|
7
|
+
import type { OrchestraSession } from "./types.js";
|
|
8
|
+
export interface PersistedStore {
|
|
9
|
+
version: number;
|
|
10
|
+
sessions: OrchestraSession[];
|
|
11
|
+
}
|
|
12
|
+
export declare function loadSessions(): OrchestraSession[];
|
|
13
|
+
export declare function saveSessions(sessions: OrchestraSession[]): void;
|
|
14
|
+
export declare function appendSession(session: OrchestraSession): void;
|
|
15
|
+
export declare function removeStoredSession(id: string): void;
|