@x-otto/runtime 0.0.1-alpha.5 → 0.0.1-alpha.7

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.
package/README.md CHANGED
@@ -63,13 +63,14 @@ runtime.hookRegistry.register(defineHook({
63
63
  | Field | Default | Description |
64
64
  |-------|---------|-------------|
65
65
  | `workspaceDir` | `process.cwd()` | Workspace root |
66
- | `providerRegistry` | `createDefaultProviderRegistry()` | LLM provider registry |
66
+ | `providerRegistry` | `createProviderRegistry()` | LLM provider registry (empty registry; providers loaded by host plugins) |
67
67
  | `hookRegistry` | `createHookRegistry({preset:'default'})` | Hook container |
68
68
  | `clock` | system clock | Deterministic clock (replay feed) |
69
69
  | `traceStore` | `MemoryAppendLog` | Trace storage backend |
70
70
  | `checkpointStore` | `MemoryAppendLog` | Checkpoint storage backend |
71
71
  | `memory` | `undefined` | Auto memory compression port |
72
72
  | `maxSessions` | env `SESSION_MAX`(50) | Session pool capacity |
73
+ | `idleTimeoutMs` | env `SESSION_IDLE_TIMEOUT_MS` | Idle session timeout |
73
74
  | `storage` | `{kind:'in-memory'}` | Persistence backend (disk/remote/custom) |
74
75
 
75
76
  ### `AgentRuntime`
@@ -86,7 +87,7 @@ runtime.hookRegistry.register(defineHook({
86
87
 
87
88
  ### `RUNTIME_DEFAULTS`
88
89
 
89
- Single source of truth for cross-layer defaults: `{ maxToolTurns: 25 }` (references `ENGINE_DEFAULTS`).
90
+ Single source of truth for cross-layer defaults: `{ maxToolTurns: 120 }` (references `ENGINE_DEFAULTS` from `@x-otto/agent`).
90
91
 
91
92
  ### Process & Fleet Governance
92
93
 
@@ -98,7 +99,7 @@ Single source of truth for cross-layer defaults: `{ maxToolTurns: 25 }` (referen
98
99
 
99
100
  ## Dependencies
100
101
 
101
- - Internal: `@x-otto/agent`, `@x-otto/ai`, `@x-otto/devtools`, `@x-otto/env`, `@x-otto/hooks`, `@x-otto/persistence`, `@x-otto/prompt`, `@x-otto/session`, `@x-otto/session-contract`, `@x-otto/shared`
102
+ - Internal: `@x-otto/agent`, `@x-otto/ai`, `@x-otto/devtools`, `@x-otto/env`, `@x-otto/hooks`, `@x-otto/interchange`, `@x-otto/persistence`, `@x-otto/prompt`, `@x-otto/session`, `@x-otto/session-contract`, `@x-otto/shared`
102
103
  - External: `node:crypto`, `node:fs/promises`, `node:path`, `node:child_process`
103
104
 
104
105
  ## Related
package/dist/index.d.ts CHANGED
@@ -4,12 +4,207 @@ import { EventBus, Events, Logger, TypedEventEmitter } from "@x-otto/shared";
4
4
  import { AppendLog, PanelStateDraftEntry, PanelStateEditedFile, PanelStatePersistence, PanelStateSnapshot, PanelStateSubagentEntry, PanelStateTodoItem, PanelStateTurnSummary, PasteStatePersistence, PasteStateSnapshot } from "@x-otto/persistence";
5
5
  import { InMemorySession, LeaseInspection, Session, SessionEntry, SessionPersistence, SessionSnapshot } from "@x-otto/session";
6
6
  import { OttoProcessInfo } from "@x-otto/env";
7
- import { Agent, AgentEvent, AgentMessage, AgentSessionEvent, AgentSessionEventMap, AgentSessionEventType, AgentSessionSubscriber, AgentTool, ApprovalRisk, AskUserQuestion, ClockPort, DescribeImagesPort, GrillAnswer, GrillQuestion, GrillRequest, MemoryPort, MemoryPort as MemoryPort$1, StreamFunction, StreamRetryConfig, ToolHookExecutor, ToolResult, TraceEvent, TraceRecorder, applyMemoryTransform } from "@x-otto/agent";
7
+ import { Agent, AgentEvent, AgentMessage, AgentSessionEvent, AgentSessionEventMap, AgentSessionEventType, AgentSessionSubscriber, AgentTool, ApprovalRisk, AskUserQuestion, ClockPort, DescribeImagesPort, GrillAnswer, GrillQuestion, GrillRequest, IdPort, MemoryPort, MemoryPort as MemoryPort$1, RandomPort, StreamFunction, StreamRetryConfig, ToolHookExecutor, ToolResult, TraceEvent, TraceRecorder, applyMemoryTransform } from "@x-otto/agent";
8
8
  import * as _$_x_otto_session_contract0 from "@x-otto/session-contract";
9
9
  import { ResidencyBudgetConfig, TurnRecord, TurnRecord as TurnRecord$1 } from "@x-otto/session-contract";
10
10
  import { ChildProcess, SpawnOptions } from "node:child_process";
11
11
  import { Devtools } from "@x-otto/devtools";
12
12
 
13
+ //#region src/plane/host-registry.d.ts
14
+ type RegistrationPlane = 'host' | 'preset';
15
+ /** 注册条目公共字段(平面无关)。 */
16
+ interface BasePlaneEntry {
17
+ /** 条目唯一 id(格内唯一;插件注册约定 `plugin:<pluginId>` / `waterfall:<timing>`)。 */
18
+ id: string;
19
+ /** 贡献类型标签('plugin' 身份声明 / 'waterfall' 贡献 / 未来轴)。 */
20
+ kind: string;
21
+ /** 贡献载荷(注册者语义自定)。 */
22
+ value: unknown;
23
+ /** 来源插件 id(非插件来源的注册可省略)。 */
24
+ pluginId?: string;
25
+ /**
26
+ * R6':来源插件 manifest 版本(信任绑定版本——插件更新后需重新评估白名单,
27
+ * trust 不跨版本自动存续)。非插件来源注册可省略。
28
+ */
29
+ pluginVersion?: string;
30
+ }
31
+ /**
32
+ * host 平面条目草稿(进程级单例)。`plane: 'host'` + `scope: 'process'` 为编译期
33
+ * 字面量——只能传给 HostRegistry.register(),传进任何 PRESET 格注册 API 即编译错误。
34
+ */
35
+ type HostPlaneDraft = BasePlaneEntry & {
36
+ readonly plane: 'host';
37
+ readonly scope: 'process';
38
+ };
39
+ /** PRESET workspace 格条目草稿——`scope: 'workspace'` 只能传给 workspace 格的注册 API。 */
40
+ type WorkspacePresetDraft = BasePlaneEntry & {
41
+ readonly plane: 'preset';
42
+ readonly scope: 'workspace';
43
+ };
44
+ /** PRESET 会话格条目草稿——`scope: 'session'` 只能传给会话格的注册 API。 */
45
+ type SessionPresetDraft = BasePlaneEntry & {
46
+ readonly plane: 'preset';
47
+ readonly scope: 'session';
48
+ };
49
+ /** 已盖章的 host 平面条目(无附加键)。 */
50
+ interface HostPlaneEntry extends HostPlaneDraft {}
51
+ /** 已盖章的 PRESET workspace 条目——workspaceKey 由格在注册时盖章(调用方不可自报)。 */
52
+ interface WorkspacePresetEntry extends WorkspacePresetDraft {
53
+ /** 所属 workspace key(`ws_<uuid>`)。由格盖章,非调用方自报。 */
54
+ workspaceKey: string;
55
+ }
56
+ /** 已盖章的 PRESET 会话条目——sessionId 由格在注册时盖章(调用方不可自报)。 */
57
+ interface SessionPresetEntry extends SessionPresetDraft {
58
+ /** 所属会话 id。由格盖章,非调用方自报。 */
59
+ sessionId: string;
60
+ }
61
+ type PlaneEntry = HostPlaneEntry | WorkspacePresetEntry | SessionPresetEntry;
62
+ /** 发射端上下文(host 单点发射携带)。缺省字段 = 不匹配对应平面。 */
63
+ interface EmitContext {
64
+ /** 发射时已知的会话 id——会话格条目仅当匹配才可达。 */
65
+ sessionId?: string;
66
+ /** 发射时已知的 workspace key——workspace 格条目仅当匹配才可达。 */
67
+ workspaceKey?: string;
68
+ }
69
+ /** R6' 版本漂移条目(插件更新后残留的旧版本注册,需重新评估)。 */
70
+ interface StalePlaneEntry {
71
+ entry: PlaneEntry;
72
+ /** 注册时快照的版本。 */
73
+ registeredVersion: string | undefined;
74
+ /** 插件当前 manifest 版本(可能缺省——manifest 无版本字段)。 */
75
+ currentVersion: string | undefined;
76
+ }
77
+ /** PRESET workspace 格(注册 + 列表 + 清理)。 */
78
+ declare class WorkspacePresetGrid {
79
+ /** workspace key(`ws_<uuid>`)——构造时由 HostRegistry.workspace() 传入。 */
80
+ readonly key: string;
81
+ private readonly entries;
82
+ /** 已 dispose(格关闭后拒绝新注册,fail-closed)。 */
83
+ private disposed;
84
+ constructor(/** workspace key(`ws_<uuid>`)——构造时由 HostRegistry.workspace() 传入。 */
85
+
86
+ key: string);
87
+ /**
88
+ * 注册一条 workspace 级 PRESET 贡献。同 id 重复注册 = 整体替换(R6':新评估覆盖
89
+ * 旧评估,不继承——插件更新后经 unregister→register 全量替换)。
90
+ */
91
+ register(draft: WorkspacePresetDraft): WorkspacePresetEntry;
92
+ unregister(id: string): boolean;
93
+ /** 撤销某插件的全部条目(pluginId 匹配)。返回撤销条数。 */
94
+ unregisterByPlugin(pluginId: string): number;
95
+ list(): readonly WorkspacePresetEntry[];
96
+ /** workspace 关闭 → 清空本格。幂等。 */
97
+ dispose(): void;
98
+ }
99
+ /** PRESET 会话格(注册 + 列表 + 清理)。 */
100
+ declare class SessionPresetGrid {
101
+ readonly sessionId: string;
102
+ private readonly entries;
103
+ private disposed;
104
+ constructor(sessionId: string);
105
+ register(draft: SessionPresetDraft): SessionPresetEntry;
106
+ unregister(id: string): boolean;
107
+ unregisterByPlugin(pluginId: string): number;
108
+ list(): readonly SessionPresetEntry[];
109
+ /** 会话 dispose → 清空本格。幂等。 */
110
+ dispose(): void;
111
+ }
112
+ /** PRESET workspace 作用域句柄——`workspace.preset.register()`(RFC-327 D2 API 形状)。 */
113
+ declare class WorkspacePresetScope {
114
+ readonly workspaceKey: string;
115
+ /**
116
+ * PRESET workspace 格。注册 API 形状 = `workspace.preset.register(draft)`。
117
+ * 语义同 WorkspacePresetGrid(注册/撤销/列表/清理),随 workspace 生命周期。
118
+ */
119
+ readonly preset: WorkspacePresetGrid;
120
+ constructor(workspaceKey: string);
121
+ /** workspace 关闭 → 清 workspace 格(R2':HOST 桶不受影响)。幂等。 */
122
+ dispose(): void;
123
+ }
124
+ /** PRESET 会话作用域句柄——`session.preset.register()`(RFC-327 D2 API 形状)。 */
125
+ declare class SessionPresetScope {
126
+ readonly sessionId: string;
127
+ /**
128
+ * PRESET 会话格。注册 API 形状 = `session.preset.register(draft)`。
129
+ * 语义同 SessionPresetGrid(注册/撤销/列表/清理),随会话生命周期。
130
+ */
131
+ readonly preset: SessionPresetGrid;
132
+ constructor(sessionId: string);
133
+ /** 会话 dispose → 清会话格(R2':HOST 桶与 workspace 格不受影响)。幂等。 */
134
+ dispose(): void;
135
+ }
136
+ /**
137
+ * HostRegistry —— 进程级单例注册表(RFC-327 修订 D2,T-327-M2-01/02)。
138
+ *
139
+ * 三桶:host 平面(进程级单例)+ PRESET workspace 格(按 workspaceKey)+ PRESET
140
+ * 会话格(按 sessionId)。生命周期=进程;dispose() 清空全部。
141
+ *
142
+ * 编译期跨平面拒绝(R2'):register 只收 HostPlaneDraft(plane:'host'),
143
+ * workspace/session 格的注册 API 只收各自字面量草稿——跨平面注册在类型层即失败。
144
+ */
145
+ declare class HostRegistry {
146
+ private readonly hostEntries;
147
+ private readonly workspaceScopes;
148
+ private readonly sessionScopes;
149
+ private disposed;
150
+ private ensureNotDisposed;
151
+ /** host 平面注册(进程级单例)。`host.register()`(RFC-327 D2 API 形状)。 */
152
+ register(draft: HostPlaneDraft): HostPlaneEntry;
153
+ unregister(id: string): boolean;
154
+ /** 撤销某插件在 host 平面的全部条目。返回撤销条数。 */
155
+ unregisterByPlugin(pluginId: string): number;
156
+ /** host 平面条目(进程级单例,不随任何会话/workspace 清理)。 */
157
+ list(): readonly HostPlaneEntry[];
158
+ /**
159
+ * PRESET workspace 格句柄(ensure 语义——workspace 挂载/首次注册时建格,幂等)。
160
+ * 注册 API 形状 = `workspace.preset.register(draft)`。
161
+ */
162
+ workspace(workspaceKey: string): WorkspacePresetScope;
163
+ /**
164
+ * PRESET 会话格句柄(ensure 语义——会话创建时派生会话格,幂等)。
165
+ * 注册 API 形状 = `session.preset.register(draft)`。
166
+ */
167
+ session(sessionId: string): SessionPresetScope;
168
+ /** workspace 关闭 → 清 workspace 格(不重建;不存在即 no-op)。 */
169
+ disposeWorkspaceGrid(workspaceKey: string): void;
170
+ /**
171
+ * RFC-327 修订 D2(M2,应用点 B 建议修订):把 `fromKey` 格的条目迁移到 `toKey` 格。
172
+ *
173
+ * 场景:pendingWorkspaceInit(交互态首次打开待信任确认)路径下插件 reload 先于
174
+ * workspaceRef 就位,PMM 用 DEFAULT_WORKSPACE_KEY('default')兜底注册;真实 key
175
+ * 就位后(completeWorkspaceDependentStartup)必须把 default 格条目迁到真实格,
176
+ * 否则两格并存、发射端按真实 key 路由查不到插件条目。
177
+ *
178
+ * 语义:条目按 id 迁移(整体搬,不重新盖章之外不改变语义);fromKey 格迁移后清空
179
+ * 且 dispose(fail-closed,防后续误注册到已废弃格)。fromKey 不存在 / toKey===fromKey
180
+ * 均为 no-op。只迁移 workspace 级条目(host/会话格不涉及)。
181
+ */
182
+ migrateWorkspaceGrid(fromKey: string, toKey: string): void;
183
+ /** 会话 dispose → 清会话格(不重建;不存在即 no-op)。 */
184
+ disposeSessionGrid(sessionId: string): void;
185
+ /** 撤销某插件在全部平面(host + 全部 workspace 格 + 全部会话格)的条目。返回撤销条数。 */
186
+ unregisterByPluginEverywhere(pluginId: string): number;
187
+ /**
188
+ * R6' 版本漂移检出:返回 pluginId 名下所有注册版本 ≠ 当前版本的条目。
189
+ * 插件更新后,正常 reload 走 unregister→register 全量替换;本方法兜底检出
190
+ * 「旧版本条目残留」(脏插件/撤销失败等异常路径)——调用方应据此重新评估
191
+ * 白名单(trust 不跨版本自动存续)。`currentVersion` 为 undefined(manifest
192
+ * 无版本)时,无版本条目视为一致、带版本条目视为漂移(需重新评估)。
193
+ */
194
+ revalidatePlugin(pluginId: string, currentVersion: string | undefined): StalePlaneEntry[];
195
+ /**
196
+ * 发射端路由(host 单点发射携带上下文)——按上下文过滤 PRESET 注册:
197
+ * host 平面条目恒达(进程级单例);
198
+ * workspace 格条目仅当 ctx.workspaceKey 匹配;
199
+ * 会话格条目仅当 ctx.sessionId 匹配(s1 事件不达 s2 的 PRESET)。
200
+ */
201
+ resolveForEmit(ctx: EmitContext): readonly PlaneEntry[];
202
+ /** 全部平面的全部条目(诊断/审计用)。 */
203
+ listAll(): readonly PlaneEntry[];
204
+ /** 进程生命周期结束 → 清空全部平面(host + workspace 格 + 会话格)。幂等。 */
205
+ dispose(): void;
206
+ }
207
+ //#endregion
13
208
  //#region src/context-source.d.ts
14
209
  interface ContextSource {
15
210
  /** 本源的唯一标识。重复注册→覆盖前一次同 id 源。 */
@@ -57,6 +252,10 @@ declare class ContextSourceRegistry {
57
252
  sealAndBuildHooks(workspaceDir?: string, memory?: ContextBuildInput['memory']): HookSpec[];
58
253
  }
59
254
  //#endregion
255
+ //#region src/session/semantic-reviewer.d.ts
256
+ type SemanticReviewerVerdict = 'allow' | 'deny' | 'abstain';
257
+ type SemanticReviewer = (toolName: string, args: Record<string, unknown>, description: string, risk?: ApprovalRisk) => Promise<SemanticReviewerVerdict>;
258
+ //#endregion
60
259
  //#region src/context-sources/memory-delta.d.ts
61
260
  /**
62
261
  * memory-delta(#3 volatile memory delta)
@@ -294,6 +493,12 @@ interface AgentSessionOptions {
294
493
  */
295
494
  parentTaskId?: string;
296
495
  interactive?: boolean;
496
+ /**
497
+ * RFC-380 T4:LLM 语义审批层(opt-in)。仅升级审批(sandbox-denied escalate ask)
498
+ * 且配置时生效;allow/deny 自动裁决(宿主侧需消费 approval.required 的
499
+ * semanticVerdict 记命令 bypass),abstain/未配置 → 既有用户弹窗流程。
500
+ */
501
+ semanticReviewer?: SemanticReviewer;
297
502
  /**
298
503
  * 是否在 `/resume` 列表中可见(缺省 = 可见)。`false` 用于 headless 一次性内部会话
299
504
  * (`otto --print/--json`)——照常落盘(sessionId/trace 有外部契约消费方),但不进列表。
@@ -992,6 +1197,15 @@ interface SessionPoolOptions {
992
1197
  * 确定性时钟端口。缺省=真实系统时钟(行为不变);replay 由 trace 回灌。
993
1198
  */
994
1199
  clock?: ClockPort;
1200
+ /**
1201
+ * 确定性 id 生成端口(M-2)。缺省=systemId(crypto.randomUUID);replay/测试注入固定序列。
1202
+ * 透传给 InMemorySession 与 fork 产物。
1203
+ */
1204
+ idGen?: IdPort;
1205
+ /**
1206
+ * 确定性随机端口(M-2)。缺省=systemRandom(Math.random);replay 由 trace 回灌。
1207
+ */
1208
+ randomGen?: RandomPort;
995
1209
  /**
996
1210
  * 仅用于 restore / restoreAll 场景。
997
1211
  * 正常 createSession 路径必须传入完整 ResolvedSessionConfig,不使用此字段。
@@ -1011,6 +1225,13 @@ interface SessionPoolOptions {
1011
1225
  residencyGovernor?: ResidencyGovernor;
1012
1226
  /** RFC-323 M4:驻留预算运行时配置 getter(settings 注入,透传给 PersistenceSync)。 */
1013
1227
  getResidencyConfig?: () => _$_x_otto_session_contract0.ResidencyBudgetConfig | undefined;
1228
+ /**
1229
+ * RFC-327 修订 D2(M2):双平面注册边界——进程级 HostRegistry(可选注入)。
1230
+ * 注入后会话在进池(create/fork/restore 三个装池点)时派生 PRESET 会话格,
1231
+ * 出池(remove/idle 驱逐/LRU 驱逐/池 dispose)时清理会话格。未注入 = 不派生
1232
+ * (宿主不接双平面即零影响)。
1233
+ */
1234
+ planeRegistry?: HostRegistry;
1014
1235
  /**
1015
1236
  * RFC-146:本地高效冷会话枚举策略(可选注入)。仅本地 SQLite 后端在
1016
1237
  * `session-pool-factory.ts` 构造期注入(内部持有 `SqliteSessionRepository`,
@@ -1107,8 +1328,12 @@ declare class SessionPool {
1107
1328
  private readonly traceStore?;
1108
1329
  private readonly checkpointStore?;
1109
1330
  private readonly clock?;
1331
+ private readonly idGen;
1332
+ private readonly randomGen;
1110
1333
  private readonly residencyGovernor?;
1111
1334
  private readonly getResidencyConfig?;
1335
+ /** RFC-327 修订 D2(M2):双平面注册边界——会话格派生/清理的宿主注册表(可选)。 */
1336
+ private readonly planeRegistry?;
1112
1337
  private readonly configProvider?;
1113
1338
  /** RFC-146:本地高效冷会话枚举策略(可选,见 SessionPoolOptions.listColdSessionsOverride)。 */
1114
1339
  private readonly listColdSessionsOverride?;
@@ -1152,8 +1377,14 @@ declare class SessionPool {
1152
1377
  /**
1153
1378
  * 登记"会话进池时刻"(create/fork/restore 三个装池点)。纯进程内状态,永不落盘,
1154
1379
  * 不会污染 `/resume` 展示的 `lastActiveAt`。活动侧续期见 `residencySince`。
1380
+ *
1381
+ * RFC-327 修订 D2(M2):同一装池点是会话格的派生点——派生 PRESET 会话格
1382
+ * (`session.preset.register()` 的目标)。会话级贡献随会话 dispose 清理
1383
+ * (见 clearSessionPlaneGrid 在四个出池点的调用)。
1155
1384
  */
1156
1385
  private admitToResidency;
1386
+ /** RFC-327 修订 D2(M2):会话出池 → 清理 PRESET 会话格(不重建;未派生即 no-op)。 */
1387
+ private clearSessionPlaneGrid;
1157
1388
  /**
1158
1389
  * 驱逐判据用的"最近驻留活动时刻" = **进池时刻与真实活动时间中较新的那个**。
1159
1390
  *
@@ -1258,15 +1489,15 @@ declare class SessionPool {
1258
1489
  * 不阻塞会话删除本身)。
1259
1490
  */
1260
1491
  private clearSessionStores;
1261
- /**
1262
- * fork 直接复用 source session 自身的已解析配置,
1263
- * 消息通过复制 snapshot entries 完整迁移。
1264
- */
1265
1492
  /**
1266
1493
  * RFC-160 D3/D4:出口 hydrate(fork 用)。无剥离态直通;有剥离态且持久层具备能力则回填;
1267
1494
  * 能力缺席 → 断言炸(接线遗漏立即暴露,绝不把剥离态固化为新会话正文)。
1268
1495
  */
1269
1496
  private ensureEntriesHydrated;
1497
+ /**
1498
+ * fork 直接复用 source session 自身的已解析配置,
1499
+ * 消息通过复制 snapshot entries 完整迁移。
1500
+ */
1270
1501
  forkSession(sourceId: string, newId?: string): Promise<AgentSession | undefined>;
1271
1502
  save(id: string): Promise<void>;
1272
1503
  saveAll(): Promise<void>;
@@ -1406,6 +1637,13 @@ interface RuntimeOptions {
1406
1637
  residencyGovernor?: ResidencyGovernor;
1407
1638
  /** RFC-323 M4:驻留预算运行时配置 getter(settings 注入透传)。 */
1408
1639
  getResidencyConfig?: () => _$_x_otto_session_contract0.ResidencyBudgetConfig | undefined;
1640
+ /**
1641
+ * RFC-327 修订 D2(M2):双平面注册边界——进程级 HostRegistry(可选注入)。
1642
+ * 注入后会话池在会话创建/fork/restore 时派生 PRESET 会话格,会话移除/驱逐/池
1643
+ * dispose 时清理会话格(对齐「会话创建派生会话格、会话 dispose 清会话格」生命周期)。
1644
+ * 未注入 = 会话格不派生(行为不变,宿主不接双平面即零影响)。
1645
+ */
1646
+ planeRegistry?: HostRegistry;
1409
1647
  }
1410
1648
  interface AgentRuntime {
1411
1649
  /** 统一派生入口:子 runtime / 宿主 / swarm / task-runner 皆经此(§4-11)。 */
@@ -1649,11 +1887,6 @@ declare class MemoryGovernor {
1649
1887
  constructor(options?: MemoryGovernorOptions);
1650
1888
  /** 当前分级(供外部只读查询,如 TUI 状态展示)。 */
1651
1889
  get currentLevel(): MemoryPressureLevel;
1652
- /**
1653
- * 晚绑定 onWarning/onCritical/onCriticalDuringGrace(App 构造时活跃 session 尚不存在,
1654
- * M2/M3 在 session 就绪后调用注入)。对齐 `App.setScheduleService` 的晚绑定模式,
1655
- * 非构造期可选依赖。
1656
- */
1657
1890
  /**
1658
1891
  * 合并式更新(每个字段独立覆盖,未传的字段保留原值)——RFC-115 追补:`app.ts`
1659
1892
  * 启动期注入 `onSample`(trace 落盘)后,`interactive.ts` 会话就绪时再调用一次
@@ -2077,6 +2310,12 @@ interface ApplyDiffResult {
2077
2310
  * apply 可能出乎意料地冲突/无冲突",不用来拒绝 apply。
2078
2311
  */
2079
2312
  declare function hasRepoDrifted(repoRoot: string, base: string): boolean;
2313
+ /**
2314
+ * 纯预检:diff 能否干净 apply 到主仓工作区(`git apply --check`,无任何副作用)。
2315
+ * 供 governance/apply-policy 的 `conflict` 信号使用——在真正 `applyDiff` 之前判定"是否可干净
2316
+ * 落地"。空 diff 视为干净。true=无冲突可落地;false=有冲突/无法判定(交给 applyDiff 兜底)。
2317
+ */
2318
+ declare function checkApply(repoRoot: string, diff: string): boolean;
2080
2319
  /**
2081
2320
  * 把作业 diff apply 到主仓工作区。**check-first,不强改**:先 `git apply --check` 验证能否干净
2082
2321
  * 应用——能才真 apply;不能(主仓漂移/冲突)则返回 applied=false + conflictPaths,**绝不**往主树
@@ -2611,9 +2850,9 @@ declare function createDocSyncReminderHooks(port: DocSyncPort, priority?: 64): H
2611
2850
  *
2612
2851
  * 放在 @x-otto/runtime(coding 依赖 runtime、反向不依赖):coding 侧 hook 经 `@x-otto/runtime` import。
2613
2852
  * 注:本表是**排序权威**(方案 H:section 仍由各自 hook 自注册,priority 数字降级为对本表的引用);
2614
- * 不强行把 `SYSTEM_PROMPT_SECTIONS` 各 section 物理并入单一 registry(那超出外科尺度、非目标)——
2853
+ * 不强行把 `SYSTEM_PROMPT_SECTIONS` 各 section 物理并入单一 registry(那超出外科尺度、非目标)。
2615
2854
  * section 数量以该常量的字段数为准,不在本段注释里重复写死具体数字(history: 建表时 7 个,
2616
- * 后追加 docSyncReminder 成 8 个,写死数字会重犯本次发现的漂移)。
2855
+ * 后追加 docSyncReminder 成 8 个,又补 skillLoopGuidance 成 9 个——写死数字会重犯本次发现的漂移)。
2617
2856
  */
2618
2857
  type SystemPromptLane = 'stable' | 'volatile';
2619
2858
  interface SystemPromptSectionSpec {
@@ -2656,7 +2895,7 @@ declare const SYSTEM_PROMPT_SECTIONS: {
2656
2895
  readonly name: "runtime:memory-index";
2657
2896
  readonly priority: 35;
2658
2897
  readonly lane: "stable";
2659
- readonly budgetBytes: 30000;
2898
+ readonly budgetBytes: 24000;
2660
2899
  };
2661
2900
  readonly skillCatalog: {
2662
2901
  readonly name: "skill-catalog-injection";
@@ -2664,11 +2903,32 @@ declare const SYSTEM_PROMPT_SECTIONS: {
2664
2903
  readonly lane: "stable";
2665
2904
  readonly budgetBytes: 12000;
2666
2905
  };
2906
+ /** RFC-374 M3 初始 8KB 低于 RFC-382 T5/T6 重建后的常态内容(8.5KB 实测,2026-08-14)——
2907
+ * 字节顶须 > 常态内容(防御失控注入而非改变正常行为),否则每次构建静默截掉 pack 尾部。
2908
+ * 10KB 维持 ~1.2x 防御余量;token 侧仍受 RFC-284 8k soft/12k hard 预算约束。 */
2667
2909
  readonly lesson: {
2668
2910
  readonly name: "lesson-injection";
2669
2911
  readonly priority: 40;
2670
2912
  readonly lane: "stable";
2671
- readonly budgetBytes: 8000;
2913
+ readonly budgetBytes: 10000;
2914
+ }; /** RFC-318 R7 治理补全:lesson-relevant-hints 原为表外 hook,现纳入统一预算面(volatile 尾段)。 */
2915
+ readonly lessonRelevantHints: {
2916
+ readonly name: "lesson-relevant-hints";
2917
+ readonly priority: 41;
2918
+ readonly lane: "volatile";
2919
+ readonly budgetBytes: 4000;
2920
+ };
2921
+ /**
2922
+ * RFC-383 M2(§9 修订 6):高频 skill 内化指令核心——引擎内部 hook
2923
+ * `internalize-skill-injection` 的 volatile 尾段预算面。**必须注册**:不注册则
2924
+ * applySectionBudget 原样放行、4KB 硬顶失效(决策器提炼不受控)。priority 42 排在
2925
+ * lessonRelevantHints(41) 之后、memoryDelta(60) 之前。
2926
+ */
2927
+ readonly internalize: {
2928
+ readonly name: "internalize-skill-injection";
2929
+ readonly priority: 42;
2930
+ readonly lane: "volatile";
2931
+ readonly budgetBytes: 4000;
2672
2932
  };
2673
2933
  readonly memoryDelta: {
2674
2934
  readonly name: "memory-delta-injection";
@@ -2693,6 +2953,11 @@ declare const SYSTEM_PROMPT_SECTIONS: {
2693
2953
  * RFC-374 M3:按 section name 应用注入预算。内容超预算时裁剪(boundFragment,
2694
2954
  * 纯文本截断后缀,RFC-142 红线兼容);name 不在表中时原样返回(插件自定义
2695
2955
  * context source 不受本表预算约束——它不进表就不进预算面,是显式而非默认)。
2956
+ *
2957
+ * 截断诊断(08-14 lesson 字节顶事故跟进):超预算裁剪是静默丢信息——内容里的
2958
+ * 截断后缀模型能看见但宿主日志看不见,预算配置漂移(如 pack 内容长大超过
2959
+ * budgetBytes)只表现为「注入内容莫名缺尾」。此处 warn(每进程每 section 一次)
2960
+ * 把截断升级为可诊断事件,触发即提示检查 budgetBytes 与内容常态体积是否匹配。
2696
2961
  */
2697
2962
  declare function applySectionBudget(name: string, content: string): string;
2698
2963
  //#endregion
@@ -2705,6 +2970,18 @@ interface SessionStableInjectionOptions {
2705
2970
  }
2706
2971
  declare function createSessionStableInjectionHooks(options: SessionStableInjectionOptions): HookSpec[];
2707
2972
  //#endregion
2973
+ //#region src/session/tool-result-store-global.d.ts
2974
+ /**
2975
+ * tool-result-store-global.ts — RFC-093:ToolResultStore 全局单例
2976
+ *
2977
+ * AgentSession 构造 spill 闭包时引用。懒初始化(首次 spill 时基于 cwd 解析 .otto 目录)——
2978
+ * 避免模块加载期做 fs 探测。
2979
+ */
2980
+ declare const globalToolResultStore: {
2981
+ spill(sessionId: string, toolCallId: string, text: string): Promise<string | undefined>;
2982
+ cleanupSession(sessionId: string): Promise<void>;
2983
+ };
2984
+ //#endregion
2708
2985
  //#region src/session/derive-title.d.ts
2709
2986
  /**
2710
2987
  * 从会话消息列表中派生标题(RFC-030 P1)。
@@ -2736,6 +3013,21 @@ interface ToolHookOptions {
2736
3013
  }
2737
3014
  declare function createToolHookExecutor(options: ToolHookOptions): ToolHookExecutor;
2738
3015
  //#endregion
3016
+ //#region src/session/session-compaction-lock.d.ts
3017
+ /**
3018
+ * RFC-381 M1/M2:跨进程 durable 压缩锁端口(与 @x-otto/memory 的 CompactionLockPort
3019
+ * 结构同形——runtime 不依赖 memory 包,结构子类型即满足;memory 侧注入处见
3020
+ * MemoryManagerConfig.compactionLock)。
3021
+ */
3022
+ interface SessionCompactionLockPort {
3023
+ acquire(sessionId: string, token: string): Promise<boolean>;
3024
+ release(sessionId: string, token: string): Promise<void>;
3025
+ }
3026
+ declare const DEFAULT_COMPACTION_LOCK_ORPHAN_TIMEOUT_MS = 60000;
3027
+ declare function createSessionCompactionLock(session: Session<unknown>, options?: {
3028
+ orphanTimeoutMs?: number;
3029
+ }): SessionCompactionLockPort;
3030
+ //#endregion
2739
3031
  //#region src/session/persistence-sync.d.ts
2740
3032
  interface PersistenceSyncDeps {
2741
3033
  persistence: SessionPersistence<AgentMessage>;
@@ -2786,6 +3078,15 @@ interface PersistenceSyncDeps {
2786
3078
  * 这是后端能力事实,不是用户配置——未来远端支持 append-tail 后改声明即可自动升级。
2787
3079
  */
2788
3080
  turnFlush?: 'incremental' | 'snapshot';
3081
+ /**
3082
+ * M-2:确定性时钟端口(可选)。restore/restoreAll 装载快照时注入 InMemorySession——
3083
+ * restore 本身不产生活动(快照 metadata 权威),但为确定性重放/测试保持一致构造。
3084
+ */
3085
+ clock?: ClockPort;
3086
+ /**
3087
+ * M-2:确定性 id 生成端口(可选)。restore 路径不 append entry,故当前仅作一致性注入。
3088
+ */
3089
+ idGen?: IdPort;
2789
3090
  }
2790
3091
  declare class PersistenceSync {
2791
3092
  private readonly deps;
@@ -2862,13 +3163,6 @@ declare class PersistenceSync {
2862
3163
  */
2863
3164
  track(agentSession: AgentSession, transient: boolean): void;
2864
3165
  flushPending(id: string): Promise<void>;
2865
- /**
2866
- * P2 缓解(独立 review 补充,2026-07-12):会话可能经 idle 驱逐(`collectIdle`)或满池 LRU
2867
- * 驱逐(`evictLeastRecent`)消失,这两条路径不经过 `removeSession`/`flushPending`(前者是
2868
- * 同步批量收集不适合 await 落盘完成,后者已自行 fire-and-forget 触发 `saveSnapshot`)——
2869
- * 提供一个轻量同步纯清理方法,供这两条驱逐路径调用,与 `flushPending` 共享同一清理意图
2870
- * 但不附带"等待落盘完成"的语义(驱逐场景不需要,也不应阻塞驱逐循环)。
2871
- */
2872
3166
  /**
2873
3167
  * RFC-323 D4:计算用于预算分配的活跃会话数(排除 transient)。
2874
3168
  *
@@ -2886,6 +3180,13 @@ declare class PersistenceSync {
2886
3180
  * 一致地排除 transient(不订阅持久化、不参与预算分摊)。
2887
3181
  */
2888
3182
  private sumEstimatedContentBytes;
3183
+ /**
3184
+ * P2 缓解(独立 review 补充,2026-07-12):会话可能经 idle 驱逐(`collectIdle`)或满池 LRU
3185
+ * 驱逐(`evictLeastRecent`)消失,这两条路径不经过 `removeSession`/`flushPending`(前者是
3186
+ * 同步批量收集不适合 await 落盘完成,后者已自行 fire-and-forget 触发 `saveSnapshot`)——
3187
+ * 提供一个轻量同步纯清理方法,供这两条驱逐路径调用,与 `flushPending` 共享同一清理意图
3188
+ * 但不附带"等待落盘完成"的语义(驱逐场景不需要,也不应阻塞驱逐循环)。
3189
+ */
2889
3190
  forgetSession(id: string): void;
2890
3191
  /**
2891
3192
  * RFC-352 D2:驱逐的最终 snapshot 仍在队列中时不能提前清 residency 状态。
@@ -2908,26 +3209,6 @@ declare class PersistenceSync {
2908
3209
  */
2909
3210
  private isTransient;
2910
3211
  save(id: string): Promise<void>;
2911
- /**
2912
- * RFC-336 D1:会话行预建——会话创建即落 `sessions` 一行(无 entries),不等首条消息。
2913
- *
2914
- * **要解决的问题**(实测复现,2026-08-10):`repo.createSession()` 的唯一调用点是
2915
- * `RelationalSessionPersistence.save()`,而 save 由 `track()` 订阅的 `turn.end`/
2916
- * `prompt.end` 触发——两者都发生在**首个模型回合完成之后**。因此"用户已回车、模型还没
2917
- * 回任何东西"这段窗口(≈ 一次完整模型往返,数秒~数十秒)内进程若被强杀(SIGKILL/OOM/
2918
- * 断电),DB 里连 `sessions` 行都不存在 → 整个会话蒸发,`/resume` 完全看不到,
2919
- * 且 `detectCrashGap` 因 `load()` 返回 null 而根本不执行(RFC-305 D3 的盲区)。
2920
- *
2921
- * **为什么复用 doSaveEntries 而非直调 repo**(D1-b,RFC-159 D3):写租约检查在
2922
- * `RelationalSessionPersistence.save()` 入口,是所有会话写路径的单一汇聚点。直调
2923
- * `repo.createSession()` 会开一条无租约的写路径先例。走这里则天然经 `enqueue` 串行链
2924
- * → `doSaveEntries` → `persistence.save()`,租约与写序语义全部继承,零新增写路径。
2925
- * 空 entries 快照在 save 内部即 `createSession()` + 零次 `appendEntry()`,正是所需语义。
2926
- *
2927
- * **幂等**:`createSession` 是 `ON CONFLICT DO NOTHING`;重复调用安全。
2928
- * **fire-and-forget**(规则 3):失败只 warn,绝不阻塞会话创建——预建是可用性增强,
2929
- * 不是创建流程的正确性前提(失败时退化为改动前行为:首个 turn 后才落行)。
2930
- */
2931
3212
  /**
2932
3213
  * RFC-336 D2:输入边界落盘——prep 成功、模型往返开始**之前**把新增 entries 落库。
2933
3214
  *
@@ -2948,6 +3229,26 @@ declare class PersistenceSync {
2948
3229
  * prompt 终态落盘共用同一条 per-session 链,天然串行、写租约语义一致。
2949
3230
  */
2950
3231
  requestInputBoundaryFlush(agentSession: AgentSession, transient: boolean): void;
3232
+ /**
3233
+ * RFC-336 D1:会话行预建——会话创建即落 `sessions` 一行(无 entries),不等首条消息。
3234
+ *
3235
+ * **要解决的问题**(实测复现,2026-08-10):`repo.createSession()` 的唯一调用点是
3236
+ * `RelationalSessionPersistence.save()`,而 save 由 `track()` 订阅的 `turn.end`/
3237
+ * `prompt.end` 触发——两者都发生在**首个模型回合完成之后**。因此"用户已回车、模型还没
3238
+ * 回任何东西"这段窗口(≈ 一次完整模型往返,数秒~数十秒)内进程若被强杀(SIGKILL/OOM/
3239
+ * 断电),DB 里连 `sessions` 行都不存在 → 整个会话蒸发,`/resume` 完全看不到,
3240
+ * 且 `detectCrashGap` 因 `load()` 返回 null 而根本不执行(RFC-305 D3 的盲区)。
3241
+ *
3242
+ * **为什么复用 doSaveEntries 而非直调 repo**(D1-b,RFC-159 D3):写租约检查在
3243
+ * `RelationalSessionPersistence.save()` 入口,是所有会话写路径的单一汇聚点。直调
3244
+ * `repo.createSession()` 会开一条无租约的写路径先例。走这里则天然经 `enqueue` 串行链
3245
+ * → `doSaveEntries` → `persistence.save()`,租约与写序语义全部继承,零新增写路径。
3246
+ * 空 entries 快照在 save 内部即 `createSession()` + 零次 `appendEntry()`,正是所需语义。
3247
+ *
3248
+ * **幂等**:`createSession` 是 `ON CONFLICT DO NOTHING`;重复调用安全。
3249
+ * **fire-and-forget**(规则 3):失败只 warn,绝不阻塞会话创建——预建是可用性增强,
3250
+ * 不是创建流程的正确性前提(失败时退化为改动前行为:首个 turn 后才落行)。
3251
+ */
2951
3252
  precreateSessionRow(agentSession: AgentSession, transient: boolean): void;
2952
3253
  /**
2953
3254
  * 驱逐路径专用:用调用方**同步捕获**的快照入链落盘。
@@ -3020,21 +3321,6 @@ declare class PersistenceSync {
3020
3321
  * 若未提供 configProvider 则返回 null。
3021
3322
  */
3022
3323
  restore(id: string): Promise<AgentSession | null>;
3023
- /**
3024
- * RFC-305 D3:restore 时 trace↔DB 对账——检出"上次进程异常终止时已发生但未落库"的
3025
- * turn 缺口并告警。对账基准 = trace append-log(逐事件实时落盘,独立于 save 链):
3026
- * DB 最后一条已持久化 entry 时间戳之后,trace 仍有 `turn.end` lifecycle 事件 →
3027
- * 这些 turn 的消息只进过内存、从未进 DB,已随崩溃永久丢失。
3028
- *
3029
- * 用时间戳而非 turn 号对账:trace 的 turn 字段 per-prompt 从 0 重置,跨 prompt 不可比;
3030
- * ts 与 entry.timestamp 同源(Date.now 系时钟),单机单调可比。
3031
- *
3032
- * 容忍度:正常退出路径(prompt.end 立即落盘 + turn 级入链)下 trace turn.end 与 DB
3033
- * 落库几乎同时,容忍 CRASH_GAP_TOLERANCE_MS 内的尾差(在途写 + 时钟粒度),超出才告警。
3034
- *
3035
- * fail-soft:traceStore 缺失/读取异常/无 turn.end 事件 → 静默跳过(debug 日志),
3036
- * 绝不阻塞 restore、绝不产生假告警。
3037
- */
3038
3324
  /**
3039
3325
  * RFC-305 D3:对账结果查询口——restore/restoreAll 内部把本次恢复检出的崩溃缺口记入
3040
3326
  * per-session 缓存,调用方(CLI resume 路径)在订阅建立后读取并 toast。缓存随
@@ -3077,7 +3363,7 @@ interface EngineSnapshot {
3077
3363
  }
3078
3364
  /** 引擎产出的治理决策(所有字段确定性)。 */
3079
3365
  interface ResidencyDecision {
3080
- /** 单会话当前有效字节预算(已/处分配层 × 压力档)。 */
3366
+ /** 单会话当前有效字节预算(分配量经压力档缩放后的最终值)。 */
3081
3367
  maxBytesPerSession: number;
3082
3368
  /** 当前全局驻留压力比例(0.0 ~ 1.0)。 */
3083
3369
  globalPressure: number;
@@ -3085,15 +3371,15 @@ interface ResidencyDecision {
3085
3371
  isGlobalPressure: boolean;
3086
3372
  }
3087
3373
  /**
3088
- * 计算“每个会话当前 应该 byte budget — 给定 snapshot,治理一个值。
3374
+ * 计算给定 snapshot 下每个会话的有效字节预算。
3089
3375
  *
3090
- * 特性:
3091
- * - 负反馈:currentTotalResidentBytes 越大 pressure 越高 → 每个会话预算*越低*。
3092
- * - 下界 MIN_PER_SESSION:防止分配结果不可用作 (如果 N 极大, SESSION_MAX=50×16=800MB < totalBudget).
3093
- * - 上界 MAX_PER_SESSION:模型折叠输入的最大(imageasher, window by compression)约为 214MB/会话。
3094
- * - 确定性:相同 snapshot → 相同 decision(R4,皱纹是稳定 的。
3376
+ * 特性:
3377
+ * - 负反馈:currentTotalResidentBytes 越大 pressure 越高 → 每个会话预算越低。
3378
+ * - 下界 MIN_PER_SESSION:防会话数极大时分配结果不可用。
3379
+ * - 上界 MAX_PER_SESSION:单会话驻留上限。
3380
+ * - 确定性:相同 snapshot → 相同 decision(R4)。
3095
3381
  */
3096
3382
  declare function decide(snapshot: EngineSnapshot): ResidencyDecision;
3097
3383
  //#endregion
3098
- export { type AgentJobListener, AgentJobRegistry, type AgentJobRegistryOptions, type AgentJobStatus, type AgentObsStatus, type AgentObservabilityOptions, AgentObservabilityRegistry, type AgentObservation, type AgentObservationMeta, type AgentObservationSnapshot, type AgentRuntime, AgentSession, type AgentSessionEvent, type AgentSessionEventMap, type AgentSessionEventType, type AgentSessionInfo, type AgentSessionJob, type AgentSessionOptions, type AgentSessionSubscriber, type ApplyDiffResult, type ApplyPolicy, type ApplySignals, type ArchiveRecallPort, type AskUserQuestion, type AutonomyLevel, type BackgroundProcess, type BackgroundProcessStatus, CAPABILITY_SURFACE_PATTERNS, type Checkpoint, type CheckpointData, type ContextBuildInput, type ContextInjectionPort, type ContextSource, ContextSourceRegistry, DEFAULT_MAX_AUTO_APPLY_LINES, type DiskSessionPoolOptions, type DocSyncPort, type EngineStoreLocation, type EngineStoreOverrides, type ExitResult, FORBIDDEN_ZONE_PATTERNS, type FileEntrySnapshot, type FileSnapshot, FleetMonitor, type FleetMonitorOptions, type FleetSample, type GrillAnswer, type GrillQuestion, type GrillRequest, type KillOptions, LEVEL_DIVISOR, type ManagedProcess, type MemoryDeltaPort, MemoryGovernor, type MemoryGovernorOptions, type MemoryPort, type MemoryPressureLevel, type MemorySample, type MemorySubsystem, PanelStateStore, PersistenceSync, type PersistenceSyncDeps, type ProcessCategory, type ProcessFilter, type ProcessLifecycle, type ProcessListener, type ProcessOwner, ProcessRegistry, type ProcessRegistryOptions, ProcessRuntime, type ProcessRuntimeOptions, type ProcessSpawnConfig, type ProcessStatus, type PromptOptions, type PromptRefresh, RUNTIME_DEFAULTS, type RegisterAgentJobInput, type RegisterInput, type RemoteSessionPoolOptions, type ReplayLevel, type ResidencyDiagnostics, ResidencyGovernor, type ResidencyPressureLevel, type ResolvedSessionConfig, type RestoreMode, type RuntimeOptions, SYSTEM_PROMPT_SECTIONS, type SandboxRunner, type SandboxToolCall, type SandboxToolResult, SandboxUnavailableError, SessionPool, type SessionPoolOptions, type SessionPorts, type SessionStableInjectionOptions, type SessionStorageConfig, type SystemPromptSectionSpec, TimeTravelController, type TimeTravelDeps, type TodoReminderPort, type TracebackView, type TurnRecord, type Verdict, type Worktree, applyDiff, applyMemoryTransform, applySectionBudget, attachAgentObserver, buildEngineStores, captureFiles, createAgentRuntime, createDefaultContextSourceRegistry, createDiskSessionPool, createDocSyncReminderHooks, createEnvironmentContextSource, createInMemorySessionPool, createMemoryDeltaHooks, createMemoryIndexContextSource, createRemoteSessionPool, createSessionStableInjectionHooks, createTodoReminderHooks, createToolHookExecutor, createWorktree, decideApply, decide as decideResidency, defaultMaxToolTurnExtensions, deriveSessionTitle, diffTouchedPaths, effectiveResidencyBudget, formatDocSyncReminder, globalAgentJobRegistry, globalAgentObservability, globalProcessRegistry, globalProcessRuntime, hasRepoDrifted, installAgentJobReaper, installExitReaper, installProcessReaper, messagesFromSnapshot, pruneOrphanWorktrees, reconstructMessages, removeWorktree, resolveSessionTitle, resolveTodoContinuationConfig, restoreFiles, revertDiff, touchesCapabilitySurface, touchesForbiddenZone, worktreeDiff };
3384
+ export { type AgentJobListener, AgentJobRegistry, type AgentJobRegistryOptions, type AgentJobStatus, type AgentObsStatus, type AgentObservabilityOptions, AgentObservabilityRegistry, type AgentObservation, type AgentObservationMeta, type AgentObservationSnapshot, type AgentRuntime, AgentSession, type AgentSessionEvent, type AgentSessionEventMap, type AgentSessionEventType, type AgentSessionInfo, type AgentSessionJob, type AgentSessionOptions, type AgentSessionSubscriber, type ApplyDiffResult, type ApplyPolicy, type ApplySignals, type ArchiveRecallPort, type AskUserQuestion, type AutonomyLevel, type BackgroundProcess, type BackgroundProcessStatus, type BasePlaneEntry, CAPABILITY_SURFACE_PATTERNS, type Checkpoint, type CheckpointData, type ContextBuildInput, type ContextInjectionPort, type ContextSource, ContextSourceRegistry, DEFAULT_COMPACTION_LOCK_ORPHAN_TIMEOUT_MS, DEFAULT_MAX_AUTO_APPLY_LINES, type DiskSessionPoolOptions, type DocSyncPort, type EmitContext, type EngineStoreLocation, type EngineStoreOverrides, type ExitResult, FORBIDDEN_ZONE_PATTERNS, type FileEntrySnapshot, type FileSnapshot, FleetMonitor, type FleetMonitorOptions, type FleetSample, type GrillAnswer, type GrillQuestion, type GrillRequest, type HostPlaneDraft, type HostPlaneEntry, HostRegistry, type KillOptions, LEVEL_DIVISOR, type ManagedProcess, type MemoryDeltaPort, MemoryGovernor, type MemoryGovernorOptions, type MemoryPort, type MemoryPressureLevel, type MemorySample, type MemorySubsystem, PanelStateStore, PersistenceSync, type PersistenceSyncDeps, type PlaneEntry, type ProcessCategory, type ProcessFilter, type ProcessLifecycle, type ProcessListener, type ProcessOwner, ProcessRegistry, type ProcessRegistryOptions, ProcessRuntime, type ProcessRuntimeOptions, type ProcessSpawnConfig, type ProcessStatus, type PromptOptions, type PromptRefresh, RUNTIME_DEFAULTS, type RegisterAgentJobInput, type RegisterInput, type RegistrationPlane, type RemoteSessionPoolOptions, type ReplayLevel, type ResidencyDiagnostics, ResidencyGovernor, type ResidencyPressureLevel, type ResolvedSessionConfig, type RestoreMode, type RuntimeOptions, SYSTEM_PROMPT_SECTIONS, type SandboxRunner, type SandboxToolCall, type SandboxToolResult, SandboxUnavailableError, type SessionCompactionLockPort, SessionPool, type SessionPoolOptions, type SessionPorts, type SessionPresetDraft, type SessionPresetEntry, type SessionStableInjectionOptions, type SessionStorageConfig, type StalePlaneEntry, type SystemPromptSectionSpec, TimeTravelController, type TimeTravelDeps, type TodoReminderPort, type TracebackView, type TurnRecord, type Verdict, type WorkspacePresetDraft, type WorkspacePresetEntry, type Worktree, applyDiff, applyMemoryTransform, applySectionBudget, attachAgentObserver, buildEngineStores, captureFiles, checkApply, createAgentRuntime, createDefaultContextSourceRegistry, createDiskSessionPool, createDocSyncReminderHooks, createEnvironmentContextSource, createInMemorySessionPool, createMemoryDeltaHooks, createMemoryIndexContextSource, createRemoteSessionPool, createSessionCompactionLock, createSessionStableInjectionHooks, createTodoReminderHooks, createToolHookExecutor, createWorktree, decideApply, decide as decideResidency, defaultMaxToolTurnExtensions, deriveSessionTitle, diffTouchedPaths, effectiveResidencyBudget, formatDocSyncReminder, globalAgentJobRegistry, globalAgentObservability, globalProcessRegistry, globalProcessRuntime, globalToolResultStore, hasRepoDrifted, installAgentJobReaper, installExitReaper, installProcessReaper, messagesFromSnapshot, pruneOrphanWorktrees, reconstructMessages, removeWorktree, resolveSessionTitle, resolveTodoContinuationConfig, restoreFiles, revertDiff, touchesCapabilitySurface, touchesForbiddenZone, worktreeDiff };
3099
3385
  //# sourceMappingURL=index.d.ts.map