@agent-controller/runtime-opencode 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.
@@ -0,0 +1,112 @@
1
+ export interface CompiledSpec {
2
+ v: 1;
3
+ metadata: SpecMetadata;
4
+ model: Model;
5
+ persona?: Persona;
6
+ task: string;
7
+ tools: ResolvedRef[];
8
+ extensions: ResolvedRef[];
9
+ skills: ResolvedRef[];
10
+ mcpServers?: MCPServer[];
11
+ subagents?: ResolvedRef[];
12
+ /**
13
+ * Deprecated: use spec.extensions[].source instead.
14
+ * When non-empty the runtime emits a deprecation warning to stderr.
15
+ * Still passed through unchanged; `agentctl install --from` uses it.
16
+ */
17
+ installs?: string[];
18
+ runtime: RuntimeConfig;
19
+ guardrails?: Guardrails;
20
+ /** Set by CLI when user passes --resume <id>. Runtime opens/continues the named session. */
21
+ sessionId?: string;
22
+ }
23
+ /**
24
+ * Per-session safety guardrail configuration. Defaults are applied at use
25
+ * site in adapter.ts so this object can be `undefined` (no guardrails block
26
+ * in the spec) without forcing the compiler to materialize defaults.
27
+ */
28
+ export interface Guardrails {
29
+ /**
30
+ * How the runtime reacts when the assistant fabricates tool-call XML in
31
+ * its message body. Defaults to "block" when absent. See honesty.ts for
32
+ * the behavior of each mode.
33
+ */
34
+ hallucinationDetector?: HallucinationMode;
35
+ }
36
+ export type HallucinationMode = "warn" | "block" | "correct";
37
+ /** One MCP server declared in spec.mcpServers[]. Mirrors MCPServer in types.go. */
38
+ export interface MCPServer {
39
+ name: string;
40
+ transport: "stdio" | "streamable-http" | "sse";
41
+ lifecycle?: "eager" | "lazy";
42
+ command?: string;
43
+ args?: string[];
44
+ env?: Record<string, string>;
45
+ url?: string;
46
+ headers?: Record<string, string>;
47
+ }
48
+ export interface SpecMetadata {
49
+ name: string;
50
+ owner?: string;
51
+ description?: string;
52
+ }
53
+ export interface Model {
54
+ provider: "anthropic" | "openai" | "google";
55
+ name: string;
56
+ temperature?: number;
57
+ }
58
+ export interface Persona {
59
+ role?: string;
60
+ instructions?: string;
61
+ }
62
+ export interface ResolvedRef {
63
+ name: string;
64
+ /**
65
+ * Absolute path to the Pi extension entrypoint. Blank when source is
66
+ * set OR when builtin is true (Pi ships the implementation).
67
+ */
68
+ entrypoint?: string;
69
+ /**
70
+ * Pi-builtin tool (bash, read, edit, write). The runtime adds the name
71
+ * to Pi's tool allowlist without loading any entrypoint.
72
+ */
73
+ builtin?: boolean;
74
+ /**
75
+ * Self-install source, e.g. "npm:pi-mcp-extension".
76
+ * When set the runtime installs the package if missing and resolves
77
+ * the entrypoint from the package's pi.extensions manifest field.
78
+ * Only "npm:" prefix is supported at v0.1.6.
79
+ */
80
+ source?: string;
81
+ config?: Record<string, unknown>;
82
+ }
83
+ export interface RuntimeConfig {
84
+ /**
85
+ * Which adapter the CLI dispatches the CompiledSpec to. `local` is the
86
+ * v0.1.x legacy alias for `local-pi` (this Pi adapter) and remains
87
+ * accepted by the schema for backwards compatibility. `local-opencode`
88
+ * routes to the opencode adapter (runtime-opencode/), added in v0.2
89
+ * slice 2.1. Mirror of the enum in schemas/adl.v1alpha1.json.
90
+ */
91
+ type: "local" | "local-pi" | "local-opencode";
92
+ /**
93
+ * v0.3.1 additive field: free-form capability requirements the runtime
94
+ * must satisfy. Boolean flags consumed in two steps: v0.3.2 adds the
95
+ * RuntimeBinding schema (resource advertising what capabilities a
96
+ * target provides), and v0.3.3 wires Backend.Resolve() to compare the
97
+ * two. Today (v0.3.1) it passes through CompiledSpec unchanged and
98
+ * the opencode adapter does not act on it. Reserved well-known keys:
99
+ * streaming, sandbox, gpu, restrictedNetwork, ephemeralFilesystem.
100
+ * Arbitrary keys are accepted so capability bundles can advertise
101
+ * their own flags (e.g. spark, notebookContext).
102
+ */
103
+ requirements?: Record<string, boolean>;
104
+ }
105
+ export type WireEventType = "session.started" | "model.request" | "model.response" | "tool.call" | "tool.result" | "message" | "session.ended" | "warning" | "error";
106
+ export interface WireEvent<T = unknown> {
107
+ v: 1;
108
+ type: WireEventType;
109
+ ts: string;
110
+ sessionId: string;
111
+ data: T;
112
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ // Mirror of cli/internal/adl/types.go and the spec §6 stdin payload.
2
+ export {};
package/dist/wire.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { WireEvent, WireEventType } from "./types.js";
2
+ /** Build a wire envelope from a session id, event type, and payload. */
3
+ export declare function stamp<T>(sessionId: string, type: WireEventType, data: T): WireEvent<T>;
4
+ /** Write one wire event as a single NDJSON line via the provided writer. */
5
+ export declare function emit<T>(write: (s: string) => void, ev: WireEvent<T>): void;
package/dist/wire.js ADDED
@@ -0,0 +1,8 @@
1
+ /** Build a wire envelope from a session id, event type, and payload. */
2
+ export function stamp(sessionId, type, data) {
3
+ return { v: 1, type, ts: new Date().toISOString(), sessionId, data };
4
+ }
5
+ /** Write one wire event as a single NDJSON line via the provided writer. */
6
+ export function emit(write, ev) {
7
+ write(JSON.stringify(ev) + "\n");
8
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@agent-controller/runtime-opencode",
3
+ "version": "0.3.1",
4
+ "description": "opencode runtime adapter for agent-controller — runs an ADL CompiledSpec against an opencode session via @opencode-ai/sdk and emits the NDJSON wire-event stream.",
5
+ "keywords": [
6
+ "agent-controller",
7
+ "adl",
8
+ "opencode",
9
+ "agent",
10
+ "ai-agents",
11
+ "llm",
12
+ "anthropic",
13
+ "runtime-adapter"
14
+ ],
15
+ "homepage": "https://github.com/CCDevelopForFun/agent-controller#readme",
16
+ "bugs": "https://github.com/CCDevelopForFun/agent-controller/issues",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/CCDevelopForFun/agent-controller.git",
20
+ "directory": "runtime-opencode"
21
+ },
22
+ "license": "MIT",
23
+ "author": "CCDevelopForFun",
24
+ "type": "module",
25
+ "main": "dist/index.js",
26
+ "files": [
27
+ "dist",
28
+ "README.md",
29
+ "LICENSE"
30
+ ],
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "engines": {
35
+ "node": ">=22"
36
+ },
37
+ "scripts": {
38
+ "build": "tsc -p .",
39
+ "test": "npm run build && vitest run",
40
+ "test:watch": "vitest"
41
+ },
42
+ "dependencies": {
43
+ "@opencode-ai/sdk": "^1.15.12"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "latest",
47
+ "typescript": "latest",
48
+ "vitest": "latest"
49
+ }
50
+ }