happy-coder 0.10.0-3 → 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/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
- /** Secret key for encryption/decryption */
314
- secret: Uint8Array;
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 secret;
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,7 +374,9 @@ declare class ApiSessionClient extends EventEmitter {
376
374
  readonly rpcHandlerManager: RpcHandlerManager;
377
375
  private agentStateLock;
378
376
  private metadataLock;
379
- constructor(token: string, secret: Uint8Array, session: Session);
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
@@ -434,53 +434,16 @@ type Usage = z.infer<typeof UsageSchema>;
434
434
  /**
435
435
  * Session information
436
436
  */
437
- declare const SessionSchema: z.ZodObject<{
438
- createdAt: z.ZodNumber;
439
- id: z.ZodString;
440
- seq: z.ZodNumber;
441
- updatedAt: z.ZodNumber;
442
- metadata: z.ZodAny;
443
- metadataVersion: z.ZodNumber;
444
- agentState: z.ZodNullable<z.ZodAny>;
445
- agentStateVersion: z.ZodNumber;
446
- connectivityStatus: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["neverConnected", "online", "offline"]>, z.ZodString]>>;
447
- connectivityStatusSince: z.ZodOptional<z.ZodNumber>;
448
- connectivityStatusReason: z.ZodOptional<z.ZodString>;
449
- state: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["running", "archiveRequested", "archived"]>, z.ZodString]>>;
450
- stateSince: z.ZodOptional<z.ZodNumber>;
451
- stateReason: z.ZodOptional<z.ZodString>;
452
- }, "strip", z.ZodTypeAny, {
453
- id: string;
454
- seq: number;
455
- createdAt: number;
456
- updatedAt: number;
457
- metadataVersion: number;
458
- agentStateVersion: number;
459
- metadata?: any;
460
- agentState?: any;
461
- connectivityStatus?: string | undefined;
462
- connectivityStatusSince?: number | undefined;
463
- connectivityStatusReason?: string | undefined;
464
- state?: string | undefined;
465
- stateSince?: number | undefined;
466
- stateReason?: string | undefined;
467
- }, {
437
+ type Session = {
468
438
  id: string;
469
439
  seq: number;
470
- createdAt: number;
471
- updatedAt: number;
440
+ encryptionKey: Uint8Array;
441
+ encryptionVariant: 'legacy' | 'dataKey';
442
+ metadata: Metadata;
472
443
  metadataVersion: number;
444
+ agentState: AgentState | null;
473
445
  agentStateVersion: number;
474
- metadata?: any;
475
- agentState?: any;
476
- connectivityStatus?: string | undefined;
477
- connectivityStatusSince?: number | undefined;
478
- connectivityStatusReason?: string | undefined;
479
- state?: string | undefined;
480
- stateSince?: number | undefined;
481
- stateReason?: string | undefined;
482
- }>;
483
- type Session = z.infer<typeof SessionSchema>;
446
+ };
484
447
  /**
485
448
  * Machine metadata - static information (rarely changes)
486
449
  */
@@ -533,59 +496,15 @@ declare const DaemonStateSchema: z.ZodObject<{
533
496
  shutdownSource?: string | undefined;
534
497
  }>;
535
498
  type DaemonState = z.infer<typeof DaemonStateSchema>;
