@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,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Codex (ChatGPT OAuth) flow
|
|
3
|
+
*
|
|
4
|
+
* NOTE: This module uses Node.js crypto and http for the OAuth callback.
|
|
5
|
+
* It is only intended for CLI use, not browser environments.
|
|
6
|
+
*/
|
|
7
|
+
import type { ITelemetryService } from "@cline/shared";
|
|
8
|
+
import type { OAuthCredentials, OAuthPrompt, OAuthProviderInterface } from "./types";
|
|
9
|
+
export declare const OPENAI_CODEX_OAUTH_CONFIG: {
|
|
10
|
+
readonly authorizationEndpoint: "https://auth.openai.com/oauth/authorize";
|
|
11
|
+
readonly tokenEndpoint: "https://auth.openai.com/oauth/token";
|
|
12
|
+
readonly clientId: "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
13
|
+
readonly redirectUri: "http://localhost:1455/auth/callback";
|
|
14
|
+
readonly scopes: "openid profile email offline_access";
|
|
15
|
+
readonly callbackPort: 1455;
|
|
16
|
+
readonly jwtClaimPath: "https://api.openai.com/auth";
|
|
17
|
+
readonly refreshBufferMs: number;
|
|
18
|
+
readonly retryableTokenGraceMs: number;
|
|
19
|
+
readonly httpTimeoutMs: number;
|
|
20
|
+
};
|
|
21
|
+
export type RefreshTokenResolution = {
|
|
22
|
+
forceRefresh?: boolean;
|
|
23
|
+
refreshBufferMs?: number;
|
|
24
|
+
retryableTokenGraceMs?: number;
|
|
25
|
+
};
|
|
26
|
+
export declare function loginOpenAICodex(options: {
|
|
27
|
+
onAuth: (info: {
|
|
28
|
+
url: string;
|
|
29
|
+
instructions?: string;
|
|
30
|
+
}) => void;
|
|
31
|
+
onPrompt: (prompt: OAuthPrompt) => Promise<string>;
|
|
32
|
+
onProgress?: (message: string) => void;
|
|
33
|
+
onManualCodeInput?: () => Promise<string>;
|
|
34
|
+
originator?: string;
|
|
35
|
+
telemetry?: ITelemetryService;
|
|
36
|
+
}): Promise<OAuthCredentials>;
|
|
37
|
+
export declare function refreshOpenAICodexToken(refreshToken: string, fallback?: OAuthCredentials): Promise<OAuthCredentials>;
|
|
38
|
+
export declare function getValidOpenAICodexCredentials(currentCredentials: OAuthCredentials | null, options?: RefreshTokenResolution & {
|
|
39
|
+
telemetry?: ITelemetryService;
|
|
40
|
+
}): Promise<OAuthCredentials | null>;
|
|
41
|
+
export declare function isOpenAICodexTokenExpired(credentials: OAuthCredentials, refreshBufferMs?: number): boolean;
|
|
42
|
+
export declare function normalizeOpenAICodexCredentials(credentials: OAuthCredentials): OAuthCredentials;
|
|
43
|
+
export declare const openaiCodexOAuthProvider: OAuthProviderInterface;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ITelemetryService } from "@cline/shared";
|
|
2
|
+
import type { OAuthCredentials, OAuthLoginCallbacks, OAuthProviderInterface, OcaClientMetadata, OcaOAuthProviderOptions, OcaTokenResolution } from "./types";
|
|
3
|
+
export declare const DEFAULT_INTERNAL_IDCS_CLIENT_ID = "a8331954c0cf48ba99b5dd223a14c6ea";
|
|
4
|
+
export declare const DEFAULT_INTERNAL_IDCS_URL = "https://idcs-9dc693e80d9b469480d7afe00e743931.identity.oraclecloud.com";
|
|
5
|
+
export declare const DEFAULT_INTERNAL_IDCS_SCOPES = "openid offline_access";
|
|
6
|
+
export declare const DEFAULT_INTERNAL_OCA_BASE_URL = "https://code-internal.aiservice.us-chicago-1.oci.oraclecloud.com/20250206/app/litellm";
|
|
7
|
+
export declare const DEFAULT_EXTERNAL_IDCS_CLIENT_ID = "c1aba3deed5740659981a752714eba33";
|
|
8
|
+
export declare const DEFAULT_EXTERNAL_IDCS_URL = "https://login-ext.identity.oraclecloud.com";
|
|
9
|
+
export declare const DEFAULT_EXTERNAL_IDCS_SCOPES = "openid offline_access";
|
|
10
|
+
export declare const DEFAULT_EXTERNAL_OCA_BASE_URL = "https://code.aiservice.us-chicago-1.oci.oraclecloud.com/20250206/app/litellm";
|
|
11
|
+
export declare const OCI_HEADER_OPC_REQUEST_ID = "opc-request-id";
|
|
12
|
+
export declare function loginOcaOAuth(options: OcaOAuthProviderOptions & {
|
|
13
|
+
callbacks: OAuthLoginCallbacks;
|
|
14
|
+
telemetry?: ITelemetryService;
|
|
15
|
+
}): Promise<OAuthCredentials>;
|
|
16
|
+
export declare function refreshOcaToken(credentials: OAuthCredentials, options?: OcaOAuthProviderOptions): Promise<OAuthCredentials>;
|
|
17
|
+
export declare function getValidOcaCredentials(currentCredentials: OAuthCredentials | null, options?: OcaTokenResolution & {
|
|
18
|
+
telemetry?: ITelemetryService;
|
|
19
|
+
}, providerOptions?: OcaOAuthProviderOptions & {
|
|
20
|
+
telemetry?: ITelemetryService;
|
|
21
|
+
}): Promise<OAuthCredentials | null>;
|
|
22
|
+
export declare function createOcaOAuthProvider(options?: OcaOAuthProviderOptions): OAuthProviderInterface;
|
|
23
|
+
export declare function generateOcaOpcRequestId(taskId: string, token: string): Promise<string>;
|
|
24
|
+
export declare function createOcaRequestHeaders(input: {
|
|
25
|
+
accessToken: string;
|
|
26
|
+
taskId: string;
|
|
27
|
+
metadata?: OcaClientMetadata;
|
|
28
|
+
}): Promise<Record<string, string>>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface OAuthCallbackPayload {
|
|
2
|
+
url: URL;
|
|
3
|
+
code?: string;
|
|
4
|
+
state?: string;
|
|
5
|
+
provider?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface OAuthServerListeningInfo {
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
callbackUrl: string;
|
|
12
|
+
}
|
|
13
|
+
export interface OAuthServerCloseInfo {
|
|
14
|
+
host: string;
|
|
15
|
+
port: number;
|
|
16
|
+
}
|
|
17
|
+
export interface LocalOAuthServerOptions {
|
|
18
|
+
host?: string;
|
|
19
|
+
ports: number[];
|
|
20
|
+
callbackPath: string;
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
expectedState?: string;
|
|
23
|
+
successHtml?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Called when the local redirect server successfully binds to a port and is
|
|
26
|
+
* ready to receive the OAuth callback. Hosts can use this to display a
|
|
27
|
+
* "waiting for callback" status indicator or — in remote-development
|
|
28
|
+
* environments like JetBrains Gateway — to forward the port from the remote
|
|
29
|
+
* machine to the local machine where the user's browser is running.
|
|
30
|
+
*
|
|
31
|
+
* May be async; `startLocalOAuthServer` will **await** this callback before
|
|
32
|
+
* returning so that any setup it performs (e.g. port-forwarding) is
|
|
33
|
+
* guaranteed to complete before the caller opens the auth URL. Errors
|
|
34
|
+
* thrown by this callback are swallowed — they do not prevent the OAuth
|
|
35
|
+
* flow from proceeding.
|
|
36
|
+
*/
|
|
37
|
+
onListening?: (info: OAuthServerListeningInfo) => void | Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Called when the local redirect server closes, either because the OAuth
|
|
40
|
+
* callback was received, the flow was cancelled, or the timeout elapsed.
|
|
41
|
+
* Hosts should use this to tear down any port-forward set up in
|
|
42
|
+
* `onListening` and clear any "waiting for callback" status UI.
|
|
43
|
+
*
|
|
44
|
+
* May be async; fired after the underlying server socket is closed.
|
|
45
|
+
*/
|
|
46
|
+
onClose?: (info: OAuthServerCloseInfo) => void | Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export interface LocalOAuthServer {
|
|
49
|
+
callbackUrl: string;
|
|
50
|
+
waitForCallback: () => Promise<OAuthCallbackPayload | null>;
|
|
51
|
+
cancelWait: () => void;
|
|
52
|
+
close: () => void;
|
|
53
|
+
}
|
|
54
|
+
export declare function startLocalOAuthServer(options: LocalOAuthServerOptions): Promise<LocalOAuthServer>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ITelemetryService } from "@cline/shared";
|
|
2
|
+
import type { OAuthServerCloseInfo, OAuthServerListeningInfo } from "./server";
|
|
3
|
+
export interface OAuthPrompt {
|
|
4
|
+
message: string;
|
|
5
|
+
defaultValue?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface OAuthCredentials {
|
|
8
|
+
access: string;
|
|
9
|
+
refresh: string;
|
|
10
|
+
/**
|
|
11
|
+
* Expiration timestamp in milliseconds since epoch.
|
|
12
|
+
*/
|
|
13
|
+
expires: number;
|
|
14
|
+
/**
|
|
15
|
+
* Optional provider-specific account identifier.
|
|
16
|
+
*/
|
|
17
|
+
accountId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional email for display/telemetry.
|
|
20
|
+
*/
|
|
21
|
+
email?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Provider-specific metadata (user info, provider hint, etc).
|
|
24
|
+
*/
|
|
25
|
+
metadata?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export interface OAuthLoginCallbacks {
|
|
28
|
+
onAuth: (info: {
|
|
29
|
+
url: string;
|
|
30
|
+
instructions?: string;
|
|
31
|
+
}) => void;
|
|
32
|
+
onPrompt: (prompt: OAuthPrompt) => Promise<string>;
|
|
33
|
+
onProgress?: (message: string) => void;
|
|
34
|
+
onManualCodeInput?: () => Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Called when the local OAuth redirect server successfully binds to a port
|
|
37
|
+
* and is ready to receive the browser callback. The `info` object contains
|
|
38
|
+
* the host, the bound port number, and the full `callbackUrl`.
|
|
39
|
+
*
|
|
40
|
+
* Use this to:
|
|
41
|
+
* - Show a "waiting for OAuth callback on port N" status indicator in your UI.
|
|
42
|
+
* - Forward the port in remote-development environments (e.g. JetBrains
|
|
43
|
+
* Gateway) from the remote machine to the machine running the browser.
|
|
44
|
+
*
|
|
45
|
+
* Paired with `onServerClose` for teardown.
|
|
46
|
+
*
|
|
47
|
+
* Only fired when the provider uses a local callback server
|
|
48
|
+
* (`OAuthProviderInterface.usesCallbackServer === true`).
|
|
49
|
+
*/
|
|
50
|
+
onServerListening?: (info: OAuthServerListeningInfo) => void | Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Called when the local OAuth redirect server closes — either because the
|
|
53
|
+
* callback was received, the flow was cancelled, or the timeout elapsed.
|
|
54
|
+
*
|
|
55
|
+
* Use this to:
|
|
56
|
+
* - Clear any "waiting for callback" status UI shown in `onServerListening`.
|
|
57
|
+
* - Tear down port-forwards set up in `onServerListening`.
|
|
58
|
+
*
|
|
59
|
+
* Only fired when the provider uses a local callback server
|
|
60
|
+
* (`OAuthProviderInterface.usesCallbackServer === true`).
|
|
61
|
+
*/
|
|
62
|
+
onServerClose?: (info: OAuthServerCloseInfo) => void | Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
export interface OAuthProviderInterface {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
usesCallbackServer: boolean;
|
|
68
|
+
login(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials>;
|
|
69
|
+
refreshToken(credentials: OAuthCredentials): Promise<OAuthCredentials>;
|
|
70
|
+
getApiKey(credentials: OAuthCredentials): string;
|
|
71
|
+
}
|
|
72
|
+
export type OcaMode = "internal" | "external";
|
|
73
|
+
export interface OcaOAuthEnvironmentConfig {
|
|
74
|
+
clientId: string;
|
|
75
|
+
idcsUrl: string;
|
|
76
|
+
scopes: string;
|
|
77
|
+
baseUrl: string;
|
|
78
|
+
}
|
|
79
|
+
export interface OcaOAuthConfig {
|
|
80
|
+
internal: OcaOAuthEnvironmentConfig;
|
|
81
|
+
external: OcaOAuthEnvironmentConfig;
|
|
82
|
+
}
|
|
83
|
+
export interface OcaClientMetadata {
|
|
84
|
+
client?: string;
|
|
85
|
+
clientVersion?: string;
|
|
86
|
+
clientIde?: string;
|
|
87
|
+
clientIdeVersion?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface OcaOAuthProviderOptions {
|
|
90
|
+
config?: Partial<OcaOAuthConfig>;
|
|
91
|
+
mode?: OcaMode | (() => OcaMode);
|
|
92
|
+
callbackPath?: string;
|
|
93
|
+
callbackPorts?: number[];
|
|
94
|
+
requestTimeoutMs?: number;
|
|
95
|
+
refreshBufferMs?: number;
|
|
96
|
+
retryableTokenGraceMs?: number;
|
|
97
|
+
telemetry?: ITelemetryService;
|
|
98
|
+
}
|
|
99
|
+
export interface OcaTokenResolution {
|
|
100
|
+
forceRefresh?: boolean;
|
|
101
|
+
refreshBufferMs?: number;
|
|
102
|
+
retryableTokenGraceMs?: number;
|
|
103
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { OAuthCallbackPayload } from "./server";
|
|
2
|
+
import type { OAuthCredentials } from "./types";
|
|
3
|
+
export declare function getProofKey(): Promise<{
|
|
4
|
+
verifier: string;
|
|
5
|
+
challenge: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function normalizeBaseUrl(value: string): string;
|
|
8
|
+
export declare function resolveUrl(baseUrl: string, path: string): string;
|
|
9
|
+
export type ParsedAuthorizationInput = {
|
|
10
|
+
code?: string;
|
|
11
|
+
state?: string;
|
|
12
|
+
provider?: string;
|
|
13
|
+
};
|
|
14
|
+
export type ParseAuthorizationInputOptions = {
|
|
15
|
+
includeProvider?: boolean;
|
|
16
|
+
allowHashCodeState?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function parseAuthorizationInput(input: string, options?: ParseAuthorizationInputOptions): ParsedAuthorizationInput;
|
|
19
|
+
export declare function decodeJwtPayload(token?: string): Record<string, unknown> | null;
|
|
20
|
+
export declare function parseOAuthError(text: string): {
|
|
21
|
+
code?: string;
|
|
22
|
+
message?: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function isCredentialLikelyExpired(credentials: Pick<OAuthCredentials, "expires">, refreshBufferMs: number): boolean;
|
|
25
|
+
export declare function resolveAuthorizationCodeInput(input: {
|
|
26
|
+
waitForCallback: () => Promise<OAuthCallbackPayload | null>;
|
|
27
|
+
cancelWait: () => void;
|
|
28
|
+
onManualCodeInput?: () => Promise<string>;
|
|
29
|
+
parseOptions?: ParseAuthorizationInputOptions;
|
|
30
|
+
}): Promise<ParsedAuthorizationInput & {
|
|
31
|
+
error?: string;
|
|
32
|
+
}>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AutomationEventEnvelope, BasicLogger, ExtensionContext, ITelemetryService } from "@cline/shared";
|
|
2
|
+
import type { CronService } from "../cron/service/cron-service";
|
|
3
|
+
import type { HubScheduleRuntimeHandlers } from "../cron/service/schedule-service";
|
|
4
|
+
import type { RuntimeHost } from "../runtime/host/runtime-host";
|
|
5
|
+
import type { ClineAutomationEventIngressResult, ClineAutomationEventLog, ClineAutomationListEventsOptions, ClineAutomationListRunsOptions, ClineAutomationListSpecsOptions, ClineAutomationRun, ClineAutomationSpec, ClineCoreAutomationApi, ClineCoreAutomationOptions } from "./types";
|
|
6
|
+
export declare function normalizeAutomationOptions(options: ClineCoreAutomationOptions | boolean | undefined): ClineCoreAutomationOptions | undefined;
|
|
7
|
+
export declare function normalizeAutomationCronScope(scope: ClineCoreAutomationOptions["cronScope"]): "global" | "workspace" | undefined;
|
|
8
|
+
export declare class ClineCoreAutomationController implements ClineCoreAutomationApi {
|
|
9
|
+
private readonly getService;
|
|
10
|
+
constructor(getService: () => CronService);
|
|
11
|
+
start(): Promise<void>;
|
|
12
|
+
stop(): Promise<void>;
|
|
13
|
+
reconcileNow(): Promise<void>;
|
|
14
|
+
ingestEvent(event: AutomationEventEnvelope): ClineAutomationEventIngressResult;
|
|
15
|
+
listEvents(options?: ClineAutomationListEventsOptions): ClineAutomationEventLog[];
|
|
16
|
+
getEvent(eventId: string): ClineAutomationEventLog | undefined;
|
|
17
|
+
listSpecs(options?: ClineAutomationListSpecsOptions): ClineAutomationSpec[];
|
|
18
|
+
listRuns(options?: ClineAutomationListRunsOptions): ClineAutomationRun[];
|
|
19
|
+
}
|
|
20
|
+
export interface ClineCoreAutomationRuntimeHandlersInput {
|
|
21
|
+
host: RuntimeHost;
|
|
22
|
+
getExtensionContext(): ExtensionContext | undefined;
|
|
23
|
+
}
|
|
24
|
+
export declare function createClineCoreAutomationRuntimeHandlers(input: ClineCoreAutomationRuntimeHandlersInput): HubScheduleRuntimeHandlers;
|
|
25
|
+
export interface ClineCoreAutomationExtensionContextInput {
|
|
26
|
+
automationService?: CronService;
|
|
27
|
+
automation: ClineCoreAutomationApi;
|
|
28
|
+
context?: ExtensionContext;
|
|
29
|
+
clientName?: string;
|
|
30
|
+
distinctId?: string;
|
|
31
|
+
logger?: BasicLogger;
|
|
32
|
+
telemetry?: ITelemetryService;
|
|
33
|
+
}
|
|
34
|
+
export declare function createClineCoreAutomationExtensionContext(input: ClineCoreAutomationExtensionContextInput): ExtensionContext | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PendingPromptsRuntimeService, PendingPromptsServiceApi, RuntimeHost, SessionModelRuntimeService, SessionUsageRuntimeService } from "../runtime/host/runtime-host";
|
|
2
|
+
import { type ClineCoreSettingsApi } from "../settings";
|
|
3
|
+
export type RuntimeHostServiceExtensions = RuntimeHost & Partial<PendingPromptsRuntimeService & SessionUsageRuntimeService & SessionModelRuntimeService>;
|
|
4
|
+
export declare function createClineCoreSettingsApi(host: RuntimeHost): ClineCoreSettingsApi;
|
|
5
|
+
export declare function createClineCorePendingPromptsApi(host: RuntimeHost): PendingPromptsServiceApi;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExtensionContext } from "@cline/shared";
|
|
2
|
+
import type { RuntimeCapabilities } from "../runtime/capabilities";
|
|
3
|
+
import type { StartSessionInput } from "../runtime/host/runtime-host";
|
|
4
|
+
import type { ClineCoreStartInput } from "./types";
|
|
5
|
+
export declare function toClineCoreStartInput(input: StartSessionInput | ClineCoreStartInput): ClineCoreStartInput;
|
|
6
|
+
export interface NormalizeClineCoreStartInputOptions {
|
|
7
|
+
defaultCapabilities?: RuntimeCapabilities;
|
|
8
|
+
withExtensionContext?: (context?: ExtensionContext) => ExtensionContext | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function normalizeClineCoreStartInput(input: ClineCoreStartInput, options?: NormalizeClineCoreStartInputOptions): StartSessionInput;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ITelemetryService } from "@cline/shared";
|
|
2
|
+
import type { ClineCoreStartInput } from "./types";
|
|
3
|
+
export interface EmitSessionStartedTelemetryInput {
|
|
4
|
+
input: ClineCoreStartInput;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
telemetry?: ITelemetryService;
|
|
7
|
+
clientName?: string;
|
|
8
|
+
runtimeAddress?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function emitSessionStartedTelemetry(input: EmitSessionStartedTelemetryInput): void;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import type { Message } from "@cline/llms";
|
|
2
|
+
import type { AgentConfig, AutomationEventEnvelope, BasicLogger, ITelemetryService } from "@cline/shared";
|
|
3
|
+
import type { CronEventSuppression } from "../cron/events/cron-event-ingress";
|
|
4
|
+
import type { CronEventLogRecord, CronRunRecord, CronSpecRecord } from "../cron/store/sqlite-cron-store";
|
|
5
|
+
import type { CheckpointEntry } from "../hooks/checkpoint-hooks";
|
|
6
|
+
import type { RuntimeCapabilities } from "../runtime/capabilities";
|
|
7
|
+
import type { SessionHistoryListOptions } from "../runtime/host/history";
|
|
8
|
+
import type { SessionBackend } from "../runtime/host/host";
|
|
9
|
+
import type { LocalRuntimeStartOptions, RuntimeHostMode, StartSessionInput, StartSessionResult } from "../runtime/host/runtime-host";
|
|
10
|
+
import type { CoreSessionConfig } from "../types/config";
|
|
11
|
+
import type { SessionMessagesArtifactUploader } from "../types/session";
|
|
12
|
+
export type { RuntimeHostMode } from "../runtime/host/runtime-host";
|
|
13
|
+
export type { ClineCoreSettingsApi } from "../settings";
|
|
14
|
+
export interface HubOptions {
|
|
15
|
+
endpoint?: string;
|
|
16
|
+
authToken?: string;
|
|
17
|
+
strategy?: "prefer-hub" | "require-hub";
|
|
18
|
+
clientType?: string;
|
|
19
|
+
displayName?: string;
|
|
20
|
+
workspaceRoot?: string;
|
|
21
|
+
cwd?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RemoteOptions {
|
|
24
|
+
endpoint: string;
|
|
25
|
+
authToken?: string;
|
|
26
|
+
clientType?: string;
|
|
27
|
+
displayName?: string;
|
|
28
|
+
workspaceRoot?: string;
|
|
29
|
+
cwd?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ClineCoreAutomationOptions {
|
|
32
|
+
/** @deprecated Use `cronSpecsDir`. */
|
|
33
|
+
cronDir?: string;
|
|
34
|
+
cronSpecsDir?: string;
|
|
35
|
+
/** @deprecated Reports are written under the resolved cron specs directory. */
|
|
36
|
+
reportsDir?: string;
|
|
37
|
+
cronScope?: "global" | "user" | "workspace";
|
|
38
|
+
workspaceRoot?: string;
|
|
39
|
+
dbPath?: string;
|
|
40
|
+
pollIntervalMs?: number;
|
|
41
|
+
claimLeaseSeconds?: number;
|
|
42
|
+
globalMaxConcurrency?: number;
|
|
43
|
+
watcherDebounceMs?: number;
|
|
44
|
+
autoStart?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export type ClineAutomationSpec = CronSpecRecord;
|
|
47
|
+
export type ClineAutomationRun = CronRunRecord;
|
|
48
|
+
export type ClineAutomationEventLog = CronEventLogRecord;
|
|
49
|
+
export type ClineAutomationEventSuppression = CronEventSuppression;
|
|
50
|
+
export type ClineAutomationRunStatus = "queued" | "running" | "done" | "failed" | "cancelled";
|
|
51
|
+
export interface ClineAutomationListSpecsOptions {
|
|
52
|
+
triggerKind?: "one_off" | "schedule" | "event";
|
|
53
|
+
enabled?: boolean;
|
|
54
|
+
parseStatus?: "valid" | "invalid";
|
|
55
|
+
includeRemoved?: boolean;
|
|
56
|
+
limit?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface ClineAutomationListRunsOptions {
|
|
59
|
+
specId?: string;
|
|
60
|
+
status?: ClineAutomationRunStatus | ClineAutomationRunStatus[];
|
|
61
|
+
limit?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface ClineAutomationListEventsOptions {
|
|
64
|
+
eventType?: string;
|
|
65
|
+
source?: string;
|
|
66
|
+
processingStatus?: "received" | "unmatched" | "queued" | "suppressed" | "failed";
|
|
67
|
+
limit?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface ClineAutomationEventIngressResult {
|
|
70
|
+
event: ClineAutomationEventLog;
|
|
71
|
+
duplicate: boolean;
|
|
72
|
+
matchedSpecIds: string[];
|
|
73
|
+
queuedRuns: ClineAutomationRun[];
|
|
74
|
+
suppressions: ClineAutomationEventSuppression[];
|
|
75
|
+
}
|
|
76
|
+
export interface ClineCoreAutomationApi {
|
|
77
|
+
start(): Promise<void>;
|
|
78
|
+
stop(): Promise<void>;
|
|
79
|
+
reconcileNow(): Promise<void>;
|
|
80
|
+
ingestEvent(event: AutomationEventEnvelope): ClineAutomationEventIngressResult;
|
|
81
|
+
listEvents(options?: ClineAutomationListEventsOptions): ClineAutomationEventLog[];
|
|
82
|
+
getEvent(eventId: string): ClineAutomationEventLog | undefined;
|
|
83
|
+
listSpecs(options?: ClineAutomationListSpecsOptions): ClineAutomationSpec[];
|
|
84
|
+
listRuns(options?: ClineAutomationListRunsOptions): ClineAutomationRun[];
|
|
85
|
+
}
|
|
86
|
+
export type ClineCoreListHistoryOptions = SessionHistoryListOptions;
|
|
87
|
+
export interface ClineCoreStartInput extends Omit<StartSessionInput, "config" | "localRuntime"> {
|
|
88
|
+
config: CoreSessionConfig;
|
|
89
|
+
localRuntime?: LocalRuntimeStartOptions;
|
|
90
|
+
}
|
|
91
|
+
export interface RestoreOptions {
|
|
92
|
+
/**
|
|
93
|
+
* Restore the message history by starting a new session fork trimmed to
|
|
94
|
+
* `checkpointRunCount`. Defaults to true.
|
|
95
|
+
*/
|
|
96
|
+
messages?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Restore the workspace files from the checkpoint's git snapshot.
|
|
99
|
+
* Defaults to true.
|
|
100
|
+
*/
|
|
101
|
+
workspace?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Start the forked session with messages before the checkpoint user message
|
|
104
|
+
* while still returning messages through that user message. This is for
|
|
105
|
+
* clients that put the checkpoint message back into a compose box so it can
|
|
106
|
+
* be edited and submitted again without duplicating it in session history.
|
|
107
|
+
*/
|
|
108
|
+
omitCheckpointMessageFromSession?: boolean;
|
|
109
|
+
}
|
|
110
|
+
export interface RestoreInput {
|
|
111
|
+
sessionId: string;
|
|
112
|
+
checkpointRunCount: number;
|
|
113
|
+
start?: ClineCoreStartInput;
|
|
114
|
+
cwd?: string;
|
|
115
|
+
restore?: RestoreOptions;
|
|
116
|
+
}
|
|
117
|
+
export interface RestoreResult {
|
|
118
|
+
sessionId?: string;
|
|
119
|
+
startResult?: StartSessionResult;
|
|
120
|
+
messages?: Message[];
|
|
121
|
+
checkpoint: CheckpointEntry;
|
|
122
|
+
}
|
|
123
|
+
export interface ClineCoreOptions {
|
|
124
|
+
/**
|
|
125
|
+
* A human-readable name for this SDK client (e.g. `"my-app"`, `"acme-bot"`).
|
|
126
|
+
* Used to identify the consumer in telemetry and logs.
|
|
127
|
+
*/
|
|
128
|
+
clientName?: string;
|
|
129
|
+
/**
|
|
130
|
+
* A stable identifier for this machine or user, used for telemetry attribution.
|
|
131
|
+
* Defaults to the system machine ID, falling back to a generated `cl-<nanoid>` persisted
|
|
132
|
+
* at `~/.cline/data/machine-id`.
|
|
133
|
+
*/
|
|
134
|
+
distinctId?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Controls how the runtime host is selected:
|
|
137
|
+
* - `"auto"` (default) — prefers a compatible local hub when one is available and falls
|
|
138
|
+
* back to local in-process execution when not.
|
|
139
|
+
* - `"hub"` — requires a compatible websocket hub runtime; throws if one is not reachable.
|
|
140
|
+
* - `"remote"` — requires an explicit remote websocket hub endpoint.
|
|
141
|
+
* - `"local"` — always uses local in-process execution and local SQLite/file storage.
|
|
142
|
+
*/
|
|
143
|
+
backendMode?: RuntimeHostMode;
|
|
144
|
+
/**
|
|
145
|
+
* Hub runtime connection options. Used when `backendMode` is `"hub"` or when `"auto"`
|
|
146
|
+
* should prefer a shared local hub if available.
|
|
147
|
+
*/
|
|
148
|
+
hub?: HubOptions;
|
|
149
|
+
/**
|
|
150
|
+
* Remote hub connection options. Only relevant when `backendMode` is `"remote"`.
|
|
151
|
+
*/
|
|
152
|
+
remote?: RemoteOptions;
|
|
153
|
+
/**
|
|
154
|
+
* Client-owned runtime capabilities. Core adapts these handlers to the
|
|
155
|
+
* selected runtime backend so apps implement interactive behavior once.
|
|
156
|
+
*/
|
|
157
|
+
capabilities?: RuntimeCapabilities;
|
|
158
|
+
/**
|
|
159
|
+
* Telemetry service instance to use for capturing events and usage.
|
|
160
|
+
* If omitted, telemetry is a no-op.
|
|
161
|
+
*/
|
|
162
|
+
telemetry?: ITelemetryService;
|
|
163
|
+
/**
|
|
164
|
+
* Optional structured logger for core-side operational diagnostics such as
|
|
165
|
+
* runtime-host selection and fallback decisions.
|
|
166
|
+
*/
|
|
167
|
+
logger?: BasicLogger;
|
|
168
|
+
/**
|
|
169
|
+
* Per-tool approval policies that control whether a tool runs automatically,
|
|
170
|
+
* requires user confirmation, or is blocked entirely.
|
|
171
|
+
*/
|
|
172
|
+
toolPolicies?: AgentConfig["toolPolicies"];
|
|
173
|
+
/**
|
|
174
|
+
* Optional hook invoked after `messages.json` is persisted to disk.
|
|
175
|
+
* Consumers can use this to mirror session transcripts into remote storage.
|
|
176
|
+
*/
|
|
177
|
+
messagesArtifactUploader?: SessionMessagesArtifactUploader;
|
|
178
|
+
/**
|
|
179
|
+
* Enables file-based and event-driven automation through this ClineCore
|
|
180
|
+
* instance. When configured, callers use `cline.automation.*` instead of
|
|
181
|
+
* constructing cron services directly.
|
|
182
|
+
*/
|
|
183
|
+
automation?: boolean | ClineCoreAutomationOptions;
|
|
184
|
+
/**
|
|
185
|
+
* Custom `fetch` implementation forwarded to the AI gateway providers used
|
|
186
|
+
* by local sessions. When supplied, it is threaded into each
|
|
187
|
+
* `ProviderConfig.fetch` built during session bootstrap, which in turn
|
|
188
|
+
* populates `GatewayProviderSettings.fetch` (and the top-level
|
|
189
|
+
* `GatewayConfig.fetch` fallback) so hosts can inject custom HTTP behavior
|
|
190
|
+
* such as proxies, retries, tracing, or test doubles.
|
|
191
|
+
*
|
|
192
|
+
* Per-session or per-provider overrides still win: an explicit
|
|
193
|
+
* `config.fetch` on `CoreSessionConfig` or a stored provider-level `fetch`
|
|
194
|
+
* takes precedence over this default.
|
|
195
|
+
*
|
|
196
|
+
* Applies only to sessions executed in this process (local and fallback-
|
|
197
|
+
* to-local auto mode). For hub and remote runtimes the HTTP call happens
|
|
198
|
+
* inside the process that owns the gateway, so configure `fetch` there:
|
|
199
|
+
* - `startHubServer({ fetch })` / `ensureHubServer({ fetch })` from
|
|
200
|
+
* `@cline/hub`
|
|
201
|
+
* - `createLocalHubScheduleRuntimeHandlers({ fetch })` from
|
|
202
|
+
* `@cline/core/hub` for the scheduler
|
|
203
|
+
*/
|
|
204
|
+
fetch?: typeof fetch;
|
|
205
|
+
/**
|
|
206
|
+
* An already-constructed session backend to use instead of resolving one automatically.
|
|
207
|
+
* Intended for testing or embedding a custom persistence layer.
|
|
208
|
+
* @internal
|
|
209
|
+
*/
|
|
210
|
+
sessionService?: SessionBackend;
|
|
211
|
+
/**
|
|
212
|
+
* Optional hook invoked before each session starts.
|
|
213
|
+
* Use this to prepare workspace-scoped runtime state and then return an
|
|
214
|
+
* adapter that mutates the shared session input before core starts the run.
|
|
215
|
+
*/
|
|
216
|
+
prepare?: (input: ClineCoreStartInput) => Promise<StartSessionBootstrap | undefined> | StartSessionBootstrap | undefined;
|
|
217
|
+
}
|
|
218
|
+
export interface StartSessionBootstrap {
|
|
219
|
+
applyToStartSessionInput(input: ClineCoreStartInput): Promise<ClineCoreStartInput> | ClineCoreStartInput;
|
|
220
|
+
dispose?(): Promise<void> | void;
|
|
221
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AutomationEventEnvelope, BasicLogger } from "@cline/shared";
|
|
2
|
+
import type { CronEventLogRecord, CronRunRecord, CronSpecRecord, SqliteCronStore } from "../store/sqlite-cron-store";
|
|
3
|
+
/**
|
|
4
|
+
* Durable ingress for normalized automation events.
|
|
5
|
+
*
|
|
6
|
+
* This layer persists the incoming event before matching, then materializes
|
|
7
|
+
* queued `cron_runs` for matching event specs. It deliberately does not
|
|
8
|
+
* execute agents; the normal runner claim loop owns execution.
|
|
9
|
+
*/
|
|
10
|
+
export interface CronEventIngressOptions {
|
|
11
|
+
store: SqliteCronStore;
|
|
12
|
+
now?: () => number;
|
|
13
|
+
logger?: BasicLogger;
|
|
14
|
+
}
|
|
15
|
+
export type CronEventSuppressionReason = "duplicate_event" | "filter_mismatch" | "dedupe_window" | "cooldown";
|
|
16
|
+
export interface CronEventSuppression {
|
|
17
|
+
specId?: string;
|
|
18
|
+
externalId?: string;
|
|
19
|
+
reason: CronEventSuppressionReason;
|
|
20
|
+
dedupeKey?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface CronEventIngressResult {
|
|
23
|
+
event: CronEventLogRecord;
|
|
24
|
+
duplicate: boolean;
|
|
25
|
+
matchedSpecs: CronSpecRecord[];
|
|
26
|
+
queuedRuns: CronRunRecord[];
|
|
27
|
+
suppressions: CronEventSuppression[];
|
|
28
|
+
}
|
|
29
|
+
export declare function automationEventMatchesFilters(event: AutomationEventEnvelope, filters: Record<string, unknown> | undefined): boolean;
|
|
30
|
+
export declare class CronEventIngress {
|
|
31
|
+
private readonly store;
|
|
32
|
+
private readonly nowFn;
|
|
33
|
+
private readonly logger?;
|
|
34
|
+
constructor(options: CronEventIngressOptions);
|
|
35
|
+
ingestEvent(event: AutomationEventEnvelope): CronEventIngressResult;
|
|
36
|
+
private materializeForSpec;
|
|
37
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ResolveCronSpecsDirOptions } from "@cline/shared/storage";
|
|
2
|
+
import type { CronEventLogRecord, CronRunRecord, CronSpecRecord } from "../store/sqlite-cron-store";
|
|
3
|
+
/**
|
|
4
|
+
* Writes a markdown report for a completed or failed cron run.
|
|
5
|
+
* Reports live under `<cron-specs-dir>/reports/<run-id>.md`.
|
|
6
|
+
* By default that is `~/.cline/cron/reports/<run-id>.md`.
|
|
7
|
+
* and are derived artifacts — the database is still the operational source
|
|
8
|
+
* of truth.
|
|
9
|
+
*/
|
|
10
|
+
export interface CronRunReportData {
|
|
11
|
+
finalText?: string;
|
|
12
|
+
usage?: {
|
|
13
|
+
inputTokens?: number;
|
|
14
|
+
outputTokens?: number;
|
|
15
|
+
cacheReadTokens?: number;
|
|
16
|
+
cacheWriteTokens?: number;
|
|
17
|
+
totalCost?: number;
|
|
18
|
+
};
|
|
19
|
+
toolCalls?: Array<{
|
|
20
|
+
name: string;
|
|
21
|
+
error?: string;
|
|
22
|
+
durationMs?: number;
|
|
23
|
+
}>;
|
|
24
|
+
durationMs?: number;
|
|
25
|
+
error?: string;
|
|
26
|
+
triggerEvent?: CronEventLogRecord;
|
|
27
|
+
}
|
|
28
|
+
export interface WriteReportOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Cron spec source/report location. Defaults to global `~/.cline/cron`.
|
|
31
|
+
* Pass `{ scope: "workspace", workspaceRoot }` to write reports beside a
|
|
32
|
+
* future workspace-scoped cron specs directory.
|
|
33
|
+
*/
|
|
34
|
+
specs?: ResolveCronSpecsDirOptions;
|
|
35
|
+
workspaceRoot: string;
|
|
36
|
+
run: CronRunRecord;
|
|
37
|
+
spec: CronSpecRecord;
|
|
38
|
+
data: CronRunReportData;
|
|
39
|
+
}
|
|
40
|
+
export declare function writeCronRunReport(options: WriteReportOptions): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CronSpecRecord, SqliteCronStore } from "../store/sqlite-cron-store";
|
|
2
|
+
/**
|
|
3
|
+
* Queue materialization rules shared between the reconciler, watcher, and
|
|
4
|
+
* periodic runner tick. Execution stays trigger-agnostic once a row is
|
|
5
|
+
* queued; this module is the only place that decides when to create a row.
|
|
6
|
+
*/
|
|
7
|
+
export interface CronMaterializerOptions {
|
|
8
|
+
store: SqliteCronStore;
|
|
9
|
+
now?: () => number;
|
|
10
|
+
}
|
|
11
|
+
export interface MaterializeSummary {
|
|
12
|
+
oneOffQueued: number;
|
|
13
|
+
scheduleQueued: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class CronMaterializer {
|
|
16
|
+
private readonly store;
|
|
17
|
+
private readonly nowFn;
|
|
18
|
+
constructor(options: CronMaterializerOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Run materialization for every valid/enabled spec. Typically called at
|
|
21
|
+
* startup (after reconciliation) and on each runner tick.
|
|
22
|
+
*/
|
|
23
|
+
materializeAll(): MaterializeSummary;
|
|
24
|
+
/**
|
|
25
|
+
* Ensure a single one-off spec has exactly one run record for its current
|
|
26
|
+
* revision unless an explicit rerun path creates a different trigger kind.
|
|
27
|
+
* Returns true if a new queued run was created.
|
|
28
|
+
*/
|
|
29
|
+
materializeOneOff(spec: CronSpecRecord): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Materialize schedule runs. Implements the "one overdue catch-up on
|
|
32
|
+
* startup, then advance" policy described in PLAN.md.
|
|
33
|
+
*/
|
|
34
|
+
materializeSchedule(spec: CronSpecRecord): boolean;
|
|
35
|
+
}
|