@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.
Files changed (176) hide show
  1. package/dist/index.d.ts +11 -2300
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +1807 -539
  4. package/dist/index.js.map +7 -1
  5. package/dist/server/autophase-routes.d.ts +10 -0
  6. package/dist/server/autophase-routes.d.ts.map +1 -0
  7. package/dist/server/autophase-ws-handler.d.ts +87 -0
  8. package/dist/server/autophase-ws-handler.d.ts.map +1 -0
  9. package/dist/server/backend-services.d.ts +103 -0
  10. package/dist/server/backend-services.d.ts.map +1 -0
  11. package/dist/server/boot.d.ts +19 -0
  12. package/dist/server/boot.d.ts.map +1 -0
  13. package/dist/server/brain-routes.d.ts +11 -0
  14. package/dist/server/brain-routes.d.ts.map +1 -0
  15. package/dist/server/codebase-indexing.d.ts +15 -0
  16. package/dist/server/codebase-indexing.d.ts.map +1 -0
  17. package/dist/server/collaboration-ws-handler.d.ts +167 -0
  18. package/dist/server/collaboration-ws-handler.d.ts.map +1 -0
  19. package/dist/server/completion-handlers.d.ts +39 -0
  20. package/dist/server/completion-handlers.d.ts.map +1 -0
  21. package/dist/server/connection-handler.d.ts +72 -0
  22. package/dist/server/connection-handler.d.ts.map +1 -0
  23. package/dist/server/context-meta.d.ts +28 -0
  24. package/dist/server/context-meta.d.ts.map +1 -0
  25. package/dist/server/custom-context-modes.d.ts +43 -0
  26. package/dist/server/custom-context-modes.d.ts.map +1 -0
  27. package/dist/server/design-handlers.d.ts +40 -0
  28. package/dist/server/design-handlers.d.ts.map +1 -0
  29. package/dist/server/discover-mailbox-bridge.d.ts +26 -0
  30. package/dist/server/discover-mailbox-bridge.d.ts.map +1 -0
  31. package/dist/server/entry.d.ts +2 -2
  32. package/dist/server/entry.d.ts.map +1 -0
  33. package/dist/server/entry.js +1595 -562
  34. package/dist/server/entry.js.map +7 -1
  35. package/dist/server/eternal-iteration-broadcast.d.ts +11 -0
  36. package/dist/server/eternal-iteration-broadcast.d.ts.map +1 -0
  37. package/dist/server/file-handlers.d.ts +45 -0
  38. package/dist/server/file-handlers.d.ts.map +1 -0
  39. package/dist/server/file-picker.d.ts +26 -0
  40. package/dist/server/file-picker.d.ts.map +1 -0
  41. package/dist/server/git-handlers.d.ts +55 -0
  42. package/dist/server/git-handlers.d.ts.map +1 -0
  43. package/dist/server/goal-handlers.d.ts +19 -0
  44. package/dist/server/goal-handlers.d.ts.map +1 -0
  45. package/dist/server/handlers/index.d.ts +12 -0
  46. package/dist/server/handlers/index.d.ts.map +1 -0
  47. package/dist/server/handlers/worklist-handlers.d.ts +49 -0
  48. package/dist/server/handlers/worklist-handlers.d.ts.map +1 -0
  49. package/dist/server/handlers.d.ts +1 -51
  50. package/dist/server/handlers.js +17 -8
  51. package/dist/server/handlers.js.map +7 -1
  52. package/dist/server/http-server/analytics-handler.d.ts +35 -0
  53. package/dist/server/http-server/analytics-handler.d.ts.map +1 -0
  54. package/dist/server/http-server/api-handlers.d.ts +44 -0
  55. package/dist/server/http-server/api-handlers.d.ts.map +1 -0
  56. package/dist/server/http-server.d.ts +108 -0
  57. package/dist/server/http-server.d.ts.map +1 -0
  58. package/dist/server/index.d.ts +93 -0
  59. package/dist/server/index.d.ts.map +1 -0
  60. package/dist/server/instance-registry.d.ts +63 -0
  61. package/dist/server/instance-registry.d.ts.map +1 -0
  62. package/dist/server/kanban-routes.d.ts +7 -0
  63. package/dist/server/kanban-routes.d.ts.map +1 -0
  64. package/dist/server/lifecycle.d.ts +51 -0
  65. package/dist/server/lifecycle.d.ts.map +1 -0
  66. package/dist/server/mailbox-handlers.d.ts +63 -0
  67. package/dist/server/mailbox-handlers.d.ts.map +1 -0
  68. package/dist/server/mailbox-routes.d.ts +11 -0
  69. package/dist/server/mailbox-routes.d.ts.map +1 -0
  70. package/dist/server/mcp-handlers.d.ts +55 -0
  71. package/dist/server/mcp-handlers.d.ts.map +1 -0
  72. package/dist/server/mcp-routes.d.ts +41 -0
  73. package/dist/server/mcp-routes.d.ts.map +1 -0
  74. package/dist/server/memory-handlers.d.ts +28 -0
  75. package/dist/server/memory-handlers.d.ts.map +1 -0
  76. package/dist/server/message-dispatcher.d.ts +41 -0
  77. package/dist/server/message-dispatcher.d.ts.map +1 -0
  78. package/dist/server/mode-handlers.d.ts +50 -0
  79. package/dist/server/mode-handlers.d.ts.map +1 -0
  80. package/dist/server/mode-routes.d.ts +8 -0
  81. package/dist/server/mode-routes.d.ts.map +1 -0
  82. package/dist/server/model-auto-discovery.d.ts +9 -0
  83. package/dist/server/model-auto-discovery.d.ts.map +1 -0
  84. package/dist/server/model-catalog.d.ts +16 -0
  85. package/dist/server/model-catalog.d.ts.map +1 -0
  86. package/dist/server/open-browser.d.ts +16 -0
  87. package/dist/server/open-browser.d.ts.map +1 -0
  88. package/dist/server/path-containment.d.ts +3 -0
  89. package/dist/server/path-containment.d.ts.map +1 -0
  90. package/dist/server/pending-confirms.d.ts +14 -0
  91. package/dist/server/pending-confirms.d.ts.map +1 -0
  92. package/dist/server/port-utils.d.ts +28 -0
  93. package/dist/server/port-utils.d.ts.map +1 -0
  94. package/dist/server/pre-context-services.d.ts +60 -0
  95. package/dist/server/pre-context-services.d.ts.map +1 -0
  96. package/dist/server/pref-helpers.d.ts +43 -0
  97. package/dist/server/pref-helpers.d.ts.map +1 -0
  98. package/dist/server/prefs-routes.d.ts +27 -0
  99. package/dist/server/prefs-routes.d.ts.map +1 -0
  100. package/dist/server/process-handlers.d.ts +20 -0
  101. package/dist/server/process-handlers.d.ts.map +1 -0
  102. package/dist/server/project-handlers.d.ts +53 -0
  103. package/dist/server/project-handlers.d.ts.map +1 -0
  104. package/dist/server/project-routes.d.ts +10 -0
  105. package/dist/server/project-routes.d.ts.map +1 -0
  106. package/dist/server/projects-manifest.d.ts +18 -0
  107. package/dist/server/projects-manifest.d.ts.map +1 -0
  108. package/dist/server/prompts-handlers.d.ts +38 -0
  109. package/dist/server/prompts-handlers.d.ts.map +1 -0
  110. package/dist/server/provider-config-io.d.ts +15 -0
  111. package/dist/server/provider-config-io.d.ts.map +1 -0
  112. package/dist/server/provider-config-standalone.d.ts +13 -0
  113. package/dist/server/provider-config-standalone.d.ts.map +1 -0
  114. package/dist/server/provider-handlers.d.ts +74 -0
  115. package/dist/server/provider-handlers.d.ts.map +1 -0
  116. package/dist/server/provider-keys.d.ts +53 -0
  117. package/dist/server/provider-keys.d.ts.map +1 -0
  118. package/dist/server/provider-routes.d.ts +13 -0
  119. package/dist/server/provider-routes.d.ts.map +1 -0
  120. package/dist/server/provider-store.d.ts +26 -0
  121. package/dist/server/provider-store.d.ts.map +1 -0
  122. package/dist/server/routes.d.ts +187 -0
  123. package/dist/server/routes.d.ts.map +1 -0
  124. package/dist/server/sdd-board-routes.d.ts +11 -0
  125. package/dist/server/sdd-board-routes.d.ts.map +1 -0
  126. package/dist/server/sdd-board-ws-handler.d.ts +57 -0
  127. package/dist/server/sdd-board-ws-handler.d.ts.map +1 -0
  128. package/dist/server/sdd-wizard-routes.d.ts +16 -0
  129. package/dist/server/sdd-wizard-routes.d.ts.map +1 -0
  130. package/dist/server/sdd-wizard-wiring.d.ts +26 -0
  131. package/dist/server/sdd-wizard-wiring.d.ts.map +1 -0
  132. package/dist/server/sdd-wizard-ws-handler.d.ts +66 -0
  133. package/dist/server/sdd-wizard-ws-handler.d.ts.map +1 -0
  134. package/dist/server/server-runtime.d.ts +118 -0
  135. package/dist/server/server-runtime.d.ts.map +1 -0
  136. package/dist/server/session-handlers.d.ts +57 -0
  137. package/dist/server/session-handlers.d.ts.map +1 -0
  138. package/dist/server/session-routes.d.ts +23 -0
  139. package/dist/server/session-routes.d.ts.map +1 -0
  140. package/dist/server/setup-events.d.ts +67 -0
  141. package/dist/server/setup-events.d.ts.map +1 -0
  142. package/dist/server/setup-screen.d.ts +44 -0
  143. package/dist/server/setup-screen.d.ts.map +1 -0
  144. package/dist/server/shell-git-routes.d.ts +10 -0
  145. package/dist/server/shell-git-routes.d.ts.map +1 -0
  146. package/dist/server/shell-open.d.ts +12 -0
  147. package/dist/server/shell-open.d.ts.map +1 -0
  148. package/dist/server/skills-handlers.d.ts +77 -0
  149. package/dist/server/skills-handlers.d.ts.map +1 -0
  150. package/dist/server/specs-routes.d.ts +11 -0
  151. package/dist/server/specs-routes.d.ts.map +1 -0
  152. package/dist/server/specs-ws-handler.d.ts +34 -0
  153. package/dist/server/specs-ws-handler.d.ts.map +1 -0
  154. package/dist/server/standalone-session-identity.d.ts +35 -0
  155. package/dist/server/standalone-session-identity.d.ts.map +1 -0
  156. package/dist/server/start-webui.d.ts +29 -0
  157. package/dist/server/start-webui.d.ts.map +1 -0
  158. package/dist/server/terminal-ws-handler.d.ts +70 -0
  159. package/dist/server/terminal-ws-handler.d.ts.map +1 -0
  160. package/dist/server/token-estimator.d.ts +66 -0
  161. package/dist/server/token-estimator.d.ts.map +1 -0
  162. package/dist/server/types.d.ts +143 -0
  163. package/dist/server/types.d.ts.map +1 -0
  164. package/dist/server/usage-cost.d.ts +39 -0
  165. package/dist/server/usage-cost.d.ts.map +1 -0
  166. package/dist/server/worktree-ws-handler.d.ts +67 -0
  167. package/dist/server/worktree-ws-handler.d.ts.map +1 -0
  168. package/dist/server/ws-auth.d.ts +83 -0
  169. package/dist/server/ws-auth.d.ts.map +1 -0
  170. package/dist/server/ws-payload-validation.d.ts +126 -0
  171. package/dist/server/ws-payload-validation.d.ts.map +1 -0
  172. package/dist/server/ws-utils.d.ts +38 -0
  173. package/dist/server/ws-utils.d.ts.map +1 -0
  174. package/dist/server/zip.d.ts +9 -0
  175. package/dist/server/zip.d.ts.map +1 -0
  176. package/package.json +11 -12
