reevesagents 1.2.0 → 1.3.1
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/AGENTS.md +183 -0
- package/CHANGELOG.md +61 -0
- package/README.md +292 -171
- package/dist/{chunk-4Q3JF22J.js → chunk-2LC6V55H.js} +2 -2
- package/dist/chunk-4W6MVOPK.js +29 -0
- package/dist/{chunk-MVMGFG4W.js → chunk-65LHCGPC.js} +836 -263
- package/dist/chunk-D24DQQ6V.js +0 -0
- package/dist/chunk-HS6TOISU.js +30 -0
- package/dist/chunk-YMUISYYB.js +5426 -0
- package/dist/chunk-Z2JHNE7V.js +317 -0
- package/dist/cli.d.ts +4 -1
- package/dist/cli.js +442 -49
- package/dist/extras-25AF6TAR.js +0 -0
- package/dist/index.d.ts +13 -37
- package/dist/index.js +13 -19
- package/dist/open-browser-DRSIJQ37.js +0 -0
- package/dist/{router-WCFLHJV7.js → router-TGRU5BFX.js} +1543 -797
- package/dist/{server-Z2YTGWSX.js → server-GYB53IBP.js} +267 -136
- package/dist/server-H2XEJQYT.js +622 -0
- package/dist/{tui-launch-7RGFE5KY.js → tui-launch-45ERRX5M.js} +2 -2
- package/dist/web/app.css +371 -26
- package/dist/web/app.js +717 -51
- package/dist/web/index.html +115 -10
- package/package.json +25 -18
- package/dist/chunk-3IXII4H5.js +0 -129
- package/dist/chunk-DHAW6OY3.js +0 -40
- package/dist/chunk-G6FN75ZW.js +0 -2393
- package/dist/chunk-JY4ZTTRK.js +0 -172
- package/dist/chunk-LUW6GCPO.js +0 -108
|
@@ -1,47 +1,66 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
WEB_EXTRA_MODULES
|
|
4
|
+
} from "./chunk-D24DQQ6V.js";
|
|
2
5
|
|
|
3
|
-
// src/
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
claude
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"kimi
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"deepseek-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
6
|
+
// src/core/model-data.ts
|
|
7
|
+
var CC_MODEL_SOURCE = "curated Claude Code aliases";
|
|
8
|
+
var CC_MODELS = [
|
|
9
|
+
"sonnet",
|
|
10
|
+
"opus",
|
|
11
|
+
"haiku"
|
|
12
|
+
];
|
|
13
|
+
var CODEX_MODEL_SOURCE = "curated Codex CLI model ids";
|
|
14
|
+
var CODEX_MODELS = [
|
|
15
|
+
"gpt-5-codex",
|
|
16
|
+
"gpt-5"
|
|
17
|
+
];
|
|
18
|
+
var OPENCODE_MODEL_SOURCE = "curated OpenCode provider/model ids";
|
|
19
|
+
var OPENCODE_MODELS = [
|
|
20
|
+
"anthropic/claude-sonnet-4-5",
|
|
21
|
+
"anthropic/claude-opus-4-1",
|
|
22
|
+
"anthropic/claude-haiku-4-5",
|
|
23
|
+
"openai/gpt-5-codex",
|
|
24
|
+
"openai/gpt-5"
|
|
25
|
+
];
|
|
26
|
+
var HERMES_MODEL_SOURCE = "curated Hermes model ids";
|
|
27
|
+
var HERMES_MODELS = [
|
|
28
|
+
"anthropic/claude-sonnet-4",
|
|
29
|
+
"anthropic/claude-opus-4",
|
|
30
|
+
"anthropic/claude-haiku-4-5",
|
|
31
|
+
"openai/gpt-5"
|
|
32
|
+
];
|
|
33
|
+
var KIMI_MODEL_SOURCE = "curated Kimi Code model aliases";
|
|
34
|
+
var KIMI_MODELS = [
|
|
35
|
+
"kimi-code/kimi-for-coding"
|
|
36
|
+
];
|
|
37
|
+
var DEEPSEEK_MODEL_SOURCE = "curated DeepSeek CLI model ids";
|
|
38
|
+
var DEEPSEEK_MODELS = [
|
|
39
|
+
"deepseek-coder:6.7b",
|
|
40
|
+
"deepseek-coder:1.3b",
|
|
41
|
+
"deepseek-coder:33b"
|
|
42
|
+
];
|
|
43
|
+
var PI_MODEL_SOURCE = "curated Pi model aliases";
|
|
44
|
+
var PI_MODELS = [
|
|
45
|
+
"sonnet",
|
|
46
|
+
"opus",
|
|
47
|
+
"deepseek/deepseek-chat",
|
|
48
|
+
"openai/gpt-4o"
|
|
49
|
+
];
|
|
50
|
+
var QWEN_MODEL_SOURCE = "curated Qwen Code model ids";
|
|
51
|
+
var QWEN_MODELS = [
|
|
52
|
+
"qwen3-coder-plus",
|
|
53
|
+
"qwen3-coder-flash"
|
|
54
|
+
];
|
|
55
|
+
var AIDER_MODEL_SOURCE = "curated Aider model aliases";
|
|
56
|
+
var AIDER_MODELS = [
|
|
57
|
+
"sonnet",
|
|
58
|
+
"opus",
|
|
59
|
+
"haiku",
|
|
60
|
+
"deepseek/deepseek-chat"
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
// src/core/provider-registry.ts
|
|
45
64
|
var HERMES_PROVIDER_PREFIXES = /* @__PURE__ */ new Set([
|
|
46
65
|
"auto",
|
|
47
66
|
"openrouter",
|
|
@@ -79,42 +98,211 @@ var HERMES_PROVIDER_PREFIXES = /* @__PURE__ */ new Set([
|
|
|
79
98
|
"tencent-tokenhub",
|
|
80
99
|
"custom"
|
|
81
100
|
]);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
101
|
+
function parseHermesModel(value) {
|
|
102
|
+
const separator = value.indexOf(":");
|
|
103
|
+
if (separator <= 0) return { model: value };
|
|
104
|
+
const provider = value.slice(0, separator).trim();
|
|
105
|
+
const model = value.slice(separator + 1).trim();
|
|
106
|
+
if (!provider || !model || !HERMES_PROVIDER_PREFIXES.has(provider)) return { model: value };
|
|
107
|
+
return { provider, model };
|
|
108
|
+
}
|
|
109
|
+
var PROVIDER_REGISTRY = {
|
|
110
|
+
cc: {
|
|
111
|
+
id: "cc",
|
|
112
|
+
bin: "claude",
|
|
113
|
+
displayName: "Claude Code",
|
|
114
|
+
color: "#d97757",
|
|
115
|
+
// Anthropic Orange (Claude brand); the one warm color in the palette
|
|
116
|
+
aliases: ["cc", "claude", "claude code", "claude-code", "claudecode"],
|
|
117
|
+
models: CC_MODELS,
|
|
118
|
+
modelSource: CC_MODEL_SOURCE,
|
|
119
|
+
helpRequirements: [
|
|
120
|
+
{ feature: "skip permissions", tokens: ["--dangerously-skip-permissions"] }
|
|
121
|
+
],
|
|
122
|
+
buildArgs: ({ permissions, model, auth_mode, effort }) => {
|
|
123
|
+
const args = [];
|
|
124
|
+
if (permissions === "skip") args.push("--dangerously-skip-permissions");
|
|
125
|
+
if (auth_mode === "api-key") args.push("--bare");
|
|
126
|
+
if (effort !== "default") args.push("--effort", effort);
|
|
127
|
+
if (model) args.push("--model", model);
|
|
128
|
+
return args;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
codex: {
|
|
132
|
+
id: "codex",
|
|
133
|
+
bin: "codex",
|
|
134
|
+
displayName: "Codex CLI",
|
|
135
|
+
color: "#7aa8c4",
|
|
136
|
+
// cool teal-blue
|
|
137
|
+
aliases: ["codex", "codex cli", "codex-cli"],
|
|
138
|
+
models: CODEX_MODELS,
|
|
139
|
+
modelSource: CODEX_MODEL_SOURCE,
|
|
140
|
+
helpRequirements: [
|
|
141
|
+
{ feature: "skip permissions", tokens: ["--dangerously-bypass-approvals-and-sandbox"] }
|
|
142
|
+
],
|
|
143
|
+
buildArgs: ({ permissions, model }) => {
|
|
144
|
+
const args = [];
|
|
145
|
+
if (permissions === "skip") args.push("--dangerously-bypass-approvals-and-sandbox");
|
|
146
|
+
if (model) args.push("--model", model);
|
|
147
|
+
return args;
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
opencode: {
|
|
151
|
+
id: "opencode",
|
|
152
|
+
bin: "opencode",
|
|
153
|
+
displayName: "OpenCode CLI",
|
|
154
|
+
color: "#a890d1",
|
|
155
|
+
// muted purple
|
|
156
|
+
aliases: ["opencode", "opencode cli", "opencode-cli", "open_code"],
|
|
157
|
+
models: OPENCODE_MODELS,
|
|
158
|
+
modelSource: OPENCODE_MODEL_SOURCE,
|
|
159
|
+
helpRequirements: [
|
|
160
|
+
{ feature: "prompt launch", tokens: ["--prompt"] },
|
|
161
|
+
{ feature: "model selection", tokens: ["--model"] }
|
|
162
|
+
],
|
|
163
|
+
buildArgs: ({ model }) => {
|
|
164
|
+
const args = [];
|
|
165
|
+
if (model) args.push("--model", model);
|
|
166
|
+
return args;
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
hermes: {
|
|
170
|
+
id: "hermes",
|
|
171
|
+
bin: "hermes",
|
|
172
|
+
displayName: "Hermes",
|
|
173
|
+
color: "#c97b9b",
|
|
174
|
+
// muted rose
|
|
175
|
+
aliases: ["hermes"],
|
|
176
|
+
models: HERMES_MODELS,
|
|
177
|
+
modelSource: HERMES_MODEL_SOURCE,
|
|
178
|
+
helpRequirements: [
|
|
179
|
+
{ feature: "chat launch", tokens: ["--model"] },
|
|
180
|
+
{ feature: "skip permissions", tokens: ["--yolo"] }
|
|
181
|
+
],
|
|
182
|
+
helpArgs: ["chat", "--help"],
|
|
183
|
+
buildArgs: ({ permissions, model }) => {
|
|
184
|
+
const args = ["chat"];
|
|
185
|
+
if (permissions === "skip") args.push("--yolo");
|
|
186
|
+
if (model) {
|
|
187
|
+
const parsed = parseHermesModel(model);
|
|
188
|
+
if (parsed.provider) args.push("--provider", parsed.provider);
|
|
189
|
+
args.push("--model", parsed.model);
|
|
190
|
+
}
|
|
191
|
+
return args;
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
kimi: {
|
|
195
|
+
id: "kimi",
|
|
196
|
+
bin: "kimi",
|
|
197
|
+
displayName: "Kimi Code",
|
|
198
|
+
color: "#b6a45d",
|
|
199
|
+
// muted gold
|
|
200
|
+
aliases: ["kimi", "kimi code", "kimi-code"],
|
|
201
|
+
models: KIMI_MODELS,
|
|
202
|
+
modelSource: KIMI_MODEL_SOURCE,
|
|
203
|
+
helpRequirements: [
|
|
204
|
+
{ feature: "model selection", tokens: ["--model"] },
|
|
205
|
+
{ feature: "skip permissions", tokens: ["--yolo"] }
|
|
206
|
+
],
|
|
207
|
+
buildArgs: ({ permissions, model }) => {
|
|
208
|
+
const args = [];
|
|
209
|
+
if (permissions === "skip") args.push("--yolo");
|
|
210
|
+
if (model) args.push("--model", model);
|
|
211
|
+
return args;
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
deepseek: {
|
|
215
|
+
id: "deepseek",
|
|
216
|
+
bin: "deepseek",
|
|
217
|
+
displayName: "DeepSeek CLI",
|
|
218
|
+
color: "#6fb0a8",
|
|
219
|
+
// muted cyan
|
|
220
|
+
aliases: ["deepseek", "deepseek cli", "deepseek-cli"],
|
|
221
|
+
models: DEEPSEEK_MODELS,
|
|
222
|
+
modelSource: DEEPSEEK_MODEL_SOURCE,
|
|
223
|
+
helpRequirements: [
|
|
224
|
+
{ feature: "model selection", tokens: ["--model"] }
|
|
225
|
+
],
|
|
226
|
+
buildArgs: ({ model }) => {
|
|
227
|
+
const args = [];
|
|
228
|
+
if (model) args.push("--model", model);
|
|
229
|
+
return args;
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
pi: {
|
|
233
|
+
id: "pi",
|
|
234
|
+
bin: "pi",
|
|
235
|
+
displayName: "Pi",
|
|
236
|
+
color: "#86a76b",
|
|
237
|
+
// muted olive
|
|
238
|
+
aliases: ["pi"],
|
|
239
|
+
models: PI_MODELS,
|
|
240
|
+
modelSource: PI_MODEL_SOURCE,
|
|
241
|
+
helpRequirements: [
|
|
242
|
+
{ feature: "model selection", tokens: ["--model"] }
|
|
243
|
+
],
|
|
244
|
+
buildArgs: ({ model }) => {
|
|
245
|
+
const args = [];
|
|
246
|
+
if (model) args.push("--model", model);
|
|
247
|
+
return args;
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
qwen: {
|
|
251
|
+
id: "qwen",
|
|
252
|
+
bin: "qwen",
|
|
253
|
+
displayName: "Qwen Code",
|
|
254
|
+
color: "#c58c63",
|
|
255
|
+
// muted copper
|
|
256
|
+
aliases: ["qwen", "qwen code", "qwen-code"],
|
|
257
|
+
models: QWEN_MODELS,
|
|
258
|
+
modelSource: QWEN_MODEL_SOURCE,
|
|
259
|
+
helpRequirements: [
|
|
260
|
+
{ feature: "model selection", tokens: ["--model"] },
|
|
261
|
+
{ feature: "skip permissions", tokens: ["--approval-mode"] }
|
|
262
|
+
],
|
|
263
|
+
buildArgs: ({ permissions, model }) => {
|
|
264
|
+
const args = [];
|
|
265
|
+
if (permissions === "skip") args.push("--approval-mode", "yolo");
|
|
266
|
+
if (model) args.push("--model", model);
|
|
267
|
+
return args;
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
aider: {
|
|
271
|
+
id: "aider",
|
|
272
|
+
bin: "aider",
|
|
273
|
+
displayName: "Aider",
|
|
274
|
+
color: "#8fa6d4",
|
|
275
|
+
// muted periwinkle
|
|
276
|
+
aliases: ["aider"],
|
|
277
|
+
models: AIDER_MODELS,
|
|
278
|
+
modelSource: AIDER_MODEL_SOURCE,
|
|
279
|
+
helpRequirements: [
|
|
280
|
+
{ feature: "model selection", tokens: ["--model"] },
|
|
281
|
+
{ feature: "skip confirmations", tokens: ["--yes-always"] }
|
|
282
|
+
],
|
|
283
|
+
buildArgs: ({ permissions, model }) => {
|
|
284
|
+
const args = [];
|
|
285
|
+
if (permissions === "skip") args.push("--yes-always");
|
|
286
|
+
if (model) args.push("--model", model);
|
|
287
|
+
return args;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
115
290
|
};
|
|
291
|
+
var PROVIDER_DEFS = Object.values(PROVIDER_REGISTRY);
|
|
292
|
+
|
|
293
|
+
// src/core/providers.ts
|
|
294
|
+
import { execFileSync, spawnSync } from "child_process";
|
|
295
|
+
var BIN = Object.fromEntries(
|
|
296
|
+
PROVIDER_DEFS.map((def) => [def.id, def.bin])
|
|
297
|
+
);
|
|
298
|
+
var PROVIDERS = Object.keys(PROVIDER_REGISTRY);
|
|
299
|
+
var PROVIDER_ALIASES = Object.fromEntries(
|
|
300
|
+
PROVIDER_DEFS.flatMap((def) => def.aliases.map((alias) => [alias, def.id]))
|
|
301
|
+
);
|
|
302
|
+
var HELP_INSPECT_TIMEOUT_MS = 3e3;
|
|
303
|
+
var HELP_INSPECT_TOTAL_BUDGET_MS = 8e3;
|
|
116
304
|
function isProvider(value) {
|
|
117
|
-
return typeof value === "string" && Object.prototype.hasOwnProperty.call(
|
|
305
|
+
return typeof value === "string" && Object.prototype.hasOwnProperty.call(PROVIDER_REGISTRY, value);
|
|
118
306
|
}
|
|
119
307
|
function normalizeProvider(value) {
|
|
120
308
|
if (typeof value !== "string") return null;
|
|
@@ -125,65 +313,8 @@ function buildCommand(opts) {
|
|
|
125
313
|
if (!isProvider(provider)) {
|
|
126
314
|
throw new Error(`Unsupported provider: ${String(provider)}`);
|
|
127
315
|
}
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
if (permissions === "skip") cmd.push("--dangerously-skip-permissions");
|
|
131
|
-
if (auth_mode === "api-key") cmd.push("--bare");
|
|
132
|
-
if (effort !== "default") cmd.push("--effort", effort);
|
|
133
|
-
if (model) cmd.push("--model", model);
|
|
134
|
-
return cmd;
|
|
135
|
-
}
|
|
136
|
-
if (provider === "codex") {
|
|
137
|
-
if (permissions === "skip") cmd.push("--dangerously-bypass-approvals-and-sandbox");
|
|
138
|
-
if (model) cmd.push("--model", model);
|
|
139
|
-
return cmd;
|
|
140
|
-
}
|
|
141
|
-
if (provider === "opencode") {
|
|
142
|
-
if (model) cmd.push("--model", model);
|
|
143
|
-
return cmd;
|
|
144
|
-
}
|
|
145
|
-
if (provider === "hermes") {
|
|
146
|
-
cmd.push("chat");
|
|
147
|
-
if (permissions === "skip") cmd.push("--yolo");
|
|
148
|
-
if (model) {
|
|
149
|
-
const parsed = parseHermesModel(model);
|
|
150
|
-
if (parsed.provider) cmd.push("--provider", parsed.provider);
|
|
151
|
-
cmd.push("--model", parsed.model);
|
|
152
|
-
}
|
|
153
|
-
return cmd;
|
|
154
|
-
}
|
|
155
|
-
if (provider === "kimi") {
|
|
156
|
-
if (permissions === "skip") cmd.push("--yolo");
|
|
157
|
-
if (model) cmd.push("--model", model);
|
|
158
|
-
return cmd;
|
|
159
|
-
}
|
|
160
|
-
if (provider === "deepseek") {
|
|
161
|
-
if (model) cmd.push("--model", model);
|
|
162
|
-
return cmd;
|
|
163
|
-
}
|
|
164
|
-
if (provider === "pi") {
|
|
165
|
-
if (model) cmd.push("--model", model);
|
|
166
|
-
return cmd;
|
|
167
|
-
}
|
|
168
|
-
if (provider === "qwen") {
|
|
169
|
-
if (permissions === "skip") cmd.push("--approval-mode", "yolo");
|
|
170
|
-
if (model) cmd.push("--model", model);
|
|
171
|
-
return cmd;
|
|
172
|
-
}
|
|
173
|
-
if (provider === "aider") {
|
|
174
|
-
if (permissions === "skip") cmd.push("--yes-always");
|
|
175
|
-
if (model) cmd.push("--model", model);
|
|
176
|
-
return cmd;
|
|
177
|
-
}
|
|
178
|
-
return cmd;
|
|
179
|
-
}
|
|
180
|
-
function parseHermesModel(value) {
|
|
181
|
-
const separator = value.indexOf(":");
|
|
182
|
-
if (separator <= 0) return { model: value };
|
|
183
|
-
const provider = value.slice(0, separator).trim();
|
|
184
|
-
const model = value.slice(separator + 1).trim();
|
|
185
|
-
if (!provider || !model || !HERMES_PROVIDER_PREFIXES.has(provider)) return { model: value };
|
|
186
|
-
return { provider, model };
|
|
316
|
+
const def = PROVIDER_REGISTRY[provider];
|
|
317
|
+
return [def.bin, ...def.buildArgs({ permissions, model, auth_mode, effort })];
|
|
187
318
|
}
|
|
188
319
|
function detectAvailable() {
|
|
189
320
|
const result = {};
|
|
@@ -198,11 +329,11 @@ function detectAvailable() {
|
|
|
198
329
|
return result;
|
|
199
330
|
}
|
|
200
331
|
function helpCommand(provider) {
|
|
201
|
-
|
|
202
|
-
return [
|
|
332
|
+
const def = PROVIDER_REGISTRY[provider];
|
|
333
|
+
return [def.bin, ...def.helpArgs ?? ["--help"]];
|
|
203
334
|
}
|
|
204
335
|
function missingHelpFeatures(provider, helpText) {
|
|
205
|
-
return
|
|
336
|
+
return PROVIDER_REGISTRY[provider].helpRequirements.filter((req) => req.tokens.some((token) => !helpText.includes(token))).map((req) => req.feature);
|
|
206
337
|
}
|
|
207
338
|
function inspectProviderCompatibility() {
|
|
208
339
|
const available = detectAvailable();
|
|
@@ -264,9 +395,6 @@ ${inspected.stderr ?? ""}`;
|
|
|
264
395
|
return result;
|
|
265
396
|
}
|
|
266
397
|
|
|
267
|
-
// src/utils/display.ts
|
|
268
|
-
import chalk from "chalk";
|
|
269
|
-
|
|
270
398
|
// src/utils/tokens.ts
|
|
271
399
|
var colors = {
|
|
272
400
|
text: {
|
|
@@ -319,28 +447,10 @@ var colors = {
|
|
|
319
447
|
gradient: ["#a5cdf7", "#7eb8f5", "#5a96e0", "#3a7ad8", "#2457a7"]
|
|
320
448
|
// breath cycle
|
|
321
449
|
},
|
|
322
|
-
// Provider colors
|
|
450
|
+
// Provider brand colors live with each provider in the registry
|
|
451
|
+
// (launcher/provider-registry.ts); read them through providerColor() in
|
|
452
|
+
// utils/display.ts. They are kept distinct from accent.bright so a focused
|
|
323
453
|
// provider row does not collide visually with the selection cursor.
|
|
324
|
-
provider: {
|
|
325
|
-
cc: "#d97757",
|
|
326
|
-
// Anthropic Orange (Claude brand); the one warm color
|
|
327
|
-
codex: "#7aa8c4",
|
|
328
|
-
// cool teal-blue
|
|
329
|
-
opencode: "#a890d1",
|
|
330
|
-
// muted purple
|
|
331
|
-
hermes: "#c97b9b",
|
|
332
|
-
// muted rose
|
|
333
|
-
kimi: "#b6a45d",
|
|
334
|
-
// muted gold
|
|
335
|
-
deepseek: "#6fb0a8",
|
|
336
|
-
// muted cyan
|
|
337
|
-
pi: "#86a76b",
|
|
338
|
-
// muted olive
|
|
339
|
-
qwen: "#c58c63",
|
|
340
|
-
// muted copper
|
|
341
|
-
aider: "#8fa6d4"
|
|
342
|
-
// muted periwinkle
|
|
343
|
-
},
|
|
344
454
|
model: {
|
|
345
455
|
default: "#9b9488",
|
|
346
456
|
// CLI default or unset model
|
|
@@ -373,22 +483,14 @@ var space = {
|
|
|
373
483
|
};
|
|
374
484
|
|
|
375
485
|
// src/utils/display.ts
|
|
376
|
-
var PROVIDER_DISPLAY_NAMES =
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
opencode: "OpenCode CLI",
|
|
380
|
-
hermes: "Hermes",
|
|
381
|
-
kimi: "Kimi Code",
|
|
382
|
-
deepseek: "DeepSeek CLI",
|
|
383
|
-
pi: "Pi",
|
|
384
|
-
qwen: "Qwen Code",
|
|
385
|
-
aider: "Aider"
|
|
386
|
-
};
|
|
486
|
+
var PROVIDER_DISPLAY_NAMES = Object.fromEntries(
|
|
487
|
+
PROVIDER_DEFS.map((def) => [def.id, def.displayName])
|
|
488
|
+
);
|
|
387
489
|
function providerDisplayName(provider) {
|
|
388
490
|
return PROVIDER_DISPLAY_NAMES[provider] ?? provider;
|
|
389
491
|
}
|
|
390
492
|
function providerColor(p) {
|
|
391
|
-
return
|
|
493
|
+
return PROVIDER_REGISTRY[p]?.color ?? "gray";
|
|
392
494
|
}
|
|
393
495
|
function modelColor(model, provider) {
|
|
394
496
|
const lower = model.trim().toLowerCase();
|
|
@@ -429,7 +531,7 @@ function redactSecrets(text) {
|
|
|
429
531
|
return result;
|
|
430
532
|
}
|
|
431
533
|
|
|
432
|
-
// src/
|
|
534
|
+
// src/core/runs.ts
|
|
433
535
|
import {
|
|
434
536
|
chmodSync,
|
|
435
537
|
closeSync,
|
|
@@ -528,10 +630,6 @@ function normalizeTaskStatus(value) {
|
|
|
528
630
|
function normalizePermissions(value) {
|
|
529
631
|
return value === "skip" ? "skip" : "ask";
|
|
530
632
|
}
|
|
531
|
-
function normalizeRunMode(value) {
|
|
532
|
-
if (value === "spawner" || value === "orchestrator") return value;
|
|
533
|
-
return void 0;
|
|
534
|
-
}
|
|
535
633
|
function asString(value, fallback = "") {
|
|
536
634
|
return typeof value === "string" ? value : fallback;
|
|
537
635
|
}
|
|
@@ -566,8 +664,6 @@ function normalizeRun(raw) {
|
|
|
566
664
|
started_at: asString(raw.started_at, nowIso()),
|
|
567
665
|
ended_at: asNullableString(raw.ended_at)
|
|
568
666
|
};
|
|
569
|
-
const mode = normalizeRunMode(raw.mode);
|
|
570
|
-
if (mode) run.mode = mode;
|
|
571
667
|
const reevesSession = asString(raw.reeves_session);
|
|
572
668
|
if (reevesSession) run.reeves_session = reevesSession;
|
|
573
669
|
return run;
|
|
@@ -576,7 +672,6 @@ function normalizeRunHistory(raw) {
|
|
|
576
672
|
return {
|
|
577
673
|
id: asString(raw.id),
|
|
578
674
|
name: asString(raw.name).trim() || fallbackRunName(asString(raw.id)),
|
|
579
|
-
mode: normalizeRunMode(raw.mode) ?? "spawner",
|
|
580
675
|
status: raw.status === "stale" ? "stale" : "ended",
|
|
581
676
|
working_dir: asString(raw.working_dir),
|
|
582
677
|
started_at: asString(raw.started_at, nowIso()),
|
|
@@ -650,11 +745,6 @@ function writeRun(run) {
|
|
|
650
745
|
return withRunsLock(() => writeRunUnlocked(run));
|
|
651
746
|
}
|
|
652
747
|
function readRun(runId) {
|
|
653
|
-
const run = readRunUnlocked(runId);
|
|
654
|
-
if (run.mode !== "spawner") throw new Error(`Run not found: ${runId}`);
|
|
655
|
-
return run;
|
|
656
|
-
}
|
|
657
|
-
function readRunAny(runId) {
|
|
658
748
|
return readRunUnlocked(runId);
|
|
659
749
|
}
|
|
660
750
|
function updateRun(runId, patch) {
|
|
@@ -665,7 +755,7 @@ function updateRun(runId, patch) {
|
|
|
665
755
|
function isRunEnded(run) {
|
|
666
756
|
return run.status === "ended" || run.ended_at !== null;
|
|
667
757
|
}
|
|
668
|
-
function listRunsUnlocked(
|
|
758
|
+
function listRunsUnlocked(includeEnded = false) {
|
|
669
759
|
let entries;
|
|
670
760
|
try {
|
|
671
761
|
entries = readdirSync(runsDir());
|
|
@@ -678,13 +768,13 @@ function listRunsUnlocked(includeAllModes, includeEnded = false) {
|
|
|
678
768
|
try {
|
|
679
769
|
const run = readRunUnlocked(entry);
|
|
680
770
|
if (!includeEnded && isRunEnded(run)) continue;
|
|
681
|
-
|
|
771
|
+
runs.push(run);
|
|
682
772
|
} catch {
|
|
683
773
|
}
|
|
684
774
|
}
|
|
685
775
|
return runs.sort((a, b) => new Date(b.started_at).getTime() - new Date(a.started_at).getTime());
|
|
686
776
|
}
|
|
687
|
-
function listRunHistoryUnlocked(
|
|
777
|
+
function listRunHistoryUnlocked() {
|
|
688
778
|
let entries;
|
|
689
779
|
try {
|
|
690
780
|
entries = readdirSync(historyDir());
|
|
@@ -695,30 +785,26 @@ function listRunHistoryUnlocked(includeAllModes) {
|
|
|
695
785
|
for (const entry of entries) {
|
|
696
786
|
if (!entry.endsWith(".json")) continue;
|
|
697
787
|
try {
|
|
698
|
-
|
|
699
|
-
if (includeAllModes || record.mode === "spawner") history.push(record);
|
|
788
|
+
history.push(normalizeRunHistory(JSON.parse(readFileSync(join(historyDir(), entry), "utf-8"))));
|
|
700
789
|
} catch {
|
|
701
790
|
}
|
|
702
791
|
}
|
|
703
792
|
return history.sort((a, b) => new Date(b.archived_at).getTime() - new Date(a.archived_at).getTime());
|
|
704
793
|
}
|
|
705
794
|
function listRuns() {
|
|
706
|
-
return listRunsUnlocked(
|
|
795
|
+
return listRunsUnlocked();
|
|
707
796
|
}
|
|
708
|
-
function
|
|
709
|
-
return
|
|
710
|
-
}
|
|
711
|
-
function listRunHistory(options = {}) {
|
|
712
|
-
return listRunHistoryUnlocked(options.includeAllModes === true);
|
|
797
|
+
function listRunHistory() {
|
|
798
|
+
return listRunHistoryUnlocked();
|
|
713
799
|
}
|
|
714
800
|
function removeRun(runId) {
|
|
715
801
|
withRunsLock(() => {
|
|
716
802
|
rmSync(runDir(runId), { recursive: true, force: true });
|
|
717
803
|
});
|
|
718
804
|
}
|
|
719
|
-
function deleteAgent(agentId
|
|
805
|
+
function deleteAgent(agentId) {
|
|
720
806
|
return withRunsLock(() => {
|
|
721
|
-
const runs = listRunsUnlocked(
|
|
807
|
+
const runs = listRunsUnlocked();
|
|
722
808
|
for (const run of runs) {
|
|
723
809
|
try {
|
|
724
810
|
const agent = readAgentUnlocked(run.id, agentId);
|
|
@@ -781,7 +867,6 @@ function buildRunHistoryRecord(run, status) {
|
|
|
781
867
|
return {
|
|
782
868
|
id: run.id,
|
|
783
869
|
name: run.name,
|
|
784
|
-
mode: run.mode === "orchestrator" ? "orchestrator" : "spawner",
|
|
785
870
|
status,
|
|
786
871
|
working_dir: run.working_dir,
|
|
787
872
|
started_at: run.started_at,
|
|
@@ -804,7 +889,7 @@ function endRunIfNoLiveAgents(runId, endedAt = nowIso()) {
|
|
|
804
889
|
return withRunsLock(() => {
|
|
805
890
|
const run = readRunUnlocked(runId);
|
|
806
891
|
if (run.status === "ended" || run.ended_at !== null) return run;
|
|
807
|
-
const liveAgents = listAgentsForRunIds([runId]).filter((agent) => !agent.ended_at);
|
|
892
|
+
const liveAgents = listAgentsForRunIds([runId]).filter((agent) => !agent.ended_at && !agent.headless);
|
|
808
893
|
if (liveAgents.length > 0) return run;
|
|
809
894
|
const endedRun = { ...run, status: "ended", ended_at: endedAt };
|
|
810
895
|
writeRunUnlocked(endedRun);
|
|
@@ -814,9 +899,6 @@ function endRunIfNoLiveAgents(runId, endedAt = nowIso()) {
|
|
|
814
899
|
function listAgents(runId) {
|
|
815
900
|
return listAgentsForRunIds(runId ? [runId] : listRuns().map((run) => run.id));
|
|
816
901
|
}
|
|
817
|
-
function listAgentsAny(runId) {
|
|
818
|
-
return listAgentsForRunIds(runId ? [runId] : listRunsAny().map((run) => run.id));
|
|
819
|
-
}
|
|
820
902
|
function findAgent(agentId) {
|
|
821
903
|
for (const run of listRuns()) {
|
|
822
904
|
try {
|
|
@@ -826,15 +908,6 @@ function findAgent(agentId) {
|
|
|
826
908
|
}
|
|
827
909
|
throw new Error(`Agent not found: ${agentId}`);
|
|
828
910
|
}
|
|
829
|
-
function findAgentAny(agentId) {
|
|
830
|
-
for (const run of listRunsAny()) {
|
|
831
|
-
try {
|
|
832
|
-
return readAgentUnlocked(run.id, agentId);
|
|
833
|
-
} catch {
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
837
|
-
}
|
|
838
911
|
function defaultTmuxSessionExists(session) {
|
|
839
912
|
if (!session) return false;
|
|
840
913
|
try {
|
|
@@ -866,17 +939,8 @@ function runHasLiveTmuxTarget(run, options = {}) {
|
|
|
866
939
|
const targetExists = options.targetExists ?? defaultTmuxTargetExists;
|
|
867
940
|
const sessionExists = options.sessionExists ?? defaultTmuxSessionExists;
|
|
868
941
|
const agents = listAgents(run.id).filter((agent) => !agent.ended_at);
|
|
869
|
-
if (run.mode === "spawner") {
|
|
870
|
-
const windowedAgents2 = agents.filter((agent) => !agent.headless && agent.tmux_window_id);
|
|
871
|
-
if (windowedAgents2.length > 0) return windowedAgents2.some((agent) => targetExists(agent.tmux_window_id));
|
|
872
|
-
return sessionExists(run.tmux_session);
|
|
873
|
-
}
|
|
874
|
-
const rootAgent = agents.find((agent) => agent.role === "root" && (!run.root_agent_id || agent.id === run.root_agent_id));
|
|
875
|
-
if (!rootAgent) return false;
|
|
876
942
|
const windowedAgents = agents.filter((agent) => !agent.headless && agent.tmux_window_id);
|
|
877
|
-
if (windowedAgents.length > 0)
|
|
878
|
-
return windowedAgents.some((agent) => targetExists(agent.tmux_window_id));
|
|
879
|
-
}
|
|
943
|
+
if (windowedAgents.length > 0) return windowedAgents.some((agent) => targetExists(agent.tmux_window_id));
|
|
880
944
|
return sessionExists(run.tmux_session);
|
|
881
945
|
}
|
|
882
946
|
function autoCleanupRuns(options = {}) {
|
|
@@ -886,7 +950,7 @@ function autoCleanupRuns(options = {}) {
|
|
|
886
950
|
const haveTmux = options.cleanStale === false ? false : tmuxAvailable();
|
|
887
951
|
const removed = [];
|
|
888
952
|
const archived = [];
|
|
889
|
-
const runs = listRunsUnlocked(
|
|
953
|
+
const runs = listRunsUnlocked(true);
|
|
890
954
|
for (const run of runs) {
|
|
891
955
|
const isEnded = isRunEnded(run);
|
|
892
956
|
const isStale = !isEnded && haveTmux && !runHasLiveTmuxTarget(run, { sessionExists, targetExists });
|
|
@@ -901,8 +965,163 @@ function autoCleanupRuns(options = {}) {
|
|
|
901
965
|
return { removed, archived };
|
|
902
966
|
}
|
|
903
967
|
|
|
968
|
+
// src/core/doctor.ts
|
|
969
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
970
|
+
import { accessSync, constants, existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
971
|
+
import { createRequire } from "module";
|
|
972
|
+
import { join as join2 } from "path";
|
|
973
|
+
var MIN_NODE_VERSION = [20, 19, 0];
|
|
974
|
+
function parseNodeVersion(version) {
|
|
975
|
+
const clean = version.startsWith("v") ? version.slice(1) : version;
|
|
976
|
+
const [major = "0", minor = "0", patch = "0"] = clean.split(".");
|
|
977
|
+
return [parseInt(major, 10) || 0, parseInt(minor, 10) || 0, parseInt(patch, 10) || 0];
|
|
978
|
+
}
|
|
979
|
+
function nodeMeetsMinimum(version) {
|
|
980
|
+
for (let i = 0; i < MIN_NODE_VERSION.length; i++) {
|
|
981
|
+
if (version[i] > MIN_NODE_VERSION[i]) return true;
|
|
982
|
+
if (version[i] < MIN_NODE_VERSION[i]) return false;
|
|
983
|
+
}
|
|
984
|
+
return true;
|
|
985
|
+
}
|
|
986
|
+
function nodeVersionCheck(rawVersion = process.version) {
|
|
987
|
+
const version = rawVersion.startsWith("v") ? rawVersion.slice(1) : rawVersion;
|
|
988
|
+
const parsed = parseNodeVersion(version);
|
|
989
|
+
const ok = nodeMeetsMinimum(parsed);
|
|
990
|
+
return {
|
|
991
|
+
name: "node",
|
|
992
|
+
status: ok ? "ok" : "fail",
|
|
993
|
+
detail: ok ? version : `${version} (need >=20.19.0)`
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
function readProcVersion() {
|
|
997
|
+
try {
|
|
998
|
+
return readFileSync2("/proc/version", "utf-8");
|
|
999
|
+
} catch {
|
|
1000
|
+
return "";
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
function isWsl(env, procVersion) {
|
|
1004
|
+
return Boolean(
|
|
1005
|
+
env.WSL_DISTRO_NAME || env.WSL_INTEROP || /microsoft|wsl/i.test(procVersion)
|
|
1006
|
+
);
|
|
1007
|
+
}
|
|
1008
|
+
function platformSupportCheck(platform = process.platform, env = process.env, procVersion = platform === "linux" ? readProcVersion() : "") {
|
|
1009
|
+
if (platform === "darwin") return { name: "platform", status: "ok", detail: "macOS supported" };
|
|
1010
|
+
if (platform === "linux") {
|
|
1011
|
+
return {
|
|
1012
|
+
name: "platform",
|
|
1013
|
+
status: "ok",
|
|
1014
|
+
detail: isWsl(env, procVersion) ? "WSL supported" : "Linux supported"
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
if (platform === "win32") {
|
|
1018
|
+
return {
|
|
1019
|
+
name: "platform",
|
|
1020
|
+
status: "fail",
|
|
1021
|
+
detail: "native Windows unsupported; use WSL with tmux and provider CLIs installed inside WSL"
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
return {
|
|
1025
|
+
name: "platform",
|
|
1026
|
+
status: "warn",
|
|
1027
|
+
detail: `${platform} is untested; supported targets are macOS, Linux, and WSL`
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
function checkTmux() {
|
|
1031
|
+
try {
|
|
1032
|
+
const versionStr = execFileSync2("tmux", ["-V"], { encoding: "utf8" }).trim();
|
|
1033
|
+
const match = versionStr.match(/tmux (\d+)\.(\d+)/);
|
|
1034
|
+
if (!match) return { name: "tmux", status: "warn", detail: `unexpected version format: ${versionStr}` };
|
|
1035
|
+
const major = parseInt(match[1] ?? "0", 10);
|
|
1036
|
+
const minor = parseInt(match[2] ?? "0", 10);
|
|
1037
|
+
if (major < 3) return { name: "tmux", status: "warn", detail: `tmux ${major}.${minor}; upgrade to 3.0+ recommended` };
|
|
1038
|
+
return { name: "tmux", status: "ok", detail: `tmux ${major}.${minor}` };
|
|
1039
|
+
} catch {
|
|
1040
|
+
return { name: "tmux", status: "fail", detail: "not on PATH" };
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
function checkProviders() {
|
|
1044
|
+
const available = detectAvailable();
|
|
1045
|
+
const statuses = Object.entries(available).map(([name, isAvail]) => `${providerDisplayName(name)}: ${isAvail ? "ok" : "missing"}`).join("; ");
|
|
1046
|
+
const noneAvail = Object.values(available).every((value) => !value);
|
|
1047
|
+
return {
|
|
1048
|
+
name: "providers",
|
|
1049
|
+
status: noneAvail ? "fail" : "ok",
|
|
1050
|
+
detail: statuses
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
function checkProviderCompatibility() {
|
|
1054
|
+
if (process.env.REEVES_DOCTOR_SKIP_PROVIDER_COMPAT === "1") {
|
|
1055
|
+
return { name: "provider compat", status: "warn", detail: "skipped by REEVES_DOCTOR_SKIP_PROVIDER_COMPAT" };
|
|
1056
|
+
}
|
|
1057
|
+
const compatibility = inspectProviderCompatibility();
|
|
1058
|
+
const installed = Object.values(compatibility).filter((provider) => provider.available);
|
|
1059
|
+
if (installed.length === 0) return { name: "provider compat", status: "warn", detail: "no installed providers to inspect" };
|
|
1060
|
+
const problems = installed.filter((provider) => !provider.ok).map((provider) => `${providerDisplayName(provider.provider)}: ${provider.detail}`);
|
|
1061
|
+
if (problems.length === 0) {
|
|
1062
|
+
return { name: "provider compat", status: "ok", detail: `${installed.map((provider) => providerDisplayName(provider.provider)).join(", ")} compatible` };
|
|
1063
|
+
}
|
|
1064
|
+
return {
|
|
1065
|
+
name: "provider compat",
|
|
1066
|
+
status: "warn",
|
|
1067
|
+
detail: problems.slice(0, 3).join("; ") + (problems.length > 3 ? `; +${problems.length - 3} more` : "")
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
function checkPathAccess(name, path) {
|
|
1071
|
+
if (!existsSync2(path)) return { name, status: "warn", detail: `${path} (will be created on first use)` };
|
|
1072
|
+
try {
|
|
1073
|
+
accessSync(path, constants.R_OK | constants.W_OK);
|
|
1074
|
+
return { name, status: "ok", detail: path };
|
|
1075
|
+
} catch {
|
|
1076
|
+
return { name, status: "fail", detail: `${path} (not readable/writable)` };
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
function checkWebExtras() {
|
|
1080
|
+
const requireFrom = createRequire(import.meta.url);
|
|
1081
|
+
const missing = WEB_EXTRA_MODULES.filter((name) => {
|
|
1082
|
+
try {
|
|
1083
|
+
requireFrom.resolve(name);
|
|
1084
|
+
return false;
|
|
1085
|
+
} catch {
|
|
1086
|
+
return true;
|
|
1087
|
+
}
|
|
1088
|
+
});
|
|
1089
|
+
if (missing.length === 0) {
|
|
1090
|
+
return { name: "web extras", status: "ok", detail: `${WEB_EXTRA_MODULES.join(" + ")} present (web UI available)` };
|
|
1091
|
+
}
|
|
1092
|
+
return { name: "web extras", status: "warn", detail: `${missing.join(", ")} not installed; TUI unaffected, web UI disabled` };
|
|
1093
|
+
}
|
|
1094
|
+
function checkRunsState() {
|
|
1095
|
+
try {
|
|
1096
|
+
const runs = listRuns();
|
|
1097
|
+
return { name: "runs state", status: "ok", detail: `${runs.length} run${runs.length === 1 ? "" : "s"}` };
|
|
1098
|
+
} catch (err) {
|
|
1099
|
+
return {
|
|
1100
|
+
name: "runs state",
|
|
1101
|
+
status: "fail",
|
|
1102
|
+
detail: `error reading runs: ${err instanceof Error ? err.message : "unknown"}`
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
function runDoctor() {
|
|
1107
|
+
return {
|
|
1108
|
+
checks: [
|
|
1109
|
+
platformSupportCheck(),
|
|
1110
|
+
nodeVersionCheck(),
|
|
1111
|
+
checkTmux(),
|
|
1112
|
+
checkProviders(),
|
|
1113
|
+
checkProviderCompatibility(),
|
|
1114
|
+
checkPathAccess("state dir", stateRoot()),
|
|
1115
|
+
checkPathAccess("runs dir", runsDir()),
|
|
1116
|
+
checkPathAccess("presets dir", join2(stateRoot(), "presets")),
|
|
1117
|
+
checkRunsState(),
|
|
1118
|
+
checkWebExtras()
|
|
1119
|
+
]
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
|
|
904
1123
|
// src/i18n/languages.ts
|
|
905
|
-
var LANGUAGES = ["en", "de", "fr", "es", "pt", "it", "tr", "zh-Hans", "ar"];
|
|
1124
|
+
var LANGUAGES = ["en", "de", "fr", "es", "pt", "it", "tr", "ru", "zh-Hans", "ar"];
|
|
906
1125
|
var LANGUAGE_OPTIONS = [
|
|
907
1126
|
{ code: "en", flag: "\u{1F1FA}\u{1F1F8}", name: "English", nativeName: "English", dir: "ltr" },
|
|
908
1127
|
{ code: "de", flag: "\u{1F1E9}\u{1F1EA}", name: "German", nativeName: "Deutsch", dir: "ltr" },
|
|
@@ -911,6 +1130,7 @@ var LANGUAGE_OPTIONS = [
|
|
|
911
1130
|
{ code: "pt", flag: "\u{1F1F5}\u{1F1F9}", name: "Portuguese", nativeName: "Portugu\xEAs", dir: "ltr" },
|
|
912
1131
|
{ code: "it", flag: "\u{1F1EE}\u{1F1F9}", name: "Italian", nativeName: "Italiano", dir: "ltr" },
|
|
913
1132
|
{ code: "tr", flag: "\u{1F1F9}\u{1F1F7}", name: "Turkish", nativeName: "T\xFCrk\xE7e", dir: "ltr" },
|
|
1133
|
+
{ code: "ru", flag: "\u{1F1F7}\u{1F1FA}", name: "Russian", nativeName: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439", dir: "ltr" },
|
|
914
1134
|
{ code: "zh-Hans", flag: "\u{1F1E8}\u{1F1F3}", name: "Simplified Chinese", nativeName: "\u7B80\u4F53\u4E2D\u6587", dir: "ltr" },
|
|
915
1135
|
{ code: "ar", flag: "\u{1F1F8}\u{1F1E6}", name: "Arabic", nativeName: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629", dir: "rtl" }
|
|
916
1136
|
];
|
|
@@ -922,10 +1142,10 @@ function languageOption(code) {
|
|
|
922
1142
|
return LANGUAGE_OPTIONS.find((option) => option.code === code) ?? LANGUAGE_OPTIONS[0];
|
|
923
1143
|
}
|
|
924
1144
|
|
|
925
|
-
// src/
|
|
926
|
-
import { readFileSync as
|
|
1145
|
+
// src/core/config.ts
|
|
1146
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, renameSync as renameSync2 } from "fs";
|
|
927
1147
|
import { homedir as homedir2 } from "os";
|
|
928
|
-
import { join as
|
|
1148
|
+
import { join as join3, dirname as dirname2 } from "path";
|
|
929
1149
|
var SCHEMA_VERSION = 2;
|
|
930
1150
|
var DEFAULT_GLOBAL = {
|
|
931
1151
|
peek_interval_ms: 5e3,
|
|
@@ -939,11 +1159,11 @@ var DEFAULT_GLOBAL = {
|
|
|
939
1159
|
function configPath() {
|
|
940
1160
|
const base = process.env.REEVES_CONFIG;
|
|
941
1161
|
if (base) return base;
|
|
942
|
-
return
|
|
1162
|
+
return join3(homedir2(), ".reeves", "config.json");
|
|
943
1163
|
}
|
|
944
1164
|
function configExists() {
|
|
945
1165
|
try {
|
|
946
|
-
|
|
1166
|
+
readFileSync3(configPath(), "utf-8");
|
|
947
1167
|
return true;
|
|
948
1168
|
} catch {
|
|
949
1169
|
return false;
|
|
@@ -976,7 +1196,7 @@ function mergeDefaults(raw) {
|
|
|
976
1196
|
}
|
|
977
1197
|
function loadConfig() {
|
|
978
1198
|
try {
|
|
979
|
-
const content =
|
|
1199
|
+
const content = readFileSync3(configPath(), "utf-8");
|
|
980
1200
|
return mergeDefaults(JSON.parse(content));
|
|
981
1201
|
} catch {
|
|
982
1202
|
return defaultConfig();
|
|
@@ -995,36 +1215,218 @@ function saveConfig(cfg) {
|
|
|
995
1215
|
}
|
|
996
1216
|
return path;
|
|
997
1217
|
}
|
|
1218
|
+
var CONFIG_FIELDS = [
|
|
1219
|
+
{ key: "peek_interval_ms", kind: "posint", label: "peek interval (ms)" },
|
|
1220
|
+
{ key: "peek_lines", kind: "posint", label: "peek lines" },
|
|
1221
|
+
{ key: "max_depth", kind: "posint", label: "max depth" },
|
|
1222
|
+
{ key: "max_agents", kind: "posint", label: "max agents" },
|
|
1223
|
+
{ key: "ready_delay_ms", kind: "nonneg-int", label: "ready delay (ms)" },
|
|
1224
|
+
{ key: "default_permissions", kind: "permissions", label: "default permissions" },
|
|
1225
|
+
{ key: "language", kind: "language", label: "language" }
|
|
1226
|
+
];
|
|
1227
|
+
function configFieldSpec(key) {
|
|
1228
|
+
const spec = CONFIG_FIELDS.find((field) => field.key === key);
|
|
1229
|
+
if (!spec) throw new Error(`unknown config field: ${key}`);
|
|
1230
|
+
return spec;
|
|
1231
|
+
}
|
|
1232
|
+
function parseConfigValue(key, raw) {
|
|
1233
|
+
const spec = configFieldSpec(key);
|
|
1234
|
+
if (spec.kind === "posint" || spec.kind === "nonneg-int") {
|
|
1235
|
+
const n = Number(raw);
|
|
1236
|
+
if (!Number.isFinite(n)) throw new Error(`${spec.label} must be a number`);
|
|
1237
|
+
return n;
|
|
1238
|
+
}
|
|
1239
|
+
return raw;
|
|
1240
|
+
}
|
|
1241
|
+
function validateConfigField(spec, value) {
|
|
1242
|
+
switch (spec.kind) {
|
|
1243
|
+
case "posint":
|
|
1244
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) throw new Error(`${spec.label} must be a positive integer`);
|
|
1245
|
+
return value;
|
|
1246
|
+
case "nonneg-int":
|
|
1247
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) throw new Error(`${spec.label} must be zero or a positive integer`);
|
|
1248
|
+
return value;
|
|
1249
|
+
case "permissions":
|
|
1250
|
+
if (value !== "ask" && value !== "skip") throw new Error(`${spec.label} must be ask or skip`);
|
|
1251
|
+
return value;
|
|
1252
|
+
case "language":
|
|
1253
|
+
if (!isLanguageCode(value)) throw new Error(`unknown language: ${String(value)}`);
|
|
1254
|
+
return value;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
function setConfigValues(patch) {
|
|
1258
|
+
const cfg = loadConfig();
|
|
1259
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
1260
|
+
const spec = configFieldSpec(key);
|
|
1261
|
+
cfg.global[spec.key] = validateConfigField(spec, value);
|
|
1262
|
+
}
|
|
1263
|
+
saveConfig(cfg);
|
|
1264
|
+
return cfg;
|
|
1265
|
+
}
|
|
998
1266
|
|
|
999
|
-
// src/
|
|
1000
|
-
import {
|
|
1267
|
+
// src/core/store.ts
|
|
1268
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3, readdirSync as readdirSync2, unlinkSync as unlinkSync2, renameSync as renameSync3, existsSync as existsSync3, chmodSync as chmodSync2 } from "fs";
|
|
1269
|
+
import { join as join4, dirname as dirname3 } from "path";
|
|
1270
|
+
function stateDir() {
|
|
1271
|
+
return stateRoot();
|
|
1272
|
+
}
|
|
1273
|
+
function presetsDir() {
|
|
1274
|
+
return join4(stateDir(), "presets");
|
|
1275
|
+
}
|
|
1276
|
+
function atomicWrite(path, data) {
|
|
1277
|
+
mkdirSync3(dirname3(path), { recursive: true });
|
|
1278
|
+
const tmp = `${path}.tmp`;
|
|
1279
|
+
writeFileSync3(tmp, JSON.stringify(data, null, 2), "utf-8");
|
|
1280
|
+
chmodSync2(tmp, 384);
|
|
1281
|
+
try {
|
|
1282
|
+
renameSync3(tmp, path);
|
|
1283
|
+
} catch {
|
|
1284
|
+
writeFileSync3(path, JSON.stringify(data, null, 2), "utf-8");
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
function isEffort(value) {
|
|
1288
|
+
return value === "default" || value === "low" || value === "medium" || value === "high" || value === "xhigh" || value === "max";
|
|
1289
|
+
}
|
|
1290
|
+
function normalizeSlot(raw, fallbackDir = "") {
|
|
1291
|
+
const promptRaw = typeof raw.initial_prompt === "string" ? raw.initial_prompt : typeof raw.task_template === "string" ? raw.task_template : "";
|
|
1292
|
+
return {
|
|
1293
|
+
nickname_template: typeof raw.nickname_template === "string" ? raw.nickname_template : "agent",
|
|
1294
|
+
provider: isProvider(raw.provider) ? raw.provider : "cc",
|
|
1295
|
+
model: typeof raw.model === "string" ? raw.model : "",
|
|
1296
|
+
auth_mode: raw.auth_mode === "api-key" ? "api-key" : "default",
|
|
1297
|
+
effort: isEffort(raw.effort) ? raw.effort : "default",
|
|
1298
|
+
initial_prompt: promptRaw,
|
|
1299
|
+
working_dir: typeof raw.working_dir === "string" ? raw.working_dir : fallbackDir,
|
|
1300
|
+
permissions: raw.permissions === "skip" ? "skip" : "ask",
|
|
1301
|
+
rc_enabled: typeof raw.rc_enabled === "boolean" ? raw.rc_enabled : false
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
function normalizePreset(raw) {
|
|
1305
|
+
if (typeof raw !== "object" || raw === null) return null;
|
|
1306
|
+
const obj = raw;
|
|
1307
|
+
const legacyDir = typeof obj.working_dir_pattern === "string" ? obj.working_dir_pattern : "";
|
|
1308
|
+
const rootRaw = typeof obj.root === "object" && obj.root !== null ? obj.root : {};
|
|
1309
|
+
const workersRaw = Array.isArray(obj.workers) ? obj.workers : [];
|
|
1310
|
+
return {
|
|
1311
|
+
name: typeof obj.name === "string" ? obj.name : "preset",
|
|
1312
|
+
description: typeof obj.description === "string" ? obj.description : "",
|
|
1313
|
+
root: normalizeSlot(rootRaw, legacyDir),
|
|
1314
|
+
workers: workersRaw.filter((w) => typeof w === "object" && w !== null).map((w) => normalizeSlot(w, legacyDir)),
|
|
1315
|
+
working_dir_pattern: legacyDir || void 0,
|
|
1316
|
+
created_at: typeof obj.created_at === "string" ? obj.created_at : (/* @__PURE__ */ new Date()).toISOString(),
|
|
1317
|
+
updated_at: typeof obj.updated_at === "string" ? obj.updated_at : (/* @__PURE__ */ new Date()).toISOString()
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
function listPresets() {
|
|
1321
|
+
const dir = presetsDir();
|
|
1322
|
+
if (!existsSync3(dir)) return [];
|
|
1323
|
+
try {
|
|
1324
|
+
return readdirSync2(dir).filter((f) => f.endsWith(".json")).map((f) => {
|
|
1325
|
+
try {
|
|
1326
|
+
return normalizePreset(JSON.parse(readFileSync4(join4(dir, f), "utf-8")));
|
|
1327
|
+
} catch {
|
|
1328
|
+
return null;
|
|
1329
|
+
}
|
|
1330
|
+
}).filter((t) => t !== null);
|
|
1331
|
+
} catch {
|
|
1332
|
+
return [];
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
function loadPreset(name) {
|
|
1336
|
+
try {
|
|
1337
|
+
return normalizePreset(JSON.parse(readFileSync4(join4(presetsDir(), `${name}.json`), "utf-8")));
|
|
1338
|
+
} catch {
|
|
1339
|
+
return null;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
function savePreset(tree) {
|
|
1343
|
+
atomicWrite(join4(presetsDir(), `${tree.name}.json`), tree);
|
|
1344
|
+
}
|
|
1345
|
+
function deletePreset(name) {
|
|
1346
|
+
try {
|
|
1347
|
+
unlinkSync2(join4(presetsDir(), `${name}.json`));
|
|
1348
|
+
} catch {
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
function sanitizePresetName(raw) {
|
|
1352
|
+
return raw.trim().replace(/[^a-zA-Z0-9_-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 64);
|
|
1353
|
+
}
|
|
1354
|
+
function agentToSlot(agent) {
|
|
1355
|
+
return {
|
|
1356
|
+
nickname_template: agent.nickname,
|
|
1357
|
+
provider: agent.provider,
|
|
1358
|
+
model: agent.model,
|
|
1359
|
+
auth_mode: "default",
|
|
1360
|
+
effort: "default",
|
|
1361
|
+
initial_prompt: agent.task,
|
|
1362
|
+
working_dir: agent.working_dir,
|
|
1363
|
+
permissions: agent.permissions,
|
|
1364
|
+
rc_enabled: agent.rc_enabled
|
|
1365
|
+
};
|
|
1366
|
+
}
|
|
1367
|
+
function savePresetFromRun(runId, name, description = "") {
|
|
1368
|
+
const presetName = sanitizePresetName(name);
|
|
1369
|
+
if (!presetName) throw new Error("preset name is required");
|
|
1370
|
+
const run = readRun(runId);
|
|
1371
|
+
const agents = listAgents(run.id).filter((agent) => !agent.headless);
|
|
1372
|
+
if (agents.length === 0) throw new Error("run has no agents to save as a preset");
|
|
1373
|
+
const root = agents.find((agent) => agent.role === "root") ?? agents[0];
|
|
1374
|
+
const workers = agents.filter((agent) => agent !== root);
|
|
1375
|
+
const existing = loadPreset(presetName);
|
|
1376
|
+
const now = nowIso();
|
|
1377
|
+
const tree = {
|
|
1378
|
+
name: presetName,
|
|
1379
|
+
description,
|
|
1380
|
+
root: agentToSlot(root),
|
|
1381
|
+
workers: workers.map(agentToSlot),
|
|
1382
|
+
created_at: existing?.created_at ?? now,
|
|
1383
|
+
updated_at: now
|
|
1384
|
+
};
|
|
1385
|
+
savePreset(tree);
|
|
1386
|
+
return tree;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
// src/core/runtime.ts
|
|
1390
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
1001
1391
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
1002
1392
|
import stripAnsi from "strip-ansi";
|
|
1003
1393
|
|
|
1004
|
-
// src/
|
|
1005
|
-
import { existsSync as
|
|
1394
|
+
// src/core/provider-launch.ts
|
|
1395
|
+
import { existsSync as existsSync4, statSync as statSync2 } from "fs";
|
|
1006
1396
|
import { homedir as homedir3 } from "os";
|
|
1007
|
-
import { join as
|
|
1397
|
+
import { join as join5 } from "path";
|
|
1008
1398
|
function expandHome(p) {
|
|
1009
1399
|
if (p === "~") return homedir3();
|
|
1010
|
-
if (p.startsWith("~/")) return
|
|
1400
|
+
if (p.startsWith("~/")) return join5(homedir3(), p.slice(2));
|
|
1011
1401
|
return p;
|
|
1012
1402
|
}
|
|
1013
1403
|
function resolveWorkingDir(requested, fallback) {
|
|
1014
1404
|
if (!requested) return fallback;
|
|
1015
1405
|
const expanded = expandHome(requested.trim());
|
|
1016
1406
|
if (!expanded) return fallback;
|
|
1017
|
-
if (
|
|
1407
|
+
if (existsSync4(expanded) && statSync2(expanded).isDirectory()) return expanded;
|
|
1018
1408
|
throw new Error(`Working directory does not exist: ${expanded}`);
|
|
1019
1409
|
}
|
|
1020
1410
|
function shellQuote(s) {
|
|
1021
1411
|
return `'${s.replace(/'/g, "'\\''")}'`;
|
|
1022
1412
|
}
|
|
1023
1413
|
|
|
1024
|
-
// src/
|
|
1414
|
+
// src/core/runtime.ts
|
|
1415
|
+
var ALLOWED_KEYS = [
|
|
1416
|
+
"enter",
|
|
1417
|
+
"escape",
|
|
1418
|
+
"backspace",
|
|
1419
|
+
"tab",
|
|
1420
|
+
"space",
|
|
1421
|
+
"up",
|
|
1422
|
+
"down",
|
|
1423
|
+
"left",
|
|
1424
|
+
"right",
|
|
1425
|
+
"ctrl-c"
|
|
1426
|
+
];
|
|
1025
1427
|
var realDriver = {
|
|
1026
1428
|
tmux(args, input) {
|
|
1027
|
-
return
|
|
1429
|
+
return execFileSync3("tmux", args, {
|
|
1028
1430
|
encoding: "utf8",
|
|
1029
1431
|
input,
|
|
1030
1432
|
stdio: input === void 0 ? ["ignore", "pipe", "pipe"] : ["pipe", "pipe", "pipe"]
|
|
@@ -1233,13 +1635,7 @@ function createAgentWindow(runId, tmuxSession, role, config, inheritedWorkingDir
|
|
|
1233
1635
|
function validateAgents(configs, available) {
|
|
1234
1636
|
for (const config of configs) requireProvider(config.provider, available);
|
|
1235
1637
|
}
|
|
1236
|
-
function assertSpawnerMode(mode) {
|
|
1237
|
-
if (mode !== void 0 && mode !== "spawner") {
|
|
1238
|
-
throw new Error("Only agent-run mode is available in this package");
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
1638
|
function startRun(request, options = {}) {
|
|
1242
|
-
assertSpawnerMode(request.mode);
|
|
1243
1639
|
const cfg = loadConfig();
|
|
1244
1640
|
const driver = options.driver ?? realDriver;
|
|
1245
1641
|
const available = options.available ?? detectAvailable();
|
|
@@ -1257,7 +1653,6 @@ function startRun(request, options = {}) {
|
|
|
1257
1653
|
const root = createAgentWindow(runId, tmuxSession, "root", request.root, workingDir, readyDelayMs, driver);
|
|
1258
1654
|
const run = {
|
|
1259
1655
|
id: runId,
|
|
1260
|
-
mode: "spawner",
|
|
1261
1656
|
name: request.name,
|
|
1262
1657
|
status: "running",
|
|
1263
1658
|
tmux_session: tmuxSession,
|
|
@@ -1287,6 +1682,101 @@ function startRun(request, options = {}) {
|
|
|
1287
1682
|
throw new Error(`Failed to start run ${request.name}: ${detail}`, { cause: err });
|
|
1288
1683
|
}
|
|
1289
1684
|
}
|
|
1685
|
+
function slotToLaunchConfig(slot) {
|
|
1686
|
+
return {
|
|
1687
|
+
nickname: slot.nickname_template,
|
|
1688
|
+
provider: slot.provider,
|
|
1689
|
+
model: slot.model,
|
|
1690
|
+
auth_mode: slot.auth_mode,
|
|
1691
|
+
effort: slot.effort,
|
|
1692
|
+
task: slot.initial_prompt,
|
|
1693
|
+
working_dir: slot.working_dir,
|
|
1694
|
+
permissions: slot.permissions,
|
|
1695
|
+
rc_enabled: slot.rc_enabled
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
function startRunFromPreset(presetName, opts = {}, options = {}) {
|
|
1699
|
+
const tree = loadPreset(presetName);
|
|
1700
|
+
if (!tree) throw new Error(`preset not found: ${presetName}`);
|
|
1701
|
+
return startRun({
|
|
1702
|
+
name: opts.name?.trim() || tree.name,
|
|
1703
|
+
working_dir: opts.working_dir || process.cwd(),
|
|
1704
|
+
root: slotToLaunchConfig(tree.root),
|
|
1705
|
+
workers: tree.workers.map(slotToLaunchConfig),
|
|
1706
|
+
preset_name: tree.name
|
|
1707
|
+
}, options);
|
|
1708
|
+
}
|
|
1709
|
+
function createHeadlessHeadAgent(runId, tmuxSession, provider, workingDir) {
|
|
1710
|
+
const cfg = loadConfig();
|
|
1711
|
+
const agent = {
|
|
1712
|
+
id: randomUUID2(),
|
|
1713
|
+
run_id: runId,
|
|
1714
|
+
nickname: providerDisplayName(provider),
|
|
1715
|
+
provider,
|
|
1716
|
+
model: "",
|
|
1717
|
+
role: "root",
|
|
1718
|
+
working_dir: workingDir,
|
|
1719
|
+
task: "",
|
|
1720
|
+
task_status: "working",
|
|
1721
|
+
task_note: "",
|
|
1722
|
+
tmux_session: tmuxSession,
|
|
1723
|
+
tmux_window_id: "",
|
|
1724
|
+
tmux_pane_id: "",
|
|
1725
|
+
rc_enabled: false,
|
|
1726
|
+
permissions: cfg.global.default_permissions,
|
|
1727
|
+
headless: true,
|
|
1728
|
+
inbox: [],
|
|
1729
|
+
last_seen: nowMs(),
|
|
1730
|
+
started_at: nowIso(),
|
|
1731
|
+
ended_at: null
|
|
1732
|
+
};
|
|
1733
|
+
writeAgent(agent);
|
|
1734
|
+
return agent;
|
|
1735
|
+
}
|
|
1736
|
+
function startRunWithHead(headProvider, firstWorker, options = {}) {
|
|
1737
|
+
const cfg = loadConfig();
|
|
1738
|
+
const driver = options.driver ?? realDriver;
|
|
1739
|
+
const available = options.available ?? detectAvailable();
|
|
1740
|
+
validateAgents([firstWorker], available);
|
|
1741
|
+
const runId = randomUUID2();
|
|
1742
|
+
const readyDelayMs = cfg.global.ready_delay_ms;
|
|
1743
|
+
const workingDir = resolveWorkingDir(firstWorker.working_dir, process.cwd());
|
|
1744
|
+
const reevesAnchor = pickReevesAnchor(driver);
|
|
1745
|
+
const tmuxSession = tmuxRunSessionName(runId, providerDisplayName(headProvider));
|
|
1746
|
+
let createdRunSession = false;
|
|
1747
|
+
try {
|
|
1748
|
+
createRunSessionWithReevesTab(driver, tmuxSession, reevesAnchor, workingDir);
|
|
1749
|
+
createdRunSession = true;
|
|
1750
|
+
const head = createHeadlessHeadAgent(runId, tmuxSession, headProvider, workingDir);
|
|
1751
|
+
const run = {
|
|
1752
|
+
id: runId,
|
|
1753
|
+
name: providerDisplayName(headProvider),
|
|
1754
|
+
status: "running",
|
|
1755
|
+
tmux_session: tmuxSession,
|
|
1756
|
+
reeves_session: reevesAnchor.sessionName,
|
|
1757
|
+
reeves_window_id: reevesAnchor.windowId,
|
|
1758
|
+
reeves_pane_id: reevesAnchor.paneId,
|
|
1759
|
+
root_agent_id: head.id,
|
|
1760
|
+
working_dir: workingDir,
|
|
1761
|
+
preset_name: null,
|
|
1762
|
+
started_at: nowIso(),
|
|
1763
|
+
ended_at: null
|
|
1764
|
+
};
|
|
1765
|
+
writeRun(run);
|
|
1766
|
+
const worker = createAgentWindow(runId, tmuxSession, "worker", firstWorker, workingDir, readyDelayMs, driver);
|
|
1767
|
+
return { run, agents: [head, worker] };
|
|
1768
|
+
} catch (err) {
|
|
1769
|
+
if (createdRunSession) {
|
|
1770
|
+
try {
|
|
1771
|
+
driver.tmux(["kill-session", "-t", tmuxSession]);
|
|
1772
|
+
} catch {
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
removeRun(runId);
|
|
1776
|
+
const detail = childProcessOutput(err) || (err instanceof Error ? err.message : "tmux returned a non-zero exit code");
|
|
1777
|
+
throw new Error(`Failed to start run ${providerDisplayName(headProvider)}: ${detail}`, { cause: err });
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1290
1780
|
function spawnWorker(request, options = {}) {
|
|
1291
1781
|
const cfg = loadConfig();
|
|
1292
1782
|
const driver = options.driver ?? realDriver;
|
|
@@ -1294,9 +1784,6 @@ function spawnWorker(request, options = {}) {
|
|
|
1294
1784
|
requireProvider(request.provider, available);
|
|
1295
1785
|
const run = readRun(request.run_id);
|
|
1296
1786
|
if (run.status === "ended" || run.ended_at) throw new Error(`Run is ended: ${run.id}`);
|
|
1297
|
-
if (run.mode !== "spawner") {
|
|
1298
|
-
throw new Error("Run not found");
|
|
1299
|
-
}
|
|
1300
1787
|
return createAgentWindow(
|
|
1301
1788
|
run.id,
|
|
1302
1789
|
run.tmux_session,
|
|
@@ -1341,13 +1828,14 @@ function openAgent(agentId, options = {}) {
|
|
|
1341
1828
|
}
|
|
1342
1829
|
function peekAgent(agentId, lines = 10, options = {}) {
|
|
1343
1830
|
const driver = options.driver ?? realDriver;
|
|
1831
|
+
const n = Number.isFinite(lines) && lines > 0 ? Math.floor(lines) : 10;
|
|
1344
1832
|
try {
|
|
1345
1833
|
const agent = findAgent(agentId);
|
|
1346
1834
|
if (agent.headless || !agent.tmux_pane_id) return "(headless agent - no output)";
|
|
1347
|
-
let output = driver.tmux(["capture-pane", "-p", "-e", "-S", String(-
|
|
1835
|
+
let output = driver.tmux(["capture-pane", "-p", "-e", "-S", String(-n), "-t", agent.tmux_pane_id]);
|
|
1348
1836
|
if (!output.trim()) {
|
|
1349
1837
|
try {
|
|
1350
|
-
output = driver.tmux(["capture-pane", "-p", "-e", "-a", "-S", String(-
|
|
1838
|
+
output = driver.tmux(["capture-pane", "-p", "-e", "-a", "-S", String(-n), "-t", agent.tmux_pane_id]);
|
|
1351
1839
|
} catch {
|
|
1352
1840
|
}
|
|
1353
1841
|
}
|
|
@@ -1356,13 +1844,50 @@ function peekAgent(agentId, lines = 10, options = {}) {
|
|
|
1356
1844
|
return "";
|
|
1357
1845
|
}
|
|
1358
1846
|
}
|
|
1847
|
+
function sendText(agentId, text, options = {}) {
|
|
1848
|
+
const driver = options.driver ?? realDriver;
|
|
1849
|
+
const agent = findAgent(agentId);
|
|
1850
|
+
if (agent.headless || !agent.tmux_pane_id) throw new Error("This agent is headless - no tmux pane exists");
|
|
1851
|
+
pasteTextToPane(driver, agent.tmux_pane_id, text);
|
|
1852
|
+
lastPasteAtByPane.set(agent.tmux_pane_id, Date.now());
|
|
1853
|
+
if (!agent.ended_at && agent.task_status === "queued") updateAgent(agent.run_id, agent.id, { task_status: "working" });
|
|
1854
|
+
}
|
|
1855
|
+
function tmuxKey(key) {
|
|
1856
|
+
if (key === "enter") return "Enter";
|
|
1857
|
+
if (key === "escape") return "Escape";
|
|
1858
|
+
if (key === "backspace") return "BSpace";
|
|
1859
|
+
if (key === "tab") return "Tab";
|
|
1860
|
+
if (key === "space") return "Space";
|
|
1861
|
+
if (key === "up") return "Up";
|
|
1862
|
+
if (key === "down") return "Down";
|
|
1863
|
+
if (key === "left") return "Left";
|
|
1864
|
+
if (key === "right") return "Right";
|
|
1865
|
+
return "C-c";
|
|
1866
|
+
}
|
|
1867
|
+
function sendKey(agentId, key, options = {}) {
|
|
1868
|
+
const driver = options.driver ?? realDriver;
|
|
1869
|
+
const agent = findAgent(agentId);
|
|
1870
|
+
if (agent.headless || !agent.tmux_pane_id) throw new Error("This agent is headless - no tmux pane exists");
|
|
1871
|
+
if (!ALLOWED_KEYS.includes(key)) throw new Error(`Unsupported key: ${String(key)}`);
|
|
1872
|
+
if (key === "enter") {
|
|
1873
|
+
const lastPasteAt = lastPasteAtByPane.get(agent.tmux_pane_id) ?? 0;
|
|
1874
|
+
const remaining = POST_PASTE_ENTER_DELAY_MS - (Date.now() - lastPasteAt);
|
|
1875
|
+
if (remaining > 0) {
|
|
1876
|
+
if (driver === realDriver) sleepSync2(remaining);
|
|
1877
|
+
else driver.delay(() => {
|
|
1878
|
+
}, remaining);
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
driver.tmux(["send-keys", "-t", agent.tmux_pane_id, tmuxKey(key)]);
|
|
1882
|
+
if (!agent.ended_at && agent.task_status === "queued") updateAgent(agent.run_id, agent.id, { task_status: "working" });
|
|
1883
|
+
}
|
|
1884
|
+
function interrupt(agentId, options = {}) {
|
|
1885
|
+
sendKey(agentId, "ctrl-c", options);
|
|
1886
|
+
}
|
|
1359
1887
|
function killAgent(agentId, options = {}) {
|
|
1360
1888
|
const driver = options.driver ?? realDriver;
|
|
1361
1889
|
const agent = findAgent(agentId);
|
|
1362
1890
|
const run = readRun(agent.run_id);
|
|
1363
|
-
if (run.mode !== "spawner") {
|
|
1364
|
-
throw new Error("Run not found");
|
|
1365
|
-
}
|
|
1366
1891
|
try {
|
|
1367
1892
|
driver.tmux(["kill-window", "-t", agent.tmux_window_id]);
|
|
1368
1893
|
} catch {
|
|
@@ -1406,15 +1931,47 @@ function stopRun(runId, options = {}) {
|
|
|
1406
1931
|
archiveAndRemoveRun(run.id, "ended");
|
|
1407
1932
|
return endedRun;
|
|
1408
1933
|
}
|
|
1934
|
+
function openTmuxTarget(id, options = {}) {
|
|
1935
|
+
const driver = options.driver ?? realDriver;
|
|
1936
|
+
let session;
|
|
1937
|
+
let window;
|
|
1938
|
+
let label;
|
|
1939
|
+
try {
|
|
1940
|
+
const run = readRun(id);
|
|
1941
|
+
session = run.tmux_session;
|
|
1942
|
+
window = "reeves";
|
|
1943
|
+
label = run.name;
|
|
1944
|
+
} catch {
|
|
1945
|
+
try {
|
|
1946
|
+
const agent = findAgent(id);
|
|
1947
|
+
session = agent.tmux_session;
|
|
1948
|
+
window = agent.tmux_window_id;
|
|
1949
|
+
label = agent.nickname;
|
|
1950
|
+
} catch {
|
|
1951
|
+
throw new Error(`no run or agent found: ${id}`);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
const target = `${session}:${window}`;
|
|
1955
|
+
try {
|
|
1956
|
+
driver.tmux(["switch-client", "-t", target]);
|
|
1957
|
+
} catch {
|
|
1958
|
+
}
|
|
1959
|
+
try {
|
|
1960
|
+
driver.tmux(["select-window", "-t", target]);
|
|
1961
|
+
} catch {
|
|
1962
|
+
}
|
|
1963
|
+
return { session, window, label };
|
|
1964
|
+
}
|
|
1409
1965
|
|
|
1410
1966
|
export {
|
|
1967
|
+
PROVIDER_REGISTRY,
|
|
1968
|
+
PROVIDER_DEFS,
|
|
1411
1969
|
BIN,
|
|
1412
1970
|
PROVIDERS,
|
|
1413
1971
|
isProvider,
|
|
1414
1972
|
normalizeProvider,
|
|
1415
1973
|
buildCommand,
|
|
1416
1974
|
detectAvailable,
|
|
1417
|
-
inspectProviderCompatibility,
|
|
1418
1975
|
colors,
|
|
1419
1976
|
sep,
|
|
1420
1977
|
space,
|
|
@@ -1422,13 +1979,14 @@ export {
|
|
|
1422
1979
|
providerColor,
|
|
1423
1980
|
modelColor,
|
|
1424
1981
|
modelBadgeLabel,
|
|
1982
|
+
redactSecrets,
|
|
1425
1983
|
stateRoot,
|
|
1426
1984
|
runsDir,
|
|
1985
|
+
runDir,
|
|
1427
1986
|
nowIso,
|
|
1987
|
+
withRunsLock,
|
|
1428
1988
|
readRun,
|
|
1429
|
-
readRunAny,
|
|
1430
1989
|
listRuns,
|
|
1431
|
-
listRunsAny,
|
|
1432
1990
|
listRunHistory,
|
|
1433
1991
|
deleteAgent,
|
|
1434
1992
|
deleteRunHistory,
|
|
@@ -1436,11 +1994,10 @@ export {
|
|
|
1436
1994
|
readAgent,
|
|
1437
1995
|
archiveAndRemoveRun,
|
|
1438
1996
|
listAgents,
|
|
1439
|
-
listAgentsAny,
|
|
1440
1997
|
findAgent,
|
|
1441
|
-
findAgentAny,
|
|
1442
1998
|
runHasLiveTmuxTarget,
|
|
1443
1999
|
autoCleanupRuns,
|
|
2000
|
+
runDoctor,
|
|
1444
2001
|
LANGUAGE_OPTIONS,
|
|
1445
2002
|
DEFAULT_LANGUAGE,
|
|
1446
2003
|
isLanguageCode,
|
|
@@ -1450,13 +2007,29 @@ export {
|
|
|
1450
2007
|
defaultConfig,
|
|
1451
2008
|
loadConfig,
|
|
1452
2009
|
saveConfig,
|
|
2010
|
+
CONFIG_FIELDS,
|
|
2011
|
+
parseConfigValue,
|
|
2012
|
+
setConfigValues,
|
|
2013
|
+
presetsDir,
|
|
2014
|
+
listPresets,
|
|
2015
|
+
loadPreset,
|
|
2016
|
+
savePreset,
|
|
2017
|
+
deletePreset,
|
|
2018
|
+
savePresetFromRun,
|
|
2019
|
+
ALLOWED_KEYS,
|
|
1453
2020
|
startRun,
|
|
2021
|
+
startRunFromPreset,
|
|
2022
|
+
startRunWithHead,
|
|
1454
2023
|
spawnWorker,
|
|
1455
2024
|
openReeves,
|
|
1456
2025
|
openRunTabs,
|
|
1457
2026
|
openAgent,
|
|
1458
2027
|
peekAgent,
|
|
2028
|
+
sendText,
|
|
2029
|
+
sendKey,
|
|
2030
|
+
interrupt,
|
|
1459
2031
|
killAgent,
|
|
1460
|
-
stopRun
|
|
2032
|
+
stopRun,
|
|
2033
|
+
openTmuxTarget
|
|
1461
2034
|
};
|
|
1462
|
-
//# sourceMappingURL=chunk-
|
|
2035
|
+
//# sourceMappingURL=chunk-65LHCGPC.js.map
|