@adhdev/daemon-core 0.9.82-rc.450 → 0.9.82-rc.451

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.
@@ -1,16 +1,10 @@
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>>;
1
+ /**
2
+ * Session-host runtime-surface helpers.
3
+ *
4
+ * These classification helpers (live_runtime / recovery_snapshot / inactive_record)
5
+ * are owned by @adhdev/session-host-core as the single source of truth. daemon-core
6
+ * re-exports them so consumers can keep importing from this path while the behavior
7
+ * (including the `record.surfaceKind` short-circuit) stays identical across packages.
8
+ */
9
+ export { getSessionHostRecoveryLabel, getSessionHostSurfaceKind, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, partitionSessionHostDiagnosticsSessions, partitionSessionHostRecords, } from '@adhdev/session-host-core';
10
+ export type { SessionHostSurfaceKind, SessionHostSurfaceRecordLike, } from '@adhdev/session-host-core';
@@ -7,6 +7,7 @@
7
7
  * IMPORTANT: This file must remain runtime-free (types only).
8
8
  */
9
9
  import type { StatusResponse, ChatMessage, ExtensionInfo, SystemInfo, DetectedIde, AgentEntry } from './types.js';
10
+ import type { SessionAttachedClient as CoreSessionAttachedClient, SessionWriteOwner as CoreSessionWriteOwner, SessionHostRecord as CoreSessionHostRecord, SessionHostLogEntry as CoreSessionHostLogEntry, SessionHostRequestTrace as CoreSessionHostRequestTrace, SessionHostRuntimeTransition as CoreSessionHostRuntimeTransition, SessionHostDiagnostics as CoreSessionHostDiagnostics } from '@adhdev/session-host-core';
10
11
  export type { StatusResponse, ChatMessage, ExtensionInfo, SystemInfo, DetectedIde, AgentEntry, };
11
12
  export type { ProviderState, ProviderStatus, ActiveChatData, IdeProviderState, CliProviderState, AcpProviderState, ExtensionProviderState, ProviderEvent, } from './providers/provider-instance.js';
12
13
  export type { ProviderErrorReason } from './providers/provider-instance.js';
