mindwire 0.1.25 → 0.1.27

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/index.cjs CHANGED
@@ -638,8 +638,8 @@ var WorkspaceApi = class {
638
638
  agents;
639
639
  projects;
640
640
  chats;
641
- snapshot() {
642
- return this.mw.http.request("GET", "/workspace");
641
+ snapshot(options = {}) {
642
+ return this.mw.http.request("GET", "/workspace", { query: options });
643
643
  }
644
644
  /** Start an operation owned by the daemon. The same ID/payload returns the existing operation. */
645
645
  createProject(request) {
@@ -654,8 +654,8 @@ var WorkspaceApi = class {
654
654
  /** Incremental reconciliation. Pass the previous identity to detect a replaced/restored workspace.
655
655
  * A 409 requires fetching snapshot() again; never apply a delta to a different registry.
656
656
  */
657
- changes(since, workspaceId) {
658
- return this.mw.http.request("GET", "/workspace/changes", { query: { since, workspaceId } });
657
+ changes(since, workspaceId, options = {}) {
658
+ return this.mw.http.request("GET", "/workspace/changes", { query: { since, workspaceId, ...options } });
659
659
  }
660
660
  /** Import legacy metadata before replacing a local cache. Safe to repeat after interruption. */
661
661
  import(records) {
@@ -811,9 +811,11 @@ var ServiceApi = class {
811
811
  return this.client.http.request("GET", "/service/update");
812
812
  }
813
813
  /** Download first. Acquire immediately before replacement; busy work returns 409.
814
+ * With serviceUpdateVersion >= 2, force authorizes interrupting active work.
815
+ * It never overrides another installer's lease.
814
816
  * Admission stays closed until release, process exit, or the one-minute expiry. */
815
- acquireUpdate() {
816
- return this.client.http.request("POST", "/service/update");
817
+ acquireUpdate(options) {
818
+ return this.client.http.request("POST", "/service/update", options ? { body: options } : void 0);
817
819
  }
818
820
  releaseUpdate(id) {
819
821
  return this.client.http.request("DELETE", `/service/update/${encodeURIComponent(id)}`);
@@ -903,8 +905,10 @@ var ComputerApi = class {
903
905
  updateStatus() {
904
906
  return this.client.http.request("GET", "/computer/update");
905
907
  }
906
- requestUpdate(version) {
907
- return this.client.http.request("POST", "/computer/update", { body: { version } });
908
+ /** Automatic requests wait for idle. With serviceUpdateVersion >= 2, force
909
+ * promotes the same active request to an explicit restart without re-downloading. */
910
+ requestUpdate(version, options = {}) {
911
+ return this.client.http.request("POST", "/computer/update", { body: { version, ...options } });
908
912
  }
909
913
  invite(routes) {
910
914
  return this.client.http.request("POST", "/computer/pairings", { body: { routes } });
@@ -936,12 +940,16 @@ var ComputerApi = class {
936
940
  return this.client.http.request("DELETE", `/computer/forwards/${encodeURIComponent(id)}`);
937
941
  }
938
942
  };
943
+ function computerPairingQRData(invitation) {
944
+ return JSON.stringify(invitation);
945
+ }
939
946
  function computerPairingURI(invitation) {
940
- const bytes = new TextEncoder().encode(JSON.stringify(invitation));
947
+ const bytes = new TextEncoder().encode(computerPairingQRData(invitation));
941
948
  let binary = "";
942
949
  for (const byte of bytes) binary += String.fromCharCode(byte);
943
950
  const encoded = btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
944
- return `mindwire://pair?v=1#${encoded}`;
951
+ const action = "mode" in invitation && invitation.mode === "reconnect" ? "reconnect" : "pair";
952
+ return `mindwire://${action}?v=1#${encoded}`;
945
953
  }
946
954
 
947
955
  // src/embedded.ts
@@ -951,7 +959,7 @@ init_errors();
951
959
  init_errors();
952
960
 
953
961
  // src/version.ts
954
- var SDK_VERSION = "0.1.25" ;
962
+ var SDK_VERSION = "0.1.27" ;
955
963
 
956
964
  // src/daemon-binary.ts
957
965
  function supported(platform, arch) {
@@ -1354,9 +1362,12 @@ var Mindwire = class _Mindwire {
1354
1362
  });
1355
1363
  }
1356
1364
  // ---- chats & history -----------------------------------------------------
1357
- /** `GET /chats` — recorded chats (newest first), shared across agents. */
1358
- chats() {
1359
- return this.http.request("GET", "/chats");
1365
+ /** Native project conversations and drafts, newest first, shared across agents.
1366
+ * `cwd` matches an exact directory; `projectId` selects saved membership.
1367
+ * `refresh` bypasses the daemon's short native metadata cache.
1368
+ */
1369
+ chats(options = {}) {
1370
+ return this.http.request("GET", "/chats", { query: options });
1360
1371
  }
1361
1372
  /**
1362
1373
  * `PUT /chats/{id}` — rename a chat. The user title wins over the agent's native auto-title in
@@ -1401,6 +1412,30 @@ var Mindwire = class _Mindwire {
1401
1412
  query
1402
1413
  });
1403
1414
  }
1415
+ /**
1416
+ * Byte-budgeted history (default 1 MiB). Whole messages are retained, including
1417
+ * up to two newest messages even when oversized. Older services return their
1418
+ * bounded array, normalized here without a probe or duplicate request.
1419
+ */
1420
+ async messagePage(chatId, opts = {}) {
1421
+ const limit = opts.limit ?? 12;
1422
+ const result = await this.http.request(
1423
+ "GET",
1424
+ `/chats/${encodeURIComponent(chatId)}/messages`,
1425
+ {
1426
+ query: {
1427
+ ...this.agentParam(opts),
1428
+ limit,
1429
+ before: opts.before,
1430
+ paged: "true",
1431
+ maxBytes: opts.maxBytes ?? 1048576
1432
+ }
1433
+ }
1434
+ );
1435
+ if (result === null) return { messages: [], hasMore: false };
1436
+ if (!Array.isArray(result)) return result;
1437
+ return { messages: result, hasMore: result.length === limit, before: result[0]?.id };
1438
+ }
1404
1439
  /** `GET /chats/{id}/run` — the latest run for a chat (reattach anchor), or `null` if none yet. */
1405
1440
  async latestRun(chatId) {
1406
1441
  const data = await this.http.request(
@@ -1424,6 +1459,7 @@ var Mindwire = class _Mindwire {
1424
1459
  chatId: input.chatId,
1425
1460
  message: input.message
1426
1461
  };
1462
+ if (input.requestId !== void 0) body.requestId = input.requestId;
1427
1463
  if (input.cwd !== void 0) body.cwd = input.cwd;
1428
1464
  if (input.options !== void 0) body.options = input.options;
1429
1465
  if (input.mode !== void 0) body.mode = input.mode;
@@ -2956,6 +2992,7 @@ exports.catalogModels = catalogModels;
2956
2992
  exports.catalogProvider = catalogProvider;
2957
2993
  exports.catalogProviders = catalogProviders;
2958
2994
  exports.clearCatalogCache = clearCatalogCache;
2995
+ exports.computerPairingQRData = computerPairingQRData;
2959
2996
  exports.computerPairingURI = computerPairingURI;
2960
2997
  exports.docker = docker;
2961
2998
  exports.ensureDaemon = ensureDaemon;