@wrongstack/webui 0.265.1 → 0.268.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.
@@ -1,6 +1,7 @@
1
1
  import { WebSocket } from 'ws';
2
- import { Agent, EventBus, SessionStore, ToolRegistry, ModelsRegistry, ConfigStore, SecretVault, JournalEntry, Logger, MemoryStore, Config, MCPRegistryHandle, ProviderConfig, ProviderApiKey, Context, SkillLoader } from '@wrongstack/core';
2
+ import { Agent, EventBus, SessionStore, ToolRegistry, ModelsRegistry, ConfigStore, SecretVault, JournalEntry, Logger, MemoryStore, ProviderConfig, ProviderApiKey, Context, SkillLoader } from '@wrongstack/core';
3
3
  import * as http from 'node:http';
4
+ import { MCPRegistry } from '@wrongstack/mcp';
4
5
  import { SkillInstaller } from '@wrongstack/core/skills';
5
6
 
6
7
  interface WSServerMessage {
@@ -402,6 +403,27 @@ declare function handleFilesList(ws: WebSocket, msg: unknown, projectRoot: strin
402
403
  * directory yields an empty-but-valid payload.
403
404
  */
404
405
  declare function handleGitInfo(ws: WebSocket, projectRoot: string): Promise<void>;
406
+ /**
407
+ * Read the working-tree change set (everything that differs from HEAD:
408
+ * staged, unstaged, and untracked) and broadcast a `git.changes` message.
409
+ *
410
+ * The file list comes from `git status --porcelain -z` (NUL-delimited so
411
+ * paths with spaces/unicode survive intact, and renames are unambiguous).
412
+ * Per-file line counts come from `--numstat` of both the unstaged and the
413
+ * staged diff, summed. Untracked files intentionally report 0/0 here so the
414
+ * list view does not read every untracked file; `git.diff` loads a selected
415
+ * file lazily on demand.
416
+ * Never throws — a non-repo yields an empty list.
417
+ */
418
+ declare function handleGitChanges(ws: WebSocket, projectRoot: string): Promise<void>;
419
+ /**
420
+ * Resolve the before/after text for a single file and broadcast a `git.diff`
421
+ * message. `oldText` is the file at HEAD (`git show HEAD:<path>`), `newText`
422
+ * is the current working-tree content. New/untracked files have empty
423
+ * `oldText`; deleted files have empty `newText`. Binary or oversized files
424
+ * are reported with a flag instead of content so the client can show a notice.
425
+ */
426
+ declare function handleGitDiff(ws: WebSocket, projectRoot: string, path: string): Promise<void>;
405
427
 
406
428
  /**
407
429
  * Shared memory-operation WebSocket handlers for both the standalone WebUI
@@ -431,30 +453,36 @@ declare function handleMemoryRemember(ws: WebSocket, msg: unknown, memoryStore:
431
453
  declare function handleMemoryForget(ws: WebSocket, msg: unknown, memoryStore: MemoryStore): Promise<void>;
432
454
 
433
455
  /**
434
- * MCP management handlers for the WebUI server.
435
- * Handles MCP-related WS messages from the browser client.
456
+ * MCP management handlers for the WebUI server (both the standalone
457
+ * `wrongstack webui` server and the CLI's embedded `--webui` server).
458
+ *
459
+ * These are thin WebSocket translators over the shared, surface-agnostic
460
+ * management core in `@wrongstack/mcp` (`manage.ts`) — the SAME core the REPL
461
+ * `/mcp` command writes against (same config.json, same MCPRegistry). All the
462
+ * config IO, url/header persistence, and live registry start/stop logic lives
463
+ * there; here we only map structured results to WS events the browser expects.
436
464
  */
437
465
 
438
- /** Handle mcp.list — return all configured MCP servers */
439
- declare function handleMcpList(ws: WebSocket, _msg: WSClientMessage, config: Config, _globalConfigPath: string, mcpRegistry?: MCPRegistryHandle): Promise<void>;
440
- /** Handle mcp.add — add a new MCP server configuration */
441
- declare function handleMcpAdd(ws: WebSocket, msg: WSClientMessage, config: Config, globalConfigPath: string, mcpRegistry?: MCPRegistryHandle): Promise<void>;
442
- /** Handle mcp.removeremove an MCP server configuration */
443
- declare function handleMcpRemove(ws: WebSocket, msg: WSClientMessage, _config: Config, globalConfigPath: string, mcpRegistry?: MCPRegistryHandle): Promise<void>;
444
- /** Handle mcp.updateupdate an existing MCP server configuration */
445
- declare function handleMcpUpdate(ws: WebSocket, msg: WSClientMessage, _config: Config, globalConfigPath: string): Promise<void>;
446
- /** Handle mcp.wakewake a sleeping MCP server (restart it) */
447
- declare function handleMcpWake(ws: WebSocket, msg: WSClientMessage, _config: Config, _globalConfigPath: string, mcpRegistry?: MCPRegistryHandle): Promise<void>;
448
- /** Handle mcp.sleepput an MCP server to sleep (stop it) */
449
- declare function handleMcpSleep(ws: WebSocket, msg: WSClientMessage, _config: Config, _globalConfigPath: string, mcpRegistry?: MCPRegistryHandle): Promise<void>;
450
- /** Handle mcp.discoverperform one-time tool discovery on an MCP server */
451
- declare function handleMcpDiscover(ws: WebSocket, msg: WSClientMessage, _config: Config, _globalConfigPath: string, _mcpRegistry?: MCPRegistryHandle): Promise<void>;
452
- /** Handle mcp.enableenable an MCP server */
453
- declare function handleMcpEnable(ws: WebSocket, msg: WSClientMessage, _config: Config, _globalConfigPath: string): Promise<void>;
454
- /** Handle mcp.disabledisable an MCP server */
455
- declare function handleMcpDisable(ws: WebSocket, msg: WSClientMessage, _config: Config, _globalConfigPath: string): Promise<void>;
456
- /** Handle mcp.restartrestart an MCP server */
457
- declare function handleMcpRestart(ws: WebSocket, msg: WSClientMessage, _config: Config, _globalConfigPath: string): Promise<void>;
466
+ /** mcp.list — configured servers merged with live registry status + tools. */
467
+ declare function handleMcpList(ws: WebSocket, _msg: WSClientMessage, globalConfigPath: string, mcpRegistry?: MCPRegistry): Promise<void>;
468
+ /** mcp.add — persist a new server (incl. url/headers) and start it if enabled. */
469
+ declare function handleMcpAdd(ws: WebSocket, msg: WSClientMessage, globalConfigPath: string, mcpRegistry?: MCPRegistry): Promise<void>;
470
+ /** mcp.updatere-persist config (incl. url/headers) and re-apply to registry. */
471
+ declare function handleMcpUpdate(ws: WebSocket, msg: WSClientMessage, globalConfigPath: string, mcpRegistry?: MCPRegistry): Promise<void>;
472
+ /** mcp.removestop the server and delete it from config. */
473
+ declare function handleMcpRemove(ws: WebSocket, msg: WSClientMessage, globalConfigPath: string, mcpRegistry?: MCPRegistry): Promise<void>;
474
+ /** mcp.enableflip enabled:true in config and start the server. */
475
+ declare function handleMcpEnable(ws: WebSocket, msg: WSClientMessage, globalConfigPath: string, mcpRegistry?: MCPRegistry): Promise<void>;
476
+ /** mcp.disablestop the server and flip enabled:false in config. */
477
+ declare function handleMcpDisable(ws: WebSocket, msg: WSClientMessage, globalConfigPath: string, mcpRegistry?: MCPRegistry): Promise<void>;
478
+ /** mcp.sleepstop a running server (config stays enabled). */
479
+ declare function handleMcpSleep(ws: WebSocket, msg: WSClientMessage, globalConfigPath: string, mcpRegistry?: MCPRegistry): Promise<void>;
480
+ /** mcp.wakerestart a sleeping/stopped server from config. */
481
+ declare function handleMcpWake(ws: WebSocket, msg: WSClientMessage, globalConfigPath: string, mcpRegistry?: MCPRegistry): Promise<void>;
482
+ /** mcp.restartstop + start a server. */
483
+ declare function handleMcpRestart(ws: WebSocket, msg: WSClientMessage, globalConfigPath: string, mcpRegistry?: MCPRegistry): Promise<void>;
484
+ /** mcp.discoverensure the server is running and report its live tools. */
485
+ declare function handleMcpDiscover(ws: WebSocket, msg: WSClientMessage, globalConfigPath: string, mcpRegistry?: MCPRegistry): Promise<void>;
458
486
 
459
487
  /**
460
488
  * Custom context modes — user-defined presets that are loaded from disk,
@@ -754,4 +782,4 @@ declare function startWebUI(opts?: WebUIOptions & {
754
782
  open?: boolean | undefined;
755
783
  }): Promise<void>;
756
784
 
757
- export { AutoPhaseWebSocketHandler, type BackendServices, type ConnectedClient, type ContextBreakdown, type CreateHttpServerOptions, type CustomContextMode, type CustomModeStore, type EternalBroadcast, type EternalSubscribe, type EternalSubscription, type KeyOpResult, type MessageTokenEntry, type ProvidersRecord, type ShellOpenRequest, type ShellOpenResult, type ShellOpenTarget, type SkillsContext, type ToolTokenEntry, type VerifyClientInput, type WSClientMessage, type WSServerMessage, type WebUIInstanceRecord, type WebUIOptions, addProvider, broadcast, browserOpenCommand, buildCspHeader, createCustomModeStore, createEternalSubscription, createHttpServer, createProviderConfigIO, defaultBaseDir, deleteKey, errMessage, estimateTokens, extractToken, findFreePort, formatInstances, generateAuthToken, handleFilesList, handleFilesRead, handleFilesTree, handleFilesWrite, handleGitInfo, handleMcpAdd, handleMcpDisable, handleMcpDiscover, handleMcpEnable, handleMcpList, handleMcpRemove, handleMcpRestart, handleMcpSleep, handleMcpUpdate, handleMcpWake, handleMemoryForget, handleMemoryList, handleMemoryRemember, handleShellOpen, handleSkillsContent, handleSkillsCreate, handleSkillsEdit, handleSkillsExport, handleSkillsInstall, handleSkillsUninstall, handleSkillsUpdate, hostHeaderOk, injectWsPort, isLoopbackBind, isLoopbackHostname, isPortFree, listInstances, loadSavedProviders, maskedKey, messagePreview, messageTokens, normalizeKeys, openBrowser, registerInstance, registryPath, removeProvider, saveProviders, send, sendResult, setActiveKey, startWebUI, stringifyContent, tokenMatches, unregisterInstance, upsertKey, verifyClient, writeKeysBack };
785
+ export { AutoPhaseWebSocketHandler, type BackendServices, type ConnectedClient, type ContextBreakdown, type CreateHttpServerOptions, type CustomContextMode, type CustomModeStore, type EternalBroadcast, type EternalSubscribe, type EternalSubscription, type KeyOpResult, type MessageTokenEntry, type ProvidersRecord, type ShellOpenRequest, type ShellOpenResult, type ShellOpenTarget, type SkillsContext, type ToolTokenEntry, type VerifyClientInput, type WSClientMessage, type WSServerMessage, type WebUIInstanceRecord, type WebUIOptions, addProvider, broadcast, browserOpenCommand, buildCspHeader, createCustomModeStore, createEternalSubscription, createHttpServer, createProviderConfigIO, defaultBaseDir, deleteKey, errMessage, estimateTokens, extractToken, findFreePort, formatInstances, generateAuthToken, handleFilesList, handleFilesRead, handleFilesTree, handleFilesWrite, handleGitChanges, handleGitDiff, handleGitInfo, handleMcpAdd, handleMcpDisable, handleMcpDiscover, handleMcpEnable, handleMcpList, handleMcpRemove, handleMcpRestart, handleMcpSleep, handleMcpUpdate, handleMcpWake, handleMemoryForget, handleMemoryList, handleMemoryRemember, handleShellOpen, handleSkillsContent, handleSkillsCreate, handleSkillsEdit, handleSkillsExport, handleSkillsInstall, handleSkillsUninstall, handleSkillsUpdate, hostHeaderOk, injectWsPort, isLoopbackBind, isLoopbackHostname, isPortFree, listInstances, loadSavedProviders, maskedKey, messagePreview, messageTokens, normalizeKeys, openBrowser, registerInstance, registryPath, removeProvider, saveProviders, send, sendResult, setActiveKey, startWebUI, stringifyContent, tokenMatches, unregisterInstance, upsertKey, verifyClient, writeKeysBack };