happy-coder 0.1.7 → 0.1.10

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 (51) hide show
  1. package/dist/index.cjs +950 -938
  2. package/dist/index.mjs +880 -868
  3. package/dist/lib.cjs +32 -0
  4. package/dist/lib.d.cts +527 -0
  5. package/dist/lib.d.mts +527 -0
  6. package/dist/lib.mjs +14 -0
  7. package/dist/types-B2JzqUiU.cjs +831 -0
  8. package/dist/types-DnQGY77F.mjs +818 -0
  9. package/package.json +25 -10
  10. package/dist/auth/auth.d.ts +0 -38
  11. package/dist/auth/auth.js +0 -76
  12. package/dist/auth/auth.test.d.ts +0 -7
  13. package/dist/auth/auth.test.js +0 -96
  14. package/dist/auth/crypto.d.ts +0 -25
  15. package/dist/auth/crypto.js +0 -36
  16. package/dist/claude/claude.d.ts +0 -54
  17. package/dist/claude/claude.js +0 -170
  18. package/dist/claude/claude.test.d.ts +0 -7
  19. package/dist/claude/claude.test.js +0 -130
  20. package/dist/claude/types.d.ts +0 -37
  21. package/dist/claude/types.js +0 -7
  22. package/dist/commands/start.d.ts +0 -38
  23. package/dist/commands/start.js +0 -161
  24. package/dist/commands/start.test.d.ts +0 -7
  25. package/dist/commands/start.test.js +0 -307
  26. package/dist/handlers/message-handler.d.ts +0 -65
  27. package/dist/handlers/message-handler.js +0 -187
  28. package/dist/index.d.ts +0 -1
  29. package/dist/index.js +0 -1
  30. package/dist/session/service.d.ts +0 -27
  31. package/dist/session/service.js +0 -93
  32. package/dist/session/service.test.d.ts +0 -7
  33. package/dist/session/service.test.js +0 -71
  34. package/dist/session/types.d.ts +0 -44
  35. package/dist/session/types.js +0 -4
  36. package/dist/socket/client.d.ts +0 -50
  37. package/dist/socket/client.js +0 -136
  38. package/dist/socket/client.test.d.ts +0 -7
  39. package/dist/socket/client.test.js +0 -74
  40. package/dist/socket/types.d.ts +0 -80
  41. package/dist/socket/types.js +0 -12
  42. package/dist/utils/config.d.ts +0 -22
  43. package/dist/utils/config.js +0 -23
  44. package/dist/utils/logger.d.ts +0 -26
  45. package/dist/utils/logger.js +0 -60
  46. package/dist/utils/paths.d.ts +0 -18
  47. package/dist/utils/paths.js +0 -24
  48. package/dist/utils/qrcode.d.ts +0 -19
  49. package/dist/utils/qrcode.js +0 -37
  50. package/dist/utils/qrcode.test.d.ts +0 -7
  51. package/dist/utils/qrcode.test.js +0 -14
