mindwire 0.1.19 → 0.1.23

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.d.ts CHANGED
@@ -35,6 +35,8 @@ export * from "./types.js";
35
35
  export { ServiceApi } from "./service.js";
36
36
  export type { ServiceUpdateState, ServiceUpdateLease } from "./service.js";
37
37
  export { WorkspaceApi, WorkspaceCollection, ProjectOperationsApi, GitAccessApi } from "./workspace.js";
38
- export type { ProjectRequest, ProjectAuth, ProjectOperation, ProjectRemoveRequest, GitConnection, GitAccessState, ProjectGitState, GitAction, GitIdentity, GitOperationRequest, GitOperation } from "./workspace.js";
38
+ export type { ProjectRequest, ProjectAuth, ProjectOperation, ProjectRemoveRequest, GitConnection, GitAccessState, ProjectGitState, GitAction, GitIdentity, GitIdentityScope, GitIdentitySettings, GitIdentityUpdate, GitOperationRequest, GitOperation } from "./workspace.js";
39
39
  export type { WorkspaceRecord, WorkspaceAgent, WorkspaceProject, WorkspaceChat, WorkspaceKind, WorkspaceInput, WorkspaceImport, WorkspaceSnapshot } from "./workspace.js";
40
40
  export * from "./surfaces.js";
41
+ export * from "./execution.js";
42
+ export * from "./computer.js";
package/dist/index.js CHANGED
@@ -1,56 +1,5 @@
1
- // src/errors.ts
2
- var MindwireError = class extends Error {
3
- constructor(message, options) {
4
- super(message, options);
5
- this.name = "MindwireError";
6
- }
7
- };
8
- var ApiError = class _ApiError extends MindwireError {
9
- status;
10
- url;
11
- method;
12
- body;
13
- constructor(args) {
14
- super(_ApiError.messageFor(args));
15
- this.name = "ApiError";
16
- this.status = args.status;
17
- this.url = args.url;
18
- this.method = args.method;
19
- this.body = args.body;
20
- }
21
- static messageFor({
22
- status,
23
- method,
24
- url,
25
- body
26
- }) {
27
- const detail = body && typeof body === "object" && "error" in body && typeof body.error === "string" ? body.error : typeof body === "string" && body.trim() !== "" ? body.trim() : "";
28
- const base = `${method} ${url} failed with ${status}`;
29
- return detail ? `${base}: ${detail}` : base;
30
- }
31
- };
32
- var RunFailedError = class extends MindwireError {
33
- status;
34
- runId;
35
- constructor(runId, status, detail) {
36
- super(detail ? `run ${runId} ${status}: ${detail}` : `run ${runId} ${status}`);
37
- this.name = "RunFailedError";
38
- this.runId = runId;
39
- this.status = status;
40
- }
41
- };
42
- var TimeoutError = class extends MindwireError {
43
- method;
44
- path;
45
- timeoutMs;
46
- constructor(method, path, timeoutMs) {
47
- super(`mindwire: ${method} ${path} timed out after ${timeoutMs}ms`);
48
- this.name = "TimeoutError";
49
- this.method = method;
50
- this.path = path;
51
- this.timeoutMs = timeoutMs;
52
- }
53
- };
1
+ import { MindwireError, TimeoutError, ApiError, RunFailedError } from './chunk-T6TD76UA.js';
2
+ export { ApiError, MindwireError, RunFailedError, TimeoutError } from './chunk-T6TD76UA.js';
54
3
 
55
4
  // src/http.ts
56
5
  var DEFAULT_TIMEOUT_MS = 12e4;
