adhdev 0.8.50 → 0.8.52

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 (41) hide show
  1. package/dist/cli/index.js +30 -5
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/index.js +30 -5
  4. package/dist/index.js.map +1 -1
  5. package/package.json +3 -2
  6. package/vendor/terminal-mux-cli/index.d.mts +1 -0
  7. package/vendor/terminal-mux-cli/index.d.ts +1 -0
  8. package/vendor/terminal-mux-cli/index.js +2056 -0
  9. package/vendor/terminal-mux-cli/index.mjs +2048 -0
  10. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.d.mts +427 -0
  11. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.d.ts +427 -0
  12. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.js +617 -0
  13. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.js.map +1 -0
  14. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.mjs +573 -0
  15. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.mjs.map +1 -0
  16. package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/package.json +7 -0
  17. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.d.mts +16 -0
  18. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.d.ts +16 -0
  19. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.js +206 -0
  20. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.mjs +17 -0
  21. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/chunk-7RNMRPVZ.mjs +183 -0
  22. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/chunk-R4EFW6W3.mjs +46 -0
  23. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/chunk-XZWWVN5W.mjs +164 -0
  24. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.d.mts +35 -0
  25. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.d.ts +35 -0
  26. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.js +219 -0
  27. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.mjs +13 -0
  28. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.d.mts +5 -0
  29. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.d.ts +5 -0
  30. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.js +427 -0
  31. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.mjs +34 -0
  32. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/package.json +33 -0
  33. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.d.mts +49 -0
  34. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.d.ts +49 -0
  35. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.js +222 -0
  36. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.mjs +16 -0
  37. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.d.mts +162 -0
  38. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.d.ts +162 -0
  39. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.js +985 -0
  40. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.mjs +948 -0
  41. package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/package.json +7 -0
