chore: import upstream snapshot with attribution
FreeBSD Smoke / FreeBSD Smoke (x86_64) (push) Has been cancelled
CI / Quality Guardrails (push) Has been cancelled
CI / Build & Test (macos-latest) (push) Has been cancelled
CI / Build & Test (ubuntu-latest) (push) Has been cancelled
CI / Build & Test (windows-latest) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / PowerShell Syntax (push) Has been cancelled
CI / Windows Cross-Target Check (Linux) (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:10:34 +08:00
commit a789495a98
1551 changed files with 718128 additions and 0 deletions
+93
View File
@@ -0,0 +1,93 @@
#[derive(Debug, Clone)]
pub struct ToolOutput {
pub output: String,
pub title: Option<String>,
pub metadata: Option<serde_json::Value>,
pub images: Vec<ToolImage>,
}
#[derive(Debug, Clone)]
pub struct ToolImage {
pub media_type: String,
pub data: String,
pub label: Option<String>,
}
impl ToolOutput {
pub fn new(output: impl Into<String>) -> Self {
Self {
output: output.into(),
title: None,
metadata: None,
images: Vec::new(),
}
}
pub fn with_title(mut self, title: impl Into<String>) -> Self {
self.title = Some(title.into());
self
}
pub fn with_metadata(mut self, metadata: serde_json::Value) -> Self {
self.metadata = Some(metadata);
self
}
pub fn with_image(mut self, media_type: impl Into<String>, data: impl Into<String>) -> Self {
self.images.push(ToolImage {
media_type: media_type.into(),
data: data.into(),
label: None,
});
self
}
pub fn with_labeled_image(
mut self,
media_type: impl Into<String>,
data: impl Into<String>,
label: impl Into<String>,
) -> Self {
self.images.push(ToolImage {
media_type: media_type.into(),
data: data.into(),
label: Some(label.into()),
});
self
}
}
/// Resolve tool name aliases to their canonical internal names.
///
/// When using OAuth, the API presents tools with Claude Code names
/// (e.g. `file_grep`, `shell_exec`). The model uses those names in
/// sub-tool calls (e.g. inside `batch`), but our registry uses internal
/// names (`grep`, `bash`). This mapping ensures both forms resolve
/// correctly.
///
/// This lives in `jcode-tool-types` (rather than the tool `Registry`) so that
/// low-level crates such as config can normalize tool names without depending
/// on the full tool subsystem.
pub fn resolve_tool_name(name: &str) -> &str {
match name {
"communicate" => "swarm",
"task" | "task_runner" => "subagent",
"launch" => "open",
"shell" => "bash",
"shell_exec" => "bash",
"read_file" => "read",
"file_read" => "read",
"write_file" => "write",
"file_write" => "write",
"edit_file" => "edit",
"file_edit" => "edit",
// The native grep tool was removed in favor of agentgrep, but models
// still frequently call `grep` (and OAuth's `file_grep`). agentgrep's
// grep mode accepts `pattern` as an alias for `query`, so these calls
// work as-is.
"grep" | "file_grep" => "agentgrep",
"skill" | "Skill" => "skill_manage",
"todoread" | "todowrite" | "todo_read" | "todo_write" | "todos" => "todo",
other => other,
}
}