peaks-loop-internal-runtime 0.0.1 → 0.0.4

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 Peaks 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.
@@ -1,3 +1,4 @@
1
+ import type { ChildProcess } from 'node:child_process';
1
2
  export interface DispatchInput {
2
3
  sid: string;
3
4
  rid: string;
@@ -13,6 +14,7 @@ export interface DispatchInput {
13
14
  export interface DispatchResult {
14
15
  pid: number;
15
16
  dispatchRecordPath: string;
17
+ child?: ChildProcess;
16
18
  }
17
19
  export declare function dispatchDetached(i: DispatchInput): Promise<DispatchResult>;
18
20
  //# sourceMappingURL=dispatch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mapp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C;IAAC,kBAAkB,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,YAAY,CAAC;CAAE;AAElG,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAkChF"}
package/dist/dispatch.js CHANGED
@@ -36,5 +36,5 @@ export async function dispatchDetached(i) {
36
36
  rid: i.rid, mode: 'detached', vendor: i.vendor,
37
37
  status: 'running', heartbeats: [], at: Date.now(),
38
38
  }, null, 2));
39
- return { pid: handle.pid, dispatchRecordPath: recPath };
39
+ return { pid: handle.pid, dispatchRecordPath: recPath, child: handle.child };
40
40
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export declare const RUNTIME_VERSION = "4.0.19";
1
+ export declare const RUNTIME_VERSION = "4.0.22";
2
+ export declare const RUNTIME_NPM_VERSION = "0.0.3";
2
3
  export { ClaudeAdapter } from './vendor/claude-adapter.js';
3
4
  export { CodexAdapter } from './vendor/codex-adapter.js';
4
5
  export { CopilotAdapter } from './vendor/copilot-adapter.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC9E,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAA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4 +1,12 @@
1
- export const RUNTIME_VERSION = '4.0.19';
1
+ // API contract: RUNTIME_VERSION tracks peaks-loop root version (4.0.x).
2
+ // This is what consumers (sub-agents dispatched by peaks-code) check at
3
+ // runtime to verify protocol compatibility.
4
+ export const RUNTIME_VERSION = '4.0.22';
5
+ // npm version: independent 0.0.x SemVer. Runtime is its own package
6
+ // (peaks-loop-internal-runtime@NPM_VERSION) on the registry; bumps
7
+ // per peaks release notes when its public surface actually changes
8
+ // (not per root version bump).
9
+ export const RUNTIME_NPM_VERSION = '0.0.3';
2
10
  export { ClaudeAdapter } from './vendor/claude-adapter.js';
3
11
  export { CodexAdapter } from './vendor/codex-adapter.js';
4
12
  export { CopilotAdapter } from './vendor/copilot-adapter.js';
