@skaile/forge-agent-runtime 1.0.0 → 1.1.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/CHANGELOG.md +8 -0
- package/README.md +58 -0
- package/dist/app-runner-host/index.d.mts +61 -0
- package/dist/app-runner-host/index.d.ts +61 -0
- package/dist/app-runner-host/index.mjs +565 -0
- package/dist/index.d.mts +6 -124
- package/dist/index.d.ts +6 -124
- package/dist/index.mjs +11 -535
- package/dist/shared/forge-agent-runtime.B1LZr0Sl.mjs +538 -0
- package/dist/shared/forge-agent-runtime.DlNAoPjs.d.mts +122 -0
- package/dist/shared/forge-agent-runtime.DlNAoPjs.d.ts +122 -0
- package/package.json +6 -2
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { AIProviderRegistryView } from '@skaile/forge-settings/server';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AgentAdapter — canonical interface for forge agent harnesses.
|
|
5
|
+
*
|
|
6
|
+
* Every harness (omp, claude-sdk, codex, …) runs behind an adapter that
|
|
7
|
+
* implements this interface. Apps depend only on this contract, not the
|
|
8
|
+
* concrete adapter type.
|
|
9
|
+
*
|
|
10
|
+
* Lifecycle:
|
|
11
|
+
* 1. Call `connect(config)` — spawns the subprocess or initialises the SDK client.
|
|
12
|
+
* 2. Call `sendCommand(cmd)` to dispatch prompts and control commands.
|
|
13
|
+
* 3. Call `listen()` to consume the async event stream.
|
|
14
|
+
* 4. Call `abort()` to cancel an in-flight turn.
|
|
15
|
+
* 5. Call `disconnect()` to tear down cleanly.
|
|
16
|
+
*
|
|
17
|
+
* Adapters are STATEFUL: one instance per active agent session.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** Input to the agent: a natural-language prompt or a control message. */
|
|
21
|
+
interface AgentCommand {
|
|
22
|
+
type: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
/** Output from the agent: any typed event from the skaile protocol. */
|
|
26
|
+
interface AgentEvent {
|
|
27
|
+
type: string;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
/** Observable lifecycle state of an adapter instance. */
|
|
31
|
+
type AgentStatus = "idle" | "running" | "error" | "disconnected";
|
|
32
|
+
/**
|
|
33
|
+
* Configuration passed to `AgentAdapter.connect()`.
|
|
34
|
+
*
|
|
35
|
+
* All fields mirror `AgentProcessConfig` from `agent-process.ts`
|
|
36
|
+
* so the ProcessManagerAdapter can pass them through unchanged.
|
|
37
|
+
*/
|
|
38
|
+
interface AgentAdapterConfig {
|
|
39
|
+
/** Working directory for the agent (--project-dir) */
|
|
40
|
+
projectDir: string;
|
|
41
|
+
/** Bridge harness type (omp, claude-sdk). Defaults to 'omp'. */
|
|
42
|
+
harness?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The AI provider registry the session runs against. The adapter resolves
|
|
45
|
+
* each enabled entry's credential reference and delivers it through the
|
|
46
|
+
* child environment.
|
|
47
|
+
*/
|
|
48
|
+
registry?: AIProviderRegistryView;
|
|
49
|
+
/**
|
|
50
|
+
* Registry entry ids the session is restricted to (`--providers a,b`).
|
|
51
|
+
* Absent or empty: the session sees the whole registry. `registry` should
|
|
52
|
+
* already be narrowed to the same ids so only their credentials are delivered.
|
|
53
|
+
*/
|
|
54
|
+
providers?: string[];
|
|
55
|
+
/**
|
|
56
|
+
* The layered environment `env:` references resolve against and the child
|
|
57
|
+
* env is based on; defaults to `process.env`.
|
|
58
|
+
*/
|
|
59
|
+
credentialEnv?: Record<string, string | undefined>;
|
|
60
|
+
/** Model selection as `"<providerId>/<modelId>"`, a bare model id, or `@role` */
|
|
61
|
+
model?: string;
|
|
62
|
+
/** Environment variables injected into the subprocess */
|
|
63
|
+
env?: Record<string, string>;
|
|
64
|
+
/** System prompt written to .skaile/system-prompt.md before spawn */
|
|
65
|
+
systemPrompt?: string;
|
|
66
|
+
/** Max agentic turns */
|
|
67
|
+
maxTurns?: number;
|
|
68
|
+
/** GitAgent definition directory */
|
|
69
|
+
agentDir?: string;
|
|
70
|
+
/** OMP harness session ID for native resume */
|
|
71
|
+
harnessSessionId?: string;
|
|
72
|
+
/** Address the subprocess binds and the client dials. Absent: runtime default bind, dial `127.0.0.1`. */
|
|
73
|
+
host?: string;
|
|
74
|
+
/** Bearer token the subprocess WebSocket requires and the client presents. Absent: no authentication. */
|
|
75
|
+
wsAuthToken?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Canonical interface for all forge agent harnesses.
|
|
79
|
+
*
|
|
80
|
+
* Implementations wrap the `AgentProcessManager` pattern used by the existing
|
|
81
|
+
* forge apps, exposing a minimal async API that higher-level managers consume.
|
|
82
|
+
*/
|
|
83
|
+
interface AgentAdapter {
|
|
84
|
+
/**
|
|
85
|
+
* Connect to the agent harness and prepare it for commands.
|
|
86
|
+
* Must be called once before `sendCommand` or `listen`.
|
|
87
|
+
*/
|
|
88
|
+
connect(config: AgentAdapterConfig): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Send a command to the connected agent.
|
|
91
|
+
* Throws if `connect()` has not been called or the session has disconnected.
|
|
92
|
+
*/
|
|
93
|
+
sendCommand(command: AgentCommand): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Return an async iterable of agent events.
|
|
96
|
+
* The iterable completes when the adapter disconnects.
|
|
97
|
+
*
|
|
98
|
+
* Callers can use `for await (const event of adapter.listen()) { ... }` or
|
|
99
|
+
* subscribe via an EventEmitter bridge (see BaseAgentManager).
|
|
100
|
+
*/
|
|
101
|
+
listen(): AsyncIterable<AgentEvent>;
|
|
102
|
+
/**
|
|
103
|
+
* Cancel the current in-flight agent turn.
|
|
104
|
+
* No-op if the agent is idle.
|
|
105
|
+
*/
|
|
106
|
+
abort(): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Whether the adapter is connected and the agent is ready to receive commands.
|
|
109
|
+
*/
|
|
110
|
+
isConnected(): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Observable lifecycle state.
|
|
113
|
+
*/
|
|
114
|
+
getStatus(): AgentStatus;
|
|
115
|
+
/**
|
|
116
|
+
* Tear down the adapter: disconnect, stop subprocess if applicable, release resources.
|
|
117
|
+
* Safe to call multiple times.
|
|
118
|
+
*/
|
|
119
|
+
disconnect(): Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type { AgentEvent as A, AgentAdapter as a, AgentAdapterConfig as b, AgentCommand as c, AgentStatus as d };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skaile/forge-agent-runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Agent process lifecycle for Skaile forge apps: spawns `skaile serve`, connects over WebSocket, and exposes the AgentAdapter, harness registry and session manager. Node-only.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "bun@1.3.9",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.mts",
|
|
12
12
|
"import": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"./app-runner-host": {
|
|
15
|
+
"types": "./dist/app-runner-host/index.d.mts",
|
|
16
|
+
"import": "./dist/app-runner-host/index.mjs"
|
|
13
17
|
}
|
|
14
18
|
},
|
|
15
19
|
"files": [
|
|
@@ -39,7 +43,7 @@
|
|
|
39
43
|
},
|
|
40
44
|
"dependencies": {
|
|
41
45
|
"@skaile/forge-settings": "^1.0.0",
|
|
42
|
-
"@skaile/workspaces": "^6.
|
|
46
|
+
"@skaile/workspaces": "^6.11.0",
|
|
43
47
|
"consola": "^3.4.2",
|
|
44
48
|
"picocolors": "^1.1.1"
|
|
45
49
|
},
|