@cloop/runner 0.3.56 → 0.3.57

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.
@@ -39,7 +39,7 @@ import {
39
39
  systemServices,
40
40
  unitFor,
41
41
  which
42
- } from "./chunk-5UUNMYXF.js";
42
+ } from "./chunk-EWCRSUJM.js";
43
43
  import {
44
44
  MeshSocket,
45
45
  WAKE_TICK_MS,
@@ -113,14 +113,14 @@ import {
113
113
  olderThan
114
114
  } from "./chunk-365HFCQQ.js";
115
115
  import "./chunk-PKIEWBR7.js";
116
- import "./chunk-MNZIE6UK.js";
117
- import "./chunk-4NKNL6UU.js";
116
+ import "./chunk-6Z22QRZA.js";
117
+ import "./chunk-VXBAFPY4.js";
118
118
  import {
119
119
  getMachine
120
120
  } from "./chunk-SBYSVZ7J.js";
121
121
  import {
122
122
  VERSION
123
- } from "./chunk-7KLXPUCK.js";
123
+ } from "./chunk-SOM5GPW2.js";
124
124
  import {
125
125
  getMeshUrl,
126
126
  getOrigin,
@@ -579,6 +579,14 @@ function placeFor(a) {
579
579
  branch: `cloop/${run3}`
580
580
  };
581
581
  }
