takt 0.43.0 → 0.45.0
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 +5 -2
- package/builtins/en/config.yaml +3 -1
- package/builtins/en/workflows/backend-cqrs.yaml +21 -0
- package/builtins/en/workflows/backend.yaml +21 -0
- package/builtins/en/workflows/dual-cqrs.yaml +21 -0
- package/builtins/en/workflows/dual.yaml +21 -0
- package/builtins/en/workflows/frontend-maintenance.yaml +21 -0
- package/builtins/en/workflows/frontend.yaml +21 -0
- package/builtins/en/workflows/review-backend-cqrs.yaml +22 -0
- package/builtins/en/workflows/review-backend.yaml +22 -0
- package/builtins/en/workflows/review-default.yaml +27 -2
- package/builtins/en/workflows/review-dual-cqrs.yaml +22 -0
- package/builtins/en/workflows/review-dual.yaml +22 -0
- package/builtins/en/workflows/review-fix-backend-cqrs.yaml +22 -0
- package/builtins/en/workflows/review-fix-backend.yaml +22 -0
- package/builtins/en/workflows/review-fix-default.yaml +23 -1
- package/builtins/en/workflows/review-fix-dual-cqrs.yaml +22 -0
- package/builtins/en/workflows/review-fix-dual.yaml +22 -0
- package/builtins/en/workflows/review-fix-frontend.yaml +22 -0
- package/builtins/en/workflows/review-fix-takt-default.yaml +23 -1
- package/builtins/en/workflows/review-frontend.yaml +22 -0
- package/builtins/en/workflows/review-takt-default.yaml +27 -2
- package/builtins/en/workflows/terraform.yaml +23 -2
- package/builtins/ja/config.yaml +3 -1
- package/builtins/ja/workflows/backend-cqrs.yaml +21 -0
- package/builtins/ja/workflows/backend.yaml +21 -0
- package/builtins/ja/workflows/dual-cqrs.yaml +21 -0
- package/builtins/ja/workflows/dual.yaml +21 -0
- package/builtins/ja/workflows/frontend-maintenance.yaml +21 -0
- package/builtins/ja/workflows/frontend.yaml +21 -0
- package/builtins/ja/workflows/review-backend-cqrs.yaml +22 -0
- package/builtins/ja/workflows/review-backend.yaml +22 -0
- package/builtins/ja/workflows/review-default.yaml +26 -2
- package/builtins/ja/workflows/review-dual-cqrs.yaml +22 -0
- package/builtins/ja/workflows/review-dual.yaml +22 -0
- package/builtins/ja/workflows/review-fix-backend-cqrs.yaml +22 -0
- package/builtins/ja/workflows/review-fix-backend.yaml +22 -0
- package/builtins/ja/workflows/review-fix-default.yaml +23 -1
- package/builtins/ja/workflows/review-fix-dual-cqrs.yaml +22 -0
- package/builtins/ja/workflows/review-fix-dual.yaml +22 -0
- package/builtins/ja/workflows/review-fix-frontend.yaml +22 -0
- package/builtins/ja/workflows/review-fix-takt-default.yaml +23 -1
- package/builtins/ja/workflows/review-frontend.yaml +22 -0
- package/builtins/ja/workflows/review-takt-default.yaml +26 -2
- package/builtins/ja/workflows/terraform.yaml +23 -2
- package/dist/agents/judge-status-usecase.d.ts +17 -7
- package/dist/agents/judge-status-usecase.d.ts.map +1 -1
- package/dist/agents/judge-status-usecase.js +25 -13
- package/dist/agents/judge-status-usecase.js.map +1 -1
- package/dist/agents/structured-caller/prompt-based-structured-caller.d.ts.map +1 -1
- package/dist/agents/structured-caller/prompt-based-structured-caller.js +7 -14
- package/dist/agents/structured-caller/prompt-based-structured-caller.js.map +1 -1
- package/dist/app/cli/program.js +1 -1
- package/dist/app/cli/program.js.map +1 -1
- package/dist/commands/analyze-usage.d.ts +26 -0
- package/dist/commands/analyze-usage.d.ts.map +1 -0
- package/dist/commands/analyze-usage.js +305 -0
- package/dist/commands/analyze-usage.js.map +1 -0
- package/dist/commands/repertoire/add.d.ts.map +1 -1
- package/dist/commands/repertoire/add.js +7 -11
- package/dist/commands/repertoire/add.js.map +1 -1
- package/dist/core/logging/contracts.d.ts +1 -0
- package/dist/core/logging/contracts.d.ts.map +1 -1
- package/dist/core/logging/contracts.js +1 -0
- package/dist/core/logging/contracts.js.map +1 -1
- package/dist/core/logging/phaseUsageEvent.d.ts +40 -0
- package/dist/core/logging/phaseUsageEvent.d.ts.map +1 -0
- package/dist/core/logging/phaseUsageEvent.js +195 -0
- package/dist/core/logging/phaseUsageEvent.js.map +1 -0
- package/dist/core/logging/providerEvent.d.ts +4 -0
- package/dist/core/logging/providerEvent.d.ts.map +1 -1
- package/dist/core/logging/providerEvent.js +31 -27
- package/dist/core/logging/providerEvent.js.map +1 -1
- package/dist/core/logging/span-to-ndjson-mapper.d.ts +10 -0
- package/dist/core/logging/span-to-ndjson-mapper.d.ts.map +1 -0
- package/dist/core/logging/span-to-ndjson-mapper.js +311 -0
- package/dist/core/logging/span-to-ndjson-mapper.js.map +1 -0
- package/dist/core/models/config-schemas.d.ts +40 -0
- package/dist/core/models/config-schemas.d.ts.map +1 -1
- package/dist/core/models/config-schemas.js +2 -0
- package/dist/core/models/config-schemas.js.map +1 -1
- package/dist/core/models/config-types.d.ts +8 -2
- package/dist/core/models/config-types.d.ts.map +1 -1
- package/dist/core/models/provider-profiles.d.ts +2 -1
- package/dist/core/models/provider-profiles.d.ts.map +1 -1
- package/dist/core/models/provider-profiles.js +1 -1
- package/dist/core/models/provider-profiles.js.map +1 -1
- package/dist/core/models/schema-base.d.ts +27 -0
- package/dist/core/models/schema-base.d.ts.map +1 -1
- package/dist/core/models/schema-base.js +2 -0
- package/dist/core/models/schema-base.js.map +1 -1
- package/dist/core/models/workflow-schemas.d.ts +59 -32
- package/dist/core/models/workflow-schemas.d.ts.map +1 -1
- package/dist/core/workflow/arpeggio/types.d.ts +3 -0
- package/dist/core/workflow/arpeggio/types.d.ts.map +1 -1
- package/dist/core/workflow/engine/ArpeggioRunner.d.ts +6 -1
- package/dist/core/workflow/engine/ArpeggioRunner.d.ts.map +1 -1
- package/dist/core/workflow/engine/ArpeggioRunner.js +97 -51
- package/dist/core/workflow/engine/ArpeggioRunner.js.map +1 -1
- package/dist/core/workflow/engine/OptionsBuilder.d.ts +3 -2
- package/dist/core/workflow/engine/OptionsBuilder.d.ts.map +1 -1
- package/dist/core/workflow/engine/OptionsBuilder.js +8 -1
- package/dist/core/workflow/engine/OptionsBuilder.js.map +1 -1
- package/dist/core/workflow/engine/ParallelRunner.d.ts +6 -1
- package/dist/core/workflow/engine/ParallelRunner.d.ts.map +1 -1
- package/dist/core/workflow/engine/ParallelRunner.js +32 -3
- package/dist/core/workflow/engine/ParallelRunner.js.map +1 -1
- package/dist/core/workflow/engine/StepExecutor.d.ts +5 -1
- package/dist/core/workflow/engine/StepExecutor.d.ts.map +1 -1
- package/dist/core/workflow/engine/StepExecutor.js +32 -3
- package/dist/core/workflow/engine/StepExecutor.js.map +1 -1
- package/dist/core/workflow/engine/TeamLeaderRunner.d.ts +6 -1
- package/dist/core/workflow/engine/TeamLeaderRunner.d.ts.map +1 -1
- package/dist/core/workflow/engine/TeamLeaderRunner.js +41 -7
- package/dist/core/workflow/engine/TeamLeaderRunner.js.map +1 -1
- package/dist/core/workflow/engine/WorkflowEngine.d.ts.map +1 -1
- package/dist/core/workflow/engine/WorkflowEngine.js +7 -0
- package/dist/core/workflow/engine/WorkflowEngine.js.map +1 -1
- package/dist/core/workflow/engine/WorkflowEngineSetup.d.ts.map +1 -1
- package/dist/core/workflow/engine/WorkflowEngineSetup.js +21 -1
- package/dist/core/workflow/engine/WorkflowEngineSetup.js.map +1 -1
- package/dist/core/workflow/engine/WorkflowRunLoop.d.ts +2 -0
- package/dist/core/workflow/engine/WorkflowRunLoop.d.ts.map +1 -1
- package/dist/core/workflow/engine/WorkflowRunLoop.js +10 -0
- package/dist/core/workflow/engine/WorkflowRunLoop.js.map +1 -1
- package/dist/core/workflow/engine/team-leader-part-runner.d.ts +10 -2
- package/dist/core/workflow/engine/team-leader-part-runner.d.ts.map +1 -1
- package/dist/core/workflow/engine/team-leader-part-runner.js +20 -2
- package/dist/core/workflow/engine/team-leader-part-runner.js.map +1 -1
- package/dist/core/workflow/observability/workflowSpans.d.ts +48 -2
- package/dist/core/workflow/observability/workflowSpans.d.ts.map +1 -1
- package/dist/core/workflow/observability/workflowSpans.js +303 -8
- package/dist/core/workflow/observability/workflowSpans.js.map +1 -1
- package/dist/core/workflow/permission-profile-resolution.d.ts +1 -1
- package/dist/core/workflow/permission-profile-resolution.d.ts.map +1 -1
- package/dist/core/workflow/permission-profile-resolution.js +10 -8
- package/dist/core/workflow/permission-profile-resolution.js.map +1 -1
- package/dist/core/workflow/phase-runner.d.ts +11 -1
- package/dist/core/workflow/phase-runner.d.ts.map +1 -1
- package/dist/core/workflow/phase-runner.js.map +1 -1
- package/dist/core/workflow/report-phase-runner.d.ts.map +1 -1
- package/dist/core/workflow/report-phase-runner.js +48 -11
- package/dist/core/workflow/report-phase-runner.js.map +1 -1
- package/dist/core/workflow/status-judgment-phase.d.ts.map +1 -1
- package/dist/core/workflow/status-judgment-phase.js +37 -2
- package/dist/core/workflow/status-judgment-phase.js.map +1 -1
- package/dist/core/workflow/types.d.ts +6 -0
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/features/interactive/aiCaller.d.ts +6 -1
- package/dist/features/interactive/aiCaller.d.ts.map +1 -1
- package/dist/features/interactive/aiCaller.js +10 -3
- package/dist/features/interactive/aiCaller.js.map +1 -1
- package/dist/features/interactive/clipboardImage.d.ts +3 -0
- package/dist/features/interactive/clipboardImage.d.ts.map +1 -0
- package/dist/features/interactive/clipboardImage.js +91 -0
- package/dist/features/interactive/clipboardImage.js.map +1 -0
- package/dist/features/interactive/clipboardImageFeedback.d.ts +2 -0
- package/dist/features/interactive/clipboardImageFeedback.d.ts.map +1 -0
- package/dist/features/interactive/clipboardImageFeedback.js +6 -0
- package/dist/features/interactive/clipboardImageFeedback.js.map +1 -0
- package/dist/features/interactive/conversationLoop.d.ts.map +1 -1
- package/dist/features/interactive/conversationLoop.js +8 -3
- package/dist/features/interactive/conversationLoop.js.map +1 -1
- package/dist/features/interactive/imageAttachments.d.ts +3 -0
- package/dist/features/interactive/imageAttachments.d.ts.map +1 -1
- package/dist/features/interactive/imageAttachments.js +18 -0
- package/dist/features/interactive/imageAttachments.js.map +1 -1
- package/dist/features/interactive/interactive.d.ts +1 -0
- package/dist/features/interactive/interactive.d.ts.map +1 -1
- package/dist/features/interactive/interactive.js.map +1 -1
- package/dist/features/interactive/interactiveInput.d.ts.map +1 -1
- package/dist/features/interactive/interactiveInput.js +4 -1
- package/dist/features/interactive/interactiveInput.js.map +1 -1
- package/dist/features/interactive/lineEditor.d.ts +18 -14
- package/dist/features/interactive/lineEditor.d.ts.map +1 -1
- package/dist/features/interactive/lineEditor.js +174 -80
- package/dist/features/interactive/lineEditor.js.map +1 -1
- package/dist/features/interactive/passthroughMode.d.ts.map +1 -1
- package/dist/features/interactive/passthroughMode.js +4 -1
- package/dist/features/interactive/passthroughMode.js.map +1 -1
- package/dist/features/interactive/quietMode.d.ts.map +1 -1
- package/dist/features/interactive/quietMode.js +5 -2
- package/dist/features/interactive/quietMode.js.map +1 -1
- package/dist/features/interactive/slashCommandRegistry.d.ts.map +1 -1
- package/dist/features/interactive/slashCommandRegistry.js +1 -0
- package/dist/features/interactive/slashCommandRegistry.js.map +1 -1
- package/dist/features/repertoire/takt-repertoire-config.d.ts.map +1 -1
- package/dist/features/repertoire/takt-repertoire-config.js +2 -1
- package/dist/features/repertoire/takt-repertoire-config.js.map +1 -1
- package/dist/features/tasks/attachments.d.ts.map +1 -1
- package/dist/features/tasks/attachments.js +18 -1
- package/dist/features/tasks/attachments.js.map +1 -1
- package/dist/features/tasks/execute/runAllTasks.js +3 -3
- package/dist/features/tasks/execute/runAllTasks.js.map +1 -1
- package/dist/features/tasks/execute/selectAndExecute.d.ts.map +1 -1
- package/dist/features/tasks/execute/selectAndExecute.js +1 -2
- package/dist/features/tasks/execute/selectAndExecute.js.map +1 -1
- package/dist/features/tasks/execute/taskSpecContext.d.ts +1 -0
- package/dist/features/tasks/execute/taskSpecContext.d.ts.map +1 -1
- package/dist/features/tasks/execute/taskSpecContext.js +25 -1
- package/dist/features/tasks/execute/taskSpecContext.js.map +1 -1
- package/dist/features/tasks/execute/workflowExecution.js +2 -0
- package/dist/features/tasks/execute/workflowExecution.js.map +1 -1
- package/dist/features/tasks/execute/workflowExecutionBootstrap.d.ts +1 -0
- package/dist/features/tasks/execute/workflowExecutionBootstrap.d.ts.map +1 -1
- package/dist/features/tasks/execute/workflowExecutionBootstrap.js +32 -1
- package/dist/features/tasks/execute/workflowExecutionBootstrap.js.map +1 -1
- package/dist/features/tasks/watch/index.js +3 -3
- package/dist/features/tasks/watch/index.js.map +1 -1
- package/dist/infra/claude/client.d.ts.map +1 -1
- package/dist/infra/claude/client.js +1 -0
- package/dist/infra/claude/client.js.map +1 -1
- package/dist/infra/claude/executor.d.ts.map +1 -1
- package/dist/infra/claude/executor.js +5 -35
- package/dist/infra/claude/executor.js.map +1 -1
- package/dist/infra/claude/image-input.d.ts +4 -0
- package/dist/infra/claude/image-input.d.ts.map +1 -0
- package/dist/infra/claude/image-input.js +63 -0
- package/dist/infra/claude/image-input.js.map +1 -0
- package/dist/infra/claude/types.d.ts +3 -0
- package/dist/infra/claude/types.d.ts.map +1 -1
- package/dist/infra/claude/usage.d.ts +3 -0
- package/dist/infra/claude/usage.d.ts.map +1 -0
- package/dist/infra/claude/usage.js +45 -0
- package/dist/infra/claude/usage.js.map +1 -0
- package/dist/infra/claude-headless/result-response.d.ts.map +1 -1
- package/dist/infra/claude-headless/result-response.js +1 -0
- package/dist/infra/claude-headless/result-response.js.map +1 -1
- package/dist/infra/claude-headless/stream-json-lines.d.ts +2 -0
- package/dist/infra/claude-headless/stream-json-lines.d.ts.map +1 -1
- package/dist/infra/claude-headless/stream-json-lines.js +4 -0
- package/dist/infra/claude-headless/stream-json-lines.js.map +1 -1
- package/dist/infra/codex/client.d.ts.map +1 -1
- package/dist/infra/codex/client.js +31 -8
- package/dist/infra/codex/client.js.map +1 -1
- package/dist/infra/codex/types.d.ts +2 -0
- package/dist/infra/codex/types.d.ts.map +1 -1
- package/dist/infra/codex/types.js.map +1 -1
- package/dist/infra/config/configNormalizers.d.ts +2 -1
- package/dist/infra/config/configNormalizers.d.ts.map +1 -1
- package/dist/infra/config/configNormalizers.js.map +1 -1
- package/dist/infra/config/env/global-current-env-specs.d.ts.map +1 -1
- package/dist/infra/config/env/global-current-env-specs.js +2 -0
- package/dist/infra/config/env/global-current-env-specs.js.map +1 -1
- package/dist/infra/config/global/globalConfig.d.ts +1 -1
- package/dist/infra/config/global/globalConfig.d.ts.map +1 -1
- package/dist/infra/config/global/globalConfig.js +1 -1
- package/dist/infra/config/global/globalConfig.js.map +1 -1
- package/dist/infra/config/global/globalConfigCore.d.ts.map +1 -1
- package/dist/infra/config/global/globalConfigCore.js +2 -0
- package/dist/infra/config/global/globalConfigCore.js.map +1 -1
- package/dist/infra/config/global/globalConfigResolvers.d.ts +2 -0
- package/dist/infra/config/global/globalConfigResolvers.d.ts.map +1 -1
- package/dist/infra/config/global/globalConfigResolvers.js +20 -0
- package/dist/infra/config/global/globalConfigResolvers.js.map +1 -1
- package/dist/infra/config/global/globalConfigSerializer.d.ts.map +1 -1
- package/dist/infra/config/global/globalConfigSerializer.js +6 -0
- package/dist/infra/config/global/globalConfigSerializer.js.map +1 -1
- package/dist/infra/config/global/index.d.ts +1 -1
- package/dist/infra/config/global/index.d.ts.map +1 -1
- package/dist/infra/config/global/index.js +1 -1
- package/dist/infra/config/global/index.js.map +1 -1
- package/dist/infra/config/global/initialization.d.ts +4 -1
- package/dist/infra/config/global/initialization.d.ts.map +1 -1
- package/dist/infra/config/global/initialization.js +1 -0
- package/dist/infra/config/global/initialization.js.map +1 -1
- package/dist/infra/config/traced/tracedConfigSchema.d.ts.map +1 -1
- package/dist/infra/config/traced/tracedConfigSchema.js +4 -0
- package/dist/infra/config/traced/tracedConfigSchema.js.map +1 -1
- package/dist/infra/fs/index.d.ts +1 -0
- package/dist/infra/fs/index.d.ts.map +1 -1
- package/dist/infra/fs/index.js +1 -0
- package/dist/infra/fs/index.js.map +1 -1
- package/dist/infra/fs/jsonl.d.ts +2 -0
- package/dist/infra/fs/jsonl.d.ts.map +1 -0
- package/dist/infra/fs/jsonl.js +5 -0
- package/dist/infra/fs/jsonl.js.map +1 -0
- package/dist/infra/kiro/client.d.ts +8 -0
- package/dist/infra/kiro/client.d.ts.map +1 -0
- package/dist/infra/kiro/client.js +177 -0
- package/dist/infra/kiro/client.js.map +1 -0
- package/dist/infra/kiro/index.d.ts +2 -0
- package/dist/infra/kiro/index.d.ts.map +1 -0
- package/dist/infra/kiro/index.js +2 -0
- package/dist/infra/kiro/index.js.map +1 -0
- package/dist/infra/kiro/process.d.ts +13 -0
- package/dist/infra/kiro/process.d.ts.map +1 -0
- package/dist/infra/kiro/process.js +212 -0
- package/dist/infra/kiro/process.js.map +1 -0
- package/dist/infra/kiro/types.d.ts +13 -0
- package/dist/infra/kiro/types.d.ts.map +1 -0
- package/dist/infra/kiro/types.js +2 -0
- package/dist/infra/kiro/types.js.map +1 -0
- package/dist/infra/observability/monitorJsonMetricExporter.d.ts +17 -0
- package/dist/infra/observability/monitorJsonMetricExporter.d.ts.map +1 -0
- package/dist/infra/observability/monitorJsonMetricExporter.js +174 -0
- package/dist/infra/observability/monitorJsonMetricExporter.js.map +1 -0
- package/dist/infra/observability/otelFoundation.d.ts +9 -1
- package/dist/infra/observability/otelFoundation.d.ts.map +1 -1
- package/dist/infra/observability/otelFoundation.js +97 -7
- package/dist/infra/observability/otelFoundation.js.map +1 -1
- package/dist/infra/observability/sessionLogSpanProcessor.d.ts +22 -0
- package/dist/infra/observability/sessionLogSpanProcessor.d.ts.map +1 -0
- package/dist/infra/observability/sessionLogSpanProcessor.js +127 -0
- package/dist/infra/observability/sessionLogSpanProcessor.js.map +1 -0
- package/dist/infra/observability/usageEventsSpanProcessor.d.ts +19 -0
- package/dist/infra/observability/usageEventsSpanProcessor.d.ts.map +1 -0
- package/dist/infra/observability/usageEventsSpanProcessor.js +77 -0
- package/dist/infra/observability/usageEventsSpanProcessor.js.map +1 -0
- package/dist/infra/opencode/types.d.ts.map +1 -1
- package/dist/infra/opencode/types.js +8 -4
- package/dist/infra/opencode/types.js.map +1 -1
- package/dist/infra/providers/claude-headless.d.ts +1 -0
- package/dist/infra/providers/claude-headless.d.ts.map +1 -1
- package/dist/infra/providers/claude-headless.js +1 -0
- package/dist/infra/providers/claude-headless.js.map +1 -1
- package/dist/infra/providers/claude-terminal.d.ts +1 -0
- package/dist/infra/providers/claude-terminal.d.ts.map +1 -1
- package/dist/infra/providers/claude-terminal.js +1 -0
- package/dist/infra/providers/claude-terminal.js.map +1 -1
- package/dist/infra/providers/claude.d.ts +1 -0
- package/dist/infra/providers/claude.d.ts.map +1 -1
- package/dist/infra/providers/claude.js +2 -0
- package/dist/infra/providers/claude.js.map +1 -1
- package/dist/infra/providers/codex.d.ts +1 -0
- package/dist/infra/providers/codex.d.ts.map +1 -1
- package/dist/infra/providers/codex.js +2 -0
- package/dist/infra/providers/codex.js.map +1 -1
- package/dist/infra/providers/copilot.d.ts +1 -0
- package/dist/infra/providers/copilot.d.ts.map +1 -1
- package/dist/infra/providers/copilot.js +1 -0
- package/dist/infra/providers/copilot.js.map +1 -1
- package/dist/infra/providers/cursor.d.ts +1 -0
- package/dist/infra/providers/cursor.d.ts.map +1 -1
- package/dist/infra/providers/cursor.js +1 -0
- package/dist/infra/providers/cursor.js.map +1 -1
- package/dist/infra/providers/imageAttachmentPrompt.d.ts +4 -0
- package/dist/infra/providers/imageAttachmentPrompt.d.ts.map +1 -0
- package/dist/infra/providers/imageAttachmentPrompt.js +10 -0
- package/dist/infra/providers/imageAttachmentPrompt.js.map +1 -0
- package/dist/infra/providers/index.d.ts.map +1 -1
- package/dist/infra/providers/index.js +2 -0
- package/dist/infra/providers/index.js.map +1 -1
- package/dist/infra/providers/kiro.d.ts +7 -0
- package/dist/infra/providers/kiro.d.ts.map +1 -0
- package/dist/infra/providers/kiro.js +47 -0
- package/dist/infra/providers/kiro.js.map +1 -0
- package/dist/infra/providers/mock.d.ts +1 -0
- package/dist/infra/providers/mock.d.ts.map +1 -1
- package/dist/infra/providers/mock.js +1 -0
- package/dist/infra/providers/mock.js.map +1 -1
- package/dist/infra/providers/opencode.d.ts +1 -0
- package/dist/infra/providers/opencode.d.ts.map +1 -1
- package/dist/infra/providers/opencode.js +1 -0
- package/dist/infra/providers/opencode.js.map +1 -1
- package/dist/infra/providers/provider-capabilities.d.ts +1 -0
- package/dist/infra/providers/provider-capabilities.d.ts.map +1 -1
- package/dist/infra/providers/provider-capabilities.js +6 -1
- package/dist/infra/providers/provider-capabilities.js.map +1 -1
- package/dist/infra/providers/types.d.ts +7 -0
- package/dist/infra/providers/types.d.ts.map +1 -1
- package/dist/infra/task/clone-errors.d.ts +3 -0
- package/dist/infra/task/clone-errors.d.ts.map +1 -0
- package/dist/infra/task/clone-errors.js +5 -0
- package/dist/infra/task/clone-errors.js.map +1 -0
- package/dist/infra/task/clone-exec.d.ts +5 -1
- package/dist/infra/task/clone-exec.d.ts.map +1 -1
- package/dist/infra/task/clone-exec.js +146 -48
- package/dist/infra/task/clone-exec.js.map +1 -1
- package/dist/infra/task/clone.d.ts.map +1 -1
- package/dist/infra/task/clone.js +7 -9
- package/dist/infra/task/clone.js.map +1 -1
- package/dist/infra/task/runner.d.ts +1 -1
- package/dist/infra/task/runner.d.ts.map +1 -1
- package/dist/infra/task/runner.js +2 -2
- package/dist/infra/task/runner.js.map +1 -1
- package/dist/infra/task/taskLifecycleService.d.ts +1 -2
- package/dist/infra/task/taskLifecycleService.d.ts.map +1 -1
- package/dist/infra/task/taskLifecycleService.js +13 -19
- package/dist/infra/task/taskLifecycleService.js.map +1 -1
- package/dist/infra/task/taskRecordMutations.d.ts +0 -1
- package/dist/infra/task/taskRecordMutations.d.ts.map +1 -1
- package/dist/infra/task/taskRecordMutations.js +0 -12
- package/dist/infra/task/taskRecordMutations.js.map +1 -1
- package/dist/shared/constants.d.ts +1 -0
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/constants.js +1 -0
- package/dist/shared/constants.js.map +1 -1
- package/dist/shared/i18n/labels_en.yaml +3 -1
- package/dist/shared/i18n/labels_ja.yaml +3 -1
- package/dist/shared/types/provider.d.ts +3 -1
- package/dist/shared/types/provider.d.ts.map +1 -1
- package/dist/shared/types/provider.js +15 -1
- package/dist/shared/types/provider.js.map +1 -1
- package/dist/shared/utils/spawn.d.ts +3 -4
- package/dist/shared/utils/spawn.d.ts.map +1 -1
- package/dist/shared/utils/spawn.js +6 -9
- package/dist/shared/utils/spawn.js.map +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { getErrorMessage } from '../../shared/utils/index.js';
|
|
2
|
+
import { execKiro } from './process.js';
|
|
3
|
+
const KIRO_ABORTED_MESSAGE = 'Kiro execution aborted';
|
|
4
|
+
const KIRO_ERROR_DETAIL_MAX_LENGTH = 400;
|
|
5
|
+
const KIRO_SESSION_ID_PATTERN = /^[A-Za-z0-9._:-]+$/;
|
|
6
|
+
function buildPrompt(prompt, systemPrompt) {
|
|
7
|
+
if (!systemPrompt) {
|
|
8
|
+
return prompt;
|
|
9
|
+
}
|
|
10
|
+
return `${systemPrompt}\n\n${prompt}`;
|
|
11
|
+
}
|
|
12
|
+
function buildTrustArgs(options) {
|
|
13
|
+
if (options.permissionMode === 'full') {
|
|
14
|
+
return ['--trust-all-tools'];
|
|
15
|
+
}
|
|
16
|
+
if (options.permissionMode === 'edit') {
|
|
17
|
+
return ['--trust-tools=read,grep,write,shell'];
|
|
18
|
+
}
|
|
19
|
+
if (options.permissionMode === 'readonly') {
|
|
20
|
+
return ['--trust-tools=read,grep'];
|
|
21
|
+
}
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
function validateSessionId(sessionId) {
|
|
25
|
+
if (!KIRO_SESSION_ID_PATTERN.test(sessionId)) {
|
|
26
|
+
throw new Error('Invalid Kiro session ID. Only letters, numbers, dot, underscore, colon, and hyphen are allowed.');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function buildInputArg(prompt) {
|
|
30
|
+
// Kiro documents the prompt as positional INPUT, but does not document a `--` separator.
|
|
31
|
+
return prompt.startsWith('-') ? `\n${prompt}` : prompt;
|
|
32
|
+
}
|
|
33
|
+
function buildArgs(options, prompt) {
|
|
34
|
+
const args = [
|
|
35
|
+
'chat',
|
|
36
|
+
'--no-interactive',
|
|
37
|
+
...buildTrustArgs(options),
|
|
38
|
+
];
|
|
39
|
+
if (options.sessionId) {
|
|
40
|
+
validateSessionId(options.sessionId);
|
|
41
|
+
args.push('--resume-id', options.sessionId);
|
|
42
|
+
}
|
|
43
|
+
args.push(buildInputArg(prompt));
|
|
44
|
+
return args;
|
|
45
|
+
}
|
|
46
|
+
function trimDetail(value) {
|
|
47
|
+
const normalized = (value ?? '').trim();
|
|
48
|
+
if (!normalized) {
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
return normalized.length > KIRO_ERROR_DETAIL_MAX_LENGTH
|
|
52
|
+
? `${normalized.slice(0, KIRO_ERROR_DETAIL_MAX_LENGTH)}...`
|
|
53
|
+
: normalized;
|
|
54
|
+
}
|
|
55
|
+
function redactDetail(value, kiroApiKey) {
|
|
56
|
+
if (!kiroApiKey) {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
return value.split(kiroApiKey).join('[REDACTED]');
|
|
60
|
+
}
|
|
61
|
+
function redactedTrimmedDetail(value, kiroApiKey) {
|
|
62
|
+
return trimDetail(redactDetail(value ?? '', kiroApiKey));
|
|
63
|
+
}
|
|
64
|
+
function resolveEffectiveKiroApiKey(kiroApiKey) {
|
|
65
|
+
return kiroApiKey ?? process.env.KIRO_API_KEY;
|
|
66
|
+
}
|
|
67
|
+
function selectErrorDetail(error) {
|
|
68
|
+
const stderr = trimDetail(error.stderr);
|
|
69
|
+
if (stderr) {
|
|
70
|
+
return error.stderr ?? '';
|
|
71
|
+
}
|
|
72
|
+
const stdout = trimDetail(error.stdout);
|
|
73
|
+
if (stdout) {
|
|
74
|
+
return error.stdout ?? '';
|
|
75
|
+
}
|
|
76
|
+
return getErrorMessage(error);
|
|
77
|
+
}
|
|
78
|
+
function isAuthenticationError(error) {
|
|
79
|
+
const message = [
|
|
80
|
+
trimDetail(error.message),
|
|
81
|
+
trimDetail(error.stderr),
|
|
82
|
+
trimDetail(error.stdout),
|
|
83
|
+
].join('\n').toLowerCase();
|
|
84
|
+
const patterns = [
|
|
85
|
+
'authentication',
|
|
86
|
+
'unauthorized',
|
|
87
|
+
'forbidden',
|
|
88
|
+
'api key',
|
|
89
|
+
'kiro_api_key',
|
|
90
|
+
'kiro-api-key',
|
|
91
|
+
'login required',
|
|
92
|
+
];
|
|
93
|
+
return patterns.some((pattern) => message.includes(pattern));
|
|
94
|
+
}
|
|
95
|
+
function classifyExecutionError(error, options) {
|
|
96
|
+
if (options.abortSignal?.aborted || error.name === 'AbortError') {
|
|
97
|
+
return KIRO_ABORTED_MESSAGE;
|
|
98
|
+
}
|
|
99
|
+
if (error.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER') {
|
|
100
|
+
return 'Kiro CLI output exceeded buffer limit';
|
|
101
|
+
}
|
|
102
|
+
if (error.code === 'ENOENT') {
|
|
103
|
+
return 'kiro-cli binary not found. Install Kiro CLI and ensure `kiro-cli` is in PATH, or set TAKT_KIRO_CLI_PATH/kiro_cli_path.';
|
|
104
|
+
}
|
|
105
|
+
if (isAuthenticationError(error)) {
|
|
106
|
+
return 'Kiro authentication failed. Set TAKT_KIRO_API_KEY, kiro_api_key, or KIRO_API_KEY.';
|
|
107
|
+
}
|
|
108
|
+
if (typeof error.code === 'number') {
|
|
109
|
+
const detail = redactedTrimmedDetail(selectErrorDetail(error), options.kiroApiKey);
|
|
110
|
+
return `Kiro CLI exited with code ${error.code}: ${detail}`;
|
|
111
|
+
}
|
|
112
|
+
return redactDetail(getErrorMessage(error), options.kiroApiKey);
|
|
113
|
+
}
|
|
114
|
+
function emitResult(options, result, success, error) {
|
|
115
|
+
options.onStream?.({
|
|
116
|
+
type: 'result',
|
|
117
|
+
data: {
|
|
118
|
+
result,
|
|
119
|
+
success,
|
|
120
|
+
error,
|
|
121
|
+
sessionId: options.sessionId ?? '',
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
export class KiroClient {
|
|
126
|
+
async call(agentType, prompt, options) {
|
|
127
|
+
const promptText = buildPrompt(prompt, options.systemPrompt);
|
|
128
|
+
const effectiveKiroApiKey = resolveEffectiveKiroApiKey(options.kiroApiKey);
|
|
129
|
+
const effectiveOptions = effectiveKiroApiKey === options.kiroApiKey
|
|
130
|
+
? options
|
|
131
|
+
: { ...options, kiroApiKey: effectiveKiroApiKey };
|
|
132
|
+
try {
|
|
133
|
+
const args = buildArgs(effectiveOptions, promptText);
|
|
134
|
+
const { stdout } = await execKiro(args, effectiveOptions);
|
|
135
|
+
const content = stdout.trim();
|
|
136
|
+
if (!content) {
|
|
137
|
+
const message = 'kiro-cli returned empty output';
|
|
138
|
+
emitResult(options, '', false, message);
|
|
139
|
+
return {
|
|
140
|
+
persona: agentType,
|
|
141
|
+
status: 'error',
|
|
142
|
+
content: message,
|
|
143
|
+
error: message,
|
|
144
|
+
timestamp: new Date(),
|
|
145
|
+
sessionId: options.sessionId,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
options.onStream?.({ type: 'text', data: { text: content } });
|
|
149
|
+
emitResult(options, content, true);
|
|
150
|
+
return {
|
|
151
|
+
persona: agentType,
|
|
152
|
+
status: 'done',
|
|
153
|
+
content,
|
|
154
|
+
timestamp: new Date(),
|
|
155
|
+
sessionId: options.sessionId,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
catch (rawError) {
|
|
159
|
+
const error = rawError;
|
|
160
|
+
const message = classifyExecutionError(error, effectiveOptions);
|
|
161
|
+
emitResult(options, '', false, message);
|
|
162
|
+
return {
|
|
163
|
+
persona: agentType,
|
|
164
|
+
status: 'error',
|
|
165
|
+
content: message,
|
|
166
|
+
error: message,
|
|
167
|
+
timestamp: new Date(),
|
|
168
|
+
sessionId: options.sessionId,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const defaultClient = new KiroClient();
|
|
174
|
+
export async function callKiro(agentType, prompt, options) {
|
|
175
|
+
return defaultClient.call(agentType, prompt, options);
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/infra/kiro/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAsB,MAAM,cAAc,CAAC;AAK5D,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AACtD,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;AAErD,SAAS,WAAW,CAAC,MAAc,EAAE,YAAqB;IACxD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,YAAY,OAAO,MAAM,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,cAAc,CAAC,OAAwB;IAC9C,IAAI,OAAO,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;QACtC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC/B,CAAC;IACD,IAAI,OAAO,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;QACtC,OAAO,CAAC,qCAAqC,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,OAAO,CAAC,cAAc,KAAK,UAAU,EAAE,CAAC;QAC1C,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,iBAAiB,CAAC,SAAiB;IAC1C,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,iGAAiG,CAAC,CAAC;IACrH,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,MAAc;IACnC,yFAAyF;IACzF,OAAO,MAAM,CAAC,U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BACd,SAAS,EAAE,IAAI,IAAI,EAAE;gBACrB,SAAS,EAAE,OAAO,CAAC,SAAS;aAC7B,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,MAAM,aAAa,GAAG,IAAI,UAAU,EAAE,CAAC;AAEvC,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,SAAiB,EACjB,MAAc,EACd,OAAwB;IAExB,OAAO,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infra/kiro/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infra/kiro/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,GAET,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { KiroCallOptions } from './types.js';
|
|
2
|
+
export type KiroExecResult = {
|
|
3
|
+
stdout: string;
|
|
4
|
+
stderr: string;
|
|
5
|
+
};
|
|
6
|
+
export type KiroExecError = Error & {
|
|
7
|
+
code?: string | number;
|
|
8
|
+
stdout?: string;
|
|
9
|
+
stderr?: string;
|
|
10
|
+
signal?: NodeJS.Signals | null;
|
|
11
|
+
};
|
|
12
|
+
export declare function execKiro(args: string[], options: KiroCallOptions): Promise<KiroExecResult>;
|
|
13
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../../src/infra/kiro/process.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAqClD,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG;IAClC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;CAChC,CAAC;AAkDF,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC,CA8JzB"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { crossSpawn } from '../../shared/utils/index.js';
|
|
2
|
+
const KIRO_COMMAND = 'kiro-cli';
|
|
3
|
+
const KIRO_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
|
|
4
|
+
const KIRO_FORCE_KILL_DELAY_MS_DEFAULT = 1_000;
|
|
5
|
+
const KIRO_ENV_ALLOWLIST = [
|
|
6
|
+
'ALL_PROXY',
|
|
7
|
+
'APPDATA',
|
|
8
|
+
'HOME',
|
|
9
|
+
'HTTP_PROXY',
|
|
10
|
+
'HTTPS_PROXY',
|
|
11
|
+
'LANG',
|
|
12
|
+
'LC_ALL',
|
|
13
|
+
'LOCALAPPDATA',
|
|
14
|
+
'NO_PROXY',
|
|
15
|
+
'NODE_EXTRA_CA_CERTS',
|
|
16
|
+
'PATH',
|
|
17
|
+
'Path',
|
|
18
|
+
'SHELL',
|
|
19
|
+
'SSL_CERT_DIR',
|
|
20
|
+
'SSL_CERT_FILE',
|
|
21
|
+
'SystemRoot',
|
|
22
|
+
'TEMP',
|
|
23
|
+
'TERM',
|
|
24
|
+
'TMP',
|
|
25
|
+
'TMPDIR',
|
|
26
|
+
'USERPROFILE',
|
|
27
|
+
'XDG_CACHE_HOME',
|
|
28
|
+
'XDG_CONFIG_HOME',
|
|
29
|
+
'XDG_DATA_HOME',
|
|
30
|
+
'all_proxy',
|
|
31
|
+
'http_proxy',
|
|
32
|
+
'https_proxy',
|
|
33
|
+
'no_proxy',
|
|
34
|
+
'KIRO_HOME',
|
|
35
|
+
];
|
|
36
|
+
function buildEnv(kiroApiKey) {
|
|
37
|
+
const env = {};
|
|
38
|
+
for (const key of KIRO_ENV_ALLOWLIST) {
|
|
39
|
+
const value = process.env[key];
|
|
40
|
+
if (value !== undefined) {
|
|
41
|
+
env[key] = value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const resolvedKiroApiKey = kiroApiKey !== undefined ? kiroApiKey : process.env.KIRO_API_KEY;
|
|
45
|
+
if (resolvedKiroApiKey !== undefined) {
|
|
46
|
+
env.KIRO_API_KEY = resolvedKiroApiKey;
|
|
47
|
+
}
|
|
48
|
+
return env;
|
|
49
|
+
}
|
|
50
|
+
function createExecError(message, params = {}) {
|
|
51
|
+
const error = new Error(message);
|
|
52
|
+
if (params.name) {
|
|
53
|
+
error.name = params.name;
|
|
54
|
+
}
|
|
55
|
+
error.code = params.code;
|
|
56
|
+
error.stdout = params.stdout;
|
|
57
|
+
error.stderr = params.stderr;
|
|
58
|
+
error.signal = params.signal;
|
|
59
|
+
return error;
|
|
60
|
+
}
|
|
61
|
+
function buildCloseErrorMessage(code, signal) {
|
|
62
|
+
if (signal !== null) {
|
|
63
|
+
return `kiro-cli terminated by signal ${signal}`;
|
|
64
|
+
}
|
|
65
|
+
if (code !== null) {
|
|
66
|
+
return `kiro-cli exited with code ${code}`;
|
|
67
|
+
}
|
|
68
|
+
return 'kiro-cli closed without exit code or signal';
|
|
69
|
+
}
|
|
70
|
+
export function execKiro(args, options) {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
const child = crossSpawn(options.kiroCliPath ?? KIRO_COMMAND, args, {
|
|
73
|
+
cwd: options.cwd,
|
|
74
|
+
env: buildEnv(options.kiroApiKey),
|
|
75
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
76
|
+
});
|
|
77
|
+
child.stdin?.end();
|
|
78
|
+
let stdout = '';
|
|
79
|
+
let stderr = '';
|
|
80
|
+
let stdoutBytes = 0;
|
|
81
|
+
let stderrBytes = 0;
|
|
82
|
+
let settled = false;
|
|
83
|
+
let terminationTimer;
|
|
84
|
+
let childClosed = false;
|
|
85
|
+
const clearTerminationTimer = () => {
|
|
86
|
+
if (terminationTimer !== undefined) {
|
|
87
|
+
clearTimeout(terminationTimer);
|
|
88
|
+
terminationTimer = undefined;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const scheduleForceKill = () => {
|
|
92
|
+
if (terminationTimer === undefined) {
|
|
93
|
+
terminationTimer = setTimeout(() => {
|
|
94
|
+
if (!childClosed) {
|
|
95
|
+
child.kill('SIGKILL');
|
|
96
|
+
}
|
|
97
|
+
terminationTimer = undefined;
|
|
98
|
+
}, KIRO_FORCE_KILL_DELAY_MS_DEFAULT);
|
|
99
|
+
terminationTimer.unref?.();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const terminateChild = () => {
|
|
103
|
+
child.kill('SIGTERM');
|
|
104
|
+
scheduleForceKill();
|
|
105
|
+
};
|
|
106
|
+
const abortHandler = () => {
|
|
107
|
+
if (settled)
|
|
108
|
+
return;
|
|
109
|
+
terminateChild();
|
|
110
|
+
};
|
|
111
|
+
const cleanup = () => {
|
|
112
|
+
if (childClosed) {
|
|
113
|
+
clearTerminationTimer();
|
|
114
|
+
}
|
|
115
|
+
if (options.abortSignal) {
|
|
116
|
+
options.abortSignal.removeEventListener('abort', abortHandler);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const rejectOnce = (error) => {
|
|
120
|
+
if (settled)
|
|
121
|
+
return;
|
|
122
|
+
settled = true;
|
|
123
|
+
cleanup();
|
|
124
|
+
reject(error);
|
|
125
|
+
};
|
|
126
|
+
const rejectAfterTermination = (error) => {
|
|
127
|
+
if (settled)
|
|
128
|
+
return;
|
|
129
|
+
terminateChild();
|
|
130
|
+
settled = true;
|
|
131
|
+
cleanup();
|
|
132
|
+
reject(error);
|
|
133
|
+
};
|
|
134
|
+
const resolveOnce = (result) => {
|
|
135
|
+
if (settled)
|
|
136
|
+
return;
|
|
137
|
+
settled = true;
|
|
138
|
+
cleanup();
|
|
139
|
+
resolve(result);
|
|
140
|
+
};
|
|
141
|
+
const appendChunk = (target, chunk) => {
|
|
142
|
+
const text = typeof chunk === 'string' ? chunk : chunk.toString('utf-8');
|
|
143
|
+
const byteLength = Buffer.byteLength(text);
|
|
144
|
+
if (target === 'stdout') {
|
|
145
|
+
stdoutBytes += byteLength;
|
|
146
|
+
if (stdoutBytes > KIRO_MAX_BUFFER_BYTES) {
|
|
147
|
+
rejectAfterTermination(createExecError('kiro-cli stdout exceeded buffer limit', {
|
|
148
|
+
code: 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER',
|
|
149
|
+
stdout,
|
|
150
|
+
stderr,
|
|
151
|
+
}));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
stdout += text;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
stderrBytes += byteLength;
|
|
158
|
+
if (stderrBytes > KIRO_MAX_BUFFER_BYTES) {
|
|
159
|
+
rejectAfterTermination(createExecError('kiro-cli stderr exceeded buffer limit', {
|
|
160
|
+
code: 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER',
|
|
161
|
+
stdout,
|
|
162
|
+
stderr,
|
|
163
|
+
}));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
stderr += text;
|
|
167
|
+
};
|
|
168
|
+
child.stdout?.on('data', (chunk) => appendChunk('stdout', chunk));
|
|
169
|
+
child.stderr?.on('data', (chunk) => appendChunk('stderr', chunk));
|
|
170
|
+
child.on('error', (error) => {
|
|
171
|
+
rejectOnce(createExecError(error.message, {
|
|
172
|
+
code: error.code,
|
|
173
|
+
stdout,
|
|
174
|
+
stderr,
|
|
175
|
+
}));
|
|
176
|
+
});
|
|
177
|
+
child.on('close', (code, signal) => {
|
|
178
|
+
childClosed = true;
|
|
179
|
+
clearTerminationTimer();
|
|
180
|
+
if (settled)
|
|
181
|
+
return;
|
|
182
|
+
if (options.abortSignal?.aborted) {
|
|
183
|
+
rejectOnce(createExecError('Kiro execution aborted', {
|
|
184
|
+
name: 'AbortError',
|
|
185
|
+
stdout,
|
|
186
|
+
stderr,
|
|
187
|
+
signal,
|
|
188
|
+
}));
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (code === 0) {
|
|
192
|
+
resolveOnce({ stdout, stderr });
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
rejectOnce(createExecError(buildCloseErrorMessage(code, signal), {
|
|
196
|
+
code: code === null ? undefined : code,
|
|
197
|
+
stdout,
|
|
198
|
+
stderr,
|
|
199
|
+
signal,
|
|
200
|
+
}));
|
|
201
|
+
});
|
|
202
|
+
if (options.abortSignal) {
|
|
203
|
+
if (options.abortSignal.aborted) {
|
|
204
|
+
abortHandler();
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
options.abortSignal.addEventListener('abort', abortHandler, { once: true });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../../src/infra/kiro/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGzD,MAAM,YAAY,GAAG,UAAU,CAAC;AAChC,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC/C,MAAM,gCAAgC,GAAG,KAAK,CAAC;AAC/C,MAAM,kBAAkB,GAAG;IACzB,WAAW;IACX,SAAS;IACT,MAAM;IACN,YAAY;IACZ,aAAa;IACb,MAAM;IACN,QAAQ;IAC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gB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9E,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PermissionMode } from '../../core/models/index.js';
|
|
2
|
+
import type { StreamCallback } from '../../shared/types/provider.js';
|
|
3
|
+
export interface KiroCallOptions {
|
|
4
|
+
cwd: string;
|
|
5
|
+
abortSignal?: AbortSignal;
|
|
6
|
+
sessionId?: string;
|
|
7
|
+
systemPrompt?: string;
|
|
8
|
+
permissionMode?: PermissionMode;
|
|
9
|
+
onStream?: StreamCallback;
|
|
10
|
+
kiroApiKey?: string;
|
|
11
|
+
kiroCliPath?: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/infra/kiro/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/infra/kiro/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PushMetricExporter, ResourceMetrics } from '@opentelemetry/sdk-metrics';
|
|
2
|
+
export interface MonitorJsonMetricExporterOptions {
|
|
3
|
+
runId: string;
|
|
4
|
+
monitorPath: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class MonitorJsonMetricExporter implements PushMetricExporter {
|
|
7
|
+
private readonly registrations;
|
|
8
|
+
private shutdownRequested;
|
|
9
|
+
private overflowWarned;
|
|
10
|
+
constructor(options?: MonitorJsonMetricExporterOptions);
|
|
11
|
+
register(options: MonitorJsonMetricExporterOptions): () => void;
|
|
12
|
+
export(metrics: ResourceMetrics, resultCallback: Parameters<PushMetricExporter['export']>[1]): void;
|
|
13
|
+
forceFlush(): Promise<void>;
|
|
14
|
+
shutdown(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare function hasCardinalityOverflow(metrics: ResourceMetrics): boolean;
|
|
17
|
+
//# sourceMappingURL=monitorJsonMetricExporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitorJsonMetricExporter.d.ts","sourceRoot":"","sources":["../../../src/infra/observability/monitorJsonMetricExporter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAKV,kBAAkB,EAClB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAMpC,MAAM,WAAW,gCAAgC;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAID,qBAAa,yBAA0B,YAAW,kBAAkB;IAClE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAuD;IACrF,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,cAAc,CAAS;gBAEnB,OAAO,CAAC,EAAE,gCAAgC;IAMtD,QAAQ,CAAC,OAAO,EAAE,gCAAgC,GAAG,MAAM,IAAI;IAgB/D,MAAM,CAAC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAyC7F,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAE3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAIhC;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAMxE"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { dirname } from 'node:path';
|
|
2
|
+
import { ensureDir, writeFileAtomic } from '../config/index.js';
|
|
3
|
+
import { createLogger } from '../../shared/utils/debug.js';
|
|
4
|
+
const log = createLogger('monitor-json-metric-exporter');
|
|
5
|
+
export class MonitorJsonMetricExporter {
|
|
6
|
+
registrations = new Map();
|
|
7
|
+
shutdownRequested = false;
|
|
8
|
+
overflowWarned = false;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
if (options) {
|
|
11
|
+
this.register(options);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
register(options) {
|
|
15
|
+
if (this.registrations.has(options.runId)) {
|
|
16
|
+
// A live run already owns this runId; keep it rather than redirect its
|
|
17
|
+
// monitor.json output to a colliding path.
|
|
18
|
+
log.warn('Ignoring duplicate monitor.json metric registration', {
|
|
19
|
+
runId: options.runId,
|
|
20
|
+
monitorPath: options.monitorPath,
|
|
21
|
+
});
|
|
22
|
+
return () => { };
|
|
23
|
+
}
|
|
24
|
+
this.registrations.set(options.runId, options);
|
|
25
|
+
return () => {
|
|
26
|
+
this.registrations.delete(options.runId);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export(metrics, resultCallback) {
|
|
30
|
+
if (this.shutdownRequested) {
|
|
31
|
+
resultCallback({ code: 1, error: new Error('MonitorJsonMetricExporter is shut down') });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
// The metric SDK caps each instrument at a fixed cardinality (2000 distinct
|
|
35
|
+
// attribute sets). Because every metric is keyed by takt.run.id, a very
|
|
36
|
+
// long-lived process with many overlapping runs eventually overflows: new
|
|
37
|
+
// runs' series merge into an attribute-less overflow bucket, so their
|
|
38
|
+
// run-scoped monitor.json filters to empty. Surface this once instead of
|
|
39
|
+
// letting late runs silently get no monitor.json.
|
|
40
|
+
if (!this.overflowWarned && hasCardinalityOverflow(metrics)) {
|
|
41
|
+
this.overflowWarned = true;
|
|
42
|
+
log.warn('OpenTelemetry metric cardinality limit reached; per-run monitor.json metrics may be incomplete for long-lived processes');
|
|
43
|
+
}
|
|
44
|
+
for (const options of this.registrations.values()) {
|
|
45
|
+
try {
|
|
46
|
+
const filtered = filterResourceMetricsByRun(metrics, options.runId);
|
|
47
|
+
if (filtered.scopeMetrics.length === 0) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
ensureDir(dirname(options.monitorPath));
|
|
51
|
+
writeFileAtomic(options.monitorPath, `${JSON.stringify(serializeResourceMetrics(filtered), null, 2)}\n`);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const wrapped = error instanceof Error ? error : new Error(String(error));
|
|
55
|
+
log.error('Failed to write monitor.json metrics', {
|
|
56
|
+
runId: options.runId,
|
|
57
|
+
error: wrapped.message,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
resultCallback({ code: 0 });
|
|
62
|
+
}
|
|
63
|
+
async forceFlush() { }
|
|
64
|
+
async shutdown() {
|
|
65
|
+
this.shutdownRequested = true;
|
|
66
|
+
this.registrations.clear();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export function hasCardinalityOverflow(metrics) {
|
|
70
|
+
return metrics.scopeMetrics.some((scopeMetrics) => scopeMetrics.metrics.some((metric) => metric.dataPoints.some((point) => point.attributes['otel.metric.overflow'] === true)));
|
|
71
|
+
}
|
|
72
|
+
function filterResourceMetricsByRun(metrics, runId) {
|
|
73
|
+
return {
|
|
74
|
+
...metrics,
|
|
75
|
+
scopeMetrics: metrics.scopeMetrics
|
|
76
|
+
.map((scopeMetrics) => ({
|
|
77
|
+
...scopeMetrics,
|
|
78
|
+
metrics: scopeMetrics.metrics
|
|
79
|
+
.map((metric) => ({
|
|
80
|
+
...metric,
|
|
81
|
+
dataPoints: metric.dataPoints.filter((point) => point.attributes['takt.run.id'] === runId),
|
|
82
|
+
}))
|
|
83
|
+
.filter((metric) => metric.dataPoints.length > 0),
|
|
84
|
+
}))
|
|
85
|
+
.filter((scopeMetrics) => scopeMetrics.metrics.length > 0),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function serializeResourceMetrics(metrics) {
|
|
89
|
+
return {
|
|
90
|
+
schemaVersion: 1,
|
|
91
|
+
generatedAt: new Date().toISOString(),
|
|
92
|
+
resource: toJsonObject(metrics.resource.attributes ?? {}),
|
|
93
|
+
scopeMetrics: metrics.scopeMetrics.map((scopeMetrics) => ({
|
|
94
|
+
scope: {
|
|
95
|
+
name: scopeMetrics.scope.name,
|
|
96
|
+
...(scopeMetrics.scope.version ? { version: scopeMetrics.scope.version } : {}),
|
|
97
|
+
},
|
|
98
|
+
metrics: scopeMetrics.metrics.map(serializeMetricData),
|
|
99
|
+
})),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function serializeMetricData(metric) {
|
|
103
|
+
return {
|
|
104
|
+
name: metric.descriptor.name,
|
|
105
|
+
description: metric.descriptor.description,
|
|
106
|
+
unit: metric.descriptor.unit,
|
|
107
|
+
dataPointType: dataPointTypeName(metric.dataPointType),
|
|
108
|
+
aggregationTemporality: aggregationTemporalityName(metric.aggregationTemporality),
|
|
109
|
+
...('isMonotonic' in metric ? { isMonotonic: metric.isMonotonic } : {}),
|
|
110
|
+
points: metric.dataPoints.map(serializeDataPoint),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function serializeDataPoint(point) {
|
|
114
|
+
return {
|
|
115
|
+
startTime: hrTimeToIso(point.startTime),
|
|
116
|
+
endTime: hrTimeToIso(point.endTime),
|
|
117
|
+
attributes: toJsonObject(point.attributes),
|
|
118
|
+
value: toJsonValue(point.value),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function dataPointTypeName(type) {
|
|
122
|
+
switch (type) {
|
|
123
|
+
case 0:
|
|
124
|
+
return 'histogram';
|
|
125
|
+
case 1:
|
|
126
|
+
return 'exponential_histogram';
|
|
127
|
+
case 2:
|
|
128
|
+
return 'gauge';
|
|
129
|
+
case 3:
|
|
130
|
+
return 'sum';
|
|
131
|
+
default:
|
|
132
|
+
return String(type);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function aggregationTemporalityName(temporality) {
|
|
136
|
+
switch (temporality) {
|
|
137
|
+
case 0:
|
|
138
|
+
return 'delta';
|
|
139
|
+
case 1:
|
|
140
|
+
return 'cumulative';
|
|
141
|
+
default:
|
|
142
|
+
return String(temporality);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function hrTimeToIso(time) {
|
|
146
|
+
const [seconds, nanoseconds] = time;
|
|
147
|
+
return new Date((seconds * 1000) + Math.floor(nanoseconds / 1_000_000)).toISOString();
|
|
148
|
+
}
|
|
149
|
+
function toJsonObject(value) {
|
|
150
|
+
const result = {};
|
|
151
|
+
for (const [key, item] of Object.entries(value)) {
|
|
152
|
+
result[key] = toJsonValue(item);
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
function toJsonValue(value) {
|
|
157
|
+
if (value === null
|
|
158
|
+
|| typeof value === 'string'
|
|
159
|
+
|| typeof value === 'number'
|
|
160
|
+
|| typeof value === 'boolean') {
|
|
161
|
+
return value;
|
|
162
|
+
}
|
|
163
|
+
if (typeof value === 'bigint') {
|
|
164
|
+
return value.toString();
|
|
165
|
+
}
|
|
166
|
+
if (Array.isArray(value)) {
|
|
167
|
+
return value.map(toJsonValue);
|
|
168
|
+
}
|
|
169
|
+
if (typeof value === 'object' && value !== null) {
|
|
170
|
+
return toJsonObject(value);
|
|
171
|
+
}
|
|
172
|
+
return String(value);
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=monitorJsonMetricExporter.js.map
|