happy-coder 0.10.0-2 → 0.10.0-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/bin/happy-mcp.mjs +32 -0
- package/dist/codex/happyMcpStdioBridge.cjs +80 -0
- package/dist/codex/happyMcpStdioBridge.d.cts +2 -0
- package/dist/codex/happyMcpStdioBridge.d.mts +2 -0
- package/dist/codex/happyMcpStdioBridge.mjs +78 -0
- package/dist/index-67rskwL7.cjs +6033 -0
- package/dist/index-Dw96QD4T.mjs +6025 -0
- package/dist/index.cjs +33 -6024
- package/dist/index.mjs +33 -6024
- package/dist/lib.cjs +2 -1
- package/dist/lib.d.cts +54 -112
- package/dist/lib.d.mts +54 -112
- package/dist/lib.mjs +2 -1
- package/dist/runCodex-BLNf5zb1.cjs +1155 -0
- package/dist/runCodex-BNH8w4O9.mjs +1153 -0
- package/dist/{types-xfXKJHdM.mjs → types-2wHnX7UW.mjs} +311 -170
- package/dist/{types-WP9wteZE.cjs → types-BcDnTXMg.cjs} +348 -206
- package/package.json +20 -6
- package/scripts/ripgrep_launcher.cjs +2 -26
- package/scripts/unpack-tools.cjs +163 -0
- package/tools/archives/difftastic-LICENSE +21 -0
- package/tools/archives/difftastic-arm64-darwin.tar.gz +0 -0
- package/tools/archives/difftastic-arm64-linux.tar.gz +0 -0
- package/tools/archives/difftastic-x64-darwin.tar.gz +0 -0
- package/tools/archives/difftastic-x64-linux.tar.gz +0 -0
- package/tools/archives/difftastic-x64-win32.tar.gz +0 -0
- package/tools/archives/ripgrep-arm64-darwin.tar.gz +0 -0
- package/tools/archives/ripgrep-arm64-linux.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-darwin.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-linux.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-win32.tar.gz +0 -0
- package/tools/licenses/difftastic-LICENSE +21 -0
- package/tools/licenses/ripgrep-LICENSE +3 -0
- package/tools/unpacked/difft +0 -0
- package/ripgrep/arm64-linux/rg +0 -0
- package/ripgrep/arm64-linux/ripgrep.node +0 -0
- package/ripgrep/x64-darwin/rg +0 -0
- package/ripgrep/x64-darwin/ripgrep.node +0 -0
- package/ripgrep/x64-linux/rg +0 -0
- package/ripgrep/x64-linux/ripgrep.node +0 -0
- package/ripgrep/x64-win32/rg.exe +0 -0
- package/ripgrep/x64-win32/ripgrep.node +0 -0
- /package/{ripgrep/COPYING → tools/archives/ripgrep-LICENSE} +0 -0
- /package/{ripgrep/arm64-darwin → tools/unpacked}/rg +0 -0
- /package/{ripgrep/arm64-darwin → tools/unpacked}/ripgrep.node +0 -0
package/dist/lib.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var types = require('./types-
|
|
3
|
+
var types = require('./types-BcDnTXMg.cjs');
|
|
4
4
|
require('axios');
|
|
5
5
|
require('chalk');
|
|
6
6
|
require('fs');
|
|
@@ -19,6 +19,7 @@ require('fs/promises');
|
|
|
19
19
|
require('crypto');
|
|
20
20
|
require('path');
|
|
21
21
|
require('url');
|
|
22
|
+
require('os');
|
|
22
23
|
require('expo-server-sdk');
|
|
23
24
|
|
|
24
25
|
|
package/dist/lib.d.cts
CHANGED
|
@@ -308,11 +308,9 @@ interface RpcRequest {
|
|
|
308
308
|
* Configuration for RPC handler manager
|
|
309
309
|
*/
|
|
310
310
|
interface RpcHandlerConfig {
|
|
311
|
-
/** Prefix to add to all method names (e.g., sessionId or machineId) */
|
|
312
311
|
scopePrefix: string;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
/** Logger function for debugging */
|
|
312
|
+
encryptionKey: Uint8Array;
|
|
313
|
+
encryptionVariant: 'legacy' | 'dataKey';
|
|
316
314
|
logger?: (message: string, data?: any) => void;
|
|
317
315
|
}
|
|
318
316
|
|
|
@@ -324,7 +322,8 @@ interface RpcHandlerConfig {
|
|
|
324
322
|
declare class RpcHandlerManager {
|
|
325
323
|
private handlers;
|
|
326
324
|
private readonly scopePrefix;
|
|
327
|
-
private readonly
|
|
325
|
+
private readonly encryptionKey;
|
|
326
|
+
private readonly encryptionVariant;
|
|
328
327
|
private readonly logger;
|
|
329
328
|
private socket;
|
|
330
329
|
constructor(config: RpcHandlerConfig);
|
|
@@ -364,7 +363,6 @@ declare class RpcHandlerManager {
|
|
|
364
363
|
|
|
365
364
|
declare class ApiSessionClient extends EventEmitter {
|
|
366
365
|
private readonly token;
|
|
367
|
-
private readonly secret;
|
|
368
366
|
readonly sessionId: string;
|
|
369
367
|
private metadata;
|
|
370
368
|
private metadataVersion;
|
|
@@ -376,13 +374,16 @@ declare class ApiSessionClient extends EventEmitter {
|
|
|
376
374
|
readonly rpcHandlerManager: RpcHandlerManager;
|
|
377
375
|
private agentStateLock;
|
|
378
376
|
private metadataLock;
|
|
379
|
-
|
|
377
|
+
private encryptionKey;
|
|
378
|
+
private encryptionVariant;
|
|
379
|
+
constructor(token: string, session: Session);
|
|
380
380
|
onUserMessage(callback: (data: UserMessage) => void): void;
|
|
381
381
|
/**
|
|
382
382
|
* Send message to session
|
|
383
383
|
* @param body - Message body (can be MessageContent or raw content for agent messages)
|
|
384
384
|
*/
|
|
385
385
|
sendClaudeSessionMessage(body: RawJSONLines): void;
|
|
386
|
+
sendCodexMessage(body: any): void;
|
|
386
387
|
sendSessionEvent(event: {
|
|
387
388
|
type: 'switch';
|
|
388
389
|
mode: 'local' | 'remote';
|
|
@@ -433,53 +434,16 @@ type Usage = z.infer<typeof UsageSchema>;
|
|
|
433
434
|
/**
|
|
434
435
|
* Session information
|
|
435
436
|
*/
|
|
436
|
-
|
|
437
|
-
createdAt: z.ZodNumber;
|
|
438
|
-
id: z.ZodString;
|
|
439
|
-
seq: z.ZodNumber;
|
|
440
|
-
updatedAt: z.ZodNumber;
|
|
441
|
-
metadata: z.ZodAny;
|
|
442
|
-
metadataVersion: z.ZodNumber;
|
|
443
|
-
agentState: z.ZodNullable<z.ZodAny>;
|
|
444
|
-
agentStateVersion: z.ZodNumber;
|
|
445
|
-
connectivityStatus: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["neverConnected", "online", "offline"]>, z.ZodString]>>;
|
|
446
|
-
connectivityStatusSince: z.ZodOptional<z.ZodNumber>;
|
|
447
|
-
connectivityStatusReason: z.ZodOptional<z.ZodString>;
|
|
448
|
-
state: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["running", "archiveRequested", "archived"]>, z.ZodString]>>;
|
|
449
|
-
stateSince: z.ZodOptional<z.ZodNumber>;
|
|
450
|
-
stateReason: z.ZodOptional<z.ZodString>;
|
|
451
|
-
}, "strip", z.ZodTypeAny, {
|
|
452
|
-
id: string;
|
|
453
|
-
seq: number;
|
|
454
|
-
createdAt: number;
|
|
455
|
-
updatedAt: number;
|
|
456
|
-
metadataVersion: number;
|
|
457
|
-
agentStateVersion: number;
|
|
458
|
-
metadata?: any;
|
|
459
|
-
agentState?: any;
|
|
460
|
-
connectivityStatus?: string | undefined;
|
|
461
|
-
connectivityStatusSince?: number | undefined;
|
|
462
|
-
connectivityStatusReason?: string | undefined;
|
|
463
|
-
state?: string | undefined;
|
|
464
|
-
stateSince?: number | undefined;
|
|
465
|
-
stateReason?: string | undefined;
|
|
466
|
-
}, {
|
|
437
|
+
type Session = {
|
|
467
438
|
id: string;
|
|
468
439
|
seq: number;
|
|
469
|
-
|
|
470
|
-
|
|
440
|
+
encryptionKey: Uint8Array;
|
|
441
|
+
encryptionVariant: 'legacy' | 'dataKey';
|
|
442
|
+
metadata: Metadata;
|
|
471
443
|
metadataVersion: number;
|
|
444
|
+
agentState: AgentState | null;
|
|
472
445
|
agentStateVersion: number;
|
|
473
|
-
|
|
474
|
-
agentState?: any;
|
|
475
|
-
connectivityStatus?: string | undefined;
|
|
476
|
-
connectivityStatusSince?: number | undefined;
|
|
477
|
-
connectivityStatusReason?: string | undefined;
|
|
478
|
-
state?: string | undefined;
|
|
479
|
-
stateSince?: number | undefined;
|
|
480
|
-
stateReason?: string | undefined;
|
|
481
|
-
}>;
|
|
482
|
-
type Session = z.infer<typeof SessionSchema>;
|
|
446
|
+
};
|
|
483
447
|
/**
|
|
484
448
|
* Machine metadata - static information (rarely changes)
|
|
485
449
|
*/
|
|
@@ -489,18 +453,21 @@ declare const MachineMetadataSchema: z.ZodObject<{
|
|
|
489
453
|
happyCliVersion: z.ZodString;
|
|
490
454
|
homeDir: z.ZodString;
|
|
491
455
|
happyHomeDir: z.ZodString;
|
|
456
|
+
happyLibDir: z.ZodString;
|
|
492
457
|
}, "strip", z.ZodTypeAny, {
|
|
493
458
|
host: string;
|
|
494
459
|
platform: string;
|
|
495
460
|
happyCliVersion: string;
|
|
496
461
|
homeDir: string;
|
|
497
462
|
happyHomeDir: string;
|
|
463
|
+
happyLibDir: string;
|
|
498
464
|
}, {
|
|
499
465
|
host: string;
|
|
500
466
|
platform: string;
|
|
501
467
|
happyCliVersion: string;
|
|
502
468
|
homeDir: string;
|
|
503
469
|
happyHomeDir: string;
|
|
470
|
+
happyLibDir: string;
|
|
504
471
|
}>;
|
|
505
472
|
type MachineMetadata = z.infer<typeof MachineMetadataSchema>;
|
|
506
473
|
/**
|
|
@@ -529,59 +496,15 @@ declare const DaemonStateSchema: z.ZodObject<{
|
|
|
529
496
|
shutdownSource?: string | undefined;
|
|
530
497
|
}>;
|
|
531
498
|
type DaemonState = z.infer<typeof DaemonStateSchema>;
|
|
532
|
-
|
|
533
|
-
* Machine information - similar to Session
|
|
534
|
-
*/
|
|
535
|
-
declare const MachineSchema: z.ZodObject<{
|
|
536
|
-
id: z.ZodString;
|
|
537
|
-
metadata: z.ZodAny;
|
|
538
|
-
metadataVersion: z.ZodNumber;
|
|
539
|
-
daemonState: z.ZodNullable<z.ZodAny>;
|
|
540
|
-
daemonStateVersion: z.ZodNumber;
|
|
541
|
-
active: z.ZodBoolean;
|
|
542
|
-
activeAt: z.ZodNumber;
|
|
543
|
-
createdAt: z.ZodNumber;
|
|
544
|
-
updatedAt: z.ZodNumber;
|
|
545
|
-
connectivityStatus: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["neverConnected", "online", "offline"]>, z.ZodString]>>;
|
|
546
|
-
connectivityStatusSince: z.ZodOptional<z.ZodNumber>;
|
|
547
|
-
connectivityStatusReason: z.ZodOptional<z.ZodString>;
|
|
548
|
-
state: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["running", "archiveRequested", "archived"]>, z.ZodString]>>;
|
|
549
|
-
stateSince: z.ZodOptional<z.ZodNumber>;
|
|
550
|
-
stateReason: z.ZodOptional<z.ZodString>;
|
|
551
|
-
}, "strip", z.ZodTypeAny, {
|
|
552
|
-
id: string;
|
|
553
|
-
createdAt: number;
|
|
554
|
-
updatedAt: number;
|
|
555
|
-
metadataVersion: number;
|
|
556
|
-
daemonStateVersion: number;
|
|
557
|
-
active: boolean;
|
|
558
|
-
activeAt: number;
|
|
559
|
-
metadata?: any;
|
|
560
|
-
daemonState?: any;
|
|
561
|
-
connectivityStatus?: string | undefined;
|
|
562
|
-
connectivityStatusSince?: number | undefined;
|
|
563
|
-
connectivityStatusReason?: string | undefined;
|
|
564
|
-
state?: string | undefined;
|
|
565
|
-
stateSince?: number | undefined;
|
|
566
|
-
stateReason?: string | undefined;
|
|
567
|
-
}, {
|
|
499
|
+
type Machine = {
|
|
568
500
|
id: string;
|
|
569
|
-
|
|
570
|
-
|
|
501
|
+
encryptionKey: Uint8Array;
|
|
502
|
+
encryptionVariant: 'legacy' | 'dataKey';
|
|
503
|
+
metadata: MachineMetadata;
|
|
571
504
|
metadataVersion: number;
|
|
505
|
+
daemonState: DaemonState | null;
|
|
572
506
|
daemonStateVersion: number;
|
|
573
|
-
|
|
574
|
-
activeAt: number;
|
|
575
|
-
metadata?: any;
|
|
576
|
-
daemonState?: any;
|
|
577
|
-
connectivityStatus?: string | undefined;
|
|
578
|
-
connectivityStatusSince?: number | undefined;
|
|
579
|
-
connectivityStatusReason?: string | undefined;
|
|
580
|
-
state?: string | undefined;
|
|
581
|
-
stateSince?: number | undefined;
|
|
582
|
-
stateReason?: string | undefined;
|
|
583
|
-
}>;
|
|
584
|
-
type Machine = z.infer<typeof MachineSchema>;
|
|
507
|
+
};
|
|
585
508
|
declare const UserMessageSchema: z.ZodObject<{
|
|
586
509
|
role: z.ZodLiteral<"user">;
|
|
587
510
|
content: z.ZodObject<{
|
|
@@ -673,8 +596,10 @@ type Metadata = {
|
|
|
673
596
|
claudeSessionId?: string;
|
|
674
597
|
tools?: string[];
|
|
675
598
|
slashCommands?: string[];
|
|
676
|
-
homeDir
|
|
677
|
-
happyHomeDir
|
|
599
|
+
homeDir: string;
|
|
600
|
+
happyHomeDir: string;
|
|
601
|
+
happyLibDir: string;
|
|
602
|
+
happyToolsDir: string;
|
|
678
603
|
startedFromDaemon?: boolean;
|
|
679
604
|
hostPid?: number;
|
|
680
605
|
startedBy?: 'daemon' | 'terminal';
|
|
@@ -682,6 +607,7 @@ type Metadata = {
|
|
|
682
607
|
lifecycleStateSince?: number;
|
|
683
608
|
archivedBy?: string;
|
|
684
609
|
archiveReason?: string;
|
|
610
|
+
flavor?: string;
|
|
685
611
|
};
|
|
686
612
|
type AgentState = {
|
|
687
613
|
controlledByUser?: boolean | null | undefined;
|
|
@@ -701,6 +627,7 @@ type AgentState = {
|
|
|
701
627
|
status: 'canceled' | 'denied' | 'approved';
|
|
702
628
|
reason?: string;
|
|
703
629
|
mode?: PermissionMode;
|
|
630
|
+
decision?: 'approved' | 'approved_for_session' | 'denied' | 'abort';
|
|
704
631
|
allowTools?: string[];
|
|
705
632
|
};
|
|
706
633
|
};
|
|
@@ -735,12 +662,11 @@ type MachineRpcHandlers = {
|
|
|
735
662
|
};
|
|
736
663
|
declare class ApiMachineClient {
|
|
737
664
|
private token;
|
|
738
|
-
private secret;
|
|
739
665
|
private machine;
|
|
740
666
|
private socket;
|
|
741
667
|
private keepAliveInterval;
|
|
742
668
|
private rpcHandlerManager;
|
|
743
|
-
constructor(token: string,
|
|
669
|
+
constructor(token: string, machine: Machine);
|
|
744
670
|
setRPCHandlers({ spawnSession, stopSession, requestShutdown }: MachineRpcHandlers): void;
|
|
745
671
|
/**
|
|
746
672
|
* Update machine metadata
|
|
@@ -788,11 +714,29 @@ declare class PushNotificationClient {
|
|
|
788
714
|
sendToAllDevices(title: string, body: string, data?: Record<string, any>): void;
|
|
789
715
|
}
|
|
790
716
|
|
|
717
|
+
/**
|
|
718
|
+
* Minimal persistence functions for happy CLI
|
|
719
|
+
*
|
|
720
|
+
* Handles settings and private key storage in ~/.happy/ or local .happy/
|
|
721
|
+
*/
|
|
722
|
+
|
|
723
|
+
type Credentials = {
|
|
724
|
+
token: string;
|
|
725
|
+
encryption: {
|
|
726
|
+
type: 'legacy';
|
|
727
|
+
secret: Uint8Array;
|
|
728
|
+
} | {
|
|
729
|
+
type: 'dataKey';
|
|
730
|
+
publicKey: Uint8Array;
|
|
731
|
+
machineKey: Uint8Array;
|
|
732
|
+
};
|
|
733
|
+
};
|
|
734
|
+
|
|
791
735
|
declare class ApiClient {
|
|
792
|
-
|
|
793
|
-
private readonly
|
|
736
|
+
static create(credential: Credentials): Promise<ApiClient>;
|
|
737
|
+
private readonly credential;
|
|
794
738
|
private readonly pushClient;
|
|
795
|
-
constructor(
|
|
739
|
+
private constructor();
|
|
796
740
|
/**
|
|
797
741
|
* Create a new session or load existing one with the given tag
|
|
798
742
|
*/
|
|
@@ -801,11 +745,6 @@ declare class ApiClient {
|
|
|
801
745
|
metadata: Metadata;
|
|
802
746
|
state: AgentState | null;
|
|
803
747
|
}): Promise<Session>;
|
|
804
|
-
/**
|
|
805
|
-
* Get machine by ID from the server
|
|
806
|
-
* Returns the current machine state from the server with decrypted metadata and daemonState
|
|
807
|
-
*/
|
|
808
|
-
getMachine(machineId: string): Promise<Machine | null>;
|
|
809
748
|
/**
|
|
810
749
|
* Register or update machine with the server
|
|
811
750
|
* Returns the current machine state from the server with decrypted metadata and daemonState
|
|
@@ -840,6 +779,8 @@ declare class Logger {
|
|
|
840
779
|
debugLargeJson(message: string, object: unknown, maxStringLength?: number, maxArrayLength?: number): void;
|
|
841
780
|
info(message: string, ...args: unknown[]): void;
|
|
842
781
|
infoDeveloper(message: string, ...args: unknown[]): void;
|
|
782
|
+
warn(message: string, ...args: unknown[]): void;
|
|
783
|
+
getLogPath(): string;
|
|
843
784
|
private logToConsole;
|
|
844
785
|
private sendToRemoteServer;
|
|
845
786
|
private logToFile;
|
|
@@ -854,6 +795,7 @@ declare let logger: Logger;
|
|
|
854
795
|
*/
|
|
855
796
|
declare class Configuration {
|
|
856
797
|
readonly serverUrl: string;
|
|
798
|
+
readonly webappUrl: string;
|
|
857
799
|
readonly isDaemonProcess: boolean;
|
|
858
800
|
readonly happyHomeDir: string;
|
|
859
801
|
readonly logsDir: string;
|
package/dist/lib.d.mts
CHANGED
|
@@ -308,11 +308,9 @@ interface RpcRequest {
|
|
|
308
308
|
* Configuration for RPC handler manager
|
|
309
309
|
*/
|
|
310
310
|
interface RpcHandlerConfig {
|
|
311
|
-
/** Prefix to add to all method names (e.g., sessionId or machineId) */
|
|
312
311
|
scopePrefix: string;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
/** Logger function for debugging */
|
|
312
|
+
encryptionKey: Uint8Array;
|
|
313
|
+
encryptionVariant: 'legacy' | 'dataKey';
|
|
316
314
|
logger?: (message: string, data?: any) => void;
|
|
317
315
|
}
|
|
318
316
|
|
|
@@ -324,7 +322,8 @@ interface RpcHandlerConfig {
|
|
|
324
322
|
declare class RpcHandlerManager {
|
|
325
323
|
private handlers;
|
|
326
324
|
private readonly scopePrefix;
|
|
327
|
-
private readonly
|
|
325
|
+
private readonly encryptionKey;
|
|
326
|
+
private readonly encryptionVariant;
|
|
328
327
|
private readonly logger;
|
|
329
328
|
private socket;
|
|
330
329
|
constructor(config: RpcHandlerConfig);
|
|
@@ -364,7 +363,6 @@ declare class RpcHandlerManager {
|
|
|
364
363
|
|
|
365
364
|
declare class ApiSessionClient extends EventEmitter {
|
|
366
365
|
private readonly token;
|
|
367
|
-
private readonly secret;
|
|
368
366
|
readonly sessionId: string;
|
|
369
367
|
private metadata;
|
|
370
368
|
private metadataVersion;
|
|
@@ -376,13 +374,16 @@ declare class ApiSessionClient extends EventEmitter {
|
|
|
376
374
|
readonly rpcHandlerManager: RpcHandlerManager;
|
|
377
375
|
private agentStateLock;
|
|
378
376
|
private metadataLock;
|
|
379
|
-
|
|
377
|
+
private encryptionKey;
|
|
378
|
+
private encryptionVariant;
|
|
379
|
+
constructor(token: string, session: Session);
|
|
380
380
|
onUserMessage(callback: (data: UserMessage) => void): void;
|
|
381
381
|
/**
|
|
382
382
|
* Send message to session
|
|
383
383
|
* @param body - Message body (can be MessageContent or raw content for agent messages)
|
|
384
384
|
*/
|
|
385
385
|
sendClaudeSessionMessage(body: RawJSONLines): void;
|
|
386
|
+
sendCodexMessage(body: any): void;
|
|
386
387
|
sendSessionEvent(event: {
|
|
387
388
|
type: 'switch';
|
|
388
389
|
mode: 'local' | 'remote';
|
|
@@ -433,53 +434,16 @@ type Usage = z.infer<typeof UsageSchema>;
|
|
|
433
434
|
/**
|
|
434
435
|
* Session information
|
|
435
436
|
*/
|
|
436
|
-
|
|
437
|
-
createdAt: z.ZodNumber;
|
|
438
|
-
id: z.ZodString;
|
|
439
|
-
seq: z.ZodNumber;
|
|
440
|
-
updatedAt: z.ZodNumber;
|
|
441
|
-
metadata: z.ZodAny;
|
|
442
|
-
metadataVersion: z.ZodNumber;
|
|
443
|
-
agentState: z.ZodNullable<z.ZodAny>;
|
|
444
|
-
agentStateVersion: z.ZodNumber;
|
|
445
|
-
connectivityStatus: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["neverConnected", "online", "offline"]>, z.ZodString]>>;
|
|
446
|
-
connectivityStatusSince: z.ZodOptional<z.ZodNumber>;
|
|
447
|
-
connectivityStatusReason: z.ZodOptional<z.ZodString>;
|
|
448
|
-
state: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["running", "archiveRequested", "archived"]>, z.ZodString]>>;
|
|
449
|
-
stateSince: z.ZodOptional<z.ZodNumber>;
|
|
450
|
-
stateReason: z.ZodOptional<z.ZodString>;
|
|
451
|
-
}, "strip", z.ZodTypeAny, {
|
|
452
|
-
id: string;
|
|
453
|
-
seq: number;
|
|
454
|
-
createdAt: number;
|
|
455
|
-
updatedAt: number;
|
|
456
|
-
metadataVersion: number;
|
|
457
|
-
agentStateVersion: number;
|
|
458
|
-
metadata?: any;
|
|
459
|
-
agentState?: any;
|
|
460
|
-
connectivityStatus?: string | undefined;
|
|
461
|
-
connectivityStatusSince?: number | undefined;
|
|
462
|
-
connectivityStatusReason?: string | undefined;
|
|
463
|
-
state?: string | undefined;
|
|
464
|
-
stateSince?: number | undefined;
|
|
465
|
-
stateReason?: string | undefined;
|
|
466
|
-
}, {
|
|
437
|
+
type Session = {
|
|
467
438
|
id: string;
|
|
468
439
|
seq: number;
|
|
469
|
-
|
|
470
|
-
|
|
440
|
+
encryptionKey: Uint8Array;
|
|
441
|
+
encryptionVariant: 'legacy' | 'dataKey';
|
|
442
|
+
metadata: Metadata;
|
|
471
443
|
metadataVersion: number;
|
|
444
|
+
agentState: AgentState | null;
|
|
472
445
|
agentStateVersion: number;
|
|
473
|
-
|
|
474
|
-
agentState?: any;
|
|
475
|
-
connectivityStatus?: string | undefined;
|
|
476
|
-
connectivityStatusSince?: number | undefined;
|
|
477
|
-
connectivityStatusReason?: string | undefined;
|
|
478
|
-
state?: string | undefined;
|
|
479
|
-
stateSince?: number | undefined;
|
|
480
|
-
stateReason?: string | undefined;
|
|
481
|
-
}>;
|
|
482
|
-
type Session = z.infer<typeof SessionSchema>;
|
|
446
|
+
};
|
|
483
447
|
/**
|
|
484
448
|
* Machine metadata - static information (rarely changes)
|
|
485
449
|
*/
|
|
@@ -489,18 +453,21 @@ declare const MachineMetadataSchema: z.ZodObject<{
|
|
|
489
453
|
happyCliVersion: z.ZodString;
|
|
490
454
|
homeDir: z.ZodString;
|
|
491
455
|
happyHomeDir: z.ZodString;
|
|
456
|
+
happyLibDir: z.ZodString;
|
|
492
457
|
}, "strip", z.ZodTypeAny, {
|
|
493
458
|
host: string;
|
|
494
459
|
platform: string;
|
|
495
460
|
happyCliVersion: string;
|
|
496
461
|
homeDir: string;
|
|
497
462
|
happyHomeDir: string;
|
|
463
|
+
happyLibDir: string;
|
|
498
464
|
}, {
|
|
499
465
|
host: string;
|
|
500
466
|
platform: string;
|
|
501
467
|
happyCliVersion: string;
|
|
502
468
|
homeDir: string;
|
|
503
469
|
happyHomeDir: string;
|
|
470
|
+
happyLibDir: string;
|
|
504
471
|
}>;
|
|
505
472
|
type MachineMetadata = z.infer<typeof MachineMetadataSchema>;
|
|
506
473
|
/**
|
|
@@ -529,59 +496,15 @@ declare const DaemonStateSchema: z.ZodObject<{
|
|
|
529
496
|
shutdownSource?: string | undefined;
|
|
530
497
|
}>;
|
|
531
498
|
type DaemonState = z.infer<typeof DaemonStateSchema>;
|
|
532
|
-
|
|
533
|
-
* Machine information - similar to Session
|
|
534
|
-
*/
|
|
535
|
-
declare const MachineSchema: z.ZodObject<{
|
|
536
|
-
id: z.ZodString;
|
|
537
|
-
metadata: z.ZodAny;
|
|
538
|
-
metadataVersion: z.ZodNumber;
|
|
539
|
-
daemonState: z.ZodNullable<z.ZodAny>;
|
|
540
|
-
daemonStateVersion: z.ZodNumber;
|
|
541
|
-
active: z.ZodBoolean;
|
|
542
|
-
activeAt: z.ZodNumber;
|
|
543
|
-
createdAt: z.ZodNumber;
|
|
544
|
-
updatedAt: z.ZodNumber;
|
|
545
|
-
connectivityStatus: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["neverConnected", "online", "offline"]>, z.ZodString]>>;
|
|
546
|
-
connectivityStatusSince: z.ZodOptional<z.ZodNumber>;
|
|
547
|
-
connectivityStatusReason: z.ZodOptional<z.ZodString>;
|
|
548
|
-
state: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["running", "archiveRequested", "archived"]>, z.ZodString]>>;
|
|
549
|
-
stateSince: z.ZodOptional<z.ZodNumber>;
|
|
550
|
-
stateReason: z.ZodOptional<z.ZodString>;
|
|
551
|
-
}, "strip", z.ZodTypeAny, {
|
|
552
|
-
id: string;
|
|
553
|
-
createdAt: number;
|
|
554
|
-
updatedAt: number;
|
|
555
|
-
metadataVersion: number;
|
|
556
|
-
daemonStateVersion: number;
|
|
557
|
-
active: boolean;
|
|
558
|
-
activeAt: number;
|
|
559
|
-
metadata?: any;
|
|
560
|
-
daemonState?: any;
|
|
561
|
-
connectivityStatus?: string | undefined;
|
|
562
|
-
connectivityStatusSince?: number | undefined;
|
|
563
|
-
connectivityStatusReason?: string | undefined;
|
|
564
|
-
state?: string | undefined;
|
|
565
|
-
stateSince?: number | undefined;
|
|
566
|
-
stateReason?: string | undefined;
|
|
567
|
-
}, {
|
|
499
|
+
type Machine = {
|
|
568
500
|
id: string;
|
|
569
|
-
|
|
570
|
-
|
|
501
|
+
encryptionKey: Uint8Array;
|
|
502
|
+
encryptionVariant: 'legacy' | 'dataKey';
|
|
503
|
+
metadata: MachineMetadata;
|
|
571
504
|
metadataVersion: number;
|
|
505
|
+
daemonState: DaemonState | null;
|
|
572
506
|
daemonStateVersion: number;
|
|
573
|
-
|
|
574
|
-
activeAt: number;
|
|
575
|
-
metadata?: any;
|
|
576
|
-
daemonState?: any;
|
|
577
|
-
connectivityStatus?: string | undefined;
|
|
578
|
-
connectivityStatusSince?: number | undefined;
|
|
579
|
-
connectivityStatusReason?: string | undefined;
|
|
580
|
-
state?: string | undefined;
|
|
581
|
-
stateSince?: number | undefined;
|
|
582
|
-
stateReason?: string | undefined;
|
|
583
|
-
}>;
|
|
584
|
-
type Machine = z.infer<typeof MachineSchema>;
|
|
507
|
+
};
|
|
585
508
|
declare const UserMessageSchema: z.ZodObject<{
|
|
586
509
|
role: z.ZodLiteral<"user">;
|
|
587
510
|
content: z.ZodObject<{
|
|
@@ -673,8 +596,10 @@ type Metadata = {
|
|
|
673
596
|
claudeSessionId?: string;
|
|
674
597
|
tools?: string[];
|
|
675
598
|
slashCommands?: string[];
|
|
676
|
-
homeDir
|
|
677
|
-
happyHomeDir
|
|
599
|
+
homeDir: string;
|
|
600
|
+
happyHomeDir: string;
|
|
601
|
+
happyLibDir: string;
|
|
602
|
+
happyToolsDir: string;
|
|
678
603
|
startedFromDaemon?: boolean;
|
|
679
604
|
hostPid?: number;
|
|
680
605
|
startedBy?: 'daemon' | 'terminal';
|
|
@@ -682,6 +607,7 @@ type Metadata = {
|
|
|
682
607
|
lifecycleStateSince?: number;
|
|
683
608
|
archivedBy?: string;
|
|
684
609
|
archiveReason?: string;
|
|
610
|
+
flavor?: string;
|
|
685
611
|
};
|
|
686
612
|
type AgentState = {
|
|
687
613
|
controlledByUser?: boolean | null | undefined;
|
|
@@ -701,6 +627,7 @@ type AgentState = {
|
|
|
701
627
|
status: 'canceled' | 'denied' | 'approved';
|
|
702
628
|
reason?: string;
|
|
703
629
|
mode?: PermissionMode;
|
|
630
|
+
decision?: 'approved' | 'approved_for_session' | 'denied' | 'abort';
|
|
704
631
|
allowTools?: string[];
|
|
705
632
|
};
|
|
706
633
|
};
|
|
@@ -735,12 +662,11 @@ type MachineRpcHandlers = {
|
|
|
735
662
|
};
|
|
736
663
|
declare class ApiMachineClient {
|
|
737
664
|
private token;
|
|
738
|
-
private secret;
|
|
739
665
|
private machine;
|
|
740
666
|
private socket;
|
|
741
667
|
private keepAliveInterval;
|
|
742
668
|
private rpcHandlerManager;
|
|
743
|
-
constructor(token: string,
|
|
669
|
+
constructor(token: string, machine: Machine);
|
|
744
670
|
setRPCHandlers({ spawnSession, stopSession, requestShutdown }: MachineRpcHandlers): void;
|
|
745
671
|
/**
|
|
746
672
|
* Update machine metadata
|
|
@@ -788,11 +714,29 @@ declare class PushNotificationClient {
|
|
|
788
714
|
sendToAllDevices(title: string, body: string, data?: Record<string, any>): void;
|
|
789
715
|
}
|
|
790
716
|
|
|
717
|
+
/**
|
|
718
|
+
* Minimal persistence functions for happy CLI
|
|
719
|
+
*
|
|
720
|
+
* Handles settings and private key storage in ~/.happy/ or local .happy/
|
|
721
|
+
*/
|
|
722
|
+
|
|
723
|
+
type Credentials = {
|
|
724
|
+
token: string;
|
|
725
|
+
encryption: {
|
|
726
|
+
type: 'legacy';
|
|
727
|
+
secret: Uint8Array;
|
|
728
|
+
} | {
|
|
729
|
+
type: 'dataKey';
|
|
730
|
+
publicKey: Uint8Array;
|
|
731
|
+
machineKey: Uint8Array;
|
|
732
|
+
};
|
|
733
|
+
};
|
|
734
|
+
|
|
791
735
|
declare class ApiClient {
|
|
792
|
-
|
|
793
|
-
private readonly
|
|
736
|
+
static create(credential: Credentials): Promise<ApiClient>;
|
|
737
|
+
private readonly credential;
|
|
794
738
|
private readonly pushClient;
|
|
795
|
-
constructor(
|
|
739
|
+
private constructor();
|
|
796
740
|
/**
|
|
797
741
|
* Create a new session or load existing one with the given tag
|
|
798
742
|
*/
|
|
@@ -801,11 +745,6 @@ declare class ApiClient {
|
|
|
801
745
|
metadata: Metadata;
|
|
802
746
|
state: AgentState | null;
|
|
803
747
|
}): Promise<Session>;
|
|
804
|
-
/**
|
|
805
|
-
* Get machine by ID from the server
|
|
806
|
-
* Returns the current machine state from the server with decrypted metadata and daemonState
|
|
807
|
-
*/
|
|
808
|
-
getMachine(machineId: string): Promise<Machine | null>;
|
|
809
748
|
/**
|
|
810
749
|
* Register or update machine with the server
|
|
811
750
|
* Returns the current machine state from the server with decrypted metadata and daemonState
|
|
@@ -840,6 +779,8 @@ declare class Logger {
|
|
|
840
779
|
debugLargeJson(message: string, object: unknown, maxStringLength?: number, maxArrayLength?: number): void;
|
|
841
780
|
info(message: string, ...args: unknown[]): void;
|
|
842
781
|
infoDeveloper(message: string, ...args: unknown[]): void;
|
|
782
|
+
warn(message: string, ...args: unknown[]): void;
|
|
783
|
+
getLogPath(): string;
|
|
843
784
|
private logToConsole;
|
|
844
785
|
private sendToRemoteServer;
|
|
845
786
|
private logToFile;
|
|
@@ -854,6 +795,7 @@ declare let logger: Logger;
|
|
|
854
795
|
*/
|
|
855
796
|
declare class Configuration {
|
|
856
797
|
readonly serverUrl: string;
|
|
798
|
+
readonly webappUrl: string;
|
|
857
799
|
readonly isDaemonProcess: boolean;
|
|
858
800
|
readonly happyHomeDir: string;
|
|
859
801
|
readonly logsDir: string;
|
package/dist/lib.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ApiClient, a as ApiSessionClient, R as RawJSONLinesSchema, c as configuration, l as logger } from './types-
|
|
1
|
+
export { A as ApiClient, a as ApiSessionClient, R as RawJSONLinesSchema, c as configuration, l as logger } from './types-2wHnX7UW.mjs';
|
|
2
2
|
import 'axios';
|
|
3
3
|
import 'chalk';
|
|
4
4
|
import 'fs';
|
|
@@ -17,4 +17,5 @@ import 'fs/promises';
|
|
|
17
17
|
import 'crypto';
|
|
18
18
|
import 'path';
|
|
19
19
|
import 'url';
|
|
20
|
+
import 'os';
|
|
20
21
|
import 'expo-server-sdk';
|