nexum-code 0.15.1 → 0.15.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.
@@ -4,7 +4,7 @@ import { dirname as __cjsShimDirname } from 'node:path';
4
4
  const __filename = __cjsShimFileURLToPath(import.meta.url);
5
5
  const __dirname = __cjsShimDirname(__filename);
6
6
  import "./suppress-sqlite-warning-C2VB0doZ.mjs";
7
- import { $n as NEXUM_ERROR_INFO, $t as parseStreamingArgs, A as langFromPath, An as saveTuiConfig, At as DISABLE_TERMINAL_FOCUS_REPORTING, B as AgentGroupComponent, Bn as DEFAULT_CATALOG_URL, Bt as TERMINAL_FOCUS_OUT, C as isEmptySessionHintDismissed, Cn as appendJsonlLine, Ct as createEditorTheme, D as renderDiffLines, Dn as TuiConfigParseError, Dt as getColorPalette, E as ToolCallComponent, En as PULSE_WAVE_FRAMES, Et as contrastTextHex, F as SkillActivationComponent, Fn as detectInstallSource, Ft as OSC11_RESPONSE, G as BREATHE_CYCLE_MS, Gn as resolveNexumHome, H as sanitizeShellOutput, Hn as saveCatalogCache, Ht as TERMINAL_THEME_LIGHT, I as ReadGroupComponent, In as CLI_COMMAND_NAME, It as OSC11_RESPONSE_PREFIX, J as clearGoalState, Jn as log, Jt as STATUS_BULLET, K as getBreathingFrame, Kn as MemoryMemoStore, L as parseReadGroupOutput, Ln as CLI_UI_MODE, Lt as OSC11_RESPONSE_PREFIX_NO_ESC, M as ThinkingComponent, Mn as getDataDir, Mt as ENABLE_TERMINAL_FOCUS_REPORTING, N as estimateTokens, Nn as getInputHistoryFile, Nt as ENABLE_TERMINAL_THEME_REPORTING, O as renderDiffLinesClustered, On as TuiLikePreferencesSchema, Ot as detectTerminalTheme, P as getSharedSpeedTracker, Pn as getLogDir, Pt as OSC11_QUERY, Qn as ErrorCodes, Qt as isTodoItemShape, R as BackgroundAgentStatusComponent, Rn as CLI_USER_AGENT_PRODUCT, Rt as QUERY_TERMINAL_THEME, S as UserMessageComponent, Sn as readUpdateCache, St as resolveThemeSync, T as toggleEmptySessionHint, Tn as PIXEL_PULSE_FRAMES, Tt as createThemeStyles, U as WelcomeComponent, Un as NexumHarness, V as replaceTabs, Vn as fetchCatalog, Vt as TERMINAL_THEME_DARK, W as NEXUM_CODE_LOGO, Xn as isNexumError, Xt as argsRecord, Y as refineGoal, Yn as resolveGlobalLogPath, Yt as appendStreamingArgsPreview, Zn as isOrphanedToolCallError, Zt as formatErrorMessage, _n as setExperimentalFlags, _t as clearInfoPanelState, a as isEmbeddingModelCached, an as EXIT_CONFIRM_WINDOW_MS, b as getDaemonInstructions, bn as selectUpdateTarget, bt as isBusy, cn as TIP_ROTATION_INTERVAL_MS, d as hasDispose, dn as getLlmNotSetMessage, en as serializeToolResultOutput, f as isPlanExpandable, fn as getNoActiveSessionMessage, gn as isExperimentalFlagEnabled, gt as FooterComponent, hn as sortSlashCommands, i as getKnowledgeStore, in as EMPTY_SESSION_HINT_URL, j as CachedContainer, jn as detectShellEnvironment, jt as DISABLE_TERMINAL_THEME_REPORTING, k as highlightLines, kn as loadTuiConfig, kt as parseOsc11BackgroundTheme, ln as getCtrlCHint, lt as handlePlanCommand, m as formatMemoryMemoForInjection, mn as BUILTIN_SLASH_COMMANDS, n as clearEvalPanelState, nn as truncateErrorMessage, nt as changeThinkingLevel, o as startManualEmbeddingDownload, on as MAIN_AGENT_ID, p as MoonLoader, pn as buildSkillSlashCommands, q as resetBreathingClock, qn as flushDiagnosticLogs, qt as printableChar, r as openUrl, rn as CHARS_PER_TOKEN, rt as getModelCycleLevel, s as buildRoleAdditionalText, sn as SESSION_TIPS, st as handleFusionPlanCommand, t as dispatchInput, tn as stringValue, tt as toTerminalHyperlink, u as disposeChildren, un as getCtrlDHint, vn as refreshProviderBalance, w as isTurnElapsedEnabled, wn as readJsonlFile, wt as createMarkdownTheme, xn as refreshUpdateCache, xt as isStreaming, yn as supportsBalance, z as AssistantMessageComponent, zn as PRODUCT_NAME, zt as TERMINAL_FOCUS_IN } from "./dispatch-C98jHQkj.mjs";
7
+ import { $n as NEXUM_ERROR_INFO, $t as parseStreamingArgs, A as langFromPath, An as saveTuiConfig, At as DISABLE_TERMINAL_FOCUS_REPORTING, B as AgentGroupComponent, Bn as DEFAULT_CATALOG_URL, Bt as TERMINAL_FOCUS_OUT, C as isEmptySessionHintDismissed, Cn as appendJsonlLine, Ct as createEditorTheme, D as renderDiffLines, Dn as TuiConfigParseError, Dt as getColorPalette, E as ToolCallComponent, En as PULSE_WAVE_FRAMES, Et as contrastTextHex, F as SkillActivationComponent, Fn as detectInstallSource, Ft as OSC11_RESPONSE, G as BREATHE_CYCLE_MS, Gn as resolveNexumHome, H as sanitizeShellOutput, Hn as saveCatalogCache, Ht as TERMINAL_THEME_LIGHT, I as ReadGroupComponent, In as CLI_COMMAND_NAME, It as OSC11_RESPONSE_PREFIX, J as clearGoalState, Jn as log, Jt as STATUS_BULLET, K as getBreathingFrame, Kn as MemoryMemoStore, L as parseReadGroupOutput, Ln as CLI_UI_MODE, Lt as OSC11_RESPONSE_PREFIX_NO_ESC, M as ThinkingComponent, Mn as getDataDir, Mt as ENABLE_TERMINAL_FOCUS_REPORTING, N as estimateTokens, Nn as getInputHistoryFile, Nt as ENABLE_TERMINAL_THEME_REPORTING, O as renderDiffLinesClustered, On as TuiLikePreferencesSchema, Ot as detectTerminalTheme, P as getSharedSpeedTracker, Pn as getLogDir, Pt as OSC11_QUERY, Qn as ErrorCodes, Qt as isTodoItemShape, R as BackgroundAgentStatusComponent, Rn as CLI_USER_AGENT_PRODUCT, Rt as QUERY_TERMINAL_THEME, S as UserMessageComponent, Sn as readUpdateCache, St as resolveThemeSync, T as toggleEmptySessionHint, Tn as PIXEL_PULSE_FRAMES, Tt as createThemeStyles, U as WelcomeComponent, Un as NexumHarness, V as replaceTabs, Vn as fetchCatalog, Vt as TERMINAL_THEME_DARK, W as NEXUM_CODE_LOGO, Xn as isNexumError, Xt as argsRecord, Y as refineGoal, Yn as resolveGlobalLogPath, Yt as appendStreamingArgsPreview, Zn as isOrphanedToolCallError, Zt as formatErrorMessage, _n as setExperimentalFlags, _t as clearInfoPanelState, a as isEmbeddingModelCached, an as EXIT_CONFIRM_WINDOW_MS, b as getDaemonInstructions, bn as selectUpdateTarget, bt as isBusy, cn as TIP_ROTATION_INTERVAL_MS, d as hasDispose, dn as getLlmNotSetMessage, en as serializeToolResultOutput, f as isPlanExpandable, fn as getNoActiveSessionMessage, gn as isExperimentalFlagEnabled, gt as FooterComponent, hn as sortSlashCommands, i as getKnowledgeStore, in as EMPTY_SESSION_HINT_URL, j as CachedContainer, jn as detectShellEnvironment, jt as DISABLE_TERMINAL_THEME_REPORTING, k as highlightLines, kn as loadTuiConfig, kt as parseOsc11BackgroundTheme, ln as getCtrlCHint, lt as handlePlanCommand, m as formatMemoryMemoForInjection, mn as BUILTIN_SLASH_COMMANDS, n as clearEvalPanelState, nn as truncateErrorMessage, nt as changeThinkingLevel, o as startManualEmbeddingDownload, on as MAIN_AGENT_ID, p as MoonLoader, pn as buildSkillSlashCommands, q as resetBreathingClock, qn as flushDiagnosticLogs, qt as printableChar, r as openUrl, rn as CHARS_PER_TOKEN, rt as getModelCycleLevel, s as buildRoleAdditionalText, sn as SESSION_TIPS, st as handleFusionPlanCommand, t as dispatchInput, tn as stringValue, tt as toTerminalHyperlink, u as disposeChildren, un as getCtrlDHint, vn as refreshProviderBalance, w as isTurnElapsedEnabled, wn as readJsonlFile, wt as createMarkdownTheme, xn as refreshUpdateCache, xt as isStreaming, yn as supportsBalance, z as AssistantMessageComponent, zn as PRODUCT_NAME, zt as TERMINAL_FOCUS_IN } from "./dispatch-RwKBVuHW.mjs";
8
8
  import { a as setLocale, o as t } from "./text-input-dialog-Dvux6kIR.mjs";
