@cloop/runner 0.3.36 → 0.3.37

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.
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  serveTakeovers
4
- } from "./chunk-NC2CYUVJ.js";
5
- import "./chunk-XVJP7XW3.js";
4
+ } from "./chunk-QBSVTFL7.js";
5
+ import "./chunk-RXGUYYDP.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-OJH72SCM.js";
41
+ } from "./chunk-G35UCZVP.js";
42
42
  import {
43
43
  MeshSocket,
44
44
  WAKE_TICK_MS,
@@ -55,7 +55,7 @@ import {
55
55
  runnerStatePath,
56
56
  threadsFilePath,
57
57
  writeRunnerState
58
- } from "./chunk-NKUPQAVX.js";
58
+ } from "./chunk-3KTZTHQM.js";
59
59
  import {
60
60
  BackgroundReading,
61
61
  BoxToolError,
@@ -100,20 +100,20 @@ import {
100
100
  utcWindow,
101
101
  windowsPowerShellEnv,
102
102
  writeBoxConfig
103
- } from "./chunk-6SRF3XGA.js";
103
+ } from "./chunk-LYHS7CSA.js";
104
104
  import "./chunk-VK6GV757.js";
105
105
  import {
106
106
  olderThan
107
107
  } from "./chunk-365HFCQQ.js";
108
108
  import "./chunk-PKIEWBR7.js";
109
- import "./chunk-C5WAMQVJ.js";
110
- import "./chunk-LFLFQOPL.js";
109
+ import "./chunk-SEVJGIDJ.js";
110
+ import "./chunk-WC72IBTN.js";
111
111
  import {
112
112
  getMachine
113
113
  } from "./chunk-SBYSVZ7J.js";
114
114
  import {
115
115
  VERSION
116
- } from "./chunk-WZHNYHUT.js";
116
+ } from "./chunk-LYHUSZRK.js";
117
117
  import {
118
118
  getMeshUrl,
119
119
  getOrigin,
@@ -3,7 +3,7 @@ import {
3
3
  RUN_TEXT_MAX,
4
4
  boxPath,
5
5
  runnerPath
6
- } from "./chunk-6SRF3XGA.js";
6
+ } from "./chunk-LYHS7CSA.js";
7
7
 
8
8
  // src/box-watch.ts
9
9
  import { randomUUID } from "crypto";