@@ -70,64 +71,37 @@ export interface ProviderSummaryItem {
70
71
  export interface ProviderSummaryMetadata {
71
72
  items: ProviderSummaryItem[];
72
73
  }
73
- export interface SessionHostAttachedClient {
74
- clientId: string;
74
+ /**
75
+ * Wire-subset session-host types.
76
+ *
77
+ * These are the shapes daemon-core / web-core see over the wire — a subset of the
78
+ * authoritative types owned by @adhdev/session-host-core (which additionally carry
79
+ * transport / category / launchCommand / buffer and stricter union typing on wire
80
+ * scalars). They are DERIVED from the SSOT via Pick/Omit so shared fields cannot
81
+ * drift; only the deliberate wire looseness (string-typed `type`/`lifecycle`,
82
+ * optional `meta`) is re-applied here.
83
+ */
84
+ export type SessionHostAttachedClient = Omit<CoreSessionAttachedClient, 'type'> & {
85
+ /** Widened over the wire — the raw client-type string is not re-validated here. */
75
86
  type: string;
76
- readOnly: boolean;
77
- attachedAt: number;
78
- lastSeenAt: number;
79
- }
80
- export interface SessionHostWriteOwner {
81
- clientId: string;
82
- ownerType: 'agent' | 'user';
83
- acquiredAt: number;
84
- }
85
- export interface SessionHostRecord {
86
- sessionId: string;
87
- runtimeKey: string;
88
- displayName: string;
89
- workspaceLabel: string;
90
- providerType: string;
91
- workspace: string;
92
- lifecycle: 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted';
93
- surfaceKind?: 'live_runtime' | 'recovery_snapshot' | 'inactive_record';
87
+ };
88
+ export type SessionHostWriteOwner = CoreSessionWriteOwner;
89
+ export type SessionHostRecord = Pick<CoreSessionHostRecord, 'sessionId' | 'runtimeKey' | 'displayName' | 'workspaceLabel' | 'providerType' | 'workspace' | 'lifecycle' | 'surfaceKind' | 'osPid' | 'lastActivityAt' | 'createdAt' | 'startedAt'> & {
94
90
  writeOwner: SessionHostWriteOwner | null;
95
91
  attachedClients: SessionHostAttachedClient[];
96
- osPid?: number;
97
- lastActivityAt: number;
98
- createdAt: number;
99
- startedAt?: number;
92
+ /** Optional over the wire — omitted when the record carries no metadata. */
100
93
  meta?: Record<string, unknown>;
101
- }
102
- export interface SessionHostLogEntry {
103
- timestamp: number;
104
- level: 'debug' | 'info' | 'warn' | 'error';
105
- message: string;
106
- sessionId?: string;
107
- }
108
- export interface SessionHostRequestTrace {
109
- timestamp: number;
110
- requestId: string;
94
+ };
95
+ export type SessionHostLogEntry = Omit<CoreSessionHostLogEntry, 'data'>;
96
+ export type SessionHostRequestTrace = Omit<CoreSessionHostRequestTrace, 'type'> & {
97
+ /** Widened over the wire the request-type union is not re-validated here. */
111
98
  type: string;
112
- sessionId?: string;
113
- clientId?: string;
114
- success: boolean;
115
- durationMs: number;
116
- error?: string;
117
- }
118
- export interface SessionHostRuntimeTransition {
119
- timestamp: number;
120
- sessionId: string;
121
- action: string;
99
+ };
100
+ export type SessionHostRuntimeTransition = Omit<CoreSessionHostRuntimeTransition, 'lifecycle'> & {
101
+ /** Widened over the wire — the lifecycle union is not re-validated here. */
122
102
  lifecycle?: string;
123
- detail?: string;
124
- success?: boolean;
125
- error?: string;
126
- }
127
- export interface SessionHostDiagnosticsSnapshot {
128
- hostStartedAt: number;
129
- endpoint: string;
130
- runtimeCount: number;
103
+ };
104
+ export type SessionHostDiagnosticsSnapshot = Omit<CoreSessionHostDiagnostics, 'supportedRequestTypes' | 'sessions' | 'liveRuntimes' | 'recoverySnapshots' | 'inactiveRecords' | 'recentLogs' | 'recentRequests' | 'recentTransitions'> & {
131
105
  sessions?: SessionHostRecord[];
132
106
  liveRuntimes?: SessionHostRecord[];
133
107
  recoverySnapshots?: SessionHostRecord[];
@@ -135,7 +109,7 @@ export interface SessionHostDiagnosticsSnapshot {
135
109
  recentLogs: SessionHostLogEntry[];
136
110
  recentRequests: SessionHostRequestTrace[];
137
111
  recentTransitions: SessionHostRuntimeTransition[];
138
- }
112
+ };
139
113
  export type TransportTopic = 'session.chat_tail' | 'session.runtime_output' | 'machine.runtime' | 'session_host.diagnostics' | 'session.modal' | 'daemon.metadata' | 'workspace.git';
140
114
  export interface SessionChatTailSubscriptionParams extends ReadChatCursor {
141
115
  targetSessionId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.450",
3
+ "version": "0.9.82-rc.451",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -46,7 +46,7 @@
46
46
  "author": "vilmire",
47
47
  "license": "AGPL-3.0-or-later",
48
48
  "dependencies": {
49
- "@adhdev/mesh-shared": "0.9.82-rc.450",
49
+ "@adhdev/mesh-shared": "0.9.82-rc.451",
50
50
  "@adhdev/session-host-core": "*",
51
51
  "@agentclientprotocol/sdk": "^0.16.1",
52
52
  "ajv": "^8.20.0",
@@ -1,80 +1,20 @@
1
- import type { SessionHostRecord } from '../shared-types.js';
2
-
3
- export type SessionHostSurfaceKind = 'live_runtime' | 'recovery_snapshot' | 'inactive_record';
4
-
5
- export interface SessionHostSurfaceRecordLike {
6
- lifecycle?: string | null;
7
- meta?: Record<string, unknown> | null;
8
- }
9
-
10
- const LIVE_LIFECYCLES = new Set(['starting', 'running', 'stopping', 'interrupted']);
11
-
12
- export function isSessionHostLiveRuntime(record: SessionHostSurfaceRecordLike | null | undefined): boolean {
13
- const lifecycle = String(record?.lifecycle || '').trim();
14
- return LIVE_LIFECYCLES.has(lifecycle);
15
- }
16
-
17
- export function getSessionHostRecoveryLabel(meta: Record<string, unknown> | null | undefined): string | null {
18
- const recoveryState = typeof meta?.runtimeRecoveryState === 'string'
19
- ? String(meta.runtimeRecoveryState).trim()
20
- : '';
21
- if (!recoveryState) return null;
22
- if (recoveryState === 'auto_resumed') return 'restored after restart';
23
- if (recoveryState === 'resume_failed') return 'restore failed';
24
- if (recoveryState === 'host_restart_interrupted') return 'host restart interrupted';
25
- if (recoveryState === 'orphan_snapshot') return 'snapshot recovered';
26
- return recoveryState.replace(/_/g, ' ');
27
- }
28
-
29
- export function isSessionHostRecoverySnapshot(record: SessionHostSurfaceRecordLike | null | undefined): boolean {
30
- if (!record) return false;
31
- if (isSessionHostLiveRuntime(record)) return false;
32
-
33
- const lifecycle = String(record.lifecycle || '').trim();
34
- if (lifecycle && lifecycle !== 'stopped' && lifecycle !== 'failed') {
35
- return false;
36
- }
37
-
38
- const meta = record.meta || undefined;
39
- if (meta?.restoredFromStorage === true) return true;
40
- return getSessionHostRecoveryLabel(meta) !== null;
41
- }
42
-
43
- export function getSessionHostSurfaceKind(record: SessionHostSurfaceRecordLike | null | undefined): SessionHostSurfaceKind {
44
- if (isSessionHostLiveRuntime(record)) return 'live_runtime';
45
- if (isSessionHostRecoverySnapshot(record)) return 'recovery_snapshot';
46
- return 'inactive_record';
47
- }
48
-
49
- export function partitionSessionHostRecords<T extends SessionHostSurfaceRecordLike>(records: T[]): {
50
- liveRuntimes: T[];
51
- recoverySnapshots: T[];
52
- inactiveRecords: T[];
53
- } {
54
- const liveRuntimes: T[] = [];
55
- const recoverySnapshots: T[] = [];
56
- const inactiveRecords: T[] = [];
57
-
58
- for (const record of records) {
59
- const kind = getSessionHostSurfaceKind(record);
60
- if (kind === 'live_runtime') {
61
- liveRuntimes.push(record);
62
- } else if (kind === 'recovery_snapshot') {
63
- recoverySnapshots.push(record);
64
- } else {
65
- inactiveRecords.push(record);
66
- }
67
- }
68
-
69
- return {
70
- liveRuntimes,
71
- recoverySnapshots,
72
- inactiveRecords,
73
- };
74
- }
75
-
76
- export function partitionSessionHostDiagnosticsSessions(
77
- records: SessionHostRecord[] | null | undefined,
78
- ): ReturnType<typeof partitionSessionHostRecords<SessionHostRecord>> {
79
- return partitionSessionHostRecords(records || []);
80
- }
1
+ /**
2
+ * Session-host runtime-surface helpers.
3
+ *
4
+ * These classification helpers (live_runtime / recovery_snapshot / inactive_record)
5
+ * are owned by @adhdev/session-host-core as the single source of truth. daemon-core
6
+ * re-exports them so consumers can keep importing from this path while the behavior
7
+ * (including the `record.surfaceKind` short-circuit) stays identical across packages.
8
+ */
9
+ export {
10
+ getSessionHostRecoveryLabel,
11
+ getSessionHostSurfaceKind,
12
+ isSessionHostLiveRuntime,
13
+ isSessionHostRecoverySnapshot,
14
+ partitionSessionHostDiagnosticsSessions,
15
+ partitionSessionHostRecords,
16
+ } from '@adhdev/session-host-core';
17
+ export type {
18
+ SessionHostSurfaceKind,
19
+ SessionHostSurfaceRecordLike,
20
+ } from '@adhdev/session-host-core';
@@ -15,6 +15,15 @@ import type {
15
15
  DetectedIde,
16
16
  AgentEntry,
17
17
  } from './types.js';
18
+ import type {
19
+ SessionAttachedClient as CoreSessionAttachedClient,
20
+ SessionWriteOwner as CoreSessionWriteOwner,
21
+ SessionHostRecord as CoreSessionHostRecord,
22
+ SessionHostLogEntry as CoreSessionHostLogEntry,
23
+ SessionHostRequestTrace as CoreSessionHostRequestTrace,
24
+ SessionHostRuntimeTransition as CoreSessionHostRuntimeTransition,
25
+ SessionHostDiagnostics as CoreSessionHostDiagnostics,
26
+ } from '@adhdev/session-host-core';
18
27
 
19
28
  export type {
20
29
  StatusResponse,
@@ -134,70 +143,67 @@ export interface ProviderSummaryMetadata {
134
143
  items: ProviderSummaryItem[];
135
144
  }
136
145
 
137
- export interface SessionHostAttachedClient {
138
- clientId: string;
146
+ /**
147
+ * Wire-subset session-host types.
148
+ *
149
+ * These are the shapes daemon-core / web-core see over the wire — a subset of the
150
+ * authoritative types owned by @adhdev/session-host-core (which additionally carry
151
+ * transport / category / launchCommand / buffer and stricter union typing on wire
152
+ * scalars). They are DERIVED from the SSOT via Pick/Omit so shared fields cannot
153
+ * drift; only the deliberate wire looseness (string-typed `type`/`lifecycle`,
154
+ * optional `meta`) is re-applied here.
155
+ */
156
+ export type SessionHostAttachedClient = Omit<CoreSessionAttachedClient, 'type'> & {
157
+ /** Widened over the wire — the raw client-type string is not re-validated here. */
139
158
  type: string;
140
- readOnly: boolean;
141
- attachedAt: number;
142
- lastSeenAt: number;
143
- }
144
-
145
- export interface SessionHostWriteOwner {
146
- clientId: string;
147
- ownerType: 'agent' | 'user';
148
- acquiredAt: number;
149
- }
159
+ };
150
160
 
151
- export interface SessionHostRecord {
152
- sessionId: string;
153
- runtimeKey: string;
154
- displayName: string;
155
- workspaceLabel: string;
156
- providerType: string;
157
- workspace: string;
158
- lifecycle: 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted';
159
- surfaceKind?: 'live_runtime' | 'recovery_snapshot' | 'inactive_record';
161
+ export type SessionHostWriteOwner = CoreSessionWriteOwner;
162
+
163
+ export type SessionHostRecord = Pick<
164
+ CoreSessionHostRecord,
165
+ | 'sessionId'
166
+ | 'runtimeKey'
167
+ | 'displayName'
168
+ | 'workspaceLabel'
169
+ | 'providerType'
170
+ | 'workspace'
171
+ | 'lifecycle'
172
+ | 'surfaceKind'
173
+ | 'osPid'
174
+ | 'lastActivityAt'
175
+ | 'createdAt'
176
+ | 'startedAt'
177
+ > & {
160
178
  writeOwner: SessionHostWriteOwner | null;
161
179
  attachedClients: SessionHostAttachedClient[];
162
- osPid?: number;
163
- lastActivityAt: number;
164
- createdAt: number;
165
- startedAt?: number;
180
+ /** Optional over the wire — omitted when the record carries no metadata. */
166
181
  meta?: Record<string, unknown>;
167
- }
182
+ };
168
183
 
169
- export interface SessionHostLogEntry {
170
- timestamp: number;
171
- level: 'debug' | 'info' | 'warn' | 'error';
172
- message: string;
173
- sessionId?: string;
174
- }
184
+ export type SessionHostLogEntry = Omit<CoreSessionHostLogEntry, 'data'>;
175
185
 
176
- export interface SessionHostRequestTrace {
177
- timestamp: number;
178
- requestId: string;
186
+ export type SessionHostRequestTrace = Omit<CoreSessionHostRequestTrace, 'type'> & {
187
+ /** Widened over the wire — the request-type union is not re-validated here. */
179
188
  type: string;
180
- sessionId?: string;
181
- clientId?: string;
182
- success: boolean;
183
- durationMs: number;
184
- error?: string;
185
- }
189
+ };
186
190
 
187
- export interface SessionHostRuntimeTransition {
188
- timestamp: number;
189
- sessionId: string;
190
- action: string;
191
+ export type SessionHostRuntimeTransition = Omit<CoreSessionHostRuntimeTransition, 'lifecycle'> & {
192
+ /** Widened over the wire — the lifecycle union is not re-validated here. */
191
193
  lifecycle?: string;
192
- detail?: string;
193
- success?: boolean;
194
- error?: string;
195
- }
194
+ };
196
195
 
197
- export interface SessionHostDiagnosticsSnapshot {
198
- hostStartedAt: number;
199
- endpoint: string;
200
- runtimeCount: number;
196
+ export type SessionHostDiagnosticsSnapshot = Omit<
197
+ CoreSessionHostDiagnostics,
198
+ | 'supportedRequestTypes'
199
+ | 'sessions'
200
+ | 'liveRuntimes'
201
+ | 'recoverySnapshots'
202
+ | 'inactiveRecords'
203
+ | 'recentLogs'
204
+ | 'recentRequests'
205
+ | 'recentTransitions'
206
+ > & {
201
207
  sessions?: SessionHostRecord[];
202
208
  liveRuntimes?: SessionHostRecord[];
203
209
  recoverySnapshots?: SessionHostRecord[];
@@ -205,7 +211,7 @@ export interface SessionHostDiagnosticsSnapshot {
205
211
  recentLogs: SessionHostLogEntry[];
206
212
  recentRequests: SessionHostRequestTrace[];
207
213
  recentTransitions: SessionHostRuntimeTransition[];
208
- }
214
+ };
209
215
 
210
216
  export type TransportTopic = 'session.chat_tail' | 'session.runtime_output' | 'machine.runtime' | 'session_host.diagnostics' | 'session.modal' | 'daemon.metadata' | 'workspace.git';
211
217