mirror of
https://github.com/cline/cline.git
synced 2026-09-21 05:10:09 +08:00
* Improve OpenRouter sticky session routing OpenRouter prompt caching was getting weaker cache hit rates because requests did not include a stable session_id. Without that identifier, OpenRouter can route consecutive turns away from the same upstream cache context even when cache_control is present, causing more fresh input billing. Propagate explicit runtime sessionId metadata from agents into model requests without synthesizing fallback session or conversation ids. Add provider metadata for sticky sessions so OpenRouter maps metadata.sessionId to the JSON body session_id field, while keeping the mechanism extensible for header-based providers. Apply sticky-session metadata in the AI SDK provider fetch wrapper, preserving explicit wire values when callers already set them. Move trimNonEmpty and omitUndefinedValues into @cline/shared for reuse, and cover the JSON-body, header, and no-fallback paths with tests. * Tighten sticky session fetch body handling Treat init.body null as an explicit no-body override so the sticky-session wrapper does not inspect or parse a Request body that the caller has intentionally overridden. Model fetch body text by source, which removes the unreachable JSON-body injection branch and makes the Request rewrite path explicit. Also type the provider fetch mocks so sticky-session assertions compile cleanly in editors. * merges model-handle default metadata with per-request metadata
Packages Overview
This directory is the single documentation source for package-level responsibilities.
- High-level package roles: this file (
packages/README.md) - Package interaction and runtime flows:
ARCHITECTURE.md
Package Responsibilities
| Package | Primary responsibility | Typical consumers | Internal deps |
|---|---|---|---|
@cline/shared |
Cross-package shared primitives (path resolution, session common types, indexing helpers) | @cline/agents, @cline/core, apps |
None |
@cline/llms |
Model catalog + provider settings schema + handler creation SDK | @cline/agents, @cline/core, apps |
None |
@cline/agents |
Stateless agent runtime loop (tools, hooks, extensions, teams, streaming) | @cline/core, apps |
@cline/llms, @cline/shared |
@cline/core |
Stateful runtime orchestration (runtime composition, session lifecycle/storage, local and hub runtime services, hub discovery and client helpers) | CLI/Desktop apps | @cline/agents, @cline/llms, @cline/shared |
How Packages Work Together
@cline/llmsdefines model/provider capabilities and builds concrete handlers.@cline/agentsruns the agent loop on top of those handlers and tool execution primitives.@cline/corecomposes runtime behavior with persistent sessions/storage and local or hub-backed runtime services.@cline/corehub services orchestrate scheduled runtime execution, execution history, and schedule command handling.@cline/core/hubexposes discovery, the detached hub daemon, and session-oriented client APIs (HubSessionClient,HubUIClient) when hosts need a shared daemon.@cline/sharedprovides the shared contracts and path/session primitives used across the stack.
Practical Boundary Rules
- Put provider/model schema, cataloging, and handler wiring in
@cline/llms. - Put loop/tool/hook/team execution behavior in
@cline/agents. - Put persistence, session lifecycle, and runtime assembly in
@cline/core. - Put scheduled execution and schedule persistence in
@cline/corehub services. - Put hub discovery, attach flows, and session-oriented client adapters in
@cline/core/hub. - Put cross-package utility types and path/session constants in
@cline/shared. - Put remote-config schemas, materialization, telemetry normalization, and blob upload primitives in
@cline/shared/remote-config.
Runtime Entry Points
- Node-oriented imports exist where packages expose a distinct Node alias.
@cline/coreitself is now the Node/runtime-oriented entry point for host/session services.- Browser entry points still exist in packages that intentionally publish a browser surface, but
@cline/coreno longer does.
Notes for Doc Consolidation
Nested package README.md and ARCHITECTURE.md files can be reduced or removed after references are updated to point here.