@@ -9,7 +9,7 @@ import {
9
9
  readRunnerState,
10
10
  runnerStatePath,
11
11
  threadsFilePath
12
- } from "./chunk-NKUPQAVX.js";
12
+ } from "./chunk-3KTZTHQM.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-6SRF3XGA.js";
51
+ } from "./chunk-LYHS7CSA.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-C5WAMQVJ.js";
65
+ } from "./chunk-SEVJGIDJ.js";
66
66
  import {
67
67
  ConnectFailure,
68
68
  connectReport,
69
69
  deviceLogin,
70
70
  newAttempt,
71
71
  sendConnectReport
72
- } from "./chunk-LFLFQOPL.js";
72
+ } from "./chunk-WC72IBTN.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-WZHNYHUT.js";
80
+ } from "./chunk-LYHUSZRK.js";
81
81
  import {
82
82
  STAGING_ORIGIN,
83
83
  getOrigin,
@@ -117,147 +117,25 @@ function writeBoxConfig(cfg) {
117
117
  renameSync(temp, path);
118
118
  }
119
119
 
120
- // src/run-log.ts
121
- import {
122
- appendFileSync,
123
- chmodSync as chmodSync2,
124
- mkdirSync as mkdirSync2,
125
- readdirSync,
126
- renameSync as renameSync2,
127
- statSync,
128
- unlinkSync
129
- } from "fs";
130
- import { dirname as dirname2, join as join3 } from "path";
131
- var RUN_LOG_LINE_MAX = 500;
132
- var RUN_LOG_MAX_BYTES = 5 * 1024 * 1024;
133
- var RUN_LOG_KEEP_MS = 14 * 24 * 36e5;
134
- var SAFE_ID = /^[\w-]{1,100}$/;
135
- function runLogDir(runsFile) {
136
- return join3(dirname2(runsFile), "runs");
137
- }
138
- function runLogPath(dir, workId) {
139
- return SAFE_ID.test(workId) ? join3(dir, `${workId}.log`) : null;
140
- }
141
- var SECRETS = [
142
- // The whole block, to its END line or the end of the text: a cut-off paste still hides its body.
143
- [/-----BEGIN ([A-Z0-9 ]+)-----[\s\S]*?(?:-----END \1-----|$)/g, "[redacted key block]"],
144
- [/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]{8,}/gi, "$1 [redacted]"],
145
- [/(:\/\/)[^\s/@:]+:[^\s/@]+@/g, "$1[redacted]@"],
146
- [
147
- /([?&](?:access_token|token|key|api_key|apikey|secret|sig|signature|code|password)=)[^&\s"']+/gi,
148
- "$1[redacted]"
149
- ],
150
- [
151
- /(\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,
152
- "$1[redacted]"
153
- ],
154
- [
155
- /(--?[\w-]*(?:token|secret|password|api-key|apikey)[\w-]*[ =])["']?[^\s"']{4,}["']?/gi,
156
- "$1[redacted]"
157
- ],
158
- [/\b(?:sk|pk|rk)[-_][A-Za-z0-9_-]{16,}/g, "[redacted]"],
159
- [/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})/g, "[redacted]"],
160
- [/\bxox[abprs]-[A-Za-z0-9-]{10,}/g, "[redacted]"],
161
- [/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g, "[redacted]"],
162
- [/\bAIza[0-9A-Za-z_-]{30,}/g, "[redacted]"],
163
- [/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{4,}/g, "[redacted]"]
164
- ];
165
- var OPAQUE = /[A-Za-z0-9_+=-]{32,}/g;
166
- function redactSecrets(text3) {
167
- let out = text3;
168
- for (const [pattern, replacement] of SECRETS) out = out.replace(pattern, replacement);
169
- return out.replace(
170
- OPAQUE,
171
- (run2) => /^[0-9a-f-]+$/i.test(run2) || !/\d/.test(run2) || !/[A-Za-z]/.test(run2) ? run2 : "[redacted]"
172
- );
173
- }
174
- function logText(text3) {
175
- const flat = redactSecrets(stripControl(text3).replace(/\s+/g, " ").trim());
176
- return flat.length > RUN_LOG_LINE_MAX ? `${flat.slice(0, RUN_LOG_LINE_MAX - 1)}\u2026` : flat;
177
- }
178
- function logLineFor(item) {
179
- switch (item.type) {
180
- case "text":
181
- return item.text;
182
- case "tool": {
183
- const input = item.detail ?? item.summary ?? item.target;
184
- return `> ${item.name}${input ? `: ${input}` : ""}`;
185
- }
186
- case "ask":
187
- return `? ${item.summary}`;
188
- case "session":
189
- return item.notReady ? `! Not connected at start: ${item.notReady.join(", ")}` : null;
190
- case "result":
191
- return item.ok ? `= Result: ${item.text ?? "done"}` : `= Error: ${item.text ?? "no text"}`;
192
- default:
193
- return null;
194
- }
195
- }
196
- function appendRunLog(dir, workId, text3, { now = Date.now(), maxBytes = RUN_LOG_MAX_BYTES } = {}) {
197
- const path = runLogPath(dir, workId);
198
- if (!path) return;
199
- const line = `${stamp(now)} ${logText(text3)}
200
- `;
201
- mkdirSync2(dir, { recursive: true, mode: 448 });
202
- const size = sizeOf(path);
203
- if (size > 0 && size + Buffer.byteLength(line) > maxBytes) renameSync2(path, `${path}.1`);
204
- appendFileSync(path, line, { mode: 384 });
205
- }
206
- function pruneRunLogs(dir, now = Date.now(), keepMs = RUN_LOG_KEEP_MS) {
207
- mkdirSync2(dir, { recursive: true, mode: 448 });
208
- chmodSync2(dir, 448);
209
- let removed = 0;
210
- for (const name of readdirSync(dir)) {
211
- if (!/\.log(\.1)?$/.test(name)) continue;
212
- const path = join3(dir, name);
213
- try {
214
- if (statSync(path).mtimeMs < now - keepMs) {
215
- unlinkSync(path);
216
- removed++;
217
- }
218
- } catch {
219
- }
220
- }
221
- return removed;
222
- }
223
- function sizeOf(path) {
224
- try {
225
- return statSync(path).size;
226
- } catch {
227
- return 0;
228
- }
229
- }
230
- var STOPPED_SUMMARY = "The run was stopped.";
231
- function endNote(end) {
232
- return `= ${end.kind === "settled" ? "Done" : "Ended"}: ${end.summary ?? end.kind}`;
233
- }
234
- function isEndLogLine(line) {
235
- return /^\S+ = (Done|Ended): /.test(line);
236
- }
237
- function stamp(now) {
238
- const d = new Date(now);
239
- return [d.getHours(), d.getMinutes(), d.getSeconds()].map((n) => String(n).padStart(2, "0")).join(":");
240
- }
241
-
242
120
  // src/outside-sessions.ts
243
121
  import { createReadStream } from "fs";
244
122
  import { readFile, readdir, stat } from "fs/promises";
245
123
  import { homedir as homedir2 } from "os";
246
- import { dirname as dirname3, join as join4 } from "path";
124
+ import { dirname as dirname2, join as join3 } from "path";
247
125
  import { createInterface } from "readline";
248
126
  var seen = /* @__PURE__ */ new Map();
249
127
  var UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
