zenflo 0.11.2

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 (43) hide show
  1. package/README.md +60 -0
  2. package/bin/zenflo-mcp.mjs +32 -0
  3. package/bin/zenflo.mjs +35 -0
  4. package/dist/codex/happyMcpStdioBridge.cjs +107 -0
  5. package/dist/codex/happyMcpStdioBridge.d.cts +2 -0
  6. package/dist/codex/happyMcpStdioBridge.d.mts +2 -0
  7. package/dist/codex/happyMcpStdioBridge.mjs +105 -0
  8. package/dist/index-CHuQvfiV.cjs +6175 -0
  9. package/dist/index-DOSJeDVm.mjs +6145 -0
  10. package/dist/index.cjs +41 -0
  11. package/dist/index.d.cts +1 -0
  12. package/dist/index.d.mts +1 -0
  13. package/dist/index.mjs +38 -0
  14. package/dist/lib.cjs +31 -0
  15. package/dist/lib.d.cts +825 -0
  16. package/dist/lib.d.mts +825 -0
  17. package/dist/lib.mjs +21 -0
  18. package/dist/runCodex-4WtZDlEl.cjs +1337 -0
  19. package/dist/runCodex-CLOGxmC3.mjs +1334 -0
  20. package/dist/types-D5e0nXc5.cjs +2221 -0
  21. package/dist/types-qUJrSxtv.mjs +2175 -0
  22. package/package.json +125 -0
  23. package/scripts/claude_local_launcher.cjs +98 -0
  24. package/scripts/claude_remote_launcher.cjs +13 -0
  25. package/scripts/ripgrep_launcher.cjs +33 -0
  26. package/scripts/unpack-tools.cjs +163 -0
  27. package/tools/archives/difftastic-LICENSE +21 -0
  28. package/tools/archives/difftastic-arm64-darwin.tar.gz +0 -0
  29. package/tools/archives/difftastic-arm64-linux.tar.gz +0 -0
  30. package/tools/archives/difftastic-x64-darwin.tar.gz +0 -0
  31. package/tools/archives/difftastic-x64-linux.tar.gz +0 -0
  32. package/tools/archives/difftastic-x64-win32.tar.gz +0 -0
  33. package/tools/archives/ripgrep-LICENSE +3 -0
  34. package/tools/archives/ripgrep-arm64-darwin.tar.gz +0 -0
  35. package/tools/archives/ripgrep-arm64-linux.tar.gz +0 -0
  36. package/tools/archives/ripgrep-x64-darwin.tar.gz +0 -0
  37. package/tools/archives/ripgrep-x64-linux.tar.gz +0 -0
  38. package/tools/archives/ripgrep-x64-win32.tar.gz +0 -0
  39. package/tools/licenses/difftastic-LICENSE +21 -0
  40. package/tools/licenses/ripgrep-LICENSE +3 -0
  41. package/tools/unpacked/difft +0 -0
  42. package/tools/unpacked/rg +0 -0
  43. package/tools/unpacked/ripgrep.node +0 -0
