@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
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
/** The ui directory beside this module (src/ui in tests, dist/ui when installed) — the one the file routes read. */
|
|
3
|
+
export declare const UI_DIR: string;
|
|
4
|
+
/** A versioned path: the area (`assets` or `ui/js`), the version, the rest (the plain path's name). */
|
|
5
|
+
export declare const VERSIONED_ASSET_PATH: RegExp;
|
|
6
|
+
export declare const IMMUTABLE_PUBLIC = "public, max-age=31536000, immutable";
|
|
7
|
+
export declare const IMMUTABLE_PRIVATE = "private, max-age=31536000, immutable";
|
|
8
|
+
/** What an older tab's module request gets: the stale-tab prompt's SyntaxError, never a newer file. */
|
|
9
|
+
export declare const STALE_MODULE_BODY = "throw new SyntaxError(\"AgEnD was updated: this tab is older than the server. Reload it.\");\n";
|
|
10
|
+
/** <V>: the first 12 hex of a SHA-256 over every file of `uiDir` (its path and its bytes' hash), in a fixed order. */
|
|
11
|
+
export declare function computeAssetVersion(uiDir?: string): string;
|
|
12
|
+
/** This process's <V>. */
|
|
13
|
+
export declare function assetVersion(uiDir?: string): string;
|
|
14
|
+
/** Take the snapshot now (the listener's start), not at the first page, which may come after an update rewrote the files. */
|
|
15
|
+
export declare function warmAssetVersion(): void;
|
|
16
|
+
/** Whether `bytes`, served as the ui file `rel`, are exactly what <V> describes (a file changed or added since: no). */
|
|
17
|
+
export declare function assetIntact(rel: string, bytes: Buffer | string): boolean;
|
|
18
|
+
/** Whether the ui directory is still the one <V> describes (re-read at most once a second): a shell is versioned only then. */
|
|
19
|
+
export declare function assetsUnchanged(now?: number): boolean;
|
|
20
|
+
/** Tests: whether the snapshot was taken already (without taking it). */
|
|
21
|
+
export declare function assetVersionTaken(): boolean;
|
|
22
|
+
/** Tests: the snapshot's file hashes, to change as if the files on disk had been rewritten since (forces a re-check). */
|
|
23
|
+
export declare function assetSnapshotForTests(): Map<string, string>;
|
|
24
|
+
/** Tests and smokes: forget the snapshot, or pin <V> over the files as they are (what an update looks like to an open tab). */
|
|
25
|
+
export declare function resetAssetVersion(pin?: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Before anything routes the request (the public link's route list, the session gate, the handlers): a versioned path
|
|
28
|
+
* is rewritten to its plain path, and the request remembers it was versioned and whether that is this process's <V>.
|
|
29
|
+
* Anything else is left as it is. Once per request (the public link's gateway and the listener both call it).
|
|
30
|
+
*/
|
|
31
|
+
export declare function takeAssetVersion(req: IncomingMessage, current?: () => string): void;
|
|
32
|
+
/** The version mark takeAssetVersion left (undefined: a plain path). */
|
|
33
|
+
export declare function assetVersionMark(req: IncomingMessage): {
|
|
34
|
+
current: boolean;
|
|
35
|
+
version: string;
|
|
36
|
+
} | undefined;
|
|
37
|
+
/** A request for an older (or another) <V>: a module that throws the stale-tab SyntaxError; anything else 404. */
|
|
38
|
+
export declare function answerStaleAsset(res: ServerResponse, path: string): void;
|
|
39
|
+
/** A stylesheet served under <V>: its own `url("/assets/…")` (fonts, @import) under the same <V>. */
|
|
40
|
+
export declare function versionCss(css: string, version: string): string;
|
|
41
|
+
export type ModuleGraph = ReadonlyMap<string, readonly string[]>;
|
|
42
|
+
/** The static imports of a module's source (side-effect imports and re-exports included; dynamic `import()` not). */
|
|
43
|
+
export declare function staticImportsOf(source: string): string[];
|
|
44
|
+
/**
|
|
45
|
+
* The served modules (every `/assets/<name>.js`, every `/ui/js/<name>.js`) and the served modules each one imports
|
|
46
|
+
* statically, by plain URL. An import that names nothing served (a vendor path, a typo in a comment) is left out, so a
|
|
47
|
+
* preload never asks for a file that is not there.
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildModuleGraph(uiDir: string, assets: ReadonlyArray<readonly [string, string]>): ModuleGraph;
|
|
50
|
+
/** Every module the entries import statically, directly or not, the entries first (breadth first). */
|
|
51
|
+
export declare function staticClosure(graph: ModuleGraph, entries: readonly string[]): string[];
|
|
52
|
+
/**
|
|
53
|
+
* How many waves of requests loading `entries` takes when `preloaded` are asked for at once up front: a module that is
|
|
54
|
+
* not preloaded is asked for only once the module importing it has arrived. 1 = everything in the first wave.
|
|
55
|
+
*/
|
|
56
|
+
export declare function loadWaves(graph: ModuleGraph, entries: readonly string[], preloaded: ReadonlySet<string>): number;
|
|
57
|
+
/** A plain module URL under <V>. */
|
|
58
|
+
export declare const versioned: (url: string, version: string) => string;
|
|
59
|
+
/**
|
|
60
|
+
* The app shell under <V>: its own `/assets/` scripts and stylesheets versioned, then — before any of them — the import
|
|
61
|
+
* map and one modulepreload per module of `preload`, and (when given) the module graph module-warm.js reads for the
|
|
62
|
+
* panels opened later. `<script type="importmap">` is the one inline script spelling sendPanelHtml gives the nonce to
|
|
63
|
+
* besides a bare `<script>`; the graph is data (`application/json`), which no policy runs.
|
|
64
|
+
*/
|
|
65
|
+
export declare function versionShell(html: string, version: string, preload: readonly string[], graph?: ModuleGraph): string;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M-3314 (measured in M-3312): the web app's files under a version, cached for good, and its module graph preloaded.
|
|
3
|
+
*
|
|
4
|
+
* Over a slow link every file was a round trip (`no-store`), and the app's ES modules arrived in about fourteen waves —
|
|
5
|
+
* each one learnt only from the one before. Now:
|
|
6
|
+
*
|
|
7
|
+
* - **A version in the path.** `/assets/v-<V>/<name>` and `/ui/js/v-<V>/<name>` serve exactly what the plain paths serve,
|
|
8
|
+
* through the same gates (the request is rewritten to the plain path before anything routes it), but with
|
|
9
|
+
* `max-age=31536000, immutable` — `public` for /assets (served to anyone), `private` for /ui/js (a session's). <V> is
|
|
10
|
+
* a hash of every file of the ui directory, so an update or a rollback is a new <V>: nothing cached is reused across.
|
|
11
|
+
* The plain paths stay as they were (`no-store`) for every page that names them.
|
|
12
|
+
* - **Never mixed versions.** A tab opened on an older <V> that loads a module later asks for that older <V>: it gets a
|
|
13
|
+
* module that throws a SyntaxError (a stylesheet: 404), which is what the stale-tab prompt (#3822) already recognises
|
|
14
|
+
* — "this tab is older than AgEnD" with Reload — instead of a new file linked into old ones.
|
|
15
|
+
* - **One import map** in the app shell maps `/assets/` and `/ui/js/` to the versioned paths, so the 800-odd absolute
|
|
16
|
+
* and relative imports in the modules need no change; it maps the versioned prefixes to themselves, so a module's
|
|
17
|
+
* relative import (already versioned by its own URL) is not versioned twice.
|
|
18
|
+
* - **modulepreload.** The server reads the modules' static imports once (buildModuleGraph); the shell names the whole
|
|
19
|
+
* static closure of what this load opens, so the browser asks for all of it at once (one wave, not fourteen). The
|
|
20
|
+
* panels loaded later (Settings, Fleet…) are warmed the same way from the graph the shell carries (module-warm.js).
|
|
21
|
+
*/
|
|
22
|
+
import { createHash } from "node:crypto";
|
|
23
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
24
|
+
import { dirname, join } from "node:path";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
26
|
+
/** The ui directory beside this module (src/ui in tests, dist/ui when installed) — the one the file routes read. */
|
|
27
|
+
export const UI_DIR = join(dirname(fileURLToPath(import.meta.url)), "ui");
|
|
28
|
+
/** A versioned path: the area (`assets` or `ui/js`), the version, the rest (the plain path's name). */
|
|
29
|
+
export const VERSIONED_ASSET_PATH = /^\/(assets|ui\/js)\/v-([0-9a-f]{12})\/([^/?#]+)$/;
|
|
30
|
+
export const IMMUTABLE_PUBLIC = "public, max-age=31536000, immutable";
|
|
31
|
+
export const IMMUTABLE_PRIVATE = "private, max-age=31536000, immutable";
|
|
32
|
+
/** What an older tab's module request gets: the stale-tab prompt's SyntaxError, never a newer file. */
|
|
33
|
+
export const STALE_MODULE_BODY = "throw new SyntaxError(\"AgEnD was updated: this tab is older than the server. Reload it.\");\n";
|
|
34
|
+
function filesUnder(dir, rel = "") {
|
|
35
|
+
const out = [];
|
|
36
|
+
for (const e of readdirSync(join(dir, rel), { withFileTypes: true })) {
|
|
37
|
+
const p = rel ? `${rel}/${e.name}` : e.name;
|
|
38
|
+
if (e.isDirectory())
|
|
39
|
+
out.push(...filesUnder(dir, p));
|
|
40
|
+
else if (e.isFile())
|
|
41
|
+
out.push(p);
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
/** Every file of `uiDir` (its path under it) and the SHA-256 of its bytes, in a fixed order. */
|
|
46
|
+
function snapshotOf(uiDir) {
|
|
47
|
+
const files = new Map();
|
|
48
|
+
for (const f of filesUnder(uiDir).sort())
|
|
49
|
+
files.set(f, createHash("sha256").update(readFileSync(join(uiDir, f))).digest("hex"));
|
|
50
|
+
return files;
|
|
51
|
+
}
|
|
52
|
+
const versionOf = (files) => {
|
|
53
|
+
const h = createHash("sha256");
|
|
54
|
+
for (const [f, sum] of files) {
|
|
55
|
+
h.update(f);
|
|
56
|
+
h.update("\0");
|
|
57
|
+
h.update(sum);
|
|
58
|
+
h.update("\0");
|
|
59
|
+
}
|
|
60
|
+
return h.digest("hex").slice(0, 12);
|
|
61
|
+
};
|
|
62
|
+
/** <V>: the first 12 hex of a SHA-256 over every file of `uiDir` (its path and its bytes' hash), in a fixed order. */
|
|
63
|
+
export function computeAssetVersion(uiDir = UI_DIR) { return versionOf(snapshotOf(uiDir)); }
|
|
64
|
+
/**
|
|
65
|
+
* This process's <V> and the files it describes, taken once — eagerly when the listener starts (warmAssetVersion), so
|
|
66
|
+
* it describes the files this process started with. An update or a rollback rewrites the files under a still-running
|
|
67
|
+
* process (npm replaces the package, then the fleet restarts — minutes later, #4148): what is served under <V> must be
|
|
68
|
+
* exactly what <V> named, so a versioned file is checked against this snapshot on every request (assetIntact), and the
|
|
69
|
+
* shell is versioned only while the whole directory still matches (assetsUnchanged).
|
|
70
|
+
*/
|
|
71
|
+
let memo = null;
|
|
72
|
+
function snapshot(uiDir = UI_DIR) {
|
|
73
|
+
if (!memo || memo.dir !== uiDir) {
|
|
74
|
+
const files = snapshotOf(uiDir);
|
|
75
|
+
memo = { dir: uiDir, v: versionOf(files), files };
|
|
76
|
+
}
|
|
77
|
+
return memo;
|
|
78
|
+
}
|
|
79
|
+
/** This process's <V>. */
|
|
80
|
+
export function assetVersion(uiDir = UI_DIR) { return snapshot(uiDir).v; }
|
|
81
|
+
/** Take the snapshot now (the listener's start), not at the first page, which may come after an update rewrote the files. */
|
|
82
|
+
export function warmAssetVersion() { try {
|
|
83
|
+
snapshot();
|
|
84
|
+
}
|
|
85
|
+
catch { /* no ui directory: nothing is versioned */ } }
|
|
86
|
+
/** Whether `bytes`, served as the ui file `rel`, are exactly what <V> describes (a file changed or added since: no). */
|
|
87
|
+
export function assetIntact(rel, bytes) {
|
|
88
|
+
const want = snapshot().files.get(rel.split("\\").join("/"));
|
|
89
|
+
return want !== undefined && want === createHash("sha256").update(bytes).digest("hex");
|
|
90
|
+
}
|
|
91
|
+
let unchangedAt = { t: -Infinity, ok: true };
|
|
92
|
+
/** Whether the ui directory is still the one <V> describes (re-read at most once a second): a shell is versioned only then. */
|
|
93
|
+
export function assetsUnchanged(now = performance.now()) {
|
|
94
|
+
if (now - unchangedAt.t < 1000)
|
|
95
|
+
return unchangedAt.ok;
|
|
96
|
+
let ok;
|
|
97
|
+
try {
|
|
98
|
+
ok = versionOf(snapshotOf(UI_DIR)) === versionOf(snapshot().files);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
ok = false;
|
|
102
|
+
}
|
|
103
|
+
unchangedAt = { t: now, ok };
|
|
104
|
+
return ok;
|
|
105
|
+
}
|
|
106
|
+
/** Tests: whether the snapshot was taken already (without taking it). */
|
|
107
|
+
export function assetVersionTaken() { return memo !== null; }
|
|
108
|
+
/** Tests: the snapshot's file hashes, to change as if the files on disk had been rewritten since (forces a re-check). */
|
|
109
|
+
export function assetSnapshotForTests() { unchangedAt = { t: -Infinity, ok: true }; return snapshot().files; }
|
|
110
|
+
/** Tests and smokes: forget the snapshot, or pin <V> over the files as they are (what an update looks like to an open tab). */
|
|
111
|
+
export function resetAssetVersion(pin) {
|
|
112
|
+
memo = null;
|
|
113
|
+
unchangedAt = { t: -Infinity, ok: true };
|
|
114
|
+
if (pin)
|
|
115
|
+
memo = { dir: UI_DIR, v: pin, files: snapshotOf(UI_DIR) };
|
|
116
|
+
}
|
|
117
|
+
const marks = new WeakMap();
|
|
118
|
+
/**
|
|
119
|
+
* Before anything routes the request (the public link's route list, the session gate, the handlers): a versioned path
|
|
120
|
+
* is rewritten to its plain path, and the request remembers it was versioned and whether that is this process's <V>.
|
|
121
|
+
* Anything else is left as it is. Once per request (the public link's gateway and the listener both call it).
|
|
122
|
+
*/
|
|
123
|
+
export function takeAssetVersion(req, current = () => assetVersion()) {
|
|
124
|
+
if (marks.has(req))
|
|
125
|
+
return;
|
|
126
|
+
const raw = req.url ?? "/";
|
|
127
|
+
const q = raw.search(/[?#]/);
|
|
128
|
+
const path = q < 0 ? raw : raw.slice(0, q);
|
|
129
|
+
const m = VERSIONED_ASSET_PATH.exec(path);
|
|
130
|
+
if (!m)
|
|
131
|
+
return;
|
|
132
|
+
req.url = `/${m[1]}/${m[3]}${q < 0 ? "" : raw.slice(q)}`;
|
|
133
|
+
marks.set(req, { current: m[2] === current(), version: m[2] });
|
|
134
|
+
}
|
|
135
|
+
/** The version mark takeAssetVersion left (undefined: a plain path). */
|
|
136
|
+
export function assetVersionMark(req) { return marks.get(req); }
|
|
137
|
+
/** A request for an older (or another) <V>: a module that throws the stale-tab SyntaxError; anything else 404. */
|
|
138
|
+
export function answerStaleAsset(res, path) {
|
|
139
|
+
if (path.endsWith(".js")) {
|
|
140
|
+
res.writeHead(200, { "Content-Type": "text/javascript; charset=utf-8", "Cache-Control": "no-store" });
|
|
141
|
+
res.end(STALE_MODULE_BODY);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
res.writeHead(404, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
145
|
+
res.end(JSON.stringify({ error: "not found" }));
|
|
146
|
+
}
|
|
147
|
+
/** A stylesheet served under <V>: its own `url("/assets/…")` (fonts, @import) under the same <V>. */
|
|
148
|
+
export function versionCss(css, version) {
|
|
149
|
+
return css.split('url("/assets/').join(`url("/assets/v-${version}/`);
|
|
150
|
+
}
|
|
151
|
+
const STATIC_IMPORT = /(?:^|[;\n}])\s*(?:import|export)\s*(?:[\w$*{}\s,]+?\s*from\s*)?["']([^"'\n]+)["']/g;
|
|
152
|
+
/** The static imports of a module's source (side-effect imports and re-exports included; dynamic `import()` not). */
|
|
153
|
+
export function staticImportsOf(source) {
|
|
154
|
+
const out = [];
|
|
155
|
+
for (const m of source.matchAll(STATIC_IMPORT))
|
|
156
|
+
out.push(m[1]);
|
|
157
|
+
for (const m of source.matchAll(/(?:import|export)\{[^}]*\}from"([^"]+)"/g))
|
|
158
|
+
out.push(m[1]); // minified vendor files
|
|
159
|
+
for (const m of source.matchAll(/import\s*\w+\s*from"([^"]+)"/g))
|
|
160
|
+
out.push(m[1]);
|
|
161
|
+
return [...new Set(out)];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The served modules (every `/assets/<name>.js`, every `/ui/js/<name>.js`) and the served modules each one imports
|
|
165
|
+
* statically, by plain URL. An import that names nothing served (a vendor path, a typo in a comment) is left out, so a
|
|
166
|
+
* preload never asks for a file that is not there.
|
|
167
|
+
*/
|
|
168
|
+
export function buildModuleGraph(uiDir, assets) {
|
|
169
|
+
const files = new Map();
|
|
170
|
+
for (const [name, file] of assets)
|
|
171
|
+
if (name.endsWith(".js"))
|
|
172
|
+
files.set(`/assets/${name}`, join(uiDir, file));
|
|
173
|
+
for (const f of readdirSync(uiDir))
|
|
174
|
+
if (/^[a-z0-9_-]+\.js$/.test(f))
|
|
175
|
+
files.set(`/ui/js/${f}`, join(uiDir, f));
|
|
176
|
+
const graph = new Map();
|
|
177
|
+
for (const [url, file] of files) {
|
|
178
|
+
let source;
|
|
179
|
+
try {
|
|
180
|
+
source = readFileSync(file, "utf-8");
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const deps = [];
|
|
186
|
+
for (const spec of staticImportsOf(source)) {
|
|
187
|
+
if (!spec.startsWith("/") && !spec.startsWith("./") && !spec.startsWith("../"))
|
|
188
|
+
continue;
|
|
189
|
+
const to = new URL(spec, `http://h${url}`).pathname;
|
|
190
|
+
if (files.has(to) && to !== url && !deps.includes(to))
|
|
191
|
+
deps.push(to);
|
|
192
|
+
}
|
|
193
|
+
graph.set(url, deps);
|
|
194
|
+
}
|
|
195
|
+
return graph;
|
|
196
|
+
}
|
|
197
|
+
/** Every module the entries import statically, directly or not, the entries first (breadth first). */
|
|
198
|
+
export function staticClosure(graph, entries) {
|
|
199
|
+
const seen = new Set(), queue = entries.filter(e => graph.has(e));
|
|
200
|
+
for (const e of queue)
|
|
201
|
+
seen.add(e);
|
|
202
|
+
for (let i = 0; i < queue.length; i++)
|
|
203
|
+
for (const d of graph.get(queue[i]) ?? [])
|
|
204
|
+
if (!seen.has(d)) {
|
|
205
|
+
seen.add(d);
|
|
206
|
+
queue.push(d);
|
|
207
|
+
}
|
|
208
|
+
return queue;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* How many waves of requests loading `entries` takes when `preloaded` are asked for at once up front: a module that is
|
|
212
|
+
* not preloaded is asked for only once the module importing it has arrived. 1 = everything in the first wave.
|
|
213
|
+
*/
|
|
214
|
+
export function loadWaves(graph, entries, preloaded) {
|
|
215
|
+
const wave = new Map();
|
|
216
|
+
const queue = [];
|
|
217
|
+
for (const e of entries)
|
|
218
|
+
if (graph.has(e) && !wave.has(e)) {
|
|
219
|
+
wave.set(e, 1);
|
|
220
|
+
queue.push(e);
|
|
221
|
+
}
|
|
222
|
+
for (const p of preloaded)
|
|
223
|
+
if (graph.has(p) && !wave.has(p)) {
|
|
224
|
+
wave.set(p, 1);
|
|
225
|
+
queue.push(p);
|
|
226
|
+
}
|
|
227
|
+
// Breadth first by wave: a module's import arrives one wave after it unless it was asked for earlier.
|
|
228
|
+
for (let i = 0; i < queue.length; i++) {
|
|
229
|
+
const u = queue[i], w = wave.get(u);
|
|
230
|
+
for (const d of graph.get(u) ?? [])
|
|
231
|
+
if (!wave.has(d)) {
|
|
232
|
+
wave.set(d, w + 1);
|
|
233
|
+
queue.push(d);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
let max = 0;
|
|
237
|
+
for (const u of staticClosure(graph, entries))
|
|
238
|
+
max = Math.max(max, wave.get(u) ?? 0);
|
|
239
|
+
return max;
|
|
240
|
+
}
|
|
241
|
+
/** A plain module URL under <V>. */
|
|
242
|
+
export const versioned = (url, version) => url.replace(/^\/(assets|ui\/js)\//, `/$1/v-${version}/`);
|
|
243
|
+
/**
|
|
244
|
+
* The app shell under <V>: its own `/assets/` scripts and stylesheets versioned, then — before any of them — the import
|
|
245
|
+
* map and one modulepreload per module of `preload`, and (when given) the module graph module-warm.js reads for the
|
|
246
|
+
* panels opened later. `<script type="importmap">` is the one inline script spelling sendPanelHtml gives the nonce to
|
|
247
|
+
* besides a bare `<script>`; the graph is data (`application/json`), which no policy runs.
|
|
248
|
+
*/
|
|
249
|
+
export function versionShell(html, version, preload, graph) {
|
|
250
|
+
const pre = `/v-${version}/`;
|
|
251
|
+
const map = { imports: { "/assets/": `/assets${pre}`, "/ui/js/": `/ui/js${pre}`, [`/assets${pre}`]: `/assets${pre}`, [`/ui/js${pre}`]: `/ui/js${pre}` } };
|
|
252
|
+
const head = [`<script type="importmap">${JSON.stringify(map)}</script>`,
|
|
253
|
+
...preload.map(u => `<link rel="modulepreload" href="${versioned(u, version)}">`),
|
|
254
|
+
...(graph ? [`<script type="application/json" id="agend-modules">${JSON.stringify(Object.fromEntries(graph)).replace(/</g, "\\u003c")}</script>`] : [])].join("\n");
|
|
255
|
+
const body = html.replace(/(src|href)="\/assets\//g, `$1="/assets${pre}`);
|
|
256
|
+
const at = body.search(/<script|<link rel="stylesheet"/);
|
|
257
|
+
return at < 0 ? body : `${body.slice(0, at)}${head}\n${body.slice(at)}`;
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=web-asset-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-asset-version.js","sourceRoot":"","sources":["../src/web-asset-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM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CAAC,CAAC,CAAC,CAAC,sDAAsD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtK,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,cAAc,GAAG,EAAE,CAAC,CAAC;IAC1E,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,gCAAgC,CAAC,CAAC;IACzD,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;AAC1E,CAAC"}
|
package/dist/web-host-guard.js
CHANGED
|
@@ -159,6 +159,8 @@ export function sendPanelHtml(res, html, status = 200, headers = {}, csp = {}) {
|
|
|
159
159
|
// match, not a tag filter. Any other spelling (`<SCRIPT>`, `<script src=…>`, `<script type=module>`) is left as is
|
|
160
160
|
// and so has no nonce: inline it is blocked, `src=` scripts load by 'self'. Widening the match would hand the
|
|
161
161
|
// nonce to more spellings; nothing here sanitises input.
|
|
162
|
-
|
|
162
|
+
// M-3314: the app shell's import map (`<script type="importmap">`, written by versionShell) is ours too, so it gets it.
|
|
163
|
+
res.end(html.split("<script>").join(`<script nonce="${nonce}">`).split('<script type="importmap">').join(`<script type="importmap" nonce="${nonce}">`)
|
|
164
|
+
.split("<style>").join(`<style nonce="${nonce}">`));
|
|
163
165
|
}
|
|
164
166
|
//# sourceMappingURL=web-host-guard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-host-guard.js","sourceRoot":"","sources":["../src/web-host-guard.ts"],"names":[],"mappings":"AAgBA,OA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,GAAG,GAAG,EAAE,OAAO,GAA2B,EAAE,EAAE,GAAG,GAA6C,EAAE;IACrK,MAAM,KAAK,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjD,GAAG,CAAC,SAAS,CAAC,yBAAyB,EAAE,0BAA0B,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IACjF,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,0BAA0B,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClF,kHAAkH;IAClH,mHAAmH;IACnH,8GAA8G;IAC9G,yDAAyD;IACzD,wHAAwH;IACxH,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,kBAAkB,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,mCAAmC,KAAK,IAAI,CAAC;SACnJ,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,iBAAiB,KAAK,IAAI,CAAC,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -5,9 +5,18 @@ export declare const WEB_INSTALL_KEEP_ENDED_MS: number;
|
|
|
5
5
|
export declare const WEB_INSTALL_LINES = 12;
|
|
6
6
|
export type HostInstallPhase = "running" | "ok" | "failed" | "cancelled" | "timeout";
|
|
7
7
|
/** Why a start was refused. Codes: the page words them in its own language. */
|
|
8
|
-
export type HostInstallRefusal = "unsupported" | "already" | "busy" | "shutting_down" | "failed" | "not_allowed" | "not_installed" | "up_to_date" | "version_unreadable";
|
|
9
|
-
/**
|
|
10
|
-
|
|
8
|
+
export type HostInstallRefusal = "unsupported" | "already" | "busy" | "shutting_down" | "failed" | "not_allowed" | "not_installed" | "up_to_date" | "version_unreadable" | "cli_self_updating" | "not_npm" | "still_npm" | "no_npm_copy";
|
|
9
|
+
/**
|
|
10
|
+
* What a run does: install a CLI that is not there, or take an installed one to AgEnD's audited release. M-3307 (#4146), Claude Code only: `native` installs the audited
|
|
11
|
+
* release with Claude's own installer over an npm-global install (the switch); `remove-npm` then removes the npm copy, a separate step the person asks for.
|
|
12
|
+
*/
|
|
13
|
+
export type HostInstallMode = "install" | "update" | "native" | "remove-npm";
|
|
14
|
+
/** M-3307: what a `native` or `remove-npm` run found afterwards — where `claude` now resolves (a fresh login shell), its kind, and the npm copy if it is still there. */
|
|
15
|
+
export interface ClaudeInstallAfter {
|
|
16
|
+
kind: "native" | "npm-global" | "other" | null;
|
|
17
|
+
path: string | null;
|
|
18
|
+
npmLeftover: string | null;
|
|
19
|
+
}
|
|
11
20
|
export type HostInstallStart = {
|
|
12
21
|
started: true;
|
|
13
22
|
} | {
|
|
@@ -29,6 +38,7 @@ export interface HostInstallReporter {
|
|
|
29
38
|
verified: boolean;
|
|
30
39
|
version: string | null;
|
|
31
40
|
signIn: boolean;
|
|
41
|
+
claude?: ClaudeInstallAfter;
|
|
32
42
|
}): void;
|
|
33
43
|
/** An update: the version the binary probe read before it started, and the audited release it goes to (null: not read). Told once, when the window is open. */
|
|
34
44
|
update?(from: string | null, target: string | null): void;
|
|
@@ -81,6 +91,8 @@ export interface HostInstallView {
|
|
|
81
91
|
reached: boolean | null;
|
|
82
92
|
/** The window could not be confirmed removed (the same warning `/login` gives). */
|
|
83
93
|
cleanupFailed: boolean;
|
|
94
|
+
/** M-3307: a `native` or `remove-npm` run that ended `ok`: where `claude` resolves now, its kind, and the npm copy still left (null: not such a run, or not read). */
|
|
95
|
+
claude: ClaudeInstallAfter | null;
|
|
84
96
|
}
|
|
85
97
|
/**
|
|
86
98
|
* AGEND-136: what an update runs for `backend`: the registry's `host.update` command with its `{version}` filled with the newest audited release (cli-audited.ts), and that
|
|
@@ -98,6 +110,21 @@ export declare function hostUpdatePlan(backend: string): {
|
|
|
98
110
|
* `latest_ack_required`: the CLI's update is the exception and the page did not say it knew (refuse; the page must be refreshed). `latest_ack_mismatch`: the page claims the exception for a CLI whose update is pinned.
|
|
99
111
|
*/
|
|
100
112
|
export declare function hostUpdateAckError(backend: string, ack: unknown): "latest_ack_required" | "latest_ack_mismatch" | null;
|
|
113
|
+
/** M-3302: how recent a file in Claude Code's staging folder must be to count as its own update still running. */
|
|
114
|
+
export declare const CLAUDE_SELF_UPDATE_WINDOW_MS: number;
|
|
115
|
+
/**
|
|
116
|
+
* M-3302: is Claude Code downloading an update of its own right now? Its native installer writes the new release into
|
|
117
|
+
* `<XDG cache>/claude/staging` and moves it into `~/.local/share/claude/versions` when done, so the folder is empty between updates.
|
|
118
|
+
* A file there written in the last ten minutes is a self-update in progress (an older one is a leftover from an update that was
|
|
119
|
+
* stopped, and does not block). Running Claude's installer from the dashboard then would race it, so the dashboard says "try
|
|
120
|
+
* again in a few minutes" instead of starting. No folder, or one that cannot be read: false.
|
|
121
|
+
*/
|
|
122
|
+
export declare function claudeSelfUpdating(env?: NodeJS.ProcessEnv, now?: number): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* M-3307: the command that removes the npm copy of Claude Code at `packageDir` (`<prefix>/lib/node_modules/@anthropic-ai/claude-code`): npm's own uninstall, aimed at that
|
|
125
|
+
* copy's prefix so it is the copy the switch found and not another npm's. The directory comes from the server's own reading of the install, quoted; never from the page.
|
|
126
|
+
*/
|
|
127
|
+
export declare function npmUninstallCommand(packageDir: string): string;
|
|
101
128
|
/** "CLI exited with code 3 — …" (login-manager.ts) → 3. */
|
|
102
129
|
export declare function exitCodeOf(detail: string): number | null;
|
|
103
130
|
/** The installer's output as a few plain lines: tmux's own dead-pane line and blank runs gone, ANSI stripped, secrets masked. */
|
package/dist/web-host-install.js
CHANGED
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
* No command, path or environment. An ended run is kept 10 minutes, then it is gone.
|
|
20
20
|
*/
|
|
21
21
|
import { randomBytes } from "node:crypto";
|
|
22
|
+
import { readdirSync, statSync } from "node:fs";
|
|
23
|
+
import { homedir } from "node:os";
|
|
24
|
+
import { basename, dirname, join } from "node:path";
|
|
25
|
+
import { CLAUDE_NPM_PACKAGE } from "./claude-install-kind.js";
|
|
22
26
|
import { AUDITED_VERSION, auditedVersion, versionOf } from "./cli-audited.js";
|
|
23
27
|
import { hostFacts } from "./cli-registry.js";
|
|
24
28
|
import { dialogScreenText } from "./dialog-screen-text.js";
|
|
@@ -62,6 +66,44 @@ export function hostUpdateAckError(backend, ack) {
|
|
|
62
66
|
return "latest_ack_mismatch";
|
|
63
67
|
return null;
|
|
64
68
|
}
|
|
69
|
+
/** M-3302: how recent a file in Claude Code's staging folder must be to count as its own update still running. */
|
|
70
|
+
export const CLAUDE_SELF_UPDATE_WINDOW_MS = 10 * 60_000;
|
|
71
|
+
/**
|
|
72
|
+
* M-3302: is Claude Code downloading an update of its own right now? Its native installer writes the new release into
|
|
73
|
+
* `<XDG cache>/claude/staging` and moves it into `~/.local/share/claude/versions` when done, so the folder is empty between updates.
|
|
74
|
+
* A file there written in the last ten minutes is a self-update in progress (an older one is a leftover from an update that was
|
|
75
|
+
* stopped, and does not block). Running Claude's installer from the dashboard then would race it, so the dashboard says "try
|
|
76
|
+
* again in a few minutes" instead of starting. No folder, or one that cannot be read: false.
|
|
77
|
+
*/
|
|
78
|
+
export function claudeSelfUpdating(env = process.env, now = Date.now()) {
|
|
79
|
+
const cache = env.XDG_CACHE_HOME?.trim() || join(env.HOME?.trim() || homedir(), ".cache");
|
|
80
|
+
const staging = join(cache, "claude", "staging");
|
|
81
|
+
let names;
|
|
82
|
+
try {
|
|
83
|
+
names = readdirSync(staging);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return names.some(name => {
|
|
89
|
+
try {
|
|
90
|
+
const age = now - statSync(join(staging, name)).mtimeMs;
|
|
91
|
+
return age >= -60_000 && age < CLAUDE_SELF_UPDATE_WINDOW_MS;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* M-3307: the command that removes the npm copy of Claude Code at `packageDir` (`<prefix>/lib/node_modules/@anthropic-ai/claude-code`): npm's own uninstall, aimed at that
|
|
100
|
+
* copy's prefix so it is the copy the switch found and not another npm's. The directory comes from the server's own reading of the install, quoted; never from the page.
|
|
101
|
+
*/
|
|
102
|
+
export function npmUninstallCommand(packageDir) {
|
|
103
|
+
const scope = dirname(packageDir), modules = dirname(scope), lib = dirname(modules);
|
|
104
|
+
const prefix = basename(lib) === "lib" ? dirname(lib) : lib;
|
|
105
|
+
return `npm --prefix '${prefix.replace(/'/g, "'\\''")}' -g uninstall ${CLAUDE_NPM_PACKAGE}`;
|
|
106
|
+
}
|
|
65
107
|
/** "CLI exited with code 3 — …" (login-manager.ts) → 3. */
|
|
66
108
|
export function exitCodeOf(detail) {
|
|
67
109
|
const m = /exited with code (\d{1,3})\b/.exec(detail);
|
|
@@ -88,11 +130,12 @@ export class WebHostInstalls {
|
|
|
88
130
|
execution?.assert();
|
|
89
131
|
if (!this.deps.isLocalAdmin(who.handle))
|
|
90
132
|
return { error: "not_allowed" };
|
|
91
|
-
|
|
133
|
+
const allowed = mode === "update" ? this.deps.updatable?.(backend) === true : mode === "install" ? this.deps.installable(backend) : backend === "claude-code" && this.deps.updatable?.(backend) === true;
|
|
134
|
+
if (!allowed)
|
|
92
135
|
return { error: "unsupported" };
|
|
93
136
|
const run = {
|
|
94
137
|
id: randomBytes(16).toString("hex"), backend, mode, fromVersion: null, targetVersion: null, latest: mode === "update" && hostFacts(backend, "update")?.release === "latest-unaudited", label: who.label, startedAt: this.now(), phase: "running", endedAt: null,
|
|
95
|
-
lines: [], exitCode: null, verified: null, version: null, signIn: false, cleanupFailed: false, reached: null,
|
|
138
|
+
lines: [], exitCode: null, verified: null, version: null, signIn: false, cleanupFailed: false, reached: null, claude: null,
|
|
96
139
|
};
|
|
97
140
|
// Published only once the start is accepted (a refused start leaves what was shown before exactly as it was). A fast installer's `done` may land before that: it
|
|
98
141
|
// settles `run`, and the publication below then shows it already over.
|
|
@@ -112,8 +155,10 @@ export class WebHostInstalls {
|
|
|
112
155
|
run.version = result.version;
|
|
113
156
|
run.signIn = run.mode === "install" && result.verified && result.signIn;
|
|
114
157
|
// An update that exited 0 is not a success until the binary probe says it reached the audited release: true/false once the version after is read, null when it was not.
|
|
115
|
-
if (run.mode === "update")
|
|
158
|
+
if (run.mode === "update" || run.mode === "native")
|
|
116
159
|
run.reached = result.verified && run.targetVersion !== null && versionOf(result.version) !== null ? versionOf(result.version) === run.targetVersion : null;
|
|
160
|
+
if (run.mode === "native" || run.mode === "remove-npm")
|
|
161
|
+
run.claude = result.claude ?? null;
|
|
117
162
|
}
|
|
118
163
|
else {
|
|
119
164
|
run.phase = result.detail === "cancelled" ? "cancelled" : result.detail === "timeout" ? "timeout" : "failed";
|
|
@@ -126,7 +171,7 @@ export class WebHostInstalls {
|
|
|
126
171
|
let started;
|
|
127
172
|
// An install is asked of the fleet exactly as before (#3542: the CLI's id, a reporter, the confirmed change's execution); only an update says its mode.
|
|
128
173
|
try {
|
|
129
|
-
started = mode
|
|
174
|
+
started = mode !== "install" ? await this.deps.start(backend, reporter, execution, mode) : execution ? await this.deps.start(backend, reporter, execution) : await this.deps.start(backend, reporter);
|
|
130
175
|
}
|
|
131
176
|
catch (err) {
|
|
132
177
|
started = { refused: "failed", message: err?.message ?? String(err) };
|
|
@@ -155,6 +200,7 @@ export class WebHostInstalls {
|
|
|
155
200
|
return {
|
|
156
201
|
id: run.id, backend: run.backend, mode: run.mode, fromVersion: run.fromVersion, targetVersion: run.targetVersion, latest: run.latest, phase: run.phase, startedOn: run.label, startedAt: run.startedAt, endedAt: run.endedAt,
|
|
157
202
|
lines: [...run.lines], exitCode: run.exitCode, verified: run.verified, version: run.version, signIn: run.signIn, cleanupFailed: run.cleanupFailed, reached: run.reached,
|
|
203
|
+
claude: run.claude ? { ...run.claude } : null,
|
|
158
204
|
};
|
|
159
205
|
}
|
|
160
206
|
changed(phase) { try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-host-install.js","sourceRoot":"","sources":["../src/web-host-install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,iEAAiE;AACjE,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,MAAM,CAAC;AACrD,8FAA8F;AAC9F,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,MAAM,iBAAiB,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"web-host-install.js","sourceRoot":"","sources":["../src/web-host-install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,E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;YAC5N,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO;YACvK,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI;SAC9C,CAAC;IACJ,CAAC;IAEO,OAAO,CAAC,KAA0B,IAAU,IAAI,CAAC;QAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,8CAA8C,CAAC,CAAC,CAAC,CAAC;CACnJ"}
|
package/dist/web-terminal.d.ts
CHANGED
|
@@ -157,6 +157,11 @@ export declare class WebTerminalSession extends EventEmitter {
|
|
|
157
157
|
constructor(spec: WebTerminalSpec, events: WebTerminalEvents, backend: TerminalBackend, logger: TerminalLogger, now?: () => number);
|
|
158
158
|
/** The one-time access token, readable only until it is redeemed or the session ends. */
|
|
159
159
|
peekAccessToken(): string | null;
|
|
160
|
+
/**
|
|
161
|
+
* #4145: replace an unredeemed token that got out (pasted into a chat) — the old one stops working at once, the failed
|
|
162
|
+
* tries so far still count. False once it was redeemed or the session is not running.
|
|
163
|
+
*/
|
|
164
|
+
rotateAccessToken(): boolean;
|
|
160
165
|
get ttlRemainingMs(): number;
|
|
161
166
|
start(): Promise<void>;
|
|
162
167
|
/**
|
package/dist/web-terminal.js
CHANGED
|
@@ -151,6 +151,17 @@ export class WebTerminalSession extends EventEmitter {
|
|
|
151
151
|
}
|
|
152
152
|
/** The one-time access token, readable only until it is redeemed or the session ends. */
|
|
153
153
|
peekAccessToken() { return this.accessToken; }
|
|
154
|
+
/**
|
|
155
|
+
* #4145: replace an unredeemed token that got out (pasted into a chat) — the old one stops working at once, the failed
|
|
156
|
+
* tries so far still count. False once it was redeemed or the session is not running.
|
|
157
|
+
*/
|
|
158
|
+
rotateAccessToken() {
|
|
159
|
+
if (this.state !== "running" || this.accessToken === null)
|
|
160
|
+
return false;
|
|
161
|
+
this.accessToken = generateAccessToken();
|
|
162
|
+
this.audit("web_terminal_token_rotated", {});
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
154
165
|
get ttlRemainingMs() { return Math.max(0, this.expiresAt - this.now()); }
|
|
155
166
|
async start() {
|
|
156
167
|
if (this.state !== "created")
|