@songsid/agend 2.4.0-beta.11 → 2.4.0-beta.12
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/accounts-view.d.ts +29 -0
- package/dist/accounts-view.js +2 -14
- package/dist/accounts-view.js.map +1 -1
- package/dist/agent-endpoint.d.ts +1 -0
- package/dist/agent-endpoint.js +4 -2
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/auth-api.d.ts +2 -0
- package/dist/auth-api.js +28 -2
- package/dist/auth-api.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-server.js +1 -1
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/mcp-tools.js +3 -1
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/claude-install-kind.d.ts +19 -0
- package/dist/claude-install-kind.js +54 -0
- package/dist/claude-install-kind.js.map +1 -0
- package/dist/daemon.d.ts +5 -0
- package/dist/daemon.js +20 -2
- package/dist/daemon.js.map +1 -1
- package/dist/fleet-manager.d.ts +105 -1
- package/dist/fleet-manager.js +366 -24
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/hub/SKILL.md +25 -0
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +6 -0
- package/dist/hub/agent-intro-model.d.ts +38 -0
- package/dist/hub/agent-intro-model.js +14 -0
- package/dist/hub/agent-intro-model.js.map +1 -0
- package/dist/hub/agent-intro-tool.d.ts +35 -0
- package/dist/hub/agent-intro-tool.js +83 -0
- package/dist/hub/agent-intro-tool.js.map +1 -0
- package/dist/hub/client.d.ts +1 -0
- package/dist/hub/client.js +26 -0
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +13 -5
- package/dist/hub/compose/member.js +28 -5
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +1 -0
- package/dist/hub/compose/server.js +5 -1
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/http/compose.d.ts +1 -0
- package/dist/hub/http/compose.js +28 -5
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/schema.js +6 -0
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/member/agent-intro.d.ts +28 -0
- package/dist/hub/member/agent-intro.js +66 -0
- package/dist/hub/member/agent-intro.js.map +1 -0
- package/dist/hub/member/room-ask.d.ts +10 -0
- package/dist/hub/member/room-ask.js +70 -7
- package/dist/hub/member/room-ask.js.map +1 -1
- package/dist/hub/member/room-notification.d.ts +1 -1
- package/dist/hub/member/room-post.d.ts +6 -3
- package/dist/hub/member/room-post.js +9 -3
- package/dist/hub/member/room-post.js.map +1 -1
- package/dist/hub/protocol.d.ts +172 -4
- package/dist/hub/protocol.js +10 -5
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/room-answer-status-model.d.ts +3 -0
- package/dist/hub/room-answer-status-model.js +4 -0
- package/dist/hub/room-answer-status-model.js.map +1 -0
- package/dist/hub/room-brief-model.d.ts +30 -0
- package/dist/hub/room-brief-model.js +37 -0
- package/dist/hub/room-brief-model.js.map +1 -0
- package/dist/hub/room-context-model.d.ts +2 -0
- package/dist/hub/room-context-model.js +2 -2
- package/dist/hub/room-context-model.js.map +1 -1
- package/dist/hub/room-members-model.d.ts +63 -0
- package/dist/hub/room-members-model.js +7 -0
- package/dist/hub/room-members-model.js.map +1 -0
- package/dist/hub/rooms/agents.js +50 -10
- package/dist/hub/rooms/agents.js.map +1 -1
- package/dist/hub/rooms/brief.d.ts +18 -0
- package/dist/hub/rooms/brief.js +39 -0
- package/dist/hub/rooms/brief.js.map +1 -0
- package/dist/hub/rooms/members-page.d.ts +33 -0
- package/dist/hub/rooms/members-page.js +37 -0
- package/dist/hub/rooms/members-page.js.map +1 -0
- package/dist/hub/rooms/purpose.d.ts +7 -0
- package/dist/hub/rooms/purpose.js +14 -0
- package/dist/hub/rooms/purpose.js.map +1 -0
- package/dist/hub/rooms/service.d.ts +11 -0
- package/dist/hub/rooms/service.js +56 -12
- package/dist/hub/rooms/service.js.map +1 -1
- package/dist/hub/rooms/types.d.ts +6 -2
- package/dist/hub/runtime.d.ts +1 -1
- package/dist/hub/server.js +27 -1
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/types.d.ts +9 -5
- package/dist/hub-room-reply-warning.d.ts +2 -0
- package/dist/hub-room-reply-warning.js +16 -0
- package/dist/hub-room-reply-warning.js.map +1 -0
- package/dist/instance-lifecycle.d.ts +15 -0
- package/dist/instance-lifecycle.js +36 -1
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +20 -0
- package/dist/locale.js.map +1 -1
- package/dist/login-controller.d.ts +26 -0
- package/dist/login-controller.js +72 -2
- package/dist/login-controller.js.map +1 -1
- package/dist/native-mcp.js +1 -1
- package/dist/native-mcp.js.map +1 -1
- package/dist/needs-you-hub.js +1 -1
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +8 -1
- package/dist/needs-you.js +5 -0
- package/dist/needs-you.js.map +1 -1
- package/dist/outbound-handlers.d.ts +2 -1
- package/dist/outbound-handlers.js +17 -4
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +10 -0
- package/dist/outbound-schemas.js +3 -1
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/public-web-gateway.js +5 -1
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/restart-progress.d.ts +6 -0
- package/dist/restart-progress.js +5 -0
- package/dist/restart-progress.js.map +1 -1
- package/dist/settings-effect.js +17 -1
- package/dist/settings-effect.js.map +1 -1
- package/dist/tool-permissions.js +3 -3
- package/dist/tool-permissions.js.map +1 -1
- package/dist/ui/chat-quote.js +3 -261
- package/dist/ui/host-install.js +77 -3
- package/dist/ui/hub-agent-intro.js +15 -6
- package/dist/ui/hub-attachments.js +81 -3
- package/dist/ui/hub-client.js +4 -0
- package/dist/ui/hub-intro-notice.js +16 -0
- package/dist/ui/hub-my-agents.js +5 -2
- package/dist/ui/hub-room-composer.js +10 -2
- package/dist/ui/hub-room-list.js +1 -1
- package/dist/ui/hub-room-members.js +2 -0
- package/dist/ui/hub-room-new.js +7 -4
- package/dist/ui/hub-room-purpose.js +19 -0
- package/dist/ui/hub-room-search.js +1 -1
- package/dist/ui/hub-room-settings.js +9 -0
- package/dist/ui/hub-room-strings.js +6 -4
- package/dist/ui/hub-room-thread.js +68 -17
- package/dist/ui/panel-chat.js +19 -5
- package/dist/ui/panel-hub.js +61 -18
- package/dist/ui/shared/app-i18n.js +2 -2
- package/dist/ui/shared/app-shell.js +6 -0
- package/dist/ui/shared/app.js +3 -1
- package/dist/ui/shared/chat-msg-actions.js +3 -1
- package/dist/ui/shared/chat-quote.js +261 -0
- package/dist/ui/shared/hub-chat.css +28 -0
- package/dist/ui/shared/hub-rooms-u2.css +5 -0
- package/dist/ui/shared/module-warm.d.ts +3 -0
- package/dist/ui/shared/module-warm.js +39 -0
- package/dist/web-api.d.ts +17 -4
- package/dist/web-api.js +83 -6
- package/dist/web-api.js.map +1 -1
- package/dist/web-asset-version.d.ts +65 -0
- package/dist/web-asset-version.js +259 -0
- package/dist/web-asset-version.js.map +1 -0
- package/dist/web-host-guard.js +3 -1
- package/dist/web-host-guard.js.map +1 -1
- package/dist/web-host-install.d.ts +30 -3
- package/dist/web-host-install.js +50 -4
- package/dist/web-host-install.js.map +1 -1
- package/dist/web-terminal.d.ts +5 -0
- package/dist/web-terminal.js +11 -0
- package/dist/web-terminal.js.map +1 -1
- package/launcher/agend-install.cjs +48 -7
- package/package.json +1 -1
package/dist/fleet-manager.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withHubRoomReplyWarning } from "./hub-room-reply-warning.js";
|
|
1
2
|
import { hubSharingNoticeText } from "./hub-sharing-notice.js";
|
|
2
3
|
import { hubPageSharingSettings } from "./hub-page-sharing-settings.js";
|
|
3
4
|
import { replyPreviews } from "./reply-preview-spec.js";
|
|
@@ -71,6 +72,7 @@ import { atomicWriteFileSync } from "./atomic-write.js";
|
|
|
71
72
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
72
73
|
import { freemem, totalmem, homedir, hostname } from "node:os";
|
|
73
74
|
import { effectiveCpuCount } from "./cpu-quota.js";
|
|
75
|
+
import { realpath } from "node:fs/promises";
|
|
74
76
|
import { createServer } from "node:http";
|
|
75
77
|
import { Worker } from "node:worker_threads";
|
|
76
78
|
import { ProbeWorkerPool } from "./probe-worker-pool.js";
|
|
@@ -297,7 +299,8 @@ import { resolveUpdateLaunch, openUpdateLog, updateLogPath, watchUpdateLaunch }
|
|
|
297
299
|
import { isWebUpdateTarget, readLogTail, RUNNING_AGEND_VERSION, updateOffer, webProgressOf, webUpdateTarget } from "./web-update.js";
|
|
298
300
|
import { admitProfileLogin, LoginController, LOGIN_TOKEN_RESEND_PREFIX, POST_LOGIN_RECOVERY_DEADLINE_MS } from "./login-controller.js";
|
|
299
301
|
import { WebBackendLogins, dashboardSignInSupported } from "./web-backend-login.js";
|
|
300
|
-
import {
|
|
302
|
+
import { CLAUDE_NPM_PACKAGE, claudeInstallKind, displayHostPath } from "./claude-install-kind.js";
|
|
303
|
+
import { WebHostInstalls, claudeSelfUpdating, hostUpdatePlan, npmUninstallCommand } from "./web-host-install.js";
|
|
301
304
|
import { cliUpdateView, versionOf } from "./cli-audited.js";
|
|
302
305
|
import { runBeforeDeadline } from "./deadline.js";
|
|
303
306
|
import { LoginWindowLock } from "./login-window-lock.js";
|
|
@@ -353,6 +356,7 @@ import { sharedRolloutIndex } from "./rollout-index.js";
|
|
|
353
356
|
import { TASK_BOARD_ON_NOTICE, dashboardRefusalIn, taskBoardOffIn, taskBoardSwitchedOn } from "./dashboard-permissions.js";
|
|
354
357
|
import { mayUseTool, resolveToolSet, scheduleOpRefusal, toolForIpcType, toolRefusedMessage, } from "./tool-permissions.js";
|
|
355
358
|
import { authorizeSession, decideWebGate, loadOrCreateWebToken, readSessionCookies, readWebToken, sessionCookieUpgrade } from "./web-auth.js";
|
|
359
|
+
import { takeAssetVersion, warmAssetVersion } from "./web-asset-version.js";
|
|
356
360
|
import { bypassesWebGate, handleAuthRequest, serveGuestRefusedPage, serveSigninPage } from "./auth-api.js";
|
|
357
361
|
import { isWebPageNavigation } from "./web-shell-routes.js";
|
|
358
362
|
import { guestSessionPolicy, localSessionPolicy, publicLinkSessionPolicy, sessionVia, tokenEpoch, WebSessionStore } from "./web-session.js";
|
|
@@ -766,6 +770,11 @@ function emojiListFilter(opts) {
|
|
|
766
770
|
}
|
|
767
771
|
/** #1920: a guest's scope until phase 2 derives one: nothing. */
|
|
768
772
|
const NO_GUEST_SCOPE = new Set();
|
|
773
|
+
/** M-3302: what a delivery log line says of a notice — its first line, places as plain text, at most 100 characters. */
|
|
774
|
+
export function noticePreview(text) {
|
|
775
|
+
const first = stripPlaceRefs(text).split("\n").find(l => l.trim() !== "")?.trim() ?? "";
|
|
776
|
+
return first.length > 100 ? `${first.slice(0, 99)}…` : first;
|
|
777
|
+
}
|
|
769
778
|
/** #1490 row 27: a restart asked for one lifecycle of an instance after it was stopped, restarted or replaced. */
|
|
770
779
|
export class RestartSupersededError extends Error {
|
|
771
780
|
/** `shown`: the instance as the chat list names it (shownInstanceName). */
|
|
@@ -1464,7 +1473,7 @@ export class FleetManager {
|
|
|
1464
1473
|
return { result: null, error: "Native panes can only read Windows runtime model inventories" };
|
|
1465
1474
|
return { result: await this.listModelCatalog({ instanceName: target }) };
|
|
1466
1475
|
}
|
|
1467
|
-
const ops = { hub_room_list: "hub-room-list", hub_room_post: "hub-room-post", hub_room_members: "hub-room-members", hub_people_search: "hub-people-search", list_instances: "list", describe_instance: "describe", task: "task", send_to_instance: "send",
|
|
1476
|
+
const ops = { hub_set_intro: "hub-set-intro", hub_room_list: "hub-room-list", hub_room_post: "hub-room-post", hub_room_members: "hub-room-members", hub_people_search: "hub-people-search", list_instances: "list", describe_instance: "describe", task: "task", send_to_instance: "send",
|
|
1468
1477
|
delegate_task: "delegate", request_information: "ask", report_result: "report", delivery_status: "delivery-status" };
|
|
1469
1478
|
const { nativeAgentAdmissionContext } = await import("./native-agent-admission.js");
|
|
1470
1479
|
const { dispatchAgentOperation } = await import("./agent-endpoint.js");
|
|
@@ -2632,11 +2641,15 @@ export class FleetManager {
|
|
|
2632
2641
|
attachPrivateQuestions: read => { this.hubPrivateQuestions = read; },
|
|
2633
2642
|
attachReacts: handler => { this.hubReacts = handler; },
|
|
2634
2643
|
},
|
|
2644
|
+
attachAgentIntro: port => { this.hubAgentIntro = port; },
|
|
2635
2645
|
attachAgentRooms: port => { this.hubAgentRooms = port; this.notifyHubRoomTools(); },
|
|
2636
2646
|
roomToolsChanged: () => this.notifyHubRoomTools(),
|
|
2637
2647
|
roomConversationGeneration: agent => this.daemons.get(agent)?.roomConversationGeneration() ?? null,
|
|
2638
2648
|
attachRoomInputs: handler => { this.hubRoomInput = handler; },
|
|
2649
|
+
attachRoomOwed: port => { this.hubRoomOwed = port; },
|
|
2639
2650
|
roomNotify: input => this.deliverHubRoomNotification(input),
|
|
2651
|
+
// M-3313: a sign-in token in what the Hub sends is taken back the moment the link receives it.
|
|
2652
|
+
sawText: text => this.sawHubText(text),
|
|
2640
2653
|
roomReceipt: (caller, receiptId) => verifyRoomReceipt({
|
|
2641
2654
|
lookup: (agent, id) => {
|
|
2642
2655
|
const item = this.queryDurableDeliveryStatus(agent, { messageId: id }).items[0];
|
|
@@ -3021,6 +3034,32 @@ export class FleetManager {
|
|
|
3021
3034
|
return this.hubContactWindows ??= new HubContactWindows(join(this.dataDir, "hub-contact-windows.json"));
|
|
3022
3035
|
}
|
|
3023
3036
|
hubContactRestricted(agent) { return this.contactWindows().restricted(agent); }
|
|
3037
|
+
/**
|
|
3038
|
+
* M-3313 (#4145 for the Hub): what a Hub question or room notification hands the agent, with this fleet's sign-in
|
|
3039
|
+
* access token hidden (exact match, as a chat's). The live one is taken back and replaced, and the sign-in's chat told.
|
|
3040
|
+
* The Hub's own copy of the post is beyond the Fleet: it keeps it (encrypted) until its retention deletes it.
|
|
3041
|
+
*/
|
|
3042
|
+
/**
|
|
3043
|
+
* M-3313 (Fable #4165 F1): a Hub frame's content as the member link receives it — before it waits for its agent (busy,
|
|
3044
|
+
* paused, offline) or is dropped undelivered — so a live sign-in token in it is taken back at once, not at delivery.
|
|
3045
|
+
* Nothing is changed here: the delivery hides it from the agent (screenHubText).
|
|
3046
|
+
*/
|
|
3047
|
+
sawHubText(text) {
|
|
3048
|
+
const screened = this.screenLoginToken(text);
|
|
3049
|
+
if (!screened?.live)
|
|
3050
|
+
return;
|
|
3051
|
+
this.logger.warn("A sign-in access token arrived from the Hub: taken back and replaced");
|
|
3052
|
+
void this.loginController?.tokenPastedElsewhere().catch((err) => this.logger.warn({ err: err.message }, "Taking back a sign-in token pasted on the Hub failed"));
|
|
3053
|
+
}
|
|
3054
|
+
screenHubText(text) {
|
|
3055
|
+
const screened = this.screenLoginToken(text);
|
|
3056
|
+
if (!screened)
|
|
3057
|
+
return text;
|
|
3058
|
+
this.logger.warn("A sign-in access token reached this Fleet in a Hub question: hidden from the agent, taken back and replaced");
|
|
3059
|
+
if (screened.live)
|
|
3060
|
+
void this.loginController?.tokenPastedElsewhere().catch((err) => this.logger.warn({ err: err.message }, "Taking back a sign-in token pasted on the Hub failed"));
|
|
3061
|
+
return screened.text;
|
|
3062
|
+
}
|
|
3024
3063
|
/**
|
|
3025
3064
|
* A Hub question to its representative agent: ordinary cross-instance delivery (idle gate, wake, retries), from the
|
|
3026
3065
|
* reserved Hub sender with the Hub-issued correlation id. beforeInput runs immediately before the IPC hand-off.
|
|
@@ -3049,12 +3088,17 @@ export class FleetManager {
|
|
|
3049
3088
|
};
|
|
3050
3089
|
if (input.roomContextGeneration)
|
|
3051
3090
|
ipcMeta.hub_room_context_generation = input.roomContextGeneration;
|
|
3052
|
-
const result = await this.deliverToInstance(input.agent, { type: "fleet_inbound", targetSession: input.agent, content: input.text, meta: ipcMeta }, { isCrossInstance: true, stillCurrent: input.stillCurrent, beforeInput: async () => {
|
|
3091
|
+
const result = await this.deliverToInstance(input.agent, { type: "fleet_inbound", targetSession: input.agent, content: this.screenHubText(input.text), meta: ipcMeta }, { isCrossInstance: true, stillCurrent: input.stillCurrent, beforeInput: async () => {
|
|
3053
3092
|
const classic = this.isClassicInstance(input.agent);
|
|
3054
3093
|
// A busy Classic room must finish its public turn first; never force a private question into that turn's queue.
|
|
3055
3094
|
const idle = () => this.waitForInstanceIdle(input.agent, 0, this.lastDeliveryAt.get(input.agent) ?? 0, () => !input.stillCurrent());
|
|
3056
3095
|
if (classic && !await idle())
|
|
3057
3096
|
return false;
|
|
3097
|
+
if (!ipcMeta.hub_room_context_generation && /^hub-room-[a-f0-9-]{36}$/.test(input.correlationId)) {
|
|
3098
|
+
const generation = this.daemons.get(input.agent)?.roomConversationGeneration();
|
|
3099
|
+
if (generation)
|
|
3100
|
+
ipcMeta.hub_room_context_generation = generation;
|
|
3101
|
+
}
|
|
3058
3102
|
if (!(await input.beforeInput()))
|
|
3059
3103
|
return false;
|
|
3060
3104
|
if (classic) {
|
|
@@ -3071,13 +3115,14 @@ export class FleetManager {
|
|
|
3071
3115
|
}
|
|
3072
3116
|
async deliverHubRoomNotification(input) {
|
|
3073
3117
|
const { HUB_REPORT_TARGET } = await import("./hub/representative.js");
|
|
3074
|
-
|
|
3118
|
+
const config = input.kind === "answer-reminder" ? this.hubAgentConfig(input.agent) : this.fleetConfig?.instances[input.agent];
|
|
3119
|
+
if (this.shuttingDown || !config || isNativeExecInstance(config))
|
|
3075
3120
|
return false;
|
|
3076
|
-
const prefix = input.kind === "mention-feedback" ? "hub-room-mention-feedback" : "hub-room-post-answer";
|
|
3077
|
-
const result = await this.deliverToInstance(input.agent, { type: "fleet_inbound", targetSession: input.agent, content: input.text,
|
|
3121
|
+
const prefix = input.kind === "answer-reminder" ? "hub-room-answer-reminder" : input.kind === "mention-feedback" ? "hub-room-mention-feedback" : "hub-room-post-answer";
|
|
3122
|
+
const result = await this.deliverToInstance(input.agent, { type: "fleet_inbound", targetSession: input.agent, content: this.screenHubText(input.text),
|
|
3078
3123
|
meta: { chat_id: "", message_id: `${prefix}-${input.id}`, user: `instance:${HUB_REPORT_TARGET}`, user_id: `instance:${HUB_REPORT_TARGET}`,
|
|
3079
3124
|
ts: new Date().toISOString(), thread_id: "", from_instance: HUB_REPORT_TARGET, from_display: "Hub", correlation_id: `${prefix}-${input.id}`,
|
|
3080
|
-
request_kind: "notification", requires_reply: "false", task_summary: input.kind === "mention-feedback" ? "Hub mention delivery feedback" : "A reply to your Hub room post" } }, { isCrossInstance: true, stillCurrent: input.stillCurrent, beforeInput: input.beforeInput });
|
|
3125
|
+
request_kind: "notification", requires_reply: "false", task_summary: input.kind === "answer-reminder" ? "Hub room answer reminder" : input.kind === "mention-feedback" ? "Hub mention delivery feedback" : "A reply to your Hub room post" } }, { isCrossInstance: true, stillCurrent: input.stillCurrent, beforeInput: input.beforeInput });
|
|
3081
3126
|
return result !== false;
|
|
3082
3127
|
}
|
|
3083
3128
|
/** S-51: why the Hub (or this fleet's Hub membership) is not running, if it is held. Empty while off or running. */
|
|
@@ -3207,16 +3252,25 @@ export class FleetManager {
|
|
|
3207
3252
|
}
|
|
3208
3253
|
hubReacts = null;
|
|
3209
3254
|
/** The member side's pane-failure hook for a Hub-issued correlation id (else null). */
|
|
3255
|
+
hubRoomOwed = null;
|
|
3256
|
+
hubRoomReplyWarning(agent) { try {
|
|
3257
|
+
return this.hubRoomOwed?.replyWarning(agent);
|
|
3258
|
+
}
|
|
3259
|
+
catch {
|
|
3260
|
+
return undefined;
|
|
3261
|
+
} }
|
|
3210
3262
|
hubRoomInput = null;
|
|
3211
3263
|
hubDeliveryFailed = null;
|
|
3212
3264
|
/** The connected member adapter; never an agent-selectable identity. */
|
|
3213
3265
|
hubAgentRooms = null;
|
|
3266
|
+
hubAgentIntro = null;
|
|
3267
|
+
hubSetIntro(caller, text, operationId) { return this.hubAgentIntro?.set(caller, text, operationId) ?? Promise.resolve({ ok: false, code: "unavailable" }); }
|
|
3214
3268
|
hubRoomToolsAvailable() { return this.hubAgentRooms?.available() === true; }
|
|
3215
3269
|
hubRoomList(caller) {
|
|
3216
3270
|
return this.hubAgentRooms?.rooms(caller) ?? Promise.resolve({ ok: false, code: "unavailable" });
|
|
3217
3271
|
}
|
|
3218
|
-
hubRoomMembers(caller, room) {
|
|
3219
|
-
return this.hubAgentRooms?.members(caller, room) ?? Promise.resolve({ ok: false, code: "unavailable" });
|
|
3272
|
+
hubRoomMembers(caller, room, options) {
|
|
3273
|
+
return this.hubAgentRooms?.members(caller, room, options) ?? Promise.resolve({ ok: false, code: "unavailable" });
|
|
3220
3274
|
}
|
|
3221
3275
|
hubPeopleSearch(caller, q) {
|
|
3222
3276
|
return this.hubAgentRooms?.people(caller, q) ?? Promise.resolve({ ok: false, code: "unavailable" });
|
|
@@ -3385,6 +3439,11 @@ export class FleetManager {
|
|
|
3385
3439
|
startupRetries = new Map();
|
|
3386
3440
|
/** #2484: instances whose automatic startup retry is running now (between its timer and its outcome). */
|
|
3387
3441
|
startupRetriesRunning = new Set();
|
|
3442
|
+
/** M-3302 (#4146): instances held because their backend's CLI is not installed — started again the moment it is (watchMissingBinaries). */
|
|
3443
|
+
missingBinaryHolds = new Map();
|
|
3444
|
+
missingBinaryWatch = null;
|
|
3445
|
+
missingBinaryNotices = new Map();
|
|
3446
|
+
static MISSING_BINARY_WATCH_MS = 15_000;
|
|
3388
3447
|
/** Bumped by every explicit stop (incl. the stop half of a restart); fences the outage hand-off. */
|
|
3389
3448
|
explicitStopGeneration = new Map();
|
|
3390
3449
|
/** instanceName → outage hand-off currently executing; a repeat joins it. */
|
|
@@ -9648,6 +9707,8 @@ export class FleetManager {
|
|
|
9648
9707
|
return false;
|
|
9649
9708
|
if (this.stopOnUnsupportedCli(name, err, what))
|
|
9650
9709
|
return false;
|
|
9710
|
+
if (this.holdMissingBinary(name, err))
|
|
9711
|
+
return false;
|
|
9651
9712
|
this.logger.error({ err, name }, `Failed to start ${what}`);
|
|
9652
9713
|
this.scheduleStartupRetry(name, 0);
|
|
9653
9714
|
return false;
|
|
@@ -9691,6 +9752,11 @@ export class FleetManager {
|
|
|
9691
9752
|
}
|
|
9692
9753
|
/** Drop a pending automatic retry (an operator start/stop/restart supersedes it). */
|
|
9693
9754
|
cancelStartupRetry(name) {
|
|
9755
|
+
// M-3302: a person's start/stop/restart supersedes the hold too (a start that still finds no binary holds it again).
|
|
9756
|
+
if (this.missingBinaryHolds?.delete(name)) {
|
|
9757
|
+
this.needsYou?.poke();
|
|
9758
|
+
this.stopMissingBinaryWatchIfIdle();
|
|
9759
|
+
}
|
|
9694
9760
|
const pending = this.startupRetries.get(name);
|
|
9695
9761
|
if (!pending)
|
|
9696
9762
|
return;
|
|
@@ -9698,11 +9764,124 @@ export class FleetManager {
|
|
|
9698
9764
|
this.startupRetries.delete(name);
|
|
9699
9765
|
this.logger.info({ name }, "Pending automatic startup retry cancelled");
|
|
9700
9766
|
}
|
|
9767
|
+
/**
|
|
9768
|
+
* M-3302 (#4146): the start failed because the backend's CLI is not installed (BackendBinaryMissingError). That does not get better
|
|
9769
|
+
* on the 1 → 5 → 15 min backoff and should not be given up on either: the instance is held, one notice per binary names the binary
|
|
9770
|
+
* and the install command (Needs you shows it too), and the fleet looks for the binary every MISSING_BINARY_WATCH_MS and starts each
|
|
9771
|
+
* held instance the moment it is back. True: handled.
|
|
9772
|
+
*/
|
|
9773
|
+
holdMissingBinary(name, failure) {
|
|
9774
|
+
if (failure instanceof SupersededStartError)
|
|
9775
|
+
return false;
|
|
9776
|
+
const err = this.lifecycle?.missingBinaryAt?.(name, failure) ?? null;
|
|
9777
|
+
if (!err)
|
|
9778
|
+
return false;
|
|
9779
|
+
const pending = this.startupRetries.get(name);
|
|
9780
|
+
if (pending) {
|
|
9781
|
+
clearTimeout(pending.timer);
|
|
9782
|
+
this.startupRetries.delete(name);
|
|
9783
|
+
}
|
|
9784
|
+
const known = this.missingBinaryHolds.get(name);
|
|
9785
|
+
if (!known || known.binary !== err.binary) {
|
|
9786
|
+
this.missingBinaryHolds.set(name, { backend: err.backend, binary: err.binary, since: known?.since ?? Date.now() });
|
|
9787
|
+
this.logger.error({ name, backend: err.backend, binary: err.binary }, `Not starting ${name}: its backend binary "${err.binary}" is not installed — held until it is back`);
|
|
9788
|
+
this.queueMissingBinaryNotice(name, err.backend, err.binary);
|
|
9789
|
+
this.needsYou?.poke();
|
|
9790
|
+
}
|
|
9791
|
+
this.instanceProcessStatus.set(name, "stopped");
|
|
9792
|
+
this.ensureMissingBinaryWatch();
|
|
9793
|
+
return true;
|
|
9794
|
+
}
|
|
9795
|
+
/** The install command shown for a missing binary: the registry's (what /login and the dashboard run). */
|
|
9796
|
+
missingBinaryFix(backend) {
|
|
9797
|
+
return BACKEND_INSTALLATION_INFO[backend]?.install ?? "";
|
|
9798
|
+
}
|
|
9799
|
+
/**
|
|
9800
|
+
* M-3302: the summary a restart/update completion posts — `base` plus the "why" of its failed instances (missingBinarySummary). The one place both completions
|
|
9801
|
+
* (the startup batch after an update or restart, and the in-process restart) build it, so neither can drop the line (Fable on #4161).
|
|
9802
|
+
*/
|
|
9803
|
+
completionSummary(base) {
|
|
9804
|
+
return { ...base, ...this.missingBinarySummary(base.failedNames ?? []) };
|
|
9805
|
+
}
|
|
9806
|
+
/** M-3302: the restart/update completion's "why" for the failed instances held on a missing binary, grouped by binary ({} when none). */
|
|
9807
|
+
missingBinarySummary(failedNames) {
|
|
9808
|
+
const groups = new Map();
|
|
9809
|
+
for (const name of failedNames) {
|
|
9810
|
+
const hold = this.missingBinaryHold(name);
|
|
9811
|
+
if (!hold)
|
|
9812
|
+
continue;
|
|
9813
|
+
const group = groups.get(hold.binary) ?? { binary: hold.binary, fix: hold.fix, names: [] };
|
|
9814
|
+
group.names.push(name);
|
|
9815
|
+
groups.set(hold.binary, group);
|
|
9816
|
+
}
|
|
9817
|
+
return groups.size ? { missingBinaries: [...groups.values()] } : {};
|
|
9818
|
+
}
|
|
9819
|
+
/** M-3302: a missing binary's hold, for Needs you (null: none). */
|
|
9820
|
+
missingBinaryHold(name) {
|
|
9821
|
+
const hold = this.missingBinaryHolds?.get(name);
|
|
9822
|
+
return hold ? { ...hold, fix: this.missingBinaryFix(hold.backend) } : null;
|
|
9823
|
+
}
|
|
9824
|
+
/** One notice per missing binary, however many instances it stopped (the same aggregation window as the start-retry notices). */
|
|
9825
|
+
queueMissingBinaryNotice(name, backend, binary) {
|
|
9826
|
+
const pending = this.missingBinaryNotices.get(binary);
|
|
9827
|
+
if (pending) {
|
|
9828
|
+
if (!pending.names.includes(name))
|
|
9829
|
+
pending.names.push(name);
|
|
9830
|
+
return;
|
|
9831
|
+
}
|
|
9832
|
+
const timer = setTimeout(() => {
|
|
9833
|
+
const entry = this.missingBinaryNotices.get(binary);
|
|
9834
|
+
this.missingBinaryNotices.delete(binary);
|
|
9835
|
+
if (entry)
|
|
9836
|
+
this.notifyFleetError(t("fleet.backend_binary_missing", entry.names.length, entry.names.join(", "), binary, this.missingBinaryFix(entry.backend)));
|
|
9837
|
+
}, FleetManager.STARTUP_RETRY_NOTICE_AGGREGATE_MS);
|
|
9838
|
+
timer.unref?.();
|
|
9839
|
+
this.missingBinaryNotices.set(binary, { names: [name], backend, timer });
|
|
9840
|
+
}
|
|
9841
|
+
ensureMissingBinaryWatch() {
|
|
9842
|
+
if (this.missingBinaryWatch || this.shuttingDown)
|
|
9843
|
+
return;
|
|
9844
|
+
this.missingBinaryWatch = setInterval(() => { void this.checkMissingBinaries(); }, FleetManager.MISSING_BINARY_WATCH_MS);
|
|
9845
|
+
this.missingBinaryWatch.unref?.();
|
|
9846
|
+
}
|
|
9847
|
+
stopMissingBinaryWatchIfIdle() {
|
|
9848
|
+
if (this.missingBinaryHolds?.size || !this.missingBinaryWatch)
|
|
9849
|
+
return;
|
|
9850
|
+
clearInterval(this.missingBinaryWatch);
|
|
9851
|
+
this.missingBinaryWatch = null;
|
|
9852
|
+
}
|
|
9853
|
+
missingBinaryCheckRunning = false;
|
|
9854
|
+
/** One look per backend still missing; each held instance whose binary is back is started now (through the spawn gate, as a retry). */
|
|
9855
|
+
async checkMissingBinaries() {
|
|
9856
|
+
if (this.missingBinaryCheckRunning || this.shuttingDown)
|
|
9857
|
+
return;
|
|
9858
|
+
this.missingBinaryCheckRunning = true;
|
|
9859
|
+
try {
|
|
9860
|
+
const backends = [...new Set([...this.missingBinaryHolds.values()].map(h => h.backend))];
|
|
9861
|
+
for (const backend of backends) {
|
|
9862
|
+
const path = await resolveBackendBinary(backend).catch(() => undefined);
|
|
9863
|
+
if (typeof path !== "string" || !path)
|
|
9864
|
+
continue;
|
|
9865
|
+
for (const [name, hold] of [...this.missingBinaryHolds]) {
|
|
9866
|
+
if (hold.backend !== backend)
|
|
9867
|
+
continue;
|
|
9868
|
+
this.missingBinaryHolds.delete(name);
|
|
9869
|
+
this.logger.info({ name, backend, binary: hold.binary, path }, `Backend binary "${hold.binary}" is back — starting ${name}`);
|
|
9870
|
+
void this.runStartupRetry(name, 0);
|
|
9871
|
+
}
|
|
9872
|
+
this.needsYou?.poke();
|
|
9873
|
+
}
|
|
9874
|
+
}
|
|
9875
|
+
finally {
|
|
9876
|
+
this.missingBinaryCheckRunning = false;
|
|
9877
|
+
this.stopMissingBinaryWatchIfIdle();
|
|
9878
|
+
}
|
|
9879
|
+
}
|
|
9701
9880
|
/** #2484: the instance's own start retry is scheduled or running, and no person paused it (a stop cancels the retry). */
|
|
9702
9881
|
inStartRetryBackoff(name) {
|
|
9703
9882
|
if (this.shuttingDown || this.lifecycle.isPaused(name))
|
|
9704
9883
|
return false;
|
|
9705
|
-
return this.startupRetries.has(name) || this.startupRetriesRunning.has(name);
|
|
9884
|
+
return this.startupRetries.has(name) || this.startupRetriesRunning.has(name) || this.missingBinaryHolds?.has(name) === true;
|
|
9706
9885
|
}
|
|
9707
9886
|
/** Pending automatic retry, if any (status display / tests). */
|
|
9708
9887
|
pendingStartupRetry(name) {
|
|
@@ -9791,6 +9970,8 @@ export class FleetManager {
|
|
|
9791
9970
|
return;
|
|
9792
9971
|
if (this.stopOnUnsupportedCli(name, err, "instance"))
|
|
9793
9972
|
return;
|
|
9973
|
+
if (this.holdMissingBinary(name, err))
|
|
9974
|
+
return;
|
|
9794
9975
|
this.logger.error({ err, name, attempt: attempt + 1 }, "Automatic startup retry failed");
|
|
9795
9976
|
this.scheduleStartupRetry(name, attempt + 1);
|
|
9796
9977
|
}
|
|
@@ -12622,7 +12803,7 @@ export class FleetManager {
|
|
|
12622
12803
|
// version it aimed for, the one running, and the one repair), never just "updated".
|
|
12623
12804
|
const aimedAt = pendingProgressOperation === "update" ? pendingUpdateProgress?.progress.version : undefined;
|
|
12624
12805
|
const notLanded = aimedAt && agendVersion !== "unknown" && aimedAt !== agendVersion ? t("update.not_landed", aimedAt, agendVersion) : null;
|
|
12625
|
-
const completionSummary = {
|
|
12806
|
+
const completionSummary = this.completionSummary({
|
|
12626
12807
|
running: started,
|
|
12627
12808
|
total,
|
|
12628
12809
|
version: agendVersion,
|
|
@@ -12632,7 +12813,7 @@ export class FleetManager {
|
|
|
12632
12813
|
...(cleanupOutcome && "render" in cleanupOutcome
|
|
12633
12814
|
? { warningText: cleanupOutcome.render.warning, warningCommand: cleanupOutcome.render.cleanupCommand }
|
|
12634
12815
|
: notLanded ? { warningText: notLanded } : {}),
|
|
12635
|
-
};
|
|
12816
|
+
});
|
|
12636
12817
|
const progressCompleted = await startupProgress.finish(completionSummary);
|
|
12637
12818
|
// Armed only after the completion posted: an append racing ahead of it would be overwritten by it.
|
|
12638
12819
|
if (cleanupOutcome && "watch" in cleanupOutcome)
|
|
@@ -13741,6 +13922,10 @@ export class FleetManager {
|
|
|
13741
13922
|
else if (msg.type === "instance_progress") {
|
|
13742
13923
|
this.cacheInstanceProgress(name, msg.progress || null);
|
|
13743
13924
|
}
|
|
13925
|
+
else if (msg.type === "hub_room_turn_ended") {
|
|
13926
|
+
if (this.instanceIpcClients.get(name) === ipc && typeof msg.generation === "string" && typeof msg.turn === "string")
|
|
13927
|
+
void this.hubRoomOwed?.turnEnded(name, msg.generation, msg.turn).catch(err => this.logger.warn({ err }, "Hub room completion notice held"));
|
|
13928
|
+
}
|
|
13744
13929
|
else if (msg.type === "hub_room_input") {
|
|
13745
13930
|
if (this.instanceIpcClients.get(name) === ipc && typeof msg.correlationId === "string" && typeof msg.generation === "string")
|
|
13746
13931
|
this.hubRoomInput?.(msg.correlationId, name, msg.generation);
|
|
@@ -14417,10 +14602,42 @@ export class FleetManager {
|
|
|
14417
14602
|
}
|
|
14418
14603
|
async handleInboundMessage(msg) {
|
|
14419
14604
|
msg = { ...msg, humanOriginalBody: msg.humanOriginalBody ?? msg.text, humanOrigin: msg.isBotMessage ? undefined : msg.humanOrigin && { ...msg.humanOrigin } };
|
|
14605
|
+
// #4145: this fleet's sign-in access token pasted into a chat is hidden before anything logs, indexes, keeps or
|
|
14606
|
+
// delivers the message — then taken back and replaced, and the chat told where it goes.
|
|
14607
|
+
const pasted = this.screenPastedLoginToken(msg);
|
|
14608
|
+
if (pasted) {
|
|
14609
|
+
msg = pasted.msg;
|
|
14610
|
+
if (pasted.live)
|
|
14611
|
+
await this.takeBackPastedLoginToken(msg);
|
|
14612
|
+
}
|
|
14420
14613
|
if (msg.isBotMessage)
|
|
14421
14614
|
return withSpawnHoldReply(undefined, () => this.handleInboundMessageCore(msg));
|
|
14422
14615
|
return withSpawnHoldReply(text => this.inboundNoticeAdapter(msg)?.sendText(msg.chatId, text, { threadId: msg.threadId }) ?? Promise.resolve(), () => this.handleInboundMessageCore(msg));
|
|
14423
14616
|
}
|
|
14617
|
+
/** #4145 (the web chat's /ui/send too): `text` with this fleet's sign-in access token hidden; null when there is none in it. */
|
|
14618
|
+
screenLoginToken(text) { return this.loginController?.screenToken(text) ?? null; }
|
|
14619
|
+
/** #4145: take a pasted access token back (a new one goes the way the first went); the line for the chat it was pasted in, or null. */
|
|
14620
|
+
loginTokenPasted() { return this.loginController?.tokenPasted() ?? Promise.resolve(null); }
|
|
14621
|
+
/** #4145: the message with the live (or a just-taken-back) sign-in access token hidden in its text and its receipt body; null when neither has one. */
|
|
14622
|
+
screenPastedLoginToken(msg) {
|
|
14623
|
+
const text = this.screenLoginToken(msg.text ?? "");
|
|
14624
|
+
const body = msg.humanOriginalBody === undefined || msg.humanOriginalBody === msg.text ? text : this.screenLoginToken(msg.humanOriginalBody);
|
|
14625
|
+
if (!text && !body)
|
|
14626
|
+
return null;
|
|
14627
|
+
return { msg: { ...msg, ...(text ? { text: text.text } : {}), ...(body ? { humanOriginalBody: body.text } : {}) }, live: !!(text?.live || body?.live) };
|
|
14628
|
+
}
|
|
14629
|
+
/** #4145: take the pasted token back (a new one goes privately) and say so once, where it was pasted. Never the token in a log line. */
|
|
14630
|
+
async takeBackPastedLoginToken(msg) {
|
|
14631
|
+
this.logger.warn({ source: msg.source, adapterId: msg.adapterId, chatId: msg.chatId, threadId: msg.threadId, userId: msg.userId }, "A sign-in access token was pasted into a chat: hidden, taken back and replaced");
|
|
14632
|
+
const notice = await this.loginTokenPasted().catch((err) => {
|
|
14633
|
+
this.logger.warn({ err: err.message }, "Taking back a pasted sign-in token failed");
|
|
14634
|
+
return null;
|
|
14635
|
+
});
|
|
14636
|
+
if (!notice || msg.isBotMessage)
|
|
14637
|
+
return;
|
|
14638
|
+
await this.inboundNoticeAdapter(msg)?.sendText(msg.chatId, notice, { threadId: msg.threadId || undefined })
|
|
14639
|
+
.catch((err) => this.logger.warn({ err: err.message }, "Pasted sign-in token notice failed"));
|
|
14640
|
+
}
|
|
14424
14641
|
/**
|
|
14425
14642
|
* #1752: the bot that speaks back about an inbound message — in a fleet topic the owning instance's adapter, never
|
|
14426
14643
|
* the sibling that happened to win the dedup race; elsewhere (ClassicBot rooms, no routed instance) the receiver.
|
|
@@ -15201,6 +15418,8 @@ export class FleetManager {
|
|
|
15201
15418
|
const operationId = typeof msg.operationId === "string" ? msg.operationId : undefined;
|
|
15202
15419
|
const sourceDaemonBootId = typeof msg.sourceDaemonBootId === "string" ? msg.sourceDaemonBootId : undefined;
|
|
15203
15420
|
const respond = (result, error) => {
|
|
15421
|
+
if (tool === "reply" && msg.statusOnly !== true)
|
|
15422
|
+
result = withHubRoomReplyWarning(result, () => this.hubRoomReplyWarning(instanceName), error);
|
|
15204
15423
|
const ipc = this.instanceIpcClients.get(instanceName);
|
|
15205
15424
|
let sent = false;
|
|
15206
15425
|
if (fleetRequestId) {
|
|
@@ -17544,6 +17763,11 @@ export class FleetManager {
|
|
|
17544
17763
|
await this.lifecycle.remove(name, authorization, execution, transition);
|
|
17545
17764
|
else
|
|
17546
17765
|
await this.lifecycle.remove(name, authorization);
|
|
17766
|
+
// M-3302: a removed instance is no longer held for its missing binary (the watch would only skip it).
|
|
17767
|
+
if (this.missingBinaryHolds?.delete(name)) {
|
|
17768
|
+
this.needsYou?.poke();
|
|
17769
|
+
this.stopMissingBinaryWatchIfIdle();
|
|
17770
|
+
}
|
|
17547
17771
|
// #1490 row 27: its hang/exit offers were for the instance now gone (stopInstance clears them; removal stops
|
|
17548
17772
|
// through the lifecycle directly). The offers' own lifecycle pins refuse them too.
|
|
17549
17773
|
this.clearNoncePromptsForInstance(name);
|
|
@@ -19096,7 +19320,7 @@ export class FleetManager {
|
|
|
19096
19320
|
if (this.adapter && target) {
|
|
19097
19321
|
const out = this.renderPlaces(this.getPrimaryAdapterId(), body, target.opts);
|
|
19098
19322
|
this.adapter.sendText(target.chatId, out.text, out.opts)
|
|
19099
|
-
.then(() => opts.ack?.(true), err => { this.logger.warn({ err }, "Failed to send fleet error notification"); opts.ack?.(false); });
|
|
19323
|
+
.then(() => { this.logger.info({ notice: noticePreview(body) }, "Fleet notice delivered"); opts.ack?.(true); }, err => { this.logger.warn({ err }, "Failed to send fleet error notification"); opts.ack?.(false); });
|
|
19100
19324
|
dispatched = true;
|
|
19101
19325
|
}
|
|
19102
19326
|
}
|
|
@@ -19203,7 +19427,8 @@ export class FleetManager {
|
|
|
19203
19427
|
if (!send)
|
|
19204
19428
|
return false;
|
|
19205
19429
|
// `ack` (a caller that must not lose the message) is told when the platform took it or refused it; everyone else only gets the log line.
|
|
19206
|
-
|
|
19430
|
+
// M-3302 (#4146): a delivered notice leaves one line, so the log can tell whether the person was told (only failures were logged).
|
|
19431
|
+
send.sent.then(() => { this.logger.info({ instanceName, notice: noticePreview(text) }, "Notice delivered"); ack?.(true); }, e => { this.logger.warn({ err: e, instanceName }, send.failure); ack?.(false); });
|
|
19207
19432
|
return true;
|
|
19208
19433
|
}
|
|
19209
19434
|
/**
|
|
@@ -19898,6 +20123,7 @@ export class FleetManager {
|
|
|
19898
20123
|
interaction: p.interaction ? { kind: p.interaction.kind, owner: wait?.owner ?? null, episode: p.interaction.episode, since: p.interaction.since } : null,
|
|
19899
20124
|
interactionSummary: p.interaction?.kind === "kiro_choice" ? t("kiro3.running") : p.interaction_summary ?? null,
|
|
19900
20125
|
kiroCompatibility: this.kiroCompatibilityHolds?.get(name),
|
|
20126
|
+
backendMissing: this.missingBinaryHold(name),
|
|
19901
20127
|
pauseReason, pausedAt,
|
|
19902
20128
|
crashedAt: crashed ? (this.needsCrashedAt.get(name) ?? null) : null,
|
|
19903
20129
|
signIn: pauseReason === "auth" ? this.signInFor(name) : null,
|
|
@@ -23351,7 +23577,58 @@ export class FleetManager {
|
|
|
23351
23577
|
}
|
|
23352
23578
|
}
|
|
23353
23579
|
return buildAccountsView({ targets, diskProfiles, agents, classic, fleetDefaults, usage, keepAlive, machines, installShown: this.webHostInstalls.view()?.backend ?? null,
|
|
23354
|
-
versions: new Map(this.backendAvailabilityRows().map(row => [row.backend, row.version ?? null])) });
|
|
23580
|
+
versions: new Map(this.backendAvailabilityRows().map(row => [row.backend, row.version ?? null])), claudeInstall: await this.claudeInstallShown() });
|
|
23581
|
+
}
|
|
23582
|
+
/**
|
|
23583
|
+
* M-3307: the install kind as the AI accounts page is told it — paths `~`-abbreviated (Fable note 2 on #4163) — and, for a native install, the npm copy still left on
|
|
23584
|
+
* this computer (note 1: found again here, not only remembered from a switch in this process), so its removal is offered after a restart too.
|
|
23585
|
+
*/
|
|
23586
|
+
async claudeInstallShown() {
|
|
23587
|
+
const ci = await this.claudeInstall();
|
|
23588
|
+
if (!ci)
|
|
23589
|
+
return null;
|
|
23590
|
+
const home = homedir();
|
|
23591
|
+
if (ci.kind === "npm-global")
|
|
23592
|
+
return { kind: ci.kind, ...(ci.npmPackageDir ? { npmPackageDir: displayHostPath(ci.npmPackageDir, home) } : {}) };
|
|
23593
|
+
if (ci.kind !== "native")
|
|
23594
|
+
return { kind: ci.kind };
|
|
23595
|
+
const left = await this.findClaudeNpmCopy().catch(() => null);
|
|
23596
|
+
return { kind: "native", ...(left ? { npmLeftover: displayHostPath(left, home) } : {}) };
|
|
23597
|
+
}
|
|
23598
|
+
claudeNpmCopyCache = null;
|
|
23599
|
+
/**
|
|
23600
|
+
* M-3307 (Fable note 1 on #4163): an npm copy of Claude Code on this computer, looked for afresh: the one a switch in this process found, else `<npm root -g>/@anthropic-ai/claude-code`
|
|
23601
|
+
* (a fresh login shell's npm), else the system prefixes' (/usr/lib, /usr/local/lib). The answer is kept a minute (the page reads it on each view). Null: none.
|
|
23602
|
+
*/
|
|
23603
|
+
async findClaudeNpmCopy() {
|
|
23604
|
+
if (this.claudeNpmCopy && existsSync(this.claudeNpmCopy))
|
|
23605
|
+
return this.claudeNpmCopy;
|
|
23606
|
+
const now = performance.now();
|
|
23607
|
+
if (this.claudeNpmCopyCache && now - this.claudeNpmCopyCache.at < 60_000)
|
|
23608
|
+
return this.claudeNpmCopyCache.dir;
|
|
23609
|
+
const roots = [];
|
|
23610
|
+
try {
|
|
23611
|
+
const r = await runOnLoginShell("npm root -g 2>/dev/null");
|
|
23612
|
+
const root = r.status === 0 ? r.stdout.trim().split("\n").pop()?.trim() ?? "" : "";
|
|
23613
|
+
if (isAbsolute(root))
|
|
23614
|
+
roots.push(root);
|
|
23615
|
+
}
|
|
23616
|
+
catch { /* no npm */ }
|
|
23617
|
+
roots.push("/usr/lib/node_modules", "/usr/local/lib/node_modules");
|
|
23618
|
+
const dir = roots.map(root => join(root, CLAUDE_NPM_PACKAGE)).find(d => existsSync(d)) ?? null;
|
|
23619
|
+
this.claudeNpmCopyCache = { at: now, dir };
|
|
23620
|
+
return dir;
|
|
23621
|
+
}
|
|
23622
|
+
/** M-3307 (#4146): the kind of the host's Claude Code install, from the real path of the `claude` the availability snapshot resolved (null: none, or unreadable). */
|
|
23623
|
+
async claudeInstall(path = this.backendAvailabilityRows().find(row => row.backend === "claude-code")?.path ?? null) {
|
|
23624
|
+
if (!path)
|
|
23625
|
+
return null;
|
|
23626
|
+
try {
|
|
23627
|
+
return claudeInstallKind(await realpath(path), process.env, homedir());
|
|
23628
|
+
}
|
|
23629
|
+
catch {
|
|
23630
|
+
return null;
|
|
23631
|
+
}
|
|
23355
23632
|
}
|
|
23356
23633
|
/**
|
|
23357
23634
|
* AGEND-113: a dashboard sign-in just finished: read the usage once more now (the panel's own forced read, so its 30-second floor and Retry-After hold), instead of showing what was read
|
|
@@ -24635,14 +24912,29 @@ export class FleetManager {
|
|
|
24635
24912
|
if (!base || isRemovedBackend(backend))
|
|
24636
24913
|
return { refused: "unsupported" };
|
|
24637
24914
|
// AGEND-136: an update runs the registry's `host.update` command with the audited release in it (hostUpdatePlan); the window, its judgement and its release are the install's.
|
|
24638
|
-
const plan = mode === "update" ? hostUpdatePlan(backend) : null;
|
|
24639
|
-
if (mode === "update" && !plan)
|
|
24915
|
+
const plan = mode === "update" || mode === "native" ? hostUpdatePlan(backend) : null;
|
|
24916
|
+
if ((mode === "update" || mode === "native") && !plan)
|
|
24640
24917
|
return { refused: "unsupported" };
|
|
24641
|
-
|
|
24918
|
+
// M-3307 (#4146): the switch and the npm copy's removal are Claude Code's alone.
|
|
24919
|
+
if ((mode === "native" || mode === "remove-npm") && backend !== "claude-code")
|
|
24920
|
+
return { refused: "unsupported" };
|
|
24921
|
+
// remove-npm: the npm copy the switch found (its package directory), removed with npm of that same prefix (<prefix>/lib/node_modules/@anthropic-ai/claude-code).
|
|
24922
|
+
// Fable note 1 on #4163: found afresh, so a restart after the switch does not lose it.
|
|
24923
|
+
if (mode === "remove-npm")
|
|
24924
|
+
this.claudeNpmCopyCache = null;
|
|
24925
|
+
const npmCopy = mode === "remove-npm" ? await this.findClaudeNpmCopy().catch(() => null) : null;
|
|
24926
|
+
if (mode === "remove-npm" && (!npmCopy || !existsSync(npmCopy)))
|
|
24927
|
+
return { refused: "no_npm_copy" };
|
|
24928
|
+
const info = plan ? { install: plan.command } : npmCopy ? { install: npmUninstallCommand(npmCopy) } : base;
|
|
24642
24929
|
// The fleet-wide window, claimed before the first await (shared with /login, chat's install and sign-in).
|
|
24643
24930
|
const claim = this.loginWindow.tryClaim("install", backend);
|
|
24644
24931
|
if (!claim)
|
|
24645
24932
|
return { refused: this.loginWindow.isClosed ? "shutting_down" : "busy" };
|
|
24933
|
+
// M-3302: Claude Code downloading an update of its own right now — its installer, started from here, would race it. Asked to try again in a few minutes.
|
|
24934
|
+
if (backend === "claude-code" && claudeSelfUpdating()) {
|
|
24935
|
+
this.loginWindow.release(claim);
|
|
24936
|
+
return { refused: "cli_self_updating" };
|
|
24937
|
+
}
|
|
24646
24938
|
// #3542 / AGEND-144 (Prism on #3539): the claim is a lock, not the asker's authority. The confirmed change's own execution (its session, role, confirmation and the settings it was held
|
|
24647
24939
|
// against) is asked again after each wait (the binary check, the version refresh), and its admission ends at the tmux command that starts the installer (openInstallWindow → `launch`).
|
|
24648
24940
|
const asker = () => { try {
|
|
@@ -24657,10 +24949,25 @@ export class FleetManager {
|
|
|
24657
24949
|
return { refused: "already" };
|
|
24658
24950
|
}
|
|
24659
24951
|
// An update needs the CLI where the Accounts page found it: on the fleet's PATH, else (a fresh login shell, then) the installer's own directories (~/.grok/bin, ~/.opencode/bin …).
|
|
24660
|
-
if (mode
|
|
24952
|
+
if (mode !== "install" && !present && !(await this.locateInstalledCli(backend, base.binary).catch(() => null))) {
|
|
24661
24953
|
this.loginWindow.release(claim);
|
|
24662
24954
|
return { refused: "not_installed" };
|
|
24663
24955
|
}
|
|
24956
|
+
// M-3307: the switch is offered only over an npm-global install; the removal only once `claude` resolves to the native install (else nothing would be left).
|
|
24957
|
+
if (mode === "native" || mode === "remove-npm") {
|
|
24958
|
+
const now = await this.claudeInstallAfter(base.binary, null);
|
|
24959
|
+
if (mode === "native" && now.kind !== "npm-global") {
|
|
24960
|
+
this.loginWindow.release(claim);
|
|
24961
|
+
return { refused: "not_npm" };
|
|
24962
|
+
}
|
|
24963
|
+
if (mode === "native")
|
|
24964
|
+
this.claudeNpmCopy = (await this.claudeInstall(now.path))?.npmPackageDir ?? null;
|
|
24965
|
+
// The removal needs a native install to fall back on: `claude` resolves to it already, or it is there behind the npm copy on PATH (the switch's "still npm" case).
|
|
24966
|
+
if (mode === "remove-npm" && now.kind !== "native" && !(await this.nativeClaudePresent())) {
|
|
24967
|
+
this.loginWindow.release(claim);
|
|
24968
|
+
return { refused: "still_npm" };
|
|
24969
|
+
}
|
|
24970
|
+
}
|
|
24664
24971
|
if (!asker()) {
|
|
24665
24972
|
this.loginWindow.release(claim);
|
|
24666
24973
|
return { refused: "failed" };
|
|
@@ -24689,7 +24996,7 @@ export class FleetManager {
|
|
|
24689
24996
|
return { refused: "version_unreadable" };
|
|
24690
24997
|
}
|
|
24691
24998
|
// AGEND-153: the named exception (`release: "latest-unaudited"`) is offered at any readable version (it goes to the vendor's newest, not to our audited release), so "behind" does not decide it.
|
|
24692
|
-
if (cliUpdateView(backend, versionBefore, true, plan.target === null)?.button !== true) {
|
|
24999
|
+
if (mode === "update" && cliUpdateView(backend, versionBefore, true, plan.target === null)?.button !== true) {
|
|
24693
25000
|
this.loginWindow.release(claim);
|
|
24694
25001
|
return { refused: "up_to_date" };
|
|
24695
25002
|
}
|
|
@@ -24720,9 +25027,17 @@ export class FleetManager {
|
|
|
24720
25027
|
version = this.backendAvailabilityRows().find(row => row.backend === backend)?.version ?? null;
|
|
24721
25028
|
}
|
|
24722
25029
|
}
|
|
24723
|
-
|
|
25030
|
+
// M-3307: after the switch or the removal, where `claude` resolves now (a fresh login shell), its kind, and whether the npm copy is still there.
|
|
25031
|
+
const claude = ok && (mode === "native" || mode === "remove-npm") ? await this.claudeInstallAfter(base.binary, mode === "remove-npm" ? npmCopy : this.claudeNpmCopy).catch(() => undefined) : undefined;
|
|
25032
|
+
if (claude && mode === "remove-npm" && !claude.npmLeftover) {
|
|
25033
|
+
this.claudeNpmCopy = null;
|
|
25034
|
+
this.claudeNpmCopyCache = null;
|
|
25035
|
+
}
|
|
25036
|
+
this.logger.info({ backend, mode, ok, verified, ...(plan ? { to: plan.target } : {}), ...(claude ? { claude } : {}), ...(ok ? {} : { detail }) }, mode === "install" ? "Dashboard install ended" : mode === "update" ? "Dashboard update ended" : mode === "native" ? "Dashboard switch to Claude's native install ended" : "Dashboard removal of the npm Claude Code ended");
|
|
25037
|
+
// Fable note 2 on #4163: what the page is told names no user — paths are shown `~`-abbreviated (the log above keeps them whole, on this computer).
|
|
25038
|
+
const shown = claude ? { ...claude, path: displayHostPath(claude.path, homedir()), npmLeftover: displayHostPath(claude.npmLeftover, homedir()) } : undefined;
|
|
24724
25039
|
try {
|
|
24725
|
-
reporter.done({ ok, detail, cleanupFailed, verified, version, signIn: !!LOGIN_FLOWS[backend] && dashboardSignInSupported(backend) });
|
|
25040
|
+
reporter.done({ ok, detail, cleanupFailed, verified, version, signIn: mode === "install" && !!LOGIN_FLOWS[backend] && dashboardSignInSupported(backend), ...(shown ? { claude: shown } : {}) });
|
|
24726
25041
|
}
|
|
24727
25042
|
catch { /* a view never stops the install */ }
|
|
24728
25043
|
},
|
|
@@ -24736,6 +25051,20 @@ export class FleetManager {
|
|
|
24736
25051
|
}
|
|
24737
25052
|
return { started: true };
|
|
24738
25053
|
}
|
|
25054
|
+
/** M-3307: the npm copy of Claude Code the last switch found (its package directory), the one `remove-npm` removes. */
|
|
25055
|
+
claudeNpmCopy = null;
|
|
25056
|
+
/** M-3307: Claude's native install is there: `~/.local/bin/claude` leads into its versions folder. */
|
|
25057
|
+
async nativeClaudePresent() {
|
|
25058
|
+
const real = await realpath(join(homedir(), ".local", "bin", "claude")).catch(() => null);
|
|
25059
|
+
return !!real && claudeInstallKind(real, process.env, homedir()).kind === "native";
|
|
25060
|
+
}
|
|
25061
|
+
/** M-3307: where `binary` resolves in a fresh login shell now, the kind of that install, and whether `npmCopy` (a package directory) is still there. */
|
|
25062
|
+
async claudeInstallAfter(binary, npmCopy) {
|
|
25063
|
+
const at = await this.locateBinaryOnLoginShell(binary).catch(() => null);
|
|
25064
|
+
const real = at ? await realpath(at).catch(() => null) : null;
|
|
25065
|
+
const kind = real ? claudeInstallKind(real, process.env, homedir()).kind : null;
|
|
25066
|
+
return { kind, path: real, npmLeftover: npmCopy && existsSync(npmCopy) ? npmCopy : null };
|
|
25067
|
+
}
|
|
24739
25068
|
/** A fresh login shell's answer for `binary`, else the installer's own directories (see locateBinaryOnLoginShell / locateInstalledBackend). */
|
|
24740
25069
|
async locateInstalledCli(backend, binary) {
|
|
24741
25070
|
return (await this.locateBinaryOnLoginShell(binary)) ?? (await this.locateInstalledBackend(backend));
|
|
@@ -28668,6 +28997,13 @@ export class FleetManager {
|
|
|
28668
28997
|
for (const pending of this.startupRetries.values())
|
|
28669
28998
|
clearTimeout(pending.timer);
|
|
28670
28999
|
this.startupRetries.clear();
|
|
29000
|
+
if (this.missingBinaryWatch) {
|
|
29001
|
+
clearInterval(this.missingBinaryWatch);
|
|
29002
|
+
this.missingBinaryWatch = null;
|
|
29003
|
+
}
|
|
29004
|
+
for (const pending of this.missingBinaryNotices?.values() ?? [])
|
|
29005
|
+
clearTimeout(pending.timer);
|
|
29006
|
+
this.missingBinaryNotices?.clear();
|
|
28671
29007
|
for (const pending of this.startupRetryNotices.values())
|
|
28672
29008
|
clearTimeout(pending.timer);
|
|
28673
29009
|
this.startupRetryNotices.clear();
|
|
@@ -30874,13 +31210,13 @@ export class FleetManager {
|
|
|
30874
31210
|
const { createRequire } = await import("node:module");
|
|
30875
31211
|
const _require2 = createRequire(import.meta.url);
|
|
30876
31212
|
const agendVersion2 = _require2("../package.json").version ?? "unknown";
|
|
30877
|
-
const progressCompleted = await restartProgress.finish({
|
|
31213
|
+
const progressCompleted = await restartProgress.finish(this.completionSummary({
|
|
30878
31214
|
running: started,
|
|
30879
31215
|
total,
|
|
30880
31216
|
version: agendVersion2,
|
|
30881
31217
|
pausedNames: pausedNames2,
|
|
30882
31218
|
failedNames,
|
|
30883
|
-
});
|
|
31219
|
+
}));
|
|
30884
31220
|
if (groupId && this.adapter) {
|
|
30885
31221
|
let restartText;
|
|
30886
31222
|
if (failedNames.length === 0 && pausedNames2.length === 0) {
|
|
@@ -31474,6 +31810,9 @@ export class FleetManager {
|
|
|
31474
31810
|
res.end(JSON.stringify({ error: "fleet stopping" }));
|
|
31475
31811
|
return;
|
|
31476
31812
|
}
|
|
31813
|
+
// M-3314: a versioned asset path goes through every check below as its plain path (the public link's gateway did
|
|
31814
|
+
// this already for its own requests; once per request).
|
|
31815
|
+
takeAssetVersion(req);
|
|
31477
31816
|
const requestPath = new URL(req.url ?? "/", `http://localhost:${port}`).pathname;
|
|
31478
31817
|
const publicUrl = new URL(req.url ?? "/", `http://localhost:${port}`);
|
|
31479
31818
|
if (remoteRuntimeEnabled() && !gatewayRequestContext(req)
|
|
@@ -31860,6 +32199,9 @@ export class FleetManager {
|
|
|
31860
32199
|
}
|
|
31861
32200
|
}
|
|
31862
32201
|
startHealthServer(port) {
|
|
32202
|
+
// M-3314: <V> describes the files this process started with, taken now — not at the first page, which may come after
|
|
32203
|
+
// an update rewrote them.
|
|
32204
|
+
warmAssetVersion();
|
|
31863
32205
|
let settled;
|
|
31864
32206
|
const listening = new Promise(resolve => { settled = resolve; });
|
|
31865
32207
|
this.startedAt = Date.now();
|