happy-imou-cloud 2.1.21 → 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.
- package/dist/{BaseReasoningProcessor-DxFwO2z9.cjs → BaseReasoningProcessor-BVdXoFXc.cjs} +2 -2
- package/dist/{BaseReasoningProcessor-DdPnQSmQ.mjs → BaseReasoningProcessor-BYNLDM-T.mjs} +2 -2
- package/dist/{ProviderSelectionHandler-B5Aq5gA_.cjs → ProviderSelectionHandler-DDzNcWPJ.cjs} +2 -2
- package/dist/{ProviderSelectionHandler-DQITIqZK.mjs → ProviderSelectionHandler-DgINCAMh.mjs} +2 -2
- package/dist/{api-8xtJZeXZ.cjs → api-BXGRJ5Kn.cjs} +75 -15
- package/dist/{api-DB30ctmX.mjs → api-bhF1J82q.mjs} +73 -16
- package/dist/{command-79M8Bz4I.cjs → command-Byj1OLb9.cjs} +2 -2
- package/dist/{command-C6injNJE.mjs → command-CyUpFVkQ.mjs} +2 -2
- package/dist/{index-D4A092LJ.cjs → index-BNTRi6Uv.cjs} +374 -57
- package/dist/{index-krVv4CWK.mjs → index-CEhnCQim.mjs} +372 -55
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +132 -72
- package/dist/lib.d.mts +132 -72
- package/dist/lib.mjs +1 -1
- package/dist/{registerKillSessionHandler-beu2g-Qo.mjs → registerKillSessionHandler-BtPo6LkG.mjs} +2 -2
- package/dist/{registerKillSessionHandler-Cl_er9rg.cjs → registerKillSessionHandler-CuP57vY0.cjs} +2 -2
- package/dist/{runClaude-nzLh-orP.mjs → runClaude-CMKm1bBe.mjs} +4 -4
- package/dist/{runClaude-DmXinUiz.cjs → runClaude-CqJgxqjW.cjs} +4 -4
- package/dist/{runCodex-C-Pjpbxn.mjs → runCodex-BkfujuLR.mjs} +9 -7
- package/dist/{runCodex-CoqsQ-cb.cjs → runCodex-DIaZ1wGI.cjs} +9 -7
- package/dist/{runGemini-CIVm6NWC.mjs → runGemini-DcN0Nb3f.mjs} +4 -4
- package/dist/{runGemini-BC_5rNMt.cjs → runGemini-U4GRLlSn.cjs} +4 -4
- package/package.json +1 -1
- package/scripts/tooling-utils.mjs +167 -167
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import{createRequire as _pkgrollCR}from"node:module";const require=_pkgrollCR(import.meta.url);import chalk from 'chalk';
|
|
2
|
-
import { l as logger, j as encodeBase64, c as configuration, k as readCredentials, m as ensureSigningCredentials, r as readSettings, u as updateSettings, n as encodeBase64Url, g as delay, o as buildClientHeaders, q as decodeBase64, w as writeCredentialsLegacy, t as writeCredentialsDataKey, v as readDaemonState, x as HAPPY_CLOUD_DAEMON_PORT, y as clearDaemonState, z as packageJson, B as acquireDaemonLock, C as writeDaemonState, A as ApiClient,
|
|
2
|
+
import { l as logger, j as encodeBase64, c as configuration, k as readCredentials, m as ensureSigningCredentials, r as readSettings, u as updateSettings, n as encodeBase64Url, g as delay, o as buildClientHeaders, q as decodeBase64, w as writeCredentialsLegacy, t as writeCredentialsDataKey, v as readDaemonState, x as HAPPY_CLOUD_DAEMON_PORT, y as clearDaemonState, z as packageJson, i as isAuthenticationRequiredError, B as acquireDaemonLock, C as writeDaemonState, A as ApiClient, D as releaseDaemonLock, E as validateProfileForAgent, F as getProfileEnvironmentVariables, G as clearCredentials, I as clearMachineId, M as MessageContentSchema, J as buildSocketAuth, K as encrypt, L as HeadTailPreviewBuffer, N as getLatestDaemonLog } from './api-bhF1J82q.mjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import fs, { writeFile as writeFile$1, rename, unlink as unlink$1 } from 'fs/promises';
|
|
5
5
|
import os$1, { homedir } from 'os';
|
|
6
6
|
import * as tmp from 'tmp';
|
|
7
|
-
import { randomUUID, randomBytes } from 'node:crypto';
|
|
7
|
+
import { randomUUID, randomBytes, createCipheriv } from 'node:crypto';
|
|
8
8
|
import tweetnacl from 'tweetnacl';
|
|
9
9
|
import axios from 'axios';
|
|
10
10
|
import qrcode from 'qrcode-terminal';
|
|
@@ -29,6 +29,7 @@ import { randomUUID as randomUUID$1, randomBytes as randomBytes$1, createHash }
|
|
|
29
29
|
import { createInterface } from 'node:readline';
|
|
30
30
|
import { createServer } from 'http';
|
|
31
31
|
import { promisify } from 'util';
|
|
32
|
+
import { io } from 'socket.io-client';
|
|
32
33
|
import { ndJsonStream, ClientSideConnection } from '@agentclientprotocol/sdk';
|
|
33
34
|
import { fileURLToPath as fileURLToPath$1 } from 'node:url';
|
|
34
35
|
import 'node:events';
|
|
@@ -2573,6 +2574,63 @@ async function archiveDetachedManagedSessionIfNeeded(opts) {
|
|
|
2573
2574
|
return true;
|
|
2574
2575
|
}
|
|
2575
2576
|
|
|
2577
|
+
function createOfflineMachine(opts) {
|
|
2578
|
+
const { credentials, machineId, metadata, daemonState } = opts;
|
|
2579
|
+
if (credentials.encryption.type === "dataKey") {
|
|
2580
|
+
return {
|
|
2581
|
+
id: machineId,
|
|
2582
|
+
encryptionKey: credentials.encryption.machineKey,
|
|
2583
|
+
encryptionVariant: "dataKey",
|
|
2584
|
+
metadata,
|
|
2585
|
+
metadataVersion: 0,
|
|
2586
|
+
daemonState,
|
|
2587
|
+
daemonStateVersion: 0
|
|
2588
|
+
};
|
|
2589
|
+
}
|
|
2590
|
+
return {
|
|
2591
|
+
id: machineId,
|
|
2592
|
+
encryptionKey: credentials.encryption.secret,
|
|
2593
|
+
encryptionVariant: "legacy",
|
|
2594
|
+
metadata,
|
|
2595
|
+
metadataVersion: 0,
|
|
2596
|
+
daemonState,
|
|
2597
|
+
daemonStateVersion: 0
|
|
2598
|
+
};
|
|
2599
|
+
}
|
|
2600
|
+
async function registerDaemonMachine(opts) {
|
|
2601
|
+
let userScopedObserver = opts.userScopedObserver;
|
|
2602
|
+
let machine = createOfflineMachine(opts);
|
|
2603
|
+
let daemonHasAuthenticatedSync = false;
|
|
2604
|
+
try {
|
|
2605
|
+
machine = await opts.api.getOrCreateMachine({
|
|
2606
|
+
machineId: opts.machineId,
|
|
2607
|
+
metadata: opts.metadata,
|
|
2608
|
+
daemonState: opts.daemonState
|
|
2609
|
+
});
|
|
2610
|
+
daemonHasAuthenticatedSync = true;
|
|
2611
|
+
logger.debug(`[DAEMON RUN] Machine registered: ${machine.id}`);
|
|
2612
|
+
} catch (error) {
|
|
2613
|
+
if (!isAuthenticationRequiredError(error)) {
|
|
2614
|
+
throw error;
|
|
2615
|
+
}
|
|
2616
|
+
logger.warn(
|
|
2617
|
+
"[DAEMON RUN] Machine registration rejected by the server. Continuing with local-only daemon control until authentication is refreshed.",
|
|
2618
|
+
error instanceof Error ? error.message : String(error)
|
|
2619
|
+
);
|
|
2620
|
+
try {
|
|
2621
|
+
await userScopedObserver?.close();
|
|
2622
|
+
} catch (observerCloseError) {
|
|
2623
|
+
logger.debug("[DAEMON RUN] Failed to close user-scoped observer after auth fallback", observerCloseError);
|
|
2624
|
+
}
|
|
2625
|
+
userScopedObserver = null;
|
|
2626
|
+
}
|
|
2627
|
+
return {
|
|
2628
|
+
machine,
|
|
2629
|
+
daemonHasAuthenticatedSync,
|
|
2630
|
+
userScopedObserver
|
|
2631
|
+
};
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2576
2634
|
const NON_SESSION_PROCESS_TYPES$1 = /* @__PURE__ */ new Set([
|
|
2577
2635
|
"current",
|
|
2578
2636
|
"daemon",
|
|
@@ -2966,28 +3024,6 @@ const initialMachineMetadata = {
|
|
|
2966
3024
|
happyHomeDir: configuration.happyCloudHomeDir,
|
|
2967
3025
|
happyLibDir: projectPath()
|
|
2968
3026
|
};
|
|
2969
|
-
function createOfflineMachine(credentials, machineId, daemonState) {
|
|
2970
|
-
if (credentials.encryption.type === "dataKey") {
|
|
2971
|
-
return {
|
|
2972
|
-
id: machineId,
|
|
2973
|
-
encryptionKey: credentials.encryption.machineKey,
|
|
2974
|
-
encryptionVariant: "dataKey",
|
|
2975
|
-
metadata: initialMachineMetadata,
|
|
2976
|
-
metadataVersion: 0,
|
|
2977
|
-
daemonState,
|
|
2978
|
-
daemonStateVersion: 0
|
|
2979
|
-
};
|
|
2980
|
-
}
|
|
2981
|
-
return {
|
|
2982
|
-
id: machineId,
|
|
2983
|
-
encryptionKey: credentials.encryption.secret,
|
|
2984
|
-
encryptionVariant: "legacy",
|
|
2985
|
-
metadata: initialMachineMetadata,
|
|
2986
|
-
metadataVersion: 0,
|
|
2987
|
-
daemonState,
|
|
2988
|
-
daemonStateVersion: 0
|
|
2989
|
-
};
|
|
2990
|
-
}
|
|
2991
3027
|
async function getProfileEnvironmentVariablesForAgent(profileId, agentType) {
|
|
2992
3028
|
try {
|
|
2993
3029
|
const settings = await readSettings();
|
|
@@ -3562,31 +3598,16 @@ ${stderrSnapshot}`);
|
|
|
3562
3598
|
logger.debug("[DAEMON RUN] Failed to start user-scoped observer, continuing without it", error);
|
|
3563
3599
|
}
|
|
3564
3600
|
}
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
} catch (error) {
|
|
3576
|
-
if (!isAuthenticationRequiredError(error)) {
|
|
3577
|
-
throw error;
|
|
3578
|
-
}
|
|
3579
|
-
logger.warn(
|
|
3580
|
-
"[DAEMON RUN] Machine registration rejected by the server. Continuing with local-only daemon control until authentication is refreshed.",
|
|
3581
|
-
error instanceof Error ? error.message : String(error)
|
|
3582
|
-
);
|
|
3583
|
-
try {
|
|
3584
|
-
await userScopedObserver?.close();
|
|
3585
|
-
} catch (observerCloseError) {
|
|
3586
|
-
logger.debug("[DAEMON RUN] Failed to close user-scoped observer after auth fallback", observerCloseError);
|
|
3587
|
-
}
|
|
3588
|
-
userScopedObserver = null;
|
|
3589
|
-
}
|
|
3601
|
+
const machineRegistration = await registerDaemonMachine({
|
|
3602
|
+
api: activeApi,
|
|
3603
|
+
credentials,
|
|
3604
|
+
machineId,
|
|
3605
|
+
metadata: initialMachineMetadata,
|
|
3606
|
+
daemonState: initialDaemonState,
|
|
3607
|
+
userScopedObserver
|
|
3608
|
+
});
|
|
3609
|
+
const { machine, daemonHasAuthenticatedSync } = machineRegistration;
|
|
3610
|
+
userScopedObserver = machineRegistration.userScopedObserver;
|
|
3590
3611
|
const apiMachine = daemonHasAuthenticatedSync ? activeApi.machineSyncClient(machine) : null;
|
|
3591
3612
|
apiMachine?.setRPCHandlers({
|
|
3592
3613
|
spawnSession,
|
|
@@ -5007,6 +5028,291 @@ async function handleHappyOrgCommand(args, deps = {}) {
|
|
|
5007
5028
|
throw new Error(`Unknown happy-org subcommand: ${subcommand}`);
|
|
5008
5029
|
}
|
|
5009
5030
|
|
|
5031
|
+
const AGENT_SEND_AES_KEY_REQUIRED_MESSAGE = "Enterprise mode requires an AES key. Pass --aes-key or authenticate with a server response that includes credentials.aesKey.";
|
|
5032
|
+
const AGENT_SEND_E2EE_LEGACY_REQUIRED_MESSAGE = "Legacy e2ee mode is only available for legacy credentials. Use --mode enterprise or re-authenticate with a legacy account.";
|
|
5033
|
+
async function handleAgentCommand(args) {
|
|
5034
|
+
const subcommand = args[0];
|
|
5035
|
+
if (!subcommand || subcommand === "help" || subcommand === "--help" || subcommand === "-h") {
|
|
5036
|
+
showAgentHelp();
|
|
5037
|
+
return;
|
|
5038
|
+
}
|
|
5039
|
+
if (subcommand === "send") {
|
|
5040
|
+
await handleAgentSend(args.slice(1));
|
|
5041
|
+
return;
|
|
5042
|
+
}
|
|
5043
|
+
console.error(chalk.red(`Unknown agent subcommand: ${subcommand}`));
|
|
5044
|
+
showAgentHelp();
|
|
5045
|
+
process.exit(1);
|
|
5046
|
+
}
|
|
5047
|
+
function showAgentHelp() {
|
|
5048
|
+
console.log(`
|
|
5049
|
+
${chalk.bold("hicloud agent")} - Enterprise task communication relay
|
|
5050
|
+
|
|
5051
|
+
${chalk.bold("Usage:")}
|
|
5052
|
+
hicloud agent send --session <id> --message <json>
|
|
5053
|
+
hicloud agent send --session <id> --message <json> --mode enterprise
|
|
5054
|
+
hicloud agent send --session <id> --message <json> --mode e2ee
|
|
5055
|
+
hicloud agent help
|
|
5056
|
+
|
|
5057
|
+
${chalk.bold("Options:")}
|
|
5058
|
+
--session <id> Target session ID (alias: --session-id)
|
|
5059
|
+
--message <json> App-display-compatible JSON message
|
|
5060
|
+
--mode <mode> Communication mode: e2ee (default), enterprise, or aes
|
|
5061
|
+
--aes-key <hex> Override enterprise AES key with a 64-char hex value
|
|
5062
|
+
|
|
5063
|
+
${chalk.bold("Message format:")}
|
|
5064
|
+
{"role":"user","content":{"type":"text","text":"Hello"}}
|
|
5065
|
+
{"role":"agent","content":{"type":"output","data":{"message":"Task complete"}}}
|
|
5066
|
+
|
|
5067
|
+
Optional meta fields such as meta.happyOrg are preserved so task replay and
|
|
5068
|
+
audit linkage survive enterprise communication writes.
|
|
5069
|
+
|
|
5070
|
+
${chalk.bold("Communication modes:")}
|
|
5071
|
+
e2ee Legacy-compatible end-to-end encryption using legacy credentials.
|
|
5072
|
+
This mode stays explicit and is never auto-selected as a fallback.
|
|
5073
|
+
enterprise Enterprise-managed AES-256-GCM mode. Server decrypts authorized
|
|
5074
|
+
aes plaintext for replay/audit. Requires an AES key.
|
|
5075
|
+
|
|
5076
|
+
${chalk.bold("Examples:")}
|
|
5077
|
+
hicloud agent send --session sess_abc123 --message '{"role":"user","content":{"type":"text","text":"Review this PR"}}'
|
|
5078
|
+
hicloud agent send --session sess_abc123 --message '{"role":"user","content":{"type":"text","text":"Review enterprise trace"},"meta":{"happyOrg":{"taskContext":{"taskId":"task-1","organizationId":"org-1","memberAgentId":"member-1","supervisorAgentId":"ceo-1"},"replyContext":{"dispatchId":"dispatch-1","scope":"cli-agent","replyTo":"ceo-1"}}}}' --mode enterprise
|
|
5079
|
+
`);
|
|
5080
|
+
}
|
|
5081
|
+
async function handleAgentSend(args) {
|
|
5082
|
+
const opts = parseAgentSendArgs(args);
|
|
5083
|
+
if (!opts) {
|
|
5084
|
+
process.exit(1);
|
|
5085
|
+
return;
|
|
5086
|
+
}
|
|
5087
|
+
let parsedMessage;
|
|
5088
|
+
try {
|
|
5089
|
+
parsedMessage = JSON.parse(opts.messageJson);
|
|
5090
|
+
} catch {
|
|
5091
|
+
console.error(chalk.red("Error: Message must be valid JSON."));
|
|
5092
|
+
process.exit(1);
|
|
5093
|
+
return;
|
|
5094
|
+
}
|
|
5095
|
+
if (!validateAgentSendMessage(parsedMessage)) {
|
|
5096
|
+
console.error(chalk.red("Error: Message does not match the App display schema."));
|
|
5097
|
+
console.error(chalk.yellow('Expected: {"role":"user","content":{"type":"text","text":"..."}} or {"role":"agent","content":{"type":"output","data":{...}}}.'));
|
|
5098
|
+
process.exit(1);
|
|
5099
|
+
return;
|
|
5100
|
+
}
|
|
5101
|
+
const credentials = await readCredentials();
|
|
5102
|
+
if (!credentials) {
|
|
5103
|
+
console.error(chalk.red('Error: Not authenticated. Please run "hicloud auth login" first.'));
|
|
5104
|
+
process.exit(1);
|
|
5105
|
+
return;
|
|
5106
|
+
}
|
|
5107
|
+
let resolved;
|
|
5108
|
+
try {
|
|
5109
|
+
resolved = resolveAgentSendOptions(opts, parsedMessage, credentials);
|
|
5110
|
+
} catch (error) {
|
|
5111
|
+
console.error(chalk.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
5112
|
+
process.exit(1);
|
|
5113
|
+
return;
|
|
5114
|
+
}
|
|
5115
|
+
console.log(chalk.bold(`
|
|
5116
|
+
Sending message to session: ${resolved.sessionId}`));
|
|
5117
|
+
console.log(chalk.gray(`Communication mode: ${resolved.encryptionMode === "aes" ? "enterprise (aes)" : "legacy e2ee"}`));
|
|
5118
|
+
console.log(chalk.gray(`Server: ${configuration.serverUrl}`));
|
|
5119
|
+
await sendMessage({
|
|
5120
|
+
...resolved,
|
|
5121
|
+
credentials
|
|
5122
|
+
});
|
|
5123
|
+
}
|
|
5124
|
+
function validateAgentSendMessage(message) {
|
|
5125
|
+
return MessageContentSchema.safeParse(message).success;
|
|
5126
|
+
}
|
|
5127
|
+
function resolveAgentSendOptions(opts, messageContent, credentials) {
|
|
5128
|
+
if (opts.requestedMode === "aes") {
|
|
5129
|
+
const aesKey = opts.aesKey ?? credentials.aesKey ?? void 0;
|
|
5130
|
+
if (!aesKey) {
|
|
5131
|
+
throw new Error(AGENT_SEND_AES_KEY_REQUIRED_MESSAGE);
|
|
5132
|
+
}
|
|
5133
|
+
if (!/^[0-9a-fA-F]{64}$/.test(aesKey)) {
|
|
5134
|
+
throw new Error("Enterprise AES key must be a 64-character hex string.");
|
|
5135
|
+
}
|
|
5136
|
+
return {
|
|
5137
|
+
sessionId: opts.sessionId,
|
|
5138
|
+
messageContent,
|
|
5139
|
+
encryptionMode: "aes",
|
|
5140
|
+
aesKey
|
|
5141
|
+
};
|
|
5142
|
+
}
|
|
5143
|
+
if (credentials.encryption.type !== "legacy") {
|
|
5144
|
+
throw new Error(AGENT_SEND_E2EE_LEGACY_REQUIRED_MESSAGE);
|
|
5145
|
+
}
|
|
5146
|
+
return {
|
|
5147
|
+
sessionId: opts.sessionId,
|
|
5148
|
+
messageContent,
|
|
5149
|
+
encryptionMode: "e2ee",
|
|
5150
|
+
encryptionKey: credentials.encryption.secret,
|
|
5151
|
+
encryptionVariant: "legacy"
|
|
5152
|
+
};
|
|
5153
|
+
}
|
|
5154
|
+
async function sendMessage(opts) {
|
|
5155
|
+
let socket;
|
|
5156
|
+
let resolved = false;
|
|
5157
|
+
return await new Promise((resolve, reject) => {
|
|
5158
|
+
socket = io(configuration.serverUrl, {
|
|
5159
|
+
auth: (cb) => {
|
|
5160
|
+
cb(buildSocketAuth({
|
|
5161
|
+
credentials: opts.credentials,
|
|
5162
|
+
clientType: "session-scoped",
|
|
5163
|
+
sessionId: opts.sessionId
|
|
5164
|
+
}));
|
|
5165
|
+
},
|
|
5166
|
+
path: "/v1/updates",
|
|
5167
|
+
transports: ["websocket"],
|
|
5168
|
+
reconnection: false,
|
|
5169
|
+
timeout: 1e4
|
|
5170
|
+
});
|
|
5171
|
+
const timeout = setTimeout(() => {
|
|
5172
|
+
if (!resolved) {
|
|
5173
|
+
resolved = true;
|
|
5174
|
+
socket?.close();
|
|
5175
|
+
reject(new Error("Connection timeout"));
|
|
5176
|
+
}
|
|
5177
|
+
}, 1e4);
|
|
5178
|
+
socket.on("connect", () => {
|
|
5179
|
+
console.log(chalk.green("Connected to server"));
|
|
5180
|
+
});
|
|
5181
|
+
socket.on("connect_error", (err) => {
|
|
5182
|
+
if (!resolved) {
|
|
5183
|
+
resolved = true;
|
|
5184
|
+
clearTimeout(timeout);
|
|
5185
|
+
socket?.close();
|
|
5186
|
+
reject(new Error(`Connection error: ${err.message}`));
|
|
5187
|
+
}
|
|
5188
|
+
});
|
|
5189
|
+
socket.on("error", (err) => {
|
|
5190
|
+
if (!resolved) {
|
|
5191
|
+
resolved = true;
|
|
5192
|
+
clearTimeout(timeout);
|
|
5193
|
+
socket?.close();
|
|
5194
|
+
reject(new Error(`Socket error: ${err}`));
|
|
5195
|
+
}
|
|
5196
|
+
});
|
|
5197
|
+
const localId = `agent-${randomUUID()}`;
|
|
5198
|
+
const payload = {
|
|
5199
|
+
sid: opts.sessionId,
|
|
5200
|
+
localId
|
|
5201
|
+
};
|
|
5202
|
+
if (opts.encryptionMode === "aes") {
|
|
5203
|
+
const encrypted = encryptAesJson(JSON.stringify(opts.messageContent), opts.aesKey);
|
|
5204
|
+
if (!encrypted) {
|
|
5205
|
+
clearTimeout(timeout);
|
|
5206
|
+
if (!resolved) {
|
|
5207
|
+
resolved = true;
|
|
5208
|
+
socket?.close();
|
|
5209
|
+
reject(new Error("AES encryption failed"));
|
|
5210
|
+
}
|
|
5211
|
+
return;
|
|
5212
|
+
}
|
|
5213
|
+
payload.message = encrypted;
|
|
5214
|
+
payload.encryptionMode = "aes";
|
|
5215
|
+
} else {
|
|
5216
|
+
payload.message = encodeBase64(encrypt(opts.encryptionKey, opts.encryptionVariant, opts.messageContent));
|
|
5217
|
+
}
|
|
5218
|
+
socket.emit("message", payload, (ack) => {
|
|
5219
|
+
clearTimeout(timeout);
|
|
5220
|
+
if (!resolved) {
|
|
5221
|
+
resolved = true;
|
|
5222
|
+
socket?.close();
|
|
5223
|
+
if (ack?.ok) {
|
|
5224
|
+
console.log(chalk.green("\nMessage sent successfully!"));
|
|
5225
|
+
console.log(chalk.gray(` messageId: ${ack.messageId ?? "unknown"}`));
|
|
5226
|
+
console.log(chalk.gray(` status: ${ack.status ?? "accepted"}`));
|
|
5227
|
+
resolve();
|
|
5228
|
+
} else {
|
|
5229
|
+
reject(new Error(`Message rejected: ${ack?.error ?? "unknown"}`));
|
|
5230
|
+
}
|
|
5231
|
+
}
|
|
5232
|
+
});
|
|
5233
|
+
});
|
|
5234
|
+
}
|
|
5235
|
+
function encryptAesJson(jsonMessage, aesKeyHex) {
|
|
5236
|
+
try {
|
|
5237
|
+
const key = Buffer.from(aesKeyHex, "hex");
|
|
5238
|
+
if (key.length !== 32) {
|
|
5239
|
+
return null;
|
|
5240
|
+
}
|
|
5241
|
+
const nonce = randomBytes(12);
|
|
5242
|
+
const cipher = createCipheriv("aes-256-gcm", key, nonce);
|
|
5243
|
+
const plaintext = Buffer.from(jsonMessage, "utf8");
|
|
5244
|
+
const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
5245
|
+
const authTag = cipher.getAuthTag();
|
|
5246
|
+
const bundle = Buffer.alloc(1 + 12 + encrypted.length + 16);
|
|
5247
|
+
bundle.writeUInt8(0, 0);
|
|
5248
|
+
nonce.copy(bundle, 1);
|
|
5249
|
+
encrypted.copy(bundle, 13);
|
|
5250
|
+
authTag.copy(bundle, 13 + encrypted.length);
|
|
5251
|
+
return bundle.toString("base64");
|
|
5252
|
+
} catch {
|
|
5253
|
+
return null;
|
|
5254
|
+
}
|
|
5255
|
+
}
|
|
5256
|
+
function parseAgentSendArgs(args) {
|
|
5257
|
+
let sessionId;
|
|
5258
|
+
let messageJson;
|
|
5259
|
+
let requestedMode = "e2ee";
|
|
5260
|
+
let aesKey;
|
|
5261
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
5262
|
+
const arg = args[index];
|
|
5263
|
+
if (arg === "--session" || arg === "-s" || arg === "--session-id") {
|
|
5264
|
+
sessionId = args[index + 1];
|
|
5265
|
+
index += 1;
|
|
5266
|
+
continue;
|
|
5267
|
+
}
|
|
5268
|
+
if (arg === "--message" || arg === "-m") {
|
|
5269
|
+
messageJson = args[index + 1];
|
|
5270
|
+
index += 1;
|
|
5271
|
+
continue;
|
|
5272
|
+
}
|
|
5273
|
+
if (arg === "--mode" || arg === "--encryption" || arg === "--encryption-mode") {
|
|
5274
|
+
const mode = args[index + 1]?.toLowerCase();
|
|
5275
|
+
index += 1;
|
|
5276
|
+
if (mode === "enterprise" || mode === "aes") {
|
|
5277
|
+
requestedMode = "aes";
|
|
5278
|
+
continue;
|
|
5279
|
+
}
|
|
5280
|
+
if (mode === "e2ee") {
|
|
5281
|
+
requestedMode = "e2ee";
|
|
5282
|
+
continue;
|
|
5283
|
+
}
|
|
5284
|
+
console.error(chalk.red(`Unknown communication mode: ${mode}. Use 'e2ee', 'enterprise', or 'aes'.`));
|
|
5285
|
+
return null;
|
|
5286
|
+
}
|
|
5287
|
+
if (arg === "--aes-key") {
|
|
5288
|
+
aesKey = args[index + 1];
|
|
5289
|
+
index += 1;
|
|
5290
|
+
continue;
|
|
5291
|
+
}
|
|
5292
|
+
if (arg === "--help" || arg === "-h") {
|
|
5293
|
+
showAgentHelp();
|
|
5294
|
+
return null;
|
|
5295
|
+
}
|
|
5296
|
+
if (!arg.startsWith("-")) {
|
|
5297
|
+
messageJson ??= arg;
|
|
5298
|
+
}
|
|
5299
|
+
}
|
|
5300
|
+
if (!sessionId) {
|
|
5301
|
+
console.error(chalk.red("Error: --session <sessionId> or --session-id <sessionId> is required."));
|
|
5302
|
+
return null;
|
|
5303
|
+
}
|
|
5304
|
+
if (!messageJson) {
|
|
5305
|
+
console.error(chalk.red("Error: --message <json> is required."));
|
|
5306
|
+
return null;
|
|
5307
|
+
}
|
|
5308
|
+
return {
|
|
5309
|
+
sessionId,
|
|
5310
|
+
messageJson,
|
|
5311
|
+
requestedMode,
|
|
5312
|
+
aesKey
|
|
5313
|
+
};
|
|
5314
|
+
}
|
|
5315
|
+
|
|
5010
5316
|
function getProjectPath(workingDirectory, claudeConfigDirOverride) {
|
|
5011
5317
|
const projectId = resolve$1(workingDirectory).replace(/[^a-zA-Z0-9-]/g, "-");
|
|
5012
5318
|
const claudeConfigDirRaw = process.env.CLAUDE_CONFIG_DIR ?? "";
|
|
@@ -10440,14 +10746,14 @@ var launch = /*#__PURE__*/Object.freeze({
|
|
|
10440
10746
|
const unifiedProviderExecutors = {
|
|
10441
10747
|
claude: async (opts) => {
|
|
10442
10748
|
const claudeOptions = opts.claudeOptions ?? {};
|
|
10443
|
-
const { runClaude } = await import('./runClaude-
|
|
10749
|
+
const { runClaude } = await import('./runClaude-CMKm1bBe.mjs');
|
|
10444
10750
|
await runClaude(opts.credentials, {
|
|
10445
10751
|
...claudeOptions,
|
|
10446
10752
|
startingMode: claudeOptions.startingMode ?? (claudeOptions.startedBy === "daemon" ? "remote" : void 0)
|
|
10447
10753
|
});
|
|
10448
10754
|
},
|
|
10449
10755
|
codex: async (opts) => {
|
|
10450
|
-
const { runCodex } = await import('./runCodex-
|
|
10756
|
+
const { runCodex } = await import('./runCodex-BkfujuLR.mjs');
|
|
10451
10757
|
await runCodex({
|
|
10452
10758
|
credentials: opts.credentials,
|
|
10453
10759
|
startedBy: opts.startedBy,
|
|
@@ -10456,7 +10762,7 @@ const unifiedProviderExecutors = {
|
|
|
10456
10762
|
});
|
|
10457
10763
|
},
|
|
10458
10764
|
gemini: async (opts) => {
|
|
10459
|
-
const { runGemini } = await import('./runGemini-
|
|
10765
|
+
const { runGemini } = await import('./runGemini-DcN0Nb3f.mjs');
|
|
10460
10766
|
await runGemini({
|
|
10461
10767
|
credentials: opts.credentials,
|
|
10462
10768
|
startedBy: opts.startedBy
|
|
@@ -10539,7 +10845,7 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
10539
10845
|
return;
|
|
10540
10846
|
} else if (subcommand === "runtime") {
|
|
10541
10847
|
if (args[1] === "providers") {
|
|
10542
|
-
const { renderRuntimeProviders } = await import('./command-
|
|
10848
|
+
const { renderRuntimeProviders } = await import('./command-CyUpFVkQ.mjs');
|
|
10543
10849
|
console.log(renderRuntimeProviders());
|
|
10544
10850
|
return;
|
|
10545
10851
|
}
|
|
@@ -10601,6 +10907,17 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
10601
10907
|
process.exit(1);
|
|
10602
10908
|
}
|
|
10603
10909
|
return;
|
|
10910
|
+
} else if (subcommand === "agent") {
|
|
10911
|
+
try {
|
|
10912
|
+
await handleAgentCommand(args.slice(1));
|
|
10913
|
+
} catch (error) {
|
|
10914
|
+
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
|
10915
|
+
if (process.env.DEBUG) {
|
|
10916
|
+
console.error(error);
|
|
10917
|
+
}
|
|
10918
|
+
process.exit(1);
|
|
10919
|
+
}
|
|
10920
|
+
return;
|
|
10604
10921
|
} else if (subcommand === "codex") {
|
|
10605
10922
|
try {
|
|
10606
10923
|
let startedBy = void 0;
|
|
@@ -10728,8 +11045,8 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
10728
11045
|
const projectId = args[3];
|
|
10729
11046
|
try {
|
|
10730
11047
|
const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
|
|
10731
|
-
const { readCredentials: readCredentials2 } = await import('./api-
|
|
10732
|
-
const { ApiClient: ApiClient2 } = await import('./api-
|
|
11048
|
+
const { readCredentials: readCredentials2 } = await import('./api-bhF1J82q.mjs').then(function (n) { return n.O; });
|
|
11049
|
+
const { ApiClient: ApiClient2 } = await import('./api-bhF1J82q.mjs').then(function (n) { return n.P; });
|
|
10733
11050
|
let userEmail = void 0;
|
|
10734
11051
|
try {
|
|
10735
11052
|
const credentials = await readCredentials2();
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('chalk');
|
|
4
|
-
require('./api-
|
|
4
|
+
require('./api-BXGRJ5Kn.cjs');
|
|
5
5
|
require('zod');
|
|
6
|
-
require('./index-
|
|
6
|
+
require('./index-BNTRi6Uv.cjs');
|
|
7
7
|
require('node:child_process');
|
|
8
8
|
require('node:fs');
|
|
9
9
|
require('cross-spawn');
|
package/dist/index.mjs
CHANGED