@mono-agent/agent-runtime 0.2.2 → 0.4.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/ARCHITECTURE.md +48 -3
- package/MIGRATION.md +115 -0
- package/README.md +24 -8
- package/package.json +3 -2
- package/src/agent/compaction.js +11 -677
- package/src/agent/index.js +1 -1
- package/src/agent/tools/pi-bridge.js +46 -10
- package/src/agent/tools/web-fetch.js +48 -12
- package/src/ai/failure.js +1 -1
- package/src/ai/index.js +1 -0
- package/src/ai/providers/claude-cli.js +5 -1
- package/src/ai/providers/pi-errors.js +65 -0
- package/src/ai/providers/pi-native.js +1445 -0
- package/src/ai/providers/pi-sdk.js +26 -1301
- package/src/ai/runtime/capabilities.js +3 -0
- package/src/ai/runtime/registry.js +4 -2
- package/src/ai/runtime/router.js +23 -7
- package/src/ai/runtime/sessions.js +3 -2
- package/src/ai/types.js +0 -1
- package/src/runtime.js +3 -2
|
@@ -24,6 +24,9 @@ export const RUNTIME_CAPABILITIES = {
|
|
|
24
24
|
// The pi bridge keeps a pi-agent-core Session transcript per provider
|
|
25
25
|
// session id and seeds Agent initialState.messages on resume.
|
|
26
26
|
supports_session_resume: true,
|
|
27
|
+
// The pi-native bridge does not (yet) wire native subagents / an AskAgent
|
|
28
|
+
// tool, so advertise no support rather than letting callers expect it.
|
|
29
|
+
supports_native_subagents: false,
|
|
27
30
|
},
|
|
28
31
|
codex: {
|
|
29
32
|
runtime: "cli",
|
|
@@ -35,7 +35,9 @@ const builtinBridgeSpecs = {
|
|
|
35
35
|
id: "pi",
|
|
36
36
|
supports: (ref) => ref?.sdk === "pi",
|
|
37
37
|
capabilities: () => runtimeCapabilities("pi"),
|
|
38
|
-
|
|
38
|
+
// The pi-native AgentHarness bridge is the sole pi runtime path. The
|
|
39
|
+
// hand-rolled pi-sdk bridge was removed once native reached parity.
|
|
40
|
+
load: async () => (await import("../providers/pi-native.js")).piNativeRuntimeBridge,
|
|
39
41
|
},
|
|
40
42
|
};
|
|
41
43
|
|
|
@@ -49,7 +51,7 @@ export function listRuntimeBridges() {
|
|
|
49
51
|
|
|
50
52
|
export async function resolveRuntimeBridge(modelRef, options = {}) {
|
|
51
53
|
for (const spec of Object.values(builtinBridgeSpecs)) {
|
|
52
|
-
if (spec.supports(modelRef, options)) return spec.load();
|
|
54
|
+
if (spec.supports(modelRef, options)) return spec.load(options);
|
|
53
55
|
}
|
|
54
56
|
throw new Error(`unsupported sdk: ${modelRef?.sdk || "unknown"}`);
|
|
55
57
|
}
|
package/src/ai/runtime/router.js
CHANGED
|
@@ -191,21 +191,37 @@ function normaliseChain(chain) {
|
|
|
191
191
|
|
|
192
192
|
function entrySatisfiesRequirements(entry, options) {
|
|
193
193
|
const requires = entry.requires;
|
|
194
|
-
|
|
194
|
+
// Synthesize effective requirements: merge the entry's own `requires` with
|
|
195
|
+
// requirements inferred from per-run options, so a chain entry that carries
|
|
196
|
+
// no explicit `requires` (the agent-host + runtime-adapter paths cannot carry
|
|
197
|
+
// one today) still respects option-implied capability needs. Each option
|
|
198
|
+
// inference defers to an explicit entry pin, never overriding it.
|
|
199
|
+
const effectiveRequires = { ...(requires || null) };
|
|
200
|
+
// Honour request-time outputSchema → require structured_output unless the
|
|
201
|
+
// entry already pins it.
|
|
202
|
+
if (options.outputSchema && effectiveRequires.structured_output === undefined) {
|
|
203
|
+
effectiveRequires.structured_output = true;
|
|
204
|
+
}
|
|
205
|
+
// Honour native-subagent teammates → require supports_native_subagents unless
|
|
206
|
+
// the entry already pins it. A pi entry (supports_native_subagents:false) then
|
|
207
|
+
// fails here rather than silently dropping the teammates.
|
|
208
|
+
if (
|
|
209
|
+
Array.isArray(options.nativeSubagents?.teammates)
|
|
210
|
+
&& options.nativeSubagents.teammates.length > 0
|
|
211
|
+
&& effectiveRequires.supports_native_subagents === undefined
|
|
212
|
+
) {
|
|
213
|
+
effectiveRequires.supports_native_subagents = true;
|
|
214
|
+
}
|
|
215
|
+
if (Object.keys(effectiveRequires).length === 0) return true;
|
|
195
216
|
let caps;
|
|
196
217
|
try {
|
|
197
218
|
caps = runtimeCapabilities(entry.model);
|
|
198
219
|
} catch {
|
|
199
220
|
return false;
|
|
200
221
|
}
|
|
201
|
-
for (const [key, expected] of Object.entries(
|
|
222
|
+
for (const [key, expected] of Object.entries(effectiveRequires)) {
|
|
202
223
|
if (caps[key] !== expected) return false;
|
|
203
224
|
}
|
|
204
|
-
// Honour request-time outputSchema → require structured_output unless
|
|
205
|
-
// already specified.
|
|
206
|
-
if (options.outputSchema && requires.structured_output !== false && caps.structured_output === false) {
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
225
|
return true;
|
|
210
226
|
}
|
|
211
227
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Provider session registries.
|
|
2
2
|
//
|
|
3
3
|
// Bridges that support continuous provider sessions (codex-app keeps the
|
|
4
|
-
// app-server subprocess + thread alive, pi-
|
|
5
|
-
// register their live sessions here, keyed by provider session id.
|
|
4
|
+
// app-server subprocess + thread alive, pi-native keeps a pi Session
|
|
5
|
+
// transcript) register their live sessions here, keyed by provider session id.
|
|
6
|
+
// The host
|
|
6
7
|
// owns session lifetime policy (which conversation maps to which session,
|
|
7
8
|
// when to resume, when to retire); these registries only make sure nothing
|
|
8
9
|
// leaks if the host forgets: every entry carries an idle TTL backstop with an
|
package/src/ai/types.js
CHANGED
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
* @property {string} [runArtifactDir]
|
|
28
28
|
* @property {AbortSignal} [abortSignal]
|
|
29
29
|
* @property {Object} [liveInput]
|
|
30
|
-
* @property {"auto"|"concise"|"detailed"|"off"|"on"|null} [piReasoningSummary]
|
|
31
30
|
* @property {Object} [settings]
|
|
32
31
|
* @property {Object} [nativeSubagents] Same-runtime teammate helpers exposed through native provider subagent surfaces.
|
|
33
32
|
* @property {(event: RuntimeEvent) => void} [onEvent]
|
package/src/runtime.js
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
// method that resolves the right provider bridge based on `options.model` +
|
|
7
7
|
// `options.executionMode`.
|
|
8
8
|
//
|
|
9
|
-
//
|
|
10
|
-
// register themselves on import via the runtime registry. Hosts
|
|
9
|
+
// The built-in bridges (claude-sdk, claude-cli, pi-native, codex-app,
|
|
10
|
+
// opencode-app) register themselves on import via the runtime registry. Hosts
|
|
11
|
+
// that need
|
|
11
12
|
// finer control can keep using the named exports (resolveRuntimeBridge,
|
|
12
13
|
// generateClaudeResponse, etc.) directly.
|
|
13
14
|
//
|