@clinebot/core 0.0.18 → 0.0.21
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/account/cline-account-service.d.ts +3 -2
- package/dist/account/cline-account-service.d.ts.map +1 -0
- package/dist/account/index.d.ts +1 -0
- package/dist/account/index.d.ts.map +1 -0
- package/dist/account/rpc.d.ts +1 -0
- package/dist/account/rpc.d.ts.map +1 -0
- package/dist/account/types.d.ts +1 -0
- package/dist/account/types.d.ts.map +1 -0
- package/dist/agents/agent-config-loader.d.ts +1 -0
- package/dist/agents/agent-config-loader.d.ts.map +1 -0
- package/dist/agents/agent-config-parser.d.ts +1 -0
- package/dist/agents/agent-config-parser.d.ts.map +1 -0
- package/dist/agents/hooks-config-loader.d.ts +1 -0
- package/dist/agents/hooks-config-loader.d.ts.map +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/plugin-config-loader.d.ts +1 -0
- package/dist/agents/plugin-config-loader.d.ts.map +1 -0
- package/dist/agents/plugin-loader.d.ts +1 -0
- package/dist/agents/plugin-loader.d.ts.map +1 -0
- package/dist/agents/plugin-sandbox.d.ts +1 -0
- package/dist/agents/plugin-sandbox.d.ts.map +1 -0
- package/dist/agents/unified-config-file-watcher.d.ts +1 -0
- package/dist/agents/unified-config-file-watcher.d.ts.map +1 -0
- package/dist/agents/user-instruction-config-loader.d.ts +1 -0
- package/dist/agents/user-instruction-config-loader.d.ts.map +1 -0
- package/dist/auth/client.d.ts +1 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/cline.d.ts +1 -0
- package/dist/auth/cline.d.ts.map +1 -0
- package/dist/auth/codex.d.ts +1 -0
- package/dist/auth/codex.d.ts.map +1 -0
- package/dist/auth/oca.d.ts +1 -0
- package/dist/auth/oca.d.ts.map +1 -0
- package/dist/auth/server.d.ts +1 -0
- package/dist/auth/server.d.ts.map +1 -0
- package/dist/auth/types.d.ts +1 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/utils.d.ts +1 -0
- package/dist/auth/utils.d.ts.map +1 -0
- package/dist/chat/chat-schema.d.ts +13 -12
- package/dist/chat/chat-schema.d.ts.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.node.d.ts +2 -0
- package/dist/index.node.d.ts.map +1 -0
- package/dist/index.node.js +303 -302
- package/dist/input/file-indexer.d.ts +1 -0
- package/dist/input/file-indexer.d.ts.map +1 -0
- package/dist/input/index.d.ts +1 -0
- package/dist/input/index.d.ts.map +1 -0
- package/dist/input/mention-enricher.d.ts +1 -0
- package/dist/input/mention-enricher.d.ts.map +1 -0
- package/dist/mcp/config-loader.d.ts +1 -0
- package/dist/mcp/config-loader.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/manager.d.ts +1 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/types.d.ts +1 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/providers/local-provider-registry.d.ts +36 -0
- package/dist/providers/local-provider-registry.d.ts.map +1 -0
- package/dist/providers/local-provider-service.d.ts +2 -1
- package/dist/providers/local-provider-service.d.ts.map +1 -0
- package/dist/runtime/commands.d.ts +1 -0
- package/dist/runtime/commands.d.ts.map +1 -0
- package/dist/runtime/hook-file-hooks.d.ts +1 -0
- package/dist/runtime/hook-file-hooks.d.ts.map +1 -0
- package/dist/runtime/rules.d.ts +1 -0
- package/dist/runtime/rules.d.ts.map +1 -0
- package/dist/runtime/runtime-builder.d.ts +1 -0
- package/dist/runtime/runtime-builder.d.ts.map +1 -0
- package/dist/runtime/sandbox/subprocess-sandbox.d.ts +1 -0
- package/dist/runtime/sandbox/subprocess-sandbox.d.ts.map +1 -0
- package/dist/runtime/session-runtime.d.ts +2 -0
- package/dist/runtime/session-runtime.d.ts.map +1 -0
- package/dist/runtime/skills.d.ts +1 -0
- package/dist/runtime/skills.d.ts.map +1 -0
- package/dist/runtime/tool-approval.d.ts +1 -0
- package/dist/runtime/tool-approval.d.ts.map +1 -0
- package/dist/runtime/workflows.d.ts +1 -0
- package/dist/runtime/workflows.d.ts.map +1 -0
- package/dist/session/default-session-manager.d.ts +4 -0
- package/dist/session/default-session-manager.d.ts.map +1 -0
- package/dist/session/file-session-service.d.ts +1 -0
- package/dist/session/file-session-service.d.ts.map +1 -0
- package/dist/session/rpc-session-service.d.ts +1 -0
- package/dist/session/rpc-session-service.d.ts.map +1 -0
- package/dist/session/rpc-spawn-lease.d.ts +1 -0
- package/dist/session/rpc-spawn-lease.d.ts.map +1 -0
- package/dist/session/runtime-oauth-token-manager.d.ts +1 -0
- package/dist/session/runtime-oauth-token-manager.d.ts.map +1 -0
- package/dist/session/session-agent-events.d.ts +20 -1
- package/dist/session/session-agent-events.d.ts.map +1 -0
- package/dist/session/session-artifacts.d.ts +1 -0
- package/dist/session/session-artifacts.d.ts.map +1 -0
- package/dist/session/session-config-builder.d.ts +1 -0
- package/dist/session/session-config-builder.d.ts.map +1 -0
- package/dist/session/session-graph.d.ts +1 -0
- package/dist/session/session-graph.d.ts.map +1 -0
- package/dist/session/session-host.d.ts +1 -0
- package/dist/session/session-host.d.ts.map +1 -0
- package/dist/session/session-manager.d.ts +1 -0
- package/dist/session/session-manager.d.ts.map +1 -0
- package/dist/session/session-manifest.d.ts +2 -1
- package/dist/session/session-manifest.d.ts.map +1 -0
- package/dist/session/session-service.d.ts +1 -0
- package/dist/session/session-service.d.ts.map +1 -0
- package/dist/session/session-team-coordination.d.ts +1 -0
- package/dist/session/session-team-coordination.d.ts.map +1 -0
- package/dist/session/session-telemetry.d.ts +3 -1
- package/dist/session/session-telemetry.d.ts.map +1 -0
- package/dist/session/sqlite-rpc-session-backend.d.ts +1 -0
- package/dist/session/sqlite-rpc-session-backend.d.ts.map +1 -0
- package/dist/session/unified-session-persistence-service.d.ts +1 -0
- package/dist/session/unified-session-persistence-service.d.ts.map +1 -0
- package/dist/session/utils/helpers.d.ts +1 -0
- package/dist/session/utils/helpers.d.ts.map +1 -0
- package/dist/session/utils/types.d.ts +1 -0
- package/dist/session/utils/types.d.ts.map +1 -0
- package/dist/session/utils/usage.d.ts +1 -0
- package/dist/session/utils/usage.d.ts.map +1 -0
- package/dist/session/workspace-manager.d.ts +1 -0
- package/dist/session/workspace-manager.d.ts.map +1 -0
- package/dist/session/workspace-manifest.d.ts +1 -0
- package/dist/session/workspace-manifest.d.ts.map +1 -0
- package/dist/storage/file-team-store.d.ts +1 -0
- package/dist/storage/file-team-store.d.ts.map +1 -0
- package/dist/storage/provider-settings-legacy-migration.d.ts +1 -0
- package/dist/storage/provider-settings-legacy-migration.d.ts.map +1 -0
- package/dist/storage/provider-settings-manager.d.ts +1 -0
- package/dist/storage/provider-settings-manager.d.ts.map +1 -0
- package/dist/storage/sqlite-session-store.d.ts +1 -0
- package/dist/storage/sqlite-session-store.d.ts.map +1 -0
- package/dist/storage/sqlite-team-store.d.ts +1 -0
- package/dist/storage/sqlite-team-store.d.ts.map +1 -0
- package/dist/storage/team-store.d.ts +1 -0
- package/dist/storage/team-store.d.ts.map +1 -0
- package/dist/team/index.d.ts +1 -0
- package/dist/team/index.d.ts.map +1 -0
- package/dist/team/projections.d.ts +1 -0
- package/dist/team/projections.d.ts.map +1 -0
- package/dist/telemetry/ITelemetryAdapter.d.ts +1 -0
- package/dist/telemetry/ITelemetryAdapter.d.ts.map +1 -0
- package/dist/telemetry/LoggerTelemetryAdapter.d.ts +1 -0
- package/dist/telemetry/LoggerTelemetryAdapter.d.ts.map +1 -0
- package/dist/telemetry/OpenTelemetryAdapter.d.ts +1 -0
- package/dist/telemetry/OpenTelemetryAdapter.d.ts.map +1 -0
- package/dist/telemetry/OpenTelemetryProvider.d.ts +1 -0
- package/dist/telemetry/OpenTelemetryProvider.d.ts.map +1 -0
- package/dist/telemetry/TelemetryService.d.ts +1 -0
- package/dist/telemetry/TelemetryService.d.ts.map +1 -0
- package/dist/telemetry/core-events.d.ts +55 -22
- package/dist/telemetry/core-events.d.ts.map +1 -0
- package/dist/telemetry/opentelemetry.d.ts +1 -0
- package/dist/telemetry/opentelemetry.d.ts.map +1 -0
- package/dist/tools/constants.d.ts +1 -0
- package/dist/tools/constants.d.ts.map +1 -0
- package/dist/tools/definitions.d.ts +8 -1
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/executors/apply-patch-parser.d.ts +1 -0
- package/dist/tools/executors/apply-patch-parser.d.ts.map +1 -0
- package/dist/tools/executors/apply-patch.d.ts +1 -0
- package/dist/tools/executors/apply-patch.d.ts.map +1 -0
- package/dist/tools/executors/bash.d.ts +2 -1
- package/dist/tools/executors/bash.d.ts.map +1 -0
- package/dist/tools/executors/editor.d.ts +1 -0
- package/dist/tools/executors/editor.d.ts.map +1 -0
- package/dist/tools/executors/file-read.d.ts +1 -0
- package/dist/tools/executors/file-read.d.ts.map +1 -0
- package/dist/tools/executors/index.d.ts +14 -7
- package/dist/tools/executors/index.d.ts.map +1 -0
- package/dist/tools/executors/search.d.ts +1 -0
- package/dist/tools/executors/search.d.ts.map +1 -0
- package/dist/tools/executors/web-fetch.d.ts +1 -0
- package/dist/tools/executors/web-fetch.d.ts.map +1 -0
- package/dist/tools/helpers.d.ts +15 -0
- package/dist/tools/helpers.d.ts.map +1 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/model-tool-routing.d.ts +1 -0
- package/dist/tools/model-tool-routing.d.ts.map +1 -0
- package/dist/tools/presets.d.ts +1 -0
- package/dist/tools/presets.d.ts.map +1 -0
- package/dist/tools/schemas.d.ts +41 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/types.d.ts +3 -2
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/types/common.d.ts +1 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/events.d.ts +1 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/provider-settings.d.ts +1 -0
- package/dist/types/provider-settings.d.ts.map +1 -0
- package/dist/types/sessions.d.ts +1 -0
- package/dist/types/sessions.d.ts.map +1 -0
- package/dist/types/storage.d.ts +1 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/workspace.d.ts +1 -0
- package/dist/types/workspace.d.ts.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +8 -6
- package/src/account/cline-account-service.test.ts +0 -101
- package/src/account/cline-account-service.ts +0 -287
- package/src/account/index.ts +0 -22
- package/src/account/rpc.test.ts +0 -62
- package/src/account/rpc.ts +0 -172
- package/src/account/types.ts +0 -98
- package/src/agents/agent-config-loader.test.ts +0 -236
- package/src/agents/agent-config-loader.ts +0 -108
- package/src/agents/agent-config-parser.ts +0 -198
- package/src/agents/hooks-config-loader.test.ts +0 -20
- package/src/agents/hooks-config-loader.ts +0 -118
- package/src/agents/index.ts +0 -85
- package/src/agents/plugin-config-loader.test.ts +0 -140
- package/src/agents/plugin-config-loader.ts +0 -97
- package/src/agents/plugin-loader.test.ts +0 -228
- package/src/agents/plugin-loader.ts +0 -172
- package/src/agents/plugin-sandbox-bootstrap.ts +0 -445
- package/src/agents/plugin-sandbox.test.ts +0 -317
- package/src/agents/plugin-sandbox.ts +0 -341
- package/src/agents/unified-config-file-watcher.test.ts +0 -196
- package/src/agents/unified-config-file-watcher.ts +0 -483
- package/src/agents/user-instruction-config-loader.test.ts +0 -158
- package/src/agents/user-instruction-config-loader.ts +0 -438
- package/src/auth/client.test.ts +0 -40
- package/src/auth/client.ts +0 -25
- package/src/auth/cline.test.ts +0 -130
- package/src/auth/cline.ts +0 -420
- package/src/auth/codex.test.ts +0 -170
- package/src/auth/codex.ts +0 -491
- package/src/auth/oca.test.ts +0 -215
- package/src/auth/oca.ts +0 -573
- package/src/auth/server.ts +0 -216
- package/src/auth/types.ts +0 -81
- package/src/auth/utils.test.ts +0 -128
- package/src/auth/utils.ts +0 -247
- package/src/chat/chat-schema.ts +0 -82
- package/src/index.node.ts +0 -285
- package/src/index.ts +0 -211
- package/src/input/file-indexer.d.ts +0 -11
- package/src/input/file-indexer.test.ts +0 -127
- package/src/input/file-indexer.ts +0 -327
- package/src/input/index.ts +0 -7
- package/src/input/mention-enricher.test.ts +0 -85
- package/src/input/mention-enricher.ts +0 -122
- package/src/mcp/config-loader.test.ts +0 -238
- package/src/mcp/config-loader.ts +0 -219
- package/src/mcp/index.ts +0 -26
- package/src/mcp/manager.test.ts +0 -106
- package/src/mcp/manager.ts +0 -262
- package/src/mcp/types.ts +0 -88
- package/src/providers/local-provider-service.ts +0 -608
- package/src/runtime/commands.test.ts +0 -98
- package/src/runtime/commands.ts +0 -83
- package/src/runtime/hook-file-hooks.test.ts +0 -237
- package/src/runtime/hook-file-hooks.ts +0 -859
- package/src/runtime/index.ts +0 -37
- package/src/runtime/rules.ts +0 -34
- package/src/runtime/runtime-builder.team-persistence.test.ts +0 -202
- package/src/runtime/runtime-builder.test.ts +0 -371
- package/src/runtime/runtime-builder.ts +0 -589
- package/src/runtime/runtime-parity.test.ts +0 -143
- package/src/runtime/sandbox/subprocess-sandbox.ts +0 -231
- package/src/runtime/session-runtime.ts +0 -46
- package/src/runtime/skills.ts +0 -44
- package/src/runtime/tool-approval.ts +0 -104
- package/src/runtime/workflows.test.ts +0 -119
- package/src/runtime/workflows.ts +0 -45
- package/src/session/default-session-manager.e2e.test.ts +0 -384
- package/src/session/default-session-manager.test.ts +0 -1741
- package/src/session/default-session-manager.ts +0 -1233
- package/src/session/file-session-service.ts +0 -280
- package/src/session/index.ts +0 -42
- package/src/session/rpc-session-service.ts +0 -107
- package/src/session/rpc-spawn-lease.test.ts +0 -49
- package/src/session/rpc-spawn-lease.ts +0 -122
- package/src/session/runtime-oauth-token-manager.test.ts +0 -137
- package/src/session/runtime-oauth-token-manager.ts +0 -272
- package/src/session/session-agent-events.ts +0 -159
- package/src/session/session-artifacts.ts +0 -106
- package/src/session/session-config-builder.ts +0 -113
- package/src/session/session-graph.ts +0 -92
- package/src/session/session-host.test.ts +0 -29
- package/src/session/session-host.ts +0 -242
- package/src/session/session-manager.ts +0 -69
- package/src/session/session-manifest.ts +0 -29
- package/src/session/session-service.team-persistence.test.ts +0 -48
- package/src/session/session-service.ts +0 -673
- package/src/session/session-team-coordination.ts +0 -229
- package/src/session/session-telemetry.ts +0 -95
- package/src/session/sqlite-rpc-session-backend.ts +0 -303
- package/src/session/unified-session-persistence-service.test.ts +0 -85
- package/src/session/unified-session-persistence-service.ts +0 -996
- package/src/session/utils/helpers.ts +0 -139
- package/src/session/utils/types.ts +0 -57
- package/src/session/utils/usage.ts +0 -32
- package/src/session/workspace-manager.ts +0 -98
- package/src/session/workspace-manifest.ts +0 -100
- package/src/storage/artifact-store.ts +0 -1
- package/src/storage/file-team-store.ts +0 -257
- package/src/storage/index.ts +0 -11
- package/src/storage/provider-settings-legacy-migration.test.ts +0 -307
- package/src/storage/provider-settings-legacy-migration.ts +0 -689
- package/src/storage/provider-settings-manager.test.ts +0 -145
- package/src/storage/provider-settings-manager.ts +0 -150
- package/src/storage/session-store.ts +0 -1
- package/src/storage/sqlite-session-store.ts +0 -275
- package/src/storage/sqlite-team-store.ts +0 -454
- package/src/storage/team-store.ts +0 -40
- package/src/team/index.ts +0 -4
- package/src/team/projections.ts +0 -285
- package/src/telemetry/ITelemetryAdapter.ts +0 -94
- package/src/telemetry/LoggerTelemetryAdapter.test.ts +0 -42
- package/src/telemetry/LoggerTelemetryAdapter.ts +0 -114
- package/src/telemetry/OpenTelemetryAdapter.test.ts +0 -157
- package/src/telemetry/OpenTelemetryAdapter.ts +0 -348
- package/src/telemetry/OpenTelemetryProvider.test.ts +0 -113
- package/src/telemetry/OpenTelemetryProvider.ts +0 -322
- package/src/telemetry/TelemetryService.test.ts +0 -134
- package/src/telemetry/TelemetryService.ts +0 -141
- package/src/telemetry/core-events.ts +0 -344
- package/src/telemetry/opentelemetry.ts +0 -20
- package/src/tools/constants.ts +0 -35
- package/src/tools/definitions.test.ts +0 -658
- package/src/tools/definitions.ts +0 -726
- package/src/tools/executors/apply-patch-parser.ts +0 -520
- package/src/tools/executors/apply-patch.ts +0 -359
- package/src/tools/executors/bash.ts +0 -205
- package/src/tools/executors/editor.test.ts +0 -35
- package/src/tools/executors/editor.ts +0 -219
- package/src/tools/executors/file-read.test.ts +0 -49
- package/src/tools/executors/file-read.ts +0 -110
- package/src/tools/executors/index.ts +0 -75
- package/src/tools/executors/search.ts +0 -278
- package/src/tools/executors/web-fetch.ts +0 -259
- package/src/tools/index.ts +0 -168
- package/src/tools/model-tool-routing.test.ts +0 -86
- package/src/tools/model-tool-routing.ts +0 -132
- package/src/tools/presets.test.ts +0 -62
- package/src/tools/presets.ts +0 -168
- package/src/tools/schemas.ts +0 -284
- package/src/tools/types.ts +0 -328
- package/src/types/common.ts +0 -14
- package/src/types/config.ts +0 -84
- package/src/types/events.ts +0 -74
- package/src/types/index.ts +0 -24
- package/src/types/provider-settings.ts +0 -43
- package/src/types/sessions.ts +0 -16
- package/src/types/storage.ts +0 -64
- package/src/types/workspace.ts +0 -7
- package/src/types.ts +0 -128
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Search Executor
|
|
3
|
-
*
|
|
4
|
-
* Built-in implementation for searching the codebase using regex.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import * as fs from "node:fs/promises";
|
|
8
|
-
import * as path from "node:path";
|
|
9
|
-
import type { ToolContext } from "@clinebot/agents";
|
|
10
|
-
import { getFileIndex } from "../../input";
|
|
11
|
-
import type { SearchExecutor } from "../types.js";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Options for the search executor
|
|
15
|
-
*/
|
|
16
|
-
export interface SearchExecutorOptions {
|
|
17
|
-
/**
|
|
18
|
-
* File extensions to include in search (without dot)
|
|
19
|
-
* @default common code extensions
|
|
20
|
-
*/
|
|
21
|
-
includeExtensions?: string[];
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Directories to exclude from search
|
|
25
|
-
* @default ["node_modules", ".git", "dist", "build", ".next", "coverage"]
|
|
26
|
-
*/
|
|
27
|
-
excludeDirs?: string[];
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Maximum number of results to return
|
|
31
|
-
* @default 100
|
|
32
|
-
*/
|
|
33
|
-
maxResults?: number;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Number of context lines before and after match
|
|
37
|
-
* @default 2
|
|
38
|
-
*/
|
|
39
|
-
contextLines?: number;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Maximum depth to traverse
|
|
43
|
-
* @default 20
|
|
44
|
-
*/
|
|
45
|
-
maxDepth?: number;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const DEFAULT_INCLUDE_EXTENSIONS = [
|
|
49
|
-
"ts",
|
|
50
|
-
"tsx",
|
|
51
|
-
"js",
|
|
52
|
-
"jsx",
|
|
53
|
-
"mjs",
|
|
54
|
-
"cjs",
|
|
55
|
-
"json",
|
|
56
|
-
"md",
|
|
57
|
-
"mdx",
|
|
58
|
-
"txt",
|
|
59
|
-
"yaml",
|
|
60
|
-
"yml",
|
|
61
|
-
"toml",
|
|
62
|
-
"py",
|
|
63
|
-
"rb",
|
|
64
|
-
"go",
|
|
65
|
-
"rs",
|
|
66
|
-
"java",
|
|
67
|
-
"kt",
|
|
68
|
-
"swift",
|
|
69
|
-
"c",
|
|
70
|
-
"cpp",
|
|
71
|
-
"h",
|
|
72
|
-
"hpp",
|
|
73
|
-
"css",
|
|
74
|
-
"scss",
|
|
75
|
-
"less",
|
|
76
|
-
"html",
|
|
77
|
-
"vue",
|
|
78
|
-
"svelte",
|
|
79
|
-
"sql",
|
|
80
|
-
"sh",
|
|
81
|
-
"bash",
|
|
82
|
-
"zsh",
|
|
83
|
-
"fish",
|
|
84
|
-
"ps1",
|
|
85
|
-
"env",
|
|
86
|
-
"gitignore",
|
|
87
|
-
"dockerignore",
|
|
88
|
-
"editorconfig",
|
|
89
|
-
];
|
|
90
|
-
|
|
91
|
-
const DEFAULT_EXCLUDE_DIRS = [
|
|
92
|
-
"node_modules",
|
|
93
|
-
".git",
|
|
94
|
-
"dist",
|
|
95
|
-
"build",
|
|
96
|
-
".next",
|
|
97
|
-
"coverage",
|
|
98
|
-
"__pycache__",
|
|
99
|
-
".venv",
|
|
100
|
-
"venv",
|
|
101
|
-
".cache",
|
|
102
|
-
".turbo",
|
|
103
|
-
".output",
|
|
104
|
-
"out",
|
|
105
|
-
"target",
|
|
106
|
-
"bin",
|
|
107
|
-
"obj",
|
|
108
|
-
];
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Search result for a single file match
|
|
112
|
-
*/
|
|
113
|
-
interface SearchMatch {
|
|
114
|
-
file: string;
|
|
115
|
-
line: number;
|
|
116
|
-
column: number;
|
|
117
|
-
match: string;
|
|
118
|
-
context: string[];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function shouldIncludeFile(
|
|
122
|
-
relativePath: string,
|
|
123
|
-
excludeDirs: Set<string>,
|
|
124
|
-
includeExtensions: Set<string>,
|
|
125
|
-
maxDepth: number,
|
|
126
|
-
): boolean {
|
|
127
|
-
const segments = relativePath.split("/");
|
|
128
|
-
const fileName = segments[segments.length - 1] ?? "";
|
|
129
|
-
const directoryDepth = segments.length - 1;
|
|
130
|
-
|
|
131
|
-
if (directoryDepth > maxDepth) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
for (let i = 0; i < segments.length - 1; i++) {
|
|
136
|
-
if (excludeDirs.has(segments[i] ?? "")) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const ext = path.posix.extname(fileName).slice(1).toLowerCase();
|
|
142
|
-
return includeExtensions.has(ext) || (!ext && !fileName.startsWith("."));
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Create a search executor using regex pattern matching
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```typescript
|
|
150
|
-
* const search = createSearchExecutor({
|
|
151
|
-
* maxResults: 50,
|
|
152
|
-
* contextLines: 3,
|
|
153
|
-
* })
|
|
154
|
-
*
|
|
155
|
-
* const results = await search("function\\s+handleClick", "/path/to/project", context)
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
export function createSearchExecutor(
|
|
159
|
-
options: SearchExecutorOptions = {},
|
|
160
|
-
): SearchExecutor {
|
|
161
|
-
const {
|
|
162
|
-
includeExtensions = DEFAULT_INCLUDE_EXTENSIONS,
|
|
163
|
-
excludeDirs = DEFAULT_EXCLUDE_DIRS,
|
|
164
|
-
maxResults = 100,
|
|
165
|
-
contextLines = 2,
|
|
166
|
-
maxDepth = 20,
|
|
167
|
-
} = options;
|
|
168
|
-
const excludeDirsSet = new Set(excludeDirs);
|
|
169
|
-
const includeExtensionsSet = new Set(
|
|
170
|
-
includeExtensions.map((extension) => extension.toLowerCase()),
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
return async (
|
|
174
|
-
query: string,
|
|
175
|
-
cwd: string,
|
|
176
|
-
_context: ToolContext,
|
|
177
|
-
): Promise<string> => {
|
|
178
|
-
// Compile regex
|
|
179
|
-
let regex: RegExp;
|
|
180
|
-
try {
|
|
181
|
-
regex = new RegExp(query, "gim");
|
|
182
|
-
} catch (error) {
|
|
183
|
-
throw new Error(
|
|
184
|
-
`Invalid regex pattern: ${query}. ${error instanceof Error ? error.message : ""}`,
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const matches: SearchMatch[] = [];
|
|
189
|
-
let totalFilesSearched = 0;
|
|
190
|
-
|
|
191
|
-
const fileList = await getFileIndex(cwd);
|
|
192
|
-
|
|
193
|
-
// Search files from the fast index.
|
|
194
|
-
for (const relativePath of fileList) {
|
|
195
|
-
if (
|
|
196
|
-
!shouldIncludeFile(
|
|
197
|
-
relativePath,
|
|
198
|
-
excludeDirsSet,
|
|
199
|
-
includeExtensionsSet,
|
|
200
|
-
maxDepth,
|
|
201
|
-
)
|
|
202
|
-
) {
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (matches.length >= maxResults) break;
|
|
207
|
-
|
|
208
|
-
totalFilesSearched++;
|
|
209
|
-
const filePath = path.join(cwd, relativePath);
|
|
210
|
-
|
|
211
|
-
try {
|
|
212
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
213
|
-
const lines = content.split("\n");
|
|
214
|
-
|
|
215
|
-
for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
|
|
216
|
-
const line = lines[lineIdx];
|
|
217
|
-
regex.lastIndex = 0; // Reset regex state
|
|
218
|
-
|
|
219
|
-
let match: RegExpExecArray | null;
|
|
220
|
-
while ((match = regex.exec(line)) !== null) {
|
|
221
|
-
if (matches.length >= maxResults) break;
|
|
222
|
-
|
|
223
|
-
// Get context lines
|
|
224
|
-
const contextStart = Math.max(0, lineIdx - contextLines);
|
|
225
|
-
const contextEnd = Math.min(
|
|
226
|
-
lines.length - 1,
|
|
227
|
-
lineIdx + contextLines,
|
|
228
|
-
);
|
|
229
|
-
const contextLinesArr: string[] = [];
|
|
230
|
-
|
|
231
|
-
for (let i = contextStart; i <= contextEnd; i++) {
|
|
232
|
-
const prefix = i === lineIdx ? ">" : " ";
|
|
233
|
-
contextLinesArr.push(`${prefix} ${i + 1}: ${lines[i]}`);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
matches.push({
|
|
237
|
-
file: relativePath,
|
|
238
|
-
line: lineIdx + 1,
|
|
239
|
-
column: match.index + 1,
|
|
240
|
-
match: match[0],
|
|
241
|
-
context: contextLinesArr,
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// Prevent infinite loop on zero-length matches
|
|
245
|
-
if (match.index === regex.lastIndex) {
|
|
246
|
-
regex.lastIndex++;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
} catch {}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// Format results
|
|
254
|
-
if (matches.length === 0) {
|
|
255
|
-
return `No results found for pattern: ${query}\nSearched ${totalFilesSearched} files.`;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const resultLines: string[] = [
|
|
259
|
-
`Found ${matches.length} result${matches.length === 1 ? "" : "s"} for pattern: ${query}`,
|
|
260
|
-
`Searched ${totalFilesSearched} files.`,
|
|
261
|
-
"",
|
|
262
|
-
];
|
|
263
|
-
|
|
264
|
-
for (const match of matches) {
|
|
265
|
-
resultLines.push(`${match.file}:${match.line}:${match.column}`);
|
|
266
|
-
resultLines.push(...match.context);
|
|
267
|
-
resultLines.push("");
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
if (matches.length >= maxResults) {
|
|
271
|
-
resultLines.push(
|
|
272
|
-
`(Showing first ${maxResults} results. Refine your search for more specific results.)`,
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return resultLines.join("\n");
|
|
277
|
-
};
|
|
278
|
-
}
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web Fetch Executor
|
|
3
|
-
*
|
|
4
|
-
* Built-in implementation for fetching web content using native fetch.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ToolContext } from "@clinebot/agents";
|
|
8
|
-
import type { WebFetchExecutor } from "../types.js";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Options for the web fetch executor
|
|
12
|
-
*/
|
|
13
|
-
export interface WebFetchExecutorOptions {
|
|
14
|
-
/**
|
|
15
|
-
* Timeout for fetch requests in milliseconds
|
|
16
|
-
* @default 30000 (30 seconds)
|
|
17
|
-
*/
|
|
18
|
-
timeoutMs?: number;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Maximum response size in bytes
|
|
22
|
-
* @default 5_000_000 (5MB)
|
|
23
|
-
*/
|
|
24
|
-
maxResponseBytes?: number;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* User agent string
|
|
28
|
-
* @default "Mozilla/5.0 (compatible; AgentBot/1.0)"
|
|
29
|
-
*/
|
|
30
|
-
userAgent?: string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Additional headers
|
|
34
|
-
*/
|
|
35
|
-
headers?: Record<string, string>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Whether to follow redirects
|
|
39
|
-
* @default true
|
|
40
|
-
*/
|
|
41
|
-
followRedirects?: boolean;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Maximum number of redirects to follow
|
|
45
|
-
* @default 5
|
|
46
|
-
*/
|
|
47
|
-
maxRedirects?: number;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Extract text content from HTML
|
|
52
|
-
* Simple implementation - strips tags and normalizes whitespace
|
|
53
|
-
*/
|
|
54
|
-
function htmlToText(html: string): string {
|
|
55
|
-
return (
|
|
56
|
-
html
|
|
57
|
-
// Remove script and style elements
|
|
58
|
-
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "")
|
|
59
|
-
.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "")
|
|
60
|
-
// Remove HTML comments
|
|
61
|
-
.replace(/<!--[\s\S]*?-->/g, "")
|
|
62
|
-
// Replace block elements with newlines
|
|
63
|
-
.replace(/<(p|div|br|hr|h[1-6]|li|tr)[^>]*>/gi, "\n")
|
|
64
|
-
// Remove all remaining tags
|
|
65
|
-
.replace(/<[^>]+>/g, " ")
|
|
66
|
-
// Decode HTML entities
|
|
67
|
-
.replace(/ /g, " ")
|
|
68
|
-
.replace(/&/g, "&")
|
|
69
|
-
.replace(/</g, "<")
|
|
70
|
-
.replace(/>/g, ">")
|
|
71
|
-
.replace(/"/g, '"')
|
|
72
|
-
.replace(/&#(\d+);/g, (_, n) => String.fromCharCode(parseInt(n, 10)))
|
|
73
|
-
// Normalize whitespace
|
|
74
|
-
.replace(/\s+/g, " ")
|
|
75
|
-
.replace(/\n\s+/g, "\n")
|
|
76
|
-
.replace(/\n{3,}/g, "\n\n")
|
|
77
|
-
.trim()
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Create a web fetch executor using native fetch
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```typescript
|
|
86
|
-
* const webFetch = createWebFetchExecutor({
|
|
87
|
-
* timeoutMs: 15000,
|
|
88
|
-
* maxResponseBytes: 2_000_000,
|
|
89
|
-
* })
|
|
90
|
-
*
|
|
91
|
-
* const content = await webFetch(
|
|
92
|
-
* "https://docs.example.com/api",
|
|
93
|
-
* "Extract the authentication section",
|
|
94
|
-
* context
|
|
95
|
-
* )
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
export function createWebFetchExecutor(
|
|
99
|
-
options: WebFetchExecutorOptions = {},
|
|
100
|
-
): WebFetchExecutor {
|
|
101
|
-
const {
|
|
102
|
-
timeoutMs = 30000,
|
|
103
|
-
maxResponseBytes = 5_000_000,
|
|
104
|
-
userAgent = "Mozilla/5.0 (compatible; AgentBot/1.0)",
|
|
105
|
-
headers = {},
|
|
106
|
-
followRedirects = true,
|
|
107
|
-
// maxRedirects is available in options but native fetch handles it automatically
|
|
108
|
-
} = options;
|
|
109
|
-
|
|
110
|
-
return async (
|
|
111
|
-
url: string,
|
|
112
|
-
prompt: string,
|
|
113
|
-
context: ToolContext,
|
|
114
|
-
): Promise<string> => {
|
|
115
|
-
// Validate URL
|
|
116
|
-
let parsedUrl: URL;
|
|
117
|
-
try {
|
|
118
|
-
parsedUrl = new URL(url);
|
|
119
|
-
} catch {
|
|
120
|
-
throw new Error(`Invalid URL: ${url}`);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Only allow http and https
|
|
124
|
-
if (!["http:", "https:"].includes(parsedUrl.protocol)) {
|
|
125
|
-
throw new Error(
|
|
126
|
-
`Invalid protocol: ${parsedUrl.protocol}. Only http and https are supported.`,
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Create abort controller for timeout
|
|
131
|
-
const controller = new AbortController();
|
|
132
|
-
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
133
|
-
let contextAbortHandler: (() => void) | undefined;
|
|
134
|
-
|
|
135
|
-
// Combine with context abort signal
|
|
136
|
-
if (context.abortSignal) {
|
|
137
|
-
contextAbortHandler = () => controller.abort();
|
|
138
|
-
context.abortSignal.addEventListener("abort", contextAbortHandler);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
try {
|
|
142
|
-
const response = await fetch(url, {
|
|
143
|
-
method: "GET",
|
|
144
|
-
headers: {
|
|
145
|
-
"User-Agent": userAgent,
|
|
146
|
-
Accept:
|
|
147
|
-
"text/html,application/xhtml+xml,application/xml;q=0.9,text/plain;q=0.8,*/*;q=0.7",
|
|
148
|
-
"Accept-Language": "en-US,en;q=0.9",
|
|
149
|
-
...headers,
|
|
150
|
-
},
|
|
151
|
-
redirect: followRedirects ? "follow" : "manual",
|
|
152
|
-
signal: controller.signal,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
clearTimeout(timeout);
|
|
156
|
-
|
|
157
|
-
// Check for redirect limit (if we're checking manually)
|
|
158
|
-
if (!followRedirects && response.status >= 300 && response.status < 400) {
|
|
159
|
-
const location = response.headers.get("location");
|
|
160
|
-
return `Redirect to: ${location}`;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Check response status
|
|
164
|
-
if (!response.ok) {
|
|
165
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Get content type
|
|
169
|
-
const contentType = response.headers.get("content-type") || "";
|
|
170
|
-
|
|
171
|
-
// Read response body with size limit
|
|
172
|
-
const reader = response.body?.getReader();
|
|
173
|
-
if (!reader) {
|
|
174
|
-
throw new Error("Failed to read response body");
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const chunks: Uint8Array[] = [];
|
|
178
|
-
let totalSize = 0;
|
|
179
|
-
|
|
180
|
-
while (true) {
|
|
181
|
-
const { done, value } = await reader.read();
|
|
182
|
-
if (done) break;
|
|
183
|
-
|
|
184
|
-
totalSize += value.length;
|
|
185
|
-
if (totalSize > maxResponseBytes) {
|
|
186
|
-
reader.cancel();
|
|
187
|
-
throw new Error(
|
|
188
|
-
`Response too large: exceeded ${maxResponseBytes} bytes`,
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
chunks.push(value);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Combine chunks
|
|
196
|
-
const buffer = new Uint8Array(totalSize);
|
|
197
|
-
let offset = 0;
|
|
198
|
-
for (const chunk of chunks) {
|
|
199
|
-
buffer.set(chunk, offset);
|
|
200
|
-
offset += chunk.length;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Decode as text
|
|
204
|
-
const text = new TextDecoder("utf-8").decode(buffer);
|
|
205
|
-
|
|
206
|
-
// Process content based on type
|
|
207
|
-
let content: string;
|
|
208
|
-
if (
|
|
209
|
-
contentType.includes("text/html") ||
|
|
210
|
-
contentType.includes("application/xhtml")
|
|
211
|
-
) {
|
|
212
|
-
content = htmlToText(text);
|
|
213
|
-
} else if (contentType.includes("application/json")) {
|
|
214
|
-
try {
|
|
215
|
-
const json = JSON.parse(text);
|
|
216
|
-
content = JSON.stringify(json, null, 2);
|
|
217
|
-
} catch {
|
|
218
|
-
content = text;
|
|
219
|
-
}
|
|
220
|
-
} else {
|
|
221
|
-
content = text;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Format output with metadata
|
|
225
|
-
const outputLines = [
|
|
226
|
-
`URL: ${url}`,
|
|
227
|
-
`Content-Type: ${contentType}`,
|
|
228
|
-
`Size: ${totalSize} bytes`,
|
|
229
|
-
``,
|
|
230
|
-
`--- Content ---`,
|
|
231
|
-
content.slice(0, 50000), // Limit content size for output
|
|
232
|
-
];
|
|
233
|
-
|
|
234
|
-
if (content.length > 50000) {
|
|
235
|
-
outputLines.push(
|
|
236
|
-
`\n[Content truncated: showing first 50000 of ${content.length} characters]`,
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
outputLines.push(``, `--- Analysis Request ---`, `Prompt: ${prompt}`);
|
|
241
|
-
|
|
242
|
-
return outputLines.join("\n");
|
|
243
|
-
} catch (error) {
|
|
244
|
-
clearTimeout(timeout);
|
|
245
|
-
|
|
246
|
-
if (error instanceof Error) {
|
|
247
|
-
if (error.name === "AbortError") {
|
|
248
|
-
throw new Error(`Request timed out after ${timeoutMs}ms`);
|
|
249
|
-
}
|
|
250
|
-
throw error;
|
|
251
|
-
}
|
|
252
|
-
throw new Error(`Fetch failed: ${String(error)}`);
|
|
253
|
-
} finally {
|
|
254
|
-
if (context.abortSignal && contextAbortHandler) {
|
|
255
|
-
context.abortSignal.removeEventListener("abort", contextAbortHandler);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
}
|
package/src/tools/index.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default Tools
|
|
3
|
-
*
|
|
4
|
-
* This module provides a set of configurable default tools for agents.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// Zod Utilities
|
|
8
|
-
export { validateWithZod, zodToJsonSchema } from "@clinebot/shared";
|
|
9
|
-
// Constants
|
|
10
|
-
export { ALL_DEFAULT_TOOL_NAMES, DefaultToolNames } from "./constants.js";
|
|
11
|
-
// Tool Definitions
|
|
12
|
-
export {
|
|
13
|
-
createApplyPatchTool,
|
|
14
|
-
createAskQuestionTool,
|
|
15
|
-
createBashTool,
|
|
16
|
-
createDefaultTools,
|
|
17
|
-
createEditorTool,
|
|
18
|
-
createReadFilesTool,
|
|
19
|
-
createSearchTool,
|
|
20
|
-
createSkillsTool,
|
|
21
|
-
createWebFetchTool,
|
|
22
|
-
} from "./definitions.js";
|
|
23
|
-
// Built-in Executors
|
|
24
|
-
export {
|
|
25
|
-
type ApplyPatchExecutorOptions,
|
|
26
|
-
type BashExecutorOptions,
|
|
27
|
-
createApplyPatchExecutor,
|
|
28
|
-
createBashExecutor,
|
|
29
|
-
createDefaultExecutors,
|
|
30
|
-
createEditorExecutor,
|
|
31
|
-
createFileReadExecutor,
|
|
32
|
-
createSearchExecutor,
|
|
33
|
-
createWebFetchExecutor,
|
|
34
|
-
type DefaultExecutorsOptions,
|
|
35
|
-
type EditorExecutorOptions,
|
|
36
|
-
type FileReadExecutorOptions,
|
|
37
|
-
type SearchExecutorOptions,
|
|
38
|
-
type WebFetchExecutorOptions,
|
|
39
|
-
} from "./executors/index.js";
|
|
40
|
-
export {
|
|
41
|
-
DEFAULT_MODEL_TOOL_ROUTING_RULES,
|
|
42
|
-
resolveToolRoutingConfig,
|
|
43
|
-
type ToolRoutingRule,
|
|
44
|
-
} from "./model-tool-routing.js";
|
|
45
|
-
// Presets
|
|
46
|
-
export {
|
|
47
|
-
createDefaultToolsWithPreset,
|
|
48
|
-
createToolPoliciesWithPreset,
|
|
49
|
-
type ToolPolicyPresetName,
|
|
50
|
-
type ToolPresetName,
|
|
51
|
-
ToolPresets,
|
|
52
|
-
} from "./presets.js";
|
|
53
|
-
// Schemas
|
|
54
|
-
export {
|
|
55
|
-
type ApplyPatchInput,
|
|
56
|
-
ApplyPatchInputSchema,
|
|
57
|
-
type AskQuestionInput,
|
|
58
|
-
AskQuestionInputSchema,
|
|
59
|
-
type EditFileInput,
|
|
60
|
-
EditFileInputSchema,
|
|
61
|
-
type FetchWebContentInput,
|
|
62
|
-
FetchWebContentInputSchema,
|
|
63
|
-
type ReadFileRequest,
|
|
64
|
-
ReadFileRequestSchema,
|
|
65
|
-
type ReadFilesInput,
|
|
66
|
-
ReadFilesInputSchema,
|
|
67
|
-
type RunCommandsInput,
|
|
68
|
-
RunCommandsInputSchema,
|
|
69
|
-
type SearchCodebaseInput,
|
|
70
|
-
SearchCodebaseInputSchema,
|
|
71
|
-
type SkillsInput,
|
|
72
|
-
SkillsInputSchema,
|
|
73
|
-
type WebFetchRequest,
|
|
74
|
-
WebFetchRequestSchema,
|
|
75
|
-
} from "./schemas.js";
|
|
76
|
-
// Types
|
|
77
|
-
export type {
|
|
78
|
-
ApplyPatchExecutor,
|
|
79
|
-
AskQuestionExecutor,
|
|
80
|
-
BashExecutor,
|
|
81
|
-
CreateDefaultToolsOptions,
|
|
82
|
-
DefaultToolName,
|
|
83
|
-
DefaultToolsConfig,
|
|
84
|
-
EditorExecutor,
|
|
85
|
-
FileReadExecutor,
|
|
86
|
-
SearchExecutor,
|
|
87
|
-
SkillsExecutor,
|
|
88
|
-
SkillsExecutorSkillMetadata,
|
|
89
|
-
SkillsExecutorWithMetadata,
|
|
90
|
-
ToolExecutors,
|
|
91
|
-
ToolOperationResult,
|
|
92
|
-
WebFetchExecutor,
|
|
93
|
-
} from "./types.js";
|
|
94
|
-
|
|
95
|
-
// =============================================================================
|
|
96
|
-
// Convenience: Create Tools with Built-in Executors
|
|
97
|
-
// =============================================================================
|
|
98
|
-
|
|
99
|
-
import type { Tool } from "@clinebot/agents";
|
|
100
|
-
import { createDefaultTools } from "./definitions.js";
|
|
101
|
-
import {
|
|
102
|
-
createDefaultExecutors,
|
|
103
|
-
type DefaultExecutorsOptions,
|
|
104
|
-
} from "./executors/index.js";
|
|
105
|
-
import type { CreateDefaultToolsOptions, ToolExecutors } from "./types.js";
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Options for creating default tools with built-in executors
|
|
109
|
-
*/
|
|
110
|
-
export interface CreateBuiltinToolsOptions
|
|
111
|
-
extends Omit<CreateDefaultToolsOptions, "executors"> {
|
|
112
|
-
/**
|
|
113
|
-
* Configuration for the built-in executors
|
|
114
|
-
*/
|
|
115
|
-
executorOptions?: DefaultExecutorsOptions;
|
|
116
|
-
/**
|
|
117
|
-
* Optional executor overrides/additions for tools without built-ins
|
|
118
|
-
*/
|
|
119
|
-
executors?: Partial<ToolExecutors>;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Create default tools with built-in Node.js executors
|
|
124
|
-
*
|
|
125
|
-
* This is a convenience function that creates the default tools with
|
|
126
|
-
* working implementations using Node.js built-in modules.
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* ```typescript
|
|
130
|
-
* import { Agent } from "@clinebot/agents"
|
|
131
|
-
* import { createBuiltinTools } from "@clinebot/core/node"
|
|
132
|
-
*
|
|
133
|
-
* const tools = createBuiltinTools({
|
|
134
|
-
* cwd: "/path/to/project",
|
|
135
|
-
* enableBash: true,
|
|
136
|
-
* enableWebFetch: false, // Disable web fetching
|
|
137
|
-
* executorOptions: {
|
|
138
|
-
* bash: { timeoutMs: 60000 },
|
|
139
|
-
* },
|
|
140
|
-
* })
|
|
141
|
-
*
|
|
142
|
-
* const agent = new Agent({
|
|
143
|
-
* providerId: "anthropic",
|
|
144
|
-
* modelId: "claude-sonnet-4-20250514",
|
|
145
|
-
* systemPrompt: "You are a coding assistant.",
|
|
146
|
-
* tools,
|
|
147
|
-
* })
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
export function createBuiltinTools(
|
|
151
|
-
options: CreateBuiltinToolsOptions = {},
|
|
152
|
-
): Tool[] {
|
|
153
|
-
const {
|
|
154
|
-
executorOptions = {},
|
|
155
|
-
executors: executorOverrides,
|
|
156
|
-
...toolsConfig
|
|
157
|
-
} = options;
|
|
158
|
-
|
|
159
|
-
const executors = {
|
|
160
|
-
...createDefaultExecutors(executorOptions),
|
|
161
|
-
...(executorOverrides ?? {}),
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
return createDefaultTools({
|
|
165
|
-
...toolsConfig,
|
|
166
|
-
executors,
|
|
167
|
-
});
|
|
168
|
-
}
|