@moxt-ai/mobius 0.0.190 → 0.0.191

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3381,7 +3381,7 @@ var program = new Command();
3381
3381
  // package.json
3382
3382
  var package_default = {
3383
3383
  name: "@moxt-ai/mobius",
3384
- version: "0.0.190",
3384
+ version: "0.0.191",
3385
3385
  description: "Mobius CLI for pairing and running local AI agent services.",
3386
3386
  type: "module",
3387
3387
  bin: {
@@ -29655,6 +29655,24 @@ var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSch
29655
29655
  var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
29656
29656
  var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
29657
29657
 
29658
+ // ../protocol/src/runtime-diagnostics.ts
29659
+ var identifier = external_exports.custom(isIdentifier);
29660
+ var runtimeDiagnosticsRequestSchema = external_exports.strictObject({
29661
+ kind: external_exports.literal("runtime.diagnostics.read"),
29662
+ requestId: identifier
29663
+ });
29664
+ var runtimeDiagnosticsResultSchema = external_exports.strictObject({
29665
+ kind: external_exports.literal("runtime.diagnostics.result"),
29666
+ requestId: identifier,
29667
+ truncated: external_exports.boolean(),
29668
+ version: external_exports.string().max(32),
29669
+ entries: external_exports.array(external_exports.record(external_exports.string(), external_exports.string().max(256)).readonly()).max(200).readonly()
29670
+ }).refine((value) => JSON.stringify(value).length <= 65536, "Diagnostics exceed the report limit");
29671
+ var decodeRuntimeDiagnosticsRequest = (raw) => runtimeDiagnosticsRequestSchema.parse(JSON.parse(raw));
29672
+ var decodeRuntimeDiagnosticsResult = (raw) => runtimeDiagnosticsResultSchema.parse(JSON.parse(raw));
29673
+ var encodeRuntimeDiagnosticsRequest = (value) => JSON.stringify(runtimeDiagnosticsRequestSchema.parse(value));
29674
+ var encodeRuntimeDiagnosticsResult = (value) => JSON.stringify(runtimeDiagnosticsResultSchema.parse(value));
29675
+
29658
29676
  // ../protocol/src/session-event-log-v2.ts
29659
29677
  var MAX_EVENT_COUNT = 1e4;
29660
29678
  var MAX_COLLECTION_SIZE = 1e3;
@@ -30228,6 +30246,11 @@ var serviceToDaemonSignatures = {
30228
30246
  encodeRuntimeLivenessReadyEvent,
30229
30247
  decodeRuntimeLivenessReadyEvent
30230
30248
  ),
30249
+ "runtime.diagnostics.read": defineMessageSignature(
30250
+ "runtime.diagnostics.read",
30251
+ encodeRuntimeDiagnosticsRequest,
30252
+ decodeRuntimeDiagnosticsRequest
30253
+ ),
30231
30254
  [RUNTIME_PING_KIND]: defineMessageSignature(RUNTIME_PING_KIND, encodeRuntimePingCommand, decodeRuntimePingCommand),
30232
30255
  [SESSION_CANCEL_KIND]: defineMessageSignature(
30233
30256
  SESSION_CANCEL_KIND,
@@ -30374,6 +30397,11 @@ var daemonToServiceSignatures = {
30374
30397
  encodeRuntimeHeartbeatEvent,
30375
30398
  decodeRuntimeHeartbeatEvent
30376
30399
  ),
30400
+ "runtime.diagnostics.result": defineMessageSignature(
30401
+ "runtime.diagnostics.result",
30402
+ encodeRuntimeDiagnosticsResult,
30403
+ decodeRuntimeDiagnosticsResult
30404
+ ),
30377
30405
  [RUNTIME_PONG_KIND]: defineMessageSignature(RUNTIME_PONG_KIND, encodeRuntimePongEvent, decodeRuntimePongEvent),
30378
30406
  [SESSION_EVENT_V2_KIND]: defineMessageSignature(
30379
30407
  SESSION_EVENT_V2_KIND,
@@ -34226,10 +34254,10 @@ function sql(strings, ...params) {
34226
34254
  return new SQL(result);
34227
34255
  }
34228
34256
  _sql.join = join21;
34229
- function identifier(value) {
34257
+ function identifier2(value) {
34230
34258
  return new Name(value);
34231
34259
  }
34232
- _sql.identifier = identifier;
34260
+ _sql.identifier = identifier2;
34233
34261
  function placeholder2(name2) {
34234
34262
  return new Placeholder(name2);
34235
34263
  }
@@ -35825,19 +35853,19 @@ var SQLiteCustomColumn = class extends SQLiteColumn {
35825
35853
  mapFromJsonValue(value) {
35826
35854
  return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
35827
35855
  }
35828
- jsonSelectIdentifier(identifier, sql2) {
35829
- if (typeof this.forJsonSelect === "function") return this.forJsonSelect(identifier, sql2);
35856
+ jsonSelectIdentifier(identifier2, sql2) {
35857
+ if (typeof this.forJsonSelect === "function") return this.forJsonSelect(identifier2, sql2);
35830
35858
  const rawType = this.getSQLType().toLowerCase();
35831
35859
  const parenPos = rawType.indexOf("(");
35832
35860
  switch (parenPos + 1 ? rawType.slice(0, parenPos) : rawType) {
35833
35861
  case "numeric":
35834
35862
  case "decimal":
35835
35863
  case "bigint":
35836
- return sql2`cast(${identifier} as text)`;
35864
+ return sql2`cast(${identifier2} as text)`;
35837
35865
  case "blob":
35838
- return sql2`hex(${identifier})`;
35866
+ return sql2`hex(${identifier2})`;
35839
35867
  default:
35840
- return identifier;
35868
+ return identifier2;
35841
35869
  }
35842
35870
  }
35843
35871
  mapToDriverValue = (value) => {
@@ -42407,6 +42435,74 @@ var DaemonDiagnosticLog = class {
42407
42435
  this.#path = join18(this.#directory, "daemon.log");
42408
42436
  this.#maximumBytes = maximumBytes;
42409
42437
  }
42438
+ // Export only correlation and failure metadata. Local messages and paths stay local.
42439
+ snapshot = () => {
42440
+ let content;
42441
+ try {
42442
+ content = readFileSync2(this.#path, "utf8");
42443
+ } catch (cause) {
42444
+ if (cause instanceof Error && Reflect.get(cause, "code") === "ENOENT") {
42445
+ return { entries: [], truncated: false };
42446
+ }
42447
+ throw cause;
42448
+ }
42449
+ const lines = content.split("\n").filter((line) => line.length > 0);
42450
+ const entries = [];
42451
+ const fields = [
42452
+ "agentId",
42453
+ "operation",
42454
+ "runtimeId",
42455
+ "closeCode",
42456
+ "timeoutMilliseconds",
42457
+ "proxyRoute",
42458
+ "timestamp",
42459
+ "event",
42460
+ "channelId",
42461
+ "requestId",
42462
+ "commandId",
42463
+ "sessionId",
42464
+ "turnId",
42465
+ "connectionEpoch",
42466
+ "code",
42467
+ "source",
42468
+ "failureName",
42469
+ "failureCode",
42470
+ "failureStatusCode",
42471
+ "cause1Name",
42472
+ "cause1Code",
42473
+ "cause2Name",
42474
+ "cause2Code"
42475
+ ];
42476
+ for (const line of lines.slice(-200)) {
42477
+ const start = line.indexOf("{");
42478
+ if (start < 0) {
42479
+ continue;
42480
+ }
42481
+ let value;
42482
+ try {
42483
+ value = JSON.parse(line.slice(start));
42484
+ } catch {
42485
+ continue;
42486
+ }
42487
+ if (typeof value !== "object" || value === null) {
42488
+ continue;
42489
+ }
42490
+ const entry = {};
42491
+ for (const field of fields) {
42492
+ const item = Reflect.get(value, field);
42493
+ if (typeof item === "string" && /^[a-zA-Z0-9_.: -]{1,256}$/u.test(item)) {
42494
+ entry[field] = item;
42495
+ }
42496
+ }
42497
+ entries.push(entry);
42498
+ }
42499
+ let truncated = lines.length > 200 || Buffer.byteLength(content) >= this.#maximumBytes - 4096;
42500
+ while (JSON.stringify(entries).length > 6e4) {
42501
+ entries.shift();
42502
+ truncated = true;
42503
+ }
42504
+ return { entries, truncated };
42505
+ };
42410
42506
  record = (diagnostic) => {
42411
42507
  const encoded = `${diagnostic.replace(/[\r\n]+/gu, " ").trim()}
42412
42508
  `;
@@ -44718,6 +44814,7 @@ var RelayConnectionDiagnostics = class {
44718
44814
  this.#relayOrigin = relayUrl.origin;
44719
44815
  this.#route = describeEnvironmentProxyRoute(relayUrl);
44720
44816
  }
44817
+ snapshot = () => this.#localLog.snapshot();
44721
44818
  catalogFailed = (failure2) => {
44722
44819
  const details = { ...this.#route, relayOrigin: this.#relayOrigin };
44723
44820
  addFailureDetails(details, failure2);
@@ -44789,6 +44886,7 @@ var RelayConnectionDiagnostics = class {
44789
44886
  }
44790
44887
  this.#localLog.record(
44791
44888
  `Mobius daemon diagnostic ${JSON.stringify({
44889
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
44792
44890
  channelId: this.#channelId,
44793
44891
  event,
44794
44892
  requestId,
@@ -44803,7 +44901,12 @@ var RelayConnectionDiagnostics = class {
44803
44901
  event,
44804
44902
  sessionId: this.#channelId
44805
44903
  });
44806
- const encoded = JSON.stringify({ channelId: this.#channelId, event, ...details });
44904
+ const encoded = JSON.stringify({
44905
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
44906
+ channelId: this.#channelId,
44907
+ event,
44908
+ ...details
44909
+ });
44807
44910
  this.#localLog.record(`Mobius relay diagnostic ${encoded}`);
44808
44911
  if (warning) {
44809
44912
  process.stderr.write(`Mobius relay diagnostic ${encoded}
@@ -46436,6 +46539,37 @@ function createDaemonCommandHandler({
46436
46539
  return {
46437
46540
  handle: (message) => {
46438
46541
  const kind = message.kind;
46542
+ if (kind === "runtime.diagnostics.read") {
46543
+ audit.record({
46544
+ event: "runtime_diagnostics_read",
46545
+ commandId: message.requestId,
46546
+ sessionId: "runtime",
46547
+ details: {}
46548
+ });
46549
+ try {
46550
+ send(socket, {
46551
+ kind: "runtime.diagnostics.result",
46552
+ requestId: message.requestId,
46553
+ version: package_default.version,
46554
+ ...diagnostics.snapshot()
46555
+ });
46556
+ } catch {
46557
+ audit.record({
46558
+ event: "runtime_diagnostics_failed",
46559
+ commandId: message.requestId,
46560
+ sessionId: "runtime",
46561
+ details: { code: "diagnostics_unavailable" }
46562
+ });
46563
+ send(socket, {
46564
+ kind: "session.operation.failed",
46565
+ requestId: message.requestId,
46566
+ sessionId: "runtime",
46567
+ code: "diagnostics_unavailable",
46568
+ message: "Local diagnostics are unavailable."
46569
+ });
46570
+ }
46571
+ return;
46572
+ }
46439
46573
  if (kind === RUNTIME_PING_KIND) {
46440
46574
  send(socket, { kind: RUNTIME_PONG_KIND, requestId: message.requestId });
46441
46575
  return;