@clinebot/core 0.0.20 → 0.0.22
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,228 +0,0 @@
|
|
|
1
|
-
import { mkdir, mkdtemp, 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 {
|
|
6
|
-
loadAgentPluginFromPath,
|
|
7
|
-
loadAgentPluginsFromPaths,
|
|
8
|
-
} from "./plugin-loader";
|
|
9
|
-
|
|
10
|
-
describe("plugin-loader", () => {
|
|
11
|
-
it("loads default-exported plugin from path", async () => {
|
|
12
|
-
const dir = await mkdtemp(join(tmpdir(), "core-plugin-loader-"));
|
|
13
|
-
try {
|
|
14
|
-
const pluginPath = join(dir, "plugin-default.mjs");
|
|
15
|
-
await writeFile(
|
|
16
|
-
pluginPath,
|
|
17
|
-
[
|
|
18
|
-
"export default {",
|
|
19
|
-
" name: 'from-default',",
|
|
20
|
-
" manifest: { capabilities: ['hooks'], hookStages: ['input'] },",
|
|
21
|
-
" onInput: ({ input }) => ({ overrideInput: input })",
|
|
22
|
-
"};",
|
|
23
|
-
].join("\n"),
|
|
24
|
-
"utf8",
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const plugin = await loadAgentPluginFromPath(pluginPath);
|
|
28
|
-
expect(plugin.name).toBe("from-default");
|
|
29
|
-
expect(plugin.manifest.capabilities).toContain("hooks");
|
|
30
|
-
} finally {
|
|
31
|
-
await rm(dir, { recursive: true, force: true });
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("loads named plugin export from path", async () => {
|
|
36
|
-
const dir = await mkdtemp(join(tmpdir(), "core-plugin-loader-"));
|
|
37
|
-
try {
|
|
38
|
-
const pluginPath = join(dir, "plugin-named.mjs");
|
|
39
|
-
await writeFile(
|
|
40
|
-
pluginPath,
|
|
41
|
-
[
|
|
42
|
-
"export const plugin = {",
|
|
43
|
-
" name: 'from-named',",
|
|
44
|
-
" manifest: { capabilities: ['tools'] },",
|
|
45
|
-
"};",
|
|
46
|
-
].join("\n"),
|
|
47
|
-
"utf8",
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const plugin = await loadAgentPluginFromPath(pluginPath, {
|
|
51
|
-
exportName: "plugin",
|
|
52
|
-
});
|
|
53
|
-
expect(plugin.name).toBe("from-named");
|
|
54
|
-
} finally {
|
|
55
|
-
await rm(dir, { recursive: true, force: true });
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("loads multiple plugins from file paths", async () => {
|
|
60
|
-
const dir = await mkdtemp(join(tmpdir(), "core-plugin-loader-"));
|
|
61
|
-
try {
|
|
62
|
-
const firstPath = join(dir, "plugin-a.mjs");
|
|
63
|
-
const secondPath = join(dir, "plugin-b.mjs");
|
|
64
|
-
await writeFile(
|
|
65
|
-
firstPath,
|
|
66
|
-
"export default { name: 'plugin-a', manifest: { capabilities: ['tools'] } };",
|
|
67
|
-
"utf8",
|
|
68
|
-
);
|
|
69
|
-
await writeFile(
|
|
70
|
-
secondPath,
|
|
71
|
-
"export default { name: 'plugin-b', manifest: { capabilities: ['commands'] } };",
|
|
72
|
-
"utf8",
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const plugins = await loadAgentPluginsFromPaths([firstPath, secondPath]);
|
|
76
|
-
expect(plugins.map((plugin) => plugin.name)).toEqual([
|
|
77
|
-
"plugin-a",
|
|
78
|
-
"plugin-b",
|
|
79
|
-
]);
|
|
80
|
-
} finally {
|
|
81
|
-
await rm(dir, { recursive: true, force: true });
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("loads TypeScript plugins from file paths", async () => {
|
|
86
|
-
const dir = await mkdtemp(join(tmpdir(), "core-plugin-loader-"));
|
|
87
|
-
try {
|
|
88
|
-
const pluginPath = join(dir, "plugin-ts.ts");
|
|
89
|
-
await writeFile(
|
|
90
|
-
pluginPath,
|
|
91
|
-
[
|
|
92
|
-
"const name: string = 'plugin-ts';",
|
|
93
|
-
"export default {",
|
|
94
|
-
" name,",
|
|
95
|
-
" manifest: { capabilities: ['tools'] },",
|
|
96
|
-
"};",
|
|
97
|
-
].join("\n"),
|
|
98
|
-
"utf8",
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const plugin = await loadAgentPluginFromPath(pluginPath);
|
|
102
|
-
expect(plugin.name).toBe("plugin-ts");
|
|
103
|
-
} finally {
|
|
104
|
-
await rm(dir, { recursive: true, force: true });
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("resolves plugin-local dependencies from the plugin path", async () => {
|
|
109
|
-
const dir = await mkdtemp(join(tmpdir(), "core-plugin-loader-"));
|
|
110
|
-
try {
|
|
111
|
-
const depDir = join(dir, "node_modules", "plugin-local-dep");
|
|
112
|
-
await mkdir(depDir, { recursive: true });
|
|
113
|
-
await writeFile(
|
|
114
|
-
join(depDir, "package.json"),
|
|
115
|
-
JSON.stringify({
|
|
116
|
-
name: "plugin-local-dep",
|
|
117
|
-
type: "module",
|
|
118
|
-
exports: "./index.js",
|
|
119
|
-
}),
|
|
120
|
-
"utf8",
|
|
121
|
-
);
|
|
122
|
-
await writeFile(
|
|
123
|
-
join(depDir, "index.js"),
|
|
124
|
-
"export const depName = 'plugin-local-dep';\n",
|
|
125
|
-
"utf8",
|
|
126
|
-
);
|
|
127
|
-
const pluginPath = join(dir, "plugin-with-dep.ts");
|
|
128
|
-
await writeFile(
|
|
129
|
-
pluginPath,
|
|
130
|
-
[
|
|
131
|
-
"import { depName } from 'plugin-local-dep';",
|
|
132
|
-
"export default {",
|
|
133
|
-
" name: depName,",
|
|
134
|
-
" manifest: { capabilities: ['tools'] },",
|
|
135
|
-
"};",
|
|
136
|
-
].join("\n"),
|
|
137
|
-
"utf8",
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
const plugin = await loadAgentPluginFromPath(pluginPath, { cwd: dir });
|
|
141
|
-
expect(plugin.name).toBe("plugin-local-dep");
|
|
142
|
-
} finally {
|
|
143
|
-
await rm(dir, { recursive: true, force: true });
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("prefers plugin-installed SDK packages over workspace aliases", async () => {
|
|
148
|
-
const dir = await mkdtemp(join(tmpdir(), "core-plugin-loader-"));
|
|
149
|
-
try {
|
|
150
|
-
const depDir = join(dir, "node_modules", "@clinebot", "shared");
|
|
151
|
-
await mkdir(depDir, { recursive: true });
|
|
152
|
-
await writeFile(
|
|
153
|
-
join(depDir, "package.json"),
|
|
154
|
-
JSON.stringify({
|
|
155
|
-
name: "@clinebot/shared",
|
|
156
|
-
type: "module",
|
|
157
|
-
exports: "./index.js",
|
|
158
|
-
}),
|
|
159
|
-
"utf8",
|
|
160
|
-
);
|
|
161
|
-
await writeFile(
|
|
162
|
-
join(depDir, "index.js"),
|
|
163
|
-
"export const sdkMarker = 'plugin-installed-sdk';\n",
|
|
164
|
-
"utf8",
|
|
165
|
-
);
|
|
166
|
-
const pluginPath = join(dir, "plugin-with-sdk-dep.ts");
|
|
167
|
-
await writeFile(
|
|
168
|
-
pluginPath,
|
|
169
|
-
[
|
|
170
|
-
"import { sdkMarker } from '@clinebot/shared';",
|
|
171
|
-
"export default {",
|
|
172
|
-
" name: sdkMarker,",
|
|
173
|
-
" manifest: { capabilities: ['tools'] },",
|
|
174
|
-
"};",
|
|
175
|
-
].join("\n"),
|
|
176
|
-
"utf8",
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
const plugin = await loadAgentPluginFromPath(pluginPath, { cwd: dir });
|
|
180
|
-
expect(plugin.name).toBe("plugin-installed-sdk");
|
|
181
|
-
} finally {
|
|
182
|
-
await rm(dir, { recursive: true, force: true });
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it("requires copied plugins to provide their own non-SDK dependencies", async () => {
|
|
187
|
-
const dir = await mkdtemp(join(tmpdir(), "core-plugin-loader-copy-"));
|
|
188
|
-
try {
|
|
189
|
-
const pluginPath = join(dir, "portable-subagents.ts");
|
|
190
|
-
await writeFile(
|
|
191
|
-
pluginPath,
|
|
192
|
-
[
|
|
193
|
-
"import { resolveClineDataDir } from '@clinebot/shared/storage';",
|
|
194
|
-
"import YAML from 'yaml';",
|
|
195
|
-
"export default {",
|
|
196
|
-
" name: typeof resolveClineDataDir === 'function' ? YAML.stringify({ ok: true }) : 'invalid',",
|
|
197
|
-
" manifest: { capabilities: ['tools'] },",
|
|
198
|
-
"};",
|
|
199
|
-
].join("\n"),
|
|
200
|
-
"utf8",
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
await expect(
|
|
204
|
-
loadAgentPluginFromPath(pluginPath, { cwd: dir, useCache: true }),
|
|
205
|
-
).rejects.toThrow(/Cannot find (package|module) 'yaml'/i);
|
|
206
|
-
} finally {
|
|
207
|
-
await rm(dir, { recursive: true, force: true });
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("rejects invalid plugin export missing manifest", async () => {
|
|
212
|
-
const dir = await mkdtemp(join(tmpdir(), "core-plugin-loader-"));
|
|
213
|
-
try {
|
|
214
|
-
const pluginPath = join(dir, "invalid-plugin.mjs");
|
|
215
|
-
await writeFile(
|
|
216
|
-
pluginPath,
|
|
217
|
-
"export default { name: 'invalid-plugin' };",
|
|
218
|
-
"utf8",
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
await expect(loadAgentPluginFromPath(pluginPath)).rejects.toThrow(
|
|
222
|
-
/missing required "manifest"/i,
|
|
223
|
-
);
|
|
224
|
-
} finally {
|
|
225
|
-
await rm(dir, { recursive: true, force: true });
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
});
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { builtinModules, createRequire } from "node:module";
|
|
3
|
-
import { dirname, resolve } from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import type { AgentConfig } from "@clinebot/agents";
|
|
6
|
-
import createJiti from "jiti";
|
|
7
|
-
|
|
8
|
-
type AgentPlugin = NonNullable<AgentConfig["extensions"]>[number];
|
|
9
|
-
type PluginLike = {
|
|
10
|
-
name: string;
|
|
11
|
-
manifest: {
|
|
12
|
-
capabilities: string[];
|
|
13
|
-
hookStages?: string[];
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export interface LoadAgentPluginFromPathOptions {
|
|
18
|
-
exportName?: string;
|
|
19
|
-
cwd?: string;
|
|
20
|
-
useCache?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
24
|
-
const WORKSPACE_ALIASES = collectWorkspaceAliases(MODULE_DIR);
|
|
25
|
-
const BUILTIN_MODULES = new Set(
|
|
26
|
-
builtinModules.flatMap((id) => [id, id.replace(/^node:/, "")]),
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
function isObject(value: unknown): value is Record<string, unknown> {
|
|
30
|
-
return typeof value === "object" && value !== null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function hasValidStringArray(value: unknown): value is string[] {
|
|
34
|
-
return (
|
|
35
|
-
Array.isArray(value) && value.every((entry) => typeof entry === "string")
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function validatePluginManifest(
|
|
40
|
-
plugin: PluginLike,
|
|
41
|
-
absolutePath: string,
|
|
42
|
-
): void {
|
|
43
|
-
if (!isObject(plugin.manifest)) {
|
|
44
|
-
throw new Error(
|
|
45
|
-
`Invalid plugin module at ${absolutePath}: missing required "manifest"`,
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
if (!hasValidStringArray(plugin.manifest.capabilities)) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
`Invalid plugin module at ${absolutePath}: manifest.capabilities must be a string array`,
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
if (plugin.manifest.capabilities.length === 0) {
|
|
54
|
-
throw new Error(
|
|
55
|
-
`Invalid plugin module at ${absolutePath}: manifest.capabilities cannot be empty`,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
if (
|
|
59
|
-
Object.hasOwn(plugin.manifest, "hookStages") &&
|
|
60
|
-
!hasValidStringArray(plugin.manifest.hookStages)
|
|
61
|
-
) {
|
|
62
|
-
throw new Error(
|
|
63
|
-
`Invalid plugin module at ${absolutePath}: manifest.hookStages must be a string array when provided`,
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function validatePluginExport(
|
|
69
|
-
plugin: unknown,
|
|
70
|
-
absolutePath: string,
|
|
71
|
-
): asserts plugin is PluginLike {
|
|
72
|
-
if (!isObject(plugin)) {
|
|
73
|
-
throw new Error(
|
|
74
|
-
`Invalid plugin module at ${absolutePath}: expected object export`,
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
if (typeof plugin.name !== "string" || plugin.name.length === 0) {
|
|
78
|
-
throw new Error(
|
|
79
|
-
`Invalid plugin module at ${absolutePath}: expected non-empty "name"`,
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
if (!Object.hasOwn(plugin, "manifest")) {
|
|
83
|
-
throw new Error(
|
|
84
|
-
`Invalid plugin module at ${absolutePath}: missing required "manifest"`,
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
validatePluginManifest(plugin as PluginLike, absolutePath);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function collectWorkspaceAliases(startDir: string): Record<string, string> {
|
|
91
|
-
const root = resolve(startDir, "..", "..", "..", "..");
|
|
92
|
-
const aliases: Record<string, string> = {};
|
|
93
|
-
const candidates: Record<string, string> = {
|
|
94
|
-
"@clinebot/agents": resolve(root, "packages/agents/src/index.ts"),
|
|
95
|
-
"@clinebot/core": resolve(root, "packages/core/src/index.node.ts"),
|
|
96
|
-
"@clinebot/llms": resolve(root, "packages/llms/src/index.ts"),
|
|
97
|
-
"@clinebot/rpc": resolve(root, "packages/rpc/src/index.ts"),
|
|
98
|
-
"@clinebot/scheduler": resolve(root, "packages/scheduler/src/index.ts"),
|
|
99
|
-
"@clinebot/shared": resolve(root, "packages/shared/src/index.ts"),
|
|
100
|
-
"@clinebot/shared/storage": resolve(
|
|
101
|
-
root,
|
|
102
|
-
"packages/shared/src/storage/index.ts",
|
|
103
|
-
),
|
|
104
|
-
"@clinebot/shared/db": resolve(root, "packages/shared/src/db/index.ts"),
|
|
105
|
-
};
|
|
106
|
-
for (const [key, value] of Object.entries(candidates)) {
|
|
107
|
-
if (existsSync(value)) {
|
|
108
|
-
aliases[key] = value;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return aliases;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function collectPluginImportAliases(
|
|
115
|
-
pluginPath: string,
|
|
116
|
-
): Record<string, string> {
|
|
117
|
-
const pluginRequire = createRequire(pluginPath);
|
|
118
|
-
const aliases: Record<string, string> = {};
|
|
119
|
-
for (const [specifier, sourcePath] of Object.entries(WORKSPACE_ALIASES)) {
|
|
120
|
-
try {
|
|
121
|
-
pluginRequire.resolve(specifier);
|
|
122
|
-
continue;
|
|
123
|
-
} catch {
|
|
124
|
-
// Use the workspace source only when the plugin package does not provide
|
|
125
|
-
// its own installed SDK dependency.
|
|
126
|
-
}
|
|
127
|
-
aliases[specifier] = sourcePath;
|
|
128
|
-
}
|
|
129
|
-
return aliases;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
async function importPluginModule(
|
|
133
|
-
absolutePath: string,
|
|
134
|
-
options: LoadAgentPluginFromPathOptions = {},
|
|
135
|
-
): Promise<Record<string, unknown>> {
|
|
136
|
-
const aliases = collectPluginImportAliases(absolutePath);
|
|
137
|
-
const jiti = createJiti(absolutePath, {
|
|
138
|
-
alias: aliases,
|
|
139
|
-
cache: options.useCache,
|
|
140
|
-
requireCache: options.useCache,
|
|
141
|
-
esmResolve: true,
|
|
142
|
-
interopDefault: false,
|
|
143
|
-
nativeModules: [...BUILTIN_MODULES],
|
|
144
|
-
transformModules: Object.keys(aliases),
|
|
145
|
-
});
|
|
146
|
-
return (await jiti.import(absolutePath, {})) as Record<string, unknown>;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export async function loadAgentPluginFromPath(
|
|
150
|
-
pluginPath: string,
|
|
151
|
-
options: LoadAgentPluginFromPathOptions = {},
|
|
152
|
-
): Promise<AgentPlugin> {
|
|
153
|
-
const absolutePath = resolve(options.cwd ?? process.cwd(), pluginPath);
|
|
154
|
-
const moduleExports = await importPluginModule(absolutePath, options);
|
|
155
|
-
const exportName = options.exportName ?? "plugin";
|
|
156
|
-
const plugin = (moduleExports.default ??
|
|
157
|
-
moduleExports[exportName]) as unknown;
|
|
158
|
-
|
|
159
|
-
validatePluginExport(plugin, absolutePath);
|
|
160
|
-
return plugin as AgentPlugin;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export async function loadAgentPluginsFromPaths(
|
|
164
|
-
pluginPaths: string[],
|
|
165
|
-
options: LoadAgentPluginFromPathOptions = {},
|
|
166
|
-
): Promise<AgentPlugin[]> {
|
|
167
|
-
const loaded: AgentPlugin[] = [];
|
|
168
|
-
for (const pluginPath of pluginPaths) {
|
|
169
|
-
loaded.push(await loadAgentPluginFromPath(pluginPath, options));
|
|
170
|
-
}
|
|
171
|
-
return loaded;
|
|
172
|
-
}
|