@chatcode/chatcode-cli 3.0.5-rc.3 → 3.0.5-rc.4

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 (34) hide show
  1. package/README.md +2 -0
  2. package/README.zh.md +2 -0
  3. package/lib/{command-errors-ChiY9aSU.js → command-errors-Dy38dE7J.js} +12 -12
  4. package/lib/{command-trees-D1yNnMLf.js → command-trees-CyZU9OgJ.js} +2 -2
  5. package/lib/{component-identity-BXmlpdls.js → component-identity-DXrrXp1z.js} +3 -3
  6. package/lib/{extension-events-BBvUPMbs.js → extension-events-DGLD0QXk.js} +20 -20
  7. package/lib/{host-access-DCtUmgis.js → host-access-DXxSOjq9.js} +1 -1
  8. package/lib/{keymap-CeRpxc9c.js → keymap-BfegLkpv.js} +2 -2
  9. package/lib/{plugin-DQAJoZvM.js → plugin-BOeJiplQ.js} +547 -550
  10. package/lib/{scenes-NsR-REtH.js → scenes-CMbv2mIB.js} +3 -3
  11. package/lib/{settings-sections-DgB-eDtZ.js → settings-sections-iiyY7jD8.js} +3 -3
  12. package/lib/{statusBarSettings-5yzdiOv1.js → statusBarSettings-BSQLLAKO.js} +3 -3
  13. package/lib/{themes-DpFOCFEc.js → themes-DwpCTrf5.js} +12 -12
  14. package/lib/tui-compat-command-trees.js +1 -1
  15. package/lib/tui-compat-extensions.js +3 -3
  16. package/lib/tui-compat-plugin-host.js +5 -5
  17. package/lib/tui-compat-scenes.js +1 -1
  18. package/lib/tui-compat-settings-sections.js +1 -1
  19. package/lib/tui-compat-working-activity.js +1 -1
  20. package/lib/tui-compat-workspaces.js +1 -1
  21. package/lib/tui-compat.js +5 -5
  22. package/lib/{workspaces-CVtLIC34.js → workspaces-D1_eegCv.js} +2 -2
  23. package/package.json +20 -20
  24. package/runtime/manifest.json +1 -1
  25. package/runtime/node_modules/@deepseek-ai/dsh-api-remotes/lib/client.js +19 -19
  26. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/index.js +86 -2
  27. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/typert.host.js +19 -19
  28. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/typert.remote-client.js +19 -19
  29. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/agent.d.ts +31 -0
  30. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/agent.js +81 -0
  31. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/index.js +20 -2
  32. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-account/lib/client.js +2 -2
  33. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-general/lib/client.js +1 -1
  34. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
@@ -1,7 +1,7 @@
1
- import { a as compositionRoot, i as bindCallerEffect, n as activationFiber, o as concreteService, s as requirePluginCaller } from "./host-access-DCtUmgis.js";
2
- import { n as componentIdentityOf } from "./component-identity-BXmlpdls.js";
1
+ import { a as compositionRoot, i as bindCallerEffect, n as activationFiber, o as concreteService, s as requirePluginCaller } from "./host-access-DXxSOjq9.js";
2
+ import { n as componentIdentityOf } from "./component-identity-DXrrXp1z.js";
3
3
  import { Service } from "@deepseek-ai/cordis";
4
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/scenes.js
4
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/scenes.js
5
5
  /** Provider-neutral full-screen scene registry for terminal front doors. */
6
6
  const name = "dsh-tui-scenes";
7
7
  /**
@@ -1,6 +1,6 @@
1
- import { a as compositionRoot, i as bindCallerEffect, n as activationFiber, o as concreteService, s as requirePluginCaller } from "./host-access-DCtUmgis.js";
1
+ import { a as compositionRoot, i as bindCallerEffect, n as activationFiber, o as concreteService, s as requirePluginCaller } from "./host-access-DXxSOjq9.js";
2
2
  import { Service } from "@deepseek-ai/cordis";
3
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/credentialRefGuard.js
3
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/credentialRefGuard.js
4
4
  /**
5
5
  * Credential-ref reservation guard for the plugin settings-section seam.
6
6
  *
@@ -49,7 +49,7 @@ function vetSectionSecretRefs(section) {
49
49
  };
50
50
  }
51
51
  //#endregion
52
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/settings-sections.js
52
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/settings-sections.js
53
53
  /**
54
54
  * Plugin settings-section extension seam for terminal front doors.
55
55
  *
@@ -1,5 +1,5 @@
1
1
  import Schema from "@deepseek-ai/schemastery";
2
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/settingsCompat.js
2
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/settingsCompat.js
3
3
  /** Mark display fields editable on hosts that support volatile Config references. */
