@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
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { postPlatformConnect, resolvePlatformServiceConfig, trimString, } from "./client.js";
|
|
2
|
+
import { PLATFORM_CONNECT_METHODS, platformConnectMethodPath, platformConnectServicePath, } from "./core-services.js";
|
|
3
|
+
const DEFAULT_TIMEOUT_MS = 2_500;
|
|
4
|
+
const DEFAULT_MAX_ATTEMPTS = 2;
|
|
5
|
+
const TOOL_EXECUTION_BASE_URL_ENV_VARS = [
|
|
6
|
+
"TOOL_EXECUTION_SERVICE_URL",
|
|
7
|
+
"MAESTRO_TOOL_EXECUTION_SERVICE_URL",
|
|
8
|
+
"MAESTRO_PLATFORM_BASE_URL",
|
|
9
|
+
"MAESTRO_EVALOPS_BASE_URL",
|
|
10
|
+
"EVALOPS_BASE_URL",
|
|
11
|
+
];
|
|
12
|
+
const TOOL_EXECUTION_TOKEN_ENV_VARS = [
|
|
13
|
+
"TOOL_EXECUTION_SERVICE_TOKEN",
|
|
14
|
+
"MAESTRO_TOOL_EXECUTION_SERVICE_TOKEN",
|
|
15
|
+
"MAESTRO_EVALOPS_ACCESS_TOKEN",
|
|
16
|
+
"EVALOPS_TOKEN",
|
|
17
|
+
];
|
|
18
|
+
const TOOL_EXECUTION_ORGANIZATION_ENV_VARS = [
|
|
19
|
+
"TOOL_EXECUTION_SERVICE_ORGANIZATION_ID",
|
|
20
|
+
"MAESTRO_TOOL_EXECUTION_ORGANIZATION_ID",
|
|
21
|
+
"MAESTRO_EVALOPS_ORG_ID",
|
|
22
|
+
"EVALOPS_ORGANIZATION_ID",
|
|
23
|
+
"MAESTRO_ENTERPRISE_ORG_ID",
|
|
24
|
+
];
|
|
25
|
+
const TOOL_EXECUTION_WORKSPACE_ENV_VARS = [
|
|
26
|
+
"TOOL_EXECUTION_SERVICE_WORKSPACE_ID",
|
|
27
|
+
"MAESTRO_TOOL_EXECUTION_WORKSPACE_ID",
|
|
28
|
+
"MAESTRO_REMOTE_RUNNER_WORKSPACE_ID",
|
|
29
|
+
"MAESTRO_EVALOPS_WORKSPACE_ID",
|
|
30
|
+
"EVALOPS_WORKSPACE_ID",
|
|
31
|
+
"MAESTRO_WORKSPACE_ID",
|
|
32
|
+
];
|
|
33
|
+
const TOOL_EXECUTION_TIMEOUT_ENV_VARS = [
|
|
34
|
+
"TOOL_EXECUTION_SERVICE_TIMEOUT_MS",
|
|
35
|
+
"MAESTRO_TOOL_EXECUTION_SERVICE_TIMEOUT_MS",
|
|
36
|
+
];
|
|
37
|
+
const TOOL_EXECUTION_MAX_ATTEMPTS_ENV_VARS = [
|
|
38
|
+
"TOOL_EXECUTION_SERVICE_MAX_ATTEMPTS",
|
|
39
|
+
"MAESTRO_TOOL_EXECUTION_SERVICE_MAX_ATTEMPTS",
|
|
40
|
+
];
|
|
41
|
+
const EXECUTE_TOOL_PATH = platformConnectMethodPath(PLATFORM_CONNECT_METHODS.toolexecution.executeTool);
|
|
42
|
+
const RESUME_TOOL_EXECUTION_PATH = platformConnectMethodPath(PLATFORM_CONNECT_METHODS.toolexecution.resumeToolExecution);
|
|
43
|
+
const RECORD_TOOL_EXECUTION_OUTPUT_PATH = platformConnectMethodPath(PLATFORM_CONNECT_METHODS.toolexecution.recordToolExecutionOutput);
|
|
44
|
+
function stripTrailingSlashes(value) {
|
|
45
|
+
return value.replace(/\/+$/u, "");
|
|
46
|
+
}
|
|
47
|
+
function normalizeBaseUrl(baseUrl) {
|
|
48
|
+
let normalized = stripTrailingSlashes(baseUrl.trim());
|
|
49
|
+
for (const suffix of [
|
|
50
|
+
EXECUTE_TOOL_PATH,
|
|
51
|
+
RESUME_TOOL_EXECUTION_PATH,
|
|
52
|
+
RECORD_TOOL_EXECUTION_OUTPUT_PATH,
|
|
53
|
+
platformConnectServicePath(PLATFORM_CONNECT_METHODS.toolexecution.executeTool.service),
|
|
54
|
+
]) {
|
|
55
|
+
if (normalized.endsWith(suffix)) {
|
|
56
|
+
normalized = stripTrailingSlashes(normalized.slice(0, -suffix.length));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return normalized;
|
|
60
|
+
}
|
|
61
|
+
export async function resolveToolExecutionServiceConfig(overrides = {}) {
|
|
62
|
+
const config = await resolvePlatformServiceConfig({
|
|
63
|
+
baseUrlEnvVars: TOOL_EXECUTION_BASE_URL_ENV_VARS,
|
|
64
|
+
tokenEnvVars: TOOL_EXECUTION_TOKEN_ENV_VARS,
|
|
65
|
+
organizationEnvVars: TOOL_EXECUTION_ORGANIZATION_ENV_VARS,
|
|
66
|
+
workspaceEnvVars: TOOL_EXECUTION_WORKSPACE_ENV_VARS,
|
|
67
|
+
timeoutEnvVars: TOOL_EXECUTION_TIMEOUT_ENV_VARS,
|
|
68
|
+
maxAttemptsEnvVars: TOOL_EXECUTION_MAX_ATTEMPTS_ENV_VARS,
|
|
69
|
+
baseUrlSuffixes: [
|
|
70
|
+
EXECUTE_TOOL_PATH,
|
|
71
|
+
RESUME_TOOL_EXECUTION_PATH,
|
|
72
|
+
RECORD_TOOL_EXECUTION_OUTPUT_PATH,
|
|
73
|
+
platformConnectServicePath(PLATFORM_CONNECT_METHODS.toolexecution.executeTool.service),
|
|
74
|
+
],
|
|
75
|
+
defaultTimeoutMs: DEFAULT_TIMEOUT_MS,
|
|
76
|
+
defaultMaxAttempts: DEFAULT_MAX_ATTEMPTS,
|
|
77
|
+
requireBaseUrl: false,
|
|
78
|
+
requireOrganizationId: true,
|
|
79
|
+
requireToken: true,
|
|
80
|
+
});
|
|
81
|
+
if (!config?.baseUrl || !config.workspaceId) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
...config,
|
|
86
|
+
baseUrl: normalizeBaseUrl(trimString(overrides.baseUrl ?? config.baseUrl) ?? config.baseUrl),
|
|
87
|
+
organizationId: trimString(overrides.organizationId ?? config.organizationId) ??
|
|
88
|
+
config.organizationId,
|
|
89
|
+
workspaceId: trimString(overrides.workspaceId ?? config.workspaceId) ??
|
|
90
|
+
config.workspaceId,
|
|
91
|
+
token: trimString(overrides.token ?? config.token) ?? config.token,
|
|
92
|
+
timeoutMs: overrides.timeoutMs ?? config.timeoutMs,
|
|
93
|
+
maxAttempts: overrides.maxAttempts ?? config.maxAttempts,
|
|
94
|
+
teamId: trimString(overrides.teamId ?? config.teamId),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function firstString(record, ...keys) {
|
|
98
|
+
for (const key of keys) {
|
|
99
|
+
const value = record[key];
|
|
100
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
101
|
+
return value.trim();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
function firstBoolean(record, ...keys) {
|
|
107
|
+
for (const key of keys) {
|
|
108
|
+
const value = record[key];
|
|
109
|
+
if (typeof value === "boolean") {
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
function objectValue(record, ...keys) {
|
|
116
|
+
for (const key of keys) {
|
|
117
|
+
const value = record[key];
|
|
118
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
119
|
+
return value;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
function normalizeExecutionState(value) {
|
|
125
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
return value.trim();
|
|
129
|
+
}
|
|
130
|
+
function normalizeApprovalWait(record) {
|
|
131
|
+
if (!record) {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
const approvalRequestId = firstString(record, "approvalRequestId", "approval_request_id");
|
|
135
|
+
const resumeToken = firstString(record, "resumeToken", "resume_token");
|
|
136
|
+
const reason = firstString(record, "reason");
|
|
137
|
+
if (!approvalRequestId && !resumeToken && !reason) {
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
...(approvalRequestId ? { approvalRequestId } : {}),
|
|
142
|
+
...(resumeToken ? { resumeToken } : {}),
|
|
143
|
+
...(reason ? { reason } : {}),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function normalizeExecutionRecord(record) {
|
|
147
|
+
if (!record) {
|
|
148
|
+
return {};
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
id: firstString(record, "id"),
|
|
152
|
+
state: normalizeExecutionState(record.state),
|
|
153
|
+
errorMessage: firstString(record, "errorMessage", "error_message"),
|
|
154
|
+
approvalWait: normalizeApprovalWait(objectValue(record, "approvalWait", "approval_wait")),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function stripUndefinedValues(record) {
|
|
158
|
+
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
|
|
159
|
+
}
|
|
160
|
+
function normalizeExecuteToolRequest(request) {
|
|
161
|
+
return stripUndefinedValues({
|
|
162
|
+
linkage: stripUndefinedValues({
|
|
163
|
+
workspaceId: request.linkage.workspaceId,
|
|
164
|
+
organizationId: request.linkage.organizationId,
|
|
165
|
+
agentId: request.linkage.agentId,
|
|
166
|
+
runId: request.linkage.runId,
|
|
167
|
+
objectiveId: request.linkage.objectiveId,
|
|
168
|
+
stepId: request.linkage.stepId,
|
|
169
|
+
actorId: request.linkage.actorId,
|
|
170
|
+
surface: request.linkage.surface,
|
|
171
|
+
channelId: request.linkage.channelId,
|
|
172
|
+
correlationId: request.linkage.correlationId,
|
|
173
|
+
}),
|
|
174
|
+
tool: stripUndefinedValues({
|
|
175
|
+
namespace: request.tool.namespace,
|
|
176
|
+
name: request.tool.name,
|
|
177
|
+
version: request.tool.version,
|
|
178
|
+
capability: request.tool.capability,
|
|
179
|
+
operation: request.tool.operation,
|
|
180
|
+
idempotent: request.tool.idempotent,
|
|
181
|
+
mutatesResource: request.tool.mutatesResource,
|
|
182
|
+
}),
|
|
183
|
+
connector: request.connector
|
|
184
|
+
? stripUndefinedValues({
|
|
185
|
+
connectionId: request.connector.connectionId,
|
|
186
|
+
providerId: request.connector.providerId,
|
|
187
|
+
resourceId: request.connector.resourceId,
|
|
188
|
+
resourceKind: request.connector.resourceKind,
|
|
189
|
+
credentialRef: request.connector.credentialRef,
|
|
190
|
+
credentialEnvironment: request.connector.credentialEnvironment,
|
|
191
|
+
})
|
|
192
|
+
: undefined,
|
|
193
|
+
arguments: request.arguments,
|
|
194
|
+
riskLevel: request.riskLevel,
|
|
195
|
+
retryPolicy: request.retryPolicy
|
|
196
|
+
? stripUndefinedValues({
|
|
197
|
+
maxAttempts: request.retryPolicy.maxAttempts,
|
|
198
|
+
initialDelayMs: request.retryPolicy.initialDelayMs,
|
|
199
|
+
maxDelayMs: request.retryPolicy.maxDelayMs,
|
|
200
|
+
allowNonIdempotentRetry: request.retryPolicy.allowNonIdempotentRetry,
|
|
201
|
+
})
|
|
202
|
+
: undefined,
|
|
203
|
+
idempotencyKey: request.idempotencyKey,
|
|
204
|
+
metadata: request.metadata,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function normalizeToolExecutionOutput(output) {
|
|
208
|
+
return stripUndefinedValues({
|
|
209
|
+
rawOutput: output.rawOutput,
|
|
210
|
+
safeOutput: output.safeOutput,
|
|
211
|
+
proposals: output.proposals?.map((proposal) => stripUndefinedValues({
|
|
212
|
+
kind: proposal.kind,
|
|
213
|
+
targetRef: proposal.targetRef,
|
|
214
|
+
payload: proposal.payload,
|
|
215
|
+
metadata: proposal.metadata,
|
|
216
|
+
})),
|
|
217
|
+
redactions: output.redactions,
|
|
218
|
+
contentType: output.contentType,
|
|
219
|
+
outputDigest: output.outputDigest,
|
|
220
|
+
durationMs: output.durationMs,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
async function parseJsonResponse(response, serviceName) {
|
|
224
|
+
const text = await response.text();
|
|
225
|
+
if (!response.ok) {
|
|
226
|
+
throw new Error(`${serviceName} returned ${response.status}: ${text || response.statusText}`);
|
|
227
|
+
}
|
|
228
|
+
if (!text.trim()) {
|
|
229
|
+
throw new Error(`${serviceName} returned empty response`);
|
|
230
|
+
}
|
|
231
|
+
return JSON.parse(text);
|
|
232
|
+
}
|
|
233
|
+
export async function executeToolWithPlatform(config, request, signal) {
|
|
234
|
+
const response = await postPlatformConnect(config, EXECUTE_TOOL_PATH, normalizeExecuteToolRequest(request), {
|
|
235
|
+
serviceName: "tool execution service",
|
|
236
|
+
failureMode: "required",
|
|
237
|
+
timeoutMs: config.timeoutMs,
|
|
238
|
+
maxAttempts: config.maxAttempts,
|
|
239
|
+
signal,
|
|
240
|
+
});
|
|
241
|
+
const payload = await parseJsonResponse(response, "tool execution service");
|
|
242
|
+
return {
|
|
243
|
+
execution: normalizeExecutionRecord(objectValue(payload, "execution")),
|
|
244
|
+
idempotentReplay: firstBoolean(payload, "idempotentReplay", "idempotent_replay") === true,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
export async function resumeToolExecutionWithPlatform(config, request, signal) {
|
|
248
|
+
const response = await postPlatformConnect(config, RESUME_TOOL_EXECUTION_PATH, stripUndefinedValues({
|
|
249
|
+
executionId: request.executionId,
|
|
250
|
+
approvalRequestId: request.approvalRequestId,
|
|
251
|
+
resumeToken: request.resumeToken,
|
|
252
|
+
approved: request.approved,
|
|
253
|
+
decidedBy: request.decidedBy,
|
|
254
|
+
reason: request.reason,
|
|
255
|
+
}), {
|
|
256
|
+
serviceName: "tool execution service",
|
|
257
|
+
failureMode: "required",
|
|
258
|
+
timeoutMs: config.timeoutMs,
|
|
259
|
+
maxAttempts: config.maxAttempts,
|
|
260
|
+
signal,
|
|
261
|
+
});
|
|
262
|
+
const payload = await parseJsonResponse(response, "tool execution service");
|
|
263
|
+
return {
|
|
264
|
+
execution: normalizeExecutionRecord(objectValue(payload, "execution")),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
export async function recordToolExecutionOutputWithPlatform(config, request, signal) {
|
|
268
|
+
const response = await postPlatformConnect(config, RECORD_TOOL_EXECUTION_OUTPUT_PATH, stripUndefinedValues({
|
|
269
|
+
executionId: request.executionId,
|
|
270
|
+
output: normalizeToolExecutionOutput(request.output),
|
|
271
|
+
metadata: request.metadata,
|
|
272
|
+
}), {
|
|
273
|
+
serviceName: "tool execution service",
|
|
274
|
+
failureMode: "required",
|
|
275
|
+
timeoutMs: config.timeoutMs,
|
|
276
|
+
maxAttempts: config.maxAttempts,
|
|
277
|
+
signal,
|
|
278
|
+
});
|
|
279
|
+
const payload = await parseJsonResponse(response, "tool execution service");
|
|
280
|
+
return {
|
|
281
|
+
execution: normalizeExecutionRecord(objectValue(payload, "execution")),
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=tool-execution-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-execution-client.js","sourceRoot":"","sources":["../../src/platform/tool-execution-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,mBAAmB,EACnB,4BAA4B,EAC5B,UAAU,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,GAC1B,MAAM,oBAAoB,CAAC;AAE5B,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACjC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B,MAAM,gCAAgC,GAAG;IACxC,4BAA4B;IAC5B,oCAAoC;IACpC,2BAA2B;IAC3B,0BAA0B;IAC1B,kBAAkB;CACT,CAAC;AAEX,MAAM,6BAA6B,GAAG;IACrC,8BAA8B;IAC9B,sCAAsC;IACtC,8BAA8B;IAC9B,eAAe;CACN,CAAC;AAEX,MAAM,oCAAoC,GAAG;IAC5C,wCAAwC;IACxC,wCAAwC;IACxC,wBAAwB;IACxB,yBAAyB;IACzB,2BAA2B;CAClB,CAAC;AAEX,MAAM,iCAAiC,GAAG;IACzC,qCAAqC;IACrC,qCAAqC;IACrC,oCAAoC;IACpC,8BAA8B;IAC9B,sBAAsB;IACtB,sBAAsB;CACb,CAAC;AAEX,MAAM,+BAA+B,GAAG;IACvC,mCAAmC;IACnC,2CAA2C;CAClC,CAAC;AAEX,MAAM,oCAAoC,GAAG;IAC5C,qCAAqC;IACrC,6CAA6C;CACpC,CAAC;AAEX,MAAM,iBAAiB,GAAG,yBAAyB,CAClD,wBAAwB,CAAC,aAAa,CAAC,WAAW,CAClD,CAAC;AACF,MAAM,0BAA0B,GAAG,yBAAyB,CAC3D,wBAAwB,CAAC,aAAa,CAAC,mBAAmB,CAC1D,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EAAE,wBAAwB;QACrC,WAAW,EAAE,UAAU;QACvB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,MAAM;KACN,CACD,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;IAC5E,OAAO;QACN,SAAS,EAAE,wBAAwB,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;KACtE,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qCAAqC,CAC1D,MAAkC,EAClC,OAAiD,EACjD,MAAoB;IAEpB,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CACzC,MAAM,EACN,iCAAiC,EACjC,oBAAoB,CAAC;QACpB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM,EAAE,4BAA4B,CAAC,OAAO,CAAC,MAAM,CAAC;QACpD,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC1B,CAAC,EACF;QACC,WAAW,EAAE,wBAAwB;QACrC,WAAW,EAAE,UAAU;QACvB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,MAAM;KACN,CACD,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;IAC5E,OAAO;QACN,SAAS,EAAE,wBAAwB,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;KACtE,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype PlatformServiceConfig,\n\tgetEnvValue,\n\tpostPlatformConnect,\n\tresolvePlatformServiceConfig,\n\ttrimString,\n} from \"./client.js\";\nimport {\n\tPLATFORM_CONNECT_METHODS,\n\tplatformConnectMethodPath,\n\tplatformConnectServicePath,\n} from \"./core-services.js\";\n\nconst DEFAULT_TIMEOUT_MS = 2_500;\nconst DEFAULT_MAX_ATTEMPTS = 2;\n\nconst TOOL_EXECUTION_BASE_URL_ENV_VARS = [\n\t\"TOOL_EXECUTION_SERVICE_URL\",\n\t\"MAESTRO_TOOL_EXECUTION_SERVICE_URL\",\n\t\"MAESTRO_PLATFORM_BASE_URL\",\n\t\"MAESTRO_EVALOPS_BASE_URL\",\n\t\"EVALOPS_BASE_URL\",\n] as const;\n\nconst TOOL_EXECUTION_TOKEN_ENV_VARS = [\n\t\"TOOL_EXECUTION_SERVICE_TOKEN\",\n\t\"MAESTRO_TOOL_EXECUTION_SERVICE_TOKEN\",\n\t\"MAESTRO_EVALOPS_ACCESS_TOKEN\",\n\t\"EVALOPS_TOKEN\",\n] as const;\n\nconst TOOL_EXECUTION_ORGANIZATION_ENV_VARS = [\n\t\"TOOL_EXECUTION_SERVICE_ORGANIZATION_ID\",\n\t\"MAESTRO_TOOL_EXECUTION_ORGANIZATION_ID\",\n\t\"MAESTRO_EVALOPS_ORG_ID\",\n\t\"EVALOPS_ORGANIZATION_ID\",\n\t\"MAESTRO_ENTERPRISE_ORG_ID\",\n] as const;\n\nconst TOOL_EXECUTION_WORKSPACE_ENV_VARS = [\n\t\"TOOL_EXECUTION_SERVICE_WORKSPACE_ID\",\n\t\"MAESTRO_TOOL_EXECUTION_WORKSPACE_ID\",\n\t\"MAESTRO_REMOTE_RUNNER_WORKSPACE_ID\",\n\t\"MAESTRO_EVALOPS_WORKSPACE_ID\",\n\t\"EVALOPS_WORKSPACE_ID\",\n\t\"MAESTRO_WORKSPACE_ID\",\n] as const;\n\nconst TOOL_EXECUTION_TIMEOUT_ENV_VARS = [\n\t\"TOOL_EXECUTION_SERVICE_TIMEOUT_MS\",\n\t\"MAESTRO_TOOL_EXECUTION_SERVICE_TIMEOUT_MS\",\n] as const;\n\nconst TOOL_EXECUTION_MAX_ATTEMPTS_ENV_VARS = [\n\t\"TOOL_EXECUTION_SERVICE_MAX_ATTEMPTS\",\n\t\"MAESTRO_TOOL_EXECUTION_SERVICE_MAX_ATTEMPTS\",\n] as const;\n\nconst EXECUTE_TOOL_PATH = platformConnectMethodPath(\n\tPLATFORM_CONNECT_METHODS.toolexecution.executeTool,\n);\nconst RESUME_TOOL_EXECUTION_PATH = platformConnectMethodPath(\n\tPLATFORM_CONNECT_METHODS.toolexecution.resumeToolExecution,\n);\nconst RECORD_TOOL_EXECUTION_OUTPUT_PATH = platformConnectMethodPath(\n\tPLATFORM_CONNECT_METHODS.toolexecution.recordToolExecutionOutput,\n);\n\nexport type ToolExecutionRiskLevel =\n\t| \"RISK_LEVEL_UNSPECIFIED\"\n\t| \"RISK_LEVEL_LOW\"\n\t| \"RISK_LEVEL_MEDIUM\"\n\t| \"RISK_LEVEL_HIGH\"\n\t| \"RISK_LEVEL_CRITICAL\";\n\nexport type ToolExecutionState =\n\t| \"TOOL_EXECUTION_STATE_UNSPECIFIED\"\n\t| \"TOOL_EXECUTION_STATE_ACCEPTED\"\n\t| \"TOOL_EXECUTION_STATE_POLICY_EVALUATING\"\n\t| \"TOOL_EXECUTION_STATE_WAITING_APPROVAL\"\n\t| \"TOOL_EXECUTION_STATE_RUNNING\"\n\t| \"TOOL_EXECUTION_STATE_SUCCEEDED\"\n\t| \"TOOL_EXECUTION_STATE_FAILED\"\n\t| \"TOOL_EXECUTION_STATE_DENIED\"\n\t| \"TOOL_EXECUTION_STATE_CANCELLED\";\n\nexport interface ToolExecutionLinkage {\n\tworkspaceId: string;\n\torganizationId?: string;\n\tagentId: string;\n\trunId?: string;\n\tobjectiveId?: string;\n\tstepId: string;\n\tactorId?: string;\n\tsurface?: string;\n\tchannelId?: string;\n\tcorrelationId?: string;\n}\n\nexport interface PlatformToolRef {\n\tnamespace: string;\n\tname: string;\n\tversion?: string;\n\tcapability: string;\n\toperation?: string;\n\tidempotent?: boolean;\n\tmutatesResource?: boolean;\n}\n\nexport interface PlatformConnectorRef {\n\tconnectionId?: string;\n\tproviderId?: string;\n\tresourceId?: string;\n\tresourceKind?: string;\n\tcredentialRef?: string;\n\tcredentialEnvironment?: string;\n}\n\nexport interface PlatformToolRetryPolicy {\n\tmaxAttempts?: number;\n\tinitialDelayMs?: number;\n\tmaxDelayMs?: number;\n\tallowNonIdempotentRetry?: boolean;\n}\n\nexport interface ExecutePlatformToolRequest {\n\tlinkage: ToolExecutionLinkage;\n\ttool: PlatformToolRef;\n\tconnector?: PlatformConnectorRef;\n\targuments: Record<string, unknown>;\n\triskLevel?: ToolExecutionRiskLevel;\n\tretryPolicy?: PlatformToolRetryPolicy;\n\tidempotencyKey: string;\n\tmetadata?: Record<string, string>;\n}\n\nexport interface ResumePlatformToolExecutionRequest {\n\texecutionId: string;\n\tapprovalRequestId: string;\n\tresumeToken: string;\n\tapproved: boolean;\n\tdecidedBy?: string;\n\treason?: string;\n}\n\nexport interface PlatformToolOutputProposal {\n\tkind: string;\n\ttargetRef?: string;\n\tpayload?: Record<string, unknown>;\n\tmetadata?: Record<string, string>;\n}\n\nexport interface PlatformToolExecutionOutput {\n\trawOutput?: Record<string, unknown>;\n\tsafeOutput?: Record<string, unknown>;\n\tproposals?: PlatformToolOutputProposal[];\n\tredactions?: string[];\n\tcontentType?: string;\n\toutputDigest?: string;\n\tdurationMs?: number;\n}\n\nexport interface RecordPlatformToolExecutionOutputRequest {\n\texecutionId: string;\n\toutput: PlatformToolExecutionOutput;\n\tmetadata?: Record<string, string>;\n}\n\nexport interface PlatformApprovalWait {\n\tapprovalRequestId?: string;\n\tresumeToken?: string;\n\treason?: string;\n}\n\nexport interface PlatformToolExecutionRecord {\n\tid?: string;\n\tstate?: ToolExecutionState;\n\terrorMessage?: string;\n\tapprovalWait?: PlatformApprovalWait;\n}\n\nexport interface ExecutePlatformToolResponse {\n\texecution: PlatformToolExecutionRecord;\n\tidempotentReplay: boolean;\n}\n\nexport interface ResumePlatformToolExecutionResponse {\n\texecution: PlatformToolExecutionRecord;\n}\n\nexport interface RecordPlatformToolExecutionOutputResponse {\n\texecution: PlatformToolExecutionRecord;\n}\n\nexport interface ToolExecutionServiceConfig extends PlatformServiceConfig {}\n\nfunction stripTrailingSlashes(value: string): string {\n\treturn value.replace(/\\/+$/u, \"\");\n}\n\nfunction normalizeBaseUrl(baseUrl: string): string {\n\tlet normalized = stripTrailingSlashes(baseUrl.trim());\n\tfor (const suffix of [\n\t\tEXECUTE_TOOL_PATH,\n\t\tRESUME_TOOL_EXECUTION_PATH,\n\t\tRECORD_TOOL_EXECUTION_OUTPUT_PATH,\n\t\tplatformConnectServicePath(\n\t\t\tPLATFORM_CONNECT_METHODS.toolexecution.executeTool.service,\n\t\t),\n\t]) {\n\t\tif (normalized.endsWith(suffix)) {\n\t\t\tnormalized = stripTrailingSlashes(normalized.slice(0, -suffix.length));\n\t\t}\n\t}\n\treturn normalized;\n}\n\nexport async function resolveToolExecutionServiceConfig(\n\toverrides: Partial<ToolExecutionServiceConfig> = {},\n): Promise<ToolExecutionServiceConfig | null> {\n\tconst config = await resolvePlatformServiceConfig({\n\t\tbaseUrlEnvVars: TOOL_EXECUTION_BASE_URL_ENV_VARS,\n\t\ttokenEnvVars: TOOL_EXECUTION_TOKEN_ENV_VARS,\n\t\torganizationEnvVars: TOOL_EXECUTION_ORGANIZATION_ENV_VARS,\n\t\tworkspaceEnvVars: TOOL_EXECUTION_WORKSPACE_ENV_VARS,\n\t\ttimeoutEnvVars: TOOL_EXECUTION_TIMEOUT_ENV_VARS,\n\t\tmaxAttemptsEnvVars: TOOL_EXECUTION_MAX_ATTEMPTS_ENV_VARS,\n\t\tbaseUrlSuffixes: [\n\t\t\tEXECUTE_TOOL_PATH,\n\t\t\tRESUME_TOOL_EXECUTION_PATH,\n\t\t\tRECORD_TOOL_EXECUTION_OUTPUT_PATH,\n\t\t\tplatformConnectServicePath(\n\t\t\t\tPLATFORM_CONNECT_METHODS.toolexecution.executeTool.service,\n\t\t\t),\n\t\t],\n\t\tdefaultTimeoutMs: DEFAULT_TIMEOUT_MS,\n\t\tdefaultMaxAttempts: DEFAULT_MAX_ATTEMPTS,\n\t\trequireBaseUrl: false,\n\t\trequireOrganizationId: true,\n\t\trequireToken: true,\n\t});\n\tif (!config?.baseUrl || !config.workspaceId) {\n\t\treturn null;\n\t}\n\treturn {\n\t\t...config,\n\t\tbaseUrl: normalizeBaseUrl(\n\t\t\ttrimString(overrides.baseUrl ?? config.baseUrl) ?? config.baseUrl,\n\t\t),\n\t\torganizationId:\n\t\t\ttrimString(overrides.organizationId ?? config.organizationId) ??\n\t\t\tconfig.organizationId,\n\t\tworkspaceId:\n\t\t\ttrimString(overrides.workspaceId ?? config.workspaceId) ??\n\t\t\tconfig.workspaceId,\n\t\ttoken: trimString(overrides.token ?? config.token) ?? config.token,\n\t\ttimeoutMs: overrides.timeoutMs ?? config.timeoutMs,\n\t\tmaxAttempts: overrides.maxAttempts ?? config.maxAttempts,\n\t\tteamId: trimString(overrides.teamId ?? config.teamId),\n\t};\n}\n\nfunction firstString(\n\trecord: Record<string, unknown>,\n\t...keys: string[]\n): string | undefined {\n\tfor (const key of keys) {\n\t\tconst value = record[key];\n\t\tif (typeof value === \"string\" && value.trim().length > 0) {\n\t\t\treturn value.trim();\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction firstBoolean(\n\trecord: Record<string, unknown>,\n\t...keys: string[]\n): boolean | undefined {\n\tfor (const key of keys) {\n\t\tconst value = record[key];\n\t\tif (typeof value === \"boolean\") {\n\t\t\treturn value;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction objectValue(\n\trecord: Record<string, unknown>,\n\t...keys: string[]\n): Record<string, unknown> | undefined {\n\tfor (const key of keys) {\n\t\tconst value = record[key];\n\t\tif (value && typeof value === \"object\" && !Array.isArray(value)) {\n\t\t\treturn value as Record<string, unknown>;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction normalizeExecutionState(\n\tvalue: unknown,\n): ToolExecutionState | undefined {\n\tif (typeof value !== \"string\" || value.trim().length === 0) {\n\t\treturn undefined;\n\t}\n\treturn value.trim() as ToolExecutionState;\n}\n\nfunction normalizeApprovalWait(\n\trecord: Record<string, unknown> | undefined,\n): PlatformApprovalWait | undefined {\n\tif (!record) {\n\t\treturn undefined;\n\t}\n\tconst approvalRequestId = firstString(\n\t\trecord,\n\t\t\"approvalRequestId\",\n\t\t\"approval_request_id\",\n\t);\n\tconst resumeToken = firstString(record, \"resumeToken\", \"resume_token\");\n\tconst reason = firstString(record, \"reason\");\n\tif (!approvalRequestId && !resumeToken && !reason) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\t...(approvalRequestId ? { approvalRequestId } : {}),\n\t\t...(resumeToken ? { resumeToken } : {}),\n\t\t...(reason ? { reason } : {}),\n\t};\n}\n\nfunction normalizeExecutionRecord(\n\trecord: Record<string, unknown> | undefined,\n): PlatformToolExecutionRecord {\n\tif (!record) {\n\t\treturn {};\n\t}\n\treturn {\n\t\tid: firstString(record, \"id\"),\n\t\tstate: normalizeExecutionState(record.state),\n\t\terrorMessage: firstString(record, \"errorMessage\", \"error_message\"),\n\t\tapprovalWait: normalizeApprovalWait(\n\t\t\tobjectValue(record, \"approvalWait\", \"approval_wait\"),\n\t\t),\n\t};\n}\n\nfunction stripUndefinedValues(\n\trecord: Record<string, unknown>,\n): Record<string, unknown> {\n\treturn Object.fromEntries(\n\t\tObject.entries(record).filter(([, value]) => value !== undefined),\n\t);\n}\n\nfunction normalizeExecuteToolRequest(\n\trequest: ExecutePlatformToolRequest,\n): Record<string, unknown> {\n\treturn stripUndefinedValues({\n\t\tlinkage: stripUndefinedValues({\n\t\t\tworkspaceId: request.linkage.workspaceId,\n\t\t\torganizationId: request.linkage.organizationId,\n\t\t\tagentId: request.linkage.agentId,\n\t\t\trunId: request.linkage.runId,\n\t\t\tobjectiveId: request.linkage.objectiveId,\n\t\t\tstepId: request.linkage.stepId,\n\t\t\tactorId: request.linkage.actorId,\n\t\t\tsurface: request.linkage.surface,\n\t\t\tchannelId: request.linkage.channelId,\n\t\t\tcorrelationId: request.linkage.correlationId,\n\t\t}),\n\t\ttool: stripUndefinedValues({\n\t\t\tnamespace: request.tool.namespace,\n\t\t\tname: request.tool.name,\n\t\t\tversion: request.tool.version,\n\t\t\tcapability: request.tool.capability,\n\t\t\toperation: request.tool.operation,\n\t\t\tidempotent: request.tool.idempotent,\n\t\t\tmutatesResource: request.tool.mutatesResource,\n\t\t}),\n\t\tconnector: request.connector\n\t\t\t? stripUndefinedValues({\n\t\t\t\t\tconnectionId: request.connector.connectionId,\n\t\t\t\t\tproviderId: request.connector.providerId,\n\t\t\t\t\tresourceId: request.connector.resourceId,\n\t\t\t\t\tresourceKind: request.connector.resourceKind,\n\t\t\t\t\tcredentialRef: request.connector.credentialRef,\n\t\t\t\t\tcredentialEnvironment: request.connector.credentialEnvironment,\n\t\t\t\t})\n\t\t\t: undefined,\n\t\targuments: request.arguments,\n\t\triskLevel: request.riskLevel,\n\t\tretryPolicy: request.retryPolicy\n\t\t\t? stripUndefinedValues({\n\t\t\t\t\tmaxAttempts: request.retryPolicy.maxAttempts,\n\t\t\t\t\tinitialDelayMs: request.retryPolicy.initialDelayMs,\n\t\t\t\t\tmaxDelayMs: request.retryPolicy.maxDelayMs,\n\t\t\t\t\tallowNonIdempotentRetry: request.retryPolicy.allowNonIdempotentRetry,\n\t\t\t\t})\n\t\t\t: undefined,\n\t\tidempotencyKey: request.idempotencyKey,\n\t\tmetadata: request.metadata,\n\t});\n}\n\nfunction normalizeToolExecutionOutput(\n\toutput: PlatformToolExecutionOutput,\n): Record<string, unknown> {\n\treturn stripUndefinedValues({\n\t\trawOutput: output.rawOutput,\n\t\tsafeOutput: output.safeOutput,\n\t\tproposals: output.proposals?.map((proposal) =>\n\t\t\tstripUndefinedValues({\n\t\t\t\tkind: proposal.kind,\n\t\t\t\ttargetRef: proposal.targetRef,\n\t\t\t\tpayload: proposal.payload,\n\t\t\t\tmetadata: proposal.metadata,\n\t\t\t}),\n\t\t),\n\t\tredactions: output.redactions,\n\t\tcontentType: output.contentType,\n\t\toutputDigest: output.outputDigest,\n\t\tdurationMs: output.durationMs,\n\t});\n}\n\nasync function parseJsonResponse(\n\tresponse: Response,\n\tserviceName: string,\n): Promise<Record<string, unknown>> {\n\tconst text = await response.text();\n\tif (!response.ok) {\n\t\tthrow new Error(\n\t\t\t`${serviceName} returned ${response.status}: ${text || response.statusText}`,\n\t\t);\n\t}\n\tif (!text.trim()) {\n\t\tthrow new Error(`${serviceName} returned empty response`);\n\t}\n\treturn JSON.parse(text) as Record<string, unknown>;\n}\n\nexport async function executeToolWithPlatform(\n\tconfig: ToolExecutionServiceConfig,\n\trequest: ExecutePlatformToolRequest,\n\tsignal?: AbortSignal,\n): Promise<ExecutePlatformToolResponse> {\n\tconst response = await postPlatformConnect(\n\t\tconfig,\n\t\tEXECUTE_TOOL_PATH,\n\t\tnormalizeExecuteToolRequest(request),\n\t\t{\n\t\t\tserviceName: \"tool execution service\",\n\t\t\tfailureMode: \"required\",\n\t\t\ttimeoutMs: config.timeoutMs,\n\t\t\tmaxAttempts: config.maxAttempts,\n\t\t\tsignal,\n\t\t},\n\t);\n\tconst payload = await parseJsonResponse(response, \"tool execution service\");\n\treturn {\n\t\texecution: normalizeExecutionRecord(objectValue(payload, \"execution\")),\n\t\tidempotentReplay:\n\t\t\tfirstBoolean(payload, \"idempotentReplay\", \"idempotent_replay\") === true,\n\t};\n}\n\nexport async function resumeToolExecutionWithPlatform(\n\tconfig: ToolExecutionServiceConfig,\n\trequest: ResumePlatformToolExecutionRequest,\n\tsignal?: AbortSignal,\n): Promise<ResumePlatformToolExecutionResponse> {\n\tconst response = await postPlatformConnect(\n\t\tconfig,\n\t\tRESUME_TOOL_EXECUTION_PATH,\n\t\tstripUndefinedValues({\n\t\t\texecutionId: request.executionId,\n\t\t\tapprovalRequestId: request.approvalRequestId,\n\t\t\tresumeToken: request.resumeToken,\n\t\t\tapproved: request.approved,\n\t\t\tdecidedBy: request.decidedBy,\n\t\t\treason: request.reason,\n\t\t}),\n\t\t{\n\t\t\tserviceName: \"tool execution service\",\n\t\t\tfailureMode: \"required\",\n\t\t\ttimeoutMs: config.timeoutMs,\n\t\t\tmaxAttempts: config.maxAttempts,\n\t\t\tsignal,\n\t\t},\n\t);\n\tconst payload = await parseJsonResponse(response, \"tool execution service\");\n\treturn {\n\t\texecution: normalizeExecutionRecord(objectValue(payload, \"execution\")),\n\t};\n}\n\nexport async function recordToolExecutionOutputWithPlatform(\n\tconfig: ToolExecutionServiceConfig,\n\trequest: RecordPlatformToolExecutionOutputRequest,\n\tsignal?: AbortSignal,\n): Promise<RecordPlatformToolExecutionOutputResponse> {\n\tconst response = await postPlatformConnect(\n\t\tconfig,\n\t\tRECORD_TOOL_EXECUTION_OUTPUT_PATH,\n\t\tstripUndefinedValues({\n\t\t\texecutionId: request.executionId,\n\t\t\toutput: normalizeToolExecutionOutput(request.output),\n\t\t\tmetadata: request.metadata,\n\t\t}),\n\t\t{\n\t\t\tserviceName: \"tool execution service\",\n\t\t\tfailureMode: \"required\",\n\t\t\ttimeoutMs: config.timeoutMs,\n\t\t\tmaxAttempts: config.maxAttempts,\n\t\t\tsignal,\n\t\t},\n\t);\n\tconst payload = await parseJsonResponse(response, \"tool execution service\");\n\treturn {\n\t\texecution: normalizeExecutionRecord(objectValue(payload, \"execution\")),\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-client.d.ts","sourceRoot":"","sources":["../../src/prompts/service-client.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACX,0BAA0B,EAC1B,sBAAsB,EACtB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"service-client.d.ts","sourceRoot":"","sources":["../../src/prompts/service-client.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACX,0BAA0B,EAC1B,sBAAsB,EACtB,MAAM,YAAY,CAAC;AAwNpB,wBAAsB,qBAAqB,CAC1C,KAAK,EAAE,0BAA0B,GAC/B,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CA8BxC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getEnvValue, postPlatformConnect, resolveOrganizationId, resolvePlatformServiceConfig, trimString, } from "../platform/client.js";
|
|
2
2
|
import { PLATFORM_CONNECT_METHODS, PLATFORM_CONNECT_SERVICES, platformConnectMethodPath, platformConnectServicePath, } from "../platform/core-services.js";
|
|
3
|
+
import { fetchDownstream } from "../utils/downstream-http.js";
|
|
3
4
|
import { createLogger } from "../utils/logger.js";
|
|
4
5
|
const logger = createLogger("prompts:service");
|
|
5
6
|
const DEFAULT_TIMEOUT_MS = 2_000;
|
|
@@ -115,6 +116,7 @@ async function resolveViaPlatformConnect(config, input, name) {
|
|
|
115
116
|
label: trimString(input.label) ?? "production",
|
|
116
117
|
}, {
|
|
117
118
|
serviceName: "prompts service",
|
|
119
|
+
failureMode: "optional",
|
|
118
120
|
timeoutMs: config.timeoutMs,
|
|
119
121
|
maxAttempts: config.maxAttempts,
|
|
120
122
|
});
|
|
@@ -134,11 +136,12 @@ async function resolveViaLegacyRest(config, input, name) {
|
|
|
134
136
|
if (trimString(input.surface)) {
|
|
135
137
|
url.searchParams.set("surface", trimString(input.surface));
|
|
136
138
|
}
|
|
137
|
-
const response = await
|
|
139
|
+
const response = await fetchDownstream(url, {
|
|
138
140
|
method: "GET",
|
|
139
141
|
headers: buildHeaders(config),
|
|
140
142
|
}, {
|
|
141
143
|
serviceName: "prompts service",
|
|
144
|
+
failureMode: "optional",
|
|
142
145
|
timeoutMs: config.timeoutMs,
|
|
143
146
|
maxAttempts: config.maxAttempts,
|
|
144
147
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-client.js","sourceRoot":"","sources":["../../src/prompts/service-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,UAAU,GACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,GA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AClC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC","sourcesContent":["import {\n\ttype PlatformServiceConfig,\n\tfetchWithRetry,\n\tgetEnvValue,\n\tpostPlatformConnect,\n\tresolveOrganizationId,\n\tresolvePlatformServiceConfig,\n\ttrimString,\n} from \"../platform/client.js\";\nimport {\n\tPLATFORM_CONNECT_METHODS,\n\tPLATFORM_CONNECT_SERVICES,\n\tplatformConnectMethodPath,\n\tplatformConnectServicePath,\n} from \"../platform/core-services.js\";\nimport { createLogger } from \"../utils/logger.js\";\nimport type {\n\tResolvePromptTemplateInput,\n\tResolvedPromptTemplate,\n} from \"./types.js\";\n\nconst logger = createLogger(\"prompts:service\");\nconst DEFAULT_TIMEOUT_MS = 2_000;\nconst DEFAULT_MAX_ATTEMPTS = 2;\nconst RESOLVE_PROMPT_PATH = platformConnectMethodPath(\n\tPLATFORM_CONNECT_METHODS.prompts.resolve,\n);\nconst LEGACY_RESOLVE_PROMPT_PATH = \"/v1/resolve\";\nconst PROMPTS_BASE_URL_ENV_VARS = [\n\t\"PROMPTS_SERVICE_URL\",\n\t\"MAESTRO_PROMPTS_SERVICE_URL\",\n] as const;\nconst PROMPTS_TOKEN_ENV_VARS = [\n\t\"PROMPTS_SERVICE_TOKEN\",\n\t\"MAESTRO_PROMPTS_SERVICE_TOKEN\",\n\t\"MAESTRO_EVALOPS_ACCESS_TOKEN\",\n\t\"EVALOPS_TOKEN\",\n] as const;\nconst PROMPTS_ORGANIZATION_ENV_VARS = [\n\t\"PROMPTS_SERVICE_ORGANIZATION_ID\",\n\t\"MAESTRO_PROMPTS_ORGANIZATION_ID\",\n\t\"MAESTRO_EVALOPS_ORG_ID\",\n\t\"EVALOPS_ORGANIZATION_ID\",\n\t\"MAESTRO_ENTERPRISE_ORG_ID\",\n] as const;\n\ntype PromptsTransport = \"connect\" | \"legacy-rest\";\n\ntype PromptsServiceConfig = PlatformServiceConfig & {\n\ttransport: PromptsTransport;\n};\n\ninterface ResolveVersionPayload {\n\tid?: string;\n\tversion?: number;\n\tcontent?: string;\n}\n\ninterface ResolveResponse {\n\tversion?: ResolveVersionPayload;\n}\n\nfunction resolvePromptsTransport(): PromptsTransport {\n\tconst configured = trimString(\n\t\tprocess.env.PROMPTS_SERVICE_TRANSPORT,\n\t)?.toLowerCase();\n\tif (configured === \"connect\" || configured === \"platform\") {\n\t\treturn \"connect\";\n\t}\n\tif (configured === \"legacy\" || configured === \"legacy-rest\") {\n\t\treturn \"legacy-rest\";\n\t}\n\tconst serviceSpecificBase = getEnvValue(PROMPTS_BASE_URL_ENV_VARS);\n\treturn serviceSpecificBase ? \"legacy-rest\" : \"connect\";\n}\n\nfunction hasConfiguredPromptsBaseUrl(): boolean {\n\treturn Boolean(\n\t\tgetEnvValue([\n\t\t\t...PROMPTS_BASE_URL_ENV_VARS,\n\t\t\t\"MAESTRO_PLATFORM_BASE_URL\",\n\t\t\t\"MAESTRO_EVALOPS_BASE_URL\",\n\t\t\t\"EVALOPS_BASE_URL\",\n\t\t]),\n\t);\n}\n\nfunction warnPromptsServiceMisconfiguration(): void {\n\tif (!hasConfiguredPromptsBaseUrl()) {\n\t\treturn;\n\t}\n\tif (!resolveOrganizationId(PROMPTS_ORGANIZATION_ENV_VARS)) {\n\t\tlogger.warn(\n\t\t\t\"Prompts service configured without organization id; retaining bundled prompts\",\n\t\t);\n\t\treturn;\n\t}\n\tlogger.warn(\n\t\t\"Prompts service configured without access token; retaining bundled prompts\",\n\t);\n}\n\nasync function resolvePromptsServiceConfig(): Promise<PromptsServiceConfig | null> {\n\tconst config = await resolvePlatformServiceConfig({\n\t\tbaseUrlEnvVars: PROMPTS_BASE_URL_ENV_VARS,\n\t\ttokenEnvVars: PROMPTS_TOKEN_ENV_VARS,\n\t\torganizationEnvVars: PROMPTS_ORGANIZATION_ENV_VARS,\n\t\ttimeoutEnvVars: [\n\t\t\t\"PROMPTS_SERVICE_TIMEOUT_MS\",\n\t\t\t\"MAESTRO_PROMPTS_TIMEOUT_MS\",\n\t\t],\n\t\tmaxAttemptsEnvVars: [\n\t\t\t\"PROMPTS_SERVICE_MAX_ATTEMPTS\",\n\t\t\t\"MAESTRO_PROMPTS_MAX_ATTEMPTS\",\n\t\t],\n\t\tbaseUrlSuffixes: [\n\t\t\tRESOLVE_PROMPT_PATH,\n\t\t\tLEGACY_RESOLVE_PROMPT_PATH,\n\t\t\tplatformConnectServicePath(PLATFORM_CONNECT_SERVICES.prompts),\n\t\t],\n\t\tdefaultTimeoutMs: DEFAULT_TIMEOUT_MS,\n\t\tdefaultMaxAttempts: DEFAULT_MAX_ATTEMPTS,\n\t\trequireOrganizationId: true,\n\t\trequireToken: true,\n\t});\n\tif (!config) {\n\t\twarnPromptsServiceMisconfiguration();\n\t\treturn null;\n\t}\n\n\treturn {\n\t\t...config,\n\t\ttransport: resolvePromptsTransport(),\n\t};\n}\n\nfunction buildHeaders(config: PromptsServiceConfig): Record<string, string> {\n\treturn {\n\t\t...(config.token ? { Authorization: `Bearer ${config.token}` } : {}),\n\t\t...(config.organizationId\n\t\t\t? { \"X-Organization-ID\": config.organizationId }\n\t\t\t: {}),\n\t};\n}\n\nfunction normalizeResolvedPrompt(\n\tinput: ResolvePromptTemplateInput,\n\tpayload: ResolveResponse,\n): ResolvedPromptTemplate | null {\n\tconst name = trimString(input.name);\n\tconst versionId = trimString(payload.version?.id);\n\tconst content = trimString(payload.version?.content);\n\tconst version = payload.version?.version;\n\tif (!name || !versionId || !content || !Number.isFinite(version)) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tname,\n\t\tlabel: trimString(input.label) ?? \"production\",\n\t\tsurface: trimString(input.surface),\n\t\tversion: Math.round(version!),\n\t\tversionId,\n\t\tcontent,\n\t};\n}\n\nasync function resolveViaPlatformConnect(\n\tconfig: PromptsServiceConfig,\n\tinput: ResolvePromptTemplateInput,\n\tname: string,\n): Promise<ResolveResponse | null> {\n\tconst response = await postPlatformConnect(\n\t\tconfig,\n\t\tRESOLVE_PROMPT_PATH,\n\t\t{\n\t\t\tname,\n\t\t\tlabel: trimString(input.label) ?? \"production\",\n\t\t},\n\t\t{\n\t\t\tserviceName: \"prompts service\",\n\t\t\ttimeoutMs: config.timeoutMs,\n\t\t\tmaxAttempts: config.maxAttempts,\n\t\t},\n\t);\n\tif (response.status === 404) {\n\t\treturn null;\n\t}\n\tif (!response.ok) {\n\t\tconst text = await response.text();\n\t\tthrow new Error(\n\t\t\t`prompts service returned ${response.status}: ${text || response.statusText}`,\n\t\t);\n\t}\n\treturn (await response.json()) as ResolveResponse;\n}\n\nasync function resolveViaLegacyRest(\n\tconfig: PromptsServiceConfig,\n\tinput: ResolvePromptTemplateInput,\n\tname: string,\n): Promise<ResolveResponse | null> {\n\tconst url = new URL(LEGACY_RESOLVE_PROMPT_PATH, config.baseUrl);\n\turl.searchParams.set(\"name\", name);\n\turl.searchParams.set(\"env\", trimString(input.label) ?? \"production\");\n\tif (trimString(input.surface)) {\n\t\turl.searchParams.set(\"surface\", trimString(input.surface)!);\n\t}\n\n\tconst response = await fetchWithRetry(\n\t\turl.toString(),\n\t\t{\n\t\t\tmethod: \"GET\",\n\t\t\theaders: buildHeaders(config),\n\t\t},\n\t\t{\n\t\t\tserviceName: \"prompts service\",\n\t\t\ttimeoutMs: config.timeoutMs,\n\t\t\tmaxAttempts: config.maxAttempts,\n\t\t},\n\t);\n\tif (response.status === 404) {\n\t\treturn null;\n\t}\n\tif (!response.ok) {\n\t\tconst text = await response.text();\n\t\tthrow new Error(\n\t\t\t`prompts service returned ${response.status}: ${text || response.statusText}`,\n\t\t);\n\t}\n\treturn (await response.json()) as ResolveResponse;\n}\n\nexport async function resolvePromptTemplate(\n\tinput: ResolvePromptTemplateInput,\n): Promise<ResolvedPromptTemplate | null> {\n\tconst name = trimString(input.name);\n\tif (!name) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst config = await resolvePromptsServiceConfig();\n\t\tif (!config) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst payload =\n\t\t\tconfig.transport === \"connect\"\n\t\t\t\t? await resolveViaPlatformConnect(config, input, name)\n\t\t\t\t: await resolveViaLegacyRest(config, input, name);\n\t\tif (!payload) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn normalizeResolvedPrompt(input, payload);\n\t} catch (error) {\n\t\tlogger.warn(\"Failed to resolve prompt template; retaining bundled prompt\", {\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\tname,\n\t\t\tlabel: trimString(input.label) ?? \"production\",\n\t\t\tsurface: trimString(input.surface),\n\t\t});\n\t\treturn null;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"service-client.js","sourceRoot":"","sources":["../../src/prompts/service-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,WAAW,EACX,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,UAAU,GACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,GAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMlD,MAAM,MAAM,GAAG,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAC/C,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACjC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,mBAAmB,GAAG,yBAAyB,CACpD,wBAAwB,CAAC,OAAO,CAAC,OAAO,CACxC,CAAC;AACF,MAAM,0BAA0B,GAAG,aAAa,CAAC;AACjD,MAAM,yBAAyB,GAAG;IACjC,qBAAqB;IACrB,6BAA6B;CACpB,CAAC;AACX,MAAM,sBAAsB,GAAG;IAC9B,uBAAuB;IACvB,+BAA+B;IAC/B,8BAA8B;IAC9B,eAAe;CACN,CAAC;AACX,MAAM,6BAA6B,GAAG;IACrC,iCAAiC;IACjC,iCAAiC;IACj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ACb,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,OAAO,GACZ,MAAM,CAAC,SAAS,KAAK,SAAS;YAC7B,CAAC,CAAC,MAAM,yBAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC;YACtD,CAAC,CAAC,MAAM,oBAAoB,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO,IAAI,CAAC;QACb,CAAC;QAED,OAAO,uBAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC,6DAA6D,EAAE;YAC1E,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC7D,IAAI;YACJ,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,YAAY;YAC9C,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC;SAClC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC","sourcesContent":["import {\n\ttype PlatformServiceConfig,\n\tgetEnvValue,\n\tpostPlatformConnect,\n\tresolveOrganizationId,\n\tresolvePlatformServiceConfig,\n\ttrimString,\n} from \"../platform/client.js\";\nimport {\n\tPLATFORM_CONNECT_METHODS,\n\tPLATFORM_CONNECT_SERVICES,\n\tplatformConnectMethodPath,\n\tplatformConnectServicePath,\n} from \"../platform/core-services.js\";\nimport { fetchDownstream } from \"../utils/downstream-http.js\";\nimport { createLogger } from \"../utils/logger.js\";\nimport type {\n\tResolvePromptTemplateInput,\n\tResolvedPromptTemplate,\n} from \"./types.js\";\n\nconst logger = createLogger(\"prompts:service\");\nconst DEFAULT_TIMEOUT_MS = 2_000;\nconst DEFAULT_MAX_ATTEMPTS = 2;\nconst RESOLVE_PROMPT_PATH = platformConnectMethodPath(\n\tPLATFORM_CONNECT_METHODS.prompts.resolve,\n);\nconst LEGACY_RESOLVE_PROMPT_PATH = \"/v1/resolve\";\nconst PROMPTS_BASE_URL_ENV_VARS = [\n\t\"PROMPTS_SERVICE_URL\",\n\t\"MAESTRO_PROMPTS_SERVICE_URL\",\n] as const;\nconst PROMPTS_TOKEN_ENV_VARS = [\n\t\"PROMPTS_SERVICE_TOKEN\",\n\t\"MAESTRO_PROMPTS_SERVICE_TOKEN\",\n\t\"MAESTRO_EVALOPS_ACCESS_TOKEN\",\n\t\"EVALOPS_TOKEN\",\n] as const;\nconst PROMPTS_ORGANIZATION_ENV_VARS = [\n\t\"PROMPTS_SERVICE_ORGANIZATION_ID\",\n\t\"MAESTRO_PROMPTS_ORGANIZATION_ID\",\n\t\"MAESTRO_EVALOPS_ORG_ID\",\n\t\"EVALOPS_ORGANIZATION_ID\",\n\t\"MAESTRO_ENTERPRISE_ORG_ID\",\n] as const;\n\ntype PromptsTransport = \"connect\" | \"legacy-rest\";\n\ntype PromptsServiceConfig = PlatformServiceConfig & {\n\ttransport: PromptsTransport;\n};\n\ninterface ResolveVersionPayload {\n\tid?: string;\n\tversion?: number;\n\tcontent?: string;\n}\n\ninterface ResolveResponse {\n\tversion?: ResolveVersionPayload;\n}\n\nfunction resolvePromptsTransport(): PromptsTransport {\n\tconst configured = trimString(\n\t\tprocess.env.PROMPTS_SERVICE_TRANSPORT,\n\t)?.toLowerCase();\n\tif (configured === \"connect\" || configured === \"platform\") {\n\t\treturn \"connect\";\n\t}\n\tif (configured === \"legacy\" || configured === \"legacy-rest\") {\n\t\treturn \"legacy-rest\";\n\t}\n\tconst serviceSpecificBase = getEnvValue(PROMPTS_BASE_URL_ENV_VARS);\n\treturn serviceSpecificBase ? \"legacy-rest\" : \"connect\";\n}\n\nfunction hasConfiguredPromptsBaseUrl(): boolean {\n\treturn Boolean(\n\t\tgetEnvValue([\n\t\t\t...PROMPTS_BASE_URL_ENV_VARS,\n\t\t\t\"MAESTRO_PLATFORM_BASE_URL\",\n\t\t\t\"MAESTRO_EVALOPS_BASE_URL\",\n\t\t\t\"EVALOPS_BASE_URL\",\n\t\t]),\n\t);\n}\n\nfunction warnPromptsServiceMisconfiguration(): void {\n\tif (!hasConfiguredPromptsBaseUrl()) {\n\t\treturn;\n\t}\n\tif (!resolveOrganizationId(PROMPTS_ORGANIZATION_ENV_VARS)) {\n\t\tlogger.warn(\n\t\t\t\"Prompts service configured without organization id; retaining bundled prompts\",\n\t\t);\n\t\treturn;\n\t}\n\tlogger.warn(\n\t\t\"Prompts service configured without access token; retaining bundled prompts\",\n\t);\n}\n\nasync function resolvePromptsServiceConfig(): Promise<PromptsServiceConfig | null> {\n\tconst config = await resolvePlatformServiceConfig({\n\t\tbaseUrlEnvVars: PROMPTS_BASE_URL_ENV_VARS,\n\t\ttokenEnvVars: PROMPTS_TOKEN_ENV_VARS,\n\t\torganizationEnvVars: PROMPTS_ORGANIZATION_ENV_VARS,\n\t\ttimeoutEnvVars: [\n\t\t\t\"PROMPTS_SERVICE_TIMEOUT_MS\",\n\t\t\t\"MAESTRO_PROMPTS_TIMEOUT_MS\",\n\t\t],\n\t\tmaxAttemptsEnvVars: [\n\t\t\t\"PROMPTS_SERVICE_MAX_ATTEMPTS\",\n\t\t\t\"MAESTRO_PROMPTS_MAX_ATTEMPTS\",\n\t\t],\n\t\tbaseUrlSuffixes: [\n\t\t\tRESOLVE_PROMPT_PATH,\n\t\t\tLEGACY_RESOLVE_PROMPT_PATH,\n\t\t\tplatformConnectServicePath(PLATFORM_CONNECT_SERVICES.prompts),\n\t\t],\n\t\tdefaultTimeoutMs: DEFAULT_TIMEOUT_MS,\n\t\tdefaultMaxAttempts: DEFAULT_MAX_ATTEMPTS,\n\t\trequireOrganizationId: true,\n\t\trequireToken: true,\n\t});\n\tif (!config) {\n\t\twarnPromptsServiceMisconfiguration();\n\t\treturn null;\n\t}\n\n\treturn {\n\t\t...config,\n\t\ttransport: resolvePromptsTransport(),\n\t};\n}\n\nfunction buildHeaders(config: PromptsServiceConfig): Record<string, string> {\n\treturn {\n\t\t...(config.token ? { Authorization: `Bearer ${config.token}` } : {}),\n\t\t...(config.organizationId\n\t\t\t? { \"X-Organization-ID\": config.organizationId }\n\t\t\t: {}),\n\t};\n}\n\nfunction normalizeResolvedPrompt(\n\tinput: ResolvePromptTemplateInput,\n\tpayload: ResolveResponse,\n): ResolvedPromptTemplate | null {\n\tconst name = trimString(input.name);\n\tconst versionId = trimString(payload.version?.id);\n\tconst content = trimString(payload.version?.content);\n\tconst version = payload.version?.version;\n\tif (!name || !versionId || !content || !Number.isFinite(version)) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tname,\n\t\tlabel: trimString(input.label) ?? \"production\",\n\t\tsurface: trimString(input.surface),\n\t\tversion: Math.round(version!),\n\t\tversionId,\n\t\tcontent,\n\t};\n}\n\nasync function resolveViaPlatformConnect(\n\tconfig: PromptsServiceConfig,\n\tinput: ResolvePromptTemplateInput,\n\tname: string,\n): Promise<ResolveResponse | null> {\n\tconst response = await postPlatformConnect(\n\t\tconfig,\n\t\tRESOLVE_PROMPT_PATH,\n\t\t{\n\t\t\tname,\n\t\t\tlabel: trimString(input.label) ?? \"production\",\n\t\t},\n\t\t{\n\t\t\tserviceName: \"prompts service\",\n\t\t\tfailureMode: \"optional\",\n\t\t\ttimeoutMs: config.timeoutMs,\n\t\t\tmaxAttempts: config.maxAttempts,\n\t\t},\n\t);\n\tif (response.status === 404) {\n\t\treturn null;\n\t}\n\tif (!response.ok) {\n\t\tconst text = await response.text();\n\t\tthrow new Error(\n\t\t\t`prompts service returned ${response.status}: ${text || response.statusText}`,\n\t\t);\n\t}\n\treturn (await response.json()) as ResolveResponse;\n}\n\nasync function resolveViaLegacyRest(\n\tconfig: PromptsServiceConfig,\n\tinput: ResolvePromptTemplateInput,\n\tname: string,\n): Promise<ResolveResponse | null> {\n\tconst url = new URL(LEGACY_RESOLVE_PROMPT_PATH, config.baseUrl);\n\turl.searchParams.set(\"name\", name);\n\turl.searchParams.set(\"env\", trimString(input.label) ?? \"production\");\n\tif (trimString(input.surface)) {\n\t\turl.searchParams.set(\"surface\", trimString(input.surface)!);\n\t}\n\n\tconst response = await fetchDownstream(\n\t\turl,\n\t\t{\n\t\t\tmethod: \"GET\",\n\t\t\theaders: buildHeaders(config),\n\t\t},\n\t\t{\n\t\t\tserviceName: \"prompts service\",\n\t\t\tfailureMode: \"optional\",\n\t\t\ttimeoutMs: config.timeoutMs,\n\t\t\tmaxAttempts: config.maxAttempts,\n\t\t},\n\t);\n\tif (response.status === 404) {\n\t\treturn null;\n\t}\n\tif (!response.ok) {\n\t\tconst text = await response.text();\n\t\tthrow new Error(\n\t\t\t`prompts service returned ${response.status}: ${text || response.statusText}`,\n\t\t);\n\t}\n\treturn (await response.json()) as ResolveResponse;\n}\n\nexport async function resolvePromptTemplate(\n\tinput: ResolvePromptTemplateInput,\n): Promise<ResolvedPromptTemplate | null> {\n\tconst name = trimString(input.name);\n\tif (!name) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst config = await resolvePromptsServiceConfig();\n\t\tif (!config) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst payload =\n\t\t\tconfig.transport === \"connect\"\n\t\t\t\t? await resolveViaPlatformConnect(config, input, name)\n\t\t\t\t: await resolveViaLegacyRest(config, input, name);\n\t\tif (!payload) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn normalizeResolvedPrompt(input, payload);\n\t} catch (error) {\n\t\tlogger.warn(\"Failed to resolve prompt template; retaining bundled prompt\", {\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\tname,\n\t\t\tlabel: trimString(input.label) ?? \"production\",\n\t\t\tsurface: trimString(input.surface),\n\t\t});\n\t\treturn null;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-auth.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;
|
|
1
|
+
{"version":3,"file":"anthropic-auth.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAYH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,SAAS,CAAC;AAEnD,MAAM,WAAW,wBAAwB;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,kBAAkB,CAAC;CACzB;AA4BD,eAAO,MAAM,uBAAuB,8IACwG,CAAC;AAyB7I,wBAAsB,iCAAiC,IAAI,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CA+BlG;AAED,wBAAsB,4BAA4B,CACjD,UAAU,EAAE,wBAAwB,GAClC,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,IAAI,CAAC,CAMpE;AAED,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAqBjG;AAED,wBAAsB,yBAAyB,CAC9C,IAAI,GAAE,kBAA0B;;;GAsBhC;AAED,wBAAsB,kCAAkC,CACvD,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC;IACV,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CAAC,CAiCR;AAED,wBAAsB,0BAA0B,CAC/C,YAAY,EAAE,MAAM,GAClB,OAAO,CAAC;IACV,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CAAC,CA0BR;AAED,wBAAsB,iBAAiB,CACtC,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBxB"}
|
|
@@ -51,7 +51,9 @@ import { rm } from "node:fs/promises";
|
|
|
51
51
|
import { dirname, join, resolve } from "node:path";
|
|
52
52
|
import { getAgentDir } from "../config/constants.js";
|
|
53
53
|
import { safeJsonParse } from "../utils/json.js";
|
|
54
|
+
import { fetchOAuthHttp } from "../utils/oauth-http.js";
|
|
54
55
|
const CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
56
|
+
const ANTHROPIC_OAUTH_SERVICE_NAME = "Anthropic OAuth service";
|
|
55
57
|
const CLAUDE_LOGIN_HOST = {
|
|
56
58
|
pro: "claude.ai",
|
|
57
59
|
console: "console.anthropic.com",
|
|
@@ -154,7 +156,7 @@ export async function exchangeAnthropicAuthorizationCode(code, verifier) {
|
|
|
154
156
|
if (!actualCode || !state) {
|
|
155
157
|
return null;
|
|
156
158
|
}
|
|
157
|
-
const response = await
|
|
159
|
+
const response = await fetchOAuthHttp("https://console.anthropic.com/v1/oauth/token", {
|
|
158
160
|
method: "POST",
|
|
159
161
|
headers: { "Content-Type": "application/json" },
|
|
160
162
|
body: JSON.stringify({
|
|
@@ -165,7 +167,7 @@ export async function exchangeAnthropicAuthorizationCode(code, verifier) {
|
|
|
165
167
|
redirect_uri: "https://console.anthropic.com/oauth/code/callback",
|
|
166
168
|
code_verifier: verifier,
|
|
167
169
|
}),
|
|
168
|
-
});
|
|
170
|
+
}, { serviceName: ANTHROPIC_OAUTH_SERVICE_NAME });
|
|
169
171
|
if (!response.ok) {
|
|
170
172
|
return null;
|
|
171
173
|
}
|
|
@@ -180,7 +182,7 @@ export async function exchangeAnthropicAuthorizationCode(code, verifier) {
|
|
|
180
182
|
};
|
|
181
183
|
}
|
|
182
184
|
export async function refreshAnthropicOAuthToken(refreshToken) {
|
|
183
|
-
const response = await
|
|
185
|
+
const response = await fetchOAuthHttp("https://console.anthropic.com/v1/oauth/token", {
|
|
184
186
|
method: "POST",
|
|
185
187
|
headers: { "Content-Type": "application/json" },
|
|
186
188
|
body: JSON.stringify({
|
|
@@ -188,7 +190,7 @@ export async function refreshAnthropicOAuthToken(refreshToken) {
|
|
|
188
190
|
refresh_token: refreshToken,
|
|
189
191
|
client_id: CLIENT_ID,
|
|
190
192
|
}),
|
|
191
|
-
});
|
|
193
|
+
}, { serviceName: ANTHROPIC_OAUTH_SERVICE_NAME });
|
|
192
194
|
if (!response.ok) {
|
|
193
195
|
return null;
|
|
194
196
|
}
|
|
@@ -203,13 +205,13 @@ export async function refreshAnthropicOAuthToken(refreshToken) {
|
|
|
203
205
|
};
|
|
204
206
|
}
|
|
205
207
|
export async function fetchClaudeApiKey(accessToken) {
|
|
206
|
-
const response = await
|
|
208
|
+
const response = await fetchOAuthHttp("https://api.anthropic.com/api/oauth/claude_cli/create_api_key", {
|
|
207
209
|
method: "POST",
|
|
208
210
|
headers: {
|
|
209
211
|
"Content-Type": "application/json",
|
|
210
212
|
authorization: `Bearer ${accessToken}`,
|
|
211
213
|
},
|
|
212
|
-
});
|
|
214
|
+
}, { serviceName: ANTHROPIC_OAUTH_SERVICE_NAME });
|
|
213
215
|
if (!response.ok) {
|
|
214
216
|
return null;
|
|
215
217
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-auth.js","sourceRoot":"","sources":["../../src/providers/anthropic-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,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CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,OAAO,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAyB,CAAC;IAChE,OAAO,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACrE,CAAC","sourcesContent":["/**\n * Anthropic OAuth Authentication\n *\n * This module implements OAuth 2.0 with PKCE for authenticating with\n * Anthropic's Claude API. It supports both claude.ai (Pro) and\n * console.anthropic.com (Console) login modes.\n *\n * ## Authentication Flow\n *\n * ```\n * ┌─────────────────────────────────────────────────────────────┐\n * │ Anthropic OAuth Flow │\n * ├─────────────────────────────────────────────────────────────┤\n * │ 1. Generate PKCE challenge (verifier + challenge) │\n * │ 2. Generate login URL → User opens in browser │\n * │ 3. User authenticates at claude.ai or console.anthropic.com│\n * │ 4. Receive authorization code from redirect │\n * │ 5. Exchange code + verifier for access/refresh tokens │\n * │ 6. Store credentials in ~/.maestro/anthropic-oauth.json │\n * │ 7. Auto-refresh tokens when they expire │\n * └─────────────────────────────────────────────────────────────┘\n * ```\n *\n * ## Login Modes\n *\n * | Mode | Host | Description |\n * |---------|-------------------------|--------------------------|\n * | pro | claude.ai | Claude Pro subscriptions |\n * | console | console.anthropic.com | API Console access |\n *\n * ## Token Storage\n *\n * Credentials are stored at:\n * - Default: `~/.maestro/anthropic-oauth.json`\n * - Custom: `$ANTHROPIC_OAUTH_FILE`\n *\n * File is created with mode 0o600 (owner read/write only).\n *\n * ## Key Functions\n *\n * - `generateAnthropicLoginUrl()`: Create OAuth URL for browser\n * - `exchangeAnthropicAuthorizationCode()`: Exchange code for tokens\n * - `getFreshAnthropicOAuthCredential()`: Get valid token (auto-refresh)\n * - `fetchClaudeApiKey()`: Convert OAuth token to API key\n *\n * @module providers/anthropic-auth\n */\n\nimport { createHash, randomBytes } from \"node:crypto\";\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { rm } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { getAgentDir } from \"../config/constants.js\";\nimport { safeJsonParse } from \"../utils/json.js\";\n\n// Portions of this module are derived from https://github.com/sst/opencode-anthropic-auth (MIT).\n\nexport type AnthropicLoginMode = \"pro\" | \"console\";\n\nexport interface AnthropicOAuthCredential {\n\taccessToken: string;\n\trefreshToken: string;\n\texpiresAt: number;\n\tmode: AnthropicLoginMode;\n}\n\nconst CLIENT_ID = \"9d1c250a-e61b-44d9-88ed-5944d1962f5e\";\n\nconst CLAUDE_LOGIN_HOST: Record<AnthropicLoginMode, string> = {\n\tpro: \"claude.ai\",\n\tconsole: \"console.anthropic.com\",\n};\n\ninterface AnthropicTokenResponse {\n\taccess_token?: string;\n\trefresh_token?: string;\n\texpires_in?: number;\n\terror?: string;\n}\n\ninterface ClaudeApiKeyResponse {\n\traw_key?: string;\n}\n\nconst DEFAULT_BASE_DIR = resolve(getAgentDir(), \"..\");\n\nconst AUTH_FILE = resolve(\n\tprocess.env.ANTHROPIC_OAUTH_FILE ??\n\t\tjoin(DEFAULT_BASE_DIR, \"anthropic-oauth.json\"),\n);\n\nexport const CLAUDE_CODE_BETA_HEADER =\n\t\"oauth-2025-04-20,claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14,advanced-tool-use-2025-11-20\";\n\ninterface PKCEPair {\n\tverifier: string;\n\tchallenge: string;\n}\n\nfunction toBase64Url(buffer: Buffer): string {\n\treturn buffer\n\t\t.toString(\"base64\")\n\t\t.replace(/\\+/g, \"-\")\n\t\t.replace(/\\//g, \"_\")\n\t\t.replace(/=+$/g, \"\");\n}\n\nasync function generatePKCE(): Promise<PKCEPair> {\n\tconst verifier = toBase64Url(randomBytes(32));\n\tconst challenge = toBase64Url(createHash(\"sha256\").update(verifier).digest());\n\treturn { verifier, challenge };\n}\n\nfunction ensureAuthDir(): void {\n\tmkdirSync(dirname(AUTH_FILE), { recursive: true });\n}\n\nexport async function getStoredAnthropicOAuthCredential(): Promise<AnthropicOAuthCredential | null> {\n\ttry {\n\t\tconst contents = readFileSync(AUTH_FILE, \"utf8\");\n\t\tconst result = safeJsonParse<{\n\t\t\taccessToken?: unknown;\n\t\t\trefreshToken?: unknown;\n\t\t\texpiresAt?: unknown;\n\t\t\tmode?: unknown;\n\t\t}>(contents, \"Anthropic auth credentials\");\n\n\t\tif (!result.success) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst parsed = result.data;\n\t\tif (\n\t\t\ttypeof parsed.accessToken === \"string\" &&\n\t\t\ttypeof parsed.refreshToken === \"string\" &&\n\t\t\ttypeof parsed.expiresAt === \"number\"\n\t\t) {\n\t\t\treturn {\n\t\t\t\taccessToken: parsed.accessToken,\n\t\t\t\trefreshToken: parsed.refreshToken,\n\t\t\t\texpiresAt: parsed.expiresAt,\n\t\t\t\tmode: parsed.mode === \"console\" ? \"console\" : \"pro\",\n\t\t\t};\n\t\t}\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function saveAnthropicOAuthCredential(\n\tcredential: AnthropicOAuthCredential,\n): Promise<void> {\n\tensureAuthDir();\n\twriteFileSync(AUTH_FILE, JSON.stringify(credential, null, 2), {\n\t\tencoding: \"utf8\",\n\t\tmode: 0o600,\n\t});\n}\n\nexport async function deleteAnthropicOAuthCredential(): Promise<void> {\n\ttry {\n\t\tawait rm(AUTH_FILE);\n\t} catch {\n\t\t// ignore when file does not exist\n\t}\n}\n\nexport async function getFreshAnthropicOAuthCredential(): Promise<AnthropicOAuthCredential | null> {\n\tconst stored = await getStoredAnthropicOAuthCredential();\n\tif (!stored) {\n\t\treturn null;\n\t}\n\tif (stored.expiresAt - Date.now() > 60_000) {\n\t\treturn stored;\n\t}\n\tconst refreshed = await refreshAnthropicOAuthToken(stored.refreshToken);\n\tif (!refreshed) {\n\t\tawait deleteAnthropicOAuthCredential();\n\t\treturn null;\n\t}\n\tconst next: AnthropicOAuthCredential = {\n\t\t...stored,\n\t\taccessToken: refreshed.accessToken,\n\t\trefreshToken: refreshed.refreshToken ?? stored.refreshToken,\n\t\texpiresAt: refreshed.expiresAt,\n\t};\n\tawait saveAnthropicOAuthCredential(next);\n\treturn next;\n}\n\nexport async function generateAnthropicLoginUrl(\n\tmode: AnthropicLoginMode = \"pro\",\n) {\n\tconst pkce = await generatePKCE();\n\tconst base = new URL(\n\t\t`https://${CLAUDE_LOGIN_HOST[mode]}/oauth/authorize`,\n\t\t`https://${CLAUDE_LOGIN_HOST[mode]}`,\n\t);\n\tbase.searchParams.set(\"code\", \"true\");\n\tbase.searchParams.set(\"client_id\", CLIENT_ID);\n\tbase.searchParams.set(\"response_type\", \"code\");\n\tbase.searchParams.set(\n\t\t\"redirect_uri\",\n\t\t\"https://console.anthropic.com/oauth/code/callback\",\n\t);\n\tbase.searchParams.set(\n\t\t\"scope\",\n\t\t\"org:create_api_key user:profile user:inference\",\n\t);\n\tbase.searchParams.set(\"code_challenge\", pkce.challenge);\n\tbase.searchParams.set(\"code_challenge_method\", \"S256\");\n\tbase.searchParams.set(\"state\", pkce.verifier);\n\treturn { url: base.toString(), verifier: pkce.verifier };\n}\n\nexport async function exchangeAnthropicAuthorizationCode(\n\tcode: string,\n\tverifier: string,\n): Promise<{\n\taccessToken: string;\n\trefreshToken: string;\n\texpiresAt: number;\n} | null> {\n\tconst [actualCode, state] = code.trim().split(\"#\");\n\tif (!actualCode || !state) {\n\t\treturn null;\n\t}\n\tconst response = await fetch(\"https://console.anthropic.com/v1/oauth/token\", {\n\t\tmethod: \"POST\",\n\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\tbody: JSON.stringify({\n\t\t\tcode: actualCode,\n\t\t\tstate,\n\t\t\tgrant_type: \"authorization_code\",\n\t\t\tclient_id: CLIENT_ID,\n\t\t\tredirect_uri: \"https://console.anthropic.com/oauth/code/callback\",\n\t\t\tcode_verifier: verifier,\n\t\t}),\n\t});\n\tif (!response.ok) {\n\t\treturn null;\n\t}\n\tconst payload = (await response.json()) as AnthropicTokenResponse;\n\tif (!payload.access_token || !payload.refresh_token) {\n\t\treturn null;\n\t}\n\treturn {\n\t\taccessToken: payload.access_token,\n\t\trefreshToken: payload.refresh_token,\n\t\texpiresAt: Date.now() + (payload.expires_in ?? 0) * 1000,\n\t};\n}\n\nexport async function refreshAnthropicOAuthToken(\n\trefreshToken: string,\n): Promise<{\n\taccessToken: string;\n\trefreshToken?: string;\n\texpiresAt: number;\n} | null> {\n\tconst response = await fetch(\"https://console.anthropic.com/v1/oauth/token\", {\n\t\tmethod: \"POST\",\n\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\tbody: JSON.stringify({\n\t\t\tgrant_type: \"refresh_token\",\n\t\t\trefresh_token: refreshToken,\n\t\t\tclient_id: CLIENT_ID,\n\t\t}),\n\t});\n\tif (!response.ok) {\n\t\treturn null;\n\t}\n\tconst payload = (await response.json()) as AnthropicTokenResponse;\n\tif (!payload.access_token) {\n\t\treturn null;\n\t}\n\treturn {\n\t\taccessToken: payload.access_token,\n\t\trefreshToken: payload.refresh_token,\n\t\texpiresAt: Date.now() + (payload.expires_in ?? 0) * 1000,\n\t};\n}\n\nexport async function fetchClaudeApiKey(\n\taccessToken: string,\n): Promise<string | null> {\n\tconst response = await fetch(\n\t\t\"https://api.anthropic.com/api/oauth/claude_cli/create_api_key\",\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\tauthorization: `Bearer ${accessToken}`,\n\t\t\t},\n\t\t},\n\t);\n\tif (!response.ok) {\n\t\treturn null;\n\t}\n\tconst payload = (await response.json()) as ClaudeApiKeyResponse;\n\treturn typeof payload.raw_key === \"string\" ? payload.raw_key : null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"anthropic-auth.js","sourceRoot":"","sources":["../../src/providers/anthropic-auth.ts"],"names":[],"mappings":"A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IAAI,CAAC;IACb,CAAC;IACD,OAAO;QACN,WAAW,EAAE,OAAO,CAAC,YAAY;QACjC,YAAY,EAAE,OAAO,CAAC,aAAa;QACnC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,GAAG,IAAI;KACxD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,WAAmB;IAEnB,MAAM,QAAQ,GAAG,MAAM,cAAc,CACpC,+DAA+D,EAC/D;QACC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACR,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,WAAW,EAAE;SACtC;KACD,EACD,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAC7C,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,OAAO,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAyB,CAAC;IAChE,OAAO,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACrE,CAAC","sourcesContent":["/**\n * Anthropic OAuth Authentication\n *\n * This module implements OAuth 2.0 with PKCE for authenticating with\n * Anthropic's Claude API. It supports both claude.ai (Pro) and\n * console.anthropic.com (Console) login modes.\n *\n * ## Authentication Flow\n *\n * ```\n * ┌─────────────────────────────────────────────────────────────┐\n * │ Anthropic OAuth Flow │\n * ├─────────────────────────────────────────────────────────────┤\n * │ 1. Generate PKCE challenge (verifier + challenge) │\n * │ 2. Generate login URL → User opens in browser │\n * │ 3. User authenticates at claude.ai or console.anthropic.com│\n * │ 4. Receive authorization code from redirect │\n * │ 5. Exchange code + verifier for access/refresh tokens │\n * │ 6. Store credentials in ~/.maestro/anthropic-oauth.json │\n * │ 7. Auto-refresh tokens when they expire │\n * └─────────────────────────────────────────────────────────────┘\n * ```\n *\n * ## Login Modes\n *\n * | Mode | Host | Description |\n * |---------|-------------------------|--------------------------|\n * | pro | claude.ai | Claude Pro subscriptions |\n * | console | console.anthropic.com | API Console access |\n *\n * ## Token Storage\n *\n * Credentials are stored at:\n * - Default: `~/.maestro/anthropic-oauth.json`\n * - Custom: `$ANTHROPIC_OAUTH_FILE`\n *\n * File is created with mode 0o600 (owner read/write only).\n *\n * ## Key Functions\n *\n * - `generateAnthropicLoginUrl()`: Create OAuth URL for browser\n * - `exchangeAnthropicAuthorizationCode()`: Exchange code for tokens\n * - `getFreshAnthropicOAuthCredential()`: Get valid token (auto-refresh)\n * - `fetchClaudeApiKey()`: Convert OAuth token to API key\n *\n * @module providers/anthropic-auth\n */\n\nimport { createHash, randomBytes } from \"node:crypto\";\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { rm } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { getAgentDir } from \"../config/constants.js\";\nimport { safeJsonParse } from \"../utils/json.js\";\nimport { fetchOAuthHttp } from \"../utils/oauth-http.js\";\n\n// Portions of this module are derived from https://github.com/sst/opencode-anthropic-auth (MIT).\n\nexport type AnthropicLoginMode = \"pro\" | \"console\";\n\nexport interface AnthropicOAuthCredential {\n\taccessToken: string;\n\trefreshToken: string;\n\texpiresAt: number;\n\tmode: AnthropicLoginMode;\n}\n\nconst CLIENT_ID = \"9d1c250a-e61b-44d9-88ed-5944d1962f5e\";\nconst ANTHROPIC_OAUTH_SERVICE_NAME = \"Anthropic OAuth service\";\n\nconst CLAUDE_LOGIN_HOST: Record<AnthropicLoginMode, string> = {\n\tpro: \"claude.ai\",\n\tconsole: \"console.anthropic.com\",\n};\n\ninterface AnthropicTokenResponse {\n\taccess_token?: string;\n\trefresh_token?: string;\n\texpires_in?: number;\n\terror?: string;\n}\n\ninterface ClaudeApiKeyResponse {\n\traw_key?: string;\n}\n\nconst DEFAULT_BASE_DIR = resolve(getAgentDir(), \"..\");\n\nconst AUTH_FILE = resolve(\n\tprocess.env.ANTHROPIC_OAUTH_FILE ??\n\t\tjoin(DEFAULT_BASE_DIR, \"anthropic-oauth.json\"),\n);\n\nexport const CLAUDE_CODE_BETA_HEADER =\n\t\"oauth-2025-04-20,claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14,advanced-tool-use-2025-11-20\";\n\ninterface PKCEPair {\n\tverifier: string;\n\tchallenge: string;\n}\n\nfunction toBase64Url(buffer: Buffer): string {\n\treturn buffer\n\t\t.toString(\"base64\")\n\t\t.replace(/\\+/g, \"-\")\n\t\t.replace(/\\//g, \"_\")\n\t\t.replace(/=+$/g, \"\");\n}\n\nasync function generatePKCE(): Promise<PKCEPair> {\n\tconst verifier = toBase64Url(randomBytes(32));\n\tconst challenge = toBase64Url(createHash(\"sha256\").update(verifier).digest());\n\treturn { verifier, challenge };\n}\n\nfunction ensureAuthDir(): void {\n\tmkdirSync(dirname(AUTH_FILE), { recursive: true });\n}\n\nexport async function getStoredAnthropicOAuthCredential(): Promise<AnthropicOAuthCredential | null> {\n\ttry {\n\t\tconst contents = readFileSync(AUTH_FILE, \"utf8\");\n\t\tconst result = safeJsonParse<{\n\t\t\taccessToken?: unknown;\n\t\t\trefreshToken?: unknown;\n\t\t\texpiresAt?: unknown;\n\t\t\tmode?: unknown;\n\t\t}>(contents, \"Anthropic auth credentials\");\n\n\t\tif (!result.success) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst parsed = result.data;\n\t\tif (\n\t\t\ttypeof parsed.accessToken === \"string\" &&\n\t\t\ttypeof parsed.refreshToken === \"string\" &&\n\t\t\ttypeof parsed.expiresAt === \"number\"\n\t\t) {\n\t\t\treturn {\n\t\t\t\taccessToken: parsed.accessToken,\n\t\t\t\trefreshToken: parsed.refreshToken,\n\t\t\t\texpiresAt: parsed.expiresAt,\n\t\t\t\tmode: parsed.mode === \"console\" ? \"console\" : \"pro\",\n\t\t\t};\n\t\t}\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function saveAnthropicOAuthCredential(\n\tcredential: AnthropicOAuthCredential,\n): Promise<void> {\n\tensureAuthDir();\n\twriteFileSync(AUTH_FILE, JSON.stringify(credential, null, 2), {\n\t\tencoding: \"utf8\",\n\t\tmode: 0o600,\n\t});\n}\n\nexport async function deleteAnthropicOAuthCredential(): Promise<void> {\n\ttry {\n\t\tawait rm(AUTH_FILE);\n\t} catch {\n\t\t// ignore when file does not exist\n\t}\n}\n\nexport async function getFreshAnthropicOAuthCredential(): Promise<AnthropicOAuthCredential | null> {\n\tconst stored = await getStoredAnthropicOAuthCredential();\n\tif (!stored) {\n\t\treturn null;\n\t}\n\tif (stored.expiresAt - Date.now() > 60_000) {\n\t\treturn stored;\n\t}\n\tconst refreshed = await refreshAnthropicOAuthToken(stored.refreshToken);\n\tif (!refreshed) {\n\t\tawait deleteAnthropicOAuthCredential();\n\t\treturn null;\n\t}\n\tconst next: AnthropicOAuthCredential = {\n\t\t...stored,\n\t\taccessToken: refreshed.accessToken,\n\t\trefreshToken: refreshed.refreshToken ?? stored.refreshToken,\n\t\texpiresAt: refreshed.expiresAt,\n\t};\n\tawait saveAnthropicOAuthCredential(next);\n\treturn next;\n}\n\nexport async function generateAnthropicLoginUrl(\n\tmode: AnthropicLoginMode = \"pro\",\n) {\n\tconst pkce = await generatePKCE();\n\tconst base = new URL(\n\t\t`https://${CLAUDE_LOGIN_HOST[mode]}/oauth/authorize`,\n\t\t`https://${CLAUDE_LOGIN_HOST[mode]}`,\n\t);\n\tbase.searchParams.set(\"code\", \"true\");\n\tbase.searchParams.set(\"client_id\", CLIENT_ID);\n\tbase.searchParams.set(\"response_type\", \"code\");\n\tbase.searchParams.set(\n\t\t\"redirect_uri\",\n\t\t\"https://console.anthropic.com/oauth/code/callback\",\n\t);\n\tbase.searchParams.set(\n\t\t\"scope\",\n\t\t\"org:create_api_key user:profile user:inference\",\n\t);\n\tbase.searchParams.set(\"code_challenge\", pkce.challenge);\n\tbase.searchParams.set(\"code_challenge_method\", \"S256\");\n\tbase.searchParams.set(\"state\", pkce.verifier);\n\treturn { url: base.toString(), verifier: pkce.verifier };\n}\n\nexport async function exchangeAnthropicAuthorizationCode(\n\tcode: string,\n\tverifier: string,\n): Promise<{\n\taccessToken: string;\n\trefreshToken: string;\n\texpiresAt: number;\n} | null> {\n\tconst [actualCode, state] = code.trim().split(\"#\");\n\tif (!actualCode || !state) {\n\t\treturn null;\n\t}\n\tconst response = await fetchOAuthHttp(\n\t\t\"https://console.anthropic.com/v1/oauth/token\",\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tbody: JSON.stringify({\n\t\t\t\tcode: actualCode,\n\t\t\t\tstate,\n\t\t\t\tgrant_type: \"authorization_code\",\n\t\t\t\tclient_id: CLIENT_ID,\n\t\t\t\tredirect_uri: \"https://console.anthropic.com/oauth/code/callback\",\n\t\t\t\tcode_verifier: verifier,\n\t\t\t}),\n\t\t},\n\t\t{ serviceName: ANTHROPIC_OAUTH_SERVICE_NAME },\n\t);\n\tif (!response.ok) {\n\t\treturn null;\n\t}\n\tconst payload = (await response.json()) as AnthropicTokenResponse;\n\tif (!payload.access_token || !payload.refresh_token) {\n\t\treturn null;\n\t}\n\treturn {\n\t\taccessToken: payload.access_token,\n\t\trefreshToken: payload.refresh_token,\n\t\texpiresAt: Date.now() + (payload.expires_in ?? 0) * 1000,\n\t};\n}\n\nexport async function refreshAnthropicOAuthToken(\n\trefreshToken: string,\n): Promise<{\n\taccessToken: string;\n\trefreshToken?: string;\n\texpiresAt: number;\n} | null> {\n\tconst response = await fetchOAuthHttp(\n\t\t\"https://console.anthropic.com/v1/oauth/token\",\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tbody: JSON.stringify({\n\t\t\t\tgrant_type: \"refresh_token\",\n\t\t\t\trefresh_token: refreshToken,\n\t\t\t\tclient_id: CLIENT_ID,\n\t\t\t}),\n\t\t},\n\t\t{ serviceName: ANTHROPIC_OAUTH_SERVICE_NAME },\n\t);\n\tif (!response.ok) {\n\t\treturn null;\n\t}\n\tconst payload = (await response.json()) as AnthropicTokenResponse;\n\tif (!payload.access_token) {\n\t\treturn null;\n\t}\n\treturn {\n\t\taccessToken: payload.access_token,\n\t\trefreshToken: payload.refresh_token,\n\t\texpiresAt: Date.now() + (payload.expires_in ?? 0) * 1000,\n\t};\n}\n\nexport async function fetchClaudeApiKey(\n\taccessToken: string,\n): Promise<string | null> {\n\tconst response = await fetchOAuthHttp(\n\t\t\"https://api.anthropic.com/api/oauth/claude_cli/create_api_key\",\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\tauthorization: `Bearer ${accessToken}`,\n\t\t\t},\n\t\t},\n\t\t{ serviceName: ANTHROPIC_OAUTH_SERVICE_NAME },\n\t);\n\tif (!response.ok) {\n\t\treturn null;\n\t}\n\tconst payload = (await response.json()) as ClaudeApiKeyResponse;\n\treturn typeof payload.raw_key === \"string\" ? payload.raw_key : null;\n}\n"]}
|
|
@@ -63,6 +63,7 @@ export declare const envApiKeyMap: {
|
|
|
63
63
|
readonly "google-antigravity": readonly ["GOOGLE_ANTIGRAVITY_TOKEN"];
|
|
64
64
|
readonly evalops: readonly ["MAESTRO_EVALOPS_ACCESS_TOKEN"];
|
|
65
65
|
readonly openai: readonly ["OPENAI_API_KEY"];
|
|
66
|
+
readonly "openai-codex": readonly ["OPENAI_CODEX_TOKEN", "OPENAI_CODEX_ACCESS_TOKEN", "CODEX_API_KEY"];
|
|
66
67
|
readonly "azure-openai": readonly ["AZURE_OPENAI_API_KEY"];
|
|
67
68
|
readonly anthropic: readonly ["ANTHROPIC_OAUTH_TOKEN", "ANTHROPIC_API_KEY"];
|
|
68
69
|
readonly bedrock: readonly ["AWS_ACCESS_KEY_ID", "AWS_PROFILE", "AWS_SSO_SESSION_NAME", "AWS_WEB_IDENTITY_TOKEN_FILE", "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../src/providers/api-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAMH,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../src/providers/api-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAMH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;CA2B6B,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,YAAY,CAAC;AAEtD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,aAAa,CAErE;AAYD,MAAM,MAAM,YAAY,GACrB,UAAU,GACV,KAAK,GACL,gBAAgB,GAChB,YAAY,GACZ,SAAS,CAAC;AAEb,MAAM,WAAW,kBAAkB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,YAAY,CAC3B,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GAClB,kBAAkB,CAoFpB;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAOhE"}
|
|
@@ -66,6 +66,11 @@ export const envApiKeyMap = {
|
|
|
66
66
|
"google-antigravity": ["GOOGLE_ANTIGRAVITY_TOKEN"],
|
|
67
67
|
evalops: ["MAESTRO_EVALOPS_ACCESS_TOKEN"],
|
|
68
68
|
openai: ["OPENAI_API_KEY"],
|
|
69
|
+
"openai-codex": [
|
|
70
|
+
"OPENAI_CODEX_TOKEN",
|
|
71
|
+
"OPENAI_CODEX_ACCESS_TOKEN",
|
|
72
|
+
"CODEX_API_KEY",
|
|
73
|
+
],
|
|
69
74
|
"azure-openai": ["AZURE_OPENAI_API_KEY"],
|
|
70
75
|
anthropic: ["ANTHROPIC_OAUTH_TOKEN", "ANTHROPIC_API_KEY"],
|
|
71
76
|
bedrock: [
|