@clinebot/core 0.0.35 → 0.0.36
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 +1 -2
- package/dist/ClineCore.d.ts +53 -39
- package/dist/ClineCore.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 +6 -6
- package/dist/account/rpc.d.ts.map +1 -1
- package/dist/cron/index.d.ts +6 -0
- package/dist/cron/index.d.ts.map +1 -0
- package/dist/cron/resource-limiter.d.ts +9 -0
- package/dist/cron/resource-limiter.d.ts.map +1 -0
- package/dist/cron/schedule-command-service.d.ts +10 -0
- package/dist/cron/schedule-command-service.d.ts.map +1 -0
- package/dist/cron/schedule-service.d.ts +100 -0
- package/dist/cron/schedule-service.d.ts.map +1 -0
- package/dist/cron/scheduler.d.ts +66 -0
- package/dist/cron/scheduler.d.ts.map +1 -0
- package/dist/cron/sqlite-schedule-store.d.ts +52 -0
- package/dist/cron/sqlite-schedule-store.d.ts.map +1 -0
- package/dist/extensions/config/agent-config-loader.d.ts +4 -3
- package/dist/extensions/config/agent-config-loader.d.ts.map +1 -1
- package/dist/extensions/config/runtime-commands.d.ts +1 -0
- package/dist/extensions/config/runtime-commands.d.ts.map +1 -1
- package/dist/extensions/config/user-instruction-config-loader.d.ts +1 -0
- package/dist/extensions/config/user-instruction-config-loader.d.ts.map +1 -1
- package/dist/extensions/context/agentic-compaction.d.ts +2 -2
- package/dist/extensions/context/agentic-compaction.d.ts.map +1 -1
- package/dist/extensions/context/compaction-shared.d.ts +5 -4
- package/dist/extensions/context/compaction-shared.d.ts.map +1 -1
- package/dist/extensions/context/compaction.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-config-loader.d.ts +9 -2
- package/dist/extensions/plugin/plugin-config-loader.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-loader.d.ts +5 -3
- package/dist/extensions/plugin/plugin-loader.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-module-import.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-sandbox.d.ts +15 -2
- package/dist/extensions/plugin/plugin-sandbox.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-targeting.d.ts +7 -0
- package/dist/extensions/plugin/plugin-targeting.d.ts.map +1 -0
- package/dist/extensions/plugin-sandbox-bootstrap.js +211 -211
- package/dist/extensions/tools/definitions.d.ts +1 -1
- package/dist/extensions/tools/definitions.d.ts.map +1 -1
- package/dist/extensions/tools/executors/apply-patch.d.ts +3 -1
- package/dist/extensions/tools/executors/apply-patch.d.ts.map +1 -1
- package/dist/extensions/tools/executors/search.d.ts +1 -1
- package/dist/extensions/tools/executors/search.d.ts.map +1 -1
- package/dist/extensions/tools/index.d.ts +2 -0
- package/dist/extensions/tools/index.d.ts.map +1 -1
- package/dist/extensions/tools/presets.d.ts +26 -43
- package/dist/extensions/tools/presets.d.ts.map +1 -1
- package/dist/extensions/tools/runtime.d.ts +25 -0
- package/dist/extensions/tools/runtime.d.ts.map +1 -0
- package/dist/extensions/tools/schemas.d.ts.map +1 -1
- package/dist/extensions/tools/team/team-tools.d.ts +1 -0
- package/dist/extensions/tools/team/team-tools.d.ts.map +1 -1
- package/dist/hooks/hook-file-hooks.d.ts +4 -1
- package/dist/hooks/hook-file-hooks.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/subprocess.d.ts +8 -1
- package/dist/hooks/subprocess.d.ts.map +1 -1
- package/dist/hub/browser-websocket.d.ts +18 -0
- package/dist/hub/browser-websocket.d.ts.map +1 -0
- package/dist/hub/client.d.ts +45 -0
- package/dist/hub/client.d.ts.map +1 -0
- package/dist/hub/connect.d.ts +15 -0
- package/dist/hub/connect.d.ts.map +1 -0
- package/dist/hub/daemon-entry.d.ts +2 -0
- package/dist/hub/daemon-entry.d.ts.map +1 -0
- package/dist/hub/daemon-entry.js +1045 -0
- package/dist/hub/daemon.d.ts +5 -0
- package/dist/hub/daemon.d.ts.map +1 -0
- package/dist/hub/defaults.d.ts +13 -0
- package/dist/hub/defaults.d.ts.map +1 -0
- package/dist/hub/discovery.d.ts +29 -0
- package/dist/hub/discovery.d.ts.map +1 -0
- package/dist/hub/index.d.ts +15 -0
- package/dist/hub/index.d.ts.map +1 -0
- package/dist/hub/index.js +1044 -0
- package/dist/hub/native-transport.d.ts +17 -0
- package/dist/hub/native-transport.d.ts.map +1 -0
- package/dist/hub/runtime-handlers.d.ts +11 -0
- package/dist/hub/runtime-handlers.d.ts.map +1 -0
- package/dist/hub/server.d.ts +86 -0
- package/dist/hub/server.d.ts.map +1 -0
- package/dist/hub/session-client.d.ts +87 -0
- package/dist/hub/session-client.d.ts.map +1 -0
- package/dist/hub/start-shared-server.d.ts +19 -0
- package/dist/hub/start-shared-server.d.ts.map +1 -0
- package/dist/hub/transport.d.ts +8 -0
- package/dist/hub/transport.d.ts.map +1 -0
- package/dist/hub/ui-client.d.ts +44 -0
- package/dist/hub/ui-client.d.ts.map +1 -0
- package/dist/hub/workspace.d.ts +4 -0
- package/dist/hub/workspace.d.ts.map +1 -0
- package/dist/index.d.ts +26 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +498 -476
- package/dist/llms/configured-provider-registry.d.ts +28 -0
- package/dist/llms/configured-provider-registry.d.ts.map +1 -0
- package/dist/llms/provider-defaults.d.ts +27 -0
- package/dist/llms/provider-defaults.d.ts.map +1 -0
- package/dist/llms/provider-settings.d.ts +202 -0
- package/dist/llms/provider-settings.d.ts.map +1 -0
- package/dist/llms/runtime-config.d.ts +4 -0
- package/dist/llms/runtime-config.d.ts.map +1 -0
- package/dist/llms/runtime-registry.d.ts +20 -0
- package/dist/llms/runtime-registry.d.ts.map +1 -0
- package/dist/llms/runtime-types.d.ts +85 -0
- package/dist/llms/runtime-types.d.ts.map +1 -0
- package/dist/runtime/host.d.ts +1 -2
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/rules.d.ts +1 -0
- package/dist/runtime/rules.d.ts.map +1 -1
- package/dist/runtime/runtime-builder.d.ts.map +1 -1
- package/dist/runtime/runtime-host.d.ts +22 -24
- package/dist/runtime/runtime-host.d.ts.map +1 -1
- package/dist/runtime/runtime-oauth-token-manager.d.ts.map +1 -1
- package/dist/runtime/session-runtime.d.ts +1 -19
- package/dist/runtime/session-runtime.d.ts.map +1 -1
- package/dist/services/global-settings.d.ts +12 -0
- package/dist/services/global-settings.d.ts.map +1 -0
- package/dist/services/local-runtime-bootstrap.d.ts +9 -3
- package/dist/services/local-runtime-bootstrap.d.ts.map +1 -1
- package/dist/services/plugin-tools.d.ts +16 -0
- package/dist/services/plugin-tools.d.ts.map +1 -0
- package/dist/services/providers/local-provider-registry.d.ts +4 -4
- package/dist/services/providers/local-provider-registry.d.ts.map +1 -1
- package/dist/services/providers/local-provider-service.d.ts +13 -13
- package/dist/services/providers/local-provider-service.d.ts.map +1 -1
- package/dist/services/session-data.d.ts +1 -1
- package/dist/services/session-data.d.ts.map +1 -1
- package/dist/services/storage/provider-settings-legacy-migration.d.ts +1 -1
- package/dist/services/storage/provider-settings-legacy-migration.d.ts.map +1 -1
- package/dist/services/telemetry/index.js +28 -15
- package/dist/services/workspace-manifest.d.ts +11 -0
- package/dist/services/workspace-manifest.d.ts.map +1 -1
- package/dist/session/persistence-service.d.ts +11 -23
- package/dist/session/persistence-service.d.ts.map +1 -1
- package/dist/session/session-manifest-store.d.ts +22 -0
- package/dist/session/session-manifest-store.d.ts.map +1 -0
- package/dist/session/session-row.d.ts +93 -0
- package/dist/session/session-row.d.ts.map +1 -0
- package/dist/session/session-service.d.ts +2 -102
- package/dist/session/session-service.d.ts.map +1 -1
- package/dist/session/subagent-session-manager.d.ts +36 -0
- package/dist/session/subagent-session-manager.d.ts.map +1 -0
- package/dist/session/team-persistence-store.d.ts +24 -0
- package/dist/session/team-persistence-store.d.ts.map +1 -0
- package/dist/transports/hub.d.ts +47 -0
- package/dist/transports/hub.d.ts.map +1 -0
- package/dist/transports/local.d.ts +10 -6
- package/dist/transports/local.d.ts.map +1 -1
- package/dist/transports/remote.d.ts +10 -0
- package/dist/transports/remote.d.ts.map +1 -0
- package/dist/transports/runtime-host-support.d.ts +3 -2
- package/dist/transports/runtime-host-support.d.ts.map +1 -1
- package/dist/types/chat-schema.d.ts +10 -12
- package/dist/types/chat-schema.d.ts.map +1 -1
- package/dist/types/config.d.ts +8 -7
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/provider-settings.d.ts +4 -5
- package/dist/types/provider-settings.d.ts.map +1 -1
- package/dist/types/session.d.ts +2 -1
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +20 -6
- package/src/ClineCore.ts +68 -40
- package/src/account/index.ts +3 -3
- package/src/account/rpc.ts +12 -12
- package/src/cron/index.ts +5 -0
- package/src/cron/resource-limiter.ts +46 -0
- package/src/cron/schedule-command-service.ts +193 -0
- package/src/cron/schedule-service.ts +703 -0
- package/src/cron/scheduler.ts +637 -0
- package/src/cron/sqlite-schedule-store.ts +708 -0
- package/src/extensions/config/agent-config-loader.ts +17 -7
- package/src/extensions/config/runtime-commands.ts +6 -0
- package/src/extensions/config/user-instruction-config-loader.ts +1 -0
- package/src/extensions/context/agentic-compaction.ts +3 -3
- package/src/extensions/context/basic-compaction.ts +2 -2
- package/src/extensions/context/compaction-shared.ts +5 -4
- package/src/extensions/context/compaction.ts +3 -3
- package/src/extensions/plugin/plugin-config-loader.ts +17 -2
- package/src/extensions/plugin/plugin-loader.ts +48 -4
- package/src/extensions/plugin/plugin-module-import.ts +0 -2
- package/src/extensions/plugin/plugin-sandbox-bootstrap.ts +93 -39
- package/src/extensions/plugin/plugin-sandbox.ts +47 -27
- package/src/extensions/plugin/plugin-targeting.ts +32 -0
- package/src/extensions/tools/definitions.ts +30 -49
- package/src/extensions/tools/executors/apply-patch.ts +69 -80
- package/src/extensions/tools/executors/search.ts +195 -3
- package/src/extensions/tools/index.ts +10 -0
- package/src/extensions/tools/presets.ts +31 -46
- package/src/extensions/tools/runtime.ts +261 -0
- package/src/extensions/tools/schemas.ts +4 -2
- package/src/extensions/tools/team/team-tools.ts +21 -0
- package/src/hooks/hook-file-hooks.ts +8 -2
- package/src/hooks/index.ts +0 -7
- package/src/hooks/subprocess-runner.ts +1 -1
- package/src/hooks/subprocess.ts +9 -0
- package/src/hub/browser-websocket.ts +137 -0
- package/src/hub/client.ts +574 -0
- package/src/hub/connect.ts +156 -0
- package/src/hub/daemon-entry.ts +87 -0
- package/src/hub/daemon.ts +181 -0
- package/src/hub/defaults.ts +43 -0
- package/src/hub/discovery.ts +247 -0
- package/src/hub/index.ts +14 -0
- package/src/hub/native-transport.ts +31 -0
- package/src/hub/runtime-handlers.ts +140 -0
- package/src/hub/server.ts +1888 -0
- package/src/hub/session-client.ts +460 -0
- package/src/hub/start-shared-server.ts +58 -0
- package/src/hub/transport.ts +14 -0
- package/src/hub/ui-client.ts +122 -0
- package/src/hub/workspace.ts +19 -0
- package/src/index.ts +124 -68
- package/src/llms/configured-provider-registry.ts +193 -0
- package/src/llms/provider-defaults.ts +637 -0
- package/src/llms/provider-settings.ts +263 -0
- package/src/llms/runtime-config.ts +43 -0
- package/src/llms/runtime-registry.ts +171 -0
- package/src/llms/runtime-types.ts +121 -0
- package/src/runtime/host.ts +107 -269
- package/src/runtime/index.ts +1 -0
- package/src/runtime/rules.ts +12 -0
- package/src/runtime/runtime-builder.ts +24 -8
- package/src/runtime/runtime-host.ts +89 -61
- package/src/runtime/runtime-oauth-token-manager.ts +11 -15
- package/src/runtime/session-runtime.ts +0 -24
- package/src/services/global-settings.ts +122 -0
- package/src/services/local-runtime-bootstrap.ts +51 -13
- package/src/services/plugin-tools.ts +85 -0
- package/src/services/providers/local-provider-registry.ts +6 -6
- package/src/services/providers/local-provider-service.ts +42 -37
- package/src/services/session-data.ts +15 -9
- package/src/services/storage/provider-settings-legacy-migration.ts +6 -4
- package/src/services/storage/provider-settings-manager.ts +1 -1
- package/src/services/workspace-manifest.ts +18 -0
- package/src/session/file-session-service.ts +1 -1
- package/src/session/index.ts +6 -27
- package/src/session/persistence-service.ts +119 -504
- package/src/session/session-manifest-store.ts +158 -0
- package/src/session/session-row.ts +199 -0
- package/src/session/session-service.ts +17 -376
- package/src/session/session-team-coordination.ts +1 -1
- package/src/session/subagent-session-manager.ts +397 -0
- package/src/session/team-persistence-store.ts +176 -0
- package/src/transports/hub.ts +656 -0
- package/src/transports/local.ts +135 -40
- package/src/transports/remote.ts +26 -0
- package/src/transports/runtime-host-support.ts +63 -9
- package/src/types/chat-schema.ts +4 -5
- package/src/types/config.ts +8 -7
- package/src/types/provider-settings.ts +11 -7
- package/src/types/session.ts +2 -4
- package/src/types.ts +27 -1
- package/dist/hooks/persistent.d.ts +0 -64
- package/dist/hooks/persistent.d.ts.map +0 -1
- package/dist/runtime/rpc-runtime-ensure.d.ts +0 -65
- package/dist/runtime/rpc-runtime-ensure.d.ts.map +0 -1
- package/dist/runtime/rpc-spawn-lease.d.ts +0 -8
- package/dist/runtime/rpc-spawn-lease.d.ts.map +0 -1
- package/dist/session/rpc-session-service.d.ts +0 -16
- package/dist/session/rpc-session-service.d.ts.map +0 -1
- package/dist/session/sqlite-rpc-session-backend.d.ts +0 -31
- package/dist/session/sqlite-rpc-session-backend.d.ts.map +0 -1
- package/dist/transports/rpc.d.ts +0 -51
- package/dist/transports/rpc.d.ts.map +0 -1
- package/src/ClineCore.test.ts +0 -226
- package/src/account/cline-account-service.test.ts +0 -185
- package/src/account/featurebase-token.test.ts +0 -175
- package/src/account/rpc.test.ts +0 -63
- package/src/auth/bounded-ttl-cache.test.ts +0 -38
- package/src/auth/client.test.ts +0 -69
- package/src/auth/cline.test.ts +0 -267
- package/src/auth/codex.test.ts +0 -170
- package/src/auth/oca.test.ts +0 -340
- package/src/auth/server.test.ts +0 -287
- package/src/auth/utils.test.ts +0 -128
- package/src/extensions/config/agent-config-loader.test.ts +0 -236
- package/src/extensions/config/hooks-config-loader.test.ts +0 -20
- package/src/extensions/config/runtime-commands.test.ts +0 -115
- package/src/extensions/config/unified-config-file-watcher.test.ts +0 -196
- package/src/extensions/config/user-instruction-config-loader.test.ts +0 -246
- package/src/extensions/context/compaction.test.ts +0 -483
- package/src/extensions/mcp/config-loader.test.ts +0 -238
- package/src/extensions/mcp/manager.test.ts +0 -105
- package/src/extensions/plugin/plugin-config-loader.test.ts +0 -184
- package/src/extensions/plugin/plugin-loader.test.ts +0 -292
- package/src/extensions/plugin/plugin-sandbox.test.ts +0 -423
- package/src/extensions/tools/definitions.test.ts +0 -780
- package/src/extensions/tools/executors/bash.test.ts +0 -87
- package/src/extensions/tools/executors/editor.test.ts +0 -35
- package/src/extensions/tools/executors/file-read.test.ts +0 -125
- package/src/extensions/tools/model-tool-routing.test.ts +0 -86
- package/src/extensions/tools/presets.test.ts +0 -70
- package/src/extensions/tools/team/multi-agent.lifecycle.test.ts +0 -455
- package/src/extensions/tools/team/spawn-agent-tool.test.ts +0 -381
- package/src/extensions/tools/team/team-tools.test.ts +0 -918
- package/src/hooks/checkpoint-hooks.test.ts +0 -168
- package/src/hooks/hook-file-hooks.test.ts +0 -311
- package/src/hooks/persistent.ts +0 -661
- package/src/runtime/history.test.ts +0 -114
- package/src/runtime/host.test.ts +0 -230
- package/src/runtime/rpc-runtime-ensure.test.ts +0 -123
- package/src/runtime/rpc-runtime-ensure.ts +0 -659
- package/src/runtime/rpc-spawn-lease.test.ts +0 -81
- package/src/runtime/rpc-spawn-lease.ts +0 -156
- package/src/runtime/runtime-builder.team-persistence.test.ts +0 -245
- package/src/runtime/runtime-builder.test.ts +0 -615
- package/src/runtime/runtime-oauth-token-manager.test.ts +0 -137
- package/src/runtime/runtime-parity.test.ts +0 -143
- package/src/services/providers/local-provider-service.test.ts +0 -1062
- package/src/services/session-data.test.ts +0 -160
- package/src/services/storage/provider-settings-legacy-migration.test.ts +0 -424
- package/src/services/storage/provider-settings-manager.test.ts +0 -191
- package/src/services/telemetry/OpenTelemetryAdapter.test.ts +0 -157
- package/src/services/telemetry/OpenTelemetryProvider.test.ts +0 -326
- package/src/services/telemetry/TelemetryLoggerSink.test.ts +0 -42
- package/src/services/telemetry/TelemetryService.test.ts +0 -134
- package/src/services/telemetry/distinct-id.test.ts +0 -57
- package/src/services/workspace/file-indexer.d.ts +0 -11
- package/src/services/workspace/file-indexer.test.ts +0 -156
- package/src/services/workspace/mention-enricher.test.ts +0 -106
- package/src/session/persistence-service.test.ts +0 -300
- package/src/session/rpc-session-service.ts +0 -114
- package/src/session/session-service.team-persistence.test.ts +0 -48
- package/src/session/sqlite-rpc-session-backend.ts +0 -301
- package/src/transports/local.e2e.test.ts +0 -380
- package/src/transports/local.test.ts +0 -2559
- package/src/transports/rpc.test.ts +0 -82
- package/src/transports/rpc.ts +0 -665
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Search Executor
|
|
3
3
|
*
|
|
4
|
-
* Built-in implementation for searching the codebase using regex.
|
|
4
|
+
* Built-in implementation for searching the codebase using ripgrep (if available) or regex.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
7
8
|
import * as fs from "node:fs/promises";
|
|
8
9
|
import * as path from "node:path";
|
|
9
10
|
import type { ToolContext } from "@clinebot/shared";
|
|
@@ -118,6 +119,152 @@ interface SearchMatch {
|
|
|
118
119
|
context: string[];
|
|
119
120
|
}
|
|
120
121
|
|
|
122
|
+
let rgAvailable: boolean | null = null;
|
|
123
|
+
|
|
124
|
+
function checkRipgrepAvailable(): Promise<boolean> {
|
|
125
|
+
if (rgAvailable !== null) {
|
|
126
|
+
return Promise.resolve(rgAvailable);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return new Promise((resolve) => {
|
|
130
|
+
const child = spawn("rg", ["--version"], {
|
|
131
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
child.on("close", (code) => {
|
|
135
|
+
rgAvailable = code === 0;
|
|
136
|
+
resolve(rgAvailable);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
child.on("error", () => {
|
|
140
|
+
rgAvailable = false;
|
|
141
|
+
resolve(false);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
setTimeout(() => {
|
|
145
|
+
if (!child.killed) {
|
|
146
|
+
child.kill("SIGTERM");
|
|
147
|
+
}
|
|
148
|
+
if (rgAvailable === null) {
|
|
149
|
+
rgAvailable = false;
|
|
150
|
+
resolve(false);
|
|
151
|
+
}
|
|
152
|
+
}, 1000);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function searchWithRipgrep(
|
|
157
|
+
query: string,
|
|
158
|
+
cwd: string,
|
|
159
|
+
maxResults: number,
|
|
160
|
+
contextLines: number,
|
|
161
|
+
timeoutMs: number = 5000,
|
|
162
|
+
abortSignal?: AbortSignal,
|
|
163
|
+
): Promise<SearchMatch[] | null> {
|
|
164
|
+
return new Promise((resolve) => {
|
|
165
|
+
const child = spawn(
|
|
166
|
+
"rg",
|
|
167
|
+
["--json", `--context=${contextLines}`, "--max-count=1", "-i", query],
|
|
168
|
+
{
|
|
169
|
+
cwd,
|
|
170
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
171
|
+
},
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
let stdout = "";
|
|
175
|
+
let resolved = false;
|
|
176
|
+
|
|
177
|
+
const cleanup = () => {
|
|
178
|
+
if (!child.killed) {
|
|
179
|
+
child.kill("SIGTERM");
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const timeout = setTimeout(() => {
|
|
184
|
+
if (!resolved) {
|
|
185
|
+
resolved = true;
|
|
186
|
+
cleanup();
|
|
187
|
+
resolve(null);
|
|
188
|
+
}
|
|
189
|
+
}, timeoutMs);
|
|
190
|
+
|
|
191
|
+
const finalize = (result: SearchMatch[] | null) => {
|
|
192
|
+
if (!resolved) {
|
|
193
|
+
resolved = true;
|
|
194
|
+
clearTimeout(timeout);
|
|
195
|
+
cleanup();
|
|
196
|
+
resolve(result);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
if (abortSignal?.aborted) {
|
|
201
|
+
cleanup();
|
|
202
|
+
resolve(null);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
abortSignal?.addEventListener("abort", () => {
|
|
207
|
+
finalize(null);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
child.stdout.on("data", (chunk: Buffer | string) => {
|
|
211
|
+
stdout += chunk.toString();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
child.stderr.on("data", () => {
|
|
215
|
+
// Ignore stderr
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
child.on("close", (code: number | null) => {
|
|
219
|
+
if (code === 0 || code === 1) {
|
|
220
|
+
try {
|
|
221
|
+
const matches: SearchMatch[] = [];
|
|
222
|
+
const lines = stdout.split("\n").filter((line) => line.trim());
|
|
223
|
+
|
|
224
|
+
for (const line of lines) {
|
|
225
|
+
if (matches.length >= maxResults) break;
|
|
226
|
+
|
|
227
|
+
const json = JSON.parse(line);
|
|
228
|
+
if (json.type === "match") {
|
|
229
|
+
const matchData = json.data;
|
|
230
|
+
const contextLines: string[] = [];
|
|
231
|
+
|
|
232
|
+
if (json.data.submatches && json.data.submatches.length > 0) {
|
|
233
|
+
const submatch = json.data.submatches[0];
|
|
234
|
+
matches.push({
|
|
235
|
+
file: matchData.path.text,
|
|
236
|
+
line: matchData.line_number,
|
|
237
|
+
column: (submatch?.start ?? 0) + 1,
|
|
238
|
+
match: submatch?.match?.text ?? "",
|
|
239
|
+
context: contextLines,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
} else if (json.type === "context" && matches.length > 0) {
|
|
243
|
+
const lastMatch = matches[matches.length - 1];
|
|
244
|
+
const prefix =
|
|
245
|
+
json.data.line_number === lastMatch.line ? ">" : " ";
|
|
246
|
+
lastMatch.context.push(
|
|
247
|
+
`${prefix} ${json.data.line_number}: ${json.data.lines?.text ?? json.data.line?.text ?? ""}`,
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
finalize(matches.length > 0 ? matches : null);
|
|
253
|
+
} catch {
|
|
254
|
+
finalize(null);
|
|
255
|
+
}
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
finalize(null);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
child.on("error", () => {
|
|
263
|
+
finalize(null);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
121
268
|
function shouldIncludeFile(
|
|
122
269
|
relativePath: string,
|
|
123
270
|
excludeDirs: Set<string>,
|
|
@@ -173,9 +320,49 @@ export function createSearchExecutor(
|
|
|
173
320
|
return async (
|
|
174
321
|
query: string,
|
|
175
322
|
cwd: string,
|
|
176
|
-
|
|
323
|
+
context: ToolContext,
|
|
177
324
|
): Promise<string> => {
|
|
178
|
-
//
|
|
325
|
+
// Check for abort before starting
|
|
326
|
+
if (context.abortSignal?.aborted) {
|
|
327
|
+
throw new Error("Search operation aborted");
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Try ripgrep first if available
|
|
331
|
+
const isRgAvailable = await checkRipgrepAvailable();
|
|
332
|
+
let rgMatches: SearchMatch[] | null = null;
|
|
333
|
+
if (isRgAvailable) {
|
|
334
|
+
rgMatches = await searchWithRipgrep(
|
|
335
|
+
query,
|
|
336
|
+
cwd,
|
|
337
|
+
maxResults,
|
|
338
|
+
contextLines,
|
|
339
|
+
5000,
|
|
340
|
+
context.abortSignal,
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (rgMatches) {
|
|
345
|
+
const resultLines: string[] = [
|
|
346
|
+
`Found ${rgMatches.length} result${rgMatches.length === 1 ? "" : "s"} for pattern: ${query}`,
|
|
347
|
+
"",
|
|
348
|
+
];
|
|
349
|
+
|
|
350
|
+
for (const match of rgMatches) {
|
|
351
|
+
resultLines.push(`${match.file}:${match.line}:${match.column}`);
|
|
352
|
+
resultLines.push(...match.context);
|
|
353
|
+
resultLines.push("");
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (rgMatches.length >= maxResults) {
|
|
357
|
+
resultLines.push(
|
|
358
|
+
`(Showing first ${maxResults} results. Refine your search for more specific results.)`,
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return resultLines.join("\n");
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Fallback to manual regex search
|
|
179
366
|
let regex: RegExp;
|
|
180
367
|
try {
|
|
181
368
|
regex = new RegExp(query, "gim");
|
|
@@ -192,6 +379,11 @@ export function createSearchExecutor(
|
|
|
192
379
|
|
|
193
380
|
// Search files from the fast index.
|
|
194
381
|
for (const relativePath of fileList) {
|
|
382
|
+
// Check for abort signal
|
|
383
|
+
if (context.abortSignal?.aborted) {
|
|
384
|
+
throw new Error("Search operation aborted");
|
|
385
|
+
}
|
|
386
|
+
|
|
195
387
|
if (
|
|
196
388
|
!shouldIncludeFile(
|
|
197
389
|
relativePath,
|
|
@@ -53,6 +53,15 @@ export {
|
|
|
53
53
|
type ToolPresetName,
|
|
54
54
|
ToolPresets,
|
|
55
55
|
} from "./presets";
|
|
56
|
+
export {
|
|
57
|
+
type BuiltinToolAvailabilityContext,
|
|
58
|
+
getCoreAcpToolNames,
|
|
59
|
+
getCoreBuiltinToolCatalog,
|
|
60
|
+
getCoreDefaultEnabledToolIds,
|
|
61
|
+
getCoreHeadlessToolNames,
|
|
62
|
+
resolveCoreSelectedToolIds,
|
|
63
|
+
type ToolCatalogEntry,
|
|
64
|
+
} from "./runtime";
|
|
56
65
|
// Schemas
|
|
57
66
|
export {
|
|
58
67
|
type ApplyPatchInput,
|
|
@@ -78,6 +87,7 @@ export {
|
|
|
78
87
|
type WebFetchRequest,
|
|
79
88
|
WebFetchRequestSchema,
|
|
80
89
|
} from "./schemas";
|
|
90
|
+
export { TEAM_TOOL_NAMES } from "./team/team-tools";
|
|
81
91
|
// Types
|
|
82
92
|
export type {
|
|
83
93
|
ApplyPatchExecutor,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Pre-configured tool combinations for common use cases.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { Tool, ToolPolicy } from "@clinebot/shared";
|
|
7
|
+
import type { AgentMode, Tool, ToolPolicy } from "@clinebot/shared";
|
|
8
8
|
import { ALL_DEFAULT_TOOL_NAMES } from "./constants";
|
|
9
9
|
import { createDefaultTools } from "./definitions";
|
|
10
10
|
import type { CreateDefaultToolsOptions, DefaultToolsConfig } from "./types";
|
|
@@ -19,91 +19,73 @@ export interface ToolPresetConfig extends DefaultToolsConfig {
|
|
|
19
19
|
*/
|
|
20
20
|
export const ToolPresets = {
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
browser: {
|
|
25
|
-
enableReadFiles: false,
|
|
26
|
-
enableSearch: false,
|
|
27
|
-
enableBash: false,
|
|
28
|
-
enableWebFetch: false,
|
|
29
|
-
enableApplyPatch: false,
|
|
30
|
-
enableEditor: false,
|
|
31
|
-
enableSkills: true,
|
|
32
|
-
enableAskQuestion: true,
|
|
33
|
-
enableSubmitAndExit: false,
|
|
34
|
-
enableSpawnAgent: true,
|
|
35
|
-
enableAgentTeams: true,
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Search-focused tools (read_files + search_codebase)
|
|
40
|
-
* Good for code exploration and analysis agents
|
|
22
|
+
* Act mode (full development tools)
|
|
23
|
+
* Good for coding assistants and task automation
|
|
41
24
|
*/
|
|
42
|
-
|
|
25
|
+
act: {
|
|
43
26
|
enableReadFiles: true,
|
|
44
27
|
enableSearch: true,
|
|
45
|
-
enableBash:
|
|
28
|
+
enableBash: true,
|
|
46
29
|
enableWebFetch: false,
|
|
47
30
|
enableApplyPatch: false,
|
|
48
|
-
enableEditor:
|
|
49
|
-
enableSkills:
|
|
50
|
-
enableAskQuestion:
|
|
31
|
+
enableEditor: true,
|
|
32
|
+
enableSkills: true,
|
|
33
|
+
enableAskQuestion: true,
|
|
51
34
|
enableSubmitAndExit: false,
|
|
52
35
|
enableSpawnAgent: true,
|
|
53
36
|
enableAgentTeams: true,
|
|
54
37
|
},
|
|
55
38
|
|
|
56
39
|
/**
|
|
57
|
-
*
|
|
58
|
-
* Good for
|
|
40
|
+
* Plan mode (read-only, no shell access)
|
|
41
|
+
* Good for analysis and documentation agents
|
|
59
42
|
*/
|
|
60
|
-
|
|
43
|
+
plan: {
|
|
61
44
|
enableReadFiles: true,
|
|
62
45
|
enableSearch: true,
|
|
63
46
|
enableBash: true,
|
|
64
47
|
enableWebFetch: true,
|
|
65
48
|
enableApplyPatch: false,
|
|
66
|
-
enableEditor:
|
|
49
|
+
enableEditor: false,
|
|
67
50
|
enableSkills: true,
|
|
68
51
|
enableAskQuestion: true,
|
|
69
|
-
enableSubmitAndExit:
|
|
52
|
+
enableSubmitAndExit: false,
|
|
70
53
|
enableSpawnAgent: true,
|
|
71
54
|
enableAgentTeams: true,
|
|
72
55
|
},
|
|
73
56
|
|
|
74
57
|
/**
|
|
75
|
-
*
|
|
76
|
-
* Good for
|
|
58
|
+
* Search-focused tools (read_files + search_codebase)
|
|
59
|
+
* Good for code exploration and analysis agents
|
|
77
60
|
*/
|
|
78
|
-
|
|
61
|
+
search: {
|
|
79
62
|
enableReadFiles: true,
|
|
80
63
|
enableSearch: true,
|
|
81
|
-
enableBash:
|
|
82
|
-
enableWebFetch:
|
|
64
|
+
enableBash: false,
|
|
65
|
+
enableWebFetch: false,
|
|
83
66
|
enableApplyPatch: false,
|
|
84
67
|
enableEditor: false,
|
|
85
|
-
enableSkills:
|
|
86
|
-
enableAskQuestion:
|
|
68
|
+
enableSkills: false,
|
|
69
|
+
enableAskQuestion: false,
|
|
87
70
|
enableSubmitAndExit: false,
|
|
88
71
|
enableSpawnAgent: true,
|
|
89
72
|
enableAgentTeams: true,
|
|
90
73
|
},
|
|
91
74
|
|
|
92
75
|
/**
|
|
93
|
-
* Minimal tools
|
|
94
|
-
* Good for focused single-file tasks
|
|
76
|
+
* Minimal tools for focused tasks
|
|
95
77
|
*/
|
|
96
78
|
minimal: {
|
|
97
79
|
enableReadFiles: false,
|
|
98
80
|
enableSearch: false,
|
|
99
|
-
enableBash:
|
|
81
|
+
enableBash: true,
|
|
100
82
|
enableWebFetch: false,
|
|
101
83
|
enableApplyPatch: false,
|
|
102
84
|
enableEditor: false,
|
|
103
85
|
enableSkills: false,
|
|
104
|
-
enableAskQuestion:
|
|
86
|
+
enableAskQuestion: false,
|
|
105
87
|
enableSubmitAndExit: false,
|
|
106
|
-
enableSpawnAgent:
|
|
88
|
+
enableSpawnAgent: true,
|
|
107
89
|
enableAgentTeams: false,
|
|
108
90
|
},
|
|
109
91
|
|
|
@@ -132,12 +114,15 @@ export const ToolPresets = {
|
|
|
132
114
|
export type ToolPresetName = keyof typeof ToolPresets;
|
|
133
115
|
|
|
134
116
|
export function resolveToolPresetName(options: {
|
|
135
|
-
mode?:
|
|
117
|
+
mode?: AgentMode;
|
|
136
118
|
}): ToolPresetName {
|
|
137
119
|
if (options.mode === "plan") {
|
|
138
|
-
return "
|
|
120
|
+
return "plan";
|
|
121
|
+
}
|
|
122
|
+
if (options.mode === "yolo") {
|
|
123
|
+
return "yolo";
|
|
139
124
|
}
|
|
140
|
-
return
|
|
125
|
+
return "act";
|
|
141
126
|
}
|
|
142
127
|
|
|
143
128
|
/**
|
|
@@ -177,7 +162,7 @@ export function createToolPoliciesWithPreset(
|
|
|
177
162
|
*
|
|
178
163
|
* @example
|
|
179
164
|
* ```typescript
|
|
180
|
-
* const tools = createDefaultToolsWithPreset("
|
|
165
|
+
* const tools = createDefaultToolsWithPreset("plan", {
|
|
181
166
|
* executors: {
|
|
182
167
|
* readFile: async ({ path }) => fs.readFile(path, "utf-8"),
|
|
183
168
|
* search: async (query, cwd) => searchFiles(query, cwd),
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import type { CoreAgentMode } from "../../types/config";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_MODEL_TOOL_ROUTING_RULES,
|
|
4
|
+
resolveToolRoutingConfig,
|
|
5
|
+
} from "./model-tool-routing";
|
|
6
|
+
import { resolveToolPresetName, ToolPresets } from "./presets";
|
|
7
|
+
import { createSpawnAgentTool } from "./team/spawn-agent-tool";
|
|
8
|
+
import { TEAM_TOOL_NAMES } from "./team/team-tools";
|
|
9
|
+
import type { DefaultToolsConfig } from "./types";
|
|
10
|
+
|
|
11
|
+
export interface ToolCatalogEntry {
|
|
12
|
+
id: string;
|
|
13
|
+
description: string;
|
|
14
|
+
defaultEnabled: boolean;
|
|
15
|
+
headlessToolNames: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface BuiltinToolAvailabilityContext {
|
|
19
|
+
mode?: CoreAgentMode;
|
|
20
|
+
providerId?: string;
|
|
21
|
+
modelId?: string;
|
|
22
|
+
enableSpawnAgent?: boolean;
|
|
23
|
+
enableAgentTeams?: boolean;
|
|
24
|
+
disabledToolIds?: ReadonlySet<string>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type RuntimeToolCatalogEntry = Omit<ToolCatalogEntry, "defaultEnabled">;
|
|
28
|
+
|
|
29
|
+
const BASE_TOOL_CATALOG: readonly RuntimeToolCatalogEntry[] = [
|
|
30
|
+
{
|
|
31
|
+
id: "read_files",
|
|
32
|
+
description:
|
|
33
|
+
"Read the full content of text or image files at the provided absolute paths, or return only an inclusive one-based line range when start_line/end_line are provided.",
|
|
34
|
+
headlessToolNames: ["read_files"],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "search_codebase",
|
|
38
|
+
description:
|
|
39
|
+
"Perform regex pattern searches across the codebase for code patterns, definitions, imports, and other text matches.",
|
|
40
|
+
headlessToolNames: ["search_codebase"],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "run_commands",
|
|
44
|
+
description:
|
|
45
|
+
"Run shell commands from the root of the workspace for listing files, checking git status, builds, tests, and similar tasks.",
|
|
46
|
+
headlessToolNames: ["run_commands"],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "editor",
|
|
50
|
+
description:
|
|
51
|
+
"Make controlled filesystem edits on text files with create, replace, and insert operations.",
|
|
52
|
+
headlessToolNames: ["editor"],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: "fetch_web_content",
|
|
56
|
+
description:
|
|
57
|
+
"Fetch URL content and analyze it with a prompt describing what to extract.",
|
|
58
|
+
headlessToolNames: ["fetch_web_content"],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "skills",
|
|
62
|
+
description:
|
|
63
|
+
"Execute a configured skill within the main conversation when a matching skill exists for the task.",
|
|
64
|
+
headlessToolNames: ["skills"],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: "ask_question",
|
|
68
|
+
description:
|
|
69
|
+
"Ask the user a single clarifying question with 2-5 selectable options.",
|
|
70
|
+
headlessToolNames: ["ask_question"],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: "spawn_agent",
|
|
74
|
+
description: createSpawnAgentTool({ configProvider: {} as never })
|
|
75
|
+
.description,
|
|
76
|
+
headlessToolNames: ["spawn_agent"],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: "teams",
|
|
80
|
+
description:
|
|
81
|
+
"Enable team collaboration tools for teammate management, task coordination, mailbox messaging, mission logs, and outcomes.",
|
|
82
|
+
headlessToolNames: [...TEAM_TOOL_NAMES],
|
|
83
|
+
},
|
|
84
|
+
] as const;
|
|
85
|
+
|
|
86
|
+
const TOOL_NAME_TO_FLAG: Partial<
|
|
87
|
+
Record<
|
|
88
|
+
string,
|
|
89
|
+
keyof Pick<
|
|
90
|
+
DefaultToolsConfig,
|
|
91
|
+
| "enableReadFiles"
|
|
92
|
+
| "enableSearch"
|
|
93
|
+
| "enableBash"
|
|
94
|
+
| "enableWebFetch"
|
|
95
|
+
| "enableApplyPatch"
|
|
96
|
+
| "enableEditor"
|
|
97
|
+
| "enableSkills"
|
|
98
|
+
| "enableAskQuestion"
|
|
99
|
+
| "enableSubmitAndExit"
|
|
100
|
+
>
|
|
101
|
+
>
|
|
102
|
+
> = {
|
|
103
|
+
read_files: "enableReadFiles",
|
|
104
|
+
search_codebase: "enableSearch",
|
|
105
|
+
run_commands: "enableBash",
|
|
106
|
+
fetch_web_content: "enableWebFetch",
|
|
107
|
+
apply_patch: "enableApplyPatch",
|
|
108
|
+
editor: "enableEditor",
|
|
109
|
+
skills: "enableSkills",
|
|
110
|
+
ask_question: "enableAskQuestion",
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
function resolveContextMode(
|
|
114
|
+
mode?: BuiltinToolAvailabilityContext["mode"],
|
|
115
|
+
): CoreAgentMode {
|
|
116
|
+
return mode === "plan" || mode === "yolo" ? mode : "act";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
type ResolvedToolFlags = Pick<
|
|
120
|
+
DefaultToolsConfig,
|
|
121
|
+
| "enableReadFiles"
|
|
122
|
+
| "enableSearch"
|
|
123
|
+
| "enableBash"
|
|
124
|
+
| "enableWebFetch"
|
|
125
|
+
| "enableApplyPatch"
|
|
126
|
+
| "enableEditor"
|
|
127
|
+
| "enableSkills"
|
|
128
|
+
| "enableAskQuestion"
|
|
129
|
+
| "enableSubmitAndExit"
|
|
130
|
+
> & {
|
|
131
|
+
enableSpawnAgent?: boolean;
|
|
132
|
+
enableAgentTeams?: boolean;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
function resolvePresetFlags(context: BuiltinToolAvailabilityContext): {
|
|
136
|
+
mode: CoreAgentMode;
|
|
137
|
+
flags: ResolvedToolFlags;
|
|
138
|
+
} {
|
|
139
|
+
const mode = resolveContextMode(context.mode);
|
|
140
|
+
const preset = ToolPresets[resolveToolPresetName({ mode })];
|
|
141
|
+
const routed = resolveToolRoutingConfig(
|
|
142
|
+
context.providerId ?? "",
|
|
143
|
+
context.modelId ?? "",
|
|
144
|
+
mode,
|
|
145
|
+
DEFAULT_MODEL_TOOL_ROUTING_RULES,
|
|
146
|
+
);
|
|
147
|
+
return {
|
|
148
|
+
mode,
|
|
149
|
+
flags: {
|
|
150
|
+
...preset,
|
|
151
|
+
...routed,
|
|
152
|
+
...(typeof context.enableSpawnAgent === "boolean"
|
|
153
|
+
? { enableSpawnAgent: context.enableSpawnAgent }
|
|
154
|
+
: {}),
|
|
155
|
+
...(typeof context.enableAgentTeams === "boolean"
|
|
156
|
+
? { enableAgentTeams: context.enableAgentTeams }
|
|
157
|
+
: {}),
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function isEntryEnabledByDefault(
|
|
163
|
+
entryId: string,
|
|
164
|
+
context: BuiltinToolAvailabilityContext,
|
|
165
|
+
): boolean {
|
|
166
|
+
if (context.disabledToolIds?.has(entryId)) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const { flags } = resolvePresetFlags(context);
|
|
171
|
+
if (entryId === "spawn_agent") {
|
|
172
|
+
return flags.enableSpawnAgent === true;
|
|
173
|
+
}
|
|
174
|
+
if (entryId === "teams") {
|
|
175
|
+
return flags.enableAgentTeams === true;
|
|
176
|
+
}
|
|
177
|
+
if (entryId === "editor") {
|
|
178
|
+
return flags.enableEditor === true || flags.enableApplyPatch === true;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const flag = TOOL_NAME_TO_FLAG[entryId];
|
|
182
|
+
return flag ? flags[flag] === true : false;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function buildCatalogEntry(
|
|
186
|
+
entry: RuntimeToolCatalogEntry,
|
|
187
|
+
context: BuiltinToolAvailabilityContext,
|
|
188
|
+
): ToolCatalogEntry {
|
|
189
|
+
if (entry.id === "editor") {
|
|
190
|
+
const { flags } = resolvePresetFlags(context);
|
|
191
|
+
const usesApplyPatch =
|
|
192
|
+
flags.enableApplyPatch === true && flags.enableEditor !== true;
|
|
193
|
+
return {
|
|
194
|
+
...entry,
|
|
195
|
+
defaultEnabled: isEntryEnabledByDefault(entry.id, context),
|
|
196
|
+
headlessToolNames: [usesApplyPatch ? "apply_patch" : "editor"],
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
...entry,
|
|
202
|
+
defaultEnabled: isEntryEnabledByDefault(entry.id, context),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function getCoreBuiltinToolCatalog(
|
|
207
|
+
context: BuiltinToolAvailabilityContext = {},
|
|
208
|
+
): ToolCatalogEntry[] {
|
|
209
|
+
return BASE_TOOL_CATALOG.map((entry) => buildCatalogEntry(entry, context));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function getCoreDefaultEnabledToolIds(
|
|
213
|
+
context: BuiltinToolAvailabilityContext = {},
|
|
214
|
+
): string[] {
|
|
215
|
+
return getCoreBuiltinToolCatalog(context)
|
|
216
|
+
.filter((entry) => entry.defaultEnabled)
|
|
217
|
+
.map((entry) => entry.id);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function resolveCoreSelectedToolIds(input: {
|
|
221
|
+
enabled: boolean;
|
|
222
|
+
allowlist?: string[];
|
|
223
|
+
availabilityContext?: BuiltinToolAvailabilityContext;
|
|
224
|
+
}): Set<string> {
|
|
225
|
+
if (!input.enabled) {
|
|
226
|
+
return new Set();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const catalog = getCoreBuiltinToolCatalog(input.availabilityContext);
|
|
230
|
+
const known = new Set(catalog.map((entry) => entry.id));
|
|
231
|
+
if (!input.allowlist || input.allowlist.length === 0) {
|
|
232
|
+
return new Set(
|
|
233
|
+
catalog.filter((entry) => entry.defaultEnabled).map((entry) => entry.id),
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
for (const id of input.allowlist) {
|
|
238
|
+
if (!known.has(id)) {
|
|
239
|
+
throw new Error(
|
|
240
|
+
`Unknown tool "${id}". Available tools: ${catalog.map((entry) => entry.id).join(", ")}`,
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return new Set(input.allowlist);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function getCoreHeadlessToolNames(
|
|
248
|
+
selectedToolIds: ReadonlySet<string>,
|
|
249
|
+
context: BuiltinToolAvailabilityContext = {},
|
|
250
|
+
): string[] {
|
|
251
|
+
return getCoreBuiltinToolCatalog(context)
|
|
252
|
+
.filter((entry) => selectedToolIds.has(entry.id))
|
|
253
|
+
.flatMap((entry) => entry.headlessToolNames);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function getCoreAcpToolNames(
|
|
257
|
+
selectedToolIds: ReadonlySet<string>,
|
|
258
|
+
context: BuiltinToolAvailabilityContext = {},
|
|
259
|
+
): string[] {
|
|
260
|
+
return getCoreHeadlessToolNames(selectedToolIds, context);
|
|
261
|
+
}
|
|
@@ -228,10 +228,12 @@ export const ApplyPatchInputSchema = z
|
|
|
228
228
|
input: z
|
|
229
229
|
.string()
|
|
230
230
|
.min(1)
|
|
231
|
-
.describe(
|
|
231
|
+
.describe(
|
|
232
|
+
"The freeform apply_patch payload in the canonical patch grammar (e.g *** Begin Patch, *** Update File:, @@, and *** End Patch).",
|
|
233
|
+
),
|
|
232
234
|
})
|
|
233
235
|
.describe(
|
|
234
|
-
"Modify or create a text file by applying patches. Prefer
|
|
236
|
+
"Modify or create a text file by applying patches using the canonical apply_patch diff grammar. Prefer sending the patch body directly rather than wrapping it in shell syntax. IMPORTANT: large patches can time out, so use small chunks and multiple calls when possible.",
|
|
235
237
|
);
|
|
236
238
|
export const ApplyPatchInputUnionSchema = z.union([
|
|
237
239
|
ApplyPatchInputSchema,
|
|
@@ -161,6 +161,27 @@ export interface BootstrapAgentTeamsResult {
|
|
|
161
161
|
restoredTeammates: string[];
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
export const TEAM_TOOL_NAMES = [
|
|
165
|
+
"team_spawn_teammate",
|
|
166
|
+
"team_shutdown_teammate",
|
|
167
|
+
"team_status",
|
|
168
|
+
"team_task",
|
|
169
|
+
"team_run_task",
|
|
170
|
+
"team_cancel_run",
|
|
171
|
+
"team_list_runs",
|
|
172
|
+
"team_await_runs",
|
|
173
|
+
"team_send_message",
|
|
174
|
+
"team_broadcast",
|
|
175
|
+
"team_read_mailbox",
|
|
176
|
+
"team_mission_log",
|
|
177
|
+
"team_cleanup",
|
|
178
|
+
"team_create_outcome",
|
|
179
|
+
"team_attach_outcome_fragment",
|
|
180
|
+
"team_review_outcome_fragment",
|
|
181
|
+
"team_finalize_outcome",
|
|
182
|
+
"team_list_outcomes",
|
|
183
|
+
] as const;
|
|
184
|
+
|
|
164
185
|
function spawnTeamTeammate(
|
|
165
186
|
options: Omit<CreateAgentTeamsToolsOptions, "requesterId" | "allowSpawn"> & {
|
|
166
187
|
requesterId: string;
|