@dadado/agent-kit-cli 6.10.1 → 6.11.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/{add-7GH3K44T.js → add-P4DIZKC2.js} +3 -3
- package/dist/{chunk-O5FKTKOW.js → chunk-2B3HHQ3L.js} +3 -3
- package/dist/{chunk-6LRY2CYU.js → chunk-47ZJ3S7M.js} +4 -1
- package/dist/{chunk-TUZVOPKY.js → chunk-5D5BJZW5.js} +75 -122
- package/dist/{chunk-BB22FGQ4.js → chunk-5KDMATUR.js} +1 -1
- package/dist/{chunk-6UKI4CAN.js → chunk-5TEXYAGP.js} +10 -1
- package/dist/{chunk-LPZ2KXVE.js → chunk-6GM5YUWR.js} +1 -1
- package/dist/chunk-7ABY6DYH.js +89 -0
- package/dist/{chunk-HVH24VRL.js → chunk-7T4MDNV3.js} +1 -1
- package/dist/{chunk-BSYQJ5WF.js → chunk-AOSXKF3M.js} +1 -1
- package/dist/{chunk-26KXYR5T.js → chunk-BOZUBCQA.js} +2 -2
- package/dist/{chunk-GQ6Q3P7C.js → chunk-CAOQBBP5.js} +2 -2
- package/dist/{chunk-LGSNC4OI.js → chunk-FQNAEFTW.js} +1 -1
- package/dist/{chunk-BIFWN6BJ.js → chunk-FTLMWPQY.js} +1 -1
- package/dist/{chunk-52WYZFP5.js → chunk-H3PQYVFT.js} +2 -2
- package/dist/{chunk-MTLQN57O.js → chunk-JPAQOESJ.js} +85 -1
- package/dist/{chunk-BZI5G3OZ.js → chunk-KHFPPQJ5.js} +35 -5
- package/dist/{chunk-75ELVLBY.js → chunk-MAXEVJCP.js} +1 -1
- package/dist/{chunk-ZF4YBL7F.js → chunk-Q4J5UXVQ.js} +1 -1
- package/dist/{chunk-CXDAT76O.js → chunk-S4T6KYYA.js} +2 -2
- package/dist/{chunk-TZA7MT4I.js → chunk-SZ5REXPD.js} +2 -2
- package/dist/chunk-UGJ3YAT2.js +273 -0
- package/dist/{chunk-HIJTNHJE.js → chunk-UQSFGLY5.js} +3 -3
- package/dist/{chunk-S7XAV6JK.js → chunk-VWDFMXFK.js} +5 -5
- package/dist/{chunk-K5OCGZWA.js → chunk-YN5NBMQT.js} +8 -8
- package/dist/{commands-EQHK3ZEP.js → commands-F437QCGQ.js} +5 -5
- package/dist/{contribute-VSVPRHQ7.js → contribute-G5DFZCH6.js} +4 -4
- package/dist/{countdown-XYRE4GZU.js → countdown-6SP7IEJ3.js} +7 -7
- package/dist/{diff-4P7LMQK5.js → diff-VCVSR4OV.js} +5 -5
- package/dist/{doctor-E6LOBJYK.js → doctor-5LPPWRPI.js} +9 -9
- package/dist/{engine-info-3MQML5I2.js → engine-info-LEE37RRK.js} +2 -2
- package/dist/{ground-control-726LRB6Q.js → ground-control-IJ5NQVLP.js} +4 -4
- package/dist/{hook-HJW5SXQG.js → hook-A22PNYY2.js} +5 -5
- package/dist/index.js +22 -20
- package/dist/{init-KKVT2RW4.js → init-VCOMQ32C.js} +12 -12
- package/dist/{install-BPZTP5KT.js → install-YXOE2U6T.js} +12 -12
- package/dist/queue-Q2LEPXSY.js +172 -0
- package/dist/{run-326EEQYY.js → run-BOWCPU56.js} +50 -271
- package/dist/{run-plan-2IFO4G4Y.js → run-plan-P65QMVCS.js} +8 -7
- package/dist/{setup-global-BFBSR2RZ.js → setup-global-QEEW7ASU.js} +6 -6
- package/dist/{status-LNXVLDMP.js → status-WGO2O7TR.js} +7 -7
- package/dist/{update-PX5XFCSG.js → update-LV335HJU.js} +10 -10
- package/package.json +20 -13
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
diffAgainstRegistry,
|
|
8
8
|
summarizeDiff
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2B3HHQ3L.js";
|
|
10
10
|
import {
|
|
11
11
|
DEFAULT_REGISTRY_URL,
|
|
12
12
|
assertSafeRegistrySource,
|
|
13
13
|
loadAgentKitManifest,
|
|
14
14
|
resolveRegistryRoot
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7T4MDNV3.js";
|
|
16
16
|
import {
|
|
17
17
|
KIT_PACKAGE_SPEC,
|
|
18
18
|
KIT_VERSION
|
|
@@ -52,6 +52,86 @@ var LineSplitter = class {
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
+
// src/plan-loop/token-usage.ts
|
|
56
|
+
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
57
|
+
var count = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 ? v : void 0;
|
|
58
|
+
var make = (input, cached, output) => ({
|
|
59
|
+
inputTokens: input,
|
|
60
|
+
cachedInputTokens: cached,
|
|
61
|
+
outputTokens: output,
|
|
62
|
+
totalTokens: input + output
|
|
63
|
+
});
|
|
64
|
+
function fromModelUsage(models) {
|
|
65
|
+
if (!isRecord(models)) return null;
|
|
66
|
+
let seen = false;
|
|
67
|
+
let input = 0;
|
|
68
|
+
let cached = 0;
|
|
69
|
+
let output = 0;
|
|
70
|
+
for (const m of Object.values(models)) {
|
|
71
|
+
if (!isRecord(m)) continue;
|
|
72
|
+
const i = count(m.inputTokens);
|
|
73
|
+
const o = count(m.outputTokens);
|
|
74
|
+
if (i === void 0 && o === void 0) continue;
|
|
75
|
+
seen = true;
|
|
76
|
+
const read = count(m.cacheReadInputTokens) ?? 0;
|
|
77
|
+
input += (i ?? 0) + read + (count(m.cacheCreationInputTokens) ?? 0);
|
|
78
|
+
cached += read;
|
|
79
|
+
output += o ?? 0;
|
|
80
|
+
}
|
|
81
|
+
return seen ? make(input, cached, output) : null;
|
|
82
|
+
}
|
|
83
|
+
function readResultUsage(event) {
|
|
84
|
+
const models = fromModelUsage(event.modelUsage);
|
|
85
|
+
if (models) return { usage: models, cumulative: true };
|
|
86
|
+
const u = event.usage;
|
|
87
|
+
if (!isRecord(u)) return null;
|
|
88
|
+
const i = count(u.input_tokens);
|
|
89
|
+
const o = count(u.output_tokens);
|
|
90
|
+
if (i === void 0 && o === void 0) return null;
|
|
91
|
+
const codexCached = count(u.cached_input_tokens);
|
|
92
|
+
if (codexCached !== void 0) {
|
|
93
|
+
return { usage: make(i ?? 0, codexCached, o ?? 0), cumulative: true };
|
|
94
|
+
}
|
|
95
|
+
const read = count(u.cache_read_input_tokens);
|
|
96
|
+
const write = count(u.cache_creation_input_tokens);
|
|
97
|
+
return {
|
|
98
|
+
usage: make((i ?? 0) + (read ?? 0) + (write ?? 0), read ?? null, o ?? 0),
|
|
99
|
+
cumulative: false
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function sumUsage(a, b) {
|
|
103
|
+
if (!a) return b;
|
|
104
|
+
if (!b) return a;
|
|
105
|
+
const cached = a.cachedInputTokens === null && b.cachedInputTokens === null ? null : (a.cachedInputTokens ?? 0) + (b.cachedInputTokens ?? 0);
|
|
106
|
+
return make(a.inputTokens + b.inputTokens, cached, a.outputTokens + b.outputTokens);
|
|
107
|
+
}
|
|
108
|
+
var UsageTally = class {
|
|
109
|
+
sessions = /* @__PURE__ */ new Map();
|
|
110
|
+
note(sessionId, report) {
|
|
111
|
+
if (!report) return;
|
|
112
|
+
const key = sessionId ?? "";
|
|
113
|
+
const prev = this.sessions.get(key);
|
|
114
|
+
if (report.cumulative || !prev) {
|
|
115
|
+
this.sessions.set(key, report);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (prev.cumulative) return;
|
|
119
|
+
this.sessions.set(key, {
|
|
120
|
+
cumulative: false,
|
|
121
|
+
usage: sumUsage(prev.usage, report.usage)
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/** Apply another tally's reports after this one's (a resumed child of the same tick). */
|
|
125
|
+
merge(other) {
|
|
126
|
+
for (const [key, report] of other.sessions) this.note(key, report);
|
|
127
|
+
}
|
|
128
|
+
total() {
|
|
129
|
+
let sum = null;
|
|
130
|
+
for (const report of this.sessions.values()) sum = sumUsage(sum, report.usage);
|
|
131
|
+
return sum;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
55
135
|
// src/plan-loop/hitl-relay.ts
|
|
56
136
|
var HITL_GATE_LINE_RE = /^HITL_GATE:\s*([a-z0-9-]+)\s*\|\s*(.+)$/;
|
|
57
137
|
var HITL_REPLY_PREFIX = "HITL_REPLY:";
|
|
@@ -354,7 +434,9 @@ var TurnWatcher = class {
|
|
|
354
434
|
isError: ev.is_error === true,
|
|
355
435
|
subtype: typeof ev.subtype === "string" ? ev.subtype : null,
|
|
356
436
|
errors: Array.isArray(ev.errors) ? ev.errors.filter((e) => typeof e === "string") : [],
|
|
357
|
-
backgroundTasks: this.backgroundTasks
|
|
437
|
+
backgroundTasks: this.backgroundTasks,
|
|
438
|
+
usage: readResultUsage(event),
|
|
439
|
+
sessionId: typeof ev.session_id === "string" ? ev.session_id : null
|
|
358
440
|
});
|
|
359
441
|
}
|
|
360
442
|
}
|
|
@@ -362,6 +444,8 @@ var TurnWatcher = class {
|
|
|
362
444
|
|
|
363
445
|
export {
|
|
364
446
|
LineSplitter,
|
|
447
|
+
sumUsage,
|
|
448
|
+
UsageTally,
|
|
365
449
|
RESERVED_GATE_IDS,
|
|
366
450
|
HITL_UNANSWERED_EXIT_CODE,
|
|
367
451
|
formatHitlGateLine,
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
redactSecrets,
|
|
14
14
|
resolveHitlRunOptions,
|
|
15
15
|
spawnLogged
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-5TEXYAGP.js";
|
|
17
17
|
import {
|
|
18
18
|
RESERVED_GATE_IDS
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-JPAQOESJ.js";
|
|
20
20
|
import {
|
|
21
21
|
ensureLoopLogsDir,
|
|
22
22
|
runnerStatePaths
|
|
@@ -73,13 +73,42 @@ function rewriteRootArgvToRun(argv) {
|
|
|
73
73
|
function commandMarkdownPath(root, name) {
|
|
74
74
|
return path.join(root, ".cursor", "commands", `${normalizeSlashName(name)}.md`);
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
var OPERATOR_NOTE_HEADING = "## Operator resolution note (`--note`)";
|
|
77
|
+
var OPERATOR_NOTE_PREAMBLE = "Operator context for this run, relayed verbatim. It is not an answer to any Ask: every gate you open still waits for a `HITL_REPLY:` line.";
|
|
78
|
+
function buildDispatchPrompt(commandBody, note) {
|
|
79
|
+
const lines = [
|
|
78
80
|
"Follow the Agent Kit command below. This session is headless: use numbered-list HITL (Ask questions is Cursor-only). Before each numbered list print one line `HITL_GATE: <ask-id> | <label 1> | <label 2> | ...` (ask-id and labels from the hitl-gates skill), then wait; the operator's answer arrives as `HITL_REPLY: <ask-id> | operator reply <n> | <label>`. Never /git-prod. No CLI --force promote.",
|
|
79
81
|
"",
|
|
80
82
|
commandBody.trimEnd(),
|
|
81
83
|
""
|
|
82
|
-
]
|
|
84
|
+
];
|
|
85
|
+
if (note?.trim()) {
|
|
86
|
+
lines.push(OPERATOR_NOTE_HEADING, "", OPERATOR_NOTE_PREAMBLE, "", note.trim(), "");
|
|
87
|
+
}
|
|
88
|
+
return lines.join("\n");
|
|
89
|
+
}
|
|
90
|
+
var NOTE_SENTINEL_RE = /^[ \t>]*(HITL_GATE|HITL_REPLY):/m;
|
|
91
|
+
async function resolveOperatorNote(raw, root) {
|
|
92
|
+
let text = raw;
|
|
93
|
+
if (raw.startsWith("@")) {
|
|
94
|
+
const rel = raw.slice(1).trim();
|
|
95
|
+
if (!rel) return { ok: false, message: "--note @<file>: missing file path" };
|
|
96
|
+
const file = path.resolve(root, rel);
|
|
97
|
+
try {
|
|
98
|
+
text = await readFile(file, "utf8");
|
|
99
|
+
} catch {
|
|
100
|
+
return { ok: false, message: `--note: cannot read ${rel}` };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!text.trim()) return { ok: false, message: "--note is empty" };
|
|
104
|
+
const sentinel = NOTE_SENTINEL_RE.exec(text);
|
|
105
|
+
if (sentinel) {
|
|
106
|
+
return {
|
|
107
|
+
ok: false,
|
|
108
|
+
message: `--note may not contain a ${sentinel[1]}: line (a note is operator context, never a gate or a reply)`
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return { ok: true, note: text };
|
|
83
112
|
}
|
|
84
113
|
function promoteBlockedMessage(name) {
|
|
85
114
|
const n = normalizeSlashName(name);
|
|
@@ -216,6 +245,7 @@ export {
|
|
|
216
245
|
classifySlash,
|
|
217
246
|
rewriteRootArgvToRun,
|
|
218
247
|
buildDispatchPrompt,
|
|
248
|
+
resolveOperatorNote,
|
|
219
249
|
promoteBlockedMessage,
|
|
220
250
|
unknownSlashMessage,
|
|
221
251
|
readCommandFile,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatHitlGateLine
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JPAQOESJ.js";
|
|
4
4
|
|
|
5
5
|
// src/plan-loop/driver-events.ts
|
|
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.3.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;
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
compareSemver,
|
|
6
6
|
normalizeSemver
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-H3PQYVFT.js";
|
|
8
8
|
import {
|
|
9
9
|
MANIFEST_RELATIVE_PATH
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-7T4MDNV3.js";
|
|
11
11
|
import {
|
|
12
12
|
KIT_VERSION,
|
|
13
13
|
pinnedCliSpec
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readRunQueueState
|
|
3
|
+
} from "./chunk-7ABY6DYH.js";
|
|
4
|
+
import {
|
|
5
|
+
DRIVER_PROTOCOL_VERSION,
|
|
6
|
+
DriverAgentSink,
|
|
7
|
+
createDriverAnswerReader,
|
|
8
|
+
createDriverEmitter,
|
|
9
|
+
driverReplies,
|
|
10
|
+
driverStop
|
|
11
|
+
} from "./chunk-S4T6KYYA.js";
|
|
12
|
+
import {
|
|
13
|
+
detectAgentBackend
|
|
14
|
+
} from "./chunk-5KDMATUR.js";
|
|
15
|
+
import {
|
|
16
|
+
classifyGateExit,
|
|
17
|
+
landGateExit
|
|
18
|
+
} from "./chunk-BOZUBCQA.js";
|
|
19
|
+
import {
|
|
20
|
+
buildDispatchPrompt,
|
|
21
|
+
ensureDispatchLogPath,
|
|
22
|
+
readCommandFile,
|
|
23
|
+
runHeadlessDispatch
|
|
24
|
+
} from "./chunk-KHFPPQJ5.js";
|
|
25
|
+
import {
|
|
26
|
+
formatHitlSummary,
|
|
27
|
+
hitlExitCode
|
|
28
|
+
} from "./chunk-JPAQOESJ.js";
|
|
29
|
+
import {
|
|
30
|
+
HANDOFF_REL
|
|
31
|
+
} from "./chunk-C4Q77GGJ.js";
|
|
32
|
+
|
|
33
|
+
// src/plan-loop/dispatch-driver.ts
|
|
34
|
+
import { readFile } from "fs/promises";
|
|
35
|
+
import path from "path";
|
|
36
|
+
var DISPATCH_DRIVER_TICK = 1;
|
|
37
|
+
var QUEUE_STATE_POLL_MS = 1e3;
|
|
38
|
+
function projectQueueState(handoff) {
|
|
39
|
+
const { queue, cursor, current, status } = readRunQueueState(handoff);
|
|
40
|
+
if (queue.length === 0) return { cursor: null, total: 0, current: null, status: null };
|
|
41
|
+
return { cursor, total: queue.length, current, status };
|
|
42
|
+
}
|
|
43
|
+
async function readHandoffText(root) {
|
|
44
|
+
try {
|
|
45
|
+
return await readFile(path.join(root, HANDOFF_REL), "utf8");
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function readQueueState(root) {
|
|
51
|
+
return projectQueueState(await readHandoffText(root) ?? "");
|
|
52
|
+
}
|
|
53
|
+
function createQueueStateWatcher(opts) {
|
|
54
|
+
const read = opts.read ?? (() => readHandoffText(opts.root));
|
|
55
|
+
let last = JSON.stringify(opts.initial);
|
|
56
|
+
let pending = null;
|
|
57
|
+
let busy = null;
|
|
58
|
+
let stopped = false;
|
|
59
|
+
const emit = (next, key) => {
|
|
60
|
+
last = key;
|
|
61
|
+
pending = null;
|
|
62
|
+
opts.emitter.emit({ type: "queue_state", ...next });
|
|
63
|
+
};
|
|
64
|
+
const sample = async () => {
|
|
65
|
+
const text = await read();
|
|
66
|
+
if (text !== null && text.trim() === "") return null;
|
|
67
|
+
const next = projectQueueState(text ?? "");
|
|
68
|
+
return { next, key: JSON.stringify(next) };
|
|
69
|
+
};
|
|
70
|
+
const check = async () => {
|
|
71
|
+
const got = await sample();
|
|
72
|
+
if (!got || stopped) return;
|
|
73
|
+
if (got.key === last) {
|
|
74
|
+
pending = null;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (got.key !== pending) {
|
|
78
|
+
pending = got.key;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
emit(got.next, got.key);
|
|
82
|
+
};
|
|
83
|
+
const tick = () => {
|
|
84
|
+
if (busy) return busy;
|
|
85
|
+
busy = check().finally(() => {
|
|
86
|
+
busy = null;
|
|
87
|
+
});
|
|
88
|
+
return busy;
|
|
89
|
+
};
|
|
90
|
+
opts.emitter.emit({ type: "queue_state", ...opts.initial });
|
|
91
|
+
const timer = setInterval(() => {
|
|
92
|
+
void tick();
|
|
93
|
+
}, opts.pollMs ?? QUEUE_STATE_POLL_MS);
|
|
94
|
+
timer.unref?.();
|
|
95
|
+
return {
|
|
96
|
+
flush: async () => {
|
|
97
|
+
if (busy) await busy;
|
|
98
|
+
const got = await sample();
|
|
99
|
+
if (!got || stopped || got.key === last) return;
|
|
100
|
+
emit(got.next, got.key);
|
|
101
|
+
},
|
|
102
|
+
stop: () => {
|
|
103
|
+
stopped = true;
|
|
104
|
+
clearInterval(timer);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async function landDispatchOutcome(opts) {
|
|
109
|
+
const { result } = opts;
|
|
110
|
+
const stop = result.hitl?.stop;
|
|
111
|
+
const trigger = classifyGateExit({ stop, failed: opts.exitCode !== 0 });
|
|
112
|
+
if (!trigger) return;
|
|
113
|
+
const summary = result.lastResult?.resultText.trim() || result.lastResult?.assistantTexts.at(-1)?.trim() || void 0;
|
|
114
|
+
try {
|
|
115
|
+
await landGateExit({
|
|
116
|
+
root: opts.root,
|
|
117
|
+
outcome: {
|
|
118
|
+
trigger,
|
|
119
|
+
exitCode: opts.exitCode,
|
|
120
|
+
reason: stop?.message ?? `${opts.backendId} exited with code ${opts.exitCode}`,
|
|
121
|
+
command: `run ${opts.slash}`,
|
|
122
|
+
backend: opts.backendId,
|
|
123
|
+
logPath: opts.logPath,
|
|
124
|
+
...stop ? { askId: stop.askId } : {},
|
|
125
|
+
...summary ? { summary } : {},
|
|
126
|
+
...result.lastResult ? {
|
|
127
|
+
gateText: [result.lastResult.resultText, ...result.lastResult.assistantTexts].join(
|
|
128
|
+
"\n"
|
|
129
|
+
)
|
|
130
|
+
} : {}
|
|
131
|
+
},
|
|
132
|
+
log: opts.log
|
|
133
|
+
});
|
|
134
|
+
} catch (err) {
|
|
135
|
+
opts.log(`gate-exit: landing failed: ${String(err)}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function runDispatchDriver(opts) {
|
|
139
|
+
const root = path.resolve(opts.root);
|
|
140
|
+
const emitter = createDriverEmitter(opts.events.write, opts.events.now);
|
|
141
|
+
const reader = createDriverAnswerReader({
|
|
142
|
+
input: opts.events.input,
|
|
143
|
+
emitter,
|
|
144
|
+
tick: () => DISPATCH_DRIVER_TICK
|
|
145
|
+
});
|
|
146
|
+
const writeErr = opts.events.writeErr ?? ((text) => {
|
|
147
|
+
process.stderr.write(text);
|
|
148
|
+
});
|
|
149
|
+
const say = (message, level = "info") => emitter.emit({ type: "log", level, message });
|
|
150
|
+
let ticks = 0;
|
|
151
|
+
let queue = null;
|
|
152
|
+
const finish = async (exitCode, reason, result) => {
|
|
153
|
+
if (queue) {
|
|
154
|
+
await queue.flush();
|
|
155
|
+
queue.stop();
|
|
156
|
+
}
|
|
157
|
+
emitter.emit({
|
|
158
|
+
type: "run_end",
|
|
159
|
+
exitCode,
|
|
160
|
+
ticks,
|
|
161
|
+
pending: null,
|
|
162
|
+
reason,
|
|
163
|
+
planExhausted: false,
|
|
164
|
+
replies: driverReplies(result?.hitl?.replies),
|
|
165
|
+
stop: driverStop(result?.hitl?.stop),
|
|
166
|
+
usage: result?.usage?.total() ?? null
|
|
167
|
+
});
|
|
168
|
+
reader.close();
|
|
169
|
+
return exitCode;
|
|
170
|
+
};
|
|
171
|
+
const detected = await detectAgentBackend(opts.backend, opts.whichFn);
|
|
172
|
+
if (!detected.ok) {
|
|
173
|
+
say(detected.message, "error");
|
|
174
|
+
return finish(1, detected.message);
|
|
175
|
+
}
|
|
176
|
+
const file = await readCommandFile(root, opts.slash);
|
|
177
|
+
if (!file.ok) {
|
|
178
|
+
say(file.message, "error");
|
|
179
|
+
return finish(1, file.message);
|
|
180
|
+
}
|
|
181
|
+
const prompt = buildDispatchPrompt(file.body, opts.note);
|
|
182
|
+
const initialQueue = await readQueueState(root);
|
|
183
|
+
emitter.emit({
|
|
184
|
+
type: "run_start",
|
|
185
|
+
protocol: DRIVER_PROTOCOL_VERSION,
|
|
186
|
+
command: opts.slash,
|
|
187
|
+
backend: detected.id,
|
|
188
|
+
plan: null,
|
|
189
|
+
pending: null,
|
|
190
|
+
maxTicks: null,
|
|
191
|
+
hitl: opts.noHitl ? "off" : "driver",
|
|
192
|
+
queue: initialQueue
|
|
193
|
+
});
|
|
194
|
+
queue = createQueueStateWatcher({
|
|
195
|
+
root,
|
|
196
|
+
emitter,
|
|
197
|
+
initial: initialQueue,
|
|
198
|
+
pollMs: opts.queuePollMs
|
|
199
|
+
});
|
|
200
|
+
say(`Dispatch: ${opts.slash} via ${detected.id}`);
|
|
201
|
+
say(`Command file: ${path.relative(root, file.path)}`);
|
|
202
|
+
if (opts.dryRun) {
|
|
203
|
+
say("--dry-run: no agent will be started. Prompt:");
|
|
204
|
+
say(prompt);
|
|
205
|
+
return finish(0, "dry-run");
|
|
206
|
+
}
|
|
207
|
+
const logPath = await ensureDispatchLogPath(root);
|
|
208
|
+
say(`Log: ${path.relative(root, logPath)}`);
|
|
209
|
+
const onSigInt = () => {
|
|
210
|
+
queue?.stop();
|
|
211
|
+
emitter.emit({
|
|
212
|
+
type: "run_end",
|
|
213
|
+
exitCode: 130,
|
|
214
|
+
ticks,
|
|
215
|
+
pending: null,
|
|
216
|
+
reason: "interrupted (SIGINT)",
|
|
217
|
+
planExhausted: false,
|
|
218
|
+
usage: null
|
|
219
|
+
});
|
|
220
|
+
process.exit(130);
|
|
221
|
+
};
|
|
222
|
+
process.on("SIGINT", onSigInt);
|
|
223
|
+
try {
|
|
224
|
+
ticks = DISPATCH_DRIVER_TICK;
|
|
225
|
+
let result;
|
|
226
|
+
try {
|
|
227
|
+
result = await runHeadlessDispatch({
|
|
228
|
+
backendId: detected.id,
|
|
229
|
+
bin: detected.bin,
|
|
230
|
+
workspace: root,
|
|
231
|
+
prompt,
|
|
232
|
+
model: opts.model,
|
|
233
|
+
logPath,
|
|
234
|
+
spawnFn: opts.spawnFn,
|
|
235
|
+
versionFn: opts.versionFn,
|
|
236
|
+
log: (line) => say(line),
|
|
237
|
+
render: new DriverAgentSink(emitter, DISPATCH_DRIVER_TICK),
|
|
238
|
+
hitl: {
|
|
239
|
+
policy: opts.noHitl ? "off" : "driver",
|
|
240
|
+
readAnswer: reader.read,
|
|
241
|
+
write: writeErr
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
} catch (err) {
|
|
245
|
+
say(String(err), "error");
|
|
246
|
+
return finish(1, `${opts.slash} failed to start: ${String(err)}`);
|
|
247
|
+
}
|
|
248
|
+
for (const line of formatHitlSummary(result.hitl)) say(line);
|
|
249
|
+
const exitCode = hitlExitCode(result.exitCode, result.hitl);
|
|
250
|
+
if (opts.landOnGate) {
|
|
251
|
+
await landDispatchOutcome({
|
|
252
|
+
root,
|
|
253
|
+
slash: opts.slash,
|
|
254
|
+
backendId: detected.id,
|
|
255
|
+
logPath,
|
|
256
|
+
exitCode,
|
|
257
|
+
result,
|
|
258
|
+
log: (line) => say(line, "warn")
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
const stop = result.hitl?.stop;
|
|
262
|
+
const reason = stop ? stop.message : exitCode === 0 ? "session ended" : `${detected.id} exited with code ${exitCode}`;
|
|
263
|
+
return finish(exitCode, reason, result);
|
|
264
|
+
} finally {
|
|
265
|
+
process.off("SIGINT", onSigInt);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export {
|
|
270
|
+
readHandoffText,
|
|
271
|
+
landDispatchOutcome,
|
|
272
|
+
runDispatchDriver
|
|
273
|
+
};
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
compareSemver,
|
|
3
3
|
normalizeSemver,
|
|
4
4
|
readLocalKitVersion
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-H3PQYVFT.js";
|
|
6
6
|
import {
|
|
7
7
|
L0_ARTIFACTS
|
|
8
8
|
} from "./chunk-2KIOZMTV.js";
|
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
mergeStats,
|
|
16
16
|
recordOutcome,
|
|
17
17
|
resolveProtectedGlobs
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-7T4MDNV3.js";
|
|
19
19
|
import {
|
|
20
20
|
loadManagedHashLedger,
|
|
21
21
|
saveManagedHashLedger
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-47ZJ3S7M.js";
|
|
23
23
|
import {
|
|
24
24
|
KIT_PACKAGE_SPEC,
|
|
25
25
|
KIT_VERSION
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isBranchInBase
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AOSXKF3M.js";
|
|
4
4
|
import {
|
|
5
5
|
GATE_EXIT_BRANCH_PREFIX,
|
|
6
6
|
GATE_EXIT_NOTE_DIR,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
isSafeBaseRef,
|
|
12
12
|
landGateExit,
|
|
13
13
|
resolveGateExitRefs
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BOZUBCQA.js";
|
|
15
15
|
import {
|
|
16
16
|
ensurePathIgnored
|
|
17
17
|
} from "./chunk-MUTTNRX4.js";
|
|
@@ -19,14 +19,14 @@ import {
|
|
|
19
19
|
ensureDispatchLogPath,
|
|
20
20
|
readCommandFile,
|
|
21
21
|
runHeadlessDispatch
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-KHFPPQJ5.js";
|
|
23
23
|
import {
|
|
24
24
|
redactSecrets
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-5TEXYAGP.js";
|
|
26
26
|
import {
|
|
27
27
|
formatHitlSummary,
|
|
28
28
|
hitlExitCode
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-JPAQOESJ.js";
|
|
30
30
|
|
|
31
31
|
// src/plan-loop/review-job.ts
|
|
32
32
|
import { randomBytes } from "crypto";
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
formatStaleCliRefusal,
|
|
7
7
|
installL0,
|
|
8
8
|
syncFromManifest
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-UQSFGLY5.js";
|
|
10
10
|
import {
|
|
11
11
|
SkippedSymlinkError,
|
|
12
12
|
formatPersonalizationSkippedSymlinks,
|
|
@@ -15,21 +15,21 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
REGISTRY_CLI_ARGS,
|
|
17
17
|
resolveRegistryFromCli
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-MAXEVJCP.js";
|
|
19
19
|
import {
|
|
20
20
|
assessClaudeCommandAdapters,
|
|
21
21
|
executeSafeReadinessFixes
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-CAOQBBP5.js";
|
|
23
23
|
import {
|
|
24
24
|
writeReadinessSnapshot
|
|
25
25
|
} from "./chunk-HAFRAXGV.js";
|
|
26
26
|
import {
|
|
27
27
|
writeClaudeSessionStartHook
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-Q4J5UXVQ.js";
|
|
29
29
|
import {
|
|
30
30
|
CLAUDE_HITL_FALLBACK,
|
|
31
31
|
generateClaudeCommandAdapters
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-FQNAEFTW.js";
|
|
33
33
|
import {
|
|
34
34
|
shouldUseWelcomeColor,
|
|
35
35
|
withCliProgress
|
|
@@ -56,13 +56,13 @@ import {
|
|
|
56
56
|
npxPinned,
|
|
57
57
|
pathCliStatus,
|
|
58
58
|
syncPathCliToRuntime
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-SZ5REXPD.js";
|
|
60
60
|
import {
|
|
61
61
|
assessEnvironment
|
|
62
62
|
} from "./chunk-B3VR5YBQ.js";
|
|
63
63
|
import {
|
|
64
64
|
warnIfRunningCliBehindNpm
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-H3PQYVFT.js";
|
|
66
66
|
import {
|
|
67
67
|
DOMAIN_PACK_IDS,
|
|
68
68
|
allPacks,
|
|
@@ -79,7 +79,7 @@ import {
|
|
|
79
79
|
resolveProtectedGlobs,
|
|
80
80
|
saveManifest,
|
|
81
81
|
skillTargetDir
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-7T4MDNV3.js";
|
|
83
83
|
import {
|
|
84
84
|
KIT_VERSION,
|
|
85
85
|
pinnedCliSpec
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RUN_CATALOG
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-KHFPPQJ5.js";
|
|
4
|
+
import "./chunk-5TEXYAGP.js";
|
|
5
|
+
import "./chunk-JPAQOESJ.js";
|
|
6
6
|
import {
|
|
7
7
|
discoverInstalledCommands
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-FQNAEFTW.js";
|
|
9
9
|
import "./chunk-WGLPZXNU.js";
|
|
10
10
|
import "./chunk-6RRG3WOE.js";
|
|
11
11
|
import "./chunk-QTON2GQX.js";
|
|
12
12
|
import {
|
|
13
13
|
L0_ARTIFACTS
|
|
14
14
|
} from "./chunk-2KIOZMTV.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-47ZJ3S7M.js";
|
|
16
16
|
import {
|
|
17
17
|
KIT_VERSION
|
|
18
18
|
} from "./chunk-7HDQEK6T.js";
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
REGISTRY_CLI_ARGS,
|
|
3
3
|
resolveRegistryFromCli
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MAXEVJCP.js";
|
|
5
5
|
import {
|
|
6
6
|
logger
|
|
7
7
|
} from "./chunk-ZB43YMHW.js";
|
|
8
8
|
import {
|
|
9
9
|
managedPairs
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6GM5YUWR.js";
|
|
11
11
|
import "./chunk-2KIOZMTV.js";
|
|
12
12
|
import {
|
|
13
13
|
loadAgentKitManifest,
|
|
14
14
|
normalizeRelPath
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7T4MDNV3.js";
|
|
16
16
|
import {
|
|
17
17
|
resolveContained
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-47ZJ3S7M.js";
|
|
19
19
|
import "./chunk-C4Q77GGJ.js";
|
|
20
20
|
import "./chunk-5B4DVO6C.js";
|
|
21
21
|
|