feat: upgrade investigation and presentation runtime
This commit is contained in:
@@ -164,7 +164,7 @@ export class OpencodeRuntimeAdapter {
|
||||
return response.output as { id: string; direct: boolean; sandboxed: boolean; workspaceRoot?: string }[] | undefined;
|
||||
};
|
||||
let tools = await readTools();
|
||||
const required = [...LOCAL_QUERY_TOOL_IDS, ...(config.TJWATER_MCP_ENABLED ? PRODUCT_MCP_TOOL_IDS : []), "shell", "ask_user", "final_answer", "present_answer", "locate_features", "zoom_to_map", "show_chart", "view_history", "memory_manager", "skill_manager", "render_scada_analysis", "clear_scada_analysis", "publish_execution_plan", "publish_task_report", "publish_task_progress", "publish_task_presentation", "propose_task_action", "add_task_human_evidence", "request_task_data_access", "todowrite", "send_task_message", "reply_agent_message"];
|
||||
const required = [...LOCAL_QUERY_TOOL_IDS, ...(config.TJWATER_MCP_ENABLED ? PRODUCT_MCP_TOOL_IDS : []), "shell", "ask_user", "ask_task_user", "final_answer", "present_answer", "present_view", "memory_manager", "skill_manager", "publish_execution_plan", "publish_task_report", "publish_task_progress", "publish_task_presentation", "propose_task_action", "add_task_human_evidence", "request_task_data_access", "todowrite", "send_task_message", "reply_agent_message"];
|
||||
let missing = required.filter((name) => !tools?.some((tool) => tool.id === name && tool.direct));
|
||||
const catalogDeadline = Date.now() + 10_000;
|
||||
// Native MCP connection/catalog publication can finish after plugin setup.
|
||||
@@ -284,7 +284,8 @@ export class OpencodeRuntimeAdapter {
|
||||
let sessionId: string | undefined;
|
||||
try {
|
||||
const session = await client.session.create({
|
||||
title: "prompt-suggestions", agent: "instruction",
|
||||
title: "prompt-suggestions", agent: "prompt-suggestions",
|
||||
permissions: [{ action: "*", resource: "*", effect: "deny" }],
|
||||
model: { providerID: selected.providerID, id: selected.modelID },
|
||||
location: { directory },
|
||||
}, { signal });
|
||||
|
||||
@@ -68,24 +68,33 @@ export function serviceOpencodeConfig(input: Record<string, unknown>, models: Ag
|
||||
instruction: {
|
||||
description: "TJWater structured data and UI agent", mode: "primary", ...instruction, model: models.defaults.chat, system,
|
||||
permissions: [
|
||||
{ action: "ask_task_user", resource: "*", effect: "deny" },
|
||||
...agentMessageTools.map((action): PermissionRule => ({ action, resource: "*", effect: action.startsWith("mcp_") && deniedProductQuery(action, (input.permissions ?? []) as PermissionRule[]) ? "deny" : "allow" })),
|
||||
...((instruction.permissions ?? []) as PermissionRule[]),
|
||||
{ action: "subagent", resource: "*", effect: "deny" },
|
||||
],
|
||||
},
|
||||
"prompt-suggestions": {
|
||||
description: "仅根据已加载活动生成推荐问题 JSON", mode: "primary",
|
||||
model: models.defaults.chat,
|
||||
system: readFileSync(resolve(".opencode/agents/prompt-suggestions.md"), "utf8"),
|
||||
permissions: [{ action: "*", resource: "*", effect: "deny" }],
|
||||
},
|
||||
[TASK_AGENT]: {
|
||||
description: "后台工况调查,协调只读子任务并统一发布进展与报告", mode: "primary",
|
||||
model: models.defaults.task,
|
||||
system: `${system}\n\n${readFileSync(resolve(".opencode/agents/investigation.md"), "utf8")}`,
|
||||
permissions: [
|
||||
{ action: "ask_task_user", resource: "*", effect: "allow" },
|
||||
{ action: "question", resource: "*", effect: "deny" },
|
||||
{ action: "ask_user", resource: "*", effect: "deny" },
|
||||
...agentMessageTools.map((action): PermissionRule => ({ action, resource: "*", effect: [queryMcpToolId("read_agent_messages"), "reply_agent_message"].includes(action) && !(action.startsWith("mcp_") && deniedProductQuery(action, (input.permissions ?? []) as PermissionRule[])) ? "allow" : "deny" })),
|
||||
{ action: "subagent", resource: "*", effect: "deny" },
|
||||
{ action: "subagent", resource: TASK_READER_AGENT, effect: "allow" },
|
||||
],
|
||||
},
|
||||
[TASK_READER_AGENT]: {
|
||||
description: "独立核查一项调查问题,仅查询当前任务授权资料并返回证据编号、发现与局限", mode: "subagent",
|
||||
system: readFileSync(resolve(".opencode/agents/investigation-reader.md"), "utf8"),
|
||||
description: "运行时只读调查子代理,具体核查提示由父调查在每次调用中提供", mode: "subagent",
|
||||
permissions: [
|
||||
{ action: "*", resource: "*", effect: "deny" },
|
||||
...TASK_READER_TOOLS.filter((name) => !PRODUCT_MCP_TOOL_IDS.includes(name) || !deniedProductQuery(name, (input.permissions ?? []) as PermissionRule[])).map((action) => ({ action, resource: "*", effect: "allow" })),
|
||||
|
||||
@@ -3,7 +3,7 @@ import { dirname, join, resolve } from "node:path";
|
||||
|
||||
// Only a public loopback endpoint, outside model-writable workspaces. The
|
||||
// trusted OpenCode process already owns its separate internal-channel token.
|
||||
export function writeQueryMcpConnection(metadataRoot: string, url: string, executionTimeoutMs = 35_000) {
|
||||
export function writeQueryMcpConnection(metadataRoot: string, url: string, executionTimeoutMs = 300_000) {
|
||||
const path = resolve(join(dirname(metadataRoot), "mcp-query", "connection.json"));
|
||||
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
||||
const temporary = `${path}.${process.pid}.tmp`;
|
||||
|
||||
Reference in New Issue
Block a user