582
+ function withHeld(prompt, held) {
583
+ if (!held.length) return prompt;
584
+ return `${prompt}
585
+
586
+ The owner added this while the run was being prepared:
587
+
588
+ ${held.join("\n\n")}`;
589
+ }
582
590
  function launchText(prompt, place, photos = "") {
583
591
  const where = place.kind === "worktree" ? `
584
592
 
@@ -874,6 +882,11 @@ var CloudroomDriver = class {
874
882
  * Core has no session for them yet; they go in once the run's prompt is in.
875
883
  */
876
884
  early = /* @__PURE__ */ new Map();
885
+ /**
886
+ * The command ids of follow-ups in each live run's prompt, by thread, so a
887
+ * resend sends nothing. A failed prompt or the run's end drops them.
888
+ */
889
+ folded = /* @__PURE__ */ new Map();
877
890
  /** Runs stopped while still being prepared, or while moving off a refused model. */
878
891
  stopped = /* @__PURE__ */ new Set();
879
892
  /** Runs' model facts, by thread, as the store keeps them. */
@@ -1077,6 +1090,7 @@ var CloudroomDriver = class {
1077
1090
  this.keep(thread, { named: a.model });
1078
1091
  const place = placeFor(a);
1079
1092
  let photos;
1093
+ let inPrompt = 0;
1080
1094
  const photosOnce = async () => {
1081
1095
  photos ??= await this.photos(a, place);
1082
1096
  return photos;
@@ -1109,10 +1123,16 @@ var CloudroomDriver = class {
1109
1123
  folder(existing2 ?? await this.session(thread))
1110
1124
  );
1111
1125
  if (this.stopped.has(thread)) throw STOPPED_IN_PREPARATION;
1126
+ const photoLine = (await photosOnce()).line;
1127
+ const held = this.foldEarly(thread);
1128
+ inPrompt = held.length;
1129
+ if (held.length)
1130
+ this.log(`launch work=${a.work_id} thread=${thread} followups_in_prompt=${held.length}`);
1112
1131
  await this.core.command(thread, "prompts", {
1113
1132
  request_id: prompt,
1114
- text: launchText(a.prompt, place, (await photosOnce()).line)
1133
+ text: launchText(withHeld(a.prompt, held), place, photoLine)
1115
1134
  });
1135
+ inPrompt = 0;
1116
1136
  this.preparing.delete(thread);
1117
1137
  if (this.stopped.has(thread))
1118
1138
  await this.stopRun(thread, `prepared-${a.work_id}`).catch(
@@ -1144,8 +1164,9 @@ var CloudroomDriver = class {
1144
1164
  return this.sendEarly(thread, a.work_id);
1145
1165
  });
1146
1166
  prep.catch((err) => {
1147
- const dropped = this.early.get(thread)?.size ?? 0;
1167
+ const dropped = (this.early.get(thread)?.size ?? 0) + inPrompt;
1148
1168
  this.early.delete(thread);
1169
+ this.folded.delete(thread);
1149
1170
  if (dropped && err !== STOPPED_IN_PREPARATION)
1150
1171
  this.deps.followUpLost?.({ work: a.work_id, n: dropped });
1151
1172
  this.log(
@@ -1165,6 +1186,7 @@ var CloudroomDriver = class {
1165
1186
  */
1166
1187
  async send(a) {
1167
1188
  const id = this.carrier(a.thread_id);
1189
+ if (this.folded.get(id)?.has(a.command_id)) return { delivered: "queue" };
1168
1190
  const early = this.early.get(id);
1169
1191
  if (early && !a.answer) {
1170
1192
  early.set(a.command_id, early.get(a.command_id) ?? a);
@@ -1173,18 +1195,31 @@ var CloudroomDriver = class {
1173
1195
  }
1174
1196
  return this.sendNow(id, a);
1175
1197
  }
1198
+ /** Takes the follow-ups held so far, in the order they came, for the run's prompt. Later ones still wait. */
1199
+ foldEarly(thread) {
1200
+ const early = this.early.get(thread);
1201
+ if (!early) return [];
1202
+ const held = [...early.values()];
1203
+ early.clear();
1204
+ if (!held.length) return [];
1205
+ const ids = this.folded.get(thread) ?? /* @__PURE__ */ new Set();
1206
+ for (const a of held) ids.add(a.command_id);
1207
+ this.folded.set(thread, ids);
1208
+ return held.map((a) => a.text);
1209
+ }
1176
1210
  /**
1177
- * The follow-ups that came while the run was prepared, in the order they
1178
- * came. One that comes while these go in joins the end of the line. Each
1179
- * goes as a resume: core may not have counted the run's prompt yet. The
1180
- * app already told the owner each one is queued, so a failure here goes to
1181
- * the mesh as `followup_lost`, the one place it is seen.
1211
+ * The follow-ups that came while the run's prompt was on its way, in the
1212
+ * order they came. One that comes while these go in joins the end of the
1213
+ * line. Each waits as the next prompt, never a steer into a turn just
1214
+ * starting; it goes as a resume, as core may not have counted the run's
1215
+ * prompt yet. The app already told the owner each one is queued, so a
1216
+ * failure here goes to the mesh as `followup_lost`, the one place it is seen.
1182
1217
  */
1183
1218
  async sendEarly(thread, work) {
1184
1219
  const early = this.early.get(thread);
1185
1220
  if (!early) return;
1186
1221
  for (const a of early.values()) {
1187
- await this.sendNow(thread, { ...a, resume: true }).then(
1222
+ await this.sendNow(thread, { ...a, mode: "queue", resume: true }).then(
1188
1223
  (r) => this.log(`send thread=${thread} after its prompt delivered=${r.delivered}`),
1189
1224
  (err) => {
1190
1225
  this.deps.followUpLost?.({
@@ -1371,6 +1406,7 @@ ${line}` : line;
1371
1406
  watch(id, report) {
1372
1407
  const onEvent = (event) => {
1373
1408
  const ends = event.kind === "settled" || event.kind === "failed";
1409
+ if (ends) this.folded.delete(id);
1374
1410
  if (ends && this.runModels.has(id))
1375
1411
  this.keep(id, { ended_at: new Date(this.now()).toISOString() });
1376
1412
  report(ends ? { ...event, harness: this.harness } : event);
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  ConnectFailure,
4
4
  deviceLogin
5
- } from "./chunk-4NKNL6UU.js";
5
+ } from "./chunk-VXBAFPY4.js";
6
6
  import {
7
7
  ApiError,
8
8
  ReauthError,
@@ -64,14 +64,14 @@ import {
64
64
  } from "./chunk-PKIEWBR7.js";
65
65
  import {
66
66
  connectWebhook
67
- } from "./chunk-MNZIE6UK.js";
67
+ } from "./chunk-6Z22QRZA.js";
68
68
  import {
69
69
  ConnectFailure,
70
70
  connectReport,
71
71
  deviceLogin,
72
72
  newAttempt,
73
73
  sendConnectReport
74
- } from "./chunk-4NKNL6UU.js";
74
+ } from "./chunk-VXBAFPY4.js";
75
75
  import {
76
76
  defaultDeviceName,
77
77
  getMachine,
@@ -79,7 +79,7 @@ import {
79
79
  } from "./chunk-SBYSVZ7J.js";
80
80
  import {
81
81
  VERSION
82
- } from "./chunk-7KLXPUCK.js";
82
+ } from "./chunk-SOM5GPW2.js";
83
83
  import {
84
84
  STAGING_ORIGIN,
85
85
  getOrigin,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/version.ts
4
- var VERSION = true ? "0.3.56" : "0.0.0-dev";
4
+ var VERSION = true ? "0.3.57" : "0.0.0-dev";
5
5
 
6
6
  export {
7
7
  VERSION
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-SBYSVZ7J.js";
7
7
  import {
8
8
  VERSION
9
- } from "./chunk-7KLXPUCK.js";
9
+ } from "./chunk-SOM5GPW2.js";
10
10
  import {
11
11
  getOrigin,
12
12
  readCredentials,
@@ -54,17 +54,17 @@ import {
54
54
  which,
55
55
  workFolder,
56
56
  workFolderLine
57
- } from "./chunk-5UUNMYXF.js";
57
+ } from "./chunk-EWCRSUJM.js";
58
58
  import "./chunk-BI2Y5ZCL.js";
59
59
  import "./chunk-TZDLUM3E.js";
60
60
  import "./chunk-XAKDSXMW.js";
61
61
  import "./chunk-VK6GV757.js";
62
62
  import "./chunk-365HFCQQ.js";
63
63
  import "./chunk-PKIEWBR7.js";
64
- import "./chunk-MNZIE6UK.js";
65
- import "./chunk-4NKNL6UU.js";
64
+ import "./chunk-6Z22QRZA.js";
65
+ import "./chunk-VXBAFPY4.js";
66
66
  import "./chunk-SBYSVZ7J.js";
67
- import "./chunk-7KLXPUCK.js";
67
+ import "./chunk-SOM5GPW2.js";
68
68
  import "./chunk-D5UZW42X.js";
69
69
  export {
70
70
  DEFAULT_T3_URL,
@@ -7,17 +7,17 @@ import {
7
7
  runnerOrigin,
8
8
  stopService,
9
9
  unitOrigin
10
- } from "./chunk-5UUNMYXF.js";
10
+ } from "./chunk-EWCRSUJM.js";
11
11
  import "./chunk-BI2Y5ZCL.js";
12
12
  import "./chunk-TZDLUM3E.js";
13
13
  import "./chunk-XAKDSXMW.js";
14
14
  import "./chunk-VK6GV757.js";
15
15
  import "./chunk-365HFCQQ.js";
16
16
  import "./chunk-PKIEWBR7.js";
17
- import "./chunk-MNZIE6UK.js";
18
- import "./chunk-4NKNL6UU.js";
17
+ import "./chunk-6Z22QRZA.js";
18
+ import "./chunk-VXBAFPY4.js";
19
19
  import "./chunk-SBYSVZ7J.js";
20
- import "./chunk-7KLXPUCK.js";
20
+ import "./chunk-SOM5GPW2.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-5UUNMYXF.js";
5
+ } from "./chunk-EWCRSUJM.js";
6
6
  import "./chunk-BI2Y5ZCL.js";