@@ -226,7 +175,8 @@ var Http = class {
226
175
  url,
227
176
  {
228
177
  method,
229
- headers: this.headers(await this.authToken(base, force), extra),
178
+ headers: this.headers(await this.authToken(base, force), extra, init.body !== void 0),
179
+ ...init.body !== void 0 ? { body: JSON.stringify(init.body) } : {},
230
180
  ...init.signal ? { signal: init.signal } : {}
231
181
  },
232
182
  method,
@@ -587,6 +537,15 @@ var GitAccessApi = class {
587
537
  this.mw = mw;
588
538
  }
589
539
  mw;
540
+ /** Reads attribution independently of GitHub authentication. Requires gitIdentityVersion >= 1. */
541
+ identity(context = {}) {
542
+ return this.mw.http.request("GET", "/workspace/git/identity", { query: context });
543
+ }
544
+ /** Saves settings only; never stages or commits. all_workspaces installs this
545
+ * workspace's copy of a client-managed default; the client handles fan-out. */
546
+ setIdentity(update, context = {}) {
547
+ return this.mw.http.request("PUT", "/workspace/git/identity", { query: context, body: update });
548
+ }
590
549
  state() {
591
550
  return this.mw.http.request("GET", "/workspace/git");
592
551
  }
@@ -608,7 +567,7 @@ var GitAccessApi = class {
608
567
  run(projectId, operation, auth) {
609
568
  return this.mw.http.request("POST", `/workspace/projects/${encodeURIComponent(projectId)}/git/${operation}`, { body: { auth } });
610
569
  }
611
- /** Requires health.gitOperationsVersion >= 1 (>= 2 for branch changes). Acceptance persists before Git runs;
570
+ /** Requires health.gitOperationsVersion >= 1 (>= 2 for branches, >= 4 for restore_commit). Acceptance persists before Git runs;
612
571
  * disconnecting only detaches the client. The same ID/intent never runs twice.
613
572
  */
614
573
  start(projectId, request) {
@@ -618,7 +577,7 @@ var GitAccessApi = class {
618
577
  const result = await this.mw.http.request(
619
578
  "GET",
620
579
  `/workspace/projects/${encodeURIComponent(projectId)}/git/operations`,
621
- { query: { active: activeOnly, actionsVersion: 2 } }
580
+ { query: { active: activeOnly, actionsVersion: 4 } }
622
581
  );
623
582
  return result.operations;
624
583
  }
@@ -731,8 +690,121 @@ var ServiceApi = class {
731
690
  }
732
691
  };
733
692
 
693
+ // src/execution.ts
694
+ var ExecutionApi = class {
695
+ constructor(client) {
696
+ this.client = client;
697
+ this.terminals = new TerminalsApi(client);
698
+ }
699
+ client;
700
+ terminals;
701
+ host() {
702
+ return this.client.http.request("GET", "/workspace/host");
703
+ }
704
+ resources() {
705
+ return this.client.http.request("GET", "/workspace/resources");
706
+ }
707
+ files(path = "", query) {
708
+ return this.client.http.request("GET", "/workspace/files", { query: { path, query } });
709
+ }
710
+ read(path) {
711
+ return this.client.http.request("GET", "/workspace/file", { query: { path } });
712
+ }
713
+ write(path, content) {
714
+ return this.client.http.request("PUT", "/workspace/file", { body: { path, content } });
715
+ }
716
+ remove(path) {
717
+ return this.client.http.request("DELETE", "/workspace/file", { query: { path } });
718
+ }
719
+ exec(command, signal) {
720
+ return this.client.http.request("POST", "/workspace/exec", { body: command, signal });
721
+ }
722
+ /** Output data is base64, preserving partial UTF-8 chunks. Cancelling stops this command. */
723
+ async *stream(command, signal) {
724
+ const response = await this.client.http.open("POST", "/workspace/exec/stream", { body: command, signal });
725
+ yield* readSSE(response.body, signal);
726
+ }
727
+ };
728
+ var TerminalsApi = class {
729
+ constructor(client) {
730
+ this.client = client;
731
+ }
732
+ client;
733
+ list(directory) {
734
+ return this.client.http.request("GET", "/workspace/terminals", { query: { directory } });
735
+ }
736
+ open(request) {
737
+ return this.client.http.request("POST", "/workspace/terminals", { body: request });
738
+ }
739
+ get(id) {
740
+ return this.client.http.request("GET", this.path(id));
741
+ }
742
+ close(id) {
743
+ return this.client.http.request("DELETE", this.path(id));
744
+ }
745
+ input(id, input) {
746
+ return this.client.http.request("POST", `${this.path(id)}/input`, { body: input });
747
+ }
748
+ resize(id, columns, rows) {
749
+ return this.client.http.request("PUT", `${this.path(id)}/size`, { body: { columns, rows } });
750
+ }
751
+ /** Detaching only closes the subscription. Resume from the last sequence; reset replaces the screen. */
752
+ async *events(id, after = 0, signal) {
753
+ const response = await this.client.http.open("GET", `${this.path(id)}/events`, { query: { after }, signal });
754
+ yield* readSSE(response.body, signal);
755
+ }
756
+ path(id) {
757
+ return `/workspace/terminals/${encodeURIComponent(id)}`;
758
+ }
759
+ };
760
+
761
+ // src/computer.ts
762
+ var ComputerApi = class {
763
+ constructor(client) {
764
+ this.client = client;
765
+ }
766
+ client;
767
+ info() {
768
+ return this.client.http.request("GET", "/computer");
769
+ }
770
+ setRoutes(routes) {
771
+ return this.client.http.request("PUT", "/computer/routes", { body: { routes } });
772
+ }
773
+ updateStatus() {
774
+ return this.client.http.request("GET", "/computer/update");
775
+ }
776
+ requestUpdate(version) {
777
+ return this.client.http.request("POST", "/computer/update", { body: { version } });
778
+ }
779
+ invite(routes) {
780
+ return this.client.http.request("POST", "/computer/pairings", { body: { routes } });
781
+ }
782
+ pairing(id) {
783
+ return this.client.http.request("GET", `/computer/pairings/${encodeURIComponent(id)}`);
784
+ }
785
+ completePairing(id, requestId) {
786
+ return this.client.http.request("POST", `/computer/pairings/${encodeURIComponent(id)}/complete`, { body: { requestId } });
787
+ }
788
+ decide(id, requestId, approve) {
789
+ return this.client.http.request("POST", `/computer/pairings/${encodeURIComponent(id)}/decision`, { body: { requestId, approve } });
790
+ }
791
+ devices() {
792
+ return this.client.http.request("GET", "/computer/devices");
793
+ }
794
+ revoke(id) {
795
+ return this.client.http.request("DELETE", `/computer/devices/${encodeURIComponent(id)}`);
796
+ }
797
+ };
798
+ function computerPairingURI(invitation) {
799
+ const bytes = new TextEncoder().encode(JSON.stringify(invitation));
800
+ let binary = "";
801
+ for (const byte of bytes) binary += String.fromCharCode(byte);
802
+ const encoded = btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
803
+ return `mindwire://pair?v=1#${encoded}`;
804
+ }
805
+
734
806
  // src/version.ts
735
- var SDK_VERSION = "0.1.19" ;
807
+ var SDK_VERSION = "0.1.23" ;
736
808
 
737
809
  // src/daemon-binary.ts
738
810
  function supported(platform, arch) {
@@ -761,21 +833,13 @@ async function ensureDaemonBinary(opts = {}) {
761
833
  if (!/^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?$/.test(version)) {
762
834
  throw new MindwireError(`mindwire: cannot download daemon for non-release SDK version ${version}`);
763
835
  }
764
- const fs = await import('fs/promises');
765
836
  const path = await import('path');
766
- const os = await import('os');
767
- const crypto = await import('crypto');
768
- const home = os.homedir();
769
- const defaultCache = daemonPlatform === "darwin" ? path.join(home, "Library", "Caches", "mindwire") : daemonPlatform === "win32" ? path.join(proc.process?.env?.LOCALAPPDATA ?? home, "mindwire", "Cache") : path.join(proc.process?.env?.XDG_CACHE_HOME ?? path.join(home, ".cache"), "mindwire");
770
- const dir = path.join(opts.cacheDir ?? defaultCache, version, `${daemonPlatform}-${daemonArch}`);
837
+ const { binaryCacheDirectory, cachedExecutable, cacheExecutable } = await import('./binary-cache-ZTEYICUF.js');
838
+ const dir = path.join(opts.cacheDir ?? await binaryCacheDirectory(daemonPlatform), version, `${daemonPlatform}-${daemonArch}`);
771
839
  const asset = assetName(version, daemonPlatform, daemonArch);
772
840
  const bin = path.join(dir, asset);
773
- const shaFile = `${bin}.sha256`;
774
- try {
775
- const [bytes2, expected2] = await Promise.all([fs.readFile(bin), fs.readFile(shaFile, "utf8")]);
776
- if (crypto.createHash("sha256").update(bytes2).digest("hex") === expected2.trim()) return bin;
777
- } catch {
778
- }
841
+ const cached = await cachedExecutable(bin);
842
+ if (cached) return cached;
779
843
  const base = (opts.releaseBaseUrl ?? proc.process?.env?.MINDWIRE_RELEASE_BASE_URL ?? "https://github.com/oblien/mindwire/releases/download").replace(/\/$/, "");
780
844
  const release = `${base}/v${version}`;
781
845
  const request = opts.fetch ?? globalThis.fetch;
@@ -797,17 +861,7 @@ async function ensureDaemonBinary(opts = {}) {
797
861
  const expected = checksumFor(await checksums.text(), asset);
798
862
  if (!expected) throw new MindwireError(`mindwire: release v${version} has no checksum for ${asset}`);
799
863
  const bytes = new Uint8Array(await binary.arrayBuffer());
800
- const actual = crypto.createHash("sha256").update(bytes).digest("hex");
801
- if (actual !== expected) throw new MindwireError(`mindwire: checksum verification failed for ${asset}`);
802
- await fs.mkdir(dir, { recursive: true });
803
- const temp = `${bin}.${process.pid}.tmp`;
804
- await fs.writeFile(temp, bytes, { mode: 493 });
805
- await fs.writeFile(`${shaFile}.${process.pid}.tmp`, `${expected}
806
- `);
807
- await fs.rename(temp, bin);
808
- await fs.rename(`${shaFile}.${process.pid}.tmp`, shaFile);
809
- if (daemonPlatform !== "win32") await fs.chmod(bin, 493);
810
- return bin;
864
+ return cacheExecutable(bin, bytes, expected);
811
865
  }
812
866
 
813
867
  // src/embedded.ts
@@ -994,6 +1048,8 @@ var Mindwire = class _Mindwire {
994
1048
  workspace;
995
1049
  surfaces;
996
1050
  service;
1051
+ execution;
1052
+ computer;
997
1053
  http;
998
1054
  /** The default agent type applied to agent-scoped calls, if set. */
999
1055
  defaultAgent;
@@ -1030,6 +1086,8 @@ var Mindwire = class _Mindwire {
1030
1086
  this.workspace = new WorkspaceApi(this);
1031
1087
  this.surfaces = new SurfacesApi(this);
1032
1088
  this.service = new ServiceApi(this);
1089
+ this.execution = new ExecutionApi(this);
1090
+ this.computer = new ComputerApi(this);
1033
1091
  this.auth = new AuthApi(this);
1034
1092
  this.prompts = new PromptsApi(this);
1035
1093
  this.mcp = new McpApi(this);
@@ -1053,6 +1111,8 @@ var Mindwire = class _Mindwire {
1053
1111
  clone.workspace = new WorkspaceApi(clone);
1054
1112
  clone.surfaces = new SurfacesApi(clone);
1055
1113
  clone.service = new ServiceApi(clone);
1114
+ clone.execution = new ExecutionApi(clone);
1115
+ clone.computer = new ComputerApi(clone);
1056
1116
  clone.auth = new AuthApi(clone);
1057
1117
  clone.prompts = new PromptsApi(clone);
1058
1118
  clone.mcp = new McpApi(clone);
@@ -2715,6 +2775,6 @@ function clearCatalogCache() {
2715
2775
  inflight = null;
2716
2776
  }
2717
2777
 
2718
- export { ApiError, AuthApi, ContainerHost, GitAccessApi, Http, MODELS_DEV_URL, McpApi, Mindwire, MindwireError, NotifyApi, ProjectOperationsApi, PromptsApi, ProvidersApi, Run, RunFailedError, SDK_VERSION, ServiceApi, SurfacesApi, TimeoutError, WorkspaceApi, WorkspaceCollection, catalogModels, catalogProvider, catalogProviders, clearCatalogCache, docker, ensureDaemon, ensureDaemonBinary, loadCatalog, local, lookupModel, oblien, provisionContainer, provisionDocker, provisionOblien, provisionSsh, provisionSshContainer, remote, resolveLinuxDaemon, ssh, startEmbedded };
2778
+ export { AuthApi, ComputerApi, ContainerHost, ExecutionApi, GitAccessApi, Http, MODELS_DEV_URL, McpApi, Mindwire, NotifyApi, ProjectOperationsApi, PromptsApi, ProvidersApi, Run, SDK_VERSION, ServiceApi, SurfacesApi, TerminalsApi, WorkspaceApi, WorkspaceCollection, catalogModels, catalogProvider, catalogProviders, clearCatalogCache, computerPairingURI, docker, ensureDaemon, ensureDaemonBinary, loadCatalog, local, lookupModel, oblien, provisionContainer, provisionDocker, provisionOblien, provisionSsh, provisionSshContainer, remote, resolveLinuxDaemon, ssh, startEmbedded };
2719
2779
  //# sourceMappingURL=index.js.map
2720
2780
  //# sourceMappingURL=index.js.map