@oxgeneral/orch 0.3.2 → 0.3.4
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/App-RKAPZNZO.js +6682 -0
- package/dist/agent-KBTLGGCT.js +183 -0
- package/dist/agent-shop-YN2BSLHM.js +2 -0
- package/dist/chunk-2C2TFQ7K.js +136 -0
- package/dist/chunk-45K2XID7.js +29 -0
- package/dist/{shell-IH2MMTVP.js → chunk-52BFUGDD.js} +8 -6
- package/dist/chunk-7X2GI5OV.js +181 -0
- package/dist/{chunk-HSBYJ5C5.js → chunk-A36WAF2S.js} +89 -2
- package/dist/chunk-CHIP7O6V.js +83 -0
- package/dist/{claude-RIB3RQS5.js → chunk-D6RFF3KN.js} +12 -9
- package/dist/{chunk-BCPUTULS.js → chunk-DAVHOWGD.js} +188 -16
- package/dist/chunk-FRTKB575.js +87 -0
- package/dist/chunk-HXYAZGLP.js +15 -0
- package/dist/chunk-I3SMISEF.js +29 -0
- package/dist/chunk-K6DMQERQ.js +89 -0
- package/dist/chunk-LV6GDBBI.js +297 -0
- package/dist/chunk-NLQAJ7TW.js +147 -0
- package/dist/chunk-NLQAJ7TW.js.map +1 -0
- package/dist/chunk-P6ATSXGL.js +107 -0
- package/dist/chunk-PNE6LQRF.js +5 -0
- package/dist/{chunk-MGFMVPRD.js → chunk-S3QYSBW4.js} +11 -4
- package/dist/chunk-S3QYSBW4.js.map +1 -0
- package/dist/chunk-U2VDNUZL.js +52 -0
- package/dist/{chunk-QEEM67OA.js → chunk-UIJYU3J7.js} +3 -3
- package/dist/{chunk-QEEM67OA.js.map → chunk-UIJYU3J7.js.map} +1 -1
- package/dist/{chunk-2UC4SVJB.js → chunk-VMDQVRBR.js} +22 -8
- package/dist/chunk-VMDQVRBR.js.map +1 -0
- package/dist/chunk-W6RSVMXR.js +66 -0
- package/dist/claude-INM52PTH.js +88 -0
- package/dist/claude-INM52PTH.js.map +1 -0
- package/dist/claude-NHUNA5RZ.js +5 -0
- package/dist/cli.js +199 -1
- package/dist/clipboard-service-RTDUUQQU.js +200 -0
- package/dist/{codex-VBUSA2GJ.js → codex-DIXT44JR.js} +17 -11
- package/dist/codex-QGH2GRV6.js +125 -0
- package/dist/codex-QGH2GRV6.js.map +1 -0
- package/dist/config-OTAVSMOD.js +75 -0
- package/dist/container-LJU4QNDH.js +1594 -0
- package/dist/context-OL4BVUV5.js +83 -0
- package/dist/{cursor-4QIOTDBW.js → cursor-C3TR2IJC.js} +11 -8
- package/dist/cursor-KQJTQ73D.js +99 -0
- package/dist/cursor-KQJTQ73D.js.map +1 -0
- package/dist/doctor-V2FPS236.js +67 -0
- package/dist/doctor-service-TPOMFAIG.js +2 -0
- package/dist/goal-FMYYN2FR.js +138 -0
- package/dist/index.d.ts +64 -41
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- package/dist/init-U7MCIOB2.js +165 -0
- package/dist/logs-PHPYWQ6I.js +207 -0
- package/dist/msg-FUWWLEKM.js +95 -0
- package/dist/orchestrator-ADO66XZ3.js +5 -0
- package/dist/{orchestrator-FGGXK3N3.js.map → orchestrator-ADO66XZ3.js.map} +1 -1
- package/dist/orchestrator-E3FQ4SOE.js +1424 -0
- package/dist/process-manager-HUVNAPQV.js +2 -0
- package/dist/registry-PQWRVNF2.js +2 -0
- package/dist/run-N72G5V2H.js +95 -0
- package/dist/shell-3S4VLYEG.js +4 -0
- package/dist/shell-JXOPKDXH.js +221 -0
- package/dist/shell-JXOPKDXH.js.map +1 -0
- package/dist/shop-picker-2HY67UWP.js +79 -0
- package/dist/status-RZWN2C6C.js +56 -0
- package/dist/task-2TJW6Z7O.js +221 -0
- package/dist/team-PFLP4PPL.js +97 -0
- package/dist/template-engine-4IZKRRHG.js +3 -0
- package/dist/tui-IM3YUUVD.js +245 -0
- package/dist/update-YLP7FPNY.js +64 -0
- package/dist/update-check-4YKLGBFB.js +2 -0
- package/dist/{workspace-manager-T6AXG7XL.js → workspace-manager-EVD67GCG.js} +4 -4
- package/dist/{workspace-manager-T6AXG7XL.js.map → workspace-manager-EVD67GCG.js.map} +1 -1
- package/dist/workspace-manager-JM6U7JOH.js +215 -0
- package/package.json +1 -1
- package/readme.md +9 -2
- package/scripts/postinstall.js +44 -2
- package/dist/App-YJM5QGP7.js +0 -19
- package/dist/agent-S4DKSX63.js +0 -9
- package/dist/agent-shop-D2RS4BZK.js +0 -2
- package/dist/chunk-2UC4SVJB.js.map +0 -1
- package/dist/chunk-5AJ4LYO5.js +0 -8
- package/dist/chunk-6MJ7V6VY.js +0 -2
- package/dist/chunk-CDFA4IIQ.js +0 -2
- package/dist/chunk-CHRW4CLD.js +0 -2
- package/dist/chunk-GZ2Q56YZ.js +0 -2
- package/dist/chunk-HMMPM7MF.js +0 -3
- package/dist/chunk-HXOMNULD.js +0 -2
- package/dist/chunk-IQXRQBUK.js +0 -83
- package/dist/chunk-IQXRQBUK.js.map +0 -1
- package/dist/chunk-L26TK7Y5.js +0 -2
- package/dist/chunk-L3FYR45M.js +0 -2
- package/dist/chunk-LXNRCJ22.js +0 -2
- package/dist/chunk-MGFMVPRD.js.map +0 -1
- package/dist/chunk-MNXU3KCD.js +0 -2
- package/dist/chunk-PJ5DKXGR.js +0 -2
- package/dist/chunk-UMZEA3JT.js +0 -5
- package/dist/chunk-UW6GUUE6.js +0 -3
- package/dist/chunk-ZA5Z33GO.js +0 -11
- package/dist/claude-E36EGXUV.js +0 -2
- package/dist/claude-RIB3RQS5.js.map +0 -1
- package/dist/clipboard-service-PDTSZIR5.js +0 -25
- package/dist/codex-OTZKVESD.js +0 -2
- package/dist/codex-VBUSA2GJ.js.map +0 -1
- package/dist/config-CCSS2P7R.js +0 -2
- package/dist/container-OIXLFSX2.js +0 -6
- package/dist/context-GSMQHQES.js +0 -7
- package/dist/cursor-3DJA6LWS.js +0 -2
- package/dist/cursor-4QIOTDBW.js.map +0 -1
- package/dist/doctor-KBK5JZBZ.js +0 -2
- package/dist/doctor-service-PB7YBH3F.js +0 -2
- package/dist/goal-RFKFPR7M.js +0 -8
- package/dist/init-WRDFAFS2.js +0 -53
- package/dist/logs-5QHJWMEG.js +0 -12
- package/dist/msg-4SCLBO4K.js +0 -9
- package/dist/orchestrator-FGGXK3N3.js +0 -5
- package/dist/orchestrator-R7IWZUT6.js +0 -13
- package/dist/process-manager-33H27MQF.js +0 -2
- package/dist/registry-BO2PPRNG.js +0 -2
- package/dist/run-HSHRELOP.js +0 -3
- package/dist/shell-EOJBDWTH.js +0 -2
- package/dist/shell-IH2MMTVP.js.map +0 -1
- package/dist/shop-picker-LE3SKFOX.js +0 -5
- package/dist/status-DLBNWSWM.js +0 -2
- package/dist/task-J6ZN7ALI.js +0 -20
- package/dist/team-MSIBKOQC.js +0 -4
- package/dist/template-engine-ONIDVD4F.js +0 -2
- package/dist/tui-LW7WIDE3.js +0 -2
- package/dist/update-PC2ENCKU.js +0 -2
- package/dist/update-check-HGMBDYHL.js +0 -2
- package/dist/workspace-manager-KOOYTO7E.js +0 -3
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { agentToEditorContent, openInEditor, agentFromEditorContent } from './chunk-P6ATSXGL.js';
|
|
3
|
+
import { printSuccess, agentName, printTable, dim, statusIcon, formatTokens, printKeyValue } from './chunk-7X2GI5OV.js';
|
|
4
|
+
|
|
5
|
+
// src/cli/commands/agent.ts
|
|
6
|
+
function registerAgentCommand(program, container) {
|
|
7
|
+
const agent = program.command("agent").description("Manage agents");
|
|
8
|
+
agent.command("add <name>").description("Add a new agent").requiredOption("--adapter <adapter>", "Adapter type: claude, shell, codex, cursor").option("--role <role>", "Agent role description").option("--command <cmd>", "Shell command (for shell adapter)").option("--model <model>", "Model name (for AI adapters)").option("--max-turns <n>", "Max turns per run").option("--timeout <ms>", "Timeout in ms").option("--approval-policy <policy>", "suggest|auto|manual").option("--workspace-mode <mode>", "shared|worktree|isolated").option("--skills <skills>", "Comma-separated list of agent skills").option("-e, --edit", "Open $EDITOR to write the role description").action(async (name, opts) => {
|
|
9
|
+
await container.paths.requireInit();
|
|
10
|
+
let role = opts.role;
|
|
11
|
+
if (opts.edit) {
|
|
12
|
+
const initial = agentToEditorContent({ name, model: opts.model, role });
|
|
13
|
+
const edited = await openInEditor(initial);
|
|
14
|
+
const parsed = agentFromEditorContent(edited);
|
|
15
|
+
if (parsed.name) name = parsed.name;
|
|
16
|
+
if (parsed.model) opts.model = parsed.model;
|
|
17
|
+
if (parsed.role) role = parsed.role;
|
|
18
|
+
}
|
|
19
|
+
const a = await container.agentService.create({
|
|
20
|
+
name,
|
|
21
|
+
adapter: opts.adapter,
|
|
22
|
+
role,
|
|
23
|
+
command: opts.command,
|
|
24
|
+
model: opts.model,
|
|
25
|
+
max_turns: opts.maxTurns ? parseInt(opts.maxTurns, 10) : void 0,
|
|
26
|
+
timeout_ms: opts.timeout ? parseInt(opts.timeout, 10) : void 0,
|
|
27
|
+
approval_policy: opts.approvalPolicy,
|
|
28
|
+
workspace_mode: opts.workspaceMode,
|
|
29
|
+
skills: opts.skills ? opts.skills.split(",").map((s) => s.trim()) : void 0
|
|
30
|
+
});
|
|
31
|
+
if (container.context.json) {
|
|
32
|
+
console.log(JSON.stringify(a, null, 2));
|
|
33
|
+
} else if (container.context.quiet) {
|
|
34
|
+
console.log(a.id);
|
|
35
|
+
} else {
|
|
36
|
+
printSuccess(`Added agent ${agentName(a.name)} (${a.adapter}) \u2192 ${a.id}`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
agent.command("shop").description("Browse and install pre-built agent templates").option("--list", "Print all templates (non-interactive)").action(async (opts) => {
|
|
40
|
+
await container.paths.requireInit();
|
|
41
|
+
const { AGENT_SHOP_TEMPLATES } = await import('./agent-shop-YN2BSLHM.js');
|
|
42
|
+
if (opts.list || !process.stdout.isTTY) {
|
|
43
|
+
printTable(
|
|
44
|
+
["Key", "Name", "Adapter", "Model", "Skills"],
|
|
45
|
+
AGENT_SHOP_TEMPLATES.map((t) => [t.key, t.name, t.adapter, t.model.replace("claude-", ""), t.skills.slice(0, 2).join(", ")])
|
|
46
|
+
);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const { pickFromShop } = await import('./shop-picker-2HY67UWP.js');
|
|
50
|
+
const template = await pickFromShop(AGENT_SHOP_TEMPLATES);
|
|
51
|
+
if (!template) {
|
|
52
|
+
console.log(" Cancelled.");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const a = await container.agentService.create({
|
|
56
|
+
name: template.name,
|
|
57
|
+
adapter: template.adapter,
|
|
58
|
+
model: template.model,
|
|
59
|
+
role: template.role,
|
|
60
|
+
skills: template.skills,
|
|
61
|
+
approval_policy: template.approval_policy
|
|
62
|
+
});
|
|
63
|
+
printSuccess(`Added agent ${agentName(a.name)} (${a.adapter}) \u2192 ${a.id}`);
|
|
64
|
+
});
|
|
65
|
+
agent.command("list").description("List all agents").action(async () => {
|
|
66
|
+
await container.paths.requireInit();
|
|
67
|
+
const agents = await container.agentService.list();
|
|
68
|
+
if (container.context.json) {
|
|
69
|
+
console.log(JSON.stringify(agents, null, 2));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (container.context.quiet) {
|
|
73
|
+
agents.forEach((a) => console.log(a.id));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (agents.length === 0) {
|
|
77
|
+
console.log(`
|
|
78
|
+
No agents. Add one: ${dim("orch agent add <name> --adapter claude")}
|
|
79
|
+
`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const headers = ["STATUS", "AGENT", "ADAPTER", "TASK", "TIME"];
|
|
83
|
+
const rows = agents.map((a) => [
|
|
84
|
+
`${statusIcon(a.status)} ${a.status}`,
|
|
85
|
+
agentName(a.name),
|
|
86
|
+
a.adapter,
|
|
87
|
+
a.current_task ?? dim("\u2014"),
|
|
88
|
+
dim("\u2014")
|
|
89
|
+
]);
|
|
90
|
+
console.log();
|
|
91
|
+
printTable(headers, rows);
|
|
92
|
+
const running = agents.filter((a) => a.status === "running").length;
|
|
93
|
+
console.log(
|
|
94
|
+
`
|
|
95
|
+
${agents.length} agents \xB7 ${running} running \xB7 ${formatTokens(agents.reduce((sum, a) => sum + (a.stats.tokens_used ?? 0), 0))} tokens total
|
|
96
|
+
`
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
agent.command("status <id>").description("Show agent details").action(async (id) => {
|
|
100
|
+
await container.paths.requireInit();
|
|
101
|
+
const a = await container.agentService.get(id);
|
|
102
|
+
if (container.context.json) {
|
|
103
|
+
console.log(JSON.stringify(a, null, 2));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
console.log(`
|
|
107
|
+
${a.name}`);
|
|
108
|
+
console.log(` ${"\u2550".repeat(42)}`);
|
|
109
|
+
console.log();
|
|
110
|
+
const pairs = [
|
|
111
|
+
["Adapter", `${a.adapter}${a.config.model ? ` (${a.config.model})` : ""}`],
|
|
112
|
+
["Status", `${statusIcon(a.status)} ${a.status}`],
|
|
113
|
+
["Policy", a.config.approval_policy ?? "auto"]
|
|
114
|
+
];
|
|
115
|
+
if (a.current_task) pairs.push(["Task", a.current_task]);
|
|
116
|
+
if (a.role) pairs.push(["Role", a.role]);
|
|
117
|
+
if (a.config.skills?.length) pairs.push(["Skills", a.config.skills.join(", ")]);
|
|
118
|
+
printKeyValue(pairs);
|
|
119
|
+
console.log(`
|
|
120
|
+
Stats
|
|
121
|
+
${"\u2500".repeat(42)}`);
|
|
122
|
+
printKeyValue([
|
|
123
|
+
["Tasks completed", String(a.stats.tasks_completed)],
|
|
124
|
+
["Tasks failed", String(a.stats.tasks_failed)],
|
|
125
|
+
["Total runs", String(a.stats.total_runs)],
|
|
126
|
+
["Tokens used", formatTokens(a.stats.tokens_used ?? 0)]
|
|
127
|
+
]);
|
|
128
|
+
console.log();
|
|
129
|
+
});
|
|
130
|
+
agent.command("edit <id>").description("Edit an agent in $EDITOR").action(async (id) => {
|
|
131
|
+
await container.paths.requireInit();
|
|
132
|
+
const a = await container.agentService.get(id);
|
|
133
|
+
const initial = agentToEditorContent({
|
|
134
|
+
name: a.name,
|
|
135
|
+
model: a.config.model,
|
|
136
|
+
role: a.role
|
|
137
|
+
});
|
|
138
|
+
const edited = await openInEditor(initial);
|
|
139
|
+
const parsed = agentFromEditorContent(edited);
|
|
140
|
+
const updated = await container.agentService.update(id, {
|
|
141
|
+
name: parsed.name,
|
|
142
|
+
role: parsed.role,
|
|
143
|
+
model: parsed.model
|
|
144
|
+
});
|
|
145
|
+
if (container.context.json) {
|
|
146
|
+
console.log(JSON.stringify(updated, null, 2));
|
|
147
|
+
} else if (container.context.quiet) {
|
|
148
|
+
console.log(updated.id);
|
|
149
|
+
} else {
|
|
150
|
+
printSuccess(`Updated agent ${agentName(updated.name)} (${updated.id})`);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
agent.command("remove <id>").description("Remove an agent").action(async (id) => {
|
|
154
|
+
await container.paths.requireInit();
|
|
155
|
+
await container.agentService.remove(id);
|
|
156
|
+
printSuccess(`Removed agent ${id}`);
|
|
157
|
+
});
|
|
158
|
+
agent.command("disable <id>").description("Disable an agent").action(async (id) => {
|
|
159
|
+
await container.paths.requireInit();
|
|
160
|
+
await container.agentService.disable(id);
|
|
161
|
+
printSuccess(`Disabled agent ${id}`);
|
|
162
|
+
});
|
|
163
|
+
agent.command("enable <id>").description("Enable an agent").action(async (id) => {
|
|
164
|
+
await container.paths.requireInit();
|
|
165
|
+
await container.agentService.enable(id);
|
|
166
|
+
printSuccess(`Enabled agent ${id}`);
|
|
167
|
+
});
|
|
168
|
+
agent.command("autonomous <id>").description("Toggle autonomous mode for an agent").option("--on", "Enable autonomous mode").option("--off", "Disable autonomous mode").action(async (id, opts) => {
|
|
169
|
+
await container.paths.requireInit();
|
|
170
|
+
const current = await container.agentService.get(id);
|
|
171
|
+
const enable = opts.on ? true : opts.off ? false : !current.autonomous;
|
|
172
|
+
const a = await container.agentService.setAutonomous(id, enable);
|
|
173
|
+
if (container.context.json) {
|
|
174
|
+
console.log(JSON.stringify(a, null, 2));
|
|
175
|
+
} else if (container.context.quiet) {
|
|
176
|
+
console.log(a.id);
|
|
177
|
+
} else {
|
|
178
|
+
printSuccess(`Autonomous mode ${enable ? "enabled" : "disabled"} for agent ${agentName(a.name)} (${a.id})`);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export { registerAgentCommand };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// src/domain/errors.ts
|
|
3
|
+
var OrchestryError = class extends Error {
|
|
4
|
+
constructor(message, exitCode, hint) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.exitCode = exitCode;
|
|
7
|
+
this.hint = hint;
|
|
8
|
+
this.name = "OrchestryError";
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var NotInitializedError = class extends OrchestryError {
|
|
12
|
+
constructor() {
|
|
13
|
+
super("Not initialized", 3, "Run: orch init");
|
|
14
|
+
this.name = "NotInitializedError";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var InvalidArgumentsError = class extends OrchestryError {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message, 2);
|
|
20
|
+
this.name = "InvalidArgumentsError";
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var LockConflictError = class extends OrchestryError {
|
|
24
|
+
constructor(pid) {
|
|
25
|
+
super(`Orchestrator already running (PID: ${pid})`, 4, "Use: orch status");
|
|
26
|
+
this.name = "LockConflictError";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var NoAgentsError = class extends OrchestryError {
|
|
30
|
+
constructor() {
|
|
31
|
+
super("No agents configured", 1, "Run: orch agent add <name> --adapter claude");
|
|
32
|
+
this.name = "NoAgentsError";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var TaskNotFoundError = class extends OrchestryError {
|
|
36
|
+
constructor(taskId) {
|
|
37
|
+
super(`Task not found: ${taskId}`, 1);
|
|
38
|
+
this.name = "TaskNotFoundError";
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var AgentNotFoundError = class extends OrchestryError {
|
|
42
|
+
constructor(agentId) {
|
|
43
|
+
super(`Agent not found: ${agentId}`, 1);
|
|
44
|
+
this.name = "AgentNotFoundError";
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var TaskAlreadyRunningError = class extends OrchestryError {
|
|
48
|
+
constructor(taskId, runId, agentName) {
|
|
49
|
+
super(
|
|
50
|
+
`Task ${taskId} is already running (run: ${runId}, agent: ${agentName})`,
|
|
51
|
+
1,
|
|
52
|
+
`Use: orch logs --task ${taskId} --follow`
|
|
53
|
+
);
|
|
54
|
+
this.name = "TaskAlreadyRunningError";
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var InvalidTransitionError = class extends OrchestryError {
|
|
58
|
+
constructor(taskId, from, to) {
|
|
59
|
+
super(`Invalid transition for ${taskId}: ${from} \u2192 ${to}`, 1);
|
|
60
|
+
this.name = "InvalidTransitionError";
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var GoalNotFoundError = class extends OrchestryError {
|
|
64
|
+
constructor(goalId) {
|
|
65
|
+
super(`Goal not found: ${goalId}`, 1);
|
|
66
|
+
this.name = "GoalNotFoundError";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var TeamNotFoundError = class extends OrchestryError {
|
|
70
|
+
constructor(teamId) {
|
|
71
|
+
super(`Team not found: ${teamId}`, 1);
|
|
72
|
+
this.name = "TeamNotFoundError";
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var WorkspaceError = class extends OrchestryError {
|
|
76
|
+
constructor(message, hint) {
|
|
77
|
+
super(message, 6, hint);
|
|
78
|
+
this.name = "WorkspaceError";
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var ERROR_HINTS = {
|
|
82
|
+
["adapter_not_found" /* ADAPTER_NOT_FOUND */]: {
|
|
83
|
+
message: "CLI \u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D.",
|
|
84
|
+
fix: "\u0423\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0435: npm i -g @anthropic-ai/claude-code",
|
|
85
|
+
doctorHint: true
|
|
86
|
+
},
|
|
87
|
+
["auth_failed" /* AUTH_FAILED */]: {
|
|
88
|
+
message: "API \u043A\u043B\u044E\u0447 \u043D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D.",
|
|
89
|
+
fix: "\u041F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435: claude auth status"
|
|
90
|
+
},
|
|
91
|
+
["timeout" /* TIMEOUT */]: {
|
|
92
|
+
message: "\u0410\u0433\u0435\u043D\u0442 \u043F\u0440\u0435\u0432\u044B\u0441\u0438\u043B \u043B\u0438\u043C\u0438\u0442 \u0432\u0440\u0435\u043C\u0435\u043D\u0438.",
|
|
93
|
+
fix: "\u0423\u0432\u0435\u043B\u0438\u0447\u044C\u0442\u0435 \u0447\u0435\u0440\u0435\u0437: orch config set agent_timeout <ms>"
|
|
94
|
+
},
|
|
95
|
+
["rate_limit" /* RATE_LIMIT */]: {
|
|
96
|
+
message: "\u0414\u043E\u0441\u0442\u0438\u0433\u043D\u0443\u0442 \u043B\u0438\u043C\u0438\u0442 API.",
|
|
97
|
+
fix: "\u041F\u043E\u0434\u043E\u0436\u0434\u0438\u0442\u0435 \u0438 \u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0435: orch task retry <id>"
|
|
98
|
+
},
|
|
99
|
+
["process_crash" /* PROCESS_CRASH */]: {
|
|
100
|
+
message: "\u041F\u0440\u043E\u0446\u0435\u0441\u0441 \u0430\u0433\u0435\u043D\u0442\u0430 \u0443\u043F\u0430\u043B.",
|
|
101
|
+
fix: "\u041F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435: orch task retry <id>"
|
|
102
|
+
},
|
|
103
|
+
["spawn_failed" /* SPAWN_FAILED */]: {
|
|
104
|
+
message: "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u044C \u043F\u0440\u043E\u0446\u0435\u0441\u0441.",
|
|
105
|
+
fix: "\u041F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 PATH \u0438 \u043F\u0440\u0430\u0432\u0430 \u0434\u043E\u0441\u0442\u0443\u043F\u0430"
|
|
106
|
+
},
|
|
107
|
+
["unknown" /* UNKNOWN */]: {
|
|
108
|
+
message: "\u041D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u043E\u0448\u0438\u0431\u043A\u0430.",
|
|
109
|
+
fix: "\u0417\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0435: orch doctor",
|
|
110
|
+
doctorHint: true
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
function classifyAdapterError(error, exitCode) {
|
|
114
|
+
const lower = error.toLowerCase();
|
|
115
|
+
if (lower.includes("enoent") || lower.includes("spawn failed")) {
|
|
116
|
+
return "spawn_failed" /* SPAWN_FAILED */;
|
|
117
|
+
}
|
|
118
|
+
if (lower.includes("not found") || lower.includes("command not found") || lower.includes("no such file")) {
|
|
119
|
+
return "adapter_not_found" /* ADAPTER_NOT_FOUND */;
|
|
120
|
+
}
|
|
121
|
+
if (lower.includes("auth") || lower.includes("unauthorized") || lower.includes("401") || lower.includes("invalid api key") || lower.includes("authentication")) {
|
|
122
|
+
return "auth_failed" /* AUTH_FAILED */;
|
|
123
|
+
}
|
|
124
|
+
if (lower.includes("timeout") || lower.includes("timed out") || lower.includes("etimedout")) {
|
|
125
|
+
return "timeout" /* TIMEOUT */;
|
|
126
|
+
}
|
|
127
|
+
if (lower.includes("rate limit") || lower.includes("429") || lower.includes("too many requests")) {
|
|
128
|
+
return "rate_limit" /* RATE_LIMIT */;
|
|
129
|
+
}
|
|
130
|
+
if (exitCode !== void 0 && exitCode !== 0) {
|
|
131
|
+
return "process_crash" /* PROCESS_CRASH */;
|
|
132
|
+
}
|
|
133
|
+
return "unknown" /* UNKNOWN */;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export { AgentNotFoundError, ERROR_HINTS, GoalNotFoundError, InvalidArgumentsError, InvalidTransitionError, LockConflictError, NoAgentsError, NotInitializedError, OrchestryError, TaskAlreadyRunningError, TaskNotFoundError, TeamNotFoundError, WorkspaceError, classifyAdapterError };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// src/infrastructure/adapters/registry.ts
|
|
3
|
+
var AdapterRegistry = class {
|
|
4
|
+
adapters = /* @__PURE__ */ new Map();
|
|
5
|
+
register(adapter) {
|
|
6
|
+
this.adapters.set(adapter.kind, adapter);
|
|
7
|
+
}
|
|
8
|
+
get(kind) {
|
|
9
|
+
return this.adapters.get(kind);
|
|
10
|
+
}
|
|
11
|
+
require(kind) {
|
|
12
|
+
const adapter = this.adapters.get(kind);
|
|
13
|
+
if (!adapter) {
|
|
14
|
+
throw new Error(`Unknown adapter: "${kind}". Available: ${this.listKinds().join(", ")}`);
|
|
15
|
+
}
|
|
16
|
+
return adapter;
|
|
17
|
+
}
|
|
18
|
+
list() {
|
|
19
|
+
return Array.from(this.adapters.values());
|
|
20
|
+
}
|
|
21
|
+
listKinds() {
|
|
22
|
+
return Array.from(this.adapters.keys());
|
|
23
|
+
}
|
|
24
|
+
has(kind) {
|
|
25
|
+
return this.adapters.has(kind);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { AdapterRegistry };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readLines } from './chunk-CHIP7O6V.js';
|
|
3
|
+
import { classifyAdapterError } from './chunk-2C2TFQ7K.js';
|
|
2
4
|
import { execFile } from 'child_process';
|
|
3
5
|
import { promisify } from 'util';
|
|
4
6
|
|
|
@@ -122,7 +124,7 @@ var ShellAdapter = class {
|
|
|
122
124
|
const version = stdout.split("\n")[0]?.trim() ?? "unknown";
|
|
123
125
|
return { ok: true, version };
|
|
124
126
|
} catch {
|
|
125
|
-
return { ok: false, error: "bash not found" };
|
|
127
|
+
return { ok: false, error: "bash not found", errorKind: classifyAdapterError("bash not found") };
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
execute(params) {
|
|
@@ -132,7 +134,8 @@ var ShellAdapter = class {
|
|
|
132
134
|
yield {
|
|
133
135
|
type: "error",
|
|
134
136
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
135
|
-
data: "Shell adapter requires a command in agent config"
|
|
137
|
+
data: "Shell adapter requires a command in agent config",
|
|
138
|
+
errorKind: "spawn_failed" /* SPAWN_FAILED */
|
|
136
139
|
};
|
|
137
140
|
}
|
|
138
141
|
return { pid: 0, events: errorGen() };
|
|
@@ -179,7 +182,8 @@ var ShellAdapter = class {
|
|
|
179
182
|
await buffer.push({
|
|
180
183
|
type: "error",
|
|
181
184
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
182
|
-
data: line
|
|
185
|
+
data: line,
|
|
186
|
+
errorKind: classifyAdapterError(line)
|
|
183
187
|
});
|
|
184
188
|
}
|
|
185
189
|
})();
|
|
@@ -214,5 +218,3 @@ var ShellAdapter = class {
|
|
|
214
218
|
};
|
|
215
219
|
|
|
216
220
|
export { ShellAdapter };
|
|
217
|
-
//# sourceMappingURL=shell-IH2MMTVP.js.map
|
|
218
|
-
//# sourceMappingURL=shell-IH2MMTVP.js.map
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
|
|
4
|
+
var icons = {
|
|
5
|
+
running: "\u25CF",
|
|
6
|
+
todo: "\u25CB",
|
|
7
|
+
review: "\u25C8",
|
|
8
|
+
done: "\u2713",
|
|
9
|
+
failed: "\u2715",
|
|
10
|
+
retrying: "\u21BB",
|
|
11
|
+
cancelled: "\u25CB",
|
|
12
|
+
idle: "\u25CB",
|
|
13
|
+
error: "\u2715",
|
|
14
|
+
disabled: "\u2500",
|
|
15
|
+
agentAction: "\u25B8",
|
|
16
|
+
orchestratorEvent: "\u2192",
|
|
17
|
+
warning: "\u26A0"
|
|
18
|
+
};
|
|
19
|
+
var asciiIcons = {
|
|
20
|
+
running: "*",
|
|
21
|
+
todo: "o",
|
|
22
|
+
review: "#",
|
|
23
|
+
done: "+",
|
|
24
|
+
failed: "x",
|
|
25
|
+
retrying: "~",
|
|
26
|
+
cancelled: "o",
|
|
27
|
+
idle: "o",
|
|
28
|
+
error: "x",
|
|
29
|
+
disabled: "-",
|
|
30
|
+
agentAction: ">",
|
|
31
|
+
orchestratorEvent: "->",
|
|
32
|
+
warning: "!!"
|
|
33
|
+
};
|
|
34
|
+
var COLOR_CODES = {
|
|
35
|
+
amber: 214,
|
|
36
|
+
green: 72,
|
|
37
|
+
red: 167,
|
|
38
|
+
blue: 74,
|
|
39
|
+
yellow: 178,
|
|
40
|
+
dim: 240,
|
|
41
|
+
ghost: 236,
|
|
42
|
+
white: 255,
|
|
43
|
+
purple: 141
|
|
44
|
+
};
|
|
45
|
+
var _colors;
|
|
46
|
+
function getColors() {
|
|
47
|
+
if (!_colors) {
|
|
48
|
+
_colors = {};
|
|
49
|
+
for (const [name, code] of Object.entries(COLOR_CODES)) {
|
|
50
|
+
_colors[name] = chalk.ansi256(code);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return _colors;
|
|
54
|
+
}
|
|
55
|
+
var colors = new Proxy({}, {
|
|
56
|
+
get(_target, prop) {
|
|
57
|
+
return getColors()[prop];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var useAscii = false;
|
|
61
|
+
function setAsciiMode(ascii) {
|
|
62
|
+
useAscii = ascii;
|
|
63
|
+
}
|
|
64
|
+
function setNoColor(noColor) {
|
|
65
|
+
if (noColor) {
|
|
66
|
+
chalk.level = 0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function getIcon(name) {
|
|
70
|
+
return useAscii ? asciiIcons[name] : icons[name];
|
|
71
|
+
}
|
|
72
|
+
function statusIcon(status) {
|
|
73
|
+
const icon = getIcon(status);
|
|
74
|
+
switch (status) {
|
|
75
|
+
case "running":
|
|
76
|
+
case "in_progress":
|
|
77
|
+
return colors.green(getIcon("running"));
|
|
78
|
+
case "todo":
|
|
79
|
+
return colors.dim(getIcon("todo"));
|
|
80
|
+
case "review":
|
|
81
|
+
return colors.blue(getIcon("review"));
|
|
82
|
+
case "done":
|
|
83
|
+
return colors.green(getIcon("done"));
|
|
84
|
+
case "failed":
|
|
85
|
+
return colors.red(getIcon("failed"));
|
|
86
|
+
case "retrying":
|
|
87
|
+
return colors.yellow(getIcon("retrying"));
|
|
88
|
+
case "cancelled":
|
|
89
|
+
return colors.dim(getIcon("cancelled"));
|
|
90
|
+
case "idle":
|
|
91
|
+
return colors.dim(getIcon("idle"));
|
|
92
|
+
case "error":
|
|
93
|
+
return colors.red(getIcon("error"));
|
|
94
|
+
case "disabled":
|
|
95
|
+
return colors.ghost(getIcon("disabled"));
|
|
96
|
+
default:
|
|
97
|
+
return icon;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function priorityLabel(priority) {
|
|
101
|
+
switch (priority) {
|
|
102
|
+
case 1:
|
|
103
|
+
return colors.red("P1");
|
|
104
|
+
case 2:
|
|
105
|
+
return colors.yellow("P2");
|
|
106
|
+
case 3:
|
|
107
|
+
return "P3";
|
|
108
|
+
case 4:
|
|
109
|
+
return colors.dim("P4");
|
|
110
|
+
default:
|
|
111
|
+
return `P${priority}`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function formatDuration(ms) {
|
|
115
|
+
const seconds = Math.floor(ms / 1e3);
|
|
116
|
+
if (seconds < 60) return `${seconds}s`;
|
|
117
|
+
const minutes = Math.floor(seconds / 60);
|
|
118
|
+
const secs = seconds % 60;
|
|
119
|
+
if (minutes < 60) return `${minutes}:${String(secs).padStart(2, "0")}`;
|
|
120
|
+
const hours = Math.floor(minutes / 60);
|
|
121
|
+
const mins = minutes % 60;
|
|
122
|
+
return `${hours}h${String(mins).padStart(2, "0")}m`;
|
|
123
|
+
}
|
|
124
|
+
function formatDurationSince(isoDate) {
|
|
125
|
+
const ms = Date.now() - new Date(isoDate).getTime();
|
|
126
|
+
return formatDuration(ms);
|
|
127
|
+
}
|
|
128
|
+
function formatTokens(n) {
|
|
129
|
+
if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`;
|
|
130
|
+
return String(n);
|
|
131
|
+
}
|
|
132
|
+
function printError(message, hint) {
|
|
133
|
+
console.error(` ${colors.red(getIcon("failed"))} ${message}`);
|
|
134
|
+
if (hint) {
|
|
135
|
+
console.error(` ${hint}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function printSuccess(message) {
|
|
139
|
+
console.log(` ${colors.green(getIcon("done"))} ${message}`);
|
|
140
|
+
}
|
|
141
|
+
function printWarning(message) {
|
|
142
|
+
console.log(` ${colors.yellow(getIcon("warning"))} ${message}`);
|
|
143
|
+
}
|
|
144
|
+
function printTable(headers, rows, padding = 2) {
|
|
145
|
+
const colWidths = headers.map(
|
|
146
|
+
(h, i) => Math.max(h.length, ...rows.map((r) => stripAnsi(r[i] ?? "").length))
|
|
147
|
+
);
|
|
148
|
+
const headerLine = headers.map((h, i) => h.padEnd(colWidths[i] + padding)).join("");
|
|
149
|
+
console.log(` ${colors.dim(headerLine)}`);
|
|
150
|
+
for (const row of rows) {
|
|
151
|
+
const line = row.map((cell, i) => {
|
|
152
|
+
const stripped = stripAnsi(cell);
|
|
153
|
+
const pad = (colWidths[i] ?? 0) + padding - stripped.length;
|
|
154
|
+
return cell + " ".repeat(Math.max(0, pad));
|
|
155
|
+
}).join("");
|
|
156
|
+
console.log(` ${line}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function printKeyValue(pairs) {
|
|
160
|
+
const maxKey = Math.max(...pairs.map(([k]) => k.length));
|
|
161
|
+
for (const [key, value] of pairs) {
|
|
162
|
+
console.log(` ${colors.dim(key.padEnd(maxKey + 2))}${value}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function filePath(p) {
|
|
166
|
+
return colors.purple(p);
|
|
167
|
+
}
|
|
168
|
+
function agentName(name) {
|
|
169
|
+
return colors.green(name);
|
|
170
|
+
}
|
|
171
|
+
function amber(text) {
|
|
172
|
+
return colors.amber(text);
|
|
173
|
+
}
|
|
174
|
+
function dim(text) {
|
|
175
|
+
return colors.dim(text);
|
|
176
|
+
}
|
|
177
|
+
function stripAnsi(str) {
|
|
178
|
+
return str.replace(/\x1b\[[0-9;]*m/g, "");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export { agentName, amber, dim, filePath, formatDuration, formatDurationSince, formatTokens, getIcon, printError, printKeyValue, printSuccess, printTable, printWarning, priorityLabel, setAsciiMode, setNoColor, statusIcon };
|
|
@@ -1,5 +1,90 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { AUTONOMOUS_LABEL } from './chunk-PNE6LQRF.js';
|
|
3
|
+
|
|
4
|
+
// src/infrastructure/template/template-engine.ts
|
|
5
|
+
var LiquidTemplateEngine = class {
|
|
6
|
+
engine;
|
|
7
|
+
renderTimeoutMs;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.renderTimeoutMs = options?.renderTimeoutMs ?? 5e3;
|
|
10
|
+
}
|
|
11
|
+
async getEngine() {
|
|
12
|
+
if (!this.engine) {
|
|
13
|
+
const { Liquid } = await import('liquidjs');
|
|
14
|
+
this.engine = new Liquid({
|
|
15
|
+
strictFilters: false,
|
|
16
|
+
strictVariables: false
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return this.engine;
|
|
20
|
+
}
|
|
21
|
+
async render(template, context) {
|
|
22
|
+
const engine = await this.getEngine();
|
|
23
|
+
const renderPromise = engine.parseAndRender(template, context);
|
|
24
|
+
if (this.renderTimeoutMs <= 0) {
|
|
25
|
+
return renderPromise;
|
|
26
|
+
}
|
|
27
|
+
let timer;
|
|
28
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
29
|
+
timer = setTimeout(
|
|
30
|
+
() => reject(new Error(`Template render timed out after ${this.renderTimeoutMs}ms`)),
|
|
31
|
+
this.renderTimeoutMs
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
try {
|
|
35
|
+
return await Promise.race([renderPromise, timeoutPromise]);
|
|
36
|
+
} finally {
|
|
37
|
+
clearTimeout(timer);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function buildPromptContext(task, agent, attempt, workspacePath, config, options) {
|
|
42
|
+
const { allAgents, retryContext, sharedContext, feedback, messages: rawMessages, goal } = options ?? {};
|
|
43
|
+
const agentById = new Map((allAgents ?? []).map((a) => [a.id, a]));
|
|
44
|
+
const messages = rawMessages?.length ? rawMessages.map((m) => ({
|
|
45
|
+
id: m.id,
|
|
46
|
+
from: agentById.get(m.from_agent_id)?.name ?? m.from_agent_id,
|
|
47
|
+
subject: m.subject,
|
|
48
|
+
body: m.body,
|
|
49
|
+
sent_at: m.created_at,
|
|
50
|
+
reply_to: m.reply_to
|
|
51
|
+
})) : void 0;
|
|
52
|
+
return {
|
|
53
|
+
project: {
|
|
54
|
+
name: config.project.name,
|
|
55
|
+
description: config.project.description
|
|
56
|
+
},
|
|
57
|
+
task: {
|
|
58
|
+
id: task.id,
|
|
59
|
+
title: task.title,
|
|
60
|
+
description: task.description,
|
|
61
|
+
priority: task.priority,
|
|
62
|
+
labels: task.labels,
|
|
63
|
+
scope: task.scope,
|
|
64
|
+
is_autonomous: task.labels?.includes(AUTONOMOUS_LABEL) ?? false,
|
|
65
|
+
goal_id: task.goalId
|
|
66
|
+
},
|
|
67
|
+
agent: {
|
|
68
|
+
id: agent.id,
|
|
69
|
+
name: agent.name,
|
|
70
|
+
role: agent.role
|
|
71
|
+
},
|
|
72
|
+
agents: (allAgents ?? []).map((a) => ({
|
|
73
|
+
id: a.id,
|
|
74
|
+
name: a.name,
|
|
75
|
+
role: a.role,
|
|
76
|
+
adapter: a.adapter
|
|
77
|
+
})),
|
|
78
|
+
attempt: attempt > 1 ? attempt : null,
|
|
79
|
+
workspace_path: workspacePath,
|
|
80
|
+
retry: attempt > 1 ? retryContext : void 0,
|
|
81
|
+
feedback,
|
|
82
|
+
shared_context: sharedContext && Object.keys(sharedContext).length > 0 ? sharedContext : void 0,
|
|
83
|
+
messages,
|
|
84
|
+
goal
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
var DEFAULT_PROMPT_TEMPLATE = `You are {{ agent.name }}{% if agent.role %} ({{ agent.role }}){% endif %}.
|
|
3
88
|
|
|
4
89
|
## Task: {{ task.title }}
|
|
5
90
|
{{ task.description }}
|
|
@@ -109,4 +194,6 @@ This is an autonomous task driven by a goal. Work in a continuous loop until the
|
|
|
109
194
|
- If critical information is missing, document your assumptions and continue.
|
|
110
195
|
- When a task is too large or spans multiple domains, break it into subtasks using \`orch task add\`.
|
|
111
196
|
- When creating subtasks, use \`--scope\` to declare which files each task will touch, and \`--depends-on\` to order dependent work.
|
|
112
|
-
`;
|
|
197
|
+
`;
|
|
198
|
+
|
|
199
|
+
export { DEFAULT_PROMPT_TEMPLATE, LiquidTemplateEngine, buildPromptContext };
|