@clinebot/core 0.0.22 → 0.0.23
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/dist/ClineCore.d.ts +110 -0
- package/dist/ClineCore.d.ts.map +1 -0
- package/dist/account/cline-account-service.d.ts +2 -1
- package/dist/account/cline-account-service.d.ts.map +1 -1
- package/dist/account/index.d.ts +1 -1
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/rpc.d.ts +3 -1
- package/dist/account/rpc.d.ts.map +1 -1
- package/dist/account/types.d.ts +3 -0
- package/dist/account/types.d.ts.map +1 -1
- package/dist/agents/plugin-loader.d.ts.map +1 -1
- package/dist/agents/plugin-sandbox-bootstrap.js +17 -17
- package/dist/auth/client.d.ts +1 -1
- package/dist/auth/client.d.ts.map +1 -1
- package/dist/auth/cline.d.ts +1 -1
- package/dist/auth/cline.d.ts.map +1 -1
- package/dist/auth/codex.d.ts +1 -1
- package/dist/auth/codex.d.ts.map +1 -1
- package/dist/auth/oca.d.ts +1 -1
- package/dist/auth/oca.d.ts.map +1 -1
- package/dist/auth/utils.d.ts +2 -2
- package/dist/auth/utils.d.ts.map +1 -1
- package/dist/index.d.ts +50 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +949 -0
- package/dist/providers/local-provider-service.d.ts +4 -4
- package/dist/providers/local-provider-service.d.ts.map +1 -1
- package/dist/runtime/runtime-builder.d.ts +1 -0
- package/dist/runtime/runtime-builder.d.ts.map +1 -1
- package/dist/runtime/session-runtime.d.ts +2 -1
- package/dist/runtime/session-runtime.d.ts.map +1 -1
- package/dist/runtime/team-runtime-registry.d.ts +13 -0
- package/dist/runtime/team-runtime-registry.d.ts.map +1 -0
- package/dist/session/default-session-manager.d.ts +2 -2
- package/dist/session/default-session-manager.d.ts.map +1 -1
- package/dist/session/rpc-runtime-ensure.d.ts +53 -0
- package/dist/session/rpc-runtime-ensure.d.ts.map +1 -0
- package/dist/session/session-config-builder.d.ts +2 -3
- package/dist/session/session-config-builder.d.ts.map +1 -1
- package/dist/session/session-host.d.ts +8 -18
- package/dist/session/session-host.d.ts.map +1 -1
- package/dist/session/session-manager.d.ts +1 -1
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manifest.d.ts +1 -2
- package/dist/session/session-manifest.d.ts.map +1 -1
- package/dist/session/unified-session-persistence-service.d.ts +2 -2
- package/dist/session/unified-session-persistence-service.d.ts.map +1 -1
- package/dist/session/utils/helpers.d.ts +1 -1
- package/dist/session/utils/helpers.d.ts.map +1 -1
- package/dist/session/utils/types.d.ts +1 -1
- package/dist/session/utils/types.d.ts.map +1 -1
- package/dist/storage/provider-settings-legacy-migration.d.ts.map +1 -1
- package/dist/telemetry/OpenTelemetryProvider.d.ts.map +1 -1
- package/dist/telemetry/distinct-id.d.ts +2 -0
- package/dist/telemetry/distinct-id.d.ts.map +1 -0
- package/dist/telemetry/{opentelemetry.d.ts → index.d.ts} +1 -1
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +28 -0
- package/dist/tools/constants.d.ts +1 -1
- package/dist/tools/constants.d.ts.map +1 -1
- package/dist/tools/definitions.d.ts +3 -3
- package/dist/tools/definitions.d.ts.map +1 -1
- package/dist/tools/executors/apply-patch.d.ts +1 -1
- package/dist/tools/executors/apply-patch.d.ts.map +1 -1
- package/dist/tools/executors/bash.d.ts +1 -1
- package/dist/tools/executors/bash.d.ts.map +1 -1
- package/dist/tools/executors/editor.d.ts +1 -1
- package/dist/tools/executors/editor.d.ts.map +1 -1
- package/dist/tools/executors/file-read.d.ts +1 -1
- package/dist/tools/executors/file-read.d.ts.map +1 -1
- package/dist/tools/executors/index.d.ts +14 -14
- package/dist/tools/executors/index.d.ts.map +1 -1
- package/dist/tools/executors/search.d.ts +1 -1
- package/dist/tools/executors/search.d.ts.map +1 -1
- package/dist/tools/executors/web-fetch.d.ts +1 -1
- package/dist/tools/executors/web-fetch.d.ts.map +1 -1
- package/dist/tools/helpers.d.ts +1 -1
- package/dist/tools/helpers.d.ts.map +1 -1
- package/dist/tools/index.d.ts +10 -10
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/model-tool-routing.d.ts +1 -1
- package/dist/tools/model-tool-routing.d.ts.map +1 -1
- package/dist/tools/presets.d.ts +1 -1
- package/dist/tools/presets.d.ts.map +1 -1
- package/dist/types/common.d.ts +17 -8
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/config.d.ts +4 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/provider-settings.d.ts +1 -1
- package/dist/types/provider-settings.d.ts.map +1 -1
- package/dist/types.d.ts +5 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +44 -38
- package/src/ClineCore.ts +137 -0
- package/src/account/cline-account-service.test.ts +101 -0
- package/src/account/cline-account-service.ts +300 -0
- package/src/account/featurebase-token.test.ts +175 -0
- package/src/account/index.ts +23 -0
- package/src/account/rpc.test.ts +63 -0
- package/src/account/rpc.ts +185 -0
- package/src/account/types.ts +102 -0
- package/src/agents/agent-config-loader.test.ts +236 -0
- package/src/agents/agent-config-loader.ts +108 -0
- package/src/agents/agent-config-parser.ts +198 -0
- package/src/agents/hooks-config-loader.test.ts +20 -0
- package/src/agents/hooks-config-loader.ts +118 -0
- package/src/agents/index.ts +85 -0
- package/src/agents/plugin-config-loader.test.ts +140 -0
- package/src/agents/plugin-config-loader.ts +97 -0
- package/src/agents/plugin-loader.test.ts +210 -0
- package/src/agents/plugin-loader.ts +175 -0
- package/src/agents/plugin-sandbox-bootstrap.ts +448 -0
- package/src/agents/plugin-sandbox.test.ts +296 -0
- package/src/agents/plugin-sandbox.ts +341 -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 +420 -0
- package/src/auth/codex.test.ts +170 -0
- package/src/auth/codex.ts +491 -0
- package/src/auth/oca.test.ts +215 -0
- package/src/auth/oca.ts +573 -0
- package/src/auth/server.ts +216 -0
- package/src/auth/types.ts +81 -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/index.ts +479 -0
- package/src/input/file-indexer.d.ts +11 -0
- package/src/input/file-indexer.test.ts +127 -0
- package/src/input/file-indexer.ts +327 -0
- package/src/input/index.ts +7 -0
- package/src/input/mention-enricher.test.ts +85 -0
- package/src/input/mention-enricher.ts +122 -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/providers/local-provider-registry.ts +232 -0
- package/src/providers/local-provider-service.test.ts +783 -0
- package/src/providers/local-provider-service.ts +471 -0
- package/src/runtime/commands.test.ts +98 -0
- package/src/runtime/commands.ts +83 -0
- package/src/runtime/hook-file-hooks.test.ts +237 -0
- package/src/runtime/hook-file-hooks.ts +859 -0
- package/src/runtime/index.ts +37 -0
- package/src/runtime/rules.ts +34 -0
- package/src/runtime/runtime-builder.team-persistence.test.ts +245 -0
- package/src/runtime/runtime-builder.test.ts +371 -0
- package/src/runtime/runtime-builder.ts +631 -0
- package/src/runtime/runtime-parity.test.ts +143 -0
- package/src/runtime/sandbox/subprocess-sandbox.ts +231 -0
- package/src/runtime/session-runtime.ts +49 -0
- package/src/runtime/skills.ts +44 -0
- package/src/runtime/team-runtime-registry.ts +46 -0
- package/src/runtime/tool-approval.ts +104 -0
- package/src/runtime/workflows.test.ts +119 -0
- package/src/runtime/workflows.ts +45 -0
- package/src/session/default-session-manager.e2e.test.ts +384 -0
- package/src/session/default-session-manager.test.ts +1931 -0
- package/src/session/default-session-manager.ts +1422 -0
- package/src/session/file-session-service.ts +280 -0
- package/src/session/index.ts +45 -0
- package/src/session/rpc-runtime-ensure.ts +521 -0
- package/src/session/rpc-session-service.ts +107 -0
- package/src/session/rpc-spawn-lease.test.ts +49 -0
- package/src/session/rpc-spawn-lease.ts +122 -0
- package/src/session/runtime-oauth-token-manager.test.ts +137 -0
- package/src/session/runtime-oauth-token-manager.ts +272 -0
- package/src/session/session-agent-events.ts +248 -0
- package/src/session/session-artifacts.ts +106 -0
- package/src/session/session-config-builder.ts +113 -0
- package/src/session/session-graph.ts +92 -0
- package/src/session/session-host.test.ts +89 -0
- package/src/session/session-host.ts +205 -0
- package/src/session/session-manager.ts +69 -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 +673 -0
- package/src/session/session-team-coordination.ts +229 -0
- package/src/session/session-telemetry.ts +100 -0
- package/src/session/sqlite-rpc-session-backend.ts +303 -0
- package/src/session/unified-session-persistence-service.test.ts +85 -0
- package/src/session/unified-session-persistence-service.ts +994 -0
- package/src/session/utils/helpers.ts +139 -0
- package/src/session/utils/types.ts +57 -0
- package/src/session/utils/usage.ts +32 -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/file-team-store.ts +257 -0
- package/src/storage/index.ts +11 -0
- package/src/storage/provider-settings-legacy-migration.test.ts +424 -0
- package/src/storage/provider-settings-legacy-migration.ts +826 -0
- package/src/storage/provider-settings-manager.test.ts +191 -0
- package/src/storage/provider-settings-manager.ts +152 -0
- package/src/storage/session-store.ts +1 -0
- package/src/storage/sqlite-session-store.ts +275 -0
- package/src/storage/sqlite-team-store.ts +454 -0
- package/src/storage/team-store.ts +40 -0
- package/src/team/index.ts +4 -0
- package/src/team/projections.ts +285 -0
- package/src/telemetry/ITelemetryAdapter.ts +94 -0
- package/src/telemetry/LoggerTelemetryAdapter.test.ts +42 -0
- package/src/telemetry/LoggerTelemetryAdapter.ts +114 -0
- package/src/telemetry/OpenTelemetryAdapter.test.ts +157 -0
- package/src/telemetry/OpenTelemetryAdapter.ts +348 -0
- package/src/telemetry/OpenTelemetryProvider.test.ts +113 -0
- package/src/telemetry/OpenTelemetryProvider.ts +325 -0
- package/src/telemetry/TelemetryService.test.ts +134 -0
- package/src/telemetry/TelemetryService.ts +141 -0
- package/src/telemetry/core-events.ts +400 -0
- package/src/telemetry/distinct-id.test.ts +57 -0
- package/src/telemetry/distinct-id.ts +58 -0
- package/src/telemetry/index.ts +20 -0
- package/src/tools/constants.ts +35 -0
- package/src/tools/definitions.test.ts +704 -0
- package/src/tools/definitions.ts +709 -0
- package/src/tools/executors/apply-patch-parser.ts +520 -0
- package/src/tools/executors/apply-patch.ts +359 -0
- package/src/tools/executors/bash.test.ts +87 -0
- package/src/tools/executors/bash.ts +207 -0
- package/src/tools/executors/editor.test.ts +35 -0
- package/src/tools/executors/editor.ts +219 -0
- package/src/tools/executors/file-read.test.ts +49 -0
- package/src/tools/executors/file-read.ts +110 -0
- package/src/tools/executors/index.ts +87 -0
- package/src/tools/executors/search.ts +278 -0
- package/src/tools/executors/web-fetch.ts +259 -0
- package/src/tools/helpers.ts +130 -0
- package/src/tools/index.ts +169 -0
- package/src/tools/model-tool-routing.test.ts +86 -0
- package/src/tools/model-tool-routing.ts +132 -0
- package/src/tools/presets.test.ts +62 -0
- package/src/tools/presets.ts +168 -0
- package/src/tools/schemas.ts +327 -0
- package/src/tools/types.ts +329 -0
- package/src/types/common.ts +26 -0
- package/src/types/config.ts +86 -0
- package/src/types/events.ts +74 -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 +132 -0
- package/src/version.ts +3 -0
- package/dist/index.node.d.ts +0 -47
- package/dist/index.node.d.ts.map +0 -1
- package/dist/index.node.js +0 -948
- package/dist/telemetry/opentelemetry.d.ts.map +0 -1
- package/dist/telemetry/opentelemetry.js +0 -27
|
@@ -0,0 +1,327 @@
|
|
|
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
|
+
export const INPUT_ARG_CHAR_LIMIT = 6000;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Schema for read tool input
|
|
14
|
+
*/
|
|
15
|
+
const AbsolutePath = z
|
|
16
|
+
.string()
|
|
17
|
+
.describe("The absolute file path of a text file to read content from");
|
|
18
|
+
|
|
19
|
+
export const ReadFileLineRangeSchema = z
|
|
20
|
+
.object({
|
|
21
|
+
start_line: z
|
|
22
|
+
.number()
|
|
23
|
+
.int()
|
|
24
|
+
.positive()
|
|
25
|
+
.nullable()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe(
|
|
28
|
+
"Optional one-based starting line number to read from; use null or omit for the start of the file",
|
|
29
|
+
),
|
|
30
|
+
end_line: z
|
|
31
|
+
.number()
|
|
32
|
+
.int()
|
|
33
|
+
.positive()
|
|
34
|
+
.nullable()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe(
|
|
37
|
+
"Optional one-based ending line number to read through; use null or omit for the end of the file",
|
|
38
|
+
),
|
|
39
|
+
})
|
|
40
|
+
.refine(
|
|
41
|
+
({ start_line, end_line }) =>
|
|
42
|
+
start_line == null || end_line == null || start_line <= end_line,
|
|
43
|
+
{
|
|
44
|
+
message: "start_line must be less than or equal to end_line",
|
|
45
|
+
path: ["end_line"],
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export const ReadFileRequestSchema = z
|
|
50
|
+
.object({
|
|
51
|
+
path: AbsolutePath,
|
|
52
|
+
start_line: ReadFileLineRangeSchema.shape.start_line,
|
|
53
|
+
end_line: ReadFileLineRangeSchema.shape.end_line,
|
|
54
|
+
})
|
|
55
|
+
.refine(
|
|
56
|
+
({ start_line, end_line }) =>
|
|
57
|
+
start_line == null || end_line == null || start_line <= end_line,
|
|
58
|
+
{
|
|
59
|
+
message: "start_line must be less than or equal to end_line",
|
|
60
|
+
path: ["end_line"],
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Schema for read_files tool input
|
|
66
|
+
*/
|
|
67
|
+
export const ReadFilesInputSchema = z.object({
|
|
68
|
+
files: z
|
|
69
|
+
.array(ReadFileRequestSchema)
|
|
70
|
+
.describe(
|
|
71
|
+
"Array of file read requests. Omit start_line/end_line or set them to null to return the full file content boundaries; provide integers to return only that inclusive one-based line range. Prefer this tool over running terminal command to get file content for better performance and reliability.",
|
|
72
|
+
),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Union schema for read_files tool input, allowing either a single string, an array of strings, or the full object schema
|
|
77
|
+
*/
|
|
78
|
+
export const ReadFilesInputUnionSchema = z.union([
|
|
79
|
+
ReadFilesInputSchema,
|
|
80
|
+
ReadFileRequestSchema,
|
|
81
|
+
z.array(ReadFileRequestSchema),
|
|
82
|
+
z.array(z.string()),
|
|
83
|
+
z.string(),
|
|
84
|
+
z.object({ files: ReadFileRequestSchema }),
|
|
85
|
+
z.object({ file_paths: z.array(AbsolutePath) }),
|
|
86
|
+
z.object({ file_paths: z.string() }),
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Schema for search_codebase tool input
|
|
91
|
+
*/
|
|
92
|
+
export const SearchCodebaseInputSchema = z.object({
|
|
93
|
+
queries: z
|
|
94
|
+
.array(z.string())
|
|
95
|
+
.describe("Array of regex search queries to execute"),
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Union schema for search_codebase tool input, allowing either a single string, an array of strings, or the full object schema
|
|
100
|
+
*/
|
|
101
|
+
export const SearchCodebaseUnionInputSchema = z.union([
|
|
102
|
+
SearchCodebaseInputSchema,
|
|
103
|
+
z.array(z.string()),
|
|
104
|
+
z.string(),
|
|
105
|
+
z.object({ queries: z.string() }),
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
const CommandInputSchema = z
|
|
109
|
+
.string()
|
|
110
|
+
.describe(
|
|
111
|
+
`The non-interactive shell command to execute - MUST keep input short and concise (within ${INPUT_ARG_CHAR_LIMIT * 2} characters) to avoid timeouts.`,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Schema for run_commands tool input
|
|
116
|
+
*/
|
|
117
|
+
export const RunCommandsInputSchema = z.object({
|
|
118
|
+
commands: z
|
|
119
|
+
.array(CommandInputSchema)
|
|
120
|
+
.describe("Array of shell commands to execute"),
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Union schema for run_commands tool input. More flexible.
|
|
125
|
+
*/
|
|
126
|
+
export const RunCommandsInputUnionSchema = z.union([
|
|
127
|
+
RunCommandsInputSchema,
|
|
128
|
+
z.object({ commands: CommandInputSchema }),
|
|
129
|
+
z.array(z.string()),
|
|
130
|
+
z.string(),
|
|
131
|
+
]);
|
|
132
|
+
|
|
133
|
+
export const StructuredCommandInputSchema = z.object({
|
|
134
|
+
command: z
|
|
135
|
+
.string()
|
|
136
|
+
.min(1)
|
|
137
|
+
.describe("The executable to run directly without shell parsing."),
|
|
138
|
+
args: z
|
|
139
|
+
.array(z.string())
|
|
140
|
+
.optional()
|
|
141
|
+
.describe("Optional argv list passed directly to the executable."),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
export const StructuredCommandEntrySchema = z.union([
|
|
145
|
+
CommandInputSchema,
|
|
146
|
+
StructuredCommandInputSchema,
|
|
147
|
+
]);
|
|
148
|
+
/**
|
|
149
|
+
* Schema for run_commands tool input
|
|
150
|
+
*/
|
|
151
|
+
export const StructuredCommandsInputSchema = z.object({
|
|
152
|
+
commands: z
|
|
153
|
+
.array(StructuredCommandEntrySchema)
|
|
154
|
+
.describe(
|
|
155
|
+
"Array of commands to execute. Prefer structured { command, args } entries for portability; plain strings are still supported and are interpreted by the active shell.",
|
|
156
|
+
),
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Union schema for run_commands tool input. More flexible.
|
|
161
|
+
*/
|
|
162
|
+
export const StructuredCommandsInputUnionSchema = z.union([
|
|
163
|
+
RunCommandsInputSchema,
|
|
164
|
+
StructuredCommandsInputSchema,
|
|
165
|
+
z.object({ commands: StructuredCommandEntrySchema }),
|
|
166
|
+
z.array(z.string()),
|
|
167
|
+
z.array(StructuredCommandInputSchema),
|
|
168
|
+
z.string(),
|
|
169
|
+
StructuredCommandInputSchema,
|
|
170
|
+
]);
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Schema for a single web fetch request
|
|
174
|
+
*/
|
|
175
|
+
export const WebFetchRequestSchema = z.object({
|
|
176
|
+
url: z.string().describe("The URL to fetch"),
|
|
177
|
+
prompt: z.string().min(2).describe("Analysis prompt for the fetched content"),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Schema for fetch_web_content tool input
|
|
182
|
+
*/
|
|
183
|
+
export const FetchWebContentInputSchema = z.object({
|
|
184
|
+
requests: z
|
|
185
|
+
.array(WebFetchRequestSchema)
|
|
186
|
+
.describe("Array of the URLs for the web fetch requests"),
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Schema for editor tool input
|
|
191
|
+
*/
|
|
192
|
+
export const EditFileInputSchema = z
|
|
193
|
+
.object({
|
|
194
|
+
path: z
|
|
195
|
+
.string()
|
|
196
|
+
.min(1)
|
|
197
|
+
.describe("The absolute file path for the action to be performed on"),
|
|
198
|
+
old_text: z
|
|
199
|
+
.string()
|
|
200
|
+
.nullable()
|
|
201
|
+
.optional()
|
|
202
|
+
.describe(
|
|
203
|
+
`Exact text to replace (must match exactly once). Omit this when creating a missing file or inserting via insert_line. Keep this at or below ${INPUT_ARG_CHAR_LIMIT} characters when possible; larger payloads should be split across multiple tool calls to avoid timeouts.`,
|
|
204
|
+
),
|
|
205
|
+
new_text: z
|
|
206
|
+
.string()
|
|
207
|
+
.describe(
|
|
208
|
+
`The new content to write when creating a missing file, the replacement text for edits, or the inserted text when insert_line is provided. Keep this at or below ${INPUT_ARG_CHAR_LIMIT} characters when possible; for large edits, use multiple calls with small chunks of old_text and new_text to iteratively edit the file.`,
|
|
209
|
+
),
|
|
210
|
+
insert_line: z
|
|
211
|
+
.number()
|
|
212
|
+
.int()
|
|
213
|
+
.nullable()
|
|
214
|
+
.optional()
|
|
215
|
+
.describe(
|
|
216
|
+
"Optional one-based line index. When provided, the tool inserts new_text at that line instead of performing a replacement edit.",
|
|
217
|
+
),
|
|
218
|
+
})
|
|
219
|
+
.describe(
|
|
220
|
+
"Edit a text file by replacing old_text with new_text, create the file with new_text if it does not exist, or insert new_text at insert_line when insert_line is provided. Prefer using this tool for file edits over shell commands. IMPORTANT: large edits can time out, so use small chunks and multiple calls when possible.",
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Schema for apply_patch tool input
|
|
225
|
+
*/
|
|
226
|
+
export const ApplyPatchInputSchema = z
|
|
227
|
+
.object({
|
|
228
|
+
input: z
|
|
229
|
+
.string()
|
|
230
|
+
.min(1)
|
|
231
|
+
.describe("The apply_patch text payload, including patch instructions"),
|
|
232
|
+
})
|
|
233
|
+
.describe(
|
|
234
|
+
"Modify or create a text file by applying patches. Prefer using this tool for file edits over shell commands. IMPORTANT: large patches can time out, so use small chunks and multiple calls when possible.",
|
|
235
|
+
);
|
|
236
|
+
export const ApplyPatchInputUnionSchema = z.union([
|
|
237
|
+
ApplyPatchInputSchema,
|
|
238
|
+
z.string(),
|
|
239
|
+
]);
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Schema for skills tool input
|
|
243
|
+
*/
|
|
244
|
+
export const SkillsInputSchema = z.object({
|
|
245
|
+
skill: z.string().min(1).describe("Name of the skill to execute."),
|
|
246
|
+
args: z
|
|
247
|
+
.string()
|
|
248
|
+
.nullable()
|
|
249
|
+
.optional()
|
|
250
|
+
.describe("Arguments for the skill; use null when omitted"),
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Schema for ask_followup_question tool input
|
|
255
|
+
*/
|
|
256
|
+
export const AskQuestionInputSchema = z.object({
|
|
257
|
+
question: z
|
|
258
|
+
.string()
|
|
259
|
+
.min(1)
|
|
260
|
+
.describe(
|
|
261
|
+
'The single question to ask the user. E.g. "How can I help you?"',
|
|
262
|
+
),
|
|
263
|
+
options: z
|
|
264
|
+
.array(z.string().min(1))
|
|
265
|
+
.min(2)
|
|
266
|
+
.max(5)
|
|
267
|
+
.describe(
|
|
268
|
+
"Array of 2-5 user-selectable answer options for the single question",
|
|
269
|
+
),
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// =============================================================================
|
|
273
|
+
// Type Definitions (derived from Zod schemas)
|
|
274
|
+
// =============================================================================
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Input for a single file read request
|
|
278
|
+
*/
|
|
279
|
+
export type ReadFileRequest = z.infer<typeof ReadFileRequestSchema>;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Input for the read_files tool
|
|
283
|
+
*/
|
|
284
|
+
export type ReadFilesInput = z.infer<typeof ReadFilesInputSchema>;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Input for the search_codebase tool
|
|
288
|
+
*/
|
|
289
|
+
export type SearchCodebaseInput = z.infer<typeof SearchCodebaseInputSchema>;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Input for the run_commands tool
|
|
293
|
+
*/
|
|
294
|
+
export type RunCommandsInput = z.infer<typeof RunCommandsInputSchema>;
|
|
295
|
+
export type StructuredCommandInput = z.infer<
|
|
296
|
+
typeof StructuredCommandInputSchema
|
|
297
|
+
>;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Web fetch request parameters
|
|
301
|
+
*/
|
|
302
|
+
export type WebFetchRequest = z.infer<typeof WebFetchRequestSchema>;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Input for the fetch_web_content tool
|
|
306
|
+
*/
|
|
307
|
+
export type FetchWebContentInput = z.infer<typeof FetchWebContentInputSchema>;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Input for the editor tool
|
|
311
|
+
*/
|
|
312
|
+
export type EditFileInput = z.infer<typeof EditFileInputSchema>;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Input for the apply_patch tool
|
|
316
|
+
*/
|
|
317
|
+
export type ApplyPatchInput = z.infer<typeof ApplyPatchInputSchema>;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Input for the skills tool
|
|
321
|
+
*/
|
|
322
|
+
export type SkillsInput = z.infer<typeof SkillsInputSchema>;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Input for the ask_followup_question tool
|
|
326
|
+
*/
|
|
327
|
+
export type AskQuestionInput = z.infer<typeof AskQuestionInputSchema>;
|
|
@@ -0,0 +1,329 @@
|
|
|
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 {
|
|
9
|
+
ApplyPatchInput,
|
|
10
|
+
EditFileInput,
|
|
11
|
+
ReadFileRequest,
|
|
12
|
+
StructuredCommandInput,
|
|
13
|
+
} from "./schemas";
|
|
14
|
+
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// Tool Result Types
|
|
17
|
+
// =============================================================================
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Result from a single tool operation
|
|
21
|
+
*/
|
|
22
|
+
export interface ToolOperationResult {
|
|
23
|
+
/** The query/input that was executed */
|
|
24
|
+
query: string;
|
|
25
|
+
/** The result content (if successful) */
|
|
26
|
+
result: string;
|
|
27
|
+
/** Error message (if failed) */
|
|
28
|
+
error?: string;
|
|
29
|
+
/** Whether the operation succeeded */
|
|
30
|
+
success: boolean;
|
|
31
|
+
/** Duration in MS */
|
|
32
|
+
duration?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// =============================================================================
|
|
36
|
+
// Executor Interfaces
|
|
37
|
+
// =============================================================================
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Executor for reading files
|
|
41
|
+
*
|
|
42
|
+
* @param request - File path and optional inclusive line range to read
|
|
43
|
+
* @param context - Tool execution context
|
|
44
|
+
* @returns The file content as a string
|
|
45
|
+
*/
|
|
46
|
+
export type FileReadExecutor = (
|
|
47
|
+
request: ReadFileRequest,
|
|
48
|
+
context: ToolContext,
|
|
49
|
+
) => Promise<string>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Executor for searching the codebase
|
|
53
|
+
*
|
|
54
|
+
* @param query - Regex pattern to search for
|
|
55
|
+
* @param cwd - Current working directory for the search
|
|
56
|
+
* @param context - Tool execution context
|
|
57
|
+
* @returns Search results as a formatted string
|
|
58
|
+
*/
|
|
59
|
+
export type SearchExecutor = (
|
|
60
|
+
query: string,
|
|
61
|
+
cwd: string,
|
|
62
|
+
context: ToolContext,
|
|
63
|
+
) => Promise<string>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Executor for running shell commands
|
|
67
|
+
*
|
|
68
|
+
* @param command - Shell command to execute
|
|
69
|
+
* @param cwd - Current working directory for execution
|
|
70
|
+
* @param context - Tool execution context
|
|
71
|
+
* @returns Command output (stdout)
|
|
72
|
+
*/
|
|
73
|
+
export type BashExecutor = (
|
|
74
|
+
command: string | StructuredCommandInput,
|
|
75
|
+
cwd: string,
|
|
76
|
+
context: ToolContext,
|
|
77
|
+
) => Promise<string>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Executor for fetching web content
|
|
81
|
+
*
|
|
82
|
+
* @param url - URL to fetch
|
|
83
|
+
* @param prompt - Analysis prompt for the content
|
|
84
|
+
* @param context - Tool execution context
|
|
85
|
+
* @returns Analyzed/extracted content
|
|
86
|
+
*/
|
|
87
|
+
export type WebFetchExecutor = (
|
|
88
|
+
url: string,
|
|
89
|
+
prompt: string,
|
|
90
|
+
context: ToolContext,
|
|
91
|
+
) => Promise<string>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Executor for editing files
|
|
95
|
+
*
|
|
96
|
+
* @param input - Editor command input
|
|
97
|
+
* @param cwd - Current working directory for filesystem operations
|
|
98
|
+
* @param context - Tool execution context
|
|
99
|
+
* @returns A formatted operation result string
|
|
100
|
+
*/
|
|
101
|
+
export type EditorExecutor = (
|
|
102
|
+
input: EditFileInput,
|
|
103
|
+
cwd: string,
|
|
104
|
+
context: ToolContext,
|
|
105
|
+
) => Promise<string>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Executor for apply_patch operations
|
|
109
|
+
*
|
|
110
|
+
* @param input - apply_patch command payload
|
|
111
|
+
* @param cwd - Current working directory for filesystem operations
|
|
112
|
+
* @param context - Tool execution context
|
|
113
|
+
* @returns A formatted operation result string
|
|
114
|
+
*/
|
|
115
|
+
export type ApplyPatchExecutor = (
|
|
116
|
+
input: ApplyPatchInput,
|
|
117
|
+
cwd: string,
|
|
118
|
+
context: ToolContext,
|
|
119
|
+
) => Promise<string>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Executor for invoking configured skills
|
|
123
|
+
*
|
|
124
|
+
* @param skill - Skill name to invoke
|
|
125
|
+
* @param args - Optional arguments for the skill
|
|
126
|
+
* @param context - Tool execution context
|
|
127
|
+
* @returns Skill loading/invocation result
|
|
128
|
+
*/
|
|
129
|
+
export type SkillsExecutor = (
|
|
130
|
+
skill: string,
|
|
131
|
+
args: string | undefined,
|
|
132
|
+
context: ToolContext,
|
|
133
|
+
) => Promise<string>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Executor for asking a single follow-up question with selectable options
|
|
137
|
+
*
|
|
138
|
+
* @param question - Single clarifying question for the user
|
|
139
|
+
* @param options - 2-5 selectable answer options
|
|
140
|
+
* @param context - Tool execution context
|
|
141
|
+
* @returns Executor-specific result payload
|
|
142
|
+
*/
|
|
143
|
+
export type AskQuestionExecutor = (
|
|
144
|
+
question: string,
|
|
145
|
+
options: string[],
|
|
146
|
+
context: ToolContext,
|
|
147
|
+
) => Promise<string>;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Skill metadata exposed by SkillsExecutor for clients/UI
|
|
151
|
+
*/
|
|
152
|
+
export interface SkillsExecutorSkillMetadata {
|
|
153
|
+
/** Normalized skill id (usually lowercased name) */
|
|
154
|
+
id: string;
|
|
155
|
+
/** Display name for the skill */
|
|
156
|
+
name: string;
|
|
157
|
+
/** Optional short description */
|
|
158
|
+
description?: string;
|
|
159
|
+
/** True when configured but intentionally disabled */
|
|
160
|
+
disabled: boolean;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* A callable executor that can also expose configured skill metadata.
|
|
165
|
+
*/
|
|
166
|
+
export interface SkillsExecutorWithMetadata {
|
|
167
|
+
(
|
|
168
|
+
skill: string,
|
|
169
|
+
args: string | undefined,
|
|
170
|
+
context: ToolContext,
|
|
171
|
+
): Promise<string>;
|
|
172
|
+
configuredSkills?: SkillsExecutorSkillMetadata[];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Collection of all tool executors
|
|
177
|
+
*/
|
|
178
|
+
export interface ToolExecutors {
|
|
179
|
+
/** File reading implementation */
|
|
180
|
+
readFile?: FileReadExecutor;
|
|
181
|
+
/** Codebase search implementation */
|
|
182
|
+
search?: SearchExecutor;
|
|
183
|
+
/** Shell command execution implementation */
|
|
184
|
+
bash?: BashExecutor;
|
|
185
|
+
/** Web content fetching implementation */
|
|
186
|
+
webFetch?: WebFetchExecutor;
|
|
187
|
+
/** Filesystem editor implementation */
|
|
188
|
+
editor?: EditorExecutor;
|
|
189
|
+
/** Apply patch implementation */
|
|
190
|
+
applyPatch?: ApplyPatchExecutor;
|
|
191
|
+
/** Skill invocation implementation */
|
|
192
|
+
skills?: SkillsExecutorWithMetadata;
|
|
193
|
+
/** Follow-up question implementation */
|
|
194
|
+
askQuestion?: AskQuestionExecutor;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// =============================================================================
|
|
198
|
+
// Tool Configuration
|
|
199
|
+
// =============================================================================
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Names of available default tools
|
|
203
|
+
*/
|
|
204
|
+
export type DefaultToolName =
|
|
205
|
+
| "read_files"
|
|
206
|
+
| "search_codebase"
|
|
207
|
+
| "run_commands"
|
|
208
|
+
| "fetch_web_content"
|
|
209
|
+
| "apply_patch"
|
|
210
|
+
| "editor"
|
|
211
|
+
| "skills"
|
|
212
|
+
| "ask_question";
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Configuration for enabling/disabling default tools
|
|
216
|
+
*/
|
|
217
|
+
export interface DefaultToolsConfig {
|
|
218
|
+
/**
|
|
219
|
+
* Enable the read_files tool
|
|
220
|
+
* @default true
|
|
221
|
+
*/
|
|
222
|
+
enableReadFiles?: boolean;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Enable the search_codebase tool
|
|
226
|
+
* @default true
|
|
227
|
+
*/
|
|
228
|
+
enableSearch?: boolean;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Enable the run_commands tool
|
|
232
|
+
* @default true
|
|
233
|
+
*/
|
|
234
|
+
enableBash?: boolean;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Enable the fetch_web_content tool
|
|
238
|
+
* @default true
|
|
239
|
+
*/
|
|
240
|
+
enableWebFetch?: boolean;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Enable the apply_patch tool
|
|
244
|
+
* @default true
|
|
245
|
+
*/
|
|
246
|
+
enableApplyPatch?: boolean;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Enable the editor tool
|
|
250
|
+
* @default true
|
|
251
|
+
*/
|
|
252
|
+
enableEditor?: boolean;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Enable the skills tool
|
|
256
|
+
* @default true
|
|
257
|
+
*/
|
|
258
|
+
enableSkills?: boolean;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Enable the ask_followup_question tool
|
|
262
|
+
* @default true
|
|
263
|
+
*/
|
|
264
|
+
enableAskQuestion?: boolean;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Current working directory for tools that need it
|
|
268
|
+
*/
|
|
269
|
+
cwd?: string;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Timeout for file read operations in milliseconds
|
|
273
|
+
* @default 10000
|
|
274
|
+
*/
|
|
275
|
+
fileReadTimeoutMs?: number;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Timeout for bash command execution in milliseconds
|
|
279
|
+
* @default 30000
|
|
280
|
+
*/
|
|
281
|
+
bashTimeoutMs?: number;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Timeout for web fetch operations in milliseconds
|
|
285
|
+
* @default 30000
|
|
286
|
+
*/
|
|
287
|
+
webFetchTimeoutMs?: number;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Timeout for search operations in milliseconds
|
|
291
|
+
* @default 30000
|
|
292
|
+
*/
|
|
293
|
+
searchTimeoutMs?: number;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Timeout for apply_patch operations in milliseconds
|
|
297
|
+
* @default 30000
|
|
298
|
+
*/
|
|
299
|
+
applyPatchTimeoutMs?: number;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Timeout for editor operations in milliseconds
|
|
303
|
+
* @default 30000
|
|
304
|
+
*/
|
|
305
|
+
editorTimeoutMs?: number;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Timeout for skills operations in milliseconds
|
|
309
|
+
* @default 15000
|
|
310
|
+
*/
|
|
311
|
+
skillsTimeoutMs?: number;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Timeout for ask_followup_question operations in milliseconds
|
|
315
|
+
* @default 15000
|
|
316
|
+
*/
|
|
317
|
+
askQuestionTimeoutMs?: number;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Options for creating default tools
|
|
322
|
+
*/
|
|
323
|
+
export interface CreateDefaultToolsOptions extends DefaultToolsConfig {
|
|
324
|
+
/**
|
|
325
|
+
* Executor implementations for the tools
|
|
326
|
+
* Only tools with provided executors will be available
|
|
327
|
+
*/
|
|
328
|
+
executors: ToolExecutors;
|
|
329
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SESSION_STATUS_VALUES } from "@clinebot/shared";
|
|
2
|
+
|
|
3
|
+
export const SESSION_STATUSES = SESSION_STATUS_VALUES;
|
|
4
|
+
|
|
5
|
+
export type SessionStatus = (typeof SESSION_STATUSES)[number];
|
|
6
|
+
|
|
7
|
+
export const SessionSource = {
|
|
8
|
+
CORE: "core",
|
|
9
|
+
CLI: "cli",
|
|
10
|
+
SUBAGENT: "subagent",
|
|
11
|
+
DESKTOP: "desktop",
|
|
12
|
+
KANBAN: "kanban",
|
|
13
|
+
API: "api",
|
|
14
|
+
WEB: "web",
|
|
15
|
+
VSCODE: "vscode",
|
|
16
|
+
ENTERPRISE: "enterprise",
|
|
17
|
+
IDE: "ide",
|
|
18
|
+
JETBRAINS: "jetbrains",
|
|
19
|
+
NEOVIM: "neovim",
|
|
20
|
+
UNKNOWN: "unknown",
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
export type BuiltinSessionSource =
|
|
24
|
+
(typeof SessionSource)[keyof typeof SessionSource];
|
|
25
|
+
|
|
26
|
+
export type SessionSource = BuiltinSessionSource | (string & {});
|