@@ -1 +1 @@
1
- {"version":3,"file":"claude-adapter.d.ts","sourceRoot":"","sources":["../../src/vendor/claude-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,qBAAa,aAAc,YAAW,aAAa;IACjD,QAAQ,CAAC,EAAE,EAAG,QAAQ,CAAU;IAChC,QAAQ,CAAC,MAAM,YAAY;IAC3B,QAAQ,CAAC,cAAc,SAAY;IAEnC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE;IAO7E,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAe7C,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;CAM1C"}
1
+ {"version":3,"file":"claude-adapter.d.ts","sourceRoot":"","sources":["../../src/vendor/claude-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,qBAAa,aAAc,YAAW,aAAa;IACjD,QAAQ,CAAC,EAAE,EAAG,QAAQ,CAAU;IAChC,QAAQ,CAAC,MAAM,YAAY;IAC3B,QAAQ,CAAC,cAAc,SAAY;IAEnC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE;IAO7E,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAe7C,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;CAG1C"}
@@ -1,6 +1,4 @@
1
- import { execFile } from 'node:child_process';
2
- import { promisify } from 'node:util';
3
- const pExecFile = promisify(execFile);
1
+ import { detectBinaryInstalled } from './detect-binary.js';
4
2
  export class ClaudeAdapter {
5
3
  id = 'claude';
6
4
  binary = 'claude';
@@ -30,12 +28,6 @@ export class ClaudeAdapter {
30
28
  }
31
29
  }
32
30
  async detectInstalled() {
33
- try {
34
- const { stdout } = await pExecFile(this.binary, ['--version'], { timeout: 3000 });
35
- return stdout.length > 0;
36
- }
37
- catch {
38
- return false;
39
- }
31
+ return detectBinaryInstalled(this.binary);
40
32
  }
41
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"codex-adapter.d.ts","sourceRoot":"","sources":["../../src/vendor/codex-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,qBAAa,YAAa,YAAW,aAAa;IAChD,QAAQ,CAAC,EAAE,EAAG,OAAO,CAAU;IAC/B,QAAQ,CAAC,MAAM,WAAW;IAC1B,QAAQ,CAAC,cAAc,SAAY;IACnC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAGtC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAO7C,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;CAI1C"}
1
+ {"version":3,"file":"codex-adapter.d.ts","sourceRoot":"","sources":["../../src/vendor/codex-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,qBAAa,YAAa,YAAW,aAAa;IAChD,QAAQ,CAAC,EAAE,EAAG,OAAO,CAAU;IAC/B,QAAQ,CAAC,MAAM,WAAW;IAC1B,QAAQ,CAAC,cAAc,SAAY;IACnC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAGtC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAO7C,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;CAG1C"}
@@ -1,6 +1,4 @@
1
- import { execFile } from 'node:child_process';
2
- import { promisify } from 'node:util';
3
- const pExecFile = promisify(execFile);
1
+ import { detectBinaryInstalled } from './detect-binary.js';
4
2
  export class CodexAdapter {
5
3
  id = 'codex';
6
4
  binary = 'codex';
@@ -20,12 +18,6 @@ export class CodexAdapter {
20
18
  }
21
19
  }
22
20
  async detectInstalled() {
23
- try {
24
- const { stdout } = await pExecFile(this.binary, ['--version'], { timeout: 3000 });
25
- return stdout.length > 0;
26
- }
27
- catch {
28
- return false;
29
- }
21
+ return detectBinaryInstalled(this.binary);
30
22
  }
31
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"copilot-adapter.d.ts","sourceRoot":"","sources":["../../src/vendor/copilot-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,qBAAa,cAAe,YAAW,aAAa;IAClD,QAAQ,CAAC,EAAE,EAAG,SAAS,CAAU;IACjC,QAAQ,CAAC,MAAM,aAAa;IAC5B,QAAQ,CAAC,cAAc,SAAY;IACnC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IACtC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAO7C,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;CAI1C"}
1
+ {"version":3,"file":"copilot-adapter.d.ts","sourceRoot":"","sources":["../../src/vendor/copilot-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,qBAAa,cAAe,YAAW,aAAa;IAClD,QAAQ,CAAC,EAAE,EAAG,SAAS,CAAU;IACjC,QAAQ,CAAC,MAAM,aAAa;IAC5B,QAAQ,CAAC,cAAc,SAAY;IACnC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IACtC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAO7C,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;CAG1C"}
@@ -1,6 +1,4 @@
1
- import { execFile } from 'node:child_process';
2
- import { promisify } from 'node:util';
3
- const pExecFile = promisify(execFile);
1
+ import { detectBinaryInstalled } from './detect-binary.js';
4
2
  export class CopilotAdapter {
5
3
  id = 'copilot';
6
4
  binary = 'copilot';
@@ -18,12 +16,6 @@ export class CopilotAdapter {
18
16
  }
19
17
  }
20
18
  async detectInstalled() {
21
- try {
22
- const { stdout } = await pExecFile(this.binary, ['--version'], { timeout: 3000 });
23
- return stdout.length > 0;
24
- }
25
- catch {
26
- return false;
27
- }
19
+ return detectBinaryInstalled(this.binary);
28
20
  }
29
21
  }
@@ -0,0 +1,3 @@
1
+ /** Resolve a binary through the platform's PATH lookup without invoking a shell. */
2
+ export declare function detectBinaryInstalled(binary: string): Promise<boolean>;
3
+ //# sourceMappingURL=detect-binary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-binary.d.ts","sourceRoot":"","sources":["../../src/vendor/detect-binary.ts"],"names":[],"mappings":"AAIA,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQtE"}
@@ -0,0 +1,11 @@
1
+ import { execFile } from 'node:child_process';
2
+ const DETECT_TIMEOUT_MS = 3000;
3
+ /** Resolve a binary through the platform's PATH lookup without invoking a shell. */
4
+ export function detectBinaryInstalled(binary) {
5
+ const locator = process.platform === 'win32' ? 'where.exe' : 'which';
6
+ return new Promise((resolve) => {
7
+ execFile(locator, [binary], { timeout: DETECT_TIMEOUT_MS }, (error, stdout) => {
8
+ resolve(error === null && stdout.trim().length > 0);
9
+ });
10
+ });
11
+ }
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "peaks-loop-internal-runtime",
3
- "version": "0.0.1",
3
+ "version": "0.0.4",
4
4
  "description": "Detached sub-agent runtime: ProcessSupervisor + LifecycleOwner + VendorAdapter (claude/codex/copilot) + G8 infinite-context auto-compact. Slice 2026-08-10.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/SquabbyZ/peaks-loop"
8
+ },
5
9
  "type": "module",
6
10
  "main": "./dist/index.js",
7
11
  "types": "./dist/index.d.ts",
@@ -11,15 +15,15 @@
11
15
  "publishConfig": {
12
16
  "access": "public"
13
17
  },
14
- "scripts": {
15
- "build": "tsc -p tsconfig.json",
16
- "test": "vitest run tests/unit/runtime"
17
- },
18
18
  "peerDependencies": {
19
- "peaks-loop-shared": "workspace:*"
19
+ "peaks-loop-shared": "0.0.53"
20
20
  },
21
21
  "devDependencies": {
22
22
  "typescript": "^5.4.0",
23
23
  "vitest": "4.1.10"
24
+ },
25
+ "scripts": {
26
+ "build": "tsc -p tsconfig.json",
27
+ "test": "vitest run tests/unit/runtime"
24
28
  }
25
- }
29
+ }
package/src/dispatch.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { writeFileSync, mkdirSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
+ import type { ChildProcess } from 'node:child_process';
3
4
  import { ProcessSupervisor } from './process-supervisor.js';
4
5
  import { LifecycleOwner } from './lifecycle.js';
5
6
  import { VendorAdapterRegistry } from './vendor/registry.js';
@@ -18,7 +19,7 @@ export interface DispatchInput {
18
19
  runtimeDir: string; subAgentsDir: string;
19
20
  verbatimBlocks?: string[];
20
21
  }
21
- export interface DispatchResult { pid: number; dispatchRecordPath: string; }
22
+ export interface DispatchResult { pid: number; dispatchRecordPath: string; child?: ChildProcess; }
22
23
 
23
24
  export async function dispatchDetached(i: DispatchInput): Promise<DispatchResult> {
24
25
  const registry = new VendorAdapterRegistry([new ClaudeAdapter(), new CodexAdapter(), new CopilotAdapter()]);
@@ -53,5 +54,5 @@ export async function dispatchDetached(i: DispatchInput): Promise<DispatchResult
53
54
  status: 'running', heartbeats: [], at: Date.now(),
54
55
  }, null, 2));
