@wrongstack/webui-server 0.284.0 → 0.285.0
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/index.d.ts +11 -2300
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1019 -277
- package/dist/index.js.map +7 -1
- package/dist/server/autophase-routes.d.ts +10 -0
- package/dist/server/autophase-routes.d.ts.map +1 -0
- package/dist/server/autophase-ws-handler.d.ts +87 -0
- package/dist/server/autophase-ws-handler.d.ts.map +1 -0
- package/dist/server/backend-services.d.ts +114 -0
- package/dist/server/backend-services.d.ts.map +1 -0
- package/dist/server/boot.d.ts +19 -0
- package/dist/server/boot.d.ts.map +1 -0
- package/dist/server/brain-routes.d.ts +9 -0
- package/dist/server/brain-routes.d.ts.map +1 -0
- package/dist/server/codebase-indexing.d.ts +15 -0
- package/dist/server/codebase-indexing.d.ts.map +1 -0
- package/dist/server/collaboration-ws-handler.d.ts +159 -0
- package/dist/server/collaboration-ws-handler.d.ts.map +1 -0
- package/dist/server/completion-handlers.d.ts +39 -0
- package/dist/server/completion-handlers.d.ts.map +1 -0
- package/dist/server/connection-handler.d.ts +72 -0
- package/dist/server/connection-handler.d.ts.map +1 -0
- package/dist/server/context-meta.d.ts +28 -0
- package/dist/server/context-meta.d.ts.map +1 -0
- package/dist/server/custom-context-modes.d.ts +43 -0
- package/dist/server/custom-context-modes.d.ts.map +1 -0
- package/dist/server/design-handlers.d.ts +40 -0
- package/dist/server/design-handlers.d.ts.map +1 -0
- package/dist/server/discover-mailbox-bridge.d.ts +26 -0
- package/dist/server/discover-mailbox-bridge.d.ts.map +1 -0
- package/dist/server/entry.d.ts +2 -2
- package/dist/server/entry.d.ts.map +1 -0
- package/dist/server/entry.js +811 -300
- package/dist/server/entry.js.map +7 -1
- package/dist/server/eternal-iteration-broadcast.d.ts +11 -0
- package/dist/server/eternal-iteration-broadcast.d.ts.map +1 -0
- package/dist/server/file-handlers.d.ts +45 -0
- package/dist/server/file-handlers.d.ts.map +1 -0
- package/dist/server/file-picker.d.ts +26 -0
- package/dist/server/file-picker.d.ts.map +1 -0
- package/dist/server/git-handlers.d.ts +55 -0
- package/dist/server/git-handlers.d.ts.map +1 -0
- package/dist/server/goal-handlers.d.ts +19 -0
- package/dist/server/goal-handlers.d.ts.map +1 -0
- package/dist/server/handlers/index.d.ts +12 -0
- package/dist/server/handlers/index.d.ts.map +1 -0
- package/dist/server/handlers/worklist-handlers.d.ts +49 -0
- package/dist/server/handlers/worklist-handlers.d.ts.map +1 -0
- package/dist/server/handlers.d.ts +1 -51
- package/dist/server/handlers.js +17 -8
- package/dist/server/handlers.js.map +7 -1
- package/dist/server/http-server/analytics-handler.d.ts +35 -0
- package/dist/server/http-server/analytics-handler.d.ts.map +1 -0
- package/dist/server/http-server/api-handlers.d.ts +44 -0
- package/dist/server/http-server/api-handlers.d.ts.map +1 -0
- package/dist/server/http-server.d.ts +108 -0
- package/dist/server/http-server.d.ts.map +1 -0
- package/dist/server/index.d.ts +93 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/instance-registry.d.ts +63 -0
- package/dist/server/instance-registry.d.ts.map +1 -0
- package/dist/server/kanban-routes.d.ts +7 -0
- package/dist/server/kanban-routes.d.ts.map +1 -0
- package/dist/server/lifecycle.d.ts +51 -0
- package/dist/server/lifecycle.d.ts.map +1 -0
- package/dist/server/mailbox-handlers.d.ts +51 -0
- package/dist/server/mailbox-handlers.d.ts.map +1 -0
- package/dist/server/mailbox-routes.d.ts +10 -0
- package/dist/server/mailbox-routes.d.ts.map +1 -0
- package/dist/server/mcp-handlers.d.ts +46 -0
- package/dist/server/mcp-handlers.d.ts.map +1 -0
- package/dist/server/mcp-routes.d.ts +37 -0
- package/dist/server/mcp-routes.d.ts.map +1 -0
- package/dist/server/memory-handlers.d.ts +28 -0
- package/dist/server/memory-handlers.d.ts.map +1 -0
- package/dist/server/message-dispatcher.d.ts +41 -0
- package/dist/server/message-dispatcher.d.ts.map +1 -0
- package/dist/server/mode-handlers.d.ts +50 -0
- package/dist/server/mode-handlers.d.ts.map +1 -0
- package/dist/server/mode-routes.d.ts +8 -0
- package/dist/server/mode-routes.d.ts.map +1 -0
- package/dist/server/model-auto-discovery.d.ts +9 -0
- package/dist/server/model-auto-discovery.d.ts.map +1 -0
- package/dist/server/model-catalog.d.ts +16 -0
- package/dist/server/model-catalog.d.ts.map +1 -0
- package/dist/server/open-browser.d.ts +16 -0
- package/dist/server/open-browser.d.ts.map +1 -0
- package/dist/server/path-containment.d.ts +3 -0
- package/dist/server/path-containment.d.ts.map +1 -0
- package/dist/server/pending-confirms.d.ts +14 -0
- package/dist/server/pending-confirms.d.ts.map +1 -0
- package/dist/server/port-utils.d.ts +28 -0
- package/dist/server/port-utils.d.ts.map +1 -0
- package/dist/server/pre-context-services.d.ts +58 -0
- package/dist/server/pre-context-services.d.ts.map +1 -0
- package/dist/server/pref-helpers.d.ts +43 -0
- package/dist/server/pref-helpers.d.ts.map +1 -0
- package/dist/server/prefs-routes.d.ts +27 -0
- package/dist/server/prefs-routes.d.ts.map +1 -0
- package/dist/server/process-handlers.d.ts +20 -0
- package/dist/server/process-handlers.d.ts.map +1 -0
- package/dist/server/project-handlers.d.ts +53 -0
- package/dist/server/project-handlers.d.ts.map +1 -0
- package/dist/server/project-routes.d.ts +10 -0
- package/dist/server/project-routes.d.ts.map +1 -0
- package/dist/server/projects-manifest.d.ts +18 -0
- package/dist/server/projects-manifest.d.ts.map +1 -0
- package/dist/server/prompts-handlers.d.ts +38 -0
- package/dist/server/prompts-handlers.d.ts.map +1 -0
- package/dist/server/provider-config-io.d.ts +15 -0
- package/dist/server/provider-config-io.d.ts.map +1 -0
- package/dist/server/provider-config-standalone.d.ts +13 -0
- package/dist/server/provider-config-standalone.d.ts.map +1 -0
- package/dist/server/provider-handlers.d.ts +74 -0
- package/dist/server/provider-handlers.d.ts.map +1 -0
- package/dist/server/provider-keys.d.ts +53 -0
- package/dist/server/provider-keys.d.ts.map +1 -0
- package/dist/server/provider-routes.d.ts +13 -0
- package/dist/server/provider-routes.d.ts.map +1 -0
- package/dist/server/provider-store.d.ts +26 -0
- package/dist/server/provider-store.d.ts.map +1 -0
- package/dist/server/routes.d.ts +182 -0
- package/dist/server/routes.d.ts.map +1 -0
- package/dist/server/sdd-board-routes.d.ts +11 -0
- package/dist/server/sdd-board-routes.d.ts.map +1 -0
- package/dist/server/sdd-board-ws-handler.d.ts +57 -0
- package/dist/server/sdd-board-ws-handler.d.ts.map +1 -0
- package/dist/server/sdd-wizard-routes.d.ts +16 -0
- package/dist/server/sdd-wizard-routes.d.ts.map +1 -0
- package/dist/server/sdd-wizard-wiring.d.ts +26 -0
- package/dist/server/sdd-wizard-wiring.d.ts.map +1 -0
- package/dist/server/sdd-wizard-ws-handler.d.ts +66 -0
- package/dist/server/sdd-wizard-ws-handler.d.ts.map +1 -0
- package/dist/server/server-runtime.d.ts +118 -0
- package/dist/server/server-runtime.d.ts.map +1 -0
- package/dist/server/session-handlers.d.ts +44 -0
- package/dist/server/session-handlers.d.ts.map +1 -0
- package/dist/server/session-routes.d.ts +23 -0
- package/dist/server/session-routes.d.ts.map +1 -0
- package/dist/server/setup-events.d.ts +67 -0
- package/dist/server/setup-events.d.ts.map +1 -0
- package/dist/server/setup-screen.d.ts +44 -0
- package/dist/server/setup-screen.d.ts.map +1 -0
- package/dist/server/shell-git-routes.d.ts +10 -0
- package/dist/server/shell-git-routes.d.ts.map +1 -0
- package/dist/server/shell-open.d.ts +12 -0
- package/dist/server/shell-open.d.ts.map +1 -0
- package/dist/server/skills-handlers.d.ts +77 -0
- package/dist/server/skills-handlers.d.ts.map +1 -0
- package/dist/server/specs-routes.d.ts +11 -0
- package/dist/server/specs-routes.d.ts.map +1 -0
- package/dist/server/specs-ws-handler.d.ts +34 -0
- package/dist/server/specs-ws-handler.d.ts.map +1 -0
- package/dist/server/start-webui.d.ts +29 -0
- package/dist/server/start-webui.d.ts.map +1 -0
- package/dist/server/terminal-ws-handler.d.ts +70 -0
- package/dist/server/terminal-ws-handler.d.ts.map +1 -0
- package/dist/server/token-estimator.d.ts +66 -0
- package/dist/server/token-estimator.d.ts.map +1 -0
- package/dist/server/types.d.ts +143 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/usage-cost.d.ts +39 -0
- package/dist/server/usage-cost.d.ts.map +1 -0
- package/dist/server/worktree-ws-handler.d.ts +67 -0
- package/dist/server/worktree-ws-handler.d.ts.map +1 -0
- package/dist/server/ws-auth.d.ts +83 -0
- package/dist/server/ws-auth.d.ts.map +1 -0
- package/dist/server/ws-payload-validation.d.ts +122 -0
- package/dist/server/ws-payload-validation.d.ts.map +1 -0
- package/dist/server/ws-utils.d.ts +38 -0
- package/dist/server/ws-utils.d.ts.map +1 -0
- package/dist/server/zip.d.ts +9 -0
- package/dist/server/zip.d.ts.map +1 -0
- package/package.json +11 -12
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token-usage cost math for the WebUI server.
|
|
3
|
+
*
|
|
4
|
+
* models.dev pricing is expressed in **dollars per 1,000,000 tokens**, and
|
|
5
|
+
* providers omit the field entirely for free/unmetered plans. Both the
|
|
6
|
+
* `session.start` payload (which ships the per-token rates to the client) and
|
|
7
|
+
* `stats.get` (which reports an actual dollar figure) repeated the same
|
|
8
|
+
* "read `model.cost.*` with a `?? 0` fallback, then divide by 1e6" logic
|
|
9
|
+
* inline. Pulling it here keeps the rate normalization and the cost formula in
|
|
10
|
+
* one tested place — a wrong field name or a missing `/ 1e6` silently produces
|
|
11
|
+
* a plausible-but-wrong number, which is exactly what a unit test should pin.
|
|
12
|
+
*/
|
|
13
|
+
/** Per-1,000,000-token pricing, normalized to numbers (0 when unpriced). */
|
|
14
|
+
export interface CostRates {
|
|
15
|
+
/** $ per 1M input tokens. */
|
|
16
|
+
input: number;
|
|
17
|
+
/** $ per 1M output tokens. */
|
|
18
|
+
output: number;
|
|
19
|
+
/** $ per 1M cache-read tokens. */
|
|
20
|
+
cacheRead: number;
|
|
21
|
+
}
|
|
22
|
+
/** Token counts for a turn/session. `cacheRead` is optional (older counters). */
|
|
23
|
+
export interface TokenUsage {
|
|
24
|
+
input: number;
|
|
25
|
+
output: number;
|
|
26
|
+
cacheRead?: number | undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Normalize a models.dev model object's pricing into {@link CostRates}.
|
|
30
|
+
* Missing model, missing `cost`, or missing individual fields all yield 0 —
|
|
31
|
+
* free/unmetered plans report `$0` rather than crashing.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getCostRates(model: unknown): CostRates;
|
|
34
|
+
/**
|
|
35
|
+
* Dollar cost of `usage` at the given per-1M-token `rates`. Returns 0 when all
|
|
36
|
+
* rates are 0 (unpriced plan).
|
|
37
|
+
*/
|
|
38
|
+
export declare function computeUsageCost(usage: TokenUsage, rates: CostRates): number;
|
|
39
|
+
//# sourceMappingURL=usage-cost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-cost.d.ts","sourceRoot":"","sources":["../../src/server/usage-cost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,iFAAiF;AACjF,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAStD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CAO5E"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { WebSocket } from 'ws';
|
|
2
|
+
import type { EventBus, Logger } from '@wrongstack/core';
|
|
3
|
+
export interface WorktreeManagementDeps {
|
|
4
|
+
projectRoot: string;
|
|
5
|
+
/** Board snapshot dir — powers the cross-process liveness guard on cleanup. */
|
|
6
|
+
boardsDir: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* WorktreeWebSocketHandler — mirrors AutoPhaseWebSocketHandler. Subscribes to
|
|
10
|
+
* the shared EventBus `worktree.*` lifecycle events, keeps a live snapshot of
|
|
11
|
+
* every worktree, and broadcasts:
|
|
12
|
+
* - `worktree.event` incrementally (drives the flowing activity strip)
|
|
13
|
+
* - `worktree.state` on connect + on a 2s timer (drives swim-lanes/DAG)
|
|
14
|
+
*/
|
|
15
|
+
export declare class WorktreeWebSocketHandler {
|
|
16
|
+
private readonly events;
|
|
17
|
+
private readonly logger;
|
|
18
|
+
private readonly management?;
|
|
19
|
+
private readonly clients;
|
|
20
|
+
private readonly handles;
|
|
21
|
+
private baseBranch;
|
|
22
|
+
private broadcastInterval;
|
|
23
|
+
private readonly offs;
|
|
24
|
+
constructor(events: EventBus, logger: Logger, management?: WorktreeManagementDeps | undefined);
|
|
25
|
+
addClient(ws: WebSocket): void;
|
|
26
|
+
/** Handle worktree-panel control messages (scan / clean / per-row ops). */
|
|
27
|
+
handleMessage(msg: {
|
|
28
|
+
type: string;
|
|
29
|
+
payload?: Record<string, unknown>;
|
|
30
|
+
}): Promise<boolean>;
|
|
31
|
+
dispose(): void;
|
|
32
|
+
/** Absolute managed-worktrees root for this project. */
|
|
33
|
+
private worktreesRoot;
|
|
34
|
+
/** True iff `dir` resolves strictly inside the managed worktrees root. */
|
|
35
|
+
private underRoot;
|
|
36
|
+
/** Branches of worktrees a live in-session run currently owns. */
|
|
37
|
+
private liveActiveBranches;
|
|
38
|
+
/**
|
|
39
|
+
* Scan the disk for managed worktrees/branches NOT owned by a live in-session
|
|
40
|
+
* run and broadcast them as orphans, with whether it is safe to clean now.
|
|
41
|
+
* No-op (empty inventory) when management deps were not wired.
|
|
42
|
+
*/
|
|
43
|
+
private scanAndBroadcast;
|
|
44
|
+
/**
|
|
45
|
+
* Force-remove every orphaned worktree + branch. Refused while a run is live —
|
|
46
|
+
* in this session (active handles) OR another process (the SDD board liveness
|
|
47
|
+
* guard inside cleanupStaleSddWorktrees). Best-effort; reports the outcome.
|
|
48
|
+
*/
|
|
49
|
+
private cleanupOrphans;
|
|
50
|
+
/** Remove/discard ONE worktree + branch. Refused while a live run owns it. */
|
|
51
|
+
private removeOne;
|
|
52
|
+
/** Squash-merge ONE branch into base. Refused while a live run owns it. */
|
|
53
|
+
private mergeBranch;
|
|
54
|
+
/** Compact change summary for one worktree checkout. */
|
|
55
|
+
private diffOne;
|
|
56
|
+
private subscribe;
|
|
57
|
+
private upsert;
|
|
58
|
+
private patch;
|
|
59
|
+
private activity;
|
|
60
|
+
private stateMessage;
|
|
61
|
+
private broadcastState;
|
|
62
|
+
private ensureBroadcast;
|
|
63
|
+
private stopBroadcast;
|
|
64
|
+
private broadcast;
|
|
65
|
+
private send;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=worktree-ws-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-ws-handler.d.ts","sourceRoot":"","sources":["../../src/server/worktree-ws-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAmBzD,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,qBAAa,wBAAwB;IAQjC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,M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ostname(hostname: string): boolean;
|
|
3
|
+
/** True when the server is bound to a loopback interface (vs. LAN/0.0.0.0). */
|
|
4
|
+
export declare function isLoopbackBind(wsHost: string): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* True when the server is bound to a wildcard address that exposes it on every
|
|
7
|
+
* interface — IPv4 `0.0.0.0` OR IPv6 `::` (and its bracketed form). The
|
|
8
|
+
* "LAN exposure = deny" guards below must treat both families identically; a
|
|
9
|
+
* `::` bind is exactly as exposed as `0.0.0.0` and previously slipped past the
|
|
10
|
+
* `wsHost === '0.0.0.0'` string check.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isWildcardBind(wsHost: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Constant-time comparison of a provided token against the expected one.
|
|
15
|
+
* A length mismatch short-circuits (lengths aren't secret); equal-length
|
|
16
|
+
* inputs are compared with `timingSafeEqual` so the token can't be recovered
|
|
17
|
+
* byte-by-byte via response timing.
|
|
18
|
+
*/
|
|
19
|
+
export declare function tokenMatches(provided: string | undefined, expected: string): boolean;
|
|
20
|
+
/** Pull the `token` query param out of a request URL (`/?token=…`). */
|
|
21
|
+
export declare function extractToken(url: string): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Pull the `ws_token` value out of a Cookie header (`Cookie: ws_token=…`).
|
|
24
|
+
* The WebUI's auth-token cookie is set via `Set-Cookie: ws_token=<token>;
|
|
25
|
+
* HttpOnly; SameSite=Strict; Path=/` from the `/ws-auth` HTTP endpoint. The
|
|
26
|
+
* browser then sends it back automatically on the WS upgrade request —
|
|
27
|
+
* closing the C-598 (Information Exposure Through Query String) class
|
|
28
|
+
* because the token never appears in the URL, browser history, or
|
|
29
|
+
* reverse-proxy access logs.
|
|
30
|
+
*
|
|
31
|
+
* Returns `undefined` if the cookie header is absent or malformed.
|
|
32
|
+
*/
|
|
33
|
+
export declare function extractTokenFromCookie(cookieHeader: string | string[] | undefined): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* DNS-rebinding defense. On a loopback bind, the `Host` header must resolve to
|
|
36
|
+
* a loopback name. When the operator deliberately exposes the socket (wsHost is
|
|
37
|
+
* a LAN/0.0.0.0 address) the Host is legitimately non-loopback, so the guard is
|
|
38
|
+
* skipped and connection auth falls to the token check.
|
|
39
|
+
*/
|
|
40
|
+
export declare function hostHeaderOk(input: {
|
|
41
|
+
hostHeader: string | undefined;
|
|
42
|
+
wsHost: string;
|
|
43
|
+
allowedHostnames?: readonly string[] | undefined;
|
|
44
|
+
}): boolean;
|
|
45
|
+
export interface VerifyClientInput {
|
|
46
|
+
/** Browser `Origin` header, or undefined for non-browser clients. */
|
|
47
|
+
origin?: string | undefined;
|
|
48
|
+
/** Request URL (`req.url`) — carries the `?token=…` query param. */
|
|
49
|
+
url: string;
|
|
50
|
+
/** `Host` header (`req.headers.host`). */
|
|
51
|
+
hostHeader?: string | undefined;
|
|
52
|
+
/** Peer address (`req.socket.remoteAddress`). */
|
|
53
|
+
remoteAddress?: string | undefined;
|
|
54
|
+
/** `Cookie` header (`req.headers.cookie`). Carries `ws_token=…` when the
|
|
55
|
+
* browser went through `/ws-auth` to set the HttpOnly auth cookie. */
|
|
56
|
+
cookieHeader?: string | string[] | undefined;
|
|
57
|
+
/** Host/interface the WS server is bound to. */
|
|
58
|
+
wsHost: string;
|
|
59
|
+
/** The server's generated auth token. */
|
|
60
|
+
expectedToken: string;
|
|
61
|
+
/** Force token auth even for loopback binds, useful behind public tunnels. */
|
|
62
|
+
requireToken?: boolean | undefined;
|
|
63
|
+
/** Extra Host header names allowed on loopback binds, e.g. a tunnel hostname. */
|
|
64
|
+
allowedHostnames?: readonly string[] | undefined;
|
|
65
|
+
/** Allow browser WS URL tokens for explicit public WS URLs where cookies cannot cross hostnames. */
|
|
66
|
+
allowBrowserUrlToken?: boolean | undefined;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Decide whether to accept an incoming WebSocket handshake. Pure mirror of the
|
|
70
|
+
* closure previously inlined in `index.ts`; see the module doc for the layered
|
|
71
|
+
* policy. Returns `true` to accept, `false` to reject.
|
|
72
|
+
*
|
|
73
|
+
* Token sources, in priority order:
|
|
74
|
+
* 1. `Cookie: ws_token=…` (browser clients that went through `/ws-auth`)
|
|
75
|
+
* 2. `?token=…` URL query param (non-browser clients: curl, scripts)
|
|
76
|
+
*
|
|
77
|
+
* Browser clients (with an `Origin` header) are restricted to the cookie path —
|
|
78
|
+
* URL token is rejected for them, closing the C-598 query-string token
|
|
79
|
+
* exposure class. Non-browser clients keep the URL-token fallback so curl
|
|
80
|
+
* and tests continue to work.
|
|
81
|
+
*/
|
|
82
|
+
export declare function verifyClient(input: VerifyClientInput): boolean;
|
|
83
|
+
//# sourceMappingURL=ws-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-auth.d.ts","sourceRoot":"","sources":["../../src/server/ws-auth.ts"],"names":[],"mappings":"AA+BA,mDAAmD;AACnD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAO5D;AAwBD,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEtD;AAYD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMpF;AAED,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAkBtG;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CAClD,GAAG,OAAO,CAYV;AAED,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,oEAAoE;IACpE,GAAG,EAAE,MAAM,CAAC;IACZ,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,iDAAiD;IACjD,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC;2EACuE;IACvE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7C,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACjD,oGAAoG;IACpG,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC5C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAuD9D"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export type PayloadValidationResult<T> = {
|
|
2
|
+
ok: true;
|
|
3
|
+
value: T;
|
|
4
|
+
} | {
|
|
5
|
+
ok: false;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
export interface ModelSwitchPayload {
|
|
9
|
+
provider: string;
|
|
10
|
+
model: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function validateModelSwitchPayload(payload: unknown): PayloadValidationResult<ModelSwitchPayload>;
|
|
13
|
+
export interface PrefsUpdatePayload {
|
|
14
|
+
prefs: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface MailboxMessagesPayload {
|
|
17
|
+
limit?: number;
|
|
18
|
+
agentId?: string;
|
|
19
|
+
unreadOnly?: boolean;
|
|
20
|
+
incompleteOnly?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function validateMailboxMessagesPayload(payload: unknown): PayloadValidationResult<MailboxMessagesPayload | undefined>;
|
|
23
|
+
export interface MailboxAgentsPayload {
|
|
24
|
+
onlineOnly?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function validateMailboxAgentsPayload(payload: unknown): PayloadValidationResult<MailboxAgentsPayload | undefined>;
|
|
27
|
+
export interface MailboxPurgePayload {
|
|
28
|
+
completedMaxAgeMs?: number;
|
|
29
|
+
incompleteMaxAgeMs?: number;
|
|
30
|
+
}
|
|
31
|
+
export declare function validateMailboxPurgePayload(payload: unknown): PayloadValidationResult<MailboxPurgePayload | undefined>;
|
|
32
|
+
export interface BrainRiskPayload {
|
|
33
|
+
level: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function validateBrainRiskPayload(payload: unknown): PayloadValidationResult<BrainRiskPayload>;
|
|
36
|
+
export interface BrainAskPayload {
|
|
37
|
+
question: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function validateBrainAskPayload(payload: unknown): PayloadValidationResult<BrainAskPayload>;
|
|
40
|
+
export interface AutonomySwitchPayload {
|
|
41
|
+
mode: string;
|
|
42
|
+
}
|
|
43
|
+
export declare function validateAutonomySwitchPayload(payload: unknown): PayloadValidationResult<AutonomySwitchPayload>;
|
|
44
|
+
export interface PlanTemplateUsePayload {
|
|
45
|
+
template: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function validatePlanTemplateUsePayload(payload: unknown): PayloadValidationResult<PlanTemplateUsePayload>;
|
|
48
|
+
export declare function validatePrefsUpdatePayload(payload: unknown): PayloadValidationResult<PrefsUpdatePayload>;
|
|
49
|
+
export interface SkillsCreatePayload {
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
scope: 'project' | 'global';
|
|
53
|
+
}
|
|
54
|
+
export declare function validateSkillsCreatePayload(payload: unknown): PayloadValidationResult<SkillsCreatePayload>;
|
|
55
|
+
export interface SkillsEditPayload {
|
|
56
|
+
name: string;
|
|
57
|
+
body: string;
|
|
58
|
+
}
|
|
59
|
+
export declare function validateSkillsEditPayload(payload: unknown): PayloadValidationResult<SkillsEditPayload>;
|
|
60
|
+
export interface ProcessKillPayload {
|
|
61
|
+
pid: number;
|
|
62
|
+
}
|
|
63
|
+
export declare function validateProcessKillPayload(payload: unknown): PayloadValidationResult<ProcessKillPayload>;
|
|
64
|
+
export interface WorkingDirSetPayload {
|
|
65
|
+
path: string;
|
|
66
|
+
}
|
|
67
|
+
export declare function validateWorkingDirSetPayload(payload: unknown): PayloadValidationResult<WorkingDirSetPayload>;
|
|
68
|
+
export interface ModeSwitchPayload {
|
|
69
|
+
id: string;
|
|
70
|
+
}
|
|
71
|
+
export declare function validateModeSwitchPayload(payload: unknown): PayloadValidationResult<ModeSwitchPayload>;
|
|
72
|
+
export interface ContextModeIdPayload {
|
|
73
|
+
id: string;
|
|
74
|
+
}
|
|
75
|
+
export declare function validateContextModeSwitchPayload(payload: unknown): PayloadValidationResult<ContextModeIdPayload>;
|
|
76
|
+
export declare function validateContextModeDeletePayload(payload: unknown): PayloadValidationResult<ContextModeIdPayload>;
|
|
77
|
+
export interface ContextModeCreatePayload {
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
description: string;
|
|
81
|
+
thresholds: {
|
|
82
|
+
warn: number;
|
|
83
|
+
soft: number;
|
|
84
|
+
hard: number;
|
|
85
|
+
};
|
|
86
|
+
preserveK: number;
|
|
87
|
+
eliseThreshold: number;
|
|
88
|
+
}
|
|
89
|
+
export declare function validateContextModeCreatePayload(payload: unknown): PayloadValidationResult<ContextModeCreatePayload>;
|
|
90
|
+
export interface ContextModeUpdatePayload {
|
|
91
|
+
id: string;
|
|
92
|
+
name?: string;
|
|
93
|
+
description?: string;
|
|
94
|
+
thresholds?: {
|
|
95
|
+
warn?: number;
|
|
96
|
+
soft?: number;
|
|
97
|
+
hard?: number;
|
|
98
|
+
};
|
|
99
|
+
preserveK?: number;
|
|
100
|
+
eliseThreshold?: number;
|
|
101
|
+
}
|
|
102
|
+
export declare function validateContextModeUpdatePayload(payload: unknown): PayloadValidationResult<ContextModeUpdatePayload>;
|
|
103
|
+
export interface ShellOpenPayload {
|
|
104
|
+
path: string;
|
|
105
|
+
target?: 'file' | 'terminal';
|
|
106
|
+
}
|
|
107
|
+
export declare function validateShellOpenPayload(payload: unknown): PayloadValidationResult<ShellOpenPayload>;
|
|
108
|
+
export interface GitDiffPayload {
|
|
109
|
+
path: string;
|
|
110
|
+
}
|
|
111
|
+
export declare function validateGitDiffPayload(payload: unknown): PayloadValidationResult<GitDiffPayload>;
|
|
112
|
+
export interface ProjectsAddPayload {
|
|
113
|
+
root: string;
|
|
114
|
+
name?: string;
|
|
115
|
+
}
|
|
116
|
+
export declare function validateProjectsAddPayload(payload: unknown): PayloadValidationResult<ProjectsAddPayload>;
|
|
117
|
+
export interface ProjectsSelectPayload {
|
|
118
|
+
root: string;
|
|
119
|
+
name?: string;
|
|
120
|
+
}
|
|
121
|
+
export declare function validateProjectsSelectPayload(payload: unknown): PayloadValidationResult<ProjectsSelectPayload>;
|
|
122
|
+
//# sourceMappingURL=ws-payload-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-payload-validation.d.ts","sourceRoot":"","sources":["../../src/server/ws-payload-validation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAMjG,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,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I,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,uBAAuB,CAAC,cAAc,CAAC,CAYhG;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,GACf,uBAAuB,CAAC,kBAAkB,CAAC,CAgB7C;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,OAAO,GACf,uBAAuB,CAAC,qBAAqB,CAAC,CAgBhD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { WebSocket } from 'ws';
|
|
2
|
+
import type { ConnectedClient } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Send a JSON message to a single WebSocket client.
|
|
5
|
+
* No-op when the socket is not in OPEN state (disconnected / closing).
|
|
6
|
+
*/
|
|
7
|
+
export declare function send(ws: WebSocket, msg: object): void;
|
|
8
|
+
/**
|
|
9
|
+
* Broadcast a JSON message to every connected client.
|
|
10
|
+
* Swallows per-socket send errors — a client that disconnected between the
|
|
11
|
+
* readyState check and `ws.send()` is cleaned up by its own `close` handler.
|
|
12
|
+
*/
|
|
13
|
+
export declare function broadcast(clients: Map<WebSocket, ConnectedClient>, msg: object): void;
|
|
14
|
+
/**
|
|
15
|
+
* Send a success/failure result message (used by key.* and provider.* handlers).
|
|
16
|
+
* The frontend expects `key.operation_result` with `{ success, message }`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function sendResult(ws: WebSocket, success: boolean, message: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Extract a human-readable message from an unknown thrown value.
|
|
21
|
+
*/
|
|
22
|
+
export declare function errMessage(err: unknown): string;
|
|
23
|
+
/**
|
|
24
|
+
* Generate a cryptographically random WebSocket auth token (hex string).
|
|
25
|
+
* Shared between standalone and CLI-embedded WebUI servers.
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateAuthToken(): string;
|
|
28
|
+
export declare function resolveAuthToken(explicit?: string | undefined): string;
|
|
29
|
+
export declare function hostForBrowserUrl(bindHost: string): string;
|
|
30
|
+
export declare function buildWebUIAccessUrl(opts: {
|
|
31
|
+
host: string;
|
|
32
|
+
port: number;
|
|
33
|
+
token?: string | undefined;
|
|
34
|
+
protocol?: 'http' | 'https' | undefined;
|
|
35
|
+
publicUrl?: string | undefined;
|
|
36
|
+
}): string;
|
|
37
|
+
export declare function envFlag(name: string): boolean;
|
|
38
|
+
//# sourceMappingURL=ws-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-utils.d.ts","sourceRoot":"","sources":["../../src/server/ws-utils.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;GAGG;AACH,wBAAgB,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAIrD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,GAAG,CAAC,SAAS,EAAE,eAAe,CAAC,EACxC,GAAG,EAAE,MAAM,GACV,IAAI,CAYN;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAEjF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAE/C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMtE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK1D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACxC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,GAAG,MAAM,CAgBT;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAG7C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ZipEntryInput {
|
|
2
|
+
name: string;
|
|
3
|
+
data: string | Uint8Array;
|
|
4
|
+
}
|
|
5
|
+
/** Create a standards-compliant ZIP archive using only Node built-ins. */
|
|
6
|
+
export declare function createZipBuffer(entries: ZipEntryInput[]): Buffer;
|
|
7
|
+
/** Minimal reader for validation/import paths; rejects encrypted or unsafe entries. */
|
|
8
|
+
export declare function readZipEntries(archive: Uint8Array): Map<string, Buffer>;
|
|
9
|
+
//# sourceMappingURL=zip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../src/server/zip.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAC3B;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM,CAiDhE;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAyCvE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wrongstack/webui-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.285.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "WrongStack WebUI HTTP/WebSocket server module — extracted from @wrongstack/webui in PR #243/244 to remove the CLI -> @wrongstack/webui/server cross-package edge (audit §3.1.1). Pure backend: HTTP routes, WebSocket handlers, MCP tool wrappers, HTML serving. The web frontend lives in @wrongstack/webui; this package is the standalone server it can run on.",
|
|
6
6
|
"keywords": [
|
|
@@ -37,27 +37,26 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"jszip": "^3.10.1",
|
|
41
40
|
"ws": "^8.21.0",
|
|
42
|
-
"@wrongstack/core": "0.
|
|
43
|
-
"@wrongstack/kanban": "0.
|
|
44
|
-
"@wrongstack/
|
|
45
|
-
"@wrongstack/
|
|
46
|
-
"@wrongstack/
|
|
47
|
-
"@wrongstack/
|
|
48
|
-
"@wrongstack/
|
|
41
|
+
"@wrongstack/core": "0.285.0",
|
|
42
|
+
"@wrongstack/kanban": "0.285.0",
|
|
43
|
+
"@wrongstack/providers": "0.285.0",
|
|
44
|
+
"@wrongstack/super-memory": "0.285.0",
|
|
45
|
+
"@wrongstack/sdd": "0.285.0",
|
|
46
|
+
"@wrongstack/mcp": "0.285.0",
|
|
47
|
+
"@wrongstack/tools": "0.285.0",
|
|
48
|
+
"@wrongstack/runtime": "0.285.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^26.0.1",
|
|
52
52
|
"@types/ws": "^8.18.1",
|
|
53
|
-
"
|
|
54
|
-
"typescript": "^6.0.3"
|
|
53
|
+
"typescript": "^7.0.2"
|
|
55
54
|
},
|
|
56
55
|
"publishConfig": {
|
|
57
56
|
"access": "public"
|
|
58
57
|
},
|
|
59
58
|
"scripts": {
|
|
60
|
-
"build": "
|
|
59
|
+
"build": "node ../../scripts/build-package.mjs",
|
|
61
60
|
"typecheck": "tsc --noEmit",
|
|
62
61
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
|
|
63
62
|
}
|