@clinebot/core 0.0.35 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/ClineCore.d.ts +53 -39
- package/dist/ClineCore.d.ts.map +1 -1
- package/dist/account/index.d.ts +1 -1
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/rpc.d.ts +6 -6
- package/dist/account/rpc.d.ts.map +1 -1
- package/dist/cron/index.d.ts +6 -0
- package/dist/cron/index.d.ts.map +1 -0
- package/dist/cron/resource-limiter.d.ts +9 -0
- package/dist/cron/resource-limiter.d.ts.map +1 -0
- package/dist/cron/schedule-command-service.d.ts +10 -0
- package/dist/cron/schedule-command-service.d.ts.map +1 -0
- package/dist/cron/schedule-service.d.ts +100 -0
- package/dist/cron/schedule-service.d.ts.map +1 -0
- package/dist/cron/scheduler.d.ts +66 -0
- package/dist/cron/scheduler.d.ts.map +1 -0
- package/dist/cron/sqlite-schedule-store.d.ts +52 -0
- package/dist/cron/sqlite-schedule-store.d.ts.map +1 -0
- package/dist/extensions/config/agent-config-loader.d.ts +4 -3
- package/dist/extensions/config/agent-config-loader.d.ts.map +1 -1
- package/dist/extensions/config/runtime-commands.d.ts +1 -0
- package/dist/extensions/config/runtime-commands.d.ts.map +1 -1
- package/dist/extensions/config/user-instruction-config-loader.d.ts +1 -0
- package/dist/extensions/config/user-instruction-config-loader.d.ts.map +1 -1
- package/dist/extensions/context/agentic-compaction.d.ts +2 -2
- package/dist/extensions/context/agentic-compaction.d.ts.map +1 -1
- package/dist/extensions/context/compaction-shared.d.ts +5 -4
- package/dist/extensions/context/compaction-shared.d.ts.map +1 -1
- package/dist/extensions/context/compaction.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-config-loader.d.ts +9 -2
- package/dist/extensions/plugin/plugin-config-loader.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-loader.d.ts +5 -3
- package/dist/extensions/plugin/plugin-loader.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-module-import.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-sandbox.d.ts +15 -2
- package/dist/extensions/plugin/plugin-sandbox.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-targeting.d.ts +7 -0
- package/dist/extensions/plugin/plugin-targeting.d.ts.map +1 -0
- package/dist/extensions/plugin-sandbox-bootstrap.js +211 -211
- package/dist/extensions/tools/definitions.d.ts +1 -1
- package/dist/extensions/tools/definitions.d.ts.map +1 -1
- package/dist/extensions/tools/executors/apply-patch.d.ts +3 -1
- package/dist/extensions/tools/executors/apply-patch.d.ts.map +1 -1
- package/dist/extensions/tools/executors/search.d.ts +1 -1
- package/dist/extensions/tools/executors/search.d.ts.map +1 -1
- package/dist/extensions/tools/index.d.ts +2 -0
- package/dist/extensions/tools/index.d.ts.map +1 -1
- package/dist/extensions/tools/presets.d.ts +26 -43
- package/dist/extensions/tools/presets.d.ts.map +1 -1
- package/dist/extensions/tools/runtime.d.ts +25 -0
- package/dist/extensions/tools/runtime.d.ts.map +1 -0
- package/dist/extensions/tools/schemas.d.ts.map +1 -1
- package/dist/extensions/tools/team/team-tools.d.ts +1 -0
- package/dist/extensions/tools/team/team-tools.d.ts.map +1 -1
- package/dist/hooks/hook-file-hooks.d.ts +4 -1
- package/dist/hooks/hook-file-hooks.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/subprocess.d.ts +8 -1
- package/dist/hooks/subprocess.d.ts.map +1 -1
- package/dist/hub/browser-websocket.d.ts +18 -0
- package/dist/hub/browser-websocket.d.ts.map +1 -0
- package/dist/hub/client.d.ts +45 -0
- package/dist/hub/client.d.ts.map +1 -0
- package/dist/hub/connect.d.ts +15 -0
- package/dist/hub/connect.d.ts.map +1 -0
- package/dist/hub/daemon-entry.d.ts +2 -0
- package/dist/hub/daemon-entry.d.ts.map +1 -0
- package/dist/hub/daemon-entry.js +1045 -0
- package/dist/hub/daemon.d.ts +5 -0
- package/dist/hub/daemon.d.ts.map +1 -0
- package/dist/hub/defaults.d.ts +13 -0
- package/dist/hub/defaults.d.ts.map +1 -0
- package/dist/hub/discovery.d.ts +29 -0
- package/dist/hub/discovery.d.ts.map +1 -0
- package/dist/hub/index.d.ts +15 -0
- package/dist/hub/index.d.ts.map +1 -0
- package/dist/hub/index.js +1044 -0
- package/dist/hub/native-transport.d.ts +17 -0
- package/dist/hub/native-transport.d.ts.map +1 -0
- package/dist/hub/runtime-handlers.d.ts +11 -0
- package/dist/hub/runtime-handlers.d.ts.map +1 -0
- package/dist/hub/server.d.ts +86 -0
- package/dist/hub/server.d.ts.map +1 -0
- package/dist/hub/session-client.d.ts +87 -0
- package/dist/hub/session-client.d.ts.map +1 -0
- package/dist/hub/start-shared-server.d.ts +19 -0
- package/dist/hub/start-shared-server.d.ts.map +1 -0
- package/dist/hub/transport.d.ts +8 -0
- package/dist/hub/transport.d.ts.map +1 -0
- package/dist/hub/ui-client.d.ts +44 -0
- package/dist/hub/ui-client.d.ts.map +1 -0
- package/dist/hub/workspace.d.ts +4 -0
- package/dist/hub/workspace.d.ts.map +1 -0
- package/dist/index.d.ts +26 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +498 -476
- package/dist/llms/configured-provider-registry.d.ts +28 -0
- package/dist/llms/configured-provider-registry.d.ts.map +1 -0
- package/dist/llms/provider-defaults.d.ts +27 -0
- package/dist/llms/provider-defaults.d.ts.map +1 -0
- package/dist/llms/provider-settings.d.ts +202 -0
- package/dist/llms/provider-settings.d.ts.map +1 -0
- package/dist/llms/runtime-config.d.ts +4 -0
- package/dist/llms/runtime-config.d.ts.map +1 -0
- package/dist/llms/runtime-registry.d.ts +20 -0
- package/dist/llms/runtime-registry.d.ts.map +1 -0
- package/dist/llms/runtime-types.d.ts +85 -0
- package/dist/llms/runtime-types.d.ts.map +1 -0
- package/dist/runtime/host.d.ts +1 -2
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/rules.d.ts +1 -0
- package/dist/runtime/rules.d.ts.map +1 -1
- package/dist/runtime/runtime-builder.d.ts.map +1 -1
- package/dist/runtime/runtime-host.d.ts +22 -24
- package/dist/runtime/runtime-host.d.ts.map +1 -1
- package/dist/runtime/runtime-oauth-token-manager.d.ts.map +1 -1
- package/dist/runtime/session-runtime.d.ts +1 -19
- package/dist/runtime/session-runtime.d.ts.map +1 -1
- package/dist/services/global-settings.d.ts +12 -0
- package/dist/services/global-settings.d.ts.map +1 -0
- package/dist/services/local-runtime-bootstrap.d.ts +9 -3
- package/dist/services/local-runtime-bootstrap.d.ts.map +1 -1
- package/dist/services/plugin-tools.d.ts +16 -0
- package/dist/services/plugin-tools.d.ts.map +1 -0
- package/dist/services/providers/local-provider-registry.d.ts +4 -4
- package/dist/services/providers/local-provider-registry.d.ts.map +1 -1
- package/dist/services/providers/local-provider-service.d.ts +13 -13
- package/dist/services/providers/local-provider-service.d.ts.map +1 -1
- package/dist/services/session-data.d.ts +1 -1
- package/dist/services/session-data.d.ts.map +1 -1
- package/dist/services/storage/provider-settings-legacy-migration.d.ts +1 -1
- package/dist/services/storage/provider-settings-legacy-migration.d.ts.map +1 -1
- package/dist/services/telemetry/index.js +28 -15
- package/dist/services/workspace-manifest.d.ts +11 -0
- package/dist/services/workspace-manifest.d.ts.map +1 -1
- package/dist/session/persistence-service.d.ts +11 -23
- package/dist/session/persistence-service.d.ts.map +1 -1
- package/dist/session/session-manifest-store.d.ts +22 -0
- package/dist/session/session-manifest-store.d.ts.map +1 -0
- package/dist/session/session-row.d.ts +93 -0
- package/dist/session/session-row.d.ts.map +1 -0
- package/dist/session/session-service.d.ts +2 -102
- package/dist/session/session-service.d.ts.map +1 -1
- package/dist/session/subagent-session-manager.d.ts +36 -0
- package/dist/session/subagent-session-manager.d.ts.map +1 -0
- package/dist/session/team-persistence-store.d.ts +24 -0
- package/dist/session/team-persistence-store.d.ts.map +1 -0
- package/dist/transports/hub.d.ts +47 -0
- package/dist/transports/hub.d.ts.map +1 -0
- package/dist/transports/local.d.ts +10 -6
- package/dist/transports/local.d.ts.map +1 -1
- package/dist/transports/remote.d.ts +10 -0
- package/dist/transports/remote.d.ts.map +1 -0
- package/dist/transports/runtime-host-support.d.ts +3 -2
- package/dist/transports/runtime-host-support.d.ts.map +1 -1
- package/dist/types/chat-schema.d.ts +10 -12
- package/dist/types/chat-schema.d.ts.map +1 -1
- package/dist/types/config.d.ts +8 -7
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/provider-settings.d.ts +4 -5
- package/dist/types/provider-settings.d.ts.map +1 -1
- package/dist/types/session.d.ts +2 -1
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +20 -6
- package/src/ClineCore.ts +68 -40
- package/src/account/index.ts +3 -3
- package/src/account/rpc.ts +12 -12
- package/src/cron/index.ts +5 -0
- package/src/cron/resource-limiter.ts +46 -0
- package/src/cron/schedule-command-service.ts +193 -0
- package/src/cron/schedule-service.ts +703 -0
- package/src/cron/scheduler.ts +637 -0
- package/src/cron/sqlite-schedule-store.ts +708 -0
- package/src/extensions/config/agent-config-loader.ts +17 -7
- package/src/extensions/config/runtime-commands.ts +6 -0
- package/src/extensions/config/user-instruction-config-loader.ts +1 -0
- package/src/extensions/context/agentic-compaction.ts +3 -3
- package/src/extensions/context/basic-compaction.ts +2 -2
- package/src/extensions/context/compaction-shared.ts +5 -4
- package/src/extensions/context/compaction.ts +3 -3
- package/src/extensions/plugin/plugin-config-loader.ts +17 -2
- package/src/extensions/plugin/plugin-loader.ts +48 -4
- package/src/extensions/plugin/plugin-module-import.ts +0 -2
- package/src/extensions/plugin/plugin-sandbox-bootstrap.ts +93 -39
- package/src/extensions/plugin/plugin-sandbox.ts +47 -27
- package/src/extensions/plugin/plugin-targeting.ts +32 -0
- package/src/extensions/tools/definitions.ts +30 -49
- package/src/extensions/tools/executors/apply-patch.ts +69 -80
- package/src/extensions/tools/executors/search.ts +195 -3
- package/src/extensions/tools/index.ts +10 -0
- package/src/extensions/tools/presets.ts +31 -46
- package/src/extensions/tools/runtime.ts +261 -0
- package/src/extensions/tools/schemas.ts +4 -2
- package/src/extensions/tools/team/team-tools.ts +21 -0
- package/src/hooks/hook-file-hooks.ts +8 -2
- package/src/hooks/index.ts +0 -7
- package/src/hooks/subprocess-runner.ts +1 -1
- package/src/hooks/subprocess.ts +9 -0
- package/src/hub/browser-websocket.ts +137 -0
- package/src/hub/client.ts +574 -0
- package/src/hub/connect.ts +156 -0
- package/src/hub/daemon-entry.ts +87 -0
- package/src/hub/daemon.ts +181 -0
- package/src/hub/defaults.ts +43 -0
- package/src/hub/discovery.ts +247 -0
- package/src/hub/index.ts +14 -0
- package/src/hub/native-transport.ts +31 -0
- package/src/hub/runtime-handlers.ts +140 -0
- package/src/hub/server.ts +1888 -0
- package/src/hub/session-client.ts +460 -0
- package/src/hub/start-shared-server.ts +58 -0
- package/src/hub/transport.ts +14 -0
- package/src/hub/ui-client.ts +122 -0
- package/src/hub/workspace.ts +19 -0
- package/src/index.ts +124 -68
- package/src/llms/configured-provider-registry.ts +193 -0
- package/src/llms/provider-defaults.ts +637 -0
- package/src/llms/provider-settings.ts +263 -0
- package/src/llms/runtime-config.ts +43 -0
- package/src/llms/runtime-registry.ts +171 -0
- package/src/llms/runtime-types.ts +121 -0
- package/src/runtime/host.ts +107 -269
- package/src/runtime/index.ts +1 -0
- package/src/runtime/rules.ts +12 -0
- package/src/runtime/runtime-builder.ts +24 -8
- package/src/runtime/runtime-host.ts +89 -61
- package/src/runtime/runtime-oauth-token-manager.ts +11 -15
- package/src/runtime/session-runtime.ts +0 -24
- package/src/services/global-settings.ts +122 -0
- package/src/services/local-runtime-bootstrap.ts +51 -13
- package/src/services/plugin-tools.ts +85 -0
- package/src/services/providers/local-provider-registry.ts +6 -6
- package/src/services/providers/local-provider-service.ts +42 -37
- package/src/services/session-data.ts +15 -9
- package/src/services/storage/provider-settings-legacy-migration.ts +6 -4
- package/src/services/storage/provider-settings-manager.ts +1 -1
- package/src/services/workspace-manifest.ts +18 -0
- package/src/session/file-session-service.ts +1 -1
- package/src/session/index.ts +6 -27
- package/src/session/persistence-service.ts +119 -504
- package/src/session/session-manifest-store.ts +158 -0
- package/src/session/session-row.ts +199 -0
- package/src/session/session-service.ts +17 -376
- package/src/session/session-team-coordination.ts +1 -1
- package/src/session/subagent-session-manager.ts +397 -0
- package/src/session/team-persistence-store.ts +176 -0
- package/src/transports/hub.ts +656 -0
- package/src/transports/local.ts +135 -40
- package/src/transports/remote.ts +26 -0
- package/src/transports/runtime-host-support.ts +63 -9
- package/src/types/chat-schema.ts +4 -5
- package/src/types/config.ts +8 -7
- package/src/types/provider-settings.ts +11 -7
- package/src/types/session.ts +2 -4
- package/src/types.ts +27 -1
- package/dist/hooks/persistent.d.ts +0 -64
- package/dist/hooks/persistent.d.ts.map +0 -1
- package/dist/runtime/rpc-runtime-ensure.d.ts +0 -65
- package/dist/runtime/rpc-runtime-ensure.d.ts.map +0 -1
- package/dist/runtime/rpc-spawn-lease.d.ts +0 -8
- package/dist/runtime/rpc-spawn-lease.d.ts.map +0 -1
- package/dist/session/rpc-session-service.d.ts +0 -16
- package/dist/session/rpc-session-service.d.ts.map +0 -1
- package/dist/session/sqlite-rpc-session-backend.d.ts +0 -31
- package/dist/session/sqlite-rpc-session-backend.d.ts.map +0 -1
- package/dist/transports/rpc.d.ts +0 -51
- package/dist/transports/rpc.d.ts.map +0 -1
- package/src/ClineCore.test.ts +0 -226
- package/src/account/cline-account-service.test.ts +0 -185
- package/src/account/featurebase-token.test.ts +0 -175
- package/src/account/rpc.test.ts +0 -63
- package/src/auth/bounded-ttl-cache.test.ts +0 -38
- package/src/auth/client.test.ts +0 -69
- package/src/auth/cline.test.ts +0 -267
- package/src/auth/codex.test.ts +0 -170
- package/src/auth/oca.test.ts +0 -340
- package/src/auth/server.test.ts +0 -287
- package/src/auth/utils.test.ts +0 -128
- package/src/extensions/config/agent-config-loader.test.ts +0 -236
- package/src/extensions/config/hooks-config-loader.test.ts +0 -20
- package/src/extensions/config/runtime-commands.test.ts +0 -115
- package/src/extensions/config/unified-config-file-watcher.test.ts +0 -196
- package/src/extensions/config/user-instruction-config-loader.test.ts +0 -246
- package/src/extensions/context/compaction.test.ts +0 -483
- package/src/extensions/mcp/config-loader.test.ts +0 -238
- package/src/extensions/mcp/manager.test.ts +0 -105
- package/src/extensions/plugin/plugin-config-loader.test.ts +0 -184
- package/src/extensions/plugin/plugin-loader.test.ts +0 -292
- package/src/extensions/plugin/plugin-sandbox.test.ts +0 -423
- package/src/extensions/tools/definitions.test.ts +0 -780
- package/src/extensions/tools/executors/bash.test.ts +0 -87
- package/src/extensions/tools/executors/editor.test.ts +0 -35
- package/src/extensions/tools/executors/file-read.test.ts +0 -125
- package/src/extensions/tools/model-tool-routing.test.ts +0 -86
- package/src/extensions/tools/presets.test.ts +0 -70
- package/src/extensions/tools/team/multi-agent.lifecycle.test.ts +0 -455
- package/src/extensions/tools/team/spawn-agent-tool.test.ts +0 -381
- package/src/extensions/tools/team/team-tools.test.ts +0 -918
- package/src/hooks/checkpoint-hooks.test.ts +0 -168
- package/src/hooks/hook-file-hooks.test.ts +0 -311
- package/src/hooks/persistent.ts +0 -661
- package/src/runtime/history.test.ts +0 -114
- package/src/runtime/host.test.ts +0 -230
- package/src/runtime/rpc-runtime-ensure.test.ts +0 -123
- package/src/runtime/rpc-runtime-ensure.ts +0 -659
- package/src/runtime/rpc-spawn-lease.test.ts +0 -81
- package/src/runtime/rpc-spawn-lease.ts +0 -156
- package/src/runtime/runtime-builder.team-persistence.test.ts +0 -245
- package/src/runtime/runtime-builder.test.ts +0 -615
- package/src/runtime/runtime-oauth-token-manager.test.ts +0 -137
- package/src/runtime/runtime-parity.test.ts +0 -143
- package/src/services/providers/local-provider-service.test.ts +0 -1062
- package/src/services/session-data.test.ts +0 -160
- package/src/services/storage/provider-settings-legacy-migration.test.ts +0 -424
- package/src/services/storage/provider-settings-manager.test.ts +0 -191
- package/src/services/telemetry/OpenTelemetryAdapter.test.ts +0 -157
- package/src/services/telemetry/OpenTelemetryProvider.test.ts +0 -326
- package/src/services/telemetry/TelemetryLoggerSink.test.ts +0 -42
- package/src/services/telemetry/TelemetryService.test.ts +0 -134
- package/src/services/telemetry/distinct-id.test.ts +0 -57
- package/src/services/workspace/file-indexer.d.ts +0 -11
- package/src/services/workspace/file-indexer.test.ts +0 -156
- package/src/services/workspace/mention-enricher.test.ts +0 -106
- package/src/session/persistence-service.test.ts +0 -300
- package/src/session/rpc-session-service.ts +0 -114
- package/src/session/session-service.team-persistence.test.ts +0 -48
- package/src/session/sqlite-rpc-session-backend.ts +0 -301
- package/src/transports/local.e2e.test.ts +0 -380
- package/src/transports/local.test.ts +0 -2559
- package/src/transports/rpc.test.ts +0 -82
- package/src/transports/rpc.ts +0 -665
|
@@ -43,12 +43,14 @@ export function resolveAgentsConfigDirPath(): string {
|
|
|
43
43
|
return resolveAgentsConfigDirPathFromShared();
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function resolveAgentConfigSearchPaths(
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
export function resolveAgentConfigSearchPaths(
|
|
47
|
+
workspacePath?: string,
|
|
48
|
+
): string[] {
|
|
49
|
+
return resolveAgentConfigSearchPathsFromShared(workspacePath);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
export interface CreateAgentConfigWatcherOptions {
|
|
53
|
+
workspacePath?: string;
|
|
52
54
|
directoryPathOrPaths?: string | ReadonlyArray<string>;
|
|
53
55
|
debounceMs?: number;
|
|
54
56
|
emitParseErrors?: boolean;
|
|
@@ -56,6 +58,7 @@ export interface CreateAgentConfigWatcherOptions {
|
|
|
56
58
|
|
|
57
59
|
function toDirectoryPaths(
|
|
58
60
|
directoryPathOrPaths?: string | ReadonlyArray<string>,
|
|
61
|
+
workspacePath?: string,
|
|
59
62
|
): string[] {
|
|
60
63
|
if (Array.isArray(directoryPathOrPaths)) {
|
|
61
64
|
return [...directoryPathOrPaths];
|
|
@@ -63,15 +66,16 @@ function toDirectoryPaths(
|
|
|
63
66
|
if (typeof directoryPathOrPaths === "string") {
|
|
64
67
|
return [directoryPathOrPaths];
|
|
65
68
|
}
|
|
66
|
-
return resolveAgentConfigSearchPaths();
|
|
69
|
+
return resolveAgentConfigSearchPaths(workspacePath);
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
export function createAgentConfigDefinition(
|
|
70
73
|
directoryPathOrPaths?: string | ReadonlyArray<string>,
|
|
74
|
+
workspacePath?: string,
|
|
71
75
|
): UnifiedConfigDefinition<"agent", AgentYamlConfig> {
|
|
72
76
|
return {
|
|
73
77
|
type: "agent",
|
|
74
|
-
directories: toDirectoryPaths(directoryPathOrPaths),
|
|
78
|
+
directories: toDirectoryPaths(directoryPathOrPaths, workspacePath),
|
|
75
79
|
includeFile: (fileName) => isAgentConfigYamlFile(fileName),
|
|
76
80
|
parseFile: (context) => parseAgentConfigFromYaml(context.content),
|
|
77
81
|
resolveId: (config) => normalizeAgentConfigName(config.name),
|
|
@@ -82,7 +86,12 @@ export function createAgentConfigWatcher(
|
|
|
82
86
|
options?: CreateAgentConfigWatcherOptions,
|
|
83
87
|
): AgentConfigWatcher {
|
|
84
88
|
return new UnifiedConfigFileWatcher(
|
|
85
|
-
[
|
|
89
|
+
[
|
|
90
|
+
createAgentConfigDefinition(
|
|
91
|
+
options?.directoryPathOrPaths,
|
|
92
|
+
options?.workspacePath,
|
|
93
|
+
),
|
|
94
|
+
],
|
|
86
95
|
{
|
|
87
96
|
debounceMs: options?.debounceMs,
|
|
88
97
|
emitParseErrors: options?.emitParseErrors,
|
|
@@ -92,9 +101,10 @@ export function createAgentConfigWatcher(
|
|
|
92
101
|
|
|
93
102
|
export async function readAgentConfigsFromDisk(
|
|
94
103
|
directoryPathOrPaths?: string | ReadonlyArray<string>,
|
|
104
|
+
workspacePath?: string,
|
|
95
105
|
): Promise<Map<string, AgentYamlConfig>> {
|
|
96
106
|
const watcher = new UnifiedConfigFileWatcher([
|
|
97
|
-
createAgentConfigDefinition(directoryPathOrPaths),
|
|
107
|
+
createAgentConfigDefinition(directoryPathOrPaths, workspacePath),
|
|
98
108
|
]);
|
|
99
109
|
await watcher.refreshAll();
|
|
100
110
|
const snapshot = watcher.getSnapshot("agent");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { truncateSplit } from "@clinebot/shared";
|
|
1
2
|
import type {
|
|
2
3
|
SkillConfig,
|
|
3
4
|
UserInstructionConfigWatcher,
|
|
@@ -10,6 +11,7 @@ export type AvailableRuntimeCommand = {
|
|
|
10
11
|
id: string;
|
|
11
12
|
name: string;
|
|
12
13
|
instructions: string;
|
|
14
|
+
description?: string;
|
|
13
15
|
kind: RuntimeCommandKind;
|
|
14
16
|
};
|
|
15
17
|
|
|
@@ -32,6 +34,10 @@ function listCommandsForKind(
|
|
|
32
34
|
id,
|
|
33
35
|
name: record.item.name,
|
|
34
36
|
instructions: record.item.instructions,
|
|
37
|
+
description: truncateSplit(
|
|
38
|
+
record.item.description ?? record.item.instructions,
|
|
39
|
+
".",
|
|
40
|
+
),
|
|
35
41
|
kind,
|
|
36
42
|
}))
|
|
37
43
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type * as LlmsProviders from "@clinebot/llms";
|
|
2
1
|
import { createHandler } from "@clinebot/llms";
|
|
3
2
|
import type { BasicLogger } from "@clinebot/shared";
|
|
4
3
|
import type {
|
|
@@ -6,6 +5,7 @@ import type {
|
|
|
6
5
|
CoreCompactionResult,
|
|
7
6
|
CoreCompactionSummarizerConfig,
|
|
8
7
|
} from "../../types/config";
|
|
8
|
+
import type { ProviderConfig } from "../../types/provider-settings";
|
|
9
9
|
import {
|
|
10
10
|
buildSummaryMessage,
|
|
11
11
|
buildSummaryRequest,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from "./compaction-shared";
|
|
21
21
|
|
|
22
22
|
async function generateSummary(options: {
|
|
23
|
-
providerConfig:
|
|
23
|
+
providerConfig: ProviderConfig;
|
|
24
24
|
request: string;
|
|
25
25
|
logger?: BasicLogger;
|
|
26
26
|
}): Promise<string> {
|
|
@@ -48,7 +48,7 @@ async function generateSummary(options: {
|
|
|
48
48
|
|
|
49
49
|
export async function runAgenticCompaction(options: {
|
|
50
50
|
context: CoreCompactionContext;
|
|
51
|
-
providerConfig:
|
|
51
|
+
providerConfig: ProviderConfig;
|
|
52
52
|
summarizer?: CoreCompactionSummarizerConfig;
|
|
53
53
|
preserveRecentTokens: number;
|
|
54
54
|
estimateMessageTokens: EstimateMessageTokens;
|
|
@@ -33,9 +33,9 @@ function sanitizeMessageForBasic(
|
|
|
33
33
|
return text ? { ...message, content: text } : undefined;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
// Preserve
|
|
36
|
+
// Preserve multimodal structure: trim text blocks, keep non-text blocks intact.
|
|
37
37
|
const kept = message.content.filter(
|
|
38
|
-
(block) => block.type
|
|
38
|
+
(block) => block.type !== "text" || block.text.trim(),
|
|
39
39
|
);
|
|
40
40
|
if (kept.length === 0) {
|
|
41
41
|
return undefined;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { ToolResultContent } from "@clinebot/llms";
|
|
2
2
|
import type { MessageWithMetadata } from "@clinebot/shared";
|
|
3
3
|
import type {
|
|
4
4
|
CoreCompactionContext,
|
|
5
5
|
CoreCompactionSummarizerConfig,
|
|
6
6
|
} from "../../types/config";
|
|
7
|
+
import type { ProviderConfig } from "../../types/provider-settings";
|
|
7
8
|
|
|
8
9
|
export const DEFAULT_CONTEXT_WINDOW_TOKENS = 200_000;
|
|
9
10
|
export const DEFAULT_THRESHOLD_RATIO = 0.95;
|
|
@@ -41,7 +42,7 @@ export function truncateText(text: string, limit: number): string {
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
export function flattenToolResultContent(
|
|
44
|
-
content:
|
|
45
|
+
content: ToolResultContent["content"],
|
|
45
46
|
): string {
|
|
46
47
|
if (typeof content === "string") {
|
|
47
48
|
return truncateText(content, TOOL_RESULT_CHAR_LIMIT);
|
|
@@ -404,9 +405,9 @@ Edited: ${options.fileOps.modifiedFiles.join(", ") || "none"}`,
|
|
|
404
405
|
}
|
|
405
406
|
|
|
406
407
|
export function resolveSummarizerConfig(options: {
|
|
407
|
-
activeProviderConfig:
|
|
408
|
+
activeProviderConfig: ProviderConfig;
|
|
408
409
|
summarizer?: CoreCompactionSummarizerConfig;
|
|
409
|
-
}):
|
|
410
|
+
}): ProviderConfig {
|
|
410
411
|
const summarizer = options.summarizer;
|
|
411
412
|
if (!summarizer) {
|
|
412
413
|
return {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type * as LlmsProviders from "@clinebot/llms";
|
|
2
1
|
import type {
|
|
3
2
|
CoreCompactionConfig,
|
|
4
3
|
CoreCompactionContext,
|
|
@@ -6,6 +5,7 @@ import type {
|
|
|
6
5
|
CoreCompactionStrategy,
|
|
7
6
|
CoreSessionConfig,
|
|
8
7
|
} from "../../types/config";
|
|
8
|
+
import type { ProviderConfig } from "../../types/provider-settings";
|
|
9
9
|
import { runAgenticCompaction } from "./agentic-compaction";
|
|
10
10
|
import { runBasicCompaction } from "./basic-compaction";
|
|
11
11
|
import {
|
|
@@ -41,7 +41,7 @@ type EstimateMessageTokens = ReturnType<typeof createTokenEstimator>;
|
|
|
41
41
|
|
|
42
42
|
type BuiltinCompactionStrategyOptions = {
|
|
43
43
|
context: CoreCompactionContext;
|
|
44
|
-
providerConfig:
|
|
44
|
+
providerConfig: ProviderConfig;
|
|
45
45
|
compaction: CoreCompactionConfig | undefined;
|
|
46
46
|
estimateMessageTokens: EstimateMessageTokens;
|
|
47
47
|
logger: Pick<CoreSessionConfig, "logger">["logger"];
|
|
@@ -129,7 +129,7 @@ export function createContextCompactionPrepareTurn(
|
|
|
129
129
|
({
|
|
130
130
|
providerId: config.providerId,
|
|
131
131
|
modelId: config.modelId,
|
|
132
|
-
} as
|
|
132
|
+
} as ProviderConfig);
|
|
133
133
|
const estimateMessageTokens = createTokenEstimator();
|
|
134
134
|
const strategy = userCompaction?.strategy ?? "basic";
|
|
135
135
|
const runBuiltinStrategy = BUILTIN_COMPACTION_STRATEGIES[strategy];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import type { AgentConfig } from "@clinebot/shared";
|
|
2
|
+
import type { AgentConfig, WorkspaceInfo } from "@clinebot/shared";
|
|
3
3
|
import {
|
|
4
4
|
discoverPluginModulePaths as discoverPluginModulePathsFromShared,
|
|
5
5
|
resolveConfiguredPluginModulePaths,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import type { PluginLoadDiagnostics } from "./plugin-load-report";
|
|
9
9
|
import { loadAgentPluginsFromPathsWithDiagnostics } from "./plugin-loader";
|
|
10
10
|
import { loadSandboxedPlugins } from "./plugin-sandbox";
|
|
11
|
+
import type { PluginTargeting } from "./plugin-targeting";
|
|
11
12
|
|
|
12
13
|
type AgentPlugin = NonNullable<AgentConfig["extensions"]>[number];
|
|
13
14
|
|
|
@@ -54,13 +55,20 @@ export function resolveAgentPluginPaths(
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
export interface ResolveAndLoadAgentPluginsOptions
|
|
57
|
-
extends ResolveAgentPluginPathsOptions
|
|
58
|
+
extends ResolveAgentPluginPathsOptions,
|
|
59
|
+
PluginTargeting {
|
|
58
60
|
mode?: "sandbox" | "in_process";
|
|
59
61
|
exportName?: string;
|
|
60
62
|
importTimeoutMs?: number;
|
|
61
63
|
hookTimeoutMs?: number;
|
|
62
64
|
contributionTimeoutMs?: number;
|
|
63
65
|
onEvent?: (event: { name: string; payload?: unknown }) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Structured workspace and git metadata. Forwarded to sandboxed plugins
|
|
68
|
+
* via PluginSetupCtx.workspaceInfo and made available to in-process plugins
|
|
69
|
+
* in the extension context.
|
|
70
|
+
*/
|
|
71
|
+
workspaceInfo?: WorkspaceInfo;
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
export async function resolveAndLoadAgentPlugins(
|
|
@@ -80,6 +88,9 @@ export async function resolveAndLoadAgentPlugins(
|
|
|
80
88
|
const report = await loadAgentPluginsFromPathsWithDiagnostics(paths, {
|
|
81
89
|
cwd: options.cwd,
|
|
82
90
|
exportName: options.exportName,
|
|
91
|
+
providerId: options.providerId,
|
|
92
|
+
modelId: options.modelId,
|
|
93
|
+
workspaceInfo: options.workspaceInfo,
|
|
83
94
|
});
|
|
84
95
|
return {
|
|
85
96
|
extensions: report.plugins,
|
|
@@ -95,6 +106,10 @@ export async function resolveAndLoadAgentPlugins(
|
|
|
95
106
|
hookTimeoutMs: options.hookTimeoutMs,
|
|
96
107
|
contributionTimeoutMs: options.contributionTimeoutMs,
|
|
97
108
|
onEvent: options.onEvent,
|
|
109
|
+
providerId: options.providerId,
|
|
110
|
+
modelId: options.modelId,
|
|
111
|
+
cwd: options.cwd,
|
|
112
|
+
workspaceInfo: options.workspaceInfo,
|
|
98
113
|
});
|
|
99
114
|
return {
|
|
100
115
|
extensions: sandboxed.extensions ?? [],
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
|
-
import type { AgentConfig } from "@clinebot/shared";
|
|
2
|
+
import type { AgentConfig, PluginSetupContext } from "@clinebot/shared";
|
|
3
|
+
import { normalizePluginManifest } from "@clinebot/shared";
|
|
3
4
|
import type {
|
|
4
5
|
PluginInitializationFailure,
|
|
5
6
|
PluginInitializationWarning,
|
|
6
7
|
} from "./plugin-load-report";
|
|
7
8
|
import { importPluginModule } from "./plugin-module-import";
|
|
9
|
+
import {
|
|
10
|
+
matchesPluginManifestTargeting,
|
|
11
|
+
type PluginTargeting,
|
|
12
|
+
} from "./plugin-targeting";
|
|
8
13
|
|
|
9
14
|
type AgentPlugin = NonNullable<AgentConfig["extensions"]>[number];
|
|
10
15
|
type PluginLike = {
|
|
@@ -12,6 +17,8 @@ type PluginLike = {
|
|
|
12
17
|
manifest: {
|
|
13
18
|
capabilities: string[];
|
|
14
19
|
hookStages?: string[];
|
|
20
|
+
providerIds?: string[];
|
|
21
|
+
modelIds?: string[];
|
|
15
22
|
};
|
|
16
23
|
};
|
|
17
24
|
|
|
@@ -19,6 +26,7 @@ export interface LoadAgentPluginFromPathOptions {
|
|
|
19
26
|
exportName?: string;
|
|
20
27
|
cwd?: string;
|
|
21
28
|
useCache?: boolean;
|
|
29
|
+
workspaceInfo?: PluginSetupContext["workspaceInfo"];
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
function isObject(value: unknown): value is Record<string, unknown> {
|
|
@@ -58,6 +66,22 @@ function validatePluginManifest(
|
|
|
58
66
|
`Invalid plugin module at ${absolutePath}: manifest.hookStages must be a string array when provided`,
|
|
59
67
|
);
|
|
60
68
|
}
|
|
69
|
+
if (
|
|
70
|
+
Object.hasOwn(plugin.manifest, "providerIds") &&
|
|
71
|
+
!hasValidStringArray(plugin.manifest.providerIds)
|
|
72
|
+
) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
`Invalid plugin module at ${absolutePath}: manifest.providerIds must be a string array when provided`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
if (
|
|
78
|
+
Object.hasOwn(plugin.manifest, "modelIds") &&
|
|
79
|
+
!hasValidStringArray(plugin.manifest.modelIds)
|
|
80
|
+
) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
`Invalid plugin module at ${absolutePath}: manifest.modelIds must be a string array when provided`,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
61
85
|
}
|
|
62
86
|
|
|
63
87
|
function validatePluginExport(
|
|
@@ -95,12 +119,29 @@ export async function loadAgentPluginFromPath(
|
|
|
95
119
|
moduleExports[exportName]) as unknown;
|
|
96
120
|
|
|
97
121
|
validatePluginExport(plugin, absolutePath);
|
|
98
|
-
|
|
122
|
+
const pluginTyped = plugin as AgentPlugin;
|
|
123
|
+
const originalSetup = pluginTyped.setup;
|
|
124
|
+
|
|
125
|
+
// Wrap setup to inject workspace context
|
|
126
|
+
const setupWithContext: AgentPlugin["setup"] = originalSetup
|
|
127
|
+
? (api, _ctx) => {
|
|
128
|
+
const ctx = {
|
|
129
|
+
workspaceInfo: options.workspaceInfo,
|
|
130
|
+
};
|
|
131
|
+
return originalSetup(api, ctx);
|
|
132
|
+
}
|
|
133
|
+
: undefined;
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
...pluginTyped,
|
|
137
|
+
manifest: normalizePluginManifest(pluginTyped.manifest),
|
|
138
|
+
setup: setupWithContext,
|
|
139
|
+
};
|
|
99
140
|
}
|
|
100
141
|
|
|
101
142
|
export async function loadAgentPluginsFromPaths(
|
|
102
143
|
pluginPaths: string[],
|
|
103
|
-
options: LoadAgentPluginFromPathOptions = {},
|
|
144
|
+
options: LoadAgentPluginFromPathOptions & PluginTargeting = {},
|
|
104
145
|
): Promise<AgentPlugin[]> {
|
|
105
146
|
const report = await loadAgentPluginsFromPathsWithDiagnostics(
|
|
106
147
|
pluginPaths,
|
|
@@ -111,7 +152,7 @@ export async function loadAgentPluginsFromPaths(
|
|
|
111
152
|
|
|
112
153
|
export async function loadAgentPluginsFromPathsWithDiagnostics(
|
|
113
154
|
pluginPaths: string[],
|
|
114
|
-
options: LoadAgentPluginFromPathOptions = {},
|
|
155
|
+
options: LoadAgentPluginFromPathOptions & PluginTargeting = {},
|
|
115
156
|
): Promise<{
|
|
116
157
|
plugins: AgentPlugin[];
|
|
117
158
|
failures: PluginInitializationFailure[];
|
|
@@ -128,6 +169,9 @@ export async function loadAgentPluginsFromPathsWithDiagnostics(
|
|
|
128
169
|
for (const pluginPath of pluginPaths) {
|
|
129
170
|
try {
|
|
130
171
|
const plugin = await loadAgentPluginFromPath(pluginPath, options);
|
|
172
|
+
if (!matchesPluginManifestTargeting(plugin.manifest, options)) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
131
175
|
const existing = loadedByName.get(plugin.name);
|
|
132
176
|
if (existing) {
|
|
133
177
|
warnings.push({
|
|
@@ -26,8 +26,6 @@ function collectWorkspaceAliases(root: string): Record<string, string> {
|
|
|
26
26
|
"@clinebot/agents": resolve(root, "packages/agents/src/index.ts"),
|
|
27
27
|
"@clinebot/core": resolve(root, "packages/core/src/index.ts"),
|
|
28
28
|
"@clinebot/llms": resolve(root, "packages/llms/src/index.ts"),
|
|
29
|
-
"@clinebot/rpc": resolve(root, "packages/rpc/src/index.ts"),
|
|
30
|
-
"@clinebot/scheduler": resolve(root, "packages/scheduler/src/index.ts"),
|
|
31
29
|
"@clinebot/shared": resolve(root, "packages/shared/src/index.ts"),
|
|
32
30
|
"@clinebot/shared/storage": resolve(
|
|
33
31
|
root,
|
|
@@ -4,13 +4,18 @@
|
|
|
4
4
|
* This file runs inside an isolated Node.js child process spawned by
|
|
5
5
|
* {@link SubprocessSandbox}. It receives RPC calls over IPC and dynamically
|
|
6
6
|
* imports plugin modules, wiring up their contributions (tools, commands,
|
|
7
|
-
*
|
|
7
|
+
* message builders, providers) and lifecycle hooks.
|
|
8
8
|
*
|
|
9
9
|
* Because it executes in a separate process it must stay bundle-safe and only
|
|
10
10
|
* depend on local helpers that can be inlined into the sandbox build.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { normalizePluginManifest, type PluginManifest } from "@clinebot/shared";
|
|
13
14
|
import { importPluginModule } from "./plugin-module-import";
|
|
15
|
+
import {
|
|
16
|
+
matchesPluginManifestTargeting,
|
|
17
|
+
type PluginTargeting,
|
|
18
|
+
} from "./plugin-targeting";
|
|
14
19
|
|
|
15
20
|
// ---------------------------------------------------------------------------
|
|
16
21
|
// Types (intentionally minimal – mirrors only what the RPC protocol needs)
|
|
@@ -31,18 +36,6 @@ interface PluginCommand {
|
|
|
31
36
|
handler?: (input: string) => Promise<string>;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
interface PluginShortcut {
|
|
35
|
-
name: string;
|
|
36
|
-
value: string;
|
|
37
|
-
description?: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface PluginFlag {
|
|
41
|
-
name: string;
|
|
42
|
-
description?: string;
|
|
43
|
-
defaultValue?: boolean | string | number;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
39
|
interface PluginMessageBuilder {
|
|
47
40
|
name: string;
|
|
48
41
|
build: (message: unknown[]) => unknown[]; // Message[]
|
|
@@ -57,16 +50,18 @@ interface PluginProvider {
|
|
|
57
50
|
interface PluginApi {
|
|
58
51
|
registerTool(tool: PluginTool): void;
|
|
59
52
|
registerCommand(command: PluginCommand): void;
|
|
60
|
-
registerShortcut(shortcut: PluginShortcut): void;
|
|
61
|
-
registerFlag(flag: PluginFlag): void;
|
|
62
53
|
registerMessageBuilder(builder: PluginMessageBuilder): void;
|
|
63
54
|
registerProvider(provider: PluginProvider): void;
|
|
64
55
|
}
|
|
65
56
|
|
|
57
|
+
interface PluginSetupCtx {
|
|
58
|
+
workspaceInfo?: unknown;
|
|
59
|
+
}
|
|
60
|
+
|
|
66
61
|
interface PluginModule {
|
|
67
62
|
name: string;
|
|
68
|
-
manifest:
|
|
69
|
-
setup?: (api: PluginApi) => void | Promise<void>;
|
|
63
|
+
manifest: PluginManifest;
|
|
64
|
+
setup?: (api: PluginApi, ctx: PluginSetupCtx) => void | Promise<void>;
|
|
70
65
|
[hookName: string]: unknown;
|
|
71
66
|
}
|
|
72
67
|
|
|
@@ -86,14 +81,14 @@ interface PluginDescriptor {
|
|
|
86
81
|
pluginId: string;
|
|
87
82
|
pluginPath: string;
|
|
88
83
|
name: string;
|
|
89
|
-
manifest:
|
|
84
|
+
manifest: PluginManifest;
|
|
90
85
|
contributions: {
|
|
91
86
|
tools: ContributionDescriptor[];
|
|
92
87
|
commands: ContributionDescriptor[];
|
|
93
|
-
shortcuts: ContributionDescriptor[];
|
|
94
|
-
flags: ContributionDescriptor[];
|
|
95
88
|
messageBuilders: ContributionDescriptor[];
|
|
96
89
|
providers: ContributionDescriptor[];
|
|
90
|
+
shortcuts?: ContributionDescriptor[];
|
|
91
|
+
flags?: ContributionDescriptor[];
|
|
97
92
|
};
|
|
98
93
|
}
|
|
99
94
|
|
|
@@ -132,6 +127,12 @@ function isObject(value: unknown): value is Record<string, unknown> {
|
|
|
132
127
|
return typeof value === "object" && value !== null;
|
|
133
128
|
}
|
|
134
129
|
|
|
130
|
+
function hasValidStringArray(value: unknown): value is string[] {
|
|
131
|
+
return (
|
|
132
|
+
Array.isArray(value) && value.every((entry) => typeof entry === "string")
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
135
136
|
function assertValidPluginModule(
|
|
136
137
|
plugin: unknown,
|
|
137
138
|
pluginPath: string,
|
|
@@ -145,6 +146,29 @@ function assertValidPluginModule(
|
|
|
145
146
|
if (!isObject(plugin.manifest)) {
|
|
146
147
|
throw new Error(`Invalid plugin manifest: ${pluginPath}`);
|
|
147
148
|
}
|
|
149
|
+
if (
|
|
150
|
+
Object.hasOwn(plugin.manifest, "providerIds") &&
|
|
151
|
+
!hasValidStringArray(plugin.manifest.providerIds)
|
|
152
|
+
) {
|
|
153
|
+
throw new Error(`Invalid plugin manifest.providerIds: ${pluginPath}`);
|
|
154
|
+
}
|
|
155
|
+
if (
|
|
156
|
+
Object.hasOwn(plugin.manifest, "modelIds") &&
|
|
157
|
+
!hasValidStringArray(plugin.manifest.modelIds)
|
|
158
|
+
) {
|
|
159
|
+
throw new Error(`Invalid plugin manifest.modelIds: ${pluginPath}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function assertValidPluginSetupCtx(
|
|
164
|
+
ctx: unknown,
|
|
165
|
+
): asserts ctx is PluginSetupCtx {
|
|
166
|
+
if (!isObject(ctx)) {
|
|
167
|
+
throw new Error("Plugin setup context must be an object");
|
|
168
|
+
}
|
|
169
|
+
if (ctx.workspaceInfo !== undefined && !isObject(ctx.workspaceInfo)) {
|
|
170
|
+
throw new Error("Plugin setup context workspaceInfo must be an object");
|
|
171
|
+
}
|
|
148
172
|
}
|
|
149
173
|
|
|
150
174
|
// ---------------------------------------------------------------------------
|
|
@@ -183,6 +207,16 @@ function emitEvent(name: string, payload?: unknown): void {
|
|
|
183
207
|
// Expose event emitter to plugins.
|
|
184
208
|
(globalThis as Record<string, unknown>).__clinePluginHost = { emitEvent };
|
|
185
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Session workspace env — populated by `initialize()` and available to any
|
|
212
|
+
* plugin code that executes before the setup hook, or cannot use hook context.
|
|
213
|
+
* Prefer using PluginSetupCtx from the setup function when possible.
|
|
214
|
+
*/
|
|
215
|
+
(globalThis as Record<string, unknown>).__clineSessionEnv = {
|
|
216
|
+
cwd: undefined as string | undefined,
|
|
217
|
+
workspaceInfo: undefined as unknown,
|
|
218
|
+
};
|
|
219
|
+
|
|
186
220
|
// ---------------------------------------------------------------------------
|
|
187
221
|
// Helpers
|
|
188
222
|
// ---------------------------------------------------------------------------
|
|
@@ -214,16 +248,44 @@ function getPlugin(pluginId: string): PluginState {
|
|
|
214
248
|
async function initialize(args: {
|
|
215
249
|
pluginPaths?: string[];
|
|
216
250
|
exportName?: string;
|
|
251
|
+
providerId?: string;
|
|
252
|
+
modelId?: string;
|
|
253
|
+
cwd?: string;
|
|
254
|
+
workspaceInfo?: unknown;
|
|
217
255
|
}): Promise<InitializeResult> {
|
|
218
256
|
pluginState.clear();
|
|
219
257
|
pluginCounter = 0;
|
|
220
258
|
contributionCounters.clear();
|
|
221
259
|
|
|
260
|
+
// Apply the session's working directory so that process.cwd() and relative
|
|
261
|
+
// path resolution inside plugins reflect the correct workspace, not the
|
|
262
|
+
// host process's cwd (which may differ when --cwd was used without calling
|
|
263
|
+
// process.chdir() on the host side).
|
|
264
|
+
if (args.cwd) {
|
|
265
|
+
try {
|
|
266
|
+
process.chdir(args.cwd);
|
|
267
|
+
} catch {
|
|
268
|
+
// Ignore — best-effort; path may not exist in unusual environments.
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Keep the global escape-hatch in sync with the active session.
|
|
273
|
+
const sessionEnv = (globalThis as Record<string, unknown>)
|
|
274
|
+
.__clineSessionEnv as Record<string, unknown>;
|
|
275
|
+
if (sessionEnv) {
|
|
276
|
+
sessionEnv.cwd = args.cwd;
|
|
277
|
+
sessionEnv.workspaceInfo = args.workspaceInfo;
|
|
278
|
+
}
|
|
279
|
+
|
|
222
280
|
const descriptors: PluginDescriptor[] = [];
|
|
223
281
|
const failures: PluginInitializationFailure[] = [];
|
|
224
282
|
const warnings: PluginInitializationWarning[] = [];
|
|
225
283
|
const exportName = args.exportName || "plugin";
|
|
226
284
|
const pluginIndexByName = new Map<string, number>();
|
|
285
|
+
const targeting: PluginTargeting = {
|
|
286
|
+
providerId: args.providerId,
|
|
287
|
+
modelId: args.modelId,
|
|
288
|
+
};
|
|
227
289
|
|
|
228
290
|
for (const pluginPath of args.pluginPaths || []) {
|
|
229
291
|
let plugin: PluginModule | undefined;
|
|
@@ -232,15 +294,19 @@ async function initialize(args: {
|
|
|
232
294
|
plugin = (moduleExports.default ??
|
|
233
295
|
moduleExports[exportName]) as unknown as PluginModule;
|
|
234
296
|
assertValidPluginModule(plugin, pluginPath);
|
|
297
|
+
plugin.manifest = normalizePluginManifest(plugin.manifest);
|
|
298
|
+
if (!matchesPluginManifestTargeting(plugin.manifest, targeting)) {
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
235
301
|
|
|
236
302
|
const pluginId = `plugin_${++pluginCounter}`;
|
|
237
303
|
const contributions: PluginDescriptor["contributions"] = {
|
|
238
304
|
tools: [],
|
|
239
305
|
commands: [],
|
|
240
|
-
shortcuts: [],
|
|
241
|
-
flags: [],
|
|
242
306
|
messageBuilders: [],
|
|
243
307
|
providers: [],
|
|
308
|
+
shortcuts: [],
|
|
309
|
+
flags: [],
|
|
244
310
|
};
|
|
245
311
|
const handlers: PluginState["handlers"] = {
|
|
246
312
|
tools: new Map(),
|
|
@@ -272,22 +338,6 @@ async function initialize(args: {
|
|
|
272
338
|
description: command.description,
|
|
273
339
|
});
|
|
274
340
|
},
|
|
275
|
-
registerShortcut: (shortcut) => {
|
|
276
|
-
contributions.shortcuts.push({
|
|
277
|
-
id: makeId(pluginId, "shortcut"),
|
|
278
|
-
name: shortcut.name,
|
|
279
|
-
value: shortcut.value,
|
|
280
|
-
description: shortcut.description,
|
|
281
|
-
});
|
|
282
|
-
},
|
|
283
|
-
registerFlag: (flag) => {
|
|
284
|
-
contributions.flags.push({
|
|
285
|
-
id: makeId(pluginId, "flag"),
|
|
286
|
-
name: flag.name,
|
|
287
|
-
description: flag.description,
|
|
288
|
-
defaultValue: flag.defaultValue,
|
|
289
|
-
});
|
|
290
|
-
},
|
|
291
341
|
registerMessageBuilder: (builder) => {
|
|
292
342
|
const id = makeId(pluginId, "builder");
|
|
293
343
|
handlers.messageBuilders.set(id, builder.build);
|
|
@@ -305,7 +355,11 @@ async function initialize(args: {
|
|
|
305
355
|
|
|
306
356
|
if (typeof plugin.setup === "function") {
|
|
307
357
|
try {
|
|
308
|
-
|
|
358
|
+
const setupCtx = {
|
|
359
|
+
workspaceInfo: args.workspaceInfo,
|
|
360
|
+
};
|
|
361
|
+
assertValidPluginSetupCtx(setupCtx);
|
|
362
|
+
await plugin.setup(api, setupCtx);
|
|
309
363
|
} catch (error) {
|
|
310
364
|
failures.push({
|
|
311
365
|
pluginPath,
|