engine7 7.1.148 → 7.1.150
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/bg-worker.mjs +263 -67
- package/dist/cc-desktop.mjs +48 -6
- package/dist/cli.mjs +4890 -3323
- package/dist/engine-startup.mjs +7296 -4302
- package/dist/main.mjs +7309 -4306
- package/dist/recall-worker.mjs +183 -42
- package/dist/topics-worker.mjs +185 -54
- package/dist/travel-gateway.mjs +378 -125
- package/dist/travel-host.mjs +944 -472
- package/dist/travel-node.mjs +2 -3
- package/dist/travel-oss-bundle-stream.mjs +13 -1
- package/dist/travel-pairing.mjs +384 -131
- package/dist/travel-sync-worker.mjs +235 -114
- package/dist/web-console.mjs +390 -147
- package/package.json +2 -2
package/dist/cc-desktop.mjs
CHANGED
|
@@ -5,9 +5,12 @@ var __esm = (fn, res) => function __init() {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/cc-driver/long-http.ts
|
|
8
|
+
var CC_JOB_HEADER, isCcJobId;
|
|
8
9
|
var init_long_http = __esm({
|
|
9
10
|
"src/cc-driver/long-http.ts"() {
|
|
10
11
|
"use strict";
|
|
12
|
+
CC_JOB_HEADER = "x-engine7-cc-job-id";
|
|
13
|
+
isCcJobId = (value) => typeof value === "string" && /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(value);
|
|
11
14
|
}
|
|
12
15
|
});
|
|
13
16
|
|
|
@@ -184,6 +187,7 @@ ${terminalText(job.prompt)}`;
|
|
|
184
187
|
options.writeInput(`\x1B[200~${prompt}\x1B[201~`);
|
|
185
188
|
enterTimer = setTimeout(() => {
|
|
186
189
|
if (closed || active !== job) return;
|
|
190
|
+
job.entered = true;
|
|
187
191
|
try {
|
|
188
192
|
options.writeInput("\r");
|
|
189
193
|
} catch (e) {
|
|
@@ -205,6 +209,30 @@ ${terminalText(job.prompt)}`;
|
|
|
205
209
|
unlockInput();
|
|
206
210
|
}
|
|
207
211
|
};
|
|
212
|
+
const stopJob = (id) => {
|
|
213
|
+
const index = queue.findIndex((job) => job.id === id);
|
|
214
|
+
const reason = failure("Desktop CC request cancelled (stop)", 499);
|
|
215
|
+
if (index >= 0) {
|
|
216
|
+
queue.splice(index, 1)[0].reject(reason);
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
if (active?.id !== id) return false;
|
|
220
|
+
if (active.entered && !active.submitted) {
|
|
221
|
+
active.stopRequested = true;
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
const submitted = active.submitted;
|
|
225
|
+
options.writeInput(submitted ? "\x1B" : "");
|
|
226
|
+
clearTimeout(enterTimer);
|
|
227
|
+
clearTimeout(ackTimer);
|
|
228
|
+
active.reject(reason);
|
|
229
|
+
active = void 0;
|
|
230
|
+
suspended = submitted;
|
|
231
|
+
endpoint.busy = submitted;
|
|
232
|
+
if (pasting) unlockInput();
|
|
233
|
+
pump();
|
|
234
|
+
return true;
|
|
235
|
+
};
|
|
208
236
|
const onHook = (input) => {
|
|
209
237
|
if (!input || typeof input.hook_event_name !== "string" || typeof input.session_id !== "string" || typeof input.cwd !== "string" || canonical(input.cwd) !== endpoint.workDir) throw failure("Invalid desktop hook identity", 400);
|
|
210
238
|
const event = input.hook_event_name;
|
|
@@ -228,7 +256,8 @@ ${terminalText(job.prompt)}`;
|
|
|
228
256
|
if (active && typeof input.prompt === "string" && input.prompt.startsWith(`[engine7_cc_ask:${active.id}] `)) {
|
|
229
257
|
active.submitted = true;
|
|
230
258
|
clearTimeout(ackTimer);
|
|
231
|
-
|
|
259
|
+
if (active.stopRequested) stopJob(active.id);
|
|
260
|
+
else unlockInput();
|
|
232
261
|
} else if (active) {
|
|
233
262
|
active.reject(failure("Desktop user changed the active turn"));
|
|
234
263
|
active = void 0;
|
|
@@ -264,7 +293,7 @@ ${terminalText(job.prompt)}`;
|
|
|
264
293
|
const server = createServer(async (req, res) => {
|
|
265
294
|
const reply = (status, value) => {
|
|
266
295
|
if (res.destroyed || res.writableEnded) return;
|
|
267
|
-
res.writeHead(status, { "content-type": "application/json" });
|
|
296
|
+
if (!res.headersSent) res.writeHead(status, { "content-type": "application/json" });
|
|
268
297
|
res.end(JSON.stringify(value));
|
|
269
298
|
};
|
|
270
299
|
const auth = String(req.headers.authorization || "");
|
|
@@ -278,13 +307,14 @@ ${terminalText(job.prompt)}`;
|
|
|
278
307
|
reply(200, { ...status, suspended, draft, queued: queue.length });
|
|
279
308
|
return;
|
|
280
309
|
}
|
|
281
|
-
if (req.method !== "POST" || !["/ask", "/hook", "/title"].includes(req.url || "")) {
|
|
310
|
+
if (req.method !== "POST" || !["/ask", "/submit", "/stop", "/hook", "/title"].includes(req.url || "")) {
|
|
282
311
|
reply(404, { error: "Not found" });
|
|
283
312
|
return;
|
|
284
313
|
}
|
|
314
|
+
const managed = req.url === "/submit";
|
|
285
315
|
let job;
|
|
286
316
|
const disconnect = () => {
|
|
287
|
-
if (!job || res.writableEnded) return;
|
|
317
|
+
if (managed || !job || res.writableEnded) return;
|
|
288
318
|
const index = queue.indexOf(job);
|
|
289
319
|
if (index >= 0) queue.splice(index, 1);
|
|
290
320
|
job.reject(failure("Caller disconnected; any submitted desktop turn continues", 499));
|
|
@@ -298,6 +328,11 @@ ${terminalText(job.prompt)}`;
|
|
|
298
328
|
return;
|
|
299
329
|
}
|
|
300
330
|
if (input?.instance !== endpoint.instance || input.sessionId !== endpoint.sessionId || typeof input.workDir !== "string" || canonical(input.workDir) !== endpoint.workDir) throw failure("Desktop identity/session changed");
|
|
331
|
+
if (req.url === "/stop") {
|
|
332
|
+
if (!isCcJobId(input.jobId)) throw failure("Invalid CC jobId", 400);
|
|
333
|
+
reply(200, { stopped: stopJob(input.jobId) });
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
301
336
|
if (req.url === "/title") {
|
|
302
337
|
const title2 = normalizeDesktopTitle(input.title);
|
|
303
338
|
const previous = endpoint.title;
|
|
@@ -316,11 +351,18 @@ ${terminalText(job.prompt)}`;
|
|
|
316
351
|
throw failure("prompt and source required", 400);
|
|
317
352
|
}
|
|
318
353
|
if (queue.length >= 32) throw failure("Desktop queue full", 429);
|
|
354
|
+
if (managed && !isCcJobId(input.jobId)) throw failure("Invalid CC jobId", 400);
|
|
355
|
+
const id = managed ? input.jobId : randomUUID();
|
|
356
|
+
if (active?.id === id || queue.some((item) => item.id === id)) throw failure("CC job already exists");
|
|
319
357
|
const result = new Promise((resolve, reject) => {
|
|
320
|
-
job = { id
|
|
358
|
+
job = { id, prompt: input.prompt, source: input.source, sessionId: input.sessionId, submitted: false, resolve, reject };
|
|
321
359
|
queue.push(job);
|
|
322
360
|
});
|
|
323
|
-
if (res.destroyed)
|
|
361
|
+
if (managed && !res.destroyed) {
|
|
362
|
+
res.writeHead(200, { "content-type": "application/json", [CC_JOB_HEADER]: id });
|
|
363
|
+
res.flushHeaders();
|
|
364
|
+
}
|
|
365
|
+
if (res.destroyed && !managed) disconnect();
|
|
324
366
|
else pump();
|
|
325
367
|
reply(200, await result);
|
|
326
368
|
} catch (error) {
|