@cloop/runner 0.3.38 → 0.3.41
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-TQJJ6EJK.js → box-G664ZM6O.js} +30 -12
- package/dist/{chunk-3WRLILTX.js → chunk-3XQ44U27.js} +5 -5
- package/dist/{chunk-43OQXKIP.js → chunk-4MMTNAPM.js} +1 -1
- package/dist/{chunk-Z3KDTCS6.js → chunk-ILLDES3M.js} +1 -1
- package/dist/{chunk-WWG6T3HW.js → chunk-LGKSLIU2.js} +1 -1
- package/dist/{chunk-HYYLDJ5K.js → chunk-LMW4JHRH.js} +3 -3
- package/dist/{chunk-PF6QW6CK.js → chunk-NPTLMG3V.js} +1 -1
- package/dist/{chunk-TQ2SCOKH.js → chunk-SDVTQCW7.js} +135 -66
- package/dist/chunk-WIAWWXGP.js +857 -0
- package/dist/{connect-CBWHDE5Y.js → connect-SFAOSHIO.js} +6 -6
- package/dist/{disconnect-POJACA2Q.js → disconnect-ERRRZY25.js} +6 -6
- package/dist/{existing-runner-XOCSW4F4.js → existing-runner-HI4DFKSW.js} +6 -6
- package/dist/index.js +14 -14
- package/dist/{login-JRAQBWSB.js → login-UURPRX5F.js} +2 -2
- package/dist/{mcp-server-N7WRPR77.js → mcp-server-MTDAMQ7C.js} +1 -1
- package/dist/{runner-KFEUMXMY.js → runner-GMHC5FE7.js} +3 -3
- package/dist/{runs-5YIEWOJM.js → runs-XR4MYK4X.js} +2 -2
- package/dist/{statusline-JYOI3SWJ.js → statusline-BV2IXFDB.js} +1 -1
- package/dist/{takeover-S3PBIUN5.js → takeover-H5YOSKV5.js} +4 -4
- package/dist/{use-BLFMGGRV.js → use-6OHXWE5L.js} +6 -6
- package/package.json +1 -1
- package/dist/chunk-OIZI3FXO.js +0 -254
|
@@ -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-LMW4JHRH.js";
|
|
5
|
+
import "./chunk-NPTLMG3V.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-3XQ44U27.js";
|
|
42
42
|
import {
|
|
43
43
|
MeshSocket,
|
|
44
44
|
WAKE_TICK_MS,
|
|
@@ -52,17 +52,18 @@ import {
|
|
|
52
52
|
hostedThreadsFilePath,
|
|
53
53
|
lockThreadsFile,
|
|
54
54
|
readRunnerState,
|
|
55
|
+
runOutputs,
|
|
55
56
|
runnerStatePath,
|
|
56
57
|
threadsFilePath,
|
|
57
58
|
writeRunnerState
|
|
58
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-WIAWWXGP.js";
|
|
59
60
|
import {
|
|
60
61
|
BackgroundReading,
|
|
61
62
|
BoxToolError,
|
|
62
63
|
HARNESS_LIMIT,
|
|
63
64
|
HARNESS_STALE_MS,
|
|
64
65
|
LocalDriver,
|
|
65
|
-
|
|
66
|
+
MACHINE_RESULT_INSTRUCTION,
|
|
66
67
|
RUN_TEXT_MAX,
|
|
67
68
|
STOPPED_SUMMARY,
|
|
68
69
|
T3Client,
|
|
@@ -100,20 +101,20 @@ import {
|
|
|
100
101
|
utcWindow,
|
|
101
102
|
windowsPowerShellEnv,
|
|
102
103
|
writeBoxConfig
|
|
103
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-SDVTQCW7.js";
|
|
104
105
|
import "./chunk-VK6GV757.js";
|
|
105
106
|
import {
|
|
106
107
|
olderThan
|
|
107
108
|
} from "./chunk-365HFCQQ.js";
|
|
108
109
|
import "./chunk-PKIEWBR7.js";
|
|
109
|
-
import "./chunk-
|
|
110
|
-
import "./chunk-
|
|
110
|
+
import "./chunk-LGKSLIU2.js";
|
|
111
|
+
import "./chunk-4MMTNAPM.js";
|
|
111
112
|
import {
|
|
112
113
|
getMachine
|
|
113
114
|
} from "./chunk-SBYSVZ7J.js";
|
|
114
115
|
import {
|
|
115
116
|
VERSION
|
|
116
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-ILLDES3M.js";
|
|
117
118
|
import {
|
|
118
119
|
getMeshUrl,
|
|
119
120
|
getOrigin,
|
|
@@ -122,6 +123,10 @@ import {
|
|
|
122
123
|
readCredentials
|
|
123
124
|
} from "./chunk-D5UZW42X.js";
|
|
124
125
|
|
|
126
|
+
// src/commands/box.ts
|
|
127
|
+
import { homedir as homedir3 } from "os";
|
|
128
|
+
import { join as join6 } from "path";
|
|
129
|
+
|
|
125
130
|
// src/cloudroom-core.ts
|
|
126
131
|
var CoreError = class extends Error {
|
|
127
132
|
constructor(status, code, message) {
|
|
@@ -572,7 +577,7 @@ The Task names the repository ${place.named}. This folder is empty: clone it her
|
|
|
572
577
|
|
|
573
578
|
${photos}` : ""}
|
|
574
579
|
|
|
575
|
-
${
|
|
580
|
+
${MACHINE_RESULT_INSTRUCTION}`;
|
|
576
581
|
}
|
|
577
582
|
var NEW_FOLD = {
|
|
578
583
|
start: null,
|
|
@@ -1007,9 +1012,11 @@ var CloudroomDriver = class {
|
|
|
1007
1012
|
* working in the folder, keeps it. A
|
|
1008
1013
|
* failure here is logged and the end is reported as it was.
|
|
1009
1014
|
*/
|
|
1010
|
-
async tidy(id,
|
|
1015
|
+
async tidy(id, ended) {
|
|
1016
|
+
let end = ended;
|
|
1011
1017
|
try {
|
|
1012
1018
|
const s = await this.core.session(id);
|
|
1019
|
+
if (s?.workspace_path && end.kind === "settled") end = { ...end, cwd: s.workspace_path };
|
|
1013
1020
|
const tree = worktreeOf(s?.workspace ?? null);
|
|
1014
1021
|
if (!s || !tree) return end;
|
|
1015
1022
|
const path = folder(s);
|
|
@@ -2573,11 +2580,21 @@ async function run2() {
|
|
|
2573
2580
|
return e && { thread_id: e.thread_id, settled: Boolean(e.settled_at) };
|
|
2574
2581
|
}
|
|
2575
2582
|
});
|
|
2583
|
+
const outputs = runOutputs({
|
|
2584
|
+
origin: cfg.origin ?? getOrigin(),
|
|
2585
|
+
deviceToken: () => token,
|
|
2586
|
+
log: log2,
|
|
2587
|
+
dir: runnerDir(),
|
|
2588
|
+
awakeDir: hosted ? join6(homedir3(), ".cloop", "awake") : null
|
|
2589
|
+
});
|
|
2590
|
+
const previews = outputs.connector;
|
|
2591
|
+
void previews.resume();
|
|
2576
2592
|
const watch = new BoxWatch({
|
|
2577
2593
|
file: threadsFile,
|
|
2578
2594
|
watch: (id, onEvent) => driver.watch(id, onEvent),
|
|
2579
2595
|
send: (frame) => socket.send({ ...frame }),
|
|
2580
|
-
log: log2
|
|
2596
|
+
log: log2,
|
|
2597
|
+
attach: outputs.attach
|
|
2581
2598
|
});
|
|
2582
2599
|
const setup = hosted ? void 0 : new SetupShare({
|
|
2583
2600
|
origin: cfg.origin ?? getOrigin(),
|
|
@@ -2820,6 +2837,7 @@ async function run2() {
|
|
|
2820
2837
|
const stop = (code = 0) => {
|
|
2821
2838
|
log2("stopping");
|
|
2822
2839
|
watch.stop();
|
|
2840
|
+
previews.stop();
|
|
2823
2841
|
unfollow?.();
|
|
2824
2842
|
if (driver instanceof LocalDriver) driver.stop();
|
|
2825
2843
|
lock.release();
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
readRunnerState,
|
|
10
10
|
runnerStatePath,
|
|
11
11
|
threadsFilePath
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WIAWWXGP.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-SDVTQCW7.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-LGKSLIU2.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-4MMTNAPM.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-ILLDES3M.js";
|
|
81
81
|
import {
|
|
82
82
|
STAGING_ORIGIN,
|
|
83
83
|
getOrigin,
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import {
|
|
3
3
|
findRun,
|
|
4
4
|
ownHarness
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-NPTLMG3V.js";
|
|
6
6
|
import {
|
|
7
7
|
lockThreadsFile,
|
|
8
8
|
threadsFilePath
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WIAWWXGP.js";
|
|
10
10
|
import {
|
|
11
11
|
localRunsFilePath,
|
|
12
12
|
readRunRecords,
|
|
13
13
|
runHarness,
|
|
14
14
|
takeoverSummary
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-SDVTQCW7.js";
|
|
16
16
|
import {
|
|
17
17
|
sanitizeLabel
|
|
18
18
|
} from "./chunk-VK6GV757.js";
|
|
@@ -63,6 +63,61 @@ function serviceIdentity(kind, env) {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// src/spawn-command.ts
|
|
67
|
+
import { execFileSync } from "child_process";
|
|
68
|
+
function commandFor(bin, args, platform = process.platform, comspec = process.env.ComSpec) {
|
|
69
|
+
if (platform !== "win32") return { file: bin, args };
|
|
70
|
+
const executable = windowsExecutable(bin) ?? bin;
|
|
71
|
+
if (!/\.(cmd|bat)$/i.test(executable)) return { file: executable, args };
|
|
72
|
+
return {
|
|
73
|
+
file: comspec ?? "cmd.exe",
|
|
74
|
+
args: ["/d", "/s", "/c", `"${[executable, ...args].map(quoteWindowsArg).join(" ")}"`],
|
|
75
|
+
windowsVerbatimArguments: true
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function quoteWindowsArg(arg) {
|
|
79
|
+
if (arg && !/[ \t"]/.test(arg)) return arg;
|
|
80
|
+
let quoted = '"';
|
|
81
|
+
let backslashes = 0;
|
|
82
|
+
for (const ch of arg) {
|
|
83
|
+
if (ch === "\\") {
|
|
84
|
+
backslashes++;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
quoted += "\\".repeat(ch === '"' ? backslashes * 2 + 1 : backslashes) + ch;
|
|
88
|
+
backslashes = 0;
|
|
89
|
+
}
|
|
90
|
+
return `${quoted}${"\\".repeat(backslashes * 2)}"`;
|
|
91
|
+
}
|
|
92
|
+
function preferExecutable(lines) {
|
|
93
|
+
return lines.find((line) => /\.exe$/i.test(line)) ?? lines.find((line) => /\.(cmd|bat)$/i.test(line)) ?? null;
|
|
94
|
+
}
|
|
95
|
+
var windowsExecutables = /* @__PURE__ */ new Map();
|
|
96
|
+
function windowsExecutable(bin) {
|
|
97
|
+
if (/[\\/]/.test(bin)) return bin;
|
|
98
|
+
if (process.platform !== "win32") return null;
|
|
99
|
+
const key = JSON.stringify([bin, process.env.PATH, process.env.PATHEXT]);
|
|
100
|
+
if (windowsExecutables.has(key)) return windowsExecutables.get(key) ?? null;
|
|
101
|
+
let resolved = null;
|
|
102
|
+
try {
|
|
103
|
+
resolved = preferExecutable(
|
|
104
|
+
execFileSync("where.exe", [bin], { encoding: "utf-8", timeout: 5e3 }).split(/\r?\n/).map((line) => line.trim()).filter(Boolean)
|
|
105
|
+
);
|
|
106
|
+
} catch {
|
|
107
|
+
}
|
|
108
|
+
windowsExecutables.set(key, resolved);
|
|
109
|
+
if (!resolved)
|
|
110
|
+
console.error(
|
|
111
|
+
`[runner:spawn] Could not resolve ${bin} to an executable on PATH. Install the agent and reconnect the runner.`
|
|
112
|
+
);
|
|
113
|
+
return resolved;
|
|
114
|
+
}
|
|
115
|
+
function windowsPowerShellEnv(env = process.env) {
|
|
116
|
+
return Object.fromEntries(
|
|
117
|
+
Object.entries(env).filter(([key]) => key.toLowerCase() !== "psmodulepath")
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
66
121
|
// src/runner-config.ts
|
|
67
122
|
import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
68
123
|
import { dirname, join as join2 } from "path";
|
|
@@ -432,61 +487,6 @@ function stamp(now) {
|
|
|
432
487
|
return [d.getHours(), d.getMinutes(), d.getSeconds()].map((n) => String(n).padStart(2, "0")).join(":");
|
|
433
488
|
}
|
|
434
489
|
|
|
435
|
-
// src/spawn-command.ts
|
|
436
|
-
import { execFileSync } from "child_process";
|
|
437
|
-
function commandFor(bin, args, platform = process.platform, comspec = process.env.ComSpec) {
|
|
438
|
-
if (platform !== "win32") return { file: bin, args };
|
|
439
|
-
const executable = windowsExecutable(bin) ?? bin;
|
|
440
|
-
if (!/\.(cmd|bat)$/i.test(executable)) return { file: executable, args };
|
|
441
|
-
return {
|
|
442
|
-
file: comspec ?? "cmd.exe",
|
|
443
|
-
args: ["/d", "/s", "/c", `"${[executable, ...args].map(quoteWindowsArg).join(" ")}"`],
|
|
444
|
-
windowsVerbatimArguments: true
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
function quoteWindowsArg(arg) {
|
|
448
|
-
if (arg && !/[ \t"]/.test(arg)) return arg;
|
|
449
|
-
let quoted = '"';
|
|
450
|
-
let backslashes = 0;
|
|
451
|
-
for (const ch of arg) {
|
|
452
|
-
if (ch === "\\") {
|
|
453
|
-
backslashes++;
|
|
454
|
-
continue;
|
|
455
|
-
}
|
|
456
|
-
quoted += "\\".repeat(ch === '"' ? backslashes * 2 + 1 : backslashes) + ch;
|
|
457
|
-
backslashes = 0;
|
|
458
|
-
}
|
|
459
|
-
return `${quoted}${"\\".repeat(backslashes * 2)}"`;
|
|
460
|
-
}
|
|
461
|
-
function preferExecutable(lines) {
|
|
462
|
-
return lines.find((line) => /\.exe$/i.test(line)) ?? lines.find((line) => /\.(cmd|bat)$/i.test(line)) ?? null;
|
|
463
|
-
}
|
|
464
|
-
var windowsExecutables = /* @__PURE__ */ new Map();
|
|
465
|
-
function windowsExecutable(bin) {
|
|
466
|
-
if (/[\\/]/.test(bin)) return bin;
|
|
467
|
-
if (process.platform !== "win32") return null;
|
|
468
|
-
const key = JSON.stringify([bin, process.env.PATH, process.env.PATHEXT]);
|
|
469
|
-
if (windowsExecutables.has(key)) return windowsExecutables.get(key) ?? null;
|
|
470
|
-
let resolved = null;
|
|
471
|
-
try {
|
|
472
|
-
resolved = preferExecutable(
|
|
473
|
-
execFileSync("where.exe", [bin], { encoding: "utf-8", timeout: 5e3 }).split(/\r?\n/).map((line) => line.trim()).filter(Boolean)
|
|
474
|
-
);
|
|
475
|
-
} catch {
|
|
476
|
-
}
|
|
477
|
-
windowsExecutables.set(key, resolved);
|
|
478
|
-
if (!resolved)
|
|
479
|
-
console.error(
|
|
480
|
-
`[runner:spawn] Could not resolve ${bin} to an executable on PATH. Install the agent and reconnect the runner.`
|
|
481
|
-
);
|
|
482
|
-
return resolved;
|
|
483
|
-
}
|
|
484
|
-
function windowsPowerShellEnv(env = process.env) {
|
|
485
|
-
return Object.fromEntries(
|
|
486
|
-
Object.entries(env).filter(([key]) => key.toLowerCase() !== "psmodulepath")
|
|
487
|
-
);
|
|
488
|
-
}
|
|
489
|
-
|
|
490
490
|
// src/t3-bin.ts
|
|
491
491
|
import { execFile, execFileSync as execFileSync2 } from "child_process";
|
|
492
492
|
import { existsSync, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
|
|
@@ -788,6 +788,33 @@ function repoName(repository) {
|
|
|
788
788
|
// ../clo0p-app/contracts/run-result.ts
|
|
789
789
|
var WIZARD_STEPS_MAX = 6;
|
|
790
790
|
var WIZARD_FOR = "steps only the user can do by hand: a sign-in, an app permission, a key from a dashboard, or a change in a dashboard or console you cannot make yourself";
|
|
791
|
+
var CHECK_BACK_MIN_MINUTES = 5;
|
|
792
|
+
var CHECK_BACK_MAX_MINUTES = 3 * 24 * 60;
|
|
793
|
+
var CHECK_BACK_WHY_MAX = 300;
|
|
794
|
+
var RUN_IMAGES_MAX = 6;
|
|
795
|
+
var RUN_IMAGE_MAX_BYTES = 5 * 1024 * 1024;
|
|
796
|
+
var RUN_IMAGE_TYPES = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" };
|
|
797
|
+
function imageExt(bytes) {
|
|
798
|
+
const at = (i, ...want) => want.every((b, j) => bytes[i + j] === b);
|
|
799
|
+
if (at(0, 137, 80, 78, 71, 13, 10, 26, 10)) return "png";
|
|
800
|
+
if (at(0, 255, 216, 255)) return "jpg";
|
|
801
|
+
if (at(0, 82, 73, 70, 70) && at(8, 87, 69, 66, 80)) return "webp";
|
|
802
|
+
return null;
|
|
803
|
+
}
|
|
804
|
+
var RUN_MEDIA_KEY = runMediaPattern("[0-9a-f-]{36}\\/[0-9a-f-]{36}\\/");
|
|
805
|
+
var RUN_MEDIA_FILE = runMediaPattern("");
|
|
806
|
+
var RUN_PREVIEWS_MAX = 3;
|
|
807
|
+
var PREVIEW_HOURS = 24;
|
|
808
|
+
var PREVIEW_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
809
|
+
function isPort(v) {
|
|
810
|
+
return typeof v === "number" && Number.isInteger(v) && v >= 1 && v <= 65535;
|
|
811
|
+
}
|
|
812
|
+
function isPreviewPath(v) {
|
|
813
|
+
return typeof v === "string" && v.length <= 400 && v.startsWith("/") && !v.startsWith("//") && !/[\s\\]/.test(v);
|
|
814
|
+
}
|
|
815
|
+
function runMediaPattern(folder) {
|
|
816
|
+
return new RegExp(`^${folder}[0-9a-f-]{36}\\.(${Object.keys(RUN_IMAGE_TYPES).join("|")})$`);
|
|
817
|
+
}
|
|
791
818
|
var RESULT_INSTRUCTION = [
|
|
792
819
|
"When you finish, end your final message with a fenced block tagged cloop-result containing JSON, for example:",
|
|
793
820
|
"```cloop-result",
|
|
@@ -799,6 +826,12 @@ var RESULT_INSTRUCTION = [
|
|
|
799
826
|
"List as outputs only what this run made. A PR or page you only read, checked or cited goes in the summary, never in outputs.",
|
|
800
827
|
"When the ask is to find, compare, summarise or research something, put the whole answer in a doc output with a body, so the owner has one page to read; the summary stays one or two sentences."
|
|
801
828
|
].join("\n");
|
|
829
|
+
var MACHINE_RESULT_INSTRUCTION = [
|
|
830
|
+
RESULT_INSTRUCTION,
|
|
831
|
+
`To show the owner a picture, such as a screenshot of a UI change or a result a picture explains better than words, save it as a PNG, JPEG or WebP file outside the repository (for example in /tmp) and list it as an output: {"kind": "image", "title": "The new sign-in page", "path": "/tmp/sign-in.png"}, with the file's absolute path. Cloop uploads the file and shows it on the run. At most ${RUN_IMAGES_MAX} images, each under ${RUN_IMAGE_MAX_BYTES / (1024 * 1024)} MB. On a Cloop Box, the Playwright browser tool takes a screenshot of any page, a local server's page too.`,
|
|
832
|
+
`To let the owner open a web app or page you are running on this machine, such as a dev server, leave the server running after your turn ends: start it in the background, detached from your shell (for example \`nohup npm run dev -- --port 5173 > /tmp/dev.log 2>&1 &\`), and check it answers on its port. Then list it as an output: {"kind": "preview", "title": "The new sign-in page", "port": 5173, "path": "/sign-in"}, with the port it listens on and an optional path to open first. Cloop gives the owner a private link to it for ${PREVIEW_HOURS} hours, while this machine is on. At most ${RUN_PREVIEWS_MAX} previews a run.`,
|
|
833
|
+
`When you started something that keeps running after this turn (a build, a deploy, a long job) or you wait on something outside, do not wait in the turn: add "check_back": {"in_minutes": 120, "why": "Read the training log and report the score."} to the block. Cloop sends you a message in this conversation then, with your why, and you carry on from there. Give ${CHECK_BACK_MIN_MINUTES} to ${CHECK_BACK_MAX_MINUTES} minutes. Leave it out when the work is done.`
|
|
834
|
+
].join("\n");
|
|
802
835
|
var SUMMARY_MAX = 4e3;
|
|
803
836
|
var ASKS_MAX = 1e3;
|
|
804
837
|
var DOC_BODY_MAX = 8e3;
|
|
@@ -853,12 +886,38 @@ function readOutput(o) {
|
|
|
853
886
|
}
|
|
854
887
|
case "file":
|
|
855
888
|
return text(out.path, 400) ? { kind: "file", title, path: out.path } : null;
|
|
889
|
+
case "image":
|
|
890
|
+
if (!text(out.path, 400)) return null;
|
|
891
|
+
return {
|
|
892
|
+
kind: "image",
|
|
893
|
+
title,
|
|
894
|
+
path: out.path,
|
|
895
|
+
...typeof out.media === "string" && RUN_MEDIA_KEY.test(out.media) ? { media: out.media } : {}
|
|
896
|
+
};
|
|
897
|
+
case "preview":
|
|
898
|
+
if (!isPort(out.port) || out.path !== void 0 && !isPreviewPath(out.path)) return null;
|
|
899
|
+
return {
|
|
900
|
+
kind: "preview",
|
|
901
|
+
title,
|
|
902
|
+
port: out.port,
|
|
903
|
+
...out.path !== void 0 ? { path: out.path } : {},
|
|
904
|
+
...typeof out.preview === "string" && PREVIEW_ID.test(out.preview) ? { preview: out.preview } : {}
|
|
905
|
+
};
|
|
856
906
|
case "wizard":
|
|
857
907
|
return Array.isArray(out.steps) && out.steps.length ? { kind: "wizard", title, steps: out.steps } : null;
|
|
858
908
|
default:
|
|
859
909
|
return null;
|
|
860
910
|
}
|
|
861
911
|
}
|
|
912
|
+
function readCheckBack(v) {
|
|
913
|
+
if (!v || typeof v !== "object") return null;
|
|
914
|
+
const { in_minutes: minutes, why } = v;
|
|
915
|
+
if (typeof minutes !== "number" || !Number.isFinite(minutes) || typeof why !== "string" || !why.trim()) return null;
|
|
916
|
+
return {
|
|
917
|
+
in_minutes: Math.min(CHECK_BACK_MAX_MINUTES, Math.max(CHECK_BACK_MIN_MINUTES, Math.round(minutes))),
|
|
918
|
+
why: why.trim().slice(0, CHECK_BACK_WHY_MAX)
|
|
919
|
+
};
|
|
920
|
+
}
|
|
862
921
|
function readCheck(c) {
|
|
863
922
|
if (!c || typeof c !== "object") return null;
|
|
864
923
|
const check = c;
|
|
@@ -886,13 +945,15 @@ function readRunResult(message) {
|
|
|
886
945
|
const asks = typeof value?.asks === "string" ? value.asks.trim() : "";
|
|
887
946
|
const outputs = list(value?.outputs).flatMap((o) => readOutput(o) ?? []);
|
|
888
947
|
const checks = list(value?.checks).flatMap((c) => readCheck(c) ?? []);
|
|
948
|
+
const checkBack = readCheckBack(value?.check_back);
|
|
889
949
|
return {
|
|
890
950
|
result: {
|
|
891
951
|
summary: summary.length > SUMMARY_MAX ? `${summary.slice(0, SUMMARY_MAX - 1)}\u2026` : summary,
|
|
892
952
|
outputs: outputs.slice(0, ITEMS_MAX),
|
|
893
953
|
checks: checks.slice(0, ITEMS_MAX),
|
|
894
954
|
...value?.nothing_new === true ? { nothing_new: true } : {},
|
|
895
|
-
...asks ? { asks: asks.length > ASKS_MAX ? `${asks.slice(0, ASKS_MAX - 1)}\u2026` : asks } : {}
|
|
955
|
+
...asks ? { asks: asks.length > ASKS_MAX ? `${asks.slice(0, ASKS_MAX - 1)}\u2026` : asks } : {},
|
|
956
|
+
...checkBack ? { check_back: checkBack } : {}
|
|
896
957
|
},
|
|
897
958
|
dropped: { outputs: list(value?.outputs).length - outputs.length, checks: list(value?.checks).length - checks.length }
|
|
898
959
|
};
|
|
@@ -1866,7 +1927,7 @@ var T3Driver = class {
|
|
|
1866
1927
|
...photos2.attachments.length ? { threadId: a.work_id } : {},
|
|
1867
1928
|
initialMessage: {
|
|
1868
1929
|
...photos2.attachments.length ? { messageId: a.work_id } : {},
|
|
1869
|
-
text: [a.prompt, missing && cloneLine(missing), photos2.line,
|
|
1930
|
+
text: [a.prompt, missing && cloneLine(missing), photos2.line, MACHINE_RESULT_INSTRUCTION].filter(Boolean).join("\n\n"),
|
|
1870
1931
|
attachments: photos2.attachments
|
|
1871
1932
|
}
|
|
1872
1933
|
}
|
|
@@ -2367,7 +2428,7 @@ var T3Driver = class {
|
|
|
2367
2428
|
text: handoverPrompt("Carry on with the task in this thread.", name, reason).concat(
|
|
2368
2429
|
`
|
|
2369
2430
|
|
|
2370
|
-
${
|
|
2431
|
+
${MACHINE_RESULT_INSTRUCTION}`
|
|
2371
2432
|
),
|
|
2372
2433
|
attachments: [],
|
|
2373
2434
|
modelSelection: to,
|
|
@@ -2555,6 +2616,9 @@ function pickRepo(repos, repository) {
|
|
|
2555
2616
|
if (!picked) throw new BoxToolError("no_project");
|
|
2556
2617
|
return picked;
|
|
2557
2618
|
}
|
|
2619
|
+
function withFolder(r, end) {
|
|
2620
|
+
return end.kind === "settled" ? { ...end, cwd: r.repo } : end;
|
|
2621
|
+
}
|
|
2558
2622
|
function run(cmd, args, cwd) {
|
|
2559
2623
|
return new Promise(
|
|
2560
2624
|
(resolve, reject) => execFile3(
|
|
@@ -2975,7 +3039,7 @@ ${a.text}` : a.text;
|
|
|
2975
3039
|
}
|
|
2976
3040
|
if (r.end) {
|
|
2977
3041
|
const { at: _at, ...end } = r.end;
|
|
2978
|
-
onEvent(end);
|
|
3042
|
+
onEvent(withFolder(r, end));
|
|
2979
3043
|
return unwatch;
|
|
2980
3044
|
}
|
|
2981
3045
|
const live = this.lives.get(id);
|
|
@@ -3105,7 +3169,7 @@ ${a.text}` : a.text;
|
|
|
3105
3169
|
});
|
|
3106
3170
|
child.stdin?.write(dialect.opening(r, `${prompt}
|
|
3107
3171
|
|
|
3108
|
-
${
|
|
3172
|
+
${MACHINE_RESULT_INSTRUCTION}`, images));
|
|
3109
3173
|
if (!dialect.keepsStdin) child.stdin?.end();
|
|
3110
3174
|
child.stderr?.on("data", (chunk) => {
|
|
3111
3175
|
live.stderr = (live.stderr + chunk.toString("utf-8")).slice(-2e3);
|
|
@@ -3348,7 +3412,7 @@ ${RESULT_INSTRUCTION}`, images));
|
|
|
3348
3412
|
r.pid = null;
|
|
3349
3413
|
this.save();
|
|
3350
3414
|
this.note(r, endNote(end));
|
|
3351
|
-
this.emit(r.work_id, end);
|
|
3415
|
+
this.emit(r.work_id, withFolder(r, end));
|
|
3352
3416
|
}
|
|
3353
3417
|
emit(id, event) {
|
|
3354
3418
|
for (const listener of [...this.listeners.get(id) ?? []]) listener(event);
|
|
@@ -3398,7 +3462,12 @@ function readRunRecords(file = localRunsFilePath()) {
|
|
|
3398
3462
|
}
|
|
3399
3463
|
|
|
3400
3464
|
export {
|
|
3401
|
-
|
|
3465
|
+
RUN_IMAGES_MAX,
|
|
3466
|
+
RUN_IMAGE_MAX_BYTES,
|
|
3467
|
+
RUN_IMAGE_TYPES,
|
|
3468
|
+
imageExt,
|
|
3469
|
+
RUN_PREVIEWS_MAX,
|
|
3470
|
+
MACHINE_RESULT_INSTRUCTION,
|
|
3402
3471
|
readRunResult,
|
|
3403
3472
|
hasResultBlock,
|
|
3404
3473
|
resultText,
|
|
@@ -3420,6 +3489,10 @@ export {
|
|
|
3420
3489
|
runnerPath,
|
|
3421
3490
|
cloopCommand,
|
|
3422
3491
|
serviceIdentity,
|
|
3492
|
+
commandFor,
|
|
3493
|
+
quoteWindowsArg,
|
|
3494
|
+
windowsExecutable,
|
|
3495
|
+
windowsPowerShellEnv,
|
|
3423
3496
|
boxPath,
|
|
3424
3497
|
isLocal,
|
|
3425
3498
|
isHosted,
|
|
@@ -3435,10 +3508,6 @@ export {
|
|
|
3435
3508
|
redactSecrets,
|
|
3436
3509
|
STOPPED_SUMMARY,
|
|
3437
3510
|
isEndLogLine,
|
|
3438
|
-
commandFor,
|
|
3439
|
-
quoteWindowsArg,
|
|
3440
|
-
windowsExecutable,
|
|
3441
|
-
windowsPowerShellEnv,
|
|
3442
3511
|
parseAttachments,
|
|
3443
3512
|
fetchImages,
|
|
3444
3513
|
delivery,
|