@cerulin/chell 0.2.5

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 (53) hide show
  1. package/README.md +75 -0
  2. package/bin/chell-mcp.mjs +33 -0
  3. package/bin/chell.mjs +37 -0
  4. package/dist/codex/chellMcpStdioBridge.cjs +80 -0
  5. package/dist/codex/chellMcpStdioBridge.d.cts +2 -0
  6. package/dist/codex/chellMcpStdioBridge.d.mts +2 -0
  7. package/dist/codex/chellMcpStdioBridge.mjs +78 -0
  8. package/dist/index-B443j7JQ.mjs +6714 -0
  9. package/dist/index-qS668VWY.cjs +6730 -0
  10. package/dist/index.cjs +42 -0
  11. package/dist/index.d.cts +1 -0
  12. package/dist/index.d.mts +1 -0
  13. package/dist/index.mjs +39 -0
  14. package/dist/lib.cjs +32 -0
  15. package/dist/lib.d.cts +891 -0
  16. package/dist/lib.d.mts +891 -0
  17. package/dist/lib.mjs +22 -0
  18. package/dist/runCodex-DHtm7TWT.cjs +2020 -0
  19. package/dist/runCodex-DLbjgnc4.mjs +2017 -0
  20. package/dist/runGemini-C03RUmvr.mjs +788 -0
  21. package/dist/runGemini-fdb5jxAA.cjs +791 -0
  22. package/dist/types-DBjv5m4J.cjs +2499 -0
  23. package/dist/types-fM_iFuNp.mjs +2452 -0
  24. package/package.json +131 -0
  25. package/scripts/claude_local_launcher.cjs +98 -0
  26. package/scripts/claude_remote_launcher.cjs +13 -0
  27. package/scripts/codex_local_launcher.cjs +155 -0
  28. package/scripts/codex_preload.cjs +56 -0
  29. package/scripts/codex_remote_launcher.cjs +129 -0
  30. package/scripts/obfuscate-dist.mjs +73 -0
  31. package/scripts/pack-chell.cjs +32 -0
  32. package/scripts/publish-scoped.ps1 +58 -0
  33. package/scripts/ripgrep_launcher.cjs +33 -0
  34. package/scripts/unpack-tools.cjs +163 -0
  35. package/tools/archives/difftastic-LICENSE +21 -0
  36. package/tools/archives/difftastic-arm64-darwin.tar.gz +0 -0
  37. package/tools/archives/difftastic-arm64-linux.tar.gz +0 -0
  38. package/tools/archives/difftastic-x64-darwin.tar.gz +0 -0
  39. package/tools/archives/difftastic-x64-linux.tar.gz +0 -0
  40. package/tools/archives/difftastic-x64-win32.tar.gz +0 -0
  41. package/tools/archives/ripgrep-LICENSE +3 -0
  42. package/tools/archives/ripgrep-arm64-darwin.tar.gz +0 -0
  43. package/tools/archives/ripgrep-arm64-linux.tar.gz +0 -0
  44. package/tools/archives/ripgrep-x64-darwin.tar.gz +0 -0
  45. package/tools/archives/ripgrep-x64-linux.tar.gz +0 -0
  46. package/tools/archives/ripgrep-x64-win32.tar.gz +0 -0
  47. package/tools/licenses/difftastic-LICENSE +21 -0
  48. package/tools/licenses/ripgrep-LICENSE +3 -0
  49. package/tools/unpacked/difft +0 -0
  50. package/tools/unpacked/difft.exe +0 -0
  51. package/tools/unpacked/rg +0 -0
  52. package/tools/unpacked/rg.exe +0 -0
  53. package/tools/unpacked/ripgrep.node +0 -0