@@ -0,0 +1,427 @@
1
+ import * as net from 'net';
2
+
3
+ type SessionTransport = 'pty';
4
+ type SessionHostCategory = 'cli' | 'acp' | 'shell';
5
+ type SessionLifecycle = 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted';
6
+ type SessionClientType = 'daemon' | 'web' | 'local-terminal';
7
+ type SessionOwnerType = 'agent' | 'user';
8
+ interface SessionLaunchCommand {
9
+ command: string;
10
+ args: string[];
11
+ env?: Record<string, string>;
12
+ }
13
+ interface SessionWriteOwner {
14
+ clientId: string;
15
+ ownerType: SessionOwnerType;
16
+ acquiredAt: number;
17
+ }
18
+ interface SessionAttachedClient {
19
+ clientId: string;
20
+ type: SessionClientType;
21
+ readOnly: boolean;
22
+ attachedAt: number;
23
+ lastSeenAt: number;
24
+ }
25
+ interface SessionBufferSnapshot {
26
+ seq: number;
27
+ text: string;
28
+ truncated: boolean;
29
+ cols?: number;
30
+ rows?: number;
31
+ }
32
+ interface SessionBufferState {
33
+ scrollbackBytes: number;
34
+ snapshotSeq: number;
35
+ }
36
+ interface SessionHostRecord {
37
+ sessionId: string;
38
+ runtimeKey: string;
39
+ displayName: string;
40
+ workspaceLabel: string;
41
+ transport: SessionTransport;
42
+ providerType: string;
43
+ category: SessionHostCategory;
44
+ workspace: string;
45
+ launchCommand: SessionLaunchCommand;
46
+ osPid?: number;
47
+ createdAt: number;
48
+ startedAt?: number;
49
+ lastActivityAt: number;
50
+ lifecycle: SessionLifecycle;
51
+ writeOwner: SessionWriteOwner | null;
52
+ attachedClients: SessionAttachedClient[];
53
+ buffer: SessionBufferState;
54
+ meta: Record<string, unknown>;
55
+ }
56
+ interface CreateSessionPayload {
57
+ sessionId?: string;
58
+ runtimeKey?: string;
59
+ displayName?: string;
60
+ providerType: string;
61
+ category: SessionHostCategory;
62
+ workspace: string;
63
+ launchCommand: SessionLaunchCommand;
64
+ cols?: number;
65
+ rows?: number;
66
+ clientId?: string;
67
+ clientType?: SessionClientType;
68
+ meta?: Record<string, unknown>;
69
+ }
70
+ interface AttachSessionPayload {
71
+ sessionId: string;
72
+ clientId: string;
73
+ clientType: SessionClientType;
74
+ readOnly?: boolean;
75
+ }
76
+ interface DetachSessionPayload {
77
+ sessionId: string;
78
+ clientId: string;
79
+ }
80
+ interface SendInputPayload {
81
+ sessionId: string;
82
+ clientId: string;
83
+ data: string;
84
+ }
85
+ interface ResizeSessionPayload {
86
+ sessionId: string;
87
+ cols: number;
88
+ rows: number;
89
+ }
90
+ interface StopSessionPayload {
91
+ sessionId: string;
92
+ }
93
+ interface ResumeSessionPayload {
94
+ sessionId: string;
95
+ }
96
+ interface AcquireWritePayload {
97
+ sessionId: string;
98
+ clientId: string;
99
+ ownerType: SessionOwnerType;
100
+ force?: boolean;
101
+ }
102
+ interface ReleaseWritePayload {
103
+ sessionId: string;
104
+ clientId: string;
105
+ }
106
+ interface GetSnapshotPayload {
107
+ sessionId: string;
108
+ sinceSeq?: number;
109
+ }
110
+ interface ClearSessionBufferPayload {
111
+ sessionId: string;
112
+ }
113
+ interface UpdateSessionMetaPayload {
114
+ sessionId: string;
115
+ meta: Record<string, unknown>;
116
+ replace?: boolean;
117
+ }
118
+ interface GetHostDiagnosticsPayload {
119
+ includeSessions?: boolean;
120
+ limit?: number;
121
+ }
122
+ interface ForceDetachClientPayload {
123
+ sessionId: string;
124
+ clientId: string;
125
+ }
126
+ interface SendSignalPayload {
127
+ sessionId: string;
128
+ signal: string;
129
+ }
130
+ interface RestartSessionPayload {
131
+ sessionId: string;
132
+ }
133
+ interface PruneDuplicateSessionsPayload {
134
+ providerType?: string;
135
+ workspace?: string;
136
+ dryRun?: boolean;
137
+ }
138
+ interface SessionHostDuplicateSessionGroup {
139
+ bindingKey: string;
140
+ providerType: string;
141
+ workspace: string;
142
+ providerSessionId: string;
143
+ keptSessionId: string;
144
+ prunedSessionIds: string[];
145
+ }
146
+ interface SessionHostPruneDuplicatesResult {
147
+ duplicateGroupCount: number;
148
+ keptSessionIds: string[];
149
+ prunedSessionIds: string[];
150
+ groups: SessionHostDuplicateSessionGroup[];
151
+ }
152
+ interface SessionHostLogEntry {
153
+ timestamp: number;
154
+ level: 'debug' | 'info' | 'warn' | 'error';
155
+ message: string;
156
+ sessionId?: string;
157
+ data?: Record<string, unknown>;
158
+ }
159
+ interface SessionHostRequestTrace {
160
+ timestamp: number;
161
+ requestId: string;
162
+ type: SessionHostRequest['type'];
163
+ sessionId?: string;
164
+ clientId?: string;
165
+ success: boolean;
166
+ durationMs: number;
167
+ error?: string;
168
+ }
169
+ interface SessionHostRuntimeTransition {
170
+ timestamp: number;
171
+ sessionId: string;
172
+ action: string;
173
+ lifecycle?: SessionLifecycle;
174
+ detail?: string;
175
+ success?: boolean;
176
+ error?: string;
177
+ }
178
+ interface SessionHostDiagnostics {
179
+ hostStartedAt: number;
180
+ endpoint: string;
181
+ runtimeCount: number;
182
+ sessions?: SessionHostRecord[];
183
+ recentLogs: SessionHostLogEntry[];
184
+ recentRequests: SessionHostRequestTrace[];
185
+ recentTransitions: SessionHostRuntimeTransition[];
186
+ }
187
+ type SessionHostRequest = {
188
+ type: 'create_session';
189
+ payload: CreateSessionPayload;
190
+ } | {
191
+ type: 'attach_session';
192
+ payload: AttachSessionPayload;
193
+ } | {
194
+ type: 'detach_session';
195
+ payload: DetachSessionPayload;
196
+ } | {
197
+ type: 'send_input';
198
+ payload: SendInputPayload;
199
+ } | {
200
+ type: 'resize_session';
201
+ payload: ResizeSessionPayload;
202
+ } | {
203
+ type: 'stop_session';
204
+ payload: StopSessionPayload;
205
+ } | {
206
+ type: 'resume_session';
207
+ payload: ResumeSessionPayload;
208
+ } | {
209
+ type: 'acquire_write';
210
+ payload: AcquireWritePayload;
211
+ } | {
212
+ type: 'release_write';
213
+ payload: ReleaseWritePayload;
214
+ } | {
215
+ type: 'get_snapshot';
216
+ payload: GetSnapshotPayload;
217
+ } | {
218
+ type: 'clear_session_buffer';
219
+ payload: ClearSessionBufferPayload;
220
+ } | {
221
+ type: 'update_session_meta';
222
+ payload: UpdateSessionMetaPayload;
223
+ } | {
224
+ type: 'get_host_diagnostics';
225
+ payload?: GetHostDiagnosticsPayload;
226
+ } | {
227
+ type: 'force_detach_client';
228
+ payload: ForceDetachClientPayload;
229
+ } | {
230
+ type: 'send_signal';
231
+ payload: SendSignalPayload;
232
+ } | {
233
+ type: 'restart_session';
234
+ payload: RestartSessionPayload;
235
+ } | {
236
+ type: 'prune_duplicate_sessions';
237
+ payload?: PruneDuplicateSessionsPayload;
238
+ } | {
239
+ type: 'list_sessions';
240
+ payload?: {};
241
+ };
242
+ interface SessionHostResponse<T = unknown> {
243
+ success: boolean;
244
+ result?: T;
245
+ error?: string;
246
+ }
247
+ type SessionHostEvent = {
248
+ type: 'session_created';
249
+ sessionId: string;
250
+ record: SessionHostRecord;
251
+ } | {
252
+ type: 'session_started';
253
+ sessionId: string;
254
+ pid?: number;
255
+ } | {
256
+ type: 'session_resumed';
257
+ sessionId: string;
258
+ pid?: number;
259
+ } | {
260
+ type: 'session_output';
261
+ sessionId: string;
262
+ seq: number;
263
+ data: string;
264
+ } | {
265
+ type: 'session_cleared';
266
+ sessionId: string;
267
+ } | {
268
+ type: 'session_exit';
269
+ sessionId: string;
270
+ exitCode: number | null;
271
+ } | {
272
+ type: 'session_stopped';
273
+ sessionId: string;
274
+ } | {
275
+ type: 'session_resized';
276
+ sessionId: string;
277
+ cols: number;
278
+ rows: number;
279
+ } | {
280
+ type: 'write_owner_changed';
281
+ sessionId: string;
282
+ owner: SessionWriteOwner | null;
283
+ } | {
284
+ type: 'client_attached';
285
+ sessionId: string;
286
+ client: SessionAttachedClient;
287
+ } | {
288
+ type: 'client_detached';
289
+ sessionId: string;
290
+ clientId: string;
291
+ } | {
292
+ type: 'host_log';
293
+ entry: SessionHostLogEntry;
294
+ } | {
295
+ type: 'request_trace';
296
+ trace: SessionHostRequestTrace;
297
+ } | {
298
+ type: 'runtime_transition';
299
+ transition: SessionHostRuntimeTransition;
300
+ };
301
+ interface SessionHostRequestEnvelope {
302
+ kind: 'request';
303
+ requestId: string;
304
+ request: SessionHostRequest;
305
+ }
306
+ interface SessionHostResponseEnvelope {
307
+ kind: 'response';
308
+ requestId: string;
309
+ response: SessionHostResponse;
310
+ }
311
+ interface SessionHostEventEnvelope {
312
+ kind: 'event';
313
+ event: SessionHostEvent;
314
+ }
315
+ type SessionHostWireEnvelope = SessionHostRequestEnvelope | SessionHostResponseEnvelope | SessionHostEventEnvelope;
316
+
317
+ interface SessionRingBufferOptions {
318
+ maxBytes?: number;
319
+ }
320
+ declare class SessionRingBuffer {
321
+ private maxBytes;
322
+ private chunks;
323
+ private nextSeq;
324
+ private totalBytes;
325
+ constructor(options?: SessionRingBufferOptions);
326
+ append(data: string): number;
327
+ snapshot(sinceSeq?: number): SessionBufferSnapshot;
328
+ getState(): {
329
+ scrollbackBytes: number;
330
+ snapshotSeq: number;
331
+ };
332
+ clear(): void;
333
+ restore(snapshot: {
334
+ seq: number;
335
+ text: string;
336
+ }): void;
337
+ private trim;
338
+ }
339
+
340
+ declare class SessionHostRegistry {
341
+ private sessions;
342
+ createSession(payload: CreateSessionPayload): SessionHostRecord;
343
+ restoreSession(record: SessionHostRecord, snapshot?: {
344
+ seq: number;
345
+ text: string;
346
+ } | null): SessionHostRecord;
347
+ listSessions(): SessionHostRecord[];
348
+ getSession(sessionId: string): SessionHostRecord | null;
349
+ attachClient(payload: AttachSessionPayload): SessionHostRecord;
350
+ detachClient(payload: DetachSessionPayload): SessionHostRecord;
351
+ acquireWrite(payload: AcquireWritePayload): SessionHostRecord;
352
+ releaseWrite(payload: ReleaseWritePayload): SessionHostRecord;
353
+ appendOutput(sessionId: string, data: string): {
354
+ record: SessionHostRecord;
355
+ seq: number;
356
+ };
357
+ getSnapshot(sessionId: string, sinceSeq?: number): SessionBufferSnapshot;
358
+ clearBuffer(sessionId: string): SessionHostRecord;
359
+ updateSessionMeta(sessionId: string, meta: Record<string, unknown>, replace?: boolean): SessionHostRecord;
360
+ markStarted(sessionId: string, pid?: number): SessionHostRecord;
361
+ markStopped(sessionId: string, lifecycle?: 'stopped' | 'failed'): SessionHostRecord;
362
+ setLifecycle(sessionId: string, lifecycle: 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted'): SessionHostRecord;
363
+ deleteSession(sessionId: string): boolean;
364
+ private requireSession;
365
+ private cloneRecord;
366
+ }
367
+
368
+ declare function getWorkspaceLabel(workspace: string): string;
369
+ declare function buildRuntimeDisplayName(payload: Pick<CreateSessionPayload, 'displayName' | 'providerType' | 'workspace'>): string;
370
+ declare function buildRuntimeKey(payload: Pick<CreateSessionPayload, 'runtimeKey' | 'displayName' | 'providerType' | 'workspace'>, existingKeys: Iterable<string>): string;
371
+ declare function resolveRuntimeRecord(records: SessionHostRecord[], identifier: string): SessionHostRecord;
372
+ declare function formatRuntimeOwner(record: Pick<SessionHostRecord, 'writeOwner'>): string;
373
+
374
+ interface SessionHostEndpoint {
375
+ kind: 'unix' | 'pipe';
376
+ path: string;
377
+ }
378
+ declare function getDefaultSessionHostEndpoint(appName?: string): SessionHostEndpoint;
379
+ declare function createLineParser(onEnvelope: (envelope: SessionHostWireEnvelope) => void): (chunk: Buffer | string) => void;
380
+ interface SessionHostClientOptions {
381
+ endpoint?: SessionHostEndpoint;
382
+ appName?: string;
383
+ }
384
+ declare class SessionHostClient {
385
+ readonly endpoint: SessionHostEndpoint;
386
+ private socket;
387
+ private requestWaiters;
388
+ private eventListeners;
389
+ constructor(options?: SessionHostClientOptions);
390
+ connect(): Promise<void>;
391
+ onEvent(listener: (event: SessionHostEvent) => void): () => void;
392
+ request<T = unknown>(request: SessionHostRequest): Promise<SessionHostResponse<T>>;
393
+ close(): Promise<void>;
394
+ }
395
+ declare function createResponseEnvelope(requestId: string, response: SessionHostResponse): SessionHostResponseEnvelope;
396
+ declare function writeEnvelope(socket: Pick<net.Socket, 'write'>, envelope: SessionHostWireEnvelope): void;
397
+
398
+ /**
399
+ * Shared PTY spawn environment utilities.
400
+ *
401
+ * Centralises npm/pnpm/yarn env variable stripping, terminal colour env
402
+ * injection, and node-pty spawn-helper permission fixing.
403
+ *
404
+ * Used by daemon-core (provider-cli-adapter), session-host-daemon (runtime),
405
+ * and daemon-cloud (session-host).
406
+ */
407
+ /**
408
+ * Strip package-manager injected environment variables that can interfere
409
+ * with child CLI processes and apply terminal colour defaults.
410
+ */
411
+ declare function sanitizeSpawnEnv(baseEnv: NodeJS.ProcessEnv, overrides?: Record<string, string>): Record<string, string>;
412
+ /**
413
+ * Apply preferred terminal colour environment variables.
414
+ * Ensures TERM is set to xterm-256color and enables colour on Windows.
415
+ */
416
+ declare function applyTerminalColorEnv(env: Record<string, string>): void;
417
+ /**
418
+ * Ensure node-pty's spawn-helper binary has execute permissions.
419
+ *
420
+ * npm's default umask can strip +x from the prebuilt spawn-helper on macOS/Linux,
421
+ * causing EACCES when node-pty tries to fork. Best-effort fix.
422
+ *
423
+ * @param logFn Optional log callback for reporting the fix.
424
+ */
425
+ declare function ensureNodePtySpawnHelperPermissions(logFn?: (msg: string) => void): void;
426
+
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 };