@clinebot/core 0.0.37 → 0.0.38
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 +11 -1
- package/dist/ClineCore.d.ts +18 -214
- package/dist/account/cline-account-service.d.ts +0 -1
- package/dist/account/index.d.ts +0 -1
- package/dist/account/rpc.d.ts +0 -1
- package/dist/account/types.d.ts +0 -1
- package/dist/auth/bounded-ttl-cache.d.ts +0 -1
- package/dist/auth/client.d.ts +0 -1
- package/dist/auth/cline.d.ts +0 -5
- package/dist/auth/codex.d.ts +0 -1
- package/dist/auth/oca.d.ts +0 -1
- package/dist/auth/server.d.ts +0 -1
- package/dist/auth/types.d.ts +0 -1
- package/dist/auth/utils.d.ts +0 -1
- package/dist/cline-core/automation.d.ts +34 -0
- package/dist/cline-core/runtime-services.d.ts +5 -0
- package/dist/cline-core/start-input.d.ts +10 -0
- package/dist/cline-core/telemetry.d.ts +10 -0
- package/dist/cline-core/types.d.ts +221 -0
- package/dist/cron/{cron-event-ingress.d.ts → events/cron-event-ingress.d.ts} +1 -2
- package/dist/cron/{cron-report-writer.d.ts → reports/cron-report-writer.d.ts} +1 -2
- package/dist/cron/{cron-materializer.d.ts → runner/cron-materializer.d.ts} +1 -2
- package/dist/cron/{cron-runner.d.ts → runner/cron-runner.d.ts} +6 -4
- package/dist/cron/{resource-limiter.d.ts → runner/resource-limiter.d.ts} +0 -1
- package/dist/cron/schedule/scheduler.d.ts +12 -0
- package/dist/cron/{cron-service.d.ts → service/cron-service.d.ts} +4 -5
- package/dist/cron/{schedule-command-service.d.ts → service/schedule-command-service.d.ts} +0 -1
- package/dist/cron/{schedule-service.d.ts → service/schedule-service.d.ts} +20 -22
- package/dist/cron/{cron-reconciler.d.ts → specs/cron-reconciler.d.ts} +1 -2
- package/dist/cron/{cron-spec-parser.d.ts → specs/cron-spec-parser.d.ts} +0 -1
- package/dist/cron/{cron-watcher.d.ts → specs/cron-watcher.d.ts} +0 -1
- package/dist/cron/{cron-schema.d.ts → store/cron-schema.d.ts} +0 -1
- package/dist/cron/{sqlite-cron-store.d.ts → store/sqlite-cron-store.d.ts} +12 -2
- package/dist/extensions/config/index.d.ts +4 -7
- package/dist/extensions/config/runtime-commands.d.ts +0 -1
- package/dist/extensions/config/skill-frontmatter-toggle.d.ts +11 -0
- package/dist/extensions/config/unified-config-file-watcher.d.ts +0 -1
- package/dist/extensions/config/user-instruction-config-loader.d.ts +0 -1
- package/dist/extensions/config/user-instruction-plugin.d.ts +25 -0
- package/dist/extensions/config/user-instruction-service.d.ts +23 -0
- package/dist/extensions/context/agentic-compaction.d.ts +0 -1
- package/dist/extensions/context/basic-compaction.d.ts +0 -1
- package/dist/extensions/context/compaction-shared.d.ts +0 -1
- package/dist/extensions/context/compaction.d.ts +0 -1
- package/dist/extensions/index.d.ts +0 -1
- package/dist/extensions/mcp/client.d.ts +0 -1
- package/dist/extensions/mcp/config-loader.d.ts +0 -1
- package/dist/extensions/mcp/index.d.ts +0 -1
- package/dist/extensions/mcp/manager.d.ts +0 -1
- package/dist/extensions/mcp/name-transform.d.ts +0 -1
- package/dist/extensions/mcp/policies.d.ts +0 -1
- package/dist/extensions/mcp/tools.d.ts +2 -3
- package/dist/extensions/mcp/types.d.ts +3 -4
- package/dist/extensions/plugin/plugin-config-loader.d.ts +0 -1
- package/dist/extensions/plugin/plugin-load-report.d.ts +0 -1
- package/dist/extensions/plugin/plugin-loader.d.ts +0 -1
- package/dist/extensions/plugin/plugin-module-import.d.ts +0 -1
- package/dist/extensions/plugin/plugin-sandbox.d.ts +0 -1
- package/dist/extensions/plugin/plugin-targeting.d.ts +0 -1
- package/dist/extensions/plugin-sandbox-bootstrap.js +1 -446
- package/dist/extensions/tools/constants.d.ts +0 -1
- package/dist/extensions/tools/definitions.d.ts +13 -14
- package/dist/extensions/tools/executors/apply-patch-parser.d.ts +0 -1
- package/dist/extensions/tools/executors/apply-patch.d.ts +0 -1
- package/dist/extensions/tools/executors/bash.d.ts +0 -1
- package/dist/extensions/tools/executors/editor.d.ts +0 -1
- package/dist/extensions/tools/executors/file-read.d.ts +0 -1
- package/dist/extensions/tools/executors/index.d.ts +0 -1
- package/dist/extensions/tools/executors/search.d.ts +0 -1
- package/dist/extensions/tools/executors/web-fetch.d.ts +0 -1
- package/dist/extensions/tools/helpers.d.ts +0 -1
- package/dist/extensions/tools/index.d.ts +2 -3
- package/dist/extensions/tools/model-tool-routing.d.ts +0 -1
- package/dist/extensions/tools/presets.d.ts +4 -5
- package/dist/extensions/tools/runtime.d.ts +0 -1
- package/dist/extensions/tools/schemas.d.ts +0 -1
- package/dist/extensions/tools/team/delegated-agent.d.ts +3 -4
- package/dist/extensions/tools/team/index.d.ts +0 -1
- package/dist/extensions/tools/team/multi-agent.d.ts +1 -2
- package/dist/extensions/tools/team/projections.d.ts +0 -1
- package/dist/extensions/tools/team/runtime.d.ts +0 -1
- package/dist/extensions/tools/team/spawn-agent-tool.d.ts +4 -5
- package/dist/extensions/tools/team/subagent-prompts.d.ts +0 -1
- package/dist/extensions/tools/team/team-tools.d.ts +7 -8
- package/dist/extensions/tools/types.d.ts +11 -12
- package/dist/hooks/checkpoint-hooks.d.ts +9 -2
- package/dist/hooks/hook-extension.d.ts +2 -0
- package/dist/{extensions/config/hooks-config-loader.d.ts → hooks/hook-file-config.d.ts} +1 -2
- package/dist/hooks/hook-file-hooks.d.ts +2 -2
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/subprocess-runner.d.ts +0 -1
- package/dist/hooks/subprocess.d.ts +0 -1
- package/dist/hub/{connect.d.ts → client/connect.d.ts} +1 -2
- package/dist/hub/{client.d.ts → client/index.d.ts} +41 -4
- package/dist/hub/{session-client.d.ts → client/session-client.d.ts} +41 -13
- package/dist/hub/{ui-client.d.ts → client/ui-client.d.ts} +1 -1
- package/dist/hub/daemon/entry.d.ts +1 -0
- package/dist/hub/daemon/entry.js +720 -0
- package/dist/hub/{daemon.d.ts → daemon/index.d.ts} +6 -3
- package/dist/hub/{runtime-handlers.d.ts → daemon/runtime-handlers.d.ts} +3 -2
- package/dist/hub/{start-shared-server.d.ts → daemon/start-shared-server.d.ts} +1 -2
- package/dist/hub/{defaults.d.ts → discovery/defaults.d.ts} +0 -1
- package/dist/hub/{discovery.d.ts → discovery/index.d.ts} +2 -1
- package/dist/hub/{workspace.d.ts → discovery/workspace.d.ts} +1 -2
- package/dist/hub/index.d.ts +28 -11
- package/dist/hub/index.js +484 -1061
- package/dist/hub/runtime-host/hub-runtime-host.d.ts +73 -0
- package/dist/{transports/remote.d.ts → hub/runtime-host/remote-runtime-host.d.ts} +1 -2
- package/dist/hub/{browser-websocket.d.ts → server/browser-websocket.d.ts} +1 -2
- package/dist/hub/{transport.d.ts → server/command-transport.d.ts} +0 -1
- package/dist/hub/server/handlers/approval-handlers.d.ts +17 -0
- package/dist/hub/server/handlers/capability-handlers.d.ts +12 -0
- package/dist/hub/server/handlers/client-handlers.d.ts +6 -0
- package/dist/hub/server/handlers/context.d.ts +56 -0
- package/dist/hub/server/handlers/run-handlers.d.ts +5 -0
- package/dist/hub/server/handlers/session-event-projector.d.ts +7 -0
- package/dist/hub/server/handlers/session-handlers.d.ts +20 -0
- package/dist/hub/server/hub-client-contributions.d.ts +19 -0
- package/dist/hub/server/hub-notifications.d.ts +7 -0
- package/dist/hub/server/hub-schedule-events.d.ts +2 -0
- package/dist/hub/server/hub-server-logging.d.ts +2 -0
- package/dist/hub/server/hub-server-options.d.ts +55 -0
- package/dist/hub/server/hub-server-transport.d.ts +34 -0
- package/dist/hub/server/hub-session-records.d.ts +8 -0
- package/dist/hub/server/hub-websocket-server.d.ts +6 -0
- package/dist/hub/server/index.d.ts +4 -0
- package/dist/hub/{native-transport.d.ts → server/native-transport.d.ts} +1 -2
- package/dist/index.d.ts +51 -41
- package/dist/index.js +214 -872
- package/dist/runtime/capabilities/index.d.ts +2 -0
- package/dist/runtime/capabilities/normalize-runtime-capabilities.d.ts +2 -0
- package/dist/runtime/capabilities/runtime-capabilities.d.ts +6 -0
- package/dist/runtime/config/agent-message-codec.d.ts +6 -0
- package/dist/runtime/{agent-runtime-config-builder.d.ts → config/agent-runtime-config-builder.d.ts} +12 -21
- package/dist/runtime/host/history.d.ts +18 -0
- package/dist/runtime/{host.d.ts → host/host.d.ts} +3 -4
- package/dist/runtime/host/local/agent-event-bridge.d.ts +29 -0
- package/dist/runtime/host/local/session-record.d.ts +6 -0
- package/dist/runtime/host/local/session-service-invoker.d.ts +4 -0
- package/dist/runtime/host/local/spawn-tool.d.ts +15 -0
- package/dist/runtime/host/local/user-files.d.ts +1 -0
- package/dist/runtime/host/local-runtime-host.d.ts +118 -0
- package/dist/{transports → runtime/host}/runtime-host-support.d.ts +3 -5
- package/dist/runtime/{runtime-host.d.ts → host/runtime-host.d.ts} +66 -31
- package/dist/runtime/{runtime-builder.d.ts → orchestration/runtime-builder.d.ts} +0 -1
- package/dist/runtime/{runtime-event-adapter.d.ts → orchestration/runtime-event-adapter.d.ts} +0 -1
- package/dist/runtime/{runtime-oauth-token-manager.d.ts → orchestration/runtime-oauth-token-manager.d.ts} +1 -2
- package/dist/runtime/{session-runtime-orchestrator.d.ts → orchestration/session-runtime-orchestrator.d.ts} +20 -63
- package/dist/runtime/{session-runtime.d.ts → orchestration/session-runtime.d.ts} +14 -12
- package/dist/runtime/{user-input-builder.d.ts → orchestration/user-input-builder.d.ts} +2 -11
- package/dist/runtime/{loop-detection.d.ts → safety/loop-detection.d.ts} +0 -1
- package/dist/runtime/{mistake-tracker.d.ts → safety/mistake-tracker.d.ts} +0 -1
- package/dist/runtime/{rules.d.ts → safety/rules.d.ts} +1 -2
- package/dist/runtime/{subprocess-sandbox.d.ts → tools/subprocess-sandbox.d.ts} +15 -1
- package/dist/runtime/{tool-approval.d.ts → tools/tool-approval.d.ts} +0 -1
- package/dist/runtime/turn-queue/pending-prompt-service.d.ts +64 -0
- package/dist/services/agent-events.d.ts +1 -2
- package/dist/services/config.d.ts +0 -1
- package/dist/services/global-settings.d.ts +27 -5
- package/dist/{llms → services/llms}/cline-recommended-models.d.ts +1 -2
- package/dist/{llms → services/llms}/configured-provider-registry.d.ts +0 -1
- package/dist/services/llms/handler-factory.d.ts +3 -0
- package/dist/{llms → services/llms}/provider-defaults.d.ts +2 -1
- package/dist/{llms → services/llms}/provider-settings.d.ts +5 -3
- package/dist/{llms → services/llms}/runtime-config.d.ts +0 -1
- package/dist/{llms → services/llms}/runtime-registry.d.ts +0 -1
- package/dist/{llms → services/llms}/runtime-types.d.ts +0 -1
- package/dist/services/local-runtime-bootstrap.d.ts +7 -9
- package/dist/services/plugin-tools.d.ts +0 -1
- package/dist/services/providers/local-provider-registry.d.ts +9 -10
- package/dist/services/providers/local-provider-service.d.ts +36 -3
- package/dist/services/providers/model-source.d.ts +3 -0
- package/dist/services/session-artifacts.d.ts +0 -1
- package/dist/services/session-data.d.ts +2 -3
- package/dist/services/session-telemetry.d.ts +0 -1
- package/dist/services/storage/file-team-store.d.ts +0 -1
- package/dist/services/storage/provider-settings-legacy-migration.d.ts +0 -1
- package/dist/services/storage/provider-settings-manager.d.ts +3 -4
- package/dist/services/storage/sqlite-session-store.d.ts +0 -1
- package/dist/services/storage/sqlite-team-store.d.ts +0 -1
- package/dist/services/storage/team-store.d.ts +0 -1
- package/dist/services/telemetry/ITelemetryAdapter.d.ts +0 -1
- package/dist/services/telemetry/OpenTelemetryAdapter.d.ts +0 -1
- package/dist/services/telemetry/OpenTelemetryProvider.d.ts +32 -1
- package/dist/services/telemetry/TelemetryLoggerSink.d.ts +0 -1
- package/dist/services/telemetry/TelemetryService.d.ts +0 -1
- package/dist/services/telemetry/core-events.d.ts +46 -3
- package/dist/services/telemetry/distinct-id.d.ts +0 -1
- package/dist/services/telemetry/index.d.ts +1 -2
- package/dist/services/telemetry/index.js +1 -0
- package/dist/services/usage.d.ts +10 -2
- package/dist/services/workspace/file-indexer.d.ts +0 -1
- package/dist/services/workspace/index.d.ts +0 -1
- package/dist/services/workspace/mention-enricher.d.ts +0 -1
- package/dist/{session → services/workspace}/workspace-manager.d.ts +0 -1
- package/dist/services/{workspace-manifest.d.ts → workspace/workspace-manifest.d.ts} +20 -5
- package/dist/services/workspace/workspace-telemetry.d.ts +18 -0
- package/dist/session/checkpoint-restore.d.ts +20 -0
- package/dist/session/{session-graph.d.ts → models/session-graph.d.ts} +2 -3
- package/dist/session/{session-manifest.d.ts → models/session-manifest.d.ts} +0 -1
- package/dist/session/{session-row.d.ts → models/session-row.d.ts} +2 -3
- package/dist/session/{file-session-service.d.ts → services/file-session-service.d.ts} +1 -2
- package/dist/session/{message-builder.d.ts → services/message-builder.d.ts} +7 -16
- package/dist/session/{persistence-service.d.ts → services/persistence-service.d.ts} +10 -11
- package/dist/session/{session-service.d.ts → services/session-service.d.ts} +4 -5
- package/dist/session/session-snapshot.d.ts +57 -0
- package/dist/session/session-versioning-service.d.ts +48 -0
- package/dist/session/{conversation-store.d.ts → stores/conversation-store.d.ts} +0 -1
- package/dist/session/{session-manifest-store.d.ts → stores/session-manifest-store.d.ts} +3 -4
- package/dist/session/{team-persistence-store.d.ts → stores/team-persistence-store.d.ts} +2 -3
- package/dist/session/team/index.d.ts +2 -0
- package/dist/session/{subagent-session-manager.d.ts → team/team-child-session-manager.d.ts} +7 -8
- package/dist/session/{session-team-coordination.d.ts → team/team-session-coordinator.d.ts} +3 -4
- package/dist/settings/index.d.ts +2 -0
- package/dist/settings/settings-service.d.ts +6 -0
- package/dist/settings/types.d.ts +42 -0
- package/dist/types/chat-schema.d.ts +24 -7
- package/dist/types/common.d.ts +0 -1
- package/dist/types/config.d.ts +2 -3
- package/dist/types/events.d.ts +8 -1
- package/dist/types/provider-settings.d.ts +2 -3
- package/dist/types/session.d.ts +22 -6
- package/dist/types/sessions.d.ts +0 -1
- package/dist/types/storage.d.ts +0 -1
- package/dist/types.d.ts +17 -14
- package/dist/version.d.ts +0 -1
- package/package.json +16 -12
- package/dist/ClineCore.d.ts.map +0 -1
- package/dist/account/cline-account-service.d.ts.map +0 -1
- package/dist/account/index.d.ts.map +0 -1
- package/dist/account/rpc.d.ts.map +0 -1
- package/dist/account/types.d.ts.map +0 -1
- package/dist/auth/bounded-ttl-cache.d.ts.map +0 -1
- package/dist/auth/client.d.ts.map +0 -1
- package/dist/auth/cline.d.ts.map +0 -1
- package/dist/auth/codex.d.ts.map +0 -1
- package/dist/auth/oca.d.ts.map +0 -1
- package/dist/auth/server.d.ts.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/utils.d.ts.map +0 -1
- package/dist/cron/cron-event-ingress.d.ts.map +0 -1
- package/dist/cron/cron-materializer.d.ts.map +0 -1
- package/dist/cron/cron-reconciler.d.ts.map +0 -1
- package/dist/cron/cron-report-writer.d.ts.map +0 -1
- package/dist/cron/cron-runner.d.ts.map +0 -1
- package/dist/cron/cron-schema.d.ts.map +0 -1
- package/dist/cron/cron-service.d.ts.map +0 -1
- package/dist/cron/cron-spec-parser.d.ts.map +0 -1
- package/dist/cron/cron-watcher.d.ts.map +0 -1
- package/dist/cron/resource-limiter.d.ts.map +0 -1
- package/dist/cron/schedule-command-service.d.ts.map +0 -1
- package/dist/cron/schedule-service.d.ts.map +0 -1
- package/dist/cron/scheduler.d.ts +0 -68
- package/dist/cron/scheduler.d.ts.map +0 -1
- package/dist/cron/sqlite-cron-store.d.ts.map +0 -1
- package/dist/cron/sqlite-schedule-store.d.ts +0 -52
- package/dist/cron/sqlite-schedule-store.d.ts.map +0 -1
- package/dist/extensions/config/agent-config-loader.d.ts +0 -20
- package/dist/extensions/config/agent-config-loader.d.ts.map +0 -1
- package/dist/extensions/config/agent-config-parser.d.ts +0 -29
- package/dist/extensions/config/agent-config-parser.d.ts.map +0 -1
- package/dist/extensions/config/hooks-config-loader.d.ts.map +0 -1
- package/dist/extensions/config/index.d.ts.map +0 -1
- package/dist/extensions/config/runtime-commands.d.ts.map +0 -1
- package/dist/extensions/config/unified-config-file-watcher.d.ts.map +0 -1
- package/dist/extensions/config/user-instruction-config-loader.d.ts.map +0 -1
- package/dist/extensions/context/agentic-compaction.d.ts.map +0 -1
- package/dist/extensions/context/basic-compaction.d.ts.map +0 -1
- package/dist/extensions/context/compaction-shared.d.ts.map +0 -1
- package/dist/extensions/context/compaction.d.ts.map +0 -1
- package/dist/extensions/index.d.ts.map +0 -1
- package/dist/extensions/mcp/client.d.ts.map +0 -1
- package/dist/extensions/mcp/config-loader.d.ts.map +0 -1
- package/dist/extensions/mcp/index.d.ts.map +0 -1
- package/dist/extensions/mcp/manager.d.ts.map +0 -1
- package/dist/extensions/mcp/name-transform.d.ts.map +0 -1
- package/dist/extensions/mcp/policies.d.ts.map +0 -1
- package/dist/extensions/mcp/tools.d.ts.map +0 -1
- package/dist/extensions/mcp/types.d.ts.map +0 -1
- package/dist/extensions/plugin/plugin-config-loader.d.ts.map +0 -1
- package/dist/extensions/plugin/plugin-load-report.d.ts.map +0 -1
- package/dist/extensions/plugin/plugin-loader.d.ts.map +0 -1
- package/dist/extensions/plugin/plugin-module-import.d.ts.map +0 -1
- package/dist/extensions/plugin/plugin-sandbox.d.ts.map +0 -1
- package/dist/extensions/plugin/plugin-targeting.d.ts.map +0 -1
- package/dist/extensions/tools/constants.d.ts.map +0 -1
- package/dist/extensions/tools/definitions.d.ts.map +0 -1
- package/dist/extensions/tools/executors/apply-patch-parser.d.ts.map +0 -1
- package/dist/extensions/tools/executors/apply-patch.d.ts.map +0 -1
- package/dist/extensions/tools/executors/bash.d.ts.map +0 -1
- package/dist/extensions/tools/executors/editor.d.ts.map +0 -1
- package/dist/extensions/tools/executors/file-read.d.ts.map +0 -1
- package/dist/extensions/tools/executors/index.d.ts.map +0 -1
- package/dist/extensions/tools/executors/search.d.ts.map +0 -1
- package/dist/extensions/tools/executors/web-fetch.d.ts.map +0 -1
- package/dist/extensions/tools/helpers.d.ts.map +0 -1
- package/dist/extensions/tools/index.d.ts.map +0 -1
- package/dist/extensions/tools/model-tool-routing.d.ts.map +0 -1
- package/dist/extensions/tools/presets.d.ts.map +0 -1
- package/dist/extensions/tools/runtime.d.ts.map +0 -1
- package/dist/extensions/tools/schemas.d.ts.map +0 -1
- package/dist/extensions/tools/team/delegated-agent.d.ts.map +0 -1
- package/dist/extensions/tools/team/index.d.ts.map +0 -1
- package/dist/extensions/tools/team/multi-agent.d.ts.map +0 -1
- package/dist/extensions/tools/team/projections.d.ts.map +0 -1
- package/dist/extensions/tools/team/runtime.d.ts.map +0 -1
- package/dist/extensions/tools/team/spawn-agent-tool.d.ts.map +0 -1
- package/dist/extensions/tools/team/subagent-prompts.d.ts.map +0 -1
- package/dist/extensions/tools/team/team-tools.d.ts.map +0 -1
- package/dist/extensions/tools/types.d.ts.map +0 -1
- package/dist/hooks/checkpoint-hooks.d.ts.map +0 -1
- package/dist/hooks/hook-bridge.d.ts +0 -118
- package/dist/hooks/hook-bridge.d.ts.map +0 -1
- package/dist/hooks/hook-file-hooks.d.ts.map +0 -1
- package/dist/hooks/hook-registry.d.ts +0 -16
- package/dist/hooks/hook-registry.d.ts.map +0 -1
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/subprocess-runner.d.ts.map +0 -1
- package/dist/hooks/subprocess.d.ts.map +0 -1
- package/dist/hub/browser-websocket.d.ts.map +0 -1
- package/dist/hub/client.d.ts.map +0 -1
- package/dist/hub/connect.d.ts.map +0 -1
- package/dist/hub/daemon-entry.d.ts +0 -2
- package/dist/hub/daemon-entry.d.ts.map +0 -1
- package/dist/hub/daemon-entry.js +0 -1305
- package/dist/hub/daemon.d.ts.map +0 -1
- package/dist/hub/defaults.d.ts.map +0 -1
- package/dist/hub/discovery.d.ts.map +0 -1
- package/dist/hub/index.d.ts.map +0 -1
- package/dist/hub/native-transport.d.ts.map +0 -1
- package/dist/hub/runtime-handlers.d.ts.map +0 -1
- package/dist/hub/server.d.ts +0 -104
- package/dist/hub/server.d.ts.map +0 -1
- package/dist/hub/session-client.d.ts.map +0 -1
- package/dist/hub/start-shared-server.d.ts.map +0 -1
- package/dist/hub/transport.d.ts.map +0 -1
- package/dist/hub/ui-client.d.ts.map +0 -1
- package/dist/hub/workspace.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/llms/cline-recommended-models.d.ts.map +0 -1
- package/dist/llms/configured-provider-registry.d.ts.map +0 -1
- package/dist/llms/handler-factory.d.ts +0 -16
- package/dist/llms/handler-factory.d.ts.map +0 -1
- package/dist/llms/provider-defaults.d.ts.map +0 -1
- package/dist/llms/provider-settings.d.ts.map +0 -1
- package/dist/llms/runtime-config.d.ts.map +0 -1
- package/dist/llms/runtime-registry.d.ts.map +0 -1
- package/dist/llms/runtime-types.d.ts.map +0 -1
- package/dist/runtime/agent-config-adapter.d.ts +0 -148
- package/dist/runtime/agent-config-adapter.d.ts.map +0 -1
- package/dist/runtime/agent-runtime-config-builder.d.ts.map +0 -1
- package/dist/runtime/history.d.ts +0 -10
- package/dist/runtime/history.d.ts.map +0 -1
- package/dist/runtime/host.d.ts.map +0 -1
- package/dist/runtime/loop-detection.d.ts.map +0 -1
- package/dist/runtime/mistake-tracker.d.ts.map +0 -1
- package/dist/runtime/rules.d.ts.map +0 -1
- package/dist/runtime/runtime-builder.d.ts.map +0 -1
- package/dist/runtime/runtime-event-adapter.d.ts.map +0 -1
- package/dist/runtime/runtime-host.d.ts.map +0 -1
- package/dist/runtime/runtime-oauth-token-manager.d.ts.map +0 -1
- package/dist/runtime/session-runtime-orchestrator.d.ts.map +0 -1
- package/dist/runtime/session-runtime.d.ts.map +0 -1
- package/dist/runtime/subprocess-sandbox.d.ts.map +0 -1
- package/dist/runtime/tool-approval.d.ts.map +0 -1
- package/dist/runtime/user-input-builder.d.ts.map +0 -1
- package/dist/services/agent-events.d.ts.map +0 -1
- package/dist/services/config.d.ts.map +0 -1
- package/dist/services/global-settings.d.ts.map +0 -1
- package/dist/services/index.js +0 -28
- package/dist/services/local-runtime-bootstrap.d.ts.map +0 -1
- package/dist/services/plugin-tools.d.ts.map +0 -1
- package/dist/services/providers/local-provider-registry.d.ts.map +0 -1
- package/dist/services/providers/local-provider-service.d.ts.map +0 -1
- package/dist/services/session-artifacts.d.ts.map +0 -1
- package/dist/services/session-data.d.ts.map +0 -1
- package/dist/services/session-telemetry.d.ts.map +0 -1
- package/dist/services/storage/file-team-store.d.ts.map +0 -1
- package/dist/services/storage/provider-settings-legacy-migration.d.ts.map +0 -1
- package/dist/services/storage/provider-settings-manager.d.ts.map +0 -1
- package/dist/services/storage/sqlite-session-store.d.ts.map +0 -1
- package/dist/services/storage/sqlite-team-store.d.ts.map +0 -1
- package/dist/services/storage/team-store.d.ts.map +0 -1
- package/dist/services/telemetry/ITelemetryAdapter.d.ts.map +0 -1
- package/dist/services/telemetry/OpenTelemetryAdapter.d.ts.map +0 -1
- package/dist/services/telemetry/OpenTelemetryProvider.d.ts.map +0 -1
- package/dist/services/telemetry/TelemetryLoggerSink.d.ts.map +0 -1
- package/dist/services/telemetry/TelemetryService.d.ts.map +0 -1
- package/dist/services/telemetry/core-events.d.ts.map +0 -1
- package/dist/services/telemetry/distinct-id.d.ts.map +0 -1
- package/dist/services/telemetry/index.d.ts.map +0 -1
- package/dist/services/usage.d.ts.map +0 -1
- package/dist/services/workspace/file-indexer.d.ts.map +0 -1
- package/dist/services/workspace/index.d.ts.map +0 -1
- package/dist/services/workspace/mention-enricher.d.ts.map +0 -1
- package/dist/services/workspace-manifest.d.ts.map +0 -1
- package/dist/session/conversation-store.d.ts.map +0 -1
- package/dist/session/file-session-service.d.ts.map +0 -1
- package/dist/session/message-builder.d.ts.map +0 -1
- package/dist/session/persistence-service.d.ts.map +0 -1
- package/dist/session/session-graph.d.ts.map +0 -1
- package/dist/session/session-manifest-store.d.ts.map +0 -1
- package/dist/session/session-manifest.d.ts.map +0 -1
- package/dist/session/session-row.d.ts.map +0 -1
- package/dist/session/session-service.d.ts.map +0 -1
- package/dist/session/session-team-coordination.d.ts.map +0 -1
- package/dist/session/subagent-session-manager.d.ts.map +0 -1
- package/dist/session/team-persistence-store.d.ts.map +0 -1
- package/dist/session/workspace-manager.d.ts.map +0 -1
- package/dist/transports/hub.d.ts +0 -58
- package/dist/transports/hub.d.ts.map +0 -1
- package/dist/transports/local.d.ts +0 -119
- package/dist/transports/local.d.ts.map +0 -1
- package/dist/transports/remote.d.ts.map +0 -1
- package/dist/transports/runtime-host-support.d.ts.map +0 -1
- package/dist/types/chat-schema.d.ts.map +0 -1
- package/dist/types/common.d.ts.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/events.d.ts.map +0 -1
- package/dist/types/provider-settings.d.ts.map +0 -1
- package/dist/types/session.d.ts.map +0 -1
- package/dist/types/sessions.d.ts.map +0 -1
- package/dist/types/storage.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/src/ClineCore.ts +0 -1026
- package/src/account/cline-account-service.ts +0 -338
- package/src/account/index.ts +0 -24
- package/src/account/rpc.ts +0 -185
- package/src/account/types.ts +0 -108
- package/src/auth/bounded-ttl-cache.ts +0 -53
- package/src/auth/client.ts +0 -46
- package/src/auth/cline.ts +0 -724
- package/src/auth/codex.ts +0 -491
- package/src/auth/oca.ts +0 -588
- package/src/auth/server.ts +0 -265
- package/src/auth/types.ts +0 -110
- package/src/auth/utils.ts +0 -247
- package/src/cron/cron-event-ingress.ts +0 -357
- package/src/cron/cron-materializer.ts +0 -97
- package/src/cron/cron-reconciler.ts +0 -241
- package/src/cron/cron-report-writer.ts +0 -153
- package/src/cron/cron-runner.ts +0 -495
- package/src/cron/cron-schema.ts +0 -127
- package/src/cron/cron-service.ts +0 -163
- package/src/cron/cron-spec-parser.ts +0 -489
- package/src/cron/cron-watcher.ts +0 -102
- package/src/cron/index.ts +0 -15
- package/src/cron/resource-limiter.ts +0 -46
- package/src/cron/schedule-command-service.ts +0 -193
- package/src/cron/schedule-service.ts +0 -703
- package/src/cron/scheduler.ts +0 -772
- package/src/cron/sqlite-cron-store.ts +0 -1286
- package/src/cron/sqlite-schedule-store.ts +0 -708
- package/src/extensions/config/agent-config-loader.ts +0 -114
- package/src/extensions/config/agent-config-parser.ts +0 -198
- package/src/extensions/config/hooks-config-loader.ts +0 -117
- package/src/extensions/config/index.ts +0 -77
- package/src/extensions/config/runtime-commands.ts +0 -82
- package/src/extensions/config/unified-config-file-watcher.ts +0 -496
- package/src/extensions/config/user-instruction-config-loader.ts +0 -549
- package/src/extensions/context/agentic-compaction.ts +0 -131
- package/src/extensions/context/basic-compaction.ts +0 -300
- package/src/extensions/context/compaction-shared.ts +0 -459
- package/src/extensions/context/compaction.ts +0 -226
- package/src/extensions/index.ts +0 -18
- package/src/extensions/mcp/client.ts +0 -420
- package/src/extensions/mcp/config-loader.ts +0 -219
- package/src/extensions/mcp/index.ts +0 -42
- package/src/extensions/mcp/manager.ts +0 -260
- package/src/extensions/mcp/name-transform.ts +0 -33
- package/src/extensions/mcp/policies.ts +0 -47
- package/src/extensions/mcp/tools.ts +0 -47
- package/src/extensions/mcp/types.ts +0 -116
- package/src/extensions/plugin/plugin-config-loader.ts +0 -140
- package/src/extensions/plugin/plugin-load-report.ts +0 -20
- package/src/extensions/plugin/plugin-loader.ts +0 -220
- package/src/extensions/plugin/plugin-module-import.ts +0 -276
- package/src/extensions/plugin/plugin-sandbox-bootstrap.ts +0 -662
- package/src/extensions/plugin/plugin-sandbox.ts +0 -586
- package/src/extensions/plugin/plugin-targeting.ts +0 -32
- package/src/extensions/tools/constants.ts +0 -37
- package/src/extensions/tools/definitions.ts +0 -738
- package/src/extensions/tools/executors/apply-patch-parser.ts +0 -520
- package/src/extensions/tools/executors/apply-patch.ts +0 -348
- package/src/extensions/tools/executors/bash.ts +0 -207
- package/src/extensions/tools/executors/editor.ts +0 -220
- package/src/extensions/tools/executors/file-read.ts +0 -135
- package/src/extensions/tools/executors/index.ts +0 -87
- package/src/extensions/tools/executors/search.ts +0 -470
- package/src/extensions/tools/executors/web-fetch.ts +0 -259
- package/src/extensions/tools/helpers.ts +0 -154
- package/src/extensions/tools/index.ts +0 -183
- package/src/extensions/tools/model-tool-routing.ts +0 -134
- package/src/extensions/tools/presets.ts +0 -190
- package/src/extensions/tools/runtime.ts +0 -261
- package/src/extensions/tools/schemas.ts +0 -343
- package/src/extensions/tools/team/delegated-agent.ts +0 -136
- package/src/extensions/tools/team/index.ts +0 -5
- package/src/extensions/tools/team/multi-agent.ts +0 -1845
- package/src/extensions/tools/team/projections.ts +0 -283
- package/src/extensions/tools/team/runtime.ts +0 -54
- package/src/extensions/tools/team/spawn-agent-tool.ts +0 -201
- package/src/extensions/tools/team/subagent-prompts.ts +0 -41
- package/src/extensions/tools/team/team-tools.ts +0 -902
- package/src/extensions/tools/types.ts +0 -354
- package/src/hooks/checkpoint-hooks.ts +0 -238
- package/src/hooks/hook-bridge.ts +0 -489
- package/src/hooks/hook-file-hooks.ts +0 -934
- package/src/hooks/hook-registry.ts +0 -257
- package/src/hooks/index.ts +0 -18
- package/src/hooks/subprocess-runner.ts +0 -196
- package/src/hooks/subprocess.ts +0 -469
- package/src/hub/browser-websocket.ts +0 -159
- package/src/hub/client.ts +0 -633
- package/src/hub/connect.ts +0 -156
- package/src/hub/daemon-entry.ts +0 -122
- package/src/hub/daemon.ts +0 -284
- package/src/hub/defaults.ts +0 -70
- package/src/hub/discovery.ts +0 -247
- package/src/hub/index.ts +0 -14
- package/src/hub/native-transport.ts +0 -31
- package/src/hub/runtime-handlers.ts +0 -141
- package/src/hub/server.ts +0 -2317
- package/src/hub/session-client.ts +0 -502
- package/src/hub/start-shared-server.ts +0 -61
- package/src/hub/transport.ts +0 -14
- package/src/hub/ui-client.ts +0 -126
- package/src/hub/workspace.ts +0 -19
- package/src/index.ts +0 -688
- package/src/llms/cline-recommended-models.ts +0 -167
- package/src/llms/configured-provider-registry.ts +0 -193
- package/src/llms/handler-factory.ts +0 -56
- package/src/llms/provider-defaults.ts +0 -653
- package/src/llms/provider-settings.ts +0 -310
- package/src/llms/runtime-config.ts +0 -43
- package/src/llms/runtime-registry.ts +0 -172
- package/src/llms/runtime-types.ts +0 -121
- package/src/runtime/agent-config-adapter.ts +0 -636
- package/src/runtime/agent-runtime-config-builder.ts +0 -205
- package/src/runtime/error-feedback.ts +0 -142
- package/src/runtime/history.ts +0 -374
- package/src/runtime/host.ts +0 -222
- package/src/runtime/index.ts +0 -23
- package/src/runtime/loop-detection.ts +0 -162
- package/src/runtime/mistake-tracker.ts +0 -221
- package/src/runtime/rules.ts +0 -49
- package/src/runtime/runtime-builder.ts +0 -814
- package/src/runtime/runtime-event-adapter.ts +0 -412
- package/src/runtime/runtime-host.ts +0 -250
- package/src/runtime/runtime-oauth-token-manager.ts +0 -268
- package/src/runtime/session-runtime-orchestrator.ts +0 -1253
- package/src/runtime/session-runtime.ts +0 -69
- package/src/runtime/subprocess-sandbox.ts +0 -255
- package/src/runtime/tool-approval.ts +0 -102
- package/src/runtime/user-input-builder.ts +0 -167
- package/src/services/agent-events.ts +0 -256
- package/src/services/config.ts +0 -5
- package/src/services/global-settings.ts +0 -122
- package/src/services/local-runtime-bootstrap.ts +0 -424
- package/src/services/plugin-tools.ts +0 -86
- package/src/services/providers/local-provider-registry.ts +0 -456
- package/src/services/providers/local-provider-service.ts +0 -772
- package/src/services/session-artifacts.ts +0 -138
- package/src/services/session-data.ts +0 -398
- package/src/services/session-telemetry.ts +0 -89
- package/src/services/storage/artifact-store.ts +0 -1
- package/src/services/storage/file-team-store.ts +0 -250
- package/src/services/storage/index.ts +0 -11
- package/src/services/storage/provider-settings-legacy-migration.ts +0 -789
- package/src/services/storage/provider-settings-manager.ts +0 -167
- package/src/services/storage/session-store.ts +0 -1
- package/src/services/storage/sqlite-session-store.ts +0 -270
- package/src/services/storage/sqlite-team-store.ts +0 -537
- package/src/services/storage/team-store.ts +0 -36
- package/src/services/telemetry/ITelemetryAdapter.ts +0 -94
- package/src/services/telemetry/OpenTelemetryAdapter.ts +0 -348
- package/src/services/telemetry/OpenTelemetryProvider.ts +0 -415
- package/src/services/telemetry/TelemetryLoggerSink.ts +0 -121
- package/src/services/telemetry/TelemetryService.ts +0 -139
- package/src/services/telemetry/core-events.ts +0 -400
- package/src/services/telemetry/distinct-id.ts +0 -58
- package/src/services/telemetry/index.ts +0 -20
- package/src/services/usage.ts +0 -32
- package/src/services/workspace/file-indexer.ts +0 -351
- package/src/services/workspace/index.ts +0 -7
- package/src/services/workspace/mention-enricher.ts +0 -122
- package/src/services/workspace-manifest.ts +0 -72
- package/src/session/conversation-store.ts +0 -77
- package/src/session/file-session-service.ts +0 -282
- package/src/session/index.ts +0 -32
- package/src/session/message-builder.ts +0 -941
- package/src/session/persistence-service.ts +0 -559
- package/src/session/session-graph.ts +0 -92
- package/src/session/session-manifest-store.ts +0 -158
- package/src/session/session-manifest.ts +0 -29
- package/src/session/session-row.ts +0 -199
- package/src/session/session-service.ts +0 -324
- package/src/session/session-team-coordination.ts +0 -240
- package/src/session/subagent-session-manager.ts +0 -397
- package/src/session/team-persistence-store.ts +0 -176
- package/src/session/workspace-manager.ts +0 -100
- package/src/transports/hub.ts +0 -1081
- package/src/transports/local.ts +0 -1826
- package/src/transports/remote.ts +0 -27
- package/src/transports/runtime-host-support.ts +0 -140
- package/src/types/chat-schema.ts +0 -81
- package/src/types/common.ts +0 -26
- package/src/types/config.ts +0 -220
- package/src/types/events.ts +0 -80
- package/src/types/index.ts +0 -26
- package/src/types/provider-settings.ts +0 -54
- package/src/types/session.ts +0 -111
- package/src/types/sessions.ts +0 -37
- package/src/types/storage.ts +0 -56
- package/src/types.ts +0 -167
- package/src/version.ts +0 -3
|
@@ -1,902 +0,0 @@
|
|
|
1
|
-
import type { AgentResult } from "@clinebot/shared";
|
|
2
|
-
import {
|
|
3
|
-
createTool,
|
|
4
|
-
TEAM_AWAIT_TIMEOUT_MS,
|
|
5
|
-
TEAM_RUN_MESSAGE_PREVIEW_LIMIT,
|
|
6
|
-
TEAM_RUN_TEXT_PREVIEW_LIMIT,
|
|
7
|
-
TEAM_TASK_IGNORED_FIELDS_BY_ACTION,
|
|
8
|
-
type TeamAttachOutcomeFragmentInput,
|
|
9
|
-
TeamAttachOutcomeFragmentInputSchema,
|
|
10
|
-
type TeamAwaitRunsInput,
|
|
11
|
-
TeamAwaitRunsInputSchema,
|
|
12
|
-
type TeamBroadcastInput,
|
|
13
|
-
TeamBroadcastInputSchema,
|
|
14
|
-
TeamBroadcastToolResultSchema,
|
|
15
|
-
type TeamCancelRunInput,
|
|
16
|
-
TeamCancelRunInputSchema,
|
|
17
|
-
TeamCancelRunToolResultSchema,
|
|
18
|
-
type TeamCleanupInput,
|
|
19
|
-
TeamCleanupInputSchema,
|
|
20
|
-
TeamCleanupToolResultSchema,
|
|
21
|
-
type TeamCreateOutcomeInput,
|
|
22
|
-
TeamCreateOutcomeInputSchema,
|
|
23
|
-
type TeamCreateOutcomeToolResult,
|
|
24
|
-
TeamCreateOutcomeToolResultSchema,
|
|
25
|
-
type TeamFinalizeOutcomeInput,
|
|
26
|
-
TeamFinalizeOutcomeInputSchema,
|
|
27
|
-
TeamFinalizeOutcomeToolResultSchema,
|
|
28
|
-
type TeamListOutcomesInput,
|
|
29
|
-
TeamListOutcomesInputSchema,
|
|
30
|
-
type TeamListRunsInput,
|
|
31
|
-
TeamListRunsInputSchema,
|
|
32
|
-
type TeamMailboxMessageToolResult,
|
|
33
|
-
TeamMailboxMessageToolResultSchema,
|
|
34
|
-
type TeamMissionLogInput,
|
|
35
|
-
TeamMissionLogInputSchema,
|
|
36
|
-
TeamMissionLogToolResultSchema,
|
|
37
|
-
TeamOutcomeFragmentToolResultSchema,
|
|
38
|
-
type TeamOutcomeToolResult,
|
|
39
|
-
TeamOutcomeToolResultSchema,
|
|
40
|
-
type TeamReadMailboxInput,
|
|
41
|
-
TeamReadMailboxInputSchema,
|
|
42
|
-
type TeamReviewOutcomeFragmentInput,
|
|
43
|
-
TeamReviewOutcomeFragmentInputSchema,
|
|
44
|
-
type TeamRunRecord,
|
|
45
|
-
type TeamRunResultSummary,
|
|
46
|
-
type TeamRunTaskInput,
|
|
47
|
-
TeamRunTaskInputSchema,
|
|
48
|
-
type TeamRunTaskToolResult,
|
|
49
|
-
TeamRunTaskToolResultSchema,
|
|
50
|
-
type TeamRunToolSummary,
|
|
51
|
-
TeamRunToolSummarySchema,
|
|
52
|
-
type TeamRuntimeState,
|
|
53
|
-
type TeamSendMessageInput,
|
|
54
|
-
TeamSendMessageInputSchema,
|
|
55
|
-
TeamSendMessageToolResultSchema,
|
|
56
|
-
type TeamShutdownTeammateInput,
|
|
57
|
-
TeamShutdownTeammateInputSchema,
|
|
58
|
-
TeamSimpleAgentStatusToolResultSchema,
|
|
59
|
-
type TeamSpawnTeammateInput,
|
|
60
|
-
TeamSpawnTeammateInputSchema,
|
|
61
|
-
type TeamStatusInput,
|
|
62
|
-
TeamStatusInputSchema,
|
|
63
|
-
type TeamStatusToolResult,
|
|
64
|
-
TeamStatusToolResultSchema,
|
|
65
|
-
type TeamTaskInput,
|
|
66
|
-
TeamTaskInputSchema,
|
|
67
|
-
type TeamTaskToolResult,
|
|
68
|
-
TeamTaskToolResultSchema,
|
|
69
|
-
type TeamTeammateSpec,
|
|
70
|
-
type Tool,
|
|
71
|
-
validateWithZod,
|
|
72
|
-
zodToJsonSchema,
|
|
73
|
-
} from "@clinebot/shared";
|
|
74
|
-
import {
|
|
75
|
-
buildDelegatedAgentConfig,
|
|
76
|
-
type DelegatedAgentConfigProvider,
|
|
77
|
-
type DelegatedAgentRuntimeConfig,
|
|
78
|
-
} from "./delegated-agent";
|
|
79
|
-
import type { AgentTeamsRuntime } from "./multi-agent";
|
|
80
|
-
|
|
81
|
-
function truncateText(value: string, maxLength: number): string {
|
|
82
|
-
const normalized = value.replace(/\s+/g, " ").trim();
|
|
83
|
-
if (normalized.length <= maxLength) {
|
|
84
|
-
return normalized;
|
|
85
|
-
}
|
|
86
|
-
return `${normalized.slice(0, Math.max(0, maxLength - 3)).trimEnd()}...`;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function summarizeRunResult(
|
|
90
|
-
run: TeamRunRecord,
|
|
91
|
-
): TeamRunResultSummary | undefined {
|
|
92
|
-
const result = run.result as AgentResult | undefined;
|
|
93
|
-
if (!result) {
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
textPreview: truncateText(result.text, TEAM_RUN_TEXT_PREVIEW_LIMIT),
|
|
98
|
-
iterations: result.iterations,
|
|
99
|
-
finishReason: result.finishReason,
|
|
100
|
-
durationMs: result.durationMs,
|
|
101
|
-
usage: {
|
|
102
|
-
inputTokens: result.usage.inputTokens,
|
|
103
|
-
outputTokens: result.usage.outputTokens,
|
|
104
|
-
cacheReadTokens: result.usage.cacheReadTokens,
|
|
105
|
-
cacheWriteTokens: result.usage.cacheWriteTokens,
|
|
106
|
-
totalCost: result.usage.totalCost,
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function dateToIso(value: Date | undefined): string | undefined {
|
|
112
|
-
return value?.toISOString();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function summarizeRun(run: TeamRunRecord): TeamRunToolSummary {
|
|
116
|
-
return {
|
|
117
|
-
id: run.id,
|
|
118
|
-
agentId: run.agentId,
|
|
119
|
-
taskId: run.taskId,
|
|
120
|
-
status: run.status,
|
|
121
|
-
messagePreview: truncateText(run.message, TEAM_RUN_MESSAGE_PREVIEW_LIMIT),
|
|
122
|
-
priority: run.priority,
|
|
123
|
-
retryCount: run.retryCount,
|
|
124
|
-
maxRetries: run.maxRetries,
|
|
125
|
-
nextAttemptAt: dateToIso(run.nextAttemptAt),
|
|
126
|
-
continueConversation: run.continueConversation,
|
|
127
|
-
startedAt: run.startedAt.toISOString(),
|
|
128
|
-
endedAt: dateToIso(run.endedAt),
|
|
129
|
-
leaseOwner: run.leaseOwner,
|
|
130
|
-
heartbeatAt: dateToIso(run.heartbeatAt),
|
|
131
|
-
lastProgressAt: dateToIso(run.lastProgressAt),
|
|
132
|
-
lastProgressMessage: run.lastProgressMessage,
|
|
133
|
-
currentActivity: run.currentActivity,
|
|
134
|
-
error: run.error,
|
|
135
|
-
resultSummary: summarizeRunResult(run),
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function assertAwaitedRunSucceeded(run: TeamRunRecord): void {
|
|
140
|
-
if (run.status === "failed") {
|
|
141
|
-
throw new Error(
|
|
142
|
-
`Run "${run.id}" failed${run.error ? `: ${run.error}` : ""}`,
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
if (run.status === "cancelled") {
|
|
146
|
-
throw new Error(
|
|
147
|
-
`Run "${run.id}" was cancelled${run.error ? `: ${run.error}` : ""}`,
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
if (run.status === "interrupted") {
|
|
151
|
-
throw new Error(
|
|
152
|
-
`Run "${run.id}" was interrupted${run.error ? `: ${run.error}` : ""}`,
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export type TeamTeammateRuntimeConfig = DelegatedAgentRuntimeConfig;
|
|
158
|
-
|
|
159
|
-
export interface CreateAgentTeamsToolsOptions {
|
|
160
|
-
runtime: AgentTeamsRuntime;
|
|
161
|
-
requesterId: string;
|
|
162
|
-
teammateConfigProvider: DelegatedAgentConfigProvider;
|
|
163
|
-
createBaseTools?: () => Tool[];
|
|
164
|
-
allowSpawn?: boolean;
|
|
165
|
-
includeSpawnTool?: boolean;
|
|
166
|
-
includeManagementTools?: boolean;
|
|
167
|
-
onLeadToolsUnlocked?: (tools: Tool[]) => void;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export interface BootstrapAgentTeamsOptions {
|
|
171
|
-
runtime: AgentTeamsRuntime;
|
|
172
|
-
teammateConfigProvider: DelegatedAgentConfigProvider;
|
|
173
|
-
createBaseTools?: () => Tool[];
|
|
174
|
-
leadAgentId?: string;
|
|
175
|
-
restoredTeammates?: TeamTeammateSpec[];
|
|
176
|
-
restoredFromPersistence?: boolean;
|
|
177
|
-
includeLeadSpawnTool?: boolean;
|
|
178
|
-
includeLeadManagementTools?: boolean;
|
|
179
|
-
onLeadToolsUnlocked?: (tools: Tool[]) => void;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export interface BootstrapAgentTeamsResult {
|
|
183
|
-
tools: Tool[];
|
|
184
|
-
restoredFromPersistence: boolean;
|
|
185
|
-
restoredTeammates: string[];
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export const TEAM_TOOL_NAMES = [
|
|
189
|
-
"team_spawn_teammate",
|
|
190
|
-
"team_shutdown_teammate",
|
|
191
|
-
"team_status",
|
|
192
|
-
"team_task",
|
|
193
|
-
"team_run_task",
|
|
194
|
-
"team_cancel_run",
|
|
195
|
-
"team_list_runs",
|
|
196
|
-
"team_await_runs",
|
|
197
|
-
"team_send_message",
|
|
198
|
-
"team_broadcast",
|
|
199
|
-
"team_read_mailbox",
|
|
200
|
-
"team_mission_log",
|
|
201
|
-
"team_cleanup",
|
|
202
|
-
"team_create_outcome",
|
|
203
|
-
"team_attach_outcome_fragment",
|
|
204
|
-
"team_review_outcome_fragment",
|
|
205
|
-
"team_finalize_outcome",
|
|
206
|
-
"team_list_outcomes",
|
|
207
|
-
] as const;
|
|
208
|
-
|
|
209
|
-
function spawnTeamTeammate(
|
|
210
|
-
options: Omit<CreateAgentTeamsToolsOptions, "requesterId" | "allowSpawn"> & {
|
|
211
|
-
requesterId: string;
|
|
212
|
-
spec: TeamTeammateSpec;
|
|
213
|
-
},
|
|
214
|
-
): void {
|
|
215
|
-
const teammateTools: Tool[] = [];
|
|
216
|
-
if (options.createBaseTools) {
|
|
217
|
-
teammateTools.push(...options.createBaseTools());
|
|
218
|
-
}
|
|
219
|
-
teammateTools.push(
|
|
220
|
-
...createAgentTeamsTools({
|
|
221
|
-
runtime: options.runtime,
|
|
222
|
-
requesterId: options.spec.agentId,
|
|
223
|
-
teammateConfigProvider: options.teammateConfigProvider,
|
|
224
|
-
createBaseTools: options.createBaseTools,
|
|
225
|
-
allowSpawn: false,
|
|
226
|
-
}),
|
|
227
|
-
);
|
|
228
|
-
options.runtime.spawnTeammate({
|
|
229
|
-
agentId: options.spec.agentId,
|
|
230
|
-
config: buildDelegatedAgentConfig({
|
|
231
|
-
kind: "teammate",
|
|
232
|
-
prompt: options.spec.rolePrompt,
|
|
233
|
-
role: options.spec.rolePrompt,
|
|
234
|
-
configProvider: options.teammateConfigProvider,
|
|
235
|
-
tools: teammateTools,
|
|
236
|
-
maxIterations: options.spec.maxIterations,
|
|
237
|
-
cwd: options.teammateConfigProvider.getRuntimeConfig().cwd,
|
|
238
|
-
}),
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export function bootstrapAgentTeams(
|
|
243
|
-
options: BootstrapAgentTeamsOptions,
|
|
244
|
-
): BootstrapAgentTeamsResult {
|
|
245
|
-
const leadAgentId = options.leadAgentId ?? "lead";
|
|
246
|
-
const restoredFromPersistence = options.restoredFromPersistence === true;
|
|
247
|
-
|
|
248
|
-
const tools = createAgentTeamsTools({
|
|
249
|
-
runtime: options.runtime,
|
|
250
|
-
requesterId: leadAgentId,
|
|
251
|
-
teammateConfigProvider: options.teammateConfigProvider,
|
|
252
|
-
createBaseTools: options.createBaseTools,
|
|
253
|
-
allowSpawn: true,
|
|
254
|
-
includeSpawnTool: options.includeLeadSpawnTool,
|
|
255
|
-
includeManagementTools: options.includeLeadManagementTools,
|
|
256
|
-
onLeadToolsUnlocked: options.onLeadToolsUnlocked,
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
const restoredTeammates: string[] = [];
|
|
260
|
-
for (const spec of options.restoredTeammates ?? []) {
|
|
261
|
-
if (options.runtime.isTeammateActive(spec.agentId)) {
|
|
262
|
-
continue;
|
|
263
|
-
}
|
|
264
|
-
spawnTeamTeammate({
|
|
265
|
-
runtime: options.runtime,
|
|
266
|
-
requesterId: leadAgentId,
|
|
267
|
-
teammateConfigProvider: options.teammateConfigProvider,
|
|
268
|
-
createBaseTools: options.createBaseTools,
|
|
269
|
-
spec,
|
|
270
|
-
});
|
|
271
|
-
restoredTeammates.push(spec.agentId);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return {
|
|
275
|
-
tools,
|
|
276
|
-
restoredFromPersistence,
|
|
277
|
-
restoredTeammates,
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
export function createAgentTeamsTools(
|
|
282
|
-
options: CreateAgentTeamsToolsOptions,
|
|
283
|
-
): Tool[] {
|
|
284
|
-
const allowSpawn = options.allowSpawn ?? true;
|
|
285
|
-
const includeSpawnTool = options.includeSpawnTool ?? true;
|
|
286
|
-
const includeManagementTools = options.includeManagementTools ?? true;
|
|
287
|
-
const tools: Tool[] = [];
|
|
288
|
-
|
|
289
|
-
if (includeSpawnTool) {
|
|
290
|
-
tools.push(
|
|
291
|
-
createTool<TeamSpawnTeammateInput, { agentId: string; status: string }>({
|
|
292
|
-
name: "team_spawn_teammate",
|
|
293
|
-
description: "Spawn a teammate with a required agentId and rolePrompt.",
|
|
294
|
-
inputSchema: zodToJsonSchema(TeamSpawnTeammateInputSchema),
|
|
295
|
-
execute: async (input) => {
|
|
296
|
-
const validatedInput = validateWithZod(
|
|
297
|
-
TeamSpawnTeammateInputSchema,
|
|
298
|
-
input,
|
|
299
|
-
);
|
|
300
|
-
if (options.runtime.getMemberRole(options.requesterId) !== "lead") {
|
|
301
|
-
throw new Error("Only the lead agent can manage teammates.");
|
|
302
|
-
}
|
|
303
|
-
if (!allowSpawn) {
|
|
304
|
-
throw new Error("Spawning teammates is disabled in this context.");
|
|
305
|
-
}
|
|
306
|
-
const spec: TeamTeammateSpec = {
|
|
307
|
-
agentId: validatedInput.agentId,
|
|
308
|
-
rolePrompt: validatedInput.rolePrompt,
|
|
309
|
-
};
|
|
310
|
-
spawnTeamTeammate({
|
|
311
|
-
runtime: options.runtime,
|
|
312
|
-
requesterId: options.requesterId,
|
|
313
|
-
teammateConfigProvider: options.teammateConfigProvider,
|
|
314
|
-
createBaseTools: options.createBaseTools,
|
|
315
|
-
spec,
|
|
316
|
-
});
|
|
317
|
-
if (!includeManagementTools) {
|
|
318
|
-
options.onLeadToolsUnlocked?.(
|
|
319
|
-
createAgentTeamsTools({
|
|
320
|
-
...options,
|
|
321
|
-
includeSpawnTool: false,
|
|
322
|
-
includeManagementTools: true,
|
|
323
|
-
onLeadToolsUnlocked: undefined,
|
|
324
|
-
}),
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
return validateWithZod(TeamSimpleAgentStatusToolResultSchema, {
|
|
328
|
-
agentId: validatedInput.agentId,
|
|
329
|
-
status: "spawned",
|
|
330
|
-
});
|
|
331
|
-
},
|
|
332
|
-
}) as Tool,
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (!includeManagementTools) {
|
|
337
|
-
return tools;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
tools.push(
|
|
341
|
-
createTool<TeamShutdownTeammateInput, { agentId: string; status: string }>({
|
|
342
|
-
name: "team_shutdown_teammate",
|
|
343
|
-
description: "Shutdown a teammate by agentId.",
|
|
344
|
-
inputSchema: zodToJsonSchema(TeamShutdownTeammateInputSchema),
|
|
345
|
-
execute: async (input) => {
|
|
346
|
-
const validatedInput = validateWithZod(
|
|
347
|
-
TeamShutdownTeammateInputSchema,
|
|
348
|
-
input,
|
|
349
|
-
);
|
|
350
|
-
if (options.runtime.getMemberRole(options.requesterId) !== "lead") {
|
|
351
|
-
throw new Error("Only the lead agent can manage teammates.");
|
|
352
|
-
}
|
|
353
|
-
options.runtime.shutdownTeammate(
|
|
354
|
-
validatedInput.agentId,
|
|
355
|
-
validatedInput.reason,
|
|
356
|
-
);
|
|
357
|
-
return validateWithZod(TeamSimpleAgentStatusToolResultSchema, {
|
|
358
|
-
agentId: validatedInput.agentId,
|
|
359
|
-
status: "stopped",
|
|
360
|
-
});
|
|
361
|
-
},
|
|
362
|
-
}) as Tool,
|
|
363
|
-
);
|
|
364
|
-
|
|
365
|
-
tools.push(
|
|
366
|
-
createTool<TeamStatusInput, TeamStatusToolResult>({
|
|
367
|
-
name: "team_status",
|
|
368
|
-
description:
|
|
369
|
-
"Return a snapshot of team members, task counts, mailbox, and mission log stats.",
|
|
370
|
-
inputSchema: zodToJsonSchema(TeamStatusInputSchema),
|
|
371
|
-
execute: async (input) => {
|
|
372
|
-
validateWithZod(TeamStatusInputSchema, input);
|
|
373
|
-
return validateWithZod(
|
|
374
|
-
TeamStatusToolResultSchema,
|
|
375
|
-
options.runtime.getSnapshot(),
|
|
376
|
-
);
|
|
377
|
-
},
|
|
378
|
-
}) as Tool,
|
|
379
|
-
);
|
|
380
|
-
|
|
381
|
-
tools.push(
|
|
382
|
-
createTool<TeamTaskInput, TeamTaskToolResult>({
|
|
383
|
-
name: "team_task",
|
|
384
|
-
description:
|
|
385
|
-
"Manage shared team tasks with action-specific payloads. " +
|
|
386
|
-
"create requires title and description, with optional dependsOn and assignee. " +
|
|
387
|
-
"list accepts optional status, assignee. " +
|
|
388
|
-
"claim requires taskId. complete requires taskId and summary. block requires taskId and reason. " +
|
|
389
|
-
"Do not include fields from other actions.",
|
|
390
|
-
inputSchema: zodToJsonSchema(TeamTaskInputSchema),
|
|
391
|
-
execute: async (input) => {
|
|
392
|
-
const validatedInput = validateWithZod(TeamTaskInputSchema, input);
|
|
393
|
-
switch (validatedInput.action) {
|
|
394
|
-
case "create": {
|
|
395
|
-
const ignoredFieldSet = new Set(
|
|
396
|
-
TEAM_TASK_IGNORED_FIELDS_BY_ACTION.create ?? [],
|
|
397
|
-
);
|
|
398
|
-
const ignoredFields = Object.entries(
|
|
399
|
-
input as Record<string, unknown>,
|
|
400
|
-
)
|
|
401
|
-
.filter(
|
|
402
|
-
([field, value]) => ignoredFieldSet.has(field) && value != null,
|
|
403
|
-
)
|
|
404
|
-
.map(([field]) => field);
|
|
405
|
-
const task = options.runtime.createTask({
|
|
406
|
-
title: validatedInput.title!,
|
|
407
|
-
description: validatedInput.description!,
|
|
408
|
-
dependsOn: validatedInput.dependsOn,
|
|
409
|
-
assignee: validatedInput.assignee,
|
|
410
|
-
createdBy: options.requesterId,
|
|
411
|
-
});
|
|
412
|
-
return validateWithZod(TeamTaskToolResultSchema, {
|
|
413
|
-
action: "create",
|
|
414
|
-
taskId: task.id,
|
|
415
|
-
status: task.status,
|
|
416
|
-
...(ignoredFields.length > 0
|
|
417
|
-
? {
|
|
418
|
-
ignoredFields,
|
|
419
|
-
note: `Ignored fields for action=create: ${ignoredFields.join(", ")}`,
|
|
420
|
-
}
|
|
421
|
-
: {}),
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
case "list":
|
|
425
|
-
return validateWithZod(TeamTaskToolResultSchema, {
|
|
426
|
-
action: "list",
|
|
427
|
-
tasks: options.runtime.listTaskItems({
|
|
428
|
-
status: validatedInput.status,
|
|
429
|
-
assignee: validatedInput.assignee,
|
|
430
|
-
}),
|
|
431
|
-
});
|
|
432
|
-
case "claim": {
|
|
433
|
-
const task = options.runtime.claimTask(
|
|
434
|
-
validatedInput.taskId!,
|
|
435
|
-
options.requesterId,
|
|
436
|
-
);
|
|
437
|
-
return validateWithZod(TeamTaskToolResultSchema, {
|
|
438
|
-
action: "claim",
|
|
439
|
-
taskId: task.id,
|
|
440
|
-
status: task.status,
|
|
441
|
-
nextStep:
|
|
442
|
-
"Task is now in_progress. Execute the work using team_run_task or your own tools, then call team_task with action=complete when done.",
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
case "complete": {
|
|
446
|
-
const task = options.runtime.completeTask(
|
|
447
|
-
validatedInput.taskId!,
|
|
448
|
-
options.requesterId,
|
|
449
|
-
validatedInput.summary!,
|
|
450
|
-
);
|
|
451
|
-
return validateWithZod(TeamTaskToolResultSchema, {
|
|
452
|
-
action: "complete",
|
|
453
|
-
taskId: task.id,
|
|
454
|
-
status: task.status,
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
case "block": {
|
|
458
|
-
const task = options.runtime.blockTask(
|
|
459
|
-
validatedInput.taskId!,
|
|
460
|
-
options.requesterId,
|
|
461
|
-
validatedInput.reason!,
|
|
462
|
-
);
|
|
463
|
-
return validateWithZod(TeamTaskToolResultSchema, {
|
|
464
|
-
action: "block",
|
|
465
|
-
taskId: task.id,
|
|
466
|
-
status: task.status,
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
},
|
|
471
|
-
}) as Tool,
|
|
472
|
-
);
|
|
473
|
-
|
|
474
|
-
// Track in-flight sync runs per agent for dedup
|
|
475
|
-
// (Claude sometimes emits duplicate tool_use blocks in a single response;
|
|
476
|
-
// duplicate sync calls should await the first dispatched run)
|
|
477
|
-
const pendingSyncRuns = new Map<string, Promise<TeamRunTaskToolResult>>();
|
|
478
|
-
|
|
479
|
-
tools.push(
|
|
480
|
-
createTool<TeamRunTaskInput, TeamRunTaskToolResult>({
|
|
481
|
-
name: "team_run_task",
|
|
482
|
-
description:
|
|
483
|
-
"Route a delegated task to a teammate. Choose sync (wait) or async (run in background).",
|
|
484
|
-
inputSchema: zodToJsonSchema(TeamRunTaskInputSchema),
|
|
485
|
-
execute: async (input) => {
|
|
486
|
-
const validatedInput = validateWithZod(TeamRunTaskInputSchema, input);
|
|
487
|
-
if (validatedInput.runMode === "async") {
|
|
488
|
-
const run = options.runtime.startTeammateRun(
|
|
489
|
-
validatedInput.agentId,
|
|
490
|
-
validatedInput.task,
|
|
491
|
-
{
|
|
492
|
-
taskId: validatedInput.taskId || undefined,
|
|
493
|
-
fromAgentId: options.requesterId,
|
|
494
|
-
continueConversation:
|
|
495
|
-
validatedInput.continueConversation || undefined,
|
|
496
|
-
},
|
|
497
|
-
);
|
|
498
|
-
return validateWithZod(TeamRunTaskToolResultSchema, {
|
|
499
|
-
agentId: validatedInput.agentId,
|
|
500
|
-
mode: "async",
|
|
501
|
-
status: "queued",
|
|
502
|
-
dispatched: true,
|
|
503
|
-
message: `Task dispatched to ${validatedInput.agentId} and queued as ${run.id}.`,
|
|
504
|
-
runId: run.id,
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// Deduplication guard: collapse a duplicate sync call for the same
|
|
509
|
-
// agent onto the first in-flight dispatch in this parallel tool-call batch.
|
|
510
|
-
const pendingRun = pendingSyncRuns.get(validatedInput.agentId);
|
|
511
|
-
if (pendingRun) {
|
|
512
|
-
const result = await pendingRun;
|
|
513
|
-
return validateWithZod(TeamRunTaskToolResultSchema, {
|
|
514
|
-
...result,
|
|
515
|
-
status: "joined",
|
|
516
|
-
deduped: true,
|
|
517
|
-
message: `Task for ${validatedInput.agentId} was already dispatched in this tool batch; joined the existing in-flight run.`,
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
const runPromise = options.runtime
|
|
521
|
-
.routeToTeammate(validatedInput.agentId, validatedInput.task, {
|
|
522
|
-
taskId: validatedInput.taskId || undefined,
|
|
523
|
-
fromAgentId: options.requesterId,
|
|
524
|
-
continueConversation:
|
|
525
|
-
validatedInput.continueConversation || undefined,
|
|
526
|
-
})
|
|
527
|
-
.then((result) =>
|
|
528
|
-
validateWithZod(TeamRunTaskToolResultSchema, {
|
|
529
|
-
agentId: validatedInput.agentId,
|
|
530
|
-
mode: "sync" as const,
|
|
531
|
-
status: "running" as const,
|
|
532
|
-
dispatched: true,
|
|
533
|
-
message: `Task dispatched to ${validatedInput.agentId} and completed in sync mode.`,
|
|
534
|
-
text: result.text,
|
|
535
|
-
iterations: result.iterations,
|
|
536
|
-
}),
|
|
537
|
-
)
|
|
538
|
-
.finally(() => {
|
|
539
|
-
pendingSyncRuns.delete(validatedInput.agentId);
|
|
540
|
-
});
|
|
541
|
-
pendingSyncRuns.set(validatedInput.agentId, runPromise);
|
|
542
|
-
return await runPromise;
|
|
543
|
-
},
|
|
544
|
-
}) as Tool,
|
|
545
|
-
);
|
|
546
|
-
|
|
547
|
-
tools.push(
|
|
548
|
-
createTool<TeamCancelRunInput, { runId: string; status: string }>({
|
|
549
|
-
name: "team_cancel_run",
|
|
550
|
-
description: "Cancel one async teammate run.",
|
|
551
|
-
inputSchema: zodToJsonSchema(TeamCancelRunInputSchema),
|
|
552
|
-
execute: async (input) => {
|
|
553
|
-
const validatedInput = validateWithZod(TeamCancelRunInputSchema, input);
|
|
554
|
-
const run = options.runtime.cancelRun(
|
|
555
|
-
validatedInput.runId,
|
|
556
|
-
validatedInput.reason,
|
|
557
|
-
);
|
|
558
|
-
return validateWithZod(TeamCancelRunToolResultSchema, {
|
|
559
|
-
runId: run.id,
|
|
560
|
-
status: run.status,
|
|
561
|
-
});
|
|
562
|
-
},
|
|
563
|
-
}) as Tool,
|
|
564
|
-
);
|
|
565
|
-
|
|
566
|
-
tools.push(
|
|
567
|
-
createTool<TeamListRunsInput, TeamRunToolSummary[]>({
|
|
568
|
-
name: "team_list_runs",
|
|
569
|
-
description:
|
|
570
|
-
"List teammate runs started with team_run_task in async mode, including live activity/progress fields when available.",
|
|
571
|
-
inputSchema: zodToJsonSchema(TeamListRunsInputSchema),
|
|
572
|
-
execute: async (input) =>
|
|
573
|
-
validateWithZod(
|
|
574
|
-
TeamRunToolSummarySchema.array(),
|
|
575
|
-
options.runtime
|
|
576
|
-
.listRuns(validateWithZod(TeamListRunsInputSchema, input))
|
|
577
|
-
.map(summarizeRun),
|
|
578
|
-
),
|
|
579
|
-
}) as Tool,
|
|
580
|
-
);
|
|
581
|
-
|
|
582
|
-
tools.push(
|
|
583
|
-
createTool<TeamAwaitRunsInput, TeamRunToolSummary | TeamRunToolSummary[]>({
|
|
584
|
-
name: "team_await_runs",
|
|
585
|
-
description:
|
|
586
|
-
"Wait for async teammate runs. Provide runId to wait for one run, or omit it to wait for all active async runs. Uses a long timeout for legitimate teammate work.",
|
|
587
|
-
inputSchema: zodToJsonSchema(TeamAwaitRunsInputSchema),
|
|
588
|
-
timeoutMs: TEAM_AWAIT_TIMEOUT_MS,
|
|
589
|
-
execute: async (input) => {
|
|
590
|
-
const validatedInput = validateWithZod(TeamAwaitRunsInputSchema, input);
|
|
591
|
-
if (validatedInput.runId) {
|
|
592
|
-
const run = await options.runtime.awaitRun(validatedInput.runId);
|
|
593
|
-
assertAwaitedRunSucceeded(run);
|
|
594
|
-
return validateWithZod(TeamRunToolSummarySchema, summarizeRun(run));
|
|
595
|
-
}
|
|
596
|
-
const runs = await options.runtime.awaitAllRuns();
|
|
597
|
-
const failedRuns = runs.filter((run) =>
|
|
598
|
-
["failed", "cancelled", "interrupted"].includes(run.status),
|
|
599
|
-
);
|
|
600
|
-
if (failedRuns.length > 0) {
|
|
601
|
-
const details = failedRuns
|
|
602
|
-
.map(
|
|
603
|
-
(run) =>
|
|
604
|
-
`${run.id}:${run.status}${run.error ? `(${run.error})` : ""}`,
|
|
605
|
-
)
|
|
606
|
-
.join(", ");
|
|
607
|
-
throw new Error(
|
|
608
|
-
`One or more runs did not complete successfully: ${details}`,
|
|
609
|
-
);
|
|
610
|
-
}
|
|
611
|
-
return validateWithZod(
|
|
612
|
-
TeamRunToolSummarySchema.array(),
|
|
613
|
-
runs.map(summarizeRun),
|
|
614
|
-
);
|
|
615
|
-
},
|
|
616
|
-
}) as Tool,
|
|
617
|
-
);
|
|
618
|
-
|
|
619
|
-
tools.push(
|
|
620
|
-
createTool<TeamSendMessageInput, { id: string; toAgentId: string }>({
|
|
621
|
-
name: "team_send_message",
|
|
622
|
-
description: "Send a mailbox message to a specific teammate.",
|
|
623
|
-
inputSchema: zodToJsonSchema(TeamSendMessageInputSchema),
|
|
624
|
-
execute: async (input) => {
|
|
625
|
-
const validatedInput = validateWithZod(
|
|
626
|
-
TeamSendMessageInputSchema,
|
|
627
|
-
input,
|
|
628
|
-
);
|
|
629
|
-
const message = options.runtime.sendMessage(
|
|
630
|
-
options.requesterId,
|
|
631
|
-
validatedInput.toAgentId,
|
|
632
|
-
validatedInput.subject,
|
|
633
|
-
validatedInput.body,
|
|
634
|
-
validatedInput.taskId ?? undefined,
|
|
635
|
-
);
|
|
636
|
-
return validateWithZod(TeamSendMessageToolResultSchema, {
|
|
637
|
-
id: message.id,
|
|
638
|
-
toAgentId: message.toAgentId,
|
|
639
|
-
});
|
|
640
|
-
},
|
|
641
|
-
}) as Tool,
|
|
642
|
-
);
|
|
643
|
-
|
|
644
|
-
tools.push(
|
|
645
|
-
createTool<TeamBroadcastInput, { delivered: number }>({
|
|
646
|
-
name: "team_broadcast",
|
|
647
|
-
description: "Broadcast a message to all teammates.",
|
|
648
|
-
inputSchema: zodToJsonSchema(TeamBroadcastInputSchema),
|
|
649
|
-
execute: async (input) => {
|
|
650
|
-
const validatedInput = validateWithZod(TeamBroadcastInputSchema, input);
|
|
651
|
-
const messages = options.runtime.broadcast(
|
|
652
|
-
options.requesterId,
|
|
653
|
-
validatedInput.subject,
|
|
654
|
-
validatedInput.body,
|
|
655
|
-
{
|
|
656
|
-
taskId: validatedInput.taskId ?? undefined,
|
|
657
|
-
},
|
|
658
|
-
);
|
|
659
|
-
return validateWithZod(TeamBroadcastToolResultSchema, {
|
|
660
|
-
delivered: messages.length,
|
|
661
|
-
});
|
|
662
|
-
},
|
|
663
|
-
}) as Tool,
|
|
664
|
-
);
|
|
665
|
-
|
|
666
|
-
tools.push(
|
|
667
|
-
createTool<TeamReadMailboxInput, TeamMailboxMessageToolResult[]>({
|
|
668
|
-
name: "team_read_mailbox",
|
|
669
|
-
description: "Read the current agent mailbox.",
|
|
670
|
-
inputSchema: zodToJsonSchema(TeamReadMailboxInputSchema),
|
|
671
|
-
execute: async (input) => {
|
|
672
|
-
const validatedInput = validateWithZod(
|
|
673
|
-
TeamReadMailboxInputSchema,
|
|
674
|
-
input,
|
|
675
|
-
);
|
|
676
|
-
return validateWithZod(
|
|
677
|
-
TeamMailboxMessageToolResultSchema.array(),
|
|
678
|
-
options.runtime.listMailbox(options.requesterId, {
|
|
679
|
-
unreadOnly: validatedInput.unreadOnly,
|
|
680
|
-
markRead: true,
|
|
681
|
-
}),
|
|
682
|
-
);
|
|
683
|
-
},
|
|
684
|
-
}) as Tool,
|
|
685
|
-
);
|
|
686
|
-
|
|
687
|
-
tools.push(
|
|
688
|
-
createTool<TeamMissionLogInput, { id: string }>({
|
|
689
|
-
name: "team_mission_log",
|
|
690
|
-
description: "Append a mission log update for your team.",
|
|
691
|
-
inputSchema: zodToJsonSchema(TeamMissionLogInputSchema),
|
|
692
|
-
execute: async (input) => {
|
|
693
|
-
const validatedInput = validateWithZod(
|
|
694
|
-
TeamMissionLogInputSchema,
|
|
695
|
-
input,
|
|
696
|
-
);
|
|
697
|
-
const entry = options.runtime.appendMissionLog({
|
|
698
|
-
agentId: options.requesterId,
|
|
699
|
-
taskId: validatedInput.taskId || undefined,
|
|
700
|
-
kind: validatedInput.kind,
|
|
701
|
-
summary: validatedInput.summary,
|
|
702
|
-
evidence: validatedInput.evidence?.length
|
|
703
|
-
? validatedInput.evidence
|
|
704
|
-
: undefined,
|
|
705
|
-
nextAction: validatedInput.nextAction || undefined,
|
|
706
|
-
});
|
|
707
|
-
return validateWithZod(TeamMissionLogToolResultSchema, {
|
|
708
|
-
id: entry.id,
|
|
709
|
-
});
|
|
710
|
-
},
|
|
711
|
-
}) as Tool,
|
|
712
|
-
);
|
|
713
|
-
|
|
714
|
-
tools.push(
|
|
715
|
-
createTool<TeamCleanupInput, { status: string }>({
|
|
716
|
-
name: "team_cleanup",
|
|
717
|
-
description:
|
|
718
|
-
"Clean up the team runtime. Fails if teammates are still running.",
|
|
719
|
-
inputSchema: zodToJsonSchema(TeamCleanupInputSchema),
|
|
720
|
-
execute: async (input) => {
|
|
721
|
-
validateWithZod(TeamCleanupInputSchema, input);
|
|
722
|
-
if (options.runtime.getMemberRole(options.requesterId) !== "lead") {
|
|
723
|
-
throw new Error("Only the lead agent can run cleanup.");
|
|
724
|
-
}
|
|
725
|
-
options.runtime.cleanup();
|
|
726
|
-
return validateWithZod(TeamCleanupToolResultSchema, {
|
|
727
|
-
status: "cleaned",
|
|
728
|
-
});
|
|
729
|
-
},
|
|
730
|
-
}) as Tool,
|
|
731
|
-
);
|
|
732
|
-
|
|
733
|
-
tools.push(
|
|
734
|
-
createTool<TeamCreateOutcomeInput, TeamCreateOutcomeToolResult>({
|
|
735
|
-
name: "team_create_outcome",
|
|
736
|
-
description: "Create a converged team outcome.",
|
|
737
|
-
inputSchema: zodToJsonSchema(TeamCreateOutcomeInputSchema),
|
|
738
|
-
execute: async (input) => {
|
|
739
|
-
const validatedInput = validateWithZod(
|
|
740
|
-
TeamCreateOutcomeInputSchema,
|
|
741
|
-
input,
|
|
742
|
-
);
|
|
743
|
-
const outcome = options.runtime.createOutcome({
|
|
744
|
-
title: validatedInput.title,
|
|
745
|
-
requiredSections: validatedInput.requiredSections,
|
|
746
|
-
createdBy: options.requesterId,
|
|
747
|
-
});
|
|
748
|
-
return validateWithZod(TeamCreateOutcomeToolResultSchema, {
|
|
749
|
-
outcomeId: outcome.id,
|
|
750
|
-
status: outcome.status,
|
|
751
|
-
requiredSections: outcome.requiredSections,
|
|
752
|
-
});
|
|
753
|
-
},
|
|
754
|
-
}) as Tool,
|
|
755
|
-
);
|
|
756
|
-
|
|
757
|
-
tools.push(
|
|
758
|
-
createTool<
|
|
759
|
-
TeamAttachOutcomeFragmentInput,
|
|
760
|
-
{ fragmentId: string; status: string }
|
|
761
|
-
>({
|
|
762
|
-
name: "team_attach_outcome_fragment",
|
|
763
|
-
description: "Attach a fragment to an outcome section.",
|
|
764
|
-
inputSchema: zodToJsonSchema(TeamAttachOutcomeFragmentInputSchema),
|
|
765
|
-
execute: async (input) => {
|
|
766
|
-
const validatedInput = validateWithZod(
|
|
767
|
-
TeamAttachOutcomeFragmentInputSchema,
|
|
768
|
-
input,
|
|
769
|
-
);
|
|
770
|
-
const fragment = options.runtime.attachOutcomeFragment({
|
|
771
|
-
outcomeId: validatedInput.outcomeId,
|
|
772
|
-
section: validatedInput.section,
|
|
773
|
-
sourceAgentId: options.requesterId,
|
|
774
|
-
sourceRunId: validatedInput.sourceRunId || undefined,
|
|
775
|
-
content: validatedInput.content,
|
|
776
|
-
});
|
|
777
|
-
return validateWithZod(TeamOutcomeFragmentToolResultSchema, {
|
|
778
|
-
fragmentId: fragment.id,
|
|
779
|
-
status: fragment.status,
|
|
780
|
-
});
|
|
781
|
-
},
|
|
782
|
-
}) as Tool,
|
|
783
|
-
);
|
|
784
|
-
|
|
785
|
-
tools.push(
|
|
786
|
-
createTool<
|
|
787
|
-
TeamReviewOutcomeFragmentInput,
|
|
788
|
-
{ fragmentId: string; status: string }
|
|
789
|
-
>({
|
|
790
|
-
name: "team_review_outcome_fragment",
|
|
791
|
-
description: "Review one outcome fragment.",
|
|
792
|
-
inputSchema: zodToJsonSchema(TeamReviewOutcomeFragmentInputSchema),
|
|
793
|
-
execute: async (input) => {
|
|
794
|
-
const validatedInput = validateWithZod(
|
|
795
|
-
TeamReviewOutcomeFragmentInputSchema,
|
|
796
|
-
input,
|
|
797
|
-
);
|
|
798
|
-
const fragment = options.runtime.reviewOutcomeFragment({
|
|
799
|
-
fragmentId: validatedInput.fragmentId,
|
|
800
|
-
reviewedBy: options.requesterId,
|
|
801
|
-
approved: validatedInput.approved,
|
|
802
|
-
});
|
|
803
|
-
return validateWithZod(TeamOutcomeFragmentToolResultSchema, {
|
|
804
|
-
fragmentId: fragment.id,
|
|
805
|
-
status: fragment.status,
|
|
806
|
-
});
|
|
807
|
-
},
|
|
808
|
-
}) as Tool,
|
|
809
|
-
);
|
|
810
|
-
|
|
811
|
-
tools.push(
|
|
812
|
-
createTool<TeamFinalizeOutcomeInput, { outcomeId: string; status: string }>(
|
|
813
|
-
{
|
|
814
|
-
name: "team_finalize_outcome",
|
|
815
|
-
description: "Finalize one outcome.",
|
|
816
|
-
inputSchema: zodToJsonSchema(TeamFinalizeOutcomeInputSchema),
|
|
817
|
-
execute: async (input) => {
|
|
818
|
-
const validatedInput = validateWithZod(
|
|
819
|
-
TeamFinalizeOutcomeInputSchema,
|
|
820
|
-
input,
|
|
821
|
-
);
|
|
822
|
-
const outcome = options.runtime.finalizeOutcome(
|
|
823
|
-
validatedInput.outcomeId,
|
|
824
|
-
);
|
|
825
|
-
return validateWithZod(TeamFinalizeOutcomeToolResultSchema, {
|
|
826
|
-
outcomeId: outcome.id,
|
|
827
|
-
status: outcome.status,
|
|
828
|
-
});
|
|
829
|
-
},
|
|
830
|
-
},
|
|
831
|
-
) as Tool,
|
|
832
|
-
);
|
|
833
|
-
|
|
834
|
-
tools.push(
|
|
835
|
-
createTool<TeamListOutcomesInput, TeamOutcomeToolResult[]>({
|
|
836
|
-
name: "team_list_outcomes",
|
|
837
|
-
description: "List team outcomes.",
|
|
838
|
-
inputSchema: zodToJsonSchema(TeamListOutcomesInputSchema),
|
|
839
|
-
execute: async (input) => {
|
|
840
|
-
validateWithZod(TeamListOutcomesInputSchema, input);
|
|
841
|
-
return validateWithZod(
|
|
842
|
-
TeamOutcomeToolResultSchema.array(),
|
|
843
|
-
options.runtime.listOutcomes(),
|
|
844
|
-
);
|
|
845
|
-
},
|
|
846
|
-
}) as Tool,
|
|
847
|
-
);
|
|
848
|
-
|
|
849
|
-
return tools;
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
export function reviveTeamStateDates(
|
|
853
|
-
state: TeamRuntimeState,
|
|
854
|
-
): TeamRuntimeState {
|
|
855
|
-
return {
|
|
856
|
-
...state,
|
|
857
|
-
tasks: state.tasks.map((task) => ({
|
|
858
|
-
...task,
|
|
859
|
-
createdAt: new Date(task.createdAt),
|
|
860
|
-
updatedAt: new Date(task.updatedAt),
|
|
861
|
-
})),
|
|
862
|
-
mailbox: state.mailbox.map((message) => ({
|
|
863
|
-
...message,
|
|
864
|
-
sentAt: new Date(message.sentAt),
|
|
865
|
-
readAt: message.readAt ? new Date(message.readAt) : undefined,
|
|
866
|
-
})),
|
|
867
|
-
missionLog: state.missionLog.map((entry) => ({
|
|
868
|
-
...entry,
|
|
869
|
-
ts: new Date(entry.ts),
|
|
870
|
-
})),
|
|
871
|
-
runs: (state.runs ?? []).map((run) => ({
|
|
872
|
-
...run,
|
|
873
|
-
startedAt: new Date(run.startedAt),
|
|
874
|
-
endedAt: run.endedAt ? new Date(run.endedAt) : undefined,
|
|
875
|
-
nextAttemptAt: run.nextAttemptAt
|
|
876
|
-
? new Date(run.nextAttemptAt)
|
|
877
|
-
: undefined,
|
|
878
|
-
heartbeatAt: run.heartbeatAt ? new Date(run.heartbeatAt) : undefined,
|
|
879
|
-
})),
|
|
880
|
-
outcomes: (state.outcomes ?? []).map((outcome) => ({
|
|
881
|
-
...outcome,
|
|
882
|
-
createdAt: new Date(outcome.createdAt),
|
|
883
|
-
finalizedAt: outcome.finalizedAt
|
|
884
|
-
? new Date(outcome.finalizedAt)
|
|
885
|
-
: undefined,
|
|
886
|
-
})),
|
|
887
|
-
outcomeFragments: (state.outcomeFragments ?? []).map((fragment) => ({
|
|
888
|
-
...fragment,
|
|
889
|
-
createdAt: new Date(fragment.createdAt),
|
|
890
|
-
reviewedAt: fragment.reviewedAt
|
|
891
|
-
? new Date(fragment.reviewedAt)
|
|
892
|
-
: undefined,
|
|
893
|
-
})),
|
|
894
|
-
};
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
export function sanitizeTeamName(name: string): string {
|
|
898
|
-
return name
|
|
899
|
-
.toLowerCase()
|
|
900
|
-
.replace(/[^a-z0-9._-]+/g, "-")
|
|
901
|
-
.replace(/^-+|-+$/g, "");
|
|
902
|
-
}
|