repoburg 1.3.320 → 1.3.322
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,
|
|
@@ -44111,14 +44124,14 @@ var AppServerClient = class {
|
|
|
44111
44124
|
}
|
|
44112
44125
|
const id = this.nextId++;
|
|
44113
44126
|
const message = JSON.stringify({ id, method, params }) + "\n";
|
|
44114
|
-
const
|
|
44127
|
+
const timer3 = setTimeout(() => {
|
|
44115
44128
|
this.pending.delete(id);
|
|
44116
44129
|
reject(new Error(`Request '${method}' (id=${id}) timed out after ${REQUEST_TIMEOUT_MS}ms`));
|
|
44117
44130
|
}, REQUEST_TIMEOUT_MS);
|
|
44118
44131
|
this.pending.set(id, {
|
|
44119
44132
|
resolve,
|
|
44120
44133
|
reject,
|
|
44121
|
-
timer:
|
|
44134
|
+
timer: timer3
|
|
44122
44135
|
});
|
|
44123
44136
|
this.write(message);
|
|
44124
44137
|
});
|
|
@@ -44193,14 +44206,14 @@ var AppServerClient = class {
|
|
|
44193
44206
|
if (this.gone) return Promise.resolve(true);
|
|
44194
44207
|
return new Promise((resolve) => {
|
|
44195
44208
|
const onExit = () => {
|
|
44196
|
-
clearTimeout(
|
|
44209
|
+
clearTimeout(timer3);
|
|
44197
44210
|
resolve(true);
|
|
44198
44211
|
};
|
|
44199
|
-
const
|
|
44212
|
+
const timer3 = setTimeout(() => {
|
|
44200
44213
|
this.proc.removeListener("exit", onExit);
|
|
44201
44214
|
resolve(false);
|
|
44202
44215
|
}, ms);
|
|
44203
|
-
|
|
44216
|
+
timer3.unref?.();
|
|
44204
44217
|
this.proc.once("exit", onExit);
|
|
44205
44218
|
});
|
|
44206
44219
|
}
|
|
@@ -44925,14 +44938,14 @@ var VscodeWebManager = class {
|
|
|
44925
44938
|
waitForReady(inst) {
|
|
44926
44939
|
const deadline = this.deps.now() + STARTUP_TIMEOUT_MS;
|
|
44927
44940
|
return new Promise((resolve) => {
|
|
44928
|
-
const
|
|
44941
|
+
const timer3 = setInterval(async () => {
|
|
44929
44942
|
if (inst.state !== "starting") {
|
|
44930
|
-
clearInterval(
|
|
44943
|
+
clearInterval(timer3);
|
|
44931
44944
|
resolve();
|
|
44932
44945
|
return;
|
|
44933
44946
|
}
|
|
44934
44947
|
if (this.deps.now() > deadline) {
|
|
44935
|
-
clearInterval(
|
|
44948
|
+
clearInterval(timer3);
|
|
44936
44949
|
inst.state = "error";
|
|
44937
44950
|
inst.error = `serve-web did not become ready within ${STARTUP_TIMEOUT_MS / 1e3}s`;
|
|
44938
44951
|
inst.stopping = true;
|
|
@@ -44944,7 +44957,7 @@ var VscodeWebManager = class {
|
|
|
44944
44957
|
}
|
|
44945
44958
|
try {
|
|
44946
44959
|
await this.deps.probe(inst.port, inst.token, inst.id);
|
|
44947
|
-
clearInterval(
|
|
44960
|
+
clearInterval(timer3);
|
|
44948
44961
|
if (inst.state === "starting") {
|
|
44949
44962
|
inst.state = "running";
|
|
44950
44963
|
this.markAccessed(inst.id);
|
|
@@ -99430,7 +99443,8 @@ Each subdirectory of this folder is one mini app:
|
|
|
99430
99443
|
<app-id>/
|
|
99431
99444
|
manifest.json - { "title": string, "description"?: string, "icon"?: string,
|
|
99432
99445
|
"tools"?: [{ "name", "description", "inputSchema" }],
|
|
99433
|
-
"headlessSessions"?: boolean
|
|
99446
|
+
"headlessSessions"?: boolean,
|
|
99447
|
+
"sessionActivity"?: boolean }
|
|
99434
99448
|
"icon" is the app logo: a Lucide icon name (see
|
|
99435
99449
|
"Icons and logos" below)
|
|
99436
99450
|
index.html - markup only (full HTML document); do NOT reference app.js
|
|
@@ -99626,6 +99640,46 @@ runtime and events go to the open tab only.
|
|
|
99626
99640
|
- events are not replayed. Keep the session ids in the state, and when the
|
|
99627
99641
|
runtime loads ask getSession(id) what happened while the pane was down
|
|
99628
99642
|
|
|
99643
|
+
## Other sessions' turns (manifest "sessionActivity")
|
|
99644
|
+
|
|
99645
|
+
Set "sessionActivity": true in manifest.json to hear when a turn starts or
|
|
99646
|
+
ends in a session the app did NOT open (the user's sessions, other apps'):
|
|
99647
|
+
|
|
99648
|
+
AgentPane.onSessionActivity(({ event, sessionId, turnId, origin, originName, cancelled }) => ...)
|
|
99649
|
+
|
|
99650
|
+
- event is 'turn:started', 'turn:completed' or 'turn:failed' (cancelled: true
|
|
99651
|
+
when the user stopped it); turns of discussion threads are left out
|
|
99652
|
+
- origin is 'peer' when a message from another Claude session (SendMessage)
|
|
99653
|
+
started the turn, with originName the sender's name; null otherwise
|
|
99654
|
+
- turn:started can come again for the same turnId (a background task's
|
|
99655
|
+
follow-up reopens the turn): dedupe by turnId
|
|
99656
|
+
- read the session with getSessionInfo(sessionId) (cwd, runtime_type,
|
|
99657
|
+
transcript_path); the prompt itself is in the transcript
|
|
99658
|
+
- fires in the headless runtime only, with or without a tab: in the global
|
|
99659
|
+
instance, and in every workspace instance that has state and sees the
|
|
99660
|
+
session. Register the listener synchronously at startup
|
|
99661
|
+
- the app's own sessions are not reported here: they have onTurnCompleted
|
|
99662
|
+
|
|
99663
|
+
## Alarms
|
|
99664
|
+
|
|
99665
|
+
The headless runtime's setTimeout dies with it (pane restart, hot reload).
|
|
99666
|
+
For a wake-up that must happen, use an alarm; the pane keeps it in its
|
|
99667
|
+
database and fires it into the instance that set it, loading it if needed:
|
|
99668
|
+
|
|
99669
|
+
await AgentPane.setAlarm('checkin:' + id, 15 * 60_000, { id }); // { name, fireAt, data }
|
|
99670
|
+
AgentPane.onAlarm(({ name, data, fireAt }) => ...);
|
|
99671
|
+
await AgentPane.clearAlarm(name); // { cleared }
|
|
99672
|
+
await AgentPane.listAlarms(); // soonest first
|
|
99673
|
+
|
|
99674
|
+
- headless only: in the tab these reject (use callTool to reach the headless
|
|
99675
|
+
runtime) and onAlarm never fires there
|
|
99676
|
+
- names are per instance; setting a name again moves that alarm. An alarm
|
|
99677
|
+
fires once, then it is gone. delayMs is at most 30 days, data at most 64 KB
|
|
99678
|
+
of JSON, at most 200 alarms per instance
|
|
99679
|
+
- an alarm that came due while the pane was down fires right after startup;
|
|
99680
|
+
check the state before acting on it
|
|
99681
|
+
- register onAlarm synchronously at startup. Deleting the app drops its alarms
|
|
99682
|
+
|
|
99629
99683
|
## Result contract
|
|
99630
99684
|
|
|
99631
99685
|
To give the app a structured result, put this requirement in the job prompt:
|
|
@@ -99646,12 +99700,20 @@ function readManifestIn(dir) {
|
|
|
99646
99700
|
description: typeof parsed.description === "string" ? parsed.description : void 0,
|
|
99647
99701
|
icon: typeof parsed.icon === "string" ? parsed.icon : void 0,
|
|
99648
99702
|
tools: Array.isArray(parsed.tools) ? parsed.tools.filter((t) => t && typeof t.name === "string" && typeof t.description === "string") : void 0,
|
|
99649
|
-
headlessSessions: parsed.headlessSessions === true ? true : void 0
|
|
99703
|
+
headlessSessions: parsed.headlessSessions === true ? true : void 0,
|
|
99704
|
+
sessionActivity: parsed.sessionActivity === true ? true : void 0
|
|
99650
99705
|
};
|
|
99651
99706
|
} catch {
|
|
99652
99707
|
return null;
|
|
99653
99708
|
}
|
|
99654
99709
|
}
|
|
99710
|
+
function listAppIds() {
|
|
99711
|
+
try {
|
|
99712
|
+
return fs2.readdirSync(appsRoot(), { withFileTypes: true }).filter((entry) => entry.isDirectory() && APP_ID_RE.test(entry.name)).map((entry) => entry.name);
|
|
99713
|
+
} catch {
|
|
99714
|
+
return [];
|
|
99715
|
+
}
|
|
99716
|
+
}
|
|
99655
99717
|
function readManifest(id) {
|
|
99656
99718
|
return readManifestIn(appDir(id));
|
|
99657
99719
|
}
|
|
@@ -99695,8 +99757,8 @@ function startAppsWatch(onAppChange) {
|
|
|
99695
99757
|
const file2 = segs[segs.length - 1];
|
|
99696
99758
|
if (!appId || appId === path5.basename(root) || !APP_ID_RE.test(appId) || file2 === "state.json") return;
|
|
99697
99759
|
if (segs.length === 1 && isRegularFile(path5.join(root, appId))) return;
|
|
99698
|
-
const
|
|
99699
|
-
if (
|
|
99760
|
+
const timer3 = pendingChanges.get(appId);
|
|
99761
|
+
if (timer3) clearTimeout(timer3);
|
|
99700
99762
|
pendingChanges.set(
|
|
99701
99763
|
appId,
|
|
99702
99764
|
setTimeout(() => {
|
|
@@ -99714,7 +99776,7 @@ function stopAppsWatch() {
|
|
|
99714
99776
|
watcher.close();
|
|
99715
99777
|
watcher = null;
|
|
99716
99778
|
}
|
|
99717
|
-
for (const
|
|
99779
|
+
for (const timer3 of pendingChanges.values()) clearTimeout(timer3);
|
|
99718
99780
|
pendingChanges.clear();
|
|
99719
99781
|
}
|
|
99720
99782
|
|
|
@@ -100231,6 +100293,13 @@ function appSessionSummary(appId, workspace, sessionId) {
|
|
|
100231
100293
|
if (!session || !sessionVisibleTo(session, appId, workspace)) return null;
|
|
100232
100294
|
return sessionSummary(session, appId);
|
|
100233
100295
|
}
|
|
100296
|
+
function activityInstances(appId, sessionId) {
|
|
100297
|
+
const db2 = getDb();
|
|
100298
|
+
const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
|
|
100299
|
+
if (!session || openedByApp(session, appId)) return [];
|
|
100300
|
+
const rows = db2.prepare("SELECT workspace_path FROM app_instances WHERE app_id = ? AND workspace_path != '' ORDER BY workspace_path").all(appId);
|
|
100301
|
+
return ["", ...rows.map((r) => r.workspace_path).filter((w) => sessionVisibleTo(session, appId, w))];
|
|
100302
|
+
}
|
|
100234
100303
|
function ownSession(appId, sessionId, api) {
|
|
100235
100304
|
const session = getDb().prepare("SELECT * FROM sessions WHERE id = ?").get(String(sessionId));
|
|
100236
100305
|
if (!session || !openedByApp(session, appId)) {
|
|
@@ -100273,6 +100342,124 @@ function toolCaller(appId, sessionId) {
|
|
|
100273
100342
|
// src/apps/headless-runtime.ts
|
|
100274
100343
|
import vm2 from "node:vm";
|
|
100275
100344
|
|
|
100345
|
+
// src/apps/app-alarms.ts
|
|
100346
|
+
var MAX_ALARM_DELAY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
100347
|
+
var MAX_ALARMS_PER_INSTANCE = 200;
|
|
100348
|
+
var MAX_NAME_LENGTH = 200;
|
|
100349
|
+
var MAX_DATA_BYTES = 64 * 1024;
|
|
100350
|
+
var MAX_TIMER_WAIT_MS = 60 * 60 * 1e3;
|
|
100351
|
+
function parseData(raw) {
|
|
100352
|
+
if (raw == null) return null;
|
|
100353
|
+
try {
|
|
100354
|
+
return JSON.parse(raw);
|
|
100355
|
+
} catch {
|
|
100356
|
+
return null;
|
|
100357
|
+
}
|
|
100358
|
+
}
|
|
100359
|
+
function toAlarm(row) {
|
|
100360
|
+
return { name: row.name, fireAt: row.fire_at, data: parseData(row.data) };
|
|
100361
|
+
}
|
|
100362
|
+
function setAppAlarm(appId, workspace, name, delayMs, data) {
|
|
100363
|
+
if (typeof name !== "string" || !name.trim() || name.length > MAX_NAME_LENGTH) {
|
|
100364
|
+
throw new Error(`setAlarm: name must be a non-empty string of at most ${MAX_NAME_LENGTH} characters`);
|
|
100365
|
+
}
|
|
100366
|
+
if (typeof delayMs !== "number" || !Number.isFinite(delayMs) || delayMs < 0) {
|
|
100367
|
+
throw new Error("setAlarm: delayMs must be a number of milliseconds, 0 or more");
|
|
100368
|
+
}
|
|
100369
|
+
if (delayMs > MAX_ALARM_DELAY_MS) {
|
|
100370
|
+
throw new Error(`setAlarm: delayMs is at most ${MAX_ALARM_DELAY_MS} (30 days)`);
|
|
100371
|
+
}
|
|
100372
|
+
let json2 = null;
|
|
100373
|
+
if (data !== void 0) {
|
|
100374
|
+
try {
|
|
100375
|
+
json2 = JSON.stringify(data) ?? null;
|
|
100376
|
+
} catch {
|
|
100377
|
+
throw new Error("setAlarm: data must be JSON");
|
|
100378
|
+
}
|
|
100379
|
+
if (json2 && Buffer.byteLength(json2) > MAX_DATA_BYTES) {
|
|
100380
|
+
throw new Error(`setAlarm: data is at most ${MAX_DATA_BYTES} bytes of JSON`);
|
|
100381
|
+
}
|
|
100382
|
+
}
|
|
100383
|
+
const db2 = getDb();
|
|
100384
|
+
const exists2 = db2.prepare("SELECT 1 FROM app_alarms WHERE app_id = ? AND workspace_path = ? AND name = ?").get(appId, workspace, name);
|
|
100385
|
+
if (!exists2) {
|
|
100386
|
+
const { n } = db2.prepare("SELECT COUNT(*) AS n FROM app_alarms WHERE app_id = ? AND workspace_path = ?").get(appId, workspace);
|
|
100387
|
+
if (n >= MAX_ALARMS_PER_INSTANCE) {
|
|
100388
|
+
throw new Error(`setAlarm: an instance holds at most ${MAX_ALARMS_PER_INSTANCE} alarms; clear one first`);
|
|
100389
|
+
}
|
|
100390
|
+
}
|
|
100391
|
+
const fireAt = Date.now() + Math.round(delayMs);
|
|
100392
|
+
db2.prepare(
|
|
100393
|
+
`INSERT INTO app_alarms (app_id, workspace_path, name, fire_at, data, created_at)
|
|
100394
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
100395
|
+
ON CONFLICT(app_id, workspace_path, name) DO UPDATE SET
|
|
100396
|
+
fire_at = excluded.fire_at, data = excluded.data, created_at = excluded.created_at`
|
|
100397
|
+
).run(appId, workspace, name, fireAt, json2, (/* @__PURE__ */ new Date()).toISOString());
|
|
100398
|
+
schedule();
|
|
100399
|
+
return { name, fireAt, data: parseData(json2) };
|
|
100400
|
+
}
|
|
100401
|
+
function clearAppAlarm(appId, workspace, name) {
|
|
100402
|
+
if (typeof name !== "string") throw new Error("clearAlarm: name must be a string");
|
|
100403
|
+
const { changes } = getDb().prepare("DELETE FROM app_alarms WHERE app_id = ? AND workspace_path = ? AND name = ?").run(appId, workspace, name);
|
|
100404
|
+
schedule();
|
|
100405
|
+
return { cleared: changes > 0 };
|
|
100406
|
+
}
|
|
100407
|
+
function listAppAlarms(appId, workspace) {
|
|
100408
|
+
const rows = getDb().prepare("SELECT * FROM app_alarms WHERE app_id = ? AND workspace_path = ? ORDER BY fire_at, name").all(appId, workspace);
|
|
100409
|
+
return rows.map(toAlarm);
|
|
100410
|
+
}
|
|
100411
|
+
function deleteAppAlarms(appId) {
|
|
100412
|
+
getDb().prepare("DELETE FROM app_alarms WHERE app_id = ?").run(appId);
|
|
100413
|
+
schedule();
|
|
100414
|
+
}
|
|
100415
|
+
var deliver = null;
|
|
100416
|
+
var timer2 = null;
|
|
100417
|
+
function fireDueAlarms(now = Date.now()) {
|
|
100418
|
+
const db2 = getDb();
|
|
100419
|
+
const due = db2.transaction(() => {
|
|
100420
|
+
const rows = db2.prepare("SELECT * FROM app_alarms WHERE fire_at <= ? ORDER BY fire_at, name").all(now);
|
|
100421
|
+
const drop = db2.prepare("DELETE FROM app_alarms WHERE app_id = ? AND workspace_path = ? AND name = ?");
|
|
100422
|
+
for (const row of rows) drop.run(row.app_id, row.workspace_path, row.name);
|
|
100423
|
+
return rows;
|
|
100424
|
+
}).immediate().map((row) => ({ appId: row.app_id, workspace: row.workspace_path, ...toAlarm(row) }));
|
|
100425
|
+
for (const alarm of due) {
|
|
100426
|
+
try {
|
|
100427
|
+
deliver?.(alarm);
|
|
100428
|
+
} catch (err) {
|
|
100429
|
+
console.error(`[alarms] ${alarm.appId} alarm ${alarm.name} failed:`, err);
|
|
100430
|
+
}
|
|
100431
|
+
}
|
|
100432
|
+
return due;
|
|
100433
|
+
}
|
|
100434
|
+
function schedule() {
|
|
100435
|
+
if (!deliver) return;
|
|
100436
|
+
if (timer2) clearTimeout(timer2);
|
|
100437
|
+
timer2 = null;
|
|
100438
|
+
const next = getDb().prepare("SELECT MIN(fire_at) AS at FROM app_alarms").get();
|
|
100439
|
+
if (next.at == null) return;
|
|
100440
|
+
const wait = Math.min(Math.max(next.at - Date.now(), 0), MAX_TIMER_WAIT_MS);
|
|
100441
|
+
timer2 = setTimeout(() => {
|
|
100442
|
+
timer2 = null;
|
|
100443
|
+
try {
|
|
100444
|
+
fireDueAlarms();
|
|
100445
|
+
} catch (err) {
|
|
100446
|
+
console.error("[alarms] firing failed:", err);
|
|
100447
|
+
}
|
|
100448
|
+
schedule();
|
|
100449
|
+
}, wait);
|
|
100450
|
+
timer2.unref?.();
|
|
100451
|
+
}
|
|
100452
|
+
function startAppAlarms(onDue) {
|
|
100453
|
+
stopAppAlarms();
|
|
100454
|
+
deliver = onDue;
|
|
100455
|
+
schedule();
|
|
100456
|
+
}
|
|
100457
|
+
function stopAppAlarms() {
|
|
100458
|
+
if (timer2) clearTimeout(timer2);
|
|
100459
|
+
timer2 = null;
|
|
100460
|
+
deliver = null;
|
|
100461
|
+
}
|
|
100462
|
+
|
|
100276
100463
|
// src/apps/app-compile.ts
|
|
100277
100464
|
import vm from "node:vm";
|
|
100278
100465
|
import path9 from "node:path";
|
|
@@ -100481,6 +100668,23 @@ interface AgentPaneFileData { name?: string; type?: string; data: string }
|
|
|
100481
100668
|
type AgentPaneFileRef = string | { id?: string; url?: string };
|
|
100482
100669
|
/** A submitTurn attachment: a stored file, or inline bytes sent with that turn only. */
|
|
100483
100670
|
type AgentPaneAttachment = AgentPaneFileRef | Blob | AgentPaneFileData;
|
|
100671
|
+
/** onSessionActivity: a turn started or ended in a session this app did not
|
|
100672
|
+
* open. Read the session with getSessionInfo (cwd, runtime_type,
|
|
100673
|
+
* transcript_path). */
|
|
100674
|
+
interface AgentPaneSessionActivity {
|
|
100675
|
+
event: 'turn:started' | 'turn:completed' | 'turn:failed';
|
|
100676
|
+
sessionId: string;
|
|
100677
|
+
turnId: string;
|
|
100678
|
+
/** 'peer': a message from another Claude session (SendMessage) started the
|
|
100679
|
+
* turn; null: the user, or an app. */
|
|
100680
|
+
origin: 'peer' | null;
|
|
100681
|
+
/** The sending session's name for a peer turn, else null. */
|
|
100682
|
+
originName: string | null;
|
|
100683
|
+
/** turn:failed of a turn the user stopped. */
|
|
100684
|
+
cancelled?: boolean;
|
|
100685
|
+
}
|
|
100686
|
+
/** An alarm of this instance (setAlarm). fireAt is epoch ms. */
|
|
100687
|
+
interface AgentPaneAlarm { name: string; fireAt: number; data: unknown }
|
|
100484
100688
|
interface AgentPaneSubmitTurnOptions {
|
|
100485
100689
|
/** Files the agent receives with the prompt (images are shown to the model). */
|
|
100486
100690
|
attachments?: AgentPaneAttachment[];
|
|
@@ -100532,6 +100736,21 @@ declare const AgentPane: {
|
|
|
100532
100736
|
/** Fires when the live background-task set of one of the app's sessions
|
|
100533
100737
|
* changes (also empty sets, when the last task ends). */
|
|
100534
100738
|
onBackgroundTasks(cb: (payload: AgentPaneBackgroundTasksPayload | null) => void): void;
|
|
100739
|
+
/** Headless only, with "sessionActivity": true in the manifest: a turn
|
|
100740
|
+
* started or ended in a session this app did not open (the user's), in
|
|
100741
|
+
* this instance's sight. turn:started can come again for the same turnId
|
|
100742
|
+
* when a background task's follow-up reopens the turn. */
|
|
100743
|
+
onSessionActivity(cb: (payload: AgentPaneSessionActivity) => void): void;
|
|
100744
|
+
/** Headless only: wake this instance in delayMs (at most 30 days), also
|
|
100745
|
+
* after a pane restart. Setting a name again moves that alarm. data (JSON)
|
|
100746
|
+
* comes back with it. Rejects in the tab. */
|
|
100747
|
+
setAlarm(name: string, delayMs: number, data?: unknown): Promise<AgentPaneAlarm>;
|
|
100748
|
+
/** Headless only: drop an alarm; cleared is false when none had the name. */
|
|
100749
|
+
clearAlarm(name: string): Promise<{ cleared: boolean }>;
|
|
100750
|
+
/** Headless only: this instance's alarms, soonest first. */
|
|
100751
|
+
listAlarms(): Promise<AgentPaneAlarm[]>;
|
|
100752
|
+
/** Headless only: an alarm of this instance came due. It fires once. */
|
|
100753
|
+
onAlarm(cb: (alarm: AgentPaneAlarm) => void): void;
|
|
100535
100754
|
resolveToolCall(callId: string, result?: unknown): Promise<{ ok: boolean }>;
|
|
100536
100755
|
/** Show a session in the pane (switches the view to its conversation).
|
|
100537
100756
|
* Only works while the app is on screen: call it from a click handler. */
|
|
@@ -100825,7 +101044,13 @@ function loadRuntime(appId, workspace) {
|
|
|
100825
101044
|
if (headlessSessions) return;
|
|
100826
101045
|
throw new Error(`${api} is not available in the headless runtime without "headlessSessions": true in manifest.json`);
|
|
100827
101046
|
};
|
|
100828
|
-
const entry = {
|
|
101047
|
+
const entry = {
|
|
101048
|
+
handler: null,
|
|
101049
|
+
turnListeners: [],
|
|
101050
|
+
taskListeners: [],
|
|
101051
|
+
activityListeners: [],
|
|
101052
|
+
alarmListeners: []
|
|
101053
|
+
};
|
|
100829
101054
|
const bridge = {
|
|
100830
101055
|
getApp: () => answer(() => ({ id: appId, title: manifest?.title ?? appId, workspace })),
|
|
100831
101056
|
// State is scoped to the calling session's workspace instance; '' = global
|
|
@@ -100901,9 +101126,23 @@ function loadRuntime(appId, workspace) {
|
|
|
100901
101126
|
onBackgroundTasks: (cb) => {
|
|
100902
101127
|
if (typeof cb === "function") entry.taskListeners.push(cb);
|
|
100903
101128
|
},
|
|
100904
|
-
//
|
|
101129
|
+
// Heard only with "sessionActivity" in the manifest (deliverSessionActivity).
|
|
101130
|
+
onSessionActivity: (cb) => {
|
|
101131
|
+
if (typeof cb === "function") entry.activityListeners.push(cb);
|
|
101132
|
+
},
|
|
101133
|
+
setAlarm: (name, delayMs, data) => answer(() => setAppAlarm(appId, workspace, name, delayMs, data)),
|
|
101134
|
+
clearAlarm: (name) => answer(() => clearAppAlarm(appId, workspace, name)),
|
|
101135
|
+
listAlarms: () => answer(() => listAppAlarms(appId, workspace)),
|
|
101136
|
+
onAlarm: (cb) => {
|
|
101137
|
+
if (typeof cb === "function") entry.alarmListeners.push(cb);
|
|
101138
|
+
},
|
|
101139
|
+
// Live streaming is for a screen; nothing here renders. The same goes for
|
|
101140
|
+
// state changes: the tab re-renders on them, and an app.ts shared by tab
|
|
101141
|
+
// and runtime registers that at startup — which must not fail the load.
|
|
100905
101142
|
onTurnDelta: () => {
|
|
100906
101143
|
},
|
|
101144
|
+
onStateChanged: () => {
|
|
101145
|
+
},
|
|
100907
101146
|
// UI actions are intentionally unavailable headless.
|
|
100908
101147
|
openSession: () => answer(() => {
|
|
100909
101148
|
throw new Error("openSession is not available in the headless runtime");
|
|
@@ -100932,7 +101171,8 @@ function loadRuntime(appId, workspace) {
|
|
|
100932
101171
|
console.warn(`[headless:${appId}] app.js load failed: ${err.message}`);
|
|
100933
101172
|
return null;
|
|
100934
101173
|
}
|
|
100935
|
-
|
|
101174
|
+
const listens = entry.turnListeners.length || entry.taskListeners.length || entry.activityListeners.length || entry.alarmListeners.length;
|
|
101175
|
+
if (!entry.handler && !listens) return null;
|
|
100936
101176
|
runtimes.set(key, entry);
|
|
100937
101177
|
return entry;
|
|
100938
101178
|
}
|
|
@@ -100942,7 +101182,7 @@ function getHeadlessToolHandler(appId, workspace = "") {
|
|
|
100942
101182
|
function dispatchHeadlessToolCall(handler, tool2, args, caller = null) {
|
|
100943
101183
|
const callId = v4_default();
|
|
100944
101184
|
const result = new Promise((resolve, reject) => {
|
|
100945
|
-
const
|
|
101185
|
+
const timer3 = setTimeout(() => {
|
|
100946
101186
|
pendingCalls.delete(callId);
|
|
100947
101187
|
reject(
|
|
100948
101188
|
new Error(
|
|
@@ -100950,7 +101190,7 @@ function dispatchHeadlessToolCall(handler, tool2, args, caller = null) {
|
|
|
100950
101190
|
)
|
|
100951
101191
|
);
|
|
100952
101192
|
}, HEADLESS_TOOL_TIMEOUT_MS);
|
|
100953
|
-
pendingCalls.set(callId, { resolve, reject, timer:
|
|
101193
|
+
pendingCalls.set(callId, { resolve, reject, timer: timer3 });
|
|
100954
101194
|
});
|
|
100955
101195
|
const crashed = (err) => {
|
|
100956
101196
|
const pending = pendingCalls.get(callId);
|
|
@@ -101002,6 +101242,49 @@ function deliverSessionEvent(event, data) {
|
|
|
101002
101242
|
for (const listener of runtime.turnListeners) runAppCode(appId, () => listener(name, payload));
|
|
101003
101243
|
}
|
|
101004
101244
|
var SESSION_EVENTS = /* @__PURE__ */ new Set(["turn:completed", "turn:failed", "turn:cancelled", "background_tasks"]);
|
|
101245
|
+
var ACTIVITY_EVENTS = /* @__PURE__ */ new Set(["turn:started", "turn:completed", "turn:failed", "turn:cancelled"]);
|
|
101246
|
+
var activityApps = null;
|
|
101247
|
+
function sessionActivityApps() {
|
|
101248
|
+
activityApps ??= listAppIds().filter((id) => readManifest(id)?.sessionActivity === true);
|
|
101249
|
+
return activityApps;
|
|
101250
|
+
}
|
|
101251
|
+
function activityPayload(event, data) {
|
|
101252
|
+
const sessionId = String(data.sessionId);
|
|
101253
|
+
const turnId = String(data.turnId);
|
|
101254
|
+
const turn = getTurnOrigin(turnId);
|
|
101255
|
+
if (!turn || turn.thread_id || turn.session_id !== sessionId) return null;
|
|
101256
|
+
const peer = turn.origin === "peer";
|
|
101257
|
+
const base = { sessionId, turnId, origin: peer ? "peer" : null, originName: peer ? turn.origin_name : null };
|
|
101258
|
+
if (event === "turn:started") return { event, ...base };
|
|
101259
|
+
const [name, payload] = turnEvent(event, data);
|
|
101260
|
+
return { event: name, ...base, ...payload.cancelled ? { cancelled: true } : {} };
|
|
101261
|
+
}
|
|
101262
|
+
function getTurnOrigin(turnId) {
|
|
101263
|
+
const row = getDb().prepare("SELECT session_id, thread_id, origin, origin_name FROM turns WHERE id = ?").get(turnId);
|
|
101264
|
+
return row ?? null;
|
|
101265
|
+
}
|
|
101266
|
+
function deliverSessionActivity(event, data) {
|
|
101267
|
+
const apps = sessionActivityApps();
|
|
101268
|
+
if (!apps.length) return;
|
|
101269
|
+
const payload = activityPayload(event, data);
|
|
101270
|
+
if (!payload) return;
|
|
101271
|
+
for (const appId of apps) {
|
|
101272
|
+
for (const workspace of activityInstances(appId, String(payload.sessionId))) {
|
|
101273
|
+
const runtime = loadRuntime(appId, workspace);
|
|
101274
|
+
if (!runtime) continue;
|
|
101275
|
+
for (const listener of runtime.activityListeners) runAppCode(appId, () => listener({ ...payload }));
|
|
101276
|
+
}
|
|
101277
|
+
}
|
|
101278
|
+
}
|
|
101279
|
+
function deliverAlarm(alarm) {
|
|
101280
|
+
const runtime = loadRuntime(alarm.appId, alarm.workspace);
|
|
101281
|
+
if (!runtime?.alarmListeners.length) {
|
|
101282
|
+
console.warn(`[headless:${alarm.appId}] alarm ${alarm.name} dropped: the app has no onAlarm listener headless`);
|
|
101283
|
+
return;
|
|
101284
|
+
}
|
|
101285
|
+
const payload = { name: alarm.name, data: alarm.data, fireAt: alarm.fireAt };
|
|
101286
|
+
for (const listener of runtime.alarmListeners) runAppCode(alarm.appId, () => listener({ ...payload }));
|
|
101287
|
+
}
|
|
101005
101288
|
function handleUnhandledRejection(reason, promise2) {
|
|
101006
101289
|
if (promise2 instanceof Promise) throw reason;
|
|
101007
101290
|
console.error("[headless] unhandled rejection in app code:", reason);
|
|
@@ -101010,18 +101293,28 @@ var stopSessionEvents = null;
|
|
|
101010
101293
|
function startHeadlessEvents() {
|
|
101011
101294
|
stopHeadlessEvents();
|
|
101012
101295
|
const untap2 = tapBroadcast((event, data) => {
|
|
101013
|
-
|
|
101296
|
+
const session = SESSION_EVENTS.has(event);
|
|
101297
|
+
const activity = ACTIVITY_EVENTS.has(event);
|
|
101298
|
+
if (!session && !activity) return;
|
|
101014
101299
|
setImmediate(() => {
|
|
101015
|
-
|
|
101016
|
-
deliverSessionEvent
|
|
101017
|
-
|
|
101018
|
-
|
|
101300
|
+
for (const [wanted, deliver2] of [
|
|
101301
|
+
[session, deliverSessionEvent],
|
|
101302
|
+
[activity, deliverSessionActivity]
|
|
101303
|
+
]) {
|
|
101304
|
+
if (!wanted) continue;
|
|
101305
|
+
try {
|
|
101306
|
+
deliver2(event, data);
|
|
101307
|
+
} catch (err) {
|
|
101308
|
+
console.error(`[headless] ${event} delivery failed:`, err);
|
|
101309
|
+
}
|
|
101019
101310
|
}
|
|
101020
101311
|
});
|
|
101021
101312
|
});
|
|
101022
101313
|
process.on("unhandledRejection", handleUnhandledRejection);
|
|
101314
|
+
startAppAlarms(deliverAlarm);
|
|
101023
101315
|
stopSessionEvents = () => {
|
|
101024
101316
|
untap2();
|
|
101317
|
+
stopAppAlarms();
|
|
101025
101318
|
process.off("unhandledRejection", handleUnhandledRejection);
|
|
101026
101319
|
};
|
|
101027
101320
|
}
|
|
@@ -101031,6 +101324,7 @@ function stopHeadlessEvents() {
|
|
|
101031
101324
|
}
|
|
101032
101325
|
function invalidateHeadlessRuntime(appId) {
|
|
101033
101326
|
invalidateCompiledApp(appId);
|
|
101327
|
+
activityApps = null;
|
|
101034
101328
|
if (!appId) {
|
|
101035
101329
|
runtimes.clear();
|
|
101036
101330
|
return;
|
|
@@ -101151,7 +101445,7 @@ function dispatchAppTool(toolName, args, workspace = "", callerSessionId) {
|
|
|
101151
101445
|
}
|
|
101152
101446
|
const callId = v4_default();
|
|
101153
101447
|
const result = new Promise((resolve, reject) => {
|
|
101154
|
-
const
|
|
101448
|
+
const timer3 = setTimeout(() => {
|
|
101155
101449
|
pendingCalls2.delete(callId);
|
|
101156
101450
|
reject(
|
|
101157
101451
|
new Error(
|
|
@@ -101159,7 +101453,7 @@ function dispatchAppTool(toolName, args, workspace = "", callerSessionId) {
|
|
|
101159
101453
|
)
|
|
101160
101454
|
);
|
|
101161
101455
|
}, TOOL_CALL_TIMEOUT_MS);
|
|
101162
|
-
pendingCalls2.set(callId, { resolve, reject, timer:
|
|
101456
|
+
pendingCalls2.set(callId, { resolve, reject, timer: timer3, appId });
|
|
101163
101457
|
broadcast("app:tool_call", { appId, callId, tool: localName, args: args ?? {}, workspace, caller });
|
|
101164
101458
|
});
|
|
101165
101459
|
return { callId, result };
|
|
@@ -101905,6 +102199,7 @@ async function registerAppRoutes(fastify, opts) {
|
|
|
101905
102199
|
fs7.rmSync(appDir(id), { recursive: true, force: true });
|
|
101906
102200
|
deleteAppFiles(id);
|
|
101907
102201
|
deleteAppInstances(id);
|
|
102202
|
+
deleteAppAlarms(id);
|
|
101908
102203
|
invalidateHeadlessRuntime(id);
|
|
101909
102204
|
return { ok: true };
|
|
101910
102205
|
});
|
|
@@ -102159,7 +102454,7 @@ function runCcusage(args) {
|
|
|
102159
102454
|
failure ??= reason;
|
|
102160
102455
|
child.kill("SIGTERM");
|
|
102161
102456
|
};
|
|
102162
|
-
const
|
|
102457
|
+
const timer3 = setTimeout(() => stop(`ccusage did not finish in ${RUN_TIMEOUT_MS / 1e3}s`), RUN_TIMEOUT_MS);
|
|
102163
102458
|
child.stdout.on("data", (chunk) => {
|
|
102164
102459
|
size2 += chunk.length;
|
|
102165
102460
|
if (size2 > MAX_OUTPUT_BYTES) stop("ccusage output is too large");
|
|
@@ -102169,11 +102464,11 @@ function runCcusage(args) {
|
|
|
102169
102464
|
if (stderr.length < 16384) stderr += chunk.toString("utf8");
|
|
102170
102465
|
});
|
|
102171
102466
|
child.on("error", (err) => {
|
|
102172
|
-
clearTimeout(
|
|
102467
|
+
clearTimeout(timer3);
|
|
102173
102468
|
reject(new Error(`ccusage could not start: ${err.message}`));
|
|
102174
102469
|
});
|
|
102175
102470
|
child.on("close", (code, signal) => {
|
|
102176
|
-
clearTimeout(
|
|
102471
|
+
clearTimeout(timer3);
|
|
102177
102472
|
if (failure) return reject(new Error(failure));
|
|
102178
102473
|
if (code !== 0) {
|
|
102179
102474
|
const detail = stderr.trim().split("\n").slice(-3).join(" ").slice(0, 500);
|
|
@@ -118585,11 +118880,11 @@ function requestHost(dir, body, timeoutMs = 2e3) {
|
|
|
118585
118880
|
const sock = net2.connect(hostSocketPath(dir));
|
|
118586
118881
|
let buf = "";
|
|
118587
118882
|
let settled = false;
|
|
118588
|
-
const
|
|
118883
|
+
const timer3 = setTimeout(() => finish(Object.assign(new Error("session host timed out"), { code: "ETIMEDOUT" })), timeoutMs);
|
|
118589
118884
|
const finish = (err, value) => {
|
|
118590
118885
|
if (settled) return;
|
|
118591
118886
|
settled = true;
|
|
118592
|
-
clearTimeout(
|
|
118887
|
+
clearTimeout(timer3);
|
|
118593
118888
|
sock.destroy();
|
|
118594
118889
|
if (err) reject(err);
|
|
118595
118890
|
else resolve(value);
|
|
@@ -118644,11 +118939,11 @@ function attachHost(dir, after, timeoutMs = 5e3) {
|
|
|
118644
118939
|
const sock = net2.connect(hostSocketPath(dir));
|
|
118645
118940
|
let head = Buffer.alloc(0);
|
|
118646
118941
|
let settled = false;
|
|
118647
|
-
const
|
|
118942
|
+
const timer3 = setTimeout(() => fail(Object.assign(new Error("session host attach timed out"), { code: "ETIMEDOUT" })), timeoutMs);
|
|
118648
118943
|
const fail = (err) => {
|
|
118649
118944
|
if (settled) return;
|
|
118650
118945
|
settled = true;
|
|
118651
|
-
clearTimeout(
|
|
118946
|
+
clearTimeout(timer3);
|
|
118652
118947
|
sock.destroy();
|
|
118653
118948
|
reject(err);
|
|
118654
118949
|
};
|
|
@@ -118673,7 +118968,7 @@ function attachHost(dir, after, timeoutMs = 5e3) {
|
|
|
118673
118968
|
return;
|
|
118674
118969
|
}
|
|
118675
118970
|
settled = true;
|
|
118676
|
-
clearTimeout(
|
|
118971
|
+
clearTimeout(timer3);
|
|
118677
118972
|
sock.off("error", fail);
|
|
118678
118973
|
sock.off("close", onEarlyClose);
|
|
118679
118974
|
const attachment = new HostAttachment(header, sock);
|
|
@@ -120599,15 +120894,15 @@ function handleItemEvent(params, sessionId, turnId, status, broadcastEvent, extr
|
|
|
120599
120894
|
}
|
|
120600
120895
|
function within(promise2, ms) {
|
|
120601
120896
|
return new Promise((resolve) => {
|
|
120602
|
-
const
|
|
120603
|
-
|
|
120897
|
+
const timer3 = setTimeout(() => resolve(null), ms);
|
|
120898
|
+
timer3.unref?.();
|
|
120604
120899
|
promise2.then(
|
|
120605
120900
|
(value) => {
|
|
120606
|
-
clearTimeout(
|
|
120901
|
+
clearTimeout(timer3);
|
|
120607
120902
|
resolve(value);
|
|
120608
120903
|
},
|
|
120609
120904
|
() => {
|
|
120610
|
-
clearTimeout(
|
|
120905
|
+
clearTimeout(timer3);
|
|
120611
120906
|
resolve(null);
|
|
120612
120907
|
}
|
|
120613
120908
|
);
|
|
@@ -121303,16 +121598,16 @@ function replayDone(client, what) {
|
|
|
121303
121598
|
if (!client.replaying || client.isClosed()) return Promise.resolve();
|
|
121304
121599
|
return new Promise((resolve) => {
|
|
121305
121600
|
const done = () => {
|
|
121306
|
-
clearTimeout(
|
|
121601
|
+
clearTimeout(timer3);
|
|
121307
121602
|
client.events.off("replayDone", done);
|
|
121308
121603
|
client.events.off("closed", done);
|
|
121309
121604
|
resolve();
|
|
121310
121605
|
};
|
|
121311
|
-
const
|
|
121606
|
+
const timer3 = setTimeout(() => {
|
|
121312
121607
|
console.error(`[codex] the replay of ${what} takes long; startup goes on`);
|
|
121313
121608
|
done();
|
|
121314
121609
|
}, REPLAY_WAIT_MS);
|
|
121315
|
-
|
|
121610
|
+
timer3.unref?.();
|
|
121316
121611
|
client.events.once("replayDone", done);
|
|
121317
121612
|
client.events.once("closed", done);
|
|
121318
121613
|
});
|
|
@@ -123679,18 +123974,18 @@ var claudeHostAdopter = {
|
|
|
123679
123974
|
retire
|
|
123680
123975
|
});
|
|
123681
123976
|
refreshHostLimit2(entry, running);
|
|
123682
|
-
let
|
|
123977
|
+
let timer3 = null;
|
|
123683
123978
|
await Promise.race([
|
|
123684
123979
|
entry.replayDone,
|
|
123685
123980
|
new Promise((resolve) => {
|
|
123686
|
-
|
|
123981
|
+
timer3 = setTimeout(() => {
|
|
123687
123982
|
console.error(`[claude] the replay of ${row.entry_key} takes long; startup goes on`);
|
|
123688
123983
|
resolve();
|
|
123689
123984
|
}, REPLAY_WAIT_MS2);
|
|
123690
|
-
|
|
123985
|
+
timer3.unref?.();
|
|
123691
123986
|
})
|
|
123692
123987
|
]);
|
|
123693
|
-
if (
|
|
123988
|
+
if (timer3) clearTimeout(timer3);
|
|
123694
123989
|
console.log(
|
|
123695
123990
|
`[claude] adopted the CLI of ${row.entry_key} (pid ${proc.pid ?? "?"})${running ? `, turn ${row.turn_id} goes on` : ""}${retire ? `; it closes once idle: ${retire}` : ""}`
|
|
123696
123991
|
);
|
|
@@ -123888,12 +124183,12 @@ var HttpError = class extends Error {
|
|
|
123888
124183
|
};
|
|
123889
124184
|
async function fetchJson(url2, init, timeoutMs = 5e3) {
|
|
123890
124185
|
const controller = new AbortController();
|
|
123891
|
-
const
|
|
124186
|
+
const timer3 = setTimeout(() => controller.abort(), timeoutMs);
|
|
123892
124187
|
let response;
|
|
123893
124188
|
try {
|
|
123894
124189
|
response = await fetch(url2, { ...init, signal: controller.signal });
|
|
123895
124190
|
} finally {
|
|
123896
|
-
clearTimeout(
|
|
124191
|
+
clearTimeout(timer3);
|
|
123897
124192
|
}
|
|
123898
124193
|
const text2 = await response.text();
|
|
123899
124194
|
if (!response.ok) {
|
|
@@ -124345,11 +124640,11 @@ async function getAgentRuntimeState(baseUrl, sessionId, timeoutMs = 5e3) {
|
|
|
124345
124640
|
function reconnectDelay(delayMs, signal) {
|
|
124346
124641
|
return new Promise((resolve) => {
|
|
124347
124642
|
if (signal?.aborted) return resolve();
|
|
124348
|
-
const
|
|
124643
|
+
const timer3 = setTimeout(resolve, delayMs);
|
|
124349
124644
|
signal?.addEventListener(
|
|
124350
124645
|
"abort",
|
|
124351
124646
|
() => {
|
|
124352
|
-
clearTimeout(
|
|
124647
|
+
clearTimeout(timer3);
|
|
124353
124648
|
resolve();
|
|
124354
124649
|
},
|
|
124355
124650
|
{ once: true }
|
|
@@ -124364,7 +124659,7 @@ async function runThrowawayPrompt(client, options) {
|
|
|
124364
124659
|
const created = await client.createSession(options.model ? { model_id: options.model } : {});
|
|
124365
124660
|
throwawayId = created.id;
|
|
124366
124661
|
const controller = new AbortController();
|
|
124367
|
-
const
|
|
124662
|
+
const timer3 = setTimeout(() => controller.abort(), options.timeoutMs);
|
|
124368
124663
|
try {
|
|
124369
124664
|
await client.createInput(throwawayId, {
|
|
124370
124665
|
user_prompt: options.prompt,
|
|
@@ -124391,7 +124686,7 @@ async function runThrowawayPrompt(client, options) {
|
|
|
124391
124686
|
}
|
|
124392
124687
|
return failed ? null : reply;
|
|
124393
124688
|
} finally {
|
|
124394
|
-
clearTimeout(
|
|
124689
|
+
clearTimeout(timer3);
|
|
124395
124690
|
}
|
|
124396
124691
|
} catch {
|
|
124397
124692
|
return null;
|