@evalops/maestro 0.10.8 → 0.10.11
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 +3 -1
- package/dist/agent/action-approval.d.ts +6 -0
- package/dist/agent/action-approval.d.ts.map +1 -1
- package/dist/agent/action-approval.js.map +1 -1
- package/dist/agent/agent.d.ts +13 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.js +368 -1
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/auto-compaction.d.ts +4 -4
- package/dist/agent/auto-compaction.d.ts.map +1 -1
- package/dist/agent/auto-compaction.js.map +1 -1
- package/dist/agent/compaction-cleanup.d.ts +2 -0
- package/dist/agent/compaction-cleanup.d.ts.map +1 -1
- package/dist/agent/compaction-cleanup.js +17 -2
- package/dist/agent/compaction-cleanup.js.map +1 -1
- package/dist/agent/compaction.d.ts +3 -1
- package/dist/agent/compaction.d.ts.map +1 -1
- package/dist/agent/compaction.js +10 -2
- package/dist/agent/compaction.js.map +1 -1
- package/dist/agent/context-manager.d.ts +4 -0
- package/dist/agent/context-manager.d.ts.map +1 -1
- package/dist/agent/context-manager.js +8 -0
- package/dist/agent/context-manager.js.map +1 -1
- package/dist/agent/context-providers.d.ts +2 -0
- package/dist/agent/context-providers.d.ts.map +1 -1
- package/dist/agent/context-providers.js +3 -2
- package/dist/agent/context-providers.js.map +1 -1
- package/dist/agent/providers/google-gemini-cli.js +17 -5
- package/dist/agent/providers/google.js +174 -144
- package/dist/agent/providers/openai-codex-responses.d.ts +4 -0
- package/dist/agent/providers/openai-codex-responses.d.ts.map +1 -0
- package/dist/agent/providers/openai-codex-responses.js +637 -0
- package/dist/agent/providers/openai-codex-responses.js.map +1 -0
- package/dist/agent/providers/openai-codex-session.d.ts +18 -0
- package/dist/agent/providers/openai-codex-session.d.ts.map +1 -0
- package/dist/agent/providers/openai-codex-session.js +53 -0
- package/dist/agent/providers/openai-codex-session.js.map +1 -0
- package/dist/agent/providers/openai-responses-sdk.d.ts.map +1 -1
- package/dist/agent/providers/openai-responses-sdk.js +16 -6
- package/dist/agent/providers/openai-responses-sdk.js.map +1 -1
- package/dist/agent/providers/openai-shared.d.ts +12 -5
- package/dist/agent/providers/openai-shared.d.ts.map +1 -1
- package/dist/agent/providers/openai-shared.js +291 -2
- package/dist/agent/providers/openai-shared.js.map +1 -1
- package/dist/agent/providers/openai.d.ts +1 -1
- package/dist/agent/providers/openai.d.ts.map +1 -1
- package/dist/agent/providers/openai.js +48 -20
- package/dist/agent/providers/openai.js.map +1 -1
- package/dist/agent/providers/vertex.js +7 -0
- package/dist/agent/tracing.d.ts +16 -5
- package/dist/agent/tracing.d.ts.map +1 -1
- package/dist/agent/tracing.js +44 -2
- package/dist/agent/tracing.js.map +1 -1
- package/dist/agent/transport/create-provider-stream.d.ts.map +1 -1
- package/dist/agent/transport/create-provider-stream.js +9 -0
- package/dist/agent/transport/create-provider-stream.js.map +1 -1
- package/dist/agent/transport/tool-execution-bridge.d.ts +86 -0
- package/dist/agent/transport/tool-execution-bridge.d.ts.map +1 -0
- package/dist/agent/transport/tool-execution-bridge.js +665 -0
- package/dist/agent/transport/tool-execution-bridge.js.map +1 -0
- package/dist/agent/transport/tool-execution.d.ts +3 -0
- package/dist/agent/transport/tool-execution.d.ts.map +1 -1
- package/dist/agent/transport/tool-execution.js +16 -1
- package/dist/agent/transport/tool-execution.js.map +1 -1
- package/dist/agent/transport/tool-safety-pipeline.d.ts +7 -1
- package/dist/agent/transport/tool-safety-pipeline.d.ts.map +1 -1
- package/dist/agent/transport/tool-safety-pipeline.js +207 -40
- package/dist/agent/transport/tool-safety-pipeline.js.map +1 -1
- package/dist/agent/transport/tool-update-queue.d.ts +2 -0
- package/dist/agent/transport/tool-update-queue.d.ts.map +1 -1
- package/dist/agent/transport/tool-update-queue.js.map +1 -1
- package/dist/agent/transport.d.ts +3 -0
- package/dist/agent/transport.d.ts.map +1 -1
- package/dist/agent/transport.js +96 -16
- package/dist/agent/transport.js.map +1 -1
- package/dist/agent/types.d.ts +50 -2
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/approvals/platform-action-approval.d.ts +32 -0
- package/dist/approvals/platform-action-approval.d.ts.map +1 -0
- package/dist/approvals/platform-action-approval.js +210 -0
- package/dist/approvals/platform-action-approval.js.map +1 -0
- package/dist/approvals/service-client.d.ts +56 -0
- package/dist/approvals/service-client.d.ts.map +1 -0
- package/dist/approvals/service-client.js +316 -0
- package/dist/approvals/service-client.js.map +1 -0
- package/dist/audit/logger.d.ts +4 -4
- package/dist/bootstrap/auth-setup.d.ts +2 -2
- package/dist/bootstrap/auth-setup.d.ts.map +1 -1
- package/dist/bootstrap/auth-setup.js +4 -7
- package/dist/bootstrap/auth-setup.js.map +1 -1
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +29 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/commands/codex.d.ts +2 -0
- package/dist/cli/commands/codex.d.ts.map +1 -0
- package/dist/cli/commands/codex.js +65 -0
- package/dist/cli/commands/codex.js.map +1 -0
- package/dist/cli/commands/config.js +1 -1
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/evalops.d.ts +2 -0
- package/dist/cli/commands/evalops.d.ts.map +1 -0
- package/dist/cli/commands/evalops.js +74 -0
- package/dist/cli/commands/evalops.js.map +1 -0
- package/dist/cli/commands/hosted-runner.d.ts +23 -0
- package/dist/cli/commands/hosted-runner.d.ts.map +1 -0
- package/dist/cli/commands/hosted-runner.js +241 -0
- package/dist/cli/commands/hosted-runner.js.map +1 -0
- package/dist/cli/commands/init.d.ts +4 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +140 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/memory.d.ts.map +1 -1
- package/dist/cli/commands/memory.js +23 -30
- package/dist/cli/commands/memory.js.map +1 -1
- package/dist/cli/commands/remote.d.ts +3 -0
- package/dist/cli/commands/remote.d.ts.map +1 -0
- package/dist/cli/commands/remote.js +631 -0
- package/dist/cli/commands/remote.js.map +1 -0
- package/dist/cli/commands/stats.d.ts +7 -0
- package/dist/cli/commands/stats.d.ts.map +1 -0
- package/dist/cli/commands/stats.js +167 -0
- package/dist/cli/commands/stats.js.map +1 -0
- package/dist/cli/headless-protocol.d.ts +16 -1
- package/dist/cli/headless-protocol.d.ts.map +1 -1
- package/dist/cli/headless-protocol.js +60 -4
- package/dist/cli/headless-protocol.js.map +1 -1
- package/dist/cli/headless.d.ts.map +1 -1
- package/dist/cli/headless.js +1 -0
- package/dist/cli/headless.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +44 -1
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/jsonl-writer.d.ts.map +1 -1
- package/dist/cli/jsonl-writer.js +19 -6
- package/dist/cli/jsonl-writer.js.map +1 -1
- package/dist/cli-tui/client-tools/client-tool-controller.d.ts.map +1 -1
- package/dist/cli-tui/client-tools/client-tool-controller.js +17 -1
- package/dist/cli-tui/client-tools/client-tool-controller.js.map +1 -1
- package/dist/cli-tui/commands/access-command.js +1 -1
- package/dist/cli-tui/commands/access-command.js.map +1 -1
- package/dist/cli-tui/commands/audit-command.js +1 -1
- package/dist/cli-tui/commands/audit-command.js.map +1 -1
- package/dist/cli-tui/commands/command-catalog.d.ts +29 -0
- package/dist/cli-tui/commands/command-catalog.d.ts.map +1 -0
- package/dist/cli-tui/commands/command-catalog.js +645 -0
- package/dist/cli-tui/commands/command-catalog.js.map +1 -0
- package/dist/cli-tui/commands/command-registry-adapter.d.ts +12 -0
- package/dist/cli-tui/commands/command-registry-adapter.d.ts.map +1 -0
- package/dist/cli-tui/commands/command-registry-adapter.js +120 -0
- package/dist/cli-tui/commands/command-registry-adapter.js.map +1 -0
- package/dist/cli-tui/commands/command-suite-catalog.d.ts +14 -0
- package/dist/cli-tui/commands/command-suite-catalog.d.ts.map +1 -0
- package/dist/cli-tui/commands/command-suite-catalog.js +147 -0
- package/dist/cli-tui/commands/command-suite-catalog.js.map +1 -0
- package/dist/cli-tui/commands/{grouped-command-handlers.d.ts → command-suite-handlers.d.ts} +27 -26
- package/dist/cli-tui/commands/command-suite-handlers.d.ts.map +1 -0
- package/dist/cli-tui/commands/command-suite-handlers.js +110 -0
- package/dist/cli-tui/commands/command-suite-handlers.js.map +1 -0
- package/dist/cli-tui/commands/hotkeys-command.d.ts +1 -1
- package/dist/cli-tui/commands/hotkeys-command.d.ts.map +1 -1
- package/dist/cli-tui/commands/hotkeys-command.js +2 -2
- package/dist/cli-tui/commands/hotkeys-command.js.map +1 -1
- package/dist/cli-tui/commands/limits-command.js +1 -1
- package/dist/cli-tui/commands/limits-command.js.map +1 -1
- package/dist/cli-tui/commands/pii-command.js +1 -1
- package/dist/cli-tui/commands/pii-command.js.map +1 -1
- package/dist/cli-tui/commands/registry.d.ts +1 -1
- package/dist/cli-tui/commands/registry.d.ts.map +1 -1
- package/dist/cli-tui/commands/registry.js +29 -921
- package/dist/cli-tui/commands/registry.js.map +1 -1
- package/dist/cli-tui/commands/{grouped → subcommands}/auth-commands.d.ts +2 -1
- package/dist/cli-tui/commands/subcommands/auth-commands.d.ts.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/auth-commands.js +22 -6
- package/dist/cli-tui/commands/subcommands/auth-commands.js.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/config-commands.d.ts +0 -1
- package/dist/cli-tui/commands/subcommands/config-commands.d.ts.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/config-commands.js +2 -2
- package/dist/cli-tui/commands/subcommands/config-commands.js.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/diag-commands.d.ts +1 -2
- package/dist/cli-tui/commands/subcommands/diag-commands.d.ts.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/diag-commands.js +5 -7
- package/dist/cli-tui/commands/subcommands/diag-commands.js.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/git-commands.d.ts +0 -2
- package/dist/cli-tui/commands/subcommands/git-commands.d.ts.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/git-commands.js +2 -2
- package/dist/cli-tui/commands/subcommands/git-commands.js.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/index.d.ts +2 -2
- package/dist/cli-tui/commands/subcommands/index.d.ts.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/index.js +2 -2
- package/dist/cli-tui/commands/subcommands/index.js.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/safety-commands.d.ts +0 -1
- package/dist/cli-tui/commands/subcommands/safety-commands.d.ts.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/safety-commands.js +12 -12
- package/dist/cli-tui/commands/subcommands/safety-commands.js.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/session-commands.d.ts +1 -2
- package/dist/cli-tui/commands/subcommands/session-commands.d.ts.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/session-commands.js +3 -3
- package/dist/cli-tui/commands/subcommands/session-commands.js.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/tools-commands.d.ts +0 -1
- package/dist/cli-tui/commands/subcommands/tools-commands.d.ts.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/tools-commands.js +2 -2
- package/dist/cli-tui/commands/subcommands/tools-commands.js.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/ui-commands.d.ts +0 -1
- package/dist/cli-tui/commands/subcommands/ui-commands.d.ts.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/ui-commands.js +5 -5
- package/dist/cli-tui/commands/subcommands/ui-commands.js.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/undo-commands.d.ts +1 -2
- package/dist/cli-tui/commands/subcommands/undo-commands.d.ts.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/undo-commands.js +6 -6
- package/dist/cli-tui/commands/subcommands/undo-commands.js.map +1 -0
- package/dist/cli-tui/commands/subcommands/usage-commands.d.ts.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/usage-commands.js +2 -2
- package/dist/cli-tui/commands/subcommands/usage-commands.js.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/utils.d.ts +15 -15
- package/dist/cli-tui/commands/subcommands/utils.d.ts.map +1 -0
- package/dist/cli-tui/commands/{grouped → subcommands}/utils.js +13 -8
- package/dist/cli-tui/commands/subcommands/utils.js.map +1 -0
- package/dist/cli-tui/commands/types.d.ts +3 -3
- package/dist/cli-tui/commands/types.d.ts.map +1 -1
- package/dist/cli-tui/commands/types.js.map +1 -1
- package/dist/cli-tui/editor-view.d.ts +1 -1
- package/dist/cli-tui/editor-view.d.ts.map +1 -1
- package/dist/cli-tui/editor-view.js +1 -1
- package/dist/cli-tui/editor-view.js.map +1 -1
- package/dist/cli-tui/oauth/oauth-flow-controller.d.ts +4 -0
- package/dist/cli-tui/oauth/oauth-flow-controller.d.ts.map +1 -1
- package/dist/cli-tui/oauth/oauth-flow-controller.js +76 -5
- package/dist/cli-tui/oauth/oauth-flow-controller.js.map +1 -1
- package/dist/cli-tui/run/run-controller.d.ts +2 -2
- package/dist/cli-tui/run/run-controller.d.ts.map +1 -1
- package/dist/cli-tui/run/run-controller.js +3 -2
- package/dist/cli-tui/run/run-controller.js.map +1 -1
- package/dist/cli-tui/run/run-shell-command.d.ts.map +1 -1
- package/dist/cli-tui/run/run-shell-command.js +11 -3
- package/dist/cli-tui/run/run-shell-command.js.map +1 -1
- package/dist/cli-tui/run/streaming-shell-command.d.ts.map +1 -1
- package/dist/cli-tui/run/streaming-shell-command.js +11 -3
- package/dist/cli-tui/run/streaming-shell-command.js.map +1 -1
- package/dist/cli-tui/selectors/model-selector.d.ts.map +1 -1
- package/dist/cli-tui/selectors/model-selector.js +1 -0
- package/dist/cli-tui/selectors/model-selector.js.map +1 -1
- package/dist/cli-tui/tui-renderer/agent-event-bridge.d.ts +8 -0
- package/dist/cli-tui/tui-renderer/agent-event-bridge.d.ts.map +1 -1
- package/dist/cli-tui/tui-renderer/agent-event-bridge.js +23 -2
- package/dist/cli-tui/tui-renderer/agent-event-bridge.js.map +1 -1
- package/dist/cli-tui/tui-renderer/command-registry-options.d.ts +3 -3
- package/dist/cli-tui/tui-renderer/command-registry-options.d.ts.map +1 -1
- package/dist/cli-tui/tui-renderer/command-registry-options.js +12 -2
- package/dist/cli-tui/tui-renderer/command-registry-options.js.map +1 -1
- package/dist/cli-tui/tui-renderer/command-suite-wiring.d.ts +32 -0
- package/dist/cli-tui/tui-renderer/command-suite-wiring.d.ts.map +1 -0
- package/dist/cli-tui/tui-renderer/command-suite-wiring.js +108 -0
- package/dist/cli-tui/tui-renderer/command-suite-wiring.js.map +1 -0
- package/dist/cli-tui/tui-renderer/input-controller.d.ts +2 -2
- package/dist/cli-tui/tui-renderer/input-controller.d.ts.map +1 -1
- package/dist/cli-tui/tui-renderer/input-controller.js +2 -2
- package/dist/cli-tui/tui-renderer/input-controller.js.map +1 -1
- package/dist/cli-tui/tui-renderer/ui-state-controller.d.ts +1 -1
- package/dist/cli-tui/tui-renderer/ui-state-controller.js +1 -1
- package/dist/cli-tui/tui-renderer/ui-state-controller.js.map +1 -1
- package/dist/cli-tui/tui-renderer.d.ts +1 -3
- package/dist/cli-tui/tui-renderer.d.ts.map +1 -1
- package/dist/cli-tui/tui-renderer.js +37 -83
- package/dist/cli-tui/tui-renderer.js.map +1 -1
- package/dist/cli-tui/utils/runtime-badges.d.ts +8 -0
- package/dist/cli-tui/utils/runtime-badges.d.ts.map +1 -1
- package/dist/cli-tui/utils/runtime-badges.js +58 -0
- package/dist/cli-tui/utils/runtime-badges.js.map +1 -1
- package/dist/cli.js +42555 -23133
- package/dist/cli.js.map +1 -1
- package/dist/config/env-vars.d.ts +4 -0
- package/dist/config/env-vars.d.ts.map +1 -1
- package/dist/config/env-vars.js +4 -0
- package/dist/config/env-vars.js.map +1 -1
- package/dist/config/feature-flags.d.ts +44 -0
- package/dist/config/feature-flags.d.ts.map +1 -1
- package/dist/config/feature-flags.js +214 -0
- package/dist/config/feature-flags.js.map +1 -1
- package/dist/connectors/service-client.d.ts +98 -0
- package/dist/connectors/service-client.d.ts.map +1 -0
- package/dist/connectors/service-client.js +459 -0
- package/dist/connectors/service-client.js.map +1 -0
- package/dist/conversation/render-model.d.ts.map +1 -1
- package/dist/conversation/render-model.js +53 -3
- package/dist/conversation/render-model.js.map +1 -1
- package/dist/db/health.d.ts +8 -0
- package/dist/db/health.d.ts.map +1 -0
- package/dist/db/health.js +64 -0
- package/dist/db/health.js.map +1 -0
- package/dist/db/migrate.d.ts +301 -0
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +186 -0
- package/dist/db/migrate.js.map +1 -1
- package/dist/db/migrations/0000_initial.sql +308 -0
- package/dist/db/migrations/0001_shared_sessions.sql +18 -0
- package/dist/db/migrations/0002_usage_metrics.sql +28 -0
- package/dist/db/migrations/0003_execution_traces.sql +18 -0
- package/dist/db/migrations/0004_workspace_config.sql +11 -0
- package/dist/db/migrations/0005_revenue_attribution.sql +31 -0
- package/dist/db/migrations/0006_hosted_session_storage.sql +51 -0
- package/dist/db/migrations/0007_reconcile_legacy_audit_hash_cache.sql +24 -0
- package/dist/db/migrations/0008_reconcile_legacy_webhook_deliveries.sql +290 -0
- package/dist/db/migrations/meta/0000_snapshot.json +2438 -0
- package/dist/db/migrations/meta/_journal.json +69 -0
- package/dist/db/schema.d.ts +2232 -844
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +187 -1
- package/dist/db/schema.js.map +1 -1
- package/dist/evalops/agent-bootstrap.d.ts +73 -0
- package/dist/evalops/agent-bootstrap.d.ts.map +1 -0
- package/dist/evalops/agent-bootstrap.js +380 -0
- package/dist/evalops/agent-bootstrap.js.map +1 -0
- package/dist/export-html.d.ts.map +1 -1
- package/dist/export-html.js +7 -4
- package/dist/export-html.js.map +1 -1
- package/dist/headless/utility-command-manager.d.ts +2 -1
- package/dist/headless/utility-command-manager.d.ts.map +1 -1
- package/dist/headless/utility-command-manager.js +12 -6
- package/dist/headless/utility-command-manager.js.map +1 -1
- package/dist/headless/utility-file-read.d.ts +1 -0
- package/dist/headless/utility-file-read.d.ts.map +1 -1
- package/dist/headless/utility-file-read.js +5 -1
- package/dist/headless/utility-file-read.js.map +1 -1
- package/dist/headless/utility-file-search.d.ts +1 -0
- package/dist/headless/utility-file-search.d.ts.map +1 -1
- package/dist/headless/utility-file-search.js +4 -1
- package/dist/headless/utility-file-search.js.map +1 -1
- package/dist/headless/utility-file-watch-manager.d.ts +2 -1
- package/dist/headless/utility-file-watch-manager.d.ts.map +1 -1
- package/dist/headless/utility-file-watch-manager.js +6 -2
- package/dist/headless/utility-file-watch-manager.js.map +1 -1
- package/dist/headless/workspace-root.d.ts +8 -0
- package/dist/headless/workspace-root.d.ts.map +1 -0
- package/dist/headless/workspace-root.js +74 -0
- package/dist/headless/workspace-root.js.map +1 -0
- package/dist/hooks/notification-hooks.d.ts +5 -0
- package/dist/hooks/notification-hooks.d.ts.map +1 -1
- package/dist/hooks/notification-hooks.js +4 -0
- package/dist/hooks/notification-hooks.js.map +1 -1
- package/dist/lsp/diagnostic-deltas.d.ts +20 -0
- package/dist/lsp/diagnostic-deltas.d.ts.map +1 -0
- package/dist/lsp/diagnostic-deltas.js +92 -0
- package/dist/lsp/diagnostic-deltas.js.map +1 -0
- package/dist/lsp/diagnostic-repair.d.ts +48 -0
- package/dist/lsp/diagnostic-repair.d.ts.map +1 -0
- package/dist/lsp/diagnostic-repair.js +143 -0
- package/dist/lsp/diagnostic-repair.js.map +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +127 -37
- package/dist/main.js.map +1 -1
- package/dist/mcp/config.d.ts +4 -2
- package/dist/mcp/config.d.ts.map +1 -1
- package/dist/mcp/config.js +58 -14
- package/dist/mcp/config.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/manager.d.ts +1 -0
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +1 -0
- package/dist/mcp/manager.js.map +1 -1
- package/dist/mcp/platform-plugin.d.ts +3 -0
- package/dist/mcp/platform-plugin.d.ts.map +1 -0
- package/dist/mcp/platform-plugin.js +117 -0
- package/dist/mcp/platform-plugin.js.map +1 -0
- package/dist/mcp/tool-bridge.d.ts +15 -0
- package/dist/mcp/tool-bridge.d.ts.map +1 -1
- package/dist/mcp/tool-bridge.js +194 -6
- package/dist/mcp/tool-bridge.js.map +1 -1
- package/dist/memory/platform-memory-client.d.ts +130 -0
- package/dist/memory/platform-memory-client.d.ts.map +1 -0
- package/dist/memory/platform-memory-client.js +330 -0
- package/dist/memory/platform-memory-client.js.map +1 -0
- package/dist/memory/service-client.d.ts.map +1 -1
- package/dist/memory/service-client.js +1 -2
- package/dist/memory/service-client.js.map +1 -1
- package/dist/models/builtin.d.ts.map +1 -1
- package/dist/models/builtin.js +137 -0
- package/dist/models/builtin.js.map +1 -1
- package/dist/models/config-loader.d.ts +10 -10
- package/dist/models/config-loader.d.ts.map +1 -1
- package/dist/models/config-loader.js +1 -0
- package/dist/models/config-loader.js.map +1 -1
- package/dist/models/registry.d.ts +1 -0
- package/dist/models/registry.d.ts.map +1 -1
- package/dist/models/registry.js +1 -0
- package/dist/models/registry.js.map +1 -1
- package/dist/oauth/connectors.d.ts +25 -0
- package/dist/oauth/connectors.d.ts.map +1 -0
- package/dist/oauth/connectors.js +253 -0
- package/dist/oauth/connectors.js.map +1 -0
- package/dist/oauth/device-identity.d.ts +18 -0
- package/dist/oauth/device-identity.d.ts.map +1 -0
- package/dist/oauth/device-identity.js +193 -0
- package/dist/oauth/device-identity.js.map +1 -0
- package/dist/oauth/evalops.d.ts.map +1 -1
- package/dist/oauth/evalops.js +74 -15
- package/dist/oauth/evalops.js.map +1 -1
- package/dist/oauth/index.d.ts +1 -1
- package/dist/oauth/index.d.ts.map +1 -1
- package/dist/oauth/index.js +31 -1
- package/dist/oauth/index.js.map +1 -1
- package/dist/oauth/openai-codex.d.ts +16 -0
- package/dist/oauth/openai-codex.d.ts.map +1 -0
- package/dist/oauth/openai-codex.js +300 -0
- package/dist/oauth/openai-codex.js.map +1 -0
- package/dist/opentelemetry.d.ts.map +1 -1
- package/dist/opentelemetry.js +9 -2
- package/dist/opentelemetry.js.map +1 -1
- package/dist/platform/agent-runtime-client.d.ts +279 -0
- package/dist/platform/agent-runtime-client.d.ts.map +1 -0
- package/dist/platform/agent-runtime-client.js +515 -0
- package/dist/platform/agent-runtime-client.js.map +1 -0
- package/dist/platform/cerebro-facts-client.d.ts +56 -0
- package/dist/platform/cerebro-facts-client.d.ts.map +1 -0
- package/dist/platform/cerebro-facts-client.js +297 -0
- package/dist/platform/cerebro-facts-client.js.map +1 -0
- package/dist/platform/client.d.ts +2 -1
- package/dist/platform/client.d.ts.map +1 -1
- package/dist/platform/client.js +9 -26
- package/dist/platform/client.js.map +1 -1
- package/dist/platform/core-services.d.ts +128 -0
- package/dist/platform/core-services.d.ts.map +1 -1
- package/dist/platform/core-services.js +128 -0
- package/dist/platform/core-services.js.map +1 -1
- package/dist/platform/maestro-timeline-client.d.ts +22 -0
- package/dist/platform/maestro-timeline-client.d.ts.map +1 -0
- package/dist/platform/maestro-timeline-client.js +373 -0
- package/dist/platform/maestro-timeline-client.js.map +1 -0
- package/dist/platform/tool-execution-client.d.ts +104 -0
- package/dist/platform/tool-execution-client.d.ts.map +1 -0
- package/dist/platform/tool-execution-client.js +284 -0
- package/dist/platform/tool-execution-client.js.map +1 -0
- package/dist/prompts/service-client.d.ts.map +1 -1
- package/dist/prompts/service-client.js +5 -2
- package/dist/prompts/service-client.js.map +1 -1
- package/dist/providers/anthropic-auth.d.ts.map +1 -1
- package/dist/providers/anthropic-auth.js +8 -6
- package/dist/providers/anthropic-auth.js.map +1 -1
- package/dist/providers/api-keys.d.ts +1 -0
- package/dist/providers/api-keys.d.ts.map +1 -1
- package/dist/providers/api-keys.js +5 -0
- package/dist/providers/api-keys.js.map +1 -1
- package/dist/providers/auth.d.ts +2 -1
- package/dist/providers/auth.d.ts.map +1 -1
- package/dist/providers/auth.js +26 -3
- package/dist/providers/auth.js.map +1 -1
- package/dist/remote-runner/attach-client.d.ts +41 -0
- package/dist/remote-runner/attach-client.d.ts.map +1 -0
- package/dist/remote-runner/attach-client.js +692 -0
- package/dist/remote-runner/attach-client.js.map +1 -0
- package/dist/remote-runner/client.d.ts +205 -0
- package/dist/remote-runner/client.d.ts.map +1 -0
- package/dist/remote-runner/client.js +633 -0
- package/dist/remote-runner/client.js.map +1 -0
- package/dist/safety/action-firewall.d.ts +6 -1
- package/dist/safety/action-firewall.d.ts.map +1 -1
- package/dist/safety/action-firewall.js +62 -26
- package/dist/safety/action-firewall.js.map +1 -1
- package/dist/safety/governance-service-client.d.ts +36 -0
- package/dist/safety/governance-service-client.d.ts.map +1 -0
- package/dist/safety/governance-service-client.js +279 -0
- package/dist/safety/governance-service-client.js.map +1 -0
- package/dist/safety/policy.d.ts +13 -2
- package/dist/safety/policy.d.ts.map +1 -1
- package/dist/safety/policy.js +474 -52
- package/dist/safety/policy.js.map +1 -1
- package/dist/sdk-tools.d.ts +21 -0
- package/dist/sdk-tools.d.ts.map +1 -1
- package/dist/sdk-tools.js +16 -0
- package/dist/sdk-tools.js.map +1 -1
- package/dist/server/app-context.d.ts +25 -0
- package/dist/server/app-context.d.ts.map +1 -1
- package/dist/server/app-context.js.map +1 -1
- package/dist/server/approval-service.d.ts +7 -8
- package/dist/server/approval-service.d.ts.map +1 -1
- package/dist/server/approval-service.js +12 -24
- package/dist/server/approval-service.js.map +1 -1
- package/dist/server/authz.d.ts +23 -2
- package/dist/server/authz.d.ts.map +1 -1
- package/dist/server/authz.js +153 -17
- package/dist/server/authz.js.map +1 -1
- package/dist/server/handlers/approvals.d.ts.map +1 -1
- package/dist/server/handlers/approvals.js +3 -10
- package/dist/server/handlers/approvals.js.map +1 -1
- package/dist/server/handlers/branch.d.ts.map +1 -1
- package/dist/server/handlers/branch.js +29 -20
- package/dist/server/handlers/branch.js.map +1 -1
- package/dist/server/handlers/bridge.d.ts.map +1 -1
- package/dist/server/handlers/bridge.js +3 -2
- package/dist/server/handlers/bridge.js.map +1 -1
- package/dist/server/handlers/chat-ws.d.ts.map +1 -1
- package/dist/server/handlers/chat-ws.js +23 -31
- package/dist/server/handlers/chat-ws.js.map +1 -1
- package/dist/server/handlers/chat.d.ts.map +1 -1
- package/dist/server/handlers/chat.js +105 -46
- package/dist/server/handlers/chat.js.map +1 -1
- package/dist/server/handlers/compliance.d.ts +3 -0
- package/dist/server/handlers/compliance.d.ts.map +1 -0
- package/dist/server/handlers/compliance.js +53 -0
- package/dist/server/handlers/compliance.js.map +1 -0
- package/dist/server/handlers/context.d.ts.map +1 -1
- package/dist/server/handlers/context.js +3 -8
- package/dist/server/handlers/context.js.map +1 -1
- package/dist/server/handlers/fleet.d.ts +4 -0
- package/dist/server/handlers/fleet.d.ts.map +1 -0
- package/dist/server/handlers/fleet.js +9 -0
- package/dist/server/handlers/fleet.js.map +1 -0
- package/dist/server/handlers/headless-sessions.d.ts +4 -0
- package/dist/server/handlers/headless-sessions.d.ts.map +1 -1
- package/dist/server/handlers/headless-sessions.js +168 -3
- package/dist/server/handlers/headless-sessions.js.map +1 -1
- package/dist/server/handlers/health.d.ts +31 -2
- package/dist/server/handlers/health.d.ts.map +1 -1
- package/dist/server/handlers/health.js +82 -8
- package/dist/server/handlers/health.js.map +1 -1
- package/dist/server/handlers/hosted-runner-drain.d.ts +128 -0
- package/dist/server/handlers/hosted-runner-drain.d.ts.map +1 -0
- package/dist/server/handlers/hosted-runner-drain.js +373 -0
- package/dist/server/handlers/hosted-runner-drain.js.map +1 -0
- package/dist/server/handlers/hosted-runner-identity.d.ts +17 -0
- package/dist/server/handlers/hosted-runner-identity.d.ts.map +1 -0
- package/dist/server/handlers/hosted-runner-identity.js +39 -0
- package/dist/server/handlers/hosted-runner-identity.js.map +1 -0
- package/dist/server/handlers/intelligent-router.d.ts +3 -0
- package/dist/server/handlers/intelligent-router.d.ts.map +1 -0
- package/dist/server/handlers/intelligent-router.js +141 -0
- package/dist/server/handlers/intelligent-router.js.map +1 -0
- package/dist/server/handlers/models.d.ts.map +1 -1
- package/dist/server/handlers/models.js +14 -0
- package/dist/server/handlers/models.js.map +1 -1
- package/dist/server/handlers/pending-requests.d.ts +8 -0
- package/dist/server/handlers/pending-requests.d.ts.map +1 -0
- package/dist/server/handlers/pending-requests.js +149 -0
- package/dist/server/handlers/pending-requests.js.map +1 -0
- package/dist/server/handlers/revenue-attribution.d.ts +3 -0
- package/dist/server/handlers/revenue-attribution.d.ts.map +1 -0
- package/dist/server/handlers/revenue-attribution.js +45 -0
- package/dist/server/handlers/revenue-attribution.js.map +1 -0
- package/dist/server/handlers/runtime-app-server-ws.d.ts +10 -0
- package/dist/server/handlers/runtime-app-server-ws.d.ts.map +1 -0
- package/dist/server/handlers/runtime-app-server-ws.js +206 -0
- package/dist/server/handlers/runtime-app-server-ws.js.map +1 -0
- package/dist/server/handlers/session-artifacts.js +2 -2
- package/dist/server/handlers/session-artifacts.js.map +1 -1
- package/dist/server/handlers/session-attachments.js +3 -3
- package/dist/server/handlers/session-attachments.js.map +1 -1
- package/dist/server/handlers/session-timeline.d.ts +11 -0
- package/dist/server/handlers/session-timeline.d.ts.map +1 -0
- package/dist/server/handlers/session-timeline.js +77 -0
- package/dist/server/handlers/session-timeline.js.map +1 -0
- package/dist/server/handlers/sessions.d.ts +11 -0
- package/dist/server/handlers/sessions.d.ts.map +1 -1
- package/dist/server/handlers/sessions.js +68 -100
- package/dist/server/handlers/sessions.js.map +1 -1
- package/dist/server/handlers/traces.d.ts +3 -0
- package/dist/server/handlers/traces.d.ts.map +1 -0
- package/dist/server/handlers/traces.js +60 -0
- package/dist/server/handlers/traces.js.map +1 -0
- package/dist/server/handlers/usage-analytics.d.ts +3 -0
- package/dist/server/handlers/usage-analytics.d.ts.map +1 -0
- package/dist/server/handlers/usage-analytics.js +40 -0
- package/dist/server/handlers/usage-analytics.js.map +1 -0
- package/dist/server/handlers/workspace-config.d.ts +3 -0
- package/dist/server/handlers/workspace-config.d.ts.map +1 -0
- package/dist/server/handlers/workspace-config.js +62 -0
- package/dist/server/handlers/workspace-config.js.map +1 -0
- package/dist/server/headless-in-process-host.d.ts +8 -1
- package/dist/server/headless-in-process-host.d.ts.map +1 -1
- package/dist/server/headless-in-process-host.js +6 -0
- package/dist/server/headless-in-process-host.js.map +1 -1
- package/dist/server/headless-runtime-service.d.ts +99 -1
- package/dist/server/headless-runtime-service.d.ts.map +1 -1
- package/dist/server/headless-runtime-service.js +286 -23
- package/dist/server/headless-runtime-service.js.map +1 -1
- package/dist/server/hosted-session-manager.d.ts +103 -0
- package/dist/server/hosted-session-manager.d.ts.map +1 -0
- package/dist/server/hosted-session-manager.js +629 -0
- package/dist/server/hosted-session-manager.js.map +1 -0
- package/dist/server/pending-request-payload.d.ts +4 -0
- package/dist/server/pending-request-payload.d.ts.map +1 -0
- package/dist/server/pending-request-payload.js +107 -0
- package/dist/server/pending-request-payload.js.map +1 -0
- package/dist/server/request-context.d.ts +4 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js +9 -0
- package/dist/server/request-context.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +149 -1
- package/dist/server/routes.js.map +1 -1
- package/dist/server/runtime-ws-access.d.ts +16 -0
- package/dist/server/runtime-ws-access.d.ts.map +1 -0
- package/dist/server/runtime-ws-access.js +21 -0
- package/dist/server/runtime-ws-access.js.map +1 -0
- package/dist/server/server-middlewares.d.ts +1 -1
- package/dist/server/server-middlewares.d.ts.map +1 -1
- package/dist/server/server-middlewares.js +35 -27
- package/dist/server/server-middlewares.js.map +1 -1
- package/dist/server/server-request-manager.d.ts +8 -27
- package/dist/server/server-request-manager.d.ts.map +1 -1
- package/dist/server/server-request-manager.js +7 -0
- package/dist/server/server-request-manager.js.map +1 -1
- package/dist/server/server-utils.d.ts +2 -1
- package/dist/server/server-utils.d.ts.map +1 -1
- package/dist/server/server-utils.js +11 -1
- package/dist/server/server-utils.js.map +1 -1
- package/dist/server/session-event-env.d.ts +2 -0
- package/dist/server/session-event-env.d.ts.map +1 -0
- package/dist/server/session-event-env.js +8 -0
- package/dist/server/session-event-env.js.map +1 -0
- package/dist/server/session-initialization.d.ts +25 -4
- package/dist/server/session-initialization.d.ts.map +1 -1
- package/dist/server/session-initialization.js +22 -5
- package/dist/server/session-initialization.js.map +1 -1
- package/dist/server/session-scope.d.ts +4 -0
- package/dist/server/session-scope.d.ts.map +1 -1
- package/dist/server/session-scope.js +44 -4
- package/dist/server/session-scope.js.map +1 -1
- package/dist/server/session-timeline.d.ts +13 -0
- package/dist/server/session-timeline.d.ts.map +1 -0
- package/dist/server/session-timeline.js +566 -0
- package/dist/server/session-timeline.js.map +1 -0
- package/dist/services/compliance/controls.d.ts +6 -0
- package/dist/services/compliance/controls.d.ts.map +1 -0
- package/dist/services/compliance/controls.js +113 -0
- package/dist/services/compliance/controls.js.map +1 -0
- package/dist/services/compliance/index.d.ts +6 -0
- package/dist/services/compliance/index.d.ts.map +1 -0
- package/dist/services/compliance/index.js +5 -0
- package/dist/services/compliance/index.js.map +1 -0
- package/dist/services/compliance/normalize.d.ts +23 -0
- package/dist/services/compliance/normalize.d.ts.map +1 -0
- package/dist/services/compliance/normalize.js +226 -0
- package/dist/services/compliance/normalize.js.map +1 -0
- package/dist/services/compliance/recorder.d.ts +22 -0
- package/dist/services/compliance/recorder.d.ts.map +1 -0
- package/dist/services/compliance/recorder.js +89 -0
- package/dist/services/compliance/recorder.js.map +1 -0
- package/dist/services/compliance/service.d.ts +24 -0
- package/dist/services/compliance/service.d.ts.map +1 -0
- package/dist/services/compliance/service.js +426 -0
- package/dist/services/compliance/service.js.map +1 -0
- package/dist/services/compliance/types.d.ts +185 -0
- package/dist/services/compliance/types.d.ts.map +1 -0
- package/dist/services/compliance/types.js +2 -0
- package/dist/services/compliance/types.js.map +1 -0
- package/dist/services/intelligent-router/index.d.ts +5 -0
- package/dist/services/intelligent-router/index.d.ts.map +1 -0
- package/dist/services/intelligent-router/index.js +5 -0
- package/dist/services/intelligent-router/index.js.map +1 -0
- package/dist/services/intelligent-router/normalize.d.ts +9 -0
- package/dist/services/intelligent-router/normalize.d.ts.map +1 -0
- package/dist/services/intelligent-router/normalize.js +169 -0
- package/dist/services/intelligent-router/normalize.js.map +1 -0
- package/dist/services/intelligent-router/recorder.d.ts +24 -0
- package/dist/services/intelligent-router/recorder.d.ts.map +1 -0
- package/dist/services/intelligent-router/recorder.js +98 -0
- package/dist/services/intelligent-router/recorder.js.map +1 -0
- package/dist/services/intelligent-router/service.d.ts +22 -0
- package/dist/services/intelligent-router/service.d.ts.map +1 -0
- package/dist/services/intelligent-router/service.js +328 -0
- package/dist/services/intelligent-router/service.js.map +1 -0
- package/dist/services/intelligent-router/types.d.ts +98 -0
- package/dist/services/intelligent-router/types.d.ts.map +1 -0
- package/dist/services/intelligent-router/types.js +7 -0
- package/dist/services/intelligent-router/types.js.map +1 -0
- package/dist/services/revenue-attribution/index.d.ts +4 -0
- package/dist/services/revenue-attribution/index.d.ts.map +1 -0
- package/dist/services/revenue-attribution/index.js +4 -0
- package/dist/services/revenue-attribution/index.js.map +1 -0
- package/dist/services/revenue-attribution/normalize.d.ts +13 -0
- package/dist/services/revenue-attribution/normalize.d.ts.map +1 -0
- package/dist/services/revenue-attribution/normalize.js +155 -0
- package/dist/services/revenue-attribution/normalize.js.map +1 -0
- package/dist/services/revenue-attribution/service.d.ts +21 -0
- package/dist/services/revenue-attribution/service.d.ts.map +1 -0
- package/dist/services/revenue-attribution/service.js +248 -0
- package/dist/services/revenue-attribution/service.js.map +1 -0
- package/dist/services/revenue-attribution/types.d.ts +96 -0
- package/dist/services/revenue-attribution/types.d.ts.map +1 -0
- package/dist/services/revenue-attribution/types.js +7 -0
- package/dist/services/revenue-attribution/types.js.map +1 -0
- package/dist/services/traces/index.d.ts +5 -0
- package/dist/services/traces/index.d.ts.map +1 -0
- package/dist/services/traces/index.js +4 -0
- package/dist/services/traces/index.js.map +1 -0
- package/dist/services/traces/normalize.d.ts +20 -0
- package/dist/services/traces/normalize.d.ts.map +1 -0
- package/dist/services/traces/normalize.js +261 -0
- package/dist/services/traces/normalize.js.map +1 -0
- package/dist/services/traces/otel.d.ts +3 -0
- package/dist/services/traces/otel.d.ts.map +1 -0
- package/dist/services/traces/otel.js +173 -0
- package/dist/services/traces/otel.js.map +1 -0
- package/dist/services/traces/service.d.ts +17 -0
- package/dist/services/traces/service.d.ts.map +1 -0
- package/dist/services/traces/service.js +197 -0
- package/dist/services/traces/service.js.map +1 -0
- package/dist/services/traces/types.d.ts +130 -0
- package/dist/services/traces/types.d.ts.map +1 -0
- package/dist/services/traces/types.js +8 -0
- package/dist/services/traces/types.js.map +1 -0
- package/dist/services/usage-analytics/aggregation.d.ts +18 -0
- package/dist/services/usage-analytics/aggregation.d.ts.map +1 -0
- package/dist/services/usage-analytics/aggregation.js +130 -0
- package/dist/services/usage-analytics/aggregation.js.map +1 -0
- package/dist/services/usage-analytics/index.d.ts +5 -0
- package/dist/services/usage-analytics/index.d.ts.map +1 -0
- package/dist/services/usage-analytics/index.js +4 -0
- package/dist/services/usage-analytics/index.js.map +1 -0
- package/dist/services/usage-analytics/recorder.d.ts +16 -0
- package/dist/services/usage-analytics/recorder.d.ts.map +1 -0
- package/dist/services/usage-analytics/recorder.js +128 -0
- package/dist/services/usage-analytics/recorder.js.map +1 -0
- package/dist/services/usage-analytics/service.d.ts +15 -0
- package/dist/services/usage-analytics/service.d.ts.map +1 -0
- package/dist/services/usage-analytics/service.js +210 -0
- package/dist/services/usage-analytics/service.js.map +1 -0
- package/dist/services/usage-analytics/types.d.ts +80 -0
- package/dist/services/usage-analytics/types.d.ts.map +1 -0
- package/dist/services/usage-analytics/types.js +2 -0
- package/dist/services/usage-analytics/types.js.map +1 -0
- package/dist/services/workspace-config/index.d.ts +6 -0
- package/dist/services/workspace-config/index.d.ts.map +1 -0
- package/dist/services/workspace-config/index.js +5 -0
- package/dist/services/workspace-config/index.js.map +1 -0
- package/dist/services/workspace-config/middleware.d.ts +5 -0
- package/dist/services/workspace-config/middleware.d.ts.map +1 -0
- package/dist/services/workspace-config/middleware.js +98 -0
- package/dist/services/workspace-config/middleware.js.map +1 -0
- package/dist/services/workspace-config/normalize.d.ts +17 -0
- package/dist/services/workspace-config/normalize.d.ts.map +1 -0
- package/dist/services/workspace-config/normalize.js +148 -0
- package/dist/services/workspace-config/normalize.js.map +1 -0
- package/dist/services/workspace-config/policy.d.ts +16 -0
- package/dist/services/workspace-config/policy.d.ts.map +1 -0
- package/dist/services/workspace-config/policy.js +77 -0
- package/dist/services/workspace-config/policy.js.map +1 -0
- package/dist/services/workspace-config/service.d.ts +20 -0
- package/dist/services/workspace-config/service.d.ts.map +1 -0
- package/dist/services/workspace-config/service.js +162 -0
- package/dist/services/workspace-config/service.js.map +1 -0
- package/dist/services/workspace-config/types.d.ts +71 -0
- package/dist/services/workspace-config/types.d.ts.map +1 -0
- package/dist/services/workspace-config/types.js +2 -0
- package/dist/services/workspace-config/types.js.map +1 -0
- package/dist/session/manager.d.ts.map +1 -1
- package/dist/session/manager.js +10 -0
- package/dist/session/manager.js.map +1 -1
- package/dist/session/migration.d.ts.map +1 -1
- package/dist/session/migration.js +2 -1
- package/dist/session/migration.js.map +1 -1
- package/dist/session/session-memory.d.ts.map +1 -1
- package/dist/session/session-memory.js +7 -1
- package/dist/session/session-memory.js.map +1 -1
- package/dist/session/types.d.ts +1 -2
- package/dist/session/types.d.ts.map +1 -1
- package/dist/session/types.js +1 -22
- package/dist/session/types.js.map +1 -1
- package/dist/session/wire-format.d.ts +7 -0
- package/dist/session/wire-format.d.ts.map +1 -0
- package/dist/session/wire-format.generated.d.ts +95 -0
- package/dist/session/wire-format.generated.d.ts.map +1 -0
- package/dist/session/wire-format.generated.js +111 -0
- package/dist/session/wire-format.generated.js.map +1 -0
- package/dist/session/wire-format.js +145 -0
- package/dist/session/wire-format.js.map +1 -0
- package/dist/shared-memory/client.d.ts.map +1 -1
- package/dist/shared-memory/client.js +22 -22
- package/dist/shared-memory/client.js.map +1 -1
- package/dist/skills/artifact-metadata.d.ts +16 -0
- package/dist/skills/artifact-metadata.d.ts.map +1 -0
- package/dist/skills/artifact-metadata.js +86 -0
- package/dist/skills/artifact-metadata.js.map +1 -0
- package/dist/skills/loader.d.ts +2 -2
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +1 -0
- package/dist/skills/loader.js.map +1 -1
- package/dist/skills/service-client.d.ts +42 -0
- package/dist/skills/service-client.d.ts.map +1 -0
- package/dist/skills/service-client.js +258 -0
- package/dist/skills/service-client.js.map +1 -0
- package/dist/skills/tool.d.ts +3 -0
- package/dist/skills/tool.d.ts.map +1 -1
- package/dist/skills/tool.js +67 -5
- package/dist/skills/tool.js.map +1 -1
- package/dist/telemetry/index.d.ts +4 -0
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +5 -0
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/maestro-event-bus.d.ts +440 -0
- package/dist/telemetry/maestro-event-bus.d.ts.map +1 -0
- package/dist/telemetry/maestro-event-bus.js +784 -0
- package/dist/telemetry/maestro-event-bus.js.map +1 -0
- package/dist/telemetry/maestro-event-catalog.d.ts +48 -0
- package/dist/telemetry/maestro-event-catalog.d.ts.map +1 -0
- package/dist/telemetry/maestro-event-catalog.js +69 -0
- package/dist/telemetry/maestro-event-catalog.js.map +1 -0
- package/dist/telemetry/maestro-platform-replay-fixture.d.ts +24 -0
- package/dist/telemetry/maestro-platform-replay-fixture.d.ts.map +1 -0
- package/dist/telemetry/maestro-platform-replay-fixture.js +400 -0
- package/dist/telemetry/maestro-platform-replay-fixture.js.map +1 -0
- package/dist/telemetry/maestro-publisher-conformance-fixture.d.ts +29 -0
- package/dist/telemetry/maestro-publisher-conformance-fixture.d.ts.map +1 -0
- package/dist/telemetry/maestro-publisher-conformance-fixture.js +240 -0
- package/dist/telemetry/maestro-publisher-conformance-fixture.js.map +1 -0
- package/dist/telemetry/meter-service-client.d.ts +0 -33
- package/dist/telemetry/meter-service-client.d.ts.map +1 -1
- package/dist/telemetry/meter-service-client.js +22 -50
- package/dist/telemetry/meter-service-client.js.map +1 -1
- package/dist/telemetry/turn-tracker.d.ts.map +1 -1
- package/dist/telemetry/turn-tracker.js +5 -5
- package/dist/telemetry/turn-tracker.js.map +1 -1
- package/dist/telemetry/wide-events.d.ts +8 -0
- package/dist/telemetry/wide-events.d.ts.map +1 -1
- package/dist/telemetry/wide-events.js +28 -0
- package/dist/telemetry/wide-events.js.map +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +14 -4
- package/dist/telemetry.js.map +1 -1
- package/dist/timeline/redaction.d.ts +5 -0
- package/dist/timeline/redaction.d.ts.map +1 -0
- package/dist/timeline/redaction.js +119 -0
- package/dist/timeline/redaction.js.map +1 -0
- package/dist/tools/ask-user.d.ts +26 -0
- package/dist/tools/ask-user.d.ts.map +1 -1
- package/dist/tools/ask-user.js +33 -1
- package/dist/tools/ask-user.js.map +1 -1
- package/dist/tools/background/task-types.d.ts +1 -1
- package/dist/tools/edit.d.ts +2 -0
- package/dist/tools/edit.d.ts.map +1 -1
- package/dist/tools/edit.js +27 -7
- package/dist/tools/edit.js.map +1 -1
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/pipeline.d.ts.map +1 -1
- package/dist/tools/pipeline.js +16 -7
- package/dist/tools/pipeline.js.map +1 -1
- package/dist/tools/write.d.ts +2 -0
- package/dist/tools/write.d.ts.map +1 -1
- package/dist/tools/write.js +24 -6
- package/dist/tools/write.js.map +1 -1
- package/dist/tracking/cost-tracker.d.ts +15 -12
- package/dist/tracking/cost-tracker.d.ts.map +1 -1
- package/dist/tracking/cost-tracker.js +29 -40
- package/dist/tracking/cost-tracker.js.map +1 -1
- package/dist/utils/checkpoint-profiler.d.ts +29 -0
- package/dist/utils/checkpoint-profiler.d.ts.map +1 -0
- package/dist/utils/checkpoint-profiler.js +118 -0
- package/dist/utils/checkpoint-profiler.js.map +1 -0
- package/dist/utils/downstream-http.d.ts +21 -0
- package/dist/utils/downstream-http.d.ts.map +1 -0
- package/dist/utils/downstream-http.js +151 -0
- package/dist/utils/downstream-http.js.map +1 -0
- package/dist/utils/downstream.d.ts +18 -0
- package/dist/utils/downstream.d.ts.map +1 -0
- package/dist/utils/downstream.js +47 -0
- package/dist/utils/downstream.js.map +1 -0
- package/dist/utils/logger.d.ts +3 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +12 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/oauth-http.d.ts +8 -0
- package/dist/utils/oauth-http.d.ts.map +1 -0
- package/dist/utils/oauth-http.js +41 -0
- package/dist/utils/oauth-http.js.map +1 -0
- package/dist/utils/path-utils.d.ts +2 -0
- package/dist/utils/path-utils.d.ts.map +1 -0
- package/dist/utils/path-utils.js +12 -0
- package/dist/utils/path-utils.js.map +1 -0
- package/dist/utils/path-validation.d.ts +1 -1
- package/dist/utils/path-validation.d.ts.map +1 -1
- package/dist/utils/path-validation.js +3 -3
- package/dist/utils/path-validation.js.map +1 -1
- package/dist/version.json +2 -2
- package/dist/web-server.d.ts +7 -1
- package/dist/web-server.d.ts.map +1 -1
- package/dist/web-server.js +117 -15
- package/dist/web-server.js.map +1 -1
- package/dist/webhooks/delivery.d.ts.map +1 -1
- package/dist/webhooks/delivery.js +9 -12
- package/dist/webhooks/delivery.js.map +1 -1
- package/node_modules/@bufbuild/protobuf/dist/cjs/descriptors.d.ts +12 -5
- package/node_modules/@bufbuild/protobuf/dist/cjs/from-binary.js +7 -7
- package/node_modules/@bufbuild/protobuf/dist/cjs/from-json.d.ts +1 -1
- package/node_modules/@bufbuild/protobuf/dist/cjs/from-json.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/cjs/reflect/path.d.ts +1 -1
- package/node_modules/@bufbuild/protobuf/dist/cjs/registry.js +24 -1
- package/node_modules/@bufbuild/protobuf/dist/cjs/to-json.d.ts +1 -1
- package/node_modules/@bufbuild/protobuf/dist/cjs/to-json.js +9 -10
- package/node_modules/@bufbuild/protobuf/dist/cjs/types.d.ts +1 -1
- package/node_modules/@bufbuild/protobuf/dist/cjs/wire/binary-encoding.d.ts +9 -7
- package/node_modules/@bufbuild/protobuf/dist/cjs/wire/binary-encoding.js +18 -8
- package/node_modules/@bufbuild/protobuf/dist/cjs/wire/text-encoding.d.ts +4 -2
- package/node_modules/@bufbuild/protobuf/dist/cjs/wire/text-encoding.js +8 -1
- package/node_modules/@bufbuild/protobuf/dist/cjs/wkt/gen/google/protobuf/api_pb.d.ts +1 -1
- package/node_modules/@bufbuild/protobuf/dist/cjs/wkt/gen/google/protobuf/compiler/plugin_pb.d.ts +2 -2
- package/node_modules/@bufbuild/protobuf/dist/cjs/wkt/gen/google/protobuf/descriptor_pb.d.ts +37 -23
- package/node_modules/@bufbuild/protobuf/dist/cjs/wkt/gen/google/protobuf/descriptor_pb.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/cjs/wkt/gen/google/protobuf/field_mask_pb.d.ts +32 -36
- package/node_modules/@bufbuild/protobuf/dist/cjs/wkt/gen/google/protobuf/go_features_pb.d.ts +65 -0
- package/node_modules/@bufbuild/protobuf/dist/cjs/wkt/gen/google/protobuf/go_features_pb.js +38 -2
- package/node_modules/@bufbuild/protobuf/dist/cjs/wkt/gen/google/protobuf/timestamp_pb.d.ts +5 -5
- package/node_modules/@bufbuild/protobuf/dist/cjs/wkt/gen/google/protobuf/type_pb.d.ts +3 -3
- package/node_modules/@bufbuild/protobuf/dist/cjs/wkt/wrappers.d.ts +10 -0
- package/node_modules/@bufbuild/protobuf/dist/cjs/wkt/wrappers.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/descriptors.d.ts +12 -5
- package/node_modules/@bufbuild/protobuf/dist/esm/from-binary.js +7 -7
- package/node_modules/@bufbuild/protobuf/dist/esm/from-json.d.ts +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/from-json.js +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/path.d.ts +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/registry.js +24 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/to-json.d.ts +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/to-json.js +10 -11
- package/node_modules/@bufbuild/protobuf/dist/esm/types.d.ts +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.d.ts +9 -7
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js +18 -8
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.d.ts +4 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.js +8 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/api_pb.d.ts +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.d.ts +2 -2
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/descriptor_pb.d.ts +37 -23
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/descriptor_pb.js +1 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/field_mask_pb.d.ts +32 -36
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/go_features_pb.d.ts +65 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/go_features_pb.js +37 -1
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/timestamp_pb.d.ts +5 -5
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/type_pb.d.ts +3 -3
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/wrappers.d.ts +10 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/wrappers.js +23 -0
- package/node_modules/@bufbuild/protobuf/package.json +1 -1
- package/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.d.ts +305 -2
- package/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.d.ts.map +1 -1
- package/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.js +34 -4
- package/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.js.map +1 -1
- package/node_modules/@evalops/contracts/dist/index.d.ts +88 -0
- package/node_modules/@evalops/contracts/dist/index.d.ts.map +1 -1
- package/node_modules/@evalops/contracts/dist/index.js +2 -0
- package/node_modules/@evalops/contracts/dist/index.js.map +1 -1
- package/node_modules/@evalops/contracts/dist/proto/maestro/v1/headless_pb.d.ts +77 -77
- package/node_modules/@evalops/contracts/dist/proto/maestro/v1/headless_pb.d.ts.map +1 -1
- package/node_modules/@evalops/contracts/dist/proto/maestro/v1/headless_pb.js +1 -1
- package/node_modules/@evalops/contracts/dist/proto/maestro/v1/headless_pb.js.map +1 -1
- package/node_modules/@evalops/contracts/dist/runtime-app-server.d.ts +182 -0
- package/node_modules/@evalops/contracts/dist/runtime-app-server.d.ts.map +1 -0
- package/node_modules/@evalops/contracts/dist/runtime-app-server.js +83 -0
- package/node_modules/@evalops/contracts/dist/runtime-app-server.js.map +1 -0
- package/node_modules/@evalops/contracts/dist/runtime-server-request.d.ts +133 -0
- package/node_modules/@evalops/contracts/dist/runtime-server-request.d.ts.map +1 -0
- package/node_modules/@evalops/contracts/dist/runtime-server-request.js +68 -0
- package/node_modules/@evalops/contracts/dist/runtime-server-request.js.map +1 -0
- package/node_modules/@evalops/contracts/dist/schemas.d.ts +178 -0
- package/node_modules/@evalops/contracts/dist/schemas.d.ts.map +1 -1
- package/node_modules/@evalops/contracts/dist/schemas.js +165 -0
- package/node_modules/@evalops/contracts/dist/schemas.js.map +1 -1
- package/node_modules/@evalops/contracts/dist/typebox-utils.d.ts +2 -0
- package/node_modules/@evalops/contracts/dist/typebox-utils.d.ts.map +1 -0
- package/node_modules/@evalops/contracts/dist/typebox-utils.js +5 -0
- package/node_modules/@evalops/contracts/dist/typebox-utils.js.map +1 -0
- package/node_modules/@evalops/contracts/dist/validators.d.ts +4 -1
- package/node_modules/@evalops/contracts/dist/validators.d.ts.map +1 -1
- package/node_modules/@evalops/contracts/dist/validators.js +4 -1
- package/node_modules/@evalops/contracts/dist/validators.js.map +1 -1
- package/node_modules/@evalops/contracts/package.json +1 -1
- package/node_modules/@evalops/tui/package.json +1 -1
- package/node_modules/string-width/index.js +93 -9
- package/node_modules/string-width/package.json +1 -1
- package/package.json +32 -25
- package/dist/cli-tui/commands/grouped/auth-commands.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped/auth-commands.js.map +0 -1
- package/dist/cli-tui/commands/grouped/config-commands.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped/config-commands.js.map +0 -1
- package/dist/cli-tui/commands/grouped/diag-commands.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped/diag-commands.js.map +0 -1
- package/dist/cli-tui/commands/grouped/git-commands.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped/git-commands.js.map +0 -1
- package/dist/cli-tui/commands/grouped/index.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped/index.js.map +0 -1
- package/dist/cli-tui/commands/grouped/safety-commands.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped/safety-commands.js.map +0 -1
- package/dist/cli-tui/commands/grouped/session-commands.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped/session-commands.js.map +0 -1
- package/dist/cli-tui/commands/grouped/tools-commands.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped/tools-commands.js.map +0 -1
- package/dist/cli-tui/commands/grouped/ui-commands.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped/ui-commands.js.map +0 -1
- package/dist/cli-tui/commands/grouped/undo-commands.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped/undo-commands.js.map +0 -1
- package/dist/cli-tui/commands/grouped/usage-commands.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped/usage-commands.js.map +0 -1
- package/dist/cli-tui/commands/grouped/utils.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped/utils.js.map +0 -1
- package/dist/cli-tui/commands/grouped-command-handlers.d.ts.map +0 -1
- package/dist/cli-tui/commands/grouped-command-handlers.js +0 -135
- package/dist/cli-tui/commands/grouped-command-handlers.js.map +0 -1
- package/dist/cli-tui/tui-renderer/grouped-handlers-wiring.d.ts +0 -78
- package/dist/cli-tui/tui-renderer/grouped-handlers-wiring.d.ts.map +0 -1
- package/dist/cli-tui/tui-renderer/grouped-handlers-wiring.js +0 -129
- package/dist/cli-tui/tui-renderer/grouped-handlers-wiring.js.map +0 -1
- package/node_modules/@evalops/memory/dist/client.d.ts +0 -94
- package/node_modules/@evalops/memory/dist/client.js +0 -503
- package/node_modules/@evalops/memory/gen/proto/dist/memory/v1/memory_pb.d.ts +0 -608
- package/node_modules/@evalops/memory/gen/proto/dist/memory/v1/memory_pb.js +0 -187
- package/node_modules/@evalops/memory/package.json +0 -26
- /package/dist/cli-tui/commands/{grouped → subcommands}/usage-commands.d.ts +0 -0
package/dist/agent/transport.js
CHANGED
|
@@ -57,15 +57,48 @@ import { checkSessionLimits } from "../safety/policy.js";
|
|
|
57
57
|
import { createSafetyMiddleware, } from "../safety/safety-middleware.js";
|
|
58
58
|
import { SemanticJudge } from "../safety/semantic-judge.js";
|
|
59
59
|
import { WorkflowStateError, WorkflowStateTracker, applyWorkflowStateHooks, isWorkflowTrackedTool, } from "../safety/workflow-state.js";
|
|
60
|
+
import { getSkillArtifactMetadataFromDetails, } from "../skills/artifact-metadata.js";
|
|
60
61
|
import { getOptimalConcurrency } from "../tools/parallel-execution.js";
|
|
61
62
|
import { trackUsage } from "../tracking/cost-tracker.js";
|
|
62
63
|
import { getTrainingHeaders } from "../training.js";
|
|
63
64
|
import { getStoredCredentials } from "./keys.js";
|
|
64
65
|
import { createProviderStream } from "./transport/create-provider-stream.js";
|
|
66
|
+
import { getDefaultPlatformToolExecutionBridge, } from "./transport/tool-execution-bridge.js";
|
|
65
67
|
import { createToolExecutionPromise } from "./transport/tool-execution.js";
|
|
66
68
|
import { evaluateToolSafety, } from "./transport/tool-safety-pipeline.js";
|
|
67
69
|
import { createToolUpdateQueue, waitForNextExecutionOrUpdate, } from "./transport/tool-update-queue.js";
|
|
68
70
|
import { calculateCost, resolveEnvCredential, } from "./transport/transport-utils.js";
|
|
71
|
+
function getGovernedToolResultEventMetadata(details) {
|
|
72
|
+
if (!details || typeof details !== "object") {
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
const governedOutcome = details
|
|
76
|
+
.governedOutcome;
|
|
77
|
+
if (!governedOutcome || typeof governedOutcome !== "object") {
|
|
78
|
+
return {};
|
|
79
|
+
}
|
|
80
|
+
const normalized = governedOutcome;
|
|
81
|
+
const classification = typeof normalized.classification === "string"
|
|
82
|
+
? normalized.classification
|
|
83
|
+
: undefined;
|
|
84
|
+
const errorCode = typeof normalized.code === "string" && normalized.code.trim().length > 0
|
|
85
|
+
? normalized.code.trim()
|
|
86
|
+
: classification;
|
|
87
|
+
const approvalRequestId = typeof normalized.approvalRequestId === "string" &&
|
|
88
|
+
normalized.approvalRequestId.trim().length > 0
|
|
89
|
+
? normalized.approvalRequestId.trim()
|
|
90
|
+
: undefined;
|
|
91
|
+
return {
|
|
92
|
+
errorCode,
|
|
93
|
+
approvalRequestId,
|
|
94
|
+
governedOutcome: classification,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function getSkillToolResultEventMetadata(details) {
|
|
98
|
+
return {
|
|
99
|
+
skillMetadata: getSkillArtifactMetadataFromDetails(details),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
69
102
|
/**
|
|
70
103
|
* Provider Transport - Multi-provider LLM communication with safety controls
|
|
71
104
|
*
|
|
@@ -266,6 +299,7 @@ export class ProviderTransport {
|
|
|
266
299
|
authType: credential?.type ?? "api-key",
|
|
267
300
|
headers,
|
|
268
301
|
requestBody: credential?.requestBody,
|
|
302
|
+
sessionId: cfg.session?.id,
|
|
269
303
|
taskBudget: cfg.taskBudget,
|
|
270
304
|
};
|
|
271
305
|
let hasMoreToolCalls = true;
|
|
@@ -325,6 +359,7 @@ export class ProviderTransport {
|
|
|
325
359
|
let steeringAfterTools = null;
|
|
326
360
|
let pendingNextTurn = false;
|
|
327
361
|
let encounteredError = false;
|
|
362
|
+
let firstModelOutputSeen = false;
|
|
328
363
|
const currentMessages = cfg.preprocessMessages
|
|
329
364
|
? await cfg.preprocessMessages(allMessages, {
|
|
330
365
|
systemPrompt,
|
|
@@ -358,6 +393,9 @@ export class ProviderTransport {
|
|
|
358
393
|
await new Promise((resolve) => setTimeout(resolve, backoffMs));
|
|
359
394
|
}
|
|
360
395
|
streamAttempt++;
|
|
396
|
+
cfg.queryProfiler?.checkpoint("model:request:start", {
|
|
397
|
+
attempt: streamAttempt,
|
|
398
|
+
});
|
|
361
399
|
const stream = createProviderStream(model, currentContext, streamOptions, { reasoning: cfg.reasoning, reasoningSummary: cfg.reasoningSummary });
|
|
362
400
|
try {
|
|
363
401
|
for await (const event of stream) {
|
|
@@ -374,6 +412,10 @@ export class ProviderTransport {
|
|
|
374
412
|
if (event.type === "text_delta" ||
|
|
375
413
|
event.type === "thinking_delta" ||
|
|
376
414
|
event.type === "toolcall_delta") {
|
|
415
|
+
if (!firstModelOutputSeen) {
|
|
416
|
+
cfg.queryProfiler?.checkpoint("model:first-token");
|
|
417
|
+
firstModelOutputSeen = true;
|
|
418
|
+
}
|
|
377
419
|
if (currentAssistantMessage) {
|
|
378
420
|
yield {
|
|
379
421
|
type: "message_update",
|
|
@@ -384,6 +426,10 @@ export class ProviderTransport {
|
|
|
384
426
|
continue;
|
|
385
427
|
}
|
|
386
428
|
if (event.type === "toolcall_end") {
|
|
429
|
+
if (!firstModelOutputSeen) {
|
|
430
|
+
cfg.queryProfiler?.checkpoint("model:first-token");
|
|
431
|
+
firstModelOutputSeen = true;
|
|
432
|
+
}
|
|
387
433
|
const rawArgs = event.toolCall.arguments;
|
|
388
434
|
const normalizedArgs = rawArgs &&
|
|
389
435
|
typeof rawArgs === "object" &&
|
|
@@ -410,6 +456,7 @@ export class ProviderTransport {
|
|
|
410
456
|
if (credential?.type !== "anthropic-oauth") {
|
|
411
457
|
try {
|
|
412
458
|
trackUsage({
|
|
459
|
+
sessionId: cfg.session?.id,
|
|
413
460
|
provider: model.provider,
|
|
414
461
|
model: model.id,
|
|
415
462
|
tokensInput: usage.input || 0,
|
|
@@ -496,18 +543,28 @@ export class ProviderTransport {
|
|
|
496
543
|
steeringAfterTools = steering;
|
|
497
544
|
}
|
|
498
545
|
};
|
|
499
|
-
const buildExecutionEvents = (toolCall, message, isError) =>
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
type: "
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
546
|
+
const buildExecutionEvents = (toolCall, message, isError, metadata) => {
|
|
547
|
+
const governedMetadata = getGovernedToolResultEventMetadata(message.details);
|
|
548
|
+
const skillMetadata = getSkillToolResultEventMetadata(message.details).skillMetadata;
|
|
549
|
+
return [
|
|
550
|
+
{ type: "message_start", message },
|
|
551
|
+
{ type: "message_end", message },
|
|
552
|
+
{
|
|
553
|
+
type: "tool_execution_end",
|
|
554
|
+
toolCallId: toolCall.id,
|
|
555
|
+
toolExecutionId: metadata?.toolExecutionId,
|
|
556
|
+
approvalRequestId: metadata?.approvalRequestId ??
|
|
557
|
+
governedMetadata.approvalRequestId,
|
|
558
|
+
errorCode: governedMetadata.errorCode,
|
|
559
|
+
governedOutcome: governedMetadata.governedOutcome,
|
|
560
|
+
skillMetadata,
|
|
561
|
+
toolName: toolCall.name,
|
|
562
|
+
result: message,
|
|
563
|
+
isError,
|
|
564
|
+
},
|
|
565
|
+
];
|
|
566
|
+
};
|
|
567
|
+
const emitToolResult = (message, toolCall, isError, metadata) => {
|
|
511
568
|
try {
|
|
512
569
|
applyWorkflowStateHooks({
|
|
513
570
|
toolCall,
|
|
@@ -516,7 +573,7 @@ export class ProviderTransport {
|
|
|
516
573
|
isError,
|
|
517
574
|
});
|
|
518
575
|
toolResults.push(message);
|
|
519
|
-
return buildExecutionEvents(toolCall, message, isError);
|
|
576
|
+
return buildExecutionEvents(toolCall, message, isError, metadata);
|
|
520
577
|
}
|
|
521
578
|
catch (error) {
|
|
522
579
|
if (error instanceof WorkflowStateError) {
|
|
@@ -529,7 +586,7 @@ export class ProviderTransport {
|
|
|
529
586
|
timestamp: this.clock.now(),
|
|
530
587
|
};
|
|
531
588
|
toolResults.push(workflowErrorResult);
|
|
532
|
-
return buildExecutionEvents(toolCall, workflowErrorResult, true);
|
|
589
|
+
return buildExecutionEvents(toolCall, workflowErrorResult, true, metadata);
|
|
533
590
|
}
|
|
534
591
|
throw error;
|
|
535
592
|
}
|
|
@@ -571,7 +628,10 @@ export class ProviderTransport {
|
|
|
571
628
|
continue;
|
|
572
629
|
}
|
|
573
630
|
const outcome = next.outcome;
|
|
574
|
-
events.push(...emitToolResult(outcome.message, next.execution.toolCall, outcome.isError
|
|
631
|
+
events.push(...emitToolResult(outcome.message, next.execution.toolCall, outcome.isError, {
|
|
632
|
+
toolExecutionId: outcome.toolExecutionId,
|
|
633
|
+
approvalRequestId: outcome.approvalRequestId,
|
|
634
|
+
}));
|
|
575
635
|
await checkSteering();
|
|
576
636
|
break;
|
|
577
637
|
}
|
|
@@ -598,6 +658,10 @@ export class ProviderTransport {
|
|
|
598
658
|
adaptiveThresholds: this.adaptiveThresholds,
|
|
599
659
|
auditLogger: this.auditLogger,
|
|
600
660
|
approvalService: this.options.approvalService,
|
|
661
|
+
toolExecutionBridge: this.options.platformToolExecutionBridge === false
|
|
662
|
+
? undefined
|
|
663
|
+
: (this.options.platformToolExecutionBridge ??
|
|
664
|
+
getDefaultPlatformToolExecutionBridge()),
|
|
601
665
|
hookService,
|
|
602
666
|
firewall,
|
|
603
667
|
rateLimitState: {
|
|
@@ -667,6 +731,11 @@ export class ProviderTransport {
|
|
|
667
731
|
toolRetryService: this.options.toolRetryService,
|
|
668
732
|
toolRetryConfig: this.options.toolRetryConfig,
|
|
669
733
|
clientToolService: this.options.clientToolService,
|
|
734
|
+
toolExecutionBridge: this.options.platformToolExecutionBridge === false
|
|
735
|
+
? undefined
|
|
736
|
+
: (this.options.platformToolExecutionBridge ??
|
|
737
|
+
getDefaultPlatformToolExecutionBridge()),
|
|
738
|
+
toolExecutionBridgePlan: safetyVerdict.toolExecutionBridgePlan,
|
|
670
739
|
toolUpdateQueue,
|
|
671
740
|
clientToolExecPromise,
|
|
672
741
|
});
|
|
@@ -690,7 +759,10 @@ export class ProviderTransport {
|
|
|
690
759
|
continue;
|
|
691
760
|
}
|
|
692
761
|
const outcome = next.outcome;
|
|
693
|
-
for (const event of emitToolResult(outcome.message, next.execution.toolCall, outcome.isError
|
|
762
|
+
for (const event of emitToolResult(outcome.message, next.execution.toolCall, outcome.isError, {
|
|
763
|
+
toolExecutionId: outcome.toolExecutionId,
|
|
764
|
+
approvalRequestId: outcome.approvalRequestId,
|
|
765
|
+
})) {
|
|
694
766
|
yield event;
|
|
695
767
|
}
|
|
696
768
|
await checkSteering();
|
|
@@ -762,6 +834,14 @@ export class ProviderTransport {
|
|
|
762
834
|
pendingNextTurn = true;
|
|
763
835
|
}
|
|
764
836
|
hasMoreToolCalls = encounteredError ? false : pendingNextTurn;
|
|
837
|
+
if (encounteredError) {
|
|
838
|
+
cfg.queryProfiler?.terminal("turn:error");
|
|
839
|
+
}
|
|
840
|
+
else if (!hasMoreToolCalls) {
|
|
841
|
+
cfg.queryProfiler?.terminal("turn:complete", {
|
|
842
|
+
tool_results: toolResults.length,
|
|
843
|
+
});
|
|
844
|
+
}
|
|
765
845
|
}
|
|
766
846
|
}
|
|
767
847
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/agent/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAE,gCAAgC,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAwB,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAc,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAEN,sBAAsB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACN,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CA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AC;gBAChC,MAAM,QAAQ,GAAG,MAAM,mBAAmB,EAAc,CAAC;gBACzD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACzB,eAAe,GAAG,QAAQ,CAAC;gBAC5B,CAAC;YACF,CAAC;YAED,IACC,CAAC,eAAe;gBAChB,eAAe,CAAC,MAAM,KAAK,CAAC;gBAC5B,mBAAmB,EAClB,CAAC;gBACF,MAAM,SAAS,GAAG,MAAM,mBAAmB,EAAc,CAAC;gBAC1D,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC1B,eAAe,GAAG,SAAS,CAAC;gBAC7B,CAAC;YACF,CAAC;YAED,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChC,eAAe,GAAG,IAAI,CAAC;YACxB,CAAC;YAED,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC;QAC/D,CAAC;IACF,CAAC","sourcesContent":["/**\n * Agent Transport Layer - LLM Communication and Tool Execution Orchestration\n *\n * This module is the heart of the agent's execution loop. It handles:\n * 1. Streaming communication with LLM providers (Anthropic, OpenAI, Google)\n * 2. Concurrent tool execution with configurable parallelism\n * 3. Safety enforcement via action firewall integration\n * 4. Hook system integration for tool lifecycle events\n *\n * ## Architecture Overview\n *\n * ```\n * User Message → Transport.run() → Provider Stream → Parse Tool Calls\n * ↓ ↓\n * Emit Turn Events ←── Tool Results ←── Execute Tools\n * ↓ ↑\n * Continue Loop ───────────────────────────────┘\n * ```\n *\n * ## Concurrent Tool Execution\n *\n * When the LLM returns multiple tool calls in a single response, we execute\n * them concurrently up to `maxConcurrentToolExecutions` limit. This improves\n * latency for independent operations (e.g., reading multiple files).\n *\n * However, tools that affect WorkflowStateTracker (PII tracking) are serialized\n * to maintain consistent state ordering. A warning is logged when this happens.\n *\n * ## Safety Integration Points\n *\n * 1. **Pre-execution**: Action firewall evaluates each tool call\n * 2. **Approval flow**: Dangerous actions trigger user approval\n * 3. **PII tracking**: WorkflowState hooks track data flow for egress prevention\n * 4. **Doom loop detection**: Identical consecutive tool calls are blocked\n * 5. **Rate limiting**: Per-tool rate limits prevent runaway execution\n *\n * ## Event Stream\n *\n * The transport yields AgentEvents that drive the UI:\n * - turn_start/end: Turn boundaries for UI state management\n * - message_start/update/end: Streaming content updates\n * - tool_execution_start/end: Tool lifecycle for progress display\n * - action_approval_required/resolved: Approval UI triggers\n *\n * @module agent/transport\n */\n\nimport { isContextFirewallBlockingEnabled } from \"../config/env-vars.js\";\nimport { type ToolHookService, createToolHookService } from \"../hooks/index.js\";\nimport { getProviderNetworkConfig } from \"../providers/network-config.js\";\nimport { isStreamIdleTimeoutError } from \"../providers/stream-idle-timeout.js\";\nimport { type Clock, systemClock } from \"../utils/clock.js\";\nimport { createLogger } from \"../utils/logger.js\";\n\nconst logger = createLogger(\"transport\");\nimport type { AuthCredential } from \"../providers/auth.js\";\nimport { defaultActionFirewall } from \"../safety/action-firewall.js\";\nimport { AdaptiveThresholds } from \"../safety/adaptive-thresholds.js\";\nimport { checkSessionLimits } from \"../safety/policy.js\";\nimport {\n\ttype SafetyMiddleware,\n\tcreateSafetyMiddleware,\n} from \"../safety/safety-middleware.js\";\nimport { SemanticJudge } from \"../safety/semantic-judge.js\";\nimport {\n\tWorkflowStateError,\n\tWorkflowStateTracker,\n\tapplyWorkflowStateHooks,\n\tisWorkflowTrackedTool,\n} from \"../safety/workflow-state.js\";\nimport { getOptimalConcurrency } from \"../tools/parallel-execution.js\";\nimport { trackUsage } from \"../tracking/cost-tracker.js\";\nimport { getTrainingHeaders } from \"../training.js\";\nimport type { ActionApprovalService } from \"./action-approval.js\";\nimport { getStoredCredentials } from \"./keys.js\";\nimport type { ToolRetryConfig, ToolRetryService } from \"./tool-retry.js\";\nimport { createProviderStream } from \"./transport/create-provider-stream.js\";\nimport { createToolExecutionPromise } from \"./transport/tool-execution.js\";\nimport {\n\ttype ToolSafetyVerdict,\n\tevaluateToolSafety,\n} from \"./transport/tool-safety-pipeline.js\";\nimport {\n\ttype PendingExecution,\n\tcreateToolUpdateQueue,\n\twaitForNextExecutionOrUpdate,\n} from \"./transport/tool-update-queue.js\";\nimport {\n\ttype SessionTokenCounter,\n\ttype ToolAuditLogger,\n\tcalculateCost,\n\tresolveEnvCredential,\n} from \"./transport/transport-utils.js\";\nimport type {\n\tAgentEvent,\n\tAgentRunConfig,\n\tAgentToolResult,\n\tAgentTransport,\n\tAppMessage,\n\tAssistantMessage,\n\tMessage,\n\tQueuedMessage,\n\tToolCall,\n\tToolResultMessage,\n} from \"./types.js\";\n\n// Re-export types for backward compatibility\nexport type {\n\tSessionTokenCounter,\n\tToolAuditLogger,\n} from \"./transport/transport-utils.js\";\n\nexport interface ClientToolExecutionService {\n\trequestExecution: (\n\t\tid: string,\n\t\ttoolName: string,\n\t\targs: Record<string, unknown>,\n\t\tsignal?: AbortSignal,\n\t) => Promise<{ content: AgentToolResult[\"content\"]; isError: boolean }>;\n}\n\nexport interface ProviderTransportOptions {\n\tgetApiKey?: (\n\t\tprovider: string,\n\t) => Promise<string | undefined> | string | undefined;\n\tgetAuthContext?: (\n\t\tprovider: string,\n\t) => AuthCredential | undefined | Promise<AuthCredential | undefined>;\n\tcorsProxyUrl?: string;\n\tapprovalService?: ActionApprovalService;\n\ttoolRetryService?: ToolRetryService;\n\ttoolRetryConfig?: ToolRetryConfig;\n\tclientToolService?: ClientToolExecutionService;\n\tmaxConcurrentToolExecutions?: number;\n\t/** Hook service for tool lifecycle hooks (PreToolUse, PostToolUse, etc.) */\n\thookService?: ToolHookService;\n\t/** Current working directory for hook execution (required if hookService not provided) */\n\tcwd?: string;\n\t/** Clock for timestamps and rate limiting (default: system clock) */\n\tclock?: Clock;\n\t/** Session token counter used for enforcing policy session limits */\n\tsessionTokenCounter?: SessionTokenCounter;\n\t/** Audit logger for sensitive tool execution events */\n\tauditLogger?: ToolAuditLogger;\n}\n\n/**\n * Provider Transport - Multi-provider LLM communication with safety controls\n *\n * The main transport implementation that handles streaming LLM responses,\n * executing tool calls, and enforcing safety policies. Supports Anthropic,\n * OpenAI, and Google providers through a unified interface.\n *\n * ## State Management\n *\n * - **workflowState**: Tracks PII artifacts for egress prevention\n * - **recentToolTimestamps**: Per-tool timestamps for rate limiting\n * - **safetyMiddleware**: Unified security (loop detection, sequence analysis, firewall)\n *\n * ## Safety Mechanisms\n *\n * ### SafetyMiddleware Integration\n * All safety checks are now handled through SafetyMiddleware:\n * - **Loop Detection**: Catches identical consecutive calls (replaces doom loop)\n * - **Sequence Analysis**: Detects suspicious behavioral patterns\n * - **Context Firewall**: Sanitizes arguments and blocks sensitive content\n *\n * ### Rate Limiting\n * Each tool has a per-window rate limit (TOOL_RATE_LIMIT calls per\n * TOOL_RATE_WINDOW_MS). This prevents runaway tool execution that could\n * waste resources or hit external API limits.\n *\n * ### Workflow State Serialization\n * When tools that track PII are present in a batch, concurrent execution\n * is disabled to ensure correct state ordering.\n */\nexport class ProviderTransport implements AgentTransport {\n\t/** Tracks PII artifacts through the workflow for egress prevention */\n\tprivate workflowState = new WorkflowStateTracker();\n\t/** Prevents repeated warnings about serialized workflow execution */\n\tprivate warnedAboutWorkflowConcurrency = false;\n\t/** Per-tool timestamp arrays for rate limiting enforcement */\n\tprivate recentToolTimestamps = new Map<string, number[]>();\n\t/** Safety middleware for sequence analysis and context sanitization */\n\tprivate readonly safetyMiddleware!: SafetyMiddleware;\n\t/** Adaptive thresholds for anomaly-based rate limiting */\n\tprivate readonly adaptiveThresholds!: AdaptiveThresholds;\n\t/** Tool call count in current minute window (for adaptive tracking) */\n\tprivate toolCallsThisMinute = 0;\n\t/** Last minute window start time */\n\tprivate minuteWindowStart = 0;\n\tprivate readonly clock: Clock;\n\tprivate readonly sessionTokenCounter?: SessionTokenCounter;\n\tprivate readonly auditLogger?: ToolAuditLogger;\n\n\t/**\n\t * Rate Limit Window - time window for counting tool invocations\n\t * 10 seconds balances burst protection with legitimate rapid use\n\t */\n\tprivate static readonly TOOL_RATE_WINDOW_MS = 10_000;\n\n\t/**\n\t * Rate Limit Maximum - max calls per tool within the window\n\t * 5 calls in 10 seconds allows fast iteration while preventing abuse\n\t */\n\tprivate static readonly TOOL_RATE_LIMIT = 5;\n\n\tconstructor(private options: ProviderTransportOptions = {}) {\n\t\tthis.clock = options.clock ?? systemClock;\n\t\tthis.sessionTokenCounter = options.sessionTokenCounter;\n\t\tthis.auditLogger = options.auditLogger;\n\t\tthis.minuteWindowStart = this.clock.now();\n\t\t// Initialize adaptive thresholds for anomaly detection\n\t\tthis.adaptiveThresholds = new AdaptiveThresholds({\n\t\t\talpha: 0.3, // Give more weight to recent observations\n\t\t\tanomalyThreshold: 2.5, // 2.5 std devs = more aggressive anomaly detection\n\t\t\tminObservations: 5, // Need at least 5 observations before anomaly detection\n\t\t});\n\t\t// Initialize safety middleware for unified security checks\n\t\tthis.safetyMiddleware = createSafetyMiddleware({\n\t\t\t// Enable loop detection (replaces transport's doom loop detection)\n\t\t\tenableLoopDetection: true,\n\t\t\t// Configure loop detector to match transport's previous behavior\n\t\t\tloopDetector: {\n\t\t\t\tmaxIdenticalCalls: 3, // Match DOOM_LOOP_THRESHOLD\n\t\t\t\tmaxSimilarCalls: 5,\n\t\t\t\tmaxCallsPerMinute: 30, // More aggressive rate limit than TOOL_RATE_LIMIT\n\t\t\t\tautoPause: false, // Transport handles the pause flow\n\t\t\t},\n\t\t\t// Enable sequence analysis for behavioral threat detection\n\t\t\tenableSequenceAnalysis: true,\n\t\t\t// Enable context firewall with blocking for sanitizing audit logs\n\t\t\tenableContextFirewall: true,\n\t\t\t// Configure context firewall blocking (can be disabled via MAESTRO_CONTEXT_FIREWALL_BLOCKING=0)\n\t\t\tcontextFirewall: {\n\t\t\t\t// When blocking is disabled, vault credentials so test keys can pass through safely.\n\t\t\t\tvaultCredentials: !isContextFirewallBlockingEnabled(),\n\t\t\t\tblocking: {\n\t\t\t\t\tenabled: isContextFirewallBlockingEnabled(),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Continue from current context without a new user message.\n\t *\n\t * This method reuses the run() logic but skips adding a new user message.\n\t * Useful for:\n\t * - Retrying after transient errors (rate limits, overload, 5xx)\n\t * - Continuing after context compaction\n\t * - Resuming interrupted tool execution\n\t *\n\t * @param messages - Current conversation history\n\t * @param config - Runtime configuration\n\t * @param signal - Optional abort signal for cancellation\n\t * @returns Async iterable of agent events\n\t */\n\tasync *continue(\n\t\tmessages: Message[],\n\t\tconfig: AgentRunConfig,\n\t\tsignal?: AbortSignal,\n\t): AsyncGenerator<AgentEvent, void, unknown> {\n\t\t// Create a synthetic \"continuation\" message that signals we're resuming\n\t\t// This doesn't get added to the conversation but satisfies the run() interface\n\t\tconst continuationMessage: Message = {\n\t\t\trole: \"user\",\n\t\t\tcontent: [\n\t\t\t\t{ type: \"text\", text: \"[System: Continuing from previous context]\" },\n\t\t\t],\n\t\t\ttimestamp: this.clock.now(),\n\t\t};\n\n\t\t// Delegate to run() - the continuation message is used internally\n\t\t// but the actual context comes from the messages array\n\t\tyield* this.run(messages, continuationMessage, config, signal);\n\t}\n\n\tasync *run(\n\t\tmessages: Message[],\n\t\tuserMessage: Message,\n\t\tcfg: AgentRunConfig,\n\t\tsignal?: AbortSignal,\n\t): AsyncGenerator<AgentEvent, void, unknown> {\n\t\tconst { systemPrompt, tools } = cfg;\n\t\tlet model = cfg.model;\n\t\tconst firewall = defaultActionFirewall;\n\n\t\t// Configure semantic judge if LLM access is provided\n\t\tif (cfg.runLLM) {\n\t\t\tfirewall.setSemanticJudge(new SemanticJudge(cfg.runLLM));\n\t\t}\n\n\t\t// Initialize hook service for tool lifecycle hooks\n\t\tconst hookService =\n\t\t\tthis.options.hookService ??\n\t\t\t(this.options.cwd\n\t\t\t\t? createToolHookService({\n\t\t\t\t\t\tcwd: this.options.cwd,\n\t\t\t\t\t\tsessionId: cfg.session?.id,\n\t\t\t\t\t\tresolveTool: (toolName) =>\n\t\t\t\t\t\t\tcfg.tools?.find((tool) => tool.name === toolName),\n\t\t\t\t\t})\n\t\t\t\t: undefined);\n\n\t\tthis.workflowState.reset();\n\n\t\tlet credential: AuthCredential | undefined;\n\t\tif (this.options.getAuthContext) {\n\t\t\tcredential = await this.options.getAuthContext(model.provider);\n\t\t}\n\t\tif (!credential && this.options.getApiKey) {\n\t\t\tconst fallbackKey = await this.options.getApiKey(model.provider);\n\t\t\tif (fallbackKey) {\n\t\t\t\tcredential = {\n\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\ttoken: fallbackKey,\n\t\t\t\t\ttype: \"api-key\",\n\t\t\t\t\tsource: \"env\",\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\tif (!credential) {\n\t\t\tconst envCredential = resolveEnvCredential(model.provider);\n\t\t\tif (envCredential) {\n\t\t\t\tcredential = envCredential;\n\t\t\t}\n\t\t}\n\t\tif (!credential) {\n\t\t\tconst stored = getStoredCredentials(model.provider);\n\t\t\tif (stored.apiKey) {\n\t\t\t\tcredential = {\n\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\ttoken: stored.apiKey,\n\t\t\t\t\ttype: stored.authType ?? \"api-key\",\n\t\t\t\t\tsource: \"custom_literal\",\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst apiKey = credential?.token;\n\t\tif (!apiKey) {\n\t\t\tthrow new Error(\n\t\t\t\t`No credentials found for provider \"${model.provider}\". Provide an API key or configure getAuthContext.`,\n\t\t\t);\n\t\t}\n\n\t\tyield { type: \"message_start\", message: userMessage };\n\t\tif (cfg.emitUserMessageEnd !== false) {\n\t\t\tyield { type: \"message_end\", message: userMessage };\n\t\t}\n\n\t\tconst context = {\n\t\t\tsystemPrompt,\n\t\t\tmessages,\n\t\t\ttools,\n\t\t};\n\n\t\tif (this.options.corsProxyUrl && model.baseUrl) {\n\t\t\tmodel = {\n\t\t\t\t...model,\n\t\t\t\tbaseUrl: `${this.options.corsProxyUrl}/?url=${encodeURIComponent(model.baseUrl)}`,\n\t\t\t};\n\t\t}\n\n\t\tconst trainingHeaders = getTrainingHeaders();\n\t\tconst headers =\n\t\t\ttrainingHeaders || model.headers || credential?.headers\n\t\t\t\t? {\n\t\t\t\t\t\t...(model.headers ?? {}),\n\t\t\t\t\t\t...(trainingHeaders ?? {}),\n\t\t\t\t\t\t...(credential?.headers ?? {}),\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\n\t\tconst streamOptions = {\n\t\t\tapiKey,\n\t\t\tmaxTokens: model.maxTokens,\n\t\t\tsignal,\n\t\t\tauthType: credential?.type ?? \"api-key\",\n\t\t\theaders,\n\t\t\trequestBody: credential?.requestBody,\n\t\t\ttaskBudget: cfg.taskBudget,\n\t\t};\n\n\t\tlet hasMoreToolCalls = true;\n\t\tconst allMessages = [...context.messages];\n\t\tconst getSteeringMessages =\n\t\t\tcfg.getSteeringMessages ?? cfg.getQueuedMessages;\n\t\tconst getFollowUpMessages = cfg.getFollowUpMessages;\n\t\tconst getPromptOnlyMessages = cfg.getPromptOnlyMessages;\n\n\t\tlet pendingMessages = getSteeringMessages\n\t\t\t? await getSteeringMessages<AppMessage>()\n\t\t\t: [];\n\n\t\twhile (hasMoreToolCalls || pendingMessages.length > 0) {\n\t\t\tyield { type: \"turn_start\" };\n\n\t\t\t// Enforce session limits before every turn (duration + tokens)\n\t\t\tif (cfg.session) {\n\t\t\t\tlet tokenCount: number | undefined;\n\t\t\t\tif (this.sessionTokenCounter) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst count = await this.sessionTokenCounter(cfg.session.id);\n\t\t\t\t\t\tif (count !== null) {\n\t\t\t\t\t\t\ttokenCount = count;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t// Log error but don't throw - let checkSessionLimits handle it.\n\t\t\t\t\t\t// If limits are active, it will fail closed because tokenCount is undefined.\n\t\t\t\t\t\t// If no limits are active, we shouldn't block just because tracking failed.\n\t\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\t\"Failed to get session token count\",\n\t\t\t\t\t\t\terr instanceof Error ? err : new Error(String(err)),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst limitCheck = checkSessionLimits(cfg.session, {\n\t\t\t\t\ttokenCount: tokenCount,\n\t\t\t\t});\n\t\t\t\tif (!limitCheck.allowed) {\n\t\t\t\t\tthrow new Error(limitCheck.reason);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (getPromptOnlyMessages) {\n\t\t\t\tconst promptOnlyMessages = await getPromptOnlyMessages();\n\t\t\t\tif (promptOnlyMessages.length > 0) {\n\t\t\t\t\tallMessages.push(...promptOnlyMessages);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (pendingMessages.length > 0) {\n\t\t\t\tfor (const queued of pendingMessages) {\n\t\t\t\t\tyield { type: \"message_start\", message: queued.original };\n\t\t\t\t\tyield { type: \"message_end\", message: queued.original };\n\t\t\t\t\tif (queued.llm) {\n\t\t\t\t\t\tallMessages.push(queued.llm);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpendingMessages = [];\n\t\t\t}\n\n\t\t\tlet currentAssistantMessage: AssistantMessage | null = null;\n\t\t\tlet completedAssistantMessage: AssistantMessage | null = null;\n\t\t\tconst toolCallsToExecute: ToolCall[] = [];\n\t\t\tlet toolResults: ToolResultMessage[] = [];\n\t\t\tlet steeringAfterTools: QueuedMessage<AppMessage>[] | null = null;\n\t\t\tlet pendingNextTurn = false;\n\t\t\tlet encounteredError = false;\n\n\t\t\tconst currentMessages = cfg.preprocessMessages\n\t\t\t\t? await cfg.preprocessMessages(\n\t\t\t\t\t\tallMessages,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsystemPrompt,\n\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tuserMessage,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t)\n\t\t\t\t: allMessages;\n\n\t\t\tconst currentContext = {\n\t\t\t\t...context,\n\t\t\t\tmessages: currentMessages,\n\t\t\t};\n\n\t\t\t// Stream retry logic for idle timeouts\n\t\t\tconst networkConfig = getProviderNetworkConfig(model.provider);\n\t\t\tconst maxStreamRetries = networkConfig.streamMaxRetries;\n\t\t\tlet streamAttempt = 0;\n\t\t\tlet streamSuccess = false;\n\n\t\t\twhile (!streamSuccess && streamAttempt <= maxStreamRetries) {\n\t\t\t\tif (streamAttempt > 0) {\n\t\t\t\t\t// Reset state for retry\n\t\t\t\t\tcurrentAssistantMessage = null;\n\t\t\t\t\ttoolCallsToExecute.length = 0;\n\t\t\t\t\tpendingNextTurn = false;\n\n\t\t\t\t\tconst backoffMs = Math.min(\n\t\t\t\t\t\tnetworkConfig.backoffInitial * 2 ** (streamAttempt - 1),\n\t\t\t\t\t\tnetworkConfig.backoffMax,\n\t\t\t\t\t);\n\t\t\t\t\tlogger.info(\"Retrying stream after idle timeout\", {\n\t\t\t\t\t\tattempt: streamAttempt,\n\t\t\t\t\t\tmaxRetries: maxStreamRetries,\n\t\t\t\t\t\tbackoffMs,\n\t\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\t});\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, backoffMs));\n\t\t\t\t}\n\t\t\t\tstreamAttempt++;\n\n\t\t\t\tconst stream = createProviderStream(\n\t\t\t\t\tmodel,\n\t\t\t\t\tcurrentContext,\n\t\t\t\t\tstreamOptions,\n\t\t\t\t\t{ reasoning: cfg.reasoning, reasoningSummary: cfg.reasoningSummary },\n\t\t\t\t);\n\n\t\t\t\ttry {\n\t\t\t\t\tfor await (const event of stream) {\n\t\t\t\t\t\tif (event.type === \"start\") {\n\t\t\t\t\t\t\tcurrentAssistantMessage = event.partial;\n\t\t\t\t\t\t\tif (currentAssistantMessage) {\n\t\t\t\t\t\t\t\tyield {\n\t\t\t\t\t\t\t\t\ttype: \"message_start\",\n\t\t\t\t\t\t\t\t\tmessage: currentAssistantMessage,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tevent.type === \"text_delta\" ||\n\t\t\t\t\t\t\tevent.type === \"thinking_delta\" ||\n\t\t\t\t\t\t\tevent.type === \"toolcall_delta\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tif (currentAssistantMessage) {\n\t\t\t\t\t\t\t\tyield {\n\t\t\t\t\t\t\t\t\ttype: \"message_update\",\n\t\t\t\t\t\t\t\t\tmessage: currentAssistantMessage,\n\t\t\t\t\t\t\t\t\tassistantMessageEvent: event,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (event.type === \"toolcall_end\") {\n\t\t\t\t\t\t\tconst rawArgs = event.toolCall.arguments;\n\t\t\t\t\t\t\tconst normalizedArgs =\n\t\t\t\t\t\t\t\trawArgs &&\n\t\t\t\t\t\t\t\ttypeof rawArgs === \"object\" &&\n\t\t\t\t\t\t\t\t!Array.isArray(rawArgs)\n\t\t\t\t\t\t\t\t\t? (rawArgs as Record<string, unknown>)\n\t\t\t\t\t\t\t\t\t: {};\n\t\t\t\t\t\t\ttoolCallsToExecute.push({\n\t\t\t\t\t\t\t\ttype: \"toolCall\",\n\t\t\t\t\t\t\t\tid: event.toolCall.id,\n\t\t\t\t\t\t\t\tname: event.toolCall.name,\n\t\t\t\t\t\t\t\targuments: normalizedArgs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (event.type === \"done\") {\n\t\t\t\t\t\t\tif (currentAssistantMessage) {\n\t\t\t\t\t\t\t\tcompletedAssistantMessage = currentAssistantMessage;\n\t\t\t\t\t\t\t\tyield { type: \"message_end\", message: currentAssistantMessage };\n\t\t\t\t\t\t\t\tif (currentAssistantMessage.usage) {\n\t\t\t\t\t\t\t\t\tconst usage = currentAssistantMessage.usage;\n\t\t\t\t\t\t\t\t\tconst cost = model.cost\n\t\t\t\t\t\t\t\t\t\t? calculateCost(usage, model.cost)\n\t\t\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t\t\t\t\tif (credential?.type !== \"anthropic-oauth\") {\n\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\ttrackUsage({\n\t\t\t\t\t\t\t\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\t\t\t\t\t\t\t\tmodel: model.id,\n\t\t\t\t\t\t\t\t\t\t\t\ttokensInput: usage.input || 0,\n\t\t\t\t\t\t\t\t\t\t\t\ttokensOutput: usage.output || 0,\n\t\t\t\t\t\t\t\t\t\t\t\ttokensCacheRead: usage.cacheRead,\n\t\t\t\t\t\t\t\t\t\t\t\ttokensCacheWrite: usage.cacheWrite,\n\t\t\t\t\t\t\t\t\t\t\t\tcost,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\t\t\tlogger.warn(\"Failed to track usage\", {\n\t\t\t\t\t\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: String(error),\n\t\t\t\t\t\t\t\t\t\t\t\tstack: error instanceof Error ? error.stack : undefined,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpendingNextTurn = toolCallsToExecute.length > 0;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (event.type === \"error\") {\n\t\t\t\t\t\t\tcompletedAssistantMessage = event.error;\n\t\t\t\t\t\t\tif (currentAssistantMessage) {\n\t\t\t\t\t\t\t\tyield { type: \"message_end\", message: currentAssistantMessage };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpendingNextTurn = false;\n\t\t\t\t\t\t\tencounteredError = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tstreamSuccess = true;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tisStreamIdleTimeoutError(error) &&\n\t\t\t\t\t\tstreamAttempt <= maxStreamRetries\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.warn(\"Stream idle timeout, will retry\", {\n\t\t\t\t\t\t\tattempt: streamAttempt,\n\t\t\t\t\t\t\tmaxRetries: maxStreamRetries,\n\t\t\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\t\t\tidleMs: error.idleMs,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontinue; // Retry the stream\n\t\t\t\t\t}\n\t\t\t\t\t// Not retryable or exhausted retries - re-throw\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t} // end while retry loop\n\n\t\t\tif (toolCallsToExecute.length > 0) {\n\t\t\t\ttoolResults = [];\n\t\t\t\tconst toolUpdateQueue = createToolUpdateQueue();\n\t\t\t\tconst pendingExecutions: PendingExecution[] = [];\n\t\t\t\tconst rawConcurrency = this.options.maxConcurrentToolExecutions ?? 2;\n\t\t\t\tconst configuredConcurrency = Number.isFinite(rawConcurrency)\n\t\t\t\t\t? Math.max(1, Math.floor(rawConcurrency))\n\t\t\t\t\t: 2;\n\t\t\t\tconst hasWorkflowTrackedTool = toolCallsToExecute.some((call) =>\n\t\t\t\t\tisWorkflowTrackedTool(call.name),\n\t\t\t\t);\n\t\t\t\tconst requiresSerializedTurn =\n\t\t\t\t\thasWorkflowTrackedTool && toolCallsToExecute.length > 1;\n\n\t\t\t\t// Calculate optimal concurrency - higher for read-only batches\n\t\t\t\tlet concurrencyLimit = getOptimalConcurrency(\n\t\t\t\t\ttoolCallsToExecute,\n\t\t\t\t\ttools,\n\t\t\t\t\t{\n\t\t\t\t\t\tbaseConcurrency: configuredConcurrency,\n\t\t\t\t\t\tmaxReadOnlyConcurrency: 8, // Allow up to 8x parallel for read-only\n\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\t// Override: workflow-tracked tools require serialization\n\t\t\t\tif (configuredConcurrency > 1 && requiresSerializedTurn) {\n\t\t\t\t\tconcurrencyLimit = 1;\n\t\t\t\t\tif (!this.warnedAboutWorkflowConcurrency) {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t\"WorkflowStateTracker requires serialized tool execution; maxConcurrentToolExecutions capped at 1\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.warnedAboutWorkflowConcurrency = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet steeringTriggered = false;\n\t\t\t\tlet remainingToolCalls: ToolCall[] = [];\n\n\t\t\t\tconst checkSteering = async (): Promise<void> => {\n\t\t\t\t\tif (steeringTriggered || !getSteeringMessages) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst steering = await getSteeringMessages<AppMessage>();\n\t\t\t\t\tif (steering.length > 0) {\n\t\t\t\t\t\tsteeringTriggered = true;\n\t\t\t\t\t\tsteeringAfterTools = steering;\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tconst buildExecutionEvents = (\n\t\t\t\t\ttoolCall: ToolCall,\n\t\t\t\t\tmessage: ToolResultMessage,\n\t\t\t\t\tisError: boolean,\n\t\t\t\t): AgentEvent[] => [\n\t\t\t\t\t{ type: \"message_start\", message } as AgentEvent,\n\t\t\t\t\t{ type: \"message_end\", message } as AgentEvent,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"tool_execution_end\",\n\t\t\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\t\tresult: message,\n\t\t\t\t\t\tisError,\n\t\t\t\t\t} as AgentEvent,\n\t\t\t\t];\n\t\t\t\tconst emitToolResult = (\n\t\t\t\t\tmessage: ToolResultMessage,\n\t\t\t\t\ttoolCall: ToolCall,\n\t\t\t\t\tisError: boolean,\n\t\t\t\t) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tapplyWorkflowStateHooks({\n\t\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\t\tresult: message,\n\t\t\t\t\t\t\ttracker: this.workflowState,\n\t\t\t\t\t\t\tisError,\n\t\t\t\t\t\t});\n\t\t\t\t\t\ttoolResults.push(message);\n\t\t\t\t\t\treturn buildExecutionEvents(toolCall, message, isError);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof WorkflowStateError) {\n\t\t\t\t\t\t\tconst workflowErrorResult: ToolResultMessage = {\n\t\t\t\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: error.message }],\n\t\t\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\t\t\ttimestamp: this.clock.now(),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\ttoolResults.push(workflowErrorResult);\n\t\t\t\t\t\t\treturn buildExecutionEvents(toolCall, workflowErrorResult, true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst emitSkippedToolCall = (toolCall: ToolCall): AgentEvent[] => {\n\t\t\t\t\tconst sanitizedSkippedArgs = this.safetyMiddleware.sanitizeForLogging(\n\t\t\t\t\t\ttoolCall.arguments as Record<string, unknown>,\n\t\t\t\t\t);\n\t\t\t\t\tconst skippedResult: ToolResultMessage = {\n\t\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: \"Skipped due to queued user message.\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\ttimestamp: this.clock.now(),\n\t\t\t\t\t};\n\t\t\t\t\treturn [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"tool_execution_start\",\n\t\t\t\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\t\t\targs: sanitizedSkippedArgs,\n\t\t\t\t\t\t} as AgentEvent,\n\t\t\t\t\t\t...emitToolResult(skippedResult, toolCall, true),\n\t\t\t\t\t];\n\t\t\t\t};\n\n\t\t\t\tconst scheduleResolveIfNeeded = async (): Promise<AgentEvent[]> => {\n\t\t\t\t\tif (pendingExecutions.length < concurrencyLimit) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\tconst events: AgentEvent[] = [];\n\t\t\t\t\twhile (pendingExecutions.length >= concurrencyLimit) {\n\t\t\t\t\t\tconst next = await waitForNextExecutionOrUpdate(\n\t\t\t\t\t\t\tpendingExecutions,\n\t\t\t\t\t\t\ttoolUpdateQueue,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (next.kind === \"update\") {\n\t\t\t\t\t\t\tevents.push(next.event);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst outcome = next.outcome;\n\t\t\t\t\t\tevents.push(\n\t\t\t\t\t\t\t...emitToolResult(\n\t\t\t\t\t\t\t\toutcome.message,\n\t\t\t\t\t\t\t\tnext.execution.toolCall,\n\t\t\t\t\t\t\t\toutcome.isError,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait checkSteering();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\treturn events;\n\t\t\t\t};\n\n\t\t\t\tfor (\n\t\t\t\t\tlet toolIndex = 0;\n\t\t\t\t\ttoolIndex < toolCallsToExecute.length;\n\t\t\t\t\ttoolIndex++\n\t\t\t\t) {\n\t\t\t\t\tif (steeringTriggered) {\n\t\t\t\t\t\tremainingToolCalls = toolCallsToExecute.slice(toolIndex);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst toolCall = toolCallsToExecute[toolIndex];\n\t\t\t\t\tif (!toolCall) continue;\n\n\t\t\t\t\t// Run safety pipeline (rate limiting, hooks, firewall, approval, validation)\n\t\t\t\t\tconst safetyIterator = evaluateToolSafety({\n\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\ttools,\n\t\t\t\t\t\tuserMessage,\n\t\t\t\t\t\tcfg,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tclock: this.clock,\n\t\t\t\t\t\tsafetyMiddleware: this.safetyMiddleware,\n\t\t\t\t\t\tworkflowState: this.workflowState,\n\t\t\t\t\t\tadaptiveThresholds: this.adaptiveThresholds,\n\t\t\t\t\t\tauditLogger: this.auditLogger,\n\t\t\t\t\t\tapprovalService: this.options.approvalService,\n\t\t\t\t\t\thookService,\n\t\t\t\t\t\tfirewall,\n\t\t\t\t\t\trateLimitState: {\n\t\t\t\t\t\t\trecentToolTimestamps: this.recentToolTimestamps,\n\t\t\t\t\t\t\ttoolCallsThisMinute: this.toolCallsThisMinute,\n\t\t\t\t\t\t\tminuteWindowStart: this.minuteWindowStart,\n\t\t\t\t\t\t\trateWindowMs: ProviderTransport.TOOL_RATE_WINDOW_MS,\n\t\t\t\t\t\t\trateLimit: ProviderTransport.TOOL_RATE_LIMIT,\n\t\t\t\t\t\t},\n\t\t\t\t\t\temitToolResult,\n\t\t\t\t\t});\n\t\t\t\t\tlet safetyVerdict: ToolSafetyVerdict | undefined;\n\t\t\t\t\tlet rateLimitUpdate:\n\t\t\t\t\t\t| { toolCallsThisMinute: number; minuteWindowStart: number }\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst safetyStep = await safetyIterator.next();\n\t\t\t\t\t\tif (safetyStep.done) {\n\t\t\t\t\t\t\t({ verdict: safetyVerdict, rateLimitUpdate } = safetyStep.value);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tyield safetyStep.value;\n\t\t\t\t\t}\n\t\t\t\t\tif (!safetyVerdict || !rateLimitUpdate) {\n\t\t\t\t\t\tthrow new Error(\"Safety pipeline did not return a verdict.\");\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply rate limit state updates\n\t\t\t\t\tthis.toolCallsThisMinute = rateLimitUpdate.toolCallsThisMinute;\n\t\t\t\t\tthis.minuteWindowStart = rateLimitUpdate.minuteWindowStart;\n\n\t\t\t\t\tif (safetyVerdict.outcome === \"blocked\") {\n\t\t\t\t\t\tawait checkSteering();\n\t\t\t\t\t\tif (steeringTriggered) {\n\t\t\t\t\t\t\tremainingToolCalls = toolCallsToExecute.slice(toolIndex + 1);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst {\n\t\t\t\t\t\teffectiveToolCall,\n\t\t\t\t\t\tvalidatedArgs,\n\t\t\t\t\t\ttoolDef: tool,\n\t\t\t\t\t\tsanitizedExecutionArgs,\n\t\t\t\t\t} = safetyVerdict;\n\t\t\t\t\t// Use hook-modified (pre-validation) args for hook inputs\n\n\t\t\t\t\t// For client tools, set up the execution promise first, then emit event\n\t\t\t\t\t// This prevents race conditions where the client responds before we're listening\n\t\t\t\t\tlet clientToolExecPromise:\n\t\t\t\t\t\t| ReturnType<ClientToolExecutionService[\"requestExecution\"]>\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tif (\n\t\t\t\t\t\ttool.executionLocation === \"client\" &&\n\t\t\t\t\t\tthis.options.clientToolService\n\t\t\t\t\t) {\n\t\t\t\t\t\tclientToolExecPromise =\n\t\t\t\t\t\t\tthis.options.clientToolService.requestExecution(\n\t\t\t\t\t\t\t\ttoolCall.id,\n\t\t\t\t\t\t\t\ttoolCall.name,\n\t\t\t\t\t\t\t\tvalidatedArgs,\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t// Now emit the event - the promise is already waiting for the result\n\t\t\t\t\t\tyield {\n\t\t\t\t\t\t\ttype: \"client_tool_request\",\n\t\t\t\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\t\t\t// Client tools execute out-of-process; they need the real args.\n\t\t\t\t\t\t\targs: validatedArgs,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst executionPromise = createToolExecutionPromise({\n\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\teffectiveToolCall,\n\t\t\t\t\t\ttool,\n\t\t\t\t\t\tvalidatedArgs,\n\t\t\t\t\t\tsanitizedExecutionArgs,\n\t\t\t\t\t\tcfg,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tclock: this.clock,\n\t\t\t\t\t\tsafetyMiddleware: this.safetyMiddleware,\n\t\t\t\t\t\tadaptiveThresholds: this.adaptiveThresholds,\n\t\t\t\t\t\tauditLogger: this.auditLogger,\n\t\t\t\t\t\thookService,\n\t\t\t\t\t\ttoolRetryService: this.options.toolRetryService,\n\t\t\t\t\t\ttoolRetryConfig: this.options.toolRetryConfig,\n\t\t\t\t\t\tclientToolService: this.options.clientToolService,\n\t\t\t\t\t\ttoolUpdateQueue,\n\t\t\t\t\t\tclientToolExecPromise,\n\t\t\t\t\t});\n\n\t\t\t\t\tpendingExecutions.push({\n\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\tpromise: executionPromise,\n\t\t\t\t\t});\n\t\t\t\t\tconst events = await scheduleResolveIfNeeded();\n\t\t\t\t\tfor (const event of events) {\n\t\t\t\t\t\tyield event;\n\t\t\t\t\t}\n\t\t\t\t\tif (steeringTriggered) {\n\t\t\t\t\t\tremainingToolCalls = toolCallsToExecute.slice(toolIndex + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\twhile (pendingExecutions.length > 0) {\n\t\t\t\t\tconst next = await waitForNextExecutionOrUpdate(\n\t\t\t\t\t\tpendingExecutions,\n\t\t\t\t\t\ttoolUpdateQueue,\n\t\t\t\t\t);\n\t\t\t\t\tif (next.kind === \"update\") {\n\t\t\t\t\t\tyield next.event;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst outcome = next.outcome;\n\t\t\t\t\tfor (const event of emitToolResult(\n\t\t\t\t\t\toutcome.message,\n\t\t\t\t\t\tnext.execution.toolCall,\n\t\t\t\t\t\toutcome.isError,\n\t\t\t\t\t)) {\n\t\t\t\t\t\tyield event;\n\t\t\t\t\t}\n\t\t\t\t\tawait checkSteering();\n\t\t\t\t}\n\n\t\t\t\tthis.safetyMiddleware.clearCredentials();\n\n\t\t\t\tif (steeringTriggered && remainingToolCalls.length > 0) {\n\t\t\t\t\tfor (const toolCall of remainingToolCalls) {\n\t\t\t\t\t\tfor (const event of emitSkippedToolCall(toolCall)) {\n\t\t\t\t\t\t\tyield event;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!steeringTriggered && getSteeringMessages) {\n\t\t\t\t\tconst steering = await getSteeringMessages<AppMessage>();\n\t\t\t\t\tif (steering.length > 0) {\n\t\t\t\t\t\tsteeringAfterTools = steering;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (completedAssistantMessage) {\n\t\t\t\tallMessages.push(completedAssistantMessage);\n\t\t\t}\n\t\t\tallMessages.push(...toolResults);\n\n\t\t\tyield {\n\t\t\t\ttype: \"turn_end\",\n\t\t\t\tmessage: completedAssistantMessage ??\n\t\t\t\t\tcurrentAssistantMessage ?? {\n\t\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\t\tcontent: [],\n\t\t\t\t\t\tapi: model.api,\n\t\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\t\tmodel: model.id,\n\t\t\t\t\t\tusage: {\n\t\t\t\t\t\t\tinput: 0,\n\t\t\t\t\t\t\toutput: 0,\n\t\t\t\t\t\t\tcacheRead: 0,\n\t\t\t\t\t\t\tcacheWrite: 0,\n\t\t\t\t\t\t\tcost: {\n\t\t\t\t\t\t\t\tinput: 0,\n\t\t\t\t\t\t\t\toutput: 0,\n\t\t\t\t\t\t\t\tcacheRead: 0,\n\t\t\t\t\t\t\t\tcacheWrite: 0,\n\t\t\t\t\t\t\t\ttotal: 0,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstopReason: \"error\",\n\t\t\t\t\t\ttimestamp: this.clock.now(),\n\t\t\t\t\t},\n\t\t\t\ttoolResults,\n\t\t\t};\n\n\t\t\tif (steeringAfterTools && steeringAfterTools.length > 0) {\n\t\t\t\tpendingMessages = steeringAfterTools;\n\t\t\t} else if (getSteeringMessages) {\n\t\t\t\tconst steering = await getSteeringMessages<AppMessage>();\n\t\t\t\tif (steering.length > 0) {\n\t\t\t\t\tpendingMessages = steering;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t!pendingNextTurn &&\n\t\t\t\tpendingMessages.length === 0 &&\n\t\t\t\tgetFollowUpMessages\n\t\t\t) {\n\t\t\t\tconst followUps = await getFollowUpMessages<AppMessage>();\n\t\t\t\tif (followUps.length > 0) {\n\t\t\t\t\tpendingMessages = followUps;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (pendingMessages.length > 0) {\n\t\t\t\tpendingNextTurn = true;\n\t\t\t}\n\n\t\t\thasMoreToolCalls = encounteredError ? false : pendingNextTurn;\n\t\t}\n\t}\n}\n"]}
|
|
1
|
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I,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACzD,eAAe,GAAG,kBAAkB,CAAC;YACtC,CAAC;iBAAM,IAAI,mBAAmB,EAAE,CAAC;gBAChC,MAAM,QAAQ,GAAG,MAAM,mBAAmB,EAAc,CAAC;gBACzD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACzB,eAAe,GAAG,QAAQ,CAAC;gBAC5B,CAAC;YACF,CAAC;YAED,IACC,CAAC,eAAe;gBAChB,eAAe,CAAC,MAAM,KAAK,CAAC;gBAC5B,mBAAmB,EAClB,CAAC;gBACF,MAAM,SAAS,GAAG,MAAM,mBAAmB,EAAc,CAAC;gBAC1D,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC1B,eAAe,GAAG,SAAS,CAAC;gBAC7B,CAAC;YACF,CAAC;YAED,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChC,eAAe,GAAG,IAAI,CAAC;YACxB,CAAC;YAED,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC;YAC9D,IAAI,gBAAgB,EAAE,CAAC;gBACtB,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;YAC3C,CAAC;iBAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC9B,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,eAAe,EAAE;oBAC5C,YAAY,EAAE,WAAW,CAAC,MAAM;iBAChC,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["/**\n * Agent Transport Layer - LLM Communication and Tool Execution Orchestration\n *\n * This module is the heart of the agent's execution loop. It handles:\n * 1. Streaming communication with LLM providers (Anthropic, OpenAI, Google)\n * 2. Concurrent tool execution with configurable parallelism\n * 3. Safety enforcement via action firewall integration\n * 4. Hook system integration for tool lifecycle events\n *\n * ## Architecture Overview\n *\n * ```\n * User Message → Transport.run() → Provider Stream → Parse Tool Calls\n * ↓ ↓\n * Emit Turn Events ←── Tool Results ←── Execute Tools\n * ↓ ↑\n * Continue Loop ───────────────────────────────┘\n * ```\n *\n * ## Concurrent Tool Execution\n *\n * When the LLM returns multiple tool calls in a single response, we execute\n * them concurrently up to `maxConcurrentToolExecutions` limit. This improves\n * latency for independent operations (e.g., reading multiple files).\n *\n * However, tools that affect WorkflowStateTracker (PII tracking) are serialized\n * to maintain consistent state ordering. A warning is logged when this happens.\n *\n * ## Safety Integration Points\n *\n * 1. **Pre-execution**: Action firewall evaluates each tool call\n * 2. **Approval flow**: Dangerous actions trigger user approval\n * 3. **PII tracking**: WorkflowState hooks track data flow for egress prevention\n * 4. **Doom loop detection**: Identical consecutive tool calls are blocked\n * 5. **Rate limiting**: Per-tool rate limits prevent runaway execution\n *\n * ## Event Stream\n *\n * The transport yields AgentEvents that drive the UI:\n * - turn_start/end: Turn boundaries for UI state management\n * - message_start/update/end: Streaming content updates\n * - tool_execution_start/end: Tool lifecycle for progress display\n * - action_approval_required/resolved: Approval UI triggers\n *\n * @module agent/transport\n */\n\nimport { isContextFirewallBlockingEnabled } from \"../config/env-vars.js\";\nimport { type ToolHookService, createToolHookService } from \"../hooks/index.js\";\nimport { getProviderNetworkConfig } from \"../providers/network-config.js\";\nimport { isStreamIdleTimeoutError } from \"../providers/stream-idle-timeout.js\";\nimport { type Clock, systemClock } from \"../utils/clock.js\";\nimport { createLogger } from \"../utils/logger.js\";\n\nconst logger = createLogger(\"transport\");\nimport type { AuthCredential } from \"../providers/auth.js\";\nimport { defaultActionFirewall } from \"../safety/action-firewall.js\";\nimport { AdaptiveThresholds } from \"../safety/adaptive-thresholds.js\";\nimport { checkSessionLimits } from \"../safety/policy.js\";\nimport {\n\ttype SafetyMiddleware,\n\tcreateSafetyMiddleware,\n} from \"../safety/safety-middleware.js\";\nimport { SemanticJudge } from \"../safety/semantic-judge.js\";\nimport {\n\tWorkflowStateError,\n\tWorkflowStateTracker,\n\tapplyWorkflowStateHooks,\n\tisWorkflowTrackedTool,\n} from \"../safety/workflow-state.js\";\nimport {\n\ttype SkillArtifactMetadata,\n\tgetSkillArtifactMetadataFromDetails,\n} from \"../skills/artifact-metadata.js\";\nimport { getOptimalConcurrency } from \"../tools/parallel-execution.js\";\nimport { trackUsage } from \"../tracking/cost-tracker.js\";\nimport { getTrainingHeaders } from \"../training.js\";\nimport type { ActionApprovalService } from \"./action-approval.js\";\nimport { getStoredCredentials } from \"./keys.js\";\nimport type { ToolRetryConfig, ToolRetryService } from \"./tool-retry.js\";\nimport { createProviderStream } from \"./transport/create-provider-stream.js\";\nimport {\n\ttype PlatformToolExecutionBridge,\n\tgetDefaultPlatformToolExecutionBridge,\n} from \"./transport/tool-execution-bridge.js\";\nimport { createToolExecutionPromise } from \"./transport/tool-execution.js\";\nimport {\n\ttype ToolSafetyVerdict,\n\tevaluateToolSafety,\n} from \"./transport/tool-safety-pipeline.js\";\nimport {\n\ttype PendingExecution,\n\tcreateToolUpdateQueue,\n\twaitForNextExecutionOrUpdate,\n} from \"./transport/tool-update-queue.js\";\nimport {\n\ttype SessionTokenCounter,\n\ttype ToolAuditLogger,\n\tcalculateCost,\n\tresolveEnvCredential,\n} from \"./transport/transport-utils.js\";\nimport type {\n\tAgentEvent,\n\tAgentRunConfig,\n\tAgentToolResult,\n\tAgentTransport,\n\tAppMessage,\n\tAssistantMessage,\n\tMessage,\n\tQueuedMessage,\n\tToolCall,\n\tToolResultMessage,\n} from \"./types.js\";\n\ntype GovernedToolOutcome =\n\t| \"approval_required\"\n\t| \"approval_pending\"\n\t| \"authentication_required\"\n\t| \"denied\"\n\t| \"rate_limited\";\n\nfunction getGovernedToolResultEventMetadata(details: unknown): {\n\terrorCode?: string;\n\tapprovalRequestId?: string;\n\tgovernedOutcome?: GovernedToolOutcome;\n} {\n\tif (!details || typeof details !== \"object\") {\n\t\treturn {};\n\t}\n\n\tconst governedOutcome = (details as { governedOutcome?: unknown })\n\t\t.governedOutcome;\n\tif (!governedOutcome || typeof governedOutcome !== \"object\") {\n\t\treturn {};\n\t}\n\n\tconst normalized = governedOutcome as Record<string, unknown>;\n\tconst classification =\n\t\ttypeof normalized.classification === \"string\"\n\t\t\t? (normalized.classification as GovernedToolOutcome)\n\t\t\t: undefined;\n\tconst errorCode =\n\t\ttypeof normalized.code === \"string\" && normalized.code.trim().length > 0\n\t\t\t? normalized.code.trim()\n\t\t\t: classification;\n\tconst approvalRequestId =\n\t\ttypeof normalized.approvalRequestId === \"string\" &&\n\t\tnormalized.approvalRequestId.trim().length > 0\n\t\t\t? normalized.approvalRequestId.trim()\n\t\t\t: undefined;\n\n\treturn {\n\t\terrorCode,\n\t\tapprovalRequestId,\n\t\tgovernedOutcome: classification,\n\t};\n}\n\nfunction getSkillToolResultEventMetadata(details: unknown): {\n\tskillMetadata?: SkillArtifactMetadata;\n} {\n\treturn {\n\t\tskillMetadata: getSkillArtifactMetadataFromDetails(details),\n\t};\n}\n\n// Re-export types for backward compatibility\nexport type {\n\tSessionTokenCounter,\n\tToolAuditLogger,\n} from \"./transport/transport-utils.js\";\n\nexport interface ClientToolExecutionService {\n\trequestExecution: (\n\t\tid: string,\n\t\ttoolName: string,\n\t\targs: Record<string, unknown>,\n\t\tsignal?: AbortSignal,\n\t) => Promise<{ content: AgentToolResult[\"content\"]; isError: boolean }>;\n}\n\nexport interface ProviderTransportOptions {\n\tgetApiKey?: (\n\t\tprovider: string,\n\t) => Promise<string | undefined> | string | undefined;\n\tgetAuthContext?: (\n\t\tprovider: string,\n\t) => AuthCredential | undefined | Promise<AuthCredential | undefined>;\n\tcorsProxyUrl?: string;\n\tapprovalService?: ActionApprovalService;\n\ttoolRetryService?: ToolRetryService;\n\ttoolRetryConfig?: ToolRetryConfig;\n\tclientToolService?: ClientToolExecutionService;\n\tmaxConcurrentToolExecutions?: number;\n\t/** Hook service for tool lifecycle hooks (PreToolUse, PostToolUse, etc.) */\n\thookService?: ToolHookService;\n\t/** Current working directory for hook execution (required if hookService not provided) */\n\tcwd?: string;\n\t/** Clock for timestamps and rate limiting (default: system clock) */\n\tclock?: Clock;\n\t/** Session token counter used for enforcing policy session limits */\n\tsessionTokenCounter?: SessionTokenCounter;\n\t/** Audit logger for sensitive tool execution events */\n\tauditLogger?: ToolAuditLogger;\n\t/** Optional Platform ToolExecution bridge override */\n\tplatformToolExecutionBridge?: PlatformToolExecutionBridge | false;\n}\n\n/**\n * Provider Transport - Multi-provider LLM communication with safety controls\n *\n * The main transport implementation that handles streaming LLM responses,\n * executing tool calls, and enforcing safety policies. Supports Anthropic,\n * OpenAI, and Google providers through a unified interface.\n *\n * ## State Management\n *\n * - **workflowState**: Tracks PII artifacts for egress prevention\n * - **recentToolTimestamps**: Per-tool timestamps for rate limiting\n * - **safetyMiddleware**: Unified security (loop detection, sequence analysis, firewall)\n *\n * ## Safety Mechanisms\n *\n * ### SafetyMiddleware Integration\n * All safety checks are now handled through SafetyMiddleware:\n * - **Loop Detection**: Catches identical consecutive calls (replaces doom loop)\n * - **Sequence Analysis**: Detects suspicious behavioral patterns\n * - **Context Firewall**: Sanitizes arguments and blocks sensitive content\n *\n * ### Rate Limiting\n * Each tool has a per-window rate limit (TOOL_RATE_LIMIT calls per\n * TOOL_RATE_WINDOW_MS). This prevents runaway tool execution that could\n * waste resources or hit external API limits.\n *\n * ### Workflow State Serialization\n * When tools that track PII are present in a batch, concurrent execution\n * is disabled to ensure correct state ordering.\n */\nexport class ProviderTransport implements AgentTransport {\n\t/** Tracks PII artifacts through the workflow for egress prevention */\n\tprivate workflowState = new WorkflowStateTracker();\n\t/** Prevents repeated warnings about serialized workflow execution */\n\tprivate warnedAboutWorkflowConcurrency = false;\n\t/** Per-tool timestamp arrays for rate limiting enforcement */\n\tprivate recentToolTimestamps = new Map<string, number[]>();\n\t/** Safety middleware for sequence analysis and context sanitization */\n\tprivate readonly safetyMiddleware!: SafetyMiddleware;\n\t/** Adaptive thresholds for anomaly-based rate limiting */\n\tprivate readonly adaptiveThresholds!: AdaptiveThresholds;\n\t/** Tool call count in current minute window (for adaptive tracking) */\n\tprivate toolCallsThisMinute = 0;\n\t/** Last minute window start time */\n\tprivate minuteWindowStart = 0;\n\tprivate readonly clock: Clock;\n\tprivate readonly sessionTokenCounter?: SessionTokenCounter;\n\tprivate readonly auditLogger?: ToolAuditLogger;\n\n\t/**\n\t * Rate Limit Window - time window for counting tool invocations\n\t * 10 seconds balances burst protection with legitimate rapid use\n\t */\n\tprivate static readonly TOOL_RATE_WINDOW_MS = 10_000;\n\n\t/**\n\t * Rate Limit Maximum - max calls per tool within the window\n\t * 5 calls in 10 seconds allows fast iteration while preventing abuse\n\t */\n\tprivate static readonly TOOL_RATE_LIMIT = 5;\n\n\tconstructor(private options: ProviderTransportOptions = {}) {\n\t\tthis.clock = options.clock ?? systemClock;\n\t\tthis.sessionTokenCounter = options.sessionTokenCounter;\n\t\tthis.auditLogger = options.auditLogger;\n\t\tthis.minuteWindowStart = this.clock.now();\n\t\t// Initialize adaptive thresholds for anomaly detection\n\t\tthis.adaptiveThresholds = new AdaptiveThresholds({\n\t\t\talpha: 0.3, // Give more weight to recent observations\n\t\t\tanomalyThreshold: 2.5, // 2.5 std devs = more aggressive anomaly detection\n\t\t\tminObservations: 5, // Need at least 5 observations before anomaly detection\n\t\t});\n\t\t// Initialize safety middleware for unified security checks\n\t\tthis.safetyMiddleware = createSafetyMiddleware({\n\t\t\t// Enable loop detection (replaces transport's doom loop detection)\n\t\t\tenableLoopDetection: true,\n\t\t\t// Configure loop detector to match transport's previous behavior\n\t\t\tloopDetector: {\n\t\t\t\tmaxIdenticalCalls: 3, // Match DOOM_LOOP_THRESHOLD\n\t\t\t\tmaxSimilarCalls: 5,\n\t\t\t\tmaxCallsPerMinute: 30, // More aggressive rate limit than TOOL_RATE_LIMIT\n\t\t\t\tautoPause: false, // Transport handles the pause flow\n\t\t\t},\n\t\t\t// Enable sequence analysis for behavioral threat detection\n\t\t\tenableSequenceAnalysis: true,\n\t\t\t// Enable context firewall with blocking for sanitizing audit logs\n\t\t\tenableContextFirewall: true,\n\t\t\t// Configure context firewall blocking (can be disabled via MAESTRO_CONTEXT_FIREWALL_BLOCKING=0)\n\t\t\tcontextFirewall: {\n\t\t\t\t// When blocking is disabled, vault credentials so test keys can pass through safely.\n\t\t\t\tvaultCredentials: !isContextFirewallBlockingEnabled(),\n\t\t\t\tblocking: {\n\t\t\t\t\tenabled: isContextFirewallBlockingEnabled(),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Continue from current context without a new user message.\n\t *\n\t * This method reuses the run() logic but skips adding a new user message.\n\t * Useful for:\n\t * - Retrying after transient errors (rate limits, overload, 5xx)\n\t * - Continuing after context compaction\n\t * - Resuming interrupted tool execution\n\t *\n\t * @param messages - Current conversation history\n\t * @param config - Runtime configuration\n\t * @param signal - Optional abort signal for cancellation\n\t * @returns Async iterable of agent events\n\t */\n\tasync *continue(\n\t\tmessages: Message[],\n\t\tconfig: AgentRunConfig,\n\t\tsignal?: AbortSignal,\n\t): AsyncGenerator<AgentEvent, void, unknown> {\n\t\t// Create a synthetic \"continuation\" message that signals we're resuming\n\t\t// This doesn't get added to the conversation but satisfies the run() interface\n\t\tconst continuationMessage: Message = {\n\t\t\trole: \"user\",\n\t\t\tcontent: [\n\t\t\t\t{ type: \"text\", text: \"[System: Continuing from previous context]\" },\n\t\t\t],\n\t\t\ttimestamp: this.clock.now(),\n\t\t};\n\n\t\t// Delegate to run() - the continuation message is used internally\n\t\t// but the actual context comes from the messages array\n\t\tyield* this.run(messages, continuationMessage, config, signal);\n\t}\n\n\tasync *run(\n\t\tmessages: Message[],\n\t\tuserMessage: Message,\n\t\tcfg: AgentRunConfig,\n\t\tsignal?: AbortSignal,\n\t): AsyncGenerator<AgentEvent, void, unknown> {\n\t\tconst { systemPrompt, tools } = cfg;\n\t\tlet model = cfg.model;\n\t\tconst firewall = defaultActionFirewall;\n\n\t\t// Configure semantic judge if LLM access is provided\n\t\tif (cfg.runLLM) {\n\t\t\tfirewall.setSemanticJudge(new SemanticJudge(cfg.runLLM));\n\t\t}\n\n\t\t// Initialize hook service for tool lifecycle hooks\n\t\tconst hookService =\n\t\t\tthis.options.hookService ??\n\t\t\t(this.options.cwd\n\t\t\t\t? createToolHookService({\n\t\t\t\t\t\tcwd: this.options.cwd,\n\t\t\t\t\t\tsessionId: cfg.session?.id,\n\t\t\t\t\t\tresolveTool: (toolName) =>\n\t\t\t\t\t\t\tcfg.tools?.find((tool) => tool.name === toolName),\n\t\t\t\t\t})\n\t\t\t\t: undefined);\n\n\t\tthis.workflowState.reset();\n\n\t\tlet credential: AuthCredential | undefined;\n\t\tif (this.options.getAuthContext) {\n\t\t\tcredential = await this.options.getAuthContext(model.provider);\n\t\t}\n\t\tif (!credential && this.options.getApiKey) {\n\t\t\tconst fallbackKey = await this.options.getApiKey(model.provider);\n\t\t\tif (fallbackKey) {\n\t\t\t\tcredential = {\n\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\ttoken: fallbackKey,\n\t\t\t\t\ttype: \"api-key\",\n\t\t\t\t\tsource: \"env\",\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\tif (!credential) {\n\t\t\tconst envCredential = resolveEnvCredential(model.provider);\n\t\t\tif (envCredential) {\n\t\t\t\tcredential = envCredential;\n\t\t\t}\n\t\t}\n\t\tif (!credential) {\n\t\t\tconst stored = getStoredCredentials(model.provider);\n\t\t\tif (stored.apiKey) {\n\t\t\t\tcredential = {\n\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\ttoken: stored.apiKey,\n\t\t\t\t\ttype: stored.authType ?? \"api-key\",\n\t\t\t\t\tsource: \"custom_literal\",\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst apiKey = credential?.token;\n\t\tif (!apiKey) {\n\t\t\tthrow new Error(\n\t\t\t\t`No credentials found for provider \"${model.provider}\". Provide an API key or configure getAuthContext.`,\n\t\t\t);\n\t\t}\n\n\t\tyield { type: \"message_start\", message: userMessage };\n\t\tif (cfg.emitUserMessageEnd !== false) {\n\t\t\tyield { type: \"message_end\", message: userMessage };\n\t\t}\n\n\t\tconst context = {\n\t\t\tsystemPrompt,\n\t\t\tmessages,\n\t\t\ttools,\n\t\t};\n\n\t\tif (this.options.corsProxyUrl && model.baseUrl) {\n\t\t\tmodel = {\n\t\t\t\t...model,\n\t\t\t\tbaseUrl: `${this.options.corsProxyUrl}/?url=${encodeURIComponent(model.baseUrl)}`,\n\t\t\t};\n\t\t}\n\n\t\tconst trainingHeaders = getTrainingHeaders();\n\t\tconst headers =\n\t\t\ttrainingHeaders || model.headers || credential?.headers\n\t\t\t\t? {\n\t\t\t\t\t\t...(model.headers ?? {}),\n\t\t\t\t\t\t...(trainingHeaders ?? {}),\n\t\t\t\t\t\t...(credential?.headers ?? {}),\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\n\t\tconst streamOptions = {\n\t\t\tapiKey,\n\t\t\tmaxTokens: model.maxTokens,\n\t\t\tsignal,\n\t\t\tauthType: credential?.type ?? \"api-key\",\n\t\t\theaders,\n\t\t\trequestBody: credential?.requestBody,\n\t\t\tsessionId: cfg.session?.id,\n\t\t\ttaskBudget: cfg.taskBudget,\n\t\t};\n\n\t\tlet hasMoreToolCalls = true;\n\t\tconst allMessages = [...context.messages];\n\t\tconst getSteeringMessages =\n\t\t\tcfg.getSteeringMessages ?? cfg.getQueuedMessages;\n\t\tconst getFollowUpMessages = cfg.getFollowUpMessages;\n\t\tconst getPromptOnlyMessages = cfg.getPromptOnlyMessages;\n\n\t\tlet pendingMessages = getSteeringMessages\n\t\t\t? await getSteeringMessages<AppMessage>()\n\t\t\t: [];\n\n\t\twhile (hasMoreToolCalls || pendingMessages.length > 0) {\n\t\t\tyield { type: \"turn_start\" };\n\n\t\t\t// Enforce session limits before every turn (duration + tokens)\n\t\t\tif (cfg.session) {\n\t\t\t\tlet tokenCount: number | undefined;\n\t\t\t\tif (this.sessionTokenCounter) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst count = await this.sessionTokenCounter(cfg.session.id);\n\t\t\t\t\t\tif (count !== null) {\n\t\t\t\t\t\t\ttokenCount = count;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t// Log error but don't throw - let checkSessionLimits handle it.\n\t\t\t\t\t\t// If limits are active, it will fail closed because tokenCount is undefined.\n\t\t\t\t\t\t// If no limits are active, we shouldn't block just because tracking failed.\n\t\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\t\"Failed to get session token count\",\n\t\t\t\t\t\t\terr instanceof Error ? err : new Error(String(err)),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst limitCheck = checkSessionLimits(cfg.session, {\n\t\t\t\t\ttokenCount: tokenCount,\n\t\t\t\t});\n\t\t\t\tif (!limitCheck.allowed) {\n\t\t\t\t\tthrow new Error(limitCheck.reason);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (getPromptOnlyMessages) {\n\t\t\t\tconst promptOnlyMessages = await getPromptOnlyMessages();\n\t\t\t\tif (promptOnlyMessages.length > 0) {\n\t\t\t\t\tallMessages.push(...promptOnlyMessages);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (pendingMessages.length > 0) {\n\t\t\t\tfor (const queued of pendingMessages) {\n\t\t\t\t\tyield { type: \"message_start\", message: queued.original };\n\t\t\t\t\tyield { type: \"message_end\", message: queued.original };\n\t\t\t\t\tif (queued.llm) {\n\t\t\t\t\t\tallMessages.push(queued.llm);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpendingMessages = [];\n\t\t\t}\n\n\t\t\tlet currentAssistantMessage: AssistantMessage | null = null;\n\t\t\tlet completedAssistantMessage: AssistantMessage | null = null;\n\t\t\tconst toolCallsToExecute: ToolCall[] = [];\n\t\t\tlet toolResults: ToolResultMessage[] = [];\n\t\t\tlet steeringAfterTools: QueuedMessage<AppMessage>[] | null = null;\n\t\t\tlet pendingNextTurn = false;\n\t\t\tlet encounteredError = false;\n\t\t\tlet firstModelOutputSeen = false;\n\n\t\t\tconst currentMessages = cfg.preprocessMessages\n\t\t\t\t? await cfg.preprocessMessages(\n\t\t\t\t\t\tallMessages,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsystemPrompt,\n\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tuserMessage,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t)\n\t\t\t\t: allMessages;\n\n\t\t\tconst currentContext = {\n\t\t\t\t...context,\n\t\t\t\tmessages: currentMessages,\n\t\t\t};\n\n\t\t\t// Stream retry logic for idle timeouts\n\t\t\tconst networkConfig = getProviderNetworkConfig(model.provider);\n\t\t\tconst maxStreamRetries = networkConfig.streamMaxRetries;\n\t\t\tlet streamAttempt = 0;\n\t\t\tlet streamSuccess = false;\n\n\t\t\twhile (!streamSuccess && streamAttempt <= maxStreamRetries) {\n\t\t\t\tif (streamAttempt > 0) {\n\t\t\t\t\t// Reset state for retry\n\t\t\t\t\tcurrentAssistantMessage = null;\n\t\t\t\t\ttoolCallsToExecute.length = 0;\n\t\t\t\t\tpendingNextTurn = false;\n\n\t\t\t\t\tconst backoffMs = Math.min(\n\t\t\t\t\t\tnetworkConfig.backoffInitial * 2 ** (streamAttempt - 1),\n\t\t\t\t\t\tnetworkConfig.backoffMax,\n\t\t\t\t\t);\n\t\t\t\t\tlogger.info(\"Retrying stream after idle timeout\", {\n\t\t\t\t\t\tattempt: streamAttempt,\n\t\t\t\t\t\tmaxRetries: maxStreamRetries,\n\t\t\t\t\t\tbackoffMs,\n\t\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\t});\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, backoffMs));\n\t\t\t\t}\n\t\t\t\tstreamAttempt++;\n\n\t\t\t\tcfg.queryProfiler?.checkpoint(\"model:request:start\", {\n\t\t\t\t\tattempt: streamAttempt,\n\t\t\t\t});\n\t\t\t\tconst stream = createProviderStream(\n\t\t\t\t\tmodel,\n\t\t\t\t\tcurrentContext,\n\t\t\t\t\tstreamOptions,\n\t\t\t\t\t{ reasoning: cfg.reasoning, reasoningSummary: cfg.reasoningSummary },\n\t\t\t\t);\n\n\t\t\t\ttry {\n\t\t\t\t\tfor await (const event of stream) {\n\t\t\t\t\t\tif (event.type === \"start\") {\n\t\t\t\t\t\t\tcurrentAssistantMessage = event.partial;\n\t\t\t\t\t\t\tif (currentAssistantMessage) {\n\t\t\t\t\t\t\t\tyield {\n\t\t\t\t\t\t\t\t\ttype: \"message_start\",\n\t\t\t\t\t\t\t\t\tmessage: currentAssistantMessage,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tevent.type === \"text_delta\" ||\n\t\t\t\t\t\t\tevent.type === \"thinking_delta\" ||\n\t\t\t\t\t\t\tevent.type === \"toolcall_delta\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tif (!firstModelOutputSeen) {\n\t\t\t\t\t\t\t\tcfg.queryProfiler?.checkpoint(\"model:first-token\");\n\t\t\t\t\t\t\t\tfirstModelOutputSeen = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (currentAssistantMessage) {\n\t\t\t\t\t\t\t\tyield {\n\t\t\t\t\t\t\t\t\ttype: \"message_update\",\n\t\t\t\t\t\t\t\t\tmessage: currentAssistantMessage,\n\t\t\t\t\t\t\t\t\tassistantMessageEvent: event,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (event.type === \"toolcall_end\") {\n\t\t\t\t\t\t\tif (!firstModelOutputSeen) {\n\t\t\t\t\t\t\t\tcfg.queryProfiler?.checkpoint(\"model:first-token\");\n\t\t\t\t\t\t\t\tfirstModelOutputSeen = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst rawArgs = event.toolCall.arguments;\n\t\t\t\t\t\t\tconst normalizedArgs =\n\t\t\t\t\t\t\t\trawArgs &&\n\t\t\t\t\t\t\t\ttypeof rawArgs === \"object\" &&\n\t\t\t\t\t\t\t\t!Array.isArray(rawArgs)\n\t\t\t\t\t\t\t\t\t? (rawArgs as Record<string, unknown>)\n\t\t\t\t\t\t\t\t\t: {};\n\t\t\t\t\t\t\ttoolCallsToExecute.push({\n\t\t\t\t\t\t\t\ttype: \"toolCall\",\n\t\t\t\t\t\t\t\tid: event.toolCall.id,\n\t\t\t\t\t\t\t\tname: event.toolCall.name,\n\t\t\t\t\t\t\t\targuments: normalizedArgs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (event.type === \"done\") {\n\t\t\t\t\t\t\tif (currentAssistantMessage) {\n\t\t\t\t\t\t\t\tcompletedAssistantMessage = currentAssistantMessage;\n\t\t\t\t\t\t\t\tyield { type: \"message_end\", message: currentAssistantMessage };\n\t\t\t\t\t\t\t\tif (currentAssistantMessage.usage) {\n\t\t\t\t\t\t\t\t\tconst usage = currentAssistantMessage.usage;\n\t\t\t\t\t\t\t\t\tconst cost = model.cost\n\t\t\t\t\t\t\t\t\t\t? calculateCost(usage, model.cost)\n\t\t\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t\t\t\t\tif (credential?.type !== \"anthropic-oauth\") {\n\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\ttrackUsage({\n\t\t\t\t\t\t\t\t\t\t\t\tsessionId: cfg.session?.id,\n\t\t\t\t\t\t\t\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\t\t\t\t\t\t\t\tmodel: model.id,\n\t\t\t\t\t\t\t\t\t\t\t\ttokensInput: usage.input || 0,\n\t\t\t\t\t\t\t\t\t\t\t\ttokensOutput: usage.output || 0,\n\t\t\t\t\t\t\t\t\t\t\t\ttokensCacheRead: usage.cacheRead,\n\t\t\t\t\t\t\t\t\t\t\t\ttokensCacheWrite: usage.cacheWrite,\n\t\t\t\t\t\t\t\t\t\t\t\tcost,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\t\t\tlogger.warn(\"Failed to track usage\", {\n\t\t\t\t\t\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: String(error),\n\t\t\t\t\t\t\t\t\t\t\t\tstack: error instanceof Error ? error.stack : undefined,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpendingNextTurn = toolCallsToExecute.length > 0;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (event.type === \"error\") {\n\t\t\t\t\t\t\tcompletedAssistantMessage = event.error;\n\t\t\t\t\t\t\tif (currentAssistantMessage) {\n\t\t\t\t\t\t\t\tyield { type: \"message_end\", message: currentAssistantMessage };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpendingNextTurn = false;\n\t\t\t\t\t\t\tencounteredError = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tstreamSuccess = true;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tisStreamIdleTimeoutError(error) &&\n\t\t\t\t\t\tstreamAttempt <= maxStreamRetries\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.warn(\"Stream idle timeout, will retry\", {\n\t\t\t\t\t\t\tattempt: streamAttempt,\n\t\t\t\t\t\t\tmaxRetries: maxStreamRetries,\n\t\t\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\t\t\tidleMs: error.idleMs,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontinue; // Retry the stream\n\t\t\t\t\t}\n\t\t\t\t\t// Not retryable or exhausted retries - re-throw\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t} // end while retry loop\n\n\t\t\tif (toolCallsToExecute.length > 0) {\n\t\t\t\ttoolResults = [];\n\t\t\t\tconst toolUpdateQueue = createToolUpdateQueue();\n\t\t\t\tconst pendingExecutions: PendingExecution[] = [];\n\t\t\t\tconst rawConcurrency = this.options.maxConcurrentToolExecutions ?? 2;\n\t\t\t\tconst configuredConcurrency = Number.isFinite(rawConcurrency)\n\t\t\t\t\t? Math.max(1, Math.floor(rawConcurrency))\n\t\t\t\t\t: 2;\n\t\t\t\tconst hasWorkflowTrackedTool = toolCallsToExecute.some((call) =>\n\t\t\t\t\tisWorkflowTrackedTool(call.name),\n\t\t\t\t);\n\t\t\t\tconst requiresSerializedTurn =\n\t\t\t\t\thasWorkflowTrackedTool && toolCallsToExecute.length > 1;\n\n\t\t\t\t// Calculate optimal concurrency - higher for read-only batches\n\t\t\t\tlet concurrencyLimit = getOptimalConcurrency(\n\t\t\t\t\ttoolCallsToExecute,\n\t\t\t\t\ttools,\n\t\t\t\t\t{\n\t\t\t\t\t\tbaseConcurrency: configuredConcurrency,\n\t\t\t\t\t\tmaxReadOnlyConcurrency: 8, // Allow up to 8x parallel for read-only\n\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\t// Override: workflow-tracked tools require serialization\n\t\t\t\tif (configuredConcurrency > 1 && requiresSerializedTurn) {\n\t\t\t\t\tconcurrencyLimit = 1;\n\t\t\t\t\tif (!this.warnedAboutWorkflowConcurrency) {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t\"WorkflowStateTracker requires serialized tool execution; maxConcurrentToolExecutions capped at 1\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.warnedAboutWorkflowConcurrency = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet steeringTriggered = false;\n\t\t\t\tlet remainingToolCalls: ToolCall[] = [];\n\n\t\t\t\tconst checkSteering = async (): Promise<void> => {\n\t\t\t\t\tif (steeringTriggered || !getSteeringMessages) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst steering = await getSteeringMessages<AppMessage>();\n\t\t\t\t\tif (steering.length > 0) {\n\t\t\t\t\t\tsteeringTriggered = true;\n\t\t\t\t\t\tsteeringAfterTools = steering;\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tconst buildExecutionEvents = (\n\t\t\t\t\ttoolCall: ToolCall,\n\t\t\t\t\tmessage: ToolResultMessage,\n\t\t\t\t\tisError: boolean,\n\t\t\t\t\tmetadata?: {\n\t\t\t\t\t\ttoolExecutionId?: string;\n\t\t\t\t\t\tapprovalRequestId?: string;\n\t\t\t\t\t},\n\t\t\t\t): AgentEvent[] => {\n\t\t\t\t\tconst governedMetadata = getGovernedToolResultEventMetadata(\n\t\t\t\t\t\tmessage.details,\n\t\t\t\t\t);\n\t\t\t\t\tconst skillMetadata = getSkillToolResultEventMetadata(\n\t\t\t\t\t\tmessage.details,\n\t\t\t\t\t).skillMetadata;\n\t\t\t\t\treturn [\n\t\t\t\t\t\t{ type: \"message_start\", message } as AgentEvent,\n\t\t\t\t\t\t{ type: \"message_end\", message } as AgentEvent,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"tool_execution_end\",\n\t\t\t\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\t\t\t\ttoolExecutionId: metadata?.toolExecutionId,\n\t\t\t\t\t\t\tapprovalRequestId:\n\t\t\t\t\t\t\t\tmetadata?.approvalRequestId ??\n\t\t\t\t\t\t\t\tgovernedMetadata.approvalRequestId,\n\t\t\t\t\t\t\terrorCode: governedMetadata.errorCode,\n\t\t\t\t\t\t\tgovernedOutcome: governedMetadata.governedOutcome,\n\t\t\t\t\t\t\tskillMetadata,\n\t\t\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\t\t\tresult: message,\n\t\t\t\t\t\t\tisError,\n\t\t\t\t\t\t} as AgentEvent,\n\t\t\t\t\t];\n\t\t\t\t};\n\t\t\t\tconst emitToolResult = (\n\t\t\t\t\tmessage: ToolResultMessage,\n\t\t\t\t\ttoolCall: ToolCall,\n\t\t\t\t\tisError: boolean,\n\t\t\t\t\tmetadata?: {\n\t\t\t\t\t\ttoolExecutionId?: string;\n\t\t\t\t\t\tapprovalRequestId?: string;\n\t\t\t\t\t},\n\t\t\t\t) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tapplyWorkflowStateHooks({\n\t\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\t\tresult: message,\n\t\t\t\t\t\t\ttracker: this.workflowState,\n\t\t\t\t\t\t\tisError,\n\t\t\t\t\t\t});\n\t\t\t\t\t\ttoolResults.push(message);\n\t\t\t\t\t\treturn buildExecutionEvents(toolCall, message, isError, metadata);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (error instanceof WorkflowStateError) {\n\t\t\t\t\t\t\tconst workflowErrorResult: ToolResultMessage = {\n\t\t\t\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: error.message }],\n\t\t\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\t\t\ttimestamp: this.clock.now(),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\ttoolResults.push(workflowErrorResult);\n\t\t\t\t\t\t\treturn buildExecutionEvents(\n\t\t\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\t\t\tworkflowErrorResult,\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst emitSkippedToolCall = (toolCall: ToolCall): AgentEvent[] => {\n\t\t\t\t\tconst sanitizedSkippedArgs = this.safetyMiddleware.sanitizeForLogging(\n\t\t\t\t\t\ttoolCall.arguments as Record<string, unknown>,\n\t\t\t\t\t);\n\t\t\t\t\tconst skippedResult: ToolResultMessage = {\n\t\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: \"Skipped due to queued user message.\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\ttimestamp: this.clock.now(),\n\t\t\t\t\t};\n\t\t\t\t\treturn [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"tool_execution_start\",\n\t\t\t\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\t\t\targs: sanitizedSkippedArgs,\n\t\t\t\t\t\t} as AgentEvent,\n\t\t\t\t\t\t...emitToolResult(skippedResult, toolCall, true),\n\t\t\t\t\t];\n\t\t\t\t};\n\n\t\t\t\tconst scheduleResolveIfNeeded = async (): Promise<AgentEvent[]> => {\n\t\t\t\t\tif (pendingExecutions.length < concurrencyLimit) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\tconst events: AgentEvent[] = [];\n\t\t\t\t\twhile (pendingExecutions.length >= concurrencyLimit) {\n\t\t\t\t\t\tconst next = await waitForNextExecutionOrUpdate(\n\t\t\t\t\t\t\tpendingExecutions,\n\t\t\t\t\t\t\ttoolUpdateQueue,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (next.kind === \"update\") {\n\t\t\t\t\t\t\tevents.push(next.event);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst outcome = next.outcome;\n\t\t\t\t\t\tevents.push(\n\t\t\t\t\t\t\t...emitToolResult(\n\t\t\t\t\t\t\t\toutcome.message,\n\t\t\t\t\t\t\t\tnext.execution.toolCall,\n\t\t\t\t\t\t\t\toutcome.isError,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttoolExecutionId: outcome.toolExecutionId,\n\t\t\t\t\t\t\t\t\tapprovalRequestId: outcome.approvalRequestId,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait checkSteering();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\treturn events;\n\t\t\t\t};\n\n\t\t\t\tfor (\n\t\t\t\t\tlet toolIndex = 0;\n\t\t\t\t\ttoolIndex < toolCallsToExecute.length;\n\t\t\t\t\ttoolIndex++\n\t\t\t\t) {\n\t\t\t\t\tif (steeringTriggered) {\n\t\t\t\t\t\tremainingToolCalls = toolCallsToExecute.slice(toolIndex);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst toolCall = toolCallsToExecute[toolIndex];\n\t\t\t\t\tif (!toolCall) continue;\n\n\t\t\t\t\t// Run safety pipeline (rate limiting, hooks, firewall, approval, validation)\n\t\t\t\t\tconst safetyIterator = evaluateToolSafety({\n\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\ttools,\n\t\t\t\t\t\tuserMessage,\n\t\t\t\t\t\tcfg,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tclock: this.clock,\n\t\t\t\t\t\tsafetyMiddleware: this.safetyMiddleware,\n\t\t\t\t\t\tworkflowState: this.workflowState,\n\t\t\t\t\t\tadaptiveThresholds: this.adaptiveThresholds,\n\t\t\t\t\t\tauditLogger: this.auditLogger,\n\t\t\t\t\t\tapprovalService: this.options.approvalService,\n\t\t\t\t\t\ttoolExecutionBridge:\n\t\t\t\t\t\t\tthis.options.platformToolExecutionBridge === false\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: (this.options.platformToolExecutionBridge ??\n\t\t\t\t\t\t\t\t\tgetDefaultPlatformToolExecutionBridge()),\n\t\t\t\t\t\thookService,\n\t\t\t\t\t\tfirewall,\n\t\t\t\t\t\trateLimitState: {\n\t\t\t\t\t\t\trecentToolTimestamps: this.recentToolTimestamps,\n\t\t\t\t\t\t\ttoolCallsThisMinute: this.toolCallsThisMinute,\n\t\t\t\t\t\t\tminuteWindowStart: this.minuteWindowStart,\n\t\t\t\t\t\t\trateWindowMs: ProviderTransport.TOOL_RATE_WINDOW_MS,\n\t\t\t\t\t\t\trateLimit: ProviderTransport.TOOL_RATE_LIMIT,\n\t\t\t\t\t\t},\n\t\t\t\t\t\temitToolResult,\n\t\t\t\t\t});\n\t\t\t\t\tlet safetyVerdict: ToolSafetyVerdict | undefined;\n\t\t\t\t\tlet rateLimitUpdate:\n\t\t\t\t\t\t| { toolCallsThisMinute: number; minuteWindowStart: number }\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst safetyStep = await safetyIterator.next();\n\t\t\t\t\t\tif (safetyStep.done) {\n\t\t\t\t\t\t\t({ verdict: safetyVerdict, rateLimitUpdate } = safetyStep.value);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tyield safetyStep.value;\n\t\t\t\t\t}\n\t\t\t\t\tif (!safetyVerdict || !rateLimitUpdate) {\n\t\t\t\t\t\tthrow new Error(\"Safety pipeline did not return a verdict.\");\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply rate limit state updates\n\t\t\t\t\tthis.toolCallsThisMinute = rateLimitUpdate.toolCallsThisMinute;\n\t\t\t\t\tthis.minuteWindowStart = rateLimitUpdate.minuteWindowStart;\n\n\t\t\t\t\tif (safetyVerdict.outcome === \"blocked\") {\n\t\t\t\t\t\tawait checkSteering();\n\t\t\t\t\t\tif (steeringTriggered) {\n\t\t\t\t\t\t\tremainingToolCalls = toolCallsToExecute.slice(toolIndex + 1);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst {\n\t\t\t\t\t\teffectiveToolCall,\n\t\t\t\t\t\tvalidatedArgs,\n\t\t\t\t\t\ttoolDef: tool,\n\t\t\t\t\t\tsanitizedExecutionArgs,\n\t\t\t\t\t} = safetyVerdict;\n\t\t\t\t\t// Use hook-modified (pre-validation) args for hook inputs\n\n\t\t\t\t\t// For client tools, set up the execution promise first, then emit event\n\t\t\t\t\t// This prevents race conditions where the client responds before we're listening\n\t\t\t\t\tlet clientToolExecPromise:\n\t\t\t\t\t\t| ReturnType<ClientToolExecutionService[\"requestExecution\"]>\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tif (\n\t\t\t\t\t\ttool.executionLocation === \"client\" &&\n\t\t\t\t\t\tthis.options.clientToolService\n\t\t\t\t\t) {\n\t\t\t\t\t\tclientToolExecPromise =\n\t\t\t\t\t\t\tthis.options.clientToolService.requestExecution(\n\t\t\t\t\t\t\t\ttoolCall.id,\n\t\t\t\t\t\t\t\ttoolCall.name,\n\t\t\t\t\t\t\t\tvalidatedArgs,\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t// Now emit the event - the promise is already waiting for the result\n\t\t\t\t\t\tyield {\n\t\t\t\t\t\t\ttype: \"client_tool_request\",\n\t\t\t\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\t\t\t\ttoolName: toolCall.name,\n\t\t\t\t\t\t\t// Client tools execute out-of-process; they need the real args.\n\t\t\t\t\t\t\targs: validatedArgs,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst executionPromise = createToolExecutionPromise({\n\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\teffectiveToolCall,\n\t\t\t\t\t\ttool,\n\t\t\t\t\t\tvalidatedArgs,\n\t\t\t\t\t\tsanitizedExecutionArgs,\n\t\t\t\t\t\tcfg,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tclock: this.clock,\n\t\t\t\t\t\tsafetyMiddleware: this.safetyMiddleware,\n\t\t\t\t\t\tadaptiveThresholds: this.adaptiveThresholds,\n\t\t\t\t\t\tauditLogger: this.auditLogger,\n\t\t\t\t\t\thookService,\n\t\t\t\t\t\ttoolRetryService: this.options.toolRetryService,\n\t\t\t\t\t\ttoolRetryConfig: this.options.toolRetryConfig,\n\t\t\t\t\t\tclientToolService: this.options.clientToolService,\n\t\t\t\t\t\ttoolExecutionBridge:\n\t\t\t\t\t\t\tthis.options.platformToolExecutionBridge === false\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: (this.options.platformToolExecutionBridge ??\n\t\t\t\t\t\t\t\t\tgetDefaultPlatformToolExecutionBridge()),\n\t\t\t\t\t\ttoolExecutionBridgePlan: safetyVerdict.toolExecutionBridgePlan,\n\t\t\t\t\t\ttoolUpdateQueue,\n\t\t\t\t\t\tclientToolExecPromise,\n\t\t\t\t\t});\n\n\t\t\t\t\tpendingExecutions.push({\n\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\tpromise: executionPromise,\n\t\t\t\t\t});\n\t\t\t\t\tconst events = await scheduleResolveIfNeeded();\n\t\t\t\t\tfor (const event of events) {\n\t\t\t\t\t\tyield event;\n\t\t\t\t\t}\n\t\t\t\t\tif (steeringTriggered) {\n\t\t\t\t\t\tremainingToolCalls = toolCallsToExecute.slice(toolIndex + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\twhile (pendingExecutions.length > 0) {\n\t\t\t\t\tconst next = await waitForNextExecutionOrUpdate(\n\t\t\t\t\t\tpendingExecutions,\n\t\t\t\t\t\ttoolUpdateQueue,\n\t\t\t\t\t);\n\t\t\t\t\tif (next.kind === \"update\") {\n\t\t\t\t\t\tyield next.event;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst outcome = next.outcome;\n\t\t\t\t\tfor (const event of emitToolResult(\n\t\t\t\t\t\toutcome.message,\n\t\t\t\t\t\tnext.execution.toolCall,\n\t\t\t\t\t\toutcome.isError,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttoolExecutionId: outcome.toolExecutionId,\n\t\t\t\t\t\t\tapprovalRequestId: outcome.approvalRequestId,\n\t\t\t\t\t\t},\n\t\t\t\t\t)) {\n\t\t\t\t\t\tyield event;\n\t\t\t\t\t}\n\t\t\t\t\tawait checkSteering();\n\t\t\t\t}\n\n\t\t\t\tthis.safetyMiddleware.clearCredentials();\n\n\t\t\t\tif (steeringTriggered && remainingToolCalls.length > 0) {\n\t\t\t\t\tfor (const toolCall of remainingToolCalls) {\n\t\t\t\t\t\tfor (const event of emitSkippedToolCall(toolCall)) {\n\t\t\t\t\t\t\tyield event;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!steeringTriggered && getSteeringMessages) {\n\t\t\t\t\tconst steering = await getSteeringMessages<AppMessage>();\n\t\t\t\t\tif (steering.length > 0) {\n\t\t\t\t\t\tsteeringAfterTools = steering;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (completedAssistantMessage) {\n\t\t\t\tallMessages.push(completedAssistantMessage);\n\t\t\t}\n\t\t\tallMessages.push(...toolResults);\n\n\t\t\tyield {\n\t\t\t\ttype: \"turn_end\",\n\t\t\t\tmessage: completedAssistantMessage ??\n\t\t\t\t\tcurrentAssistantMessage ?? {\n\t\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\t\tcontent: [],\n\t\t\t\t\t\tapi: model.api,\n\t\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\t\tmodel: model.id,\n\t\t\t\t\t\tusage: {\n\t\t\t\t\t\t\tinput: 0,\n\t\t\t\t\t\t\toutput: 0,\n\t\t\t\t\t\t\tcacheRead: 0,\n\t\t\t\t\t\t\tcacheWrite: 0,\n\t\t\t\t\t\t\tcost: {\n\t\t\t\t\t\t\t\tinput: 0,\n\t\t\t\t\t\t\t\toutput: 0,\n\t\t\t\t\t\t\t\tcacheRead: 0,\n\t\t\t\t\t\t\t\tcacheWrite: 0,\n\t\t\t\t\t\t\t\ttotal: 0,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstopReason: \"error\",\n\t\t\t\t\t\ttimestamp: this.clock.now(),\n\t\t\t\t\t},\n\t\t\t\ttoolResults,\n\t\t\t};\n\n\t\t\tif (steeringAfterTools && steeringAfterTools.length > 0) {\n\t\t\t\tpendingMessages = steeringAfterTools;\n\t\t\t} else if (getSteeringMessages) {\n\t\t\t\tconst steering = await getSteeringMessages<AppMessage>();\n\t\t\t\tif (steering.length > 0) {\n\t\t\t\t\tpendingMessages = steering;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t!pendingNextTurn &&\n\t\t\t\tpendingMessages.length === 0 &&\n\t\t\t\tgetFollowUpMessages\n\t\t\t) {\n\t\t\t\tconst followUps = await getFollowUpMessages<AppMessage>();\n\t\t\t\tif (followUps.length > 0) {\n\t\t\t\t\tpendingMessages = followUps;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (pendingMessages.length > 0) {\n\t\t\t\tpendingNextTurn = true;\n\t\t\t}\n\n\t\t\thasMoreToolCalls = encounteredError ? false : pendingNextTurn;\n\t\t\tif (encounteredError) {\n\t\t\t\tcfg.queryProfiler?.terminal(\"turn:error\");\n\t\t\t} else if (!hasMoreToolCalls) {\n\t\t\t\tcfg.queryProfiler?.terminal(\"turn:complete\", {\n\t\t\t\t\ttool_results: toolResults.length,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
package/dist/agent/types.d.ts
CHANGED
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
*/
|
|
33
33
|
import type { TSchema } from "@sinclair/typebox";
|
|
34
34
|
import type { PromptMetadata } from "../prompts/types.js";
|
|
35
|
+
import type { SkillArtifactMetadata } from "../skills/artifact-metadata.js";
|
|
36
|
+
import type { CheckpointProfiler } from "../utils/checkpoint-profiler.js";
|
|
35
37
|
import type { ActionApprovalDecision, ActionApprovalRequest } from "./action-approval.js";
|
|
36
38
|
import type { ToolRetryDecision, ToolRetryRequest } from "./tool-retry.js";
|
|
37
39
|
/**
|
|
@@ -40,12 +42,13 @@ import type { ToolRetryDecision, ToolRetryRequest } from "./tool-retry.js";
|
|
|
40
42
|
* Each provider may support different API formats:
|
|
41
43
|
* - `openai-completions` - OpenAI Chat Completions API
|
|
42
44
|
* - `openai-responses` - OpenAI Responses API (newer format)
|
|
45
|
+
* - `openai-codex-responses` - ChatGPT Codex Responses backend
|
|
43
46
|
* - `anthropic-messages` - Anthropic Messages API
|
|
44
47
|
* - `google-generative-ai` - Google Generative AI (Gemini)
|
|
45
48
|
* - `google-gemini-cli` - Google Cloud Code Assist (Gemini CLI)
|
|
46
49
|
* - `bedrock-converse` - AWS Bedrock Converse API
|
|
47
50
|
*/
|
|
48
|
-
export type Api = "openai-completions" | "openai-responses" | "anthropic-messages" | "google-generative-ai" | "google-gemini-cli" | "bedrock-converse" | "vertex-ai";
|
|
51
|
+
export type Api = "openai-completions" | "openai-responses" | "openai-codex-responses" | "anthropic-messages" | "google-generative-ai" | "google-gemini-cli" | "bedrock-converse" | "vertex-ai";
|
|
49
52
|
export interface OpenAICompatOverrides {
|
|
50
53
|
supportsStore?: boolean;
|
|
51
54
|
supportsDeveloperRole?: boolean;
|
|
@@ -75,7 +78,7 @@ export interface OpenAICompatOverrides {
|
|
|
75
78
|
* - `openrouter` - OpenRouter (aggregator)
|
|
76
79
|
* - `zai` - ZAI
|
|
77
80
|
*/
|
|
78
|
-
export type KnownProvider = "anthropic" | "bedrock" | "google" | "openai" | "azure-openai" | "writer" | "xai" | "groq" | "cerebras" | "openrouter" | "zai";
|
|
81
|
+
export type KnownProvider = "anthropic" | "bedrock" | "google" | "openai" | "openai-codex" | "azure-openai" | "writer" | "xai" | "groq" | "cerebras" | "openrouter" | "zai";
|
|
79
82
|
/**
|
|
80
83
|
* Provider identifier - either a known provider or a custom string.
|
|
81
84
|
* Custom providers can be used with OpenAI-compatible APIs.
|
|
@@ -994,6 +997,8 @@ export type AgentEvent = {
|
|
|
994
997
|
type: "tool_execution_start";
|
|
995
998
|
/** Tool call identifier */
|
|
996
999
|
toolCallId: string;
|
|
1000
|
+
/** Optional Platform ToolExecution identifier */
|
|
1001
|
+
toolExecutionId?: string;
|
|
997
1002
|
/** Name of the tool */
|
|
998
1003
|
toolName: string;
|
|
999
1004
|
/** Optional human-facing label for live UI */
|
|
@@ -1007,6 +1012,16 @@ export type AgentEvent = {
|
|
|
1007
1012
|
type: "tool_execution_end";
|
|
1008
1013
|
/** Tool call identifier */
|
|
1009
1014
|
toolCallId: string;
|
|
1015
|
+
/** Optional Platform ToolExecution identifier */
|
|
1016
|
+
toolExecutionId?: string;
|
|
1017
|
+
/** Optional approval request identifier correlated to Platform ToolExecution */
|
|
1018
|
+
approvalRequestId?: string;
|
|
1019
|
+
/** Optional stable error or outcome code for telemetry and clients */
|
|
1020
|
+
errorCode?: string;
|
|
1021
|
+
/** Optional governed outcome classification surfaced by the tool result */
|
|
1022
|
+
governedOutcome?: "approval_required" | "approval_pending" | "authentication_required" | "denied" | "rate_limited";
|
|
1023
|
+
/** Optional selected skill artifact metadata surfaced by the tool result */
|
|
1024
|
+
skillMetadata?: SkillArtifactMetadata;
|
|
1010
1025
|
/** Name of the tool */
|
|
1011
1026
|
toolName: string;
|
|
1012
1027
|
/** Optional human-facing label for live UI */
|
|
@@ -1017,6 +1032,35 @@ export type AgentEvent = {
|
|
|
1017
1032
|
result: ToolResultMessage;
|
|
1018
1033
|
/** Whether the tool returned an error */
|
|
1019
1034
|
isError: boolean;
|
|
1035
|
+
} | {
|
|
1036
|
+
/** LSP diagnostic delta produced by an edit/write tool call */
|
|
1037
|
+
type: "diagnostic_delta";
|
|
1038
|
+
/** Tool call identifier */
|
|
1039
|
+
toolCallId: string;
|
|
1040
|
+
/** Name of the tool */
|
|
1041
|
+
toolName: string;
|
|
1042
|
+
/** File affected by the diagnostic delta */
|
|
1043
|
+
file: string;
|
|
1044
|
+
/** User-facing file path from the tool call */
|
|
1045
|
+
displayPath: string;
|
|
1046
|
+
/** Whether a pre-edit baseline was available */
|
|
1047
|
+
usedDelta: boolean;
|
|
1048
|
+
/** Newly introduced diagnostic count */
|
|
1049
|
+
introducedCount: number;
|
|
1050
|
+
/** Diagnostics repaired by the tool call */
|
|
1051
|
+
repairedCount: number;
|
|
1052
|
+
/** Remaining diagnostics for the affected file */
|
|
1053
|
+
remainingCount: number;
|
|
1054
|
+
/** Stable fingerprint for introduced diagnostics */
|
|
1055
|
+
fingerprint: string;
|
|
1056
|
+
/** Repair attempt number for this fingerprint */
|
|
1057
|
+
repairAttempt?: number;
|
|
1058
|
+
/** Maximum automatic repair attempts for this fingerprint */
|
|
1059
|
+
maxRepairAttempts?: number;
|
|
1060
|
+
/** Whether Agent queued a follow-up repair turn */
|
|
1061
|
+
willAutoFollowUp: boolean;
|
|
1062
|
+
/** Why a repair follow-up was or was not queued */
|
|
1063
|
+
reason: string;
|
|
1020
1064
|
} | {
|
|
1021
1065
|
/** Summary emitted after the final tool in a batch completes */
|
|
1022
1066
|
type: "tool_batch_summary";
|
|
@@ -1206,6 +1250,8 @@ export interface AgentRunConfig {
|
|
|
1206
1250
|
};
|
|
1207
1251
|
/** Optional helper function for running LLM queries (e.g., for summarization) */
|
|
1208
1252
|
runLLM?: (systemPrompt: string, userPrompt: string) => Promise<string>;
|
|
1253
|
+
/** Optional debug checkpoint profiler for local query latency diagnostics. */
|
|
1254
|
+
queryProfiler?: CheckpointProfiler;
|
|
1209
1255
|
/** Optional sandbox for isolated tool execution */
|
|
1210
1256
|
sandbox?: import("../sandbox/types.js").Sandbox;
|
|
1211
1257
|
/** Sampling temperature override (0.0-2.0, lower = more deterministic) */
|
|
@@ -1273,6 +1319,8 @@ export interface StreamOptions {
|
|
|
1273
1319
|
headers?: Record<string, string>;
|
|
1274
1320
|
/** Additional request body fields for provider-specific extensions */
|
|
1275
1321
|
requestBody?: Record<string, unknown>;
|
|
1322
|
+
/** Stable session id for provider-side request grouping/cache keys */
|
|
1323
|
+
sessionId?: string;
|
|
1276
1324
|
/** Authentication type for the request */
|
|
1277
1325
|
authType?: "api-key" | "anthropic-oauth";
|
|
1278
1326
|
/** Optional Anthropic API-side task budget for the current turn */
|