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:
@@ -0,0 +1,30 @@
|
||||
import { z } from "zod";
|
||||
import { getInternalBridgeConfig } from "./internalBridge.js";
|
||||
import { tool, type ToolContext } from "./tool.js";
|
||||
|
||||
type Operation = "send" | "reply";
|
||||
|
||||
// This helper is not a model-facing tool. Each registered tool fixes its operation
|
||||
// and input contract; the bridge resolves identity, project, run and thread scope.
|
||||
export function agentMessageTool<Args extends z.ZodRawShape>(operation: Operation, definition: {
|
||||
description: string;
|
||||
args: Args;
|
||||
}) {
|
||||
const inputSchema = z.object(definition.args).strict();
|
||||
return tool({
|
||||
...definition,
|
||||
async execute(args, context: ToolContext) {
|
||||
const input = inputSchema.parse(args);
|
||||
const { baseUrl, internalToken } = getInternalBridgeConfig();
|
||||
const response = await fetch(`${baseUrl}/internal/agent-messages/${operation}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", "x-agent-internal-token": internalToken },
|
||||
signal: context.signal,
|
||||
body: JSON.stringify({ session_id: context.sessionID, input }),
|
||||
});
|
||||
const text = await response.text();
|
||||
if (!response.ok) throw new Error(`agent message ${operation} failed (${response.status}): ${text}`);
|
||||
return text;
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user