@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,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Codex OAuth integration.
|
|
3
|
+
*
|
|
4
|
+
* This is intentionally separate from the OpenAI Platform OAuth flow. Codex
|
|
5
|
+
* uses the ChatGPT access token directly against the ChatGPT Codex backend,
|
|
6
|
+
* while the regular OpenAI provider exchanges the login for a Platform API key.
|
|
7
|
+
*/
|
|
8
|
+
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
9
|
+
import { createServer, } from "node:http";
|
|
10
|
+
import { createLogger } from "../utils/logger.js";
|
|
11
|
+
import { saveOAuthCredentials } from "./storage.js";
|
|
12
|
+
const logger = createLogger("oauth:openai-codex");
|
|
13
|
+
const CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
14
|
+
const ISSUER = "https://auth.openai.com";
|
|
15
|
+
const AUTHORIZE_URL = `${ISSUER}/oauth/authorize`;
|
|
16
|
+
const TOKEN_URL = `${ISSUER}/oauth/token`;
|
|
17
|
+
const CALLBACK_PORT = 1455;
|
|
18
|
+
const CALLBACK_HOST = "127.0.0.1";
|
|
19
|
+
const REDIRECT_URI = `http://localhost:${CALLBACK_PORT}/auth/callback`;
|
|
20
|
+
const CALLBACK_ORIGIN = `http://${CALLBACK_HOST}:${CALLBACK_PORT}`;
|
|
21
|
+
const SCOPE = "openid profile email offline_access";
|
|
22
|
+
const ORIGINATOR = "codex_cli_rs";
|
|
23
|
+
const JWT_CLAIM_PATH = "https://api.openai.com/auth";
|
|
24
|
+
const LOGIN_TIMEOUT_MS = 5 * 60 * 1000;
|
|
25
|
+
function base64UrlEncode(buffer) {
|
|
26
|
+
return buffer
|
|
27
|
+
.toString("base64")
|
|
28
|
+
.replace(/\+/g, "-")
|
|
29
|
+
.replace(/\//g, "_")
|
|
30
|
+
.replace(/=+$/g, "");
|
|
31
|
+
}
|
|
32
|
+
function base64UrlDecode(value) {
|
|
33
|
+
const padded = `${value}${"=".repeat((4 - (value.length % 4)) % 4)}`;
|
|
34
|
+
return Buffer.from(padded.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf8");
|
|
35
|
+
}
|
|
36
|
+
function generatePkce() {
|
|
37
|
+
const verifier = base64UrlEncode(randomBytes(32));
|
|
38
|
+
const challenge = base64UrlEncode(createHash("sha256").update(verifier).digest());
|
|
39
|
+
return { verifier, challenge };
|
|
40
|
+
}
|
|
41
|
+
function createState() {
|
|
42
|
+
return base64UrlEncode(randomBytes(32));
|
|
43
|
+
}
|
|
44
|
+
function safeTimingEqual(a, b) {
|
|
45
|
+
const left = Buffer.from(a);
|
|
46
|
+
const right = Buffer.from(b);
|
|
47
|
+
return left.length === right.length && timingSafeEqual(left, right);
|
|
48
|
+
}
|
|
49
|
+
function escapeHtml(value) {
|
|
50
|
+
return value
|
|
51
|
+
.replace(/&/g, "&")
|
|
52
|
+
.replace(/</g, "<")
|
|
53
|
+
.replace(/>/g, ">")
|
|
54
|
+
.replace(/"/g, """)
|
|
55
|
+
.replace(/'/g, "'");
|
|
56
|
+
}
|
|
57
|
+
export function parseOpenAICodexAuthorizationInput(input) {
|
|
58
|
+
const value = input.trim();
|
|
59
|
+
if (!value)
|
|
60
|
+
return {};
|
|
61
|
+
try {
|
|
62
|
+
const url = new URL(value);
|
|
63
|
+
return {
|
|
64
|
+
code: url.searchParams.get("code") ?? undefined,
|
|
65
|
+
state: url.searchParams.get("state") ?? undefined,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Not a full URL.
|
|
70
|
+
}
|
|
71
|
+
if (value.includes("#")) {
|
|
72
|
+
const [code, state] = value.split("#", 2);
|
|
73
|
+
return { code, state };
|
|
74
|
+
}
|
|
75
|
+
if (value.includes("code=")) {
|
|
76
|
+
const params = new URLSearchParams(value);
|
|
77
|
+
return {
|
|
78
|
+
code: params.get("code") ?? undefined,
|
|
79
|
+
state: params.get("state") ?? undefined,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return { code: value };
|
|
83
|
+
}
|
|
84
|
+
function decodeJwt(token) {
|
|
85
|
+
try {
|
|
86
|
+
const parts = token.split(".");
|
|
87
|
+
if (parts.length !== 3 || !parts[1])
|
|
88
|
+
return null;
|
|
89
|
+
return JSON.parse(base64UrlDecode(parts[1]));
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function extractOpenAICodexAccountId(accessToken) {
|
|
96
|
+
const payload = decodeJwt(accessToken);
|
|
97
|
+
const accountId = payload?.[JWT_CLAIM_PATH]?.chatgpt_account_id;
|
|
98
|
+
return typeof accountId === "string" && accountId.trim().length > 0
|
|
99
|
+
? accountId.trim()
|
|
100
|
+
: null;
|
|
101
|
+
}
|
|
102
|
+
function buildAuthorizationUrl(state, challenge) {
|
|
103
|
+
const url = new URL(AUTHORIZE_URL);
|
|
104
|
+
url.searchParams.set("response_type", "code");
|
|
105
|
+
url.searchParams.set("client_id", CLIENT_ID);
|
|
106
|
+
url.searchParams.set("redirect_uri", REDIRECT_URI);
|
|
107
|
+
url.searchParams.set("scope", SCOPE);
|
|
108
|
+
url.searchParams.set("code_challenge", challenge);
|
|
109
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
110
|
+
url.searchParams.set("state", state);
|
|
111
|
+
url.searchParams.set("id_token_add_organizations", "true");
|
|
112
|
+
url.searchParams.set("codex_cli_simplified_flow", "true");
|
|
113
|
+
url.searchParams.set("originator", ORIGINATOR);
|
|
114
|
+
return url.toString();
|
|
115
|
+
}
|
|
116
|
+
async function exchangeAuthorizationCode(code, verifier) {
|
|
117
|
+
const response = await fetch(TOKEN_URL, {
|
|
118
|
+
method: "POST",
|
|
119
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
120
|
+
body: new URLSearchParams({
|
|
121
|
+
grant_type: "authorization_code",
|
|
122
|
+
client_id: CLIENT_ID,
|
|
123
|
+
code,
|
|
124
|
+
code_verifier: verifier,
|
|
125
|
+
redirect_uri: REDIRECT_URI,
|
|
126
|
+
}).toString(),
|
|
127
|
+
});
|
|
128
|
+
if (!response.ok) {
|
|
129
|
+
const text = await response.text().catch(() => "");
|
|
130
|
+
throw new Error(`OpenAI Codex token exchange failed (${response.status}): ${text}`);
|
|
131
|
+
}
|
|
132
|
+
const payload = (await response.json());
|
|
133
|
+
if (!payload.access_token || !payload.refresh_token) {
|
|
134
|
+
throw new Error("OpenAI Codex token response was missing OAuth tokens");
|
|
135
|
+
}
|
|
136
|
+
const accountId = extractOpenAICodexAccountId(payload.access_token);
|
|
137
|
+
if (!accountId) {
|
|
138
|
+
throw new Error("OpenAI Codex token response did not include account id");
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
type: "oauth",
|
|
142
|
+
access: payload.access_token,
|
|
143
|
+
refresh: payload.refresh_token,
|
|
144
|
+
expires: Date.now() + (payload.expires_in ?? 3600) * 1000,
|
|
145
|
+
metadata: {
|
|
146
|
+
mode: "openai-codex",
|
|
147
|
+
accountId,
|
|
148
|
+
scopes: SCOPE.split(" "),
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async function refreshAccessToken(refreshToken) {
|
|
153
|
+
const response = await fetch(TOKEN_URL, {
|
|
154
|
+
method: "POST",
|
|
155
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
156
|
+
body: new URLSearchParams({
|
|
157
|
+
grant_type: "refresh_token",
|
|
158
|
+
client_id: CLIENT_ID,
|
|
159
|
+
refresh_token: refreshToken,
|
|
160
|
+
}).toString(),
|
|
161
|
+
});
|
|
162
|
+
if (!response.ok) {
|
|
163
|
+
const text = await response.text().catch(() => "");
|
|
164
|
+
throw new Error(`OpenAI Codex token refresh failed (${response.status}): ${text}`);
|
|
165
|
+
}
|
|
166
|
+
const payload = (await response.json());
|
|
167
|
+
if (!payload.access_token || !payload.refresh_token) {
|
|
168
|
+
throw new Error("OpenAI Codex refresh response was missing OAuth tokens");
|
|
169
|
+
}
|
|
170
|
+
const accountId = extractOpenAICodexAccountId(payload.access_token);
|
|
171
|
+
if (!accountId) {
|
|
172
|
+
throw new Error("OpenAI Codex refresh response did not include account id");
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
type: "oauth",
|
|
176
|
+
access: payload.access_token,
|
|
177
|
+
refresh: payload.refresh_token,
|
|
178
|
+
expires: Date.now() + (payload.expires_in ?? 3600) * 1000,
|
|
179
|
+
metadata: {
|
|
180
|
+
mode: "openai-codex",
|
|
181
|
+
accountId,
|
|
182
|
+
scopes: SCOPE.split(" "),
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
async function startCallbackServer(state) {
|
|
187
|
+
return new Promise((resolve) => {
|
|
188
|
+
let settleCode;
|
|
189
|
+
const codePromise = new Promise((codeResolve) => {
|
|
190
|
+
settleCode = codeResolve;
|
|
191
|
+
});
|
|
192
|
+
const server = createServer((req, res) => {
|
|
193
|
+
const reqUrl = new URL(req.url ?? "", CALLBACK_ORIGIN);
|
|
194
|
+
if (reqUrl.pathname !== "/auth/callback") {
|
|
195
|
+
res.writeHead(404, { "Content-Type": "text/html; charset=utf-8" });
|
|
196
|
+
res.end("<html><body><h1>Not Found</h1></body></html>");
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const error = reqUrl.searchParams.get("error");
|
|
200
|
+
const errorDescription = reqUrl.searchParams.get("error_description");
|
|
201
|
+
if (error) {
|
|
202
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
203
|
+
res.end(`<html><body><h1>Authentication Failed</h1><p>${escapeHtml(error)}</p><p>${escapeHtml(errorDescription ?? "")}</p></body></html>`);
|
|
204
|
+
settleCode(null);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const code = reqUrl.searchParams.get("code");
|
|
208
|
+
const returnedState = reqUrl.searchParams.get("state");
|
|
209
|
+
if (!code || !returnedState || !safeTimingEqual(returnedState, state)) {
|
|
210
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
211
|
+
res.end("<html><body><h1>Authentication Failed</h1><p>Invalid OAuth callback.</p></body></html>");
|
|
212
|
+
settleCode(null);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
216
|
+
res.end("<html><body><h1>Login Successful</h1><p>You can close this tab and return to Maestro.</p></body></html>");
|
|
217
|
+
settleCode(code);
|
|
218
|
+
});
|
|
219
|
+
server.once("error", (error) => {
|
|
220
|
+
logger.warn("OpenAI Codex OAuth callback server unavailable", {
|
|
221
|
+
code: error.code,
|
|
222
|
+
message: error.message,
|
|
223
|
+
});
|
|
224
|
+
settleCode(null);
|
|
225
|
+
resolve({ server: null, getCode: () => codePromise });
|
|
226
|
+
});
|
|
227
|
+
server.listen(CALLBACK_PORT, CALLBACK_HOST, () => {
|
|
228
|
+
resolve({ server, getCode: () => codePromise });
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
async function waitForPromptCode(onPromptCode, state) {
|
|
233
|
+
const input = await onPromptCode();
|
|
234
|
+
const parsed = parseOpenAICodexAuthorizationInput(input);
|
|
235
|
+
if (parsed.state && !safeTimingEqual(parsed.state, state)) {
|
|
236
|
+
throw new Error("State mismatch in OpenAI Codex OAuth callback");
|
|
237
|
+
}
|
|
238
|
+
return parsed.code ?? null;
|
|
239
|
+
}
|
|
240
|
+
export async function loginOpenAICodex(onAuthUrl, onPromptCode, onStatus) {
|
|
241
|
+
const { verifier, challenge } = generatePkce();
|
|
242
|
+
const state = createState();
|
|
243
|
+
const authUrl = buildAuthorizationUrl(state, challenge);
|
|
244
|
+
const callback = await startCallbackServer(state);
|
|
245
|
+
let timeout;
|
|
246
|
+
try {
|
|
247
|
+
onAuthUrl(authUrl);
|
|
248
|
+
onStatus?.(callback.server
|
|
249
|
+
? "Complete OpenAI login in the browser, or paste the redirect URL/code if prompted."
|
|
250
|
+
: "Callback server unavailable. Paste the OpenAI redirect URL or authorization code.");
|
|
251
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
252
|
+
timeout = setTimeout(() => {
|
|
253
|
+
reject(new Error("OpenAI Codex OAuth login timed out"));
|
|
254
|
+
}, LOGIN_TIMEOUT_MS);
|
|
255
|
+
});
|
|
256
|
+
let code;
|
|
257
|
+
if (!callback.server && onPromptCode) {
|
|
258
|
+
code = await Promise.race([
|
|
259
|
+
waitForPromptCode(onPromptCode, state),
|
|
260
|
+
timeoutPromise,
|
|
261
|
+
]);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
code = await Promise.race([callback.getCode(), timeoutPromise]);
|
|
265
|
+
if (!code && onPromptCode) {
|
|
266
|
+
code = await Promise.race([
|
|
267
|
+
waitForPromptCode(onPromptCode, state),
|
|
268
|
+
timeoutPromise,
|
|
269
|
+
]);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (!code) {
|
|
273
|
+
throw new Error(onPromptCode
|
|
274
|
+
? "Missing OpenAI Codex authorization code"
|
|
275
|
+
: "OpenAI Codex OAuth did not receive a callback. Try again with a manual code prompt.");
|
|
276
|
+
}
|
|
277
|
+
onStatus?.("Exchanging OpenAI Codex authorization code...");
|
|
278
|
+
const credentials = await exchangeAuthorizationCode(code, verifier);
|
|
279
|
+
saveOAuthCredentials("openai-codex", credentials);
|
|
280
|
+
onStatus?.("OpenAI Codex credentials saved.");
|
|
281
|
+
}
|
|
282
|
+
finally {
|
|
283
|
+
if (timeout) {
|
|
284
|
+
clearTimeout(timeout);
|
|
285
|
+
}
|
|
286
|
+
callback.server?.close();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
export async function refreshOpenAICodexToken(refreshToken, metadata) {
|
|
290
|
+
const refreshed = await refreshAccessToken(refreshToken);
|
|
291
|
+
return {
|
|
292
|
+
...refreshed,
|
|
293
|
+
metadata: {
|
|
294
|
+
...(metadata ?? {}),
|
|
295
|
+
...refreshed.metadata,
|
|
296
|
+
mode: "openai-codex",
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=openai-codex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-codex.js","sourceRoot":"","sources":["../../src/oauth/openai-codex.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,E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,QAAQ,EAAE;YACT,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC;YACnB,GAAG,SAAS,CAAC,QAAQ;YACrB,IAAI,EAAE,cAAc;SACpB;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * OpenAI Codex OAuth integration.\n *\n * This is intentionally separate from the OpenAI Platform OAuth flow. Codex\n * uses the ChatGPT access token directly against the ChatGPT Codex backend,\n * while the regular OpenAI provider exchanges the login for a Platform API key.\n */\n\nimport { createHash, randomBytes, timingSafeEqual } from \"node:crypto\";\nimport {\n\ttype IncomingMessage,\n\ttype Server,\n\ttype ServerResponse,\n\tcreateServer,\n} from \"node:http\";\nimport { createLogger } from \"../utils/logger.js\";\nimport { type OAuthCredentials, saveOAuthCredentials } from \"./storage.js\";\n\nconst logger = createLogger(\"oauth:openai-codex\");\n\nconst CLIENT_ID = \"app_EMoamEEZ73f0CkXaXp7hrann\";\nconst ISSUER = \"https://auth.openai.com\";\nconst AUTHORIZE_URL = `${ISSUER}/oauth/authorize`;\nconst TOKEN_URL = `${ISSUER}/oauth/token`;\nconst CALLBACK_PORT = 1455;\nconst CALLBACK_HOST = \"127.0.0.1\";\nconst REDIRECT_URI = `http://localhost:${CALLBACK_PORT}/auth/callback`;\nconst CALLBACK_ORIGIN = `http://${CALLBACK_HOST}:${CALLBACK_PORT}`;\nconst SCOPE = \"openid profile email offline_access\";\nconst ORIGINATOR = \"codex_cli_rs\";\nconst JWT_CLAIM_PATH = \"https://api.openai.com/auth\";\nconst LOGIN_TIMEOUT_MS = 5 * 60 * 1000;\n\ninterface TokenResponse {\n\taccess_token?: string;\n\trefresh_token?: string;\n\texpires_in?: number;\n\terror?: string;\n\terror_description?: string;\n}\n\ninterface CodexJwtPayload {\n\t[JWT_CLAIM_PATH]?: {\n\t\tchatgpt_account_id?: string;\n\t};\n\t[key: string]: unknown;\n}\n\nfunction base64UrlEncode(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\nfunction base64UrlDecode(value: string): string {\n\tconst padded = `${value}${\"=\".repeat((4 - (value.length % 4)) % 4)}`;\n\treturn Buffer.from(\n\t\tpadded.replace(/-/g, \"+\").replace(/_/g, \"/\"),\n\t\t\"base64\",\n\t).toString(\"utf8\");\n}\n\nfunction generatePkce(): { verifier: string; challenge: string } {\n\tconst verifier = base64UrlEncode(randomBytes(32));\n\tconst challenge = base64UrlEncode(\n\t\tcreateHash(\"sha256\").update(verifier).digest(),\n\t);\n\treturn { verifier, challenge };\n}\n\nfunction createState(): string {\n\treturn base64UrlEncode(randomBytes(32));\n}\n\nfunction safeTimingEqual(a: string, b: string): boolean {\n\tconst left = Buffer.from(a);\n\tconst right = Buffer.from(b);\n\treturn left.length === right.length && timingSafeEqual(left, right);\n}\n\nfunction escapeHtml(value: string): string {\n\treturn value\n\t\t.replace(/&/g, \"&\")\n\t\t.replace(/</g, \"<\")\n\t\t.replace(/>/g, \">\")\n\t\t.replace(/\"/g, \""\")\n\t\t.replace(/'/g, \"'\");\n}\n\nexport function parseOpenAICodexAuthorizationInput(input: string): {\n\tcode?: string;\n\tstate?: string;\n} {\n\tconst value = input.trim();\n\tif (!value) return {};\n\n\ttry {\n\t\tconst url = new URL(value);\n\t\treturn {\n\t\t\tcode: url.searchParams.get(\"code\") ?? undefined,\n\t\t\tstate: url.searchParams.get(\"state\") ?? undefined,\n\t\t};\n\t} catch {\n\t\t// Not a full URL.\n\t}\n\n\tif (value.includes(\"#\")) {\n\t\tconst [code, state] = value.split(\"#\", 2);\n\t\treturn { code, state };\n\t}\n\n\tif (value.includes(\"code=\")) {\n\t\tconst params = new URLSearchParams(value);\n\t\treturn {\n\t\t\tcode: params.get(\"code\") ?? undefined,\n\t\t\tstate: params.get(\"state\") ?? undefined,\n\t\t};\n\t}\n\n\treturn { code: value };\n}\n\nfunction decodeJwt(token: string): CodexJwtPayload | null {\n\ttry {\n\t\tconst parts = token.split(\".\");\n\t\tif (parts.length !== 3 || !parts[1]) return null;\n\t\treturn JSON.parse(base64UrlDecode(parts[1])) as CodexJwtPayload;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport function extractOpenAICodexAccountId(\n\taccessToken: string,\n): string | null {\n\tconst payload = decodeJwt(accessToken);\n\tconst accountId = payload?.[JWT_CLAIM_PATH]?.chatgpt_account_id;\n\treturn typeof accountId === \"string\" && accountId.trim().length > 0\n\t\t? accountId.trim()\n\t\t: null;\n}\n\nfunction buildAuthorizationUrl(state: string, challenge: string): string {\n\tconst url = new URL(AUTHORIZE_URL);\n\turl.searchParams.set(\"response_type\", \"code\");\n\turl.searchParams.set(\"client_id\", CLIENT_ID);\n\turl.searchParams.set(\"redirect_uri\", REDIRECT_URI);\n\turl.searchParams.set(\"scope\", SCOPE);\n\turl.searchParams.set(\"code_challenge\", challenge);\n\turl.searchParams.set(\"code_challenge_method\", \"S256\");\n\turl.searchParams.set(\"state\", state);\n\turl.searchParams.set(\"id_token_add_organizations\", \"true\");\n\turl.searchParams.set(\"codex_cli_simplified_flow\", \"true\");\n\turl.searchParams.set(\"originator\", ORIGINATOR);\n\treturn url.toString();\n}\n\nasync function exchangeAuthorizationCode(\n\tcode: string,\n\tverifier: string,\n): Promise<OAuthCredentials> {\n\tconst response = await fetch(TOKEN_URL, {\n\t\tmethod: \"POST\",\n\t\theaders: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n\t\tbody: new URLSearchParams({\n\t\t\tgrant_type: \"authorization_code\",\n\t\t\tclient_id: CLIENT_ID,\n\t\t\tcode,\n\t\t\tcode_verifier: verifier,\n\t\t\tredirect_uri: REDIRECT_URI,\n\t\t}).toString(),\n\t});\n\n\tif (!response.ok) {\n\t\tconst text = await response.text().catch(() => \"\");\n\t\tthrow new Error(\n\t\t\t`OpenAI Codex token exchange failed (${response.status}): ${text}`,\n\t\t);\n\t}\n\n\tconst payload = (await response.json()) as TokenResponse;\n\tif (!payload.access_token || !payload.refresh_token) {\n\t\tthrow new Error(\"OpenAI Codex token response was missing OAuth tokens\");\n\t}\n\n\tconst accountId = extractOpenAICodexAccountId(payload.access_token);\n\tif (!accountId) {\n\t\tthrow new Error(\"OpenAI Codex token response did not include account id\");\n\t}\n\n\treturn {\n\t\ttype: \"oauth\",\n\t\taccess: payload.access_token,\n\t\trefresh: payload.refresh_token,\n\t\texpires: Date.now() + (payload.expires_in ?? 3600) * 1000,\n\t\tmetadata: {\n\t\t\tmode: \"openai-codex\",\n\t\t\taccountId,\n\t\t\tscopes: SCOPE.split(\" \"),\n\t\t},\n\t};\n}\n\nasync function refreshAccessToken(\n\trefreshToken: string,\n): Promise<OAuthCredentials> {\n\tconst response = await fetch(TOKEN_URL, {\n\t\tmethod: \"POST\",\n\t\theaders: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n\t\tbody: new URLSearchParams({\n\t\t\tgrant_type: \"refresh_token\",\n\t\t\tclient_id: CLIENT_ID,\n\t\t\trefresh_token: refreshToken,\n\t\t}).toString(),\n\t});\n\n\tif (!response.ok) {\n\t\tconst text = await response.text().catch(() => \"\");\n\t\tthrow new Error(\n\t\t\t`OpenAI Codex token refresh failed (${response.status}): ${text}`,\n\t\t);\n\t}\n\n\tconst payload = (await response.json()) as TokenResponse;\n\tif (!payload.access_token || !payload.refresh_token) {\n\t\tthrow new Error(\"OpenAI Codex refresh response was missing OAuth tokens\");\n\t}\n\n\tconst accountId = extractOpenAICodexAccountId(payload.access_token);\n\tif (!accountId) {\n\t\tthrow new Error(\"OpenAI Codex refresh response did not include account id\");\n\t}\n\n\treturn {\n\t\ttype: \"oauth\",\n\t\taccess: payload.access_token,\n\t\trefresh: payload.refresh_token,\n\t\texpires: Date.now() + (payload.expires_in ?? 3600) * 1000,\n\t\tmetadata: {\n\t\t\tmode: \"openai-codex\",\n\t\t\taccountId,\n\t\t\tscopes: SCOPE.split(\" \"),\n\t\t},\n\t};\n}\n\nasync function startCallbackServer(state: string): Promise<{\n\tserver: Server | null;\n\tgetCode: () => Promise<string | null>;\n}> {\n\treturn new Promise((resolve) => {\n\t\tlet settleCode: (code: string | null) => void;\n\t\tconst codePromise = new Promise<string | null>((codeResolve) => {\n\t\t\tsettleCode = codeResolve;\n\t\t});\n\n\t\tconst server = createServer((req: IncomingMessage, res: ServerResponse) => {\n\t\t\tconst reqUrl = new URL(req.url ?? \"\", CALLBACK_ORIGIN);\n\t\t\tif (reqUrl.pathname !== \"/auth/callback\") {\n\t\t\t\tres.writeHead(404, { \"Content-Type\": \"text/html; charset=utf-8\" });\n\t\t\t\tres.end(\"<html><body><h1>Not Found</h1></body></html>\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst error = reqUrl.searchParams.get(\"error\");\n\t\t\tconst errorDescription = reqUrl.searchParams.get(\"error_description\");\n\t\t\tif (error) {\n\t\t\t\tres.writeHead(400, { \"Content-Type\": \"text/html; charset=utf-8\" });\n\t\t\t\tres.end(\n\t\t\t\t\t`<html><body><h1>Authentication Failed</h1><p>${escapeHtml(error)}</p><p>${escapeHtml(errorDescription ?? \"\")}</p></body></html>`,\n\t\t\t\t);\n\t\t\t\tsettleCode(null);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst code = reqUrl.searchParams.get(\"code\");\n\t\t\tconst returnedState = reqUrl.searchParams.get(\"state\");\n\t\t\tif (!code || !returnedState || !safeTimingEqual(returnedState, state)) {\n\t\t\t\tres.writeHead(400, { \"Content-Type\": \"text/html; charset=utf-8\" });\n\t\t\t\tres.end(\n\t\t\t\t\t\"<html><body><h1>Authentication Failed</h1><p>Invalid OAuth callback.</p></body></html>\",\n\t\t\t\t);\n\t\t\t\tsettleCode(null);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tres.writeHead(200, { \"Content-Type\": \"text/html; charset=utf-8\" });\n\t\t\tres.end(\n\t\t\t\t\"<html><body><h1>Login Successful</h1><p>You can close this tab and return to Maestro.</p></body></html>\",\n\t\t\t);\n\t\t\tsettleCode(code);\n\t\t});\n\n\t\tserver.once(\"error\", (error: NodeJS.ErrnoException) => {\n\t\t\tlogger.warn(\"OpenAI Codex OAuth callback server unavailable\", {\n\t\t\t\tcode: error.code,\n\t\t\t\tmessage: error.message,\n\t\t\t});\n\t\t\tsettleCode(null);\n\t\t\tresolve({ server: null, getCode: () => codePromise });\n\t\t});\n\n\t\tserver.listen(CALLBACK_PORT, CALLBACK_HOST, () => {\n\t\t\tresolve({ server, getCode: () => codePromise });\n\t\t});\n\t});\n}\n\nasync function waitForPromptCode(\n\tonPromptCode: () => Promise<string>,\n\tstate: string,\n): Promise<string | null> {\n\tconst input = await onPromptCode();\n\tconst parsed = parseOpenAICodexAuthorizationInput(input);\n\tif (parsed.state && !safeTimingEqual(parsed.state, state)) {\n\t\tthrow new Error(\"State mismatch in OpenAI Codex OAuth callback\");\n\t}\n\treturn parsed.code ?? null;\n}\n\nexport async function loginOpenAICodex(\n\tonAuthUrl: (url: string) => void,\n\tonPromptCode?: () => Promise<string>,\n\tonStatus?: (status: string) => void,\n): Promise<void> {\n\tconst { verifier, challenge } = generatePkce();\n\tconst state = createState();\n\tconst authUrl = buildAuthorizationUrl(state, challenge);\n\tconst callback = await startCallbackServer(state);\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\n\ttry {\n\t\tonAuthUrl(authUrl);\n\t\tonStatus?.(\n\t\t\tcallback.server\n\t\t\t\t? \"Complete OpenAI login in the browser, or paste the redirect URL/code if prompted.\"\n\t\t\t\t: \"Callback server unavailable. Paste the OpenAI redirect URL or authorization code.\",\n\t\t);\n\n\t\tconst timeoutPromise = new Promise<never>((_, reject) => {\n\t\t\ttimeout = setTimeout(() => {\n\t\t\t\treject(new Error(\"OpenAI Codex OAuth login timed out\"));\n\t\t\t}, LOGIN_TIMEOUT_MS);\n\t\t});\n\n\t\tlet code: string | null;\n\t\tif (!callback.server && onPromptCode) {\n\t\t\tcode = await Promise.race([\n\t\t\t\twaitForPromptCode(onPromptCode, state),\n\t\t\t\ttimeoutPromise,\n\t\t\t]);\n\t\t} else {\n\t\t\tcode = await Promise.race([callback.getCode(), timeoutPromise]);\n\t\t\tif (!code && onPromptCode) {\n\t\t\t\tcode = await Promise.race([\n\t\t\t\t\twaitForPromptCode(onPromptCode, state),\n\t\t\t\t\ttimeoutPromise,\n\t\t\t\t]);\n\t\t\t}\n\t\t}\n\n\t\tif (!code) {\n\t\t\tthrow new Error(\n\t\t\t\tonPromptCode\n\t\t\t\t\t? \"Missing OpenAI Codex authorization code\"\n\t\t\t\t\t: \"OpenAI Codex OAuth did not receive a callback. Try again with a manual code prompt.\",\n\t\t\t);\n\t\t}\n\n\t\tonStatus?.(\"Exchanging OpenAI Codex authorization code...\");\n\t\tconst credentials = await exchangeAuthorizationCode(code, verifier);\n\t\tsaveOAuthCredentials(\"openai-codex\", credentials);\n\t\tonStatus?.(\"OpenAI Codex credentials saved.\");\n\t} finally {\n\t\tif (timeout) {\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t\tcallback.server?.close();\n\t}\n}\n\nexport async function refreshOpenAICodexToken(\n\trefreshToken: string,\n\tmetadata?: Record<string, unknown>,\n): Promise<OAuthCredentials> {\n\tconst refreshed = await refreshAccessToken(refreshToken);\n\treturn {\n\t\t...refreshed,\n\t\tmetadata: {\n\t\t\t...(metadata ?? {}),\n\t\t\t...refreshed.metadata,\n\t\t\tmode: \"openai-codex\",\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opentelemetry.d.ts","sourceRoot":"","sources":["../src/opentelemetry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opentelemetry.d.ts","sourceRoot":"","sources":["../src/opentelemetry.ts"],"names":[],"mappings":"AA0CA,eAAO,MAAM,sBAAsB,QAAO,OAmBzC,CAAC;AAEF,eAAO,MAAM,kBAAkB,2CAAoC,CAAC;AAEpE,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,sBAAsB,IAAI,mBAAmB,CAsC5D;AAED,wBAAsB,iBAAiB,CACtC,WAAW,SAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAiEf"}
|
package/dist/opentelemetry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { DiagConsoleLogger, DiagLogLevel, diag, trace, } from "@opentelemetry/api";
|
|
2
3
|
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
|
3
4
|
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
4
5
|
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
5
6
|
import { SEMRESATTRS_DEPLOYMENT_ENVIRONMENT, SEMRESATTRS_SERVICE_NAME, SEMRESATTRS_SERVICE_VERSION, } from "@opentelemetry/semantic-conventions";
|
|
6
|
-
import { getPackageVersion } from "./package-metadata.js";
|
|
7
7
|
let sdkStartPromise = null;
|
|
8
8
|
let sdkStarted = false;
|
|
9
9
|
let handlersRegistered = false;
|
|
@@ -16,7 +16,14 @@ const packageVersion = (() => {
|
|
|
16
16
|
if (cached) {
|
|
17
17
|
return cached;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
try {
|
|
20
|
+
const packageJson = createRequire(import.meta.url)("../package.json");
|
|
21
|
+
const version = packageJson.version;
|
|
22
|
+
cached = typeof version === "string" ? version : "unknown";
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
cached = process.env.MAESTRO_VERSION ?? "unknown";
|
|
26
|
+
}
|
|
20
27
|
return cached;
|
|
21
28
|
};
|
|
22
29
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opentelemetry.js","sourceRoot":"","sources":["../src/opentelemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,YAAY,EACZ,IAAI,EACJ,KAAK,GACL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EACN,kCAAkC,EAClC,wBAAwB,EACxB,2BAA2B,GAC3B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,IAAI,eAAe,GAAyB,IAAI,CAAC;AACjD,IAAI,UAAU,GAAG,KAAK,CAAC;AACvB,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAC/B,IAAI,qBAAqB,GAAkB,IAAI,CAAC;AAChD,IAAI,iBAAiB,GAAkB,IAAI,CAAC;AAC5C,IAAI,WAAW,GAAmB,IAAI,CAAC;AAEvC,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE;IAC5B,IAAI,MAAM,GAAkB,IAAI,CAAC;IACjC,OAAO,GAAW,EAAE;QACnB,IAAI,MAAM,EAAE,CAAC;YACZ,OAAO,MAAM,CAAC;QACf,CAAC;QACD,MAAM,GAAG,iBAAiB,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC;IACf,CAAC,CAAC;AACH,CAAC,CAAC,EAAE,CAAC;AAEL,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAY,EAAE;IACnD,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,GAAG,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,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E,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;YAC3B,KAAK,QAAQ,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;YAC5B,KAAK,QAAQ,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,eAAe,CAAC;AACxB,CAAC","sourcesContent":["import {\n\tDiagConsoleLogger,\n\tDiagLogLevel,\n\tdiag,\n\ttrace,\n} from \"@opentelemetry/api\";\nimport { getNodeAutoInstrumentations } from \"@opentelemetry/auto-instrumentations-node\";\nimport { resourceFromAttributes } from \"@opentelemetry/resources\";\nimport { NodeSDK } from \"@opentelemetry/sdk-node\";\nimport {\n\tSEMRESATTRS_DEPLOYMENT_ENVIRONMENT,\n\tSEMRESATTRS_SERVICE_NAME,\n\tSEMRESATTRS_SERVICE_VERSION,\n} from \"@opentelemetry/semantic-conventions\";\nimport { getPackageVersion } from \"./package-metadata.js\";\n\nlet sdkStartPromise: Promise<void> | null = null;\nlet sdkStarted = false;\nlet handlersRegistered = false;\nlet configuredServiceName: string | null = null;\nlet configuredSampler: string | null = null;\nlet sdkInstance: NodeSDK | null = null;\n\nconst packageVersion = (() => {\n\tlet cached: string | null = null;\n\treturn (): string => {\n\t\tif (cached) {\n\t\t\treturn cached;\n\t\t}\n\t\tcached = getPackageVersion();\n\t\treturn cached;\n\t};\n})();\n\nexport const isOpenTelemetryEnabled = (): boolean => {\n\tif (process.env.MAESTRO_OTEL === \"0\") {\n\t\treturn false;\n\t}\n\n\tif (process.env.MAESTRO_OTEL === \"1\") {\n\t\treturn true;\n\t}\n\n\tconst hasOtlpEndpoint = Boolean(process.env.OTEL_EXPORTER_OTLP_ENDPOINT);\n\tconst traceExporter = process.env.OTEL_TRACES_EXPORTER;\n\tconst metricsExporter = process.env.OTEL_METRICS_EXPORTER;\n\tconst logsExporter = process.env.OTEL_LOGS_EXPORTER;\n\tconst hasExplicitExporter =\n\t\t(traceExporter && traceExporter !== \"none\") ||\n\t\t(metricsExporter && metricsExporter !== \"none\") ||\n\t\t(logsExporter && logsExporter !== \"none\");\n\n\treturn hasOtlpEndpoint || Boolean(hasExplicitExporter);\n};\n\nexport const getTelemetryTracer = () => trace.getTracer(\"composer\");\n\nexport interface OpenTelemetryStatus {\n\tenabled: boolean;\n\treason: string;\n\tserviceName: string;\n\tsdkStarted: boolean;\n\totlpEndpoint?: string;\n\ttracesExporter?: string;\n\tmetricsExporter?: string;\n\tlogsExporter?: string;\n\tautoInstrumentation: boolean;\n\tsampler?: string;\n}\n\nexport function getOpenTelemetryStatus(): OpenTelemetryStatus {\n\tconst enabled = isOpenTelemetryEnabled();\n\tconst otlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT;\n\tconst tracesExporter =\n\t\tprocess.env.OTEL_TRACES_EXPORTER || (otlpEndpoint ? \"otlp\" : \"default\");\n\tconst metricsExporter =\n\t\tprocess.env.OTEL_METRICS_EXPORTER || (otlpEndpoint ? \"otlp\" : \"default\");\n\tconst logsExporter =\n\t\tprocess.env.OTEL_LOGS_EXPORTER || (otlpEndpoint ? \"otlp\" : \"default\");\n\tconst sampler =\n\t\tconfiguredSampler ||\n\t\tprocess.env.OTEL_TRACES_SAMPLER ||\n\t\tprocess.env.MAESTRO_OTEL_SAMPLER ||\n\t\t\"parentbased_traceidratio\";\n\n\tconst reason = enabled\n\t\t? process.env.MAESTRO_OTEL === \"1\"\n\t\t\t? \"MAESTRO_OTEL=1\"\n\t\t\t: \"OTEL exporter detected\"\n\t\t: process.env.MAESTRO_OTEL === \"0\"\n\t\t\t? \"MAESTRO_OTEL=0\"\n\t\t\t: \"no OTEL exporter configured\";\n\n\treturn {\n\t\tenabled,\n\t\treason,\n\t\tserviceName:\n\t\t\tconfiguredServiceName ||\n\t\t\tprocess.env.MAESTRO_OTEL_SERVICE_NAME ||\n\t\t\t\"composer\",\n\t\tsdkStarted,\n\t\totlpEndpoint,\n\t\ttracesExporter,\n\t\tmetricsExporter,\n\t\tlogsExporter,\n\t\tautoInstrumentation: enabled,\n\t\tsampler,\n\t};\n}\n\nexport async function initOpenTelemetry(\n\tserviceName = \"composer\",\n): Promise<void> {\n\tif (sdkStartPromise) {\n\t\treturn sdkStartPromise;\n\t}\n\tif (!isOpenTelemetryEnabled()) {\n\t\tsdkStartPromise = Promise.resolve();\n\t\treturn sdkStartPromise;\n\t}\n\n\tdiag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ERROR);\n\n\tconst resolvedServiceName =\n\t\tprocess.env.MAESTRO_OTEL_SERVICE_NAME || serviceName;\n\tconfiguredServiceName = resolvedServiceName;\n\n\tif (process.env.MAESTRO_OTEL_SAMPLER && !process.env.OTEL_TRACES_SAMPLER) {\n\t\tprocess.env.OTEL_TRACES_SAMPLER = process.env.MAESTRO_OTEL_SAMPLER;\n\t\tconfiguredSampler = process.env.MAESTRO_OTEL_SAMPLER;\n\t} else if (process.env.OTEL_TRACES_SAMPLER) {\n\t\tconfiguredSampler = process.env.OTEL_TRACES_SAMPLER;\n\t}\n\tconst resource = resourceFromAttributes({\n\t\t[SEMRESATTRS_SERVICE_NAME]: resolvedServiceName,\n\t\t[SEMRESATTRS_SERVICE_VERSION]: packageVersion(),\n\t\t[SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: process.env.NODE_ENV ?? \"development\",\n\t});\n\n\tconst sdk = new NodeSDK({\n\t\tresource,\n\t\tinstrumentations: [getNodeAutoInstrumentations()],\n\t});\n\tsdkInstance = sdk;\n\tsdkStartPromise = Promise.resolve().then(() => {\n\t\ttry {\n\t\t\tsdk.start();\n\t\t\tsdkStarted = true;\n\t\t} catch {\n\t\t\t// If OTEL boot fails, continue without blocking CLI/Web usage\n\t\t}\n\t});\n\n\tif (!handlersRegistered) {\n\t\thandlersRegistered = true;\n\t\tconst shutdown = async () => {\n\t\t\ttry {\n\t\t\t\tif (sdkInstance) {\n\t\t\t\t\tawait sdkInstance.shutdown();\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignore shutdown failures\n\t\t\t}\n\t\t};\n\n\t\tprocess.once(\"beforeExit\", () => {\n\t\t\tvoid shutdown();\n\t\t});\n\t\tprocess.once(\"SIGINT\", () => {\n\t\t\tvoid shutdown();\n\t\t});\n\t\tprocess.once(\"SIGTERM\", () => {\n\t\t\tvoid shutdown();\n\t\t});\n\t}\n\n\treturn sdkStartPromise;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"opentelemetry.js","sourceRoot":"","sources":["../src/opentelemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACN,iBAAiB,EACjB,YAAY,EACZ,IAAI,EACJ,KAAK,GACL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EACN,kCAAkC,EAClC,wBAAwB,EACxB,2BAA2B,GAC3B,MAAM,qCAAqC,CAAC;AAE7C,IAAI,eAAe,GAAyB,IAAI,CAAC;AACjD,IAAI,UAAU,GAAG,KAAK,CAAC;AACvB,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAC/B,IAAI,qBAAqB,GAAkB,IAAI,CAAC;AAChD,IAAI,iBAAiB,GAAkB,IAAI,CAAC;AAC5C,IAAI,WAAW,GAAmB,IAAI,CAAC;AAEvC,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE;IAC5B,IAAI,MAAM,GAAkB,IAAI,CAAC;IACjC,OAAO,GAAW,EAAE;QACnB,IAAI,MAAM,EAAE,CAAC;YACZ,OAAO,MAAM,CAAC;QACf,CAAC;QACD,IAAI,CAAC;YACJ,MAAM,WAAW,GAAG,aAAa,CAAC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C,GAAG,EAAE;QAC7C,IAAI,CAAC;YACJ,GAAG,CAAC,KAAK,EAAE,CAAC;YACZ,UAAU,GAAG,IAAI,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACR,8DAA8D;QAC/D,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACzB,kBAAkB,GAAG,IAAI,CAAC;QAC1B,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;YAC3B,IAAI,CAAC;gBACJ,IAAI,WAAW,EAAE,CAAC;oBACjB,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;gBAC9B,CAAC;YACF,CAAC;YAAC,MAAM,CAAC;gBACR,2BAA2B;YAC5B,CAAC;QACF,CAAC,CAAC;QAEF,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE;YAC/B,KAAK,QAAQ,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;YAC3B,KAAK,QAAQ,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;YAC5B,KAAK,QAAQ,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,eAAe,CAAC;AACxB,CAAC","sourcesContent":["import { createRequire } from \"node:module\";\nimport {\n\tDiagConsoleLogger,\n\tDiagLogLevel,\n\tdiag,\n\ttrace,\n} from \"@opentelemetry/api\";\nimport { getNodeAutoInstrumentations } from \"@opentelemetry/auto-instrumentations-node\";\nimport { resourceFromAttributes } from \"@opentelemetry/resources\";\nimport { NodeSDK } from \"@opentelemetry/sdk-node\";\nimport {\n\tSEMRESATTRS_DEPLOYMENT_ENVIRONMENT,\n\tSEMRESATTRS_SERVICE_NAME,\n\tSEMRESATTRS_SERVICE_VERSION,\n} from \"@opentelemetry/semantic-conventions\";\n\nlet sdkStartPromise: Promise<void> | null = null;\nlet sdkStarted = false;\nlet handlersRegistered = false;\nlet configuredServiceName: string | null = null;\nlet configuredSampler: string | null = null;\nlet sdkInstance: NodeSDK | null = null;\n\nconst packageVersion = (() => {\n\tlet cached: string | null = null;\n\treturn (): string => {\n\t\tif (cached) {\n\t\t\treturn cached;\n\t\t}\n\t\ttry {\n\t\t\tconst packageJson = createRequire(import.meta.url)(\"../package.json\") as {\n\t\t\t\tversion?: string;\n\t\t\t};\n\t\t\tconst version = packageJson.version;\n\t\t\tcached = typeof version === \"string\" ? version : \"unknown\";\n\t\t} catch (error) {\n\t\t\tcached = process.env.MAESTRO_VERSION ?? \"unknown\";\n\t\t}\n\t\treturn cached;\n\t};\n})();\n\nexport const isOpenTelemetryEnabled = (): boolean => {\n\tif (process.env.MAESTRO_OTEL === \"0\") {\n\t\treturn false;\n\t}\n\n\tif (process.env.MAESTRO_OTEL === \"1\") {\n\t\treturn true;\n\t}\n\n\tconst hasOtlpEndpoint = Boolean(process.env.OTEL_EXPORTER_OTLP_ENDPOINT);\n\tconst traceExporter = process.env.OTEL_TRACES_EXPORTER;\n\tconst metricsExporter = process.env.OTEL_METRICS_EXPORTER;\n\tconst logsExporter = process.env.OTEL_LOGS_EXPORTER;\n\tconst hasExplicitExporter =\n\t\t(traceExporter && traceExporter !== \"none\") ||\n\t\t(metricsExporter && metricsExporter !== \"none\") ||\n\t\t(logsExporter && logsExporter !== \"none\");\n\n\treturn hasOtlpEndpoint || Boolean(hasExplicitExporter);\n};\n\nexport const getTelemetryTracer = () => trace.getTracer(\"composer\");\n\nexport interface OpenTelemetryStatus {\n\tenabled: boolean;\n\treason: string;\n\tserviceName: string;\n\tsdkStarted: boolean;\n\totlpEndpoint?: string;\n\ttracesExporter?: string;\n\tmetricsExporter?: string;\n\tlogsExporter?: string;\n\tautoInstrumentation: boolean;\n\tsampler?: string;\n}\n\nexport function getOpenTelemetryStatus(): OpenTelemetryStatus {\n\tconst enabled = isOpenTelemetryEnabled();\n\tconst otlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT;\n\tconst tracesExporter =\n\t\tprocess.env.OTEL_TRACES_EXPORTER || (otlpEndpoint ? \"otlp\" : \"default\");\n\tconst metricsExporter =\n\t\tprocess.env.OTEL_METRICS_EXPORTER || (otlpEndpoint ? \"otlp\" : \"default\");\n\tconst logsExporter =\n\t\tprocess.env.OTEL_LOGS_EXPORTER || (otlpEndpoint ? \"otlp\" : \"default\");\n\tconst sampler =\n\t\tconfiguredSampler ||\n\t\tprocess.env.OTEL_TRACES_SAMPLER ||\n\t\tprocess.env.MAESTRO_OTEL_SAMPLER ||\n\t\t\"parentbased_traceidratio\";\n\n\tconst reason = enabled\n\t\t? process.env.MAESTRO_OTEL === \"1\"\n\t\t\t? \"MAESTRO_OTEL=1\"\n\t\t\t: \"OTEL exporter detected\"\n\t\t: process.env.MAESTRO_OTEL === \"0\"\n\t\t\t? \"MAESTRO_OTEL=0\"\n\t\t\t: \"no OTEL exporter configured\";\n\n\treturn {\n\t\tenabled,\n\t\treason,\n\t\tserviceName:\n\t\t\tconfiguredServiceName ||\n\t\t\tprocess.env.MAESTRO_OTEL_SERVICE_NAME ||\n\t\t\t\"composer\",\n\t\tsdkStarted,\n\t\totlpEndpoint,\n\t\ttracesExporter,\n\t\tmetricsExporter,\n\t\tlogsExporter,\n\t\tautoInstrumentation: enabled,\n\t\tsampler,\n\t};\n}\n\nexport async function initOpenTelemetry(\n\tserviceName = \"composer\",\n): Promise<void> {\n\tif (sdkStartPromise) {\n\t\treturn sdkStartPromise;\n\t}\n\tif (!isOpenTelemetryEnabled()) {\n\t\tsdkStartPromise = Promise.resolve();\n\t\treturn sdkStartPromise;\n\t}\n\n\tdiag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ERROR);\n\n\tconst resolvedServiceName =\n\t\tprocess.env.MAESTRO_OTEL_SERVICE_NAME || serviceName;\n\tconfiguredServiceName = resolvedServiceName;\n\n\tif (process.env.MAESTRO_OTEL_SAMPLER && !process.env.OTEL_TRACES_SAMPLER) {\n\t\tprocess.env.OTEL_TRACES_SAMPLER = process.env.MAESTRO_OTEL_SAMPLER;\n\t\tconfiguredSampler = process.env.MAESTRO_OTEL_SAMPLER;\n\t} else if (process.env.OTEL_TRACES_SAMPLER) {\n\t\tconfiguredSampler = process.env.OTEL_TRACES_SAMPLER;\n\t}\n\tconst resource = resourceFromAttributes({\n\t\t[SEMRESATTRS_SERVICE_NAME]: resolvedServiceName,\n\t\t[SEMRESATTRS_SERVICE_VERSION]: packageVersion(),\n\t\t[SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: process.env.NODE_ENV ?? \"development\",\n\t});\n\n\tconst sdk = new NodeSDK({\n\t\tresource,\n\t\tinstrumentations: [getNodeAutoInstrumentations()],\n\t});\n\tsdkInstance = sdk;\n\tsdkStartPromise = Promise.resolve().then(() => {\n\t\ttry {\n\t\t\tsdk.start();\n\t\t\tsdkStarted = true;\n\t\t} catch {\n\t\t\t// If OTEL boot fails, continue without blocking CLI/Web usage\n\t\t}\n\t});\n\n\tif (!handlersRegistered) {\n\t\thandlersRegistered = true;\n\t\tconst shutdown = async () => {\n\t\t\ttry {\n\t\t\t\tif (sdkInstance) {\n\t\t\t\t\tawait sdkInstance.shutdown();\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignore shutdown failures\n\t\t\t}\n\t\t};\n\n\t\tprocess.once(\"beforeExit\", () => {\n\t\t\tvoid shutdown();\n\t\t});\n\t\tprocess.once(\"SIGINT\", () => {\n\t\t\tvoid shutdown();\n\t\t});\n\t\tprocess.once(\"SIGTERM\", () => {\n\t\t\tvoid shutdown();\n\t\t});\n\t}\n\n\treturn sdkStartPromise;\n}\n"]}
|