shadok-ai 0.17.61 → 0.17.62

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 CHANGED
@@ -427,7 +427,8 @@ Enter to skip; you can add it later from the web UI).
427
427
  appears twice.
428
428
  While it is being started the central panel says so — *your first agent is
429
429
  waking up…*, with the real steps ticking off (access to Claude, workspace,
430
- Claude Code) — instead of the *no agent open* invitation, which would ask you to
430
+ Claude Code, then *Saying hello* — the screen stays until it has actually
431
+ greeted you) — instead of the *no agent open* invitation, which would ask you to
431
432
  create a second one while the first is being born. It is a status, not a
432
433
  screen: nothing to click, nothing to dismiss, and it ends on its own whichever
433
434
  way the spawn goes (started, refused because the instance is signed out,
@@ -83,7 +83,11 @@ export interface FirstAgentStatus {
83
83
  /** The spawn step the server last announced (src/spawn-steps.ts), so the
84
84
  * page's "starting" panel shows the same real progress as a tab's loader.
85
85
  * Null before the first one and whenever nothing is pending. */
86
- step: SpawnStep | null;
86
+ step: SpawnStep | "hello" | null;
87
+ /** The lead's session while its FIRST turn (the greeting) is under way: the
88
+ * wait stays open until it has answered, so the page keeps its loader up
89
+ * instead of showing an empty chat that fills a few seconds later. */
90
+ greeting: string | null;
87
91
  }
88
92
  /** A copy, so no caller can hold a handle on the state and edit it. */
89
93
  export declare function firstAgentStatus(): FirstAgentStatus;
@@ -106,6 +110,13 @@ export declare function announceFirstAgent(channelCount: number): void;
106
110
  export declare function noteFirstAgentStep(step: unknown): void;
107
111
  /** The one way out of `pending`. Never conditional: every reason ends the wait. */
108
112
  export declare function settleFirstAgent(reason: FirstAgentPlan["reason"]): void;
113
+ /** The lead was born and is being greeted: keep the wait open on its behalf
114
+ * (step "hello"). Never reopens a settled wait. */
115
+ export declare function greetFirstAgent(sessionId: string): void;
116
+ /** The greeting of THIS session is over (answered, failed, or the guard fired). */
117
+ export declare function endFirstAgentGreeting(sessionId: string): void;
118
+ /** The spawn's own exit: settles the wait unless a greeting now owns it. */
119
+ export declare function settleAfterSpawn(): void;
109
120
  /**
110
121
  * Start the lead agent if this instance has none. Idempotent by construction:
111
122
  * the condition is "no channel at all", so both callers can call it freely.
@@ -51,7 +51,7 @@ export function firstAgentPlan(input) {
51
51
  return { spawn: false, reason: "not-signed-in" };
52
52
  return { spawn: true, reason: "first-boot", name: FIRST_AGENT_NAME, profile: BOSS_PROFILE_NAME };
53
53
  }
54
- let status = { pending: false, reason: "idle", step: null };
54
+ let status = { pending: false, reason: "idle", step: null, greeting: null };
55
55
  /** A copy, so no caller can hold a handle on the state and edit it. */
56
56
  export function firstAgentStatus() {
57
57
  return { ...status };
@@ -71,8 +71,8 @@ export function firstAgentStatus() {
71
71
  export function announceFirstAgent(channelCount) {
72
72
  status =
73
73
  channelCount > 0
74
- ? { pending: false, reason: "channels-exist", step: null }
75
- : { pending: true, reason: "starting", step: null };
74
+ ? { pending: false, reason: "channels-exist", step: null, greeting: null }
75
+ : { pending: true, reason: "starting", step: null, greeting: null };
76
76
  }
77
77
  /** Record the step the lead's spawn has reached. Ignored once the wait is over
78
78
  * (a late message must not put a step back on a settled status) and for
@@ -84,7 +84,24 @@ export function noteFirstAgentStep(step) {
84
84
  }
85
85
  /** The one way out of `pending`. Never conditional: every reason ends the wait. */
86
86
  export function settleFirstAgent(reason) {
87
- status = { pending: false, reason, step: null };
87
+ status = { pending: false, reason, step: null, greeting: null };
88
+ }
89
+ /** The lead was born and is being greeted: keep the wait open on its behalf
90
+ * (step "hello"). Never reopens a settled wait. */
91
+ export function greetFirstAgent(sessionId) {
92
+ if (!status.pending)
93
+ return;
94
+ status = { ...status, step: "hello", greeting: sessionId };
95
+ }
96
+ /** The greeting of THIS session is over (answered, failed, or the guard fired). */
97
+ export function endFirstAgentGreeting(sessionId) {
98
+ if (status.greeting === sessionId)
99
+ settleFirstAgent("first-boot");
100
+ }
101
+ /** The spawn's own exit: settles the wait unless a greeting now owns it. */
102
+ export function settleAfterSpawn() {
103
+ if (status.greeting === null)
104
+ settleFirstAgent("first-boot");
88
105
  }
89
106
  /** Guards the two callers (boot, sign-in) against firing at the same moment. */
90
107
  let inFlight = false;
@@ -166,7 +183,9 @@ export async function ensureFirstAgent(deps) {
166
183
  // on `exited`, on a socket failure and on the 60s guard, and every one of
167
184
  // them has to end the "starting…" status. `onReady` has already written the
168
185
  // channel by now, so the client sees the tab and the cleared flag together.
169
- settleFirstAgent("first-boot");
186
+ // …unless `onReady` handed the wait to the greeting (greetFirstAgent), which
187
+ // ends it itself when the lead has answered.
188
+ settleAfterSpawn();
170
189
  }
171
190
  return "first-boot";
172
191
  }
@@ -1 +1 @@
1
- {"version":3,"file":"first-agent.js","sourceRoot":"","sources":["../src/first-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,SAAS,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAC;AAE/D;;;;;;;;;;;GAWG;AAEH,uDAAuD;AACvD;oFACoF;AACpF,MAAM,UAAU,iBAAiB,CAAC,QAAkD;IAClF,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC,KAAK,KAAK,aAAa,CAAC,CAAC,MAAM,CAAC;AACrF,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAW,EAAE,OAA2B;IAC7E,OAAO,EAAE,IAAI,EAAE,OAAgB,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AACxF,CAAC;AASD;;;;;;GAMG;AACH,MAAM,UAAU,cA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AC5E,4EAA4E;QAC5E,6EAA6E;QAC7E,6CAA6C;QAC7C,gBAAgB,EAAE,CAAC;IACrB,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
package/dist/server.js CHANGED
@@ -33,7 +33,7 @@ import { startSetupToken, submitSetupTokenCode, cancelSetupToken } from "./setup
33
33
  import { startAgentLogin, submitAgentLoginCode, cancelAgentLogin, agentLoginPending, agentLoginInfo, } from "./agent-login.js";
34
34
  import { readTokenExpiry } from "./claude-creds.js";
35
35
  import { starCount } from "./stars.js";
36
- import { announceFirstAgent, countMainChannels, ensureFirstAgent, firstAgentStatus, settleFirstAgent, } from "./first-agent.js";
36
+ import { announceFirstAgent, countMainChannels, ensureFirstAgent, firstAgentStatus, settleFirstAgent, greetFirstAgent, endFirstAgentGreeting, } from "./first-agent.js";
37
37
  import { readGroundAt } from "./ground.js";
38
38
  import { homeGreetingBrief, instanceContextInterviewBrief } from "./greeting.js";
39
39
  import { ensureSshIdentity, groupKeyRows, volumeKeyPaths } from "./ssh.js";
@@ -284,6 +284,8 @@ function adoptHomeChannel() {
284
284
  * a far smaller problem than one whose boot path threw. `SHADOK_GREETING=0`
285
285
  * turns it off, the way `SHADOK_PILOT_PROMPT=0` does for the pilot prompt.
286
286
  */
287
+ /** The longest the first-agent loader waits for the lead's greeting. */
288
+ const GREETING_WAIT_MAX_MS = 3 * 60_000;
287
289
  function greetHomeAgent(id) {
288
290
  if (process.env.SHADOK_GREETING === "0")
289
291
  return;
@@ -304,7 +306,18 @@ function greetHomeAgent(id) {
304
306
  console.log(`${tag} — not built (${e instanceof Error ? e.message : String(e)})`);
305
307
  return;
306
308
  }
309
+ // The page keeps its loader up until the lead has answered (the person sees
310
+ // the hello, not an empty chat filling in). Every way out ends the wait; the
311
+ // guard covers a turn that never reports back.
312
+ greetFirstAgent(id);
313
+ setTimeout(() => endFirstAgentGreeting(id), GREETING_WAIT_MAX_MS).unref?.();
307
314
  void deliverWithRetry(() => driveChannel(id, brief, resolveSessionTarget(loadChannels(), id, process.cwd())), () => sessions.has(id)).then((res) => {
315
+ // Only a FAILED delivery ends the wait here. A delivered one ends it when
316
+ // the lead's first text lands (the stream-text broadcast): the turn-done
317
+ // that resolves the delivery can come early — measured ~3s after the
318
+ // prompt while the lead was still thinking for 28s.
319
+ if (!res.ok)
320
+ endFirstAgentGreeting(id);
308
321
  if (res.ok)
309
322
  console.log(`${tag} — delivered (attempt ${res.attempts})`);
310
323
  else if (res.gone)
@@ -7215,6 +7228,9 @@ function startContentTail(s) {
7215
7228
  // TailEvent): the client shows it as is instead of dating everything on
7216
7229
  // reception.
7217
7230
  broadcast(s, { type: "stream-text", text: e.text, at: e.at, afterInternal, ...(e.uuid ? { msgId: e.uuid } : {}) });
7231
+ // The lead's greeting has a first answer: the first-agent loader may go
7232
+ // (a no-op for every other session — src/first-agent.ts).
7233
+ endFirstAgentGreeting(s.id);
7218
7234
  }
7219
7235
  else if (e.kind === "prompt") {
7220
7236
  // The echoed prompt bubble learns its transcript id (see TailEvent).