536
- /**
537
- * Machine information - similar to Session
538
- */
539
- declare const MachineSchema: z.ZodObject<{
540
- id: z.ZodString;
541
- metadata: z.ZodAny;
542
- metadataVersion: z.ZodNumber;
543
- daemonState: z.ZodNullable<z.ZodAny>;
544
- daemonStateVersion: z.ZodNumber;
545
- active: z.ZodBoolean;
546
- activeAt: z.ZodNumber;
547
- createdAt: z.ZodNumber;
548
- updatedAt: z.ZodNumber;
549
- connectivityStatus: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["neverConnected", "online", "offline"]>, z.ZodString]>>;
550
- connectivityStatusSince: z.ZodOptional<z.ZodNumber>;
551
- connectivityStatusReason: z.ZodOptional<z.ZodString>;
552
- state: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["running", "archiveRequested", "archived"]>, z.ZodString]>>;
553
- stateSince: z.ZodOptional<z.ZodNumber>;
554
- stateReason: z.ZodOptional<z.ZodString>;
555
- }, "strip", z.ZodTypeAny, {
556
- id: string;
557
- createdAt: number;
558
- updatedAt: number;
559
- metadataVersion: number;
560
- daemonStateVersion: number;
561
- active: boolean;
562
- activeAt: number;
563
- metadata?: any;
564
- daemonState?: any;
565
- connectivityStatus?: string | undefined;
566
- connectivityStatusSince?: number | undefined;
567
- connectivityStatusReason?: string | undefined;
568
- state?: string | undefined;
569
- stateSince?: number | undefined;
570
- stateReason?: string | undefined;
571
- }, {
499
+ type Machine = {
572
500
  id: string;
573
- createdAt: number;
574
- updatedAt: number;
501
+ encryptionKey: Uint8Array;
502
+ encryptionVariant: 'legacy' | 'dataKey';
503
+ metadata: MachineMetadata;
575
504
  metadataVersion: number;
505
+ daemonState: DaemonState | null;
576
506
  daemonStateVersion: number;
577
- active: boolean;
578
- activeAt: number;
579
- metadata?: any;
580
- daemonState?: any;
581
- connectivityStatus?: string | undefined;
582
- connectivityStatusSince?: number | undefined;
583
- connectivityStatusReason?: string | undefined;
584
- state?: string | undefined;
585
- stateSince?: number | undefined;
586
- stateReason?: string | undefined;
587
- }>;
588
- type Machine = z.infer<typeof MachineSchema>;
507
+ };
589
508
  declare const UserMessageSchema: z.ZodObject<{
590
509
  role: z.ZodLiteral<"user">;
591
510
  content: z.ZodObject<{
@@ -743,12 +662,11 @@ type MachineRpcHandlers = {
743
662
  };
744
663
  declare class ApiMachineClient {
745
664
  private token;
746
- private secret;
747
665
  private machine;
748
666
  private socket;
749
667
  private keepAliveInterval;
750
668
  private rpcHandlerManager;
751
- constructor(token: string, secret: Uint8Array, machine: Machine);
669
+ constructor(token: string, machine: Machine);
752
670
  setRPCHandlers({ spawnSession, stopSession, requestShutdown }: MachineRpcHandlers): void;
753
671
  /**
754
672
  * Update machine metadata
@@ -796,11 +714,29 @@ declare class PushNotificationClient {
796
714
  sendToAllDevices(title: string, body: string, data?: Record<string, any>): void;
797
715
  }
798
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
+
799
735
  declare class ApiClient {
800
- private readonly token;
801
- private readonly secret;
736
+ static create(credential: Credentials): Promise<ApiClient>;
737
+ private readonly credential;
802
738
  private readonly pushClient;
803
- constructor(token: string, secret: Uint8Array);
739
+ private constructor();
804
740
  /**
805
741
  * Create a new session or load existing one with the given tag
806
742
  */
@@ -809,11 +745,6 @@ declare class ApiClient {
809
745
  metadata: Metadata;
810
746
  state: AgentState | null;
811
747
  }): Promise<Session>;
812
- /**
813
- * Get machine by ID from the server
814
- * Returns the current machine state from the server with decrypted metadata and daemonState
815
- */
816
- getMachine(machineId: string): Promise<Machine | null>;
817
748
  /**
818
749
  * Register or update machine with the server
819
750
  * Returns the current machine state from the server with decrypted metadata and daemonState
@@ -864,6 +795,7 @@ declare let logger: Logger;
864
795
  */
865
796
  declare class Configuration {
866
797
  readonly serverUrl: string;
798
+ readonly webappUrl: string;
867
799
  readonly isDaemonProcess: boolean;
868
800
  readonly happyHomeDir: string;
869
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
- /** Secret key for encryption/decryption */
314
- secret: Uint8Array;
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 secret;
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,7 +374,9 @@ declare class ApiSessionClient extends EventEmitter {
376
374
  readonly rpcHandlerManager: RpcHandlerManager;
377
375
  private agentStateLock;
378
376
  private metadataLock;
379
- constructor(token: string, secret: Uint8Array, session: Session);
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
@@ -434,53 +434,16 @@ type Usage = z.infer<typeof UsageSchema>;
434
434
  /**
435
435
  * Session information
436
436
  */
437
- declare const SessionSchema: z.ZodObject<{
438
- createdAt: z.ZodNumber;
439
- id: z.ZodString;
440
- seq: z.ZodNumber;
441
- updatedAt: z.ZodNumber;
442
- metadata: z.ZodAny;
443
- metadataVersion: z.ZodNumber;
444
- agentState: z.ZodNullable<z.ZodAny>;
445
- agentStateVersion: z.ZodNumber;
446
- connectivityStatus: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["neverConnected", "online", "offline"]>, z.ZodString]>>;
447
- connectivityStatusSince: z.ZodOptional<z.ZodNumber>;
448
- connectivityStatusReason: z.ZodOptional<z.ZodString>;
449
- state: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["running", "archiveRequested", "archived"]>, z.ZodString]>>;
450
- stateSince: z.ZodOptional<z.ZodNumber>;
451
- stateReason: z.ZodOptional<z.ZodString>;
452
- }, "strip", z.ZodTypeAny, {
453
- id: string;
454
- seq: number;
455
- createdAt: number;
456
- updatedAt: number;
457
- metadataVersion: number;
458
- agentStateVersion: number;
459
- metadata?: any;
460
- agentState?: any;
461
- connectivityStatus?: string | undefined;
462
- connectivityStatusSince?: number | undefined;
463
- connectivityStatusReason?: string | undefined;
464
- state?: string | undefined;
465
- stateSince?: number | undefined;
466
- stateReason?: string | undefined;
467
- }, {
437
+ type Session = {
468
438
  id: string;
469
439
  seq: number;
470
- createdAt: number;
471
- updatedAt: number;
440
+ encryptionKey: Uint8Array;
441
+ encryptionVariant: 'legacy' | 'dataKey';
442
+ metadata: Metadata;
472
443
  metadataVersion: number;
444
+ agentState: AgentState | null;
473
445
  agentStateVersion: number;
474
- metadata?: any;
475
- agentState?: any;
476
- connectivityStatus?: string | undefined;
477
- connectivityStatusSince?: number | undefined;
478
- connectivityStatusReason?: string | undefined;
479
- state?: string | undefined;
480
- stateSince?: number | undefined;
481
- stateReason?: string | undefined;
482
- }>;
483
- type Session = z.infer<typeof SessionSchema>;
446
+ };
484
447
  /**
485
448
  * Machine metadata - static information (rarely changes)
486
449
  */
@@ -533,59 +496,15 @@ declare const DaemonStateSchema: z.ZodObject<{
533
496
  shutdownSource?: string | undefined;
534
497
  }>;
535
498
  type DaemonState = z.infer<typeof DaemonStateSchema>;
536
- /**
537
- * Machine information - similar to Session
538
- */
539
- declare const MachineSchema: z.ZodObject<{
540
- id: z.ZodString;
541
- metadata: z.ZodAny;
542
- metadataVersion: z.ZodNumber;
543
- daemonState: z.ZodNullable<z.ZodAny>;
544
- daemonStateVersion: z.ZodNumber;
545
- active: z.ZodBoolean;
546
- activeAt: z.ZodNumber;
547
- createdAt: z.ZodNumber;
548
- updatedAt: z.ZodNumber;
549
- connectivityStatus: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["neverConnected", "online", "offline"]>, z.ZodString]>>;
550
- connectivityStatusSince: z.ZodOptional<z.ZodNumber>;
551
- connectivityStatusReason: z.ZodOptional<z.ZodString>;
552
- state: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["running", "archiveRequested", "archived"]>, z.ZodString]>>;
553
- stateSince: z.ZodOptional<z.ZodNumber>;
554
- stateReason: z.ZodOptional<z.ZodString>;
555
- }, "strip", z.ZodTypeAny, {
556
- id: string;
557
- createdAt: number;
558
- updatedAt: number;
559
- metadataVersion: number;
560
- daemonStateVersion: number;
561
- active: boolean;
562
- activeAt: number;
563
- metadata?: any;
564
- daemonState?: any;
565
- connectivityStatus?: string | undefined;
566
- connectivityStatusSince?: number | undefined;
567
- connectivityStatusReason?: string | undefined;
568
- state?: string | undefined;
569
- stateSince?: number | undefined;
570
- stateReason?: string | undefined;
571
- }, {
499
+ type Machine = {
572
500
  id: string;
573
- createdAt: number;
574
- updatedAt: number;
501
+ encryptionKey: Uint8Array;
502
+ encryptionVariant: 'legacy' | 'dataKey';
503
+ metadata: MachineMetadata;
575
504
  metadataVersion: number;
505
+ daemonState: DaemonState | null;
576
506
  daemonStateVersion: number;
577
- active: boolean;
578
- activeAt: number;
579
- metadata?: any;
580
- daemonState?: any;
581
- connectivityStatus?: string | undefined;
582
- connectivityStatusSince?: number | undefined;
583
- connectivityStatusReason?: string | undefined;
584
- state?: string | undefined;
585
- stateSince?: number | undefined;
586
- stateReason?: string | undefined;
587
- }>;
588
- type Machine = z.infer<typeof MachineSchema>;
507
+ };
589
508
  declare const UserMessageSchema: z.ZodObject<{
590
509
  role: z.ZodLiteral<"user">;
591
510
  content: z.ZodObject<{
@@ -743,12 +662,11 @@ type MachineRpcHandlers = {
743
662
  };
744
663
  declare class ApiMachineClient {
745
664
  private token;
746
- private secret;
747
665
  private machine;
748
666
  private socket;
749
667
  private keepAliveInterval;
750
668
  private rpcHandlerManager;
751
- constructor(token: string, secret: Uint8Array, machine: Machine);
669
+ constructor(token: string, machine: Machine);
752
670
  setRPCHandlers({ spawnSession, stopSession, requestShutdown }: MachineRpcHandlers): void;
753
671
  /**
754
672
  * Update machine metadata
@@ -796,11 +714,29 @@ declare class PushNotificationClient {
796
714
  sendToAllDevices(title: string, body: string, data?: Record<string, any>): void;
797
715
  }
798
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
+
799
735
  declare class ApiClient {
800
- private readonly token;
801
- private readonly secret;
736
+ static create(credential: Credentials): Promise<ApiClient>;
737
+ private readonly credential;
802
738
  private readonly pushClient;
803
- constructor(token: string, secret: Uint8Array);
739
+ private constructor();
804
740
  /**
805
741
  * Create a new session or load existing one with the given tag
806
742
  */
@@ -809,11 +745,6 @@ declare class ApiClient {
809
745
  metadata: Metadata;
810
746
  state: AgentState | null;
811
747
  }): Promise<Session>;
812
- /**
813
- * Get machine by ID from the server
814
- * Returns the current machine state from the server with decrypted metadata and daemonState
815
- */
816
- getMachine(machineId: string): Promise<Machine | null>;
817
748
  /**
818
749
  * Register or update machine with the server
819
750
  * Returns the current machine state from the server with decrypted metadata and daemonState
@@ -864,6 +795,7 @@ declare let logger: Logger;
864
795
  */
865
796
  declare class Configuration {
866
797
  readonly serverUrl: string;
798
+ readonly webappUrl: string;
867
799
  readonly isDaemonProcess: boolean;
868
800
  readonly happyHomeDir: string;
869
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-xds_c-JJ.mjs';
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';
@@ -2,13 +2,13 @@
2
2
 
3
3
  var ink = require('ink');
4
4
  var React = require('react');
5
- var types = require('./types-CsJGQvQ3.cjs');
5
+ var types = require('./types-BcDnTXMg.cjs');
6
6
  var index_js = require('@modelcontextprotocol/sdk/client/index.js');
7
7
  var stdio_js = require('@modelcontextprotocol/sdk/client/stdio.js');
8
8
  var z = require('zod');
9
9
  var types_js = require('@modelcontextprotocol/sdk/types.js');
10
10
  var node_crypto = require('node:crypto');
11
- var index = require('./index-tqOLc1Il.cjs');
11
+ var index = require('./index-67rskwL7.cjs');
12
12
  var os = require('node:os');
13
13
  var node_path = require('node:path');
14
14
  var fs = require('node:fs');
@@ -680,7 +680,7 @@ const CodexDisplay = ({ messageBuffer, logPath, onExit }) => {
680
680
 
681
681
  async function runCodex(opts) {
682
682
  const sessionTag = node_crypto.randomUUID();
683
- const api = new types.ApiClient(opts.token, opts.secret);
683
+ const api = await types.ApiClient.create(opts.credentials);
684
684
  const settings = await types.readSettings();
685
685
  let machineId = settings?.machineId;
686
686
  if (!machineId) {
@@ -1,12 +1,12 @@
1
1
  import { useStdout, useInput, Box, Text, render } from 'ink';
2
2
  import React, { useState, useRef, useEffect, useCallback } from 'react';
3
- import { l as logger, A as ApiClient, r as readSettings, p as projectPath, c as configuration, b as packageJson } from './types-xds_c-JJ.mjs';
3
+ import { l as logger, A as ApiClient, r as readSettings, p as projectPath, c as configuration, b as packageJson } from './types-2wHnX7UW.mjs';
4
4
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
5
5
  import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
6
6
  import { z } from 'zod';
7
7
  import { ElicitRequestSchema } from '@modelcontextprotocol/sdk/types.js';
8
8
  import { randomUUID } from 'node:crypto';
9
- import { i as initialMachineMetadata, M as MessageQueue2, h as hashObject, a as MessageBuffer, s as startHappyServer, t as trimIdent } from './index-DPVbp4Yx.mjs';
9
+ import { i as initialMachineMetadata, M as MessageQueue2, h as hashObject, a as MessageBuffer, s as startHappyServer, t as trimIdent } from './index-Dw96QD4T.mjs';
10
10
  import os from 'node:os';
11
11
  import { resolve, join } from 'node:path';
12
12
  import fs from 'node:fs';
@@ -678,7 +678,7 @@ const CodexDisplay = ({ messageBuffer, logPath, onExit }) => {
678
678
 
679
679
  async function runCodex(opts) {
680
680
  const sessionTag = randomUUID();
681
- const api = new ApiClient(opts.token, opts.secret);
681
+ const api = await ApiClient.create(opts.credentials);
682
682
  const settings = await readSettings();
683
683
  let machineId = settings?.machineId;
684
684
  if (!machineId) {