@cloop/runner 0.3.31 → 0.3.35
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/{box-RFAHCXZS.js → box-LZGTTQKL.js} +54 -117
- package/dist/{chunk-YLVOEZWH.js → chunk-5WUAG7OI.js} +28 -8
- package/dist/{chunk-WYU74GLG.js → chunk-6Y3ILQDO.js} +1 -1
- package/dist/{chunk-MEAVT5SJ.js → chunk-HNQZY27C.js} +14 -9
- package/dist/{chunk-52CUSFDQ.js → chunk-KDTPUD2Y.js} +1 -0
- package/dist/{chunk-R73PVAM2.js → chunk-S52SLN25.js} +397 -50
- package/dist/{chunk-UERK5AHI.js → chunk-TTHOALU4.js} +3 -3
- package/dist/{chunk-7AHYPGSU.js → chunk-W6OIPMGZ.js} +1 -1
- package/dist/{chunk-GL77IQQE.js → chunk-YLUOCGC7.js} +1 -1
- package/dist/{chunk-FKYVJUIR.js → chunk-ZE7NJCLG.js} +1 -1
- package/dist/{connect-WRTLQW5H.js → connect-P23JWZLO.js} +7 -7
- package/dist/{disconnect-I44BWWFB.js → disconnect-JHQLT3XZ.js} +7 -7
- package/dist/{existing-runner-SP6SNFH4.js → existing-runner-NHJNRBZH.js} +7 -7
- package/dist/index.js +14 -14
- package/dist/{login-LH2KF7N2.js → login-7RGV3MBV.js} +2 -2
- package/dist/{mcp-server-SGIWNLLL.js → mcp-server-4OGU3LVF.js} +2 -2
- package/dist/{runner-SXUQH5IU.js → runner-JBHX5F57.js} +3 -3
- package/dist/{runs-3YZO57MX.js → runs-WLVXWOZO.js} +2 -2
- package/dist/{statusline-UHZTCNCB.js → statusline-RK56LGNA.js} +1 -1
- package/dist/{takeover-M4QHMXTZ.js → takeover-T452RX74.js} +4 -4
- package/dist/{use-YB75NHTE.js → use-HWIFM4F4.js} +7 -7
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
serveTakeovers
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-TTHOALU4.js";
|
|
5
|
+
import "./chunk-ZE7NJCLG.js";
|
|
6
6
|
import {
|
|
7
7
|
CAPTURE_TICK_MS,
|
|
8
8
|
DEFAULT_FALLBACK_MODEL,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
systemServices,
|
|
39
39
|
unitFor,
|
|
40
40
|
which
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-HNQZY27C.js";
|
|
42
42
|
import {
|
|
43
43
|
MeshSocket,
|
|
44
44
|
WAKE_TICK_MS,
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
defaultSocketFactory,
|
|
47
47
|
runnerLog,
|
|
48
48
|
wakeWatch
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-KDTPUD2Y.js";
|
|
50
50
|
import {
|
|
51
51
|
BoxWatch,
|
|
52
52
|
hostedThreadsFilePath,
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
runnerStatePath,
|
|
56
56
|
threadsFilePath,
|
|
57
57
|
writeRunnerState
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-5WUAG7OI.js";
|
|
59
59
|
import {
|
|
60
60
|
BackgroundReading,
|
|
61
61
|
BoxToolError,
|
|
@@ -81,6 +81,7 @@ import {
|
|
|
81
81
|
isHosted,
|
|
82
82
|
isLocal,
|
|
83
83
|
isT3,
|
|
84
|
+
listOutsideSessions,
|
|
84
85
|
nextProgress,
|
|
85
86
|
orderThreads,
|
|
86
87
|
quotaFromClaude,
|
|
@@ -99,20 +100,20 @@ import {
|
|
|
99
100
|
utcWindow,
|
|
100
101
|
windowsPowerShellEnv,
|
|
101
102
|
writeBoxConfig
|
|
102
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-S52SLN25.js";
|
|
103
104
|
import "./chunk-VK6GV757.js";
|
|
104
105
|
import {
|
|
105
106
|
olderThan
|
|
106
107
|
} from "./chunk-365HFCQQ.js";
|
|
107
108
|
import "./chunk-PKIEWBR7.js";
|
|
108
|
-
import "./chunk-
|
|
109
|
-
import "./chunk-
|
|
109
|
+
import "./chunk-W6OIPMGZ.js";
|
|
110
|
+
import "./chunk-6Y3ILQDO.js";
|
|
110
111
|
import {
|
|
111
112
|
getMachine
|
|
112
113
|
} from "./chunk-SBYSVZ7J.js";
|
|
113
114
|
import {
|
|
114
115
|
VERSION
|
|
115
|
-
} from "./chunk-
|
|
116
|
+
} from "./chunk-YLUOCGC7.js";
|
|
116
117
|
import {
|
|
117
118
|
getMeshUrl,
|
|
118
119
|
getOrigin,
|
|
@@ -1470,8 +1471,8 @@ function claudeReader(window, days) {
|
|
|
1470
1471
|
if (typeof m.id !== "string") addTokens(days, day, "claude", call);
|
|
1471
1472
|
else {
|
|
1472
1473
|
const key = `${m.id} ${String(d.requestId ?? "")}`;
|
|
1473
|
-
const
|
|
1474
|
-
if (!
|
|
1474
|
+
const seen = calls.get(key);
|
|
1475
|
+
if (!seen || call.output >= seen.output) calls.set(key, call);
|
|
1475
1476
|
}
|
|
1476
1477
|
return true;
|
|
1477
1478
|
},
|
|
@@ -1679,80 +1680,6 @@ function lastKnown(read, initial, { ms, what, onFail }) {
|
|
|
1679
1680
|
};
|
|
1680
1681
|
}
|
|
1681
1682
|
|
|
1682
|
-
// src/outside-sessions.ts
|
|
1683
|
-
import { createReadStream as createReadStream2 } from "fs";
|
|
1684
|
-
import { readdir as readdir2, stat as stat2 } from "fs/promises";
|
|
1685
|
-
import { homedir } from "os";
|
|
1686
|
-
import { join as join4 } from "path";
|
|
1687
|
-
import { createInterface as createInterface2 } from "readline";
|
|
1688
|
-
var seen = /* @__PURE__ */ new Map();
|
|
1689
|
-
var UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
|
|
1690
|
-
async function listOutsideSessions(root = join4(homedir(), ".claude", "projects"), own = /* @__PURE__ */ new Set(), now = Date.now()) {
|
|
1691
|
-
const files = [];
|
|
1692
|
-
for (const project of await readdir2(root, { withFileTypes: true }).catch(() => [])) {
|
|
1693
|
-
if (!project.isDirectory()) continue;
|
|
1694
|
-
for (const entry of await readdir2(join4(root, project.name), { withFileTypes: true }).catch(
|
|
1695
|
-
() => []
|
|
1696
|
-
)) {
|
|
1697
|
-
if (!entry.isFile() || !entry.name.endsWith(".jsonl")) continue;
|
|
1698
|
-
const id = entry.name.slice(0, -6);
|
|
1699
|
-
if (!UUID.test(id) || own.has(id)) continue;
|
|
1700
|
-
const path = join4(root, project.name, entry.name);
|
|
1701
|
-
const info = await stat2(path).catch(() => null);
|
|
1702
|
-
if (info && info.mtimeMs >= now - 7 * 864e5)
|
|
1703
|
-
files.push({ id, project: project.name.slice(0, 200), file: path, mtime: info.mtimeMs });
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
const results = [];
|
|
1707
|
-
const newest = files.sort((a, b) => b.mtime - a.mtime).slice(0, 20);
|
|
1708
|
-
for (const path of seen.keys()) if (!newest.some((file) => file.file === path)) seen.delete(path);
|
|
1709
|
-
for (const file of newest) {
|
|
1710
|
-
const known = seen.get(file.file);
|
|
1711
|
-
let title = known?.mtime === file.mtime ? known.title : void 0;
|
|
1712
|
-
let cwd = known?.mtime === file.mtime ? known.cwd : void 0;
|
|
1713
|
-
if (known?.mtime !== file.mtime) {
|
|
1714
|
-
const stream = createReadStream2(file.file, { encoding: "utf8" });
|
|
1715
|
-
const lines = createInterface2({ input: stream, crlfDelay: Number.POSITIVE_INFINITY });
|
|
1716
|
-
try {
|
|
1717
|
-
for await (const line of lines) {
|
|
1718
|
-
if (!cwd && line.includes('"cwd"')) {
|
|
1719
|
-
try {
|
|
1720
|
-
const record = JSON.parse(line);
|
|
1721
|
-
if (typeof record.cwd === "string" && record.cwd.startsWith("/") && record.cwd.length <= 500)
|
|
1722
|
-
cwd = record.cwd;
|
|
1723
|
-
} catch {
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
if (!/^\s*\{\s*"type"\s*:\s*"(?:summary|custom-title|title)"/.test(line)) continue;
|
|
1727
|
-
try {
|
|
1728
|
-
const record = JSON.parse(line);
|
|
1729
|
-
const value = record.type === "summary" ? record.summary : record.type === "custom-title" ? record.customTitle : record.title;
|
|
1730
|
-
if (typeof value === "string" && value.trim()) title = value.trim().slice(0, 120);
|
|
1731
|
-
} catch {
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
} finally {
|
|
1735
|
-
lines.close();
|
|
1736
|
-
stream.destroy();
|
|
1737
|
-
}
|
|
1738
|
-
seen.set(file.file, {
|
|
1739
|
-
mtime: file.mtime,
|
|
1740
|
-
...title ? { title } : {},
|
|
1741
|
-
...cwd ? { cwd } : {}
|
|
1742
|
-
});
|
|
1743
|
-
}
|
|
1744
|
-
results.push({
|
|
1745
|
-
id: file.id,
|
|
1746
|
-
project: file.project,
|
|
1747
|
-
updatedAt: new Date(file.mtime).toISOString(),
|
|
1748
|
-
status: "idle",
|
|
1749
|
-
...cwd ? { cwd } : {},
|
|
1750
|
-
...title ? { title } : {}
|
|
1751
|
-
});
|
|
1752
|
-
}
|
|
1753
|
-
return results;
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
1683
|
// src/result-outbox.ts
|
|
1757
1684
|
var OUTBOX_MAX = 50;
|
|
1758
1685
|
var OUTBOX_KEEP_MS = 24 * 36e5;
|
|
@@ -1812,8 +1739,8 @@ import {
|
|
|
1812
1739
|
rmSync as rmSync2,
|
|
1813
1740
|
symlinkSync
|
|
1814
1741
|
} from "fs";
|
|
1815
|
-
import { homedir
|
|
1816
|
-
import { join as
|
|
1742
|
+
import { homedir, tmpdir as tmpdir2 } from "os";
|
|
1743
|
+
import { join as join4 } from "path";
|
|
1817
1744
|
var SKILL_DIRS = [".agents/skills", ".claude/skills", ".codex/skills"];
|
|
1818
1745
|
var GUIDE_FILES = [".agents/AGENTS.md", ".claude/CLAUDE.md", ".codex/AGENTS.md"];
|
|
1819
1746
|
var SKILLS_CAP_BYTES = 25 * 1024 * 1024;
|
|
@@ -1831,13 +1758,13 @@ function findSetup(home) {
|
|
|
1831
1758
|
for (const dir of SKILL_DIRS) {
|
|
1832
1759
|
let entries;
|
|
1833
1760
|
try {
|
|
1834
|
-
entries = readdirSync(
|
|
1761
|
+
entries = readdirSync(join4(home, dir)).sort();
|
|
1835
1762
|
} catch {
|
|
1836
1763
|
continue;
|
|
1837
1764
|
}
|
|
1838
1765
|
for (const name of entries) {
|
|
1839
|
-
const path =
|
|
1840
|
-
if (names.has(name) || !existsSync2(
|
|
1766
|
+
const path = join4(home, dir, name);
|
|
1767
|
+
if (names.has(name) || !existsSync2(join4(path, "SKILL.md"))) continue;
|
|
1841
1768
|
const real = realpath2(path);
|
|
1842
1769
|
if (!real || reals.has(real)) continue;
|
|
1843
1770
|
names.add(name);
|
|
@@ -1845,18 +1772,18 @@ function findSetup(home) {
|
|
|
1845
1772
|
skills.push({ name, path: real });
|
|
1846
1773
|
}
|
|
1847
1774
|
}
|
|
1848
|
-
const guide = GUIDE_FILES.map((file) => realpath2(
|
|
1775
|
+
const guide = GUIDE_FILES.map((file) => realpath2(join4(home, file))).find((p) => p !== null) ?? null;
|
|
1849
1776
|
return { skills, guide };
|
|
1850
1777
|
}
|
|
1851
1778
|
function stage(setup) {
|
|
1852
|
-
const dir = mkdtempSync(
|
|
1853
|
-
mkdirSync2(
|
|
1779
|
+
const dir = mkdtempSync(join4(tmpdir2(), "cloop-setup-"));
|
|
1780
|
+
mkdirSync2(join4(dir, ".agents", "skills"), { recursive: true });
|
|
1854
1781
|
for (const skill of setup.skills)
|
|
1855
|
-
symlinkSync(skill.path,
|
|
1856
|
-
if (setup.guide) copyFileSync(setup.guide,
|
|
1782
|
+
symlinkSync(skill.path, join4(dir, ".agents", "skills", skill.name), "junction");
|
|
1783
|
+
if (setup.guide) copyFileSync(setup.guide, join4(dir, ".agents", "owner-guide.md"));
|
|
1857
1784
|
return dir;
|
|
1858
1785
|
}
|
|
1859
|
-
async function packSkills(home =
|
|
1786
|
+
async function packSkills(home = homedir(), capBytes = SKILLS_CAP_BYTES, tarBin = "tar") {
|
|
1860
1787
|
const setup = findSetup(home);
|
|
1861
1788
|
if (setup.skills.length === 0 && !setup.guide) return { ok: false, reason: "no_skills" };
|
|
1862
1789
|
let dir;
|
|
@@ -2000,8 +1927,8 @@ function remoteMcp(found) {
|
|
|
2000
1927
|
const url = httpUrl(entry.url);
|
|
2001
1928
|
const name = mcpName(entry.name);
|
|
2002
1929
|
if (!url || !name) continue;
|
|
2003
|
-
const
|
|
2004
|
-
if (
|
|
1930
|
+
const seen = byUrl.get(url);
|
|
1931
|
+
if (seen) seen.keyed ||= entry.keyed;
|
|
2005
1932
|
else byUrl.set(url, { name, url, keyed: entry.keyed });
|
|
2006
1933
|
}
|
|
2007
1934
|
return [...byUrl.values()].slice(0, MAX_REMOTE_MCP);
|
|
@@ -2013,10 +1940,10 @@ function readText(path) {
|
|
|
2013
1940
|
return "";
|
|
2014
1941
|
}
|
|
2015
1942
|
}
|
|
2016
|
-
function readRemoteMcp(home =
|
|
1943
|
+
function readRemoteMcp(home = homedir(), codexHome2 = process.env.CODEX_HOME || join4(home, ".codex")) {
|
|
2017
1944
|
return remoteMcp([
|
|
2018
|
-
...claudeRemoteMcp(readText(
|
|
2019
|
-
...codexRemoteMcp(readText(
|
|
1945
|
+
...claudeRemoteMcp(readText(join4(home, ".claude.json"))),
|
|
1946
|
+
...codexRemoteMcp(readText(join4(codexHome2, "config.toml")))
|
|
2020
1947
|
]);
|
|
2021
1948
|
}
|
|
2022
1949
|
async function sendSkills(tar, deps) {
|
|
@@ -2096,7 +2023,7 @@ var T3_REFRESH_MS = 2 * 6e4;
|
|
|
2096
2023
|
var LOOKBACK_MS = 48 * 60 * 6e4;
|
|
2097
2024
|
var PROJECTIONS_PER_READ = 25;
|
|
2098
2025
|
var SHELL_HEADERS = { "x-t3-orchestration-protocol": "2" };
|
|
2099
|
-
var
|
|
2026
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
2100
2027
|
function isSettled(t) {
|
|
2101
2028
|
if (t.archivedAt || t.deletedAt) return true;
|
|
2102
2029
|
if (t.settledOverride === "settled") return true;
|
|
@@ -2176,7 +2103,7 @@ var T3Threads = class {
|
|
|
2176
2103
|
});
|
|
2177
2104
|
const ids = (projection.providerThreads ?? []).flatMap((p) => {
|
|
2178
2105
|
const id = p.nativeThreadRef?.nativeId;
|
|
2179
|
-
return typeof id === "string" &&
|
|
2106
|
+
return typeof id === "string" && UUID.test(id) ? [id.toLowerCase()] : [];
|
|
2180
2107
|
});
|
|
2181
2108
|
if (ids.length === 0) continue;
|
|
2182
2109
|
this.resolvedAt.set(thread.id, harnessKey(thread));
|
|
@@ -2200,8 +2127,8 @@ import {
|
|
|
2200
2127
|
rmSync as rmSync3,
|
|
2201
2128
|
writeFileSync
|
|
2202
2129
|
} from "fs";
|
|
2203
|
-
import { homedir as
|
|
2204
|
-
import { dirname, join as
|
|
2130
|
+
import { homedir as homedir2 } from "os";
|
|
2131
|
+
import { dirname, join as join5 } from "path";
|
|
2205
2132
|
var REGISTRY_LATEST = "https://registry.npmjs.org/@cloop/runner/latest";
|
|
2206
2133
|
var FIRST_CHECK_MS = 10 * 6e4;
|
|
2207
2134
|
var CHECK_EVERY_MS = 6 * 36e5;
|
|
@@ -2241,10 +2168,10 @@ function updateDir(env) {
|
|
|
2241
2168
|
return runnerPath(env, process.env.CLOOP_UPDATE_DIR, (dir) => dir);
|
|
2242
2169
|
}
|
|
2243
2170
|
function updateLogPath() {
|
|
2244
|
-
return
|
|
2171
|
+
return join5(updateDir(), "update.log");
|
|
2245
2172
|
}
|
|
2246
2173
|
function statePath(env) {
|
|
2247
|
-
return
|
|
2174
|
+
return join5(updateDir(env), "update.json");
|
|
2248
2175
|
}
|
|
2249
2176
|
function readFailed() {
|
|
2250
2177
|
try {
|
|
@@ -2292,7 +2219,7 @@ var adoptWords = (npx, to, kind) => [
|
|
|
2292
2219
|
kind
|
|
2293
2220
|
];
|
|
2294
2221
|
function adoptScriptPath() {
|
|
2295
|
-
return
|
|
2222
|
+
return join5(updateDir(), "adopt.cmd");
|
|
2296
2223
|
}
|
|
2297
2224
|
function adoptScript(npx, to, kind, log3) {
|
|
2298
2225
|
return [
|
|
@@ -2306,7 +2233,7 @@ function servicePath(kind, platform) {
|
|
|
2306
2233
|
platform,
|
|
2307
2234
|
kind,
|
|
2308
2235
|
environment: runnerEnvironment(),
|
|
2309
|
-
home:
|
|
2236
|
+
home: homedir2(),
|
|
2310
2237
|
uid: process.getuid?.() ?? 0,
|
|
2311
2238
|
...process.env.CLOOP_UNIT_DIR ? { dir: process.env.CLOOP_UNIT_DIR } : {}
|
|
2312
2239
|
}).path;
|
|
@@ -2448,7 +2375,7 @@ async function adopt(from, kind, { services: given, script = process.argv[1] ??
|
|
|
2448
2375
|
const where = {
|
|
2449
2376
|
platform: services.platform,
|
|
2450
2377
|
kind,
|
|
2451
|
-
home:
|
|
2378
|
+
home: homedir2(),
|
|
2452
2379
|
uid: process.getuid?.() ?? 0,
|
|
2453
2380
|
...process.env.CLOOP_UNIT_DIR ? { dir: process.env.CLOOP_UNIT_DIR } : {}
|
|
2454
2381
|
};
|
|
@@ -2534,7 +2461,8 @@ function boxPresence(beat) {
|
|
|
2534
2461
|
outsideThreads: beat.outsideThreads,
|
|
2535
2462
|
otherThreads: beat.otherThreads,
|
|
2536
2463
|
...beat.t3 ? { t3: beat.t3 } : {},
|
|
2537
|
-
...beat.hosted ? { harness: beat.hosted } : {}
|
|
2464
|
+
...beat.hosted ? { harness: beat.hosted } : {},
|
|
2465
|
+
...beat.repos?.length ? { repos: beat.repos } : {}
|
|
2538
2466
|
},
|
|
2539
2467
|
status: beat.running > 0 ? "active" : "idle",
|
|
2540
2468
|
event: beat.running > 0 ? `${beat.running} running` : ""
|
|
@@ -2665,7 +2593,7 @@ async function run2() {
|
|
|
2665
2593
|
{
|
|
2666
2594
|
driver,
|
|
2667
2595
|
onLaunch: (workId, threadId) => watch.add(workId, threadId),
|
|
2668
|
-
|
|
2596
|
+
onSend: (threadId, workId) => watch.follow(threadId, workId),
|
|
2669
2597
|
...setup ? { setup } : {},
|
|
2670
2598
|
diag: async () => buildDiag({
|
|
2671
2599
|
version: VERSION,
|
|
@@ -2775,6 +2703,7 @@ async function run2() {
|
|
|
2775
2703
|
process.platform,
|
|
2776
2704
|
(error, ver) => socket.send(runnerLog("update_failed", { error, ver }))
|
|
2777
2705
|
);
|
|
2706
|
+
let lastRepos;
|
|
2778
2707
|
const readDriver = lastKnown(
|
|
2779
2708
|
async () => {
|
|
2780
2709
|
const shown = showsOtherThreads(readRunnerConfig());
|
|
@@ -2788,11 +2717,18 @@ async function run2() {
|
|
|
2788
2717
|
if (own)
|
|
2789
2718
|
outsideThreads = await listOutsideSessions(
|
|
2790
2719
|
void 0,
|
|
2791
|
-
new Set(listed.threads.map((t) => t.id))
|
|
2720
|
+
new Set(listed.threads.filter((t) => t.cloop).map((t) => t.id))
|
|
2792
2721
|
);
|
|
2793
|
-
|
|
2722
|
+
const repos = await driver.checkouts?.().catch(() => lastRepos);
|
|
2723
|
+
lastRepos = repos ?? lastRepos;
|
|
2724
|
+
return { shown, running: listed.running, outsideThreads, repos: lastRepos };
|
|
2725
|
+
},
|
|
2726
|
+
{
|
|
2727
|
+
shown: showsOtherThreads(readRunnerConfig()),
|
|
2728
|
+
running: 0,
|
|
2729
|
+
outsideThreads: [],
|
|
2730
|
+
repos: void 0
|
|
2794
2731
|
},
|
|
2795
|
-
{ shown: showsOtherThreads(readRunnerConfig()), running: 0, outsideThreads: [] },
|
|
2796
2732
|
{
|
|
2797
2733
|
ms: DRIVER_READ_MS,
|
|
2798
2734
|
what: `${driver.name} read`,
|
|
@@ -2817,7 +2753,7 @@ async function run2() {
|
|
|
2817
2753
|
try {
|
|
2818
2754
|
await renew();
|
|
2819
2755
|
const callsBefore = callsStarted;
|
|
2820
|
-
const { shown, running, outsideThreads } = await readDriver();
|
|
2756
|
+
const { shown, running, outsideThreads, repos } = await readDriver();
|
|
2821
2757
|
lastBeatAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2822
2758
|
socket.sendPresence(
|
|
2823
2759
|
boxPresence({
|
|
@@ -2829,7 +2765,8 @@ async function run2() {
|
|
|
2829
2765
|
otherThreads: shown,
|
|
2830
2766
|
running,
|
|
2831
2767
|
t3: cfg && isT3(cfg) ? t3Presence(cfg, t3.renewalFailed) : null,
|
|
2832
|
-
...hosted ? { hosted: hosted.harness } : {}
|
|
2768
|
+
...hosted ? { hosted: hosted.harness } : {},
|
|
2769
|
+
...repos ? { repos } : {}
|
|
2833
2770
|
})
|
|
2834
2771
|
);
|
|
2835
2772
|
update?.beat({ running, inFlight: inFlight + callsStarted - callsBefore });
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
RUN_TEXT_MAX,
|
|
4
4
|
boxPath,
|
|
5
5
|
runnerPath
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-S52SLN25.js";
|
|
7
7
|
|
|
8
8
|
// src/box-watch.ts
|
|
9
9
|
import { randomUUID } from "crypto";
|
|
@@ -97,7 +97,7 @@ var BoxWatch = class {
|
|
|
97
97
|
start() {
|
|
98
98
|
for (const e of this.entries) if (!e.settled_at) this.watch(e);
|
|
99
99
|
}
|
|
100
|
-
add(workId, threadId) {
|
|
100
|
+
add(workId, threadId, why = "launch") {
|
|
101
101
|
if (this.entries.some((e) => e.work_id === workId)) return;
|
|
102
102
|
const entry = {
|
|
103
103
|
work_id: workId,
|
|
@@ -106,15 +106,35 @@ var BoxWatch = class {
|
|
|
106
106
|
};
|
|
107
107
|
this.entries.push(entry);
|
|
108
108
|
this.save();
|
|
109
|
-
this.deps.log(
|
|
109
|
+
this.deps.log(`${why} work=${workId} thread=${threadId}`);
|
|
110
110
|
this.watch(entry);
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
/**
|
|
113
|
+
* A send the thread took. A settled entry is watched again, so the turn
|
|
114
|
+
* the send started reports its own end. A thread with no entry, one the
|
|
115
|
+
* owner started outside Cloop, is watched from now under the app's
|
|
116
|
+
* `workId`; without one nobody would read its end, so it stays unwatched.
|
|
117
|
+
* A `workId` other than the entry's moves the entry to that row.
|
|
118
|
+
*/
|
|
119
|
+
follow(threadId, workId) {
|
|
113
120
|
const entry = this.entries.find((e) => e.thread_id === threadId);
|
|
114
|
-
if (!entry
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
if (!entry) {
|
|
122
|
+
if (workId) this.add(workId, threadId, "adopt");
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (workId && workId !== entry.work_id) {
|
|
126
|
+
const unwatch = this.live.get(entry.work_id);
|
|
127
|
+
this.live.delete(entry.work_id);
|
|
128
|
+
if (unwatch) this.live.set(workId, unwatch);
|
|
129
|
+
this.deps.log(`rebind thread=${threadId} work=${entry.work_id} to=${workId}`);
|
|
130
|
+
entry.work_id = workId;
|
|
131
|
+
entry.questions = void 0;
|
|
132
|
+
}
|
|
133
|
+
if (entry.settled_at) {
|
|
134
|
+
entry.settled_at = void 0;
|
|
135
|
+
entry.event = void 0;
|
|
136
|
+
entry.sent_at = void 0;
|
|
137
|
+
}
|
|
118
138
|
this.save();
|
|
119
139
|
this.watch(entry);
|
|
120
140
|
}
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
freshness,
|
|
5
5
|
outcomeLine,
|
|
6
6
|
runnerLog
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KDTPUD2Y.js";
|
|
8
8
|
import {
|
|
9
9
|
readRunnerState,
|
|
10
10
|
runnerStatePath,
|
|
11
11
|
threadsFilePath
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-5WUAG7OI.js";
|
|
13
13
|
import {
|
|
14
14
|
BoxToolError,
|
|
15
15
|
CLOOP_THREAD_PREFIX,
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
windowsExecutable,
|
|
49
49
|
windowsPowerShellEnv,
|
|
50
50
|
writeBoxConfig
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-S52SLN25.js";
|
|
52
52
|
import {
|
|
53
53
|
CLAUDE_FLOOR,
|
|
54
54
|
CODEX_FLOOR,
|
|
@@ -62,14 +62,14 @@ import {
|
|
|
62
62
|
} from "./chunk-PKIEWBR7.js";
|
|
63
63
|
import {
|
|
64
64
|
connectWebhook
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-W6OIPMGZ.js";
|
|
66
66
|
import {
|
|
67
67
|
ConnectFailure,
|
|
68
68
|
connectReport,
|
|
69
69
|
deviceLogin,
|
|
70
70
|
newAttempt,
|
|
71
71
|
sendConnectReport
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-6Y3ILQDO.js";
|
|
73
73
|
import {
|
|
74
74
|
defaultDeviceName,
|
|
75
75
|
getMachine,
|
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
} from "./chunk-SBYSVZ7J.js";
|
|
78
78
|
import {
|
|
79
79
|
VERSION
|
|
80
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-YLUOCGC7.js";
|
|
81
81
|
import {
|
|
82
82
|
STAGING_ORIGIN,
|
|
83
83
|
getOrigin,
|
|
@@ -305,6 +305,9 @@ function parseSendArgs(args) {
|
|
|
305
305
|
const question = args.question_id;
|
|
306
306
|
if (question !== void 0 && question !== null && (typeof question !== "string" || !question || question.length > 1e3))
|
|
307
307
|
throw new BoxToolError("bad_args");
|
|
308
|
+
const work = args.work_id;
|
|
309
|
+
if (work !== void 0 && (typeof work !== "string" || !UUID.test(work)))
|
|
310
|
+
throw new BoxToolError("bad_args");
|
|
308
311
|
return {
|
|
309
312
|
thread_id: parseThreadId(args),
|
|
310
313
|
text,
|
|
@@ -312,9 +315,11 @@ function parseSendArgs(args) {
|
|
|
312
315
|
command_id: parseCommandId(args),
|
|
313
316
|
answer: args.answer === true,
|
|
314
317
|
...args.resume === true ? { resume: true } : {},
|
|
315
|
-
...question !== void 0 ? { question_id: question } : {}
|
|
318
|
+
...question !== void 0 ? { question_id: question } : {},
|
|
319
|
+
...work !== void 0 ? { work_id: work } : {}
|
|
316
320
|
};
|
|
317
321
|
}
|
|
322
|
+
var SENT = /* @__PURE__ */ new Set(["answer", "steer", "queue", "start"]);
|
|
318
323
|
var BOX_TOOLS = {
|
|
319
324
|
// The runner version tells the app which keys this machine answers: `cloop use` arrived in 0.2.6.
|
|
320
325
|
status: async ({ driver }) => {
|
|
@@ -332,10 +337,10 @@ var BOX_TOOLS = {
|
|
|
332
337
|
onLaunch?.(a.work_id, launched.thread_id);
|
|
333
338
|
return launched;
|
|
334
339
|
},
|
|
335
|
-
async "thread.send"({ driver,
|
|
340
|
+
async "thread.send"({ driver, onSend }, args) {
|
|
336
341
|
const parsed = parseSendArgs(args);
|
|
337
342
|
const result = await driver.send(parsed);
|
|
338
|
-
if (
|
|
343
|
+
if (SENT.has(result.delivered)) onSend?.(parsed.thread_id, parsed.work_id);
|
|
339
344
|
return result;
|
|
340
345
|
},
|
|
341
346
|
"thread.interrupt": ({ driver }, args) => driver.interrupt(parseThreadId(args), parseCommandId(args)),
|