shadok-ai 0.11.1 → 0.11.3
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 +11 -1
- package/dist/claude-bin.d.ts +45 -0
- package/dist/claude-bin.js +70 -0
- package/dist/claude-bin.js.map +1 -1
- package/dist/first-agent.d.ts +40 -0
- package/dist/first-agent.js +40 -1
- package/dist/first-agent.js.map +1 -1
- package/dist/server.js +32 -3
- package/dist/server.js.map +1 -1
- package/dist/tmux.js +10 -0
- package/dist/tmux.js.map +1 -1
- package/package.json +1 -1
- package/public/index.html +79 -10
package/README.md
CHANGED
|
@@ -165,6 +165,14 @@ Enter to skip; you can add it later from the web UI).
|
|
|
165
165
|
a brand-new instance (which is signed out at boot, so there is nothing to
|
|
166
166
|
spawn yet). The condition is "no channel", which makes it idempotent: it never
|
|
167
167
|
appears twice.
|
|
168
|
+
While it is being started the central panel says so — *starting your first
|
|
169
|
+
agent…* — instead of the *no agent open* invitation, which would ask you to
|
|
170
|
+
create a second one while the first is being born. It is a status, not a
|
|
171
|
+
screen: nothing to click, nothing to dismiss, and it ends on its own whichever
|
|
172
|
+
way the spawn goes (started, refused because the instance is signed out,
|
|
173
|
+
failed). The two look identical from the browser — an empty cockpit is an
|
|
174
|
+
empty cockpit — so the server is asked (`GET /first-agent`) rather than
|
|
175
|
+
guessed at, and the agent list is reconciled faster while the answer is yes.
|
|
168
176
|
It is the environment's **home base**: pinned at the top of the list, with no
|
|
169
177
|
close button and no *Close agent* in its menu. You can still reload, rename,
|
|
170
178
|
re-profile or mute it — "permanent" should not mean "stuck". A cockpit that
|
|
@@ -580,7 +588,9 @@ cockpit's name, per launch directory: click the header brand to rename it, so
|
|
|
580
588
|
several cockpits stay apart in the tab bar; an empty PUT reverts to the default),
|
|
581
589
|
`/theme` (GET/PUT — the cockpit's colour palette, per launch directory: an accent
|
|
582
590
|
key picked from the ⋯ menu, e.g. `emerald`; unknown/`amber` reverts to default),
|
|
583
|
-
`/profiles`, `/secrets`, `/telegram`, `/defaults`, `/
|
|
591
|
+
`/profiles`, `/secrets`, `/telegram`, `/defaults`, `/first-agent` (GET —
|
|
592
|
+
`{pending, reason}`: whether this instance's lead agent is being started
|
|
593
|
+
right now), `/version`, `/autoupdate`,
|
|
584
594
|
`/update-channel` (POST `{channel}` — `alpha` or `beta`), `/permission-mode`, `/tweak/prepare` (POST — clone/refresh shadok-ai's own source,
|
|
585
595
|
returns the cwd to start the tweak agent in), and the sign-in group: `/auth` (GET
|
|
586
596
|
— `{loggedIn, email?, subscriptionType?}`), `/auth/login` (POST — start a flow,
|
package/dist/claude-bin.d.ts
CHANGED
|
@@ -94,6 +94,51 @@ export interface RetryOptions {
|
|
|
94
94
|
* hold the server back from serving).
|
|
95
95
|
*/
|
|
96
96
|
export declare function findClaudeBinWithRetry(deps: FindClaudeDeps, opts?: RetryOptions): Promise<ClaudeBin>;
|
|
97
|
+
/**
|
|
98
|
+
* Is this the kernel refusing to run a binary that is being rewritten?
|
|
99
|
+
*
|
|
100
|
+
* ETXTBSY — "text file busy", where "text" is the old Unix word for a
|
|
101
|
+
* program's CODE segment, nothing to do with text files. The kernel refuses
|
|
102
|
+
* both directions: writing a file that is executing, and executing a file that
|
|
103
|
+
* is being written. It is the second that reaches us.
|
|
104
|
+
*
|
|
105
|
+
* Every `@anthropic-ai/claude-code` upgrade rewrites a ~214 MB native binary in
|
|
106
|
+
* place, so the window is SECONDS wide rather than microseconds, and a machine
|
|
107
|
+
* that follows releases hits it repeatedly — three times in one day here, each
|
|
108
|
+
* time killing an agent spawn and reporting it as a death.
|
|
109
|
+
*
|
|
110
|
+
* This is a DIFFERENT failure from invariant 32, and the difference decides the
|
|
111
|
+
* cure. There the file is the wrong thing (the npm placeholder) and reinstalling
|
|
112
|
+
* makes it worse, so we say what is wrong and stop. Here the file is exactly
|
|
113
|
+
* right and merely busy — the condition is transient by construction, resolves
|
|
114
|
+
* on its own, and the only possible mistake is concluding too early.
|
|
115
|
+
*
|
|
116
|
+
* `findClaudeBinWithRetry` cannot help: it retries a STAT, and a busy binary
|
|
117
|
+
* stats perfectly. You only learn at `execve`.
|
|
118
|
+
*/
|
|
119
|
+
export declare function isBinaryBusyError(e: unknown): boolean;
|
|
120
|
+
/** Marks a spawn that failed because the pane's command never got to run. */
|
|
121
|
+
export declare function binaryBusyError(what: string): Error;
|
|
122
|
+
export declare const BINARY_BUSY_TRIES = 6;
|
|
123
|
+
export declare const BINARY_BUSY_DELAY_MS = 500;
|
|
124
|
+
/**
|
|
125
|
+
* Runs a pilot's synchronous `start()`, waiting out a binary that is mid-upgrade.
|
|
126
|
+
*
|
|
127
|
+
* The retry lives HERE and not inside `start()` because both pilots' `start()`
|
|
128
|
+
* are synchronous: waiting there would block the event loop for every other
|
|
129
|
+
* agent. `attachPilot` is already async, so this is the first place that can
|
|
130
|
+
* afford to wait at all.
|
|
131
|
+
*
|
|
132
|
+
* Only a busy binary is retried. Any other failure is rethrown at once — a
|
|
133
|
+
* missing binary or a bad path does not get better by being asked six times,
|
|
134
|
+
* and burying it under three seconds of retries would hide the real message.
|
|
135
|
+
*/
|
|
136
|
+
export declare function startWithBusyRetry(start: () => void, opts?: {
|
|
137
|
+
tries?: number;
|
|
138
|
+
delayMs?: number;
|
|
139
|
+
sleep?: (ms: number) => Promise<void>;
|
|
140
|
+
onRetry?: (attempt: number, tries: number) => void;
|
|
141
|
+
}): Promise<void>;
|
|
97
142
|
/** Live deps for {@link findClaudeBin}, reading the real filesystem. */
|
|
98
143
|
export declare function liveClaudeDeps(): FindClaudeDeps;
|
|
99
144
|
/**
|
package/dist/claude-bin.js
CHANGED
|
@@ -210,6 +210,76 @@ export async function findClaudeBinWithRetry(deps, opts = {}) {
|
|
|
210
210
|
}
|
|
211
211
|
return last;
|
|
212
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Is this the kernel refusing to run a binary that is being rewritten?
|
|
215
|
+
*
|
|
216
|
+
* ETXTBSY — "text file busy", where "text" is the old Unix word for a
|
|
217
|
+
* program's CODE segment, nothing to do with text files. The kernel refuses
|
|
218
|
+
* both directions: writing a file that is executing, and executing a file that
|
|
219
|
+
* is being written. It is the second that reaches us.
|
|
220
|
+
*
|
|
221
|
+
* Every `@anthropic-ai/claude-code` upgrade rewrites a ~214 MB native binary in
|
|
222
|
+
* place, so the window is SECONDS wide rather than microseconds, and a machine
|
|
223
|
+
* that follows releases hits it repeatedly — three times in one day here, each
|
|
224
|
+
* time killing an agent spawn and reporting it as a death.
|
|
225
|
+
*
|
|
226
|
+
* This is a DIFFERENT failure from invariant 32, and the difference decides the
|
|
227
|
+
* cure. There the file is the wrong thing (the npm placeholder) and reinstalling
|
|
228
|
+
* makes it worse, so we say what is wrong and stop. Here the file is exactly
|
|
229
|
+
* right and merely busy — the condition is transient by construction, resolves
|
|
230
|
+
* on its own, and the only possible mistake is concluding too early.
|
|
231
|
+
*
|
|
232
|
+
* `findClaudeBinWithRetry` cannot help: it retries a STAT, and a busy binary
|
|
233
|
+
* stats perfectly. You only learn at `execve`.
|
|
234
|
+
*/
|
|
235
|
+
export function isBinaryBusyError(e) {
|
|
236
|
+
if (!e)
|
|
237
|
+
return false;
|
|
238
|
+
const code = e.code;
|
|
239
|
+
if (code === "ETXTBSY")
|
|
240
|
+
return true;
|
|
241
|
+
// node-pty surfaces the errno inside a message rather than as `code`, and a
|
|
242
|
+
// shell in between may too. Matching the token is what actually catches it.
|
|
243
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
244
|
+
return /\bETXTBSY\b|text file busy/i.test(msg);
|
|
245
|
+
}
|
|
246
|
+
/** Marks a spawn that failed because the pane's command never got to run. */
|
|
247
|
+
export function binaryBusyError(what) {
|
|
248
|
+
const e = new Error(`${what} could not be executed (ETXTBSY: the binary is being rewritten)`);
|
|
249
|
+
e.code = "ETXTBSY";
|
|
250
|
+
return e;
|
|
251
|
+
}
|
|
252
|
+
export const BINARY_BUSY_TRIES = 6;
|
|
253
|
+
export const BINARY_BUSY_DELAY_MS = 500;
|
|
254
|
+
/**
|
|
255
|
+
* Runs a pilot's synchronous `start()`, waiting out a binary that is mid-upgrade.
|
|
256
|
+
*
|
|
257
|
+
* The retry lives HERE and not inside `start()` because both pilots' `start()`
|
|
258
|
+
* are synchronous: waiting there would block the event loop for every other
|
|
259
|
+
* agent. `attachPilot` is already async, so this is the first place that can
|
|
260
|
+
* afford to wait at all.
|
|
261
|
+
*
|
|
262
|
+
* Only a busy binary is retried. Any other failure is rethrown at once — a
|
|
263
|
+
* missing binary or a bad path does not get better by being asked six times,
|
|
264
|
+
* and burying it under three seconds of retries would hide the real message.
|
|
265
|
+
*/
|
|
266
|
+
export async function startWithBusyRetry(start, opts = {}) {
|
|
267
|
+
const tries = Math.max(1, opts.tries ?? BINARY_BUSY_TRIES);
|
|
268
|
+
const delayMs = opts.delayMs ?? BINARY_BUSY_DELAY_MS;
|
|
269
|
+
const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
270
|
+
for (let i = 1;; i++) {
|
|
271
|
+
try {
|
|
272
|
+
start();
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
catch (e) {
|
|
276
|
+
if (!isBinaryBusyError(e) || i >= tries)
|
|
277
|
+
throw e;
|
|
278
|
+
opts.onRetry?.(i, tries);
|
|
279
|
+
await sleep(delayMs);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
213
283
|
/** Live deps for {@link findClaudeBin}, reading the real filesystem. */
|
|
214
284
|
export function liveClaudeDeps() {
|
|
215
285
|
return {
|
package/dist/claude-bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-bin.js","sourceRoot":"","sources":["../src/claude-bin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,GAAG,2BAA2B,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,UAAU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,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IAC5H,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,CAAC,4FAA4F,CAAC,CAAC;QAC1G,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IACxC,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE,CAAC;IAC9E,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAoB,CAAC,oDAAoD,CAAC,EAAE,CAAC;AAC1G,CAAC"}
|
package/dist/first-agent.d.ts
CHANGED
|
@@ -30,6 +30,46 @@ export declare function firstAgentPlan(input: {
|
|
|
30
30
|
channelCount: number;
|
|
31
31
|
authState: AuthState;
|
|
32
32
|
}): FirstAgentPlan;
|
|
33
|
+
/**
|
|
34
|
+
* What the cockpit is allowed to SAY while it has no agent to show.
|
|
35
|
+
*
|
|
36
|
+
* The browser cannot work this out on its own: "a first agent is on its way"
|
|
37
|
+
* and "the user closed their last tab" are the same zero channels (invariant
|
|
38
|
+
* 18, which is why `active` can be null). Guessing picks one of two wrong
|
|
39
|
+
* answers — either a returning user is told forever that their first agent is
|
|
40
|
+
* starting, or a brand-new one is invited to create a SECOND lead agent while
|
|
41
|
+
* the first is being born. So the side doing the spawning says which it is.
|
|
42
|
+
*
|
|
43
|
+
* The state is deliberately hard to leave switched on. Every exit from
|
|
44
|
+
* `ensureFirstAgent` goes through `settleFirstAgent`, including the ones that
|
|
45
|
+
* spawn nothing (`not-signed-in`, `channels-exist`), the socket erroring and
|
|
46
|
+
* the 60s guard — because a flag that could stick would leave a signed-out
|
|
47
|
+
* cockpit reading "starting your first agent…" forever, which is a worse first
|
|
48
|
+
* impression than the empty state this replaces.
|
|
49
|
+
*/
|
|
50
|
+
export interface FirstAgentStatus {
|
|
51
|
+
/** Is a lead agent genuinely being started right now? */
|
|
52
|
+
pending: boolean;
|
|
53
|
+
/** Why — the plan's reason once one has been computed, before that "starting". */
|
|
54
|
+
reason: FirstAgentPlan["reason"] | "starting" | "idle";
|
|
55
|
+
}
|
|
56
|
+
/** A copy, so no caller can hold a handle on the state and edit it. */
|
|
57
|
+
export declare function firstAgentStatus(): FirstAgentStatus;
|
|
58
|
+
/**
|
|
59
|
+
* Say a spawn is coming, BEFORE the attempt itself.
|
|
60
|
+
*
|
|
61
|
+
* The boot path defers `ensureFirstAgent` a beat (so it dials a server already
|
|
62
|
+
* accepting) and opens the browser first — so without this the very page this
|
|
63
|
+
* status exists for loads during that gap and is told "idle", which is the bug.
|
|
64
|
+
* The auth probe inside `ensureFirstAgent` costs another ~850ms on top.
|
|
65
|
+
*
|
|
66
|
+
* Authoritative, not sticky: called with channels present it CLEARS the flag
|
|
67
|
+
* rather than leaving a stale one — an instance that has agents has nothing
|
|
68
|
+
* pending by definition.
|
|
69
|
+
*/
|
|
70
|
+
export declare function announceFirstAgent(channelCount: number): void;
|
|
71
|
+
/** The one way out of `pending`. Never conditional: every reason ends the wait. */
|
|
72
|
+
export declare function settleFirstAgent(reason: FirstAgentPlan["reason"]): void;
|
|
33
73
|
/**
|
|
34
74
|
* Start the lead agent if this instance has none. Idempotent by construction:
|
|
35
75
|
* the condition is "no channel at all", so both callers can call it freely.
|
package/dist/first-agent.js
CHANGED
|
@@ -32,6 +32,33 @@ export function firstAgentPlan(input) {
|
|
|
32
32
|
return { spawn: false, reason: "not-signed-in" };
|
|
33
33
|
return { spawn: true, reason: "first-boot", name: FIRST_AGENT_NAME, profile: BOSS_PROFILE_NAME };
|
|
34
34
|
}
|
|
35
|
+
let status = { pending: false, reason: "idle" };
|
|
36
|
+
/** A copy, so no caller can hold a handle on the state and edit it. */
|
|
37
|
+
export function firstAgentStatus() {
|
|
38
|
+
return { ...status };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Say a spawn is coming, BEFORE the attempt itself.
|
|
42
|
+
*
|
|
43
|
+
* The boot path defers `ensureFirstAgent` a beat (so it dials a server already
|
|
44
|
+
* accepting) and opens the browser first — so without this the very page this
|
|
45
|
+
* status exists for loads during that gap and is told "idle", which is the bug.
|
|
46
|
+
* The auth probe inside `ensureFirstAgent` costs another ~850ms on top.
|
|
47
|
+
*
|
|
48
|
+
* Authoritative, not sticky: called with channels present it CLEARS the flag
|
|
49
|
+
* rather than leaving a stale one — an instance that has agents has nothing
|
|
50
|
+
* pending by definition.
|
|
51
|
+
*/
|
|
52
|
+
export function announceFirstAgent(channelCount) {
|
|
53
|
+
status =
|
|
54
|
+
channelCount > 0
|
|
55
|
+
? { pending: false, reason: "channels-exist" }
|
|
56
|
+
: { pending: true, reason: "starting" };
|
|
57
|
+
}
|
|
58
|
+
/** The one way out of `pending`. Never conditional: every reason ends the wait. */
|
|
59
|
+
export function settleFirstAgent(reason) {
|
|
60
|
+
status = { pending: false, reason };
|
|
61
|
+
}
|
|
35
62
|
/** Guards the two callers (boot, sign-in) against firing at the same moment. */
|
|
36
63
|
let inFlight = false;
|
|
37
64
|
/**
|
|
@@ -48,8 +75,15 @@ export async function ensureFirstAgent(deps) {
|
|
|
48
75
|
channelCount: loadChannels().length,
|
|
49
76
|
authState: (await authStatus()).state,
|
|
50
77
|
});
|
|
51
|
-
if (!plan.spawn)
|
|
78
|
+
if (!plan.spawn) {
|
|
79
|
+
settleFirstAgent(plan.reason);
|
|
52
80
|
return plan.reason;
|
|
81
|
+
}
|
|
82
|
+
// The sign-in path reaches here without the boot path's announcement, and the
|
|
83
|
+
// auth probe above has just spent ~850ms — say it now, so the window in which
|
|
84
|
+
// the page could be told "idle" while a spawn is under way is closed at both
|
|
85
|
+
// ends rather than only at boot.
|
|
86
|
+
announceFirstAgent(0);
|
|
53
87
|
inFlight = true;
|
|
54
88
|
try {
|
|
55
89
|
await new Promise((resolve) => {
|
|
@@ -100,6 +134,11 @@ export async function ensureFirstAgent(deps) {
|
|
|
100
134
|
}
|
|
101
135
|
finally {
|
|
102
136
|
inFlight = false;
|
|
137
|
+
// In the `finally` on purpose: the spawn resolves on `ready`, on `error`,
|
|
138
|
+
// on `exited`, on a socket failure and on the 60s guard, and every one of
|
|
139
|
+
// them has to end the "starting…" status. `onReady` has already written the
|
|
140
|
+
// channel by now, so the client sees the tab and the cleared flag together.
|
|
141
|
+
settleFirstAgent("first-boot");
|
|
103
142
|
}
|
|
104
143
|
return "first-boot";
|
|
105
144
|
}
|
package/dist/first-agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"first-agent.js","sourceRoot":"","sources":["../src/first-agent.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAkB,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;;;;;;;;;;GAWG;AAEH,uDAAuD;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAS1C;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAG9B;IACC,IAAI,KAAK,CAAC,YAAY,GAAG,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC9E,0EAA0E;IAC1E,iFAAiF;IACjF,IAAI,KAAK,CAAC,SAAS,KAAK,WAAW;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IACtF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,gBAAgB,EAA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I,CAAC,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;oBACtC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,IAAK,CAAC,CAAC;oBACtC,MAAM,EAAE,CAAC;gBACX,CAAC;qBAAM,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACrD,MAAM,EAAE,CAAC;gBACX,CAAC;YACH,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACvB,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,QAAQ,GAAG,KAAK,CAAC;QACjB,0EAA0E;QAC1E,0EAA0E;QAC1E,4EAA4E;QAC5E,4EAA4E;QAC5E,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -18,7 +18,7 @@ import { PtyPilot } from "./session.js";
|
|
|
18
18
|
import { ensureClaudeHome, ensureProjectTrusted } from "./claude-home.js";
|
|
19
19
|
import { authStatus, cancelLogin, startLogin, submitLoginCode } from "./claude-auth.js";
|
|
20
20
|
import { starCount } from "./stars.js";
|
|
21
|
-
import { ensureFirstAgent } from "./first-agent.js";
|
|
21
|
+
import { announceFirstAgent, ensureFirstAgent, firstAgentStatus, settleFirstAgent, } from "./first-agent.js";
|
|
22
22
|
import { readGroundAt } from "./ground.js";
|
|
23
23
|
import { homeGreetingBrief } from "./greeting.js";
|
|
24
24
|
import { ensureSshIdentity } from "./ssh.js";
|
|
@@ -53,7 +53,7 @@ import { acquireInstanceLock, releaseInstanceLock } from "./lock.js";
|
|
|
53
53
|
import { bindRefusal, originAllowed, parseOrigins, resolveHost, browserOrigin, } from "./net.js";
|
|
54
54
|
import { pctFromUsage, windowForModel } from "./context.js";
|
|
55
55
|
import { startHeartbeat } from "./heartbeat.js";
|
|
56
|
-
import { ensureClaude, claudeCommand, classifyBin, findClaudeBinWithRetry, liveClaudeDeps, rememberClaudeBin, resolveBin, sampleBin, } from "./claude-bin.js";
|
|
56
|
+
import { ensureClaude, claudeCommand, classifyBin, findClaudeBinWithRetry, startWithBusyRetry, liveClaudeDeps, rememberClaudeBin, resolveBin, sampleBin, } from "./claude-bin.js";
|
|
57
57
|
import { ensureTmux, tmuxInstallCommand } from "./tmux-install.js";
|
|
58
58
|
import { cspHeader, injectNonce, NONCE_PLACEHOLDER, injectAssetVersion, injectInstanceKey } from "./csp.js";
|
|
59
59
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -183,6 +183,9 @@ function greetHomeAgent(id) {
|
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
185
|
async function startFirstAgent() {
|
|
186
|
+
// Before the attempt, not after it: the browser may already be loading, and
|
|
187
|
+
// the empty state it would otherwise paint invites a SECOND lead agent.
|
|
188
|
+
announceFirstAgent(loadChannels().length);
|
|
186
189
|
try {
|
|
187
190
|
const why = await ensureFirstAgent({
|
|
188
191
|
port: boundPort,
|
|
@@ -205,6 +208,11 @@ async function startFirstAgent() {
|
|
|
205
208
|
console.log(`first agent: skipped (${why})`);
|
|
206
209
|
}
|
|
207
210
|
catch (e) {
|
|
211
|
+
// `ensureFirstAgent` settles its own status in a `finally`, but it can also
|
|
212
|
+
// throw BEFORE reaching it (reading the channel list, probing auth). A
|
|
213
|
+
// cockpit stuck on "starting your first agent…" is exactly what this
|
|
214
|
+
// feature must never produce, so the outermost handler ends the wait too.
|
|
215
|
+
settleFirstAgent("not-signed-in");
|
|
208
216
|
console.log(`first agent: could not start — ${e instanceof Error ? e.message : String(e)}`);
|
|
209
217
|
}
|
|
210
218
|
}
|
|
@@ -967,6 +975,17 @@ app.get("/defaults", (_req, res) => {
|
|
|
967
975
|
// share it. One source of truth with the server's own per-dir keying.
|
|
968
976
|
res.json({ cwd: process.cwd(), instanceKey: instanceKey() });
|
|
969
977
|
});
|
|
978
|
+
// Is the instance's lead agent on its way? A page with no channel cannot tell
|
|
979
|
+
// "one is being born" from "you closed your last tab" — both are zero channels
|
|
980
|
+
// (invariant 18) — and the difference decides whether it invites the user to
|
|
981
|
+
// create an agent or asks them to wait. Its own route rather than a field on
|
|
982
|
+
// `/defaults`, because the two have different lifetimes: `/defaults` hands out
|
|
983
|
+
// facts that cannot change under the page (the launch dir, its `instanceKey`)
|
|
984
|
+
// and is read once, while this one changes while the page watches and is
|
|
985
|
+
// POLLED — for as long as it answers `pending`, and never after.
|
|
986
|
+
app.get("/first-agent", (_req, res) => {
|
|
987
|
+
res.json(firstAgentStatus());
|
|
988
|
+
});
|
|
970
989
|
// Cockpit name (header brand + browser tab), per launch directory — so several
|
|
971
990
|
// cockpits stay distinguishable across a reload. Empty PUT clears it.
|
|
972
991
|
app.get("/title", (_req, res) => {
|
|
@@ -2309,7 +2328,13 @@ async function attachPilot(s) {
|
|
|
2309
2328
|
notifyParent(s, { kind: "exited" });
|
|
2310
2329
|
destroySession(s);
|
|
2311
2330
|
});
|
|
2312
|
-
pilot.start()
|
|
2331
|
+
// Not `pilot.start()` directly: a claude-code upgrade rewrites a ~214 MB
|
|
2332
|
+
// binary in place, and a spawn landing in that window dies on ETXTBSY. It is
|
|
2333
|
+
// transient by construction, so it is waited out rather than reported as a
|
|
2334
|
+
// death — see `isBinaryBusyError`.
|
|
2335
|
+
await startWithBusyRetry(() => pilot.start(), {
|
|
2336
|
+
onRetry: (attempt, tries) => console.log(`spawn ${id.slice(0, 8)}: claude binary busy (upgrade in flight), retry ${attempt}/${tries}`),
|
|
2337
|
+
});
|
|
2313
2338
|
// Start the stall clock now: a session reattached mid-work must not look
|
|
2314
2339
|
// instantly "silent since epoch" and trip the fork detector before its tail
|
|
2315
2340
|
// has had a chance to stream anything.
|
|
@@ -3559,6 +3584,10 @@ server.listen(port, HOST, () => {
|
|
|
3559
3584
|
// would delay the window for nothing.
|
|
3560
3585
|
openBrowser("http://localhost:" + port);
|
|
3561
3586
|
adoptHomeChannel();
|
|
3587
|
+
// Announce here, not only inside the deferred call: the browser is opening
|
|
3588
|
+
// NOW and would otherwise be told there is nothing coming for a second and a
|
|
3589
|
+
// half — the whole window this status exists to fill.
|
|
3590
|
+
announceFirstAgent(loadChannels().length);
|
|
3562
3591
|
setTimeout(() => void startFirstAgent(), 1500).unref?.();
|
|
3563
3592
|
});
|
|
3564
3593
|
//# sourceMappingURL=server.js.map
|