# Packages

> How SDK packages fit together, what each package exports, and where boundaries are enforced.

- 网址：https://funcoding.ai/agents/cline/sdk/architecture/overview/
- 来源：Cline 官方文档原文（英文），Apache-2.0 许可，同步于 2026-10-11
- 官方原文：https://docs.cline.bot/sdk/architecture/overview

---
The SDK is split into layered packages. Dependencies flow downward: `core` depends on `agents`, `llms`, and `shared`; `agents` depends on `llms` and `shared`; `llms` depends on `shared`.

## Package Stack

```txt
Your application / CLI / VS Code / JetBrains
          │
          ▼
@cline/core
Sessions, storage, built-in tools, hub, automation, telemetry
          │
          ├── @cline/agents
          │   Browser-compatible AgentRuntime / Agent loop
          │
          ├── @cline/llms
          │   Provider handlers, gateway, model catalogs
          │
          └── @cline/shared
              Types, schemas, tools, hooks, extension contracts
```

## Packages

### @cline/core

Node runtime/orchestration layer.

Key exports include:

| Export | Description |
|--------|-------------|
| `ClineCore` | Main runtime entry point |
| `ClineCoreOptions` | Constructor options |
| `ClineCoreStartInput` | Session start input |
| `CoreSessionConfig` | Session configuration |
| `SessionRecord` | Persisted session metadata |
| `AgentPlugin` | Public plugin type |
| `createTool` | Re-export from shared |

Capabilities include:

- local/hub/remote runtime backends
- session manifests and message artifacts
- built-in tools
- tool approvals
- automation/scheduling services
- telemetry hooks
- plugin/extension loading
- team/sub-agent tools

Depends on: `@cline/shared`, `@cline/llms`, `@cline/agents`.

### @cline/agents

Browser-compatible agent execution loop.

Key exports include:

| Export | Description |
|--------|-------------|
| `AgentRuntime` | Core runtime class |
| `Agent` | Alias for `AgentRuntime` |
| `createAgentRuntime`, `createAgent` | Factory functions |
| `AgentRuntimeConfig` | Constructor config union |
| `AgentRunInput`, `AgentEventListener` | Runtime helper types |
| `createTool` | Re-export from `@cline/shared` |

Methods on `AgentRuntime` include `run`, `continue`, `abort`, `subscribe`, `restore`, and `snapshot`.

Depends on: `@cline/shared`, `@cline/llms`.

### @cline/llms

Provider and model layer.

Key exports include:

| Export | Description |
|--------|-------------|
| `DefaultGateway`, `createGateway` | Gateway for creating provider-backed agent models |
| `createHandler`, `createHandlerAsync` | Provider handler factories |
| `getAllProviders`, `getProviderIds`, `getModelsForProvider` | Catalog helpers |
| `registerProvider`, `registerModel` | Runtime registry extension |
| `ModelInfo`, `ProviderInfo` | Provider/model metadata |

Depends on: `@cline/shared`.

### @cline/shared

Foundation package for shared contracts and utilities.

Key exports include:

| Export | Description |
|--------|-------------|
| `createTool` | Helper for creating typed tools |
| `AgentTool`, `AgentToolContext`, `ToolPolicy` | Tool interfaces |
| `AgentEvent`, `AgentResult`, `AgentConfig` | Host-facing agent types |
| `AgentRuntimeEvent`, `AgentRunResult` | Runtime-facing agent types |
| `HookEngine`, `HookStage`, `HookPolicies` | Hook contracts and engine |
| `ContributionRegistry`, `AgentExtensionApi` | Extension registration contracts |
| `ModelInfo`, `Message`, `ContentBlock` | Model/message types |
| `BasicLogger`, `noopBasicLogger` | Logging contracts |

No higher-layer dependencies.

## Install

```bash
npm install @cline/sdk
```

`@cline/sdk` re-exports everything from `@cline/core`. Install `@cline/agents` or `@cline/llms` directly only if you need lower-level control.

## Design Principles

### Strict dependency direction

Dependencies flow downward only. Lower layers stay embeddable without pulling in the full runtime.

### Browser-compatible agent loop

`@cline/agents` exposes a browser-compatible runtime. It does not own session storage, built-in file/shell tools, hub transports, or Node-specific orchestration.

### Core as orchestration layer

`@cline/core` owns Node runtime integration: session persistence, built-in tools, automation, hub/remote transports, telemetry, and extension loading.
