@agent-controller/runtime 0.3.1
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 +21 -0
- package/README.md +98 -0
- package/dist/adapter.d.ts +23 -0
- package/dist/adapter.js +980 -0
- package/dist/honesty.d.ts +59 -0
- package/dist/honesty.js +226 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +40 -0
- package/dist/testing/fake-provider.d.ts +60 -0
- package/dist/testing/fake-provider.js +170 -0
- package/dist/types.d.ts +112 -0
- package/dist/types.js +2 -0
- package/dist/wire.d.ts +5 -0
- package/dist/wire.js +8 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CCDevelopForFun
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# `@agent-controller/runtime` — Pi runtime adapter
|
|
2
|
+
|
|
3
|
+
Node/TypeScript adapter that runs an [agent-controller](https://github.com/CCDevelopForFun/agent-controller) `CompiledSpec` against a Pi session and emits the NDJSON wire-event stream that `agentctl` consumes. This is the original / production adapter; the opencode adapter ([`@agent-controller/runtime-opencode`](https://www.npmjs.com/package/@agent-controller/runtime-opencode)) is the v0.2 sibling.
|
|
4
|
+
|
|
5
|
+
Requires **Node 22.19.0+** — `@earendil-works/pi-ai` and `@earendil-works/pi-coding-agent` declare `engines.node: ">=22.19.0"` (the nested `undici` they ship needs that floor). Older Node 22.x will install but is outside the supported range.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @agent-controller/runtime
|
|
11
|
+
# or per-project
|
|
12
|
+
npm install --save-dev @agent-controller/runtime
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Use with `agentctl`
|
|
16
|
+
|
|
17
|
+
`agentctl` (the Go CLI) spawns this package as a subprocess. The example specs under [`examples/`](https://github.com/CCDevelopForFun/agent-controller/tree/main/examples) reference cwd-relative registry entries (`tools/`, `extensions/`, `skills/`, `agents/`) that ship with the source repo but not with this npm package. For an npm-only install, use a self-contained spec:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# 1) Write a self-contained spec (no tools[]/extensions[]/skills[]/subagents[])
|
|
21
|
+
cat > /tmp/hello.yaml <<'EOF'
|
|
22
|
+
apiVersion: agent-controller.dev/v1alpha1
|
|
23
|
+
kind: Agent
|
|
24
|
+
metadata: { name: hello }
|
|
25
|
+
spec:
|
|
26
|
+
model: { provider: anthropic, name: claude-sonnet-4-20250514 }
|
|
27
|
+
persona: { role: Helpful demo, instructions: Answer concisely. }
|
|
28
|
+
task: Say hello.
|
|
29
|
+
tools: []
|
|
30
|
+
runtime: { type: local }
|
|
31
|
+
EOF
|
|
32
|
+
|
|
33
|
+
# 2) Point agentctl at the adapter and run
|
|
34
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
35
|
+
|
|
36
|
+
# global install
|
|
37
|
+
AGENT_CONTROLLER_RUNTIME="$(npm root -g)/@agent-controller/runtime/dist/index.js" \
|
|
38
|
+
agentctl run /tmp/hello.yaml
|
|
39
|
+
|
|
40
|
+
# or per-project (from a directory with the package in node_modules)
|
|
41
|
+
AGENT_CONTROLLER_RUNTIME="./node_modules/@agent-controller/runtime/dist/index.js" \
|
|
42
|
+
agentctl run /tmp/hello.yaml
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Without `AGENT_CONTROLLER_RUNTIME`, `agentctl run` looks under `<cwd>/runtime/dist/index.js` — the source-clone-and-build install path.
|
|
46
|
+
|
|
47
|
+
`agentctl` (matching version) is available from the [GitHub Releases page](https://github.com/CCDevelopForFun/agent-controller/releases) as cross-platform binaries.
|
|
48
|
+
|
|
49
|
+
## Architecture role
|
|
50
|
+
|
|
51
|
+
This package is the **subprocess** spawned by `agentctl run` when `spec.runtime.type` is `local` or `local-pi`. It:
|
|
52
|
+
|
|
53
|
+
1. Reads a `CompiledSpec` JSON document from stdin
|
|
54
|
+
2. Constructs Pi's `DefaultResourceLoader` from the spec (skills paths, agent files, MCP config)
|
|
55
|
+
3. Materializes `<cwd>/.pi/mcp.json` and `<cwd>/.pi/agents/*.md` for Pi's loaders
|
|
56
|
+
4. Auto-installs `spec.extensions[].source` packages on demand
|
|
57
|
+
5. Builds the system prompt: honesty preamble + persona + role + skill bodies
|
|
58
|
+
6. Calls `createAgentSession` + `session.prompt`
|
|
59
|
+
7. Translates Pi's internal events into the wire-protocol NDJSON envelope
|
|
60
|
+
8. Runs the runtime-side hallucination detector on assistant messages
|
|
61
|
+
|
|
62
|
+
## Environment variables
|
|
63
|
+
|
|
64
|
+
| Variable | Effect |
|
|
65
|
+
|---|---|
|
|
66
|
+
| `AGENT_CONTROLLER_EXT_CONFIG` | Per-extension config blob (set by adapter from `spec.extensions[].config`) |
|
|
67
|
+
| `AGENT_CONTROLLER_USE_FAKE_PROVIDER` | If `1`, the adapter loads the test fake-provider before starting the session (Layer-1 E2E only) |
|
|
68
|
+
| `AGENT_CONTROLLER_NO_AUTO_INSTALL` | If `1`, auto-installation of `spec.extensions[].source` is disabled; missing packages fail fast |
|
|
69
|
+
| `ANTHROPIC_BASE_URL` | Forwarded to Pi for model gateway override |
|
|
70
|
+
| `AC_PI_BIN` | Path to the `pi` CLI for subagent process spawning (set by the adapter when subagents exist) |
|
|
71
|
+
| `PI_CODING_AGENT_DIR` | Pi's project-local config dir; isolated under a temp dir in tests |
|
|
72
|
+
|
|
73
|
+
## What this adapter does NOT cover
|
|
74
|
+
|
|
75
|
+
- opencode-style native subagents — see [`@agent-controller/runtime-opencode`](https://www.npmjs.com/package/@agent-controller/runtime-opencode)
|
|
76
|
+
- Kubernetes / remote execution — planned v0.4 via the `Backend` interface in the CLI
|
|
77
|
+
|
|
78
|
+
## Building from source
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
git clone https://github.com/CCDevelopForFun/agent-controller.git
|
|
82
|
+
cd agent-controller/runtime
|
|
83
|
+
npm install --ignore-scripts
|
|
84
|
+
npm run build # tsc → dist/
|
|
85
|
+
npm test # vitest
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`--ignore-scripts` is important: Pi's nested install hook will otherwise try to set up the user's `~/.pi` directory.
|
|
89
|
+
|
|
90
|
+
## Cross-references
|
|
91
|
+
|
|
92
|
+
- [agent-controller README](https://github.com/CCDevelopForFun/agent-controller#readme) — project overview + quickstart
|
|
93
|
+
- [Dual-adapter architecture overview](https://github.com/CCDevelopForFun/agent-controller/blob/main/docs/architecture/overview.md)
|
|
94
|
+
- [Harness capability matrix](https://github.com/CCDevelopForFun/agent-controller/blob/main/docs/architecture/harness-matrix.md) — per-feature support table
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT — see [LICENSE](https://github.com/CCDevelopForFun/agent-controller/blob/main/LICENSE).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CompiledSpec, WireEvent } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a source-bound extension: install it if needed, read its
|
|
4
|
+
* pi.extensions manifest, and return the absolute entrypoint path.
|
|
5
|
+
*
|
|
6
|
+
* @param source — e.g. "npm:pi-mcp-extension"
|
|
7
|
+
* @returns absolute path to the extension entrypoint
|
|
8
|
+
* @throws when source scheme is unsupported, pi is missing, install fails,
|
|
9
|
+
* or the package declares no extensions
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveSourceBoundExtension(source: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* runSession assembles a Pi session from the CompiledSpec, subscribes to
|
|
14
|
+
* its events, submits the task as the initial prompt, and resolves when
|
|
15
|
+
* the session ends. emit is invoked once per outgoing wire event.
|
|
16
|
+
*
|
|
17
|
+
* Extension configuration is passed to extensions via the
|
|
18
|
+
* AGENT_CONTROLLER_EXT_CONFIG env var (JSON object keyed by extension name).
|
|
19
|
+
* This is a deliberate MVP convention; v0.2 will migrate to Pi's
|
|
20
|
+
* settingsManager once that API stabilizes (tracked in spec §12 research
|
|
21
|
+
* item 5).
|
|
22
|
+
*/
|
|
23
|
+
export declare function runSession(spec: CompiledSpec, emit: (ev: WireEvent) => void): Promise<void>;
|