55
56
 
56
- return { pid: handle.pid, dispatchRecordPath: recPath };
57
+ return { pid: handle.pid, dispatchRecordPath: recPath, child: handle.child };
57
58
  }
package/src/index.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  // API contract: RUNTIME_VERSION tracks peaks-loop root version (4.0.x).
2
2
  // This is what consumers (sub-agents dispatched by peaks-code) check at
3
3
  // runtime to verify protocol compatibility.
4
- export const RUNTIME_VERSION = '4.0.20';
4
+ export const RUNTIME_VERSION = '4.0.22';
5
5
 
6
6
  // npm version: independent 0.0.x SemVer. Runtime is its own package
7
7
  // (peaks-loop-internal-runtime@NPM_VERSION) on the registry; bumps
8
8
  // per peaks release notes when its public surface actually changes
9
9
  // (not per root version bump).
10
- export const RUNTIME_NPM_VERSION = '0.0.1';
10
+ export const RUNTIME_NPM_VERSION = '0.0.3';
11
11
  export { ClaudeAdapter } from './vendor/claude-adapter.js';
12
12
  export { CodexAdapter } from './vendor/codex-adapter.js';
13
13
  export { CopilotAdapter } from './vendor/copilot-adapter.js';
@@ -1,9 +1,6 @@
1
- import { execFile } from 'node:child_process';
2
- import { promisify } from 'node:util';
3
1
  import type { VendorAdapter } from './adapter.js';
