mindwire 0.1.43 → 0.1.44

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
@@ -471,8 +471,8 @@ var Run = class _Run {
471
471
  * Steer a follow-up message into the running turn without cancelling it. Requires the agent's
472
472
  * `input` capability.
473
473
  */
474
- async sendInput(text) {
475
- await this.http.request("POST", `/runs/${encodeURIComponent(this.id)}/input`, { body: { text } });
474
+ async sendInput(text, options = {}) {
475
+ await this.http.request("POST", `/runs/${encodeURIComponent(this.id)}/input`, { body: { text, ...options } });
476
476
  }
477
477
  /**
478
478
  * Soft-stop the running turn (ask the agent to halt current work) without the hard process kill
@@ -1244,6 +1244,9 @@ function computerPairingURI(invitation) {
1244
1244
  return `mindwire://${action}?v=1#${encoded}`;
1245
1245
  }
1246
1246
 
1247
+ // src/client.ts
1248
+ init_binary_cache();
1249
+
1247
1250
  // src/embedded.ts
1248
1251
  init_errors();
1249
1252
 
@@ -1251,7 +1254,7 @@ init_errors();
1251
1254
  init_errors();
1252
1255
 
1253
1256
  // src/version.ts
1254
- var SDK_VERSION = "0.1.43" ;
1257
+ var SDK_VERSION = "0.1.44" ;
1255
1258
  function versionAtLeast(actual, desired) {
1256
1259
  if (actual === desired) return true;
1257
1260
  if (!actual || !/^\d+\.\d+\.\d+$/.test(actual) || !/^\d+\.\d+\.\d+$/.test(desired)) return false;
@@ -1680,6 +1683,45 @@ var Mindwire = class _Mindwire {
1680
1683
  body: { title }
1681
1684
  });
1682
1685
  }
1686
+ /** Resumable upload over the same connection as chat. Retrying an identical chunk is safe. */
1687
+ uploadAttachmentChunk(chatId, id, chunk, signal) {
1688
+ return this.http.request("PUT", `/chats/${encodeURIComponent(chatId)}/attachments/${encodeURIComponent(id)}`, { body: chunk, signal });
1689
+ }
1690
+ /** Store a file with its conversation, then pass the returned reference in turn options. */
1691
+ async uploadAttachment(chatId, file, options = {}) {
1692
+ if (file.data.byteLength > 16 * 1024 * 1024) throw new RangeError("Attachments must be at most 16 MiB");
1693
+ const data = new Uint8Array(file.data);
1694
+ const hash = async (bytes) => {
1695
+ if (!globalThis.crypto?.subtle) return executableChecksum(bytes);
1696
+ const digest = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", bytes));
1697
+ return Array.from(digest, (b) => b.toString(16).padStart(2, "0")).join("");
1698
+ };
1699
+ const sha256 = await hash(data);
1700
+ const id = (await hash(new TextEncoder().encode(`${chatId}\0${file.name}\0${sha256}`))).slice(0, 32);
1701
+ let offset = 0;
1702
+ for (; ; ) {
1703
+ options.signal?.throwIfAborted();
1704
+ const end = Math.min(data.length, offset + 384 * 1024);
1705
+ let binary = "";
1706
+ for (let start = offset; start < end; start += 16384) {
1707
+ binary += String.fromCharCode(...data.subarray(start, Math.min(end, start + 16384)));
1708
+ }
1709
+ const state = await this.uploadAttachmentChunk(chatId, id, {
1710
+ name: file.name,
1711
+ mime: file.mime ?? "application/octet-stream",
1712
+ bytes: data.length,
1713
+ sha256,
1714
+ offset,
1715
+ data: btoa(binary)
1716
+ }, options.signal);
1717
+ if (state.id !== id || state.bytes !== data.length || state.offset < end || state.offset > data.length || state.complete && state.offset !== data.length || !state.complete && state.offset <= offset) {
1718
+ throw new Error("Invalid attachment upload acknowledgement");
1719
+ }
1720
+ options.onProgress?.(data.length === 0 ? 1 : state.offset / data.length);
1721
+ if (state.complete) return { artifactId: id, name: state.name, mime: state.mime, bytes: state.bytes };
1722
+ offset = state.offset;
1723
+ }
1724
+ }
1683
1725
  /**
1684
1726
  * `DELETE /chats/{id}` — a true, irreversible delete: purges ALL of the chat's mindwire
1685
1727
  * bookkeeping and, for every session the chat mapped to, removes that agent's native transcript
@@ -1761,6 +1803,7 @@ var Mindwire = class _Mindwire {
1761
1803
  message: input.message
1762
1804
  };
1763
1805
  if (input.requestId !== void 0) body.requestId = input.requestId;
1806
+ if (input.queueIfRunning !== void 0) body.queueIfRunning = input.queueIfRunning;
1764
1807
  if (input.cwd !== void 0) body.cwd = input.cwd;
1765
1808
  if (input.options !== void 0) body.options = input.options;
1766
1809
  if (input.mode !== void 0) body.mode = input.mode;