happy-imou-cloud 1.1.6 → 1.1.7

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.
@@ -4,7 +4,7 @@ var fs = require('fs');
4
4
  var path = require('path');
5
5
  var os = require('os');
6
6
  var child_process = require('child_process');
7
- var api = require('./types-DSQA_cBn.cjs');
7
+ var api = require('./types-BSTmyv9d.cjs');
8
8
 
9
9
  const GEMINI_API_KEY_ENV = "GEMINI_API_KEY";
10
10
  const GOOGLE_API_KEY_ENV = "GOOGLE_API_KEY";
@@ -2,7 +2,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
2
2
  import { join } from 'path';
3
3
  import { homedir } from 'os';
4
4
  import { execSync } from 'child_process';
5
- import { l as logger } from './types-DY1-MAPO.mjs';
5
+ import { l as logger } from './types-BXyraW9R.mjs';
6
6
 
7
7
  const GEMINI_API_KEY_ENV = "GEMINI_API_KEY";
8
8
  const GOOGLE_API_KEY_ENV = "GOOGLE_API_KEY";
@@ -1,7 +1,7 @@
1
1
  import{createRequire as _pkgrollCR}from"node:module";const require=_pkgrollCR(import.meta.url);import chalk from 'chalk';
2
2
  import os$1, { homedir, tmpdir } from 'node:os';
3
3
  import { randomUUID, randomBytes } from 'node:crypto';
4
- import { l as logger, f as backoff, d as delay, R as RawJSONLinesSchema, g as AsyncLock, c as configuration, H as HAPPY_CLOUD_DAEMON_PORT, p as packageJson, e as encodeBase64, h as encodeBase64Url, i as decodeBase64, A as ApiClient, b as connectionState, s as startOfflineReconnection, j as getLatestDaemonLog } from './types-DY1-MAPO.mjs';
4
+ import { l as logger, f as backoff, d as delay, R as RawJSONLinesSchema, g as AsyncLock, c as configuration, H as HAPPY_CLOUD_DAEMON_PORT, p as packageJson, e as encodeBase64, h as buildAuthenticatedHeaders, i as encodeBase64Url, j as buildClientHeaders, k as decodeBase64, A as ApiClient, b as connectionState, s as startOfflineReconnection, m as getLatestDaemonLog } from './types-BXyraW9R.mjs';
5
5
  import { spawn, execSync, execFileSync } from 'node:child_process';
6
6
  import { resolve, isAbsolute, join } from 'node:path';
7
7
  import { createInterface } from 'node:readline';
@@ -19,7 +19,7 @@ import 'socket.io-client';
19
19
  import tweetnacl from 'tweetnacl';
20
20
  import 'expo-server-sdk';
21
21
  import { isDeepStrictEqual } from 'node:util';
22
- import { readDaemonState, clearDaemonState, readSettings, readCredentials, updateSettings, writeCredentialsLegacy, writeCredentialsDataKey, acquireDaemonLock, writeDaemonState, releaseDaemonLock, validateProfileForAgent, getProfileEnvironmentVariables, clearCredentials, clearMachineId } from './persistence-DS4-Wbnm.mjs';
22
+ import { readDaemonState, clearDaemonState, readSettings, readCredentials, updateSettings, writeCredentialsLegacy, writeCredentialsDataKey, acquireDaemonLock, writeDaemonState, releaseDaemonLock, validateProfileForAgent, getProfileEnvironmentVariables, clearCredentials, clearMachineId } from './persistence-BGsuPqaO.mjs';
23
23
  import { createHash, randomBytes as randomBytes$1 } from 'crypto';
24
24
  import { spawn as spawn$1, execSync as execSync$1, exec } from 'child_process';
25
25
  import { readFileSync as readFileSync$1, existsSync as existsSync$1, writeFileSync as writeFileSync$1, chmodSync, unlinkSync as unlinkSync$1, mkdirSync as mkdirSync$1 } from 'fs';
