happy-imou-cloud 2.1.21 → 2.1.23
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/{BaseReasoningProcessor-DdPnQSmQ.mjs → BaseReasoningProcessor-By0QiYEu.mjs} +2 -2
- package/dist/{BaseReasoningProcessor-DxFwO2z9.cjs → BaseReasoningProcessor-_EHQVXKN.cjs} +2 -2
- package/dist/{ProviderSelectionHandler-B5Aq5gA_.cjs → ProviderSelectionHandler-BSzm8oJH.cjs} +2 -2
- package/dist/{ProviderSelectionHandler-DQITIqZK.mjs → ProviderSelectionHandler-XwkBLKvY.mjs} +2 -2
- package/dist/{api-DB30ctmX.mjs → api-CDC4ZRT7.mjs} +73 -16
- package/dist/{api-8xtJZeXZ.cjs → api-CusZs0lm.cjs} +75 -15
- package/dist/{command-C6injNJE.mjs → command-B7O2Hn-D.mjs} +2 -2
- package/dist/{command-79M8Bz4I.cjs → command-Cp_bgCOD.cjs} +2 -2
- package/dist/{index-krVv4CWK.mjs → index-CFLvb1x1.mjs} +372 -55
- package/dist/{index-D4A092LJ.cjs → index-yX0QThPc.cjs} +374 -57
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +82 -22
- package/dist/lib.d.mts +82 -22
- package/dist/lib.mjs +1 -1
- package/dist/{registerKillSessionHandler-Cl_er9rg.cjs → registerKillSessionHandler-3f8MBSd6.cjs} +2 -2
- package/dist/{registerKillSessionHandler-beu2g-Qo.mjs → registerKillSessionHandler-aB2llDD3.mjs} +2 -2
- package/dist/{runClaude-DmXinUiz.cjs → runClaude-5moKE082.cjs} +4 -4
- package/dist/{runClaude-nzLh-orP.mjs → runClaude-BXO5ycyI.mjs} +4 -4
- package/dist/{runCodex-CoqsQ-cb.cjs → runCodex-BJn5KMLg.cjs} +9 -7
- package/dist/{runCodex-C-Pjpbxn.mjs → runCodex-DYEMgHdw.mjs} +9 -7
- package/dist/{runGemini-CIVm6NWC.mjs → runGemini-CHWnR9gf.mjs} +4 -4
- package/dist/{runGemini-BC_5rNMt.cjs → runGemini-CWG0QweX.cjs} +4 -4
- package/package.json +1 -1
- package/scripts/tooling-utils.mjs +167 -167
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as createSessionMetadata, p as publishSessionRegistration } from './index-
|
|
2
|
-
import { s as startOfflineReconnection, c as configuration, i as isAuthenticationRequiredError, l as logger } from './api-
|
|
1
|
+
import { a as createSessionMetadata, p as publishSessionRegistration } from './index-CFLvb1x1.mjs';
|
|
2
|
+
import { s as startOfflineReconnection, c as configuration, i as isAuthenticationRequiredError, l as logger } from './api-CDC4ZRT7.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 index = require('./index-
|
|
4
|
-
var persistence = require('./api-
|
|
3
|
+
var index = require('./index-yX0QThPc.cjs');
|
|
4
|
+
var persistence = require('./api-CusZs0lm.cjs');
|
|
5
5
|
var node_events = require('node:events');
|
|
6
6
|
var node_crypto = require('node:crypto');
|
|
7
7
|
|
package/dist/{ProviderSelectionHandler-B5Aq5gA_.cjs → ProviderSelectionHandler-BSzm8oJH.cjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var persistence = require('./api-
|
|
4
|
-
var registerKillSessionHandler = require('./registerKillSessionHandler-
|
|
3
|
+
var persistence = require('./api-CusZs0lm.cjs');
|
|
4
|
+
var registerKillSessionHandler = require('./registerKillSessionHandler-3f8MBSd6.cjs');
|
|
5
5
|
|
|
6
6
|
async function runModeLoop(opts) {
|
|
7
7
|
let currentMode = opts.startingMode;
|
package/dist/{ProviderSelectionHandler-DQITIqZK.mjs → ProviderSelectionHandler-XwkBLKvY.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as logger } from './api-
|
|
2
|
-
import { g as getPendingInteractionTimeoutMs, I as INTERACTION_SUPERSEDED_ERROR, a as INTERACTION_TIMED_OUT_ERROR } from './registerKillSessionHandler-
|
|
1
|
+
import { l as logger } from './api-CDC4ZRT7.mjs';
|
|
2
|
+
import { g as getPendingInteractionTimeoutMs, I as INTERACTION_SUPERSEDED_ERROR, a as INTERACTION_TIMED_OUT_ERROR } from './registerKillSessionHandler-aB2llDD3.mjs';
|
|
3
3
|
|
|
4
4
|
async function runModeLoop(opts) {
|
|
5
5
|
let currentMode = opts.startingMode;
|
|
@@ -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.
|
|
21
|
+
var version = "2.1.23";
|
|
22
22
|
var description = "hicloud - Imou 企业定制版。关键是 happy!移动端远程 AI 编程工具,支持 Claude Code、Codex 和 Gemini CLI";
|
|
23
23
|
var author = "long.zhu";
|
|
24
24
|
var license = "MIT";
|
|
@@ -844,7 +844,9 @@ const credentialsSchema = z.object({
|
|
|
844
844
|
encryption: z.object({
|
|
845
845
|
publicKey: z.string().base64(),
|
|
846
846
|
machineKey: z.string().base64()
|
|
847
|
-
}).nullish()
|
|
847
|
+
}).nullish(),
|
|
848
|
+
aesKey: z.string().nullish()
|
|
849
|
+
// AES shared key for enterprise comm (hex), from login response
|
|
848
850
|
});
|
|
849
851
|
async function readCredentials() {
|
|
850
852
|
if (!existsSync(configuration.privateKeyFile)) {
|
|
@@ -857,6 +859,7 @@ async function readCredentials() {
|
|
|
857
859
|
return {
|
|
858
860
|
token: credentials.token,
|
|
859
861
|
signing: credentials.signing ?? null,
|
|
862
|
+
aesKey: credentials.aesKey ?? void 0,
|
|
860
863
|
encryption: {
|
|
861
864
|
type: "legacy",
|
|
862
865
|
secret: new Uint8Array(Buffer.from(credentials.secret, "base64"))
|
|
@@ -866,6 +869,7 @@ async function readCredentials() {
|
|
|
866
869
|
return {
|
|
867
870
|
token: credentials.token,
|
|
868
871
|
signing: credentials.signing ?? null,
|
|
872
|
+
aesKey: credentials.aesKey ?? void 0,
|
|
869
873
|
encryption: {
|
|
870
874
|
type: "dataKey",
|
|
871
875
|
publicKey: new Uint8Array(Buffer.from(credentials.encryption.publicKey, "base64")),
|
|
@@ -885,7 +889,8 @@ async function writeCredentialsLegacy(credentials) {
|
|
|
885
889
|
await writeFile(configuration.privateKeyFile, JSON.stringify({
|
|
886
890
|
secret: encodeBase64(credentials.secret),
|
|
887
891
|
token: credentials.token,
|
|
888
|
-
signing: credentials.signing
|
|
892
|
+
signing: credentials.signing,
|
|
893
|
+
aesKey: credentials.aesKey
|
|
889
894
|
}, null, 2));
|
|
890
895
|
}
|
|
891
896
|
async function writeCredentialsDataKey(credentials) {
|
|
@@ -895,7 +900,8 @@ async function writeCredentialsDataKey(credentials) {
|
|
|
895
900
|
await writeFile(configuration.privateKeyFile, JSON.stringify({
|
|
896
901
|
encryption: { publicKey: encodeBase64(credentials.publicKey), machineKey: encodeBase64(credentials.machineKey) },
|
|
897
902
|
token: credentials.token,
|
|
898
|
-
signing: credentials.signing
|
|
903
|
+
signing: credentials.signing,
|
|
904
|
+
aesKey: credentials.aesKey
|
|
899
905
|
}, null, 2));
|
|
900
906
|
}
|
|
901
907
|
async function clearCredentials() {
|
|
@@ -1282,11 +1288,18 @@ const ProtocolV3DescriptorSchema = z$1.object({
|
|
|
1282
1288
|
const ProtocolV3CapabilitiesResponseSchema = z$1.object({
|
|
1283
1289
|
protocol: ProtocolV3DescriptorSchema
|
|
1284
1290
|
});
|
|
1285
|
-
const SessionMessageContentSchema = z$1.
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
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
|
+
]);
|
|
1290
1303
|
const NewSessionBodySchema = z$1.object({
|
|
1291
1304
|
t: z$1.literal("new-session"),
|
|
1292
1305
|
id: z$1.string(),
|
|
@@ -1523,7 +1536,7 @@ const AgentMessageSchema = z$1.object({
|
|
|
1523
1536
|
}),
|
|
1524
1537
|
meta: MessageMetaSchema.optional()
|
|
1525
1538
|
});
|
|
1526
|
-
z$1.union([UserMessageSchema, AgentMessageSchema]);
|
|
1539
|
+
const MessageContentSchema = z$1.union([UserMessageSchema, AgentMessageSchema]);
|
|
1527
1540
|
|
|
1528
1541
|
function buildSessionRuntimeIndex(metadata) {
|
|
1529
1542
|
if (!metadata) {
|
|
@@ -2426,20 +2439,23 @@ async function ensureSigningCredentials(credentials, opts = {}) {
|
|
|
2426
2439
|
const upgradedCredentials = {
|
|
2427
2440
|
...credentials,
|
|
2428
2441
|
token: response.data.token,
|
|
2429
|
-
signing: response.data.signing
|
|
2442
|
+
signing: response.data.signing,
|
|
2443
|
+
aesKey: response.data.aesKey ?? credentials.aesKey
|
|
2430
2444
|
};
|
|
2431
2445
|
if (upgradedCredentials.encryption.type === "legacy") {
|
|
2432
2446
|
await writeCredentialsLegacy({
|
|
2433
2447
|
secret: upgradedCredentials.encryption.secret,
|
|
2434
2448
|
token: upgradedCredentials.token,
|
|
2435
|
-
signing: upgradedCredentials.signing
|
|
2449
|
+
signing: upgradedCredentials.signing,
|
|
2450
|
+
aesKey: upgradedCredentials.aesKey
|
|
2436
2451
|
});
|
|
2437
2452
|
} else {
|
|
2438
2453
|
await writeCredentialsDataKey({
|
|
2439
2454
|
publicKey: upgradedCredentials.encryption.publicKey,
|
|
2440
2455
|
machineKey: upgradedCredentials.encryption.machineKey,
|
|
2441
2456
|
token: upgradedCredentials.token,
|
|
2442
|
-
signing: upgradedCredentials.signing
|
|
2457
|
+
signing: upgradedCredentials.signing,
|
|
2458
|
+
aesKey: upgradedCredentials.aesKey
|
|
2443
2459
|
});
|
|
2444
2460
|
}
|
|
2445
2461
|
logger.debug("[AUTH] Signing credentials bootstrapped successfully");
|
|
@@ -3099,6 +3115,17 @@ class ApiSessionClient extends EventEmitter {
|
|
|
3099
3115
|
logger.debug("[SOCKET] [UPDATE] [ERROR] No body in update!");
|
|
3100
3116
|
return;
|
|
3101
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
|
+
}
|
|
3102
3129
|
if (data.body.t === "new-message" && data.body.message.content.t === "encrypted") {
|
|
3103
3130
|
const messageSeq = typeof data.body.message.seq === "number" ? data.body.message.seq : null;
|
|
3104
3131
|
if (messageSeq !== null && messageSeq <= this.lastChangeSeq) {
|
|
@@ -3165,6 +3192,32 @@ class ApiSessionClient extends EventEmitter {
|
|
|
3165
3192
|
}
|
|
3166
3193
|
this.emit("message", parsedBody);
|
|
3167
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
|
+
}
|
|
3168
3221
|
maybeAutoAcknowledgeHappyOrgDispatch(message) {
|
|
3169
3222
|
const candidate = this.resolveHappyOrgDispatchBusinessAckCandidate(message);
|
|
3170
3223
|
if (!candidate) {
|
|
@@ -3472,7 +3525,9 @@ class ApiSessionClient extends EventEmitter {
|
|
|
3472
3525
|
if (message.seq <= this.lastChangeSeq) {
|
|
3473
3526
|
continue;
|
|
3474
3527
|
}
|
|
3475
|
-
if (message.content.t === "
|
|
3528
|
+
if (message.content.t === "plaintext") {
|
|
3529
|
+
this.dispatchPlaintextSessionMessage(message.content.p);
|
|
3530
|
+
} else if (message.content.t === "encrypted") {
|
|
3476
3531
|
this.dispatchEncryptedSessionMessage(message.content.c);
|
|
3477
3532
|
}
|
|
3478
3533
|
this.lastChangeSeq = Math.max(this.lastChangeSeq, message.seq);
|
|
@@ -3503,7 +3558,9 @@ class ApiSessionClient extends EventEmitter {
|
|
|
3503
3558
|
const message = payload.message;
|
|
3504
3559
|
if (message && typeof message === "object") {
|
|
3505
3560
|
const content = message.content;
|
|
3506
|
-
if (content && typeof content === "object" && content.t === "
|
|
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") {
|
|
3507
3564
|
this.dispatchEncryptedSessionMessage(content.c);
|
|
3508
3565
|
}
|
|
3509
3566
|
}
|
|
@@ -5060,4 +5117,4 @@ var api = /*#__PURE__*/Object.freeze({
|
|
|
5060
5117
|
ApiClient: ApiClient
|
|
5061
5118
|
});
|
|
5062
5119
|
|
|
5063
|
-
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,
|
|
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 };
|
|
@@ -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.
|
|
41
|
+
var version = "2.1.23";
|
|
42
42
|
var description = "hicloud - Imou 企业定制版。关键是 happy!移动端远程 AI 编程工具,支持 Claude Code、Codex 和 Gemini CLI";
|
|
43
43
|
var author = "long.zhu";
|
|
44
44
|
var license = "MIT";
|
|
@@ -864,7 +864,9 @@ const credentialsSchema = z__namespace.object({
|
|
|
864
864
|
encryption: z__namespace.object({
|
|
865
865
|
publicKey: z__namespace.string().base64(),
|
|
866
866
|
machineKey: z__namespace.string().base64()
|
|
867
|
-
}).nullish()
|
|
867
|
+
}).nullish(),
|
|
868
|
+
aesKey: z__namespace.string().nullish()
|
|
869
|
+
// AES shared key for enterprise comm (hex), from login response
|
|
868
870
|
});
|
|
869
871
|
async function readCredentials() {
|
|
870
872
|
if (!fs.existsSync(configuration.privateKeyFile)) {
|
|
@@ -877,6 +879,7 @@ async function readCredentials() {
|
|
|
877
879
|
return {
|
|
878
880
|
token: credentials.token,
|
|
879
881
|
signing: credentials.signing ?? null,
|
|
882
|
+
aesKey: credentials.aesKey ?? void 0,
|
|
880
883
|
encryption: {
|
|
881
884
|
type: "legacy",
|
|
882
885
|
secret: new Uint8Array(Buffer.from(credentials.secret, "base64"))
|
|
@@ -886,6 +889,7 @@ async function readCredentials() {
|
|
|
886
889
|
return {
|
|
887
890
|
token: credentials.token,
|
|
888
891
|
signing: credentials.signing ?? null,
|
|
892
|
+
aesKey: credentials.aesKey ?? void 0,
|
|
889
893
|
encryption: {
|
|
890
894
|
type: "dataKey",
|
|
891
895
|
publicKey: new Uint8Array(Buffer.from(credentials.encryption.publicKey, "base64")),
|
|
@@ -905,7 +909,8 @@ async function writeCredentialsLegacy(credentials) {
|
|
|
905
909
|
await promises.writeFile(configuration.privateKeyFile, JSON.stringify({
|
|
906
910
|
secret: encodeBase64(credentials.secret),
|
|
907
911
|
token: credentials.token,
|
|
908
|
-
signing: credentials.signing
|
|
912
|
+
signing: credentials.signing,
|
|
913
|
+
aesKey: credentials.aesKey
|
|
909
914
|
}, null, 2));
|
|
910
915
|
}
|
|
911
916
|
async function writeCredentialsDataKey(credentials) {
|
|
@@ -915,7 +920,8 @@ async function writeCredentialsDataKey(credentials) {
|
|
|
915
920
|
await promises.writeFile(configuration.privateKeyFile, JSON.stringify({
|
|
916
921
|
encryption: { publicKey: encodeBase64(credentials.publicKey), machineKey: encodeBase64(credentials.machineKey) },
|
|
917
922
|
token: credentials.token,
|
|
918
|
-
signing: credentials.signing
|
|
923
|
+
signing: credentials.signing,
|
|
924
|
+
aesKey: credentials.aesKey
|
|
919
925
|
}, null, 2));
|
|
920
926
|
}
|
|
921
927
|
async function clearCredentials() {
|
|
@@ -1302,11 +1308,18 @@ const ProtocolV3DescriptorSchema = z.z.object({
|
|
|
1302
1308
|
const ProtocolV3CapabilitiesResponseSchema = z.z.object({
|
|
1303
1309
|
protocol: ProtocolV3DescriptorSchema
|
|
1304
1310
|
});
|
|
1305
|
-
const SessionMessageContentSchema = z.z.
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
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
|
+
]);
|
|
1310
1323
|
const NewSessionBodySchema = z.z.object({
|
|
1311
1324
|
t: z.z.literal("new-session"),
|
|
1312
1325
|
id: z.z.string(),
|
|
@@ -1543,7 +1556,7 @@ const AgentMessageSchema = z.z.object({
|
|
|
1543
1556
|
}),
|
|
1544
1557
|
meta: MessageMetaSchema.optional()
|
|
1545
1558
|
});
|
|
1546
|
-
z.z.union([UserMessageSchema, AgentMessageSchema]);
|
|
1559
|
+
const MessageContentSchema = z.z.union([UserMessageSchema, AgentMessageSchema]);
|
|
1547
1560
|
|
|
1548
1561
|
function buildSessionRuntimeIndex(metadata) {
|
|
1549
1562
|
if (!metadata) {
|
|
@@ -2446,20 +2459,23 @@ async function ensureSigningCredentials(credentials, opts = {}) {
|
|
|
2446
2459
|
const upgradedCredentials = {
|
|
2447
2460
|
...credentials,
|
|
2448
2461
|
token: response.data.token,
|
|
2449
|
-
signing: response.data.signing
|
|
2462
|
+
signing: response.data.signing,
|
|
2463
|
+
aesKey: response.data.aesKey ?? credentials.aesKey
|
|
2450
2464
|
};
|
|
2451
2465
|
if (upgradedCredentials.encryption.type === "legacy") {
|
|
2452
2466
|
await writeCredentialsLegacy({
|
|
2453
2467
|
secret: upgradedCredentials.encryption.secret,
|
|
2454
2468
|
token: upgradedCredentials.token,
|
|
2455
|
-
signing: upgradedCredentials.signing
|
|
2469
|
+
signing: upgradedCredentials.signing,
|
|
2470
|
+
aesKey: upgradedCredentials.aesKey
|
|
2456
2471
|
});
|
|
2457
2472
|
} else {
|
|
2458
2473
|
await writeCredentialsDataKey({
|
|
2459
2474
|
publicKey: upgradedCredentials.encryption.publicKey,
|
|
2460
2475
|
machineKey: upgradedCredentials.encryption.machineKey,
|
|
2461
2476
|
token: upgradedCredentials.token,
|
|
2462
|
-
signing: upgradedCredentials.signing
|
|
2477
|
+
signing: upgradedCredentials.signing,
|
|
2478
|
+
aesKey: upgradedCredentials.aesKey
|
|
2463
2479
|
});
|
|
2464
2480
|
}
|
|
2465
2481
|
logger.debug("[AUTH] Signing credentials bootstrapped successfully");
|
|
@@ -3119,6 +3135,17 @@ class ApiSessionClient extends node_events.EventEmitter {
|
|
|
3119
3135
|
logger.debug("[SOCKET] [UPDATE] [ERROR] No body in update!");
|
|
3120
3136
|
return;
|
|
3121
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
|
+
}
|
|
3122
3149
|
if (data.body.t === "new-message" && data.body.message.content.t === "encrypted") {
|
|
3123
3150
|
const messageSeq = typeof data.body.message.seq === "number" ? data.body.message.seq : null;
|
|
3124
3151
|
if (messageSeq !== null && messageSeq <= this.lastChangeSeq) {
|
|
@@ -3185,6 +3212,32 @@ class ApiSessionClient extends node_events.EventEmitter {
|
|
|
3185
3212
|
}
|
|
3186
3213
|
this.emit("message", parsedBody);
|
|
3187
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
|
+
}
|
|
3188
3241
|
maybeAutoAcknowledgeHappyOrgDispatch(message) {
|
|
3189
3242
|
const candidate = this.resolveHappyOrgDispatchBusinessAckCandidate(message);
|
|
3190
3243
|
if (!candidate) {
|
|
@@ -3492,7 +3545,9 @@ class ApiSessionClient extends node_events.EventEmitter {
|
|
|
3492
3545
|
if (message.seq <= this.lastChangeSeq) {
|
|
3493
3546
|
continue;
|
|
3494
3547
|
}
|
|
3495
|
-
if (message.content.t === "
|
|
3548
|
+
if (message.content.t === "plaintext") {
|
|
3549
|
+
this.dispatchPlaintextSessionMessage(message.content.p);
|
|
3550
|
+
} else if (message.content.t === "encrypted") {
|
|
3496
3551
|
this.dispatchEncryptedSessionMessage(message.content.c);
|
|
3497
3552
|
}
|
|
3498
3553
|
this.lastChangeSeq = Math.max(this.lastChangeSeq, message.seq);
|
|
@@ -3523,7 +3578,9 @@ class ApiSessionClient extends node_events.EventEmitter {
|
|
|
3523
3578
|
const message = payload.message;
|
|
3524
3579
|
if (message && typeof message === "object") {
|
|
3525
3580
|
const content = message.content;
|
|
3526
|
-
if (content && typeof content === "object" && content.t === "
|
|
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") {
|
|
3527
3584
|
this.dispatchEncryptedSessionMessage(content.c);
|
|
3528
3585
|
}
|
|
3529
3586
|
}
|
|
@@ -5088,10 +5145,12 @@ exports.HAPPY_ORG_REPEAT_THRESHOLD = HAPPY_ORG_REPEAT_THRESHOLD;
|
|
|
5088
5145
|
exports.HAPPY_ORG_SUMMARY_MAX_LENGTH = HAPPY_ORG_SUMMARY_MAX_LENGTH;
|
|
5089
5146
|
exports.HAPPY_ORG_TURN_REPORT_TAG = HAPPY_ORG_TURN_REPORT_TAG;
|
|
5090
5147
|
exports.HeadTailPreviewBuffer = HeadTailPreviewBuffer;
|
|
5148
|
+
exports.MessageContentSchema = MessageContentSchema;
|
|
5091
5149
|
exports.acquireDaemonLock = acquireDaemonLock;
|
|
5092
5150
|
exports.api = api;
|
|
5093
5151
|
exports.backoff = backoff;
|
|
5094
5152
|
exports.buildClientHeaders = buildClientHeaders;
|
|
5153
|
+
exports.buildSocketAuth = buildSocketAuth;
|
|
5095
5154
|
exports.clearCredentials = clearCredentials;
|
|
5096
5155
|
exports.clearDaemonState = clearDaemonState;
|
|
5097
5156
|
exports.clearMachineId = clearMachineId;
|
|
@@ -5101,6 +5160,7 @@ exports.decodeBase64 = decodeBase64;
|
|
|
5101
5160
|
exports.delay = delay;
|
|
5102
5161
|
exports.encodeBase64 = encodeBase64;
|
|
5103
5162
|
exports.encodeBase64Url = encodeBase64Url;
|
|
5163
|
+
exports.encrypt = encrypt;
|
|
5104
5164
|
exports.ensureSigningCredentials = ensureSigningCredentials;
|
|
5105
5165
|
exports.getLatestDaemonLog = getLatestDaemonLog;
|
|
5106
5166
|
exports.getProfileEnvironmentVariables = getProfileEnvironmentVariables;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as createDefaultRuntimeShell } from './index-
|
|
1
|
+
import { c as createDefaultRuntimeShell } from './index-CFLvb1x1.mjs';
|
|
2
2
|
import 'chalk';
|
|
3
|
-
import './api-
|
|
3
|
+
import './api-CDC4ZRT7.mjs';
|
|
4
4
|
import 'axios';
|
|
5
5
|
import 'fs';
|
|
6
6
|
import 'node:fs';
|