@zooid/runtime-local 0.7.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zooid contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,12 @@
1
+ import { ChildProcess } from 'node:child_process';
2
+ import { AcpRuntime, AcpSpawnSpec } from '@zooid/core';
3
+
4
+ /**
5
+ * LocalAcpRuntime spawns the ACP shim process directly on the host. No
6
+ * container, no isolation. `image` and `mounts` on the spec are ignored.
7
+ */
8
+ declare class LocalAcpRuntime implements AcpRuntime {
9
+ spawn(spec: AcpSpawnSpec): ChildProcess;
10
+ }
11
+
12
+ export { LocalAcpRuntime };
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ // src/local-acp.ts
2
+ import { spawn } from "child_process";
3
+ var LocalAcpRuntime = class {
4
+ spawn(spec) {
5
+ return spawn(spec.command, spec.args, {
6
+ stdio: ["pipe", "pipe", "pipe"],
7
+ env: { ...process.env, ...spec.env ?? {} },
8
+ cwd: spec.cwd
9
+ });
10
+ }
11
+ };
12
+ export {
13
+ LocalAcpRuntime
14
+ };
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/local-acp.ts"],"sourcesContent":["import { spawn, type ChildProcess } from 'node:child_process'\nimport type { AcpRuntime, AcpSpawnSpec } from '@zooid/core'\n\n/**\n * LocalAcpRuntime spawns the ACP shim process directly on the host. No\n * container, no isolation. `image` and `mounts` on the spec are ignored.\n */\nexport class LocalAcpRuntime implements AcpRuntime {\n spawn(spec: AcpSpawnSpec): ChildProcess {\n return spawn(spec.command, spec.args, {\n stdio: ['pipe', 'pipe', 'pipe'],\n env: { ...process.env, ...(spec.env ?? {}) },\n cwd: spec.cwd,\n })\n }\n}\n"],"mappings":";AAAA,SAAS,aAAgC;AAOlC,IAAM,kBAAN,MAA4C;AAAA,EACjD,MAAM,MAAkC;AACtC,WAAO,MAAM,KAAK,SAAS,KAAK,MAAM;AAAA,MACpC,OAAO,CAAC,QAAQ,QAAQ,MAAM;AAAA,MAC9B,KAAK,EAAE,GAAG,QAAQ,KAAK,GAAI,KAAK,OAAO,CAAC,EAAG;AAAA,MAC3C,KAAK,KAAK;AAAA,IACZ,CAAC;AAAA,EACH;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@zooid/runtime-local",
3
+ "version": "0.7.0",
4
+ "description": "Local (host machine) runtime for zooid. Spawns the agent CLI directly via node:child_process.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "main": "./src/index.ts",
8
+ "types": "./src/index.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./src/index.ts",
12
+ "import": "./src/index.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src",
18
+ "README.md"
19
+ ],
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "engines": {
24
+ "node": ">=22"
25
+ },
26
+ "dependencies": {
27
+ "@zooid/core": "^0.7.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^22.0.0",
31
+ "tsup": "^8.5.1",
32
+ "tsx": "^4.21.0",
33
+ "typescript": "^5.5.0",
34
+ "vitest": "^3.2.0",
35
+ "@zooid/acp-client": "^0.7.0"
36
+ },
37
+ "scripts": {
38
+ "build": "tsup",
39
+ "test": "vitest run",
40
+ "test:watch": "vitest",
41
+ "typecheck": "tsc --noEmit"
42
+ }
43
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { LocalAcpRuntime } from './local-acp.js'
@@ -0,0 +1,83 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
2
+ import { EventEmitter } from 'node:events'
3
+ import { Readable, Writable } from 'node:stream'
4
+
5
+ const spawnMock = vi.fn()
6
+
7
+ vi.mock('node:child_process', () => ({
8
+ spawn: spawnMock,
9
+ }))
10
+
11
+ const { LocalAcpRuntime } = await import('./local-acp.js')
12
+
13
+ class FakeChild extends EventEmitter {
14
+ stdout = new Readable({ read() {} })
15
+ stdin = new Writable({ write(_c, _e, cb) { cb() } })
16
+ stderr = new Readable({ read() {} })
17
+ pid = 1
18
+ kill = vi.fn(() => true)
19
+ }
20
+
21
+ describe('LocalAcpRuntime', () => {
22
+ beforeEach(() => {
23
+ spawnMock.mockReset()
24
+ spawnMock.mockReturnValue(new FakeChild())
25
+ })
26
+ afterEach(() => {
27
+ vi.restoreAllMocks()
28
+ })
29
+
30
+ it('spawns command + args verbatim with piped stdio', () => {
31
+ const rt = new LocalAcpRuntime()
32
+ rt.spawn({ command: 'opencode', args: ['acp'] })
33
+ expect(spawnMock).toHaveBeenCalledTimes(1)
34
+ const [cmd, args, options] = spawnMock.mock.calls[0]
35
+ expect(cmd).toBe('opencode')
36
+ expect(args).toEqual(['acp'])
37
+ expect(options.stdio).toEqual(['pipe', 'pipe', 'pipe'])
38
+ })
39
+
40
+ it('forwards cwd', () => {
41
+ const rt = new LocalAcpRuntime()
42
+ rt.spawn({ command: 'x', args: [], cwd: '/workspace' })
43
+ expect(spawnMock.mock.calls[0][2].cwd).toBe('/workspace')
44
+ })
45
+
46
+ it('merges process.env first, spec.env wins', () => {
47
+ process.env.FROM_PARENT = 'yes'
48
+ process.env.OVERRIDE_ME = 'parent'
49
+ const rt = new LocalAcpRuntime()
50
+ rt.spawn({
51
+ command: 'x',
52
+ args: [],
53
+ env: { OVERRIDE_ME: 'spec', EXTRA: '1' },
54
+ })
55
+ const env = spawnMock.mock.calls[0][2].env
56
+ expect(env.FROM_PARENT).toBe('yes')
57
+ expect(env.OVERRIDE_ME).toBe('spec')
58
+ expect(env.EXTRA).toBe('1')
59
+ delete process.env.FROM_PARENT
60
+ delete process.env.OVERRIDE_ME
61
+ })
62
+
63
+ it('ignores image and mounts on the spec (host runtime has no container)', () => {
64
+ const rt = new LocalAcpRuntime()
65
+ rt.spawn({
66
+ command: 'x',
67
+ args: [],
68
+ image: 'should-be-ignored',
69
+ mounts: [{ path: '/h', target: '/c', mode: 'ro' }],
70
+ })
71
+ const [cmd, args] = spawnMock.mock.calls[0]
72
+ expect(cmd).toBe('x')
73
+ expect(args).toEqual([])
74
+ })
75
+
76
+ it('returns the ChildProcess from spawn', () => {
77
+ const child = new FakeChild()
78
+ spawnMock.mockReturnValue(child)
79
+ const rt = new LocalAcpRuntime()
80
+ const result = rt.spawn({ command: 'x', args: [] })
81
+ expect(result).toBe(child)
82
+ })
83
+ })
@@ -0,0 +1,16 @@
1
+ import { spawn, type ChildProcess } from 'node:child_process'
2
+ import type { AcpRuntime, AcpSpawnSpec } from '@zooid/core'
3
+
4
+ /**
5
+ * LocalAcpRuntime spawns the ACP shim process directly on the host. No
6
+ * container, no isolation. `image` and `mounts` on the spec are ignored.
7
+ */
8
+ export class LocalAcpRuntime implements AcpRuntime {
9
+ spawn(spec: AcpSpawnSpec): ChildProcess {
10
+ return spawn(spec.command, spec.args, {
11
+ stdio: ['pipe', 'pipe', 'pipe'],
12
+ env: { ...process.env, ...(spec.env ?? {}) },
13
+ cwd: spec.cwd,
14
+ })
15
+ }
16
+ }