@ai-matrx/desktop-protocol 0.21.67 → 0.21.69

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/client.cjs CHANGED
@@ -144,7 +144,7 @@ var import_zod2 = require("zod");
144
144
  var import_zod = require("zod");
145
145
  var import_uuid = require("@ai-matrx/kit/uuid");
146
146
  var PROTOCOL_MAJOR = 1;
147
- var PROTOCOL_MINOR = 67;
147
+ var PROTOCOL_MINOR = 68;
148
148
  var PROTOCOL_VERSION = `${PROTOCOL_MAJOR}.${PROTOCOL_MINOR}`;
149
149
  var ProtocolVersion = import_zod.z.string().regex(/^[1-9][0-9]{0,2}\.[0-9]{1,3}$/);
150
150
  var RequestId = import_zod.z.string().min(1).max(64).regex(/^[A-Za-z0-9_-]+$/);
@@ -1525,7 +1525,13 @@ var AccountAgentsVersionDiffResult = import_zod14.z.strictObject({
1525
1525
  current: import_zod14.z.record(import_zod14.z.string().max(200), import_zod14.z.unknown()).nullable()
1526
1526
  });
1527
1527
  var AccountAgentsRestoreVersionParams = import_zod14.z.strictObject({ agent_id: AccountRowId, version_number: import_zod14.z.int().min(1) });
1528
- var AccountAgentsRestoreVersionResult = import_zod14.z.strictObject({ restored_version: import_zod14.z.int().min(1) });
1528
+ var AccountAgentsRestoreVersionResult = import_zod14.z.strictObject({
1529
+ restored_version: import_zod14.z.int().min(1),
1530
+ /** (1.68) The version row the restore saved ("Restored from v<N>"), now the agent's current version. */
1531
+ new_version: import_zod14.z.int().min(1).optional(),
1532
+ /** (1.68) True when the agent already matched the restored version: nothing was saved. */
1533
+ unchanged: import_zod14.z.boolean().optional()
1534
+ });
1529
1535
  var VaultItemKind = import_zod14.z.enum(["login", "passkey", "key", "other"]);
1530
1536
  var VaultFieldSummary = import_zod14.z.strictObject({
1531
1537
  key: import_zod14.z.string().min(1).max(120),
@@ -4910,7 +4916,8 @@ var RESULT_PATH = /* @__PURE__ */ new Map([
4910
4916
  ["apps.projects.to_window", "AppsProjectsToWindowResult"],
4911
4917
  // 1.67: Matrx Local's local_mac_apps result fields.
4912
4918
  ["photos.get", "PhotosGetResult"],
4913
- ["location.get", "LocationGetResult"]
4919
+ ["location.get", "LocationGetResult"],
4920
+ ["account.agents.restore_version", "AccountAgentsRestoreVersionResult"]
4914
4921
  ]);
4915
4922
  var NESTED_RESULTS = /* @__PURE__ */ new Map([
4916
4923
  ["apps.chats.list", [["chats", "ChatRow"]]],
@@ -5013,6 +5020,13 @@ function createDesktopClient(options) {
5013
5020
  const listeners = /* @__PURE__ */ new Set();
5014
5021
  const readyWaiters = /* @__PURE__ */ new Set();
5015
5022
  const pending = /* @__PURE__ */ new Map();
5023
+ const abandoned = /* @__PURE__ */ new Set();
5024
+ const ABANDONED_MAX = 1024;
5025
+ function abandon(id) {
5026
+ if (!sendJson({ id, type: "cancel" })) return;
5027
+ abandoned.add(id);
5028
+ if (abandoned.size > ABANDONED_MAX) abandoned.delete(abandoned.values().next().value);
5029
+ }
5016
5030
  const streams = /* @__PURE__ */ new Map();
5017
5031
  const bySid = /* @__PURE__ */ new Map();
5018
5032
  const eventHandlers = /* @__PURE__ */ new Map();
@@ -5131,6 +5145,7 @@ function createDesktopClient(options) {
5131
5145
  const stopped = rule !== null && (rule.action === "stop" || rule.action === "reauth" && authRefusals >= 2);
5132
5146
  const terminal = stopped && rule ? rule : void 0;
5133
5147
  const lost = error ?? (terminal ? new DesktopProtocolError(terminal.error[0], terminal.error[1]) : rule && rule.action === "reauth" ? new DesktopProtocolError(rule.error[0], rule.error[1], { retryable: true }) : new DesktopProtocolError("DEVICE_OFFLINE", "Connection lost", { retryable: true }));
5148
+ abandoned.clear();
5134
5149
  for (const [id, p] of pending) {
5135
5150
  pending.delete(id);
5136
5151
  p.cleanup();
@@ -5234,7 +5249,10 @@ function createDesktopClient(options) {
5234
5249
  const s = streams.get(msg.id);
5235
5250
  if (s) return onStreamResult(s, msg.result);
5236
5251
  const p = pending.get(msg.id);
5237
- if (!p) return diagnose({ kind: "unknown_request", id: msg.id, type: msg.type });
5252
+ if (!p) {
5253
+ if (abandoned.delete(msg.id)) return;
5254
+ return diagnose({ kind: "unknown_request", id: msg.id, type: msg.type });
5255
+ }
5238
5256
  pending.delete(msg.id);
5239
5257
  p.cleanup();
5240
5258
  p.resolve(msg.result);
@@ -5251,7 +5269,10 @@ function createDesktopClient(options) {
5251
5269
  return endStream(s, null, error);
5252
5270
  }
5253
5271
  const p = pending.get(msg.id);
5254
- if (!p) return diagnose({ kind: "unknown_request", id: msg.id, type: msg.type });
5272
+ if (!p) {
5273
+ if (abandoned.delete(msg.id)) return;
5274
+ return diagnose({ kind: "unknown_request", id: msg.id, type: msg.type });
5275
+ }
5255
5276
  pending.delete(msg.id);
5256
5277
  p.cleanup();
5257
5278
  p.reject(error);
@@ -5482,13 +5503,13 @@ function createDesktopClient(options) {
5482
5503
  const timer = timers.setTimeout(() => {
5483
5504
  pending.delete(id);
5484
5505
  cleanup();
5485
- sendJson({ id, type: "cancel" });
5506
+ abandon(id);
5486
5507
  reject(new DesktopProtocolError("TIMEOUT", `${op} timed out`, { retryable: true }));
5487
5508
  }, timeoutMs);
5488
5509
  const onAbort = () => {
5489
5510
  pending.delete(id);
5490
5511
  cleanup();
5491
- sendJson({ id, type: "cancel" });
5512
+ abandon(id);
5492
5513
  reject(new DesktopProtocolError("CANCELLED", "Aborted"));
5493
5514
  };
5494
5515
  function cleanup() {