operon-agents-core 0.1.0-alpha.2 → 0.1.0-alpha.21

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 (289) hide show
  1. package/dist/agent/agent.d.ts +8 -7
  2. package/dist/agent/compose-hooks.d.ts +10 -1
  3. package/dist/agent/compose-hooks.js +61 -6
  4. package/dist/agent/concurrency.js +1 -1
  5. package/dist/agent/context-report.d.ts +2 -2
  6. package/dist/agent/durable-state.d.ts +22 -0
  7. package/dist/agent/durable-state.js +54 -0
  8. package/dist/agent/index.d.ts +2 -2
  9. package/dist/agent/index.js +1 -1
  10. package/dist/agent/instruction-context.d.ts +6 -6
  11. package/dist/agent/instruction-context.js +23 -23
  12. package/dist/agent/profile-builtins.js +1 -1
  13. package/dist/agent/run-support.d.ts +1 -1
  14. package/dist/agent/run-support.js +6 -5
  15. package/dist/agent/runner.d.ts +25 -22
  16. package/dist/agent/runner.js +217 -121
  17. package/dist/agent/session.d.ts +262 -156
  18. package/dist/agent/session.js +590 -418
  19. package/dist/agent/subagent-tools.js +3 -3
  20. package/dist/agent/subagent.js +28 -13
  21. package/dist/agent/toolset.d.ts +1 -0
  22. package/dist/agent/toolset.js +13 -7
  23. package/dist/agent/workflow/journal.d.ts +2 -2
  24. package/dist/agent/workflow/journal.js +2 -2
  25. package/dist/agent/workflow/manager.d.ts +1 -1
  26. package/dist/agent/workflow/manager.js +1 -1
  27. package/dist/agent/workflow/prompt.js +2 -2
  28. package/dist/agent/workflow/sandbox.d.ts +1 -1
  29. package/dist/agent/workflow/sandbox.js +1 -1
  30. package/dist/agent/workflow/tool.js +30 -43
  31. package/dist/agent/worktree.d.ts +8 -8
  32. package/dist/agent/worktree.js +15 -15
  33. package/dist/capabilities/assembler.d.ts +29 -5
  34. package/dist/capabilities/assembler.js +85 -9
  35. package/dist/capabilities/background/code-task.d.ts +43 -0
  36. package/dist/capabilities/background/code-task.js +75 -0
  37. package/dist/capabilities/background/command-task.d.ts +9 -2
  38. package/dist/capabilities/background/command-task.js +22 -6
  39. package/dist/capabilities/background/index.d.ts +6 -1
  40. package/dist/capabilities/background/index.js +26 -20
  41. package/dist/capabilities/background/manager.d.ts +57 -1
  42. package/dist/capabilities/background/manager.js +210 -45
  43. package/dist/capabilities/background/persist-disk.d.ts +1 -1
  44. package/dist/capabilities/background/persist-disk.js +1 -1
  45. package/dist/capabilities/background/persist.js +4 -2
  46. package/dist/capabilities/background/projections.d.ts +16 -0
  47. package/dist/capabilities/background/projections.js +86 -0
  48. package/dist/capabilities/background/stall-watchdog.d.ts +41 -0
  49. package/dist/capabilities/background/stall-watchdog.js +85 -0
  50. package/dist/capabilities/background/task.d.ts +8 -7
  51. package/dist/capabilities/background/tools.js +33 -7
  52. package/dist/capabilities/capability-data.d.ts +52 -0
  53. package/dist/capabilities/capability-data.js +88 -0
  54. package/dist/capabilities/capability-state.d.ts +2 -4
  55. package/dist/capabilities/capability-state.js +5 -23
  56. package/dist/capabilities/capability.d.ts +203 -38
  57. package/dist/capabilities/compaction/index.js +10 -4
  58. package/dist/capabilities/compaction/service.d.ts +20 -5
  59. package/dist/capabilities/compaction/service.js +27 -11
  60. package/dist/capabilities/goal/goal-store.d.ts +76 -12
  61. package/dist/capabilities/goal/goal-store.js +137 -53
  62. package/dist/capabilities/goal/index.d.ts +1 -1
  63. package/dist/capabilities/goal/index.js +30 -7
  64. package/dist/capabilities/index.d.ts +9 -6
  65. package/dist/capabilities/index.js +4 -3
  66. package/dist/capabilities/plan/index.js +22 -5
  67. package/dist/capabilities/plan/plan-mode.d.ts +30 -9
  68. package/dist/capabilities/plan/plan-mode.js +57 -32
  69. package/dist/capabilities/plan/tools.js +1 -1
  70. package/dist/capabilities/skills/flow-provider.js +3 -3
  71. package/dist/capabilities/skills/index.d.ts +13 -1
  72. package/dist/capabilities/skills/index.js +30 -21
  73. package/dist/capabilities/skills/parser.d.ts +2 -2
  74. package/dist/capabilities/skills/parser.js +3 -3
  75. package/dist/capabilities/skills/registry.d.ts +5 -6
  76. package/dist/capabilities/skills/registry.js +6 -9
  77. package/dist/capabilities/skills/scanner.d.ts +3 -3
  78. package/dist/capabilities/skills/scanner.js +14 -14
  79. package/dist/capabilities/skills/service.d.ts +2 -1
  80. package/dist/capabilities/skills/service.js +3 -3
  81. package/dist/capabilities/skills/skill-tool.d.ts +2 -0
  82. package/dist/capabilities/skills/skill-tool.js +1 -1
  83. package/dist/capabilities/task/index.js +2 -1
  84. package/dist/capabilities/task/persist-disk.d.ts +1 -1
  85. package/dist/capabilities/task/persist-disk.js +1 -1
  86. package/dist/capabilities/task/persist.js +1 -1
  87. package/dist/capabilities/todo/index.js +11 -6
  88. package/dist/capabilities/todo/injector.js +2 -1
  89. package/dist/capabilities/todo/todo-store.d.ts +28 -7
  90. package/dist/capabilities/todo/todo-store.js +44 -11
  91. package/dist/capabilities/todo/tools.js +8 -3
  92. package/dist/capabilities/tool-provider.d.ts +3 -3
  93. package/dist/capabilities/user-hooks/engine.d.ts +3 -3
  94. package/dist/capabilities/user-hooks/engine.js +7 -7
  95. package/dist/capabilities/user-hooks/index.js +2 -1
  96. package/dist/capabilities/workflow/index.d.ts +5 -3
  97. package/dist/capabilities/workflow/index.js +3 -2
  98. package/dist/commands/index.js +34 -32
  99. package/dist/config/index.d.ts +1 -1
  100. package/dist/config/provider-manager.js +0 -28
  101. package/dist/config/schema.d.ts +53 -4
  102. package/dist/config/schema.js +53 -1
  103. package/dist/events/events.d.ts +43 -11
  104. package/dist/events/events.js +1 -0
  105. package/dist/events/index.d.ts +2 -2
  106. package/dist/events/index.js +1 -1
  107. package/dist/events/projection.d.ts +49 -1
  108. package/dist/events/projection.js +144 -19
  109. package/dist/events/publisher.js +2 -21
  110. package/dist/home.d.ts +1 -1
  111. package/dist/home.js +1 -1
  112. package/dist/index.d.ts +3 -2
  113. package/dist/index.js +2 -1
  114. package/dist/internal.d.ts +5 -2
  115. package/dist/internal.js +5 -2
  116. package/dist/llm/define-model.d.ts +4 -0
  117. package/dist/llm/define-model.js +63 -25
  118. package/dist/llm/index.d.ts +1 -0
  119. package/dist/llm/index.js +1 -0
  120. package/dist/llm/model.d.ts +2 -0
  121. package/dist/llm/provider.d.ts +17 -0
  122. package/dist/llm/provider.js +14 -0
  123. package/dist/llm/retry.js +1 -1
  124. package/dist/loop/context.d.ts +21 -1
  125. package/dist/loop/context.js +47 -9
  126. package/dist/loop/events.d.ts +5 -1
  127. package/dist/loop/index.d.ts +2 -2
  128. package/dist/loop/index.js +1 -1
  129. package/dist/loop/interruption.d.ts +9 -4
  130. package/dist/loop/interruption.js +11 -25
  131. package/dist/loop/run-turn.d.ts +16 -3
  132. package/dist/loop/run-turn.js +13 -4
  133. package/dist/loop/steer.d.ts +78 -12
  134. package/dist/loop/steer.js +101 -38
  135. package/dist/loop/tool-call.d.ts +13 -2
  136. package/dist/loop/tool-call.js +135 -5
  137. package/dist/loop/turn-step.d.ts +13 -2
  138. package/dist/loop/turn-step.js +29 -7
  139. package/dist/loop/types.d.ts +6 -0
  140. package/dist/mcp/auth-tool.d.ts +3 -1
  141. package/dist/mcp/auth-tool.js +2 -2
  142. package/dist/mcp/capability.d.ts +13 -0
  143. package/dist/mcp/capability.js +36 -17
  144. package/dist/mcp/config-loader.d.ts +5 -5
  145. package/dist/mcp/config-loader.js +17 -17
  146. package/dist/mcp/credentials.d.ts +35 -0
  147. package/dist/mcp/credentials.js +2 -0
  148. package/dist/mcp/filter.d.ts +2 -2
  149. package/dist/mcp/index.d.ts +4 -3
  150. package/dist/mcp/index.js +1 -1
  151. package/dist/mcp/manager.d.ts +108 -6
  152. package/dist/mcp/manager.js +262 -18
  153. package/dist/mcp/oauth/callback-server.d.ts +10 -1
  154. package/dist/mcp/oauth/callback-server.js +82 -16
  155. package/dist/mcp/oauth/index.d.ts +2 -2
  156. package/dist/mcp/oauth/provider.d.ts +18 -0
  157. package/dist/mcp/oauth/provider.js +31 -1
  158. package/dist/mcp/oauth/service.d.ts +9 -3
  159. package/dist/mcp/oauth/service.js +29 -4
  160. package/dist/mcp/sdk-transport.js +1 -1
  161. package/dist/mcp/server.js +1 -1
  162. package/dist/permission/auto-approver/prompts-data.d.ts +1 -1
  163. package/dist/permission/auto-approver/prompts-data.js +1 -1
  164. package/dist/permission/manager.d.ts +5 -3
  165. package/dist/permission/manager.js +7 -3
  166. package/dist/permission/policies.d.ts +2 -2
  167. package/dist/permission/policies.js +4 -4
  168. package/dist/plugins/fields.d.ts +14 -0
  169. package/dist/plugins/fields.js +30 -0
  170. package/dist/plugins/hooks.d.ts +2 -2
  171. package/dist/plugins/hooks.js +12 -12
  172. package/dist/plugins/index.js +1 -0
  173. package/dist/plugins/manager.d.ts +8 -3
  174. package/dist/plugins/manager.js +18 -7
  175. package/dist/plugins/manifest.d.ts +2 -2
  176. package/dist/plugins/manifest.js +101 -91
  177. package/dist/plugins/marketplace.js +76 -57
  178. package/dist/plugins/store.d.ts +3 -3
  179. package/dist/plugins/store.js +6 -6
  180. package/dist/protocol/index.d.ts +1 -1
  181. package/dist/store/catalog-store.d.ts +4 -1
  182. package/dist/store/catalog-store.js +5 -1
  183. package/dist/store/checkpointing-store.d.ts +41 -0
  184. package/dist/store/checkpointing-store.js +86 -0
  185. package/dist/store/disk-store.d.ts +8 -0
  186. package/dist/store/disk-store.js +127 -5
  187. package/dist/store/index.d.ts +3 -2
  188. package/dist/store/index.js +2 -1
  189. package/dist/store/log-store.d.ts +9 -1
  190. package/dist/store/log-store.js +68 -4
  191. package/dist/store/migrate.d.ts +8 -2
  192. package/dist/store/migrate.js +9 -2
  193. package/dist/store/origin.d.ts +31 -6
  194. package/dist/store/origin.js +0 -14
  195. package/dist/store/pg.d.ts +1 -0
  196. package/dist/store/pg.js +37 -2
  197. package/dist/store/redis.d.ts +1 -0
  198. package/dist/store/redis.js +30 -0
  199. package/dist/store/repository.d.ts +13 -1
  200. package/dist/store/repository.js +45 -2
  201. package/dist/store/session-catalog.d.ts +4 -0
  202. package/dist/store/session-catalog.js +6 -0
  203. package/dist/store/storage.js +3 -0
  204. package/dist/store/store.d.ts +97 -34
  205. package/dist/store/store.js +64 -10
  206. package/dist/telemetry/appender.d.ts +43 -0
  207. package/dist/telemetry/appender.js +46 -0
  208. package/dist/telemetry/events.d.ts +142 -0
  209. package/dist/telemetry/events.js +141 -0
  210. package/dist/telemetry/index.d.ts +10 -0
  211. package/dist/telemetry/index.js +6 -0
  212. package/dist/telemetry/projection.d.ts +23 -0
  213. package/dist/telemetry/projection.js +185 -0
  214. package/dist/telemetry/redact.d.ts +20 -0
  215. package/dist/telemetry/redact.js +40 -0
  216. package/dist/telemetry/service.d.ts +49 -0
  217. package/dist/telemetry/service.js +137 -0
  218. package/dist/testing.d.ts +58 -0
  219. package/dist/testing.js +123 -0
  220. package/dist/tool/background.d.ts +9 -6
  221. package/dist/tool/background.js +7 -1
  222. package/dist/tool/builtin/ask-user-question.js +6 -5
  223. package/dist/tool/builtin/bash.d.ts +6 -0
  224. package/dist/tool/builtin/bash.js +79 -42
  225. package/dist/tool/builtin/edit.js +82 -109
  226. package/dist/tool/builtin/glob.js +13 -13
  227. package/dist/tool/builtin/grep.js +13 -13
  228. package/dist/tool/builtin/read.js +25 -15
  229. package/dist/tool/builtin/write.js +49 -33
  230. package/dist/tool/define.d.ts +14 -8
  231. package/dist/tool/define.js +8 -2
  232. package/dist/tool/{machine-base.d.ts → environment-base.d.ts} +37 -37
  233. package/dist/tool/{machine-base.js → environment-base.js} +45 -119
  234. package/dist/tool/{machine-local.d.ts → environment-local.d.ts} +9 -8
  235. package/dist/tool/{machine-local.js → environment-local.js} +60 -81
  236. package/dist/tool/{machine-null.d.ts → environment-null.d.ts} +9 -9
  237. package/dist/tool/{machine-null.js → environment-null.js} +9 -9
  238. package/dist/tool/{machine-ssh.d.ts → environment-ssh.d.ts} +33 -18
  239. package/dist/tool/{machine-ssh.js → environment-ssh.js} +118 -149
  240. package/dist/tool/{machine.d.ts → environment.d.ts} +53 -82
  241. package/dist/tool/environment.js +2 -0
  242. package/dist/tool/file-freshness.d.ts +33 -19
  243. package/dist/tool/file-freshness.js +39 -30
  244. package/dist/tool/filesystem-tools.d.ts +1 -1
  245. package/dist/tool/filesystem-tools.js +1 -1
  246. package/dist/tool/git-context.d.ts +2 -2
  247. package/dist/tool/git-context.js +8 -8
  248. package/dist/tool/index.d.ts +12 -12
  249. package/dist/tool/index.js +12 -10
  250. package/dist/tool/policies/path-access.d.ts +4 -4
  251. package/dist/tool/policies/path-access.js +12 -12
  252. package/dist/tool/questions.d.ts +8 -0
  253. package/dist/tool/search/catalog.d.ts +37 -0
  254. package/dist/tool/search/catalog.js +182 -0
  255. package/dist/tool/search/deferral.d.ts +3 -2
  256. package/dist/tool/search/loaded.d.ts +32 -0
  257. package/dist/tool/search/loaded.js +96 -0
  258. package/dist/tool/search/search-tool.d.ts +2 -6
  259. package/dist/tool/search/search-tool.js +16 -15
  260. package/dist/tool/shell-env.js +4 -0
  261. package/dist/tool/support/bash-paths.js +38 -7
  262. package/dist/tool/support/{machine-ops.d.ts → environment-ops.d.ts} +12 -14
  263. package/dist/tool/support/{machine-ops.js → environment-ops.js} +21 -2
  264. package/dist/tool/support/git-worktree.d.ts +3 -3
  265. package/dist/tool/support/git-worktree.js +6 -6
  266. package/dist/tool/support/rg-locator.d.ts +6 -6
  267. package/dist/tool/support/rg-locator.js +6 -6
  268. package/dist/tool/support/ripgrep-run.d.ts +5 -5
  269. package/dist/tool/support/ripgrep-run.js +3 -3
  270. package/dist/tool/support/tool-path.d.ts +3 -3
  271. package/dist/tool/support/tool-path.js +7 -7
  272. package/dist/tool/types.d.ts +54 -10
  273. package/dist/tool/web/fetch-url.js +1 -1
  274. package/dist/tool/web/web-search.js +1 -1
  275. package/dist/tool/workspace-spec.d.ts +3 -3
  276. package/dist/tool/workspace-spec.js +27 -27
  277. package/dist/tracing/bridge.d.ts +9 -1
  278. package/dist/tracing/bridge.js +307 -77
  279. package/dist/tracing/index.d.ts +2 -2
  280. package/dist/tracing/otel.d.ts +28 -1
  281. package/dist/tracing/otel.js +150 -38
  282. package/dist/tracing/processor.d.ts +22 -0
  283. package/dist/tracing/processor.js +2 -0
  284. package/dist/tracing/spans.d.ts +54 -0
  285. package/dist/tracing/spans.js +5 -0
  286. package/package.json +6 -2
  287. package/dist/tool/machine.js +0 -15
  288. package/dist/tool/search/activation.d.ts +0 -13
  289. package/dist/tool/search/activation.js +0 -31
