Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.cline.bot/llms.txt

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

The SDK has two main runtime entry points:
  • ClineCore from @cline/core: Node runtime with sessions, persistence, built-in tools, approvals, automation, and hub support.
  • Agent / AgentRuntime from @cline/agents: browser-compatible, stateless, in-process execution. You provide tools, persistence, and lifecycle management.
Agent is an alias for AgentRuntime. Use Agent when constructing from provider/model IDs. Use AgentRuntime when supplying a pre-built AgentModel.

Which Runtime to Use

NeedUse
Browser-compatible or lightweight in-process agentAgent / AgentRuntime
Custom tools onlyAgent / AgentRuntime
Manual control over persistenceAgent / AgentRuntime
Built-in tools for files, shell, search, web fetchClineCore
Session persistenceClineCore
Hub/remote runtimeClineCore
Scheduling or event automationClineCore
Multi-agent teamsClineCore

Agent / AgentRuntime

Agent runs the core loop:
run() or continue()
  -> model request
  -> tool calls, if any
  -> tool results
  -> repeat until complete
import { Agent } from "@cline/sdk"

const agent = new Agent({
  providerId: "anthropic",
  modelId: "claude-sonnet-4-6",
  apiKey: process.env.ANTHROPIC_API_KEY,
  systemPrompt: "You are a helpful coding assistant.",
  tools: [myTool],
})

agent.subscribe((event) => {
  if (event.type === "assistant-text-delta") {
    process.stdout.write(event.text ?? "")
  }
})

const result = await agent.run("Review this diff")
console.log(result.outputText)

Methods

MethodPurpose
run(input)Start a run with user input
continue(input?)Continue with optional new input
abort(reason?)Abort the active run
subscribe(listener)Listen to AgentRuntimeEvent events
restore(messages)Replace conversation history
snapshot()Read runtime state
See Agent reference for exact signatures.

Multi-Turn Conversations

AgentRuntime keeps message state internally. Use continue() after the first run:
await agent.run("What does this project do?")
await agent.continue("Now identify risky files")
If you persist messages externally, restore them with restore(messages) before continuing.

ClineCore

ClineCore wraps runtime execution with application features:
  • session manifests and message artifacts
  • built-in tools
  • tool approval callbacks
  • local, hub, and remote backends
  • automation/scheduling APIs
  • optional plugin paths and extensions
import { ClineCore } from "@cline/sdk"

const cline = await ClineCore.create({
  clientName: "my-app",
  backendMode: "auto",
})

const session = await cline.start({
  prompt: "Set up GitHub Actions for this repo",
  config: {
    providerId: "anthropic",
    modelId: "claude-sonnet-4-6",
    apiKey: process.env.ANTHROPIC_API_KEY,
    systemPrompt: "You are a helpful coding assistant.",
    cwd: "/path/to/project",
    workspaceRoot: "/path/to/project",
    enableTools: true,
    enableSpawnAgent: false,
    enableAgentTeams: false,
  },
})

console.log(session.sessionId)
console.log(session.result?.finishReason)

Methods

MethodPurpose
ClineCore.create(options)Create the runtime
start(input)Start a session
send({ sessionId, prompt })Send a follow-up message
subscribe(listener, options?)Listen to session events
list(limit?, options?)List sessions with history metadata
get(sessionId)Read session metadata
readMessages(sessionId)Read session messages
getAccumulatedUsage(sessionId)Read session token/cost totals
abort(sessionId, reason?)Abort current work
stop(sessionId)Stop a session
delete(sessionId)Delete a session
dispose(reason?)Clean up runtime resources
See ClineCore reference for exact signatures.

Backend Modes

ModeBehavior
autoPrefer a compatible local hub, otherwise use local execution
hubRequire a compatible WebSocket hub
remoteConnect to a configured remote hub
localAlways use local in-process execution and local storage
For process topology, see Hub & Spoke.

Session Artifacts

ClineCore stores session manifests and messages as files. A session result includes:
FieldMeaning
sessionIdSession identifier
manifestParsed session manifest
manifestPathPath to the session manifest JSON
messagesPathPath to persisted message JSON
resultFinal AgentResult, when available

Tool Approval

Use tool policies for simple cases:
await cline.start({
  prompt: "Audit this repo",
  config: {
    providerId: "anthropic",
    modelId: "claude-sonnet-4-6",
    apiKey: process.env.ANTHROPIC_API_KEY,
    systemPrompt: "You are a helpful coding assistant.",
    cwd: process.cwd(),
    workspaceRoot: process.cwd(),
    enableTools: true,
    enableSpawnAgent: false,
    enableAgentTeams: false,
  },
  toolPolicies: {
    read_files: { autoApprove: true },
    search_codebase: { autoApprove: true },
    run_commands: { autoApprove: false },
    editor: { autoApprove: false },
  },
})
Use requestToolApproval when your application needs to decide dynamically:
const cline = await ClineCore.create({
  clientName: "my-app",
  capabilities: {
    requestToolApproval: async (request) => {
      return { approved: request.toolName !== "run_commands" }
    },
  },
})
For tool behavior and policies, see Tools.