@cloop/runner 0.2.6 → 0.2.7
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-Q5AA4S2T.js → box-U65RXLCX.js} +9 -9
- package/dist/{chunk-V4IYJUCC.js → chunk-DLFNATEZ.js} +6 -6
- package/dist/{chunk-E3V2PRVS.js → chunk-JFCEKATW.js} +21 -148
- package/dist/{chunk-52VJGOLJ.js → chunk-JZNBZUPZ.js} +1 -1
- package/dist/{chunk-GTE4QSTR.js → chunk-KH6FK6UQ.js} +1 -1
- package/dist/{chunk-H7ZCXBNW.js → chunk-LNQLGVYC.js} +328 -46
- package/dist/{chunk-UEV7ARIT.js → chunk-MC4DJ4LX.js} +7 -7
- package/dist/{chunk-2SZUL2B6.js → chunk-SANEFNTU.js} +1 -1
- package/dist/{chunk-SXV4JF5H.js → chunk-X7MNNKU3.js} +5 -24
- package/dist/{connect-FG5VDH5N.js → connect-GSGNPOPK.js} +6 -5
- package/dist/{disconnect-ZV32O475.js → disconnect-VTIIRAIV.js} +7 -7
- package/dist/index.js +15 -15
- package/dist/{login-ZKPZEFCV.js → login-XK4DOOGZ.js} +2 -2
- package/dist/{mcp-server-TINABFRL.js → mcp-server-GDTT45SF.js} +5 -5
- package/dist/{runner-VY3HK7L4.js → runner-ST77ZDLI.js} +3 -3
- package/dist/{runs-QLO2XZVZ.js → runs-2CZ3YZGI.js} +3 -3
- package/dist/{statusline-BWUUERD5.js → statusline-6WXP6S3D.js} +1 -1
- package/dist/{takeover-TKQ5V4KV.js → takeover-WHU4CEKP.js} +5 -5
- package/dist/{use-ALFEOPLY.js → use-TBSTJORL.js} +6 -5
- package/package.json +1 -1
- package/dist/{hook-activity-R7OPEYBX.js → hook-activity-LBYV4WJW.js} +1 -1
- package/dist/{hook-session-start-GEBGA63R.js → hook-session-start-YSEV5DCB.js} +3 -3
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
serveTakeovers
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-DLFNATEZ.js";
|
|
5
|
+
import "./chunk-MC4DJ4LX.js";
|
|
6
6
|
import {
|
|
7
7
|
LocalDriver
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-JFCEKATW.js";
|
|
9
9
|
import {
|
|
10
10
|
MeshSocket,
|
|
11
11
|
defaultSocketFactory
|
|
12
12
|
} from "./chunk-ZILLDYL4.js";
|
|
13
|
-
import "./chunk-VK6GV757.js";
|
|
14
13
|
import {
|
|
15
14
|
DEFAULT_FALLBACK_MODEL,
|
|
16
15
|
T3Client,
|
|
@@ -22,7 +21,7 @@ import {
|
|
|
22
21
|
probeClaudePermissions,
|
|
23
22
|
probeCodex,
|
|
24
23
|
runBoxTool
|
|
25
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-X7MNNKU3.js";
|
|
26
25
|
import {
|
|
27
26
|
BoxWatch,
|
|
28
27
|
lockThreadsFile,
|
|
@@ -34,15 +33,16 @@ import {
|
|
|
34
33
|
isLocal,
|
|
35
34
|
readRunnerConfig,
|
|
36
35
|
writeBoxConfig
|
|
37
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-LNQLGVYC.js";
|
|
38
37
|
import {
|
|
39
38
|
getMachine
|
|
40
39
|
} from "./chunk-JX6VG5FE.js";
|
|
40
|
+
import "./chunk-VK6GV757.js";
|
|
41
41
|
import "./chunk-R3CLO2FB.js";
|
|
42
|
-
import "./chunk-
|
|
43
|
-
import "./chunk-
|
|
42
|
+
import "./chunk-JZNBZUPZ.js";
|
|
43
|
+
import "./chunk-SANEFNTU.js";
|
|
44
44
|
import "./chunk-AG6SI6I2.js";
|
|
45
|
-
import "./chunk-
|
|
45
|
+
import "./chunk-KH6FK6UQ.js";
|
|
46
46
|
import {
|
|
47
47
|
getMeshUrl,
|
|
48
48
|
getToken,
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
findRun
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MC4DJ4LX.js";
|
|
5
5
|
import {
|
|
6
6
|
localRunsFilePath,
|
|
7
7
|
readRunRecords,
|
|
8
8
|
takeoverSummary
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
sanitizeLabel
|
|
12
|
-
} from "./chunk-VK6GV757.js";
|
|
9
|
+
} from "./chunk-JFCEKATW.js";
|
|
13
10
|
import {
|
|
14
11
|
lockThreadsFile,
|
|
15
12
|
threadsFilePath
|
|
@@ -17,10 +14,13 @@ import {
|
|
|
17
14
|
import {
|
|
18
15
|
isLocal,
|
|
19
16
|
readRunnerConfig
|
|
20
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-LNQLGVYC.js";
|
|
21
18
|
import {
|
|
22
19
|
shortMachineName
|
|
23
20
|
} from "./chunk-JX6VG5FE.js";
|
|
21
|
+
import {
|
|
22
|
+
sanitizeLabel
|
|
23
|
+
} from "./chunk-VK6GV757.js";
|
|
24
24
|
|
|
25
25
|
// src/commands/takeover.ts
|
|
26
26
|
import { spawnSync } from "child_process";
|
|
@@ -1,148 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
stripControl
|
|
4
|
-
} from "./chunk-VK6GV757.js";
|
|
5
2
|
import {
|
|
6
3
|
BoxToolError,
|
|
7
4
|
RESULT_INSTRUCTION,
|
|
5
|
+
STOPPED_SUMMARY,
|
|
6
|
+
appendRunLog,
|
|
7
|
+
endNote,
|
|
8
|
+
isProgressSentence,
|
|
9
|
+
logLineFor,
|
|
10
|
+
nextProgress,
|
|
8
11
|
orderThreads,
|
|
9
|
-
parseRunResult
|
|
10
|
-
|
|
12
|
+
parseRunResult,
|
|
13
|
+
prUrlIn,
|
|
14
|
+
pruneRunLogs,
|
|
15
|
+
resultPrUrl,
|
|
16
|
+
runLogDir
|
|
17
|
+
} from "./chunk-LNQLGVYC.js";
|
|
11
18
|
import {
|
|
12
19
|
CONFIG_DIR
|
|
13
20
|
} from "./chunk-3DIGCVL4.js";
|
|
14
21
|
|
|
15
|
-
// src/run-log.ts
|
|
16
|
-
import {
|
|
17
|
-
appendFileSync,
|
|
18
|
-
chmodSync,
|
|
19
|
-
mkdirSync,
|
|
20
|
-
readdirSync,
|
|
21
|
-
renameSync,
|
|
22
|
-
statSync,
|
|
23
|
-
unlinkSync
|
|
24
|
-
} from "fs";
|
|
25
|
-
import { dirname, join } from "path";
|
|
26
|
-
var RUN_LOG_LINE_MAX = 500;
|
|
27
|
-
var RUN_LOG_MAX_BYTES = 5 * 1024 * 1024;
|
|
28
|
-
var RUN_LOG_KEEP_MS = 14 * 24 * 36e5;
|
|
29
|
-
var SAFE_ID = /^[\w-]{1,100}$/;
|
|
30
|
-
function runLogDir(runsFile) {
|
|
31
|
-
return join(dirname(runsFile), "runs");
|
|
32
|
-
}
|
|
33
|
-
function runLogPath(dir, workId) {
|
|
34
|
-
return SAFE_ID.test(workId) ? join(dir, `${workId}.log`) : null;
|
|
35
|
-
}
|
|
36
|
-
var SECRETS = [
|
|
37
|
-
[/-----BEGIN [A-Z ]*PRIVATE KEY-----.*/g, "[redacted private key]"],
|
|
38
|
-
[/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]{8,}/gi, "$1 [redacted]"],
|
|
39
|
-
[/(:\/\/)[^\s/@:]+:[^\s/@]+@/g, "$1[redacted]@"],
|
|
40
|
-
[
|
|
41
|
-
/([?&](?:access_token|token|key|api_key|apikey|secret|sig|signature|code|password)=)[^&\s"']+/gi,
|
|
42
|
-
"$1[redacted]"
|
|
43
|
-
],
|
|
44
|
-
[
|
|
45
|
-
/(\b(?:[\w-]*(?:token|secret|passw(?:or)?d|pwd|api[_-]?key|apikey|credential|private[_-]?key)[\w-]*|authorization|auth)["']?\s*[=:]\s*["']?)(?!Bearer\b|Basic\b|\[redacted)[^\s"',;}]{4,}/gi,
|
|
46
|
-
"$1[redacted]"
|
|
47
|
-
],
|
|
48
|
-
[
|
|
49
|
-
/(--?[\w-]*(?:token|secret|password|api-key|apikey)[\w-]*[ =])["']?[^\s"']{4,}["']?/gi,
|
|
50
|
-
"$1[redacted]"
|
|
51
|
-
],
|
|
52
|
-
[/\b(?:sk|pk|rk)-[A-Za-z0-9_-]{16,}/g, "[redacted]"],
|
|
53
|
-
[/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})/g, "[redacted]"],
|
|
54
|
-
[/\bxox[abprs]-[A-Za-z0-9-]{10,}/g, "[redacted]"],
|
|
55
|
-
[/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g, "[redacted]"],
|
|
56
|
-
[/\bAIza[0-9A-Za-z_-]{30,}/g, "[redacted]"],
|
|
57
|
-
[/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{4,}/g, "[redacted]"]
|
|
58
|
-
];
|
|
59
|
-
var OPAQUE = /[A-Za-z0-9_+=-]{32,}/g;
|
|
60
|
-
function redactSecrets(text) {
|
|
61
|
-
let out = text;
|
|
62
|
-
for (const [pattern, replacement] of SECRETS) out = out.replace(pattern, replacement);
|
|
63
|
-
return out.replace(
|
|
64
|
-
OPAQUE,
|
|
65
|
-
(run2) => /^[0-9a-f-]+$/i.test(run2) || !/\d/.test(run2) || !/[A-Za-z]/.test(run2) ? run2 : "[redacted]"
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
function logText(text) {
|
|
69
|
-
const flat = redactSecrets(stripControl(text).replace(/\s+/g, " ").trim());
|
|
70
|
-
return flat.length > RUN_LOG_LINE_MAX ? `${flat.slice(0, RUN_LOG_LINE_MAX - 1)}\u2026` : flat;
|
|
71
|
-
}
|
|
72
|
-
function logLineFor(item) {
|
|
73
|
-
switch (item.type) {
|
|
74
|
-
case "text":
|
|
75
|
-
return item.text;
|
|
76
|
-
case "tool": {
|
|
77
|
-
const input = item.detail ?? item.summary ?? item.target;
|
|
78
|
-
return `> ${item.name}${input ? `: ${input}` : ""}`;
|
|
79
|
-
}
|
|
80
|
-
case "ask":
|
|
81
|
-
return `? ${item.summary}`;
|
|
82
|
-
case "result":
|
|
83
|
-
return item.ok ? `= Result: ${item.text ?? "done"}` : `= Error: ${item.text ?? "no text"}`;
|
|
84
|
-
default:
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function appendRunLog(dir, workId, text, { now = Date.now(), maxBytes = RUN_LOG_MAX_BYTES } = {}) {
|
|
89
|
-
const path = runLogPath(dir, workId);
|
|
90
|
-
if (!path) return;
|
|
91
|
-
const line = `${stamp(now)} ${logText(text)}
|
|
92
|
-
`;
|
|
93
|
-
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
94
|
-
const size = sizeOf(path);
|
|
95
|
-
if (size > 0 && size + Buffer.byteLength(line) > maxBytes) renameSync(path, `${path}.1`);
|
|
96
|
-
appendFileSync(path, line, { mode: 384 });
|
|
97
|
-
}
|
|
98
|
-
function pruneRunLogs(dir, now = Date.now(), keepMs = RUN_LOG_KEEP_MS) {
|
|
99
|
-
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
100
|
-
chmodSync(dir, 448);
|
|
101
|
-
let removed = 0;
|
|
102
|
-
for (const name of readdirSync(dir)) {
|
|
103
|
-
if (!/\.log(\.1)?$/.test(name)) continue;
|
|
104
|
-
const path = join(dir, name);
|
|
105
|
-
try {
|
|
106
|
-
if (statSync(path).mtimeMs < now - keepMs) {
|
|
107
|
-
unlinkSync(path);
|
|
108
|
-
removed++;
|
|
109
|
-
}
|
|
110
|
-
} catch {
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return removed;
|
|
114
|
-
}
|
|
115
|
-
function sizeOf(path) {
|
|
116
|
-
try {
|
|
117
|
-
return statSync(path).size;
|
|
118
|
-
} catch {
|
|
119
|
-
return 0;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
var STOPPED_SUMMARY = "The run was stopped.";
|
|
123
|
-
function endNote(end) {
|
|
124
|
-
return `= ${end.kind === "settled" ? "Done" : "Ended"}: ${end.summary ?? end.kind}`;
|
|
125
|
-
}
|
|
126
|
-
function isEndLogLine(line) {
|
|
127
|
-
return /^\S+ = (Done|Ended): /.test(line);
|
|
128
|
-
}
|
|
129
|
-
function stamp(now) {
|
|
130
|
-
const d = new Date(now);
|
|
131
|
-
return [d.getHours(), d.getMinutes(), d.getSeconds()].map((n) => String(n).padStart(2, "0")).join(":");
|
|
132
|
-
}
|
|
133
|
-
|
|
134
22
|
// src/drivers/local.ts
|
|
135
23
|
import { execFile, execFileSync, spawn } from "child_process";
|
|
136
|
-
import { chmodSync
|
|
24
|
+
import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
137
25
|
import { homedir, hostname } from "os";
|
|
138
|
-
import { basename, dirname
|
|
26
|
+
import { basename, dirname, join } from "path";
|
|
139
27
|
import { createInterface } from "readline";
|
|
140
28
|
var STOPPED = { kind: "failed", summary: STOPPED_SUMMARY };
|
|
141
29
|
function takeoverSummary(machine) {
|
|
142
30
|
return `You took this over on ${machine}.`;
|
|
143
31
|
}
|
|
144
32
|
var CONTINUE_PROMPT = "Continue the work from where you stopped. If it is already done, say so in one sentence.";
|
|
145
|
-
var PR_URL = /https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/\d+/g;
|
|
146
33
|
var SHARED_BRANCHES = /* @__PURE__ */ new Set(["staging", "main", "master", "HEAD"]);
|
|
147
34
|
var COMMANDS_KEPT = 50;
|
|
148
35
|
var SUMMARY_MAX = 200;
|
|
@@ -165,7 +52,7 @@ function failedEnd(harness, run2) {
|
|
|
165
52
|
return { summary: `${lead}${quoted}"`, ...error };
|
|
166
53
|
}
|
|
167
54
|
function localRunsFilePath() {
|
|
168
|
-
return process.env.CLOOP_LOCAL_RUNS_FILE ??
|
|
55
|
+
return process.env.CLOOP_LOCAL_RUNS_FILE ?? join(homedir(), CONFIG_DIR, "local-runs.json");
|
|
169
56
|
}
|
|
170
57
|
function pickRepo(repos, repository) {
|
|
171
58
|
if (!repository) {
|
|
@@ -179,9 +66,6 @@ function pickRepo(repos, repository) {
|
|
|
179
66
|
if (!found) throw new BoxToolError("no_project");
|
|
180
67
|
return found;
|
|
181
68
|
}
|
|
182
|
-
function prUrlIn(text) {
|
|
183
|
-
return text?.match(PR_URL)?.at(-1) ?? null;
|
|
184
|
-
}
|
|
185
69
|
function run(cmd, args, cwd) {
|
|
186
70
|
return new Promise(
|
|
187
71
|
(resolve, reject) => execFile(
|
|
@@ -604,12 +488,8 @@ ${RESULT_INSTRUCTION}`));
|
|
|
604
488
|
}
|
|
605
489
|
}
|
|
606
490
|
progress(r, live, line, force) {
|
|
607
|
-
const summary = (
|
|
608
|
-
if (
|
|
609
|
-
const now = this.now();
|
|
610
|
-
if (!force && now - live.lastProgressAt < (this.deps.progressMs ?? 3e4)) return;
|
|
611
|
-
live.lastProgressAt = now;
|
|
612
|
-
this.emit(r.work_id, { kind: "progress", summary });
|
|
491
|
+
const summary = nextProgress(live, line, this.now(), this.deps.progressMs, force);
|
|
492
|
+
if (summary) this.emit(r.work_id, { kind: "progress", summary });
|
|
613
493
|
}
|
|
614
494
|
async onExit(r, live, code, signal) {
|
|
615
495
|
if (this.lives.get(r.work_id) === live) this.lives.delete(r.work_id);
|
|
@@ -685,7 +565,7 @@ ${RESULT_INSTRUCTION}`));
|
|
|
685
565
|
* work. A run that committed without pushing says so.
|
|
686
566
|
*/
|
|
687
567
|
async outcome(r, text) {
|
|
688
|
-
const named =
|
|
568
|
+
const named = resultPrUrl(text);
|
|
689
569
|
if (named) return { pr: named };
|
|
690
570
|
if (!r.head_at_launch) return { pr: null };
|
|
691
571
|
const head = await this.repo.head(r.repo);
|
|
@@ -730,12 +610,12 @@ ${RESULT_INSTRUCTION}`));
|
|
|
730
610
|
return readRunRecords(this.file).filter((r) => !(r.end && Date.parse(r.end.at) < cutoff));
|
|
731
611
|
}
|
|
732
612
|
save() {
|
|
733
|
-
|
|
613
|
+
mkdirSync(dirname(this.file), { recursive: true, mode: 448 });
|
|
734
614
|
const tmp = `${this.file}.tmp`;
|
|
735
615
|
writeFileSync(tmp, `${JSON.stringify([...this.runs.values()], null, 2)}
|
|
736
616
|
`, { mode: 384 });
|
|
737
|
-
|
|
738
|
-
|
|
617
|
+
chmodSync(tmp, 384);
|
|
618
|
+
renameSync(tmp, this.file);
|
|
739
619
|
}
|
|
740
620
|
};
|
|
741
621
|
function readRunRecords(file = localRunsFilePath()) {
|
|
@@ -748,15 +628,8 @@ function readRunRecords(file = localRunsFilePath()) {
|
|
|
748
628
|
return [];
|
|
749
629
|
}
|
|
750
630
|
}
|
|
751
|
-
function isProgressSentence(value) {
|
|
752
|
-
return typeof value === "string" && /\S[ \t]+\S/.test(value.trim().split(/\r?\n/)[0] ?? "");
|
|
753
|
-
}
|
|
754
631
|
|
|
755
632
|
export {
|
|
756
|
-
runLogDir,
|
|
757
|
-
runLogPath,
|
|
758
|
-
STOPPED_SUMMARY,
|
|
759
|
-
isEndLogLine,
|
|
760
633
|
takeoverSummary,
|
|
761
634
|
localRunsFilePath,
|
|
762
635
|
LocalDriver,
|