package/dist/lib.d.cts ADDED
@@ -0,0 +1,825 @@
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
+ scopePrefix: string;
312
+ encryptionKey: Uint8Array;
313
+ encryptionVariant: 'legacy' | 'dataKey';
314
+ logger?: (message: string, data?: any) => void;
315
+ }
316
+
317
+ /**
318
+ * Generic RPC handler manager for session and machine clients
319
+ * Manages RPC method registration, encryption/decryption, and handler execution
320
+ */
321
+
322
+ declare class RpcHandlerManager {
323
+ private handlers;
324
+ private readonly scopePrefix;
325
+ private readonly encryptionKey;
326
+ private readonly encryptionVariant;
327
+ private readonly logger;
328
+ private socket;
329
+ constructor(config: RpcHandlerConfig);
330
+ /**
331
+ * Register an RPC handler for a specific method
332
+ * @param method - The method name (without prefix)
333
+ * @param handler - The handler function
334
+ */
335
+ registerHandler<TRequest = any, TResponse = any>(method: string, handler: RpcHandler<TRequest, TResponse>): void;
336
+ /**
337
+ * Handle an incoming RPC request
338
+ * @param request - The RPC request data
339
+ * @param callback - The response callback
340
+ */
341
+ handleRequest(request: RpcRequest): Promise<any>;
342
+ onSocketConnect(socket: Socket): void;
343
+ onSocketDisconnect(): void;
344
+ /**
345
+ * Get the number of registered handlers
346
+ */
347
+ getHandlerCount(): number;
348
+ /**
349
+ * Check if a handler is registered
350
+ * @param method - The method name (without prefix)
351
+ */
352
+ hasHandler(method: string): boolean;
353
+ /**
354
+ * Clear all handlers
355
+ */
356
+ clearHandlers(): void;
357
+ /**
358
+ * Get the prefixed method name
359
+ * @param method - The method name
360
+ */
361
+ private getPrefixedMethod;
362
+ }
363
+
364
+ declare class ApiSessionClient extends EventEmitter {
365
+ private readonly token;
366
+ readonly sessionId: string;
367
+ private metadata;
368
+ private metadataVersion;
369
+ private agentState;
370
+ private agentStateVersion;
371
+ private socket;
372
+ private pendingMessages;
373
+ private pendingMessageCallback;
374
+ readonly rpcHandlerManager: RpcHandlerManager;
375
+ private agentStateLock;
376
+ private metadataLock;
377
+ private encryptionKey;
378
+ private encryptionVariant;
379
+ constructor(token: string, 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
+ sendSessionEvent(event: {
388
+ type: 'switch';
389
+ mode: 'local' | 'remote';
390
+ } | {
391
+ type: 'message';
392
+ message: string;
393
+ } | {
394
+ type: 'permission-mode-changed';
395
+ mode: 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
396
+ } | {
397
+ type: 'ready';
398
+ }, id?: string): void;
399
+ /**
400
+ * Send a ping message to keep the connection alive
401
+ */
402
+ keepAlive(thinking: boolean, mode: 'local' | 'remote'): void;
403
+ /**
404
+ * Send session death message
405
+ */
406
+ sendSessionDeath(): void;
407
+ /**
408
+ * Send usage data to the server
409
+ */
410
+ sendUsageData(usage: Usage): void;
411
+ /**
412
+ * Update session metadata
413
+ * @param handler - Handler function that returns the updated metadata
414
+ */
415
+ updateMetadata(handler: (metadata: Metadata) => Metadata): void;
416
+ /**
417
+ * Update session agent state
418
+ * @param handler - Handler function that returns the updated agent state
419
+ */
420
+ updateAgentState(handler: (metadata: AgentState) => AgentState): void;
421
+ /**
422
+ * Wait for socket buffer to flush
423
+ */
424
+ flush(): Promise<void>;
425
+ close(): Promise<void>;
426
+ }
427
+
428
+ type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
429
+
430
+ /**
431
+ * Usage data type from Claude
432
+ */
433
+ type Usage = z.infer<typeof UsageSchema>;
434
+ /**
435
+ * Session information
436
+ */
437
+ type Session = {
438
+ id: string;
439
+ seq: number;
440
+ encryptionKey: Uint8Array;
441
+ encryptionVariant: 'legacy' | 'dataKey';
442
+ metadata: Metadata;
443
+ metadataVersion: number;
444
+ agentState: AgentState | null;
445
+ agentStateVersion: number;
446
+ };
447
+ /**
448
+ * Machine metadata - static information (rarely changes)
449
+ */
450
+ declare const MachineMetadataSchema: z.ZodObject<{
451
+ host: z.ZodString;
452
+ platform: z.ZodString;
453
+ happyCliVersion: z.ZodString;
454
+ homeDir: z.ZodString;
455
+ happyHomeDir: z.ZodString;
456
+ happyLibDir: z.ZodString;
457
+ }, "strip", z.ZodTypeAny, {
458
+ host: string;
459
+ platform: string;
460
+ happyCliVersion: string;
461
+ homeDir: string;
462
+ happyHomeDir: string;
463
+ happyLibDir: string;
464
+ }, {
465
+ host: string;
466
+ platform: string;
467
+ happyCliVersion: string;
468
+ homeDir: string;
469
+ happyHomeDir: string;
470
+ happyLibDir: string;
471
+ }>;
472
+ type MachineMetadata = z.infer<typeof MachineMetadataSchema>;
473
+ /**
474
+ * Daemon state - dynamic runtime information (frequently updated)
475
+ */
476
+ declare const DaemonStateSchema: z.ZodObject<{
477
+ status: z.ZodUnion<[z.ZodEnum<["running", "shutting-down"]>, z.ZodString]>;
478
+ pid: z.ZodOptional<z.ZodNumber>;
479
+ httpPort: z.ZodOptional<z.ZodNumber>;
480
+ startedAt: z.ZodOptional<z.ZodNumber>;
481
+ shutdownRequestedAt: z.ZodOptional<z.ZodNumber>;
482
+ shutdownSource: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["mobile-app", "cli", "os-signal", "unknown"]>, z.ZodString]>>;
483
+ }, "strip", z.ZodTypeAny, {
484
+ status: string;
485
+ pid?: number | undefined;
486
+ httpPort?: number | undefined;
487
+ startedAt?: number | undefined;
488
+ shutdownRequestedAt?: number | undefined;
489
+ shutdownSource?: string | undefined;
490
+ }, {
491
+ status: string;
492
+ pid?: number | undefined;
493
+ httpPort?: number | undefined;
494
+ startedAt?: number | undefined;
495
+ shutdownRequestedAt?: number | undefined;
496
+ shutdownSource?: string | undefined;
497
+ }>;
498
+ type DaemonState = z.infer<typeof DaemonStateSchema>;
499
+ type Machine = {
500
+ id: string;
501
+ encryptionKey: Uint8Array;
502
+ encryptionVariant: 'legacy' | 'dataKey';
503
+ metadata: MachineMetadata;
504
+ metadataVersion: number;
505
+ daemonState: DaemonState | null;
506
+ daemonStateVersion: number;
507
+ };
508
+ declare const UserMessageSchema: z.ZodObject<{
509
+ role: z.ZodLiteral<"user">;
510
+ content: z.ZodObject<{
511
+ type: z.ZodLiteral<"text">;
512
+ text: z.ZodString;
513
+ }, "strip", z.ZodTypeAny, {
514
+ type: "text";
515
+ text: string;
516
+ }, {
517
+ type: "text";
518
+ text: string;
519
+ }>;
520
+ localKey: z.ZodOptional<z.ZodString>;
521
+ meta: z.ZodOptional<z.ZodObject<{
522
+ sentFrom: z.ZodOptional<z.ZodString>;
523
+ permissionMode: z.ZodOptional<z.ZodString>;
524
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
525
+ fallbackModel: z.ZodOptional<z.ZodNullable<z.ZodString>>;
526
+ customSystemPrompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
527
+ appendSystemPrompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
528
+ allowedTools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
529
+ disallowedTools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
530
+ }, "strip", z.ZodTypeAny, {
531
+ sentFrom?: string | undefined;
532
+ permissionMode?: string | undefined;
533
+ model?: string | null | undefined;
534
+ fallbackModel?: string | null | undefined;
535
+ customSystemPrompt?: string | null | undefined;
536
+ appendSystemPrompt?: string | null | undefined;
537
+ allowedTools?: string[] | null | undefined;
538
+ disallowedTools?: string[] | null | undefined;
539
+ }, {
540
+ sentFrom?: string | undefined;
541
+ permissionMode?: string | undefined;
542
+ model?: string | null | undefined;
543
+ fallbackModel?: string | null | undefined;
544
+ customSystemPrompt?: string | null | undefined;
545
+ appendSystemPrompt?: string | null | undefined;
546
+ allowedTools?: string[] | null | undefined;
547
+ disallowedTools?: string[] | null | undefined;
548
+ }>>;
549
+ }, "strip", z.ZodTypeAny, {
550
+ content: {
551
+ type: "text";
552
+ text: string;
553
+ };
554
+ role: "user";
555
+ localKey?: string | undefined;
556
+ meta?: {
557
+ sentFrom?: string | undefined;
558
+ permissionMode?: string | undefined;
559
+ model?: string | null | undefined;
560
+ fallbackModel?: string | null | undefined;
561
+ customSystemPrompt?: string | null | undefined;
562
+ appendSystemPrompt?: string | null | undefined;
563
+ allowedTools?: string[] | null | undefined;
564
+ disallowedTools?: string[] | null | undefined;
565
+ } | undefined;
566
+ }, {
567
+ content: {
568
+ type: "text";
569
+ text: string;
570
+ };
571
+ role: "user";
572
+ localKey?: string | undefined;
573
+ meta?: {
574
+ sentFrom?: string | undefined;
575
+ permissionMode?: string | undefined;
576
+ model?: string | null | undefined;
577
+ fallbackModel?: string | null | undefined;
578
+ customSystemPrompt?: string | null | undefined;
579
+ appendSystemPrompt?: string | null | undefined;
580
+ allowedTools?: string[] | null | undefined;
581
+ disallowedTools?: string[] | null | undefined;
582
+ } | undefined;
583
+ }>;
584
+ type UserMessage = z.infer<typeof UserMessageSchema>;
585
+ type Metadata = {
586
+ path: string;
587
+ host: string;
588
+ version?: string;
589
+ name?: string;
590
+ os?: string;
591
+ summary?: {
592
+ text: string;
593
+ updatedAt: number;
594
+ };
595
+ machineId?: string;
596
+ claudeSessionId?: string;
597
+ tools?: string[];
598
+ slashCommands?: string[];
599
+ homeDir: string;
600
+ happyHomeDir: string;
601
+ happyLibDir: string;
602
+ happyToolsDir: string;
603
+ startedFromDaemon?: boolean;
604
+ hostPid?: number;
605
+ startedBy?: 'daemon' | 'terminal';
606
+ lifecycleState?: 'running' | 'archiveRequested' | 'archived' | string;
607
+ lifecycleStateSince?: number;
608
+ archivedBy?: string;
609
+ archiveReason?: string;
610
+ flavor?: string;
611
+ };
612
+ type AgentState = {
613
+ controlledByUser?: boolean | null | undefined;
614
+ requests?: {
615
+ [id: string]: {
616
+ tool: string;
617
+ arguments: any;
618
+ createdAt: number;
619
+ };
620
+ };
621
+ completedRequests?: {
622
+ [id: string]: {
623
+ tool: string;
624
+ arguments: any;
625
+ createdAt: number;
626
+ completedAt: number;
627
+ status: 'canceled' | 'denied' | 'approved';
628
+ reason?: string;
629
+ mode?: PermissionMode;
630
+ decision?: 'approved' | 'approved_for_session' | 'denied' | 'abort';
631
+ allowTools?: string[];
632
+ };
633
+ };
634
+ };
635
+
636
+ interface SpawnSessionOptions {
637
+ machineId?: string;
638
+ directory: string;
639
+ sessionId?: string;
640
+ approvedNewDirectoryCreation?: boolean;
641
+ agent?: 'claude' | 'codex';
642
+ token?: string;
643
+ }
644
+ type SpawnSessionResult = {
645
+ type: 'success';
646
+ sessionId: string;
647
+ } | {
648
+ type: 'requestToApproveDirectoryCreation';
649
+ directory: string;
650
+ } | {
651
+ type: 'error';
652
+ errorMessage: string;
653
+ };
654
+
655
+ /**
656
+ * WebSocket client for machine/daemon communication with Happy server
657
+ * Similar to ApiSessionClient but for machine-scoped connections
658
+ */
659
+
660
+ type MachineRpcHandlers = {
661
+ spawnSession: (options: SpawnSessionOptions) => Promise<SpawnSessionResult>;
662
+ stopSession: (sessionId: string) => boolean;
663
+ requestShutdown: () => void;
664
+ };
665
+ declare class ApiMachineClient {
666
+ private token;
667
+ private machine;
668
+ private socket;
669
+ private keepAliveInterval;
670
+ private rpcHandlerManager;
671
+ constructor(token: string, machine: Machine);
672
+ setRPCHandlers({ spawnSession, stopSession, requestShutdown }: MachineRpcHandlers): void;
673
+ /**
674
+ * Update machine metadata
675
+ * Currently unused, changes from the mobile client are more likely
676
+ * for example to set a custom name.
677
+ */
678
+ updateMachineMetadata(handler: (metadata: MachineMetadata | null) => MachineMetadata): Promise<void>;
679
+ /**
680
+ * Update daemon state (runtime info) - similar to session updateAgentState
681
+ * Simplified without lock - relies on backoff for retry
682
+ */
683
+ updateDaemonState(handler: (state: DaemonState | null) => DaemonState): Promise<void>;
684
+ connect(): void;
685
+ private startKeepAlive;
686
+ private stopKeepAlive;
687
+ shutdown(): void;
688
+ }
689
+
690
+ interface PushToken {
691
+ id: string;
692
+ token: string;
693
+ createdAt: number;
694
+ updatedAt: number;
695
+ }
696
+ declare class PushNotificationClient {
697
+ private readonly token;
698
+ private readonly baseUrl;
699
+ private readonly expo;
700
+ constructor(token: string, baseUrl?: string);
701
+ /**
702
+ * Fetch all push tokens for the authenticated user
703
+ */
704
+ fetchPushTokens(): Promise<PushToken[]>;
705
+ /**
706
+ * Send push notification via Expo Push API with retry
707
+ * @param messages - Array of push messages to send
708
+ */
709
+ sendPushNotifications(messages: ExpoPushMessage[]): Promise<void>;
710
+ /**
711
+ * Send a push notification to all registered devices for the user
712
+ * @param title - Notification title
713
+ * @param body - Notification body
714
+ * @param data - Additional data to send with the notification
715
+ */
716
+ sendToAllDevices(title: string, body: string, data?: Record<string, any>): void;
717
+ }
718
+
719
+ /**
720
+ * Minimal persistence functions for happy CLI
721
+ *
722
+ * Handles settings and private key storage in ~/.happy/ or local .happy/
723
+ */
724
+
725
+ type Credentials = {
726
+ token: string;
727
+ encryption: {
728
+ type: 'legacy';
729
+ secret: Uint8Array;
730
+ } | {
731
+ type: 'dataKey';
732
+ publicKey: Uint8Array;
733
+ machineKey: Uint8Array;
734
+ };
735
+ };
736
+
737
+ declare class ApiClient {
738
+ static create(credential: Credentials): Promise<ApiClient>;
739
+ private readonly credential;
740
+ private readonly pushClient;
741
+ private constructor();
742
+ /**
743
+ * Create a new session or load existing one with the given tag
744
+ */
745
+ getOrCreateSession(opts: {
746
+ tag: string;
747
+ metadata: Metadata;
748
+ state: AgentState | null;
749
+ }): Promise<Session>;
750
+ /**
751
+ * Register or update machine with the server
752
+ * Returns the current machine state from the server with decrypted metadata and daemonState
753
+ */
754
+ getOrCreateMachine(opts: {
755
+ machineId: string;
756
+ metadata: MachineMetadata;
757
+ daemonState?: DaemonState;
758
+ }): Promise<Machine>;
759
+ sessionSyncClient(session: Session): ApiSessionClient;
760
+ machineSyncClient(machine: Machine): ApiMachineClient;
761
+ push(): PushNotificationClient;
762
+ /**
763
+ * Register a vendor API token with the server
764
+ * The token is sent as a JSON string - server handles encryption
765
+ */
766
+ registerVendorToken(vendor: 'openai' | 'anthropic' | 'gemini', apiKey: any): Promise<void>;
767
+ /**
768
+ * Send a Claude message to user's inbox
769
+ */
770
+ sendInboxMessage(opts: {
771
+ title: string;
772
+ message: string;
773
+ sessionId?: string;
774
+ priority?: 'low' | 'normal' | 'high';
775
+ }): Promise<void>;
776
+ }
777
+
778
+ /**
779
+ * Design decisions:
780
+ * - Logging should be done only through file for debugging, otherwise we might disturb the claude session when in interactive mode
781
+ * - Use info for logs that are useful to the user - this is our UI
782
+ * - File output location: ~/.handy/logs/<date time in local timezone>.log
783
+ */
784
+ declare class Logger {
785
+ readonly logFilePath: string;
786
+ private dangerouslyUnencryptedServerLoggingUrl;
787
+ constructor(logFilePath?: string);
788
+ localTimezoneTimestamp(): string;
789
+ debug(message: string, ...args: unknown[]): void;
790
+ debugLargeJson(message: string, object: unknown, maxStringLength?: number, maxArrayLength?: number): void;
791
+ info(message: string, ...args: unknown[]): void;
792
+ infoDeveloper(message: string, ...args: unknown[]): void;
793
+ warn(message: string, ...args: unknown[]): void;
794
+ getLogPath(): string;
795
+ private logToConsole;
796
+ private sendToRemoteServer;
797
+ private logToFile;
798
+ }
799
+ declare let logger: Logger;
800
+
801
+ /**
802
+ * Global configuration for happy CLI
803
+ *
804
+ * Centralizes all configuration including environment variables and paths
805
+ * Environment files should be loaded using Node's --env-file flag
806
+ */
807
+ declare class Configuration {
808
+ readonly serverUrl: string;
809
+ readonly webappUrl: string;
810
+ readonly isDaemonProcess: boolean;
811
+ readonly happyHomeDir: string;
812
+ readonly logsDir: string;
813
+ readonly settingsFile: string;
814
+ readonly privateKeyFile: string;
815
+ readonly daemonStateFile: string;
816
+ readonly daemonLockFile: string;
817
+ readonly currentCliVersion: string;
818
+ readonly isExperimentalEnabled: boolean;
819
+ readonly disableCaffeinate: boolean;
820
+ constructor();
821
+ }
822
+ declare const configuration: Configuration;
823
+
824
+ export { ApiClient, ApiSessionClient, RawJSONLinesSchema, configuration, logger };
825
+ export type { RawJSONLines };