repoburg 1.3.320 → 1.3.321
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/agent-pane/backend/dist/index.js +356 -61
- package/agent-pane/backend/dist/server.js +356 -61
- package/agent-pane/frontend/dist/assets/{TerminalView-D5Hg3Fzf.js → TerminalView-Z7ZJ436H.js} +1 -1
- package/agent-pane/frontend/dist/assets/{index-Cckb2tlY.js → index-CjwvHfxy.js} +12 -2
- package/agent-pane/frontend/dist/index.html +1 -1
- package/package.json +1 -1
- package/tabtape/extension/dist/build-info.json +3 -3
- package/tabtape/extension/dist/manifest.json +1 -1
- package/tabtape/ui/dist/build-info.json +3 -3
|
@@ -761,7 +761,7 @@ var require_plugin = __commonJS({
|
|
|
761
761
|
const name = this.name;
|
|
762
762
|
let completed = false;
|
|
763
763
|
this.options = typeof this.options === "function" ? this.options(this.server) : this.options;
|
|
764
|
-
let
|
|
764
|
+
let timer3 = null;
|
|
765
765
|
const done = (execErr) => {
|
|
766
766
|
if (completed) {
|
|
767
767
|
debug("loading complete", name);
|
|
@@ -774,16 +774,16 @@ var require_plugin = __commonJS({
|
|
|
774
774
|
debug("exec completed", name);
|
|
775
775
|
}
|
|
776
776
|
completed = true;
|
|
777
|
-
if (
|
|
778
|
-
clearTimeout(
|
|
777
|
+
if (timer3) {
|
|
778
|
+
clearTimeout(timer3);
|
|
779
779
|
}
|
|
780
780
|
callback(execErr);
|
|
781
781
|
};
|
|
782
782
|
if (this.timeout > 0) {
|
|
783
783
|
debug("setting up timeout", name, this.timeout);
|
|
784
|
-
|
|
784
|
+
timer3 = setTimeout(function() {
|
|
785
785
|
debug("timed out", name);
|
|
786
|
-
|
|
786
|
+
timer3 = null;
|
|
787
787
|
const readyTimeoutErr = new AVV_ERR_PLUGIN_EXEC_TIMEOUT(name);
|
|
788
788
|
readyTimeoutErr.fn = func;
|
|
789
789
|
done(readyTimeoutErr);
|
|
@@ -1370,9 +1370,9 @@ var require_avvio = __commonJS({
|
|
|
1370
1370
|
function timeoutCall(func, rootErr, context, cb) {
|
|
1371
1371
|
const name = func.unwrappedName ?? func.name;
|
|
1372
1372
|
debug("setting up ready timeout", name, this._opts.timeout);
|
|
1373
|
-
let
|
|
1373
|
+
let timer3 = setTimeout(() => {
|
|
1374
1374
|
debug("timed out", name);
|
|
1375
|
-
|
|
1375
|
+
timer3 = null;
|
|
1376
1376
|
const toutErr = new AVV_ERR_READY_TIMEOUT(name);
|
|
1377
1377
|
toutErr.fn = func;
|
|
1378
1378
|
this._error = toutErr;
|
|
@@ -1384,9 +1384,9 @@ var require_avvio = __commonJS({
|
|
|
1384
1384
|
func(rootErr, context, timeoutCb.bind(this));
|
|
1385
1385
|
}
|
|
1386
1386
|
function timeoutCb(err) {
|
|
1387
|
-
if (
|
|
1388
|
-
clearTimeout(
|
|
1389
|
-
|
|
1387
|
+
if (timer3) {
|
|
1388
|
+
clearTimeout(timer3);
|
|
1389
|
+
timer3 = null;
|
|
1390
1390
|
this._error = err;
|
|
1391
1391
|
process.nextTick(cb, this._error);
|
|
1392
1392
|
} else {
|
|
@@ -41106,6 +41106,19 @@ function createTables(database) {
|
|
|
41106
41106
|
UNIQUE(app_id, workspace_path)
|
|
41107
41107
|
);
|
|
41108
41108
|
|
|
41109
|
+
-- Mini-app alarms (apps/app-alarms.ts): one row per (app, instance, name),
|
|
41110
|
+
-- deleted when it fires. fire_at is epoch ms. They outlive a pane restart:
|
|
41111
|
+
-- a due alarm fires right after startup.
|
|
41112
|
+
CREATE TABLE IF NOT EXISTS app_alarms (
|
|
41113
|
+
app_id TEXT NOT NULL,
|
|
41114
|
+
workspace_path TEXT NOT NULL DEFAULT '',
|
|
41115
|
+
name TEXT NOT NULL,
|
|
41116
|
+
fire_at INTEGER NOT NULL,
|
|
41117
|
+
data TEXT,
|
|
41118
|
+
created_at TEXT NOT NULL,
|
|
41119
|
+
PRIMARY KEY (app_id, workspace_path, name)
|
|
41120
|
+
);
|
|
41121
|
+
|
|
41109
41122
|
CREATE TABLE IF NOT EXISTS cli_processes (
|
|
41110
41123
|
pid INTEGER PRIMARY KEY,
|
|
41111
41124
|
session_id TEXT NOT NULL,
|
|
@@ -44094,14 +44107,14 @@ var AppServerClient = class {
|
|
|
44094
44107
|
}
|
|
44095
44108
|
const id = this.nextId++;
|
|
44096
44109
|
const message = JSON.stringify({ id, method, params }) + "\n";
|
|
44097
|
-
const
|
|
44110
|
+
const timer3 = setTimeout(() => {
|
|
44098
44111
|
this.pending.delete(id);
|
|
44099
44112
|
reject(new Error(`Request '${method}' (id=${id}) timed out after ${REQUEST_TIMEOUT_MS}ms`));
|
|
44100
44113
|
}, REQUEST_TIMEOUT_MS);
|
|
44101
44114
|
this.pending.set(id, {
|
|
44102
44115
|
resolve,
|
|
44103
44116
|
reject,
|
|
44104
|
-
timer:
|
|
44117
|
+
timer: timer3
|
|
44105
44118
|
});
|
|
44106
44119
|
this.write(message);
|
|
44107
44120
|
});
|
|
@@ -44176,14 +44189,14 @@ var AppServerClient = class {
|
|
|
44176
44189
|
if (this.gone) return Promise.resolve(true);
|
|
44177
44190
|
return new Promise((resolve) => {
|
|
44178
44191
|
const onExit = () => {
|
|
44179
|
-
clearTimeout(
|
|
44192
|
+
clearTimeout(timer3);
|
|
44180
44193
|
resolve(true);
|
|
44181
44194
|
};
|
|
44182
|
-
const
|
|
44195
|
+
const timer3 = setTimeout(() => {
|
|
44183
44196
|
this.proc.removeListener("exit", onExit);
|
|
44184
44197
|
resolve(false);
|
|
44185
44198
|
}, ms);
|
|
44186
|
-
|
|
44199
|
+
timer3.unref?.();
|
|
44187
44200
|
this.proc.once("exit", onExit);
|
|
44188
44201
|
});
|
|
44189
44202
|
}
|
|
@@ -44908,14 +44921,14 @@ var VscodeWebManager = class {
|
|
|
44908
44921
|
waitForReady(inst) {
|
|
44909
44922
|
const deadline = this.deps.now() + STARTUP_TIMEOUT_MS;
|
|
44910
44923
|
return new Promise((resolve) => {
|
|
44911
|
-
const
|
|
44924
|
+
const timer3 = setInterval(async () => {
|
|
44912
44925
|
if (inst.state !== "starting") {
|
|
44913
|
-
clearInterval(
|
|
44926
|
+
clearInterval(timer3);
|
|
44914
44927
|
resolve();
|
|
44915
44928
|
return;
|
|
44916
44929
|
}
|
|
44917
44930
|
if (this.deps.now() > deadline) {
|
|
44918
|
-
clearInterval(
|
|
44931
|
+
clearInterval(timer3);
|
|
44919
44932
|
inst.state = "error";
|
|
44920
44933
|
inst.error = `serve-web did not become ready within ${STARTUP_TIMEOUT_MS / 1e3}s`;
|
|
44921
44934
|
inst.stopping = true;
|
|
@@ -44927,7 +44940,7 @@ var VscodeWebManager = class {
|
|
|
44927
44940
|
}
|
|
44928
44941
|
try {
|
|
44929
44942
|
await this.deps.probe(inst.port, inst.token, inst.id);
|
|
44930
|
-
clearInterval(
|
|
44943
|
+
clearInterval(timer3);
|
|
44931
44944
|
if (inst.state === "starting") {
|
|
44932
44945
|
inst.state = "running";
|
|
44933
44946
|
this.markAccessed(inst.id);
|
|
@@ -99413,7 +99426,8 @@ Each subdirectory of this folder is one mini app:
|
|
|
99413
99426
|
<app-id>/
|
|
99414
99427
|
manifest.json - { "title": string, "description"?: string, "icon"?: string,
|
|
99415
99428
|
"tools"?: [{ "name", "description", "inputSchema" }],
|
|
99416
|
-
"headlessSessions"?: boolean
|
|
99429
|
+
"headlessSessions"?: boolean,
|
|
99430
|
+
"sessionActivity"?: boolean }
|
|
99417
99431
|
"icon" is the app logo: a Lucide icon name (see
|
|
99418
99432
|
"Icons and logos" below)
|
|
99419
99433
|
index.html - markup only (full HTML document); do NOT reference app.js
|
|
@@ -99609,6 +99623,46 @@ runtime and events go to the open tab only.
|
|
|
99609
99623
|
- events are not replayed. Keep the session ids in the state, and when the
|
|
99610
99624
|
runtime loads ask getSession(id) what happened while the pane was down
|
|
99611
99625
|
|
|
99626
|
+
## Other sessions' turns (manifest "sessionActivity")
|
|
99627
|
+
|
|
99628
|
+
Set "sessionActivity": true in manifest.json to hear when a turn starts or
|
|
99629
|
+
ends in a session the app did NOT open (the user's sessions, other apps'):
|
|
99630
|
+
|
|
99631
|
+
AgentPane.onSessionActivity(({ event, sessionId, turnId, origin, originName, cancelled }) => ...)
|
|
99632
|
+
|
|
99633
|
+
- event is 'turn:started', 'turn:completed' or 'turn:failed' (cancelled: true
|
|
99634
|
+
when the user stopped it); turns of discussion threads are left out
|
|
99635
|
+
- origin is 'peer' when a message from another Claude session (SendMessage)
|
|
99636
|
+
started the turn, with originName the sender's name; null otherwise
|
|
99637
|
+
- turn:started can come again for the same turnId (a background task's
|
|
99638
|
+
follow-up reopens the turn): dedupe by turnId
|
|
99639
|
+
- read the session with getSessionInfo(sessionId) (cwd, runtime_type,
|
|
99640
|
+
transcript_path); the prompt itself is in the transcript
|
|
99641
|
+
- fires in the headless runtime only, with or without a tab: in the global
|
|
99642
|
+
instance, and in every workspace instance that has state and sees the
|
|
99643
|
+
session. Register the listener synchronously at startup
|
|
99644
|
+
- the app's own sessions are not reported here: they have onTurnCompleted
|
|
99645
|
+
|
|
99646
|
+
## Alarms
|
|
99647
|
+
|
|
99648
|
+
The headless runtime's setTimeout dies with it (pane restart, hot reload).
|
|
99649
|
+
For a wake-up that must happen, use an alarm; the pane keeps it in its
|
|
99650
|
+
database and fires it into the instance that set it, loading it if needed:
|
|
99651
|
+
|
|
99652
|
+
await AgentPane.setAlarm('checkin:' + id, 15 * 60_000, { id }); // { name, fireAt, data }
|
|
99653
|
+
AgentPane.onAlarm(({ name, data, fireAt }) => ...);
|
|
99654
|
+
await AgentPane.clearAlarm(name); // { cleared }
|
|
99655
|
+
await AgentPane.listAlarms(); // soonest first
|
|
99656
|
+
|
|
99657
|
+
- headless only: in the tab these reject (use callTool to reach the headless
|
|
99658
|
+
runtime) and onAlarm never fires there
|
|
99659
|
+
- names are per instance; setting a name again moves that alarm. An alarm
|
|
99660
|
+
fires once, then it is gone. delayMs is at most 30 days, data at most 64 KB
|
|
99661
|
+
of JSON, at most 200 alarms per instance
|
|
99662
|
+
- an alarm that came due while the pane was down fires right after startup;
|
|
99663
|
+
check the state before acting on it
|
|
99664
|
+
- register onAlarm synchronously at startup. Deleting the app drops its alarms
|
|
99665
|
+
|
|
99612
99666
|
## Result contract
|
|
99613
99667
|
|
|
99614
99668
|
To give the app a structured result, put this requirement in the job prompt:
|
|
@@ -99629,12 +99683,20 @@ function readManifestIn(dir) {
|
|
|
99629
99683
|
description: typeof parsed.description === "string" ? parsed.description : void 0,
|
|
99630
99684
|
icon: typeof parsed.icon === "string" ? parsed.icon : void 0,
|
|
99631
99685
|
tools: Array.isArray(parsed.tools) ? parsed.tools.filter((t) => t && typeof t.name === "string" && typeof t.description === "string") : void 0,
|
|
99632
|
-
headlessSessions: parsed.headlessSessions === true ? true : void 0
|
|
99686
|
+
headlessSessions: parsed.headlessSessions === true ? true : void 0,
|
|
99687
|
+
sessionActivity: parsed.sessionActivity === true ? true : void 0
|
|
99633
99688
|
};
|
|
99634
99689
|
} catch {
|
|
99635
99690
|
return null;
|
|
99636
99691
|
}
|
|
99637
99692
|
}
|
|
99693
|
+
function listAppIds() {
|
|
99694
|
+
try {
|
|
99695
|
+
return fs2.readdirSync(appsRoot(), { withFileTypes: true }).filter((entry) => entry.isDirectory() && APP_ID_RE.test(entry.name)).map((entry) => entry.name);
|
|
99696
|
+
} catch {
|
|
99697
|
+
return [];
|
|
99698
|
+
}
|
|
99699
|
+
}
|
|
99638
99700
|
function readManifest(id) {
|
|
99639
99701
|
return readManifestIn(appDir(id));
|
|
99640
99702
|
}
|
|
@@ -99678,8 +99740,8 @@ function startAppsWatch(onAppChange) {
|
|
|
99678
99740
|
const file2 = segs[segs.length - 1];
|
|
99679
99741
|
if (!appId || appId === path5.basename(root) || !APP_ID_RE.test(appId) || file2 === "state.json") return;
|
|
99680
99742
|
if (segs.length === 1 && isRegularFile(path5.join(root, appId))) return;
|
|
99681
|
-
const
|
|
99682
|
-
if (
|
|
99743
|
+
const timer3 = pendingChanges.get(appId);
|
|
99744
|
+
if (timer3) clearTimeout(timer3);
|
|
99683
99745
|
pendingChanges.set(
|
|
99684
99746
|
appId,
|
|
99685
99747
|
setTimeout(() => {
|
|
@@ -99697,7 +99759,7 @@ function stopAppsWatch() {
|
|
|
99697
99759
|
watcher.close();
|
|
99698
99760
|
watcher = null;
|
|
99699
99761
|
}
|
|
99700
|
-
for (const
|
|
99762
|
+
for (const timer3 of pendingChanges.values()) clearTimeout(timer3);
|
|
99701
99763
|
pendingChanges.clear();
|
|
99702
99764
|
}
|
|
99703
99765
|
|
|
@@ -100214,6 +100276,13 @@ function appSessionSummary(appId, workspace, sessionId) {
|
|
|
100214
100276
|
if (!session || !sessionVisibleTo(session, appId, workspace)) return null;
|
|
100215
100277
|
return sessionSummary(session, appId);
|
|
100216
100278
|
}
|
|
100279
|
+
function activityInstances(appId, sessionId) {
|
|
100280
|
+
const db2 = getDb();
|
|
100281
|
+
const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
|
|
100282
|
+
if (!session || openedByApp(session, appId)) return [];
|
|
100283
|
+
const rows = db2.prepare("SELECT workspace_path FROM app_instances WHERE app_id = ? AND workspace_path != '' ORDER BY workspace_path").all(appId);
|
|
100284
|
+
return ["", ...rows.map((r) => r.workspace_path).filter((w) => sessionVisibleTo(session, appId, w))];
|
|
100285
|
+
}
|
|
100217
100286
|
function ownSession(appId, sessionId, api) {
|
|
100218
100287
|
const session = getDb().prepare("SELECT * FROM sessions WHERE id = ?").get(String(sessionId));
|
|
100219
100288
|
if (!session || !openedByApp(session, appId)) {
|
|
@@ -100256,6 +100325,124 @@ function toolCaller(appId, sessionId) {
|
|
|
100256
100325
|
// src/apps/headless-runtime.ts
|
|
100257
100326
|
import vm2 from "node:vm";
|
|
100258
100327
|
|
|
100328
|
+
// src/apps/app-alarms.ts
|
|
100329
|
+
var MAX_ALARM_DELAY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
100330
|
+
var MAX_ALARMS_PER_INSTANCE = 200;
|
|
100331
|
+
var MAX_NAME_LENGTH = 200;
|
|
100332
|
+
var MAX_DATA_BYTES = 64 * 1024;
|
|
100333
|
+
var MAX_TIMER_WAIT_MS = 60 * 60 * 1e3;
|
|
100334
|
+
function parseData(raw) {
|
|
100335
|
+
if (raw == null) return null;
|
|
100336
|
+
try {
|
|
100337
|
+
return JSON.parse(raw);
|
|
100338
|
+
} catch {
|
|
100339
|
+
return null;
|
|
100340
|
+
}
|
|
100341
|
+
}
|
|
100342
|
+
function toAlarm(row) {
|
|
100343
|
+
return { name: row.name, fireAt: row.fire_at, data: parseData(row.data) };
|
|
100344
|
+
}
|
|
100345
|
+
function setAppAlarm(appId, workspace, name, delayMs, data) {
|
|
100346
|
+
if (typeof name !== "string" || !name.trim() || name.length > MAX_NAME_LENGTH) {
|
|
100347
|
+
throw new Error(`setAlarm: name must be a non-empty string of at most ${MAX_NAME_LENGTH} characters`);
|
|
100348
|
+
}
|
|
100349
|
+
if (typeof delayMs !== "number" || !Number.isFinite(delayMs) || delayMs < 0) {
|
|
100350
|
+
throw new Error("setAlarm: delayMs must be a number of milliseconds, 0 or more");
|
|
100351
|
+
}
|
|
100352
|
+
if (delayMs > MAX_ALARM_DELAY_MS) {
|
|
100353
|
+
throw new Error(`setAlarm: delayMs is at most ${MAX_ALARM_DELAY_MS} (30 days)`);
|
|
100354
|
+
}
|
|
100355
|
+
let json2 = null;
|
|
100356
|
+
if (data !== void 0) {
|
|
100357
|
+
try {
|
|
100358
|
+
json2 = JSON.stringify(data) ?? null;
|
|
100359
|
+
} catch {
|
|
100360
|
+
throw new Error("setAlarm: data must be JSON");
|
|
100361
|
+
}
|
|
100362
|
+
if (json2 && Buffer.byteLength(json2) > MAX_DATA_BYTES) {
|
|
100363
|
+
throw new Error(`setAlarm: data is at most ${MAX_DATA_BYTES} bytes of JSON`);
|
|
100364
|
+
}
|
|
100365
|
+
}
|
|
100366
|
+
const db2 = getDb();
|
|
100367
|
+
const exists2 = db2.prepare("SELECT 1 FROM app_alarms WHERE app_id = ? AND workspace_path = ? AND name = ?").get(appId, workspace, name);
|
|
100368
|
+
if (!exists2) {
|
|
100369
|
+
const { n } = db2.prepare("SELECT COUNT(*) AS n FROM app_alarms WHERE app_id = ? AND workspace_path = ?").get(appId, workspace);
|
|
100370
|
+
if (n >= MAX_ALARMS_PER_INSTANCE) {
|
|
100371
|
+
throw new Error(`setAlarm: an instance holds at most ${MAX_ALARMS_PER_INSTANCE} alarms; clear one first`);
|
|
100372
|
+
}
|
|
100373
|
+
}
|
|
100374
|
+
const fireAt = Date.now() + Math.round(delayMs);
|
|
100375
|
+
db2.prepare(
|
|
100376
|
+
`INSERT INTO app_alarms (app_id, workspace_path, name, fire_at, data, created_at)
|
|
100377
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
100378
|
+
ON CONFLICT(app_id, workspace_path, name) DO UPDATE SET
|
|
100379
|
+
fire_at = excluded.fire_at, data = excluded.data, created_at = excluded.created_at`
|
|
100380
|
+
).run(appId, workspace, name, fireAt, json2, (/* @__PURE__ */ new Date()).toISOString());
|
|
100381
|
+
schedule();
|
|
100382
|
+
return { name, fireAt, data: parseData(json2) };
|
|
100383
|
+
}
|
|
100384
|
+
function clearAppAlarm(appId, workspace, name) {
|
|
100385
|
+
if (typeof name !== "string") throw new Error("clearAlarm: name must be a string");
|
|
100386
|
+
const { changes } = getDb().prepare("DELETE FROM app_alarms WHERE app_id = ? AND workspace_path = ? AND name = ?").run(appId, workspace, name);
|
|
100387
|
+
schedule();
|
|
100388
|
+
return { cleared: changes > 0 };
|
|
100389
|
+
}
|
|
100390
|
+
function listAppAlarms(appId, workspace) {
|
|
100391
|
+
const rows = getDb().prepare("SELECT * FROM app_alarms WHERE app_id = ? AND workspace_path = ? ORDER BY fire_at, name").all(appId, workspace);
|
|
100392
|
+
return rows.map(toAlarm);
|
|
100393
|
+
}
|
|
100394
|
+
function deleteAppAlarms(appId) {
|
|
100395
|
+
getDb().prepare("DELETE FROM app_alarms WHERE app_id = ?").run(appId);
|
|
100396
|
+
schedule();
|
|
100397
|
+
}
|
|
100398
|
+
var deliver = null;
|
|
100399
|
+
var timer2 = null;
|
|
100400
|
+
function fireDueAlarms(now = Date.now()) {
|
|
100401
|
+
const db2 = getDb();
|
|
100402
|
+
const due = db2.transaction(() => {
|
|
100403
|
+
const rows = db2.prepare("SELECT * FROM app_alarms WHERE fire_at <= ? ORDER BY fire_at, name").all(now);
|
|
100404
|
+
const drop = db2.prepare("DELETE FROM app_alarms WHERE app_id = ? AND workspace_path = ? AND name = ?");
|
|
100405
|
+
for (const row of rows) drop.run(row.app_id, row.workspace_path, row.name);
|
|
100406
|
+
return rows;
|
|
100407
|
+
}).immediate().map((row) => ({ appId: row.app_id, workspace: row.workspace_path, ...toAlarm(row) }));
|
|
100408
|
+
for (const alarm of due) {
|
|
100409
|
+
try {
|
|
100410
|
+
deliver?.(alarm);
|
|
100411
|
+
} catch (err) {
|
|
100412
|
+
console.error(`[alarms] ${alarm.appId} alarm ${alarm.name} failed:`, err);
|
|
100413
|
+
}
|
|
100414
|
+
}
|
|
100415
|
+
return due;
|
|
100416
|
+
}
|
|
100417
|
+
function schedule() {
|
|
100418
|
+
if (!deliver) return;
|
|
100419
|
+
if (timer2) clearTimeout(timer2);
|
|
100420
|
+
timer2 = null;
|
|
100421
|
+
const next = getDb().prepare("SELECT MIN(fire_at) AS at FROM app_alarms").get();
|
|
100422
|
+
if (next.at == null) return;
|
|
100423
|
+
const wait = Math.min(Math.max(next.at - Date.now(), 0), MAX_TIMER_WAIT_MS);
|
|
100424
|
+
timer2 = setTimeout(() => {
|
|
100425
|
+
timer2 = null;
|
|
100426
|
+
try {
|
|
100427
|
+
fireDueAlarms();
|
|
100428
|
+
} catch (err) {
|
|
100429
|
+
console.error("[alarms] firing failed:", err);
|
|
100430
|
+
}
|
|
100431
|
+
schedule();
|
|
100432
|
+
}, wait);
|
|
100433
|
+
timer2.unref?.();
|
|
100434
|
+
}
|
|
100435
|
+
function startAppAlarms(onDue) {
|
|
100436
|
+
stopAppAlarms();
|
|
100437
|
+
deliver = onDue;
|
|
100438
|
+
schedule();
|
|
100439
|
+
}
|
|
100440
|
+
function stopAppAlarms() {
|
|
100441
|
+
if (timer2) clearTimeout(timer2);
|
|
100442
|
+
timer2 = null;
|
|
100443
|
+
deliver = null;
|
|
100444
|
+
}
|
|
100445
|
+
|
|
100259
100446
|
// src/apps/app-compile.ts
|
|
100260
100447
|
import vm from "node:vm";
|
|
100261
100448
|
import path9 from "node:path";
|
|
@@ -100464,6 +100651,23 @@ interface AgentPaneFileData { name?: string; type?: string; data: string }
|
|
|
100464
100651
|
type AgentPaneFileRef = string | { id?: string; url?: string };
|
|
100465
100652
|
/** A submitTurn attachment: a stored file, or inline bytes sent with that turn only. */
|
|
100466
100653
|
type AgentPaneAttachment = AgentPaneFileRef | Blob | AgentPaneFileData;
|
|
100654
|
+
/** onSessionActivity: a turn started or ended in a session this app did not
|
|
100655
|
+
* open. Read the session with getSessionInfo (cwd, runtime_type,
|
|
100656
|
+
* transcript_path). */
|
|
100657
|
+
interface AgentPaneSessionActivity {
|
|
100658
|
+
event: 'turn:started' | 'turn:completed' | 'turn:failed';
|
|
100659
|
+
sessionId: string;
|
|
100660
|
+
turnId: string;
|
|
100661
|
+
/** 'peer': a message from another Claude session (SendMessage) started the
|
|
100662
|
+
* turn; null: the user, or an app. */
|
|
100663
|
+
origin: 'peer' | null;
|
|
100664
|
+
/** The sending session's name for a peer turn, else null. */
|
|
100665
|
+
originName: string | null;
|
|
100666
|
+
/** turn:failed of a turn the user stopped. */
|
|
100667
|
+
cancelled?: boolean;
|
|
100668
|
+
}
|
|
100669
|
+
/** An alarm of this instance (setAlarm). fireAt is epoch ms. */
|
|
100670
|
+
interface AgentPaneAlarm { name: string; fireAt: number; data: unknown }
|
|
100467
100671
|
interface AgentPaneSubmitTurnOptions {
|
|
100468
100672
|
/** Files the agent receives with the prompt (images are shown to the model). */
|
|
100469
100673
|
attachments?: AgentPaneAttachment[];
|
|
@@ -100515,6 +100719,21 @@ declare const AgentPane: {
|
|
|
100515
100719
|
/** Fires when the live background-task set of one of the app's sessions
|
|
100516
100720
|
* changes (also empty sets, when the last task ends). */
|
|
100517
100721
|
onBackgroundTasks(cb: (payload: AgentPaneBackgroundTasksPayload | null) => void): void;
|
|
100722
|
+
/** Headless only, with "sessionActivity": true in the manifest: a turn
|
|
100723
|
+
* started or ended in a session this app did not open (the user's), in
|
|
100724
|
+
* this instance's sight. turn:started can come again for the same turnId
|
|
100725
|
+
* when a background task's follow-up reopens the turn. */
|
|
100726
|
+
onSessionActivity(cb: (payload: AgentPaneSessionActivity) => void): void;
|
|
100727
|
+
/** Headless only: wake this instance in delayMs (at most 30 days), also
|
|
100728
|
+
* after a pane restart. Setting a name again moves that alarm. data (JSON)
|
|
100729
|
+
* comes back with it. Rejects in the tab. */
|
|
100730
|
+
setAlarm(name: string, delayMs: number, data?: unknown): Promise<AgentPaneAlarm>;
|
|
100731
|
+
/** Headless only: drop an alarm; cleared is false when none had the name. */
|
|
100732
|
+
clearAlarm(name: string): Promise<{ cleared: boolean }>;
|
|
100733
|
+
/** Headless only: this instance's alarms, soonest first. */
|
|
100734
|
+
listAlarms(): Promise<AgentPaneAlarm[]>;
|
|
100735
|
+
/** Headless only: an alarm of this instance came due. It fires once. */
|
|
100736
|
+
onAlarm(cb: (alarm: AgentPaneAlarm) => void): void;
|
|
100518
100737
|
resolveToolCall(callId: string, result?: unknown): Promise<{ ok: boolean }>;
|
|
100519
100738
|
/** Show a session in the pane (switches the view to its conversation).
|
|
100520
100739
|
* Only works while the app is on screen: call it from a click handler. */
|
|
@@ -100808,7 +101027,13 @@ function loadRuntime(appId, workspace) {
|
|
|
100808
101027
|
if (headlessSessions) return;
|
|
100809
101028
|
throw new Error(`${api} is not available in the headless runtime without "headlessSessions": true in manifest.json`);
|
|
100810
101029
|
};
|
|
100811
|
-
const entry = {
|
|
101030
|
+
const entry = {
|
|
101031
|
+
handler: null,
|
|
101032
|
+
turnListeners: [],
|
|
101033
|
+
taskListeners: [],
|
|
101034
|
+
activityListeners: [],
|
|
101035
|
+
alarmListeners: []
|
|
101036
|
+
};
|
|
100812
101037
|
const bridge = {
|
|
100813
101038
|
getApp: () => answer(() => ({ id: appId, title: manifest?.title ?? appId, workspace })),
|
|
100814
101039
|
// State is scoped to the calling session's workspace instance; '' = global
|
|
@@ -100884,9 +101109,23 @@ function loadRuntime(appId, workspace) {
|
|
|
100884
101109
|
onBackgroundTasks: (cb) => {
|
|
100885
101110
|
if (typeof cb === "function") entry.taskListeners.push(cb);
|
|
100886
101111
|
},
|
|
100887
|
-
//
|
|
101112
|
+
// Heard only with "sessionActivity" in the manifest (deliverSessionActivity).
|
|
101113
|
+
onSessionActivity: (cb) => {
|
|
101114
|
+
if (typeof cb === "function") entry.activityListeners.push(cb);
|
|
101115
|
+
},
|
|
101116
|
+
setAlarm: (name, delayMs, data) => answer(() => setAppAlarm(appId, workspace, name, delayMs, data)),
|
|
101117
|
+
clearAlarm: (name) => answer(() => clearAppAlarm(appId, workspace, name)),
|
|
101118
|
+
listAlarms: () => answer(() => listAppAlarms(appId, workspace)),
|
|
101119
|
+
onAlarm: (cb) => {
|
|
101120
|
+
if (typeof cb === "function") entry.alarmListeners.push(cb);
|
|
101121
|
+
},
|
|
101122
|
+
// Live streaming is for a screen; nothing here renders. The same goes for
|
|
101123
|
+
// state changes: the tab re-renders on them, and an app.ts shared by tab
|
|
101124
|
+
// and runtime registers that at startup — which must not fail the load.
|
|
100888
101125
|
onTurnDelta: () => {
|
|
100889
101126
|
},
|
|
101127
|
+
onStateChanged: () => {
|
|
101128
|
+
},
|
|
100890
101129
|
// UI actions are intentionally unavailable headless.
|
|
100891
101130
|
openSession: () => answer(() => {
|
|
100892
101131
|
throw new Error("openSession is not available in the headless runtime");
|
|
@@ -100915,7 +101154,8 @@ function loadRuntime(appId, workspace) {
|
|
|
100915
101154
|
console.warn(`[headless:${appId}] app.js load failed: ${err.message}`);
|
|
100916
101155
|
return null;
|
|
100917
101156
|
}
|
|
100918
|
-
|
|
101157
|
+
const listens = entry.turnListeners.length || entry.taskListeners.length || entry.activityListeners.length || entry.alarmListeners.length;
|
|
101158
|
+
if (!entry.handler && !listens) return null;
|
|
100919
101159
|
runtimes.set(key, entry);
|
|
100920
101160
|
return entry;
|
|
100921
101161
|
}
|
|
@@ -100925,7 +101165,7 @@ function getHeadlessToolHandler(appId, workspace = "") {
|
|
|
100925
101165
|
function dispatchHeadlessToolCall(handler, tool2, args, caller = null) {
|
|
100926
101166
|
const callId = v4_default();
|
|
100927
101167
|
const result = new Promise((resolve, reject) => {
|
|
100928
|
-
const
|
|
101168
|
+
const timer3 = setTimeout(() => {
|
|
100929
101169
|
pendingCalls.delete(callId);
|
|
100930
101170
|
reject(
|
|
100931
101171
|
new Error(
|
|
@@ -100933,7 +101173,7 @@ function dispatchHeadlessToolCall(handler, tool2, args, caller = null) {
|
|
|
100933
101173
|
)
|
|
100934
101174
|
);
|
|
100935
101175
|
}, HEADLESS_TOOL_TIMEOUT_MS);
|
|
100936
|
-
pendingCalls.set(callId, { resolve, reject, timer:
|
|
101176
|
+
pendingCalls.set(callId, { resolve, reject, timer: timer3 });
|
|
100937
101177
|
});
|
|
100938
101178
|
const crashed = (err) => {
|
|
100939
101179
|
const pending = pendingCalls.get(callId);
|
|
@@ -100985,6 +101225,49 @@ function deliverSessionEvent(event, data) {
|
|
|
100985
101225
|
for (const listener of runtime.turnListeners) runAppCode(appId, () => listener(name, payload));
|
|
100986
101226
|
}
|
|
100987
101227
|
var SESSION_EVENTS = /* @__PURE__ */ new Set(["turn:completed", "turn:failed", "turn:cancelled", "background_tasks"]);
|
|
101228
|
+
var ACTIVITY_EVENTS = /* @__PURE__ */ new Set(["turn:started", "turn:completed", "turn:failed", "turn:cancelled"]);
|
|
101229
|
+
var activityApps = null;
|
|
101230
|
+
function sessionActivityApps() {
|
|
101231
|
+
activityApps ??= listAppIds().filter((id) => readManifest(id)?.sessionActivity === true);
|
|
101232
|
+
return activityApps;
|
|
101233
|
+
}
|
|
101234
|
+
function activityPayload(event, data) {
|
|
101235
|
+
const sessionId = String(data.sessionId);
|
|
101236
|
+
const turnId = String(data.turnId);
|
|
101237
|
+
const turn = getTurnOrigin(turnId);
|
|
101238
|
+
if (!turn || turn.thread_id || turn.session_id !== sessionId) return null;
|
|
101239
|
+
const peer = turn.origin === "peer";
|
|
101240
|
+
const base = { sessionId, turnId, origin: peer ? "peer" : null, originName: peer ? turn.origin_name : null };
|
|
101241
|
+
if (event === "turn:started") return { event, ...base };
|
|
101242
|
+
const [name, payload] = turnEvent(event, data);
|
|
101243
|
+
return { event: name, ...base, ...payload.cancelled ? { cancelled: true } : {} };
|
|
101244
|
+
}
|
|
101245
|
+
function getTurnOrigin(turnId) {
|
|
101246
|
+
const row = getDb().prepare("SELECT session_id, thread_id, origin, origin_name FROM turns WHERE id = ?").get(turnId);
|
|
101247
|
+
return row ?? null;
|
|
101248
|
+
}
|
|
101249
|
+
function deliverSessionActivity(event, data) {
|
|
101250
|
+
const apps = sessionActivityApps();
|
|
101251
|
+
if (!apps.length) return;
|
|
101252
|
+
const payload = activityPayload(event, data);
|
|
101253
|
+
if (!payload) return;
|
|
101254
|
+
for (const appId of apps) {
|
|
101255
|
+
for (const workspace of activityInstances(appId, String(payload.sessionId))) {
|
|
101256
|
+
const runtime = loadRuntime(appId, workspace);
|
|
101257
|
+
if (!runtime) continue;
|
|
101258
|
+
for (const listener of runtime.activityListeners) runAppCode(appId, () => listener({ ...payload }));
|
|
101259
|
+
}
|
|
101260
|
+
}
|
|
101261
|
+
}
|
|
101262
|
+
function deliverAlarm(alarm) {
|
|
101263
|
+
const runtime = loadRuntime(alarm.appId, alarm.workspace);
|
|
101264
|
+
if (!runtime?.alarmListeners.length) {
|
|
101265
|
+
console.warn(`[headless:${alarm.appId}] alarm ${alarm.name} dropped: the app has no onAlarm listener headless`);
|
|
101266
|
+
return;
|
|
101267
|
+
}
|
|
101268
|
+
const payload = { name: alarm.name, data: alarm.data, fireAt: alarm.fireAt };
|
|
101269
|
+
for (const listener of runtime.alarmListeners) runAppCode(alarm.appId, () => listener({ ...payload }));
|
|
101270
|
+
}
|
|
100988
101271
|
function handleUnhandledRejection(reason, promise2) {
|
|
100989
101272
|
if (promise2 instanceof Promise) throw reason;
|
|
100990
101273
|
console.error("[headless] unhandled rejection in app code:", reason);
|
|
@@ -100993,18 +101276,28 @@ var stopSessionEvents = null;
|
|
|
100993
101276
|
function startHeadlessEvents() {
|
|
100994
101277
|
stopHeadlessEvents();
|
|
100995
101278
|
const untap2 = tapBroadcast((event, data) => {
|
|
100996
|
-
|
|
101279
|
+
const session = SESSION_EVENTS.has(event);
|
|
101280
|
+
const activity = ACTIVITY_EVENTS.has(event);
|
|
101281
|
+
if (!session && !activity) return;
|
|
100997
101282
|
setImmediate(() => {
|
|
100998
|
-
|
|
100999
|
-
deliverSessionEvent
|
|
101000
|
-
|
|
101001
|
-
|
|
101283
|
+
for (const [wanted, deliver2] of [
|
|
101284
|
+
[session, deliverSessionEvent],
|
|
101285
|
+
[activity, deliverSessionActivity]
|
|
101286
|
+
]) {
|
|
101287
|
+
if (!wanted) continue;
|
|
101288
|
+
try {
|
|
101289
|
+
deliver2(event, data);
|
|
101290
|
+
} catch (err) {
|
|
101291
|
+
console.error(`[headless] ${event} delivery failed:`, err);
|
|
101292
|
+
}
|
|
101002
101293
|
}
|
|
101003
101294
|
});
|
|
101004
101295
|
});
|
|
101005
101296
|
process.on("unhandledRejection", handleUnhandledRejection);
|
|
101297
|
+
startAppAlarms(deliverAlarm);
|
|
101006
101298
|
stopSessionEvents = () => {
|
|
101007
101299
|
untap2();
|
|
101300
|
+
stopAppAlarms();
|
|
101008
101301
|
process.off("unhandledRejection", handleUnhandledRejection);
|
|
101009
101302
|
};
|
|
101010
101303
|
}
|
|
@@ -101014,6 +101307,7 @@ function stopHeadlessEvents() {
|
|
|
101014
101307
|
}
|
|
101015
101308
|
function invalidateHeadlessRuntime(appId) {
|
|
101016
101309
|
invalidateCompiledApp(appId);
|
|
101310
|
+
activityApps = null;
|
|
101017
101311
|
if (!appId) {
|
|
101018
101312
|
runtimes.clear();
|
|
101019
101313
|
return;
|
|
@@ -101134,7 +101428,7 @@ function dispatchAppTool(toolName, args, workspace = "", callerSessionId) {
|
|
|
101134
101428
|
}
|
|
101135
101429
|
const callId = v4_default();
|
|
101136
101430
|
const result = new Promise((resolve, reject) => {
|
|
101137
|
-
const
|
|
101431
|
+
const timer3 = setTimeout(() => {
|
|
101138
101432
|
pendingCalls2.delete(callId);
|
|
101139
101433
|
reject(
|
|
101140
101434
|
new Error(
|
|
@@ -101142,7 +101436,7 @@ function dispatchAppTool(toolName, args, workspace = "", callerSessionId) {
|
|
|
101142
101436
|
)
|
|
101143
101437
|
);
|
|
101144
101438
|
}, TOOL_CALL_TIMEOUT_MS);
|
|
101145
|
-
pendingCalls2.set(callId, { resolve, reject, timer:
|
|
101439
|
+
pendingCalls2.set(callId, { resolve, reject, timer: timer3, appId });
|
|
101146
101440
|
broadcast("app:tool_call", { appId, callId, tool: localName, args: args ?? {}, workspace, caller });
|
|
101147
101441
|
});
|
|
101148
101442
|
return { callId, result };
|
|
@@ -101888,6 +102182,7 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101888
102182
|
fs7.rmSync(appDir(id), { recursive: true, force: true });
|
|
101889
102183
|
deleteAppFiles(id);
|
|
101890
102184
|
deleteAppInstances(id);
|
|
102185
|
+
deleteAppAlarms(id);
|
|
101891
102186
|
invalidateHeadlessRuntime(id);
|
|
101892
102187
|
return { ok: true };
|
|
101893
102188
|
});
|
|
@@ -102142,7 +102437,7 @@ function runCcusage(args) {
|
|
|
102142
102437
|
failure ??= reason;
|
|
102143
102438
|
child.kill("SIGTERM");
|
|
102144
102439
|
};
|
|
102145
|
-
const
|
|
102440
|
+
const timer3 = setTimeout(() => stop(`ccusage did not finish in ${RUN_TIMEOUT_MS / 1e3}s`), RUN_TIMEOUT_MS);
|
|
102146
102441
|
child.stdout.on("data", (chunk) => {
|
|
102147
102442
|
size2 += chunk.length;
|
|
102148
102443
|
if (size2 > MAX_OUTPUT_BYTES) stop("ccusage output is too large");
|
|
@@ -102152,11 +102447,11 @@ function runCcusage(args) {
|
|
|
102152
102447
|
if (stderr.length < 16384) stderr += chunk.toString("utf8");
|
|
102153
102448
|
});
|
|
102154
102449
|
child.on("error", (err) => {
|
|
102155
|
-
clearTimeout(
|
|
102450
|
+
clearTimeout(timer3);
|
|
102156
102451
|
reject(new Error(`ccusage could not start: ${err.message}`));
|
|
102157
102452
|
});
|
|
102158
102453
|
child.on("close", (code, signal) => {
|
|
102159
|
-
clearTimeout(
|
|
102454
|
+
clearTimeout(timer3);
|
|
102160
102455
|
if (failure) return reject(new Error(failure));
|
|
102161
102456
|
if (code !== 0) {
|
|
102162
102457
|
const detail = stderr.trim().split("\n").slice(-3).join(" ").slice(0, 500);
|
|
@@ -118568,11 +118863,11 @@ function requestHost(dir, body, timeoutMs = 2e3) {
|
|
|
118568
118863
|
const sock = net2.connect(hostSocketPath(dir));
|
|
118569
118864
|
let buf = "";
|
|
118570
118865
|
let settled = false;
|
|
118571
|
-
const
|
|
118866
|
+
const timer3 = setTimeout(() => finish(Object.assign(new Error("session host timed out"), { code: "ETIMEDOUT" })), timeoutMs);
|
|
118572
118867
|
const finish = (err, value) => {
|
|
118573
118868
|
if (settled) return;
|
|
118574
118869
|
settled = true;
|
|
118575
|
-
clearTimeout(
|
|
118870
|
+
clearTimeout(timer3);
|
|
118576
118871
|
sock.destroy();
|
|
118577
118872
|
if (err) reject(err);
|
|
118578
118873
|
else resolve(value);
|
|
@@ -118627,11 +118922,11 @@ function attachHost(dir, after, timeoutMs = 5e3) {
|
|
|
118627
118922
|
const sock = net2.connect(hostSocketPath(dir));
|
|
118628
118923
|
let head = Buffer.alloc(0);
|
|
118629
118924
|
let settled = false;
|
|
118630
|
-
const
|
|
118925
|
+
const timer3 = setTimeout(() => fail(Object.assign(new Error("session host attach timed out"), { code: "ETIMEDOUT" })), timeoutMs);
|
|
118631
118926
|
const fail = (err) => {
|
|
118632
118927
|
if (settled) return;
|
|
118633
118928
|
settled = true;
|
|
118634
|
-
clearTimeout(
|
|
118929
|
+
clearTimeout(timer3);
|
|
118635
118930
|
sock.destroy();
|
|
118636
118931
|
reject(err);
|
|
118637
118932
|
};
|
|
@@ -118656,7 +118951,7 @@ function attachHost(dir, after, timeoutMs = 5e3) {
|
|
|
118656
118951
|
return;
|
|
118657
118952
|
}
|
|
118658
118953
|
settled = true;
|
|
118659
|
-
clearTimeout(
|
|
118954
|
+
clearTimeout(timer3);
|
|
118660
118955
|
sock.off("error", fail);
|
|
118661
118956
|
sock.off("close", onEarlyClose);
|
|
118662
118957
|
const attachment = new HostAttachment(header, sock);
|
|
@@ -120612,15 +120907,15 @@ function handleItemEvent(params, sessionId, turnId, status, broadcastEvent, extr
|
|
|
120612
120907
|
}
|
|
120613
120908
|
function within(promise2, ms) {
|
|
120614
120909
|
return new Promise((resolve) => {
|
|
120615
|
-
const
|
|
120616
|
-
|
|
120910
|
+
const timer3 = setTimeout(() => resolve(null), ms);
|
|
120911
|
+
timer3.unref?.();
|
|
120617
120912
|
promise2.then(
|
|
120618
120913
|
(value) => {
|
|
120619
|
-
clearTimeout(
|
|
120914
|
+
clearTimeout(timer3);
|
|
120620
120915
|
resolve(value);
|
|
120621
120916
|
},
|
|
120622
120917
|
() => {
|
|
120623
|
-
clearTimeout(
|
|
120918
|
+
clearTimeout(timer3);
|
|
120624
120919
|
resolve(null);
|
|
120625
120920
|
}
|
|
120626
120921
|
);
|
|
@@ -121316,16 +121611,16 @@ function replayDone(client, what) {
|
|
|
121316
121611
|
if (!client.replaying || client.isClosed()) return Promise.resolve();
|
|
121317
121612
|
return new Promise((resolve) => {
|
|
121318
121613
|
const done = () => {
|
|
121319
|
-
clearTimeout(
|
|
121614
|
+
clearTimeout(timer3);
|
|
121320
121615
|
client.events.off("replayDone", done);
|
|
121321
121616
|
client.events.off("closed", done);
|
|
121322
121617
|
resolve();
|
|
121323
121618
|
};
|
|
121324
|
-
const
|
|
121619
|
+
const timer3 = setTimeout(() => {
|
|
121325
121620
|
console.error(`[codex] the replay of ${what} takes long; startup goes on`);
|
|
121326
121621
|
done();
|
|
121327
121622
|
}, REPLAY_WAIT_MS);
|
|
121328
|
-
|
|
121623
|
+
timer3.unref?.();
|
|
121329
121624
|
client.events.once("replayDone", done);
|
|
121330
121625
|
client.events.once("closed", done);
|
|
121331
121626
|
});
|
|
@@ -123692,18 +123987,18 @@ var claudeHostAdopter = {
|
|
|
123692
123987
|
retire
|
|
123693
123988
|
});
|
|
123694
123989
|
refreshHostLimit2(entry, running);
|
|
123695
|
-
let
|
|
123990
|
+
let timer3 = null;
|
|
123696
123991
|
await Promise.race([
|
|
123697
123992
|
entry.replayDone,
|
|
123698
123993
|
new Promise((resolve) => {
|
|
123699
|
-
|
|
123994
|
+
timer3 = setTimeout(() => {
|
|
123700
123995
|
console.error(`[claude] the replay of ${row.entry_key} takes long; startup goes on`);
|
|
123701
123996
|
resolve();
|
|
123702
123997
|
}, REPLAY_WAIT_MS2);
|
|
123703
|
-
|
|
123998
|
+
timer3.unref?.();
|
|
123704
123999
|
})
|
|
123705
124000
|
]);
|
|
123706
|
-
if (
|
|
124001
|
+
if (timer3) clearTimeout(timer3);
|
|
123707
124002
|
console.log(
|
|
123708
124003
|
`[claude] adopted the CLI of ${row.entry_key} (pid ${proc.pid ?? "?"})${running ? `, turn ${row.turn_id} goes on` : ""}${retire ? `; it closes once idle: ${retire}` : ""}`
|
|
123709
124004
|
);
|
|
@@ -123901,12 +124196,12 @@ var HttpError = class extends Error {
|
|
|
123901
124196
|
};
|
|
123902
124197
|
async function fetchJson(url2, init, timeoutMs = 5e3) {
|
|
123903
124198
|
const controller = new AbortController();
|
|
123904
|
-
const
|
|
124199
|
+
const timer3 = setTimeout(() => controller.abort(), timeoutMs);
|
|
123905
124200
|
let response;
|
|
123906
124201
|
try {
|
|
123907
124202
|
response = await fetch(url2, { ...init, signal: controller.signal });
|
|
123908
124203
|
} finally {
|
|
123909
|
-
clearTimeout(
|
|
124204
|
+
clearTimeout(timer3);
|
|
123910
124205
|
}
|
|
123911
124206
|
const text2 = await response.text();
|
|
123912
124207
|
if (!response.ok) {
|
|
@@ -124358,11 +124653,11 @@ async function getAgentRuntimeState(baseUrl, sessionId, timeoutMs = 5e3) {
|
|
|
124358
124653
|
function reconnectDelay(delayMs, signal) {
|
|
124359
124654
|
return new Promise((resolve) => {
|
|
124360
124655
|
if (signal?.aborted) return resolve();
|
|
124361
|
-
const
|
|
124656
|
+
const timer3 = setTimeout(resolve, delayMs);
|
|
124362
124657
|
signal?.addEventListener(
|
|
124363
124658
|
"abort",
|
|
124364
124659
|
() => {
|
|
124365
|
-
clearTimeout(
|
|
124660
|
+
clearTimeout(timer3);
|
|
124366
124661
|
resolve();
|
|
124367
124662
|
},
|
|
124368
124663
|
{ once: true }
|
|
@@ -124377,7 +124672,7 @@ async function runThrowawayPrompt(client, options) {
|
|
|
124377
124672
|
const created = await client.createSession(options.model ? { model_id: options.model } : {});
|
|
124378
124673
|
throwawayId = created.id;
|
|
124379
124674
|
const controller = new AbortController();
|
|
124380
|
-
const
|
|
124675
|
+
const timer3 = setTimeout(() => controller.abort(), options.timeoutMs);
|
|
124381
124676
|
try {
|
|
124382
124677
|
await client.createInput(throwawayId, {
|
|
124383
124678
|
user_prompt: options.prompt,
|
|
@@ -124404,7 +124699,7 @@ async function runThrowawayPrompt(client, options) {
|
|
|
124404
124699
|
}
|
|
124405
124700
|
return failed ? null : reply;
|
|
124406
124701
|
} finally {
|
|
124407
|
-
clearTimeout(
|
|
124702
|
+
clearTimeout(timer3);
|
|
124408
124703
|
}
|
|
124409
124704
|
} catch {
|
|
124410
124705
|
return null;
|