@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
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-session consecutive-mistake tracker.
|
|
3
|
+
*
|
|
4
|
+
* @see PLAN.md §3.1 — wrapped around `recordMistake` moved from
|
|
5
|
+
* `packages/agents/src/api/error-handling.ts` lines 147–311.
|
|
6
|
+
* @see PLAN.md §3.2.3 — public surface of `MistakeTracker`.
|
|
7
|
+
*
|
|
8
|
+
* The pure procedural `recordMistake(input, deps)` becomes `record(input)`
|
|
9
|
+
* on the class; `consecutiveMistakes` is internal state. Other deps flow
|
|
10
|
+
* through the constructor instead.
|
|
11
|
+
*
|
|
12
|
+
* NOTE: the §3.2.3 constructor shape omits some fields (agentId,
|
|
13
|
+
* conversationId/runId getters, appendRecoveryNotice). They are retained
|
|
14
|
+
* here for log + notice parity per PLAN.md §3.4.3/§3.4.5. Step 8
|
|
15
|
+
* (`impl-runtime-porter`) may refactor once SessionRuntime is wired up.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {
|
|
19
|
+
AgentEvent,
|
|
20
|
+
BasicLogMetadata,
|
|
21
|
+
ConsecutiveMistakeLimitContext,
|
|
22
|
+
ConsecutiveMistakeLimitDecision,
|
|
23
|
+
} from "@clinebot/shared";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Legacy-agents-style leveled log function. The sdk-re `BasicLogger`
|
|
27
|
+
* does not carry a level argument (§shared/logging/logger.ts); callers
|
|
28
|
+
* are expected to bridge via `metadata.severity` or dispatch to
|
|
29
|
+
* `debug`/`log`/`error`. `MistakeTracker` accepts a leveled callable
|
|
30
|
+
* here so Step 8 can plug in whichever bridging shape `SessionRuntime`
|
|
31
|
+
* ends up using.
|
|
32
|
+
*/
|
|
33
|
+
export type LeveledLog = (
|
|
34
|
+
level: "debug" | "info" | "warn" | "error",
|
|
35
|
+
message: string,
|
|
36
|
+
metadata?: BasicLogMetadata,
|
|
37
|
+
) => void;
|
|
38
|
+
|
|
39
|
+
export type MistakeReason =
|
|
40
|
+
| "api_error"
|
|
41
|
+
| "invalid_tool_call"
|
|
42
|
+
| "tool_execution_failed";
|
|
43
|
+
|
|
44
|
+
export interface RecordMistakeInput {
|
|
45
|
+
iteration: number;
|
|
46
|
+
reason: MistakeReason;
|
|
47
|
+
details?: string;
|
|
48
|
+
/** When true, jump straight to maxConsecutiveMistakes instead of incrementing by 1. */
|
|
49
|
+
forceAtLimit?: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type MistakeOutcome =
|
|
53
|
+
| { action: "continue"; guidance?: string }
|
|
54
|
+
| { action: "stop"; message: string; reason?: string };
|
|
55
|
+
|
|
56
|
+
export interface MistakeTrackerOptions {
|
|
57
|
+
readonly maxConsecutiveMistakes: number;
|
|
58
|
+
readonly onLimitReached?: (
|
|
59
|
+
ctx: ConsecutiveMistakeLimitContext,
|
|
60
|
+
) =>
|
|
61
|
+
| Promise<ConsecutiveMistakeLimitDecision>
|
|
62
|
+
| ConsecutiveMistakeLimitDecision;
|
|
63
|
+
readonly emit: (event: AgentEvent) => void;
|
|
64
|
+
readonly log: LeveledLog;
|
|
65
|
+
readonly agentId: string;
|
|
66
|
+
readonly getConversationId: () => string;
|
|
67
|
+
readonly getActiveRunId: () => string;
|
|
68
|
+
readonly appendRecoveryNotice: (
|
|
69
|
+
message: string,
|
|
70
|
+
reason: MistakeReason,
|
|
71
|
+
) => void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export class MistakeTracker {
|
|
75
|
+
private consecutiveMistakes = 0;
|
|
76
|
+
private readonly options: MistakeTrackerOptions;
|
|
77
|
+
|
|
78
|
+
constructor(options: MistakeTrackerOptions) {
|
|
79
|
+
this.options = options;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async record(input: RecordMistakeInput): Promise<MistakeOutcome> {
|
|
83
|
+
const max = this.options.maxConsecutiveMistakes;
|
|
84
|
+
const next = input.forceAtLimit && max ? max : this.consecutiveMistakes + 1;
|
|
85
|
+
this.consecutiveMistakes = next;
|
|
86
|
+
|
|
87
|
+
const errorMessage =
|
|
88
|
+
input.details?.trim() || `consecutive mistake (${input.reason})`;
|
|
89
|
+
this.options.emit({
|
|
90
|
+
type: "error",
|
|
91
|
+
error: new Error(errorMessage),
|
|
92
|
+
recoverable: true,
|
|
93
|
+
iteration: input.iteration,
|
|
94
|
+
});
|
|
95
|
+
this.options.log("warn", "Recorded consecutive mistake", {
|
|
96
|
+
agentId: this.options.agentId,
|
|
97
|
+
conversationId: this.options.getConversationId(),
|
|
98
|
+
runId: this.options.getActiveRunId(),
|
|
99
|
+
iteration: input.iteration,
|
|
100
|
+
reason: input.reason,
|
|
101
|
+
details: input.details,
|
|
102
|
+
consecutiveMistakes: next,
|
|
103
|
+
maxConsecutiveMistakes: this.options.maxConsecutiveMistakes,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
if (!max || next < max) {
|
|
107
|
+
return { action: "continue" };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const decision = await resolveConsecutiveMistakeDecision(
|
|
111
|
+
{
|
|
112
|
+
iteration: input.iteration,
|
|
113
|
+
consecutiveMistakes: next,
|
|
114
|
+
maxConsecutiveMistakes: max,
|
|
115
|
+
reason: input.reason,
|
|
116
|
+
details: input.details,
|
|
117
|
+
},
|
|
118
|
+
this.options.onLimitReached,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
if (decision.action === "continue") {
|
|
122
|
+
const guidance = decision.guidance?.trim();
|
|
123
|
+
if (guidance) {
|
|
124
|
+
this.options.appendRecoveryNotice(guidance, input.reason);
|
|
125
|
+
}
|
|
126
|
+
this.consecutiveMistakes = 0;
|
|
127
|
+
return { action: "continue", guidance };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
action: "stop",
|
|
132
|
+
reason: decision.reason?.trim() || undefined,
|
|
133
|
+
message: buildMistakeLimitStopMessage({
|
|
134
|
+
iteration: input.iteration,
|
|
135
|
+
consecutiveMistakes: next,
|
|
136
|
+
maxConsecutiveMistakes: max,
|
|
137
|
+
reason: input.reason,
|
|
138
|
+
details: input.details,
|
|
139
|
+
stopReason: decision.reason,
|
|
140
|
+
}),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
reset(): void {
|
|
145
|
+
this.consecutiveMistakes = 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
get value(): number {
|
|
149
|
+
return this.consecutiveMistakes;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// =============================================================================
|
|
154
|
+
// Mistake Limit Stop Message (pure helper — ported verbatim)
|
|
155
|
+
// =============================================================================
|
|
156
|
+
|
|
157
|
+
export function buildMistakeLimitStopMessage(input: {
|
|
158
|
+
iteration: number;
|
|
159
|
+
consecutiveMistakes: number;
|
|
160
|
+
maxConsecutiveMistakes: number;
|
|
161
|
+
reason:
|
|
162
|
+
| "api_error"
|
|
163
|
+
| "invalid_tool_call"
|
|
164
|
+
| "completion_without_submit"
|
|
165
|
+
| "tool_execution_failed";
|
|
166
|
+
details?: string;
|
|
167
|
+
stopReason?: string;
|
|
168
|
+
}): string {
|
|
169
|
+
const parts = [
|
|
170
|
+
`Stopped after ${input.consecutiveMistakes}/${input.maxConsecutiveMistakes} consecutive mistakes (${input.reason}) at iteration ${input.iteration}.`,
|
|
171
|
+
];
|
|
172
|
+
const details = input.details?.trim();
|
|
173
|
+
if (details) {
|
|
174
|
+
parts.push(`Error: ${details}`);
|
|
175
|
+
}
|
|
176
|
+
const stopReason = input.stopReason?.trim();
|
|
177
|
+
if (stopReason) {
|
|
178
|
+
parts.push(`Decision: ${stopReason}`);
|
|
179
|
+
}
|
|
180
|
+
parts.push(
|
|
181
|
+
"Session state was preserved. Send a new prompt to resume from the latest state.",
|
|
182
|
+
);
|
|
183
|
+
return parts.join(" ");
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// =============================================================================
|
|
187
|
+
// Consecutive Mistake Decision Resolution (pure helper — ported verbatim)
|
|
188
|
+
// =============================================================================
|
|
189
|
+
|
|
190
|
+
async function resolveConsecutiveMistakeDecision(
|
|
191
|
+
input: ConsecutiveMistakeLimitContext,
|
|
192
|
+
callback?: (
|
|
193
|
+
context: ConsecutiveMistakeLimitContext,
|
|
194
|
+
) =>
|
|
195
|
+
| Promise<ConsecutiveMistakeLimitDecision>
|
|
196
|
+
| ConsecutiveMistakeLimitDecision,
|
|
197
|
+
): Promise<ConsecutiveMistakeLimitDecision> {
|
|
198
|
+
if (!callback) {
|
|
199
|
+
return {
|
|
200
|
+
action: "stop",
|
|
201
|
+
reason: `maximum consecutive mistakes reached (${input.maxConsecutiveMistakes})`,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
return await callback(input);
|
|
206
|
+
} catch (error) {
|
|
207
|
+
return {
|
|
208
|
+
action: "stop",
|
|
209
|
+
reason:
|
|
210
|
+
error instanceof Error
|
|
211
|
+
? error.message
|
|
212
|
+
: `maximum consecutive mistakes reached (${input.maxConsecutiveMistakes})`,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// TODO(PLAN.md Step 8): The `emit` channel currently accepts legacy `AgentEvent`
|
|
218
|
+
// so the "recoverable error" event shape is preserved verbatim. When
|
|
219
|
+
// `SessionRuntime` wires this up in Step 8, consider whether this should
|
|
220
|
+
// emit an `AgentRuntimeEvent` (per the §3.2.3 signature proposal) and let
|
|
221
|
+
// the bridge translate, or keep the direct legacy channel for notice parity.
|
package/src/runtime/rules.ts
CHANGED
|
@@ -20,6 +20,18 @@ export function formatRulesForSystemPrompt(
|
|
|
20
20
|
return `\n\n# Rules\n${renderedRules}`;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export function mergeRulesForSystemPrompt(
|
|
24
|
+
primaryRules?: string,
|
|
25
|
+
additionalRules?: string,
|
|
26
|
+
): string | undefined {
|
|
27
|
+
const primary = primaryRules?.trim();
|
|
28
|
+
const additional = additionalRules?.trim();
|
|
29
|
+
if (primary && additional) {
|
|
30
|
+
return `${primary}\n\n${additional}`;
|
|
31
|
+
}
|
|
32
|
+
return primary || additional || undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
23
35
|
export function listEnabledRulesFromWatcher(
|
|
24
36
|
watcher: UserInstructionConfigWatcher,
|
|
25
37
|
): RuleConfig[] {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { existsSync, readdirSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
BasicLogger,
|
|
5
|
+
RuntimeConfigExtensionKind,
|
|
6
|
+
TeamTeammateSpec,
|
|
7
|
+
Tool,
|
|
8
|
+
} from "@clinebot/shared";
|
|
4
9
|
import { resolveSkillsConfigSearchPaths } from "@clinebot/shared/storage";
|
|
5
10
|
import { nanoid } from "nanoid";
|
|
6
11
|
import {
|
|
@@ -32,6 +37,10 @@ import {
|
|
|
32
37
|
createDelegatedAgentConfigProvider,
|
|
33
38
|
type TeamEvent,
|
|
34
39
|
} from "../extensions/tools/team";
|
|
40
|
+
import {
|
|
41
|
+
filterDisabledTools,
|
|
42
|
+
resolveDisabledToolNames,
|
|
43
|
+
} from "../services/global-settings";
|
|
35
44
|
import { createLocalTeamStore } from "../services/storage/team-store";
|
|
36
45
|
import type { CoreAgentMode, CoreSessionConfig } from "../types/config";
|
|
37
46
|
import type {
|
|
@@ -51,6 +60,19 @@ type SkillsExecutorWithMetadata = SkillsExecutor & {
|
|
|
51
60
|
configuredSkills?: SkillsExecutorMetadataItem[];
|
|
52
61
|
};
|
|
53
62
|
|
|
63
|
+
const ALL_CONFIG_EXTENSIONS: readonly RuntimeConfigExtensionKind[] = [
|
|
64
|
+
"rules",
|
|
65
|
+
"skills",
|
|
66
|
+
"plugins",
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
function hasConfigExtension(
|
|
70
|
+
extensions: ReadonlyArray<RuntimeConfigExtensionKind> | undefined,
|
|
71
|
+
kind: RuntimeConfigExtensionKind,
|
|
72
|
+
): boolean {
|
|
73
|
+
return new Set(extensions ?? ALL_CONFIG_EXTENSIONS).has(kind);
|
|
74
|
+
}
|
|
75
|
+
|
|
54
76
|
function isToolEnabledByPolicies(
|
|
55
77
|
toolName: string,
|
|
56
78
|
toolPolicies: CoreSessionConfig["toolPolicies"],
|
|
@@ -74,6 +96,13 @@ function filterToolsByPolicies(
|
|
|
74
96
|
);
|
|
75
97
|
}
|
|
76
98
|
|
|
99
|
+
function filterAvailableTools(
|
|
100
|
+
tools: Tool[],
|
|
101
|
+
toolPolicies: CoreSessionConfig["toolPolicies"],
|
|
102
|
+
): Tool[] {
|
|
103
|
+
return filterDisabledTools(filterToolsByPolicies(tools, toolPolicies));
|
|
104
|
+
}
|
|
105
|
+
|
|
77
106
|
export function createTeamName(): string {
|
|
78
107
|
return `team-${nanoid(5)}`;
|
|
79
108
|
}
|
|
@@ -96,7 +125,7 @@ function createBuiltinToolsList(
|
|
|
96
125
|
toolRoutingRules ?? DEFAULT_MODEL_TOOL_ROUTING_RULES,
|
|
97
126
|
);
|
|
98
127
|
|
|
99
|
-
return
|
|
128
|
+
return filterAvailableTools(
|
|
100
129
|
createBuiltinTools({
|
|
101
130
|
cwd,
|
|
102
131
|
...preset,
|
|
@@ -412,6 +441,28 @@ function shutdownTeamRuntime(
|
|
|
412
441
|
}
|
|
413
442
|
}
|
|
414
443
|
|
|
444
|
+
function isRuntimeLifecycleShutdownReason(reason: string | undefined): boolean {
|
|
445
|
+
if (reason === undefined) {
|
|
446
|
+
return true;
|
|
447
|
+
}
|
|
448
|
+
switch (reason) {
|
|
449
|
+
case "session_stop":
|
|
450
|
+
case "session_complete":
|
|
451
|
+
case "session_error":
|
|
452
|
+
case "session_manager_dispose":
|
|
453
|
+
case "cli_run_shutdown":
|
|
454
|
+
case "cli_interactive_shutdown":
|
|
455
|
+
case "cli_interactive_startup_cancelled":
|
|
456
|
+
case "provider_change":
|
|
457
|
+
case "acp_shutdown":
|
|
458
|
+
case "hub_server_stop":
|
|
459
|
+
case "vscode_webview_dispose":
|
|
460
|
+
return true;
|
|
461
|
+
default:
|
|
462
|
+
return false;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
415
466
|
function normalizeConfig(
|
|
416
467
|
config: CoreSessionConfig,
|
|
417
468
|
): Required<
|
|
@@ -474,13 +525,17 @@ export class DefaultRuntimeBuilder implements RuntimeBuilder {
|
|
|
474
525
|
createSpawnTool,
|
|
475
526
|
onTeamRestored,
|
|
476
527
|
userInstructionWatcher: sharedUserInstructionWatcher,
|
|
528
|
+
configExtensions,
|
|
477
529
|
defaultToolExecutors,
|
|
478
530
|
} = input;
|
|
479
531
|
const onTeamEvent = input.onTeamEvent ?? (() => {});
|
|
480
532
|
const normalized = normalizeConfig(config);
|
|
533
|
+
const globallyDisabledToolNames = resolveDisabledToolNames();
|
|
481
534
|
const tools: Tool[] = [];
|
|
482
535
|
const effectiveTeamName = config.teamName?.trim() || createTeamName();
|
|
483
|
-
const
|
|
536
|
+
const teamStoreKey = config.sessionId?.trim() || effectiveTeamName;
|
|
537
|
+
const skillsEnabled = hasConfigExtension(configExtensions, "skills");
|
|
538
|
+
const hasLocalSkills = skillsEnabled && hasSkillsFiles(config.cwd);
|
|
484
539
|
let teamToolsRegistered = false;
|
|
485
540
|
const watcherProvided = Boolean(sharedUserInstructionWatcher);
|
|
486
541
|
let userInstructionWatcher = sharedUserInstructionWatcher;
|
|
@@ -488,7 +543,12 @@ export class DefaultRuntimeBuilder implements RuntimeBuilder {
|
|
|
488
543
|
let skillsExecutor: SkillsExecutorWithMetadata | undefined;
|
|
489
544
|
let mcpShutdown: (() => Promise<void>) | undefined;
|
|
490
545
|
|
|
491
|
-
if (
|
|
546
|
+
if (
|
|
547
|
+
!userInstructionWatcher &&
|
|
548
|
+
normalized.enableTools &&
|
|
549
|
+
skillsEnabled &&
|
|
550
|
+
hasLocalSkills
|
|
551
|
+
) {
|
|
492
552
|
userInstructionWatcher = createUserInstructionConfigWatcher({
|
|
493
553
|
skills: { workspacePath: config.cwd },
|
|
494
554
|
rules: { workspacePath: config.cwd },
|
|
@@ -499,6 +559,7 @@ export class DefaultRuntimeBuilder implements RuntimeBuilder {
|
|
|
499
559
|
|
|
500
560
|
if (
|
|
501
561
|
normalized.enableTools &&
|
|
562
|
+
skillsEnabled &&
|
|
502
563
|
userInstructionWatcher &&
|
|
503
564
|
(watcherProvided ||
|
|
504
565
|
hasLocalSkills ||
|
|
@@ -535,7 +596,7 @@ export class DefaultRuntimeBuilder implements RuntimeBuilder {
|
|
|
535
596
|
const teamStore = normalized.enableAgentTeams
|
|
536
597
|
? createLocalTeamStore()
|
|
537
598
|
: undefined;
|
|
538
|
-
const restoredTeam = teamStore?.loadRuntime(
|
|
599
|
+
const restoredTeam = teamStore?.loadRuntime(teamStoreKey);
|
|
539
600
|
const restoredTeamState = restoredTeam?.state;
|
|
540
601
|
const restoredTeammateSpecs = restoredTeam?.teammates ?? [];
|
|
541
602
|
const teammateSpecs = new Map(
|
|
@@ -548,6 +609,7 @@ export class DefaultRuntimeBuilder implements RuntimeBuilder {
|
|
|
548
609
|
}
|
|
549
610
|
| undefined;
|
|
550
611
|
let pendingLeadTeamTools: Tool[] = [];
|
|
612
|
+
let restoredStateHydratedIntoRuntime = false;
|
|
551
613
|
const delegatedAgentConfigProvider = createDelegatedAgentConfigProvider({
|
|
552
614
|
providerId: config.providerId,
|
|
553
615
|
modelId: config.modelId,
|
|
@@ -603,12 +665,15 @@ export class DefaultRuntimeBuilder implements RuntimeBuilder {
|
|
|
603
665
|
};
|
|
604
666
|
teammateSpecs.set(spec.agentId, spec);
|
|
605
667
|
}
|
|
606
|
-
if (
|
|
668
|
+
if (
|
|
669
|
+
event.type === "teammate_shutdown" &&
|
|
670
|
+
!isRuntimeLifecycleShutdownReason(event.reason)
|
|
671
|
+
) {
|
|
607
672
|
teammateSpecs.delete(event.agentId);
|
|
608
673
|
}
|
|
609
|
-
teamStore.handleTeamEvent(
|
|
674
|
+
teamStore.handleTeamEvent(teamStoreKey, event);
|
|
610
675
|
teamStore.persistRuntime(
|
|
611
|
-
|
|
676
|
+
teamStoreKey,
|
|
612
677
|
teamRuntime.exportState(),
|
|
613
678
|
Array.from(teammateSpecs.values()),
|
|
614
679
|
);
|
|
@@ -617,7 +682,7 @@ export class DefaultRuntimeBuilder implements RuntimeBuilder {
|
|
|
617
682
|
});
|
|
618
683
|
if (restoredTeamState) {
|
|
619
684
|
teamRuntime.hydrateState(restoredTeamState);
|
|
620
|
-
|
|
685
|
+
restoredStateHydratedIntoRuntime = true;
|
|
621
686
|
}
|
|
622
687
|
registryEntry.runtime = teamRuntime;
|
|
623
688
|
}
|
|
@@ -628,8 +693,7 @@ export class DefaultRuntimeBuilder implements RuntimeBuilder {
|
|
|
628
693
|
}
|
|
629
694
|
teamToolsRegistered = true;
|
|
630
695
|
|
|
631
|
-
const
|
|
632
|
-
const teamBootstrap = factory({
|
|
696
|
+
const teamBootstrap = bootstrapAgentTeams({
|
|
633
697
|
runtime: teamRuntime,
|
|
634
698
|
leadAgentId: config.sessionId || "lead",
|
|
635
699
|
restoredFromPersistence: Boolean(restoredTeamState),
|
|
@@ -656,6 +720,10 @@ export class DefaultRuntimeBuilder implements RuntimeBuilder {
|
|
|
656
720
|
teammateConfigProvider: delegatedAgentConfigProvider,
|
|
657
721
|
});
|
|
658
722
|
|
|
723
|
+
if (restoredStateHydratedIntoRuntime) {
|
|
724
|
+
teamRuntime.recoverActiveRuns("runtime_recovered");
|
|
725
|
+
}
|
|
726
|
+
|
|
659
727
|
if (teamBootstrap.restoredFromPersistence) {
|
|
660
728
|
onTeamRestored?.();
|
|
661
729
|
}
|
|
@@ -714,7 +782,7 @@ export class DefaultRuntimeBuilder implements RuntimeBuilder {
|
|
|
714
782
|
: undefined;
|
|
715
783
|
|
|
716
784
|
return {
|
|
717
|
-
tools:
|
|
785
|
+
tools: filterAvailableTools(tools, config.toolPolicies),
|
|
718
786
|
logger: logger ?? config.logger,
|
|
719
787
|
telemetry: telemetry ?? config.telemetry,
|
|
720
788
|
teamRuntime,
|
|
@@ -726,7 +794,11 @@ export class DefaultRuntimeBuilder implements RuntimeBuilder {
|
|
|
726
794
|
registerLeadAgent: (agent) => {
|
|
727
795
|
leadAgentInstance = agent;
|
|
728
796
|
if (pendingLeadTeamTools.length > 0) {
|
|
729
|
-
agent.addTools(
|
|
797
|
+
agent.addTools(
|
|
798
|
+
filterDisabledTools(pendingLeadTeamTools, [
|
|
799
|
+
...globallyDisabledToolNames,
|
|
800
|
+
]),
|
|
801
|
+
);
|
|
730
802
|
}
|
|
731
803
|
},
|
|
732
804
|
shutdown: async (reason: string) => {
|