推进资源工具与本地优先兼容链收口
This commit is contained in:
@@ -27,6 +27,10 @@ pub fn manifest() -> Value {
|
||||
page_save_tool(),
|
||||
available_tool("mnote.page.update_title", "更新当前页面标题", ["page.write"]),
|
||||
available_tool("mnote.page.update_options", "更新当前页面设置", ["page.write"]),
|
||||
mindmap_fetch_tool(),
|
||||
mindmap_apply_ops_tool(),
|
||||
office_fetch_summary_tool(),
|
||||
office_propose_changes_tool(),
|
||||
available_tool("mnote.artifact.create_summary", "为当前页面创建或更新 AI Summary", ["artifact.write"]),
|
||||
available_tool("mnote.artifact.create_ai_note", "基于当前页面创建新的 AI Note", ["artifact.write"])
|
||||
]
|
||||
@@ -479,6 +483,120 @@ fn doc_markdown_edit_tool() -> Value {
|
||||
tool
|
||||
}
|
||||
|
||||
fn resource_identity_properties(resource_id_name: &str) -> Value {
|
||||
let mut properties = base_identity_properties();
|
||||
if let Value::Object(map) = &mut properties {
|
||||
map.insert("rootUri".into(), json!({ "type": "string" }));
|
||||
map.insert("sourceKind".into(), json!({ "type": "string" }));
|
||||
map.insert(resource_id_name.into(), json!({ "type": "string" }));
|
||||
map.insert("resourcePath".into(), json!({ "type": "string" }));
|
||||
map.insert(
|
||||
"aiAccessScope".into(),
|
||||
json!({
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"permissionLevel": { "type": "string" },
|
||||
"allowedResourceIds": { "type": "array", "items": { "type": "string" } },
|
||||
"allowedRoots": { "type": "array" }
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
properties
|
||||
}
|
||||
|
||||
fn mindmap_fetch_tool() -> Value {
|
||||
let mut properties = resource_identity_properties("mindmapId");
|
||||
if let Value::Object(map) = &mut properties {
|
||||
map.insert(
|
||||
"scope".into(),
|
||||
json!({ "type": "string", "enum": ["tree", "subtree", "markdown_summary"], "default": "tree" }),
|
||||
);
|
||||
map.insert("nodeId".into(), json!({ "type": "string" }));
|
||||
}
|
||||
json!({
|
||||
"name": "mnote.mindmap.fetch",
|
||||
"description": "读取授权 root 内的 mindmap resource 结构或 markdown summary",
|
||||
"schemaVersion": TOOL_SCHEMA_VERSION,
|
||||
"capabilityScope": ["resource.read", "mindmap.read"],
|
||||
"status": "available",
|
||||
"annotations": tool_annotations(true, false, true, false),
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["workspaceId", "documentId", "mindmapId", "sessionId", "runId", "toolCallId", "traceId", "actorId"],
|
||||
"properties": properties
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn mindmap_apply_ops_tool() -> Value {
|
||||
write_tool(
|
||||
"mnote.mindmap.apply_ops",
|
||||
"对授权 mindmap resource 生成或执行结构操作;本地 workspace 默认建议 agent 直接编辑授权文件,必要时才走该工具",
|
||||
["resource.write", "mindmap.write"],
|
||||
json!({
|
||||
"mindmapId": { "type": "string" },
|
||||
"rootUri": { "type": "string" },
|
||||
"sourceKind": { "type": "string" },
|
||||
"resourcePath": { "type": "string" },
|
||||
"expectedRevision": { "type": ["number", "string"] },
|
||||
"ops": {
|
||||
"type": "array",
|
||||
"items": { "type": "object" }
|
||||
},
|
||||
"aiAccessScope": { "type": "object" }
|
||||
}),
|
||||
["mindmapId", "ops"],
|
||||
)
|
||||
}
|
||||
|
||||
fn office_fetch_summary_tool() -> Value {
|
||||
let mut properties = resource_identity_properties("assetId");
|
||||
if let Value::Object(map) = &mut properties {
|
||||
map.insert(
|
||||
"extractMode".into(),
|
||||
json!({ "type": "string", "enum": ["text", "outline", "metadata"], "default": "metadata" }),
|
||||
);
|
||||
}
|
||||
json!({
|
||||
"name": "mnote.office.fetch_summary",
|
||||
"description": "读取授权 Office resource 的元数据和轻量文本摘要;不直接写二进制文件",
|
||||
"schemaVersion": TOOL_SCHEMA_VERSION,
|
||||
"capabilityScope": ["resource.read", "office.read"],
|
||||
"status": "available",
|
||||
"annotations": tool_annotations(true, false, true, false),
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["workspaceId", "documentId", "assetId", "sessionId", "runId", "toolCallId", "traceId", "actorId"],
|
||||
"properties": properties
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn office_propose_changes_tool() -> Value {
|
||||
let mut properties = resource_identity_properties("assetId");
|
||||
if let Value::Object(map) = &mut properties {
|
||||
map.insert("instructions".into(), json!({ "type": "string" }));
|
||||
map.insert(
|
||||
"basisRevision".into(),
|
||||
json!({ "type": ["number", "string"] }),
|
||||
);
|
||||
}
|
||||
json!({
|
||||
"name": "mnote.office.propose_changes",
|
||||
"description": "基于授权 Office resource 生成修改建议;真实写入仍由 OnlyOffice / officecli 完成",
|
||||
"schemaVersion": TOOL_SCHEMA_VERSION,
|
||||
"capabilityScope": ["resource.read", "office.read"],
|
||||
"status": "available",
|
||||
"annotations": tool_annotations(true, false, true, false),
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["workspaceId", "documentId", "assetId", "sessionId", "runId", "toolCallId", "traceId", "actorId", "instructions"],
|
||||
"properties": properties
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn tool_annotations(
|
||||
readonly: bool,
|
||||
destructive: bool,
|
||||
|
||||
Reference in New Issue
Block a user