@@ -1,29 +1,37 @@
1
- import type { Machine, MachineFactory } from "../tool/machine.ts";
1
+ import type { Environment } from "../tool/environment.ts";
2
2
  import { FileFreshnessLedger } from "../tool/file-freshness.ts";
3
3
  import type { ChatModel } from "../llm/define-model.ts";
4
4
  import type { ThinkingLevel } from "../llm/model.ts";
5
5
  import type { PermissionMode, Responder } from "../permission/types.ts";
6
- import { PermissionManager, type PermissionManagerOptions } from "../permission/manager.ts";
6
+ import { PermissionManager } from "../permission/manager.ts";
7
7
  import type { BackgroundSpawner } from "../tool/background.ts";
8
- import type { BackgroundManager, BackgroundTaskInfo, BackgroundTaskOutputDelta, BackgroundTaskOutputSnapshot } from "../capabilities/background/index.ts";
9
- import type { GoalSnapshot, GoalStore } from "../capabilities/goal/index.ts";
10
- import type { WorkflowManager } from "../capabilities/workflow/index.ts";
11
- import type { WorkflowSnapshot } from "./workflow/snapshot.ts";
8
+ import { WorkflowManager } from "./workflow/manager.ts";
9
+ import type { WorkflowJournal } from "./workflow/journal.ts";
12
10
  import type { ContextBreakdown } from "./context-report.ts";
