mindwire 0.1.43 → 0.1.45

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.
@@ -88,7 +88,7 @@ function computerPairingURI(invitation) {
88
88
  }
89
89
 
90
90
  // src/version.ts
91
- var SDK_VERSION = "0.1.43" ;
91
+ var SDK_VERSION = "0.1.45" ;
92
92
  function versionAtLeast(actual, desired) {
93
93
  if (actual === desired) return true;
94
94
  if (!actual || !/^\d+\.\d+\.\d+$/.test(actual) || !/^\d+\.\d+\.\d+$/.test(desired)) return false;
@@ -997,8 +997,8 @@ var Run = class _Run {
997
997
  * Steer a follow-up message into the running turn without cancelling it. Requires the agent's
998
998
  * `input` capability.
999
999
  */
1000
- async sendInput(text) {
1001
- await this.http.request("POST", `/runs/${encodeURIComponent(this.id)}/input`, { body: { text } });
1000
+ async sendInput(text, options = {}) {
1001
+ await this.http.request("POST", `/runs/${encodeURIComponent(this.id)}/input`, { body: { text, ...options } });
1002
1002
  }
1003
1003
  /**
1004
1004
  * Soft-stop the running turn (ask the agent to halt current work) without the hard process kill
@@ -2050,6 +2050,45 @@ var Mindwire = class _Mindwire {
2050
2050
  body: { title }
2051
2051
  });
2052
2052
  }
2053
+ /** Resumable upload over the same connection as chat. Retrying an identical chunk is safe. */
2054
+ uploadAttachmentChunk(chatId, id, chunk, signal) {
2055
+ return this.http.request("PUT", `/chats/${encodeURIComponent(chatId)}/attachments/${encodeURIComponent(id)}`, { body: chunk, signal });
2056
+ }
2057
+ /** Store a file with its conversation, then pass the returned reference in turn options. */
2058
+ async uploadAttachment(chatId, file, options = {}) {
2059
+ if (file.data.byteLength > 16 * 1024 * 1024) throw new RangeError("Attachments must be at most 16 MiB");
2060
+ const data = new Uint8Array(file.data);
2061
+ const hash = async (bytes) => {
2062
+ if (!globalThis.crypto?.subtle) return executableChecksum(bytes);
2063
+ const digest = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", bytes));
2064
+ return Array.from(digest, (b) => b.toString(16).padStart(2, "0")).join("");
2065
+ };
2066
+ const sha256 = await hash(data);
2067
+ const id = (await hash(new TextEncoder().encode(`${chatId}\0${file.name}\0${sha256}`))).slice(0, 32);
2068
+ let offset = 0;
2069
+ for (; ; ) {
2070
+ options.signal?.throwIfAborted();
2071
+ const end = Math.min(data.length, offset + 384 * 1024);
2072
+ let binary = "";
2073
+ for (let start = offset; start < end; start += 16384) {
2074
+ binary += String.fromCharCode(...data.subarray(start, Math.min(end, start + 16384)));
2075
+ }
2076
+ const state = await this.uploadAttachmentChunk(chatId, id, {
2077
+ name: file.name,
2078
+ mime: file.mime ?? "application/octet-stream",
2079
+ bytes: data.length,
2080
+ sha256,
2081
+ offset,
2082
+ data: btoa(binary)
2083
+ }, options.signal);
2084
+ 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) {
2085
+ throw new Error("Invalid attachment upload acknowledgement");
2086
+ }
2087
+ options.onProgress?.(data.length === 0 ? 1 : state.offset / data.length);
2088
+ if (state.complete) return { artifactId: id, name: state.name, mime: state.mime, bytes: state.bytes };
2089
+ offset = state.offset;
2090
+ }
2091
+ }
2053
2092
  /**
2054
2093
  * `DELETE /chats/{id}` — a true, irreversible delete: purges ALL of the chat's mindwire
2055
2094
  * bookkeeping and, for every session the chat mapped to, removes that agent's native transcript
@@ -2131,6 +2170,7 @@ var Mindwire = class _Mindwire {
2131
2170
  message: input.message
2132
2171
  };
2133
2172
  if (input.requestId !== void 0) body.requestId = input.requestId;
2173
+ if (input.queueIfRunning !== void 0) body.queueIfRunning = input.queueIfRunning;
2134
2174
  if (input.cwd !== void 0) body.cwd = input.cwd;
2135
2175
  if (input.options !== void 0) body.options = input.options;
2136
2176
  if (input.mode !== void 0) body.mode = input.mode;
@@ -2603,7 +2643,7 @@ async function ensureComputer(directory, cliPath, patch = {}, onProgress, option
2603
2643
  if (!compatible(controller2) || !await processStateAlive(controller2)) {
2604
2644
  await ensureComputer(directory, cliPath, {}, onProgress, { ...options, waitForRoutes: false });
2605
2645
  }
2606
- const { changeComputerConnection } = await import('./connection-change-SF6UKNSO.js');
2646
+ const { changeComputerConnection } = await import('./connection-change-DRBAPLGD.js');
2607
2647
  await changeComputerConnection(directory, Object.fromEntries(changed.map((key) => [key, patch[key]])), { signal: options.signal, onProgress });
2608
2648
  return computerClient(directory);
2609
2649
  }
@@ -2644,7 +2684,7 @@ async function ensureComputer(directory, cliPath, patch = {}, onProgress, option
2644
2684
  let controller = await readJSON(path4.join(directory, "computer-controller.json"));
2645
2685
  if (existing && controller && !compatible(controller) && await processStateAlive(controller)) {
2646
2686
  onProgress?.("Refreshing the background connection service\u2026");
2647
- const { handoffController } = await import('./controller-handoff-WVGU5UNV.js');
2687
+ const { handoffController } = await import('./controller-handoff-DXG2BW6L.js');
2648
2688
  await handoffController(directory, controller, config, await existing.computer.info());
2649
2689
  controller = void 0;
2650
2690
  }
@@ -2678,7 +2718,7 @@ async function ensureComputer(directory, cliPath, patch = {}, onProgress, option
2678
2718
  }
2679
2719
  }
2680
2720
  async function superviseComputer(directory) {
2681
- const controller = await import('./controller-FCIIKFUZ.js');
2721
+ const controller = await import('./controller-75KVB27Q.js');
2682
2722
  await controller.superviseComputer(directory);
2683
2723
  }
2684
2724
  async function stopComputer(directory, force = false) {
@@ -2703,5 +2743,5 @@ async function stopComputer(directory, force = false) {
2703
2743
  }
2704
2744
 
2705
2745
  export { CONTROLLER_PROTOCOL, ProviderConnectionError, RelayOutput, SDK_VERSION, acquireProcessLock, adoptProcess, adoptRelay, cloudflareCommand, computerClient, computerPairingQRData, computerPairingURI, currentProcessIdentity, defaultComputerConfig, defaultStateDirectory, directRoutes, ensureComputer, ensureDaemonBinary, hasCertificateError, ownChild, processIdentity, processStateAlive, providerFailure, providerNeedsAction, readJSON, startRelay, stopComputer, superviseComputer, versionAtLeast, websocketURL, writeJSON };
2706
- //# sourceMappingURL=chunk-G7CSL6OC.js.map
2707
- //# sourceMappingURL=chunk-G7CSL6OC.js.map
2746
+ //# sourceMappingURL=chunk-7NLK636R.js.map
2747
+ //# sourceMappingURL=chunk-7NLK636R.js.map