@clinebot/core 0.0.35 → 0.0.37
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 +362 -39
- package/dist/ClineCore.d.ts.map +1 -1
- package/dist/account/cline-account-service.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/cron-event-ingress.d.ts +38 -0
- package/dist/cron/cron-event-ingress.d.ts.map +1 -0
- package/dist/cron/cron-materializer.d.ts +36 -0
- package/dist/cron/cron-materializer.d.ts.map +1 -0
- package/dist/cron/cron-reconciler.d.ts +62 -0
- package/dist/cron/cron-reconciler.d.ts.map +1 -0
- package/dist/cron/cron-report-writer.d.ts +41 -0
- package/dist/cron/cron-report-writer.d.ts.map +1 -0
- package/dist/cron/cron-runner.d.ts +43 -0
- package/dist/cron/cron-runner.d.ts.map +1 -0
- package/dist/cron/cron-schema.d.ts +3 -0
- package/dist/cron/cron-schema.d.ts.map +1 -0
- package/dist/cron/cron-service.d.ts +57 -0
- package/dist/cron/cron-service.d.ts.map +1 -0
- package/dist/cron/cron-spec-parser.d.ts +27 -0
- package/dist/cron/cron-spec-parser.d.ts.map +1 -0
- package/dist/cron/cron-watcher.d.ts +23 -0
- package/dist/cron/cron-watcher.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 +68 -0
- package/dist/cron/scheduler.d.ts.map +1 -0
- package/dist/cron/sqlite-cron-store.d.ts +230 -0
- package/dist/cron/sqlite-cron-store.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 +15 -2
- package/dist/extensions/plugin/plugin-config-loader.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-loader.d.ts +13 -7
- 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 +21 -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 +237 -276
- package/dist/extensions/tools/constants.d.ts +1 -0
- package/dist/extensions/tools/constants.d.ts.map +1 -1
- package/dist/extensions/tools/definitions.d.ts +3 -4
- 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/editor.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/helpers.d.ts +1 -0
- package/dist/extensions/tools/helpers.d.ts.map +1 -1
- package/dist/extensions/tools/index.d.ts +3 -2
- package/dist/extensions/tools/index.d.ts.map +1 -1
- package/dist/extensions/tools/presets.d.ts +27 -44
- 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 +25 -3
- package/dist/extensions/tools/schemas.d.ts.map +1 -1
- package/dist/extensions/tools/team/delegated-agent.d.ts +2 -2
- package/dist/extensions/tools/team/delegated-agent.d.ts.map +1 -1
- package/dist/extensions/tools/team/multi-agent.d.ts +7 -3
- package/dist/extensions/tools/team/multi-agent.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/extensions/tools/types.d.ts +0 -5
- package/dist/extensions/tools/types.d.ts.map +1 -1
- package/dist/hooks/hook-bridge.d.ts +118 -0
- package/dist/hooks/hook-bridge.d.ts.map +1 -0
- package/dist/hooks/hook-file-hooks.d.ts +6 -2
- package/dist/hooks/hook-file-hooks.d.ts.map +1 -1
- package/dist/hooks/hook-registry.d.ts +16 -0
- package/dist/hooks/hook-registry.d.ts.map +1 -0
- 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 +51 -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 +1305 -0
- package/dist/hub/daemon.d.ts +5 -0
- package/dist/hub/daemon.d.ts.map +1 -0
- package/dist/hub/defaults.d.ts +17 -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 +1294 -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 +104 -0
- package/dist/hub/server.d.ts.map +1 -0
- package/dist/hub/session-client.d.ts +90 -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 +45 -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 +29 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +782 -471
- package/dist/llms/cline-recommended-models.d.ts +20 -0
- package/dist/llms/cline-recommended-models.d.ts.map +1 -0
- package/dist/llms/configured-provider-registry.d.ts +28 -0
- package/dist/llms/configured-provider-registry.d.ts.map +1 -0
- package/dist/llms/handler-factory.d.ts +16 -0
- package/dist/llms/handler-factory.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 +245 -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/agent-config-adapter.d.ts +148 -0
- package/dist/runtime/agent-config-adapter.d.ts.map +1 -0
- package/dist/runtime/agent-runtime-config-builder.d.ts +96 -0
- package/dist/runtime/agent-runtime-config-builder.d.ts.map +1 -0
- package/dist/runtime/history.d.ts +6 -0
- package/dist/runtime/history.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +1 -2
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/loop-detection.d.ts +59 -0
- package/dist/runtime/loop-detection.d.ts.map +1 -0
- package/dist/runtime/mistake-tracker.d.ts +69 -0
- package/dist/runtime/mistake-tracker.d.ts.map +1 -0
- 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-event-adapter.d.ts +102 -0
- package/dist/runtime/runtime-event-adapter.d.ts.map +1 -0
- package/dist/runtime/runtime-host.d.ts +49 -26
- 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-orchestrator.d.ts +261 -0
- package/dist/runtime/session-runtime-orchestrator.d.ts.map +1 -0
- package/dist/runtime/session-runtime.d.ts +16 -21
- package/dist/runtime/session-runtime.d.ts.map +1 -1
- package/dist/runtime/user-input-builder.d.ts +24 -0
- package/dist/runtime/user-input-builder.d.ts.map +1 -0
- package/dist/services/global-settings.d.ts +12 -0
- package/dist/services/global-settings.d.ts.map +1 -0
- package/dist/services/index.js +28 -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 +199 -23
- package/dist/services/providers/local-provider-registry.d.ts.map +1 -1
- package/dist/services/providers/local-provider-service.d.ts +15 -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/session-telemetry.d.ts +7 -2
- package/dist/services/session-telemetry.d.ts.map +1 -1
- package/dist/services/storage/file-team-store.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/storage/provider-settings-manager.d.ts +1 -0
- package/dist/services/storage/provider-settings-manager.d.ts.map +1 -1
- package/dist/services/storage/sqlite-team-store.d.ts.map +1 -1
- package/dist/services/workspace-manifest.d.ts +11 -0
- package/dist/services/workspace-manifest.d.ts.map +1 -1
- package/dist/session/conversation-store.d.ts +30 -0
- package/dist/session/conversation-store.d.ts.map +1 -0
- package/dist/session/message-builder.d.ts +65 -0
- package/dist/session/message-builder.d.ts.map +1 -0
- 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-manifest.d.ts +1 -1
- 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 +58 -0
- package/dist/transports/hub.d.ts.map +1 -0
- package/dist/transports/local.d.ts +23 -9
- 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 +15 -17
- package/dist/types/chat-schema.d.ts.map +1 -1
- package/dist/types/config.d.ts +17 -7
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/events.d.ts +7 -6
- package/dist/types/events.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 +7 -3
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types.d.ts +11 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +20 -6
- package/src/ClineCore.ts +757 -44
- package/src/account/cline-account-service.ts +44 -6
- package/src/account/index.ts +3 -3
- package/src/account/rpc.ts +12 -12
- package/src/cron/cron-event-ingress.ts +357 -0
- package/src/cron/cron-materializer.ts +97 -0
- package/src/cron/cron-reconciler.ts +241 -0
- package/src/cron/cron-report-writer.ts +153 -0
- package/src/cron/cron-runner.ts +495 -0
- package/src/cron/cron-schema.ts +127 -0
- package/src/cron/cron-service.ts +163 -0
- package/src/cron/cron-spec-parser.ts +489 -0
- package/src/cron/cron-watcher.ts +102 -0
- package/src/cron/index.ts +15 -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 +772 -0
- package/src/cron/sqlite-cron-store.ts +1286 -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 +37 -2
- package/src/extensions/plugin/plugin-loader.ts +69 -9
- package/src/extensions/plugin/plugin-module-import.ts +0 -2
- package/src/extensions/plugin/plugin-sandbox-bootstrap.ts +243 -39
- package/src/extensions/plugin/plugin-sandbox.ts +173 -29
- package/src/extensions/plugin/plugin-targeting.ts +32 -0
- package/src/extensions/tools/constants.ts +2 -0
- package/src/extensions/tools/definitions.ts +61 -71
- package/src/extensions/tools/executors/apply-patch.ts +69 -80
- package/src/extensions/tools/executors/editor.ts +4 -3
- package/src/extensions/tools/executors/search.ts +195 -3
- package/src/extensions/tools/helpers.ts +24 -0
- package/src/extensions/tools/index.ts +11 -2
- package/src/extensions/tools/presets.ts +32 -47
- package/src/extensions/tools/runtime.ts +261 -0
- package/src/extensions/tools/schemas.ts +17 -20
- package/src/extensions/tools/team/delegated-agent.ts +8 -3
- package/src/extensions/tools/team/multi-agent.ts +135 -19
- package/src/extensions/tools/team/team-tools.ts +172 -91
- package/src/extensions/tools/types.ts +0 -6
- package/src/hooks/hook-bridge.ts +489 -0
- package/src/hooks/hook-file-hooks.ts +66 -5
- package/src/hooks/hook-registry.ts +257 -0
- 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 +159 -0
- package/src/hub/client.ts +633 -0
- package/src/hub/connect.ts +156 -0
- package/src/hub/daemon-entry.ts +122 -0
- package/src/hub/daemon.ts +284 -0
- package/src/hub/defaults.ts +70 -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 +141 -0
- package/src/hub/server.ts +2317 -0
- package/src/hub/session-client.ts +502 -0
- package/src/hub/start-shared-server.ts +61 -0
- package/src/hub/transport.ts +14 -0
- package/src/hub/ui-client.ts +126 -0
- package/src/hub/workspace.ts +19 -0
- package/src/index.ts +169 -68
- package/src/llms/cline-recommended-models.ts +167 -0
- package/src/llms/configured-provider-registry.ts +193 -0
- package/src/llms/handler-factory.ts +56 -0
- package/src/llms/provider-defaults.ts +653 -0
- package/src/llms/provider-settings.ts +310 -0
- package/src/llms/runtime-config.ts +43 -0
- package/src/llms/runtime-registry.ts +172 -0
- package/src/llms/runtime-types.ts +121 -0
- package/src/runtime/agent-config-adapter.ts +636 -0
- package/src/runtime/agent-runtime-config-builder.ts +205 -0
- package/src/runtime/error-feedback.ts +142 -0
- package/src/runtime/history.ts +137 -0
- package/src/runtime/host.ts +127 -267
- package/src/runtime/index.ts +1 -0
- package/src/runtime/loop-detection.ts +162 -0
- package/src/runtime/mistake-tracker.ts +221 -0
- package/src/runtime/rules.ts +12 -0
- package/src/runtime/runtime-builder.ts +85 -13
- package/src/runtime/runtime-event-adapter.ts +412 -0
- package/src/runtime/runtime-host.ts +134 -62
- package/src/runtime/runtime-oauth-token-manager.ts +11 -15
- package/src/runtime/session-runtime-orchestrator.ts +1253 -0
- package/src/runtime/session-runtime.ts +16 -26
- package/src/runtime/user-input-builder.ts +167 -0
- package/src/services/global-settings.ts +122 -0
- package/src/services/local-runtime-bootstrap.ts +175 -31
- package/src/services/plugin-tools.ts +86 -0
- package/src/services/providers/local-provider-registry.ts +277 -61
- package/src/services/providers/local-provider-service.ts +109 -44
- package/src/services/session-data.ts +18 -10
- package/src/services/session-telemetry.ts +6 -15
- package/src/services/storage/file-team-store.ts +1 -5
- package/src/services/storage/provider-settings-legacy-migration.ts +14 -51
- package/src/services/storage/provider-settings-manager.ts +17 -2
- package/src/services/storage/sqlite-team-store.ts +1 -5
- package/src/services/workspace-manifest.ts +18 -0
- package/src/session/conversation-store.ts +77 -0
- package/src/session/file-session-service.ts +1 -1
- package/src/session/index.ts +6 -27
- package/src/session/message-builder.ts +941 -0
- 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 +1081 -0
- package/src/transports/local.ts +419 -93
- package/src/transports/remote.ts +27 -0
- package/src/transports/runtime-host-support.ts +63 -9
- package/src/types/chat-schema.ts +4 -5
- package/src/types/config.ts +17 -7
- package/src/types/events.ts +8 -6
- package/src/types/index.ts +3 -0
- package/src/types/provider-settings.ts +18 -7
- package/src/types/session.ts +7 -6
- package/src/types.ts +42 -2
- 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/services/telemetry/index.js +0 -15
- 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,48 @@ 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
|
+
AgentExtensionAutomationEventType,
|
|
8
|
+
HookStage,
|
|
9
|
+
Message,
|
|
10
|
+
PluginSetupContext,
|
|
11
|
+
Tool,
|
|
12
|
+
WorkspaceInfo,
|
|
13
|
+
} from "@clinebot/shared";
|
|
6
14
|
import { SubprocessSandbox } from "../../runtime/subprocess-sandbox";
|
|
7
15
|
import type { PluginLoadDiagnostics } from "./plugin-load-report";
|
|
16
|
+
import type { PluginTargeting } from "./plugin-targeting";
|
|
8
17
|
|
|
9
|
-
export
|
|
18
|
+
export type SandboxedPluginSetupContext = Pick<
|
|
19
|
+
PluginSetupContext,
|
|
20
|
+
"session" | "client" | "user" | "workspaceInfo" | "logger"
|
|
21
|
+
>;
|
|
22
|
+
|
|
23
|
+
export interface PluginSandboxOptions extends PluginTargeting {
|
|
10
24
|
pluginPaths: string[];
|
|
11
25
|
exportName?: string;
|
|
12
26
|
importTimeoutMs?: number;
|
|
13
27
|
hookTimeoutMs?: number;
|
|
14
28
|
contributionTimeoutMs?: number;
|
|
15
29
|
onEvent?: (event: { name: string; payload?: unknown }) => void;
|
|
30
|
+
/**
|
|
31
|
+
* The session's working directory. Forwarded to the sandbox subprocess so
|
|
32
|
+
* that `process.cwd()` returns the correct path inside the sandbox even
|
|
33
|
+
* when `--cwd` was passed without calling `process.chdir()` on the host.
|
|
34
|
+
*/
|
|
35
|
+
cwd?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Structured workspace and git metadata (branch, commit, remotes) generated
|
|
38
|
+
* at session startup. Forwarded to plugins via PluginSetupCtx.workspaceInfo
|
|
39
|
+
* so they can inspect git state without running their own commands.
|
|
40
|
+
*/
|
|
41
|
+
workspaceInfo?: WorkspaceInfo;
|
|
42
|
+
session?: SandboxedPluginSetupContext["session"];
|
|
43
|
+
client?: SandboxedPluginSetupContext["client"];
|
|
44
|
+
user?: SandboxedPluginSetupContext["user"];
|
|
45
|
+
/** Enables a logger bridge that forwards sandbox log calls to the host. */
|
|
46
|
+
logger?: SandboxedPluginSetupContext["logger"];
|
|
16
47
|
}
|
|
17
48
|
|
|
18
49
|
type AgentExtension = NonNullable<AgentConfig["extensions"]>[number];
|
|
@@ -25,11 +56,14 @@ type SandboxedContributionDescriptor = {
|
|
|
25
56
|
inputSchema?: unknown;
|
|
26
57
|
timeoutMs?: number;
|
|
27
58
|
retryable?: boolean;
|
|
28
|
-
value?: string;
|
|
29
|
-
defaultValue?: boolean | string | number;
|
|
30
59
|
metadata?: Record<string, unknown>;
|
|
31
60
|
};
|
|
32
61
|
|
|
62
|
+
type SandboxedAutomationEventTypeDescriptor =
|
|
63
|
+
AgentExtensionAutomationEventType & {
|
|
64
|
+
id: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
33
67
|
type SandboxedPluginDescriptor = {
|
|
34
68
|
pluginId: string;
|
|
35
69
|
pluginPath: string;
|
|
@@ -38,10 +72,11 @@ type SandboxedPluginDescriptor = {
|
|
|
38
72
|
contributions: {
|
|
39
73
|
tools: SandboxedContributionDescriptor[];
|
|
40
74
|
commands: SandboxedContributionDescriptor[];
|
|
41
|
-
shortcuts: SandboxedContributionDescriptor[];
|
|
42
|
-
flags: SandboxedContributionDescriptor[];
|
|
43
75
|
messageBuilders: SandboxedContributionDescriptor[];
|
|
44
76
|
providers: SandboxedContributionDescriptor[];
|
|
77
|
+
automationEventTypes: SandboxedAutomationEventTypeDescriptor[];
|
|
78
|
+
shortcuts?: SandboxedContributionDescriptor[];
|
|
79
|
+
flags?: SandboxedContributionDescriptor[];
|
|
45
80
|
};
|
|
46
81
|
};
|
|
47
82
|
|
|
@@ -49,6 +84,24 @@ type SandboxedInitializeResult = {
|
|
|
49
84
|
plugins: SandboxedPluginDescriptor[];
|
|
50
85
|
} & PluginLoadDiagnostics;
|
|
51
86
|
|
|
87
|
+
function normalizeDescriptor(
|
|
88
|
+
descriptor: SandboxedPluginDescriptor,
|
|
89
|
+
): SandboxedPluginDescriptor {
|
|
90
|
+
return {
|
|
91
|
+
...descriptor,
|
|
92
|
+
contributions: {
|
|
93
|
+
tools: descriptor.contributions?.tools ?? [],
|
|
94
|
+
commands: descriptor.contributions?.commands ?? [],
|
|
95
|
+
messageBuilders: descriptor.contributions?.messageBuilders ?? [],
|
|
96
|
+
providers: descriptor.contributions?.providers ?? [],
|
|
97
|
+
automationEventTypes:
|
|
98
|
+
descriptor.contributions?.automationEventTypes ?? [],
|
|
99
|
+
shortcuts: descriptor.contributions?.shortcuts ?? [],
|
|
100
|
+
flags: descriptor.contributions?.flags ?? [],
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
52
105
|
function isUnknownPluginIdError(error: unknown): boolean {
|
|
53
106
|
const message = error instanceof Error ? error.message : String(error);
|
|
54
107
|
return message.includes("Unknown sandbox plugin id:");
|
|
@@ -113,6 +166,21 @@ const HOOK_BINDINGS: Array<{
|
|
|
113
166
|
extensionKey: "onSessionStart",
|
|
114
167
|
sandboxHookName: "onSessionStart",
|
|
115
168
|
},
|
|
169
|
+
{
|
|
170
|
+
stage: "run_start",
|
|
171
|
+
extensionKey: "onRunStart",
|
|
172
|
+
sandboxHookName: "onRunStart",
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
stage: "iteration_start",
|
|
176
|
+
extensionKey: "onIterationStart",
|
|
177
|
+
sandboxHookName: "onIterationStart",
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
stage: "turn_start",
|
|
181
|
+
extensionKey: "onTurnStart",
|
|
182
|
+
sandboxHookName: "onTurnStart",
|
|
183
|
+
},
|
|
116
184
|
{
|
|
117
185
|
stage: "before_agent_start",
|
|
118
186
|
extensionKey: "onBeforeAgentStart",
|
|
@@ -133,6 +201,21 @@ const HOOK_BINDINGS: Array<{
|
|
|
133
201
|
extensionKey: "onTurnEnd",
|
|
134
202
|
sandboxHookName: "onTurnEnd",
|
|
135
203
|
},
|
|
204
|
+
{
|
|
205
|
+
stage: "stop_error",
|
|
206
|
+
extensionKey: "onAgentError",
|
|
207
|
+
sandboxHookName: "onAgentError",
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
stage: "iteration_end",
|
|
211
|
+
extensionKey: "onIterationEnd",
|
|
212
|
+
sandboxHookName: "onIterationEnd",
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
stage: "run_end",
|
|
216
|
+
extensionKey: "onRunEnd",
|
|
217
|
+
sandboxHookName: "onRunEnd",
|
|
218
|
+
},
|
|
136
219
|
{
|
|
137
220
|
stage: "session_shutdown",
|
|
138
221
|
extensionKey: "onSessionShutdown",
|
|
@@ -181,6 +264,14 @@ export async function loadSandboxedPlugins(
|
|
|
181
264
|
const initArgs = {
|
|
182
265
|
pluginPaths: options.pluginPaths,
|
|
183
266
|
exportName: options.exportName,
|
|
267
|
+
providerId: options.providerId,
|
|
268
|
+
modelId: options.modelId,
|
|
269
|
+
cwd: options.cwd,
|
|
270
|
+
session: options.session,
|
|
271
|
+
client: options.client,
|
|
272
|
+
user: options.user,
|
|
273
|
+
workspaceInfo: options.workspaceInfo,
|
|
274
|
+
loggerEnabled: Boolean(options.logger),
|
|
184
275
|
};
|
|
185
276
|
|
|
186
277
|
// Guard against concurrent re-initialization when multiple tools/hooks
|
|
@@ -208,7 +299,7 @@ export async function loadSandboxedPlugins(
|
|
|
208
299
|
});
|
|
209
300
|
throw error;
|
|
210
301
|
}
|
|
211
|
-
const descriptors = initialized.plugins;
|
|
302
|
+
const descriptors = initialized.plugins.map(normalizeDescriptor);
|
|
212
303
|
|
|
213
304
|
const extensions: NonNullable<AgentConfig["extensions"]> = descriptors.map(
|
|
214
305
|
(descriptor) => {
|
|
@@ -230,6 +321,13 @@ export async function loadSandboxedPlugins(
|
|
|
230
321
|
contributionTimeoutMs,
|
|
231
322
|
reinitialize,
|
|
232
323
|
);
|
|
324
|
+
registerMessageBuilders(
|
|
325
|
+
api,
|
|
326
|
+
sandbox,
|
|
327
|
+
descriptor,
|
|
328
|
+
contributionTimeoutMs,
|
|
329
|
+
reinitialize,
|
|
330
|
+
);
|
|
233
331
|
registerSimpleContributions(api, descriptor);
|
|
234
332
|
},
|
|
235
333
|
};
|
|
@@ -267,7 +365,7 @@ function registerTools(
|
|
|
267
365
|
timeoutMs: number,
|
|
268
366
|
reinitialize: () => Promise<void>,
|
|
269
367
|
): void {
|
|
270
|
-
for (const td of descriptor.contributions
|
|
368
|
+
for (const td of descriptor.contributions?.tools ?? []) {
|
|
271
369
|
const tool: Tool = {
|
|
272
370
|
name: td.name,
|
|
273
371
|
description: td.description ?? "",
|
|
@@ -318,7 +416,7 @@ function registerCommands(
|
|
|
318
416
|
timeoutMs: number,
|
|
319
417
|
reinitialize: () => Promise<void>,
|
|
320
418
|
): void {
|
|
321
|
-
for (const cd of descriptor.contributions
|
|
419
|
+
for (const cd of descriptor.contributions?.commands ?? []) {
|
|
322
420
|
api.registerCommand({
|
|
323
421
|
name: cd.name,
|
|
324
422
|
description: cd.description,
|
|
@@ -357,36 +455,82 @@ function registerSimpleContributions(
|
|
|
357
455
|
api: AgentExtensionApi,
|
|
358
456
|
descriptor: SandboxedPluginDescriptor,
|
|
359
457
|
): void {
|
|
360
|
-
for (const
|
|
361
|
-
api.
|
|
362
|
-
name:
|
|
363
|
-
|
|
364
|
-
|
|
458
|
+
for (const pd of descriptor.contributions?.providers ?? []) {
|
|
459
|
+
api.registerProvider({
|
|
460
|
+
name: pd.name,
|
|
461
|
+
description: pd.description,
|
|
462
|
+
metadata: pd.metadata,
|
|
365
463
|
});
|
|
366
464
|
}
|
|
367
465
|
|
|
368
|
-
for (const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
466
|
+
for (const eventType of descriptor.contributions?.automationEventTypes ??
|
|
467
|
+
[]) {
|
|
468
|
+
api.registerAutomationEventType({
|
|
469
|
+
eventType: eventType.eventType,
|
|
470
|
+
source: eventType.source,
|
|
471
|
+
description: eventType.description,
|
|
472
|
+
attributesSchema: eventType.attributesSchema,
|
|
473
|
+
payloadSchema: eventType.payloadSchema,
|
|
474
|
+
examples: eventType.examples,
|
|
475
|
+
metadata: eventType.metadata,
|
|
373
476
|
});
|
|
374
477
|
}
|
|
478
|
+
}
|
|
375
479
|
|
|
376
|
-
|
|
480
|
+
function registerMessageBuilders(
|
|
481
|
+
api: AgentExtensionApi,
|
|
482
|
+
sandbox: SubprocessSandbox,
|
|
483
|
+
descriptor: SandboxedPluginDescriptor,
|
|
484
|
+
timeoutMs: number,
|
|
485
|
+
reinitialize: () => Promise<void>,
|
|
486
|
+
): void {
|
|
487
|
+
for (const bd of descriptor.contributions?.messageBuilders ?? []) {
|
|
377
488
|
api.registerMessageBuilder({
|
|
378
|
-
name:
|
|
379
|
-
build
|
|
489
|
+
name: bd.name,
|
|
490
|
+
async build(messages) {
|
|
491
|
+
try {
|
|
492
|
+
const result = await sandbox.call<unknown[]>(
|
|
493
|
+
"buildMessages",
|
|
494
|
+
{
|
|
495
|
+
pluginId: descriptor.pluginId,
|
|
496
|
+
contributionId: bd.id,
|
|
497
|
+
messages,
|
|
498
|
+
},
|
|
499
|
+
{ timeoutMs },
|
|
500
|
+
);
|
|
501
|
+
return isMessageArray(result) ? result : messages;
|
|
502
|
+
} catch (error) {
|
|
503
|
+
if (!isUnknownPluginIdError(error)) {
|
|
504
|
+
throw error;
|
|
505
|
+
}
|
|
506
|
+
await reinitialize();
|
|
507
|
+
const result = await sandbox.call<unknown[]>(
|
|
508
|
+
"buildMessages",
|
|
509
|
+
{
|
|
510
|
+
pluginId: descriptor.pluginId,
|
|
511
|
+
contributionId: bd.id,
|
|
512
|
+
messages,
|
|
513
|
+
},
|
|
514
|
+
{ timeoutMs },
|
|
515
|
+
);
|
|
516
|
+
return isMessageArray(result) ? result : messages;
|
|
517
|
+
}
|
|
518
|
+
},
|
|
380
519
|
});
|
|
381
520
|
}
|
|
521
|
+
}
|
|
382
522
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
523
|
+
function isMessageArray(value: unknown): value is Message[] {
|
|
524
|
+
return (
|
|
525
|
+
Array.isArray(value) &&
|
|
526
|
+
value.every(
|
|
527
|
+
(entry) =>
|
|
528
|
+
typeof entry === "object" &&
|
|
529
|
+
entry !== null &&
|
|
530
|
+
"role" in entry &&
|
|
531
|
+
"content" in entry,
|
|
532
|
+
)
|
|
533
|
+
);
|
|
390
534
|
}
|
|
391
535
|
|
|
392
536
|
function makeHookHandler(
|
|
@@ -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
|
+
}
|
|
@@ -18,6 +18,7 @@ export const DefaultToolNames = {
|
|
|
18
18
|
EDITOR: "editor",
|
|
19
19
|
SKILLS: "skills",
|
|
20
20
|
ASK: "ask_question",
|
|
21
|
+
SUBMIT_AND_EXIT: "submit_and_exit",
|
|
21
22
|
} as const;
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -32,4 +33,5 @@ export const ALL_DEFAULT_TOOL_NAMES: DefaultToolName[] = [
|
|
|
32
33
|
DefaultToolNames.EDITOR,
|
|
33
34
|
DefaultToolNames.SKILLS,
|
|
34
35
|
DefaultToolNames.ASK,
|
|
36
|
+
DefaultToolNames.SUBMIT_AND_EXIT,
|
|
35
37
|
];
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
formatReadFileQuery,
|
|
16
16
|
formatRunCommandQuery,
|
|
17
17
|
getEditorSizeError,
|
|
18
|
+
getReadFileRangeError,
|
|
18
19
|
normalizeReadFileRequests,
|
|
19
20
|
normalizeRunCommandsInput,
|
|
20
21
|
withTimeout,
|
|
@@ -92,6 +93,16 @@ export function createReadFilesTool(
|
|
|
92
93
|
|
|
93
94
|
return Promise.all(
|
|
94
95
|
requests.map(async (request): Promise<ToolOperationResult> => {
|
|
96
|
+
const rangeError = getReadFileRangeError(request);
|
|
97
|
+
if (rangeError) {
|
|
98
|
+
return {
|
|
99
|
+
query: formatReadFileQuery(request),
|
|
100
|
+
result: "",
|
|
101
|
+
error: `Invalid file range: ${rangeError}`,
|
|
102
|
+
success: false,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
95
106
|
try {
|
|
96
107
|
const content = await withTimeout(
|
|
97
108
|
executor(request, context),
|
|
@@ -206,16 +217,23 @@ export function createBashTool(
|
|
|
206
217
|
maxRetries: 0,
|
|
207
218
|
execute: async (input, context) => {
|
|
208
219
|
const validate = validateWithZod(RunCommandsInputUnionSchema, input);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
220
|
+
let commands: string[];
|
|
221
|
+
if (typeof validate === "string") {
|
|
222
|
+
commands = [validate];
|
|
223
|
+
} else if (Array.isArray(validate)) {
|
|
224
|
+
commands = validate;
|
|
225
|
+
} else if ("commands" in validate) {
|
|
226
|
+
commands = Array.isArray(validate.commands)
|
|
227
|
+
? validate.commands
|
|
228
|
+
: [validate.commands];
|
|
229
|
+
} else if ("command" in validate) {
|
|
230
|
+
commands = [validate.command];
|
|
231
|
+
} else {
|
|
232
|
+
commands = [validate.cmd];
|
|
233
|
+
}
|
|
216
234
|
|
|
217
235
|
return Promise.all(
|
|
218
|
-
commands.map(async (command): Promise<ToolOperationResult> => {
|
|
236
|
+
commands.map(async (command: string): Promise<ToolOperationResult> => {
|
|
219
237
|
try {
|
|
220
238
|
const output = await withTimeout(
|
|
221
239
|
executor(command, cwd, context),
|
|
@@ -350,67 +368,48 @@ export function createWebFetchTool(
|
|
|
350
368
|
});
|
|
351
369
|
}
|
|
352
370
|
|
|
353
|
-
const APPLY_PATCH_TOOL_DESC = `
|
|
371
|
+
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
372
|
|
|
355
|
-
%%bash
|
|
356
|
-
apply_patch <<"EOF"
|
|
357
373
|
*** Begin Patch
|
|
358
|
-
|
|
374
|
+
*** Update File: path/to/file.ts
|
|
375
|
+
@@ optional section marker
|
|
376
|
+
[context before]
|
|
377
|
+
-[old line]
|
|
378
|
+
+[new line]
|
|
379
|
+
[context after]
|
|
359
380
|
*** End Patch
|
|
360
|
-
EOF
|
|
361
|
-
|
|
362
|
-
Where [YOUR_PATCH] is the actual content of your patch, specified in the following V4A diff format.
|
|
363
381
|
|
|
364
|
-
|
|
382
|
+
Supported actions:
|
|
383
|
+
- \`*** Add File: <path>\`
|
|
384
|
+
- \`*** Update File: <path>\`
|
|
385
|
+
- \`*** Delete File: <path>\`
|
|
386
|
+
- optional \`*** Move to: <new path>\` immediately after an Update File header
|
|
365
387
|
|
|
366
|
-
|
|
367
|
-
In
|
|
368
|
-
|
|
369
|
-
-
|
|
370
|
-
|
|
371
|
-
|
|
388
|
+
Rules:
|
|
389
|
+
- In an Add File section, every file-content line must start with \`+\`.
|
|
390
|
+
- In an Update section, use context lines plus \`-\` and \`+\` lines to describe the change.
|
|
391
|
+
- Use \`@@\` markers when extra context is needed to disambiguate repeated code blocks.
|
|
392
|
+
- Do not use line numbers; this format is context-based.
|
|
393
|
+
- Prefer sending the patch body directly. Legacy shell wrappers such as \`%%bash\` and \`apply_patch <<"EOF"\` are accepted for compatibility but are not preferred.
|
|
372
394
|
|
|
373
|
-
|
|
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]
|
|
395
|
+
Example:
|
|
381
396
|
|
|
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
397
|
*** Begin Patch
|
|
396
|
-
*** Update File:
|
|
397
|
-
@@
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
*** End Patch
|
|
408
|
-
EOF`;
|
|
398
|
+
*** Update File: src/page.tsx
|
|
399
|
+
@@
|
|
400
|
+
return (
|
|
401
|
+
<div>
|
|
402
|
+
<button onClick={() => console.log("clicked")}>Click me</button>
|
|
403
|
+
+ <button onClick={() => console.log("cancel clicked")}>Cancel</button>
|
|
404
|
+
</div>
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
*** End Patch`;
|
|
409
408
|
|
|
410
409
|
/**
|
|
411
410
|
* Create the apply_patch tool
|
|
412
411
|
*
|
|
413
|
-
* Applies the
|
|
412
|
+
* Applies the canonical apply_patch format to one or more files.
|
|
414
413
|
*/
|
|
415
414
|
export function createApplyPatchTool(
|
|
416
415
|
executor: ApplyPatchExecutor,
|
|
@@ -583,11 +582,8 @@ export function createSkillsTool(
|
|
|
583
582
|
*/
|
|
584
583
|
export function createAskQuestionTool(
|
|
585
584
|
executor: AskQuestionExecutor,
|
|
586
|
-
config: Pick<DefaultToolsConfig, "askQuestionTimeoutMs"> = {},
|
|
587
585
|
): Tool<AskQuestionInput, string> {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
return createTool<AskQuestionInput, string>({
|
|
586
|
+
return {
|
|
591
587
|
name: "ask_question",
|
|
592
588
|
description:
|
|
593
589
|
"Ask user a question for clarifying or gathering information needed to complete the task. " +
|
|
@@ -596,18 +592,13 @@ export function createAskQuestionTool(
|
|
|
596
592
|
"Provide an array of 2-5 options for the user to choose from. " +
|
|
597
593
|
"Never include an option to toggle to Act mode.",
|
|
598
594
|
inputSchema: zodToJsonSchema(AskQuestionInputSchema),
|
|
599
|
-
timeoutMs,
|
|
600
595
|
retryable: false,
|
|
601
596
|
maxRetries: 0,
|
|
602
597
|
execute: async (input, context) => {
|
|
603
598
|
const validatedInput = validateWithZod(AskQuestionInputSchema, input);
|
|
604
|
-
return
|
|
605
|
-
executor(validatedInput.question, validatedInput.options, context),
|
|
606
|
-
timeoutMs,
|
|
607
|
-
`ask_question timed out after ${timeoutMs}ms`,
|
|
608
|
-
);
|
|
599
|
+
return executor(validatedInput.question, validatedInput.options, context);
|
|
609
600
|
},
|
|
610
|
-
}
|
|
601
|
+
};
|
|
611
602
|
}
|
|
612
603
|
|
|
613
604
|
export function createSubmitAndExitTool(
|
|
@@ -651,8 +642,7 @@ export function createSubmitAndExitTool(
|
|
|
651
642
|
*
|
|
652
643
|
* @example
|
|
653
644
|
* ```typescript
|
|
654
|
-
* import { Agent } from "@clinebot/
|
|
655
|
-
* import { createDefaultTools } from "@clinebot/core"
|
|
645
|
+
* import { Agent, createDefaultTools } from "@clinebot/core"
|
|
656
646
|
* import * as fs from "fs/promises"
|
|
657
647
|
* import { exec } from "child_process"
|
|
658
648
|
*
|
|
@@ -738,7 +728,7 @@ export function createDefaultTools(options: CreateDefaultToolsOptions): Tool[] {
|
|
|
738
728
|
|
|
739
729
|
// Add ask_question tool if enabled and executor provided
|
|
740
730
|
if (enableAskQuestion && executors.askQuestion) {
|
|
741
|
-
tools.push(createAskQuestionTool(executors.askQuestion
|
|
731
|
+
tools.push(createAskQuestionTool(executors.askQuestion));
|
|
742
732
|
} else if (enableSubmitAndExit && executors.submit) {
|
|
743
733
|
// Add submit_and_exit tool if enabled and executor provided
|
|
744
734
|
tools.push(createSubmitAndExitTool(executors.submit, config));
|