package/dist/lib.d.cts ADDED
@@ -0,0 +1,891 @@
1
+ import { z } from 'zod';
2
+ import { EventEmitter } from 'node:events';
3
+ import { Socket } from 'socket.io-client';
4
+ import { ExpoPushMessage } from 'expo-server-sdk';
5
+
6
+ /**
7
+ * Simplified schema that only validates fields actually used in the codebase
8
+ * while preserving all other fields through passthrough()
9
+ */
10
+
11
+ declare const UsageSchema: z.ZodObject<{
12
+ input_tokens: z.ZodNumber;
13
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
14
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
15
+ output_tokens: z.ZodNumber;
16
+ service_tier: z.ZodOptional<z.ZodString>;
17
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
18
+ input_tokens: z.ZodNumber;
19
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
20
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
21
+ output_tokens: z.ZodNumber;
22
+ service_tier: z.ZodOptional<z.ZodString>;
23
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
24
+ input_tokens: z.ZodNumber;
25
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
26
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
27
+ output_tokens: z.ZodNumber;
28
+ service_tier: z.ZodOptional<z.ZodString>;
29
+ }, z.ZodTypeAny, "passthrough">>;
30
+ declare const RawJSONLinesSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
31
+ type: z.ZodLiteral<"user">;
32
+ isSidechain: z.ZodOptional<z.ZodBoolean>;
33
+ isMeta: z.ZodOptional<z.ZodBoolean>;
34
+ uuid: z.ZodString;
35
+ message: z.ZodObject<{
36
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
37
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
38
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
39
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
40
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
41
+ }, z.ZodTypeAny, "passthrough">>;
42
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
43
+ type: z.ZodLiteral<"user">;
44
+ isSidechain: z.ZodOptional<z.ZodBoolean>;
45
+ isMeta: z.ZodOptional<z.ZodBoolean>;
46
+ uuid: z.ZodString;
47
+ message: z.ZodObject<{
48
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
49
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
50
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
51
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
52
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
53
+ }, z.ZodTypeAny, "passthrough">>;
54
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
55
+ type: z.ZodLiteral<"user">;
56
+ isSidechain: z.ZodOptional<z.ZodBoolean>;
57
+ isMeta: z.ZodOptional<z.ZodBoolean>;
58
+ uuid: z.ZodString;
59
+ message: z.ZodObject<{
60
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
61
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
62
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
63
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
64
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
65
+ }, z.ZodTypeAny, "passthrough">>;
66
+ }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
67
+ uuid: z.ZodString;
68
+ type: z.ZodLiteral<"assistant">;
69
+ message: z.ZodObject<{
70
+ usage: z.ZodOptional<z.ZodObject<{
71
+ input_tokens: z.ZodNumber;
72
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
73
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
74
+ output_tokens: z.ZodNumber;
75
+ service_tier: z.ZodOptional<z.ZodString>;
76
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
77
+ input_tokens: z.ZodNumber;
78
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
79
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
80
+ output_tokens: z.ZodNumber;
81
+ service_tier: z.ZodOptional<z.ZodString>;
82
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
83
+ input_tokens: z.ZodNumber;
84
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
85
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
86
+ output_tokens: z.ZodNumber;
87
+ service_tier: z.ZodOptional<z.ZodString>;
88
+ }, z.ZodTypeAny, "passthrough">>>;
89
+ content: z.ZodAny;
90
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
91
+ usage: z.ZodOptional<z.ZodObject<{
92
+ input_tokens: z.ZodNumber;
93
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
94
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
95
+ output_tokens: z.ZodNumber;
96
+ service_tier: z.ZodOptional<z.ZodString>;
97
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
98
+ input_tokens: z.ZodNumber;
99
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
100
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
101
+ output_tokens: z.ZodNumber;
102
+ service_tier: z.ZodOptional<z.ZodString>;
103
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
104
+ input_tokens: z.ZodNumber;
105
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
106
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
107
+ output_tokens: z.ZodNumber;
108
+ service_tier: z.ZodOptional<z.ZodString>;
109
+ }, z.ZodTypeAny, "passthrough">>>;
110
+ content: z.ZodAny;
111
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
112
+ usage: z.ZodOptional<z.ZodObject<{
113
+ input_tokens: z.ZodNumber;
114
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
115
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
116
+ output_tokens: z.ZodNumber;
117
+ service_tier: z.ZodOptional<z.ZodString>;
118
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
119
+ input_tokens: z.ZodNumber;
120
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
121
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
122
+ output_tokens: z.ZodNumber;
123
+ service_tier: z.ZodOptional<z.ZodString>;
124
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
125
+ input_tokens: z.ZodNumber;
126
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
127
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
128
+ output_tokens: z.ZodNumber;
129
+ service_tier: z.ZodOptional<z.ZodString>;
130
+ }, z.ZodTypeAny, "passthrough">>>;
131
+ content: z.ZodAny;
132
+ }, z.ZodTypeAny, "passthrough">>;
133
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
134
+ uuid: z.ZodString;
135
+ type: z.ZodLiteral<"assistant">;
136
+ message: z.ZodObject<{
137
+ usage: z.ZodOptional<z.ZodObject<{
138
+ input_tokens: z.ZodNumber;
139
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
140
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
141
+ output_tokens: z.ZodNumber;
142
+ service_tier: z.ZodOptional<z.ZodString>;
143
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
144
+ input_tokens: z.ZodNumber;
145
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
146
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
147
+ output_tokens: z.ZodNumber;
148
+ service_tier: z.ZodOptional<z.ZodString>;
149
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
150
+ input_tokens: z.ZodNumber;
151
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
152
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
153
+ output_tokens: z.ZodNumber;
154
+ service_tier: z.ZodOptional<z.ZodString>;
155
+ }, z.ZodTypeAny, "passthrough">>>;
156
+ content: z.ZodAny;
157
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
158
+ usage: z.ZodOptional<z.ZodObject<{
159
+ input_tokens: z.ZodNumber;
160
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
161
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
162
+ output_tokens: z.ZodNumber;
163
+ service_tier: z.ZodOptional<z.ZodString>;
164
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
165
+ input_tokens: z.ZodNumber;
166
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
167
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
168
+ output_tokens: z.ZodNumber;
169
+ service_tier: z.ZodOptional<z.ZodString>;
170
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
171
+ input_tokens: z.ZodNumber;
172
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
173
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
174
+ output_tokens: z.ZodNumber;
175
+ service_tier: z.ZodOptional<z.ZodString>;
176
+ }, z.ZodTypeAny, "passthrough">>>;
177
+ content: z.ZodAny;
178
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
179
+ usage: z.ZodOptional<z.ZodObject<{
180
+ input_tokens: z.ZodNumber;
181
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
182
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
183
+ output_tokens: z.ZodNumber;
184
+ service_tier: z.ZodOptional<z.ZodString>;
185
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
186
+ input_tokens: z.ZodNumber;
187
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
188
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
189
+ output_tokens: z.ZodNumber;
190
+ service_tier: z.ZodOptional<z.ZodString>;
191
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
192
+ input_tokens: z.ZodNumber;
193
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
194
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
195
+ output_tokens: z.ZodNumber;
196
+ service_tier: z.ZodOptional<z.ZodString>;
197
+ }, z.ZodTypeAny, "passthrough">>>;
198
+ content: z.ZodAny;
199
+ }, z.ZodTypeAny, "passthrough">>;
200
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
201
+ uuid: z.ZodString;
202
+ type: z.ZodLiteral<"assistant">;
203
+ message: z.ZodObject<{
204
+ usage: z.ZodOptional<z.ZodObject<{
205
+ input_tokens: z.ZodNumber;
206
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
207
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
208
+ output_tokens: z.ZodNumber;
209
+ service_tier: z.ZodOptional<z.ZodString>;
210
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
211
+ input_tokens: z.ZodNumber;
212
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
213
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
214
+ output_tokens: z.ZodNumber;
215
+ service_tier: z.ZodOptional<z.ZodString>;
216
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
217
+ input_tokens: z.ZodNumber;
218
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
219
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
220
+ output_tokens: z.ZodNumber;
221
+ service_tier: z.ZodOptional<z.ZodString>;
222
+ }, z.ZodTypeAny, "passthrough">>>;
223
+ content: z.ZodAny;
224
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
225
+ usage: z.ZodOptional<z.ZodObject<{
226
+ input_tokens: z.ZodNumber;
227
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
228
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
229
+ output_tokens: z.ZodNumber;
230
+ service_tier: z.ZodOptional<z.ZodString>;
231
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
232
+ input_tokens: z.ZodNumber;
233
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
234
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
235
+ output_tokens: z.ZodNumber;
236
+ service_tier: z.ZodOptional<z.ZodString>;
237
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
238
+ input_tokens: z.ZodNumber;
239
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
240
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
241
+ output_tokens: z.ZodNumber;
242
+ service_tier: z.ZodOptional<z.ZodString>;
243
+ }, z.ZodTypeAny, "passthrough">>>;
244
+ content: z.ZodAny;
245
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
246
+ usage: z.ZodOptional<z.ZodObject<{
247
+ input_tokens: z.ZodNumber;
248
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
249
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
250
+ output_tokens: z.ZodNumber;
251
+ service_tier: z.ZodOptional<z.ZodString>;
252
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
253
+ input_tokens: z.ZodNumber;
254
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
255
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
256
+ output_tokens: z.ZodNumber;
257
+ service_tier: z.ZodOptional<z.ZodString>;
258
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
259
+ input_tokens: z.ZodNumber;
260
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
261
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
262
+ output_tokens: z.ZodNumber;
263
+ service_tier: z.ZodOptional<z.ZodString>;
264
+ }, z.ZodTypeAny, "passthrough">>>;
265
+ content: z.ZodAny;
266
+ }, z.ZodTypeAny, "passthrough">>;
267
+ }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
268
+ type: z.ZodLiteral<"summary">;
269
+ summary: z.ZodString;
270
+ leafUuid: z.ZodString;
271
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
272
+ type: z.ZodLiteral<"summary">;
273
+ summary: z.ZodString;
274
+ leafUuid: z.ZodString;
275
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
276
+ type: z.ZodLiteral<"summary">;
277
+ summary: z.ZodString;
278
+ leafUuid: z.ZodString;
279
+ }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
280
+ type: z.ZodLiteral<"system">;
281
+ uuid: z.ZodString;
282
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
283
+ type: z.ZodLiteral<"system">;
284
+ uuid: z.ZodString;
285
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
286
+ type: z.ZodLiteral<"system">;
287
+ uuid: z.ZodString;
288
+ }, z.ZodTypeAny, "passthrough">>]>;
289
+ type RawJSONLines = z.infer<typeof RawJSONLinesSchema>;
290
+
291
+ /**
292
+ * Common RPC types and interfaces for both session and machine clients
293
+ */
294
+ /**
295
+ * Generic RPC handler function type
296
+ * @template TRequest - The request data type
297
+ * @template TResponse - The response data type
298
+ */
299
+ type RpcHandler<TRequest = any, TResponse = any> = (data: TRequest) => TResponse | Promise<TResponse>;
300
+ /**
301
+ * RPC request data from server
302
+ */
303
+ interface RpcRequest {
304
+ method: string;
305
+ params: string;
306
+ }
307
+ /**
308
+ * Configuration for RPC handler manager
309
+ */
310
+ interface RpcHandlerConfig {
311
+ /** Prefix to add to all method names (e.g., sessionId or machineId) */
312
+ scopePrefix: string;
313
+ /** Secret key for encryption/decryption */
314
+ secret: Uint8Array;
315
+ /** Logger function for debugging */
316
+ logger?: (message: string, data?: any) => void;
317
+ }
318
+
319
+ /**
320
+ * Generic RPC handler manager for session and machine clients
321
+ * Manages RPC method registration, encryption/decryption, and handler execution
322
+ */
323
+
324
+ declare class RpcHandlerManager {
325
+ private handlers;
326
+ private readonly scopePrefix;
327
+ private readonly secret;
328
+ private readonly logger;
329
+ private socket;
330
+ constructor(config: RpcHandlerConfig);
331
+ /**
332
+ * Register an RPC handler for a specific method
333
+ * @param method - The method name (without prefix)
334
+ * @param handler - The handler function
335
+ */
336
+ registerHandler<TRequest = any, TResponse = any>(method: string, handler: RpcHandler<TRequest, TResponse>): void;
337
+ /**
338
+ * Handle an incoming RPC request
339
+ * @param request - The RPC request data
340
+ * @param callback - The response callback
341
+ */
342
+ handleRequest(request: RpcRequest): Promise<any>;
343
+ onSocketConnect(socket: Socket): void;
344
+ onSocketDisconnect(): void;
345
+ /**
346
+ * Get the number of registered handlers
347
+ */
348
+ getHandlerCount(): number;
349
+ /**
350
+ * Check if a handler is registered
351
+ * @param method - The method name (without prefix)
352
+ */
353
+ hasHandler(method: string): boolean;
354
+ /**
355
+ * Clear all handlers
356
+ */
357
+ clearHandlers(): void;
358
+ /**
359
+ * Get the prefixed method name
360
+ * @param method - The method name
361
+ */
362
+ private getPrefixedMethod;
363
+ }
364
+
365
+ declare class ApiSessionClient extends EventEmitter {
366
+ private readonly token;
367
+ private readonly secret;
368
+ readonly sessionId: string;
369
+ private metadata;
370
+ private metadataVersion;
371
+ private agentState;
372
+ private agentStateVersion;
373
+ private socket;
374
+ private pendingMessages;
375
+ private pendingMessageCallback;
376
+ readonly rpcHandlerManager: RpcHandlerManager;
377
+ private agentStateLock;
378
+ private metadataLock;
379
+ constructor(token: string, secret: Uint8Array, session: Session);
380
+ onUserMessage(callback: (data: UserMessage) => void): void;
381
+ /**
382
+ * Send message to session
383
+ * @param body - Message body (can be MessageContent or raw content for agent messages)
384
+ */
385
+ sendClaudeSessionMessage(body: RawJSONLines): void;
386
+ sendCodexMessage(body: any): void;
387
+ sendGeminiMessage(body: any): void;
388
+ sendSessionEvent(event: {
389
+ type: 'switch';
390
+ mode: 'local' | 'remote';
391
+ } | {
392
+ type: 'message';
393
+ message: string;
394
+ } | {
395
+ type: 'permission-mode-changed';
396
+ mode: 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
397
+ } | {
398
+ type: 'ready';
399
+ }, id?: string): void;
400
+ /**
401
+ * Send a ping message to keep the connection alive
402
+ */
403
+ keepAlive(thinking: boolean, mode: 'local' | 'remote'): void;
404
+ /**
405
+ * Send session death message
406
+ */
407
+ sendSessionDeath(): void;
408
+ /**
409
+ * Send usage data to the server
410
+ */
411
+ sendUsageData(usage: Usage): void;
412
+ /**
413
+ * Update session metadata
414
+ * @param handler - Handler function that returns the updated metadata
415
+ */
416
+ updateMetadata(handler: (metadata: Metadata) => Metadata): void;
417
+ /**
418
+ * Update session agent state
419
+ * @param handler - Handler function that returns the updated agent state
420
+ */
421
+ updateAgentState(handler: (metadata: AgentState) => AgentState): void;
422
+ /**
423
+ * Wait for socket buffer to flush
424
+ */
425
+ flush(): Promise<void>;
426
+ close(): Promise<void>;
427
+ }
428
+
429
+ type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
430
+
431
+ /**
432
+ * Usage data type from Claude
433
+ */
434
+ type Usage = z.infer<typeof UsageSchema>;
435
+ /**
436
+ * Session information
437
+ */
438
+ declare const SessionSchema: z.ZodObject<{
439
+ createdAt: z.ZodNumber;
440
+ id: z.ZodString;
441
+ seq: z.ZodNumber;
442
+ updatedAt: z.ZodNumber;
443
+ metadata: z.ZodAny;
444
+ metadataVersion: z.ZodNumber;
445
+ agentState: z.ZodNullable<z.ZodAny>;
446
+ agentStateVersion: z.ZodNumber;
447
+ connectivityStatus: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["neverConnected", "online", "offline"]>, z.ZodString]>>;
448
+ connectivityStatusSince: z.ZodOptional<z.ZodNumber>;
449
+ connectivityStatusReason: z.ZodOptional<z.ZodString>;
450
+ state: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["running", "archiveRequested", "archived"]>, z.ZodString]>>;
451
+ stateSince: z.ZodOptional<z.ZodNumber>;
452
+ stateReason: z.ZodOptional<z.ZodString>;
453
+ }, "strip", z.ZodTypeAny, {
454
+ id: string;
455
+ seq: number;
456
+ createdAt: number;
457
+ updatedAt: number;
458
+ metadataVersion: number;
459
+ agentStateVersion: number;
460
+ metadata?: any;
461
+ agentState?: any;
462
+ connectivityStatus?: string | undefined;
463
+ connectivityStatusSince?: number | undefined;
464
+ connectivityStatusReason?: string | undefined;
465
+ state?: string | undefined;
466
+ stateSince?: number | undefined;
467
+ stateReason?: string | undefined;
468
+ }, {
469
+ id: string;
470
+ seq: number;
471
+ createdAt: number;
472
+ updatedAt: number;
473
+ metadataVersion: number;
474
+ agentStateVersion: number;
475
+ metadata?: any;
476
+ agentState?: any;
477
+ connectivityStatus?: string | undefined;
478
+ connectivityStatusSince?: number | undefined;
479
+ connectivityStatusReason?: string | undefined;
480
+ state?: string | undefined;
481
+ stateSince?: number | undefined;
482
+ stateReason?: string | undefined;
483
+ }>;
484
+ type Session = z.infer<typeof SessionSchema>;
485
+ /**
486
+ * Machine metadata - static information (rarely changes)
487
+ */
488
+ declare const MachineMetadataSchema: z.ZodObject<{
489
+ host: z.ZodString;
490
+ platform: z.ZodString;
491
+ happyCliVersion: z.ZodString;
492
+ homeDir: z.ZodString;
493
+ happyHomeDir: z.ZodString;
494
+ happyLibDir: z.ZodString;
495
+ }, "strip", z.ZodTypeAny, {
496
+ host: string;
497
+ platform: string;
498
+ happyCliVersion: string;
499
+ homeDir: string;
500
+ happyHomeDir: string;
501
+ happyLibDir: string;
502
+ }, {
503
+ host: string;
504
+ platform: string;
505
+ happyCliVersion: string;
506
+ homeDir: string;
507
+ happyHomeDir: string;
508
+ happyLibDir: string;
509
+ }>;
510
+ type MachineMetadata = z.infer<typeof MachineMetadataSchema>;
511
+ /**
512
+ * Daemon state - dynamic runtime information (frequently updated)
513
+ */
514
+ declare const DaemonStateSchema: z.ZodObject<{
515
+ status: z.ZodUnion<[z.ZodEnum<["running", "shutting-down"]>, z.ZodString]>;
516
+ pid: z.ZodOptional<z.ZodNumber>;
517
+ httpPort: z.ZodOptional<z.ZodNumber>;
518
+ startedAt: z.ZodOptional<z.ZodNumber>;
519
+ shutdownRequestedAt: z.ZodOptional<z.ZodNumber>;
520
+ shutdownSource: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["mobile-app", "cli", "os-signal", "unknown"]>, z.ZodString]>>;
521
+ }, "strip", z.ZodTypeAny, {
522
+ status: string;
523
+ pid?: number | undefined;
524
+ httpPort?: number | undefined;
525
+ startedAt?: number | undefined;
526
+ shutdownRequestedAt?: number | undefined;
527
+ shutdownSource?: string | undefined;
528
+ }, {
529
+ status: string;
530
+ pid?: number | undefined;
531
+ httpPort?: number | undefined;
532
+ startedAt?: number | undefined;
533
+ shutdownRequestedAt?: number | undefined;
534
+ shutdownSource?: string | undefined;
535
+ }>;
536
+ type DaemonState = z.infer<typeof DaemonStateSchema>;
537
+ /**
538
+ * Machine information - similar to Session
539
+ */
540
+ declare const MachineSchema: z.ZodObject<{
541
+ id: z.ZodString;
542
+ metadata: z.ZodAny;
543
+ metadataVersion: z.ZodNumber;
544
+ daemonState: z.ZodNullable<z.ZodAny>;
545
+ daemonStateVersion: z.ZodNumber;
546
+ active: z.ZodBoolean;
547
+ activeAt: z.ZodNumber;
548
+ createdAt: z.ZodNumber;
549
+ updatedAt: z.ZodNumber;
550
+ connectivityStatus: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["neverConnected", "online", "offline"]>, z.ZodString]>>;
551
+ connectivityStatusSince: z.ZodOptional<z.ZodNumber>;
552
+ connectivityStatusReason: z.ZodOptional<z.ZodString>;
553
+ state: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["running", "archiveRequested", "archived"]>, z.ZodString]>>;
554
+ stateSince: z.ZodOptional<z.ZodNumber>;
555
+ stateReason: z.ZodOptional<z.ZodString>;
556
+ }, "strip", z.ZodTypeAny, {
557
+ id: string;
558
+ createdAt: number;
559
+ updatedAt: number;
560
+ metadataVersion: number;
561
+ daemonStateVersion: number;
562
+ active: boolean;
563
+ activeAt: number;
564
+ metadata?: any;
565
+ daemonState?: any;
566
+ connectivityStatus?: string | undefined;
567
+ connectivityStatusSince?: number | undefined;
568
+ connectivityStatusReason?: string | undefined;
569
+ state?: string | undefined;
570
+ stateSince?: number | undefined;
571
+ stateReason?: string | undefined;
572
+ }, {
573
+ id: string;
574
+ createdAt: number;
575
+ updatedAt: number;
576
+ metadataVersion: number;
577
+ daemonStateVersion: number;
578
+ active: boolean;
579
+ activeAt: number;
580
+ metadata?: any;
581
+ daemonState?: any;
582
+ connectivityStatus?: string | undefined;
583
+ connectivityStatusSince?: number | undefined;
584
+ connectivityStatusReason?: string | undefined;
585
+ state?: string | undefined;
586
+ stateSince?: number | undefined;
587
+ stateReason?: string | undefined;
588
+ }>;
589
+ type Machine = z.infer<typeof MachineSchema>;
590
+ declare const UserMessageSchema: z.ZodObject<{
591
+ role: z.ZodLiteral<"user">;
592
+ content: z.ZodObject<{
593
+ type: z.ZodLiteral<"text">;
594
+ text: z.ZodString;
595
+ }, "strip", z.ZodTypeAny, {
596
+ type: "text";
597
+ text: string;
598
+ }, {
599
+ type: "text";
600
+ text: string;
601
+ }>;
602
+ localKey: z.ZodOptional<z.ZodString>;
603
+ meta: z.ZodOptional<z.ZodObject<{
604
+ sentFrom: z.ZodOptional<z.ZodString>;
605
+ permissionMode: z.ZodOptional<z.ZodString>;
606
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
607
+ fallbackModel: z.ZodOptional<z.ZodNullable<z.ZodString>>;
608
+ customSystemPrompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
609
+ appendSystemPrompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
610
+ allowedTools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
611
+ disallowedTools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
612
+ }, "strip", z.ZodTypeAny, {
613
+ sentFrom?: string | undefined;
614
+ permissionMode?: string | undefined;
615
+ model?: string | null | undefined;
616
+ fallbackModel?: string | null | undefined;
617
+ customSystemPrompt?: string | null | undefined;
618
+ appendSystemPrompt?: string | null | undefined;
619
+ allowedTools?: string[] | null | undefined;
620
+ disallowedTools?: string[] | null | undefined;
621
+ }, {
622
+ sentFrom?: string | undefined;
623
+ permissionMode?: string | undefined;
624
+ model?: string | null | undefined;
625
+ fallbackModel?: string | null | undefined;
626
+ customSystemPrompt?: string | null | undefined;
627
+ appendSystemPrompt?: string | null | undefined;
628
+ allowedTools?: string[] | null | undefined;
629
+ disallowedTools?: string[] | null | undefined;
630
+ }>>;
631
+ }, "strip", z.ZodTypeAny, {
632
+ content: {
633
+ type: "text";
634
+ text: string;
635
+ };
636
+ role: "user";
637
+ localKey?: string | undefined;
638
+ meta?: {
639
+ sentFrom?: string | undefined;
640
+ permissionMode?: string | undefined;
641
+ model?: string | null | undefined;
642
+ fallbackModel?: string | null | undefined;
643
+ customSystemPrompt?: string | null | undefined;
644
+ appendSystemPrompt?: string | null | undefined;
645
+ allowedTools?: string[] | null | undefined;
646
+ disallowedTools?: string[] | null | undefined;
647
+ } | undefined;
648
+ }, {
649
+ content: {
650
+ type: "text";
651
+ text: string;
652
+ };
653
+ role: "user";
654
+ localKey?: string | undefined;
655
+ meta?: {
656
+ sentFrom?: string | undefined;
657
+ permissionMode?: string | undefined;
658
+ model?: string | null | undefined;
659
+ fallbackModel?: string | null | undefined;
660
+ customSystemPrompt?: string | null | undefined;
661
+ appendSystemPrompt?: string | null | undefined;
662
+ allowedTools?: string[] | null | undefined;
663
+ disallowedTools?: string[] | null | undefined;
664
+ } | undefined;
665
+ }>;
666
+ type UserMessage = z.infer<typeof UserMessageSchema>;
667
+ type Metadata = {
668
+ path: string;
669
+ host: string;
670
+ version?: string;
671
+ name?: string;
672
+ os?: string;
673
+ summary?: {
674
+ text: string;
675
+ updatedAt: number;
676
+ };
677
+ machineId?: string;
678
+ claudeSessionId?: string;
679
+ tools?: string[];
680
+ slashCommands?: string[];
681
+ homeDir: string;
682
+ happyHomeDir: string;
683
+ happyLibDir: string;
684
+ happyToolsDir: string;
685
+ startedFromDaemon?: boolean;
686
+ hostPid?: number;
687
+ startedBy?: 'daemon' | 'terminal';
688
+ lifecycleState?: 'running' | 'archiveRequested' | 'archived' | string;
689
+ lifecycleStateSince?: number;
690
+ archivedBy?: string;
691
+ archiveReason?: string;
692
+ flavor?: string;
693
+ };
694
+ type AgentState = {
695
+ controlledByUser?: boolean | null | undefined;
696
+ requests?: {
697
+ [id: string]: {
698
+ tool: string;
699
+ arguments: any;
700
+ createdAt: number;
701
+ };
702
+ };
703
+ completedRequests?: {
704
+ [id: string]: {
705
+ tool: string;
706
+ arguments: any;
707
+ createdAt: number;
708
+ completedAt: number;
709
+ status: 'canceled' | 'denied' | 'approved';
710
+ reason?: string;
711
+ mode?: PermissionMode;
712
+ decision?: 'approved' | 'approved_for_session' | 'denied' | 'abort';
713
+ allowTools?: string[];
714
+ };
715
+ };
716
+ };
717
+
718
+ interface SpawnSessionOptions {
719
+ machineId?: string;
720
+ directory: string;
721
+ sessionId?: string;
722
+ approvedNewDirectoryCreation?: boolean;
723
+ }
724
+ type SpawnSessionResult = {
725
+ type: 'success';
726
+ sessionId: string;
727
+ } | {
728
+ type: 'requestToApproveDirectoryCreation';
729
+ directory: string;
730
+ } | {
731
+ type: 'error';
732
+ errorMessage: string;
733
+ };
734
+
735
+ /**
736
+ * WebSocket client for machine/daemon communication with Happy server
737
+ * Similar to ApiSessionClient but for machine-scoped connections
738
+ */
739
+
740
+ type MachineRpcHandlers = {
741
+ spawnSession: (options: SpawnSessionOptions) => Promise<SpawnSessionResult>;
742
+ stopSession: (sessionId: string) => boolean;
743
+ requestShutdown: () => void;
744
+ };
745
+ declare class ApiMachineClient {
746
+ private token;
747
+ private secret;
748
+ private machine;
749
+ private socket;
750
+ private keepAliveInterval;
751
+ private rpcHandlerManager;
752
+ private terminalManager;
753
+ constructor(token: string, secret: Uint8Array, machine: Machine);
754
+ setRPCHandlers({ spawnSession, stopSession, requestShutdown }: MachineRpcHandlers): void;
755
+ /**
756
+ * Update machine metadata
757
+ * Currently unused, changes from the mobile client are more likely
758
+ * for example to set a custom name.
759
+ */
760
+ updateMachineMetadata(handler: (metadata: MachineMetadata | null) => MachineMetadata): Promise<void>;
761
+ /**
762
+ * Update daemon state (runtime info) - similar to session updateAgentState
763
+ * Simplified without lock - relies on backoff for retry
764
+ */
765
+ updateDaemonState(handler: (state: DaemonState | null) => DaemonState): Promise<void>;
766
+ connect(): void;
767
+ /**
768
+ * Set up terminal event listeners from server
769
+ */
770
+ private setupTerminalListeners;
771
+ private startKeepAlive;
772
+ private stopKeepAlive;
773
+ shutdown(): void;
774
+ }
775
+
776
+ interface PushToken {
777
+ id: string;
778
+ token: string;
779
+ createdAt: number;
780
+ updatedAt: number;
781
+ }
782
+ declare class PushNotificationClient {
783
+ private readonly token;
784
+ private readonly baseUrl;
785
+ private readonly expo;
786
+ constructor(token: string, baseUrl?: string);
787
+ /**
788
+ * Fetch all push tokens for the authenticated user
789
+ */
790
+ fetchPushTokens(): Promise<PushToken[]>;
791
+ /**
792
+ * Send push notification via Expo Push API with retry
793
+ * @param messages - Array of push messages to send
794
+ */
795
+ sendPushNotifications(messages: ExpoPushMessage[]): Promise<void>;
796
+ /**
797
+ * Send a push notification to all registered devices for the user
798
+ * @param title - Notification title
799
+ * @param body - Notification body
800
+ * @param data - Additional data to send with the notification
801
+ */
802
+ sendToAllDevices(title: string, body: string, data?: Record<string, any>): void;
803
+ }
804
+
805
+ declare class ApiClient {
806
+ private readonly token;
807
+ private readonly secret;
808
+ private readonly pushClient;
809
+ constructor(token: string, secret: Uint8Array);
810
+ /**
811
+ * Create a new session or load existing one with the given tag
812
+ */
813
+ getOrCreateSession(opts: {
814
+ tag: string;
815
+ metadata: Metadata;
816
+ state: AgentState | null;
817
+ }): Promise<Session>;
818
+ /**
819
+ * Get machine by ID from the server
820
+ * Returns the current machine state from the server with decrypted metadata and daemonState
821
+ */
822
+ getMachine(machineId: string): Promise<Machine | null>;
823
+ /**
824
+ * Register or update machine with the server
825
+ * Returns the current machine state from the server with decrypted metadata and daemonState
826
+ */
827
+ getOrCreateMachine(opts: {
828
+ machineId: string;
829
+ metadata: MachineMetadata;
830
+ daemonState?: DaemonState;
831
+ }): Promise<Machine>;
832
+ sessionSyncClient(session: Session): ApiSessionClient;
833
+ machineSyncClient(machine: Machine): ApiMachineClient;
834
+ push(): PushNotificationClient;
835
+ /**
836
+ * Register a vendor API token with the server
837
+ * The token is sent as a JSON string - server handles encryption
838
+ */
839
+ registerVendorToken(vendor: 'openai' | 'anthropic' | 'gemini', apiKey: any): Promise<void>;
840
+ }
841
+
842
+ /**
843
+ * Design decisions:
844
+ * - Logging should be done only through file for debugging, otherwise we might disturb the claude session when in interactive mode
845
+ * - Use info for logs that are useful to the user - this is our UI
846
+ * - File output location: ~/.handy/logs/<date time in local timezone>.log
847
+ */
848
+ declare class Logger {
849
+ readonly logFilePath: string;
850
+ private dangerouslyUnencryptedServerLoggingUrl;
851
+ private latestLogDupPath;
852
+ private initError;
853
+ constructor(logFilePath?: string);
854
+ localTimezoneTimestamp(): string;
855
+ debug(message: string, ...args: unknown[]): void;
856
+ debugLargeJson(message: string, object: unknown, maxStringLength?: number, maxArrayLength?: number): void;
857
+ info(message: string, ...args: unknown[]): void;
858
+ infoDeveloper(message: string, ...args: unknown[]): void;
859
+ warn(message: string, ...args: unknown[]): void;
860
+ getLogPath(): string;
861
+ private logToConsole;
862
+ private sendToRemoteServer;
863
+ private logToFile;
864
+ getInitError(): unknown | undefined;
865
+ }
866
+ declare let logger: Logger;
867
+
868
+ /**
869
+ * Global configuration for happy CLI
870
+ *
871
+ * Centralizes all configuration including environment variables and paths
872
+ * Environment files should be loaded using Node's --env-file flag
873
+ */
874
+ declare class Configuration {
875
+ readonly serverUrl: string;
876
+ readonly isDaemonProcess: boolean;
877
+ readonly isHeadlessMode: boolean;
878
+ readonly happyHomeDir: string;
879
+ readonly logsDir: string;
880
+ readonly settingsFile: string;
881
+ readonly privateKeyFile: string;
882
+ readonly daemonStateFile: string;
883
+ readonly daemonLockFile: string;
884
+ readonly currentCliVersion: string;
885
+ readonly isExperimentalEnabled: boolean;
886
+ constructor();
887
+ }
888
+ declare const configuration: Configuration;
889
+
890
+ export { ApiClient, ApiSessionClient, RawJSONLinesSchema, configuration, logger };
891
+ export type { RawJSONLines };