@okxweb3/a2a-node 0.2.11-beta-8fef2ef558-260901172338 → 0.2.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.
Files changed (3) hide show
  1. package/dist/cli.js +222 -1298
  2. package/dist/index.js +17 -18
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -108,7 +108,6 @@ function resolveTaskPaths(homeDir = resolveTaskHome()) {
108
108
  workspaceDir: (0, import_node_path2.join)(homeDir, "workspace"),
109
109
  xmtpDir: (0, import_node_path2.join)(homeDir, "xmtp"),
110
110
  sqliteDir: (0, import_node_path2.join)(homeDir, "sqlite"),
111
- bzRecordsDir: (0, import_node_path2.join)(homeDir, "bz-records"),
112
111
  pendingCommandsDir: (0, import_node_path2.join)(homeDir, "commands", "pending"),
113
112
  processingCommandsDir: (0, import_node_path2.join)(homeDir, "commands", "processing"),
114
113
  completedCommandsDir: (0, import_node_path2.join)(homeDir, "commands", "completed"),
@@ -6525,7 +6524,7 @@ var require_path = __commonJS({
6525
6524
  function isAbsolute4(path2) {
6526
6525
  return path2.charAt(0) === "/";
6527
6526
  }
6528
- function join34(...args) {
6527
+ function join33(...args) {
6529
6528
  return normalizePath(args.join("/"));
6530
6529
  }
6531
6530
  function dirname11(path2) {
@@ -6550,7 +6549,7 @@ var require_path = __commonJS({
6550
6549
  exports2.basename = basename11;
6551
6550
  exports2.dirname = dirname11;
6552
6551
  exports2.isAbsolute = isAbsolute4;
6553
- exports2.join = join34;
6552
+ exports2.join = join33;
6554
6553
  exports2.normalizePath = normalizePath;
6555
6554
  exports2.relative = relative;
6556
6555
  exports2.resolve = resolve14;
@@ -26935,7 +26934,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
26935
26934
  client: {
26936
26935
  id: "gateway-client",
26937
26936
  displayName: "okx-a2a-node",
26938
- version: "0.2.11-beta-8fef2ef558-260901172338",
26937
+ version: "0.2.11",
26939
26938
  platform: "node",
26940
26939
  mode: "backend",
26941
26940
  instanceId
@@ -26946,7 +26945,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
26946
26945
  commands: [],
26947
26946
  permissions: {},
26948
26947
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
26949
- userAgent: `okx-a2a-node/${"0.2.11-beta-8fef2ef558-260901172338"}`,
26948
+ userAgent: `okx-a2a-node/${"0.2.11"}`,
26950
26949
  auth: {
26951
26950
  ...config.token ? { token: config.token } : {},
26952
26951
  ...config.password ? { password: config.password } : {}
@@ -29005,7 +29004,7 @@ var init_sentry_config = __esm({
29005
29004
  environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
29006
29005
  SENTRY_CONFIG = {
29007
29006
  projectName: "okx/openclaw-okx-a2a-extension",
29008
- release: "0.2.11-beta-8fef2ef558-260901172338",
29007
+ release: "0.2.11",
29009
29008
  environment,
29010
29009
  runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
29011
29010
  };
@@ -29294,7 +29293,7 @@ var require_BufferList = __commonJS({
29294
29293
  this.head = this.tail = null;
29295
29294
  this.length = 0;
29296
29295
  };
29297
- BufferList.prototype.join = function join34(s) {
29296
+ BufferList.prototype.join = function join33(s) {
29298
29297
  if (this.length === 0) return "";
29299
29298
  var p = this.head;
29300
29299
  var ret = "" + p.data;
@@ -39575,8 +39574,8 @@ function readSqliteRows(dbPath, sql, params = []) {
39575
39574
  if (!(0, import_node_fs17.existsSync)(dbPath)) {
39576
39575
  throw unavailable(`SQLite database not found: ${dbPath}`);
39577
39576
  }
39578
- const { DatabaseSync: DatabaseSync5 } = loadSqlite3();
39579
- const db = new DatabaseSync5(dbPath, { readOnly: true });
39577
+ const { DatabaseSync: DatabaseSync4 } = loadSqlite3();
39578
+ const db = new DatabaseSync4(dbPath, { readOnly: true });
39580
39579
  try {
39581
39580
  return db.prepare(sql).all(...params);
39582
39581
  } finally {
@@ -40175,7 +40174,7 @@ async function exportDiagnosticLogs(options) {
40175
40174
  node: process.version,
40176
40175
  platform: process.platform,
40177
40176
  arch: process.arch,
40178
- packageVersion: true ? "0.2.11-beta-8fef2ef558-260901172338" : "unknown",
40177
+ packageVersion: true ? "0.2.11" : "unknown",
40179
40178
  sensitiveContentIncluded: options.includeSensitiveContent,
40180
40179
  listenerAndLlmContentIncluded: true,
40181
40180
  credentialsAlwaysRedacted: true,
@@ -41069,11 +41068,6 @@ function getA2ACapabilities() {
41069
41068
  ok: true,
41070
41069
  fixCommands: [],
41071
41070
  message: ""
41072
- },
41073
- tradeRecordsV1: {
41074
- ok: true,
41075
- fixCommands: [],
41076
- message: ""
41077
41071
  }
41078
41072
  };
41079
41073
  }
@@ -41103,1057 +41097,6 @@ var init_capabilities_cli = __esm({
41103
41097
  }
41104
41098
  });
41105
41099
 
41106
- // src/trade-records-store.ts
41107
- function resolveTradeRecordsDbPath(homeDir) {
41108
- return (0, import_node_path24.join)(resolveTaskPaths(homeDir).bzRecordsDir, TRADE_RECORDS_DB_NAME);
41109
- }
41110
- function tradeRecordsDbExists(homeDir) {
41111
- return (0, import_node_fs20.existsSync)(resolveTradeRecordsDbPath(homeDir));
41112
- }
41113
- function encodeTradeRecordCursor(cursor) {
41114
- return Buffer.from(JSON.stringify(cursor), "utf8").toString("base64url");
41115
- }
41116
- function decodeTradeRecordCursor(value) {
41117
- try {
41118
- const parsed = JSON.parse(Buffer.from(value, "base64url").toString("utf8"));
41119
- if (parsed.version !== 1 || parsed.sortBy !== "createdAt" && parsed.sortBy !== "updatedAt" || parsed.order !== "asc" && parsed.order !== "desc" || typeof parsed.timestamp !== "number" || !Number.isSafeInteger(parsed.timestamp) || parsed.timestamp < 0 || typeof parsed.deliveryId !== "string" || parsed.deliveryId.length === 0) {
41120
- throw new Error("invalid cursor payload");
41121
- }
41122
- return parsed;
41123
- } catch {
41124
- throw new TradeRecordsStoreError("INVALID_ARGUMENT", "--cursor is invalid");
41125
- }
41126
- }
41127
- function applyMigrationV1(db) {
41128
- db.exec(`
41129
- CREATE TABLE ${TABLE_NAME} (
41130
- delivery_id TEXT PRIMARY KEY,
41131
- job_id TEXT NOT NULL,
41132
- status TEXT NOT NULL,
41133
- reason TEXT NOT NULL DEFAULT '',
41134
- extra TEXT NOT NULL DEFAULT '{}',
41135
- created_at INTEGER NOT NULL,
41136
- updated_at INTEGER NOT NULL,
41137
- deleted_at INTEGER,
41138
- CHECK (length(job_id) > 0),
41139
- CHECK (length(delivery_id) > 0),
41140
- CHECK (length(status) > 0),
41141
- CHECK (json_valid(extra)),
41142
- CHECK (json_type(extra) = 'object')
41143
- )
41144
- `);
41145
- db.exec(`CREATE INDEX idx_trade_records_job_updated ON ${TABLE_NAME}(job_id, updated_at DESC, delivery_id DESC)`);
41146
- db.exec(`CREATE INDEX idx_trade_records_status_updated ON ${TABLE_NAME}(status, updated_at DESC, delivery_id DESC)`);
41147
- db.exec(`CREATE INDEX idx_trade_records_created ON ${TABLE_NAME}(created_at DESC, delivery_id DESC)`);
41148
- db.exec(`CREATE INDEX idx_trade_records_deleted ON ${TABLE_NAME}(deleted_at, updated_at DESC)`);
41149
- }
41150
- function buildWhere(filter2, includeCursor) {
41151
- const clauses = [];
41152
- const params = [];
41153
- const add = (clause, ...values) => {
41154
- clauses.push(clause);
41155
- params.push(...values);
41156
- };
41157
- if (!filter2.includeDeleted) {
41158
- add(filter2.onlyDeleted ? "deleted_at IS NOT NULL" : "deleted_at IS NULL");
41159
- } else if (filter2.onlyDeleted) {
41160
- add("deleted_at IS NOT NULL");
41161
- }
41162
- if (filter2.jobId) add("job_id = ?", filter2.jobId);
41163
- if (filter2.deliveryId) add("delivery_id = ?", filter2.deliveryId);
41164
- if (filter2.statuses && filter2.statuses.length > 0) {
41165
- add(`status IN (${filter2.statuses.map(() => "?").join(", ")})`, ...filter2.statuses);
41166
- }
41167
- if (filter2.reason !== void 0) add("reason = ?", filter2.reason);
41168
- if (filter2.reasonContains !== void 0) {
41169
- add("reason LIKE ? ESCAPE '\\'", `%${escapeLike(filter2.reasonContains)}%`);
41170
- }
41171
- if (filter2.createdFrom !== void 0) add("created_at >= ?", filter2.createdFrom);
41172
- if (filter2.createdTo !== void 0) add("created_at <= ?", filter2.createdTo);
41173
- if (filter2.updatedFrom !== void 0) add("updated_at >= ?", filter2.updatedFrom);
41174
- if (filter2.updatedTo !== void 0) add("updated_at <= ?", filter2.updatedTo);
41175
- for (const extra of filter2.extraEquals ?? []) {
41176
- if (extra.value === null) {
41177
- add("json_type(extra, ?) = 'null'", extra.path);
41178
- } else {
41179
- add(
41180
- "json_extract(extra, ?) = ?",
41181
- extra.path,
41182
- typeof extra.value === "boolean" ? extra.value ? 1 : 0 : extra.value
41183
- );
41184
- }
41185
- }
41186
- if (includeCursor && filter2.cursor) {
41187
- const column = filter2.sortBy === "createdAt" ? "created_at" : "updated_at";
41188
- const operator = filter2.order === "asc" ? ">" : "<";
41189
- add(
41190
- `(${column} ${operator} ? OR (${column} = ? AND delivery_id ${operator} ?))`,
41191
- filter2.cursor.timestamp,
41192
- filter2.cursor.timestamp,
41193
- filter2.cursor.deliveryId
41194
- );
41195
- }
41196
- return { clauses, params };
41197
- }
41198
- function mapRow(row) {
41199
- const extra = JSON.parse(row.extra);
41200
- if (!isJsonObject(extra)) {
41201
- throw new TradeRecordsStoreError("DATABASE_READ_FAILED", "stored trade record extra is not a JSON object");
41202
- }
41203
- return {
41204
- jobId: row.job_id,
41205
- deliveryId: row.delivery_id,
41206
- status: row.status,
41207
- reason: row.reason,
41208
- extra,
41209
- createdAt: row.created_at,
41210
- updatedAt: row.updated_at,
41211
- deletedAt: row.deleted_at
41212
- };
41213
- }
41214
- function isJsonObject(value) {
41215
- return typeof value === "object" && value !== null && !Array.isArray(value);
41216
- }
41217
- function escapeLike(value) {
41218
- return value.replace(/[\\%_]/g, (character) => `\\${character}`);
41219
- }
41220
- function readPragmaNumber(db, name) {
41221
- const row = db.prepare(`PRAGMA ${name}`).get();
41222
- return Number(row[name] ?? 0);
41223
- }
41224
- function assertNotSymlink(path2, label) {
41225
- if (!(0, import_node_fs20.existsSync)(path2)) {
41226
- return;
41227
- }
41228
- if ((0, import_node_fs20.lstatSync)(path2).isSymbolicLink()) {
41229
- throw new TradeRecordsStoreError("DATABASE_PATH_UNSAFE", `${label} must not be a symbolic link`);
41230
- }
41231
- }
41232
- function assertSafeDatabasePath(dbPath) {
41233
- assertSafeDatabaseFile(dbPath);
41234
- for (const suffix of ["-journal", "-wal", "-shm"]) {
41235
- assertNotSymlink(`${dbPath}${suffix}`, `trade records database sidecar ${suffix}`);
41236
- }
41237
- }
41238
- function assertSafeDatabaseFile(dbPath) {
41239
- if (!(0, import_node_fs20.existsSync)(dbPath)) {
41240
- return;
41241
- }
41242
- const stat4 = (0, import_node_fs20.lstatSync)(dbPath);
41243
- if (stat4.isSymbolicLink()) {
41244
- throw new TradeRecordsStoreError(
41245
- "DATABASE_PATH_UNSAFE",
41246
- "trade records database must not be a symbolic link"
41247
- );
41248
- }
41249
- if (!stat4.isFile() || stat4.nlink !== 1) {
41250
- throw new TradeRecordsStoreError(
41251
- "DATABASE_PATH_UNSAFE",
41252
- "trade records database must be a regular file with one hard link"
41253
- );
41254
- }
41255
- }
41256
- function rollbackQuietly(db) {
41257
- try {
41258
- db.exec("ROLLBACK");
41259
- } catch {
41260
- }
41261
- }
41262
- function withBusyRetry(operation) {
41263
- for (let attempt = 1; ; attempt += 1) {
41264
- try {
41265
- return operation();
41266
- } catch (error) {
41267
- if (!isSqliteBusyError(error) || attempt >= WRITE_RETRY_ATTEMPTS) {
41268
- throw error;
41269
- }
41270
- sleepSyncMs2(Math.min(100 * 2 ** (attempt - 1), 1600));
41271
- }
41272
- }
41273
- }
41274
- function sleepSyncMs2(ms) {
41275
- const buffer2 = new Int32Array(new SharedArrayBuffer(4));
41276
- Atomics.wait(buffer2, 0, 0, ms);
41277
- }
41278
- function loadSqlite4() {
41279
- const originalEmitWarning = process.emitWarning;
41280
- process.emitWarning = ((warning, ...args) => {
41281
- const message = typeof warning === "string" ? warning : warning.message;
41282
- if (message.includes("SQLite is an experimental feature") && args.some((arg) => arg === "ExperimentalWarning")) {
41283
- return;
41284
- }
41285
- return originalEmitWarning.call(process, warning, ...args);
41286
- });
41287
- try {
41288
- return require("node:sqlite");
41289
- } finally {
41290
- process.emitWarning = originalEmitWarning;
41291
- }
41292
- }
41293
- var import_node_fs20, import_node_path24, DatabaseSync3, TRADE_RECORDS_APPLICATION_ID, TRADE_RECORDS_SCHEMA_VERSION, TRADE_RECORDS_DB_NAME, TABLE_NAME, WRITE_RETRY_ATTEMPTS, TradeRecordsStoreError, TradeRecordsStore;
41294
- var init_trade_records_store = __esm({
41295
- "src/trade-records-store.ts"() {
41296
- "use strict";
41297
- import_node_fs20 = require("node:fs");
41298
- import_node_path24 = require("node:path");
41299
- init_paths();
41300
- init_session_store();
41301
- ({ DatabaseSync: DatabaseSync3 } = loadSqlite4());
41302
- TRADE_RECORDS_APPLICATION_ID = 1329681490;
41303
- TRADE_RECORDS_SCHEMA_VERSION = 1;
41304
- TRADE_RECORDS_DB_NAME = "trade-records.sqlite";
41305
- TABLE_NAME = `"trade-records"`;
41306
- WRITE_RETRY_ATTEMPTS = 6;
41307
- TradeRecordsStoreError = class extends Error {
41308
- code;
41309
- constructor(code, message) {
41310
- super(message);
41311
- this.name = "TradeRecordsStoreError";
41312
- this.code = code;
41313
- }
41314
- };
41315
- TradeRecordsStore = class _TradeRecordsStore {
41316
- dbPath;
41317
- db;
41318
- constructor(dbPath, db) {
41319
- this.dbPath = dbPath;
41320
- this.db = db;
41321
- }
41322
- static openForWrite(homeDir) {
41323
- const paths = resolveTaskPaths(homeDir);
41324
- assertNotSymlink(paths.bzRecordsDir, "trade records directory");
41325
- ensureTaskDir(paths.bzRecordsDir);
41326
- assertNotSymlink(paths.bzRecordsDir, "trade records directory");
41327
- const dbPath = (0, import_node_path24.join)(paths.bzRecordsDir, TRADE_RECORDS_DB_NAME);
41328
- assertSafeDatabasePath(dbPath);
41329
- const db = new DatabaseSync3(dbPath);
41330
- const store = new _TradeRecordsStore(dbPath, db);
41331
- try {
41332
- store.configureConnectionForWrite();
41333
- store.ensureSchemaForWrite();
41334
- return store;
41335
- } catch (error) {
41336
- db.close();
41337
- throw error;
41338
- }
41339
- }
41340
- static openForRead(homeDir) {
41341
- const dbPath = resolveTradeRecordsDbPath(homeDir);
41342
- if (!(0, import_node_fs20.existsSync)(dbPath)) {
41343
- return null;
41344
- }
41345
- assertSafeDatabaseFile(dbPath);
41346
- const db = new DatabaseSync3(dbPath, { readOnly: true });
41347
- const store = new _TradeRecordsStore(dbPath, db);
41348
- try {
41349
- db.exec("PRAGMA query_only=ON");
41350
- store.assertReadableSchema();
41351
- return store;
41352
- } catch (error) {
41353
- db.close();
41354
- throw error;
41355
- }
41356
- }
41357
- close() {
41358
- this.db.close();
41359
- }
41360
- insert(records) {
41361
- return this.withWriteTransaction(() => {
41362
- const existingStatement = this.db.prepare(
41363
- `SELECT deleted_at FROM ${TABLE_NAME} WHERE delivery_id = ?`
41364
- );
41365
- const upsertStatement = this.db.prepare(`
41366
- INSERT INTO ${TABLE_NAME} (
41367
- delivery_id, job_id, status, reason, extra, created_at, updated_at, deleted_at
41368
- ) VALUES (?, ?, ?, ?, ?, ?, ?, NULL)
41369
- ON CONFLICT(delivery_id) DO UPDATE SET
41370
- job_id = excluded.job_id,
41371
- status = excluded.status,
41372
- reason = excluded.reason,
41373
- extra = excluded.extra,
41374
- updated_at = excluded.updated_at,
41375
- deleted_at = NULL
41376
- `);
41377
- const now = Date.now();
41378
- let insertedCount = 0;
41379
- let updatedCount = 0;
41380
- let restoredCount = 0;
41381
- for (const record of records) {
41382
- const existing = existingStatement.get(record.deliveryId);
41383
- if (!existing) {
41384
- insertedCount += 1;
41385
- } else if (existing.deleted_at === null) {
41386
- updatedCount += 1;
41387
- } else {
41388
- restoredCount += 1;
41389
- }
41390
- upsertStatement.run(
41391
- record.deliveryId,
41392
- record.jobId,
41393
- record.status,
41394
- record.reason,
41395
- JSON.stringify(record.extra),
41396
- now,
41397
- now
41398
- );
41399
- }
41400
- return { insertedCount, updatedCount, restoredCount };
41401
- });
41402
- }
41403
- delete(deliveryId, jobId) {
41404
- return this.withWriteTransaction(() => {
41405
- const existing = this.db.prepare(`
41406
- SELECT deleted_at FROM ${TABLE_NAME}
41407
- WHERE delivery_id = ?${jobId ? " AND job_id = ?" : ""}
41408
- `).get(...jobId ? [deliveryId, jobId] : [deliveryId]);
41409
- if (!existing) {
41410
- return { deliveryId, deleted: false, alreadyDeleted: false, notFound: true };
41411
- }
41412
- if (existing.deleted_at !== null) {
41413
- return { deliveryId, deleted: false, alreadyDeleted: true, notFound: false };
41414
- }
41415
- const now = Date.now();
41416
- this.db.prepare(`
41417
- UPDATE ${TABLE_NAME}
41418
- SET deleted_at = ?, updated_at = ?
41419
- WHERE delivery_id = ?${jobId ? " AND job_id = ?" : ""} AND deleted_at IS NULL
41420
- `).run(...jobId ? [now, now, deliveryId, jobId] : [now, now, deliveryId]);
41421
- return { deliveryId, deleted: true, alreadyDeleted: false, notFound: false };
41422
- });
41423
- }
41424
- query(filter2) {
41425
- const base = buildWhere(filter2, false);
41426
- const page = buildWhere(filter2, true);
41427
- const sortColumn = filter2.sortBy === "createdAt" ? "created_at" : "updated_at";
41428
- const direction = filter2.order.toUpperCase();
41429
- const rows = this.db.prepare(`
41430
- SELECT delivery_id, job_id, status, reason, extra, created_at, updated_at, deleted_at
41431
- FROM ${TABLE_NAME}
41432
- ${page.clauses.length > 0 ? `WHERE ${page.clauses.join(" AND ")}` : ""}
41433
- ORDER BY ${sortColumn} ${direction}, delivery_id ${direction}
41434
- LIMIT ?
41435
- `).all(...page.params, filter2.limit + 1);
41436
- const hasMore = rows.length > filter2.limit;
41437
- const visibleRows = hasMore ? rows.slice(0, filter2.limit) : rows;
41438
- const records = visibleRows.map(mapRow);
41439
- const last = visibleRows.at(-1);
41440
- const nextCursor = hasMore && last ? encodeTradeRecordCursor({
41441
- version: 1,
41442
- sortBy: filter2.sortBy,
41443
- order: filter2.order,
41444
- timestamp: filter2.sortBy === "createdAt" ? last.created_at : last.updated_at,
41445
- deliveryId: last.delivery_id
41446
- }) : null;
41447
- let count;
41448
- if (filter2.includeCount) {
41449
- const row = this.db.prepare(`
41450
- SELECT COUNT(*) AS count
41451
- FROM ${TABLE_NAME}
41452
- ${base.clauses.length > 0 ? `WHERE ${base.clauses.join(" AND ")}` : ""}
41453
- `).get(...base.params);
41454
- count = Number(row.count);
41455
- }
41456
- return { records, nextCursor, ...count === void 0 ? {} : { count } };
41457
- }
41458
- configureConnectionForWrite() {
41459
- this.db.exec("PRAGMA busy_timeout=5000");
41460
- }
41461
- ensureSchemaForWrite() {
41462
- withBusyRetry(() => {
41463
- this.db.exec("BEGIN IMMEDIATE");
41464
- try {
41465
- const applicationId = readPragmaNumber(this.db, "application_id");
41466
- const userVersion = readPragmaNumber(this.db, "user_version");
41467
- const hasTables = Boolean(this.db.prepare(
41468
- "SELECT 1 AS present FROM sqlite_master WHERE type = 'table' LIMIT 1"
41469
- ).get());
41470
- if (applicationId === 0 && !hasTables && userVersion === 0) {
41471
- this.db.exec(`PRAGMA application_id=${TRADE_RECORDS_APPLICATION_ID}`);
41472
- } else if (applicationId !== TRADE_RECORDS_APPLICATION_ID) {
41473
- throw new TradeRecordsStoreError(
41474
- "DATABASE_IDENTITY_MISMATCH",
41475
- "trade records database identity does not match"
41476
- );
41477
- }
41478
- if (userVersion > TRADE_RECORDS_SCHEMA_VERSION) {
41479
- throw new TradeRecordsStoreError(
41480
- "DATABASE_SCHEMA_TOO_NEW",
41481
- `trade records schema version ${userVersion} is newer than supported ${TRADE_RECORDS_SCHEMA_VERSION}`
41482
- );
41483
- }
41484
- if (userVersion < 1) {
41485
- applyMigrationV1(this.db);
41486
- this.db.exec("PRAGMA user_version=1");
41487
- }
41488
- this.db.exec("COMMIT");
41489
- } catch (error) {
41490
- rollbackQuietly(this.db);
41491
- throw error;
41492
- }
41493
- });
41494
- withBusyRetry(() => {
41495
- this.db.exec("PRAGMA journal_mode=WAL");
41496
- this.db.exec("PRAGMA synchronous=FULL");
41497
- });
41498
- }
41499
- assertReadableSchema() {
41500
- const applicationId = readPragmaNumber(this.db, "application_id");
41501
- if (applicationId !== TRADE_RECORDS_APPLICATION_ID) {
41502
- throw new TradeRecordsStoreError(
41503
- "DATABASE_IDENTITY_MISMATCH",
41504
- "trade records database identity does not match"
41505
- );
41506
- }
41507
- const userVersion = readPragmaNumber(this.db, "user_version");
41508
- if (userVersion > TRADE_RECORDS_SCHEMA_VERSION) {
41509
- throw new TradeRecordsStoreError(
41510
- "DATABASE_SCHEMA_TOO_NEW",
41511
- `trade records schema version ${userVersion} is newer than supported ${TRADE_RECORDS_SCHEMA_VERSION}`
41512
- );
41513
- }
41514
- if (userVersion < TRADE_RECORDS_SCHEMA_VERSION) {
41515
- throw new TradeRecordsStoreError(
41516
- "DATABASE_MIGRATION_REQUIRED",
41517
- "trade records database requires a write command to finish migration"
41518
- );
41519
- }
41520
- }
41521
- withWriteTransaction(operation) {
41522
- return withBusyRetry(() => {
41523
- this.db.exec("BEGIN IMMEDIATE");
41524
- try {
41525
- const result = operation();
41526
- this.db.exec("COMMIT");
41527
- return result;
41528
- } catch (error) {
41529
- rollbackQuietly(this.db);
41530
- throw error;
41531
- }
41532
- });
41533
- }
41534
- };
41535
- }
41536
- });
41537
-
41538
- // src/trade-records-cli.ts
41539
- var trade_records_cli_exports = {};
41540
- __export(trade_records_cli_exports, {
41541
- handleTradeRecordsCommand: () => handleTradeRecordsCommand,
41542
- printTradeRecordsUsage: () => printTradeRecordsUsage
41543
- });
41544
- async function handleTradeRecordsCommand(args) {
41545
- const wantsJson = args.includes("--json");
41546
- try {
41547
- const subcommand = args[0];
41548
- if (!subcommand || isHelpArg(subcommand)) {
41549
- printTradeRecordsUsage();
41550
- return;
41551
- }
41552
- if (args.slice(1).some(isHelpArg)) {
41553
- printSubcommandUsage(subcommand);
41554
- return;
41555
- }
41556
- if (subcommand === "insert") {
41557
- handleInsert(args.slice(1));
41558
- return;
41559
- }
41560
- if (subcommand === "query") {
41561
- handleQuery(args.slice(1));
41562
- return;
41563
- }
41564
- if (subcommand === "delete") {
41565
- handleDelete(args.slice(1));
41566
- return;
41567
- }
41568
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `Unknown trade-records command: ${subcommand}`);
41569
- } catch (error) {
41570
- outputError(wantsJson, normalizeError(error));
41571
- process.exitCode = 1;
41572
- }
41573
- }
41574
- function printTradeRecordsUsage() {
41575
- console.log(`Usage: okx-a2a trade-records <insert|query|delete> [options]
41576
-
41577
- Commands:
41578
- insert Insert or replace trade records by deliveryId.
41579
- query Query active or soft-deleted trade records.
41580
- delete Soft-delete one trade record by deliveryId.
41581
-
41582
- Run \`okx-a2a trade-records <command> --help\` for command-specific help.`);
41583
- }
41584
- function printSubcommandUsage(subcommand) {
41585
- if (subcommand === "insert") {
41586
- console.log(`Usage: okx-a2a trade-records insert [options]
41587
-
41588
- Input modes (choose exactly one):
41589
- --job-id <id> --delivery-id <id> --status <status> [--reason <text>] [--extra <json-object>]
41590
- --input-json <json-array>
41591
- --input-file <path-to-json-array>
41592
-
41593
- Options:
41594
- --reason <text> Default: empty string.
41595
- --extra <json> Complete JSON object. Default: {}.
41596
- --json Print machine-readable summary.`);
41597
- return;
41598
- }
41599
- if (subcommand === "query") {
41600
- console.log(`Usage: okx-a2a trade-records query [options]
41601
-
41602
- Options:
41603
- --job-id <id> Filter by job id.
41604
- --delivery-id <id> Filter by delivery id.
41605
- --status <status> Filter by status; repeatable.
41606
- --reason <text> Exact reason match.
41607
- --reason-contains <text> Reason substring match.
41608
- --created-from <epoch-ms> Inclusive createdAt lower bound.
41609
- --created-to <epoch-ms> Inclusive createdAt upper bound.
41610
- --updated-from <epoch-ms> Inclusive updatedAt lower bound.
41611
- --updated-to <epoch-ms> Inclusive updatedAt upper bound.
41612
- --extra-eq <path=json> Exact extra field match; repeatable.
41613
- --include-deleted Include active and deleted records.
41614
- --only-deleted Return only deleted records.
41615
- --sort-by <createdAt|updatedAt> Default: updatedAt.
41616
- --order <asc|desc> Default: desc.
41617
- --limit <n> Default: 100; maximum: 1000.
41618
- --cursor <cursor> Continue keyset pagination.
41619
- --count Include total matching count.
41620
- --json Print machine-readable output.`);
41621
- return;
41622
- }
41623
- if (subcommand === "delete") {
41624
- console.log(`Usage: okx-a2a trade-records delete --delivery-id <id> [--job-id <id>] [--json]
41625
-
41626
- Soft-delete one trade record. Repeated deletes and missing records are idempotent.`);
41627
- return;
41628
- }
41629
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `Unknown trade-records command: ${subcommand}`);
41630
- }
41631
- function handleInsert(args) {
41632
- const parsed = parseArgs(args, {
41633
- command: "trade-records insert",
41634
- options: /* @__PURE__ */ new Set([...INPUT_FIELD_OPTIONS, "input-json", "input-file"]),
41635
- flags: /* @__PURE__ */ new Set(["json"])
41636
- });
41637
- const json = parsed.flags.has("json");
41638
- const loaded = loadInsertRecords(parsed);
41639
- const coalesced = coalesceByLastDeliveryId(loaded.records);
41640
- const store = TradeRecordsStore.openForWrite();
41641
- try {
41642
- const result = store.insert(coalesced.records);
41643
- const payload = {
41644
- ok: true,
41645
- operation: "insert",
41646
- inputCount: loaded.records.length,
41647
- finalRecordCount: coalesced.records.length,
41648
- insertedCount: result.insertedCount,
41649
- updatedCount: result.updatedCount,
41650
- restoredCount: result.restoredCount,
41651
- duplicateInputCount: coalesced.duplicateInputCount
41652
- };
41653
- if (json) {
41654
- console.log(JSON.stringify(payload));
41655
- return;
41656
- }
41657
- if (loaded.records.length === 1) {
41658
- const operation = result.insertedCount === 1 ? "inserted" : result.restoredCount === 1 ? "restored" : "updated";
41659
- console.log(`Trade record saved: deliveryId=${coalesced.records[0].deliveryId}, result=${operation}`);
41660
- return;
41661
- }
41662
- console.log(`Trade records saved: ${loaded.records.length} inputs, ${coalesced.records.length} final records`);
41663
- console.log(
41664
- `Inserted: ${result.insertedCount}, updated: ${result.updatedCount}, restored: ${result.restoredCount}, duplicate inputs overwritten: ${coalesced.duplicateInputCount}`
41665
- );
41666
- } finally {
41667
- store.close();
41668
- }
41669
- }
41670
- function handleQuery(args) {
41671
- const parsed = parseArgs(args, {
41672
- command: "trade-records query",
41673
- options: /* @__PURE__ */ new Set([
41674
- "job-id",
41675
- "delivery-id",
41676
- "status",
41677
- "reason",
41678
- "reason-contains",
41679
- "created-from",
41680
- "created-to",
41681
- "updated-from",
41682
- "updated-to",
41683
- "extra-eq",
41684
- "sort-by",
41685
- "order",
41686
- "limit",
41687
- "cursor"
41688
- ]),
41689
- flags: /* @__PURE__ */ new Set(["include-deleted", "only-deleted", "count", "json"]),
41690
- repeatable: /* @__PURE__ */ new Set(["status", "extra-eq"])
41691
- });
41692
- const json = parsed.flags.has("json");
41693
- if (parsed.flags.has("include-deleted") && parsed.flags.has("only-deleted")) {
41694
- throw new TradeRecordsCliError(
41695
- "INVALID_ARGUMENT",
41696
- "--include-deleted and --only-deleted cannot be used together"
41697
- );
41698
- }
41699
- const sortBy = readChoice(parsed, "sort-by", ["createdAt", "updatedAt"]) ?? "updatedAt";
41700
- const order = readChoice(parsed, "order", ["asc", "desc"]) ?? "desc";
41701
- const cursorRaw = readSingle(parsed, "cursor");
41702
- const cursor = cursorRaw ? decodeTradeRecordCursor(cursorRaw) : void 0;
41703
- if (cursor && (cursor.sortBy !== sortBy || cursor.order !== order)) {
41704
- throw new TradeRecordsCliError(
41705
- "INVALID_ARGUMENT",
41706
- "--cursor does not match the requested --sort-by and --order"
41707
- );
41708
- }
41709
- const createdFrom = readTimestamp(parsed, "created-from");
41710
- const createdTo = readTimestamp(parsed, "created-to");
41711
- const updatedFrom = readTimestamp(parsed, "updated-from");
41712
- const updatedTo = readTimestamp(parsed, "updated-to");
41713
- assertRange("created", createdFrom, createdTo);
41714
- assertRange("updated", updatedFrom, updatedTo);
41715
- const filter2 = {
41716
- sortBy,
41717
- order,
41718
- limit: readLimit(parsed),
41719
- statuses: parsed.options.get("status")?.map((value) => requireText(value, "--status", MAX_STATUS_LENGTH)),
41720
- extraEquals: (parsed.options.get("extra-eq") ?? []).map(parseExtraFilter),
41721
- includeDeleted: parsed.flags.has("include-deleted"),
41722
- onlyDeleted: parsed.flags.has("only-deleted"),
41723
- includeCount: parsed.flags.has("count"),
41724
- ...readOptionalText(parsed, "job-id", MAX_ID_LENGTH) ? { jobId: readOptionalText(parsed, "job-id", MAX_ID_LENGTH) } : {},
41725
- ...readOptionalText(parsed, "delivery-id", MAX_ID_LENGTH) ? { deliveryId: readOptionalText(parsed, "delivery-id", MAX_ID_LENGTH) } : {},
41726
- ...readSingle(parsed, "reason") !== void 0 ? { reason: readSingle(parsed, "reason") } : {},
41727
- ...readSingle(parsed, "reason-contains") !== void 0 ? { reasonContains: readSingle(parsed, "reason-contains") } : {},
41728
- ...createdFrom === void 0 ? {} : { createdFrom },
41729
- ...createdTo === void 0 ? {} : { createdTo },
41730
- ...updatedFrom === void 0 ? {} : { updatedFrom },
41731
- ...updatedTo === void 0 ? {} : { updatedTo },
41732
- ...cursor ? { cursor } : {}
41733
- };
41734
- const store = TradeRecordsStore.openForRead();
41735
- if (!store) {
41736
- outputQuery(json, [], filter2.limit, null, filter2.includeCount ? 0 : void 0);
41737
- return;
41738
- }
41739
- try {
41740
- const result = store.query(filter2);
41741
- outputQuery(json, result.records, filter2.limit, result.nextCursor, result.count);
41742
- } finally {
41743
- store.close();
41744
- }
41745
- }
41746
- function handleDelete(args) {
41747
- const parsed = parseArgs(args, {
41748
- command: "trade-records delete",
41749
- options: /* @__PURE__ */ new Set(["delivery-id", "job-id"]),
41750
- flags: /* @__PURE__ */ new Set(["json"])
41751
- });
41752
- const json = parsed.flags.has("json");
41753
- const deliveryId = requireText(readSingle(parsed, "delivery-id"), "--delivery-id", MAX_ID_LENGTH);
41754
- const jobId = readOptionalText(parsed, "job-id", MAX_ID_LENGTH);
41755
- if (!tradeRecordsDbExists()) {
41756
- outputDelete(json, {
41757
- deliveryId,
41758
- deleted: false,
41759
- alreadyDeleted: false,
41760
- notFound: true
41761
- });
41762
- return;
41763
- }
41764
- const store = TradeRecordsStore.openForWrite();
41765
- try {
41766
- outputDelete(json, store.delete(deliveryId, jobId));
41767
- } finally {
41768
- store.close();
41769
- }
41770
- }
41771
- function loadInsertRecords(parsed) {
41772
- const inputJson = readSingle(parsed, "input-json");
41773
- const inputFile = readSingle(parsed, "input-file");
41774
- const providedFieldOptions = [...INPUT_FIELD_OPTIONS].filter((name) => parsed.options.has(name));
41775
- const modeCount = Number(inputJson !== void 0) + Number(inputFile !== void 0) + Number(providedFieldOptions.length > 0);
41776
- if (modeCount !== 1) {
41777
- throw new TradeRecordsCliError(
41778
- "INVALID_ARGUMENT",
41779
- "trade-records insert requires exactly one input mode: field options, --input-json, or --input-file"
41780
- );
41781
- }
41782
- if (inputJson !== void 0) {
41783
- assertInputSize(inputJson, "--input-json");
41784
- return { records: parseRecordArray(inputJson, "--input-json") };
41785
- }
41786
- if (inputFile !== void 0) {
41787
- let content2;
41788
- try {
41789
- const stat4 = (0, import_node_fs21.statSync)(inputFile);
41790
- if (!stat4.isFile()) {
41791
- throw new Error("not a regular file");
41792
- }
41793
- if (stat4.size > MAX_INPUT_BYTES) {
41794
- throw new TradeRecordsCliError("INPUT_TOO_LARGE", `--input-file exceeds ${MAX_INPUT_BYTES} bytes`);
41795
- }
41796
- content2 = (0, import_node_fs21.readFileSync)(inputFile, "utf8");
41797
- } catch (error) {
41798
- if (error instanceof TradeRecordsCliError) throw error;
41799
- throw new TradeRecordsCliError("INVALID_INPUT_FILE", `could not read --input-file: ${String(error)}`);
41800
- }
41801
- return { records: parseRecordArray(content2, "--input-file") };
41802
- }
41803
- const extraRaw = readSingle(parsed, "extra");
41804
- let extra = {};
41805
- if (extraRaw !== void 0) {
41806
- extra = parseJsonObject(extraRaw, "--extra");
41807
- }
41808
- return {
41809
- records: [normalizeRecord({
41810
- jobId: readSingle(parsed, "job-id"),
41811
- deliveryId: readSingle(parsed, "delivery-id"),
41812
- status: readSingle(parsed, "status"),
41813
- reason: readSingle(parsed, "reason") ?? "",
41814
- extra
41815
- }, 0)]
41816
- };
41817
- }
41818
- function parseRecordArray(raw, label) {
41819
- let parsed;
41820
- try {
41821
- parsed = JSON.parse(raw);
41822
- } catch {
41823
- throw new TradeRecordsCliError("INVALID_INPUT_JSON", `${label} must contain valid JSON`);
41824
- }
41825
- if (!Array.isArray(parsed) || parsed.length === 0) {
41826
- throw new TradeRecordsCliError("INVALID_INPUT_JSON", `${label} must contain a non-empty JSON array`);
41827
- }
41828
- if (parsed.length > MAX_BATCH_RECORDS) {
41829
- throw new TradeRecordsCliError(
41830
- "TOO_MANY_RECORDS",
41831
- `${label} contains ${parsed.length} records; maximum is ${MAX_BATCH_RECORDS}`
41832
- );
41833
- }
41834
- const records = [];
41835
- const details = [];
41836
- for (let index2 = 0; index2 < parsed.length; index2 += 1) {
41837
- try {
41838
- records.push(normalizeRecord(parsed[index2], index2));
41839
- } catch (error) {
41840
- const normalized = normalizeError(error);
41841
- details.push(...normalized.details ?? [{ index: index2, reason: normalized.message }]);
41842
- }
41843
- }
41844
- if (details.length > 0) {
41845
- throw new TradeRecordsCliError("INVALID_ARGUMENT", "one or more trade records are invalid", details);
41846
- }
41847
- return records;
41848
- }
41849
- function normalizeRecord(value, index2) {
41850
- if (!isJsonObject2(value)) {
41851
- throw invalidField(index2, void 0, "must be a JSON object");
41852
- }
41853
- for (const field of Object.keys(value)) {
41854
- if (FORBIDDEN_RECORD_FIELDS.has(field)) {
41855
- throw invalidField(index2, field, "business callers must not provide timestamp fields");
41856
- }
41857
- if (!ALLOWED_RECORD_FIELDS.has(field)) {
41858
- throw invalidField(index2, field, "unknown field; put extensible fields inside extra");
41859
- }
41860
- }
41861
- const jobId = requireRecordText(value.jobId, index2, "jobId", MAX_ID_LENGTH);
41862
- const deliveryId = requireRecordText(value.deliveryId, index2, "deliveryId", MAX_ID_LENGTH);
41863
- const status = requireRecordText(value.status, index2, "status", MAX_STATUS_LENGTH);
41864
- const reason = value.reason === void 0 ? "" : requireRecordString(value.reason, index2, "reason", MAX_REASON_LENGTH, true);
41865
- const extra = value.extra === void 0 ? {} : value.extra;
41866
- if (!isJsonObject2(extra)) {
41867
- throw invalidField(index2, "extra", "must be a JSON object");
41868
- }
41869
- const serializedExtra = JSON.stringify(extra);
41870
- if (Buffer.byteLength(serializedExtra, "utf8") > MAX_EXTRA_BYTES) {
41871
- throw invalidField(index2, "extra", `serialized JSON exceeds ${MAX_EXTRA_BYTES} bytes`);
41872
- }
41873
- return { jobId, deliveryId, status, reason, extra };
41874
- }
41875
- function coalesceByLastDeliveryId(records) {
41876
- const lastIndexes = /* @__PURE__ */ new Map();
41877
- records.forEach((record, index2) => lastIndexes.set(record.deliveryId, index2));
41878
- const coalesced = records.filter((record, index2) => lastIndexes.get(record.deliveryId) === index2);
41879
- return { records: coalesced, duplicateInputCount: records.length - coalesced.length };
41880
- }
41881
- function parseArgs(args, spec) {
41882
- const options = /* @__PURE__ */ new Map();
41883
- const flags = /* @__PURE__ */ new Set();
41884
- for (let index2 = 0; index2 < args.length; index2 += 1) {
41885
- const token = args[index2];
41886
- if (!token.startsWith("--")) {
41887
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `${spec.command} unexpected positional argument: ${token}`);
41888
- }
41889
- const name = token.slice(2);
41890
- if (spec.flags.has(name)) {
41891
- if (flags.has(name)) {
41892
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `${token} must not be repeated`);
41893
- }
41894
- flags.add(name);
41895
- continue;
41896
- }
41897
- if (!spec.options.has(name)) {
41898
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `${spec.command} unknown option ${token}`);
41899
- }
41900
- if (index2 + 1 >= args.length) {
41901
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `${token} requires a value`);
41902
- }
41903
- const value = args[++index2];
41904
- if (value.startsWith("--")) {
41905
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `${token} requires a value`);
41906
- }
41907
- const values = options.get(name) ?? [];
41908
- if (values.length > 0 && !spec.repeatable?.has(name)) {
41909
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `${token} must not be repeated`);
41910
- }
41911
- values.push(value);
41912
- options.set(name, values);
41913
- }
41914
- return { options, flags };
41915
- }
41916
- function readSingle(parsed, name) {
41917
- return parsed.options.get(name)?.[0];
41918
- }
41919
- function readOptionalText(parsed, name, maxLength) {
41920
- const value = readSingle(parsed, name);
41921
- return value === void 0 ? void 0 : requireText(value, `--${name}`, maxLength);
41922
- }
41923
- function requireText(value, label, maxLength) {
41924
- if (typeof value !== "string" || value.trim().length === 0) {
41925
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `${label} is required and must be a non-empty string`);
41926
- }
41927
- const normalized = value.trim();
41928
- if (normalized.length > maxLength) {
41929
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `${label} exceeds ${maxLength} characters`);
41930
- }
41931
- return normalized;
41932
- }
41933
- function requireRecordText(value, index2, field, maxLength) {
41934
- if (typeof value !== "string" || value.trim().length === 0) {
41935
- throw invalidField(index2, field, "must be a non-empty string");
41936
- }
41937
- const normalized = value.trim();
41938
- if (normalized.length > maxLength) {
41939
- throw invalidField(index2, field, `exceeds ${maxLength} characters`);
41940
- }
41941
- return normalized;
41942
- }
41943
- function requireRecordString(value, index2, field, maxLength, allowEmpty) {
41944
- if (typeof value !== "string" || !allowEmpty && value.length === 0) {
41945
- throw invalidField(index2, field, allowEmpty ? "must be a string" : "must be a non-empty string");
41946
- }
41947
- if (value.length > maxLength) {
41948
- throw invalidField(index2, field, `exceeds ${maxLength} characters`);
41949
- }
41950
- return value;
41951
- }
41952
- function invalidField(index2, field, reason) {
41953
- return new TradeRecordsCliError("INVALID_ARGUMENT", `invalid trade record at index ${index2}`, [
41954
- { index: index2, ...field ? { field } : {}, reason }
41955
- ]);
41956
- }
41957
- function parseJsonObject(raw, label) {
41958
- let value;
41959
- try {
41960
- value = JSON.parse(raw);
41961
- } catch {
41962
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `${label} must be valid JSON`);
41963
- }
41964
- if (!isJsonObject2(value)) {
41965
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `${label} must be a JSON object`);
41966
- }
41967
- if (Buffer.byteLength(JSON.stringify(value), "utf8") > MAX_EXTRA_BYTES) {
41968
- throw new TradeRecordsCliError("INPUT_TOO_LARGE", `${label} exceeds ${MAX_EXTRA_BYTES} bytes`);
41969
- }
41970
- return value;
41971
- }
41972
- function parseExtraFilter(raw) {
41973
- const separator = raw.indexOf("=");
41974
- if (separator <= 0 || separator === raw.length - 1) {
41975
- throw new TradeRecordsCliError("INVALID_ARGUMENT", "--extra-eq must use path=jsonValue syntax");
41976
- }
41977
- const path2 = raw.slice(0, separator).trim();
41978
- const segments = path2.split(".");
41979
- if (segments.some((segment) => !/^[A-Za-z_][A-Za-z0-9_]*$/.test(segment))) {
41980
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `--extra-eq has invalid JSON path: ${path2}`);
41981
- }
41982
- let value;
41983
- try {
41984
- value = JSON.parse(raw.slice(separator + 1));
41985
- } catch {
41986
- throw new TradeRecordsCliError("INVALID_ARGUMENT", "--extra-eq value must be a JSON primitive");
41987
- }
41988
- if (typeof value === "object" && value !== null) {
41989
- throw new TradeRecordsCliError("INVALID_ARGUMENT", "--extra-eq value must be a JSON primitive");
41990
- }
41991
- if (!["string", "number", "boolean"].includes(typeof value) && value !== null) {
41992
- throw new TradeRecordsCliError("INVALID_ARGUMENT", "--extra-eq value must be a JSON primitive");
41993
- }
41994
- if (typeof value === "number" && !Number.isFinite(value)) {
41995
- throw new TradeRecordsCliError("INVALID_ARGUMENT", "--extra-eq number must be finite");
41996
- }
41997
- return { path: `$.${segments.join(".")}`, value };
41998
- }
41999
- function readTimestamp(parsed, name) {
42000
- const raw = readSingle(parsed, name);
42001
- if (raw === void 0) return void 0;
42002
- const value = Number(raw);
42003
- if (!Number.isSafeInteger(value) || value < 0) {
42004
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `--${name} must be a non-negative integer`);
42005
- }
42006
- return value;
42007
- }
42008
- function assertRange(label, from, to) {
42009
- if (from !== void 0 && to !== void 0 && from > to) {
42010
- throw new TradeRecordsCliError("INVALID_ARGUMENT", `--${label}-from must not exceed --${label}-to`);
42011
- }
42012
- }
42013
- function readLimit(parsed) {
42014
- const raw = readSingle(parsed, "limit");
42015
- if (raw === void 0) return 100;
42016
- const limit = Number(raw);
42017
- if (!Number.isInteger(limit) || limit < 1 || limit > 1e3) {
42018
- throw new TradeRecordsCliError("INVALID_ARGUMENT", "--limit must be an integer between 1 and 1000");
42019
- }
42020
- return limit;
42021
- }
42022
- function readChoice(parsed, name, choices) {
42023
- const value = readSingle(parsed, name);
42024
- if (value === void 0) return void 0;
42025
- if (!choices.includes(value)) {
42026
- throw new TradeRecordsCliError(
42027
- "INVALID_ARGUMENT",
42028
- `--${name} must be one of: ${choices.join(", ")}`
42029
- );
42030
- }
42031
- return value;
42032
- }
42033
- function assertInputSize(value, label) {
42034
- if (Buffer.byteLength(value, "utf8") > MAX_INPUT_BYTES) {
42035
- throw new TradeRecordsCliError("INPUT_TOO_LARGE", `${label} exceeds ${MAX_INPUT_BYTES} bytes`);
42036
- }
42037
- }
42038
- function outputQuery(json, records, limit, nextCursor, count) {
42039
- if (json) {
42040
- console.log(JSON.stringify({
42041
- ok: true,
42042
- records,
42043
- page: { limit, nextCursor },
42044
- ...count === void 0 ? {} : { count }
42045
- }));
42046
- return;
42047
- }
42048
- if (records.length === 0) {
42049
- console.log("No trade records found.");
42050
- return;
42051
- }
42052
- for (const record of records) {
42053
- console.log(
42054
- `${record.deliveryId} job=${record.jobId} status=${record.status} reason=${JSON.stringify(record.reason)} extra=${JSON.stringify(record.extra)} createdAt=${record.createdAt} updatedAt=${record.updatedAt} deletedAt=${record.deletedAt ?? ""}`
42055
- );
42056
- }
42057
- if (nextCursor) {
42058
- console.log(`Next cursor: ${nextCursor}`);
42059
- }
42060
- if (count !== void 0) {
42061
- console.log(`Count: ${count}`);
42062
- }
42063
- }
42064
- function outputDelete(json, result) {
42065
- if (json) {
42066
- console.log(JSON.stringify({ ok: true, operation: "delete", ...result }));
42067
- return;
42068
- }
42069
- if (result.deleted) {
42070
- console.log(`Trade record deleted: deliveryId=${result.deliveryId}`);
42071
- } else if (result.alreadyDeleted) {
42072
- console.log(`Trade record already deleted: deliveryId=${result.deliveryId}`);
42073
- } else {
42074
- console.log(`Trade record not found: deliveryId=${result.deliveryId}`);
42075
- }
42076
- }
42077
- function outputError(json, error) {
42078
- if (json) {
42079
- console.log(JSON.stringify({
42080
- ok: false,
42081
- code: error.code,
42082
- message: error.message,
42083
- ...error.details ? { details: error.details } : {}
42084
- }));
42085
- return;
42086
- }
42087
- console.error(`Trade records error [${error.code}]: ${error.message}`);
42088
- for (const detail of error.details ?? []) {
42089
- console.error(
42090
- ` index=${detail.index ?? ""} field=${detail.field ?? ""} reason=${detail.reason}`
42091
- );
42092
- }
42093
- }
42094
- function normalizeError(error) {
42095
- if (error instanceof TradeRecordsCliError) return error;
42096
- if (error instanceof TradeRecordsStoreError) {
42097
- return new TradeRecordsCliError(error.code, error.message);
42098
- }
42099
- if (isBusyError(error)) {
42100
- return new TradeRecordsCliError("DATABASE_BUSY", "trade records database is busy; retry later");
42101
- }
42102
- return new TradeRecordsCliError(
42103
- "TRADE_RECORDS_FAILED",
42104
- error instanceof Error ? error.message : String(error)
42105
- );
42106
- }
42107
- function isBusyError(error) {
42108
- if (!(error instanceof Error)) return false;
42109
- const code = error.errcode;
42110
- return typeof code === "number" && ((code & 255) === 5 || (code & 255) === 6) || /database is locked|database table is locked/i.test(error.message);
42111
- }
42112
- function isJsonObject2(value) {
42113
- return typeof value === "object" && value !== null && !Array.isArray(value);
42114
- }
42115
- function isHelpArg(value) {
42116
- return value === "help" || value === "-h" || value === "--help";
42117
- }
42118
- var import_node_fs21, MAX_BATCH_RECORDS, MAX_INPUT_BYTES, MAX_EXTRA_BYTES, MAX_ID_LENGTH, MAX_STATUS_LENGTH, MAX_REASON_LENGTH, INPUT_FIELD_OPTIONS, FORBIDDEN_RECORD_FIELDS, ALLOWED_RECORD_FIELDS, TradeRecordsCliError;
42119
- var init_trade_records_cli = __esm({
42120
- "src/trade-records-cli.ts"() {
42121
- "use strict";
42122
- import_node_fs21 = require("node:fs");
42123
- init_trade_records_store();
42124
- MAX_BATCH_RECORDS = 1e3;
42125
- MAX_INPUT_BYTES = 10 * 1024 * 1024;
42126
- MAX_EXTRA_BYTES = 256 * 1024;
42127
- MAX_ID_LENGTH = 512;
42128
- MAX_STATUS_LENGTH = 128;
42129
- MAX_REASON_LENGTH = 4096;
42130
- INPUT_FIELD_OPTIONS = /* @__PURE__ */ new Set(["job-id", "delivery-id", "status", "reason", "extra"]);
42131
- FORBIDDEN_RECORD_FIELDS = /* @__PURE__ */ new Set([
42132
- "createdAt",
42133
- "createAt",
42134
- "updatedAt",
42135
- "updateAt",
42136
- "deletedAt",
42137
- "created_at",
42138
- "create_at",
42139
- "updated_at",
42140
- "update_at",
42141
- "deleted_at"
42142
- ]);
42143
- ALLOWED_RECORD_FIELDS = /* @__PURE__ */ new Set(["jobId", "deliveryId", "status", "reason", "extra"]);
42144
- TradeRecordsCliError = class extends Error {
42145
- code;
42146
- details;
42147
- constructor(code, message, details) {
42148
- super(message);
42149
- this.name = "TradeRecordsCliError";
42150
- this.code = code;
42151
- this.details = details;
42152
- }
42153
- };
42154
- }
42155
- });
42156
-
42157
41100
  // ../core/src/xmtp-sdk/onchainos/bin.ts
