@wrongstack/webui-server 0.284.1 → 0.286.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 +1807 -539
- 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 +103 -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 +11 -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 +167 -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 +1595 -562
- 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 +63 -0
- package/dist/server/mailbox-handlers.d.ts.map +1 -0
- package/dist/server/mailbox-routes.d.ts +11 -0
- package/dist/server/mailbox-routes.d.ts.map +1 -0
- package/dist/server/mcp-handlers.d.ts +55 -0
- package/dist/server/mcp-handlers.d.ts.map +1 -0
- package/dist/server/mcp-routes.d.ts +41 -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 +60 -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 +187 -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 +57 -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/standalone-session-identity.d.ts +35 -0
- package/dist/server/standalone-session-identity.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 +126 -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,67 @@
|
|
|
1
|
+
import type { Context, EventBus, SessionEventBridge, WstackPaths } from '@wrongstack/core';
|
|
2
|
+
import type { WebSocket } from 'ws';
|
|
3
|
+
import type { ConnectedClient, WSServerMessage } from './types.js';
|
|
4
|
+
import type { PendingConfirm } from './pending-confirms.js';
|
|
5
|
+
/** Metrics for the file watcher that watches status.json files. */
|
|
6
|
+
export interface FileWatcherMetrics {
|
|
7
|
+
/** Number of status.json filesystem events detected after filename filtering. */
|
|
8
|
+
fileChangesDetected: number;
|
|
9
|
+
filesProcessed: number;
|
|
10
|
+
broadcastsSent: number;
|
|
11
|
+
debounceResets: number;
|
|
12
|
+
totalDebounceDelayMs: number;
|
|
13
|
+
activeProjects: number;
|
|
14
|
+
/** Average debounce delay in ms across all broadcasts. */
|
|
15
|
+
averageDebounceDelayMs: number;
|
|
16
|
+
/** Whether the file watcher is currently active. */
|
|
17
|
+
watcherActive: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface SetupEventsDeps {
|
|
20
|
+
events: EventBus;
|
|
21
|
+
broadcast: (clients: Map<WebSocket, ConnectedClient>, msg: WSServerMessage) => void;
|
|
22
|
+
clients: Map<WebSocket, ConnectedClient>;
|
|
23
|
+
config: {
|
|
24
|
+
tools?: {
|
|
25
|
+
maxIterations?: number | undefined;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
context: Context;
|
|
29
|
+
pendingConfirms: Map<string, PendingConfirm>;
|
|
30
|
+
/** Optional global config dir (~/.wrongstack) — enables SessionRegistry poll for fleet view. */
|
|
31
|
+
globalConfigPath?: string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Audit-level-aware session log bridge. When provided, tool/error/provider
|
|
34
|
+
* events are persisted to the session JSONL (same contract as the CLI) —
|
|
35
|
+
* without it, standalone-WebUI sessions carry no audit events and resume
|
|
36
|
+
* with no tool history.
|
|
37
|
+
*/
|
|
38
|
+
sessionBridge?: SessionEventBridge | undefined;
|
|
39
|
+
/** Optional wpaths for writing status.json file. */
|
|
40
|
+
wpaths?: WstackPaths | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Optional object to populate with file watcher metrics.
|
|
43
|
+
* When provided, the setupEvents function will populate this object
|
|
44
|
+
* with real-time metrics from the file watcher.
|
|
45
|
+
*/
|
|
46
|
+
watcherMetrics?: FileWatcherMetrics | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Receives the internal `broadcastSessions` fn so the HTTP layer can trigger
|
|
49
|
+
* an immediate fleet re-broadcast on `POST /api/fleet/ping` (push-on-write
|
|
50
|
+
* from a TUI/REPL), instead of waiting on the registry file-watch/poll.
|
|
51
|
+
*/
|
|
52
|
+
onFleetBroadcaster?: ((fn: () => Promise<void>) => void) | undefined;
|
|
53
|
+
}
|
|
54
|
+
export declare function statusProjectHashFromWatchFilename(projectsDir: string, filename: string | Buffer): string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Wire kernel events to WS broadcasts and (when wpaths/globalConfigPath are
|
|
57
|
+
* given) start the status-file watcher and session-poll interval.
|
|
58
|
+
*
|
|
59
|
+
* Returns a disposer that stops the watcher, clears the metrics/poll
|
|
60
|
+
* intervals, and flushes pending debounce timers. Callers MUST invoke it on
|
|
61
|
+
* shutdown — the watcher is `persistent: true` and the metrics interval is not
|
|
62
|
+
* `unref`'d, so without disposal they keep the process alive and leak across
|
|
63
|
+
* server restarts. (Previously this was hung off a non-existent
|
|
64
|
+
* `process.on('cleanup')` event that never fired.)
|
|
65
|
+
*/
|
|
66
|
+
export declare function setupEvents(deps: SetupEventsDeps): () => void;
|
|
67
|
+
//# sourceMappingURL=setup-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-events.d.ts","sourceRoot":"","sources":["../../src/server/setup-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAuB,kBAAkB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAM5D,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,iFAAiF;IACjF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,sBAAsB,EAAE,MAAM,CAAC;IAC/B,oDAAoD;IACpD,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,SAAS,EAAE,eAAe,CAAC,EAAE,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;IACpF,OAAO,EAAE,GAAG,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;IACzC,MAAM,EAAE;QAAE,KAAK,CAAC,EAAE;YAAE,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;SAAE,CAAA;KAAE,CAAC;IAC3D,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C,gGAAgG;IAChG,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAC/C,oDAAoD;IACpD,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACjC;;;;OAIG;IACH,cAAc,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAChD;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACtE;AAED,wBAAgB,kCAAkC,CAChD,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GAAG,MAAM,GACxB,MAAM,GAAG,IAAI,CAOf;AAOD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,IAAI,CAk8B7D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First-run setup + active-provider resolution.
|
|
3
|
+
*
|
|
4
|
+
* Phase 1b of the god-module split (issue: God-modules >1500 lines).
|
|
5
|
+
* `startWebUI` in `./index.ts` previously inlined the provider-resolution
|
|
6
|
+
* ladder (configured provider → first saved provider → stub provider +
|
|
7
|
+
* `needsSetup` flag). This module lifts that ladder into a single pure-ish
|
|
8
|
+
* function so `index.ts` reads as orchestration, not branching.
|
|
9
|
+
*
|
|
10
|
+
* No behaviour change: the three branches, the structured error logs, the
|
|
11
|
+
* `needsSetup` flag, and the stub provider's exact shape are preserved
|
|
12
|
+
* verbatim. The function throws on the same failures the inline code did.
|
|
13
|
+
*/
|
|
14
|
+
import type { Provider, ProviderRegistry } from '@wrongstack/core';
|
|
15
|
+
import type { Config } from '@wrongstack/core/types';
|
|
16
|
+
export interface ResolveSetupProviderOptions {
|
|
17
|
+
config: Config;
|
|
18
|
+
/** True when neither provider nor model is set in config. */
|
|
19
|
+
needsProvider: boolean;
|
|
20
|
+
providerRegistry: ProviderRegistry;
|
|
21
|
+
}
|
|
22
|
+
export interface ResolvedSetupProvider {
|
|
23
|
+
provider: Provider;
|
|
24
|
+
/**
|
|
25
|
+
* True when no provider could be resolved and a stub was created — the
|
|
26
|
+
* frontend should show the onboarding/setup screen. False otherwise.
|
|
27
|
+
* (The caller merges this into its existing `needsSetup` flag.)
|
|
28
|
+
*/
|
|
29
|
+
needsSetup: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolve the active provider from config, mirroring the inline ladder that
|
|
33
|
+
* used to live in `startWebUI`:
|
|
34
|
+
*
|
|
35
|
+
* 1. provider + model configured → build from the configured provider.
|
|
36
|
+
* 2. no active provider but saved providers exist → build from the first
|
|
37
|
+
* saved provider (vault already decrypted its key).
|
|
38
|
+
* 3. no providers at all → boot with an inert placeholder provider and signal
|
|
39
|
+
* `needsSetup` so the frontend shows the onboarding screen.
|
|
40
|
+
*
|
|
41
|
+
* Throws on provider-construction failure (same as the inline code).
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveSetupProvider(opts: ResolveSetupProviderOptions): ResolvedSetupProvider;
|
|
44
|
+
//# sourceMappingURL=setup-screen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-screen.d.ts","sourceRoot":"","sources":["../../src/server/setup-screen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAkB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAuCrD,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,QAAQ,CAAC;IACnB;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB;AAaD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,2BAA2B,GAChC,qBAAqB,CAkDvB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WebSocket } from 'ws';
|
|
2
|
+
import type { WSClientMessage } from './types.js';
|
|
3
|
+
export interface ShellGitRouteHandlers {
|
|
4
|
+
gitInfo: (ws: WebSocket) => Promise<void>;
|
|
5
|
+
gitChanges: (ws: WebSocket) => Promise<void>;
|
|
6
|
+
gitDiff: (ws: WebSocket, msg: WSClientMessage) => Promise<void>;
|
|
7
|
+
shellOpen: (ws: WebSocket, msg: WSClientMessage) => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare function handleShellGitRoute(ws: WebSocket, msg: WSClientMessage, handlers: ShellGitRouteHandlers): Promise<boolean>;
|
|
10
|
+
//# sourceMappingURL=shell-git-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-git-routes.d.ts","sourceRoot":"","sources":["../../src/server/shell-git-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,CAAC,EAAE,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,UAAU,EAAE,CAAC,EAAE,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,SAAS,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnE;AAED,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC,OAAO,CAAC,CAiBlB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Logger } from '@wrongstack/core';
|
|
2
|
+
export type ShellOpenTarget = 'terminal' | 'file-manager';
|
|
3
|
+
export interface ShellOpenRequest {
|
|
4
|
+
path: string;
|
|
5
|
+
target: ShellOpenTarget;
|
|
6
|
+
}
|
|
7
|
+
export interface ShellOpenResult {
|
|
8
|
+
success: boolean;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function handleShellOpen(req: ShellOpenRequest, logger: Logger): Promise<ShellOpenResult>;
|
|
12
|
+
//# sourceMappingURL=shell-open.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-open.d.ts","sourceRoot":"","sources":["../../src/server/shell-open.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,cAAc,CAAC;AAE1D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAeD,wBAAsB,eAAe,CACnC,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,eAAe,CAAC,CAyD1B"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared skills WebSocket handlers for both the standalone WebUI server
|
|
3
|
+
* (`packages/webui/src/server/index.ts`) and the CLI's `--webui` embedded
|
|
4
|
+
* server (`packages/cli/src/webui-server.ts`).
|
|
5
|
+
*
|
|
6
|
+
* These were previously inlined in BOTH servers, and the CLI copy had
|
|
7
|
+
* drifted — it only wired `skills.list`, so `skills.content` /
|
|
8
|
+
* `skills.export` / `skills.update` (and install/uninstall/create/edit)
|
|
9
|
+
* fell through to the "Unhandled message type" warning even though the
|
|
10
|
+
* SkillsPanel sends them. Extracting the full set here gives both servers
|
|
11
|
+
* one source of truth. Each function handles the full request→response
|
|
12
|
+
* cycle for one message type; callers drop them into their switch:
|
|
13
|
+
*
|
|
14
|
+
* case 'skills.content': return handleSkillsContent(ws, skillsCtx, msg);
|
|
15
|
+
*
|
|
16
|
+
* The logic is a verbatim lift of the standalone's inline cases — only the
|
|
17
|
+
* dependency references changed (`skillLoader`/`skillInstaller`/
|
|
18
|
+
* `projectRoot` → `ctx.*`, local `send`/`errMessage` → imported helpers).
|
|
19
|
+
*/
|
|
20
|
+
import type { WebSocket } from 'ws';
|
|
21
|
+
import type { SkillLoader } from '@wrongstack/core';
|
|
22
|
+
import type { SkillInstaller } from '@wrongstack/core/skills';
|
|
23
|
+
export interface SkillsContext {
|
|
24
|
+
/** Backs skills.list/content/edit/export. Absent ⇒ feature disabled. */
|
|
25
|
+
skillLoader: SkillLoader | undefined;
|
|
26
|
+
/** Backs skills.install/uninstall/update. Absent ⇒ those ops disabled. */
|
|
27
|
+
skillInstaller: SkillInstaller | undefined;
|
|
28
|
+
/** Project root — used by skills.create to write `.wrongstack/skills/…`. */
|
|
29
|
+
projectRoot: string;
|
|
30
|
+
/** Project skills directory, normally `<project>/.wrongstack/skills`. */
|
|
31
|
+
projectSkillsDir?: string | undefined;
|
|
32
|
+
/** User-global skills directory, normally `~/.wrongstack/skills`. */
|
|
33
|
+
globalSkillsDir?: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* List installed skills. Enriches each manifest with the source URL + git
|
|
37
|
+
* ref recorded by the installer (when present), so the panel can show
|
|
38
|
+
* provenance and offer update/uninstall.
|
|
39
|
+
*/
|
|
40
|
+
export declare function handleSkillsList(ws: WebSocket, ctx: SkillsContext): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Read a single skill's body + its directory's related files + which other
|
|
43
|
+
* skills reference it by name. Powers the skill detail/preview view.
|
|
44
|
+
*/
|
|
45
|
+
export declare function handleSkillsContent(ws: WebSocket, ctx: SkillsContext, msg: unknown): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Install a skill from a git ref (`owner/repo` or URL). Optional `global`
|
|
48
|
+
* installs into the user-wide skills dir instead of the project's.
|
|
49
|
+
*/
|
|
50
|
+
export declare function handleSkillsInstall(ws: WebSocket, ctx: SkillsContext, msg: unknown): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Uninstall a skill by name. Optional `global` restricts/Targets the
|
|
53
|
+
* user-wide install.
|
|
54
|
+
*/
|
|
55
|
+
export declare function handleSkillsUninstall(ws: WebSocket, ctx: SkillsContext, msg: unknown): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Update one skill (`name`) or all installed skills (when `name` is
|
|
58
|
+
* omitted). Reports per-skill updated/unchanged/error tallies.
|
|
59
|
+
*/
|
|
60
|
+
export declare function handleSkillsUpdate(ws: WebSocket, ctx: SkillsContext, msg: unknown): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Scaffold a new project- or global-scoped skill from a name + description.
|
|
63
|
+
* Writes a templated `SKILL.md` under `.wrongstack/skills/<name>/` (project)
|
|
64
|
+
* or the user-wide skills dir (global).
|
|
65
|
+
*/
|
|
66
|
+
export declare function handleSkillsCreate(ws: WebSocket, ctx: SkillsContext, msg: unknown): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Overwrite a skill's body. Refuses bundled skills (read-only) and unknown
|
|
69
|
+
* names.
|
|
70
|
+
*/
|
|
71
|
+
export declare function handleSkillsEdit(ws: WebSocket, ctx: SkillsContext, msg: unknown): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Export every readable skill as a base64-encoded zip (one folder per skill,
|
|
74
|
+
* each with its `SKILL.md`). Powers the panel's "Export all" button.
|
|
75
|
+
*/
|
|
76
|
+
export declare function handleSkillsExport(ws: WebSocket, ctx: SkillsContext): Promise<void>;
|
|
77
|
+
//# sourceMappingURL=skills-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills-handlers.d.ts","sourceRoot":"","sources":["../../src/server/skills-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAM9D,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,0EAA0E;IAC1E,cAAc,EAAE,cAAc,GAAG,SAAS,CAAC;IAC3C,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAID;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDvF;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,IAAI,CAAC,CAuDf;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,IAAI,CAAC,CA6Bf;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,IAAI,CAAC,CAqBf;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,IAAI,CAAC,CA0Ff;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBzF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WebSocket } from 'ws';
|
|
2
|
+
import type { WSClientMessage } from './types.js';
|
|
3
|
+
export interface SpecsRouteHandlers {
|
|
4
|
+
handleMessage: (msg: {
|
|
5
|
+
type: string;
|
|
6
|
+
payload?: Record<string, unknown>;
|
|
7
|
+
}) => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/** Forward any `specs.*` message to the SpecsWebSocketHandler. */
|
|
10
|
+
export declare function handleSpecsRoute(_ws: WebSocket, msg: WSClientMessage, handlers: SpecsRouteHandlers): Promise<boolean>;
|
|
11
|
+
//# sourceMappingURL=specs-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specs-routes.d.ts","sourceRoot":"","sources":["../../src/server/specs-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5F;AAED,kEAAkE;AAClE,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,SAAS,EACd,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,kBAAkB,GAC3B,OAAO,CAAC,OAAO,CAAC,CAIlB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { WebSocket } from 'ws';
|
|
2
|
+
interface SpecsWSMessage {
|
|
3
|
+
type: string;
|
|
4
|
+
payload?: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* SpecsWebSocketHandler — read-only-ish browser of persisted SDD specs and their
|
|
8
|
+
* task graphs, rendered as a FORGE-style dependency board (topological phase
|
|
9
|
+
* columns + dependency refs). Shared by both webui servers via specs-routes.
|
|
10
|
+
*
|
|
11
|
+
* Message types:
|
|
12
|
+
* specs.list → all specs + progress
|
|
13
|
+
* specs.get { specId } → one spec's dependency board
|
|
14
|
+
* specs.taskStatus { graphId, taskId, status } → update + rebroadcast
|
|
15
|
+
*/
|
|
16
|
+
export declare class SpecsWebSocketHandler {
|
|
17
|
+
private specStore;
|
|
18
|
+
private graphStore;
|
|
19
|
+
private clients;
|
|
20
|
+
constructor(specsDir: string, taskGraphsDir: string);
|
|
21
|
+
addClient(ws: WebSocket): void;
|
|
22
|
+
handleMessage(msg: SpecsWSMessage): Promise<void>;
|
|
23
|
+
private buildList;
|
|
24
|
+
private broadcastList;
|
|
25
|
+
private sendList;
|
|
26
|
+
private broadcastDetail;
|
|
27
|
+
private findGraphForSpec;
|
|
28
|
+
private buildDetail;
|
|
29
|
+
private updateTaskStatus;
|
|
30
|
+
private broadcast;
|
|
31
|
+
private send;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=specs-ws-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specs-ws-handler.d.ts","sourceRoot":"","sources":["../../src/server/specs-ws-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAcpC,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAgBD;;;;;;;;;GASG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,OAAO,CAAuB;IAEtC,YAAY,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAGlD;IAED,SAAS,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,CAM7B;IAEK,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBtD;YAIa,SAAS;YAiBT,aAAa;YAIb,QAAQ;YAMR,eAAe;YAUf,gBAAgB;IAM9B,OAAO,CAAC,WAAW;YAuEL,gBAAgB;IAkB9B,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,IAAI;CAGb"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Config, EventBus, Logger, SessionRegistry, SessionStore } from '@wrongstack/core';
|
|
2
|
+
import { AgentStatusTracker } from '@wrongstack/core';
|
|
3
|
+
export interface StandaloneSessionIdentityPaths {
|
|
4
|
+
globalRoot: string;
|
|
5
|
+
projectRoot: string;
|
|
6
|
+
projectSlug: string;
|
|
7
|
+
projectSessions: string;
|
|
8
|
+
}
|
|
9
|
+
export interface StandaloneSessionIdentityOptions {
|
|
10
|
+
config: Config;
|
|
11
|
+
events: EventBus;
|
|
12
|
+
logger: Logger;
|
|
13
|
+
paths: StandaloneSessionIdentityPaths;
|
|
14
|
+
workingDir: string;
|
|
15
|
+
initialSessionId: string;
|
|
16
|
+
sessionStore?: SessionStore | undefined;
|
|
17
|
+
sessionRegistry?: SessionRegistry | undefined;
|
|
18
|
+
/** Embedded hosts can keep ownership of their existing recovery lock. */
|
|
19
|
+
manageRecoveryLock?: boolean | undefined;
|
|
20
|
+
/** Test/embedding escape hatch; production defaults to enabled. */
|
|
21
|
+
enableHqTelemetry?: boolean | undefined;
|
|
22
|
+
}
|
|
23
|
+
export interface StandaloneSessionIdentityLifecycle {
|
|
24
|
+
readonly statusTracker: AgentStatusTracker | undefined;
|
|
25
|
+
activate(sessionId: string): Promise<void>;
|
|
26
|
+
stop(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Own the cross-surface identity associated with the standalone WebUI's live
|
|
30
|
+
* session writer. Session routes call {@link activate} after swapping writers;
|
|
31
|
+
* shutdown calls {@link stop}. Transitions are serialized and every optional
|
|
32
|
+
* external surface is fail-soft, while identity selection itself stays live.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createStandaloneSessionIdentityLifecycle(opts: StandaloneSessionIdentityOptions): Promise<StandaloneSessionIdentityLifecycle>;
|
|
35
|
+
//# sourceMappingURL=standalone-session-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standalone-session-identity.d.ts","sourceRoot":"","sources":["../../src/server/standalone-session-identity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EACL,kBAAkB,EAInB,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,8BAA8B;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gCAAgC;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,8BAA8B,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,eAAe,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;IAC9C,yEAAyE;IACzE,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzC,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACzC;AAED,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,aAAa,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACvD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAsB,wCAAwC,CAC5D,IAAI,EAAE,gCAAgC,GACrC,OAAO,CAAC,kCAAkC,CAAC,CAqL7C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { WebUIOptions } from './types.js';
|
|
2
|
+
export declare function startWebUI(opts?: WebUIOptions & {
|
|
3
|
+
wsPort?: number | undefined;
|
|
4
|
+
wsHost?: string | undefined;
|
|
5
|
+
httpPort?: number | undefined;
|
|
6
|
+
accessToken?: string | undefined;
|
|
7
|
+
publicUrl?: string | undefined;
|
|
8
|
+
publicWsUrl?: string | undefined;
|
|
9
|
+
requireToken?: boolean | undefined;
|
|
10
|
+
open?: boolean | undefined;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Webui-side mailbox bridge discovery.
|
|
14
|
+
*
|
|
15
|
+
* The webui doesn't spawn a bridge — the bridge (`wstack mailbox serve`)
|
|
16
|
+
* is spawned by any CLI surface via the auto-bootstrap wiring. We just
|
|
17
|
+
* probe the per-project lock for an already-running instance and stash
|
|
18
|
+
* the discovered handle on `ctx.meta['mailboxBridge']` so any later
|
|
19
|
+
* code (the `/mailbox` HTTP surface, agent-status broadcasters,
|
|
20
|
+
* external-agent proxy) can find it without re-running discovery.
|
|
21
|
+
*
|
|
22
|
+
* If no bridge is running, we log a breadcrumb so the user knows
|
|
23
|
+
* to start one (`wstack --repl`, `wstack --webui`, or
|
|
24
|
+
* `wstack mailbox serve` standalone).
|
|
25
|
+
*
|
|
26
|
+
* Best-effort: never throws. A failure (missing lock dir, ENOENT,
|
|
27
|
+
* etc.) logs at warn level and returns — the webui keeps running.
|
|
28
|
+
*/
|
|
29
|
+
//# sourceMappingURL=start-webui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-webui.d.ts","sourceRoot":"","sources":["../../src/server/start-webui.ts"],"names":[],"mappings":"AAgEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,UAAU,CAC9B,IAAI,GAAE,YAAY,GAAG;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACvB,GACL,OAAO,CAAC,IAAI,CAAC,CA4hBf;AAED;;;;;;;;;;;;;;;;GAgBG"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { WebSocket } from 'ws';
|
|
2
|
+
import type { Logger } from '@wrongstack/core';
|
|
3
|
+
/** Loose inbound shape — matches the server's internal WSClientMessage. */
|
|
4
|
+
type IncomingMessage = {
|
|
5
|
+
type: string;
|
|
6
|
+
payload?: unknown;
|
|
7
|
+
};
|
|
8
|
+
type PtyExit = {
|
|
9
|
+
exitCode: number;
|
|
10
|
+
signal?: number | undefined;
|
|
11
|
+
};
|
|
12
|
+
interface PtyProcess {
|
|
13
|
+
readonly pid?: number | undefined;
|
|
14
|
+
write(data: string): void;
|
|
15
|
+
resize(cols: number, rows: number): void;
|
|
16
|
+
kill(): void;
|
|
17
|
+
onData(cb: (data: string) => void): unknown;
|
|
18
|
+
onExit(cb: (event: PtyExit) => void): unknown;
|
|
19
|
+
}
|
|
20
|
+
interface NodePtyApi {
|
|
21
|
+
spawn(file: string, args: string[], opts: {
|
|
22
|
+
name: string;
|
|
23
|
+
cols: number;
|
|
24
|
+
rows: number;
|
|
25
|
+
cwd: string;
|
|
26
|
+
env: Record<string, string | undefined>;
|
|
27
|
+
useConptyDll?: boolean | undefined;
|
|
28
|
+
}): PtyProcess;
|
|
29
|
+
}
|
|
30
|
+
type LoadNodePty = () => NodePtyApi | null;
|
|
31
|
+
type KillProcessTree = (pid: number) => void;
|
|
32
|
+
/**
|
|
33
|
+
* TerminalWebSocketHandler — backs the WebUI's integrated terminal panel.
|
|
34
|
+
*
|
|
35
|
+
* Mirrors the lifecycle shape of WorktreeWebSocketHandler but is *per-client*
|
|
36
|
+
* and *interactive*: each connected WebSocket owns a map of real node-pty
|
|
37
|
+
* sessions keyed by a client-chosen id. Browser xterm.js ⇄ pty wiring:
|
|
38
|
+
* - `terminal.create` → spawn a shell pty, stream its output back
|
|
39
|
+
* - `terminal.input` → write keystrokes to the pty
|
|
40
|
+
* - `terminal.resize` → propagate xterm's fit dimensions
|
|
41
|
+
* - `terminal.close` → kill the pty
|
|
42
|
+
* When a client disconnects, every pty it owns is killed (no orphan shells).
|
|
43
|
+
*/
|
|
44
|
+
export declare class TerminalWebSocketHandler {
|
|
45
|
+
/** Resolves the cwd new terminals open in — tracks the live working dir. */
|
|
46
|
+
private readonly getCwd;
|
|
47
|
+
private readonly logger;
|
|
48
|
+
private readonly loadNodePty;
|
|
49
|
+
private readonly killProcessTree;
|
|
50
|
+
/** ws → (terminalId → pty). */
|
|
51
|
+
private readonly sessions;
|
|
52
|
+
constructor(
|
|
53
|
+
/** Resolves the cwd new terminals open in — tracks the live working dir. */
|
|
54
|
+
getCwd: () => string, logger: Logger, loadNodePty?: LoadNodePty, killProcessTree?: KillProcessTree);
|
|
55
|
+
addClient(ws: WebSocket): void;
|
|
56
|
+
/** Kill every pty owned by every client (server shutdown). */
|
|
57
|
+
dispose(): void;
|
|
58
|
+
/** True if this message was a terminal.* message (handled here). */
|
|
59
|
+
handleMessage(ws: WebSocket, msg: IncomingMessage): boolean;
|
|
60
|
+
private create;
|
|
61
|
+
private input;
|
|
62
|
+
private resize;
|
|
63
|
+
private close;
|
|
64
|
+
private disposeClient;
|
|
65
|
+
private killPty;
|
|
66
|
+
private killWindowsProcessTree;
|
|
67
|
+
private send;
|
|
68
|
+
}
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=terminal-ws-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-ws-handler.d.ts","sourceRoot":"","sources":["../../src/server/terminal-ws-handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI/C,2EAA2E;AAC3E,KAAK,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAC3D,KAAK,OAAO,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AACjE,UAAU,UAAU;IAClB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,IAAI,IAAI,IAAI,CAAC;IACb,MAAM,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC;IAC5C,MAAM,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC;CAC/C;AACD,UAAU,UAAU;IAClB,KAAK,CACH,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;QACxC,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KACpC,GACA,UAAU,CAAC;CACf;AACD,KAAK,WAAW,GAAG,MAAM,UAAU,GAAG,IAAI,CAAC;AAC3C,KAAK,eAAe,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;AAS7C;;;;;;;;;;;GAWG;AACH,qBAAa,wBAAwB;IAKjC,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe;IARlC,+BAA+B;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiD;IAE1E;IACE,4EAA4E;IAC3D,MAAM,EAAE,MAAM,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,WAAW,GAAE,WAAgC,EAC7C,eAAe,GAAE,eAAwC,EACxE;IAEJ,SAAS,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,CAI7B;IAED,8DAA8D;IAC9D,OAAO,IAAI,IAAI,CAEd;IAED,oEAAoE;IACpE,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAmB1D;IAID,OAAO,CAAC,MAAM;IAgEd,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,MAAM;IAUd,OAAO,CAAC,KAAK;IAQb,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,OAAO;IAYf,OAAO,CAAC,sBAAsB;IAkB9B,OAAO,CAAC,IAAI;CAOb"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-section context-window token estimate for the `context.debug` command.
|
|
3
|
+
*
|
|
4
|
+
* Uses the simple 4-chars-per-token heuristic — not exact, but close enough to
|
|
5
|
+
* spot which section (system prompt, tool schemas, or message history) is
|
|
6
|
+
* eating the context window. Tool schemas in particular are easy to overlook:
|
|
7
|
+
* each tool ships its full JSON schema to the model every turn, so 20+ builtins
|
|
8
|
+
* can cost 10-20k tokens on their own.
|
|
9
|
+
*
|
|
10
|
+
* Extracted from `index.ts` as a pure function so the breakdown maths can be
|
|
11
|
+
* unit tested without standing up a Context/ToolRegistry.
|
|
12
|
+
*/
|
|
13
|
+
/** 4-chars-per-token heuristic estimate for a string. */
|
|
14
|
+
export declare function estimateTokens(s: string): number;
|
|
15
|
+
/** Stringify arbitrary content for length estimation (JSON, with fallbacks). */
|
|
16
|
+
export declare function stringifyContent(c: unknown): string;
|
|
17
|
+
interface PromptBlock {
|
|
18
|
+
text?: string | undefined;
|
|
19
|
+
}
|
|
20
|
+
interface ToolLike {
|
|
21
|
+
name: string;
|
|
22
|
+
inputSchema?: unknown | undefined;
|
|
23
|
+
description?: string | undefined;
|
|
24
|
+
}
|
|
25
|
+
interface MessageLike {
|
|
26
|
+
role: string;
|
|
27
|
+
content: unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface ToolTokenEntry {
|
|
30
|
+
name: string;
|
|
31
|
+
tokens: number;
|
|
32
|
+
}
|
|
33
|
+
export interface MessageTokenEntry {
|
|
34
|
+
index: number;
|
|
35
|
+
role: string;
|
|
36
|
+
tokens: number;
|
|
37
|
+
preview: string;
|
|
38
|
+
}
|
|
39
|
+
export interface ContextBreakdown {
|
|
40
|
+
total: number;
|
|
41
|
+
systemPrompt: number;
|
|
42
|
+
tools: {
|
|
43
|
+
total: number;
|
|
44
|
+
count: number;
|
|
45
|
+
breakdown: ToolTokenEntry[];
|
|
46
|
+
};
|
|
47
|
+
messages: {
|
|
48
|
+
total: number;
|
|
49
|
+
count: number;
|
|
50
|
+
breakdown: MessageTokenEntry[];
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export declare function messageTokens(content: unknown): number;
|
|
54
|
+
export declare function messagePreview(content: unknown): string;
|
|
55
|
+
/**
|
|
56
|
+
* Compute the per-section token breakdown for the active context. Mirrors the
|
|
57
|
+
* shape the `context.debug` WS reply expects (minus the `mode`/`policy` fields,
|
|
58
|
+
* which the caller layers on from `context.meta`).
|
|
59
|
+
*/
|
|
60
|
+
export declare function estimateContextBreakdown(input: {
|
|
61
|
+
systemPrompt: ReadonlyArray<PromptBlock>;
|
|
62
|
+
tools: ReadonlyArray<ToolLike>;
|
|
63
|
+
messages: ReadonlyArray<MessageLike>;
|
|
64
|
+
}): ContextBreakdown;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=token-estimator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-estimator.d.ts","sourceRoot":"","sources":["../../src/server/token-estimator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,yDAAyD;AACzD,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAOnD;AAED,UAAU,WAAW;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AACD,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAQD,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,cAAc,EAAE,CAAA;KAAE,CAAC;IACrE,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,iBAAiB,EAAE,CAAA;KAAE,CAAC;CAC5E;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAWtD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAevD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACzC,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/B,QAAQ,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CACtC,GAAG,gBAAgB,CA4BnB"}
|