@staff0rd/assist 0.757.0 → 0.758.0

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/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.757.0",
9
+ version: "0.758.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -15033,6 +15033,20 @@ import {
15033
15033
  } from "http";
15034
15034
  import { request as httpsRequest } from "https";
15035
15035
 
15036
+ // src/commands/sessions/web/peerTimeoutMs.ts
15037
+ var peerTimeoutMs = 2e4;
15038
+
15039
+ // src/commands/sessions/web/boundUpstream.ts
15040
+ function boundUpstream(upstream, res) {
15041
+ upstream.setTimeout(
15042
+ peerTimeoutMs,
15043
+ () => upstream.destroy(new Error(`no response after ${peerTimeoutMs}ms`))
15044
+ );
15045
+ res.on("close", () => {
15046
+ if (!res.writableFinished) upstream.destroy();
15047
+ });
15048
+ }
15049
+
15036
15050
  // src/commands/sessions/web/isQuietPoll.ts
15037
15051
  var POLLED_PATHS = /* @__PURE__ */ new Set(["/api/git-status"]);
15038
15052
  function isQuietPoll(pathname, status2) {
@@ -15071,6 +15085,7 @@ function forwardToPeer(req, res, node, url) {
15071
15085
  },
15072
15086
  (peer) => relayPeerResponse(peer, res, url.pathname, log2, resolve26)
15073
15087
  );
15088
+ boundUpstream(upstream, res);
15074
15089
  upstream.on("error", (error) => {
15075
15090
  log2(`failed: ${error.message}`);
15076
15091
  if (res.headersSent) res.destroy();
@@ -39088,6 +39103,49 @@ function registerVerify(program2) {
39088
39103
  configHelp(verifyCommand, verifyConfigHelp);
39089
39104
  }
39090
39105
 
39106
+ // src/commands/watch/decideLap.ts
39107
+ var RELAUNCH_CODES = /* @__PURE__ */ new Set([0, 2, 4]);
39108
+ function decideLap(end, interrupted) {
39109
+ if (interrupted) return { kind: "exit", code: 130 };
39110
+ if (end.code === null) return { kind: "relaunch" };
39111
+ if (RELAUNCH_CODES.has(end.code)) return { kind: "relaunch" };
39112
+ return { kind: "exit", code: end.code };
39113
+ }
39114
+
39115
+ // src/commands/watch/runWatchLap.ts
39116
+ import { spawn as spawn9 } from "child_process";
39117
+ var WATCH_LAP_ARGS = ["watch", "wait", "--pull", "--build"];
39118
+ function runWatchLap() {
39119
+ return new Promise((resolve26, reject) => {
39120
+ const assistFromPath = spawn9("assist", WATCH_LAP_ARGS, {
39121
+ stdio: "inherit",
39122
+ shell: process.platform === "win32"
39123
+ });
39124
+ assistFromPath.on("close", (code, signal) => resolve26({ code, signal }));
39125
+ assistFromPath.on("error", reject);
39126
+ });
39127
+ }
39128
+
39129
+ // src/commands/watch/watchLoop.ts
39130
+ async function watchLoop() {
39131
+ let interrupted = false;
39132
+ const recordInterruptAndLetLapFinish = () => {
39133
+ interrupted = true;
39134
+ };
39135
+ process.on("SIGINT", recordInterruptAndLetLapFinish);
39136
+ for (let lap = 1; ; lap++) {
39137
+ console.log(`lap ${lap}: assist ${WATCH_LAP_ARGS.join(" ")}`);
39138
+ const end = await runWatchLap();
39139
+ const decision = decideLap(end, interrupted);
39140
+ const how = end.signal ? `killed by ${end.signal}` : `exited ${end.code}`;
39141
+ if (decision.kind === "exit") {
39142
+ console.error(`lap ${lap} ${how} \u2014 stopping`);
39143
+ return process.exit(decision.code);
39144
+ }
39145
+ console.log(`lap ${lap} ${how} \u2014 relaunching`);
39146
+ }
39147
+ }
39148
+
39091
39149
  // src/commands/watch/resolveUpstream.ts
39092
39150
  import { execFileSync as execFileSync21 } from "child_process";
39093
39151
  function runGit3(args, cwd) {
@@ -39702,6 +39760,9 @@ function registerWatch(program2) {
39702
39760
  ).action(
39703
39761
  (options2) => watchWait(options2)
39704
39762
  );
39763
+ watchCommand.command("loop").description(
39764
+ "Run assist watch wait --pull --build as a fresh child per lap, relaunching after exit 0, 2 or 4 or a signal kill, and exit with the child's code on 1, 3 or 130"
39765
+ ).action(() => watchLoop());
39705
39766
  watchCommand.command("report").description(
39706
39767
  "Print the built version, the last 10 commits as a markdown table, the restarts the new commits make necessary, and whether ~/.claude needs a sync"
39707
39768
  ).option(
@@ -44129,10 +44190,10 @@ function restoreAllSessions(spawner, sessions, notify2) {
44129
44190
 
44130
44191
  // src/commands/sessions/daemon/retrySession.ts
44131
44192
  function retrySession(session, clients, onStatusChange) {
44132
- const spawn10 = respawnThunk(session);
44133
- if (!spawn10) return false;
44193
+ const spawn11 = respawnThunk(session);
44194
+ if (!spawn11) return false;
44134
44195
  const respawn = () => {
44135
- respawnSession(session, spawn10, "running", clients, onStatusChange);
44196
+ respawnSession(session, spawn11, "running", clients, onStatusChange);
44136
44197
  daemonLog(`session ${session.id} retried: ${session.name}`);
44137
44198
  };
44138
44199
  const pty2 = session.pty;
@@ -45860,10 +45921,10 @@ var handleHelloRequest = (client, m, d) => {
45860
45921
  };
45861
45922
 
45862
45923
  // src/commands/sessions/daemon/creator.ts
45863
- function creator(isNew, spawn10) {
45924
+ function creator(isNew, spawn11) {
45864
45925
  return (client, m, d) => {
45865
45926
  if (m.links.route(client, d)) return;
45866
- const result = spawn10(m, d);
45927
+ const result = spawn11(m, d);
45867
45928
  if (typeof result !== "string") {
45868
45929
  sendTo(client, { type: "error", message: result.error });
45869
45930
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.757.0",
3
+ "version": "0.758.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {