@adhdev/daemon-core 0.8.52 → 0.8.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/commands/cli-manager.d.ts +8 -1
  2. package/dist/index.d.ts +5 -1
  3. package/dist/index.js +896 -299
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +887 -300
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/providers/acp-provider-instance.d.ts +2 -1
  8. package/dist/providers/cli-provider-instance.d.ts +3 -1
  9. package/dist/providers/cli-script-results.d.ts +8 -0
  10. package/dist/providers/contracts.d.ts +58 -9
  11. package/dist/providers/control-effects.d.ts +4 -1
  12. package/dist/providers/io-contracts.d.ts +91 -0
  13. package/dist/providers/provider-schema.d.ts +5 -0
  14. package/dist/session-host/runtime-surface.d.ts +16 -0
  15. package/dist/session-host/startup-restore-policy.d.ts +1 -0
  16. package/dist/shared-types.d.ts +6 -0
  17. package/dist/types.d.ts +3 -3
  18. package/node_modules/@adhdev/session-host-core/dist/index.d.mts +16 -1
  19. package/node_modules/@adhdev/session-host-core/dist/index.d.ts +16 -1
  20. package/node_modules/@adhdev/session-host-core/dist/index.js +59 -0
  21. package/node_modules/@adhdev/session-host-core/dist/index.js.map +1 -1
  22. package/node_modules/@adhdev/session-host-core/dist/index.mjs +54 -0
  23. package/node_modules/@adhdev/session-host-core/dist/index.mjs.map +1 -1
  24. package/node_modules/@adhdev/session-host-core/package.json +1 -1
  25. package/package.json +1 -1
  26. package/src/commands/cdp-commands.ts +27 -0
  27. package/src/commands/chat-commands.ts +7 -2
  28. package/src/commands/cli-manager.ts +9 -5
  29. package/src/commands/handler.ts +1 -9
  30. package/src/commands/stream-commands.ts +26 -36
  31. package/src/daemon/dev-server.ts +4 -18
  32. package/src/index.d.ts +3 -0
  33. package/src/index.ts +12 -1
  34. package/src/providers/acp-provider-instance.ts +156 -14
  35. package/src/providers/cli-provider-instance.ts +54 -5
  36. package/src/providers/cli-script-results.ts +39 -0
  37. package/src/providers/contracts.ts +72 -19
  38. package/src/providers/control-effects.ts +86 -1
  39. package/src/providers/io-contracts.ts +340 -0
  40. package/src/providers/provider-loader.ts +18 -13
  41. package/src/providers/provider-schema.ts +154 -0
  42. package/src/session-host/runtime-surface.ts +80 -0
  43. package/src/session-host/startup-restore-policy.d.ts +1 -0
  44. package/src/session-host/startup-restore-policy.js +7 -0
  45. package/src/session-host/startup-restore-policy.ts +7 -0
  46. package/src/shared-types.ts +6 -0
  47. package/src/status/builders.ts +5 -81
  48. package/src/types.ts +3 -3
@@ -14,8 +14,9 @@
14
14
  * 4. onEvent('send_message') → session/prompt transmit
15
15
  * 5. dispose() → kill process
16
16
  */
17
- import type { ProviderModule, ContentBlock } from './contracts.js';
17
+ import type { ProviderModule, ContentBlock, InputEnvelope } from './contracts.js';
18
18
  import type { ProviderInstance, AcpProviderState, InstanceContext } from './provider-instance.js';
19
+ export declare function buildAcpPromptParts(input: InputEnvelope, agentCapabilities?: Record<string, any>): ContentBlock[];
19
20
  export declare class AcpProviderInstance implements ProviderInstance {
20
21
  private cliArgs;
21
22
  readonly type: string;
@@ -4,10 +4,11 @@
4
4
  * Lifecycle layer on top of ProviderCliAdapter.
5
5
  * collectCliData() + status transition logic from daemon-status.ts moved here.
6
6
  */
7
- import type { ProviderModule } from './contracts.js';
7
+ import { type ProviderModule } from './contracts.js';
8
8
  import type { ProviderInstance, ProviderState, InstanceContext } from './provider-instance.js';
9
9
  import { ProviderCliAdapter } from '../cli-adapters/provider-cli-adapter.js';
10
10
  import type { PtyTransportFactory } from '../cli-adapters/pty-transport.js';
11
+ export declare function getForcedNewSessionScriptName(provider: ProviderModule | undefined, launchMode: 'new' | 'resume' | 'manual'): string | null;
11
12
  export declare class CliProviderInstance implements ProviderInstance {
12
13
  private provider;
13
14
  private workingDir;
@@ -62,6 +63,7 @@ export declare class CliProviderInstance implements ProviderInstance {
62
63
  dispose(): void;
63
64
  private completedDebounceTimer;
64
65
  private completedDebouncePending;
66
+ private enforceFreshSessionLaunchIfNeeded;
65
67
  private detectStatusTransition;
66
68
  private pushEvent;
67
69
  private flushEvents;
@@ -0,0 +1,8 @@
1
+ export declare function parseCliScriptResult(result: unknown): {
2
+ success: boolean;
3
+ payload: any;
4
+ };
5
+ export declare function getCliScriptCommand(payload: any): {
6
+ type: string;
7
+ text?: string;
8
+ } | null;
@@ -29,7 +29,9 @@ export interface ReadChatResult {
29
29
  effects?: ProviderEffect[];
30
30
  }
31
31
  import type { ChatMessage } from '../types.js';
32
- export type { ChatMessage };
32
+ export { flattenMessageParts, normalizeInputEnvelope, normalizeMessageParts, } from './io-contracts.js';
33
+ import type { InputEnvelope, InputPart, MessagePart } from './io-contracts.js';
34
+ export type { ChatMessage, InputEnvelope, InputPart, MessagePart };
33
35
  export type AgentStatus = 'idle' | 'generating' | 'waiting_approval' | 'error' | 'panel_hidden' | 'streaming';
34
36
  export interface ModalInfo {
35
37
  message: string;
@@ -39,7 +41,7 @@ export interface ModalInfo {
39
41
  }
40
42
  export interface ProviderEffectMessage {
41
43
  role?: 'system' | 'assistant' | 'user';
42
- content: string | ContentBlock[];
44
+ content: string | MessagePart[];
43
45
  kind?: string;
44
46
  senderName?: string;
45
47
  }
@@ -55,7 +57,7 @@ export interface ProviderEffectNotification {
55
57
  level?: 'info' | 'success' | 'warning';
56
58
  channels?: ProviderNotificationChannel[];
57
59
  preferenceKey?: ProviderNotificationPreferenceKey;
58
- bubbleContent?: string | ContentBlock[];
60
+ bubbleContent?: string | MessagePart[];
59
61
  }
60
62
  export interface ProviderEffect {
61
63
  type: 'message' | 'toast' | 'notification';
@@ -156,16 +158,18 @@ export interface ToolCallLocation {
156
158
  path: string;
157
159
  line?: number | null;
158
160
  }
159
- /** Normalize content: string ContentBlock[] */
160
- export declare function normalizeContent(content: string | ContentBlock[]): ContentBlock[];
161
- /** Flatten ContentBlock[] string (backward compat / plain-text extraction) */
162
- export declare function flattenContent(content: string | ContentBlock[]): string;
163
- /** SendMessage params — supports rich content (ACP PromptRequest compatible) */
161
+ /** Normalize content into canonical message parts */
162
+ export declare function normalizeContent(content: string | MessagePart[] | ContentBlock[]): MessagePart[];
163
+ /** Flatten canonical/legacy content into a plain-text fallback string */
164
+ export declare function flattenContent(content: string | MessagePart[] | ContentBlock[]): string;
165
+ /** SendMessage params — canonical input envelope with legacy text/prompt compatibility */
164
166
  export interface SendMessageParams {
165
167
  /** Shortcut: text-only message */
166
168
  text?: string;
167
- /** Rich content blocks (ACP ContentBlock[]) */
169
+ /** Rich content blocks (legacy ACP ContentBlock[]) */
168
170
  prompt?: ContentBlock[];
171
+ /** Canonical multipart runtime input */
172
+ input?: InputEnvelope;
169
173
  }
170
174
  export interface SendMessageResult {
171
175
  sent: boolean;
@@ -257,6 +261,12 @@ export interface ProviderModule {
257
261
  icon?: string;
258
262
  /** Display name (short name) */
259
263
  displayName?: string;
264
+ /** Provider-definition version maintained in adhdev-providers */
265
+ providerVersion?: string;
266
+ /** Inventory/support status label maintained in adhdev-providers */
267
+ status?: string;
268
+ /** Inventory/support detail string maintained in adhdev-providers */
269
+ details?: string;
260
270
  /** Install instructions (shown when command is missing) */
261
271
  install?: string;
262
272
  /** Custom version detection command (e.g. 'cursor --version', 'claude -v') */
@@ -311,6 +321,14 @@ export interface ProviderModule {
311
321
  shell?: boolean;
312
322
  env?: Record<string, string>;
313
323
  };
324
+ /** Delay before submitting typed CLI input (provider-specific TUI tuning) */
325
+ sendDelayMs?: number;
326
+ /** Submit key used after typing into CLI PTY (default: carriage return) */
327
+ sendKey?: string;
328
+ /** How the CLI adapter decides when to submit typed input */
329
+ submitStrategy?: 'wait_for_echo' | 'immediate';
330
+ /** Keep this provider out of the upstream auto-updated bundle */
331
+ disableUpstream?: boolean;
314
332
  approvalKeys?: Record<number, string>;
315
333
  patterns?: {
316
334
  prompt?: RegExp[];
@@ -376,6 +394,20 @@ export interface ProviderModule {
376
394
  spawnArgBuilder?: (config: Record<string, string>) => string[];
377
395
  /** ACP agent auth methods (multiple supported — in priority order) */
378
396
  auth?: AcpAuthMethod[];
397
+ contractVersion?: number;
398
+ capabilities?: {
399
+ input?: {
400
+ multipart?: boolean;
401
+ mediaTypes?: Array<'text' | 'image' | 'audio' | 'video' | 'resource'>;
402
+ };
403
+ output?: {
404
+ richContent?: boolean;
405
+ mediaTypes?: Array<'text' | 'image' | 'audio' | 'video' | 'resource'>;
406
+ };
407
+ controls?: {
408
+ typedResults?: boolean;
409
+ };
410
+ };
379
411
  }
380
412
  export interface ProviderResumeCapability {
381
413
  supported: boolean;
@@ -549,6 +581,23 @@ export interface ProviderControlOption {
549
581
  description?: string;
550
582
  group?: string;
551
583
  }
584
+ export interface ControlListResult {
585
+ options: ProviderControlOption[];
586
+ currentValue?: string | number | boolean;
587
+ error?: string;
588
+ }
589
+ export interface ControlSetResult {
590
+ ok: boolean;
591
+ currentValue?: string | number | boolean;
592
+ effects?: ProviderEffect[];
593
+ error?: string;
594
+ }
595
+ export interface ControlInvokeResult {
596
+ ok: boolean;
597
+ currentValue?: string | number | boolean;
598
+ effects?: ProviderEffect[];
599
+ error?: string;
600
+ }
552
601
  /**
553
602
  * ProviderControlDef — A single interactive control declared by a provider.
554
603
  *
@@ -1,4 +1,7 @@
1
- import type { ProviderControlDef, ProviderEffect } from './contracts.js';
1
+ import type { ControlInvokeResult, ControlListResult, ControlSetResult, ProviderControlDef, ProviderEffect } from './contracts.js';
2
2
  export type ProviderControlValue = string | number | boolean;
3
3
  export declare function extractProviderControlValues(controls: ProviderControlDef[] | undefined, data: any): Record<string, ProviderControlValue> | undefined;
4
4
  export declare function normalizeProviderEffects(data: any): ProviderEffect[];
5
+ export declare function normalizeControlListResult(data: any): ControlListResult;
6
+ export declare function normalizeControlSetResult(data: any): ControlSetResult;
7
+ export declare function normalizeControlInvokeResult(data: any): ControlInvokeResult;
@@ -0,0 +1,91 @@
1
+ import type { ContentAnnotations } from './contracts.js';
2
+ export type InputPart = TextInputPart | ImageInputPart | AudioInputPart | VideoInputPart | ResourceInputPart;
3
+ export interface TextInputPart {
4
+ type: 'text';
5
+ text: string;
6
+ }
7
+ export interface ImageInputPart {
8
+ type: 'image';
9
+ mimeType: string;
10
+ uri?: string;
11
+ data?: string;
12
+ alt?: string;
13
+ }
14
+ export interface AudioInputPart {
15
+ type: 'audio';
16
+ mimeType: string;
17
+ uri?: string;
18
+ data?: string;
19
+ transcript?: string;
20
+ }
21
+ export interface VideoInputPart {
22
+ type: 'video';
23
+ mimeType: string;
24
+ uri?: string;
25
+ data?: string;
26
+ posterUri?: string;
27
+ }
28
+ export interface ResourceInputPart {
29
+ type: 'resource';
30
+ uri: string;
31
+ mimeType?: string;
32
+ name?: string;
33
+ text?: string;
34
+ data?: string;
35
+ }
36
+ export interface InputEnvelope {
37
+ parts: InputPart[];
38
+ textFallback: string;
39
+ metadata?: {
40
+ source?: 'dashboard' | 'shortcut_api' | 'provider_script' | 'session_replay';
41
+ clientTimestamp?: number;
42
+ };
43
+ }
44
+ export type MessagePart = TextMessagePart | ImageMessagePart | AudioMessagePart | VideoMessagePart | ResourceLinkMessagePart | ResourceMessagePart;
45
+ export interface TextMessagePart {
46
+ type: 'text';
47
+ text: string;
48
+ annotations?: ContentAnnotations;
49
+ }
50
+ export interface ImageMessagePart {
51
+ type: 'image';
52
+ mimeType: string;
53
+ uri?: string;
54
+ data?: string;
55
+ annotations?: ContentAnnotations;
56
+ }
57
+ export interface AudioMessagePart {
58
+ type: 'audio';
59
+ mimeType: string;
60
+ uri?: string;
61
+ data?: string;
62
+ transcript?: string;
63
+ annotations?: ContentAnnotations;
64
+ }
65
+ export interface VideoMessagePart {
66
+ type: 'video';
67
+ mimeType: string;
68
+ uri?: string;
69
+ data?: string;
70
+ posterUri?: string;
71
+ annotations?: ContentAnnotations;
72
+ }
73
+ export interface ResourceLinkMessagePart {
74
+ type: 'resource_link';
75
+ uri: string;
76
+ name: string;
77
+ mimeType?: string;
78
+ size?: number;
79
+ }
80
+ export interface ResourceMessagePart {
81
+ type: 'resource';
82
+ resource: {
83
+ uri: string;
84
+ mimeType?: string | null;
85
+ text?: string;
86
+ blob?: string;
87
+ };
88
+ }
89
+ export declare function normalizeInputEnvelope(input: unknown): InputEnvelope;
90
+ export declare function normalizeMessageParts(content: unknown): MessagePart[];
91
+ export declare function flattenMessageParts(parts: MessagePart[]): string;
@@ -0,0 +1,5 @@
1
+ export interface ProviderValidationResult {
2
+ errors: string[];
3
+ warnings: string[];
4
+ }
5
+ export declare function validateProviderDefinition(raw: unknown): ProviderValidationResult;
@@ -0,0 +1,16 @@
1
+ import type { SessionHostRecord } from '../shared-types.js';
2
+ export type SessionHostSurfaceKind = 'live_runtime' | 'recovery_snapshot' | 'inactive_record';
3
+ export interface SessionHostSurfaceRecordLike {
4
+ lifecycle?: string | null;
5
+ meta?: Record<string, unknown> | null;
6
+ }
7
+ export declare function isSessionHostLiveRuntime(record: SessionHostSurfaceRecordLike | null | undefined): boolean;
8
+ export declare function getSessionHostRecoveryLabel(meta: Record<string, unknown> | null | undefined): string | null;
9
+ export declare function isSessionHostRecoverySnapshot(record: SessionHostSurfaceRecordLike | null | undefined): boolean;
10
+ export declare function getSessionHostSurfaceKind(record: SessionHostSurfaceRecordLike | null | undefined): SessionHostSurfaceKind;
11
+ export declare function partitionSessionHostRecords<T extends SessionHostSurfaceRecordLike>(records: T[]): {
12
+ liveRuntimes: T[];
13
+ recoverySnapshots: T[];
14
+ inactiveRecords: T[];
15
+ };
16
+ export declare function partitionSessionHostDiagnosticsSessions(records: SessionHostRecord[] | null | undefined): ReturnType<typeof partitionSessionHostRecords<SessionHostRecord>>;
@@ -0,0 +1 @@
1
+ export declare function shouldAutoRestoreHostedSessionsOnStartup(env?: NodeJS.ProcessEnv): boolean;
@@ -72,6 +72,7 @@ export interface SessionHostRecord {
72
72
  providerType: string;
73
73
  workspace: string;
74
74
  lifecycle: 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted';
75
+ surfaceKind?: 'live_runtime' | 'recovery_snapshot' | 'inactive_record';
75
76
  writeOwner: SessionHostWriteOwner | null;
76
77
  attachedClients: SessionHostAttachedClient[];
77
78
  osPid?: number;
@@ -110,6 +111,9 @@ export interface SessionHostDiagnosticsSnapshot {
110
111
  endpoint: string;
111
112
  runtimeCount: number;
112
113
  sessions?: SessionHostRecord[];
114
+ liveRuntimes?: SessionHostRecord[];
115
+ recoverySnapshots?: SessionHostRecord[];
116
+ inactiveRecords?: SessionHostRecord[];
113
117
  recentLogs: SessionHostLogEntry[];
114
118
  recentRequests: SessionHostRequestTrace[];
115
119
  recentTransitions: SessionHostRuntimeTransition[];
@@ -344,6 +348,8 @@ export interface ProviderControlSchema {
344
348
  step?: number;
345
349
  /** Sort order */
346
350
  order?: number;
351
+ /** Hide this control even if it would otherwise render */
352
+ hidden?: boolean;
347
353
  }
348
354
  /** Machine hardware/OS info (reported by daemon, displayed by web) */
349
355
  export interface MachineInfo {
package/dist/types.d.ts CHANGED
@@ -21,8 +21,8 @@ export interface StatusResponse extends StatusReportPayload {
21
21
  }
22
22
  export interface ChatMessage {
23
23
  role: string;
24
- /** Plain text (legacy) or rich content blocks (ACP standard) */
25
- content: string | ContentBlock[];
24
+ /** Plain text (legacy) or canonical message parts */
25
+ content: string | MessagePart[];
26
26
  kind?: string;
27
27
  id?: string;
28
28
  index?: number;
@@ -41,7 +41,7 @@ export interface ChatMessage {
41
41
  /** Sender name for shared sessions */
42
42
  senderName?: string;
43
43
  }
44
- import type { ContentBlock, ToolCallInfo } from './providers/contracts.js';
44
+ import type { MessagePart, ToolCallInfo } from './providers/contracts.js';
45
45
  export interface ExtensionInfo {
46
46
  id: string;
47
47
  type: string;
@@ -33,6 +33,7 @@ interface SessionBufferState {
33
33
  scrollbackBytes: number;
34
34
  snapshotSeq: number;
35
35
  }
36
+ type SessionHostSurfaceKind = 'live_runtime' | 'recovery_snapshot' | 'inactive_record';
36
37
  interface SessionHostRecord {
37
38
  sessionId: string;
38
39
  runtimeKey: string;
@@ -48,6 +49,7 @@ interface SessionHostRecord {
48
49
  startedAt?: number;
49
50
  lastActivityAt: number;
50
51
  lifecycle: SessionLifecycle;
52
+ surfaceKind?: SessionHostSurfaceKind;
51
53
  writeOwner: SessionWriteOwner | null;
52
54
  attachedClients: SessionAttachedClient[];
53
55
  buffer: SessionBufferState;
@@ -180,6 +182,9 @@ interface SessionHostDiagnostics {
180
182
  endpoint: string;
181
183
  runtimeCount: number;
182
184
  sessions?: SessionHostRecord[];
185
+ liveRuntimes?: SessionHostRecord[];
186
+ recoverySnapshots?: SessionHostRecord[];
187
+ inactiveRecords?: SessionHostRecord[];
183
188
  recentLogs: SessionHostLogEntry[];
184
189
  recentRequests: SessionHostRequestTrace[];
185
190
  recentTransitions: SessionHostRuntimeTransition[];
@@ -368,6 +373,16 @@ declare class SessionHostRegistry {
368
373
  declare function getWorkspaceLabel(workspace: string): string;
369
374
  declare function buildRuntimeDisplayName(payload: Pick<CreateSessionPayload, 'displayName' | 'providerType' | 'workspace'>): string;
370
375
  declare function buildRuntimeKey(payload: Pick<CreateSessionPayload, 'runtimeKey' | 'displayName' | 'providerType' | 'workspace'>, existingKeys: Iterable<string>): string;
376
+ interface SessionHostSurfaceRecordLike {
377
+ lifecycle?: string | null;
378
+ surfaceKind?: SessionHostSurfaceKind | null;
379
+ meta?: Record<string, unknown> | null;
380
+ }
381
+ declare function isSessionHostLiveRuntime(record: SessionHostSurfaceRecordLike | null | undefined): boolean;
382
+ declare function getSessionHostRecoveryLabel(meta: Record<string, unknown> | null | undefined): string | null;
383
+ declare function isSessionHostRecoverySnapshot(record: SessionHostSurfaceRecordLike | null | undefined): boolean;
384
+ declare function getSessionHostSurfaceKind(record: SessionHostSurfaceRecordLike | null | undefined): SessionHostSurfaceKind;
385
+ declare function resolveAttachableRuntimeRecord(records: SessionHostRecord[], identifier: string): SessionHostRecord;
371
386
  declare function resolveRuntimeRecord(records: SessionHostRecord[], identifier: string): SessionHostRecord;
372
387
  declare function formatRuntimeOwner(record: Pick<SessionHostRecord, 'writeOwner'>): string;
373
388
 
@@ -424,4 +439,4 @@ declare function applyTerminalColorEnv(env: Record<string, string>): void;
424
439
  */
425
440
  declare function ensureNodePtySpawnHelperPermissions(logFn?: (msg: string) => void): void;
426
441
 
427
- export { type AcquireWritePayload, type AttachSessionPayload, type ClearSessionBufferPayload, type CreateSessionPayload, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionClientType, type SessionHostCategory, SessionHostClient, type SessionHostClientOptions, type SessionHostDiagnostics, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTransport, type SessionWriteOwner, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, buildRuntimeDisplayName, buildRuntimeKey, createLineParser, createResponseEnvelope, ensureNodePtySpawnHelperPermissions, formatRuntimeOwner, getDefaultSessionHostEndpoint, getWorkspaceLabel, resolveRuntimeRecord, sanitizeSpawnEnv, writeEnvelope };
442
+ export { type AcquireWritePayload, type AttachSessionPayload, type ClearSessionBufferPayload, type CreateSessionPayload, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionClientType, type SessionHostCategory, SessionHostClient, type SessionHostClientOptions, type SessionHostDiagnostics, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostSurfaceKind, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTransport, type SessionWriteOwner, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, buildRuntimeDisplayName, buildRuntimeKey, createLineParser, createResponseEnvelope, ensureNodePtySpawnHelperPermissions, formatRuntimeOwner, getDefaultSessionHostEndpoint, getSessionHostRecoveryLabel, getSessionHostSurfaceKind, getWorkspaceLabel, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, resolveAttachableRuntimeRecord, resolveRuntimeRecord, sanitizeSpawnEnv, writeEnvelope };
@@ -33,6 +33,7 @@ interface SessionBufferState {
33
33
  scrollbackBytes: number;
34
34
  snapshotSeq: number;
35
35
  }
36
+ type SessionHostSurfaceKind = 'live_runtime' | 'recovery_snapshot' | 'inactive_record';
36
37
  interface SessionHostRecord {
37
38
  sessionId: string;
38
39
  runtimeKey: string;
@@ -48,6 +49,7 @@ interface SessionHostRecord {
48
49
  startedAt?: number;
49
50
  lastActivityAt: number;
50
51
  lifecycle: SessionLifecycle;
52
+ surfaceKind?: SessionHostSurfaceKind;
51
53
  writeOwner: SessionWriteOwner | null;
52
54
  attachedClients: SessionAttachedClient[];
53
55
  buffer: SessionBufferState;
@@ -180,6 +182,9 @@ interface SessionHostDiagnostics {
180
182
  endpoint: string;
181
183
  runtimeCount: number;
182
184
  sessions?: SessionHostRecord[];
185
+ liveRuntimes?: SessionHostRecord[];
186
+ recoverySnapshots?: SessionHostRecord[];
187
+ inactiveRecords?: SessionHostRecord[];
183
188
  recentLogs: SessionHostLogEntry[];
184
189
  recentRequests: SessionHostRequestTrace[];
185
190
  recentTransitions: SessionHostRuntimeTransition[];
@@ -368,6 +373,16 @@ declare class SessionHostRegistry {
368
373
  declare function getWorkspaceLabel(workspace: string): string;
369
374
  declare function buildRuntimeDisplayName(payload: Pick<CreateSessionPayload, 'displayName' | 'providerType' | 'workspace'>): string;
370
375
  declare function buildRuntimeKey(payload: Pick<CreateSessionPayload, 'runtimeKey' | 'displayName' | 'providerType' | 'workspace'>, existingKeys: Iterable<string>): string;
376
+ interface SessionHostSurfaceRecordLike {
377
+ lifecycle?: string | null;
378
+ surfaceKind?: SessionHostSurfaceKind | null;
379
+ meta?: Record<string, unknown> | null;
380
+ }
381
+ declare function isSessionHostLiveRuntime(record: SessionHostSurfaceRecordLike | null | undefined): boolean;
382
+ declare function getSessionHostRecoveryLabel(meta: Record<string, unknown> | null | undefined): string | null;
383
+ declare function isSessionHostRecoverySnapshot(record: SessionHostSurfaceRecordLike | null | undefined): boolean;
384
+ declare function getSessionHostSurfaceKind(record: SessionHostSurfaceRecordLike | null | undefined): SessionHostSurfaceKind;
385
+ declare function resolveAttachableRuntimeRecord(records: SessionHostRecord[], identifier: string): SessionHostRecord;
371
386
  declare function resolveRuntimeRecord(records: SessionHostRecord[], identifier: string): SessionHostRecord;
372
387
  declare function formatRuntimeOwner(record: Pick<SessionHostRecord, 'writeOwner'>): string;
373
388
 
@@ -424,4 +439,4 @@ declare function applyTerminalColorEnv(env: Record<string, string>): void;
424
439
  */
425
440
  declare function ensureNodePtySpawnHelperPermissions(logFn?: (msg: string) => void): void;
426
441
 
427
- export { type AcquireWritePayload, type AttachSessionPayload, type ClearSessionBufferPayload, type CreateSessionPayload, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionClientType, type SessionHostCategory, SessionHostClient, type SessionHostClientOptions, type SessionHostDiagnostics, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTransport, type SessionWriteOwner, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, buildRuntimeDisplayName, buildRuntimeKey, createLineParser, createResponseEnvelope, ensureNodePtySpawnHelperPermissions, formatRuntimeOwner, getDefaultSessionHostEndpoint, getWorkspaceLabel, resolveRuntimeRecord, sanitizeSpawnEnv, writeEnvelope };
442
+ export { type AcquireWritePayload, type AttachSessionPayload, type ClearSessionBufferPayload, type CreateSessionPayload, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionClientType, type SessionHostCategory, SessionHostClient, type SessionHostClientOptions, type SessionHostDiagnostics, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostSurfaceKind, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTransport, type SessionWriteOwner, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, buildRuntimeDisplayName, buildRuntimeKey, createLineParser, createResponseEnvelope, ensureNodePtySpawnHelperPermissions, formatRuntimeOwner, getDefaultSessionHostEndpoint, getSessionHostRecoveryLabel, getSessionHostSurfaceKind, getWorkspaceLabel, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, resolveAttachableRuntimeRecord, resolveRuntimeRecord, sanitizeSpawnEnv, writeEnvelope };
@@ -41,7 +41,12 @@ __export(index_exports, {
41
41
  ensureNodePtySpawnHelperPermissions: () => ensureNodePtySpawnHelperPermissions,
42
42
  formatRuntimeOwner: () => formatRuntimeOwner,
43
43
  getDefaultSessionHostEndpoint: () => getDefaultSessionHostEndpoint,
44
+ getSessionHostRecoveryLabel: () => getSessionHostRecoveryLabel,
45
+ getSessionHostSurfaceKind: () => getSessionHostSurfaceKind,
44
46
  getWorkspaceLabel: () => getWorkspaceLabel,
47
+ isSessionHostLiveRuntime: () => isSessionHostLiveRuntime,
48
+ isSessionHostRecoverySnapshot: () => isSessionHostRecoverySnapshot,
49
+ resolveAttachableRuntimeRecord: () => resolveAttachableRuntimeRecord,
45
50
  resolveRuntimeRecord: () => resolveRuntimeRecord,
46
51
  sanitizeSpawnEnv: () => sanitizeSpawnEnv,
47
52
  writeEnvelope: () => writeEnvelope
@@ -149,6 +154,55 @@ function buildRuntimeKey(payload, existingKeys) {
149
154
  }
150
155
  return candidate;
151
156
  }
157
+ var LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
158
+ function isSessionHostLiveRuntime(record) {
159
+ if (!record) return false;
160
+ if (record.surfaceKind === "live_runtime") return true;
161
+ if (record.surfaceKind === "recovery_snapshot" || record.surfaceKind === "inactive_record") return false;
162
+ const lifecycle = String(record.lifecycle || "").trim();
163
+ return LIVE_LIFECYCLES.has(lifecycle);
164
+ }
165
+ function getSessionHostRecoveryLabel(meta) {
166
+ const recoveryState = typeof meta?.runtimeRecoveryState === "string" ? String(meta.runtimeRecoveryState).trim() : "";
167
+ if (!recoveryState) return null;
168
+ if (recoveryState === "auto_resumed") return "restored after restart";
169
+ if (recoveryState === "resume_failed") return "restore failed";
170
+ if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
171
+ if (recoveryState === "orphan_snapshot") return "snapshot recovered";
172
+ return recoveryState.replace(/_/g, " ");
173
+ }
174
+ function isSessionHostRecoverySnapshot(record) {
175
+ if (!record) return false;
176
+ if (record.surfaceKind === "recovery_snapshot") return true;
177
+ if (record.surfaceKind === "live_runtime" || record.surfaceKind === "inactive_record") return false;
178
+ if (isSessionHostLiveRuntime(record)) return false;
179
+ const lifecycle = String(record.lifecycle || "").trim();
180
+ if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
181
+ return false;
182
+ }
183
+ const meta = record.meta || void 0;
184
+ if (meta?.restoredFromStorage === true) return true;
185
+ return getSessionHostRecoveryLabel(meta) !== null;
186
+ }
187
+ function getSessionHostSurfaceKind(record) {
188
+ if (record?.surfaceKind === "live_runtime" || record?.surfaceKind === "recovery_snapshot" || record?.surfaceKind === "inactive_record") {
189
+ return record.surfaceKind;
190
+ }
191
+ if (isSessionHostLiveRuntime(record)) return "live_runtime";
192
+ if (isSessionHostRecoverySnapshot(record)) return "recovery_snapshot";
193
+ return "inactive_record";
194
+ }
195
+ function resolveAttachableRuntimeRecord(records, identifier) {
196
+ const record = resolveRuntimeRecord(records, identifier);
197
+ const surfaceKind = getSessionHostSurfaceKind(record);
198
+ if (surfaceKind === "live_runtime") {
199
+ return record;
200
+ }
201
+ if (surfaceKind === "recovery_snapshot") {
202
+ throw new Error(`Runtime ${record.runtimeKey} is a recovery snapshot, not a live attach target. Resume or recover it first.`);
203
+ }
204
+ throw new Error(`Runtime ${record.runtimeKey} is ${record.lifecycle}, not a live attach target.`);
205
+ }
152
206
  function uniqueMatch(records, predicate) {
153
207
  const matches = records.filter(predicate);
154
208
  if (matches.length === 1) return matches[0] || null;
@@ -609,7 +663,12 @@ function ensureNodePtySpawnHelperPermissions(logFn) {
609
663
  ensureNodePtySpawnHelperPermissions,
610
664
  formatRuntimeOwner,
611
665
  getDefaultSessionHostEndpoint,
666
+ getSessionHostRecoveryLabel,
667
+ getSessionHostSurfaceKind,
612
668
  getWorkspaceLabel,
669
+ isSessionHostLiveRuntime,
670
+ isSessionHostRecoverySnapshot,
671
+ resolveAttachableRuntimeRecord,
613
672
  resolveRuntimeRecord,
614
673
  sanitizeSpawnEnv,
615
674
  writeEnvelope