@okxweb3/a2a-node 0.0.16 → 0.0.17-beta-db5dca184d-260624150845
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/README.md +40 -6
- package/dist/cli.js +768 -374
- package/dist/index.js +182 -15
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -343,6 +343,9 @@ function mapPendingGatewayDeliveryRow(row) {
|
|
|
343
343
|
...row.job_id ? { jobId: row.job_id } : {},
|
|
344
344
|
...row.llm_content ? { llmContent: row.llm_content } : {},
|
|
345
345
|
...row.message_id ? { messageId: row.message_id } : {},
|
|
346
|
+
...row.attention_id ? { attentionId: row.attention_id } : {},
|
|
347
|
+
...row.delivery_state_json ? { deliveryStateJson: row.delivery_state_json } : {},
|
|
348
|
+
...row.payload_json ? { payloadJson: row.payload_json } : {},
|
|
346
349
|
...row.last_error ? { lastError: row.last_error } : {},
|
|
347
350
|
...row.last_attempt_at ? { lastAttemptAt: row.last_attempt_at } : {}
|
|
348
351
|
};
|
|
@@ -579,7 +582,7 @@ var init_session_store = __esm({
|
|
|
579
582
|
`);
|
|
580
583
|
}
|
|
581
584
|
ensurePendingGatewayDeliveriesSchema() {
|
|
582
|
-
const expectedKindCheck =
|
|
585
|
+
const expectedKindCheck = this.pendingGatewayDeliveryKindCheck();
|
|
583
586
|
this.db.exec(`
|
|
584
587
|
CREATE TABLE IF NOT EXISTS pending_gateway_deliveries (
|
|
585
588
|
id TEXT PRIMARY KEY,
|
|
@@ -590,6 +593,9 @@ var init_session_store = __esm({
|
|
|
590
593
|
content TEXT NOT NULL,
|
|
591
594
|
llm_content TEXT,
|
|
592
595
|
message_id TEXT UNIQUE,
|
|
596
|
+
attention_id TEXT,
|
|
597
|
+
delivery_state_json TEXT,
|
|
598
|
+
payload_json TEXT,
|
|
593
599
|
attempts INTEGER NOT NULL DEFAULT 0,
|
|
594
600
|
last_error TEXT,
|
|
595
601
|
created_at TEXT NOT NULL,
|
|
@@ -597,7 +603,7 @@ var init_session_store = __esm({
|
|
|
597
603
|
)
|
|
598
604
|
`);
|
|
599
605
|
const row = this.db.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name='pending_gateway_deliveries'").get();
|
|
600
|
-
if (row?.sql?.includes("
|
|
606
|
+
if (row?.sql?.includes("attention_id") && row.sql.includes("delivery_state_json") && row.sql.includes("payload_json")) {
|
|
601
607
|
return;
|
|
602
608
|
}
|
|
603
609
|
this.db.exec("ALTER TABLE pending_gateway_deliveries RENAME TO pending_gateway_deliveries_old");
|
|
@@ -611,6 +617,9 @@ var init_session_store = __esm({
|
|
|
611
617
|
content TEXT NOT NULL,
|
|
612
618
|
llm_content TEXT,
|
|
613
619
|
message_id TEXT UNIQUE,
|
|
620
|
+
attention_id TEXT,
|
|
621
|
+
delivery_state_json TEXT,
|
|
622
|
+
payload_json TEXT,
|
|
614
623
|
attempts INTEGER NOT NULL DEFAULT 0,
|
|
615
624
|
last_error TEXT,
|
|
616
625
|
created_at TEXT NOT NULL,
|
|
@@ -620,15 +629,19 @@ var init_session_store = __esm({
|
|
|
620
629
|
this.db.exec(`
|
|
621
630
|
INSERT INTO pending_gateway_deliveries (
|
|
622
631
|
id, kind, provider, session_key, job_id, content, llm_content,
|
|
623
|
-
message_id,
|
|
632
|
+
message_id, attention_id, delivery_state_json, payload_json,
|
|
633
|
+
attempts, last_error, created_at, last_attempt_at
|
|
624
634
|
)
|
|
625
635
|
SELECT
|
|
626
636
|
id, kind, provider, session_key, job_id, content, llm_content,
|
|
627
|
-
message_id, attempts, last_error, created_at, last_attempt_at
|
|
637
|
+
message_id, NULL, NULL, NULL, attempts, last_error, created_at, last_attempt_at
|
|
628
638
|
FROM pending_gateway_deliveries_old
|
|
629
639
|
`);
|
|
630
640
|
this.db.exec("DROP TABLE pending_gateway_deliveries_old");
|
|
631
641
|
}
|
|
642
|
+
pendingGatewayDeliveryKindCheck() {
|
|
643
|
+
return "kind IN ('session_send', 'chat_inject', 'dispatch_user_latest', 'prompt_user_latest')";
|
|
644
|
+
}
|
|
632
645
|
close() {
|
|
633
646
|
this.db.close();
|
|
634
647
|
}
|
|
@@ -1358,9 +1371,10 @@ var init_session_store = __esm({
|
|
|
1358
1371
|
this.db.prepare(`
|
|
1359
1372
|
INSERT INTO pending_gateway_deliveries (
|
|
1360
1373
|
id, kind, provider, session_key, job_id, content, llm_content,
|
|
1361
|
-
message_id,
|
|
1374
|
+
message_id, attention_id, delivery_state_json, payload_json,
|
|
1375
|
+
attempts, last_error, created_at, last_attempt_at
|
|
1362
1376
|
)
|
|
1363
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0, NULL, ?, NULL)
|
|
1377
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, NULL, ?, NULL)
|
|
1364
1378
|
`).run(
|
|
1365
1379
|
id,
|
|
1366
1380
|
input.kind,
|
|
@@ -1370,6 +1384,9 @@ var init_session_store = __esm({
|
|
|
1370
1384
|
input.content,
|
|
1371
1385
|
input.llmContent ?? null,
|
|
1372
1386
|
messageId,
|
|
1387
|
+
input.attentionId ?? null,
|
|
1388
|
+
input.deliveryStateJson ?? null,
|
|
1389
|
+
input.payloadJson ?? null,
|
|
1373
1390
|
createdAt
|
|
1374
1391
|
);
|
|
1375
1392
|
const row = this.getPendingGatewayDelivery(id);
|
|
@@ -1516,6 +1533,19 @@ async function readDaemonLock(lockPath) {
|
|
|
1516
1533
|
const running = Number.isInteger(metadata.pid) && metadata.pid > 0 && isProcessAlive(metadata.pid);
|
|
1517
1534
|
return { metadata, running, stale: !running, path: lockPath };
|
|
1518
1535
|
}
|
|
1536
|
+
async function markDaemonReady(lockPath) {
|
|
1537
|
+
const current = await readDaemonLock(lockPath);
|
|
1538
|
+
const metadata = current.metadata;
|
|
1539
|
+
if (!metadata || metadata.pid !== process.pid) {
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1542
|
+
await (0, import_promises.writeFile)(ownerPath(lockPath), `${JSON.stringify({
|
|
1543
|
+
...metadata,
|
|
1544
|
+
ready: true,
|
|
1545
|
+
readyAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1546
|
+
}, null, 2)}
|
|
1547
|
+
`, "utf8");
|
|
1548
|
+
}
|
|
1519
1549
|
async function removeLock(lockPath) {
|
|
1520
1550
|
await (0, import_promises.rm)(lockPath, { recursive: true, force: true });
|
|
1521
1551
|
}
|
|
@@ -1526,7 +1556,8 @@ async function acquireDaemonLock(paths, entry) {
|
|
|
1526
1556
|
cwd: process.cwd(),
|
|
1527
1557
|
entry,
|
|
1528
1558
|
homeDir: paths.homeDir,
|
|
1529
|
-
capabilities: DAEMON_CAPABILITIES
|
|
1559
|
+
capabilities: DAEMON_CAPABILITIES,
|
|
1560
|
+
ready: false
|
|
1530
1561
|
};
|
|
1531
1562
|
ensureTaskDir(paths.runDir);
|
|
1532
1563
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
@@ -1630,15 +1661,15 @@ async function ensureAiWorkspace(paths) {
|
|
|
1630
1661
|
return aiWorkingDir;
|
|
1631
1662
|
}
|
|
1632
1663
|
async function waitForImmediateExit(child, timeoutMs) {
|
|
1633
|
-
return await new Promise((
|
|
1664
|
+
return await new Promise((resolve8) => {
|
|
1634
1665
|
let timer;
|
|
1635
1666
|
const onExit = () => {
|
|
1636
1667
|
clearTimeout(timer);
|
|
1637
|
-
|
|
1668
|
+
resolve8(true);
|
|
1638
1669
|
};
|
|
1639
1670
|
timer = setTimeout(() => {
|
|
1640
1671
|
child.off("exit", onExit);
|
|
1641
|
-
|
|
1672
|
+
resolve8(false);
|
|
1642
1673
|
}, timeoutMs);
|
|
1643
1674
|
child.once("exit", onExit);
|
|
1644
1675
|
});
|
|
@@ -1648,12 +1679,17 @@ async function getDaemonStatus(homeDir) {
|
|
|
1648
1679
|
const pid = await readPid(paths.pidPath);
|
|
1649
1680
|
const lock = await readDaemonLock(paths.daemonLockPath);
|
|
1650
1681
|
const lockPid = lock.metadata?.pid ?? null;
|
|
1682
|
+
const lockReadyStateKnown = !!lock.metadata && (typeof lock.metadata.ready === "boolean" || typeof lock.metadata.readyAt === "string");
|
|
1683
|
+
const lockReady = lockReadyStateKnown ? lock.metadata?.ready === true || typeof lock.metadata?.readyAt === "string" : true;
|
|
1651
1684
|
if (lock.running) {
|
|
1652
1685
|
return {
|
|
1653
1686
|
running: true,
|
|
1654
1687
|
pid: lockPid ?? pid,
|
|
1655
1688
|
stale: false,
|
|
1656
1689
|
capabilities: lock.metadata?.capabilities ?? [],
|
|
1690
|
+
ready: lockReady,
|
|
1691
|
+
readyAt: lock.metadata?.readyAt ?? null,
|
|
1692
|
+
readyStateKnown: lockReadyStateKnown,
|
|
1657
1693
|
pidPath: paths.pidPath,
|
|
1658
1694
|
lockPath: paths.daemonLockPath,
|
|
1659
1695
|
lockPid,
|
|
@@ -1666,6 +1702,9 @@ async function getDaemonStatus(homeDir) {
|
|
|
1666
1702
|
pid: null,
|
|
1667
1703
|
stale: lock.stale,
|
|
1668
1704
|
capabilities: [],
|
|
1705
|
+
ready: false,
|
|
1706
|
+
readyAt: null,
|
|
1707
|
+
readyStateKnown: false,
|
|
1669
1708
|
pidPath: paths.pidPath,
|
|
1670
1709
|
lockPath: paths.daemonLockPath,
|
|
1671
1710
|
lockPid,
|
|
@@ -1678,6 +1717,9 @@ async function getDaemonStatus(homeDir) {
|
|
|
1678
1717
|
pid,
|
|
1679
1718
|
stale: !running || lock.stale,
|
|
1680
1719
|
capabilities: running ? lock.metadata?.capabilities ?? [] : [],
|
|
1720
|
+
ready: running && !lockReadyStateKnown ? true : running && lockReady,
|
|
1721
|
+
readyAt: running ? lock.metadata?.readyAt ?? null : null,
|
|
1722
|
+
readyStateKnown: running && lockReadyStateKnown,
|
|
1681
1723
|
pidPath: paths.pidPath,
|
|
1682
1724
|
lockPath: paths.daemonLockPath,
|
|
1683
1725
|
lockPid,
|
|
@@ -1743,6 +1785,9 @@ async function startDaemon(homeDir) {
|
|
|
1743
1785
|
pid: child.pid ?? null,
|
|
1744
1786
|
stale: false,
|
|
1745
1787
|
capabilities: DAEMON_CAPABILITIES,
|
|
1788
|
+
ready: false,
|
|
1789
|
+
readyAt: null,
|
|
1790
|
+
readyStateKnown: true,
|
|
1746
1791
|
pidPath: paths.pidPath,
|
|
1747
1792
|
lockPath: paths.daemonLockPath,
|
|
1748
1793
|
lockPid: child.pid ?? null,
|
|
@@ -1757,7 +1802,7 @@ async function waitForExit(pid, timeoutMs) {
|
|
|
1757
1802
|
if (!isProcessAlive(pid)) {
|
|
1758
1803
|
return true;
|
|
1759
1804
|
}
|
|
1760
|
-
await new Promise((
|
|
1805
|
+
await new Promise((resolve8) => setTimeout(resolve8, 100));
|
|
1761
1806
|
}
|
|
1762
1807
|
return !isProcessAlive(pid);
|
|
1763
1808
|
}
|
|
@@ -1786,6 +1831,9 @@ async function stopDaemon(homeDir) {
|
|
|
1786
1831
|
pid: current.pid,
|
|
1787
1832
|
stale: false,
|
|
1788
1833
|
capabilities: [],
|
|
1834
|
+
ready: false,
|
|
1835
|
+
readyAt: null,
|
|
1836
|
+
readyStateKnown: false,
|
|
1789
1837
|
pidPath: paths.pidPath,
|
|
1790
1838
|
lockPath: paths.daemonLockPath,
|
|
1791
1839
|
lockPid: current.lockPid,
|
|
@@ -1809,6 +1857,9 @@ async function stopDaemon(homeDir) {
|
|
|
1809
1857
|
pid: current.pid,
|
|
1810
1858
|
stale: false,
|
|
1811
1859
|
capabilities: exited ? [] : current.capabilities,
|
|
1860
|
+
ready: !exited && current.ready,
|
|
1861
|
+
readyAt: !exited ? current.readyAt : null,
|
|
1862
|
+
readyStateKnown: !exited && current.readyStateKnown,
|
|
1812
1863
|
pidPath: paths.pidPath,
|
|
1813
1864
|
lockPath: paths.daemonLockPath,
|
|
1814
1865
|
lockPid: current.lockPid,
|
|
@@ -1817,7 +1868,116 @@ async function stopDaemon(homeDir) {
|
|
|
1817
1868
|
forced
|
|
1818
1869
|
};
|
|
1819
1870
|
}
|
|
1820
|
-
|
|
1871
|
+
async function ensureDaemonReady(options = {}) {
|
|
1872
|
+
const paths = resolveTaskPaths(options.homeDir);
|
|
1873
|
+
const commandName = options.commandName ?? "command";
|
|
1874
|
+
const timeoutMs = options.timeoutMs ?? readReadyTimeoutMs(options.env ?? process.env);
|
|
1875
|
+
let status = await getDaemonStatus(options.homeDir);
|
|
1876
|
+
let started = false;
|
|
1877
|
+
let logPath = paths.listenerLogPath;
|
|
1878
|
+
if (!status.running) {
|
|
1879
|
+
options.stderr?.write(`[okx-a2a] ${commandName} requires the daemon; starting daemon...
|
|
1880
|
+
`);
|
|
1881
|
+
const startResult = await startDaemon(options.homeDir);
|
|
1882
|
+
started = startResult.started;
|
|
1883
|
+
logPath = startResult.logPath;
|
|
1884
|
+
status = startResult;
|
|
1885
|
+
if (!status.running) {
|
|
1886
|
+
throw new Error(
|
|
1887
|
+
`${commandName} requires the daemon, but automatic daemon start failed. Check ${logPath} or run \`okx-a2a daemon restart\`.`
|
|
1888
|
+
);
|
|
1889
|
+
}
|
|
1890
|
+
status = await waitForDaemonReady({
|
|
1891
|
+
homeDir: options.homeDir,
|
|
1892
|
+
timeoutMs,
|
|
1893
|
+
requiredCapabilities: options.requiredCapabilities,
|
|
1894
|
+
requireKnownReadyState: true,
|
|
1895
|
+
logPath,
|
|
1896
|
+
commandName
|
|
1897
|
+
});
|
|
1898
|
+
options.stderr?.write(`[okx-a2a] daemon ready pid=${status.pid ?? "(unknown)"} log=${logPath}
|
|
1899
|
+
`);
|
|
1900
|
+
} else if (status.readyStateKnown && !status.ready) {
|
|
1901
|
+
status = await waitForDaemonReady({
|
|
1902
|
+
homeDir: options.homeDir,
|
|
1903
|
+
timeoutMs,
|
|
1904
|
+
requiredCapabilities: options.requiredCapabilities,
|
|
1905
|
+
requireKnownReadyState: false,
|
|
1906
|
+
logPath,
|
|
1907
|
+
commandName
|
|
1908
|
+
});
|
|
1909
|
+
}
|
|
1910
|
+
assertRequiredCapabilities(status, options.requiredCapabilities, commandName);
|
|
1911
|
+
return {
|
|
1912
|
+
...status,
|
|
1913
|
+
started,
|
|
1914
|
+
logPath
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
async function waitForDaemonReady(options) {
|
|
1918
|
+
const deadline = Date.now() + Math.max(0, options.timeoutMs);
|
|
1919
|
+
let lastStatus = await getDaemonStatus(options.homeDir);
|
|
1920
|
+
while (Date.now() <= deadline) {
|
|
1921
|
+
const status = await getDaemonStatus(options.homeDir);
|
|
1922
|
+
lastStatus = status;
|
|
1923
|
+
if (!status.running) {
|
|
1924
|
+
if (status.stale) {
|
|
1925
|
+
throw new Error(
|
|
1926
|
+
`${options.commandName} requires the daemon, but the daemon exited before becoming ready. Check ${options.logPath} or run \`okx-a2a daemon restart\`.`
|
|
1927
|
+
);
|
|
1928
|
+
}
|
|
1929
|
+
} else if (isReadyForCommand(status, options.requiredCapabilities, options.requireKnownReadyState)) {
|
|
1930
|
+
return status;
|
|
1931
|
+
} else if (status.ready && findMissingCapabilities(status, options.requiredCapabilities).length > 0) {
|
|
1932
|
+
assertRequiredCapabilities(status, options.requiredCapabilities, options.commandName);
|
|
1933
|
+
}
|
|
1934
|
+
await sleep(Math.min(READY_POLL_MS, Math.max(1, deadline - Date.now() + 1)));
|
|
1935
|
+
}
|
|
1936
|
+
const missing = findMissingCapabilities(lastStatus, options.requiredCapabilities);
|
|
1937
|
+
const capabilitySuffix = missing.length > 0 ? ` missingCapabilities=${missing.join(",")}` : "";
|
|
1938
|
+
throw new Error(
|
|
1939
|
+
`${options.commandName} requires the daemon, but it did not become ready within ${options.timeoutMs}ms${capabilitySuffix}. Check ${options.logPath} or run \`okx-a2a daemon restart\`.`
|
|
1940
|
+
);
|
|
1941
|
+
}
|
|
1942
|
+
function isReadyForCommand(status, requiredCapabilities, requireKnownReadyState = false) {
|
|
1943
|
+
if (!status.running) {
|
|
1944
|
+
return false;
|
|
1945
|
+
}
|
|
1946
|
+
if (requireKnownReadyState && !status.readyStateKnown) {
|
|
1947
|
+
return false;
|
|
1948
|
+
}
|
|
1949
|
+
if (status.readyStateKnown && !status.ready) {
|
|
1950
|
+
return false;
|
|
1951
|
+
}
|
|
1952
|
+
return findMissingCapabilities(status, requiredCapabilities).length === 0;
|
|
1953
|
+
}
|
|
1954
|
+
function assertRequiredCapabilities(status, requiredCapabilities, commandName) {
|
|
1955
|
+
const missing = findMissingCapabilities(status, requiredCapabilities);
|
|
1956
|
+
if (missing.length === 0) {
|
|
1957
|
+
return;
|
|
1958
|
+
}
|
|
1959
|
+
throw new Error(
|
|
1960
|
+
`${commandName} requires a daemon with ${missing.join(",")} support. Run \`okx-a2a daemon restart\` first.`
|
|
1961
|
+
);
|
|
1962
|
+
}
|
|
1963
|
+
function findMissingCapabilities(status, requiredCapabilities) {
|
|
1964
|
+
if (!requiredCapabilities || requiredCapabilities.length === 0) {
|
|
1965
|
+
return [];
|
|
1966
|
+
}
|
|
1967
|
+
return requiredCapabilities.filter((capability) => !status.capabilities.includes(capability));
|
|
1968
|
+
}
|
|
1969
|
+
function readReadyTimeoutMs(env) {
|
|
1970
|
+
const raw = env[DAEMON_READY_TIMEOUT_ENV]?.trim();
|
|
1971
|
+
if (!raw) {
|
|
1972
|
+
return DEFAULT_READY_TIMEOUT_MS;
|
|
1973
|
+
}
|
|
1974
|
+
const parsed = Number(raw);
|
|
1975
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_READY_TIMEOUT_MS;
|
|
1976
|
+
}
|
|
1977
|
+
function sleep(ms) {
|
|
1978
|
+
return new Promise((resolve8) => setTimeout(resolve8, ms));
|
|
1979
|
+
}
|
|
1980
|
+
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;
|
|
1821
1981
|
var init_daemon = __esm({
|
|
1822
1982
|
"src/daemon.ts"() {
|
|
1823
1983
|
"use strict";
|
|
@@ -1831,6 +1991,9 @@ var init_daemon = __esm({
|
|
|
1831
1991
|
STOP_GRACE_MS = 5e3;
|
|
1832
1992
|
FORCE_KILL_GRACE_MS = 5e3;
|
|
1833
1993
|
START_EXIT_CHECK_MS = 750;
|
|
1994
|
+
DEFAULT_READY_TIMEOUT_MS = 12e4;
|
|
1995
|
+
READY_POLL_MS = 250;
|
|
1996
|
+
DAEMON_READY_TIMEOUT_ENV = "OKX_A2A_DAEMON_READY_TIMEOUT_MS";
|
|
1834
1997
|
}
|
|
1835
1998
|
});
|
|
1836
1999
|
|
|
@@ -2077,7 +2240,7 @@ var init_command_store = __esm({
|
|
|
2077
2240
|
if (result) {
|
|
2078
2241
|
return result;
|
|
2079
2242
|
}
|
|
2080
|
-
await new Promise((
|
|
2243
|
+
await new Promise((resolve8) => setTimeout(resolve8, 500));
|
|
2081
2244
|
}
|
|
2082
2245
|
return null;
|
|
2083
2246
|
}
|
|
@@ -3175,7 +3338,7 @@ async function promptForAiProviderWithArrows(options) {
|
|
|
3175
3338
|
options.stdin.resume();
|
|
3176
3339
|
options.stdout.write("\x1B[?25l");
|
|
3177
3340
|
render();
|
|
3178
|
-
return await new Promise((
|
|
3341
|
+
return await new Promise((resolve8, reject) => {
|
|
3179
3342
|
const cleanup = () => {
|
|
3180
3343
|
options.stdin.off("keypress", onKeypress);
|
|
3181
3344
|
options.stdin.setRawMode(false);
|
|
@@ -3194,7 +3357,7 @@ async function promptForAiProviderWithArrows(options) {
|
|
|
3194
3357
|
clearRendered();
|
|
3195
3358
|
options.stdout.write(`Selected AI provider: ${provider}
|
|
3196
3359
|
`);
|
|
3197
|
-
|
|
3360
|
+
resolve8(provider);
|
|
3198
3361
|
};
|
|
3199
3362
|
const onKeypress = (_str, key) => {
|
|
3200
3363
|
if (key.ctrl && key.name === "c") {
|
|
@@ -3311,14 +3474,14 @@ async function startUserAttentionEventServer(options = {}) {
|
|
|
3311
3474
|
}
|
|
3312
3475
|
}
|
|
3313
3476
|
}
|
|
3314
|
-
await new Promise((
|
|
3477
|
+
await new Promise((resolve8, reject) => {
|
|
3315
3478
|
const onError = (err2) => {
|
|
3316
3479
|
server.off("listening", onListening);
|
|
3317
3480
|
reject(err2);
|
|
3318
3481
|
};
|
|
3319
3482
|
const onListening = () => {
|
|
3320
3483
|
server.off("error", onError);
|
|
3321
|
-
|
|
3484
|
+
resolve8();
|
|
3322
3485
|
};
|
|
3323
3486
|
server.once("error", onError);
|
|
3324
3487
|
server.once("listening", onListening);
|
|
@@ -3333,7 +3496,7 @@ async function startUserAttentionEventServer(options = {}) {
|
|
|
3333
3496
|
for (const socket of sockets) {
|
|
3334
3497
|
socket.destroy();
|
|
3335
3498
|
}
|
|
3336
|
-
return new Promise((
|
|
3499
|
+
return new Promise((resolve8, reject) => {
|
|
3337
3500
|
server.close((err2) => {
|
|
3338
3501
|
if (process.platform !== "win32") {
|
|
3339
3502
|
try {
|
|
@@ -3344,7 +3507,7 @@ async function startUserAttentionEventServer(options = {}) {
|
|
|
3344
3507
|
if (err2) {
|
|
3345
3508
|
reject(err2);
|
|
3346
3509
|
} else {
|
|
3347
|
-
|
|
3510
|
+
resolve8();
|
|
3348
3511
|
}
|
|
3349
3512
|
});
|
|
3350
3513
|
});
|
|
@@ -3353,7 +3516,7 @@ async function startUserAttentionEventServer(options = {}) {
|
|
|
3353
3516
|
}
|
|
3354
3517
|
async function subscribeUserAttentionEvents(options) {
|
|
3355
3518
|
const path = resolveUserAttentionIpcPath(options.homeDir);
|
|
3356
|
-
return new Promise((
|
|
3519
|
+
return new Promise((resolve8) => {
|
|
3357
3520
|
const socket = (0, import_node_net.createConnection)(path);
|
|
3358
3521
|
let settled = false;
|
|
3359
3522
|
let buffer2 = "";
|
|
@@ -3362,7 +3525,7 @@ async function subscribeUserAttentionEvents(options) {
|
|
|
3362
3525
|
return;
|
|
3363
3526
|
}
|
|
3364
3527
|
settled = true;
|
|
3365
|
-
|
|
3528
|
+
resolve8({
|
|
3366
3529
|
path,
|
|
3367
3530
|
connected,
|
|
3368
3531
|
close() {
|
|
@@ -3394,7 +3557,7 @@ async function subscribeUserAttentionEvents(options) {
|
|
|
3394
3557
|
}
|
|
3395
3558
|
async function notifyUserAttentionChanged(homeDir) {
|
|
3396
3559
|
const path = resolveUserAttentionIpcPath(homeDir);
|
|
3397
|
-
return new Promise((
|
|
3560
|
+
return new Promise((resolve8) => {
|
|
3398
3561
|
const socket = (0, import_node_net.createConnection)(path);
|
|
3399
3562
|
let done = false;
|
|
3400
3563
|
const finish = (ok) => {
|
|
@@ -3403,7 +3566,7 @@ async function notifyUserAttentionChanged(homeDir) {
|
|
|
3403
3566
|
}
|
|
3404
3567
|
done = true;
|
|
3405
3568
|
socket.destroy();
|
|
3406
|
-
|
|
3569
|
+
resolve8(ok);
|
|
3407
3570
|
};
|
|
3408
3571
|
socket.setTimeout(1e3, () => finish(false));
|
|
3409
3572
|
socket.once("connect", () => {
|
|
@@ -7271,7 +7434,7 @@ async function callOpenClawGateway(opts) {
|
|
|
7271
7434
|
errorWithTimestamp(
|
|
7272
7435
|
`${LOG_PREFIX} rpc retry method=${opts.method} attempt=${attempt + 1} delayMs=${delayMs}: ${message}`
|
|
7273
7436
|
);
|
|
7274
|
-
await
|
|
7437
|
+
await sleep2(delayMs);
|
|
7275
7438
|
continue;
|
|
7276
7439
|
}
|
|
7277
7440
|
errorWithTimestamp(
|
|
@@ -7347,8 +7510,8 @@ function isGatewayStartingError(err2) {
|
|
|
7347
7510
|
const e = err2;
|
|
7348
7511
|
return String(e?.details?.reason ?? "") === "startup-sidecars" || String(e?.message ?? "").toLowerCase().includes("gateway starting");
|
|
7349
7512
|
}
|
|
7350
|
-
async function
|
|
7351
|
-
await new Promise((
|
|
7513
|
+
async function sleep2(ms) {
|
|
7514
|
+
await new Promise((resolve8) => setTimeout(resolve8, ms));
|
|
7352
7515
|
}
|
|
7353
7516
|
function readSyncedGatewayConfig(env) {
|
|
7354
7517
|
try {
|
|
@@ -7373,7 +7536,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
7373
7536
|
client: {
|
|
7374
7537
|
id: "gateway-client",
|
|
7375
7538
|
displayName: "okx-a2a-node",
|
|
7376
|
-
version: "0.0.
|
|
7539
|
+
version: "0.0.17-beta-db5dca184d-260624150845",
|
|
7377
7540
|
platform: "node",
|
|
7378
7541
|
mode: "backend",
|
|
7379
7542
|
instanceId
|
|
@@ -7384,7 +7547,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
7384
7547
|
commands: [],
|
|
7385
7548
|
permissions: {},
|
|
7386
7549
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
7387
|
-
userAgent: `okx-a2a-node/${"0.0.
|
|
7550
|
+
userAgent: `okx-a2a-node/${"0.0.17-beta-db5dca184d-260624150845"}`,
|
|
7388
7551
|
auth: {
|
|
7389
7552
|
...config.token ? { token: config.token } : {},
|
|
7390
7553
|
...config.password ? { password: config.password } : {}
|
|
@@ -7489,7 +7652,7 @@ var init_openclaw_gateway = __esm({
|
|
|
7489
7652
|
);
|
|
7490
7653
|
const ws = wsFactory(this.config.url);
|
|
7491
7654
|
this.ws = ws;
|
|
7492
|
-
await new Promise((
|
|
7655
|
+
await new Promise((resolve8, reject) => {
|
|
7493
7656
|
let settled = false;
|
|
7494
7657
|
const timer = setTimeout(() => {
|
|
7495
7658
|
if (settled) {
|
|
@@ -7508,7 +7671,7 @@ var init_openclaw_gateway = __esm({
|
|
|
7508
7671
|
}
|
|
7509
7672
|
settled = true;
|
|
7510
7673
|
clearTimeout(timer);
|
|
7511
|
-
|
|
7674
|
+
resolve8();
|
|
7512
7675
|
},
|
|
7513
7676
|
(err2) => {
|
|
7514
7677
|
if (settled) {
|
|
@@ -7560,7 +7723,7 @@ var init_openclaw_gateway = __esm({
|
|
|
7560
7723
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
7561
7724
|
const id = `okx-a2a-${++this.requestSeq}-${(0, import_node_crypto3.randomUUID)()}`;
|
|
7562
7725
|
const frame = { type: "req", id, method, params };
|
|
7563
|
-
return new Promise((
|
|
7726
|
+
return new Promise((resolve8, reject) => {
|
|
7564
7727
|
const timer = setTimeout(() => {
|
|
7565
7728
|
this.pending.delete(id);
|
|
7566
7729
|
reject(Object.assign(new Error(`OpenClaw gateway request timed out method=${method}`), {
|
|
@@ -7569,7 +7732,7 @@ var init_openclaw_gateway = __esm({
|
|
|
7569
7732
|
}));
|
|
7570
7733
|
}, timeoutMs);
|
|
7571
7734
|
timer.unref?.();
|
|
7572
|
-
this.pending.set(id, { method, resolve:
|
|
7735
|
+
this.pending.set(id, { method, resolve: resolve8, reject, timer });
|
|
7573
7736
|
try {
|
|
7574
7737
|
this.ws.send(JSON.stringify(frame));
|
|
7575
7738
|
} catch (err2) {
|
|
@@ -9864,7 +10027,7 @@ var require_path = __commonJS({
|
|
|
9864
10027
|
const parts = splitPathRe.exec(truncated);
|
|
9865
10028
|
return parts ? parts.slice(1) : [];
|
|
9866
10029
|
}
|
|
9867
|
-
function
|
|
10030
|
+
function resolve8(...args) {
|
|
9868
10031
|
let resolvedPath = "";
|
|
9869
10032
|
let resolvedAbsolute = false;
|
|
9870
10033
|
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
@@ -9900,8 +10063,8 @@ var require_path = __commonJS({
|
|
|
9900
10063
|
return arr.slice(start, end - start + 1);
|
|
9901
10064
|
}
|
|
9902
10065
|
function relative(from3, to) {
|
|
9903
|
-
from3 =
|
|
9904
|
-
to =
|
|
10066
|
+
from3 = resolve8(from3).slice(1);
|
|
10067
|
+
to = resolve8(to).slice(1);
|
|
9905
10068
|
const fromParts = trim2(from3.split("/"));
|
|
9906
10069
|
const toParts = trim2(to.split("/"));
|
|
9907
10070
|
const length2 = Math.min(fromParts.length, toParts.length);
|
|
@@ -9937,7 +10100,7 @@ var require_path = __commonJS({
|
|
|
9937
10100
|
function isAbsolute2(path) {
|
|
9938
10101
|
return path.charAt(0) === "/";
|
|
9939
10102
|
}
|
|
9940
|
-
function
|
|
10103
|
+
function join22(...args) {
|
|
9941
10104
|
return normalizePath(args.join("/"));
|
|
9942
10105
|
}
|
|
9943
10106
|
function dirname6(path) {
|
|
@@ -9962,10 +10125,10 @@ var require_path = __commonJS({
|
|
|
9962
10125
|
exports2.basename = basename5;
|
|
9963
10126
|
exports2.dirname = dirname6;
|
|
9964
10127
|
exports2.isAbsolute = isAbsolute2;
|
|
9965
|
-
exports2.join =
|
|
10128
|
+
exports2.join = join22;
|
|
9966
10129
|
exports2.normalizePath = normalizePath;
|
|
9967
10130
|
exports2.relative = relative;
|
|
9968
|
-
exports2.resolve =
|
|
10131
|
+
exports2.resolve = resolve8;
|
|
9969
10132
|
}
|
|
9970
10133
|
});
|
|
9971
10134
|
|
|
@@ -9984,8 +10147,8 @@ var require_syncpromise = __commonJS({
|
|
|
9984
10147
|
States2[States2["REJECTED"] = REJECTED] = "REJECTED";
|
|
9985
10148
|
})(States || (States = {}));
|
|
9986
10149
|
function resolvedSyncPromise(value) {
|
|
9987
|
-
return new SyncPromise((
|
|
9988
|
-
|
|
10150
|
+
return new SyncPromise((resolve8) => {
|
|
10151
|
+
resolve8(value);
|
|
9989
10152
|
});
|
|
9990
10153
|
}
|
|
9991
10154
|
function rejectedSyncPromise(reason) {
|
|
@@ -10009,15 +10172,15 @@ var require_syncpromise = __commonJS({
|
|
|
10009
10172
|
}
|
|
10010
10173
|
/** JSDoc */
|
|
10011
10174
|
then(onfulfilled, onrejected) {
|
|
10012
|
-
return new _SyncPromise((
|
|
10175
|
+
return new _SyncPromise((resolve8, reject) => {
|
|
10013
10176
|
this._handlers.push([
|
|
10014
10177
|
false,
|
|
10015
10178
|
(result) => {
|
|
10016
10179
|
if (!onfulfilled) {
|
|
10017
|
-
|
|
10180
|
+
resolve8(result);
|
|
10018
10181
|
} else {
|
|
10019
10182
|
try {
|
|
10020
|
-
|
|
10183
|
+
resolve8(onfulfilled(result));
|
|
10021
10184
|
} catch (e) {
|
|
10022
10185
|
reject(e);
|
|
10023
10186
|
}
|
|
@@ -10028,7 +10191,7 @@ var require_syncpromise = __commonJS({
|
|
|
10028
10191
|
reject(reason);
|
|
10029
10192
|
} else {
|
|
10030
10193
|
try {
|
|
10031
|
-
|
|
10194
|
+
resolve8(onrejected(reason));
|
|
10032
10195
|
} catch (e) {
|
|
10033
10196
|
reject(e);
|
|
10034
10197
|
}
|
|
@@ -10044,7 +10207,7 @@ var require_syncpromise = __commonJS({
|
|
|
10044
10207
|
}
|
|
10045
10208
|
/** JSDoc */
|
|
10046
10209
|
finally(onfinally) {
|
|
10047
|
-
return new _SyncPromise((
|
|
10210
|
+
return new _SyncPromise((resolve8, reject) => {
|
|
10048
10211
|
let val;
|
|
10049
10212
|
let isRejected;
|
|
10050
10213
|
return this.then(
|
|
@@ -10067,7 +10230,7 @@ var require_syncpromise = __commonJS({
|
|
|
10067
10230
|
reject(val);
|
|
10068
10231
|
return;
|
|
10069
10232
|
}
|
|
10070
|
-
|
|
10233
|
+
resolve8(val);
|
|
10071
10234
|
});
|
|
10072
10235
|
});
|
|
10073
10236
|
}
|
|
@@ -10157,21 +10320,21 @@ var require_promisebuffer = __commonJS({
|
|
|
10157
10320
|
return task;
|
|
10158
10321
|
}
|
|
10159
10322
|
function drain(timeout) {
|
|
10160
|
-
return new syncpromise.SyncPromise((
|
|
10323
|
+
return new syncpromise.SyncPromise((resolve8, reject) => {
|
|
10161
10324
|
let counter = buffer2.length;
|
|
10162
10325
|
if (!counter) {
|
|
10163
|
-
return
|
|
10326
|
+
return resolve8(true);
|
|
10164
10327
|
}
|
|
10165
10328
|
const capturedSetTimeout = setTimeout(() => {
|
|
10166
10329
|
if (timeout && timeout > 0) {
|
|
10167
|
-
|
|
10330
|
+
resolve8(false);
|
|
10168
10331
|
}
|
|
10169
10332
|
}, timeout);
|
|
10170
10333
|
buffer2.forEach((item) => {
|
|
10171
10334
|
void syncpromise.resolvedSyncPromise(item).then(() => {
|
|
10172
10335
|
if (!--counter) {
|
|
10173
10336
|
clearTimeout(capturedSetTimeout);
|
|
10174
|
-
|
|
10337
|
+
resolve8(true);
|
|
10175
10338
|
}
|
|
10176
10339
|
}, reject);
|
|
10177
10340
|
});
|
|
@@ -11373,17 +11536,17 @@ var require_eventProcessors = __commonJS({
|
|
|
11373
11536
|
getGlobalEventProcessors().push(callback);
|
|
11374
11537
|
}
|
|
11375
11538
|
function notifyEventProcessors(processors, event, hint, index2 = 0) {
|
|
11376
|
-
return new utils.SyncPromise((
|
|
11539
|
+
return new utils.SyncPromise((resolve8, reject) => {
|
|
11377
11540
|
const processor = processors[index2];
|
|
11378
11541
|
if (event === null || typeof processor !== "function") {
|
|
11379
|
-
|
|
11542
|
+
resolve8(event);
|
|
11380
11543
|
} else {
|
|
11381
11544
|
const result = processor({ ...event }, hint);
|
|
11382
11545
|
(typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) && processor.id && result === null && utils.logger.log(`Event processor "${processor.id}" dropped event`);
|
|
11383
11546
|
if (utils.isThenable(result)) {
|
|
11384
|
-
void result.then((final) => notifyEventProcessors(processors, final, hint, index2 + 1).then(
|
|
11547
|
+
void result.then((final) => notifyEventProcessors(processors, final, hint, index2 + 1).then(resolve8)).then(null, reject);
|
|
11385
11548
|
} else {
|
|
11386
|
-
void notifyEventProcessors(processors, result, hint, index2 + 1).then(
|
|
11549
|
+
void notifyEventProcessors(processors, result, hint, index2 + 1).then(resolve8).then(null, reject);
|
|
11387
11550
|
}
|
|
11388
11551
|
}
|
|
11389
11552
|
});
|
|
@@ -14537,18 +14700,18 @@ var require_baseclient = __commonJS({
|
|
|
14537
14700
|
* `false` otherwise
|
|
14538
14701
|
*/
|
|
14539
14702
|
_isClientDoneProcessing(timeout) {
|
|
14540
|
-
return new utils.SyncPromise((
|
|
14703
|
+
return new utils.SyncPromise((resolve8) => {
|
|
14541
14704
|
let ticked = 0;
|
|
14542
14705
|
const tick = 1;
|
|
14543
14706
|
const interval = setInterval(() => {
|
|
14544
14707
|
if (this._numProcessing == 0) {
|
|
14545
14708
|
clearInterval(interval);
|
|
14546
|
-
|
|
14709
|
+
resolve8(true);
|
|
14547
14710
|
} else {
|
|
14548
14711
|
ticked += tick;
|
|
14549
14712
|
if (timeout && ticked >= timeout) {
|
|
14550
14713
|
clearInterval(interval);
|
|
14551
|
-
|
|
14714
|
+
resolve8(false);
|
|
14552
14715
|
}
|
|
14553
14716
|
}
|
|
14554
14717
|
}, tick);
|
|
@@ -19196,20 +19359,20 @@ var require_promisify = __commonJS({
|
|
|
19196
19359
|
"../../node_modules/agent-base/dist/src/promisify.js"(exports2) {
|
|
19197
19360
|
"use strict";
|
|
19198
19361
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
19199
|
-
function
|
|
19362
|
+
function promisify3(fn) {
|
|
19200
19363
|
return function(req, opts) {
|
|
19201
|
-
return new Promise((
|
|
19364
|
+
return new Promise((resolve8, reject) => {
|
|
19202
19365
|
fn.call(this, req, opts, (err2, rtn) => {
|
|
19203
19366
|
if (err2) {
|
|
19204
19367
|
reject(err2);
|
|
19205
19368
|
} else {
|
|
19206
|
-
|
|
19369
|
+
resolve8(rtn);
|
|
19207
19370
|
}
|
|
19208
19371
|
});
|
|
19209
19372
|
});
|
|
19210
19373
|
};
|
|
19211
19374
|
}
|
|
19212
|
-
exports2.default =
|
|
19375
|
+
exports2.default = promisify3;
|
|
19213
19376
|
}
|
|
19214
19377
|
});
|
|
19215
19378
|
|
|
@@ -19407,7 +19570,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
19407
19570
|
var debug_1 = __importDefault(require_src());
|
|
19408
19571
|
var debug = debug_1.default("https-proxy-agent:parse-proxy-response");
|
|
19409
19572
|
function parseProxyResponse(socket) {
|
|
19410
|
-
return new Promise((
|
|
19573
|
+
return new Promise((resolve8, reject) => {
|
|
19411
19574
|
let buffersLength = 0;
|
|
19412
19575
|
const buffers = [];
|
|
19413
19576
|
function read2() {
|
|
@@ -19447,7 +19610,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
19447
19610
|
const firstLine = buffered.toString("ascii", 0, buffered.indexOf("\r\n"));
|
|
19448
19611
|
const statusCode = +firstLine.split(" ")[1];
|
|
19449
19612
|
debug("got proxy server response: %o", firstLine);
|
|
19450
|
-
|
|
19613
|
+
resolve8({
|
|
19451
19614
|
statusCode,
|
|
19452
19615
|
buffered
|
|
19453
19616
|
});
|
|
@@ -19468,11 +19631,11 @@ var require_agent = __commonJS({
|
|
|
19468
19631
|
"use strict";
|
|
19469
19632
|
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
19470
19633
|
function adopt(value) {
|
|
19471
|
-
return value instanceof P2 ? value : new P2(function(
|
|
19472
|
-
|
|
19634
|
+
return value instanceof P2 ? value : new P2(function(resolve8) {
|
|
19635
|
+
resolve8(value);
|
|
19473
19636
|
});
|
|
19474
19637
|
}
|
|
19475
|
-
return new (P2 || (P2 = Promise))(function(
|
|
19638
|
+
return new (P2 || (P2 = Promise))(function(resolve8, reject) {
|
|
19476
19639
|
function fulfilled(value) {
|
|
19477
19640
|
try {
|
|
19478
19641
|
step(generator.next(value));
|
|
@@ -19488,7 +19651,7 @@ var require_agent = __commonJS({
|
|
|
19488
19651
|
}
|
|
19489
19652
|
}
|
|
19490
19653
|
function step(result) {
|
|
19491
|
-
result.done ?
|
|
19654
|
+
result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
19492
19655
|
}
|
|
19493
19656
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19494
19657
|
});
|
|
@@ -19699,7 +19862,7 @@ var require_http = __commonJS({
|
|
|
19699
19862
|
function createRequestExecutor(options, httpModule, agent) {
|
|
19700
19863
|
const { hostname, pathname, port, protocol, search } = new url.URL(options.url);
|
|
19701
19864
|
return function makeRequest(request) {
|
|
19702
|
-
return new Promise((
|
|
19865
|
+
return new Promise((resolve8, reject) => {
|
|
19703
19866
|
let body = streamFromBody(request.body);
|
|
19704
19867
|
const headers = { ...options.headers };
|
|
19705
19868
|
if (request.body.length > GZIP_THRESHOLD) {
|
|
@@ -19725,7 +19888,7 @@ var require_http = __commonJS({
|
|
|
19725
19888
|
res.setEncoding("utf8");
|
|
19726
19889
|
const retryAfterHeader = _nullishCoalesce(res.headers["retry-after"], () => null);
|
|
19727
19890
|
const rateLimitsHeader = _nullishCoalesce(res.headers["x-sentry-rate-limits"], () => null);
|
|
19728
|
-
|
|
19891
|
+
resolve8({
|
|
19729
19892
|
statusCode: res.statusCode,
|
|
19730
19893
|
headers: {
|
|
19731
19894
|
"retry-after": retryAfterHeader,
|
|
@@ -19993,7 +20156,7 @@ var require_websocket2 = __commonJS({
|
|
|
19993
20156
|
};
|
|
19994
20157
|
async function createWebSocketClient(rawUrl) {
|
|
19995
20158
|
const parts = url.parse(rawUrl);
|
|
19996
|
-
return new Promise((
|
|
20159
|
+
return new Promise((resolve8, reject) => {
|
|
19997
20160
|
const key = crypto3.randomBytes(16).toString("base64");
|
|
19998
20161
|
const digest2 = createKey(key);
|
|
19999
20162
|
const req = http2.request({
|
|
@@ -20024,7 +20187,7 @@ var require_websocket2 = __commonJS({
|
|
|
20024
20187
|
return;
|
|
20025
20188
|
}
|
|
20026
20189
|
const client = new WebSocketInterface(socket);
|
|
20027
|
-
|
|
20190
|
+
resolve8(client);
|
|
20028
20191
|
});
|
|
20029
20192
|
req.on("error", (err2) => {
|
|
20030
20193
|
reject(err2);
|
|
@@ -21353,10 +21516,10 @@ var require_contextlines = __commonJS({
|
|
|
21353
21516
|
var FILE_CONTENT_CACHE = new lru_map.LRUMap(100);
|
|
21354
21517
|
var DEFAULT_LINES_OF_CONTEXT = 7;
|
|
21355
21518
|
function readTextFileAsync(path) {
|
|
21356
|
-
return new Promise((
|
|
21519
|
+
return new Promise((resolve8, reject) => {
|
|
21357
21520
|
fs.readFile(path, "utf8", (err2, data) => {
|
|
21358
21521
|
if (err2) reject(err2);
|
|
21359
|
-
else
|
|
21522
|
+
else resolve8(data);
|
|
21360
21523
|
});
|
|
21361
21524
|
});
|
|
21362
21525
|
}
|
|
@@ -21666,13 +21829,13 @@ var require_context = __commonJS({
|
|
|
21666
21829
|
version: `10.${Number(os.release().split(".")[0]) - 4}`
|
|
21667
21830
|
};
|
|
21668
21831
|
try {
|
|
21669
|
-
const output4 = await new Promise((
|
|
21832
|
+
const output4 = await new Promise((resolve8, reject) => {
|
|
21670
21833
|
child_process.execFile("/usr/bin/sw_vers", (error, stdout) => {
|
|
21671
21834
|
if (error) {
|
|
21672
21835
|
reject(error);
|
|
21673
21836
|
return;
|
|
21674
21837
|
}
|
|
21675
|
-
|
|
21838
|
+
resolve8(stdout);
|
|
21676
21839
|
});
|
|
21677
21840
|
});
|
|
21678
21841
|
darwinInfo.name = matchFirst(/^ProductName:\s+(.*)$/m, output4);
|
|
@@ -24529,14 +24692,242 @@ var init_sentry_config = __esm({
|
|
|
24529
24692
|
environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
24530
24693
|
SENTRY_CONFIG = {
|
|
24531
24694
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
24532
|
-
release: "0.0.
|
|
24695
|
+
release: "0.0.17-beta-db5dca184d-260624150845",
|
|
24533
24696
|
environment
|
|
24534
24697
|
};
|
|
24535
24698
|
}
|
|
24536
24699
|
});
|
|
24537
24700
|
|
|
24701
|
+
// src/autostart.ts
|
|
24702
|
+
var autostart_exports = {};
|
|
24703
|
+
__export(autostart_exports, {
|
|
24704
|
+
autostartStatus: () => autostartStatus,
|
|
24705
|
+
buildLaunchdPlist: () => buildLaunchdPlist,
|
|
24706
|
+
buildSystemdUserService: () => buildSystemdUserService,
|
|
24707
|
+
installAutostart: () => installAutostart,
|
|
24708
|
+
installLaunchdAutostart: () => installLaunchdAutostart,
|
|
24709
|
+
installSystemdAutostart: () => installSystemdAutostart,
|
|
24710
|
+
printLaunchdPlist: () => printLaunchdPlist,
|
|
24711
|
+
printSystemdAutostartUnit: () => printSystemdAutostartUnit,
|
|
24712
|
+
resolveLaunchdAutostartPaths: () => resolveLaunchdAutostartPaths,
|
|
24713
|
+
resolveSystemdAutostartPaths: () => resolveSystemdAutostartPaths,
|
|
24714
|
+
uninstallAutostart: () => uninstallAutostart,
|
|
24715
|
+
uninstallLaunchdAutostart: () => uninstallLaunchdAutostart,
|
|
24716
|
+
uninstallSystemdAutostart: () => uninstallSystemdAutostart
|
|
24717
|
+
});
|
|
24718
|
+
function resolveSystemdAutostartPaths(home = (0, import_node_os4.homedir)()) {
|
|
24719
|
+
const serviceDir = (0, import_node_path13.join)(home, ".config", "systemd", "user");
|
|
24720
|
+
return {
|
|
24721
|
+
serviceDir,
|
|
24722
|
+
servicePath: (0, import_node_path13.join)(serviceDir, SERVICE_NAME)
|
|
24723
|
+
};
|
|
24724
|
+
}
|
|
24725
|
+
function resolveLaunchdAutostartPaths(home = (0, import_node_os4.homedir)()) {
|
|
24726
|
+
const agentDir = (0, import_node_path13.join)(home, "Library", "LaunchAgents");
|
|
24727
|
+
return {
|
|
24728
|
+
agentDir,
|
|
24729
|
+
plistPath: (0, import_node_path13.join)(agentDir, LAUNCHD_PLIST_NAME)
|
|
24730
|
+
};
|
|
24731
|
+
}
|
|
24732
|
+
function quoteSystemdArg(value) {
|
|
24733
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
24734
|
+
}
|
|
24735
|
+
function escapeXml(value) {
|
|
24736
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
24737
|
+
}
|
|
24738
|
+
function resolveCliPath() {
|
|
24739
|
+
const entry = process.argv[1];
|
|
24740
|
+
if (!entry) {
|
|
24741
|
+
throw new Error("Unable to resolve current okx-a2a CLI path");
|
|
24742
|
+
}
|
|
24743
|
+
return (0, import_node_path13.resolve)(entry);
|
|
24744
|
+
}
|
|
24745
|
+
function buildSystemdUserService() {
|
|
24746
|
+
const taskHome2 = resolveTaskHome();
|
|
24747
|
+
const pathValue = process.env.PATH?.trim() || "/usr/local/bin:/usr/bin:/bin";
|
|
24748
|
+
const execStart = [
|
|
24749
|
+
quoteSystemdArg(process.execPath),
|
|
24750
|
+
quoteSystemdArg(resolveCliPath()),
|
|
24751
|
+
"run"
|
|
24752
|
+
].join(" ");
|
|
24753
|
+
return `[Unit]
|
|
24754
|
+
Description=OKX A2A daemon
|
|
24755
|
+
After=default.target
|
|
24756
|
+
|
|
24757
|
+
[Service]
|
|
24758
|
+
Type=simple
|
|
24759
|
+
ExecStart=${execStart}
|
|
24760
|
+
Restart=always
|
|
24761
|
+
RestartSec=5
|
|
24762
|
+
Environment=${quoteSystemdArg(`PATH=${pathValue}`)}
|
|
24763
|
+
Environment=${quoteSystemdArg(`OKX_AGENT_TASK_HOME=${taskHome2}`)}
|
|
24764
|
+
|
|
24765
|
+
[Install]
|
|
24766
|
+
WantedBy=default.target
|
|
24767
|
+
`;
|
|
24768
|
+
}
|
|
24769
|
+
function buildLaunchdPlist() {
|
|
24770
|
+
const paths = resolveTaskPaths();
|
|
24771
|
+
const pathValue = process.env.PATH?.trim() || "/usr/local/bin:/usr/bin:/bin";
|
|
24772
|
+
const args = [process.execPath, resolveCliPath(), "run"];
|
|
24773
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
24774
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
24775
|
+
<plist version="1.0">
|
|
24776
|
+
<dict>
|
|
24777
|
+
<key>Label</key>
|
|
24778
|
+
<string>${LAUNCHD_LABEL}</string>
|
|
24779
|
+
<key>ProgramArguments</key>
|
|
24780
|
+
<array>
|
|
24781
|
+
${args.map((arg) => ` <string>${escapeXml(arg)}</string>`).join("\n")}
|
|
24782
|
+
</array>
|
|
24783
|
+
<key>EnvironmentVariables</key>
|
|
24784
|
+
<dict>
|
|
24785
|
+
<key>PATH</key>
|
|
24786
|
+
<string>${escapeXml(pathValue)}</string>
|
|
24787
|
+
<key>OKX_AGENT_TASK_HOME</key>
|
|
24788
|
+
<string>${escapeXml(paths.homeDir)}</string>
|
|
24789
|
+
</dict>
|
|
24790
|
+
<key>RunAtLoad</key>
|
|
24791
|
+
<true/>
|
|
24792
|
+
<key>KeepAlive</key>
|
|
24793
|
+
<true/>
|
|
24794
|
+
<key>StandardOutPath</key>
|
|
24795
|
+
<string>${escapeXml(paths.listenerLogPath)}</string>
|
|
24796
|
+
<key>StandardErrorPath</key>
|
|
24797
|
+
<string>${escapeXml(paths.listenerLogPath)}</string>
|
|
24798
|
+
</dict>
|
|
24799
|
+
</plist>
|
|
24800
|
+
`;
|
|
24801
|
+
}
|
|
24802
|
+
async function runSystemctl(args) {
|
|
24803
|
+
try {
|
|
24804
|
+
return await execFileAsync("systemctl", ["--user", ...args], {
|
|
24805
|
+
timeout: 3e4,
|
|
24806
|
+
env: process.env
|
|
24807
|
+
});
|
|
24808
|
+
} catch (err2) {
|
|
24809
|
+
const e = err2;
|
|
24810
|
+
const stdout = String(e.stdout ?? "");
|
|
24811
|
+
const stderr = String(e.stderr ?? e.message ?? err2);
|
|
24812
|
+
throw new Error(`systemctl --user ${args.join(" ")} failed: ${(stderr || stdout).trim()}`);
|
|
24813
|
+
}
|
|
24814
|
+
}
|
|
24815
|
+
async function runLaunchctl(args, options = {}) {
|
|
24816
|
+
try {
|
|
24817
|
+
return await execFileAsync("launchctl", args, {
|
|
24818
|
+
timeout: 3e4,
|
|
24819
|
+
env: process.env
|
|
24820
|
+
});
|
|
24821
|
+
} catch (err2) {
|
|
24822
|
+
const e = err2;
|
|
24823
|
+
const stdout = String(e.stdout ?? "");
|
|
24824
|
+
const stderr = String(e.stderr ?? e.message ?? err2);
|
|
24825
|
+
if (options.tolerateFailure) {
|
|
24826
|
+
return { stdout, stderr };
|
|
24827
|
+
}
|
|
24828
|
+
throw new Error(`launchctl ${args.join(" ")} failed: ${(stderr || stdout).trim()}`);
|
|
24829
|
+
}
|
|
24830
|
+
}
|
|
24831
|
+
function launchdDomain() {
|
|
24832
|
+
const uid2 = typeof process.getuid === "function" ? process.getuid() : null;
|
|
24833
|
+
if (uid2 === null) {
|
|
24834
|
+
throw new Error("Unable to resolve current uid for launchd autostart");
|
|
24835
|
+
}
|
|
24836
|
+
return `gui/${uid2}`;
|
|
24837
|
+
}
|
|
24838
|
+
async function installSystemdAutostart() {
|
|
24839
|
+
const paths = resolveSystemdAutostartPaths();
|
|
24840
|
+
await (0, import_promises5.mkdir)(paths.serviceDir, { recursive: true });
|
|
24841
|
+
await (0, import_promises5.writeFile)(paths.servicePath, buildSystemdUserService(), "utf8");
|
|
24842
|
+
await runSystemctl(["daemon-reload"]);
|
|
24843
|
+
await runSystemctl(["enable", "--now", SERVICE_NAME]);
|
|
24844
|
+
return { platform: "linux-systemd", path: paths.servicePath };
|
|
24845
|
+
}
|
|
24846
|
+
async function uninstallSystemdAutostart() {
|
|
24847
|
+
const paths = resolveSystemdAutostartPaths();
|
|
24848
|
+
try {
|
|
24849
|
+
await runSystemctl(["disable", "--now", SERVICE_NAME]);
|
|
24850
|
+
} catch (err2) {
|
|
24851
|
+
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
24852
|
+
if (!message.includes("does not exist") && !message.includes("not loaded")) {
|
|
24853
|
+
throw err2;
|
|
24854
|
+
}
|
|
24855
|
+
}
|
|
24856
|
+
await (0, import_promises5.rm)(paths.servicePath, { force: true });
|
|
24857
|
+
await runSystemctl(["daemon-reload"]);
|
|
24858
|
+
return { platform: "linux-systemd", path: paths.servicePath };
|
|
24859
|
+
}
|
|
24860
|
+
function printSystemdAutostartUnit() {
|
|
24861
|
+
return buildSystemdUserService();
|
|
24862
|
+
}
|
|
24863
|
+
async function installLaunchdAutostart() {
|
|
24864
|
+
const paths = resolveLaunchdAutostartPaths();
|
|
24865
|
+
const taskPaths = resolveTaskPaths();
|
|
24866
|
+
await (0, import_promises5.mkdir)(paths.agentDir, { recursive: true });
|
|
24867
|
+
await (0, import_promises5.mkdir)(taskPaths.logsDir, { recursive: true });
|
|
24868
|
+
await (0, import_promises5.writeFile)(paths.plistPath, buildLaunchdPlist(), "utf8");
|
|
24869
|
+
const domain = launchdDomain();
|
|
24870
|
+
await runLaunchctl(["bootout", domain, paths.plistPath], { tolerateFailure: true });
|
|
24871
|
+
await runLaunchctl(["bootstrap", domain, paths.plistPath]);
|
|
24872
|
+
await runLaunchctl(["enable", `${domain}/${LAUNCHD_LABEL}`]);
|
|
24873
|
+
await runLaunchctl(["kickstart", "-k", `${domain}/${LAUNCHD_LABEL}`]);
|
|
24874
|
+
return { platform: "macos-launchd", path: paths.plistPath };
|
|
24875
|
+
}
|
|
24876
|
+
async function uninstallLaunchdAutostart() {
|
|
24877
|
+
const paths = resolveLaunchdAutostartPaths();
|
|
24878
|
+
await runLaunchctl(["bootout", launchdDomain(), paths.plistPath], { tolerateFailure: true });
|
|
24879
|
+
await (0, import_promises5.rm)(paths.plistPath, { force: true });
|
|
24880
|
+
return { platform: "macos-launchd", path: paths.plistPath };
|
|
24881
|
+
}
|
|
24882
|
+
function printLaunchdPlist() {
|
|
24883
|
+
return buildLaunchdPlist();
|
|
24884
|
+
}
|
|
24885
|
+
async function installAutostart() {
|
|
24886
|
+
if (process.platform === "linux") {
|
|
24887
|
+
return installSystemdAutostart();
|
|
24888
|
+
}
|
|
24889
|
+
if (process.platform === "darwin") {
|
|
24890
|
+
return installLaunchdAutostart();
|
|
24891
|
+
}
|
|
24892
|
+
throw new Error(`autostart is not supported on ${process.platform}`);
|
|
24893
|
+
}
|
|
24894
|
+
async function uninstallAutostart() {
|
|
24895
|
+
if (process.platform === "linux") {
|
|
24896
|
+
return uninstallSystemdAutostart();
|
|
24897
|
+
}
|
|
24898
|
+
if (process.platform === "darwin") {
|
|
24899
|
+
return uninstallLaunchdAutostart();
|
|
24900
|
+
}
|
|
24901
|
+
throw new Error(`autostart is not supported on ${process.platform}`);
|
|
24902
|
+
}
|
|
24903
|
+
function autostartStatus() {
|
|
24904
|
+
if (process.platform === "linux") {
|
|
24905
|
+
return printSystemdAutostartUnit();
|
|
24906
|
+
}
|
|
24907
|
+
if (process.platform === "darwin") {
|
|
24908
|
+
return printLaunchdPlist();
|
|
24909
|
+
}
|
|
24910
|
+
throw new Error(`autostart is not supported on ${process.platform}`);
|
|
24911
|
+
}
|
|
24912
|
+
var import_node_child_process3, import_promises5, import_node_os4, import_node_path13, import_node_util, execFileAsync, SERVICE_NAME, LAUNCHD_LABEL, LAUNCHD_PLIST_NAME;
|
|
24913
|
+
var init_autostart = __esm({
|
|
24914
|
+
"src/autostart.ts"() {
|
|
24915
|
+
"use strict";
|
|
24916
|
+
import_node_child_process3 = require("node:child_process");
|
|
24917
|
+
import_promises5 = require("node:fs/promises");
|
|
24918
|
+
import_node_os4 = require("node:os");
|
|
24919
|
+
import_node_path13 = require("node:path");
|
|
24920
|
+
import_node_util = require("node:util");
|
|
24921
|
+
init_paths();
|
|
24922
|
+
execFileAsync = (0, import_node_util.promisify)(import_node_child_process3.execFile);
|
|
24923
|
+
SERVICE_NAME = "okx-a2a.service";
|
|
24924
|
+
LAUNCHD_LABEL = "com.okx.a2a";
|
|
24925
|
+
LAUNCHD_PLIST_NAME = `${LAUNCHD_LABEL}.plist`;
|
|
24926
|
+
}
|
|
24927
|
+
});
|
|
24928
|
+
|
|
24538
24929
|
// ../core/src/xmtp-sdk/onchainos/bin.ts
|
|
24539
|
-
async function
|
|
24930
|
+
async function resolve3() {
|
|
24540
24931
|
if (resolvedBin) {
|
|
24541
24932
|
return resolvedBin;
|
|
24542
24933
|
}
|
|
@@ -24548,7 +24939,7 @@ async function resolve2() {
|
|
|
24548
24939
|
}
|
|
24549
24940
|
try {
|
|
24550
24941
|
const shell = process.env.SHELL || "/bin/bash";
|
|
24551
|
-
const { stdout } = await
|
|
24942
|
+
const { stdout } = await execFileAsync2(shell, ["-lc", "command -v onchainos"]);
|
|
24552
24943
|
const bin = extractExecutablePath(stdout);
|
|
24553
24944
|
if (bin) {
|
|
24554
24945
|
logWithTimestamp(`[onchainos] resolved binary via shell: ${bin}`);
|
|
@@ -24609,12 +25000,12 @@ function commandForLog(bin, args) {
|
|
|
24609
25000
|
return `${bin} ${redactArgsForLog(args).join(" ")}`;
|
|
24610
25001
|
}
|
|
24611
25002
|
async function exec(args) {
|
|
24612
|
-
const bin = await
|
|
25003
|
+
const bin = await resolve3();
|
|
24613
25004
|
const cmd = commandForLog(bin, args);
|
|
24614
25005
|
logWithTimestamp(`[onchainos] exec: ${cmd}`);
|
|
24615
25006
|
const t0 = Date.now();
|
|
24616
25007
|
try {
|
|
24617
|
-
const result = await
|
|
25008
|
+
const result = await execFileAsync2(bin, args);
|
|
24618
25009
|
logWithTimestamp(
|
|
24619
25010
|
`[onchainos] exec done: ${cmd} (${Date.now() - t0}ms, stdout=${result.stdout.length}B, stderr=${result.stderr.length}B)`
|
|
24620
25011
|
);
|
|
@@ -24647,16 +25038,16 @@ async function exec(args) {
|
|
|
24647
25038
|
throw err2;
|
|
24648
25039
|
}
|
|
24649
25040
|
}
|
|
24650
|
-
var import_node_fs10,
|
|
25041
|
+
var import_node_fs10, import_node_child_process4, import_node_util2, execFileAsync2, resolvedBin, REDACTED_VALUE_FLAGS;
|
|
24651
25042
|
var init_bin = __esm({
|
|
24652
25043
|
"../core/src/xmtp-sdk/onchainos/bin.ts"() {
|
|
24653
25044
|
"use strict";
|
|
24654
25045
|
init_log();
|
|
24655
25046
|
import_node_fs10 = require("node:fs");
|
|
24656
|
-
|
|
24657
|
-
|
|
25047
|
+
import_node_child_process4 = require("node:child_process");
|
|
25048
|
+
import_node_util2 = require("node:util");
|
|
24658
25049
|
init_sentry_logger();
|
|
24659
|
-
|
|
25050
|
+
execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process4.execFile);
|
|
24660
25051
|
resolvedBin = null;
|
|
24661
25052
|
REDACTED_VALUE_FLAGS = /* @__PURE__ */ new Set(["--message"]);
|
|
24662
25053
|
}
|
|
@@ -28189,8 +28580,8 @@ var require_util2 = __commonJS({
|
|
|
28189
28580
|
function createDeferredPromise() {
|
|
28190
28581
|
let res;
|
|
28191
28582
|
let rej;
|
|
28192
|
-
const promise = new Promise((
|
|
28193
|
-
res =
|
|
28583
|
+
const promise = new Promise((resolve8, reject) => {
|
|
28584
|
+
res = resolve8;
|
|
28194
28585
|
rej = reject;
|
|
28195
28586
|
});
|
|
28196
28587
|
return { promise, resolve: res, reject: rej };
|
|
@@ -29694,8 +30085,8 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
|
|
29694
30085
|
});
|
|
29695
30086
|
}
|
|
29696
30087
|
});
|
|
29697
|
-
const busboyResolve = new Promise((
|
|
29698
|
-
busboy.on("finish",
|
|
30088
|
+
const busboyResolve = new Promise((resolve8, reject) => {
|
|
30089
|
+
busboy.on("finish", resolve8);
|
|
29699
30090
|
busboy.on("error", (err2) => reject(new TypeError(err2)));
|
|
29700
30091
|
});
|
|
29701
30092
|
if (this.body !== null) for await (const chunk of consumeBody(this[kState].body)) busboy.write(chunk);
|
|
@@ -30229,9 +30620,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
30229
30620
|
}
|
|
30230
30621
|
close(callback) {
|
|
30231
30622
|
if (callback === void 0) {
|
|
30232
|
-
return new Promise((
|
|
30623
|
+
return new Promise((resolve8, reject) => {
|
|
30233
30624
|
this.close((err2, data) => {
|
|
30234
|
-
return err2 ? reject(err2) :
|
|
30625
|
+
return err2 ? reject(err2) : resolve8(data);
|
|
30235
30626
|
});
|
|
30236
30627
|
});
|
|
30237
30628
|
}
|
|
@@ -30269,12 +30660,12 @@ var require_dispatcher_base = __commonJS({
|
|
|
30269
30660
|
err2 = null;
|
|
30270
30661
|
}
|
|
30271
30662
|
if (callback === void 0) {
|
|
30272
|
-
return new Promise((
|
|
30663
|
+
return new Promise((resolve8, reject) => {
|
|
30273
30664
|
this.destroy(err2, (err3, data) => {
|
|
30274
30665
|
return err3 ? (
|
|
30275
30666
|
/* istanbul ignore next: should never error */
|
|
30276
30667
|
reject(err3)
|
|
30277
|
-
) :
|
|
30668
|
+
) : resolve8(data);
|
|
30278
30669
|
});
|
|
30279
30670
|
});
|
|
30280
30671
|
}
|
|
@@ -31334,16 +31725,16 @@ var require_client2 = __commonJS({
|
|
|
31334
31725
|
return this[kNeedDrain] < 2;
|
|
31335
31726
|
}
|
|
31336
31727
|
async [kClose]() {
|
|
31337
|
-
return new Promise((
|
|
31728
|
+
return new Promise((resolve8) => {
|
|
31338
31729
|
if (!this[kSize]) {
|
|
31339
|
-
|
|
31730
|
+
resolve8(null);
|
|
31340
31731
|
} else {
|
|
31341
|
-
this[kClosedResolve] =
|
|
31732
|
+
this[kClosedResolve] = resolve8;
|
|
31342
31733
|
}
|
|
31343
31734
|
});
|
|
31344
31735
|
}
|
|
31345
31736
|
async [kDestroy](err2) {
|
|
31346
|
-
return new Promise((
|
|
31737
|
+
return new Promise((resolve8) => {
|
|
31347
31738
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
31348
31739
|
for (let i = 0; i < requests.length; i++) {
|
|
31349
31740
|
const request = requests[i];
|
|
@@ -31354,7 +31745,7 @@ var require_client2 = __commonJS({
|
|
|
31354
31745
|
this[kClosedResolve]();
|
|
31355
31746
|
this[kClosedResolve] = null;
|
|
31356
31747
|
}
|
|
31357
|
-
|
|
31748
|
+
resolve8();
|
|
31358
31749
|
};
|
|
31359
31750
|
if (this[kHTTP2Session] != null) {
|
|
31360
31751
|
util.destroy(this[kHTTP2Session], err2);
|
|
@@ -31934,7 +32325,7 @@ var require_client2 = __commonJS({
|
|
|
31934
32325
|
});
|
|
31935
32326
|
}
|
|
31936
32327
|
try {
|
|
31937
|
-
const socket = await new Promise((
|
|
32328
|
+
const socket = await new Promise((resolve8, reject) => {
|
|
31938
32329
|
client[kConnector]({
|
|
31939
32330
|
host,
|
|
31940
32331
|
hostname,
|
|
@@ -31946,7 +32337,7 @@ var require_client2 = __commonJS({
|
|
|
31946
32337
|
if (err2) {
|
|
31947
32338
|
reject(err2);
|
|
31948
32339
|
} else {
|
|
31949
|
-
|
|
32340
|
+
resolve8(socket2);
|
|
31950
32341
|
}
|
|
31951
32342
|
});
|
|
31952
32343
|
});
|
|
@@ -32570,12 +32961,12 @@ upgrade: ${upgrade}\r
|
|
|
32570
32961
|
cb();
|
|
32571
32962
|
}
|
|
32572
32963
|
}
|
|
32573
|
-
const waitForDrain = () => new Promise((
|
|
32964
|
+
const waitForDrain = () => new Promise((resolve8, reject) => {
|
|
32574
32965
|
assert(callback === null);
|
|
32575
32966
|
if (socket[kError]) {
|
|
32576
32967
|
reject(socket[kError]);
|
|
32577
32968
|
} else {
|
|
32578
|
-
callback =
|
|
32969
|
+
callback = resolve8;
|
|
32579
32970
|
}
|
|
32580
32971
|
});
|
|
32581
32972
|
if (client[kHTTPConnVersion] === "h2") {
|
|
@@ -32920,8 +33311,8 @@ var require_pool_base = __commonJS({
|
|
|
32920
33311
|
if (this[kQueue].isEmpty()) {
|
|
32921
33312
|
return Promise.all(this[kClients].map((c) => c.close()));
|
|
32922
33313
|
} else {
|
|
32923
|
-
return new Promise((
|
|
32924
|
-
this[kClosedResolve] =
|
|
33314
|
+
return new Promise((resolve8) => {
|
|
33315
|
+
this[kClosedResolve] = resolve8;
|
|
32925
33316
|
});
|
|
32926
33317
|
}
|
|
32927
33318
|
}
|
|
@@ -33499,7 +33890,7 @@ var require_readable = __commonJS({
|
|
|
33499
33890
|
if (this.closed) {
|
|
33500
33891
|
return Promise.resolve(null);
|
|
33501
33892
|
}
|
|
33502
|
-
return new Promise((
|
|
33893
|
+
return new Promise((resolve8, reject) => {
|
|
33503
33894
|
const signalListenerCleanup = signal ? util.addAbortListener(signal, () => {
|
|
33504
33895
|
this.destroy();
|
|
33505
33896
|
}) : noop;
|
|
@@ -33508,7 +33899,7 @@ var require_readable = __commonJS({
|
|
|
33508
33899
|
if (signal && signal.aborted) {
|
|
33509
33900
|
reject(signal.reason || Object.assign(new Error("The operation was aborted"), { name: "AbortError" }));
|
|
33510
33901
|
} else {
|
|
33511
|
-
|
|
33902
|
+
resolve8(null);
|
|
33512
33903
|
}
|
|
33513
33904
|
}).on("error", noop).on("data", function(chunk) {
|
|
33514
33905
|
limit -= chunk.length;
|
|
@@ -33530,11 +33921,11 @@ var require_readable = __commonJS({
|
|
|
33530
33921
|
throw new TypeError("unusable");
|
|
33531
33922
|
}
|
|
33532
33923
|
assert(!stream[kConsume]);
|
|
33533
|
-
return new Promise((
|
|
33924
|
+
return new Promise((resolve8, reject) => {
|
|
33534
33925
|
stream[kConsume] = {
|
|
33535
33926
|
type,
|
|
33536
33927
|
stream,
|
|
33537
|
-
resolve:
|
|
33928
|
+
resolve: resolve8,
|
|
33538
33929
|
reject,
|
|
33539
33930
|
length: 0,
|
|
33540
33931
|
body: []
|
|
@@ -33569,12 +33960,12 @@ var require_readable = __commonJS({
|
|
|
33569
33960
|
}
|
|
33570
33961
|
}
|
|
33571
33962
|
function consumeEnd(consume2) {
|
|
33572
|
-
const { type, body, resolve:
|
|
33963
|
+
const { type, body, resolve: resolve8, stream, length: length2 } = consume2;
|
|
33573
33964
|
try {
|
|
33574
33965
|
if (type === "text") {
|
|
33575
|
-
|
|
33966
|
+
resolve8(toUSVString(Buffer.concat(body)));
|
|
33576
33967
|
} else if (type === "json") {
|
|
33577
|
-
|
|
33968
|
+
resolve8(JSON.parse(Buffer.concat(body)));
|
|
33578
33969
|
} else if (type === "arrayBuffer") {
|
|
33579
33970
|
const dst = new Uint8Array(length2);
|
|
33580
33971
|
let pos = 0;
|
|
@@ -33582,12 +33973,12 @@ var require_readable = __commonJS({
|
|
|
33582
33973
|
dst.set(buf, pos);
|
|
33583
33974
|
pos += buf.byteLength;
|
|
33584
33975
|
}
|
|
33585
|
-
|
|
33976
|
+
resolve8(dst.buffer);
|
|
33586
33977
|
} else if (type === "blob") {
|
|
33587
33978
|
if (!Blob2) {
|
|
33588
33979
|
Blob2 = require("buffer").Blob;
|
|
33589
33980
|
}
|
|
33590
|
-
|
|
33981
|
+
resolve8(new Blob2(body, { type: stream[kContentType] }));
|
|
33591
33982
|
}
|
|
33592
33983
|
consumeFinish(consume2);
|
|
33593
33984
|
} catch (err2) {
|
|
@@ -33842,9 +34233,9 @@ var require_api_request = __commonJS({
|
|
|
33842
34233
|
};
|
|
33843
34234
|
function request(opts, callback) {
|
|
33844
34235
|
if (callback === void 0) {
|
|
33845
|
-
return new Promise((
|
|
34236
|
+
return new Promise((resolve8, reject) => {
|
|
33846
34237
|
request.call(this, opts, (err2, data) => {
|
|
33847
|
-
return err2 ? reject(err2) :
|
|
34238
|
+
return err2 ? reject(err2) : resolve8(data);
|
|
33848
34239
|
});
|
|
33849
34240
|
});
|
|
33850
34241
|
}
|
|
@@ -34017,9 +34408,9 @@ var require_api_stream = __commonJS({
|
|
|
34017
34408
|
};
|
|
34018
34409
|
function stream(opts, factory, callback) {
|
|
34019
34410
|
if (callback === void 0) {
|
|
34020
|
-
return new Promise((
|
|
34411
|
+
return new Promise((resolve8, reject) => {
|
|
34021
34412
|
stream.call(this, opts, factory, (err2, data) => {
|
|
34022
|
-
return err2 ? reject(err2) :
|
|
34413
|
+
return err2 ? reject(err2) : resolve8(data);
|
|
34023
34414
|
});
|
|
34024
34415
|
});
|
|
34025
34416
|
}
|
|
@@ -34300,9 +34691,9 @@ var require_api_upgrade = __commonJS({
|
|
|
34300
34691
|
};
|
|
34301
34692
|
function upgrade(opts, callback) {
|
|
34302
34693
|
if (callback === void 0) {
|
|
34303
|
-
return new Promise((
|
|
34694
|
+
return new Promise((resolve8, reject) => {
|
|
34304
34695
|
upgrade.call(this, opts, (err2, data) => {
|
|
34305
|
-
return err2 ? reject(err2) :
|
|
34696
|
+
return err2 ? reject(err2) : resolve8(data);
|
|
34306
34697
|
});
|
|
34307
34698
|
});
|
|
34308
34699
|
}
|
|
@@ -34391,9 +34782,9 @@ var require_api_connect = __commonJS({
|
|
|
34391
34782
|
};
|
|
34392
34783
|
function connect(opts, callback) {
|
|
34393
34784
|
if (callback === void 0) {
|
|
34394
|
-
return new Promise((
|
|
34785
|
+
return new Promise((resolve8, reject) => {
|
|
34395
34786
|
connect.call(this, opts, (err2, data) => {
|
|
34396
|
-
return err2 ? reject(err2) :
|
|
34787
|
+
return err2 ? reject(err2) : resolve8(data);
|
|
34397
34788
|
});
|
|
34398
34789
|
});
|
|
34399
34790
|
}
|
|
@@ -34917,7 +35308,7 @@ var require_mock_interceptor = __commonJS({
|
|
|
34917
35308
|
var require_mock_client = __commonJS({
|
|
34918
35309
|
"../../node_modules/undici/lib/mock/mock-client.js"(exports2, module2) {
|
|
34919
35310
|
"use strict";
|
|
34920
|
-
var { promisify:
|
|
35311
|
+
var { promisify: promisify3 } = require("util");
|
|
34921
35312
|
var Client2 = require_client2();
|
|
34922
35313
|
var { buildMockDispatch } = require_mock_utils();
|
|
34923
35314
|
var {
|
|
@@ -34957,7 +35348,7 @@ var require_mock_client = __commonJS({
|
|
|
34957
35348
|
return new MockInterceptor(opts, this[kDispatches]);
|
|
34958
35349
|
}
|
|
34959
35350
|
async [kClose]() {
|
|
34960
|
-
await
|
|
35351
|
+
await promisify3(this[kOriginalClose])();
|
|
34961
35352
|
this[kConnected] = 0;
|
|
34962
35353
|
this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
|
|
34963
35354
|
}
|
|
@@ -34970,7 +35361,7 @@ var require_mock_client = __commonJS({
|
|
|
34970
35361
|
var require_mock_pool = __commonJS({
|
|
34971
35362
|
"../../node_modules/undici/lib/mock/mock-pool.js"(exports2, module2) {
|
|
34972
35363
|
"use strict";
|
|
34973
|
-
var { promisify:
|
|
35364
|
+
var { promisify: promisify3 } = require("util");
|
|
34974
35365
|
var Pool = require_pool();
|
|
34975
35366
|
var { buildMockDispatch } = require_mock_utils();
|
|
34976
35367
|
var {
|
|
@@ -35010,7 +35401,7 @@ var require_mock_pool = __commonJS({
|
|
|
35010
35401
|
return new MockInterceptor(opts, this[kDispatches]);
|
|
35011
35402
|
}
|
|
35012
35403
|
async [kClose]() {
|
|
35013
|
-
await
|
|
35404
|
+
await promisify3(this[kOriginalClose])();
|
|
35014
35405
|
this[kConnected] = 0;
|
|
35015
35406
|
this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
|
|
35016
35407
|
}
|
|
@@ -38015,7 +38406,7 @@ var require_fetch = __commonJS({
|
|
|
38015
38406
|
async function dispatch({ body }) {
|
|
38016
38407
|
const url = requestCurrentURL(request);
|
|
38017
38408
|
const agent = fetchParams.controller.dispatcher;
|
|
38018
|
-
return new Promise((
|
|
38409
|
+
return new Promise((resolve8, reject) => agent.dispatch(
|
|
38019
38410
|
{
|
|
38020
38411
|
path: url.pathname + url.search,
|
|
38021
38412
|
origin: url.origin,
|
|
@@ -38091,7 +38482,7 @@ var require_fetch = __commonJS({
|
|
|
38091
38482
|
}
|
|
38092
38483
|
}
|
|
38093
38484
|
}
|
|
38094
|
-
|
|
38485
|
+
resolve8({
|
|
38095
38486
|
status,
|
|
38096
38487
|
statusText,
|
|
38097
38488
|
headersList: headers[kHeadersList],
|
|
@@ -38134,7 +38525,7 @@ var require_fetch = __commonJS({
|
|
|
38134
38525
|
const val = headersList[n + 1].toString("latin1");
|
|
38135
38526
|
headers[kHeadersList].append(key, val);
|
|
38136
38527
|
}
|
|
38137
|
-
|
|
38528
|
+
resolve8({
|
|
38138
38529
|
status,
|
|
38139
38530
|
statusText: STATUS_CODES[status],
|
|
38140
38531
|
headersList: headers[kHeadersList],
|
|
@@ -41461,11 +41852,11 @@ var require_fetch_pb = __commonJS({
|
|
|
41461
41852
|
"use strict";
|
|
41462
41853
|
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
41463
41854
|
function adopt(value) {
|
|
41464
|
-
return value instanceof P2 ? value : new P2(function(
|
|
41465
|
-
|
|
41855
|
+
return value instanceof P2 ? value : new P2(function(resolve8) {
|
|
41856
|
+
resolve8(value);
|
|
41466
41857
|
});
|
|
41467
41858
|
}
|
|
41468
|
-
return new (P2 || (P2 = Promise))(function(
|
|
41859
|
+
return new (P2 || (P2 = Promise))(function(resolve8, reject) {
|
|
41469
41860
|
function fulfilled(value) {
|
|
41470
41861
|
try {
|
|
41471
41862
|
step(generator.next(value));
|
|
@@ -41481,7 +41872,7 @@ var require_fetch_pb = __commonJS({
|
|
|
41481
41872
|
}
|
|
41482
41873
|
}
|
|
41483
41874
|
function step(result) {
|
|
41484
|
-
result.done ?
|
|
41875
|
+
result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
41485
41876
|
}
|
|
41486
41877
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
41487
41878
|
});
|
|
@@ -42751,7 +43142,7 @@ var require_aspromise = __commonJS({
|
|
|
42751
43142
|
var params = new Array(arguments.length - 1), offset = 0, index2 = 2, pending = true;
|
|
42752
43143
|
while (index2 < arguments.length)
|
|
42753
43144
|
params[offset++] = arguments[index2++];
|
|
42754
|
-
return new Promise(function executor(
|
|
43145
|
+
return new Promise(function executor(resolve8, reject) {
|
|
42755
43146
|
params[offset] = function callback(err2) {
|
|
42756
43147
|
if (pending) {
|
|
42757
43148
|
pending = false;
|
|
@@ -42761,7 +43152,7 @@ var require_aspromise = __commonJS({
|
|
|
42761
43152
|
var params2 = new Array(arguments.length - 1), offset2 = 0;
|
|
42762
43153
|
while (offset2 < params2.length)
|
|
42763
43154
|
params2[offset2++] = arguments[offset2];
|
|
42764
|
-
|
|
43155
|
+
resolve8.apply(null, params2);
|
|
42765
43156
|
}
|
|
42766
43157
|
}
|
|
42767
43158
|
};
|
|
@@ -52217,7 +52608,7 @@ var require_Observable = __commonJS({
|
|
|
52217
52608
|
Observable2.prototype.forEach = function(next, promiseCtor) {
|
|
52218
52609
|
var _this = this;
|
|
52219
52610
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
52220
|
-
return new promiseCtor(function(
|
|
52611
|
+
return new promiseCtor(function(resolve8, reject) {
|
|
52221
52612
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
52222
52613
|
next: function(value) {
|
|
52223
52614
|
try {
|
|
@@ -52228,7 +52619,7 @@ var require_Observable = __commonJS({
|
|
|
52228
52619
|
}
|
|
52229
52620
|
},
|
|
52230
52621
|
error: reject,
|
|
52231
|
-
complete:
|
|
52622
|
+
complete: resolve8
|
|
52232
52623
|
});
|
|
52233
52624
|
_this.subscribe(subscriber);
|
|
52234
52625
|
});
|
|
@@ -52250,14 +52641,14 @@ var require_Observable = __commonJS({
|
|
|
52250
52641
|
Observable2.prototype.toPromise = function(promiseCtor) {
|
|
52251
52642
|
var _this = this;
|
|
52252
52643
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
52253
|
-
return new promiseCtor(function(
|
|
52644
|
+
return new promiseCtor(function(resolve8, reject) {
|
|
52254
52645
|
var value;
|
|
52255
52646
|
_this.subscribe(function(x) {
|
|
52256
52647
|
return value = x;
|
|
52257
52648
|
}, function(err2) {
|
|
52258
52649
|
return reject(err2);
|
|
52259
52650
|
}, function() {
|
|
52260
|
-
return
|
|
52651
|
+
return resolve8(value);
|
|
52261
52652
|
});
|
|
52262
52653
|
});
|
|
52263
52654
|
};
|
|
@@ -52518,11 +52909,11 @@ var require_innerFrom = __commonJS({
|
|
|
52518
52909
|
"use strict";
|
|
52519
52910
|
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
52520
52911
|
function adopt(value) {
|
|
52521
|
-
return value instanceof P2 ? value : new P2(function(
|
|
52522
|
-
|
|
52912
|
+
return value instanceof P2 ? value : new P2(function(resolve8) {
|
|
52913
|
+
resolve8(value);
|
|
52523
52914
|
});
|
|
52524
52915
|
}
|
|
52525
|
-
return new (P2 || (P2 = Promise))(function(
|
|
52916
|
+
return new (P2 || (P2 = Promise))(function(resolve8, reject) {
|
|
52526
52917
|
function fulfilled(value) {
|
|
52527
52918
|
try {
|
|
52528
52919
|
step(generator.next(value));
|
|
@@ -52538,7 +52929,7 @@ var require_innerFrom = __commonJS({
|
|
|
52538
52929
|
}
|
|
52539
52930
|
}
|
|
52540
52931
|
function step(result) {
|
|
52541
|
-
result.done ?
|
|
52932
|
+
result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
52542
52933
|
}
|
|
52543
52934
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
52544
52935
|
});
|
|
@@ -52620,14 +53011,14 @@ var require_innerFrom = __commonJS({
|
|
|
52620
53011
|
}, i);
|
|
52621
53012
|
function verb(n) {
|
|
52622
53013
|
i[n] = o[n] && function(v) {
|
|
52623
|
-
return new Promise(function(
|
|
52624
|
-
v = o[n](v), settle(
|
|
53014
|
+
return new Promise(function(resolve8, reject) {
|
|
53015
|
+
v = o[n](v), settle(resolve8, reject, v.done, v.value);
|
|
52625
53016
|
});
|
|
52626
53017
|
};
|
|
52627
53018
|
}
|
|
52628
|
-
function settle(
|
|
53019
|
+
function settle(resolve8, reject, d, v) {
|
|
52629
53020
|
Promise.resolve(v).then(function(v2) {
|
|
52630
|
-
|
|
53021
|
+
resolve8({ value: v2, done: d });
|
|
52631
53022
|
}, reject);
|
|
52632
53023
|
}
|
|
52633
53024
|
};
|
|
@@ -67360,7 +67751,7 @@ function createAsyncStreamProxy(stream) {
|
|
|
67360
67751
|
function isHexString(value) {
|
|
67361
67752
|
return typeof value === "string" && /^0x(?:[0-9a-fA-F]{2})+$/.test(value);
|
|
67362
67753
|
}
|
|
67363
|
-
var import_node_bindings, import_node_bindings2, import_types,
|
|
67754
|
+
var import_node_bindings, import_node_bindings2, import_types, import_node_path14, 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;
|
|
67364
67755
|
var init_dist4 = __esm({
|
|
67365
67756
|
"../../node_modules/@xmtp/node-sdk/dist/index.js"() {
|
|
67366
67757
|
init_dist2();
|
|
@@ -67369,7 +67760,7 @@ var init_dist4 = __esm({
|
|
|
67369
67760
|
import_node_bindings2 = require("@xmtp/node-bindings");
|
|
67370
67761
|
init_dist();
|
|
67371
67762
|
import_types = require("node:util/types");
|
|
67372
|
-
|
|
67763
|
+
import_node_path14 = require("node:path");
|
|
67373
67764
|
import_node_process = __toESM(require("node:process"), 1);
|
|
67374
67765
|
ApiUrls = {
|
|
67375
67766
|
local: "http://localhost:5556",
|
|
@@ -67530,8 +67921,8 @@ var init_dist4 = __esm({
|
|
|
67530
67921
|
value: this.#queue.shift()
|
|
67531
67922
|
});
|
|
67532
67923
|
}
|
|
67533
|
-
return new Promise((
|
|
67534
|
-
this.#pendingResolves.push(
|
|
67924
|
+
return new Promise((resolve8) => {
|
|
67925
|
+
this.#pendingResolves.push(resolve8);
|
|
67535
67926
|
});
|
|
67536
67927
|
};
|
|
67537
67928
|
return = () => {
|
|
@@ -67557,7 +67948,7 @@ var init_dist4 = __esm({
|
|
|
67557
67948
|
isUsableProperty = (prop) => {
|
|
67558
67949
|
return usableProperties.includes(prop);
|
|
67559
67950
|
};
|
|
67560
|
-
wait = (ms) => new Promise((
|
|
67951
|
+
wait = (ms) => new Promise((resolve8) => setTimeout(resolve8, ms));
|
|
67561
67952
|
DEFAULT_RETRY_DELAY = 6e4;
|
|
67562
67953
|
DEFAULT_RETRY_ATTEMPTS = 10;
|
|
67563
67954
|
createStream = async (streamFunction, streamValueMutator, options) => {
|
|
@@ -68615,7 +69006,7 @@ var init_dist4 = __esm({
|
|
|
68615
69006
|
const inboxId = await getInboxIdForIdentifier(identifier, env, gatewayHost) || generateInboxId(identifier, options?.nonce);
|
|
68616
69007
|
let dbPath;
|
|
68617
69008
|
if (options?.dbPath === void 0) {
|
|
68618
|
-
dbPath = (0,
|
|
69009
|
+
dbPath = (0, import_node_path14.join)(import_node_process.default.cwd(), `xmtp-${env}-${inboxId}.db3`);
|
|
68619
69010
|
} else if (typeof options.dbPath === "function") {
|
|
68620
69011
|
dbPath = options.dbPath(inboxId);
|
|
68621
69012
|
} else {
|
|
@@ -77124,7 +77515,7 @@ var init_wait = __esm({
|
|
|
77124
77515
|
|
|
77125
77516
|
// ../../node_modules/viem/_esm/utils/promise/withRetry.js
|
|
77126
77517
|
function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry: shouldRetry2 = () => true } = {}) {
|
|
77127
|
-
return new Promise((
|
|
77518
|
+
return new Promise((resolve8, reject) => {
|
|
77128
77519
|
const attemptRetry = async ({ count = 0 } = {}) => {
|
|
77129
77520
|
const retry = async ({ error }) => {
|
|
77130
77521
|
const delay = typeof delay_ === "function" ? delay_({ count, error }) : delay_;
|
|
@@ -77134,7 +77525,7 @@ function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry: shoul
|
|
|
77134
77525
|
};
|
|
77135
77526
|
try {
|
|
77136
77527
|
const data = await fn();
|
|
77137
|
-
|
|
77528
|
+
resolve8(data);
|
|
77138
77529
|
} catch (err2) {
|
|
77139
77530
|
if (count < retryCount && await shouldRetry2({ count, error: err2 }))
|
|
77140
77531
|
return retry({ error: err2 });
|
|
@@ -77708,13 +78099,13 @@ var init_transactionRequest = __esm({
|
|
|
77708
78099
|
|
|
77709
78100
|
// ../../node_modules/viem/_esm/utils/promise/withResolvers.js
|
|
77710
78101
|
function withResolvers() {
|
|
77711
|
-
let
|
|
78102
|
+
let resolve8 = () => void 0;
|
|
77712
78103
|
let reject = () => void 0;
|
|
77713
78104
|
const promise = new Promise((resolve_, reject_) => {
|
|
77714
|
-
|
|
78105
|
+
resolve8 = resolve_;
|
|
77715
78106
|
reject = reject_;
|
|
77716
78107
|
});
|
|
77717
|
-
return { promise, resolve:
|
|
78108
|
+
return { promise, resolve: resolve8, reject };
|
|
77718
78109
|
}
|
|
77719
78110
|
var init_withResolvers = __esm({
|
|
77720
78111
|
"../../node_modules/viem/_esm/utils/promise/withResolvers.js"() {
|
|
@@ -77733,8 +78124,8 @@ function createBatchScheduler({ fn, id, shouldSplitBatch, wait: wait3 = 0, sort
|
|
|
77733
78124
|
if (sort && Array.isArray(data))
|
|
77734
78125
|
data.sort(sort);
|
|
77735
78126
|
for (let i = 0; i < scheduler.length; i++) {
|
|
77736
|
-
const { resolve:
|
|
77737
|
-
|
|
78127
|
+
const { resolve: resolve8 } = scheduler[i];
|
|
78128
|
+
resolve8?.([data[i], data]);
|
|
77738
78129
|
}
|
|
77739
78130
|
}).catch((err2) => {
|
|
77740
78131
|
for (let i = 0; i < scheduler.length; i++) {
|
|
@@ -77750,16 +78141,16 @@ function createBatchScheduler({ fn, id, shouldSplitBatch, wait: wait3 = 0, sort
|
|
|
77750
78141
|
return {
|
|
77751
78142
|
flush: flush2,
|
|
77752
78143
|
async schedule(args) {
|
|
77753
|
-
const { promise, resolve:
|
|
78144
|
+
const { promise, resolve: resolve8, reject } = withResolvers();
|
|
77754
78145
|
const split2 = shouldSplitBatch?.([...getBatchedArgs(), args]);
|
|
77755
78146
|
if (split2)
|
|
77756
78147
|
exec2();
|
|
77757
78148
|
const hasActiveScheduler = getScheduler().length > 0;
|
|
77758
78149
|
if (hasActiveScheduler) {
|
|
77759
|
-
setScheduler({ args, resolve:
|
|
78150
|
+
setScheduler({ args, resolve: resolve8, reject });
|
|
77760
78151
|
return promise;
|
|
77761
78152
|
}
|
|
77762
|
-
setScheduler({ args, resolve:
|
|
78153
|
+
setScheduler({ args, resolve: resolve8, reject });
|
|
77763
78154
|
setTimeout(exec2, wait3);
|
|
77764
78155
|
return promise;
|
|
77765
78156
|
}
|
|
@@ -78196,7 +78587,7 @@ var init_getTransactionCount = __esm({
|
|
|
78196
78587
|
|
|
78197
78588
|
// ../../node_modules/viem/_esm/utils/promise/withTimeout.js
|
|
78198
78589
|
function withTimeout(fn, { errorInstance = new Error("timed out"), timeout, signal }) {
|
|
78199
|
-
return new Promise((
|
|
78590
|
+
return new Promise((resolve8, reject) => {
|
|
78200
78591
|
;
|
|
78201
78592
|
(async () => {
|
|
78202
78593
|
let timeoutId;
|
|
@@ -78211,7 +78602,7 @@ function withTimeout(fn, { errorInstance = new Error("timed out"), timeout, sign
|
|
|
78211
78602
|
}
|
|
78212
78603
|
}, timeout);
|
|
78213
78604
|
}
|
|
78214
|
-
|
|
78605
|
+
resolve8(await fn({ signal: controller?.signal || null }));
|
|
78215
78606
|
} catch (err2) {
|
|
78216
78607
|
if (err2?.name === "AbortError")
|
|
78217
78608
|
reject(errorInstance);
|
|
@@ -81288,7 +81679,7 @@ async function sendCalls(client, parameters) {
|
|
|
81288
81679
|
});
|
|
81289
81680
|
promises.push(promise);
|
|
81290
81681
|
if (experimental_fallbackDelay > 0)
|
|
81291
|
-
await new Promise((
|
|
81682
|
+
await new Promise((resolve8) => setTimeout(resolve8, experimental_fallbackDelay));
|
|
81292
81683
|
}
|
|
81293
81684
|
const results = await Promise.allSettled(promises);
|
|
81294
81685
|
if (results.every((r) => r.status === "rejected"))
|
|
@@ -81419,9 +81810,9 @@ async function waitForCallsStatus(client, parameters) {
|
|
|
81419
81810
|
throwOnFailure = false
|
|
81420
81811
|
} = parameters;
|
|
81421
81812
|
const observerId = stringify(["waitForCallsStatus", client.uid, id]);
|
|
81422
|
-
const { promise, resolve:
|
|
81813
|
+
const { promise, resolve: resolve8, reject } = withResolvers();
|
|
81423
81814
|
let timer;
|
|
81424
|
-
const unobserve = observe(observerId, { resolve:
|
|
81815
|
+
const unobserve = observe(observerId, { resolve: resolve8, reject }, (emit) => {
|
|
81425
81816
|
const unpoll = poll(async () => {
|
|
81426
81817
|
const done = (fn) => {
|
|
81427
81818
|
clearTimeout(timer);
|
|
@@ -81759,13 +82150,13 @@ async function waitForTransactionReceipt(client, parameters) {
|
|
|
81759
82150
|
let retrying = false;
|
|
81760
82151
|
let _unobserve;
|
|
81761
82152
|
let _unwatch;
|
|
81762
|
-
const { promise, resolve:
|
|
82153
|
+
const { promise, resolve: resolve8, reject } = withResolvers();
|
|
81763
82154
|
const timer = timeout ? setTimeout(() => {
|
|
81764
82155
|
_unwatch?.();
|
|
81765
82156
|
_unobserve?.();
|
|
81766
82157
|
reject(new WaitForTransactionReceiptTimeoutError({ hash: hash2 }));
|
|
81767
82158
|
}, timeout) : void 0;
|
|
81768
|
-
_unobserve = observe(observerId, { onReplaced, resolve:
|
|
82159
|
+
_unobserve = observe(observerId, { onReplaced, resolve: resolve8, reject }, async (emit) => {
|
|
81769
82160
|
receipt = await getAction(client, getTransactionReceipt, "getTransactionReceipt")({ hash: hash2 }).catch(() => void 0);
|
|
81770
82161
|
if (receipt && confirmations <= 1) {
|
|
81771
82162
|
clearTimeout(timer);
|
|
@@ -83401,7 +83792,7 @@ var init_agent_status = __esm({
|
|
|
83401
83792
|
|
|
83402
83793
|
// ../core/src/xmtp-sdk/index.ts
|
|
83403
83794
|
function cachePath(dataDir, fileName) {
|
|
83404
|
-
return (0,
|
|
83795
|
+
return (0, import_node_path15.join)(dataDir, fileName);
|
|
83405
83796
|
}
|
|
83406
83797
|
function ensureCacheDir(dataDir) {
|
|
83407
83798
|
ensureA2aTaskDir(dataDir);
|
|
@@ -83761,13 +84152,13 @@ function createOfflineReplayAddressSummary(address) {
|
|
|
83761
84152
|
durationMs: 0
|
|
83762
84153
|
};
|
|
83763
84154
|
}
|
|
83764
|
-
var import_node_fs11,
|
|
84155
|
+
var import_node_fs11, import_node_path15, DEFAULT_DATA_DIR, SENSITIVE_WORDS_LAZY_RETRY_COOLDOWN_MS, SESSION_EXPIRED_RE, SYSTEM_CONFIG_DEFAULTS, SEMVER_RE, SENDER_BLACKLISTED_MESSAGE, RECIPIENT_BLACKLISTED_MESSAGE, XmtpService;
|
|
83765
84156
|
var init_xmtp_sdk = __esm({
|
|
83766
84157
|
"../core/src/xmtp-sdk/index.ts"() {
|
|
83767
84158
|
"use strict";
|
|
83768
84159
|
init_log();
|
|
83769
84160
|
import_node_fs11 = require("node:fs");
|
|
83770
|
-
|
|
84161
|
+
import_node_path15 = require("node:path");
|
|
83771
84162
|
init_dist4();
|
|
83772
84163
|
init_sentry_logger();
|
|
83773
84164
|
init_extract_job_id();
|
|
@@ -85879,12 +86270,12 @@ function loadSqlite3() {
|
|
|
85879
86270
|
process.emitWarning = originalEmitWarning;
|
|
85880
86271
|
}
|
|
85881
86272
|
}
|
|
85882
|
-
var import_node_fs12,
|
|
86273
|
+
var import_node_fs12, import_node_path16, DatabaseSync3, InvalidXmtpMessageStore;
|
|
85883
86274
|
var init_invalid_message_store = __esm({
|
|
85884
86275
|
"src/invalid-message-store.ts"() {
|
|
85885
86276
|
"use strict";
|
|
85886
86277
|
import_node_fs12 = require("node:fs");
|
|
85887
|
-
|
|
86278
|
+
import_node_path16 = require("node:path");
|
|
85888
86279
|
init_paths();
|
|
85889
86280
|
({ DatabaseSync: DatabaseSync3 } = loadSqlite3());
|
|
85890
86281
|
InvalidXmtpMessageStore = class {
|
|
@@ -85892,8 +86283,8 @@ var init_invalid_message_store = __esm({
|
|
|
85892
86283
|
db;
|
|
85893
86284
|
constructor(homeDir) {
|
|
85894
86285
|
const paths = resolveTaskPaths(homeDir);
|
|
85895
|
-
this.dbPath = (0,
|
|
85896
|
-
(0, import_node_fs12.mkdirSync)((0,
|
|
86286
|
+
this.dbPath = (0, import_node_path16.join)(paths.sqliteDir, "invalid-xmtp-messages.sqlite");
|
|
86287
|
+
(0, import_node_fs12.mkdirSync)((0, import_node_path16.dirname)(this.dbPath), { recursive: true });
|
|
85897
86288
|
this.db = new DatabaseSync3(this.dbPath);
|
|
85898
86289
|
this.ensureReady();
|
|
85899
86290
|
}
|
|
@@ -87261,7 +87652,7 @@ function buildAiAdapterCommand(options) {
|
|
|
87261
87652
|
function readCodexAddDirs(env = process.env) {
|
|
87262
87653
|
const raw = env.OKX_A2A_AI_CODEX_ADD_DIRS ?? env.OKX_AGENT_TASK_CODEX_ADD_DIRS ?? "";
|
|
87263
87654
|
const seen = /* @__PURE__ */ new Set();
|
|
87264
|
-
return raw.split(
|
|
87655
|
+
return raw.split(import_node_path17.delimiter).map((value) => expandHomePath(value.trim())).filter(Boolean).filter((dir) => {
|
|
87265
87656
|
if (seen.has(dir)) {
|
|
87266
87657
|
return false;
|
|
87267
87658
|
}
|
|
@@ -87271,10 +87662,10 @@ function readCodexAddDirs(env = process.env) {
|
|
|
87271
87662
|
}
|
|
87272
87663
|
function expandHomePath(value) {
|
|
87273
87664
|
if (value === "~") {
|
|
87274
|
-
return (0,
|
|
87665
|
+
return (0, import_node_os5.homedir)();
|
|
87275
87666
|
}
|
|
87276
87667
|
if (value.startsWith("~/")) {
|
|
87277
|
-
return (0,
|
|
87668
|
+
return (0, import_node_path17.join)((0, import_node_os5.homedir)(), value.slice(2));
|
|
87278
87669
|
}
|
|
87279
87670
|
return value;
|
|
87280
87671
|
}
|
|
@@ -87286,7 +87677,7 @@ async function runAiAdapter(options) {
|
|
|
87286
87677
|
errorWithTimestamp(
|
|
87287
87678
|
`[okx-agent-task] AI adapter start provider=${options.provider} command=${built.command} mode=${options.sessionId ? "resume" : "new"} cwd=${options.cwd ?? process.cwd()}`
|
|
87288
87679
|
);
|
|
87289
|
-
const child = (0,
|
|
87680
|
+
const child = (0, import_node_child_process5.spawn)(built.command, built.args, {
|
|
87290
87681
|
cwd: options.cwd,
|
|
87291
87682
|
env: buildAiProviderEnv(built.command, { ...process.env, ...options.env ?? {}, OKX_A2A_IS_CLI: "1" }),
|
|
87292
87683
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -87344,9 +87735,9 @@ async function runAiAdapter(options) {
|
|
|
87344
87735
|
}, 5e3).unref();
|
|
87345
87736
|
}, timeoutMs);
|
|
87346
87737
|
timeout?.unref();
|
|
87347
|
-
const exitCode = await new Promise((
|
|
87738
|
+
const exitCode = await new Promise((resolve8, reject) => {
|
|
87348
87739
|
child.once("error", reject);
|
|
87349
|
-
child.once("close", (code2) =>
|
|
87740
|
+
child.once("close", (code2) => resolve8(code2));
|
|
87350
87741
|
});
|
|
87351
87742
|
if (timeout) {
|
|
87352
87743
|
clearTimeout(timeout);
|
|
@@ -87480,9 +87871,9 @@ function formatOpenClawSessionKey(sessionKey, agentId) {
|
|
|
87480
87871
|
function buildClaudeAddDirArgs(homeDir, env) {
|
|
87481
87872
|
const dirs = [
|
|
87482
87873
|
homeDir,
|
|
87483
|
-
(0,
|
|
87484
|
-
(0,
|
|
87485
|
-
...env.OKX_A2A_AI_CLAUDE_ADD_DIRS ? env.OKX_A2A_AI_CLAUDE_ADD_DIRS.split(
|
|
87874
|
+
(0, import_node_path17.join)((0, import_node_os5.homedir)(), ".agents"),
|
|
87875
|
+
(0, import_node_path17.join)(__dirname, ".."),
|
|
87876
|
+
...env.OKX_A2A_AI_CLAUDE_ADD_DIRS ? env.OKX_A2A_AI_CLAUDE_ADD_DIRS.split(import_node_path17.delimiter).filter(Boolean) : []
|
|
87486
87877
|
];
|
|
87487
87878
|
return ["--add-dir", ...[...new Set(dirs)]];
|
|
87488
87879
|
}
|
|
@@ -87534,17 +87925,17 @@ function applyArgTemplate(template, options) {
|
|
|
87534
87925
|
const homeDir = options.homeDir ?? resolveTaskPaths().homeDir;
|
|
87535
87926
|
const cwd = options.cwd ?? process.cwd();
|
|
87536
87927
|
return template.map((arg) => {
|
|
87537
|
-
return arg.replaceAll("{prompt}", options.prompt).replaceAll("{sessionId}", options.sessionId ?? "").replaceAll("{homeDir}", homeDir).replaceAll("{cwd}", cwd).replaceAll("{repoCli}", (0,
|
|
87928
|
+
return arg.replaceAll("{prompt}", options.prompt).replaceAll("{sessionId}", options.sessionId ?? "").replaceAll("{homeDir}", homeDir).replaceAll("{cwd}", cwd).replaceAll("{repoCli}", (0, import_node_path17.join)(__dirname, "cli.js"));
|
|
87538
87929
|
});
|
|
87539
87930
|
}
|
|
87540
|
-
var
|
|
87931
|
+
var import_node_child_process5, import_node_os5, import_node_path17, CLAUDE_ALLOWED_TOOLS, CLAUDE_PERMISSION_MODES, CODEX_SANDBOX_MODES, CODEX_APPROVAL_POLICIES;
|
|
87541
87932
|
var init_ai_adapter = __esm({
|
|
87542
87933
|
"src/ai-adapter.ts"() {
|
|
87543
87934
|
"use strict";
|
|
87544
87935
|
init_log();
|
|
87545
|
-
|
|
87546
|
-
|
|
87547
|
-
|
|
87936
|
+
import_node_child_process5 = require("node:child_process");
|
|
87937
|
+
import_node_os5 = require("node:os");
|
|
87938
|
+
import_node_path17 = require("node:path");
|
|
87548
87939
|
init_ai_command();
|
|
87549
87940
|
init_paths();
|
|
87550
87941
|
init_session_store();
|
|
@@ -87585,7 +87976,7 @@ function aiRunSentryExtra(input) {
|
|
|
87585
87976
|
closeSignal: input.closeSignal ?? "",
|
|
87586
87977
|
timedOut: input.timedOut === void 0 ? "" : String(input.timedOut),
|
|
87587
87978
|
aiSessionId: input.aiSessionId ?? "",
|
|
87588
|
-
aiLogFile: input.logPath ? (0,
|
|
87979
|
+
aiLogFile: input.logPath ? (0, import_node_path18.basename)(input.logPath) : "",
|
|
87589
87980
|
commandPendingMs: input.commandPendingMs ?? "",
|
|
87590
87981
|
queueWaitMs: input.queueWaitMs ?? "",
|
|
87591
87982
|
cliMs: input.cliMs ?? "",
|
|
@@ -87617,7 +88008,7 @@ function aiRunToolFailureSentryExtra(failure, context) {
|
|
|
87617
88008
|
closeSignal: context.closeSignal ?? "",
|
|
87618
88009
|
timedOut: String(context.timedOut),
|
|
87619
88010
|
aiSessionId: context.aiSessionId ?? "",
|
|
87620
|
-
aiLogFile: (0,
|
|
88011
|
+
aiLogFile: (0, import_node_path18.basename)(context.logPath)
|
|
87621
88012
|
}).filter(([, value]) => value !== "");
|
|
87622
88013
|
return entries.reduce((out, [key, value]) => {
|
|
87623
88014
|
out[key] = String(value);
|
|
@@ -87929,11 +88320,11 @@ function extractDeniedFilesystemPath(text) {
|
|
|
87929
88320
|
}
|
|
87930
88321
|
function getPreferredCodexWritableRoot(target) {
|
|
87931
88322
|
const expanded = expandHomePath2(target);
|
|
87932
|
-
const home = (0,
|
|
88323
|
+
const home = (0, import_node_os6.homedir)();
|
|
87933
88324
|
const appRoots = [
|
|
87934
|
-
(0,
|
|
87935
|
-
(0,
|
|
87936
|
-
(0,
|
|
88325
|
+
(0, import_node_path18.join)(home, ".onchainos", "task"),
|
|
88326
|
+
(0, import_node_path18.join)(home, ".onchainos", "deliverables"),
|
|
88327
|
+
(0, import_node_path18.join)(home, ".okx-agent-task")
|
|
87937
88328
|
];
|
|
87938
88329
|
for (const root of appRoots) {
|
|
87939
88330
|
if (expanded === root || expanded.startsWith(`${root}/`)) {
|
|
@@ -87948,16 +88339,16 @@ function inferAppOwnedCodexWritableRoot(failure) {
|
|
|
87948
88339
|
return void 0;
|
|
87949
88340
|
}
|
|
87950
88341
|
if (containsOnchainosCommand(command) && /\b0x[0-9a-fA-F]{16,}\b/.test(command)) {
|
|
87951
|
-
return (0,
|
|
88342
|
+
return (0, import_node_path18.join)((0, import_node_os6.homedir)(), ".onchainos", "task");
|
|
87952
88343
|
}
|
|
87953
88344
|
return void 0;
|
|
87954
88345
|
}
|
|
87955
88346
|
function expandHomePath2(value) {
|
|
87956
88347
|
if (value === "~") {
|
|
87957
|
-
return (0,
|
|
88348
|
+
return (0, import_node_os6.homedir)();
|
|
87958
88349
|
}
|
|
87959
88350
|
if (value.startsWith("~/")) {
|
|
87960
|
-
return (0,
|
|
88351
|
+
return (0, import_node_path18.join)((0, import_node_os6.homedir)(), value.slice(2));
|
|
87961
88352
|
}
|
|
87962
88353
|
return value;
|
|
87963
88354
|
}
|
|
@@ -88885,17 +89276,17 @@ function shortenJobId2(jobId) {
|
|
|
88885
89276
|
}
|
|
88886
89277
|
return `${jobId.slice(0, 6)}\u2026${jobId.slice(-4)}`;
|
|
88887
89278
|
}
|
|
88888
|
-
var import_node_crypto8, import_node_fs13,
|
|
89279
|
+
var import_node_crypto8, import_node_fs13, import_promises6, import_node_child_process6, import_node_os6, import_node_path18, AiRunner, CODEX_TOOL_FAILURE_MARKER;
|
|
88889
89280
|
var init_ai_runner = __esm({
|
|
88890
89281
|
"src/ai-runner.ts"() {
|
|
88891
89282
|
"use strict";
|
|
88892
89283
|
init_log();
|
|
88893
89284
|
import_node_crypto8 = require("node:crypto");
|
|
88894
89285
|
import_node_fs13 = require("node:fs");
|
|
88895
|
-
|
|
88896
|
-
|
|
88897
|
-
|
|
88898
|
-
|
|
89286
|
+
import_promises6 = require("node:fs/promises");
|
|
89287
|
+
import_node_child_process6 = require("node:child_process");
|
|
89288
|
+
import_node_os6 = require("node:os");
|
|
89289
|
+
import_node_path18 = require("node:path");
|
|
88899
89290
|
init_ai_command();
|
|
88900
89291
|
init_paths();
|
|
88901
89292
|
init_file_store();
|
|
@@ -89112,7 +89503,7 @@ var init_ai_runner = __esm({
|
|
|
89112
89503
|
let timedOut = false;
|
|
89113
89504
|
const timeoutMs = readAiProviderTimeoutMs();
|
|
89114
89505
|
const spawnStartedAt = Date.now();
|
|
89115
|
-
const child = (0,
|
|
89506
|
+
const child = (0, import_node_child_process6.spawn)(command, args, {
|
|
89116
89507
|
cwd: aiCwd,
|
|
89117
89508
|
stdio: ["ignore", "pipe", "pipe"],
|
|
89118
89509
|
env: buildAiProviderEnv(command, {
|
|
@@ -89174,9 +89565,9 @@ var init_ai_runner = __esm({
|
|
|
89174
89565
|
}, 5e3).unref();
|
|
89175
89566
|
}, timeoutMs);
|
|
89176
89567
|
timeout?.unref();
|
|
89177
|
-
const closeResult = await new Promise((
|
|
89568
|
+
const closeResult = await new Promise((resolve8, reject) => {
|
|
89178
89569
|
child.once("error", reject);
|
|
89179
|
-
child.once("close", (code2, signal) =>
|
|
89570
|
+
child.once("close", (code2, signal) => resolve8({ code: code2, signal }));
|
|
89180
89571
|
});
|
|
89181
89572
|
if (timeout) {
|
|
89182
89573
|
clearTimeout(timeout);
|
|
@@ -89198,8 +89589,8 @@ var init_ai_runner = __esm({
|
|
|
89198
89589
|
const sessionWriteMs = sessionWriteEndedAt - sessionWriteStartedAt;
|
|
89199
89590
|
const logFileCloseStartedAt = Date.now();
|
|
89200
89591
|
if (log) {
|
|
89201
|
-
await new Promise((
|
|
89202
|
-
log.end(
|
|
89592
|
+
await new Promise((resolve8) => {
|
|
89593
|
+
log.end(resolve8);
|
|
89203
89594
|
});
|
|
89204
89595
|
}
|
|
89205
89596
|
const logFileCloseEndedAt = Date.now();
|
|
@@ -89404,10 +89795,10 @@ var init_ai_runner = __esm({
|
|
|
89404
89795
|
const safeMessageId = encodeURIComponent(request.messageId);
|
|
89405
89796
|
if (request.source === "job-dispatch") {
|
|
89406
89797
|
const safeJobId = encodeURIComponent(request.jobId ?? "unknown");
|
|
89407
|
-
return (0,
|
|
89798
|
+
return (0, import_node_path18.join)(this.logsDir, `ai-${safeJobId}-${safeMessageId}.log`);
|
|
89408
89799
|
}
|
|
89409
89800
|
const safeSessionKey = encodeURIComponent(request.sessionKey);
|
|
89410
|
-
return (0,
|
|
89801
|
+
return (0, import_node_path18.join)(this.logsDir, `ai-session-${safeSessionKey}-${safeMessageId}.log`);
|
|
89411
89802
|
}
|
|
89412
89803
|
readRunAiSessionId(provider, request, file, sessionMeta) {
|
|
89413
89804
|
if (request.source === "job-dispatch" && request.jobId) {
|
|
@@ -89561,7 +89952,7 @@ var init_ai_runner = __esm({
|
|
|
89561
89952
|
process.env.OKX_AGENT_TASK_AI_CWD,
|
|
89562
89953
|
this.sessionStore.getSetting("ai_working_dir"),
|
|
89563
89954
|
safeProcessCwd(),
|
|
89564
|
-
(0,
|
|
89955
|
+
(0, import_node_os6.homedir)(),
|
|
89565
89956
|
this.homeDir
|
|
89566
89957
|
];
|
|
89567
89958
|
return candidates.find((candidate) => !!candidate && isDirectory(candidate)) ?? this.homeDir;
|
|
@@ -89718,7 +90109,7 @@ var init_ai_runner = __esm({
|
|
|
89718
90109
|
async appendLlmLog(entry) {
|
|
89719
90110
|
try {
|
|
89720
90111
|
ensureTaskDir(this.logsDir);
|
|
89721
|
-
await (0,
|
|
90112
|
+
await (0, import_promises6.appendFile)((0, import_node_path18.join)(this.logsDir, "llm.log"), formatLlmLogEntry(entry), "utf8");
|
|
89722
90113
|
} catch (err2) {
|
|
89723
90114
|
errorWithTimestamp("[okx-agent-task] failed to append llm.log:", err2);
|
|
89724
90115
|
}
|
|
@@ -91863,12 +92254,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
91863
92254
|
}));
|
|
91864
92255
|
}
|
|
91865
92256
|
});
|
|
91866
|
-
service.setPluginVersion("0.0.
|
|
92257
|
+
service.setPluginVersion("0.0.17-beta-db5dca184d-260624150845");
|
|
91867
92258
|
await service.init();
|
|
91868
92259
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
91869
92260
|
if (pluginVersionStatus.unavailable) {
|
|
91870
92261
|
throw new Error(
|
|
91871
|
-
`@okxweb3/a2a-node v${"0.0.
|
|
92262
|
+
`@okxweb3/a2a-node v${"0.0.17-beta-db5dca184d-260624150845"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
91872
92263
|
);
|
|
91873
92264
|
}
|
|
91874
92265
|
const systemConfig = service.getSystemConfig();
|
|
@@ -91886,7 +92277,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
91886
92277
|
onchainosAgentId: "*",
|
|
91887
92278
|
reason: "system-config missing sentryDsn",
|
|
91888
92279
|
pluginId: "@okxweb3/a2a-node",
|
|
91889
|
-
pluginVersion: "0.0.
|
|
92280
|
+
pluginVersion: "0.0.17-beta-db5dca184d-260624150845"
|
|
91890
92281
|
});
|
|
91891
92282
|
}
|
|
91892
92283
|
logWithTimestamp(
|
|
@@ -92147,7 +92538,9 @@ async function runListenerWithLock(options, paths) {
|
|
|
92147
92538
|
sessionStore,
|
|
92148
92539
|
homeDir: options.homeDir
|
|
92149
92540
|
});
|
|
92150
|
-
await
|
|
92541
|
+
await markDaemonReady(paths.daemonLockPath);
|
|
92542
|
+
logWithTimestamp(`[okx-agent-task] daemon ready lock=${paths.daemonLockPath}`);
|
|
92543
|
+
await new Promise((resolve8) => {
|
|
92151
92544
|
const shutdown2 = (signal) => {
|
|
92152
92545
|
if (stopping) {
|
|
92153
92546
|
return;
|
|
@@ -92156,7 +92549,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
92156
92549
|
logWithTimestamp(`[okx-agent-task] received ${signal}, stopping listener`);
|
|
92157
92550
|
const forceResolve = setTimeout(() => {
|
|
92158
92551
|
logWithTimestamp("[okx-agent-task] listener shutdown timed out; forcing process exit");
|
|
92159
|
-
|
|
92552
|
+
resolve8();
|
|
92160
92553
|
}, SHUTDOWN_FORCE_RESOLVE_MS);
|
|
92161
92554
|
void (async () => {
|
|
92162
92555
|
if (timer) {
|
|
@@ -92184,7 +92577,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
92184
92577
|
stopClients(service);
|
|
92185
92578
|
sessionStore.close();
|
|
92186
92579
|
clearTimeout(forceResolve);
|
|
92187
|
-
|
|
92580
|
+
resolve8();
|
|
92188
92581
|
})();
|
|
92189
92582
|
};
|
|
92190
92583
|
process.once("SIGTERM", shutdown2);
|
|
@@ -92230,9 +92623,9 @@ var init_listener = __esm({
|
|
|
92230
92623
|
|
|
92231
92624
|
// ../core/src/file-upload-safety.ts
|
|
92232
92625
|
function getUnsafeFileUploadReason(filePath, sensitiveUploadReg = []) {
|
|
92233
|
-
const expanded = (0,
|
|
92626
|
+
const expanded = (0, import_node_path19.resolve)(expandHome(filePath));
|
|
92234
92627
|
const target = (0, import_node_fs14.realpathSync)(expanded);
|
|
92235
|
-
const targetName = (0,
|
|
92628
|
+
const targetName = (0, import_node_path19.basename)(target);
|
|
92236
92629
|
if (targetName === ".env" || targetName.startsWith(".env.")) {
|
|
92237
92630
|
return ".env";
|
|
92238
92631
|
}
|
|
@@ -92240,18 +92633,18 @@ function getUnsafeFileUploadReason(filePath, sensitiveUploadReg = []) {
|
|
|
92240
92633
|
if (configuredRule) {
|
|
92241
92634
|
return `SENSITIVE_UPLOAD_REG:${configuredRule}`;
|
|
92242
92635
|
}
|
|
92243
|
-
const home = safeRealpath((0,
|
|
92636
|
+
const home = safeRealpath((0, import_node_os7.homedir)());
|
|
92244
92637
|
if (!home) {
|
|
92245
92638
|
return null;
|
|
92246
92639
|
}
|
|
92247
92640
|
for (const dir of SENSITIVE_HOME_DIRS) {
|
|
92248
|
-
const sensitiveDir = safeRealpath((0,
|
|
92641
|
+
const sensitiveDir = safeRealpath((0, import_node_path19.join)(home, dir));
|
|
92249
92642
|
if (sensitiveDir && isPathInside(target, sensitiveDir)) {
|
|
92250
92643
|
return `~/${dir}`;
|
|
92251
92644
|
}
|
|
92252
92645
|
}
|
|
92253
92646
|
for (const file of SENSITIVE_HOME_FILES) {
|
|
92254
|
-
const sensitiveFile = safeRealpath((0,
|
|
92647
|
+
const sensitiveFile = safeRealpath((0, import_node_path19.join)(home, file));
|
|
92255
92648
|
if (sensitiveFile && target === sensitiveFile) {
|
|
92256
92649
|
return `~/${file}`;
|
|
92257
92650
|
}
|
|
@@ -92277,10 +92670,10 @@ function matchSensitiveUploadReg(paths, patterns) {
|
|
|
92277
92670
|
}
|
|
92278
92671
|
function expandHome(filePath) {
|
|
92279
92672
|
if (filePath === "~") {
|
|
92280
|
-
return (0,
|
|
92673
|
+
return (0, import_node_os7.homedir)();
|
|
92281
92674
|
}
|
|
92282
|
-
if (filePath.startsWith(`~${
|
|
92283
|
-
return (0,
|
|
92675
|
+
if (filePath.startsWith(`~${import_node_path19.sep}`)) {
|
|
92676
|
+
return (0, import_node_path19.join)((0, import_node_os7.homedir)(), filePath.slice(2));
|
|
92284
92677
|
}
|
|
92285
92678
|
return filePath;
|
|
92286
92679
|
}
|
|
@@ -92291,15 +92684,15 @@ function safeRealpath(path) {
|
|
|
92291
92684
|
return (0, import_node_fs14.realpathSync)(path);
|
|
92292
92685
|
}
|
|
92293
92686
|
function isPathInside(target, dir) {
|
|
92294
|
-
return target === dir || target.startsWith(`${dir}${
|
|
92687
|
+
return target === dir || target.startsWith(`${dir}${import_node_path19.sep}`);
|
|
92295
92688
|
}
|
|
92296
|
-
var import_node_fs14,
|
|
92689
|
+
var import_node_fs14, import_node_os7, import_node_path19, SENSITIVE_HOME_DIRS, SENSITIVE_HOME_FILES, UNSAFE_FILE_UPLOAD_MESSAGE;
|
|
92297
92690
|
var init_file_upload_safety = __esm({
|
|
92298
92691
|
"../core/src/file-upload-safety.ts"() {
|
|
92299
92692
|
"use strict";
|
|
92300
92693
|
import_node_fs14 = require("node:fs");
|
|
92301
|
-
|
|
92302
|
-
|
|
92694
|
+
import_node_os7 = require("node:os");
|
|
92695
|
+
import_node_path19 = require("node:path");
|
|
92303
92696
|
SENSITIVE_HOME_DIRS = [
|
|
92304
92697
|
".ssh",
|
|
92305
92698
|
".gnupg",
|
|
@@ -92307,7 +92700,7 @@ var init_file_upload_safety = __esm({
|
|
|
92307
92700
|
".azure",
|
|
92308
92701
|
".kube",
|
|
92309
92702
|
".docker",
|
|
92310
|
-
(0,
|
|
92703
|
+
(0, import_node_path19.join)(".config", "gcloud")
|
|
92311
92704
|
];
|
|
92312
92705
|
SENSITIVE_HOME_FILES = [
|
|
92313
92706
|
".npmrc",
|
|
@@ -92369,7 +92762,7 @@ function hasHelpFlag(args) {
|
|
|
92369
92762
|
return args.some((arg) => arg === "-h" || arg === "--help" || arg === "help");
|
|
92370
92763
|
}
|
|
92371
92764
|
async function uploadFile(params) {
|
|
92372
|
-
const filename = params.filename || (0,
|
|
92765
|
+
const filename = params.filename || (0, import_node_path20.basename)(params.filePath);
|
|
92373
92766
|
const mimeType = params.mimeType || "application/octet-stream";
|
|
92374
92767
|
const uploadConfig = readUploadSystemConfig();
|
|
92375
92768
|
const unsafeReason = getUnsafeFileUploadReason(params.filePath, uploadConfig.sensitiveUploadReg);
|
|
@@ -92393,7 +92786,7 @@ async function uploadFile(params) {
|
|
|
92393
92786
|
const attachment = { filename, mimeType, data: new Uint8Array(data) };
|
|
92394
92787
|
const encrypted = await RemoteAttachmentCodec.encodeEncrypted(attachment, new AttachmentCodec());
|
|
92395
92788
|
ensureFileDirs();
|
|
92396
|
-
const encryptedPath = (0,
|
|
92789
|
+
const encryptedPath = (0, import_node_path20.resolve)(FILE_WORK_DIR, `${(0, import_node_crypto11.randomUUID)()}.enc`);
|
|
92397
92790
|
(0, import_node_fs15.writeFileSync)(encryptedPath, encrypted.payload);
|
|
92398
92791
|
try {
|
|
92399
92792
|
const stdout = runOnchainos([
|
|
@@ -92437,7 +92830,7 @@ async function uploadFile(params) {
|
|
|
92437
92830
|
}
|
|
92438
92831
|
async function downloadFile(params) {
|
|
92439
92832
|
ensureFileDirs();
|
|
92440
|
-
const encryptedPath = (0,
|
|
92833
|
+
const encryptedPath = (0, import_node_path20.resolve)(FILE_WORK_DIR, `${(0, import_node_crypto11.randomUUID)()}.enc`);
|
|
92441
92834
|
try {
|
|
92442
92835
|
const stdout = runOnchainos([
|
|
92443
92836
|
"agent",
|
|
@@ -92473,7 +92866,7 @@ async function downloadFile(params) {
|
|
|
92473
92866
|
const outputFilename = params.filename || attachment.filename || `${(0, import_node_crypto11.randomUUID)()}.bin`;
|
|
92474
92867
|
const outputDir = DOWNLOADS_DIR;
|
|
92475
92868
|
ensureA2aTaskDir(outputDir);
|
|
92476
|
-
const outputPath = (0,
|
|
92869
|
+
const outputPath = (0, import_node_path20.resolve)(outputDir, (0, import_node_path20.basename)(outputFilename));
|
|
92477
92870
|
(0, import_node_fs15.writeFileSync)(outputPath, attachment.data);
|
|
92478
92871
|
console.log(outputPath);
|
|
92479
92872
|
} finally {
|
|
@@ -92503,7 +92896,7 @@ function toArrayBuffer(bytes) {
|
|
|
92503
92896
|
function runOnchainos(args, operation, extra = {}) {
|
|
92504
92897
|
const command = readCommand("ONCHAINOS_BIN", "onchainos");
|
|
92505
92898
|
const [bin, ...prefix] = command;
|
|
92506
|
-
const result = (0,
|
|
92899
|
+
const result = (0, import_node_child_process7.spawnSync)(bin, [...prefix, ...args], {
|
|
92507
92900
|
encoding: "utf8",
|
|
92508
92901
|
env: process.env
|
|
92509
92902
|
});
|
|
@@ -92634,14 +93027,14 @@ function readRequiredOption(args, name2) {
|
|
|
92634
93027
|
}
|
|
92635
93028
|
return value;
|
|
92636
93029
|
}
|
|
92637
|
-
var
|
|
93030
|
+
var import_node_child_process7, import_node_crypto11, import_node_fs15, import_node_path20, import_proto4, OKX_A2A_PATHS, OKX_A2A_HOME_DIR, FILE_WORK_DIR, DOWNLOADS_DIR, SYSTEM_CONFIG_PATH;
|
|
92638
93031
|
var init_file_cli = __esm({
|
|
92639
93032
|
"src/file-cli.ts"() {
|
|
92640
93033
|
"use strict";
|
|
92641
|
-
|
|
93034
|
+
import_node_child_process7 = require("node:child_process");
|
|
92642
93035
|
import_node_crypto11 = require("node:crypto");
|
|
92643
93036
|
import_node_fs15 = require("node:fs");
|
|
92644
|
-
|
|
93037
|
+
import_node_path20 = require("node:path");
|
|
92645
93038
|
init_dist6();
|
|
92646
93039
|
import_proto4 = __toESM(require_node3());
|
|
92647
93040
|
init_a2a_paths();
|
|
@@ -92652,7 +93045,7 @@ var init_file_cli = __esm({
|
|
|
92652
93045
|
OKX_A2A_HOME_DIR = OKX_A2A_PATHS.homeDir;
|
|
92653
93046
|
FILE_WORK_DIR = process.env.OKX_A2A_FILE_WORK_DIR || OKX_A2A_PATHS.filesDir;
|
|
92654
93047
|
DOWNLOADS_DIR = process.env.OKX_A2A_DOWNLOADS_DIR || OKX_A2A_PATHS.downloadsDir;
|
|
92655
|
-
SYSTEM_CONFIG_PATH = (0,
|
|
93048
|
+
SYSTEM_CONFIG_PATH = (0, import_node_path20.resolve)(OKX_A2A_PATHS.xmtpDir, "system-config.json");
|
|
92656
93049
|
}
|
|
92657
93050
|
});
|
|
92658
93051
|
|
|
@@ -92815,18 +93208,11 @@ async function assertDaemonRunningForWatch(store, parsed) {
|
|
|
92815
93208
|
if (parsed.flags.has("ignore-daemon-status")) {
|
|
92816
93209
|
return;
|
|
92817
93210
|
}
|
|
92818
|
-
|
|
92819
|
-
|
|
92820
|
-
|
|
92821
|
-
|
|
92822
|
-
|
|
92823
|
-
throw new Error(
|
|
92824
|
-
`user watch requires the daemon, but the pid file is stale (pid=${status.pid}). Run \`okx-a2a daemon restart\` first. To only inspect the current list without daemon-driven new message delivery, add --ignore-daemon-status.`
|
|
92825
|
-
);
|
|
92826
|
-
}
|
|
92827
|
-
throw new Error(
|
|
92828
|
-
"user watch requires the daemon. Run `okx-a2a daemon start` first. To only inspect the current list without daemon-driven new message delivery, add --ignore-daemon-status."
|
|
92829
|
-
);
|
|
93211
|
+
await ensureDaemonReady({
|
|
93212
|
+
homeDir: store.homeDir,
|
|
93213
|
+
commandName: "user watch",
|
|
93214
|
+
stderr: process.stderr
|
|
93215
|
+
});
|
|
92830
93216
|
}
|
|
92831
93217
|
async function watchUserAttentionLoop(store, parsed, json, options = {}) {
|
|
92832
93218
|
const timeoutMs = (readNumberOption(parsed, "timeout") ?? 0) * 1e3;
|
|
@@ -92933,7 +93319,7 @@ async function watchUserAttentionViaDaemon(store, parsed, json, options) {
|
|
|
92933
93319
|
nextHeartbeatAt = Date.now() + Math.min(1e3, Math.max(100, pollMs));
|
|
92934
93320
|
}
|
|
92935
93321
|
const waitMs = deadline ? Math.max(0, Math.min(pollMs, USER_ATTENTION_WATCH_PARENT_CHECK_MS, deadline - Date.now())) : Math.min(pollMs, USER_ATTENTION_WATCH_PARENT_CHECK_MS);
|
|
92936
|
-
await
|
|
93322
|
+
await sleep3(waitMs);
|
|
92937
93323
|
}
|
|
92938
93324
|
} finally {
|
|
92939
93325
|
watcherCleanup.cleanup();
|
|
@@ -93042,24 +93428,24 @@ function createWakeSignal() {
|
|
|
93042
93428
|
wake = null;
|
|
93043
93429
|
},
|
|
93044
93430
|
wait(ms) {
|
|
93045
|
-
return new Promise((
|
|
93431
|
+
return new Promise((resolve8) => {
|
|
93046
93432
|
const timer = setTimeout(() => {
|
|
93047
93433
|
if (wake === finish) {
|
|
93048
93434
|
wake = null;
|
|
93049
93435
|
}
|
|
93050
|
-
|
|
93436
|
+
resolve8();
|
|
93051
93437
|
}, ms);
|
|
93052
93438
|
const finish = () => {
|
|
93053
93439
|
clearTimeout(timer);
|
|
93054
|
-
|
|
93440
|
+
resolve8();
|
|
93055
93441
|
};
|
|
93056
93442
|
wake = finish;
|
|
93057
93443
|
});
|
|
93058
93444
|
}
|
|
93059
93445
|
};
|
|
93060
93446
|
}
|
|
93061
|
-
function
|
|
93062
|
-
return new Promise((
|
|
93447
|
+
function sleep3(ms) {
|
|
93448
|
+
return new Promise((resolve8) => setTimeout(resolve8, ms));
|
|
93063
93449
|
}
|
|
93064
93450
|
function output(json, payload, human) {
|
|
93065
93451
|
if (json) {
|
|
@@ -93878,55 +94264,30 @@ function chooseDispatchMessage(messages, messageId) {
|
|
|
93878
94264
|
return [...messages].reverse().find((message) => message.direction === "inbound") ?? messages.at(-1) ?? null;
|
|
93879
94265
|
}
|
|
93880
94266
|
async function assertDaemonRunningForAiDispatch(commandName) {
|
|
93881
|
-
|
|
93882
|
-
|
|
93883
|
-
|
|
93884
|
-
|
|
93885
|
-
|
|
93886
|
-
|
|
93887
|
-
|
|
93888
|
-
|
|
93889
|
-
}));
|
|
93890
|
-
throw new Error(
|
|
93891
|
-
`${commandName} requires a daemon with ${DAEMON_CAPABILITY_AI_DISPATCH} support. Run \`okx-a2a daemon restart\` first.`
|
|
93892
|
-
);
|
|
93893
|
-
}
|
|
93894
|
-
if (status.stale) {
|
|
93895
|
-
logger.error(LogEvent.DAEMON_COMMAND_STALE, new Error(`${commandName} daemon pid file stale`), sessionCliSentryExtra(commandName, {
|
|
94267
|
+
try {
|
|
94268
|
+
await ensureDaemonReady({
|
|
94269
|
+
commandName,
|
|
94270
|
+
requiredCapabilities: [DAEMON_CAPABILITY_AI_DISPATCH],
|
|
94271
|
+
stderr: process.stderr
|
|
94272
|
+
});
|
|
94273
|
+
} catch (err2) {
|
|
94274
|
+
logger.error(LogEvent.DAEMON_COMMAND_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), sessionCliSentryExtra(commandName, {
|
|
93896
94275
|
stage: "daemon_precondition",
|
|
93897
|
-
reason: "
|
|
93898
|
-
pid: String(status.pid ?? "")
|
|
94276
|
+
reason: "daemon_autostart_failed"
|
|
93899
94277
|
}));
|
|
93900
|
-
throw
|
|
93901
|
-
`${commandName} requires the daemon, but the pid file is stale (pid=${status.pid}). Run \`okx-a2a daemon restart\` first.`
|
|
93902
|
-
);
|
|
94278
|
+
throw err2;
|
|
93903
94279
|
}
|
|
93904
|
-
logger.error(LogEvent.DAEMON_COMMAND_FAILED, new Error(`${commandName} daemon not running`), sessionCliSentryExtra(commandName, {
|
|
93905
|
-
stage: "daemon_precondition",
|
|
93906
|
-
reason: "daemon_not_running"
|
|
93907
|
-
}));
|
|
93908
|
-
throw new Error(`${commandName} requires the daemon. Run \`okx-a2a daemon start\` first.`);
|
|
93909
94280
|
}
|
|
93910
94281
|
async function assertDaemonRunningForQueuedCommand(commandName) {
|
|
93911
|
-
|
|
93912
|
-
|
|
93913
|
-
|
|
93914
|
-
|
|
93915
|
-
if (status.stale) {
|
|
93916
|
-
logger.error(LogEvent.DAEMON_COMMAND_STALE, new Error(`${commandName} daemon pid file stale`), sessionCliSentryExtra(commandName, {
|
|
94282
|
+
try {
|
|
94283
|
+
await ensureDaemonReady({ commandName, stderr: process.stderr });
|
|
94284
|
+
} catch (err2) {
|
|
94285
|
+
logger.error(LogEvent.DAEMON_COMMAND_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), sessionCliSentryExtra(commandName, {
|
|
93917
94286
|
stage: "daemon_precondition",
|
|
93918
|
-
reason: "
|
|
93919
|
-
pid: String(status.pid ?? "")
|
|
94287
|
+
reason: "daemon_autostart_failed"
|
|
93920
94288
|
}));
|
|
93921
|
-
throw
|
|
93922
|
-
`${commandName} requires the daemon, but the pid file is stale (pid=${status.pid}). Run \`okx-a2a daemon restart\` first.`
|
|
93923
|
-
);
|
|
94289
|
+
throw err2;
|
|
93924
94290
|
}
|
|
93925
|
-
logger.error(LogEvent.DAEMON_COMMAND_FAILED, new Error(`${commandName} daemon not running`), sessionCliSentryExtra(commandName, {
|
|
93926
|
-
stage: "daemon_precondition",
|
|
93927
|
-
reason: "daemon_not_running"
|
|
93928
|
-
}));
|
|
93929
|
-
throw new Error(`${commandName} requires the daemon. Run \`okx-a2a daemon start\` first.`);
|
|
93930
94291
|
}
|
|
93931
94292
|
function sessionCliSentryExtra(operation, extra = {}) {
|
|
93932
94293
|
return {
|
|
@@ -94808,7 +95169,7 @@ function detectSetupTarget() {
|
|
|
94808
95169
|
}
|
|
94809
95170
|
const gatewayProviders = [
|
|
94810
95171
|
...commandExists("openclaw") ? ["openclaw"] : [],
|
|
94811
|
-
...commandExists("hermes") || (0, import_node_fs16.existsSync)((0,
|
|
95172
|
+
...commandExists("hermes") || (0, import_node_fs16.existsSync)((0, import_node_path21.join)(process.env.HERMES_HOME ?? (0, import_node_path21.join)((0, import_node_os8.homedir)(), ".hermes"))) ? ["hermes"] : []
|
|
94812
95173
|
];
|
|
94813
95174
|
if (gatewayProviders.length === 1) {
|
|
94814
95175
|
return gatewayProviders[0];
|
|
@@ -94865,7 +95226,7 @@ async function getCurrentNodeCliVersion() {
|
|
|
94865
95226
|
return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
|
|
94866
95227
|
}
|
|
94867
95228
|
function getBundledNodeCliVersion() {
|
|
94868
|
-
return true ? "0.0.
|
|
95229
|
+
return true ? "0.0.17-beta-db5dca184d-260624150845" : null;
|
|
94869
95230
|
}
|
|
94870
95231
|
function readConfiguredAiProvider() {
|
|
94871
95232
|
const explicit = process.env.OKX_AGENT_TASK_AI_CLI ?? process.env.OKX_A2A_AI_PROVIDER;
|
|
@@ -94916,13 +95277,8 @@ async function updateOpenClaw(release, options) {
|
|
|
94916
95277
|
const label = options.label ?? "update";
|
|
94917
95278
|
assertNotRunningInsideGateway("openclaw");
|
|
94918
95279
|
const pluginSpec = buildNpmPackageSpec("openclaw", release);
|
|
94919
|
-
console.log(`[${label}]
|
|
94920
|
-
|
|
94921
|
-
await runCommand("openclaw", ["plugins", "uninstall", "okx-a2a", "--force"]);
|
|
94922
|
-
} else {
|
|
94923
|
-
console.log(`[${label}] OpenClaw plugin okx-a2a is not currently installed; uninstall skipped`);
|
|
94924
|
-
}
|
|
94925
|
-
await runCommand("openclaw", ["plugins", "install", pluginSpec, OPENCLAW_UNSAFE_INSTALL_FLAG]);
|
|
95280
|
+
console.log(`[${label}] installing OpenClaw plugin okx-a2a from ${pluginSpec} with --force`);
|
|
95281
|
+
await runCommand("openclaw", ["plugins", "install", pluginSpec, OPENCLAW_FORCE_INSTALL_FLAG, OPENCLAW_UNSAFE_INSTALL_FLAG]);
|
|
94926
95282
|
if (options.restart) {
|
|
94927
95283
|
console.log(`[${label}] restarting OpenClaw gateway`);
|
|
94928
95284
|
await runCommand("openclaw", ["gateway", "restart"]);
|
|
@@ -94935,17 +95291,17 @@ async function updateHermes(release, options) {
|
|
|
94935
95291
|
const label = options.label ?? "update";
|
|
94936
95292
|
assertNotRunningInsideGateway("hermes");
|
|
94937
95293
|
const spec = buildNpmPackageSpec("hermes", release);
|
|
94938
|
-
const workDir = await (0,
|
|
95294
|
+
const workDir = await (0, import_promises7.mkdtemp)((0, import_node_path21.join)((0, import_node_os8.tmpdir)(), `okx-a2a-${label}-hermes-`));
|
|
94939
95295
|
try {
|
|
94940
95296
|
console.log(`[${label}] downloading ${spec}`);
|
|
94941
95297
|
const npmTarball = await npmPack(spec, workDir);
|
|
94942
|
-
const npmPackageDir = (0,
|
|
95298
|
+
const npmPackageDir = (0, import_node_path21.join)(workDir, "npm-package");
|
|
94943
95299
|
await runCommand("tar", ["-xzf", npmTarball, "-C", npmPackageDir], { ensureDir: npmPackageDir });
|
|
94944
|
-
const pluginTarball = await findHermesPluginTarball((0,
|
|
94945
|
-
const pluginDir = (0,
|
|
95300
|
+
const pluginTarball = await findHermesPluginTarball((0, import_node_path21.join)(npmPackageDir, "package", "dist"));
|
|
95301
|
+
const pluginDir = (0, import_node_path21.join)(workDir, "plugin");
|
|
94946
95302
|
await runCommand("tar", ["-xzf", pluginTarball, "-C", pluginDir], { ensureDir: pluginDir });
|
|
94947
95303
|
const unpackedPluginDir = await findFirstDirectory(pluginDir);
|
|
94948
|
-
const installer = (0,
|
|
95304
|
+
const installer = (0, import_node_path21.join)(unpackedPluginDir, "scripts", "install-or-upgrade.sh");
|
|
94949
95305
|
console.log(`[${label}] running ${installer}`);
|
|
94950
95306
|
await runCommand("bash", [installer, ...options.restart ? ["--restart"] : []], { cwd: unpackedPluginDir });
|
|
94951
95307
|
await normalizeHermesOkxA2aPluginConfig();
|
|
@@ -94954,13 +95310,13 @@ async function updateHermes(release, options) {
|
|
|
94954
95310
|
}
|
|
94955
95311
|
console.log(`[${label}] hermes ${label} done`);
|
|
94956
95312
|
} finally {
|
|
94957
|
-
await (0,
|
|
95313
|
+
await (0, import_promises7.rm)(workDir, { recursive: true, force: true });
|
|
94958
95314
|
}
|
|
94959
95315
|
}
|
|
94960
95316
|
async function normalizeHermesOkxA2aPluginConfig(configFile = resolveHermesConfigPath()) {
|
|
94961
95317
|
let content3;
|
|
94962
95318
|
try {
|
|
94963
|
-
content3 = await (0,
|
|
95319
|
+
content3 = await (0, import_promises7.readFile)(configFile, "utf8");
|
|
94964
95320
|
} catch (error) {
|
|
94965
95321
|
if (isNodeError(error) && error.code === "ENOENT") {
|
|
94966
95322
|
return false;
|
|
@@ -94971,18 +95327,18 @@ async function normalizeHermesOkxA2aPluginConfig(configFile = resolveHermesConfi
|
|
|
94971
95327
|
if (!normalized.changed) {
|
|
94972
95328
|
return false;
|
|
94973
95329
|
}
|
|
94974
|
-
await (0,
|
|
95330
|
+
await (0, import_promises7.writeFile)(configFile, normalized.content);
|
|
94975
95331
|
console.log(`[update] normalized Hermes plugins.enabled okx-a2a entry in ${configFile}`);
|
|
94976
95332
|
return true;
|
|
94977
95333
|
}
|
|
94978
95334
|
async function ensureHermesOkxA2aPluginConfig(configFile = resolveHermesConfigPath()) {
|
|
94979
95335
|
let content3;
|
|
94980
95336
|
try {
|
|
94981
|
-
content3 = await (0,
|
|
95337
|
+
content3 = await (0, import_promises7.readFile)(configFile, "utf8");
|
|
94982
95338
|
} catch (error) {
|
|
94983
95339
|
if (isNodeError(error) && error.code === "ENOENT") {
|
|
94984
|
-
await (0,
|
|
94985
|
-
await (0,
|
|
95340
|
+
await (0, import_promises7.mkdir)((0, import_node_path21.resolve)(configFile, ".."), { recursive: true });
|
|
95341
|
+
await (0, import_promises7.writeFile)(configFile, "plugins:\n enabled:\n - okx-a2a\n");
|
|
94986
95342
|
console.log(`[update] added Hermes plugins.enabled okx-a2a entry in ${configFile}`);
|
|
94987
95343
|
return true;
|
|
94988
95344
|
}
|
|
@@ -94990,7 +95346,7 @@ async function ensureHermesOkxA2aPluginConfig(configFile = resolveHermesConfigPa
|
|
|
94990
95346
|
}
|
|
94991
95347
|
const normalized = normalizeHermesPluginConfigContent(content3);
|
|
94992
95348
|
if (normalized.changed) {
|
|
94993
|
-
await (0,
|
|
95349
|
+
await (0, import_promises7.writeFile)(configFile, normalized.content);
|
|
94994
95350
|
console.log(`[update] normalized Hermes plugins.enabled okx-a2a entry in ${configFile}`);
|
|
94995
95351
|
return true;
|
|
94996
95352
|
}
|
|
@@ -94998,7 +95354,7 @@ async function ensureHermesOkxA2aPluginConfig(configFile = resolveHermesConfigPa
|
|
|
94998
95354
|
return false;
|
|
94999
95355
|
}
|
|
95000
95356
|
const updated = addHermesOkxA2aEnabled(content3);
|
|
95001
|
-
await (0,
|
|
95357
|
+
await (0, import_promises7.writeFile)(configFile, updated);
|
|
95002
95358
|
console.log(`[update] added Hermes plugins.enabled okx-a2a entry in ${configFile}`);
|
|
95003
95359
|
return true;
|
|
95004
95360
|
}
|
|
@@ -95141,7 +95497,7 @@ function addHermesOkxA2aEnabled(content3) {
|
|
|
95141
95497
|
return `${lines.join("\n")}${trailingNewline ? "\n" : ""}`;
|
|
95142
95498
|
}
|
|
95143
95499
|
function resolveHermesConfigPath() {
|
|
95144
|
-
return (0,
|
|
95500
|
+
return (0, import_node_path21.join)(process.env.HERMES_HOME ?? (0, import_node_path21.join)((0, import_node_os8.homedir)(), ".hermes"), "config.yaml");
|
|
95145
95501
|
}
|
|
95146
95502
|
function lineIndent(line) {
|
|
95147
95503
|
const match = line.match(/^\s*/);
|
|
@@ -95222,7 +95578,7 @@ async function isGatewayPluginInstalled(target) {
|
|
|
95222
95578
|
if (target === "openclaw") {
|
|
95223
95579
|
return (await getInstalledOpenClawPluginInfo()).installed;
|
|
95224
95580
|
}
|
|
95225
|
-
if ((0, import_node_fs16.existsSync)((0,
|
|
95581
|
+
if ((0, import_node_fs16.existsSync)((0, import_node_path21.join)(process.env.HERMES_HOME ?? (0, import_node_path21.join)((0, import_node_os8.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml"))) {
|
|
95226
95582
|
return true;
|
|
95227
95583
|
}
|
|
95228
95584
|
return await isGlobalNpmPackageInstalled(UPDATE_PACKAGES.hermes);
|
|
@@ -95316,9 +95672,9 @@ function parsePackageVersionFromText(output4) {
|
|
|
95316
95672
|
return output4.match(/@okxweb3\/a2a-openclaw@([0-9A-Za-z.+-]+)/)?.[1] ?? null;
|
|
95317
95673
|
}
|
|
95318
95674
|
async function getInstalledHermesPluginVersion() {
|
|
95319
|
-
const pluginYaml = (0,
|
|
95675
|
+
const pluginYaml = (0, import_node_path21.join)(process.env.HERMES_HOME ?? (0, import_node_path21.join)((0, import_node_os8.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
|
|
95320
95676
|
try {
|
|
95321
|
-
const content3 = await (0,
|
|
95677
|
+
const content3 = await (0, import_promises7.readFile)(pluginYaml, "utf8");
|
|
95322
95678
|
return parsePluginYamlVersion(content3);
|
|
95323
95679
|
} catch (error) {
|
|
95324
95680
|
if (isNodeError(error) && error.code === "ENOENT") {
|
|
@@ -95369,23 +95725,23 @@ async function npmPack(spec, destination) {
|
|
|
95369
95725
|
if (!tarballName) {
|
|
95370
95726
|
throw new Error(`Unable to detect npm pack tarball from output: ${output4.trim()}`);
|
|
95371
95727
|
}
|
|
95372
|
-
return (0,
|
|
95728
|
+
return (0, import_node_path21.resolve)(destination, (0, import_node_path21.basename)(tarballName));
|
|
95373
95729
|
}
|
|
95374
95730
|
async function findHermesPluginTarball(distDir) {
|
|
95375
|
-
const entries = await (0,
|
|
95731
|
+
const entries = await (0, import_promises7.readdir)(distDir);
|
|
95376
95732
|
const tarball = entries.find((entry) => /^okx-a2a-hermes-plugin-.+\.tar\.gz$/.test(entry));
|
|
95377
95733
|
if (!tarball) {
|
|
95378
95734
|
throw new Error(`Hermes npm package did not contain dist/okx-a2a-hermes-plugin-*.tar.gz`);
|
|
95379
95735
|
}
|
|
95380
|
-
return (0,
|
|
95736
|
+
return (0, import_node_path21.join)(distDir, tarball);
|
|
95381
95737
|
}
|
|
95382
95738
|
async function findFirstDirectory(parent) {
|
|
95383
|
-
const entries = await (0,
|
|
95739
|
+
const entries = await (0, import_promises7.readdir)(parent, { withFileTypes: true });
|
|
95384
95740
|
const dir = entries.find((entry) => entry.isDirectory());
|
|
95385
95741
|
if (!dir) {
|
|
95386
95742
|
throw new Error(`No unpacked plugin directory found under ${parent}`);
|
|
95387
95743
|
}
|
|
95388
|
-
return (0,
|
|
95744
|
+
return (0, import_node_path21.join)(parent, dir.name);
|
|
95389
95745
|
}
|
|
95390
95746
|
function readOption2(args, name2) {
|
|
95391
95747
|
const index2 = args.indexOf(name2);
|
|
@@ -95427,11 +95783,11 @@ function assertOnlyKnownUpdateOptions(args, command = "update") {
|
|
|
95427
95783
|
}
|
|
95428
95784
|
async function runCommand(command, args, options = {}) {
|
|
95429
95785
|
if (options.ensureDir) {
|
|
95430
|
-
const { mkdir:
|
|
95431
|
-
await
|
|
95786
|
+
const { mkdir: mkdir5 } = await import("node:fs/promises");
|
|
95787
|
+
await mkdir5(options.ensureDir, { recursive: true });
|
|
95432
95788
|
}
|
|
95433
95789
|
await new Promise((resolvePromise, reject) => {
|
|
95434
|
-
const child = (0,
|
|
95790
|
+
const child = (0, import_node_child_process8.spawn)(command, args, {
|
|
95435
95791
|
cwd: options.cwd,
|
|
95436
95792
|
stdio: redirectCommandStdoutToStderr ? ["ignore", "pipe", "pipe"] : "inherit"
|
|
95437
95793
|
});
|
|
@@ -95451,7 +95807,7 @@ async function runCommand(command, args, options = {}) {
|
|
|
95451
95807
|
}
|
|
95452
95808
|
async function runCommandCapture(command, args) {
|
|
95453
95809
|
return await new Promise((resolvePromise, reject) => {
|
|
95454
|
-
const child = (0,
|
|
95810
|
+
const child = (0, import_node_child_process8.spawn)(command, args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
95455
95811
|
let stdout = "";
|
|
95456
95812
|
let stderr = "";
|
|
95457
95813
|
child.stdout.setEncoding("utf8");
|
|
@@ -95478,7 +95834,7 @@ ${stderr}`));
|
|
|
95478
95834
|
}
|
|
95479
95835
|
async function runCommandCaptureOptional(command, args) {
|
|
95480
95836
|
return await new Promise((resolvePromise) => {
|
|
95481
|
-
const child = (0,
|
|
95837
|
+
const child = (0, import_node_child_process8.spawn)(command, args, { stdio: ["ignore", "pipe", "ignore"] });
|
|
95482
95838
|
let stdout = "";
|
|
95483
95839
|
child.stdout.setEncoding("utf8");
|
|
95484
95840
|
child.stdout.on("data", (chunk) => {
|
|
@@ -95492,15 +95848,15 @@ async function runCommandCaptureOptional(command, args) {
|
|
|
95492
95848
|
});
|
|
95493
95849
|
});
|
|
95494
95850
|
}
|
|
95495
|
-
var
|
|
95851
|
+
var import_node_child_process8, import_node_fs16, import_promises7, import_node_os8, import_node_path21, UPDATE_PACKAGES, OPENCLAW_FORCE_INSTALL_FLAG, OPENCLAW_UNSAFE_INSTALL_FLAG, redirectCommandStdoutToStderr;
|
|
95496
95852
|
var init_update_cli = __esm({
|
|
95497
95853
|
"src/update-cli.ts"() {
|
|
95498
95854
|
"use strict";
|
|
95499
|
-
|
|
95855
|
+
import_node_child_process8 = require("node:child_process");
|
|
95500
95856
|
import_node_fs16 = require("node:fs");
|
|
95501
|
-
|
|
95502
|
-
|
|
95503
|
-
|
|
95857
|
+
import_promises7 = require("node:fs/promises");
|
|
95858
|
+
import_node_os8 = require("node:os");
|
|
95859
|
+
import_node_path21 = require("node:path");
|
|
95504
95860
|
init_ai_provider();
|
|
95505
95861
|
init_ai_command();
|
|
95506
95862
|
init_session_store();
|
|
@@ -95509,16 +95865,17 @@ var init_update_cli = __esm({
|
|
|
95509
95865
|
openclaw: "@okxweb3/a2a-openclaw",
|
|
95510
95866
|
hermes: "@okxweb3/a2a-hermes"
|
|
95511
95867
|
};
|
|
95868
|
+
OPENCLAW_FORCE_INSTALL_FLAG = "--force";
|
|
95512
95869
|
OPENCLAW_UNSAFE_INSTALL_FLAG = "--dangerously-force-unsafe-install";
|
|
95513
95870
|
redirectCommandStdoutToStderr = false;
|
|
95514
95871
|
}
|
|
95515
95872
|
});
|
|
95516
95873
|
|
|
95517
95874
|
// src/cli.ts
|
|
95518
|
-
var
|
|
95875
|
+
var import_node_child_process9 = require("node:child_process");
|
|
95519
95876
|
var import_node_fs17 = require("node:fs");
|
|
95520
|
-
var
|
|
95521
|
-
var
|
|
95877
|
+
var import_node_os9 = require("node:os");
|
|
95878
|
+
var import_node_path22 = require("node:path");
|
|
95522
95879
|
init_daemon();
|
|
95523
95880
|
init_command_store();
|
|
95524
95881
|
init_file_store();
|
|
@@ -95532,7 +95889,7 @@ init_sentry_logger();
|
|
|
95532
95889
|
init_sentry_config();
|
|
95533
95890
|
var CURRENT_GATEWAY_SESSION_KEYS_ENV2 = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
|
|
95534
95891
|
function printUsage2() {
|
|
95535
|
-
console.log(`okx-a2a ${"0.0.
|
|
95892
|
+
console.log(`okx-a2a ${"0.0.17-beta-db5dca184d-260624150845"}
|
|
95536
95893
|
|
|
95537
95894
|
Usage:
|
|
95538
95895
|
okx-a2a <command> [options]
|
|
@@ -95569,20 +95926,22 @@ Run \`okx-a2a <command> -h\` for command-specific help.
|
|
|
95569
95926
|
`);
|
|
95570
95927
|
}
|
|
95571
95928
|
function printVersion() {
|
|
95572
|
-
console.log("0.0.
|
|
95929
|
+
console.log("0.0.17-beta-db5dca184d-260624150845");
|
|
95573
95930
|
}
|
|
95574
95931
|
function printDaemonUsage() {
|
|
95575
|
-
console.log(`Usage: okx-a2a daemon <start|restart|stop|status> [options]
|
|
95932
|
+
console.log(`Usage: okx-a2a daemon <start|restart|stop|status|autostart> [options]
|
|
95576
95933
|
|
|
95577
95934
|
Commands:
|
|
95578
|
-
daemon start [--provider codex|claude|hermes|openclaw] [--ai-provider codex|claude|hermes|openclaw]
|
|
95579
|
-
Start the background XMTP-to-JSON writer
|
|
95935
|
+
daemon start [--provider codex|claude|hermes|openclaw] [--ai-provider codex|claude|hermes|openclaw] [--no-autostart]
|
|
95936
|
+
Start the background XMTP-to-JSON writer and install OS autostart by default
|
|
95580
95937
|
daemon restart [--provider codex|claude|hermes|openclaw] [--ai-provider codex|claude|hermes|openclaw]
|
|
95581
95938
|
Restart the background writer
|
|
95582
95939
|
daemon stop
|
|
95583
95940
|
Stop the background writer
|
|
95584
95941
|
daemon status
|
|
95585
95942
|
Print writer process status
|
|
95943
|
+
daemon autostart <install|uninstall|status>
|
|
95944
|
+
Manage OS autostart for okx-a2a run
|
|
95586
95945
|
`);
|
|
95587
95946
|
}
|
|
95588
95947
|
function printLogsUsage() {
|
|
@@ -95801,6 +96160,9 @@ function hasFlag2(args, name2) {
|
|
|
95801
96160
|
function readLifecycleProviderOption(args) {
|
|
95802
96161
|
return readOption3(args, "--provider") ?? readOption3(args, "--ai-provider");
|
|
95803
96162
|
}
|
|
96163
|
+
function shouldInstallAutostart(args) {
|
|
96164
|
+
return !hasFlag2(args, "--no-autostart");
|
|
96165
|
+
}
|
|
95804
96166
|
function printStopDaemonResult(result) {
|
|
95805
96167
|
if (result.stopped) {
|
|
95806
96168
|
console.log(`stopped pid=${result.pid}${result.forced ? " (forced)" : ""}`);
|
|
@@ -95823,12 +96185,12 @@ async function printDaemonStatus() {
|
|
|
95823
96185
|
}
|
|
95824
96186
|
}
|
|
95825
96187
|
async function tailLogFile(logPath) {
|
|
95826
|
-
await new Promise((
|
|
95827
|
-
const child = (0,
|
|
96188
|
+
await new Promise((resolve8, reject) => {
|
|
96189
|
+
const child = (0, import_node_child_process9.spawn)("tail", ["-600", "-f", logPath], { stdio: "inherit" });
|
|
95828
96190
|
child.on("error", reject);
|
|
95829
96191
|
child.on("close", (code2, signal) => {
|
|
95830
96192
|
if (signal || code2 === 0) {
|
|
95831
|
-
|
|
96193
|
+
resolve8();
|
|
95832
96194
|
return;
|
|
95833
96195
|
}
|
|
95834
96196
|
reject(new Error(`tail exited with code=${code2}`));
|
|
@@ -95847,7 +96209,7 @@ async function handleLogs(args) {
|
|
|
95847
96209
|
return;
|
|
95848
96210
|
}
|
|
95849
96211
|
if (subcommand === "llm") {
|
|
95850
|
-
await tailLogFile((0,
|
|
96212
|
+
await tailLogFile((0, import_node_path22.join)(paths.logsDir, "llm.log"));
|
|
95851
96213
|
return;
|
|
95852
96214
|
}
|
|
95853
96215
|
throw new Error("logs requires <server|llm>");
|
|
@@ -96139,25 +96501,15 @@ function formatDaemonCommandResult(type, result) {
|
|
|
96139
96501
|
return `agents=${payload?.agentCount ?? 0} activeClients=${payload?.activeClients ?? 0} changed=${payload?.changed ? "yes" : "no"} added=${payload?.added?.length ?? 0} removed=${payload?.removed?.length ?? 0}`;
|
|
96140
96502
|
}
|
|
96141
96503
|
async function assertDaemonRunningForQueuedCommand2(commandName) {
|
|
96142
|
-
|
|
96143
|
-
|
|
96144
|
-
|
|
96145
|
-
|
|
96146
|
-
if (status.stale) {
|
|
96147
|
-
logger.error(LogEvent.DAEMON_COMMAND_STALE, new Error(`${commandName} daemon pid file stale`), directCliSentryExtra(commandName, {
|
|
96504
|
+
try {
|
|
96505
|
+
await ensureDaemonReady({ commandName, stderr: process.stderr });
|
|
96506
|
+
} catch (err2) {
|
|
96507
|
+
logger.error(LogEvent.DAEMON_COMMAND_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), directCliSentryExtra(commandName, {
|
|
96148
96508
|
stage: "daemon_precondition",
|
|
96149
|
-
reason: "
|
|
96150
|
-
pid: String(status.pid ?? "")
|
|
96509
|
+
reason: "daemon_autostart_failed"
|
|
96151
96510
|
}));
|
|
96152
|
-
throw
|
|
96153
|
-
`${commandName} requires the daemon, but the pid file is stale (pid=${status.pid}). Run \`okx-a2a daemon restart\` first.`
|
|
96154
|
-
);
|
|
96511
|
+
throw err2;
|
|
96155
96512
|
}
|
|
96156
|
-
logger.error(LogEvent.DAEMON_COMMAND_FAILED, new Error(`${commandName} daemon not running`), directCliSentryExtra(commandName, {
|
|
96157
|
-
stage: "daemon_precondition",
|
|
96158
|
-
reason: "daemon_not_running"
|
|
96159
|
-
}));
|
|
96160
|
-
throw new Error(`${commandName} requires the daemon. Run \`okx-a2a daemon start\` first.`);
|
|
96161
96513
|
}
|
|
96162
96514
|
async function configureDefaultAiProviderForLifecycle(args) {
|
|
96163
96515
|
const store = new SessionStore();
|
|
@@ -96177,6 +96529,21 @@ async function configureDefaultAiProviderForLifecycle(args) {
|
|
|
96177
96529
|
}
|
|
96178
96530
|
async function handleStart(args) {
|
|
96179
96531
|
await configureDefaultAiProviderForLifecycle(args);
|
|
96532
|
+
if (shouldInstallAutostart(args)) {
|
|
96533
|
+
try {
|
|
96534
|
+
const { installAutostart: installAutostart2 } = await Promise.resolve().then(() => (init_autostart(), autostart_exports));
|
|
96535
|
+
const result2 = await installAutostart2();
|
|
96536
|
+
console.log(`installed ${result2.platform} autostart ${result2.path}`);
|
|
96537
|
+
const status = await getDaemonStatus();
|
|
96538
|
+
if (status.running) {
|
|
96539
|
+
console.log(`running pid=${status.pid}`);
|
|
96540
|
+
}
|
|
96541
|
+
return;
|
|
96542
|
+
} catch (err2) {
|
|
96543
|
+
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
96544
|
+
console.warn(`autostart install failed; starting without autostart: ${message}`);
|
|
96545
|
+
}
|
|
96546
|
+
}
|
|
96180
96547
|
const result = await startDaemon();
|
|
96181
96548
|
if (result.started) {
|
|
96182
96549
|
console.log(`started pid=${result.pid} log=${result.logPath}`);
|
|
@@ -96198,6 +96565,29 @@ async function handleRestart(args) {
|
|
|
96198
96565
|
console.log(`already running pid=${startResult.pid} log=${startResult.logPath}`);
|
|
96199
96566
|
}
|
|
96200
96567
|
}
|
|
96568
|
+
async function handleDaemonAutostart(args) {
|
|
96569
|
+
const subcommand = args[0] ?? "status";
|
|
96570
|
+
const {
|
|
96571
|
+
autostartStatus: autostartStatus2,
|
|
96572
|
+
installAutostart: installAutostart2,
|
|
96573
|
+
uninstallAutostart: uninstallAutostart2
|
|
96574
|
+
} = await Promise.resolve().then(() => (init_autostart(), autostart_exports));
|
|
96575
|
+
if (subcommand === "install") {
|
|
96576
|
+
const result = await installAutostart2();
|
|
96577
|
+
console.log(`installed ${result.platform} autostart ${result.path}`);
|
|
96578
|
+
return;
|
|
96579
|
+
}
|
|
96580
|
+
if (subcommand === "uninstall") {
|
|
96581
|
+
const result = await uninstallAutostart2();
|
|
96582
|
+
console.log(`removed ${result.platform} autostart ${result.path}`);
|
|
96583
|
+
return;
|
|
96584
|
+
}
|
|
96585
|
+
if (subcommand === "status") {
|
|
96586
|
+
console.log(autostartStatus2());
|
|
96587
|
+
return;
|
|
96588
|
+
}
|
|
96589
|
+
throw new Error("daemon autostart requires <install|uninstall|status>");
|
|
96590
|
+
}
|
|
96201
96591
|
async function handleAiProvider(args) {
|
|
96202
96592
|
if (hasHelpFlag5(args)) {
|
|
96203
96593
|
printAiProviderUsage();
|
|
@@ -96524,7 +96914,7 @@ function initDirectCliSentry() {
|
|
|
96524
96914
|
}
|
|
96525
96915
|
cliSentryInitAttempted = true;
|
|
96526
96916
|
try {
|
|
96527
|
-
const configPath = (0,
|
|
96917
|
+
const configPath = (0, import_node_path22.join)(resolveTaskHomeForSentryConfig(), "xmtp", "system-config.json");
|
|
96528
96918
|
if (!(0, import_node_fs17.existsSync)(configPath)) {
|
|
96529
96919
|
return;
|
|
96530
96920
|
}
|
|
@@ -96546,13 +96936,13 @@ function resolveTaskHomeForSentryConfig() {
|
|
|
96546
96936
|
return process.env.OKX_AGENT_TASK_HOME;
|
|
96547
96937
|
}
|
|
96548
96938
|
try {
|
|
96549
|
-
const home = (0,
|
|
96939
|
+
const home = (0, import_node_os9.homedir)();
|
|
96550
96940
|
if (home) {
|
|
96551
|
-
return (0,
|
|
96941
|
+
return (0, import_node_path22.join)(home, ".okx-agent-task");
|
|
96552
96942
|
}
|
|
96553
96943
|
} catch {
|
|
96554
96944
|
}
|
|
96555
|
-
return (0,
|
|
96945
|
+
return (0, import_node_path22.resolve)(process.cwd(), ".okx-agent-task");
|
|
96556
96946
|
}
|
|
96557
96947
|
function directCliSentryExtra(operation, extra = {}) {
|
|
96558
96948
|
return {
|
|
@@ -96568,8 +96958,8 @@ async function flushDirectCliSentry() {
|
|
|
96568
96958
|
return;
|
|
96569
96959
|
}
|
|
96570
96960
|
try {
|
|
96571
|
-
const timeout = new Promise((
|
|
96572
|
-
const timer = setTimeout(() =>
|
|
96961
|
+
const timeout = new Promise((resolve8) => {
|
|
96962
|
+
const timer = setTimeout(() => resolve8("timeout"), 750);
|
|
96573
96963
|
timer.unref?.();
|
|
96574
96964
|
});
|
|
96575
96965
|
const result = await Promise.race([shutdown().then(() => "flushed"), timeout]);
|
|
@@ -96618,6 +97008,10 @@ async function main() {
|
|
|
96618
97008
|
await printDaemonStatus();
|
|
96619
97009
|
return;
|
|
96620
97010
|
}
|
|
97011
|
+
if (daemonCommand === "autostart") {
|
|
97012
|
+
await handleDaemonAutostart(daemonArgs);
|
|
97013
|
+
return;
|
|
97014
|
+
}
|
|
96621
97015
|
throw new Error(`Unknown daemon command: ${daemonCommand}`);
|
|
96622
97016
|
}
|
|
96623
97017
|
if (command === "start") {
|