@mono-agent/agent-runtime 0.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/ARCHITECTURE.md +219 -0
- package/LICENSE +674 -0
- package/README.md +430 -0
- package/package.json +46 -0
- package/src/agent/allowlists.js +49 -0
- package/src/agent/approval.js +211 -0
- package/src/agent/compaction.js +752 -0
- package/src/agent/index.js +40 -0
- package/src/agent/prompt/skill-index.js +66 -0
- package/src/agent/tool-bloat.js +164 -0
- package/src/agent/tools/bash.js +156 -0
- package/src/agent/tools/edit.js +15 -0
- package/src/agent/tools/glob.js +71 -0
- package/src/agent/tools/grep.js +84 -0
- package/src/agent/tools/index.js +17 -0
- package/src/agent/tools/pi-bridge.js +638 -0
- package/src/agent/tools/read.js +39 -0
- package/src/agent/tools/shared/constants.js +21 -0
- package/src/agent/tools/shared/dedup.js +31 -0
- package/src/agent/tools/shared/output-truncation.js +54 -0
- package/src/agent/tools/shared/path-resolver.js +156 -0
- package/src/agent/tools/shared/ripgrep.js +130 -0
- package/src/agent/tools/shared/runtime-context.js +69 -0
- package/src/agent/tools/web-fetch.js +59 -0
- package/src/agent/tools/web-search.js +21 -0
- package/src/agent/tools/write.js +14 -0
- package/src/agent/transcript.js +227 -0
- package/src/ai/backend.js +17 -0
- package/src/ai/cost.js +164 -0
- package/src/ai/failure.js +165 -0
- package/src/ai/file-change-stats.js +234 -0
- package/src/ai/index.js +16 -0
- package/src/ai/live-input-prompt.js +15 -0
- package/src/ai/observer.js +233 -0
- package/src/ai/providers/claude-cli.js +694 -0
- package/src/ai/providers/claude-sdk.js +864 -0
- package/src/ai/providers/claude-subagents.js +67 -0
- package/src/ai/providers/codex-app.js +1045 -0
- package/src/ai/providers/opencode-app.js +356 -0
- package/src/ai/providers/opencode-discovery.js +39 -0
- package/src/ai/providers/pi-events.js +62 -0
- package/src/ai/providers/pi-messages.js +68 -0
- package/src/ai/providers/pi-models.js +111 -0
- package/src/ai/providers/pi-sdk.js +1310 -0
- package/src/ai/registry.js +5 -0
- package/src/ai/runtime/capabilities-used.js +56 -0
- package/src/ai/runtime/capabilities.js +44 -0
- package/src/ai/runtime/context-windows.js +38 -0
- package/src/ai/runtime/fast-mode.js +8 -0
- package/src/ai/runtime/model-refs.js +144 -0
- package/src/ai/runtime/registry.js +57 -0
- package/src/ai/runtime/router.js +214 -0
- package/src/ai/runtime/sessions.js +126 -0
- package/src/ai/streaming/codex-events.js +139 -0
- package/src/ai/streaming/opencode-events.js +54 -0
- package/src/ai/types.js +70 -0
- package/src/index.js +23 -0
- package/src/pi-auth.js +80 -0
- package/src/runtime-brand.js +32 -0
- package/src/runtime.js +104 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
function hasNativeClaudeSubagents(nativeSubagents) {
|
|
2
|
+
return nativeSubagents?.provider === "claude"
|
|
3
|
+
&& Array.isArray(nativeSubagents.teammates)
|
|
4
|
+
&& nativeSubagents.teammates.length > 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function claudeSubagentModelAlias(teammate) {
|
|
8
|
+
const raw = [
|
|
9
|
+
teammate?.modelRef,
|
|
10
|
+
teammate?.model?.reference,
|
|
11
|
+
teammate?.model?.model,
|
|
12
|
+
].filter(Boolean).join(" ").toLowerCase();
|
|
13
|
+
if (raw.includes("opus")) return "opus";
|
|
14
|
+
if (raw.includes("haiku")) return "haiku";
|
|
15
|
+
if (raw.includes("sonnet")) return "sonnet";
|
|
16
|
+
return "inherit";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function claudeSubagentMcpServers(mcpServers = {}) {
|
|
20
|
+
const servers = [];
|
|
21
|
+
for (const [name, server] of Object.entries(mcpServers || {})) {
|
|
22
|
+
if (!server || typeof server !== "object") continue;
|
|
23
|
+
servers.push({ [name]: server });
|
|
24
|
+
}
|
|
25
|
+
return servers;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function cleanList(values = []) {
|
|
29
|
+
return Array.from(new Set((Array.isArray(values) ? values : [])
|
|
30
|
+
.map((value) => String(value || "").trim())
|
|
31
|
+
.filter(Boolean)));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function withTaskTool(tools) {
|
|
35
|
+
if (!Array.isArray(tools) || !tools.length) return tools;
|
|
36
|
+
return cleanList([...tools, "Task"]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function claudeNativeAgentDefinitions(nativeSubagents) {
|
|
40
|
+
if (!hasNativeClaudeSubagents(nativeSubagents)) return null;
|
|
41
|
+
const definitions = {};
|
|
42
|
+
for (const teammate of nativeSubagents.teammates) {
|
|
43
|
+
const name = String(teammate?.name || "").trim();
|
|
44
|
+
const prompt = String(teammate?.helperSystemPrompt || teammate?.instructions || "").trim();
|
|
45
|
+
if (!name || !prompt) continue;
|
|
46
|
+
const definition = {
|
|
47
|
+
description: String(teammate.description || teammate.displayName || name),
|
|
48
|
+
prompt,
|
|
49
|
+
};
|
|
50
|
+
const tools = cleanList(teammate.allowedTools);
|
|
51
|
+
if (tools.length) definition.tools = tools;
|
|
52
|
+
const disallowedTools = cleanList(teammate.disallowedTools);
|
|
53
|
+
if (disallowedTools.length) definition.disallowedTools = disallowedTools;
|
|
54
|
+
const model = claudeSubagentModelAlias(teammate);
|
|
55
|
+
if (model) definition.model = model;
|
|
56
|
+
const mcpServers = claudeSubagentMcpServers(teammate.mcpServers);
|
|
57
|
+
if (mcpServers.length) definition.mcpServers = mcpServers;
|
|
58
|
+
definitions[name] = definition;
|
|
59
|
+
}
|
|
60
|
+
return Object.keys(definitions).length ? definitions : null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function claudeToolsWithNativeSubagents(allowedTools, nativeSubagents) {
|
|
64
|
+
return claudeNativeAgentDefinitions(nativeSubagents)
|
|
65
|
+
? withTaskTool(allowedTools)
|
|
66
|
+
: allowedTools;
|
|
67
|
+
}
|