@cline/core 0.0.38-nightly.1778113663
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -0
- package/dist/ClineCore.d.ts +282 -0
- package/dist/account/cline-account-service.d.ts +37 -0
- package/dist/account/index.d.ts +3 -0
- package/dist/account/rpc.d.ts +40 -0
- package/dist/account/types.d.ts +98 -0
- package/dist/auth/bounded-ttl-cache.d.ts +13 -0
- package/dist/auth/client.d.ts +30 -0
- package/dist/auth/cline.d.ts +64 -0
- package/dist/auth/codex.d.ts +43 -0
- package/dist/auth/oca.d.ts +28 -0
- package/dist/auth/server.d.ts +54 -0
- package/dist/auth/types.d.ts +103 -0
- package/dist/auth/utils.d.ts +32 -0
- package/dist/cline-core/automation.d.ts +34 -0
- package/dist/cline-core/runtime-services.d.ts +5 -0
- package/dist/cline-core/start-input.d.ts +10 -0
- package/dist/cline-core/telemetry.d.ts +10 -0
- package/dist/cline-core/types.d.ts +221 -0
- package/dist/cron/events/cron-event-ingress.d.ts +37 -0
- package/dist/cron/reports/cron-report-writer.d.ts +40 -0
- package/dist/cron/runner/cron-materializer.d.ts +35 -0
- package/dist/cron/runner/cron-runner.d.ts +45 -0
- package/dist/cron/runner/resource-limiter.d.ts +8 -0
- package/dist/cron/schedule/scheduler.d.ts +12 -0
- package/dist/cron/service/cron-service.d.ts +56 -0
- package/dist/cron/service/schedule-command-service.d.ts +9 -0
- package/dist/cron/service/schedule-service.d.ts +98 -0
- package/dist/cron/specs/cron-reconciler.d.ts +61 -0
- package/dist/cron/specs/cron-spec-parser.d.ts +26 -0
- package/dist/cron/specs/cron-watcher.d.ts +22 -0
- package/dist/cron/store/cron-schema.d.ts +2 -0
- package/dist/cron/store/sqlite-cron-store.d.ts +240 -0
- package/dist/extensions/config/index.d.ts +7 -0
- package/dist/extensions/config/runtime-commands.d.ts +11 -0
- package/dist/extensions/config/skill-frontmatter-toggle.d.ts +11 -0
- package/dist/extensions/config/unified-config-file-watcher.d.ts +77 -0
- package/dist/extensions/config/user-instruction-config-loader.d.ts +64 -0
- package/dist/extensions/config/user-instruction-plugin.d.ts +25 -0
- package/dist/extensions/config/user-instruction-service.d.ts +23 -0
- package/dist/extensions/context/agentic-compaction.d.ts +12 -0
- package/dist/extensions/context/basic-compaction.d.ts +8 -0
- package/dist/extensions/context/compaction-shared.d.ts +60 -0
- package/dist/extensions/context/compaction.d.ts +24 -0
- package/dist/extensions/index.d.ts +5 -0
- package/dist/extensions/mcp/client.d.ts +2 -0
- package/dist/extensions/mcp/config-loader.d.ts +15 -0
- package/dist/extensions/mcp/index.d.ts +8 -0
- package/dist/extensions/mcp/manager.d.ts +23 -0
- package/dist/extensions/mcp/name-transform.d.ts +2 -0
- package/dist/extensions/mcp/policies.d.ts +14 -0
- package/dist/extensions/mcp/tools.d.ts +3 -0
- package/dist/extensions/mcp/types.d.ts +94 -0
- package/dist/extensions/plugin/plugin-config-loader.d.ts +40 -0
- package/dist/extensions/plugin/plugin-load-report.d.ts +18 -0
- package/dist/extensions/plugin/plugin-loader.d.ts +22 -0
- package/dist/extensions/plugin/plugin-module-import.d.ts +4 -0
- package/dist/extensions/plugin/plugin-sandbox.d.ts +36 -0
- package/dist/extensions/plugin/plugin-targeting.d.ts +6 -0
- package/dist/extensions/plugin-sandbox-bootstrap.js +1 -0
- package/dist/extensions/tools/constants.d.ts +24 -0
- package/dist/extensions/tools/definitions.d.ts +102 -0
- package/dist/extensions/tools/executors/apply-patch-parser.d.ts +68 -0
- package/dist/extensions/tools/executors/apply-patch.d.ts +28 -0
- package/dist/extensions/tools/executors/bash.d.ts +49 -0
- package/dist/extensions/tools/executors/editor.d.ts +31 -0
- package/dist/extensions/tools/executors/file-read.d.ts +40 -0
- package/dist/extensions/tools/executors/index.d.ts +50 -0
- package/dist/extensions/tools/executors/search.d.ts +50 -0
- package/dist/extensions/tools/executors/web-fetch.d.ts +58 -0
- package/dist/extensions/tools/helpers.d.ts +15 -0
- package/dist/extensions/tools/index.d.ts +59 -0
- package/dist/extensions/tools/model-tool-routing.d.ts +33 -0
- package/dist/extensions/tools/presets.d.ts +132 -0
- package/dist/extensions/tools/runtime.d.ts +24 -0
- package/dist/extensions/tools/schemas.d.ts +241 -0
- package/dist/extensions/tools/team/delegated-agent.d.ts +43 -0
- package/dist/extensions/tools/team/index.d.ts +2 -0
- package/dist/extensions/tools/team/multi-agent.d.ts +230 -0
- package/dist/extensions/tools/team/projections.d.ts +8 -0
- package/dist/extensions/tools/team/runtime.d.ts +4 -0
- package/dist/extensions/tools/team/spawn-agent-tool.d.ts +83 -0
- package/dist/extensions/tools/team/subagent-prompts.d.ts +3 -0
- package/dist/extensions/tools/team/team-tools.d.ts +35 -0
- package/dist/extensions/tools/types.d.ts +254 -0
- package/dist/hooks/checkpoint-hooks.d.ts +45 -0
- package/dist/hooks/hook-extension.d.ts +2 -0
- package/dist/hooks/hook-file-config.d.ts +24 -0
- package/dist/hooks/hook-file-hooks.d.ts +21 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/subprocess-runner.d.ts +21 -0
- package/dist/hooks/subprocess.d.ts +68 -0
- package/dist/hub/client/connect.d.ts +14 -0
- package/dist/hub/client/index.d.ts +88 -0
- package/dist/hub/client/session-client.d.ts +118 -0
- package/dist/hub/client/ui-client.d.ts +45 -0
- package/dist/hub/daemon/entry.d.ts +1 -0
- package/dist/hub/daemon/entry.js +720 -0
- package/dist/hub/daemon/index.d.ts +8 -0
- package/dist/hub/daemon/runtime-handlers.d.ts +12 -0
- package/dist/hub/daemon/start-shared-server.d.ts +18 -0
- package/dist/hub/discovery/defaults.d.ts +16 -0
- package/dist/hub/discovery/index.d.ts +30 -0
- package/dist/hub/discovery/workspace.d.ts +3 -0
- package/dist/hub/index.d.ts +32 -0
- package/dist/hub/index.js +717 -0
- package/dist/hub/runtime-host/hub-runtime-host.d.ts +73 -0
- package/dist/hub/runtime-host/remote-runtime-host.d.ts +9 -0
- package/dist/hub/server/browser-websocket.d.ts +17 -0
- package/dist/hub/server/command-transport.d.ts +7 -0
- package/dist/hub/server/handlers/approval-handlers.d.ts +17 -0
- package/dist/hub/server/handlers/capability-handlers.d.ts +12 -0
- package/dist/hub/server/handlers/client-handlers.d.ts +6 -0
- package/dist/hub/server/handlers/context.d.ts +56 -0
- package/dist/hub/server/handlers/run-handlers.d.ts +5 -0
- package/dist/hub/server/handlers/session-event-projector.d.ts +7 -0
- package/dist/hub/server/handlers/session-handlers.d.ts +20 -0
- package/dist/hub/server/hub-client-contributions.d.ts +19 -0
- package/dist/hub/server/hub-notifications.d.ts +7 -0
- package/dist/hub/server/hub-schedule-events.d.ts +2 -0
- package/dist/hub/server/hub-server-logging.d.ts +2 -0
- package/dist/hub/server/hub-server-options.d.ts +55 -0
- package/dist/hub/server/hub-server-transport.d.ts +34 -0
- package/dist/hub/server/hub-session-records.d.ts +8 -0
- package/dist/hub/server/hub-websocket-server.d.ts +6 -0
- package/dist/hub/server/index.d.ts +4 -0
- package/dist/hub/server/native-transport.d.ts +16 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +715 -0
- package/dist/runtime/capabilities/index.d.ts +2 -0
- package/dist/runtime/capabilities/normalize-runtime-capabilities.d.ts +2 -0
- package/dist/runtime/capabilities/runtime-capabilities.d.ts +6 -0
- package/dist/runtime/config/agent-message-codec.d.ts +6 -0
- package/dist/runtime/config/agent-runtime-config-builder.d.ts +87 -0
- package/dist/runtime/host/history.d.ts +18 -0
- package/dist/runtime/host/host.d.ts +7 -0
- package/dist/runtime/host/local/agent-event-bridge.d.ts +29 -0
- package/dist/runtime/host/local/session-record.d.ts +6 -0
- package/dist/runtime/host/local/session-service-invoker.d.ts +4 -0
- package/dist/runtime/host/local/spawn-tool.d.ts +15 -0
- package/dist/runtime/host/local/user-files.d.ts +1 -0
- package/dist/runtime/host/local-runtime-host.d.ts +119 -0
- package/dist/runtime/host/runtime-host-support.d.ts +20 -0
- package/dist/runtime/host/runtime-host.d.ts +163 -0
- package/dist/runtime/orchestration/runtime-builder.d.ts +6 -0
- package/dist/runtime/orchestration/runtime-event-adapter.d.ts +101 -0
- package/dist/runtime/orchestration/runtime-oauth-token-manager.d.ts +30 -0
- package/dist/runtime/orchestration/session-runtime-orchestrator.d.ts +218 -0
- package/dist/runtime/orchestration/session-runtime.d.ts +58 -0
- package/dist/runtime/orchestration/user-input-builder.d.ts +15 -0
- package/dist/runtime/safety/loop-detection.d.ts +58 -0
- package/dist/runtime/safety/mistake-tracker.d.ts +68 -0
- package/dist/runtime/safety/rules.d.ts +6 -0
- package/dist/runtime/tools/subprocess-sandbox.d.ts +43 -0
- package/dist/runtime/tools/tool-approval.d.ts +9 -0
- package/dist/runtime/turn-queue/pending-prompt-service.d.ts +64 -0
- package/dist/services/agent-events.d.ts +33 -0
- package/dist/services/config.d.ts +2 -0
- package/dist/services/global-settings.d.ts +34 -0
- package/dist/services/llms/cline-recommended-models.d.ts +19 -0
- package/dist/services/llms/configured-provider-registry.d.ts +27 -0
- package/dist/services/llms/handler-factory.d.ts +3 -0
- package/dist/services/llms/provider-defaults.d.ts +28 -0
- package/dist/services/llms/provider-settings.d.ts +247 -0
- package/dist/services/llms/runtime-config.d.ts +3 -0
- package/dist/services/llms/runtime-registry.d.ts +19 -0
- package/dist/services/llms/runtime-types.d.ts +84 -0
- package/dist/services/local-runtime-bootstrap.d.ts +45 -0
- package/dist/services/plugin-tools.d.ts +15 -0
- package/dist/services/providers/local-provider-registry.d.ts +218 -0
- package/dist/services/providers/local-provider-service.d.ts +99 -0
- package/dist/services/providers/model-source.d.ts +3 -0
- package/dist/services/session-artifacts.d.ts +17 -0
- package/dist/services/session-data.d.ts +51 -0
- package/dist/services/session-telemetry.d.ts +15 -0
- package/dist/services/storage/file-team-store.d.ts +28 -0
- package/dist/services/storage/provider-settings-legacy-migration.d.ts +38 -0
- package/dist/services/storage/provider-settings-manager.d.ts +23 -0
- package/dist/services/storage/sqlite-session-store.d.ts +30 -0
- package/dist/services/storage/sqlite-team-store.d.ts +34 -0
- package/dist/services/storage/team-store.d.ts +15 -0
- package/dist/services/telemetry/ITelemetryAdapter.d.ts +54 -0
- package/dist/services/telemetry/OpenTelemetryAdapter.d.ts +43 -0
- package/dist/services/telemetry/OpenTelemetryProvider.d.ts +83 -0
- package/dist/services/telemetry/TelemetryLoggerSink.d.ts +27 -0
- package/dist/services/telemetry/TelemetryService.d.ts +34 -0
- package/dist/services/telemetry/core-events.d.ts +198 -0
- package/dist/services/telemetry/distinct-id.d.ts +1 -0
- package/dist/services/telemetry/index.d.ts +3 -0
- package/dist/services/telemetry/index.js +1 -0
- package/dist/services/usage.d.ts +18 -0
- package/dist/services/workspace/file-indexer.d.ts +5 -0
- package/dist/services/workspace/index.d.ts +4 -0
- package/dist/services/workspace/mention-enricher.d.ts +13 -0
- package/dist/services/workspace/workspace-manager.d.ts +27 -0
- package/dist/services/workspace/workspace-manifest.d.ts +31 -0
- package/dist/services/workspace/workspace-telemetry.d.ts +18 -0
- package/dist/session/checkpoint-restore.d.ts +20 -0
- package/dist/session/models/session-graph.d.ts +15 -0
- package/dist/session/models/session-manifest.d.ts +29 -0
- package/dist/session/models/session-row.d.ts +92 -0
- package/dist/session/services/file-session-service.d.ts +8 -0
- package/dist/session/services/message-builder.d.ts +66 -0
- package/dist/session/services/persistence-service.d.ts +58 -0
- package/dist/session/services/session-service.d.ts +13 -0
- package/dist/session/session-snapshot.d.ts +57 -0
- package/dist/session/session-versioning-service.d.ts +48 -0
- package/dist/session/stores/conversation-store.d.ts +29 -0
- package/dist/session/stores/session-manifest-store.d.ts +21 -0
- package/dist/session/stores/team-persistence-store.d.ts +23 -0
- package/dist/session/team/index.d.ts +2 -0
- package/dist/session/team/team-child-session-manager.d.ts +35 -0
- package/dist/session/team/team-session-coordinator.d.ts +13 -0
- package/dist/settings/index.d.ts +2 -0
- package/dist/settings/settings-service.d.ts +6 -0
- package/dist/settings/types.d.ts +42 -0
- package/dist/types/chat-schema.d.ts +161 -0
- package/dist/types/common.d.ts +19 -0
- package/dist/types/config.d.ts +167 -0
- package/dist/types/events.d.ts +89 -0
- package/dist/types/provider-settings.d.ts +19 -0
- package/dist/types/session.d.ts +116 -0
- package/dist/types/sessions.d.ts +28 -0
- package/dist/types/storage.d.ts +36 -0
- package/dist/types.d.ts +32 -0
- package/dist/version.d.ts +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ToolApprovalRequest, ToolApprovalResult } from "@cline/shared";
|
|
2
|
+
import type { ToolExecutors } from "../../extensions/tools";
|
|
3
|
+
export interface RuntimeCapabilities {
|
|
4
|
+
toolExecutors?: Partial<ToolExecutors>;
|
|
5
|
+
requestToolApproval?: (request: ToolApprovalRequest) => Promise<ToolApprovalResult> | ToolApprovalResult;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentMessage, Message, MessageWithMetadata } from "@cline/shared";
|
|
2
|
+
export declare function messageToAgentMessages(message: MessageWithMetadata): AgentMessage[];
|
|
3
|
+
export declare function messagesToAgentMessages(messages: readonly MessageWithMetadata[]): AgentMessage[];
|
|
4
|
+
export declare function agentMessageToMessageWithMetadata(message: AgentMessage): MessageWithMetadata;
|
|
5
|
+
export declare function agentMessagesToMessagesWithMetadata(messages: readonly AgentMessage[]): MessageWithMetadata[];
|
|
6
|
+
export declare function agentMessagesToMessages(messages: readonly AgentMessage[]): Message[];
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build an `AgentRuntimeConfig` from an `AgentConfig` plus session-owned
|
|
3
|
+
* supporting objects (model handler, tools, hooks, plugins, telemetry).
|
|
4
|
+
*
|
|
5
|
+
* The function is intentionally **pure**: it does not create handlers or tools
|
|
6
|
+
* itself; it receives them already resolved from the caller (`SessionRuntime`)
|
|
7
|
+
* and wires them into an `AgentRuntimeConfig`.
|
|
8
|
+
*
|
|
9
|
+
* Fields that do **not** round-trip into `AgentRuntimeConfig`
|
|
10
|
+
* (e.g. `execution.maxConsecutiveMistakes`, `execution.loopDetection`) are
|
|
11
|
+
* consumed by `SessionRuntime` / `MistakeTracker` /
|
|
12
|
+
* `LoopDetectionTracker` — not passed through here.
|
|
13
|
+
*/
|
|
14
|
+
import type { AgentConfig, AgentMessage, AgentModel, AgentRuntimeConfig, AgentRuntimeHooks, AgentRuntimePlugin, AgentRuntimePrepareTurnContext, AgentRuntimePrepareTurnResult, AgentTelemetry, AgentTool, BasicLogger } from "@cline/shared";
|
|
15
|
+
/**
|
|
16
|
+
* Inputs required to assemble an `AgentRuntimeConfig`. Distinct from
|
|
17
|
+
* `AgentConfig` because some of these (the model adapter, the hook
|
|
18
|
+
* bridge's runtime-hooks bag, a resolved plugin list) can only be
|
|
19
|
+
* produced inside `SessionRuntime`.
|
|
20
|
+
*/
|
|
21
|
+
export interface CreateAgentRuntimeConfigInput {
|
|
22
|
+
readonly agentConfig: AgentConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Core/hub runtime session identifier used for host lifecycle operations,
|
|
25
|
+
* event routing, persistence, and approval delivery.
|
|
26
|
+
*/
|
|
27
|
+
readonly sessionId?: string;
|
|
28
|
+
readonly agentId: string;
|
|
29
|
+
/**
|
|
30
|
+
* Agent conversation/transcript identifier used by tools, hooks, telemetry,
|
|
31
|
+
* and model history correlation.
|
|
32
|
+
*/
|
|
33
|
+
readonly conversationId?: string;
|
|
34
|
+
readonly parentAgentId?: string;
|
|
35
|
+
/** The role label for teammates (`AgentConfig.role` in sub-agent configs). */
|
|
36
|
+
readonly agentRole?: string;
|
|
37
|
+
/** Pre-built model adapter (produced by `apiHandlerToAgentModel`). */
|
|
38
|
+
readonly model: AgentModel;
|
|
39
|
+
readonly logger?: BasicLogger;
|
|
40
|
+
readonly telemetry?: AgentTelemetry;
|
|
41
|
+
/** Pre-built tool array (builtins + plugin-contributed + session extras). */
|
|
42
|
+
readonly tools?: readonly AgentTool<unknown, unknown>[];
|
|
43
|
+
readonly toolContextMetadata?: Record<string, unknown>;
|
|
44
|
+
/** Pre-resolved plugin list from the plugin loader. */
|
|
45
|
+
readonly plugins?: readonly AgentRuntimePlugin[];
|
|
46
|
+
/** Runtime hooks supplied by the session/runtime builder. */
|
|
47
|
+
readonly hooks?: Partial<AgentRuntimeHooks>;
|
|
48
|
+
/** Host-owned context pipeline invoked before runtime model hooks. */
|
|
49
|
+
readonly prepareTurn?: (context: AgentRuntimePrepareTurnContext) => Promise<AgentRuntimePrepareTurnResult | undefined> | AgentRuntimePrepareTurnResult | undefined;
|
|
50
|
+
/** Seed messages (usually `session.conversation.getMessages()`). */
|
|
51
|
+
readonly initialMessages?: readonly AgentMessage[];
|
|
52
|
+
/**
|
|
53
|
+
* Override for `AgentRuntimeConfig.systemPrompt` — useful when
|
|
54
|
+
* the caller has composed additional guidance (e.g. via
|
|
55
|
+
* `LocalRuntimeHost.composeSystemPrompt`). Defaults to
|
|
56
|
+
* `agentConfig.systemPrompt`.
|
|
57
|
+
*/
|
|
58
|
+
readonly systemPrompt?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Produce an `AgentRuntimeConfig` from session-owned runtime inputs.
|
|
62
|
+
*/
|
|
63
|
+
export declare function createAgentRuntimeConfig(input: CreateAgentRuntimeConfigInput): AgentRuntimeConfig;
|
|
64
|
+
/**
|
|
65
|
+
* Collect the provider-/reasoning-related fields from `AgentConfig`
|
|
66
|
+
* into `AgentRuntimeConfig.modelOptions`. Kept undefined when every
|
|
67
|
+
* field is undefined so the runtime does not receive an empty object.
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildModelOptions(config: AgentConfig): Record<string, unknown> | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Compose `messageModelInfo` from the provider-related fields per
|
|
72
|
+
* §3.2.1: `{ id: modelId, provider: providerId, family:
|
|
73
|
+
* providerConfig?.family }`.
|
|
74
|
+
*/
|
|
75
|
+
export declare function buildMessageModelInfo(config: AgentConfig): AgentMessage["modelInfo"];
|
|
76
|
+
/**
|
|
77
|
+
* `"parallel"` when `maxParallelToolCalls ≥ 2`, `"sequential"` when
|
|
78
|
+
* `1`, `undefined` when the caller did not specify.
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveToolExecution(maxParallelToolCalls: number | undefined): "sequential" | "parallel" | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Adapt the full `ITelemetryService` to the minimal `AgentTelemetry`
|
|
83
|
+
* shape. The runtime only calls `capture(event, properties)`; the
|
|
84
|
+
* remaining methods are host concerns and stay on the
|
|
85
|
+
* `ITelemetryService` instance owned by `SessionRuntime`.
|
|
86
|
+
*/
|
|
87
|
+
export declare function mapTelemetry(telemetry: AgentConfig["telemetry"]): AgentTelemetry | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SessionManifest } from "../../session/models/session-manifest";
|
|
2
|
+
import type { SessionHistoryRecord, SessionRecord } from "../../types/sessions";
|
|
3
|
+
import type { SessionBackend } from "./host";
|
|
4
|
+
import type { RuntimeHost } from "./runtime-host";
|
|
5
|
+
export interface SessionHistoryListOptions {
|
|
6
|
+
limit?: number;
|
|
7
|
+
includeManifestFallback?: boolean;
|
|
8
|
+
hydrate?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function manifestToSessionRecord(manifest: SessionManifest): SessionRecord;
|
|
11
|
+
export declare function hydrateSessionHistory(host: Pick<RuntimeHost, "readSessionMessages">, rows: SessionRecord[]): Promise<SessionHistoryRecord[]>;
|
|
12
|
+
export declare function listSessionHistory(host: Pick<RuntimeHost, "listSessions" | "readSessionMessages">, options?: SessionHistoryListOptions): Promise<SessionHistoryRecord[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Lists history directly from the persistence backend without constructing a
|
|
15
|
+
* runtime host. This keeps read-only history commands from initializing runtime
|
|
16
|
+
* services such as plugins, MCP, or hub transport.
|
|
17
|
+
*/
|
|
18
|
+
export declare function listSessionHistoryFromBackend(backend: Pick<SessionBackend, "listSessions">, options?: SessionHistoryListOptions): Promise<SessionHistoryRecord[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ClineCoreOptions } from "../../cline-core/types";
|
|
2
|
+
import { FileSessionService } from "../../session/services/file-session-service";
|
|
3
|
+
import { CoreSessionService } from "../../session/services/session-service";
|
|
4
|
+
import type { RuntimeHost } from "./runtime-host";
|
|
5
|
+
export type SessionBackend = CoreSessionService | FileSessionService;
|
|
6
|
+
export declare function resolveSessionBackend(options: ClineCoreOptions): Promise<SessionBackend>;
|
|
7
|
+
export declare function createRuntimeHost(options: ClineCoreOptions): Promise<RuntimeHost>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AgentEvent, BasicLogger } from "@cline/shared";
|
|
2
|
+
import type { TeamEvent } from "../../../extensions/tools/team";
|
|
3
|
+
import { type AgentEventContext } from "../../../services/agent-events";
|
|
4
|
+
import type { CoreSessionConfig } from "../../../types/config";
|
|
5
|
+
import type { CoreSessionEvent } from "../../../types/events";
|
|
6
|
+
import type { ActiveSession } from "../../../types/session";
|
|
7
|
+
import type { SessionAccumulatedUsage } from "../runtime-host";
|
|
8
|
+
export interface AgentEventBridgeDeps {
|
|
9
|
+
getSession(sessionId: string): ActiveSession | undefined;
|
|
10
|
+
usageBySession: Map<string, SessionAccumulatedUsage>;
|
|
11
|
+
emit(event: CoreSessionEvent): void;
|
|
12
|
+
persistMessages: AgentEventContext["persistMessages"];
|
|
13
|
+
enqueuePendingPrompt(sessionId: string, entry: {
|
|
14
|
+
prompt: string;
|
|
15
|
+
delivery: "queue" | "steer";
|
|
16
|
+
}): void;
|
|
17
|
+
invokeBackendOptional(method: string, ...args: unknown[]): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare class AgentEventBridge {
|
|
20
|
+
private readonly deps;
|
|
21
|
+
constructor(deps: AgentEventBridgeDeps);
|
|
22
|
+
dispatchAgentEvent(sessionId: string, config: CoreSessionConfig, event: AgentEvent): void;
|
|
23
|
+
handleTeamEvent(rootSessionId: string, event: TeamEvent): Promise<void>;
|
|
24
|
+
handlePluginEvent(rootSessionId: string, event: {
|
|
25
|
+
name: string;
|
|
26
|
+
payload?: unknown;
|
|
27
|
+
}, fallbackAutomation?: NonNullable<CoreSessionConfig["extensionContext"]>["automation"]): Promise<void>;
|
|
28
|
+
handlePluginLog(rootSessionId: string, payload: unknown, fallbackLogger?: BasicLogger): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FileSessionService } from "../../../session/services/file-session-service";
|
|
2
|
+
import type { CoreSessionService } from "../../../session/services/session-service";
|
|
3
|
+
import type { ActiveSession } from "../../../types/session";
|
|
4
|
+
import type { SessionRecord } from "../../../types/sessions";
|
|
5
|
+
export type SessionBackend = CoreSessionService | FileSessionService;
|
|
6
|
+
export declare function toActiveSessionRecord(session: ActiveSession): SessionRecord;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SessionBackend } from "./session-record";
|
|
2
|
+
export declare function invokeBackend<T>(backend: SessionBackend, method: string, ...args: unknown[]): Promise<T>;
|
|
3
|
+
export declare function invokeBackendOptional(backend: SessionBackend, method: string, ...args: unknown[]): Promise<void>;
|
|
4
|
+
export declare function invokeBackendOptionalValue<T = unknown>(backend: SessionBackend, method: string, ...args: unknown[]): Promise<T | undefined>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AgentEvent, AgentTool } from "@cline/shared";
|
|
2
|
+
import { type ToolExecutors } from "../../../extensions/tools";
|
|
3
|
+
import type { CoreSessionConfig } from "../../../types/config";
|
|
4
|
+
import type { ActiveSession } from "../../../types/session";
|
|
5
|
+
export type SubAgentStartTracker = Map<string, {
|
|
6
|
+
startedAt: number;
|
|
7
|
+
rootSessionId: string;
|
|
8
|
+
}>;
|
|
9
|
+
export interface SpawnToolDeps {
|
|
10
|
+
getSession(sessionId: string): ActiveSession | undefined;
|
|
11
|
+
subAgentStarts: SubAgentStartTracker;
|
|
12
|
+
onAgentEvent(rootSessionId: string, config: CoreSessionConfig, event: AgentEvent): void;
|
|
13
|
+
invokeBackendOptional(method: string, ...args: unknown[]): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare function createSessionSpawnTool(deps: SpawnToolDeps, config: CoreSessionConfig, rootSessionId: string, toolExecutors?: Partial<ToolExecutors>): AgentTool;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadUserFileContent(path: string): Promise<string>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type * as LlmsProviders from "@cline/llms";
|
|
2
|
+
import { type AgentConfig, type AgentResult, type ITelemetryService } from "@cline/shared";
|
|
3
|
+
import type { HookEventPayload } from "../../hooks";
|
|
4
|
+
import { ProviderSettingsManager } from "../../services/storage/provider-settings-manager";
|
|
5
|
+
import type { CoreSessionConfig } from "../../types/config";
|
|
6
|
+
import type { CoreSessionEvent } from "../../types/events";
|
|
7
|
+
import type { SessionRecord } from "../../types/sessions";
|
|
8
|
+
import type { RuntimeCapabilities } from "../capabilities";
|
|
9
|
+
import { RuntimeOAuthTokenManager } from "../orchestration/runtime-oauth-token-manager";
|
|
10
|
+
import type { RuntimeBuilder } from "../orchestration/session-runtime";
|
|
11
|
+
import { SessionRuntime } from "../orchestration/session-runtime-orchestrator";
|
|
12
|
+
import { type SessionBackend } from "./local/session-record";
|
|
13
|
+
import type { PendingPromptsServiceApi, RestoreSessionInput, RestoreSessionResult, RuntimeHost, RuntimeHostSubscribeOptions, SendSessionInput, SessionAccumulatedUsage, StartSessionInput, StartSessionResult } from "./runtime-host";
|
|
14
|
+
export interface LocalRuntimeHostOptions {
|
|
15
|
+
distinctId?: string;
|
|
16
|
+
sessionService: SessionBackend;
|
|
17
|
+
runtimeBuilder?: RuntimeBuilder;
|
|
18
|
+
createAgent?: (config: AgentConfig) => SessionRuntime;
|
|
19
|
+
capabilities?: RuntimeCapabilities;
|
|
20
|
+
toolPolicies?: AgentConfig["toolPolicies"];
|
|
21
|
+
providerSettingsManager?: ProviderSettingsManager;
|
|
22
|
+
oauthTokenManager?: RuntimeOAuthTokenManager;
|
|
23
|
+
telemetry?: ITelemetryService;
|
|
24
|
+
/**
|
|
25
|
+
* Default custom `fetch` implementation threaded into every
|
|
26
|
+
* `ProviderConfig.fetch` built during local session bootstrap. Used by
|
|
27
|
+
* the AI gateway providers when issuing HTTP requests.
|
|
28
|
+
*/
|
|
29
|
+
fetch?: typeof fetch;
|
|
30
|
+
}
|
|
31
|
+
export declare class LocalRuntimeHost implements RuntimeHost {
|
|
32
|
+
readonly runtimeAddress: undefined;
|
|
33
|
+
readonly pendingPrompts: PendingPromptsServiceApi;
|
|
34
|
+
private readonly sessionService;
|
|
35
|
+
private readonly runtimeBuilder;
|
|
36
|
+
private readonly createAgentInstance;
|
|
37
|
+
private readonly toolExecutors?;
|
|
38
|
+
private readonly defaultCapabilities?;
|
|
39
|
+
private readonly defaultToolPolicies?;
|
|
40
|
+
private readonly providerSettingsManager;
|
|
41
|
+
private readonly oauthTokenManager;
|
|
42
|
+
private readonly defaultTelemetry?;
|
|
43
|
+
private readonly defaultFetch?;
|
|
44
|
+
private readonly events;
|
|
45
|
+
private readonly sessions;
|
|
46
|
+
private readonly usageBySession;
|
|
47
|
+
private readonly subAgentStarts;
|
|
48
|
+
private readonly pendingPromptsController;
|
|
49
|
+
private readonly eventBridge;
|
|
50
|
+
private readonly sessionVersioning;
|
|
51
|
+
constructor(options: LocalRuntimeHostOptions);
|
|
52
|
+
startSession(input: StartSessionInput): Promise<StartSessionResult>;
|
|
53
|
+
restoreSession(input: RestoreSessionInput): Promise<RestoreSessionResult>;
|
|
54
|
+
runTurn(input: SendSessionInput): Promise<AgentResult | undefined>;
|
|
55
|
+
getAccumulatedUsage(sessionId: string): Promise<SessionAccumulatedUsage | undefined>;
|
|
56
|
+
abort(sessionId: string, reason?: unknown): Promise<void>;
|
|
57
|
+
stopSession(sessionId: string): Promise<void>;
|
|
58
|
+
dispose(reason?: string): Promise<void>;
|
|
59
|
+
getSession(sessionId: string): Promise<SessionRecord | undefined>;
|
|
60
|
+
listSessions(limit?: number): Promise<SessionRecord[]>;
|
|
61
|
+
deleteSession(sessionId: string): Promise<boolean>;
|
|
62
|
+
updateSession(sessionId: string, updates: {
|
|
63
|
+
prompt?: string | null;
|
|
64
|
+
metadata?: Record<string, unknown> | null;
|
|
65
|
+
title?: string | null;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
updated: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
readSessionMessages(sessionId: string): Promise<LlmsProviders.Message[]>;
|
|
70
|
+
dispatchHookEvent(payload: HookEventPayload): Promise<void>;
|
|
71
|
+
subscribe(listener: (event: CoreSessionEvent) => void, options?: RuntimeHostSubscribeOptions): () => void;
|
|
72
|
+
updateSessionModel(sessionId: string, modelId: string): Promise<void>;
|
|
73
|
+
handlePluginEvent(rootSessionId: string, event: {
|
|
74
|
+
name: string;
|
|
75
|
+
payload?: unknown;
|
|
76
|
+
}, fallbackAutomation?: NonNullable<CoreSessionConfig["extensionContext"]>["automation"]): Promise<void>;
|
|
77
|
+
private executeTurn;
|
|
78
|
+
private completeInteractiveTurn;
|
|
79
|
+
private completeAbortedInteractiveTurn;
|
|
80
|
+
private executeAgentTurn;
|
|
81
|
+
/**
|
|
82
|
+
* Anchor `task.completed` telemetry to the assistant's explicit
|
|
83
|
+
* completion declaration. We emit at most once per session, the moment
|
|
84
|
+
* a successful `submit_and_exit` tool call is observed in the run
|
|
85
|
+
* result. This is the SDK analog of original Cline's
|
|
86
|
+
* `attempt_completion`-driven emission and works for both interactive
|
|
87
|
+
* and non-interactive sessions.
|
|
88
|
+
*
|
|
89
|
+
* `shutdownSession(...)` retains a fallback emission for completed
|
|
90
|
+
* sessions that finish without an explicit completion-tool observation
|
|
91
|
+
* (e.g., non-interactive runs not using the yolo preset). This helper
|
|
92
|
+
* sets `submitAndExitObserved` so the shutdown fallback can suppress a
|
|
93
|
+
* duplicate emission for the same logical completion.
|
|
94
|
+
*/
|
|
95
|
+
private observeTaskCompletionTool;
|
|
96
|
+
private prepareTurnInput;
|
|
97
|
+
private ensureSessionPersisted;
|
|
98
|
+
private markTurnRunning;
|
|
99
|
+
private persistSessionMetadata;
|
|
100
|
+
private finalizeSingleRun;
|
|
101
|
+
private failSession;
|
|
102
|
+
private shutdownSession;
|
|
103
|
+
private releaseSessionRuntime;
|
|
104
|
+
private updateStatus;
|
|
105
|
+
private runWithAuthRetry;
|
|
106
|
+
private syncOAuthCredentials;
|
|
107
|
+
private getSessionOrThrow;
|
|
108
|
+
private resolveAbsoluteFilePaths;
|
|
109
|
+
private getSessionAgentTelemetryIdentity;
|
|
110
|
+
private emitStatus;
|
|
111
|
+
private emitSessionSnapshot;
|
|
112
|
+
private emit;
|
|
113
|
+
private listRows;
|
|
114
|
+
private getRow;
|
|
115
|
+
private readManifest;
|
|
116
|
+
private invoke;
|
|
117
|
+
private invokeOptional;
|
|
118
|
+
private invokeOptionalValue;
|
|
119
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type * as LlmsProviders from "@cline/llms";
|
|
2
|
+
import type { HookEventPayload } from "../../hooks";
|
|
3
|
+
import type { CoreSessionEvent } from "../../types/events";
|
|
4
|
+
import type { RuntimeHostSubscribeOptions, SessionAccumulatedUsage } from "./runtime-host";
|
|
5
|
+
export declare class RuntimeHostEventBus {
|
|
6
|
+
private readonly listeners;
|
|
7
|
+
subscribe(listener: (event: CoreSessionEvent) => void, options?: RuntimeHostSubscribeOptions): () => void;
|
|
8
|
+
emit(event: CoreSessionEvent): void;
|
|
9
|
+
get size(): number;
|
|
10
|
+
}
|
|
11
|
+
export declare function readPersistedMessagesFile(messagesPath?: string | null): Promise<LlmsProviders.Message[]>;
|
|
12
|
+
export declare function cloneAccumulatedUsage(usage: SessionAccumulatedUsage | undefined): SessionAccumulatedUsage | undefined;
|
|
13
|
+
type HookAuditBackend = {
|
|
14
|
+
queueSpawnRequest(payload: HookEventPayload): Promise<void>;
|
|
15
|
+
upsertSubagentSessionFromHook(payload: HookEventPayload): Promise<string | undefined>;
|
|
16
|
+
appendSubagentHookAudit(sessionId: string, payload: HookEventPayload): Promise<void>;
|
|
17
|
+
applySubagentStatus(sessionId: string, payload: HookEventPayload): Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
export declare function replaySubagentHookEvent(payload: HookEventPayload, backend: HookAuditBackend): Promise<void>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type * as LlmsProviders from "@cline/llms";
|
|
2
|
+
import type { AgentResult, RuntimeConfigExtensionKind } from "@cline/shared";
|
|
3
|
+
import type { HookEventPayload } from "../../hooks";
|
|
4
|
+
import type { CheckpointEntry } from "../../hooks/checkpoint-hooks";
|
|
5
|
+
import type { ProviderSettings } from "../../services/llms/provider-settings";
|
|
6
|
+
import type { SessionManifest } from "../../session/models/session-manifest";
|
|
7
|
+
import type { SessionSource } from "../../types/common";
|
|
8
|
+
import type { CoreSessionConfig } from "../../types/config";
|
|
9
|
+
import type { CoreSessionEvent, SessionPendingPrompt } from "../../types/events";
|
|
10
|
+
import type { SessionRecord } from "../../types/sessions";
|
|
11
|
+
import type { RuntimeCapabilities } from "../capabilities";
|
|
12
|
+
type LocalOnlyCoreSessionConfigKeys = "hooks" | "logger" | "telemetry" | "extensionContext" | "extraTools" | "extensions" | "onTeamEvent" | "onConsecutiveMistakeLimitReached";
|
|
13
|
+
export type RuntimeSessionConfig = Omit<CoreSessionConfig, LocalOnlyCoreSessionConfigKeys | "checkpoint" | "compaction"> & {
|
|
14
|
+
checkpoint?: Omit<NonNullable<CoreSessionConfig["checkpoint"]>, "createCheckpoint">;
|
|
15
|
+
compaction?: Omit<NonNullable<CoreSessionConfig["compaction"]>, "compact">;
|
|
16
|
+
};
|
|
17
|
+
export type LocalRuntimeBootstrapConfig = Pick<CoreSessionConfig, LocalOnlyCoreSessionConfigKeys> & {
|
|
18
|
+
checkpoint?: Pick<NonNullable<CoreSessionConfig["checkpoint"]>, "createCheckpoint"> & Partial<NonNullable<CoreSessionConfig["checkpoint"]>>;
|
|
19
|
+
compaction?: Pick<NonNullable<CoreSessionConfig["compaction"]>, "compact"> & Partial<NonNullable<CoreSessionConfig["compaction"]>>;
|
|
20
|
+
};
|
|
21
|
+
export interface LocalRuntimeStartOptions {
|
|
22
|
+
hooks?: LocalRuntimeBootstrapConfig["hooks"];
|
|
23
|
+
logger?: LocalRuntimeBootstrapConfig["logger"];
|
|
24
|
+
telemetry?: LocalRuntimeBootstrapConfig["telemetry"];
|
|
25
|
+
extensionContext?: LocalRuntimeBootstrapConfig["extensionContext"];
|
|
26
|
+
extraTools?: LocalRuntimeBootstrapConfig["extraTools"];
|
|
27
|
+
extensions?: LocalRuntimeBootstrapConfig["extensions"];
|
|
28
|
+
onTeamEvent?: LocalRuntimeBootstrapConfig["onTeamEvent"];
|
|
29
|
+
onConsecutiveMistakeLimitReached?: LocalRuntimeBootstrapConfig["onConsecutiveMistakeLimitReached"];
|
|
30
|
+
checkpoint?: LocalRuntimeBootstrapConfig["checkpoint"];
|
|
31
|
+
compaction?: LocalRuntimeBootstrapConfig["compaction"];
|
|
32
|
+
modelCatalogDefaults?: Partial<NonNullable<ProviderSettings["modelCatalog"]>>;
|
|
33
|
+
userInstructionService?: import("../../extensions/config").UserInstructionConfigService;
|
|
34
|
+
configExtensions?: RuntimeConfigExtensionKind[];
|
|
35
|
+
onTeamRestored?: () => void;
|
|
36
|
+
}
|
|
37
|
+
export interface StartSessionInput {
|
|
38
|
+
config: RuntimeSessionConfig;
|
|
39
|
+
source?: SessionSource;
|
|
40
|
+
prompt?: string;
|
|
41
|
+
interactive?: boolean;
|
|
42
|
+
sessionMetadata?: Record<string, unknown>;
|
|
43
|
+
initialMessages?: LlmsProviders.Message[];
|
|
44
|
+
userImages?: string[];
|
|
45
|
+
userFiles?: string[];
|
|
46
|
+
/**
|
|
47
|
+
* Host-local bootstrap options. These are intentionally isolated from the
|
|
48
|
+
* transport-neutral runtime session config so all runtime hosts share the
|
|
49
|
+
* same execution contract while still allowing host-specific preparation.
|
|
50
|
+
*/
|
|
51
|
+
localRuntime?: LocalRuntimeStartOptions;
|
|
52
|
+
capabilities?: RuntimeCapabilities;
|
|
53
|
+
toolPolicies?: import("@cline/shared").AgentConfig["toolPolicies"];
|
|
54
|
+
}
|
|
55
|
+
export declare function splitCoreSessionConfig(config: CoreSessionConfig): {
|
|
56
|
+
config: RuntimeSessionConfig;
|
|
57
|
+
localRuntime?: LocalRuntimeStartOptions;
|
|
58
|
+
};
|
|
59
|
+
export interface StartSessionResult {
|
|
60
|
+
sessionId: string;
|
|
61
|
+
manifest: SessionManifest;
|
|
62
|
+
manifestPath: string;
|
|
63
|
+
messagesPath: string;
|
|
64
|
+
result?: AgentResult;
|
|
65
|
+
}
|
|
66
|
+
export interface SendSessionInput {
|
|
67
|
+
sessionId: string;
|
|
68
|
+
prompt: string;
|
|
69
|
+
userImages?: string[];
|
|
70
|
+
userFiles?: string[];
|
|
71
|
+
delivery?: "queue" | "steer";
|
|
72
|
+
timeoutMs?: number;
|
|
73
|
+
}
|
|
74
|
+
export interface SessionAccumulatedUsage {
|
|
75
|
+
inputTokens: number;
|
|
76
|
+
outputTokens: number;
|
|
77
|
+
cacheReadTokens: number;
|
|
78
|
+
cacheWriteTokens: number;
|
|
79
|
+
totalCost: number;
|
|
80
|
+
}
|
|
81
|
+
export interface PendingPromptMutationResult {
|
|
82
|
+
sessionId: string;
|
|
83
|
+
prompts: SessionPendingPrompt[];
|
|
84
|
+
prompt?: SessionPendingPrompt;
|
|
85
|
+
updated?: boolean;
|
|
86
|
+
removed?: boolean;
|
|
87
|
+
}
|
|
88
|
+
export interface PendingPromptsListInput {
|
|
89
|
+
sessionId: string;
|
|
90
|
+
}
|
|
91
|
+
export interface PendingPromptsUpdateInput {
|
|
92
|
+
sessionId: string;
|
|
93
|
+
promptId: string;
|
|
94
|
+
prompt?: string;
|
|
95
|
+
delivery?: "queue" | "steer";
|
|
96
|
+
}
|
|
97
|
+
export interface PendingPromptsDeleteInput {
|
|
98
|
+
sessionId: string;
|
|
99
|
+
promptId: string;
|
|
100
|
+
}
|
|
101
|
+
export interface PendingPromptsServiceApi {
|
|
102
|
+
list(input: PendingPromptsListInput): Promise<SessionPendingPrompt[]>;
|
|
103
|
+
update(input: PendingPromptsUpdateInput): Promise<PendingPromptMutationResult>;
|
|
104
|
+
delete(input: PendingPromptsDeleteInput): Promise<PendingPromptMutationResult>;
|
|
105
|
+
}
|
|
106
|
+
export interface PendingPromptsRuntimeService {
|
|
107
|
+
readonly pendingPrompts: PendingPromptsServiceApi;
|
|
108
|
+
}
|
|
109
|
+
export interface SessionUsageRuntimeService {
|
|
110
|
+
getAccumulatedUsage(sessionId: string): Promise<SessionAccumulatedUsage | undefined>;
|
|
111
|
+
}
|
|
112
|
+
export interface SessionModelRuntimeService {
|
|
113
|
+
updateSessionModel(sessionId: string, modelId: string): Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
export interface RuntimeHostSubscribeOptions {
|
|
116
|
+
sessionId?: string;
|
|
117
|
+
}
|
|
118
|
+
export interface RestoreSessionInput {
|
|
119
|
+
sessionId: string;
|
|
120
|
+
checkpointRunCount: number;
|
|
121
|
+
cwd?: string;
|
|
122
|
+
restore?: {
|
|
123
|
+
messages?: boolean;
|
|
124
|
+
workspace?: boolean;
|
|
125
|
+
omitCheckpointMessageFromSession?: boolean;
|
|
126
|
+
};
|
|
127
|
+
start?: StartSessionInput;
|
|
128
|
+
}
|
|
129
|
+
export interface RestoreSessionResult {
|
|
130
|
+
sessionId?: string;
|
|
131
|
+
startResult?: StartSessionResult;
|
|
132
|
+
messages?: LlmsProviders.Message[];
|
|
133
|
+
checkpoint: CheckpointEntry;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* RuntimeHost is the transport/runtime boundary for core session execution.
|
|
137
|
+
* Callers must normalize broad local config into `RuntimeSessionConfig`
|
|
138
|
+
* plus optional named `localRuntime` bootstrap fields before invoking a host.
|
|
139
|
+
*/
|
|
140
|
+
export interface RuntimeHost {
|
|
141
|
+
readonly runtimeAddress?: string;
|
|
142
|
+
startSession(input: StartSessionInput): Promise<StartSessionResult>;
|
|
143
|
+
runTurn(input: SendSessionInput): Promise<AgentResult | undefined>;
|
|
144
|
+
restoreSession(input: RestoreSessionInput): Promise<RestoreSessionResult>;
|
|
145
|
+
abort(sessionId: string, reason?: unknown): Promise<void>;
|
|
146
|
+
stopSession(sessionId: string): Promise<void>;
|
|
147
|
+
dispose(reason?: string): Promise<void>;
|
|
148
|
+
getSession(sessionId: string): Promise<SessionRecord | undefined>;
|
|
149
|
+
listSessions(limit?: number): Promise<SessionRecord[]>;
|
|
150
|
+
deleteSession(sessionId: string): Promise<boolean>;
|
|
151
|
+
updateSession(sessionId: string, updates: {
|
|
152
|
+
prompt?: string | null;
|
|
153
|
+
metadata?: Record<string, unknown> | null;
|
|
154
|
+
title?: string | null;
|
|
155
|
+
}): Promise<{
|
|
156
|
+
updated: boolean;
|
|
157
|
+
}>;
|
|
158
|
+
readSessionMessages(sessionId: string): Promise<LlmsProviders.Message[]>;
|
|
159
|
+
dispatchHookEvent(payload: HookEventPayload): Promise<void>;
|
|
160
|
+
subscribe(listener: (event: CoreSessionEvent) => void, options?: RuntimeHostSubscribeOptions): () => void;
|
|
161
|
+
}
|
|
162
|
+
export type RuntimeHostMode = "auto" | "local" | "hub" | "remote";
|
|
163
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RuntimeBuilder, RuntimeBuilderInput, BuiltRuntime as RuntimeEnvironment } from "./session-runtime";
|
|
2
|
+
export declare function createTeamName(): string;
|
|
3
|
+
export declare class DefaultRuntimeBuilder implements RuntimeBuilder {
|
|
4
|
+
private readonly teamRuntimeEntries;
|
|
5
|
+
build(input: RuntimeBuilderInput): Promise<RuntimeEnvironment>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter from the new `AgentRuntimeEvent` union (13 variants, defined
|
|
3
|
+
* in `@cline/shared/src/agent.ts`) to the legacy `AgentEvent` union
|
|
4
|
+
* (9 top-level types, defined in
|
|
5
|
+
* `@cline/shared/src/agents/types.ts`) consumed by today's
|
|
6
|
+
* `Agent.subscribeEvents` callback.
|
|
7
|
+
*
|
|
8
|
+
* @see PLAN.md §3.1 — new file introduced alongside the core runtime port.
|
|
9
|
+
* @see PLAN.md §3.3.2 — variant-by-variant OLD → NEW mapping.
|
|
10
|
+
* @see PLAN.md §3.2.4 — called from `Agent.subscribeEvents` inside the
|
|
11
|
+
* legacy-agent facade.
|
|
12
|
+
*
|
|
13
|
+
* --- IMPLEMENTATION NOTE — PLAN §3.3.2 text/reasoning-delta rows ----------
|
|
14
|
+
*
|
|
15
|
+
* PLAN.md §3.3.2 describes `assistant-text-delta` as "first delta →
|
|
16
|
+
* content_start, subsequent → content_update". The **actual** legacy
|
|
17
|
+
* shape forbids this: `AgentContentUpdateEvent.contentType` is
|
|
18
|
+
* hard-typed as `"tool"` in
|
|
19
|
+
* `packages/shared/src/agents/types.ts:87`, and the legacy
|
|
20
|
+
* turn-processor
|
|
21
|
+
* (`packages/agents/src/runtime/turn-processor.ts:82-87,113-118`)
|
|
22
|
+
* emits a `content_start` event for **every** text delta and for
|
|
23
|
+
* **every** reasoning delta — not just the first. This adapter
|
|
24
|
+
* preserves that observable behavior (what every legacy consumer
|
|
25
|
+
* relies on today) over the description in §3.3.2.
|
|
26
|
+
*
|
|
27
|
+
* text deltas → content_start { contentType:"text", text,
|
|
28
|
+
* accumulated } (per delta)
|
|
29
|
+
* reasoning deltas → content_start { contentType:"reasoning",
|
|
30
|
+
* reasoning, redacted } (per delta)
|
|
31
|
+
* assistant-message → one content_end { contentType:"text", text }
|
|
32
|
+
* if any text parts; one
|
|
33
|
+
* content_end { contentType:"reasoning", reasoning }
|
|
34
|
+
* if any reasoning parts
|
|
35
|
+
* (turn-processor.ts:157-170).
|
|
36
|
+
*
|
|
37
|
+
* --- STATEFUL BOOK-KEEPING ------------------------------------------------
|
|
38
|
+
*
|
|
39
|
+
* 1. Rolling usage totals. `usage-updated` carries the already-
|
|
40
|
+
* accumulated snapshot (agent-runtime.ts:668-683). Legacy
|
|
41
|
+
* `AgentUsageEvent` wants both per-turn delta and accumulated
|
|
42
|
+
* totals; the adapter subtracts the previous accumulated value
|
|
43
|
+
* from the incoming one to produce the delta.
|
|
44
|
+
* 2. Tool timing. `tool-finished` does not carry `durationMs`. The
|
|
45
|
+
* adapter records `Date.now()` on `tool-started` (keyed by
|
|
46
|
+
* `toolCallId`) and computes `durationMs` at `tool-finished`.
|
|
47
|
+
* Matches `tool-orchestrator.ts:112-131`.
|
|
48
|
+
*
|
|
49
|
+
* Both are scoped to a single adapter instance and cleared by
|
|
50
|
+
* `reset()`.
|
|
51
|
+
*/
|
|
52
|
+
import type { AgentEvent, AgentMessage, AgentRuntimeEvent } from "@cline/shared";
|
|
53
|
+
declare function textFromMessage(message: AgentMessage | undefined): string;
|
|
54
|
+
/**
|
|
55
|
+
* Per-subscriber adapter instance. Constructed once per
|
|
56
|
+
* `Agent.subscribeEvents` registration (or per `SessionRuntime`),
|
|
57
|
+
* used for the lifetime of that subscription, and `reset()` at the
|
|
58
|
+
* start of every new run.
|
|
59
|
+
*
|
|
60
|
+
* `translate(event)` returns zero, one, or two `AgentEvent`s. An
|
|
61
|
+
* array is needed because a single `assistant-message` may yield both
|
|
62
|
+
* a text `content_end` and a reasoning `content_end`. Empty array
|
|
63
|
+
* means the event is intentionally suppressed (§3.3.2 rows
|
|
64
|
+
* `run-started`, `message-added`).
|
|
65
|
+
*/
|
|
66
|
+
export declare class RuntimeEventAdapter {
|
|
67
|
+
private lastUsage;
|
|
68
|
+
private toolStartedAt;
|
|
69
|
+
translate(event: AgentRuntimeEvent): AgentEvent[];
|
|
70
|
+
reset(): void;
|
|
71
|
+
private translateAssistantMessage;
|
|
72
|
+
private translateToolStarted;
|
|
73
|
+
private translateToolFinished;
|
|
74
|
+
private translateUsage;
|
|
75
|
+
private translateRunFinished;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Stateless translator. Works correctly for every variant except
|
|
79
|
+
* those that require bookkeeping:
|
|
80
|
+
*
|
|
81
|
+
* - `usage-updated` — deltas cannot be computed without a prior
|
|
82
|
+
* snapshot; this function treats the prior snapshot as zero (so
|
|
83
|
+
* delta == accumulated). Adequate for a single event, incorrect
|
|
84
|
+
* across multiple.
|
|
85
|
+
* - `tool-finished` — `durationMs` is reported as `undefined`
|
|
86
|
+
* because the corresponding `tool-started` was never observed by
|
|
87
|
+
* this one-shot adapter.
|
|
88
|
+
*
|
|
89
|
+
* Production code must use `RuntimeEventAdapter` for multi-event
|
|
90
|
+
* runs; this function exists for ad-hoc unit tests and one-shot
|
|
91
|
+
* translations where bookkeeping does not matter.
|
|
92
|
+
*
|
|
93
|
+
* Returns `undefined` when the event maps to zero legacy events
|
|
94
|
+
* (`run-started`, `message-added`, or an `assistant-message` that
|
|
95
|
+
* carries no text/reasoning parts). When an event produces multiple
|
|
96
|
+
* legacy events (e.g. `assistant-message` with both text and
|
|
97
|
+
* reasoning parts), only the first is returned; callers needing the
|
|
98
|
+
* full array must use `RuntimeEventAdapter.translate()`.
|
|
99
|
+
*/
|
|
100
|
+
export declare function toLegacyAgentEvent(event: AgentRuntimeEvent): AgentEvent | undefined;
|
|
101
|
+
export { textFromMessage };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ITelemetryService, type OAuthProviderId } from "@cline/shared";
|
|
2
|
+
import { ProviderSettingsManager } from "../../services/storage/provider-settings-manager";
|
|
3
|
+
type ManagedOAuthProviderId = OAuthProviderId;
|
|
4
|
+
export declare class OAuthReauthRequiredError extends Error {
|
|
5
|
+
readonly providerId: ManagedOAuthProviderId;
|
|
6
|
+
constructor(providerId: ManagedOAuthProviderId);
|
|
7
|
+
}
|
|
8
|
+
export type RuntimeOAuthResolution = {
|
|
9
|
+
providerId: ManagedOAuthProviderId;
|
|
10
|
+
apiKey: string;
|
|
11
|
+
accountId?: string;
|
|
12
|
+
refreshed: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare class RuntimeOAuthTokenManager {
|
|
15
|
+
private readonly providerSettingsManager;
|
|
16
|
+
private readonly telemetry?;
|
|
17
|
+
private readonly refreshInFlight;
|
|
18
|
+
constructor(options?: {
|
|
19
|
+
providerSettingsManager?: ProviderSettingsManager;
|
|
20
|
+
telemetry?: ITelemetryService;
|
|
21
|
+
});
|
|
22
|
+
resolveProviderApiKey(input: {
|
|
23
|
+
providerId: string;
|
|
24
|
+
forceRefresh?: boolean;
|
|
25
|
+
}): Promise<RuntimeOAuthResolution | null>;
|
|
26
|
+
private resolveWithSingleFlight;
|
|
27
|
+
private resolveProviderApiKeyInternal;
|
|
28
|
+
private resolveCredentials;
|
|
29
|
+
}
|
|
30
|
+
export {};
|