@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,658 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
createBashTool,
|
|
4
|
-
createDefaultTools,
|
|
5
|
-
createReadFilesTool,
|
|
6
|
-
createSkillsTool,
|
|
7
|
-
} from "./definitions.js";
|
|
8
|
-
import { INPUT_ARG_CHAR_LIMIT } from "./schemas.js";
|
|
9
|
-
import type { SkillsExecutorWithMetadata } from "./types.js";
|
|
10
|
-
|
|
11
|
-
function createMockSkillsExecutor(
|
|
12
|
-
fn: (...args: unknown[]) => Promise<string> = async () => "ok",
|
|
13
|
-
configuredSkills?: SkillsExecutorWithMetadata["configuredSkills"],
|
|
14
|
-
): SkillsExecutorWithMetadata {
|
|
15
|
-
const executor = fn as SkillsExecutorWithMetadata;
|
|
16
|
-
executor.configuredSkills = configuredSkills;
|
|
17
|
-
return executor;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe("default skills tool", () => {
|
|
21
|
-
it("is included only when enabled with a skills executor", () => {
|
|
22
|
-
const toolsWithoutExecutor = createDefaultTools({
|
|
23
|
-
executors: {},
|
|
24
|
-
enableSkills: true,
|
|
25
|
-
});
|
|
26
|
-
expect(toolsWithoutExecutor.map((tool) => tool.name)).not.toContain(
|
|
27
|
-
"skills",
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const toolsWithExecutor = createDefaultTools({
|
|
31
|
-
executors: {
|
|
32
|
-
skills: createMockSkillsExecutor(),
|
|
33
|
-
},
|
|
34
|
-
enableSkills: true,
|
|
35
|
-
});
|
|
36
|
-
expect(toolsWithExecutor.map((tool) => tool.name)).toContain("skills");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("includes configured skill names in description", () => {
|
|
40
|
-
const executor = createMockSkillsExecutor(
|
|
41
|
-
async () => "ok",
|
|
42
|
-
[
|
|
43
|
-
{ id: "commit", name: "commit", disabled: false },
|
|
44
|
-
{
|
|
45
|
-
id: "review-pr",
|
|
46
|
-
name: "review-pr",
|
|
47
|
-
description: "Review a PR",
|
|
48
|
-
disabled: false,
|
|
49
|
-
},
|
|
50
|
-
{ id: "disabled-skill", name: "disabled-skill", disabled: true },
|
|
51
|
-
],
|
|
52
|
-
);
|
|
53
|
-
const tool = createSkillsTool(executor);
|
|
54
|
-
expect(tool.description).toContain("Available skills: commit, review-pr.");
|
|
55
|
-
expect(tool.description).not.toContain("disabled-skill");
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("omits skill list from description when no skills are configured", () => {
|
|
59
|
-
const executor = createMockSkillsExecutor(async () => "ok");
|
|
60
|
-
const tool = createSkillsTool(executor);
|
|
61
|
-
expect(tool.description).not.toContain("Available skills");
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("validates and executes skill invocation input", async () => {
|
|
65
|
-
const execute = vi.fn(async () => "loaded");
|
|
66
|
-
const tools = createDefaultTools({
|
|
67
|
-
executors: {
|
|
68
|
-
skills: createMockSkillsExecutor(execute),
|
|
69
|
-
},
|
|
70
|
-
enableReadFiles: false,
|
|
71
|
-
enableSearch: false,
|
|
72
|
-
enableBash: false,
|
|
73
|
-
enableWebFetch: false,
|
|
74
|
-
enableEditor: false,
|
|
75
|
-
enableSkills: true,
|
|
76
|
-
});
|
|
77
|
-
const skillsTool = tools.find((tool) => tool.name === "skills");
|
|
78
|
-
expect(skillsTool).toBeDefined();
|
|
79
|
-
if (!skillsTool) {
|
|
80
|
-
throw new Error("Expected skills tool to be defined.");
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const result = await skillsTool.execute(
|
|
84
|
-
{ skill: "commit", args: "-m 'fix'" },
|
|
85
|
-
{
|
|
86
|
-
agentId: "agent-1",
|
|
87
|
-
conversationId: "conv-1",
|
|
88
|
-
iteration: 1,
|
|
89
|
-
},
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
expect(result).toBe("loaded");
|
|
93
|
-
expect(execute).toHaveBeenCalledWith(
|
|
94
|
-
"commit",
|
|
95
|
-
"-m 'fix'",
|
|
96
|
-
expect.objectContaining({
|
|
97
|
-
agentId: "agent-1",
|
|
98
|
-
conversationId: "conv-1",
|
|
99
|
-
iteration: 1,
|
|
100
|
-
}),
|
|
101
|
-
);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
describe("default ask_question tool", () => {
|
|
106
|
-
it("is enabled by default when executor is provided", () => {
|
|
107
|
-
const tools = createDefaultTools({
|
|
108
|
-
executors: {
|
|
109
|
-
askQuestion: async () => "ok",
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
expect(tools.map((tool) => tool.name)).toContain("ask_question");
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("is excluded when explicitly disabled", () => {
|
|
116
|
-
const tools = createDefaultTools({
|
|
117
|
-
executors: {
|
|
118
|
-
askQuestion: async () => "ok",
|
|
119
|
-
},
|
|
120
|
-
enableAskQuestion: false,
|
|
121
|
-
});
|
|
122
|
-
expect(tools.map((tool) => tool.name)).not.toContain("ask_question");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("is included only when enabled with an askQuestion executor", () => {
|
|
126
|
-
const toolsWithoutExecutor = createDefaultTools({
|
|
127
|
-
executors: {},
|
|
128
|
-
enableAskQuestion: true,
|
|
129
|
-
});
|
|
130
|
-
expect(toolsWithoutExecutor.map((tool) => tool.name)).not.toContain(
|
|
131
|
-
"ask_question",
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const toolsWithExecutor = createDefaultTools({
|
|
135
|
-
executors: {
|
|
136
|
-
askQuestion: async () => "ok",
|
|
137
|
-
},
|
|
138
|
-
enableAskQuestion: true,
|
|
139
|
-
});
|
|
140
|
-
expect(toolsWithExecutor.map((tool) => tool.name)).toContain(
|
|
141
|
-
"ask_question",
|
|
142
|
-
);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("validates and executes ask_question input", async () => {
|
|
146
|
-
const execute = vi.fn(async () => "asked");
|
|
147
|
-
const tools = createDefaultTools({
|
|
148
|
-
executors: {
|
|
149
|
-
askQuestion: execute,
|
|
150
|
-
},
|
|
151
|
-
enableReadFiles: false,
|
|
152
|
-
enableSearch: false,
|
|
153
|
-
enableBash: false,
|
|
154
|
-
enableWebFetch: false,
|
|
155
|
-
enableEditor: false,
|
|
156
|
-
enableSkills: false,
|
|
157
|
-
enableAskQuestion: true,
|
|
158
|
-
});
|
|
159
|
-
const askTool = tools.find((tool) => tool.name === "ask_question");
|
|
160
|
-
expect(askTool).toBeDefined();
|
|
161
|
-
if (!askTool) {
|
|
162
|
-
throw new Error("Expected ask_question tool to be defined.");
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const result = await askTool.execute(
|
|
166
|
-
{
|
|
167
|
-
question: "Which approach should I take?",
|
|
168
|
-
options: ["Option 1", "Option 2"],
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
agentId: "agent-1",
|
|
172
|
-
conversationId: "conv-1",
|
|
173
|
-
iteration: 1,
|
|
174
|
-
},
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
expect(result).toBe("asked");
|
|
178
|
-
expect(execute).toHaveBeenCalledWith(
|
|
179
|
-
"Which approach should I take?",
|
|
180
|
-
["Option 1", "Option 2"],
|
|
181
|
-
expect.objectContaining({
|
|
182
|
-
agentId: "agent-1",
|
|
183
|
-
conversationId: "conv-1",
|
|
184
|
-
iteration: 1,
|
|
185
|
-
}),
|
|
186
|
-
);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
describe("default apply_patch tool", () => {
|
|
191
|
-
it("is included only when enabled with an applyPatch executor", () => {
|
|
192
|
-
const toolsWithoutExecutor = createDefaultTools({
|
|
193
|
-
executors: {},
|
|
194
|
-
enableApplyPatch: true,
|
|
195
|
-
});
|
|
196
|
-
expect(toolsWithoutExecutor.map((tool) => tool.name)).not.toContain(
|
|
197
|
-
"apply_patch",
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
const toolsWithExecutor = createDefaultTools({
|
|
201
|
-
executors: {
|
|
202
|
-
applyPatch: async () => "ok",
|
|
203
|
-
},
|
|
204
|
-
enableApplyPatch: true,
|
|
205
|
-
});
|
|
206
|
-
expect(toolsWithExecutor.map((tool) => tool.name)).toContain("apply_patch");
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it("validates and executes apply_patch input", async () => {
|
|
210
|
-
const execute = vi.fn(async () => "patched");
|
|
211
|
-
const tools = createDefaultTools({
|
|
212
|
-
executors: {
|
|
213
|
-
applyPatch: execute,
|
|
214
|
-
},
|
|
215
|
-
enableReadFiles: false,
|
|
216
|
-
enableSearch: false,
|
|
217
|
-
enableBash: false,
|
|
218
|
-
enableWebFetch: false,
|
|
219
|
-
enableEditor: false,
|
|
220
|
-
enableSkills: false,
|
|
221
|
-
enableAskQuestion: false,
|
|
222
|
-
enableApplyPatch: true,
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
const applyPatchTool = tools.find((tool) => tool.name === "apply_patch");
|
|
226
|
-
expect(applyPatchTool).toBeDefined();
|
|
227
|
-
if (!applyPatchTool) {
|
|
228
|
-
throw new Error("Expected apply_patch tool to be defined.");
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const result = await applyPatchTool.execute(
|
|
232
|
-
{ input: "*** Begin Patch\n*** End Patch" },
|
|
233
|
-
{
|
|
234
|
-
agentId: "agent-1",
|
|
235
|
-
conversationId: "conv-1",
|
|
236
|
-
iteration: 1,
|
|
237
|
-
},
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
expect(result).toEqual({
|
|
241
|
-
query: "apply_patch",
|
|
242
|
-
result: "patched",
|
|
243
|
-
success: true,
|
|
244
|
-
});
|
|
245
|
-
expect(execute).toHaveBeenCalledWith(
|
|
246
|
-
{ input: "*** Begin Patch\n*** End Patch" },
|
|
247
|
-
process.cwd(),
|
|
248
|
-
expect.objectContaining({
|
|
249
|
-
agentId: "agent-1",
|
|
250
|
-
conversationId: "conv-1",
|
|
251
|
-
iteration: 1,
|
|
252
|
-
}),
|
|
253
|
-
);
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
describe("default run_commands tool", () => {
|
|
258
|
-
it("accepts object input with commands as a single string", async () => {
|
|
259
|
-
const execute = vi.fn(async (command: string) => `ran:${command}`);
|
|
260
|
-
const tool = createBashTool(execute);
|
|
261
|
-
|
|
262
|
-
const result = await tool.execute({ commands: "ls" } as never, {
|
|
263
|
-
agentId: "agent-1",
|
|
264
|
-
conversationId: "conv-1",
|
|
265
|
-
iteration: 1,
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
expect(result).toEqual([
|
|
269
|
-
{
|
|
270
|
-
query: "ls",
|
|
271
|
-
result: "ran:ls",
|
|
272
|
-
success: true,
|
|
273
|
-
},
|
|
274
|
-
]);
|
|
275
|
-
expect(execute).toHaveBeenCalledTimes(1);
|
|
276
|
-
expect(execute).toHaveBeenCalledWith(
|
|
277
|
-
"ls",
|
|
278
|
-
process.cwd(),
|
|
279
|
-
expect.objectContaining({
|
|
280
|
-
agentId: "agent-1",
|
|
281
|
-
conversationId: "conv-1",
|
|
282
|
-
iteration: 1,
|
|
283
|
-
}),
|
|
284
|
-
);
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
describe("default read_files tool", () => {
|
|
289
|
-
it("normalizes ranged file requests and passes them to the executor", async () => {
|
|
290
|
-
const execute = vi.fn(async () => "selected lines");
|
|
291
|
-
const tool = createReadFilesTool(execute);
|
|
292
|
-
|
|
293
|
-
const result = await tool.execute(
|
|
294
|
-
{
|
|
295
|
-
files: [
|
|
296
|
-
{
|
|
297
|
-
path: "/tmp/example.ts",
|
|
298
|
-
start_line: 3,
|
|
299
|
-
end_line: 5,
|
|
300
|
-
},
|
|
301
|
-
],
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
agentId: "agent-1",
|
|
305
|
-
conversationId: "conv-1",
|
|
306
|
-
iteration: 1,
|
|
307
|
-
},
|
|
308
|
-
);
|
|
309
|
-
|
|
310
|
-
expect(result).toEqual([
|
|
311
|
-
{
|
|
312
|
-
query: "/tmp/example.ts:3-5",
|
|
313
|
-
result: "selected lines",
|
|
314
|
-
success: true,
|
|
315
|
-
},
|
|
316
|
-
]);
|
|
317
|
-
expect(execute).toHaveBeenCalledWith(
|
|
318
|
-
{
|
|
319
|
-
path: "/tmp/example.ts",
|
|
320
|
-
start_line: 3,
|
|
321
|
-
end_line: 5,
|
|
322
|
-
},
|
|
323
|
-
expect.objectContaining({
|
|
324
|
-
agentId: "agent-1",
|
|
325
|
-
conversationId: "conv-1",
|
|
326
|
-
iteration: 1,
|
|
327
|
-
}),
|
|
328
|
-
);
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it("keeps legacy string inputs reading full file content", async () => {
|
|
332
|
-
const execute = vi.fn(async () => "full file");
|
|
333
|
-
const tool = createReadFilesTool(execute);
|
|
334
|
-
|
|
335
|
-
await tool.execute("/tmp/example.ts" as never, {
|
|
336
|
-
agentId: "agent-1",
|
|
337
|
-
conversationId: "conv-1",
|
|
338
|
-
iteration: 1,
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
expect(execute).toHaveBeenCalledWith(
|
|
342
|
-
{ path: "/tmp/example.ts" },
|
|
343
|
-
expect.objectContaining({
|
|
344
|
-
agentId: "agent-1",
|
|
345
|
-
conversationId: "conv-1",
|
|
346
|
-
iteration: 1,
|
|
347
|
-
}),
|
|
348
|
-
);
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
it("treats null line bounds as full-file boundaries", async () => {
|
|
352
|
-
const execute = vi.fn(async () => "full file");
|
|
353
|
-
const tool = createReadFilesTool(execute);
|
|
354
|
-
|
|
355
|
-
const result = await tool.execute(
|
|
356
|
-
{
|
|
357
|
-
files: [
|
|
358
|
-
{
|
|
359
|
-
path: "/tmp/example.ts",
|
|
360
|
-
start_line: null,
|
|
361
|
-
end_line: null,
|
|
362
|
-
},
|
|
363
|
-
],
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
agentId: "agent-1",
|
|
367
|
-
conversationId: "conv-1",
|
|
368
|
-
iteration: 1,
|
|
369
|
-
},
|
|
370
|
-
);
|
|
371
|
-
|
|
372
|
-
expect(result).toEqual([
|
|
373
|
-
{
|
|
374
|
-
query: "/tmp/example.ts",
|
|
375
|
-
result: "full file",
|
|
376
|
-
success: true,
|
|
377
|
-
},
|
|
378
|
-
]);
|
|
379
|
-
expect(execute).toHaveBeenCalledWith(
|
|
380
|
-
{
|
|
381
|
-
path: "/tmp/example.ts",
|
|
382
|
-
start_line: null,
|
|
383
|
-
end_line: null,
|
|
384
|
-
},
|
|
385
|
-
expect.objectContaining({
|
|
386
|
-
agentId: "agent-1",
|
|
387
|
-
conversationId: "conv-1",
|
|
388
|
-
iteration: 1,
|
|
389
|
-
}),
|
|
390
|
-
);
|
|
391
|
-
});
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
describe("zod schema conversion", () => {
|
|
395
|
-
it("preserves read_files required properties in generated JSON schema", () => {
|
|
396
|
-
const tool = createReadFilesTool(async () => "ok");
|
|
397
|
-
const inputSchema = tool.inputSchema as Record<string, unknown>;
|
|
398
|
-
const properties = inputSchema.properties as Record<string, unknown>;
|
|
399
|
-
expect(inputSchema.type).toBe("object");
|
|
400
|
-
expect(properties.files).toMatchObject({
|
|
401
|
-
type: "array",
|
|
402
|
-
items: {
|
|
403
|
-
type: "object",
|
|
404
|
-
properties: {
|
|
405
|
-
path: {
|
|
406
|
-
type: "string",
|
|
407
|
-
description:
|
|
408
|
-
"The absolute file path of a text file to read content from",
|
|
409
|
-
},
|
|
410
|
-
start_line: {
|
|
411
|
-
anyOf: [{ type: "integer" }, { type: "null" }],
|
|
412
|
-
description:
|
|
413
|
-
"Optional one-based starting line number to read from; use null or omit for the start of the file",
|
|
414
|
-
},
|
|
415
|
-
end_line: {
|
|
416
|
-
anyOf: [{ type: "integer" }, { type: "null" }],
|
|
417
|
-
description:
|
|
418
|
-
"Optional one-based ending line number to read through; use null or omit for the end of the file",
|
|
419
|
-
},
|
|
420
|
-
},
|
|
421
|
-
required: ["path"],
|
|
422
|
-
},
|
|
423
|
-
description:
|
|
424
|
-
"Array of file read requests. Omit start_line/end_line or set them to null to return the full file content boundaries; provide integers to return only that inclusive one-based line range. Prefer this tool over running terminal command to get file content for better performance and reliability.",
|
|
425
|
-
});
|
|
426
|
-
expect(inputSchema.required).toEqual(["files"]);
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
it("exposes skills args as optional nullable in tool schemas", () => {
|
|
430
|
-
const tools = createDefaultTools({
|
|
431
|
-
executors: {
|
|
432
|
-
skills: createMockSkillsExecutor(),
|
|
433
|
-
},
|
|
434
|
-
enableReadFiles: false,
|
|
435
|
-
enableSearch: false,
|
|
436
|
-
enableBash: false,
|
|
437
|
-
enableWebFetch: false,
|
|
438
|
-
enableEditor: false,
|
|
439
|
-
enableApplyPatch: false,
|
|
440
|
-
enableAskQuestion: false,
|
|
441
|
-
enableSkills: true,
|
|
442
|
-
});
|
|
443
|
-
const skills = tools.find((tool) => tool.name === "skills");
|
|
444
|
-
expect(skills).toBeDefined();
|
|
445
|
-
if (!skills) {
|
|
446
|
-
throw new Error("Expected skills tool.");
|
|
447
|
-
}
|
|
448
|
-
const schema = skills.inputSchema as {
|
|
449
|
-
required?: string[];
|
|
450
|
-
properties?: Record<string, unknown>;
|
|
451
|
-
};
|
|
452
|
-
expect(schema.required).toEqual(["skill"]);
|
|
453
|
-
expect(schema.properties).toHaveProperty("args");
|
|
454
|
-
});
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
describe("default editor tool", () => {
|
|
458
|
-
it("accepts replacement edits without insert fields", async () => {
|
|
459
|
-
const execute = vi.fn(async () => "patched");
|
|
460
|
-
const tools = createDefaultTools({
|
|
461
|
-
executors: {
|
|
462
|
-
editor: execute,
|
|
463
|
-
},
|
|
464
|
-
enableReadFiles: false,
|
|
465
|
-
enableSearch: false,
|
|
466
|
-
enableBash: false,
|
|
467
|
-
enableWebFetch: false,
|
|
468
|
-
enableSkills: false,
|
|
469
|
-
enableAskQuestion: false,
|
|
470
|
-
enableApplyPatch: false,
|
|
471
|
-
enableEditor: true,
|
|
472
|
-
});
|
|
473
|
-
const editorTool = tools.find((tool) => tool.name === "editor");
|
|
474
|
-
expect(editorTool).toBeDefined();
|
|
475
|
-
if (!editorTool) {
|
|
476
|
-
throw new Error("Expected editor tool to be defined.");
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
const result = await editorTool.execute(
|
|
480
|
-
{
|
|
481
|
-
path: "/tmp/example.ts",
|
|
482
|
-
old_text: "before",
|
|
483
|
-
new_text: "after",
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
agentId: "agent-1",
|
|
487
|
-
conversationId: "conv-1",
|
|
488
|
-
iteration: 1,
|
|
489
|
-
},
|
|
490
|
-
);
|
|
491
|
-
|
|
492
|
-
expect(result).toEqual({
|
|
493
|
-
query: "edit:/tmp/example.ts",
|
|
494
|
-
result: "patched",
|
|
495
|
-
success: true,
|
|
496
|
-
});
|
|
497
|
-
expect(execute).toHaveBeenCalledWith(
|
|
498
|
-
expect.objectContaining({
|
|
499
|
-
path: "/tmp/example.ts",
|
|
500
|
-
old_text: "before",
|
|
501
|
-
new_text: "after",
|
|
502
|
-
}),
|
|
503
|
-
process.cwd(),
|
|
504
|
-
expect.objectContaining({
|
|
505
|
-
agentId: "agent-1",
|
|
506
|
-
conversationId: "conv-1",
|
|
507
|
-
iteration: 1,
|
|
508
|
-
}),
|
|
509
|
-
);
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
it("allows edit without old_text so missing files can be created", async () => {
|
|
513
|
-
const execute = vi.fn(async () => "patched");
|
|
514
|
-
const tools = createDefaultTools({
|
|
515
|
-
executors: {
|
|
516
|
-
editor: execute,
|
|
517
|
-
},
|
|
518
|
-
enableReadFiles: false,
|
|
519
|
-
enableSearch: false,
|
|
520
|
-
enableBash: false,
|
|
521
|
-
enableWebFetch: false,
|
|
522
|
-
enableSkills: false,
|
|
523
|
-
enableAskQuestion: false,
|
|
524
|
-
enableApplyPatch: false,
|
|
525
|
-
enableEditor: true,
|
|
526
|
-
});
|
|
527
|
-
const editorTool = tools.find((tool) => tool.name === "editor");
|
|
528
|
-
expect(editorTool).toBeDefined();
|
|
529
|
-
if (!editorTool) {
|
|
530
|
-
throw new Error("Expected editor tool to be defined.");
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
const result = await editorTool.execute(
|
|
534
|
-
{
|
|
535
|
-
path: "/tmp/example.ts",
|
|
536
|
-
new_text: "created",
|
|
537
|
-
},
|
|
538
|
-
{
|
|
539
|
-
agentId: "agent-1",
|
|
540
|
-
conversationId: "conv-1",
|
|
541
|
-
iteration: 1,
|
|
542
|
-
},
|
|
543
|
-
);
|
|
544
|
-
|
|
545
|
-
expect(result).toEqual({
|
|
546
|
-
query: "edit:/tmp/example.ts",
|
|
547
|
-
result: "patched",
|
|
548
|
-
success: true,
|
|
549
|
-
});
|
|
550
|
-
expect(execute).toHaveBeenCalledWith(
|
|
551
|
-
expect.objectContaining({
|
|
552
|
-
path: "/tmp/example.ts",
|
|
553
|
-
new_text: "created",
|
|
554
|
-
}),
|
|
555
|
-
process.cwd(),
|
|
556
|
-
expect.anything(),
|
|
557
|
-
);
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
it("treats insert_line as an insert operation", async () => {
|
|
561
|
-
const execute = vi.fn(async () => "patched");
|
|
562
|
-
const tools = createDefaultTools({
|
|
563
|
-
executors: {
|
|
564
|
-
editor: execute,
|
|
565
|
-
},
|
|
566
|
-
enableReadFiles: false,
|
|
567
|
-
enableSearch: false,
|
|
568
|
-
enableBash: false,
|
|
569
|
-
enableWebFetch: false,
|
|
570
|
-
enableSkills: false,
|
|
571
|
-
enableAskQuestion: false,
|
|
572
|
-
enableApplyPatch: false,
|
|
573
|
-
enableEditor: true,
|
|
574
|
-
});
|
|
575
|
-
const editorTool = tools.find((tool) => tool.name === "editor");
|
|
576
|
-
expect(editorTool).toBeDefined();
|
|
577
|
-
if (!editorTool) {
|
|
578
|
-
throw new Error("Expected editor tool to be defined.");
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
const result = await editorTool.execute(
|
|
582
|
-
{
|
|
583
|
-
path: "/tmp/example.ts",
|
|
584
|
-
new_text: "after",
|
|
585
|
-
insert_line: 3,
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
agentId: "agent-1",
|
|
589
|
-
conversationId: "conv-1",
|
|
590
|
-
iteration: 1,
|
|
591
|
-
},
|
|
592
|
-
);
|
|
593
|
-
|
|
594
|
-
expect(result).toEqual({
|
|
595
|
-
query: "insert:/tmp/example.ts",
|
|
596
|
-
result: "patched",
|
|
597
|
-
success: true,
|
|
598
|
-
});
|
|
599
|
-
expect(execute).toHaveBeenCalledWith(
|
|
600
|
-
expect.objectContaining({
|
|
601
|
-
path: "/tmp/example.ts",
|
|
602
|
-
new_text: "after",
|
|
603
|
-
insert_line: 3,
|
|
604
|
-
}),
|
|
605
|
-
process.cwd(),
|
|
606
|
-
expect.anything(),
|
|
607
|
-
);
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
it("returns a recoverable tool error when text exceeds the soft character limit", async () => {
|
|
611
|
-
const execute = vi.fn(async () => "patched");
|
|
612
|
-
const tools = createDefaultTools({
|
|
613
|
-
executors: {
|
|
614
|
-
editor: execute,
|
|
615
|
-
},
|
|
616
|
-
enableReadFiles: false,
|
|
617
|
-
enableSearch: false,
|
|
618
|
-
enableBash: false,
|
|
619
|
-
enableWebFetch: false,
|
|
620
|
-
enableSkills: false,
|
|
621
|
-
enableAskQuestion: false,
|
|
622
|
-
enableApplyPatch: false,
|
|
623
|
-
enableEditor: true,
|
|
624
|
-
});
|
|
625
|
-
const editorTool = tools.find((tool) => tool.name === "editor");
|
|
626
|
-
expect(editorTool).toBeDefined();
|
|
627
|
-
if (!editorTool) {
|
|
628
|
-
throw new Error("Expected editor tool to be defined.");
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
const oversizedText = "x".repeat(INPUT_ARG_CHAR_LIMIT + 1);
|
|
632
|
-
const result = await editorTool.execute(
|
|
633
|
-
{
|
|
634
|
-
path: "/tmp/example.ts",
|
|
635
|
-
new_text: oversizedText,
|
|
636
|
-
},
|
|
637
|
-
{
|
|
638
|
-
agentId: "agent-1",
|
|
639
|
-
conversationId: "conv-1",
|
|
640
|
-
iteration: 1,
|
|
641
|
-
},
|
|
642
|
-
);
|
|
643
|
-
|
|
644
|
-
expect(result).toEqual({
|
|
645
|
-
query: "edit:/tmp/example.ts",
|
|
646
|
-
result: "",
|
|
647
|
-
error: expect.stringContaining("new_text was"),
|
|
648
|
-
success: false,
|
|
649
|
-
});
|
|
650
|
-
if (typeof result !== "object" || result == null || !("error" in result)) {
|
|
651
|
-
throw new Error("Expected editor tool result to include an error.");
|
|
652
|
-
}
|
|
653
|
-
expect(result.error).toContain(
|
|
654
|
-
`recommended limit of ${INPUT_ARG_CHAR_LIMIT}`,
|
|
655
|
-
);
|
|
656
|
-
expect(execute).not.toHaveBeenCalled();
|
|
657
|
-
});
|
|
658
|
-
});
|