Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Effectful-Tech/clanka/llms.txt

Use this file to discover all available pages before exploring further.

When the language model wants to take an action it writes JavaScript and submits it to AgentExecutor. Inside that sandbox every tool is available as a plain async function — no imports needed. The declarations below are derived directly from AgentTools.ts and are injected into the model’s system prompt so the model knows the exact signatures.
All tool functions are globals in the sandbox. The model calls them with await because they are async. Variables and state are not shared between separate script executions.

File system tools

readFile

Read a file and return its content as a string, or null if the file does not exist. Optionally slice by line range.
declare function readFile(options: {
  path: string
  startLine?: number
  endLine?: number
}): Promise<string | null>

writeFile

Write content to a file. Parent directories are created automatically. Prefer applyPatch when updating existing files to avoid accidental overwrites.
declare function writeFile(options: {
  path: string
  content: string
}): Promise<void>

removeFile

Delete a file from disk.
declare function removeFile(path: string): Promise<void>

renameFile

Move or rename a file. Parent directories are created if they do not exist.
declare function renameFile(options: {
  from: string
  to: string
}): Promise<void>

ls

List the entries in a directory.
declare function ls(directory: string): Promise<string[]>

glob

Return all file paths matching a glob pattern, relative to the working directory.
declare function glob(pattern: string): Promise<string[]>

applyPatch

Apply a git/unified diff patch that can add, update, move, or delete multiple files in a single call. Returns a summary of the files changed.
declare function applyPatch(patch: string): Promise<string>
This is the most efficient way to make multi-file edits. The model produces a diff and the executor applies it atomically.

Search tools

rg

Run ripgrep against the working directory. Returns matching lines (up to maxLines, default 500).
declare function rg(options: {
  pattern: string
  glob?: string          // --glob filter
  filesOnly?: boolean    // --files-with-matches
  maxLines?: number      // cap total lines returned
}): Promise<string>
Semantic code search powered by embeddings. Describe what you are looking for in natural language and receive the most relevant code chunks.
declare function search(query: string): Promise<string>
search is only available when a SemanticSearch layer is provided to the executor. See Semantic search for setup instructions.

Shell and CLI tools

bash

Run a shell command and return combined stdout/stderr. The default timeout is 120 000 ms; the maximum is 240 000 ms.
declare function bash(options: {
  command: string
  timeoutMs?: number
}): Promise<string>

gh

Run the GitHub CLI (gh) with the provided arguments. The working directory is set to the agent’s configured directory. Use this instead of bash("gh …").
declare function gh(args: string[]): Promise<string>

Web tools

webSearch

Search the web using the configured Exa search integration. Returns a formatted string of results.
declare function webSearch(options: ExaSearchOptions): Promise<string>

fetchMarkdown

Fetch a URL and return its content converted to Markdown.
declare function fetchMarkdown(url: string): Promise<string>

Sub-agent tools

delegate

Spawn a sub-agent to complete a task. The parent agent waits for the sub-agent to call taskComplete and then receives the summary. Sub-agents share the same tool set but run with a fresh conversation history.
declare function delegate(task: string): Promise<string>

Task management tools

The agent maintains an in-memory todo list scoped to the current executor instance. These tools let the model track its own progress across multiple tool calls.

listTodos

declare function listTodos(): Promise<Array<{ id: number; text: string; completed: boolean }>>

addTodo

declare function addTodo(text: string): Promise<void>

updateTodo

declare function updateTodo(options: {
  id: number
  text?: string
  completed?: boolean
}): Promise<void>

clearTodos

declare function clearTodos(): Promise<void>

Control tools

taskComplete

Signal that the task is fully done and provide the final output message. Calling this causes the output stream to end with AgentFinished.
declare function taskComplete(output: string): Promise<void>
taskComplete should only be called once, and only when every step of the task is finished. The agent prompt instructs the model to make sure all work is done before calling it.

sleep

Pause execution for a given number of milliseconds.
declare function sleep(ms: number): Promise<void>

Example: multi-step file operation

The following is representative of how the model would use several tools together in a single script:
// Read a file, make changes, and write back using applyPatch
const content = await readFile({ path: "src/index.ts" })
console.log("Current content:", content?.slice(0, 200))

const files = await glob("src/**/*.ts")
console.log("TypeScript files:", files)

const searchResults = await rg({
  pattern: "TODO",
  glob: "src/**/*.ts",
  filesOnly: true,
})
console.log("Files with TODOs:", searchResults)

await addTodo("Fix all TODO comments in src/")

await applyPatch(`
*** /dev/null
--- src/utils.ts
@@ -0,0 +1,3 @@
+// Utilities
+export const noop = () => {}
`)

await taskComplete("Created src/utils.ts with a noop utility.")

Globals also available

In addition to tool functions, the sandbox exposes:
  • console — standard console.log, console.error, etc. All output is captured and sent back to the model.
  • fetch — the global fetch API for making HTTP requests.
  • process — explicitly set to undefined; Node.js APIs are not available.

Build docs developers (and LLMs) love