TRILHA 2

🔧 Tool System

Domine a interface Tool, o pipeline de execucao, o Bash Tool com seus 23 validators, as File Tools (Read/Write/Edit) e as Search Tools (Glob & Grep) ate a integracao MCP.

5
Modulos
~30
Topicos
~4h
Duracao
Avancado
Nivel

Navegacao Rapida

2.1 ~50 min

The Tool System

A interface Tool, o pipeline de registro e filtragem, orquestracao de concorrencia, permissoes e o fluxo completo de execucao.

1
🔧 The Tool Interface (Tool.ts)
Protocol contract, inputSchema, call, permissions
2
🏭 buildTool() Factory & Fail-Closed Defaults
Defaults conservadores, BuiltTool type magic
3
📦 Three-Tier Registration Pipeline
getAllBaseTools, getTools, assembleToolPool
4
🔄 Orchestration & Concurrency
partitionToolCalls, concurrent vs serial batches
5
⚡ StreamingToolExecutor
Real-time execution, sibling abort, in-order emission
6
🛡️ Permission Context & Execution Pipeline
checkPermissionsAndCallTool, DeepImmutable, Zod validation
Ver Completo
2.2 ~60 min

The Bash Tool

O gateway do sistema operacional: 7 camadas de processamento, 23 security validators, shell snapshot, sandboxing e output handling.

1
💻 Architecture & Command Pipeline
7 layers antes do spawn, buildExecCommand()
2
🛡️ The 23 Security Validators
bashCommandIsSafe(), allow/passthrough/ask chain
3
📸 Shell Snapshot System
Aliases, functions, PATH capturados uma vez por sessao
4
🔒 Permission Plumbing & Sandboxing
bashToolHasPermission(), SandboxManager, rule matching
5
⏳ Background Execution & Output Handling
3 paths de background, size limits, image detection
6
🎯 UI Classification & Sed Special Case
Collapse behavior, pipeline classification, sed-as-edit
Ver Completo
2.3 ~50 min

File Tools (Read, Write, Edit)

Tres ferramentas de manipulacao de arquivo com um invariante compartilhado: toda escrita requer leitura previa. Dedup, quote normalization e staleness checks.

1
📖 Read Tool Deep-Dive
Pagination, token limits, image/PDF/notebook support
2
✏️ Write Tool Deep-Dive
Read-before-write gate, atomic write, LF policy
3
✂️ Edit Tool & Quote Normalization
Exact string replacement, curly quotes, desanitization
4
🔄 The Read-Before-Write Contract
4 fases, double staleness check, race window
5
📊 Write vs Edit: When to Use Each
Token cost comparison, use cases
6
🔏 Limits Precedence & Dedup System
Env var > GrowthBook > default, mtime-based dedup
Ver Completo
2.4 ~45 min

Search Tools (Glob & Grep)

Ambas delegam para ripgrep: Glob busca nomes de arquivo, Grep busca conteudo. Tres output modes, pagination, e resolucao de binario em tres camadas.

1
🔍 Glob Delegates to ripgrep
--files --glob, absolute path decomposition
2
📋 Grep's Three Output Modes
files_with_matches, content, count
3
📄 Pagination: head_limit & offset
Default 250, unlimited escape hatch, 20KB persist threshold
4
⚙️ ripgrep Binary Resolution
system -> embedded -> builtin, memoized, security
5
⚡ Performance Architecture
Timeouts, EAGAIN retry, buffer cap, path relativization
6
🛡️ Pattern Safety & UNC Path Security
Leading-dash problem, NTLM leak prevention, glob parsing
Ver Completo
2.5 ~55 min

MCP Integration

Model Context Protocol: 8 transports, 7-layer config cascade, OAuth com PKCE, tool proxying, elicitation e deduplication baseada em conteudo.

1
🔌 Transport Types & Architecture
8 transports: stdio, sse, http, ws, ide, sdk, in-process
2
📋 7-Layer Config Scope Cascade
enterprise > dynamic > claudeai > project > local > user > managed
3
🔗 Connection Lifecycle & State Machine
Batched connection, timeout race, capability negotiation
4
🎭 Tool Proxying & MCPTool
Name normalization, description cap, result handling
5
🔐 OAuth Authentication & McpAuthTool
PKCE flow, model-triggered auth, Slack quirk, XAA
6
📡 Elicitation & Deduplication
Form/URL modes, content-based dedup, CCR proxy unwrapping
Ver Completo