@@ -0,0 +1,10 @@
1
+ import type { WebSocket } from 'ws';
2
+ import type { WSClientMessage } from './types.js';
3
+ export interface AutoPhaseRouteHandlers {
4
+ handleMessage: (msg: {
5
+ type: string;
6
+ payload?: Record<string, unknown>;
7
+ }) => Promise<void>;
8
+ }
9
+ export declare function handleAutoPhaseRoute(_ws: WebSocket, msg: WSClientMessage, handlers: AutoPhaseRouteHandlers): Promise<boolean>;
10
+ //# sourceMappingURL=autophase-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autophase-routes.d.ts","sourceRoot":"","sources":["../../src/server/autophase-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,sBAAsB;IACrC,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,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,SAAS,EACd,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,sBAAsB,GAC/B,OAAO,CAAC,OAAO,CAAC,CAIlB"}
@@ -0,0 +1,87 @@
1
+ import type { WebSocket } from 'ws';
2
+ import type { Agent, Context, EventBus, Logger } from '@wrongstack/core';
3
+ interface AutoPhaseWSMessage {
4
+ type: string;
5
+ payload?: Record<string, unknown>;
6
+ }
7
+ /**
8
+ * AutoPhaseWebSocketHandler — WebSocket-based AutoPhase control.
9
+ *
10
+ * Message types:
11
+ * autophase.start → { title, phases?, autonomous? }
12
+ * autophase.pause → {}
13
+ * autophase.resume → {}
14
+ * autophase.stop → {}
15
+ * autophase.status → {}
16
+ * autophase.selectPhase → { phaseId }
17
+ * autophase.taskStatus → { taskId, status }
18
+ */
19
+ export declare class AutoPhaseWebSocketHandler {
20
+ private agent;
21
+ private context;
22
+ private logger;
23
+ private events?;
24
+ private projectRoot?;
25
+ private orchestrator;
26
+ private graph;
27
+ private store;
28
+ private clients;
29
+ private broadcastInterval;
30
+ /** Aborts in-flight task agents AND the planning turn when the run is stopped. */
31
+ private abort;
32
+ /** Set the instant a stop/clear/revert is requested, so a planning turn that
33
+ * resolves afterwards never launches the orchestrator (the abort alone can't
34
+ * cover the window between the LLM call resolving and the orchestrator start). */
35
+ private stopping;
36
+ /** Optional per-phase git-worktree isolation (lazily created at start). */
37
+ private worktrees;
38
+ /** Base branch + tip SHA captured at run start so a revert can git-revert the
39
+ * run's squash commits (history-preserving) instead of a destructive reset. */
40
+ private runBase;
41
+ /** Per-run worker identities so the board can show "who is on what". */
42
+ private usedNicknames;
43
+ constructor(agent: Agent, context: Context, logger: Logger, storeDir: string, events?: EventBus | undefined, projectRoot?: string | undefined);
44
+ addClient(ws: WebSocket): void;
45
+ handleMessage(msg: AutoPhaseWSMessage): Promise<void>;
46
+ private handleStart;
47
+ /**
48
+ * Halt the run NOW — at any phase. Sets `stopping` (so a planning turn that
49
+ * resolves afterwards bails), aborts in-flight agents, stops the orchestrator
50
+ * tick, and ends the live broadcast. The board is kept for review; use
51
+ * `autophase.clear` to reset or `autophase.revert` to undo the changes.
52
+ */
53
+ private handleStop;
54
+ /**
55
+ * Stop + wipe: tear down phase worktrees and reset to an empty board so the UI
56
+ * returns to the start screen ("new one"). Does NOT touch already-merged commits
57
+ * on the base branch — that is `autophase.revert`.
58
+ */
59
+ private handleClear;
60
+ /**
61
+ * Stop + undo: remove phase worktrees, then history-preservingly `git revert`
62
+ * every commit this run landed on the base branch (captured `runBase`..HEAD),
63
+ * then reset to an empty board. Refuses (reports a reason) on a dirty tree or a
64
+ * conflicting revert rather than leaving the tree half-reverted.
65
+ */
66
+ private handleRevert;
67
+ /** Generic fallback phases when the LLM planner produces nothing usable. */
68
+ private defaultPhases;
69
+ /** Plan phases+todos for the goal via the LLM; fall back to defaults on failure.
70
+ * The caller passes the run's abort signal so a stop during planning cancels
71
+ * the LLM turn (the previous fresh, never-aborted controller made planning
72
+ * uninterruptible). */
73
+ private planPhases;
74
+ private executeTaskWithAgent;
75
+ /** Persist + broadcast after an interactive board mutation. */
76
+ private afterBoardMutation;
77
+ private handleTaskStatusChange;
78
+ private startBroadcast;
79
+ private stopBroadcast;
80
+ private broadcastState;
81
+ private buildState;
82
+ private sendState;
83
+ private broadcast;
84
+ private send;
85
+ }
86
+ export {};
87
+ //# sourceMappingURL=autophase-ws-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autophase-ws-handler.d.ts","sourceRoot":"","sources":["../../src/server/autophase-ws-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAYpC,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAoDzE,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,yBAAyB;IAqBlC,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM;IAEd,OAAO,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,WAAW,CAAC;IAzBtB,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,iBAAiB,CAA+C;IACxE,kFAAkF;IAClF,OAAO,CAAC,KAAK,CAAgC;IAC7C;;uFAEmF;IACnF,OAAO,CAAC,QAAQ,CAAS;IACzB,2EAA2E;IAC3E,OAAO,CAAC,SAAS,CAAgC;IACjD;oFACgF;IAChF,OAAO,CAAC,OAAO,CAAgD;IAC/D,wEAAwE;IACxE,OAAO,CAAC,aAAa,CAAqB;IAE1C,YACU,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,EACR,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,EAC7B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,EAGzC;IAED,SAAS,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,CAS7B;IAEK,aAAa,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyG1D;YAEa,WAAW;IAwIzB;;;;;OAKG;YACW,UAAU;IASxB;;;;OAIG;YACW,WAAW;IAYzB;;;;;OAKG;YACW,YAAY;IAsB1B,4EAA4E;IAC5E,OAAO,CAAC,aAAa;IAUrB;;;4BAGwB;YACV,UAAU;YA2BV,oBAAoB;IA+BlC,+DAA+D;IAC/D,OAAO,CAAC,kBAAkB;YAKZ,sBAAsB;IAcpC,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,UAAU;IAqGlB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,IAAI;CAKb"}
@@ -0,0 +1,103 @@
1
+ import type { AutoCompactionMiddleware, BrainAutoRisk, CollaborationBus, Compactor, Context, MemoryStore, DefaultModeStore, EventBus, Logger, ModelsRegistry, ObservableBrainArbiter, PermissionPolicy, Provider, ProviderRegistry, SessionStore, SkillInstaller, SkillLoader, ToolRegistry, AgentPipelines, Container, SessionReader } from '@wrongstack/core';
2
+ import type { DefaultTokenCounter } from '@wrongstack/core/infrastructure';
3
+ /** Session shape returned by `SessionStore.create()`. */
4
+ type Session = Awaited<ReturnType<SessionStore['create']>>;
5
+ import { Agent, BrainMonitor, BrainDecisionLedger, type BrainRuntime, ToolExecutor, type AnnotationsStore } from '@wrongstack/core';
6
+ import type { MCPRegistry } from '@wrongstack/mcp';
7
+ import { AutoPhaseWebSocketHandler } from './autophase-ws-handler.js';
8
+ import { CollaborationWebSocketHandler } from './collaboration-ws-handler.js';
9
+ import { SddBoardWebSocketHandler } from './sdd-board-ws-handler.js';
10
+ import { SddWizardWebSocketHandler } from './sdd-wizard-ws-handler.js';
11
+ import { SpecsWebSocketHandler } from './specs-ws-handler.js';
12
+ import { TerminalWebSocketHandler } from './terminal-ws-handler.js';
13
+ import { WorktreeWebSocketHandler } from './worktree-ws-handler.js';
14
+ import type { Config, ProviderConfig } from '@wrongstack/core/types';
15
+ import type { WstackPaths } from '@wrongstack/core/utils';
16
+ export interface AgentServicesInput {
17
+ config: Config;
18
+ wpaths: WstackPaths;
19
+ logger: Logger;
20
+ projectRoot: string;
21
+ workingDir: string;
22
+ /** Pre-context services (built in startWebUI with opts.services injection). */
23
+ context: Context;
24
+ provider: Provider;
25
+ container: Container;
26
+ toolRegistry: ToolRegistry;
27
+ providerRegistry: ProviderRegistry;
28
+ modelsRegistry: ModelsRegistry;
29
+ events: EventBus;
30
+ mcpRegistry: MCPRegistry;
31
+ memoryStore: MemoryStore;
32
+ modeStore: DefaultModeStore;
33
+ customModeStore: import('./custom-context-modes.js').CustomModeStore;
34
+ skillLoader: SkillLoader | undefined;
35
+ skillInstaller: SkillInstaller | undefined;
36
+ tokenCounter: DefaultTokenCounter;
37
+ pipelines: AgentPipelines;
38
+ /** Mutable capabilities ref — the factory populates `.current`. */
39
+ modelCapabilitiesRef: {
40
+ current: unknown;
41
+ };
42
+ /** Returns the LIVE session (swapped on /new + resume) — read at send time. */
43
+ sessionGetter: () => Session;
44
+ /** Read-only session reader (collab replay-on-join). */
45
+ sessionReader: SessionReader;
46
+ /** Annotations store (collab notes). */
47
+ annotationsStore: AnnotationsStore;
48
+ /**
49
+ * Persist the canonical `config.brain` to the GLOBAL config (serialized
50
+ * behind startWebUI's config write lock). Absent = Brain edits are
51
+ * live-only.
52
+ */
53
+ persistBrainConfig?: ((config: import('@wrongstack/core/types').BrainConfig) => Promise<void>) | undefined;
54
+ }
55
+ export interface AgentServices {
56
+ collabBus: CollaborationBus;
57
+ compactor: Compactor;
58
+ autoCompactor: AutoCompactionMiddleware | undefined;
59
+ toolExecutor: ToolExecutor;
60
+ agent: Agent;
61
+ permissionPolicy: PermissionPolicy;
62
+ pipelines: AgentPipelines;
63
+ brain: ObservableBrainArbiter;
64
+ brainSettings: {
65
+ maxAutoRisk: BrainAutoRisk;
66
+ };
67
+ /** Live-editable Brain config owner (brain.config.get/set routes). */
68
+ brainRuntime: BrainRuntime;
69
+ brainLog: Array<{
70
+ at: number;
71
+ kind: string;
72
+ question: string;
73
+ outcome: string;
74
+ }>;
75
+ brainMonitor: BrainMonitor;
76
+ /** LIVE persistent decision ledger (undefined when disabled). Read via the
77
+ * services object at shutdown — ledger toggles swap the instance. */
78
+ brainLedger: BrainDecisionLedger | undefined;
79
+ codebaseIndexing: {
80
+ onFileWritten(filePath: string): void;
81
+ dispose(): void;
82
+ };
83
+ autoPhaseHandler: AutoPhaseWebSocketHandler;
84
+ specsHandler: SpecsWebSocketHandler;
85
+ sddBoardHandler: SddBoardWebSocketHandler;
86
+ sddWizardHandler: SddWizardWebSocketHandler;
87
+ worktreeHandler: WorktreeWebSocketHandler;
88
+ terminalHandler: TerminalWebSocketHandler;
89
+ collabHandler: CollaborationWebSocketHandler;
90
+ /** Refresh auto-compaction denominator on model switch. */
91
+ updateAutoCompactionMaxContext: (newProvider: Provider, providerId?: string, providerCfg?: ProviderConfig | undefined) => Promise<void>;
92
+ }
93
+ /**
94
+ * Build the post-context agent services: pipelines + middleware, compaction,
95
+ * tool executor + agent, Brain, and the per-feature WebSocket handlers.
96
+ *
97
+ * Returns everything `startWebUI` needs to wire routes + the dispatcher.
98
+ * The `updateAutoCompactionMaxContext` closure captures the live
99
+ * `autoCompactor` / `modelCapabilitiesRef` it built.
100
+ */
101
+ export declare function createAgentServices(input: AgentServicesInput): Promise<AgentServices>;
102
+ export {};
103
+ //# sourceMappingURL=backend-services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend-services.d.ts","sourceRoot":"","sources":["../../src/server/backend-services.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAC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Ac,CAAC;IAC1B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,aAAa,EAAE;QAAE,WAAW,EAAE,aAAa,CAAA;KAAE,CAAC;IAC9C,sEAAsE;IACtE,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjF,YAAY,EAAE,YAAY,CAAC;IAC3B;0EACsE;IACtE,WAAW,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAC7C,gBAAgB,EAAE;QAAE,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,IAAI,IAAI,CAAA;KAAE,CAAC;IAC7E,gBAAgB,EAAE,yBAAyB,CAAC;IAC5C,YAAY,EAAE,qBAAqB,CAAC;IACpC,eAAe,EAAE,wBAAwB,CAAC;IAC1C,gBAAgB,EAAE,yBAAyB,CAAC;IAC5C,eAAe,EAAE,wBAAwB,CAAC;IAC1C,eAAe,EAAE,wBAAwB,CAAC;IAC1C,aAAa,EAAE,6BAA6B,CAAC;IAC7C,2DAA2D;IAC3D,8BAA8B,EAAE,CAC9B,WAAW,EAAE,QAAQ,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,cAAc,GAAG,SAAS,KACrC,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAub3F"}
@@ -0,0 +1,19 @@
1
+ import { type Config, type DefaultLogger, type DefaultSecretVault, type WstackPaths } from '@wrongstack/core';
2
+ export interface BootResult {
3
+ config: Config;
4
+ vault: DefaultSecretVault;
5
+ globalConfigPath: string;
6
+ projectRoot: string;
7
+ wpaths: WstackPaths;
8
+ logger: InstanceType<typeof DefaultLogger>;
9
+ }
10
+ /**
11
+ * Thin WebUI wrapper over the canonical `bootConfig` in `@wrongstack/core`
12
+ * (mirrors packages/cli/src/boot-config.ts). All real boot behavior — wstack
13
+ * path resolution, the AES-GCM `DefaultSecretVault`, plaintext-secret
14
+ * migration, and config load/merge — lives in core so the WebUI server and the
15
+ * CLI can't drift. Only the secret-migration notice label (`WebUI`) differs.
16
+ */
17
+ export declare function bootConfig(): Promise<BootResult>;
18
+ export declare function patchConfig(config: Config, updates: Partial<Config>): Config;
19
+ //# sourceMappingURL=boot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../../src/server/boot.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAEjB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,kBAAkB,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,YAAY,CAAC,OAAO,aAAa,CAAC,CAAC;CAC5C;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,CAKtD;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAE5E"}
@@ -0,0 +1,11 @@
1
+ import type { WebSocket } from 'ws';
2
+ import type { WSClientMessage } from './types.js';
3
+ export interface BrainRouteHandlers {
4
+ status: (ws: WebSocket, msg: WSClientMessage) => Promise<void> | void;
5
+ risk: (ws: WebSocket, msg: WSClientMessage) => Promise<void> | void;
6
+ ask: (ws: WebSocket, msg: WSClientMessage) => Promise<void> | void;
7
+ configGet: (ws: WebSocket, msg: WSClientMessage) => Promise<void> | void;
8
+ configSet: (ws: WebSocket, msg: WSClientMessage) => Promise<void> | void;
9
+ }
10
+ export declare function handleBrainRoute(ws: WebSocket, msg: WSClientMessage, handlers: BrainRouteHandlers): Promise<boolean>;
11
+ //# sourceMappingURL=brain-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brain-routes.d.ts","sourceRoot":"","sources":["../../src/server/brain-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,MAAM,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACtE,IAAI,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACpE,GAAG,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACnE,SAAS,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACzE,SAAS,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC1E;AAED,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,kBAAkB,GAC3B,OAAO,CAAC,OAAO,CAAC,CAoBlB"}
@@ -0,0 +1,15 @@
1
+ import type { Context, IndexingConfig, Logger } from '@wrongstack/core';
2
+ export interface WebUICodebaseIndexingDeps {
3
+ config: {
4
+ indexing?: IndexingConfig | undefined;
5
+ };
6
+ context: Context;
7
+ projectRoot: string;
8
+ logger: Logger;
9
+ }
10
+ export interface WebUICodebaseIndexing {
11
+ onFileWritten(filePath: string): void;
12
+ dispose(): void;
13
+ }
14
+ export declare function setupWebUICodebaseIndexing(deps: WebUICodebaseIndexingDeps): WebUICodebaseIndexing;
15
+ //# sourceMappingURL=codebase-indexing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codebase-indexing.d.ts","sourceRoot":"","sources":["../../src/server/codebase-indexing.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAqBxE,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAAA;KAAE,CAAC;IAClD,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,yBAAyB,GAC9B,qBAAqB,CAmFvB"}
@@ -0,0 +1,167 @@
1
+ import type { WebSocket } from 'ws';
2
+ import type { CollaborationBus, EventBus, Logger } from '@wrongstack/core';
3
+ import type { AnnotationsStore, SessionReader } from '@wrongstack/core/storage';
4
+ import type { CollabRole } from './types.js';
5
+ export interface CollaborationHandlerOptions {
6
+ /**
7
+ * Resolve the session currently owned by this WebUI runtime. When supplied,
8
+ * joins and live EventBus mirrors are constrained to that session.
9
+ */
10
+ getActiveSessionId?: (() => string) | undefined;
11
+ /**
12
+ * Host-owned authorization for roles that can mutate collaboration state.
13
+ * Omission is intentionally fail-closed: clients may only join as observers.
14
+ */
15
+ authorizeRole?: ((input: {
16
+ ws: WebSocket;
17
+ sessionId: string;
18
+ requestedRole: Exclude<CollabRole, 'observer'>;
19
+ }) => boolean) | undefined;
20
+ }
21
+ /**
22
+ * CollaborationWebSocketHandler — session-scoped collaboration transport.
23
+ * Mirrors `WorktreeWebSocketHandler` and `AutoPhaseWebSocketHandler`.
24
+ *
25
+ * Capabilities in this phase:
26
+ * - A second human (or any client) joins an active agent run as an
27
+ * `observer` and receives a live mirror of the kernel's iteration /
28
+ * tool / subagent events.
29
+ * - The observer declares a `sessionId` on join. Hosts provide the live
30
+ * runtime session id so replay and EventBus routing stay session-scoped.
31
+ * - The observer can leave at any time; cleanup runs on WS close/error.
32
+ * - Privileged roles are never accepted from the wire by themselves.
33
+ * The host must explicitly authorize annotator/controller grants.
34
+ *
35
+ * Protocol additions (see `packages/webui/src/types.ts`):
36
+ * client → server: collab.join { sessionId, role: 'observer' }
37
+ * collab.leave { sessionId }
38
+ * server → client: collab.state (initial + 2s periodic)
39
+ * collab.participant.joined
40
+ * collab.participant.left
41
+ * collab.event (live kernel event mirror)
42
+ */
43
+ export declare class CollaborationWebSocketHandler {
44
+ private readonly events;
45
+ private readonly logger;
46
+ /**
47
+ * Optional reader over the on-disk session log. When provided, late
48
+ * joiners receive the last `REPLAY_LIMIT` events of the joined
49
+ * session before live mirroring begins. Without a reader, joining
50
+ * is still allowed — the observer simply starts from "now" with no
51
+ * historical context.
52
+ */
53
+ private readonly reader?;
54
+ /**
55
+ * Optional sidecar store for collaboration annotations. Required
56
+ * for the `annotator` role — without it, `collab.annotate` messages
57
+ * are rejected with an error.
58
+ */
59
+ private readonly annotations?;
60
+ /**
61
+ * Optional kernel-level pause/resume bus. Required for the
62
+ * `controller` role — without it, `collab.request_pause` is rejected
63
+ * with an error. Wired to the agent's `toolCall` pipeline via
64
+ * `collabPauseMiddleware` in the webui server boot.
65
+ */
66
+ private readonly bus?;
67
+ private readonly options;
68
+ private readonly clients;
69
+ /** sessionId → participants currently watching it. */
70
+ private readonly bySession;
71
+ private broadcastInterval;
72
+ private readonly offs;
73
+ constructor(events: EventBus, logger: Logger,
74
+ /**
75
+ * Optional reader over the on-disk session log. When provided, late
76
+ * joiners receive the last `REPLAY_LIMIT` events of the joined
77
+ * session before live mirroring begins. Without a reader, joining
78
+ * is still allowed — the observer simply starts from "now" with no
79
+ * historical context.
80
+ */
81
+ reader?: SessionReader | undefined,
82
+ /**
83
+ * Optional sidecar store for collaboration annotations. Required
84
+ * for the `annotator` role — without it, `collab.annotate` messages
85
+ * are rejected with an error.
86
+ */
87
+ annotations?: AnnotationsStore | undefined,
88
+ /**
89
+ * Optional kernel-level pause/resume bus. Required for the
90
+ * `controller` role — without it, `collab.request_pause` is rejected
91
+ * with an error. Wired to the agent's `toolCall` pipeline via
92
+ * `collabPauseMiddleware` in the webui server boot.
93
+ */
94
+ bus?: CollaborationBus | undefined, options?: CollaborationHandlerOptions);
95
+ addClient(ws: WebSocket): void;
96
+ dispose(): void;
97
+ /**
98
+ * Dispatch a parsed client message. Returns true when the message was
99
+ * recognized and handled; false when the caller should ignore / log.
100
+ * Phase 1 only knows `collab.join` and `collab.leave`; unknown types
101
+ * return false so the upstream router can decide.
102
+ */
103
+ handleMessage(ws: WebSocket, msg: {
104
+ type: string;
105
+ payload?: unknown | undefined;
106
+ }): boolean;
107
+ private join;
108
+ private leave;
109
+ private handleDisconnect;
110
+ /**
111
+ * Look up the participant record for a given WS across all sessions.
112
+ * Returns null when the WS hasn't joined (e.g. the client sent a
113
+ * `collab.annotate` before `collab.join`).
114
+ */
115
+ private findParticipant;
116
+ private findParticipantById;
117
+ private handleAnnotate;
118
+ private handleResolve;
119
+ private subscribe;
120
+ private broadcastEvent;
121
+ /**
122
+ * Replay the last `REPLAY_LIMIT` events from the on-disk session log
123
+ * to a single observer (the late joiner). Each event is forwarded as
124
+ * a `collab.event` with `replay: true` so the client can distinguish
125
+ * history from the live stream.
126
+ *
127
+ * The session log stores typed `SessionEvent`s (`user_input`,
128
+ * `llm_response`, `tool_result`, etc.) — different from the kernel's
129
+ * bus events. We translate the most useful subset (`tool.*` and
130
+ * `iteration.*`-shaped ones) into the same `kind` namespace the live
131
+ * mirror uses, so the client can render a single activity strip.
132
+ */
133
+ private replayHistory;
134
+ /**
135
+ * Map a stored `SessionEvent` to a `collab.event.kind` so the live
136
+ * strip and the history strip can share a single rendering path.
137
+ * Returns null for events that don't have a meaningful live analog
138
+ * (e.g. `session_start`, file-snapshot bookkeeping, rewind markers).
139
+ */
140
+ private historyEventToKind;
141
+ private stateMessage;
142
+ private ensureBroadcast;
143
+ private stopBroadcast;
144
+ private broadcast;
145
+ private send;
146
+ private errorMessage;
147
+ private handleRequestPause;
148
+ private handleResume;
149
+ private handleGrantControl;
150
+ /**
151
+ * Phase 4 — handle a controller's manual tool-call injection.
152
+ * Validates the payload, queues it on the bus, and broadcasts
153
+ * the grant so observers see what just happened. The actual
154
+ * splice into the agent's pipeline is performed by the
155
+ * `collabInjectMiddleware` on the next tool call.
156
+ */
157
+ private handleInjectTool;
158
+ /**
159
+ * Bus callback: a queued injection was spliced into a real tool call. Re-emit
160
+ * `collab.injection.granted` with phase `'consumed'` and the now-known tool
161
+ * name. The injection carries no sessionId, so resolve it from the author's
162
+ * current participant. If the author has left, fail closed rather than leak
163
+ * the payload to unrelated sessions.
164
+ */
165
+ private broadcastInjectionConsumed;
166
+ }
167
+ //# sourceMappingURL=collaboration-ws-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collaboration-ws-handler.d.ts","sourceRoot":"","sources":["../../src/server/collaboration-ws-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAyB,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEhF,OAAO,KAA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;IAED,OAAO,IAAI,IAAI,CAId;IAID;;;;;OAKG;IACH,aAAa,CACX,EAAE,EAAE,SAAS,EACb,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;KAAE,GACnD,OAAO,CA4CT;IAID,OAAO,CAAC,IAAI;IA2FZ,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,gBAAgB;IAwCxB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,mBAAmB;YASb,cAAc;YA4Ed,aAAa;IA0E3B,OAAO,CAAC,SAAS;IA6CjB,OAAO,CAAC,cAAc;IAgBtB;;;;;;;;;;;OAWG;YACW,aAAa;IAiC3B;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAmB1B,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,SAAS;IAiBjB,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,YAAY;YAMN,kBAAkB;YAiDlB,YAAY;YA0CZ,kBAAkB;IAgDhC;;;;;;OAMG;YACW,gBAAgB;IAuF9B;;;;;;OAMG;IACH,OAAO,CAAC,0BAA0B;CAgCnC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Context-aware editor completion for the WebUI Monaco surface.
3
+ *
4
+ * The handler combines fast symbol-index hits with a short, JSON-only LLM call.
5
+ * It is intentionally side-effect free: it never writes files and only reads the
6
+ * existing codebase index when available.
7
+ */
8
+ import type { WebSocket } from 'ws';
9
+ import type { Context, Provider, Tool } from '@wrongstack/core';
10
+ export type CompletionItemKind = 'text' | 'method' | 'function' | 'constructor' | 'field' | 'variable' | 'class' | 'interface' | 'module' | 'property' | 'unit' | 'value' | 'enum' | 'keyword' | 'snippet' | 'file' | 'reference';
11
+ export interface CompletionSuggestion {
12
+ label: string;
13
+ insertText: string;
14
+ kind?: CompletionItemKind | undefined;
15
+ detail?: string | undefined;
16
+ documentation?: string | undefined;
17
+ sortText?: string | undefined;
18
+ source?: 'llm' | 'index' | 'lsp' | undefined;
19
+ }
20
+ export interface CompletionHandlerOptions {
21
+ projectRoot: string;
22
+ provider?: Provider | undefined;
23
+ model?: string | undefined;
24
+ indexDir?: string | undefined;
25
+ lspCompletion?: LspCompletionSource | undefined;
26
+ timeoutMs?: number | undefined;
27
+ }
28
+ export interface LspCompletionSourceRequest {
29
+ filePath: string;
30
+ lineNumber: number;
31
+ column: number;
32
+ content?: string | undefined;
33
+ triggerCharacter?: string | undefined;
34
+ signal: AbortSignal;
35
+ }
36
+ export type LspCompletionSource = (request: LspCompletionSourceRequest) => Promise<CompletionSuggestion[]>;
37
+ export declare function handleCompletionRequest(ws: WebSocket, msg: unknown, opts: CompletionHandlerOptions): Promise<void>;
38
+ export declare function createToolLspCompletionSource(tool: Tool | undefined, ctx: Context): LspCompletionSource | undefined;
39
+ //# sourceMappingURL=completion-handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion-handlers.d.ts","sourceRoot":"","sources":["../../src/server/completion-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAW,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAIzE,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,QAAQ,GACR,UAAU,GACV,aAAa,GACb,OAAO,GACP,UAAU,GACV,OAAO,GACP,WAAW,GACX,QAAQ,GACR,UAAU,GACV,MAAM,GACN,OAAO,GACP,MAAM,GACN,SAAS,GACT,SAAS,GACT,MAAM,GACN,WAAW,CAAC;AAEhB,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACtC,MAAM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(issue: God-modules >1500 lines).
5
+ * `startWebUI` in `./index.ts` previously inlined:
6
+ * - per-connection message rate limiting (state + `checkRateLimit`)
7
+ * - the `handleConnection` callback registered on both WS servers
8
+ * - the F5-resilience replay (transcript + usage) shipped to every new
9
+ * connection so a browser refresh rehydrates without an extra round-trip
10
+ *
11
+ * All of that moves here. The factory returns the `(ws) => void` handler
12
+ * that `startWebUI` registers on `wssPrimary` / `wssSecondary`. Behaviour is
13
+ * preserved verbatim — rate-limit windows, the 2 000-message replay cap, the
14
+ * pending-confirm cleanup on close, and the error swallow on socket errors.
15
+ */
16
+ import type { Context, Message, Usage } from '@wrongstack/core';
17
+ import type { DefaultTokenCounter } from '@wrongstack/core/infrastructure';
18
+ import type { WebSocket } from 'ws';
19
+ import type { AutoPhaseWebSocketHandler } from './autophase-ws-handler.js';
20
+ import type { CollaborationWebSocketHandler } from './collaboration-ws-handler.js';
21
+ import type { SddBoardWebSocketHandler } from './sdd-board-ws-handler.js';
22
+ import type { SddWizardWebSocketHandler } from './sdd-wizard-ws-handler.js';
23
+ import type { SpecsWebSocketHandler } from './specs-ws-handler.js';
24
+ import type { TerminalWebSocketHandler } from './terminal-ws-handler.js';
25
+ import type { WorktreeWebSocketHandler } from './worktree-ws-handler.js';
26
+ import type { ConnectedClient, WSClientMessage } from './types.js';
27
+ import { type PendingConfirm } from './pending-confirms.js';
28
+ /** The session.start payload enriched with optional F5-replay fields. */
29
+ type SessionStartEnriched = Record<string, unknown>;
30
+ export interface ConnectionHandlerOptions {
31
+ /** Live session id — re-read every connect (mutable across /new + resume). */
32
+ getSessionId(): string;
33
+ /** Builds the rich session.start payload (model, costs, cwd, …). */
34
+ sessionStartPayload(): Promise<SessionStartEnriched>;
35
+ /** Token counter — `total()` feeds the replayUsage block. */
36
+ tokenCounter: DefaultTokenCounter;
37
+ /** Agent context — fallback source for replay when the session log is unavailable. */
38
+ context: Context;
39
+ /**
40
+ * Load the visible chat replay for a reconnecting client. Prefer the
41
+ * session log over `context.messages`: context is the model working set and
42
+ * may have been compacted, while the session log is the UI transcript.
43
+ */
44
+ loadReplay?: (() => Promise<{
45
+ messages: Message[];
46
+ usage?: Usage | undefined;
47
+ } | null>) | undefined;
48
+ /** Live WS clients map (shared with the dispatcher + broadcaster). */
49
+ clients: Map<WebSocket, ConnectedClient>;
50
+ /** Pending permission confirmations — drained to 'no' on disconnect. */
51
+ pendingConfirms: Map<string, PendingConfirm>;
52
+ /** Per-feature WS handlers that register each new client for their feeds. */
53
+ autoPhaseHandler: AutoPhaseWebSocketHandler;
54
+ specsHandler: SpecsWebSocketHandler;
55
+ sddBoardHandler: SddBoardWebSocketHandler;
56
+ sddWizardHandler: SddWizardWebSocketHandler;
57
+ worktreeHandler: WorktreeWebSocketHandler;
58
+ collabHandler: CollaborationWebSocketHandler;
59
+ terminalHandler: TerminalWebSocketHandler;
60
+ /** The inbound message dispatcher (handles parsed WSClientMessage). */
61
+ handleMessage: (ws: WebSocket, client: ConnectedClient, msg: WSClientMessage) => Promise<void>;
62
+ }
63
+ /**
64
+ * Build the `(ws) => void` connection handler.
65
+ *
66
+ * Owns the rate-limit state + the per-process connection-id sequence so two
67
+ * handlers built in the same process don't share buckets. Returns the handler
68
+ * plus a `dispose` for tests; production registers it directly on the servers.
69
+ */
70
+ export declare function createConnectionHandler(opts: ConnectionHandlerOptions): (ws: WebSocket) => void;
71
+ export {};
72
+ //# sourceMappingURL=connection-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-handler.d.ts","sourceRoot":"","sources":["../../src/server/connection-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAEpC,OAAO,KAAK,EAAE,yBAA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,YAAY,EAAE,qBAAqB,CAAC;IACpC,eAAe,EAAE,wBAAwB,CAAC;IAC1C,gBAAgB,EAAE,yBAAyB,CAAC;IAC5C,eAAe,EAAE,wBAAwB,CAAC;IAC1C,aAAa,EAAE,6BAA6B,CAAC;IAC7C,eAAe,EAAE,wBAAwB,CAAC;IAC1C,uEAAuE;IACvE,aAAa,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChG;AA2BD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,wBAAwB,GAC7B,CAAC,EAAE,EAAE,SAAS,KAAK,IAAI,CA4LzB"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Context-meta seeding for the standalone WebUI server.
3
+ *
4
+ * Phase 1c of the god-module split (issue: God-modules >1500 lines).
5
+ * `startWebUI` in `./index.ts` previously inlined a ~70-line block that
6
+ * mirrored the CLI's `getSettings()` mapping: it reads the persisted
7
+ * `config.json` shape and projects the relevant fields onto `context.meta`
8
+ * so the settings panel, autonomy engine, fallback chain, feature toggles,
9
+ * and Telegram extension state all reflect the persisted config on first
10
+ * connect — before any `prefs.update` arrives.
11
+ *
12
+ * Pure config → meta projection. No behaviour change.
13
+ */
14
+ import type { Config } from '@wrongstack/core/types';
15
+ /**
16
+ * Seed `context.meta` from the loaded config. Mirrors the CLI's
17
+ * `getSettings()` mapping so TUI and WebUI agree. Without this the snapshot
18
+ * is empty and every browser shows localStorage defaults (autonomy "off",
19
+ * etc.) regardless of what config.json says.
20
+ *
21
+ * The `context` is typed structurally so this module does not take a
22
+ * dependency on the higher `Context` class — anything with a writable
23
+ * `meta: Record<string, unknown>` works.
24
+ */
25
+ export declare function seedContextMeta(config: Config, context: {
26
+ meta: Record<string, unknown>;
27
+ }): void;
28
+ //# sourceMappingURL=context-meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-meta.d.ts","sourceRoot":"","sources":["../../src/server/context-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACzC,IAAI,CA8FN"}