Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/**
* Phase 7 S4 — pure tool-name → display/permission helpers for Claude.
*
* Mirrors the shape of [copilotToolDisplay.ts](../copilot/copilotToolDisplay.ts)
* but is keyed off the SDK's built-in tool list. The mapping table lives
* here (and is snapshot-tested in
* [claudeToolDisplay.test.ts](../../test/node/claudeToolDisplay.test.ts))
* so renames of either the SDK tool names or the host's `permissionKind`
* union flow through compile-checks and the snapshot diff.
*
* No I/O, no DI; safe to import from any layer of `agentHost`.
*/
/**
* Auto-approval kind reported alongside `pending_confirmation` signals
* (see `IAgentToolPendingConfirmationSignal.permissionKind` in
* [agentService.ts:317](../../common/agentService.ts#L317)).
*
* Phase 7 only emits the subset relevant to Claude's built-in tools —
* `hook` and `memory` are reserved for later phases.
*/
export
type
ClaudePermissionKind
=
|
'shell'
|
'write'
|
'mcp'
|
'read'
|
'url'
|
'skill'
|
'custom-tool'
;
/**
* Phase 8.5 — rendering hint for the workbench. Drives terminal /
* search / subagent renderers (the workbench picks a renderer off
* `_meta.toolKind`; unknown values fall through to the generic tool
* renderer). Mirror of
* [`copilotToolDisplay.getToolKind`](../copilot/copilotToolDisplay.ts).
*/
export
type
ClaudeToolKind
=
;
/**
* Which field on the SDK's `tool_input` carries the path/url surfaced
* to the user (and tracked by Phase 8 for file-edit tools). One field
* per tool — tools without a path-bearing field omit this.
*/
type
ClaudeToolPathField
=
'file_path'
|
'notebook_path'
|
'path'
|
'url'
;
/**
* Single source-of-truth row for one of Claude's built-in tools. Every
* structural fact the host needs about the tool sits in this row; the
* exported helpers below are one-liners over the table. Adding a new
* SDK tool means adding one row and one `displayName` arm. The
* snapshot test in [claudeToolDisplay.test.ts](../../test/node/claudeToolDisplay.test.ts)
* fails until both this map and the snapshot are updated together.
*
* `displayName` is intentionally NOT on the row — it is user-facing
* and must be `localize()`-d, which we cannot do at module-init time
* without freezing the bundle's locale. Lookup lives in
* {@link getClaudeToolDisplayName}.
*/
interface
ClaudeToolRow
{
readonly
:
;
/** Field on `tool_input` carrying the path/url for this tool, if any. */
readonly
?
:
;
/** True for tools whose execution writes to disk and is tracked by `FileEditTracker` (Phase 8). */
readonly
?
:
true
;
/**
* True for tools the SDK never auto-approves under any
* `permissionMode` (so they always reach `canUseTool`). Drives
* {@link INTERACTIVE_CLAUDE_TOOLS}.
*/
readonly
?
:
true
;
/**
* Phase 8.5 — rendering hint for the workbench. Omit for tools that
* use the generic renderer without specialized streaming behavior.
*/
readonly
?
:
;
}
const
TOOL_ROWS
:
{
readonly
[
:
string
]
:
}
=
{
// shell tools — no `language` is carried: the workbench picks
// `'shellscript'` from the tool name (it only special-cases
// `'powershell'`), and the SDK's `Bash` tool is the generic shell
// entry point (bash on POSIX, Git Bash on Windows), so claiming a
// specific dialect here would be misleading and unused.
:
{
:
'shell'
,
:
'terminal'
}
,
:
{
:
'shell'
,
:
'terminal'
}
,
:
{
:
'shell'
,
:
'terminal'
}
,
// read tools
:
{
:
'read'
,
:
'file_path'
,
:
'read'
}
,
:
{
:
'read'
,
:
'path'
,
:
'search'
}
,
:
{
:
'read'
,
:
'path'
,
:
'search'
}
,
LS
:
{
:
'read'
,
:
'path'
}
,
:
{
:
'read'
,
:
'notebook_path'
,
:
'read'
}
,
// write tools
:
{
:
'write'
,
:
'file_path'
,
:
true
}
,
:
{
:
'write'
,
:
'file_path'
,
:
true
}
,
:
{
:
'write'
,
:
'file_path'
,
:
true
}
,
:
{
:
'write'
,
:
'notebook_path'
,
:
true
}
,
:
{
:
'write'
}
,
// network tools
:
{
:
'url'
,
:
'url'
}
,
// host-routed / custom
:
{
:
'custom-tool'
,
:
'subagent'
}
,
:
{
:
'custom-tool'
,
:
'subagent'
}
,
:
{
:
'custom-tool'
,
:
true
}
,
:
{
:
'custom-tool'
,
:
true
}
,
// skill + task-list family — host-routed custom tools that render in the
// generic tool renderer (no `toolKind`) but carry rich invocation /
// past-tense messages so their collapsed row is self-explanatory.
:
{
:
'skill'
}
,
:
{
:
'custom-tool'
}
,
:
{
:
'custom-tool'
}
,
:
{
:
'custom-tool'
}
,
:
{
:
'custom-tool'
}
,
}
;
const
MCP_TOOL_PREFIX
=
'mcp__'
;
/**
* S4 row lookup. Falls back to `'custom-tool'` for unknown tools so
* Claude's growing built-in list never breaks the host.
*/
export
function
getClaudePermissionKind
(
:
string
)
:
{
const
=
TOOL_ROWS
[
]
;
if
(
)
{
return
.
;
}
if
(
.
startsWith
(
MCP_TOOL_PREFIX
)
)
{
return
'mcp'
;
}
return
'custom-tool'
;
}
/**
* Localized display name for the SDK's built-in tools (S4). Falls back
* to the raw tool name so unknown tools still render something
* sensible. For `mcp__server__tool` the prefix is stripped to surface
* the server/tool pair.
*/
export
function
getClaudeToolDisplayName
(
:
string
)
:
string
{
const
=
getServerToolDisplay
(
,
undefined
)
?.
;
if
(
!==
undefined
)
{
return
;
}
switch
(
)
{
case
'Bash'
:
return
localize
(
'claude.tool.bash'
,
"Run shell command"
)
;
case
'BashOutput'
:
return
localize
(
'claude.tool.bashOutput'
,
"Read shell output"
)
;
case
'KillBash'
:
return
localize
(
'claude.tool.killBash'
,
"Kill shell command"
)
;
case
'Read'
:
return
localize
(
'claude.tool.read'
,
"Read file"
)
;
case
'Glob'
:
return
localize
(
'claude.tool.glob'
,
"Find files"
)
;
case
'Grep'
:
return
localize
(
'claude.tool.grep'
,
"Search files"
)
;
case
'LS'
:
return
localize
(
'claude.tool.ls'
,
"List directory"
)
;
case
'NotebookRead'
:
return
localize
(
'claude.tool.notebookRead'
,
"Read notebook"
)
;
case
'Write'
:
return
localize
(
'claude.tool.write'
,
"Write file"
)
;
case
'Edit'
:
return
localize
(
'claude.tool.edit'
,
"Edit file"
)
;
case
'MultiEdit'
:
return
localize
(
'claude.tool.multiEdit'
,
"Edit file"
)
;
case
'NotebookEdit'
:
return
localize
(
'claude.tool.notebookEdit'
,
"Edit notebook"
)
;
case
'TodoWrite'
:
return
localize
(
'claude.tool.todoWrite'
,
"Update todo list"
)
;
case
'WebFetch'
:
return
localize
(
'claude.tool.webFetch'
,
"Fetch URL"
)
;
case
'Task'
:
case
'Agent'
:
return
localize
(
'claude.tool.task'
,
"Run subagent task"
)
;
case
'ExitPlanMode'
:
return
localize
(
'claude.tool.exitPlanMode'
,
"Ready to code?"
)
;
case
'AskUserQuestion'
:
return
localize
(
'claude.tool.askUserQuestion'
,
"Ask user a question"
)
;
case
'Skill'
:
return
localize
(
'claude.tool.skill'
,
"Run skill"
)
;
case
'TaskCreate'
:
return
localize
(
'claude.tool.taskCreate'
,
"Create task"
)
;
case
'TaskUpdate'
:
return
localize
(
'claude.tool.taskUpdate'
,
"Update task"
)
;
case
'TaskList'
:
return
localize
(
'claude.tool.taskList'
,
"List tasks"
)
;
case
'TaskGet'
:
return
localize
(
'claude.tool.taskGet'
,
"Read task"
)
;
}
if
(
.
startsWith
(
MCP_TOOL_PREFIX
)
)
{
return
localize
(
'claude.tool.mcp'
,
"Run MCP tool {0}"
,
.
slice
(
MCP_TOOL_PREFIX
.
)
)
;
}
return
;
}
/**
* Read the `pathField` named on the tool's row from `input`. Returns
* `undefined` for tools without a path field, for missing fields, or
* for wrong-typed fields (defensive against malformed SDK input).
*
* Used both for `pending_confirmation.permissionPath` (S4) and Phase 8
* file-edit tracking — callers that only care about edits gate with
* {@link isClaudeFileEditTool} first.
*/
export
function
getClaudeToolPath
(
:
string
,
:
unknown
)
:
string
|
undefined
{
const
=
TOOL_ROWS
[
]
;
if
(
!
?.
||
typeof
!==
'object'
||
===
null
)
{
return
undefined
;
}
const
=
(
as
<
string
,
unknown
>
)
[
.
]
;
return
typeof
===
'string'
?
:
undefined
;
}
/**
* Phase 8 — true for tools that produce on-disk file edits tracked by
* `FileEditTracker`. Excludes `TodoWrite` (in-memory) and `Bash` (edits
* not surfaced as canonical SDK `tool_use` blocks the host can pair
* with `tool_result`).
*/
export
function
isClaudeFileEditTool
(
:
string
)
:
boolean
{
return
TOOL_ROWS
[
]
?.
===
true
;
}
/**
* Phase 7 S3.5. Tools whose `canUseTool` invocation is satisfied by a
* host-driven round-trip rather than the SDK's auto-approval:
* - `AskUserQuestion` — carousel (S3.5a).
* - `ExitPlanMode` — `pending_confirmation` with custom Approve/Deny
* labels and the plan body as `invocationMessage` (S3.5b).
*
* Membership only signals that the SDK does not auto-approve under any
* `permissionMode`, ensuring the call always reaches the host.
* `_handleCanUseTool` dispatches via `INTERACTIVE_CLAUDE_TOOLS.has(toolName)`.
*
* Derived from the `interactive: true` rows above so the table stays
* the single source of truth.
*/
export
const
INTERACTIVE_CLAUDE_TOOLS
:
<
string
>
=
new
Set
(
.
entries
(
TOOL_ROWS
)
.
filter
(
(
[
,
]
)
=>
.
)
.
map
(
(
[
]
)
=>
)
,
)
;
/**
* Confirmation-card title shown when a tool needs explicit user
* approval (S3.4 `pending_confirmation` flow). Mirrors the per-kind
* titles in {@link getPermissionDisplay} for CopilotAgent so both
* agents render identical wording. The workbench keys off
* `confirmationTitle` to render the Approve/Deny buttons — when it
* is absent, the tool card silently flips to "auto-approved" state
* even though the agent is parked. See `sessionPermissions.ts`'s
* `createToolReadyAction`.
*/
/**
* Phase 8.5 — workbench rendering hint. One-liner over `TOOL_ROWS`.
* Returns `'terminal'` for shell tools (drives the terminal renderer),
* `'search'` for `Grep` / `Glob` (drives the search renderer),
* `'subagent'` for `Task` / `Agent` (drives the subagent renderer), and
* `'read'` for file reads (defers incomplete resource arguments).
*/
export
function
getClaudeToolKind
(
:
string
)
:
|
undefined
{
return
TOOL_ROWS
[
]
?.
;
}
/**
* Phase 8.5 — build the `_meta` bag stamped at the tool-open seam.
* Returns `undefined` for tools that have no `toolKind` hint so the
* resulting envelope stays minimal. Mirrors Copilot's
* [`mapSessionEvents.ts:197`](../copilot/mapSessionEvents.ts#L197)
* single-write pattern.
*/
export
function
buildClaudeToolMeta
(
:
string
)
:
<
string
,
unknown
>
|
undefined
{
const
=
buildClaudeToolCallMeta
(
)
;
return
?
toToolCallMeta
(
)
:
undefined
;
}
/**
* Typed variant of {@link buildClaudeToolMeta} that returns the
* {@link IToolCallMeta} directly, for callers that consume the typed view
* rather than the serialized `_meta` bag. Returns `undefined` for tools that
* have no `toolKind` hint.
*/
/**
* Narrows a `TaskUpdate` call's `status` to the values that change the rendered
* verb; any other or absent value yields `undefined` (generic "Updating" verb).
*/
function
readTaskUpdateStatus
(
:
unknown
)
:
'in_progress'
|
'completed'
|
'deleted'
|
undefined
{
const
=
readStringField
(
,
'status'
)
;
return
===
'in_progress'
||
===
'completed'
||
===
'deleted'
?
:
undefined
;
}
/**
* Phase 8.5 — rich invocation message for a `pending_confirmation`
* card or a streaming `ChatToolCallStart` action. Reads the
* SDK's `tool_use.input` defensively and falls back to the static
* `displayName` on any shape mismatch. Mirror of
* [`copilotToolDisplay.getInvocationMessage`](../copilot/copilotToolDisplay.ts#L473).
*/
/**
* Phase 8.5 — canonical "input as code" string rendered under the
* tool-call row. Shell tools surface the raw `command`; search tools
* surface the `pattern`; everything else falls back to pretty-printed
* JSON. Returns `undefined` only when the input is itself absent.
*/