@okxweb3/a2a-node 0.1.3 → 0.1.4-beta-161afc7833-260702114832
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/cli.js +619 -363
- package/dist/index.js +461 -205
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1822,15 +1822,15 @@ async function ensureAiWorkspace(paths) {
|
|
|
1822
1822
|
return aiWorkingDir;
|
|
1823
1823
|
}
|
|
1824
1824
|
async function waitForImmediateExit(child, timeoutMs) {
|
|
1825
|
-
return await new Promise((
|
|
1825
|
+
return await new Promise((resolve9) => {
|
|
1826
1826
|
let timer;
|
|
1827
1827
|
const onExit = () => {
|
|
1828
1828
|
clearTimeout(timer);
|
|
1829
|
-
|
|
1829
|
+
resolve9(true);
|
|
1830
1830
|
};
|
|
1831
1831
|
timer = setTimeout(() => {
|
|
1832
1832
|
child.off("exit", onExit);
|
|
1833
|
-
|
|
1833
|
+
resolve9(false);
|
|
1834
1834
|
}, timeoutMs);
|
|
1835
1835
|
child.once("exit", onExit);
|
|
1836
1836
|
});
|
|
@@ -1963,7 +1963,7 @@ async function waitForExit(pid, timeoutMs) {
|
|
|
1963
1963
|
if (!isProcessAlive(pid)) {
|
|
1964
1964
|
return true;
|
|
1965
1965
|
}
|
|
1966
|
-
await new Promise((
|
|
1966
|
+
await new Promise((resolve9) => setTimeout(resolve9, 100));
|
|
1967
1967
|
}
|
|
1968
1968
|
return !isProcessAlive(pid);
|
|
1969
1969
|
}
|
|
@@ -2136,7 +2136,7 @@ function readReadyTimeoutMs(env) {
|
|
|
2136
2136
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_READY_TIMEOUT_MS;
|
|
2137
2137
|
}
|
|
2138
2138
|
function sleep(ms) {
|
|
2139
|
-
return new Promise((
|
|
2139
|
+
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
2140
2140
|
}
|
|
2141
2141
|
var import_node_fs3, import_promises2, import_node_child_process, import_node_path5, STOP_GRACE_MS, FORCE_KILL_GRACE_MS, START_EXIT_CHECK_MS, DEFAULT_READY_TIMEOUT_MS, READY_POLL_MS, DAEMON_READY_TIMEOUT_ENV;
|
|
2142
2142
|
var init_daemon = __esm({
|
|
@@ -2405,7 +2405,7 @@ var init_command_store = __esm({
|
|
|
2405
2405
|
if (result) {
|
|
2406
2406
|
return result;
|
|
2407
2407
|
}
|
|
2408
|
-
await new Promise((
|
|
2408
|
+
await new Promise((resolve9) => setTimeout(resolve9, 500));
|
|
2409
2409
|
}
|
|
2410
2410
|
return null;
|
|
2411
2411
|
}
|
|
@@ -3684,7 +3684,7 @@ async function promptForAiProviderWithArrows(options) {
|
|
|
3684
3684
|
options.stdin.resume();
|
|
3685
3685
|
options.stdout.write("\x1B[?25l");
|
|
3686
3686
|
render();
|
|
3687
|
-
return await new Promise((
|
|
3687
|
+
return await new Promise((resolve9, reject) => {
|
|
3688
3688
|
const cleanup = () => {
|
|
3689
3689
|
options.stdin.off("keypress", onKeypress);
|
|
3690
3690
|
options.stdin.setRawMode(false);
|
|
@@ -3703,7 +3703,7 @@ async function promptForAiProviderWithArrows(options) {
|
|
|
3703
3703
|
clearRendered();
|
|
3704
3704
|
options.stdout.write(`Selected AI provider: ${provider}
|
|
3705
3705
|
`);
|
|
3706
|
-
|
|
3706
|
+
resolve9(provider);
|
|
3707
3707
|
};
|
|
3708
3708
|
const onKeypress = (_str, key) => {
|
|
3709
3709
|
if (key.ctrl && key.name === "c") {
|
|
@@ -3820,14 +3820,14 @@ async function startUserAttentionEventServer(options = {}) {
|
|
|
3820
3820
|
}
|
|
3821
3821
|
}
|
|
3822
3822
|
}
|
|
3823
|
-
await new Promise((
|
|
3823
|
+
await new Promise((resolve9, reject) => {
|
|
3824
3824
|
const onError = (err2) => {
|
|
3825
3825
|
server.off("listening", onListening);
|
|
3826
3826
|
reject(err2);
|
|
3827
3827
|
};
|
|
3828
3828
|
const onListening = () => {
|
|
3829
3829
|
server.off("error", onError);
|
|
3830
|
-
|
|
3830
|
+
resolve9();
|
|
3831
3831
|
};
|
|
3832
3832
|
server.once("error", onError);
|
|
3833
3833
|
server.once("listening", onListening);
|
|
@@ -3842,7 +3842,7 @@ async function startUserAttentionEventServer(options = {}) {
|
|
|
3842
3842
|
for (const socket of sockets) {
|
|
3843
3843
|
socket.destroy();
|
|
3844
3844
|
}
|
|
3845
|
-
return new Promise((
|
|
3845
|
+
return new Promise((resolve9, reject) => {
|
|
3846
3846
|
server.close((err2) => {
|
|
3847
3847
|
if (process.platform !== "win32") {
|
|
3848
3848
|
try {
|
|
@@ -3853,7 +3853,7 @@ async function startUserAttentionEventServer(options = {}) {
|
|
|
3853
3853
|
if (err2) {
|
|
3854
3854
|
reject(err2);
|
|
3855
3855
|
} else {
|
|
3856
|
-
|
|
3856
|
+
resolve9();
|
|
3857
3857
|
}
|
|
3858
3858
|
});
|
|
3859
3859
|
});
|
|
@@ -3862,7 +3862,7 @@ async function startUserAttentionEventServer(options = {}) {
|
|
|
3862
3862
|
}
|
|
3863
3863
|
async function subscribeUserAttentionEvents(options) {
|
|
3864
3864
|
const path = resolveUserAttentionIpcPath(options.homeDir);
|
|
3865
|
-
return new Promise((
|
|
3865
|
+
return new Promise((resolve9) => {
|
|
3866
3866
|
const socket = (0, import_node_net.createConnection)(path);
|
|
3867
3867
|
let settled = false;
|
|
3868
3868
|
let buffer2 = "";
|
|
@@ -3871,7 +3871,7 @@ async function subscribeUserAttentionEvents(options) {
|
|
|
3871
3871
|
return;
|
|
3872
3872
|
}
|
|
3873
3873
|
settled = true;
|
|
3874
|
-
|
|
3874
|
+
resolve9({
|
|
3875
3875
|
path,
|
|
3876
3876
|
connected,
|
|
3877
3877
|
close() {
|
|
@@ -3903,7 +3903,7 @@ async function subscribeUserAttentionEvents(options) {
|
|
|
3903
3903
|
}
|
|
3904
3904
|
async function notifyUserAttentionChanged(homeDir) {
|
|
3905
3905
|
const path = resolveUserAttentionIpcPath(homeDir);
|
|
3906
|
-
return new Promise((
|
|
3906
|
+
return new Promise((resolve9) => {
|
|
3907
3907
|
const socket = (0, import_node_net.createConnection)(path);
|
|
3908
3908
|
let done = false;
|
|
3909
3909
|
const finish = (ok) => {
|
|
@@ -3912,7 +3912,7 @@ async function notifyUserAttentionChanged(homeDir) {
|
|
|
3912
3912
|
}
|
|
3913
3913
|
done = true;
|
|
3914
3914
|
socket.destroy();
|
|
3915
|
-
|
|
3915
|
+
resolve9(ok);
|
|
3916
3916
|
};
|
|
3917
3917
|
socket.setTimeout(1e3, () => finish(false));
|
|
3918
3918
|
socket.once("connect", () => {
|
|
@@ -6213,7 +6213,7 @@ var require_websocket = __commonJS({
|
|
|
6213
6213
|
var http2 = require("http");
|
|
6214
6214
|
var net = require("net");
|
|
6215
6215
|
var tls = require("tls");
|
|
6216
|
-
var { randomBytes: randomBytes3, createHash:
|
|
6216
|
+
var { randomBytes: randomBytes3, createHash: createHash4 } = require("crypto");
|
|
6217
6217
|
var { Duplex, Readable } = require("stream");
|
|
6218
6218
|
var { URL: URL2 } = require("url");
|
|
6219
6219
|
var PerMessageDeflate = require_permessage_deflate();
|
|
@@ -6873,7 +6873,7 @@ var require_websocket = __commonJS({
|
|
|
6873
6873
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
6874
6874
|
return;
|
|
6875
6875
|
}
|
|
6876
|
-
const digest2 =
|
|
6876
|
+
const digest2 = createHash4("sha1").update(key + GUID).digest("base64");
|
|
6877
6877
|
if (res.headers["sec-websocket-accept"] !== digest2) {
|
|
6878
6878
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
6879
6879
|
return;
|
|
@@ -7240,7 +7240,7 @@ var require_websocket_server = __commonJS({
|
|
|
7240
7240
|
var EventEmitter2 = require("events");
|
|
7241
7241
|
var http2 = require("http");
|
|
7242
7242
|
var { Duplex } = require("stream");
|
|
7243
|
-
var { createHash:
|
|
7243
|
+
var { createHash: createHash4 } = require("crypto");
|
|
7244
7244
|
var extension = require_extension();
|
|
7245
7245
|
var PerMessageDeflate = require_permessage_deflate();
|
|
7246
7246
|
var subprotocol = require_subprotocol();
|
|
@@ -7541,7 +7541,7 @@ var require_websocket_server = __commonJS({
|
|
|
7541
7541
|
);
|
|
7542
7542
|
}
|
|
7543
7543
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
7544
|
-
const digest2 =
|
|
7544
|
+
const digest2 = createHash4("sha1").update(key + GUID).digest("base64");
|
|
7545
7545
|
const headers = [
|
|
7546
7546
|
"HTTP/1.1 101 Switching Protocols",
|
|
7547
7547
|
"Upgrade: websocket",
|
|
@@ -7720,6 +7720,161 @@ function clearClient() {
|
|
|
7720
7720
|
}
|
|
7721
7721
|
sharedClient = null;
|
|
7722
7722
|
}
|
|
7723
|
+
function resolveOpenClawStateDir(env = process.env) {
|
|
7724
|
+
const override = env.OPENCLAW_STATE_DIR?.trim();
|
|
7725
|
+
if (override) {
|
|
7726
|
+
return resolveUserPath(override, env);
|
|
7727
|
+
}
|
|
7728
|
+
return (0, import_node_path11.join)(resolveHomeDir2(env), ".openclaw");
|
|
7729
|
+
}
|
|
7730
|
+
function resolveHomeDir2(env) {
|
|
7731
|
+
const override = env.OPENCLAW_HOME?.trim();
|
|
7732
|
+
if (override) {
|
|
7733
|
+
return resolveUserPath(override, env);
|
|
7734
|
+
}
|
|
7735
|
+
try {
|
|
7736
|
+
const home = (0, import_node_os3.homedir)();
|
|
7737
|
+
if (home) {
|
|
7738
|
+
return home;
|
|
7739
|
+
}
|
|
7740
|
+
} catch {
|
|
7741
|
+
}
|
|
7742
|
+
return (0, import_node_path11.resolve)(process.cwd());
|
|
7743
|
+
}
|
|
7744
|
+
function resolveUserPath(input, env) {
|
|
7745
|
+
if (input === "~" || input.startsWith("~/")) {
|
|
7746
|
+
return (0, import_node_path11.join)(resolveHomeDir2({ ...env, OPENCLAW_HOME: void 0 }), input.slice(2));
|
|
7747
|
+
}
|
|
7748
|
+
return (0, import_node_path11.resolve)(input);
|
|
7749
|
+
}
|
|
7750
|
+
function base64UrlEncode(buf) {
|
|
7751
|
+
return buf.toString("base64").replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/g, "");
|
|
7752
|
+
}
|
|
7753
|
+
function derivePublicKeyRaw(publicKeyPem) {
|
|
7754
|
+
const spki = (0, import_node_crypto3.createPublicKey)(publicKeyPem).export({ type: "spki", format: "der" });
|
|
7755
|
+
if (Buffer.isBuffer(spki) && spki.length === ED25519_SPKI_PREFIX.length + 32 && spki.subarray(0, ED25519_SPKI_PREFIX.length).equals(ED25519_SPKI_PREFIX)) {
|
|
7756
|
+
return spki.subarray(ED25519_SPKI_PREFIX.length);
|
|
7757
|
+
}
|
|
7758
|
+
return Buffer.from(spki);
|
|
7759
|
+
}
|
|
7760
|
+
function publicKeyRawBase64UrlFromPem(publicKeyPem) {
|
|
7761
|
+
return base64UrlEncode(derivePublicKeyRaw(publicKeyPem));
|
|
7762
|
+
}
|
|
7763
|
+
function fingerprintPublicKey(publicKeyPem) {
|
|
7764
|
+
return (0, import_node_crypto3.createHash)("sha256").update(derivePublicKeyRaw(publicKeyPem)).digest("hex");
|
|
7765
|
+
}
|
|
7766
|
+
function ensureParentDir(filePath) {
|
|
7767
|
+
(0, import_node_fs8.mkdirSync)((0, import_node_path11.dirname)(filePath), { recursive: true });
|
|
7768
|
+
}
|
|
7769
|
+
function loadOrCreateDeviceIdentity(env = process.env) {
|
|
7770
|
+
const filePath = (0, import_node_path11.join)(resolveOpenClawStateDir(env), "identity", DEVICE_IDENTITY_FILE);
|
|
7771
|
+
try {
|
|
7772
|
+
if ((0, import_node_fs8.existsSync)(filePath)) {
|
|
7773
|
+
const parsed = JSON.parse((0, import_node_fs8.readFileSync)(filePath, "utf8"));
|
|
7774
|
+
if (parsed.version === 1 && typeof parsed.deviceId === "string" && typeof parsed.publicKeyPem === "string" && typeof parsed.privateKeyPem === "string") {
|
|
7775
|
+
const derivedId = fingerprintPublicKey(parsed.publicKeyPem);
|
|
7776
|
+
if (derivedId && derivedId !== parsed.deviceId) {
|
|
7777
|
+
const updated = { ...parsed, deviceId: derivedId };
|
|
7778
|
+
writeSecretJson(filePath, updated);
|
|
7779
|
+
return { deviceId: derivedId, publicKeyPem: parsed.publicKeyPem, privateKeyPem: parsed.privateKeyPem };
|
|
7780
|
+
}
|
|
7781
|
+
return {
|
|
7782
|
+
deviceId: parsed.deviceId,
|
|
7783
|
+
publicKeyPem: parsed.publicKeyPem,
|
|
7784
|
+
privateKeyPem: parsed.privateKeyPem
|
|
7785
|
+
};
|
|
7786
|
+
}
|
|
7787
|
+
}
|
|
7788
|
+
} catch (err2) {
|
|
7789
|
+
errorWithTimestamp(`${LOG_PREFIX} failed reading device identity: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
7790
|
+
}
|
|
7791
|
+
const { publicKey, privateKey } = (0, import_node_crypto3.generateKeyPairSync)("ed25519");
|
|
7792
|
+
const publicKeyPem = publicKey.export({ type: "spki", format: "pem" }).toString();
|
|
7793
|
+
const privateKeyPem = privateKey.export({ type: "pkcs8", format: "pem" }).toString();
|
|
7794
|
+
const identity3 = {
|
|
7795
|
+
version: 1,
|
|
7796
|
+
deviceId: fingerprintPublicKey(publicKeyPem),
|
|
7797
|
+
publicKeyPem,
|
|
7798
|
+
privateKeyPem,
|
|
7799
|
+
createdAtMs: Date.now()
|
|
7800
|
+
};
|
|
7801
|
+
writeSecretJson(filePath, identity3);
|
|
7802
|
+
return {
|
|
7803
|
+
deviceId: identity3.deviceId,
|
|
7804
|
+
publicKeyPem,
|
|
7805
|
+
privateKeyPem
|
|
7806
|
+
};
|
|
7807
|
+
}
|
|
7808
|
+
function signDevicePayload(privateKeyPem, payload) {
|
|
7809
|
+
return base64UrlEncode((0, import_node_crypto3.sign)(null, Buffer.from(payload, "utf8"), (0, import_node_crypto3.createPrivateKey)(privateKeyPem)));
|
|
7810
|
+
}
|
|
7811
|
+
function writeSecretJson(filePath, value) {
|
|
7812
|
+
ensureParentDir(filePath);
|
|
7813
|
+
(0, import_node_fs8.writeFileSync)(filePath, `${JSON.stringify(value, null, 2)}
|
|
7814
|
+
`, { encoding: "utf8", mode: 384 });
|
|
7815
|
+
try {
|
|
7816
|
+
(0, import_node_fs8.chmodSync)(filePath, 384);
|
|
7817
|
+
} catch {
|
|
7818
|
+
}
|
|
7819
|
+
}
|
|
7820
|
+
function resolveDeviceAuthPath(env = process.env) {
|
|
7821
|
+
return (0, import_node_path11.join)(resolveOpenClawStateDir(env), "identity", DEVICE_AUTH_FILE);
|
|
7822
|
+
}
|
|
7823
|
+
function loadStoredDeviceAuth(deviceId, role) {
|
|
7824
|
+
try {
|
|
7825
|
+
const raw = (0, import_node_fs8.readFileSync)(resolveDeviceAuthPath(), "utf8");
|
|
7826
|
+
const parsed = JSON.parse(raw);
|
|
7827
|
+
if (parsed.version !== 1 || parsed.deviceId !== deviceId || !parsed.tokens) {
|
|
7828
|
+
return null;
|
|
7829
|
+
}
|
|
7830
|
+
const entry = parsed.tokens[role];
|
|
7831
|
+
if (!entry || typeof entry.token !== "string" || !entry.token) {
|
|
7832
|
+
return null;
|
|
7833
|
+
}
|
|
7834
|
+
return {
|
|
7835
|
+
token: entry.token,
|
|
7836
|
+
scopes: Array.isArray(entry.scopes) ? entry.scopes.filter((scope) => typeof scope === "string") : void 0
|
|
7837
|
+
};
|
|
7838
|
+
} catch {
|
|
7839
|
+
return null;
|
|
7840
|
+
}
|
|
7841
|
+
}
|
|
7842
|
+
function storeDeviceAuth(deviceId, role, token, scopes) {
|
|
7843
|
+
const filePath = resolveDeviceAuthPath();
|
|
7844
|
+
let existing = null;
|
|
7845
|
+
try {
|
|
7846
|
+
existing = JSON.parse((0, import_node_fs8.readFileSync)(filePath, "utf8"));
|
|
7847
|
+
} catch {
|
|
7848
|
+
existing = null;
|
|
7849
|
+
}
|
|
7850
|
+
const next = {
|
|
7851
|
+
version: 1,
|
|
7852
|
+
deviceId,
|
|
7853
|
+
tokens: existing?.deviceId === deviceId && existing.tokens ? { ...existing.tokens } : {}
|
|
7854
|
+
};
|
|
7855
|
+
next.tokens[role] = {
|
|
7856
|
+
token,
|
|
7857
|
+
role,
|
|
7858
|
+
scopes,
|
|
7859
|
+
updatedAtMs: Date.now()
|
|
7860
|
+
};
|
|
7861
|
+
writeSecretJson(filePath, next);
|
|
7862
|
+
}
|
|
7863
|
+
function buildDeviceAuthPayloadV3(params) {
|
|
7864
|
+
return [
|
|
7865
|
+
"v3",
|
|
7866
|
+
params.deviceId,
|
|
7867
|
+
params.clientId,
|
|
7868
|
+
params.clientMode,
|
|
7869
|
+
params.role,
|
|
7870
|
+
params.scopes.join(","),
|
|
7871
|
+
String(params.signedAtMs),
|
|
7872
|
+
params.token ?? "",
|
|
7873
|
+
params.nonce,
|
|
7874
|
+
params.platform.trim(),
|
|
7875
|
+
params.deviceFamily?.trim() ?? ""
|
|
7876
|
+
].join("|");
|
|
7877
|
+
}
|
|
7723
7878
|
async function ensureClient(timeoutMs) {
|
|
7724
7879
|
if (sharedClient?.isReady()) {
|
|
7725
7880
|
return sharedClient;
|
|
@@ -7869,7 +8024,7 @@ function isGatewayStartingError(err2) {
|
|
|
7869
8024
|
return String(e?.details?.reason ?? "") === "startup-sidecars" || String(e?.message ?? "").toLowerCase().includes("gateway starting");
|
|
7870
8025
|
}
|
|
7871
8026
|
async function sleep2(ms) {
|
|
7872
|
-
await new Promise((
|
|
8027
|
+
await new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
7873
8028
|
}
|
|
7874
8029
|
function readSyncedGatewayConfig(env) {
|
|
7875
8030
|
try {
|
|
@@ -7887,34 +8042,87 @@ function readSyncedGatewayConfig(env) {
|
|
|
7887
8042
|
return null;
|
|
7888
8043
|
}
|
|
7889
8044
|
}
|
|
7890
|
-
function buildConnectParams(config, instanceId, protocolVersion) {
|
|
8045
|
+
function buildConnectParams(config, instanceId, protocolVersion, deviceIdentity, nonce) {
|
|
8046
|
+
const role = "operator";
|
|
8047
|
+
const storedAuth = loadStoredDeviceAuth(deviceIdentity.deviceId, role);
|
|
8048
|
+
const explicitToken = config.token?.trim();
|
|
8049
|
+
const storedToken = storedAuth?.token?.trim();
|
|
8050
|
+
const password = config.password?.trim();
|
|
8051
|
+
const token = explicitToken || storedToken || void 0;
|
|
8052
|
+
const scopes = storedAuth?.scopes?.length ? storedAuth.scopes : [...DEFAULT_SCOPES];
|
|
8053
|
+
const signedAtMs = Date.now();
|
|
8054
|
+
const platform = process.platform;
|
|
8055
|
+
const clientId = "gateway-client";
|
|
8056
|
+
const clientMode = "backend";
|
|
8057
|
+
const device = nonce ? (() => {
|
|
8058
|
+
const signaturePayload = buildDeviceAuthPayloadV3({
|
|
8059
|
+
deviceId: deviceIdentity.deviceId,
|
|
8060
|
+
clientId,
|
|
8061
|
+
clientMode,
|
|
8062
|
+
role,
|
|
8063
|
+
scopes,
|
|
8064
|
+
signedAtMs,
|
|
8065
|
+
token,
|
|
8066
|
+
nonce,
|
|
8067
|
+
platform
|
|
8068
|
+
});
|
|
8069
|
+
return {
|
|
8070
|
+
id: deviceIdentity.deviceId,
|
|
8071
|
+
publicKey: publicKeyRawBase64UrlFromPem(deviceIdentity.publicKeyPem),
|
|
8072
|
+
signature: signDevicePayload(deviceIdentity.privateKeyPem, signaturePayload),
|
|
8073
|
+
signedAt: signedAtMs,
|
|
8074
|
+
nonce
|
|
8075
|
+
};
|
|
8076
|
+
})() : void 0;
|
|
7891
8077
|
return {
|
|
7892
8078
|
minProtocol: protocolVersion,
|
|
7893
8079
|
maxProtocol: protocolVersion,
|
|
7894
8080
|
client: {
|
|
7895
|
-
id:
|
|
8081
|
+
id: clientId,
|
|
7896
8082
|
displayName: "okx-a2a-node",
|
|
7897
|
-
version: "0.1.
|
|
7898
|
-
platform
|
|
7899
|
-
mode:
|
|
8083
|
+
version: "0.1.4-beta-161afc7833-260702114832",
|
|
8084
|
+
platform,
|
|
8085
|
+
mode: clientMode,
|
|
7900
8086
|
instanceId
|
|
7901
8087
|
},
|
|
7902
|
-
role
|
|
7903
|
-
scopes
|
|
8088
|
+
role,
|
|
8089
|
+
scopes,
|
|
7904
8090
|
caps: [],
|
|
7905
8091
|
commands: [],
|
|
7906
8092
|
permissions: {},
|
|
7907
8093
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
7908
|
-
userAgent: `okx-a2a-node/${"0.1.
|
|
8094
|
+
userAgent: `okx-a2a-node/${"0.1.4-beta-161afc7833-260702114832"}`,
|
|
8095
|
+
...device ? { device } : {},
|
|
7909
8096
|
auth: {
|
|
7910
|
-
...
|
|
7911
|
-
...
|
|
8097
|
+
...token ? { token } : {},
|
|
8098
|
+
...storedToken && !explicitToken ? { deviceToken: storedToken } : {},
|
|
8099
|
+
...password ? { password } : {}
|
|
7912
8100
|
}
|
|
7913
8101
|
};
|
|
7914
8102
|
}
|
|
7915
8103
|
function isHelloOk(value) {
|
|
7916
8104
|
return typeof value === "object" && value !== null && value.type === "hello-ok";
|
|
7917
8105
|
}
|
|
8106
|
+
function persistHelloAuth(value, deviceId) {
|
|
8107
|
+
if (!value || typeof value !== "object") {
|
|
8108
|
+
return;
|
|
8109
|
+
}
|
|
8110
|
+
const auth = value.auth;
|
|
8111
|
+
if (!auth || typeof auth !== "object") {
|
|
8112
|
+
return;
|
|
8113
|
+
}
|
|
8114
|
+
const record = auth;
|
|
8115
|
+
if (typeof record.deviceToken !== "string" || !record.deviceToken) {
|
|
8116
|
+
return;
|
|
8117
|
+
}
|
|
8118
|
+
const role = typeof record.role === "string" && record.role.trim() ? record.role.trim() : "operator";
|
|
8119
|
+
const scopes = Array.isArray(record.scopes) ? record.scopes.filter((scope) => typeof scope === "string" && scope.trim().length > 0) : [];
|
|
8120
|
+
try {
|
|
8121
|
+
storeDeviceAuth(deviceId, role, record.deviceToken, scopes);
|
|
8122
|
+
} catch (err2) {
|
|
8123
|
+
errorWithTimestamp(`${LOG_PREFIX} failed storing device auth token: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
8124
|
+
}
|
|
8125
|
+
}
|
|
7918
8126
|
function toGatewayError(error) {
|
|
7919
8127
|
const err2 = Object.assign(new Error(error?.message || "OpenClaw gateway request failed"), {
|
|
7920
8128
|
code: error?.code,
|
|
@@ -7971,12 +8179,15 @@ function isSessionNotFound(err2) {
|
|
|
7971
8179
|
const msg = String(e?.message ?? "");
|
|
7972
8180
|
return (code2 === "INVALID_REQUEST" || code2 === "SESSION_NOT_FOUND") && msg.includes("session not found");
|
|
7973
8181
|
}
|
|
7974
|
-
var import_node_crypto3, DEFAULT_GATEWAY_PORT, DEFAULT_TIMEOUT_MS, DEFAULT_HEALTH_TIMEOUT_MS, PREFERRED_PROTOCOL_VERSION, LEGACY_PROTOCOL_VERSION, DEFAULT_SCOPES, LOG_PREFIX, GATEWAY_STARTING_RETRY_DELAYS_MS, wsFactory, preferredGatewayProtocolVersion, sharedClient, MinimalGatewayClient;
|
|
8182
|
+
var import_node_crypto3, import_node_fs8, import_node_os3, import_node_path11, DEFAULT_GATEWAY_PORT, DEFAULT_TIMEOUT_MS, DEFAULT_HEALTH_TIMEOUT_MS, PREFERRED_PROTOCOL_VERSION, LEGACY_PROTOCOL_VERSION, DEFAULT_SCOPES, LOG_PREFIX, GATEWAY_STARTING_RETRY_DELAYS_MS, CONNECT_CHALLENGE_FALLBACK_MS, DEVICE_AUTH_FILE, DEVICE_IDENTITY_FILE, ED25519_SPKI_PREFIX, wsFactory, preferredGatewayProtocolVersion, sharedClient, MinimalGatewayClient;
|
|
7975
8183
|
var init_openclaw_gateway = __esm({
|
|
7976
8184
|
"src/openclaw-gateway.ts"() {
|
|
7977
8185
|
"use strict";
|
|
7978
8186
|
init_log();
|
|
7979
8187
|
import_node_crypto3 = require("node:crypto");
|
|
8188
|
+
import_node_fs8 = require("node:fs");
|
|
8189
|
+
import_node_os3 = require("node:os");
|
|
8190
|
+
import_node_path11 = require("node:path");
|
|
7980
8191
|
init_openclaw_gateway_config();
|
|
7981
8192
|
DEFAULT_GATEWAY_PORT = 18789;
|
|
7982
8193
|
DEFAULT_TIMEOUT_MS = 2e4;
|
|
@@ -7986,6 +8197,10 @@ var init_openclaw_gateway = __esm({
|
|
|
7986
8197
|
DEFAULT_SCOPES = ["operator.admin"];
|
|
7987
8198
|
LOG_PREFIX = "[okx-a2a:gateway]";
|
|
7988
8199
|
GATEWAY_STARTING_RETRY_DELAYS_MS = [300, 700, 1200, 2e3, 3e3];
|
|
8200
|
+
CONNECT_CHALLENGE_FALLBACK_MS = 750;
|
|
8201
|
+
DEVICE_AUTH_FILE = "device-auth.json";
|
|
8202
|
+
DEVICE_IDENTITY_FILE = "device.json";
|
|
8203
|
+
ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
|
|
7989
8204
|
wsFactory = createDefaultWebSocket;
|
|
7990
8205
|
preferredGatewayProtocolVersion = PREFERRED_PROTOCOL_VERSION;
|
|
7991
8206
|
sharedClient = null;
|
|
@@ -7993,11 +8208,13 @@ var init_openclaw_gateway = __esm({
|
|
|
7993
8208
|
config;
|
|
7994
8209
|
protocolVersion;
|
|
7995
8210
|
instanceId = (0, import_node_crypto3.randomUUID)();
|
|
8211
|
+
deviceIdentity = loadOrCreateDeviceIdentity();
|
|
7996
8212
|
pending = /* @__PURE__ */ new Map();
|
|
7997
8213
|
ws = null;
|
|
7998
8214
|
ready = false;
|
|
7999
8215
|
closed = false;
|
|
8000
8216
|
requestSeq = 0;
|
|
8217
|
+
connectNonce = null;
|
|
8001
8218
|
constructor(config, protocolVersion) {
|
|
8002
8219
|
this.config = config;
|
|
8003
8220
|
this.protocolVersion = protocolVersion;
|
|
@@ -8011,7 +8228,7 @@ var init_openclaw_gateway = __esm({
|
|
|
8011
8228
|
);
|
|
8012
8229
|
const ws = wsFactory(this.config.url);
|
|
8013
8230
|
this.ws = ws;
|
|
8014
|
-
await new Promise((
|
|
8231
|
+
await new Promise((resolve9, reject) => {
|
|
8015
8232
|
let settled = false;
|
|
8016
8233
|
const timer = setTimeout(() => {
|
|
8017
8234
|
if (settled) {
|
|
@@ -8030,7 +8247,7 @@ var init_openclaw_gateway = __esm({
|
|
|
8030
8247
|
}
|
|
8031
8248
|
settled = true;
|
|
8032
8249
|
clearTimeout(timer);
|
|
8033
|
-
|
|
8250
|
+
resolve9();
|
|
8034
8251
|
},
|
|
8035
8252
|
(err2) => {
|
|
8036
8253
|
if (settled) {
|
|
@@ -8082,7 +8299,7 @@ var init_openclaw_gateway = __esm({
|
|
|
8082
8299
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
8083
8300
|
const id = `okx-a2a-${++this.requestSeq}-${(0, import_node_crypto3.randomUUID)()}`;
|
|
8084
8301
|
const frame = { type: "req", id, method, params };
|
|
8085
|
-
return new Promise((
|
|
8302
|
+
return new Promise((resolve9, reject) => {
|
|
8086
8303
|
const timer = setTimeout(() => {
|
|
8087
8304
|
this.pending.delete(id);
|
|
8088
8305
|
reject(Object.assign(new Error(`OpenClaw gateway request timed out method=${method}`), {
|
|
@@ -8091,7 +8308,7 @@ var init_openclaw_gateway = __esm({
|
|
|
8091
8308
|
}));
|
|
8092
8309
|
}, timeoutMs);
|
|
8093
8310
|
timer.unref?.();
|
|
8094
|
-
this.pending.set(id, { method, resolve:
|
|
8311
|
+
this.pending.set(id, { method, resolve: resolve9, reject, timer });
|
|
8095
8312
|
try {
|
|
8096
8313
|
this.ws.send(JSON.stringify(frame));
|
|
8097
8314
|
} catch (err2) {
|
|
@@ -8122,9 +8339,10 @@ var init_openclaw_gateway = __esm({
|
|
|
8122
8339
|
this.ws = null;
|
|
8123
8340
|
}
|
|
8124
8341
|
async handleOpen(timeoutMs) {
|
|
8342
|
+
const nonce = await this.waitForConnectNonce(Math.min(timeoutMs, CONNECT_CHALLENGE_FALLBACK_MS));
|
|
8125
8343
|
const hello = await this.request(
|
|
8126
8344
|
"connect",
|
|
8127
|
-
buildConnectParams(this.config, this.instanceId, this.protocolVersion),
|
|
8345
|
+
buildConnectParams(this.config, this.instanceId, this.protocolVersion, this.deviceIdentity, nonce),
|
|
8128
8346
|
{ timeoutMs }
|
|
8129
8347
|
);
|
|
8130
8348
|
if (!isHelloOk(hello)) {
|
|
@@ -8132,6 +8350,9 @@ var init_openclaw_gateway = __esm({
|
|
|
8132
8350
|
code: "PROTOCOL_ERROR"
|
|
8133
8351
|
});
|
|
8134
8352
|
}
|
|
8353
|
+
if (nonce) {
|
|
8354
|
+
persistHelloAuth(hello, this.deviceIdentity.deviceId);
|
|
8355
|
+
}
|
|
8135
8356
|
this.ready = true;
|
|
8136
8357
|
}
|
|
8137
8358
|
handleMessage(raw) {
|
|
@@ -8143,6 +8364,9 @@ var init_openclaw_gateway = __esm({
|
|
|
8143
8364
|
return;
|
|
8144
8365
|
}
|
|
8145
8366
|
if (frame.type !== "res") {
|
|
8367
|
+
if (frame.type === "event") {
|
|
8368
|
+
this.handleEventFrame(frame);
|
|
8369
|
+
}
|
|
8146
8370
|
return;
|
|
8147
8371
|
}
|
|
8148
8372
|
if (frame.progress) {
|
|
@@ -8172,6 +8396,38 @@ var init_openclaw_gateway = __esm({
|
|
|
8172
8396
|
this.pending.delete(id);
|
|
8173
8397
|
}
|
|
8174
8398
|
}
|
|
8399
|
+
handleEventFrame(frame) {
|
|
8400
|
+
if (frame.event !== "connect.challenge") {
|
|
8401
|
+
return;
|
|
8402
|
+
}
|
|
8403
|
+
const payload = frame.payload;
|
|
8404
|
+
const nonce = typeof payload === "object" && payload !== null && "nonce" in payload ? String(payload.nonce ?? "").trim() : "";
|
|
8405
|
+
if (nonce) {
|
|
8406
|
+
this.connectNonce = nonce;
|
|
8407
|
+
}
|
|
8408
|
+
}
|
|
8409
|
+
async waitForConnectNonce(timeoutMs) {
|
|
8410
|
+
const existing = this.connectNonce?.trim();
|
|
8411
|
+
if (existing) {
|
|
8412
|
+
return existing;
|
|
8413
|
+
}
|
|
8414
|
+
const deadline = Date.now() + timeoutMs;
|
|
8415
|
+
while (!this.connectNonce && Date.now() < deadline) {
|
|
8416
|
+
await sleep2(10);
|
|
8417
|
+
if (this.closed || this.ws?.readyState !== 1) {
|
|
8418
|
+
throw Object.assign(new Error("OpenClaw gateway socket closed before connect challenge"), {
|
|
8419
|
+
code: "ECONNRESET",
|
|
8420
|
+
retryable: true
|
|
8421
|
+
});
|
|
8422
|
+
}
|
|
8423
|
+
}
|
|
8424
|
+
const nonce = this.connectNonce?.trim();
|
|
8425
|
+
if (!nonce) {
|
|
8426
|
+
errorWithTimestamp(`${LOG_PREFIX} connect challenge unavailable; falling back to legacy auth-less connect`);
|
|
8427
|
+
return null;
|
|
8428
|
+
}
|
|
8429
|
+
return nonce;
|
|
8430
|
+
}
|
|
8175
8431
|
};
|
|
8176
8432
|
}
|
|
8177
8433
|
});
|
|
@@ -8554,12 +8810,12 @@ function readGatewaySessionKeysEnv(env) {
|
|
|
8554
8810
|
return raw.split(",").map((item) => item.trim()).filter(Boolean);
|
|
8555
8811
|
}
|
|
8556
8812
|
function readSingleActiveOriginSessionKey(env) {
|
|
8557
|
-
const path = (0,
|
|
8558
|
-
if (!(0,
|
|
8813
|
+
const path = (0, import_node_path12.join)(resolveTaskHome2(env), "run", "gateway-route-origins.json");
|
|
8814
|
+
if (!(0, import_node_fs9.existsSync)(path)) {
|
|
8559
8815
|
return [];
|
|
8560
8816
|
}
|
|
8561
8817
|
try {
|
|
8562
|
-
const parsed = JSON.parse((0,
|
|
8818
|
+
const parsed = JSON.parse((0, import_node_fs9.readFileSync)(path, "utf8"));
|
|
8563
8819
|
if (!isRecord(parsed) || !Array.isArray(parsed.origins)) {
|
|
8564
8820
|
return [];
|
|
8565
8821
|
}
|
|
@@ -8584,7 +8840,7 @@ function readSingleActiveOriginSessionKey(env) {
|
|
|
8584
8840
|
}
|
|
8585
8841
|
}
|
|
8586
8842
|
function resolveTaskHome2(env) {
|
|
8587
|
-
return env.OKX_AGENT_TASK_HOME?.trim() || (0,
|
|
8843
|
+
return env.OKX_AGENT_TASK_HOME?.trim() || (0, import_node_path12.join)((0, import_node_os4.homedir)(), ".okx-agent-task");
|
|
8588
8844
|
}
|
|
8589
8845
|
function logOpenClawRouteSkip(reason, input) {
|
|
8590
8846
|
if (reason === "missing_gateway_session_key") {
|
|
@@ -8625,13 +8881,13 @@ function safeDecode2(value) {
|
|
|
8625
8881
|
return value;
|
|
8626
8882
|
}
|
|
8627
8883
|
}
|
|
8628
|
-
var
|
|
8884
|
+
var import_node_fs9, import_node_os4, import_node_path12, CURRENT_GATEWAY_SESSION_KEYS_ENV, NON_DELIVERY_CHANNELS, ACTIVE_ORIGIN_TTL_MS;
|
|
8629
8885
|
var init_openclaw_route = __esm({
|
|
8630
8886
|
"src/openclaw-route.ts"() {
|
|
8631
8887
|
"use strict";
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8888
|
+
import_node_fs9 = require("node:fs");
|
|
8889
|
+
import_node_os4 = require("node:os");
|
|
8890
|
+
import_node_path12 = require("node:path");
|
|
8635
8891
|
CURRENT_GATEWAY_SESSION_KEYS_ENV = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
|
|
8636
8892
|
NON_DELIVERY_CHANNELS = /* @__PURE__ */ new Set(["heartbeat", "cron", "webhook", "voice"]);
|
|
8637
8893
|
ACTIVE_ORIGIN_TTL_MS = 30 * 6e4;
|
|
@@ -10445,7 +10701,7 @@ var require_path = __commonJS({
|
|
|
10445
10701
|
const parts = splitPathRe.exec(truncated);
|
|
10446
10702
|
return parts ? parts.slice(1) : [];
|
|
10447
10703
|
}
|
|
10448
|
-
function
|
|
10704
|
+
function resolve9(...args) {
|
|
10449
10705
|
let resolvedPath = "";
|
|
10450
10706
|
let resolvedAbsolute = false;
|
|
10451
10707
|
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
@@ -10481,8 +10737,8 @@ var require_path = __commonJS({
|
|
|
10481
10737
|
return arr.slice(start, end - start + 1);
|
|
10482
10738
|
}
|
|
10483
10739
|
function relative(from3, to) {
|
|
10484
|
-
from3 =
|
|
10485
|
-
to =
|
|
10740
|
+
from3 = resolve9(from3).slice(1);
|
|
10741
|
+
to = resolve9(to).slice(1);
|
|
10486
10742
|
const fromParts = trim2(from3.split("/"));
|
|
10487
10743
|
const toParts = trim2(to.split("/"));
|
|
10488
10744
|
const length2 = Math.min(fromParts.length, toParts.length);
|
|
@@ -10518,10 +10774,10 @@ var require_path = __commonJS({
|
|
|
10518
10774
|
function isAbsolute2(path) {
|
|
10519
10775
|
return path.charAt(0) === "/";
|
|
10520
10776
|
}
|
|
10521
|
-
function
|
|
10777
|
+
function join24(...args) {
|
|
10522
10778
|
return normalizePath(args.join("/"));
|
|
10523
10779
|
}
|
|
10524
|
-
function
|
|
10780
|
+
function dirname7(path) {
|
|
10525
10781
|
const result = splitPath(path);
|
|
10526
10782
|
const root = result[0];
|
|
10527
10783
|
let dir = result[1];
|
|
@@ -10541,12 +10797,12 @@ var require_path = __commonJS({
|
|
|
10541
10797
|
return f;
|
|
10542
10798
|
}
|
|
10543
10799
|
exports2.basename = basename5;
|
|
10544
|
-
exports2.dirname =
|
|
10800
|
+
exports2.dirname = dirname7;
|
|
10545
10801
|
exports2.isAbsolute = isAbsolute2;
|
|
10546
|
-
exports2.join =
|
|
10802
|
+
exports2.join = join24;
|
|
10547
10803
|
exports2.normalizePath = normalizePath;
|
|
10548
10804
|
exports2.relative = relative;
|
|
10549
|
-
exports2.resolve =
|
|
10805
|
+
exports2.resolve = resolve9;
|
|
10550
10806
|
}
|
|
10551
10807
|
});
|
|
10552
10808
|
|
|
@@ -10565,8 +10821,8 @@ var require_syncpromise = __commonJS({
|
|
|
10565
10821
|
States2[States2["REJECTED"] = REJECTED] = "REJECTED";
|
|
10566
10822
|
})(States || (States = {}));
|
|
10567
10823
|
function resolvedSyncPromise(value) {
|
|
10568
|
-
return new SyncPromise((
|
|
10569
|
-
|
|
10824
|
+
return new SyncPromise((resolve9) => {
|
|
10825
|
+
resolve9(value);
|
|
10570
10826
|
});
|
|
10571
10827
|
}
|
|
10572
10828
|
function rejectedSyncPromise(reason) {
|
|
@@ -10590,15 +10846,15 @@ var require_syncpromise = __commonJS({
|
|
|
10590
10846
|
}
|
|
10591
10847
|
/** JSDoc */
|
|
10592
10848
|
then(onfulfilled, onrejected) {
|
|
10593
|
-
return new _SyncPromise((
|
|
10849
|
+
return new _SyncPromise((resolve9, reject) => {
|
|
10594
10850
|
this._handlers.push([
|
|
10595
10851
|
false,
|
|
10596
10852
|
(result) => {
|
|
10597
10853
|
if (!onfulfilled) {
|
|
10598
|
-
|
|
10854
|
+
resolve9(result);
|
|
10599
10855
|
} else {
|
|
10600
10856
|
try {
|
|
10601
|
-
|
|
10857
|
+
resolve9(onfulfilled(result));
|
|
10602
10858
|
} catch (e) {
|
|
10603
10859
|
reject(e);
|
|
10604
10860
|
}
|
|
@@ -10609,7 +10865,7 @@ var require_syncpromise = __commonJS({
|
|
|
10609
10865
|
reject(reason);
|
|
10610
10866
|
} else {
|
|
10611
10867
|
try {
|
|
10612
|
-
|
|
10868
|
+
resolve9(onrejected(reason));
|
|
10613
10869
|
} catch (e) {
|
|
10614
10870
|
reject(e);
|
|
10615
10871
|
}
|
|
@@ -10625,7 +10881,7 @@ var require_syncpromise = __commonJS({
|
|
|
10625
10881
|
}
|
|
10626
10882
|
/** JSDoc */
|
|
10627
10883
|
finally(onfinally) {
|
|
10628
|
-
return new _SyncPromise((
|
|
10884
|
+
return new _SyncPromise((resolve9, reject) => {
|
|
10629
10885
|
let val;
|
|
10630
10886
|
let isRejected;
|
|
10631
10887
|
return this.then(
|
|
@@ -10648,7 +10904,7 @@ var require_syncpromise = __commonJS({
|
|
|
10648
10904
|
reject(val);
|
|
10649
10905
|
return;
|
|
10650
10906
|
}
|
|
10651
|
-
|
|
10907
|
+
resolve9(val);
|
|
10652
10908
|
});
|
|
10653
10909
|
});
|
|
10654
10910
|
}
|
|
@@ -10738,21 +10994,21 @@ var require_promisebuffer = __commonJS({
|
|
|
10738
10994
|
return task;
|
|
10739
10995
|
}
|
|
10740
10996
|
function drain(timeout) {
|
|
10741
|
-
return new syncpromise.SyncPromise((
|
|
10997
|
+
return new syncpromise.SyncPromise((resolve9, reject) => {
|
|
10742
10998
|
let counter = buffer2.length;
|
|
10743
10999
|
if (!counter) {
|
|
10744
|
-
return
|
|
11000
|
+
return resolve9(true);
|
|
10745
11001
|
}
|
|
10746
11002
|
const capturedSetTimeout = setTimeout(() => {
|
|
10747
11003
|
if (timeout && timeout > 0) {
|
|
10748
|
-
|
|
11004
|
+
resolve9(false);
|
|
10749
11005
|
}
|
|
10750
11006
|
}, timeout);
|
|
10751
11007
|
buffer2.forEach((item) => {
|
|
10752
11008
|
void syncpromise.resolvedSyncPromise(item).then(() => {
|
|
10753
11009
|
if (!--counter) {
|
|
10754
11010
|
clearTimeout(capturedSetTimeout);
|
|
10755
|
-
|
|
11011
|
+
resolve9(true);
|
|
10756
11012
|
}
|
|
10757
11013
|
}, reject);
|
|
10758
11014
|
});
|
|
@@ -11954,17 +12210,17 @@ var require_eventProcessors = __commonJS({
|
|
|
11954
12210
|
getGlobalEventProcessors().push(callback);
|
|
11955
12211
|
}
|
|
11956
12212
|
function notifyEventProcessors(processors, event, hint, index2 = 0) {
|
|
11957
|
-
return new utils.SyncPromise((
|
|
12213
|
+
return new utils.SyncPromise((resolve9, reject) => {
|
|
11958
12214
|
const processor = processors[index2];
|
|
11959
12215
|
if (event === null || typeof processor !== "function") {
|
|
11960
|
-
|
|
12216
|
+
resolve9(event);
|
|
11961
12217
|
} else {
|
|
11962
12218
|
const result = processor({ ...event }, hint);
|
|
11963
12219
|
(typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) && processor.id && result === null && utils.logger.log(`Event processor "${processor.id}" dropped event`);
|
|
11964
12220
|
if (utils.isThenable(result)) {
|
|
11965
|
-
void result.then((final) => notifyEventProcessors(processors, final, hint, index2 + 1).then(
|
|
12221
|
+
void result.then((final) => notifyEventProcessors(processors, final, hint, index2 + 1).then(resolve9)).then(null, reject);
|
|
11966
12222
|
} else {
|
|
11967
|
-
void notifyEventProcessors(processors, result, hint, index2 + 1).then(
|
|
12223
|
+
void notifyEventProcessors(processors, result, hint, index2 + 1).then(resolve9).then(null, reject);
|
|
11968
12224
|
}
|
|
11969
12225
|
}
|
|
11970
12226
|
});
|
|
@@ -15118,18 +15374,18 @@ var require_baseclient = __commonJS({
|
|
|
15118
15374
|
* `false` otherwise
|
|
15119
15375
|
*/
|
|
15120
15376
|
_isClientDoneProcessing(timeout) {
|
|
15121
|
-
return new utils.SyncPromise((
|
|
15377
|
+
return new utils.SyncPromise((resolve9) => {
|
|
15122
15378
|
let ticked = 0;
|
|
15123
15379
|
const tick = 1;
|
|
15124
15380
|
const interval = setInterval(() => {
|
|
15125
15381
|
if (this._numProcessing == 0) {
|
|
15126
15382
|
clearInterval(interval);
|
|
15127
|
-
|
|
15383
|
+
resolve9(true);
|
|
15128
15384
|
} else {
|
|
15129
15385
|
ticked += tick;
|
|
15130
15386
|
if (timeout && ticked >= timeout) {
|
|
15131
15387
|
clearInterval(interval);
|
|
15132
|
-
|
|
15388
|
+
resolve9(false);
|
|
15133
15389
|
}
|
|
15134
15390
|
}
|
|
15135
15391
|
}, tick);
|
|
@@ -19544,7 +19800,7 @@ var require_supports_color = __commonJS({
|
|
|
19544
19800
|
return 1;
|
|
19545
19801
|
}
|
|
19546
19802
|
if ("CI" in env) {
|
|
19547
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((
|
|
19803
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign3) => sign3 in env) || env.CI_NAME === "codeship") {
|
|
19548
19804
|
return 1;
|
|
19549
19805
|
}
|
|
19550
19806
|
return min;
|
|
@@ -19779,12 +20035,12 @@ var require_promisify = __commonJS({
|
|
|
19779
20035
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
19780
20036
|
function promisify3(fn) {
|
|
19781
20037
|
return function(req, opts) {
|
|
19782
|
-
return new Promise((
|
|
20038
|
+
return new Promise((resolve9, reject) => {
|
|
19783
20039
|
fn.call(this, req, opts, (err2, rtn) => {
|
|
19784
20040
|
if (err2) {
|
|
19785
20041
|
reject(err2);
|
|
19786
20042
|
} else {
|
|
19787
|
-
|
|
20043
|
+
resolve9(rtn);
|
|
19788
20044
|
}
|
|
19789
20045
|
});
|
|
19790
20046
|
});
|
|
@@ -19988,7 +20244,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
19988
20244
|
var debug_1 = __importDefault(require_src());
|
|
19989
20245
|
var debug = debug_1.default("https-proxy-agent:parse-proxy-response");
|
|
19990
20246
|
function parseProxyResponse(socket) {
|
|
19991
|
-
return new Promise((
|
|
20247
|
+
return new Promise((resolve9, reject) => {
|
|
19992
20248
|
let buffersLength = 0;
|
|
19993
20249
|
const buffers = [];
|
|
19994
20250
|
function read2() {
|
|
@@ -20028,7 +20284,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
20028
20284
|
const firstLine = buffered.toString("ascii", 0, buffered.indexOf("\r\n"));
|
|
20029
20285
|
const statusCode = +firstLine.split(" ")[1];
|
|
20030
20286
|
debug("got proxy server response: %o", firstLine);
|
|
20031
|
-
|
|
20287
|
+
resolve9({
|
|
20032
20288
|
statusCode,
|
|
20033
20289
|
buffered
|
|
20034
20290
|
});
|
|
@@ -20049,11 +20305,11 @@ var require_agent = __commonJS({
|
|
|
20049
20305
|
"use strict";
|
|
20050
20306
|
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
20051
20307
|
function adopt(value) {
|
|
20052
|
-
return value instanceof P2 ? value : new P2(function(
|
|
20053
|
-
|
|
20308
|
+
return value instanceof P2 ? value : new P2(function(resolve9) {
|
|
20309
|
+
resolve9(value);
|
|
20054
20310
|
});
|
|
20055
20311
|
}
|
|
20056
|
-
return new (P2 || (P2 = Promise))(function(
|
|
20312
|
+
return new (P2 || (P2 = Promise))(function(resolve9, reject) {
|
|
20057
20313
|
function fulfilled(value) {
|
|
20058
20314
|
try {
|
|
20059
20315
|
step(generator.next(value));
|
|
@@ -20069,7 +20325,7 @@ var require_agent = __commonJS({
|
|
|
20069
20325
|
}
|
|
20070
20326
|
}
|
|
20071
20327
|
function step(result) {
|
|
20072
|
-
result.done ?
|
|
20328
|
+
result.done ? resolve9(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
20073
20329
|
}
|
|
20074
20330
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20075
20331
|
});
|
|
@@ -20280,7 +20536,7 @@ var require_http = __commonJS({
|
|
|
20280
20536
|
function createRequestExecutor(options, httpModule, agent) {
|
|
20281
20537
|
const { hostname, pathname, port, protocol, search } = new url.URL(options.url);
|
|
20282
20538
|
return function makeRequest(request) {
|
|
20283
|
-
return new Promise((
|
|
20539
|
+
return new Promise((resolve9, reject) => {
|
|
20284
20540
|
let body = streamFromBody(request.body);
|
|
20285
20541
|
const headers = { ...options.headers };
|
|
20286
20542
|
if (request.body.length > GZIP_THRESHOLD) {
|
|
@@ -20306,7 +20562,7 @@ var require_http = __commonJS({
|
|
|
20306
20562
|
res.setEncoding("utf8");
|
|
20307
20563
|
const retryAfterHeader = _nullishCoalesce(res.headers["retry-after"], () => null);
|
|
20308
20564
|
const rateLimitsHeader = _nullishCoalesce(res.headers["x-sentry-rate-limits"], () => null);
|
|
20309
|
-
|
|
20565
|
+
resolve9({
|
|
20310
20566
|
statusCode: res.statusCode,
|
|
20311
20567
|
headers: {
|
|
20312
20568
|
"retry-after": retryAfterHeader,
|
|
@@ -20574,7 +20830,7 @@ var require_websocket2 = __commonJS({
|
|
|
20574
20830
|
};
|
|
20575
20831
|
async function createWebSocketClient(rawUrl) {
|
|
20576
20832
|
const parts = url.parse(rawUrl);
|
|
20577
|
-
return new Promise((
|
|
20833
|
+
return new Promise((resolve9, reject) => {
|
|
20578
20834
|
const key = crypto3.randomBytes(16).toString("base64");
|
|
20579
20835
|
const digest2 = createKey(key);
|
|
20580
20836
|
const req = http2.request({
|
|
@@ -20605,7 +20861,7 @@ var require_websocket2 = __commonJS({
|
|
|
20605
20861
|
return;
|
|
20606
20862
|
}
|
|
20607
20863
|
const client = new WebSocketInterface(socket);
|
|
20608
|
-
|
|
20864
|
+
resolve9(client);
|
|
20609
20865
|
});
|
|
20610
20866
|
req.on("error", (err2) => {
|
|
20611
20867
|
reject(err2);
|
|
@@ -21934,10 +22190,10 @@ var require_contextlines = __commonJS({
|
|
|
21934
22190
|
var FILE_CONTENT_CACHE = new lru_map.LRUMap(100);
|
|
21935
22191
|
var DEFAULT_LINES_OF_CONTEXT = 7;
|
|
21936
22192
|
function readTextFileAsync(path) {
|
|
21937
|
-
return new Promise((
|
|
22193
|
+
return new Promise((resolve9, reject) => {
|
|
21938
22194
|
fs.readFile(path, "utf8", (err2, data) => {
|
|
21939
22195
|
if (err2) reject(err2);
|
|
21940
|
-
else
|
|
22196
|
+
else resolve9(data);
|
|
21941
22197
|
});
|
|
21942
22198
|
});
|
|
21943
22199
|
}
|
|
@@ -22247,13 +22503,13 @@ var require_context = __commonJS({
|
|
|
22247
22503
|
version: `10.${Number(os.release().split(".")[0]) - 4}`
|
|
22248
22504
|
};
|
|
22249
22505
|
try {
|
|
22250
|
-
const output4 = await new Promise((
|
|
22506
|
+
const output4 = await new Promise((resolve9, reject) => {
|
|
22251
22507
|
child_process.execFile("/usr/bin/sw_vers", (error, stdout) => {
|
|
22252
22508
|
if (error) {
|
|
22253
22509
|
reject(error);
|
|
22254
22510
|
return;
|
|
22255
22511
|
}
|
|
22256
|
-
|
|
22512
|
+
resolve9(stdout);
|
|
22257
22513
|
});
|
|
22258
22514
|
});
|
|
22259
22515
|
darwinInfo.name = matchFirst(/^ProductName:\s+(.*)$/m, output4);
|
|
@@ -25016,23 +25272,23 @@ function resolveAiPermissionPreset(options = {}) {
|
|
|
25016
25272
|
}
|
|
25017
25273
|
function readAiPermissionPresetFromConfig(homeDir) {
|
|
25018
25274
|
const configPath = resolveTaskConfigPath(homeDir);
|
|
25019
|
-
if (!(0,
|
|
25275
|
+
if (!(0, import_node_fs10.existsSync)(configPath)) {
|
|
25020
25276
|
return null;
|
|
25021
25277
|
}
|
|
25022
|
-
const raw = readSimpleTomlStringValue((0,
|
|
25278
|
+
const raw = readSimpleTomlStringValue((0, import_node_fs10.readFileSync)(configPath, "utf8"), "ai.permissions", "preset");
|
|
25023
25279
|
return raw ? normalizeAiPermissionPreset(raw, configPath) : null;
|
|
25024
25280
|
}
|
|
25025
25281
|
function writeAiPermissionPresetToConfig(homeDir, preset) {
|
|
25026
25282
|
const normalized = normalizeAiPermissionPreset(preset, "permission preset");
|
|
25027
25283
|
ensureTaskDir(homeDir);
|
|
25028
25284
|
const configPath = resolveTaskConfigPath(homeDir);
|
|
25029
|
-
const current = (0,
|
|
25285
|
+
const current = (0, import_node_fs10.existsSync)(configPath) ? (0, import_node_fs10.readFileSync)(configPath, "utf8") : "";
|
|
25030
25286
|
const next = upsertSimpleTomlStringValue(current, "ai.permissions", "preset", normalized);
|
|
25031
|
-
(0,
|
|
25287
|
+
(0, import_node_fs10.writeFileSync)(configPath, next, "utf8");
|
|
25032
25288
|
return normalized;
|
|
25033
25289
|
}
|
|
25034
25290
|
function resolveTaskConfigPath(homeDir) {
|
|
25035
|
-
return (0,
|
|
25291
|
+
return (0, import_node_path13.join)(homeDir, "config.toml");
|
|
25036
25292
|
}
|
|
25037
25293
|
function normalizeAiPermissionPreset(value, source) {
|
|
25038
25294
|
const normalized = value.trim().toLowerCase();
|
|
@@ -25105,12 +25361,12 @@ function upsertSimpleTomlStringValue(text, section, key, value) {
|
|
|
25105
25361
|
function escapeRegExp(value) {
|
|
25106
25362
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25107
25363
|
}
|
|
25108
|
-
var
|
|
25364
|
+
var import_node_fs10, import_node_path13, AI_PERMISSION_PRESETS, DEFAULT_AI_PERMISSION_PRESET;
|
|
25109
25365
|
var init_task_config = __esm({
|
|
25110
25366
|
"src/task-config.ts"() {
|
|
25111
25367
|
"use strict";
|
|
25112
|
-
|
|
25113
|
-
|
|
25368
|
+
import_node_fs10 = require("node:fs");
|
|
25369
|
+
import_node_path13 = require("node:path");
|
|
25114
25370
|
init_paths();
|
|
25115
25371
|
AI_PERMISSION_PRESETS = ["bypass", "auto"];
|
|
25116
25372
|
DEFAULT_AI_PERMISSION_PRESET = "bypass";
|
|
@@ -25125,7 +25381,7 @@ var init_sentry_config = __esm({
|
|
|
25125
25381
|
environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
25126
25382
|
SENTRY_CONFIG = {
|
|
25127
25383
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
25128
|
-
release: "0.1.
|
|
25384
|
+
release: "0.1.4-beta-161afc7833-260702114832",
|
|
25129
25385
|
environment
|
|
25130
25386
|
};
|
|
25131
25387
|
}
|
|
@@ -25155,18 +25411,18 @@ __export(autostart_exports, {
|
|
|
25155
25411
|
uninstallLaunchdAutostart: () => uninstallLaunchdAutostart,
|
|
25156
25412
|
uninstallSystemdAutostart: () => uninstallSystemdAutostart
|
|
25157
25413
|
});
|
|
25158
|
-
function resolveSystemdAutostartPaths(home = (0,
|
|
25159
|
-
const serviceDir = (0,
|
|
25414
|
+
function resolveSystemdAutostartPaths(home = (0, import_node_os5.homedir)()) {
|
|
25415
|
+
const serviceDir = (0, import_node_path14.join)(home, ".config", "systemd", "user");
|
|
25160
25416
|
return {
|
|
25161
25417
|
serviceDir,
|
|
25162
|
-
servicePath: (0,
|
|
25418
|
+
servicePath: (0, import_node_path14.join)(serviceDir, SERVICE_NAME)
|
|
25163
25419
|
};
|
|
25164
25420
|
}
|
|
25165
|
-
function resolveLaunchdAutostartPaths(home = (0,
|
|
25166
|
-
const agentDir = (0,
|
|
25421
|
+
function resolveLaunchdAutostartPaths(home = (0, import_node_os5.homedir)()) {
|
|
25422
|
+
const agentDir = (0, import_node_path14.join)(home, "Library", "LaunchAgents");
|
|
25167
25423
|
return {
|
|
25168
25424
|
agentDir,
|
|
25169
|
-
plistPath: (0,
|
|
25425
|
+
plistPath: (0, import_node_path14.join)(agentDir, LAUNCHD_PLIST_NAME)
|
|
25170
25426
|
};
|
|
25171
25427
|
}
|
|
25172
25428
|
function quoteSystemdArg(value) {
|
|
@@ -25180,7 +25436,7 @@ function resolveCliPath() {
|
|
|
25180
25436
|
if (!entry) {
|
|
25181
25437
|
throw new Error("Unable to resolve current okx-a2a CLI path");
|
|
25182
25438
|
}
|
|
25183
|
-
return (0,
|
|
25439
|
+
return (0, import_node_path14.resolve)(entry);
|
|
25184
25440
|
}
|
|
25185
25441
|
function buildSystemdUserService() {
|
|
25186
25442
|
const taskHome2 = resolveTaskHome();
|
|
@@ -25322,7 +25578,7 @@ async function stopSystemdAutostart() {
|
|
|
25322
25578
|
}
|
|
25323
25579
|
async function restartSystemdAutostart() {
|
|
25324
25580
|
const paths = resolveSystemdAutostartPaths();
|
|
25325
|
-
if (!(0,
|
|
25581
|
+
if (!(0, import_node_fs11.existsSync)(paths.servicePath)) {
|
|
25326
25582
|
return {
|
|
25327
25583
|
platform: "linux-systemd",
|
|
25328
25584
|
path: paths.servicePath,
|
|
@@ -25384,7 +25640,7 @@ async function stopLaunchdAutostart() {
|
|
|
25384
25640
|
}
|
|
25385
25641
|
async function restartLaunchdAutostart() {
|
|
25386
25642
|
const paths = resolveLaunchdAutostartPaths();
|
|
25387
|
-
if (!(0,
|
|
25643
|
+
if (!(0, import_node_fs11.existsSync)(paths.plistPath)) {
|
|
25388
25644
|
return {
|
|
25389
25645
|
platform: "macos-launchd",
|
|
25390
25646
|
path: paths.plistPath,
|
|
@@ -25452,10 +25708,10 @@ async function restartAutostart() {
|
|
|
25452
25708
|
}
|
|
25453
25709
|
function isAutostartInstalled() {
|
|
25454
25710
|
if (process.platform === "linux") {
|
|
25455
|
-
return (0,
|
|
25711
|
+
return (0, import_node_fs11.existsSync)(resolveSystemdAutostartPaths().servicePath);
|
|
25456
25712
|
}
|
|
25457
25713
|
if (process.platform === "darwin") {
|
|
25458
|
-
return (0,
|
|
25714
|
+
return (0, import_node_fs11.existsSync)(resolveLaunchdAutostartPaths().plistPath);
|
|
25459
25715
|
}
|
|
25460
25716
|
return false;
|
|
25461
25717
|
}
|
|
@@ -25468,15 +25724,15 @@ function autostartStatus() {
|
|
|
25468
25724
|
}
|
|
25469
25725
|
throw new Error(`autostart is not supported on ${process.platform}`);
|
|
25470
25726
|
}
|
|
25471
|
-
var import_node_child_process3,
|
|
25727
|
+
var import_node_child_process3, import_node_fs11, import_promises5, import_node_os5, import_node_path14, import_node_util, execFileAsync, SERVICE_NAME, LAUNCHD_LABEL, LAUNCHD_PLIST_NAME;
|
|
25472
25728
|
var init_autostart = __esm({
|
|
25473
25729
|
"src/autostart.ts"() {
|
|
25474
25730
|
"use strict";
|
|
25475
25731
|
import_node_child_process3 = require("node:child_process");
|
|
25476
|
-
|
|
25732
|
+
import_node_fs11 = require("node:fs");
|
|
25477
25733
|
import_promises5 = require("node:fs/promises");
|
|
25478
|
-
|
|
25479
|
-
|
|
25734
|
+
import_node_os5 = require("node:os");
|
|
25735
|
+
import_node_path14 = require("node:path");
|
|
25480
25736
|
import_node_util = require("node:util");
|
|
25481
25737
|
init_paths();
|
|
25482
25738
|
execFileAsync = (0, import_node_util.promisify)(import_node_child_process3.execFile);
|
|
@@ -25487,7 +25743,7 @@ var init_autostart = __esm({
|
|
|
25487
25743
|
});
|
|
25488
25744
|
|
|
25489
25745
|
// ../core/src/xmtp-sdk/onchainos/bin.ts
|
|
25490
|
-
async function
|
|
25746
|
+
async function resolve4() {
|
|
25491
25747
|
if (resolvedBin) {
|
|
25492
25748
|
return resolvedBin;
|
|
25493
25749
|
}
|
|
@@ -25529,7 +25785,7 @@ function extractExecutablePath(stdout) {
|
|
|
25529
25785
|
}
|
|
25530
25786
|
function isExecutable2(path) {
|
|
25531
25787
|
try {
|
|
25532
|
-
(0,
|
|
25788
|
+
(0, import_node_fs12.accessSync)(path, import_node_fs12.constants.X_OK);
|
|
25533
25789
|
return true;
|
|
25534
25790
|
} catch {
|
|
25535
25791
|
return false;
|
|
@@ -25560,7 +25816,7 @@ function commandForLog(bin, args) {
|
|
|
25560
25816
|
return `${bin} ${redactArgsForLog(args).join(" ")}`;
|
|
25561
25817
|
}
|
|
25562
25818
|
async function exec(args) {
|
|
25563
|
-
const bin = await
|
|
25819
|
+
const bin = await resolve4();
|
|
25564
25820
|
const cmd = commandForLog(bin, args);
|
|
25565
25821
|
logWithTimestamp(`[onchainos] exec: ${cmd}`);
|
|
25566
25822
|
const t0 = Date.now();
|
|
@@ -25598,12 +25854,12 @@ async function exec(args) {
|
|
|
25598
25854
|
throw err2;
|
|
25599
25855
|
}
|
|
25600
25856
|
}
|
|
25601
|
-
var
|
|
25857
|
+
var import_node_fs12, import_node_child_process4, import_node_util2, execFileAsync2, resolvedBin, REDACTED_VALUE_FLAGS;
|
|
25602
25858
|
var init_bin = __esm({
|
|
25603
25859
|
"../core/src/xmtp-sdk/onchainos/bin.ts"() {
|
|
25604
25860
|
"use strict";
|
|
25605
25861
|
init_log();
|
|
25606
|
-
|
|
25862
|
+
import_node_fs12 = require("node:fs");
|
|
25607
25863
|
import_node_child_process4 = require("node:child_process");
|
|
25608
25864
|
import_node_util2 = require("node:util");
|
|
25609
25865
|
init_sentry_logger();
|
|
@@ -29140,8 +29396,8 @@ var require_util2 = __commonJS({
|
|
|
29140
29396
|
function createDeferredPromise() {
|
|
29141
29397
|
let res;
|
|
29142
29398
|
let rej;
|
|
29143
|
-
const promise = new Promise((
|
|
29144
|
-
res =
|
|
29399
|
+
const promise = new Promise((resolve9, reject) => {
|
|
29400
|
+
res = resolve9;
|
|
29145
29401
|
rej = reject;
|
|
29146
29402
|
});
|
|
29147
29403
|
return { promise, resolve: res, reject: rej };
|
|
@@ -30645,8 +30901,8 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
|
|
30645
30901
|
});
|
|
30646
30902
|
}
|
|
30647
30903
|
});
|
|
30648
|
-
const busboyResolve = new Promise((
|
|
30649
|
-
busboy.on("finish",
|
|
30904
|
+
const busboyResolve = new Promise((resolve9, reject) => {
|
|
30905
|
+
busboy.on("finish", resolve9);
|
|
30650
30906
|
busboy.on("error", (err2) => reject(new TypeError(err2)));
|
|
30651
30907
|
});
|
|
30652
30908
|
if (this.body !== null) for await (const chunk of consumeBody(this[kState].body)) busboy.write(chunk);
|
|
@@ -31180,9 +31436,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
31180
31436
|
}
|
|
31181
31437
|
close(callback) {
|
|
31182
31438
|
if (callback === void 0) {
|
|
31183
|
-
return new Promise((
|
|
31439
|
+
return new Promise((resolve9, reject) => {
|
|
31184
31440
|
this.close((err2, data) => {
|
|
31185
|
-
return err2 ? reject(err2) :
|
|
31441
|
+
return err2 ? reject(err2) : resolve9(data);
|
|
31186
31442
|
});
|
|
31187
31443
|
});
|
|
31188
31444
|
}
|
|
@@ -31220,12 +31476,12 @@ var require_dispatcher_base = __commonJS({
|
|
|
31220
31476
|
err2 = null;
|
|
31221
31477
|
}
|
|
31222
31478
|
if (callback === void 0) {
|
|
31223
|
-
return new Promise((
|
|
31479
|
+
return new Promise((resolve9, reject) => {
|
|
31224
31480
|
this.destroy(err2, (err3, data) => {
|
|
31225
31481
|
return err3 ? (
|
|
31226
31482
|
/* istanbul ignore next: should never error */
|
|
31227
31483
|
reject(err3)
|
|
31228
|
-
) :
|
|
31484
|
+
) : resolve9(data);
|
|
31229
31485
|
});
|
|
31230
31486
|
});
|
|
31231
31487
|
}
|
|
@@ -32285,16 +32541,16 @@ var require_client2 = __commonJS({
|
|
|
32285
32541
|
return this[kNeedDrain] < 2;
|
|
32286
32542
|
}
|
|
32287
32543
|
async [kClose]() {
|
|
32288
|
-
return new Promise((
|
|
32544
|
+
return new Promise((resolve9) => {
|
|
32289
32545
|
if (!this[kSize]) {
|
|
32290
|
-
|
|
32546
|
+
resolve9(null);
|
|
32291
32547
|
} else {
|
|
32292
|
-
this[kClosedResolve] =
|
|
32548
|
+
this[kClosedResolve] = resolve9;
|
|
32293
32549
|
}
|
|
32294
32550
|
});
|
|
32295
32551
|
}
|
|
32296
32552
|
async [kDestroy](err2) {
|
|
32297
|
-
return new Promise((
|
|
32553
|
+
return new Promise((resolve9) => {
|
|
32298
32554
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
32299
32555
|
for (let i = 0; i < requests.length; i++) {
|
|
32300
32556
|
const request = requests[i];
|
|
@@ -32305,7 +32561,7 @@ var require_client2 = __commonJS({
|
|
|
32305
32561
|
this[kClosedResolve]();
|
|
32306
32562
|
this[kClosedResolve] = null;
|
|
32307
32563
|
}
|
|
32308
|
-
|
|
32564
|
+
resolve9();
|
|
32309
32565
|
};
|
|
32310
32566
|
if (this[kHTTP2Session] != null) {
|
|
32311
32567
|
util.destroy(this[kHTTP2Session], err2);
|
|
@@ -32885,7 +33141,7 @@ var require_client2 = __commonJS({
|
|
|
32885
33141
|
});
|
|
32886
33142
|
}
|
|
32887
33143
|
try {
|
|
32888
|
-
const socket = await new Promise((
|
|
33144
|
+
const socket = await new Promise((resolve9, reject) => {
|
|
32889
33145
|
client[kConnector]({
|
|
32890
33146
|
host,
|
|
32891
33147
|
hostname,
|
|
@@ -32897,7 +33153,7 @@ var require_client2 = __commonJS({
|
|
|
32897
33153
|
if (err2) {
|
|
32898
33154
|
reject(err2);
|
|
32899
33155
|
} else {
|
|
32900
|
-
|
|
33156
|
+
resolve9(socket2);
|
|
32901
33157
|
}
|
|
32902
33158
|
});
|
|
32903
33159
|
});
|
|
@@ -33521,12 +33777,12 @@ upgrade: ${upgrade}\r
|
|
|
33521
33777
|
cb();
|
|
33522
33778
|
}
|
|
33523
33779
|
}
|
|
33524
|
-
const waitForDrain = () => new Promise((
|
|
33780
|
+
const waitForDrain = () => new Promise((resolve9, reject) => {
|
|
33525
33781
|
assert(callback === null);
|
|
33526
33782
|
if (socket[kError]) {
|
|
33527
33783
|
reject(socket[kError]);
|
|
33528
33784
|
} else {
|
|
33529
|
-
callback =
|
|
33785
|
+
callback = resolve9;
|
|
33530
33786
|
}
|
|
33531
33787
|
});
|
|
33532
33788
|
if (client[kHTTPConnVersion] === "h2") {
|
|
@@ -33871,8 +34127,8 @@ var require_pool_base = __commonJS({
|
|
|
33871
34127
|
if (this[kQueue].isEmpty()) {
|
|
33872
34128
|
return Promise.all(this[kClients].map((c) => c.close()));
|
|
33873
34129
|
} else {
|
|
33874
|
-
return new Promise((
|
|
33875
|
-
this[kClosedResolve] =
|
|
34130
|
+
return new Promise((resolve9) => {
|
|
34131
|
+
this[kClosedResolve] = resolve9;
|
|
33876
34132
|
});
|
|
33877
34133
|
}
|
|
33878
34134
|
}
|
|
@@ -34450,7 +34706,7 @@ var require_readable = __commonJS({
|
|
|
34450
34706
|
if (this.closed) {
|
|
34451
34707
|
return Promise.resolve(null);
|
|
34452
34708
|
}
|
|
34453
|
-
return new Promise((
|
|
34709
|
+
return new Promise((resolve9, reject) => {
|
|
34454
34710
|
const signalListenerCleanup = signal ? util.addAbortListener(signal, () => {
|
|
34455
34711
|
this.destroy();
|
|
34456
34712
|
}) : noop;
|
|
@@ -34459,7 +34715,7 @@ var require_readable = __commonJS({
|
|
|
34459
34715
|
if (signal && signal.aborted) {
|
|
34460
34716
|
reject(signal.reason || Object.assign(new Error("The operation was aborted"), { name: "AbortError" }));
|
|
34461
34717
|
} else {
|
|
34462
|
-
|
|
34718
|
+
resolve9(null);
|
|
34463
34719
|
}
|
|
34464
34720
|
}).on("error", noop).on("data", function(chunk) {
|
|
34465
34721
|
limit -= chunk.length;
|
|
@@ -34481,11 +34737,11 @@ var require_readable = __commonJS({
|
|
|
34481
34737
|
throw new TypeError("unusable");
|
|
34482
34738
|
}
|
|
34483
34739
|
assert(!stream[kConsume]);
|
|
34484
|
-
return new Promise((
|
|
34740
|
+
return new Promise((resolve9, reject) => {
|
|
34485
34741
|
stream[kConsume] = {
|
|
34486
34742
|
type,
|
|
34487
34743
|
stream,
|
|
34488
|
-
resolve:
|
|
34744
|
+
resolve: resolve9,
|
|
34489
34745
|
reject,
|
|
34490
34746
|
length: 0,
|
|
34491
34747
|
body: []
|
|
@@ -34520,12 +34776,12 @@ var require_readable = __commonJS({
|
|
|
34520
34776
|
}
|
|
34521
34777
|
}
|
|
34522
34778
|
function consumeEnd(consume2) {
|
|
34523
|
-
const { type, body, resolve:
|
|
34779
|
+
const { type, body, resolve: resolve9, stream, length: length2 } = consume2;
|
|
34524
34780
|
try {
|
|
34525
34781
|
if (type === "text") {
|
|
34526
|
-
|
|
34782
|
+
resolve9(toUSVString(Buffer.concat(body)));
|
|
34527
34783
|
} else if (type === "json") {
|
|
34528
|
-
|
|
34784
|
+
resolve9(JSON.parse(Buffer.concat(body)));
|
|
34529
34785
|
} else if (type === "arrayBuffer") {
|
|
34530
34786
|
const dst = new Uint8Array(length2);
|
|
34531
34787
|
let pos = 0;
|
|
@@ -34533,12 +34789,12 @@ var require_readable = __commonJS({
|
|
|
34533
34789
|
dst.set(buf, pos);
|
|
34534
34790
|
pos += buf.byteLength;
|
|
34535
34791
|
}
|
|
34536
|
-
|
|
34792
|
+
resolve9(dst.buffer);
|
|
34537
34793
|
} else if (type === "blob") {
|
|
34538
34794
|
if (!Blob2) {
|
|
34539
34795
|
Blob2 = require("buffer").Blob;
|
|
34540
34796
|
}
|
|
34541
|
-
|
|
34797
|
+
resolve9(new Blob2(body, { type: stream[kContentType] }));
|
|
34542
34798
|
}
|
|
34543
34799
|
consumeFinish(consume2);
|
|
34544
34800
|
} catch (err2) {
|
|
@@ -34793,9 +35049,9 @@ var require_api_request = __commonJS({
|
|
|
34793
35049
|
};
|
|
34794
35050
|
function request(opts, callback) {
|
|
34795
35051
|
if (callback === void 0) {
|
|
34796
|
-
return new Promise((
|
|
35052
|
+
return new Promise((resolve9, reject) => {
|
|
34797
35053
|
request.call(this, opts, (err2, data) => {
|
|
34798
|
-
return err2 ? reject(err2) :
|
|
35054
|
+
return err2 ? reject(err2) : resolve9(data);
|
|
34799
35055
|
});
|
|
34800
35056
|
});
|
|
34801
35057
|
}
|
|
@@ -34968,9 +35224,9 @@ var require_api_stream = __commonJS({
|
|
|
34968
35224
|
};
|
|
34969
35225
|
function stream(opts, factory, callback) {
|
|
34970
35226
|
if (callback === void 0) {
|
|
34971
|
-
return new Promise((
|
|
35227
|
+
return new Promise((resolve9, reject) => {
|
|
34972
35228
|
stream.call(this, opts, factory, (err2, data) => {
|
|
34973
|
-
return err2 ? reject(err2) :
|
|
35229
|
+
return err2 ? reject(err2) : resolve9(data);
|
|
34974
35230
|
});
|
|
34975
35231
|
});
|
|
34976
35232
|
}
|
|
@@ -35251,9 +35507,9 @@ var require_api_upgrade = __commonJS({
|
|
|
35251
35507
|
};
|
|
35252
35508
|
function upgrade(opts, callback) {
|
|
35253
35509
|
if (callback === void 0) {
|
|
35254
|
-
return new Promise((
|
|
35510
|
+
return new Promise((resolve9, reject) => {
|
|
35255
35511
|
upgrade.call(this, opts, (err2, data) => {
|
|
35256
|
-
return err2 ? reject(err2) :
|
|
35512
|
+
return err2 ? reject(err2) : resolve9(data);
|
|
35257
35513
|
});
|
|
35258
35514
|
});
|
|
35259
35515
|
}
|
|
@@ -35342,9 +35598,9 @@ var require_api_connect = __commonJS({
|
|
|
35342
35598
|
};
|
|
35343
35599
|
function connect(opts, callback) {
|
|
35344
35600
|
if (callback === void 0) {
|
|
35345
|
-
return new Promise((
|
|
35601
|
+
return new Promise((resolve9, reject) => {
|
|
35346
35602
|
connect.call(this, opts, (err2, data) => {
|
|
35347
|
-
return err2 ? reject(err2) :
|
|
35603
|
+
return err2 ? reject(err2) : resolve9(data);
|
|
35348
35604
|
});
|
|
35349
35605
|
});
|
|
35350
35606
|
}
|
|
@@ -38966,7 +39222,7 @@ var require_fetch = __commonJS({
|
|
|
38966
39222
|
async function dispatch({ body }) {
|
|
38967
39223
|
const url = requestCurrentURL(request);
|
|
38968
39224
|
const agent = fetchParams.controller.dispatcher;
|
|
38969
|
-
return new Promise((
|
|
39225
|
+
return new Promise((resolve9, reject) => agent.dispatch(
|
|
38970
39226
|
{
|
|
38971
39227
|
path: url.pathname + url.search,
|
|
38972
39228
|
origin: url.origin,
|
|
@@ -39042,7 +39298,7 @@ var require_fetch = __commonJS({
|
|
|
39042
39298
|
}
|
|
39043
39299
|
}
|
|
39044
39300
|
}
|
|
39045
|
-
|
|
39301
|
+
resolve9({
|
|
39046
39302
|
status,
|
|
39047
39303
|
statusText,
|
|
39048
39304
|
headersList: headers[kHeadersList],
|
|
@@ -39085,7 +39341,7 @@ var require_fetch = __commonJS({
|
|
|
39085
39341
|
const val = headersList[n + 1].toString("latin1");
|
|
39086
39342
|
headers[kHeadersList].append(key, val);
|
|
39087
39343
|
}
|
|
39088
|
-
|
|
39344
|
+
resolve9({
|
|
39089
39345
|
status,
|
|
39090
39346
|
statusText: STATUS_CODES[status],
|
|
39091
39347
|
headersList: headers[kHeadersList],
|
|
@@ -42412,11 +42668,11 @@ var require_fetch_pb = __commonJS({
|
|
|
42412
42668
|
"use strict";
|
|
42413
42669
|
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
42414
42670
|
function adopt(value) {
|
|
42415
|
-
return value instanceof P2 ? value : new P2(function(
|
|
42416
|
-
|
|
42671
|
+
return value instanceof P2 ? value : new P2(function(resolve9) {
|
|
42672
|
+
resolve9(value);
|
|
42417
42673
|
});
|
|
42418
42674
|
}
|
|
42419
|
-
return new (P2 || (P2 = Promise))(function(
|
|
42675
|
+
return new (P2 || (P2 = Promise))(function(resolve9, reject) {
|
|
42420
42676
|
function fulfilled(value) {
|
|
42421
42677
|
try {
|
|
42422
42678
|
step(generator.next(value));
|
|
@@ -42432,7 +42688,7 @@ var require_fetch_pb = __commonJS({
|
|
|
42432
42688
|
}
|
|
42433
42689
|
}
|
|
42434
42690
|
function step(result) {
|
|
42435
|
-
result.done ?
|
|
42691
|
+
result.done ? resolve9(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
42436
42692
|
}
|
|
42437
42693
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42438
42694
|
});
|
|
@@ -43702,7 +43958,7 @@ var require_aspromise = __commonJS({
|
|
|
43702
43958
|
var params = new Array(arguments.length - 1), offset = 0, index2 = 2, pending = true;
|
|
43703
43959
|
while (index2 < arguments.length)
|
|
43704
43960
|
params[offset++] = arguments[index2++];
|
|
43705
|
-
return new Promise(function executor(
|
|
43961
|
+
return new Promise(function executor(resolve9, reject) {
|
|
43706
43962
|
params[offset] = function callback(err2) {
|
|
43707
43963
|
if (pending) {
|
|
43708
43964
|
pending = false;
|
|
@@ -43712,7 +43968,7 @@ var require_aspromise = __commonJS({
|
|
|
43712
43968
|
var params2 = new Array(arguments.length - 1), offset2 = 0;
|
|
43713
43969
|
while (offset2 < params2.length)
|
|
43714
43970
|
params2[offset2++] = arguments[offset2];
|
|
43715
|
-
|
|
43971
|
+
resolve9.apply(null, params2);
|
|
43716
43972
|
}
|
|
43717
43973
|
}
|
|
43718
43974
|
};
|
|
@@ -43918,8 +44174,8 @@ var require_float = __commonJS({
|
|
|
43918
44174
|
})();
|
|
43919
44175
|
else (function() {
|
|
43920
44176
|
function writeFloat_ieee754(writeUint, val, buf, pos) {
|
|
43921
|
-
var
|
|
43922
|
-
if (
|
|
44177
|
+
var sign3 = val < 0 ? 1 : 0;
|
|
44178
|
+
if (sign3)
|
|
43923
44179
|
val = -val;
|
|
43924
44180
|
if (val === 0)
|
|
43925
44181
|
writeUint(1 / val > 0 ? (
|
|
@@ -43932,19 +44188,19 @@ var require_float = __commonJS({
|
|
|
43932
44188
|
else if (isNaN(val))
|
|
43933
44189
|
writeUint(2143289344, buf, pos);
|
|
43934
44190
|
else if (val > 34028234663852886e22)
|
|
43935
|
-
writeUint((
|
|
44191
|
+
writeUint((sign3 << 31 | 2139095040) >>> 0, buf, pos);
|
|
43936
44192
|
else if (val < 11754943508222875e-54)
|
|
43937
|
-
writeUint((
|
|
44193
|
+
writeUint((sign3 << 31 | Math.round(val / 1401298464324817e-60)) >>> 0, buf, pos);
|
|
43938
44194
|
else {
|
|
43939
44195
|
var exponent = Math.floor(Math.log(val) / Math.LN2), mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
|
|
43940
|
-
writeUint((
|
|
44196
|
+
writeUint((sign3 << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
|
|
43941
44197
|
}
|
|
43942
44198
|
}
|
|
43943
44199
|
exports3.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
|
|
43944
44200
|
exports3.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
|
|
43945
44201
|
function readFloat_ieee754(readUint, buf, pos) {
|
|
43946
|
-
var uint = readUint(buf, pos),
|
|
43947
|
-
return exponent === 255 ? mantissa ? NaN :
|
|
44202
|
+
var uint = readUint(buf, pos), sign3 = (uint >> 31) * 2 + 1, exponent = uint >>> 23 & 255, mantissa = uint & 8388607;
|
|
44203
|
+
return exponent === 255 ? mantissa ? NaN : sign3 * Infinity : exponent === 0 ? sign3 * 1401298464324817e-60 * mantissa : sign3 * Math.pow(2, exponent - 150) * (mantissa + 8388608);
|
|
43948
44204
|
}
|
|
43949
44205
|
exports3.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
|
|
43950
44206
|
exports3.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
|
|
@@ -44002,8 +44258,8 @@ var require_float = __commonJS({
|
|
|
44002
44258
|
})();
|
|
44003
44259
|
else (function() {
|
|
44004
44260
|
function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
|
|
44005
|
-
var
|
|
44006
|
-
if (
|
|
44261
|
+
var sign3 = val < 0 ? 1 : 0;
|
|
44262
|
+
if (sign3)
|
|
44007
44263
|
val = -val;
|
|
44008
44264
|
if (val === 0) {
|
|
44009
44265
|
writeUint(0, buf, pos + off0);
|
|
@@ -44019,20 +44275,20 @@ var require_float = __commonJS({
|
|
|
44019
44275
|
writeUint(2146959360, buf, pos + off1);
|
|
44020
44276
|
} else if (val > 17976931348623157e292) {
|
|
44021
44277
|
writeUint(0, buf, pos + off0);
|
|
44022
|
-
writeUint((
|
|
44278
|
+
writeUint((sign3 << 31 | 2146435072) >>> 0, buf, pos + off1);
|
|
44023
44279
|
} else {
|
|
44024
44280
|
var mantissa;
|
|
44025
44281
|
if (val < 22250738585072014e-324) {
|
|
44026
44282
|
mantissa = val / 5e-324;
|
|
44027
44283
|
writeUint(mantissa >>> 0, buf, pos + off0);
|
|
44028
|
-
writeUint((
|
|
44284
|
+
writeUint((sign3 << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
|
|
44029
44285
|
} else {
|
|
44030
44286
|
var exponent = Math.floor(Math.log(val) / Math.LN2);
|
|
44031
44287
|
if (exponent === 1024)
|
|
44032
44288
|
exponent = 1023;
|
|
44033
44289
|
mantissa = val * Math.pow(2, -exponent);
|
|
44034
44290
|
writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
|
|
44035
|
-
writeUint((
|
|
44291
|
+
writeUint((sign3 << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
|
|
44036
44292
|
}
|
|
44037
44293
|
}
|
|
44038
44294
|
}
|
|
@@ -44040,8 +44296,8 @@ var require_float = __commonJS({
|
|
|
44040
44296
|
exports3.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
|
|
44041
44297
|
function readDouble_ieee754(readUint, off0, off1, buf, pos) {
|
|
44042
44298
|
var lo = readUint(buf, pos + off0), hi = readUint(buf, pos + off1);
|
|
44043
|
-
var
|
|
44044
|
-
return exponent === 2047 ? mantissa ? NaN :
|
|
44299
|
+
var sign3 = (hi >> 31) * 2 + 1, exponent = hi >>> 20 & 2047, mantissa = 4294967296 * (hi & 1048575) + lo;
|
|
44300
|
+
return exponent === 2047 ? mantissa ? NaN : sign3 * Infinity : exponent === 0 ? sign3 * 5e-324 * mantissa : sign3 * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
|
|
44045
44301
|
}
|
|
44046
44302
|
exports3.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
|
|
44047
44303
|
exports3.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
|
|
@@ -44213,11 +44469,11 @@ var require_longbits = __commonJS({
|
|
|
44213
44469
|
LongBits.fromNumber = function fromNumber(value) {
|
|
44214
44470
|
if (value === 0)
|
|
44215
44471
|
return zero;
|
|
44216
|
-
var
|
|
44217
|
-
if (
|
|
44472
|
+
var sign3 = value < 0;
|
|
44473
|
+
if (sign3)
|
|
44218
44474
|
value = -value;
|
|
44219
44475
|
var lo = value >>> 0, hi = (value - lo) / 4294967296 >>> 0;
|
|
44220
|
-
if (
|
|
44476
|
+
if (sign3) {
|
|
44221
44477
|
hi = ~hi >>> 0;
|
|
44222
44478
|
lo = ~lo >>> 0;
|
|
44223
44479
|
if (++lo > 4294967295) {
|
|
@@ -53168,7 +53424,7 @@ var require_Observable = __commonJS({
|
|
|
53168
53424
|
Observable2.prototype.forEach = function(next, promiseCtor) {
|
|
53169
53425
|
var _this = this;
|
|
53170
53426
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
53171
|
-
return new promiseCtor(function(
|
|
53427
|
+
return new promiseCtor(function(resolve9, reject) {
|
|
53172
53428
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
53173
53429
|
next: function(value) {
|
|
53174
53430
|
try {
|
|
@@ -53179,7 +53435,7 @@ var require_Observable = __commonJS({
|
|
|
53179
53435
|
}
|
|
53180
53436
|
},
|
|
53181
53437
|
error: reject,
|
|
53182
|
-
complete:
|
|
53438
|
+
complete: resolve9
|
|
53183
53439
|
});
|
|
53184
53440
|
_this.subscribe(subscriber);
|
|
53185
53441
|
});
|
|
@@ -53201,14 +53457,14 @@ var require_Observable = __commonJS({
|
|
|
53201
53457
|
Observable2.prototype.toPromise = function(promiseCtor) {
|
|
53202
53458
|
var _this = this;
|
|
53203
53459
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
53204
|
-
return new promiseCtor(function(
|
|
53460
|
+
return new promiseCtor(function(resolve9, reject) {
|
|
53205
53461
|
var value;
|
|
53206
53462
|
_this.subscribe(function(x) {
|
|
53207
53463
|
return value = x;
|
|
53208
53464
|
}, function(err2) {
|
|
53209
53465
|
return reject(err2);
|
|
53210
53466
|
}, function() {
|
|
53211
|
-
return
|
|
53467
|
+
return resolve9(value);
|
|
53212
53468
|
});
|
|
53213
53469
|
});
|
|
53214
53470
|
};
|
|
@@ -53469,11 +53725,11 @@ var require_innerFrom = __commonJS({
|
|
|
53469
53725
|
"use strict";
|
|
53470
53726
|
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
53471
53727
|
function adopt(value) {
|
|
53472
|
-
return value instanceof P2 ? value : new P2(function(
|
|
53473
|
-
|
|
53728
|
+
return value instanceof P2 ? value : new P2(function(resolve9) {
|
|
53729
|
+
resolve9(value);
|
|
53474
53730
|
});
|
|
53475
53731
|
}
|
|
53476
|
-
return new (P2 || (P2 = Promise))(function(
|
|
53732
|
+
return new (P2 || (P2 = Promise))(function(resolve9, reject) {
|
|
53477
53733
|
function fulfilled(value) {
|
|
53478
53734
|
try {
|
|
53479
53735
|
step(generator.next(value));
|
|
@@ -53489,7 +53745,7 @@ var require_innerFrom = __commonJS({
|
|
|
53489
53745
|
}
|
|
53490
53746
|
}
|
|
53491
53747
|
function step(result) {
|
|
53492
|
-
result.done ?
|
|
53748
|
+
result.done ? resolve9(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
53493
53749
|
}
|
|
53494
53750
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
53495
53751
|
});
|
|
@@ -53571,14 +53827,14 @@ var require_innerFrom = __commonJS({
|
|
|
53571
53827
|
}, i);
|
|
53572
53828
|
function verb(n) {
|
|
53573
53829
|
i[n] = o[n] && function(v) {
|
|
53574
|
-
return new Promise(function(
|
|
53575
|
-
v = o[n](v), settle(
|
|
53830
|
+
return new Promise(function(resolve9, reject) {
|
|
53831
|
+
v = o[n](v), settle(resolve9, reject, v.done, v.value);
|
|
53576
53832
|
});
|
|
53577
53833
|
};
|
|
53578
53834
|
}
|
|
53579
|
-
function settle(
|
|
53835
|
+
function settle(resolve9, reject, d, v) {
|
|
53580
53836
|
Promise.resolve(v).then(function(v2) {
|
|
53581
|
-
|
|
53837
|
+
resolve9({ value: v2, done: d });
|
|
53582
53838
|
}, reject);
|
|
53583
53839
|
}
|
|
53584
53840
|
};
|
|
@@ -68311,7 +68567,7 @@ function createAsyncStreamProxy(stream) {
|
|
|
68311
68567
|
function isHexString(value) {
|
|
68312
68568
|
return typeof value === "string" && /^0x(?:[0-9a-fA-F]{2})+$/.test(value);
|
|
68313
68569
|
}
|
|
68314
|
-
var import_node_bindings, import_node_bindings2, import_types,
|
|
68570
|
+
var import_node_bindings, import_node_bindings2, import_types, import_node_path15, import_node_process, ApiUrls, HistorySyncUrls, DecodedMessage, CodecNotFoundError, InboxReassignError, AccountAlreadyAssociatedError, InvalidGroupMembershipChangeError, MissingContentTypeError, SignerUnavailableError, ClientNotInitializedError, StreamFailedError, StreamInvalidRetryAttemptsError, AsyncStream, usableProperties, isUsableProperty, wait, DEFAULT_RETRY_DELAY, DEFAULT_RETRY_ATTEMPTS, createStream, Conversation, Dm, Group, Conversations, DebugInformation, Preferences, generateInboxId, getInboxIdForIdentifier, createClient, Client;
|
|
68315
68571
|
var init_dist4 = __esm({
|
|
68316
68572
|
"../../node_modules/@xmtp/node-sdk/dist/index.js"() {
|
|
68317
68573
|
init_dist2();
|
|
@@ -68320,7 +68576,7 @@ var init_dist4 = __esm({
|
|
|
68320
68576
|
import_node_bindings2 = require("@xmtp/node-bindings");
|
|
68321
68577
|
init_dist();
|
|
68322
68578
|
import_types = require("node:util/types");
|
|
68323
|
-
|
|
68579
|
+
import_node_path15 = require("node:path");
|
|
68324
68580
|
import_node_process = __toESM(require("node:process"), 1);
|
|
68325
68581
|
ApiUrls = {
|
|
68326
68582
|
local: "http://localhost:5556",
|
|
@@ -68481,8 +68737,8 @@ var init_dist4 = __esm({
|
|
|
68481
68737
|
value: this.#queue.shift()
|
|
68482
68738
|
});
|
|
68483
68739
|
}
|
|
68484
|
-
return new Promise((
|
|
68485
|
-
this.#pendingResolves.push(
|
|
68740
|
+
return new Promise((resolve9) => {
|
|
68741
|
+
this.#pendingResolves.push(resolve9);
|
|
68486
68742
|
});
|
|
68487
68743
|
};
|
|
68488
68744
|
return = () => {
|
|
@@ -68508,7 +68764,7 @@ var init_dist4 = __esm({
|
|
|
68508
68764
|
isUsableProperty = (prop) => {
|
|
68509
68765
|
return usableProperties.includes(prop);
|
|
68510
68766
|
};
|
|
68511
|
-
wait = (ms) => new Promise((
|
|
68767
|
+
wait = (ms) => new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
68512
68768
|
DEFAULT_RETRY_DELAY = 6e4;
|
|
68513
68769
|
DEFAULT_RETRY_ATTEMPTS = 10;
|
|
68514
68770
|
createStream = async (streamFunction, streamValueMutator, options) => {
|
|
@@ -69566,7 +69822,7 @@ var init_dist4 = __esm({
|
|
|
69566
69822
|
const inboxId = await getInboxIdForIdentifier(identifier, env, gatewayHost) || generateInboxId(identifier, options?.nonce);
|
|
69567
69823
|
let dbPath;
|
|
69568
69824
|
if (options?.dbPath === void 0) {
|
|
69569
|
-
dbPath = (0,
|
|
69825
|
+
dbPath = (0, import_node_path15.join)(import_node_process.default.cwd(), `xmtp-${env}-${inboxId}.db3`);
|
|
69570
69826
|
} else if (typeof options.dbPath === "function") {
|
|
69571
69827
|
dbPath = options.dbPath(inboxId);
|
|
69572
69828
|
} else {
|
|
@@ -75611,7 +75867,7 @@ function weierstrass(curveDef) {
|
|
|
75611
75867
|
}
|
|
75612
75868
|
const defaultSigOpts = { lowS: CURVE.lowS, prehash: false };
|
|
75613
75869
|
const defaultVerOpts = { lowS: CURVE.lowS, prehash: false };
|
|
75614
|
-
function
|
|
75870
|
+
function sign3(msgHash, privKey, opts = defaultSigOpts) {
|
|
75615
75871
|
const { seed, k2sig } = prepSig(msgHash, privKey, opts);
|
|
75616
75872
|
const C2 = CURVE;
|
|
75617
75873
|
const drbg = createHmacDrbg(C2.hash.outputLen, C2.nByteLength, C2.hmac);
|
|
@@ -75673,7 +75929,7 @@ function weierstrass(curveDef) {
|
|
|
75673
75929
|
CURVE,
|
|
75674
75930
|
getPublicKey,
|
|
75675
75931
|
getSharedSecret,
|
|
75676
|
-
sign:
|
|
75932
|
+
sign: sign3,
|
|
75677
75933
|
verify,
|
|
75678
75934
|
ProjectivePoint: Point3,
|
|
75679
75935
|
Signature,
|
|
@@ -78075,7 +78331,7 @@ var init_wait = __esm({
|
|
|
78075
78331
|
|
|
78076
78332
|
// ../../node_modules/viem/_esm/utils/promise/withRetry.js
|
|
78077
78333
|
function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry: shouldRetry2 = () => true } = {}) {
|
|
78078
|
-
return new Promise((
|
|
78334
|
+
return new Promise((resolve9, reject) => {
|
|
78079
78335
|
const attemptRetry = async ({ count = 0 } = {}) => {
|
|
78080
78336
|
const retry = async ({ error }) => {
|
|
78081
78337
|
const delay = typeof delay_ === "function" ? delay_({ count, error }) : delay_;
|
|
@@ -78085,7 +78341,7 @@ function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry: shoul
|
|
|
78085
78341
|
};
|
|
78086
78342
|
try {
|
|
78087
78343
|
const data = await fn();
|
|
78088
|
-
|
|
78344
|
+
resolve9(data);
|
|
78089
78345
|
} catch (err2) {
|
|
78090
78346
|
if (count < retryCount && await shouldRetry2({ count, error: err2 }))
|
|
78091
78347
|
return retry({ error: err2 });
|
|
@@ -78659,13 +78915,13 @@ var init_transactionRequest = __esm({
|
|
|
78659
78915
|
|
|
78660
78916
|
// ../../node_modules/viem/_esm/utils/promise/withResolvers.js
|
|
78661
78917
|
function withResolvers() {
|
|
78662
|
-
let
|
|
78918
|
+
let resolve9 = () => void 0;
|
|
78663
78919
|
let reject = () => void 0;
|
|
78664
78920
|
const promise = new Promise((resolve_, reject_) => {
|
|
78665
|
-
|
|
78921
|
+
resolve9 = resolve_;
|
|
78666
78922
|
reject = reject_;
|
|
78667
78923
|
});
|
|
78668
|
-
return { promise, resolve:
|
|
78924
|
+
return { promise, resolve: resolve9, reject };
|
|
78669
78925
|
}
|
|
78670
78926
|
var init_withResolvers = __esm({
|
|
78671
78927
|
"../../node_modules/viem/_esm/utils/promise/withResolvers.js"() {
|
|
@@ -78684,8 +78940,8 @@ function createBatchScheduler({ fn, id, shouldSplitBatch, wait: wait3 = 0, sort
|
|
|
78684
78940
|
if (sort && Array.isArray(data))
|
|
78685
78941
|
data.sort(sort);
|
|
78686
78942
|
for (let i = 0; i < scheduler.length; i++) {
|
|
78687
|
-
const { resolve:
|
|
78688
|
-
|
|
78943
|
+
const { resolve: resolve9 } = scheduler[i];
|
|
78944
|
+
resolve9?.([data[i], data]);
|
|
78689
78945
|
}
|
|
78690
78946
|
}).catch((err2) => {
|
|
78691
78947
|
for (let i = 0; i < scheduler.length; i++) {
|
|
@@ -78701,16 +78957,16 @@ function createBatchScheduler({ fn, id, shouldSplitBatch, wait: wait3 = 0, sort
|
|
|
78701
78957
|
return {
|
|
78702
78958
|
flush: flush2,
|
|
78703
78959
|
async schedule(args) {
|
|
78704
|
-
const { promise, resolve:
|
|
78960
|
+
const { promise, resolve: resolve9, reject } = withResolvers();
|
|
78705
78961
|
const split2 = shouldSplitBatch?.([...getBatchedArgs(), args]);
|
|
78706
78962
|
if (split2)
|
|
78707
78963
|
exec2();
|
|
78708
78964
|
const hasActiveScheduler = getScheduler().length > 0;
|
|
78709
78965
|
if (hasActiveScheduler) {
|
|
78710
|
-
setScheduler({ args, resolve:
|
|
78966
|
+
setScheduler({ args, resolve: resolve9, reject });
|
|
78711
78967
|
return promise;
|
|
78712
78968
|
}
|
|
78713
|
-
setScheduler({ args, resolve:
|
|
78969
|
+
setScheduler({ args, resolve: resolve9, reject });
|
|
78714
78970
|
setTimeout(exec2, wait3);
|
|
78715
78971
|
return promise;
|
|
78716
78972
|
}
|
|
@@ -79147,7 +79403,7 @@ var init_getTransactionCount = __esm({
|
|
|
79147
79403
|
|
|
79148
79404
|
// ../../node_modules/viem/_esm/utils/promise/withTimeout.js
|
|
79149
79405
|
function withTimeout(fn, { errorInstance = new Error("timed out"), timeout, signal }) {
|
|
79150
|
-
return new Promise((
|
|
79406
|
+
return new Promise((resolve9, reject) => {
|
|
79151
79407
|
;
|
|
79152
79408
|
(async () => {
|
|
79153
79409
|
let timeoutId;
|
|
@@ -79162,7 +79418,7 @@ function withTimeout(fn, { errorInstance = new Error("timed out"), timeout, sign
|
|
|
79162
79418
|
}
|
|
79163
79419
|
}, timeout);
|
|
79164
79420
|
}
|
|
79165
|
-
|
|
79421
|
+
resolve9(await fn({ signal: controller?.signal || null }));
|
|
79166
79422
|
} catch (err2) {
|
|
79167
79423
|
if (err2?.name === "AbortError")
|
|
79168
79424
|
reject(errorInstance);
|
|
@@ -82239,7 +82495,7 @@ async function sendCalls(client, parameters) {
|
|
|
82239
82495
|
});
|
|
82240
82496
|
promises.push(promise);
|
|
82241
82497
|
if (experimental_fallbackDelay > 0)
|
|
82242
|
-
await new Promise((
|
|
82498
|
+
await new Promise((resolve9) => setTimeout(resolve9, experimental_fallbackDelay));
|
|
82243
82499
|
}
|
|
82244
82500
|
const results = await Promise.allSettled(promises);
|
|
82245
82501
|
if (results.every((r) => r.status === "rejected"))
|
|
@@ -82370,9 +82626,9 @@ async function waitForCallsStatus(client, parameters) {
|
|
|
82370
82626
|
throwOnFailure = false
|
|
82371
82627
|
} = parameters;
|
|
82372
82628
|
const observerId = stringify(["waitForCallsStatus", client.uid, id]);
|
|
82373
|
-
const { promise, resolve:
|
|
82629
|
+
const { promise, resolve: resolve9, reject } = withResolvers();
|
|
82374
82630
|
let timer;
|
|
82375
|
-
const unobserve = observe(observerId, { resolve:
|
|
82631
|
+
const unobserve = observe(observerId, { resolve: resolve9, reject }, (emit) => {
|
|
82376
82632
|
const unpoll = poll(async () => {
|
|
82377
82633
|
const done = (fn) => {
|
|
82378
82634
|
clearTimeout(timer);
|
|
@@ -82710,13 +82966,13 @@ async function waitForTransactionReceipt(client, parameters) {
|
|
|
82710
82966
|
let retrying = false;
|
|
82711
82967
|
let _unobserve;
|
|
82712
82968
|
let _unwatch;
|
|
82713
|
-
const { promise, resolve:
|
|
82969
|
+
const { promise, resolve: resolve9, reject } = withResolvers();
|
|
82714
82970
|
const timer = timeout ? setTimeout(() => {
|
|
82715
82971
|
_unwatch?.();
|
|
82716
82972
|
_unobserve?.();
|
|
82717
82973
|
reject(new WaitForTransactionReceiptTimeoutError({ hash: hash2 }));
|
|
82718
82974
|
}, timeout) : void 0;
|
|
82719
|
-
_unobserve = observe(observerId, { onReplaced, resolve:
|
|
82975
|
+
_unobserve = observe(observerId, { onReplaced, resolve: resolve9, reject }, async (emit) => {
|
|
82720
82976
|
receipt = await getAction(client, getTransactionReceipt, "getTransactionReceipt")({ hash: hash2 }).catch(() => void 0);
|
|
82721
82977
|
if (receipt && confirmations <= 1) {
|
|
82722
82978
|
clearTimeout(timer);
|
|
@@ -83794,7 +84050,7 @@ var init_toAccount = __esm({
|
|
|
83794
84050
|
});
|
|
83795
84051
|
|
|
83796
84052
|
// ../../node_modules/viem/_esm/accounts/utils/sign.js
|
|
83797
|
-
async function
|
|
84053
|
+
async function sign2({ hash: hash2, privateKey, to = "object" }) {
|
|
83798
84054
|
const { r, s, recovery } = secp256k1.sign(hash2.slice(2), privateKey.slice(2), {
|
|
83799
84055
|
lowS: true,
|
|
83800
84056
|
extraEntropy: isHex(extraEntropy, { strict: false }) ? hexToBytes2(extraEntropy) : extraEntropy
|
|
@@ -83827,7 +84083,7 @@ var init_sign = __esm({
|
|
|
83827
84083
|
async function signAuthorization2(parameters) {
|
|
83828
84084
|
const { chainId, nonce, privateKey, to = "object" } = parameters;
|
|
83829
84085
|
const address = parameters.contractAddress ?? parameters.address;
|
|
83830
|
-
const signature = await
|
|
84086
|
+
const signature = await sign2({
|
|
83831
84087
|
hash: hashAuthorization({ address, chainId, nonce }),
|
|
83832
84088
|
privateKey,
|
|
83833
84089
|
to
|
|
@@ -83850,7 +84106,7 @@ var init_signAuthorization2 = __esm({
|
|
|
83850
84106
|
|
|
83851
84107
|
// ../../node_modules/viem/_esm/accounts/utils/signMessage.js
|
|
83852
84108
|
async function signMessage2({ message, privateKey }) {
|
|
83853
|
-
return await
|
|
84109
|
+
return await sign2({ hash: hashMessage(message), privateKey, to: "hex" });
|
|
83854
84110
|
}
|
|
83855
84111
|
var init_signMessage2 = __esm({
|
|
83856
84112
|
"../../node_modules/viem/_esm/accounts/utils/signMessage.js"() {
|
|
@@ -83870,7 +84126,7 @@ async function signTransaction2(parameters) {
|
|
|
83870
84126
|
};
|
|
83871
84127
|
return transaction;
|
|
83872
84128
|
})();
|
|
83873
|
-
const signature = await
|
|
84129
|
+
const signature = await sign2({
|
|
83874
84130
|
hash: keccak256(await serializer(signableTransaction)),
|
|
83875
84131
|
privateKey
|
|
83876
84132
|
});
|
|
@@ -83887,7 +84143,7 @@ var init_signTransaction2 = __esm({
|
|
|
83887
84143
|
// ../../node_modules/viem/_esm/accounts/utils/signTypedData.js
|
|
83888
84144
|
async function signTypedData2(parameters) {
|
|
83889
84145
|
const { privateKey, ...typedData } = parameters;
|
|
83890
|
-
return await
|
|
84146
|
+
return await sign2({
|
|
83891
84147
|
hash: hashTypedData(typedData),
|
|
83892
84148
|
privateKey,
|
|
83893
84149
|
to: "hex"
|
|
@@ -83909,7 +84165,7 @@ function privateKeyToAccount(privateKey, options = {}) {
|
|
|
83909
84165
|
address,
|
|
83910
84166
|
nonceManager,
|
|
83911
84167
|
async sign({ hash: hash2 }) {
|
|
83912
|
-
return
|
|
84168
|
+
return sign2({ hash: hash2, privateKey, to: "hex" });
|
|
83913
84169
|
},
|
|
83914
84170
|
async signAuthorization(authorization) {
|
|
83915
84171
|
return signAuthorization2({ ...authorization, privateKey });
|
|
@@ -84352,7 +84608,7 @@ var init_agent_status = __esm({
|
|
|
84352
84608
|
|
|
84353
84609
|
// ../core/src/xmtp-sdk/index.ts
|
|
84354
84610
|
function cachePath(dataDir, fileName) {
|
|
84355
|
-
return (0,
|
|
84611
|
+
return (0, import_node_path16.join)(dataDir, fileName);
|
|
84356
84612
|
}
|
|
84357
84613
|
function ensureCacheDir(dataDir) {
|
|
84358
84614
|
ensureA2aTaskDir(dataDir);
|
|
@@ -84375,10 +84631,10 @@ function isSessionExpiredError(err2) {
|
|
|
84375
84631
|
function loadSensitiveWordsFromCache(dataDir) {
|
|
84376
84632
|
try {
|
|
84377
84633
|
const path = cachePath(dataDir, "sensitive-words.json");
|
|
84378
|
-
if (!(0,
|
|
84634
|
+
if (!(0, import_node_fs13.existsSync)(path)) {
|
|
84379
84635
|
return null;
|
|
84380
84636
|
}
|
|
84381
|
-
const data = JSON.parse((0,
|
|
84637
|
+
const data = JSON.parse((0, import_node_fs13.readFileSync)(path, "utf-8"));
|
|
84382
84638
|
if (Array.isArray(data)) {
|
|
84383
84639
|
return data;
|
|
84384
84640
|
}
|
|
@@ -84392,7 +84648,7 @@ function loadSensitiveWordsFromCache(dataDir) {
|
|
|
84392
84648
|
function saveSensitiveWordsToCache(dataDir, words) {
|
|
84393
84649
|
try {
|
|
84394
84650
|
ensureCacheDir(dataDir);
|
|
84395
|
-
(0,
|
|
84651
|
+
(0, import_node_fs13.writeFileSync)(cachePath(dataDir, "sensitive-words.json"), JSON.stringify(words));
|
|
84396
84652
|
} catch (err2) {
|
|
84397
84653
|
logWithTimestamp(`[xmtp-sdk] failed to write sensitive-words.json:`, err2);
|
|
84398
84654
|
logger.error(LogEvent.CACHE_WRITE_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), { cacheName: "sensitive-words" });
|
|
@@ -84434,10 +84690,10 @@ async function loadSensitiveWordsWith(dataDir, fetcher) {
|
|
|
84434
84690
|
function loadSystemConfigFromCache(dataDir) {
|
|
84435
84691
|
try {
|
|
84436
84692
|
const path = cachePath(dataDir, "system-config.json");
|
|
84437
|
-
if (!(0,
|
|
84693
|
+
if (!(0, import_node_fs13.existsSync)(path)) {
|
|
84438
84694
|
return null;
|
|
84439
84695
|
}
|
|
84440
|
-
const data = JSON.parse((0,
|
|
84696
|
+
const data = JSON.parse((0, import_node_fs13.readFileSync)(path, "utf-8"));
|
|
84441
84697
|
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
84442
84698
|
return data;
|
|
84443
84699
|
}
|
|
@@ -84451,7 +84707,7 @@ function loadSystemConfigFromCache(dataDir) {
|
|
|
84451
84707
|
function saveSystemConfigToCache(dataDir, config) {
|
|
84452
84708
|
try {
|
|
84453
84709
|
ensureCacheDir(dataDir);
|
|
84454
|
-
(0,
|
|
84710
|
+
(0, import_node_fs13.writeFileSync)(cachePath(dataDir, "system-config.json"), JSON.stringify(config));
|
|
84455
84711
|
} catch (err2) {
|
|
84456
84712
|
logWithTimestamp(`[xmtp-sdk] failed to write system-config.json:`, err2);
|
|
84457
84713
|
logger.error(LogEvent.CACHE_WRITE_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), { cacheName: "system-config" });
|
|
@@ -84498,10 +84754,10 @@ function loadSyncByAddress(dataDir) {
|
|
|
84498
84754
|
const map = /* @__PURE__ */ new Map();
|
|
84499
84755
|
try {
|
|
84500
84756
|
const path = cachePath(dataDir, "last-sync.json");
|
|
84501
|
-
if (!(0,
|
|
84757
|
+
if (!(0, import_node_fs13.existsSync)(path)) {
|
|
84502
84758
|
return map;
|
|
84503
84759
|
}
|
|
84504
|
-
const data = JSON.parse((0,
|
|
84760
|
+
const data = JSON.parse((0, import_node_fs13.readFileSync)(path, "utf-8"));
|
|
84505
84761
|
const obj = data?.syncByAddress;
|
|
84506
84762
|
if (obj && typeof obj === "object" && !Array.isArray(obj)) {
|
|
84507
84763
|
for (const [addr, ts] of Object.entries(obj)) {
|
|
@@ -84520,9 +84776,9 @@ function saveSyncForAddress(dataDir, address, timestampMs) {
|
|
|
84520
84776
|
try {
|
|
84521
84777
|
let data = {};
|
|
84522
84778
|
const path = cachePath(dataDir, "last-sync.json");
|
|
84523
|
-
if ((0,
|
|
84779
|
+
if ((0, import_node_fs13.existsSync)(path)) {
|
|
84524
84780
|
try {
|
|
84525
|
-
const raw = JSON.parse((0,
|
|
84781
|
+
const raw = JSON.parse((0, import_node_fs13.readFileSync)(path, "utf-8"));
|
|
84526
84782
|
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
84527
84783
|
data = raw;
|
|
84528
84784
|
}
|
|
@@ -84533,7 +84789,7 @@ function saveSyncForAddress(dataDir, address, timestampMs) {
|
|
|
84533
84789
|
data.syncByAddress = {};
|
|
84534
84790
|
}
|
|
84535
84791
|
data.syncByAddress[address] = timestampMs;
|
|
84536
|
-
(0,
|
|
84792
|
+
(0, import_node_fs13.writeFileSync)(path, JSON.stringify(data, null, 2));
|
|
84537
84793
|
} catch (err2) {
|
|
84538
84794
|
logWithTimestamp(
|
|
84539
84795
|
`[xmtp-sdk] failed to write last-sync.json (address=${address}):`,
|
|
@@ -84712,13 +84968,13 @@ function createOfflineReplayAddressSummary(address) {
|
|
|
84712
84968
|
durationMs: 0
|
|
84713
84969
|
};
|
|
84714
84970
|
}
|
|
84715
|
-
var
|
|
84971
|
+
var import_node_fs13, import_node_path16, DEFAULT_DATA_DIR, SENSITIVE_WORDS_LAZY_RETRY_COOLDOWN_MS, SESSION_EXPIRED_RE, SYSTEM_CONFIG_DEFAULTS, SEMVER_RE, SENDER_BLACKLISTED_MESSAGE, RECIPIENT_BLACKLISTED_MESSAGE, XmtpService;
|
|
84716
84972
|
var init_xmtp_sdk = __esm({
|
|
84717
84973
|
"../core/src/xmtp-sdk/index.ts"() {
|
|
84718
84974
|
"use strict";
|
|
84719
84975
|
init_log();
|
|
84720
|
-
|
|
84721
|
-
|
|
84976
|
+
import_node_fs13 = require("node:fs");
|
|
84977
|
+
import_node_path16 = require("node:path");
|
|
84722
84978
|
init_dist4();
|
|
84723
84979
|
init_sentry_logger();
|
|
84724
84980
|
init_extract_job_id();
|
|
@@ -86926,12 +87182,12 @@ function loadSqlite3() {
|
|
|
86926
87182
|
process.emitWarning = originalEmitWarning;
|
|
86927
87183
|
}
|
|
86928
87184
|
}
|
|
86929
|
-
var
|
|
87185
|
+
var import_node_fs14, import_node_path17, DatabaseSync3, InvalidXmtpMessageStore;
|
|
86930
87186
|
var init_invalid_message_store = __esm({
|
|
86931
87187
|
"src/invalid-message-store.ts"() {
|
|
86932
87188
|
"use strict";
|
|
86933
|
-
|
|
86934
|
-
|
|
87189
|
+
import_node_fs14 = require("node:fs");
|
|
87190
|
+
import_node_path17 = require("node:path");
|
|
86935
87191
|
init_paths();
|
|
86936
87192
|
({ DatabaseSync: DatabaseSync3 } = loadSqlite3());
|
|
86937
87193
|
InvalidXmtpMessageStore = class {
|
|
@@ -86939,8 +87195,8 @@ var init_invalid_message_store = __esm({
|
|
|
86939
87195
|
db;
|
|
86940
87196
|
constructor(homeDir) {
|
|
86941
87197
|
const paths = resolveTaskPaths(homeDir);
|
|
86942
|
-
this.dbPath = (0,
|
|
86943
|
-
(0,
|
|
87198
|
+
this.dbPath = (0, import_node_path17.join)(paths.sqliteDir, "invalid-xmtp-messages.sqlite");
|
|
87199
|
+
(0, import_node_fs14.mkdirSync)((0, import_node_path17.dirname)(this.dbPath), { recursive: true });
|
|
86944
87200
|
this.db = new DatabaseSync3(this.dbPath);
|
|
86945
87201
|
this.ensureReady();
|
|
86946
87202
|
}
|
|
@@ -88238,7 +88494,7 @@ function buildAiAdapterCommand(options) {
|
|
|
88238
88494
|
function readCodexAddDirs(env = process.env) {
|
|
88239
88495
|
const raw = env.OKX_A2A_AI_CODEX_ADD_DIRS ?? env.OKX_AGENT_TASK_CODEX_ADD_DIRS ?? "";
|
|
88240
88496
|
const seen = /* @__PURE__ */ new Set();
|
|
88241
|
-
return raw.split(
|
|
88497
|
+
return raw.split(import_node_path18.delimiter).map((value) => expandHomePath(value.trim())).filter(Boolean).filter((dir) => {
|
|
88242
88498
|
if (seen.has(dir)) {
|
|
88243
88499
|
return false;
|
|
88244
88500
|
}
|
|
@@ -88248,10 +88504,10 @@ function readCodexAddDirs(env = process.env) {
|
|
|
88248
88504
|
}
|
|
88249
88505
|
function expandHomePath(value) {
|
|
88250
88506
|
if (value === "~") {
|
|
88251
|
-
return (0,
|
|
88507
|
+
return (0, import_node_os6.homedir)();
|
|
88252
88508
|
}
|
|
88253
88509
|
if (value.startsWith("~/")) {
|
|
88254
|
-
return (0,
|
|
88510
|
+
return (0, import_node_path18.join)((0, import_node_os6.homedir)(), value.slice(2));
|
|
88255
88511
|
}
|
|
88256
88512
|
return value;
|
|
88257
88513
|
}
|
|
@@ -88329,9 +88585,9 @@ async function runAiAdapter(options) {
|
|
|
88329
88585
|
}, 5e3).unref();
|
|
88330
88586
|
}, timeoutMs);
|
|
88331
88587
|
timeout?.unref();
|
|
88332
|
-
const exitCode = await new Promise((
|
|
88588
|
+
const exitCode = await new Promise((resolve9, reject) => {
|
|
88333
88589
|
child.once("error", reject);
|
|
88334
|
-
child.once("close", (code2) =>
|
|
88590
|
+
child.once("close", (code2) => resolve9(code2));
|
|
88335
88591
|
});
|
|
88336
88592
|
if (timeout) {
|
|
88337
88593
|
clearTimeout(timeout);
|
|
@@ -88465,9 +88721,9 @@ function formatOpenClawSessionKey(sessionKey, agentId) {
|
|
|
88465
88721
|
function buildClaudeAddDirArgs(homeDir, env) {
|
|
88466
88722
|
const dirs = [
|
|
88467
88723
|
homeDir,
|
|
88468
|
-
(0,
|
|
88469
|
-
(0,
|
|
88470
|
-
...env.OKX_A2A_AI_CLAUDE_ADD_DIRS ? env.OKX_A2A_AI_CLAUDE_ADD_DIRS.split(
|
|
88724
|
+
(0, import_node_path18.join)((0, import_node_os6.homedir)(), ".agents"),
|
|
88725
|
+
(0, import_node_path18.join)(__dirname, ".."),
|
|
88726
|
+
...env.OKX_A2A_AI_CLAUDE_ADD_DIRS ? env.OKX_A2A_AI_CLAUDE_ADD_DIRS.split(import_node_path18.delimiter).filter(Boolean) : []
|
|
88471
88727
|
];
|
|
88472
88728
|
return ["--add-dir", ...[...new Set(dirs)]];
|
|
88473
88729
|
}
|
|
@@ -88519,17 +88775,17 @@ function applyArgTemplate(template, options) {
|
|
|
88519
88775
|
const homeDir = options.homeDir ?? resolveTaskPaths().homeDir;
|
|
88520
88776
|
const cwd = options.cwd ?? process.cwd();
|
|
88521
88777
|
return template.map((arg) => {
|
|
88522
|
-
return arg.replaceAll("{prompt}", options.prompt).replaceAll("{sessionId}", options.sessionId ?? "").replaceAll("{homeDir}", homeDir).replaceAll("{cwd}", cwd).replaceAll("{repoCli}", (0,
|
|
88778
|
+
return arg.replaceAll("{prompt}", options.prompt).replaceAll("{sessionId}", options.sessionId ?? "").replaceAll("{homeDir}", homeDir).replaceAll("{cwd}", cwd).replaceAll("{repoCli}", (0, import_node_path18.join)(__dirname, "cli.js"));
|
|
88523
88779
|
});
|
|
88524
88780
|
}
|
|
88525
|
-
var import_node_child_process5,
|
|
88781
|
+
var import_node_child_process5, import_node_os6, import_node_path18, CLAUDE_ALLOWED_TOOLS, CLAUDE_PERMISSION_MODES, CODEX_SANDBOX_MODES, CODEX_APPROVAL_POLICIES;
|
|
88526
88782
|
var init_ai_adapter = __esm({
|
|
88527
88783
|
"src/ai-adapter.ts"() {
|
|
88528
88784
|
"use strict";
|
|
88529
88785
|
init_log();
|
|
88530
88786
|
import_node_child_process5 = require("node:child_process");
|
|
88531
|
-
|
|
88532
|
-
|
|
88787
|
+
import_node_os6 = require("node:os");
|
|
88788
|
+
import_node_path18 = require("node:path");
|
|
88533
88789
|
init_ai_command();
|
|
88534
88790
|
init_paths();
|
|
88535
88791
|
init_session_store();
|
|
@@ -88570,7 +88826,7 @@ function aiRunSentryExtra(input) {
|
|
|
88570
88826
|
closeSignal: input.closeSignal ?? "",
|
|
88571
88827
|
timedOut: input.timedOut === void 0 ? "" : String(input.timedOut),
|
|
88572
88828
|
aiSessionId: input.aiSessionId ?? "",
|
|
88573
|
-
aiLogFile: input.logPath ? (0,
|
|
88829
|
+
aiLogFile: input.logPath ? (0, import_node_path19.basename)(input.logPath) : "",
|
|
88574
88830
|
commandPendingMs: input.commandPendingMs ?? "",
|
|
88575
88831
|
queueWaitMs: input.queueWaitMs ?? "",
|
|
88576
88832
|
cliMs: input.cliMs ?? "",
|
|
@@ -88602,7 +88858,7 @@ function aiRunToolFailureSentryExtra(failure, context) {
|
|
|
88602
88858
|
closeSignal: context.closeSignal ?? "",
|
|
88603
88859
|
timedOut: String(context.timedOut),
|
|
88604
88860
|
aiSessionId: context.aiSessionId ?? "",
|
|
88605
|
-
aiLogFile: (0,
|
|
88861
|
+
aiLogFile: (0, import_node_path19.basename)(context.logPath)
|
|
88606
88862
|
}).filter(([, value]) => value !== "");
|
|
88607
88863
|
return entries.reduce((out, [key, value]) => {
|
|
88608
88864
|
out[key] = String(value);
|
|
@@ -88625,7 +88881,7 @@ function safeProcessCwd() {
|
|
|
88625
88881
|
}
|
|
88626
88882
|
function isDirectory(path) {
|
|
88627
88883
|
try {
|
|
88628
|
-
return (0,
|
|
88884
|
+
return (0, import_node_fs15.statSync)(path).isDirectory();
|
|
88629
88885
|
} catch {
|
|
88630
88886
|
return false;
|
|
88631
88887
|
}
|
|
@@ -88915,11 +89171,11 @@ function extractDeniedFilesystemPath(text) {
|
|
|
88915
89171
|
}
|
|
88916
89172
|
function getPreferredCodexWritableRoot(target) {
|
|
88917
89173
|
const expanded = expandHomePath2(target);
|
|
88918
|
-
const home = (0,
|
|
89174
|
+
const home = (0, import_node_os7.homedir)();
|
|
88919
89175
|
const appRoots = [
|
|
88920
|
-
(0,
|
|
88921
|
-
(0,
|
|
88922
|
-
(0,
|
|
89176
|
+
(0, import_node_path19.join)(home, ".onchainos", "task"),
|
|
89177
|
+
(0, import_node_path19.join)(home, ".onchainos", "deliverables"),
|
|
89178
|
+
(0, import_node_path19.join)(home, ".okx-agent-task")
|
|
88923
89179
|
];
|
|
88924
89180
|
for (const root of appRoots) {
|
|
88925
89181
|
if (expanded === root || expanded.startsWith(`${root}/`)) {
|
|
@@ -88934,16 +89190,16 @@ function inferAppOwnedCodexWritableRoot(failure) {
|
|
|
88934
89190
|
return void 0;
|
|
88935
89191
|
}
|
|
88936
89192
|
if (containsOnchainosCommand(command) && /\b0x[0-9a-fA-F]{16,}\b/.test(command)) {
|
|
88937
|
-
return (0,
|
|
89193
|
+
return (0, import_node_path19.join)((0, import_node_os7.homedir)(), ".onchainos", "task");
|
|
88938
89194
|
}
|
|
88939
89195
|
return void 0;
|
|
88940
89196
|
}
|
|
88941
89197
|
function expandHomePath2(value) {
|
|
88942
89198
|
if (value === "~") {
|
|
88943
|
-
return (0,
|
|
89199
|
+
return (0, import_node_os7.homedir)();
|
|
88944
89200
|
}
|
|
88945
89201
|
if (value.startsWith("~/")) {
|
|
88946
|
-
return (0,
|
|
89202
|
+
return (0, import_node_path19.join)((0, import_node_os7.homedir)(), value.slice(2));
|
|
88947
89203
|
}
|
|
88948
89204
|
return value;
|
|
88949
89205
|
}
|
|
@@ -89910,17 +90166,17 @@ function shortenJobId2(jobId) {
|
|
|
89910
90166
|
}
|
|
89911
90167
|
return `${jobId.slice(0, 6)}\u2026${jobId.slice(-4)}`;
|
|
89912
90168
|
}
|
|
89913
|
-
var import_node_crypto9,
|
|
90169
|
+
var import_node_crypto9, import_node_fs15, import_promises6, import_node_child_process6, import_node_os7, import_node_path19, AiRunner, CODEX_TOOL_FAILURE_MARKER;
|
|
89914
90170
|
var init_ai_runner = __esm({
|
|
89915
90171
|
"src/ai-runner.ts"() {
|
|
89916
90172
|
"use strict";
|
|
89917
90173
|
init_log();
|
|
89918
90174
|
import_node_crypto9 = require("node:crypto");
|
|
89919
|
-
|
|
90175
|
+
import_node_fs15 = require("node:fs");
|
|
89920
90176
|
import_promises6 = require("node:fs/promises");
|
|
89921
90177
|
import_node_child_process6 = require("node:child_process");
|
|
89922
|
-
|
|
89923
|
-
|
|
90178
|
+
import_node_os7 = require("node:os");
|
|
90179
|
+
import_node_path19 = require("node:path");
|
|
89924
90180
|
init_ai_command();
|
|
89925
90181
|
init_paths();
|
|
89926
90182
|
init_file_store();
|
|
@@ -90047,7 +90303,7 @@ var init_ai_runner = __esm({
|
|
|
90047
90303
|
ensureTaskDir(this.logsDir);
|
|
90048
90304
|
const lifecycleLogsEnabled = isAiLifecycleLoggingEnabled();
|
|
90049
90305
|
const logPath = lifecycleLogsEnabled ? this.buildRunLogPath(request) : "";
|
|
90050
|
-
const log = lifecycleLogsEnabled ? (0,
|
|
90306
|
+
const log = lifecycleLogsEnabled ? (0, import_node_fs15.createWriteStream)(logPath, { flags: "a" }) : null;
|
|
90051
90307
|
let existing = null;
|
|
90052
90308
|
let storeReadStartedAt;
|
|
90053
90309
|
let storeReadEndedAt;
|
|
@@ -90199,9 +90455,9 @@ var init_ai_runner = __esm({
|
|
|
90199
90455
|
}, 5e3).unref();
|
|
90200
90456
|
}, timeoutMs);
|
|
90201
90457
|
timeout?.unref();
|
|
90202
|
-
const closeResult = await new Promise((
|
|
90458
|
+
const closeResult = await new Promise((resolve9, reject) => {
|
|
90203
90459
|
child.once("error", reject);
|
|
90204
|
-
child.once("close", (code2, signal) =>
|
|
90460
|
+
child.once("close", (code2, signal) => resolve9({ code: code2, signal }));
|
|
90205
90461
|
});
|
|
90206
90462
|
if (timeout) {
|
|
90207
90463
|
clearTimeout(timeout);
|
|
@@ -90223,8 +90479,8 @@ var init_ai_runner = __esm({
|
|
|
90223
90479
|
const sessionWriteMs = sessionWriteEndedAt - sessionWriteStartedAt;
|
|
90224
90480
|
const logFileCloseStartedAt = Date.now();
|
|
90225
90481
|
if (log) {
|
|
90226
|
-
await new Promise((
|
|
90227
|
-
log.end(
|
|
90482
|
+
await new Promise((resolve9) => {
|
|
90483
|
+
log.end(resolve9);
|
|
90228
90484
|
});
|
|
90229
90485
|
}
|
|
90230
90486
|
const logFileCloseEndedAt = Date.now();
|
|
@@ -90430,10 +90686,10 @@ var init_ai_runner = __esm({
|
|
|
90430
90686
|
const safeMessageId = encodeURIComponent(request.messageId);
|
|
90431
90687
|
if (request.source === "job-dispatch") {
|
|
90432
90688
|
const safeJobId = encodeURIComponent(request.jobId ?? "unknown");
|
|
90433
|
-
return (0,
|
|
90689
|
+
return (0, import_node_path19.join)(this.logsDir, `ai-${safeJobId}-${safeMessageId}.log`);
|
|
90434
90690
|
}
|
|
90435
90691
|
const safeSessionKey = encodeURIComponent(request.sessionKey);
|
|
90436
|
-
return (0,
|
|
90692
|
+
return (0, import_node_path19.join)(this.logsDir, `ai-session-${safeSessionKey}-${safeMessageId}.log`);
|
|
90437
90693
|
}
|
|
90438
90694
|
readRunAiSessionId(provider, request, file, sessionMeta) {
|
|
90439
90695
|
if (request.source === "job-dispatch" && request.jobId) {
|
|
@@ -90587,7 +90843,7 @@ var init_ai_runner = __esm({
|
|
|
90587
90843
|
process.env.OKX_AGENT_TASK_AI_CWD,
|
|
90588
90844
|
this.sessionStore.getSetting("ai_working_dir"),
|
|
90589
90845
|
safeProcessCwd(),
|
|
90590
|
-
(0,
|
|
90846
|
+
(0, import_node_os7.homedir)(),
|
|
90591
90847
|
this.homeDir
|
|
90592
90848
|
];
|
|
90593
90849
|
return candidates.find((candidate) => !!candidate && isDirectory(candidate)) ?? this.homeDir;
|
|
@@ -90745,7 +91001,7 @@ var init_ai_runner = __esm({
|
|
|
90745
91001
|
async appendLlmLog(entry) {
|
|
90746
91002
|
try {
|
|
90747
91003
|
ensureTaskDir(this.logsDir);
|
|
90748
|
-
await (0, import_promises6.appendFile)((0,
|
|
91004
|
+
await (0, import_promises6.appendFile)((0, import_node_path19.join)(this.logsDir, "llm.log"), formatLlmLogEntry(entry), "utf8");
|
|
90749
91005
|
} catch (err2) {
|
|
90750
91006
|
errorWithTimestamp("[okx-agent-task] failed to append llm.log:", err2);
|
|
90751
91007
|
}
|
|
@@ -93006,12 +93262,12 @@ async function isHermesGatewayPluginEnabled(options = {}) {
|
|
|
93006
93262
|
if (options.requireGatewayRuntime && detectGatewayInvocation(env) !== "hermes") {
|
|
93007
93263
|
return false;
|
|
93008
93264
|
}
|
|
93009
|
-
const hermesHome = env.HERMES_HOME?.trim() || (0,
|
|
93010
|
-
if (!(0,
|
|
93265
|
+
const hermesHome = env.HERMES_HOME?.trim() || (0, import_node_path20.join)((0, import_node_os8.homedir)(), ".hermes");
|
|
93266
|
+
if (!(0, import_node_fs16.existsSync)((0, import_node_path20.join)(hermesHome, "plugins", "platforms", "okx-a2a", "plugin.yaml"))) {
|
|
93011
93267
|
return false;
|
|
93012
93268
|
}
|
|
93013
93269
|
try {
|
|
93014
|
-
return hermesConfigEnablesOkxA2a(await (0, import_promises7.readFile)((0,
|
|
93270
|
+
return hermesConfigEnablesOkxA2a(await (0, import_promises7.readFile)((0, import_node_path20.join)(hermesHome, "config.yaml"), "utf8"));
|
|
93015
93271
|
} catch {
|
|
93016
93272
|
return false;
|
|
93017
93273
|
}
|
|
@@ -93187,12 +93443,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
93187
93443
|
}));
|
|
93188
93444
|
}
|
|
93189
93445
|
});
|
|
93190
|
-
service.setPluginVersion("0.1.
|
|
93446
|
+
service.setPluginVersion("0.1.4-beta-161afc7833-260702114832");
|
|
93191
93447
|
await service.init();
|
|
93192
93448
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
93193
93449
|
if (pluginVersionStatus.unavailable) {
|
|
93194
93450
|
throw new Error(
|
|
93195
|
-
`@okxweb3/a2a-node v${"0.1.
|
|
93451
|
+
`@okxweb3/a2a-node v${"0.1.4-beta-161afc7833-260702114832"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
93196
93452
|
);
|
|
93197
93453
|
}
|
|
93198
93454
|
const systemConfig = service.getSystemConfig();
|
|
@@ -93210,7 +93466,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
93210
93466
|
onchainosAgentId: "*",
|
|
93211
93467
|
reason: "system-config missing sentryDsn",
|
|
93212
93468
|
pluginId: "@okxweb3/a2a-node",
|
|
93213
|
-
pluginVersion: "0.1.
|
|
93469
|
+
pluginVersion: "0.1.4-beta-161afc7833-260702114832"
|
|
93214
93470
|
});
|
|
93215
93471
|
}
|
|
93216
93472
|
logWithTimestamp(
|
|
@@ -93509,7 +93765,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
93509
93765
|
});
|
|
93510
93766
|
await markDaemonReady(paths.daemonLockPath);
|
|
93511
93767
|
logWithTimestamp(`[okx-agent-task] daemon ready lock=${paths.daemonLockPath}`);
|
|
93512
|
-
await new Promise((
|
|
93768
|
+
await new Promise((resolve9) => {
|
|
93513
93769
|
const shutdown2 = (signal) => {
|
|
93514
93770
|
if (stopping) {
|
|
93515
93771
|
return;
|
|
@@ -93518,7 +93774,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
93518
93774
|
logWithTimestamp(`[okx-agent-task] received ${signal}, stopping listener`);
|
|
93519
93775
|
const forceResolve = setTimeout(() => {
|
|
93520
93776
|
logWithTimestamp("[okx-agent-task] listener shutdown timed out; forcing process exit");
|
|
93521
|
-
|
|
93777
|
+
resolve9();
|
|
93522
93778
|
}, SHUTDOWN_FORCE_RESOLVE_MS);
|
|
93523
93779
|
void (async () => {
|
|
93524
93780
|
if (timer) {
|
|
@@ -93546,7 +93802,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
93546
93802
|
stopClients(service);
|
|
93547
93803
|
sessionStore.close();
|
|
93548
93804
|
clearTimeout(forceResolve);
|
|
93549
|
-
|
|
93805
|
+
resolve9();
|
|
93550
93806
|
})();
|
|
93551
93807
|
};
|
|
93552
93808
|
process.once("SIGTERM", shutdown2);
|
|
@@ -93562,15 +93818,15 @@ async function timeSettled(fn) {
|
|
|
93562
93818
|
return { durationMs: Date.now() - startedAt, error };
|
|
93563
93819
|
}
|
|
93564
93820
|
}
|
|
93565
|
-
var
|
|
93821
|
+
var import_node_fs16, import_promises7, import_node_os8, import_node_path20, DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC, DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC, XMTP_CLIENT_RECYCLE_INTERVAL_ENV, HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS, SHUTDOWN_FORCE_RESOLVE_MS;
|
|
93566
93822
|
var init_listener = __esm({
|
|
93567
93823
|
"src/listener.ts"() {
|
|
93568
93824
|
"use strict";
|
|
93569
93825
|
init_log();
|
|
93570
|
-
|
|
93826
|
+
import_node_fs16 = require("node:fs");
|
|
93571
93827
|
import_promises7 = require("node:fs/promises");
|
|
93572
|
-
|
|
93573
|
-
|
|
93828
|
+
import_node_os8 = require("node:os");
|
|
93829
|
+
import_node_path20 = require("node:path");
|
|
93574
93830
|
init_onchainos();
|
|
93575
93831
|
init_system_config();
|
|
93576
93832
|
init_signer();
|
|
@@ -93599,9 +93855,9 @@ var init_listener = __esm({
|
|
|
93599
93855
|
|
|
93600
93856
|
// ../core/src/file-upload-safety.ts
|
|
93601
93857
|
function getUnsafeFileUploadReason(filePath, sensitiveUploadReg = []) {
|
|
93602
|
-
const expanded = (0,
|
|
93603
|
-
const target = (0,
|
|
93604
|
-
const targetName = (0,
|
|
93858
|
+
const expanded = (0, import_node_path21.resolve)(expandHome(filePath));
|
|
93859
|
+
const target = (0, import_node_fs17.realpathSync)(expanded);
|
|
93860
|
+
const targetName = (0, import_node_path21.basename)(target);
|
|
93605
93861
|
if (targetName === ".env" || targetName.startsWith(".env.")) {
|
|
93606
93862
|
return ".env";
|
|
93607
93863
|
}
|
|
@@ -93609,18 +93865,18 @@ function getUnsafeFileUploadReason(filePath, sensitiveUploadReg = []) {
|
|
|
93609
93865
|
if (configuredRule) {
|
|
93610
93866
|
return `SENSITIVE_UPLOAD_REG:${configuredRule}`;
|
|
93611
93867
|
}
|
|
93612
|
-
const home = safeRealpath((0,
|
|
93868
|
+
const home = safeRealpath((0, import_node_os9.homedir)());
|
|
93613
93869
|
if (!home) {
|
|
93614
93870
|
return null;
|
|
93615
93871
|
}
|
|
93616
93872
|
for (const dir of SENSITIVE_HOME_DIRS) {
|
|
93617
|
-
const sensitiveDir = safeRealpath((0,
|
|
93873
|
+
const sensitiveDir = safeRealpath((0, import_node_path21.join)(home, dir));
|
|
93618
93874
|
if (sensitiveDir && isPathInside(target, sensitiveDir)) {
|
|
93619
93875
|
return `~/${dir}`;
|
|
93620
93876
|
}
|
|
93621
93877
|
}
|
|
93622
93878
|
for (const file of SENSITIVE_HOME_FILES) {
|
|
93623
|
-
const sensitiveFile = safeRealpath((0,
|
|
93879
|
+
const sensitiveFile = safeRealpath((0, import_node_path21.join)(home, file));
|
|
93624
93880
|
if (sensitiveFile && target === sensitiveFile) {
|
|
93625
93881
|
return `~/${file}`;
|
|
93626
93882
|
}
|
|
@@ -93646,29 +93902,29 @@ function matchSensitiveUploadReg(paths, patterns) {
|
|
|
93646
93902
|
}
|
|
93647
93903
|
function expandHome(filePath) {
|
|
93648
93904
|
if (filePath === "~") {
|
|
93649
|
-
return (0,
|
|
93905
|
+
return (0, import_node_os9.homedir)();
|
|
93650
93906
|
}
|
|
93651
|
-
if (filePath.startsWith(`~${
|
|
93652
|
-
return (0,
|
|
93907
|
+
if (filePath.startsWith(`~${import_node_path21.sep}`)) {
|
|
93908
|
+
return (0, import_node_path21.join)((0, import_node_os9.homedir)(), filePath.slice(2));
|
|
93653
93909
|
}
|
|
93654
93910
|
return filePath;
|
|
93655
93911
|
}
|
|
93656
93912
|
function safeRealpath(path) {
|
|
93657
|
-
if (!(0,
|
|
93913
|
+
if (!(0, import_node_fs17.existsSync)(path)) {
|
|
93658
93914
|
return null;
|
|
93659
93915
|
}
|
|
93660
|
-
return (0,
|
|
93916
|
+
return (0, import_node_fs17.realpathSync)(path);
|
|
93661
93917
|
}
|
|
93662
93918
|
function isPathInside(target, dir) {
|
|
93663
|
-
return target === dir || target.startsWith(`${dir}${
|
|
93919
|
+
return target === dir || target.startsWith(`${dir}${import_node_path21.sep}`);
|
|
93664
93920
|
}
|
|
93665
|
-
var
|
|
93921
|
+
var import_node_fs17, import_node_os9, import_node_path21, SENSITIVE_HOME_DIRS, SENSITIVE_HOME_FILES, UNSAFE_FILE_UPLOAD_MESSAGE;
|
|
93666
93922
|
var init_file_upload_safety = __esm({
|
|
93667
93923
|
"../core/src/file-upload-safety.ts"() {
|
|
93668
93924
|
"use strict";
|
|
93669
|
-
|
|
93670
|
-
|
|
93671
|
-
|
|
93925
|
+
import_node_fs17 = require("node:fs");
|
|
93926
|
+
import_node_os9 = require("node:os");
|
|
93927
|
+
import_node_path21 = require("node:path");
|
|
93672
93928
|
SENSITIVE_HOME_DIRS = [
|
|
93673
93929
|
".ssh",
|
|
93674
93930
|
".gnupg",
|
|
@@ -93676,7 +93932,7 @@ var init_file_upload_safety = __esm({
|
|
|
93676
93932
|
".azure",
|
|
93677
93933
|
".kube",
|
|
93678
93934
|
".docker",
|
|
93679
|
-
(0,
|
|
93935
|
+
(0, import_node_path21.join)(".config", "gcloud")
|
|
93680
93936
|
];
|
|
93681
93937
|
SENSITIVE_HOME_FILES = [
|
|
93682
93938
|
".npmrc",
|
|
@@ -93738,7 +93994,7 @@ function hasHelpFlag(args) {
|
|
|
93738
93994
|
return args.some((arg) => arg === "-h" || arg === "--help" || arg === "help");
|
|
93739
93995
|
}
|
|
93740
93996
|
async function uploadFile(params) {
|
|
93741
|
-
const filename = params.filename || (0,
|
|
93997
|
+
const filename = params.filename || (0, import_node_path22.basename)(params.filePath);
|
|
93742
93998
|
const mimeType = params.mimeType || "application/octet-stream";
|
|
93743
93999
|
const uploadConfig = readUploadSystemConfig();
|
|
93744
94000
|
const unsafeReason = getUnsafeFileUploadReason(params.filePath, uploadConfig.sensitiveUploadReg);
|
|
@@ -93754,16 +94010,16 @@ async function uploadFile(params) {
|
|
|
93754
94010
|
return;
|
|
93755
94011
|
}
|
|
93756
94012
|
const maxFileSizeBytes = uploadConfig.maxFileSizeBytes;
|
|
93757
|
-
const fileSize = (0,
|
|
94013
|
+
const fileSize = (0, import_node_fs18.statSync)(params.filePath).size;
|
|
93758
94014
|
if (fileSize > maxFileSizeBytes) {
|
|
93759
94015
|
throw new Error(formatFileTooLargeMessage(maxFileSizeBytes));
|
|
93760
94016
|
}
|
|
93761
|
-
const data = (0,
|
|
94017
|
+
const data = (0, import_node_fs18.readFileSync)(params.filePath);
|
|
93762
94018
|
const attachment = { filename, mimeType, data: new Uint8Array(data) };
|
|
93763
94019
|
const encrypted = await RemoteAttachmentCodec.encodeEncrypted(attachment, new AttachmentCodec());
|
|
93764
94020
|
ensureFileDirs();
|
|
93765
|
-
const encryptedPath = (0,
|
|
93766
|
-
(0,
|
|
94021
|
+
const encryptedPath = (0, import_node_path22.resolve)(FILE_WORK_DIR, `${(0, import_node_crypto12.randomUUID)()}.enc`);
|
|
94022
|
+
(0, import_node_fs18.writeFileSync)(encryptedPath, encrypted.payload);
|
|
93767
94023
|
try {
|
|
93768
94024
|
const stdout = runOnchainos([
|
|
93769
94025
|
"agent",
|
|
@@ -93799,14 +94055,14 @@ async function uploadFile(params) {
|
|
|
93799
94055
|
}, null, 2));
|
|
93800
94056
|
} finally {
|
|
93801
94057
|
try {
|
|
93802
|
-
(0,
|
|
94058
|
+
(0, import_node_fs18.unlinkSync)(encryptedPath);
|
|
93803
94059
|
} catch {
|
|
93804
94060
|
}
|
|
93805
94061
|
}
|
|
93806
94062
|
}
|
|
93807
94063
|
async function downloadFile(params) {
|
|
93808
94064
|
ensureFileDirs();
|
|
93809
|
-
const encryptedPath = (0,
|
|
94065
|
+
const encryptedPath = (0, import_node_path22.resolve)(FILE_WORK_DIR, `${(0, import_node_crypto12.randomUUID)()}.enc`);
|
|
93810
94066
|
try {
|
|
93811
94067
|
const stdout = runOnchainos([
|
|
93812
94068
|
"agent",
|
|
@@ -93830,7 +94086,7 @@ async function downloadFile(params) {
|
|
|
93830
94086
|
}));
|
|
93831
94087
|
throw new Error(`file download failed: ${stdout}`);
|
|
93832
94088
|
}
|
|
93833
|
-
const payload = new Uint8Array((0,
|
|
94089
|
+
const payload = new Uint8Array((0, import_node_fs18.readFileSync)(encryptedPath));
|
|
93834
94090
|
const digestBytes = new Uint8Array(await import_node_crypto12.webcrypto.subtle.digest("SHA-256", payload));
|
|
93835
94091
|
const actualDigest = Array.from(digestBytes).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
93836
94092
|
if (actualDigest !== params.digest) {
|
|
@@ -93842,12 +94098,12 @@ async function downloadFile(params) {
|
|
|
93842
94098
|
const outputFilename = params.filename || attachment.filename || `${(0, import_node_crypto12.randomUUID)()}.bin`;
|
|
93843
94099
|
const outputDir = DOWNLOADS_DIR;
|
|
93844
94100
|
ensureA2aTaskDir(outputDir);
|
|
93845
|
-
const outputPath = (0,
|
|
93846
|
-
(0,
|
|
94101
|
+
const outputPath = (0, import_node_path22.resolve)(outputDir, (0, import_node_path22.basename)(outputFilename));
|
|
94102
|
+
(0, import_node_fs18.writeFileSync)(outputPath, attachment.data);
|
|
93847
94103
|
console.log(outputPath);
|
|
93848
94104
|
} finally {
|
|
93849
94105
|
try {
|
|
93850
|
-
(0,
|
|
94106
|
+
(0, import_node_fs18.unlinkSync)(encryptedPath);
|
|
93851
94107
|
} catch {
|
|
93852
94108
|
}
|
|
93853
94109
|
}
|
|
@@ -93943,7 +94199,7 @@ function readUploadSystemConfig() {
|
|
|
93943
94199
|
const res = parseCliJson2(stdout, "system-config");
|
|
93944
94200
|
if (res.data && typeof res.data === "object") {
|
|
93945
94201
|
ensureA2aTaskDir(OKX_A2A_PATHS.xmtpDir);
|
|
93946
|
-
(0,
|
|
94202
|
+
(0, import_node_fs18.writeFileSync)(SYSTEM_CONFIG_PATH, JSON.stringify(res.data));
|
|
93947
94203
|
}
|
|
93948
94204
|
return parseUploadSystemConfig(res.data ?? {});
|
|
93949
94205
|
} catch {
|
|
@@ -93966,10 +94222,10 @@ function fileCliSentryExtra(operation, reason, extra = {}) {
|
|
|
93966
94222
|
}
|
|
93967
94223
|
function readSystemConfigFromCache() {
|
|
93968
94224
|
try {
|
|
93969
|
-
if (!(0,
|
|
94225
|
+
if (!(0, import_node_fs18.existsSync)(SYSTEM_CONFIG_PATH)) {
|
|
93970
94226
|
return null;
|
|
93971
94227
|
}
|
|
93972
|
-
return JSON.parse((0,
|
|
94228
|
+
return JSON.parse((0, import_node_fs18.readFileSync)(SYSTEM_CONFIG_PATH, "utf8"));
|
|
93973
94229
|
} catch {
|
|
93974
94230
|
return null;
|
|
93975
94231
|
}
|
|
@@ -94003,14 +94259,14 @@ function readRequiredOption(args, name2) {
|
|
|
94003
94259
|
}
|
|
94004
94260
|
return value;
|
|
94005
94261
|
}
|
|
94006
|
-
var import_node_child_process7, import_node_crypto12,
|
|
94262
|
+
var import_node_child_process7, import_node_crypto12, import_node_fs18, import_node_path22, import_proto4, OKX_A2A_PATHS, OKX_A2A_HOME_DIR, FILE_WORK_DIR, DOWNLOADS_DIR, SYSTEM_CONFIG_PATH;
|
|
94007
94263
|
var init_file_cli = __esm({
|
|
94008
94264
|
"src/file-cli.ts"() {
|
|
94009
94265
|
"use strict";
|
|
94010
94266
|
import_node_child_process7 = require("node:child_process");
|
|
94011
94267
|
import_node_crypto12 = require("node:crypto");
|
|
94012
|
-
|
|
94013
|
-
|
|
94268
|
+
import_node_fs18 = require("node:fs");
|
|
94269
|
+
import_node_path22 = require("node:path");
|
|
94014
94270
|
init_dist6();
|
|
94015
94271
|
import_proto4 = __toESM(require_node3());
|
|
94016
94272
|
init_a2a_paths();
|
|
@@ -94021,7 +94277,7 @@ var init_file_cli = __esm({
|
|
|
94021
94277
|
OKX_A2A_HOME_DIR = OKX_A2A_PATHS.homeDir;
|
|
94022
94278
|
FILE_WORK_DIR = process.env.OKX_A2A_FILE_WORK_DIR || OKX_A2A_PATHS.filesDir;
|
|
94023
94279
|
DOWNLOADS_DIR = process.env.OKX_A2A_DOWNLOADS_DIR || OKX_A2A_PATHS.downloadsDir;
|
|
94024
|
-
SYSTEM_CONFIG_PATH = (0,
|
|
94280
|
+
SYSTEM_CONFIG_PATH = (0, import_node_path22.resolve)(OKX_A2A_PATHS.xmtpDir, "system-config.json");
|
|
94025
94281
|
}
|
|
94026
94282
|
});
|
|
94027
94283
|
|
|
@@ -94506,16 +94762,16 @@ function createWakeSignal() {
|
|
|
94506
94762
|
wake = null;
|
|
94507
94763
|
},
|
|
94508
94764
|
wait(ms) {
|
|
94509
|
-
return new Promise((
|
|
94765
|
+
return new Promise((resolve9) => {
|
|
94510
94766
|
const timer = setTimeout(() => {
|
|
94511
94767
|
if (wake === finish) {
|
|
94512
94768
|
wake = null;
|
|
94513
94769
|
}
|
|
94514
|
-
|
|
94770
|
+
resolve9();
|
|
94515
94771
|
}, ms);
|
|
94516
94772
|
const finish = () => {
|
|
94517
94773
|
clearTimeout(timer);
|
|
94518
|
-
|
|
94774
|
+
resolve9();
|
|
94519
94775
|
};
|
|
94520
94776
|
wake = finish;
|
|
94521
94777
|
});
|
|
@@ -94523,7 +94779,7 @@ function createWakeSignal() {
|
|
|
94523
94779
|
};
|
|
94524
94780
|
}
|
|
94525
94781
|
function sleep3(ms) {
|
|
94526
|
-
return new Promise((
|
|
94782
|
+
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
94527
94783
|
}
|
|
94528
94784
|
function output(json, payload, human) {
|
|
94529
94785
|
if (json) {
|
|
@@ -96802,7 +97058,7 @@ async function getCurrentNodeCliVersion() {
|
|
|
96802
97058
|
return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
|
|
96803
97059
|
}
|
|
96804
97060
|
function getBundledNodeCliVersion() {
|
|
96805
|
-
return true ? "0.1.
|
|
97061
|
+
return true ? "0.1.4-beta-161afc7833-260702114832" : null;
|
|
96806
97062
|
}
|
|
96807
97063
|
function readConfiguredAiProvider() {
|
|
96808
97064
|
const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
|
|
@@ -96953,17 +97209,17 @@ async function updateHermes(release, options) {
|
|
|
96953
97209
|
assertNotRunningInsideGateway("hermes");
|
|
96954
97210
|
}
|
|
96955
97211
|
const spec = buildNpmPackageSpec("hermes", release);
|
|
96956
|
-
const workDir = await (0, import_promises8.mkdtemp)((0,
|
|
97212
|
+
const workDir = await (0, import_promises8.mkdtemp)((0, import_node_path23.join)((0, import_node_os10.tmpdir)(), `okx-a2a-${label}-hermes-`));
|
|
96957
97213
|
try {
|
|
96958
97214
|
console.log(`[${label}] downloading ${spec}`);
|
|
96959
97215
|
const npmTarball = await npmPack(spec, workDir);
|
|
96960
|
-
const npmPackageDir = (0,
|
|
97216
|
+
const npmPackageDir = (0, import_node_path23.join)(workDir, "npm-package");
|
|
96961
97217
|
await runCommand("tar", ["-xzf", npmTarball, "-C", npmPackageDir], { ensureDir: npmPackageDir });
|
|
96962
|
-
const pluginTarball = await findHermesPluginTarball((0,
|
|
96963
|
-
const pluginDir = (0,
|
|
97218
|
+
const pluginTarball = await findHermesPluginTarball((0, import_node_path23.join)(npmPackageDir, "package", "dist"));
|
|
97219
|
+
const pluginDir = (0, import_node_path23.join)(workDir, "plugin");
|
|
96964
97220
|
await runCommand("tar", ["-xzf", pluginTarball, "-C", pluginDir], { ensureDir: pluginDir });
|
|
96965
97221
|
const unpackedPluginDir = await findFirstDirectory(pluginDir);
|
|
96966
|
-
const installer = (0,
|
|
97222
|
+
const installer = (0, import_node_path23.join)(unpackedPluginDir, "scripts", "install-or-upgrade.sh");
|
|
96967
97223
|
console.log(`[${label}] running ${installer}`);
|
|
96968
97224
|
await runCommand("bash", [installer, ...options.restart ? ["--restart"] : []], { cwd: unpackedPluginDir });
|
|
96969
97225
|
await normalizeHermesOkxA2aPluginConfig();
|
|
@@ -97010,7 +97266,7 @@ async function ensureHermesOkxA2aPluginConfig(configFile = resolveHermesConfigPa
|
|
|
97010
97266
|
content3 = await (0, import_promises8.readFile)(configFile, "utf8");
|
|
97011
97267
|
} catch (error) {
|
|
97012
97268
|
if (isNodeError(error) && error.code === "ENOENT") {
|
|
97013
|
-
await (0, import_promises8.mkdir)((0,
|
|
97269
|
+
await (0, import_promises8.mkdir)((0, import_node_path23.resolve)(configFile, ".."), { recursive: true });
|
|
97014
97270
|
await (0, import_promises8.writeFile)(configFile, "plugins:\n enabled:\n - okx-a2a\n");
|
|
97015
97271
|
console.log(`[update] added Hermes plugins.enabled okx-a2a entry in ${configFile}`);
|
|
97016
97272
|
return true;
|
|
@@ -97243,7 +97499,7 @@ function findFirstEnabledListItem(lines, startIndex, enabledIndent) {
|
|
|
97243
97499
|
return null;
|
|
97244
97500
|
}
|
|
97245
97501
|
function resolveHermesConfigPath() {
|
|
97246
|
-
return (0,
|
|
97502
|
+
return (0, import_node_path23.join)(process.env.HERMES_HOME ?? (0, import_node_path23.join)((0, import_node_os10.homedir)(), ".hermes"), "config.yaml");
|
|
97247
97503
|
}
|
|
97248
97504
|
function lineIndent(line) {
|
|
97249
97505
|
const match = line.match(/^\s*/);
|
|
@@ -97324,7 +97580,7 @@ async function isGatewayPluginInstalled(target) {
|
|
|
97324
97580
|
if (target === "openclaw") {
|
|
97325
97581
|
return (await getInstalledOpenClawPluginInfo()).installed;
|
|
97326
97582
|
}
|
|
97327
|
-
if ((0,
|
|
97583
|
+
if ((0, import_node_fs19.existsSync)((0, import_node_path23.join)(process.env.HERMES_HOME ?? (0, import_node_path23.join)((0, import_node_os10.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml"))) {
|
|
97328
97584
|
return true;
|
|
97329
97585
|
}
|
|
97330
97586
|
return await isGlobalNpmPackageInstalled(UPDATE_PACKAGES.hermes);
|
|
@@ -97418,7 +97674,7 @@ function parsePackageVersionFromText(output4) {
|
|
|
97418
97674
|
return output4.match(/@okxweb3\/a2a-openclaw@([0-9A-Za-z.+-]+)/)?.[1] ?? null;
|
|
97419
97675
|
}
|
|
97420
97676
|
async function getInstalledHermesPluginVersion() {
|
|
97421
|
-
const pluginYaml = (0,
|
|
97677
|
+
const pluginYaml = (0, import_node_path23.join)(process.env.HERMES_HOME ?? (0, import_node_path23.join)((0, import_node_os10.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
|
|
97422
97678
|
try {
|
|
97423
97679
|
const content3 = await (0, import_promises8.readFile)(pluginYaml, "utf8");
|
|
97424
97680
|
return parsePluginYamlVersion(content3);
|
|
@@ -97471,7 +97727,7 @@ async function npmPack(spec, destination) {
|
|
|
97471
97727
|
if (!tarballName) {
|
|
97472
97728
|
throw new Error(`Unable to detect npm pack tarball from output: ${output4.trim()}`);
|
|
97473
97729
|
}
|
|
97474
|
-
return (0,
|
|
97730
|
+
return (0, import_node_path23.resolve)(destination, (0, import_node_path23.basename)(tarballName));
|
|
97475
97731
|
}
|
|
97476
97732
|
async function findHermesPluginTarball(distDir) {
|
|
97477
97733
|
const entries = await (0, import_promises8.readdir)(distDir);
|
|
@@ -97479,7 +97735,7 @@ async function findHermesPluginTarball(distDir) {
|
|
|
97479
97735
|
if (!tarball) {
|
|
97480
97736
|
throw new Error(`Hermes npm package did not contain dist/okx-a2a-hermes-plugin-*.tar.gz`);
|
|
97481
97737
|
}
|
|
97482
|
-
return (0,
|
|
97738
|
+
return (0, import_node_path23.join)(distDir, tarball);
|
|
97483
97739
|
}
|
|
97484
97740
|
async function findFirstDirectory(parent) {
|
|
97485
97741
|
const entries = await (0, import_promises8.readdir)(parent, { withFileTypes: true });
|
|
@@ -97487,7 +97743,7 @@ async function findFirstDirectory(parent) {
|
|
|
97487
97743
|
if (!dir) {
|
|
97488
97744
|
throw new Error(`No unpacked plugin directory found under ${parent}`);
|
|
97489
97745
|
}
|
|
97490
|
-
return (0,
|
|
97746
|
+
return (0, import_node_path23.join)(parent, dir.name);
|
|
97491
97747
|
}
|
|
97492
97748
|
function readOption2(args, name2) {
|
|
97493
97749
|
const index2 = args.indexOf(name2);
|
|
@@ -97654,15 +97910,15 @@ async function runCommandCaptureStatus(command, args) {
|
|
|
97654
97910
|
});
|
|
97655
97911
|
});
|
|
97656
97912
|
}
|
|
97657
|
-
var import_node_child_process8,
|
|
97913
|
+
var import_node_child_process8, import_node_fs19, import_promises8, import_node_os10, import_node_path23, UPDATE_PACKAGES, CODEX_NPM_PACKAGE, OPENCLAW_FORCE_INSTALL_FLAG, OPENCLAW_UNSAFE_INSTALL_FLAG, OKX_A2A_PLUGIN_ID, OPENCLAW_SESSION_DM_SCOPE_CONFIG_PATH, OPENCLAW_SESSION_DM_SCOPE_CONFIG_VALUE, OPENCLAW_PLUGIN_ALLOW_CONFIG_PATH, OPENCLAW_OKX_A2A_CONVERSATION_HOOK_ACCESS_CONFIG_PATH, DEFAULT_AI_PROVIDER_LOGIN_TIMEOUT_MS, SetupBlockedError, redirectCommandStdoutToStderr;
|
|
97658
97914
|
var init_update_cli = __esm({
|
|
97659
97915
|
"src/update-cli.ts"() {
|
|
97660
97916
|
"use strict";
|
|
97661
97917
|
import_node_child_process8 = require("node:child_process");
|
|
97662
|
-
|
|
97918
|
+
import_node_fs19 = require("node:fs");
|
|
97663
97919
|
import_promises8 = require("node:fs/promises");
|
|
97664
|
-
|
|
97665
|
-
|
|
97920
|
+
import_node_os10 = require("node:os");
|
|
97921
|
+
import_node_path23 = require("node:path");
|
|
97666
97922
|
init_ai_command();
|
|
97667
97923
|
init_ai_provider();
|
|
97668
97924
|
init_session_store();
|
|
@@ -97694,9 +97950,9 @@ var init_update_cli = __esm({
|
|
|
97694
97950
|
|
|
97695
97951
|
// src/cli.ts
|
|
97696
97952
|
var import_node_child_process9 = require("node:child_process");
|
|
97697
|
-
var
|
|
97698
|
-
var
|
|
97699
|
-
var
|
|
97953
|
+
var import_node_fs20 = require("node:fs");
|
|
97954
|
+
var import_node_os11 = require("node:os");
|
|
97955
|
+
var import_node_path24 = require("node:path");
|
|
97700
97956
|
init_daemon();
|
|
97701
97957
|
init_command_store();
|
|
97702
97958
|
init_file_store();
|
|
@@ -97710,7 +97966,7 @@ init_sentry_logger();
|
|
|
97710
97966
|
init_sentry_config();
|
|
97711
97967
|
var CURRENT_GATEWAY_SESSION_KEYS_ENV3 = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
|
|
97712
97968
|
function printUsage2() {
|
|
97713
|
-
console.log(`okx-a2a ${"0.1.
|
|
97969
|
+
console.log(`okx-a2a ${"0.1.4-beta-161afc7833-260702114832"}
|
|
97714
97970
|
|
|
97715
97971
|
Usage:
|
|
97716
97972
|
okx-a2a <command> [options]
|
|
@@ -97747,7 +98003,7 @@ Run \`okx-a2a <command> -h\` for command-specific help.
|
|
|
97747
98003
|
`);
|
|
97748
98004
|
}
|
|
97749
98005
|
function printVersion() {
|
|
97750
|
-
console.log("0.1.
|
|
98006
|
+
console.log("0.1.4-beta-161afc7833-260702114832");
|
|
97751
98007
|
}
|
|
97752
98008
|
function printDaemonUsage() {
|
|
97753
98009
|
console.log(`Usage: okx-a2a daemon <start|restart|stop|status|autostart> [options]
|
|
@@ -98033,12 +98289,12 @@ async function printDaemonStatus() {
|
|
|
98033
98289
|
}
|
|
98034
98290
|
}
|
|
98035
98291
|
async function tailLogFile(logPath) {
|
|
98036
|
-
await new Promise((
|
|
98292
|
+
await new Promise((resolve9, reject) => {
|
|
98037
98293
|
const child = (0, import_node_child_process9.spawn)("tail", ["-600", "-f", logPath], { stdio: "inherit" });
|
|
98038
98294
|
child.on("error", reject);
|
|
98039
98295
|
child.on("close", (code2, signal) => {
|
|
98040
98296
|
if (signal || code2 === 0) {
|
|
98041
|
-
|
|
98297
|
+
resolve9();
|
|
98042
98298
|
return;
|
|
98043
98299
|
}
|
|
98044
98300
|
reject(new Error(`tail exited with code=${code2}`));
|
|
@@ -98057,7 +98313,7 @@ async function handleLogs(args) {
|
|
|
98057
98313
|
return;
|
|
98058
98314
|
}
|
|
98059
98315
|
if (subcommand === "llm") {
|
|
98060
|
-
await tailLogFile((0,
|
|
98316
|
+
await tailLogFile((0, import_node_path24.join)(paths.logsDir, "llm.log"));
|
|
98061
98317
|
return;
|
|
98062
98318
|
}
|
|
98063
98319
|
throw new Error("logs requires <server|llm>");
|
|
@@ -98969,11 +99225,11 @@ function initDirectCliSentry() {
|
|
|
98969
99225
|
}
|
|
98970
99226
|
cliSentryInitAttempted = true;
|
|
98971
99227
|
try {
|
|
98972
|
-
const configPath = (0,
|
|
98973
|
-
if (!(0,
|
|
99228
|
+
const configPath = (0, import_node_path24.join)(resolveTaskHomeForSentryConfig(), "xmtp", "system-config.json");
|
|
99229
|
+
if (!(0, import_node_fs20.existsSync)(configPath)) {
|
|
98974
99230
|
return;
|
|
98975
99231
|
}
|
|
98976
|
-
const config = JSON.parse((0,
|
|
99232
|
+
const config = JSON.parse((0, import_node_fs20.readFileSync)(configPath, "utf8"));
|
|
98977
99233
|
if (typeof config.sentryDsn !== "string" || !config.sentryDsn) {
|
|
98978
99234
|
return;
|
|
98979
99235
|
}
|
|
@@ -98991,13 +99247,13 @@ function resolveTaskHomeForSentryConfig() {
|
|
|
98991
99247
|
return process.env.OKX_AGENT_TASK_HOME;
|
|
98992
99248
|
}
|
|
98993
99249
|
try {
|
|
98994
|
-
const home = (0,
|
|
99250
|
+
const home = (0, import_node_os11.homedir)();
|
|
98995
99251
|
if (home) {
|
|
98996
|
-
return (0,
|
|
99252
|
+
return (0, import_node_path24.join)(home, ".okx-agent-task");
|
|
98997
99253
|
}
|
|
98998
99254
|
} catch {
|
|
98999
99255
|
}
|
|
99000
|
-
return (0,
|
|
99256
|
+
return (0, import_node_path24.resolve)(process.cwd(), ".okx-agent-task");
|
|
99001
99257
|
}
|
|
99002
99258
|
function directCliSentryExtra(operation, extra = {}) {
|
|
99003
99259
|
return {
|
|
@@ -99013,8 +99269,8 @@ async function flushDirectCliSentry() {
|
|
|
99013
99269
|
return;
|
|
99014
99270
|
}
|
|
99015
99271
|
try {
|
|
99016
|
-
const timeout = new Promise((
|
|
99017
|
-
const timer = setTimeout(() =>
|
|
99272
|
+
const timeout = new Promise((resolve9) => {
|
|
99273
|
+
const timer = setTimeout(() => resolve9("timeout"), 750);
|
|
99018
99274
|
timer.unref?.();
|
|
99019
99275
|
});
|
|
99020
99276
|
const result = await Promise.race([shutdown().then(() => "flushed"), timeout]);
|