@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,20 @@
|
|
|
1
|
+
import { type ExecutionTrace, type ExecutionTraceInput, type ExecutionTraceSpan, type TraceListQuery, type TraceStatus } from "./types.js";
|
|
2
|
+
export declare class TracesValidationError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare function normalizeTraceSpanName(value: unknown): string;
|
|
6
|
+
export declare function generateTraceId(): string;
|
|
7
|
+
export declare function generateSpanId(): string;
|
|
8
|
+
export declare function parseTraceStatus(value: unknown): TraceStatus;
|
|
9
|
+
export declare function countTraceSpans(spans: ExecutionTraceSpan[]): number;
|
|
10
|
+
export declare function normalizeExecutionTraceInput(input: ExecutionTraceInput): ExecutionTrace;
|
|
11
|
+
export declare function parseTraceLimit(value: string | null | undefined): number;
|
|
12
|
+
export declare function parseTraceOffset(value: string | null | undefined): number;
|
|
13
|
+
export declare function normalizeTraceListQuery(params: {
|
|
14
|
+
workspaceId?: string;
|
|
15
|
+
agentId?: string;
|
|
16
|
+
status?: string;
|
|
17
|
+
limit?: string | null;
|
|
18
|
+
offset?: string | null;
|
|
19
|
+
}): TraceListQuery;
|
|
20
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../src/services/traces/normalize.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EAIvB,KAAK,cAAc,EAGnB,KAAK,WAAW,EAChB,MAAM,YAAY,CAAC;AAMpB,qBAAa,qBAAsB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI3B;AAiBD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAS7D;AAQD,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAS5D;AAsKD,wBAAgB,eAAe,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,MAAM,CASnE;AAED,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,mBAAmB,GACxB,cAAc,CAsBhB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAOxE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAOzE;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,GAAG,cAAc,CAYjB"}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { TRACE_SPAN_STATUSES, TRACE_STATUSES, } from "./types.js";
|
|
3
|
+
const MAX_TRACE_ID_LENGTH = 64;
|
|
4
|
+
const DEFAULT_TRACE_LIST_LIMIT = 50;
|
|
5
|
+
const MAX_TRACE_LIST_LIMIT = 100;
|
|
6
|
+
export class TracesValidationError extends Error {
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "TracesValidationError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function isRecord(value) {
|
|
13
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14
|
+
}
|
|
15
|
+
function cleanRequiredString(value, label) {
|
|
16
|
+
if (typeof value !== "string") {
|
|
17
|
+
throw new TracesValidationError(`${label} is required.`);
|
|
18
|
+
}
|
|
19
|
+
const trimmed = value.trim();
|
|
20
|
+
if (!trimmed) {
|
|
21
|
+
throw new TracesValidationError(`${label} is required.`);
|
|
22
|
+
}
|
|
23
|
+
return trimmed;
|
|
24
|
+
}
|
|
25
|
+
export function normalizeTraceSpanName(value) {
|
|
26
|
+
const normalized = cleanRequiredString(value, "span.name")
|
|
27
|
+
.replace(/[\\/\s]+/gu, ".")
|
|
28
|
+
.replace(/\.+/gu, ".")
|
|
29
|
+
.replace(/^\.+|\.+$/gu, "");
|
|
30
|
+
if (!normalized) {
|
|
31
|
+
throw new TracesValidationError("span.name is required.");
|
|
32
|
+
}
|
|
33
|
+
return normalized;
|
|
34
|
+
}
|
|
35
|
+
function cleanOptionalString(value) {
|
|
36
|
+
if (typeof value !== "string")
|
|
37
|
+
return undefined;
|
|
38
|
+
const trimmed = value.trim();
|
|
39
|
+
return trimmed ? trimmed : undefined;
|
|
40
|
+
}
|
|
41
|
+
export function generateTraceId() {
|
|
42
|
+
return randomBytes(16).toString("hex");
|
|
43
|
+
}
|
|
44
|
+
export function generateSpanId() {
|
|
45
|
+
return randomBytes(8).toString("hex");
|
|
46
|
+
}
|
|
47
|
+
export function parseTraceStatus(value) {
|
|
48
|
+
const normalized = typeof value === "string" ? value.trim().toLowerCase() : "completed";
|
|
49
|
+
if (TRACE_STATUSES.includes(normalized)) {
|
|
50
|
+
return normalized;
|
|
51
|
+
}
|
|
52
|
+
throw new TracesValidationError("Invalid trace status. Use running, completed, failed, or timeout.");
|
|
53
|
+
}
|
|
54
|
+
function parseTraceSpanStatus(value, hasError) {
|
|
55
|
+
const normalized = typeof value === "string"
|
|
56
|
+
? value.trim().toLowerCase()
|
|
57
|
+
: hasError
|
|
58
|
+
? "error"
|
|
59
|
+
: "ok";
|
|
60
|
+
if (TRACE_SPAN_STATUSES.includes(normalized)) {
|
|
61
|
+
return normalized;
|
|
62
|
+
}
|
|
63
|
+
throw new TracesValidationError("Invalid span status. Use unset, ok, or error.");
|
|
64
|
+
}
|
|
65
|
+
function normalizeTraceId(value) {
|
|
66
|
+
const traceId = cleanOptionalString(value) ?? generateTraceId();
|
|
67
|
+
if (traceId.length > MAX_TRACE_ID_LENGTH) {
|
|
68
|
+
throw new TracesValidationError(`traceId must be ${MAX_TRACE_ID_LENGTH} characters or fewer.`);
|
|
69
|
+
}
|
|
70
|
+
return traceId;
|
|
71
|
+
}
|
|
72
|
+
function parseDate(value, label) {
|
|
73
|
+
if (value === undefined)
|
|
74
|
+
return undefined;
|
|
75
|
+
if (value === null) {
|
|
76
|
+
throw new TracesValidationError(`${label} must be a valid date.`);
|
|
77
|
+
}
|
|
78
|
+
const parsed = value instanceof Date ? value : new Date(value);
|
|
79
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
80
|
+
throw new TracesValidationError(`${label} must be a valid date.`);
|
|
81
|
+
}
|
|
82
|
+
return parsed;
|
|
83
|
+
}
|
|
84
|
+
function normalizeNonNegativeInteger(value, label) {
|
|
85
|
+
if (value === undefined || value === null)
|
|
86
|
+
return undefined;
|
|
87
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
88
|
+
throw new TracesValidationError(`${label} must be a finite number.`);
|
|
89
|
+
}
|
|
90
|
+
if (value < 0) {
|
|
91
|
+
throw new TracesValidationError(`${label} must be non-negative.`);
|
|
92
|
+
}
|
|
93
|
+
return Math.floor(value);
|
|
94
|
+
}
|
|
95
|
+
function sanitizeJsonValue(value, depth = 0) {
|
|
96
|
+
if (depth > 12)
|
|
97
|
+
return String(value);
|
|
98
|
+
if (value === null)
|
|
99
|
+
return null;
|
|
100
|
+
if (value instanceof Date)
|
|
101
|
+
return value.toISOString();
|
|
102
|
+
if (typeof value === "string" || typeof value === "boolean")
|
|
103
|
+
return value;
|
|
104
|
+
if (typeof value === "number") {
|
|
105
|
+
return Number.isFinite(value) ? value : undefined;
|
|
106
|
+
}
|
|
107
|
+
if (Array.isArray(value)) {
|
|
108
|
+
return value
|
|
109
|
+
.map((item) => sanitizeJsonValue(item, depth + 1))
|
|
110
|
+
.filter((item) => item !== undefined);
|
|
111
|
+
}
|
|
112
|
+
if (isRecord(value)) {
|
|
113
|
+
const result = {};
|
|
114
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
115
|
+
const sanitized = sanitizeJsonValue(nestedValue, depth + 1);
|
|
116
|
+
if (sanitized !== undefined) {
|
|
117
|
+
result[key] = sanitized;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
function normalizeAttributes(value) {
|
|
125
|
+
if (!value)
|
|
126
|
+
return {};
|
|
127
|
+
const attributes = {};
|
|
128
|
+
for (const [key, attributeValue] of Object.entries(value)) {
|
|
129
|
+
const sanitized = sanitizeJsonValue(attributeValue);
|
|
130
|
+
if (sanitized !== undefined) {
|
|
131
|
+
attributes[key] = sanitized;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return attributes;
|
|
135
|
+
}
|
|
136
|
+
function inferDurationMs(startTime, endTime) {
|
|
137
|
+
if (!startTime || !endTime)
|
|
138
|
+
return undefined;
|
|
139
|
+
const duration = endTime.getTime() - startTime.getTime();
|
|
140
|
+
return duration >= 0 ? duration : undefined;
|
|
141
|
+
}
|
|
142
|
+
function normalizeSpan(input, parentSpanId) {
|
|
143
|
+
if (!isRecord(input)) {
|
|
144
|
+
throw new TracesValidationError("Each span must be an object.");
|
|
145
|
+
}
|
|
146
|
+
const error = cleanOptionalString(input.error);
|
|
147
|
+
const spanId = cleanOptionalString(input.spanId) ?? generateSpanId();
|
|
148
|
+
const startTime = parseDate(input.startTime, "span.startTime");
|
|
149
|
+
const endTime = parseDate(input.endTime, "span.endTime");
|
|
150
|
+
const durationMs = normalizeNonNegativeInteger(input.durationMs, "span.durationMs") ??
|
|
151
|
+
inferDurationMs(startTime, endTime);
|
|
152
|
+
const children = Array.isArray(input.children)
|
|
153
|
+
? input.children.map((child) => normalizeSpan(child, spanId))
|
|
154
|
+
: undefined;
|
|
155
|
+
const normalized = {
|
|
156
|
+
spanId,
|
|
157
|
+
name: normalizeTraceSpanName(input.name),
|
|
158
|
+
kind: cleanOptionalString(input.kind) ?? "internal",
|
|
159
|
+
status: parseTraceSpanStatus(input.status, Boolean(error)),
|
|
160
|
+
attributes: normalizeAttributes(input.attributes),
|
|
161
|
+
};
|
|
162
|
+
const resolvedParentSpanId = cleanOptionalString(input.parentSpanId) ?? parentSpanId;
|
|
163
|
+
if (resolvedParentSpanId)
|
|
164
|
+
normalized.parentSpanId = resolvedParentSpanId;
|
|
165
|
+
if (startTime)
|
|
166
|
+
normalized.startTime = startTime.toISOString();
|
|
167
|
+
if (endTime)
|
|
168
|
+
normalized.endTime = endTime.toISOString();
|
|
169
|
+
if (durationMs !== undefined)
|
|
170
|
+
normalized.durationMs = durationMs;
|
|
171
|
+
if (input.input !== undefined) {
|
|
172
|
+
const sanitizedInput = sanitizeJsonValue(input.input);
|
|
173
|
+
if (sanitizedInput !== undefined)
|
|
174
|
+
normalized.input = sanitizedInput;
|
|
175
|
+
}
|
|
176
|
+
if (input.output !== undefined) {
|
|
177
|
+
const sanitizedOutput = sanitizeJsonValue(input.output);
|
|
178
|
+
if (sanitizedOutput !== undefined)
|
|
179
|
+
normalized.output = sanitizedOutput;
|
|
180
|
+
}
|
|
181
|
+
if (error)
|
|
182
|
+
normalized.error = error;
|
|
183
|
+
if (children && children.length > 0)
|
|
184
|
+
normalized.children = children;
|
|
185
|
+
return normalized;
|
|
186
|
+
}
|
|
187
|
+
function maxSpanDurationMs(spans) {
|
|
188
|
+
let max = 0;
|
|
189
|
+
for (const span of spans) {
|
|
190
|
+
if (typeof span.durationMs === "number" && span.durationMs > max) {
|
|
191
|
+
max = span.durationMs;
|
|
192
|
+
}
|
|
193
|
+
if (span.children) {
|
|
194
|
+
max = Math.max(max, maxSpanDurationMs(span.children));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return max;
|
|
198
|
+
}
|
|
199
|
+
export function countTraceSpans(spans) {
|
|
200
|
+
let count = 0;
|
|
201
|
+
for (const span of spans) {
|
|
202
|
+
count += 1;
|
|
203
|
+
if (span.children) {
|
|
204
|
+
count += countTraceSpans(span.children);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return count;
|
|
208
|
+
}
|
|
209
|
+
export function normalizeExecutionTraceInput(input) {
|
|
210
|
+
if (!isRecord(input)) {
|
|
211
|
+
throw new TracesValidationError("Trace payload must be an object.");
|
|
212
|
+
}
|
|
213
|
+
if (!Array.isArray(input.spans)) {
|
|
214
|
+
throw new TracesValidationError("spans must be an array.");
|
|
215
|
+
}
|
|
216
|
+
const spans = input.spans.map((span) => normalizeSpan(span));
|
|
217
|
+
const createdAt = parseDate(input.createdAt, "createdAt") ?? new Date();
|
|
218
|
+
const durationMs = normalizeNonNegativeInteger(input.durationMs, "durationMs") ??
|
|
219
|
+
maxSpanDurationMs(spans);
|
|
220
|
+
return {
|
|
221
|
+
traceId: normalizeTraceId(input.traceId),
|
|
222
|
+
workspaceId: cleanRequiredString(input.workspaceId, "workspaceId"),
|
|
223
|
+
agentId: cleanRequiredString(input.agentId, "agentId"),
|
|
224
|
+
spans,
|
|
225
|
+
durationMs,
|
|
226
|
+
status: parseTraceStatus(input.status),
|
|
227
|
+
createdAt: createdAt.toISOString(),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
export function parseTraceLimit(value) {
|
|
231
|
+
if (!value)
|
|
232
|
+
return DEFAULT_TRACE_LIST_LIMIT;
|
|
233
|
+
const parsed = Number(value);
|
|
234
|
+
if (!Number.isInteger(parsed) || parsed < 1) {
|
|
235
|
+
throw new TracesValidationError("limit must be a positive integer.");
|
|
236
|
+
}
|
|
237
|
+
return Math.min(parsed, MAX_TRACE_LIST_LIMIT);
|
|
238
|
+
}
|
|
239
|
+
export function parseTraceOffset(value) {
|
|
240
|
+
if (!value)
|
|
241
|
+
return 0;
|
|
242
|
+
const parsed = Number(value);
|
|
243
|
+
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
244
|
+
throw new TracesValidationError("offset must be a non-negative integer.");
|
|
245
|
+
}
|
|
246
|
+
return parsed;
|
|
247
|
+
}
|
|
248
|
+
export function normalizeTraceListQuery(params) {
|
|
249
|
+
return {
|
|
250
|
+
...(params.workspaceId
|
|
251
|
+
? { workspaceId: cleanRequiredString(params.workspaceId, "workspaceId") }
|
|
252
|
+
: {}),
|
|
253
|
+
...(params.agentId
|
|
254
|
+
? { agentId: cleanRequiredString(params.agentId, "agentId") }
|
|
255
|
+
: {}),
|
|
256
|
+
...(params.status ? { status: parseTraceStatus(params.status) } : {}),
|
|
257
|
+
limit: parseTraceLimit(params.limit),
|
|
258
|
+
offset: parseTraceOffset(params.offset),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../../src/services/traces/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAIN,mBAAmB,EACnB,cAAc,GAMd,MAAM,YAAY,CAAC;AAEpB,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACrC,CAAC;CACD;AAED,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc,EAAE,KAAa;IACzD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,qBAAqB,CAAC,GAAG,KAAK,eAAe,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,MAAM,IAAI,qBAAqB,CAAC,GAAG,KAAK,eAAe,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACpD,MAAM,UAAU,GAA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MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrE,KAAK,EAAE,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC;QACpC,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC;KACvC,CAAC;AACH,CAAC","sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport {\n\ttype ExecutionTrace,\n\ttype ExecutionTraceInput,\n\ttype ExecutionTraceSpan,\n\tTRACE_SPAN_STATUSES,\n\tTRACE_STATUSES,\n\ttype TraceJsonValue,\n\ttype TraceListQuery,\n\ttype TraceSpanInput,\n\ttype TraceSpanStatus,\n\ttype TraceStatus,\n} from \"./types.js\";\n\nconst MAX_TRACE_ID_LENGTH = 64;\nconst DEFAULT_TRACE_LIST_LIMIT = 50;\nconst MAX_TRACE_LIST_LIMIT = 100;\n\nexport class TracesValidationError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"TracesValidationError\";\n\t}\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction cleanRequiredString(value: unknown, label: string): string {\n\tif (typeof value !== \"string\") {\n\t\tthrow new TracesValidationError(`${label} is required.`);\n\t}\n\tconst trimmed = value.trim();\n\tif (!trimmed) {\n\t\tthrow new TracesValidationError(`${label} is required.`);\n\t}\n\treturn trimmed;\n}\n\nexport function normalizeTraceSpanName(value: unknown): string {\n\tconst normalized = cleanRequiredString(value, \"span.name\")\n\t\t.replace(/[\\\\/\\s]+/gu, \".\")\n\t\t.replace(/\\.+/gu, \".\")\n\t\t.replace(/^\\.+|\\.+$/gu, \"\");\n\tif (!normalized) {\n\t\tthrow new TracesValidationError(\"span.name is required.\");\n\t}\n\treturn normalized;\n}\n\nfunction cleanOptionalString(value: unknown): string | undefined {\n\tif (typeof value !== \"string\") return undefined;\n\tconst trimmed = value.trim();\n\treturn trimmed ? trimmed : undefined;\n}\n\nexport function generateTraceId(): string {\n\treturn randomBytes(16).toString(\"hex\");\n}\n\nexport function generateSpanId(): string {\n\treturn randomBytes(8).toString(\"hex\");\n}\n\nexport function parseTraceStatus(value: unknown): TraceStatus {\n\tconst normalized =\n\t\ttypeof value === \"string\" ? value.trim().toLowerCase() : \"completed\";\n\tif (TRACE_STATUSES.includes(normalized as TraceStatus)) {\n\t\treturn normalized as TraceStatus;\n\t}\n\tthrow new TracesValidationError(\n\t\t\"Invalid trace status. Use running, completed, failed, or timeout.\",\n\t);\n}\n\nfunction parseTraceSpanStatus(\n\tvalue: unknown,\n\thasError: boolean,\n): TraceSpanStatus {\n\tconst normalized =\n\t\ttypeof value === \"string\"\n\t\t\t? value.trim().toLowerCase()\n\t\t\t: hasError\n\t\t\t\t? \"error\"\n\t\t\t\t: \"ok\";\n\tif (TRACE_SPAN_STATUSES.includes(normalized as TraceSpanStatus)) {\n\t\treturn normalized as TraceSpanStatus;\n\t}\n\tthrow new TracesValidationError(\n\t\t\"Invalid span status. Use unset, ok, or error.\",\n\t);\n}\n\nfunction normalizeTraceId(value: unknown): string {\n\tconst traceId = cleanOptionalString(value) ?? generateTraceId();\n\tif (traceId.length > MAX_TRACE_ID_LENGTH) {\n\t\tthrow new TracesValidationError(\n\t\t\t`traceId must be ${MAX_TRACE_ID_LENGTH} characters or fewer.`,\n\t\t);\n\t}\n\treturn traceId;\n}\n\nfunction parseDate(\n\tvalue: Date | string | null | undefined,\n\tlabel: string,\n): Date | undefined {\n\tif (value === undefined) return undefined;\n\tif (value === null) {\n\t\tthrow new TracesValidationError(`${label} must be a valid date.`);\n\t}\n\tconst parsed = value instanceof Date ? value : new Date(value);\n\tif (Number.isNaN(parsed.getTime())) {\n\t\tthrow new TracesValidationError(`${label} must be a valid date.`);\n\t}\n\treturn parsed;\n}\n\nfunction normalizeNonNegativeInteger(\n\tvalue: unknown,\n\tlabel: string,\n): number | undefined {\n\tif (value === undefined || value === null) return undefined;\n\tif (typeof value !== \"number\" || !Number.isFinite(value)) {\n\t\tthrow new TracesValidationError(`${label} must be a finite number.`);\n\t}\n\tif (value < 0) {\n\t\tthrow new TracesValidationError(`${label} must be non-negative.`);\n\t}\n\treturn Math.floor(value);\n}\n\nfunction sanitizeJsonValue(\n\tvalue: unknown,\n\tdepth = 0,\n): TraceJsonValue | undefined {\n\tif (depth > 12) return String(value);\n\tif (value === null) return null;\n\tif (value instanceof Date) return value.toISOString();\n\tif (typeof value === \"string\" || typeof value === \"boolean\") return value;\n\tif (typeof value === \"number\") {\n\t\treturn Number.isFinite(value) ? value : undefined;\n\t}\n\tif (Array.isArray(value)) {\n\t\treturn value\n\t\t\t.map((item) => sanitizeJsonValue(item, depth + 1))\n\t\t\t.filter((item): item is TraceJsonValue => item !== undefined);\n\t}\n\tif (isRecord(value)) {\n\t\tconst result: Record<string, TraceJsonValue> = {};\n\t\tfor (const [key, nestedValue] of Object.entries(value)) {\n\t\t\tconst sanitized = sanitizeJsonValue(nestedValue, depth + 1);\n\t\t\tif (sanitized !== undefined) {\n\t\t\t\tresult[key] = sanitized;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\treturn undefined;\n}\n\nfunction normalizeAttributes(\n\tvalue: Record<string, unknown> | undefined,\n): Record<string, TraceJsonValue> {\n\tif (!value) return {};\n\tconst attributes: Record<string, TraceJsonValue> = {};\n\tfor (const [key, attributeValue] of Object.entries(value)) {\n\t\tconst sanitized = sanitizeJsonValue(attributeValue);\n\t\tif (sanitized !== undefined) {\n\t\t\tattributes[key] = sanitized;\n\t\t}\n\t}\n\treturn attributes;\n}\n\nfunction inferDurationMs(startTime?: Date, endTime?: Date): number | undefined {\n\tif (!startTime || !endTime) return undefined;\n\tconst duration = endTime.getTime() - startTime.getTime();\n\treturn duration >= 0 ? duration : undefined;\n}\n\nfunction normalizeSpan(\n\tinput: TraceSpanInput,\n\tparentSpanId?: string,\n): ExecutionTraceSpan {\n\tif (!isRecord(input)) {\n\t\tthrow new TracesValidationError(\"Each span must be an object.\");\n\t}\n\tconst error = cleanOptionalString(input.error);\n\tconst spanId = cleanOptionalString(input.spanId) ?? generateSpanId();\n\tconst startTime = parseDate(input.startTime, \"span.startTime\");\n\tconst endTime = parseDate(input.endTime, \"span.endTime\");\n\tconst durationMs =\n\t\tnormalizeNonNegativeInteger(input.durationMs, \"span.durationMs\") ??\n\t\tinferDurationMs(startTime, endTime);\n\n\tconst children = Array.isArray(input.children)\n\t\t? input.children.map((child) => normalizeSpan(child, spanId))\n\t\t: undefined;\n\n\tconst normalized: ExecutionTraceSpan = {\n\t\tspanId,\n\t\tname: normalizeTraceSpanName(input.name),\n\t\tkind: cleanOptionalString(input.kind) ?? \"internal\",\n\t\tstatus: parseTraceSpanStatus(input.status, Boolean(error)),\n\t\tattributes: normalizeAttributes(input.attributes),\n\t};\n\tconst resolvedParentSpanId =\n\t\tcleanOptionalString(input.parentSpanId) ?? parentSpanId;\n\tif (resolvedParentSpanId) normalized.parentSpanId = resolvedParentSpanId;\n\tif (startTime) normalized.startTime = startTime.toISOString();\n\tif (endTime) normalized.endTime = endTime.toISOString();\n\tif (durationMs !== undefined) normalized.durationMs = durationMs;\n\tif (input.input !== undefined) {\n\t\tconst sanitizedInput = sanitizeJsonValue(input.input);\n\t\tif (sanitizedInput !== undefined) normalized.input = sanitizedInput;\n\t}\n\tif (input.output !== undefined) {\n\t\tconst sanitizedOutput = sanitizeJsonValue(input.output);\n\t\tif (sanitizedOutput !== undefined) normalized.output = sanitizedOutput;\n\t}\n\tif (error) normalized.error = error;\n\tif (children && children.length > 0) normalized.children = children;\n\treturn normalized;\n}\n\nfunction maxSpanDurationMs(spans: ExecutionTraceSpan[]): number {\n\tlet max = 0;\n\tfor (const span of spans) {\n\t\tif (typeof span.durationMs === \"number\" && span.durationMs > max) {\n\t\t\tmax = span.durationMs;\n\t\t}\n\t\tif (span.children) {\n\t\t\tmax = Math.max(max, maxSpanDurationMs(span.children));\n\t\t}\n\t}\n\treturn max;\n}\n\nexport function countTraceSpans(spans: ExecutionTraceSpan[]): number {\n\tlet count = 0;\n\tfor (const span of spans) {\n\t\tcount += 1;\n\t\tif (span.children) {\n\t\t\tcount += countTraceSpans(span.children);\n\t\t}\n\t}\n\treturn count;\n}\n\nexport function normalizeExecutionTraceInput(\n\tinput: ExecutionTraceInput,\n): ExecutionTrace {\n\tif (!isRecord(input)) {\n\t\tthrow new TracesValidationError(\"Trace payload must be an object.\");\n\t}\n\tif (!Array.isArray(input.spans)) {\n\t\tthrow new TracesValidationError(\"spans must be an array.\");\n\t}\n\tconst spans = input.spans.map((span) => normalizeSpan(span));\n\tconst createdAt = parseDate(input.createdAt, \"createdAt\") ?? new Date();\n\tconst durationMs =\n\t\tnormalizeNonNegativeInteger(input.durationMs, \"durationMs\") ??\n\t\tmaxSpanDurationMs(spans);\n\n\treturn {\n\t\ttraceId: normalizeTraceId(input.traceId),\n\t\tworkspaceId: cleanRequiredString(input.workspaceId, \"workspaceId\"),\n\t\tagentId: cleanRequiredString(input.agentId, \"agentId\"),\n\t\tspans,\n\t\tdurationMs,\n\t\tstatus: parseTraceStatus(input.status),\n\t\tcreatedAt: createdAt.toISOString(),\n\t};\n}\n\nexport function parseTraceLimit(value: string | null | undefined): number {\n\tif (!value) return DEFAULT_TRACE_LIST_LIMIT;\n\tconst parsed = Number(value);\n\tif (!Number.isInteger(parsed) || parsed < 1) {\n\t\tthrow new TracesValidationError(\"limit must be a positive integer.\");\n\t}\n\treturn Math.min(parsed, MAX_TRACE_LIST_LIMIT);\n}\n\nexport function parseTraceOffset(value: string | null | undefined): number {\n\tif (!value) return 0;\n\tconst parsed = Number(value);\n\tif (!Number.isInteger(parsed) || parsed < 0) {\n\t\tthrow new TracesValidationError(\"offset must be a non-negative integer.\");\n\t}\n\treturn parsed;\n}\n\nexport function normalizeTraceListQuery(params: {\n\tworkspaceId?: string;\n\tagentId?: string;\n\tstatus?: string;\n\tlimit?: string | null;\n\toffset?: string | null;\n}): TraceListQuery {\n\treturn {\n\t\t...(params.workspaceId\n\t\t\t? { workspaceId: cleanRequiredString(params.workspaceId, \"workspaceId\") }\n\t\t\t: {}),\n\t\t...(params.agentId\n\t\t\t? { agentId: cleanRequiredString(params.agentId, \"agentId\") }\n\t\t\t: {}),\n\t\t...(params.status ? { status: parseTraceStatus(params.status) } : {}),\n\t\tlimit: parseTraceLimit(params.limit),\n\t\toffset: parseTraceOffset(params.offset),\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../../../src/services/traces/otel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,cAAc,EAKd,wBAAwB,EAExB,MAAM,YAAY,CAAC;AAoKpB,wBAAgB,0BAA0B,CACzC,KAAK,EAAE,cAAc,GACnB,wBAAwB,CA0B1B"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { normalizeTraceSpanName } from "./normalize.js";
|
|
3
|
+
const OTEL_SCOPE_NAME = "maestro.traces";
|
|
4
|
+
const OTEL_SCOPE_VERSION = "1.0.0";
|
|
5
|
+
function hashHex(value, length) {
|
|
6
|
+
return createHash("sha256").update(value).digest("hex").slice(0, length);
|
|
7
|
+
}
|
|
8
|
+
function toOtelTraceId(traceId) {
|
|
9
|
+
const normalized = traceId.trim().toLowerCase();
|
|
10
|
+
if (/^[0-9a-f]{32}$/.test(normalized))
|
|
11
|
+
return normalized;
|
|
12
|
+
return hashHex(traceId, 32);
|
|
13
|
+
}
|
|
14
|
+
function toOtelSpanId(spanId) {
|
|
15
|
+
const normalized = spanId.trim().toLowerCase();
|
|
16
|
+
if (/^[0-9a-f]{16}$/.test(normalized))
|
|
17
|
+
return normalized;
|
|
18
|
+
return hashHex(spanId, 16);
|
|
19
|
+
}
|
|
20
|
+
function unixNanoFromIso(value) {
|
|
21
|
+
const millis = Date.parse(value);
|
|
22
|
+
if (Number.isNaN(millis))
|
|
23
|
+
return "0";
|
|
24
|
+
return (BigInt(millis) * 1000000n).toString();
|
|
25
|
+
}
|
|
26
|
+
function addDurationToIso(startTime, durationMs) {
|
|
27
|
+
const millis = Date.parse(startTime);
|
|
28
|
+
if (Number.isNaN(millis))
|
|
29
|
+
return startTime;
|
|
30
|
+
return new Date(millis + durationMs).toISOString();
|
|
31
|
+
}
|
|
32
|
+
function spanStartTime(trace, span) {
|
|
33
|
+
return span.startTime ?? trace.createdAt;
|
|
34
|
+
}
|
|
35
|
+
function spanEndTime(trace, span) {
|
|
36
|
+
if (span.endTime)
|
|
37
|
+
return span.endTime;
|
|
38
|
+
if (span.durationMs !== undefined) {
|
|
39
|
+
return addDurationToIso(spanStartTime(trace, span), span.durationMs);
|
|
40
|
+
}
|
|
41
|
+
return spanStartTime(trace, span);
|
|
42
|
+
}
|
|
43
|
+
function toOtelAnyValue(value) {
|
|
44
|
+
if (typeof value === "string")
|
|
45
|
+
return { stringValue: value };
|
|
46
|
+
if (typeof value === "boolean")
|
|
47
|
+
return { boolValue: value };
|
|
48
|
+
if (typeof value === "number") {
|
|
49
|
+
if (Number.isInteger(value))
|
|
50
|
+
return { intValue: String(value) };
|
|
51
|
+
return { doubleValue: value };
|
|
52
|
+
}
|
|
53
|
+
if (value === null)
|
|
54
|
+
return { stringValue: "null" };
|
|
55
|
+
if (Array.isArray(value)) {
|
|
56
|
+
return { arrayValue: { values: value.map(toOtelAnyValue) } };
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
kvlistValue: {
|
|
60
|
+
values: Object.entries(value).map(([key, nestedValue]) => ({
|
|
61
|
+
key,
|
|
62
|
+
value: toOtelAnyValue(nestedValue),
|
|
63
|
+
})),
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function attribute(key, value) {
|
|
68
|
+
return {
|
|
69
|
+
key,
|
|
70
|
+
value: toOtelAnyValue(value),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function spanKind(kind) {
|
|
74
|
+
switch (kind) {
|
|
75
|
+
case "llm_inference":
|
|
76
|
+
case "tool_call":
|
|
77
|
+
return "SPAN_KIND_CLIENT";
|
|
78
|
+
case "delegation":
|
|
79
|
+
return "SPAN_KIND_PRODUCER";
|
|
80
|
+
default:
|
|
81
|
+
return "SPAN_KIND_INTERNAL";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function statusCode(status) {
|
|
85
|
+
if (status === "ok")
|
|
86
|
+
return "STATUS_CODE_OK";
|
|
87
|
+
if (status === "error")
|
|
88
|
+
return "STATUS_CODE_ERROR";
|
|
89
|
+
return "STATUS_CODE_UNSET";
|
|
90
|
+
}
|
|
91
|
+
function spanEvents(trace, span) {
|
|
92
|
+
const events = [];
|
|
93
|
+
const timeUnixNano = unixNanoFromIso(spanStartTime(trace, span));
|
|
94
|
+
if (span.input !== undefined) {
|
|
95
|
+
events.push({
|
|
96
|
+
name: "input",
|
|
97
|
+
timeUnixNano,
|
|
98
|
+
attributes: [attribute("payload", JSON.stringify(span.input))],
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (span.output !== undefined) {
|
|
102
|
+
events.push({
|
|
103
|
+
name: "output",
|
|
104
|
+
timeUnixNano: unixNanoFromIso(spanEndTime(trace, span)),
|
|
105
|
+
attributes: [attribute("payload", JSON.stringify(span.output))],
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return events.length > 0 ? events : undefined;
|
|
109
|
+
}
|
|
110
|
+
function flattenSpans(spans) {
|
|
111
|
+
const flattened = [];
|
|
112
|
+
for (const span of spans) {
|
|
113
|
+
flattened.push(span);
|
|
114
|
+
if (span.children) {
|
|
115
|
+
flattened.push(...flattenSpans(span.children));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return flattened;
|
|
119
|
+
}
|
|
120
|
+
function toOtelSpan(trace, span) {
|
|
121
|
+
const attributes = [
|
|
122
|
+
attribute("maestro.span_kind", span.kind),
|
|
123
|
+
attribute("maestro.trace_status", trace.status),
|
|
124
|
+
attribute("maestro.duration_ms", span.durationMs ?? 0),
|
|
125
|
+
...Object.entries(span.attributes).map(([key, value]) => attribute(key, value)),
|
|
126
|
+
];
|
|
127
|
+
const otelSpan = {
|
|
128
|
+
traceId: toOtelTraceId(trace.traceId),
|
|
129
|
+
spanId: toOtelSpanId(span.spanId),
|
|
130
|
+
name: normalizeTraceSpanName(span.name),
|
|
131
|
+
kind: spanKind(span.kind),
|
|
132
|
+
startTimeUnixNano: unixNanoFromIso(spanStartTime(trace, span)),
|
|
133
|
+
endTimeUnixNano: unixNanoFromIso(spanEndTime(trace, span)),
|
|
134
|
+
attributes,
|
|
135
|
+
status: {
|
|
136
|
+
code: statusCode(span.status),
|
|
137
|
+
...(span.error ? { message: span.error } : {}),
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
if (span.parentSpanId) {
|
|
141
|
+
otelSpan.parentSpanId = toOtelSpanId(span.parentSpanId);
|
|
142
|
+
}
|
|
143
|
+
const events = spanEvents(trace, span);
|
|
144
|
+
if (events)
|
|
145
|
+
otelSpan.events = events;
|
|
146
|
+
return otelSpan;
|
|
147
|
+
}
|
|
148
|
+
export function exportTraceToOpenTelemetry(trace) {
|
|
149
|
+
return {
|
|
150
|
+
resourceSpans: [
|
|
151
|
+
{
|
|
152
|
+
resource: {
|
|
153
|
+
attributes: [
|
|
154
|
+
attribute("service.name", "maestro"),
|
|
155
|
+
attribute("maestro.workspace_id", trace.workspaceId),
|
|
156
|
+
attribute("maestro.agent_id", trace.agentId),
|
|
157
|
+
attribute("maestro.trace_id", trace.traceId),
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
scopeSpans: [
|
|
161
|
+
{
|
|
162
|
+
scope: {
|
|
163
|
+
name: OTEL_SCOPE_NAME,
|
|
164
|
+
version: OTEL_SCOPE_VERSION,
|
|
165
|
+
},
|
|
166
|
+
spans: flattenSpans(trace.spans).map((span) => toOtelSpan(trace, span)),
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
],
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Q,EAAE;oBACT,UAAU,EAAE;wBACX,SAAS,CAAC,cAAc,EAAE,SAAS,CAAC;wBACpC,SAAS,CAAC,sBAAsB,EAAE,KAAK,CAAC,WAAW,CAAC;wBACpD,SAAS,CAAC,kBAAkB,EAAE,KAAK,CAAC,OAAO,CAAC;wBAC5C,SAAS,CAAC,kBAAkB,EAAE,KAAK,CAAC,OAAO,CAAC;qBAC5C;iBACD;gBACD,UAAU,EAAE;oBACX;wBACC,KAAK,EAAE;4BACN,IAAI,EAAE,eAAe;4BACrB,OAAO,EAAE,kBAAkB;yBAC3B;wBACD,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAC7C,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CACvB;qBACD;iBACD;aACD;SACD;KACD,CAAC;AACH,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { normalizeTraceSpanName } from \"./normalize.js\";\nimport type {\n\tExecutionTrace,\n\tExecutionTraceSpan,\n\tOpenTelemetryAnyValue,\n\tOpenTelemetryKeyValue,\n\tOpenTelemetrySpan,\n\tOpenTelemetryTraceExport,\n\tTraceJsonValue,\n} from \"./types.js\";\n\nconst OTEL_SCOPE_NAME = \"maestro.traces\";\nconst OTEL_SCOPE_VERSION = \"1.0.0\";\n\nfunction hashHex(value: string, length: number): string {\n\treturn createHash(\"sha256\").update(value).digest(\"hex\").slice(0, length);\n}\n\nfunction toOtelTraceId(traceId: string): string {\n\tconst normalized = traceId.trim().toLowerCase();\n\tif (/^[0-9a-f]{32}$/.test(normalized)) return normalized;\n\treturn hashHex(traceId, 32);\n}\n\nfunction toOtelSpanId(spanId: string): string {\n\tconst normalized = spanId.trim().toLowerCase();\n\tif (/^[0-9a-f]{16}$/.test(normalized)) return normalized;\n\treturn hashHex(spanId, 16);\n}\n\nfunction unixNanoFromIso(value: string): string {\n\tconst millis = Date.parse(value);\n\tif (Number.isNaN(millis)) return \"0\";\n\treturn (BigInt(millis) * 1_000_000n).toString();\n}\n\nfunction addDurationToIso(startTime: string, durationMs: number): string {\n\tconst millis = Date.parse(startTime);\n\tif (Number.isNaN(millis)) return startTime;\n\treturn new Date(millis + durationMs).toISOString();\n}\n\nfunction spanStartTime(\n\ttrace: ExecutionTrace,\n\tspan: ExecutionTraceSpan,\n): string {\n\treturn span.startTime ?? trace.createdAt;\n}\n\nfunction spanEndTime(trace: ExecutionTrace, span: ExecutionTraceSpan): string {\n\tif (span.endTime) return span.endTime;\n\tif (span.durationMs !== undefined) {\n\t\treturn addDurationToIso(spanStartTime(trace, span), span.durationMs);\n\t}\n\treturn spanStartTime(trace, span);\n}\n\nfunction toOtelAnyValue(value: TraceJsonValue): OpenTelemetryAnyValue {\n\tif (typeof value === \"string\") return { stringValue: value };\n\tif (typeof value === \"boolean\") return { boolValue: value };\n\tif (typeof value === \"number\") {\n\t\tif (Number.isInteger(value)) return { intValue: String(value) };\n\t\treturn { doubleValue: value };\n\t}\n\tif (value === null) return { stringValue: \"null\" };\n\tif (Array.isArray(value)) {\n\t\treturn { arrayValue: { values: value.map(toOtelAnyValue) } };\n\t}\n\treturn {\n\t\tkvlistValue: {\n\t\t\tvalues: Object.entries(value).map(([key, nestedValue]) => ({\n\t\t\t\tkey,\n\t\t\t\tvalue: toOtelAnyValue(nestedValue),\n\t\t\t})),\n\t\t},\n\t};\n}\n\nfunction attribute(key: string, value: TraceJsonValue): OpenTelemetryKeyValue {\n\treturn {\n\t\tkey,\n\t\tvalue: toOtelAnyValue(value),\n\t};\n}\n\nfunction spanKind(kind: string): string {\n\tswitch (kind) {\n\t\tcase \"llm_inference\":\n\t\tcase \"tool_call\":\n\t\t\treturn \"SPAN_KIND_CLIENT\";\n\t\tcase \"delegation\":\n\t\t\treturn \"SPAN_KIND_PRODUCER\";\n\t\tdefault:\n\t\t\treturn \"SPAN_KIND_INTERNAL\";\n\t}\n}\n\nfunction statusCode(\n\tstatus: ExecutionTraceSpan[\"status\"],\n): OpenTelemetrySpan[\"status\"][\"code\"] {\n\tif (status === \"ok\") return \"STATUS_CODE_OK\";\n\tif (status === \"error\") return \"STATUS_CODE_ERROR\";\n\treturn \"STATUS_CODE_UNSET\";\n}\n\nfunction spanEvents(\n\ttrace: ExecutionTrace,\n\tspan: ExecutionTraceSpan,\n): OpenTelemetrySpan[\"events\"] {\n\tconst events: OpenTelemetrySpan[\"events\"] = [];\n\tconst timeUnixNano = unixNanoFromIso(spanStartTime(trace, span));\n\tif (span.input !== undefined) {\n\t\tevents.push({\n\t\t\tname: \"input\",\n\t\t\ttimeUnixNano,\n\t\t\tattributes: [attribute(\"payload\", JSON.stringify(span.input))],\n\t\t});\n\t}\n\tif (span.output !== undefined) {\n\t\tevents.push({\n\t\t\tname: \"output\",\n\t\t\ttimeUnixNano: unixNanoFromIso(spanEndTime(trace, span)),\n\t\t\tattributes: [attribute(\"payload\", JSON.stringify(span.output))],\n\t\t});\n\t}\n\treturn events.length > 0 ? events : undefined;\n}\n\nfunction flattenSpans(spans: ExecutionTraceSpan[]): ExecutionTraceSpan[] {\n\tconst flattened: ExecutionTraceSpan[] = [];\n\tfor (const span of spans) {\n\t\tflattened.push(span);\n\t\tif (span.children) {\n\t\t\tflattened.push(...flattenSpans(span.children));\n\t\t}\n\t}\n\treturn flattened;\n}\n\nfunction toOtelSpan(\n\ttrace: ExecutionTrace,\n\tspan: ExecutionTraceSpan,\n): OpenTelemetrySpan {\n\tconst attributes = [\n\t\tattribute(\"maestro.span_kind\", span.kind),\n\t\tattribute(\"maestro.trace_status\", trace.status),\n\t\tattribute(\"maestro.duration_ms\", span.durationMs ?? 0),\n\t\t...Object.entries(span.attributes).map(([key, value]) =>\n\t\t\tattribute(key, value),\n\t\t),\n\t];\n\n\tconst otelSpan: OpenTelemetrySpan = {\n\t\ttraceId: toOtelTraceId(trace.traceId),\n\t\tspanId: toOtelSpanId(span.spanId),\n\t\tname: normalizeTraceSpanName(span.name),\n\t\tkind: spanKind(span.kind),\n\t\tstartTimeUnixNano: unixNanoFromIso(spanStartTime(trace, span)),\n\t\tendTimeUnixNano: unixNanoFromIso(spanEndTime(trace, span)),\n\t\tattributes,\n\t\tstatus: {\n\t\t\tcode: statusCode(span.status),\n\t\t\t...(span.error ? { message: span.error } : {}),\n\t\t},\n\t};\n\tif (span.parentSpanId) {\n\t\totelSpan.parentSpanId = toOtelSpanId(span.parentSpanId);\n\t}\n\tconst events = spanEvents(trace, span);\n\tif (events) otelSpan.events = events;\n\treturn otelSpan;\n}\n\nexport function exportTraceToOpenTelemetry(\n\ttrace: ExecutionTrace,\n): OpenTelemetryTraceExport {\n\treturn {\n\t\tresourceSpans: [\n\t\t\t{\n\t\t\t\tresource: {\n\t\t\t\t\tattributes: [\n\t\t\t\t\t\tattribute(\"service.name\", \"maestro\"),\n\t\t\t\t\t\tattribute(\"maestro.workspace_id\", trace.workspaceId),\n\t\t\t\t\t\tattribute(\"maestro.agent_id\", trace.agentId),\n\t\t\t\t\t\tattribute(\"maestro.trace_id\", trace.traceId),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tscopeSpans: [\n\t\t\t\t\t{\n\t\t\t\t\t\tscope: {\n\t\t\t\t\t\t\tname: OTEL_SCOPE_NAME,\n\t\t\t\t\t\t\tversion: OTEL_SCOPE_VERSION,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tspans: flattenSpans(trace.spans).map((span) =>\n\t\t\t\t\t\t\ttoOtelSpan(trace, span),\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type DbClient } from "../../db/client.js";
|
|
2
|
+
import type { ExecutionTrace, ExecutionTraceInput, ExecutionTraceSummary, TraceListQuery, TraceListResult } from "./types.js";
|
|
3
|
+
export declare class TracesUnavailableError extends Error {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
6
|
+
export declare class TracesService {
|
|
7
|
+
private readonly getDatabase;
|
|
8
|
+
private readonly databaseConfigured;
|
|
9
|
+
constructor(getDatabase?: () => DbClient, databaseConfigured?: () => boolean);
|
|
10
|
+
recordTrace(input: ExecutionTraceInput): Promise<ExecutionTrace>;
|
|
11
|
+
getTrace(traceId: string): Promise<ExecutionTrace | null>;
|
|
12
|
+
listTraces(query: TraceListQuery): Promise<TraceListResult>;
|
|
13
|
+
summarizeTrace(trace: ExecutionTrace): ExecutionTraceSummary;
|
|
14
|
+
}
|
|
15
|
+
export declare function getTracesService(): TracesService;
|
|
16
|
+
export declare function setTracesServiceForTest(service: TracesService | null): void;
|
|
17
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/services/traces/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAA+B,MAAM,oBAAoB,CAAC;AAQhF,OAAO,KAAK,EACX,cAAc,EACd,mBAAmB,EAEnB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,MAAM,YAAY,CAAC;AAMpB,qBAAa,sBAAuB,SAAQ,KAAK;;CAKhD;AAsED,qBAAa,aAAa;IAExB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;gBADlB,WAAW,GAAE,MAAM,QAAgB,EACnC,kBAAkB,GAAE,MAAM,OAA8B;IAGpE,WAAW,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IA8ChE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAiBzD,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAuCjE,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,qBAAqB;CAW5D;AAID,wBAAgB,gBAAgB,IAAI,aAAa,CAGhD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAE3E"}
|