@cloop/runner 0.3.67 → 0.3.68

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.
@@ -40,7 +40,7 @@ import {
40
40
  systemServices,
41
41
  unitFor,
42
42
  which
43
- } from "./chunk-IK7YYRMU.js";
43
+ } from "./chunk-BVPS6DCH.js";
44
44
  import {
45
45
  MeshSocket,
46
46
  WAKE_TICK_MS,
@@ -48,7 +48,7 @@ import {
48
48
  defaultSocketFactory,
49
49
  runnerLog,
50
50
  wakeWatch
51
- } from "./chunk-5RB7XKPB.js";
51
+ } from "./chunk-AZQGERT7.js";
52
52
  import {
53
53
  BoxWatch,
54
54
  hostedThreadsFilePath,
@@ -117,14 +117,14 @@ import {
117
117
  olderThan
118
118
  } from "./chunk-365HFCQQ.js";
119
119
  import "./chunk-PKIEWBR7.js";
120
- import "./chunk-OIHUQBA4.js";
121
- import "./chunk-QKRGJKJN.js";
120
+ import "./chunk-L7D3ANPW.js";
121
+ import "./chunk-34VZ5LZI.js";
122
122
  import {
123
123
  getMachine
124
124
  } from "./chunk-SBYSVZ7J.js";
125
125
  import {
126
126
  VERSION
127
- } from "./chunk-KYDTE53W.js";
127
+ } from "./chunk-HWNRORIZ.js";
128
128
  import {
129
129
  getMeshUrl,
130
130
  getOrigin,
@@ -2776,6 +2776,7 @@ import { dirname as dirname2, join as join5 } from "path";
2776
2776
  var REGISTRY_LATEST = "https://registry.npmjs.org/@cloop/runner/latest";
2777
2777
  var FIRST_CHECK_MS = 10 * 6e4;
2778
2778
  var CHECK_EVERY_MS = 6 * 36e5;
2779
+ var RETRY_MS = 15 * 6e4;
2779
2780
  var ADOPT_WAIT_MS = 3e4;
2780
2781
  var FETCH_WAIT_MS = 3 * 6e4;
2781
2782
  var RELEASE = /^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/;
@@ -2913,7 +2914,12 @@ function selfUpdate(kind, platform = process.platform, onFailed = () => {
2913
2914
  let latest = null;
2914
2915
  let handing = false;
2915
2916
  let lastWhy = null;
2916
- const state = { checked_at: null, latest: null, error: null };
2917
+ const state = {
2918
+ checked_at: null,
2919
+ latest: null,
2920
+ error: null,
2921
+ stay: null
2922
+ };
2917
2923
  const fail = (error, version) => {
2918
2924
  state.error = error;
2919
2925
  onFailed(error, version);
@@ -2923,25 +2929,45 @@ function selfUpdate(kind, platform = process.platform, onFailed = () => {
2923
2929
  const check = async () => {
2924
2930
  state.checked_at = (/* @__PURE__ */ new Date()).toISOString();
2925
2931
  const read = await readLatest();
2926
- if (!read) return fail("registry_unreachable");
2932
+ if (!read) {
2933
+ fail("registry_unreachable");
2934
+ return false;
2935
+ }
2927
2936
  state.latest = read;
2928
2937
  state.error = null;
2929
- if (read === latest || !olderThan(VERSION, read) || read === readFailed()) return;
2938
+ if (read === latest || !olderThan(VERSION, read)) return true;
2939
+ if (read === readFailed()) {
2940
+ latest = read;
2941
+ return true;
2942
+ }
2930
2943
  const npx = findNpx();
2931
- if (!npx) return fail("npx_missing", read);
2932
- if (await fetchVersion(npx, read)) latest = read;
2933
- else fail("fetch_failed", read);
2944
+ if (!npx) {
2945
+ fail("npx_missing", read);
2946
+ return true;
2947
+ }
2948
+ if (await fetchVersion(npx, read)) {
2949
+ latest = read;
2950
+ return true;
2951
+ }
2952
+ fail("fetch_failed", read);
2953
+ return false;
2934
2954
  };
2935
- setTimeout(() => {
2936
- void check();
2937
- setInterval(() => void check(), CHECK_EVERY_MS).unref();
2938
- }, FIRST_CHECK_MS).unref();
2955
+ const schedule = (ms) => setTimeout(async () => {
2956
+ let settled = false;
2957
+ try {
2958
+ settled = await check();
2959
+ } finally {
2960
+ schedule(settled ? CHECK_EVERY_MS : RETRY_MS);
2961
+ }
2962
+ }, ms).unref();
2963
+ schedule(FIRST_CHECK_MS);
2939
2964
  const handOver = (to) => {
2940
2965
  const npx = findNpx();
2941
2966
  if (!npx) {
2942
2967
  log(`npx is not on PATH, so ${to} cannot start`);
2943
2968
  recordFailed(to);
2944
2969
  fail("npx_missing", to);
2970
+ lastWhy = `failed_before:${to}`;
2945
2971
  return;
2946
2972
  }
2947
2973
  const [command, ...args] = handOverCommand(platform, npx, to, kind);
@@ -2969,6 +2995,7 @@ function selfUpdate(kind, platform = process.platform, onFailed = () => {
2969
2995
  log(`${to} did not take over (${why}); staying on ${VERSION}`);
2970
2996
  recordFailed(to);
2971
2997
  fail("handover_failed", to);
2998
+ lastWhy = `failed_before:${to}`;
2972
2999
  };
2973
3000
  child.on("error", (err) => failed(err.message));
2974
3001
  child.on("exit", (code, signal) => {
@@ -2976,7 +3003,7 @@ function selfUpdate(kind, platform = process.platform, onFailed = () => {
2976
3003
  });
2977
3004
  };
2978
3005
  return {
2979
- state: () => ({ ...state }),
3006
+ state: () => ({ ...state, failed: readFailed() }),
2980
3007
  beat({ running, inFlight }) {
2981
3008
  if (handing) return;
2982
3009
  const decision = updateDecision({
@@ -2991,13 +3018,16 @@ function selfUpdate(kind, platform = process.platform, onFailed = () => {
2991
3018
  });
2992
3019
  if (decision.kind === "hand_over") {
2993
3020
  lastWhy = null;
3021
+ state.stay = null;
2994
3022
  handOver(decision.to);
2995
3023
  return;
2996
3024
  }
3025
+ state.stay = decision.why;
2997
3026
  const why = `${decision.why}:${latest}`;
2998
3027
  if (why !== lastWhy && latest) {
2999
3028
  log(`staying on ${VERSION}: ${decision.why}`);
3000
3029
  if (decision.why === "not_our_service") fail("not_our_service", latest);
3030
+ if (decision.why === "failed_before") fail("handover_failed", latest);
3001
3031
  }
3002
3032
  lastWhy = why;
3003
3033
  }
@@ -3285,7 +3315,13 @@ async function run2() {
3285
3315
  (s) => s.harnesses,
3286
3316
  () => []
3287
3317
  ),
3288
- update: update?.state() ?? { checked_at: null, latest: null, error: null },
3318
+ update: update?.state() ?? {
3319
+ checked_at: null,
3320
+ latest: null,
3321
+ error: null,
3322
+ stay: null,
3323
+ failed: null
3324
+ },
3289
3325
  unacked: outbox.size,
3290
3326
  clockOffsetMs: socket.clockOffset(),
3291
3327
  calls: recentCalls
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-SBYSVZ7J.js";
7
7
  import {
8
8
  VERSION
9
- } from "./chunk-KYDTE53W.js";
9
+ } from "./chunk-HWNRORIZ.js";
10
10
  import {
11
11
  getOrigin,
12
12
  readCredentials,
@@ -79,6 +79,16 @@ function callOutcome(input) {
79
79
  function outcomeLine(o) {
80
80
  return `call tool=${o.tool} call=${o.call ?? "-"} work=${o.work ?? "-"} ms=${o.ms} ok=${o.ok}${o.error ? ` error=${o.error}` : ""}`;
81
81
  }
82
+ var STAY_REASONS = [
83
+ "no_latest",
84
+ "current",
85
+ "failed_before",
86
+ "not_a_release",
87
+ "no_service",
88
+ "not_our_service",
89
+ "no_detach",
90
+ "busy"
91
+ ];
82
92
  var PLATFORMS = ["darwin", "linux", "win32", "freebsd", "openbsd", "aix", "sunos"];
83
93
  var ARCHES = ["arm64", "x64", "arm", "ia32", "ppc64", "s390x"];
84
94
  var iso = (value) => typeof value === "string" && !Number.isNaN(Date.parse(value)) && /^\d{4}-\d\d-\d\dT[\d:.]+Z$/.test(value) ? value : null;
@@ -99,7 +109,9 @@ function buildDiag(input) {
99
109
  update: {
100
110
  checked_at: iso(input.update.checked_at),
101
111
  latest: version(input.update.latest) ?? null,
102
- error: errorCode(input.update.error) ?? null
112
+ error: errorCode(input.update.error) ?? null,
113
+ stay: oneOf(STAY_REASONS)(input.update.stay) ?? null,
114
+ failed: version(input.update.failed) ?? null
103
115
  },
104
116
  unacked_results: count(input.unacked) ?? 0,
105
117
  clock_offset_ms: typeof input.clockOffsetMs === "number" && Number.isInteger(input.clockOffsetMs) && Math.abs(input.clockOffsetMs) <= 1e12 ? input.clockOffsetMs : null,
@@ -4,7 +4,7 @@ import {
4
4
  freshness,
5
5
  outcomeLine,
6
6
  runnerLog
7
- } from "./chunk-5RB7XKPB.js";
7
+ } from "./chunk-AZQGERT7.js";
8
8
  import {
9
9
  readRunnerState,
10
10
  runnerStatePath,
@@ -64,14 +64,14 @@ import {
64
64
  } from "./chunk-PKIEWBR7.js";
65
65
  import {
66
66
  connectWebhook
67
- } from "./chunk-OIHUQBA4.js";
67
+ } from "./chunk-L7D3ANPW.js";
68
68
  import {
69
69
  ConnectFailure,
70
70
  connectReport,
71
71
  deviceLogin,
72
72
  newAttempt,
73
73
  sendConnectReport
74
- } from "./chunk-QKRGJKJN.js";
74
+ } from "./chunk-34VZ5LZI.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-KYDTE53W.js";
82
+ } from "./chunk-HWNRORIZ.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.67" : "0.0.0-dev";
4
+ var VERSION = true ? "0.3.68" : "0.0.0-dev";
5
5
 
6
6
  export {
7
7
  VERSION
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  ConnectFailure,
4
4
  deviceLogin
5
- } from "./chunk-QKRGJKJN.js";
5
+ } from "./chunk-34VZ5LZI.js";
6
6
  import {
7
7
  ApiError,
8
8
  ReauthError,
@@ -57,17 +57,17 @@ import {
57
57
  which,
58
58
  workFolder,
59
59
  workFolderLine
60
- } from "./chunk-IK7YYRMU.js";
61
- import "./chunk-5RB7XKPB.js";
60
+ } from "./chunk-BVPS6DCH.js";
61
+ import "./chunk-AZQGERT7.js";
62
62
  import "./chunk-7LPSTDZE.js";
63
63
  import "./chunk-6LYMSWSB.js";
64
64
  import "./chunk-VK6GV757.js";
65
65
  import "./chunk-365HFCQQ.js";
66
66
  import "./chunk-PKIEWBR7.js";
67
- import "./chunk-OIHUQBA4.js";
68
- import "./chunk-QKRGJKJN.js";
67
+ import "./chunk-L7D3ANPW.js";
68
+ import "./chunk-34VZ5LZI.js";
69
69
  import "./chunk-SBYSVZ7J.js";
70
- import "./chunk-KYDTE53W.js";
70
+ import "./chunk-HWNRORIZ.js";
71
71
  import "./chunk-D5UZW42X.js";
72
72
  export {
73
73
  DEFAULT_T3_URL,
@@ -7,17 +7,17 @@ import {
7
7
  runnerOrigin,
8
8
  stopService,
9
9
  unitOrigin
10
- } from "./chunk-IK7YYRMU.js";
11
- import "./chunk-5RB7XKPB.js";
10
+ } from "./chunk-BVPS6DCH.js";
11
+ import "./chunk-AZQGERT7.js";
12
12
  import "./chunk-7LPSTDZE.js";
13
13
  import "./chunk-6LYMSWSB.js";
14
14
  import "./chunk-VK6GV757.js";
15
15
  import "./chunk-365HFCQQ.js";
16
16
  import "./chunk-PKIEWBR7.js";
17
- import "./chunk-OIHUQBA4.js";
18
- import "./chunk-QKRGJKJN.js";
17
+ import "./chunk-L7D3ANPW.js";
18
+ import "./chunk-34VZ5LZI.js";
19
19
  import "./chunk-SBYSVZ7J.js";
20
- import "./chunk-KYDTE53W.js";
20
+ import "./chunk-HWNRORIZ.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-IK7YYRMU.js";
6
- import "./chunk-5RB7XKPB.js";
5
+ } from "./chunk-BVPS6DCH.js";
6
+ import "./chunk-AZQGERT7.js";
7
7
  import "./chunk-7LPSTDZE.js";
8
8
  import "./chunk-6LYMSWSB.js";
9
9
  import "./chunk-VK6GV757.js";
10
10
  import "./chunk-365HFCQQ.js";
11
11
  import "./chunk-PKIEWBR7.js";
12
- import "./chunk-OIHUQBA4.js";
13
- import "./chunk-QKRGJKJN.js";
12
+ import "./chunk-L7D3ANPW.js";
13
+ import "./chunk-34VZ5LZI.js";
14
14
  import "./chunk-SBYSVZ7J.js";
15
- import "./chunk-KYDTE53W.js";
15
+ import "./chunk-HWNRORIZ.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-KYDTE53W.js";
7
+ } from "./chunk-HWNRORIZ.js";
8
8
  import {
9
9
  applyEnvironmentFlag
10
10
  } from "./chunk-D5UZW42X.js";
@@ -72,7 +72,7 @@ Add --staging to any command to use Cloop staging instead of production.
72
72
  A production machine and a staging machine can run side by side on one computer.
73
73
  `;
74
74
  async function pinExistingRunner() {
75
- const { pinExistingRunner: pin } = await import("./existing-runner-NNXJGK2R.js");
75
+ const { pinExistingRunner: pin } = await import("./existing-runner-XT3HLIPM.js");
76
76
  const { note } = pin();
77
77
  if (note) console.error(note);
78
78
  }
@@ -80,7 +80,7 @@ async function main() {
80
80
  switch (command) {
81
81
  case "login":
82
82
  case "auth": {
83
- const { loginCommand } = await import("./login-COK223KI.js");
83
+ const { loginCommand } = await import("./login-VNDFCJD4.js");
84
84
  await loginCommand(argv);
85
85
  break;
86
86
  }
@@ -90,32 +90,32 @@ async function main() {
90
90
  break;
91
91
  }
92
92
  case "serve": {
93
- const { startMcpServer } = await import("./mcp-server-5525QT5K.js");
93
+ const { startMcpServer } = await import("./mcp-server-XPHCDBFR.js");
94
94
  await startMcpServer();
95
95
  break;
96
96
  }
97
97
  case "statusline": {
98
- const { statuslineCommand } = await import("./statusline-QHEED6IO.js");
98
+ const { statuslineCommand } = await import("./statusline-VA2DSWVT.js");
99
99
  statuslineCommand();
100
100
  break;
101
101
  }
102
102
  case "connect": {
103
- const { connectCommand } = await import("./connect-3GG5D7XC.js");
103
+ const { connectCommand } = await import("./connect-D2SXLADA.js");
104
104
  await connectCommand(argv.slice(1));
105
105
  break;
106
106
  }
107
107
  case "use": {
108
- const { useCommand } = await import("./use-J6CNF6JU.js");
108
+ const { useCommand } = await import("./use-7D5GQFGB.js");
109
109
  process.exitCode = await useCommand(argv.slice(1));
110
110
  break;
111
111
  }
112
112
  case "disconnect": {
113
- const { disconnectCommand } = await import("./disconnect-VK3CZIDQ.js");
113
+ const { disconnectCommand } = await import("./disconnect-7SJKPYIN.js");
114
114
  await disconnectCommand(argv.slice(1));
115
115
  break;
116
116
  }
117
117
  case "box": {
118
- const { boxCommand } = await import("./box-NMG35YB2.js");
118
+ const { boxCommand } = await import("./box-YFGM56QY.js");
119
119
  await boxCommand(argv.slice(1));
120
120
  break;
121
121
  }
@@ -144,7 +144,7 @@ async function main() {
144
144
  break;
145
145
  }
146
146
  case "runner": {
147
- const { runnerCommand } = await import("./runner-NSFLXWNP.js");
147
+ const { runnerCommand } = await import("./runner-A3HFZ727.js");
148
148
  await runnerCommand(argv.slice(1));
149
149
  break;
150
150
  }
@@ -3,9 +3,9 @@ import {
3
3
  deviceLogin,
4
4
  loginCommand,
5
5
  refusalSentence
6
- } from "./chunk-QKRGJKJN.js";
6
+ } from "./chunk-34VZ5LZI.js";
7
7
  import "./chunk-SBYSVZ7J.js";
8
- import "./chunk-KYDTE53W.js";
8
+ import "./chunk-HWNRORIZ.js";
9
9
  import "./chunk-D5UZW42X.js";
10
10
  export {
11
11
  deviceLogin,
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  MeshSocket,
16
16
  defaultSocketFactory
17
- } from "./chunk-5RB7XKPB.js";
17
+ } from "./chunk-AZQGERT7.js";
18
18
  import {
19
19
  sanitizeLabel,
20
20
  sanitizeUntrusted
@@ -31,7 +31,7 @@ import {
31
31
  } from "./chunk-SBYSVZ7J.js";
32
32
  import {
33
33
  VERSION
34
- } from "./chunk-KYDTE53W.js";
34
+ } from "./chunk-HWNRORIZ.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-OIHUQBA4.js";
6
- import "./chunk-QKRGJKJN.js";
5
+ } from "./chunk-L7D3ANPW.js";
6
+ import "./chunk-34VZ5LZI.js";
7
7
  import "./chunk-SBYSVZ7J.js";
8
- import "./chunk-KYDTE53W.js";
8
+ import "./chunk-HWNRORIZ.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-KYDTE53W.js";
10
+ } from "./chunk-HWNRORIZ.js";
11
11
  import {
12
12
  getToken
13
13
  } from "./chunk-D5UZW42X.js";
@@ -3,8 +3,8 @@ import {
3
3
  DRIVER_NAME,
4
4
  pinExistingRunner,
5
5
  runConnect
6
- } from "./chunk-IK7YYRMU.js";
7
- import "./chunk-5RB7XKPB.js";
6
+ } from "./chunk-BVPS6DCH.js";
7
+ import "./chunk-AZQGERT7.js";
8
8
  import "./chunk-7LPSTDZE.js";
9
9
  import {
10
10
  isLocal,
@@ -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-OIHUQBA4.js";
17
- import "./chunk-QKRGJKJN.js";
16
+ import "./chunk-L7D3ANPW.js";
17
+ import "./chunk-34VZ5LZI.js";
18
18
  import "./chunk-SBYSVZ7J.js";
19
- import "./chunk-KYDTE53W.js";
19
+ import "./chunk-HWNRORIZ.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.67",
3
+ "version": "0.3.68",
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.",