@dadado/agent-kit-cli 6.7.2 → 6.8.0
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/{chunk-5WDFOFL4.js → chunk-3Z4PGEEJ.js} +8 -15
- package/dist/{chunk-R6WH5P7R.js → chunk-CXDAT76O.js} +15 -1
- package/dist/{engine-info-UQNVNOA2.js → engine-info-3MQML5I2.js} +1 -1
- package/dist/index.js +4 -4
- package/dist/{run-QG7XQ3XF.js → run-DXGTFYJK.js} +283 -41
- package/dist/{run-plan-P7VTOWYI.js → run-plan-KWGS2SOZ.js} +2 -2
- package/package.json +1 -1
|
@@ -2,8 +2,10 @@ import {
|
|
|
2
2
|
DRIVER_PROTOCOL_VERSION,
|
|
3
3
|
DriverAgentSink,
|
|
4
4
|
createDriverAnswerReader,
|
|
5
|
-
createDriverEmitter
|
|
6
|
-
|
|
5
|
+
createDriverEmitter,
|
|
6
|
+
driverReplies,
|
|
7
|
+
driverStop
|
|
8
|
+
} from "./chunk-CXDAT76O.js";
|
|
7
9
|
import {
|
|
8
10
|
classifyGateExit,
|
|
9
11
|
landGateExit
|
|
@@ -1036,6 +1038,7 @@ async function runPlanLoop(opts) {
|
|
|
1036
1038
|
emit({
|
|
1037
1039
|
type: "run_start",
|
|
1038
1040
|
protocol: DRIVER_PROTOCOL_VERSION,
|
|
1041
|
+
command: "run-plan",
|
|
1039
1042
|
backend: opts.backend.id,
|
|
1040
1043
|
plan: path5.basename(planPath),
|
|
1041
1044
|
pending: pendingAtStart,
|
|
@@ -1123,19 +1126,8 @@ async function runPlanLoop(opts) {
|
|
|
1123
1126
|
pendingBefore: before,
|
|
1124
1127
|
pendingAfter,
|
|
1125
1128
|
result: driverSentinel(sentinel2),
|
|
1126
|
-
replies: replies
|
|
1127
|
-
|
|
1128
|
-
reply,
|
|
1129
|
-
label,
|
|
1130
|
-
line,
|
|
1131
|
-
at
|
|
1132
|
-
})),
|
|
1133
|
-
stop: hitlStop ? {
|
|
1134
|
-
askId: hitlStop.askId,
|
|
1135
|
-
cause: hitlStop.cause,
|
|
1136
|
-
message: hitlStop.message,
|
|
1137
|
-
exitCode: hitlStop.exitCode
|
|
1138
|
-
} : null
|
|
1129
|
+
replies: driverReplies(replies),
|
|
1130
|
+
stop: driverStop(hitlStop)
|
|
1139
1131
|
});
|
|
1140
1132
|
try {
|
|
1141
1133
|
const runOpts = {
|
|
@@ -1318,6 +1310,7 @@ async function runPlanLoop(opts) {
|
|
|
1318
1310
|
}
|
|
1319
1311
|
|
|
1320
1312
|
export {
|
|
1313
|
+
readRunQueueState,
|
|
1321
1314
|
shouldUseLiveTui,
|
|
1322
1315
|
withLiveTui,
|
|
1323
1316
|
runPlanLoop
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import { createInterface } from "readline";
|
|
7
7
|
import { StringDecoder } from "string_decoder";
|
|
8
8
|
var DRIVER_PROTOCOL_MAJOR = 1;
|
|
9
|
-
var DRIVER_PROTOCOL_VERSION = "1.
|
|
9
|
+
var DRIVER_PROTOCOL_VERSION = "1.2.0";
|
|
10
10
|
var DRIVER_EVENTS_FORMATS = ["ndjson"];
|
|
11
11
|
var INBOUND_MAX_CHARS = 64 * 1024;
|
|
12
12
|
var AGENT_PENDING_MAX_CHARS = 4 * 1024 * 1024;
|
|
@@ -26,6 +26,18 @@ function createDriverEmitter(write = (text) => {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
function driverReplies(replies) {
|
|
30
|
+
return (replies ?? []).map(({ askId, reply, label, line, at }) => ({
|
|
31
|
+
askId,
|
|
32
|
+
reply,
|
|
33
|
+
label,
|
|
34
|
+
line,
|
|
35
|
+
at
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
function driverStop(stop) {
|
|
39
|
+
return stop ? { askId: stop.askId, cause: stop.cause, message: stop.message, exitCode: stop.exitCode } : null;
|
|
40
|
+
}
|
|
29
41
|
function parseDriverInbound(line) {
|
|
30
42
|
const text = line.trim();
|
|
31
43
|
if (text.length > INBOUND_MAX_CHARS) return { ok: false, error: "line too long" };
|
|
@@ -218,6 +230,8 @@ export {
|
|
|
218
230
|
DRIVER_PROTOCOL_VERSION,
|
|
219
231
|
DRIVER_EVENTS_FORMATS,
|
|
220
232
|
createDriverEmitter,
|
|
233
|
+
driverReplies,
|
|
234
|
+
driverStop,
|
|
221
235
|
createDriverAnswerReader,
|
|
222
236
|
DriverAgentSink
|
|
223
237
|
};
|
package/dist/index.js
CHANGED
|
@@ -240,9 +240,9 @@ var main = defineCommand({
|
|
|
240
240
|
contribute: () => import("./contribute-VSVPRHQ7.js").then((m) => m.contributeCommand),
|
|
241
241
|
handoff: () => import("./handoff-5AGE2D3T.js").then((m) => m.handoffCommand),
|
|
242
242
|
"plan-index": () => import("./plan-index-BNLUU6T5.js").then((m) => m.planIndexCommand),
|
|
243
|
-
run: () => import("./run-
|
|
244
|
-
"run-plan": () => import("./run-plan-
|
|
245
|
-
"run-plan-all": () => import("./run-
|
|
243
|
+
run: () => import("./run-DXGTFYJK.js").then((m) => m.runCommand),
|
|
244
|
+
"run-plan": () => import("./run-plan-KWGS2SOZ.js").then((m) => m.runPlanCommand),
|
|
245
|
+
"run-plan-all": () => import("./run-DXGTFYJK.js").then((m) => m.runPlanAllCommand),
|
|
246
246
|
countdown: () => import("./countdown-XYRE4GZU.js").then((m) => m.countdownCommand),
|
|
247
247
|
"ground-control": () => import("./ground-control-726LRB6Q.js").then((m) => m.groundControlCommand),
|
|
248
248
|
dashboard: () => import("./dashboard-YNCFISNO.js").then((m) => m.dashboardCommand),
|
|
@@ -253,7 +253,7 @@ var main = defineCommand({
|
|
|
253
253
|
monitors: () => import("./monitors-PDXBLB3U.js").then((m) => m.monitorsCommand),
|
|
254
254
|
sessions: () => import("./sessions-O7MYEMCT.js").then((m) => m.sessionsCommand),
|
|
255
255
|
validate: () => import("./validate-V2CW7J4B.js").then((m) => m.validateCommand),
|
|
256
|
-
"engine-info": () => import("./engine-info-
|
|
256
|
+
"engine-info": () => import("./engine-info-3MQML5I2.js").then((m) => m.engineInfoCommand),
|
|
257
257
|
commands: () => import("./commands-EQHK3ZEP.js").then((m) => m.commandsCommand)
|
|
258
258
|
},
|
|
259
259
|
async run({ rawArgs }) {
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
readRunQueueState,
|
|
2
3
|
runPlanLoop,
|
|
3
4
|
shouldUseLiveTui,
|
|
4
5
|
withLiveTui
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
6
|
+
} from "./chunk-3Z4PGEEJ.js";
|
|
7
|
+
import {
|
|
8
|
+
DRIVER_EVENTS_FORMATS,
|
|
9
|
+
DRIVER_PROTOCOL_VERSION,
|
|
10
|
+
DriverAgentSink,
|
|
11
|
+
createDriverAnswerReader,
|
|
12
|
+
createDriverEmitter,
|
|
13
|
+
driverReplies,
|
|
14
|
+
driverStop
|
|
15
|
+
} from "./chunk-CXDAT76O.js";
|
|
7
16
|
import {
|
|
8
17
|
REVIEW_PACK_SLASH,
|
|
9
18
|
runReviewJob
|
|
@@ -48,21 +57,237 @@ import "./chunk-QTON2GQX.js";
|
|
|
48
57
|
import {
|
|
49
58
|
logger
|
|
50
59
|
} from "./chunk-ZB43YMHW.js";
|
|
51
|
-
import
|
|
60
|
+
import {
|
|
61
|
+
HANDOFF_REL
|
|
62
|
+
} from "./chunk-C4Q77GGJ.js";
|
|
52
63
|
import "./chunk-5B4DVO6C.js";
|
|
53
64
|
|
|
54
65
|
// src/commands/run.ts
|
|
55
66
|
import { homedir } from "os";
|
|
56
|
-
import
|
|
67
|
+
import path2 from "path";
|
|
57
68
|
import { defineCommand } from "citty";
|
|
69
|
+
|
|
70
|
+
// src/plan-loop/dispatch-driver.ts
|
|
71
|
+
import { readFile } from "fs/promises";
|
|
72
|
+
import path from "path";
|
|
73
|
+
var DISPATCH_DRIVER_TICK = 1;
|
|
74
|
+
var QUEUE_STATE_POLL_MS = 1e3;
|
|
75
|
+
function projectQueueState(handoff) {
|
|
76
|
+
const { queue, cursor, current, status } = readRunQueueState(handoff);
|
|
77
|
+
if (queue.length === 0) return { cursor: null, total: 0, current: null, status: null };
|
|
78
|
+
return { cursor, total: queue.length, current, status };
|
|
79
|
+
}
|
|
80
|
+
async function readQueueState(root) {
|
|
81
|
+
let handoff = "";
|
|
82
|
+
try {
|
|
83
|
+
handoff = await readFile(path.join(root, HANDOFF_REL), "utf8");
|
|
84
|
+
} catch {
|
|
85
|
+
}
|
|
86
|
+
return projectQueueState(handoff);
|
|
87
|
+
}
|
|
88
|
+
function createQueueStateWatcher(opts) {
|
|
89
|
+
let last = JSON.stringify(opts.initial);
|
|
90
|
+
let busy = null;
|
|
91
|
+
let stopped = false;
|
|
92
|
+
const check = async () => {
|
|
93
|
+
const next = await readQueueState(opts.root);
|
|
94
|
+
const key = JSON.stringify(next);
|
|
95
|
+
if (key === last || stopped) return;
|
|
96
|
+
last = key;
|
|
97
|
+
opts.emitter.emit({ type: "queue_state", ...next });
|
|
98
|
+
};
|
|
99
|
+
const tick = () => {
|
|
100
|
+
if (busy) return busy;
|
|
101
|
+
busy = check().finally(() => {
|
|
102
|
+
busy = null;
|
|
103
|
+
});
|
|
104
|
+
return busy;
|
|
105
|
+
};
|
|
106
|
+
opts.emitter.emit({ type: "queue_state", ...opts.initial });
|
|
107
|
+
const timer = setInterval(() => {
|
|
108
|
+
void tick();
|
|
109
|
+
}, opts.pollMs ?? QUEUE_STATE_POLL_MS);
|
|
110
|
+
timer.unref?.();
|
|
111
|
+
return {
|
|
112
|
+
flush: async () => {
|
|
113
|
+
if (busy) await busy;
|
|
114
|
+
await tick();
|
|
115
|
+
},
|
|
116
|
+
stop: () => {
|
|
117
|
+
stopped = true;
|
|
118
|
+
clearInterval(timer);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async function landDispatchOutcome(opts) {
|
|
123
|
+
const { result } = opts;
|
|
124
|
+
const stop = result.hitl?.stop;
|
|
125
|
+
const trigger = classifyGateExit({ stop, failed: opts.exitCode !== 0 });
|
|
126
|
+
if (!trigger) return;
|
|
127
|
+
const summary = result.lastResult?.resultText.trim() || result.lastResult?.assistantTexts.at(-1)?.trim() || void 0;
|
|
128
|
+
try {
|
|
129
|
+
await landGateExit({
|
|
130
|
+
root: opts.root,
|
|
131
|
+
outcome: {
|
|
132
|
+
trigger,
|
|
133
|
+
exitCode: opts.exitCode,
|
|
134
|
+
reason: stop?.message ?? `${opts.backendId} exited with code ${opts.exitCode}`,
|
|
135
|
+
command: `run ${opts.slash}`,
|
|
136
|
+
backend: opts.backendId,
|
|
137
|
+
logPath: opts.logPath,
|
|
138
|
+
...stop ? { askId: stop.askId } : {},
|
|
139
|
+
...summary ? { summary } : {},
|
|
140
|
+
...result.lastResult ? {
|
|
141
|
+
gateText: [result.lastResult.resultText, ...result.lastResult.assistantTexts].join(
|
|
142
|
+
"\n"
|
|
143
|
+
)
|
|
144
|
+
} : {}
|
|
145
|
+
},
|
|
146
|
+
log: opts.log
|
|
147
|
+
});
|
|
148
|
+
} catch (err) {
|
|
149
|
+
opts.log(`gate-exit: landing failed: ${String(err)}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async function runDispatchDriver(opts) {
|
|
153
|
+
const root = path.resolve(opts.root);
|
|
154
|
+
const emitter = createDriverEmitter(opts.events.write, opts.events.now);
|
|
155
|
+
const reader = createDriverAnswerReader({
|
|
156
|
+
input: opts.events.input,
|
|
157
|
+
emitter,
|
|
158
|
+
tick: () => DISPATCH_DRIVER_TICK
|
|
159
|
+
});
|
|
160
|
+
const writeErr = opts.events.writeErr ?? ((text) => {
|
|
161
|
+
process.stderr.write(text);
|
|
162
|
+
});
|
|
163
|
+
const say = (message, level = "info") => emitter.emit({ type: "log", level, message });
|
|
164
|
+
let ticks = 0;
|
|
165
|
+
let queue = null;
|
|
166
|
+
const finish = async (exitCode, reason, result) => {
|
|
167
|
+
if (queue) {
|
|
168
|
+
await queue.flush();
|
|
169
|
+
queue.stop();
|
|
170
|
+
}
|
|
171
|
+
emitter.emit({
|
|
172
|
+
type: "run_end",
|
|
173
|
+
exitCode,
|
|
174
|
+
ticks,
|
|
175
|
+
pending: null,
|
|
176
|
+
reason,
|
|
177
|
+
planExhausted: false,
|
|
178
|
+
replies: driverReplies(result?.hitl?.replies),
|
|
179
|
+
stop: driverStop(result?.hitl?.stop)
|
|
180
|
+
});
|
|
181
|
+
reader.close();
|
|
182
|
+
return exitCode;
|
|
183
|
+
};
|
|
184
|
+
const detected = await detectAgentBackend(opts.backend, opts.whichFn);
|
|
185
|
+
if (!detected.ok) {
|
|
186
|
+
say(detected.message, "error");
|
|
187
|
+
return finish(1, detected.message);
|
|
188
|
+
}
|
|
189
|
+
const file = await readCommandFile(root, opts.slash);
|
|
190
|
+
if (!file.ok) {
|
|
191
|
+
say(file.message, "error");
|
|
192
|
+
return finish(1, file.message);
|
|
193
|
+
}
|
|
194
|
+
const prompt = buildDispatchPrompt(file.body);
|
|
195
|
+
const initialQueue = await readQueueState(root);
|
|
196
|
+
emitter.emit({
|
|
197
|
+
type: "run_start",
|
|
198
|
+
protocol: DRIVER_PROTOCOL_VERSION,
|
|
199
|
+
command: opts.slash,
|
|
200
|
+
backend: detected.id,
|
|
201
|
+
plan: null,
|
|
202
|
+
pending: null,
|
|
203
|
+
maxTicks: null,
|
|
204
|
+
hitl: opts.noHitl ? "off" : "driver",
|
|
205
|
+
queue: initialQueue
|
|
206
|
+
});
|
|
207
|
+
queue = createQueueStateWatcher({
|
|
208
|
+
root,
|
|
209
|
+
emitter,
|
|
210
|
+
initial: initialQueue,
|
|
211
|
+
pollMs: opts.queuePollMs
|
|
212
|
+
});
|
|
213
|
+
say(`Dispatch: ${opts.slash} via ${detected.id}`);
|
|
214
|
+
say(`Command file: ${path.relative(root, file.path)}`);
|
|
215
|
+
if (opts.dryRun) {
|
|
216
|
+
say("--dry-run: no agent will be started. Prompt:");
|
|
217
|
+
say(prompt);
|
|
218
|
+
return finish(0, "dry-run");
|
|
219
|
+
}
|
|
220
|
+
const logPath = await ensureDispatchLogPath(root);
|
|
221
|
+
say(`Log: ${path.relative(root, logPath)}`);
|
|
222
|
+
const onSigInt = () => {
|
|
223
|
+
queue?.stop();
|
|
224
|
+
emitter.emit({
|
|
225
|
+
type: "run_end",
|
|
226
|
+
exitCode: 130,
|
|
227
|
+
ticks,
|
|
228
|
+
pending: null,
|
|
229
|
+
reason: "interrupted (SIGINT)",
|
|
230
|
+
planExhausted: false
|
|
231
|
+
});
|
|
232
|
+
process.exit(130);
|
|
233
|
+
};
|
|
234
|
+
process.on("SIGINT", onSigInt);
|
|
235
|
+
try {
|
|
236
|
+
ticks = DISPATCH_DRIVER_TICK;
|
|
237
|
+
let result;
|
|
238
|
+
try {
|
|
239
|
+
result = await runHeadlessDispatch({
|
|
240
|
+
backendId: detected.id,
|
|
241
|
+
bin: detected.bin,
|
|
242
|
+
workspace: root,
|
|
243
|
+
prompt,
|
|
244
|
+
model: opts.model,
|
|
245
|
+
logPath,
|
|
246
|
+
spawnFn: opts.spawnFn,
|
|
247
|
+
versionFn: opts.versionFn,
|
|
248
|
+
log: (line) => say(line),
|
|
249
|
+
render: new DriverAgentSink(emitter, DISPATCH_DRIVER_TICK),
|
|
250
|
+
hitl: {
|
|
251
|
+
policy: opts.noHitl ? "off" : "driver",
|
|
252
|
+
readAnswer: reader.read,
|
|
253
|
+
write: writeErr
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
} catch (err) {
|
|
257
|
+
say(String(err), "error");
|
|
258
|
+
return finish(1, `${opts.slash} failed to start: ${String(err)}`);
|
|
259
|
+
}
|
|
260
|
+
for (const line of formatHitlSummary(result.hitl)) say(line);
|
|
261
|
+
const exitCode = hitlExitCode(result.exitCode, result.hitl);
|
|
262
|
+
if (opts.landOnGate) {
|
|
263
|
+
await landDispatchOutcome({
|
|
264
|
+
root,
|
|
265
|
+
slash: opts.slash,
|
|
266
|
+
backendId: detected.id,
|
|
267
|
+
logPath,
|
|
268
|
+
exitCode,
|
|
269
|
+
result,
|
|
270
|
+
log: (line) => say(line, "warn")
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
const stop = result.hitl?.stop;
|
|
274
|
+
const reason = stop ? stop.message : exitCode === 0 ? "session ended" : `${detected.id} exited with code ${exitCode}`;
|
|
275
|
+
return finish(exitCode, reason, result);
|
|
276
|
+
} finally {
|
|
277
|
+
process.off("SIGINT", onSigInt);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// src/commands/run.ts
|
|
282
|
+
var DRIVER_DISPATCH_SLASH = "run-plan-all";
|
|
58
283
|
function displayPath(target, home = homedir()) {
|
|
59
|
-
const resolvedHome =
|
|
284
|
+
const resolvedHome = path2.resolve(home);
|
|
60
285
|
if (target === resolvedHome) return "~";
|
|
61
|
-
const prefix = resolvedHome.endsWith(
|
|
62
|
-
return target.startsWith(prefix) ? `~${
|
|
286
|
+
const prefix = resolvedHome.endsWith(path2.sep) ? resolvedHome : `${resolvedHome}${path2.sep}`;
|
|
287
|
+
return target.startsWith(prefix) ? `~${path2.sep}${target.slice(prefix.length)}` : target;
|
|
63
288
|
}
|
|
64
289
|
async function executeRun(input) {
|
|
65
|
-
const root =
|
|
290
|
+
const root = path2.resolve(input.cwd);
|
|
66
291
|
const slash = normalizeSlashName(input.slash);
|
|
67
292
|
if (!slash) {
|
|
68
293
|
return { exitCode: 1, error: "Provide a slash: agent-kit run <slash>" };
|
|
@@ -80,6 +305,26 @@ async function executeRun(input) {
|
|
|
80
305
|
if (input.includeReviewed && slash !== REVIEW_PACK_SLASH) {
|
|
81
306
|
return { exitCode: 1, error: `--include-reviewed only applies to ${REVIEW_PACK_SLASH}` };
|
|
82
307
|
}
|
|
308
|
+
if (input.events) {
|
|
309
|
+
if (slash !== DRIVER_DISPATCH_SLASH) {
|
|
310
|
+
return {
|
|
311
|
+
exitCode: 1,
|
|
312
|
+
error: `--events only applies to ${DRIVER_DISPATCH_SLASH} (and agent-kit run-plan)`
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const exitCode = await runDispatchDriver({
|
|
316
|
+
root,
|
|
317
|
+
slash: DRIVER_DISPATCH_SLASH,
|
|
318
|
+
backend: input.backend,
|
|
319
|
+
model: input.model,
|
|
320
|
+
dryRun: input.dryRun,
|
|
321
|
+
noHitl: input.noHitl === true,
|
|
322
|
+
landOnGate: input.landOnGate === true,
|
|
323
|
+
events: input.events,
|
|
324
|
+
whichFn: input.whichFn
|
|
325
|
+
});
|
|
326
|
+
return { exitCode };
|
|
327
|
+
}
|
|
83
328
|
const detected = await detectAgentBackend(input.backend, input.whichFn);
|
|
84
329
|
if (!detected.ok) {
|
|
85
330
|
return { exitCode: 1, error: detected.message };
|
|
@@ -136,7 +381,7 @@ async function executeRun(input) {
|
|
|
136
381
|
const stdout = [
|
|
137
382
|
"--dry-run: no agent will be started.",
|
|
138
383
|
`Slash: ${slash}`,
|
|
139
|
-
`Command file: ${
|
|
384
|
+
`Command file: ${path2.relative(root, file.path)}`,
|
|
140
385
|
`Backend: ${detected.id} (${displayPath(detected.bin)})`,
|
|
141
386
|
"Prompt:",
|
|
142
387
|
prompt
|
|
@@ -145,8 +390,8 @@ async function executeRun(input) {
|
|
|
145
390
|
}
|
|
146
391
|
const logPath = await ensureDispatchLogPath(root);
|
|
147
392
|
console.log(`Dispatch: ${slash} via ${detected.id}`);
|
|
148
|
-
console.log(`Command file: ${
|
|
149
|
-
console.log(`Log: ${
|
|
393
|
+
console.log(`Command file: ${path2.relative(root, file.path)}`);
|
|
394
|
+
console.log(`Log: ${path2.relative(root, logPath)}`);
|
|
150
395
|
try {
|
|
151
396
|
const dispatch = {
|
|
152
397
|
backendId: detected.id,
|
|
@@ -171,34 +416,16 @@ async function executeRun(input) {
|
|
|
171
416
|
});
|
|
172
417
|
for (const line of formatHitlSummary(result.hitl)) console.log(line);
|
|
173
418
|
const exitCode = hitlExitCode(result.exitCode, result.hitl);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
reason: stop?.message ?? `${detected.id} exited with code ${exitCode}`,
|
|
185
|
-
command: `run ${slash}`,
|
|
186
|
-
backend: detected.id,
|
|
187
|
-
logPath,
|
|
188
|
-
...stop ? { askId: stop.askId } : {},
|
|
189
|
-
...summary ? { summary } : {},
|
|
190
|
-
...result.lastResult ? {
|
|
191
|
-
gateText: [
|
|
192
|
-
result.lastResult.resultText,
|
|
193
|
-
...result.lastResult.assistantTexts
|
|
194
|
-
].join("\n")
|
|
195
|
-
} : {}
|
|
196
|
-
},
|
|
197
|
-
log: (line) => console.log(line)
|
|
198
|
-
});
|
|
199
|
-
} catch (err) {
|
|
200
|
-
console.log(`gate-exit: landing failed: ${String(err)}`);
|
|
201
|
-
}
|
|
419
|
+
if (input.landOnGate) {
|
|
420
|
+
await landDispatchOutcome({
|
|
421
|
+
root,
|
|
422
|
+
slash,
|
|
423
|
+
backendId: detected.id,
|
|
424
|
+
logPath,
|
|
425
|
+
exitCode,
|
|
426
|
+
result,
|
|
427
|
+
log: (line) => console.log(line)
|
|
428
|
+
});
|
|
202
429
|
}
|
|
203
430
|
return { exitCode };
|
|
204
431
|
} catch (err) {
|
|
@@ -275,6 +502,12 @@ async function runSlashCli(slash, args) {
|
|
|
275
502
|
process.exitCode = 1;
|
|
276
503
|
return;
|
|
277
504
|
}
|
|
505
|
+
const events = String(args.events ?? "");
|
|
506
|
+
if (events && !DRIVER_EVENTS_FORMATS.includes(events)) {
|
|
507
|
+
logger.error(`--events must be one of: ${DRIVER_EVENTS_FORMATS.join(", ")}`);
|
|
508
|
+
process.exitCode = 1;
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
278
511
|
const result = await executeRun({
|
|
279
512
|
slash,
|
|
280
513
|
cwd: String(args.cwd),
|
|
@@ -287,7 +520,8 @@ async function runSlashCli(slash, args) {
|
|
|
287
520
|
plain: Boolean(args.plain),
|
|
288
521
|
landOnGate: Boolean(args["land-on-gate"]),
|
|
289
522
|
...args["max-pack-bytes"] ? { maxPackBytes: String(args["max-pack-bytes"]) } : {},
|
|
290
|
-
...args["include-reviewed"] ? { includeReviewed: true } : {}
|
|
523
|
+
...args["include-reviewed"] ? { includeReviewed: true } : {},
|
|
524
|
+
...events ? { events: {} } : {}
|
|
291
525
|
});
|
|
292
526
|
if (result.stdout) {
|
|
293
527
|
console.log(result.stdout);
|
|
@@ -321,12 +555,20 @@ var runPlanAllCommand = defineCommand({
|
|
|
321
555
|
name: "run-plan-all",
|
|
322
556
|
description: "Headless /run-plan-all queue from the L0 file. Numbered-list HITL answered from the terminal (claude backend). Never git-prod."
|
|
323
557
|
},
|
|
324
|
-
args:
|
|
558
|
+
args: {
|
|
559
|
+
...runDispatchArgs,
|
|
560
|
+
events: {
|
|
561
|
+
type: "string",
|
|
562
|
+
description: "Driver mode for apps: `ndjson` writes only NDJSON events to stdout and reads HITL answers as JSON lines on stdin (no TTY needed; driver protocol 1.2.0, see docs/driver-events-protocol.md)",
|
|
563
|
+
default: ""
|
|
564
|
+
}
|
|
565
|
+
},
|
|
325
566
|
async run({ args }) {
|
|
326
567
|
await runSlashCli("run-plan-all", args);
|
|
327
568
|
}
|
|
328
569
|
});
|
|
329
570
|
export {
|
|
571
|
+
DRIVER_DISPATCH_SLASH,
|
|
330
572
|
displayPath,
|
|
331
573
|
executeRun,
|
|
332
574
|
runCommand,
|
package/package.json
CHANGED