7
7
  import "./chunk-TZDLUM3E.js";
8
8
  import "./chunk-XAKDSXMW.js";
9
9
  import "./chunk-VK6GV757.js";
10
10
  import "./chunk-365HFCQQ.js";
11
11
  import "./chunk-PKIEWBR7.js";
12
- import "./chunk-MNZIE6UK.js";
13
- import "./chunk-4NKNL6UU.js";
12
+ import "./chunk-6Z22QRZA.js";
13
+ import "./chunk-VXBAFPY4.js";
14
14
  import "./chunk-SBYSVZ7J.js";
15
- import "./chunk-7KLXPUCK.js";
15
+ import "./chunk-SOM5GPW2.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-7KLXPUCK.js";
7
+ } from "./chunk-SOM5GPW2.js";
8
8
  import {
9
9
  applyEnvironmentFlag
10
10
  } from "./chunk-D5UZW42X.js";
@@ -69,7 +69,7 @@ Add --staging to any command to use Cloop staging instead of production.
69
69
  A production machine and a staging machine can run side by side on one computer.
70
70
  `;
71
71
  async function pinExistingRunner() {
72
- const { pinExistingRunner: pin } = await import("./existing-runner-RRMKCJ4L.js");
72
+ const { pinExistingRunner: pin } = await import("./existing-runner-KTQ7QWWS.js");
73
73
  const { note } = pin();
74
74
  if (note) console.error(note);
75
75
  }
@@ -77,7 +77,7 @@ async function main() {
77
77
  switch (command) {
78
78
  case "login":
79
79
  case "auth": {
80
- const { loginCommand } = await import("./login-W2FP2ORC.js");
80
+ const { loginCommand } = await import("./login-5JW54F7H.js");
81
81
  await loginCommand(argv);
82
82
  break;
83
83
  }
@@ -87,32 +87,32 @@ async function main() {
87
87
  break;
88
88
  }
89
89
  case "serve": {
90
- const { startMcpServer } = await import("./mcp-server-7GW5KCIJ.js");
90
+ const { startMcpServer } = await import("./mcp-server-NNCIR6YC.js");
91
91
  await startMcpServer();
92
92
  break;
93
93
  }
94
94
  case "statusline": {
95
- const { statuslineCommand } = await import("./statusline-VYT3G2IB.js");
95
+ const { statuslineCommand } = await import("./statusline-MSNEKQKH.js");
96
96
  statuslineCommand();
97
97
  break;
98
98
  }
99
99
  case "connect": {
100
- const { connectCommand } = await import("./connect-Q2FOWOII.js");
100
+ const { connectCommand } = await import("./connect-MDK3N3SN.js");
101
101
  await connectCommand(argv.slice(1));
102
102
  break;
103
103
  }
104
104
  case "use": {
105
- const { useCommand } = await import("./use-V22ZFIES.js");
105
+ const { useCommand } = await import("./use-IGVN3B5K.js");
106
106
  process.exitCode = await useCommand(argv.slice(1));
107
107
  break;
108
108
  }
109
109
  case "disconnect": {
110
- const { disconnectCommand } = await import("./disconnect-SIAWC7FM.js");
110
+ const { disconnectCommand } = await import("./disconnect-6JQ3LYUP.js");
111
111
  await disconnectCommand(argv.slice(1));
112
112
  break;
113
113
  }
114
114
  case "box": {
115
- const { boxCommand } = await import("./box-SXABYGI6.js");
115
+ const { boxCommand } = await import("./box-GW7CJC47.js");
116
116
  await boxCommand(argv.slice(1));
117
117
  break;
118
118
  }
@@ -141,7 +141,7 @@ async function main() {
141
141
  break;
142
142
  }
143
143
  case "runner": {
144
- const { runnerCommand } = await import("./runner-YCQXFCL5.js");
144
+ const { runnerCommand } = await import("./runner-UTOJRU4Y.js");
145
145
  await runnerCommand(argv.slice(1));
146
146
  break;
147
147
  }
@@ -3,9 +3,9 @@ import {
3
3
  deviceLogin,
4
4
  loginCommand,
5
5
  refusalSentence
6
- } from "./chunk-4NKNL6UU.js";
6
+ } from "./chunk-VXBAFPY4.js";
7
7
  import "./chunk-SBYSVZ7J.js";
8
- import "./chunk-7KLXPUCK.js";
8
+ import "./chunk-SOM5GPW2.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-7KLXPUCK.js";
34
+ } from "./chunk-SOM5GPW2.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-MNZIE6UK.js";
6
- import "./chunk-4NKNL6UU.js";
5
+ } from "./chunk-6Z22QRZA.js";
6
+ import "./chunk-VXBAFPY4.js";
7
7
  import "./chunk-SBYSVZ7J.js";
8
- import "./chunk-7KLXPUCK.js";
8
+ import "./chunk-SOM5GPW2.js";
9
9
  import "./chunk-D5UZW42X.js";
10
10
  export {
11
11
  connectWebhook,
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-VK6GV757.js";
8
8
  import {
9
9
  VERSION
10
- } from "./chunk-7KLXPUCK.js";
10
+ } from "./chunk-SOM5GPW2.js";
11
11
  import {
12
12
  getToken
13
13
  } from "./chunk-D5UZW42X.js";
@@ -3,7 +3,7 @@ import {
3
3
  DRIVER_NAME,
4
4
  pinExistingRunner,
5
5
  runConnect
6
- } from "./chunk-5UUNMYXF.js";
6
+ } from "./chunk-EWCRSUJM.js";
7
7
  import "./chunk-BI2Y5ZCL.js";
8
8
  import "./chunk-TZDLUM3E.js";
9
9
  import {
@@ -13,10 +13,10 @@ import {
13
13
  import "./chunk-VK6GV757.js";
14
14
  import "./chunk-365HFCQQ.js";
15
15
  import "./chunk-PKIEWBR7.js";
16
- import "./chunk-MNZIE6UK.js";
17
- import "./chunk-4NKNL6UU.js";
16
+ import "./chunk-6Z22QRZA.js";
17
+ import "./chunk-VXBAFPY4.js";
18
18
  import "./chunk-SBYSVZ7J.js";
19
- import "./chunk-7KLXPUCK.js";
19
+ import "./chunk-SOM5GPW2.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.56",
3
+ "version": "0.3.57",
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.",