shadok-ai 0.19.86 → 0.19.88
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/README.md +12 -0
- package/dist/claude-auto-update.d.ts +74 -0
- package/dist/claude-auto-update.js +88 -0
- package/dist/claude-auto-update.js.map +1 -0
- package/dist/detect.d.ts +16 -0
- package/dist/detect.js +46 -0
- package/dist/detect.js.map +1 -1
- package/dist/server.js +155 -13
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
- package/public/update-ready.d.ts +7 -0
package/README.md
CHANGED
|
@@ -575,6 +575,17 @@ Enter to skip; you can add it later from the web UI).
|
|
|
575
575
|
agent so a change that does not stick cannot loop. A message you send while
|
|
576
576
|
the respawn runs waits a few seconds for it instead of being refused. Clicking
|
|
577
577
|
still reloads at once; `SHADOK_AUTO_RELOAD=0` turns the automatic part off.
|
|
578
|
+
- **A failed Claude Code self-update is installed for you** — when an agent's
|
|
579
|
+
footer says *Auto-update failed* (typically an agent that runs as a user who
|
|
580
|
+
cannot write the global npm directory), the server checks the registry and,
|
|
581
|
+
if a newer Claude Code exists, installs it once for the whole machine; the
|
|
582
|
+
agents then reload onto it one at a time through the automatic reload above.
|
|
583
|
+
Never two installs at once (one in flight per server, plus a lock file shared
|
|
584
|
+
by every server on the host), nothing retried for an hour after an install
|
|
585
|
+
or 30 minutes after a failure, and an agent still on the previous binary
|
|
586
|
+
counts as "needs a reload", not "needs another install". A footer saying
|
|
587
|
+
*Update installed · Restart to apply* reloads the agent the same way.
|
|
588
|
+
`SHADOK_CLAUDE_AUTO_INSTALL=0` turns it off (the ⚠ button still works).
|
|
578
589
|
- **An agent that stops listening restarts itself** — Claude Code's terminal can
|
|
579
590
|
stop taking input while the process behind it stays alive (an upstream bug;
|
|
580
591
|
nothing on screen shows it). When a message cannot be typed into an agent for
|
|
@@ -1460,6 +1471,7 @@ machine, which silently shifts every daily prompt on a server running in UTC.
|
|
|
1460
1471
|
| `SHADOK_IDLE_MIN` | minutes with no client before a session is reclaimed (60) |
|
|
1461
1472
|
| `SHADOK_AUTO_RELOAD=0` | don't apply a pending "reload to apply" by itself — leave it to the ↻ click |
|
|
1462
1473
|
| `SHADOK_AUTO_RELOAD_IDLE_SEC` | how long an agent must be quiet before that automatic reload (120) |
|
|
1474
|
+
| `SHADOK_CLAUDE_AUTO_INSTALL=0` | don't install a failed Claude Code self-update by itself — leave it to the ⚠ button |
|
|
1463
1475
|
| `SHADOK_SUBMIT_RECOVERY=0` | don't restart an agent whose terminal stopped taking input — report the failed message as an error instead |
|
|
1464
1476
|
| `SHADOK_PERMISSION_MODE` | mode new agents start in (default `acceptEdits`) |
|
|
1465
1477
|
| `SHADOK_AUTOUPDATE=0` | don't apply a newer release by itself (**ON by default** under the supervisor, i.e. `npx shadok-ai`; a server run directly never self-updates, since nothing would respawn it). `0`/`false` turns it off, `1`/`true` forces it on; the GUI setting wins over either once used |
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code auto-install: when an agent's TUI footer says
|
|
3
|
+
* "✗ Auto-update failed", install the update server-side, once, by itself.
|
|
4
|
+
*
|
|
5
|
+
* Claude Code updates its own binary, but on many instances it cannot: the
|
|
6
|
+
* global npm directory belongs to root while a privilege-dropped agent runs as
|
|
7
|
+
* its group's user, so its updater fails and the footer says so. The cockpit
|
|
8
|
+
* already had the cure — the badge's "install then reload" button
|
|
9
|
+
* (`POST /claude-update`) — but it waited for a human to notice the badge on
|
|
10
|
+
* each agent. The server sees every agent's screen, so it can do it instead.
|
|
11
|
+
*
|
|
12
|
+
* The reload half needs nothing new: once the binary changes, every agent
|
|
13
|
+
* spawned on the old one carries the `claude` staleness reason, and the
|
|
14
|
+
* auto-reload sweep respawns them one at a time when each has nothing to lose
|
|
15
|
+
* (`src/auto-reload.ts`).
|
|
16
|
+
*
|
|
17
|
+
* What this module decides is WHEN an install is worth starting, and the rule
|
|
18
|
+
* is built so that it can never run twice at once nor loop:
|
|
19
|
+
* - one install at a time — in this process (`inFlight`, the same promise the
|
|
20
|
+
* button uses) and across processes (`externalInstall`: npm's reify dir or
|
|
21
|
+
* our lock file says someone else is installing);
|
|
22
|
+
* - only a footer on an agent RUNNING THE INSTALLED BINARY counts. An agent
|
|
23
|
+
* spawned on an older binary still shows the failed footer until it is
|
|
24
|
+
* reloaded, and the install already happened — that agent needs a reload,
|
|
25
|
+
* not a second install. Without this, every install would be followed by
|
|
26
|
+
* another for as long as one agent stayed un-reloaded;
|
|
27
|
+
* - after an install (or a check that found nothing newer) nothing is
|
|
28
|
+
* retried for `settleMs`, and after a failure for `failureBackoffMs`: a
|
|
29
|
+
* footer that survives the cure (an updater failing for another reason, a
|
|
30
|
+
* phrase an agent merely printed at the bottom of its answer) must not turn
|
|
31
|
+
* into an npm install every 30 seconds.
|
|
32
|
+
*/
|
|
33
|
+
export interface AutoInstallInput {
|
|
34
|
+
/** `SHADOK_CLAUDE_AUTO_INSTALL` is not off. */
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
/** Agents whose footer reads "Auto-update failed" AND that run the binary
|
|
37
|
+
* installed right now (spawn version == current version, or unknown). */
|
|
38
|
+
failingOnCurrent: number;
|
|
39
|
+
/** This process is installing already (button or a previous sweep). */
|
|
40
|
+
inFlight: boolean;
|
|
41
|
+
/** Another process is installing (npm reify dir, or our lock held). */
|
|
42
|
+
externalInstall: boolean;
|
|
43
|
+
/** ms since the last attempt that ended in success or "already latest". */
|
|
44
|
+
sinceLastSettledMs: number;
|
|
45
|
+
/** ms since the last failed attempt. */
|
|
46
|
+
sinceLastFailureMs: number;
|
|
47
|
+
settleMs: number;
|
|
48
|
+
failureBackoffMs: number;
|
|
49
|
+
}
|
|
50
|
+
export type AutoInstallVerdict = {
|
|
51
|
+
install: true;
|
|
52
|
+
} | {
|
|
53
|
+
install: false;
|
|
54
|
+
why: string;
|
|
55
|
+
};
|
|
56
|
+
/** Pure: should the server start a Claude Code install right now? */
|
|
57
|
+
export declare function autoInstallVerdict(i: AutoInstallInput): AutoInstallVerdict;
|
|
58
|
+
/**
|
|
59
|
+
* Pure: does this agent's failed footer call for an INSTALL? Only when it runs
|
|
60
|
+
* the binary installed now — or when either version is unknown, since a failed
|
|
61
|
+
* `--version` probe must not hide a real failure (the time gates still bound it).
|
|
62
|
+
*/
|
|
63
|
+
export declare function failingOnInstalled(spawnVersion: string | null | undefined, currentVersion: string | null): boolean;
|
|
64
|
+
/** Pure: is the published version newer than the installed one? Unknown → assume yes. */
|
|
65
|
+
export declare function newerPublished(installed: string | null, published: string | null): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Pure: is a lock file (written with the time it was taken) still held? A
|
|
68
|
+
* lock older than `staleMs` belongs to an install that died without releasing
|
|
69
|
+
* it — an npm install never takes that long — so it no longer blocks anyone.
|
|
70
|
+
* Age only, never a pid: in a container pids are handed out again (invariant 45).
|
|
71
|
+
*/
|
|
72
|
+
export declare function lockHeld(takenAtMs: number | null, now: number, staleMs: number): boolean;
|
|
73
|
+
/** `SHADOK_CLAUDE_AUTO_INSTALL=0` turns it off; anything else (or unset) leaves it on. */
|
|
74
|
+
export declare function autoInstallEnabled(env: string | undefined): boolean;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code auto-install: when an agent's TUI footer says
|
|
3
|
+
* "✗ Auto-update failed", install the update server-side, once, by itself.
|
|
4
|
+
*
|
|
5
|
+
* Claude Code updates its own binary, but on many instances it cannot: the
|
|
6
|
+
* global npm directory belongs to root while a privilege-dropped agent runs as
|
|
7
|
+
* its group's user, so its updater fails and the footer says so. The cockpit
|
|
8
|
+
* already had the cure — the badge's "install then reload" button
|
|
9
|
+
* (`POST /claude-update`) — but it waited for a human to notice the badge on
|
|
10
|
+
* each agent. The server sees every agent's screen, so it can do it instead.
|
|
11
|
+
*
|
|
12
|
+
* The reload half needs nothing new: once the binary changes, every agent
|
|
13
|
+
* spawned on the old one carries the `claude` staleness reason, and the
|
|
14
|
+
* auto-reload sweep respawns them one at a time when each has nothing to lose
|
|
15
|
+
* (`src/auto-reload.ts`).
|
|
16
|
+
*
|
|
17
|
+
* What this module decides is WHEN an install is worth starting, and the rule
|
|
18
|
+
* is built so that it can never run twice at once nor loop:
|
|
19
|
+
* - one install at a time — in this process (`inFlight`, the same promise the
|
|
20
|
+
* button uses) and across processes (`externalInstall`: npm's reify dir or
|
|
21
|
+
* our lock file says someone else is installing);
|
|
22
|
+
* - only a footer on an agent RUNNING THE INSTALLED BINARY counts. An agent
|
|
23
|
+
* spawned on an older binary still shows the failed footer until it is
|
|
24
|
+
* reloaded, and the install already happened — that agent needs a reload,
|
|
25
|
+
* not a second install. Without this, every install would be followed by
|
|
26
|
+
* another for as long as one agent stayed un-reloaded;
|
|
27
|
+
* - after an install (or a check that found nothing newer) nothing is
|
|
28
|
+
* retried for `settleMs`, and after a failure for `failureBackoffMs`: a
|
|
29
|
+
* footer that survives the cure (an updater failing for another reason, a
|
|
30
|
+
* phrase an agent merely printed at the bottom of its answer) must not turn
|
|
31
|
+
* into an npm install every 30 seconds.
|
|
32
|
+
*/
|
|
33
|
+
/** Pure: should the server start a Claude Code install right now? */
|
|
34
|
+
export function autoInstallVerdict(i) {
|
|
35
|
+
const no = (why) => ({ install: false, why });
|
|
36
|
+
if (!i.enabled)
|
|
37
|
+
return no("disabled");
|
|
38
|
+
if (i.failingOnCurrent <= 0)
|
|
39
|
+
return no("no agent reports a failed update on the installed binary");
|
|
40
|
+
if (i.inFlight)
|
|
41
|
+
return no("an install is already running here");
|
|
42
|
+
if (i.externalInstall)
|
|
43
|
+
return no("another process is installing");
|
|
44
|
+
if (i.sinceLastSettledMs < i.settleMs)
|
|
45
|
+
return no("installed or checked recently");
|
|
46
|
+
if (i.sinceLastFailureMs < i.failureBackoffMs)
|
|
47
|
+
return no("last install failed recently");
|
|
48
|
+
return { install: true };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Pure: does this agent's failed footer call for an INSTALL? Only when it runs
|
|
52
|
+
* the binary installed now — or when either version is unknown, since a failed
|
|
53
|
+
* `--version` probe must not hide a real failure (the time gates still bound it).
|
|
54
|
+
*/
|
|
55
|
+
export function failingOnInstalled(spawnVersion, currentVersion) {
|
|
56
|
+
if (!spawnVersion || !currentVersion)
|
|
57
|
+
return true;
|
|
58
|
+
return spawnVersion === currentVersion;
|
|
59
|
+
}
|
|
60
|
+
/** Pure: is the published version newer than the installed one? Unknown → assume yes. */
|
|
61
|
+
export function newerPublished(installed, published) {
|
|
62
|
+
if (!installed || !published)
|
|
63
|
+
return true;
|
|
64
|
+
const a = installed.split(".").map(Number);
|
|
65
|
+
const b = published.split(".").map(Number);
|
|
66
|
+
if (a.some(Number.isNaN) || b.some(Number.isNaN))
|
|
67
|
+
return installed !== published;
|
|
68
|
+
for (let k = 0; k < Math.max(a.length, b.length); k++) {
|
|
69
|
+
const d = (b[k] ?? 0) - (a[k] ?? 0);
|
|
70
|
+
if (d !== 0)
|
|
71
|
+
return d > 0;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Pure: is a lock file (written with the time it was taken) still held? A
|
|
77
|
+
* lock older than `staleMs` belongs to an install that died without releasing
|
|
78
|
+
* it — an npm install never takes that long — so it no longer blocks anyone.
|
|
79
|
+
* Age only, never a pid: in a container pids are handed out again (invariant 45).
|
|
80
|
+
*/
|
|
81
|
+
export function lockHeld(takenAtMs, now, staleMs) {
|
|
82
|
+
return takenAtMs !== null && now - takenAtMs < staleMs;
|
|
83
|
+
}
|
|
84
|
+
/** `SHADOK_CLAUDE_AUTO_INSTALL=0` turns it off; anything else (or unset) leaves it on. */
|
|
85
|
+
export function autoInstallEnabled(env) {
|
|
86
|
+
return env === undefined || !/^(0|false|off|no)$/i.test(env.trim());
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=claude-auto-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-auto-update.js","sourceRoot":"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C,MAAM,CAAC,CAAC;IAC3C,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,KAAK,SAAS,CAAC;IACjF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACtD,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,SAAwB,EAAE,GAAW,EAAE,OAAe;IAC7E,OAAO,SAAS,KAAK,IAAI,IAAI,GAAG,GAAG,SAAS,GAAG,OAAO,CAAC;AACzD,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,kBAAkB,CAAC,GAAuB;IACxD,OAAO,GAAG,KAAK,SAAS,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AACtE,CAAC"}
|
package/dist/detect.d.ts
CHANGED
|
@@ -91,6 +91,22 @@ export declare function inputText(screen: string): string;
|
|
|
91
91
|
* way back in was the one that locked the door.
|
|
92
92
|
*/
|
|
93
93
|
export declare function inputBoxVisible(screen: string): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Is the input box TALLER than the pane?
|
|
96
|
+
*
|
|
97
|
+
* The one unambiguous "there IS text in there" signal a screen offers. Every
|
|
98
|
+
* other reading of the box has to tell text from the TUI's own furniture — the
|
|
99
|
+
* resting example (`❯ Try "refactor <filepath>"`), the greyed previous message
|
|
100
|
+
* — and both of those are ONE line. Nothing but text makes a box that tall: it
|
|
101
|
+
* is ours, or a prompt Claude Code put back when a turn was interrupted.
|
|
102
|
+
*
|
|
103
|
+
* Which is why it is worth a predicate of its own rather than being left to
|
|
104
|
+
* `survives`: that one compares the box's first VISIBLE line, and a box this
|
|
105
|
+
* tall has already scrolled that line off the top. Same rule as `boxRaw` —
|
|
106
|
+
* the scroll border counts only BELOW the last `❯`, or an older prompt line
|
|
107
|
+
* further up the conversation would make a normal box read as a scrolled one.
|
|
108
|
+
*/
|
|
109
|
+
export declare function boxScrolled(screen: string): boolean;
|
|
94
110
|
/**
|
|
95
111
|
* The WHOLE input box, not just its first line.
|
|
96
112
|
*
|
package/dist/detect.js
CHANGED
|
@@ -149,6 +149,33 @@ const BOX_SCROLLED = /^\s*[─━]{2,}\s*↑\s*(\d+)\s+more\s*[─━]{2,}/;
|
|
|
149
149
|
export function inputBoxVisible(screen) {
|
|
150
150
|
return screen.includes("❯") || screen.split("\n").some((l) => BOX_SCROLLED.test(l));
|
|
151
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Is the input box TALLER than the pane?
|
|
154
|
+
*
|
|
155
|
+
* The one unambiguous "there IS text in there" signal a screen offers. Every
|
|
156
|
+
* other reading of the box has to tell text from the TUI's own furniture — the
|
|
157
|
+
* resting example (`❯ Try "refactor <filepath>"`), the greyed previous message
|
|
158
|
+
* — and both of those are ONE line. Nothing but text makes a box that tall: it
|
|
159
|
+
* is ours, or a prompt Claude Code put back when a turn was interrupted.
|
|
160
|
+
*
|
|
161
|
+
* Which is why it is worth a predicate of its own rather than being left to
|
|
162
|
+
* `survives`: that one compares the box's first VISIBLE line, and a box this
|
|
163
|
+
* tall has already scrolled that line off the top. Same rule as `boxRaw` —
|
|
164
|
+
* the scroll border counts only BELOW the last `❯`, or an older prompt line
|
|
165
|
+
* further up the conversation would make a normal box read as a scrolled one.
|
|
166
|
+
*/
|
|
167
|
+
export function boxScrolled(screen) {
|
|
168
|
+
const lines = screen.split("\n");
|
|
169
|
+
let prompt = -1;
|
|
170
|
+
let scrolled = -1;
|
|
171
|
+
for (let i = 0; i < lines.length; i++) {
|
|
172
|
+
if (lines[i].trimStart().startsWith("❯") || /^!\s/.test(lines[i]))
|
|
173
|
+
prompt = i;
|
|
174
|
+
if (BOX_SCROLLED.test(lines[i]))
|
|
175
|
+
scrolled = i;
|
|
176
|
+
}
|
|
177
|
+
return scrolled > prompt;
|
|
178
|
+
}
|
|
152
179
|
/**
|
|
153
180
|
* The WHOLE input box, not just its first line.
|
|
154
181
|
*
|
|
@@ -604,6 +631,15 @@ async function hardClearIfLeftover(pilot, text, clearMs) {
|
|
|
604
631
|
* and a box that refuses gets one Ctrl-C before the attempt is abandoned.
|
|
605
632
|
*/
|
|
606
633
|
async function emptyBox(pilot, clearMs, text) {
|
|
634
|
+
// A box TALLER than the pane is the one Ctrl-U cannot win: the keypress
|
|
635
|
+
// clears a VISUAL row and that box is dozens of them — measured on a live
|
|
636
|
+
// pane (2.1.326), 120 presses did not empty an eight-chunk ledger prelude,
|
|
637
|
+
// while ONE Ctrl-C does. So the rescue kept for a box that will not clear is
|
|
638
|
+
// also the only one that scales to a box this size, and it is tried FIRST
|
|
639
|
+
// rather than after `MAX_CLEARS` presses have spent sixteen seconds of the
|
|
640
|
+
// message's own path getting nowhere.
|
|
641
|
+
if (boxScrolled(pilot.screen()))
|
|
642
|
+
await hardClearIfLeftover(pilot, text, clearMs);
|
|
607
643
|
let stuck = 0;
|
|
608
644
|
for (let press = 0; press < MAX_CLEARS && stuck < 2; press++) {
|
|
609
645
|
const shown = boxRaw(pilot.screen());
|
|
@@ -643,6 +679,16 @@ function survives(before, now) {
|
|
|
643
679
|
}
|
|
644
680
|
export async function typeIntoBox(pilot, text, { attempts = 6, appearMs = 2_000, settleMs = 400, clearMs = 1_000, prelude } = {}) {
|
|
645
681
|
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
682
|
+
// A box the pane cannot hold is provably text, not furniture
|
|
683
|
+
// (`boxScrolled`), and `survives` cannot be the one to catch it: it
|
|
684
|
+
// compares the box's first VISIBLE line, which a box that tall has
|
|
685
|
+
// scrolled off the top — so the leftover of a failed attempt reads as an
|
|
686
|
+
// empty box. Measured on a live pane: pasting a prelude onto an
|
|
687
|
+
// eight-chunk leftover reported "landed" and sent the message with the junk
|
|
688
|
+
// glued above it (113 hidden rows where a clean box gives 50). Costs
|
|
689
|
+
// nothing on the normal path, where a box at rest is one line.
|
|
690
|
+
if (boxScrolled(pilot.screen()))
|
|
691
|
+
await emptyBox(pilot, clearMs, text);
|
|
646
692
|
// "Landed" means the box DIFFERS from what it showed just before, not that
|
|
647
693
|
// it is non-empty: an empty box is not always blank. Before the first prompt
|
|
648
694
|
// of a session, Claude Code (seen on 2.1.285) fills it with an example —
|
package/dist/detect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,cAAc,GAClB,wDAAwD,CAAC;AAE3D,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,QAAQ,CACtB,MAAc,EACd,UAAkB,EAClB,WAAmB,EACnB,GAAW,EACX,QAAgB;IAEhB,IAAI,eAAe,CAAC,MAAM,CAAC,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QACrD,OAAO,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CAAC,CAAC;AAC/C,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -20,11 +20,13 @@ import { OFFER_TOOL, filesFileFor, loadOffers, saveOffers, offerVerdict, withOff
|
|
|
20
20
|
// Same implementation as the web client's preview (plain JS, loaded as is by
|
|
21
21
|
// the browser): one source for reading the in-flight text off the screen.
|
|
22
22
|
import { extractLiveText } from "../public/live-text.js";
|
|
23
|
+
import { claudeUpdateState } from "../public/update-ready.js";
|
|
23
24
|
import { findTransientErrors, newTransientErrors, RETRY_DELAYS_MS } from "./retry.js";
|
|
24
25
|
import { backgroundTasks, screenShowsWork, inputBoxVisible, moveToOption, boxText, SubmitError, IdleTimeoutError, keepWaitingAfterTimeout, idleTimeoutMessage } from "./detect.js";
|
|
25
26
|
import { submitRecoveryVerdict, submitWithRecovery, submitRecoveryEnabled, RECOVERY_COOLDOWN_MS, UnresponsiveError, UNRESPONSIVE_REPORT_TITLE, unresponsiveReportBody, } from "./submit-recovery.js";
|
|
26
27
|
import { busyLatchVerdict, busyLatchLog, BUSY_LATCH_GRACE_MS } from "./busy-latch.js";
|
|
27
28
|
import { autoReloadVerdict, autoReloadEnabled } from "./auto-reload.js";
|
|
29
|
+
import { autoInstallVerdict, autoInstallEnabled, failingOnInstalled, newerPublished, lockHeld } from "./claude-auto-update.js";
|
|
28
30
|
import { PtyPilot } from "./session.js";
|
|
29
31
|
import { ensureClaudeHome, ensureProjectTrusted, getDefaultModel, setDefaultModel, parseClaudeVersion, seedPlanForCwds, settingsPlan, } from "./claude-home.js";
|
|
30
32
|
import { mergeAppendedPrompts } from "./prompt-args.js";
|
|
@@ -7978,22 +7980,19 @@ app.get(["/media/:name", "/media/:key/:name"], (req, res) => {
|
|
|
7978
7980
|
// footer reports "Auto-update failed"; running agents still need a reload
|
|
7979
7981
|
// afterwards to pick up the new binary (the client does that). BROWSER-ONLY: a
|
|
7980
7982
|
// deliberate operator action, not something an agent should trigger for the
|
|
7981
|
-
// whole machine (cf. the profile-guardrail boundary).
|
|
7982
|
-
//
|
|
7983
|
-
|
|
7983
|
+
// whole machine (cf. the profile-guardrail boundary). The server now also does
|
|
7984
|
+
// it by itself (`claudeAutoInstallSweep`); both go through `installClaudeOnce`,
|
|
7985
|
+
// so a click and the sweep can never run two installs.
|
|
7984
7986
|
app.post("/claude-update", async (req, res) => {
|
|
7985
7987
|
if (!requestFromBrowser(req))
|
|
7986
7988
|
return res.status(403).json({ ok: false, error: "browser-only" });
|
|
7987
7989
|
try {
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7990
|
+
// The sweep may have installed it a minute ago: the badge on an agent not
|
|
7991
|
+
// reloaded yet still says "install", and a click must not reinstall.
|
|
7992
|
+
if (!claudeUpdateInFlight && Date.now() - claudeInstallSettledAt < CLAUDE_INSTALL_SETTLE_MS) {
|
|
7993
|
+
return res.json({ ok: true, already: true });
|
|
7991
7994
|
}
|
|
7992
|
-
await
|
|
7993
|
-
// The cached binary path rots on any reinstall (invariant 32): drop it so the
|
|
7994
|
-
// next spawn re-resolves the freshly installed launcher.
|
|
7995
|
-
claudeReady = null;
|
|
7996
|
-
rememberClaudeBin(null);
|
|
7995
|
+
await installClaudeOnce("button");
|
|
7997
7996
|
console.log("claude-update: install ok");
|
|
7998
7997
|
res.json({ ok: true });
|
|
7999
7998
|
}
|
|
@@ -8003,6 +8002,138 @@ app.post("/claude-update", async (req, res) => {
|
|
|
8003
8002
|
res.status(500).json({ ok: false, error });
|
|
8004
8003
|
}
|
|
8005
8004
|
});
|
|
8005
|
+
// ── Claude Code auto-install (see src/claude-auto-update.ts) ─────────────────
|
|
8006
|
+
const CLAUDE_AUTO_INSTALL = autoInstallEnabled(process.env.SHADOK_CLAUDE_AUTO_INSTALL);
|
|
8007
|
+
const CLAUDE_INSTALL_SETTLE_MS = 60 * 60_000;
|
|
8008
|
+
const CLAUDE_INSTALL_BACKOFF_MS = 30 * 60_000;
|
|
8009
|
+
const CLAUDE_INSTALL_LOCK_STALE_MS = 20 * 60_000;
|
|
8010
|
+
let claudeUpdateInFlight = null;
|
|
8011
|
+
let claudeInstallSettledAt = 0;
|
|
8012
|
+
let claudeInstallFailedAt = 0;
|
|
8013
|
+
/** Cross-process half of the single-flight: two shadok servers on one host share
|
|
8014
|
+
* the global npm directory, and two concurrent `npm i -g` collide (ENOTEMPTY).
|
|
8015
|
+
* `wx` creates the file only if absent — the one atomic test-and-set the fs has. */
|
|
8016
|
+
function claudeInstallLockFile() {
|
|
8017
|
+
return path.join(os.homedir(), ".shadok-ai", "claude-install.lock");
|
|
8018
|
+
}
|
|
8019
|
+
function readClaudeInstallLock() {
|
|
8020
|
+
try {
|
|
8021
|
+
const t = Number(fs.readFileSync(claudeInstallLockFile(), "utf8").trim());
|
|
8022
|
+
return Number.isFinite(t) ? t : 0;
|
|
8023
|
+
}
|
|
8024
|
+
catch {
|
|
8025
|
+
return null;
|
|
8026
|
+
}
|
|
8027
|
+
}
|
|
8028
|
+
function takeClaudeInstallLock() {
|
|
8029
|
+
const file = claudeInstallLockFile();
|
|
8030
|
+
if (lockHeld(readClaudeInstallLock(), Date.now(), CLAUDE_INSTALL_LOCK_STALE_MS))
|
|
8031
|
+
return false;
|
|
8032
|
+
try {
|
|
8033
|
+
fs.rmSync(file, { force: true });
|
|
8034
|
+
}
|
|
8035
|
+
catch { /* a stale lock we cannot remove: wx below fails */ }
|
|
8036
|
+
try {
|
|
8037
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
8038
|
+
fs.writeFileSync(file, String(Date.now()), { flag: "wx" });
|
|
8039
|
+
return true;
|
|
8040
|
+
}
|
|
8041
|
+
catch {
|
|
8042
|
+
return false; // someone took it between our read and our write
|
|
8043
|
+
}
|
|
8044
|
+
}
|
|
8045
|
+
/** THE one way to install Claude Code once it is running: the button, the
|
|
8046
|
+
* auto-install sweep and the missing-binary path all share this promise, and the
|
|
8047
|
+
* lock keeps another process out. The cached binary path rots on any reinstall
|
|
8048
|
+
* (invariant 32), and the version cache would hide the change from the staleness
|
|
8049
|
+
* sweep for a minute: both are dropped on success, so the reload half starts at
|
|
8050
|
+
* once. */
|
|
8051
|
+
function installClaudeOnce(by) {
|
|
8052
|
+
if (claudeUpdateInFlight)
|
|
8053
|
+
return claudeUpdateInFlight;
|
|
8054
|
+
if (!takeClaudeInstallLock())
|
|
8055
|
+
return Promise.reject(new Error("another Claude Code install is already running on this machine"));
|
|
8056
|
+
console.log(`claude-update: installing @anthropic-ai/claude-code (npm i -g) — ${by}`);
|
|
8057
|
+
claudeUpdateInFlight = installClaudeCli()
|
|
8058
|
+
.then(() => {
|
|
8059
|
+
claudeInstallSettledAt = Date.now();
|
|
8060
|
+
claudeReady = null;
|
|
8061
|
+
rememberClaudeBin(null);
|
|
8062
|
+
claudeVerCache = null;
|
|
8063
|
+
})
|
|
8064
|
+
.catch((e) => {
|
|
8065
|
+
claudeInstallFailedAt = Date.now();
|
|
8066
|
+
throw e;
|
|
8067
|
+
})
|
|
8068
|
+
.finally(() => {
|
|
8069
|
+
claudeUpdateInFlight = null;
|
|
8070
|
+
try {
|
|
8071
|
+
fs.rmSync(claudeInstallLockFile(), { force: true });
|
|
8072
|
+
}
|
|
8073
|
+
catch { /* stale after 20 min anyway */ }
|
|
8074
|
+
});
|
|
8075
|
+
return claudeUpdateInFlight;
|
|
8076
|
+
}
|
|
8077
|
+
/** The version npm would install, or null when the registry cannot say. */
|
|
8078
|
+
function publishedClaudeVersion() {
|
|
8079
|
+
return new Promise((resolve) => {
|
|
8080
|
+
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
8081
|
+
execFile(npm, ["view", "@anthropic-ai/claude-code", "version"], { timeout: 30_000 }, (err, out) => resolve(err ? null : parseClaudeVersion(String(out)) ?? (String(out).trim() || null)));
|
|
8082
|
+
});
|
|
8083
|
+
}
|
|
8084
|
+
/** Every 30 s, beside the auto-reload sweep: an agent's footer says its own
|
|
8085
|
+
* update failed → install it for everyone, once. The reload follows through the
|
|
8086
|
+
* `claude` staleness reason. */
|
|
8087
|
+
let claudeAutoInstallChecking = false;
|
|
8088
|
+
async function claudeAutoInstallSweep() {
|
|
8089
|
+
if (!CLAUDE_AUTO_INSTALL || claudeAutoInstallChecking)
|
|
8090
|
+
return;
|
|
8091
|
+
const channels = loadChannels();
|
|
8092
|
+
let failing = 0;
|
|
8093
|
+
let current;
|
|
8094
|
+
for (const s of sessions.values()) {
|
|
8095
|
+
if (s.pilot.hasExited || claudeUpdateState(s.pilot.screen()) !== "failed")
|
|
8096
|
+
continue;
|
|
8097
|
+
if (current === undefined)
|
|
8098
|
+
current = currentClaudeVersion();
|
|
8099
|
+
const spawnVer = channels.find((c) => c.sessionId === s.id)?.spawnClaudeVer ?? null;
|
|
8100
|
+
if (failingOnInstalled(spawnVer, current))
|
|
8101
|
+
failing++;
|
|
8102
|
+
}
|
|
8103
|
+
const now = Date.now();
|
|
8104
|
+
const verdict = autoInstallVerdict({
|
|
8105
|
+
enabled: CLAUDE_AUTO_INSTALL,
|
|
8106
|
+
failingOnCurrent: failing,
|
|
8107
|
+
inFlight: !!claudeUpdateInFlight,
|
|
8108
|
+
externalInstall: claudeInstallInProgress() || lockHeld(readClaudeInstallLock(), now, CLAUDE_INSTALL_LOCK_STALE_MS),
|
|
8109
|
+
sinceLastSettledMs: now - claudeInstallSettledAt,
|
|
8110
|
+
sinceLastFailureMs: now - claudeInstallFailedAt,
|
|
8111
|
+
settleMs: CLAUDE_INSTALL_SETTLE_MS,
|
|
8112
|
+
failureBackoffMs: CLAUDE_INSTALL_BACKOFF_MS,
|
|
8113
|
+
});
|
|
8114
|
+
if (!verdict.install)
|
|
8115
|
+
return;
|
|
8116
|
+
claudeAutoInstallChecking = true;
|
|
8117
|
+
try {
|
|
8118
|
+
// A footer is a screen heuristic (invariant 2): ask the registry before
|
|
8119
|
+
// pulling a few hundred MB. Nothing newer → settle, nothing installed.
|
|
8120
|
+
const installed = current ?? currentClaudeVersion();
|
|
8121
|
+
const published = await publishedClaudeVersion();
|
|
8122
|
+
if (!newerPublished(installed, published)) {
|
|
8123
|
+
claudeInstallSettledAt = Date.now();
|
|
8124
|
+
console.log(`claude-update: ${failing} agent(s) report a failed auto-update, but ${installed} is already the latest — nothing to install`);
|
|
8125
|
+
return;
|
|
8126
|
+
}
|
|
8127
|
+
await installClaudeOnce(`auto: ${failing} agent(s) report a failed auto-update (${installed ?? "?"} → ${published ?? "latest"})`);
|
|
8128
|
+
console.log(`claude-update: auto-install ok (now ${currentClaudeVersion() ?? "?"}) — idle agents reload onto it one at a time`);
|
|
8129
|
+
}
|
|
8130
|
+
catch (e) {
|
|
8131
|
+
console.log(`claude-update: auto-install FAILED — ${e instanceof Error ? e.message : e} (next try in ${CLAUDE_INSTALL_BACKOFF_MS / 60_000} min)`);
|
|
8132
|
+
}
|
|
8133
|
+
finally {
|
|
8134
|
+
claudeAutoInstallChecking = false;
|
|
8135
|
+
}
|
|
8136
|
+
}
|
|
8006
8137
|
// The shared-ledger table — ONE per instance (keyed by the launch dir). Read by
|
|
8007
8138
|
// the GUI viewer (the version-menu / header button) AND by the `shadok-ledger`
|
|
8008
8139
|
// CLI's `check`/`list` (which run their own recall over these rows). Filtered by
|
|
@@ -9347,6 +9478,12 @@ function pendingReloadReasons(s, channels) {
|
|
|
9347
9478
|
const out = sessionStaleness(s, channels).map((r) => r.kind);
|
|
9348
9479
|
if ((s.appliedProfile ?? null) !== (s.profile ?? null))
|
|
9349
9480
|
out.push("profile");
|
|
9481
|
+
// Claude Code's own footer: "Update installed · Restart to apply". Its updater
|
|
9482
|
+
// may have written a binary the server's `claude --version` never sees (a
|
|
9483
|
+
// per-user install), so the `claude` reason above can miss it. The backoff in
|
|
9484
|
+
// autoReloadVerdict keeps a footer that survives the reload from looping.
|
|
9485
|
+
if (!out.includes("claude") && !s.pilot.hasExited && claudeUpdateState(s.pilot.screen()) === "restart")
|
|
9486
|
+
out.push("claude-restart");
|
|
9350
9487
|
return out;
|
|
9351
9488
|
}
|
|
9352
9489
|
async function autoReloadSweep() {
|
|
@@ -9594,7 +9731,7 @@ function ensureClaudeOnce(revalidate = true) {
|
|
|
9594
9731
|
// transient, so failing hard on the first sample would report a healthy
|
|
9595
9732
|
// install as broken. Nothing here runs at boot.
|
|
9596
9733
|
find: () => findClaudeBinWithRetry(liveClaudeDeps()),
|
|
9597
|
-
install:
|
|
9734
|
+
install: () => installClaudeOnce("missing binary"),
|
|
9598
9735
|
// Claude Code's auto-updater reinstalls the package in place; installing
|
|
9599
9736
|
// over it is how a fresh instance's first agent died on ENOTEMPTY.
|
|
9600
9737
|
installInProgress: claudeInstallInProgress,
|
|
@@ -12404,7 +12541,12 @@ server.listen(port, HOST, () => {
|
|
|
12404
12541
|
staleTimer.unref();
|
|
12405
12542
|
// Auto-reload: twice a minute, respawn (at most) one idle agent that is
|
|
12406
12543
|
// behind — the "reload to apply" badge applying itself. See autoReloadSweep.
|
|
12407
|
-
|
|
12544
|
+
// The install half first: a failed Claude Code self-update on any agent is
|
|
12545
|
+
// installed once, server-side, and the reload sweep then picks it up.
|
|
12546
|
+
const autoReloadTimer = setInterval(() => {
|
|
12547
|
+
void claudeAutoInstallSweep().catch(() => { });
|
|
12548
|
+
void autoReloadSweep().catch(() => { });
|
|
12549
|
+
}, 30_000);
|
|
12408
12550
|
autoReloadTimer.unref();
|
|
12409
12551
|
// The lead agent, if this instance has none. Deferred a beat so it dials a
|
|
12410
12552
|
// server that is already accepting, and never awaited: a cockpit that starts
|