@clinebot/core 0.0.20 → 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 +6 -4
- 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,86 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
DEFAULT_MODEL_TOOL_ROUTING_RULES,
|
|
4
|
-
resolveToolRoutingConfig,
|
|
5
|
-
} from "./model-tool-routing.js";
|
|
6
|
-
|
|
7
|
-
describe("model tool routing", () => {
|
|
8
|
-
it("applies default codex/gpt routing in act mode", () => {
|
|
9
|
-
const config = resolveToolRoutingConfig(
|
|
10
|
-
"openai",
|
|
11
|
-
"openai/gpt-5.4",
|
|
12
|
-
"act",
|
|
13
|
-
DEFAULT_MODEL_TOOL_ROUTING_RULES,
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
expect(config.enableApplyPatch).toBe(true);
|
|
17
|
-
expect(config.enableEditor).toBe(false);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("does not apply default codex/gpt routing in plan mode", () => {
|
|
21
|
-
const config = resolveToolRoutingConfig(
|
|
22
|
-
"openai",
|
|
23
|
-
"openai/gpt-5.4",
|
|
24
|
-
"plan",
|
|
25
|
-
DEFAULT_MODEL_TOOL_ROUTING_RULES,
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
expect(config).toEqual({});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("applies matching custom rules in order", () => {
|
|
32
|
-
const config = resolveToolRoutingConfig(
|
|
33
|
-
"anthropic",
|
|
34
|
-
"claude-sonnet-4-6",
|
|
35
|
-
"act",
|
|
36
|
-
[
|
|
37
|
-
{
|
|
38
|
-
name: "claude-editor-off",
|
|
39
|
-
mode: "act",
|
|
40
|
-
modelIdIncludes: ["claude"],
|
|
41
|
-
disableTools: ["editor"],
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: "claude-apply-patch-on",
|
|
45
|
-
mode: "act",
|
|
46
|
-
modelIdIncludes: ["claude"],
|
|
47
|
-
enableTools: ["apply_patch"],
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
expect(config.enableEditor).toBe(false);
|
|
53
|
-
expect(config.enableApplyPatch).toBe(true);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("returns empty config when no rules match", () => {
|
|
57
|
-
const config = resolveToolRoutingConfig(
|
|
58
|
-
"anthropic",
|
|
59
|
-
"claude-sonnet-4-6",
|
|
60
|
-
"act",
|
|
61
|
-
[
|
|
62
|
-
{
|
|
63
|
-
mode: "act",
|
|
64
|
-
modelIdIncludes: ["gpt"],
|
|
65
|
-
enableTools: ["apply_patch"],
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
expect(config).toEqual({});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("can match provider-only rules", () => {
|
|
74
|
-
const config = resolveToolRoutingConfig("openai", "o4-mini", "act", [
|
|
75
|
-
{
|
|
76
|
-
mode: "act",
|
|
77
|
-
providerIdIncludes: ["openai"],
|
|
78
|
-
enableTools: ["apply_patch"],
|
|
79
|
-
disableTools: ["editor"],
|
|
80
|
-
},
|
|
81
|
-
]);
|
|
82
|
-
|
|
83
|
-
expect(config.enableApplyPatch).toBe(true);
|
|
84
|
-
expect(config.enableEditor).toBe(false);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import type { CoreAgentMode } from "../types/config";
|
|
2
|
-
import type { DefaultToolName, DefaultToolsConfig } from "./types.js";
|
|
3
|
-
|
|
4
|
-
export interface ToolRoutingRule {
|
|
5
|
-
/**
|
|
6
|
-
* Optional rule label for debugging and logs.
|
|
7
|
-
*/
|
|
8
|
-
name?: string;
|
|
9
|
-
/**
|
|
10
|
-
* Which mode the rule applies to.
|
|
11
|
-
* @default "any"
|
|
12
|
-
*/
|
|
13
|
-
mode?: CoreAgentMode | "any";
|
|
14
|
-
/**
|
|
15
|
-
* Case-insensitive substrings that must match the model ID.
|
|
16
|
-
* When omitted/empty, the rule is not constrained by model ID.
|
|
17
|
-
*/
|
|
18
|
-
modelIdIncludes?: string[];
|
|
19
|
-
/**
|
|
20
|
-
* Case-insensitive substrings that must match the provider ID.
|
|
21
|
-
* When omitted/empty, the rule is not constrained by provider ID.
|
|
22
|
-
*/
|
|
23
|
-
providerIdIncludes?: string[];
|
|
24
|
-
/**
|
|
25
|
-
* Enable these tools when the rule matches.
|
|
26
|
-
*/
|
|
27
|
-
enableTools?: DefaultToolName[];
|
|
28
|
-
/**
|
|
29
|
-
* Disable these tools when the rule matches.
|
|
30
|
-
*/
|
|
31
|
-
disableTools?: DefaultToolName[];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const TOOL_NAME_TO_FLAG: Record<
|
|
35
|
-
DefaultToolName,
|
|
36
|
-
keyof Pick<
|
|
37
|
-
DefaultToolsConfig,
|
|
38
|
-
| "enableReadFiles"
|
|
39
|
-
| "enableSearch"
|
|
40
|
-
| "enableBash"
|
|
41
|
-
| "enableWebFetch"
|
|
42
|
-
| "enableApplyPatch"
|
|
43
|
-
| "enableEditor"
|
|
44
|
-
| "enableSkills"
|
|
45
|
-
| "enableAskQuestion"
|
|
46
|
-
>
|
|
47
|
-
> = {
|
|
48
|
-
read_files: "enableReadFiles",
|
|
49
|
-
search_codebase: "enableSearch",
|
|
50
|
-
run_commands: "enableBash",
|
|
51
|
-
fetch_web_content: "enableWebFetch",
|
|
52
|
-
apply_patch: "enableApplyPatch",
|
|
53
|
-
editor: "enableEditor",
|
|
54
|
-
skills: "enableSkills",
|
|
55
|
-
ask_question: "enableAskQuestion",
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const DEFAULT_MODEL_TOOL_ROUTING_RULES: ToolRoutingRule[] = [
|
|
59
|
-
{
|
|
60
|
-
name: "openai-native-use-apply-patch",
|
|
61
|
-
mode: "act",
|
|
62
|
-
providerIdIncludes: ["openai-native"],
|
|
63
|
-
enableTools: ["apply_patch"],
|
|
64
|
-
disableTools: ["editor"],
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
name: "codex-and-gpt-use-apply-patch",
|
|
68
|
-
mode: "act",
|
|
69
|
-
modelIdIncludes: ["codex", "gpt"],
|
|
70
|
-
enableTools: ["apply_patch"],
|
|
71
|
-
disableTools: ["editor"],
|
|
72
|
-
},
|
|
73
|
-
];
|
|
74
|
-
|
|
75
|
-
function matchesModelId(
|
|
76
|
-
modelId: string,
|
|
77
|
-
includes: string[] | undefined,
|
|
78
|
-
): boolean {
|
|
79
|
-
if (!includes || includes.length === 0) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
const normalizedModelId = modelId.toLowerCase();
|
|
83
|
-
return includes.some((value) =>
|
|
84
|
-
normalizedModelId.includes(value.toLowerCase()),
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function matchesRule(
|
|
89
|
-
rule: ToolRoutingRule,
|
|
90
|
-
providerId: string,
|
|
91
|
-
modelId: string,
|
|
92
|
-
mode: CoreAgentMode,
|
|
93
|
-
): boolean {
|
|
94
|
-
if (rule.mode && rule.mode !== "any" && rule.mode !== mode) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
return (
|
|
98
|
-
matchesModelId(providerId, rule.providerIdIncludes) &&
|
|
99
|
-
matchesModelId(modelId, rule.modelIdIncludes)
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function resolveToolRoutingConfig(
|
|
104
|
-
providerId: string,
|
|
105
|
-
modelId: string,
|
|
106
|
-
mode: CoreAgentMode,
|
|
107
|
-
rules: ToolRoutingRule[] | undefined,
|
|
108
|
-
): Partial<DefaultToolsConfig> {
|
|
109
|
-
if (!rules || rules.length === 0) {
|
|
110
|
-
return {};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const toggles = new Map<DefaultToolName, boolean>();
|
|
114
|
-
|
|
115
|
-
for (const rule of rules) {
|
|
116
|
-
if (!matchesRule(rule, providerId, modelId, mode)) {
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
for (const toolName of rule.disableTools ?? []) {
|
|
120
|
-
toggles.set(toolName, false);
|
|
121
|
-
}
|
|
122
|
-
for (const toolName of rule.enableTools ?? []) {
|
|
123
|
-
toggles.set(toolName, true);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const config: Partial<DefaultToolsConfig> = {};
|
|
128
|
-
for (const [toolName, enabled] of toggles.entries()) {
|
|
129
|
-
config[TOOL_NAME_TO_FLAG[toolName]] = enabled;
|
|
130
|
-
}
|
|
131
|
-
return config;
|
|
132
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
createDefaultToolsWithPreset,
|
|
4
|
-
createToolPoliciesWithPreset,
|
|
5
|
-
ToolPresets,
|
|
6
|
-
} from "./presets.js";
|
|
7
|
-
|
|
8
|
-
describe("default tool presets", () => {
|
|
9
|
-
it("explicitly configures ask_question across presets", () => {
|
|
10
|
-
expect(ToolPresets.search.enableAskQuestion).toBe(false);
|
|
11
|
-
expect(ToolPresets.development.enableAskQuestion).toBe(true);
|
|
12
|
-
expect(ToolPresets.readonly.enableAskQuestion).toBe(true);
|
|
13
|
-
expect(ToolPresets.minimal.enableAskQuestion).toBe(true);
|
|
14
|
-
expect(ToolPresets.yolo.enableAskQuestion).toBe(false);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("yolo preset excludes ask_question even when its executor exists", () => {
|
|
18
|
-
const tools = createDefaultToolsWithPreset("yolo", {
|
|
19
|
-
executors: {
|
|
20
|
-
readFile: async () => "ok",
|
|
21
|
-
search: async () => "ok",
|
|
22
|
-
bash: async () => "ok",
|
|
23
|
-
webFetch: async () => "ok",
|
|
24
|
-
applyPatch: async () => "ok",
|
|
25
|
-
editor: async () => "ok",
|
|
26
|
-
skills: async () => "ok",
|
|
27
|
-
askQuestion: async () => "ok",
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
expect(tools.map((tool) => tool.name)).toEqual([
|
|
32
|
-
"read_files",
|
|
33
|
-
"search_codebase",
|
|
34
|
-
"run_commands",
|
|
35
|
-
"fetch_web_content",
|
|
36
|
-
"editor",
|
|
37
|
-
"skills",
|
|
38
|
-
]);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe("tool policy presets", () => {
|
|
43
|
-
it("returns empty policies for default", () => {
|
|
44
|
-
expect(createToolPoliciesWithPreset("default")).toEqual({});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("yolo preset enables and auto-approves all tools", () => {
|
|
48
|
-
const policies = createToolPoliciesWithPreset("yolo");
|
|
49
|
-
expect(policies["*"]).toEqual({
|
|
50
|
-
enabled: true,
|
|
51
|
-
autoApprove: true,
|
|
52
|
-
});
|
|
53
|
-
expect(policies.ask_question).toEqual({
|
|
54
|
-
enabled: true,
|
|
55
|
-
autoApprove: true,
|
|
56
|
-
});
|
|
57
|
-
expect(policies.skills).toEqual({
|
|
58
|
-
enabled: true,
|
|
59
|
-
autoApprove: true,
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
package/src/tools/presets.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool Presets
|
|
3
|
-
*
|
|
4
|
-
* Pre-configured tool combinations for common use cases.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { Tool, ToolPolicy } from "@clinebot/shared";
|
|
8
|
-
import { ALL_DEFAULT_TOOL_NAMES } from "./constants.js";
|
|
9
|
-
import { createDefaultTools } from "./definitions.js";
|
|
10
|
-
import type { CreateDefaultToolsOptions, DefaultToolsConfig } from "./types.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Preset configurations for common use cases
|
|
14
|
-
*/
|
|
15
|
-
export const ToolPresets = {
|
|
16
|
-
/**
|
|
17
|
-
* Browser-based tools (no shell access, no web fetch)
|
|
18
|
-
*/
|
|
19
|
-
browser: {
|
|
20
|
-
enableReadFiles: false,
|
|
21
|
-
enableSearch: false,
|
|
22
|
-
enableBash: false,
|
|
23
|
-
enableWebFetch: false,
|
|
24
|
-
enableApplyPatch: false,
|
|
25
|
-
enableEditor: false,
|
|
26
|
-
enableSkills: true,
|
|
27
|
-
enableAskQuestion: true,
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Search-focused tools (read_files + search_codebase)
|
|
32
|
-
* Good for code exploration and analysis agents
|
|
33
|
-
*/
|
|
34
|
-
search: {
|
|
35
|
-
enableReadFiles: true,
|
|
36
|
-
enableSearch: true,
|
|
37
|
-
enableBash: false,
|
|
38
|
-
enableWebFetch: false,
|
|
39
|
-
enableApplyPatch: false,
|
|
40
|
-
enableEditor: false,
|
|
41
|
-
enableSkills: false,
|
|
42
|
-
enableAskQuestion: false,
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Full development tools (all tools enabled) - Act mode
|
|
47
|
-
* Good for coding assistants and task automation
|
|
48
|
-
*/
|
|
49
|
-
development: {
|
|
50
|
-
enableReadFiles: true,
|
|
51
|
-
enableSearch: true,
|
|
52
|
-
enableBash: true,
|
|
53
|
-
enableWebFetch: true,
|
|
54
|
-
enableApplyPatch: false,
|
|
55
|
-
enableEditor: true,
|
|
56
|
-
enableSkills: true,
|
|
57
|
-
enableAskQuestion: true,
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Read-only tools (no shell access) - Plan mode
|
|
62
|
-
* Good for analysis and documentation agents
|
|
63
|
-
*/
|
|
64
|
-
readonly: {
|
|
65
|
-
enableReadFiles: true,
|
|
66
|
-
enableSearch: true,
|
|
67
|
-
enableBash: true,
|
|
68
|
-
enableWebFetch: true,
|
|
69
|
-
enableApplyPatch: false,
|
|
70
|
-
enableEditor: false,
|
|
71
|
-
enableSkills: true,
|
|
72
|
-
enableAskQuestion: true,
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Minimal tools (file reading only)
|
|
77
|
-
* Good for focused single-file tasks
|
|
78
|
-
*/
|
|
79
|
-
minimal: {
|
|
80
|
-
enableReadFiles: false,
|
|
81
|
-
enableSearch: false,
|
|
82
|
-
enableBash: false,
|
|
83
|
-
enableWebFetch: false,
|
|
84
|
-
enableApplyPatch: false,
|
|
85
|
-
enableEditor: false,
|
|
86
|
-
enableSkills: false,
|
|
87
|
-
enableAskQuestion: true,
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* YOLO mode (automation-focused tools + no approval required)
|
|
92
|
-
* Good for trusted local automation workflows.
|
|
93
|
-
*/
|
|
94
|
-
yolo: {
|
|
95
|
-
enableReadFiles: true,
|
|
96
|
-
enableSearch: true,
|
|
97
|
-
enableBash: true,
|
|
98
|
-
enableWebFetch: true,
|
|
99
|
-
enableApplyPatch: false,
|
|
100
|
-
enableEditor: true,
|
|
101
|
-
enableSkills: true,
|
|
102
|
-
enableAskQuestion: false,
|
|
103
|
-
},
|
|
104
|
-
} as const satisfies Record<string, DefaultToolsConfig>;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Type for preset names
|
|
108
|
-
*/
|
|
109
|
-
export type ToolPresetName = keyof typeof ToolPresets;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Tool policy preset names
|
|
113
|
-
*/
|
|
114
|
-
export type ToolPolicyPresetName = "default" | "yolo";
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Build tool policies for a preset.
|
|
118
|
-
* `yolo` guarantees tool policies are enabled and auto-approved.
|
|
119
|
-
*/
|
|
120
|
-
export function createToolPoliciesWithPreset(
|
|
121
|
-
presetName: ToolPolicyPresetName,
|
|
122
|
-
): Record<string, ToolPolicy> {
|
|
123
|
-
if (presetName !== "yolo") {
|
|
124
|
-
return {};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const yoloPolicy: ToolPolicy = {
|
|
128
|
-
enabled: true,
|
|
129
|
-
autoApprove: true,
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const policies: Record<string, ToolPolicy> = {
|
|
133
|
-
"*": yoloPolicy,
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
for (const toolName of ALL_DEFAULT_TOOL_NAMES) {
|
|
137
|
-
policies[toolName] = yoloPolicy;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return policies;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Create default tools using a preset configuration
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```typescript
|
|
148
|
-
* const tools = createDefaultToolsWithPreset("readonly", {
|
|
149
|
-
* executors: {
|
|
150
|
-
* readFile: async ({ path }) => fs.readFile(path, "utf-8"),
|
|
151
|
-
* search: async (query, cwd) => searchFiles(query, cwd),
|
|
152
|
-
* webFetch: async (url, prompt) => fetchAndAnalyze(url, prompt),
|
|
153
|
-
* },
|
|
154
|
-
* cwd: "/path/to/project",
|
|
155
|
-
* })
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
export function createDefaultToolsWithPreset(
|
|
159
|
-
presetName: ToolPresetName,
|
|
160
|
-
options: Omit<CreateDefaultToolsOptions, keyof DefaultToolsConfig> &
|
|
161
|
-
Partial<DefaultToolsConfig>,
|
|
162
|
-
): Tool[] {
|
|
163
|
-
const preset = ToolPresets[presetName];
|
|
164
|
-
return createDefaultTools({
|
|
165
|
-
...preset,
|
|
166
|
-
...options,
|
|
167
|
-
});
|
|
168
|
-
}
|