import type { AgentTool } from "@kenkaiiii/gg-agent"; import type { Provider, ThinkingLevel } from "@kenkaiiii/gg-ai"; import type { ContextLimits } from "../core/context-limits.js"; import { SubAgentManager, type SubAgentSnapshot } from "../core/subagent-manager.js"; import { ProcessManager } from "../core/process-manager.js"; import { LspManager } from "../core/lsp/manager.js"; import { type GenerateImageAuth } from "./generate-image.js"; import { type ToolOperations } from "./operations.js"; import type { WriteGuardSettings } from "../core/workspace-guard.js"; import type { GetNetworkPolicy } from "../core/network-guard.js"; import type { SandboxPolicy } from "../core/sandbox.js"; import type { AgentDefinition } from "../core/agents.js"; import type { Skill } from "../core/skills.js"; import type { AgentNotificationQueue } from "../core/agent-notifications.js"; export { BUILTIN_TOOL_NAMES } from "./prompt-hints.js"; export interface CreateToolsOptions { agents?: AgentDefinition[]; skills?: Skill[]; /** Byte budgets for skill catalog / MCP descriptions in tool schemas. */ contextLimits?: ContextLimits; provider?: Provider; model?: string; /** Custom I/O operations for remote execution (SSH, Docker, etc.). Defaults to local filesystem. */ operations?: ToolOperations; /** Ref for checking plan mode inside tool execute functions. */ planModeRef?: { current: boolean; }; /** Callback when the LLM enters plan mode. */ onEnterPlan?: (reason?: string) => void | Promise; /** Callback when the LLM submits a plan for review. */ onExitPlan?: (planPath: string) => Promise; /** Callback after read tool successfully reads a text file. */ onFileRead?: (filePath: string) => void | Promise; /** Callback after write/edit tools successfully mutate a file. */ onFileMutated?: (filePath: string) => void | Promise; /** * Callback fired by write/edit BEFORE the on-disk write, so a checkpoint store * can snapshot the file's prior content for /rewind. Receives the resolved * absolute path. */ onPreFileMutation?: (filePath: string) => void | Promise; /** * Getter for parent's prompt-cache routing key, evaluated lazily at * sub-agent spawn time. Returning a stable key from this getter lets every * sub-agent spawned by one parent share the same prompt_cache_key prefix — * without it, each child generates a fresh sessionId-derived key and pays a * cold-cache cost on every turn. Lazy because the parent's sessionId is * only assigned after `createTools()` runs during session init. */ getCacheKey?: () => string | undefined; /** Current parent provider/model, evaluated lazily when spawning a sub-agent. */ getProvider?: () => Provider; getModel?: () => string; getThinkingLevel?: () => ThinkingLevel | undefined; getBaseUrl?: () => string | undefined; /** Optional per-model subagent concurrency cap (subagentMaxPerModel). */ getMaxPerModel?: () => number | undefined; onSubAgentState?: (snapshot: SubAgentSnapshot) => void; /** Persistent child workers omit every subagent tool to enforce one-level fan-out. */ disableSubagents?: boolean; /** * Append LSP diagnostics to edit/write results (default true). Servers are * resolved from the project/PATH only and spawn lazily on the first edit of * a matching file — disabling this is a pure opt-out, not a capability loss. */ lspDiagnostics?: boolean; /** * Auth storage for conditional tool registration. When provided AND the user * has OpenAI connected, the `generate_image` tool is registered — letting the * agent generate/edit images via OpenAI's Image API regardless of the active * chat provider. Omitted by callers that don't want image generation. */ authStorage?: GenerateImageAuth & { hasProviderAuth(provider: string): Promise; }; /** * Lazily read the workspace write-guard settings (allowOutsideWorkspaceWrites). * When omitted, writes are allowed under cwd, the OS tmpdir, and ~/.gg only. */ getWriteGuardSettings?: () => WriteGuardSettings | undefined; /** * Lazily read the network egress policy (networkMode / networkAllow). * When omitted, no network restriction is applied. */ getNetworkPolicy?: GetNetworkPolicy; /** Lazily read the OS command-sandbox mode and allowed network domains. */ getSandboxPolicy?: () => SandboxPolicy; /** * Lazily read whether `grep` may use the external `rg` scanner when present * (grepUseRipgrep). Defaults to enabled when omitted. */ getUseExternalGrep?: () => boolean; /** * Push queue for out-of-band notifications (child completions, background * process progress). When provided, producers enqueue here and the session * drains it into steering, so the agent learns about them without spending a * turn polling. */ notifications?: AgentNotificationQueue; } export interface CreateToolsResult { tools: AgentTool[]; processManager: ProcessManager; /** * Rebuild the `read` tool for a different model, reusing the SAME read * tracker so read-before-edit history survives. The read tool's video * capability (description + native-video execute path) is baked in at * creation from the model's `maxVideoBytes`, so switching to/from a * video-capable model mid-session requires a fresh tool object. Returns the * new tool; the caller swaps it into the live tool set and rebuilds the * system prompt. */ rebuildReadTool: (model: string) => AgentTool; /** * Language-server pool backing edit/write diagnostics. Present only when * enabled and running against the local filesystem; callers wire * `shutdownAll()` into their exit/cleanup paths alongside processManager. */ lspManager?: LspManager; subAgentManager?: SubAgentManager; } export declare function createTools(cwd: string, opts?: CreateToolsOptions): Promise; export { createReadTool } from "./read.js"; export { createWriteTool } from "./write.js"; export { createEditTool } from "./edit.js"; export { createBashTool } from "./bash.js"; export { createFindTool } from "./find.js"; export { createGrepTool } from "./grep.js"; export { createSearchCodeTool } from "./search-code.js"; export { createCodeNavTool } from "./code-nav.js"; export { createLsTool } from "./ls.js"; export { createWebFetchTool } from "./web-fetch.js"; export { createWebSearchTool } from "./web-search.js"; export { createSourcePathTool } from "./source-path.js"; export { createTaskOutputTool } from "./task-output.js"; export { createTaskSendTool } from "./task-send.js"; export { createTaskStopTool } from "./task-stop.js"; export { createTasksTool } from "./tasks.js"; export { createSkillTool } from "./skill.js"; export { createScreenshotTool } from "./screenshot.js"; export { createGenerateImageTool, type GenerateImageAuth } from "./generate-image.js"; export { createEnterPlanTool } from "./enter-plan.js"; export { createExitPlanTool } from "./exit-plan.js"; export { ProcessManager } from "../core/process-manager.js"; export { LspManager } from "../core/lsp/manager.js"; export { localOperations, type ToolOperations } from "./operations.js"; //# sourceMappingURL=index.d.ts.map