@dadado/agent-kit-cli 6.3.0 → 6.4.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/dashboard/dashboard-data.mjs +14 -2
- package/dashboard/dashboard.html +139 -4
- package/dashboard/lib/chat-sessions.d.mts +63 -0
- package/dashboard/lib/chat-sessions.mjs +430 -0
- package/dashboard/serve.mjs +5 -1
- package/dist/{add-VA2W7I6P.js → add-HFDX3U3R.js} +2 -2
- package/dist/{chunk-6GYKOHIL.js → chunk-3OM7JODZ.js} +2 -2
- package/dist/{chunk-Z7RYIHHX.js → chunk-6OTJEQEC.js} +3 -3
- package/dist/{chunk-MAPOQEA2.js → chunk-6RRG3WOE.js} +8 -1
- package/dist/{chunk-6KUSG7BJ.js → chunk-7BEHUBEJ.js} +3 -1
- package/dist/{chunk-VQBI3JVS.js → chunk-ANPSYWQO.js} +2 -2
- package/dist/{chunk-WMVMBPCR.js → chunk-AXLXEAVJ.js} +1 -1
- package/dist/{chunk-25J2SMJQ.js → chunk-E465FAWM.js} +1 -1
- package/dist/{chunk-U26MRIWN.js → chunk-H46W7NHC.js} +1 -1
- package/dist/{chunk-NNKOWUWM.js → chunk-HHR56LJQ.js} +64 -28
- package/dist/{chunk-SV2BR2LZ.js → chunk-IMIVTDMK.js} +7 -7
- package/dist/chunk-IRTS7WEA.js +374 -0
- package/dist/{chunk-MO63KZBP.js → chunk-KX3OUY4W.js} +8 -6
- package/dist/chunk-MWTXI6C5.js +223 -0
- package/dist/{chunk-JEI6HACW.js → chunk-NJVWTROP.js} +24 -377
- package/dist/{chunk-OVOXRH5W.js → chunk-Q4PCMRM5.js} +1 -1
- package/dist/{chunk-GUQYNUV4.js → chunk-R7DA4KXG.js} +1 -1
- package/dist/{chunk-OWWFKGKS.js → chunk-SE7ZIRLX.js} +2 -2
- package/dist/{chunk-KVY425NM.js → chunk-TZ5XYIEF.js} +4 -2
- package/dist/{chunk-Z7ABX5QI.js → chunk-WOHZ4T5V.js} +4 -2
- package/dist/{chunk-YRFSTHR5.js → chunk-XEEB4YSA.js} +13 -219
- package/dist/{chunk-QTBTKEXK.js → chunk-ZPZVROS5.js} +1 -1
- package/dist/{contribute-NLM2BN6Z.js → contribute-PP7HMPW7.js} +3 -3
- package/dist/{countdown-QXJD6TDB.js → countdown-LAUZMI7U.js} +10 -8
- package/dist/{diff-HHG4JEDE.js → diff-HYWC4G6Y.js} +4 -4
- package/dist/{doctor-TWF2M3S3.js → doctor-2X3HBRJJ.js} +8 -8
- package/dist/engine-info-4ZWEIHSX.js +89 -0
- package/dist/{ground-control-NMYYIVCV.js → ground-control-WKV2BMOW.js} +5 -4
- package/dist/{guard-EHXF76ID.js → guard-ZZRQW3DJ.js} +107 -8
- package/dist/{hook-VP7FHRSZ.js → hook-UEYR4M3Z.js} +10 -4
- package/dist/index.js +26 -22
- package/dist/{init-UOTV4ASJ.js → init-UF5VEIJX.js} +11 -11
- package/dist/{install-VCHPXQV3.js → install-6ILVA22C.js} +11 -11
- package/dist/{run-R66G276Q.js → run-2EKD2BEC.js} +12 -9
- package/dist/{run-plan-24Z5K4P3.js → run-plan-G72XMC5Z.js} +11 -7
- package/dist/sessions-O7MYEMCT.js +343 -0
- package/dist/{setup-global-M6LKGJHQ.js → setup-global-ZZEY5KWE.js} +5 -5
- package/dist/{status-5UKVIKOI.js → status-4LK2QXVQ.js} +6 -6
- package/dist/{update-VQBGEUWS.js → update-FPR2NZND.js} +9 -9
- package/package.json +1 -1
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LineSplitter,
|
|
3
|
+
TurnWatcher,
|
|
4
|
+
askOperator,
|
|
5
|
+
createTerminalAnswerReader,
|
|
6
|
+
detectHitlGate,
|
|
7
|
+
emptyHitlRecord,
|
|
8
|
+
noRelayStop,
|
|
9
|
+
unansweredStop,
|
|
10
|
+
userEventLine
|
|
11
|
+
} from "./chunk-IRTS7WEA.js";
|
|
1
12
|
import {
|
|
2
13
|
findOnPath
|
|
3
14
|
} from "./chunk-WGLPZXNU.js";
|
|
4
15
|
import {
|
|
5
16
|
HEADLESS_DENY_RULES
|
|
6
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-6RRG3WOE.js";
|
|
7
18
|
import {
|
|
8
19
|
HELMET_ACCENT,
|
|
9
20
|
LABEL_MUTED,
|
|
@@ -15,368 +26,12 @@ import {
|
|
|
15
26
|
withKoloristColor
|
|
16
27
|
} from "./chunk-QTON2GQX.js";
|
|
17
28
|
|
|
18
|
-
// src/plan-loop/hitl-relay.ts
|
|
19
|
-
import { createInterface } from "readline";
|
|
20
|
-
import { StringDecoder } from "string_decoder";
|
|
21
|
-
|
|
22
|
-
// src/plan-loop/line-splitter.ts
|
|
23
|
-
var PENDING_MAX_CHARS = 4 * 1024 * 1024;
|
|
24
|
-
var LineSplitter = class {
|
|
25
|
-
constructor(maxChars = PENDING_MAX_CHARS) {
|
|
26
|
-
this.maxChars = maxChars;
|
|
27
|
-
}
|
|
28
|
-
maxChars;
|
|
29
|
-
parts = [];
|
|
30
|
-
length = 0;
|
|
31
|
-
dropping = false;
|
|
32
|
-
/** Calls `onLine` for every line the chunk completes (without the `\n`). */
|
|
33
|
-
feed(text, onLine) {
|
|
34
|
-
let start = 0;
|
|
35
|
-
let nl = text.indexOf("\n", start);
|
|
36
|
-
while (nl !== -1) {
|
|
37
|
-
const segment = text.slice(start, nl);
|
|
38
|
-
if (this.dropping) {
|
|
39
|
-
this.dropping = false;
|
|
40
|
-
} else if (this.parts.length === 0) {
|
|
41
|
-
onLine(segment);
|
|
42
|
-
} else {
|
|
43
|
-
this.parts.push(segment);
|
|
44
|
-
const line3 = this.parts.join("");
|
|
45
|
-
this.parts = [];
|
|
46
|
-
this.length = 0;
|
|
47
|
-
onLine(line3);
|
|
48
|
-
}
|
|
49
|
-
start = nl + 1;
|
|
50
|
-
nl = text.indexOf("\n", start);
|
|
51
|
-
}
|
|
52
|
-
if (start >= text.length || this.dropping) return;
|
|
53
|
-
const tail = start === 0 ? text : text.slice(start);
|
|
54
|
-
this.parts.push(tail);
|
|
55
|
-
this.length += tail.length;
|
|
56
|
-
if (this.length > this.maxChars) {
|
|
57
|
-
this.parts = [];
|
|
58
|
-
this.length = 0;
|
|
59
|
-
this.dropping = true;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/** The held partial line ("" when none or when it was dropped); resets. */
|
|
63
|
-
end() {
|
|
64
|
-
const rest = this.dropping ? "" : this.parts.join("");
|
|
65
|
-
this.parts = [];
|
|
66
|
-
this.length = 0;
|
|
67
|
-
this.dropping = false;
|
|
68
|
-
return rest;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// src/plan-loop/hitl-relay.ts
|
|
73
|
-
var HITL_GATE_LINE_RE = /^HITL_GATE:\s*([a-z0-9-]+)\s*\|\s*(.+)$/;
|
|
74
|
-
var HITL_REPLY_PREFIX = "HITL_REPLY:";
|
|
75
|
-
var RESERVED_GATE_IDS = ["git-prod", "kit-prod"];
|
|
76
|
-
var FALLBACK_ASK_ID = "prose-fallback";
|
|
77
|
-
var HITL_UNANSWERED_EXIT_CODE = 4;
|
|
78
|
-
var HITL_SIGINT_EXIT_CODE = 130;
|
|
79
|
-
var NUMBERED_LINE_RE = /^\s*(\d+)\.\s+(.+?)\s*$/;
|
|
80
|
-
var FALLBACK_WORDING_RES = [
|
|
81
|
-
/reply with (?:the |a )?number/i,
|
|
82
|
-
/ask questions is not available/i,
|
|
83
|
-
/skip or cancel means stop/i
|
|
84
|
-
];
|
|
85
|
-
var TICK_SENTINEL_RE = /LOOP_TICK_RESULT:/;
|
|
86
|
-
function parseHitlGateLine(line3) {
|
|
87
|
-
const m = HITL_GATE_LINE_RE.exec(line3.trim());
|
|
88
|
-
if (!m?.[1] || !m[2]) return null;
|
|
89
|
-
const labels = m[2].split("|").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
90
|
-
if (labels.length === 0) return null;
|
|
91
|
-
return { askId: m[1], labels, detection: "sentinel" };
|
|
92
|
-
}
|
|
93
|
-
function formatHitlGateLine(gate) {
|
|
94
|
-
return `HITL_GATE: ${gate.askId} | ${gate.labels.join(" | ")}`;
|
|
95
|
-
}
|
|
96
|
-
function findHitlGateInText(text) {
|
|
97
|
-
let last = null;
|
|
98
|
-
for (const line3 of text.split(/\r?\n/)) {
|
|
99
|
-
const gate = parseHitlGateLine(line3);
|
|
100
|
-
if (gate) last = gate;
|
|
101
|
-
}
|
|
102
|
-
return last;
|
|
103
|
-
}
|
|
104
|
-
function cleanFallbackLabel(raw) {
|
|
105
|
-
let label = raw.trim();
|
|
106
|
-
const bold = /^\*\*(.+?)\*\*/.exec(label);
|
|
107
|
-
if (bold?.[1]) label = bold[1];
|
|
108
|
-
else label = label.replace(/\*\*/g, "").replace(/^`(.+)`$/, "$1");
|
|
109
|
-
label = label.split(/\s+[—–]\s+/)[0] ?? label;
|
|
110
|
-
return label.replace(/[.:]+$/, "").trim();
|
|
111
|
-
}
|
|
112
|
-
function detectFallbackGate(text) {
|
|
113
|
-
if (!FALLBACK_WORDING_RES.some((re) => re.test(text))) return null;
|
|
114
|
-
const labels = [];
|
|
115
|
-
let expected = 1;
|
|
116
|
-
for (const line3 of text.split(/\r?\n/)) {
|
|
117
|
-
const m = NUMBERED_LINE_RE.exec(line3);
|
|
118
|
-
if (!m?.[1] || !m[2]) continue;
|
|
119
|
-
const n = Number(m[1]);
|
|
120
|
-
if (n === 1) {
|
|
121
|
-
labels.length = 0;
|
|
122
|
-
expected = 1;
|
|
123
|
-
}
|
|
124
|
-
if (n !== expected) continue;
|
|
125
|
-
labels.push(cleanFallbackLabel(m[2]));
|
|
126
|
-
expected += 1;
|
|
127
|
-
}
|
|
128
|
-
if (labels.length < 2) return null;
|
|
129
|
-
return { askId: FALLBACK_ASK_ID, labels, detection: "fallback" };
|
|
130
|
-
}
|
|
131
|
-
function detectHitlGate(resultText, assistantTexts) {
|
|
132
|
-
if (TICK_SENTINEL_RE.test(resultText)) return null;
|
|
133
|
-
const fromResult = findHitlGateInText(resultText);
|
|
134
|
-
if (fromResult) return fromResult;
|
|
135
|
-
for (let i = assistantTexts.length - 1; i >= 0; i -= 1) {
|
|
136
|
-
const text = assistantTexts[i] ?? "";
|
|
137
|
-
if (TICK_SENTINEL_RE.test(text)) return null;
|
|
138
|
-
const gate = findHitlGateInText(text);
|
|
139
|
-
if (gate) return gate;
|
|
140
|
-
}
|
|
141
|
-
const fallback = detectFallbackGate(resultText);
|
|
142
|
-
if (fallback) return fallback;
|
|
143
|
-
for (let i = assistantTexts.length - 1; i >= 0; i -= 1) {
|
|
144
|
-
const gate = detectFallbackGate(assistantTexts[i] ?? "");
|
|
145
|
-
if (gate) return gate;
|
|
146
|
-
}
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
function isReservedGateId(askId) {
|
|
150
|
-
return RESERVED_GATE_IDS.includes(askId);
|
|
151
|
-
}
|
|
152
|
-
var STOP_WORDS = /* @__PURE__ */ new Set(["skip", "cancel"]);
|
|
153
|
-
function resolveOperatorAnswer(input, labels) {
|
|
154
|
-
const text = input.trim();
|
|
155
|
-
if (!text) return { kind: "stop", cause: "empty" };
|
|
156
|
-
const exact = labels.indexOf(text);
|
|
157
|
-
if (exact !== -1) return { kind: "reply", n: exact + 1, label: labels[exact] ?? text };
|
|
158
|
-
if (/^\d+$/.test(text)) {
|
|
159
|
-
const n = Number(text);
|
|
160
|
-
const label = labels[n - 1];
|
|
161
|
-
if (n >= 1 && label !== void 0) return { kind: "reply", n, label };
|
|
162
|
-
}
|
|
163
|
-
const lower = text.toLowerCase();
|
|
164
|
-
if (STOP_WORDS.has(lower)) return { kind: "stop", cause: lower };
|
|
165
|
-
return { kind: "other", text };
|
|
166
|
-
}
|
|
167
|
-
function formatHitlReply(askId, answer) {
|
|
168
|
-
if (answer.kind === "reply") {
|
|
169
|
-
return `${HITL_REPLY_PREFIX} ${askId} | operator reply ${answer.n} | ${answer.label}`;
|
|
170
|
-
}
|
|
171
|
-
if (answer.kind === "other") {
|
|
172
|
-
return `${HITL_REPLY_PREFIX} ${askId} | operator reply other | ${answer.text}`;
|
|
173
|
-
}
|
|
174
|
-
throw new Error("a stop answer has no reply stamp");
|
|
175
|
-
}
|
|
176
|
-
function createTerminalAnswerReader(opts = {}) {
|
|
177
|
-
return (_gate, readOpts) => new Promise((resolve) => {
|
|
178
|
-
const input = opts.input ?? process.stdin;
|
|
179
|
-
const output = opts.output ?? process.stdout;
|
|
180
|
-
const terminal = opts.terminal ?? Boolean(input.isTTY);
|
|
181
|
-
const rl = createInterface({ input, output, terminal });
|
|
182
|
-
let settled = false;
|
|
183
|
-
const finish = (answer) => {
|
|
184
|
-
if (settled) return;
|
|
185
|
-
settled = true;
|
|
186
|
-
readOpts.signal?.removeEventListener("abort", onAbort);
|
|
187
|
-
rl.close();
|
|
188
|
-
if (typeof input.pause === "function") {
|
|
189
|
-
input.pause();
|
|
190
|
-
}
|
|
191
|
-
resolve(answer);
|
|
192
|
-
};
|
|
193
|
-
const onAbort = () => finish({ kind: "eof" });
|
|
194
|
-
if (readOpts.signal?.aborted) {
|
|
195
|
-
onAbort();
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
readOpts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
199
|
-
rl.on("SIGINT", () => finish({ kind: "sigint" }));
|
|
200
|
-
rl.on("close", () => finish({ kind: "eof" }));
|
|
201
|
-
rl.question("> ", (line3) => finish({ kind: "line", text: line3 }));
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
function emptyHitlRecord() {
|
|
205
|
-
return { replies: [], fallbackDetections: 0 };
|
|
206
|
-
}
|
|
207
|
-
function operatorStop(askId, cause) {
|
|
208
|
-
return {
|
|
209
|
-
askId,
|
|
210
|
-
cause,
|
|
211
|
-
message: `stopped-by-operator: gate ${askId}, no reply (${cause})`,
|
|
212
|
-
exitCode: cause === "SIGINT" ? HITL_SIGINT_EXIT_CODE : HITL_UNANSWERED_EXIT_CODE
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
function operatorQuitStop(key) {
|
|
216
|
-
return {
|
|
217
|
-
askId: "none",
|
|
218
|
-
cause: "quit",
|
|
219
|
-
message: `stopped-by-operator: quit (${key}), no gate open`,
|
|
220
|
-
exitCode: HITL_SIGINT_EXIT_CODE
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
function unansweredStop(askId, cause) {
|
|
224
|
-
return {
|
|
225
|
-
askId,
|
|
226
|
-
cause,
|
|
227
|
-
message: `stopped: unanswered gate (${cause})`,
|
|
228
|
-
exitCode: HITL_UNANSWERED_EXIT_CODE
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
function driverStop(askId, raw) {
|
|
232
|
-
const detail = raw.detail ? `: ${raw.detail}` : "";
|
|
233
|
-
return {
|
|
234
|
-
askId,
|
|
235
|
-
cause: raw.cause,
|
|
236
|
-
message: raw.cause === "driver stop" ? `stopped-by-operator: gate ${askId}, no reply (driver stop)` : `stopped: unanswered gate (driver protocol error${detail})`,
|
|
237
|
-
exitCode: HITL_UNANSWERED_EXIT_CODE
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
function noRelayStop(askId, backend) {
|
|
241
|
-
return {
|
|
242
|
-
askId,
|
|
243
|
-
cause: "no relay",
|
|
244
|
-
message: `stopped: unanswered gate (backend ${backend} has no relay)`,
|
|
245
|
-
exitCode: HITL_UNANSWERED_EXIT_CODE
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
function reservedStop(askId) {
|
|
249
|
-
return {
|
|
250
|
-
askId,
|
|
251
|
-
cause: "reserved",
|
|
252
|
-
message: `stopped: gate ${askId} is operator-gated; run the /${askId} slash yourself (never headless)`,
|
|
253
|
-
exitCode: HITL_UNANSWERED_EXIT_CODE
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
function formatGatePrompt(gate) {
|
|
257
|
-
const head = gate.detection === "fallback" ? `HITL gate (prose fallback, ask-id ${gate.askId})` : `HITL gate ${gate.askId}`;
|
|
258
|
-
const lines = [
|
|
259
|
-
"",
|
|
260
|
-
`${head}: reply with the number or the label; anything else is sent as "other"; empty, skip, cancel or Ctrl-C stops the run.`,
|
|
261
|
-
...gate.labels.map((label, i) => ` ${i + 1}. ${label}`)
|
|
262
|
-
];
|
|
263
|
-
return `${lines.join("\n")}
|
|
264
|
-
`;
|
|
265
|
-
}
|
|
266
|
-
async function askOperator(gate, opts) {
|
|
267
|
-
if (isReservedGateId(gate.askId)) return { kind: "stop", stop: reservedStop(gate.askId) };
|
|
268
|
-
if (opts.policy === "off") return { kind: "stop", stop: unansweredStop(gate.askId, "--no-hitl") };
|
|
269
|
-
if (!opts.isTTY && opts.policy !== "driver") {
|
|
270
|
-
return { kind: "stop", stop: unansweredStop(gate.askId, "no TTY") };
|
|
271
|
-
}
|
|
272
|
-
opts.onPromptStart?.();
|
|
273
|
-
let raw;
|
|
274
|
-
try {
|
|
275
|
-
opts.write(formatGatePrompt(gate));
|
|
276
|
-
raw = await opts.readAnswer(gate, { signal: opts.signal });
|
|
277
|
-
} finally {
|
|
278
|
-
opts.onPromptEnd?.();
|
|
279
|
-
}
|
|
280
|
-
if (opts.signal?.aborted) {
|
|
281
|
-
return { kind: "stop", stop: unansweredStop(gate.askId, "child exited") };
|
|
282
|
-
}
|
|
283
|
-
if (raw.kind === "eof") return { kind: "stop", stop: operatorStop(gate.askId, "EOF") };
|
|
284
|
-
if (raw.kind === "sigint") return { kind: "stop", stop: operatorStop(gate.askId, "SIGINT") };
|
|
285
|
-
if (raw.kind === "stop") return { kind: "stop", stop: driverStop(gate.askId, raw) };
|
|
286
|
-
const answer = resolveOperatorAnswer(raw.text, gate.labels);
|
|
287
|
-
if (answer.kind === "stop") return { kind: "stop", stop: operatorStop(gate.askId, answer.cause) };
|
|
288
|
-
const line3 = formatHitlReply(gate.askId, answer);
|
|
289
|
-
const stamp = {
|
|
290
|
-
askId: gate.askId,
|
|
291
|
-
reply: answer.kind === "reply" ? `operator reply ${answer.n}` : "operator reply other",
|
|
292
|
-
label: answer.kind === "reply" ? answer.label : answer.text,
|
|
293
|
-
line: line3,
|
|
294
|
-
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
295
|
-
detection: gate.detection
|
|
296
|
-
};
|
|
297
|
-
return { kind: "reply", stamp };
|
|
298
|
-
}
|
|
299
|
-
function formatHitlSummary(record) {
|
|
300
|
-
if (!record) return [];
|
|
301
|
-
const lines = record.replies.map(
|
|
302
|
-
(s) => `HITL ${s.askId}: ${s.reply} (${s.label}) ${s.at}${s.detection === "fallback" ? " [fallback]" : ""}`
|
|
303
|
-
);
|
|
304
|
-
if (record.fallbackDetections > 0) {
|
|
305
|
-
lines.push(`hitl-detect: prose-fallback x${record.fallbackDetections}`);
|
|
306
|
-
}
|
|
307
|
-
if (record.stop) lines.push(record.stop.message);
|
|
308
|
-
return lines;
|
|
309
|
-
}
|
|
310
|
-
function hitlExitCode(childExitCode, record) {
|
|
311
|
-
if (record?.stop) return record.stop.exitCode;
|
|
312
|
-
return childExitCode;
|
|
313
|
-
}
|
|
314
|
-
function userEventLine(text) {
|
|
315
|
-
return `${JSON.stringify({ type: "user", message: { role: "user", content: text } })}
|
|
316
|
-
`;
|
|
317
|
-
}
|
|
318
|
-
var TurnWatcher = class {
|
|
319
|
-
constructor(onResult) {
|
|
320
|
-
this.onResult = onResult;
|
|
321
|
-
}
|
|
322
|
-
onResult;
|
|
323
|
-
lines = new LineSplitter();
|
|
324
|
-
assistantTexts = [];
|
|
325
|
-
decoder = new StringDecoder("utf8");
|
|
326
|
-
feed(chunk) {
|
|
327
|
-
const text = typeof chunk === "string" ? chunk : this.decoder.write(chunk);
|
|
328
|
-
if (!text) return;
|
|
329
|
-
this.lines.feed(text, (line3) => this.take(line3));
|
|
330
|
-
}
|
|
331
|
-
end() {
|
|
332
|
-
this.lines.feed(this.decoder.end(), (line3) => this.take(line3));
|
|
333
|
-
const rest = this.lines.end();
|
|
334
|
-
if (rest.trim()) this.take(rest);
|
|
335
|
-
}
|
|
336
|
-
take(line3) {
|
|
337
|
-
const trimmed = line3.trim();
|
|
338
|
-
if (!trimmed.startsWith("{")) return;
|
|
339
|
-
let event;
|
|
340
|
-
try {
|
|
341
|
-
event = JSON.parse(trimmed);
|
|
342
|
-
} catch {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
if (typeof event !== "object" || event === null) return;
|
|
346
|
-
const ev = event;
|
|
347
|
-
if (ev.type === "assistant") {
|
|
348
|
-
const content = ev.message?.content;
|
|
349
|
-
if (typeof content === "string") {
|
|
350
|
-
if (content) this.assistantTexts.push(content);
|
|
351
|
-
} else if (Array.isArray(content)) {
|
|
352
|
-
for (const part of content) {
|
|
353
|
-
if (part && typeof part === "object" && part.type === "text" && typeof part.text === "string") {
|
|
354
|
-
this.assistantTexts.push(part.text);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
if (ev.type === "result") {
|
|
361
|
-
const texts = this.assistantTexts;
|
|
362
|
-
this.assistantTexts = [];
|
|
363
|
-
this.onResult({
|
|
364
|
-
resultText: typeof ev.result === "string" ? ev.result : "",
|
|
365
|
-
assistantTexts: texts,
|
|
366
|
-
isError: ev.is_error === true,
|
|
367
|
-
subtype: typeof ev.subtype === "string" ? ev.subtype : null,
|
|
368
|
-
errors: Array.isArray(ev.errors) ? ev.errors.filter((e) => typeof e === "string") : []
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
|
|
374
29
|
// src/plan-loop/backends.ts
|
|
375
30
|
import { execFileSync as execFileSync2, spawn } from "child_process";
|
|
376
31
|
import { createWriteStream as createWriteStream2 } from "fs";
|
|
377
32
|
import { access as access2 } from "fs/promises";
|
|
378
33
|
import path2 from "path";
|
|
379
|
-
import { StringDecoder as
|
|
34
|
+
import { StringDecoder as StringDecoder3 } from "string_decoder";
|
|
380
35
|
|
|
381
36
|
// src/plan-loop/codex.ts
|
|
382
37
|
import { execFileSync } from "child_process";
|
|
@@ -701,10 +356,10 @@ var codexBackend = {
|
|
|
701
356
|
|
|
702
357
|
// src/plan-loop/cursor-acp.ts
|
|
703
358
|
import { createWriteStream } from "fs";
|
|
704
|
-
import { StringDecoder as
|
|
359
|
+
import { StringDecoder as StringDecoder2 } from "string_decoder";
|
|
705
360
|
|
|
706
361
|
// src/plan-loop/stream-render.ts
|
|
707
|
-
import { StringDecoder
|
|
362
|
+
import { StringDecoder } from "string_decoder";
|
|
708
363
|
import { trueColor } from "kolorist";
|
|
709
364
|
|
|
710
365
|
// src/plan-loop/stream-events.ts
|
|
@@ -784,12 +439,12 @@ function parseAssistant(event) {
|
|
|
784
439
|
}
|
|
785
440
|
return out.length > 0 ? out : [{ kind: "silent" }];
|
|
786
441
|
}
|
|
787
|
-
var
|
|
442
|
+
var HITL_REPLY_PREFIX = "HITL_REPLY:";
|
|
788
443
|
function parseUser(event) {
|
|
789
444
|
const message = event.message;
|
|
790
445
|
const content = isRecord2(message) ? message.content : void 0;
|
|
791
446
|
if (typeof content === "string") {
|
|
792
|
-
if (event.isReplay === true && content.startsWith(
|
|
447
|
+
if (event.isReplay === true && content.startsWith(HITL_REPLY_PREFIX)) {
|
|
793
448
|
return [{ kind: "hitl_reply", line: oneLine(content) }];
|
|
794
449
|
}
|
|
795
450
|
return [{ kind: "prompt", chars: content.length }];
|
|
@@ -807,7 +462,7 @@ function parseUser(event) {
|
|
|
807
462
|
line: firstLineOfContent(part.content)
|
|
808
463
|
});
|
|
809
464
|
} else if (type === "text" && typeof part.text === "string") {
|
|
810
|
-
if (event.isReplay === true && part.text.startsWith(
|
|
465
|
+
if (event.isReplay === true && part.text.startsWith(HITL_REPLY_PREFIX)) {
|
|
811
466
|
out.push({ kind: "hitl_reply", line: oneLine(part.text) });
|
|
812
467
|
continue;
|
|
813
468
|
}
|
|
@@ -915,7 +570,7 @@ function parseStreamLine(line3) {
|
|
|
915
570
|
}
|
|
916
571
|
|
|
917
572
|
// src/plan-loop/stream-render.ts
|
|
918
|
-
var
|
|
573
|
+
var PENDING_MAX_CHARS = 4 * 1024 * 1024;
|
|
919
574
|
var MIN_COLUMNS = 40;
|
|
920
575
|
function paint(hex, text, color) {
|
|
921
576
|
if (!color) return text;
|
|
@@ -1000,7 +655,7 @@ var StreamRenderer = class {
|
|
|
1000
655
|
pending = "";
|
|
1001
656
|
dropped = false;
|
|
1002
657
|
textOpen = false;
|
|
1003
|
-
decoder = new
|
|
658
|
+
decoder = new StringDecoder("utf8");
|
|
1004
659
|
write;
|
|
1005
660
|
color;
|
|
1006
661
|
columns;
|
|
@@ -1026,7 +681,7 @@ var StreamRenderer = class {
|
|
|
1026
681
|
}
|
|
1027
682
|
this.renderLine(line3);
|
|
1028
683
|
}
|
|
1029
|
-
if (this.pending.length >
|
|
684
|
+
if (this.pending.length > PENDING_MAX_CHARS) {
|
|
1030
685
|
this.pending = "";
|
|
1031
686
|
this.dropped = true;
|
|
1032
687
|
}
|
|
@@ -1297,7 +952,7 @@ async function runCursorAcp(opts) {
|
|
|
1297
952
|
} else p.resolve(msg.result);
|
|
1298
953
|
}
|
|
1299
954
|
};
|
|
1300
|
-
const decoder = new
|
|
955
|
+
const decoder = new StringDecoder2("utf8");
|
|
1301
956
|
const splitter = new LineSplitter();
|
|
1302
957
|
child.stdout?.on("data", (chunk) => {
|
|
1303
958
|
splitter.feed(typeof chunk === "string" ? chunk : decoder.write(chunk), take);
|
|
@@ -1437,7 +1092,7 @@ var cursorAcpBackend = {
|
|
|
1437
1092
|
|
|
1438
1093
|
// src/plan-loop/backends.ts
|
|
1439
1094
|
function createLineTranslator(translate) {
|
|
1440
|
-
const decoder = new
|
|
1095
|
+
const decoder = new StringDecoder3("utf8");
|
|
1441
1096
|
const lines = new LineSplitter();
|
|
1442
1097
|
const run = (line3, out) => {
|
|
1443
1098
|
try {
|
|
@@ -1492,7 +1147,7 @@ function redactSecrets(text, secrets) {
|
|
|
1492
1147
|
var REDACT_HOLD_MAX_CHARS = 64 * 1024;
|
|
1493
1148
|
var RedactingStreamBuffer = class {
|
|
1494
1149
|
pending = "";
|
|
1495
|
-
decoder = new
|
|
1150
|
+
decoder = new StringDecoder3("utf8");
|
|
1496
1151
|
secrets;
|
|
1497
1152
|
keep;
|
|
1498
1153
|
constructor(secrets) {
|
|
@@ -2106,14 +1761,6 @@ function getBackend(id) {
|
|
|
2106
1761
|
}
|
|
2107
1762
|
|
|
2108
1763
|
export {
|
|
2109
|
-
LineSplitter,
|
|
2110
|
-
RESERVED_GATE_IDS,
|
|
2111
|
-
HITL_UNANSWERED_EXIT_CODE,
|
|
2112
|
-
formatHitlGateLine,
|
|
2113
|
-
findHitlGateInText,
|
|
2114
|
-
operatorQuitStop,
|
|
2115
|
-
formatHitlSummary,
|
|
2116
|
-
hitlExitCode,
|
|
2117
1764
|
codexBackend,
|
|
2118
1765
|
parseStreamLine,
|
|
2119
1766
|
renderStreamEvent,
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
compareSemver,
|
|
6
6
|
normalizeSemver
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3OM7JODZ.js";
|
|
8
8
|
import {
|
|
9
9
|
MANIFEST_RELATIVE_PATH
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-7BEHUBEJ.js";
|
|
11
11
|
import {
|
|
12
12
|
KIT_VERSION,
|
|
13
13
|
pinnedCliSpec
|
|
@@ -3,9 +3,11 @@ import {
|
|
|
3
3
|
} from "./chunk-MUTTNRX4.js";
|
|
4
4
|
import {
|
|
5
5
|
claudeRedactions,
|
|
6
|
-
findHitlGateInText,
|
|
7
6
|
redactSecrets
|
|
8
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NJVWTROP.js";
|
|
8
|
+
import {
|
|
9
|
+
findHitlGateInText
|
|
10
|
+
} from "./chunk-IRTS7WEA.js";
|
|
9
11
|
import {
|
|
10
12
|
findOnPath
|
|
11
13
|
} from "./chunk-WGLPZXNU.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
RESERVED_GATE_IDS,
|
|
3
2
|
checkClaudeVersion,
|
|
4
3
|
claudeChildEnv,
|
|
5
4
|
claudeHeadlessArgs,
|
|
@@ -13,7 +12,10 @@ import {
|
|
|
13
12
|
redactSecrets,
|
|
14
13
|
resolveHitlRunOptions,
|
|
15
14
|
spawnLogged
|
|
16
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NJVWTROP.js";
|
|
16
|
+
import {
|
|
17
|
+
RESERVED_GATE_IDS
|
|
18
|
+
} from "./chunk-IRTS7WEA.js";
|
|
17
19
|
import {
|
|
18
20
|
ensureLoopLogsDir,
|
|
19
21
|
runnerStatePaths
|