@okxweb3/a2a-node 0.0.1 → 0.0.2-beta-38940d220c-260605180610
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +332 -144
- package/dist/index.js +309 -136
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1928,14 +1928,14 @@ var require_path = __commonJS({
|
|
|
1928
1928
|
}
|
|
1929
1929
|
return root + dir;
|
|
1930
1930
|
}
|
|
1931
|
-
function
|
|
1931
|
+
function basename2(path, ext) {
|
|
1932
1932
|
let f = splitPath(path)[2];
|
|
1933
1933
|
if (ext && f.slice(ext.length * -1) === ext) {
|
|
1934
1934
|
f = f.slice(0, f.length - ext.length);
|
|
1935
1935
|
}
|
|
1936
1936
|
return f;
|
|
1937
1937
|
}
|
|
1938
|
-
exports2.basename =
|
|
1938
|
+
exports2.basename = basename2;
|
|
1939
1939
|
exports2.dirname = dirname4;
|
|
1940
1940
|
exports2.isAbsolute = isAbsolute2;
|
|
1941
1941
|
exports2.join = join14;
|
|
@@ -4238,11 +4238,11 @@ Sentry.init({...});
|
|
|
4238
4238
|
*/
|
|
4239
4239
|
startSession(context) {
|
|
4240
4240
|
const { scope: scope2, client } = this.getStackTop();
|
|
4241
|
-
const { release, environment = constants3.DEFAULT_ENVIRONMENT } = client && client.getOptions() || {};
|
|
4241
|
+
const { release, environment: environment2 = constants3.DEFAULT_ENVIRONMENT } = client && client.getOptions() || {};
|
|
4242
4242
|
const { userAgent } = utils.GLOBAL_OBJ.navigator || {};
|
|
4243
4243
|
const session$1 = session.makeSession({
|
|
4244
4244
|
release,
|
|
4245
|
-
environment,
|
|
4245
|
+
environment: environment2,
|
|
4246
4246
|
user: scope2.getUser(),
|
|
4247
4247
|
...userAgent && { userAgent },
|
|
4248
4248
|
...context
|
|
@@ -6080,9 +6080,9 @@ var require_prepareEvent = __commonJS({
|
|
|
6080
6080
|
});
|
|
6081
6081
|
}
|
|
6082
6082
|
function applyClientOptions(event, options) {
|
|
6083
|
-
const { environment, release, dist, maxValueLength = 250 } = options;
|
|
6083
|
+
const { environment: environment2, release, dist, maxValueLength = 250 } = options;
|
|
6084
6084
|
if (!("environment" in event)) {
|
|
6085
|
-
event.environment = "environment" in options ?
|
|
6085
|
+
event.environment = "environment" in options ? environment2 : constants3.DEFAULT_ENVIRONMENT;
|
|
6086
6086
|
}
|
|
6087
6087
|
if (event.release === void 0 && release !== void 0) {
|
|
6088
6088
|
event.release = release;
|
|
@@ -6878,13 +6878,13 @@ var require_server_runtime_client = __commonJS({
|
|
|
6878
6878
|
}
|
|
6879
6879
|
/** Method that initialises an instance of SessionFlusher on Client */
|
|
6880
6880
|
initSessionFlusher() {
|
|
6881
|
-
const { release, environment } = this._options;
|
|
6881
|
+
const { release, environment: environment2 } = this._options;
|
|
6882
6882
|
if (!release) {
|
|
6883
6883
|
(typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) && utils.logger.warn("Cannot initialise an instance of SessionFlusher if no release is provided!");
|
|
6884
6884
|
} else {
|
|
6885
6885
|
this._sessionFlusher = new sessionflusher.SessionFlusher(this, {
|
|
6886
6886
|
release,
|
|
6887
|
-
environment
|
|
6887
|
+
environment: environment2
|
|
6888
6888
|
});
|
|
6889
6889
|
}
|
|
6890
6890
|
}
|
|
@@ -6902,13 +6902,13 @@ var require_server_runtime_client = __commonJS({
|
|
|
6902
6902
|
return id;
|
|
6903
6903
|
}
|
|
6904
6904
|
const options = this.getOptions();
|
|
6905
|
-
const { release, environment, tunnel } = options;
|
|
6905
|
+
const { release, environment: environment2, tunnel } = options;
|
|
6906
6906
|
const serializedCheckIn = {
|
|
6907
6907
|
check_in_id: id,
|
|
6908
6908
|
monitor_slug: checkIn.monitorSlug,
|
|
6909
6909
|
status: checkIn.status,
|
|
6910
6910
|
release,
|
|
6911
|
-
environment
|
|
6911
|
+
environment: environment2
|
|
6912
6912
|
};
|
|
6913
6913
|
if (checkIn.status !== "in_progress") {
|
|
6914
6914
|
serializedCheckIn.duration = checkIn.duration;
|
|
@@ -11733,10 +11733,10 @@ var require_module = __commonJS({
|
|
|
11733
11733
|
return;
|
|
11734
11734
|
}
|
|
11735
11735
|
const normalizedFilename = normalizeWindowsPathSeparator ? normalizeWindowsPath(filename) : filename;
|
|
11736
|
-
let { root, dir, base:
|
|
11736
|
+
let { root, dir, base: basename2, ext } = path.posix.parse(normalizedFilename);
|
|
11737
11737
|
const base3 = require && require.main && require.main.filename && dir || global.process.cwd();
|
|
11738
11738
|
const normalizedBase = `${base3}/`;
|
|
11739
|
-
let file =
|
|
11739
|
+
let file = basename2;
|
|
11740
11740
|
if (ext === ".js" || ext === ".mjs" || ext === ".cjs") {
|
|
11741
11741
|
file = file.slice(0, ext.length * -1);
|
|
11742
11742
|
}
|
|
@@ -17347,7 +17347,7 @@ var require_parseParams = __commonJS({
|
|
|
17347
17347
|
var require_basename = __commonJS({
|
|
17348
17348
|
"../../node_modules/@fastify/busboy/lib/utils/basename.js"(exports2, module2) {
|
|
17349
17349
|
"use strict";
|
|
17350
|
-
module2.exports = function
|
|
17350
|
+
module2.exports = function basename2(path) {
|
|
17351
17351
|
if (typeof path !== "string") {
|
|
17352
17352
|
return "";
|
|
17353
17353
|
}
|
|
@@ -17374,7 +17374,7 @@ var require_multipart = __commonJS({
|
|
|
17374
17374
|
var Dicer = require_Dicer();
|
|
17375
17375
|
var parseParams = require_parseParams();
|
|
17376
17376
|
var decodeText = require_decodeText();
|
|
17377
|
-
var
|
|
17377
|
+
var basename2 = require_basename();
|
|
17378
17378
|
var getLimit = require_getLimit();
|
|
17379
17379
|
var RE_BOUNDARY = /^boundary$/i;
|
|
17380
17380
|
var RE_FIELD = /^form-data$/i;
|
|
@@ -17491,7 +17491,7 @@ var require_multipart = __commonJS({
|
|
|
17491
17491
|
} else if (RE_FILENAME.test(parsed[i][0])) {
|
|
17492
17492
|
filename = parsed[i][1];
|
|
17493
17493
|
if (!preservePath) {
|
|
17494
|
-
filename =
|
|
17494
|
+
filename = basename2(filename);
|
|
17495
17495
|
}
|
|
17496
17496
|
}
|
|
17497
17497
|
}
|
|
@@ -65490,6 +65490,44 @@ var LogEvent = {
|
|
|
65490
65490
|
|
|
65491
65491
|
// ../core/src/sentry-logger/index.ts
|
|
65492
65492
|
var FLOW_ID = (0, import_node_crypto2.randomUUID)();
|
|
65493
|
+
var SENTRY_EXTRA_BLOCKLIST = /* @__PURE__ */ new Set([
|
|
65494
|
+
"args",
|
|
65495
|
+
"argv",
|
|
65496
|
+
"body",
|
|
65497
|
+
"cache",
|
|
65498
|
+
"command",
|
|
65499
|
+
"content",
|
|
65500
|
+
"cwd",
|
|
65501
|
+
"data",
|
|
65502
|
+
"error",
|
|
65503
|
+
"failures",
|
|
65504
|
+
"filename",
|
|
65505
|
+
"file_name",
|
|
65506
|
+
"filepath",
|
|
65507
|
+
"file_path",
|
|
65508
|
+
"headers",
|
|
65509
|
+
"input",
|
|
65510
|
+
"logpath",
|
|
65511
|
+
"message",
|
|
65512
|
+
"output",
|
|
65513
|
+
"params",
|
|
65514
|
+
"path",
|
|
65515
|
+
"payload",
|
|
65516
|
+
"prompt",
|
|
65517
|
+
"raw",
|
|
65518
|
+
"rawevent",
|
|
65519
|
+
"rawtext",
|
|
65520
|
+
"request",
|
|
65521
|
+
"response",
|
|
65522
|
+
"digest",
|
|
65523
|
+
"nonce",
|
|
65524
|
+
"salt",
|
|
65525
|
+
"secret",
|
|
65526
|
+
"stderr",
|
|
65527
|
+
"stdout",
|
|
65528
|
+
"title",
|
|
65529
|
+
"tooloutput"
|
|
65530
|
+
]);
|
|
65493
65531
|
var SentryLogger = class _SentryLogger {
|
|
65494
65532
|
static instance;
|
|
65495
65533
|
initialized = false;
|
|
@@ -65511,16 +65549,19 @@ var SentryLogger = class _SentryLogger {
|
|
|
65511
65549
|
dsn: config.dsn,
|
|
65512
65550
|
release: config.release,
|
|
65513
65551
|
environment: config.environment,
|
|
65552
|
+
maxBreadcrumbs: 0,
|
|
65553
|
+
beforeBreadcrumb: () => null,
|
|
65514
65554
|
isInner: false
|
|
65515
65555
|
});
|
|
65516
65556
|
Sentry.setTags({
|
|
65517
|
-
projectName: config.projectName
|
|
65557
|
+
projectName: config.projectName,
|
|
65558
|
+
agentPlatform: config.agentPlatform
|
|
65518
65559
|
});
|
|
65519
65560
|
this.initialized = true;
|
|
65520
65561
|
this.flush();
|
|
65521
65562
|
}
|
|
65522
65563
|
info(message, extra) {
|
|
65523
|
-
const extraWithFlow = { flowId: FLOW_ID, ...extra ?? {} };
|
|
65564
|
+
const extraWithFlow = _SentryLogger.sanitizeExtra({ flowId: FLOW_ID, ...extra ?? {} });
|
|
65524
65565
|
if (!this.initialized) {
|
|
65525
65566
|
this.buffer.push({ level: "info", message, extra: extraWithFlow });
|
|
65526
65567
|
return;
|
|
@@ -65532,7 +65573,7 @@ var SentryLogger = class _SentryLogger {
|
|
|
65532
65573
|
});
|
|
65533
65574
|
}
|
|
65534
65575
|
error(message, error, extra) {
|
|
65535
|
-
const extraWithFlow = { flowId: FLOW_ID, ...extra ?? {} };
|
|
65576
|
+
const extraWithFlow = _SentryLogger.sanitizeExtra({ flowId: FLOW_ID, ...extra ?? {} });
|
|
65536
65577
|
if (!this.initialized) {
|
|
65537
65578
|
this.buffer.push({
|
|
65538
65579
|
level: "error",
|
|
@@ -65546,7 +65587,12 @@ var SentryLogger = class _SentryLogger {
|
|
|
65546
65587
|
scope.setLevel("error");
|
|
65547
65588
|
scope.setContext("report", { info: JSON.stringify(extraWithFlow) });
|
|
65548
65589
|
Sentry.captureException(_SentryLogger.createSentryEvent(message, error), {
|
|
65549
|
-
extra: error ? {
|
|
65590
|
+
extra: error ? {
|
|
65591
|
+
...extraWithFlow,
|
|
65592
|
+
eventName: message,
|
|
65593
|
+
errorName: error.name,
|
|
65594
|
+
errorMessageLength: String(error.message.length)
|
|
65595
|
+
} : extraWithFlow
|
|
65550
65596
|
});
|
|
65551
65597
|
});
|
|
65552
65598
|
}
|
|
@@ -65563,19 +65609,30 @@ var SentryLogger = class _SentryLogger {
|
|
|
65563
65609
|
}
|
|
65564
65610
|
}
|
|
65565
65611
|
}
|
|
65612
|
+
static sanitizeExtra(extra) {
|
|
65613
|
+
return Object.fromEntries(
|
|
65614
|
+
Object.entries(extra).filter(([key]) => !SENTRY_EXTRA_BLOCKLIST.has(key.toLowerCase()))
|
|
65615
|
+
);
|
|
65616
|
+
}
|
|
65566
65617
|
static toPascalCase(str) {
|
|
65567
65618
|
return str.split(/[\s:]+/).filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("");
|
|
65568
65619
|
}
|
|
65569
65620
|
static createSentryEvent(eventName, cause) {
|
|
65570
|
-
const err2 = new Error(
|
|
65621
|
+
const err2 = new Error(eventName);
|
|
65571
65622
|
err2.name = _SentryLogger.toPascalCase(eventName);
|
|
65572
65623
|
if (cause?.stack) {
|
|
65573
|
-
err2.stack =
|
|
65624
|
+
err2.stack = [
|
|
65625
|
+
`${err2.name}: ${eventName}`,
|
|
65626
|
+
...cause.stack.split("\n").slice(1)
|
|
65627
|
+
].join("\n");
|
|
65574
65628
|
}
|
|
65575
65629
|
return err2;
|
|
65576
65630
|
}
|
|
65577
65631
|
};
|
|
65578
65632
|
var logger = SentryLogger.getInstance();
|
|
65633
|
+
var initLogger = (config) => {
|
|
65634
|
+
return logger.init(config);
|
|
65635
|
+
};
|
|
65579
65636
|
var UNKNOWN_FIELD = "unknown";
|
|
65580
65637
|
function agentExtras(identity3) {
|
|
65581
65638
|
return {
|
|
@@ -67577,17 +67634,17 @@ var AiRunner = class {
|
|
|
67577
67634
|
provider: failure.provider,
|
|
67578
67635
|
tool: failure.tool,
|
|
67579
67636
|
errorType: failure.errorType,
|
|
67580
|
-
|
|
67637
|
+
commandLength: String(failure.command?.length ?? 0),
|
|
67581
67638
|
toolExitCode: failure.exitCode === void 0 || failure.exitCode === null ? "" : String(failure.exitCode),
|
|
67582
67639
|
toolStatus: failure.status ?? "",
|
|
67583
|
-
|
|
67584
|
-
|
|
67640
|
+
toolOutputBytes: String(Buffer.byteLength(failure.output, "utf8")),
|
|
67641
|
+
rawEventBytes: String(Buffer.byteLength(failure.rawEvent, "utf8")),
|
|
67585
67642
|
sessionKey: context.sessionKey,
|
|
67586
67643
|
taskId: context.jobId ?? "",
|
|
67587
67644
|
agentId: context.agentId ?? "",
|
|
67588
67645
|
messageId: context.messageId ?? "",
|
|
67589
|
-
|
|
67590
|
-
|
|
67646
|
+
logFileName: context.logPath ? (0, import_node_path10.basename)(context.logPath) : "",
|
|
67647
|
+
cwdName: context.cwd ? (0, import_node_path10.basename)(context.cwd) : "",
|
|
67591
67648
|
providerExitCode: context.exitCode === null ? "" : String(context.exitCode),
|
|
67592
67649
|
closeSignal: context.closeSignal ?? "",
|
|
67593
67650
|
aiSessionId: context.aiSessionId ?? "",
|
|
@@ -67660,10 +67717,6 @@ function truncateForError(text, max = 500) {
|
|
|
67660
67717
|
const normalized = text.replace(/\s+/g, " ").trim();
|
|
67661
67718
|
return normalized.length > max ? `${normalized.slice(0, max)}...` : normalized;
|
|
67662
67719
|
}
|
|
67663
|
-
function trimForSentry(text, max = 1200) {
|
|
67664
|
-
const normalized = text.replace(/\s+/g, " ").trim();
|
|
67665
|
-
return normalized.length > max ? `${normalized.slice(0, max)}...` : normalized;
|
|
67666
|
-
}
|
|
67667
67720
|
function createAiToolFailureTracker(provider) {
|
|
67668
67721
|
const failures = [];
|
|
67669
67722
|
const claudeToolCommands = /* @__PURE__ */ new Map();
|
|
@@ -77004,7 +77057,6 @@ async function loadSystemConfigWith(dataDir, fetcher) {
|
|
|
77004
77057
|
console.log("[xmtp-sdk] system-config fetcher not provided by host");
|
|
77005
77058
|
return loadSystemConfigFromCache(dataDir);
|
|
77006
77059
|
}
|
|
77007
|
-
const cached = loadSystemConfigFromCache(dataDir);
|
|
77008
77060
|
try {
|
|
77009
77061
|
const config = await fetcher();
|
|
77010
77062
|
console.log(
|
|
@@ -77019,6 +77071,7 @@ async function loadSystemConfigWith(dataDir, fetcher) {
|
|
|
77019
77071
|
} catch (err2) {
|
|
77020
77072
|
console.log(`[xmtp-sdk] API fetch for system-config failed:`, err2);
|
|
77021
77073
|
}
|
|
77074
|
+
const cached = loadSystemConfigFromCache(dataDir);
|
|
77022
77075
|
if (cached) {
|
|
77023
77076
|
console.log(
|
|
77024
77077
|
`[xmtp-sdk] using cached system-config from disk: ${Object.keys(cached).length} keys`
|
|
@@ -78515,6 +78568,7 @@ var import_node_child_process4 = require("node:child_process");
|
|
|
78515
78568
|
var import_node_util = require("node:util");
|
|
78516
78569
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process4.execFile);
|
|
78517
78570
|
var resolvedBin = null;
|
|
78571
|
+
var REDACTED_VALUE_FLAGS = /* @__PURE__ */ new Set(["--message"]);
|
|
78518
78572
|
async function resolve2() {
|
|
78519
78573
|
if (resolvedBin) {
|
|
78520
78574
|
return resolvedBin;
|
|
@@ -78563,9 +78617,33 @@ function isExecutable2(path) {
|
|
|
78563
78617
|
return false;
|
|
78564
78618
|
}
|
|
78565
78619
|
}
|
|
78620
|
+
function redactArgsForLog(args) {
|
|
78621
|
+
const redacted = [];
|
|
78622
|
+
let redactNext = false;
|
|
78623
|
+
for (const arg of args) {
|
|
78624
|
+
if (redactNext) {
|
|
78625
|
+
redacted.push("<redacted>");
|
|
78626
|
+
redactNext = false;
|
|
78627
|
+
continue;
|
|
78628
|
+
}
|
|
78629
|
+
const inlineFlag = [...REDACTED_VALUE_FLAGS].find((flag) => arg.startsWith(`${flag}=`));
|
|
78630
|
+
if (inlineFlag) {
|
|
78631
|
+
redacted.push(`${inlineFlag}=<redacted>`);
|
|
78632
|
+
continue;
|
|
78633
|
+
}
|
|
78634
|
+
redacted.push(arg);
|
|
78635
|
+
if (REDACTED_VALUE_FLAGS.has(arg)) {
|
|
78636
|
+
redactNext = true;
|
|
78637
|
+
}
|
|
78638
|
+
}
|
|
78639
|
+
return redacted;
|
|
78640
|
+
}
|
|
78641
|
+
function commandForLog(bin, args) {
|
|
78642
|
+
return `${bin} ${redactArgsForLog(args).join(" ")}`;
|
|
78643
|
+
}
|
|
78566
78644
|
async function exec(args) {
|
|
78567
78645
|
const bin = await resolve2();
|
|
78568
|
-
const cmd =
|
|
78646
|
+
const cmd = commandForLog(bin, args);
|
|
78569
78647
|
console.log(`[onchainos] exec: ${cmd}`);
|
|
78570
78648
|
const t0 = Date.now();
|
|
78571
78649
|
try {
|
|
@@ -78580,15 +78658,17 @@ async function exec(args) {
|
|
|
78580
78658
|
);
|
|
78581
78659
|
logger.error(
|
|
78582
78660
|
LogEvent.ONCHAINOS_CLI_ERROR,
|
|
78583
|
-
|
|
78661
|
+
new Error("onchainos command failed"),
|
|
78584
78662
|
{
|
|
78585
|
-
|
|
78663
|
+
operation: redactArgsForLog(args).slice(0, 3).join(" "),
|
|
78664
|
+
argCount: String(args.length),
|
|
78586
78665
|
exitCode: String(err2?.code ?? ""),
|
|
78587
78666
|
signal: String(err2?.signal ?? ""),
|
|
78588
78667
|
killed: String(err2?.killed ?? ""),
|
|
78589
|
-
|
|
78590
|
-
|
|
78591
|
-
|
|
78668
|
+
stderrBytes: String(Buffer.byteLength(String(err2?.stderr ?? ""), "utf8")),
|
|
78669
|
+
stdoutBytes: String(Buffer.byteLength(String(err2?.stdout ?? ""), "utf8")),
|
|
78670
|
+
cliErrorName: err2 instanceof Error ? err2.name : "",
|
|
78671
|
+
cliErrorMessageLength: String(String(err2?.message ?? "").length),
|
|
78592
78672
|
durationMs: String(Date.now() - t0)
|
|
78593
78673
|
}
|
|
78594
78674
|
);
|
|
@@ -78615,12 +78695,25 @@ var CliErrorReason = {
|
|
|
78615
78695
|
OK_FALSE: "ok_false",
|
|
78616
78696
|
JSON_PARSE_FAILED: "json_parse_failed"
|
|
78617
78697
|
};
|
|
78698
|
+
function cliResponseExtras(stdout) {
|
|
78699
|
+
let responseJson = "0";
|
|
78700
|
+
try {
|
|
78701
|
+
JSON.parse(stdout);
|
|
78702
|
+
responseJson = "1";
|
|
78703
|
+
} catch {
|
|
78704
|
+
responseJson = "0";
|
|
78705
|
+
}
|
|
78706
|
+
return {
|
|
78707
|
+
responseBytes: String(Buffer.byteLength(stdout, "utf8")),
|
|
78708
|
+
responseJson
|
|
78709
|
+
};
|
|
78710
|
+
}
|
|
78618
78711
|
function cliOkFalseExtras(stdout, command, extra) {
|
|
78619
78712
|
return {
|
|
78620
|
-
command,
|
|
78713
|
+
operation: command,
|
|
78621
78714
|
reason: CliErrorReason.OK_FALSE,
|
|
78622
|
-
...
|
|
78623
|
-
|
|
78715
|
+
...cliResponseExtras(stdout),
|
|
78716
|
+
...extra
|
|
78624
78717
|
};
|
|
78625
78718
|
}
|
|
78626
78719
|
function parseCliJson(stdout, command, extras = {}) {
|
|
@@ -78629,10 +78722,10 @@ function parseCliJson(stdout, command, extras = {}) {
|
|
|
78629
78722
|
} catch (err2) {
|
|
78630
78723
|
const parseErr = err2 instanceof Error ? err2 : new Error(String(err2));
|
|
78631
78724
|
logger.error(LogEvent.ONCHAINOS_CLI_ERROR, parseErr, {
|
|
78632
|
-
command,
|
|
78725
|
+
operation: command,
|
|
78633
78726
|
reason: CliErrorReason.JSON_PARSE_FAILED,
|
|
78634
|
-
...
|
|
78635
|
-
|
|
78727
|
+
...cliResponseExtras(stdout),
|
|
78728
|
+
...extras
|
|
78636
78729
|
});
|
|
78637
78730
|
throw parseErr;
|
|
78638
78731
|
}
|
|
@@ -78707,7 +78800,7 @@ async function fetchAgentPage(page) {
|
|
|
78707
78800
|
);
|
|
78708
78801
|
if (!res.ok) {
|
|
78709
78802
|
guardSessionExpired(stdout, "list-agents");
|
|
78710
|
-
const parseErr = new Error(
|
|
78803
|
+
const parseErr = new Error("onchainos agent get failed");
|
|
78711
78804
|
logger.error(
|
|
78712
78805
|
LogEvent.ONCHAINOS_CLI_ERROR,
|
|
78713
78806
|
parseErr,
|
|
@@ -78751,9 +78844,7 @@ async function fetchAgentsByIds(agentIds) {
|
|
|
78751
78844
|
);
|
|
78752
78845
|
if (!res.ok) {
|
|
78753
78846
|
guardSessionExpired(stdout, "get-agents-by-ids");
|
|
78754
|
-
const parseErr = new Error(
|
|
78755
|
-
`onchainos agent get --agent-ids failed: ${stdout}`
|
|
78756
|
-
);
|
|
78847
|
+
const parseErr = new Error("onchainos agent get --agent-ids failed");
|
|
78757
78848
|
logger.error(
|
|
78758
78849
|
LogEvent.ONCHAINOS_CLI_ERROR,
|
|
78759
78850
|
parseErr,
|
|
@@ -78805,9 +78896,7 @@ async function fetchAgentByAddress(communicationAddress) {
|
|
|
78805
78896
|
);
|
|
78806
78897
|
if (!res.ok) {
|
|
78807
78898
|
guardSessionExpired(stdout, "get-agent-by-address");
|
|
78808
|
-
const parseErr = new Error(
|
|
78809
|
-
`onchainos agent get-by-address failed: ${stdout}`
|
|
78810
|
-
);
|
|
78899
|
+
const parseErr = new Error("onchainos agent get-by-address failed");
|
|
78811
78900
|
logger.error(
|
|
78812
78901
|
LogEvent.ONCHAINOS_CLI_ERROR,
|
|
78813
78902
|
parseErr,
|
|
@@ -78915,16 +79004,7 @@ async function sendHeartbeat(chainIndex) {
|
|
|
78915
79004
|
throw err2;
|
|
78916
79005
|
}
|
|
78917
79006
|
}
|
|
78918
|
-
function shouldBypassMessageEligibleForMockIntegration() {
|
|
78919
|
-
return true;
|
|
78920
|
-
}
|
|
78921
79007
|
async function checkMessageEligible(params) {
|
|
78922
|
-
if (shouldBypassMessageEligibleForMockIntegration()) {
|
|
78923
|
-
console.log(
|
|
78924
|
-
`[onchainos] message-eligible temporarily bypassed: job=${params.jobId} direction=${params.direction}`
|
|
78925
|
-
);
|
|
78926
|
-
return { eligible: true, reason: "temporarily-bypassed-for-mock-integration" };
|
|
78927
|
-
}
|
|
78928
79008
|
console.log(
|
|
78929
79009
|
`[onchainos] checking message-eligible: job=${params.jobId} direction=${params.direction} providerSecurityRate=${params.providerSecurityRate}`
|
|
78930
79010
|
);
|
|
@@ -78955,29 +79035,34 @@ async function checkMessageEligible(params) {
|
|
|
78955
79035
|
]));
|
|
78956
79036
|
} catch (err2) {
|
|
78957
79037
|
guardCatchSessionExpired(err2, "message-eligible");
|
|
78958
|
-
return { eligible:
|
|
79038
|
+
return { eligible: false, reason: "message-eligible-cli-error" };
|
|
78959
79039
|
}
|
|
78960
79040
|
if (stderr) {
|
|
78961
79041
|
console.log(`[onchainos] stderr (message-eligible): ${stderr}`);
|
|
78962
79042
|
}
|
|
78963
|
-
|
|
78964
|
-
|
|
78965
|
-
|
|
78966
|
-
|
|
78967
|
-
|
|
78968
|
-
|
|
78969
|
-
|
|
78970
|
-
|
|
78971
|
-
|
|
78972
|
-
|
|
78973
|
-
|
|
79043
|
+
let res;
|
|
79044
|
+
try {
|
|
79045
|
+
res = parseCliJson(stdout, "message-eligible", {
|
|
79046
|
+
onchainosAgentId: params.agentId,
|
|
79047
|
+
clientAgentId: params.clientAgentId,
|
|
79048
|
+
providerAgentId: params.providerAgentId,
|
|
79049
|
+
clientCommunicationAddress: params.clientCommunicationAddress,
|
|
79050
|
+
providerCommunicationAddress: params.providerCommunicationAddress,
|
|
79051
|
+
jobId: params.jobId,
|
|
79052
|
+
groupId: params.groupId,
|
|
79053
|
+
direction: params.direction,
|
|
79054
|
+
providerSecurityRate: String(params.providerSecurityRate)
|
|
79055
|
+
});
|
|
79056
|
+
} catch {
|
|
79057
|
+
return { eligible: false, reason: "message-eligible-json-parse-failed" };
|
|
79058
|
+
}
|
|
78974
79059
|
if (!res.ok) {
|
|
78975
79060
|
guardSessionExpired(stdout, "message-eligible");
|
|
78976
79061
|
console.warn(
|
|
78977
|
-
`[onchainos] message-eligible ok=false,
|
|
79062
|
+
`[onchainos] message-eligible ok=false, blocking message: ${stdout.slice(0, 200)}`
|
|
78978
79063
|
);
|
|
78979
79064
|
logger.error(
|
|
78980
|
-
LogEvent.
|
|
79065
|
+
LogEvent.ONCHAINOS_CLI_ERROR,
|
|
78981
79066
|
new Error("message-eligible ok=false"),
|
|
78982
79067
|
cliOkFalseExtras(stdout, "message-eligible", {
|
|
78983
79068
|
onchainosAgentId: params.agentId,
|
|
@@ -78993,7 +79078,7 @@ async function checkMessageEligible(params) {
|
|
|
78993
79078
|
reason: "ok=false"
|
|
78994
79079
|
})
|
|
78995
79080
|
);
|
|
78996
|
-
return { eligible:
|
|
79081
|
+
return { eligible: false, reason: "message-eligible-ok-false" };
|
|
78997
79082
|
}
|
|
78998
79083
|
console.log(
|
|
78999
79084
|
`[onchainos] message-eligible result: eligible=${res.data.eligible}`
|
|
@@ -79667,25 +79752,22 @@ async function verifyInboundA2AGroupMessage(params) {
|
|
|
79667
79752
|
}
|
|
79668
79753
|
} catch (err2) {
|
|
79669
79754
|
console.log(
|
|
79670
|
-
`[okx-agent-task:${myXmtpAddress}] message-eligible call failed,
|
|
79755
|
+
`[okx-agent-task:${myXmtpAddress}] message-eligible call failed, dropping:`,
|
|
79671
79756
|
err2
|
|
79672
79757
|
);
|
|
79673
|
-
logger.
|
|
79674
|
-
|
|
79675
|
-
|
|
79676
|
-
|
|
79677
|
-
|
|
79678
|
-
|
|
79679
|
-
|
|
79680
|
-
|
|
79681
|
-
|
|
79682
|
-
|
|
79683
|
-
|
|
79684
|
-
|
|
79685
|
-
|
|
79686
|
-
reason: "exception"
|
|
79687
|
-
}
|
|
79688
|
-
);
|
|
79758
|
+
logger.info(LogEvent.INBOUND_BLOCKED_INELIGIBLE, {
|
|
79759
|
+
...agentExtras({ walletAddress: myXmtpAddress, onchainosAgentId: myAgent.agentId }),
|
|
79760
|
+
peerWalletAddress: senderAddress,
|
|
79761
|
+
peerInboxId: senderInboxId,
|
|
79762
|
+
peerAgentId: senderAgentId,
|
|
79763
|
+
taskId: jobId,
|
|
79764
|
+
conversationId: groupId,
|
|
79765
|
+
messageId,
|
|
79766
|
+
direction: isSenderClient ? "client_to_provider" : "provider_to_client",
|
|
79767
|
+
providerSecurityRate: String(providerSecurityRate),
|
|
79768
|
+
reason: "exception"
|
|
79769
|
+
});
|
|
79770
|
+
return false;
|
|
79689
79771
|
}
|
|
79690
79772
|
return true;
|
|
79691
79773
|
}
|
|
@@ -79996,8 +80078,26 @@ function buildSendEnvelope(params) {
|
|
|
79996
80078
|
return buildA2AEnvelope({ ...params, tips });
|
|
79997
80079
|
}
|
|
79998
80080
|
|
|
80081
|
+
// ../core/src/a2a/concurrency.ts
|
|
80082
|
+
async function withSharedPromise(registry, key, fn) {
|
|
80083
|
+
const existing = registry.get(key);
|
|
80084
|
+
if (existing) {
|
|
80085
|
+
return existing;
|
|
80086
|
+
}
|
|
80087
|
+
const run = fn();
|
|
80088
|
+
registry.set(key, run);
|
|
80089
|
+
try {
|
|
80090
|
+
return await run;
|
|
80091
|
+
} finally {
|
|
80092
|
+
if (registry.get(key) === run) {
|
|
80093
|
+
registry.delete(key);
|
|
80094
|
+
}
|
|
80095
|
+
}
|
|
80096
|
+
}
|
|
80097
|
+
|
|
79999
80098
|
// src/xmtp-send.ts
|
|
80000
80099
|
var TASK_MIN_VERSION = 1;
|
|
80100
|
+
var sqliteGroupSessionPromises = /* @__PURE__ */ new Map();
|
|
80001
80101
|
function isPlainObject2(value) {
|
|
80002
80102
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
80003
80103
|
}
|
|
@@ -80209,10 +80309,10 @@ async function assertOutboundEligible(params) {
|
|
|
80209
80309
|
});
|
|
80210
80310
|
} catch (err2) {
|
|
80211
80311
|
console.log(
|
|
80212
|
-
`[okx-agent-task] outbound message-eligible call failed,
|
|
80312
|
+
`[okx-agent-task] outbound message-eligible call failed, blocking send: senderAgentId=${senderAgent.agentId} receiverAgentId=${receiverAgent.agentId} job=${jobId} group=${groupId}`,
|
|
80213
80313
|
err2
|
|
80214
80314
|
);
|
|
80215
|
-
|
|
80315
|
+
throw new Error("unable to verify message eligibility for this task/group");
|
|
80216
80316
|
}
|
|
80217
80317
|
console.log(
|
|
80218
80318
|
`[okx-agent-task] outbound message-eligible: senderAgentId=${senderAgent.agentId} receiverAgentId=${receiverAgent.agentId} job=${jobId} group=${groupId} result=${JSON.stringify(result)}`
|
|
@@ -80531,45 +80631,53 @@ async function handleSqliteGroupSendCommand(params) {
|
|
|
80531
80631
|
myAgentId: command.myAgentId,
|
|
80532
80632
|
toAgentId: toAgentKey
|
|
80533
80633
|
});
|
|
80534
|
-
const
|
|
80535
|
-
const stored = readStoredSessionFromMeta(existingMeta);
|
|
80634
|
+
const promiseKey = `${command.myAgentId}|${command.jobId}|${toAgentKey}`;
|
|
80536
80635
|
const agent = service.getClientByAddress(myXmtpAddress);
|
|
80537
80636
|
if (!agent) {
|
|
80538
80637
|
throw new Error(`no XMTP client found for ${myXmtpAddress}`);
|
|
80539
80638
|
}
|
|
80540
|
-
|
|
80541
|
-
|
|
80542
|
-
|
|
80543
|
-
|
|
80544
|
-
|
|
80545
|
-
|
|
80546
|
-
|
|
80547
|
-
|
|
80548
|
-
|
|
80549
|
-
|
|
80550
|
-
|
|
80551
|
-
|
|
80552
|
-
|
|
80553
|
-
|
|
80554
|
-
|
|
80639
|
+
const { conversation, created } = await withSharedPromise(
|
|
80640
|
+
sqliteGroupSessionPromises,
|
|
80641
|
+
promiseKey,
|
|
80642
|
+
async () => {
|
|
80643
|
+
const existingMeta = sessionStore.getSession(sessionKey);
|
|
80644
|
+
const stored = readStoredSessionFromMeta(existingMeta);
|
|
80645
|
+
let conversation2 = null;
|
|
80646
|
+
let xmtpGroupId = stored?.xmtpGroupId ?? existingMeta?.groupId ?? null;
|
|
80647
|
+
let created2 = false;
|
|
80648
|
+
if (xmtpGroupId) {
|
|
80649
|
+
conversation2 = await findGroupConversation(agent, xmtpGroupId);
|
|
80650
|
+
}
|
|
80651
|
+
if (!conversation2) {
|
|
80652
|
+
const toIdentifier = {
|
|
80653
|
+
identifier: remote.toXmtpAddress,
|
|
80654
|
+
identifierKind: 0
|
|
80655
|
+
};
|
|
80656
|
+
const canMessageResult = await agent.client.canMessage([toIdentifier]);
|
|
80657
|
+
const reachable = canMessageResult.get(remote.toXmtpAddress) ?? canMessageResult.get(remote.toXmtpAddress.toLowerCase());
|
|
80658
|
+
if (reachable === false) {
|
|
80659
|
+
throw new Error(`${remote.toXmtpAddress} is not registered on XMTP`);
|
|
80660
|
+
}
|
|
80661
|
+
conversation2 = await agent.client.conversations.newGroupWithIdentifiers(
|
|
80662
|
+
[toIdentifier],
|
|
80663
|
+
{ groupName: `a2a-${command.jobId}` }
|
|
80664
|
+
);
|
|
80665
|
+
xmtpGroupId = conversation2.id;
|
|
80666
|
+
created2 = true;
|
|
80667
|
+
await service.allowGroup(myXmtpAddress, conversation2.id);
|
|
80668
|
+
}
|
|
80669
|
+
sessionStore.upsertSession({
|
|
80670
|
+
sessionKey,
|
|
80671
|
+
jobId: command.jobId,
|
|
80672
|
+
myAgentId: command.myAgentId,
|
|
80673
|
+
toAgentId: remote.toAgentId ?? command.toAgentId ?? null,
|
|
80674
|
+
groupId: xmtpGroupId,
|
|
80675
|
+
myAgentXmtpAddress: myXmtpAddress,
|
|
80676
|
+
toAgentXmtpAddress: remote.toXmtpAddress
|
|
80677
|
+
});
|
|
80678
|
+
return { conversation: conversation2, created: created2 };
|
|
80555
80679
|
}
|
|
80556
|
-
|
|
80557
|
-
[toIdentifier],
|
|
80558
|
-
{ groupName: `a2a-${command.jobId}` }
|
|
80559
|
-
);
|
|
80560
|
-
xmtpGroupId = conversation.id;
|
|
80561
|
-
created = true;
|
|
80562
|
-
await service.allowGroup(myXmtpAddress, conversation.id);
|
|
80563
|
-
}
|
|
80564
|
-
sessionStore.upsertSession({
|
|
80565
|
-
sessionKey,
|
|
80566
|
-
jobId: command.jobId,
|
|
80567
|
-
myAgentId: command.myAgentId,
|
|
80568
|
-
toAgentId: remote.toAgentId ?? command.toAgentId ?? null,
|
|
80569
|
-
groupId: xmtpGroupId,
|
|
80570
|
-
myAgentXmtpAddress: myXmtpAddress,
|
|
80571
|
-
toAgentXmtpAddress: remote.toXmtpAddress
|
|
80572
|
-
});
|
|
80680
|
+
);
|
|
80573
80681
|
const senderAgent = service.getAgentByAddress(myXmtpAddress);
|
|
80574
80682
|
await assertOutboundEligible({
|
|
80575
80683
|
senderAgent,
|
|
@@ -80975,7 +81083,7 @@ async function onchainosSign(agentId, keyUuid, walletAddress, message) {
|
|
|
80975
81083
|
if (isSessionExpired(stdout)) {
|
|
80976
81084
|
notifySessionExpired("xmtp-sign");
|
|
80977
81085
|
}
|
|
80978
|
-
const signErr = new Error(
|
|
81086
|
+
const signErr = new Error("onchainos xmtp-sign failed");
|
|
80979
81087
|
logger.error(
|
|
80980
81088
|
LogEvent.ONCHAINOS_CLI_ERROR,
|
|
80981
81089
|
signErr,
|
|
@@ -81249,6 +81357,14 @@ function trimForUser2(value) {
|
|
|
81249
81357
|
return value.length > maxLength ? `${value.slice(0, maxLength)}...` : value;
|
|
81250
81358
|
}
|
|
81251
81359
|
|
|
81360
|
+
// ../core/src/sentry-config.ts
|
|
81361
|
+
var environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
81362
|
+
var SENTRY_CONFIG = {
|
|
81363
|
+
projectName: "okx/openclaw-okx-a2a-extension",
|
|
81364
|
+
release: "0.0.2-beta-38940d220c-260605180610",
|
|
81365
|
+
environment
|
|
81366
|
+
};
|
|
81367
|
+
|
|
81252
81368
|
// src/listener.ts
|
|
81253
81369
|
var OFFLINE_REPLAY_SYNC_INTERVAL = 5;
|
|
81254
81370
|
function shouldRunOfflineReplay(syncCount, interval = OFFLINE_REPLAY_SYNC_INTERVAL) {
|
|
@@ -81334,14 +81450,32 @@ async function runListenerWithLock(options, paths) {
|
|
|
81334
81450
|
}));
|
|
81335
81451
|
}
|
|
81336
81452
|
});
|
|
81337
|
-
service.setPluginVersion("0.0.
|
|
81453
|
+
service.setPluginVersion("0.0.2-beta-38940d220c-260605180610");
|
|
81338
81454
|
await service.init();
|
|
81339
81455
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
81340
81456
|
if (pluginVersionStatus.unavailable) {
|
|
81341
81457
|
throw new Error(
|
|
81342
|
-
`@okxweb3/a2a-node v${"0.0.
|
|
81458
|
+
`@okxweb3/a2a-node v${"0.0.2-beta-38940d220c-260605180610"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
81343
81459
|
);
|
|
81344
81460
|
}
|
|
81461
|
+
const systemConfig = service.getSystemConfig();
|
|
81462
|
+
if (systemConfig.sentryDsn) {
|
|
81463
|
+
initLogger({
|
|
81464
|
+
dsn: systemConfig.sentryDsn,
|
|
81465
|
+
...SENTRY_CONFIG,
|
|
81466
|
+
agentPlatform: "node"
|
|
81467
|
+
});
|
|
81468
|
+
} else {
|
|
81469
|
+
console.error(
|
|
81470
|
+
"[okx-agent-task] system-config did not return sentryDsn; Sentry not initialized"
|
|
81471
|
+
);
|
|
81472
|
+
logger.error(LogEvent.SENTRY_INIT_SKIPPED, void 0, {
|
|
81473
|
+
onchainosAgentId: "*",
|
|
81474
|
+
reason: "system-config missing sentryDsn",
|
|
81475
|
+
pluginId: "@okxweb3/a2a-node",
|
|
81476
|
+
pluginVersion: "0.0.2-beta-38940d220c-260605180610"
|
|
81477
|
+
});
|
|
81478
|
+
}
|
|
81345
81479
|
console.log(
|
|
81346
81480
|
`[okx-agent-task] listener initialized, clients=${service.getClients().size}, home=${store.homeDir}`
|
|
81347
81481
|
);
|
|
@@ -81384,10 +81518,47 @@ async function runListenerWithLock(options, paths) {
|
|
|
81384
81518
|
syncInFlight = false;
|
|
81385
81519
|
}
|
|
81386
81520
|
};
|
|
81387
|
-
|
|
81388
|
-
|
|
81389
|
-
|
|
81390
|
-
|
|
81521
|
+
let intervalSec = Math.max(10, service.getSystemConfig().heartbeatInterval);
|
|
81522
|
+
let timer;
|
|
81523
|
+
let stopping = false;
|
|
81524
|
+
const scheduleSyncTimer = (nextIntervalSec) => {
|
|
81525
|
+
if (stopping) {
|
|
81526
|
+
return;
|
|
81527
|
+
}
|
|
81528
|
+
if (timer) {
|
|
81529
|
+
clearInterval(timer);
|
|
81530
|
+
}
|
|
81531
|
+
intervalSec = Math.max(10, nextIntervalSec);
|
|
81532
|
+
console.log(`[okx-agent-task] scheduled sync interval ${intervalSec}s`);
|
|
81533
|
+
timer = setInterval(() => {
|
|
81534
|
+
void syncTick();
|
|
81535
|
+
}, intervalSec * 1e3);
|
|
81536
|
+
};
|
|
81537
|
+
const refreshSystemConfigTick = async () => {
|
|
81538
|
+
if (stopping) {
|
|
81539
|
+
return;
|
|
81540
|
+
}
|
|
81541
|
+
const previousIntervalSec = intervalSec;
|
|
81542
|
+
try {
|
|
81543
|
+
await service.refreshSystemConfig();
|
|
81544
|
+
if (stopping) {
|
|
81545
|
+
return;
|
|
81546
|
+
}
|
|
81547
|
+
const nextIntervalSec = Math.max(10, service.getSystemConfig().heartbeatInterval);
|
|
81548
|
+
if (nextIntervalSec !== previousIntervalSec) {
|
|
81549
|
+
console.log(
|
|
81550
|
+
`[okx-agent-task] heartbeat interval changed from ${previousIntervalSec}s to ${nextIntervalSec}s; rescheduling sync timer`
|
|
81551
|
+
);
|
|
81552
|
+
scheduleSyncTimer(nextIntervalSec);
|
|
81553
|
+
}
|
|
81554
|
+
} catch (err2) {
|
|
81555
|
+
console.log("[okx-agent-task] system-config refresh failed:", err2);
|
|
81556
|
+
}
|
|
81557
|
+
};
|
|
81558
|
+
scheduleSyncTimer(intervalSec);
|
|
81559
|
+
const systemConfigRefreshTimer = setInterval(() => {
|
|
81560
|
+
void refreshSystemConfigTick();
|
|
81561
|
+
}, 60 * 60 * 1e3);
|
|
81391
81562
|
void syncTick();
|
|
81392
81563
|
const commandProcessor = startCommandProcessor({
|
|
81393
81564
|
service,
|
|
@@ -81396,7 +81567,6 @@ async function runListenerWithLock(options, paths) {
|
|
|
81396
81567
|
homeDir: options.homeDir
|
|
81397
81568
|
});
|
|
81398
81569
|
await new Promise((resolve3) => {
|
|
81399
|
-
let stopping = false;
|
|
81400
81570
|
const shutdown = (signal) => {
|
|
81401
81571
|
if (stopping) {
|
|
81402
81572
|
return;
|
|
@@ -81408,7 +81578,10 @@ async function runListenerWithLock(options, paths) {
|
|
|
81408
81578
|
resolve3();
|
|
81409
81579
|
}, SHUTDOWN_FORCE_RESOLVE_MS);
|
|
81410
81580
|
void (async () => {
|
|
81411
|
-
|
|
81581
|
+
if (timer) {
|
|
81582
|
+
clearInterval(timer);
|
|
81583
|
+
}
|
|
81584
|
+
clearInterval(systemConfigRefreshTimer);
|
|
81412
81585
|
commandProcessor.stop();
|
|
81413
81586
|
try {
|
|
81414
81587
|
await userAttentionEvents?.close();
|