@sctg/cline-core 3.84.0-beta.20260524130712
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 +110 -0
- package/dist/ClineCore.d.ts +283 -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 +47 -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 +61 -0
- package/dist/extensions/context/compaction.d.ts +38 -0
- package/dist/extensions/index.d.ts +5 -0
- package/dist/extensions/mcp/client.d.ts +9 -0
- package/dist/extensions/mcp/config-loader.d.ts +25 -0
- package/dist/extensions/mcp/index.d.ts +11 -0
- package/dist/extensions/mcp/manager.d.ts +23 -0
- package/dist/extensions/mcp/name-transform.d.ts +2 -0
- package/dist/extensions/mcp/oauth.d.ts +48 -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 +111 -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 +84 -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 +722 -0
- package/dist/hub/daemon/index.d.ts +9 -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 +719 -0
- package/dist/hub/runtime-host/hub-runtime-host.d.ts +76 -0
- package/dist/hub/runtime-host/remote-runtime-host.d.ts +9 -0
- package/dist/hub/server/browser-websocket.d.ts +19 -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 +57 -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 +37 -0
- package/dist/hub/server/hub-session-records.d.ts +9 -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 +104 -0
- package/dist/index.js +717 -0
- package/dist/remote-config/integration.d.ts +17 -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 +80 -0
- package/dist/runtime/host/history.d.ts +19 -0
- package/dist/runtime/host/host.d.ts +7 -0
- package/dist/runtime/host/local/agent-event-bridge.d.ts +30 -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 +127 -0
- package/dist/runtime/host/runtime-host-support.d.ts +20 -0
- package/dist/runtime/host/runtime-host.d.ts +169 -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 +69 -0
- package/dist/services/agent-events.d.ts +34 -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 +250 -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 +28 -0
- package/dist/services/providers/local-provider-registry.d.ts +230 -0
- package/dist/services/providers/local-provider-service.d.ts +70 -0
- package/dist/services/providers/model-source.d.ts +3 -0
- package/dist/services/providers/provider-config-fields.d.ts +37 -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 +276 -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 +19 -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 +31 -0
- package/dist/session/models/session-row.d.ts +92 -0
- package/dist/session/services/file-session-service.d.ts +10 -0
- package/dist/session/services/message-builder.d.ts +66 -0
- package/dist/session/services/persistence-service.d.ts +59 -0
- package/dist/session/services/session-service.d.ts +15 -0
- package/dist/session/session-snapshot.d.ts +59 -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 +23 -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 +43 -0
- package/dist/types/chat-schema.d.ts +163 -0
- package/dist/types/common.d.ts +24 -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 +122 -0
- package/dist/types/sessions.d.ts +38 -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 +80 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AgentExtension, PluginSetupContext } from "@cline/shared";
|
|
2
|
+
import type { PluginInitializationFailure, PluginInitializationWarning } from "./plugin-load-report";
|
|
3
|
+
import { type PluginTargeting } from "./plugin-targeting";
|
|
4
|
+
export interface LoadAgentPluginFromPathOptions {
|
|
5
|
+
exportName?: string;
|
|
6
|
+
cwd?: string;
|
|
7
|
+
useCache?: boolean;
|
|
8
|
+
session?: PluginSetupContext["session"];
|
|
9
|
+
client?: PluginSetupContext["client"];
|
|
10
|
+
user?: PluginSetupContext["user"];
|
|
11
|
+
workspaceInfo?: PluginSetupContext["workspaceInfo"];
|
|
12
|
+
automation?: PluginSetupContext["automation"];
|
|
13
|
+
logger?: PluginSetupContext["logger"];
|
|
14
|
+
telemetry?: PluginSetupContext["telemetry"];
|
|
15
|
+
}
|
|
16
|
+
export declare function loadAgentPluginFromPath(pluginPath: string, options?: LoadAgentPluginFromPathOptions): Promise<AgentExtension>;
|
|
17
|
+
export declare function loadAgentPluginsFromPaths(pluginPaths: string[], options?: LoadAgentPluginFromPathOptions & PluginTargeting): Promise<AgentExtension[]>;
|
|
18
|
+
export declare function loadAgentPluginsFromPathsWithDiagnostics(pluginPaths: string[], options?: LoadAgentPluginFromPathOptions & PluginTargeting): Promise<{
|
|
19
|
+
plugins: AgentExtension[];
|
|
20
|
+
failures: PluginInitializationFailure[];
|
|
21
|
+
warnings: PluginInitializationWarning[];
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AgentConfig, PluginSetupContext, WorkspaceInfo } from "@cline/shared";
|
|
2
|
+
import type { PluginLoadDiagnostics } from "./plugin-load-report";
|
|
3
|
+
import type { PluginTargeting } from "./plugin-targeting";
|
|
4
|
+
export type SandboxedPluginSetupContext = Pick<PluginSetupContext, "session" | "client" | "user" | "workspaceInfo" | "logger">;
|
|
5
|
+
export interface PluginSandboxOptions extends PluginTargeting {
|
|
6
|
+
pluginPaths: string[];
|
|
7
|
+
exportName?: string;
|
|
8
|
+
importTimeoutMs?: number;
|
|
9
|
+
hookTimeoutMs?: number;
|
|
10
|
+
contributionTimeoutMs?: number;
|
|
11
|
+
onEvent?: (event: {
|
|
12
|
+
name: string;
|
|
13
|
+
payload?: unknown;
|
|
14
|
+
}) => void;
|
|
15
|
+
/**
|
|
16
|
+
* The session's working directory. Forwarded to the sandbox subprocess so
|
|
17
|
+
* that `process.cwd()` returns the correct path inside the sandbox even
|
|
18
|
+
* when `--cwd` was passed without calling `process.chdir()` on the host.
|
|
19
|
+
*/
|
|
20
|
+
cwd?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Structured workspace and git metadata (branch, commit, remotes) generated
|
|
23
|
+
* at session startup. Forwarded to plugins via PluginSetupCtx.workspaceInfo
|
|
24
|
+
* so they can inspect git state without running their own commands.
|
|
25
|
+
*/
|
|
26
|
+
workspaceInfo?: WorkspaceInfo;
|
|
27
|
+
session?: SandboxedPluginSetupContext["session"];
|
|
28
|
+
client?: SandboxedPluginSetupContext["client"];
|
|
29
|
+
user?: SandboxedPluginSetupContext["user"];
|
|
30
|
+
/** Enables a logger bridge that forwards sandbox log calls to the host. */
|
|
31
|
+
logger?: SandboxedPluginSetupContext["logger"];
|
|
32
|
+
}
|
|
33
|
+
export declare function loadSandboxedPlugins(options: PluginSandboxOptions): Promise<{
|
|
34
|
+
extensions: AgentConfig["extensions"];
|
|
35
|
+
shutdown: () => Promise<void>;
|
|
36
|
+
} & PluginLoadDiagnostics>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PluginManifest } from "@cline/shared";
|
|
2
|
+
export interface PluginTargeting {
|
|
3
|
+
providerId?: string;
|
|
4
|
+
modelId?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function matchesPluginManifestTargeting(manifest: PluginManifest | undefined, targeting: PluginTargeting | undefined): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as GG}from"node:module";var QG=GG(import.meta.url);import{normalizePluginManifest as jG}from"@cline/shared";import{existsSync as _,readFileSync as C}from"node:fs";import{builtinModules as UG,createRequire as b}from"node:module";import{dirname as M,extname as O,isAbsolute as XG,resolve as K}from"node:path";import{fileURLToPath as P}from"node:url";import{PLUGIN_FILE_EXTENSIONS as YG}from"@cline/shared";var h=M(P(import.meta.url)),ZG=b(import.meta.url),$G=K(h,"..","..","..","..",".."),S=WG($G),qG=["@cline/sdk","@cline/agents","@cline/core","@cline/core/hub","@cline/core/hub/daemon-entry","@cline/core/telemetry","@cline/llms","@cline/llms/browser","@cline/shared","@cline/shared/automation","@cline/shared/browser","@cline/shared/storage","@cline/shared/db","@cline/shared/types"],y=new Set(UG.flatMap((G)=>[G,G.replace(/^node:/,"")])),I=new Set(YG),KG=["development","node","import","require","default"];function WG(G){let Q={},U={"@cline/sdk":K(G,"packages/sdk/src/index.ts"),"@cline/agents":K(G,"packages/agents/src/index.ts"),"@cline/core":K(G,"packages/core/src/index.ts"),"@cline/llms":K(G,"packages/llms/src/index.ts"),"@cline/shared":K(G,"packages/shared/src/index.ts"),"@cline/shared/storage":K(G,"packages/shared/src/storage/index.ts"),"@cline/shared/db":K(G,"packages/shared/src/db/index.ts")};for(let[Y,Z]of Object.entries(U))if(_(Z))Q[Y]=Z;for(let Y of["agents","core","llms","shared"]){let Z=K(G,"packages",Y),$=K(Z,"package.json");if(!_($))continue;try{let X=JSON.parse(C($,"utf8"));if(typeof X.name!=="string"||!X.exports)continue;if(typeof X.exports==="string"){let q=K(Z,X.exports);if(_(q))Q[X.name]=q;continue}if(typeof X.exports!=="object")continue;for(let[q,w]of Object.entries(X.exports)){let A=_G(Z,w);if(!A)continue;let L=q==="."?X.name:`${X.name}/${q.replace(/^\.\//,"")}`;Q[L]=A}}catch{}}return Q}function _G(G,Q){let U=R(Q);if(!U)return null;let Y=m(G,U);for(let Z of Y)if(_(Z))return Z;return null}function R(G,Q=new Set){if(typeof G==="string")return G;if(!G||typeof G!=="object")return null;if(Q.has(G))return null;Q.add(G);let U=G;for(let Y of KG){let Z=R(U[Y],Q);if(Z)return Z}return null}function m(G,Q){let U=Q.replace(/^\.\//,""),Y=[K(G,Q)];if(U.startsWith("dist/")){let Z=U.replace(/^dist\//,"src/").replace(/\.(mjs|cjs|js)$/,"");return[K(G,`${Z}.ts`),K(G,`${Z}.tsx`),K(G,`${Z}.mts`),K(G,`${Z}.cts`),...Y]}return Y}function LG(G){return Object.fromEntries(Object.entries(G).sort(([Q],[U])=>U.length-Q.length))}function D(G){return!(G.startsWith(".")||G.startsWith("/")||G.startsWith("file:")||G.startsWith("data:")||G.startsWith("http:")||G.startsWith("https:"))}function J(G){if(G.startsWith("@")){let[Q,U]=G.split("/",3);return U?`${Q}/${U}`:G}return G.split("/",1)[0]??G}function wG(G){let Q=J(G);if(G===Q)return".";return`.${G.slice(Q.length)}`}function d(G){return J(G).startsWith("@cline/")}function V(G,Q){let U=J(Q),Y=M(G);while(!0){let Z=K(Y,"node_modules",U);if(_(Z)||_(K(Z,"package.json")))return!0;let $=K(Y,"..");if($===Y)return!1;Y=$}}function f(G){return T(G)!==null}function T(G){try{return ZG.resolve(G)}catch{}return AG(G)}function AG(G){let Q=J(G),U=u(Q);if(!U)return null;let Y=K(U,"package.json");try{let Z=JSON.parse(C(Y,"utf8")),$=wG(G),X=$==="."&&typeof Z.exports==="string"?Z.exports:Z.exports&&typeof Z.exports==="object"&&Object.hasOwn(Z.exports,$)?Z.exports[$]:void 0,q=R(X)??($==="."&&typeof Z.main==="string"?Z.main:null);if(!q)return null;let w=K(U,q),A=[w,...m(U,q).filter((L)=>L!==w)];for(let L of A)if(_(L))return L;return null}catch{return null}}function zG(){let G=[h],Q=process.env.CLINE_WRAPPER_PATH?.trim();if(Q)G.push(M(M(Q)));let U=process.execPath?.trim();if(U)G.push(M(U));return[...new Set(G.map((Y)=>K(Y)))]}function MG(G,Q){let U=G;while(!0){let Y=K(U,"package.json");if(_(Y))try{if(JSON.parse(C(Y,"utf8")).name===Q)return U}catch{}let Z=K(U,"node_modules",Q,"package.json");if(_(Z))return M(Z);let $=K(U,"..");if($===U)return null;U=$}}function u(G){for(let Q of zG()){let U=MG(Q,G);if(U)return U}return null}function FG(G){let U=M(G);for(let Y=0;Y<4;Y++){let Z=K(U,"package.json");if(_(Z))try{let X=JSON.parse(C(Z,"utf8"));return X!=null&&typeof X==="object"&&"cline"in X}catch{return!1}let $=K(U,"..");if($===U)return!1;U=$}return!1}function l(G,Q){let U=Q.startsWith("file:")?P(Q):XG(Q)?Q:K(M(G),Q);if(_(U)&&I.has(O(U)))return U;for(let Y of I){let Z=`${U}${Y}`;if(_(Z))return Z}for(let Y of I){let Z=K(U,`index${Y}`);if(_(Z))return Z}return null}function c(G){let Q=new Set,U=[/\bimport\s+(?:type\s+)?[^"'`]*?\bfrom\s*["'`]([^"'`]+)["'`]/g,/\bexport\s+[^"'`]*?\bfrom\s*["'`]([^"'`]+)["'`]/g,/\bimport\s*\(\s*["'`]([^"'`]+)["'`]\s*\)/g,/\brequire\s*\(\s*["'`]([^"'`]+)["'`]\s*\)/g];for(let Y of U)for(let Z of G.matchAll(Y)){let $=Z[1];if($)Q.add($)}return[...Q]}function JG(G){return O(G)!==".ts"}function g(G,Q,U=new Set){if(U.has(G)||!_(G))return;if(U.add(G),!I.has(O(G)))return;let Y=C(G,"utf8"),Z=JG(G);for(let $ of c(Y)){if($.startsWith("node:")||y.has($))continue;if(D($)){if(!Z)continue;if(Object.hasOwn(S,$)||Object.hasOwn(S,J($))||V(G,$)||d($)&&f($)||Q&&f($))continue;throw Error(`Cannot find module '${J($)}'`)}let X=l(G,$);if(X)g(X,Q,U)}}function n(G,Q=new Set,U=new Set){if(Q.has(G)||!_(G))return U;if(Q.add(G),!I.has(O(G)))return U;let Y=C(G,"utf8");for(let Z of c(Y)){if(U.add(Z),D(Z))continue;let $=l(G,Z);if($)n($,Q,U)}return U}function CG(G,Q){let U=b(G),Y={},Z=n(G),$=new Set(qG);for(let[X,q]of Object.entries(S)){try{U.resolve(X);continue}catch{}Y[X]=q}for(let X of Z)if(D(X)&&(d(X)||Q))$.add(X);for(let X of $){if(Object.hasOwn(Y,X)||V(G,X))continue;let q=T(X);if(q)Y[X]=q}if(!Q)return Y;for(let X of Z){if(!D(X)||Object.hasOwn(Y,X)||V(G,X)||X.startsWith("node:")||y.has(X))continue;let q=T(X);if(q)Y[X]=q}return Y}function IG(G){let Q=O(G);return Q===".ts"||Q===".tsx"||Q===".mts"||Q===".cts"}var F;function OG(){if(F!==void 0)return F;let G=u("jiti");if(!G)return F=null,null;let Q=K(G,"dist","babel.cjs");if(!_(Q))return F=null,null;try{let Y=b(Q)(Q);F=typeof Y==="function"?Y:null}catch{F=null}return F}async function o(G,Q={}){let U=!FG(G);g(G,U);let Y=CG(G,U),Z=LG(Y),$=await import("jiti"),X=typeof $==="function"?$:typeof $.default==="function"?$.default:void 0;if(!X)throw Error("Unable to load jiti");let q=Object.entries(Z).filter(([,W])=>IG(W)).map(([W])=>W),w=OG(),A=w?(W)=>w({...W,interopDefault:!0}):void 0;return await X(G,{alias:Z,cache:Q.useCache,requireCache:Q.useCache,esmResolve:!0,interopDefault:!1,nativeModules:[...y],transformModules:q,tryNative:!1,...A?{transform:A}:{}}).import(G,{})}function p(G,Q){if(!G)return!0;if(G.providerIds?.length){if(!Q?.providerId||!G.providerIds.includes(Q.providerId))return!1}if(G.modelIds?.length){if(!Q?.modelId||!G.modelIds.includes(Q.modelId))return!1}return!0}function z(G){return typeof G==="object"&&G!==null}function s(G){return Array.isArray(G)&&G.every((Q)=>typeof Q==="string")}function BG(G,Q){if(!z(G))throw Error(`Invalid plugin module: ${Q}`);if(typeof G.name!=="string"||!G.name)throw Error(`Invalid plugin name: ${Q}`);if(!z(G.manifest))throw Error(`Invalid plugin manifest: ${Q}`);if(Object.hasOwn(G.manifest,"providerIds")&&!s(G.manifest.providerIds))throw Error(`Invalid plugin manifest.providerIds: ${Q}`);if(Object.hasOwn(G.manifest,"modelIds")&&!s(G.manifest.modelIds))throw Error(`Invalid plugin manifest.modelIds: ${Q}`)}function DG(G){if(!z(G))throw Error("Plugin setup context must be an object");if(G.session!==void 0&&!z(G.session))throw Error("Plugin setup context session must be an object");if(G.client!==void 0&&!z(G.client))throw Error("Plugin setup context client must be an object");if(G.user!==void 0&&!z(G.user))throw Error("Plugin setup context user must be an object");if(G.workspaceInfo!==void 0&&!z(G.workspaceInfo))throw Error("Plugin setup context workspaceInfo must be an object");if(G.automation!==void 0&&!z(G.automation))throw Error("Plugin setup context automation must be an object");if(G.automation!==void 0&&typeof G.automation.ingestEvent!=="function")throw Error("Plugin setup context automation.ingestEvent must be a function");if(G.logger!==void 0&&!z(G.logger))throw Error("Plugin setup context logger must be an object")}var t=0,H=new Map,v=new Map;function HG(G){let Q=G instanceof Error?G.message:String(G),U=G instanceof Error?G.stack:void 0;return{message:Q,stack:U}}function k(G,Q,U,Y){if(!process.send)return;process.send({type:"response",id:G,ok:Q,result:U,error:Y})}function x(G,Q){if(!process.send)return;process.send({type:"event",name:G,payload:Q})}globalThis.__clinePluginHost={emitEvent:x};globalThis.__clineSessionEnv={cwd:void 0,workspaceInfo:void 0};function i(G){if(!G||typeof G!=="object")return{};return G}function NG(G){if(!G||typeof G!=="object")return;let Q={...G};if(Q.error instanceof Error)Q.error={name:Q.error.name,message:Q.error.message,stack:Q.error.stack};return Q}function EG(G){let Q=(U,Y,Z)=>{x("plugin_log",{level:U,pluginName:G,message:Y,metadata:NG(Z)})};return{debug:(U,Y)=>Q("debug",U,Y),log:(U,Y)=>Q("log",U,Y),error:(U,Y)=>Q("error",U,Y)}}function j(G,Q){let U=`${G}:${Q}`,Y=(v.get(U)??0)+1;return v.set(U,Y),`${G}_${Q}_${Y}`}function SG(G){let Q=typeof G.eventType==="string"?G.eventType.trim():"",U=typeof G.source==="string"?G.source.trim():"";if(!Q)throw Error("Automation event type contribution requires eventType");if(!U)throw Error("Automation event type contribution requires source");return{...G,eventType:Q,source:U,examples:G.examples?[...G.examples]:void 0,metadata:G.metadata?i(G.metadata):void 0}}function N(G){let Q=H.get(G);if(!Q)throw Error(`Unknown sandbox plugin id: ${G}`);return Q}async function VG(G){let Q;try{let U=await o(G.pluginPath);if(Q=U.default??U[G.exportName],BG(Q,G.pluginPath),Q.manifest=jG(Q.manifest),!p(Q.manifest,G.targeting))return{type:"skipped"};let Y={tools:[],commands:[],messageBuilders:[],providers:[],automationEventTypes:[],shortcuts:[],flags:[]},Z={tools:new Map,commands:new Map,messageBuilders:new Map},$={registerTool:(X)=>{let q=j(G.pluginId,"tool");Z.tools.set(q,X.execute),Y.tools.push({id:q,name:X.name,description:X.description,inputSchema:X.inputSchema,timeoutMs:X.timeoutMs,retryable:X.retryable})},registerCommand:(X)=>{let q=j(G.pluginId,"command");if(typeof X.handler==="function")Z.commands.set(q,X.handler);Y.commands.push({id:q,name:X.name,description:X.description})},registerMessageBuilder:(X)=>{let q=j(G.pluginId,"builder");Z.messageBuilders.set(q,X.build),Y.messageBuilders.push({id:q,name:X.name})},registerProvider:(X)=>{Y.providers.push({id:j(G.pluginId,"provider"),name:X.name,description:X.description,metadata:i(X.metadata)})},registerAutomationEventType:(X)=>{Y.automationEventTypes.push({id:j(G.pluginId,"automation_event"),...SG(X)})}};if(typeof Q.setup==="function")try{let X={...G.setupCtxBase,...G.loggerEnabled?{logger:EG(Q.name)}:{},...Q.manifest.capabilities.includes("automationEvents")?{automation:{ingestEvent:(q)=>{x("automation_event",q)}}}:{}};DG(X),await Q.setup($,X)}catch(X){return{type:"failure",failure:{pluginPath:G.pluginPath,pluginName:Q.name,phase:"setup",message:X instanceof Error?X.message:String(X),stack:X instanceof Error?X.stack:void 0}}}return{type:"loaded",state:{plugin:Q,handlers:Z},descriptor:{pluginId:G.pluginId,pluginPath:G.pluginPath,name:Q.name,manifest:Q.manifest,hooks:Q.hooks?Object.entries(Q.hooks).filter(([,X])=>typeof X==="function").map(([X])=>X):void 0,contributions:Y}}}catch(U){return{type:"failure",failure:{pluginPath:G.pluginPath,pluginName:Q?.name,phase:"load",message:U instanceof Error?U.message:String(U),stack:U instanceof Error?U.stack:void 0}}}}async function TG(G){if(H.clear(),t=0,v.clear(),G.cwd)try{process.chdir(G.cwd)}catch{}let Q=globalThis.__clineSessionEnv;if(Q)Q.cwd=G.cwd,Q.workspaceInfo=G.workspaceInfo;let U=[],Y=[],Z=[],$=G.exportName||"plugin",X=new Map,q={providerId:G.providerId,modelId:G.modelId},w={session:G.session,client:G.client,user:G.user,workspaceInfo:G.workspaceInfo},A=await Promise.all((G.pluginPaths||[]).map((L)=>{let W=`plugin_${++t}`;return VG({pluginPath:L,pluginId:W,exportName:$,targeting:q,setupCtxBase:w,loggerEnabled:G.loggerEnabled})}));for(let L of A){if(L.type==="skipped")continue;if(L.type==="failure"){Y.push(L.failure);continue}let{descriptor:W,state:r}=L,E=X.get(W.name);if(E!==void 0){let B=U[E];if(!B)X.delete(W.name);else{Z.push({type:"duplicate_plugin_override",pluginName:W.name,pluginPath:W.pluginPath,overriddenPluginPath:B.pluginPath,message:`Plugin "${W.name}" from ${W.pluginPath} overrides ${B.pluginPath}`}),H.delete(B.pluginId),U.splice(E,1),X.clear();for(let[a,e]of U.entries())X.set(e.name,a)}}H.set(W.pluginId,r),X.set(W.name,U.length),U.push(W)}return{plugins:U,failures:Y,warnings:Z}}async function bG(G){let U=N(G.pluginId).plugin.hooks?.[G.hookName];if(typeof U!=="function")return;return await U(G.payload)}async function yG(G){let U=N(G.pluginId).handlers.tools.get(G.contributionId);if(typeof U!=="function")throw Error("Unknown sandbox tool contribution");return await U(G.input,G.context)}async function RG(G){let U=N(G.pluginId).handlers.commands.get(G.contributionId);if(typeof U!=="function")return"";return await U(G.input)}async function kG(G){let U=N(G.pluginId).handlers.messageBuilders.get(G.contributionId);if(typeof U!=="function")return[];return await U(G.messages)}var vG={initialize:TG,invokeHook:bG,executeTool:yG,executeCommand:RG,buildMessages:kG};process.on("message",async(G)=>{if(!G||G.type!=="call")return;let Q=vG[G.method];if(!Q){k(G.id,!1,void 0,{message:`Unknown method: ${String(G.method)}`});return}try{let U=await Q(G.args||{});k(G.id,!0,U)}catch(U){k(G.id,!1,void 0,HG(U))}});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for Default Tools
|
|
3
|
+
*
|
|
4
|
+
* Tool name constants and utility arrays.
|
|
5
|
+
*/
|
|
6
|
+
import type { DefaultToolName } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* Constants for default tool names
|
|
9
|
+
*/
|
|
10
|
+
export declare const DefaultToolNames: {
|
|
11
|
+
readonly READ_FILES: "read_files";
|
|
12
|
+
readonly SEARCH_CODEBASE: "search_codebase";
|
|
13
|
+
readonly RUN_COMMANDS: "run_commands";
|
|
14
|
+
readonly FETCH_WEB_CONTENT: "fetch_web_content";
|
|
15
|
+
readonly APPLY_PATCH: "apply_patch";
|
|
16
|
+
readonly EDITOR: "editor";
|
|
17
|
+
readonly SKILLS: "skills";
|
|
18
|
+
readonly ASK: "ask_question";
|
|
19
|
+
readonly SUBMIT_AND_EXIT: "submit_and_exit";
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Array of all default tool names
|
|
23
|
+
*/
|
|
24
|
+
export declare const ALL_DEFAULT_TOOL_NAMES: DefaultToolName[];
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default AgentTool Definitions
|
|
3
|
+
*
|
|
4
|
+
* Factory functions for creating the default tools.
|
|
5
|
+
*/
|
|
6
|
+
import { type AgentTool } from "@cline/shared";
|
|
7
|
+
import { type ApplyPatchInput, type AskQuestionInput, type EditFileInput, type FetchWebContentInput, type ReadFilesInput, type RunCommandsInput, type SearchCodebaseInput, type SkillsInput, type StructuredCommandInput, type SubmitInput } from "./schemas";
|
|
8
|
+
import type { ApplyPatchExecutor, AskQuestionExecutor, BashExecutor, CreateDefaultToolsOptions, DefaultToolsConfig, EditorExecutor, FileReadExecutor, SearchExecutor, SkillsExecutorWithMetadata, ToolOperationResult, VerifySubmitExecutor, WebFetchExecutor } from "./types";
|
|
9
|
+
/**
|
|
10
|
+
* Create the read_files tool
|
|
11
|
+
*
|
|
12
|
+
* Reads the content of one or more files from the filesystem.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createReadFilesTool(executor: FileReadExecutor, config?: Pick<DefaultToolsConfig, "fileReadTimeoutMs">): AgentTool<ReadFilesInput, ToolOperationResult[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Create the search_codebase tool
|
|
17
|
+
*
|
|
18
|
+
* Performs regex pattern searches across the codebase.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createSearchTool(executor: SearchExecutor, config?: Pick<DefaultToolsConfig, "cwd" | "searchTimeoutMs">): AgentTool<SearchCodebaseInput, ToolOperationResult[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Create the run_commands tool
|
|
23
|
+
*
|
|
24
|
+
* Executes shell commands in the project directory.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createBashTool(executor: BashExecutor, config?: Pick<DefaultToolsConfig, "cwd" | "bashTimeoutMs">): AgentTool<RunCommandsInput, ToolOperationResult[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Create the run_commands tool
|
|
29
|
+
*
|
|
30
|
+
* Executes shell commands in the project directory.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createWindowsShellTool(executor: BashExecutor, config?: Pick<DefaultToolsConfig, "cwd" | "bashTimeoutMs">): AgentTool<StructuredCommandInput, ToolOperationResult[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Create the fetch_web_content tool
|
|
35
|
+
*
|
|
36
|
+
* Fetches content from URLs and analyzes them using provided prompts.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createWebFetchTool(executor: WebFetchExecutor, config?: Pick<DefaultToolsConfig, "webFetchTimeoutMs">): AgentTool<FetchWebContentInput, ToolOperationResult[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Create the apply_patch tool
|
|
41
|
+
*
|
|
42
|
+
* Applies the canonical apply_patch format to one or more files.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createApplyPatchTool(executor: ApplyPatchExecutor, config?: Pick<DefaultToolsConfig, "cwd" | "applyPatchTimeoutMs">): AgentTool<ApplyPatchInput, ToolOperationResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Create the editor tool
|
|
47
|
+
*
|
|
48
|
+
* Supports controlled filesystem edits with create, replace, and insert commands.
|
|
49
|
+
*/
|
|
50
|
+
export declare function createEditorTool(executor: EditorExecutor, config?: Pick<DefaultToolsConfig, "cwd" | "editorTimeoutMs">): AgentTool<EditFileInput, ToolOperationResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Create the skills tool
|
|
53
|
+
*
|
|
54
|
+
* Invokes a configured skill by name and optional arguments.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createSkillsTool(executor: SkillsExecutorWithMetadata, config?: Pick<DefaultToolsConfig, "skillsTimeoutMs">): AgentTool<SkillsInput, string>;
|
|
57
|
+
/**
|
|
58
|
+
* Create the ask_question tool
|
|
59
|
+
*
|
|
60
|
+
* Asks the user a single clarifying question with 2-5 selectable options.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createAskQuestionTool(executor: AskQuestionExecutor): AgentTool<AskQuestionInput, string>;
|
|
63
|
+
export declare function createSubmitAndExitTool(executor: VerifySubmitExecutor, config?: Pick<DefaultToolsConfig, "submitTimeoutMs">): AgentTool<SubmitInput, string>;
|
|
64
|
+
/**
|
|
65
|
+
* Create a set of default tools for an agent
|
|
66
|
+
*
|
|
67
|
+
* This function creates the default tools based on the provided configuration
|
|
68
|
+
* and executors. Only tools that are enabled AND have an executor provided
|
|
69
|
+
* will be included in the returned array.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* import { Agent, createDefaultTools } from "@cline/core"
|
|
74
|
+
* import * as fs from "fs/promises"
|
|
75
|
+
* import { exec } from "child_process"
|
|
76
|
+
*
|
|
77
|
+
* const tools = createDefaultTools({
|
|
78
|
+
* executors: {
|
|
79
|
+
* readFile: async ({ path }) => fs.readFile(path, "utf-8"),
|
|
80
|
+
* bash: async (cmd, cwd) => {
|
|
81
|
+
* return new Promise((resolve, reject) => {
|
|
82
|
+
* exec(cmd, { cwd }, (err, stdout, stderr) => {
|
|
83
|
+
* if (err) reject(new Error(stderr || err.message))
|
|
84
|
+
* else resolve(stdout)
|
|
85
|
+
* })
|
|
86
|
+
* })
|
|
87
|
+
* },
|
|
88
|
+
* },
|
|
89
|
+
* enableReadFiles: true,
|
|
90
|
+
* enableBash: true,
|
|
91
|
+
* enableSearch: false, // Disabled
|
|
92
|
+
* enableWebFetch: false, // Disabled
|
|
93
|
+
* cwd: "/path/to/project",
|
|
94
|
+
* })
|
|
95
|
+
*
|
|
96
|
+
* const agent = new Agent({
|
|
97
|
+
* // ... provider config
|
|
98
|
+
* tools,
|
|
99
|
+
* })
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function createDefaultTools(options: CreateDefaultToolsOptions): AgentTool[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply Patch parser and patch model types.
|
|
3
|
+
*
|
|
4
|
+
* This parser supports the Cline apply_patch format used by the legacy runtime.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PATCH_MARKERS: {
|
|
7
|
+
readonly BEGIN: "*** Begin Patch";
|
|
8
|
+
readonly END: "*** End Patch";
|
|
9
|
+
readonly ADD: "*** Add File: ";
|
|
10
|
+
readonly UPDATE: "*** Update File: ";
|
|
11
|
+
readonly DELETE: "*** Delete File: ";
|
|
12
|
+
readonly MOVE: "*** Move to: ";
|
|
13
|
+
readonly SECTION: "@@";
|
|
14
|
+
readonly END_FILE: "*** End of File";
|
|
15
|
+
};
|
|
16
|
+
export declare const BASH_WRAPPERS: readonly ["%%bash", "apply_patch", "EOF", "```"];
|
|
17
|
+
export declare enum PatchActionType {
|
|
18
|
+
ADD = "add",
|
|
19
|
+
DELETE = "delete",
|
|
20
|
+
UPDATE = "update"
|
|
21
|
+
}
|
|
22
|
+
export interface PatchChunk {
|
|
23
|
+
origIndex: number;
|
|
24
|
+
delLines: string[];
|
|
25
|
+
insLines: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface PatchAction {
|
|
28
|
+
type: PatchActionType;
|
|
29
|
+
newFile?: string;
|
|
30
|
+
chunks: PatchChunk[];
|
|
31
|
+
movePath?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface PatchWarning {
|
|
34
|
+
path: string;
|
|
35
|
+
chunkIndex?: number;
|
|
36
|
+
message: string;
|
|
37
|
+
context?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface Patch {
|
|
40
|
+
actions: Record<string, PatchAction>;
|
|
41
|
+
warnings?: PatchWarning[];
|
|
42
|
+
}
|
|
43
|
+
export declare class DiffError extends Error {
|
|
44
|
+
constructor(message: string);
|
|
45
|
+
}
|
|
46
|
+
export declare class PatchParser {
|
|
47
|
+
private readonly lines;
|
|
48
|
+
private readonly currentFiles;
|
|
49
|
+
private patch;
|
|
50
|
+
private index;
|
|
51
|
+
private fuzz;
|
|
52
|
+
private currentPath?;
|
|
53
|
+
constructor(lines: string[], currentFiles: Record<string, string>);
|
|
54
|
+
parse(): {
|
|
55
|
+
patch: Patch;
|
|
56
|
+
fuzz: number;
|
|
57
|
+
};
|
|
58
|
+
private addWarning;
|
|
59
|
+
private skipBeginSentinel;
|
|
60
|
+
private hasMoreLines;
|
|
61
|
+
private isEndMarker;
|
|
62
|
+
private parseNextAction;
|
|
63
|
+
private checkDuplicate;
|
|
64
|
+
private parseUpdate;
|
|
65
|
+
private parseUpdateFile;
|
|
66
|
+
private parseDelete;
|
|
67
|
+
private parseAdd;
|
|
68
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply Patch Executor
|
|
3
|
+
*
|
|
4
|
+
* Built-in implementation for the documented GPT-5 apply_patch grammar.
|
|
5
|
+
* It accepts the freeform patch body directly and tolerates the legacy shell
|
|
6
|
+
* wrapper form used by older prompts.
|
|
7
|
+
*/
|
|
8
|
+
import type { ApplyPatchExecutor } from "../types";
|
|
9
|
+
/**
|
|
10
|
+
* Options for the apply_patch executor
|
|
11
|
+
*/
|
|
12
|
+
export interface ApplyPatchExecutorOptions {
|
|
13
|
+
/**
|
|
14
|
+
* File encoding used for read/write operations
|
|
15
|
+
* @default "utf-8"
|
|
16
|
+
*/
|
|
17
|
+
encoding?: BufferEncoding;
|
|
18
|
+
/**
|
|
19
|
+
* Restrict relative-path file operations to paths inside cwd.
|
|
20
|
+
* Absolute paths are always accepted as-is.
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
restrictToCwd?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create an apply_patch executor using Node.js fs module.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createApplyPatchExecutor(options?: ApplyPatchExecutorOptions): ApplyPatchExecutor;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bash Executor
|
|
3
|
+
*
|
|
4
|
+
* Built-in implementation for running shell commands using Node.js spawn.
|
|
5
|
+
*/
|
|
6
|
+
import type { BashExecutor } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Options for the bash executor
|
|
9
|
+
*/
|
|
10
|
+
export interface BashExecutorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Shell to use for execution
|
|
13
|
+
* @default "/bin/bash" on Unix, "powershell" on Windows
|
|
14
|
+
*/
|
|
15
|
+
shell?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Timeout for command execution in milliseconds
|
|
18
|
+
* @default 30000 (30 seconds)
|
|
19
|
+
*/
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum output size in bytes
|
|
23
|
+
* @default 1_000_000 (1MB)
|
|
24
|
+
*/
|
|
25
|
+
maxOutputBytes?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Environment variables to add/override
|
|
28
|
+
*/
|
|
29
|
+
env?: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to combine stdout and stderr
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
combineOutput?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a bash executor using Node.js spawn
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const bash = createBashExecutor({
|
|
42
|
+
* timeoutMs: 60000, // 1 minute timeout
|
|
43
|
+
* shell: "/bin/zsh",
|
|
44
|
+
* })
|
|
45
|
+
*
|
|
46
|
+
* const output = await bash("ls -la", "/path/to/project", context)
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function createBashExecutor(options?: BashExecutorOptions): BashExecutor;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor Executor
|
|
3
|
+
*
|
|
4
|
+
* Built-in implementation for filesystem editing operations.
|
|
5
|
+
*/
|
|
6
|
+
import type { EditorExecutor } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Options for the editor executor
|
|
9
|
+
*/
|
|
10
|
+
export interface EditorExecutorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* File encoding used for read/write operations
|
|
13
|
+
* @default "utf-8"
|
|
14
|
+
*/
|
|
15
|
+
encoding?: BufferEncoding;
|
|
16
|
+
/**
|
|
17
|
+
* Restrict relative-path file operations to paths inside cwd.
|
|
18
|
+
* Absolute paths are always accepted as-is.
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
restrictToCwd?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Maximum number of diff lines in str_replace output
|
|
24
|
+
* @default 200
|
|
25
|
+
*/
|
|
26
|
+
maxDiffLines?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create an editor executor using Node.js fs module
|
|
30
|
+
*/
|
|
31
|
+
export declare function createEditorExecutor(options?: EditorExecutorOptions): EditorExecutor;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Read Executor
|
|
3
|
+
*
|
|
4
|
+
* Built-in implementation for reading files using Node.js fs module.
|
|
5
|
+
*/
|
|
6
|
+
import type { FileReadExecutor } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Options for the file read executor
|
|
9
|
+
*/
|
|
10
|
+
export interface FileReadExecutorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Maximum file size to read in bytes
|
|
13
|
+
* @default 10_000_000 (10MB)
|
|
14
|
+
*/
|
|
15
|
+
maxFileSizeBytes?: number;
|
|
16
|
+
/**
|
|
17
|
+
* File encoding
|
|
18
|
+
* @default "utf-8"
|
|
19
|
+
*/
|
|
20
|
+
encoding?: BufferEncoding;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to include line numbers in output
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
includeLineNumbers?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a file read executor using Node.js fs module
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const readFile = createFileReadExecutor({
|
|
33
|
+
* maxFileSizeBytes: 5_000_000, // 5MB limit
|
|
34
|
+
* includeLineNumbers: true,
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* const content = await readFile({ path: "/path/to/file.ts" }, context)
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function createFileReadExecutor(options?: FileReadExecutorOptions): FileReadExecutor;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Executor Implementations
|
|
3
|
+
*
|
|
4
|
+
* This module provides ready-to-use implementations of the tool executors
|
|
5
|
+
* using Node.js built-in modules. These can be used directly or as references
|
|
6
|
+
* for custom implementations.
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolExecutors } from "../types";
|
|
9
|
+
import { type ApplyPatchExecutorOptions } from "./apply-patch";
|
|
10
|
+
import { type BashExecutorOptions } from "./bash";
|
|
11
|
+
import { type EditorExecutorOptions } from "./editor";
|
|
12
|
+
import { type FileReadExecutorOptions } from "./file-read";
|
|
13
|
+
import { type SearchExecutorOptions } from "./search";
|
|
14
|
+
import { type WebFetchExecutorOptions } from "./web-fetch";
|
|
15
|
+
export { type ApplyPatchExecutorOptions, createApplyPatchExecutor, } from "./apply-patch";
|
|
16
|
+
export { type BashExecutorOptions, createBashExecutor, } from "./bash";
|
|
17
|
+
export { createEditorExecutor, type EditorExecutorOptions } from "./editor";
|
|
18
|
+
export { createFileReadExecutor, type FileReadExecutorOptions, } from "./file-read";
|
|
19
|
+
export { createSearchExecutor, type SearchExecutorOptions } from "./search";
|
|
20
|
+
export { createWebFetchExecutor, type WebFetchExecutorOptions, } from "./web-fetch";
|
|
21
|
+
/**
|
|
22
|
+
* Options for creating default executors
|
|
23
|
+
*/
|
|
24
|
+
export interface DefaultExecutorsOptions {
|
|
25
|
+
fileRead?: FileReadExecutorOptions;
|
|
26
|
+
search?: SearchExecutorOptions;
|
|
27
|
+
bash?: BashExecutorOptions;
|
|
28
|
+
webFetch?: WebFetchExecutorOptions;
|
|
29
|
+
applyPatch?: ApplyPatchExecutorOptions;
|
|
30
|
+
editor?: EditorExecutorOptions;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create all default executors with optional configuration
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { createDefaultTools, createDefaultExecutors } from "@cline/core"
|
|
38
|
+
*
|
|
39
|
+
* const executors = createDefaultExecutors({
|
|
40
|
+
* bash: { timeoutMs: 60000 },
|
|
41
|
+
* search: { maxResults: 50 },
|
|
42
|
+
* })
|
|
43
|
+
*
|
|
44
|
+
* const tools = createDefaultTools({
|
|
45
|
+
* executors,
|
|
46
|
+
* cwd: "/path/to/project",
|
|
47
|
+
* })
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function createDefaultExecutors(options?: DefaultExecutorsOptions): ToolExecutors;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search Executor
|
|
3
|
+
*
|
|
4
|
+
* Built-in implementation for searching the codebase using ripgrep (if available) or regex.
|
|
5
|
+
*/
|
|
6
|
+
import type { SearchExecutor } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Options for the search executor
|
|
9
|
+
*/
|
|
10
|
+
export interface SearchExecutorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* File extensions to include in search (without dot)
|
|
13
|
+
* @default common code extensions
|
|
14
|
+
*/
|
|
15
|
+
includeExtensions?: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Directories to exclude from search
|
|
18
|
+
* @default ["node_modules", ".git", "dist", "build", ".next", "coverage"]
|
|
19
|
+
*/
|
|
20
|
+
excludeDirs?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Maximum number of results to return
|
|
23
|
+
* @default 100
|
|
24
|
+
*/
|
|
25
|
+
maxResults?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Number of context lines before and after match
|
|
28
|
+
* @default 2
|
|
29
|
+
*/
|
|
30
|
+
contextLines?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Maximum depth to traverse
|
|
33
|
+
* @default 20
|
|
34
|
+
*/
|
|
35
|
+
maxDepth?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a search executor using regex pattern matching
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const search = createSearchExecutor({
|
|
43
|
+
* maxResults: 50,
|
|
44
|
+
* contextLines: 3,
|
|
45
|
+
* })
|
|
46
|
+
*
|
|
47
|
+
* const results = await search("function\\s+handleClick", "/path/to/project", context)
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function createSearchExecutor(options?: SearchExecutorOptions): SearchExecutor;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Fetch Executor
|
|
3
|
+
*
|
|
4
|
+
* Built-in implementation for fetching web content using native fetch.
|
|
5
|
+
*/
|
|
6
|
+
import type { WebFetchExecutor } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Options for the web fetch executor
|
|
9
|
+
*/
|
|
10
|
+
export interface WebFetchExecutorOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Timeout for fetch requests in milliseconds
|
|
13
|
+
* @default 30000 (30 seconds)
|
|
14
|
+
*/
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum response size in bytes
|
|
18
|
+
* @default 5_000_000 (5MB)
|
|
19
|
+
*/
|
|
20
|
+
maxResponseBytes?: number;
|
|
21
|
+
/**
|
|
22
|
+
* User agent string
|
|
23
|
+
* @default "Mozilla/5.0 (compatible; AgentBot/1.0)"
|
|
24
|
+
*/
|
|
25
|
+
userAgent?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Additional headers
|
|
28
|
+
*/
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to follow redirects
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
followRedirects?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Maximum number of redirects to follow
|
|
37
|
+
* @default 5
|
|
38
|
+
*/
|
|
39
|
+
maxRedirects?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a web fetch executor using native fetch
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const webFetch = createWebFetchExecutor({
|
|
47
|
+
* timeoutMs: 15000,
|
|
48
|
+
* maxResponseBytes: 2_000_000,
|
|
49
|
+
* })
|
|
50
|
+
*
|
|
51
|
+
* const content = await webFetch(
|
|
52
|
+
* "https://docs.example.com/api",
|
|
53
|
+
* "Extract the authentication section",
|
|
54
|
+
* context
|
|
55
|
+
* )
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function createWebFetchExecutor(options?: WebFetchExecutorOptions): WebFetchExecutor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type EditFileInput, type ReadFileRequest, type StructuredCommandInput } from "./schemas";
|
|
2
|
+
/**
|
|
3
|
+
* Format an error into a string message
|
|
4
|
+
*/
|
|
5
|
+
export declare function formatError(error: unknown): string;
|
|
6
|
+
export declare function getEditorSizeError(input: EditFileInput): string | null;
|
|
7
|
+
/**
|
|
8
|
+
* Create a timeout-wrapped promise
|
|
9
|
+
*/
|
|
10
|
+
export declare function withTimeout<T>(promise: Promise<T>, ms: number, message: string): Promise<T>;
|
|
11
|
+
export declare function normalizeReadFileRequests(input: unknown): ReadFileRequest[];
|
|
12
|
+
export declare function formatReadFileQuery(request: ReadFileRequest): string;
|
|
13
|
+
export declare function getReadFileRangeError(request: ReadFileRequest): string | null;
|
|
14
|
+
export declare function normalizeRunCommandsInput(input: unknown): Array<string | StructuredCommandInput>;
|
|
15
|
+
export declare function formatRunCommandQuery(command: string | StructuredCommandInput): string;
|