4
4
  function withLiveSettings(schema, fields) {
5
5
  for (const key of fields) {
@@ -43,7 +43,7 @@ function settingsValue(settings, ns) {
43
43
  return descriptor && "value" in descriptor ? descriptor.value : settings.get?.(ns);
44
44
  }
45
45
  //#endregion
46
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/tuiDisplayPrefs.js
46
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/tuiDisplayPrefs.js
47
47
  /** Default footer shows account-wide tokens today and current context usage. */
48
48
  const DEFAULT_STATUS_BAR = Object.freeze({
49
49
  compact: true,
@@ -203,7 +203,7 @@ function applyPageMargin(setting) {
203
203
  return next;
204
204
  }
205
205
  //#endregion
206
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/statusBarSettings.js
206
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/statusBarSettings.js
207
207
  /** Shared status-footer settings declarations and validation. */
208
208
  /**
209
209
  * Build the complete footer schema for both composition and live settings.
@@ -1,12 +1,12 @@
1
- import { c as parseCombo, i as comboMatchesStrict, r as canonicalCombo, s as fixedReservedCombos, u as reservedActionCombos } from "./keymap-CeRpxc9c.js";
2
- import { a as compositionRoot, i as bindCallerEffect, n as activationFiber, o as concreteService, r as assertCallerContext, s as requirePluginCaller, t as activationContext } from "./host-access-DCtUmgis.js";
3
- import { n as componentIdentityOf } from "./component-identity-BXmlpdls.js";
4
- import { S as DATA_DIR, f as cleanRenderText, p as cleanScalarText } from "./extension-events-BBvUPMbs.js";
1
+ import { c as parseCombo, i as comboMatchesStrict, r as canonicalCombo, s as fixedReservedCombos, u as reservedActionCombos } from "./keymap-BfegLkpv.js";
2
+ import { a as compositionRoot, i as bindCallerEffect, n as activationFiber, o as concreteService, r as assertCallerContext, s as requirePluginCaller, t as activationContext } from "./host-access-DXxSOjq9.js";
3
+ import { n as componentIdentityOf } from "./component-identity-DXrrXp1z.js";
4
+ import { S as DATA_DIR, f as cleanRenderText, p as cleanScalarText } from "./extension-events-DGLD0QXk.js";
5
5
  import { readFileSync, readdirSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  import { Context, Service } from "@deepseek-ai/cordis";
8
8
  import { KNOWN_SESSION_EVENT_TYPES } from "@deepseek-ai/dsh-session";
9
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/dialogs.js
9
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/dialogs.js
10
10
  /**
11
11
  * Managed plugin dialogs — the pi `ctx.ui.select/confirm/input` seam for
12
12
  * ChatCode CLI TUI. Plugins hand the HOST a declarative request; the TUI renders the
@@ -279,7 +279,7 @@ function getHostDialogStore(runtime) {
279
279
  }
280
280
  }
281
281
  //#endregion
282
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/status.js
282
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/status.js
283
283
  /**
284
284
  * Keyed status-line contributions — pi's `ctx.ui.setStatus(key, text)`.
285
285
  * Each plugin owns a key; setting text shows it, setting undefined clears
@@ -503,7 +503,7 @@ function getHostStatusStore(runtime) {
503
503
  }
504
504
  }
505
505
  //#endregion
506
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/shortcuts.js
506
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/shortcuts.js
507
507
  /**
508
508
  * Plugin keyboard shortcuts — pi's `pi.registerShortcut`. A plugin binds a
509
509
  * combo (`ctrl+shift+p`, `alt+k`, …) to a handler; the chat screen matches
@@ -704,7 +704,7 @@ function getHostShortcuts(runtime) {
704
704
  }
705
705
  }
706
706
  //#endregion
707
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/renderers.js
707
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/renderers.js
708
708
  /**
709
709
  * Custom session-entry renderers — pi's `pi.registerMessageRenderer`. A
710
710
  * plugin that appends its own log-only session events (`session.append(
@@ -876,7 +876,7 @@ function getHostRenderers(runtime) {
876
876
  }
877
877
  }
878
878
  //#endregion
879
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/toast.js
879
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/toast.js
880
880
  /**
881
881
  * Plugin-facing transient notifications — a fire-and-forget toast shown on
882
882
  * the host's existing notification surface (the same toasts the channel
@@ -1011,7 +1011,7 @@ function getHostToastStore(runtime) {
1011
1011
  }
1012
1012
  }
1013
1013
  //#endregion
1014
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/theme.js
1014
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/theme.js
1015
1015
  /**
1016
1016
  * dsh-tui color themes — ChatCode CLI terminal family.
1017
1017
  *
@@ -1486,7 +1486,7 @@ function getActiveTheme() {
1486
1486
  return getTheme(activeThemeName);
1487
1487
  }
1488
1488
  //#endregion
1489
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/customTheme.js
1489
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/customTheme.js
1490
1490
  /**
1491
1491
  * User-defined color themes for dsh-tui.
1492
1492
  *
@@ -1716,7 +1716,7 @@ function indexCustomThemeNames() {
1716
1716
  nameIndexed = true;
1717
1717
  }
1718
1718
  //#endregion
1719
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/themes.js
1719
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/themes.js
1720
1720
  /**
1721
1721
  * Cordis-backed runtime theme contributions.
1722
1722
  *
@@ -1,2 +1,2 @@
1
- import { r as name, t as TuiCommandTreeRuntime } from "./command-trees-D1yNnMLf.js";
1
+ import { r as name, t as TuiCommandTreeRuntime } from "./command-trees-CyZU9OgJ.js";
2
2
  export { TuiCommandTreeRuntime, TuiCommandTreeRuntime as default, name };
@@ -1,9 +1,9 @@
1
- import { a as normalizeCancelDecision, c as installDecisionGuard, n as DECISION_TOTAL_TIMEOUT_MS, o as DECISION_EVENT_PERMISSIONS, t as DECISION_HANDLER_TIMEOUT_MS, x as readGrantStore } from "./extension-events-BBvUPMbs.js";
2
- import { A as TuiDialogRuntime, C as matchShortcut, D as getHostStatusStore, E as TuiStatusStore, O as DIALOG_DEFAULT_TIMEOUT_MS, T as TuiStatusRuntime, _ as TuiToastRuntime, j as TuiDialogStore, k as INPUT_CELLS, t as TuiThemeRuntime, w as parseShortcutCombo, x as TuiShortcutRuntime, y as TuiRendererRuntime } from "./themes-DpFOCFEc.js";
1
+ import { a as normalizeCancelDecision, c as installDecisionGuard, n as DECISION_TOTAL_TIMEOUT_MS, o as DECISION_EVENT_PERMISSIONS, t as DECISION_HANDLER_TIMEOUT_MS, x as readGrantStore } from "./extension-events-DGLD0QXk.js";
2
+ import { A as TuiDialogRuntime, C as matchShortcut, D as getHostStatusStore, E as TuiStatusStore, O as DIALOG_DEFAULT_TIMEOUT_MS, T as TuiStatusRuntime, _ as TuiToastRuntime, j as TuiDialogStore, k as INPUT_CELLS, t as TuiThemeRuntime, w as parseShortcutCombo, x as TuiShortcutRuntime, y as TuiRendererRuntime } from "./themes-DwpCTrf5.js";
3
3
  import { appendFileSync, mkdirSync } from "node:fs";
4
4
  import { homedir } from "node:os";
5
5
  import { dirname, join } from "node:path";
6
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/extensions.js
6
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/extensions.js
7
7
  /**
8
8
  * The dsh-tui-extensions row: mounts every plugin-facing UI seam service in
9
9
  * one cordis plugin (one profile row, one patch-surface entry — see issue
@@ -1,10 +1,10 @@
1
- import { a as compositionRoot, i as bindCallerEffect, n as activationFiber, o as concreteService, r as assertCallerContext, t as activationContext } from "./host-access-DCtUmgis.js";
2
- import { c as requiresDecisionEvents, o as requireComponentIdentity, r as declaresCommand, s as requiresContract, t as bindComponentIdentity } from "./component-identity-BXmlpdls.js";
3
- import { B as createAdmissionCatalog, F as verifyRegistry, I as DECISION_EVENTS_COORDINATE, J as parseManifest, L as TUI_DECISION_EVENT_NAMES, M as loadSpecData, P as verifyContractProfiles, R as TUI_EXTENSION_API_VERSION, Y as projectManifest, c as installDecisionGuard, l as registerDecisionHandler, n as DECISION_TOTAL_TIMEOUT_MS, o as DECISION_EVENT_PERMISSIONS, s as decisionHandlerMetadataOf, t as DECISION_HANDLER_TIMEOUT_MS, u as withDecisionRegistration, x as readGrantStore, z as TUI_EXTENSION_PERMISSION_NAMES } from "./extension-events-BBvUPMbs.js";
4
- import { A as validatePlugin, C as TuiPluginStorageRuntime, D as buildHostDescriptor, E as HOST_SUPPORTED_CONTRACTS, O as negotiate, S as STORAGE_MAX_KEYS, T as TuiEffectLedgerRuntime, b as STORAGE_KEY_MAX_LENGTH, c as OBSERVE_CALLBACK_QUEUE_LIMIT, d as OBSERVE_ID_MAX_CHARS, f as OBSERVE_IMAGE_BASE64_MAX_CHARS, g as TuiMessageObserverRuntime, h as OBSERVE_SUMMARY_CELLS, i as withCommandErrorMapping, k as createContractIndex, l as OBSERVE_CALLBACK_TIMEOUT_MS, m as OBSERVE_SCOPE_MAX_CHARS, n as hasCommandErrorCode, o as stampCommandOwner, p as OBSERVE_IMAGE_MAX_BYTES, r as mapCommandError, s as unstampCommandOwner, t as COMMAND_ERROR_CODES, u as OBSERVE_CONTENT_MAX_CHARS, x as STORAGE_MAX_BYTES, y as PluginStorageError } from "./command-errors-ChiY9aSU.js";
1
+ import { a as compositionRoot, i as bindCallerEffect, n as activationFiber, o as concreteService, r as assertCallerContext, t as activationContext } from "./host-access-DXxSOjq9.js";
2
+ import { c as requiresDecisionEvents, o as requireComponentIdentity, r as declaresCommand, s as requiresContract, t as bindComponentIdentity } from "./component-identity-DXrrXp1z.js";
3
+ import { B as createAdmissionCatalog, F as verifyRegistry, I as DECISION_EVENTS_COORDINATE, J as parseManifest, L as TUI_DECISION_EVENT_NAMES, M as loadSpecData, P as verifyContractProfiles, R as TUI_EXTENSION_API_VERSION, Y as projectManifest, c as installDecisionGuard, l as registerDecisionHandler, n as DECISION_TOTAL_TIMEOUT_MS, o as DECISION_EVENT_PERMISSIONS, s as decisionHandlerMetadataOf, t as DECISION_HANDLER_TIMEOUT_MS, u as withDecisionRegistration, x as readGrantStore, z as TUI_EXTENSION_PERMISSION_NAMES } from "./extension-events-DGLD0QXk.js";
4
+ import { A as validatePlugin, C as TuiPluginStorageRuntime, D as buildHostDescriptor, E as HOST_SUPPORTED_CONTRACTS, O as negotiate, S as STORAGE_MAX_KEYS, T as TuiEffectLedgerRuntime, b as STORAGE_KEY_MAX_LENGTH, c as OBSERVE_CALLBACK_QUEUE_LIMIT, d as OBSERVE_ID_MAX_CHARS, f as OBSERVE_IMAGE_BASE64_MAX_CHARS, g as TuiMessageObserverRuntime, h as OBSERVE_SUMMARY_CELLS, i as withCommandErrorMapping, k as createContractIndex, l as OBSERVE_CALLBACK_TIMEOUT_MS, m as OBSERVE_SCOPE_MAX_CHARS, n as hasCommandErrorCode, o as stampCommandOwner, p as OBSERVE_IMAGE_MAX_BYTES, r as mapCommandError, s as unstampCommandOwner, t as COMMAND_ERROR_CODES, u as OBSERVE_CONTENT_MAX_CHARS, x as STORAGE_MAX_BYTES, y as PluginStorageError } from "./command-errors-Dy38dE7J.js";
5
5
  import { randomUUID } from "node:crypto";
6
6
  import { Context, Service } from "@deepseek-ai/cordis";
7
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/plugin-host.js
7
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/plugin-host.js
8
8
  /**
9
9
  * The dsh-tui-plugin-host row: the plugin-interop anchor every later
10
10
  * contract surface hangs off (storage.local, messages.observe, effect
@@ -1,2 +1,2 @@
1
- import { r as name, t as TuiSceneRuntime } from "./scenes-NsR-REtH.js";
1
+ import { r as name, t as TuiSceneRuntime } from "./scenes-CMbv2mIB.js";
2
2
  export { TuiSceneRuntime, TuiSceneRuntime as default, name };
@@ -1,2 +1,2 @@
1
- import { i as name, t as TuiSettingsSectionsRuntime } from "./settings-sections-DgB-eDtZ.js";
1
+ import { i as name, t as TuiSettingsSectionsRuntime } from "./settings-sections-iiyY7jD8.js";
2
2
  export { TuiSettingsSectionsRuntime, TuiSettingsSectionsRuntime as default, name };
@@ -235,7 +235,7 @@ function apply$1(ctx, config = {}) {
235
235
  }, "working-activity tick timer");
236
236
  }
237
237
  //#endregion
238
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/working-activity.js
238
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/working-activity.js
239
239
  /**
240
240
  * Re-export of the `dsh-working-activity` plugin under this package's own
241
241
  * name, so the bundle patch layer can mount the working-activity row as
@@ -1,2 +1,2 @@
1
- import { a as localWorkspaceUri, n as WORKSPACE_PROVIDER_TIMEOUT_MS, o as name, r as createLocalWorkspaceRuntime, s as parseLocalWorkspaceReference, t as TuiWorkspaceRuntime } from "./workspaces-CVtLIC34.js";
1
+ import { a as localWorkspaceUri, n as WORKSPACE_PROVIDER_TIMEOUT_MS, o as name, r as createLocalWorkspaceRuntime, s as parseLocalWorkspaceReference, t as TuiWorkspaceRuntime } from "./workspaces-D1_eegCv.js";
2
2
  export { TuiWorkspaceRuntime, TuiWorkspaceRuntime as default, WORKSPACE_PROVIDER_TIMEOUT_MS, createLocalWorkspaceRuntime, localWorkspaceUri, name, parseLocalWorkspaceReference };
package/lib/tui-compat.js CHANGED
@@ -1,7 +1,7 @@
1
- import { c as normalizePageMargin, g as liveConfigValues, n as createStatusBarSchema, v as withLiveSettings } from "./statusBarSettings-5yzdiOv1.js";
2
- import { t as SHORTCUT_ACTIONS } from "./keymap-CeRpxc9c.js";
1
+ import { c as normalizePageMargin, g as liveConfigValues, n as createStatusBarSchema, v as withLiveSettings } from "./statusBarSettings-BSQLLAKO.js";
2
+ import { t as SHORTCUT_ACTIONS } from "./keymap-BfegLkpv.js";
3
3
  import Schema from "@deepseek-ai/schemastery";
4
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/force-production-react.js
4
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/force-production-react.js
5
5
  /**
6
6
  * React-reconciler selects its dev/production build at require time from
7
7
  * NODE_ENV; the dev build records one performance.measure() per render into
@@ -14,7 +14,7 @@ import Schema from "@deepseek-ai/schemastery";
14
14
  */
15
15
  process.env.NODE_ENV ??= "production";
16
16
  //#endregion
17
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/index.js
17
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/index.js
18
18
  /**
19
19
  * dsh-tui plugin entry. The TUI implementation lives in `./plugin.tsx` (its
20
20
  * render path is JSX); this module owns the plugin surface (`name`/`inject`/
@@ -101,7 +101,7 @@ const Config$1 = withLiveSettings(Schema.object({
101
101
  * @returns a promise settling when the TUI teardown completes.
102
102
  */
103
103
  async function apply(ctx, config) {
104
- const { apply: ccTuiApply } = await import("./plugin-DQAJoZvM.js");
104
+ const { apply: ccTuiApply } = await import("./plugin-BOeJiplQ.js");
105
105
  return ccTuiApply(ctx, liveConfigValues(config));
106
106
  }
107
107
  //#endregion
@@ -1,8 +1,8 @@
1
- import { a as compositionRoot, i as bindCallerEffect, n as activationFiber, o as concreteService, s as requirePluginCaller } from "./host-access-DCtUmgis.js";
1
+ import { a as compositionRoot, i as bindCallerEffect, n as activationFiber, o as concreteService, s as requirePluginCaller } from "./host-access-DXxSOjq9.js";
2
2
  import { fileURLToPath, pathToFileURL } from "node:url";
3
3
  import { basename, isAbsolute, resolve } from "node:path";
4
4
  import { Service } from "@deepseek-ai/cordis";
5
- //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_08ea48c8555976e562c6368d51cb542b/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/workspaces.js
5
+ //#region ../../node_modules/.pnpm/@chatcode+cco-tui@0.10.0-rc.23_patch_hash=2bd0954ee58a1ef28c589c9110366e2ee36e13c10f316_4a63a887e34dadc12f889ca405477528/node_modules/@chatcode/cco-tui/lib/types/dsh-adapter/workspaces.js
6
6
  /**
7
7
  * Workspace-target extension seam for terminal front doors.
8
8
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chatcode/chatcode-cli",
3
3
  "description": "ChatCode CLI: TUI-first coding agent, Web launcher, profiles, and legacy DSH-compatible plugins",
4
- "version": "3.0.5-rc.3",
4
+ "version": "3.0.5-rc.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -95,47 +95,47 @@
95
95
  "ajv": "^8.20.0",
96
96
  "execa": "^10.0.0",
97
97
  "ws": "8.21.0",
98
- "@deepseek-ai/dsh-acp": "0.1.7-rc.2",
99
98
  "@deepseek-ai/dsh-agent": "0.1.7-rc.2",
100
99
  "@deepseek-ai/dsh-agent-loop": "0.1.7-rc.2",
101
- "@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.1.7-rc.2",
100
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.1.7-rc.2",
101
+ "@deepseek-ai/dsh-attachment-local": "0.1.7-rc.2",
102
102
  "@deepseek-ai/dsh-bash-local": "0.1.7-rc.2",
103
+ "@deepseek-ai/dsh-credentials-local": "0.1.7-rc.2",
104
+ "@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.1.7-rc.2",
103
105
  "@deepseek-ai/dsh-experimental-agent-team": "0.1.7-rc.2",
104
106
  "@deepseek-ai/dsh-experimental-ptc-runtime-python": "0.1.7-rc.2",
105
107
  "@deepseek-ai/dsh-experimental-tool-agent-team": "0.1.7-rc.2",
106
- "@deepseek-ai/dsh-agent-loop-testkit": "0.1.7-rc.2",
107
108
  "@deepseek-ai/dsh-fs-observation-policy": "0.1.7-rc.2",
109
+ "@deepseek-ai/dsh-fs-sandbox": "0.1.7-rc.2",
108
110
  "@deepseek-ai/dsh-host-frontend-static": "0.1.7-rc.2",
109
111
  "@deepseek-ai/dsh-host-webserver": "0.1.7-rc.2",
110
- "@deepseek-ai/dsh-attachment-local": "0.1.7-rc.2",
111
112
  "@deepseek-ai/dsh-llm": "0.1.7-rc.2",
113
+ "@deepseek-ai/dsh-llm-deepseek": "0.1.7-rc.2",
112
114
  "@deepseek-ai/dsh-llm-deepseek-api-key": "0.1.7-rc.2",
113
- "@deepseek-ai/dsh-credentials-local": "0.1.7-rc.2",
114
- "@deepseek-ai/dsh-fs-sandbox": "0.1.7-rc.2",
115
+ "@deepseek-ai/dsh-llm-deepseek-account": "0.1.7-rc.2",
115
116
  "@deepseek-ai/dsh-llm-mock-server": "0.1.7-rc.2",
117
+ "@deepseek-ai/dsh-llm-pi-ai": "0.1.7-rc.2",
116
118
  "@deepseek-ai/dsh-llm-replay": "0.1.7-rc.2",
117
- "@deepseek-ai/dsh-plugin-package-inventory-deepseek": "0.1.7-rc.2",
118
- "@deepseek-ai/dsh-llm-deepseek-account": "0.1.7-rc.2",
119
119
  "@deepseek-ai/dsh-loader-smoke": "0.1.7-rc.2",
120
- "@deepseek-ai/dsh-llm-pi-ai": "0.1.7-rc.2",
121
- "@deepseek-ai/dsh-sdk-client": "0.1.7-rc.2",
122
- "@deepseek-ai/dsh-llm-deepseek": "0.1.7-rc.2",
120
+ "@deepseek-ai/dsh-plugin-package-inventory-deepseek": "0.1.7-rc.2",
123
121
  "@deepseek-ai/dsh-sandbox-local": "0.1.7-rc.2",
124
- "@deepseek-ai/dsh-session": "0.1.7-rc.2",
125
- "@deepseek-ai/dsh-session-log-deepseek": "0.1.7-rc.2",
126
- "@deepseek-ai/dsh-session-persistence-jsonl": "0.1.7-rc.2",
127
122
  "@deepseek-ai/dsh-sandbox-policy": "0.1.7-rc.2",
123
+ "@deepseek-ai/dsh-sdk-client": "0.1.7-rc.2",
128
124
  "@deepseek-ai/dsh-session-checkpoint-policy": "0.1.7-rc.2",
129
- "@deepseek-ai/dsh-subagent": "0.1.7-rc.2",
125
+ "@deepseek-ai/dsh-session-persistence-jsonl": "0.1.7-rc.2",
126
+ "@deepseek-ai/dsh-session-log-deepseek": "0.1.7-rc.2",
130
127
  "@deepseek-ai/dsh-session-query": "0.1.7-rc.2",
131
128
  "@deepseek-ai/dsh-settings": "0.1.7-rc.2",
132
- "@deepseek-ai/dsh-shell-env": "0.1.7-rc.2",
129
+ "@deepseek-ai/dsh-subagent": "0.1.7-rc.2",
133
130
  "@deepseek-ai/dsh-subagent-spawn-in-process": "0.1.7-rc.2",
134
- "@deepseek-ai/dsh-subagent-fork-in-process": "0.1.7-rc.2",
135
131
  "@deepseek-ai/dsh-subprocess-local": "0.1.7-rc.2",
136
132
  "@deepseek-ai/dsh-system-prompt": "0.1.7-rc.2",
137
- "@deepseek-ai/dsh-tools": "0.1.7-rc.2",
138
- "@deepseek-ai/dsh-user-approval": "0.1.7-rc.2"
133
+ "@deepseek-ai/dsh-acp": "0.1.7-rc.2",
134
+ "@deepseek-ai/dsh-subagent-fork-in-process": "0.1.7-rc.2",
135
+ "@deepseek-ai/dsh-user-approval": "0.1.7-rc.2",
136
+ "@deepseek-ai/dsh-shell-env": "0.1.7-rc.2",
137
+ "@deepseek-ai/dsh-session": "0.1.7-rc.2",
138
+ "@deepseek-ai/dsh-tools": "0.1.7-rc.2"
139
139
  },
140
140
  "exports": {
141
141
  "./headless-compat": {
@@ -283,5 +283,5 @@
283
283
  "@deepseek-ai/schemastery"
284
284
  ],
285
285
  "fileCount": 3624,
286
- "byteCount": 68871835
286
+ "byteCount": 68881376
287
287
  }
@@ -10809,7 +10809,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10809
10809
  },
10810
10810
  sourceLocation: {
10811
10811
  "file": "packages/api/session-controller/src/index.ts",
10812
- "line": 443,
10812
+ "line": 451,
10813
10813
  "column": 3
10814
10814
  }
10815
10815
  },
@@ -10836,7 +10836,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10836
10836
  },
10837
10837
  sourceLocation: {
10838
10838
  "file": "packages/api/session-controller/src/index.ts",
10839
- "line": 463,
10839
+ "line": 471,
10840
10840
  "column": 3
10841
10841
  }
10842
10842
  },
@@ -10854,7 +10854,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10854
10854
  },
10855
10855
  sourceLocation: {
10856
10856
  "file": "packages/api/session-controller/src/index.ts",
10857
- "line": 325,
10857
+ "line": 333,
10858
10858
  "column": 3
10859
10859
  }
10860
10860
  },
@@ -10874,7 +10874,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10874
10874
  },
10875
10875
  sourceLocation: {
10876
10876
  "file": "packages/api/session-controller/src/index.ts",
10877
- "line": 535,
10877
+ "line": 552,
10878
10878
  "column": 3
10879
10879
  }
10880
10880
  },
@@ -10901,7 +10901,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10901
10901
  },
10902
10902
  sourceLocation: {
10903
10903
  "file": "packages/api/session-controller/src/index.ts",
10904
- "line": 276,
10904
+ "line": 284,
10905
10905
  "column": 9
10906
10906
  }
10907
10907
  },
@@ -10930,7 +10930,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10930
10930
  },
10931
10931
  sourceLocation: {
10932
10932
  "file": "packages/api/session-controller/src/index.ts",
10933
- "line": 486,
10933
+ "line": 494,
10934
10934
  "column": 10
10935
10935
  }
10936
10936
  },
@@ -10957,7 +10957,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10957
10957
  },
10958
10958
  sourceLocation: {
10959
10959
  "file": "packages/api/session-controller/src/index.ts",
10960
- "line": 421,
10960
+ "line": 429,
10961
10961
  "column": 3
10962
10962
  }
10963
10963
  },
@@ -10975,7 +10975,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10975
10975
  },
10976
10976
  sourceLocation: {
10977
10977
  "file": "packages/api/session-controller/src/index.ts",
10978
- "line": 296,
10978
+ "line": 304,
10979
10979
  "column": 9
10980
10980
  }
10981
10981
  },
@@ -11003,7 +11003,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11003
11003
  },
11004
11004
  sourceLocation: {
11005
11005
  "file": "packages/api/session-controller/src/index.ts",
11006
- "line": 255,
11006
+ "line": 263,
11007
11007
  "column": 9
11008
11008
  }
11009
11009
  },
@@ -11021,7 +11021,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11021
11021
  },
11022
11022
  sourceLocation: {
11023
11023
  "file": "packages/api/session-controller/src/index.ts",
11024
- "line": 316,
11024
+ "line": 324,
11025
11025
  "column": 3
11026
11026
  }
11027
11027
  },
@@ -11049,7 +11049,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11049
11049
  },
11050
11050
  sourceLocation: {
11051
11051
  "file": "packages/api/session-controller/src/index.ts",
11052
- "line": 346,
11052
+ "line": 354,
11053
11053
  "column": 9
11054
11054
  }
11055
11055
  },
@@ -11077,7 +11077,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11077
11077
  },
11078
11078
  sourceLocation: {
11079
11079
  "file": "packages/api/session-controller/src/index.ts",
11080
- "line": 474,
11080
+ "line": 482,
11081
11081
  "column": 3
11082
11082
  }
11083
11083
  },
@@ -11105,7 +11105,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11105
11105
  },
11106
11106
  sourceLocation: {
11107
11107
  "file": "packages/api/session-controller/src/index.ts",
11108
- "line": 505,
11108
+ "line": 522,
11109
11109
  "column": 9
11110
11110
  }
11111
11111
  },
@@ -11133,7 +11133,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11133
11133
  },
11134
11134
  sourceLocation: {
11135
11135
  "file": "packages/api/session-controller/src/index.ts",
11136
- "line": 432,
11136
+ "line": 440,
11137
11137
  "column": 3
11138
11138
  }
11139
11139
  },
@@ -11160,7 +11160,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11160
11160
  },
11161
11161
  sourceLocation: {
11162
11162
  "file": "packages/api/session-controller/src/index.ts",
11163
- "line": 409,
11163
+ "line": 417,
11164
11164
  "column": 3
11165
11165
  }
11166
11166
  },
@@ -11188,7 +11188,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11188
11188
  },
11189
11189
  sourceLocation: {
11190
11190
  "file": "packages/api/session-controller/src/index.ts",
11191
- "line": 266,
11191
+ "line": 274,
11192
11192
  "column": 3
11193
11193
  }
11194
11194
  },
@@ -11215,7 +11215,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11215
11215
  },
11216
11216
  sourceLocation: {
11217
11217
  "file": "packages/api/session-controller/src/index.ts",
11218
- "line": 287,
11218
+ "line": 295,
11219
11219
  "column": 3
11220
11220
  }
11221
11221
  },
@@ -11242,7 +11242,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11242
11242
  },
11243
11243
  sourceLocation: {
11244
11244
  "file": "packages/api/session-controller/src/index.ts",
11245
- "line": 453,
11245
+ "line": 461,
11246
11246
  "column": 3
11247
11247
  }
11248
11248
  },
@@ -11270,7 +11270,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11270
11270
  },
11271
11271
  sourceLocation: {
11272
11272
  "file": "packages/api/session-controller/src/index.ts",
11273
- "line": 376,
11273
+ "line": 384,
11274
11274
  "column": 9
11275
11275
  }
11276
11276
  },
@@ -182,6 +182,12 @@ var ApiSessionAgentController = class {
182
182
  creations = /* @__PURE__ */ new Map();
183
183
  selections = /* @__PURE__ */ new WeakMap();
184
184
  imageAdmissionChains = /* @__PURE__ */ new WeakMap();
185
+ /** Open Web history follows per Session; child views count against their parent. */
186
+ followers = /* @__PURE__ */ new Map();
187
+ /** Sessions whose last follower closed while their owned Agent was not idle. */
188
+ releaseWhenIdle = /* @__PURE__ */ new Set();
189
+ /** Sessions whose owned Agent is being released because the last follower closed. */
190
+ followerReleases = /* @__PURE__ */ new Set();
185
191
  /** @param ctx - Host context carrying Agent, model, persistence, and Typert services. */
186
192
  constructor(ctx) {
187
193
  this.ctx = ctx;
@@ -194,6 +200,13 @@ var ApiSessionAgentController = class {
194
200
  ctx.on("agent/disposed", ({ agent }) => {
195
201
  if (this.owned.get(agent.session.id)?.agent === agent) this.owned.delete(agent.session.id);
196
202
  });
203
+ ctx.on("agent/status", ({ agent, status }) => {
204
+ if (status !== "idle") return;
205
+ const sessionId = agent.session.id;
206
+ if (!this.releaseWhenIdle.has(sessionId)) return;
207
+ const handle = this.owned.get(sessionId);
208
+ if (handle?.agent === agent) this.disposeFollowing(sessionId, handle);
209
+ });
197
210
  ctx.effect(() => async () => {
198
211
  await Promise.all([...this.owned.values()].map((handle) => handle.dispose()));
199
212
  }, "api-session.ownedAgents");
@@ -229,6 +242,66 @@ var ApiSessionAgentController = class {
229
242
  async resolveObservedAgent(observation) {
230
243
  return this.resolve(observation.header.id, observation);
231
244
  }
245
+ /**
246
+ * Record one Web history follow opening or closing for a Session.
247
+ * Child views pass their parent Session, whose Agent owns them.
248
+ * The last closing follower releases the Web-owned Agent once it is idle so
249
+ * another Host process can resume the Session; a new follower cancels a
250
+ * release still waiting for the current turn.
251
+ * @param sessionId - Session identity; the parent Session for a child view.
252
+ * @param active - true when a follow stream opens, false when it closes.
253
+ */
254
+ followersChanged(sessionId, active) {
255
+ if (active) {
256
+ this.followers.set(sessionId, (this.followers.get(sessionId) ?? 0) + 1);
257
+ this.releaseWhenIdle.delete(sessionId);
258
+ return;
259
+ }
260
+ const remaining = (this.followers.get(sessionId) ?? 0) - 1;
261
+ if (remaining > 0) {
262
+ this.followers.set(sessionId, remaining);
263
+ return;
264
+ }
265
+ this.followers.delete(sessionId);
266
+ this.releaseFollowing(sessionId);
267
+ }
268
+ /**
269
+ * Release one owned Agent when no Web follower remains and the Agent is idle.
270
+ * Background activation calls this after publishing a handle so a follow
271
+ * that closed while promotion was in flight is not left holding the writer.
272
+ * @param sessionId - Session identity.
273
+ */
274
+ releaseFollowing(sessionId) {
275
+ if (this.followers.has(sessionId)) return;
276
+ const handle = this.owned.get(sessionId);
277
+ if (handle === void 0) return;
278
+ if (handle.agent.status !== "idle") {
279
+ this.releaseWhenIdle.add(sessionId);
280
+ return;
281
+ }
282
+ this.disposeFollowing(sessionId, handle);
283
+ }
284
+ /**
285
+ * Whether this controller is disposing the Session because its last Web follower closed.
286
+ * The persisted Session remains available to another Host, so its list row stays.
287
+ * @param sessionId - Session identity whose teardown is being observed.
288
+ * @returns true while the follower-triggered disposal runs.
289
+ */
290
+ isFollowerRelease(sessionId) {
291
+ return this.followerReleases.has(sessionId);
292
+ }
293
+ async disposeFollowing(sessionId, handle) {
294
+ if (this.followerReleases.has(sessionId)) return;
295
+ this.releaseWhenIdle.delete(sessionId);
296
+ this.followerReleases.add(sessionId);
297
+ try {
298
+ await handle.dispose();
299
+ } catch (error) {
300
+ this.ctx.logger.warn(`api-session: failed to release session "${sessionId}" after its last follower closed: ${String(error)}`);
301
+ } finally {
302
+ this.followerReleases.delete(sessionId);
303
+ }
304
+ }
232
305
  async resolve(sessionId, observation) {
233
306
  const live = this.liveAgent(sessionId);
234
307
  if (live !== void 0) return live;
@@ -3021,6 +3094,7 @@ let SessionController = (() => {
3021
3094
  ctx.emit("api-session/added", this.listState.summaryFor(session));
3022
3095
  });
3023
3096
  ctx.on("session/disposed", (session) => {
3097
+ if (this.agents.isFollowerRelease(session.id)) return;
3024
3098
  ctx.emit("api-session/removed", session.id);
3025
3099
  });
3026
3100
  const publishAgentAvailability = ({ agent }) => {
@@ -3054,7 +3128,11 @@ let SessionController = (() => {
3054
3128
  try {
3055
3129
  const ownedObservation = __addDisposableResource(env_1, observation, false);
3056
3130
  const result = await this.agents.resolveObservedAgent(ownedObservation);
3057
- if ("error" in result) this.ctx.emit("api-session/error", sessionId, result.error.message);
3131
+ if ("error" in result) {
3132
+ this.ctx.emit("api-session/error", sessionId, result.error.message);
3133
+ return;
3134
+ }
3135
+ this.agents.releaseFollowing(sessionId);
3058
3136
  } catch (e_1) {
3059
3137
  env_1.error = e_1;
3060
3138
  env_1.hasError = true;
@@ -3289,7 +3367,13 @@ let SessionController = (() => {
3289
3367
  */
3290
3368
  async *follow(request, signal) {
3291
3369
  await this.assertNotDeleted(request.address.kind === "session" ? request.address.sessionId : request.address.childSessionId);
3292
- yield* this.history.follow(request, signal);
3370
+ const followedSession = request.address.kind === "session" ? request.address.sessionId : request.address.parentSessionId;
3371
+ this.agents.followersChanged(followedSession, true);
3372
+ try {
3373
+ yield* this.history.follow(request, signal);
3374
+ } finally {
3375
+ this.agents.followersChanged(followedSession, false);
3376
+ }
3293
3377
  }
3294
3378
  async assertNotDeleted(sessionId) {
3295
3379
  await this.ctx.workspaceRegistry.refresh();