@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
|
@@ -2,17 +2,35 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
AgentConfig,
|
|
7
|
+
HookStage,
|
|
8
|
+
Tool,
|
|
9
|
+
WorkspaceInfo,
|
|
10
|
+
} from "@clinebot/shared";
|
|
6
11
|
import { SubprocessSandbox } from "../../runtime/subprocess-sandbox";
|
|
7
12
|
import type { PluginLoadDiagnostics } from "./plugin-load-report";
|
|
13
|
+
import type { PluginTargeting } from "./plugin-targeting";
|
|
8
14
|
|
|
9
|
-
export interface PluginSandboxOptions {
|
|
15
|
+
export interface PluginSandboxOptions extends PluginTargeting {
|
|
10
16
|
pluginPaths: string[];
|
|
11
17
|
exportName?: string;
|
|
12
18
|
importTimeoutMs?: number;
|
|
13
19
|
hookTimeoutMs?: number;
|
|
14
20
|
contributionTimeoutMs?: number;
|
|
15
21
|
onEvent?: (event: { name: string; payload?: unknown }) => void;
|
|
22
|
+
/**
|
|
23
|
+
* The session's working directory. Forwarded to the sandbox subprocess so
|
|
24
|
+
* that `process.cwd()` returns the correct path inside the sandbox even
|
|
25
|
+
* when `--cwd` was passed without calling `process.chdir()` on the host.
|
|
26
|
+
*/
|
|
27
|
+
cwd?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Structured workspace and git metadata (branch, commit, remotes) generated
|
|
30
|
+
* at session startup. Forwarded to plugins via PluginSetupCtx.workspaceInfo
|
|
31
|
+
* so they can inspect git state without running their own commands.
|
|
32
|
+
*/
|
|
33
|
+
workspaceInfo?: WorkspaceInfo;
|
|
16
34
|
}
|
|
17
35
|
|
|
18
36
|
type AgentExtension = NonNullable<AgentConfig["extensions"]>[number];
|
|
@@ -25,8 +43,6 @@ type SandboxedContributionDescriptor = {
|
|
|
25
43
|
inputSchema?: unknown;
|
|
26
44
|
timeoutMs?: number;
|
|
27
45
|
retryable?: boolean;
|
|
28
|
-
value?: string;
|
|
29
|
-
defaultValue?: boolean | string | number;
|
|
30
46
|
metadata?: Record<string, unknown>;
|
|
31
47
|
};
|
|
32
48
|
|
|
@@ -38,10 +54,10 @@ type SandboxedPluginDescriptor = {
|
|
|
38
54
|
contributions: {
|
|
39
55
|
tools: SandboxedContributionDescriptor[];
|
|
40
56
|
commands: SandboxedContributionDescriptor[];
|
|
41
|
-
shortcuts: SandboxedContributionDescriptor[];
|
|
42
|
-
flags: SandboxedContributionDescriptor[];
|
|
43
57
|
messageBuilders: SandboxedContributionDescriptor[];
|
|
44
58
|
providers: SandboxedContributionDescriptor[];
|
|
59
|
+
shortcuts?: SandboxedContributionDescriptor[];
|
|
60
|
+
flags?: SandboxedContributionDescriptor[];
|
|
45
61
|
};
|
|
46
62
|
};
|
|
47
63
|
|
|
@@ -49,6 +65,22 @@ type SandboxedInitializeResult = {
|
|
|
49
65
|
plugins: SandboxedPluginDescriptor[];
|
|
50
66
|
} & PluginLoadDiagnostics;
|
|
51
67
|
|
|
68
|
+
function normalizeDescriptor(
|
|
69
|
+
descriptor: SandboxedPluginDescriptor,
|
|
70
|
+
): SandboxedPluginDescriptor {
|
|
71
|
+
return {
|
|
72
|
+
...descriptor,
|
|
73
|
+
contributions: {
|
|
74
|
+
tools: descriptor.contributions?.tools ?? [],
|
|
75
|
+
commands: descriptor.contributions?.commands ?? [],
|
|
76
|
+
messageBuilders: descriptor.contributions?.messageBuilders ?? [],
|
|
77
|
+
providers: descriptor.contributions?.providers ?? [],
|
|
78
|
+
shortcuts: descriptor.contributions?.shortcuts ?? [],
|
|
79
|
+
flags: descriptor.contributions?.flags ?? [],
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
52
84
|
function isUnknownPluginIdError(error: unknown): boolean {
|
|
53
85
|
const message = error instanceof Error ? error.message : String(error);
|
|
54
86
|
return message.includes("Unknown sandbox plugin id:");
|
|
@@ -181,6 +213,10 @@ export async function loadSandboxedPlugins(
|
|
|
181
213
|
const initArgs = {
|
|
182
214
|
pluginPaths: options.pluginPaths,
|
|
183
215
|
exportName: options.exportName,
|
|
216
|
+
providerId: options.providerId,
|
|
217
|
+
modelId: options.modelId,
|
|
218
|
+
cwd: options.cwd,
|
|
219
|
+
workspaceInfo: options.workspaceInfo,
|
|
184
220
|
};
|
|
185
221
|
|
|
186
222
|
// Guard against concurrent re-initialization when multiple tools/hooks
|
|
@@ -208,7 +244,7 @@ export async function loadSandboxedPlugins(
|
|
|
208
244
|
});
|
|
209
245
|
throw error;
|
|
210
246
|
}
|
|
211
|
-
const descriptors = initialized.plugins;
|
|
247
|
+
const descriptors = initialized.plugins.map(normalizeDescriptor);
|
|
212
248
|
|
|
213
249
|
const extensions: NonNullable<AgentConfig["extensions"]> = descriptors.map(
|
|
214
250
|
(descriptor) => {
|
|
@@ -267,7 +303,7 @@ function registerTools(
|
|
|
267
303
|
timeoutMs: number,
|
|
268
304
|
reinitialize: () => Promise<void>,
|
|
269
305
|
): void {
|
|
270
|
-
for (const td of descriptor.contributions
|
|
306
|
+
for (const td of descriptor.contributions?.tools ?? []) {
|
|
271
307
|
const tool: Tool = {
|
|
272
308
|
name: td.name,
|
|
273
309
|
description: td.description ?? "",
|
|
@@ -318,7 +354,7 @@ function registerCommands(
|
|
|
318
354
|
timeoutMs: number,
|
|
319
355
|
reinitialize: () => Promise<void>,
|
|
320
356
|
): void {
|
|
321
|
-
for (const cd of descriptor.contributions
|
|
357
|
+
for (const cd of descriptor.contributions?.commands ?? []) {
|
|
322
358
|
api.registerCommand({
|
|
323
359
|
name: cd.name,
|
|
324
360
|
description: cd.description,
|
|
@@ -357,30 +393,14 @@ function registerSimpleContributions(
|
|
|
357
393
|
api: AgentExtensionApi,
|
|
358
394
|
descriptor: SandboxedPluginDescriptor,
|
|
359
395
|
): void {
|
|
360
|
-
for (const
|
|
361
|
-
api.registerShortcut({
|
|
362
|
-
name: sd.name,
|
|
363
|
-
value: sd.value ?? "",
|
|
364
|
-
description: sd.description,
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
for (const fd of descriptor.contributions.flags) {
|
|
369
|
-
api.registerFlag({
|
|
370
|
-
name: fd.name,
|
|
371
|
-
description: fd.description,
|
|
372
|
-
defaultValue: fd.defaultValue,
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
for (const rd of descriptor.contributions.messageBuilders) {
|
|
396
|
+
for (const rd of descriptor.contributions?.messageBuilders ?? []) {
|
|
377
397
|
api.registerMessageBuilder({
|
|
378
398
|
name: rd.name,
|
|
379
399
|
build: (m) => m,
|
|
380
400
|
});
|
|
381
401
|
}
|
|
382
402
|
|
|
383
|
-
for (const pd of descriptor.contributions
|
|
403
|
+
for (const pd of descriptor.contributions?.providers ?? []) {
|
|
384
404
|
api.registerProvider({
|
|
385
405
|
name: pd.name,
|
|
386
406
|
description: pd.description,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PluginManifest } from "@clinebot/shared";
|
|
2
|
+
|
|
3
|
+
export interface PluginTargeting {
|
|
4
|
+
providerId?: string;
|
|
5
|
+
modelId?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function matchesPluginManifestTargeting(
|
|
9
|
+
manifest: PluginManifest | undefined,
|
|
10
|
+
targeting: PluginTargeting | undefined,
|
|
11
|
+
): boolean {
|
|
12
|
+
if (!manifest) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (manifest.providerIds?.length) {
|
|
17
|
+
if (
|
|
18
|
+
!targeting?.providerId ||
|
|
19
|
+
!manifest.providerIds.includes(targeting.providerId)
|
|
20
|
+
) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (manifest.modelIds?.length) {
|
|
26
|
+
if (!targeting?.modelId || !manifest.modelIds.includes(targeting.modelId)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
@@ -350,67 +350,48 @@ export function createWebFetchTool(
|
|
|
350
350
|
});
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
const APPLY_PATCH_TOOL_DESC = `
|
|
353
|
+
const APPLY_PATCH_TOOL_DESC = `Use \`apply_patch\` to edit files with the canonical freeform patch grammar. Pass the patch text directly as the \`input\` string. Prefer the exact format below:
|
|
354
354
|
|
|
355
|
-
%%bash
|
|
356
|
-
apply_patch <<"EOF"
|
|
357
355
|
*** Begin Patch
|
|
358
|
-
|
|
356
|
+
*** Update File: path/to/file.ts
|
|
357
|
+
@@ optional section marker
|
|
358
|
+
[context before]
|
|
359
|
+
-[old line]
|
|
360
|
+
+[new line]
|
|
361
|
+
[context after]
|
|
359
362
|
*** End Patch
|
|
360
|
-
EOF
|
|
361
363
|
|
|
362
|
-
|
|
364
|
+
Supported actions:
|
|
365
|
+
- \`*** Add File: <path>\`
|
|
366
|
+
- \`*** Update File: <path>\`
|
|
367
|
+
- \`*** Delete File: <path>\`
|
|
368
|
+
- optional \`*** Move to: <new path>\` immediately after an Update File header
|
|
363
369
|
|
|
364
|
-
|
|
370
|
+
Rules:
|
|
371
|
+
- In an Add File section, every file-content line must start with \`+\`.
|
|
372
|
+
- In an Update section, use context lines plus \`-\` and \`+\` lines to describe the change.
|
|
373
|
+
- Use \`@@\` markers when extra context is needed to disambiguate repeated code blocks.
|
|
374
|
+
- Do not use line numbers; this format is context-based.
|
|
375
|
+
- Prefer sending the patch body directly. Legacy shell wrappers such as \`%%bash\` and \`apply_patch <<"EOF"\` are accepted for compatibility but are not preferred.
|
|
365
376
|
|
|
366
|
-
|
|
367
|
-
In a Update/Delete section, repeat the following for each snippet of code that needs to be changed:
|
|
368
|
-
[context_before] -> See below for further instructions on context.
|
|
369
|
-
- [old_code] -> Precede the old code with a minus sign.
|
|
370
|
-
+ [new_code] -> Precede the new, replacement code with a plus sign.
|
|
371
|
-
[context_after] -> See below for further instructions on context.
|
|
377
|
+
Example:
|
|
372
378
|
|
|
373
|
-
For instructions on [context_before] and [context_after]:
|
|
374
|
-
- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.
|
|
375
|
-
- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:
|
|
376
|
-
@@ class BaseClass
|
|
377
|
-
[3 lines of pre-context]
|
|
378
|
-
- [old_code]
|
|
379
|
-
+ [new_code]
|
|
380
|
-
[3 lines of post-context]
|
|
381
|
-
|
|
382
|
-
- If a code block is repeated so many times in a class or function such that even a single @@ statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple \`@@\` statements to jump to the right context. For instance:
|
|
383
|
-
|
|
384
|
-
@@ class BaseClass
|
|
385
|
-
@@ def method():
|
|
386
|
-
[3 lines of pre-context]
|
|
387
|
-
- [old_code]
|
|
388
|
-
+ [new_code]
|
|
389
|
-
[3 lines of post-context]
|
|
390
|
-
|
|
391
|
-
Note, then, that we do not use line numbers in this diff format, as the context is enough to uniquely identify code. An example of a message that you might pass as "input" to this function, in order to apply a patch, is shown below.
|
|
392
|
-
|
|
393
|
-
%%bash
|
|
394
|
-
apply_patch <<"EOF"
|
|
395
379
|
*** Begin Patch
|
|
396
|
-
*** Update File:
|
|
397
|
-
@@
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
*** End Patch
|
|
408
|
-
EOF`;
|
|
380
|
+
*** Update File: src/page.tsx
|
|
381
|
+
@@
|
|
382
|
+
return (
|
|
383
|
+
<div>
|
|
384
|
+
<button onClick={() => console.log("clicked")}>Click me</button>
|
|
385
|
+
+ <button onClick={() => console.log("cancel clicked")}>Cancel</button>
|
|
386
|
+
</div>
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
*** End Patch`;
|
|
409
390
|
|
|
410
391
|
/**
|
|
411
392
|
* Create the apply_patch tool
|
|
412
393
|
*
|
|
413
|
-
* Applies the
|
|
394
|
+
* Applies the canonical apply_patch format to one or more files.
|
|
414
395
|
*/
|
|
415
396
|
export function createApplyPatchTool(
|
|
416
397
|
executor: ApplyPatchExecutor,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Apply Patch Executor
|
|
3
3
|
*
|
|
4
|
-
* Built-in implementation for the
|
|
4
|
+
* Built-in implementation for the documented GPT-5 apply_patch grammar.
|
|
5
|
+
* It accepts the freeform patch body directly and tolerates the legacy shell
|
|
6
|
+
* wrapper form used by older prompts.
|
|
5
7
|
*/
|
|
6
8
|
|
|
7
9
|
import * as fs from "node:fs/promises";
|
|
@@ -25,6 +27,10 @@ interface FileChange {
|
|
|
25
27
|
movePath?: string;
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
interface NormalizedPatchInput {
|
|
31
|
+
lines: string[];
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
/**
|
|
29
35
|
* Options for the apply_patch executor
|
|
30
36
|
*/
|
|
@@ -63,104 +69,87 @@ function resolveFilePath(
|
|
|
63
69
|
return resolved;
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
let foundBegin = false;
|
|
70
|
-
let foundContent = false;
|
|
71
|
-
|
|
72
|
-
for (let i = 0; i < lines.length; i++) {
|
|
73
|
-
const line = lines[i];
|
|
74
|
-
if (
|
|
75
|
-
!insidePatch &&
|
|
76
|
-
BASH_WRAPPERS.some((wrapper) => line.startsWith(wrapper))
|
|
77
|
-
) {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (line.startsWith(PATCH_MARKERS.BEGIN)) {
|
|
82
|
-
insidePatch = true;
|
|
83
|
-
foundBegin = true;
|
|
84
|
-
result.push(line);
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
72
|
+
function normalizeLineEndings(input: string): string[] {
|
|
73
|
+
return input.split("\n").map((line) => line.replace(/\r$/, ""));
|
|
74
|
+
}
|
|
87
75
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
76
|
+
function isWrapperLine(line: string): boolean {
|
|
77
|
+
if (line.trim() === "") {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return BASH_WRAPPERS.some((wrapper) => line.startsWith(wrapper));
|
|
81
|
+
}
|
|
93
82
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
line.startsWith(PATCH_MARKERS.DELETE) ||
|
|
98
|
-
line.startsWith(PATCH_MARKERS.MOVE) ||
|
|
99
|
-
line.startsWith(PATCH_MARKERS.SECTION) ||
|
|
100
|
-
line.startsWith("+") ||
|
|
101
|
-
line.startsWith("-") ||
|
|
102
|
-
line.startsWith(" ") ||
|
|
103
|
-
line === "***";
|
|
104
|
-
|
|
105
|
-
if (isPatchContent && i !== lines.length - 1) {
|
|
106
|
-
foundContent = true;
|
|
107
|
-
}
|
|
83
|
+
function trimWrapperLines(lines: string[]): string[] {
|
|
84
|
+
let start = 0;
|
|
85
|
+
let end = lines.length;
|
|
108
86
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
(!foundBegin && isPatchContent) ||
|
|
112
|
-
(line === "" && foundContent)
|
|
113
|
-
) {
|
|
114
|
-
result.push(line);
|
|
115
|
-
}
|
|
87
|
+
while (start < end && isWrapperLine(lines[start] ?? "")) {
|
|
88
|
+
start++;
|
|
116
89
|
}
|
|
117
90
|
|
|
118
|
-
while (
|
|
119
|
-
|
|
91
|
+
while (end > start && isWrapperLine(lines[end - 1] ?? "")) {
|
|
92
|
+
end--;
|
|
120
93
|
}
|
|
121
94
|
|
|
122
|
-
return
|
|
95
|
+
return lines.slice(start, end);
|
|
123
96
|
}
|
|
124
97
|
|
|
125
|
-
function
|
|
126
|
-
|
|
127
|
-
|
|
98
|
+
function normalizePatchInput(input: string): NormalizedPatchInput {
|
|
99
|
+
const rawLines = normalizeLineEndings(input);
|
|
100
|
+
const beginIndex = rawLines.findIndex((line) =>
|
|
101
|
+
line.startsWith(PATCH_MARKERS.BEGIN),
|
|
102
|
+
);
|
|
103
|
+
let endIndex = -1;
|
|
104
|
+
for (let i = rawLines.length - 1; i >= 0; i--) {
|
|
105
|
+
if (rawLines[i]?.startsWith(PATCH_MARKERS.END)) {
|
|
106
|
+
endIndex = i;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (beginIndex !== -1 || endIndex !== -1) {
|
|
112
|
+
if (beginIndex === -1 || endIndex === -1 || endIndex < beginIndex) {
|
|
113
|
+
throw new DiffError(
|
|
114
|
+
"Invalid patch text - incomplete sentinels. Try breaking it into smaller patches.",
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
const lines = rawLines.slice(beginIndex, endIndex + 1);
|
|
118
|
+
return {
|
|
119
|
+
lines,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
128
122
|
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (!hasBegin && !hasEnd) {
|
|
133
|
-
return [PATCH_MARKERS.BEGIN, ...lines, PATCH_MARKERS.END];
|
|
123
|
+
const stripped = trimWrapperLines(rawLines);
|
|
124
|
+
while (stripped.length > 0 && stripped[0] === "") {
|
|
125
|
+
stripped.shift();
|
|
134
126
|
}
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
while (stripped.length > 0 && stripped[stripped.length - 1] === "") {
|
|
128
|
+
stripped.pop();
|
|
137
129
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
130
|
+
|
|
131
|
+
const lines = [PATCH_MARKERS.BEGIN, ...stripped, PATCH_MARKERS.END];
|
|
132
|
+
return {
|
|
133
|
+
lines,
|
|
134
|
+
};
|
|
141
135
|
}
|
|
142
136
|
|
|
143
137
|
function extractFilesForOperations(
|
|
144
|
-
|
|
138
|
+
lines: readonly string[],
|
|
145
139
|
markers: readonly string[],
|
|
146
140
|
): string[] {
|
|
147
|
-
const
|
|
148
|
-
const files: string[] = [];
|
|
141
|
+
const files = new Set<string>();
|
|
149
142
|
|
|
150
143
|
for (const line of lines) {
|
|
151
144
|
for (const marker of markers) {
|
|
152
|
-
if (
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const file = line.substring(marker.length).trim();
|
|
156
|
-
if (!text.trim().endsWith(file)) {
|
|
157
|
-
files.push(file);
|
|
145
|
+
if (line.startsWith(marker)) {
|
|
146
|
+
files.add(line.substring(marker.length).trim());
|
|
147
|
+
break;
|
|
158
148
|
}
|
|
159
|
-
break;
|
|
160
149
|
}
|
|
161
150
|
}
|
|
162
151
|
|
|
163
|
-
return files;
|
|
152
|
+
return [...files];
|
|
164
153
|
}
|
|
165
154
|
|
|
166
155
|
function applyChunks(
|
|
@@ -197,12 +186,12 @@ function applyChunks(
|
|
|
197
186
|
}
|
|
198
187
|
|
|
199
188
|
async function loadFiles(
|
|
200
|
-
|
|
189
|
+
lines: readonly string[],
|
|
201
190
|
cwd: string,
|
|
202
191
|
encoding: BufferEncoding,
|
|
203
192
|
restrictToCwd: boolean,
|
|
204
193
|
): Promise<Record<string, string>> {
|
|
205
|
-
const filesToLoad = extractFilesForOperations(
|
|
194
|
+
const filesToLoad = extractFilesForOperations(lines, [
|
|
206
195
|
PATCH_MARKERS.UPDATE,
|
|
207
196
|
PATCH_MARKERS.DELETE,
|
|
208
197
|
]);
|
|
@@ -328,14 +317,14 @@ export function createApplyPatchExecutor(
|
|
|
328
317
|
cwd: string,
|
|
329
318
|
_context: ToolContext,
|
|
330
319
|
): Promise<string> => {
|
|
331
|
-
const
|
|
320
|
+
const normalizedInput = normalizePatchInput(input.input);
|
|
332
321
|
const currentFiles = await loadFiles(
|
|
333
|
-
|
|
322
|
+
normalizedInput.lines,
|
|
334
323
|
cwd,
|
|
335
324
|
encoding,
|
|
336
325
|
restrictToCwd,
|
|
337
326
|
);
|
|
338
|
-
const parser = new PatchParser(lines, currentFiles);
|
|
327
|
+
const parser = new PatchParser(normalizedInput.lines, currentFiles);
|
|
339
328
|
const { patch, fuzz } = parser.parse();
|
|
340
329
|
const changes = patchToChanges(patch, currentFiles);
|
|
341
330
|
const touched = await applyChanges(changes, cwd, encoding, restrictToCwd);
|