happy-imou-cloud 2.1.20 → 2.1.22

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 (28) hide show
  1. package/dist/{BaseReasoningProcessor-BrPfiZf4.cjs → BaseReasoningProcessor-BVdXoFXc.cjs} +2 -2
  2. package/dist/{BaseReasoningProcessor-CQ59YfWV.mjs → BaseReasoningProcessor-BYNLDM-T.mjs} +2 -2
  3. package/dist/{ProviderSelectionHandler-B8EGoc4L.cjs → ProviderSelectionHandler-DDzNcWPJ.cjs} +2 -2
  4. package/dist/{ProviderSelectionHandler-D9WDj0pS.mjs → ProviderSelectionHandler-DgINCAMh.mjs} +2 -2
  5. package/dist/{api-BtjmMYKf.cjs → api-BXGRJ5Kn.cjs} +77 -16
  6. package/dist/{api-CtjWkGWV.mjs → api-bhF1J82q.mjs} +75 -17
  7. package/dist/{command-D9Xa72wn.cjs → command-Byj1OLb9.cjs} +2 -2
  8. package/dist/{command-BV2wo6tq.mjs → command-CyUpFVkQ.mjs} +2 -2
  9. package/dist/{index-WIr2Wt9U.cjs → index-BNTRi6Uv.cjs} +387 -24
  10. package/dist/{index-hL-ID2fR.mjs → index-CEhnCQim.mjs} +385 -22
  11. package/dist/index.cjs +2 -2
  12. package/dist/index.mjs +2 -2
  13. package/dist/lib.cjs +1 -1
  14. package/dist/lib.d.cts +132 -72
  15. package/dist/lib.d.mts +132 -72
  16. package/dist/lib.mjs +1 -1
  17. package/dist/{registerKillSessionHandler-D9JiuWdb.mjs → registerKillSessionHandler-BtPo6LkG.mjs} +2 -2
  18. package/dist/{registerKillSessionHandler-D0EYq7uF.cjs → registerKillSessionHandler-CuP57vY0.cjs} +2 -2
  19. package/dist/{runClaude-BQ3EPwaa.mjs → runClaude-CMKm1bBe.mjs} +4 -4
  20. package/dist/{runClaude-CAelse1X.cjs → runClaude-CqJgxqjW.cjs} +4 -4
  21. package/dist/{runCodex-4njIyif-.mjs → runCodex-BkfujuLR.mjs} +9 -7
  22. package/dist/{runCodex-ofeVc4Nl.cjs → runCodex-DIaZ1wGI.cjs} +9 -7
  23. package/dist/{runGemini-ClDpc5hl.mjs → runGemini-DcN0Nb3f.mjs} +4 -4
  24. package/dist/{runGemini-ChlLWNak.cjs → runGemini-U4GRLlSn.cjs} +4 -4
  25. package/package.json +3 -2
  26. package/scripts/build.mjs +38 -34
  27. package/scripts/release-smoke.mjs +17 -39
  28. package/scripts/tooling-utils.mjs +167 -0
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-WIr2Wt9U.cjs');
4
- var persistence = require('./api-BtjmMYKf.cjs');
3
+ var index = require('./index-BNTRi6Uv.cjs');
4
+ var persistence = require('./api-BXGRJ5Kn.cjs');
5
5
  var node_events = require('node:events');
6
6
  var node_crypto = require('node:crypto');
7
7
 
@@ -1,5 +1,5 @@
1
- import { a as createSessionMetadata, p as publishSessionRegistration } from './index-hL-ID2fR.mjs';
2
- import { s as startOfflineReconnection, c as configuration, i as isAuthenticationRequiredError, l as logger } from './api-CtjWkGWV.mjs';
1
+ import { a as createSessionMetadata, p as publishSessionRegistration } from './index-CEhnCQim.mjs';
2
+ import { s as startOfflineReconnection, c as configuration, i as isAuthenticationRequiredError, l as logger } from './api-bhF1J82q.mjs';
3
3
  import { EventEmitter } from 'node:events';
4
4
  import { randomUUID } from 'node:crypto';
