feat(agent): unify MCP tools and adopt Responses delivery
Move project and host queries into native MCP with host-owned OAuth/context, while retaining memory, skills, actions and publication plugins. Add nearby-model queries and explicit chat/task/learning model defaults. Adopt Responses HTTP/SSE and native steer/queue inbox delivery, preserving scoped session ownership, pending input edits and investigation communication. Disable local-provider discovery: Server /health allowed native vLLM to probe /v1/models on port 8000. A native before/after regression prevents recurrence. Validation: 170 focused Bun tests; service/plugin typechecks; native discovery, provider-discovery and input-inbox smoke checks; no paid model inference.
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
import query_project_data from "../tools/query_project_data.js";
|
||||
import web_search from "../tools/web_search.js";
|
||||
import geocode from "../tools/geocode.js";
|
||||
import final_answer from "../tools/final_answer.js";
|
||||
import present_answer from "../tools/present_answer.js";
|
||||
import locate_features from "../tools/locate_features.js";
|
||||
@@ -12,25 +9,26 @@ import { z } from "zod";
|
||||
import { resolve } from "node:path";
|
||||
import { registerSessionSandbox } from "../session-sandbox.js";
|
||||
import { registerMcpPolicy } from "../mcp-policy.js";
|
||||
import { registerTaskAgentPolicy } from "../task-agent-policy.js";
|
||||
import { AGENT_MESSAGE_TOOLS, registerAgentMessagePolicy } from "../agent-message-policy.js";
|
||||
import { checkOpencodeModels } from "../model-check.js";
|
||||
import { DEFAULT_SESSION_WORKSPACE_ROOT } from "../../src/runtime/conversationWorkspace.js";
|
||||
|
||||
import add_task_human_evidence from "../tools/add_task_human_evidence.js";
|
||||
import clear_scada_analysis from "../tools/clear_scada_analysis.js";
|
||||
import get_operational_task_context from "../tools/get_operational_task_context.js";
|
||||
import memory_manager from "../tools/memory_manager.js";
|
||||
import propose_task_action from "../tools/propose_task_action.js";
|
||||
import publish_execution_plan from "../tools/publish_execution_plan.js";
|
||||
import publish_task_report from "../tools/publish_task_report.js";
|
||||
import query_operational_task_data from "../tools/query_operational_task_data.js";
|
||||
import publish_task_progress from "../tools/publish_task_progress.js";
|
||||
import publish_task_presentation from "../tools/publish_task_presentation.js";
|
||||
import render_scada_analysis from "../tools/render_scada_analysis.js";
|
||||
import request_task_data_access from "../tools/request_task_data_access.js";
|
||||
import session_search from "../tools/session_search.js";
|
||||
import skill_manager from "../tools/skill_manager.js";
|
||||
import send_task_message from "../tools/send_task_message.js";
|
||||
import reply_agent_message from "../tools/reply_agent_message.js";
|
||||
|
||||
const businessTools = {
|
||||
web_search,
|
||||
geocode,
|
||||
query_project_data,
|
||||
final_answer,
|
||||
present_answer,
|
||||
locate_features,
|
||||
@@ -39,16 +37,17 @@ const businessTools = {
|
||||
view_history,
|
||||
add_task_human_evidence,
|
||||
clear_scada_analysis,
|
||||
get_operational_task_context,
|
||||
memory_manager,
|
||||
propose_task_action,
|
||||
publish_execution_plan,
|
||||
publish_task_report,
|
||||
query_operational_task_data,
|
||||
publish_task_progress,
|
||||
publish_task_presentation,
|
||||
render_scada_analysis,
|
||||
request_task_data_access,
|
||||
session_search,
|
||||
skill_manager,
|
||||
send_task_message,
|
||||
reply_agent_message,
|
||||
};
|
||||
|
||||
export default Plugin.define({
|
||||
@@ -57,7 +56,8 @@ export default Plugin.define({
|
||||
await registerSessionSandbox(ctx);
|
||||
await ctx.tool.transform((editor) => {
|
||||
for (const [name, definition] of Object.entries(businessTools)) {
|
||||
const input = z.object(definition.args);
|
||||
const object = z.object(definition.args);
|
||||
const input = (AGENT_MESSAGE_TOOLS as readonly string[]).includes(name) ? object.strict() : object;
|
||||
editor.add({
|
||||
name,
|
||||
description: definition.description,
|
||||
@@ -83,6 +83,7 @@ export default Plugin.define({
|
||||
priority: z.enum(["low", "medium", "high"]).optional(),
|
||||
});
|
||||
await ctx.tool.transform((editor) => {
|
||||
editor.remove("todoread");
|
||||
editor.add({
|
||||
name: "todowrite",
|
||||
description: "Update the current session's task checklist.",
|
||||
@@ -93,20 +94,18 @@ export default Plugin.define({
|
||||
return { content: JSON.stringify(todos) };
|
||||
},
|
||||
});
|
||||
editor.add({
|
||||
name: "todoread",
|
||||
description: "Read the current session's task checklist.",
|
||||
input: z.object({}),
|
||||
options: { codemode: false, permission: "todoread" },
|
||||
async execute(_input, context) {
|
||||
return { content: JSON.stringify(await ctx.storage.get(`todos/${context.sessionID}`) ?? []) };
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
const mcpReport = await registerMcpPolicy(ctx);
|
||||
await registerTaskAgentPolicy(ctx);
|
||||
await registerAgentMessagePolicy(ctx);
|
||||
await ctx.rpc.register(Rpc.define({
|
||||
id: "tjwater.tools",
|
||||
methods: {
|
||||
read_todos: {
|
||||
input: z.object({ session_id: z.string().min(1).max(128) }).strict(),
|
||||
output: z.array(todoItem),
|
||||
},
|
||||
check_models: {
|
||||
input: z.object({ models: z.array(z.object({ id: z.string(), provider_id: z.string(), model_id: z.string(), wire_id: z.string(), requires_tools: z.boolean() }).strict()).min(1).max(1000) }).strict(),
|
||||
output: z.object({
|
||||
@@ -132,13 +131,14 @@ export default Plugin.define({
|
||||
},
|
||||
events: {},
|
||||
}), {
|
||||
read_todos: async (input) => z.array(todoItem).parse(await ctx.storage.get(`todos/${input.session_id}`) ?? []),
|
||||
check_models: (input, context) => checkOpencodeModels(ctx, input, context.signal),
|
||||
mcp: mcpReport,
|
||||
list: async () => (await ctx.tool.list()).map((tool) => ({
|
||||
id: tool.id,
|
||||
direct: tool.options?.codemode === false,
|
||||
sandboxed: tool.id === "shell" && tool.description.includes("Landlock + seccomp"),
|
||||
...(tool.id === "shell" ? { workspaceRoot: resolve(process.env.TJWATER_AGENT_WORKSPACE_ROOT ?? ".agent-workspaces") } : {}),
|
||||
...(tool.id === "shell" ? { workspaceRoot: resolve(process.env.TJWATER_AGENT_WORKSPACE_ROOT ?? DEFAULT_SESSION_WORKSPACE_ROOT) } : {}),
|
||||
})),
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user