4
2
  import type { ChildStatus } from '../types.js';
5
-
6
- const pExecFile = promisify(execFile);
3
+ import { detectBinaryInstalled } from './detect-binary.js';
7
4
 
8
5
  export class ClaudeAdapter implements VendorAdapter {
9
6
  readonly id = 'claude' as const;
@@ -33,9 +30,6 @@ export class ClaudeAdapter implements VendorAdapter {
33
30
  }
34
31
 
35
32
  async detectInstalled(): Promise<boolean> {
36
- try {
37
- const { stdout } = await pExecFile(this.binary, ['--version'], { timeout: 3000 });
38
- return stdout.length > 0;
39
- } catch { return false; }
33
+ return detectBinaryInstalled(this.binary);
40
34
  }
41
35
  }
@@ -1,8 +1,6 @@
1
- import { execFile } from 'node:child_process';
2
- import { promisify } from 'node:util';
3
1
  import type { VendorAdapter } from './adapter.js';
4
2
  import type { ChildStatus } from '../types.js';
5
- const pExecFile = promisify(execFile);
3
+ import { detectBinaryInstalled } from './detect-binary.js';
6
4
 
7
5
  export class CodexAdapter implements VendorAdapter {
8
6
  readonly id = 'codex' as const;
@@ -19,7 +17,6 @@ export class CodexAdapter implements VendorAdapter {
19
17
  } catch { return null; }
20
18
  }
21
19
  async detectInstalled(): Promise<boolean> {
22
- try { const { stdout } = await pExecFile(this.binary, ['--version'], { timeout: 3000 }); return stdout.length > 0; }
23
- catch { return false; }
20
+ return detectBinaryInstalled(this.binary);
24
21
  }
25
22
  }
@@ -1,8 +1,6 @@
1
- import { execFile } from 'node:child_process';
2
- import { promisify } from 'node:util';
3
1
  import type { VendorAdapter } from './adapter.js';
4
2
  import type { ChildStatus } from '../types.js';
5
- const pExecFile = promisify(execFile);
3
+ import { detectBinaryInstalled } from './detect-binary.js';
6
4
 
7
5
  export class CopilotAdapter implements VendorAdapter {
8
6
  readonly id = 'copilot' as const;
@@ -17,7 +15,6 @@ export class CopilotAdapter implements VendorAdapter {
17
15
  } catch { return null; }
18
16
  }
19
17
  async detectInstalled(): Promise<boolean> {
20
- try { const { stdout } = await pExecFile(this.binary, ['--version'], { timeout: 3000 }); return stdout.length > 0; }
21
- catch { return false; }
18
+ return detectBinaryInstalled(this.binary);
22
19
  }
23
20
  }
@@ -0,0 +1,14 @@
1
+ import { execFile } from 'node:child_process';
2
+
3
+ const DETECT_TIMEOUT_MS = 3000;
4
+
5
+ /** Resolve a binary through the platform's PATH lookup without invoking a shell. */
6
+ export function detectBinaryInstalled(binary: string): Promise<boolean> {
7
+ const locator = process.platform === 'win32' ? 'where.exe' : 'which';
8
+
9
+ return new Promise((resolve) => {
10
+ execFile(locator, [binary], { timeout: DETECT_TIMEOUT_MS }, (error, stdout) => {
11
+ resolve(error === null && stdout.trim().length > 0);
12
+ });
13
+ });
14
+ }