13
- import type { PlanData, PlanMode } from "../capabilities/plan/index.ts";
14
- import type { CompactRequestOptions, CompactionService, PendingCompaction } from "../capabilities/compaction/index.ts";
15
- import type { ActivateSkillRequest, SkillActivationResult, SkillSummary, SkillsService } from "../capabilities/skills/index.ts";
16
- import type { PluginInfo, PluginManager, PluginSummary, ReloadSummary } from "../plugins/index.ts";
17
- import { type EventPublicationMode, type EventSink } from "../events/index.ts";
11
+ import { type EventSink } from "../events/index.ts";
18
12
  import { type Logger } from "../logging/index.ts";
19
13
  import { type AgentRecord, type SessionStore } from "../store/index.ts";
14
+ import type { Usage } from "../protocol/index.ts";
20
15
  import { type TracingProcessor } from "../tracing/index.ts";
21
16
  import { ConversationContext } from "../loop/context.ts";
22
- import type { McpServersHandle, McpServerView } from "../mcp/index.ts";
23
- import { SteerBus, type SteerContent, type SteerOrigin } from "../loop/steer.ts";
17
+ import { SteerBus, type SteerContent, type SteerOptions, type SteerOrigin, type SteerReceipt } from "../loop/steer.ts";
24
18
  import type { Capability, CapabilityDiagnostic, SessionControls } from "../capabilities/capability.ts";
