@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,228 @@
|
|
|
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
|
+
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Schema for read tool input
|
|
12
|
+
*/
|
|
13
|
+
const AbsolutePath = z
|
|
14
|
+
.string()
|
|
15
|
+
.describe("The absolute file path of a text file to read content from");
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Schema for read_files tool input
|
|
19
|
+
*/
|
|
20
|
+
export const ReadFilesInputSchema = z.object({
|
|
21
|
+
file_paths: z.array(AbsolutePath).describe("Array of absolute file paths"),
|
|
22
|
+
});
|
|
23
|
+
export const ReadFilesInputUnionSchema = z.union([
|
|
24
|
+
ReadFilesInputSchema,
|
|
25
|
+
z.array(z.string()),
|
|
26
|
+
z.string(),
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Schema for search_codebase tool input
|
|
31
|
+
*/
|
|
32
|
+
export const SearchCodebaseInputSchema = z.object({
|
|
33
|
+
queries: z
|
|
34
|
+
.array(z.string())
|
|
35
|
+
.describe("Array of regex search queries to execute"),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const CommandInputSchema = z.string();
|
|
39
|
+
/**
|
|
40
|
+
* Schema for run_commands tool input
|
|
41
|
+
*/
|
|
42
|
+
export const RunCommandsInputSchema = z.object({
|
|
43
|
+
commands: z
|
|
44
|
+
.array(CommandInputSchema)
|
|
45
|
+
.describe("Array of shell commands to execute"),
|
|
46
|
+
});
|
|
47
|
+
export const RunCommandsInputUnionSchema = z.union([
|
|
48
|
+
RunCommandsInputSchema,
|
|
49
|
+
z.array(CommandInputSchema),
|
|
50
|
+
CommandInputSchema,
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Schema for a single web fetch request
|
|
55
|
+
*/
|
|
56
|
+
export const WebFetchRequestSchema = z.object({
|
|
57
|
+
url: z.url().describe("The URL to fetch"),
|
|
58
|
+
prompt: z.string().min(2).describe("Analysis prompt for the fetched content"),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Schema for fetch_web_content tool input
|
|
63
|
+
*/
|
|
64
|
+
export const FetchWebContentInputSchema = z.object({
|
|
65
|
+
requests: z
|
|
66
|
+
.array(WebFetchRequestSchema)
|
|
67
|
+
.describe("Array of web fetch requests"),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Schema for editor tool input
|
|
72
|
+
*/
|
|
73
|
+
export const EditFileInputSchema = z
|
|
74
|
+
.object({
|
|
75
|
+
command: z
|
|
76
|
+
.enum(["create", "str_replace", "insert"])
|
|
77
|
+
.describe(
|
|
78
|
+
"Editor command to execute: create, str_replace, insert, or undo_edit",
|
|
79
|
+
),
|
|
80
|
+
path: z.string().min(1).describe("Absolute file path"),
|
|
81
|
+
file_text: z
|
|
82
|
+
.string()
|
|
83
|
+
.optional()
|
|
84
|
+
.describe("Full file content used with create"),
|
|
85
|
+
old_str: z
|
|
86
|
+
.string()
|
|
87
|
+
.optional()
|
|
88
|
+
.describe("Exact text to replace (must match exactly once)"),
|
|
89
|
+
new_str: z.string().optional().describe("Replacement or inserted text"),
|
|
90
|
+
insert_line: z
|
|
91
|
+
.number()
|
|
92
|
+
.int()
|
|
93
|
+
.optional()
|
|
94
|
+
.describe("Zero-based line index for insert"),
|
|
95
|
+
})
|
|
96
|
+
.superRefine((value, ctx) => {
|
|
97
|
+
switch (value.command) {
|
|
98
|
+
case "create":
|
|
99
|
+
if (value.file_text === undefined) {
|
|
100
|
+
ctx.addIssue({
|
|
101
|
+
code: z.ZodIssueCode.custom,
|
|
102
|
+
path: ["file_text"],
|
|
103
|
+
message: "file_text is required for command=create",
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case "str_replace":
|
|
108
|
+
if (value.old_str === undefined) {
|
|
109
|
+
ctx.addIssue({
|
|
110
|
+
code: z.ZodIssueCode.custom,
|
|
111
|
+
path: ["old_str"],
|
|
112
|
+
message: "old_str is required for command=str_replace",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
case "insert":
|
|
117
|
+
if (value.insert_line === undefined) {
|
|
118
|
+
ctx.addIssue({
|
|
119
|
+
code: z.ZodIssueCode.custom,
|
|
120
|
+
path: ["insert_line"],
|
|
121
|
+
message: "insert_line is required for command=insert",
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (value.new_str === undefined) {
|
|
125
|
+
ctx.addIssue({
|
|
126
|
+
code: z.ZodIssueCode.custom,
|
|
127
|
+
path: ["new_str"],
|
|
128
|
+
message: "new_str is required for command=insert",
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Schema for apply_patch tool input
|
|
137
|
+
*/
|
|
138
|
+
export const ApplyPatchInputSchema = z.object({
|
|
139
|
+
input: z
|
|
140
|
+
.string()
|
|
141
|
+
.min(1)
|
|
142
|
+
.describe("The apply_patch text payload, including patch instructions"),
|
|
143
|
+
});
|
|
144
|
+
export const ApplyPatchInputUnionSchema = z.union([
|
|
145
|
+
ApplyPatchInputSchema,
|
|
146
|
+
z.string(),
|
|
147
|
+
]);
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Schema for skills tool input
|
|
151
|
+
*/
|
|
152
|
+
export const SkillsInputSchema = z.object({
|
|
153
|
+
skill: z
|
|
154
|
+
.string()
|
|
155
|
+
.min(1)
|
|
156
|
+
.describe(
|
|
157
|
+
'The skill name. E.g., "commit", "review-pr", "pdf", or "ms-office-suite:pdf"',
|
|
158
|
+
),
|
|
159
|
+
args: z.string().optional().describe("Optional arguments for the skill"),
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Schema for ask_followup_question tool input
|
|
164
|
+
*/
|
|
165
|
+
export const AskQuestionInputSchema = z.object({
|
|
166
|
+
question: z
|
|
167
|
+
.string()
|
|
168
|
+
.min(1)
|
|
169
|
+
.describe(
|
|
170
|
+
'The single question to ask the user. E.g. "How can I help you?"',
|
|
171
|
+
),
|
|
172
|
+
options: z
|
|
173
|
+
.array(z.string().min(1))
|
|
174
|
+
.min(2)
|
|
175
|
+
.max(5)
|
|
176
|
+
.describe(
|
|
177
|
+
"Array of 2-5 user-selectable answer options for the single question",
|
|
178
|
+
),
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// =============================================================================
|
|
182
|
+
// Type Definitions (derived from Zod schemas)
|
|
183
|
+
// =============================================================================
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Input for the read_files tool
|
|
187
|
+
*/
|
|
188
|
+
export type ReadFilesInput = z.infer<typeof ReadFilesInputSchema>;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Input for the search_codebase tool
|
|
192
|
+
*/
|
|
193
|
+
export type SearchCodebaseInput = z.infer<typeof SearchCodebaseInputSchema>;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Input for the run_commands tool
|
|
197
|
+
*/
|
|
198
|
+
export type RunCommandsInput = z.infer<typeof RunCommandsInputSchema>;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Web fetch request parameters
|
|
202
|
+
*/
|
|
203
|
+
export type WebFetchRequest = z.infer<typeof WebFetchRequestSchema>;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Input for the fetch_web_content tool
|
|
207
|
+
*/
|
|
208
|
+
export type FetchWebContentInput = z.infer<typeof FetchWebContentInputSchema>;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Input for the editor tool
|
|
212
|
+
*/
|
|
213
|
+
export type EditFileInput = z.infer<typeof EditFileInputSchema>;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Input for the apply_patch tool
|
|
217
|
+
*/
|
|
218
|
+
export type ApplyPatchInput = z.infer<typeof ApplyPatchInputSchema>;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Input for the skills tool
|
|
222
|
+
*/
|
|
223
|
+
export type SkillsInput = z.infer<typeof SkillsInputSchema>;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Input for the ask_followup_question tool
|
|
227
|
+
*/
|
|
228
|
+
export type AskQuestionInput = z.infer<typeof AskQuestionInputSchema>;
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for Default Tools
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for executors, configuration, and results.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ToolContext } from "@clinebot/agents";
|
|
8
|
+
import type { ApplyPatchInput, EditFileInput } from "./schemas";
|
|
9
|
+
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// Tool Result Types
|
|
12
|
+
// =============================================================================
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Result from a single tool operation
|
|
16
|
+
*/
|
|
17
|
+
export interface ToolOperationResult {
|
|
18
|
+
/** The query/input that was executed */
|
|
19
|
+
query: string;
|
|
20
|
+
/** The result content (if successful) */
|
|
21
|
+
result: string;
|
|
22
|
+
/** Error message (if failed) */
|
|
23
|
+
error?: string;
|
|
24
|
+
/** Whether the operation succeeded */
|
|
25
|
+
success: boolean;
|
|
26
|
+
/** Duration in MS */
|
|
27
|
+
duration?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// =============================================================================
|
|
31
|
+
// Executor Interfaces
|
|
32
|
+
// =============================================================================
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Executor for reading files
|
|
36
|
+
*
|
|
37
|
+
* @param filePath - Absolute path to the file to read
|
|
38
|
+
* @param context - Tool execution context
|
|
39
|
+
* @returns The file content as a string
|
|
40
|
+
*/
|
|
41
|
+
export type FileReadExecutor = (
|
|
42
|
+
filePath: string,
|
|
43
|
+
context: ToolContext,
|
|
44
|
+
) => Promise<string>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Executor for searching the codebase
|
|
48
|
+
*
|
|
49
|
+
* @param query - Regex pattern to search for
|
|
50
|
+
* @param cwd - Current working directory for the search
|
|
51
|
+
* @param context - Tool execution context
|
|
52
|
+
* @returns Search results as a formatted string
|
|
53
|
+
*/
|
|
54
|
+
export type SearchExecutor = (
|
|
55
|
+
query: string,
|
|
56
|
+
cwd: string,
|
|
57
|
+
context: ToolContext,
|
|
58
|
+
) => Promise<string>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Executor for running shell commands
|
|
62
|
+
*
|
|
63
|
+
* @param command - Shell command to execute
|
|
64
|
+
* @param cwd - Current working directory for execution
|
|
65
|
+
* @param context - Tool execution context
|
|
66
|
+
* @returns Command output (stdout)
|
|
67
|
+
*/
|
|
68
|
+
export type BashExecutor = (
|
|
69
|
+
command: string,
|
|
70
|
+
cwd: string,
|
|
71
|
+
context: ToolContext,
|
|
72
|
+
) => Promise<string>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Executor for fetching web content
|
|
76
|
+
*
|
|
77
|
+
* @param url - URL to fetch
|
|
78
|
+
* @param prompt - Analysis prompt for the content
|
|
79
|
+
* @param context - Tool execution context
|
|
80
|
+
* @returns Analyzed/extracted content
|
|
81
|
+
*/
|
|
82
|
+
export type WebFetchExecutor = (
|
|
83
|
+
url: string,
|
|
84
|
+
prompt: string,
|
|
85
|
+
context: ToolContext,
|
|
86
|
+
) => Promise<string>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Executor for editing files
|
|
90
|
+
*
|
|
91
|
+
* @param input - Editor command input
|
|
92
|
+
* @param cwd - Current working directory for filesystem operations
|
|
93
|
+
* @param context - Tool execution context
|
|
94
|
+
* @returns A formatted operation result string
|
|
95
|
+
*/
|
|
96
|
+
export type EditorExecutor = (
|
|
97
|
+
input: EditFileInput,
|
|
98
|
+
cwd: string,
|
|
99
|
+
context: ToolContext,
|
|
100
|
+
) => Promise<string>;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Executor for apply_patch operations
|
|
104
|
+
*
|
|
105
|
+
* @param input - apply_patch command payload
|
|
106
|
+
* @param cwd - Current working directory for filesystem operations
|
|
107
|
+
* @param context - Tool execution context
|
|
108
|
+
* @returns A formatted operation result string
|
|
109
|
+
*/
|
|
110
|
+
export type ApplyPatchExecutor = (
|
|
111
|
+
input: ApplyPatchInput,
|
|
112
|
+
cwd: string,
|
|
113
|
+
context: ToolContext,
|
|
114
|
+
) => Promise<string>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Executor for invoking configured skills
|
|
118
|
+
*
|
|
119
|
+
* @param skill - Skill name to invoke
|
|
120
|
+
* @param args - Optional arguments for the skill
|
|
121
|
+
* @param context - Tool execution context
|
|
122
|
+
* @returns Skill loading/invocation result
|
|
123
|
+
*/
|
|
124
|
+
export type SkillsExecutor = (
|
|
125
|
+
skill: string,
|
|
126
|
+
args: string | undefined,
|
|
127
|
+
context: ToolContext,
|
|
128
|
+
) => Promise<string>;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Executor for asking a single follow-up question with selectable options
|
|
132
|
+
*
|
|
133
|
+
* @param question - Single clarifying question for the user
|
|
134
|
+
* @param options - 2-5 selectable answer options
|
|
135
|
+
* @param context - Tool execution context
|
|
136
|
+
* @returns Executor-specific result payload
|
|
137
|
+
*/
|
|
138
|
+
export type AskQuestionExecutor = (
|
|
139
|
+
question: string,
|
|
140
|
+
options: string[],
|
|
141
|
+
context: ToolContext,
|
|
142
|
+
) => Promise<string>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Skill metadata exposed by SkillsExecutor for clients/UI
|
|
146
|
+
*/
|
|
147
|
+
export interface SkillsExecutorSkillMetadata {
|
|
148
|
+
/** Normalized skill id (usually lowercased name) */
|
|
149
|
+
id: string;
|
|
150
|
+
/** Display name for the skill */
|
|
151
|
+
name: string;
|
|
152
|
+
/** Optional short description */
|
|
153
|
+
description?: string;
|
|
154
|
+
/** True when configured but intentionally disabled */
|
|
155
|
+
disabled: boolean;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* A callable executor that can also expose configured skill metadata.
|
|
160
|
+
*/
|
|
161
|
+
export interface SkillsExecutorWithMetadata {
|
|
162
|
+
(
|
|
163
|
+
skill: string,
|
|
164
|
+
args: string | undefined,
|
|
165
|
+
context: ToolContext,
|
|
166
|
+
): Promise<string>;
|
|
167
|
+
configuredSkills?: SkillsExecutorSkillMetadata[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Collection of all tool executors
|
|
172
|
+
*/
|
|
173
|
+
export interface ToolExecutors {
|
|
174
|
+
/** File reading implementation */
|
|
175
|
+
readFile?: FileReadExecutor;
|
|
176
|
+
/** Codebase search implementation */
|
|
177
|
+
search?: SearchExecutor;
|
|
178
|
+
/** Shell command execution implementation */
|
|
179
|
+
bash?: BashExecutor;
|
|
180
|
+
/** Web content fetching implementation */
|
|
181
|
+
webFetch?: WebFetchExecutor;
|
|
182
|
+
/** Filesystem editor implementation */
|
|
183
|
+
editor?: EditorExecutor;
|
|
184
|
+
/** Apply patch implementation */
|
|
185
|
+
applyPatch?: ApplyPatchExecutor;
|
|
186
|
+
/** Skill invocation implementation */
|
|
187
|
+
skills?: SkillsExecutorWithMetadata;
|
|
188
|
+
/** Follow-up question implementation */
|
|
189
|
+
askQuestion?: AskQuestionExecutor;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// =============================================================================
|
|
193
|
+
// Tool Configuration
|
|
194
|
+
// =============================================================================
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Names of available default tools
|
|
198
|
+
*/
|
|
199
|
+
export type DefaultToolName =
|
|
200
|
+
| "read_files"
|
|
201
|
+
| "search_codebase"
|
|
202
|
+
| "run_commands"
|
|
203
|
+
| "fetch_web_content"
|
|
204
|
+
| "apply_patch"
|
|
205
|
+
| "editor"
|
|
206
|
+
| "skills"
|
|
207
|
+
| "ask_question";
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Configuration for enabling/disabling default tools
|
|
211
|
+
*/
|
|
212
|
+
export interface DefaultToolsConfig {
|
|
213
|
+
/**
|
|
214
|
+
* Enable the read_files tool
|
|
215
|
+
* @default true
|
|
216
|
+
*/
|
|
217
|
+
enableReadFiles?: boolean;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Enable the search_codebase tool
|
|
221
|
+
* @default true
|
|
222
|
+
*/
|
|
223
|
+
enableSearch?: boolean;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Enable the run_commands tool
|
|
227
|
+
* @default true
|
|
228
|
+
*/
|
|
229
|
+
enableBash?: boolean;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Enable the fetch_web_content tool
|
|
233
|
+
* @default true
|
|
234
|
+
*/
|
|
235
|
+
enableWebFetch?: boolean;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Enable the apply_patch tool
|
|
239
|
+
* @default true
|
|
240
|
+
*/
|
|
241
|
+
enableApplyPatch?: boolean;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Enable the editor tool
|
|
245
|
+
* @default true
|
|
246
|
+
*/
|
|
247
|
+
enableEditor?: boolean;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Enable the skills tool
|
|
251
|
+
* @default true
|
|
252
|
+
*/
|
|
253
|
+
enableSkills?: boolean;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Enable the ask_followup_question tool
|
|
257
|
+
* @default true
|
|
258
|
+
*/
|
|
259
|
+
enableAskQuestion?: boolean;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Current working directory for tools that need it
|
|
263
|
+
*/
|
|
264
|
+
cwd?: string;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Timeout for file read operations in milliseconds
|
|
268
|
+
* @default 10000
|
|
269
|
+
*/
|
|
270
|
+
fileReadTimeoutMs?: number;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Timeout for bash command execution in milliseconds
|
|
274
|
+
* @default 30000
|
|
275
|
+
*/
|
|
276
|
+
bashTimeoutMs?: number;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Timeout for web fetch operations in milliseconds
|
|
280
|
+
* @default 30000
|
|
281
|
+
*/
|
|
282
|
+
webFetchTimeoutMs?: number;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Timeout for search operations in milliseconds
|
|
286
|
+
* @default 30000
|
|
287
|
+
*/
|
|
288
|
+
searchTimeoutMs?: number;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Timeout for apply_patch operations in milliseconds
|
|
292
|
+
* @default 30000
|
|
293
|
+
*/
|
|
294
|
+
applyPatchTimeoutMs?: number;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Timeout for editor operations in milliseconds
|
|
298
|
+
* @default 30000
|
|
299
|
+
*/
|
|
300
|
+
editorTimeoutMs?: number;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Timeout for skills operations in milliseconds
|
|
304
|
+
* @default 15000
|
|
305
|
+
*/
|
|
306
|
+
skillsTimeoutMs?: number;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Timeout for ask_followup_question operations in milliseconds
|
|
310
|
+
* @default 15000
|
|
311
|
+
*/
|
|
312
|
+
askQuestionTimeoutMs?: number;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Options for creating default tools
|
|
317
|
+
*/
|
|
318
|
+
export interface CreateDefaultToolsOptions extends DefaultToolsConfig {
|
|
319
|
+
/**
|
|
320
|
+
* Executor implementations for the tools
|
|
321
|
+
* Only tools with provided executors will be available
|
|
322
|
+
*/
|
|
323
|
+
executors: ToolExecutors;
|
|
324
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @clinebot/core
|
|
3
|
+
*
|
|
4
|
+
* Runtime-agnostic core contracts and shared state utilities.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
type ClineAccountBalance,
|
|
9
|
+
type ClineAccountOperations,
|
|
10
|
+
type ClineAccountOrganization,
|
|
11
|
+
type ClineAccountOrganizationBalance,
|
|
12
|
+
type ClineAccountOrganizationUsageTransaction,
|
|
13
|
+
type ClineAccountPaymentTransaction,
|
|
14
|
+
ClineAccountService,
|
|
15
|
+
type ClineAccountServiceOptions,
|
|
16
|
+
type ClineAccountUsageTransaction,
|
|
17
|
+
type ClineAccountUser,
|
|
18
|
+
executeRpcClineAccountAction,
|
|
19
|
+
isRpcClineAccountActionRequest,
|
|
20
|
+
RpcClineAccountService,
|
|
21
|
+
type RpcProviderActionExecutor,
|
|
22
|
+
} from "./account";
|
|
23
|
+
export type {
|
|
24
|
+
ChatMessage,
|
|
25
|
+
ChatSessionConfig,
|
|
26
|
+
ChatSessionStatus,
|
|
27
|
+
ChatSummary,
|
|
28
|
+
ChatViewState,
|
|
29
|
+
} from "./chat/chat-schema";
|
|
30
|
+
export {
|
|
31
|
+
ChatMessageRoleSchema,
|
|
32
|
+
ChatMessageSchema,
|
|
33
|
+
ChatSessionConfigSchema,
|
|
34
|
+
ChatSessionStatusSchema,
|
|
35
|
+
ChatSummarySchema,
|
|
36
|
+
ChatViewStateSchema,
|
|
37
|
+
} from "./chat/chat-schema";
|
|
38
|
+
export {
|
|
39
|
+
ALL_DEFAULT_TOOL_NAMES,
|
|
40
|
+
type AskQuestionExecutor,
|
|
41
|
+
type CreateBuiltinToolsOptions,
|
|
42
|
+
type CreateDefaultToolsOptions,
|
|
43
|
+
createBuiltinTools,
|
|
44
|
+
createDefaultExecutors,
|
|
45
|
+
createDefaultTools,
|
|
46
|
+
createDefaultToolsWithPreset,
|
|
47
|
+
createToolPoliciesWithPreset,
|
|
48
|
+
type DefaultExecutorsOptions,
|
|
49
|
+
type DefaultToolName,
|
|
50
|
+
DefaultToolNames,
|
|
51
|
+
type DefaultToolsConfig,
|
|
52
|
+
type ToolExecutors,
|
|
53
|
+
type ToolPolicyPresetName,
|
|
54
|
+
type ToolPresetName,
|
|
55
|
+
ToolPresets,
|
|
56
|
+
} from "./default-tools";
|
|
57
|
+
export {
|
|
58
|
+
hasMcpSettingsFile,
|
|
59
|
+
InMemoryMcpManager,
|
|
60
|
+
type LoadMcpSettingsOptions,
|
|
61
|
+
loadMcpSettingsFile,
|
|
62
|
+
type McpConnectionStatus,
|
|
63
|
+
type McpManager,
|
|
64
|
+
type McpManagerOptions,
|
|
65
|
+
type McpServerClient,
|
|
66
|
+
type McpServerClientFactory,
|
|
67
|
+
type McpServerRegistration,
|
|
68
|
+
type McpServerSnapshot,
|
|
69
|
+
type McpServerTransportConfig,
|
|
70
|
+
type McpSettingsFile,
|
|
71
|
+
type McpSseTransportConfig,
|
|
72
|
+
type McpStdioTransportConfig,
|
|
73
|
+
type McpStreamableHttpTransportConfig,
|
|
74
|
+
type RegisterMcpServersFromSettingsOptions,
|
|
75
|
+
registerMcpServersFromSettingsFile,
|
|
76
|
+
resolveDefaultMcpSettingsPath,
|
|
77
|
+
resolveMcpServerRegistrations,
|
|
78
|
+
} from "./mcp";
|
|
79
|
+
|
|
80
|
+
export { ProviderSettingsManager } from "./storage/provider-settings-manager";
|
|
81
|
+
export {
|
|
82
|
+
SqliteTeamStore,
|
|
83
|
+
type SqliteTeamStoreOptions,
|
|
84
|
+
} from "./storage/team-store";
|
|
85
|
+
export {
|
|
86
|
+
buildTeamProgressSummary,
|
|
87
|
+
toTeamProgressLifecycleEvent,
|
|
88
|
+
} from "./team";
|
|
89
|
+
|
|
90
|
+
// Compatibility barrel (legacy imports).
|
|
91
|
+
export type { RuntimeEnvironment, SessionEvent, StoredMessages } from "./types";
|
|
92
|
+
export type { SessionStatus } from "./types/common";
|
|
93
|
+
export { SESSION_STATUSES, SessionSource } from "./types/common";
|
|
94
|
+
export type {
|
|
95
|
+
CoreAgentMode,
|
|
96
|
+
CoreModelConfig,
|
|
97
|
+
CoreRuntimeFeatures,
|
|
98
|
+
CoreSessionConfig,
|
|
99
|
+
} from "./types/config";
|
|
100
|
+
export type {
|
|
101
|
+
CoreSessionEvent,
|
|
102
|
+
SessionChunkEvent,
|
|
103
|
+
SessionEndedEvent,
|
|
104
|
+
SessionTeamProgressEvent,
|
|
105
|
+
SessionToolEvent,
|
|
106
|
+
} from "./types/events";
|
|
107
|
+
export type {
|
|
108
|
+
ProviderTokenSource,
|
|
109
|
+
StoredProviderSettings,
|
|
110
|
+
StoredProviderSettingsEntry,
|
|
111
|
+
} from "./types/provider-settings";
|
|
112
|
+
export {
|
|
113
|
+
emptyStoredProviderSettings,
|
|
114
|
+
StoredProviderSettingsEntrySchema,
|
|
115
|
+
StoredProviderSettingsSchema,
|
|
116
|
+
} from "./types/provider-settings";
|
|
117
|
+
export type { SessionRecord, SessionRef } from "./types/sessions";
|
|
118
|
+
export type { ArtifactStore, SessionStore, TeamStore } from "./types/storage";
|
|
119
|
+
export type { WorkspaceInfo } from "./types/workspace";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface FastFileIndexOptions {
|
|
2
|
+
ttlMs?: number;
|
|
3
|
+
}
|
|
4
|
+
export declare function getFileIndex(
|
|
5
|
+
cwd: string,
|
|
6
|
+
options?: FastFileIndexOptions,
|
|
7
|
+
): Promise<Set<string>>;
|
|
8
|
+
export declare function prewarmFileIndex(
|
|
9
|
+
cwd: string,
|
|
10
|
+
options?: FastFileIndexOptions,
|
|
11
|
+
): Promise<void>;
|