@adhdev/session-host-core 0.7.12

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/src/types.ts ADDED
@@ -0,0 +1,184 @@
1
+ export type SessionTransport = 'pty';
2
+
3
+ export type SessionHostCategory = 'cli' | 'acp' | 'shell';
4
+
5
+ export type SessionLifecycle = 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted';
6
+
7
+ export type SessionClientType = 'daemon' | 'web' | 'local-terminal';
8
+
9
+ export type SessionOwnerType = 'agent' | 'user';
10
+
11
+ export interface SessionLaunchCommand {
12
+ command: string;
13
+ args: string[];
14
+ env?: Record<string, string>;
15
+ }
16
+
17
+ export interface SessionWriteOwner {
18
+ clientId: string;
19
+ ownerType: SessionOwnerType;
20
+ acquiredAt: number;
21
+ }
22
+
23
+ export interface SessionAttachedClient {
24
+ clientId: string;
25
+ type: SessionClientType;
26
+ readOnly: boolean;
27
+ attachedAt: number;
28
+ lastSeenAt: number;
29
+ }
30
+
31
+ export interface SessionBufferSnapshot {
32
+ seq: number;
33
+ text: string;
34
+ truncated: boolean;
35
+ }
36
+
37
+ export interface SessionBufferState {
38
+ scrollbackBytes: number;
39
+ snapshotSeq: number;
40
+ }
41
+
42
+ export interface SessionHostRecord {
43
+ sessionId: string;
44
+ runtimeKey: string;
45
+ displayName: string;
46
+ workspaceLabel: string;
47
+ transport: SessionTransport;
48
+ providerType: string;
49
+ category: SessionHostCategory;
50
+ workspace: string;
51
+ launchCommand: SessionLaunchCommand;
52
+ osPid?: number;
53
+ createdAt: number;
54
+ startedAt?: number;
55
+ lastActivityAt: number;
56
+ lifecycle: SessionLifecycle;
57
+ writeOwner: SessionWriteOwner | null;
58
+ attachedClients: SessionAttachedClient[];
59
+ buffer: SessionBufferState;
60
+ meta: Record<string, unknown>;
61
+ }
62
+
63
+ export interface CreateSessionPayload {
64
+ sessionId?: string;
65
+ runtimeKey?: string;
66
+ displayName?: string;
67
+ providerType: string;
68
+ category: SessionHostCategory;
69
+ workspace: string;
70
+ launchCommand: SessionLaunchCommand;
71
+ cols?: number;
72
+ rows?: number;
73
+ clientId?: string;
74
+ clientType?: SessionClientType;
75
+ meta?: Record<string, unknown>;
76
+ }
77
+
78
+ export interface AttachSessionPayload {
79
+ sessionId: string;
80
+ clientId: string;
81
+ clientType: SessionClientType;
82
+ readOnly?: boolean;
83
+ }
84
+
85
+ export interface DetachSessionPayload {
86
+ sessionId: string;
87
+ clientId: string;
88
+ }
89
+
90
+ export interface SendInputPayload {
91
+ sessionId: string;
92
+ clientId: string;
93
+ data: string;
94
+ }
95
+
96
+ export interface ResizeSessionPayload {
97
+ sessionId: string;
98
+ cols: number;
99
+ rows: number;
100
+ }
101
+
102
+ export interface StopSessionPayload {
103
+ sessionId: string;
104
+ }
105
+
106
+ export interface ResumeSessionPayload {
107
+ sessionId: string;
108
+ }
109
+
110
+ export interface AcquireWritePayload {
111
+ sessionId: string;
112
+ clientId: string;
113
+ ownerType: SessionOwnerType;
114
+ force?: boolean;
115
+ }
116
+
117
+ export interface ReleaseWritePayload {
118
+ sessionId: string;
119
+ clientId: string;
120
+ }
121
+
122
+ export interface GetSnapshotPayload {
123
+ sessionId: string;
124
+ sinceSeq?: number;
125
+ }
126
+
127
+ export interface ClearSessionBufferPayload {
128
+ sessionId: string;
129
+ }
130
+
131
+ export type SessionHostRequest =
132
+ | { type: 'create_session'; payload: CreateSessionPayload }
133
+ | { type: 'attach_session'; payload: AttachSessionPayload }
134
+ | { type: 'detach_session'; payload: DetachSessionPayload }
135
+ | { type: 'send_input'; payload: SendInputPayload }
136
+ | { type: 'resize_session'; payload: ResizeSessionPayload }
137
+ | { type: 'stop_session'; payload: StopSessionPayload }
138
+ | { type: 'resume_session'; payload: ResumeSessionPayload }
139
+ | { type: 'acquire_write'; payload: AcquireWritePayload }
140
+ | { type: 'release_write'; payload: ReleaseWritePayload }
141
+ | { type: 'get_snapshot'; payload: GetSnapshotPayload }
142
+ | { type: 'clear_session_buffer'; payload: ClearSessionBufferPayload }
143
+ | { type: 'list_sessions'; payload?: {} };
144
+
145
+ export interface SessionHostResponse<T = unknown> {
146
+ success: boolean;
147
+ result?: T;
148
+ error?: string;
149
+ }
150
+
151
+ export type SessionHostEvent =
152
+ | { type: 'session_created'; sessionId: string; record: SessionHostRecord }
153
+ | { type: 'session_started'; sessionId: string; pid?: number }
154
+ | { type: 'session_resumed'; sessionId: string; pid?: number }
155
+ | { type: 'session_output'; sessionId: string; seq: number; data: string }
156
+ | { type: 'session_cleared'; sessionId: string }
157
+ | { type: 'session_exit'; sessionId: string; exitCode: number | null }
158
+ | { type: 'session_stopped'; sessionId: string }
159
+ | { type: 'session_resized'; sessionId: string; cols: number; rows: number }
160
+ | { type: 'write_owner_changed'; sessionId: string; owner: SessionWriteOwner | null }
161
+ | { type: 'client_attached'; sessionId: string; client: SessionAttachedClient }
162
+ | { type: 'client_detached'; sessionId: string; clientId: string };
163
+
164
+ export interface SessionHostRequestEnvelope {
165
+ kind: 'request';
166
+ requestId: string;
167
+ request: SessionHostRequest;
168
+ }
169
+
170
+ export interface SessionHostResponseEnvelope {
171
+ kind: 'response';
172
+ requestId: string;
173
+ response: SessionHostResponse;
174
+ }
175
+
176
+ export interface SessionHostEventEnvelope {
177
+ kind: 'event';
178
+ event: SessionHostEvent;
179
+ }
180
+
181
+ export type SessionHostWireEnvelope =
182
+ | SessionHostRequestEnvelope
183
+ | SessionHostResponseEnvelope
184
+ | SessionHostEventEnvelope;