@okxweb3/a2a-node 0.0.11-beta-a2f19c7d0e-260620230358 → 0.0.11
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 +153 -93
- package/dist/index.js +26 -16
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3323,7 +3323,7 @@ var init_user_attention_ipc = __esm({
|
|
|
3323
3323
|
function resolveOpenClawGatewayConfigPath(homeDir = resolveA2aTaskHome()) {
|
|
3324
3324
|
return (0, import_node_path10.join)(homeDir, "openclaw-gateway.json");
|
|
3325
3325
|
}
|
|
3326
|
-
function
|
|
3326
|
+
function readSyncedOpenClawGatewayConfig2(homeDir = resolveA2aTaskHome()) {
|
|
3327
3327
|
const filePath = resolveOpenClawGatewayConfigPath(homeDir);
|
|
3328
3328
|
if (!(0, import_node_fs7.existsSync)(filePath)) {
|
|
3329
3329
|
return null;
|
|
@@ -7127,8 +7127,8 @@ async function callOpenClawGateway(opts) {
|
|
|
7127
7127
|
async function callSessionsCreate(params) {
|
|
7128
7128
|
return callOpenClawGateway({ method: "sessions.create", params });
|
|
7129
7129
|
}
|
|
7130
|
-
async function
|
|
7131
|
-
return callOpenClawGateway({ method: "
|
|
7130
|
+
async function callDeleteSessions(params) {
|
|
7131
|
+
return await callOpenClawGateway({ method: "okx-a2a.delete_sessions", params });
|
|
7132
7132
|
}
|
|
7133
7133
|
async function callSessionsSend(params) {
|
|
7134
7134
|
const idempotencyKey = params.idempotencyKey ?? (0, import_node_crypto3.randomUUID)();
|
|
@@ -7184,7 +7184,7 @@ async function sleep(ms) {
|
|
|
7184
7184
|
}
|
|
7185
7185
|
function readSyncedGatewayConfig(env) {
|
|
7186
7186
|
try {
|
|
7187
|
-
const synced =
|
|
7187
|
+
const synced = readSyncedOpenClawGatewayConfig2(env.OKX_AGENT_TASK_HOME);
|
|
7188
7188
|
if (!synced) {
|
|
7189
7189
|
return null;
|
|
7190
7190
|
}
|
|
@@ -7205,7 +7205,7 @@ function buildConnectParams(config, instanceId) {
|
|
|
7205
7205
|
client: {
|
|
7206
7206
|
id: "gateway-client",
|
|
7207
7207
|
displayName: "okx-a2a-node",
|
|
7208
|
-
version: "0.0.11
|
|
7208
|
+
version: "0.0.11",
|
|
7209
7209
|
platform: "node",
|
|
7210
7210
|
mode: "backend",
|
|
7211
7211
|
instanceId
|
|
@@ -7216,7 +7216,7 @@ function buildConnectParams(config, instanceId) {
|
|
|
7216
7216
|
commands: [],
|
|
7217
7217
|
permissions: {},
|
|
7218
7218
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
7219
|
-
userAgent: `okx-a2a-node/${"0.0.11
|
|
7219
|
+
userAgent: `okx-a2a-node/${"0.0.11"}`,
|
|
7220
7220
|
auth: {
|
|
7221
7221
|
...config.token ? { token: config.token } : {},
|
|
7222
7222
|
...config.password ? { password: config.password } : {}
|
|
@@ -7457,8 +7457,7 @@ function toOpenClawGatewaySessionKey(input) {
|
|
|
7457
7457
|
return buildOpenClawGroupSessionKey(buildXmtpScopeKey({
|
|
7458
7458
|
jobId: input.jobId || peer.jobId,
|
|
7459
7459
|
myAgentId: input.myAgentId || peer.myAgentId,
|
|
7460
|
-
toAgentId: input.toAgentId || peer.toAgentId
|
|
7461
|
-
groupId: input.groupId || "_"
|
|
7460
|
+
toAgentId: input.toAgentId || peer.toAgentId
|
|
7462
7461
|
}));
|
|
7463
7462
|
}
|
|
7464
7463
|
return buildOpenClawGroupSessionKey(input.sessionKey);
|
|
@@ -7484,8 +7483,7 @@ function buildXmtpScopeKey(input) {
|
|
|
7484
7483
|
const qs = new URLSearchParams({
|
|
7485
7484
|
my: input.myAgentId,
|
|
7486
7485
|
to: input.toAgentId,
|
|
7487
|
-
job: input.jobId
|
|
7488
|
-
gid: input.groupId
|
|
7486
|
+
job: input.jobId
|
|
7489
7487
|
});
|
|
7490
7488
|
return `${XMTP_SCOPE_PREFIX}:${qs.toString()}`;
|
|
7491
7489
|
}
|
|
@@ -23370,7 +23368,7 @@ var init_outbound_behavior = __esm({
|
|
|
23370
23368
|
};
|
|
23371
23369
|
DEFAULT_GATEWAY_PORT2 = {
|
|
23372
23370
|
callSessionsCreate,
|
|
23373
|
-
|
|
23371
|
+
callDeleteSessions,
|
|
23374
23372
|
callSessionsSend,
|
|
23375
23373
|
callChatInject,
|
|
23376
23374
|
callDispatchUserToLatestSessions,
|
|
@@ -23408,17 +23406,24 @@ var init_outbound_behavior = __esm({
|
|
|
23408
23406
|
}
|
|
23409
23407
|
}
|
|
23410
23408
|
async deleteSession(input) {
|
|
23409
|
+
const stored = this.sessionMetaStore?.getSession(input.sessionKey);
|
|
23411
23410
|
const gatewaySessionKey = this.resolveGatewaySessionKey(input);
|
|
23412
23411
|
console.error(`${GATEWAY_OUTBOUND_LOG_PREFIX} deleteSession sessionKey=${input.sessionKey} gatewaySessionKey=${gatewaySessionKey}`);
|
|
23413
23412
|
try {
|
|
23414
|
-
await this.gateway.
|
|
23415
|
-
console.error(`${GATEWAY_OUTBOUND_LOG_PREFIX} deleteSession ok sessionKey=${input.sessionKey} gatewaySessionKey=${gatewaySessionKey}`);
|
|
23416
|
-
logger.info(LogEvent.SESSION_DELETED, gatewayOutboundExtra("sessions.delete", {
|
|
23413
|
+
const result = await this.gateway.callDeleteSessions({
|
|
23417
23414
|
sessionKey: input.sessionKey,
|
|
23418
|
-
|
|
23415
|
+
...stored?.jobId ? { jobId: stored.jobId } : {},
|
|
23416
|
+
...stored?.myAgentId ? { myAgentId: stored.myAgentId } : {},
|
|
23417
|
+
...stored?.toAgentId ? { toAgentId: stored.toAgentId } : {}
|
|
23418
|
+
});
|
|
23419
|
+
console.error(`${GATEWAY_OUTBOUND_LOG_PREFIX} deleteSession ok sessionKey=${input.sessionKey} gatewaySessionKey=${gatewaySessionKey} deleted=${result.deleted ?? "(unknown)"}`);
|
|
23420
|
+
logger.info(LogEvent.SESSION_DELETED, gatewayOutboundExtra("okx-a2a.delete_sessions", {
|
|
23421
|
+
sessionKey: input.sessionKey,
|
|
23422
|
+
gatewaySessionKey,
|
|
23423
|
+
deleted: result.deleted ?? ""
|
|
23419
23424
|
}));
|
|
23420
23425
|
} catch (err2) {
|
|
23421
|
-
logger.error(LogEvent.GATEWAY_REQUEST_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), gatewayOutboundExtra("
|
|
23426
|
+
logger.error(LogEvent.GATEWAY_REQUEST_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), gatewayOutboundExtra("okx-a2a.delete_sessions", {
|
|
23422
23427
|
sessionKey: input.sessionKey,
|
|
23423
23428
|
gatewaySessionKey
|
|
23424
23429
|
}));
|
|
@@ -23710,7 +23715,7 @@ var init_sentry_config = __esm({
|
|
|
23710
23715
|
environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
23711
23716
|
SENTRY_CONFIG = {
|
|
23712
23717
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
23713
|
-
release: "0.0.11
|
|
23718
|
+
release: "0.0.11",
|
|
23714
23719
|
environment
|
|
23715
23720
|
};
|
|
23716
23721
|
}
|
|
@@ -90673,12 +90678,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
90673
90678
|
}));
|
|
90674
90679
|
}
|
|
90675
90680
|
});
|
|
90676
|
-
service.setPluginVersion("0.0.11
|
|
90681
|
+
service.setPluginVersion("0.0.11");
|
|
90677
90682
|
await service.init();
|
|
90678
90683
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
90679
90684
|
if (pluginVersionStatus.unavailable) {
|
|
90680
90685
|
throw new Error(
|
|
90681
|
-
`@okxweb3/a2a-node v${"0.0.11
|
|
90686
|
+
`@okxweb3/a2a-node v${"0.0.11"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
90682
90687
|
);
|
|
90683
90688
|
}
|
|
90684
90689
|
const systemConfig = service.getSystemConfig();
|
|
@@ -90696,7 +90701,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
90696
90701
|
onchainosAgentId: "*",
|
|
90697
90702
|
reason: "system-config missing sentryDsn",
|
|
90698
90703
|
pluginId: "@okxweb3/a2a-node",
|
|
90699
|
-
pluginVersion: "0.0.11
|
|
90704
|
+
pluginVersion: "0.0.11"
|
|
90700
90705
|
});
|
|
90701
90706
|
}
|
|
90702
90707
|
console.log(
|
|
@@ -91332,52 +91337,51 @@ async function handleUserCommand(args) {
|
|
|
91332
91337
|
const store = new SessionStore();
|
|
91333
91338
|
const storeInitMs = Date.now() - storeInitStartedAt;
|
|
91334
91339
|
let usedOpenClawGateway = false;
|
|
91340
|
+
let quietUserAttentionConsole = false;
|
|
91335
91341
|
try {
|
|
91336
91342
|
if (!subcommand || subcommand === "help" || parsed.flags.has("help")) {
|
|
91337
91343
|
printUserUsage();
|
|
91338
91344
|
return;
|
|
91339
91345
|
}
|
|
91340
91346
|
if (subcommand === "notify") {
|
|
91347
|
+
quietUserAttentionConsole = true;
|
|
91341
91348
|
assertNoUserSessionKey(parsed, subcommand);
|
|
91342
91349
|
const jobId = readJobId(parsed);
|
|
91343
91350
|
const provider = resolveUserAttentionProvider(store, jobId);
|
|
91344
91351
|
const behavior = createOutboundBehavior(provider, { store });
|
|
91345
91352
|
usedOpenClawGateway = provider === "openclaw";
|
|
91346
91353
|
const sessionKey = readCurrentSessionKeyFromEnv();
|
|
91347
|
-
|
|
91348
|
-
|
|
91349
|
-
|
|
91350
|
-
|
|
91351
|
-
|
|
91352
|
-
|
|
91354
|
+
await runWithoutConsoleOutput(async () => {
|
|
91355
|
+
bindHermesAttentionRouteIfAvailable({ provider, jobId, sessionKey });
|
|
91356
|
+
await behavior.dispatchUser({
|
|
91357
|
+
userContent: readRequiredOption2(parsed, "content"),
|
|
91358
|
+
jobId,
|
|
91359
|
+
sessionKey,
|
|
91360
|
+
idempotencyKey: parsed.options.get("idempotency-key") ?? null
|
|
91361
|
+
});
|
|
91353
91362
|
});
|
|
91354
|
-
|
|
91355
|
-
json,
|
|
91356
|
-
{ ok: true, provider, item, wakeSent: item !== null },
|
|
91357
|
-
`created notification ${item?.id ?? "(gateway inject)"}`
|
|
91358
|
-
);
|
|
91363
|
+
outputOk();
|
|
91359
91364
|
return;
|
|
91360
91365
|
}
|
|
91361
91366
|
if (subcommand === "decision-request") {
|
|
91367
|
+
quietUserAttentionConsole = true;
|
|
91362
91368
|
assertNoUserSessionKey(parsed, subcommand);
|
|
91363
91369
|
const jobId = readJobId(parsed);
|
|
91364
91370
|
const provider = resolveUserAttentionProvider(store, jobId);
|
|
91365
91371
|
const behavior = createOutboundBehavior(provider, { store });
|
|
91366
91372
|
usedOpenClawGateway = provider === "openclaw";
|
|
91367
91373
|
const sessionKey = readCurrentSessionKeyFromEnv();
|
|
91368
|
-
|
|
91369
|
-
|
|
91370
|
-
|
|
91371
|
-
|
|
91372
|
-
|
|
91373
|
-
|
|
91374
|
-
|
|
91374
|
+
await runWithoutConsoleOutput(async () => {
|
|
91375
|
+
bindHermesAttentionRouteIfAvailable({ provider, jobId, sessionKey });
|
|
91376
|
+
await behavior.promptUser({
|
|
91377
|
+
userContent: readRequiredOption2(parsed, "user-content"),
|
|
91378
|
+
llmContent: readRequiredOption2(parsed, "llm-content"),
|
|
91379
|
+
jobId,
|
|
91380
|
+
sessionKey,
|
|
91381
|
+
idempotencyKey: parsed.options.get("idempotency-key") ?? null
|
|
91382
|
+
});
|
|
91375
91383
|
});
|
|
91376
|
-
|
|
91377
|
-
json,
|
|
91378
|
-
{ ok: true, provider, item, wakeSent: item !== null },
|
|
91379
|
-
`created decision_request ${item?.id ?? "(gateway inject)"}`
|
|
91380
|
-
);
|
|
91384
|
+
outputOk();
|
|
91381
91385
|
return;
|
|
91382
91386
|
}
|
|
91383
91387
|
if (subcommand === "list") {
|
|
@@ -91432,7 +91436,11 @@ async function handleUserCommand(args) {
|
|
|
91432
91436
|
throw new Error(`Unknown user command: ${subcommand}`);
|
|
91433
91437
|
} finally {
|
|
91434
91438
|
if (usedOpenClawGateway) {
|
|
91435
|
-
|
|
91439
|
+
if (quietUserAttentionConsole) {
|
|
91440
|
+
runSyncWithoutConsoleOutput(() => stopOpenClawGateway());
|
|
91441
|
+
} else {
|
|
91442
|
+
stopOpenClawGateway();
|
|
91443
|
+
}
|
|
91436
91444
|
}
|
|
91437
91445
|
store.close();
|
|
91438
91446
|
}
|
|
@@ -91723,6 +91731,37 @@ function output(json, payload, human) {
|
|
|
91723
91731
|
}
|
|
91724
91732
|
console.log(human);
|
|
91725
91733
|
}
|
|
91734
|
+
function outputOk() {
|
|
91735
|
+
process.stdout.write("ok\n");
|
|
91736
|
+
}
|
|
91737
|
+
async function runWithoutConsoleOutput(fn) {
|
|
91738
|
+
const originalLog = console.log;
|
|
91739
|
+
const originalError = console.error;
|
|
91740
|
+
console.log = () => {
|
|
91741
|
+
};
|
|
91742
|
+
console.error = () => {
|
|
91743
|
+
};
|
|
91744
|
+
try {
|
|
91745
|
+
return await fn();
|
|
91746
|
+
} finally {
|
|
91747
|
+
console.log = originalLog;
|
|
91748
|
+
console.error = originalError;
|
|
91749
|
+
}
|
|
91750
|
+
}
|
|
91751
|
+
function runSyncWithoutConsoleOutput(fn) {
|
|
91752
|
+
const originalLog = console.log;
|
|
91753
|
+
const originalError = console.error;
|
|
91754
|
+
console.log = () => {
|
|
91755
|
+
};
|
|
91756
|
+
console.error = () => {
|
|
91757
|
+
};
|
|
91758
|
+
try {
|
|
91759
|
+
fn();
|
|
91760
|
+
} finally {
|
|
91761
|
+
console.log = originalLog;
|
|
91762
|
+
console.error = originalError;
|
|
91763
|
+
}
|
|
91764
|
+
}
|
|
91726
91765
|
function parseArgs(args) {
|
|
91727
91766
|
const positional = [];
|
|
91728
91767
|
const options = /* @__PURE__ */ new Map();
|
|
@@ -91817,7 +91856,7 @@ function resolveUserAttentionProvider(store, jobId) {
|
|
|
91817
91856
|
if (boundOrConfigured) {
|
|
91818
91857
|
return boundOrConfigured;
|
|
91819
91858
|
}
|
|
91820
|
-
if (
|
|
91859
|
+
if (readSyncedOpenClawGatewayConfig2(store.homeDir)) {
|
|
91821
91860
|
if (jobId?.trim()) {
|
|
91822
91861
|
return store.bindJobProviderIfMissing({ jobId: jobId.trim(), provider: "openclaw" }).binding.provider;
|
|
91823
91862
|
}
|
|
@@ -91954,12 +91993,19 @@ function writeHermesRouteStore(path, store) {
|
|
|
91954
91993
|
(0, import_node_fs15.renameSync)(tempPath, path);
|
|
91955
91994
|
}
|
|
91956
91995
|
function logHermesRouteBinding(event, fields) {
|
|
91996
|
+
if (!isHermesRouteBindingDebugEnabled()) {
|
|
91997
|
+
return;
|
|
91998
|
+
}
|
|
91957
91999
|
console.error(JSON.stringify({
|
|
91958
92000
|
component: "user_attention_cli",
|
|
91959
92001
|
event,
|
|
91960
92002
|
...fields
|
|
91961
92003
|
}));
|
|
91962
92004
|
}
|
|
92005
|
+
function isHermesRouteBindingDebugEnabled() {
|
|
92006
|
+
const value = process.env.OKX_A2A_DEBUG_HERMES_ROUTE_BINDING ?? "";
|
|
92007
|
+
return value === "1" || value.toLowerCase() === "true";
|
|
92008
|
+
}
|
|
91963
92009
|
function isRecord2(value) {
|
|
91964
92010
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
91965
92011
|
}
|
|
@@ -92118,19 +92164,28 @@ async function handleSessionCommand(args) {
|
|
|
92118
92164
|
const missingSessionKeys = [];
|
|
92119
92165
|
let lastProvider = null;
|
|
92120
92166
|
let gatewayDeleted = 0;
|
|
92167
|
+
const exactSessionKey = parsed.options.get("session-key") ?? null;
|
|
92168
|
+
const jobId = parsed.options.get("job-id") ?? null;
|
|
92169
|
+
const toAgentId = parsed.options.get("to-agent-id") ?? null;
|
|
92170
|
+
const exactExisting = exactSessionKey ? store.getSession(exactSessionKey) : null;
|
|
92171
|
+
const provider = resolveSessionDeleteProvider(
|
|
92172
|
+
store,
|
|
92173
|
+
exactExisting?.jobId ?? (exactSessionKey ? inferJobIdFromSessionKey3(exactSessionKey) : jobId)
|
|
92174
|
+
);
|
|
92175
|
+
if (provider === "openclaw") {
|
|
92176
|
+
usedOpenClawGateway = true;
|
|
92177
|
+
lastProvider = provider;
|
|
92178
|
+
const result = await callDeleteSessions({
|
|
92179
|
+
...exactSessionKey ? { sessionKey: exactSessionKey } : {},
|
|
92180
|
+
...jobId ? { jobId } : {},
|
|
92181
|
+
...toAgentId ? { toAgentId } : {},
|
|
92182
|
+
...exactExisting?.jobId ? { jobId: exactExisting.jobId } : {},
|
|
92183
|
+
...exactExisting?.myAgentId ? { myAgentId: exactExisting.myAgentId } : {},
|
|
92184
|
+
...exactExisting?.toAgentId ? { toAgentId: exactExisting.toAgentId } : {}
|
|
92185
|
+
});
|
|
92186
|
+
gatewayDeleted = Number.isFinite(result.deleted) ? Number(result.deleted) : 0;
|
|
92187
|
+
}
|
|
92121
92188
|
for (const target of targets) {
|
|
92122
|
-
const existing = store.getSession(target.sessionKey);
|
|
92123
|
-
const provider = resolveSessionLifecycleProvider(
|
|
92124
|
-
store,
|
|
92125
|
-
existing?.jobId ?? inferJobIdFromSessionKey3(target.sessionKey)
|
|
92126
|
-
);
|
|
92127
|
-
const behavior = provider === "openclaw" ? createOutboundBehavior(provider, { store }) : null;
|
|
92128
|
-
if (existing && behavior) {
|
|
92129
|
-
usedOpenClawGateway = true;
|
|
92130
|
-
lastProvider = provider;
|
|
92131
|
-
await behavior.deleteSession({ sessionKey: target.sessionKey });
|
|
92132
|
-
gatewayDeleted += 1;
|
|
92133
|
-
}
|
|
92134
92189
|
const deleted = store.deleteSession(target.sessionKey);
|
|
92135
92190
|
if (deleted) {
|
|
92136
92191
|
deletedSessionKeys.push(target.sessionKey);
|
|
@@ -92138,25 +92193,26 @@ async function handleSessionCommand(args) {
|
|
|
92138
92193
|
missingSessionKeys.push(target.sessionKey);
|
|
92139
92194
|
}
|
|
92140
92195
|
}
|
|
92141
|
-
const
|
|
92196
|
+
const deleteSucceeded = deletedSessionKeys.length > 0 || gatewayDeleted > 0;
|
|
92197
|
+
const jobProviderBindingDeleted = deleteSucceeded && parsed.options.has("job-id") && !parsed.options.has("to-agent-id") ? store.deleteJobProviderBinding(readRequiredOption3(parsed, "job-id")) : false;
|
|
92142
92198
|
logger.info(LogEvent.SESSION_DELETED, sessionCliSentryExtra("session_delete", {
|
|
92143
92199
|
sessionKey: targets.map((target) => target.sessionKey).join(","),
|
|
92144
92200
|
status: deletedSessionKeys.length > 0 ? "deleted" : "not_found",
|
|
92145
92201
|
provider: lastProvider ?? ""
|
|
92146
92202
|
}));
|
|
92147
|
-
const
|
|
92148
|
-
if (
|
|
92149
|
-
const deleted = deletedSessionKeys.length === 1;
|
|
92203
|
+
const exactOutputSessionKey = targets.length === 1 && parsed.options.has("session-key") ? targets[0].sessionKey : null;
|
|
92204
|
+
if (exactOutputSessionKey) {
|
|
92205
|
+
const deleted = deletedSessionKeys.length === 1 || gatewayDeleted > 0;
|
|
92150
92206
|
output2(
|
|
92151
92207
|
json,
|
|
92152
|
-
{ ok: deleted, deleted, sessionKey:
|
|
92153
|
-
deleted ? `deleted ${
|
|
92208
|
+
{ ok: deleted, deleted, sessionKey: exactOutputSessionKey, provider: lastProvider, gatewayDeleted },
|
|
92209
|
+
deleted ? `deleted ${exactOutputSessionKey}` : `session not found: ${exactOutputSessionKey}`
|
|
92154
92210
|
);
|
|
92155
92211
|
} else {
|
|
92156
92212
|
output2(
|
|
92157
92213
|
json,
|
|
92158
92214
|
{
|
|
92159
|
-
ok:
|
|
92215
|
+
ok: deleteSucceeded,
|
|
92160
92216
|
deleted: deletedSessionKeys.length,
|
|
92161
92217
|
deletedSessionKeys,
|
|
92162
92218
|
missingSessionKeys,
|
|
@@ -92166,10 +92222,10 @@ async function handleSessionCommand(args) {
|
|
|
92166
92222
|
gatewayDeleted,
|
|
92167
92223
|
jobProviderBindingDeleted
|
|
92168
92224
|
},
|
|
92169
|
-
|
|
92225
|
+
deleteSucceeded ? formatDeleteSummary(deletedSessionKeys.length, gatewayDeleted) : "session not found"
|
|
92170
92226
|
);
|
|
92171
92227
|
}
|
|
92172
|
-
if (
|
|
92228
|
+
if (!deleteSucceeded) {
|
|
92173
92229
|
process.exitCode = 2;
|
|
92174
92230
|
}
|
|
92175
92231
|
return;
|
|
@@ -92213,7 +92269,7 @@ Commands:
|
|
|
92213
92269
|
delete (--session-key <key> | --job-id <id> [--to-agent-id <id>]) [--json]
|
|
92214
92270
|
dispatch --job-id <id> [--session-agent-id <id>] [--message-id <id>] [--json]
|
|
92215
92271
|
send (--session-key <key> | --job-id <id> [--to-agent-id <id>]) --content <text> [--agent-id <id>] [--message-id <id>] [--retry] [--json]
|
|
92216
|
-
gen-key --job-id <id>
|
|
92272
|
+
gen-key --job-id <id> (--my-agent-id <id> --to-agent-id <id> | --my-xmtp-address <address> --to-xmtp-address <address>) [--json]
|
|
92217
92273
|
`);
|
|
92218
92274
|
}
|
|
92219
92275
|
function printSessionSubcommandUsage(subcommand) {
|
|
@@ -92326,13 +92382,12 @@ Options:
|
|
|
92326
92382
|
return true;
|
|
92327
92383
|
}
|
|
92328
92384
|
if (subcommand === "gen-key") {
|
|
92329
|
-
console.log(`Usage: okx-a2a session gen-key --job-id <id>
|
|
92385
|
+
console.log(`Usage: okx-a2a session gen-key --job-id <id> (--my-agent-id <id> --to-agent-id <id> | --my-xmtp-address <address> --to-xmtp-address <address>) [--json]
|
|
92330
92386
|
|
|
92331
92387
|
Generate a deterministic local session key.
|
|
92332
92388
|
|
|
92333
92389
|
Options:
|
|
92334
92390
|
--job-id <id> Job id.
|
|
92335
|
-
--group-id <id> XMTP group id.
|
|
92336
92391
|
--my-agent-id <id> Local agent id.
|
|
92337
92392
|
--to-agent-id <id> Peer agent id.
|
|
92338
92393
|
--my-xmtp-address <addr> Local XMTP address.
|
|
@@ -92602,22 +92657,7 @@ async function maybePrewarmHermesSession(store, session) {
|
|
|
92602
92657
|
return { prewarmed: false, sessionId: null };
|
|
92603
92658
|
}
|
|
92604
92659
|
}
|
|
92605
|
-
|
|
92606
|
-
await runner.dispatchSessionMessage({
|
|
92607
|
-
sessionKey: session.sessionKey,
|
|
92608
|
-
content: [
|
|
92609
|
-
"Pre-create this okx-a2a job session for future inbound task messages.",
|
|
92610
|
-
"Load the okx-agent-task routing context if available, but do not call tools, send messages, notify the user, or take on-chain actions.",
|
|
92611
|
-
"Reply with one short readiness sentence only, then wait for the next inbound envelope."
|
|
92612
|
-
].join(" "),
|
|
92613
|
-
messageId: `session-create-${Date.now()}`,
|
|
92614
|
-
jobId: session.jobId ?? null,
|
|
92615
|
-
agentId: session.myAgentId ?? null
|
|
92616
|
-
});
|
|
92617
|
-
return {
|
|
92618
|
-
prewarmed: true,
|
|
92619
|
-
sessionId: store.getAiSession(session.sessionKey, "hermes")?.sessionId ?? null
|
|
92620
|
-
};
|
|
92660
|
+
return { prewarmed: false, sessionId: null };
|
|
92621
92661
|
}
|
|
92622
92662
|
function bindHermesSessionRouteIfAvailable(session) {
|
|
92623
92663
|
const jobId = normalizeOptionalText3(session.jobId);
|
|
@@ -92709,6 +92749,23 @@ function parseHermesGatewaySessionKey(sessionKey) {
|
|
|
92709
92749
|
}
|
|
92710
92750
|
return null;
|
|
92711
92751
|
}
|
|
92752
|
+
function resolveSessionDeleteProvider(store, jobId) {
|
|
92753
|
+
const normalizedJobId = jobId?.trim() || null;
|
|
92754
|
+
if (normalizedJobId) {
|
|
92755
|
+
const binding = store.getJobProviderBinding(normalizedJobId);
|
|
92756
|
+
if (binding) {
|
|
92757
|
+
return binding.provider === "openclaw" ? "openclaw" : null;
|
|
92758
|
+
}
|
|
92759
|
+
}
|
|
92760
|
+
const configured = resolveConfiguredAiProvider({ store });
|
|
92761
|
+
if (configured === "openclaw") {
|
|
92762
|
+
return "openclaw";
|
|
92763
|
+
}
|
|
92764
|
+
if (!configured && readSyncedOpenClawGatewayConfig()) {
|
|
92765
|
+
return "openclaw";
|
|
92766
|
+
}
|
|
92767
|
+
return null;
|
|
92768
|
+
}
|
|
92712
92769
|
function persistHermesRouteBinding2(input) {
|
|
92713
92770
|
const routeStorePath = (0, import_node_path20.join)(resolveTaskHome(), "hermes", "routes.json");
|
|
92714
92771
|
const store = readHermesRouteStore2(routeStorePath);
|
|
@@ -92834,7 +92891,6 @@ function resolveSendSessionTargets(parsed, store) {
|
|
|
92834
92891
|
}
|
|
92835
92892
|
function generateSessionKey(parsed) {
|
|
92836
92893
|
const jobId = readRequiredOption3(parsed, "job-id");
|
|
92837
|
-
const groupId = readRequiredOption3(parsed, "group-id");
|
|
92838
92894
|
const myAgentId = parsed.options.get("my-agent-id");
|
|
92839
92895
|
const toAgentId = parsed.options.get("to-agent-id");
|
|
92840
92896
|
if (myAgentId || toAgentId) {
|
|
@@ -92851,8 +92907,7 @@ function generateSessionKey(parsed) {
|
|
|
92851
92907
|
const qs = new URLSearchParams({
|
|
92852
92908
|
my: myXmtpAddress,
|
|
92853
92909
|
to: toXmtpAddress,
|
|
92854
|
-
job: jobId
|
|
92855
|
-
gid: groupId
|
|
92910
|
+
job: jobId
|
|
92856
92911
|
});
|
|
92857
92912
|
return `okx-xmtp:${qs.toString()}`;
|
|
92858
92913
|
}
|
|
@@ -92869,6 +92924,12 @@ function output2(json, payload, human) {
|
|
|
92869
92924
|
}
|
|
92870
92925
|
console.log(human);
|
|
92871
92926
|
}
|
|
92927
|
+
function formatDeleteSummary(localDeleted, gatewayDeleted) {
|
|
92928
|
+
if (gatewayDeleted > 0) {
|
|
92929
|
+
return `deleted ${localDeleted} local session(s), ${gatewayDeleted} openclaw session(s)`;
|
|
92930
|
+
}
|
|
92931
|
+
return `deleted ${localDeleted} session(s)`;
|
|
92932
|
+
}
|
|
92872
92933
|
function outputHistory(_json, rows) {
|
|
92873
92934
|
console.log(JSON.stringify(rows, null, 2));
|
|
92874
92935
|
}
|
|
@@ -92979,7 +93040,6 @@ var init_session_cli = __esm({
|
|
|
92979
93040
|
init_outbound_behavior();
|
|
92980
93041
|
init_openclaw_gateway();
|
|
92981
93042
|
init_sentry_logger();
|
|
92982
|
-
init_ai_runner();
|
|
92983
93043
|
init_paths();
|
|
92984
93044
|
}
|
|
92985
93045
|
});
|
|
@@ -93488,7 +93548,7 @@ function isPrereleaseVersion(version2) {
|
|
|
93488
93548
|
}
|
|
93489
93549
|
function getCurrentNodeCliVersion() {
|
|
93490
93550
|
try {
|
|
93491
|
-
return "0.0.11
|
|
93551
|
+
return "0.0.11";
|
|
93492
93552
|
} catch {
|
|
93493
93553
|
return null;
|
|
93494
93554
|
}
|
|
@@ -93951,7 +94011,7 @@ init_task_config();
|
|
|
93951
94011
|
init_sentry_logger();
|
|
93952
94012
|
init_sentry_config();
|
|
93953
94013
|
function printUsage2() {
|
|
93954
|
-
console.log(`okx-a2a ${"0.0.11
|
|
94014
|
+
console.log(`okx-a2a ${"0.0.11"}
|
|
93955
94015
|
|
|
93956
94016
|
Usage:
|
|
93957
94017
|
okx-a2a <command> [options]
|
|
@@ -93988,7 +94048,7 @@ Run \`okx-a2a <command> -h\` for command-specific help.
|
|
|
93988
94048
|
`);
|
|
93989
94049
|
}
|
|
93990
94050
|
function printVersion() {
|
|
93991
|
-
console.log("0.0.11
|
|
94051
|
+
console.log("0.0.11");
|
|
93992
94052
|
}
|
|
93993
94053
|
function printDaemonUsage() {
|
|
93994
94054
|
console.log(`Usage: okx-a2a daemon <start|restart|stop|status> [options]
|
|
@@ -94134,7 +94194,7 @@ Commands:
|
|
|
94134
94194
|
delete (--session-key <key> | --job-id <id> [--to-agent-id <id>]) [--json]
|
|
94135
94195
|
dispatch --job-id <id> [--session-agent-id <id>] [--message-id <id>] [--json]
|
|
94136
94196
|
send (--session-key <key> | --job-id <id> [--to-agent-id <id>]) --content <text> [--agent-id <id>] [--message-id <id>] [--retry] [--json]
|
|
94137
|
-
gen-key --job-id <id>
|
|
94197
|
+
gen-key --job-id <id> (--my-agent-id <id> --to-agent-id <id> | --my-xmtp-address <address> --to-xmtp-address <address>) [--json]
|
|
94138
94198
|
`);
|
|
94139
94199
|
}
|
|
94140
94200
|
function printFileUsageProxy() {
|
package/dist/index.js
CHANGED
|
@@ -67955,6 +67955,7 @@ __export(index_exports, {
|
|
|
67955
67955
|
buildSystemMessageNotice: () => buildSystemMessageNotice,
|
|
67956
67956
|
buildSystemStoredMessage: () => buildSystemStoredMessage,
|
|
67957
67957
|
callChatInject: () => callChatInject,
|
|
67958
|
+
callDeleteSessions: () => callDeleteSessions,
|
|
67958
67959
|
callOpenClawGateway: () => callOpenClawGateway,
|
|
67959
67960
|
callSessionsCreate: () => callSessionsCreate,
|
|
67960
67961
|
callSessionsDelete: () => callSessionsDelete,
|
|
@@ -85605,6 +85606,9 @@ async function callSessionsCreate(params) {
|
|
|
85605
85606
|
async function callSessionsDelete(params) {
|
|
85606
85607
|
return callOpenClawGateway({ method: "sessions.delete", params });
|
|
85607
85608
|
}
|
|
85609
|
+
async function callDeleteSessions(params) {
|
|
85610
|
+
return await callOpenClawGateway({ method: "okx-a2a.delete_sessions", params });
|
|
85611
|
+
}
|
|
85608
85612
|
async function callSessionsSend(params) {
|
|
85609
85613
|
const idempotencyKey = params.idempotencyKey ?? (0, import_node_crypto6.randomUUID)();
|
|
85610
85614
|
const sendParams = { key: params.key, message: params.message, idempotencyKey };
|
|
@@ -85861,7 +85865,7 @@ function buildConnectParams(config, instanceId) {
|
|
|
85861
85865
|
client: {
|
|
85862
85866
|
id: "gateway-client",
|
|
85863
85867
|
displayName: "okx-a2a-node",
|
|
85864
|
-
version: "0.0.11
|
|
85868
|
+
version: "0.0.11",
|
|
85865
85869
|
platform: "node",
|
|
85866
85870
|
mode: "backend",
|
|
85867
85871
|
instanceId
|
|
@@ -85872,7 +85876,7 @@ function buildConnectParams(config, instanceId) {
|
|
|
85872
85876
|
commands: [],
|
|
85873
85877
|
permissions: {},
|
|
85874
85878
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
85875
|
-
userAgent: `okx-a2a-node/${"0.0.11
|
|
85879
|
+
userAgent: `okx-a2a-node/${"0.0.11"}`,
|
|
85876
85880
|
auth: {
|
|
85877
85881
|
...config.token ? { token: config.token } : {},
|
|
85878
85882
|
...config.password ? { password: config.password } : {}
|
|
@@ -85919,8 +85923,7 @@ function toOpenClawGatewaySessionKey(input) {
|
|
|
85919
85923
|
return buildOpenClawGroupSessionKey(buildXmtpScopeKey({
|
|
85920
85924
|
jobId: input.jobId || peer.jobId,
|
|
85921
85925
|
myAgentId: input.myAgentId || peer.myAgentId,
|
|
85922
|
-
toAgentId: input.toAgentId || peer.toAgentId
|
|
85923
|
-
groupId: input.groupId || "_"
|
|
85926
|
+
toAgentId: input.toAgentId || peer.toAgentId
|
|
85924
85927
|
}));
|
|
85925
85928
|
}
|
|
85926
85929
|
return buildOpenClawGroupSessionKey(input.sessionKey);
|
|
@@ -85946,8 +85949,7 @@ function buildXmtpScopeKey(input) {
|
|
|
85946
85949
|
const qs = new URLSearchParams({
|
|
85947
85950
|
my: input.myAgentId,
|
|
85948
85951
|
to: input.toAgentId,
|
|
85949
|
-
job: input.jobId
|
|
85950
|
-
gid: input.groupId
|
|
85952
|
+
job: input.jobId
|
|
85951
85953
|
});
|
|
85952
85954
|
return `${XMTP_SCOPE_PREFIX}:${qs.toString()}`;
|
|
85953
85955
|
}
|
|
@@ -86027,7 +86029,7 @@ var SqliteOutboundBehavior = class {
|
|
|
86027
86029
|
};
|
|
86028
86030
|
var DEFAULT_GATEWAY_PORT2 = {
|
|
86029
86031
|
callSessionsCreate,
|
|
86030
|
-
|
|
86032
|
+
callDeleteSessions,
|
|
86031
86033
|
callSessionsSend,
|
|
86032
86034
|
callChatInject,
|
|
86033
86035
|
callDispatchUserToLatestSessions,
|
|
@@ -86089,17 +86091,24 @@ var GatewayOutboundBehavior = class {
|
|
|
86089
86091
|
}
|
|
86090
86092
|
}
|
|
86091
86093
|
async deleteSession(input) {
|
|
86094
|
+
const stored = this.sessionMetaStore?.getSession(input.sessionKey);
|
|
86092
86095
|
const gatewaySessionKey = this.resolveGatewaySessionKey(input);
|
|
86093
86096
|
console.error(`${GATEWAY_OUTBOUND_LOG_PREFIX} deleteSession sessionKey=${input.sessionKey} gatewaySessionKey=${gatewaySessionKey}`);
|
|
86094
86097
|
try {
|
|
86095
|
-
await this.gateway.
|
|
86096
|
-
console.error(`${GATEWAY_OUTBOUND_LOG_PREFIX} deleteSession ok sessionKey=${input.sessionKey} gatewaySessionKey=${gatewaySessionKey}`);
|
|
86097
|
-
logger.info(LogEvent.SESSION_DELETED, gatewayOutboundExtra("sessions.delete", {
|
|
86098
|
+
const result = await this.gateway.callDeleteSessions({
|
|
86098
86099
|
sessionKey: input.sessionKey,
|
|
86099
|
-
|
|
86100
|
+
...stored?.jobId ? { jobId: stored.jobId } : {},
|
|
86101
|
+
...stored?.myAgentId ? { myAgentId: stored.myAgentId } : {},
|
|
86102
|
+
...stored?.toAgentId ? { toAgentId: stored.toAgentId } : {}
|
|
86103
|
+
});
|
|
86104
|
+
console.error(`${GATEWAY_OUTBOUND_LOG_PREFIX} deleteSession ok sessionKey=${input.sessionKey} gatewaySessionKey=${gatewaySessionKey} deleted=${result.deleted ?? "(unknown)"}`);
|
|
86105
|
+
logger.info(LogEvent.SESSION_DELETED, gatewayOutboundExtra("okx-a2a.delete_sessions", {
|
|
86106
|
+
sessionKey: input.sessionKey,
|
|
86107
|
+
gatewaySessionKey,
|
|
86108
|
+
deleted: result.deleted ?? ""
|
|
86100
86109
|
}));
|
|
86101
86110
|
} catch (err2) {
|
|
86102
|
-
logger.error(LogEvent.GATEWAY_REQUEST_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), gatewayOutboundExtra("
|
|
86111
|
+
logger.error(LogEvent.GATEWAY_REQUEST_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), gatewayOutboundExtra("okx-a2a.delete_sessions", {
|
|
86103
86112
|
sessionKey: input.sessionKey,
|
|
86104
86113
|
gatewaySessionKey
|
|
86105
86114
|
}));
|
|
@@ -89245,7 +89254,7 @@ function userWatchEventDeliveredSentryExtra(event) {
|
|
|
89245
89254
|
var environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
89246
89255
|
var SENTRY_CONFIG = {
|
|
89247
89256
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
89248
|
-
release: "0.0.11
|
|
89257
|
+
release: "0.0.11",
|
|
89249
89258
|
environment
|
|
89250
89259
|
};
|
|
89251
89260
|
|
|
@@ -89364,12 +89373,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
89364
89373
|
}));
|
|
89365
89374
|
}
|
|
89366
89375
|
});
|
|
89367
|
-
service.setPluginVersion("0.0.11
|
|
89376
|
+
service.setPluginVersion("0.0.11");
|
|
89368
89377
|
await service.init();
|
|
89369
89378
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
89370
89379
|
if (pluginVersionStatus.unavailable) {
|
|
89371
89380
|
throw new Error(
|
|
89372
|
-
`@okxweb3/a2a-node v${"0.0.11
|
|
89381
|
+
`@okxweb3/a2a-node v${"0.0.11"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
89373
89382
|
);
|
|
89374
89383
|
}
|
|
89375
89384
|
const systemConfig = service.getSystemConfig();
|
|
@@ -89387,7 +89396,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
89387
89396
|
onchainosAgentId: "*",
|
|
89388
89397
|
reason: "system-config missing sentryDsn",
|
|
89389
89398
|
pluginId: "@okxweb3/a2a-node",
|
|
89390
|
-
pluginVersion: "0.0.11
|
|
89399
|
+
pluginVersion: "0.0.11"
|
|
89391
89400
|
});
|
|
89392
89401
|
}
|
|
89393
89402
|
console.log(
|
|
@@ -89698,6 +89707,7 @@ function parsePluginYamlVersion(content3) {
|
|
|
89698
89707
|
buildSystemMessageNotice,
|
|
89699
89708
|
buildSystemStoredMessage,
|
|
89700
89709
|
callChatInject,
|
|
89710
|
+
callDeleteSessions,
|
|
89701
89711
|
callOpenClawGateway,
|
|
89702
89712
|
callSessionsCreate,
|
|
89703
89713
|
callSessionsDelete,
|
package/package.json
CHANGED