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,38 @@
|
||||
import { expect, it } from "bun:test";
|
||||
import { mkdtemp, rm } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { createServer } from "node:net";
|
||||
|
||||
const availablePort = () => new Promise<number>((done, reject) => {
|
||||
const server = createServer();
|
||||
server.once("error", reject);
|
||||
server.listen(0, "127.0.0.1", () => {
|
||||
const port = (server.address() as { port: number }).port;
|
||||
server.close((error) => error ? reject(error) : done(port));
|
||||
});
|
||||
});
|
||||
|
||||
it("passes the isolated connection path to OpenCode before the Agent writes it", async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), "query-launcher-test-"));
|
||||
try {
|
||||
const ports = await Promise.all([availablePort(), availablePort()]);
|
||||
// Execute the real launcher up to its first dependency. No OpenCode, Agent,
|
||||
// provider or business service starts; the dependency records its inputs.
|
||||
const script = `import { mock } from "bun:test";
|
||||
mock.module(${JSON.stringify(resolve("src/runtime/opencode2-server.ts"))}, () => ({ startOpencode2: async (options) => {
|
||||
console.log("LAUNCHER_ENV=" + JSON.stringify({ connection: options.env.TJWATER_AGENT_MCP_CONNECTION_PATH }));
|
||||
return { password: "TEST_ONLY", exited: Promise.resolve(0), close() {}, client: { server: { async info() { throw new Error("STOP_BEFORE_AGENT"); } } } };
|
||||
} }));
|
||||
await import(${JSON.stringify(resolve("scripts/start-isolated-integration.ts"))});`;
|
||||
const child = Bun.spawn([process.execPath, "-e", script], { cwd: process.cwd(),
|
||||
env: { ...process.env, INTEGRATION_DATA_DIR: root, INTEGRATION_AGENT_PORT: String(ports[0]), INTEGRATION_OPENCODE_PORT: String(ports[1]),
|
||||
TJWATER_AGENT_MCP_CONNECTION_PATH: "/unrelated/connection.json", AGENT_INTERNAL_TOKEN: "TEST_ONLY" }, stdout: "pipe", stderr: "pipe" });
|
||||
const [code, out, err] = await Promise.all([child.exited, new Response(child.stdout).text(), new Response(child.stderr).text()]);
|
||||
expect(code).toBe(1);
|
||||
expect(err).toContain("STOP_BEFORE_AGENT");
|
||||
const record = out.split("\n").find((line) => line.startsWith("LAUNCHER_ENV="));
|
||||
expect(record).toBeDefined();
|
||||
expect(JSON.parse(record!.slice("LAUNCHER_ENV=".length)).connection).toBe(join(root, "mcp-query", "connection.json"));
|
||||
} finally { await rm(root, { recursive: true, force: true }); }
|
||||
});
|
||||
Reference in New Issue
Block a user