@wrongstack/webui 0.87.0 → 0.89.3

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,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // src/server/index.ts
3
+ import { expectDefined as expectDefined2 } from "@wrongstack/core";
3
4
  import * as fs4 from "fs/promises";
4
5
  import * as path4 from "path";
5
6
 
@@ -164,7 +165,7 @@ import {
164
165
  collabPauseMiddleware,
165
166
  collabInjectMiddleware,
166
167
  estimateRequestTokensCalibrated,
167
- EventBus,
168
+ EventBus as EventBus2,
168
169
  HybridCompactor as HybridCompactor2,
169
170
  ProviderRegistry,
170
171
  TOKENS as TOKENS2,
@@ -172,6 +173,7 @@ import {
172
173
  atomicWrite as atomicWrite3,
173
174
  createDefaultPipelines,
174
175
  DEFAULT_CONTEXT_WINDOW_MODE_ID,
176
+ DEFAULT_SESSION_PRUNE_DAYS,
175
177
  DEFAULT_TOOLS_CONFIG,
176
178
  listContextWindowModes,
177
179
  repairToolUseAdjacency,
@@ -179,7 +181,7 @@ import {
179
181
  } from "@wrongstack/core";
180
182
  import { ToolExecutor } from "@wrongstack/core/execution";
181
183
  import { buildProviderFactoriesFromRegistry, makeProviderFromConfig } from "@wrongstack/providers";
182
- import { builtinToolsPack, forgetTool, rememberTool } from "@wrongstack/tools";
184
+ import { builtinToolsPack, forgetTool, rememberTool, searchMemoryTool, relatedMemoryTool } from "@wrongstack/tools";
183
185
  import { WebSocketServer } from "ws";
184
186
 
185
187
  // ../runtime/src/container.ts
@@ -224,7 +226,7 @@ function createDefaultContainer(opts) {
224
226
  secretScrubber: container.resolve(TOKENS.SecretScrubber)
225
227
  })
226
228
  );
227
- const memoryStore = new DefaultMemoryStore({ paths: wpaths });
229
+ const memoryStore = new DefaultMemoryStore({ paths: wpaths, events: opts.events });
228
230
  container.bind(TOKENS.MemoryStore, () => memoryStore);
229
231
  const skillLoader = new DefaultSkillLoader({ paths: wpaths, bundledDir: opts.bundledSkillsDir });
230
232
  container.bind(TOKENS.SkillLoader, () => skillLoader);
@@ -1685,12 +1687,7 @@ async function saveProviders(configPath, vault, providers) {
1685
1687
  }
1686
1688
 
1687
1689
  // src/server/provider-keys.ts
