@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
package/src/runtime/commands.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SkillConfig,
|
|
3
|
-
UserInstructionConfigWatcher,
|
|
4
|
-
WorkflowConfig,
|
|
5
|
-
} from "../agents";
|
|
6
|
-
|
|
7
|
-
export type RuntimeCommandKind = "skill" | "workflow";
|
|
8
|
-
|
|
9
|
-
export type AvailableRuntimeCommand = {
|
|
10
|
-
id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
instructions: string;
|
|
13
|
-
kind: RuntimeCommandKind;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type CommandRecord = {
|
|
17
|
-
item: SkillConfig | WorkflowConfig;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
function isCommandEnabled(command: SkillConfig | WorkflowConfig): boolean {
|
|
21
|
-
return command.disabled !== true;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function listCommandsForKind(
|
|
25
|
-
watcher: UserInstructionConfigWatcher,
|
|
26
|
-
kind: RuntimeCommandKind,
|
|
27
|
-
): AvailableRuntimeCommand[] {
|
|
28
|
-
return [...watcher.getSnapshot(kind).entries()]
|
|
29
|
-
.map(([id, record]) => ({ id, record: record as CommandRecord }))
|
|
30
|
-
.filter(({ record }) => isCommandEnabled(record.item))
|
|
31
|
-
.map(({ id, record }) => ({
|
|
32
|
-
id,
|
|
33
|
-
name: record.item.name,
|
|
34
|
-
instructions: record.item.instructions,
|
|
35
|
-
kind,
|
|
36
|
-
}))
|
|
37
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function listAvailableRuntimeCommandsFromWatcher(
|
|
41
|
-
watcher: UserInstructionConfigWatcher,
|
|
42
|
-
): AvailableRuntimeCommand[] {
|
|
43
|
-
const byName = new Map<string, AvailableRuntimeCommand>();
|
|
44
|
-
for (const command of [
|
|
45
|
-
...listCommandsForKind(watcher, "workflow"),
|
|
46
|
-
...listCommandsForKind(watcher, "skill"),
|
|
47
|
-
]) {
|
|
48
|
-
if (!byName.has(command.name)) {
|
|
49
|
-
byName.set(command.name, command);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function resolveRuntimeSlashCommandFromWatcher(
|
|
56
|
-
input: string,
|
|
57
|
-
watcher: UserInstructionConfigWatcher,
|
|
58
|
-
): string {
|
|
59
|
-
if (!input.startsWith("/") || input.length < 2) {
|
|
60
|
-
return input;
|
|
61
|
-
}
|
|
62
|
-
const match = input.match(/^\/(\S+)/);
|
|
63
|
-
if (!match) {
|
|
64
|
-
return input;
|
|
65
|
-
}
|
|
66
|
-
const name = match[1];
|
|
67
|
-
if (!name) {
|
|
68
|
-
return input;
|
|
69
|
-
}
|
|
70
|
-
const commandLength = name.length + 1;
|
|
71
|
-
const remainder = input.slice(commandLength);
|
|
72
|
-
const matched = listAvailableRuntimeCommandsFromWatcher(watcher).find(
|
|
73
|
-
(command) => command.name === name,
|
|
74
|
-
);
|
|
75
|
-
return matched ? `${matched.instructions}${remainder}` : input;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function listAvailableRuntimeCommandsForKindFromWatcher(
|
|
79
|
-
watcher: UserInstructionConfigWatcher,
|
|
80
|
-
kind: RuntimeCommandKind,
|
|
81
|
-
): AvailableRuntimeCommand[] {
|
|
82
|
-
return listCommandsForKind(watcher, kind);
|
|
83
|
-
}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import { createHookConfigFileHooks } from "./hook-file-hooks";
|
|
6
|
-
|
|
7
|
-
async function waitForFile(
|
|
8
|
-
filePath: string,
|
|
9
|
-
timeoutMs = 1500,
|
|
10
|
-
): Promise<string> {
|
|
11
|
-
const started = Date.now();
|
|
12
|
-
for (;;) {
|
|
13
|
-
try {
|
|
14
|
-
return await readFile(filePath, "utf8");
|
|
15
|
-
} catch (error) {
|
|
16
|
-
const code =
|
|
17
|
-
error && typeof error === "object" && "code" in error
|
|
18
|
-
? String((error as { code?: unknown }).code)
|
|
19
|
-
: undefined;
|
|
20
|
-
if (code !== "ENOENT" || Date.now() - started >= timeoutMs) {
|
|
21
|
-
throw error;
|
|
22
|
-
}
|
|
23
|
-
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async function createWorkspaceWithHook(
|
|
29
|
-
fileName: string,
|
|
30
|
-
body: string,
|
|
31
|
-
): Promise<{ workspace: string; hookPath: string }> {
|
|
32
|
-
const workspace = await mkdtemp(join(tmpdir(), "hooks-workspace-"));
|
|
33
|
-
const hooksDir = join(workspace, ".clinerules", "hooks");
|
|
34
|
-
await mkdir(hooksDir, { recursive: true });
|
|
35
|
-
const hookPath = join(hooksDir, fileName);
|
|
36
|
-
await writeFile(hookPath, body, "utf8");
|
|
37
|
-
return { workspace, hookPath };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
describe("createHookConfigFileHooks", () => {
|
|
41
|
-
it("ignores example hook files", async () => {
|
|
42
|
-
const { workspace } = await createWorkspaceWithHook(
|
|
43
|
-
"PreToolUse.example",
|
|
44
|
-
'echo \'HOOK_CONTROL\t{"cancel":true,"context":"should-not-run"}\'\n',
|
|
45
|
-
);
|
|
46
|
-
try {
|
|
47
|
-
const hooks = createHookConfigFileHooks({
|
|
48
|
-
cwd: workspace,
|
|
49
|
-
workspacePath: workspace,
|
|
50
|
-
});
|
|
51
|
-
expect(hooks).toBeUndefined();
|
|
52
|
-
} finally {
|
|
53
|
-
await rm(workspace, { recursive: true, force: true });
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("executes extensionless legacy hook files via bash fallback", async () => {
|
|
58
|
-
const { workspace } = await createWorkspaceWithHook(
|
|
59
|
-
"PreToolUse",
|
|
60
|
-
'echo \'HOOK_CONTROL\t{"cancel":true,"context":"legacy-ok"}\'\nexit 0\n',
|
|
61
|
-
);
|
|
62
|
-
try {
|
|
63
|
-
const hooks = createHookConfigFileHooks({
|
|
64
|
-
cwd: workspace,
|
|
65
|
-
workspacePath: workspace,
|
|
66
|
-
});
|
|
67
|
-
expect(hooks?.onToolCallStart).toBeTypeOf("function");
|
|
68
|
-
const control = await hooks?.onToolCallStart?.({
|
|
69
|
-
agentId: "agent_1",
|
|
70
|
-
conversationId: "conv_1",
|
|
71
|
-
parentAgentId: null,
|
|
72
|
-
iteration: 1,
|
|
73
|
-
call: {
|
|
74
|
-
id: "call_1",
|
|
75
|
-
name: "read_file",
|
|
76
|
-
input: { path: "README.md" },
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
expect(control).toMatchObject({ cancel: true, context: "legacy-ok" });
|
|
80
|
-
} finally {
|
|
81
|
-
await rm(workspace, { recursive: true, force: true });
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("honors shebang interpreter when present", async () => {
|
|
86
|
-
const { workspace } = await createWorkspaceWithHook(
|
|
87
|
-
"PreToolUse",
|
|
88
|
-
'#!/usr/bin/env bash\necho \'HOOK_CONTROL\t{"cancel":false,"context":"shebang-ok"}\'\n',
|
|
89
|
-
);
|
|
90
|
-
try {
|
|
91
|
-
const hooks = createHookConfigFileHooks({
|
|
92
|
-
cwd: workspace,
|
|
93
|
-
workspacePath: workspace,
|
|
94
|
-
});
|
|
95
|
-
expect(hooks?.onToolCallStart).toBeTypeOf("function");
|
|
96
|
-
const control = await hooks?.onToolCallStart?.({
|
|
97
|
-
agentId: "agent_1",
|
|
98
|
-
conversationId: "conv_1",
|
|
99
|
-
parentAgentId: null,
|
|
100
|
-
iteration: 1,
|
|
101
|
-
call: {
|
|
102
|
-
id: "call_1",
|
|
103
|
-
name: "read_file",
|
|
104
|
-
input: { path: "README.md" },
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
expect(control).toMatchObject({ cancel: false, context: "shebang-ok" });
|
|
108
|
-
} finally {
|
|
109
|
-
await rm(workspace, { recursive: true, force: true });
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("parses review control from hook output", async () => {
|
|
114
|
-
const { workspace } = await createWorkspaceWithHook(
|
|
115
|
-
"PreToolUse.ts",
|
|
116
|
-
'console.log(\'HOOK_CONTROL\\t{"review":true,"context":"needs-review"}\')\n',
|
|
117
|
-
);
|
|
118
|
-
try {
|
|
119
|
-
const hooks = createHookConfigFileHooks({
|
|
120
|
-
cwd: workspace,
|
|
121
|
-
workspacePath: workspace,
|
|
122
|
-
});
|
|
123
|
-
expect(hooks?.onToolCallStart).toBeTypeOf("function");
|
|
124
|
-
const control = await hooks?.onToolCallStart?.({
|
|
125
|
-
agentId: "agent_1",
|
|
126
|
-
conversationId: "conv_1",
|
|
127
|
-
parentAgentId: null,
|
|
128
|
-
iteration: 1,
|
|
129
|
-
call: {
|
|
130
|
-
id: "call_1",
|
|
131
|
-
name: "run_commands",
|
|
132
|
-
input: { commands: ["git status"] },
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
expect(control).toMatchObject({
|
|
136
|
-
review: true,
|
|
137
|
-
context: "needs-review",
|
|
138
|
-
});
|
|
139
|
-
} finally {
|
|
140
|
-
await rm(workspace, { recursive: true, force: true });
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it("executes python hook files", async () => {
|
|
145
|
-
const { workspace } = await createWorkspaceWithHook(
|
|
146
|
-
"PreToolUse.py",
|
|
147
|
-
'print(\'HOOK_CONTROL\\t{"cancel": false, "context": "python-ok"}\')\n',
|
|
148
|
-
);
|
|
149
|
-
try {
|
|
150
|
-
const hooks = createHookConfigFileHooks({
|
|
151
|
-
cwd: workspace,
|
|
152
|
-
workspacePath: workspace,
|
|
153
|
-
});
|
|
154
|
-
expect(hooks?.onToolCallStart).toBeTypeOf("function");
|
|
155
|
-
const control = await hooks?.onToolCallStart?.({
|
|
156
|
-
agentId: "agent_1",
|
|
157
|
-
conversationId: "conv_1",
|
|
158
|
-
parentAgentId: null,
|
|
159
|
-
iteration: 1,
|
|
160
|
-
call: {
|
|
161
|
-
id: "call_1",
|
|
162
|
-
name: "read_file",
|
|
163
|
-
input: { path: "README.md" },
|
|
164
|
-
},
|
|
165
|
-
});
|
|
166
|
-
expect(control).toMatchObject({
|
|
167
|
-
cancel: false,
|
|
168
|
-
context: "python-ok",
|
|
169
|
-
});
|
|
170
|
-
} finally {
|
|
171
|
-
await rm(workspace, { recursive: true, force: true });
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it.skipIf(process.platform !== "win32")(
|
|
176
|
-
"executes PowerShell hook files on Windows",
|
|
177
|
-
async () => {
|
|
178
|
-
const { workspace } = await createWorkspaceWithHook(
|
|
179
|
-
"PreToolUse.ps1",
|
|
180
|
-
'Write-Output \'HOOK_CONTROL\t{"cancel": false, "context": "powershell-ok"}\'\n',
|
|
181
|
-
);
|
|
182
|
-
try {
|
|
183
|
-
const hooks = createHookConfigFileHooks({
|
|
184
|
-
cwd: workspace,
|
|
185
|
-
workspacePath: workspace,
|
|
186
|
-
});
|
|
187
|
-
expect(hooks?.onToolCallStart).toBeTypeOf("function");
|
|
188
|
-
const control = await hooks?.onToolCallStart?.({
|
|
189
|
-
agentId: "agent_1",
|
|
190
|
-
conversationId: "conv_1",
|
|
191
|
-
parentAgentId: null,
|
|
192
|
-
iteration: 1,
|
|
193
|
-
call: {
|
|
194
|
-
id: "call_1",
|
|
195
|
-
name: "read_file",
|
|
196
|
-
input: { path: "README.md" },
|
|
197
|
-
},
|
|
198
|
-
});
|
|
199
|
-
expect(control).toMatchObject({
|
|
200
|
-
cancel: false,
|
|
201
|
-
context: "powershell-ok",
|
|
202
|
-
});
|
|
203
|
-
} finally {
|
|
204
|
-
await rm(workspace, { recursive: true, force: true });
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
it("maps TaskError hook files to agent_error stop events", async () => {
|
|
210
|
-
const outputPath = join(tmpdir(), `hooks-task-error-${Date.now()}.json`);
|
|
211
|
-
const { workspace } = await createWorkspaceWithHook(
|
|
212
|
-
"TaskError.js",
|
|
213
|
-
`let data='';process.stdin.on('data',c=>data+=c);process.stdin.on('end',()=>{require('node:fs').writeFileSync(${JSON.stringify(outputPath)}, data);});\n`,
|
|
214
|
-
);
|
|
215
|
-
try {
|
|
216
|
-
const hooks = createHookConfigFileHooks({
|
|
217
|
-
cwd: workspace,
|
|
218
|
-
workspacePath: workspace,
|
|
219
|
-
});
|
|
220
|
-
await hooks?.onStopError?.({
|
|
221
|
-
agentId: "agent_1",
|
|
222
|
-
conversationId: "conv_1",
|
|
223
|
-
parentAgentId: null,
|
|
224
|
-
iteration: 3,
|
|
225
|
-
error: new Error("401 unauthorized"),
|
|
226
|
-
});
|
|
227
|
-
const payload = JSON.parse(await waitForFile(outputPath)) as {
|
|
228
|
-
hookName: string;
|
|
229
|
-
error?: { message?: string };
|
|
230
|
-
};
|
|
231
|
-
expect(payload.hookName).toBe("agent_error");
|
|
232
|
-
expect(payload.error?.message).toBe("401 unauthorized");
|
|
233
|
-
} finally {
|
|
234
|
-
await rm(workspace, { recursive: true, force: true });
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
});
|