@hydra-acp/cli 0.1.87 → 0.1.88

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/dist/index.d.ts CHANGED
@@ -141,7 +141,37 @@ declare const HydraConfig: z.ZodObject<{
141
141
  defaultModels: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
142
142
  synopsisAgent: z.ZodOptional<z.ZodString>;
143
143
  synopsisModel: z.ZodOptional<z.ZodString>;
144
- synopsisOnClose: z.ZodDefault<z.ZodBoolean>;
144
+ compaction: z.ZodDefault<z.ZodObject<{
145
+ agent: z.ZodOptional<z.ZodString>;
146
+ model: z.ZodOptional<z.ZodString>;
147
+ tailK: z.ZodDefault<z.ZodNumber>;
148
+ maxIterations: z.ZodDefault<z.ZodNumber>;
149
+ contextFraction: z.ZodDefault<z.ZodNumber>;
150
+ hardCeilingFraction: z.ZodDefault<z.ZodNumber>;
151
+ absoluteFallback: z.ZodDefault<z.ZodNumber>;
152
+ idleBeforePromptMs: z.ZodDefault<z.ZodNumber>;
153
+ modelContextWindows: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
154
+ }, "strip", z.ZodTypeAny, {
155
+ tailK: number;
156
+ maxIterations: number;
157
+ contextFraction: number;
158
+ hardCeilingFraction: number;
159
+ absoluteFallback: number;
160
+ idleBeforePromptMs: number;
161
+ modelContextWindows: Record<string, number>;
162
+ agent?: string | undefined;
163
+ model?: string | undefined;
164
+ }, {
165
+ agent?: string | undefined;
166
+ model?: string | undefined;
167
+ tailK?: number | undefined;
168
+ maxIterations?: number | undefined;
169
+ contextFraction?: number | undefined;
170
+ hardCeilingFraction?: number | undefined;
171
+ absoluteFallback?: number | undefined;
172
+ idleBeforePromptMs?: number | undefined;
173
+ modelContextWindows?: Record<string, number> | undefined;
174
+ }>>;
145
175
  defaultCwd: z.ZodDefault<z.ZodString>;
146
176
  compressToolContent: z.ZodDefault<z.ZodBoolean>;
147
177
  sessionListColdLimit: z.ZodDefault<z.ZodNumber>;
@@ -191,7 +221,7 @@ declare const HydraConfig: z.ZodObject<{
191
221
  progressIndicator: z.ZodDefault<z.ZodBoolean>;
192
222
  defaultEnterAction: z.ZodDefault<z.ZodEnum<["enqueue", "amend"]>>;
193
223
  showThoughts: z.ZodDefault<z.ZodBoolean>;
194
- ambiguousWidth: z.ZodDefault<z.ZodEnum<["narrow", "wide"]>>;
224
+ ambiguousWidth: z.ZodDefault<z.ZodEnum<["auto", "narrow", "wide"]>>;
195
225
  toolContent: z.ZodDefault<z.ZodEnum<["inline", "references"]>>;
196
226
  diffContextLines: z.ZodDefault<z.ZodNumber>;
197
227
  promptHistoryMaxEntries: z.ZodDefault<z.ZodNumber>;
@@ -209,7 +239,7 @@ declare const HydraConfig: z.ZodObject<{
209
239
  progressIndicator: boolean;
210
240
  defaultEnterAction: "enqueue" | "amend";
211
241
  showThoughts: boolean;
212
- ambiguousWidth: "narrow" | "wide";
242
+ ambiguousWidth: "auto" | "narrow" | "wide";
213
243
  toolContent: "inline" | "references";
214
244
  diffContextLines: number;
215
245
  promptHistoryMaxEntries: number;
@@ -231,7 +261,7 @@ declare const HydraConfig: z.ZodObject<{
231
261
  progressIndicator?: boolean | undefined;
232
262
  defaultEnterAction?: "enqueue" | "amend" | undefined;
233
263
  showThoughts?: boolean | undefined;
234
- ambiguousWidth?: "narrow" | "wide" | undefined;
264
+ ambiguousWidth?: "auto" | "narrow" | "wide" | undefined;
235
265
  toolContent?: "inline" | "references" | undefined;
236
266
  diffContextLines?: number | undefined;
237
267
  promptHistoryMaxEntries?: number | undefined;
@@ -251,7 +281,7 @@ declare const HydraConfig: z.ZodObject<{
251
281
  progressIndicator: boolean;
252
282
  defaultEnterAction: "enqueue" | "amend";
253
283
  showThoughts: boolean;
254
- ambiguousWidth: "narrow" | "wide";
284
+ ambiguousWidth: "auto" | "narrow" | "wide";
255
285
  toolContent: "inline" | "references";
256
286
  diffContextLines: number;
257
287
  promptHistoryMaxEntries: number;
@@ -307,7 +337,17 @@ declare const HydraConfig: z.ZodObject<{
307
337
  }>;
308
338
  defaultAgent: string;
309
339
  defaultModels: Record<string, string>;
310
- synopsisOnClose: boolean;
340
+ compaction: {
341
+ tailK: number;
342
+ maxIterations: number;
343
+ contextFraction: number;
344
+ hardCeilingFraction: number;
345
+ absoluteFallback: number;
346
+ idleBeforePromptMs: number;
347
+ modelContextWindows: Record<string, number>;
348
+ agent?: string | undefined;
349
+ model?: string | undefined;
350
+ };
311
351
  defaultCwd: string;
312
352
  compressToolContent: boolean;
313
353
  sessionListColdLimit: number;
@@ -328,7 +368,7 @@ declare const HydraConfig: z.ZodObject<{
328
368
  progressIndicator?: boolean | undefined;
329
369
  defaultEnterAction?: "enqueue" | "amend" | undefined;
330
370
  showThoughts?: boolean | undefined;
331
- ambiguousWidth?: "narrow" | "wide" | undefined;
371
+ ambiguousWidth?: "auto" | "narrow" | "wide" | undefined;
332
372
  toolContent?: "inline" | "references" | undefined;
333
373
  diffContextLines?: number | undefined;
334
374
  promptHistoryMaxEntries?: number | undefined;
@@ -384,7 +424,17 @@ declare const HydraConfig: z.ZodObject<{
384
424
  defaultModels?: Record<string, string> | undefined;
385
425
  synopsisAgent?: string | undefined;
386
426
  synopsisModel?: string | undefined;
387
- synopsisOnClose?: boolean | undefined;
427
+ compaction?: {
428
+ agent?: string | undefined;
429
+ model?: string | undefined;
430
+ tailK?: number | undefined;
431
+ maxIterations?: number | undefined;
432
+ contextFraction?: number | undefined;
433
+ hardCeilingFraction?: number | undefined;
434
+ absoluteFallback?: number | undefined;
435
+ idleBeforePromptMs?: number | undefined;
436
+ modelContextWindows?: Record<string, number> | undefined;
437
+ } | undefined;
388
438
  defaultCwd?: string | undefined;
389
439
  compressToolContent?: boolean | undefined;
390
440
  sessionListColdLimit?: number | undefined;
@@ -789,6 +839,7 @@ declare const RegistryAgent: z.ZodObject<{
789
839
  url?: string | undefined;
790
840
  description?: string | undefined;
791
841
  }>>;
842
+ requiredEnv: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
792
843
  }, "strip", z.ZodTypeAny, {
793
844
  name: string;
794
845
  id: string;
@@ -860,6 +911,7 @@ declare const RegistryAgent: z.ZodObject<{
860
911
  url?: string | undefined;
861
912
  description?: string | undefined;
862
913
  } | undefined;
914
+ requiredEnv?: string[] | undefined;
863
915
  }, {
864
916
  name: string;
865
917
  id: string;
@@ -931,6 +983,7 @@ declare const RegistryAgent: z.ZodObject<{
931
983
  url?: string | undefined;
932
984
  description?: string | undefined;
933
985
  } | undefined;
986
+ requiredEnv?: string[] | undefined;
934
987
  }>;
935
988
  type RegistryAgent = z.infer<typeof RegistryAgent>;
936
989
  declare const RegistryDocument: z.ZodObject<{
@@ -1284,6 +1337,7 @@ declare const RegistryDocument: z.ZodObject<{
1284
1337
  url?: string | undefined;
1285
1338
  description?: string | undefined;
1286
1339
  }>>;
1340
+ requiredEnv: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1287
1341
  }, "strip", z.ZodTypeAny, {
1288
1342
  name: string;
1289
1343
  id: string;
@@ -1355,6 +1409,7 @@ declare const RegistryDocument: z.ZodObject<{
1355
1409
  url?: string | undefined;
1356
1410
  description?: string | undefined;
1357
1411
  } | undefined;
1412
+ requiredEnv?: string[] | undefined;
1358
1413
  }, {
1359
1414
  name: string;
1360
1415
  id: string;
@@ -1426,6 +1481,7 @@ declare const RegistryDocument: z.ZodObject<{
1426
1481
  url?: string | undefined;
1427
1482
  description?: string | undefined;
1428
1483
  } | undefined;
1484
+ requiredEnv?: string[] | undefined;
1429
1485
  }>, "many">;
1430
1486
  extensions: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
1431
1487
  }, "strip", z.ZodTypeAny, {
@@ -1501,6 +1557,7 @@ declare const RegistryDocument: z.ZodObject<{
1501
1557
  url?: string | undefined;
1502
1558
  description?: string | undefined;
1503
1559
  } | undefined;
1560
+ requiredEnv?: string[] | undefined;
1504
1561
  }[];
1505
1562
  extensions?: unknown[] | undefined;
1506
1563
  }, {
@@ -1576,6 +1633,7 @@ declare const RegistryDocument: z.ZodObject<{
1576
1633
  url?: string | undefined;
1577
1634
  description?: string | undefined;
1578
1635
  } | undefined;
1636
+ requiredEnv?: string[] | undefined;
1579
1637
  }[];
1580
1638
  extensions?: unknown[] | undefined;
1581
1639
  }>;
@@ -1741,6 +1799,7 @@ declare const SessionListEntry: z.ZodObject<{
1741
1799
  status: z.ZodDefault<z.ZodEnum<["live", "cold"]>>;
1742
1800
  busy: z.ZodDefault<z.ZodBoolean>;
1743
1801
  awaitingInput: z.ZodDefault<z.ZodBoolean>;
1802
+ compactionState: z.ZodOptional<z.ZodAny>;
1744
1803
  _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1745
1804
  }, "strip", z.ZodTypeAny, {
1746
1805
  sessionId: string;
@@ -1772,6 +1831,7 @@ declare const SessionListEntry: z.ZodObject<{
1772
1831
  } | undefined;
1773
1832
  interactive?: boolean | undefined;
1774
1833
  priority?: number | undefined;
1834
+ compactionState?: any;
1775
1835
  }, {
1776
1836
  sessionId: string;
1777
1837
  cwd: string;
@@ -1802,6 +1862,7 @@ declare const SessionListEntry: z.ZodObject<{
1802
1862
  priority?: number | undefined;
1803
1863
  busy?: boolean | undefined;
1804
1864
  awaitingInput?: boolean | undefined;
1865
+ compactionState?: any;
1805
1866
  }>;
1806
1867
  type SessionListEntry = z.infer<typeof SessionListEntry>;
1807
1868
  declare const SessionListResult: z.ZodObject<{
@@ -2023,6 +2084,7 @@ declare class AgentInstance {
2023
2084
  readonly connection: JsonRpcConnection;
2024
2085
  authMethods?: AuthMethod[];
2025
2086
  private child;
2087
+ get pid(): number | undefined;
2026
2088
  private exited;
2027
2089
  private killed;
2028
2090
  private stderrTail;
@@ -2285,527 +2347,271 @@ declare class HistoryStore {
2285
2347
  compact(sessionId: string, maxEntries: number): Promise<void>;
2286
2348
  load(sessionId: string, opts?: {
2287
2349
  tools?: "inline" | "references";
2350
+ maxEntries?: number;
2288
2351
  }): Promise<HistoryEntry[]>;
2289
2352
  flushAll(): Promise<void>;
2290
2353
  delete(sessionId: string): Promise<void>;
2291
2354
  private enqueue;
2292
2355
  }
2293
2356
 
2294
- interface PersistedQueueEntry {
2295
- messageId: string;
2296
- originator: {
2297
- clientInfo: {
2298
- name?: string;
2299
- version?: string;
2300
- };
2301
- };
2302
- prompt: unknown[];
2303
- enqueuedAt: number;
2304
- }
2357
+ declare const CompactionState: z.ZodObject<{
2358
+ status: z.ZodEnum<["requested", "running", "swap_pending", "swap_deferred", "failed"]>;
2359
+ requestedAt: z.ZodNumber;
2360
+ iter: z.ZodOptional<z.ZodNumber>;
2361
+ attempts: z.ZodOptional<z.ZodNumber>;
2362
+ lastError: z.ZodOptional<z.ZodString>;
2363
+ worker: z.ZodOptional<z.ZodObject<{
2364
+ upstreamSessionId: z.ZodString;
2365
+ pid: z.ZodNumber;
2366
+ }, "strip", z.ZodTypeAny, {
2367
+ upstreamSessionId: string;
2368
+ pid: number;
2369
+ }, {
2370
+ upstreamSessionId: string;
2371
+ pid: number;
2372
+ }>>;
2373
+ }, "strip", z.ZodTypeAny, {
2374
+ status: "requested" | "running" | "swap_pending" | "swap_deferred" | "failed";
2375
+ requestedAt: number;
2376
+ iter?: number | undefined;
2377
+ attempts?: number | undefined;
2378
+ lastError?: string | undefined;
2379
+ worker?: {
2380
+ upstreamSessionId: string;
2381
+ pid: number;
2382
+ } | undefined;
2383
+ }, {
2384
+ status: "requested" | "running" | "swap_pending" | "swap_deferred" | "failed";
2385
+ requestedAt: number;
2386
+ iter?: number | undefined;
2387
+ attempts?: number | undefined;
2388
+ lastError?: string | undefined;
2389
+ worker?: {
2390
+ upstreamSessionId: string;
2391
+ pid: number;
2392
+ } | undefined;
2393
+ }>;
2394
+ type CompactionState = z.infer<typeof CompactionState>;
2395
+ declare const SessionSynopsis: z.ZodObject<{
2396
+ goal: z.ZodOptional<z.ZodString>;
2397
+ outcome: z.ZodOptional<z.ZodString>;
2398
+ files_touched: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2399
+ tools_used: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2400
+ rejected_approaches: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2401
+ open_threads: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2402
+ decisions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2403
+ file_edit_intentions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2404
+ unresolved_errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2405
+ tool_state: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2406
+ }, "strip", z.ZodTypeAny, {
2407
+ goal?: string | undefined;
2408
+ outcome?: string | undefined;
2409
+ files_touched?: string[] | undefined;
2410
+ tools_used?: string[] | undefined;
2411
+ rejected_approaches?: string[] | undefined;
2412
+ open_threads?: string[] | undefined;
2413
+ decisions?: string[] | undefined;
2414
+ file_edit_intentions?: string[] | undefined;
2415
+ unresolved_errors?: string[] | undefined;
2416
+ tool_state?: string[] | undefined;
2417
+ }, {
2418
+ goal?: string | undefined;
2419
+ outcome?: string | undefined;
2420
+ files_touched?: string[] | undefined;
2421
+ tools_used?: string[] | undefined;
2422
+ rejected_approaches?: string[] | undefined;
2423
+ open_threads?: string[] | undefined;
2424
+ decisions?: string[] | undefined;
2425
+ file_edit_intentions?: string[] | undefined;
2426
+ unresolved_errors?: string[] | undefined;
2427
+ tool_state?: string[] | undefined;
2428
+ }>;
2429
+ type SessionSynopsis = z.infer<typeof SessionSynopsis>;
2305
2430
 
2306
- interface AttachedClient {
2307
- clientId: string;
2308
- connection: JsonRpcConnection;
2309
- clientInfo?: {
2431
+ declare const RollbackBreadcrumb: z.ZodObject<{
2432
+ previousUpstreamSessionId: z.ZodString;
2433
+ previousSummarizedThroughEntry: z.ZodOptional<z.ZodNumber>;
2434
+ }, "strip", z.ZodTypeAny, {
2435
+ previousUpstreamSessionId: string;
2436
+ previousSummarizedThroughEntry?: number | undefined;
2437
+ }, {
2438
+ previousUpstreamSessionId: string;
2439
+ previousSummarizedThroughEntry?: number | undefined;
2440
+ }>;
2441
+ type RollbackBreadcrumb = z.infer<typeof RollbackBreadcrumb>;
2442
+ declare const SessionRecord: z.ZodObject<{
2443
+ version: z.ZodLiteral<1>;
2444
+ sessionId: z.ZodString;
2445
+ lineageId: z.ZodOptional<z.ZodString>;
2446
+ upstreamSessionId: z.ZodString;
2447
+ importedFromSessionId: z.ZodOptional<z.ZodString>;
2448
+ importedFromUpstreamSessionId: z.ZodOptional<z.ZodString>;
2449
+ importedFromMachine: z.ZodOptional<z.ZodString>;
2450
+ agentId: z.ZodString;
2451
+ cwd: z.ZodString;
2452
+ title: z.ZodOptional<z.ZodString>;
2453
+ synopsis: z.ZodOptional<z.ZodObject<{
2454
+ goal: z.ZodOptional<z.ZodString>;
2455
+ outcome: z.ZodOptional<z.ZodString>;
2456
+ files_touched: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2457
+ tools_used: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2458
+ rejected_approaches: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2459
+ open_threads: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2460
+ decisions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2461
+ file_edit_intentions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2462
+ unresolved_errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2463
+ tool_state: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2464
+ }, "strip", z.ZodTypeAny, {
2465
+ goal?: string | undefined;
2466
+ outcome?: string | undefined;
2467
+ files_touched?: string[] | undefined;
2468
+ tools_used?: string[] | undefined;
2469
+ rejected_approaches?: string[] | undefined;
2470
+ open_threads?: string[] | undefined;
2471
+ decisions?: string[] | undefined;
2472
+ file_edit_intentions?: string[] | undefined;
2473
+ unresolved_errors?: string[] | undefined;
2474
+ tool_state?: string[] | undefined;
2475
+ }, {
2476
+ goal?: string | undefined;
2477
+ outcome?: string | undefined;
2478
+ files_touched?: string[] | undefined;
2479
+ tools_used?: string[] | undefined;
2480
+ rejected_approaches?: string[] | undefined;
2481
+ open_threads?: string[] | undefined;
2482
+ decisions?: string[] | undefined;
2483
+ file_edit_intentions?: string[] | undefined;
2484
+ unresolved_errors?: string[] | undefined;
2485
+ tool_state?: string[] | undefined;
2486
+ }>>;
2487
+ compactionState: z.ZodOptional<z.ZodObject<{
2488
+ status: z.ZodEnum<["requested", "running", "swap_pending", "swap_deferred", "failed"]>;
2489
+ requestedAt: z.ZodNumber;
2490
+ iter: z.ZodOptional<z.ZodNumber>;
2491
+ attempts: z.ZodOptional<z.ZodNumber>;
2492
+ lastError: z.ZodOptional<z.ZodString>;
2493
+ worker: z.ZodOptional<z.ZodObject<{
2494
+ upstreamSessionId: z.ZodString;
2495
+ pid: z.ZodNumber;
2496
+ }, "strip", z.ZodTypeAny, {
2497
+ upstreamSessionId: string;
2498
+ pid: number;
2499
+ }, {
2500
+ upstreamSessionId: string;
2501
+ pid: number;
2502
+ }>>;
2503
+ }, "strip", z.ZodTypeAny, {
2504
+ status: "requested" | "running" | "swap_pending" | "swap_deferred" | "failed";
2505
+ requestedAt: number;
2506
+ iter?: number | undefined;
2507
+ attempts?: number | undefined;
2508
+ lastError?: string | undefined;
2509
+ worker?: {
2510
+ upstreamSessionId: string;
2511
+ pid: number;
2512
+ } | undefined;
2513
+ }, {
2514
+ status: "requested" | "running" | "swap_pending" | "swap_deferred" | "failed";
2515
+ requestedAt: number;
2516
+ iter?: number | undefined;
2517
+ attempts?: number | undefined;
2518
+ lastError?: string | undefined;
2519
+ worker?: {
2520
+ upstreamSessionId: string;
2521
+ pid: number;
2522
+ } | undefined;
2523
+ }>>;
2524
+ rollbackBreadcrumb: z.ZodOptional<z.ZodObject<{
2525
+ previousUpstreamSessionId: z.ZodString;
2526
+ previousSummarizedThroughEntry: z.ZodOptional<z.ZodNumber>;
2527
+ }, "strip", z.ZodTypeAny, {
2528
+ previousUpstreamSessionId: string;
2529
+ previousSummarizedThroughEntry?: number | undefined;
2530
+ }, {
2531
+ previousUpstreamSessionId: string;
2532
+ previousSummarizedThroughEntry?: number | undefined;
2533
+ }>>;
2534
+ summarizedThroughEntry: z.ZodOptional<z.ZodNumber>;
2535
+ agentArgs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2536
+ currentModel: z.ZodOptional<z.ZodString>;
2537
+ currentMode: z.ZodOptional<z.ZodString>;
2538
+ currentUsage: z.ZodOptional<z.ZodObject<{
2539
+ used: z.ZodOptional<z.ZodNumber>;
2540
+ size: z.ZodOptional<z.ZodNumber>;
2541
+ costAmount: z.ZodOptional<z.ZodNumber>;
2542
+ costCurrency: z.ZodOptional<z.ZodString>;
2543
+ cumulativeCost: z.ZodOptional<z.ZodNumber>;
2544
+ }, "strip", z.ZodTypeAny, {
2545
+ used?: number | undefined;
2546
+ size?: number | undefined;
2547
+ costAmount?: number | undefined;
2548
+ costCurrency?: string | undefined;
2549
+ cumulativeCost?: number | undefined;
2550
+ }, {
2551
+ used?: number | undefined;
2552
+ size?: number | undefined;
2553
+ costAmount?: number | undefined;
2554
+ costCurrency?: string | undefined;
2555
+ cumulativeCost?: number | undefined;
2556
+ }>>;
2557
+ agentCommands: z.ZodOptional<z.ZodArray<z.ZodObject<{
2558
+ name: z.ZodString;
2559
+ description: z.ZodOptional<z.ZodString>;
2560
+ }, "strip", z.ZodTypeAny, {
2310
2561
  name: string;
2311
- version?: string;
2312
- };
2313
- readonly?: boolean;
2314
- }
2315
- type CachedNotification = HistoryEntry;
2316
- interface SpawnReplacementAgentParams {
2317
- agentId: string;
2318
- cwd: string;
2319
- agentArgs?: string[];
2320
- forwardedEnv?: Record<string, string>;
2321
- }
2322
- interface SpawnReplacementAgentResult {
2323
- agent: AgentInstance;
2324
- upstreamSessionId: string;
2325
- agentMeta?: Record<string, unknown>;
2326
- agentCapabilities?: AgentCapabilities;
2327
- initialModel?: string;
2328
- initialModels?: AdvertisedModel[];
2329
- initialMode?: string;
2330
- initialModes?: AdvertisedMode[];
2331
- }
2332
- type SpawnReplacementAgent = (params: SpawnReplacementAgentParams) => Promise<SpawnReplacementAgentResult>;
2333
- interface UsageSnapshot {
2334
- used?: number;
2335
- size?: number;
2336
- costAmount?: number;
2337
- costCurrency?: string;
2338
- cumulativeCost?: number;
2339
- }
2340
- interface SessionInit {
2341
- cwd: string;
2342
- agentId: string;
2343
- agent: AgentInstance;
2344
- upstreamSessionId: string;
2345
- title?: string;
2346
- sessionId?: string;
2347
- agentMeta?: Record<string, unknown>;
2348
- agentCapabilities?: AgentCapabilities;
2349
- agentArgs?: string[];
2350
- idleTimeoutMs?: number;
2351
- logger?: {
2352
- info: (msg: string) => void;
2353
- warn: (msg: string) => void;
2354
- };
2355
- spawnReplacementAgent?: SpawnReplacementAgent;
2356
- historyStore?: HistoryStore;
2357
- historyMaxEntries?: number;
2358
- currentModel?: string;
2359
- currentMode?: string;
2360
- currentUsage?: UsageSnapshot;
2361
- agentCommands?: AdvertisedCommand[];
2362
- agentModes?: AdvertisedMode[];
2363
- agentModels?: AdvertisedModel[];
2364
- firstPromptSeeded?: boolean;
2365
- scheduleSynopsis?: () => void;
2366
- createdAt?: number;
2367
- transformChain?: TransformerRef[];
2368
- idleEventTimeoutMs?: number;
2369
- parentSessionId?: string;
2370
- forkedFromSessionId?: string;
2371
- forkedFromMessageId?: string;
2372
- originatingClient?: {
2373
- name: string;
2374
- version?: string;
2375
- };
2376
- interactive?: boolean;
2377
- priority?: number;
2378
- forwardedEnv?: Record<string, string>;
2379
- listSessions?: () => Promise<{
2380
- sessionId: string;
2381
- title?: string;
2382
- cwd: string;
2383
- agentId?: string;
2384
- currentModel?: string;
2385
- }[]>;
2386
- extensionCommands?: ExtensionCommandRegistry;
2387
- availableAgents?: () => Array<{
2388
- id: string;
2389
- name?: string;
2390
- description?: string;
2391
- }>;
2392
- }
2393
- interface CloseOptions {
2394
- deleteRecord?: boolean;
2395
- }
2396
- declare class Session {
2397
- readonly sessionId: string;
2398
- readonly cwd: string;
2399
- agentId: string;
2400
- agent: AgentInstance;
2401
- upstreamSessionId: string;
2402
- agentMeta: Record<string, unknown> | undefined;
2403
- agentCapabilities: AgentCapabilities | undefined;
2404
- readonly agentArgs: string[] | undefined;
2405
- readonly parentSessionId: string | undefined;
2406
- readonly forkedFromSessionId: string | undefined;
2407
- readonly forkedFromMessageId: string | undefined;
2408
- readonly originatingClient: {
2409
- name: string;
2410
- version?: string;
2411
- } | undefined;
2412
- private _interactive;
2413
- get interactive(): boolean | undefined;
2414
- private _priority;
2415
- get priority(): number | undefined;
2416
- title: string | undefined;
2417
- currentModel: string | undefined;
2418
- currentMode: string | undefined;
2419
- private _currentUsage;
2420
- updatedAt: number;
2421
- readonly createdAt: number;
2422
- private clients;
2423
- private historyStore;
2424
- private promptQueue;
2425
- private currentEntry;
2426
- private promptInFlight;
2427
- private queueWriteChain;
2428
- private closed;
2429
- private closing;
2430
- private closeInFlight;
2431
- private closeHandlers;
2432
- private titleHandlers;
2433
- private scheduleSynopsisHook?;
2434
- private broadcastHandlers;
2435
- private lastCancelAt;
2436
- private static readonly CANCEL_ERROR_WINDOW_MS;
2437
- private forceCancelling;
2438
- private _firstPromptSeeded;
2439
- get firstPromptSeeded(): boolean;
2440
- private promptStartedAt;
2441
- private appendCount;
2442
- private historyMaxEntries;
2443
- private compactEvery;
2444
- private inFlightPermissions;
2445
- private internalPromptCapture;
2446
- private idleTimeoutMs;
2447
- private idleTimer;
2448
- private idleEventTimer;
2449
- private idleEventTimeoutMs;
2450
- private lastRecordedAt;
2451
- private spawnReplacementAgent;
2452
- forwardedEnv: Record<string, string> | undefined;
2453
- private listSessions;
2454
- private logger;
2455
- private transformChain;
2456
- private extensionCommands;
2457
- private extensionCommandsUnsub;
2458
- private pendingClaims;
2459
- private agentChangeHandlers;
2460
- private agentAdvertisedCommands;
2461
- private agentAdvertisedModes;
2462
- private agentAdvertisedModels;
2463
- private agentAdvertisedConfigOptions;
2464
- private agentCommandsHandlers;
2465
- private agentModesHandlers;
2466
- private agentModelsHandlers;
2467
- private availableAgentsFn?;
2468
- private modelHandlers;
2469
- private modeHandlers;
2470
- private interactiveHandlers;
2471
- private priorityHandlers;
2472
- private usageHandlers;
2473
- private cumulativeCost;
2474
- get currentUsage(): UsageSnapshot | undefined;
2475
- private amendInProgress;
2476
- private inFlightExtensionDispatches;
2477
- private recentlyTerminal;
2478
- private streamBuffer;
2479
- private streamFilePath;
2480
- constructor(init: SessionInit);
2481
- private broadcastMergedCommands;
2482
- private broadcastAvailableModes;
2483
- private broadcastAvailableModels;
2484
- private wireAgent;
2485
- private handleOrphanError;
2486
- private runResponseChain;
2487
- onAgentChange(handler: (info: {
2488
- agentId: string;
2489
- upstreamSessionId: string;
2490
- }) => void): void;
2491
- get attachedCount(): number;
2492
- connectedClients(excludeClientId?: string): Array<{
2493
- clientId: string;
2494
- name?: string;
2495
- version?: string;
2496
- }>;
2497
- get turnStartedAt(): number | undefined;
2498
- get awaitingInput(): boolean;
2499
- getHistorySnapshot(tools?: "inline" | "references"): Promise<CachedNotification[]>;
2500
- onBroadcast(handler: (entry: CachedNotification) => void): () => void;
2501
- attach(client: AttachedClient, historyPolicy: HistoryPolicy, opts?: {
2502
- afterMessageId?: string;
2503
- raw?: boolean;
2504
- toolContent?: "inline" | "references";
2505
- }): Promise<{
2506
- entries: CachedNotification[];
2507
- appliedPolicy: HistoryPolicy;
2508
- }>;
2509
- private loadReplay;
2510
- private buildStateSnapshotReplay;
2511
- replayPendingPermissions(client: AttachedClient): void;
2512
- detach(clientId: string): void;
2513
- private broadcastClientDisconnected;
2514
- prompt(clientId: string, params: unknown): Promise<unknown>;
2515
- private broadcastPromptReceived;
2516
- private broadcastTurnComplete;
2517
- private recordTerminal;
2518
- private broadcastPromptAmended;
2519
- private findUserEntry;
2520
- private visibleQueueDepth;
2521
- private broadcastQueueAdded;
2522
- private broadcastQueueUpdated;
2523
- private broadcastQueueRemoved;
2524
- private broadcastQueueNotification;
2525
- queueSnapshot(): PromptQueueEntry[];
2526
- flushPersistWrites(): Promise<void>;
2527
- replayPersistedQueue(entries: PersistedQueueEntry[]): void;
2528
- cancelQueuedPrompt(messageId: string): CancelPromptResult;
2529
- updateQueuedPrompt(messageId: string, prompt: unknown[]): UpdatePromptResult;
2530
- amendPrompt(clientId: string, params: AmendPromptParams): AmendPromptResult;
2531
- private amendOnHead;
2532
- private enqueueAmendmentAsFollowUp;
2533
- cancel(clientId: string): Promise<void>;
2534
- addTransformer(ref: TransformerRef): void;
2535
- forwardRequest(method: string, params: unknown, originatedBy?: Set<string>, startIdx?: number, tailKind?: "request" | "notification"): Promise<unknown>;
2536
- dischargeClaim(token: string, result: unknown): boolean;
2537
- keepAliveClaim(token: string, estimatedRemainingMs?: number): boolean;
2538
- emitToChain(emitterName: string, method: string, envelope: unknown): Promise<unknown>;
2539
- private rewriteForAgent;
2540
- close(opts?: CloseOptions): Promise<void>;
2541
- private doClose;
2542
- onClose(handler: (opts: {
2543
- deleteRecord: boolean;
2544
- }) => void): () => void;
2545
- onTitleChange(handler: (title: string) => void): void;
2546
- retitle(title: string): Promise<unknown>;
2547
- retitleFromAgent(): Promise<unknown>;
2548
- private setTitle;
2549
- private maybeSeedTitleFromPrompt;
2550
- private maybeApplyAgentModel;
2551
- private maybeApplyAgentConfigOption;
2552
- private maybeApplyAgentMode;
2553
- private maybeApplyAgentUsage;
2554
- private accumulateAndResetCost;
2555
- private injectCumulativeCost;
2556
- get totalUsage(): UsageSnapshot | undefined;
2557
- private setAgentAdvertisedCommands;
2558
- private setAgentAdvertisedModes;
2559
- private setAgentAdvertisedModels;
2560
- onAgentCommandsChange(handler: (commands: AdvertisedCommand[]) => void): void;
2561
- onAgentModesChange(handler: (modes: AdvertisedMode[]) => void): void;
2562
- onAgentModelsChange(handler: (models: AdvertisedModel[]) => void): void;
2563
- onModelChange(handler: (model: string) => void): void;
2564
- onModeChange(handler: (mode: string) => void): void;
2565
- onInteractiveChange(handler: (interactive: boolean) => void): void;
2566
- onPriorityChange(handler: (priority: number | undefined) => void): void;
2567
- setPriority(priority: number | undefined): void;
2568
- applyModelChange(modelId: string): void;
2569
- applyModeChange(modeId: string): void;
2570
- buildConfigOptions(): ConfigOption[];
2571
- private broadcastConfigOptions;
2572
- private mergeAgentOptionIntoEnvelope;
2573
- onUsageChange(handler: (usage: UsageSnapshot) => void): void;
2574
- mergedAvailableCommands(): AdvertisedCommand[];
2575
- agentOnlyAdvertisedCommands(): AdvertisedCommand[];
2576
- availableModes(): AdvertisedMode[];
2577
- availableModels(): AdvertisedModel[];
2578
- private maybeApplyAgentSessionInfo;
2579
- private handleSlashCommand;
2580
- private runExtensionCommand;
2581
- private runExtensionCommandInline;
2582
- private cancelExtensionDispatch;
2583
- private emitExtensionReply;
2584
- private handleSessionsCommand;
2585
- private handleHelpCommand;
2586
- private handleModelCommand;
2587
- private handleModeCommand;
2588
- private handleConfigCommand;
2589
- private runTitleCommand;
2590
- private runTitleCommandInline;
2591
- private runInternalPrompt;
2592
- setAgent(newAgentId: string): Promise<unknown>;
2593
- private runAgentCommand;
2594
- private runAgentCommandInline;
2595
- private runKillCommand;
2596
- private runRestartCommand;
2597
- private runRestartCommandInline;
2598
- forceCancel(): Promise<{
2599
- stopReason: string;
2600
- }>;
2601
- private respawnAgent;
2602
- private buildSwitchTranscript;
2603
- seedFromImport(): Promise<void>;
2604
- private broadcastAgentSwitch;
2605
- hasStreamBuffer(): boolean;
2606
- get streamPath(): string | undefined;
2607
- openStream(opts: {
2608
- mode?: "memory" | "file";
2609
- capacityBytes?: number;
2610
- fileCapBytes?: number;
2611
- filePathFor?: (sessionId: string) => string;
2612
- }): {
2613
- filePath?: string;
2614
- capacityBytes: number;
2615
- fileCapBytes?: number;
2616
- };
2617
- streamWrite(chunkB64: string, eof?: boolean): {
2618
- writeCursor: number;
2619
- };
2620
- streamRead(cursor: number, maxBytes: number | undefined, waitMs: number | undefined): Promise<{
2621
- bytes: string;
2622
- nextCursor: number;
2623
- gap?: number;
2624
- eof?: boolean;
2625
- }>;
2626
- streamTail(bytes: number): {
2627
- bytes: string;
2628
- startCursor: number;
2629
- endCursor: number;
2630
- truncated: boolean;
2631
- };
2632
- streamHead(bytes: number): {
2633
- bytes: string;
2634
- startCursor: number;
2635
- endCursor: number;
2636
- truncated: boolean;
2637
- };
2638
- streamWaitFor(cursor: number, timeoutMs: number): Promise<"data" | "eof" | "timeout">;
2639
- streamGrep(opts: StreamGrepOptions): StreamGrepResult;
2640
- streamInfo(): {
2641
- writeCursor: number;
2642
- oldestAvailable: number;
2643
- capacity: number;
2644
- closed: boolean;
2645
- };
2646
- private requireStreamBuffer;
2647
- private markClosed;
2648
- private get lastActivityAt();
2649
- private scheduleIdleCheck;
2650
- private armIdleTimer;
2651
- private checkIdle;
2652
- private cancelIdleTimer;
2653
- private scheduleIdleEvent;
2654
- private cancelIdleEventTimer;
2655
- private notifyChain;
2656
- private rewriteForClient;
2657
- private recordAndBroadcast;
2658
- requestPermissionFromClients(params: unknown): Promise<unknown>;
2659
- private handlePermissionRequest;
2660
- private enqueuePrompt;
2661
- private enqueueUserPrompt;
2662
- private parseQueuePosition;
2663
- private insertEntryAt;
2664
- private persistRewrite;
2665
- private persistedFromEntry;
2666
- private drainQueue;
2667
- private runQueueEntry;
2668
- private clearAmendIfMatches;
2669
- }
2670
-
2671
- declare const SessionSynopsis: z.ZodObject<{
2672
- goal: z.ZodOptional<z.ZodString>;
2673
- outcome: z.ZodOptional<z.ZodString>;
2674
- files_touched: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2675
- tools_used: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2676
- rejected_approaches: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2677
- open_threads: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2678
- }, "strip", z.ZodTypeAny, {
2679
- outcome?: string | undefined;
2680
- goal?: string | undefined;
2681
- files_touched?: string[] | undefined;
2682
- tools_used?: string[] | undefined;
2683
- rejected_approaches?: string[] | undefined;
2684
- open_threads?: string[] | undefined;
2685
- }, {
2686
- outcome?: string | undefined;
2687
- goal?: string | undefined;
2688
- files_touched?: string[] | undefined;
2689
- tools_used?: string[] | undefined;
2690
- rejected_approaches?: string[] | undefined;
2691
- open_threads?: string[] | undefined;
2692
- }>;
2693
- type SessionSynopsis = z.infer<typeof SessionSynopsis>;
2694
-
2695
- declare const SessionRecord: z.ZodObject<{
2696
- version: z.ZodLiteral<1>;
2697
- sessionId: z.ZodString;
2698
- lineageId: z.ZodOptional<z.ZodString>;
2699
- upstreamSessionId: z.ZodString;
2700
- importedFromSessionId: z.ZodOptional<z.ZodString>;
2701
- importedFromUpstreamSessionId: z.ZodOptional<z.ZodString>;
2702
- importedFromMachine: z.ZodOptional<z.ZodString>;
2703
- agentId: z.ZodString;
2704
- cwd: z.ZodString;
2705
- title: z.ZodOptional<z.ZodString>;
2706
- synopsis: z.ZodOptional<z.ZodObject<{
2707
- goal: z.ZodOptional<z.ZodString>;
2708
- outcome: z.ZodOptional<z.ZodString>;
2709
- files_touched: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2710
- tools_used: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2711
- rejected_approaches: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2712
- open_threads: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2713
- }, "strip", z.ZodTypeAny, {
2714
- outcome?: string | undefined;
2715
- goal?: string | undefined;
2716
- files_touched?: string[] | undefined;
2717
- tools_used?: string[] | undefined;
2718
- rejected_approaches?: string[] | undefined;
2719
- open_threads?: string[] | undefined;
2720
- }, {
2721
- outcome?: string | undefined;
2722
- goal?: string | undefined;
2723
- files_touched?: string[] | undefined;
2724
- tools_used?: string[] | undefined;
2725
- rejected_approaches?: string[] | undefined;
2726
- open_threads?: string[] | undefined;
2727
- }>>;
2728
- summarizedThroughEntry: z.ZodOptional<z.ZodNumber>;
2729
- agentArgs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2730
- currentModel: z.ZodOptional<z.ZodString>;
2731
- currentMode: z.ZodOptional<z.ZodString>;
2732
- currentUsage: z.ZodOptional<z.ZodObject<{
2733
- used: z.ZodOptional<z.ZodNumber>;
2734
- size: z.ZodOptional<z.ZodNumber>;
2735
- costAmount: z.ZodOptional<z.ZodNumber>;
2736
- costCurrency: z.ZodOptional<z.ZodString>;
2737
- cumulativeCost: z.ZodOptional<z.ZodNumber>;
2738
- }, "strip", z.ZodTypeAny, {
2739
- used?: number | undefined;
2740
- size?: number | undefined;
2741
- costAmount?: number | undefined;
2742
- costCurrency?: string | undefined;
2743
- cumulativeCost?: number | undefined;
2744
- }, {
2745
- used?: number | undefined;
2746
- size?: number | undefined;
2747
- costAmount?: number | undefined;
2748
- costCurrency?: string | undefined;
2749
- cumulativeCost?: number | undefined;
2750
- }>>;
2751
- agentCommands: z.ZodOptional<z.ZodArray<z.ZodObject<{
2752
- name: z.ZodString;
2753
- description: z.ZodOptional<z.ZodString>;
2754
- }, "strip", z.ZodTypeAny, {
2755
- name: string;
2756
- description?: string | undefined;
2757
- }, {
2758
- name: string;
2759
- description?: string | undefined;
2760
- }>, "many">>;
2761
- agentModes: z.ZodOptional<z.ZodArray<z.ZodObject<{
2762
- id: z.ZodString;
2763
- name: z.ZodOptional<z.ZodString>;
2764
- description: z.ZodOptional<z.ZodString>;
2765
- }, "strip", z.ZodTypeAny, {
2766
- id: string;
2767
- name?: string | undefined;
2768
- description?: string | undefined;
2769
- }, {
2770
- id: string;
2771
- name?: string | undefined;
2772
- description?: string | undefined;
2773
- }>, "many">>;
2774
- agentModels: z.ZodOptional<z.ZodArray<z.ZodObject<{
2775
- modelId: z.ZodString;
2776
- name: z.ZodOptional<z.ZodString>;
2777
- description: z.ZodOptional<z.ZodString>;
2778
- }, "strip", z.ZodTypeAny, {
2779
- modelId: string;
2780
- name?: string | undefined;
2781
- description?: string | undefined;
2782
- }, {
2783
- modelId: string;
2784
- name?: string | undefined;
2785
- description?: string | undefined;
2786
- }>, "many">>;
2787
- pendingHistorySync: z.ZodOptional<z.ZodBoolean>;
2788
- parentSessionId: z.ZodOptional<z.ZodString>;
2789
- forkedFromSessionId: z.ZodOptional<z.ZodString>;
2790
- forkedFromMessageId: z.ZodOptional<z.ZodString>;
2791
- originatingClient: z.ZodOptional<z.ZodObject<{
2792
- name: z.ZodString;
2793
- version: z.ZodOptional<z.ZodString>;
2794
- }, "strip", z.ZodTypeAny, {
2795
- name: string;
2796
- version?: string | undefined;
2797
- }, {
2798
- name: string;
2799
- version?: string | undefined;
2800
- }>>;
2801
- interactive: z.ZodOptional<z.ZodBoolean>;
2802
- priority: z.ZodOptional<z.ZodNumber>;
2803
- forwardedEnv: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2804
- createdAt: z.ZodString;
2805
- updatedAt: z.ZodString;
2806
- }, "strip", z.ZodTypeAny, {
2807
- sessionId: string;
2808
- version: 1;
2562
+ description?: string | undefined;
2563
+ }, {
2564
+ name: string;
2565
+ description?: string | undefined;
2566
+ }>, "many">>;
2567
+ agentModes: z.ZodOptional<z.ZodArray<z.ZodObject<{
2568
+ id: z.ZodString;
2569
+ name: z.ZodOptional<z.ZodString>;
2570
+ description: z.ZodOptional<z.ZodString>;
2571
+ }, "strip", z.ZodTypeAny, {
2572
+ id: string;
2573
+ name?: string | undefined;
2574
+ description?: string | undefined;
2575
+ }, {
2576
+ id: string;
2577
+ name?: string | undefined;
2578
+ description?: string | undefined;
2579
+ }>, "many">>;
2580
+ agentModels: z.ZodOptional<z.ZodArray<z.ZodObject<{
2581
+ modelId: z.ZodString;
2582
+ name: z.ZodOptional<z.ZodString>;
2583
+ description: z.ZodOptional<z.ZodString>;
2584
+ }, "strip", z.ZodTypeAny, {
2585
+ modelId: string;
2586
+ name?: string | undefined;
2587
+ description?: string | undefined;
2588
+ }, {
2589
+ modelId: string;
2590
+ name?: string | undefined;
2591
+ description?: string | undefined;
2592
+ }>, "many">>;
2593
+ pendingHistorySync: z.ZodOptional<z.ZodBoolean>;
2594
+ parentSessionId: z.ZodOptional<z.ZodString>;
2595
+ forkedFromSessionId: z.ZodOptional<z.ZodString>;
2596
+ forkedFromMessageId: z.ZodOptional<z.ZodString>;
2597
+ originatingClient: z.ZodOptional<z.ZodObject<{
2598
+ name: z.ZodString;
2599
+ version: z.ZodOptional<z.ZodString>;
2600
+ }, "strip", z.ZodTypeAny, {
2601
+ name: string;
2602
+ version?: string | undefined;
2603
+ }, {
2604
+ name: string;
2605
+ version?: string | undefined;
2606
+ }>>;
2607
+ interactive: z.ZodOptional<z.ZodBoolean>;
2608
+ priority: z.ZodOptional<z.ZodNumber>;
2609
+ forwardedEnv: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2610
+ createdAt: z.ZodString;
2611
+ updatedAt: z.ZodString;
2612
+ }, "strip", z.ZodTypeAny, {
2613
+ sessionId: string;
2614
+ version: 1;
2809
2615
  cwd: string;
2810
2616
  upstreamSessionId: string;
2811
2617
  agentId: string;
@@ -2813,6 +2619,18 @@ declare const SessionRecord: z.ZodObject<{
2813
2619
  createdAt: string;
2814
2620
  title?: string | undefined;
2815
2621
  agentArgs?: string[] | undefined;
2622
+ synopsis?: {
2623
+ goal?: string | undefined;
2624
+ outcome?: string | undefined;
2625
+ files_touched?: string[] | undefined;
2626
+ tools_used?: string[] | undefined;
2627
+ rejected_approaches?: string[] | undefined;
2628
+ open_threads?: string[] | undefined;
2629
+ decisions?: string[] | undefined;
2630
+ file_edit_intentions?: string[] | undefined;
2631
+ unresolved_errors?: string[] | undefined;
2632
+ tool_state?: string[] | undefined;
2633
+ } | undefined;
2816
2634
  currentModel?: string | undefined;
2817
2635
  currentUsage?: {
2818
2636
  used?: number | undefined;
@@ -2832,18 +2650,24 @@ declare const SessionRecord: z.ZodObject<{
2832
2650
  } | undefined;
2833
2651
  interactive?: boolean | undefined;
2834
2652
  priority?: number | undefined;
2835
- currentMode?: string | undefined;
2836
- forwardedEnv?: Record<string, string> | undefined;
2837
- synopsis?: {
2838
- outcome?: string | undefined;
2839
- goal?: string | undefined;
2840
- files_touched?: string[] | undefined;
2841
- tools_used?: string[] | undefined;
2842
- rejected_approaches?: string[] | undefined;
2843
- open_threads?: string[] | undefined;
2653
+ compactionState?: {
2654
+ status: "requested" | "running" | "swap_pending" | "swap_deferred" | "failed";
2655
+ requestedAt: number;
2656
+ iter?: number | undefined;
2657
+ attempts?: number | undefined;
2658
+ lastError?: string | undefined;
2659
+ worker?: {
2660
+ upstreamSessionId: string;
2661
+ pid: number;
2662
+ } | undefined;
2844
2663
  } | undefined;
2664
+ currentMode?: string | undefined;
2845
2665
  lineageId?: string | undefined;
2846
2666
  importedFromSessionId?: string | undefined;
2667
+ rollbackBreadcrumb?: {
2668
+ previousUpstreamSessionId: string;
2669
+ previousSummarizedThroughEntry?: number | undefined;
2670
+ } | undefined;
2847
2671
  summarizedThroughEntry?: number | undefined;
2848
2672
  agentCommands?: {
2849
2673
  name: string;
@@ -2860,6 +2684,7 @@ declare const SessionRecord: z.ZodObject<{
2860
2684
  description?: string | undefined;
2861
2685
  }[] | undefined;
2862
2686
  pendingHistorySync?: boolean | undefined;
2687
+ forwardedEnv?: Record<string, string> | undefined;
2863
2688
  }, {
2864
2689
  sessionId: string;
2865
2690
  version: 1;
@@ -2870,6 +2695,18 @@ declare const SessionRecord: z.ZodObject<{
2870
2695
  createdAt: string;
2871
2696
  title?: string | undefined;
2872
2697
  agentArgs?: string[] | undefined;
2698
+ synopsis?: {
2699
+ goal?: string | undefined;
2700
+ outcome?: string | undefined;
2701
+ files_touched?: string[] | undefined;
2702
+ tools_used?: string[] | undefined;
2703
+ rejected_approaches?: string[] | undefined;
2704
+ open_threads?: string[] | undefined;
2705
+ decisions?: string[] | undefined;
2706
+ file_edit_intentions?: string[] | undefined;
2707
+ unresolved_errors?: string[] | undefined;
2708
+ tool_state?: string[] | undefined;
2709
+ } | undefined;
2873
2710
  currentModel?: string | undefined;
2874
2711
  currentUsage?: {
2875
2712
  used?: number | undefined;
@@ -2889,18 +2726,24 @@ declare const SessionRecord: z.ZodObject<{
2889
2726
  } | undefined;
2890
2727
  interactive?: boolean | undefined;
2891
2728
  priority?: number | undefined;
2892
- currentMode?: string | undefined;
2893
- forwardedEnv?: Record<string, string> | undefined;
2894
- synopsis?: {
2895
- outcome?: string | undefined;
2896
- goal?: string | undefined;
2897
- files_touched?: string[] | undefined;
2898
- tools_used?: string[] | undefined;
2899
- rejected_approaches?: string[] | undefined;
2900
- open_threads?: string[] | undefined;
2729
+ compactionState?: {
2730
+ status: "requested" | "running" | "swap_pending" | "swap_deferred" | "failed";
2731
+ requestedAt: number;
2732
+ iter?: number | undefined;
2733
+ attempts?: number | undefined;
2734
+ lastError?: string | undefined;
2735
+ worker?: {
2736
+ upstreamSessionId: string;
2737
+ pid: number;
2738
+ } | undefined;
2901
2739
  } | undefined;
2740
+ currentMode?: string | undefined;
2902
2741
  lineageId?: string | undefined;
2903
2742
  importedFromSessionId?: string | undefined;
2743
+ rollbackBreadcrumb?: {
2744
+ previousUpstreamSessionId: string;
2745
+ previousSummarizedThroughEntry?: number | undefined;
2746
+ } | undefined;
2904
2747
  summarizedThroughEntry?: number | undefined;
2905
2748
  agentCommands?: {
2906
2749
  name: string;
@@ -2917,6 +2760,7 @@ declare const SessionRecord: z.ZodObject<{
2917
2760
  description?: string | undefined;
2918
2761
  }[] | undefined;
2919
2762
  pendingHistorySync?: boolean | undefined;
2763
+ forwardedEnv?: Record<string, string> | undefined;
2920
2764
  }>;
2921
2765
  type SessionRecord = z.infer<typeof SessionRecord>;
2922
2766
  declare class SessionStore {
@@ -2927,6 +2771,429 @@ declare class SessionStore {
2927
2771
  list(): Promise<SessionRecord[]>;
2928
2772
  }
2929
2773
 
2774
+ interface PersistedQueueEntry {
2775
+ messageId: string;
2776
+ originator: {
2777
+ clientInfo: {
2778
+ name?: string;
2779
+ version?: string;
2780
+ };
2781
+ };
2782
+ prompt: unknown[];
2783
+ enqueuedAt: number;
2784
+ }
2785
+
2786
+ interface AttachedClient {
2787
+ clientId: string;
2788
+ connection: JsonRpcConnection;
2789
+ clientInfo?: {
2790
+ name: string;
2791
+ version?: string;
2792
+ };
2793
+ readonly?: boolean;
2794
+ }
2795
+ type CachedNotification = HistoryEntry;
2796
+ interface SpawnReplacementAgentParams {
2797
+ agentId: string;
2798
+ cwd: string;
2799
+ agentArgs?: string[];
2800
+ forwardedEnv?: Record<string, string>;
2801
+ mcpServers?: unknown[];
2802
+ }
2803
+ interface SpawnReplacementAgentResult {
2804
+ agent: AgentInstance;
2805
+ upstreamSessionId: string;
2806
+ agentMeta?: Record<string, unknown>;
2807
+ agentCapabilities?: AgentCapabilities;
2808
+ initialModel?: string;
2809
+ initialModels?: AdvertisedModel[];
2810
+ initialMode?: string;
2811
+ initialModes?: AdvertisedMode[];
2812
+ }
2813
+ type SpawnReplacementAgent = (params: SpawnReplacementAgentParams) => Promise<SpawnReplacementAgentResult>;
2814
+ type LoadExistingAgentSession = (upstreamSessionId: string, params: SpawnReplacementAgentParams) => Promise<SpawnReplacementAgentResult>;
2815
+ interface UsageSnapshot {
2816
+ used?: number;
2817
+ size?: number;
2818
+ costAmount?: number;
2819
+ costCurrency?: string;
2820
+ cumulativeCost?: number;
2821
+ }
2822
+ interface SessionInit {
2823
+ cwd: string;
2824
+ agentId: string;
2825
+ agent: AgentInstance;
2826
+ upstreamSessionId: string;
2827
+ title?: string;
2828
+ sessionId?: string;
2829
+ agentMeta?: Record<string, unknown>;
2830
+ agentCapabilities?: AgentCapabilities;
2831
+ agentArgs?: string[];
2832
+ idleTimeoutMs?: number;
2833
+ logger?: {
2834
+ info: (msg: string) => void;
2835
+ warn: (msg: string) => void;
2836
+ };
2837
+ spawnReplacementAgent?: SpawnReplacementAgent;
2838
+ mintMcpServersForSwap?: (session: Session) => Promise<unknown[]>;
2839
+ historyStore?: HistoryStore;
2840
+ historyMaxEntries?: number;
2841
+ currentModel?: string;
2842
+ currentMode?: string;
2843
+ currentUsage?: UsageSnapshot;
2844
+ agentCommands?: AdvertisedCommand[];
2845
+ agentModes?: AdvertisedMode[];
2846
+ agentModels?: AdvertisedModel[];
2847
+ firstPromptSeeded?: boolean;
2848
+ scheduleSynopsis?: () => void;
2849
+ scheduleCompaction?: () => void;
2850
+ getCompactionState?: () => Promise<CompactionState | undefined>;
2851
+ createdAt?: number;
2852
+ transformChain?: TransformerRef[];
2853
+ idleEventTimeoutMs?: number;
2854
+ parentSessionId?: string;
2855
+ forkedFromSessionId?: string;
2856
+ forkedFromMessageId?: string;
2857
+ originatingClient?: {
2858
+ name: string;
2859
+ version?: string;
2860
+ };
2861
+ interactive?: boolean;
2862
+ priority?: number;
2863
+ forwardedEnv?: Record<string, string>;
2864
+ listSessions?: () => Promise<{
2865
+ sessionId: string;
2866
+ title?: string;
2867
+ cwd: string;
2868
+ agentId?: string;
2869
+ currentModel?: string;
2870
+ }[]>;
2871
+ extensionCommands?: ExtensionCommandRegistry;
2872
+ availableAgents?: () => Array<{
2873
+ id: string;
2874
+ name?: string;
2875
+ description?: string;
2876
+ }>;
2877
+ summarizedThroughEntry?: number;
2878
+ compactionState?: CompactionState;
2879
+ mcpServers?: unknown[];
2880
+ loadExistingAgentSession?: LoadExistingAgentSession;
2881
+ clearRollbackBreadcrumbHook?: () => void;
2882
+ onCompactionSwapHook?: (breadcrumb: RollbackBreadcrumb) => void;
2883
+ uncompactHook?: () => Promise<void>;
2884
+ }
2885
+ interface CloseOptions {
2886
+ deleteRecord?: boolean;
2887
+ }
2888
+ declare class Session {
2889
+ readonly sessionId: string;
2890
+ readonly cwd: string;
2891
+ agentId: string;
2892
+ agent: AgentInstance;
2893
+ upstreamSessionId: string;
2894
+ agentMeta: Record<string, unknown> | undefined;
2895
+ agentCapabilities: AgentCapabilities | undefined;
2896
+ readonly agentArgs: string[] | undefined;
2897
+ readonly parentSessionId: string | undefined;
2898
+ readonly forkedFromSessionId: string | undefined;
2899
+ readonly forkedFromMessageId: string | undefined;
2900
+ readonly originatingClient: {
2901
+ name: string;
2902
+ version?: string;
2903
+ } | undefined;
2904
+ private _interactive;
2905
+ get interactive(): boolean | undefined;
2906
+ private _priority;
2907
+ get priority(): number | undefined;
2908
+ title: string | undefined;
2909
+ private _summarizedThroughEntry;
2910
+ get summarizedThroughEntry(): number | undefined;
2911
+ set summarizedThroughEntry(value: number | undefined);
2912
+ currentModel: string | undefined;
2913
+ currentMode: string | undefined;
2914
+ compactionState: CompactionState | undefined;
2915
+ private _currentUsage;
2916
+ updatedAt: number;
2917
+ readonly createdAt: number;
2918
+ private clients;
2919
+ private historyStore;
2920
+ private promptQueue;
2921
+ private currentEntry;
2922
+ private promptInFlight;
2923
+ private modeChangeInFlight;
2924
+ private modelChangeInFlight;
2925
+ private queueWriteChain;
2926
+ private closed;
2927
+ private closing;
2928
+ private closeInFlight;
2929
+ private closeHandlers;
2930
+ private titleHandlers;
2931
+ private scheduleSynopsisHook?;
2932
+ private scheduleCompactionHook?;
2933
+ private getCompactionStateHook?;
2934
+ private _liveCompactionPhase;
2935
+ private broadcastHandlers;
2936
+ private lastCancelAt;
2937
+ private static readonly CANCEL_ERROR_WINDOW_MS;
2938
+ private forceCancelling;
2939
+ private _firstPromptSeeded;
2940
+ get firstPromptSeeded(): boolean;
2941
+ private promptStartedAt;
2942
+ private appendCount;
2943
+ private historyMaxEntries;
2944
+ private compactEvery;
2945
+ private inFlightPermissions;
2946
+ private internalPromptCapture;
2947
+ private idleTimeoutMs;
2948
+ private idleTimer;
2949
+ private idleEventTimer;
2950
+ private idleEventTimeoutMs;
2951
+ private lastRecordedAt;
2952
+ private spawnReplacementAgent;
2953
+ private mintMcpServersForSwap;
2954
+ private loadExistingAgentSession;
2955
+ private clearRollbackBreadcrumbHook;
2956
+ private onCompactionSwapHook;
2957
+ private uncompactHook;
2958
+ private readonly mcpServersConfig;
2959
+ forwardedEnv: Record<string, string> | undefined;
2960
+ private listSessions;
2961
+ private logger;
2962
+ private transformChain;
2963
+ private extensionCommands;
2964
+ private extensionCommandsUnsub;
2965
+ private pendingClaims;
2966
+ private agentChangeHandlers;
2967
+ private agentAdvertisedCommands;
2968
+ private agentAdvertisedModes;
2969
+ private agentAdvertisedModels;
2970
+ private agentAdvertisedConfigOptions;
2971
+ private agentCommandsHandlers;
2972
+ private agentModesHandlers;
2973
+ private agentModelsHandlers;
2974
+ private availableAgentsFn?;
2975
+ private modelHandlers;
2976
+ private modeHandlers;
2977
+ private interactiveHandlers;
2978
+ private priorityHandlers;
2979
+ private usageHandlers;
2980
+ private cumulativeCost;
2981
+ get currentUsage(): UsageSnapshot | undefined;
2982
+ private amendInProgress;
2983
+ private inFlightExtensionDispatches;
2984
+ private recentlyTerminal;
2985
+ private streamBuffer;
2986
+ private streamFilePath;
2987
+ constructor(init: SessionInit);
2988
+ private broadcastMergedCommands;
2989
+ private broadcastAvailableModes;
2990
+ private broadcastAvailableModels;
2991
+ private wireAgent;
2992
+ private handleOrphanError;
2993
+ private runResponseChain;
2994
+ onAgentChange(handler: (info: {
2995
+ agentId: string;
2996
+ upstreamSessionId: string;
2997
+ }) => void): void;
2998
+ get attachedCount(): number;
2999
+ connectedClients(excludeClientId?: string): Array<{
3000
+ clientId: string;
3001
+ name?: string;
3002
+ version?: string;
3003
+ }>;
3004
+ get turnStartedAt(): number | undefined;
3005
+ get awaitingInput(): boolean;
3006
+ isQuiescedForSwap(): Promise<boolean>;
3007
+ swapUpstream(opts: {
3008
+ artifact: SessionSynopsis;
3009
+ title?: string;
3010
+ tailK: number;
3011
+ summarizedThroughEntry?: number;
3012
+ }): Promise<void>;
3013
+ rollbackToUpstream(opts: {
3014
+ previousUpstreamSessionId: string;
3015
+ previousSummarizedThroughEntry?: number;
3016
+ }): Promise<void>;
3017
+ private _hasOpenToolCall;
3018
+ getHistorySnapshot(tools?: "inline" | "references"): Promise<CachedNotification[]>;
3019
+ onBroadcast(handler: (entry: CachedNotification) => void): () => void;
3020
+ broadcastCompactionPhase(update: Record<string, unknown>): void;
3021
+ attach(client: AttachedClient, historyPolicy: HistoryPolicy, opts?: {
3022
+ afterMessageId?: string;
3023
+ raw?: boolean;
3024
+ toolContent?: "inline" | "references";
3025
+ }): Promise<{
3026
+ entries: CachedNotification[];
3027
+ appliedPolicy: HistoryPolicy;
3028
+ }>;
3029
+ private loadReplay;
3030
+ private buildStateSnapshotReplay;
3031
+ replayPendingPermissions(client: AttachedClient): void;
3032
+ detach(clientId: string): void;
3033
+ private broadcastClientDisconnected;
3034
+ prompt(clientId: string, params: unknown): Promise<unknown>;
3035
+ private broadcastPromptReceived;
3036
+ private recordCurrentUsageSnapshot;
3037
+ private broadcastTurnComplete;
3038
+ private recordTerminal;
3039
+ private broadcastPromptAmended;
3040
+ private findUserEntry;
3041
+ private visibleQueueDepth;
3042
+ private broadcastQueueAdded;
3043
+ private broadcastQueueUpdated;
3044
+ private broadcastQueueRemoved;
3045
+ private broadcastQueueNotification;
3046
+ queueSnapshot(): PromptQueueEntry[];
3047
+ flushPersistWrites(): Promise<void>;
3048
+ replayPersistedQueue(entries: PersistedQueueEntry[]): void;
3049
+ cancelQueuedPrompt(messageId: string): CancelPromptResult;
3050
+ updateQueuedPrompt(messageId: string, prompt: unknown[]): UpdatePromptResult;
3051
+ amendPrompt(clientId: string, params: AmendPromptParams): AmendPromptResult;
3052
+ private amendOnHead;
3053
+ private enqueueAmendmentAsFollowUp;
3054
+ cancel(clientId: string): Promise<void>;
3055
+ addTransformer(ref: TransformerRef): void;
3056
+ forwardRequest(method: string, params: unknown, originatedBy?: Set<string>, startIdx?: number, tailKind?: "request" | "notification"): Promise<unknown>;
3057
+ dischargeClaim(token: string, result: unknown): boolean;
3058
+ keepAliveClaim(token: string, estimatedRemainingMs?: number): boolean;
3059
+ emitToChain(emitterName: string, method: string, envelope: unknown): Promise<unknown>;
3060
+ private rewriteForAgent;
3061
+ close(opts?: CloseOptions): Promise<void>;
3062
+ private doClose;
3063
+ onClose(handler: (opts: {
3064
+ deleteRecord: boolean;
3065
+ }) => void): () => void;
3066
+ onTitleChange(handler: (title: string) => void): void;
3067
+ retitle(title: string): Promise<unknown>;
3068
+ retitleFromAgent(): Promise<unknown>;
3069
+ private setTitle;
3070
+ private maybeSeedTitleFromPrompt;
3071
+ private maybeApplyAgentModel;
3072
+ private maybeApplyAgentConfigOption;
3073
+ private maybeApplyAgentMode;
3074
+ private maybeApplyAgentUsage;
3075
+ private accumulateAndResetCost;
3076
+ private injectCumulativeCost;
3077
+ get totalUsage(): UsageSnapshot | undefined;
3078
+ private setAgentAdvertisedCommands;
3079
+ private setAgentAdvertisedModes;
3080
+ private setAgentAdvertisedModels;
3081
+ onAgentCommandsChange(handler: (commands: AdvertisedCommand[]) => void): void;
3082
+ onAgentModesChange(handler: (modes: AdvertisedMode[]) => void): void;
3083
+ onAgentModelsChange(handler: (models: AdvertisedModel[]) => void): void;
3084
+ onModelChange(handler: (model: string) => void): void;
3085
+ onModeChange(handler: (mode: string) => void): void;
3086
+ onInteractiveChange(handler: (interactive: boolean) => void): void;
3087
+ onPriorityChange(handler: (priority: number | undefined) => void): void;
3088
+ setPriority(priority: number | undefined): void;
3089
+ applyModelChange(modelId: string): void;
3090
+ applyModeChange(modeId: string): void;
3091
+ buildConfigOptions(): ConfigOption[];
3092
+ private broadcastConfigOptions;
3093
+ private mergeAgentOptionIntoEnvelope;
3094
+ onUsageChange(handler: (usage: UsageSnapshot) => void): void;
3095
+ mergedAvailableCommands(): AdvertisedCommand[];
3096
+ agentOnlyAdvertisedCommands(): AdvertisedCommand[];
3097
+ availableModes(): AdvertisedMode[];
3098
+ availableModels(): AdvertisedModel[];
3099
+ private maybeApplyAgentSessionInfo;
3100
+ private handleSlashCommand;
3101
+ private runExtensionCommand;
3102
+ private runExtensionCommandInline;
3103
+ private cancelExtensionDispatch;
3104
+ private emitExtensionReply;
3105
+ private handleSessionsCommand;
3106
+ private handleHelpCommand;
3107
+ private handleModelCommand;
3108
+ private handleModeCommand;
3109
+ private handleConfigCommand;
3110
+ private runTitleCommand;
3111
+ private runTitleCommandInline;
3112
+ private runInternalPrompt;
3113
+ setAgent(newAgentId: string): Promise<unknown>;
3114
+ private runAgentCommand;
3115
+ private runAgentCommandInline;
3116
+ private runKillCommand;
3117
+ private runRestartCommand;
3118
+ private runRestartCommandInline;
3119
+ private runCompactCommand;
3120
+ private runCompactCommandInline;
3121
+ private runCompactStatusCommandInline;
3122
+ private runUncompactCommand;
3123
+ private runUncompactCommandInline;
3124
+ forceCancel(): Promise<{
3125
+ stopReason: string;
3126
+ }>;
3127
+ private respawnAgent;
3128
+ private buildSwitchTranscript;
3129
+ seedFromImport(): Promise<void>;
3130
+ private broadcastAgentSwitch;
3131
+ hasStreamBuffer(): boolean;
3132
+ get streamPath(): string | undefined;
3133
+ openStream(opts: {
3134
+ mode?: "memory" | "file";
3135
+ capacityBytes?: number;
3136
+ fileCapBytes?: number;
3137
+ filePathFor?: (sessionId: string) => string;
3138
+ }): {
3139
+ filePath?: string;
3140
+ capacityBytes: number;
3141
+ fileCapBytes?: number;
3142
+ };
3143
+ streamWrite(chunkB64: string, eof?: boolean): {
3144
+ writeCursor: number;
3145
+ };
3146
+ streamRead(cursor: number, maxBytes: number | undefined, waitMs: number | undefined): Promise<{
3147
+ bytes: string;
3148
+ nextCursor: number;
3149
+ gap?: number;
3150
+ eof?: boolean;
3151
+ }>;
3152
+ streamTail(bytes: number): {
3153
+ bytes: string;
3154
+ startCursor: number;
3155
+ endCursor: number;
3156
+ truncated: boolean;
3157
+ };
3158
+ streamHead(bytes: number): {
3159
+ bytes: string;
3160
+ startCursor: number;
3161
+ endCursor: number;
3162
+ truncated: boolean;
3163
+ };
3164
+ streamWaitFor(cursor: number, timeoutMs: number): Promise<"data" | "eof" | "timeout">;
3165
+ streamGrep(opts: StreamGrepOptions): StreamGrepResult;
3166
+ streamInfo(): {
3167
+ writeCursor: number;
3168
+ oldestAvailable: number;
3169
+ capacity: number;
3170
+ closed: boolean;
3171
+ };
3172
+ private requireStreamBuffer;
3173
+ private markClosed;
3174
+ private get lastActivityAt();
3175
+ private scheduleIdleCheck;
3176
+ private armIdleTimer;
3177
+ private checkIdle;
3178
+ private cancelIdleTimer;
3179
+ private scheduleIdleEvent;
3180
+ private cancelIdleEventTimer;
3181
+ private notifyChain;
3182
+ private rewriteForClient;
3183
+ private recordAndBroadcast;
3184
+ requestPermissionFromClients(params: unknown): Promise<unknown>;
3185
+ private handlePermissionRequest;
3186
+ private enqueuePrompt;
3187
+ private enqueueUserPrompt;
3188
+ private parseQueuePosition;
3189
+ private insertEntryAt;
3190
+ private persistRewrite;
3191
+ private persistedFromEntry;
3192
+ private drainQueue;
3193
+ private runQueueEntry;
3194
+ private clearAmendIfMatches;
3195
+ }
3196
+
2930
3197
  declare const Tombstone: z.ZodObject<{
2931
3198
  version: z.ZodLiteral<1>;
2932
3199
  agentId: z.ZodString;
@@ -2998,20 +3265,32 @@ declare const Bundle: z.ZodObject<{
2998
3265
  tools_used: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2999
3266
  rejected_approaches: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3000
3267
  open_threads: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3268
+ decisions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3269
+ file_edit_intentions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3270
+ unresolved_errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3271
+ tool_state: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3001
3272
  }, "strip", z.ZodTypeAny, {
3002
- outcome?: string | undefined;
3003
3273
  goal?: string | undefined;
3274
+ outcome?: string | undefined;
3004
3275
  files_touched?: string[] | undefined;
3005
3276
  tools_used?: string[] | undefined;
3006
3277
  rejected_approaches?: string[] | undefined;
3007
3278
  open_threads?: string[] | undefined;
3279
+ decisions?: string[] | undefined;
3280
+ file_edit_intentions?: string[] | undefined;
3281
+ unresolved_errors?: string[] | undefined;
3282
+ tool_state?: string[] | undefined;
3008
3283
  }, {
3009
- outcome?: string | undefined;
3010
3284
  goal?: string | undefined;
3285
+ outcome?: string | undefined;
3011
3286
  files_touched?: string[] | undefined;
3012
3287
  tools_used?: string[] | undefined;
3013
3288
  rejected_approaches?: string[] | undefined;
3014
3289
  open_threads?: string[] | undefined;
3290
+ decisions?: string[] | undefined;
3291
+ file_edit_intentions?: string[] | undefined;
3292
+ unresolved_errors?: string[] | undefined;
3293
+ tool_state?: string[] | undefined;
3015
3294
  }>>;
3016
3295
  summarizedThroughEntry: z.ZodOptional<z.ZodNumber>;
3017
3296
  currentModel: z.ZodOptional<z.ZodString>;
@@ -3081,6 +3360,18 @@ declare const Bundle: z.ZodObject<{
3081
3360
  lineageId: string;
3082
3361
  title?: string | undefined;
3083
3362
  upstreamSessionId?: string | undefined;
3363
+ synopsis?: {
3364
+ goal?: string | undefined;
3365
+ outcome?: string | undefined;
3366
+ files_touched?: string[] | undefined;
3367
+ tools_used?: string[] | undefined;
3368
+ rejected_approaches?: string[] | undefined;
3369
+ open_threads?: string[] | undefined;
3370
+ decisions?: string[] | undefined;
3371
+ file_edit_intentions?: string[] | undefined;
3372
+ unresolved_errors?: string[] | undefined;
3373
+ tool_state?: string[] | undefined;
3374
+ } | undefined;
3084
3375
  currentModel?: string | undefined;
3085
3376
  currentUsage?: {
3086
3377
  used?: number | undefined;
@@ -3096,14 +3387,6 @@ declare const Bundle: z.ZodObject<{
3096
3387
  interactive?: boolean | undefined;
3097
3388
  priority?: number | undefined;
3098
3389
  currentMode?: string | undefined;
3099
- synopsis?: {
3100
- outcome?: string | undefined;
3101
- goal?: string | undefined;
3102
- files_touched?: string[] | undefined;
3103
- tools_used?: string[] | undefined;
3104
- rejected_approaches?: string[] | undefined;
3105
- open_threads?: string[] | undefined;
3106
- } | undefined;
3107
3390
  summarizedThroughEntry?: number | undefined;
3108
3391
  agentCommands?: {
3109
3392
  name: string;
@@ -3123,6 +3406,18 @@ declare const Bundle: z.ZodObject<{
3123
3406
  lineageId: string;
3124
3407
  title?: string | undefined;
3125
3408
  upstreamSessionId?: string | undefined;
3409
+ synopsis?: {
3410
+ goal?: string | undefined;
3411
+ outcome?: string | undefined;
3412
+ files_touched?: string[] | undefined;
3413
+ tools_used?: string[] | undefined;
3414
+ rejected_approaches?: string[] | undefined;
3415
+ open_threads?: string[] | undefined;
3416
+ decisions?: string[] | undefined;
3417
+ file_edit_intentions?: string[] | undefined;
3418
+ unresolved_errors?: string[] | undefined;
3419
+ tool_state?: string[] | undefined;
3420
+ } | undefined;
3126
3421
  currentModel?: string | undefined;
3127
3422
  currentUsage?: {
3128
3423
  used?: number | undefined;
@@ -3138,14 +3433,6 @@ declare const Bundle: z.ZodObject<{
3138
3433
  interactive?: boolean | undefined;
3139
3434
  priority?: number | undefined;
3140
3435
  currentMode?: string | undefined;
3141
- synopsis?: {
3142
- outcome?: string | undefined;
3143
- goal?: string | undefined;
3144
- files_touched?: string[] | undefined;
3145
- tools_used?: string[] | undefined;
3146
- rejected_approaches?: string[] | undefined;
3147
- open_threads?: string[] | undefined;
3148
- } | undefined;
3149
3436
  summarizedThroughEntry?: number | undefined;
3150
3437
  agentCommands?: {
3151
3438
  name: string;
@@ -3183,6 +3470,18 @@ declare const Bundle: z.ZodObject<{
3183
3470
  lineageId: string;
3184
3471
  title?: string | undefined;
3185
3472
  upstreamSessionId?: string | undefined;
3473
+ synopsis?: {
3474
+ goal?: string | undefined;
3475
+ outcome?: string | undefined;
3476
+ files_touched?: string[] | undefined;
3477
+ tools_used?: string[] | undefined;
3478
+ rejected_approaches?: string[] | undefined;
3479
+ open_threads?: string[] | undefined;
3480
+ decisions?: string[] | undefined;
3481
+ file_edit_intentions?: string[] | undefined;
3482
+ unresolved_errors?: string[] | undefined;
3483
+ tool_state?: string[] | undefined;
3484
+ } | undefined;
3186
3485
  currentModel?: string | undefined;
3187
3486
  currentUsage?: {
3188
3487
  used?: number | undefined;
@@ -3198,14 +3497,6 @@ declare const Bundle: z.ZodObject<{
3198
3497
  interactive?: boolean | undefined;
3199
3498
  priority?: number | undefined;
3200
3499
  currentMode?: string | undefined;
3201
- synopsis?: {
3202
- outcome?: string | undefined;
3203
- goal?: string | undefined;
3204
- files_touched?: string[] | undefined;
3205
- tools_used?: string[] | undefined;
3206
- rejected_approaches?: string[] | undefined;
3207
- open_threads?: string[] | undefined;
3208
- } | undefined;
3209
3500
  summarizedThroughEntry?: number | undefined;
3210
3501
  agentCommands?: {
3211
3502
  name: string;
@@ -3241,6 +3532,18 @@ declare const Bundle: z.ZodObject<{
3241
3532
  lineageId: string;
3242
3533
  title?: string | undefined;
3243
3534
  upstreamSessionId?: string | undefined;
3535
+ synopsis?: {
3536
+ goal?: string | undefined;
3537
+ outcome?: string | undefined;
3538
+ files_touched?: string[] | undefined;
3539
+ tools_used?: string[] | undefined;
3540
+ rejected_approaches?: string[] | undefined;
3541
+ open_threads?: string[] | undefined;
3542
+ decisions?: string[] | undefined;
3543
+ file_edit_intentions?: string[] | undefined;
3544
+ unresolved_errors?: string[] | undefined;
3545
+ tool_state?: string[] | undefined;
3546
+ } | undefined;
3244
3547
  currentModel?: string | undefined;
3245
3548
  currentUsage?: {
3246
3549
  used?: number | undefined;
@@ -3256,14 +3559,6 @@ declare const Bundle: z.ZodObject<{
3256
3559
  interactive?: boolean | undefined;
3257
3560
  priority?: number | undefined;
3258
3561
  currentMode?: string | undefined;
3259
- synopsis?: {
3260
- outcome?: string | undefined;
3261
- goal?: string | undefined;
3262
- files_touched?: string[] | undefined;
3263
- tools_used?: string[] | undefined;
3264
- rejected_approaches?: string[] | undefined;
3265
- open_threads?: string[] | undefined;
3266
- } | undefined;
3267
3562
  summarizedThroughEntry?: number | undefined;
3268
3563
  agentCommands?: {
3269
3564
  name: string;
@@ -3307,6 +3602,7 @@ interface CreateSessionParams {
3307
3602
  };
3308
3603
  interactive?: boolean;
3309
3604
  forwardedEnv?: Record<string, string>;
3605
+ mintMcpServersForSwap?: (session: Session) => Promise<unknown[]>;
3310
3606
  }
3311
3607
  interface ResurrectParams {
3312
3608
  hydraSessionId: string;
@@ -3336,6 +3632,8 @@ interface ResurrectParams {
3336
3632
  forkedFromMessageId?: string;
3337
3633
  mcpServers?: unknown[];
3338
3634
  forwardedEnv?: Record<string, string>;
3635
+ compactionState?: CompactionState;
3636
+ mintMcpServersForSwap?: (session: Session) => Promise<unknown[]>;
3339
3637
  }
3340
3638
  type AgentSpawner = (opts: AgentInstanceOptions) => AgentInstance;
3341
3639
  interface SessionManagerOptions {
@@ -3343,7 +3641,8 @@ interface SessionManagerOptions {
3343
3641
  defaultModels?: Record<string, string>;
3344
3642
  synopsisAgent?: string;
3345
3643
  synopsisModel?: string;
3346
- synopsisOnClose?: boolean;
3644
+ compactionAgent?: string;
3645
+ compactionModel?: string;
3347
3646
  sessionHistoryMaxEntries?: number;
3348
3647
  defaultTransformers?: string[];
3349
3648
  idleEventTimeoutMs?: number;
@@ -3352,6 +3651,10 @@ interface SessionManagerOptions {
3352
3651
  extensionCommands?: ExtensionCommandRegistry;
3353
3652
  defaultCwd?: string;
3354
3653
  tombstones?: TombstoneStore;
3654
+ compaction?: {
3655
+ tailK?: number;
3656
+ maxIterations?: number;
3657
+ };
3355
3658
  }
3356
3659
  declare class SessionManager {
3357
3660
  private registry;
@@ -3366,7 +3669,8 @@ declare class SessionManager {
3366
3669
  private defaultModels;
3367
3670
  private synopsisAgent?;
3368
3671
  private synopsisModel?;
3369
- private synopsisOnClose;
3672
+ private compactionAgent?;
3673
+ private compactionModel?;
3370
3674
  readonly defaultTransformers: string[];
3371
3675
  private idleEventTimeoutMs;
3372
3676
  private sessionHistoryMaxEntries;
@@ -3378,8 +3682,12 @@ declare class SessionManager {
3378
3682
  private extensionCommands?;
3379
3683
  private defaultCwd;
3380
3684
  private synopsisCoordinator;
3685
+ private compactionDeferrals;
3686
+ private rollbackLocks;
3687
+ private compactionTailK;
3381
3688
  private agentCatalog;
3382
3689
  constructor(registry: Registry, spawner?: AgentSpawner, store?: SessionStore, options?: SessionManagerOptions);
3690
+ private retrySwap;
3383
3691
  private refreshAgentCatalog;
3384
3692
  create(params: CreateSessionParams): Promise<Session>;
3385
3693
  resurrect(params: ResurrectParams): Promise<Session>;
@@ -3395,6 +3703,8 @@ declare class SessionManager {
3395
3703
  private collectAgentSessions;
3396
3704
  private applySeedModel;
3397
3705
  private bootstrapAgent;
3706
+ private bootstrapAgentLoad;
3707
+ performUncompact(sessionId: string): Promise<void>;
3398
3708
  bootstrapAgentForAuth(agentId: string, cwd?: string): Promise<AgentInstance>;
3399
3709
  planSpawnForAgent(agentId: string): Promise<SpawnPlan>;
3400
3710
  consumePendingAuthAgent(agentId: string): AgentInstance | undefined;
@@ -3464,8 +3774,15 @@ declare class SessionManager {
3464
3774
  flushSynopsis(timeoutMs: number): Promise<void>;
3465
3775
  shutdownSynopsis(): Promise<void>;
3466
3776
  scheduleSynopsis(sessionId: string): void;
3777
+ scheduleCompaction(sessionId: string): void;
3778
+ getCompactionInFlight(): boolean;
3779
+ getCompactionState(sessionId: string): Promise<CompactionState | undefined>;
3780
+ getRollbackBreadcrumb(sessionId: string): Promise<RollbackBreadcrumb | undefined>;
3781
+ private broadcastHydraCompaction;
3782
+ getSummarizedThroughEntry(sessionId: string): Promise<number | undefined>;
3467
3783
  flushMetaWrites(): Promise<void>;
3468
3784
  flushHistoryWrites(): Promise<void>;
3785
+ resumePendingCompactions(): Promise<void>;
3469
3786
  resurrectPendingQueues(): Promise<void>;
3470
3787
  }
3471
3788