5
5
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var persistence = require('./api-BtjmMYKf.cjs');
4
- var registerKillSessionHandler = require('./registerKillSessionHandler-D0EYq7uF.cjs');
3
+ var persistence = require('./api-BXGRJ5Kn.cjs');
4
+ var registerKillSessionHandler = require('./registerKillSessionHandler-CuP57vY0.cjs');
5
5
 
6
6
  async function runModeLoop(opts) {
7
7
  let currentMode = opts.startingMode;
@@ -1,5 +1,5 @@
1
- import { l as logger } from './api-CtjWkGWV.mjs';
2
- import { g as getPendingInteractionTimeoutMs, I as INTERACTION_SUPERSEDED_ERROR, a as INTERACTION_TIMED_OUT_ERROR } from './registerKillSessionHandler-D9JiuWdb.mjs';
1
+ import { l as logger } from './api-bhF1J82q.mjs';
2
+ import { g as getPendingInteractionTimeoutMs, I as INTERACTION_SUPERSEDED_ERROR, a as INTERACTION_TIMED_OUT_ERROR } from './registerKillSessionHandler-BtPo6LkG.mjs';
3
3
 
4
4
  async function runModeLoop(opts) {
5
5
  let currentMode = opts.startingMode;
@@ -38,7 +38,7 @@ function _interopNamespaceDefault(e) {
38
38
  var z__namespace = /*#__PURE__*/_interopNamespaceDefault(z);
39
39
 
40
40
  var name = "happy-imou-cloud";
41
- var version = "2.1.20";
41
+ var version = "2.1.22";
42
42
  var description = "hicloud - Imou 企业定制版。关键是 happy!移动端远程 AI 编程工具,支持 Claude Code、Codex 和 Gemini CLI";
43
43
  var author = "long.zhu";
44
44
  var license = "MIT";
@@ -120,7 +120,8 @@ var scripts = {
120
120
  doctor: "node scripts/env-wrapper.cjs stable doctor",
121
121
  "// ==== Development Linking ====": "",
122
122
  "link:dev": "node scripts/link-dev.cjs",
123
- "unlink:dev": "node scripts/link-dev.cjs unlink"
123
+ "unlink:dev": "node scripts/link-dev.cjs unlink",
124
+ "test:happy-org-1.2-quality": "node ../../node_modules/vitest/vitest.mjs run --config vitest.happy-org-1.2.config.mjs"
124
125
  };
125
126
  var dependencies = {
126
127
  "@agentclientprotocol/sdk": "0.16.1",
@@ -863,7 +864,9 @@ const credentialsSchema = z__namespace.object({
863
864
  encryption: z__namespace.object({
864
865
  publicKey: z__namespace.string().base64(),
865
866
  machineKey: z__namespace.string().base64()
866
- }).nullish()
867
+ }).nullish(),
868
+ aesKey: z__namespace.string().nullish()
869
+ // AES shared key for enterprise comm (hex), from login response
867
870
  });
868
871
  async function readCredentials() {
869
872
  if (!fs.existsSync(configuration.privateKeyFile)) {
@@ -876,6 +879,7 @@ async function readCredentials() {
876
879
  return {
877
880
  token: credentials.token,
878
881
  signing: credentials.signing ?? null,
882
+ aesKey: credentials.aesKey ?? void 0,
879
883
  encryption: {
880
884
  type: "legacy",
881
885
  secret: new Uint8Array(Buffer.from(credentials.secret, "base64"))
@@ -885,6 +889,7 @@ async function readCredentials() {
885
889
  return {
886
890
  token: credentials.token,
887
891
  signing: credentials.signing ?? null,
892
+ aesKey: credentials.aesKey ?? void 0,
888
893
  encryption: {
889
894
  type: "dataKey",
890
895
  publicKey: new Uint8Array(Buffer.from(credentials.encryption.publicKey, "base64")),
@@ -904,7 +909,8 @@ async function writeCredentialsLegacy(credentials) {
904
909
  await promises.writeFile(configuration.privateKeyFile, JSON.stringify({
905
910
  secret: encodeBase64(credentials.secret),
906
911
  token: credentials.token,
907
- signing: credentials.signing
912
+ signing: credentials.signing,
913
+ aesKey: credentials.aesKey
908
914
  }, null, 2));
909
915
  }
910
916
  async function writeCredentialsDataKey(credentials) {
@@ -914,7 +920,8 @@ async function writeCredentialsDataKey(credentials) {
914
920
  await promises.writeFile(configuration.privateKeyFile, JSON.stringify({
915
921
  encryption: { publicKey: encodeBase64(credentials.publicKey), machineKey: encodeBase64(credentials.machineKey) },
916
922
  token: credentials.token,
917
- signing: credentials.signing
923
+ signing: credentials.signing,
924
+ aesKey: credentials.aesKey
918
925
  }, null, 2));
919
926
  }
920
927
  async function clearCredentials() {
@@ -1301,11 +1308,18 @@ const ProtocolV3DescriptorSchema = z.z.object({
1301
1308
  const ProtocolV3CapabilitiesResponseSchema = z.z.object({
1302
1309
  protocol: ProtocolV3DescriptorSchema
1303
1310
  });
1304
- const SessionMessageContentSchema = z.z.object({
1305
- c: z.z.string(),
1306
- // Base64 encoded encrypted content
1307
- t: z.z.literal("encrypted")
1308
- });
1311
+ const SessionMessageContentSchema = z.z.union([
1312
+ z.z.object({
1313
+ t: z.z.literal("encrypted"),
1314
+ c: z.z.string()
1315
+ // Base64 encoded encrypted content
1316
+ }),
1317
+ z.z.object({
1318
+ t: z.z.literal("plaintext"),
1319
+ p: z.z.string()
1320
+ // Plaintext JSON string (AES mode, server pre-decrypted)
1321
+ })
1322
+ ]);
1309
1323
  const NewSessionBodySchema = z.z.object({
1310
1324
  t: z.z.literal("new-session"),
1311
1325
  id: z.z.string(),
@@ -1542,7 +1556,7 @@ const AgentMessageSchema = z.z.object({
1542
1556
  }),
1543
1557
  meta: MessageMetaSchema.optional()
1544
1558
  });
1545
- z.z.union([UserMessageSchema, AgentMessageSchema]);
1559
+ const MessageContentSchema = z.z.union([UserMessageSchema, AgentMessageSchema]);
1546
1560
 
1547
1561
  function buildSessionRuntimeIndex(metadata) {
1548
1562
  if (!metadata) {
@@ -2445,20 +2459,23 @@ async function ensureSigningCredentials(credentials, opts = {}) {
2445
2459
  const upgradedCredentials = {
2446
2460
  ...credentials,
2447
2461
  token: response.data.token,
2448
- signing: response.data.signing
2462
+ signing: response.data.signing,
2463
+ aesKey: response.data.aesKey ?? credentials.aesKey
2449
2464
  };
2450
2465
  if (upgradedCredentials.encryption.type === "legacy") {
2451
2466
  await writeCredentialsLegacy({
2452
2467
  secret: upgradedCredentials.encryption.secret,
2453
2468
  token: upgradedCredentials.token,
2454
- signing: upgradedCredentials.signing
2469
+ signing: upgradedCredentials.signing,
2470
+ aesKey: upgradedCredentials.aesKey
2455
2471
  });
2456
2472
  } else {
2457
2473
  await writeCredentialsDataKey({
2458
2474
  publicKey: upgradedCredentials.encryption.publicKey,
2459
2475
  machineKey: upgradedCredentials.encryption.machineKey,
2460
2476
  token: upgradedCredentials.token,
2461
- signing: upgradedCredentials.signing
2477
+ signing: upgradedCredentials.signing,
2478
+ aesKey: upgradedCredentials.aesKey
2462
2479
  });
2463
2480
  }
2464
2481
  logger.debug("[AUTH] Signing credentials bootstrapped successfully");
@@ -3118,6 +3135,17 @@ class ApiSessionClient extends node_events.EventEmitter {
3118
3135
  logger.debug("[SOCKET] [UPDATE] [ERROR] No body in update!");
3119
3136
  return;
3120
3137
  }
3138
+ if (data.body.t === "new-message" && data.body.message.content.t === "plaintext") {
3139
+ const messageSeq = typeof data.body.message.seq === "number" ? data.body.message.seq : null;
3140
+ if (messageSeq !== null && messageSeq <= this.lastChangeSeq) {
3141
+ return;
3142
+ }
3143
+ this.dispatchPlaintextSessionMessage(data.body.message.content.p);
3144
+ if (messageSeq !== null) {
3145
+ this.lastChangeSeq = Math.max(this.lastChangeSeq, messageSeq);
3146
+ }
3147
+ return;
3148
+ }
3121
3149
  if (data.body.t === "new-message" && data.body.message.content.t === "encrypted") {
3122
3150
  const messageSeq = typeof data.body.message.seq === "number" ? data.body.message.seq : null;
3123
3151
  if (messageSeq !== null && messageSeq <= this.lastChangeSeq) {
@@ -3184,6 +3212,32 @@ class ApiSessionClient extends node_events.EventEmitter {
3184
3212
  }
3185
3213
  this.emit("message", parsedBody);
3186
3214
  }
3215
+ /**
3216
+ * Dispatch a plaintext session message (AES mode: server already decrypted).
3217
+ * The plaintext JSON is parsed and validated as a UserMessage.
3218
+ */
3219
+ dispatchPlaintextSessionMessage(plaintextJson) {
3220
+ logger.debug("[SOCKET] [UPDATE] [PLAINTEXT] Received plaintext message");
3221
+ let parsedBody = null;
3222
+ try {
3223
+ parsedBody = JSON.parse(plaintextJson);
3224
+ } catch {
3225
+ logger.debug("[SOCKET] [UPDATE] [PLAINTEXT] Failed to parse plaintext JSON, ignoring");
3226
+ return;
3227
+ }
3228
+ const userResult = UserMessageSchema.safeParse(parsedBody);
3229
+ if (userResult.success) {
3230
+ this.maybeAutoAcknowledgeHappyOrgDispatch(userResult.data);
3231
+ if (this.pendingMessageCallback) {
3232
+ this.pendingMessageCallback(userResult.data);
3233
+ } else {
3234
+ this.pendingMessages.push(userResult.data);
3235
+ }
3236
+ return;
3237
+ }
3238
+ logger.debug("[SOCKET] [UPDATE] [PLAINTEXT] Message did not match UserMessageSchema, emitting generic event");
3239
+ this.emit("message", parsedBody);
3240
+ }
3187
3241
  maybeAutoAcknowledgeHappyOrgDispatch(message) {
3188
3242
  const candidate = this.resolveHappyOrgDispatchBusinessAckCandidate(message);
3189
3243
  if (!candidate) {
@@ -3491,7 +3545,9 @@ class ApiSessionClient extends node_events.EventEmitter {
3491
3545
  if (message.seq <= this.lastChangeSeq) {
3492
3546
  continue;
3493
3547
  }
3494
- if (message.content.t === "encrypted") {
3548
+ if (message.content.t === "plaintext") {
3549
+ this.dispatchPlaintextSessionMessage(message.content.p);
3550
+ } else if (message.content.t === "encrypted") {
3495
3551
  this.dispatchEncryptedSessionMessage(message.content.c);
3496
3552
  }
3497
3553
  this.lastChangeSeq = Math.max(this.lastChangeSeq, message.seq);
@@ -3522,7 +3578,9 @@ class ApiSessionClient extends node_events.EventEmitter {
3522
3578
  const message = payload.message;
3523
3579
  if (message && typeof message === "object") {
3524
3580
  const content = message.content;
3525
- if (content && typeof content === "object" && content.t === "encrypted" && typeof content.c === "string") {
3581
+ if (content && typeof content === "object" && content.t === "plaintext" && typeof content.p === "string") {
3582
+ this.dispatchPlaintextSessionMessage(content.p);
3583
+ } else if (content && typeof content === "object" && content.t === "encrypted" && typeof content.c === "string") {
3526
3584
  this.dispatchEncryptedSessionMessage(content.c);
3527
3585
  }
3528
3586
  }
@@ -5087,10 +5145,12 @@ exports.HAPPY_ORG_REPEAT_THRESHOLD = HAPPY_ORG_REPEAT_THRESHOLD;
5087
5145
  exports.HAPPY_ORG_SUMMARY_MAX_LENGTH = HAPPY_ORG_SUMMARY_MAX_LENGTH;
5088
5146
  exports.HAPPY_ORG_TURN_REPORT_TAG = HAPPY_ORG_TURN_REPORT_TAG;
5089
5147
  exports.HeadTailPreviewBuffer = HeadTailPreviewBuffer;
5148
+ exports.MessageContentSchema = MessageContentSchema;
5090
5149
  exports.acquireDaemonLock = acquireDaemonLock;
5091
5150
  exports.api = api;
5092
5151
  exports.backoff = backoff;
5093
5152
  exports.buildClientHeaders = buildClientHeaders;
5153
+ exports.buildSocketAuth = buildSocketAuth;
5094
5154
  exports.clearCredentials = clearCredentials;
5095
5155
  exports.clearDaemonState = clearDaemonState;
5096
5156
  exports.clearMachineId = clearMachineId;
@@ -5100,6 +5160,7 @@ exports.decodeBase64 = decodeBase64;
5100
5160
  exports.delay = delay;
5101
5161
  exports.encodeBase64 = encodeBase64;
5102
5162
  exports.encodeBase64Url = encodeBase64Url;
5163
+ exports.encrypt = encrypt;
5103
5164
  exports.ensureSigningCredentials = ensureSigningCredentials;
5104
5165
  exports.getLatestDaemonLog = getLatestDaemonLog;
5105
5166
  exports.getProfileEnvironmentVariables = getProfileEnvironmentVariables;
@@ -18,7 +18,7 @@ import { unlink, readFile, mkdir, open, stat, writeFile, rename } from 'node:fs/
18
18
  import { Expo } from 'expo-server-sdk';
19
19
 
20
20
  var name = "happy-imou-cloud";
21
- var version = "2.1.20";
21
+ var version = "2.1.22";
22
22
  var description = "hicloud - Imou 企业定制版。关键是 happy!移动端远程 AI 编程工具,支持 Claude Code、Codex 和 Gemini CLI";
23
23
  var author = "long.zhu";
24
24
  var license = "MIT";
@@ -100,7 +100,8 @@ var scripts = {
100
100
  doctor: "node scripts/env-wrapper.cjs stable doctor",
101
101
  "// ==== Development Linking ====": "",
102
102
  "link:dev": "node scripts/link-dev.cjs",
103
- "unlink:dev": "node scripts/link-dev.cjs unlink"
103
+ "unlink:dev": "node scripts/link-dev.cjs unlink",
104
+ "test:happy-org-1.2-quality": "node ../../node_modules/vitest/vitest.mjs run --config vitest.happy-org-1.2.config.mjs"
104
105
  };
105
106
  var dependencies = {
106
107
  "@agentclientprotocol/sdk": "0.16.1",
@@ -843,7 +844,9 @@ const credentialsSchema = z.object({
843
844
  encryption: z.object({
844
845
  publicKey: z.string().base64(),
845
846
  machineKey: z.string().base64()
846
- }).nullish()
847
+ }).nullish(),
848
+ aesKey: z.string().nullish()
849
+ // AES shared key for enterprise comm (hex), from login response
847
850
  });
848
851
  async function readCredentials() {
849
852
  if (!existsSync(configuration.privateKeyFile)) {
@@ -856,6 +859,7 @@ async function readCredentials() {
856
859
  return {
857
860
  token: credentials.token,
858
861
  signing: credentials.signing ?? null,
862
+ aesKey: credentials.aesKey ?? void 0,
859
863
  encryption: {
860
864
  type: "legacy",
861
865
  secret: new Uint8Array(Buffer.from(credentials.secret, "base64"))
@@ -865,6 +869,7 @@ async function readCredentials() {
865
869
  return {
866
870
  token: credentials.token,
867
871
  signing: credentials.signing ?? null,
872
+ aesKey: credentials.aesKey ?? void 0,
868
873
  encryption: {
869
874
  type: "dataKey",
870
875
  publicKey: new Uint8Array(Buffer.from(credentials.encryption.publicKey, "base64")),
@@ -884,7 +889,8 @@ async function writeCredentialsLegacy(credentials) {
884
889
  await writeFile(configuration.privateKeyFile, JSON.stringify({
885
890
  secret: encodeBase64(credentials.secret),
886
891
  token: credentials.token,
887
- signing: credentials.signing
892
+ signing: credentials.signing,
893
+ aesKey: credentials.aesKey
888
894
  }, null, 2));
889
895
  }
890
896
  async function writeCredentialsDataKey(credentials) {
@@ -894,7 +900,8 @@ async function writeCredentialsDataKey(credentials) {
894
900
  await writeFile(configuration.privateKeyFile, JSON.stringify({
895
901
  encryption: { publicKey: encodeBase64(credentials.publicKey), machineKey: encodeBase64(credentials.machineKey) },
896
902
  token: credentials.token,
897
- signing: credentials.signing
903
+ signing: credentials.signing,
904
+ aesKey: credentials.aesKey
898
905
  }, null, 2));
899
906
  }
900
907
  async function clearCredentials() {
@@ -1281,11 +1288,18 @@ const ProtocolV3DescriptorSchema = z$1.object({
1281
1288
  const ProtocolV3CapabilitiesResponseSchema = z$1.object({
1282
1289
  protocol: ProtocolV3DescriptorSchema
1283
1290
  });
1284
- const SessionMessageContentSchema = z$1.object({
1285
- c: z$1.string(),
1286
- // Base64 encoded encrypted content
1287
- t: z$1.literal("encrypted")
1288
- });
1291
+ const SessionMessageContentSchema = z$1.union([
1292
+ z$1.object({
1293
+ t: z$1.literal("encrypted"),
1294
+ c: z$1.string()
1295
+ // Base64 encoded encrypted content
1296
+ }),
1297
+ z$1.object({
1298
+ t: z$1.literal("plaintext"),
1299
+ p: z$1.string()
1300
+ // Plaintext JSON string (AES mode, server pre-decrypted)
1301
+ })
1302
+ ]);
1289
1303
  const NewSessionBodySchema = z$1.object({
1290
1304
  t: z$1.literal("new-session"),
1291
1305
  id: z$1.string(),
@@ -1522,7 +1536,7 @@ const AgentMessageSchema = z$1.object({
1522
1536
  }),
1523
1537
  meta: MessageMetaSchema.optional()
1524
1538
  });
1525
- z$1.union([UserMessageSchema, AgentMessageSchema]);
1539
+ const MessageContentSchema = z$1.union([UserMessageSchema, AgentMessageSchema]);
1526
1540
 
1527
1541
  function buildSessionRuntimeIndex(metadata) {
1528
1542
  if (!metadata) {
@@ -2425,20 +2439,23 @@ async function ensureSigningCredentials(credentials, opts = {}) {
2425
2439
  const upgradedCredentials = {
2426
2440
  ...credentials,
2427
2441
  token: response.data.token,
2428
- signing: response.data.signing
2442
+ signing: response.data.signing,
2443
+ aesKey: response.data.aesKey ?? credentials.aesKey
2429
2444
  };
2430
2445
  if (upgradedCredentials.encryption.type === "legacy") {
2431
2446
  await writeCredentialsLegacy({
2432
2447
  secret: upgradedCredentials.encryption.secret,
2433
2448
  token: upgradedCredentials.token,
2434
- signing: upgradedCredentials.signing
2449
+ signing: upgradedCredentials.signing,
2450
+ aesKey: upgradedCredentials.aesKey
2435
2451
  });
2436
2452
  } else {
2437
2453
  await writeCredentialsDataKey({
2438
2454
  publicKey: upgradedCredentials.encryption.publicKey,
2439
2455
  machineKey: upgradedCredentials.encryption.machineKey,
2440
2456
  token: upgradedCredentials.token,
2441
- signing: upgradedCredentials.signing
2457
+ signing: upgradedCredentials.signing,
2458
+ aesKey: upgradedCredentials.aesKey
2442
2459
  });
2443
2460
  }
2444
2461
  logger.debug("[AUTH] Signing credentials bootstrapped successfully");
@@ -3098,6 +3115,17 @@ class ApiSessionClient extends EventEmitter {
3098
3115
  logger.debug("[SOCKET] [UPDATE] [ERROR] No body in update!");
3099
3116
  return;
3100
3117
  }
3118
+ if (data.body.t === "new-message" && data.body.message.content.t === "plaintext") {
3119
+ const messageSeq = typeof data.body.message.seq === "number" ? data.body.message.seq : null;
3120
+ if (messageSeq !== null && messageSeq <= this.lastChangeSeq) {
3121
+ return;
3122
+ }
3123
+ this.dispatchPlaintextSessionMessage(data.body.message.content.p);
3124
+ if (messageSeq !== null) {
3125
+ this.lastChangeSeq = Math.max(this.lastChangeSeq, messageSeq);
3126
+ }
3127
+ return;
3128
+ }
3101
3129
  if (data.body.t === "new-message" && data.body.message.content.t === "encrypted") {
3102
3130
  const messageSeq = typeof data.body.message.seq === "number" ? data.body.message.seq : null;
3103
3131
  if (messageSeq !== null && messageSeq <= this.lastChangeSeq) {
@@ -3164,6 +3192,32 @@ class ApiSessionClient extends EventEmitter {
3164
3192
  }
3165
3193
  this.emit("message", parsedBody);
3166
3194
  }
3195
+ /**
3196
+ * Dispatch a plaintext session message (AES mode: server already decrypted).
3197
+ * The plaintext JSON is parsed and validated as a UserMessage.
3198
+ */
3199
+ dispatchPlaintextSessionMessage(plaintextJson) {
3200
+ logger.debug("[SOCKET] [UPDATE] [PLAINTEXT] Received plaintext message");
3201
+ let parsedBody = null;
3202
+ try {
3203
+ parsedBody = JSON.parse(plaintextJson);
3204
+ } catch {
3205
+ logger.debug("[SOCKET] [UPDATE] [PLAINTEXT] Failed to parse plaintext JSON, ignoring");
3206
+ return;
3207
+ }
3208
+ const userResult = UserMessageSchema.safeParse(parsedBody);
3209
+ if (userResult.success) {
3210
+ this.maybeAutoAcknowledgeHappyOrgDispatch(userResult.data);
3211
+ if (this.pendingMessageCallback) {
3212
+ this.pendingMessageCallback(userResult.data);
3213
+ } else {
3214
+ this.pendingMessages.push(userResult.data);
3215
+ }
3216
+ return;
3217
+ }
3218
+ logger.debug("[SOCKET] [UPDATE] [PLAINTEXT] Message did not match UserMessageSchema, emitting generic event");
3219
+ this.emit("message", parsedBody);
3220
+ }
3167
3221
  maybeAutoAcknowledgeHappyOrgDispatch(message) {
3168
3222
  const candidate = this.resolveHappyOrgDispatchBusinessAckCandidate(message);
3169
3223
  if (!candidate) {
@@ -3471,7 +3525,9 @@ class ApiSessionClient extends EventEmitter {
3471
3525
  if (message.seq <= this.lastChangeSeq) {
3472
3526
  continue;
3473
3527
  }
3474
- if (message.content.t === "encrypted") {
3528
+ if (message.content.t === "plaintext") {
3529
+ this.dispatchPlaintextSessionMessage(message.content.p);
3530
+ } else if (message.content.t === "encrypted") {
3475
3531
  this.dispatchEncryptedSessionMessage(message.content.c);
3476
3532
  }
3477
3533
  this.lastChangeSeq = Math.max(this.lastChangeSeq, message.seq);
@@ -3502,7 +3558,9 @@ class ApiSessionClient extends EventEmitter {
3502
3558
  const message = payload.message;
3503
3559
  if (message && typeof message === "object") {
3504
3560
  const content = message.content;
3505
- if (content && typeof content === "object" && content.t === "encrypted" && typeof content.c === "string") {
3561
+ if (content && typeof content === "object" && content.t === "plaintext" && typeof content.p === "string") {
3562
+ this.dispatchPlaintextSessionMessage(content.p);
3563
+ } else if (content && typeof content === "object" && content.t === "encrypted" && typeof content.c === "string") {
3506
3564
  this.dispatchEncryptedSessionMessage(content.c);
3507
3565
  }
3508
3566
  }
@@ -5059,4 +5117,4 @@ var api = /*#__PURE__*/Object.freeze({
5059
5117
  ApiClient: ApiClient
5060
5118
  });
5061
5119
 
5062
- export { ApiClient as A, acquireDaemonLock as B, writeDaemonState as C, releaseDaemonLock as D, validateProfileForAgent as E, getProfileEnvironmentVariables as F, clearCredentials as G, HAPPY_ORG_TURN_REPORT_TAG as H, clearMachineId as I, HeadTailPreviewBuffer as J, getLatestDaemonLog as K, persistence as L, api as M, ApiSessionClient as a, connectionState as b, configuration as c, HAPPY_ORG_SUMMARY_MAX_LENGTH as d, HAPPY_ORG_REPEAT_THRESHOLD as e, backoff as f, delay as g, AsyncLock as h, isAuthenticationRequiredError as i, encodeBase64 as j, readCredentials as k, logger as l, ensureSigningCredentials as m, encodeBase64Url as n, buildClientHeaders as o, preserveSessionRuntimeMetadata as p, decodeBase64 as q, readSettings as r, startOfflineReconnection as s, writeCredentialsDataKey as t, updateSettings as u, readDaemonState as v, writeCredentialsLegacy as w, HAPPY_CLOUD_DAEMON_PORT as x, clearDaemonState as y, packageJson as z };
5120
+ export { ApiClient as A, acquireDaemonLock as B, writeDaemonState as C, releaseDaemonLock as D, validateProfileForAgent as E, getProfileEnvironmentVariables as F, clearCredentials as G, HAPPY_ORG_TURN_REPORT_TAG as H, clearMachineId as I, buildSocketAuth as J, encrypt as K, HeadTailPreviewBuffer as L, MessageContentSchema as M, getLatestDaemonLog as N, persistence as O, api as P, ApiSessionClient as a, connectionState as b, configuration as c, HAPPY_ORG_SUMMARY_MAX_LENGTH as d, HAPPY_ORG_REPEAT_THRESHOLD as e, backoff as f, delay as g, AsyncLock as h, isAuthenticationRequiredError as i, encodeBase64 as j, readCredentials as k, logger as l, ensureSigningCredentials as m, encodeBase64Url as n, buildClientHeaders as o, preserveSessionRuntimeMetadata as p, decodeBase64 as q, readSettings as r, startOfflineReconnection as s, writeCredentialsDataKey as t, updateSettings as u, readDaemonState as v, writeCredentialsLegacy as w, HAPPY_CLOUD_DAEMON_PORT as x, clearDaemonState as y, packageJson as z };
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-WIr2Wt9U.cjs');
3
+ var index = require('./index-BNTRi6Uv.cjs');
4
4
  require('chalk');
5
- require('./api-BtjmMYKf.cjs');
5
+ require('./api-BXGRJ5Kn.cjs');
6
6
  require('axios');
7
7
  require('fs');
8
8
  require('node:fs');
@@ -1,6 +1,6 @@
1
- import { c as createDefaultRuntimeShell } from './index-hL-ID2fR.mjs';
1
+ import { c as createDefaultRuntimeShell } from './index-CEhnCQim.mjs';
2
2
  import 'chalk';
3
- import './api-CtjWkGWV.mjs';
3
+ import './api-bhF1J82q.mjs';
4
4
  import 'axios';
5
5
  import 'fs';
6
6
  import 'node:fs';