@cloop/runner 0.3.53 → 0.3.55

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-MSTKBNXI.js";
5
- import "./chunk-P23Z66Z7.js";
4
+ } from "./chunk-XUPGFORB.js";
5
+ import "./chunk-HCAHMQC3.js";
6
6
  import {
7
7
  CAPTURE_TICK_MS,
8
8
  DEFAULT_FALLBACK_MODEL,
@@ -39,7 +39,7 @@ import {
39
39
  systemServices,
40
40
  unitFor,
41
41
  which
42
- } from "./chunk-HQUB3CZW.js";
42
+ } from "./chunk-M2BOHVUC.js";
43
43
  import {
44
44
  MeshSocket,
45
45
  WAKE_TICK_MS,
@@ -57,7 +57,7 @@ import {
57
57
  runnerStatePath,
58
58
  threadsFilePath,
59
59
  writeRunnerState
60
- } from "./chunk-PAHD4VVK.js";
60
+ } from "./chunk-HB76TZWH.js";
61
61
  import {
62
62
  BackgroundReading,
63
63
  BoxToolError,
@@ -87,6 +87,7 @@ import {
87
87
  nextModel,
88
88
  nextProgress,
89
89
  orderThreads,
90
+ ownHarnessFirst,
90
91
  quotaFromClaude,
91
92
  quotaFromCodex,
92
93
  readRunResult,
@@ -106,20 +107,20 @@ import {
106
107
  utcWindow,
107
108
  windowsPowerShellEnv,
108
109
  writeBoxConfig
109
- } from "./chunk-LNZH6D6N.js";
110
+ } from "./chunk-FHAIBI3Z.js";
110
111
  import "./chunk-VK6GV757.js";
111
112
  import {
112
113
  olderThan
113
114
  } from "./chunk-365HFCQQ.js";
114
115
  import "./chunk-PKIEWBR7.js";
115
- import "./chunk-LFUK4SJQ.js";
116
- import "./chunk-6SE2XHPZ.js";
116
+ import "./chunk-2QKGVFWN.js";
117
+ import "./chunk-TKWZ6GLL.js";
117
118
  import {
118
119
  getMachine
119
120
  } from "./chunk-SBYSVZ7J.js";
120
121
  import {
121
122
  VERSION
122
- } from "./chunk-GEBNVGKZ.js";
123
+ } from "./chunk-6CUPNFNR.js";
123
124
  import {
124
125
  getMeshUrl,
125
126
  getOrigin,
@@ -868,6 +869,11 @@ var CloudroomDriver = class {
868
869
  repos;
869
870
  /** Repository runs still being prepared after launch answered, by thread. A failed one stays, for watch to report. */
870
871
  preparing = /* @__PURE__ */ new Map();
872
+ /**
873
+ * Follow-ups that came while a run was prepared, by thread, then command id.
874
+ * Core has no session for them yet; they go in once the run's prompt is in.
875
+ */
876
+ early = /* @__PURE__ */ new Map();
871
877
  /** Runs stopped while still being prepared, or while moving off a refused model. */
872
878
  stopped = /* @__PURE__ */ new Set();
873
879
  /** Runs' model facts, by thread, as the store keeps them. */
@@ -1132,14 +1138,20 @@ var CloudroomDriver = class {
1132
1138
  const again = this.preparing.has(thread);
1133
1139
  if (!again) {
1134
1140
  if (a.attachments?.length) await photosOnce();
1141
+ this.early.set(thread, /* @__PURE__ */ new Map());
1135
1142
  const prep = this.repos.locked(place.clone, go).then(() => {
1136
1143
  this.preparing.delete(thread);
1144
+ return this.sendEarly(thread, a.work_id);
1145
+ });
1146
+ prep.catch((err) => {
1147
+ const dropped = this.early.get(thread)?.size ?? 0;
1148
+ this.early.delete(thread);
1149
+ if (dropped && err !== STOPPED_IN_PREPARATION)
1150
+ this.deps.followUpLost?.({ work: a.work_id, n: dropped });
1151
+ this.log(
1152
+ `launch failed work=${a.work_id} thread=${thread} followups_dropped=${dropped}: ${err instanceof Error ? err.message : String(err)}`
1153
+ );
1137
1154
  });
1138
- prep.catch(
1139
- (err) => this.log(
1140
- `launch failed work=${a.work_id} thread=${thread}: ${err instanceof Error ? err.message : String(err)}`
1141
- )
1142
- );
1143
1155
  this.preparing.set(thread, prep);
1144
1156
  }
1145
1157
  return answer(again || Boolean(existing));
@@ -1153,6 +1165,42 @@ var CloudroomDriver = class {
1153
1165
  */
1154
1166
  async send(a) {
1155
1167
  const id = this.carrier(a.thread_id);
1168
+ const early = this.early.get(id);
1169
+ if (early && !a.answer) {
1170
+ early.set(a.command_id, early.get(a.command_id) ?? a);
1171
+ this.log(`send thread=${id} waits for its run's prompt`);
1172
+ return { delivered: "queue" };
1173
+ }
1174
+ return this.sendNow(id, a);
1175
+ }
1176
+ /**
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.
1182
+ */
1183
+ async sendEarly(thread, work) {
1184
+ const early = this.early.get(thread);
1185
+ if (!early) return;
1186
+ for (const a of early.values()) {
1187
+ await this.sendNow(thread, { ...a, resume: true }).then(
1188
+ (r) => this.log(`send thread=${thread} after its prompt delivered=${r.delivered}`),
1189
+ (err) => {
1190
+ this.deps.followUpLost?.({
1191
+ work,
1192
+ n: 1,
1193
+ ...err instanceof BoxToolError ? { error: err.code } : {}
1194
+ });
1195
+ this.log(
1196
+ `send thread=${thread} after its prompt failed: ${err instanceof Error ? err.message : String(err)}`
1197
+ );
1198
+ }
1199
+ );
1200
+ }
1201
+ this.early.delete(thread);
1202
+ }
1203
+ async sendNow(id, a) {
1156
1204
  const s = await this.session(id);
1157
1205
  if (a.answer) return { delivered: "question_changed", question: null, question_id: null };
1158
1206
  const steer = coreRequestId("steer", a.command_id);
@@ -2778,7 +2826,7 @@ async function machineHarnesses(cfg) {
2778
2826
  probeClaude(cfg.driver === "claude-code" ? cfg.bin : void 0),
2779
2827
  probeCodex(cfg.driver === "codex" ? cfg.bin : void 0)
2780
2828
  ]);
2781
- return [claude, codex].filter((h) => h !== null);
2829
+ return ownHarnessFirst([claude, codex], cfg.driver);
2782
2830
  }
2783
2831
  async function localDriver(cfg, name) {
2784
2832
  const bin = cfg.driver === name ? cfg.bin : void 0;
@@ -2861,7 +2909,9 @@ async function run2() {
2861
2909
  ...hosted.harness === "codex" ? { models: () => codexModels() } : {},
2862
2910
  // Beside the daemon's threads: the model a Task named, a run's move off a refused one, refusals and the last list.
2863
2911
  runModels: fileRunModels(hostedRunModelsPath(hosted.harness)),
2864
- log: log2
2912
+ log: log2,
2913
+ // Called only once calls arrive, so the socket below exists by then.
2914
+ followUpLost: ({ work, n, error }) => socket.send(runnerLog("followup_lost", { work, n, tool: "thread.send", error }))
2865
2915
  }) : local && (name === "claude-code" || name === "codex") ? await localDriver(local, name) : new T3Driver({
2866
2916
  client: () => t3.client,
2867
2917
  t3Bin: isT3(cfg) ? cfg.t3Bin : null,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  ConnectFailure,
4
4
  deviceLogin
5
- } from "./chunk-6SE2XHPZ.js";
5
+ } from "./chunk-TKWZ6GLL.js";
6
6
  import {
7
7
  ApiError,
8
8
  ReauthError,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/version.ts
4
- var VERSION = true ? "0.3.53" : "0.0.0-dev";
4
+ var VERSION = true ? "0.3.55" : "0.0.0-dev";
5
5
 
6
6
  export {
7
7
  VERSION