1688
- function expectDefined(value) {
1689
- if (value === null || value === void 0) {
1690
- throw new Error("Expected value to be defined");
1691
- }
1692
- return value;
1693
- }
1690
+ import { expectDefined } from "@wrongstack/core";
1694
1691
  function normalizeKeys(cfg) {
1695
1692
  if (Array.isArray(cfg.apiKeys) && cfg.apiKeys.length > 0) {
1696
1693
  return cfg.apiKeys.map((k) => ({ ...k }));
@@ -1822,7 +1819,10 @@ function createProviderHandlers(deps) {
1822
1819
  return loadSavedProviders(globalConfigPath, vault);
1823
1820
  }
1824
1821
  async function saveConfigProviders(providers) {
1825
- const next = configWriteLock.then(() => saveProviders(globalConfigPath, vault, providers));
1822
+ const next = configWriteLock.then(() => saveProviders(globalConfigPath, vault, providers)).catch((err) => {
1823
+ const msg = err instanceof Error ? err.message : String(err);
1824
+ console.error(`[ProviderHandlers] saveProviders failed: ${msg}`);
1825
+ });
1826
1826
  configWriteLock = next;
1827
1827
  deps.setConfigWriteLock(next);
1828
1828
  await next;
@@ -1996,12 +1996,6 @@ function estimateContextBreakdown(input) {
1996
1996
  }
1997
1997
 
1998
1998
  // src/server/index.ts
1999
- function expectDefined2(value) {
2000
- if (value === null || value === void 0) {
2001
- throw new Error("Expected value to be defined");
2002
- }
2003
- return value;
2004
- }
2005
1999
  async function startWebUI(opts = {}) {
2006
2000
  const requestedWsPort = opts.wsPort ?? 3457;
2007
2001
  const wsHost = opts.wsHost ?? "127.0.0.1";
@@ -2054,12 +2048,14 @@ async function startWebUI(opts = {}) {
2054
2048
  if (config.features.memory) {
2055
2049
  toolRegistry.register(rememberTool(memoryStore));
2056
2050
  toolRegistry.register(forgetTool(memoryStore));
2051
+ toolRegistry.register(searchMemoryTool(memoryStore));
2052
+ toolRegistry.register(relatedMemoryTool(memoryStore));
2057
2053
  }
2058
2054
  console.log("[WebUI] Tool registry loaded:", toolRegistry.list().length, "tools");
2059
- const events = new EventBus();
2055
+ const events = new EventBus2();
2060
2056
  events.setLogger(logger);
2061
2057
  const sessionStore = new DefaultSessionStore2({ dir: wpaths.projectSessions });
2062
- sessionStore.prune(30).then((count) => {
2058
+ sessionStore.prune(DEFAULT_SESSION_PRUNE_DAYS).then((count) => {
2063
2059
  if (count > 0) logger.info(`Pruned ${count} old session${count === 1 ? "" : "s"}.`);
2064
2060
  }).catch(() => void 0);
2065
2061
  const sessionReader = new DefaultSessionReader({ store: sessionStore });
@@ -2353,7 +2349,10 @@ async function startWebUI(opts = {}) {
2353
2349
  if (typeof rawObj === "object" && rawObj !== null) {
2354
2350
  const obj = rawObj;
2355
2351
  if ("__proto__" in obj || "constructor" in obj || "prototype" in obj) {
2356
- send(ws, { type: "error", payload: { phase: "parse", message: "Invalid message object" } });
2352
+ send(ws, {
2353
+ type: "error",
2354
+ payload: { phase: "parse", message: "Invalid message object" }
2355
+ });
2357
2356
  } else {
2358
2357
  await handleMessage(ws, client, rawObj);
2359
2358
  }
@@ -2954,10 +2953,7 @@ async function startWebUI(opts = {}) {
2954
2953
  break;
2955
2954
  }
2956
2955
  const removed = expectDefined2(context.todos[targetIdx]);
2957
- const next = [
2958
- ...context.todos.slice(0, targetIdx),
2959
- ...context.todos.slice(targetIdx + 1)
2960
- ];
2956
+ const next = [...context.todos.slice(0, targetIdx), ...context.todos.slice(targetIdx + 1)];
2961
2957
  context.state.replaceTodos(next);
2962
2958
  sendResult(ws, true, `Removed: ${removed.content}`);
2963
2959
  broadcast(clients, { type: "todos.updated", payload: { todos: next } });
@@ -2971,12 +2967,26 @@ async function startWebUI(opts = {}) {
2971
2967
  const plan = await loadPlan(planPath);
2972
2968
  send(ws, {
2973
2969
  type: "plan.updated",
2974
- payload: { plan: plan ?? { version: 1, sessionId: session.id, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), items: [] } }
2970
+ payload: {
2971
+ plan: plan ?? {
2972
+ version: 1,
2973
+ sessionId: session.id,
2974
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2975
+ items: []
2976
+ }
2977
+ }
2975
2978
  });
2976
2979
  } catch {
2977
2980
  send(ws, {
2978
2981
  type: "plan.updated",
2979
- payload: { plan: { version: 1, sessionId: session.id, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), items: [] } }
2982
+ payload: {
2983
+ plan: {
2984
+ version: 1,
2985
+ sessionId: session.id,
2986
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2987
+ items: []
2988
+ }
2989
+ }
2980
2990
  });
2981
2991
  }
2982
2992
  } else {
@@ -3136,9 +3146,14 @@ async function startWebUI(opts = {}) {
3136
3146
  }
3137
3147
  default:
3138
3148
  if (msg.type.startsWith("autophase.")) {
3139
- await autoPhaseHandler.handleMessage(msg);
3149
+ await autoPhaseHandler.handleMessage(
3150
+ msg
3151
+ );
3140
3152
  } else {
3141
- send(ws, { type: "error", payload: { phase: "handleMessage", message: `Unknown message type: ${msg.type}` } });
3153
+ send(ws, {
3154
+ type: "error",
3155
+ payload: { phase: "handleMessage", message: `Unknown message type: ${msg.type}` }
3156
+ });
3142
3157
  }
3143
3158
  }
3144
3159
  }