25
- import { type SubagentRecord } from "./subagent.ts";
26
19
  import { type SystemPromptContext } from "./instruction-context.ts";
20
+ import type { GoalStore } from "../capabilities/goal/goal-store.ts";
21
+ import type { PlanMode } from "../capabilities/plan/plan-mode.ts";
22
+ import type { TodoStore } from "../capabilities/todo/todo-store.ts";
23
+ import type { TaskStore } from "../capabilities/task/task-store.ts";
24
+ import type { SkillsService } from "../capabilities/skills/service.ts";
25
+ import type { PluginManager } from "../plugins/manager.ts";
26
+ import type { McpServersHandle } from "../mcp/manager.ts";
27
+ import type { BackgroundManager } from "../capabilities/background/manager.ts";
28
+ import type { CompactionService } from "../capabilities/compaction/service.ts";
29
+ import type { EnvironmentFactory } from "../tool/environment.ts";
30
+ import type { EventPublicationMode } from "../events/index.ts";
31
+ import type { TelemetryService } from "../telemetry/service.ts";
32
+ import type { PermissionManagerOptions } from "../permission/manager.ts";
33
+ /** The session's whole append log, read once at open and memoized (see `Session.open`). */
34
+ export type SessionLogReader = () => Promise<readonly AgentRecord[]>;
27
35
  /** Test-only (exported via `operon-agents-core/internal`): shrink the close deadlines
28
36
  * so hang-isolation tests don't wait wall-clock seconds. */