9
9
  import { createRequire } from "node:module";
10
10
  import { randomBytes, randomUUID, scryptSync, timingSafeEqual } from "node:crypto";
@@ -32,7 +32,7 @@ function optionalBuildString(value) {
32
32
  return typeof value === "string" && value.length > 0 ? value : void 0;
33
33
  }
34
34
  const NEXUM_BUILD_INFO = {
35
- version: optionalBuildString("0.15.1"),
35
+ version: optionalBuildString("0.15.3"),
36
36
  channel: optionalBuildString(""),
37
37
  commit: optionalBuildString(""),
38
38
  buildTarget: optionalBuildString("win32-x64")
@@ -2672,27 +2672,22 @@ var GutterContainer = class extends Container {
2672
2672
  };
2673
2673
  //#endregion
2674
2674
  //#region src/tui/components/chrome/pulse-wave-loader.ts
2675
- const FULL_BOX = "■";
2676
- const DIM_DOT = "⬝";
2675
+ const LEADING_BOX = "█";
2677
2676
  /**
2678
- * 3-box pulse-wave loading indicator.
2677
+ * 8-cell flowing pulse-wave loading indicator.
2679
2678
  *
2680
- * Cycles through a breathing wave pattern:
2681
- * ■ ⬝ ⬝ → ■ ■ ⬝ → ⬝ ■ ■ → (bounce back)
2682
- *
2683
- * Colouring mirrors Grok's PromptLoadingBoxes:
2684
- * - active box (distance 0) → full primary colour
2685
- * - trailing box (distance 1) → ~72 % opacity via chalk dim
2686
- * - dim dot (distance ≥ 2) → muted
2679
+ * A full block walks across muted middle dots with a dim trailing block.
2680
+ * U+2588 and U+00B7 keep the line width stable in common CJK terminals.
2687
2681
  *
2688
2682
  * The component auto-starts on construction. Call `stop()` to tear
2689
- * down the interval timer.
2683
+ * down the timer chain.
2690
2684
  */
2691
2685
  var PulseWaveLoader = class extends Text {
2692
2686
  currentFrame = 0;
2693
2687
  intervalId = null;
2694
2688
  ui;
2695
2689
  colorHex;
2690
+ lastTickAt = 0;
2696
2691
  /** Raw frame text without Text's full-width render padding, exposed so
2697
2692
  * callers can compose the wave inline with trailing content (e.g. the
2698
2693
  * reconnect label in the status bar). */
@@ -2708,39 +2703,54 @@ var PulseWaveLoader = class extends Text {
2708
2703
  this.start();
2709
2704
  }
2710
2705
  start() {
2706
+ this.lastTickAt = performance.now();
2711
2707
  this.updateDisplay();
2712
- this.intervalId = setInterval(() => {
2713
- this.currentFrame = (this.currentFrame + 1) % PULSE_WAVE_FRAMES.length;
2714
- this.updateDisplay();
2715
- }, 120);
2708
+ this.scheduleTick(80, 80);
2716
2709
  }
2717
2710
  stop() {
2718
2711
  if (this.intervalId) {
2719
- clearInterval(this.intervalId);
2712
+ clearTimeout(this.intervalId);
2720
2713
  this.intervalId = null;
2721
2714
  }
2722
2715
  }
2716
+ dispose() {
2717
+ this.stop();
2718
+ }
2719
+ scheduleTick(intervalMs, delayMs) {
2720
+ const timer = setTimeout(() => {
2721
+ if (this.intervalId !== timer) return;
2722
+ const startedAt = performance.now();
2723
+ const elapsed = startedAt - this.lastTickAt;
2724
+ if (elapsed >= intervalMs) {
2725
+ const steps = Math.floor(elapsed / intervalMs);
2726
+ this.currentFrame = (this.currentFrame + steps) % PULSE_WAVE_FRAMES.length;
2727
+ this.lastTickAt += steps * intervalMs;
2728
+ this.updateDisplay();
2729
+ }
2730
+ const frameCostMs = performance.now() - startedAt;
2731
+ if (this.intervalId !== timer) return;
2732
+ const cadenceDelayMs = Math.max(0, intervalMs - frameCostMs);
2733
+ const backpressureDelayMs = frameCostMs * 9;
2734
+ this.scheduleTick(intervalMs, Math.max(cadenceDelayMs, backpressureDelayMs));
2735
+ }, delayMs);
2736
+ this.intervalId = timer;
2737
+ }
2723
2738
  setColorHex(colorHex) {
2724
2739
  this.colorHex = colorHex;
2725
2740
  this.updateDisplay();
2726
2741
  }
2727
2742
  updateDisplay() {
2728
2743
  const step = PULSE_WAVE_FRAMES[this.currentFrame] ?? PULSE_WAVE_FRAMES[0];
2729
- const cells = [
2730
- 0,
2731
- 1,
2732
- 2
2733
- ].map((idx) => this.renderCell(idx, step.active, step.forward));
2734
- this.frameText = cells.join(" ");
2744
+ const cells = Array.from({ length: 8 }, (_, index) => this.renderCell(index, step.active, step.forward));
2745
+ this.frameText = cells.join("");
2735
2746
  this.setText(this.frameText);
2736
2747
  this.ui.requestRender();
2737
2748
  }
2738
2749
  renderCell(index, active, forward) {
2739
2750
  const distance = forward ? active - index : index - active;
2740
- const glyph = distance >= 0 && distance < 2 ? FULL_BOX : DIM_DOT;
2741
- if (distance === 0) return chalk.hex(this.colorHex)(glyph);
2742
- if (distance === 1) return chalk.hex(this.colorHex).dim(glyph);
2743
- return chalk.dim(glyph);
2751
+ if (distance === 0) return chalk.hex(this.colorHex)(LEADING_BOX);
2752
+ if (distance === 1) return chalk.hex(this.colorHex).dim(LEADING_BOX);
2753
+ return chalk.dim("·");
2744
2754
  }
2745
2755
  };
2746
2756
  //#endregion
@@ -11742,7 +11752,7 @@ function createTUIState(options) {
11742
11752
  const base64 = Buffer.from(text, "utf8").toString("base64");
11743
11753
  if (base64.length > OSC52_MAX_TEXT_LENGTH) return false;
11744
11754
  try {
11745
- terminal.write(`\x1B]52;c;${base64}\u0007`);
11755
+ terminal.write(`\u001B]52;c;${base64}\u0007`);
11746
11756
  } catch {
11747
11757
  return false;
11748
11758
  }
@@ -12424,7 +12434,7 @@ var NexumTUI = class {
12424
12434
  const card = new OnboardingCardComponent({
12425
12435
  colors: this.state.theme.colors,
12426
12436
  onConfigure: () => {
12427
- import("./dispatch-DA_D42qp.mjs").then(({ handleConnectCommand }) => handleConnectCommand(this, "")).finally(() => {
12437
+ import("./dispatch-ClUS04uO.mjs").then(({ handleConnectCommand }) => handleConnectCommand(this, "")).finally(() => {
12428
12438
  this.restoreEditor();
12429
12439
  onDone?.();
12430
12440
  });
@@ -12462,8 +12472,8 @@ var NexumTUI = class {
12462
12472
  let error;
12463
12473
  try {
12464
12474
  ({ok, error} = await startManualEmbeddingDownload());
12465
- } catch (error) {
12466
- error = error instanceof Error ? error.message : String(error);
12475
+ } catch (downloadError) {
12476
+ error = downloadError instanceof Error ? downloadError.message : String(downloadError);
12467
12477
  }
12468
12478
  spinner.stop({
12469
12479
  ok,
@@ -14140,7 +14150,7 @@ var FileGate = class {
14140
14150
  let entries = [];
14141
14151
  try {
14142
14152
  entries = await readdir(abs, { withFileTypes: true });
14143
- } catch (error) {
14153
+ } catch {
14144
14154
  throw new FileAccessError(404, `无法读取目录:${candidate}`);
14145
14155
  }
14146
14156
  const out = [];
@@ -14533,7 +14543,14 @@ function toHttpError(error) {
14533
14543
  if (isNexumError(error)) switch (error.code) {
14534
14544
  case ErrorCodes.GOAL_OBJECTIVE_EMPTY:
14535
14545
  case ErrorCodes.GOAL_OBJECTIVE_TOO_LONG:
14536
- case ErrorCodes.REQUEST_INVALID: return new HttpError(400, error.message, error.code);
14546
+ case ErrorCodes.REQUEST_INVALID:
14547
+ case ErrorCodes.SESSION_PERMISSION_MODE_INVALID:
14548
+ case ErrorCodes.SESSION_PLAN_MODE_INVALID:
14549
+ case ErrorCodes.SESSION_WOLFPACK_MODE_INVALID:
14550
+ case ErrorCodes.SESSION_MODEL_EMPTY:
14551
+ case ErrorCodes.SESSION_THINKING_EMPTY:
14552
+ case ErrorCodes.SKILL_NAME_EMPTY:
14553
+ case ErrorCodes.BACKGROUND_TASK_ID_EMPTY: return new HttpError(400, error.message, error.code);
14537
14554
  case ErrorCodes.GOAL_NOT_FOUND:
14538
14555
  case ErrorCodes.SESSION_NOT_FOUND: return new HttpError(404, error.message, error.code);
14539
14556
  case ErrorCodes.GOAL_ALREADY_EXISTS:
@@ -15702,6 +15719,49 @@ var WebSession = class {
15702
15719
  status: this.cachedStatus
15703
15720
  }, false);
15704
15721
  }
15722
+ /** Switch permission mode, then sync status + metadata (TUI /auto,/yes parity). */
15723
+ async switchPermission(mode) {
15724
+ if (!this.session) throw new HttpError(409, "会话已归档(只读),无法切换权限模式。");
15725
+ await this.session.setPermission(mode);
15726
+ this.permission = mode;
15727
+ await this.refreshStatus();
15728
+ this.broadcast({
15729
+ type: "status",
15730
+ status: this.cachedStatus
15731
+ }, false);
15732
+ if (this.homeDir) await saveMetadata(this.homeDir, this.getMetadata());
15733
+ }
15734
+ /** Toggle plan mode, then sync status (TUI /plan parity). */
15735
+ async switchPlanMode(enabled, strategy) {
15736
+ if (!this.session) throw new HttpError(409, "会话已归档(只读),无法切换计划模式。");
15737
+ await this.session.setPlanMode(enabled, strategy);
15738
+ await this.refreshStatus();
15739
+ this.broadcast({
15740
+ type: "status",
15741
+ status: this.cachedStatus
15742
+ }, false);
15743
+ }
15744
+ /** Toggle wolfpack mode, then sync status. */
15745
+ async switchWolfpackMode(enabled) {
15746
+ if (!this.session) throw new HttpError(409, "会话已归档(只读),无法切换 Wolfpack 模式。");
15747
+ await this.session.setWolfpackMode(enabled);
15748
+ await this.refreshStatus();
15749
+ this.broadcast({
15750
+ type: "status",
15751
+ status: this.cachedStatus
15752
+ }, false);
15753
+ }
15754
+ /** Toggle RLM persistent-python mode (+ optional max depth), then sync status. */
15755
+ async switchRlm(enabled, maxDepth) {
15756
+ if (!this.session) throw new HttpError(409, "会话已归档(只读),无法切换 RLM 模式。");
15757
+ await this.session.setRlmEnabled(enabled);
15758
+ if (maxDepth !== void 0) await this.session.setRlmMaxDepth(maxDepth);
15759
+ await this.refreshStatus();
15760
+ this.broadcast({
15761
+ type: "status",
15762
+ status: this.cachedStatus
15763
+ }, false);
15764
+ }
15705
15765
  getCoreSessionId() {
15706
15766
  return this.coreSessionId;
15707
15767
  }
@@ -15764,6 +15824,15 @@ var WebSession = class {
15764
15824
  await session.cancelGoal();
15765
15825
  }, true);
15766
15826
  }
15827
+ /**
15828
+ * Public handle to the live core Session for REST RPC forwarding.
15829
+ * Throws 409 for archived (read-only) sessions so handlers never call into a
15830
+ * closed core session instead of silently creating one.
15831
+ */
15832
+ requireLiveSession() {
15833
+ if (!this.session) throw new HttpError(409, "Session is archived (read-only)", ErrorCodes.SESSION_CLOSED);
15834
+ return this.session;
15835
+ }
15767
15836
  requireGoalSession(allowBusy = false) {
15768
15837
  if (!this.session) throw new HttpError(409, "Session is archived (read-only)", ErrorCodes.SESSION_CLOSED);
15769
15838
  if (!allowBusy && this.busy) throw new HttpError(409, "Session is busy", ErrorCodes.TURN_AGENT_BUSY);
@@ -16252,7 +16321,530 @@ var SessionManager = class {
16252
16321
  for (const [, ws] of this.sessions) await ws.close();
16253
16322
  this.sessions.clear();
16254
16323
  }
16324
+ /** Resolve a live session or throw 404/409; the single guard for all handlers. */
16325
+ getLiveSession(sessionId) {
16326
+ const ws = this.sessions.get(sessionId);
16327
+ if (!ws) throw new HttpError(404, "Session not found", ErrorCodes.SESSION_NOT_FOUND);
16328
+ return ws.requireLiveSession();
16329
+ }
16330
+ async getSessionStatus(sessionId) {
16331
+ return this.getLiveSession(sessionId).getStatus();
16332
+ }
16333
+ async getSessionUsage(sessionId) {
16334
+ return this.getLiveSession(sessionId).getUsage();
16335
+ }
16336
+ async getSessionContext(sessionId) {
16337
+ return this.getLiveSession(sessionId).getContext();
16338
+ }
16339
+ async getSessionPlan(sessionId) {
16340
+ return this.getLiveSession(sessionId).getPlan();
16341
+ }
16342
+ async setPermission(sessionId, mode) {
16343
+ const ws = this.sessions.get(sessionId);
16344
+ if (!ws) throw new HttpError(404, "Session not found", ErrorCodes.SESSION_NOT_FOUND);
16345
+ await ws.switchPermission(mode);
16346
+ }
16347
+ async setPlanMode(sessionId, enabled, strategy) {
16348
+ const ws = this.sessions.get(sessionId);
16349
+ if (!ws) throw new HttpError(404, "Session not found", ErrorCodes.SESSION_NOT_FOUND);
16350
+ await ws.switchPlanMode(enabled, strategy);
16351
+ }
16352
+ async clearPlan(sessionId) {
16353
+ await this.getLiveSession(sessionId).clearPlan();
16354
+ }
16355
+ async setWolfpackMode(sessionId, enabled) {
16356
+ const ws = this.sessions.get(sessionId);
16357
+ if (!ws) throw new HttpError(404, "Session not found", ErrorCodes.SESSION_NOT_FOUND);
16358
+ await ws.switchWolfpackMode(enabled);
16359
+ }
16360
+ async setRlm(sessionId, enabled, maxDepth) {
16361
+ const ws = this.sessions.get(sessionId);
16362
+ if (!ws) throw new HttpError(404, "Session not found", ErrorCodes.SESSION_NOT_FOUND);
16363
+ await ws.switchRlm(enabled, maxDepth);
16364
+ }
16365
+ async undoHistory(sessionId, count) {
16366
+ await this.getLiveSession(sessionId).undoHistory(count);
16367
+ }
16368
+ async compact(sessionId, instruction) {
16369
+ await this.getLiveSession(sessionId).compact(instruction ? { instruction } : {});
16370
+ }
16371
+ async listSkills(sessionId) {
16372
+ return this.getLiveSession(sessionId).listSkills();
16373
+ }
16374
+ async activateSkill(sessionId, name, args) {
16375
+ await this.getLiveSession(sessionId).activateSkill(name, args);
16376
+ }
16377
+ async removeSkill(sessionId, name) {
16378
+ await this.getLiveSession(sessionId).removeSkill(name);
16379
+ }
16380
+ async listPlugins(sessionId) {
16381
+ return this.getLiveSession(sessionId).listPlugins();
16382
+ }
16383
+ async getPluginInfo(sessionId, id) {
16384
+ return this.getLiveSession(sessionId).getPluginInfo(id);
16385
+ }
16386
+ async installPlugin(sessionId, source) {
16387
+ return this.getLiveSession(sessionId).installPlugin(source);
16388
+ }
16389
+ async setPluginEnabled(sessionId, id, enabled) {
16390
+ await this.getLiveSession(sessionId).setPluginEnabled(id, enabled);
16391
+ }
16392
+ async setPluginMcpServerEnabled(sessionId, id, server, enabled) {
16393
+ await this.getLiveSession(sessionId).setPluginMcpServerEnabled(id, server, enabled);
16394
+ }
16395
+ async removePlugin(sessionId, id) {
16396
+ await this.getLiveSession(sessionId).removePlugin(id);
16397
+ }
16398
+ async reloadPlugins(sessionId) {
16399
+ return this.getLiveSession(sessionId).reloadPlugins();
16400
+ }
16401
+ async activatePlugin(sessionId, id) {
16402
+ await this.getLiveSession(sessionId).activatePlugin(id);
16403
+ }
16404
+ async deactivatePlugin(sessionId, id) {
16405
+ await this.getLiveSession(sessionId).deactivatePlugin(id);
16406
+ }
16407
+ async injectPlugin(sessionId, id) {
16408
+ await this.getLiveSession(sessionId).injectPlugin(id);
16409
+ }
16410
+ async listMcpServers(sessionId) {
16411
+ return this.getLiveSession(sessionId).listMcpServers();
16412
+ }
16413
+ async getMcpStartupMetrics(sessionId) {
16414
+ return this.getLiveSession(sessionId).getMcpStartupMetrics();
16415
+ }
16416
+ async addMcpServer(sessionId, name, config) {
16417
+ await this.getLiveSession(sessionId).addMcpServer(name, config);
16418
+ }
16419
+ async reconnectMcpServer(sessionId, name) {
16420
+ await this.getLiveSession(sessionId).reconnectMcpServer(name);
16421
+ }
16422
+ async stopMcpServer(sessionId, name) {
16423
+ await this.getLiveSession(sessionId).stopMcpServer(name);
16424
+ }
16425
+ async removeMcpServer(sessionId, name) {
16426
+ await this.getLiveSession(sessionId).removeMcpServer(name);
16427
+ }
16428
+ async listBackgroundTasks(sessionId, activeOnly, limit) {
16429
+ return this.getLiveSession(sessionId).listBackgroundTasks({
16430
+ activeOnly,
16431
+ limit
16432
+ });
16433
+ }
16434
+ async getBackgroundTaskOutput(sessionId, taskId, tail) {
16435
+ return this.getLiveSession(sessionId).getBackgroundTaskOutput(taskId, tail !== void 0 ? { tail } : {});
16436
+ }
16437
+ async stopBackgroundTask(sessionId, taskId, reason) {
16438
+ await this.getLiveSession(sessionId).stopBackgroundTask(taskId, reason !== void 0 ? { reason } : {});
16439
+ }
16440
+ getConfig(options) {
16441
+ return this.harness.getConfig(options);
16442
+ }
16443
+ setConfig(patch) {
16444
+ return this.harness.setConfig(patch);
16445
+ }
16446
+ removeProvider(providerId) {
16447
+ return this.harness.removeProvider(providerId);
16448
+ }
16449
+ getExperimentalFlags() {
16450
+ return this.harness.getExperimentalFlags();
16451
+ }
16452
+ preflight() {
16453
+ return this.harness.preflight();
16454
+ }
16255
16455
  };
16456
+ async function handleSessionControlRoutes(req, res, url, method, manager) {
16457
+ const statusMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/status$`).exec(url);
16458
+ if (statusMatch && method === "GET") {
16459
+ try {
16460
+ sendJson(res, 200, await manager.getSessionStatus(decodeURIComponent(statusMatch[1])));
16461
+ } catch (error) {
16462
+ sendHttpError(res, error);
16463
+ }
16464
+ return true;
16465
+ }
16466
+ const usageMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/usage$`).exec(url);
16467
+ if (usageMatch && method === "GET") {
16468
+ try {
16469
+ sendJson(res, 200, await manager.getSessionUsage(decodeURIComponent(usageMatch[1])));
16470
+ } catch (error) {
16471
+ sendHttpError(res, error);
16472
+ }
16473
+ return true;
16474
+ }
16475
+ const contextMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/context$`).exec(url);
16476
+ if (contextMatch && method === "GET") {
16477
+ try {
16478
+ sendJson(res, 200, await manager.getSessionContext(decodeURIComponent(contextMatch[1])));
16479
+ } catch (error) {
16480
+ sendHttpError(res, error);
16481
+ }
16482
+ return true;
16483
+ }
16484
+ const planMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/plan$`).exec(url);
16485
+ if (planMatch && method === "GET") {
16486
+ try {
16487
+ sendJson(res, 200, await manager.getSessionPlan(decodeURIComponent(planMatch[1])));
16488
+ } catch (error) {
16489
+ sendHttpError(res, error);
16490
+ }
16491
+ return true;
16492
+ }
16493
+ const permissionMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/permission$`).exec(url);
16494
+ if (permissionMatch && method === "POST") {
16495
+ try {
16496
+ const mode = requiredString(await readJsonBody(req), "mode");
16497
+ await manager.setPermission(decodeURIComponent(permissionMatch[1]), mode);
16498
+ sendJson(res, 200, { ok: true });
16499
+ } catch (error) {
16500
+ sendHttpError(res, error);
16501
+ }
16502
+ return true;
16503
+ }
16504
+ const planModeMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/plan$`).exec(url);
16505
+ if (planModeMatch && method === "POST") {
16506
+ try {
16507
+ const body = await readJsonBody(req);
16508
+ const enabled = optionalBoolean(body, "enabled", true);
16509
+ const strategy = optionalString(body, "strategy");
16510
+ await manager.setPlanMode(decodeURIComponent(planModeMatch[1]), enabled, strategy);
16511
+ sendJson(res, 200, { ok: true });
16512
+ } catch (error) {
16513
+ sendHttpError(res, error);
16514
+ }
16515
+ return true;
16516
+ }
16517
+ const clearPlanMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/plan/clear$`).exec(url);
16518
+ if (clearPlanMatch && method === "POST") {
16519
+ try {
16520
+ await manager.clearPlan(decodeURIComponent(clearPlanMatch[1]));
16521
+ sendJson(res, 200, { ok: true });
16522
+ } catch (error) {
16523
+ sendHttpError(res, error);
16524
+ }
16525
+ return true;
16526
+ }
16527
+ const wolfpackMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/wolfpack$`).exec(url);
16528
+ if (wolfpackMatch && method === "POST") {
16529
+ try {
16530
+ const enabled = optionalBoolean(await readJsonBody(req), "enabled", true);
16531
+ await manager.setWolfpackMode(decodeURIComponent(wolfpackMatch[1]), enabled);
16532
+ sendJson(res, 200, { ok: true });
16533
+ } catch (error) {
16534
+ sendHttpError(res, error);
16535
+ }
16536
+ return true;
16537
+ }
16538
+ const rlmMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/rlm$`).exec(url);
16539
+ if (rlmMatch && method === "POST") {
16540
+ try {
16541
+ const body = await readJsonBody(req);
16542
+ const enabled = optionalBoolean(body, "enabled", true);
16543
+ const maxDepth = typeof body["maxDepth"] === "number" ? body["maxDepth"] : void 0;
16544
+ await manager.setRlm(decodeURIComponent(rlmMatch[1]), enabled, maxDepth);
16545
+ sendJson(res, 200, { ok: true });
16546
+ } catch (error) {
16547
+ sendHttpError(res, error);
16548
+ }
16549
+ return true;
16550
+ }
16551
+ const undoMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/undo$`).exec(url);
16552
+ if (undoMatch && method === "POST") {
16553
+ try {
16554
+ const body = await readJsonBody(req);
16555
+ const count = typeof body["count"] === "number" ? body["count"] : 1;
16556
+ await manager.undoHistory(decodeURIComponent(undoMatch[1]), count);
16557
+ sendJson(res, 200, { ok: true });
16558
+ } catch (error) {
16559
+ sendHttpError(res, error);
16560
+ }
16561
+ return true;
16562
+ }
16563
+ const compactMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/compact$`).exec(url);
16564
+ if (compactMatch && method === "POST") {
16565
+ try {
16566
+ const body = await readJsonBody(req);
16567
+ await manager.compact(decodeURIComponent(compactMatch[1]), optionalString(body, "instruction"));
16568
+ sendJson(res, 200, { ok: true });
16569
+ } catch (error) {
16570
+ sendHttpError(res, error);
16571
+ }
16572
+ return true;
16573
+ }
16574
+ return false;
16575
+ }
16576
+ async function handleResourceRoutes(req, res, url, method, manager) {
16577
+ const skillsMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/skills$`).exec(url);
16578
+ if (skillsMatch && method === "GET") {
16579
+ try {
16580
+ sendJson(res, 200, await manager.listSkills(decodeURIComponent(skillsMatch[1])));
16581
+ } catch (error) {
16582
+ sendHttpError(res, error);
16583
+ }
16584
+ return true;
16585
+ }
16586
+ const skillActivateMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/skills/([^/]+)/activate$`).exec(url);
16587
+ if (skillActivateMatch && method === "POST") {
16588
+ try {
16589
+ const body = await readJsonBody(req);
16590
+ await manager.activateSkill(decodeURIComponent(skillActivateMatch[1]), decodeURIComponent(skillActivateMatch[2]), optionalString(body, "args"));
16591
+ sendJson(res, 200, { ok: true });
16592
+ } catch (error) {
16593
+ sendHttpError(res, error);
16594
+ }
16595
+ return true;
16596
+ }
16597
+ const skillRemoveMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/skills/([^/]+)$`).exec(url);
16598
+ if (skillRemoveMatch && method === "DELETE") {
16599
+ try {
16600
+ await manager.removeSkill(decodeURIComponent(skillRemoveMatch[1]), decodeURIComponent(skillRemoveMatch[2]));
16601
+ sendJson(res, 200, { ok: true });
16602
+ } catch (error) {
16603
+ sendHttpError(res, error);
16604
+ }
16605
+ return true;
16606
+ }
16607
+ const pluginsMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/plugins$`).exec(url);
16608
+ if (pluginsMatch && method === "GET") {
16609
+ try {
16610
+ sendJson(res, 200, await manager.listPlugins(decodeURIComponent(pluginsMatch[1])));
16611
+ } catch (error) {
16612
+ sendHttpError(res, error);
16613
+ }
16614
+ return true;
16615
+ }
16616
+ const pluginInstallMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/plugins/install$`).exec(url);
16617
+ if (pluginInstallMatch && method === "POST") {
16618
+ try {
16619
+ const body = await readJsonBody(req);
16620
+ sendJson(res, 200, await manager.installPlugin(decodeURIComponent(pluginInstallMatch[1]), requiredString(body, "source")));
16621
+ } catch (error) {
16622
+ sendHttpError(res, error);
16623
+ }
16624
+ return true;
16625
+ }
16626
+ const pluginReloadMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/plugins/reload$`).exec(url);
16627
+ if (pluginReloadMatch && method === "POST") {
16628
+ try {
16629
+ sendJson(res, 200, await manager.reloadPlugins(decodeURIComponent(pluginReloadMatch[1])));
16630
+ } catch (error) {
16631
+ sendHttpError(res, error);
16632
+ }
16633
+ return true;
16634
+ }
16635
+ const pluginEnableMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/plugins/([^/]+)/enable$`).exec(url);
16636
+ if (pluginEnableMatch && method === "POST") {
16637
+ try {
16638
+ const body = await readJsonBody(req);
16639
+ await manager.setPluginEnabled(decodeURIComponent(pluginEnableMatch[1]), decodeURIComponent(pluginEnableMatch[2]), optionalBoolean(body, "enabled", true));
16640
+ sendJson(res, 200, { ok: true });
16641
+ } catch (error) {
16642
+ sendHttpError(res, error);
16643
+ }
16644
+ return true;
16645
+ }
16646
+ const pluginMcpEnableMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/plugins/([^/]+)/mcp/([^/]+)/enable$`).exec(url);
16647
+ if (pluginMcpEnableMatch && method === "POST") {
16648
+ try {
16649
+ const body = await readJsonBody(req);
16650
+ await manager.setPluginMcpServerEnabled(decodeURIComponent(pluginMcpEnableMatch[1]), decodeURIComponent(pluginMcpEnableMatch[2]), decodeURIComponent(pluginMcpEnableMatch[3]), optionalBoolean(body, "enabled", true));
16651
+ sendJson(res, 200, { ok: true });
16652
+ } catch (error) {
16653
+ sendHttpError(res, error);
16654
+ }
16655
+ return true;
16656
+ }
16657
+ const pluginActivateMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/plugins/([^/]+)/activate$`).exec(url);
16658
+ if (pluginActivateMatch && method === "POST") {
16659
+ try {
16660
+ await manager.activatePlugin(decodeURIComponent(pluginActivateMatch[1]), decodeURIComponent(pluginActivateMatch[2]));
16661
+ sendJson(res, 200, { ok: true });
16662
+ } catch (error) {
16663
+ sendHttpError(res, error);
16664
+ }
16665
+ return true;
16666
+ }
16667
+ const pluginDeactivateMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/plugins/([^/]+)/deactivate$`).exec(url);
16668
+ if (pluginDeactivateMatch && method === "POST") {
16669
+ try {
16670
+ await manager.deactivatePlugin(decodeURIComponent(pluginDeactivateMatch[1]), decodeURIComponent(pluginDeactivateMatch[2]));
16671
+ sendJson(res, 200, { ok: true });
16672
+ } catch (error) {
16673
+ sendHttpError(res, error);
16674
+ }
16675
+ return true;
16676
+ }
16677
+ const pluginInjectMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/plugins/([^/]+)/inject$`).exec(url);
16678
+ if (pluginInjectMatch && method === "POST") {
16679
+ try {
16680
+ await manager.injectPlugin(decodeURIComponent(pluginInjectMatch[1]), decodeURIComponent(pluginInjectMatch[2]));
16681
+ sendJson(res, 200, { ok: true });
16682
+ } catch (error) {
16683
+ sendHttpError(res, error);
16684
+ }
16685
+ return true;
16686
+ }
16687
+ const pluginInfoMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/plugins/(?!(?:install|reload)$)([^/]+)$`).exec(url);
16688
+ if (pluginInfoMatch && method === "GET") {
16689
+ try {
16690
+ sendJson(res, 200, await manager.getPluginInfo(decodeURIComponent(pluginInfoMatch[1]), decodeURIComponent(pluginInfoMatch[2])));
16691
+ } catch (error) {
16692
+ sendHttpError(res, error);
16693
+ }
16694
+ return true;
16695
+ }
16696
+ if (pluginInfoMatch && method === "DELETE") {
16697
+ try {
16698
+ await manager.removePlugin(decodeURIComponent(pluginInfoMatch[1]), decodeURIComponent(pluginInfoMatch[2]));
16699
+ sendJson(res, 200, { ok: true });
16700
+ } catch (error) {
16701
+ sendHttpError(res, error);
16702
+ }
16703
+ return true;
16704
+ }
16705
+ const mcpMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/mcp$`).exec(url);
16706
+ if (mcpMatch && method === "GET") {
16707
+ try {
16708
+ sendJson(res, 200, await manager.listMcpServers(decodeURIComponent(mcpMatch[1])));
16709
+ } catch (error) {
16710
+ sendHttpError(res, error);
16711
+ }
16712
+ return true;
16713
+ }
16714
+ const mcpMetricsMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/mcp/startup-metrics$`).exec(url);
16715
+ if (mcpMetricsMatch && method === "GET") {
16716
+ try {
16717
+ sendJson(res, 200, await manager.getMcpStartupMetrics(decodeURIComponent(mcpMetricsMatch[1])));
16718
+ } catch (error) {
16719
+ sendHttpError(res, error);
16720
+ }
16721
+ return true;
16722
+ }
16723
+ const mcpAddMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/mcp/add$`).exec(url);
16724
+ if (mcpAddMatch && method === "POST") {
16725
+ try {
16726
+ const body = await readJsonBody(req);
16727
+ await manager.addMcpServer(decodeURIComponent(mcpAddMatch[1]), requiredString(body, "name"), body["config"] ?? {});
16728
+ sendJson(res, 200, { ok: true });
16729
+ } catch (error) {
16730
+ sendHttpError(res, error);
16731
+ }
16732
+ return true;
16733
+ }
16734
+ const mcpReconnectMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/mcp/([^/]+)/reconnect$`).exec(url);
16735
+ if (mcpReconnectMatch && method === "POST") {
16736
+ try {
16737
+ await manager.reconnectMcpServer(decodeURIComponent(mcpReconnectMatch[1]), decodeURIComponent(mcpReconnectMatch[2]));
16738
+ sendJson(res, 200, { ok: true });
16739
+ } catch (error) {
16740
+ sendHttpError(res, error);
16741
+ }
16742
+ return true;
16743
+ }
16744
+ const mcpStopMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/mcp/([^/]+)/stop$`).exec(url);
16745
+ if (mcpStopMatch && method === "POST") {
16746
+ try {
16747
+ await manager.stopMcpServer(decodeURIComponent(mcpStopMatch[1]), decodeURIComponent(mcpStopMatch[2]));
16748
+ sendJson(res, 200, { ok: true });
16749
+ } catch (error) {
16750
+ sendHttpError(res, error);
16751
+ }
16752
+ return true;
16753
+ }
16754
+ const mcpRemoveMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/mcp/(?!(?:add|reconnect|stop|startup-metrics)$)([^/]+)$`).exec(url);
16755
+ if (mcpRemoveMatch && method === "DELETE") {
16756
+ try {
16757
+ await manager.removeMcpServer(decodeURIComponent(mcpRemoveMatch[1]), decodeURIComponent(mcpRemoveMatch[2]));
16758
+ sendJson(res, 200, { ok: true });
16759
+ } catch (error) {
16760
+ sendHttpError(res, error);
16761
+ }
16762
+ return true;
16763
+ }
16764
+ const pathname = url.split("?")[0] ?? "/";
16765
+ const tasksMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/tasks$`).exec(pathname);
16766
+ if (tasksMatch && method === "GET") {
16767
+ try {
16768
+ const query = new URLSearchParams(url.split("?")[1] ?? "");
16769
+ const activeOnly = query.get("activeOnly") === "true" ? true : query.get("activeOnly") === "false" ? false : void 0;
16770
+ const limit = query.get("limit") ? Number(query.get("limit")) : void 0;
16771
+ sendJson(res, 200, await manager.listBackgroundTasks(decodeURIComponent(tasksMatch[1]), activeOnly, limit));
16772
+ } catch (error) {
16773
+ sendHttpError(res, error);
16774
+ }
16775
+ return true;
16776
+ }
16777
+ const taskOutputMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/tasks/([^/]+)/output$`).exec(pathname);
16778
+ if (taskOutputMatch && method === "GET") {
16779
+ try {
16780
+ const query = new URLSearchParams(url.split("?")[1] ?? "");
16781
+ const tail = query.get("tail") ? Number(query.get("tail")) : void 0;
16782
+ sendJson(res, 200, { output: await manager.getBackgroundTaskOutput(decodeURIComponent(taskOutputMatch[1]), decodeURIComponent(taskOutputMatch[2]), tail) });
16783
+ } catch (error) {
16784
+ sendHttpError(res, error);
16785
+ }
16786
+ return true;
16787
+ }
16788
+ const taskStopMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/tasks/([^/]+)/stop$`).exec(url);
16789
+ if (taskStopMatch && method === "POST") {
16790
+ try {
16791
+ const body = await readJsonBody(req);
16792
+ await manager.stopBackgroundTask(decodeURIComponent(taskStopMatch[1]), decodeURIComponent(taskStopMatch[2]), optionalString(body, "reason"));
16793
+ sendJson(res, 200, { ok: true });
16794
+ } catch (error) {
16795
+ sendHttpError(res, error);
16796
+ }
16797
+ return true;
16798
+ }
16799
+ return false;
16800
+ }
16801
+ async function handleGlobalRoutes(req, res, url, method, manager) {
16802
+ if (url === `${API_PREFIX}/config` && method === "GET") {
16803
+ try {
16804
+ sendJson(res, 200, await manager.getConfig());
16805
+ } catch (error) {
16806
+ sendHttpError(res, error);
16807
+ }
16808
+ return true;
16809
+ }
16810
+ if (url === `${API_PREFIX}/config` && method === "POST") {
16811
+ try {
16812
+ const patch = (await readJsonBody(req))["patch"];
16813
+ if (patch === null || typeof patch !== "object" || Array.isArray(patch)) throw new HttpError(400, "Missing or invalid patch field", "request.invalid");
16814
+ sendJson(res, 200, await manager.setConfig(patch));
16815
+ } catch (error) {
16816
+ sendHttpError(res, error);
16817
+ }
16818
+ return true;
16819
+ }
16820
+ const providerMatch = new RegExp(`^${API_PREFIX}/config/providers/([^/]+)$`).exec(url);
16821
+ if (providerMatch && method === "DELETE") {
16822
+ try {
16823
+ sendJson(res, 200, await manager.removeProvider(decodeURIComponent(providerMatch[1])));
16824
+ } catch (error) {
16825
+ sendHttpError(res, error);
16826
+ }
16827
+ return true;
16828
+ }
16829
+ if (url === `${API_PREFIX}/experimental-flags` && method === "GET") {
16830
+ try {
16831
+ sendJson(res, 200, await manager.getExperimentalFlags());
16832
+ } catch (error) {
16833
+ sendHttpError(res, error);
16834
+ }
16835
+ return true;
16836
+ }
16837
+ if (url === `${API_PREFIX}/preflight` && method === "GET") {
16838
+ try {
16839
+ await manager.preflight();
16840
+ sendJson(res, 200, { ok: true });
16841
+ } catch (error) {
16842
+ sendHttpError(res, error);
16843
+ }
16844
+ return true;
16845
+ }
16846
+ return false;
16847
+ }
16256
16848
  async function runWebServer(opts) {
16257
16849
  const homeDir = resolveNexumHome();
16258
16850
  const workDir = opts.workDir;
@@ -16363,6 +16955,9 @@ async function runWebServer(opts) {
16363
16955
  return;
16364
16956
  }
16365
16957
  if (await handleGoalRoute(req, res, url, (sessionId) => manager.get(sessionId))) return;
16958
+ if (await handleSessionControlRoutes(req, res, url, method, manager)) return;
16959
+ if (await handleResourceRoutes(req, res, url, method, manager)) return;
16960
+ if (await handleGlobalRoutes(req, res, url, method, manager)) return;
16366
16961
  const snapshotMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/snapshot(\\?|$)`).exec(url);
16367
16962
  if (snapshotMatch && method === "GET") {
16368
16963
  const sessionId = decodeURIComponent(snapshotMatch[1]);