happy-coder 0.1.7 → 0.1.9

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 (57) hide show
  1. package/dist/index.cjs +354 -917
  2. package/dist/index.mjs +280 -843
  3. package/dist/install-B2r_gX72.cjs +109 -0
  4. package/dist/install-HKe7dyS4.mjs +107 -0
  5. package/dist/lib.cjs +32 -0
  6. package/dist/lib.d.cts +727 -0
  7. package/dist/lib.d.mts +727 -0
  8. package/dist/lib.mjs +14 -0
  9. package/dist/run-FBXkmmN7.mjs +32 -0
  10. package/dist/run-q2To6b-c.cjs +34 -0
  11. package/dist/types-fXgEaaqP.mjs +861 -0
  12. package/dist/types-mykDX2xe.cjs +872 -0
  13. package/dist/uninstall-C42CoSCI.cjs +53 -0
  14. package/dist/uninstall-CLkTtlMv.mjs +51 -0
  15. package/package.json +25 -10
  16. package/dist/auth/auth.d.ts +0 -38
  17. package/dist/auth/auth.js +0 -76
  18. package/dist/auth/auth.test.d.ts +0 -7
  19. package/dist/auth/auth.test.js +0 -96
  20. package/dist/auth/crypto.d.ts +0 -25
  21. package/dist/auth/crypto.js +0 -36
  22. package/dist/claude/claude.d.ts +0 -54
  23. package/dist/claude/claude.js +0 -170
  24. package/dist/claude/claude.test.d.ts +0 -7
  25. package/dist/claude/claude.test.js +0 -130
  26. package/dist/claude/types.d.ts +0 -37
  27. package/dist/claude/types.js +0 -7
  28. package/dist/commands/start.d.ts +0 -38
  29. package/dist/commands/start.js +0 -161
  30. package/dist/commands/start.test.d.ts +0 -7
  31. package/dist/commands/start.test.js +0 -307
  32. package/dist/handlers/message-handler.d.ts +0 -65
  33. package/dist/handlers/message-handler.js +0 -187
  34. package/dist/index.d.ts +0 -1
  35. package/dist/index.js +0 -1
  36. package/dist/session/service.d.ts +0 -27
  37. package/dist/session/service.js +0 -93
  38. package/dist/session/service.test.d.ts +0 -7
  39. package/dist/session/service.test.js +0 -71
  40. package/dist/session/types.d.ts +0 -44
  41. package/dist/session/types.js +0 -4
  42. package/dist/socket/client.d.ts +0 -50
  43. package/dist/socket/client.js +0 -136
  44. package/dist/socket/client.test.d.ts +0 -7
  45. package/dist/socket/client.test.js +0 -74
  46. package/dist/socket/types.d.ts +0 -80
  47. package/dist/socket/types.js +0 -12
  48. package/dist/utils/config.d.ts +0 -22
  49. package/dist/utils/config.js +0 -23
  50. package/dist/utils/logger.d.ts +0 -26
  51. package/dist/utils/logger.js +0 -60
  52. package/dist/utils/paths.d.ts +0 -18
  53. package/dist/utils/paths.js +0 -24
  54. package/dist/utils/qrcode.d.ts +0 -19
  55. package/dist/utils/qrcode.js +0 -37
  56. package/dist/utils/qrcode.test.d.ts +0 -7
  57. package/dist/utils/qrcode.test.js +0 -14
