@cloop/runner 0.3.12 → 0.3.13
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-V3CQHA36.js → box-DTLW25MA.js} +9 -9
- package/dist/{chunk-YULXWTUB.js → chunk-6OWQEIFN.js} +1 -1
- package/dist/{chunk-UZYPDPGL.js → chunk-6QPGSWSN.js} +1 -1
- package/dist/{chunk-6IQ3ABBS.js → chunk-GFAI23T7.js} +1 -1
- package/dist/{chunk-Q4TAV5GV.js → chunk-H4EAJ2VW.js} +3 -3
- package/dist/{chunk-7SELZL6Z.js → chunk-OK7DODFL.js} +5 -1
- package/dist/{chunk-GNNGDCKP.js → chunk-QVFCIDR4.js} +188 -186
- package/dist/{chunk-JUQALHVZ.js → chunk-T3B3OPMM.js} +250 -73
- package/dist/{chunk-WRSJZ5WD.js → chunk-VWNTDZE3.js} +1 -1
- package/dist/{chunk-UBXT5IDU.js → chunk-YEO27QQP.js} +7 -1
- package/dist/{connect-XMPA7BZG.js → connect-CBMPU47P.js} +9 -7
- package/dist/{disconnect-ATKLCLYO.js → disconnect-CCBXASHZ.js} +7 -7
- package/dist/{existing-runner-LS2M5OAF.js → existing-runner-NSVNMW7A.js} +7 -7
- package/dist/index.js +15 -15
- package/dist/{login-4ZGAE7QV.js → login-SB72KWJZ.js} +2 -2
- package/dist/{mcp-server-4EH6Z5Z3.js → mcp-server-V4G3K5Y3.js} +1 -1
- package/dist/{runner-7PUTRUFX.js → runner-P3D25RNX.js} +3 -3
- package/dist/{runs-IVQRNCF5.js → runs-F3MKD7OX.js} +2 -2
- package/dist/{statusline-NDXFVGUT.js → statusline-ZI5YXWJ2.js} +1 -1
- package/dist/{takeover-3RVPILL7.js → takeover-HPDCHORW.js} +4 -4
- package/dist/{use-QN3OGZGP.js → use-PPF2XKSX.js} +7 -7
- package/package.json +1 -1
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
} from "./chunk-IJH4O27H.js";
|
|
6
6
|
import {
|
|
7
7
|
serveTakeovers
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-H4EAJ2VW.js";
|
|
9
|
+
import "./chunk-6OWQEIFN.js";
|
|
10
10
|
import {
|
|
11
11
|
DEFAULT_FALLBACK_MODEL,
|
|
12
12
|
T3Client,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
systemServices,
|
|
33
33
|
unitFor,
|
|
34
34
|
which
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-T3B3OPMM.js";
|
|
36
36
|
import {
|
|
37
37
|
BoxWatch,
|
|
38
38
|
lockThreadsFile,
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
runnerStatePath,
|
|
41
41
|
threadsFilePath,
|
|
42
42
|
writeRunnerState
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-VWNTDZE3.js";
|
|
44
44
|
import {
|
|
45
45
|
LocalDriver,
|
|
46
46
|
T3Driver,
|
|
@@ -51,21 +51,21 @@ import {
|
|
|
51
51
|
runnerPath,
|
|
52
52
|
showsOtherThreads,
|
|
53
53
|
writeBoxConfig
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-QVFCIDR4.js";
|
|
55
55
|
import {
|
|
56
56
|
getMachine
|
|
57
57
|
} from "./chunk-NTXQLEMQ.js";
|
|
58
58
|
import "./chunk-VK6GV757.js";
|
|
59
59
|
import {
|
|
60
60
|
olderThan
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-YEO27QQP.js";
|
|
62
62
|
import "./chunk-R3CLO2FB.js";
|
|
63
|
-
import "./chunk-
|
|
64
|
-
import "./chunk-
|
|
63
|
+
import "./chunk-6QPGSWSN.js";
|
|
64
|
+
import "./chunk-OK7DODFL.js";
|
|
65
65
|
import "./chunk-ES5BRAKJ.js";
|
|
66
66
|
import {
|
|
67
67
|
VERSION
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-GFAI23T7.js";
|
|
69
69
|
import {
|
|
70
70
|
getMeshUrl,
|
|
71
71
|
getToken,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
findRun
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6OWQEIFN.js";
|
|
5
5
|
import {
|
|
6
6
|
lockThreadsFile,
|
|
7
7
|
threadsFilePath
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VWNTDZE3.js";
|
|
9
9
|
import {
|
|
10
10
|
isLocal,
|
|
11
11
|
localRunsFilePath,
|
|
12
12
|
readRunRecords,
|
|
13
13
|
readRunnerConfig,
|
|
14
14
|
takeoverSummary
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QVFCIDR4.js";
|
|
16
16
|
import {
|
|
17
17
|
shortMachineName
|
|
18
18
|
} from "./chunk-NTXQLEMQ.js";
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-ES5BRAKJ.js";
|
|
6
6
|
import {
|
|
7
7
|
VERSION
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GFAI23T7.js";
|
|
9
9
|
import {
|
|
10
10
|
getOrigin,
|
|
11
11
|
readCredentials,
|
|
@@ -37,6 +37,8 @@ function newAttempt(now = Date.now()) {
|
|
|
37
37
|
driver: null,
|
|
38
38
|
fellBack: false,
|
|
39
39
|
workFolder: false,
|
|
40
|
+
codexInstall: null,
|
|
41
|
+
claudeInstall: null,
|
|
40
42
|
deviceToken: null
|
|
41
43
|
};
|
|
42
44
|
}
|
|
@@ -55,6 +57,8 @@ function connectReport(attempt, error, machine, now = Date.now()) {
|
|
|
55
57
|
driver: attempt.driver,
|
|
56
58
|
fell_back: attempt.fellBack,
|
|
57
59
|
work_folder: attempt.workFolder,
|
|
60
|
+
codex_install: attempt.codexInstall,
|
|
61
|
+
claude_install: attempt.claudeInstall,
|
|
58
62
|
step: attempt.step,
|
|
59
63
|
outcome: error ? "failed" : "ok",
|
|
60
64
|
error_code: error,
|
|
@@ -9,192 +9,6 @@ import {
|
|
|
9
9
|
getOrigin
|
|
10
10
|
} from "./chunk-D5UZW42X.js";
|
|
11
11
|
|
|
12
|
-
// src/run-result.ts
|
|
13
|
-
var RESULT_INSTRUCTION = [
|
|
14
|
-
"When you finish, end your final message with a fenced block tagged cloop-result containing JSON, for example:",
|
|
15
|
-
"```cloop-result",
|
|
16
|
-
'{"summary": "One or two sentences on what you did.", "outputs": [{"kind": "pr", "title": "fix: the thing", "url": "https://github.com/org/repo/pull/1"}], "checks": [{"name": "Tests", "outcome": "passed"}]}',
|
|
17
|
-
"```",
|
|
18
|
-
"An output kind is one of: pr or link (title, url), draft (title, body, optional to, optional url), doc (title, optional url or body), file (title, path). A check outcome is passed, failed or skipped.",
|
|
19
|
-
"A draft's body is the message itself, as the recipient will read it; if you saved it somewhere (a Gmail draft), put that link in url, never in body. A doc's body is the whole page in GitHub Markdown: headings, lists, bold and tables all show; a table suits one row per item. Give every product, page or source you mention as a full https link.",
|
|
20
|
-
"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."
|
|
21
|
-
].join("\n");
|
|
22
|
-
var text = (v, max) => typeof v === "string" && v.length <= max;
|
|
23
|
-
var optionalText = (v, max) => v === void 0 || text(v, max);
|
|
24
|
-
var https = (v) => {
|
|
25
|
-
try {
|
|
26
|
-
return typeof v === "string" && new URL(v).protocol === "https:";
|
|
27
|
-
} catch {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
var PR_URL = /https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/\d+/g;
|
|
32
|
-
var prNumber = (url) => Number(url.slice(url.lastIndexOf("/") + 1));
|
|
33
|
-
function prUrlIn(text2) {
|
|
34
|
-
const urls = text2?.match(PR_URL) ?? [];
|
|
35
|
-
return urls.reduce(
|
|
36
|
-
(newest, url) => newest && prNumber(newest) >= prNumber(url) ? newest : url,
|
|
37
|
-
null
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
function resultPrUrl(finalMessage) {
|
|
41
|
-
const result = parseRunResult(finalMessage);
|
|
42
|
-
if (!result) return prUrlIn(finalMessage);
|
|
43
|
-
const prs = result.outputs.flatMap((o) => o.kind === "pr" ? [o.url] : []);
|
|
44
|
-
return prs.at(-1) ?? null;
|
|
45
|
-
}
|
|
46
|
-
var SUMMARY_MAX = 4e3;
|
|
47
|
-
var DOC_BODY_MAX = 8e3;
|
|
48
|
-
function addressOutput(url) {
|
|
49
|
-
const pr = url.match(/\/pull\/(\d+)$/);
|
|
50
|
-
if (pr && prUrlIn(url) === url) return { kind: "pr", title: `Pull request #${pr[1]}`, url };
|
|
51
|
-
const { host, pathname } = new URL(url);
|
|
52
|
-
return { kind: "link", title: `${host}${pathname === "/" ? "" : pathname}`.slice(0, 120), url };
|
|
53
|
-
}
|
|
54
|
-
function cleanOutput(o) {
|
|
55
|
-
if (typeof o === "string") return https(o.trim()) ? addressOutput(o.trim()) : null;
|
|
56
|
-
if (!o || typeof o !== "object") return null;
|
|
57
|
-
const out = o;
|
|
58
|
-
if (!text(out.title, 120)) return null;
|
|
59
|
-
const title = out.title;
|
|
60
|
-
switch (out.kind) {
|
|
61
|
-
case "pr":
|
|
62
|
-
case "link":
|
|
63
|
-
return https(out.url) ? { kind: out.kind, title, url: out.url } : null;
|
|
64
|
-
case "draft":
|
|
65
|
-
return text(out.body, 4e3) && optionalText(out.to, 200) && (out.url === void 0 || https(out.url)) ? {
|
|
66
|
-
kind: "draft",
|
|
67
|
-
title,
|
|
68
|
-
body: out.body,
|
|
69
|
-
...out.to !== void 0 ? { to: out.to } : {},
|
|
70
|
-
...out.url !== void 0 ? { url: out.url } : {}
|
|
71
|
-
} : null;
|
|
72
|
-
case "doc": {
|
|
73
|
-
const body = typeof out.body === "string" && out.body.length > DOC_BODY_MAX ? `${out.body.slice(0, DOC_BODY_MAX - 1)}\u2026` : out.body;
|
|
74
|
-
return optionalText(body, DOC_BODY_MAX) && (out.url === void 0 || https(out.url)) ? {
|
|
75
|
-
kind: "doc",
|
|
76
|
-
title,
|
|
77
|
-
...out.url !== void 0 ? { url: out.url } : {},
|
|
78
|
-
...body !== void 0 ? { body } : {}
|
|
79
|
-
} : null;
|
|
80
|
-
}
|
|
81
|
-
case "file":
|
|
82
|
-
return text(out.path, 400) ? { kind: "file", title, path: out.path } : null;
|
|
83
|
-
default:
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function cleanCheck(c) {
|
|
88
|
-
if (!c || typeof c !== "object") return null;
|
|
89
|
-
const check = c;
|
|
90
|
-
if (!text(check.name, 80) || !["passed", "failed", "skipped"].includes(check.outcome))
|
|
91
|
-
return null;
|
|
92
|
-
if (!optionalText(check.detail, 200)) return null;
|
|
93
|
-
return {
|
|
94
|
-
name: check.name,
|
|
95
|
-
outcome: check.outcome,
|
|
96
|
-
...check.detail !== void 0 ? { detail: check.detail } : {}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function readRunResult(message) {
|
|
100
|
-
const none = { dropped: { outputs: 0, checks: 0 } };
|
|
101
|
-
const block = [...(message ?? "").matchAll(/```cloop-result\s*\n([\s\S]*?)```/g)].at(-1)?.[1];
|
|
102
|
-
if (!block) return none;
|
|
103
|
-
try {
|
|
104
|
-
const value = JSON.parse(block);
|
|
105
|
-
const summary = typeof value?.summary === "string" ? value.summary.trim() : "";
|
|
106
|
-
if (!summary) return none;
|
|
107
|
-
const list = (v) => Array.isArray(v) ? v : [];
|
|
108
|
-
const outputs = list(value.outputs).flatMap((o) => cleanOutput(o) ?? []);
|
|
109
|
-
const checks = list(value.checks).flatMap((c) => cleanCheck(c) ?? []);
|
|
110
|
-
return {
|
|
111
|
-
result: {
|
|
112
|
-
summary: summary.length > SUMMARY_MAX ? `${summary.slice(0, SUMMARY_MAX - 1)}\u2026` : summary,
|
|
113
|
-
outputs: outputs.slice(0, 10),
|
|
114
|
-
checks: checks.slice(0, 10),
|
|
115
|
-
...value.nothing_new === true ? { nothing_new: true } : {}
|
|
116
|
-
},
|
|
117
|
-
dropped: {
|
|
118
|
-
outputs: list(value.outputs).length - outputs.length,
|
|
119
|
-
checks: list(value.checks).length - checks.length
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
} catch {
|
|
123
|
-
return none;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function parseRunResult(message) {
|
|
127
|
-
return readRunResult(message).result;
|
|
128
|
-
}
|
|
129
|
-
function droppedLine(dropped, run2) {
|
|
130
|
-
return dropped.outputs || dropped.checks ? `result_items_dropped run=${run2} outputs=${dropped.outputs} checks=${dropped.checks}` : null;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// src/drivers/driver.ts
|
|
134
|
-
var RUNTIME_MODES = /* @__PURE__ */ new Set([
|
|
135
|
-
"approval-required",
|
|
136
|
-
"auto-accept-edits",
|
|
137
|
-
"auto",
|
|
138
|
-
"full-access"
|
|
139
|
-
]);
|
|
140
|
-
var BoxToolError = class extends Error {
|
|
141
|
-
constructor(code) {
|
|
142
|
-
super(code);
|
|
143
|
-
this.code = code;
|
|
144
|
-
this.name = "BoxToolError";
|
|
145
|
-
}
|
|
146
|
-
code;
|
|
147
|
-
};
|
|
148
|
-
var CLOOP_THREAD_PREFIX = "cloop:";
|
|
149
|
-
function questionLine(questions) {
|
|
150
|
-
return questions.map(
|
|
151
|
-
(x) => x.options?.length ? `${x.question} (${x.options.map((o) => o.label).join(", ")})` : x.question
|
|
152
|
-
).join(" ").slice(0, 500);
|
|
153
|
-
}
|
|
154
|
-
function isProgressSentence(value) {
|
|
155
|
-
return typeof value === "string" && /\S[ \t]+\S/.test(value.trim().split(/\r?\n/)[0] ?? "");
|
|
156
|
-
}
|
|
157
|
-
var PROGRESS_MS = 3e4;
|
|
158
|
-
var RUN_TEXT_MAX = 4e3;
|
|
159
|
-
function nextProgress(clock, text2, now, ms = PROGRESS_MS, force = false) {
|
|
160
|
-
const summary = (parseRunResult(text2)?.summary ?? text2.split("```cloop-result")[0] ?? "").replace(/\s+/g, " ").trim().slice(0, RUN_TEXT_MAX);
|
|
161
|
-
if (!isProgressSentence(summary)) return null;
|
|
162
|
-
if (!force && now - clock.lastProgressAt < ms) return null;
|
|
163
|
-
clock.lastProgressAt = now;
|
|
164
|
-
return summary;
|
|
165
|
-
}
|
|
166
|
-
var YES_WORDS = /* @__PURE__ */ new Set([
|
|
167
|
-
"y",
|
|
168
|
-
"yes",
|
|
169
|
-
"yep",
|
|
170
|
-
"yeah",
|
|
171
|
-
"allow",
|
|
172
|
-
"allow it",
|
|
173
|
-
"ok",
|
|
174
|
-
"okay",
|
|
175
|
-
"approve",
|
|
176
|
-
"approved",
|
|
177
|
-
"go ahead",
|
|
178
|
-
"sure",
|
|
179
|
-
"do it"
|
|
180
|
-
]);
|
|
181
|
-
function isYes(reply) {
|
|
182
|
-
return YES_WORDS.has(
|
|
183
|
-
reply.trim().toLowerCase().replace(/[.!\s]+$/, "")
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
var HARNESS_LIMIT = /usage limit|reached your [\w .-]{0,40}limit|hit your [\w .-]{0,40}limit|out of (usage )?credits/i;
|
|
187
|
-
function limitedModel(said) {
|
|
188
|
-
const name = /reached your ([\w .-]{1,40}?) limit/i.exec(said ?? "")?.[1];
|
|
189
|
-
return name && !/usage|weekly|daily|session|hour|month/i.test(name) ? name : null;
|
|
190
|
-
}
|
|
191
|
-
var LIMIT_HOLD_MS = 60 * 6e4;
|
|
192
|
-
function handoverPrompt(prompt, from) {
|
|
193
|
-
return `${prompt}
|
|
194
|
-
|
|
195
|
-
${from} started this work and stopped at its usage limit. Its changes, if any, are in this checkout. Read \`git status\` and \`git log\` first, and carry on from there.`;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
12
|
// src/environment.ts
|
|
199
13
|
import { homedir } from "os";
|
|
200
14
|
import { join } from "path";
|
|
@@ -517,6 +331,194 @@ function whichAll(bin) {
|
|
|
517
331
|
// src/drivers/t3.ts
|
|
518
332
|
import { execFile, execFileSync as execFileSync3 } from "child_process";
|
|
519
333
|
import { randomUUID } from "crypto";
|
|
334
|
+
|
|
335
|
+
// src/run-result.ts
|
|
336
|
+
var RESULT_INSTRUCTION = [
|
|
337
|
+
"When you finish, end your final message with a fenced block tagged cloop-result containing JSON, for example:",
|
|
338
|
+
"```cloop-result",
|
|
339
|
+
'{"summary": "One or two sentences on what you did.", "outputs": [{"kind": "pr", "title": "fix: the thing", "url": "https://github.com/org/repo/pull/1"}], "checks": [{"name": "Tests", "outcome": "passed"}]}',
|
|
340
|
+
"```",
|
|
341
|
+
"An output kind is one of: pr or link (title, url), draft (title, body, optional to, optional url), doc (title, optional url or body), file (title, path). A check outcome is passed, failed or skipped.",
|
|
342
|
+
"A draft's body is the message itself, as the recipient will read it; if you saved it somewhere (a Gmail draft), put that link in url, never in body. A doc's body is the whole page in GitHub Markdown: headings, lists, bold and tables all show; a table suits one row per item. Give every product, page or source you mention as a full https link.",
|
|
343
|
+
"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."
|
|
344
|
+
].join("\n");
|
|
345
|
+
var text = (v, max) => typeof v === "string" && v.length <= max;
|
|
346
|
+
var optionalText = (v, max) => v === void 0 || text(v, max);
|
|
347
|
+
var https = (v) => {
|
|
348
|
+
try {
|
|
349
|
+
return typeof v === "string" && new URL(v).protocol === "https:";
|
|
350
|
+
} catch {
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
var PR_URL = /https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/\d+/g;
|
|
355
|
+
var prNumber = (url) => Number(url.slice(url.lastIndexOf("/") + 1));
|
|
356
|
+
function prUrlIn(text2) {
|
|
357
|
+
const urls = text2?.match(PR_URL) ?? [];
|
|
358
|
+
return urls.reduce(
|
|
359
|
+
(newest, url) => newest && prNumber(newest) >= prNumber(url) ? newest : url,
|
|
360
|
+
null
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
function resultPrUrl(finalMessage) {
|
|
364
|
+
const result = parseRunResult(finalMessage);
|
|
365
|
+
if (!result) return prUrlIn(finalMessage);
|
|
366
|
+
const prs = result.outputs.flatMap((o) => o.kind === "pr" ? [o.url] : []);
|
|
367
|
+
return prs.at(-1) ?? null;
|
|
368
|
+
}
|
|
369
|
+
var SUMMARY_MAX = 4e3;
|
|
370
|
+
var DOC_BODY_MAX = 8e3;
|
|
371
|
+
function addressOutput(url) {
|
|
372
|
+
const pr = url.match(/\/pull\/(\d+)$/);
|
|
373
|
+
if (pr && prUrlIn(url) === url) return { kind: "pr", title: `Pull request #${pr[1]}`, url };
|
|
374
|
+
const { host, pathname } = new URL(url);
|
|
375
|
+
return { kind: "link", title: `${host}${pathname === "/" ? "" : pathname}`.slice(0, 120), url };
|
|
376
|
+
}
|
|
377
|
+
function cleanOutput(o) {
|
|
378
|
+
if (typeof o === "string") return https(o.trim()) ? addressOutput(o.trim()) : null;
|
|
379
|
+
if (!o || typeof o !== "object") return null;
|
|
380
|
+
const out = o;
|
|
381
|
+
if (!text(out.title, 120)) return null;
|
|
382
|
+
const title = out.title;
|
|
383
|
+
switch (out.kind) {
|
|
384
|
+
case "pr":
|
|
385
|
+
case "link":
|
|
386
|
+
return https(out.url) ? { kind: out.kind, title, url: out.url } : null;
|
|
387
|
+
case "draft":
|
|
388
|
+
return text(out.body, 4e3) && optionalText(out.to, 200) && (out.url === void 0 || https(out.url)) ? {
|
|
389
|
+
kind: "draft",
|
|
390
|
+
title,
|
|
391
|
+
body: out.body,
|
|
392
|
+
...out.to !== void 0 ? { to: out.to } : {},
|
|
393
|
+
...out.url !== void 0 ? { url: out.url } : {}
|
|
394
|
+
} : null;
|
|
395
|
+
case "doc": {
|
|
396
|
+
const body = typeof out.body === "string" && out.body.length > DOC_BODY_MAX ? `${out.body.slice(0, DOC_BODY_MAX - 1)}\u2026` : out.body;
|
|
397
|
+
return optionalText(body, DOC_BODY_MAX) && (out.url === void 0 || https(out.url)) ? {
|
|
398
|
+
kind: "doc",
|
|
399
|
+
title,
|
|
400
|
+
...out.url !== void 0 ? { url: out.url } : {},
|
|
401
|
+
...body !== void 0 ? { body } : {}
|
|
402
|
+
} : null;
|
|
403
|
+
}
|
|
404
|
+
case "file":
|
|
405
|
+
return text(out.path, 400) ? { kind: "file", title, path: out.path } : null;
|
|
406
|
+
default:
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
function cleanCheck(c) {
|
|
411
|
+
if (!c || typeof c !== "object") return null;
|
|
412
|
+
const check = c;
|
|
413
|
+
if (!text(check.name, 80) || !["passed", "failed", "skipped"].includes(check.outcome))
|
|
414
|
+
return null;
|
|
415
|
+
if (!optionalText(check.detail, 200)) return null;
|
|
416
|
+
return {
|
|
417
|
+
name: check.name,
|
|
418
|
+
outcome: check.outcome,
|
|
419
|
+
...check.detail !== void 0 ? { detail: check.detail } : {}
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
function readRunResult(message) {
|
|
423
|
+
const none = { dropped: { outputs: 0, checks: 0 } };
|
|
424
|
+
const block = [...(message ?? "").matchAll(/```cloop-result\s*\n([\s\S]*?)```/g)].at(-1)?.[1];
|
|
425
|
+
if (!block) return none;
|
|
426
|
+
try {
|
|
427
|
+
const value = JSON.parse(block);
|
|
428
|
+
const summary = typeof value?.summary === "string" ? value.summary.trim() : "";
|
|
429
|
+
if (!summary) return none;
|
|
430
|
+
const list = (v) => Array.isArray(v) ? v : [];
|
|
431
|
+
const outputs = list(value.outputs).flatMap((o) => cleanOutput(o) ?? []);
|
|
432
|
+
const checks = list(value.checks).flatMap((c) => cleanCheck(c) ?? []);
|
|
433
|
+
return {
|
|
434
|
+
result: {
|
|
435
|
+
summary: summary.length > SUMMARY_MAX ? `${summary.slice(0, SUMMARY_MAX - 1)}\u2026` : summary,
|
|
436
|
+
outputs: outputs.slice(0, 10),
|
|
437
|
+
checks: checks.slice(0, 10),
|
|
438
|
+
...value.nothing_new === true ? { nothing_new: true } : {}
|
|
439
|
+
},
|
|
440
|
+
dropped: {
|
|
441
|
+
outputs: list(value.outputs).length - outputs.length,
|
|
442
|
+
checks: list(value.checks).length - checks.length
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
} catch {
|
|
446
|
+
return none;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
function parseRunResult(message) {
|
|
450
|
+
return readRunResult(message).result;
|
|
451
|
+
}
|
|
452
|
+
function droppedLine(dropped, run2) {
|
|
453
|
+
return dropped.outputs || dropped.checks ? `result_items_dropped run=${run2} outputs=${dropped.outputs} checks=${dropped.checks}` : null;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// src/drivers/driver.ts
|
|
457
|
+
var RUNTIME_MODES = /* @__PURE__ */ new Set([
|
|
458
|
+
"approval-required",
|
|
459
|
+
"auto-accept-edits",
|
|
460
|
+
"auto",
|
|
461
|
+
"full-access"
|
|
462
|
+
]);
|
|
463
|
+
var BoxToolError = class extends Error {
|
|
464
|
+
constructor(code) {
|
|
465
|
+
super(code);
|
|
466
|
+
this.code = code;
|
|
467
|
+
this.name = "BoxToolError";
|
|
468
|
+
}
|
|
469
|
+
code;
|
|
470
|
+
};
|
|
471
|
+
var CLOOP_THREAD_PREFIX = "cloop:";
|
|
472
|
+
function questionLine(questions) {
|
|
473
|
+
return questions.map(
|
|
474
|
+
(x) => x.options?.length ? `${x.question} (${x.options.map((o) => o.label).join(", ")})` : x.question
|
|
475
|
+
).join(" ").slice(0, 500);
|
|
476
|
+
}
|
|
477
|
+
function isProgressSentence(value) {
|
|
478
|
+
return typeof value === "string" && /\S[ \t]+\S/.test(value.trim().split(/\r?\n/)[0] ?? "");
|
|
479
|
+
}
|
|
480
|
+
var PROGRESS_MS = 3e4;
|
|
481
|
+
var RUN_TEXT_MAX = 4e3;
|
|
482
|
+
function nextProgress(clock, text2, now, ms = PROGRESS_MS, force = false) {
|
|
483
|
+
const summary = (parseRunResult(text2)?.summary ?? text2.split("```cloop-result")[0] ?? "").replace(/\s+/g, " ").trim().slice(0, RUN_TEXT_MAX);
|
|
484
|
+
if (!isProgressSentence(summary)) return null;
|
|
485
|
+
if (!force && now - clock.lastProgressAt < ms) return null;
|
|
486
|
+
clock.lastProgressAt = now;
|
|
487
|
+
return summary;
|
|
488
|
+
}
|
|
489
|
+
var YES_WORDS = /* @__PURE__ */ new Set([
|
|
490
|
+
"y",
|
|
491
|
+
"yes",
|
|
492
|
+
"yep",
|
|
493
|
+
"yeah",
|
|
494
|
+
"allow",
|
|
495
|
+
"allow it",
|
|
496
|
+
"ok",
|
|
497
|
+
"okay",
|
|
498
|
+
"approve",
|
|
499
|
+
"approved",
|
|
500
|
+
"go ahead",
|
|
501
|
+
"sure",
|
|
502
|
+
"do it"
|
|
503
|
+
]);
|
|
504
|
+
function isYes(reply) {
|
|
505
|
+
return YES_WORDS.has(
|
|
506
|
+
reply.trim().toLowerCase().replace(/[.!\s]+$/, "")
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
var HARNESS_LIMIT = /usage limit|reached your [\w .-]{0,40}limit|hit your [\w .-]{0,40}limit|out of (usage )?credits/i;
|
|
510
|
+
function limitedModel(said) {
|
|
511
|
+
const name = /reached your ([\w .-]{1,40}?) limit/i.exec(said ?? "")?.[1];
|
|
512
|
+
return name && !/usage|weekly|daily|session|hour|month/i.test(name) ? name : null;
|
|
513
|
+
}
|
|
514
|
+
var LIMIT_HOLD_MS = 60 * 6e4;
|
|
515
|
+
function handoverPrompt(prompt, from) {
|
|
516
|
+
return `${prompt}
|
|
517
|
+
|
|
518
|
+
${from} started this work and stopped at its usage limit. Its changes, if any, are in this checkout. Read \`git status\` and \`git log\` first, and carry on from there.`;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// src/drivers/t3.ts
|
|
520
522
|
function isUnsettled(t) {
|
|
521
523
|
return !t.settledAt && !t.archivedAt && !isChild(t);
|
|
522
524
|
}
|