29
37
  export declare function setSessionCloseTimeoutsForTest(ms: {
@@ -31,50 +39,64 @@ export declare function setSessionCloseTimeoutsForTest(ms: {
31
39
  storeFlush?: number;
32
40
  }): void;
33
41
  export declare function newSessionId(): string;
34
- export interface SessionConfig {
42
+ /**
43
+ * What `Session.open` takes besides the scope. Everything with a lifetime — environment, store,
44
+ * events, steer, responder, logger, permission options — is READ FROM THE SCOPE, registered
45
+ * there by whoever opened it (the harness, a runner, a test). `open` only fills the gaps with
46
+ * defaults (`provide`), never overrides what the creator registered.
47
+ */
48
+ export interface SessionOpenOptions {
49
+ readonly capabilities?: readonly Capability[];
35
50
  /**
36
- * The machine this session operates. Pass a {@link Machine} directly, or a
37
- * {@link MachineFactory} when it can only be built once the session id is known.
38
- * Omitted → a {@link NullMachine}: a stateless session with no filesystem, where any
39
- * file tool that slips through fails loudly instead of touching the host disk.
51
+ * This session's id. Defaults to a fresh one.
40
52
  *
41
- * Either way the session only OPERATES the machine — disposal stays with whoever
42
- * created it. See {@link MachineFactory}.
53
+ * An ARGUMENT, not a service: it has no lifetime to manage, nothing inherits it from a parent
54
+ * scope, and nobody shares it — a capability reads `ctx.sessionId`. It used to be registered on
55
+ * the scope only because `open` took no other parameter, which made the registry double as a
56
+ * parameter list.
43
57
  */
44
- readonly machine?: Machine | MachineFactory;
45
- readonly store?: SessionStore;
46
- readonly events?: EventSink;
47
- /** `immediate` is optimized for an in-process UI. `committed` makes one ordered stream in
48
- * which record-backed events are emitted only after durable append succeeds. */
49
- readonly eventPublication?: EventPublicationMode;
50
- readonly tracing?: TracingProcessor;
51
- readonly responder?: Responder;
52
- readonly permission?: PermissionManagerOptions;
53
- readonly capabilities?: readonly Capability[];
54
- readonly steer?: SteerBus;
55
- readonly background?: BackgroundSpawner;
56
58
  readonly sessionId?: string;
59
+ /** The host's cancel handle. The session's own signal is derived from it, never replaces it. */
57
60
  readonly signal?: AbortSignal;
58
- readonly logger?: Logger;
59
61
  /**
60
- * The session's full append log, pre-read by the caller. `open` then skips its own
61
- * `readLog` and every open-time consumer (log-fold capabilities, context pre-build)
62
- * folds THESE records — sharing the read AND the `Message` object graph with whatever
63
- * else the caller seeded from them (e.g. a `SessionProjection`), instead of holding a
64
- * second parsed+blob-rehydrated copy for the session's lifetime.
65
- * Must be the complete log (all addresses, append order) as `readRecords()` returns it.
62
+ * The durable store behind this session (disk / Pg / Redis / memory). Omit for a storeless,
63
+ * in-memory session. `open` wraps it so record-backed events publish on commit and hands
64
+ * THAT wrapper out as `SessionContext.store` — which is what capabilities and the loop write
65
+ * through.
66
+ */
67
+ readonly store?: SessionStore;
68
+ /**
69
+ * The session's log, pre-read by the caller: every shard from its newest checkpoint on
70
+ * (`readSessionTails`), or the whole log. `open` then reads no log itself — the context
71
+ * pre-build folds `main`'s records from THESE, sharing the read AND the `Message` object graph
72
+ * with whatever else the caller seeded from them (e.g. a `SessionProjection`). Without it,
73
+ * `open` reads only `main` from its newest checkpoint. State is read from the store's
74
+ * key/value side either way.
66
75
  */
67
76
  readonly preloadedLog?: readonly AgentRecord[];
68
- }
69
- /**
70
- * Thrown by `Session`'s capability-backed convenience methods when the capability they
71
- * wrap is not open on this session. Detect with `instanceof`; `capability` names the
72
- * missing one. The probe tier never throws — the getters (`session.cron`, `.goal`, …)
73
- * return `undefined` instead.
74
- */
75
- export declare class CapabilityMissingError extends Error {
76
- readonly capability: string;
77
- constructor(capability: string);
77
+ /** Reopened from a store (vs created fresh). Only telemetry cares; the stream cannot tell. */
78
+ readonly resumed?: boolean;
79
+ /**
80
+ * Where this session's tools execute: an instance, or a factory called once with the session's
81
+ * id and signal. Omitted, the session gets a `NullEnvironment` — no filesystem, and any file
82
+ * tool that slips through fails loudly instead of touching the host disk.
83
+ *
84
+ * The session only OPERATES it. Disposal stays with whoever created it: a sandbox usually
85
+ * outlives any one session, so closing a session must not pull it out from under the others.
86
+ */
87
+ readonly environment?: Environment | EnvironmentFactory;
88
+ readonly events?: EventSink;
89
+ readonly steer?: SteerBus;
90
+ /** Answers permission prompts live (as opposed to the interrupt/resume path). */
91
+ readonly responder?: Responder;
92
+ readonly permissionOptions?: PermissionManagerOptions;
93
+ readonly logger?: Logger;
94
+ readonly tracing?: TracingProcessor;
95
+ /** Product telemetry (docs/telemetry.md). Absent = nothing is counted. */
96
+ readonly telemetry?: TelemetryService;
97
+ readonly eventPublication?: EventPublicationMode;
98
+ /** Spawns background work when no background capability is open. */
99
+ readonly spawner?: BackgroundSpawner;
78
100
  }
79
101
  /** The current owner and root conversation shard for the next user prompt. */
80
102
  export interface ConversationHead {
@@ -124,42 +146,62 @@ export interface SessionPort {
124
146
  /** Session model override; wins over the agent's own model. */
125
147
  readonly modelSetting: string | ChatModel | undefined;
126
148
  readonly thinkingSetting: ThinkingLevel | undefined;
127
- /** Compaction service view: reserved headroom plus full-compaction invalidation revision. */
128
- readonly compaction: {
149
+ /** Compaction service view: reserved headroom plus full-compaction invalidation revision.
150
+ * PROBE, unlike `Session.compaction` — the loop runs fine without the capability. */
151
+ readonly compactionView: {
129
152
  readonly reservedContextTokens: number;
130
153
  readonly revision: number;
131
154
  } | undefined;
132
- readonly workflow: WorkflowManager | undefined;
133
- resolveSystemPromptContext(machine: Machine): Promise<SystemPromptContext>;
155
+ /** A resume journal for one workflow run, bound to this session's store (the workflow
156
+ * capability's manager, or the session's in-memory fallback) — all the kernel's `Workflow`
157
+ * tool needs; the manager itself stays behind `session.workflow`. */
158
+ newWorkflowJournal(runId: string, parentToolCallId?: string): WorkflowJournal;
159
+ resolveSystemPromptContext(environment: Environment): Promise<SystemPromptContext>;
134
160
  recordContextBreakdown(breakdown: ContextBreakdown): void;
135
161
  flushEvents(): Promise<void>;
136
162
  setLiveContext(address: string, ctx: ConversationContext): void;
137
163
  setConversationHead(head: ConversationHead): void;
138
164
  /** Register a forked frame's inbox; the returned function unregisters it. */
139
165
  registerFrameBus(address: string, bus: SteerBus): () => void;
166
+ /**
167
+ * Rebuild a frame's conversation from its shard to resume it — read from the shard's newest
168
+ * checkpoint, never its head — and restore the frame's own capability state (its todo list)
169
+ * from what is stored for its address. Requires a store.
170
+ */
171
+ openFrameContext(address: string): Promise<ConversationContext>;
172
+ /** Add one root-agent turn's usage to the session's running total and return the new total. */
173
+ addSessionUsage(usage: Usage): Usage;
174
+ /** Persist the session's runtime permission state after a grant was applied in memory. */
175
+ persistPermissionState(): void;
140
176
  }
141
177
  /**
142
- * Capability access on a session has two tiers, one rule each:
143
- * - PROBE — the service getters (`session.cron`, `.goal`, `.plan`, `.backgroundManager`,
144
- * `.mcp`, …) return `undefined` when that capability is not open. Use these to feature-test.
145
- * - REQUIRE — the convenience wrappers (`createCronTask()`, `compact()`, `listSkills()`, …)
146
- * assume the capability and throw {@link CapabilityMissingError} when it is missing.
178
+ * Service access on a session has two tiers, one rule each:
179
+ * - PROBE — `session.service("x")` returns `undefined` when that capability is not open
180
+ * (the capability is not open). Use it to feature-test.
181
+ * - REQUIRE — `session.requireService("x")` and the convenience wrappers (`createCronTask()`,
182
+ * `compact()`, `listSkills()`, …) assume the service and throw `ServiceUnavailableError`
183
+ * when it is missing.
147
184
  * The only exceptions are list views documented as degrading to empty when the capability
148
185
  * is off (`listWorkflows`, `listSubagents`, `listMcpServers`) — views over durable state
149
186
  * that stay meaningful on a session opened without the capability.
187
+ *
188
+ * The session OWNS what its capabilities opened: `close()` runs every `closeSession` in reverse
189
+ * open order, each under a deadline.
150
190
  */
151
191
  export declare class Session implements SessionPort {
152
192
  readonly id: string;
153
- readonly machine: Machine;
193
+ /** What each open capability published, by capability name. See `service()`. */
194
+ private readonly services;
195
+ /** The host's spawner, used when no background capability is open. */
196
+ private readonly injectedSpawner;
197
+ /** Open capabilities in registration order — closed in reverse. */
198
+ private openedForClose;
199
+ readonly environment: Environment;
154
200
  readonly store?: SessionStore;
155
201
  readonly events: EventSink;
156
202
  private readonly eventPublisher;
157
203
  readonly responder?: Responder;
158
- private readonly permissionOptions?;
159
- /** Session-lived permission manager: one policy chain + approval memory +
160
- * mode for the whole session. Constructed in `openCapabilities` (needs capability policy
161
- * slots and the replayed log); runs reference it instead of building their own. */
162
- private _permission;
204
+ private readonly permissionOptions;
163
205
  readonly steer: SteerBus;
164
206
  readonly signal: AbortSignal;
165
207
  /** Upstream of `signal`. Fires only via `abort()`; a host signal aborts independently. */
@@ -167,9 +209,8 @@ export declare class Session implements SessionPort {
167
209
  readonly logger: Logger;
168
210
  private readonly tracing?;
169
211
  private readonly unsubscribeTracing?;
170
- private readonly injectedBackground?;
212
+ private readonly unsubscribeTelemetry?;
171
213
  private readonly allCapabilities;
172
- private readonly services;
173
214
  private readonly systemPromptContexts;
174
215
  private readonly liveContexts;
175
216
  /** Inboxes of frames currently running under this session, keyed by journal address. */
@@ -177,69 +218,170 @@ export declare class Session implements SessionPort {
177
218
  private activeConversationHead;
178
219
  private readonly fileLedgers;
179
220
  private modelOverride?;
180
- /** Caller-supplied one-shot log for open (see SessionConfig.preloadedLog); cleared after
181
- * openCapabilities so the array itself is not pinned for the session's lifetime. */
221
+ /** Caller-supplied one-shot log for open (see SessionOpenOptions.preloadedLog); cleared after
222
+ * provisionCapabilities so the array itself is not pinned for the session's lifetime. */
182
223
  private preloadedLog?;
183
224
  private thinkingOverride?;
184
- private openedCapabilities;
225
+ private provisionedCapabilities;
185
226
  private isOpen;
227
+ /** False once `close()` has started. What the scope's `state` used to answer. */
228
+ get open(): boolean;
229
+ /** The one close in flight (or finished): every `close()` call returns THIS promise. */
230
+ private closing;
186
231
  private runChain;
187
232
  private readonly pendingDiagnostics;
233
+ /** Builds the context a capability is opened with; set by `openCapabilities`, reused by attach. */
234
+ private contextFor;
235
+ /** Runs currently holding an assembly of `capabilities` — see `enterRun` / `exitRun`. */
236
+ private activeRuns;
237
+ /** Attach/detach requests waiting for a moment with no run in flight. */
238
+ private readonly pendingChanges;
239
+ /** Serializes applied changes, and lets `close()` wait for the one in progress. */
240
+ private changeChain;
188
241
  private lastContextBreakdown?;
242
+ /** Built at the end of `open`, once every capability's policies are in. */
243
+ private permissionManager?;
244
+ /** The mode set at RUNTIME (`setPermissionMode`, or restored from one) — what is persisted.
245
+ * A mode that only came from the host's options is not session state: reopening with
246
+ * different options must still take effect. */
247
+ private explicitPermissionMode;
248
+ /** The root agent's usage across the session's whole life, stored as `session:usage`. */
249
+ private totalUsage;
250
+ /** Beneath the publisher: stamps checkpoints, and folds each shard's lifecycle for them. */
251
+ private readonly checkpointing;
252
+ /** Writes capability and session current state to the store's key/value side. */
253
+ private readonly durable;
254
+ /** Each stateful capability's `durableState`, by name — registered when it is restored. */
255
+ private readonly durableOwners;
189
256
  private constructor();
190
- static open(cfg: SessionConfig): Promise<Session>;
257
+ /**
258
+ * Open a session. Everything it depends on arrives in `opts`; `open` fills in the defaults for
259
+ * whatever is missing, builds the session's own objects (signal, event publisher, log reader,
260
+ * controls), opens every capability in order, then builds the permission manager.
261
+ */
262
+ static open(opts?: SessionOpenOptions): Promise<Session>;
263
+ /**
264
+ * Build every capability's declared services and register them.
265
+ *
266
+ * Each capability is handed its own view of the session: the shared objects plus a
267
+ * `state` / `records` / `record` partitioned by its name. The per-RUN pair is `start`/`stop`,
268
+ * which the assembler drives.
269
+ */
191
270
  private openCapabilities;
271
+ /**
272
+ * A shard's records from its newest checkpoint on. A checkpoint written without the shard's
273
+ * lifecycle (by a context outside any session) can restore history but not the open turn, so
274
+ * in that case the whole shard is read and the lifecycle is folded from its head.
275
+ */
276
+ private readShardForRestore;
277
+ private readWholeShard;
278
+ /**
279
+ * Restore `cap`'s state for `address` from the value stored for it. Any write of that value
280
+ * still in flight lands first, so the read is never older than what this process last wrote.
281
+ */
282
+ private restoreOwner;
283
+ /** `SessionContext.persistState` for capability `owner`. */
284
+ private persistOwnerState;
285
+ /** The session's runtime permission state as persisted: the runtime mode, and its grants. */
286
+ private permissionState;
287
+ addSessionUsage(usage: Usage): Usage;
288
+ /** The root agent's token usage across the session's whole life — every run, every reopen.
289
+ * Subagents' turns are not in it (each is audited in its own shard). */
290
+ get usage(): Usage | undefined;
291
+ openFrameContext(address: string): Promise<ConversationContext>;
292
+ /** @internal `openFrameContext` over records the caller already read (the shard from a
293
+ * checkpoint on, or whole). */
294
+ frameContextFrom(address: string, records: readonly AgentRecord[]): Promise<ConversationContext>;
295
+ /** Write a capability's record to the audit shard (about `main`). Best effort: a failure is
296
+ * logged, and `records()` still sees the write, from memory. */
297
+ private appendAuditRecord;
298
+ /**
299
+ * Open `capability` in this live session. With no run in flight that is immediate; otherwise it
300
+ * waits for the last run to stop, so a run never sees its capability set change under it — the
301
+ * next run assembles with it. Resolves once `openSession` has run and the capability is part of
302
+ * the session; rejects, leaving nothing behind, when it throws.
303
+ *
304
+ * Only a `detachable` capability can come and go: an `invariant` one (permission, compaction)
305
+ * is part of the session from open — its policies were folded into the permission manager then.
306
+ */
307
+ attachCapability(capability: Capability): Promise<void>;
308
+ /** Close and remove a `detachable` capability, at the same quiet point `attachCapability` uses. */
309
+ detachCapability(name: string): Promise<void>;
310
+ /** @internal The Runner is about to assemble `capabilities` for a run. Pair with `exitRun`. */
311
+ enterRun(): void;
312
+ /** @internal The run has stopped its capabilities. The last one out applies queued changes. */
313
+ exitRun(): Promise<void>;
314
+ private submitChange;
315
+ private drainChanges;
316
+ private attachNow;
317
+ private detachNow;
318
+ /** Close capabilities in reverse open order, each fault-isolated: used to undo a failed open. */
319
+ private closeOpened;
192
320
  /**
193
321
  * Construct the session-lived PermissionManager: capability policy slots are collected from
194
322
  * the opened capabilities' static `policies` (session-tier fault isolation: a capability whose
195
- * `openSession` failed contributes nothing; a per-run `start()` failure does NOT retract its
196
- * policies — they are pure evaluators over session-lived state). Then runtime permission
197
- * state is folded back from the log — `permission.set_mode` (last wins) and approve-for-session
198
- * grants (`permission.record_approval` with scope "session").
323
+ * provision failed contributes nothing; a per-run `start()` failure does NOT retract its
324
+ * policies — they are pure evaluators over session-lived state). Then the runtime permission
325
+ * state stored for the session (`session:permission`) is applied over the host's options.
199
326
  */
200
327
  private buildPermissionManager;
201
- /** The session-lived permission manager (policy chain + mode + approval memory). */
328
+ private restorePermissionMode;
329
+ /**
330
+ * Persist the session's runtime permission state — after an approve-for-session grant, which
331
+ * is already applied in memory (`PermissionManager.applyApproval`); this is the durable half.
332
+ * Not awaited: a lost grant only means the user is asked again. The frame's
333
+ * `permission.record_approval` stays the audit record of who granted it.
334
+ */
335
+ persistPermissionState(): void;
336
+ /** The session-lived permission manager (policy chain + mode + approval memory). Built by
337
+ * `open` once every capability's policies are known; another session's manager is meaningless,
338
+ * so it is a field rather than a registry entry. */
202
339
  get permission(): PermissionManager;
203
340
  get capabilities(): readonly Capability[];
204
- service<T = unknown>(name: string): T | undefined;
205
- /** The REQUIRE tier (see the class doc): unwrap a probed service or throw the typed error. */
206
- private requireCapability;
207
- get goal(): GoalStore | undefined;
208
- get workflow(): WorkflowManager | undefined;
209
- get skills(): SkillsService | undefined;
210
- get plugins(): PluginManager | undefined;
211
- get backgroundManager(): BackgroundManager | undefined;
212
- get plan(): PlanMode | undefined;
213
- get compaction(): CompactionService | undefined;
341
+ /** PROBE tier: what the capability named `name` published, or undefined when it is not open. */
342
+ service<S = unknown>(name: string): S | undefined;
343
+ /** REQUIRE tier: the same, or a throw naming the capability that would have provided it. */
344
+ requireService<S = unknown>(name: string): S;
345
+ /** The workflow manager: the capability's, or the in-memory fallback `open` provides. */
346
+ get workflow(): WorkflowManager;
347
+ get goal(): GoalStore;
348
+ get plan(): PlanMode;
349
+ get todo(): TodoStore;
350
+ get task(): TaskStore;
351
+ get skills(): SkillsService;
352
+ get plugins(): PluginManager;
353
+ /** The MCP control plane. Absent when no MCP capability is open — hence `get`, not `require`:
354
+ * a session without MCP has no servers to report, and that is an answer, not a failure. */
214
355
  get mcp(): McpServersHandle | undefined;
215
- get background(): BackgroundSpawner | undefined;
216
- listBackgroundTasks(options?: BackgroundTaskListOptions): Promise<readonly BackgroundTaskInfo[]>;
217
- /** Past BACKGROUND workflow runs (newest first), from the durable task store. A foreground
218
- * workflow is a plain `Workflow` tool call — its record is the conversation plus its journal
219
- * shard — so it is not listed here (its shard stays resumable by runId). */
220
- listWorkflows(): Promise<readonly WorkflowSnapshot[]>;
221
- /** One background workflow run's snapshot by runId, or undefined if unknown. */
222
- getWorkflow(runId: string): Promise<WorkflowSnapshot | undefined>;
356
+ newWorkflowJournal(runId: string, parentToolCallId?: string): WorkflowJournal;
357
+ get compaction(): CompactionService;
358
+ /** The PROBE view of the same service, for the loop: absent when compaction is not open. */
359
+ get compactionView(): CompactionService | undefined;
360
+ /** The spawner the Agent/Workflow tools use: the background capability's manager, else the
361
+ * host-injected `spawner` (`SessionOpenOptions.spawner`). */
362
+ get spawner(): BackgroundSpawner | undefined;
363
+ /**
364
+ * The durable task ledger — background tasks, subagents and workflow runs.
365
+ *
366
+ * PROBE tier (`| undefined`), unlike the accessors above, and deliberately: a session opened
367
+ * without the background capability has no past runs, which is an ANSWER — so a caller writes
368
+ * `session.background?.listSubagents() ?? []` and the emptiness is visible at the call site
369
+ * instead of hidden inside a facade method. Callers that genuinely require it (stopping a
370
+ * task, detaching a tool call) should say so with `session.requireService("background")`.
371
+ */
372
+ get background(): BackgroundManager | undefined;
223
373
  /** The most-recent context-window breakdown (system/tools/messages/injections/free), stamped
224
- * by the Runner at each turn boundary — or undefined if no turn has assembled a request yet.
374
+ * by the Runner at each turn boundary and again from every step's request as sent, after every
375
+ * hook (an extension may rewrite it) — or undefined if no turn has assembled a request yet.
225
376
  * A read-only snapshot: it reflects the last turn sent, not a fresh recomputation. */
226
377
  getContextBreakdown(): ContextBreakdown | undefined;
227
378
  /** Runner-internal: record the breakdown assembled for the turn about to be sent. */
228
379
  recordContextBreakdown(breakdown: ContextBreakdown): void;
229
- /** The background subagents of this session, from the durable task store (live + reconciled
230
- * ghosts). Foreground subagents are plain `Agent` tool calls — their record is the conversation
231
- * plus their own shard — so they are not listed here (their shard stays resumable by id). */
232
- listSubagents(): Promise<readonly SubagentRecord[]>;
233
- /**
234
- * Reclassify orphaned background work (spawned by a dead process, never settled) as `lost`
235
- * through the task store: the manager writes the terminal status back and steers the lost
236
- * notification (the durable settle record), so later opens won't re-report. Also emits a warning
237
- * per reclassified subagent. Call when reopening an existing session. Returns the lost subagents
238
- * (resume any with `Agent(resume="<id>", ...)`).
239
- */
240
- reconcileSubagents(): Promise<readonly SubagentRecord[]>;
241
- /** Every record of an address in append order (for rendering the transcript). */
380
+ /** Every record of an address in append order (for rendering the transcript). Without an
381
+ * address, every conversation shard — the audit shard is read with `getAuditRecords`. */
242
382
  getRecords(address?: string): Promise<AgentRecord[]>;
383
+ /** The audit shard's records in append order; each names the shard it concerns in `about`. */
384
+ getAuditRecords(): Promise<AgentRecord[]>;
243
385
  /** @internal The kept live context for an address, or undefined (cold → caller replays). */
244
386
  liveContext(address: string): ConversationContext | undefined;
245
387
  /** @internal Cache the live context so the next turn on this address reuses it. */
@@ -252,15 +394,15 @@ export declare class Session implements SessionPort {
252
394
  */
253
395
  registerFrameBus(address: string, bus: SteerBus): () => void;
254
396
  /**
255
- * Hand a message to the frame running at `address`; `false` when nobody is there.
397
+ * Hand a message to the frame running at `address`; undefined when nobody is there.
256
398
  *
257
399
  * This is the whole seam an external coordinator needs in order to address a subagent: it can
258
400
  * already learn who exists from `agent.started` / `agent.ended` (both carry `address`), but it
259
- * has no way to reach a child's inbox — every frame owns a private `SteerBus`. Deliberately
401
+ * has no way to reach a child's queue — every frame owns a private `SteerBus`. Deliberately
260
402
  * knows nothing about peers, rosters or visibility: those are policy, and policy belongs to
261
403
  * whoever is coordinating, not to the engine.
262
404
  */
263
- steerTo(address: string, content: SteerContent, origin: SteerOrigin): boolean;
405
+ steerTo(address: string, content: SteerContent, origin: SteerOrigin, options?: SteerOptions): SteerReceipt | undefined;
264
406
  /** @internal Cached conversation owner. Durable sessions can always rebuild it from the log. */
265
407
  conversationHead(): ConversationHead | undefined;
266
408
  /** @internal Update the cache only after the source-side handoff commit has been flushed. */
@@ -274,35 +416,7 @@ export declare class Session implements SessionPort {
274
416
  * the session lifetime, so read-before-write state survives across turns and run() calls. */
275
417
  fileLedgerFor(address: string): FileFreshnessLedger;
276
418
  /** Resolve environment + AGENTS.md for the active runtime frame, cached for this Session. */
277
- resolveSystemPromptContext(machine: Machine): Promise<SystemPromptContext>;
278
- /** A bounded view of the task's authoritative output, with explicit size/truncation metadata. */
279
- readBackgroundTaskOutput(taskId: string, options?: ReadBackgroundTaskOutputOptions): Promise<BackgroundTaskOutputSnapshot>;
280
- /**
281
- * Everything a task appended since `cursor` — what a live panel polls so each tick
282
- * carries only what is new, instead of re-fetching the same window. `followable: false`
283
- * means this task keeps no byte-addressable output; use `readBackgroundTaskOutput` instead.
284
- */
285
- readBackgroundTaskOutputDelta(taskId: string, options: ReadBackgroundTaskOutputDeltaOptions): Promise<BackgroundTaskOutputDelta>;
286
- stopBackgroundTask(taskId: string, reason?: string): Promise<BackgroundTaskInfo | undefined>;
287
- /**
288
- * Move a running, detachable tool call (bash / subagent / workflow) from the foreground into
289
- * a background task — the "move to background" action. Returns false if no such call is
290
- * currently in its detachable window (already finished, or not a detachable tool).
291
- */
292
- detachTool(toolCallId: string): boolean;
293
- /** Connected MCP servers and their status. Empty when no MCP capability is open. */
294
- listMcpServers(): readonly McpServerView[];
295
- /** Force-reconnect one MCP server by name. Throws if no MCP capability is open. */
296
- reconnectMcpServer(name: string): Promise<void>;
297
- createGoal(input: CreateGoalInput): Promise<GoalSnapshot>;
298
- getGoal(): Promise<GoalSnapshot | null>;
299
- pauseGoal(options?: GoalStatusInput): Promise<GoalSnapshot | null>;
300
- resumeGoal(options?: GoalStatusInput): Promise<GoalSnapshot | null>;
301
- cancelGoal(options?: GoalStatusInput): Promise<GoalSnapshot | null>;
302
- setGoalBudget(budget: GoalBudgetInput): Promise<GoalSnapshot | null>;
303
- setPlanMode(enabled: boolean, options?: PlanModeOptions): Promise<PlanData>;
304
- getPlan(): Promise<PlanData>;
305
- clearPlan(): Promise<PlanData>;
419
+ resolveSystemPromptContext(environment: Environment): Promise<SystemPromptContext>;
306
420
  /**
307
421
  * The `SessionControls` view handed to capabilities that act on the session (the extension
308
422
  * runtime's `ctx.actions`). Bound methods over the same public operations a host would call —
@@ -315,21 +429,6 @@ export declare class Session implements SessionPort {
315
429
  * than as a failure (see `isAbortError`). Idempotent — a second call is a no-op.
316
430
  */
317
431
  abort(reason?: string): void;
318
- compact(options?: CompactRequestOptions): Promise<PendingCompaction>;
319
- pendingCompaction(): Promise<PendingCompaction | null>;
320
- cancelCompaction(): Promise<PendingCompaction | null>;
321
- private updateExistingGoal;
322
- private emitControlEvent;
323
- listSkills(): Promise<readonly SkillSummary[]>;
324
- activateSkill(name: string, args?: string): Promise<SkillActivationResult>;
325
- activateSkill(request: ActivateSkillRequest): Promise<SkillActivationResult>;
326
- listPlugins(): Promise<readonly PluginSummary[]>;
327
- getPluginInfo(id: string): Promise<PluginInfo | undefined>;
328
- installPlugin(source: string): Promise<PluginSummary>;
329
- setPluginEnabled(id: string, enabled: boolean): Promise<void>;
330
- setPluginMcpServerEnabled(id: string, server: string, enabled: boolean): Promise<void>;
331
- removePlugin(id: string): Promise<void>;
332
- reloadPlugins(): Promise<ReloadSummary>;
333
432
  setModel(model: string | ChatModel): void;
334
433
  setThinking(level: ThinkingLevel): void;
335
434
  /**
@@ -348,8 +447,15 @@ export declare class Session implements SessionPort {
348
447
  drainDiagnostics(): CapabilityDiagnostic[];
349
448
  withRunLock<T>(body: () => Promise<T>): Promise<T>;
350
449
  flushEvents(): Promise<void>;
450
+ /**
451
+ * Close the session: flush telemetry and the store, then close the scope — which disposes
452
+ * every capability provision in reverse order (each under a deadline) and finally the
453
+ * session's own infrastructure. Every call returns the SAME promise, so a second caller
454
+ * (or the facade above) waits for the teardown instead of returning while it is still running.
455
+ */
351
456
  close(): Promise<void>;
352
- /** Public URL for a port inside the machine, or undefined when the backend can't expose one. */
457
+ private runClose;
458
+ /** Public URL for a port inside the environment, or undefined when the backend can't expose one. */
353
459
  resolveExposedPort(port: number): Promise<string | undefined>;
354
460
  }
355
461
  /** Plain text of a message content (string, or the text parts of a content array). */