joonecli 0.1.1 → 0.2.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/dist/__tests__/config.test.js +1 -0
- package/dist/__tests__/config.test.js.map +1 -1
- package/dist/__tests__/installHostDeps.test.js +45 -0
- package/dist/__tests__/installHostDeps.test.js.map +1 -0
- package/dist/__tests__/whitelistedBackend.test.js +18 -0
- package/dist/__tests__/whitelistedBackend.test.js.map +1 -0
- package/dist/cli/config.d.ts +2 -0
- package/dist/cli/config.js +1 -0
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/index.js +84 -97
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/builtinCommands.js +6 -6
- package/dist/commands/builtinCommands.js.map +1 -1
- package/dist/commands/commandRegistry.d.ts +3 -1
- package/dist/commands/commandRegistry.js.map +1 -1
- package/dist/core/agentLoop.d.ts +11 -28
- package/dist/core/agentLoop.js +68 -229
- package/dist/core/agentLoop.js.map +1 -1
- package/dist/core/compactor.js +2 -2
- package/dist/core/compactor.js.map +1 -1
- package/dist/core/contextGuard.d.ts +5 -0
- package/dist/core/contextGuard.js +30 -3
- package/dist/core/contextGuard.js.map +1 -1
- package/dist/core/events.d.ts +45 -0
- package/dist/core/events.js +8 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/promptBuilder.js.map +1 -1
- package/dist/core/sessionStore.js +3 -2
- package/dist/core/sessionStore.js.map +1 -1
- package/dist/core/tokenCounter.d.ts +8 -1
- package/dist/core/tokenCounter.js +28 -0
- package/dist/core/tokenCounter.js.map +1 -1
- package/dist/hitl/bridge.js +1 -27
- package/dist/hitl/bridge.js.map +1 -1
- package/dist/middleware/loopDetection.d.ts +7 -23
- package/dist/middleware/loopDetection.js +38 -42
- package/dist/middleware/loopDetection.js.map +1 -1
- package/dist/sandbox/whitelistedBackend.d.ts +5 -0
- package/dist/sandbox/whitelistedBackend.js +27 -0
- package/dist/sandbox/whitelistedBackend.js.map +1 -0
- package/dist/tools/askUser.d.ts +12 -3
- package/dist/tools/askUser.js +16 -28
- package/dist/tools/askUser.js.map +1 -1
- package/dist/tools/bashTool.d.ts +11 -0
- package/dist/tools/bashTool.js +51 -0
- package/dist/tools/bashTool.js.map +1 -0
- package/dist/tools/index.d.ts +15 -27
- package/dist/tools/index.js +9 -181
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/installHostDeps.d.ts +8 -0
- package/dist/tools/installHostDeps.js +44 -0
- package/dist/tools/installHostDeps.js.map +1 -0
- package/dist/tracing/sessionTracer.d.ts +1 -0
- package/dist/tracing/sessionTracer.js +4 -1
- package/dist/tracing/sessionTracer.js.map +1 -1
- package/dist/ui/App.js +116 -55
- package/dist/ui/App.js.map +1 -1
- package/dist/ui/components/ActionLog.d.ts +7 -0
- package/dist/ui/components/ActionLog.js +63 -0
- package/dist/ui/components/ActionLog.js.map +1 -0
- package/dist/ui/components/FileBrowser.d.ts +2 -0
- package/dist/ui/components/FileBrowser.js +41 -0
- package/dist/ui/components/FileBrowser.js.map +1 -0
- package/dist/ui/components/MessageBubble.js +1 -1
- package/dist/ui/components/MessageBubble.js.map +1 -1
- package/package.json +8 -5
- package/AGENTS.md +0 -56
- package/Handover.md +0 -115
- package/PROGRESS.md +0 -160
- package/dist/__tests__/m55.test.js +0 -160
- package/dist/__tests__/m55.test.js.map +0 -1
- package/dist/__tests__/middleware.test.js +0 -169
- package/dist/__tests__/middleware.test.js.map +0 -1
- package/dist/__tests__/optimizations.test.d.ts +0 -1
- package/dist/__tests__/optimizations.test.js +0 -136
- package/dist/__tests__/optimizations.test.js.map +0 -1
- package/dist/__tests__/security.test.d.ts +0 -1
- package/dist/__tests__/security.test.js +0 -86
- package/dist/__tests__/security.test.js.map +0 -1
- package/dist/__tests__/streaming.test.d.ts +0 -1
- package/dist/__tests__/streaming.test.js +0 -71
- package/dist/__tests__/streaming.test.js.map +0 -1
- package/dist/__tests__/toolRouter.test.d.ts +0 -1
- package/dist/__tests__/toolRouter.test.js +0 -37
- package/dist/__tests__/toolRouter.test.js.map +0 -1
- package/dist/__tests__/tools.test.d.ts +0 -1
- package/dist/__tests__/tools.test.js +0 -112
- package/dist/__tests__/tools.test.js.map +0 -1
- package/dist/core/subAgent.d.ts +0 -56
- package/dist/core/subAgent.js +0 -240
- package/dist/core/subAgent.js.map +0 -1
- package/dist/debug_google.d.ts +0 -1
- package/dist/debug_google.js +0 -23
- package/dist/debug_google.js.map +0 -1
- package/dist/middleware/commandSanitizer.d.ts +0 -18
- package/dist/middleware/commandSanitizer.js +0 -50
- package/dist/middleware/commandSanitizer.js.map +0 -1
- package/dist/middleware/permission.d.ts +0 -17
- package/dist/middleware/permission.js +0 -59
- package/dist/middleware/permission.js.map +0 -1
- package/dist/middleware/pipeline.d.ts +0 -31
- package/dist/middleware/pipeline.js +0 -62
- package/dist/middleware/pipeline.js.map +0 -1
- package/dist/middleware/preCompletion.d.ts +0 -29
- package/dist/middleware/preCompletion.js +0 -82
- package/dist/middleware/preCompletion.js.map +0 -1
- package/dist/middleware/types.d.ts +0 -40
- package/dist/middleware/types.js +0 -8
- package/dist/middleware/types.js.map +0 -1
- package/dist/skills/loader.d.ts +0 -55
- package/dist/skills/loader.js +0 -132
- package/dist/skills/loader.js.map +0 -1
- package/dist/skills/tools.d.ts +0 -5
- package/dist/skills/tools.js +0 -78
- package/dist/skills/tools.js.map +0 -1
- package/dist/test_cache.d.ts +0 -1
- package/dist/test_cache.js +0 -55
- package/dist/test_cache.js.map +0 -1
- package/dist/test_google.d.ts +0 -1
- package/dist/test_google.js +0 -36
- package/dist/test_google.js.map +0 -1
- package/dist/tools/browser.d.ts +0 -19
- package/dist/tools/browser.js +0 -111
- package/dist/tools/browser.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -31
- package/dist/tools/registry.js +0 -168
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/router.d.ts +0 -34
- package/dist/tools/router.js +0 -75
- package/dist/tools/router.js.map +0 -1
- package/dist/tools/security.d.ts +0 -28
- package/dist/tools/security.js +0 -183
- package/dist/tools/security.js.map +0 -1
- package/dist/tools/spawnAgent.d.ts +0 -19
- package/dist/tools/spawnAgent.js +0 -130
- package/dist/tools/spawnAgent.js.map +0 -1
- package/dist/tools/webSearch.d.ts +0 -6
- package/dist/tools/webSearch.js +0 -120
- package/dist/tools/webSearch.js.map +0 -1
- package/docs/01_insights_and_patterns.md +0 -27
- package/docs/02_edge_cases_and_mitigations.md +0 -143
- package/docs/03_initial_implementation_plan.md +0 -66
- package/docs/04_tech_stack_proposal.md +0 -20
- package/docs/05_prd.md +0 -87
- package/docs/06_user_stories.md +0 -72
- package/docs/07_system_architecture.md +0 -138
- package/docs/08_roadmap.md +0 -200
- package/e2b/Dockerfile +0 -26
- package/src/__tests__/bootstrap.test.ts +0 -111
- package/src/__tests__/config.test.ts +0 -97
- package/src/__tests__/m55.test.ts +0 -238
- package/src/__tests__/middleware.test.ts +0 -219
- package/src/__tests__/modelFactory.test.ts +0 -63
- package/src/__tests__/optimizations.test.ts +0 -201
- package/src/__tests__/promptBuilder.test.ts +0 -141
- package/src/__tests__/sandbox.test.ts +0 -102
- package/src/__tests__/security.test.ts +0 -122
- package/src/__tests__/streaming.test.ts +0 -82
- package/src/__tests__/toolRouter.test.ts +0 -52
- package/src/__tests__/tools.test.ts +0 -146
- package/src/__tests__/tracing.test.ts +0 -196
- package/src/agents/agentRegistry.ts +0 -69
- package/src/agents/agentSpec.ts +0 -67
- package/src/agents/builtinAgents.ts +0 -142
- package/src/cli/config.ts +0 -124
- package/src/cli/index.ts +0 -742
- package/src/cli/modelFactory.ts +0 -174
- package/src/cli/postinstall.ts +0 -28
- package/src/cli/providers.ts +0 -107
- package/src/commands/builtinCommands.ts +0 -293
- package/src/commands/commandRegistry.ts +0 -194
- package/src/core/agentLoop.d.ts.map +0 -1
- package/src/core/agentLoop.ts +0 -312
- package/src/core/autoSave.ts +0 -95
- package/src/core/compactor.ts +0 -252
- package/src/core/contextGuard.ts +0 -129
- package/src/core/errors.ts +0 -202
- package/src/core/promptBuilder.d.ts.map +0 -1
- package/src/core/promptBuilder.ts +0 -139
- package/src/core/reasoningRouter.ts +0 -121
- package/src/core/retry.ts +0 -75
- package/src/core/sessionResumer.ts +0 -90
- package/src/core/sessionStore.ts +0 -216
- package/src/core/subAgent.ts +0 -339
- package/src/core/tokenCounter.ts +0 -64
- package/src/evals/dataset.ts +0 -67
- package/src/evals/evaluator.ts +0 -81
- package/src/hitl/bridge.ts +0 -160
- package/src/middleware/commandSanitizer.ts +0 -60
- package/src/middleware/loopDetection.ts +0 -63
- package/src/middleware/permission.ts +0 -72
- package/src/middleware/pipeline.ts +0 -75
- package/src/middleware/preCompletion.ts +0 -94
- package/src/middleware/types.ts +0 -45
- package/src/sandbox/bootstrap.ts +0 -121
- package/src/sandbox/manager.ts +0 -239
- package/src/sandbox/sync.ts +0 -157
- package/src/skills/loader.ts +0 -143
- package/src/skills/tools.ts +0 -99
- package/src/skills/types.ts +0 -13
- package/src/test_cache.ts +0 -72
- package/src/tools/askUser.ts +0 -47
- package/src/tools/browser.ts +0 -137
- package/src/tools/index.d.ts.map +0 -1
- package/src/tools/index.ts +0 -237
- package/src/tools/registry.ts +0 -198
- package/src/tools/router.ts +0 -78
- package/src/tools/security.ts +0 -220
- package/src/tools/spawnAgent.ts +0 -158
- package/src/tools/webSearch.ts +0 -142
- package/src/tracing/analyzer.ts +0 -265
- package/src/tracing/langsmith.ts +0 -63
- package/src/tracing/sessionTracer.ts +0 -202
- package/src/tracing/types.ts +0 -49
- package/src/types/valyu.d.ts +0 -37
- package/src/ui/App.tsx +0 -404
- package/src/ui/components/HITLPrompt.tsx +0 -119
- package/src/ui/components/Header.tsx +0 -51
- package/src/ui/components/MessageBubble.tsx +0 -46
- package/src/ui/components/StatusBar.tsx +0 -138
- package/src/ui/components/StreamingText.tsx +0 -48
- package/src/ui/components/ToolCallPanel.tsx +0 -80
- package/tests/commands/commands.test.ts +0 -356
- package/tests/core/compactor.test.ts +0 -217
- package/tests/core/retryAndErrors.test.ts +0 -164
- package/tests/core/sessionResumer.test.ts +0 -95
- package/tests/core/sessionStore.test.ts +0 -84
- package/tests/core/stability.test.ts +0 -165
- package/tests/core/subAgent.test.ts +0 -238
- package/tests/hitl/hitlBridge.test.ts +0 -115
- package/tsconfig.json +0 -16
- package/vitest.config.ts +0 -10
- package/vitest.out +0 -48
- /package/dist/__tests__/{m55.test.d.ts → installHostDeps.test.d.ts} +0 -0
- /package/dist/__tests__/{middleware.test.d.ts → whitelistedBackend.test.d.ts} +0 -0
package/dist/skills/tools.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { SkillLoader } from "./loader.js";
|
|
2
|
-
// ─── Shared SkillLoader instance ──────────────────────────────────────────────
|
|
3
|
-
let _loader = null;
|
|
4
|
-
export function bindSkillLoader(loader) {
|
|
5
|
-
_loader = loader;
|
|
6
|
-
}
|
|
7
|
-
function getLoader() {
|
|
8
|
-
if (!_loader) {
|
|
9
|
-
_loader = new SkillLoader();
|
|
10
|
-
}
|
|
11
|
-
return _loader;
|
|
12
|
-
}
|
|
13
|
-
// ─── SearchSkillsTool ───────────────────────────────────────────────────────────
|
|
14
|
-
export const SearchSkillsTool = {
|
|
15
|
-
name: "search_skills",
|
|
16
|
-
description: "Search for available skills. Skills provide specialized instructions for specific tasks " +
|
|
17
|
-
"(e.g., deployment workflows, testing strategies, coding patterns).",
|
|
18
|
-
schema: {
|
|
19
|
-
type: "object",
|
|
20
|
-
properties: {
|
|
21
|
-
query: {
|
|
22
|
-
type: "string",
|
|
23
|
-
description: "Search query to match against skill names and descriptions (optional — omit to list all)",
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
execute: async (args) => {
|
|
28
|
-
const loader = getLoader();
|
|
29
|
-
let skills = loader.discoverSkills();
|
|
30
|
-
if (args?.query) {
|
|
31
|
-
const q = args.query.toLowerCase();
|
|
32
|
-
skills = skills.filter((s) => s.name.toLowerCase().includes(q) ||
|
|
33
|
-
s.description.toLowerCase().includes(q));
|
|
34
|
-
}
|
|
35
|
-
if (skills.length === 0) {
|
|
36
|
-
return {
|
|
37
|
-
content: args?.query
|
|
38
|
-
? `No skills found matching "${args.query}".`
|
|
39
|
-
: "No skills found. Create a skill by adding a folder with SKILL.md to ./skills/ or ~/.joone/skills/."
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
const list = skills
|
|
43
|
-
.map((s) => `- **${s.name}** (${s.source}): ${s.description}`)
|
|
44
|
-
.join("\n");
|
|
45
|
-
return {
|
|
46
|
-
content: `Found ${skills.length} skill(s):\n${list}\n\n` +
|
|
47
|
-
`To load a skill, call \`load_skill\` with the skill name.`
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
// ─── LoadSkillTool ──────────────────────────────────────────────────────────────
|
|
52
|
-
export const LoadSkillTool = {
|
|
53
|
-
name: "load_skill",
|
|
54
|
-
description: "Loads a specific skill's full instructions (SKILL.md content). " +
|
|
55
|
-
"Use search_skills first to discover available skills.",
|
|
56
|
-
schema: {
|
|
57
|
-
type: "object",
|
|
58
|
-
properties: {
|
|
59
|
-
name: {
|
|
60
|
-
type: "string",
|
|
61
|
-
description: "The name of the skill to load",
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
required: ["name"],
|
|
65
|
-
},
|
|
66
|
-
execute: async (args) => {
|
|
67
|
-
const loader = getLoader();
|
|
68
|
-
const content = loader.loadSkill(args.name);
|
|
69
|
-
if (!content) {
|
|
70
|
-
return {
|
|
71
|
-
content: `Error: Skill "${args.name}" not found. Use search_skills to see available skills.`,
|
|
72
|
-
isError: true
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return { content };
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
//# sourceMappingURL=tools.js.map
|
package/dist/skills/tools.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/skills/tools.ts"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atAnthropic } from "@langchain/anthropic";
|
|
3
|
-
import { ExecutionHarness } from "./core/agentLoop.js";
|
|
4
|
-
import { HumanMessage } from "@langchain/core/messages";
|
|
5
|
-
async function runCacheTest() {
|
|
6
|
-
console.log("=== Starting Prompt Caching Test ===\n");
|
|
7
|
-
// We need Anthropic API Key for this to actually hit the network and measure cache
|
|
8
|
-
if (!process.env.ANTHROPIC_API_KEY) {
|
|
9
|
-
console.warn("WARNING: ANTHROPIC_API_KEY is not set in .env file. The LLM call will fail.");
|
|
10
|
-
}
|
|
11
|
-
const model = new ChatAnthropic({
|
|
12
|
-
modelName: "claude-3-5-sonnet-20241022",
|
|
13
|
-
temperature: 0,
|
|
14
|
-
maxTokens: 4096,
|
|
15
|
-
}); // No tools needed for this basic string test
|
|
16
|
-
const harness = new ExecutionHarness(model, []);
|
|
17
|
-
// 1. Create a massive static prefix (simulating a lot of project context)
|
|
18
|
-
// We repeat a string many times to ensure we pass the 1024 token minimum for Anthropic caching.
|
|
19
|
-
const massiveProjectMemory = Array(500).fill("Project Rule: Always write clean, modular TypeScript code with strict typings. ").join("\n");
|
|
20
|
-
const state = {
|
|
21
|
-
globalSystemInstructions: "You are a helpful coding assistant. You remember rules carefully.",
|
|
22
|
-
projectMemory: massiveProjectMemory,
|
|
23
|
-
sessionContext: "User OS: Windows 11",
|
|
24
|
-
conversationHistory: []
|
|
25
|
-
};
|
|
26
|
-
console.log("Turn 1: Initial Query (Should create cache)");
|
|
27
|
-
state.conversationHistory.push(new HumanMessage("Hello! What is one of the project rules?"));
|
|
28
|
-
const response1 = await harness.step(state);
|
|
29
|
-
state.conversationHistory.push(response1);
|
|
30
|
-
// In @langchain/anthropic, the actual usage stats (including cache hits/misses)
|
|
31
|
-
// are stored in the response_metadata of the AIMessage.
|
|
32
|
-
console.log(`Response 1: ${response1.content}`);
|
|
33
|
-
console.log(`Token Usage 1: ${JSON.stringify(response1.response_metadata?.usage, null, 2)}\n`);
|
|
34
|
-
// --- TURN 2 ---
|
|
35
|
-
console.log("Turn 2: Follow-up Query (Should hit cache)");
|
|
36
|
-
// We DO NOT change the globalSystemInstructions, projectMemory, or sessionContext.
|
|
37
|
-
// We only append to the conversation history. This preserves the prefix!
|
|
38
|
-
state.conversationHistory.push(new HumanMessage("Could you summarize the rule again briefly?"));
|
|
39
|
-
const response2 = await harness.step(state);
|
|
40
|
-
state.conversationHistory.push(response2);
|
|
41
|
-
console.log(`Response 2: ${response2.content}`);
|
|
42
|
-
console.log(`Token Usage 2: ${JSON.stringify(response2.response_metadata?.usage, null, 2)}\n`);
|
|
43
|
-
// --- TURN 3: The System Reminder Pattern ---
|
|
44
|
-
console.log("Turn 3: Using <system-reminder> to simulate environment change without breaking cache");
|
|
45
|
-
// If a file changed, we DON'T update `state.projectMemory`. We inject a reminder.
|
|
46
|
-
state.conversationHistory.push(new HumanMessage("<system-reminder>\nThe file 'auth.ts' has just been deleted by the user.\n</system-reminder>\nWhat should we do if we need auth now?"));
|
|
47
|
-
const response3 = await harness.step(state);
|
|
48
|
-
state.conversationHistory.push(response3);
|
|
49
|
-
console.log(`Response 3: ${response3.content}`);
|
|
50
|
-
console.log(`Token Usage 3: ${JSON.stringify(response3.response_metadata?.usage, null, 2)}\n`);
|
|
51
|
-
}
|
|
52
|
-
if (require.main === module) {
|
|
53
|
-
runCacheTest().catch(console.error);
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=test_cache.js.map
|
package/dist/test_cache.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test_cache.js","sourceRoot":"","sources":["../src/test_cache.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,KAAK,UAAU,YAAY;IACvB,OAAO,CAAC,GAAG,CAAC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@
|
|
|
1
|
-
export {};
|
package/dist/test_google.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
|
|
2
|
-
import { HumanMessage, SystemMessage } from "@langchain/core/messages";
|
|
3
|
-
import * as dotenv from "dotenv";
|
|
4
|
-
dotenv.config();
|
|
5
|
-
async function main() {
|
|
6
|
-
const model = new ChatGoogleGenerativeAI({
|
|
7
|
-
model: "gemini-2.5-flash",
|
|
8
|
-
});
|
|
9
|
-
const messagesGrouped = [
|
|
10
|
-
new SystemMessage("You are a helpful assistant."),
|
|
11
|
-
new SystemMessage("Also, be concise."),
|
|
12
|
-
new HumanMessage("Hello!"),
|
|
13
|
-
];
|
|
14
|
-
try {
|
|
15
|
-
await model.invoke(messagesGrouped);
|
|
16
|
-
console.log("Success: Grouped SystemMessages at the start work perfectly.");
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
console.error("Grouped systems failed:", e.message);
|
|
20
|
-
}
|
|
21
|
-
const messagesMidstream = [
|
|
22
|
-
new SystemMessage("You are a helpful assistant."),
|
|
23
|
-
new HumanMessage("Hello!"),
|
|
24
|
-
new SystemMessage("System recovery hint here."),
|
|
25
|
-
new HumanMessage("What did I say?"),
|
|
26
|
-
];
|
|
27
|
-
try {
|
|
28
|
-
await model.invoke(messagesMidstream);
|
|
29
|
-
console.log("Success: Mid-stream SystemMessages work.");
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
console.error("Midstream systems failed:", e.message);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
main();
|
|
36
|
-
//# sourceMappingURL=test_google.js.map
|
package/dist/test_google.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test_google.js","sourceRoot":"","sources":["../src/test_google.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,YAAY,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aller } from "../sandbox/bootstrap.js";
|
|
3
|
-
import { DynamicToolInterface } from "./index.js";
|
|
4
|
-
export declare function bindBrowserSandbox(sandbox: SandboxManager, installer: LazyInstaller): void;
|
|
5
|
-
/**
|
|
6
|
-
* Web Browser Tool — wraps Vercel Labs' `agent-browser` CLI.
|
|
7
|
-
*
|
|
8
|
-
* Provides compact accessibility-tree output optimized for LLMs
|
|
9
|
-
* (low token usage vs raw HTML). Runs inside the E2B sandbox.
|
|
10
|
-
*
|
|
11
|
-
* Supported actions:
|
|
12
|
-
* - navigate: Go to a URL
|
|
13
|
-
* - snapshot: Get the accessibility tree (compact text representation)
|
|
14
|
-
* - click: Click an element by ref
|
|
15
|
-
* - type: Type text into a form field by ref
|
|
16
|
-
* - screenshot: Capture a screenshot
|
|
17
|
-
* - scroll: Scroll the page up or down
|
|
18
|
-
*/
|
|
19
|
-
export declare const BrowserTool: DynamicToolInterface;
|
package/dist/tools/browser.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
// ─── Sandbox + Installer references ─────────────────────────────────────────
|
|
2
|
-
let _sandboxManager = null;
|
|
3
|
-
let _installer = null;
|
|
4
|
-
export function bindBrowserSandbox(sandbox, installer) {
|
|
5
|
-
_sandboxManager = sandbox;
|
|
6
|
-
_installer = installer;
|
|
7
|
-
}
|
|
8
|
-
// ─── Helpers ────────────────────────────────────────────────────────────────────
|
|
9
|
-
/**
|
|
10
|
-
* Escapes a string so it can be safely used as an argument in a Bash shell command.
|
|
11
|
-
* It wraps the string in single quotes and safely escapes internal single quotes.
|
|
12
|
-
*/
|
|
13
|
-
function escapeBashArg(arg) {
|
|
14
|
-
return `'${arg.replace(/'/g, "'\\''")}'`;
|
|
15
|
-
}
|
|
16
|
-
// ─── BrowserTool ────────────────────────────────────────────────────────────────
|
|
17
|
-
/**
|
|
18
|
-
* Web Browser Tool — wraps Vercel Labs' `agent-browser` CLI.
|
|
19
|
-
*
|
|
20
|
-
* Provides compact accessibility-tree output optimized for LLMs
|
|
21
|
-
* (low token usage vs raw HTML). Runs inside the E2B sandbox.
|
|
22
|
-
*
|
|
23
|
-
* Supported actions:
|
|
24
|
-
* - navigate: Go to a URL
|
|
25
|
-
* - snapshot: Get the accessibility tree (compact text representation)
|
|
26
|
-
* - click: Click an element by ref
|
|
27
|
-
* - type: Type text into a form field by ref
|
|
28
|
-
* - screenshot: Capture a screenshot
|
|
29
|
-
* - scroll: Scroll the page up or down
|
|
30
|
-
*/
|
|
31
|
-
export const BrowserTool = {
|
|
32
|
-
name: "browser",
|
|
33
|
-
description: "Interact with web pages using a headless browser. Actions: navigate, snapshot, click, type, screenshot, scroll. " +
|
|
34
|
-
"Returns compact accessibility-tree text output optimized for AI consumption.",
|
|
35
|
-
schema: {
|
|
36
|
-
type: "object",
|
|
37
|
-
properties: {
|
|
38
|
-
action: {
|
|
39
|
-
type: "string",
|
|
40
|
-
enum: ["navigate", "snapshot", "click", "type", "screenshot", "scroll"],
|
|
41
|
-
description: "The browser action to perform",
|
|
42
|
-
},
|
|
43
|
-
url: {
|
|
44
|
-
type: "string",
|
|
45
|
-
description: "URL to navigate to (required for 'navigate')",
|
|
46
|
-
},
|
|
47
|
-
ref: {
|
|
48
|
-
type: "string",
|
|
49
|
-
description: "Element reference from the accessibility tree (required for 'click' and 'type')",
|
|
50
|
-
},
|
|
51
|
-
text: {
|
|
52
|
-
type: "string",
|
|
53
|
-
description: "Text to type (required for 'type')",
|
|
54
|
-
},
|
|
55
|
-
direction: {
|
|
56
|
-
type: "string",
|
|
57
|
-
enum: ["up", "down"],
|
|
58
|
-
description: "Scroll direction for 'scroll' action (optional, defaults to 'down')",
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
required: ["action"],
|
|
62
|
-
},
|
|
63
|
-
execute: async (args) => {
|
|
64
|
-
if (!_sandboxManager || !_sandboxManager.isActive()) {
|
|
65
|
-
return { content: "Sandbox is not active. Cannot use browser tool.", isError: true };
|
|
66
|
-
}
|
|
67
|
-
// Build the CLI command
|
|
68
|
-
let command;
|
|
69
|
-
switch (args.action) {
|
|
70
|
-
case "navigate":
|
|
71
|
-
if (!args.url)
|
|
72
|
-
return { content: "Error: 'url' is required for navigate action.", isError: true };
|
|
73
|
-
command = `agent-browser navigate ${escapeBashArg(args.url)} 2>&1`;
|
|
74
|
-
break;
|
|
75
|
-
case "snapshot":
|
|
76
|
-
command = "agent-browser snapshot 2>&1";
|
|
77
|
-
break;
|
|
78
|
-
case "click":
|
|
79
|
-
if (!args.ref)
|
|
80
|
-
return { content: "Error: 'ref' is required for click action.", isError: true };
|
|
81
|
-
command = `agent-browser click ${escapeBashArg(args.ref)} 2>&1`;
|
|
82
|
-
break;
|
|
83
|
-
case "type":
|
|
84
|
-
if (!args.ref)
|
|
85
|
-
return { content: "Error: 'ref' is required for type action.", isError: true };
|
|
86
|
-
if (!args.text)
|
|
87
|
-
return { content: "Error: 'text' is required for type action.", isError: true };
|
|
88
|
-
command = `agent-browser type ${escapeBashArg(args.ref)} ${escapeBashArg(args.text)} 2>&1`;
|
|
89
|
-
break;
|
|
90
|
-
case "screenshot":
|
|
91
|
-
command = "agent-browser screenshot 2>&1";
|
|
92
|
-
break;
|
|
93
|
-
case "scroll":
|
|
94
|
-
const dir = args.direction || "down";
|
|
95
|
-
command = `agent-browser scroll ${escapeBashArg(dir)} 2>&1`;
|
|
96
|
-
break;
|
|
97
|
-
default:
|
|
98
|
-
return { content: `Error: Unknown action "${args.action}". Use: navigate, snapshot, click, type, screenshot, scroll.`, isError: true };
|
|
99
|
-
}
|
|
100
|
-
const result = await _sandboxManager.exec(command);
|
|
101
|
-
if (result.exitCode !== 0) {
|
|
102
|
-
return {
|
|
103
|
-
content: `Browser action failed (exit code ${result.exitCode}):\n${result.stdout}\n${result.stderr}`,
|
|
104
|
-
metadata: { exitCode: result.exitCode },
|
|
105
|
-
isError: true
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
return { content: result.stdout || "(no output)", metadata: { exitCode: result.exitCode }, isError: false };
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
//# sourceMappingURL=browser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/tools/browser.ts"],"names":[],"mappings":"AAIA,+EAA+E;AAE/E,IAAI,eAAe,GAA0B,IAAI,CAAC;AAClD,IAAI,UAAU,GAAyB,IAAI,CAAC;AAE5C,MAAM,UAAU,kBAAkB,CAChC,OAAuB,EACvB,SAAwB;IAExB,eAAe,GAAG,OAAO,CAAC;IAC1B,UAAU,GAAG,SAAS,CAAC;AACzB,CAAC;AAED,mFAAmF;AAEnF;;;GAGG;AACH,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;AAC3C,CAAC;AAED,mFAAmF;AAEnF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,WAAW,GAAyB;IAC/C,IAAI,EAAE,SAAS;IACf,WAAW,EACT,kHAAkH;QAClH,8EAA8E;IAChF,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC;gBACvE,WAAW,EAAE,+BAA+B;aAC7C;YACD,GAAG,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8CAA8C;aAC5D;YACD,GAAG,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,iFAAiF;aACpF;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oCAAoC;aAClD;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC;gBACpB,WAAW,EA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;YAER,KAAK,YAAY;gBACf,OAAO,GAAG,+BAA+B,CAAC;gBAC1C,MAAM;YAER,KAAK,QAAQ;gBACX,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC;gBACrC,OAAO,GAAG,wBAAwB,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC;gBAC5D,MAAM;YAER;gBACE,OAAO,EAAE,OAAO,EAAE,0BAA0B,IAAI,CAAC,MAAM,8DAA8D,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3I,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEnD,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO;gBACL,OAAO,EAAE,oCAAoC,MAAM,CAAC,QAAQ,OAAO,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE;gBACpG,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;gBACvC,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,IAAI,aAAa,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC9G,CAAC;CACF,CAAC"}
|
package/dist/tools/registry.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { DynamicToolInterface } from "./index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Lazy Tool Registry
|
|
4
|
-
*
|
|
5
|
-
* Instead of loading all complex tools into the System Prompt (which burns tokens
|
|
6
|
-
* and risks cache invalidation if changed), this registry maintains "stubs" —
|
|
7
|
-
* lightweight descriptors that let the agent discover tools on demand.
|
|
8
|
-
*
|
|
9
|
-
* Tools in DeferredToolsDB are NOT sent to the LLM by default. The agent can
|
|
10
|
-
* search for them via SearchToolsTool, then activate them via ActivateToolTool.
|
|
11
|
-
*/
|
|
12
|
-
export declare const DeferredToolsDB: Record<string, DynamicToolInterface>;
|
|
13
|
-
/**
|
|
14
|
-
* Returns a tool that has been dynamically activated.
|
|
15
|
-
*/
|
|
16
|
-
export declare function getActivatedTool(name: string): DynamicToolInterface | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Returns all currently activated tools.
|
|
19
|
-
*/
|
|
20
|
-
export declare function getActivatedTools(): DynamicToolInterface[];
|
|
21
|
-
/**
|
|
22
|
-
* Activates a tool from the deferred registry, making it available for execution.
|
|
23
|
-
* Returns the activated tool, or undefined if not found.
|
|
24
|
-
*/
|
|
25
|
-
export declare function activateTool(name: string): DynamicToolInterface | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Resets all activated tools. For testing.
|
|
28
|
-
*/
|
|
29
|
-
export declare function resetActivatedTools(): void;
|
|
30
|
-
export declare const SearchToolsTool: DynamicToolInterface;
|
|
31
|
-
export declare const ActivateToolTool: DynamicToolInterface;
|
package/dist/tools/registry.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lazy Tool Registry
|
|
3
|
-
*
|
|
4
|
-
* Instead of loading all complex tools into the System Prompt (which burns tokens
|
|
5
|
-
* and risks cache invalidation if changed), this registry maintains "stubs" —
|
|
6
|
-
* lightweight descriptors that let the agent discover tools on demand.
|
|
7
|
-
*
|
|
8
|
-
* Tools in DeferredToolsDB are NOT sent to the LLM by default. The agent can
|
|
9
|
-
* search for them via SearchToolsTool, then activate them via ActivateToolTool.
|
|
10
|
-
*/
|
|
11
|
-
// ─── Deferred (Lazy) Tools ─────────────────────────────────────────────────────
|
|
12
|
-
export const DeferredToolsDB = {
|
|
13
|
-
git_commit: {
|
|
14
|
-
name: "git_commit",
|
|
15
|
-
description: "Creates a new git commit with staged changes.",
|
|
16
|
-
schema: {
|
|
17
|
-
type: "object",
|
|
18
|
-
properties: { message: { type: "string" } },
|
|
19
|
-
required: ["message"],
|
|
20
|
-
},
|
|
21
|
-
execute: async (args) => ({ content: `Committed with message: ${args.message}` }),
|
|
22
|
-
},
|
|
23
|
-
git_diff: {
|
|
24
|
-
name: "git_diff",
|
|
25
|
-
description: "Shows the diff of uncommitted changes or between two branches/commits.",
|
|
26
|
-
schema: {
|
|
27
|
-
type: "object",
|
|
28
|
-
properties: {
|
|
29
|
-
target: {
|
|
30
|
-
type: "string",
|
|
31
|
-
description: "Branch, commit, or file path (optional)",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
execute: async (args) => ({ content: `Diff for: ${args.target || "working directory"}` }),
|
|
36
|
-
},
|
|
37
|
-
git_log: {
|
|
38
|
-
name: "git_log",
|
|
39
|
-
description: "Shows recent commit history with messages and hashes.",
|
|
40
|
-
schema: {
|
|
41
|
-
type: "object",
|
|
42
|
-
properties: {
|
|
43
|
-
count: {
|
|
44
|
-
type: "number",
|
|
45
|
-
description: "Number of recent commits to show (default: 10)",
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
execute: async (args) => ({ content: `Showing last ${args.count || 10} commits.` }),
|
|
50
|
-
},
|
|
51
|
-
grep_search: {
|
|
52
|
-
name: "grep_search",
|
|
53
|
-
description: "Searches for a text pattern across project files using ripgrep. Returns matching lines with filenames and line numbers.",
|
|
54
|
-
schema: {
|
|
55
|
-
type: "object",
|
|
56
|
-
properties: {
|
|
57
|
-
query: { type: "string", description: "Search pattern (regex supported)" },
|
|
58
|
-
path: { type: "string", description: "Directory or file to search in (default: .)" },
|
|
59
|
-
includes: { type: "string", description: "File glob filter (e.g., '*.ts')" },
|
|
60
|
-
},
|
|
61
|
-
required: ["query"],
|
|
62
|
-
},
|
|
63
|
-
execute: async (args) => ({ content: `Search results for '${args.query}'` }),
|
|
64
|
-
},
|
|
65
|
-
list_dir: {
|
|
66
|
-
name: "list_dir",
|
|
67
|
-
description: "Lists the contents of a directory — files and subdirectories with sizes.",
|
|
68
|
-
schema: {
|
|
69
|
-
type: "object",
|
|
70
|
-
properties: {
|
|
71
|
-
path: { type: "string", description: "Directory path to list" },
|
|
72
|
-
},
|
|
73
|
-
required: ["path"],
|
|
74
|
-
},
|
|
75
|
-
execute: async (args) => ({ content: `Directory listing for: ${args.path}` }),
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
// ─── Active Tool Set (starts empty, filled by ActivateToolTool) ─────────────
|
|
79
|
-
const activatedTools = new Map();
|
|
80
|
-
/**
|
|
81
|
-
* Returns a tool that has been dynamically activated.
|
|
82
|
-
*/
|
|
83
|
-
export function getActivatedTool(name) {
|
|
84
|
-
return activatedTools.get(name);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Returns all currently activated tools.
|
|
88
|
-
*/
|
|
89
|
-
export function getActivatedTools() {
|
|
90
|
-
return Array.from(activatedTools.values());
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Activates a tool from the deferred registry, making it available for execution.
|
|
94
|
-
* Returns the activated tool, or undefined if not found.
|
|
95
|
-
*/
|
|
96
|
-
export function activateTool(name) {
|
|
97
|
-
const tool = DeferredToolsDB[name];
|
|
98
|
-
if (!tool)
|
|
99
|
-
return undefined;
|
|
100
|
-
activatedTools.set(name, tool);
|
|
101
|
-
return tool;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Resets all activated tools. For testing.
|
|
105
|
-
*/
|
|
106
|
-
export function resetActivatedTools() {
|
|
107
|
-
activatedTools.clear();
|
|
108
|
-
}
|
|
109
|
-
// ─── SearchToolsTool ────────────────────────────────────────────────────────────
|
|
110
|
-
/**
|
|
111
|
-
* Fuzzy search: matches on tool name OR any word in the description.
|
|
112
|
-
*/
|
|
113
|
-
function fuzzyMatch(query, tool) {
|
|
114
|
-
const q = query.toLowerCase();
|
|
115
|
-
const nameMatch = tool.name.toLowerCase().includes(q);
|
|
116
|
-
const descWords = tool.description.toLowerCase();
|
|
117
|
-
const descMatch = descWords.includes(q);
|
|
118
|
-
return nameMatch || descMatch;
|
|
119
|
-
}
|
|
120
|
-
export const SearchToolsTool = {
|
|
121
|
-
name: "search_tools",
|
|
122
|
-
description: "Search for advanced tools available in the environment. Matches by tool name or description keywords.",
|
|
123
|
-
schema: {
|
|
124
|
-
type: "object",
|
|
125
|
-
properties: {
|
|
126
|
-
query: { type: "string", description: "Search query" },
|
|
127
|
-
},
|
|
128
|
-
required: ["query"],
|
|
129
|
-
},
|
|
130
|
-
execute: async (args) => {
|
|
131
|
-
const matches = Object.values(DeferredToolsDB).filter((tool) => fuzzyMatch(args.query, tool));
|
|
132
|
-
if (matches.length === 0) {
|
|
133
|
-
return { content: `No tools found matching '${args.query}'. Available categories: git, file, search.` };
|
|
134
|
-
}
|
|
135
|
-
const descriptions = matches.map((t) => `- **${t.name}**: ${t.description}`);
|
|
136
|
-
return {
|
|
137
|
-
content: `Found ${matches.length} tool(s):\n${descriptions.join("\n")}\n\n` +
|
|
138
|
-
`To use a tool, call activate_tool with its name.`
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
// ─── ActivateToolTool ───────────────────────────────────────────────────────────
|
|
143
|
-
export const ActivateToolTool = {
|
|
144
|
-
name: "activate_tool",
|
|
145
|
-
description: "Activates a discovered tool for use. Call search_tools first to find available tools.",
|
|
146
|
-
schema: {
|
|
147
|
-
type: "object",
|
|
148
|
-
properties: {
|
|
149
|
-
name: { type: "string", description: "The tool name to activate" },
|
|
150
|
-
},
|
|
151
|
-
required: ["name"],
|
|
152
|
-
},
|
|
153
|
-
execute: async (args) => {
|
|
154
|
-
const tool = activateTool(args.name);
|
|
155
|
-
if (!tool) {
|
|
156
|
-
return {
|
|
157
|
-
content: `Error: Tool '${args.name}' not found in the registry. Use search_tools to see available tools.`,
|
|
158
|
-
isError: true
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
return {
|
|
162
|
-
content: `✓ Tool '${args.name}' activated.\n` +
|
|
163
|
-
`Schema: ${JSON.stringify(tool.schema, null, 2)}\n` +
|
|
164
|
-
`You can now call it directly.`
|
|
165
|
-
};
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,kFAAkF;AAElF,MAAM,CAAC,MAAM,eAAe,GAAyC;IACnE,UAAU,EAAE;QACV,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,+CAA+C;QAC5D,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC3C,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB;QACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,2BAA2B,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;KAClF;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,UAAU;QAChB,WAAW,EACT,wEAAwE;QAC1E,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,yCAAyC;iBACvD;aACF;SACF;QACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,IAAI,CAAC,MAAM,IAAI,mBAAmB,EAAE,EAAE,CAAC;KAC1F;IACD,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,uDAAuD;QACpE,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,gDAAgD;iBAC9D;aACF;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,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI;gBACnD,+BAA+B;SAClC,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/dist/tools/router.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Where a tool executes — on the host machine or in the sandbox.
|
|
3
|
-
*/
|
|
4
|
-
export declare enum ToolTarget {
|
|
5
|
-
/** Run on the host (Node.js process). User sees changes in IDE. */
|
|
6
|
-
HOST = "host",
|
|
7
|
-
/** Run inside the E2B sandbox. Commands are isolated. */
|
|
8
|
-
SANDBOX = "sandbox"
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Routes tool calls to either the host machine or the E2B sandbox.
|
|
12
|
-
*
|
|
13
|
-
* Design principle: File I/O runs on the host so the user sees changes
|
|
14
|
-
* in their IDE in real-time. Code execution runs in the sandbox for safety.
|
|
15
|
-
*
|
|
16
|
-
* Unknown tools default to SANDBOX (safe-by-default).
|
|
17
|
-
*/
|
|
18
|
-
export declare class ToolRouter {
|
|
19
|
-
/**
|
|
20
|
-
* Determines where a tool should execute.
|
|
21
|
-
*
|
|
22
|
-
* @param toolName The name of the tool being invoked.
|
|
23
|
-
* @returns ToolTarget.HOST or ToolTarget.SANDBOX
|
|
24
|
-
*/
|
|
25
|
-
getTarget(toolName: string): ToolTarget;
|
|
26
|
-
/**
|
|
27
|
-
* Returns true if the tool should run on the host.
|
|
28
|
-
*/
|
|
29
|
-
isHostTool(toolName: string): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Returns true if the tool should run in the sandbox.
|
|
32
|
-
*/
|
|
33
|
-
isSandboxTool(toolName: string): boolean;
|
|
34
|
-
}
|
package/dist/tools/router.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Where a tool executes — on the host machine or in the sandbox.
|
|
3
|
-
*/
|
|
4
|
-
export var ToolTarget;
|
|
5
|
-
(function (ToolTarget) {
|
|
6
|
-
/** Run on the host (Node.js process). User sees changes in IDE. */
|
|
7
|
-
ToolTarget["HOST"] = "host";
|
|
8
|
-
/** Run inside the E2B sandbox. Commands are isolated. */
|
|
9
|
-
ToolTarget["SANDBOX"] = "sandbox";
|
|
10
|
-
})(ToolTarget || (ToolTarget = {}));
|
|
11
|
-
/**
|
|
12
|
-
* Tools that execute on the host machine (no code execution risk).
|
|
13
|
-
*/
|
|
14
|
-
const HOST_TOOLS = new Set([
|
|
15
|
-
"write_file",
|
|
16
|
-
"read_file",
|
|
17
|
-
"search_tools",
|
|
18
|
-
"activate_tool",
|
|
19
|
-
"list_files",
|
|
20
|
-
"search_files",
|
|
21
|
-
"web_search",
|
|
22
|
-
"search_skills",
|
|
23
|
-
"load_skill",
|
|
24
|
-
"spawn_agent",
|
|
25
|
-
"check_agent",
|
|
26
|
-
]);
|
|
27
|
-
/**
|
|
28
|
-
* Tools that execute inside the sandboxed environment.
|
|
29
|
-
*/
|
|
30
|
-
const SANDBOX_TOOLS = new Set([
|
|
31
|
-
"bash",
|
|
32
|
-
"run_tests",
|
|
33
|
-
"install_deps",
|
|
34
|
-
"run_command",
|
|
35
|
-
"python",
|
|
36
|
-
"security_scan",
|
|
37
|
-
"dep_scan",
|
|
38
|
-
"browser",
|
|
39
|
-
]);
|
|
40
|
-
/**
|
|
41
|
-
* Routes tool calls to either the host machine or the E2B sandbox.
|
|
42
|
-
*
|
|
43
|
-
* Design principle: File I/O runs on the host so the user sees changes
|
|
44
|
-
* in their IDE in real-time. Code execution runs in the sandbox for safety.
|
|
45
|
-
*
|
|
46
|
-
* Unknown tools default to SANDBOX (safe-by-default).
|
|
47
|
-
*/
|
|
48
|
-
export class ToolRouter {
|
|
49
|
-
/**
|
|
50
|
-
* Determines where a tool should execute.
|
|
51
|
-
*
|
|
52
|
-
* @param toolName The name of the tool being invoked.
|
|
53
|
-
* @returns ToolTarget.HOST or ToolTarget.SANDBOX
|
|
54
|
-
*/
|
|
55
|
-
getTarget(toolName) {
|
|
56
|
-
if (HOST_TOOLS.has(toolName)) {
|
|
57
|
-
return ToolTarget.HOST;
|
|
58
|
-
}
|
|
59
|
-
// Default: sandbox (safe-by-default — never execute unknown tools on host)
|
|
60
|
-
return ToolTarget.SANDBOX;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns true if the tool should run on the host.
|
|
64
|
-
*/
|
|
65
|
-
isHostTool(toolName) {
|
|
66
|
-
return this.getTarget(toolName) === ToolTarget.HOST;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Returns true if the tool should run in the sandbox.
|
|
70
|
-
*/
|
|
71
|
-
isSandboxTool(toolName) {
|
|
72
|
-
return this.getTarget(toolName) === ToolTarget.SANDBOX;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=router.js.map
|
package/dist/tools/router.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/tools/router.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,mEAAmE;IACnE,2BAAa,CAAA;IACb,yDAAyD;IACzD,iCAAmB,CAAA;AACrB,CAAC,EALW,UAAU,KAAV,UAAU,QAKrB;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,YAAY;IACZ,WAAW;IACX,cAAc;IACd,eAAe;IACf,YAAY;IACZ,cAAc;IACd,YAAY;IACZ,eAAe;IACf,YAAY;IACZ,aAAa;IACb,aAAa;CACd,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,MAAM;IACN,WAAW;IACX,cAAc;IACd,aAAa;IACb,QAAQ;IACR,eAAe;IACf,UAAU;IACV,SAAS;CACV,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,OAAO,UAAU;IACrB;;;;;OAKG;IACH,SAAS,CAAC,QAAgB;QACxB,IAAI,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,OAAO,UAAU,CAAC,IAAI,CAAC;QACzB,CAAC;QACD,2EAA2E;QAC3E,OAAO,UAAU,CAAC,OAAO,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,QAAgB;QACzB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,QAAgB;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC,OAAO,CAAC;IACzD,CAAC;CACF"}
|