@@ -4127,6 +4127,7 @@ async function runDoctorCommand(filter) {
4127
4127
  const credentials = await readCredentials();
4128
4128
  if (credentials) {
4129
4129
  console.log(chalk.green("\u2713 Authenticated (credentials found)"));
4130
+ console.log(`Request signing: ${credentials.signing ? chalk.green("ready") : chalk.yellow("legacy credentials")}`);
4130
4131
  } else {
4131
4132
  console.log(chalk.yellow("\u26A0\uFE0F Not authenticated (no credentials)"));
4132
4133
  }
@@ -4454,6 +4455,8 @@ async function createTerminalAuthRequest(keypair) {
4454
4455
  const response = await axios.post(`${configuration.serverUrl}/v1/auth/request`, {
4455
4456
  publicKey: encodeBase64(keypair.publicKey),
4456
4457
  supportsV2: true
4458
+ }, {
4459
+ headers: buildClientHeaders()
4457
4460
  });
4458
4461
  if (process.env.DEBUG) {
4459
4462
  console.log("[AUTH DEBUG] Auth request sent successfully");
@@ -4722,6 +4725,7 @@ async function authAndSetupMachineIfNeeded() {
4722
4725
  } else {
4723
4726
  logger.debug("[AUTH] Using existing credentials");
4724
4727
  }
4728
+ credentials = await ensureSigningCredentials(credentials);
4725
4729
  const settings = await updateSettings(async (s) => {
4726
4730
  if (newAuth || !s.machineId) {
4727
4731
  return {
@@ -4734,6 +4738,53 @@ async function authAndSetupMachineIfNeeded() {
4734
4738
  logger.debug(`[AUTH] Machine ID: ${settings.machineId}`);
4735
4739
  return { credentials, machineId: settings.machineId };
4736
4740
  }
4741
+ async function ensureSigningCredentials(credentials) {
4742
+ if (credentials.signing) {
4743
+ return credentials;
4744
+ }
4745
+ try {
4746
+ const response = await axios.post(`${configuration.serverUrl}/v1/auth/refresh`, {}, {
4747
+ headers: buildAuthenticatedHeaders({
4748
+ credentials,
4749
+ method: "POST",
4750
+ url: `${configuration.serverUrl}/v1/auth/refresh`,
4751
+ body: {},
4752
+ headers: {
4753
+ "Content-Type": "application/json"
4754
+ },
4755
+ signRequest: false
4756
+ })
4757
+ });
4758
+ if (!response.data?.success || !response.data?.token || !response.data?.signing) {
4759
+ logger.debug("[AUTH] Signing bootstrap returned incomplete payload");
4760
+ return credentials;
4761
+ }
4762
+ const upgradedCredentials = {
4763
+ ...credentials,
4764
+ token: response.data.token,
4765
+ signing: response.data.signing
4766
+ };
4767
+ if (upgradedCredentials.encryption.type === "legacy") {
4768
+ await writeCredentialsLegacy({
4769
+ secret: upgradedCredentials.encryption.secret,
4770
+ token: upgradedCredentials.token,
4771
+ signing: upgradedCredentials.signing
4772
+ });
4773
+ } else {
4774
+ await writeCredentialsDataKey({
4775
+ publicKey: upgradedCredentials.encryption.publicKey,
4776
+ machineKey: upgradedCredentials.encryption.machineKey,
4777
+ token: upgradedCredentials.token,
4778
+ signing: upgradedCredentials.signing
4779
+ });
4780
+ }
4781
+ logger.debug("[AUTH] Signing credentials bootstrapped successfully");
4782
+ return upgradedCredentials;
4783
+ } catch (error) {
4784
+ logger.debug("[AUTH] Failed to bootstrap signing credentials", error);
4785
+ return credentials;
4786
+ }
4787
+ }
4737
4788
 
4738
4789
  function spawnHappyCLI(args, options = {}) {
4739
4790
  const projectRoot = projectPath();
@@ -6840,6 +6891,7 @@ async function handleAuthStatus() {
6840
6891
  console.log(chalk.green("\u2713 Authenticated"));
6841
6892
  const tokenPreview = credentials.token.substring(0, 30) + "...";
6842
6893
  console.log(chalk.gray(` Token: ${tokenPreview}`));
6894
+ console.log(chalk.gray(` Request signing: ${credentials.signing ? "ready" : "legacy credentials (will auto-upgrade on use)"}`));
6843
6895
  if (settings?.machineId) {
6844
6896
  console.log(chalk.green("\u2713 Machine registered"));
6845
6897
  console.log(chalk.gray(` Machine ID: ${settings.machineId}`));
@@ -7583,7 +7635,7 @@ function getVersionString() {
7583
7635
  return;
7584
7636
  } else if (subcommand === "codex") {
7585
7637
  try {
7586
- const { runCodex } = await import('./runCodex-DHo2-Vmd.mjs');
7638
+ const { runCodex } = await import('./runCodex-X0BfjcZH.mjs');
7587
7639
  let startedBy = void 0;
7588
7640
  for (let i = 1; i < args.length; i++) {
7589
7641
  if (args[i] === "--started-by") {
@@ -7676,9 +7728,9 @@ function getVersionString() {
7676
7728
  if (geminiSubcommand === "project" && args[2] === "set" && args[3]) {
7677
7729
  const projectId = args[3];
7678
7730
  try {
7679
- const { saveGoogleCloudProjectToConfig } = await import('./config-C4c3eRAq.mjs').then(function (n) { return n.e; });
7680
- const { readCredentials: readCredentials2 } = await import('./persistence-DS4-Wbnm.mjs');
7681
- const { ApiClient: ApiClient2 } = await import('./types-DY1-MAPO.mjs').then(function (n) { return n.k; });
7731
+ const { saveGoogleCloudProjectToConfig } = await import('./config-Dn99YH37.mjs').then(function (n) { return n.e; });
7732
+ const { readCredentials: readCredentials2 } = await import('./persistence-BGsuPqaO.mjs');
7733
+ const { ApiClient: ApiClient2 } = await import('./types-BXyraW9R.mjs').then(function (n) { return n.n; });
7682
7734
  let userEmail = void 0;
7683
7735
  try {
7684
7736
  const credentials = await readCredentials2();
@@ -7709,7 +7761,7 @@ function getVersionString() {
7709
7761
  }
7710
7762
  if (geminiSubcommand === "project" && args[2] === "get") {
7711
7763
  try {
7712
- const { readGeminiLocalConfig } = await import('./config-C4c3eRAq.mjs').then(function (n) { return n.e; });
7764
+ const { readGeminiLocalConfig } = await import('./config-Dn99YH37.mjs').then(function (n) { return n.e; });
7713
7765
  const config = readGeminiLocalConfig();
7714
7766
  if (config.googleCloudProject) {
7715
7767
  console.log(`Current Google Cloud Project: ${config.googleCloudProject}`);
@@ -7749,7 +7801,7 @@ function getVersionString() {
7749
7801
  process.exit(0);
7750
7802
  }
7751
7803
  try {
7752
- const { runGemini } = await import('./runGemini-D1DZS8IL.mjs');
7804
+ const { runGemini } = await import('./runGemini-B-EK_BJQ.mjs');
7753
7805
  let startedBy = void 0;
7754
7806
  for (let i = 1; i < args.length; i++) {
7755
7807
  if (args[i] === "--started-by") {
@@ -3,7 +3,7 @@
3
3
  var chalk = require('chalk');
4
4
  var os = require('node:os');
5
5
  var node_crypto = require('node:crypto');
6
- var api = require('./types-DSQA_cBn.cjs');
6
+ var api = require('./types-BSTmyv9d.cjs');
7
7
  var node_child_process = require('node:child_process');
8
8
  var node_path = require('node:path');
9
9
  var node_readline = require('node:readline');
@@ -21,7 +21,7 @@ require('socket.io-client');
21
21
  var tweetnacl = require('tweetnacl');
22
22
  require('expo-server-sdk');
23
23
  var node_util = require('node:util');
24
- var persistence = require('./persistence-DW_z9Bsh.cjs');
24
+ var persistence = require('./persistence-BRH9F6RS.cjs');
25
25
  var crypto = require('crypto');
26
26
  var child_process = require('child_process');
27
27
  var fs$2 = require('fs');
@@ -256,7 +256,7 @@ function claudeFindLastSession(workingDirectory) {
256
256
  }
257
257
  }
258
258
 
259
- const __dirname$2 = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-BJ0xEdNB.cjs', document.baseURI).href))));
259
+ const __dirname$2 = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-DVI4b0mv.cjs', document.baseURI).href))));
260
260
  function projectPath() {
261
261
  const path$1 = path.resolve(__dirname$2, "..");
262
262
  return path$1;
@@ -1169,7 +1169,7 @@ function getRuntime() {
1169
1169
  }
1170
1170
  const isBun = () => getRuntime() === "bun";
1171
1171
 
1172
- const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-BJ0xEdNB.cjs', document.baseURI).href)));
1172
+ const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-DVI4b0mv.cjs', document.baseURI).href)));
1173
1173
  const __dirname$1 = node_path.join(__filename$1, "..");
1174
1174
  function getGlobalClaudeVersion() {
1175
1175
  try {
@@ -4149,6 +4149,7 @@ async function runDoctorCommand(filter) {
4149
4149
  const credentials = await persistence.readCredentials();
4150
4150
  if (credentials) {
4151
4151
  console.log(chalk.green("\u2713 Authenticated (credentials found)"));
4152
+ console.log(`Request signing: ${credentials.signing ? chalk.green("ready") : chalk.yellow("legacy credentials")}`);
4152
4153
  } else {
4153
4154
  console.log(chalk.yellow("\u26A0\uFE0F Not authenticated (no credentials)"));
4154
4155
  }
@@ -4274,7 +4275,7 @@ async function openBrowser(url) {
4274
4275
  }
4275
4276
  }
4276
4277
 
4277
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-BJ0xEdNB.cjs', document.baseURI).href)));
4278
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-DVI4b0mv.cjs', document.baseURI).href)));
4278
4279
  const QRCode = require$1("qrcode-terminal/vendor/QRCode");
4279
4280
  const QRErrorCorrectLevel = require$1("qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel");
4280
4281
  const pendingTempFiles = /* @__PURE__ */ new Set();
@@ -4476,6 +4477,8 @@ async function createTerminalAuthRequest(keypair) {
4476
4477
  const response = await axios.post(`${api.configuration.serverUrl}/v1/auth/request`, {
4477
4478
  publicKey: api.encodeBase64(keypair.publicKey),
4478
4479
  supportsV2: true
4480
+ }, {
4481
+ headers: api.buildClientHeaders()
4479
4482
  });
4480
4483
  if (process.env.DEBUG) {
4481
4484
  console.log("[AUTH DEBUG] Auth request sent successfully");
@@ -4744,6 +4747,7 @@ async function authAndSetupMachineIfNeeded() {
4744
4747
  } else {
4745
4748
  api.logger.debug("[AUTH] Using existing credentials");
4746
4749
  }
4750
+ credentials = await ensureSigningCredentials(credentials);
4747
4751
  const settings = await persistence.updateSettings(async (s) => {
4748
4752
  if (newAuth || !s.machineId) {
4749
4753
  return {
@@ -4756,6 +4760,53 @@ async function authAndSetupMachineIfNeeded() {
4756
4760
  api.logger.debug(`[AUTH] Machine ID: ${settings.machineId}`);
4757
4761
  return { credentials, machineId: settings.machineId };
4758
4762
  }
4763
+ async function ensureSigningCredentials(credentials) {
4764
+ if (credentials.signing) {
4765
+ return credentials;
4766
+ }
4767
+ try {
4768
+ const response = await axios.post(`${api.configuration.serverUrl}/v1/auth/refresh`, {}, {
4769
+ headers: api.buildAuthenticatedHeaders({
4770
+ credentials,
4771
+ method: "POST",
4772
+ url: `${api.configuration.serverUrl}/v1/auth/refresh`,
4773
+ body: {},
4774
+ headers: {
4775
+ "Content-Type": "application/json"
4776
+ },
4777
+ signRequest: false
4778
+ })
4779
+ });
4780
+ if (!response.data?.success || !response.data?.token || !response.data?.signing) {
4781
+ api.logger.debug("[AUTH] Signing bootstrap returned incomplete payload");
4782
+ return credentials;
4783
+ }
4784
+ const upgradedCredentials = {
4785
+ ...credentials,
4786
+ token: response.data.token,
4787
+ signing: response.data.signing
4788
+ };
4789
+ if (upgradedCredentials.encryption.type === "legacy") {
4790
+ await persistence.writeCredentialsLegacy({
4791
+ secret: upgradedCredentials.encryption.secret,
4792
+ token: upgradedCredentials.token,
4793
+ signing: upgradedCredentials.signing
4794
+ });
4795
+ } else {
4796
+ await persistence.writeCredentialsDataKey({
4797
+ publicKey: upgradedCredentials.encryption.publicKey,
4798
+ machineKey: upgradedCredentials.encryption.machineKey,
4799
+ token: upgradedCredentials.token,
4800
+ signing: upgradedCredentials.signing
4801
+ });
4802
+ }
4803
+ api.logger.debug("[AUTH] Signing credentials bootstrapped successfully");
4804
+ return upgradedCredentials;
4805
+ } catch (error) {
4806
+ api.logger.debug("[AUTH] Failed to bootstrap signing credentials", error);
4807
+ return credentials;
4808
+ }
4809
+ }
4759
4810
 
4760
4811
  function spawnHappyCLI(args, options = {}) {
4761
4812
  const projectRoot = projectPath();
@@ -6862,6 +6913,7 @@ async function handleAuthStatus() {
6862
6913
  console.log(chalk.green("\u2713 Authenticated"));
6863
6914
  const tokenPreview = credentials.token.substring(0, 30) + "...";
6864
6915
  console.log(chalk.gray(` Token: ${tokenPreview}`));
6916
+ console.log(chalk.gray(` Request signing: ${credentials.signing ? "ready" : "legacy credentials (will auto-upgrade on use)"}`));
6865
6917
  if (settings?.machineId) {
6866
6918
  console.log(chalk.green("\u2713 Machine registered"));
6867
6919
  console.log(chalk.gray(` Machine ID: ${settings.machineId}`));
@@ -7605,7 +7657,7 @@ function getVersionString() {
7605
7657
  return;
7606
7658
  } else if (subcommand === "codex") {
7607
7659
  try {
7608
- const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-BCgor8vK.cjs'); });
7660
+ const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-Cez8cuIh.cjs'); });
7609
7661
  let startedBy = void 0;
7610
7662
  for (let i = 1; i < args.length; i++) {
7611
7663
  if (args[i] === "--started-by") {
@@ -7698,9 +7750,9 @@ function getVersionString() {
7698
7750
  if (geminiSubcommand === "project" && args[2] === "set" && args[3]) {
7699
7751
  const projectId = args[3];
7700
7752
  try {
7701
- const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return require('./config-DSI9r8Jl.cjs'); }).then(function (n) { return n.config; });
7702
- const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./persistence-DW_z9Bsh.cjs'); });
7703
- const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./types-DSQA_cBn.cjs'); }).then(function (n) { return n.api; });
7753
+ const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return require('./config-BQNrtwRY.cjs'); }).then(function (n) { return n.config; });
7754
+ const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./persistence-BRH9F6RS.cjs'); });
7755
+ const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./types-BSTmyv9d.cjs'); }).then(function (n) { return n.api; });
7704
7756
  let userEmail = void 0;
7705
7757
  try {
7706
7758
  const credentials = await readCredentials2();
@@ -7731,7 +7783,7 @@ function getVersionString() {
7731
7783
  }
7732
7784
  if (geminiSubcommand === "project" && args[2] === "get") {
7733
7785
  try {
7734
- const { readGeminiLocalConfig } = await Promise.resolve().then(function () { return require('./config-DSI9r8Jl.cjs'); }).then(function (n) { return n.config; });
7786
+ const { readGeminiLocalConfig } = await Promise.resolve().then(function () { return require('./config-BQNrtwRY.cjs'); }).then(function (n) { return n.config; });
7735
7787
  const config = readGeminiLocalConfig();
7736
7788
  if (config.googleCloudProject) {
7737
7789
  console.log(`Current Google Cloud Project: ${config.googleCloudProject}`);
@@ -7771,7 +7823,7 @@ function getVersionString() {
7771
7823
  process.exit(0);
7772
7824
  }
7773
7825
  try {
7774
- const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-81Ogay0E.cjs'); });
7826
+ const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-C3dDtGOV.cjs'); });
7775
7827
  let startedBy = void 0;
7776
7828
  for (let i = 1; i < args.length; i++) {
7777
7829
  if (args[i] === "--started-by") {
package/dist/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  require('chalk');
4
- require('./index-BJ0xEdNB.cjs');
5
- require('./types-DSQA_cBn.cjs');
6
- require('./persistence-DW_z9Bsh.cjs');
4
+ require('./index-DVI4b0mv.cjs');
5
+ require('./types-BSTmyv9d.cjs');
6
+ require('./persistence-BRH9F6RS.cjs');
7
7
  require('zod');
8
8
  require('node:child_process');
9
9
  require('node:fs');
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import 'chalk';
2
- import './index-B3bkHdEU.mjs';
3
- import './types-DY1-MAPO.mjs';
4
- import './persistence-DS4-Wbnm.mjs';
2
+ import './index-CUmYqKWt.mjs';
3
+ import './types-BXyraW9R.mjs';
4
+ import './persistence-BGsuPqaO.mjs';
5
5
  import 'zod';
6
6
  import 'node:child_process';
7
7
  import 'node:fs';
package/dist/lib.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var api = require('./types-DSQA_cBn.cjs');
3
+ var api = require('./types-BSTmyv9d.cjs');
4
4
  require('axios');
5
5
  require('chalk');
6
6
  require('fs');
package/dist/lib.d.cts CHANGED
@@ -580,6 +580,31 @@ declare class RpcHandlerManager {
580
580
  private getPrefixedMethod;
581
581
  }
582
582
 
583
+ /**
584
+ * Minimal persistence functions for happy CLI
585
+ *
586
+ * Handles settings and private key storage in ~/.happy/ or local .happy/
587
+ */
588
+
589
+ type SigningCredentials = {
590
+ version: 1;
591
+ keyId: string;
592
+ seed: string;
593
+ algorithm: 'HMAC-SHA256';
594
+ };
595
+ type Credentials = {
596
+ token: string;
597
+ signing?: SigningCredentials | null;
598
+ encryption: {
599
+ type: 'legacy';
600
+ secret: Uint8Array;
601
+ } | {
602
+ type: 'dataKey';
603
+ publicKey: Uint8Array;
604
+ machineKey: Uint8Array;
605
+ };
606
+ };
607
+
583
608
  /**
584
609
  * ACP (Agent Communication Protocol) message data types.
585
610
  * This is the unified format for all agent messages - CLI adapts each provider's format to ACP.
@@ -637,7 +662,7 @@ type ACPMessageData = {
637
662
  [key: string]: unknown;
638
663
  };
639
664
  declare class ApiSessionClient extends EventEmitter {
640
- private readonly token;
665
+ private readonly credentials;
641
666
  readonly sessionId: string;
642
667
  private metadata;
643
668
  private metadataVersion;
@@ -651,7 +676,7 @@ declare class ApiSessionClient extends EventEmitter {
651
676
  private metadataLock;
652
677
  private encryptionKey;
653
678
  private encryptionVariant;
654
- constructor(token: string, session: Session);
679
+ constructor(credentials: Credentials, session: Session);
655
680
  onUserMessage(callback: (data: UserMessage) => void): void;
656
681
  /**
657
682
  * Send message to session
@@ -745,12 +770,12 @@ type MachineRpcHandlers = {
745
770
  requestShutdown: () => void;
746
771
  };
747
772
  declare class ApiMachineClient {
748
- private token;
773
+ private credentials;
749
774
  private machine;
750
775
  private socket;
751
776
  private keepAliveInterval;
752
777
  private rpcHandlerManager;
753
- constructor(token: string, machine: Machine);
778
+ constructor(credentials: Credentials, machine: Machine);
754
779
  setRPCHandlers({ spawnSession, stopSession, requestShutdown }: MachineRpcHandlers): void;
755
780
  /**
756
781
  * Update machine metadata
@@ -776,10 +801,10 @@ interface PushToken {
776
801
  updatedAt: number;
777
802
  }
778
803
  declare class PushNotificationClient {
779
- private readonly token;
804
+ private readonly credentials;
780
805
  private readonly baseUrl;
781
806
  private readonly expo;
782
- constructor(token: string, baseUrl?: string);
807
+ constructor(credentials: Credentials, baseUrl?: string);
783
808
  /**
784
809
  * Fetch all push tokens for the authenticated user
785
810
  */
@@ -798,29 +823,12 @@ declare class PushNotificationClient {
798
823
  sendToAllDevices(title: string, body: string, data?: Record<string, any>): void;
799
824
  }
800
825
 
801
- /**
802
- * Minimal persistence functions for happy CLI
803
- *
804
- * Handles settings and private key storage in ~/.happy/ or local .happy/
805
- */
806
-
807
- type Credentials = {
808
- token: string;
809
- encryption: {
810
- type: 'legacy';
811
- secret: Uint8Array;
812
- } | {
813
- type: 'dataKey';
814
- publicKey: Uint8Array;
815
- machineKey: Uint8Array;
816
- };
817
- };
818
-
819
826
  declare class ApiClient {
820
827
  static create(credential: Credentials): Promise<ApiClient>;
821
828
  private readonly credential;
822
829
  private readonly pushClient;
823
830
  private constructor();
831
+ private request;
824
832
  /**
825
833
  * Create a new session or load existing one with the given tag
826
834
  */
package/dist/lib.d.mts CHANGED
@@ -580,6 +580,31 @@ declare class RpcHandlerManager {
580
580
  private getPrefixedMethod;
581
581
  }
582
582
 
583
+ /**
584
+ * Minimal persistence functions for happy CLI
585
+ *
586
+ * Handles settings and private key storage in ~/.happy/ or local .happy/
587
+ */
588
+
589
+ type SigningCredentials = {
590
+ version: 1;
591
+ keyId: string;
592
+ seed: string;
593
+ algorithm: 'HMAC-SHA256';
594
+ };
595
+ type Credentials = {
596
+ token: string;
597
+ signing?: SigningCredentials | null;
598
+ encryption: {
599
+ type: 'legacy';
600
+ secret: Uint8Array;
601
+ } | {
602
+ type: 'dataKey';
603
+ publicKey: Uint8Array;
604
+ machineKey: Uint8Array;
605
+ };
606
+ };
607
+
583
608
  /**
584
609
  * ACP (Agent Communication Protocol) message data types.
585
610
  * This is the unified format for all agent messages - CLI adapts each provider's format to ACP.
@@ -637,7 +662,7 @@ type ACPMessageData = {
637
662
  [key: string]: unknown;
638
663
  };
639
664
  declare class ApiSessionClient extends EventEmitter {
640
- private readonly token;
665
+ private readonly credentials;
641
666
  readonly sessionId: string;
642
667
  private metadata;
643
668
  private metadataVersion;
@@ -651,7 +676,7 @@ declare class ApiSessionClient extends EventEmitter {
651
676
  private metadataLock;
652
677
  private encryptionKey;
653
678
  private encryptionVariant;
654
- constructor(token: string, session: Session);
679
+ constructor(credentials: Credentials, session: Session);
655
680
  onUserMessage(callback: (data: UserMessage) => void): void;
656
681
  /**
657
682
  * Send message to session
@@ -745,12 +770,12 @@ type MachineRpcHandlers = {
745
770
  requestShutdown: () => void;
746
771
  };
747
772
  declare class ApiMachineClient {
748
- private token;
773
+ private credentials;
749
774
  private machine;
750
775
  private socket;
751
776
  private keepAliveInterval;
752
777
  private rpcHandlerManager;
753
- constructor(token: string, machine: Machine);
778
+ constructor(credentials: Credentials, machine: Machine);
754
779
  setRPCHandlers({ spawnSession, stopSession, requestShutdown }: MachineRpcHandlers): void;
755
780
  /**
756
781
  * Update machine metadata
@@ -776,10 +801,10 @@ interface PushToken {
776
801
  updatedAt: number;
777
802
  }
778
803
  declare class PushNotificationClient {
779
- private readonly token;
804
+ private readonly credentials;
780
805
  private readonly baseUrl;
781
806
  private readonly expo;
782
- constructor(token: string, baseUrl?: string);
807
+ constructor(credentials: Credentials, baseUrl?: string);
783
808
  /**
784
809
  * Fetch all push tokens for the authenticated user
785
810
  */
@@ -798,29 +823,12 @@ declare class PushNotificationClient {
798
823
  sendToAllDevices(title: string, body: string, data?: Record<string, any>): void;
799
824
  }
800
825
 
801
- /**
802
- * Minimal persistence functions for happy CLI
803
- *
804
- * Handles settings and private key storage in ~/.happy/ or local .happy/
805
- */
806
-
807
- type Credentials = {
808
- token: string;
809
- encryption: {
810
- type: 'legacy';
811
- secret: Uint8Array;
812
- } | {
813
- type: 'dataKey';
814
- publicKey: Uint8Array;
815
- machineKey: Uint8Array;
816
- };
817
- };
818
-
819
826
  declare class ApiClient {
820
827
  static create(credential: Credentials): Promise<ApiClient>;
821
828
  private readonly credential;
822
829
  private readonly pushClient;
823
830
  private constructor();
831
+ private request;
824
832
  /**
825
833
  * Create a new session or load existing one with the given tag
826
834
  */
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-DY1-MAPO.mjs';
1
+ export { A as ApiClient, a as ApiSessionClient, R as RawJSONLinesSchema, c as configuration, l as logger } from './types-BXyraW9R.mjs';
2
2
  import 'axios';
3
3
  import 'chalk';
4
4
  import 'fs';
@@ -1,7 +1,7 @@
1
1
  import { readFile, open, stat, unlink, mkdir, writeFile, rename } from 'node:fs/promises';
2
2
  import { existsSync, constants, unlinkSync, writeFileSync, readdirSync, readFileSync } from 'node:fs';
3
3
  import { join, dirname } from 'node:path';
4
- import { c as configuration, l as logger, e as encodeBase64 } from './types-DY1-MAPO.mjs';
4
+ import { c as configuration, l as logger, e as encodeBase64 } from './types-BXyraW9R.mjs';
5
5
  import * as z from 'zod';
6
6
  import 'axios';
7
7
  import 'chalk';
@@ -230,6 +230,12 @@ async function updateSettings(updater) {
230
230
  }
231
231
  const credentialsSchema = z.object({
232
232
  token: z.string(),
233
+ signing: z.object({
234
+ version: z.literal(1),
235
+ keyId: z.string(),
236
+ seed: z.string().base64(),
237
+ algorithm: z.literal("HMAC-SHA256")
238
+ }).nullish(),
233
239
  secret: z.string().base64().nullish(),
234
240
  // Legacy
235
241
  encryption: z.object({
@@ -247,6 +253,7 @@ async function readCredentials() {
247
253
  if (credentials.secret) {
248
254
  return {
249
255
  token: credentials.token,
256
+ signing: credentials.signing ?? null,
250
257
  encryption: {
251
258
  type: "legacy",
252
259
  secret: new Uint8Array(Buffer.from(credentials.secret, "base64"))
@@ -255,6 +262,7 @@ async function readCredentials() {
255
262
  } else if (credentials.encryption) {
256
263
  return {
257
264
  token: credentials.token,
265
+ signing: credentials.signing ?? null,
258
266
  encryption: {
259
267
  type: "dataKey",
260
268
  publicKey: new Uint8Array(Buffer.from(credentials.encryption.publicKey, "base64")),
@@ -273,7 +281,8 @@ async function writeCredentialsLegacy(credentials) {
273
281
  }
274
282
  await writeFile(configuration.privateKeyFile, JSON.stringify({
275
283
  secret: encodeBase64(credentials.secret),
276
- token: credentials.token
284
+ token: credentials.token,
285
+ signing: credentials.signing
277
286
  }, null, 2));
278
287
  }
279
288
  async function writeCredentialsDataKey(credentials) {
@@ -282,7 +291,8 @@ async function writeCredentialsDataKey(credentials) {
282
291
  }
283
292
  await writeFile(configuration.privateKeyFile, JSON.stringify({
284
293
  encryption: { publicKey: encodeBase64(credentials.publicKey), machineKey: encodeBase64(credentials.machineKey) },
285
- token: credentials.token
294
+ token: credentials.token,
295
+ signing: credentials.signing
286
296
  }, null, 2));
287
297
  }
288
298
  async function clearCredentials() {