package/dist/lib.d.cts ADDED
@@ -0,0 +1,727 @@
1
+ import { z } from 'zod';
2
+ import { EventEmitter } from 'node:events';
3
+ import { ExpoPushMessage } from 'expo-server-sdk';
4
+
5
+ /**
6
+ * COPIED FROM https://github.com/ex3ndr/handy/blob/main/sources/sync/claude-code-schema.ts
7
+ * EDIT IN SYNC WITH ORIGINAL
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
+ }, "strip", z.ZodTypeAny, {
17
+ input_tokens: number;
18
+ output_tokens: number;
19
+ cache_creation_input_tokens?: number | undefined;
20
+ cache_read_input_tokens?: number | undefined;
21
+ service_tier?: string | undefined;
22
+ }, {
23
+ input_tokens: number;
24
+ output_tokens: number;
25
+ cache_creation_input_tokens?: number | undefined;
26
+ cache_read_input_tokens?: number | undefined;
27
+ service_tier?: string | undefined;
28
+ }>;
29
+ declare const RawJSONLinesSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
30
+ cwd: z.ZodString;
31
+ sessionId: z.ZodString;
32
+ version: z.ZodString;
33
+ uuid: z.ZodString;
34
+ timestamp: z.ZodString;
35
+ parent_tool_use_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
+ } & {
37
+ type: z.ZodLiteral<"user">;
38
+ message: z.ZodObject<{
39
+ role: z.ZodLiteral<"user">;
40
+ content: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodUnion<[z.ZodObject<{
41
+ tool_use_id: z.ZodString;
42
+ type: z.ZodLiteral<"tool_result">;
43
+ content: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodObject<{
44
+ type: z.ZodLiteral<"text">;
45
+ text: z.ZodString;
46
+ }, "strip", z.ZodTypeAny, {
47
+ type: "text";
48
+ text: string;
49
+ }, {
50
+ type: "text";
51
+ text: string;
52
+ }>, "many">]>;
53
+ is_error: z.ZodOptional<z.ZodBoolean>;
54
+ }, "strip", z.ZodTypeAny, {
55
+ type: "tool_result";
56
+ tool_use_id: string;
57
+ content: string | {
58
+ type: "text";
59
+ text: string;
60
+ }[];
61
+ is_error?: boolean | undefined;
62
+ }, {
63
+ type: "tool_result";
64
+ tool_use_id: string;
65
+ content: string | {
66
+ type: "text";
67
+ text: string;
68
+ }[];
69
+ is_error?: boolean | undefined;
70
+ }>, z.ZodObject<{
71
+ type: z.ZodLiteral<"text">;
72
+ text: z.ZodString;
73
+ }, "strip", z.ZodTypeAny, {
74
+ type: "text";
75
+ text: string;
76
+ }, {
77
+ type: "text";
78
+ text: string;
79
+ }>]>, "many">]>;
80
+ }, "strip", z.ZodTypeAny, {
81
+ content: string | ({
82
+ type: "text";
83
+ text: string;
84
+ } | {
85
+ type: "tool_result";
86
+ tool_use_id: string;
87
+ content: string | {
88
+ type: "text";
89
+ text: string;
90
+ }[];
91
+ is_error?: boolean | undefined;
92
+ })[];
93
+ role: "user";
94
+ }, {
95
+ content: string | ({
96
+ type: "text";
97
+ text: string;
98
+ } | {
99
+ type: "tool_result";
100
+ tool_use_id: string;
101
+ content: string | {
102
+ type: "text";
103
+ text: string;
104
+ }[];
105
+ is_error?: boolean | undefined;
106
+ })[];
107
+ role: "user";
108
+ }>;
109
+ isMeta: z.ZodOptional<z.ZodBoolean>;
110
+ toolUseResult: z.ZodOptional<z.ZodUnknown>;
111
+ }, "strip", z.ZodTypeAny, {
112
+ message: {
113
+ content: string | ({
114
+ type: "text";
115
+ text: string;
116
+ } | {
117
+ type: "tool_result";
118
+ tool_use_id: string;
119
+ content: string | {
120
+ type: "text";
121
+ text: string;
122
+ }[];
123
+ is_error?: boolean | undefined;
124
+ })[];
125
+ role: "user";
126
+ };
127
+ type: "user";
128
+ cwd: string;
129
+ sessionId: string;
130
+ version: string;
131
+ uuid: string;
132
+ timestamp: string;
133
+ parent_tool_use_id?: string | null | undefined;
134
+ isMeta?: boolean | undefined;
135
+ toolUseResult?: unknown;
136
+ }, {
137
+ message: {
138
+ content: string | ({
139
+ type: "text";
140
+ text: string;
141
+ } | {
142
+ type: "tool_result";
143
+ tool_use_id: string;
144
+ content: string | {
145
+ type: "text";
146
+ text: string;
147
+ }[];
148
+ is_error?: boolean | undefined;
149
+ })[];
150
+ role: "user";
151
+ };
152
+ type: "user";
153
+ cwd: string;
154
+ sessionId: string;
155
+ version: string;
156
+ uuid: string;
157
+ timestamp: string;
158
+ parent_tool_use_id?: string | null | undefined;
159
+ isMeta?: boolean | undefined;
160
+ toolUseResult?: unknown;
161
+ }>, z.ZodObject<{
162
+ cwd: z.ZodString;
163
+ sessionId: z.ZodString;
164
+ version: z.ZodString;
165
+ uuid: z.ZodString;
166
+ timestamp: z.ZodString;
167
+ parent_tool_use_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
168
+ } & {
169
+ type: z.ZodLiteral<"assistant">;
170
+ message: z.ZodObject<{
171
+ id: z.ZodString;
172
+ type: z.ZodLiteral<"message">;
173
+ role: z.ZodLiteral<"assistant">;
174
+ model: z.ZodString;
175
+ content: z.ZodArray<z.ZodUnion<[z.ZodObject<{
176
+ type: z.ZodLiteral<"text">;
177
+ text: z.ZodString;
178
+ }, "strip", z.ZodTypeAny, {
179
+ type: "text";
180
+ text: string;
181
+ }, {
182
+ type: "text";
183
+ text: string;
184
+ }>, z.ZodObject<{
185
+ type: z.ZodLiteral<"thinking">;
186
+ thinking: z.ZodString;
187
+ signature: z.ZodString;
188
+ }, "strip", z.ZodTypeAny, {
189
+ type: "thinking";
190
+ thinking: string;
191
+ signature: string;
192
+ }, {
193
+ type: "thinking";
194
+ thinking: string;
195
+ signature: string;
196
+ }>, z.ZodObject<{
197
+ type: z.ZodLiteral<"tool_use">;
198
+ id: z.ZodString;
199
+ name: z.ZodString;
200
+ input: z.ZodUnknown;
201
+ }, "strip", z.ZodTypeAny, {
202
+ type: "tool_use";
203
+ id: string;
204
+ name: string;
205
+ input?: unknown;
206
+ }, {
207
+ type: "tool_use";
208
+ id: string;
209
+ name: string;
210
+ input?: unknown;
211
+ }>, z.ZodObject<{
212
+ tool_use_id: z.ZodString;
213
+ type: z.ZodLiteral<"tool_result">;
214
+ content: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodObject<{
215
+ type: z.ZodLiteral<"text">;
216
+ text: z.ZodString;
217
+ }, "strip", z.ZodTypeAny, {
218
+ type: "text";
219
+ text: string;
220
+ }, {
221
+ type: "text";
222
+ text: string;
223
+ }>, "many">]>;
224
+ is_error: z.ZodOptional<z.ZodBoolean>;
225
+ }, "strip", z.ZodTypeAny, {
226
+ type: "tool_result";
227
+ tool_use_id: string;
228
+ content: string | {
229
+ type: "text";
230
+ text: string;
231
+ }[];
232
+ is_error?: boolean | undefined;
233
+ }, {
234
+ type: "tool_result";
235
+ tool_use_id: string;
236
+ content: string | {
237
+ type: "text";
238
+ text: string;
239
+ }[];
240
+ is_error?: boolean | undefined;
241
+ }>]>, "many">;
242
+ stop_reason: z.ZodNullable<z.ZodString>;
243
+ stop_sequence: z.ZodNullable<z.ZodString>;
244
+ usage: z.ZodObject<{
245
+ input_tokens: z.ZodNumber;
246
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
247
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
248
+ output_tokens: z.ZodNumber;
249
+ service_tier: z.ZodOptional<z.ZodString>;
250
+ }, "strip", z.ZodTypeAny, {
251
+ input_tokens: number;
252
+ output_tokens: number;
253
+ cache_creation_input_tokens?: number | undefined;
254
+ cache_read_input_tokens?: number | undefined;
255
+ service_tier?: string | undefined;
256
+ }, {
257
+ input_tokens: number;
258
+ output_tokens: number;
259
+ cache_creation_input_tokens?: number | undefined;
260
+ cache_read_input_tokens?: number | undefined;
261
+ service_tier?: string | undefined;
262
+ }>;
263
+ }, "strip", z.ZodTypeAny, {
264
+ usage: {
265
+ input_tokens: number;
266
+ output_tokens: number;
267
+ cache_creation_input_tokens?: number | undefined;
268
+ cache_read_input_tokens?: number | undefined;
269
+ service_tier?: string | undefined;
270
+ };
271
+ type: "message";
272
+ id: string;
273
+ content: ({
274
+ type: "text";
275
+ text: string;
276
+ } | {
277
+ type: "thinking";
278
+ thinking: string;
279
+ signature: string;
280
+ } | {
281
+ type: "tool_use";
282
+ id: string;
283
+ name: string;
284
+ input?: unknown;
285
+ } | {
286
+ type: "tool_result";
287
+ tool_use_id: string;
288
+ content: string | {
289
+ type: "text";
290
+ text: string;
291
+ }[];
292
+ is_error?: boolean | undefined;
293
+ })[];
294
+ role: "assistant";
295
+ model: string;
296
+ stop_reason: string | null;
297
+ stop_sequence: string | null;
298
+ }, {
299
+ usage: {
300
+ input_tokens: number;
301
+ output_tokens: number;
302
+ cache_creation_input_tokens?: number | undefined;
303
+ cache_read_input_tokens?: number | undefined;
304
+ service_tier?: string | undefined;
305
+ };
306
+ type: "message";
307
+ id: string;
308
+ content: ({
309
+ type: "text";
310
+ text: string;
311
+ } | {
312
+ type: "thinking";
313
+ thinking: string;
314
+ signature: string;
315
+ } | {
316
+ type: "tool_use";
317
+ id: string;
318
+ name: string;
319
+ input?: unknown;
320
+ } | {
321
+ type: "tool_result";
322
+ tool_use_id: string;
323
+ content: string | {
324
+ type: "text";
325
+ text: string;
326
+ }[];
327
+ is_error?: boolean | undefined;
328
+ })[];
329
+ role: "assistant";
330
+ model: string;
331
+ stop_reason: string | null;
332
+ stop_sequence: string | null;
333
+ }>;
334
+ requestId: z.ZodOptional<z.ZodString>;
335
+ }, "strip", z.ZodTypeAny, {
336
+ message: {
337
+ usage: {
338
+ input_tokens: number;
339
+ output_tokens: number;
340
+ cache_creation_input_tokens?: number | undefined;
341
+ cache_read_input_tokens?: number | undefined;
342
+ service_tier?: string | undefined;
343
+ };
344
+ type: "message";
345
+ id: string;
346
+ content: ({
347
+ type: "text";
348
+ text: string;
349
+ } | {
350
+ type: "thinking";
351
+ thinking: string;
352
+ signature: string;
353
+ } | {
354
+ type: "tool_use";
355
+ id: string;
356
+ name: string;
357
+ input?: unknown;
358
+ } | {
359
+ type: "tool_result";
360
+ tool_use_id: string;
361
+ content: string | {
362
+ type: "text";
363
+ text: string;
364
+ }[];
365
+ is_error?: boolean | undefined;
366
+ })[];
367
+ role: "assistant";
368
+ model: string;
369
+ stop_reason: string | null;
370
+ stop_sequence: string | null;
371
+ };
372
+ type: "assistant";
373
+ cwd: string;
374
+ sessionId: string;
375
+ version: string;
376
+ uuid: string;
377
+ timestamp: string;
378
+ parent_tool_use_id?: string | null | undefined;
379
+ requestId?: string | undefined;
380
+ }, {
381
+ message: {
382
+ usage: {
383
+ input_tokens: number;
384
+ output_tokens: number;
385
+ cache_creation_input_tokens?: number | undefined;
386
+ cache_read_input_tokens?: number | undefined;
387
+ service_tier?: string | undefined;
388
+ };
389
+ type: "message";
390
+ id: string;
391
+ content: ({
392
+ type: "text";
393
+ text: string;
394
+ } | {
395
+ type: "thinking";
396
+ thinking: string;
397
+ signature: string;
398
+ } | {
399
+ type: "tool_use";
400
+ id: string;
401
+ name: string;
402
+ input?: unknown;
403
+ } | {
404
+ type: "tool_result";
405
+ tool_use_id: string;
406
+ content: string | {
407
+ type: "text";
408
+ text: string;
409
+ }[];
410
+ is_error?: boolean | undefined;
411
+ })[];
412
+ role: "assistant";
413
+ model: string;
414
+ stop_reason: string | null;
415
+ stop_sequence: string | null;
416
+ };
417
+ type: "assistant";
418
+ cwd: string;
419
+ sessionId: string;
420
+ version: string;
421
+ uuid: string;
422
+ timestamp: string;
423
+ parent_tool_use_id?: string | null | undefined;
424
+ requestId?: string | undefined;
425
+ }>, z.ZodObject<{
426
+ type: z.ZodLiteral<"summary">;
427
+ summary: z.ZodString;
428
+ leafUuid: z.ZodString;
429
+ }, "strip", z.ZodTypeAny, {
430
+ type: "summary";
431
+ summary: string;
432
+ leafUuid: string;
433
+ }, {
434
+ type: "summary";
435
+ summary: string;
436
+ leafUuid: string;
437
+ }>, z.ZodObject<{
438
+ cwd: z.ZodString;
439
+ sessionId: z.ZodString;
440
+ version: z.ZodString;
441
+ uuid: z.ZodString;
442
+ timestamp: z.ZodString;
443
+ parent_tool_use_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
444
+ } & {
445
+ type: z.ZodLiteral<"system">;
446
+ content: z.ZodString;
447
+ isMeta: z.ZodOptional<z.ZodBoolean>;
448
+ level: z.ZodOptional<z.ZodString>;
449
+ parentUuid: z.ZodOptional<z.ZodString>;
450
+ isSidechain: z.ZodOptional<z.ZodBoolean>;
451
+ userType: z.ZodOptional<z.ZodString>;
452
+ }, "strip", z.ZodTypeAny, {
453
+ type: "system";
454
+ content: string;
455
+ cwd: string;
456
+ sessionId: string;
457
+ version: string;
458
+ uuid: string;
459
+ timestamp: string;
460
+ parent_tool_use_id?: string | null | undefined;
461
+ isMeta?: boolean | undefined;
462
+ level?: string | undefined;
463
+ parentUuid?: string | undefined;
464
+ isSidechain?: boolean | undefined;
465
+ userType?: string | undefined;
466
+ }, {
467
+ type: "system";
468
+ content: string;
469
+ cwd: string;
470
+ sessionId: string;
471
+ version: string;
472
+ uuid: string;
473
+ timestamp: string;
474
+ parent_tool_use_id?: string | null | undefined;
475
+ isMeta?: boolean | undefined;
476
+ level?: string | undefined;
477
+ parentUuid?: string | undefined;
478
+ isSidechain?: boolean | undefined;
479
+ userType?: string | undefined;
480
+ }>]>;
481
+ type RawJSONLines = z.infer<typeof RawJSONLinesSchema>;
482
+
483
+ /**
484
+ * Usage data type from Claude
485
+ */
486
+ type Usage = z.infer<typeof UsageSchema>;
487
+ /**
488
+ * Session information
489
+ */
490
+ declare const SessionSchema: z.ZodObject<{
491
+ createdAt: z.ZodNumber;
492
+ id: z.ZodString;
493
+ seq: z.ZodNumber;
494
+ updatedAt: z.ZodNumber;
495
+ metadata: z.ZodAny;
496
+ metadataVersion: z.ZodNumber;
497
+ agentState: z.ZodNullable<z.ZodAny>;
498
+ agentStateVersion: z.ZodNumber;
499
+ }, "strip", z.ZodTypeAny, {
500
+ id: string;
501
+ seq: number;
502
+ createdAt: number;
503
+ updatedAt: number;
504
+ metadataVersion: number;
505
+ agentStateVersion: number;
506
+ metadata?: any;
507
+ agentState?: any;
508
+ }, {
509
+ id: string;
510
+ seq: number;
511
+ createdAt: number;
512
+ updatedAt: number;
513
+ metadataVersion: number;
514
+ agentStateVersion: number;
515
+ metadata?: any;
516
+ agentState?: any;
517
+ }>;
518
+ type Session = z.infer<typeof SessionSchema>;
519
+ declare const UserMessageSchema: z.ZodObject<{
520
+ role: z.ZodLiteral<"user">;
521
+ content: z.ZodObject<{
522
+ type: z.ZodLiteral<"text">;
523
+ text: z.ZodString;
524
+ }, "strip", z.ZodTypeAny, {
525
+ type: "text";
526
+ text: string;
527
+ }, {
528
+ type: "text";
529
+ text: string;
530
+ }>;
531
+ localKey: z.ZodOptional<z.ZodString>;
532
+ sentFrom: z.ZodOptional<z.ZodEnum<["mobile", "cli"]>>;
533
+ }, "strip", z.ZodTypeAny, {
534
+ content: {
535
+ type: "text";
536
+ text: string;
537
+ };
538
+ role: "user";
539
+ localKey?: string | undefined;
540
+ sentFrom?: "mobile" | "cli" | undefined;
541
+ }, {
542
+ content: {
543
+ type: "text";
544
+ text: string;
545
+ };
546
+ role: "user";
547
+ localKey?: string | undefined;
548
+ sentFrom?: "mobile" | "cli" | undefined;
549
+ }>;
550
+ type UserMessage = z.infer<typeof UserMessageSchema>;
551
+ type Metadata = {
552
+ path: string;
553
+ host: string;
554
+ version?: string;
555
+ name?: string;
556
+ usage?: {
557
+ [model: string]: {
558
+ input?: number;
559
+ input_cache?: number;
560
+ output?: number;
561
+ output_reasoning?: number;
562
+ usd?: number;
563
+ };
564
+ };
565
+ };
566
+ type AgentState = {
567
+ controlledByUser?: boolean | null | undefined;
568
+ requests?: {
569
+ [id: string]: {
570
+ tool: string;
571
+ arguments: any;
572
+ };
573
+ };
574
+ };
575
+
576
+ type RpcHandler<T = any, R = any> = (data: T) => R | Promise<R>;
577
+ declare class ApiSessionClient extends EventEmitter {
578
+ private readonly token;
579
+ private readonly secret;
580
+ private readonly sessionId;
581
+ private metadata;
582
+ private metadataVersion;
583
+ private agentState;
584
+ private agentStateVersion;
585
+ private socket;
586
+ private pendingMessages;
587
+ private pendingMessageCallback;
588
+ private rpcHandlers;
589
+ constructor(token: string, secret: Uint8Array, session: Session);
590
+ onUserMessage(callback: (data: UserMessage) => void): void;
591
+ /**
592
+ * Send message to session
593
+ * @param body - Message body (can be MessageContent or raw content for agent messages)
594
+ */
595
+ sendClaudeSessionMessage(body: RawJSONLines): void;
596
+ /**
597
+ * Send a ping message to keep the connection alive
598
+ */
599
+ keepAlive(thinking: boolean): void;
600
+ /**
601
+ * Send session death message
602
+ */
603
+ sendSessionDeath(): void;
604
+ /**
605
+ * Send usage data to the server
606
+ */
607
+ sendUsageData(usage: Usage): void;
608
+ /**
609
+ * Update session metadata
610
+ * @param handler - Handler function that returns the updated metadata
611
+ */
612
+ updateMetadata(handler: (metadata: Metadata) => Metadata): void;
613
+ /**
614
+ * Update session agent state
615
+ * @param handler - Handler function that returns the updated agent state
616
+ */
617
+ updateAgentState(handler: (metadata: AgentState) => AgentState): void;
618
+ /**
619
+ * Set a custom RPC handler for a specific method with encrypted arguments and responses
620
+ * @param method - The method name to handle
621
+ * @param handler - The handler function to call when the method is invoked
622
+ */
623
+ setHandler<T = any, R = any>(method: string, handler: RpcHandler<T, R>): void;
624
+ /**
625
+ * Re-register all RPC handlers after reconnection
626
+ */
627
+ private reregisterHandlers;
628
+ /**
629
+ * Wait for socket buffer to flush
630
+ */
631
+ flush(): Promise<void>;
632
+ close(): Promise<void>;
633
+ }
634
+
635
+ interface PushToken {
636
+ id: string;
637
+ token: string;
638
+ createdAt: number;
639
+ updatedAt: number;
640
+ }
641
+ declare class PushNotificationClient {
642
+ private readonly token;
643
+ private readonly baseUrl;
644
+ private readonly expo;
645
+ constructor(token: string, baseUrl?: string);
646
+ /**
647
+ * Fetch all push tokens for the authenticated user
648
+ */
649
+ fetchPushTokens(): Promise<PushToken[]>;
650
+ /**
651
+ * Send push notification via Expo Push API with retry
652
+ * @param messages - Array of push messages to send
653
+ */
654
+ sendPushNotifications(messages: ExpoPushMessage[]): Promise<void>;
655
+ /**
656
+ * Send a push notification to all registered devices for the user
657
+ * @param title - Notification title
658
+ * @param body - Notification body
659
+ * @param data - Additional data to send with the notification
660
+ */
661
+ sendToAllDevices(title: string, body: string, data?: Record<string, any>): Promise<void>;
662
+ }
663
+
664
+ declare class ApiClient {
665
+ private readonly token;
666
+ private readonly secret;
667
+ private readonly pushClient;
668
+ constructor(token: string, secret: Uint8Array);
669
+ /**
670
+ * Create a new session or load existing one with the given tag
671
+ */
672
+ getOrCreateSession(opts: {
673
+ tag: string;
674
+ metadata: Metadata;
675
+ state: AgentState | null;
676
+ }): Promise<Session>;
677
+ /**
678
+ * Start realtime session client
679
+ * @param id - Session ID
680
+ * @returns Session client
681
+ */
682
+ session(session: Session): ApiSessionClient;
683
+ /**
684
+ * Get push notification client
685
+ * @returns Push notification client
686
+ */
687
+ push(): PushNotificationClient;
688
+ }
689
+
690
+ /**
691
+ * Design decisions:
692
+ * - Logging should be done only through file for debugging, otherwise we might disturb the claude session when in interactive mode
693
+ * - Use info for logs that are useful to the user - this is our UI
694
+ * - File output location: ~/.handy/logs/<date time in local timezone>.log
695
+ */
696
+ declare class Logger {
697
+ readonly logFilePathPromise: Promise<string>;
698
+ constructor(logFilePathPromise?: Promise<string>);
699
+ localTimezoneTimestamp(): string;
700
+ debug(message: string, ...args: unknown[]): void;
701
+ debugLargeJson(message: string, object: unknown, maxStringLength?: number, maxArrayLength?: number): void;
702
+ info(message: string, ...args: unknown[]): void;
703
+ infoDeveloper(message: string, ...args: unknown[]): void;
704
+ private logToConsole;
705
+ private logToFile;
706
+ }
707
+ declare let logger: Logger;
708
+ declare function initLoggerWithGlobalConfiguration(): void;
709
+
710
+ /**
711
+ * Global configuration for happy CLI
712
+ *
713
+ * Centralizes all configuration including environment variables and paths
714
+ * Environment files should be loaded using Node's --env-file flag
715
+ */
716
+ declare class Configuration {
717
+ readonly serverUrl: string;
718
+ readonly happyDir: string;
719
+ readonly logsDir: string;
720
+ readonly settingsFile: string;
721
+ readonly privateKeyFile: string;
722
+ constructor(location: 'global' | 'local');
723
+ }
724
+ declare let configuration: Configuration;
725
+ declare function initializeConfiguration(location: 'global' | 'local'): void;
726
+
727
+ export { ApiClient, ApiSessionClient, type RawJSONLines, RawJSONLinesSchema, configuration, initLoggerWithGlobalConfiguration, initializeConfiguration, logger };