loopengine 0.0.1 → 0.0.2

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.
@@ -1,27 +0,0 @@
1
- // Resolves an AgentConfig's mcpServers (if any) into real tools. This is
2
- // what makes MCP support config-driven instead of one bespoke async
3
- // builder function per server: an agent that declares mcpServers and one
4
- // that doesn't both go through loadAgent() the same way — it's a no-op
5
- // passthrough for the latter. agent-registry.ts calls this for every
6
- // agent, so adding a new MCP-backed agent means writing an AgentConfig,
7
- // not a new .ts file with its own connection-handling logic.
8
- import { connectMcpTools } from './mcp-tools.js';
9
- export async function loadAgent(config) {
10
- if (!config.mcpServers?.length) {
11
- return { config: { ...config, tools: config.tools ?? [] }, close: async () => { } };
12
- }
13
- const connections = await Promise.all(config.mcpServers.map(connectMcpTools));
14
- const mcpTools = connections.flatMap((c) => c.tools);
15
- // Last-one-wins on name collisions (hand-written tool vs. MCP tool, or
16
- // two MCP servers exposing the same name) — same resolution run-agent.ts
17
- // itself uses when it builds its own tool map. Sending the model a
18
- // duplicate tool name in its schema list would be a live API error, so
19
- // this dedupes before it gets that far.
20
- const byName = new Map([...(config.tools ?? []), ...mcpTools].map((t) => [t.name, t]));
21
- return {
22
- config: { ...config, tools: [...byName.values()] },
23
- close: async () => {
24
- await Promise.all(connections.map((c) => c.close()));
25
- },
26
- };
27
- }
@@ -1,11 +0,0 @@
1
- import { type StdioServerParameters } from '@modelcontextprotocol/sdk/client/stdio.js';
2
- import type { ToolDefinition } from './agent-config.js';
3
- export interface McpConnection {
4
- tools: ToolDefinition[];
5
- close: () => Promise<void>;
6
- }
7
- /** Spawns an MCP server over stdio, discovers its tools via listTools(),
8
- * and wraps each one so execute() forwards to callTool() on the real
9
- * server. Call close() when the agent is done with it (or on process
10
- * shutdown) to kill the child process. */
11
- export declare function connectMcpTools(serverParams: StdioServerParameters): Promise<McpConnection>;
package/dist/mcp-tools.js DELETED
@@ -1,31 +0,0 @@
1
- // Wraps a real MCP server's tools as ToolDefinition[] — the same shape as
2
- // any hand-written tool (agent-config.ts), so they drop straight into
3
- // AgentConfig.tools. Neither run-agent.ts nor ActAuth nor ToolLane know or
4
- // care that these particular tools proxy to a subprocess speaking MCP
5
- // instead of running in-process; permission gating and execution still go
6
- // through the exact same path as lookup_order or read_file.
7
- import { Client } from '@modelcontextprotocol/sdk/client/index.js';
8
- import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
9
- /** Spawns an MCP server over stdio, discovers its tools via listTools(),
10
- * and wraps each one so execute() forwards to callTool() on the real
11
- * server. Call close() when the agent is done with it (or on process
12
- * shutdown) to kill the child process. */
13
- export async function connectMcpTools(serverParams) {
14
- const client = new Client({ name: 'loopengine', version: '0.0.1' });
15
- await client.connect(new StdioClientTransport(serverParams));
16
- const { tools } = await client.listTools();
17
- const toolDefs = tools.map((tool) => ({
18
- name: tool.name,
19
- description: tool.description ?? tool.name,
20
- input_schema: tool.inputSchema,
21
- execute: async (input) => {
22
- const result = await client.callTool({ name: tool.name, arguments: input });
23
- const text = result.content
24
- .filter((block) => block.type === 'text')
25
- .map((block) => block.text)
26
- .join('\n');
27
- return result.isError ? { error: text } : text;
28
- },
29
- }));
30
- return { tools: toolDefs, close: () => client.close() };
31
- }