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/README.md +4 -12
- package/dist/index.cjs +39 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +39 -9
- package/dist/index.js.map +1 -1
- package/dist/target/docker.d.ts +7 -1
- package/dist/target/host.d.ts +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# mindwire
|
|
2
2
|
|
|
3
3
|
A typed TypeScript client for the **mindwire daemon** — one SDK for every coding-agent harness
|
|
4
|
-
(Claude Code, Codex,
|
|
4
|
+
(Claude Code, Codex, Grok Build, opencode). The daemon normalizes each agent to a single
|
|
5
5
|
protocol; this package is a thin, dependency-free client over its REST + SSE surface.
|
|
6
6
|
|
|
7
7
|
- **Embedded by default.** On a server runtime (Node/Bun/Deno) the SDK auto-spawns the bundled
|
|
@@ -107,11 +107,9 @@ const mw = new Mindwire({
|
|
|
107
107
|
await mw.ensure(); // resolves once the daemon is healthy; then turns stream as usual
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
Binary discovery for the `local` daemon, in order: the `bin` option → `$MINDWIRE_DAEMON` →
|
|
111
|
-
the
|
|
112
|
-
|
|
113
|
-
`mindwired` on `PATH`. For local dev without the prebuilt package, set `$MINDWIRE_DAEMON` to a
|
|
114
|
-
`go build`-produced binary.
|
|
110
|
+
Binary discovery for the `local` daemon, in order: the `bin` option → `$MINDWIRE_DAEMON` → a
|
|
111
|
+
verified SDK-matched binary downloaded from the GitHub Release → `mindwired` on `PATH`. For local
|
|
112
|
+
development, set `$MINDWIRE_DAEMON` to a `go build`-produced binary.
|
|
115
113
|
|
|
116
114
|
`ssh` / `docker` / `oblien` require an optional peer (`ssh2` / `dockerode` / `oblien`) — install only
|
|
117
115
|
the one you use. Importing `mindwire` never loads them.
|
|
@@ -180,12 +178,6 @@ bun install
|
|
|
180
178
|
bun run build # tsup → dist (ESM + CJS + .d.ts)
|
|
181
179
|
bun run typecheck # tsc --noEmit
|
|
182
180
|
bun test # client + SSE parser tests (mocked fetch)
|
|
183
|
-
bun run build:daemon # cross-compile mindwired → npm/mindwire-daemon-<platform>-<arch>/ (needs Go)
|
|
184
181
|
```
|
|
185
182
|
|
|
186
|
-
`build:daemon` produces the per-platform daemon packages and syncs the main package's
|
|
187
|
-
`optionalDependencies`. **Release order:** publish every `npm/mindwire-daemon-*` package first,
|
|
188
|
-
then publish `mindwire` — its optional dependencies must already exist on the registry at the
|
|
189
|
-
same version.
|
|
190
|
-
|
|
191
183
|
License: Apache-2.0.
|
package/dist/index.cjs
CHANGED
|
@@ -469,7 +469,7 @@ var Run = class _Run {
|
|
|
469
469
|
};
|
|
470
470
|
|
|
471
471
|
// src/version.ts
|
|
472
|
-
var SDK_VERSION = "0.1.
|
|
472
|
+
var SDK_VERSION = "0.1.2" ;
|
|
473
473
|
|
|
474
474
|
// src/daemon-binary.ts
|
|
475
475
|
function supported(platform, arch) {
|
|
@@ -645,7 +645,7 @@ function daemonStartError(resolved, cause) {
|
|
|
645
645
|
" \u2022 check GitHub Release access so the SDK can download its matching daemon binary; or",
|
|
646
646
|
" \u2022 set MINDWIRE_DAEMON to a `mindwired` binary; or",
|
|
647
647
|
" \u2022 pass { baseUrl } to connect to a daemon you run yourself.",
|
|
648
|
-
" \u2022 Working inside the mindwire monorepo? Run `
|
|
648
|
+
" \u2022 Working inside the mindwire monorepo? Run `go build -o /tmp/mindwired ./daemon/cmd/daemon` and set MINDWIRE_DAEMON.",
|
|
649
649
|
`(underlying error: ${cause.message})`
|
|
650
650
|
].join("\n");
|
|
651
651
|
}
|
|
@@ -1917,6 +1917,7 @@ function docker(config = {}) {
|
|
|
1917
1917
|
var DEFAULT_PORT2 = 8790;
|
|
1918
1918
|
var DEFAULT_AGENT2 = "claude-code";
|
|
1919
1919
|
var DEFAULT_AGENT_CWD2 = "/root";
|
|
1920
|
+
var DEFAULT_RUNTIME_IMAGE = `ghcr.io/oblien/mindwire-runtime:${SDK_VERSION}`;
|
|
1920
1921
|
var DockerHost = class {
|
|
1921
1922
|
constructor(container) {
|
|
1922
1923
|
this.container = container;
|
|
@@ -1971,15 +1972,14 @@ async function provisionDocker(docker2, config = {}, onLog) {
|
|
|
1971
1972
|
if (config.container !== void 0) {
|
|
1972
1973
|
container = docker2.getContainer(config.container);
|
|
1973
1974
|
} else {
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
"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."
|
|
1977
|
-
);
|
|
1978
|
-
}
|
|
1975
|
+
const image = config.image ?? DEFAULT_RUNTIME_IMAGE;
|
|
1976
|
+
await ensureImage(docker2, image, config.pull ?? "missing", onLog);
|
|
1979
1977
|
const portKey = `${port}/tcp`;
|
|
1980
1978
|
container = await docker2.createContainer({
|
|
1981
|
-
|
|
1982
|
-
|
|
1979
|
+
// The runtime image starts mindwired itself. Do not replace its command: doing so turns the
|
|
1980
|
+
// image ENTRYPOINT into `mindwired sleep infinity` and prevents the runtime from starting.
|
|
1981
|
+
Image: image,
|
|
1982
|
+
Env: [`ADDR=:${port}`, `AGENT_TYPE=${agent}`, `AGENT_CWD=${agentCwd}`],
|
|
1983
1983
|
Tty: false,
|
|
1984
1984
|
ExposedPorts: { [portKey]: {} },
|
|
1985
1985
|
HostConfig: { PortBindings: { [portKey]: [{ HostPort: "0" }] } },
|
|
@@ -2017,6 +2017,36 @@ async function provisionDocker(docker2, config = {}, onLog) {
|
|
|
2017
2017
|
};
|
|
2018
2018
|
return { id: container.id, baseUrl: `http://127.0.0.1:${hostPort}`, stop };
|
|
2019
2019
|
}
|
|
2020
|
+
async function ensureImage(docker2, image, policy, onLog) {
|
|
2021
|
+
const emit2 = (message, error) => {
|
|
2022
|
+
try {
|
|
2023
|
+
onLog?.({ phase: "pull", target: "docker", message, ...error ? { error } : {} });
|
|
2024
|
+
} catch {
|
|
2025
|
+
}
|
|
2026
|
+
};
|
|
2027
|
+
if (policy === "never") return;
|
|
2028
|
+
if (policy === "missing") {
|
|
2029
|
+
try {
|
|
2030
|
+
await docker2.getImage(image).inspect();
|
|
2031
|
+
return;
|
|
2032
|
+
} catch {
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
emit2(`pulling runtime image ${image}`);
|
|
2036
|
+
try {
|
|
2037
|
+
const stream = await docker2.pull(image);
|
|
2038
|
+
await new Promise((resolve, reject) => {
|
|
2039
|
+
stream.on("end", () => resolve());
|
|
2040
|
+
stream.on("close", () => resolve());
|
|
2041
|
+
stream.on("error", (error) => reject(error));
|
|
2042
|
+
});
|
|
2043
|
+
emit2(`runtime image ready: ${image}`);
|
|
2044
|
+
} catch (error) {
|
|
2045
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
2046
|
+
emit2(`failed to pull runtime image ${image}`, detail);
|
|
2047
|
+
throw new MindwireError(`mindwire: failed to pull Docker image ${image}: ${detail}`, { cause: error });
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2020
2050
|
function tarSingleFile(name, data, mode) {
|
|
2021
2051
|
const header = Buffer.alloc(512, 0);
|
|
2022
2052
|
header.write(name.slice(0, 100), 0, "utf8");
|