Files
next-tjwater-agent/src/runtime/query-mcp-policy.ts
T
jiang b8f7edb3ee
Generic Container CI/CD / test-build-publish (push) Successful in 1m53s
Agent CI/CD / build-test-publish-and-deploy (push) Successful in 1m53s
feat(agent): improve investigation contracts and runtime readiness
2026-11-07 19:43:57 +08:00

14 lines
1.3 KiB
TypeScript

import type { RuntimeSessionContext } from "./sessionContext.js";
import { LOCAL_QUERY_TOOLS, PRODUCT_MCP_TOOLS, PRODUCT_MCP_READ_TOOLS, PRODUCT_MCP_WRITE_TOOLS, queryMcpToolId } from "./product-mcp-tools.js";
const projectLocal = new Set(["geocode", "list_investigation_tasks", "get_investigation_task", "read_agent_messages"]);
export function allowedQueryTools(context: RuntimeSessionContext, reader = false): string[] {
if (context.learningMode === "review") return [];
const project = !!context.projectId && !context.projectKey.startsWith("personal-") && ["ordinary_chat", "task_execution", "task_collaboration"].includes(context.purpose ?? "");
if (reader) return project ? PRODUCT_MCP_READ_TOOLS.map(queryMcpToolId) : [];
const burstEvent = !!context.taskId && context.taskWorkflow === "burst_report" && !context.taskReplay;
return [...(project ? PRODUCT_MCP_TOOLS.filter((name) => (!burstEvent || name !== "run_burst_location")
&& (!(PRODUCT_MCP_WRITE_TOOLS as readonly string[]).includes(name) || context.purpose === "ordinary_chat")) : []), ...LOCAL_QUERY_TOOLS.filter((name) =>
(!projectLocal.has(name) || project) && !(context.purpose === "task_execution" && ["list_investigation_tasks", "get_investigation_task"].includes(name)))].map(queryMcpToolId);
}