@clinebot/core 0.0.0
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 +88 -0
- package/dist/account/cline-account-service.d.ts +34 -0
- package/dist/account/index.d.ts +3 -0
- package/dist/account/rpc.d.ts +38 -0
- package/dist/account/types.d.ts +74 -0
- package/dist/agents/agent-config-loader.d.ts +18 -0
- package/dist/agents/agent-config-parser.d.ts +25 -0
- package/dist/agents/hooks-config-loader.d.ts +23 -0
- package/dist/agents/index.d.ts +11 -0
- package/dist/agents/plugin-config-loader.d.ts +22 -0
- package/dist/agents/plugin-loader.d.ts +9 -0
- package/dist/agents/plugin-sandbox.d.ts +12 -0
- package/dist/agents/unified-config-file-watcher.d.ts +77 -0
- package/dist/agents/user-instruction-config-loader.d.ts +63 -0
- package/dist/auth/client.d.ts +11 -0
- package/dist/auth/cline.d.ts +41 -0
- package/dist/auth/codex.d.ts +39 -0
- package/dist/auth/oca.d.ts +22 -0
- package/dist/auth/server.d.ts +22 -0
- package/dist/auth/types.d.ts +72 -0
- package/dist/auth/utils.d.ts +32 -0
- package/dist/chat/chat-schema.d.ts +145 -0
- package/dist/default-tools/constants.d.ts +23 -0
- package/dist/default-tools/definitions.d.ts +96 -0
- package/dist/default-tools/executors/apply-patch-parser.d.ts +68 -0
- package/dist/default-tools/executors/apply-patch.d.ts +26 -0
- package/dist/default-tools/executors/bash.d.ts +49 -0
- package/dist/default-tools/executors/editor.d.ts +31 -0
- package/dist/default-tools/executors/file-read.d.ts +40 -0
- package/dist/default-tools/executors/index.d.ts +44 -0
- package/dist/default-tools/executors/search.d.ts +50 -0
- package/dist/default-tools/executors/web-fetch.d.ts +58 -0
- package/dist/default-tools/index.d.ts +57 -0
- package/dist/default-tools/presets.d.ts +124 -0
- package/dist/default-tools/schemas.d.ts +121 -0
- package/dist/default-tools/types.d.ts +237 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +220 -0
- package/dist/input/file-indexer.d.ts +5 -0
- package/dist/input/index.d.ts +4 -0
- package/dist/input/mention-enricher.d.ts +12 -0
- package/dist/mcp/config-loader.d.ts +15 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/manager.d.ts +24 -0
- package/dist/mcp/types.d.ts +66 -0
- package/dist/runtime/hook-file-hooks.d.ts +18 -0
- package/dist/runtime/rules.d.ts +5 -0
- package/dist/runtime/runtime-builder.d.ts +5 -0
- package/dist/runtime/sandbox/subprocess-sandbox.d.ts +19 -0
- package/dist/runtime/session-runtime.d.ts +36 -0
- package/dist/runtime/tool-approval.d.ts +9 -0
- package/dist/runtime/workflows.d.ts +13 -0
- package/dist/server/index.d.ts +47 -0
- package/dist/server/index.js +641 -0
- package/dist/session/default-session-manager.d.ts +77 -0
- package/dist/session/rpc-session-service.d.ts +12 -0
- package/dist/session/runtime-oauth-token-manager.d.ts +28 -0
- package/dist/session/session-artifacts.d.ts +19 -0
- package/dist/session/session-graph.d.ts +15 -0
- package/dist/session/session-host.d.ts +21 -0
- package/dist/session/session-manager.d.ts +50 -0
- package/dist/session/session-manifest.d.ts +30 -0
- package/dist/session/session-service.d.ts +113 -0
- package/dist/session/sqlite-rpc-session-backend.d.ts +30 -0
- package/dist/session/unified-session-persistence-service.d.ts +93 -0
- package/dist/session/workspace-manager.d.ts +28 -0
- package/dist/session/workspace-manifest.d.ts +25 -0
- package/dist/storage/provider-settings-legacy-migration.d.ts +13 -0
- package/dist/storage/provider-settings-manager.d.ts +20 -0
- package/dist/storage/sqlite-session-store.d.ts +29 -0
- package/dist/storage/sqlite-team-store.d.ts +31 -0
- package/dist/storage/team-store.d.ts +2 -0
- package/dist/team/index.d.ts +1 -0
- package/dist/team/projections.d.ts +8 -0
- package/dist/types/common.d.ts +10 -0
- package/dist/types/config.d.ts +37 -0
- package/dist/types/events.d.ts +54 -0
- package/dist/types/provider-settings.d.ts +20 -0
- package/dist/types/sessions.d.ts +9 -0
- package/dist/types/storage.d.ts +37 -0
- package/dist/types/workspace.d.ts +7 -0
- package/dist/types.d.ts +26 -0
- package/package.json +63 -0
- package/src/account/cline-account-service.test.ts +101 -0
- package/src/account/cline-account-service.ts +267 -0
- package/src/account/index.ts +20 -0
- package/src/account/rpc.test.ts +62 -0
- package/src/account/rpc.ts +172 -0
- package/src/account/types.ts +80 -0
- package/src/agents/agent-config-loader.test.ts +234 -0
- package/src/agents/agent-config-loader.ts +107 -0
- package/src/agents/agent-config-parser.ts +191 -0
- package/src/agents/hooks-config-loader.ts +97 -0
- package/src/agents/index.ts +84 -0
- package/src/agents/plugin-config-loader.test.ts +91 -0
- package/src/agents/plugin-config-loader.ts +160 -0
- package/src/agents/plugin-loader.test.ts +102 -0
- package/src/agents/plugin-loader.ts +105 -0
- package/src/agents/plugin-sandbox.test.ts +120 -0
- package/src/agents/plugin-sandbox.ts +471 -0
- package/src/agents/unified-config-file-watcher.test.ts +196 -0
- package/src/agents/unified-config-file-watcher.ts +483 -0
- package/src/agents/user-instruction-config-loader.test.ts +158 -0
- package/src/agents/user-instruction-config-loader.ts +438 -0
- package/src/auth/client.test.ts +40 -0
- package/src/auth/client.ts +25 -0
- package/src/auth/cline.test.ts +130 -0
- package/src/auth/cline.ts +414 -0
- package/src/auth/codex.test.ts +170 -0
- package/src/auth/codex.ts +466 -0
- package/src/auth/oca.test.ts +215 -0
- package/src/auth/oca.ts +546 -0
- package/src/auth/server.ts +216 -0
- package/src/auth/types.ts +78 -0
- package/src/auth/utils.test.ts +128 -0
- package/src/auth/utils.ts +247 -0
- package/src/chat/chat-schema.ts +82 -0
- package/src/default-tools/constants.ts +35 -0
- package/src/default-tools/definitions.test.ts +233 -0
- package/src/default-tools/definitions.ts +632 -0
- package/src/default-tools/executors/apply-patch-parser.ts +520 -0
- package/src/default-tools/executors/apply-patch.ts +359 -0
- package/src/default-tools/executors/bash.ts +205 -0
- package/src/default-tools/executors/editor.ts +231 -0
- package/src/default-tools/executors/file-read.test.ts +25 -0
- package/src/default-tools/executors/file-read.ts +94 -0
- package/src/default-tools/executors/index.ts +75 -0
- package/src/default-tools/executors/search.ts +278 -0
- package/src/default-tools/executors/web-fetch.ts +259 -0
- package/src/default-tools/index.ts +161 -0
- package/src/default-tools/presets.test.ts +63 -0
- package/src/default-tools/presets.ts +168 -0
- package/src/default-tools/schemas.ts +228 -0
- package/src/default-tools/types.ts +324 -0
- package/src/index.ts +119 -0
- package/src/input/file-indexer.d.ts +11 -0
- package/src/input/file-indexer.test.ts +87 -0
- package/src/input/file-indexer.ts +280 -0
- package/src/input/index.ts +7 -0
- package/src/input/mention-enricher.test.ts +82 -0
- package/src/input/mention-enricher.ts +119 -0
- package/src/mcp/config-loader.test.ts +238 -0
- package/src/mcp/config-loader.ts +219 -0
- package/src/mcp/index.ts +26 -0
- package/src/mcp/manager.test.ts +106 -0
- package/src/mcp/manager.ts +262 -0
- package/src/mcp/types.ts +88 -0
- package/src/runtime/hook-file-hooks.test.ts +106 -0
- package/src/runtime/hook-file-hooks.ts +736 -0
- package/src/runtime/index.ts +27 -0
- package/src/runtime/rules.ts +34 -0
- package/src/runtime/runtime-builder.team-persistence.test.ts +203 -0
- package/src/runtime/runtime-builder.test.ts +215 -0
- package/src/runtime/runtime-builder.ts +515 -0
- package/src/runtime/runtime-parity.test.ts +132 -0
- package/src/runtime/sandbox/subprocess-sandbox.ts +207 -0
- package/src/runtime/session-runtime.ts +44 -0
- package/src/runtime/tool-approval.ts +104 -0
- package/src/runtime/workflows.test.ts +119 -0
- package/src/runtime/workflows.ts +54 -0
- package/src/server/index.ts +282 -0
- package/src/session/default-session-manager.e2e.test.ts +354 -0
- package/src/session/default-session-manager.test.ts +816 -0
- package/src/session/default-session-manager.ts +1286 -0
- package/src/session/index.ts +37 -0
- package/src/session/rpc-session-service.ts +189 -0
- package/src/session/runtime-oauth-token-manager.test.ts +137 -0
- package/src/session/runtime-oauth-token-manager.ts +265 -0
- package/src/session/session-artifacts.ts +106 -0
- package/src/session/session-graph.ts +90 -0
- package/src/session/session-host.ts +190 -0
- package/src/session/session-manager.ts +56 -0
- package/src/session/session-manifest.ts +29 -0
- package/src/session/session-service.team-persistence.test.ts +48 -0
- package/src/session/session-service.ts +610 -0
- package/src/session/sqlite-rpc-session-backend.ts +303 -0
- package/src/session/unified-session-persistence-service.ts +781 -0
- package/src/session/workspace-manager.ts +98 -0
- package/src/session/workspace-manifest.ts +100 -0
- package/src/storage/artifact-store.ts +1 -0
- package/src/storage/index.ts +11 -0
- package/src/storage/provider-settings-legacy-migration.test.ts +175 -0
- package/src/storage/provider-settings-legacy-migration.ts +637 -0
- package/src/storage/provider-settings-manager.test.ts +111 -0
- package/src/storage/provider-settings-manager.ts +129 -0
- package/src/storage/session-store.ts +1 -0
- package/src/storage/sqlite-session-store.ts +270 -0
- package/src/storage/sqlite-team-store.ts +443 -0
- package/src/storage/team-store.ts +5 -0
- package/src/team/index.ts +4 -0
- package/src/team/projections.ts +285 -0
- package/src/types/common.ts +14 -0
- package/src/types/config.ts +64 -0
- package/src/types/events.ts +46 -0
- package/src/types/index.ts +24 -0
- package/src/types/provider-settings.ts +43 -0
- package/src/types/sessions.ts +16 -0
- package/src/types/storage.ts +64 -0
- package/src/types/workspace.ts +7 -0
- package/src/types.ts +127 -0
|
@@ -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.js";
|
|
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,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Tools
|
|
3
|
+
*
|
|
4
|
+
* This module provides a set of configurable default tools for agents.
|
|
5
|
+
*/
|
|
6
|
+
export { validateWithZod, zodToJsonSchema } from "@clinebot/shared";
|
|
7
|
+
export { ALL_DEFAULT_TOOL_NAMES, DefaultToolNames } from "./constants.js";
|
|
8
|
+
export { createApplyPatchTool, createAskQuestionTool, createBashTool, createDefaultTools, createEditorTool, createReadFilesTool, createSearchTool, createSkillsTool, createWebFetchTool, } from "./definitions.js";
|
|
9
|
+
export { type ApplyPatchExecutorOptions, type BashExecutorOptions, createApplyPatchExecutor, createBashExecutor, createDefaultExecutors, createEditorExecutor, createFileReadExecutor, createSearchExecutor, createWebFetchExecutor, type DefaultExecutorsOptions, type EditorExecutorOptions, type FileReadExecutorOptions, type SearchExecutorOptions, type WebFetchExecutorOptions, } from "./executors/index.js";
|
|
10
|
+
export { createDefaultToolsWithPreset, createToolPoliciesWithPreset, type ToolPolicyPresetName, type ToolPresetName, ToolPresets, } from "./presets.js";
|
|
11
|
+
export { type ApplyPatchInput, ApplyPatchInputSchema, type AskQuestionInput, AskQuestionInputSchema, type EditFileInput, EditFileInputSchema, type FetchWebContentInput, FetchWebContentInputSchema, type ReadFilesInput, ReadFilesInputSchema, type RunCommandsInput, RunCommandsInputSchema, type SearchCodebaseInput, SearchCodebaseInputSchema, type SkillsInput, SkillsInputSchema, type WebFetchRequest, WebFetchRequestSchema, } from "./schemas.js";
|
|
12
|
+
export type { ApplyPatchExecutor, AskQuestionExecutor, BashExecutor, CreateDefaultToolsOptions, DefaultToolName, DefaultToolsConfig, EditorExecutor, FileReadExecutor, SearchExecutor, SkillsExecutor, SkillsExecutorSkillMetadata, SkillsExecutorWithMetadata, ToolExecutors, ToolOperationResult, WebFetchExecutor, } from "./types.js";
|
|
13
|
+
import type { Tool } from "@clinebot/agents";
|
|
14
|
+
import { type DefaultExecutorsOptions } from "./executors/index.js";
|
|
15
|
+
import type { CreateDefaultToolsOptions, ToolExecutors } from "./types.js";
|
|
16
|
+
/**
|
|
17
|
+
* Options for creating default tools with built-in executors
|
|
18
|
+
*/
|
|
19
|
+
export interface CreateBuiltinToolsOptions extends Omit<CreateDefaultToolsOptions, "executors"> {
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for the built-in executors
|
|
22
|
+
*/
|
|
23
|
+
executorOptions?: DefaultExecutorsOptions;
|
|
24
|
+
/**
|
|
25
|
+
* Optional executor overrides/additions for tools without built-ins
|
|
26
|
+
*/
|
|
27
|
+
executors?: Partial<ToolExecutors>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create default tools with built-in Node.js executors
|
|
31
|
+
*
|
|
32
|
+
* This is a convenience function that creates the default tools with
|
|
33
|
+
* working implementations using Node.js built-in modules.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { Agent } from "@clinebot/agents"
|
|
38
|
+
* import { createBuiltinTools } from "@clinebot/core/server"
|
|
39
|
+
*
|
|
40
|
+
* const tools = createBuiltinTools({
|
|
41
|
+
* cwd: "/path/to/project",
|
|
42
|
+
* enableBash: true,
|
|
43
|
+
* enableWebFetch: false, // Disable web fetching
|
|
44
|
+
* executorOptions: {
|
|
45
|
+
* bash: { timeoutMs: 60000 },
|
|
46
|
+
* },
|
|
47
|
+
* })
|
|
48
|
+
*
|
|
49
|
+
* const agent = new Agent({
|
|
50
|
+
* providerId: "anthropic",
|
|
51
|
+
* modelId: "claude-sonnet-4-20250514",
|
|
52
|
+
* systemPrompt: "You are a coding assistant.",
|
|
53
|
+
* tools,
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function createBuiltinTools(options?: CreateBuiltinToolsOptions): Tool[];
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Presets
|
|
3
|
+
*
|
|
4
|
+
* Pre-configured tool combinations for common use cases.
|
|
5
|
+
*/
|
|
6
|
+
import type { Tool, ToolPolicy } from "@clinebot/shared";
|
|
7
|
+
import type { CreateDefaultToolsOptions, DefaultToolsConfig } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Preset configurations for common use cases
|
|
10
|
+
*/
|
|
11
|
+
export declare const ToolPresets: {
|
|
12
|
+
/**
|
|
13
|
+
* Browser-based tools (no shell access, no web fetch)
|
|
14
|
+
*/
|
|
15
|
+
readonly browser: {
|
|
16
|
+
readonly enableReadFiles: false;
|
|
17
|
+
readonly enableSearch: false;
|
|
18
|
+
readonly enableBash: false;
|
|
19
|
+
readonly enableWebFetch: false;
|
|
20
|
+
readonly enableApplyPatch: false;
|
|
21
|
+
readonly enableEditor: false;
|
|
22
|
+
readonly enableSkills: true;
|
|
23
|
+
readonly enableAskQuestion: true;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Search-focused tools (read_files + search_codebase)
|
|
27
|
+
* Good for code exploration and analysis agents
|
|
28
|
+
*/
|
|
29
|
+
readonly search: {
|
|
30
|
+
readonly enableReadFiles: true;
|
|
31
|
+
readonly enableSearch: true;
|
|
32
|
+
readonly enableBash: false;
|
|
33
|
+
readonly enableWebFetch: false;
|
|
34
|
+
readonly enableApplyPatch: false;
|
|
35
|
+
readonly enableEditor: false;
|
|
36
|
+
readonly enableSkills: false;
|
|
37
|
+
readonly enableAskQuestion: false;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Full development tools (all tools enabled) - Act mode
|
|
41
|
+
* Good for coding assistants and task automation
|
|
42
|
+
*/
|
|
43
|
+
readonly development: {
|
|
44
|
+
readonly enableReadFiles: true;
|
|
45
|
+
readonly enableSearch: true;
|
|
46
|
+
readonly enableBash: true;
|
|
47
|
+
readonly enableWebFetch: true;
|
|
48
|
+
readonly enableApplyPatch: false;
|
|
49
|
+
readonly enableEditor: true;
|
|
50
|
+
readonly enableSkills: true;
|
|
51
|
+
readonly enableAskQuestion: true;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Read-only tools (no shell access) - Plan mode
|
|
55
|
+
* Good for analysis and documentation agents
|
|
56
|
+
*/
|
|
57
|
+
readonly readonly: {
|
|
58
|
+
readonly enableReadFiles: true;
|
|
59
|
+
readonly enableSearch: true;
|
|
60
|
+
readonly enableBash: true;
|
|
61
|
+
readonly enableWebFetch: true;
|
|
62
|
+
readonly enableApplyPatch: false;
|
|
63
|
+
readonly enableEditor: false;
|
|
64
|
+
readonly enableSkills: true;
|
|
65
|
+
readonly enableAskQuestion: true;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Minimal tools (file reading only)
|
|
69
|
+
* Good for focused single-file tasks
|
|
70
|
+
*/
|
|
71
|
+
readonly minimal: {
|
|
72
|
+
readonly enableReadFiles: false;
|
|
73
|
+
readonly enableSearch: false;
|
|
74
|
+
readonly enableBash: false;
|
|
75
|
+
readonly enableWebFetch: false;
|
|
76
|
+
readonly enableApplyPatch: false;
|
|
77
|
+
readonly enableEditor: false;
|
|
78
|
+
readonly enableSkills: false;
|
|
79
|
+
readonly enableAskQuestion: true;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* YOLO mode (everything enabled + no approval required)
|
|
83
|
+
* Good for trusted local automation workflows.
|
|
84
|
+
*/
|
|
85
|
+
readonly yolo: {
|
|
86
|
+
readonly enableReadFiles: true;
|
|
87
|
+
readonly enableSearch: true;
|
|
88
|
+
readonly enableBash: true;
|
|
89
|
+
readonly enableWebFetch: true;
|
|
90
|
+
readonly enableApplyPatch: false;
|
|
91
|
+
readonly enableEditor: true;
|
|
92
|
+
readonly enableSkills: true;
|
|
93
|
+
readonly enableAskQuestion: true;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Type for preset names
|
|
98
|
+
*/
|
|
99
|
+
export type ToolPresetName = keyof typeof ToolPresets;
|
|
100
|
+
/**
|
|
101
|
+
* Tool policy preset names
|
|
102
|
+
*/
|
|
103
|
+
export type ToolPolicyPresetName = "default" | "yolo";
|
|
104
|
+
/**
|
|
105
|
+
* Build tool policies for a preset.
|
|
106
|
+
* `yolo` guarantees all tools are enabled and auto-approved.
|
|
107
|
+
*/
|
|
108
|
+
export declare function createToolPoliciesWithPreset(presetName: ToolPolicyPresetName): Record<string, ToolPolicy>;
|
|
109
|
+
/**
|
|
110
|
+
* Create default tools using a preset configuration
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const tools = createDefaultToolsWithPreset("readonly", {
|
|
115
|
+
* executors: {
|
|
116
|
+
* readFile: async (path) => fs.readFile(path, "utf-8"),
|
|
117
|
+
* search: async (query, cwd) => searchFiles(query, cwd),
|
|
118
|
+
* webFetch: async (url, prompt) => fetchAndAnalyze(url, prompt),
|
|
119
|
+
* },
|
|
120
|
+
* cwd: "/path/to/project",
|
|
121
|
+
* })
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export declare function createDefaultToolsWithPreset(presetName: ToolPresetName, options: Omit<CreateDefaultToolsOptions, keyof DefaultToolsConfig> & Partial<DefaultToolsConfig>): Tool[];
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod Schemas for Default Tool Inputs
|
|
3
|
+
*
|
|
4
|
+
* These schemas define the input structure for each default tool
|
|
5
|
+
* and are used for both validation and JSON Schema generation.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
/**
|
|
9
|
+
* Schema for read_files tool input
|
|
10
|
+
*/
|
|
11
|
+
export declare const ReadFilesInputSchema: z.ZodObject<{
|
|
12
|
+
file_paths: z.ZodArray<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare const ReadFilesInputUnionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
15
|
+
file_paths: z.ZodArray<z.ZodString>;
|
|
16
|
+
}, z.core.$strip>, z.ZodArray<z.ZodString>, z.ZodString]>;
|
|
17
|
+
/**
|
|
18
|
+
* Schema for search_codebase tool input
|
|
19
|
+
*/
|
|
20
|
+
export declare const SearchCodebaseInputSchema: z.ZodObject<{
|
|
21
|
+
queries: z.ZodArray<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
/**
|
|
24
|
+
* Schema for run_commands tool input
|
|
25
|
+
*/
|
|
26
|
+
export declare const RunCommandsInputSchema: z.ZodObject<{
|
|
27
|
+
commands: z.ZodArray<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export declare const RunCommandsInputUnionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
30
|
+
commands: z.ZodArray<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>, z.ZodArray<z.ZodString>, z.ZodString]>;
|
|
32
|
+
/**
|
|
33
|
+
* Schema for a single web fetch request
|
|
34
|
+
*/
|
|
35
|
+
export declare const WebFetchRequestSchema: z.ZodObject<{
|
|
36
|
+
url: z.ZodURL;
|
|
37
|
+
prompt: z.ZodString;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
/**
|
|
40
|
+
* Schema for fetch_web_content tool input
|
|
41
|
+
*/
|
|
42
|
+
export declare const FetchWebContentInputSchema: z.ZodObject<{
|
|
43
|
+
requests: z.ZodArray<z.ZodObject<{
|
|
44
|
+
url: z.ZodURL;
|
|
45
|
+
prompt: z.ZodString;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
/**
|
|
49
|
+
* Schema for editor tool input
|
|
50
|
+
*/
|
|
51
|
+
export declare const EditFileInputSchema: z.ZodObject<{
|
|
52
|
+
command: z.ZodEnum<{
|
|
53
|
+
create: "create";
|
|
54
|
+
str_replace: "str_replace";
|
|
55
|
+
insert: "insert";
|
|
56
|
+
}>;
|
|
57
|
+
path: z.ZodString;
|
|
58
|
+
file_text: z.ZodOptional<z.ZodString>;
|
|
59
|
+
old_str: z.ZodOptional<z.ZodString>;
|
|
60
|
+
new_str: z.ZodOptional<z.ZodString>;
|
|
61
|
+
insert_line: z.ZodOptional<z.ZodNumber>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
/**
|
|
64
|
+
* Schema for apply_patch tool input
|
|
65
|
+
*/
|
|
66
|
+
export declare const ApplyPatchInputSchema: z.ZodObject<{
|
|
67
|
+
input: z.ZodString;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
export declare const ApplyPatchInputUnionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
70
|
+
input: z.ZodString;
|
|
71
|
+
}, z.core.$strip>, z.ZodString]>;
|
|
72
|
+
/**
|
|
73
|
+
* Schema for skills tool input
|
|
74
|
+
*/
|
|
75
|
+
export declare const SkillsInputSchema: z.ZodObject<{
|
|
76
|
+
skill: z.ZodString;
|
|
77
|
+
args: z.ZodOptional<z.ZodString>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
/**
|
|
80
|
+
* Schema for ask_followup_question tool input
|
|
81
|
+
*/
|
|
82
|
+
export declare const AskQuestionInputSchema: z.ZodObject<{
|
|
83
|
+
question: z.ZodString;
|
|
84
|
+
options: z.ZodArray<z.ZodString>;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
/**
|
|
87
|
+
* Input for the read_files tool
|
|
88
|
+
*/
|
|
89
|
+
export type ReadFilesInput = z.infer<typeof ReadFilesInputSchema>;
|
|
90
|
+
/**
|
|
91
|
+
* Input for the search_codebase tool
|
|
92
|
+
*/
|
|
93
|
+
export type SearchCodebaseInput = z.infer<typeof SearchCodebaseInputSchema>;
|
|
94
|
+
/**
|
|
95
|
+
* Input for the run_commands tool
|
|
96
|
+
*/
|
|
97
|
+
export type RunCommandsInput = z.infer<typeof RunCommandsInputSchema>;
|
|
98
|
+
/**
|
|
99
|
+
* Web fetch request parameters
|
|
100
|
+
*/
|
|
101
|
+
export type WebFetchRequest = z.infer<typeof WebFetchRequestSchema>;
|
|
102
|
+
/**
|
|
103
|
+
* Input for the fetch_web_content tool
|
|
104
|
+
*/
|
|
105
|
+
export type FetchWebContentInput = z.infer<typeof FetchWebContentInputSchema>;
|
|
106
|
+
/**
|
|
107
|
+
* Input for the editor tool
|
|
108
|
+
*/
|
|
109
|
+
export type EditFileInput = z.infer<typeof EditFileInputSchema>;
|
|
110
|
+
/**
|
|
111
|
+
* Input for the apply_patch tool
|
|
112
|
+
*/
|
|
113
|
+
export type ApplyPatchInput = z.infer<typeof ApplyPatchInputSchema>;
|
|
114
|
+
/**
|
|
115
|
+
* Input for the skills tool
|
|
116
|
+
*/
|
|
117
|
+
export type SkillsInput = z.infer<typeof SkillsInputSchema>;
|
|
118
|
+
/**
|
|
119
|
+
* Input for the ask_followup_question tool
|
|
120
|
+
*/
|
|
121
|
+
export type AskQuestionInput = z.infer<typeof AskQuestionInputSchema>;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for Default Tools
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for executors, configuration, and results.
|
|
5
|
+
*/
|
|
6
|
+
import type { ToolContext } from "@clinebot/agents";
|
|
7
|
+
import type { ApplyPatchInput, EditFileInput } from "./schemas";
|
|
8
|
+
/**
|
|
9
|
+
* Result from a single tool operation
|
|
10
|
+
*/
|
|
11
|
+
export interface ToolOperationResult {
|
|
12
|
+
/** The query/input that was executed */
|
|
13
|
+
query: string;
|
|
14
|
+
/** The result content (if successful) */
|
|
15
|
+
result: string;
|
|
16
|
+
/** Error message (if failed) */
|
|
17
|
+
error?: string;
|
|
18
|
+
/** Whether the operation succeeded */
|
|
19
|
+
success: boolean;
|
|
20
|
+
/** Duration in MS */
|
|
21
|
+
duration?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Executor for reading files
|
|
25
|
+
*
|
|
26
|
+
* @param filePath - Absolute path to the file to read
|
|
27
|
+
* @param context - Tool execution context
|
|
28
|
+
* @returns The file content as a string
|
|
29
|
+
*/
|
|
30
|
+
export type FileReadExecutor = (filePath: string, context: ToolContext) => Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Executor for searching the codebase
|
|
33
|
+
*
|
|
34
|
+
* @param query - Regex pattern to search for
|
|
35
|
+
* @param cwd - Current working directory for the search
|
|
36
|
+
* @param context - Tool execution context
|
|
37
|
+
* @returns Search results as a formatted string
|
|
38
|
+
*/
|
|
39
|
+
export type SearchExecutor = (query: string, cwd: string, context: ToolContext) => Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Executor for running shell commands
|
|
42
|
+
*
|
|
43
|
+
* @param command - Shell command to execute
|
|
44
|
+
* @param cwd - Current working directory for execution
|
|
45
|
+
* @param context - Tool execution context
|
|
46
|
+
* @returns Command output (stdout)
|
|
47
|
+
*/
|
|
48
|
+
export type BashExecutor = (command: string, cwd: string, context: ToolContext) => Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Executor for fetching web content
|
|
51
|
+
*
|
|
52
|
+
* @param url - URL to fetch
|
|
53
|
+
* @param prompt - Analysis prompt for the content
|
|
54
|
+
* @param context - Tool execution context
|
|
55
|
+
* @returns Analyzed/extracted content
|
|
56
|
+
*/
|
|
57
|
+
export type WebFetchExecutor = (url: string, prompt: string, context: ToolContext) => Promise<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Executor for editing files
|
|
60
|
+
*
|
|
61
|
+
* @param input - Editor command input
|
|
62
|
+
* @param cwd - Current working directory for filesystem operations
|
|
63
|
+
* @param context - Tool execution context
|
|
64
|
+
* @returns A formatted operation result string
|
|
65
|
+
*/
|
|
66
|
+
export type EditorExecutor = (input: EditFileInput, cwd: string, context: ToolContext) => Promise<string>;
|
|
67
|
+
/**
|
|
68
|
+
* Executor for apply_patch operations
|
|
69
|
+
*
|
|
70
|
+
* @param input - apply_patch command payload
|
|
71
|
+
* @param cwd - Current working directory for filesystem operations
|
|
72
|
+
* @param context - Tool execution context
|
|
73
|
+
* @returns A formatted operation result string
|
|
74
|
+
*/
|
|
75
|
+
export type ApplyPatchExecutor = (input: ApplyPatchInput, cwd: string, context: ToolContext) => Promise<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Executor for invoking configured skills
|
|
78
|
+
*
|
|
79
|
+
* @param skill - Skill name to invoke
|
|
80
|
+
* @param args - Optional arguments for the skill
|
|
81
|
+
* @param context - Tool execution context
|
|
82
|
+
* @returns Skill loading/invocation result
|
|
83
|
+
*/
|
|
84
|
+
export type SkillsExecutor = (skill: string, args: string | undefined, context: ToolContext) => Promise<string>;
|
|
85
|
+
/**
|
|
86
|
+
* Executor for asking a single follow-up question with selectable options
|
|
87
|
+
*
|
|
88
|
+
* @param question - Single clarifying question for the user
|
|
89
|
+
* @param options - 2-5 selectable answer options
|
|
90
|
+
* @param context - Tool execution context
|
|
91
|
+
* @returns Executor-specific result payload
|
|
92
|
+
*/
|
|
93
|
+
export type AskQuestionExecutor = (question: string, options: string[], context: ToolContext) => Promise<string>;
|
|
94
|
+
/**
|
|
95
|
+
* Skill metadata exposed by SkillsExecutor for clients/UI
|
|
96
|
+
*/
|
|
97
|
+
export interface SkillsExecutorSkillMetadata {
|
|
98
|
+
/** Normalized skill id (usually lowercased name) */
|
|
99
|
+
id: string;
|
|
100
|
+
/** Display name for the skill */
|
|
101
|
+
name: string;
|
|
102
|
+
/** Optional short description */
|
|
103
|
+
description?: string;
|
|
104
|
+
/** True when configured but intentionally disabled */
|
|
105
|
+
disabled: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A callable executor that can also expose configured skill metadata.
|
|
109
|
+
*/
|
|
110
|
+
export interface SkillsExecutorWithMetadata {
|
|
111
|
+
(skill: string, args: string | undefined, context: ToolContext): Promise<string>;
|
|
112
|
+
configuredSkills?: SkillsExecutorSkillMetadata[];
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Collection of all tool executors
|
|
116
|
+
*/
|
|
117
|
+
export interface ToolExecutors {
|
|
118
|
+
/** File reading implementation */
|
|
119
|
+
readFile?: FileReadExecutor;
|
|
120
|
+
/** Codebase search implementation */
|
|
121
|
+
search?: SearchExecutor;
|
|
122
|
+
/** Shell command execution implementation */
|
|
123
|
+
bash?: BashExecutor;
|
|
124
|
+
/** Web content fetching implementation */
|
|
125
|
+
webFetch?: WebFetchExecutor;
|
|
126
|
+
/** Filesystem editor implementation */
|
|
127
|
+
editor?: EditorExecutor;
|
|
128
|
+
/** Apply patch implementation */
|
|
129
|
+
applyPatch?: ApplyPatchExecutor;
|
|
130
|
+
/** Skill invocation implementation */
|
|
131
|
+
skills?: SkillsExecutorWithMetadata;
|
|
132
|
+
/** Follow-up question implementation */
|
|
133
|
+
askQuestion?: AskQuestionExecutor;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Names of available default tools
|
|
137
|
+
*/
|
|
138
|
+
export type DefaultToolName = "read_files" | "search_codebase" | "run_commands" | "fetch_web_content" | "apply_patch" | "editor" | "skills" | "ask_question";
|
|
139
|
+
/**
|
|
140
|
+
* Configuration for enabling/disabling default tools
|
|
141
|
+
*/
|
|
142
|
+
export interface DefaultToolsConfig {
|
|
143
|
+
/**
|
|
144
|
+
* Enable the read_files tool
|
|
145
|
+
* @default true
|
|
146
|
+
*/
|
|
147
|
+
enableReadFiles?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Enable the search_codebase tool
|
|
150
|
+
* @default true
|
|
151
|
+
*/
|
|
152
|
+
enableSearch?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Enable the run_commands tool
|
|
155
|
+
* @default true
|
|
156
|
+
*/
|
|
157
|
+
enableBash?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Enable the fetch_web_content tool
|
|
160
|
+
* @default true
|
|
161
|
+
*/
|
|
162
|
+
enableWebFetch?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Enable the apply_patch tool
|
|
165
|
+
* @default true
|
|
166
|
+
*/
|
|
167
|
+
enableApplyPatch?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Enable the editor tool
|
|
170
|
+
* @default true
|
|
171
|
+
*/
|
|
172
|
+
enableEditor?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Enable the skills tool
|
|
175
|
+
* @default true
|
|
176
|
+
*/
|
|
177
|
+
enableSkills?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Enable the ask_followup_question tool
|
|
180
|
+
* @default true
|
|
181
|
+
*/
|
|
182
|
+
enableAskQuestion?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Current working directory for tools that need it
|
|
185
|
+
*/
|
|
186
|
+
cwd?: string;
|
|
187
|
+
/**
|
|
188
|
+
* Timeout for file read operations in milliseconds
|
|
189
|
+
* @default 10000
|
|
190
|
+
*/
|
|
191
|
+
fileReadTimeoutMs?: number;
|
|
192
|
+
/**
|
|
193
|
+
* Timeout for bash command execution in milliseconds
|
|
194
|
+
* @default 30000
|
|
195
|
+
*/
|
|
196
|
+
bashTimeoutMs?: number;
|
|
197
|
+
/**
|
|
198
|
+
* Timeout for web fetch operations in milliseconds
|
|
199
|
+
* @default 30000
|
|
200
|
+
*/
|
|
201
|
+
webFetchTimeoutMs?: number;
|
|
202
|
+
/**
|
|
203
|
+
* Timeout for search operations in milliseconds
|
|
204
|
+
* @default 30000
|
|
205
|
+
*/
|
|
206
|
+
searchTimeoutMs?: number;
|
|
207
|
+
/**
|
|
208
|
+
* Timeout for apply_patch operations in milliseconds
|
|
209
|
+
* @default 30000
|
|
210
|
+
*/
|
|
211
|
+
applyPatchTimeoutMs?: number;
|
|
212
|
+
/**
|
|
213
|
+
* Timeout for editor operations in milliseconds
|
|
214
|
+
* @default 30000
|
|
215
|
+
*/
|
|
216
|
+
editorTimeoutMs?: number;
|
|
217
|
+
/**
|
|
218
|
+
* Timeout for skills operations in milliseconds
|
|
219
|
+
* @default 15000
|
|
220
|
+
*/
|
|
221
|
+
skillsTimeoutMs?: number;
|
|
222
|
+
/**
|
|
223
|
+
* Timeout for ask_followup_question operations in milliseconds
|
|
224
|
+
* @default 15000
|
|
225
|
+
*/
|
|
226
|
+
askQuestionTimeoutMs?: number;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Options for creating default tools
|
|
230
|
+
*/
|
|
231
|
+
export interface CreateDefaultToolsOptions extends DefaultToolsConfig {
|
|
232
|
+
/**
|
|
233
|
+
* Executor implementations for the tools
|
|
234
|
+
* Only tools with provided executors will be available
|
|
235
|
+
*/
|
|
236
|
+
executors: ToolExecutors;
|
|
237
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @clinebot/core
|
|
3
|
+
*
|
|
4
|
+
* Runtime-agnostic core contracts and shared state utilities.
|
|
5
|
+
*/
|
|
6
|
+
export { type ClineAccountBalance, type ClineAccountOperations, type ClineAccountOrganization, type ClineAccountOrganizationBalance, type ClineAccountOrganizationUsageTransaction, type ClineAccountPaymentTransaction, ClineAccountService, type ClineAccountServiceOptions, type ClineAccountUsageTransaction, type ClineAccountUser, executeRpcClineAccountAction, isRpcClineAccountActionRequest, RpcClineAccountService, type RpcProviderActionExecutor, } from "./account";
|
|
7
|
+
export type { ChatMessage, ChatSessionConfig, ChatSessionStatus, ChatSummary, ChatViewState, } from "./chat/chat-schema";
|
|
8
|
+
export { ChatMessageRoleSchema, ChatMessageSchema, ChatSessionConfigSchema, ChatSessionStatusSchema, ChatSummarySchema, ChatViewStateSchema, } from "./chat/chat-schema";
|
|
9
|
+
export { ALL_DEFAULT_TOOL_NAMES, type AskQuestionExecutor, type CreateBuiltinToolsOptions, type CreateDefaultToolsOptions, createBuiltinTools, createDefaultExecutors, createDefaultTools, createDefaultToolsWithPreset, createToolPoliciesWithPreset, type DefaultExecutorsOptions, type DefaultToolName, DefaultToolNames, type DefaultToolsConfig, type ToolExecutors, type ToolPolicyPresetName, type ToolPresetName, ToolPresets, } from "./default-tools";
|
|
10
|
+
export { hasMcpSettingsFile, InMemoryMcpManager, type LoadMcpSettingsOptions, loadMcpSettingsFile, type McpConnectionStatus, type McpManager, type McpManagerOptions, type McpServerClient, type McpServerClientFactory, type McpServerRegistration, type McpServerSnapshot, type McpServerTransportConfig, type McpSettingsFile, type McpSseTransportConfig, type McpStdioTransportConfig, type McpStreamableHttpTransportConfig, type RegisterMcpServersFromSettingsOptions, registerMcpServersFromSettingsFile, resolveDefaultMcpSettingsPath, resolveMcpServerRegistrations, } from "./mcp";
|
|
11
|
+
export { ProviderSettingsManager } from "./storage/provider-settings-manager";
|
|
12
|
+
export { SqliteTeamStore, type SqliteTeamStoreOptions, } from "./storage/team-store";
|
|
13
|
+
export { buildTeamProgressSummary, toTeamProgressLifecycleEvent, } from "./team";
|
|
14
|
+
export type { RuntimeEnvironment, SessionEvent, StoredMessages } from "./types";
|
|
15
|
+
export type { SessionStatus } from "./types/common";
|
|
16
|
+
export { SESSION_STATUSES, SessionSource } from "./types/common";
|
|
17
|
+
export type { CoreAgentMode, CoreModelConfig, CoreRuntimeFeatures, CoreSessionConfig, } from "./types/config";
|
|
18
|
+
export type { CoreSessionEvent, SessionChunkEvent, SessionEndedEvent, SessionTeamProgressEvent, SessionToolEvent, } from "./types/events";
|
|
19
|
+
export type { ProviderTokenSource, StoredProviderSettings, StoredProviderSettingsEntry, } from "./types/provider-settings";
|
|
20
|
+
export { emptyStoredProviderSettings, StoredProviderSettingsEntrySchema, StoredProviderSettingsSchema, } from "./types/provider-settings";
|
|
21
|
+
export type { SessionRecord, SessionRef } from "./types/sessions";
|
|
22
|
+
export type { ArtifactStore, SessionStore, TeamStore } from "./types/storage";
|
|
23
|
+
export type { WorkspaceInfo } from "./types/workspace";
|