mindwire 0.1.1 → 0.1.2

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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * mindwire — a typed TypeScript client for the mindwire daemon.
3
3
  *
4
- * One SDK for every coding-agent harness (Claude Code, Codex, Copilot CLI, opencode). The
4
+ * One SDK for every coding-agent harness (Claude Code, Codex, Grok Build, opencode). The
5
5
  * daemon normalizes each agent to a single protocol; this package is a thin, dependency-free
6
6
  * client over its REST + SSE surface.
7
7
  */
package/dist/index.js CHANGED
@@ -466,7 +466,7 @@ var Run = class _Run {
466
466
  };
467
467
 
468
468
  // src/version.ts
469
- var SDK_VERSION = "0.1.1" ;
469
+ var SDK_VERSION = "0.1.2" ;
470
470
 
471
471
  // src/daemon-binary.ts
472
472
  function supported(platform, arch) {
@@ -642,7 +642,7 @@ function daemonStartError(resolved, cause) {
642
642
  " \u2022 check GitHub Release access so the SDK can download its matching daemon binary; or",
643
643
  " \u2022 set MINDWIRE_DAEMON to a `mindwired` binary; or",
644
644
  " \u2022 pass { baseUrl } to connect to a daemon you run yourself.",
645
- " \u2022 Working inside the mindwire monorepo? Run `bun run build:daemon` from the repo root to build it.",
645
+ " \u2022 Working inside the mindwire monorepo? Run `go build -o /tmp/mindwired ./daemon/cmd/daemon` and set MINDWIRE_DAEMON.",
646
646
  `(underlying error: ${cause.message})`
647
647
  ].join("\n");
648
648
  }
@@ -1914,6 +1914,7 @@ function docker(config = {}) {
1914
1914
  var DEFAULT_PORT2 = 8790;
1915
1915
  var DEFAULT_AGENT2 = "claude-code";
1916
1916
  var DEFAULT_AGENT_CWD2 = "/root";
1917
+ var DEFAULT_RUNTIME_IMAGE = `ghcr.io/oblien/mindwire-runtime:${SDK_VERSION}`;
1917
1918
  var DockerHost = class {
1918
1919
  constructor(container) {
1919
1920
  this.container = container;
@@ -1968,15 +1969,14 @@ async function provisionDocker(docker2, config = {}, onLog) {
1968
1969
  if (config.container !== void 0) {
1969
1970
  container = docker2.getContainer(config.container);
1970
1971
  } else {
1971
- if (!config.image) {
1972
- throw new MindwireError(
1973
- "mindwire: the Docker adapter needs an image or a container \u2014 pass docker({ image }) to create one, or docker({ container }) to attach to an existing one."
1974
- );
1975
- }
1972
+ const image = config.image ?? DEFAULT_RUNTIME_IMAGE;
1973
+ await ensureImage(docker2, image, config.pull ?? "missing", onLog);
1976
1974
  const portKey = `${port}/tcp`;
1977
1975
  container = await docker2.createContainer({
1978
- Image: config.image,
1979
- Cmd: ["sleep", "infinity"],
1976
+ // The runtime image starts mindwired itself. Do not replace its command: doing so turns the
1977
+ // image ENTRYPOINT into `mindwired sleep infinity` and prevents the runtime from starting.
1978
+ Image: image,
1979
+ Env: [`ADDR=:${port}`, `AGENT_TYPE=${agent}`, `AGENT_CWD=${agentCwd}`],
1980
1980
  Tty: false,
1981
1981
  ExposedPorts: { [portKey]: {} },
1982
1982
  HostConfig: { PortBindings: { [portKey]: [{ HostPort: "0" }] } },
@@ -2014,6 +2014,36 @@ async function provisionDocker(docker2, config = {}, onLog) {
2014
2014
  };
2015
2015
  return { id: container.id, baseUrl: `http://127.0.0.1:${hostPort}`, stop };
2016
2016
  }
2017
+ async function ensureImage(docker2, image, policy, onLog) {
2018
+ const emit2 = (message, error) => {
2019
+ try {
2020
+ onLog?.({ phase: "pull", target: "docker", message, ...error ? { error } : {} });
2021
+ } catch {
2022
+ }
2023
+ };
2024
+ if (policy === "never") return;
2025
+ if (policy === "missing") {
2026
+ try {
2027
+ await docker2.getImage(image).inspect();
2028
+ return;
2029
+ } catch {
2030
+ }
2031
+ }
2032
+ emit2(`pulling runtime image ${image}`);
2033
+ try {
2034
+ const stream = await docker2.pull(image);
2035
+ await new Promise((resolve, reject) => {
2036
+ stream.on("end", () => resolve());
2037
+ stream.on("close", () => resolve());
2038
+ stream.on("error", (error) => reject(error));
2039
+ });
2040
+ emit2(`runtime image ready: ${image}`);
2041
+ } catch (error) {
2042
+ const detail = error instanceof Error ? error.message : String(error);
2043
+ emit2(`failed to pull runtime image ${image}`, detail);
2044
+ throw new MindwireError(`mindwire: failed to pull Docker image ${image}: ${detail}`, { cause: error });
2045
+ }
2046
+ }
2017
2047
  function tarSingleFile(name, data, mode) {
2018
2048
  const header = Buffer.alloc(512, 0);
2019
2049
  header.write(name.slice(0, 100), 0, "utf8");