42158
41101
  async function refreshOnchainosVersionMetadata(options = {}) {
42159
41102
  const now = options.now ?? Date.now;
@@ -42273,11 +41216,11 @@ function isResolvedBinUsable(bin) {
42273
41216
  if (!isPathLikeCommand(bin)) {
42274
41217
  return true;
42275
41218
  }
42276
- return process.platform === "win32" ? (0, import_node_fs22.existsSync)(bin) : isExecutable2(bin);
41219
+ return process.platform === "win32" ? (0, import_node_fs20.existsSync)(bin) : isExecutable2(bin);
42277
41220
  }
42278
41221
  function resolvePosixBareCommand(command, pathValue) {
42279
41222
  for (const dir of pathValue.split(":")) {
42280
- const candidate = (0, import_node_path25.join)(dir || ".", command);
41223
+ const candidate = (0, import_node_path24.join)(dir || ".", command);
42281
41224
  if (isExecutable2(candidate)) {
42282
41225
  return candidate;
42283
41226
  }
@@ -42560,12 +41503,12 @@ function buildWin32CandidatePaths(names, pathValue, userProfile) {
42560
41503
  addDir(dir);
42561
41504
  }
42562
41505
  if (userProfile?.trim()) {
42563
- addDir((0, import_node_path25.join)(userProfile, ".local", "bin"));
41506
+ addDir((0, import_node_path24.join)(userProfile, ".local", "bin"));
42564
41507
  }
42565
41508
  const candidates = [];
42566
41509
  for (const dir of dirs) {
42567
41510
  for (const name of names) {
42568
- candidates.push((0, import_node_path25.join)(dir, name));
41511
+ candidates.push((0, import_node_path24.join)(dir, name));
42569
41512
  }
42570
41513
  }
42571
41514
  return candidates;
@@ -42578,7 +41521,7 @@ function buildWin32OnchainosCandidates(pathValue, userProfile) {
42578
41521
  );
42579
41522
  }
42580
41523
  function resolveWin32BareCommandCandidate(command, pathValue, pathExtValue, userProfile) {
42581
- const names = (0, import_node_path25.extname)(command) ? [command] : [
41524
+ const names = (0, import_node_path24.extname)(command) ? [command] : [
42582
41525
  ...new Set(
42583
41526
  pathExtValue.split(";").map((extension) => extension.trim().toLowerCase()).filter(Boolean).map(
42584
41527
  (extension) => `${command}${extension.startsWith(".") ? extension : `.${extension}`}`
@@ -42594,7 +41537,7 @@ function resolveWin32BareCommandCandidate(command, pathValue, pathExtValue, user
42594
41537
  return null;
42595
41538
  }
42596
41539
  function win32CandidatePriority(candidate) {
42597
- const extension = (0, import_node_path25.extname)(candidate).toLowerCase();
41540
+ const extension = (0, import_node_path24.extname)(candidate).toLowerCase();
42598
41541
  if (extension === ".exe") {
42599
41542
  return 0;
42600
41543
  }
@@ -42610,7 +41553,7 @@ function isWindowsAppsAlias(candidate) {
42610
41553
  return candidate.toLowerCase().includes(WINDOWS_APPS_ALIAS_MARKER);
42611
41554
  }
42612
41555
  function win32FileExists(path2) {
42613
- return (0, import_node_fs22.existsSync)(path2);
41556
+ return (0, import_node_fs20.existsSync)(path2);
42614
41557
  }
42615
41558
  function pickOnchainosWin32Candidate(lines, fileExists2 = win32FileExists) {
42616
41559
  const candidates = lines.map((line) => {
@@ -42666,7 +41609,7 @@ function extractExecutablePath(stdout) {
42666
41609
  }
42667
41610
  function isExecutable2(path2) {
42668
41611
  try {
42669
- (0, import_node_fs22.accessSync)(path2, import_node_fs22.constants.X_OK);
41612
+ (0, import_node_fs20.accessSync)(path2, import_node_fs20.constants.X_OK);
42670
41613
  return true;
42671
41614
  } catch {
42672
41615
  return false;
@@ -42771,14 +41714,14 @@ async function exec(args, options = {}) {
42771
41714
  }
42772
41715
  throw new Error("OnchainOS command retry exhausted");
42773
41716
  }
42774
- var import_node_fs22, import_node_child_process8, import_node_path25, import_node_util2, execFileAsync2, resolvedBin, resolvedForEnvBin, resolverRevision, versionProbeInFlight, posixDiscoveryFlights, REDACTED_VALUE_FLAGS, COMMAND_UNAVAILABLE_CODES, ONCHAINOS_VERSION_PROBE_TIMEOUT_MS, ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS, WINDOWS_APPS_ALIAS_MARKER;
41717
+ var import_node_fs20, import_node_child_process8, import_node_path24, import_node_util2, execFileAsync2, resolvedBin, resolvedForEnvBin, resolverRevision, versionProbeInFlight, posixDiscoveryFlights, REDACTED_VALUE_FLAGS, COMMAND_UNAVAILABLE_CODES, ONCHAINOS_VERSION_PROBE_TIMEOUT_MS, ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS, WINDOWS_APPS_ALIAS_MARKER;
42775
41718
  var init_bin = __esm({
42776
41719
  "../core/src/xmtp-sdk/onchainos/bin.ts"() {
42777
41720
  "use strict";
42778
41721
  init_log();
42779
- import_node_fs22 = require("node:fs");
41722
+ import_node_fs20 = require("node:fs");
42780
41723
  import_node_child_process8 = require("node:child_process");
42781
- import_node_path25 = require("node:path");
41724
+ import_node_path24 = require("node:path");
42782
41725
  import_node_util2 = require("node:util");
42783
41726
  init_sentry_logger();
42784
41727
  init_runtime_metadata();
@@ -42840,7 +41783,7 @@ function createAsyncStreamProxy(stream) {
42840
41783
  }
42841
41784
  });
42842
41785
  }
42843
- var import_node_bindings, import_node_bindings2, import_node_crypto9, import_types, import_node_path26, import_node_process, HistorySyncUrls, envMap, reverseEnvMap, envToString, createBackend, InboxReassignError, AccountAlreadyAssociatedError, MissingContentTypeError, SignerUnavailableError, ClientNotInitializedError, StreamFailedError, StreamInvalidRetryAttemptsError, generateInboxId, getInboxIdForIdentifier, isReaction, isReply, isText, isRemoteAttachment, isAttachment, isMultiRemoteAttachment, isTransactionReference, isGroupUpdated, isReadReceipt, isLeaveRequest, isWalletSendCalls, isIntent, isActions, isMarkdown, CodecRegistry, getContentFromDecodedMessageContent, getContentTypeFromDecodedMessageContent, DecodedMessage, AsyncStream, usableProperties, isUsableProperty, wait, DEFAULT_RETRY_DELAY, DEFAULT_RETRY_ATTEMPTS, createStream, Conversation, Dm, Group, Conversations, DebugInformation, Preferences, networkOptionKeys, hasBackend, resolveBackend$1, createClient, resolveBackend, createEphemeralIdentifier, toInboxUpdatesCountMap, Client;
41786
+ var import_node_bindings, import_node_bindings2, import_node_crypto9, import_types, import_node_path25, import_node_process, HistorySyncUrls, envMap, reverseEnvMap, envToString, createBackend, InboxReassignError, AccountAlreadyAssociatedError, MissingContentTypeError, SignerUnavailableError, ClientNotInitializedError, StreamFailedError, StreamInvalidRetryAttemptsError, generateInboxId, getInboxIdForIdentifier, isReaction, isReply, isText, isRemoteAttachment, isAttachment, isMultiRemoteAttachment, isTransactionReference, isGroupUpdated, isReadReceipt, isLeaveRequest, isWalletSendCalls, isIntent, isActions, isMarkdown, CodecRegistry, getContentFromDecodedMessageContent, getContentTypeFromDecodedMessageContent, DecodedMessage, AsyncStream, usableProperties, isUsableProperty, wait, DEFAULT_RETRY_DELAY, DEFAULT_RETRY_ATTEMPTS, createStream, Conversation, Dm, Group, Conversations, DebugInformation, Preferences, networkOptionKeys, hasBackend, resolveBackend$1, createClient, resolveBackend, createEphemeralIdentifier, toInboxUpdatesCountMap, Client;
42844
41787
  var init_dist2 = __esm({
42845
41788
  "../../node_modules/@xmtp/node-sdk/dist/index.js"() {
42846
41789
  import_node_bindings = require("@xmtp/node-bindings");
@@ -42848,7 +41791,7 @@ var init_dist2 = __esm({
42848
41791
  import_node_crypto9 = require("node:crypto");
42849
41792
  init_dist();
42850
41793
  import_types = require("node:util/types");
42851
- import_node_path26 = require("node:path");
41794
+ import_node_path25 = require("node:path");
42852
41795
  import_node_process = __toESM(require("node:process"), 1);
42853
41796
  HistorySyncUrls = {
42854
41797
  local: "http://localhost:5558",
@@ -44487,7 +43430,7 @@ var init_dist2 = __esm({
44487
43430
  const env = envToString(backend.env);
44488
43431
  let dbPath;
44489
43432
  if (options?.dbPath === void 0) {
44490
- dbPath = (0, import_node_path26.join)(import_node_process.default.cwd(), `xmtp-${env}-${inboxId}.db3`);
43433
+ dbPath = (0, import_node_path25.join)(import_node_process.default.cwd(), `xmtp-${env}-${inboxId}.db3`);
44491
43434
  } else if (typeof options.dbPath === "function") {
44492
43435
  dbPath = options.dbPath(inboxId);
44493
43436
  } else {
@@ -56778,14 +55721,14 @@ async function createRemoteAttachmentFromFile(unencryptedFile, uploadCallback) {
56778
55721
  const fileUrl = await uploadCallback(encryptedAttachment);
56779
55722
  return createRemoteAttachment(encryptedAttachment, fileUrl);
56780
55723
  }
56781
- var import_node_events, import_node_fs23, import_node_path27, import_ts_retry_promise, import_node_crypto10, version2, fromSelf, hasContent, isDM, isGroup, isGroupAdmin, isGroupSuperAdmin, usesCodec, filter, validLogLevels, isLogLevel, getValidLogLevels, parseLogLevel, logDetails, getInstallationInfo, createUser, createIdentifier, createSigner, AgentError, AgentStreamingError, ClientContext, ConversationContext, MessageContext, Agent, CANCEL_ACTION_ID, LimitedMap, cache;
55724
+ var import_node_events, import_node_fs21, import_node_path26, import_ts_retry_promise, import_node_crypto10, version2, fromSelf, hasContent, isDM, isGroup, isGroupAdmin, isGroupSuperAdmin, usesCodec, filter, validLogLevels, isLogLevel, getValidLogLevels, parseLogLevel, logDetails, getInstallationInfo, createUser, createIdentifier, createSigner, AgentError, AgentStreamingError, ClientContext, ConversationContext, MessageContext, Agent, CANCEL_ACTION_ID, LimitedMap, cache;
56782
55725
  var init_dist4 = __esm({
56783
55726
  "../../node_modules/@xmtp/agent-sdk/dist/index.js"() {
56784
55727
  init_dist2();
56785
55728
  init_dist2();
56786
55729
  import_node_events = __toESM(require("node:events"), 1);
56787
- import_node_fs23 = __toESM(require("node:fs"), 1);
56788
- import_node_path27 = __toESM(require("node:path"), 1);
55730
+ import_node_fs21 = __toESM(require("node:fs"), 1);
55731
+ import_node_path26 = __toESM(require("node:path"), 1);
56789
55732
  import_ts_retry_promise = __toESM(require_retry_promise(), 1);
56790
55733
  init_dist3();
56791
55734
  init_esm();
@@ -57151,9 +56094,9 @@ var init_dist4 = __esm({
57151
56094
  initializedOptions.gatewayHost = XMTP_GATEWAY_HOST;
57152
56095
  }
57153
56096
  if (typeof XMTP_DB_DIRECTORY === "string") {
57154
- import_node_fs23.default.mkdirSync(XMTP_DB_DIRECTORY, { recursive: true, mode: 448 });
56097
+ import_node_fs21.default.mkdirSync(XMTP_DB_DIRECTORY, { recursive: true, mode: 448 });
57155
56098
  initializedOptions.dbPath = (inboxId) => {
57156
- const dbPath = import_node_path27.default.join(XMTP_DB_DIRECTORY, `xmtp-${inboxId}.db3`);
56099
+ const dbPath = import_node_path26.default.join(XMTP_DB_DIRECTORY, `xmtp-${inboxId}.db3`);
57157
56100
  console.info(`Saving local database to "${dbPath}"`);
57158
56101
  return dbPath;
57159
56102
  };
@@ -58196,7 +57139,7 @@ var init_session_expired = __esm({
58196
57139
 
58197
57140
  // ../core/src/xmtp-sdk/index.ts
58198
57141
  function cachePath(dataDir, fileName) {
58199
- return (0, import_node_path28.join)(dataDir, fileName);
57142
+ return (0, import_node_path27.join)(dataDir, fileName);
58200
57143
  }
58201
57144
  function formatLogTimestamp2(timestampMs) {
58202
57145
  return timestampMs && timestampMs > 0 ? new Date(timestampMs).toISOString() : "(none)";
@@ -58224,10 +57167,10 @@ function ensureCacheDir(dataDir) {
58224
57167
  function loadSensitiveWordsFromCache(dataDir) {
58225
57168
  try {
58226
57169
  const path2 = cachePath(dataDir, "sensitive-words.json");
58227
- if (!(0, import_node_fs24.existsSync)(path2)) {
57170
+ if (!(0, import_node_fs22.existsSync)(path2)) {
58228
57171
  return null;
58229
57172
  }
58230
- const data = JSON.parse((0, import_node_fs24.readFileSync)(path2, "utf-8"));
57173
+ const data = JSON.parse((0, import_node_fs22.readFileSync)(path2, "utf-8"));
58231
57174
  if (Array.isArray(data)) {
58232
57175
  return data;
58233
57176
  }
@@ -58241,7 +57184,7 @@ function loadSensitiveWordsFromCache(dataDir) {
58241
57184
  function saveSensitiveWordsToCache(dataDir, words) {
58242
57185
  try {
58243
57186
  ensureCacheDir(dataDir);
58244
- (0, import_node_fs24.writeFileSync)(cachePath(dataDir, "sensitive-words.json"), JSON.stringify(words));
57187
+ (0, import_node_fs22.writeFileSync)(cachePath(dataDir, "sensitive-words.json"), JSON.stringify(words));
58245
57188
  } catch (err2) {
58246
57189
  logWithTimestamp(`[xmtp-sdk] failed to write sensitive-words.json:`, err2);
58247
57190
  logger.error(LogEvent.CACHE_WRITE_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), { cacheName: "sensitive-words" });
@@ -58283,10 +57226,10 @@ async function loadSensitiveWordsWith(dataDir, fetcher) {
58283
57226
  function loadSystemConfigFromCache(dataDir) {
58284
57227
  try {
58285
57228
  const path2 = cachePath(dataDir, "system-config.json");
58286
- if (!(0, import_node_fs24.existsSync)(path2)) {
57229
+ if (!(0, import_node_fs22.existsSync)(path2)) {
58287
57230
  return null;
58288
57231
  }
58289
- const data = JSON.parse((0, import_node_fs24.readFileSync)(path2, "utf-8"));
57232
+ const data = JSON.parse((0, import_node_fs22.readFileSync)(path2, "utf-8"));
58290
57233
  if (data && typeof data === "object" && !Array.isArray(data)) {
58291
57234
  return data;
58292
57235
  }
@@ -58300,7 +57243,7 @@ function loadSystemConfigFromCache(dataDir) {
58300
57243
  function saveSystemConfigToCache(dataDir, config) {
58301
57244
  try {
58302
57245
  ensureCacheDir(dataDir);
58303
- (0, import_node_fs24.writeFileSync)(cachePath(dataDir, "system-config.json"), JSON.stringify(config));
57246
+ (0, import_node_fs22.writeFileSync)(cachePath(dataDir, "system-config.json"), JSON.stringify(config));
58304
57247
  } catch (err2) {
58305
57248
  logWithTimestamp(`[xmtp-sdk] failed to write system-config.json:`, err2);
58306
57249
  logger.error(LogEvent.CACHE_WRITE_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), { cacheName: "system-config" });
@@ -58350,10 +57293,10 @@ function loadSyncByAddress(dataDir) {
58350
57293
  const map = /* @__PURE__ */ new Map();
58351
57294
  try {
58352
57295
  const path2 = cachePath(dataDir, "last-sync.json");
58353
- if (!(0, import_node_fs24.existsSync)(path2)) {
57296
+ if (!(0, import_node_fs22.existsSync)(path2)) {
58354
57297
  return map;
58355
57298
  }
58356
- const data = JSON.parse((0, import_node_fs24.readFileSync)(path2, "utf-8"));
57299
+ const data = JSON.parse((0, import_node_fs22.readFileSync)(path2, "utf-8"));
58357
57300
  const obj = data?.syncByAddress;
58358
57301
  if (obj && typeof obj === "object" && !Array.isArray(obj)) {
58359
57302
  for (const [addr, ts] of Object.entries(obj)) {
@@ -58372,9 +57315,9 @@ function saveSyncForAddress(dataDir, address, timestampMs) {
58372
57315
  try {
58373
57316
  let data = {};
58374
57317
  const path2 = cachePath(dataDir, "last-sync.json");
58375
- if ((0, import_node_fs24.existsSync)(path2)) {
57318
+ if ((0, import_node_fs22.existsSync)(path2)) {
58376
57319
  try {
58377
- const raw = JSON.parse((0, import_node_fs24.readFileSync)(path2, "utf-8"));
57320
+ const raw = JSON.parse((0, import_node_fs22.readFileSync)(path2, "utf-8"));
58378
57321
  if (raw && typeof raw === "object" && !Array.isArray(raw)) {
58379
57322
  data = raw;
58380
57323
  }
@@ -58385,7 +57328,7 @@ function saveSyncForAddress(dataDir, address, timestampMs) {
58385
57328
  data.syncByAddress = {};
58386
57329
  }
58387
57330
  data.syncByAddress[address] = timestampMs;
58388
- (0, import_node_fs24.writeFileSync)(path2, JSON.stringify(data, null, 2));
57331
+ (0, import_node_fs22.writeFileSync)(path2, JSON.stringify(data, null, 2));
58389
57332
  } catch (err2) {
58390
57333
  logWithTimestamp(
58391
57334
  `[xmtp-sdk] failed to write last-sync.json (address=${address}):`,
@@ -58604,13 +57547,13 @@ function createOfflineReplayAddressSummary(address) {
58604
57547
  durationMs: 0
58605
57548
  };
58606
57549
  }
58607
- var import_node_fs24, import_node_path28, DEFAULT_DATA_DIR, XMTP_INSTALLATION_WARNING_THRESHOLD, XMTP_INSTALLATION_NEAR_LIMIT_THRESHOLD, REPLAY_SCAN_INITIAL_BACKOFF_MS, REPLAY_SCAN_MAX_BACKOFF_MS, SENSITIVE_WORDS_LAZY_RETRY_COOLDOWN_MS, InboundReplayGate, SYSTEM_CONFIG_DEFAULTS, STREAM_RECOVERY_ALERT_THRESHOLD_MS, STREAM_RECOVERY_STABILITY_WINDOW_MS, REPLAY_GATE_DRAIN_MAX_ATTEMPTS, REPLAY_GATE_DRAIN_RETRY_DELAY_MS, SEMVER_RE, isRecord5, isPositiveNumber, SYSTEM_CONFIG_VALIDATORS, XmtpService;
57550
+ var import_node_fs22, import_node_path27, DEFAULT_DATA_DIR, XMTP_INSTALLATION_WARNING_THRESHOLD, XMTP_INSTALLATION_NEAR_LIMIT_THRESHOLD, REPLAY_SCAN_INITIAL_BACKOFF_MS, REPLAY_SCAN_MAX_BACKOFF_MS, SENSITIVE_WORDS_LAZY_RETRY_COOLDOWN_MS, InboundReplayGate, SYSTEM_CONFIG_DEFAULTS, STREAM_RECOVERY_ALERT_THRESHOLD_MS, STREAM_RECOVERY_STABILITY_WINDOW_MS, REPLAY_GATE_DRAIN_MAX_ATTEMPTS, REPLAY_GATE_DRAIN_RETRY_DELAY_MS, SEMVER_RE, isRecord5, isPositiveNumber, SYSTEM_CONFIG_VALIDATORS, XmtpService;
58608
57551
  var init_xmtp_sdk = __esm({
58609
57552
  "../core/src/xmtp-sdk/index.ts"() {
58610
57553
  "use strict";
58611
57554
  init_log();
58612
- import_node_fs24 = require("node:fs");
58613
- import_node_path28 = require("node:path");
57555
+ import_node_fs22 = require("node:fs");
57556
+ import_node_path27 = require("node:path");
58614
57557
  init_dist4();
58615
57558
  init_dist2();
58616
57559
  init_sentry_logger();
@@ -61846,7 +60789,7 @@ var init_envelope = __esm({
61846
60789
  });
61847
60790
 
61848
60791
  // src/invalid-message-store.ts
61849
- function loadSqlite5() {
60792
+ function loadSqlite4() {
61850
60793
  const originalEmitWarning = process.emitWarning;
61851
60794
  process.emitWarning = ((warning, ...args) => {
61852
60795
  const message = typeof warning === "string" ? warning : warning.message;
@@ -61861,22 +60804,22 @@ function loadSqlite5() {
61861
60804
  process.emitWarning = originalEmitWarning;
61862
60805
  }
61863
60806
  }
61864
- var import_node_fs25, import_node_path29, DatabaseSync4, InvalidXmtpMessageStore;
60807
+ var import_node_fs23, import_node_path28, DatabaseSync3, InvalidXmtpMessageStore;
61865
60808
  var init_invalid_message_store = __esm({
61866
60809
  "src/invalid-message-store.ts"() {
61867
60810
  "use strict";
61868
- import_node_fs25 = require("node:fs");
61869
- import_node_path29 = require("node:path");
60811
+ import_node_fs23 = require("node:fs");
60812
+ import_node_path28 = require("node:path");
61870
60813
  init_paths();
61871
- ({ DatabaseSync: DatabaseSync4 } = loadSqlite5());
60814
+ ({ DatabaseSync: DatabaseSync3 } = loadSqlite4());
61872
60815
  InvalidXmtpMessageStore = class {
61873
60816
  dbPath;
61874
60817
  db;
61875
60818
  constructor(homeDir) {
61876
60819
  const paths = resolveTaskPaths(homeDir);
61877
- this.dbPath = (0, import_node_path29.join)(paths.sqliteDir, "invalid-xmtp-messages.sqlite");
61878
- (0, import_node_fs25.mkdirSync)((0, import_node_path29.dirname)(this.dbPath), { recursive: true });
61879
- this.db = new DatabaseSync4(this.dbPath);
60820
+ this.dbPath = (0, import_node_path28.join)(paths.sqliteDir, "invalid-xmtp-messages.sqlite");
60821
+ (0, import_node_fs23.mkdirSync)((0, import_node_path28.dirname)(this.dbPath), { recursive: true });
60822
+ this.db = new DatabaseSync3(this.dbPath);
61880
60823
  this.ensureReady();
61881
60824
  }
61882
60825
  close() {
@@ -63321,7 +62264,7 @@ function buildAiAdapterCommand(options) {
63321
62264
  function readCodexAddDirs(env = process.env) {
63322
62265
  const raw = env.OKX_A2A_AI_CODEX_ADD_DIRS ?? env.OKX_AGENT_TASK_CODEX_ADD_DIRS ?? "";
63323
62266
  const seen = /* @__PURE__ */ new Set();
63324
- return raw.split(import_node_path30.delimiter).map((value) => expandHomePath(value.trim())).filter(Boolean).filter((dir) => {
62267
+ return raw.split(import_node_path29.delimiter).map((value) => expandHomePath(value.trim())).filter(Boolean).filter((dir) => {
63325
62268
  if (seen.has(dir)) {
63326
62269
  return false;
63327
62270
  }
@@ -63334,7 +62277,7 @@ function expandHomePath(value) {
63334
62277
  return (0, import_node_os9.homedir)();
63335
62278
  }
63336
62279
  if (value.startsWith("~/")) {
63337
- return (0, import_node_path30.join)((0, import_node_os9.homedir)(), value.slice(2));
62280
+ return (0, import_node_path29.join)((0, import_node_os9.homedir)(), value.slice(2));
63338
62281
  }
63339
62282
  return value;
63340
62283
  }
@@ -63551,9 +62494,9 @@ function formatOpenClawSessionKey(sessionKey, agentId) {
63551
62494
  function buildClaudeAddDirArgs(homeDir, env) {
63552
62495
  const dirs = [
63553
62496
  homeDir,
63554
- (0, import_node_path30.join)((0, import_node_os9.homedir)(), ".agents"),
63555
- (0, import_node_path30.join)(__dirname, ".."),
63556
- ...env.OKX_A2A_AI_CLAUDE_ADD_DIRS ? env.OKX_A2A_AI_CLAUDE_ADD_DIRS.split(import_node_path30.delimiter).filter(Boolean) : []
62497
+ (0, import_node_path29.join)((0, import_node_os9.homedir)(), ".agents"),
62498
+ (0, import_node_path29.join)(__dirname, ".."),
62499
+ ...env.OKX_A2A_AI_CLAUDE_ADD_DIRS ? env.OKX_A2A_AI_CLAUDE_ADD_DIRS.split(import_node_path29.delimiter).filter(Boolean) : []
63557
62500
  ];
63558
62501
  return ["--add-dir", ...[...new Set(dirs)]];
63559
62502
  }
@@ -63605,16 +62548,16 @@ function applyArgTemplate(template, options) {
63605
62548
  const homeDir = options.homeDir ?? resolveTaskPaths().homeDir;
63606
62549
  const cwd = options.cwd ?? process.cwd();
63607
62550
  return template.map((arg) => {
63608
- return arg.replaceAll("{prompt}", options.prompt).replaceAll("{sessionId}", options.sessionId ?? "").replaceAll("{homeDir}", homeDir).replaceAll("{cwd}", cwd).replaceAll("{repoCli}", (0, import_node_path30.join)(__dirname, "cli.js"));
62551
+ return arg.replaceAll("{prompt}", options.prompt).replaceAll("{sessionId}", options.sessionId ?? "").replaceAll("{homeDir}", homeDir).replaceAll("{cwd}", cwd).replaceAll("{repoCli}", (0, import_node_path29.join)(__dirname, "cli.js"));
63609
62552
  });
63610
62553
  }
63611
- var import_node_os9, import_node_path30, CLAUDE_ALLOWED_TOOLS, CLAUDE_PERMISSION_MODES, CODEX_SANDBOX_MODES, CODEX_APPROVAL_POLICIES;
62554
+ var import_node_os9, import_node_path29, CLAUDE_ALLOWED_TOOLS, CLAUDE_PERMISSION_MODES, CODEX_SANDBOX_MODES, CODEX_APPROVAL_POLICIES;
63612
62555
  var init_ai_adapter = __esm({
63613
62556
  "src/ai-adapter.ts"() {
63614
62557
  "use strict";
63615
62558
  init_log();
63616
62559
  import_node_os9 = require("node:os");
63617
- import_node_path30 = require("node:path");
62560
+ import_node_path29 = require("node:path");
63618
62561
  init_ai_command();
63619
62562
  init_paths();
63620
62563
  init_session_store();
@@ -63674,7 +62617,7 @@ function aiRunSentryExtra(input) {
63674
62617
  closeSignal: input.closeSignal ?? "",
63675
62618
  timedOut: input.timedOut === void 0 ? "" : String(input.timedOut),
63676
62619
  aiSessionId: input.aiSessionId ?? "",
63677
- aiLogFile: input.logPath ? (0, import_node_path31.basename)(input.logPath) : "",
62620
+ aiLogFile: input.logPath ? (0, import_node_path30.basename)(input.logPath) : "",
63678
62621
  commandPendingMs: input.commandPendingMs ?? "",
63679
62622
  queueWaitMs: input.queueWaitMs ?? "",
63680
62623
  storeReadMs: input.storeReadMs ?? "",
@@ -63702,7 +62645,7 @@ function resolveProviderCommandWithSelfHeal(options) {
63702
62645
  const env = options.env ?? process.env;
63703
62646
  const storedCommand = options.provider === "codex" ? options.store.getAiProviderCommand(options.provider) : null;
63704
62647
  const resolved = resolveAiProviderCommandWithSource(options.provider, env, storedCommand, options.platform);
63705
- if (options.provider === "codex" && resolved.source !== "explicit_override" && resolved.command !== storedCommand && (0, import_node_path31.isAbsolute)(resolved.command)) {
62648
+ if (options.provider === "codex" && resolved.source !== "explicit_override" && resolved.command !== storedCommand && (0, import_node_path30.isAbsolute)(resolved.command)) {
63706
62649
  options.store.setAiProviderCommand(options.provider, resolved.command);
63707
62650
  }
63708
62651
  return { command: resolved.command, commandSource: resolved.source };
@@ -63734,7 +62677,7 @@ function aiRunToolFailureSentryExtra(failure, context) {
63734
62677
  closeSignal: context.closeSignal ?? "",
63735
62678
  timedOut: String(context.timedOut),
63736
62679
  aiSessionId: context.aiSessionId ?? "",
63737
- aiLogFile: (0, import_node_path31.basename)(context.logPath)
62680
+ aiLogFile: (0, import_node_path30.basename)(context.logPath)
63738
62681
  }).filter(([, value]) => value !== "");
63739
62682
  return entries.reduce((out, [key, value]) => {
63740
62683
  out[key] = String(value);
@@ -63757,7 +62700,7 @@ function safeProcessCwd() {
63757
62700
  }
63758
62701
  function isDirectory(path2) {
63759
62702
  try {
63760
- return (0, import_node_fs26.statSync)(path2).isDirectory();
62703
+ return (0, import_node_fs24.statSync)(path2).isDirectory();
63761
62704
  } catch {
63762
62705
  return false;
63763
62706
  }
@@ -64096,9 +63039,9 @@ function getPreferredCodexWritableRoot(target) {
64096
63039
  const expanded = expandHomePath2(target);
64097
63040
  const home = (0, import_node_os10.homedir)();
64098
63041
  const appRoots = [
64099
- (0, import_node_path31.join)(home, ".onchainos", "task"),
64100
- (0, import_node_path31.join)(home, ".onchainos", "deliverables"),
64101
- (0, import_node_path31.join)(home, ".okx-agent-task")
63042
+ (0, import_node_path30.join)(home, ".onchainos", "task"),
63043
+ (0, import_node_path30.join)(home, ".onchainos", "deliverables"),
63044
+ (0, import_node_path30.join)(home, ".okx-agent-task")
64102
63045
  ];
64103
63046
  for (const root of appRoots) {
64104
63047
  if (expanded === root || expanded.startsWith(`${root}/`)) {
@@ -64113,7 +63056,7 @@ function inferAppOwnedCodexWritableRoot(failure) {
64113
63056
  return void 0;
64114
63057
  }
64115
63058
  if (containsOnchainosCommand(command) && /\b0x[0-9a-fA-F]{16,}\b/.test(command)) {
64116
- return (0, import_node_path31.join)((0, import_node_os10.homedir)(), ".onchainos", "task");
63059
+ return (0, import_node_path30.join)((0, import_node_os10.homedir)(), ".onchainos", "task");
64117
63060
  }
64118
63061
  return void 0;
64119
63062
  }
@@ -64122,7 +63065,7 @@ function expandHomePath2(value) {
64122
63065
  return (0, import_node_os10.homedir)();
64123
63066
  }
64124
63067
  if (value.startsWith("~/")) {
64125
- return (0, import_node_path31.join)((0, import_node_os10.homedir)(), value.slice(2));
63068
+ return (0, import_node_path30.join)((0, import_node_os10.homedir)(), value.slice(2));
64126
63069
  }
64127
63070
  return value;
64128
63071
  }
@@ -64581,7 +63524,11 @@ function synthesizeCodexProsePermissionFailure(input) {
64581
63524
  if (input.existingFailures.some(isReportableAiToolFailure)) {
64582
63525
  return null;
64583
63526
  }
64584
- const output5 = extractCodexAgentMessagePermissionText(input.output) ?? input.output;
63527
+ const agentMessageOutput = extractCodexAgentMessagePermissionText(input.output);
63528
+ if (input.runCompletedSuccessfully && agentMessageOutput === null) {
63529
+ return null;
63530
+ }
63531
+ const output5 = agentMessageOutput ?? input.output;
64585
63532
  if (!looksLikeTerminalPermissionFailure(output5)) {
64586
63533
  return null;
64587
63534
  }
@@ -65103,16 +64050,16 @@ function shortenJobId2(jobId) {
65103
64050
  }
65104
64051
  return `${jobId.slice(0, 6)}\u2026${jobId.slice(-4)}`;
65105
64052
  }
65106
- var import_node_crypto13, import_node_fs26, import_promises12, import_node_os10, import_node_path31, AiRunner, CODEX_TOOL_FAILURE_MARKER;
64053
+ var import_node_crypto13, import_node_fs24, import_promises12, import_node_os10, import_node_path30, AiRunner, CODEX_TOOL_FAILURE_MARKER;
65107
64054
  var init_ai_runner = __esm({
65108
64055
  "src/ai-runner.ts"() {
65109
64056
  "use strict";
65110
64057
  init_log();
65111
64058
  import_node_crypto13 = require("node:crypto");
65112
- import_node_fs26 = require("node:fs");
64059
+ import_node_fs24 = require("node:fs");
65113
64060
  import_promises12 = require("node:fs/promises");
65114
64061
  import_node_os10 = require("node:os");
65115
- import_node_path31 = require("node:path");
64062
+ import_node_path30 = require("node:path");
65116
64063
  init_ai_command();
65117
64064
  init_paths();
65118
64065
  init_file_store();
@@ -65257,7 +64204,7 @@ var init_ai_runner = __esm({
65257
64204
  ensureTaskDir(this.logsDir);
65258
64205
  const lifecycleLogsEnabled = isAiLifecycleLoggingEnabled();
65259
64206
  const logPath = lifecycleLogsEnabled ? this.buildRunLogPath(request) : "";
65260
- const log = lifecycleLogsEnabled ? (0, import_node_fs26.createWriteStream)(logPath, { flags: "a" }) : null;
64207
+ const log = lifecycleLogsEnabled ? (0, import_node_fs24.createWriteStream)(logPath, { flags: "a" }) : null;
65261
64208
  let existing = null;
65262
64209
  let storeReadStartedAt;
65263
64210
  let storeReadEndedAt;
@@ -65510,7 +64457,8 @@ var init_ai_runner = __esm({
65510
64457
  existingFailures: toolFailures.failures,
65511
64458
  errorType: fullOutputErrorType,
65512
64459
  output: runCompletedSuccessfully ? stdoutFull : fullOutputForClassification,
65513
- exitCode
64460
+ exitCode,
64461
+ runCompletedSuccessfully
65514
64462
  });
65515
64463
  const detectedToolFailures = syntheticToolFailure ? [...toolFailures.failures, syntheticToolFailure] : toolFailures.failures;
65516
64464
  const reportableToolFailures = selectReportableAiToolFailures({
@@ -65743,10 +64691,10 @@ var init_ai_runner = __esm({
65743
64691
  const safeMessageId = encodeURIComponent(request.messageId);
65744
64692
  if (request.source === "job-dispatch") {
65745
64693
  const safeJobId = encodeURIComponent(request.jobId ?? "unknown");
65746
- return (0, import_node_path31.join)(this.logsDir, `ai-${safeJobId}-${safeMessageId}.log`);
64694
+ return (0, import_node_path30.join)(this.logsDir, `ai-${safeJobId}-${safeMessageId}.log`);
65747
64695
  }
65748
64696
  const safeSessionKey = encodeURIComponent(request.sessionKey);
65749
- return (0, import_node_path31.join)(this.logsDir, `ai-session-${safeSessionKey}-${safeMessageId}.log`);
64697
+ return (0, import_node_path30.join)(this.logsDir, `ai-session-${safeSessionKey}-${safeMessageId}.log`);
65750
64698
  }
65751
64699
  readRunAiSessionId(provider, request, file, sessionMeta) {
65752
64700
  if (request.source === "job-dispatch" && request.jobId) {
@@ -66085,7 +65033,7 @@ var init_ai_runner = __esm({
66085
65033
  async appendLlmLog(entry) {
66086
65034
  try {
66087
65035
  ensureTaskDir(this.logsDir);
66088
- await (0, import_promises12.appendFile)((0, import_node_path31.join)(this.logsDir, "llm.log"), formatLlmLogEntry(entry), "utf8");
65036
+ await (0, import_promises12.appendFile)((0, import_node_path30.join)(this.logsDir, "llm.log"), formatLlmLogEntry(entry), "utf8");
66089
65037
  } catch (err2) {
66090
65038
  errorWithTimestamp("[okx-agent-task] failed to append llm.log:", err2);
66091
65039
  }
@@ -69513,12 +68461,12 @@ async function isGatewayAvailableForHeartbeat(options) {
69513
68461
  }
69514
68462
  async function getHermesGatewayPluginStatus(options = {}) {
69515
68463
  const env = options.env ?? process.env;
69516
- const hermesHome = env.HERMES_HOME?.trim() || (0, import_node_path32.join)((0, import_node_os11.homedir)(), ".hermes");
69517
- const pluginYamlPath = (0, import_node_path32.join)(hermesHome, "plugins", "platforms", "okx-a2a", "plugin.yaml");
69518
- if (!(0, import_node_fs27.existsSync)(pluginYamlPath)) {
68464
+ const hermesHome = env.HERMES_HOME?.trim() || (0, import_node_path31.join)((0, import_node_os11.homedir)(), ".hermes");
68465
+ const pluginYamlPath = (0, import_node_path31.join)(hermesHome, "plugins", "platforms", "okx-a2a", "plugin.yaml");
68466
+ if (!(0, import_node_fs25.existsSync)(pluginYamlPath)) {
69519
68467
  return { enabled: false, reason: "plugin_yaml_missing", hermesHome, checkedPath: pluginYamlPath };
69520
68468
  }
69521
- const configPath = (0, import_node_path32.join)(hermesHome, "config.yaml");
68469
+ const configPath = (0, import_node_path31.join)(hermesHome, "config.yaml");
69522
68470
  let content2;
69523
68471
  try {
69524
68472
  content2 = await (0, import_promises13.readFile)(configPath, "utf8");
@@ -69750,12 +68698,12 @@ async function runListenerWithLock(options, paths) {
69750
68698
  });
69751
68699
  }
69752
68700
  });
69753
- service.setPluginVersion("0.2.11-beta-8fef2ef558-260901172338");
68701
+ service.setPluginVersion("0.2.11");
69754
68702
  await service.init();
69755
68703
  const pluginVersionStatus = service.pluginVersionStatus;
69756
68704
  if (pluginVersionStatus.unavailable) {
69757
68705
  throw new Error(
69758
- `@okxweb3/a2a-node v${"0.2.11-beta-8fef2ef558-260901172338"} is below the required minimum v${pluginVersionStatus.minVersion}`
68706
+ `@okxweb3/a2a-node v${"0.2.11"} is below the required minimum v${pluginVersionStatus.minVersion}`
69759
68707
  );
69760
68708
  }
69761
68709
  const systemConfig = service.getSystemConfig();
@@ -69783,7 +68731,7 @@ async function runListenerWithLock(options, paths) {
69783
68731
  onchainosAgentId: "*",
69784
68732
  reason: "system-config missing sentryDsn",
69785
68733
  pluginId: "@okxweb3/a2a-node",
69786
- pluginVersion: "0.2.11-beta-8fef2ef558-260901172338"
68734
+ pluginVersion: "0.2.11"
69787
68735
  });
69788
68736
  }
69789
68737
  logWithTimestamp(
@@ -70133,15 +69081,15 @@ async function timeSettled(fn) {
70133
69081
  return { durationMs: Date.now() - startedAt, error };
70134
69082
  }
70135
69083
  }
70136
- var import_node_fs27, import_promises13, import_node_os11, import_node_path32, DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC, DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC, XMTP_CLIENT_RECYCLE_INTERVAL_ENV, HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS, AUTH_RECOVERY_PROBE_INTERVAL_MS, AUTH_RECOVERY_REFRESH_BACKOFF_MS, AgentRefreshAuthGate, AgentRefreshCoordinator, ListenerDeferredTaskScheduler, ListenerMaintenanceGate, UPGRADE_RECOMMENDATION_IDEMPOTENCY_KEY, SHUTDOWN_FORCE_RESOLVE_MS;
69084
+ var import_node_fs25, import_promises13, import_node_os11, import_node_path31, DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC, DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC, XMTP_CLIENT_RECYCLE_INTERVAL_ENV, HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS, AUTH_RECOVERY_PROBE_INTERVAL_MS, AUTH_RECOVERY_REFRESH_BACKOFF_MS, AgentRefreshAuthGate, AgentRefreshCoordinator, ListenerDeferredTaskScheduler, ListenerMaintenanceGate, UPGRADE_RECOMMENDATION_IDEMPOTENCY_KEY, SHUTDOWN_FORCE_RESOLVE_MS;
70137
69085
  var init_listener = __esm({
70138
69086
  "src/listener.ts"() {
70139
69087
  "use strict";
70140
69088
  init_log();
70141
- import_node_fs27 = require("node:fs");
69089
+ import_node_fs25 = require("node:fs");
70142
69090
  import_promises13 = require("node:fs/promises");
70143
69091
  import_node_os11 = require("node:os");
70144
- import_node_path32 = require("node:path");
69092
+ import_node_path31 = require("node:path");
70145
69093
  init_onchainos();
70146
69094
  init_system_config();
70147
69095
  init_offline_replay_capability();
@@ -70386,9 +69334,9 @@ async function handleXmtpTestCommand(args, releaseInfo) {
70386
69334
  async function startXmtpTest(args, releaseInfo) {
70387
69335
  assertKnownOptions(args, /* @__PURE__ */ new Set(["--name", "--run-id", "--json"]));
70388
69336
  const paths = resolveTaskPaths();
70389
- const testsDir = (0, import_node_path33.join)(paths.homeDir, "xmtp-tests");
69337
+ const testsDir = (0, import_node_path32.join)(paths.homeDir, "xmtp-tests");
70390
69338
  await ensurePrivateDir(testsDir);
70391
- const active = await readJsonIfExists((0, import_node_path33.join)(testsDir, ACTIVE_FILE));
69339
+ const active = await readJsonIfExists((0, import_node_path32.join)(testsDir, ACTIVE_FILE));
70392
69340
  if (active?.runId) {
70393
69341
  throw new Error(
70394
69342
  `XMTP test ${active.runId} is already active. Run \`okx-a2a xmtp-test stop\` first.`
@@ -70427,7 +69375,7 @@ async function startXmtpTest(args, releaseInfo) {
70427
69375
  ...releaseInfo
70428
69376
  };
70429
69377
  await writeJson(files.manifestPath, manifest);
70430
- await writeJson((0, import_node_path33.join)(testsDir, ACTIVE_FILE), {
69378
+ await writeJson((0, import_node_path32.join)(testsDir, ACTIVE_FILE), {
70431
69379
  runId,
70432
69380
  startedAt: manifest.startedAt
70433
69381
  });
@@ -70450,7 +69398,7 @@ Run \`okx-a2a xmtp-test watch\` to open the realtime dashboard.`);
70450
69398
  async function stopXmtpTest(args) {
70451
69399
  assertKnownOptions(args, /* @__PURE__ */ new Set(["--json"]));
70452
69400
  const testsDir = resolveTestsDir();
70453
- const activePath = (0, import_node_path33.join)(testsDir, ACTIVE_FILE);
69401
+ const activePath = (0, import_node_path32.join)(testsDir, ACTIVE_FILE);
70454
69402
  const active = await readJsonIfExists(activePath);
70455
69403
  if (!active?.runId) {
70456
69404
  throw new Error("No active XMTP test.");
@@ -70744,17 +69692,17 @@ function formatJobEvent(event) {
70744
69692
  return `${timestamp} ${businessEvent.padEnd(34)} ${role}#${agent} ${source}${timings.length > 0 ? ` ${timings.join(" ")}` : ""}`;
70745
69693
  }
70746
69694
  function resolveTestsDir() {
70747
- return (0, import_node_path33.join)(resolveTaskPaths().homeDir, "xmtp-tests");
69695
+ return (0, import_node_path32.join)(resolveTaskPaths().homeDir, "xmtp-tests");
70748
69696
  }
70749
69697
  function resolveRunFiles(testsDir, runId) {
70750
69698
  validateRunId(runId);
70751
- const runDir = (0, import_node_path33.join)(testsDir, runId);
69699
+ const runDir = (0, import_node_path32.join)(testsDir, runId);
70752
69700
  return {
70753
69701
  testsDir,
70754
69702
  runDir,
70755
- manifestPath: (0, import_node_path33.join)(runDir, "manifest.json"),
70756
- eventsPath: (0, import_node_path33.join)(runDir, "events.jsonl"),
70757
- summaryPath: (0, import_node_path33.join)(runDir, "summary.json")
69703
+ manifestPath: (0, import_node_path32.join)(runDir, "manifest.json"),
69704
+ eventsPath: (0, import_node_path32.join)(runDir, "events.jsonl"),
69705
+ summaryPath: (0, import_node_path32.join)(runDir, "summary.json")
70758
69706
  };
70759
69707
  }
70760
69708
  async function resolveRequestedRunId(testsDir, args, preferActive = false) {
@@ -70762,7 +69710,7 @@ async function resolveRequestedRunId(testsDir, args, preferActive = false) {
70762
69710
  if (requested) {
70763
69711
  return validateRunId(requested);
70764
69712
  }
70765
- const active = await readJsonIfExists((0, import_node_path33.join)(testsDir, ACTIVE_FILE));
69713
+ const active = await readJsonIfExists((0, import_node_path32.join)(testsDir, ACTIVE_FILE));
70766
69714
  if (active?.runId && (preferActive || !args.includes("--latest"))) {
70767
69715
  return validateRunId(active.runId);
70768
69716
  }
@@ -70788,7 +69736,7 @@ async function findLatestRunId(testsDir) {
70788
69736
  continue;
70789
69737
  }
70790
69738
  const manifest = await readJsonIfExists(
70791
- (0, import_node_path33.join)(testsDir, entry.name, "manifest.json")
69739
+ (0, import_node_path32.join)(testsDir, entry.name, "manifest.json")
70792
69740
  );
70793
69741
  if (manifest?.runId && manifest.startedAt) {
70794
69742
  manifests.push(manifest);
@@ -71023,12 +69971,12 @@ function formatPercent(value) {
71023
69971
  function validTimestamp(value) {
71024
69972
  return typeof value === "string" && Number.isFinite(Date.parse(value));
71025
69973
  }
71026
- var import_promises14, import_node_path33, RUN_ID_PATTERN2, ACTIVE_FILE;
69974
+ var import_promises14, import_node_path32, RUN_ID_PATTERN2, ACTIVE_FILE;
71027
69975
  var init_xmtp_test_cli = __esm({
71028
69976
  "src/xmtp-test-cli.ts"() {
71029
69977
  "use strict";
71030
69978
  import_promises14 = require("node:fs/promises");
71031
- import_node_path33 = require("node:path");
69979
+ import_node_path32 = require("node:path");
71032
69980
  init_daemon();
71033
69981
  init_log_tail();
71034
69982
  init_paths();
@@ -114217,9 +113165,9 @@ var init_dist6 = __esm({
114217
113165
 
114218
113166
  // ../core/src/file-upload-safety.ts
114219
113167
  function getUnsafeFileUploadReason(filePath, sensitiveUploadReg = []) {
114220
- const expanded = (0, import_node_path34.resolve)(expandHome(filePath));
114221
- const target = (0, import_node_fs28.realpathSync)(expanded);
114222
- const targetName = (0, import_node_path34.basename)(target);
113168
+ const expanded = (0, import_node_path33.resolve)(expandHome(filePath));
113169
+ const target = (0, import_node_fs26.realpathSync)(expanded);
113170
+ const targetName = (0, import_node_path33.basename)(target);
114223
113171
  if (targetName === ".env" || targetName.startsWith(".env.")) {
114224
113172
  return ".env";
114225
113173
  }
@@ -114232,13 +113180,13 @@ function getUnsafeFileUploadReason(filePath, sensitiveUploadReg = []) {
114232
113180
  return null;
114233
113181
  }
114234
113182
  for (const dir of SENSITIVE_HOME_DIRS) {
114235
- const sensitiveDir = safeRealpath((0, import_node_path34.join)(home, dir));
113183
+ const sensitiveDir = safeRealpath((0, import_node_path33.join)(home, dir));
114236
113184
  if (sensitiveDir && isPathInside(target, sensitiveDir)) {
114237
113185
  return `~/${dir}`;
114238
113186
  }
114239
113187
  }
114240
113188
  for (const file of SENSITIVE_HOME_FILES) {
114241
- const sensitiveFile = safeRealpath((0, import_node_path34.join)(home, file));
113189
+ const sensitiveFile = safeRealpath((0, import_node_path33.join)(home, file));
114242
113190
  if (sensitiveFile && target === sensitiveFile) {
114243
113191
  return `~/${file}`;
114244
113192
  }
@@ -114266,27 +113214,27 @@ function expandHome(filePath) {
114266
113214
  if (filePath === "~") {
114267
113215
  return (0, import_node_os12.homedir)();
114268
113216
  }
114269
- if (filePath.startsWith(`~${import_node_path34.sep}`)) {
114270
- return (0, import_node_path34.join)((0, import_node_os12.homedir)(), filePath.slice(2));
113217
+ if (filePath.startsWith(`~${import_node_path33.sep}`)) {
113218
+ return (0, import_node_path33.join)((0, import_node_os12.homedir)(), filePath.slice(2));
114271
113219
  }
114272
113220
  return filePath;
114273
113221
  }
114274
113222
  function safeRealpath(path2) {
114275
- if (!(0, import_node_fs28.existsSync)(path2)) {
113223
+ if (!(0, import_node_fs26.existsSync)(path2)) {
114276
113224
  return null;
114277
113225
  }
114278
- return (0, import_node_fs28.realpathSync)(path2);
113226
+ return (0, import_node_fs26.realpathSync)(path2);
114279
113227
  }
114280
113228
  function isPathInside(target, dir) {
114281
- return target === dir || target.startsWith(`${dir}${import_node_path34.sep}`);
113229
+ return target === dir || target.startsWith(`${dir}${import_node_path33.sep}`);
114282
113230
  }
114283
- var import_node_fs28, import_node_os12, import_node_path34, SENSITIVE_HOME_DIRS, SENSITIVE_HOME_FILES, UNSAFE_FILE_UPLOAD_MESSAGE;
113231
+ var import_node_fs26, import_node_os12, import_node_path33, SENSITIVE_HOME_DIRS, SENSITIVE_HOME_FILES, UNSAFE_FILE_UPLOAD_MESSAGE;
114284
113232
  var init_file_upload_safety = __esm({
114285
113233
  "../core/src/file-upload-safety.ts"() {
114286
113234
  "use strict";
114287
- import_node_fs28 = require("node:fs");
113235
+ import_node_fs26 = require("node:fs");
114288
113236
  import_node_os12 = require("node:os");
114289
- import_node_path34 = require("node:path");
113237
+ import_node_path33 = require("node:path");
114290
113238
  SENSITIVE_HOME_DIRS = [
114291
113239
  ".ssh",
114292
113240
  ".gnupg",
@@ -114294,7 +113242,7 @@ var init_file_upload_safety = __esm({
114294
113242
  ".azure",
114295
113243
  ".kube",
114296
113244
  ".docker",
114297
- (0, import_node_path34.join)(".config", "gcloud")
113245
+ (0, import_node_path33.join)(".config", "gcloud")
114298
113246
  ];
114299
113247
  SENSITIVE_HOME_FILES = [
114300
113248
  ".npmrc",
@@ -114356,7 +113304,7 @@ function hasHelpFlag(args) {
114356
113304
  return args.some((arg) => arg === "-h" || arg === "--help" || arg === "help");
114357
113305
  }
114358
113306
  async function uploadFile(params) {
114359
- const filename = params.filename || (0, import_node_path35.basename)(params.filePath);
113307
+ const filename = params.filename || (0, import_node_path34.basename)(params.filePath);
114360
113308
  const mimeType = params.mimeType || "application/octet-stream";
114361
113309
  const uploadConfig = readUploadSystemConfig();
114362
113310
  const unsafeReason = getUnsafeFileUploadReason(params.filePath, uploadConfig.sensitiveUploadReg);
@@ -114372,16 +113320,16 @@ async function uploadFile(params) {
114372
113320
  return;
114373
113321
  }
114374
113322
  const maxFileSizeBytes = uploadConfig.maxFileSizeBytes;
114375
- const fileSize = (0, import_node_fs29.statSync)(params.filePath).size;
113323
+ const fileSize = (0, import_node_fs27.statSync)(params.filePath).size;
114376
113324
  if (fileSize > maxFileSizeBytes) {
114377
113325
  throw new Error(formatFileTooLargeMessage(maxFileSizeBytes));
114378
113326
  }
114379
- const data = (0, import_node_fs29.readFileSync)(params.filePath);
113327
+ const data = (0, import_node_fs27.readFileSync)(params.filePath);
114380
113328
  const attachment = { filename, mimeType, data: new Uint8Array(data) };
114381
113329
  const encrypted = await RemoteAttachmentCodec.encodeEncrypted(attachment, new AttachmentCodec());
114382
113330
  ensureFileDirs();
114383
- const encryptedPath = (0, import_node_path35.resolve)(FILE_WORK_DIR, `${(0, import_node_crypto17.randomUUID)()}.enc`);
114384
- (0, import_node_fs29.writeFileSync)(encryptedPath, encrypted.payload);
113331
+ const encryptedPath = (0, import_node_path34.resolve)(FILE_WORK_DIR, `${(0, import_node_crypto17.randomUUID)()}.enc`);
113332
+ (0, import_node_fs27.writeFileSync)(encryptedPath, encrypted.payload);
114385
113333
  try {
114386
113334
  const stdout = runOnchainos([
114387
113335
  "agent",
@@ -114417,14 +113365,14 @@ async function uploadFile(params) {
114417
113365
  }, null, 2));
114418
113366
  } finally {
114419
113367
  try {
114420
- (0, import_node_fs29.unlinkSync)(encryptedPath);
113368
+ (0, import_node_fs27.unlinkSync)(encryptedPath);
114421
113369
  } catch {
114422
113370
  }
114423
113371
  }
114424
113372
  }
114425
113373
  async function downloadFile(params) {
114426
113374
  ensureFileDirs();
114427
- const encryptedPath = (0, import_node_path35.resolve)(FILE_WORK_DIR, `${(0, import_node_crypto17.randomUUID)()}.enc`);
113375
+ const encryptedPath = (0, import_node_path34.resolve)(FILE_WORK_DIR, `${(0, import_node_crypto17.randomUUID)()}.enc`);
114428
113376
  try {
114429
113377
  const stdout = runOnchainos([
114430
113378
  "agent",
@@ -114448,7 +113396,7 @@ async function downloadFile(params) {
114448
113396
  }));
114449
113397
  throw new Error(`file download failed: ${stdout}`);
114450
113398
  }
114451
- const payload = new Uint8Array((0, import_node_fs29.readFileSync)(encryptedPath));
113399
+ const payload = new Uint8Array((0, import_node_fs27.readFileSync)(encryptedPath));
114452
113400
  const digestBytes = new Uint8Array(await import_node_crypto17.webcrypto.subtle.digest("SHA-256", payload));
114453
113401
  const actualDigest = Array.from(digestBytes).map((byte) => byte.toString(16).padStart(2, "0")).join("");
114454
113402
  if (actualDigest !== params.digest) {
@@ -114460,12 +113408,12 @@ async function downloadFile(params) {
114460
113408
  const outputFilename = params.filename || attachment.filename || `${(0, import_node_crypto17.randomUUID)()}.bin`;
114461
113409
  const outputDir = DOWNLOADS_DIR;
114462
113410
  ensureA2aTaskDir(outputDir);
114463
- const outputPath = (0, import_node_path35.resolve)(outputDir, (0, import_node_path35.basename)(outputFilename));
114464
- (0, import_node_fs29.writeFileSync)(outputPath, attachment.data);
113411
+ const outputPath = (0, import_node_path34.resolve)(outputDir, (0, import_node_path34.basename)(outputFilename));
113412
+ (0, import_node_fs27.writeFileSync)(outputPath, attachment.data);
114465
113413
  console.log(outputPath);
114466
113414
  } finally {
114467
113415
  try {
114468
- (0, import_node_fs29.unlinkSync)(encryptedPath);
113416
+ (0, import_node_fs27.unlinkSync)(encryptedPath);
114469
113417
  } catch {
114470
113418
  }
114471
113419
  }
@@ -114562,7 +113510,7 @@ function readUploadSystemConfig() {
114562
113510
  const res = parseCliJson2(stdout, "system-config");
114563
113511
  if (res.data && typeof res.data === "object") {
114564
113512
  ensureA2aTaskDir(OKX_A2A_PATHS.xmtpDir);
114565
- (0, import_node_fs29.writeFileSync)(SYSTEM_CONFIG_PATH, JSON.stringify(res.data));
113513
+ (0, import_node_fs27.writeFileSync)(SYSTEM_CONFIG_PATH, JSON.stringify(res.data));
114566
113514
  }
114567
113515
  return parseUploadSystemConfig(res.data ?? {});
114568
113516
  } catch {
@@ -114585,10 +113533,10 @@ function fileCliSentryExtra(operation, reason, extra = {}) {
114585
113533
  }
114586
113534
  function readSystemConfigFromCache() {
114587
113535
  try {
114588
- if (!(0, import_node_fs29.existsSync)(SYSTEM_CONFIG_PATH)) {
113536
+ if (!(0, import_node_fs27.existsSync)(SYSTEM_CONFIG_PATH)) {
114589
113537
  return null;
114590
113538
  }
114591
- return JSON.parse((0, import_node_fs29.readFileSync)(SYSTEM_CONFIG_PATH, "utf8"));
113539
+ return JSON.parse((0, import_node_fs27.readFileSync)(SYSTEM_CONFIG_PATH, "utf8"));
114592
113540
  } catch {
114593
113541
  return null;
114594
113542
  }
@@ -114622,14 +113570,14 @@ function readRequiredOption(args, name) {
114622
113570
  }
114623
113571
  return value;
114624
113572
  }
114625
- var import_node_crypto17, import_node_fs29, import_node_path35, import_proto2, OKX_A2A_PATHS, OKX_A2A_HOME_DIR, FILE_WORK_DIR, DOWNLOADS_DIR, SYSTEM_CONFIG_PATH;
113573
+ var import_node_crypto17, import_node_fs27, import_node_path34, import_proto2, OKX_A2A_PATHS, OKX_A2A_HOME_DIR, FILE_WORK_DIR, DOWNLOADS_DIR, SYSTEM_CONFIG_PATH;
114626
113574
  var init_file_cli = __esm({
114627
113575
  "src/file-cli.ts"() {
114628
113576
  "use strict";
114629
113577
  init_win_spawn();
114630
113578
  import_node_crypto17 = require("node:crypto");
114631
- import_node_fs29 = require("node:fs");
114632
- import_node_path35 = require("node:path");
113579
+ import_node_fs27 = require("node:fs");
113580
+ import_node_path34 = require("node:path");
114633
113581
  init_dist6();
114634
113582
  import_proto2 = __toESM(require_node4());
114635
113583
  init_a2a_paths();
@@ -114640,7 +113588,7 @@ var init_file_cli = __esm({
114640
113588
  OKX_A2A_HOME_DIR = OKX_A2A_PATHS.homeDir;
114641
113589
  FILE_WORK_DIR = process.env.OKX_A2A_FILE_WORK_DIR || OKX_A2A_PATHS.filesDir;
114642
113590
  DOWNLOADS_DIR = process.env.OKX_A2A_DOWNLOADS_DIR || OKX_A2A_PATHS.downloadsDir;
114643
- SYSTEM_CONFIG_PATH = (0, import_node_path35.resolve)(OKX_A2A_PATHS.xmtpDir, "system-config.json");
113591
+ SYSTEM_CONFIG_PATH = (0, import_node_path34.resolve)(OKX_A2A_PATHS.xmtpDir, "system-config.json");
114644
113592
  }
114645
113593
  });
114646
113594
 
@@ -114651,12 +113599,12 @@ __export(user_attention_cli_exports, {
114651
113599
  });
114652
113600
  async function handleUserCommand(args) {
114653
113601
  const subcommand = args[0];
114654
- if (!subcommand || args.every(isHelpArg2)) {
113602
+ if (!subcommand || args.every(isHelpArg)) {
114655
113603
  printUserUsage();
114656
113604
  return;
114657
113605
  }
114658
113606
  if (subcommand === "help") {
114659
- const helpTarget = args.slice(1).find((arg) => !isHelpArg2(arg));
113607
+ const helpTarget = args.slice(1).find((arg) => !isHelpArg(arg));
114660
113608
  if (!helpTarget) {
114661
113609
  printUserUsage();
114662
113610
  return;
@@ -114673,7 +113621,7 @@ async function handleUserCommand(args) {
114673
113621
  return;
114674
113622
  }
114675
113623
  const commandStartedAt = Date.now();
114676
- const parsed = parseArgs2(args.slice(1));
113624
+ const parsed = parseArgs(args.slice(1));
114677
113625
  const json = parsed.flags.has("json");
114678
113626
  const storeInitStartedAt = Date.now();
114679
113627
  const store = new SessionStore();
@@ -114790,7 +113738,7 @@ async function handleUserCommand(args) {
114790
113738
  function hasHelpFlag2(args) {
114791
113739
  return args.some((arg) => arg === "-h" || arg === "--help");
114792
113740
  }
114793
- function isHelpArg2(arg) {
113741
+ function isHelpArg(arg) {
114794
113742
  return arg === "-h" || arg === "--help" || arg === "help";
114795
113743
  }
114796
113744
  function printUserUsage() {
@@ -115309,7 +114257,7 @@ function runSyncWithoutConsoleOutput(fn) {
115309
114257
  console.error = originalError;
115310
114258
  }
115311
114259
  }
115312
- function parseArgs2(args) {
114260
+ function parseArgs(args) {
115313
114261
  const positional = [];
115314
114262
  const options = /* @__PURE__ */ new Map();
115315
114263
  const flags = /* @__PURE__ */ new Set();
@@ -115763,12 +114711,12 @@ __export(session_cli_exports, {
115763
114711
  });
115764
114712
  async function handleSessionCommand(args) {
115765
114713
  const subcommand = args[0];
115766
- if (!subcommand || args.every(isHelpArg3)) {
114714
+ if (!subcommand || args.every(isHelpArg2)) {
115767
114715
  printSessionUsage();
115768
114716
  return;
115769
114717
  }
115770
114718
  if (subcommand === "help") {
115771
- const helpTarget = args.slice(1).find((arg) => !isHelpArg3(arg));
114719
+ const helpTarget = args.slice(1).find((arg) => !isHelpArg2(arg));
115772
114720
  if (!helpTarget) {
115773
114721
  printSessionUsage();
115774
114722
  return;
@@ -115784,7 +114732,7 @@ async function handleSessionCommand(args) {
115784
114732
  }
115785
114733
  return;
115786
114734
  }
115787
- const parsed = parseArgs3(args.slice(1));
114735
+ const parsed = parseArgs2(args.slice(1));
115788
114736
  const json = parsed.flags.has("json");
115789
114737
  const store = new SessionStore();
115790
114738
  let usedOpenClawGateway = false;
@@ -115950,9 +114898,9 @@ async function handleSessionCommand(args) {
115950
114898
  }
115951
114899
  }
115952
114900
  function hasHelpFlag3(args) {
115953
- return args.some(isHelpArg3);
114901
+ return args.some(isHelpArg2);
115954
114902
  }
115955
- function isHelpArg3(arg) {
114903
+ function isHelpArg2(arg) {
115956
114904
  return arg === "-h" || arg === "--help" || arg === "help";
115957
114905
  }
115958
114906
  function printSessionUsage() {
@@ -116758,7 +115706,7 @@ function normalizeOptionalText4(value) {
116758
115706
  const normalized = value?.trim();
116759
115707
  return normalized ? normalized : null;
116760
115708
  }
116761
- function parseArgs3(args) {
115709
+ function parseArgs2(args) {
116762
115710
  const positional = [];
116763
115711
  const options = /* @__PURE__ */ new Map();
116764
115712
  const flags = /* @__PURE__ */ new Set();
@@ -116841,7 +115789,7 @@ async function handleXmtpDebugCli(args) {
116841
115789
  throw new Error(`Unknown xmtp-debug command: ${subcommand}`);
116842
115790
  }
116843
115791
  const action = subcommand;
116844
- const parsed = parseArgs4(args.slice(1));
115792
+ const parsed = parseArgs3(args.slice(1));
116845
115793
  rejectAccountOverride(parsed);
116846
115794
  const groupId = parsed.options.get("group-id");
116847
115795
  const jobId = parsed.options.get("job-id");
@@ -116935,7 +115883,7 @@ Options:
116935
115883
  --json Print machine-readable JSON.
116936
115884
  `);
116937
115885
  }
116938
- function parseArgs4(args) {
115886
+ function parseArgs3(args) {
116939
115887
  const options = /* @__PURE__ */ new Map();
116940
115888
  const flags = /* @__PURE__ */ new Set();
116941
115889
  for (let index2 = 0; index2 < args.length; index2 += 1) {
@@ -117023,7 +115971,7 @@ async function handleAiCommand(args) {
117023
115971
  return;
117024
115972
  }
117025
115973
  const subcommand = args[0] ?? "status";
117026
- const parsed = parseArgs5(args.slice(1));
115974
+ const parsed = parseArgs4(args.slice(1));
117027
115975
  const json = parsed.flags.has("json");
117028
115976
  const store = new SessionStore();
117029
115977
  try {
@@ -117147,7 +116095,7 @@ function output4(json, payload, human) {
117147
116095
  }
117148
116096
  console.log(human);
117149
116097
  }
117150
- function parseArgs5(args) {
116098
+ function parseArgs4(args) {
117151
116099
  const positional = [];
117152
116100
  const options = /* @__PURE__ */ new Map();
117153
116101
  const flags = /* @__PURE__ */ new Set();
@@ -117203,7 +116151,7 @@ function isPostjectRunnable() {
117203
116151
  function resolvePostjectCommand() {
117204
116152
  try {
117205
116153
  const cliPath = (0, import_node_module.createRequire)(__filename).resolve("postject/dist/cli.js");
117206
- if ((0, import_node_fs30.existsSync)(cliPath)) {
116154
+ if ((0, import_node_fs28.existsSync)(cliPath)) {
117207
116155
  return { command: process.execPath, prefixArgs: [cliPath] };
117208
116156
  }
117209
116157
  } catch {
@@ -117274,26 +116222,26 @@ function buildSeaConfig(entryPath, blobPath) {
117274
116222
  }
117275
116223
  async function installWindowsNativeLauncher(options) {
117276
116224
  const nodeExe = options.nodeExe ?? process.execPath;
117277
- if (!(0, import_node_fs30.existsSync)(options.cliPath)) {
116225
+ if (!(0, import_node_fs28.existsSync)(options.cliPath)) {
117278
116226
  throw new Error(`cannot build okx-a2a.exe: CLI entry not found at ${options.cliPath}`);
117279
116227
  }
117280
- if (!(0, import_node_fs30.existsSync)(nodeExe)) {
116228
+ if (!(0, import_node_fs28.existsSync)(nodeExe)) {
117281
116229
  throw new Error(`cannot build okx-a2a.exe: node executable not found at ${nodeExe}`);
117282
116230
  }
117283
- const exePath = (0, import_node_path36.join)(options.targetDir, NATIVE_LAUNCHER_EXE_NAME);
117284
- (0, import_node_fs30.mkdirSync)(options.targetDir, { recursive: true });
117285
- const work = (0, import_node_fs30.mkdtempSync)((0, import_node_path36.join)((0, import_node_os13.tmpdir)(), "okx-a2a-sea-"));
116231
+ const exePath = (0, import_node_path35.join)(options.targetDir, NATIVE_LAUNCHER_EXE_NAME);
116232
+ (0, import_node_fs28.mkdirSync)(options.targetDir, { recursive: true });
116233
+ const work = (0, import_node_fs28.mkdtempSync)((0, import_node_path35.join)((0, import_node_os13.tmpdir)(), "okx-a2a-sea-"));
117286
116234
  try {
117287
- const entryPath = (0, import_node_path36.join)(work, "launcher-entry.js");
117288
- const blobPath = (0, import_node_path36.join)(work, "okx-a2a.blob");
117289
- const configPath = (0, import_node_path36.join)(work, "sea-config.json");
117290
- (0, import_node_fs30.writeFileSync)(entryPath, buildLauncherEntryJs(options.cliPath), "utf8");
117291
- (0, import_node_fs30.writeFileSync)(configPath, buildSeaConfig(entryPath, blobPath), "utf8");
116235
+ const entryPath = (0, import_node_path35.join)(work, "launcher-entry.js");
116236
+ const blobPath = (0, import_node_path35.join)(work, "okx-a2a.blob");
116237
+ const configPath = (0, import_node_path35.join)(work, "sea-config.json");
116238
+ (0, import_node_fs28.writeFileSync)(entryPath, buildLauncherEntryJs(options.cliPath), "utf8");
116239
+ (0, import_node_fs28.writeFileSync)(configPath, buildSeaConfig(entryPath, blobPath), "utf8");
117292
116240
  (0, import_node_child_process9.execFileSync)(nodeExe, ["--experimental-sea-config", configPath], {
117293
116241
  stdio: "ignore",
117294
116242
  windowsHide: true
117295
116243
  });
117296
- (0, import_node_fs30.copyFileSync)(nodeExe, exePath);
116244
+ (0, import_node_fs28.copyFileSync)(nodeExe, exePath);
117297
116245
  const isMac = process.platform === "darwin";
117298
116246
  if (isMac) {
117299
116247
  try {
@@ -117313,19 +116261,19 @@ async function installWindowsNativeLauncher(options) {
117313
116261
  );
117314
116262
  return { exePath, cliPath: options.cliPath, nodeExe };
117315
116263
  } finally {
117316
- (0, import_node_fs30.rmSync)(work, { recursive: true, force: true });
116264
+ (0, import_node_fs28.rmSync)(work, { recursive: true, force: true });
117317
116265
  }
117318
116266
  }
117319
- function findWindowsNativeOkxA2aExe(pathValue, appData, userProfile, fileExists2 = import_node_fs30.existsSync) {
116267
+ function findWindowsNativeOkxA2aExe(pathValue, appData, userProfile, fileExists2 = import_node_fs28.existsSync) {
117320
116268
  const dirs = pathValue.split(";").map((d) => d.trim()).filter(Boolean);
117321
116269
  if (appData) {
117322
- dirs.push((0, import_node_path36.join)(appData, "npm"));
116270
+ dirs.push((0, import_node_path35.join)(appData, "npm"));
117323
116271
  }
117324
116272
  if (userProfile) {
117325
- dirs.push((0, import_node_path36.join)(userProfile, ".local", "bin"));
116273
+ dirs.push((0, import_node_path35.join)(userProfile, ".local", "bin"));
117326
116274
  }
117327
116275
  for (const dir of dirs) {
117328
- const candidate = (0, import_node_path36.join)(dir, NATIVE_LAUNCHER_EXE_NAME);
116276
+ const candidate = (0, import_node_path35.join)(dir, NATIVE_LAUNCHER_EXE_NAME);
117329
116277
  if (fileExists2(candidate)) {
117330
116278
  return candidate;
117331
116279
  }
@@ -117334,11 +116282,11 @@ function findWindowsNativeOkxA2aExe(pathValue, appData, userProfile, fileExists2
117334
116282
  }
117335
116283
  function resolveRunningCliPath() {
117336
116284
  const fromArgv = process.argv[1];
117337
- if (fromArgv && /(?:^|[\\/])cli\.js$/.test(fromArgv) && (0, import_node_fs30.existsSync)(fromArgv)) {
116285
+ if (fromArgv && /(?:^|[\\/])cli\.js$/.test(fromArgv) && (0, import_node_fs28.existsSync)(fromArgv)) {
117338
116286
  return fromArgv;
117339
116287
  }
117340
- const beside = (0, import_node_path36.join)(__dirname, "cli.js");
117341
- if ((0, import_node_fs30.existsSync)(beside)) {
116288
+ const beside = (0, import_node_path35.join)(__dirname, "cli.js");
116289
+ if ((0, import_node_fs28.existsSync)(beside)) {
117342
116290
  return beside;
117343
116291
  }
117344
116292
  if (fromArgv) {
@@ -117356,19 +116304,19 @@ async function ensureWindowsNativeLauncher(options = {}) {
117356
116304
  if (existing) {
117357
116305
  return { exePath: existing, installed: false };
117358
116306
  }
117359
- const targetDir = env.APPDATA ? (0, import_node_path36.join)(env.APPDATA, "npm") : (0, import_node_path36.join)(env.USERPROFILE ?? (0, import_node_os13.homedir)(), ".local", "bin");
116307
+ const targetDir = env.APPDATA ? (0, import_node_path35.join)(env.APPDATA, "npm") : (0, import_node_path35.join)(env.USERPROFILE ?? (0, import_node_os13.homedir)(), ".local", "bin");
117360
116308
  const result = await installWindowsNativeLauncher({ cliPath: resolveRunningCliPath(), targetDir });
117361
116309
  return { exePath: result.exePath, installed: true };
117362
116310
  }
117363
- var import_node_child_process9, import_node_fs30, import_node_module, import_node_os13, import_node_path36, SEA_SENTINEL_FUSE, NATIVE_LAUNCHER_EXE_NAME, POSTJECT_SPEC, POSTJECT_BIN;
116311
+ var import_node_child_process9, import_node_fs28, import_node_module, import_node_os13, import_node_path35, SEA_SENTINEL_FUSE, NATIVE_LAUNCHER_EXE_NAME, POSTJECT_SPEC, POSTJECT_BIN;
117364
116312
  var init_win_native_launcher = __esm({
117365
116313
  "src/win-native-launcher.ts"() {
117366
116314
  "use strict";
117367
116315
  import_node_child_process9 = require("node:child_process");
117368
- import_node_fs30 = require("node:fs");
116316
+ import_node_fs28 = require("node:fs");
117369
116317
  import_node_module = require("node:module");
117370
116318
  import_node_os13 = require("node:os");
117371
- import_node_path36 = require("node:path");
116319
+ import_node_path35 = require("node:path");
117372
116320
  init_win_compat();
117373
116321
  init_win_spawn();
117374
116322
  SEA_SENTINEL_FUSE = "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2";
@@ -117507,7 +116455,7 @@ function buildProviderMismatchWarning(target, provider) {
117507
116455
  ].join("\n");
117508
116456
  }
117509
116457
  async function handleUpdateCommand(args) {
117510
- if (args.some(isHelpArg4)) {
116458
+ if (args.some(isHelpArg3)) {
117511
116459
  printUpdateUsage();
117512
116460
  return;
117513
116461
  }
@@ -117548,7 +116496,7 @@ function resolveUpdateTarget(target) {
117548
116496
  return detectGatewayInvocation() ?? "node";
117549
116497
  }
117550
116498
  async function handleSetupCommand(args) {
117551
- if (args.some(isHelpArg4)) {
116499
+ if (args.some(isHelpArg3)) {
117552
116500
  printSetupUsage();
117553
116501
  return;
117554
116502
  }
@@ -118110,7 +117058,7 @@ async function getCurrentNodeCliVersion() {
118110
117058
  return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
118111
117059
  }
118112
117060
  function getBundledNodeCliVersion() {
118113
- return true ? "0.2.11-beta-8fef2ef558-260901172338" : null;
117061
+ return true ? "0.2.11" : null;
118114
117062
  }
118115
117063
  function readConfiguredAiProvider() {
118116
117064
  const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
@@ -118295,17 +117243,17 @@ async function updateHermes(release, options) {
118295
117243
  assertNotRunningInsideGateway("hermes");
118296
117244
  }
118297
117245
  const spec = buildNpmPackageSpec("hermes", release);
118298
- const workDir = await (0, import_promises15.mkdtemp)((0, import_node_path37.join)((0, import_node_os14.tmpdir)(), `okx-a2a-${label}-hermes-`));
117246
+ const workDir = await (0, import_promises15.mkdtemp)((0, import_node_path36.join)((0, import_node_os14.tmpdir)(), `okx-a2a-${label}-hermes-`));
118299
117247
  try {
118300
117248
  console.log(`[${label}] downloading ${spec}`);
118301
117249
  const npmTarball = await npmPack(spec, workDir);
118302
- const npmPackageDir = (0, import_node_path37.join)(workDir, "npm-package");
117250
+ const npmPackageDir = (0, import_node_path36.join)(workDir, "npm-package");
118303
117251
  await runCommand("tar", ["-xzf", npmTarball, "-C", npmPackageDir], { ensureDir: npmPackageDir });
118304
- const pluginTarball = await findHermesPluginTarball((0, import_node_path37.join)(npmPackageDir, "package", "dist"));
118305
- const pluginDir = (0, import_node_path37.join)(workDir, "plugin");
117252
+ const pluginTarball = await findHermesPluginTarball((0, import_node_path36.join)(npmPackageDir, "package", "dist"));
117253
+ const pluginDir = (0, import_node_path36.join)(workDir, "plugin");
118306
117254
  await runCommand("tar", ["-xzf", pluginTarball, "-C", pluginDir], { ensureDir: pluginDir });
118307
117255
  const unpackedPluginDir = await findFirstDirectory(pluginDir);
118308
- const installer = (0, import_node_path37.join)(unpackedPluginDir, "scripts", "install-or-upgrade.sh");
117256
+ const installer = (0, import_node_path36.join)(unpackedPluginDir, "scripts", "install-or-upgrade.sh");
118309
117257
  console.log(`[${label}] running ${installer}`);
118310
117258
  await runCommand("bash", [installer, ...options.restart ? ["--restart"] : []], { cwd: unpackedPluginDir });
118311
117259
  await normalizeHermesOkxA2aPluginConfig();
@@ -118320,7 +117268,7 @@ async function updateHermes(release, options) {
118320
117268
  }
118321
117269
  }
118322
117270
  async function installGatewayPluginForDoctor(target) {
118323
- const release = isPrereleaseVersion("0.2.11-beta-8fef2ef558-260901172338") ? "beta" : "latest";
117271
+ const release = isPrereleaseVersion("0.2.11") ? "beta" : "latest";
118324
117272
  const insideTargetGateway = detectGatewayInvocation() === target;
118325
117273
  const options = {
118326
117274
  restart: !insideTargetGateway,
@@ -118371,7 +117319,7 @@ async function ensureHermesOkxA2aPluginConfig(configFile = resolveHermesConfigPa
118371
117319
  if (options.dryRun) {
118372
117320
  return true;
118373
117321
  }
118374
- await (0, import_promises15.mkdir)((0, import_node_path37.resolve)(configFile, ".."), { recursive: true });
117322
+ await (0, import_promises15.mkdir)((0, import_node_path36.resolve)(configFile, ".."), { recursive: true });
118375
117323
  await (0, import_promises15.writeFile)(configFile, "plugins:\n enabled:\n - okx-a2a\n");
118376
117324
  console.log(`[update] added Hermes plugins.enabled okx-a2a entry in ${configFile}`);
118377
117325
  return true;
@@ -118611,7 +117559,7 @@ function findFirstEnabledListItem(lines, startIndex, enabledIndent) {
118611
117559
  return null;
118612
117560
  }
118613
117561
  function resolveHermesConfigPath() {
118614
- return (0, import_node_path37.join)(process.env.HERMES_HOME ?? (0, import_node_path37.join)((0, import_node_os14.homedir)(), ".hermes"), "config.yaml");
117562
+ return (0, import_node_path36.join)(process.env.HERMES_HOME ?? (0, import_node_path36.join)((0, import_node_os14.homedir)(), ".hermes"), "config.yaml");
118615
117563
  }
118616
117564
  function lineIndent(line) {
118617
117565
  const match = line.match(/^\s*/);
@@ -118689,13 +117637,13 @@ async function assertGatewayPluginInstalled(target) {
118689
117637
  );
118690
117638
  }
118691
117639
  function resolveHermesPluginYamlPath() {
118692
- return (0, import_node_path37.join)(process.env.HERMES_HOME ?? (0, import_node_path37.join)((0, import_node_os14.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
117640
+ return (0, import_node_path36.join)(process.env.HERMES_HOME ?? (0, import_node_path36.join)((0, import_node_os14.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
118693
117641
  }
118694
117642
  async function isGatewayPluginInstalled(target) {
118695
117643
  if (target === "openclaw") {
118696
117644
  return (await getInstalledOpenClawPluginInfo()).installed;
118697
117645
  }
118698
- return (0, import_node_fs31.existsSync)(resolveHermesPluginYamlPath());
117646
+ return (0, import_node_fs29.existsSync)(resolveHermesPluginYamlPath());
118699
117647
  }
118700
117648
  async function getInstalledGatewayPluginVersion(target) {
118701
117649
  if (target === "hermes") {
@@ -118782,7 +117730,7 @@ function parsePackageVersionFromText(output5) {
118782
117730
  return output5.match(/@okxweb3\/a2a-openclaw@([0-9A-Za-z.+-]+)/)?.[1] ?? null;
118783
117731
  }
118784
117732
  async function getInstalledHermesPluginVersion() {
118785
- const pluginYaml = (0, import_node_path37.join)(process.env.HERMES_HOME ?? (0, import_node_path37.join)((0, import_node_os14.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
117733
+ const pluginYaml = (0, import_node_path36.join)(process.env.HERMES_HOME ?? (0, import_node_path36.join)((0, import_node_os14.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
118786
117734
  try {
118787
117735
  const content2 = await (0, import_promises15.readFile)(pluginYaml, "utf8");
118788
117736
  return parsePluginYamlVersion(content2);
@@ -118840,7 +117788,7 @@ async function npmPack(spec, destination) {
118840
117788
  if (!tarballName) {
118841
117789
  throw new Error(`Unable to detect npm pack tarball from output: ${output5.trim()}`);
118842
117790
  }
118843
- return (0, import_node_path37.resolve)(destination, (0, import_node_path37.basename)(tarballName));
117791
+ return (0, import_node_path36.resolve)(destination, (0, import_node_path36.basename)(tarballName));
118844
117792
  }
118845
117793
  async function findHermesPluginTarball(distDir) {
118846
117794
  const entries = await (0, import_promises15.readdir)(distDir);
@@ -118848,7 +117796,7 @@ async function findHermesPluginTarball(distDir) {
118848
117796
  if (!tarball) {
118849
117797
  throw new Error(`Hermes npm package did not contain dist/okx-a2a-hermes-plugin-*.tar.gz`);
118850
117798
  }
118851
- return (0, import_node_path37.join)(distDir, tarball);
117799
+ return (0, import_node_path36.join)(distDir, tarball);
118852
117800
  }
118853
117801
  async function findFirstDirectory(parent) {
118854
117802
  const entries = await (0, import_promises15.readdir)(parent, { withFileTypes: true });
@@ -118856,7 +117804,7 @@ async function findFirstDirectory(parent) {
118856
117804
  if (!dir) {
118857
117805
  throw new Error(`No unpacked plugin directory found under ${parent}`);
118858
117806
  }
118859
- return (0, import_node_path37.join)(parent, dir.name);
117807
+ return (0, import_node_path36.join)(parent, dir.name);
118860
117808
  }
118861
117809
  function readOption4(args, name) {
118862
117810
  const index2 = args.indexOf(name);
@@ -118868,7 +117816,7 @@ function readOption4(args, name) {
118868
117816
  function hasFlag(args, name) {
118869
117817
  return args.includes(name);
118870
117818
  }
118871
- function isHelpArg4(value) {
117819
+ function isHelpArg3(value) {
118872
117820
  return value === "-h" || value === "--help" || value === "help";
118873
117821
  }
118874
117822
  function isSupportedRelease(value) {
@@ -119077,15 +118025,15 @@ function buildExternalCommandInvocation(command, args, platform = process.platfo
119077
118025
  function formatExternalCommand(command, args) {
119078
118026
  return [command, ...args].join(" ");
119079
118027
  }
119080
- var import_node_child_process10, import_node_fs31, import_promises15, import_node_os14, import_node_path37, UPDATE_PACKAGES, CODEX_NPM_PACKAGE, OPENCLAW_FORCE_INSTALL_FLAG, OPENCLAW_UNSAFE_INSTALL_FLAG, OKX_A2A_PLUGIN_ID, OPENCLAW_SESSION_DM_SCOPE_CONFIG_PATH, OPENCLAW_SESSION_DM_SCOPE_CONFIG_VALUE, OPENCLAW_PLUGIN_ALLOW_CONFIG_PATH, OPENCLAW_OKX_A2A_CONVERSATION_HOOK_ACCESS_CONFIG_PATH, DEFAULT_AI_PROVIDER_LOGIN_TIMEOUT_MS, PROVIDER_CLI_AUTH_PROBE_TIMEOUT_MS, SetupBlockedError, redirectCommandStdoutToStderr;
118028
+ var import_node_child_process10, import_node_fs29, import_promises15, import_node_os14, import_node_path36, UPDATE_PACKAGES, CODEX_NPM_PACKAGE, OPENCLAW_FORCE_INSTALL_FLAG, OPENCLAW_UNSAFE_INSTALL_FLAG, OKX_A2A_PLUGIN_ID, OPENCLAW_SESSION_DM_SCOPE_CONFIG_PATH, OPENCLAW_SESSION_DM_SCOPE_CONFIG_VALUE, OPENCLAW_PLUGIN_ALLOW_CONFIG_PATH, OPENCLAW_OKX_A2A_CONVERSATION_HOOK_ACCESS_CONFIG_PATH, DEFAULT_AI_PROVIDER_LOGIN_TIMEOUT_MS, PROVIDER_CLI_AUTH_PROBE_TIMEOUT_MS, SetupBlockedError, redirectCommandStdoutToStderr;
119081
118029
  var init_update_cli = __esm({
119082
118030
  "src/update-cli.ts"() {
119083
118031
  "use strict";
119084
118032
  import_node_child_process10 = require("node:child_process");
119085
- import_node_fs31 = require("node:fs");
118033
+ import_node_fs29 = require("node:fs");
119086
118034
  import_promises15 = require("node:fs/promises");
119087
118035
  import_node_os14 = require("node:os");
119088
- import_node_path37 = require("node:path");
118036
+ import_node_path36 = require("node:path");
119089
118037
  init_ai_command();
119090
118038
  init_win_spawn();
119091
118039
  init_ai_provider();
@@ -119373,7 +118321,7 @@ async function runDoctor(options = {}) {
119373
118321
  platform: options.platform ?? process.platform,
119374
118322
  env: options.env ?? process.env,
119375
118323
  target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
119376
- cliVersion: options.cliVersion ?? (true ? "0.2.11-beta-8fef2ef558-260901172338" : "0.0.0"),
118324
+ cliVersion: options.cliVersion ?? (true ? "0.2.11" : "0.0.0"),
119377
118325
  fixMode: options.fix === true,
119378
118326
  nonInteractive: options.nonInteractive === true,
119379
118327
  packageChanged: false,
@@ -119581,11 +118529,11 @@ async function writeStdoutAndExit(output5, code) {
119581
118529
  });
119582
118530
  process.exit(code);
119583
118531
  }
119584
- var import_node_path38, DOCTOR_MIN_NODE_VERSION, DOCTOR_DAEMON_READY_TIMEOUT_MS, DOCTOR_DAEMON_WAIT_HEARTBEAT_MS, NODE_PACKAGE_SPEC, CODEX_INSTALL_SPEC, CLAUDE_INSTALL_SPEC, nodeVersionChecker, npmChecker, cliVersionChecker, windowsNativeLauncherChecker, providerBindingChecker, providerCliChecker, gatewayPluginChecker, gatewayConfigChecker, daemonChecker, agentRefreshChecker, gatewayReachableChecker, autostartChecker, CHECKERS, STATUS_MARK;
118532
+ var import_node_path37, DOCTOR_MIN_NODE_VERSION, DOCTOR_DAEMON_READY_TIMEOUT_MS, DOCTOR_DAEMON_WAIT_HEARTBEAT_MS, NODE_PACKAGE_SPEC, CODEX_INSTALL_SPEC, CLAUDE_INSTALL_SPEC, nodeVersionChecker, npmChecker, cliVersionChecker, windowsNativeLauncherChecker, providerBindingChecker, providerCliChecker, gatewayPluginChecker, gatewayConfigChecker, daemonChecker, agentRefreshChecker, gatewayReachableChecker, autostartChecker, CHECKERS, STATUS_MARK;
119585
118533
  var init_doctor_cli = __esm({
119586
118534
  "src/doctor-cli.ts"() {
119587
118535
  "use strict";
119588
- import_node_path38 = require("node:path");
118536
+ import_node_path37 = require("node:path");
119589
118537
  init_log();
119590
118538
  init_win_compat();
119591
118539
  init_ai_command();
@@ -119772,7 +118720,7 @@ var init_doctor_cli = __esm({
119772
118720
  command: "okx-a2a doctor --fix"
119773
118721
  },
119774
118722
  data: {
119775
- appDataNpm: ctx.env.APPDATA ? (0, import_node_path38.join)(ctx.env.APPDATA, "npm") : null
118723
+ appDataNpm: ctx.env.APPDATA ? (0, import_node_path37.join)(ctx.env.APPDATA, "npm") : null
119776
118724
  }
119777
118725
  };
119778
118726
  },
@@ -120380,9 +119328,9 @@ var init_doctor_cli = __esm({
120380
119328
  });
120381
119329
 
120382
119330
  // src/cli.ts
120383
- var import_node_fs32 = require("node:fs");
119331
+ var import_node_fs30 = require("node:fs");
120384
119332
  var import_node_os15 = require("node:os");
120385
- var import_node_path39 = require("node:path");
119333
+ var import_node_path38 = require("node:path");
120386
119334
  init_daemon();
120387
119335
  init_command_store();
120388
119336
  init_file_store();
@@ -120450,7 +119398,7 @@ init_sentry_config();
120450
119398
  init_runtime_metadata();
120451
119399
  var CURRENT_GATEWAY_SESSION_KEYS_ENV4 = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
120452
119400
  function printUsage3() {
120453
- console.log(`okx-a2a ${"0.2.11-beta-8fef2ef558-260901172338"}
119401
+ console.log(`okx-a2a ${"0.2.11"}
120454
119402
 
120455
119403
  Usage:
120456
119404
  okx-a2a <command> [options]
@@ -120480,8 +119428,6 @@ Commands:
120480
119428
  Alias for runtime switch-current
120481
119429
  job-provider Manage job-to-provider bindings
120482
119430
  xmtp-send Queue an XMTP message through the running daemon
120483
- trade-records
120484
- Insert, query, and soft-delete local business trade records
120485
119431
  capabilities Print machine-readable A2A capability negotiation status (used by OnchainOS)
120486
119432
 
120487
119433
  Global options:
@@ -120492,7 +119438,7 @@ Run \`okx-a2a <command> -h\` for command-specific help.
120492
119438
  `);
120493
119439
  }
120494
119440
  function printVersion() {
120495
- console.log("0.2.11-beta-8fef2ef558-260901172338");
119441
+ console.log("0.2.11");
120496
119442
  }
120497
119443
  function printDaemonUsage() {
120498
119444
  console.log(`Usage: okx-a2a daemon <start|restart|stop|status|autostart> [options]
@@ -120654,22 +119600,8 @@ function printCommandUsage(command) {
120654
119600
  printXmtpSendUsage();
120655
119601
  return true;
120656
119602
  }
120657
- if (command === "trade-records") {
120658
- printTradeRecordsUsageProxy();
120659
- return true;
120660
- }
120661
119603
  return false;
120662
119604
  }
120663
- function printTradeRecordsUsageProxy() {
120664
- console.log(`Usage: okx-a2a trade-records <insert|query|delete> [options]
120665
-
120666
- Commands:
120667
- insert Insert or replace trade records by deliveryId.
120668
- query Query active or soft-deleted trade records.
120669
- delete Soft-delete one trade record by deliveryId.
120670
-
120671
- Run \`okx-a2a trade-records <command> --help\` for command-specific help.`);
120672
- }
120673
119605
  function printUserUsageProxy() {
120674
119606
  console.log(`Usage: okx-a2a user <notify|decision-request|list|outdated-list|consume|check|watch>
120675
119607
 
@@ -120756,11 +119688,11 @@ Commands:
120756
119688
  Print setup status JSON to stdout. Installer logs are written to stderr.
120757
119689
  `);
120758
119690
  }
120759
- function isHelpArg5(value) {
119691
+ function isHelpArg4(value) {
120760
119692
  return value === "-h" || value === "--help" || value === "help";
120761
119693
  }
120762
119694
  function hasHelpFlag5(args) {
120763
- return args.some(isHelpArg5);
119695
+ return args.some(isHelpArg4);
120764
119696
  }
120765
119697
  function isVersionArg(value) {
120766
119698
  return value === "-v" || value === "--version" || value === "version";
@@ -120787,14 +119719,14 @@ function maybeRedirectDaemonSelfLog() {
120787
119719
  }
120788
119720
  try {
120789
119721
  const logPath = resolveTaskPaths().listenerLogPath;
120790
- (0, import_node_fs32.mkdirSync)((0, import_node_path39.join)(logPath, ".."), { recursive: true });
120791
- const fd = (0, import_node_fs32.openSync)(logPath, "a");
119722
+ (0, import_node_fs30.mkdirSync)((0, import_node_path38.join)(logPath, ".."), { recursive: true });
119723
+ const fd = (0, import_node_fs30.openSync)(logPath, "a");
120792
119724
  const writeToLog = ((chunk, encoding, cb) => {
120793
119725
  try {
120794
119726
  if (typeof chunk === "string") {
120795
- (0, import_node_fs32.writeSync)(fd, chunk);
119727
+ (0, import_node_fs30.writeSync)(fd, chunk);
120796
119728
  } else {
120797
- (0, import_node_fs32.writeSync)(fd, chunk);
119729
+ (0, import_node_fs30.writeSync)(fd, chunk);
120798
119730
  }
120799
119731
  } catch {
120800
119732
  }
@@ -120884,7 +119816,7 @@ async function handleLogs(args) {
120884
119816
  return;
120885
119817
  }
120886
119818
  if (subcommand === "llm") {
120887
- await tailLogFile((0, import_node_path39.join)(paths.logsDir, "llm.log"), parseLogsTailArgs(args.slice(1), subcommand));
119819
+ await tailLogFile((0, import_node_path38.join)(paths.logsDir, "llm.log"), parseLogsTailArgs(args.slice(1), subcommand));
120888
119820
  return;
120889
119821
  }
120890
119822
  throw new Error("logs requires <server|llm|export>");
@@ -121150,12 +120082,12 @@ async function queueXmtpDaemonCommand(args, type) {
121150
120082
  }
121151
120083
  async function handleTaskCommand(args) {
121152
120084
  const subcommand = args[0];
121153
- if (!subcommand || args.every(isHelpArg5)) {
120085
+ if (!subcommand || args.every(isHelpArg4)) {
121154
120086
  printTaskUsage();
121155
120087
  return;
121156
120088
  }
121157
120089
  if (subcommand === "help") {
121158
- const helpTarget = args.slice(1).find((arg) => !isHelpArg5(arg));
120090
+ const helpTarget = args.slice(1).find((arg) => !isHelpArg4(arg));
121159
120091
  if (!helpTarget) {
121160
120092
  printTaskUsage();
121161
120093
  return;
@@ -121843,11 +120775,11 @@ async function initDirectCliSentry() {
121843
120775
  }
121844
120776
  cliSentryInitAttempted = true;
121845
120777
  try {
121846
- const configPath = (0, import_node_path39.join)(resolveTaskHomeForSentryConfig(), "xmtp", "system-config.json");
121847
- if (!(0, import_node_fs32.existsSync)(configPath)) {
120778
+ const configPath = (0, import_node_path38.join)(resolveTaskHomeForSentryConfig(), "xmtp", "system-config.json");
120779
+ if (!(0, import_node_fs30.existsSync)(configPath)) {
121848
120780
  return;
121849
120781
  }
121850
- const config = JSON.parse((0, import_node_fs32.readFileSync)(configPath, "utf8"));
120782
+ const config = JSON.parse((0, import_node_fs30.readFileSync)(configPath, "utf8"));
121851
120783
  if (typeof config.sentryDsn !== "string" || !config.sentryDsn) {
121852
120784
  return;
121853
120785
  }
@@ -121872,11 +120804,11 @@ function resolveTaskHomeForSentryConfig() {
121872
120804
  try {
121873
120805
  const home = (0, import_node_os15.homedir)();
121874
120806
  if (home) {
121875
- return (0, import_node_path39.join)(home, ".okx-agent-task");
120807
+ return (0, import_node_path38.join)(home, ".okx-agent-task");
121876
120808
  }
121877
120809
  } catch {
121878
120810
  }
121879
- return (0, import_node_path39.resolve)(process.cwd(), ".okx-agent-task");
120811
+ return (0, import_node_path38.resolve)(process.cwd(), ".okx-agent-task");
121880
120812
  }
121881
120813
  function directCliSentryExtra(operation, extra = {}) {
121882
120814
  return {
@@ -121909,7 +120841,7 @@ async function main() {
121909
120841
  assertSupportedNodeVersion();
121910
120842
  }
121911
120843
  const args = process.argv.slice(3);
121912
- if (isHelpArg5(command)) {
120844
+ if (isHelpArg4(command)) {
121913
120845
  printUsage3();
121914
120846
  return;
121915
120847
  }
@@ -121925,11 +120857,6 @@ async function main() {
121925
120857
  handleCapabilitiesCommand2(process.argv.slice(3));
121926
120858
  return;
121927
120859
  }
121928
- if (command === "trade-records") {
121929
- const { handleTradeRecordsCommand: handleTradeRecordsCommand2 } = await Promise.resolve().then(() => (init_trade_records_cli(), trade_records_cli_exports));
121930
- await handleTradeRecordsCommand2(args);
121931
- return;
121932
- }
121933
120860
  if (command === "daemon") {
121934
120861
  if (hasHelpFlag5(args)) {
121935
120862
  printDaemonUsage();
@@ -121989,7 +120916,7 @@ async function main() {
121989
120916
  if (command === "xmtp-test") {
121990
120917
  const { handleXmtpTestCommand: handleXmtpTestCommand2 } = await Promise.resolve().then(() => (init_xmtp_test_cli(), xmtp_test_cli_exports));
121991
120918
  await handleXmtpTestCommand2(process.argv.slice(3), {
121992
- packageVersion: "0.2.11-beta-8fef2ef558-260901172338",
120919
+ packageVersion: "0.2.11",
121993
120920
  agentSdkVersion: "2.3.0",
121994
120921
  nodeSdkVersion: "6.1.0",
121995
120922
  nodeBindingsVersion: "1.11.0"
@@ -122094,13 +121021,10 @@ function shouldDeferHelpToNestedHandler(command, args) {
122094
121021
  if (command === "xmtp-test") {
122095
121022
  return true;
122096
121023
  }
122097
- if (command === "trade-records") {
122098
- return args.some((arg) => !isHelpArg5(arg));
122099
- }
122100
121024
  if (command !== "session" && command !== "user" && command !== "task") {
122101
121025
  return false;
122102
121026
  }
122103
- return args.some((arg) => !isHelpArg5(arg));
121027
+ return args.some((arg) => !isHelpArg4(arg));
122104
121028
  }
122105
121029
  main().then(() => {
122106
121030
  if (cliSentryFlushTimedOut) {