claudemesh-cli 1.33.0 → 1.34.0

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.
@@ -104,7 +104,7 @@ __export(exports_urls, {
104
104
  VERSION: () => VERSION,
105
105
  URLS: () => URLS
106
106
  });
107
- var URLS, VERSION = "1.33.0", env;
107
+ var URLS, VERSION = "1.34.0", env;
108
108
  var init_urls = __esm(() => {
109
109
  URLS = {
110
110
  BROKER: process.env.CLAUDEMESH_BROKER_URL ?? "wss://ic.claudemesh.com/ws",
@@ -4019,6 +4019,7 @@ __export(exports_daemon_route, {
4019
4019
  tryListStateViaDaemon: () => tryListStateViaDaemon,
4020
4020
  tryListSkillsViaDaemon: () => tryListSkillsViaDaemon,
4021
4021
  tryListPeersViaDaemon: () => tryListPeersViaDaemon,
4022
+ tryListInboxViaDaemon: () => tryListInboxViaDaemon,
4022
4023
  tryGetStateViaDaemon: () => tryGetStateViaDaemon,
4023
4024
  tryGetSkillViaDaemon: () => tryGetSkillViaDaemon,
4024
4025
  tryForgetViaDaemon: () => tryForgetViaDaemon
@@ -4049,6 +4050,22 @@ async function tryListPeersViaDaemon(mesh) {
4049
4050
  return null;
4050
4051
  }
4051
4052
  }
4053
+ async function tryListInboxViaDaemon(mesh, limit = 100) {
4054
+ if (!await daemonReachable())
4055
+ return null;
4056
+ try {
4057
+ const path = `/v1/inbox${meshQuery(mesh)}${meshQuery(mesh) ? "&" : "?"}limit=${limit}`;
4058
+ const res = await ipc({ path, timeoutMs: 3000 });
4059
+ if (res.status !== 200)
4060
+ return null;
4061
+ return Array.isArray(res.body.items) ? res.body.items : [];
4062
+ } catch (err) {
4063
+ const msg = String(err);
4064
+ if (/ENOENT|ECONNREFUSED|ipc_timeout/.test(msg))
4065
+ return null;
4066
+ return null;
4067
+ }
4068
+ }
4052
4069
  async function tryListSkillsViaDaemon(mesh) {
4053
4070
  if (!await daemonReachable())
4054
4071
  return null;
@@ -8227,38 +8244,47 @@ var exports_inbox = {};
8227
8244
  __export(exports_inbox, {
8228
8245
  runInbox: () => runInbox
8229
8246
  });
8230
- function formatMessage(msg) {
8231
- const text = msg.plaintext ?? `[encrypted: ${msg.ciphertext.slice(0, 32)}…]`;
8232
- const from = msg.senderPubkey.slice(0, 8);
8233
- const time = new Date(msg.createdAt).toLocaleTimeString();
8234
- const kindTag = msg.kind === "direct" ? "→ direct" : msg.kind;
8235
- return ` ${bold(from)} ${dim(`[${kindTag}] ${time}`)}
8247
+ function formatMessage(msg, includeMesh) {
8248
+ const text = msg.body ?? "[encrypted]";
8249
+ const from = msg.sender_name && msg.sender_name !== msg.sender_pubkey.slice(0, 8) ? `${msg.sender_name} (${msg.sender_pubkey.slice(0, 8)})` : msg.sender_pubkey.slice(0, 8);
8250
+ const time = new Date(msg.received_at).toLocaleTimeString();
8251
+ const topicTag = msg.topic ? ` (#${msg.topic})` : "";
8252
+ const meshTag = includeMesh ? ` [${msg.mesh}]` : "";
8253
+ return ` ${bold(from)} ${dim(`${meshTag}${topicTag} ${time}`)}
8236
8254
  ${text}`;
8237
8255
  }
8238
8256
  async function runInbox(flags) {
8239
- const waitMs = (flags.wait ?? 1) * 1000;
8240
- await withMesh({ meshSlug: flags.mesh ?? null }, async (client, mesh) => {
8241
- await new Promise((resolve) => setTimeout(resolve, waitMs));
8242
- const messages = client.drainPushBuffer();
8257
+ const meshSlug = flags.mesh;
8258
+ const items = await tryListInboxViaDaemon(meshSlug, flags.limit ?? 100);
8259
+ if (items === null) {
8243
8260
  if (flags.json) {
8244
- process.stdout.write(JSON.stringify(messages, null, 2) + `
8261
+ process.stdout.write(`[]
8245
8262
  `);
8246
8263
  return;
8247
8264
  }
8248
- if (messages.length === 0) {
8249
- render.info(dim(`No messages on mesh "${mesh.slug}".`));
8250
- return;
8251
- }
8252
- render.section(`inbox — ${mesh.slug} (${messages.length} message${messages.length === 1 ? "" : "s"})`);
8253
- for (const msg of messages) {
8254
- process.stdout.write(formatMessage(msg) + `
8265
+ render.info(dim("Daemon not reachable. Run `claudemesh daemon up` and retry."));
8266
+ return;
8267
+ }
8268
+ if (flags.json) {
8269
+ process.stdout.write(JSON.stringify(items, null, 2) + `
8270
+ `);
8271
+ return;
8272
+ }
8273
+ if (items.length === 0) {
8274
+ const scope = meshSlug ? `mesh "${meshSlug}"` : "any mesh";
8275
+ render.info(dim(`No messages on ${scope}.`));
8276
+ return;
8277
+ }
8278
+ const heading = meshSlug ? `inbox — ${meshSlug} (${items.length} message${items.length === 1 ? "" : "s"})` : `inbox (${items.length} message${items.length === 1 ? "" : "s"})`;
8279
+ render.section(heading);
8280
+ for (const msg of items) {
8281
+ process.stdout.write(formatMessage(msg, !meshSlug) + `
8255
8282
 
8256
8283
  `);
8257
- }
8258
- });
8284
+ }
8259
8285
  }
8260
8286
  var init_inbox = __esm(() => {
8261
- init_connect();
8287
+ init_daemon_route();
8262
8288
  init_render();
8263
8289
  init_styles();
8264
8290
  });
@@ -9149,6 +9175,9 @@ function migrateOutbox(db) {
9149
9175
  db.exec(`ALTER TABLE outbox ADD COLUMN ciphertext TEXT`);
9150
9176
  if (!hasPriority)
9151
9177
  db.exec(`ALTER TABLE outbox ADD COLUMN priority TEXT`);
9178
+ const hasSenderSessionPk = columnExists(db, "outbox", "sender_session_pubkey");
9179
+ if (!hasSenderSessionPk)
9180
+ db.exec(`ALTER TABLE outbox ADD COLUMN sender_session_pubkey TEXT`);
9152
9181
  }
9153
9182
  function columnExists(db, table, column) {
9154
9183
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
@@ -9159,7 +9188,8 @@ function findByClientId(db, clientMessageId) {
9159
9188
  SELECT id, client_message_id, request_fingerprint, payload, enqueued_at,
9160
9189
  attempts, next_attempt_at, status, last_error, delivered_at,
9161
9190
  broker_message_id, aborted_at, aborted_by, superseded_by,
9162
- mesh, target_spec, nonce, ciphertext, priority
9191
+ mesh, target_spec, nonce, ciphertext, priority,
9192
+ sender_session_pubkey
9163
9193
  FROM outbox WHERE client_message_id = ?
9164
9194
  `).get(clientMessageId);
9165
9195
  return row ?? null;
@@ -9169,9 +9199,10 @@ function insertPending(db, input) {
9169
9199
  INSERT INTO outbox (
9170
9200
  id, client_message_id, request_fingerprint, payload,
9171
9201
  enqueued_at, attempts, next_attempt_at, status,
9172
- mesh, target_spec, nonce, ciphertext, priority
9173
- ) VALUES (?, ?, ?, ?, ?, 0, ?, 'pending', ?, ?, ?, ?, ?)
9174
- `).run(input.id, input.client_message_id, input.request_fingerprint, input.payload, input.now, input.now, input.mesh ?? null, input.target_spec ?? null, input.nonce ?? null, input.ciphertext ?? null, input.priority ?? null);
9202
+ mesh, target_spec, nonce, ciphertext, priority,
9203
+ sender_session_pubkey
9204
+ ) VALUES (?, ?, ?, ?, ?, 0, ?, 'pending', ?, ?, ?, ?, ?, ?)
9205
+ `).run(input.id, input.client_message_id, input.request_fingerprint, input.payload, input.now, input.now, input.mesh ?? null, input.target_spec ?? null, input.nonce ?? null, input.ciphertext ?? null, input.priority ?? null, input.sender_session_pubkey ?? null);
9175
9206
  }
9176
9207
  function fingerprintsEqual(a, b) {
9177
9208
  if (a.length !== b.length)
@@ -9192,7 +9223,8 @@ function listOutbox(db, p = {}) {
9192
9223
  SELECT id, client_message_id, request_fingerprint, payload, enqueued_at,
9193
9224
  attempts, next_attempt_at, status, last_error, delivered_at,
9194
9225
  broker_message_id, aborted_at, aborted_by, superseded_by,
9195
- mesh, target_spec, nonce, ciphertext, priority
9226
+ mesh, target_spec, nonce, ciphertext, priority,
9227
+ sender_session_pubkey
9196
9228
  FROM outbox
9197
9229
  ${where.length ? "WHERE " + where.join(" AND ") : ""}
9198
9230
  ORDER BY enqueued_at DESC
@@ -9206,7 +9238,8 @@ function findById(db, id) {
9206
9238
  SELECT id, client_message_id, request_fingerprint, payload, enqueued_at,
9207
9239
  attempts, next_attempt_at, status, last_error, delivered_at,
9208
9240
  broker_message_id, aborted_at, aborted_by, superseded_by,
9209
- mesh, target_spec, nonce, ciphertext, priority
9241
+ mesh, target_spec, nonce, ciphertext, priority,
9242
+ sender_session_pubkey
9210
9243
  FROM outbox WHERE id = ?
9211
9244
  `).get(id) ?? null;
9212
9245
  }
@@ -9354,7 +9387,8 @@ function acceptSend(req, deps) {
9354
9387
  target_spec: req.target_spec,
9355
9388
  nonce: req.nonce,
9356
9389
  ciphertext: req.ciphertext,
9357
- priority: req.priority
9390
+ priority: req.priority,
9391
+ sender_session_pubkey: req.sender_session_pubkey
9358
9392
  });
9359
9393
  return { kind: "accepted_pending", status: 202, client_message_id: clientId };
9360
9394
  }
@@ -9453,6 +9487,10 @@ function listInbox(db, p) {
9453
9487
  where.push("sender_pubkey = ?");
9454
9488
  args.push(p.fromPubkey);
9455
9489
  }
9490
+ if (p.mesh !== undefined) {
9491
+ where.push("mesh = ?");
9492
+ args.push(p.mesh);
9493
+ }
9456
9494
  const sql = `
9457
9495
  SELECT id, client_message_id, broker_message_id, mesh, topic,
9458
9496
  sender_pubkey, sender_name, body, meta, received_at, reply_to_id
@@ -10204,10 +10242,12 @@ function makeHandler(opts) {
10204
10242
  const fromPubkey = url.searchParams.get("from") ?? undefined;
10205
10243
  const limitRaw = url.searchParams.get("limit");
10206
10244
  const limit = limitRaw ? Number.parseInt(limitRaw, 10) : undefined;
10245
+ const meshFilter = meshFromCtx(url.searchParams.get("mesh")) ?? undefined;
10207
10246
  const rows = listInbox(opts.inboxDb, {
10208
10247
  since: Number.isFinite(since) ? since : undefined,
10209
10248
  topic,
10210
10249
  fromPubkey,
10250
+ ...meshFilter ? { mesh: meshFilter } : {},
10211
10251
  limit: Number.isFinite(limit ?? NaN) ? limit : undefined
10212
10252
  });
10213
10253
  respond(res, 200, {
@@ -10324,12 +10364,17 @@ function makeHandler(opts) {
10324
10364
  respond(res, 404, { error: "mesh_not_attached", mesh: chosenSlug });
10325
10365
  return;
10326
10366
  }
10367
+ const senderSessionPubkey = session?.presence?.sessionPubkey;
10368
+ const senderSecretKey = session?.presence?.sessionSecretKey ?? meshCfg.secretKey;
10327
10369
  try {
10328
- const routed = await resolveAndEncrypt(parsed.req, broker, meshCfg.secretKey, chosenSlug);
10370
+ const routed = await resolveAndEncrypt(parsed.req, broker, senderSecretKey, chosenSlug);
10329
10371
  parsed.req.target_spec = routed.target_spec;
10330
10372
  parsed.req.ciphertext = routed.ciphertext;
10331
10373
  parsed.req.nonce = routed.nonce;
10332
10374
  parsed.req.mesh = routed.mesh;
10375
+ if (senderSessionPubkey) {
10376
+ parsed.req.sender_session_pubkey = senderSessionPubkey;
10377
+ }
10333
10378
  } catch (e) {
10334
10379
  respond(res, 502, { error: "route_failed", detail: String(e) });
10335
10380
  return;
@@ -11063,6 +11108,9 @@ var init_broker = __esm(() => {
11063
11108
 
11064
11109
  // src/daemon/session-broker.ts
11065
11110
  import { hostname as osHostname } from "node:os";
11111
+ function classifyPermanent2(error2) {
11112
+ return /unknown|invalid|forbidden|not_authorized|target_not_found/i.test(error2);
11113
+ }
11066
11114
 
11067
11115
  class SessionBrokerClient {
11068
11116
  opts;
@@ -11070,6 +11118,8 @@ class SessionBrokerClient {
11070
11118
  _status = "closed";
11071
11119
  closed = false;
11072
11120
  brokerUnsupported = false;
11121
+ pendingAcks = new Map;
11122
+ opens = [];
11073
11123
  constructor(opts) {
11074
11124
  this.opts = opts;
11075
11125
  }
@@ -11134,6 +11184,20 @@ class SessionBrokerClient {
11134
11184
  }
11135
11185
  return;
11136
11186
  }
11187
+ if (msg.type === "ack") {
11188
+ const id = String(msg.id ?? "");
11189
+ const ack = this.pendingAcks.get(id);
11190
+ if (ack) {
11191
+ this.pendingAcks.delete(id);
11192
+ clearTimeout(ack.timer);
11193
+ if (typeof msg.error === "string" && msg.error.length > 0) {
11194
+ ack.resolve({ ok: false, error: msg.error, permanent: classifyPermanent2(msg.error) });
11195
+ } else {
11196
+ ack.resolve({ ok: true, messageId: String(msg.messageId ?? id) });
11197
+ }
11198
+ }
11199
+ return;
11200
+ }
11137
11201
  if (msg.type === "push" || msg.type === "inbound") {
11138
11202
  this.opts.onPush?.(msg);
11139
11203
  return;
@@ -11142,6 +11206,19 @@ class SessionBrokerClient {
11142
11206
  onStatusChange: (s) => {
11143
11207
  this._status = s;
11144
11208
  this.opts.onStatusChange?.(s);
11209
+ if (s === "open") {
11210
+ const queued = this.opens.slice();
11211
+ this.opens.length = 0;
11212
+ for (const fn of queued) {
11213
+ try {
11214
+ fn();
11215
+ } catch (e) {
11216
+ this.log("warn", "session_open_handler_failed", { err: String(e) });
11217
+ }
11218
+ }
11219
+ } else if (s === "closed" || s === "reconnecting") {
11220
+ this.failPendingAcks(`session_ws_${s}`);
11221
+ }
11145
11222
  },
11146
11223
  log: (level, msg, meta) => this.log(level, `session_broker_${msg}`, meta)
11147
11224
  });
@@ -11157,6 +11234,57 @@ class SessionBrokerClient {
11157
11234
  });
11158
11235
  } catch {}
11159
11236
  }
11237
+ isOpen() {
11238
+ const sock = this.lifecycle?.ws;
11239
+ return !!sock && sock.readyState === sock.OPEN;
11240
+ }
11241
+ send(req) {
11242
+ return new Promise((resolve) => {
11243
+ const dispatch = () => {
11244
+ if (!this.isOpen() || !this.lifecycle) {
11245
+ resolve({ ok: false, error: "session_ws_not_open", permanent: false });
11246
+ return;
11247
+ }
11248
+ const id = req.client_message_id;
11249
+ const timer = setTimeout(() => {
11250
+ if (this.pendingAcks.delete(id)) {
11251
+ resolve({ ok: false, error: "ack_timeout", permanent: false });
11252
+ }
11253
+ }, SEND_ACK_TIMEOUT_MS2);
11254
+ this.pendingAcks.set(id, { resolve, timer });
11255
+ try {
11256
+ this.lifecycle.send({
11257
+ type: "send",
11258
+ id,
11259
+ client_message_id: id,
11260
+ request_fingerprint: req.request_fingerprint_hex,
11261
+ targetSpec: req.targetSpec,
11262
+ priority: req.priority,
11263
+ nonce: req.nonce,
11264
+ ciphertext: req.ciphertext
11265
+ });
11266
+ } catch (e) {
11267
+ this.pendingAcks.delete(id);
11268
+ clearTimeout(timer);
11269
+ resolve({ ok: false, error: `ws_write_failed: ${String(e)}`, permanent: false });
11270
+ }
11271
+ };
11272
+ if (this._status === "open")
11273
+ dispatch();
11274
+ else
11275
+ this.opens.push(dispatch);
11276
+ });
11277
+ }
11278
+ failPendingAcks(reason) {
11279
+ if (this.pendingAcks.size === 0)
11280
+ return;
11281
+ const entries = [...this.pendingAcks.entries()];
11282
+ this.pendingAcks.clear();
11283
+ for (const [, ack] of entries) {
11284
+ clearTimeout(ack.timer);
11285
+ ack.resolve({ ok: false, error: reason, permanent: false });
11286
+ }
11287
+ }
11160
11288
  async close() {
11161
11289
  this.closed = true;
11162
11290
  if (this.lifecycle) {
@@ -11180,6 +11308,7 @@ function defaultLog3(level, msg, meta) {
11180
11308
  process.stderr.write(line + `
11181
11309
  `);
11182
11310
  }
11311
+ var SEND_ACK_TIMEOUT_MS2 = 15000;
11183
11312
  var init_session_broker = __esm(() => {
11184
11313
  init_session_hello_sig();
11185
11314
  init_ws_lifecycle();
@@ -11229,7 +11358,8 @@ async function drainOnce(opts, log2) {
11229
11358
  const now = Date.now();
11230
11359
  const rows = opts.db.prepare(`
11231
11360
  SELECT id, client_message_id, request_fingerprint, payload, attempts,
11232
- target_spec, nonce, ciphertext, priority, mesh
11361
+ target_spec, nonce, ciphertext, priority, mesh,
11362
+ sender_session_pubkey
11233
11363
  FROM outbox
11234
11364
  WHERE status = 'pending' AND next_attempt_at <= ?
11235
11365
  ORDER BY enqueued_at
@@ -11241,17 +11371,21 @@ async function drainOnce(opts, log2) {
11241
11371
  if (markInflight(opts.db, row.id, now) === 0)
11242
11372
  continue;
11243
11373
  const fpHex = bufferToHex(row.request_fingerprint);
11244
- let broker;
11374
+ let daemonBroker;
11245
11375
  if (row.mesh) {
11246
- broker = opts.brokers.get(row.mesh);
11376
+ daemonBroker = opts.brokers.get(row.mesh);
11247
11377
  } else if (opts.brokers.size === 1) {
11248
- broker = opts.brokers.values().next().value;
11378
+ daemonBroker = opts.brokers.values().next().value;
11249
11379
  }
11250
- if (!broker) {
11380
+ if (!daemonBroker) {
11251
11381
  log2("warn", "drain_no_broker_for_mesh", { id: row.id, mesh: row.mesh ?? "(null)" });
11252
11382
  markDead(opts.db, row.id, `no_broker_for_mesh:${row.mesh ?? "null"}`);
11253
11383
  continue;
11254
11384
  }
11385
+ let sessionBroker;
11386
+ if (row.sender_session_pubkey && opts.getSessionBrokerByPubkey) {
11387
+ sessionBroker = opts.getSessionBrokerByPubkey(row.sender_session_pubkey);
11388
+ }
11255
11389
  let targetSpec;
11256
11390
  let nonce;
11257
11391
  let ciphertext;
@@ -11267,16 +11401,29 @@ async function drainOnce(opts, log2) {
11267
11401
  ciphertext = Buffer.from(row.payload).toString("base64");
11268
11402
  priority = "next";
11269
11403
  }
11404
+ const sendArgs = {
11405
+ targetSpec,
11406
+ priority,
11407
+ nonce,
11408
+ ciphertext,
11409
+ client_message_id: row.client_message_id,
11410
+ request_fingerprint_hex: fpHex
11411
+ };
11270
11412
  let res;
11271
11413
  try {
11272
- res = await broker.send({
11273
- targetSpec,
11274
- priority,
11275
- nonce,
11276
- ciphertext,
11277
- client_message_id: row.client_message_id,
11278
- request_fingerprint_hex: fpHex
11279
- });
11414
+ if (row.sender_session_pubkey) {
11415
+ if (!sessionBroker || !sessionBroker.isOpen()) {
11416
+ log2("info", "drain_session_ws_not_ready", {
11417
+ id: row.id,
11418
+ session_pubkey: row.sender_session_pubkey.slice(0, 12)
11419
+ });
11420
+ backoffPending(opts.db, row.id, row.attempts + 1, "session_ws_not_open", "session_ws_not_open");
11421
+ continue;
11422
+ }
11423
+ res = await sessionBroker.send(sendArgs);
11424
+ } else {
11425
+ res = await daemonBroker.send(sendArgs);
11426
+ }
11280
11427
  } catch (e) {
11281
11428
  log2("warn", "drain_send_threw", { id: row.id, err: String(e) });
11282
11429
  backoffPending(opts.db, row.id, row.attempts + 1, "exception", String(e));
@@ -11672,9 +11819,14 @@ async function runDaemon(opts = {}) {
11672
11819
  `));
11673
11820
  brokers.set(mesh.slug, broker);
11674
11821
  }
11675
- let drain = null;
11676
- drain = startDrainWorker({ db: outboxDb, brokers });
11677
11822
  const sessionBrokers = new Map;
11823
+ const sessionBrokersByPubkey = new Map;
11824
+ let drain = null;
11825
+ drain = startDrainWorker({
11826
+ db: outboxDb,
11827
+ brokers,
11828
+ getSessionBrokerByPubkey: (pubkey) => sessionBrokersByPubkey.get(pubkey)
11829
+ });
11678
11830
  setRegistryHooks({
11679
11831
  onRegister: (info) => {
11680
11832
  if (!info.presence)
@@ -11693,6 +11845,9 @@ async function runDaemon(opts = {}) {
11693
11845
  const prior = sessionBrokers.get(info.token);
11694
11846
  if (prior) {
11695
11847
  sessionBrokers.delete(info.token);
11848
+ if (sessionBrokersByPubkey.get(prior.sessionPubkey) === prior) {
11849
+ sessionBrokersByPubkey.delete(prior.sessionPubkey);
11850
+ }
11696
11851
  prior.close().catch(() => {});
11697
11852
  }
11698
11853
  const sessionSecretKeyHex = info.presence.sessionSecretKey;
@@ -11718,6 +11873,7 @@ async function runDaemon(opts = {}) {
11718
11873
  }
11719
11874
  });
11720
11875
  sessionBrokers.set(info.token, client);
11876
+ sessionBrokersByPubkey.set(info.presence.sessionPubkey, client);
11721
11877
  client.connect().catch((err) => process.stderr.write(JSON.stringify({
11722
11878
  level: "warn",
11723
11879
  msg: "session_broker_connect_failed",
@@ -11732,6 +11888,9 @@ async function runDaemon(opts = {}) {
11732
11888
  if (!client)
11733
11889
  return;
11734
11890
  sessionBrokers.delete(info.token);
11891
+ if (sessionBrokersByPubkey.get(client.sessionPubkey) === client) {
11892
+ sessionBrokersByPubkey.delete(client.sessionPubkey);
11893
+ }
11735
11894
  client.close().catch(() => {});
11736
11895
  }
11737
11896
  });
@@ -19526,7 +19685,7 @@ async function main() {
19526
19685
  }
19527
19686
  case "inbox": {
19528
19687
  const { runInbox: runInbox2 } = await Promise.resolve().then(() => (init_inbox(), exports_inbox));
19529
- await runInbox2({ json: !!flags.json });
19688
+ await runInbox2({ mesh: flags.mesh, json: !!flags.json, limit: typeof flags.limit === "number" ? flags.limit : typeof flags.limit === "string" ? Number.parseInt(flags.limit, 10) : undefined });
19530
19689
  break;
19531
19690
  }
19532
19691
  case "state": {
@@ -19781,7 +19940,7 @@ async function main() {
19781
19940
  await runSend2({ mesh: flags.mesh, priority: flags.priority, json: !!flags.json, self: !!flags.self }, positionals[1] ?? "", positionals.slice(2).join(" "));
19782
19941
  } else if (sub === "inbox") {
19783
19942
  const { runInbox: runInbox2 } = await Promise.resolve().then(() => (init_inbox(), exports_inbox));
19784
- await runInbox2({ json: !!flags.json });
19943
+ await runInbox2({ mesh: flags.mesh, json: !!flags.json, limit: typeof flags.limit === "number" ? flags.limit : typeof flags.limit === "string" ? Number.parseInt(flags.limit, 10) : undefined });
19785
19944
  } else if (sub === "status") {
19786
19945
  const { runMsgStatus: runMsgStatus2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
19787
19946
  process.exit(await runMsgStatus2(positionals[1], { mesh: flags.mesh, json: !!flags.json }));
@@ -20334,4 +20493,4 @@ main().catch((err) => {
20334
20493
  process.exit(EXIT.INTERNAL_ERROR);
20335
20494
  });
20336
20495
 
20337
- //# debugId=DC25A8288183DA4364756E2164756E21
20496
+ //# debugId=55E9142D00D4EE3764756E2164756E21