@songsid/agend 2.3.5-alpha.10 → 2.3.5-alpha.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 +17 -0
- package/dist/accounts-view.js +24 -8
- package/dist/accounts-view.js.map +1 -1
- package/dist/agent-cli-instructions.md +2 -2
- package/dist/auth-api.d.ts +48 -16
- package/dist/auth-api.js +83 -32
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/settings-role.d.ts +56 -0
- package/dist/authority/settings-role.js +48 -0
- package/dist/authority/settings-role.js.map +1 -0
- package/dist/backend/claude-code.d.ts +2 -0
- package/dist/backend/claude-code.js +32 -6
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/cli-env-probe.js +6 -2
- package/dist/backend/cli-env-probe.js.map +1 -1
- package/dist/backend/codex.d.ts +5 -3
- package/dist/backend/codex.js +31 -13
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/credential-profile.d.ts +18 -0
- package/dist/backend/credential-profile.js +46 -0
- package/dist/backend/credential-profile.js.map +1 -1
- package/dist/backend/kiro.js +1 -1
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/muse.d.ts +3 -1
- package/dist/backend/muse.js +31 -1
- package/dist/backend/muse.js.map +1 -1
- package/dist/backend/types.d.ts +17 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-availability.d.ts +15 -0
- package/dist/backend-availability.js +37 -1
- package/dist/backend-availability.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/bundled-tmux-guard.d.ts +4 -0
- package/dist/bundled-tmux-guard.js +7 -0
- package/dist/bundled-tmux-guard.js.map +1 -1
- package/dist/claude-auth-status.d.ts +20 -8
- package/dist/claude-auth-status.js +38 -22
- package/dist/claude-auth-status.js.map +1 -1
- package/dist/cli-audited.d.ts +60 -0
- package/dist/cli-audited.js +84 -0
- package/dist/cli-audited.js.map +1 -0
- package/dist/cli-capability.d.ts +36 -5
- package/dist/cli-capability.js +2 -2
- package/dist/cli-capability.js.map +1 -1
- package/dist/cli-caps-module.d.ts +5 -1
- package/dist/cli-caps-module.js +4 -2
- package/dist/cli-caps-module.js.map +1 -1
- package/dist/cli-registry-check.js +16 -2
- package/dist/cli-registry-check.js.map +1 -1
- package/dist/cli-registry.d.ts +56 -4
- package/dist/cli-registry.js +1 -1
- package/dist/cli-registry.js.map +1 -1
- package/dist/cli-spec-antigravity.d.ts +12 -1
- package/dist/cli-spec-antigravity.js +13 -1
- package/dist/cli-spec-antigravity.js.map +1 -1
- package/dist/cli-spec-claude-code.d.ts +9 -0
- package/dist/cli-spec-claude-code.js +4 -2
- package/dist/cli-spec-claude-code.js.map +1 -1
- package/dist/cli-spec-codex.d.ts +10 -1
- package/dist/cli-spec-codex.js +5 -3
- package/dist/cli-spec-codex.js.map +1 -1
- package/dist/cli-spec-grok.d.ts +5 -0
- package/dist/cli-spec-grok.js +6 -1
- package/dist/cli-spec-grok.js.map +1 -1
- package/dist/cli-spec-kiro-cli.d.ts +7 -1
- package/dist/cli-spec-kiro-cli.js +7 -3
- package/dist/cli-spec-kiro-cli.js.map +1 -1
- package/dist/cli-spec-muse.d.ts +2 -0
- package/dist/cli-spec-muse.js +3 -1
- package/dist/cli-spec-muse.js.map +1 -1
- package/dist/cli-spec-opencode.d.ts +11 -1
- package/dist/cli-spec-opencode.js +7 -2
- package/dist/cli-spec-opencode.js.map +1 -1
- package/dist/cli.js +28 -1
- package/dist/cli.js.map +1 -1
- package/dist/create-host-account.d.ts +17 -0
- package/dist/create-host-account.js +47 -0
- package/dist/create-host-account.js.map +1 -0
- package/dist/daemon.d.ts +26 -0
- package/dist/daemon.js +131 -10
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-outbox.js +7 -0
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-context.d.ts +5 -1
- package/dist/fleet-manager.d.ts +363 -71
- package/dist/fleet-manager.js +1374 -367
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-process-handlers.d.ts +1 -1
- package/dist/fleet-process-handlers.js +3 -2
- package/dist/fleet-process-handlers.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +21 -14
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +9 -8
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +9 -1
- package/dist/general-knowledge/skills/kiro-engine-migration/SKILL.md +1 -1
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +27 -20
- package/dist/instance-lifecycle.js +33 -3
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.js +29 -6
- package/dist/instructions.js.map +1 -1
- package/dist/locale.js +125 -81
- package/dist/locale.js.map +1 -1
- package/dist/login-manager.d.ts +2 -2
- package/dist/login-manager.js +3 -2
- package/dist/login-manager.js.map +1 -1
- package/dist/native-model-catalog.d.ts +20 -0
- package/dist/native-model-catalog.js +107 -2
- package/dist/native-model-catalog.js.map +1 -1
- package/dist/public-web-gateway.js +1 -1
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/public-web-link.d.ts +5 -0
- package/dist/public-web-link.js +8 -0
- package/dist/public-web-link.js.map +1 -1
- package/dist/runtime-api.d.ts +1 -1
- package/dist/runtime-api.js +104 -12
- package/dist/runtime-api.js.map +1 -1
- package/dist/runtime-autostart.d.ts +61 -0
- package/dist/runtime-autostart.js +161 -0
- package/dist/runtime-autostart.js.map +1 -0
- package/dist/runtime-background.d.ts +200 -0
- package/dist/runtime-background.js +480 -0
- package/dist/runtime-background.js.map +1 -0
- package/dist/runtime-build-info.js +5 -5
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/runtime-cli-background.d.ts +92 -0
- package/dist/runtime-cli-background.js +336 -0
- package/dist/runtime-cli-background.js.map +1 -0
- package/dist/runtime-cli-install.d.ts +148 -8
- package/dist/runtime-cli-install.js +253 -59
- package/dist/runtime-cli-install.js.map +1 -1
- package/dist/runtime-cli.d.ts +8 -1
- package/dist/runtime-cli.js +206 -44
- package/dist/runtime-cli.js.map +1 -1
- package/dist/runtime-client-store.d.ts +11 -0
- package/dist/runtime-client-store.js +20 -5
- package/dist/runtime-client-store.js.map +1 -1
- package/dist/runtime-client.d.ts +23 -1
- package/dist/runtime-client.js +92 -6
- package/dist/runtime-client.js.map +1 -1
- package/dist/runtime-connection.d.ts +1 -1
- package/dist/runtime-connection.js +1 -1
- package/dist/runtime-connection.js.map +1 -1
- package/dist/runtime-coordinator.d.ts +95 -1
- package/dist/runtime-coordinator.js +344 -10
- package/dist/runtime-coordinator.js.map +1 -1
- package/dist/runtime-enroll-notice.d.ts +4 -0
- package/dist/runtime-enroll-notice.js +21 -0
- package/dist/runtime-enroll-notice.js.map +1 -0
- package/dist/runtime-enrollment.d.ts +21 -0
- package/dist/runtime-enrollment.js +52 -0
- package/dist/runtime-enrollment.js.map +1 -0
- package/dist/runtime-pane-native.js +4 -4
- package/dist/runtime-pane-native.js.map +1 -1
- package/dist/runtime-protocol.d.ts +78 -1
- package/dist/runtime-protocol.js +95 -5
- package/dist/runtime-protocol.js.map +1 -1
- package/dist/runtime-remote-accounts.d.ts +12 -0
- package/dist/runtime-remote-accounts.js +56 -5
- package/dist/runtime-remote-accounts.js.map +1 -1
- package/dist/runtime-remote-setup.d.ts +4 -1
- package/dist/runtime-remote-setup.js +4 -1
- package/dist/runtime-remote-setup.js.map +1 -1
- package/dist/runtime-update-controller.d.ts +11 -0
- package/dist/runtime-update-controller.js +56 -4
- package/dist/runtime-update-controller.js.map +1 -1
- package/dist/settings-api.d.ts +13 -1
- package/dist/settings-api.js +44 -20
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.d.ts +5 -13
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-confirmation.d.ts +11 -13
- package/dist/settings-confirmation.js +2 -6
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.d.ts +5 -0
- package/dist/settings-effect.js +76 -10
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +8 -1
- package/dist/settings-http-confirmation.js +39 -13
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-request-capability.d.ts +7 -0
- package/dist/settings-request-capability.js +3 -1
- package/dist/settings-request-capability.js.map +1 -1
- package/dist/setup-i18n.js +4 -4
- package/dist/setup-i18n.js.map +1 -1
- package/dist/signin-keepalive.d.ts +25 -1
- package/dist/signin-keepalive.js +44 -1
- package/dist/signin-keepalive.js.map +1 -1
- package/dist/subagent-records.d.ts +45 -0
- package/dist/subagent-records.js +214 -0
- package/dist/subagent-records.js.map +1 -0
- package/dist/subagent-service.d.ts +27 -0
- package/dist/subagent-service.js +199 -0
- package/dist/subagent-service.js.map +1 -0
- package/dist/tmux-manager.d.ts +2 -2
- package/dist/tmux-manager.js +5 -3
- package/dist/tmux-manager.js.map +1 -1
- package/dist/ui/account-identity.js +7 -5
- package/dist/ui/accounts-keepalive.js +17 -17
- package/dist/ui/accounts-manage.js +34 -34
- package/dist/ui/accounts-view.js +68 -24
- package/dist/ui/agent-runtime-settings.js +1 -1
- package/dist/ui/backend-signin.js +67 -67
- package/dist/ui/chat-msg-actions.js +50 -4
- package/dist/ui/chat-quote.js +256 -0
- package/dist/ui/chat-store.js +9 -4
- package/dist/ui/cli-caps.js +7 -7
- package/dist/ui/credential-profile-select.js +4 -4
- package/dist/ui/general-location.js +1 -1
- package/dist/ui/host-install.js +290 -0
- package/dist/ui/hub-company-join-strings.js +3 -0
- package/dist/ui/hub-company-join.js +20 -2
- package/dist/ui/hub-owner-strings.js +5 -4
- package/dist/ui/hub-pairing-progress-strings.js +1 -1
- package/dist/ui/hub-quick-strings.js +4 -4
- package/dist/ui/hub-strings.js +6 -6
- package/dist/ui/machine-signin.js +4 -4
- package/dist/ui/model-picker.js +68 -0
- package/dist/ui/panel-chat.js +74 -13
- package/dist/ui/panel-fleet.js +8 -2
- package/dist/ui/panel-hub.js +8 -4
- package/dist/ui/panel-needs.js +2 -2
- package/dist/ui/panel-runtimes.js +232 -33
- package/dist/ui/panel-settings.js +7 -1
- package/dist/ui/panel-windows-cli.js +1 -1
- package/dist/ui/runtime-cli-install.js +99 -20
- package/dist/ui/runtime-commands.d.ts +2 -0
- package/dist/ui/runtime-commands.js +34 -1
- package/dist/ui/runtime-update-status.js +2 -2
- package/dist/ui/search-dialog.js +1 -0
- package/dist/ui/settings-access-overview.js +167 -0
- package/dist/ui/settings-access-strings.js +1 -1
- package/dist/ui/settings-catalog.js +19 -3
- package/dist/ui/settings-confirm.js +2 -2
- package/dist/ui/settings-devices.js +59 -25
- package/dist/ui/settings-dialogs.js +12 -13
- package/dist/ui/settings-guests.js +1 -1
- package/dist/ui/settings-hub-company-join.js +10 -7
- package/dist/ui/settings-hub-connection.js +121 -0
- package/dist/ui/settings-hub-membership.js +1 -1
- package/dist/ui/settings-hub-run.js +5 -6
- package/dist/ui/settings-hub-section.js +3 -6
- package/dist/ui/settings-hub.js +12 -7
- package/dist/ui/settings-layout.js +9 -7
- package/dist/ui/settings-outside.js +87 -19
- package/dist/ui/settings-registry.js +2 -1
- package/dist/ui/settings-revoke-strings.js +28 -0
- package/dist/ui/settings-strings.js +25 -25
- package/dist/ui/settings-web-authority.js +11 -4
- package/dist/ui/shared/accounts.css +11 -1
- package/dist/ui/shared/agend-auth.js +8 -1
- package/dist/ui/shared/app-i18n.js +10 -12
- package/dist/ui/shared/app-session.js +13 -16
- package/dist/ui/shared/app-shell.js +37 -37
- package/dist/ui/shared/app-store.js +2 -0
- package/dist/ui/shared/app.css +85 -14
- package/dist/ui/shared/chat-render.js +17 -5
- package/dist/ui/shared/chat-strings.js +4 -4
- package/dist/ui/shared/device-roles.js +27 -0
- package/dist/ui/shared/host-install.css +10 -0
- package/dist/ui/shared/hub-owner.css +6 -0
- package/dist/ui/shared/model-picker.css +21 -0
- package/dist/ui/shared/runtime-install.css +26 -1
- package/dist/ui/shared/setup-host-text.js +4 -4
- package/dist/ui/shared/signin.js +171 -64
- package/dist/ui/shared/subagent-row.css +15 -0
- package/dist/ui/shared/usage-dialog.js +28 -16
- package/dist/ui/shared/view-strings.js +7 -7
- package/dist/ui/shared/web-authorize.js +54 -4
- package/dist/ui/signin.html +19 -8
- package/dist/ui/structured-signin.js +30 -30
- package/dist/ui/subagent-row.js +72 -0
- package/dist/ui/web-terminal/terminal.js +9 -9
- package/dist/update-launch.js +4 -1
- package/dist/update-launch.js.map +1 -1
- package/dist/update-npm-env.d.ts +70 -0
- package/dist/update-npm-env.js +128 -0
- package/dist/update-npm-env.js.map +1 -0
- package/dist/usage/format-rich.js +1 -1
- package/dist/usage/format-rich.js.map +1 -1
- package/dist/usage/providers.js +2 -2
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/usage-api.d.ts +8 -2
- package/dist/usage/usage-api.js +12 -5
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/web-api.d.ts +38 -4
- package/dist/web-api.js +370 -18
- package/dist/web-api.js.map +1 -1
- package/dist/web-auth.js +1 -1
- package/dist/web-auth.js.map +1 -1
- package/dist/web-backend-login.d.ts +2 -0
- package/dist/web-backend-login.js.map +1 -1
- package/dist/web-channel-echo.js +3 -1
- package/dist/web-channel-echo.js.map +1 -1
- package/dist/web-commands.d.ts +9 -1
- package/dist/web-commands.js +7 -1
- package/dist/web-commands.js.map +1 -1
- package/dist/web-host-install.d.ts +127 -0
- package/dist/web-host-install.js +165 -0
- package/dist/web-host-install.js.map +1 -0
- package/dist/web-remote-access.d.ts +194 -11
- package/dist/web-remote-access.js +458 -34
- package/dist/web-remote-access.js.map +1 -1
- package/dist/web-session.d.ts +11 -3
- package/dist/web-session.js.map +1 -1
- package/dist/web-signin-device.d.ts +16 -0
- package/dist/web-signin-device.js +81 -0
- package/dist/web-signin-device.js.map +1 -0
- package/dist/web-update.js +3 -1
- package/dist/web-update.js.map +1 -1
- package/dist/windows-cli-api.js +2 -1
- package/dist/windows-cli-api.js.map +1 -1
- package/dist/windows-cli-worker.d.ts +14 -0
- package/dist/windows-cli-worker.js +145 -1
- package/dist/windows-cli-worker.js.map +1 -1
- package/dist/windows-cli.d.ts +4 -0
- package/dist/windows-cli.js +9 -1
- package/dist/windows-cli.js.map +1 -1
- package/launcher/agend-install.cjs +16 -3
- package/package.json +1 -1
- package/templates/runtime-install/install.ps1 +219 -12
package/dist/web-api.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type { OfficePackTools } from "./web-office-pack-tools.js";
|
|
|
14
14
|
import type { WebAppearance } from "./web-appearance.js";
|
|
15
15
|
import type { WebUpdateHost } from "./web-update.js";
|
|
16
16
|
import type { SendOpts } from "./channel/types.js";
|
|
17
|
+
import { type WebModelAction } from "./web-commands.js";
|
|
17
18
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
18
19
|
import type { LifecycleCreateArgs } from "./instance-lifecycle.js";
|
|
19
20
|
import { type Actor as BoardActor, type TaskBoard } from "./scheduler/task-board.js";
|
|
@@ -67,7 +68,9 @@ export interface WebApiContext {
|
|
|
67
68
|
/** #2072: what this host can run (the published snapshot); absent in a hand-built context. */
|
|
68
69
|
backendAvailabilityRows?(): import("./backend-availability.js").BackendAvailability[];
|
|
69
70
|
/** #2072: a backend's cached model catalog, for an instance's own account when one is named; never a probe. */
|
|
70
|
-
modelCatalogFor?(backend: string, instance: string | null
|
|
71
|
+
modelCatalogFor?(backend: string, instance: string | null, selection?: {
|
|
72
|
+
profile?: string;
|
|
73
|
+
}): Array<{
|
|
71
74
|
id: string;
|
|
72
75
|
label: string;
|
|
73
76
|
description?: string;
|
|
@@ -78,10 +81,22 @@ export interface WebApiContext {
|
|
|
78
81
|
label: string;
|
|
79
82
|
description?: string;
|
|
80
83
|
}>>;
|
|
84
|
+
refreshModelCatalogFor?(backend: string, instance: string | null, selection?: {
|
|
85
|
+
profile?: string;
|
|
86
|
+
}): Promise<{
|
|
87
|
+
models: Array<{
|
|
88
|
+
id: string;
|
|
89
|
+
label: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
}>;
|
|
92
|
+
refreshed: boolean;
|
|
93
|
+
}>;
|
|
81
94
|
/** Absent in a hand-built context: cookies are then simply not a credential, the header token still is. */
|
|
82
95
|
readonly webSessions?: WebSessionStore | null;
|
|
83
96
|
/** #2233: dashboard-started backend sign-ins (FleetManager); absent in a hand-built context. */
|
|
84
97
|
readonly webBackendLogins?: import("./web-backend-login.js").WebBackendLogins;
|
|
98
|
+
/** AGEND-133: the Install button of Settings → Agents → AI sign-ins (FleetManager.webHostInstalls); absent in a hand-built context. */
|
|
99
|
+
readonly webHostInstalls?: import("./web-host-install.js").WebHostInstalls;
|
|
85
100
|
readonly browserBackendSignIns?: import("./browser-backend-signins.js").BrowserBackendSignIns;
|
|
86
101
|
/** #3190 Part 3c: dashboard sign-ins on a paired computer (machine-signins.ts), reached through the same `/ui/browser-backend-signins` with `?machine=&profile=`. */
|
|
87
102
|
readonly machineSignIns?: import("./machine-signins.js").MachineSignIns;
|
|
@@ -121,6 +136,8 @@ export interface WebApiContext {
|
|
|
121
136
|
description?: string;
|
|
122
137
|
display_name?: string;
|
|
123
138
|
backend?: string;
|
|
139
|
+
model?: string;
|
|
140
|
+
backend_options?: Record<string, Record<string, unknown>>;
|
|
124
141
|
runtime?: "wsl" | "windows";
|
|
125
142
|
machine_id?: string;
|
|
126
143
|
native_agent_id?: string;
|
|
@@ -336,6 +353,7 @@ export interface WebApiContext {
|
|
|
336
353
|
delegations?: unknown[];
|
|
337
354
|
};
|
|
338
355
|
/** #1218: an instance's Log steps, read on demand (null: no such instance; `{ enabled: false }`: the Log is off). */
|
|
356
|
+
subagentRuns?(name: string): Promise<import("./subagent-service.js").SubagentAnswer>;
|
|
339
357
|
logSteps?(name: string, q: import("./log-service.js").LogQuery): Promise<unknown>;
|
|
340
358
|
/** #1468: the prompt-cache expiry analysis for a window ("24h" | "7d" | "30d"); absent: not offered. */
|
|
341
359
|
cacheReport?(window: string): Promise<unknown>;
|
|
@@ -352,6 +370,7 @@ export interface WebApiContext {
|
|
|
352
370
|
command: string;
|
|
353
371
|
args?: string;
|
|
354
372
|
confirm?: string;
|
|
373
|
+
action?: WebModelAction;
|
|
355
374
|
}, opts: {
|
|
356
375
|
publicLink: boolean;
|
|
357
376
|
person?: WebPerson;
|
|
@@ -419,13 +438,23 @@ export interface WebApiContext {
|
|
|
419
438
|
/** #3008: connections from outside — what Settings shows (the link's address only to this computer's admin here). */
|
|
420
439
|
webOutsideStatus?(req: IncomingMessage): Record<string, unknown>;
|
|
421
440
|
/** #3008: set up the authenticator (this computer's admin, here only): a new secret, shown once. Null: not them. */
|
|
422
|
-
webOutsideBeginEnrollment?(req: IncomingMessage): {
|
|
441
|
+
webOutsideBeginEnrollment?(req: IncomingMessage, code?: string): {
|
|
423
442
|
secret: string;
|
|
424
443
|
uri: string;
|
|
425
444
|
expiresInMs: number;
|
|
445
|
+
} | {
|
|
446
|
+
error: "code_required" | "wrong" | "paused" | "unavailable" | "not_here";
|
|
447
|
+
retryAfterMs?: number;
|
|
426
448
|
} | null;
|
|
427
|
-
webOutsideConfirmEnrollment?(req: IncomingMessage, code: string): "ok" | "wrong" | "expired" | "unsaved" | "not_here";
|
|
428
|
-
webOutsideRemove?(req: IncomingMessage): "ok" | "unsaved" | "not_here"
|
|
449
|
+
webOutsideConfirmEnrollment?(req: IncomingMessage, code: string): "ok" | "wrong" | "expired" | "unsaved" | "not_here" | "full";
|
|
450
|
+
webOutsideRemove?(req: IncomingMessage, code?: string): "ok" | "unsaved" | "not_here" | {
|
|
451
|
+
error: "code_required" | "wrong" | "paused" | "unavailable";
|
|
452
|
+
retryAfterMs?: number;
|
|
453
|
+
};
|
|
454
|
+
webOutsideStrict?(req: IncomingMessage, on: boolean, code?: string): "ok" | "not_enrolled" | "not_here" | "unsaved" | {
|
|
455
|
+
error: "code_required" | "wrong" | "paused" | "unavailable";
|
|
456
|
+
retryAfterMs?: number;
|
|
457
|
+
};
|
|
429
458
|
webOutsideSwitch?(req: IncomingMessage, on: boolean): "ok" | "not_enrolled" | "not_here" | "not_allowed" | "unsaved";
|
|
430
459
|
/** Refs #3061 (P2a): a web-only fleet's new-device approval — may this session approve (the verified owner), and the decision itself. */
|
|
431
460
|
webDevicesStatus?(req: IncomingMessage): {
|
|
@@ -443,6 +472,11 @@ export interface WebApiContext {
|
|
|
443
472
|
status: number;
|
|
444
473
|
body: Record<string, unknown>;
|
|
445
474
|
};
|
|
475
|
+
/** S-120 (D2a): close the open public link now (Settings → 存取與安全 → 總覽). Only closes; the route checks who asks. */
|
|
476
|
+
closePublicLinkFromWeb?(): Promise<{
|
|
477
|
+
status: number;
|
|
478
|
+
body: Record<string, unknown>;
|
|
479
|
+
}>;
|
|
446
480
|
/** #2910 D2: a web-only fleet's Notices (web-notices.ts); null on a fleet whose General says them. */
|
|
447
481
|
webNoticesFeed?(): {
|
|
448
482
|
view(): {
|
package/dist/web-api.js
CHANGED
|
@@ -8,7 +8,7 @@ import { classifyWebPeer, confirmAfterBody, noAuthority } from "./authority/web-
|
|
|
8
8
|
import { guestChatRefusal, guestCommandText, guestDeliveries, GUEST_PREF_MAX_BYTES, GUEST_SEARCHES, guestFrameData, guestHistory, guestMessages, guestOwnPrefs, guestPollBody, guestPrefs, guestRequestOf, guestSeesMessage, guestStatus } from "./web-guest-access.js";
|
|
9
9
|
import { withSpawnHoldReply } from "./spawn-hold-reply.js";
|
|
10
10
|
import { binaryProbe } from "./binary-probe.js";
|
|
11
|
-
import { settingsRequestExecution, settingsWrite, isSettingsReplay } from "./settings-request-capability.js";
|
|
11
|
+
import { settingsRequestExecution, settingsRequestLocalAdmin, settingsRequestRequester, settingsWrite, isSettingsReplay } from "./settings-request-capability.js";
|
|
12
12
|
import { readBoundedWebBody } from "./web-body.js";
|
|
13
13
|
import { APP_ICON_MAX_BYTES } from "./web-app-icon.js";
|
|
14
14
|
import { withAppIconLinks } from "./web-icons.js";
|
|
@@ -21,6 +21,9 @@ import { SKIN_WIRE_BYTES } from "./web-office-skins.js";
|
|
|
21
21
|
import { gatewayRequestContext } from "./web-request-context.js";
|
|
22
22
|
import { crossInstanceVisibility } from "./cross-instance-notice.js";
|
|
23
23
|
import { permitWebContinuation } from "./web-continuation.js";
|
|
24
|
+
import { HOST_CLI_PATHS, isRuntimeCliInstallPath } from "./settings-effect.js";
|
|
25
|
+
import { hostUpdateAckError } from "./web-host-install.js";
|
|
26
|
+
import { LATEST_ACK_FIELD } from "./cli-audited.js";
|
|
24
27
|
/**
|
|
25
28
|
* Web UI HTTP API handler.
|
|
26
29
|
* All /ui/* routes are handled here, extracted from fleet-manager.ts.
|
|
@@ -64,10 +67,11 @@ import { QUERY_MAX_CHARS, RESULT_MAX, SEARCH_SOURCES } from "./search/search-sto
|
|
|
64
67
|
import { xmsgShown } from "./search/search-docs.js";
|
|
65
68
|
import { WebSendDedupe } from "./web-send-dedupe.js";
|
|
66
69
|
import { handleWindowsCliRequest, nativeCliAuthorization } from "./windows-cli-api.js";
|
|
70
|
+
import { resolveCreateAccount } from "./create-host-account.js";
|
|
67
71
|
import { createNativeInstance, handleNativeInstanceRequest } from "./native-instance-api.js";
|
|
68
72
|
import { handleAgentRuntimeChange } from "./agent-runtime-api.js";
|
|
69
73
|
import { isWindowsInstance, isNativePaneInstance, isNativeExecInstance } from "./native-instance-registry.js";
|
|
70
|
-
import { handleNativeModelCatalog } from "./native-model-catalog.js";
|
|
74
|
+
import { handleNativeModelCatalog, refreshNativeModelCatalog } from "./native-model-catalog.js";
|
|
71
75
|
import { claudeDocumentedModels } from "./model-catalog-defaults.js";
|
|
72
76
|
import { handleRuntimeRequest } from "./runtime-api.js";
|
|
73
77
|
import { taskBoardOffNames } from "./dashboard-permissions.js";
|
|
@@ -1559,6 +1563,124 @@ function handleBackendLogin(req, res, url, ctx, path, method) {
|
|
|
1559
1563
|
catch { /* response ended */ } });
|
|
1560
1564
|
return true;
|
|
1561
1565
|
}
|
|
1566
|
+
/**
|
|
1567
|
+
* AGEND-133 (upstream #3521): installing a CLI on the AgEnD host from the dashboard (web-host-install.ts). The gate is the sign-in routes' own — a signed-in admin
|
|
1568
|
+
* session on the local surface; never the CLI's header token (an agent's), a guest, a read session, or the public link (refused before the body is read, and again
|
|
1569
|
+
* after it). `GET` reads the current install; `POST` `{ backend }` starts one — the browser names a CLI, the server looks up the registry's command, nothing it sends
|
|
1570
|
+
* is ever run; `POST …/cancel` `{}` stops the running one. Every answer is no-store.
|
|
1571
|
+
*/
|
|
1572
|
+
const HOST_INSTALL_STATUS = { not_allowed: 403, unsupported: 400, already: 409, not_installed: 409, up_to_date: 409, version_unreadable: 409, busy: 409, shutting_down: 503, failed: 500 };
|
|
1573
|
+
function handleHostInstall(req, res, url, ctx, path, method) {
|
|
1574
|
+
res.setHeader("Cache-Control", "private, no-store");
|
|
1575
|
+
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
1576
|
+
const reading = method === "GET";
|
|
1577
|
+
if (gatewayRequestContext(req)) {
|
|
1578
|
+
json(res, reading ? 404 : 403, { error: "install_not_over_public_link" });
|
|
1579
|
+
return true;
|
|
1580
|
+
}
|
|
1581
|
+
const who = () => {
|
|
1582
|
+
if (isSettingsReplay(req)) {
|
|
1583
|
+
const requester = settingsRequestRequester(req);
|
|
1584
|
+
if (!requester || !settingsRequestLocalAdmin(req))
|
|
1585
|
+
return { error: "install_needs_a_local_admin", status: 403 };
|
|
1586
|
+
return requester;
|
|
1587
|
+
}
|
|
1588
|
+
const v = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
|
|
1589
|
+
if (v.kind !== "allow")
|
|
1590
|
+
return { error: WEB_TOKEN_INVALID_MESSAGE, status: 401 };
|
|
1591
|
+
if (v.via !== "session" || v.session.tier !== "admin" || v.session.surface !== "local")
|
|
1592
|
+
return { error: "install_needs_a_local_admin", status: 403 };
|
|
1593
|
+
return { handle: v.session.handle, label: v.session.label };
|
|
1594
|
+
};
|
|
1595
|
+
const first = who();
|
|
1596
|
+
if ("error" in first) {
|
|
1597
|
+
json(res, first.status, { error: first.error });
|
|
1598
|
+
return true;
|
|
1599
|
+
}
|
|
1600
|
+
const installs = ctx.webHostInstalls;
|
|
1601
|
+
if (!installs) {
|
|
1602
|
+
json(res, 404, { error: "install_unavailable" });
|
|
1603
|
+
return true;
|
|
1604
|
+
}
|
|
1605
|
+
if (reading && path === "/ui/host-install" && [...url.searchParams.keys()].length === 0) {
|
|
1606
|
+
try {
|
|
1607
|
+
json(res, 200, { install: installs.view() });
|
|
1608
|
+
}
|
|
1609
|
+
catch {
|
|
1610
|
+
json(res, 503, { error: "install_unavailable" });
|
|
1611
|
+
}
|
|
1612
|
+
return true;
|
|
1613
|
+
}
|
|
1614
|
+
// Cancel only takes something away (any local admin may stop it, as `/login cancel`): it is not a held change. Install and Update (AGEND-136) are, and run only as the gate's confirmed replay.
|
|
1615
|
+
if (method !== "POST" || (path !== "/ui/host-install/cancel" && !HOST_CLI_PATHS.has(path))) {
|
|
1616
|
+
json(res, 404, { error: "not_found" });
|
|
1617
|
+
return true;
|
|
1618
|
+
}
|
|
1619
|
+
(async () => {
|
|
1620
|
+
let bytes;
|
|
1621
|
+
try {
|
|
1622
|
+
bytes = await readBoundedWebBody(req, 1024);
|
|
1623
|
+
}
|
|
1624
|
+
catch {
|
|
1625
|
+
json(res, 413, { error: "install_body_bound" });
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
if (!permitWebContinuation(req, res, ctx))
|
|
1629
|
+
return;
|
|
1630
|
+
const now = who();
|
|
1631
|
+
if ("error" in now) {
|
|
1632
|
+
json(res, now.status, { error: now.error });
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
if (now.handle !== first.handle) {
|
|
1636
|
+
json(res, 409, { error: "install_session_changed" });
|
|
1637
|
+
return;
|
|
1638
|
+
}
|
|
1639
|
+
let body;
|
|
1640
|
+
try {
|
|
1641
|
+
body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
1642
|
+
}
|
|
1643
|
+
catch {
|
|
1644
|
+
json(res, 400, { error: "install_json" });
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
if (path === "/ui/host-install/cancel") {
|
|
1648
|
+
if (!z.strictObject({}).safeParse(body).success) {
|
|
1649
|
+
json(res, 400, { error: "install_args" });
|
|
1650
|
+
return;
|
|
1651
|
+
}
|
|
1652
|
+
json(res, 200, { cancelled: await installs.cancel() });
|
|
1653
|
+
return;
|
|
1654
|
+
}
|
|
1655
|
+
// AGEND-154 (Prism P2-1 on #3552): an update may carry `acceptLatestUnaudited: true` (only the page that knows the named exception sends it); the request and the registry must agree (below).
|
|
1656
|
+
const parsed = z.strictObject({ backend: z.string().regex(/^[a-z][a-z0-9-]{0,31}$/), ...(path === "/ui/host-update" ? { [LATEST_ACK_FIELD]: z.literal(true).optional() } : {}) }).safeParse(body);
|
|
1657
|
+
if (!parsed.success) {
|
|
1658
|
+
json(res, 400, { error: "install_args" });
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
if (!isSettingsReplay(req) || !settingsRequestExecution(req)) {
|
|
1662
|
+
json(res, 403, { error: "install_confirmation_required" });
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
if (path === "/ui/host-update") {
|
|
1666
|
+
const ackError = hostUpdateAckError(parsed.data.backend, parsed.data[LATEST_ACK_FIELD]);
|
|
1667
|
+
if (ackError) {
|
|
1668
|
+
json(res, 409, { error: ackError });
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
// AGEND-136: `POST /ui/host-update { backend }` is the same request for an update: the server picks the command and the audited release; the page sends only the CLI's id.
|
|
1673
|
+
const result = await installs.begin(now, parsed.data.backend, settingsRequestExecution(req), path === "/ui/host-update" ? "update" : "install");
|
|
1674
|
+
if ("error" in result)
|
|
1675
|
+
json(res, HOST_INSTALL_STATUS[result.error] ?? 409, { error: result.error, ...(result.message ? { message: result.message } : {}) });
|
|
1676
|
+
else
|
|
1677
|
+
json(res, 200, result);
|
|
1678
|
+
})().catch(() => { try {
|
|
1679
|
+
json(res, 500, { error: "install_request_failed" });
|
|
1680
|
+
}
|
|
1681
|
+
catch { /* response ended */ } });
|
|
1682
|
+
return true;
|
|
1683
|
+
}
|
|
1562
1684
|
/**
|
|
1563
1685
|
* #3212 PR 2: Settings → Accounts — `POST /ui/accounts/<backend>` `{ name }` adds a named account (a credential profile's
|
|
1564
1686
|
* folder); `DELETE /ui/accounts/<backend>/<name>` `{ confirm: <name> }` removes one (accounts-profiles.ts: every refusal
|
|
@@ -2368,7 +2490,7 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
2368
2490
|
// the panel instead of comparing null against a missing credential.
|
|
2369
2491
|
if (path.startsWith("/ui")) {
|
|
2370
2492
|
const approved = isSettingsReplay(req) && method === "POST"
|
|
2371
|
-
&& (path === "/ui/config" || path === "/ui/instances" || /^\/ui\/instances\/[^/]+\/delete$/.test(path))
|
|
2493
|
+
&& (path === "/ui/config" || path === "/ui/instances" || /^\/ui\/instances\/[^/]+\/delete$/.test(path) || HOST_CLI_PATHS.has(path) || isRuntimeCliInstallPath(path))
|
|
2372
2494
|
? settingsRequestExecution(req) : undefined;
|
|
2373
2495
|
if (approved) {
|
|
2374
2496
|
try {
|
|
@@ -2464,6 +2586,77 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
2464
2586
|
}
|
|
2465
2587
|
// ── Backend detection ─────────────────────────────────
|
|
2466
2588
|
// #2072: the model a Settings field offers — the cached catalog of that backend (that instance's account's). Read only.
|
|
2589
|
+
if (method === "POST" && path === "/ui/models/refresh") {
|
|
2590
|
+
const admission = adminAdmissionOf(req, url, ctx);
|
|
2591
|
+
if (!admission) {
|
|
2592
|
+
json(res, 403, { error: "admin_required" });
|
|
2593
|
+
return true;
|
|
2594
|
+
}
|
|
2595
|
+
void (async () => {
|
|
2596
|
+
let body;
|
|
2597
|
+
try {
|
|
2598
|
+
body = await parseBody(req);
|
|
2599
|
+
}
|
|
2600
|
+
catch {
|
|
2601
|
+
json(res, 400, { error: "Invalid JSON" });
|
|
2602
|
+
return;
|
|
2603
|
+
}
|
|
2604
|
+
if (!permitWebContinuation(req, res, ctx))
|
|
2605
|
+
return;
|
|
2606
|
+
if (adminAdmissionOf(req, url, ctx) !== admission) {
|
|
2607
|
+
json(res, 403, { error: "admin_required" });
|
|
2608
|
+
return;
|
|
2609
|
+
}
|
|
2610
|
+
if (!body || Array.isArray(body) || typeof body !== "object" || Object.keys(body).some(k => !["backend", "instance", "runtime", "machineId", "profile"].includes(k))) {
|
|
2611
|
+
json(res, 400, { error: "invalid model target" });
|
|
2612
|
+
return;
|
|
2613
|
+
}
|
|
2614
|
+
const backend = body.backend, instance = body.instance ?? null;
|
|
2615
|
+
if (typeof backend !== "string" || !/^[a-z][a-z0-9-]{0,31}$/.test(backend) || (instance !== null && (typeof instance !== "string" || !isSafeInstanceName(instance)))) {
|
|
2616
|
+
json(res, 400, { error: "invalid model target" });
|
|
2617
|
+
return;
|
|
2618
|
+
}
|
|
2619
|
+
const runtime = body.runtime, machineId = body.machineId, profile = body.profile;
|
|
2620
|
+
if (runtime !== undefined && runtime !== "windows" && runtime !== "wsl" || machineId !== undefined && (typeof machineId !== "string" || !/^[a-f0-9-]{36}$/i.test(machineId)) || profile !== undefined && (typeof profile !== "string" || profile !== "" && !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(profile))) {
|
|
2621
|
+
json(res, 400, { error: "invalid model target" });
|
|
2622
|
+
return;
|
|
2623
|
+
}
|
|
2624
|
+
const target = { backend, instance, ...(runtime ? { runtime: runtime } : {}), ...(machineId ? { machineId: machineId } : {}), ...(profile !== undefined ? { profile: profile } : {}) };
|
|
2625
|
+
let result;
|
|
2626
|
+
try {
|
|
2627
|
+
result = await refreshNativeModelCatalog(req, url, ctx, target);
|
|
2628
|
+
// Recheck after runtime selection, before any portable probe is admitted.
|
|
2629
|
+
if (!permitWebContinuation(req, res, ctx))
|
|
2630
|
+
return;
|
|
2631
|
+
if (adminAdmissionOf(req, url, ctx) !== admission) {
|
|
2632
|
+
json(res, 403, { error: "admin_required" });
|
|
2633
|
+
return;
|
|
2634
|
+
}
|
|
2635
|
+
if (!result) {
|
|
2636
|
+
if (machineId || !ctx.refreshModelCatalogFor) {
|
|
2637
|
+
json(res, 503, { error: "model_refresh_unavailable" });
|
|
2638
|
+
return;
|
|
2639
|
+
}
|
|
2640
|
+
result = await (profile !== undefined ? ctx.refreshModelCatalogFor(backend, instance, { profile: profile }) : ctx.refreshModelCatalogFor(backend, instance));
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
catch {
|
|
2644
|
+
if (!permitWebContinuation(req, res, ctx))
|
|
2645
|
+
return;
|
|
2646
|
+
json(res, 503, { error: "model_refresh_unavailable" });
|
|
2647
|
+
return;
|
|
2648
|
+
}
|
|
2649
|
+
if (!permitWebContinuation(req, res, ctx))
|
|
2650
|
+
return;
|
|
2651
|
+
if (adminAdmissionOf(req, url, ctx) !== admission) {
|
|
2652
|
+
json(res, 403, { error: "admin_required" });
|
|
2653
|
+
return;
|
|
2654
|
+
}
|
|
2655
|
+
json(res, 200, { backend, ...result });
|
|
2656
|
+
})().catch(() => { if (!res.headersSent)
|
|
2657
|
+
json(res, 500, { error: "model_refresh_failed" }); });
|
|
2658
|
+
return true;
|
|
2659
|
+
}
|
|
2467
2660
|
if (method === "GET" && path === "/ui/models") {
|
|
2468
2661
|
const backend = url.searchParams.get("backend") ?? "";
|
|
2469
2662
|
const instance = url.searchParams.get("instance");
|
|
@@ -2481,11 +2674,16 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
2481
2674
|
json(res, 400, { error: "Invalid model catalog options" });
|
|
2482
2675
|
return true;
|
|
2483
2676
|
}
|
|
2677
|
+
const profile = url.searchParams.get("profile");
|
|
2678
|
+
if (profile !== null && profile !== "" && !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(profile)) {
|
|
2679
|
+
json(res, 400, { error: "Invalid model account" });
|
|
2680
|
+
return true;
|
|
2681
|
+
}
|
|
2484
2682
|
if (handleNativeModelCatalog(req, res, url, ctx))
|
|
2485
2683
|
return true;
|
|
2486
|
-
const models = ctx.modelCatalogFor?.(backend, instance) ?? [];
|
|
2684
|
+
const models = (profile !== null ? ctx.modelCatalogFor?.(backend, instance, { profile }) : ctx.modelCatalogFor?.(backend, instance)) ?? [];
|
|
2487
2685
|
const answerCatalog = () => {
|
|
2488
|
-
if (backend === "claude-code" && !models.length) {
|
|
2686
|
+
if (backend === "claude-code" && !models.length && !profile) {
|
|
2489
2687
|
const version = ctx.backendAvailabilityRows?.().find(row => row.backend === backend)?.version;
|
|
2490
2688
|
json(res, 200, { backend, models: claudeDocumentedModels(version), source: "official-catalog" });
|
|
2491
2689
|
}
|
|
@@ -2493,7 +2691,7 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
2493
2691
|
json(res, 200, { backend, models });
|
|
2494
2692
|
};
|
|
2495
2693
|
// The existing catalog belongs to this instance/account and always wins.
|
|
2496
|
-
if (models.length || !ctx.cliModelCatalogFor) {
|
|
2694
|
+
if (models.length || !ctx.cliModelCatalogFor || profile !== null) {
|
|
2497
2695
|
answerCatalog();
|
|
2498
2696
|
return true;
|
|
2499
2697
|
}
|
|
@@ -2855,6 +3053,38 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
2855
3053
|
// ── #1218: the Log tab ─────────────────────────────────
|
|
2856
3054
|
// An instance's steps, read on demand from its own transcript (log-service.ts). Read-only, and offered on the public
|
|
2857
3055
|
// link on purpose (the user's decision): the same masking applies to every viewer. Passive (web-auth.ts).
|
|
3056
|
+
// Deliberately absent from public gateway, guest, View and Hub projections.
|
|
3057
|
+
if (method === "GET" && path === "/ui/subagents") {
|
|
3058
|
+
const admission = adminAdmissionOf(req, url, ctx), name = url.searchParams.get("instance") ?? "";
|
|
3059
|
+
if (!admission || gatewayRequestContext(req) || guestRequestOf(req)) {
|
|
3060
|
+
json(res, 403, { error: "admin_only" });
|
|
3061
|
+
return true;
|
|
3062
|
+
}
|
|
3063
|
+
if (!name || name.length > 128 || !safeInstanceSegment(name)) {
|
|
3064
|
+
json(res, 400, { error: "invalid instance" });
|
|
3065
|
+
return true;
|
|
3066
|
+
}
|
|
3067
|
+
if (!ctx.subagentRuns) {
|
|
3068
|
+
json(res, 404, { error: "not available" });
|
|
3069
|
+
return true;
|
|
3070
|
+
}
|
|
3071
|
+
void ctx.subagentRuns(name).then(answer => {
|
|
3072
|
+
if (res.destroyed)
|
|
3073
|
+
return;
|
|
3074
|
+
if (adminAdmissionOf(req, url, ctx) !== admission || gatewayRequestContext(req) || guestRequestOf(req)) {
|
|
3075
|
+
json(res, 403, { error: "admin_only" });
|
|
3076
|
+
return;
|
|
3077
|
+
}
|
|
3078
|
+
if (answer.status === "busy") {
|
|
3079
|
+
res.setHeader("Retry-After", "2");
|
|
3080
|
+
json(res, 429, { error: "busy" });
|
|
3081
|
+
return;
|
|
3082
|
+
}
|
|
3083
|
+
json(res, 200, answer);
|
|
3084
|
+
}).catch(() => { if (!res.destroyed)
|
|
3085
|
+
json(res, 503, { error: "unavailable" }); });
|
|
3086
|
+
return true;
|
|
3087
|
+
}
|
|
2858
3088
|
if (method === "GET" && path === "/ui/steps") {
|
|
2859
3089
|
const p = url.searchParams;
|
|
2860
3090
|
const instance = p.get("instance") ?? "";
|
|
@@ -3604,6 +3834,8 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
3604
3834
|
return handleBrowserBackendSignIns(req, res, url, ctx);
|
|
3605
3835
|
if (path === "/ui/backend-login" || path.startsWith("/ui/backend-login/"))
|
|
3606
3836
|
return handleBackendLogin(req, res, url, ctx, path, method);
|
|
3837
|
+
if (path === "/ui/host-install" || path === "/ui/host-install/cancel" || path === "/ui/host-update")
|
|
3838
|
+
return handleHostInstall(req, res, url, ctx, path, method);
|
|
3607
3839
|
// #3292: before the accounts prefix — its Add pattern (`POST /ui/accounts/<backend>`) would read "keep-alive" as a backend.
|
|
3608
3840
|
if (path === "/ui/accounts/keep-alive")
|
|
3609
3841
|
return handleAccountKeepAlive(req, res, url, ctx, method);
|
|
@@ -3653,16 +3885,19 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
3653
3885
|
return true;
|
|
3654
3886
|
}
|
|
3655
3887
|
// ── #3008: connections from outside (a web-only fleet) ──
|
|
3656
|
-
// GET /ui/outside: the state (any admin; over the outside link too, read-only).
|
|
3657
|
-
//
|
|
3658
|
-
//
|
|
3659
|
-
// POST /ui/outside/
|
|
3888
|
+
// GET /ui/outside: the state (any admin; over the outside link too, read-only). What changes it is an admin's, over a
|
|
3889
|
+
// direct connection (the fleet asks the live session each time; the public link refuses these routes outright):
|
|
3890
|
+
// POST /ui/outside/enroll (a new secret, shown once; AGEND-122: {code} — the current one — while the owner's stricter
|
|
3891
|
+
// option is on and this is not the AgEnD computer), POST /ui/outside/enroll/confirm {code}, POST /ui/outside/remove
|
|
3892
|
+
// ({code} likewise), POST /ui/outside/strict {on, code?} (your own "ask for my code" switch) and POST /ui/outside/switch {on} — the
|
|
3893
|
+
// switch stays this computer's admin's, on a web-only fleet. Each acts on the caller's own authenticator only (per admin).
|
|
3894
|
+
// Never a guest (not in GUEST_ROUTES).
|
|
3660
3895
|
if (method === "GET" && path === "/ui/outside") {
|
|
3661
3896
|
res.setHeader("Cache-Control", "no-store");
|
|
3662
|
-
json(res, 200, ctx.webOutsideStatus?.(req) ?? { webOnly: false, here: false, enrolled: false, enrolledAt: null, outside: false, pausedForMs: 0, link: null });
|
|
3897
|
+
json(res, 200, ctx.webOutsideStatus?.(req) ?? { webOnly: false, here: false, manage: false, codeNeeded: false, strict: false, enrolled: false, enrolledAt: null, outside: false, pausedForMs: 0, link: null });
|
|
3663
3898
|
return true;
|
|
3664
3899
|
}
|
|
3665
|
-
if (method === "POST" && (path === "/ui/outside/enroll" || path === "/ui/outside/enroll/confirm" || path === "/ui/outside/remove" || path === "/ui/outside/switch")) {
|
|
3900
|
+
if (method === "POST" && (path === "/ui/outside/enroll" || path === "/ui/outside/enroll/confirm" || path === "/ui/outside/remove" || path === "/ui/outside/switch" || path === "/ui/outside/strict")) {
|
|
3666
3901
|
if (gatewayRequestContext(req)) {
|
|
3667
3902
|
json(res, 403, { error: "outside_not_here" });
|
|
3668
3903
|
return true;
|
|
@@ -3679,12 +3914,27 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
3679
3914
|
if (!permitWebContinuation(req, res, ctx))
|
|
3680
3915
|
return;
|
|
3681
3916
|
res.setHeader("Cache-Control", "no-store");
|
|
3917
|
+
// AGEND-122: replacing or removing the authenticator asks for the current code while the owner's stricter option is on
|
|
3918
|
+
// and this is not the AgEnD computer's own browser (the fleet decides); the answer to a missing or wrong one is its own.
|
|
3919
|
+
const stepCode = body && typeof body === "object" && typeof body.code === "string" && body.code.length <= 32 ? body.code : undefined;
|
|
3920
|
+
const refusal = (r) => {
|
|
3921
|
+
if (r.error === "paused") {
|
|
3922
|
+
res.setHeader("Retry-After", String(Math.ceil((r.retryAfterMs ?? 60_000) / 1000)));
|
|
3923
|
+
json(res, 429, { error: "paused", retryAfterMs: r.retryAfterMs ?? null });
|
|
3924
|
+
return;
|
|
3925
|
+
}
|
|
3926
|
+
json(res, r.error === "wrong" ? 401 : r.error === "unavailable" ? 503 : r.error === "code_required" ? 400 : 403, { error: r.error === "not_here" ? "outside_not_here" : r.error });
|
|
3927
|
+
};
|
|
3682
3928
|
if (path === "/ui/outside/enroll") {
|
|
3683
|
-
const r = ctx.webOutsideBeginEnrollment?.(req) ?? null;
|
|
3929
|
+
const r = ctx.webOutsideBeginEnrollment?.(req, stepCode) ?? null;
|
|
3684
3930
|
if (!r) {
|
|
3685
3931
|
json(res, 403, { error: "outside_not_here" });
|
|
3686
3932
|
return;
|
|
3687
3933
|
}
|
|
3934
|
+
if ("error" in r) {
|
|
3935
|
+
refusal(r);
|
|
3936
|
+
return;
|
|
3937
|
+
}
|
|
3688
3938
|
json(res, 200, r);
|
|
3689
3939
|
return;
|
|
3690
3940
|
}
|
|
@@ -3695,11 +3945,15 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
3695
3945
|
return;
|
|
3696
3946
|
}
|
|
3697
3947
|
const r = ctx.webOutsideConfirmEnrollment?.(req, code) ?? "not_here";
|
|
3698
|
-
json(res, r === "ok" ? 200 : r === "not_here" ? 403 : r === "unsaved" ? 503 : 400, r === "ok" ? { ok: true } : { error: r === "not_here" ? "outside_not_here" : r });
|
|
3948
|
+
json(res, r === "ok" ? 200 : r === "not_here" ? 403 : r === "unsaved" ? 503 : r === "full" ? 409 : 400, r === "ok" ? { ok: true } : { error: r === "not_here" ? "outside_not_here" : r });
|
|
3699
3949
|
return;
|
|
3700
3950
|
}
|
|
3701
3951
|
if (path === "/ui/outside/remove") {
|
|
3702
|
-
const r = ctx.webOutsideRemove?.(req) ?? "not_here";
|
|
3952
|
+
const r = ctx.webOutsideRemove?.(req, stepCode) ?? "not_here";
|
|
3953
|
+
if (typeof r === "object") {
|
|
3954
|
+
refusal(r);
|
|
3955
|
+
return;
|
|
3956
|
+
}
|
|
3703
3957
|
json(res, r === "ok" ? 200 : r === "unsaved" ? 503 : 403, r === "ok" ? { ok: true } : { error: r === "unsaved" ? "unsaved" : "outside_not_here" });
|
|
3704
3958
|
return;
|
|
3705
3959
|
}
|
|
@@ -3708,6 +3962,16 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
3708
3962
|
json(res, 400, { error: "on must be true or false" });
|
|
3709
3963
|
return;
|
|
3710
3964
|
}
|
|
3965
|
+
if (path === "/ui/outside/strict") {
|
|
3966
|
+
// AGEND-122 (per admin): the caller's OWN "ask for my code" switch — on needs their app and asks nothing, off asks their current code.
|
|
3967
|
+
const sr = ctx.webOutsideStrict?.(req, on, stepCode) ?? "not_here";
|
|
3968
|
+
if (typeof sr === "object") {
|
|
3969
|
+
refusal(sr);
|
|
3970
|
+
return;
|
|
3971
|
+
}
|
|
3972
|
+
json(res, sr === "ok" ? 200 : sr === "not_here" ? 403 : sr === "unsaved" ? 503 : 409, sr === "ok" ? { ok: true } : { error: sr === "not_here" ? "outside_not_here" : sr });
|
|
3973
|
+
return;
|
|
3974
|
+
}
|
|
3711
3975
|
const r = ctx.webOutsideSwitch?.(req, on) ?? "not_here";
|
|
3712
3976
|
json(res, r === "ok" ? 200 : r === "not_here" ? 403 : r === "unsaved" ? 503 : 409, r === "ok" ? { ok: true } : { error: r === "not_here" ? "outside_not_here" : r });
|
|
3713
3977
|
})().catch(err => {
|
|
@@ -3769,6 +4033,52 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
3769
4033
|
});
|
|
3770
4034
|
return true;
|
|
3771
4035
|
}
|
|
4036
|
+
// S-120 (D2a): POST /ui/public-link/close — 「立即關閉公開連結」 in Settings → 存取與安全 → 總覽. An admin session on this
|
|
4037
|
+
// fleet's own listener only: never over the public link itself (the gateway does not route it; refused here too), never
|
|
4038
|
+
// a guest, a read-only session or the CLI's header token. It only closes — nothing here opens a link — the way the chat
|
|
4039
|
+
// menu's 確定關閉 does (its remembered owner forgotten, so auto_open never reopens a deliberate close). A web-only fleet's
|
|
4040
|
+
// outside link is the owner's switch on this computer (#3008): 409 outside_link, left open.
|
|
4041
|
+
if (method === "POST" && path === "/ui/public-link/close") {
|
|
4042
|
+
if (gatewayRequestContext(req)) {
|
|
4043
|
+
json(res, 403, { error: "public_link_close_not_here" });
|
|
4044
|
+
return true;
|
|
4045
|
+
}
|
|
4046
|
+
const act = ctx.closePublicLinkFromWeb?.bind(ctx);
|
|
4047
|
+
if (!act) {
|
|
4048
|
+
json(res, 404, { error: "not_found" });
|
|
4049
|
+
return true;
|
|
4050
|
+
}
|
|
4051
|
+
(async () => {
|
|
4052
|
+
try {
|
|
4053
|
+
await parseBody(req);
|
|
4054
|
+
}
|
|
4055
|
+
catch {
|
|
4056
|
+
json(res, 400, { error: "Invalid JSON" });
|
|
4057
|
+
return;
|
|
4058
|
+
}
|
|
4059
|
+
if (!permitWebContinuation(req, res, ctx))
|
|
4060
|
+
return;
|
|
4061
|
+
const verdict = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
|
|
4062
|
+
if (verdict.kind !== "allow") {
|
|
4063
|
+
json(res, 401, { error: WEB_TOKEN_INVALID_MESSAGE });
|
|
4064
|
+
return;
|
|
4065
|
+
}
|
|
4066
|
+
if (verdict.via !== "session" || verdict.session?.tier !== "admin") {
|
|
4067
|
+
json(res, 403, { error: "public_link_close_needs_an_admin_session" });
|
|
4068
|
+
return;
|
|
4069
|
+
}
|
|
4070
|
+
res.setHeader("Cache-Control", "no-store");
|
|
4071
|
+
const r = await act();
|
|
4072
|
+
json(res, r.status, r.body);
|
|
4073
|
+
})().catch(err => {
|
|
4074
|
+
ctx.logger.error({ err: err.message }, "Public link close failed");
|
|
4075
|
+
try {
|
|
4076
|
+
json(res, 500, { error: "public_link_close_failed" });
|
|
4077
|
+
}
|
|
4078
|
+
catch { /* already answered */ }
|
|
4079
|
+
});
|
|
4080
|
+
return true;
|
|
4081
|
+
}
|
|
3772
4082
|
if (method === "POST" && (path === "/ui/devices/lookup" || path === "/ui/devices/approve" || path === "/ui/devices/deny")) {
|
|
3773
4083
|
const act = ctx.webDeviceLoginAct?.bind(ctx);
|
|
3774
4084
|
if (!act) {
|
|
@@ -3992,6 +4302,10 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
3992
4302
|
json(res, 400, { error: "args too long" });
|
|
3993
4303
|
return;
|
|
3994
4304
|
}
|
|
4305
|
+
if (body.action !== undefined && !["refresh", "more", "refreshAll"].includes(body.action)) {
|
|
4306
|
+
json(res, 400, { error: "invalid model action" });
|
|
4307
|
+
return;
|
|
4308
|
+
}
|
|
3995
4309
|
if (body.confirm !== undefined && !(typeof body.confirm === "string" && /^[0-9a-f]{32}$/.test(body.confirm))) {
|
|
3996
4310
|
json(res, 400, { error: "invalid confirmation" });
|
|
3997
4311
|
return;
|
|
@@ -4023,9 +4337,33 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
4023
4337
|
guestCommandsRunning.add(account);
|
|
4024
4338
|
ctx.guestCommandRuns?.record(account);
|
|
4025
4339
|
}
|
|
4340
|
+
if (isNativePaneInstance(ctx.fleetConfig?.instances[instance]) && body.action) {
|
|
4341
|
+
if (command !== "model" || body.action !== "refresh" || body.args) {
|
|
4342
|
+
json(res, 400, { error: "invalid model action" });
|
|
4343
|
+
return;
|
|
4344
|
+
}
|
|
4345
|
+
const target = ctx.fleetConfig.instances[instance];
|
|
4346
|
+
try {
|
|
4347
|
+
const refreshed = await refreshNativeModelCatalog(req, url, ctx, { backend: target.backend, instance });
|
|
4348
|
+
if (!stillAuthorized(req, res, url, ctx))
|
|
4349
|
+
return;
|
|
4350
|
+
if (!refreshed || ctx.fleetConfig?.instances[instance] !== target || !nativeCliAuthorization(req, url, ctx)) {
|
|
4351
|
+
json(res, 409, { error: "model target changed" });
|
|
4352
|
+
return;
|
|
4353
|
+
}
|
|
4354
|
+
json(res, 200, { choices: { current: target.model ?? null, options: refreshed.models.map(m => ({ id: m.id, label: m.label })), actions: ["refresh"] } });
|
|
4355
|
+
}
|
|
4356
|
+
catch {
|
|
4357
|
+
if (stillAuthorized(req, res, url, ctx))
|
|
4358
|
+
json(res, 503, { error: t("model.refresh_failed") });
|
|
4359
|
+
}
|
|
4360
|
+
return;
|
|
4361
|
+
}
|
|
4026
4362
|
try {
|
|
4027
4363
|
const { authority } = confirmAfterBody(arrival, webAuthorityOf(req, url, ctx, instance));
|
|
4028
|
-
const r = await run({ instance, command, args: str(body.args, MAX_COMMAND_ARGS), confirm: body.confirm }, { publicLink: !!gatewayRequestContext(req), person, authority, ...(guest ? { guest: true } : {}) });
|
|
4364
|
+
const r = await run({ instance, command, args: str(body.args, MAX_COMMAND_ARGS), confirm: body.confirm, ...(body.action ? { action: body.action } : {}) }, { publicLink: !!gatewayRequestContext(req), person, authority, ...(guest ? { guest: true } : {}) });
|
|
4365
|
+
if (!stillAuthorized(req, res, url, ctx))
|
|
4366
|
+
return;
|
|
4029
4367
|
json(res, r.status, r.body);
|
|
4030
4368
|
}
|
|
4031
4369
|
finally {
|
|
@@ -4265,6 +4603,17 @@ export function handleWebRequest(req, res, url, ctx) {
|
|
|
4265
4603
|
json(res, 400, { error: v.error });
|
|
4266
4604
|
return;
|
|
4267
4605
|
}
|
|
4606
|
+
// The account the form picked for this host's CLI: checked here, before anything is created, and written as the
|
|
4607
|
+
// agent's own backend_options.<cli>.credential_profile so its first start already runs under it.
|
|
4608
|
+
const account = resolveCreateAccount(ctx.dataDir, v.data, ctx.fleetConfig?.defaults?.backend);
|
|
4609
|
+
if (!account.ok) {
|
|
4610
|
+
const { ok: _ok, status, ...rest } = account;
|
|
4611
|
+
json(res, status, rest);
|
|
4612
|
+
return;
|
|
4613
|
+
}
|
|
4614
|
+
delete v.data.credentialProfile;
|
|
4615
|
+
if (account.backendOptions)
|
|
4616
|
+
v.data.backend_options = account.backendOptions;
|
|
4268
4617
|
let result = null;
|
|
4269
4618
|
let error;
|
|
4270
4619
|
const respond = (r, e) => { result = r; error = e; };
|
|
@@ -5030,7 +5379,7 @@ function webDeliveryFailure(err) {
|
|
|
5030
5379
|
if (/No warm slot is free/.test(message))
|
|
5031
5380
|
return { reason: "wake_capacity", error: "No slot is free to wake this instance. Retry when another instance is idle." };
|
|
5032
5381
|
if (/login|log in|sign in|\bauth(?:entication|orization)?\b|credential|api.?key/i.test(message))
|
|
5033
|
-
return { reason: "wake_credentials", error: "The instance could not sign in.
|
|
5382
|
+
return { reason: "wake_credentials", error: "The instance could not sign in. Connect its AI account in Settings → Agents → AI accounts and API keys → Accounts, or send /login in chat, then retry." };
|
|
5034
5383
|
if (/timed? out|timeout/i.test(message))
|
|
5035
5384
|
return { reason: "wake_timeout", error: "The instance did not become ready in time. Retry, or check its status in Fleet." };
|
|
5036
5385
|
if (/Cannot wake stopped|no longer configured/.test(message))
|
|
@@ -5702,7 +6051,10 @@ function shellBodyTag(req, ctx, mode, viewer) {
|
|
|
5702
6051
|
ownerCssState = "unknown";
|
|
5703
6052
|
}
|
|
5704
6053
|
const attr = (v) => String(v ?? "").replace(/[&<>"']/g, c => `&#${c.charCodeAt(0)};`);
|
|
5705
|
-
|
|
6054
|
+
const admission = evaluateWebRequest(req, new URL(req.url ?? "/", "http://localhost"), ctx.webToken ?? null, ctx.webSessions, { touch: false });
|
|
6055
|
+
const childMark = mode === "full" && !gatewayRequestContext(req) && !viewer?.guest && admission.kind === "allow"
|
|
6056
|
+
&& (admission.via !== "session" || admission.session.tier === "admin");
|
|
6057
|
+
return `<body data-mode="${mode}"${childMark ? ' data-subagents="1"' : ""}${mode === "full" && gatewayRequestContext(req) ? ' data-web-transport="poll"' : ""} data-dashboard-origin="${attr(p?.dashboardOrigin)}" data-preview-origin="${attr(p?.previewOrigin)}"`
|
|
5706
6058
|
+ ` data-preview-boot="${attr(p?.previewOrigin ? p.boot : "")}" data-preview-reason="${attr(p ? p.reason : "Previews are not available on this fleet.")}"`
|
|
5707
6059
|
// #1554: no availability asked (the public link, or not the full app) still says why, in the page's language.
|
|
5708
6060
|
+ ` data-preview-reason-code="${attr(p ? p.code ?? "" : gatewayRequestContext(req) ? "publicLink" : "notOffered")}"`
|