250
- async function listOutsideSessions(root = join4(homedir2(), ".claude", "projects"), own = /* @__PURE__ */ new Set(), now = Date.now()) {
128
+ async function listOutsideSessions(root = join3(homedir2(), ".claude", "projects"), own = /* @__PURE__ */ new Set(), now = Date.now()) {
251
129
  const files = [];
252
130
  for (const project of await readdir(root, { withFileTypes: true }).catch(() => [])) {
253
131
  if (!project.isDirectory()) continue;
254
- for (const entry of await readdir(join4(root, project.name), { withFileTypes: true }).catch(
132
+ for (const entry of await readdir(join3(root, project.name), { withFileTypes: true }).catch(
255
133
  () => []
256
134
  )) {
257
135
  if (!entry.isFile() || !entry.name.endsWith(".jsonl")) continue;
258
136
  const id = entry.name.slice(0, -6);
259
137
  if (!UUID.test(id) || own.has(id)) continue;
260
- const path = join4(root, project.name, entry.name);
138
+ const path = join3(root, project.name, entry.name);
261
139
  const info = await stat(path).catch(() => null);
262
140
  if (info && info.mtimeMs >= now - 7 * 864e5)
263
141
  files.push({ id, project: project.name.slice(0, 200), file: path, mtime: info.mtimeMs });
@@ -313,14 +191,14 @@ async function claudeMeta(file, mtime) {
313
191
  return meta;
314
192
  }
315
193
  function sessionRoots(home = homedir2()) {
316
- return { claude: join4(home, ".claude", "projects"), codex: join4(home, ".codex", "sessions") };
194
+ return { claude: join3(home, ".claude", "projects"), codex: join3(home, ".codex", "sessions") };
317
195
  }
318
196
  async function findSession(id, roots, harnesses) {
319
197
  if (!UUID.test(id)) return null;
320
198
  if (harnesses.includes("claude-code")) {
321
199
  for (const project of await readdir(roots.claude, { withFileTypes: true }).catch(() => [])) {
322
200
  if (!project.isDirectory()) continue;
323
- const file = join4(roots.claude, project.name, `${id}.jsonl`);
201
+ const file = join3(roots.claude, project.name, `${id}.jsonl`);
324
202
  const info = await stat(file).catch(() => null);
325
203
  if (!info?.isFile()) continue;
326
204
  const meta = await claudeMeta(file, info.mtimeMs);
@@ -374,13 +252,13 @@ async function codexFiles(root, since = 0) {
374
252
  const out = [];
375
253
  const names = async (dir) => (await readdir(dir, { withFileTypes: true }).catch(() => [])).filter((d) => d.isDirectory() && /^\d+$/.test(d.name)).map((d) => d.name).sort().reverse();
376
254
  for (const year of await names(root))
377
- for (const month of await names(join4(root, year)))
378
- for (const day of await names(join4(root, year, month))) {
379
- const dir = join4(root, year, month, day);
255
+ for (const month of await names(join3(root, year)))
256
+ for (const day of await names(join3(root, year, month))) {
257
+ const dir = join3(root, year, month, day);
380
258
  for (const entry of await readdir(dir, { withFileTypes: true }).catch(() => [])) {
381
259
  const id = entry.isFile() ? ROLLOUT.exec(entry.name)?.[1] : void 0;
382
260
  if (!id) continue;
383
- const file = join4(dir, entry.name);
261
+ const file = join3(dir, entry.name);
384
262
  const info = await stat(file).catch(() => null);
385
263
  if (info && info.mtimeMs >= since) out.push({ id, file, mtime: info.mtimeMs });
386
264
  }
@@ -420,7 +298,7 @@ async function codexMeta(file, mtime) {
420
298
  }
421
299
  async function codexTitles(root) {
422
300
  const titles = /* @__PURE__ */ new Map();
423
- const text3 = await readFile(join4(dirname3(root), "session_index.jsonl"), "utf8").catch(() => "");
301
+ const text3 = await readFile(join3(dirname2(root), "session_index.jsonl"), "utf8").catch(() => "");
424
302
  for (const line of text3.split("\n")) {
425
303
  try {
426
304
  const record = JSON.parse(line);
@@ -432,6 +310,128 @@ async function codexTitles(root) {
432
310
  return titles;
433
311
  }
434
312
 
313
+ // src/run-log.ts
314
+ import {
315
+ appendFileSync,
316
+ chmodSync as chmodSync2,
317
+ mkdirSync as mkdirSync2,
318
+ readdirSync,
319
+ renameSync as renameSync2,
320
+ statSync,
321
+ unlinkSync
322
+ } from "fs";
323
+ import { dirname as dirname3, join as join4 } from "path";
324
+ var RUN_LOG_LINE_MAX = 500;
325
+ var RUN_LOG_MAX_BYTES = 5 * 1024 * 1024;
326
+ var RUN_LOG_KEEP_MS = 14 * 24 * 36e5;
327
+ var SAFE_ID = /^[\w-]{1,100}$/;
328
+ function runLogDir(runsFile) {
329
+ return join4(dirname3(runsFile), "runs");
330
+ }
331
+ function runLogPath(dir, workId) {
332
+ return SAFE_ID.test(workId) ? join4(dir, `${workId}.log`) : null;
333
+ }
334
+ var SECRETS = [
335
+ // The whole block, to its END line or the end of the text: a cut-off paste still hides its body.
336
+ [/-----BEGIN ([A-Z0-9 ]+)-----[\s\S]*?(?:-----END \1-----|$)/g, "[redacted key block]"],
337
+ [/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]{8,}/gi, "$1 [redacted]"],
338
+ [/(:\/\/)[^\s/@:]+:[^\s/@]+@/g, "$1[redacted]@"],
339
+ [
340
+ /([?&](?:access_token|token|key|api_key|apikey|secret|sig|signature|code|password)=)[^&\s"']+/gi,
341
+ "$1[redacted]"
342
+ ],
343
+ [
344
+ /(\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,
345
+ "$1[redacted]"
346
+ ],
347
+ [
348
+ /(--?[\w-]*(?:token|secret|password|api-key|apikey)[\w-]*[ =])["']?[^\s"']{4,}["']?/gi,
349
+ "$1[redacted]"
350
+ ],
351
+ [/\b(?:sk|pk|rk)[-_][A-Za-z0-9_-]{16,}/g, "[redacted]"],
352
+ [/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})/g, "[redacted]"],
353
+ [/\bxox[abprs]-[A-Za-z0-9-]{10,}/g, "[redacted]"],
354
+ [/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g, "[redacted]"],
355
+ [/\bAIza[0-9A-Za-z_-]{30,}/g, "[redacted]"],
356
+ [/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{4,}/g, "[redacted]"]
357
+ ];
358
+ var OPAQUE = /[A-Za-z0-9_+=-]{32,}/g;
359
+ function redactSecrets(text3) {
360
+ let out = text3;
361
+ for (const [pattern, replacement] of SECRETS) out = out.replace(pattern, replacement);
362
+ return out.replace(
363
+ OPAQUE,
364
+ (run2) => /^[0-9a-f-]+$/i.test(run2) || !/\d/.test(run2) || !/[A-Za-z]/.test(run2) ? run2 : "[redacted]"
365
+ );
366
+ }
367
+ function logText(text3) {
368
+ const flat = redactSecrets(stripControl(text3).replace(/\s+/g, " ").trim());
369
+ return flat.length > RUN_LOG_LINE_MAX ? `${flat.slice(0, RUN_LOG_LINE_MAX - 1)}\u2026` : flat;
370
+ }
371
+ function logLineFor(item) {
372
+ switch (item.type) {
373
+ case "text":
374
+ return item.text;
375
+ case "tool": {
376
+ const input = item.detail ?? item.summary ?? item.target;
377
+ return `> ${item.name}${input ? `: ${input}` : ""}`;
378
+ }
379
+ case "ask":
380
+ return `? ${item.summary}`;
381
+ case "session":
382
+ return item.notReady ? `! Not connected at start: ${item.notReady.join(", ")}` : null;
383
+ case "result":
384
+ return item.ok ? `= Result: ${item.text ?? "done"}` : `= Error: ${item.text ?? "no text"}`;
385
+ default:
386
+ return null;
387
+ }
388
+ }
389
+ function appendRunLog(dir, workId, text3, { now = Date.now(), maxBytes = RUN_LOG_MAX_BYTES } = {}) {
390
+ const path = runLogPath(dir, workId);
391
+ if (!path) return;
392
+ const line = `${stamp(now)} ${logText(text3)}
393
+ `;
394
+ mkdirSync2(dir, { recursive: true, mode: 448 });
395
+ const size = sizeOf(path);
396
+ if (size > 0 && size + Buffer.byteLength(line) > maxBytes) renameSync2(path, `${path}.1`);
397
+ appendFileSync(path, line, { mode: 384 });
398
+ }
399
+ function pruneRunLogs(dir, now = Date.now(), keepMs = RUN_LOG_KEEP_MS) {
400
+ mkdirSync2(dir, { recursive: true, mode: 448 });
401
+ chmodSync2(dir, 448);
402
+ let removed = 0;
403
+ for (const name of readdirSync(dir)) {
404
+ if (!/\.log(\.1)?$/.test(name)) continue;
405
+ const path = join4(dir, name);
406
+ try {
407
+ if (statSync(path).mtimeMs < now - keepMs) {
408
+ unlinkSync(path);
409
+ removed++;
410
+ }
411
+ } catch {
412
+ }
413
+ }
414
+ return removed;
415
+ }
416
+ function sizeOf(path) {
417
+ try {
418
+ return statSync(path).size;
419
+ } catch {
420
+ return 0;
421
+ }
422
+ }
423
+ var STOPPED_SUMMARY = "The run was stopped.";
424
+ function endNote(end) {
425
+ return `= ${end.kind === "settled" ? "Done" : "Ended"}: ${end.summary ?? end.kind}`;
426
+ }
427
+ function isEndLogLine(line) {
428
+ return /^\S+ = (Done|Ended): /.test(line);
429
+ }
430
+ function stamp(now) {
431
+ const d = new Date(now);
432
+ return [d.getHours(), d.getMinutes(), d.getSeconds()].map((n) => String(n).padStart(2, "0")).join(":");
433
+ }
434
+
435
435
  // src/spawn-command.ts
436
436
  import { execFileSync } from "child_process";
437
437
  function commandFor(bin, args, platform = process.platform, comspec = process.env.ComSpec) {
@@ -768,6 +768,23 @@ import { randomUUID } from "crypto";
768
768
  import { existsSync as existsSync2 } from "fs";
769
769
  import { join as join7 } from "path";
770
770
 
771
+ // ../clo0p-app/contracts/work-spec.ts
772
+ var IMAGE_TYPES = {
773
+ "image/jpeg": "jpg",
774
+ "image/png": "png",
775
+ "image/webp": "webp",
776
+ "image/gif": "gif"
777
+ };
778
+ function isImageType(type) {
779
+ return Object.hasOwn(IMAGE_TYPES, type);
780
+ }
781
+ var IMAGE_MAX_BYTES = 10 * 1024 * 1024;
782
+ var ATTACHMENTS_MAX = 8;
783
+ function repoName(repository) {
784
+ const name = repository?.trim().toLowerCase().split("/").filter(Boolean).at(-1);
785
+ return name || null;
786
+ }
787
+
771
788
  // ../clo0p-app/contracts/run-result.ts
772
789
  var WIZARD_STEPS_MAX = 6;
773
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";
@@ -910,23 +927,6 @@ function droppedLine(dropped, run2) {
910
927
  return dropped.outputs || dropped.checks ? `result_items_dropped run=${run2} outputs=${dropped.outputs} checks=${dropped.checks}` : null;
911
928
  }
912
929
 
913
- // ../clo0p-app/contracts/work-spec.ts
914
- var IMAGE_TYPES = {
915
- "image/jpeg": "jpg",
916
- "image/png": "png",
917
- "image/webp": "webp",
918
- "image/gif": "gif"
919
- };
920
- function isImageType(type) {
921
- return Object.hasOwn(IMAGE_TYPES, type);
922
- }
923
- var IMAGE_MAX_BYTES = 10 * 1024 * 1024;
924
- var ATTACHMENTS_MAX = 8;
925
- function repoName(repository) {
926
- const name = repository?.trim().toLowerCase().split("/").filter(Boolean).at(-1);
927
- return name || null;
928
- }
929
-
930
930
  // src/drivers/attachments.ts
931
931
  import { mkdir, writeFile } from "fs/promises";
932
932
  import { join as join6 } from "path";
@@ -1017,6 +1017,9 @@ var RUNTIME_MODES = /* @__PURE__ */ new Set([
1017
1017
  "auto",
1018
1018
  "full-access"
1019
1019
  ]);
1020
+ function cloneLine(repository) {
1021
+ return `This Task names the repository ${repository}, and this machine has no project for it. Clone it outside this folder, or find it on this machine, and work in it.`;
1022
+ }
1020
1023
  var BoxToolError = class extends Error {
1021
1024
  constructor(code) {
1022
1025
  super(code);
@@ -1559,18 +1562,15 @@ function projectNames(p) {
1559
1562
  function isRepository(p) {
1560
1563
  return Boolean(p.repositoryIdentity) || existsSync2(join7(p.workspaceRoot, ".git"));
1561
1564
  }
1565
+ function holdsRepository(p, repository) {
1566
+ return projectNames(p).some((name) => repoName(name) === repoName(repository));
1567
+ }
1562
1568
  function pickProject(projects, repository) {
1563
- if (!repository) {
1564
- const repos = projects.filter(isRepository);
1565
- const pool = repos.length > 0 ? repos : projects;
1566
- const only = pool.length === 1 ? pool[0] : void 0;
1567
- if (only) return only;
1568
- throw new BoxToolError("no_project");
1569
- }
1570
- const want = repoName(repository);
1571
- const found = projects.find((p) => projectNames(p).some((name) => repoName(name) === want));
1572
- if (!found) throw new BoxToolError("no_project");
1573
- return found;
1569
+ const named = repository ? projects.find((p) => holdsRepository(p, repository)) : void 0;
1570
+ const repos = projects.filter(isRepository);
1571
+ const picked = named ?? (repos.length > 0 ? repos : projects)[0];
1572
+ if (!picked) throw new BoxToolError("no_project");
1573
+ return picked;
1574
1574
  }
1575
1575
  var SHELL_HEADERS = { "x-t3-orchestration-protocol": "2" };
1576
1576
  function boxCapabilities(scope) {
@@ -1821,6 +1821,11 @@ var T3Driver = class {
1821
1821
  ]);
1822
1822
  this.providers = cfg.providers;
1823
1823
  const project = pickProject(shell.projects ?? [], a.repository);
1824
+ const missing = a.repository && !holdsRepository(project, a.repository) ? a.repository : null;
1825
+ if (missing)
1826
+ this.log(
1827
+ `launch work=${a.work_id} has no ${missing}; starts in ${project.title} to clone it`
1828
+ );
1824
1829
  const runtimeMode = a.runtime_mode ?? cfg.settings?.defaultRuntimeMode;
1825
1830
  if (!runtimeMode || !RUNTIME_MODES.has(runtimeMode))
1826
1831
  throw new BoxToolError("runtime_mode_unknown");
@@ -1861,7 +1866,7 @@ var T3Driver = class {
1861
1866
  ...photos2.attachments.length ? { threadId: a.work_id } : {},
1862
1867
  initialMessage: {
1863
1868
  ...photos2.attachments.length ? { messageId: a.work_id } : {},
1864
- text: [a.prompt, photos2.line, RESULT_INSTRUCTION].filter(Boolean).join("\n\n"),
1869
+ text: [a.prompt, missing && cloneLine(missing), photos2.line, RESULT_INSTRUCTION].filter(Boolean).join("\n\n"),
1865
1870
  attachments: photos2.attachments
1866
1871
  }
1867
1872
  }
@@ -2541,17 +2546,14 @@ function failedEnd(harness, run2) {
2541
2546
  function localRunsFilePath(env) {
2542
2547
  return runnerPath(env, process.env.CLOOP_LOCAL_RUNS_FILE, (dir) => join8(dir, "local-runs.json"));
2543
2548
  }
2544
- function pickRepo(repos, repository) {
2545
- if (!repository) {
2546
- if (repos.length === 1 && repos[0]) return repos[0];
2547
- throw new BoxToolError("no_project");
2548
- }
2549
+ function holdsRepository2(r, repository) {
2549
2550
  const want = repoName(repository);
2550
- const found = repos.find(
2551
- (r) => repoName(r.label) === want || repoName(basename(r.path)) === want
2552
- );
2553
- if (!found) throw new BoxToolError("no_project");
2554
- return found;
2551
+ return repoName(r.label) === want || repoName(basename(r.path)) === want;
2552
+ }
2553
+ function pickRepo(repos, repository) {
2554
+ const picked = repository && repos.find((r) => holdsRepository2(r, repository)) || repos[0];
2555
+ if (!picked) throw new BoxToolError("no_project");
2556
+ return picked;
2555
2557
  }
2556
2558
  function run(cmd, args, cwd) {
2557
2559
  return new Promise(
@@ -2817,7 +2819,12 @@ var LocalDriver = class {
2817
2819
  if (a.harness && !own.aliases.includes(a.harness))
2818
2820
  throw new BoxToolError("harness_unavailable");
2819
2821
  const repo = pickRepo(this.deps.repos, a.repository);
2820
- this.refuseBusy(repo.path);
2822
+ const missing = a.repository && !holdsRepository2(repo, a.repository) ? a.repository : null;
2823
+ if (missing)
2824
+ this.log(
2825
+ `launch work=${a.work_id} has no ${missing}; starts in ${basename(repo.path)} to clone it`
2826
+ );
2827
+ else this.refuseBusy(repo.path);
2821
2828
  const { dialect, moved } = await this.route(a);
2822
2829
  const head = await this.repo.head(repo.path);
2823
2830
  const photos2 = await this.photos(a);
@@ -2830,15 +2837,13 @@ var LocalDriver = class {
2830
2837
  takeover: true,
2831
2838
  harness: this.dialectOf(concurrent).name
2832
2839
  };
2833
- this.refuseBusy(repo.path);
2840
+ if (!missing) this.refuseBusy(repo.path);
2834
2841
  const record = {
2835
2842
  work_id: a.work_id,
2836
2843
  session_id: dialect.name === "claude-code" ? a.work_id : null,
2837
2844
  repo: repo.path,
2838
2845
  title: a.title,
2839
- prompt: photos2.line ? `${a.prompt}
2840
-
2841
- ${photos2.line}` : a.prompt,
2846
+ prompt: [a.prompt, missing && cloneLine(missing), photos2.line].filter(Boolean).join("\n\n"),
2842
2847
  ...photos2.paths.length ? { images: photos2.paths } : {},
2843
2848
  ...a.model && !moved ? { model: a.model } : {},
2844
2849
  ...a.runtime_mode ? { runtime_mode: a.runtime_mode } : {},
@@ -3428,12 +3433,12 @@ export {
3428
3433
  readRunnerConfig,
3429
3434
  writeBoxConfig,
3430
3435
  IMAGE_TYPES,
3436
+ listOutsideSessions,
3431
3437
  runLogDir,
3432
3438
  runLogPath,
3433
3439
  redactSecrets,
3434
3440
  STOPPED_SUMMARY,
3435
3441
  isEndLogLine,
3436
- listOutsideSessions,
3437
3442
  commandFor,
3438
3443
  quoteWindowsArg,
3439
3444
  windowsExecutable,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/version.ts
4
- var VERSION = true ? "0.3.36" : "0.0.0-dev";
4
+ var VERSION = true ? "0.3.37" : "0.0.0-dev";
5
5
 
6
6
  export {
7
7
  VERSION
@@ -2,17 +2,17 @@
2
2
  import {
3
3
  findRun,
4
4
  ownHarness
5
- } from "./chunk-XVJP7XW3.js";
5
+ } from "./chunk-RXGUYYDP.js";
6
6
  import {
7
7
  lockThreadsFile,
8
8
  threadsFilePath
9
- } from "./chunk-NKUPQAVX.js";
9
+ } from "./chunk-3KTZTHQM.js";
10
10
  import {
11
11
  localRunsFilePath,
12
12
  readRunRecords,
13
13
  runHarness,
14
14
  takeoverSummary
15
- } from "./chunk-6SRF3XGA.js";
15
+ } from "./chunk-LYHS7CSA.js";
16
16
  import {
17
17
  sanitizeLabel
18
18
  } from "./chunk-VK6GV757.js";
@@ -9,7 +9,7 @@ import {
9
9
  runHarness,
10
10
  runLogDir,
11
11
  runLogPath
12
- } from "./chunk-6SRF3XGA.js";
12
+ } from "./chunk-LYHS7CSA.js";
13
13
  import {
14
14
  sanitizeLabel,
15
15
  stripControl
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  ConnectFailure,
4
4
  deviceLogin
5
- } from "./chunk-LFLFQOPL.js";
5
+ } from "./chunk-WC72IBTN.js";
6
6
  import {
7
7
  ApiError,
8
8
  ReauthError,
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-SBYSVZ7J.js";
7
7
  import {
8
8
  VERSION
9
- } from "./chunk-WZHNYHUT.js";
9
+ } from "./chunk-LYHUSZRK.js";
10
10
  import {
11
11
  getOrigin,
12
12
  readCredentials,
@@ -53,17 +53,17 @@ import {
53
53
  which,
54
54
  workFolder,
55
55
  workFolderLine
56
- } from "./chunk-OJH72SCM.js";
56
+ } from "./chunk-G35UCZVP.js";
57
57
  import "./chunk-KDTPUD2Y.js";
58
- import "./chunk-NKUPQAVX.js";
59
- import "./chunk-6SRF3XGA.js";
58
+ import "./chunk-3KTZTHQM.js";
59
+ import "./chunk-LYHS7CSA.js";
60
60
  import "./chunk-VK6GV757.js";
61
61
  import "./chunk-365HFCQQ.js";
62
62
  import "./chunk-PKIEWBR7.js";
63
- import "./chunk-C5WAMQVJ.js";
64
- import "./chunk-LFLFQOPL.js";
63
+ import "./chunk-SEVJGIDJ.js";
64
+ import "./chunk-WC72IBTN.js";
65
65
  import "./chunk-SBYSVZ7J.js";
66
- import "./chunk-WZHNYHUT.js";
66
+ import "./chunk-LYHUSZRK.js";
67
67
  import "./chunk-D5UZW42X.js";
68
68
  export {
69
69
  DEFAULT_T3_URL,
@@ -7,17 +7,17 @@ import {
7
7
  runnerOrigin,
8
8
  stopService,
9
9
  unitOrigin
10
- } from "./chunk-OJH72SCM.js";
10
+ } from "./chunk-G35UCZVP.js";
11
11
  import "./chunk-KDTPUD2Y.js";
12
- import "./chunk-NKUPQAVX.js";
13
- import "./chunk-6SRF3XGA.js";
12
+ import "./chunk-3KTZTHQM.js";
13
+ import "./chunk-LYHS7CSA.js";
14
14
  import "./chunk-VK6GV757.js";
15
15
  import "./chunk-365HFCQQ.js";
16
16
  import "./chunk-PKIEWBR7.js";
17
- import "./chunk-C5WAMQVJ.js";
18
- import "./chunk-LFLFQOPL.js";
17
+ import "./chunk-SEVJGIDJ.js";
18
+ import "./chunk-WC72IBTN.js";
19
19
  import "./chunk-SBYSVZ7J.js";
20
- import "./chunk-WZHNYHUT.js";
20
+ import "./chunk-LYHUSZRK.js";
21
21
  import "./chunk-D5UZW42X.js";
22
22
  export {
23
23
  disconnect,
@@ -2,17 +2,17 @@
2
2
  import {
3
3
  existingRunnerEnvironment,
4
4
  pinExistingRunner
5
- } from "./chunk-OJH72SCM.js";
5
+ } from "./chunk-G35UCZVP.js";
6
6
  import "./chunk-KDTPUD2Y.js";
7
- import "./chunk-NKUPQAVX.js";
8
- import "./chunk-6SRF3XGA.js";
7
+ import "./chunk-3KTZTHQM.js";
8
+ import "./chunk-LYHS7CSA.js";
9
9
  import "./chunk-VK6GV757.js";
10
10
  import "./chunk-365HFCQQ.js";
11
11
  import "./chunk-PKIEWBR7.js";
12
- import "./chunk-C5WAMQVJ.js";
13
- import "./chunk-LFLFQOPL.js";
12
+ import "./chunk-SEVJGIDJ.js";
13
+ import "./chunk-WC72IBTN.js";
14
14
  import "./chunk-SBYSVZ7J.js";
15
- import "./chunk-WZHNYHUT.js";
15
+ import "./chunk-LYHUSZRK.js";
16
16
  import "./chunk-D5UZW42X.js";
17
17
  export {
18
18
  existingRunnerEnvironment,
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-365HFCQQ.js";
5
5
  import {
6
6
  VERSION
7
- } from "./chunk-WZHNYHUT.js";
7
+ } from "./chunk-LYHUSZRK.js";
8
8
  import {
9
9
  applyEnvironmentFlag
10
10
  } from "./chunk-D5UZW42X.js";
@@ -68,7 +68,7 @@ Add --staging to any command to use Cloop staging instead of production.
68
68
  A production machine and a staging machine can run side by side on one computer.
69
69
  `;
70
70
  async function pinExistingRunner() {
71
- const { pinExistingRunner: pin } = await import("./existing-runner-RZIY4UG5.js");
71
+ const { pinExistingRunner: pin } = await import("./existing-runner-QMWIFBEY.js");
72
72
  const { note } = pin();
73
73
  if (note) console.error(note);
74
74
  }
@@ -76,7 +76,7 @@ async function main() {
76
76
  switch (command) {
77
77
  case "login":
78
78
  case "auth": {
79
- const { loginCommand } = await import("./login-NWMS6K6R.js");
79
+ const { loginCommand } = await import("./login-NRVY6VCH.js");
80
80
  await loginCommand(argv);
81
81
  break;
82
82
  }
@@ -86,61 +86,61 @@ async function main() {
86
86
  break;
87
87
  }
88
88
  case "serve": {
89
- const { startMcpServer } = await import("./mcp-server-4ZA4F7WY.js");
89
+ const { startMcpServer } = await import("./mcp-server-2WJ6NUFK.js");
90
90
  await startMcpServer();
91
91
  break;
92
92
  }
93
93
  case "statusline": {
94
- const { statuslineCommand } = await import("./statusline-YDVFTXO7.js");
94
+ const { statuslineCommand } = await import("./statusline-GPI2DKPD.js");
95
95
  statuslineCommand();
96
96
  break;
97
97
  }
98
98
  case "connect": {
99
- const { connectCommand } = await import("./connect-ZON4PSFH.js");
99
+ const { connectCommand } = await import("./connect-NIFPACJW.js");
100
100
  await connectCommand(argv.slice(1));
101
101
  break;
102
102
  }
103
103
  case "use": {
104
- const { useCommand } = await import("./use-IP43IFMT.js");
104
+ const { useCommand } = await import("./use-6ERJOP22.js");
105
105
  process.exitCode = await useCommand(argv.slice(1));
106
106
  break;
107
107
  }
108
108
  case "disconnect": {
109
- const { disconnectCommand } = await import("./disconnect-F3DWFZXH.js");
109
+ const { disconnectCommand } = await import("./disconnect-GLVRXCUU.js");
110
110
  await disconnectCommand(argv.slice(1));
111
111
  break;
112
112
  }
113
113
  case "box": {
114
- const { boxCommand } = await import("./box-DQQQYGY6.js");
114
+ const { boxCommand } = await import("./box-7K2E7CRQ.js");
115
115
  await boxCommand(argv.slice(1));
116
116
  break;
117
117
  }
118
118
  case "runs": {
119
119
  await pinExistingRunner();
120
- const { runsCommand } = await import("./runs-6N57MCYW.js");
120
+ const { runsCommand } = await import("./runs-UYKVOCRP.js");
121
121
  process.exitCode = runsCommand();
122
122
  break;
123
123
  }
124
124
  case "watch": {
125
125
  await pinExistingRunner();
126
- const { watchCommand } = await import("./runs-6N57MCYW.js");
126
+ const { watchCommand } = await import("./runs-UYKVOCRP.js");
127
127
  process.exitCode = await watchCommand(argv.slice(1));
128
128
  break;
129
129
  }
130
130
  case "takeover": {
131
131
  await pinExistingRunner();
132
- const { takeoverCommand } = await import("./takeover-MQIZPP6U.js");
132
+ const { takeoverCommand } = await import("./takeover-W7YCWPPH.js");
133
133
  process.exitCode = await takeoverCommand(argv.slice(1));
134
134
  break;
135
135
  }
136
136
  case "resume": {
137
137
  await pinExistingRunner();
138
- const { resumeCommand } = await import("./runs-6N57MCYW.js");
138
+ const { resumeCommand } = await import("./runs-UYKVOCRP.js");
139
139
  process.exitCode = await resumeCommand(argv.slice(1));
140
140
  break;
141
141
  }
142
142
  case "runner": {
143
- const { runnerCommand } = await import("./runner-3DXSNEHV.js");
143
+ const { runnerCommand } = await import("./runner-AJIU2O5Z.js");
144
144
  await runnerCommand(argv.slice(1));
145
145
  break;
146
146
  }
@@ -3,9 +3,9 @@ import {
3
3
  deviceLogin,
4
4
  loginCommand,
5
5
  refusalSentence
6
- } from "./chunk-LFLFQOPL.js";
6
+ } from "./chunk-WC72IBTN.js";
7
7
  import "./chunk-SBYSVZ7J.js";
8
- import "./chunk-WZHNYHUT.js";
8
+ import "./chunk-LYHUSZRK.js";
9
9
  import "./chunk-D5UZW42X.js";
10
10
  export {
11
11
  deviceLogin,
@@ -31,7 +31,7 @@ import {
31
31
  } from "./chunk-SBYSVZ7J.js";
32
32
  import {
33
33
  VERSION
34
- } from "./chunk-WZHNYHUT.js";
34
+ } from "./chunk-LYHUSZRK.js";
35
35
  import {
36
36
  getMeshUrl,
37
37
  getToken
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  connectWebhook,
4
4
  runnerCommand
5
- } from "./chunk-C5WAMQVJ.js";
6
- import "./chunk-LFLFQOPL.js";
5
+ } from "./chunk-SEVJGIDJ.js";
6
+ import "./chunk-WC72IBTN.js";
7
7
  import "./chunk-SBYSVZ7J.js";
8
- import "./chunk-WZHNYHUT.js";
8
+ import "./chunk-LYHUSZRK.js";
9
9
  import "./chunk-D5UZW42X.js";
10
10
  export {
11
11
  connectWebhook,
@@ -9,8 +9,8 @@ import {
9
9
  runsCommand,
10
10
  sessionFolder,
11
11
  watchCommand
12
- } from "./chunk-XVJP7XW3.js";
13
- import "./chunk-6SRF3XGA.js";
12
+ } from "./chunk-RXGUYYDP.js";
13
+ import "./chunk-LYHS7CSA.js";
14
14
  import "./chunk-VK6GV757.js";
15
15
  import "./chunk-D5UZW42X.js";
16
16
  export {
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-VK6GV757.js";
8
8
  import {
9
9
  VERSION
10
- } from "./chunk-WZHNYHUT.js";
10
+ } from "./chunk-LYHUSZRK.js";
11
11
  import {
12
12
  getToken
13
13
  } from "./chunk-D5UZW42X.js";
@@ -9,10 +9,10 @@ import {
9
9
  takeoverDir,
10
10
  writeTakeoverReply,
11
11
  writeTakeoverRequest
12
- } from "./chunk-NC2CYUVJ.js";
13
- import "./chunk-XVJP7XW3.js";
14
- import "./chunk-NKUPQAVX.js";
15
- import "./chunk-6SRF3XGA.js";
12
+ } from "./chunk-QBSVTFL7.js";
13
+ import "./chunk-RXGUYYDP.js";
14
+ import "./chunk-3KTZTHQM.js";
15
+ import "./chunk-LYHS7CSA.js";
16
16
  import "./chunk-VK6GV757.js";
17
17
  import "./chunk-SBYSVZ7J.js";
18
18
  import "./chunk-D5UZW42X.js";
@@ -3,20 +3,20 @@ import {
3
3
  DRIVER_NAME,
4
4
  pinExistingRunner,
5
5
  runConnect
6
- } from "./chunk-OJH72SCM.js";
6
+ } from "./chunk-G35UCZVP.js";
7
7
  import "./chunk-KDTPUD2Y.js";
8
- import "./chunk-NKUPQAVX.js";
8
+ import "./chunk-3KTZTHQM.js";
9
9
  import {
10
10
  isLocal,
11
11
  readRunnerConfig
12
- } from "./chunk-6SRF3XGA.js";
12
+ } from "./chunk-LYHS7CSA.js";
13
13
  import "./chunk-VK6GV757.js";
14
14
  import "./chunk-365HFCQQ.js";
15
15
  import "./chunk-PKIEWBR7.js";
16
- import "./chunk-C5WAMQVJ.js";
17
- import "./chunk-LFLFQOPL.js";
16
+ import "./chunk-SEVJGIDJ.js";
17
+ import "./chunk-WC72IBTN.js";
18
18
  import "./chunk-SBYSVZ7J.js";
19
- import "./chunk-WZHNYHUT.js";
19
+ import "./chunk-LYHUSZRK.js";
20
20
  import "./chunk-D5UZW42X.js";
21
21
 
22
22
  // src/commands/use.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloop/runner",
3
- "version": "0.3.36",
3
+ "version": "0.3.37",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "Make your computer and your agents Cloop machines: device login, the machine daemon, the Cloop MCP server, and Claude Code hooks.",