package/dist/lib.d.mts ADDED
@@ -0,0 +1,527 @@
1
+ import { z } from 'zod';
2
+ import { EventEmitter } from 'node:events';
3
+ import { ExpoPushMessage } from 'expo-server-sdk';
4
+
5
+ /**
6
+ * Simplified schema that only validates fields actually used in the codebase
7
+ * while preserving all other fields through passthrough()
8
+ */
9
+
10
+ declare const UsageSchema: z.ZodObject<{
11
+ input_tokens: z.ZodNumber;
12
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
13
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
14
+ output_tokens: z.ZodNumber;
15
+ service_tier: z.ZodOptional<z.ZodString>;
16
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
17
+ input_tokens: z.ZodNumber;
18
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
19
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
20
+ output_tokens: z.ZodNumber;
21
+ service_tier: z.ZodOptional<z.ZodString>;
22
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
23
+ input_tokens: z.ZodNumber;
24
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
25
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
26
+ output_tokens: z.ZodNumber;
27
+ service_tier: z.ZodOptional<z.ZodString>;
28
+ }, z.ZodTypeAny, "passthrough">>;
29
+ declare const RawJSONLinesSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
30
+ type: z.ZodLiteral<"user">;
31
+ isSidechain: z.ZodOptional<z.ZodBoolean>;
32
+ isMeta: z.ZodOptional<z.ZodBoolean>;
33
+ uuid: z.ZodString;
34
+ message: z.ZodObject<{
35
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
36
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
37
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
38
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
39
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
40
+ }, z.ZodTypeAny, "passthrough">>;
41
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
42
+ type: z.ZodLiteral<"user">;
43
+ isSidechain: z.ZodOptional<z.ZodBoolean>;
44
+ isMeta: z.ZodOptional<z.ZodBoolean>;
45
+ uuid: z.ZodString;
46
+ message: z.ZodObject<{
47
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
48
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
49
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
50
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
51
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
52
+ }, z.ZodTypeAny, "passthrough">>;
53
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
54
+ type: z.ZodLiteral<"user">;
55
+ isSidechain: z.ZodOptional<z.ZodBoolean>;
56
+ isMeta: z.ZodOptional<z.ZodBoolean>;
57
+ uuid: z.ZodString;
58
+ message: z.ZodObject<{
59
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
60
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
61
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
62
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
63
+ content: z.ZodUnion<[z.ZodString, z.ZodAny]>;
64
+ }, z.ZodTypeAny, "passthrough">>;
65
+ }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
66
+ type: z.ZodLiteral<"assistant">;
67
+ message: z.ZodObject<{
68
+ usage: z.ZodOptional<z.ZodObject<{
69
+ input_tokens: z.ZodNumber;
70
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
71
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
72
+ output_tokens: z.ZodNumber;
73
+ service_tier: z.ZodOptional<z.ZodString>;
74
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
75
+ input_tokens: z.ZodNumber;
76
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
77
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
78
+ output_tokens: z.ZodNumber;
79
+ service_tier: z.ZodOptional<z.ZodString>;
80
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
81
+ input_tokens: z.ZodNumber;
82
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
83
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
84
+ output_tokens: z.ZodNumber;
85
+ service_tier: z.ZodOptional<z.ZodString>;
86
+ }, z.ZodTypeAny, "passthrough">>>;
87
+ content: z.ZodAny;
88
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
89
+ usage: z.ZodOptional<z.ZodObject<{
90
+ input_tokens: z.ZodNumber;
91
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
92
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
93
+ output_tokens: z.ZodNumber;
94
+ service_tier: z.ZodOptional<z.ZodString>;
95
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
96
+ input_tokens: z.ZodNumber;
97
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
98
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
99
+ output_tokens: z.ZodNumber;
100
+ service_tier: z.ZodOptional<z.ZodString>;
101
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
102
+ input_tokens: z.ZodNumber;
103
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
104
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
105
+ output_tokens: z.ZodNumber;
106
+ service_tier: z.ZodOptional<z.ZodString>;
107
+ }, z.ZodTypeAny, "passthrough">>>;
108
+ content: z.ZodAny;
109
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
110
+ usage: z.ZodOptional<z.ZodObject<{
111
+ input_tokens: z.ZodNumber;
112
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
113
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
114
+ output_tokens: z.ZodNumber;
115
+ service_tier: z.ZodOptional<z.ZodString>;
116
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
117
+ input_tokens: z.ZodNumber;
118
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
119
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
120
+ output_tokens: z.ZodNumber;
121
+ service_tier: z.ZodOptional<z.ZodString>;
122
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
123
+ input_tokens: z.ZodNumber;
124
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
125
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
126
+ output_tokens: z.ZodNumber;
127
+ service_tier: z.ZodOptional<z.ZodString>;
128
+ }, z.ZodTypeAny, "passthrough">>>;
129
+ content: z.ZodAny;
130
+ }, z.ZodTypeAny, "passthrough">>;
131
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
132
+ type: z.ZodLiteral<"assistant">;
133
+ message: z.ZodObject<{
134
+ usage: z.ZodOptional<z.ZodObject<{
135
+ input_tokens: z.ZodNumber;
136
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
137
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
138
+ output_tokens: z.ZodNumber;
139
+ service_tier: z.ZodOptional<z.ZodString>;
140
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
141
+ input_tokens: z.ZodNumber;
142
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
143
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
144
+ output_tokens: z.ZodNumber;
145
+ service_tier: z.ZodOptional<z.ZodString>;
146
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
147
+ input_tokens: z.ZodNumber;
148
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
149
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
150
+ output_tokens: z.ZodNumber;
151
+ service_tier: z.ZodOptional<z.ZodString>;
152
+ }, z.ZodTypeAny, "passthrough">>>;
153
+ content: z.ZodAny;
154
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
155
+ usage: z.ZodOptional<z.ZodObject<{
156
+ input_tokens: z.ZodNumber;
157
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
158
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
159
+ output_tokens: z.ZodNumber;
160
+ service_tier: z.ZodOptional<z.ZodString>;
161
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
162
+ input_tokens: z.ZodNumber;
163
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
164
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
165
+ output_tokens: z.ZodNumber;
166
+ service_tier: z.ZodOptional<z.ZodString>;
167
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
168
+ input_tokens: z.ZodNumber;
169
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
170
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
171
+ output_tokens: z.ZodNumber;
172
+ service_tier: z.ZodOptional<z.ZodString>;
173
+ }, z.ZodTypeAny, "passthrough">>>;
174
+ content: z.ZodAny;
175
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
176
+ usage: z.ZodOptional<z.ZodObject<{
177
+ input_tokens: z.ZodNumber;
178
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
179
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
180
+ output_tokens: z.ZodNumber;
181
+ service_tier: z.ZodOptional<z.ZodString>;
182
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
183
+ input_tokens: z.ZodNumber;
184
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
185
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
186
+ output_tokens: z.ZodNumber;
187
+ service_tier: z.ZodOptional<z.ZodString>;
188
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
189
+ input_tokens: z.ZodNumber;
190
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
191
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
192
+ output_tokens: z.ZodNumber;
193
+ service_tier: z.ZodOptional<z.ZodString>;
194
+ }, z.ZodTypeAny, "passthrough">>>;
195
+ content: z.ZodAny;
196
+ }, z.ZodTypeAny, "passthrough">>;
197
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
198
+ type: z.ZodLiteral<"assistant">;
199
+ message: z.ZodObject<{
200
+ usage: z.ZodOptional<z.ZodObject<{
201
+ input_tokens: z.ZodNumber;
202
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
203
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
204
+ output_tokens: z.ZodNumber;
205
+ service_tier: z.ZodOptional<z.ZodString>;
206
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
207
+ input_tokens: z.ZodNumber;
208
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
209
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
210
+ output_tokens: z.ZodNumber;
211
+ service_tier: z.ZodOptional<z.ZodString>;
212
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
213
+ input_tokens: z.ZodNumber;
214
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
215
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
216
+ output_tokens: z.ZodNumber;
217
+ service_tier: z.ZodOptional<z.ZodString>;
218
+ }, z.ZodTypeAny, "passthrough">>>;
219
+ content: z.ZodAny;
220
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
221
+ usage: z.ZodOptional<z.ZodObject<{
222
+ input_tokens: z.ZodNumber;
223
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
224
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
225
+ output_tokens: z.ZodNumber;
226
+ service_tier: z.ZodOptional<z.ZodString>;
227
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
228
+ input_tokens: z.ZodNumber;
229
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
230
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
231
+ output_tokens: z.ZodNumber;
232
+ service_tier: z.ZodOptional<z.ZodString>;
233
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
234
+ input_tokens: z.ZodNumber;
235
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
236
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
237
+ output_tokens: z.ZodNumber;
238
+ service_tier: z.ZodOptional<z.ZodString>;
239
+ }, z.ZodTypeAny, "passthrough">>>;
240
+ content: z.ZodAny;
241
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
242
+ usage: z.ZodOptional<z.ZodObject<{
243
+ input_tokens: z.ZodNumber;
244
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
245
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
246
+ output_tokens: z.ZodNumber;
247
+ service_tier: z.ZodOptional<z.ZodString>;
248
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
249
+ input_tokens: z.ZodNumber;
250
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
251
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
252
+ output_tokens: z.ZodNumber;
253
+ service_tier: z.ZodOptional<z.ZodString>;
254
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
255
+ input_tokens: z.ZodNumber;
256
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
257
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
258
+ output_tokens: z.ZodNumber;
259
+ service_tier: z.ZodOptional<z.ZodString>;
260
+ }, z.ZodTypeAny, "passthrough">>>;
261
+ content: z.ZodAny;
262
+ }, z.ZodTypeAny, "passthrough">>;
263
+ }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
264
+ type: z.ZodLiteral<"summary">;
265
+ summary: z.ZodString;
266
+ leafUuid: z.ZodString;
267
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
268
+ type: z.ZodLiteral<"summary">;
269
+ summary: z.ZodString;
270
+ leafUuid: z.ZodString;
271
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
272
+ type: z.ZodLiteral<"summary">;
273
+ summary: z.ZodString;
274
+ leafUuid: z.ZodString;
275
+ }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
276
+ type: z.ZodLiteral<"system">;
277
+ uuid: z.ZodString;
278
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
279
+ type: z.ZodLiteral<"system">;
280
+ uuid: z.ZodString;
281
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
282
+ type: z.ZodLiteral<"system">;
283
+ uuid: z.ZodString;
284
+ }, z.ZodTypeAny, "passthrough">>]>;
285
+ type RawJSONLines = z.infer<typeof RawJSONLinesSchema>;
286
+
287
+ /**
288
+ * Usage data type from Claude
289
+ */
290
+ type Usage = z.infer<typeof UsageSchema>;
291
+ /**
292
+ * Session information
293
+ */
294
+ declare const SessionSchema: z.ZodObject<{
295
+ createdAt: z.ZodNumber;
296
+ id: z.ZodString;
297
+ seq: z.ZodNumber;
298
+ updatedAt: z.ZodNumber;
299
+ metadata: z.ZodAny;
300
+ metadataVersion: z.ZodNumber;
301
+ agentState: z.ZodNullable<z.ZodAny>;
302
+ agentStateVersion: z.ZodNumber;
303
+ }, "strip", z.ZodTypeAny, {
304
+ id: string;
305
+ seq: number;
306
+ createdAt: number;
307
+ updatedAt: number;
308
+ metadataVersion: number;
309
+ agentStateVersion: number;
310
+ metadata?: any;
311
+ agentState?: any;
312
+ }, {
313
+ id: string;
314
+ seq: number;
315
+ createdAt: number;
316
+ updatedAt: number;
317
+ metadataVersion: number;
318
+ agentStateVersion: number;
319
+ metadata?: any;
320
+ agentState?: any;
321
+ }>;
322
+ type Session = z.infer<typeof SessionSchema>;
323
+ declare const UserMessageSchema: z.ZodObject<{
324
+ role: z.ZodLiteral<"user">;
325
+ content: z.ZodObject<{
326
+ type: z.ZodLiteral<"text">;
327
+ text: z.ZodString;
328
+ }, "strip", z.ZodTypeAny, {
329
+ type: "text";
330
+ text: string;
331
+ }, {
332
+ type: "text";
333
+ text: string;
334
+ }>;
335
+ localKey: z.ZodOptional<z.ZodString>;
336
+ sentFrom: z.ZodOptional<z.ZodEnum<["mobile", "cli"]>>;
337
+ }, "strip", z.ZodTypeAny, {
338
+ content: {
339
+ type: "text";
340
+ text: string;
341
+ };
342
+ role: "user";
343
+ localKey?: string | undefined;
344
+ sentFrom?: "mobile" | "cli" | undefined;
345
+ }, {
346
+ content: {
347
+ type: "text";
348
+ text: string;
349
+ };
350
+ role: "user";
351
+ localKey?: string | undefined;
352
+ sentFrom?: "mobile" | "cli" | undefined;
353
+ }>;
354
+ type UserMessage = z.infer<typeof UserMessageSchema>;
355
+ type Metadata = {
356
+ path: string;
357
+ host: string;
358
+ version?: string;
359
+ name?: string;
360
+ os?: string;
361
+ summary?: {
362
+ text: string;
363
+ updatedAt: number;
364
+ };
365
+ };
366
+ type AgentState = {
367
+ controlledByUser?: boolean | null | undefined;
368
+ requests?: {
369
+ [id: string]: {
370
+ tool: string;
371
+ arguments: any;
372
+ };
373
+ };
374
+ };
375
+
376
+ type RpcHandler<T = any, R = any> = (data: T) => R | Promise<R>;
377
+ declare class ApiSessionClient extends EventEmitter {
378
+ private readonly token;
379
+ private readonly secret;
380
+ private readonly sessionId;
381
+ private metadata;
382
+ private metadataVersion;
383
+ private agentState;
384
+ private agentStateVersion;
385
+ private socket;
386
+ private pendingMessages;
387
+ private pendingMessageCallback;
388
+ private rpcHandlers;
389
+ constructor(token: string, secret: Uint8Array, session: Session);
390
+ onUserMessage(callback: (data: UserMessage) => void): void;
391
+ /**
392
+ * Send message to session
393
+ * @param body - Message body (can be MessageContent or raw content for agent messages)
394
+ */
395
+ sendClaudeSessionMessage(body: RawJSONLines): void;
396
+ /**
397
+ * Send a ping message to keep the connection alive
398
+ */
399
+ keepAlive(thinking: boolean): void;
400
+ /**
401
+ * Send session death message
402
+ */
403
+ sendSessionDeath(): void;
404
+ /**
405
+ * Send usage data to the server
406
+ */
407
+ sendUsageData(usage: Usage): void;
408
+ /**
409
+ * Update session metadata
410
+ * @param handler - Handler function that returns the updated metadata
411
+ */
412
+ updateMetadata(handler: (metadata: Metadata) => Metadata): void;
413
+ /**
414
+ * Update session agent state
415
+ * @param handler - Handler function that returns the updated agent state
416
+ */
417
+ updateAgentState(handler: (metadata: AgentState) => AgentState): void;
418
+ /**
419
+ * Set a custom RPC handler for a specific method with encrypted arguments and responses
420
+ * @param method - The method name to handle
421
+ * @param handler - The handler function to call when the method is invoked
422
+ */
423
+ setHandler<T = any, R = any>(method: string, handler: RpcHandler<T, R>): void;
424
+ /**
425
+ * Re-register all RPC handlers after reconnection
426
+ */
427
+ private reregisterHandlers;
428
+ /**
429
+ * Wait for socket buffer to flush
430
+ */
431
+ flush(): Promise<void>;
432
+ close(): Promise<void>;
433
+ }
434
+
435
+ interface PushToken {
436
+ id: string;
437
+ token: string;
438
+ createdAt: number;
439
+ updatedAt: number;
440
+ }
441
+ declare class PushNotificationClient {
442
+ private readonly token;
443
+ private readonly baseUrl;
444
+ private readonly expo;
445
+ constructor(token: string, baseUrl?: string);
446
+ /**
447
+ * Fetch all push tokens for the authenticated user
448
+ */
449
+ fetchPushTokens(): Promise<PushToken[]>;
450
+ /**
451
+ * Send push notification via Expo Push API with retry
452
+ * @param messages - Array of push messages to send
453
+ */
454
+ sendPushNotifications(messages: ExpoPushMessage[]): Promise<void>;
455
+ /**
456
+ * Send a push notification to all registered devices for the user
457
+ * @param title - Notification title
458
+ * @param body - Notification body
459
+ * @param data - Additional data to send with the notification
460
+ */
461
+ sendToAllDevices(title: string, body: string, data?: Record<string, any>): Promise<void>;
462
+ }
463
+
464
+ declare class ApiClient {
465
+ private readonly token;
466
+ private readonly secret;
467
+ private readonly pushClient;
468
+ constructor(token: string, secret: Uint8Array);
469
+ /**
470
+ * Create a new session or load existing one with the given tag
471
+ */
472
+ getOrCreateSession(opts: {
473
+ tag: string;
474
+ metadata: Metadata;
475
+ state: AgentState | null;
476
+ }): Promise<Session>;
477
+ /**
478
+ * Start realtime session client
479
+ * @param id - Session ID
480
+ * @returns Session client
481
+ */
482
+ session(session: Session): ApiSessionClient;
483
+ /**
484
+ * Get push notification client
485
+ * @returns Push notification client
486
+ */
487
+ push(): PushNotificationClient;
488
+ }
489
+
490
+ /**
491
+ * Design decisions:
492
+ * - Logging should be done only through file for debugging, otherwise we might disturb the claude session when in interactive mode
493
+ * - Use info for logs that are useful to the user - this is our UI
494
+ * - File output location: ~/.handy/logs/<date time in local timezone>.log
495
+ */
496
+ declare class Logger {
497
+ readonly logFilePathPromise: Promise<string>;
498
+ constructor(logFilePathPromise?: Promise<string>);
499
+ localTimezoneTimestamp(): string;
500
+ debug(message: string, ...args: unknown[]): void;
501
+ debugLargeJson(message: string, object: unknown, maxStringLength?: number, maxArrayLength?: number): void;
502
+ info(message: string, ...args: unknown[]): void;
503
+ infoDeveloper(message: string, ...args: unknown[]): void;
504
+ private logToConsole;
505
+ private logToFile;
506
+ }
507
+ declare let logger: Logger;
508
+ declare function initLoggerWithGlobalConfiguration(): void;
509
+
510
+ /**
511
+ * Global configuration for happy CLI
512
+ *
513
+ * Centralizes all configuration including environment variables and paths
514
+ * Environment files should be loaded using Node's --env-file flag
515
+ */
516
+ declare class Configuration {
517
+ readonly serverUrl: string;
518
+ readonly happyDir: string;
519
+ readonly logsDir: string;
520
+ readonly settingsFile: string;
521
+ readonly privateKeyFile: string;
522
+ constructor(location: 'global' | 'local');
523
+ }
524
+ declare let configuration: Configuration;
525
+ declare function initializeConfiguration(location: 'global' | 'local'): void;
526
+
527
+ export { ApiClient, ApiSessionClient, type RawJSONLines, RawJSONLinesSchema, configuration, initLoggerWithGlobalConfiguration, initializeConfiguration, logger };
package/dist/lib.mjs ADDED
@@ -0,0 +1,14 @@
1
+ export { A as ApiClient, a as ApiSessionClient, R as RawJSONLinesSchema, c as configuration, i as initLoggerWithGlobalConfiguration, b as initializeConfiguration, l as logger } from './types-DnQGY77F.mjs';
2
+ import 'axios';
3
+ import 'chalk';
4
+ import 'fs';
5
+ import 'node:os';
6
+ import 'node:path';
7
+ import 'node:fs/promises';
8
+ import 'node:fs';
9
+ import 'node:events';
10
+ import 'socket.io-client';
11
+ import 'zod';
12
+ import 'node:crypto';
13
+ import 'tweetnacl';
14
+ import 'expo-server-sdk';