6af26f407c
Phase 4 - Web search tool: - Brave Search API + SearXNG fallback - Configurable provider, max results - 14 tests Phase 5 - Background process management: - ProcessManager with start/status/output/kill/list tools - Configurable max concurrent, max runtime, buffer size - 28 tests
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import type { Tool, ToolResult } from '../../types.js';
|
|
import type { ProcessManager } from './manager.js';
|
|
|
|
interface ProcessOutputArgs {
|
|
id: string;
|
|
}
|
|
|
|
export function createProcessOutputTool(manager: ProcessManager): Tool {
|
|
return {
|
|
name: 'process.output',
|
|
description: 'Read recent stdout/stderr output from a background process. Returns the last ~64KB of output.',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'string', description: 'Process ID (e.g. "proc_1")' },
|
|
},
|
|
required: ['id'],
|
|
},
|
|
execute: async (rawArgs: unknown): Promise<ToolResult> => {
|
|
const args = rawArgs as ProcessOutputArgs;
|
|
try {
|
|
const output = manager.getOutput(args.id);
|
|
if (!output) {
|
|
return { success: true, output: '(no output yet)' };
|
|
}
|
|
return { success: true, output };
|
|
} catch (error) {
|
|
return {
|
|
success: false,
|
|
output: '',
|
|
error: error instanceof Error ? error.message : 'Failed to get process output',
|
|
};
|
|
}
|
|
},
|
|
};
|
|
}
|