@od-oneapp/config 2026.2.2001-canary.1
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/CHANGELOG.md +25 -0
- package/README.md +830 -0
- package/eslint/__tests__/config-structure.test.mjs +61 -0
- package/eslint/base.mjs +350 -0
- package/eslint/expo.mjs +97 -0
- package/eslint/next-test.mjs +43 -0
- package/eslint/next.mjs +74 -0
- package/eslint/node.mjs +106 -0
- package/eslint/react.mjs +313 -0
- package/eslint/rules/__tests__/no-used-underscore-vars.test.mjs +147 -0
- package/eslint/rules/no-used-underscore-vars.mjs +297 -0
- package/eslint/shared/__tests__/common-ignores.test.mjs +19 -0
- package/eslint/shared/common-ignores.mjs +172 -0
- package/eslint/shared/disabled-type-aware-rules.mjs +35 -0
- package/eslint/shared/file-patterns.mjs +124 -0
- package/eslint/shared/node-globals.mjs +50 -0
- package/eslint/storybook.mjs +81 -0
- package/eslint/test.mjs +298 -0
- package/eslint/utils/__tests__/create-validated-config.test.mjs +42 -0
- package/eslint/utils/__tests__/filter-ts-eslint-configs.test.mjs +57 -0
- package/eslint/utils/__tests__/validate-config.test.mjs +104 -0
- package/eslint/utils/create-validated-config.mjs +69 -0
- package/eslint/utils/filter-ts-eslint-configs.mjs +129 -0
- package/eslint/utils/validate-config.mjs +88 -0
- package/package.json +37 -0
- package/prettier/index.mjs +15 -0
- package/stylelint/index.mjs +129 -0
- package/tsdown/README.md +287 -0
- package/tsdown/base.mjs +77 -0
- package/tsdown/browser.mjs +34 -0
- package/tsdown/client.mjs +32 -0
- package/tsdown/dist.mjs +179 -0
- package/tsdown/index.mjs +53 -0
- package/tsdown/node.mjs +39 -0
- package/tsdown/react.mjs +30 -0
- package/typescript/base.json +52 -0
- package/typescript/dist/__tests__/browser-stub.test.d.ts +2 -0
- package/typescript/dist/__tests__/browser-stub.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/browser-stub.test.js +40 -0
- package/typescript/dist/__tests__/browser-stub.test.js.map +1 -0
- package/typescript/dist/__tests__/runtime/lifecycle.test.d.ts +2 -0
- package/typescript/dist/__tests__/runtime/lifecycle.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/runtime/lifecycle.test.js +149 -0
- package/typescript/dist/__tests__/runtime/lifecycle.test.js.map +1 -0
- package/typescript/dist/__tests__/server/abort-support.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/abort-support.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/abort-support.test.js +333 -0
- package/typescript/dist/__tests__/server/abort-support.test.js.map +1 -0
- package/typescript/dist/__tests__/server/batch-processor.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/batch-processor.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/batch-processor.test.js +173 -0
- package/typescript/dist/__tests__/server/batch-processor.test.js.map +1 -0
- package/typescript/dist/__tests__/server/cache.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/cache.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/cache.test.js +343 -0
- package/typescript/dist/__tests__/server/cache.test.js.map +1 -0
- package/typescript/dist/__tests__/server/circular-deps.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/circular-deps.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/circular-deps.test.js +412 -0
- package/typescript/dist/__tests__/server/circular-deps.test.js.map +1 -0
- package/typescript/dist/__tests__/server/claude-code-env.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/claude-code-env.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/claude-code-env.test.js +387 -0
- package/typescript/dist/__tests__/server/claude-code-env.test.js.map +1 -0
- package/typescript/dist/__tests__/server/code-analysis-tool.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/code-analysis-tool.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/code-analysis-tool.test.js +430 -0
- package/typescript/dist/__tests__/server/code-analysis-tool.test.js.map +1 -0
- package/typescript/dist/__tests__/server/code-transformation.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/code-transformation.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/code-transformation.test.js +173 -0
- package/typescript/dist/__tests__/server/code-transformation.test.js.map +1 -0
- package/typescript/dist/__tests__/server/concurrency.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/concurrency.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/concurrency.test.js +31 -0
- package/typescript/dist/__tests__/server/concurrency.test.js.map +1 -0
- package/typescript/dist/__tests__/server/context.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/context.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/context.test.js +483 -0
- package/typescript/dist/__tests__/server/context.test.js.map +1 -0
- package/typescript/dist/__tests__/server/error-handling.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/error-handling.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/error-handling.test.js +68 -0
- package/typescript/dist/__tests__/server/error-handling.test.js.map +1 -0
- package/typescript/dist/__tests__/server/error-utils.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/error-utils.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/error-utils.test.js +268 -0
- package/typescript/dist/__tests__/server/error-utils.test.js.map +1 -0
- package/typescript/dist/__tests__/server/files.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/files.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/files.test.js +160 -0
- package/typescript/dist/__tests__/server/files.test.js.map +1 -0
- package/typescript/dist/__tests__/server/logger.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/logger.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/logger.test.js +412 -0
- package/typescript/dist/__tests__/server/logger.test.js.map +1 -0
- package/typescript/dist/__tests__/server/path-manager.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/path-manager.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/path-manager.test.js +406 -0
- package/typescript/dist/__tests__/server/path-manager.test.js.map +1 -0
- package/typescript/dist/__tests__/server/retry-operations.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/retry-operations.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/retry-operations.test.js +119 -0
- package/typescript/dist/__tests__/server/retry-operations.test.js.map +1 -0
- package/typescript/dist/__tests__/server/retry.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/retry.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/retry.test.js +70 -0
- package/typescript/dist/__tests__/server/retry.test.js.map +1 -0
- package/typescript/dist/__tests__/server/retryable.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/retryable.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/retryable.test.js +23 -0
- package/typescript/dist/__tests__/server/retryable.test.js.map +1 -0
- package/typescript/dist/__tests__/server/scheduler.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/scheduler.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/scheduler.test.js +14 -0
- package/typescript/dist/__tests__/server/scheduler.test.js.map +1 -0
- package/typescript/dist/__tests__/server/security.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/security.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/security.test.js +286 -0
- package/typescript/dist/__tests__/server/security.test.js.map +1 -0
- package/typescript/dist/__tests__/server/session-management.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/session-management.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/session-management.test.js +399 -0
- package/typescript/dist/__tests__/server/session-management.test.js.map +1 -0
- package/typescript/dist/__tests__/server/session-recovery.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/session-recovery.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/session-recovery.test.js +417 -0
- package/typescript/dist/__tests__/server/session-recovery.test.js.map +1 -0
- package/typescript/dist/__tests__/server/session.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/session.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/session.test.js +102 -0
- package/typescript/dist/__tests__/server/session.test.js.map +1 -0
- package/typescript/dist/__tests__/server/simple-tools.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/simple-tools.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/simple-tools.test.js +56 -0
- package/typescript/dist/__tests__/server/simple-tools.test.js.map +1 -0
- package/typescript/dist/__tests__/server/streaming-utilities.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/streaming-utilities.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/streaming-utilities.test.js +338 -0
- package/typescript/dist/__tests__/server/streaming-utilities.test.js.map +1 -0
- package/typescript/dist/__tests__/server/streams.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/streams.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/streams.test.js +282 -0
- package/typescript/dist/__tests__/server/streams.test.js.map +1 -0
- package/typescript/dist/__tests__/server/stringify-advanced.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/stringify-advanced.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/stringify-advanced.test.js +152 -0
- package/typescript/dist/__tests__/server/stringify-advanced.test.js.map +1 -0
- package/typescript/dist/__tests__/server/structured-clone-tool.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/structured-clone-tool.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/structured-clone-tool.test.js +751 -0
- package/typescript/dist/__tests__/server/structured-clone-tool.test.js.map +1 -0
- package/typescript/dist/__tests__/server/structured-clone.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/structured-clone.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/structured-clone.test.js +305 -0
- package/typescript/dist/__tests__/server/structured-clone.test.js.map +1 -0
- package/typescript/dist/__tests__/server/tool-helpers.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/tool-helpers.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/tool-helpers.test.js +51 -0
- package/typescript/dist/__tests__/server/tool-helpers.test.js.map +1 -0
- package/typescript/dist/__tests__/server/validation.test.d.ts +2 -0
- package/typescript/dist/__tests__/server/validation.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/server/validation.test.js +585 -0
- package/typescript/dist/__tests__/server/validation.test.js.map +1 -0
- package/typescript/dist/__tests__/shared/constants.test.d.ts +2 -0
- package/typescript/dist/__tests__/shared/constants.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/shared/constants.test.js +11 -0
- package/typescript/dist/__tests__/shared/constants.test.js.map +1 -0
- package/typescript/dist/__tests__/shared/environment.test.d.ts +2 -0
- package/typescript/dist/__tests__/shared/environment.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/shared/environment.test.js +279 -0
- package/typescript/dist/__tests__/shared/environment.test.js.map +1 -0
- package/typescript/dist/__tests__/shared/stringify.test.d.ts +2 -0
- package/typescript/dist/__tests__/shared/stringify.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/shared/stringify.test.js +171 -0
- package/typescript/dist/__tests__/shared/stringify.test.js.map +1 -0
- package/typescript/dist/__tests__/shared/timeout.test.d.ts +2 -0
- package/typescript/dist/__tests__/shared/timeout.test.d.ts.map +1 -0
- package/typescript/dist/__tests__/shared/timeout.test.js +262 -0
- package/typescript/dist/__tests__/shared/timeout.test.js.map +1 -0
- package/typescript/dist/src/App.d.ts +3 -0
- package/typescript/dist/src/App.d.ts.map +1 -0
- package/typescript/dist/src/App.js +27 -0
- package/typescript/dist/src/App.js.map +1 -0
- package/typescript/dist/src/components/charts/BenchmarkCard.d.ts +12 -0
- package/typescript/dist/src/components/charts/BenchmarkCard.d.ts.map +1 -0
- package/typescript/dist/src/components/charts/BenchmarkCard.js +23 -0
- package/typescript/dist/src/components/charts/BenchmarkCard.js.map +1 -0
- package/typescript/dist/src/components/charts/ComparisonBar.d.ts +11 -0
- package/typescript/dist/src/components/charts/ComparisonBar.d.ts.map +1 -0
- package/typescript/dist/src/components/charts/ComparisonBar.js +34 -0
- package/typescript/dist/src/components/charts/ComparisonBar.js.map +1 -0
- package/typescript/dist/src/components/charts/PercentileGauge.d.ts +10 -0
- package/typescript/dist/src/components/charts/PercentileGauge.d.ts.map +1 -0
- package/typescript/dist/src/components/charts/PercentileGauge.js +68 -0
- package/typescript/dist/src/components/charts/PercentileGauge.js.map +1 -0
- package/typescript/dist/src/components/charts/index.d.ts +4 -0
- package/typescript/dist/src/components/charts/index.d.ts.map +1 -0
- package/typescript/dist/src/components/charts/index.js +4 -0
- package/typescript/dist/src/components/charts/index.js.map +1 -0
- package/typescript/dist/src/components/filters/FilterPanel.d.ts +9 -0
- package/typescript/dist/src/components/filters/FilterPanel.d.ts.map +1 -0
- package/typescript/dist/src/components/filters/FilterPanel.js +42 -0
- package/typescript/dist/src/components/filters/FilterPanel.js.map +1 -0
- package/typescript/dist/src/components/filters/index.d.ts +2 -0
- package/typescript/dist/src/components/filters/index.d.ts.map +1 -0
- package/typescript/dist/src/components/filters/index.js +2 -0
- package/typescript/dist/src/components/filters/index.js.map +1 -0
- package/typescript/dist/src/components/ui/Button.d.ts +8 -0
- package/typescript/dist/src/components/ui/Button.d.ts.map +1 -0
- package/typescript/dist/src/components/ui/Button.js +16 -0
- package/typescript/dist/src/components/ui/Button.js.map +1 -0
- package/typescript/dist/src/components/ui/Card.d.ts +14 -0
- package/typescript/dist/src/components/ui/Card.d.ts.map +1 -0
- package/typescript/dist/src/components/ui/Card.js +27 -0
- package/typescript/dist/src/components/ui/Card.js.map +1 -0
- package/typescript/dist/src/components/ui/Input.d.ts +9 -0
- package/typescript/dist/src/components/ui/Input.d.ts.map +1 -0
- package/typescript/dist/src/components/ui/Input.js +13 -0
- package/typescript/dist/src/components/ui/Input.js.map +1 -0
- package/typescript/dist/src/components/ui/Select.d.ts +14 -0
- package/typescript/dist/src/components/ui/Select.d.ts.map +1 -0
- package/typescript/dist/src/components/ui/Select.js +13 -0
- package/typescript/dist/src/components/ui/Select.js.map +1 -0
- package/typescript/dist/src/components/ui/index.d.ts +5 -0
- package/typescript/dist/src/components/ui/index.d.ts.map +1 -0
- package/typescript/dist/src/components/ui/index.js +5 -0
- package/typescript/dist/src/components/ui/index.js.map +1 -0
- package/typescript/dist/src/index.d.ts +4 -0
- package/typescript/dist/src/index.d.ts.map +1 -0
- package/typescript/dist/src/index.js +4 -0
- package/typescript/dist/src/index.js.map +1 -0
- package/typescript/dist/src/layouts/MainLayout.d.ts +2 -0
- package/typescript/dist/src/layouts/MainLayout.d.ts.map +1 -0
- package/typescript/dist/src/layouts/MainLayout.js +45 -0
- package/typescript/dist/src/layouts/MainLayout.js.map +1 -0
- package/typescript/dist/src/lib/api/benchmarks.d.ts +87 -0
- package/typescript/dist/src/lib/api/benchmarks.d.ts.map +1 -0
- package/typescript/dist/src/lib/api/benchmarks.js +274 -0
- package/typescript/dist/src/lib/api/benchmarks.js.map +1 -0
- package/typescript/dist/src/lib/api/index.d.ts +2 -0
- package/typescript/dist/src/lib/api/index.d.ts.map +1 -0
- package/typescript/dist/src/lib/api/index.js +2 -0
- package/typescript/dist/src/lib/api/index.js.map +1 -0
- package/typescript/dist/src/lib/mock-data/accident-benchmarks.d.ts +33 -0
- package/typescript/dist/src/lib/mock-data/accident-benchmarks.d.ts.map +1 -0
- package/typescript/dist/src/lib/mock-data/accident-benchmarks.js +124 -0
- package/typescript/dist/src/lib/mock-data/accident-benchmarks.js.map +1 -0
- package/typescript/dist/src/lib/mock-data/basic-life-benchmarks.d.ts +47 -0
- package/typescript/dist/src/lib/mock-data/basic-life-benchmarks.d.ts.map +1 -0
- package/typescript/dist/src/lib/mock-data/basic-life-benchmarks.js +83 -0
- package/typescript/dist/src/lib/mock-data/basic-life-benchmarks.js.map +1 -0
- package/typescript/dist/src/lib/mock-data/critical-illness-benchmarks.d.ts +39 -0
- package/typescript/dist/src/lib/mock-data/critical-illness-benchmarks.d.ts.map +1 -0
- package/typescript/dist/src/lib/mock-data/critical-illness-benchmarks.js +130 -0
- package/typescript/dist/src/lib/mock-data/critical-illness-benchmarks.js.map +1 -0
- package/typescript/dist/src/lib/mock-data/dental-benchmarks.d.ts +42 -0
- package/typescript/dist/src/lib/mock-data/dental-benchmarks.d.ts.map +1 -0
- package/typescript/dist/src/lib/mock-data/dental-benchmarks.js +137 -0
- package/typescript/dist/src/lib/mock-data/dental-benchmarks.js.map +1 -0
- package/typescript/dist/src/lib/mock-data/hospital-indemnity-benchmarks.d.ts +37 -0
- package/typescript/dist/src/lib/mock-data/hospital-indemnity-benchmarks.d.ts.map +1 -0
- package/typescript/dist/src/lib/mock-data/hospital-indemnity-benchmarks.js +128 -0
- package/typescript/dist/src/lib/mock-data/hospital-indemnity-benchmarks.js.map +1 -0
- package/typescript/dist/src/lib/mock-data/index.d.ts +3 -0
- package/typescript/dist/src/lib/mock-data/index.d.ts.map +1 -0
- package/typescript/dist/src/lib/mock-data/index.js +3 -0
- package/typescript/dist/src/lib/mock-data/index.js.map +1 -0
- package/typescript/dist/src/lib/mock-data/ltd-benchmarks.d.ts +59 -0
- package/typescript/dist/src/lib/mock-data/ltd-benchmarks.d.ts.map +1 -0
- package/typescript/dist/src/lib/mock-data/ltd-benchmarks.js +127 -0
- package/typescript/dist/src/lib/mock-data/ltd-benchmarks.js.map +1 -0
- package/typescript/dist/src/lib/mock-data/std-benchmarks.d.ts +51 -0
- package/typescript/dist/src/lib/mock-data/std-benchmarks.d.ts.map +1 -0
- package/typescript/dist/src/lib/mock-data/std-benchmarks.js +111 -0
- package/typescript/dist/src/lib/mock-data/std-benchmarks.js.map +1 -0
- package/typescript/dist/src/lib/mock-data/vision-benchmarks.d.ts +32 -0
- package/typescript/dist/src/lib/mock-data/vision-benchmarks.d.ts.map +1 -0
- package/typescript/dist/src/lib/mock-data/vision-benchmarks.js +151 -0
- package/typescript/dist/src/lib/mock-data/vision-benchmarks.js.map +1 -0
- package/typescript/dist/src/lib/mock-data/voluntary-life-benchmarks.d.ts +39 -0
- package/typescript/dist/src/lib/mock-data/voluntary-life-benchmarks.d.ts.map +1 -0
- package/typescript/dist/src/lib/mock-data/voluntary-life-benchmarks.js +97 -0
- package/typescript/dist/src/lib/mock-data/voluntary-life-benchmarks.js.map +1 -0
- package/typescript/dist/src/lib/transformers/api-to-internal.d.ts +42 -0
- package/typescript/dist/src/lib/transformers/api-to-internal.d.ts.map +1 -0
- package/typescript/dist/src/lib/transformers/api-to-internal.js +206 -0
- package/typescript/dist/src/lib/transformers/api-to-internal.js.map +1 -0
- package/typescript/dist/src/lib/transformers/index.d.ts +2 -0
- package/typescript/dist/src/lib/transformers/index.d.ts.map +1 -0
- package/typescript/dist/src/lib/transformers/index.js +2 -0
- package/typescript/dist/src/lib/transformers/index.js.map +1 -0
- package/typescript/dist/src/lib/types/accident.d.ts +46 -0
- package/typescript/dist/src/lib/types/accident.d.ts.map +1 -0
- package/typescript/dist/src/lib/types/accident.js +223 -0
- package/typescript/dist/src/lib/types/accident.js.map +1 -0
- package/typescript/dist/src/lib/types/api-schema.d.ts +476 -0
- package/typescript/dist/src/lib/types/api-schema.d.ts.map +1 -0
- package/typescript/dist/src/lib/types/api-schema.js +2 -0
- package/typescript/dist/src/lib/types/api-schema.js.map +1 -0
- package/typescript/dist/src/lib/types/basic-life.d.ts +30 -0
- package/typescript/dist/src/lib/types/basic-life.d.ts.map +1 -0
- package/typescript/dist/src/lib/types/basic-life.js +137 -0
- package/typescript/dist/src/lib/types/basic-life.js.map +1 -0
- package/typescript/dist/src/lib/types/common.d.ts +99 -0
- package/typescript/dist/src/lib/types/common.d.ts.map +1 -0
- package/typescript/dist/src/lib/types/common.js +29 -0
- package/typescript/dist/src/lib/types/common.js.map +1 -0
- package/typescript/dist/src/lib/types/critical-illness.d.ts +52 -0
- package/typescript/dist/src/lib/types/critical-illness.d.ts.map +1 -0
- package/typescript/dist/src/lib/types/critical-illness.js +254 -0
- package/typescript/dist/src/lib/types/critical-illness.js.map +1 -0
- package/typescript/dist/src/lib/types/dental.d.ts +41 -0
- package/typescript/dist/src/lib/types/dental.d.ts.map +1 -0
- package/typescript/dist/src/lib/types/dental.js +188 -0
- package/typescript/dist/src/lib/types/dental.js.map +1 -0
- package/typescript/dist/src/lib/types/hospital-indemnity.d.ts +41 -0
- package/typescript/dist/src/lib/types/hospital-indemnity.d.ts.map +1 -0
- package/typescript/dist/src/lib/types/hospital-indemnity.js +191 -0
- package/typescript/dist/src/lib/types/hospital-indemnity.js.map +1 -0
- package/typescript/dist/src/lib/types/index.d.ts +12 -0
- package/typescript/dist/src/lib/types/index.d.ts.map +1 -0
- package/typescript/dist/src/lib/types/index.js +12 -0
- package/typescript/dist/src/lib/types/index.js.map +1 -0
- package/typescript/dist/src/lib/types/ltd.d.ts +42 -0
- package/typescript/dist/src/lib/types/ltd.d.ts.map +1 -0
- package/typescript/dist/src/lib/types/ltd.js +200 -0
- package/typescript/dist/src/lib/types/ltd.js.map +1 -0
- package/typescript/dist/src/lib/types/std.d.ts +31 -0
- package/typescript/dist/src/lib/types/std.d.ts.map +1 -0
- package/typescript/dist/src/lib/types/std.js +144 -0
- package/typescript/dist/src/lib/types/std.js.map +1 -0
- package/typescript/dist/src/lib/types/vision.d.ts +31 -0
- package/typescript/dist/src/lib/types/vision.d.ts.map +1 -0
- package/typescript/dist/src/lib/types/vision.js +129 -0
- package/typescript/dist/src/lib/types/vision.js.map +1 -0
- package/typescript/dist/src/lib/types/voluntary-life.d.ts +33 -0
- package/typescript/dist/src/lib/types/voluntary-life.d.ts.map +1 -0
- package/typescript/dist/src/lib/types/voluntary-life.js +144 -0
- package/typescript/dist/src/lib/types/voluntary-life.js.map +1 -0
- package/typescript/dist/src/lib/utils/format.d.ts +11 -0
- package/typescript/dist/src/lib/utils/format.d.ts.map +1 -0
- package/typescript/dist/src/lib/utils/format.js +95 -0
- package/typescript/dist/src/lib/utils/format.js.map +1 -0
- package/typescript/dist/src/lib/utils/index.d.ts +2 -0
- package/typescript/dist/src/lib/utils/index.d.ts.map +1 -0
- package/typescript/dist/src/lib/utils/index.js +2 -0
- package/typescript/dist/src/lib/utils/index.js.map +1 -0
- package/typescript/dist/src/main.d.ts +2 -0
- package/typescript/dist/src/main.d.ts.map +1 -0
- package/typescript/dist/src/main.js +20 -0
- package/typescript/dist/src/main.js.map +1 -0
- package/typescript/dist/src/pages/AccidentComparison.d.ts +2 -0
- package/typescript/dist/src/pages/AccidentComparison.d.ts.map +1 -0
- package/typescript/dist/src/pages/AccidentComparison.js +56 -0
- package/typescript/dist/src/pages/AccidentComparison.js.map +1 -0
- package/typescript/dist/src/pages/AccidentExplorer.d.ts +2 -0
- package/typescript/dist/src/pages/AccidentExplorer.d.ts.map +1 -0
- package/typescript/dist/src/pages/AccidentExplorer.js +29 -0
- package/typescript/dist/src/pages/AccidentExplorer.js.map +1 -0
- package/typescript/dist/src/pages/BasicLifeComparison.d.ts +2 -0
- package/typescript/dist/src/pages/BasicLifeComparison.d.ts.map +1 -0
- package/typescript/dist/src/pages/BasicLifeComparison.js +59 -0
- package/typescript/dist/src/pages/BasicLifeComparison.js.map +1 -0
- package/typescript/dist/src/pages/BasicLifeExplorer.d.ts +2 -0
- package/typescript/dist/src/pages/BasicLifeExplorer.d.ts.map +1 -0
- package/typescript/dist/src/pages/BasicLifeExplorer.js +29 -0
- package/typescript/dist/src/pages/BasicLifeExplorer.js.map +1 -0
- package/typescript/dist/src/pages/CriticalIllnessComparison.d.ts +2 -0
- package/typescript/dist/src/pages/CriticalIllnessComparison.d.ts.map +1 -0
- package/typescript/dist/src/pages/CriticalIllnessComparison.js +56 -0
- package/typescript/dist/src/pages/CriticalIllnessComparison.js.map +1 -0
- package/typescript/dist/src/pages/CriticalIllnessExplorer.d.ts +2 -0
- package/typescript/dist/src/pages/CriticalIllnessExplorer.d.ts.map +1 -0
- package/typescript/dist/src/pages/CriticalIllnessExplorer.js +29 -0
- package/typescript/dist/src/pages/CriticalIllnessExplorer.js.map +1 -0
- package/typescript/dist/src/pages/Dashboard.d.ts +2 -0
- package/typescript/dist/src/pages/Dashboard.d.ts.map +1 -0
- package/typescript/dist/src/pages/Dashboard.js +8 -0
- package/typescript/dist/src/pages/Dashboard.js.map +1 -0
- package/typescript/dist/src/pages/DentalComparison.d.ts +2 -0
- package/typescript/dist/src/pages/DentalComparison.d.ts.map +1 -0
- package/typescript/dist/src/pages/DentalComparison.js +64 -0
- package/typescript/dist/src/pages/DentalComparison.js.map +1 -0
- package/typescript/dist/src/pages/DentalExplorer.d.ts +2 -0
- package/typescript/dist/src/pages/DentalExplorer.d.ts.map +1 -0
- package/typescript/dist/src/pages/DentalExplorer.js +29 -0
- package/typescript/dist/src/pages/DentalExplorer.js.map +1 -0
- package/typescript/dist/src/pages/HospitalIndemnityComparison.d.ts +2 -0
- package/typescript/dist/src/pages/HospitalIndemnityComparison.d.ts.map +1 -0
- package/typescript/dist/src/pages/HospitalIndemnityComparison.js +53 -0
- package/typescript/dist/src/pages/HospitalIndemnityComparison.js.map +1 -0
- package/typescript/dist/src/pages/HospitalIndemnityExplorer.d.ts +2 -0
- package/typescript/dist/src/pages/HospitalIndemnityExplorer.d.ts.map +1 -0
- package/typescript/dist/src/pages/HospitalIndemnityExplorer.js +29 -0
- package/typescript/dist/src/pages/HospitalIndemnityExplorer.js.map +1 -0
- package/typescript/dist/src/pages/LTDComparison.d.ts +2 -0
- package/typescript/dist/src/pages/LTDComparison.d.ts.map +1 -0
- package/typescript/dist/src/pages/LTDComparison.js +64 -0
- package/typescript/dist/src/pages/LTDComparison.js.map +1 -0
- package/typescript/dist/src/pages/LTDExplorer.d.ts +2 -0
- package/typescript/dist/src/pages/LTDExplorer.d.ts.map +1 -0
- package/typescript/dist/src/pages/LTDExplorer.js +29 -0
- package/typescript/dist/src/pages/LTDExplorer.js.map +1 -0
- package/typescript/dist/src/pages/STDComparison.d.ts +2 -0
- package/typescript/dist/src/pages/STDComparison.d.ts.map +1 -0
- package/typescript/dist/src/pages/STDComparison.js +58 -0
- package/typescript/dist/src/pages/STDComparison.js.map +1 -0
- package/typescript/dist/src/pages/STDExplorer.d.ts +2 -0
- package/typescript/dist/src/pages/STDExplorer.d.ts.map +1 -0
- package/typescript/dist/src/pages/STDExplorer.js +29 -0
- package/typescript/dist/src/pages/STDExplorer.js.map +1 -0
- package/typescript/dist/src/pages/VisionComparison.d.ts +2 -0
- package/typescript/dist/src/pages/VisionComparison.d.ts.map +1 -0
- package/typescript/dist/src/pages/VisionComparison.js +64 -0
- package/typescript/dist/src/pages/VisionComparison.js.map +1 -0
- package/typescript/dist/src/pages/VisionExplorer.d.ts +2 -0
- package/typescript/dist/src/pages/VisionExplorer.d.ts.map +1 -0
- package/typescript/dist/src/pages/VisionExplorer.js +29 -0
- package/typescript/dist/src/pages/VisionExplorer.js.map +1 -0
- package/typescript/dist/src/pages/VoluntaryLifeComparison.d.ts +2 -0
- package/typescript/dist/src/pages/VoluntaryLifeComparison.d.ts.map +1 -0
- package/typescript/dist/src/pages/VoluntaryLifeComparison.js +51 -0
- package/typescript/dist/src/pages/VoluntaryLifeComparison.js.map +1 -0
- package/typescript/dist/src/pages/VoluntaryLifeExplorer.d.ts +2 -0
- package/typescript/dist/src/pages/VoluntaryLifeExplorer.d.ts.map +1 -0
- package/typescript/dist/src/pages/VoluntaryLifeExplorer.js +29 -0
- package/typescript/dist/src/pages/VoluntaryLifeExplorer.js.map +1 -0
- package/typescript/dist/src/runtime/index.d.ts +2 -0
- package/typescript/dist/src/runtime/index.d.ts.map +1 -0
- package/typescript/dist/src/runtime/index.js +2 -0
- package/typescript/dist/src/runtime/index.js.map +1 -0
- package/typescript/dist/src/runtime/lifecycle.d.ts +16 -0
- package/typescript/dist/src/runtime/lifecycle.d.ts.map +1 -0
- package/typescript/dist/src/runtime/lifecycle.js +50 -0
- package/typescript/dist/src/runtime/lifecycle.js.map +1 -0
- package/typescript/dist/src/server/abort-support.d.ts +20 -0
- package/typescript/dist/src/server/abort-support.d.ts.map +1 -0
- package/typescript/dist/src/server/abort-support.js +101 -0
- package/typescript/dist/src/server/abort-support.js.map +1 -0
- package/typescript/dist/src/server/advanced-memory-monitor.d.ts +189 -0
- package/typescript/dist/src/server/advanced-memory-monitor.d.ts.map +1 -0
- package/typescript/dist/src/server/advanced-memory-monitor.js +718 -0
- package/typescript/dist/src/server/advanced-memory-monitor.js.map +1 -0
- package/typescript/dist/src/server/architecture-detector.d.ts +72 -0
- package/typescript/dist/src/server/architecture-detector.d.ts.map +1 -0
- package/typescript/dist/src/server/architecture-detector.js +282 -0
- package/typescript/dist/src/server/architecture-detector.js.map +1 -0
- package/typescript/dist/src/server/batch-processor-tool.d.ts +69 -0
- package/typescript/dist/src/server/batch-processor-tool.d.ts.map +1 -0
- package/typescript/dist/src/server/batch-processor-tool.js +651 -0
- package/typescript/dist/src/server/batch-processor-tool.js.map +1 -0
- package/typescript/dist/src/server/batch-processor.d.ts +73 -0
- package/typescript/dist/src/server/batch-processor.d.ts.map +1 -0
- package/typescript/dist/src/server/batch-processor.js +264 -0
- package/typescript/dist/src/server/batch-processor.js.map +1 -0
- package/typescript/dist/src/server/browser-stub.d.ts +18 -0
- package/typescript/dist/src/server/browser-stub.d.ts.map +1 -0
- package/typescript/dist/src/server/browser-stub.js +21 -0
- package/typescript/dist/src/server/browser-stub.js.map +1 -0
- package/typescript/dist/src/server/cache.d.ts +92 -0
- package/typescript/dist/src/server/cache.d.ts.map +1 -0
- package/typescript/dist/src/server/cache.js +217 -0
- package/typescript/dist/src/server/cache.js.map +1 -0
- package/typescript/dist/src/server/circular-deps.d.ts +85 -0
- package/typescript/dist/src/server/circular-deps.d.ts.map +1 -0
- package/typescript/dist/src/server/circular-deps.js +331 -0
- package/typescript/dist/src/server/circular-deps.js.map +1 -0
- package/typescript/dist/src/server/claude-code-env.d.ts +50 -0
- package/typescript/dist/src/server/claude-code-env.d.ts.map +1 -0
- package/typescript/dist/src/server/claude-code-env.js +116 -0
- package/typescript/dist/src/server/claude-code-env.js.map +1 -0
- package/typescript/dist/src/server/code-analysis-tool.d.ts +79 -0
- package/typescript/dist/src/server/code-analysis-tool.d.ts.map +1 -0
- package/typescript/dist/src/server/code-analysis-tool.js +94 -0
- package/typescript/dist/src/server/code-analysis-tool.js.map +1 -0
- package/typescript/dist/src/server/code-analysis.d.ts +16 -0
- package/typescript/dist/src/server/code-analysis.d.ts.map +1 -0
- package/typescript/dist/src/server/code-analysis.js +462 -0
- package/typescript/dist/src/server/code-analysis.js.map +1 -0
- package/typescript/dist/src/server/code-transformation.d.ts +141 -0
- package/typescript/dist/src/server/code-transformation.d.ts.map +1 -0
- package/typescript/dist/src/server/code-transformation.js +918 -0
- package/typescript/dist/src/server/code-transformation.js.map +1 -0
- package/typescript/dist/src/server/comprehensive-code-analysis.d.ts +77 -0
- package/typescript/dist/src/server/comprehensive-code-analysis.d.ts.map +1 -0
- package/typescript/dist/src/server/comprehensive-code-analysis.js +613 -0
- package/typescript/dist/src/server/comprehensive-code-analysis.js.map +1 -0
- package/typescript/dist/src/server/concurrency.d.ts +5 -0
- package/typescript/dist/src/server/concurrency.d.ts.map +1 -0
- package/typescript/dist/src/server/concurrency.js +20 -0
- package/typescript/dist/src/server/concurrency.js.map +1 -0
- package/typescript/dist/src/server/context-manager.d.ts +97 -0
- package/typescript/dist/src/server/context-manager.d.ts.map +1 -0
- package/typescript/dist/src/server/context-manager.js +410 -0
- package/typescript/dist/src/server/context-manager.js.map +1 -0
- package/typescript/dist/src/server/context-session-manager.d.ts +47 -0
- package/typescript/dist/src/server/context-session-manager.d.ts.map +1 -0
- package/typescript/dist/src/server/context-session-manager.js +594 -0
- package/typescript/dist/src/server/context-session-manager.js.map +1 -0
- package/typescript/dist/src/server/context.d.ts +66 -0
- package/typescript/dist/src/server/context.d.ts.map +1 -0
- package/typescript/dist/src/server/context.js +275 -0
- package/typescript/dist/src/server/context.js.map +1 -0
- package/typescript/dist/src/server/dependency-analyzer.d.ts +100 -0
- package/typescript/dist/src/server/dependency-analyzer.d.ts.map +1 -0
- package/typescript/dist/src/server/dependency-analyzer.js +1117 -0
- package/typescript/dist/src/server/dependency-analyzer.js.map +1 -0
- package/typescript/dist/src/server/error-handling.d.ts +106 -0
- package/typescript/dist/src/server/error-handling.d.ts.map +1 -0
- package/typescript/dist/src/server/error-handling.js +363 -0
- package/typescript/dist/src/server/error-handling.js.map +1 -0
- package/typescript/dist/src/server/file-discovery.d.ts +60 -0
- package/typescript/dist/src/server/file-discovery.d.ts.map +1 -0
- package/typescript/dist/src/server/file-discovery.js +282 -0
- package/typescript/dist/src/server/file-discovery.js.map +1 -0
- package/typescript/dist/src/server/file-streaming.d.ts +152 -0
- package/typescript/dist/src/server/file-streaming.d.ts.map +1 -0
- package/typescript/dist/src/server/file-streaming.js +627 -0
- package/typescript/dist/src/server/file-streaming.js.map +1 -0
- package/typescript/dist/src/server/files.d.ts +100 -0
- package/typescript/dist/src/server/files.d.ts.map +1 -0
- package/typescript/dist/src/server/files.js +609 -0
- package/typescript/dist/src/server/files.js.map +1 -0
- package/typescript/dist/src/server/index.d.ts +54 -0
- package/typescript/dist/src/server/index.d.ts.map +1 -0
- package/typescript/dist/src/server/index.js +54 -0
- package/typescript/dist/src/server/index.js.map +1 -0
- package/typescript/dist/src/server/logger.d.ts +95 -0
- package/typescript/dist/src/server/logger.d.ts.map +1 -0
- package/typescript/dist/src/server/logger.js +271 -0
- package/typescript/dist/src/server/logger.js.map +1 -0
- package/typescript/dist/src/server/memory-aware-cache.d.ts +169 -0
- package/typescript/dist/src/server/memory-aware-cache.d.ts.map +1 -0
- package/typescript/dist/src/server/memory-aware-cache.js +655 -0
- package/typescript/dist/src/server/memory-aware-cache.js.map +1 -0
- package/typescript/dist/src/server/memory-monitor-tool.d.ts +46 -0
- package/typescript/dist/src/server/memory-monitor-tool.d.ts.map +1 -0
- package/typescript/dist/src/server/memory-monitor-tool.js +381 -0
- package/typescript/dist/src/server/memory-monitor-tool.js.map +1 -0
- package/typescript/dist/src/server/memory-monitor.d.ts +79 -0
- package/typescript/dist/src/server/memory-monitor.d.ts.map +1 -0
- package/typescript/dist/src/server/memory-monitor.js +333 -0
- package/typescript/dist/src/server/memory-monitor.js.map +1 -0
- package/typescript/dist/src/server/optimization-engine.d.ts +68 -0
- package/typescript/dist/src/server/optimization-engine.d.ts.map +1 -0
- package/typescript/dist/src/server/optimization-engine.js +728 -0
- package/typescript/dist/src/server/optimization-engine.js.map +1 -0
- package/typescript/dist/src/server/path-manager.d.ts +46 -0
- package/typescript/dist/src/server/path-manager.d.ts.map +1 -0
- package/typescript/dist/src/server/path-manager.js +155 -0
- package/typescript/dist/src/server/path-manager.js.map +1 -0
- package/typescript/dist/src/server/pattern-analyzer.d.ts +69 -0
- package/typescript/dist/src/server/pattern-analyzer.d.ts.map +1 -0
- package/typescript/dist/src/server/pattern-analyzer.js +497 -0
- package/typescript/dist/src/server/pattern-analyzer.js.map +1 -0
- package/typescript/dist/src/server/performance-observer.d.ts +61 -0
- package/typescript/dist/src/server/performance-observer.d.ts.map +1 -0
- package/typescript/dist/src/server/performance-observer.js +394 -0
- package/typescript/dist/src/server/performance-observer.js.map +1 -0
- package/typescript/dist/src/server/performance.d.ts +121 -0
- package/typescript/dist/src/server/performance.d.ts.map +1 -0
- package/typescript/dist/src/server/performance.js +520 -0
- package/typescript/dist/src/server/performance.js.map +1 -0
- package/typescript/dist/src/server/report-generator.d.ts +131 -0
- package/typescript/dist/src/server/report-generator.d.ts.map +1 -0
- package/typescript/dist/src/server/report-generator.js +1158 -0
- package/typescript/dist/src/server/report-generator.js.map +1 -0
- package/typescript/dist/src/server/resource-lifecycle-manager.d.ts +231 -0
- package/typescript/dist/src/server/resource-lifecycle-manager.d.ts.map +1 -0
- package/typescript/dist/src/server/resource-lifecycle-manager.js +839 -0
- package/typescript/dist/src/server/resource-lifecycle-manager.js.map +1 -0
- package/typescript/dist/src/server/retry-operations.d.ts +59 -0
- package/typescript/dist/src/server/retry-operations.d.ts.map +1 -0
- package/typescript/dist/src/server/retry-operations.js +68 -0
- package/typescript/dist/src/server/retry-operations.js.map +1 -0
- package/typescript/dist/src/server/retry.d.ts +18 -0
- package/typescript/dist/src/server/retry.d.ts.map +1 -0
- package/typescript/dist/src/server/retry.js +44 -0
- package/typescript/dist/src/server/retry.js.map +1 -0
- package/typescript/dist/src/server/retryable.d.ts +2 -0
- package/typescript/dist/src/server/retryable.d.ts.map +1 -0
- package/typescript/dist/src/server/retryable.js +21 -0
- package/typescript/dist/src/server/retryable.js.map +1 -0
- package/typescript/dist/src/server/scheduler.d.ts +4 -0
- package/typescript/dist/src/server/scheduler.d.ts.map +1 -0
- package/typescript/dist/src/server/scheduler.js +21 -0
- package/typescript/dist/src/server/scheduler.js.map +1 -0
- package/typescript/dist/src/server/security-scanner.d.ts +59 -0
- package/typescript/dist/src/server/security-scanner.d.ts.map +1 -0
- package/typescript/dist/src/server/security-scanner.js +915 -0
- package/typescript/dist/src/server/security-scanner.js.map +1 -0
- package/typescript/dist/src/server/security.d.ts +25 -0
- package/typescript/dist/src/server/security.d.ts.map +1 -0
- package/typescript/dist/src/server/security.js +298 -0
- package/typescript/dist/src/server/security.js.map +1 -0
- package/typescript/dist/src/server/session-management.d.ts +103 -0
- package/typescript/dist/src/server/session-management.d.ts.map +1 -0
- package/typescript/dist/src/server/session-management.js +149 -0
- package/typescript/dist/src/server/session-management.js.map +1 -0
- package/typescript/dist/src/server/session-recovery.d.ts +91 -0
- package/typescript/dist/src/server/session-recovery.d.ts.map +1 -0
- package/typescript/dist/src/server/session-recovery.js +384 -0
- package/typescript/dist/src/server/session-recovery.js.map +1 -0
- package/typescript/dist/src/server/session.d.ts +18 -0
- package/typescript/dist/src/server/session.d.ts.map +1 -0
- package/typescript/dist/src/server/session.js +46 -0
- package/typescript/dist/src/server/session.js.map +1 -0
- package/typescript/dist/src/server/simple-tools.d.ts +15 -0
- package/typescript/dist/src/server/simple-tools.d.ts.map +1 -0
- package/typescript/dist/src/server/simple-tools.js +15 -0
- package/typescript/dist/src/server/simple-tools.js.map +1 -0
- package/typescript/dist/src/server/streaming-utilities.d.ts +107 -0
- package/typescript/dist/src/server/streaming-utilities.d.ts.map +1 -0
- package/typescript/dist/src/server/streaming-utilities.js +822 -0
- package/typescript/dist/src/server/streaming-utilities.js.map +1 -0
- package/typescript/dist/src/server/streams.d.ts +48 -0
- package/typescript/dist/src/server/streams.d.ts.map +1 -0
- package/typescript/dist/src/server/streams.js +489 -0
- package/typescript/dist/src/server/streams.js.map +1 -0
- package/typescript/dist/src/server/stringify-advanced.d.ts +31 -0
- package/typescript/dist/src/server/stringify-advanced.d.ts.map +1 -0
- package/typescript/dist/src/server/stringify-advanced.js +183 -0
- package/typescript/dist/src/server/stringify-advanced.js.map +1 -0
- package/typescript/dist/src/server/structured-clone-tool.d.ts +101 -0
- package/typescript/dist/src/server/structured-clone-tool.d.ts.map +1 -0
- package/typescript/dist/src/server/structured-clone-tool.js +450 -0
- package/typescript/dist/src/server/structured-clone-tool.js.map +1 -0
- package/typescript/dist/src/server/structured-clone.d.ts +59 -0
- package/typescript/dist/src/server/structured-clone.d.ts.map +1 -0
- package/typescript/dist/src/server/structured-clone.js +307 -0
- package/typescript/dist/src/server/structured-clone.js.map +1 -0
- package/typescript/dist/src/server/test-runner.d.ts +78 -0
- package/typescript/dist/src/server/test-runner.d.ts.map +1 -0
- package/typescript/dist/src/server/test-runner.js +1024 -0
- package/typescript/dist/src/server/test-runner.js.map +1 -0
- package/typescript/dist/src/server/tool-helpers.d.ts +6 -0
- package/typescript/dist/src/server/tool-helpers.d.ts.map +1 -0
- package/typescript/dist/src/server/tool-helpers.js +27 -0
- package/typescript/dist/src/server/tool-helpers.js.map +1 -0
- package/typescript/dist/src/server/validation.d.ts +79 -0
- package/typescript/dist/src/server/validation.d.ts.map +1 -0
- package/typescript/dist/src/server/validation.js +613 -0
- package/typescript/dist/src/server/validation.js.map +1 -0
- package/typescript/dist/src/server/worker-pool.d.ts +87 -0
- package/typescript/dist/src/server/worker-pool.d.ts.map +1 -0
- package/typescript/dist/src/server/worker-pool.js +586 -0
- package/typescript/dist/src/server/worker-pool.js.map +1 -0
- package/typescript/dist/src/server/worker-threads.d.ts +95 -0
- package/typescript/dist/src/server/worker-threads.d.ts.map +1 -0
- package/typescript/dist/src/server/worker-threads.js +1074 -0
- package/typescript/dist/src/server/worker-threads.js.map +1 -0
- package/typescript/dist/src/server/workflow-orchestrator.d.ts +122 -0
- package/typescript/dist/src/server/workflow-orchestrator.d.ts.map +1 -0
- package/typescript/dist/src/server/workflow-orchestrator.js +2131 -0
- package/typescript/dist/src/server/workflow-orchestrator.js.map +1 -0
- package/typescript/dist/src/server/worktree-manager.d.ts +70 -0
- package/typescript/dist/src/server/worktree-manager.d.ts.map +1 -0
- package/typescript/dist/src/server/worktree-manager.js +741 -0
- package/typescript/dist/src/server/worktree-manager.js.map +1 -0
- package/typescript/dist/src/shared/constants.d.ts +5 -0
- package/typescript/dist/src/shared/constants.d.ts.map +1 -0
- package/typescript/dist/src/shared/constants.js +5 -0
- package/typescript/dist/src/shared/constants.js.map +1 -0
- package/typescript/dist/src/shared/entity-config.d.ts +76 -0
- package/typescript/dist/src/shared/entity-config.d.ts.map +1 -0
- package/typescript/dist/src/shared/entity-config.js +2 -0
- package/typescript/dist/src/shared/entity-config.js.map +1 -0
- package/typescript/dist/src/shared/environment.d.ts +18 -0
- package/typescript/dist/src/shared/environment.d.ts.map +1 -0
- package/typescript/dist/src/shared/environment.js +39 -0
- package/typescript/dist/src/shared/environment.js.map +1 -0
- package/typescript/dist/src/shared/index.d.ts +6 -0
- package/typescript/dist/src/shared/index.d.ts.map +1 -0
- package/typescript/dist/src/shared/index.js +6 -0
- package/typescript/dist/src/shared/index.js.map +1 -0
- package/typescript/dist/src/shared/stringify.d.ts +16 -0
- package/typescript/dist/src/shared/stringify.d.ts.map +1 -0
- package/typescript/dist/src/shared/stringify.js +195 -0
- package/typescript/dist/src/shared/stringify.js.map +1 -0
- package/typescript/dist/src/shared/timeout.d.ts +27 -0
- package/typescript/dist/src/shared/timeout.d.ts.map +1 -0
- package/typescript/dist/src/shared/timeout.js +196 -0
- package/typescript/dist/src/shared/timeout.js.map +1 -0
- package/typescript/dist/src/types/mcp.d.ts +23 -0
- package/typescript/dist/src/types/mcp.d.ts.map +1 -0
- package/typescript/dist/src/types/mcp.js +2 -0
- package/typescript/dist/src/types/mcp.js.map +1 -0
- package/typescript/dist/tsconfig.tsbuildinfo +1 -0
- package/typescript/dist/vite.config.d.ts +3 -0
- package/typescript/dist/vite.config.d.ts.map +1 -0
- package/typescript/dist/vite.config.js +12 -0
- package/typescript/dist/vite.config.js.map +1 -0
- package/typescript/nextjs.json +17 -0
- package/typescript/node.json +10 -0
- package/typescript/react-native.json +8 -0
- package/typescript/react.json +12 -0
|
@@ -0,0 +1,2131 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { basename, extname, join } from 'node:path';
|
|
4
|
+
import { logInfo, logWarn } from '@repo/shared/logs';
|
|
5
|
+
import { safeThrowIfAborted } from './abort-support';
|
|
6
|
+
import { BatchProcessorEngine } from './batch-processor';
|
|
7
|
+
import { runWithContext } from './context';
|
|
8
|
+
import { getGlobalMemoryMonitor } from './memory-monitor';
|
|
9
|
+
import { getSessionRecoveryManager } from './session-recovery';
|
|
10
|
+
import { enhancedClone, isStructuredCloneAvailable } from './structured-clone';
|
|
11
|
+
import { ok, runTool } from './tool-helpers';
|
|
12
|
+
import { validateFilePath, validateSessionId } from './validation';
|
|
13
|
+
import { worktreeManagerTool } from './worktree-manager';
|
|
14
|
+
const SESSION_CONTEXTS = new Map();
|
|
15
|
+
function asString(value) {
|
|
16
|
+
return typeof value === 'string' ? value : undefined;
|
|
17
|
+
}
|
|
18
|
+
function asNumber(value) {
|
|
19
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
20
|
+
}
|
|
21
|
+
function asBoolean(value) {
|
|
22
|
+
return typeof value === 'boolean' ? value : undefined;
|
|
23
|
+
}
|
|
24
|
+
function asRecord(value) {
|
|
25
|
+
return value && typeof value === 'object' ? value : undefined;
|
|
26
|
+
}
|
|
27
|
+
function asStringArray(value) {
|
|
28
|
+
if (!Array.isArray(value))
|
|
29
|
+
return undefined;
|
|
30
|
+
const strings = [];
|
|
31
|
+
for (const item of value) {
|
|
32
|
+
if (typeof item !== 'string')
|
|
33
|
+
return undefined;
|
|
34
|
+
strings.push(item);
|
|
35
|
+
}
|
|
36
|
+
return strings;
|
|
37
|
+
}
|
|
38
|
+
function parseFirstContentJson(response) {
|
|
39
|
+
const first = response.content[0];
|
|
40
|
+
if (!first)
|
|
41
|
+
return {};
|
|
42
|
+
try {
|
|
43
|
+
return JSON.parse(first.text);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function normalizeSessionCheckpointErrors(value) {
|
|
50
|
+
if (!Array.isArray(value))
|
|
51
|
+
return [];
|
|
52
|
+
const errors = [];
|
|
53
|
+
for (const item of value) {
|
|
54
|
+
const record = asRecord(item);
|
|
55
|
+
if (!record)
|
|
56
|
+
continue;
|
|
57
|
+
const file = asString(record['file']);
|
|
58
|
+
const error = asString(record['error']);
|
|
59
|
+
const timestamp = asNumber(record['timestamp']);
|
|
60
|
+
if (!file || !error || timestamp === undefined)
|
|
61
|
+
continue;
|
|
62
|
+
errors.push({ file, error, timestamp });
|
|
63
|
+
}
|
|
64
|
+
return errors;
|
|
65
|
+
}
|
|
66
|
+
function isAnalysisContext(value) {
|
|
67
|
+
const record = asRecord(value);
|
|
68
|
+
if (!record)
|
|
69
|
+
return false;
|
|
70
|
+
return (typeof record['packagePath'] === 'string' &&
|
|
71
|
+
typeof record['isWorktree'] === 'boolean' &&
|
|
72
|
+
typeof record['isVercelProject'] === 'boolean' &&
|
|
73
|
+
typeof record['hasNextJs'] === 'boolean' &&
|
|
74
|
+
typeof record['hasTypeScript'] === 'boolean');
|
|
75
|
+
}
|
|
76
|
+
export const workflowOrchestratorTool = {
|
|
77
|
+
name: 'workflow_orchestrator',
|
|
78
|
+
description: 'Orchestrates code quality analysis workflows replacing 27 core functions',
|
|
79
|
+
inputSchema: {
|
|
80
|
+
type: 'object',
|
|
81
|
+
properties: {
|
|
82
|
+
action: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
enum: [
|
|
85
|
+
'detectWorktree',
|
|
86
|
+
'setupContext',
|
|
87
|
+
'createSession',
|
|
88
|
+
'checkMCPAvailability',
|
|
89
|
+
'prepareExecutionContext',
|
|
90
|
+
'storeExecutionContext',
|
|
91
|
+
'getExecutionContext',
|
|
92
|
+
'validateMainAgentContext',
|
|
93
|
+
'detectCallContext',
|
|
94
|
+
'confirmInBranchRisks',
|
|
95
|
+
'createBackupBranch',
|
|
96
|
+
'validateBranchStrategy',
|
|
97
|
+
'executeBackupPlan',
|
|
98
|
+
'discoverFiles',
|
|
99
|
+
'countWordTargets',
|
|
100
|
+
'detectPatterns',
|
|
101
|
+
'removeWords',
|
|
102
|
+
'centralizeMocks',
|
|
103
|
+
'modernizeES2023',
|
|
104
|
+
'analyzeUtilization',
|
|
105
|
+
'generateDependencyIndex',
|
|
106
|
+
'runModernization',
|
|
107
|
+
'checkMemoryPressure',
|
|
108
|
+
'performCleanup',
|
|
109
|
+
'getUserConfirmation',
|
|
110
|
+
'completeAnalysis',
|
|
111
|
+
'logToFile',
|
|
112
|
+
'contextualAnalysis',
|
|
113
|
+
'safeWorkflow',
|
|
114
|
+
'branchAwareExecution',
|
|
115
|
+
'sessionManagedWorkflow',
|
|
116
|
+
'streamFileDiscovery',
|
|
117
|
+
'incrementalAnalysis',
|
|
118
|
+
'loadAnalysisCheckpoint',
|
|
119
|
+
'saveAnalysisCheckpoint',
|
|
120
|
+
'resumeAnalysis',
|
|
121
|
+
'streamBatchProcessing',
|
|
122
|
+
],
|
|
123
|
+
description: 'Workflow action to perform',
|
|
124
|
+
},
|
|
125
|
+
packagePath: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
description: 'Path to the package being analyzed',
|
|
128
|
+
},
|
|
129
|
+
sessionId: {
|
|
130
|
+
type: 'string',
|
|
131
|
+
description: 'Unique session identifier',
|
|
132
|
+
},
|
|
133
|
+
userMessage: {
|
|
134
|
+
type: 'string',
|
|
135
|
+
description: 'Original user message/request',
|
|
136
|
+
},
|
|
137
|
+
options: {
|
|
138
|
+
type: 'object',
|
|
139
|
+
description: 'Configuration options for the workflow',
|
|
140
|
+
},
|
|
141
|
+
files: {
|
|
142
|
+
type: 'array',
|
|
143
|
+
items: { type: 'string' },
|
|
144
|
+
description: 'Array of file paths for processing',
|
|
145
|
+
},
|
|
146
|
+
analysisData: {
|
|
147
|
+
type: 'object',
|
|
148
|
+
description: 'Analysis results data',
|
|
149
|
+
},
|
|
150
|
+
context: {
|
|
151
|
+
type: 'object',
|
|
152
|
+
description: 'Analysis context information',
|
|
153
|
+
},
|
|
154
|
+
agentType: {
|
|
155
|
+
type: 'string',
|
|
156
|
+
enum: ['main', 'subagent'],
|
|
157
|
+
description: 'Type of agent making the call',
|
|
158
|
+
},
|
|
159
|
+
enforceWorktreeOnly: {
|
|
160
|
+
type: 'boolean',
|
|
161
|
+
description: 'Whether to enforce worktree-only policy',
|
|
162
|
+
},
|
|
163
|
+
operation: {
|
|
164
|
+
type: 'string',
|
|
165
|
+
description: 'Operation being performed for risk assessment',
|
|
166
|
+
},
|
|
167
|
+
riskLevel: {
|
|
168
|
+
type: 'string',
|
|
169
|
+
enum: ['low', 'medium', 'high', 'critical'],
|
|
170
|
+
description: 'Risk level of the operation',
|
|
171
|
+
},
|
|
172
|
+
agentName: {
|
|
173
|
+
type: 'string',
|
|
174
|
+
description: 'Name of the agent for backup branch creation',
|
|
175
|
+
},
|
|
176
|
+
affectedFiles: {
|
|
177
|
+
type: 'array',
|
|
178
|
+
items: { type: 'string' },
|
|
179
|
+
description: 'Files that will be affected by the operation',
|
|
180
|
+
},
|
|
181
|
+
calledDirectly: {
|
|
182
|
+
type: 'boolean',
|
|
183
|
+
description: 'Whether the agent was called directly via Task tool',
|
|
184
|
+
},
|
|
185
|
+
userRequestedInBranch: {
|
|
186
|
+
type: 'boolean',
|
|
187
|
+
description: 'Whether user explicitly requested in-branch operation',
|
|
188
|
+
},
|
|
189
|
+
workingDirectory: {
|
|
190
|
+
type: 'string',
|
|
191
|
+
description: 'Preferred working directory (worktree path)',
|
|
192
|
+
},
|
|
193
|
+
signal: {
|
|
194
|
+
description: 'AbortSignal for cancelling the operation',
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
required: ['action'],
|
|
198
|
+
},
|
|
199
|
+
async execute(args) {
|
|
200
|
+
return runTool('workflow_orchestrator', args.action, async () => {
|
|
201
|
+
const { action, packagePath, sessionId, userMessage, options, files, analysisData, context, agentType, enforceWorktreeOnly, operation, riskLevel, agentName, affectedFiles, calledDirectly, userRequestedInBranch, workingDirectory, signal, } = args;
|
|
202
|
+
if (sessionId) {
|
|
203
|
+
const sessionValidation = validateSessionId(sessionId);
|
|
204
|
+
if (!sessionValidation.isValid) {
|
|
205
|
+
throw new Error(`Invalid session ID: ${sessionValidation.error}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (packagePath) {
|
|
209
|
+
const pathValidation = validateFilePath(packagePath, [process.cwd()]);
|
|
210
|
+
if (!pathValidation.isValid) {
|
|
211
|
+
throw new Error(`Invalid package path: ${pathValidation.error}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
safeThrowIfAborted(signal);
|
|
215
|
+
switch (action) {
|
|
216
|
+
case 'validateMainAgentContext': {
|
|
217
|
+
const result = await runWithContext({
|
|
218
|
+
toolName: 'workflow_orchestrator',
|
|
219
|
+
metadata: { action: 'validateMainAgentContext', agentType, enforceWorktreeOnly },
|
|
220
|
+
}, async () => {
|
|
221
|
+
return await validateMainAgentContext(agentType, enforceWorktreeOnly, packagePath, signal);
|
|
222
|
+
});
|
|
223
|
+
return ok(result);
|
|
224
|
+
}
|
|
225
|
+
case 'detectCallContext': {
|
|
226
|
+
const callContext = await detectCallContext(agentType, sessionId);
|
|
227
|
+
return ok(callContext);
|
|
228
|
+
}
|
|
229
|
+
case 'confirmInBranchRisks': {
|
|
230
|
+
if (!operation || !riskLevel) {
|
|
231
|
+
throw new Error('Operation and risk level required for risk confirmation');
|
|
232
|
+
}
|
|
233
|
+
const confirmation = await confirmInBranchRisks(operation, riskLevel, affectedFiles ?? [], userRequestedInBranch);
|
|
234
|
+
return ok(confirmation);
|
|
235
|
+
}
|
|
236
|
+
case 'createBackupBranch': {
|
|
237
|
+
if (!agentName || !operation) {
|
|
238
|
+
throw new Error('Agent name and operation required for backup branch creation');
|
|
239
|
+
}
|
|
240
|
+
const backup = await createBackupBranch(agentName, operation, packagePath);
|
|
241
|
+
return ok(backup);
|
|
242
|
+
}
|
|
243
|
+
case 'validateBranchStrategy': {
|
|
244
|
+
if (!operation) {
|
|
245
|
+
throw new Error('Operation required for branch strategy validation');
|
|
246
|
+
}
|
|
247
|
+
const validation = await validateBranchStrategy(operation, agentType, calledDirectly, userRequestedInBranch);
|
|
248
|
+
return {
|
|
249
|
+
content: [
|
|
250
|
+
{
|
|
251
|
+
type: 'text',
|
|
252
|
+
text: JSON.stringify(validation),
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
case 'detectWorktree': {
|
|
258
|
+
if (!packagePath) {
|
|
259
|
+
throw new Error('Package path required for worktree detection');
|
|
260
|
+
}
|
|
261
|
+
const result = await detectIfInWorktree(packagePath);
|
|
262
|
+
return {
|
|
263
|
+
content: [
|
|
264
|
+
{
|
|
265
|
+
type: 'text',
|
|
266
|
+
text: JSON.stringify({
|
|
267
|
+
isWorktree: result.isWorktree,
|
|
268
|
+
worktreePath: result.worktreePath,
|
|
269
|
+
originalPath: result.originalPath,
|
|
270
|
+
branchName: result.branchName,
|
|
271
|
+
}),
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
case 'setupContext': {
|
|
277
|
+
if (!packagePath) {
|
|
278
|
+
throw new Error('Package path required for context setup');
|
|
279
|
+
}
|
|
280
|
+
const skipWorktreeDetection = asBoolean(options?.skipWorktreeDetection) ?? false;
|
|
281
|
+
const context = await setupAnalysisContext(packagePath, skipWorktreeDetection);
|
|
282
|
+
return {
|
|
283
|
+
content: [
|
|
284
|
+
{
|
|
285
|
+
type: 'text',
|
|
286
|
+
text: JSON.stringify(context),
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
case 'createSession': {
|
|
292
|
+
if (!packagePath || !sessionId) {
|
|
293
|
+
throw new Error('Package path and session ID required for session creation');
|
|
294
|
+
}
|
|
295
|
+
const session = await createOrResumeSession(userMessage ?? '', {
|
|
296
|
+
packagePath,
|
|
297
|
+
sessionId,
|
|
298
|
+
options: options ?? {},
|
|
299
|
+
});
|
|
300
|
+
return {
|
|
301
|
+
content: [
|
|
302
|
+
{
|
|
303
|
+
type: 'text',
|
|
304
|
+
text: JSON.stringify(session),
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
case 'checkMCPAvailability': {
|
|
310
|
+
const availability = await checkMCPToolAvailability();
|
|
311
|
+
return {
|
|
312
|
+
content: [
|
|
313
|
+
{
|
|
314
|
+
type: 'text',
|
|
315
|
+
text: JSON.stringify(availability),
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
case 'prepareExecutionContext': {
|
|
321
|
+
const isMain = agentType === 'main';
|
|
322
|
+
if (isMain) {
|
|
323
|
+
const branch = `agent/quality-${(sessionId ?? 'session').slice(0, 12)}`;
|
|
324
|
+
const baseBranch = options?.baseBranch ?? 'main';
|
|
325
|
+
const targetDirectory = options?.targetDirectory || `/tmp/worktree-${(sessionId ?? 'session').slice(0, 8)}`;
|
|
326
|
+
const created = await worktreeManagerTool.execute({
|
|
327
|
+
action: 'createAnalysisWorktree',
|
|
328
|
+
repositoryPath: packagePath ?? '.',
|
|
329
|
+
worktreeName: `analysis-${(sessionId ?? 'session').slice(0, 8)}`,
|
|
330
|
+
branchName: baseBranch,
|
|
331
|
+
baseBranch,
|
|
332
|
+
targetDirectory,
|
|
333
|
+
sessionId,
|
|
334
|
+
});
|
|
335
|
+
const branched = await worktreeManagerTool.execute({
|
|
336
|
+
action: 'createWorktreeBranch',
|
|
337
|
+
targetDirectory,
|
|
338
|
+
branchName: branch,
|
|
339
|
+
baseBranch,
|
|
340
|
+
sessionId,
|
|
341
|
+
});
|
|
342
|
+
const switched = await worktreeManagerTool.execute({
|
|
343
|
+
action: 'switchWorktreeBranch',
|
|
344
|
+
targetDirectory,
|
|
345
|
+
branchName: branch,
|
|
346
|
+
sessionId,
|
|
347
|
+
});
|
|
348
|
+
const contextPayload = {
|
|
349
|
+
worktreePath: targetDirectory,
|
|
350
|
+
ephemeralBranch: branch,
|
|
351
|
+
baseBranch,
|
|
352
|
+
};
|
|
353
|
+
if (sessionId) {
|
|
354
|
+
SESSION_CONTEXTS.set(sessionId, contextPayload);
|
|
355
|
+
}
|
|
356
|
+
return ok({
|
|
357
|
+
mode: 'worktree',
|
|
358
|
+
worktree: { baseBranch, branch, targetDirectory },
|
|
359
|
+
created,
|
|
360
|
+
branched,
|
|
361
|
+
switched,
|
|
362
|
+
context: contextPayload,
|
|
363
|
+
message: 'Worktree and ephemeral branch prepared for main agent execution',
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
const mutating = options?.mutating === true;
|
|
367
|
+
const allowInBranch = options?.allowInBranch === true;
|
|
368
|
+
if (mutating && !allowInBranch) {
|
|
369
|
+
return {
|
|
370
|
+
content: [
|
|
371
|
+
{
|
|
372
|
+
type: 'text',
|
|
373
|
+
text: JSON.stringify({
|
|
374
|
+
mode: 'in-branch',
|
|
375
|
+
allowed: false,
|
|
376
|
+
reason: 'Mutating operation requires options.allowInBranch=true',
|
|
377
|
+
}),
|
|
378
|
+
},
|
|
379
|
+
],
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
const backupBranch = `backup/${agentName ?? 'subagent'}-${Date.now()}`;
|
|
383
|
+
return {
|
|
384
|
+
content: [
|
|
385
|
+
{
|
|
386
|
+
type: 'text',
|
|
387
|
+
text: JSON.stringify({
|
|
388
|
+
mode: 'in-branch',
|
|
389
|
+
allowed: true,
|
|
390
|
+
backup: mutating
|
|
391
|
+
? {
|
|
392
|
+
required: true,
|
|
393
|
+
branch: backupBranch,
|
|
394
|
+
plan: [
|
|
395
|
+
`git checkout -b ${backupBranch}`,
|
|
396
|
+
'git add -A',
|
|
397
|
+
`git commit -m "Backup before ${agentName ?? 'subagent'} operation"`,
|
|
398
|
+
],
|
|
399
|
+
}
|
|
400
|
+
: { required: false },
|
|
401
|
+
}),
|
|
402
|
+
},
|
|
403
|
+
],
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
case 'storeExecutionContext': {
|
|
407
|
+
if (!sessionId) {
|
|
408
|
+
throw new Error('Session ID required for storing execution context');
|
|
409
|
+
}
|
|
410
|
+
const ctx = {
|
|
411
|
+
worktreePath: asString(options?.worktreePath) ?? asString(options?.targetDirectory) ?? undefined,
|
|
412
|
+
ephemeralBranch: asString(options?.ephemeralBranch),
|
|
413
|
+
baseBranch: asString(options?.baseBranch) ?? 'main',
|
|
414
|
+
};
|
|
415
|
+
SESSION_CONTEXTS.set(sessionId, ctx);
|
|
416
|
+
return ok({ stored: true, sessionId, context: ctx });
|
|
417
|
+
}
|
|
418
|
+
case 'getExecutionContext': {
|
|
419
|
+
if (!sessionId) {
|
|
420
|
+
throw new Error('Session ID required for retrieving execution context');
|
|
421
|
+
}
|
|
422
|
+
const ctx = SESSION_CONTEXTS.get(sessionId) ?? null;
|
|
423
|
+
return ok({ sessionId, context: ctx });
|
|
424
|
+
}
|
|
425
|
+
case 'executeBackupPlan': {
|
|
426
|
+
const targetDir = asString(args.workingDirectory) ?? packagePath ?? process.cwd();
|
|
427
|
+
const backup = await worktreeManagerTool.execute({
|
|
428
|
+
action: 'backupWorktreeState',
|
|
429
|
+
targetDirectory: targetDir,
|
|
430
|
+
sessionId,
|
|
431
|
+
});
|
|
432
|
+
return ok({ executed: true, backup });
|
|
433
|
+
}
|
|
434
|
+
case 'discoverFiles': {
|
|
435
|
+
if (!packagePath || !context) {
|
|
436
|
+
throw new Error('Package path and context required for file discovery');
|
|
437
|
+
}
|
|
438
|
+
if (!isAnalysisContext(context)) {
|
|
439
|
+
throw new Error('Invalid analysis context for file discovery');
|
|
440
|
+
}
|
|
441
|
+
const discoveredFiles = await discoverProjectFiles(packagePath, context, sessionId);
|
|
442
|
+
return {
|
|
443
|
+
content: [
|
|
444
|
+
{
|
|
445
|
+
type: 'text',
|
|
446
|
+
text: JSON.stringify(discoveredFiles),
|
|
447
|
+
},
|
|
448
|
+
],
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
case 'countWordTargets': {
|
|
452
|
+
if (!packagePath) {
|
|
453
|
+
throw new Error('Package path required for word target counting');
|
|
454
|
+
}
|
|
455
|
+
const wordTargets = await countWordRemovalTargets(packagePath);
|
|
456
|
+
return {
|
|
457
|
+
content: [
|
|
458
|
+
{
|
|
459
|
+
type: 'text',
|
|
460
|
+
text: JSON.stringify(wordTargets),
|
|
461
|
+
},
|
|
462
|
+
],
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
case 'detectPatterns': {
|
|
466
|
+
if (!context || !files) {
|
|
467
|
+
throw new Error('Context and files required for pattern detection');
|
|
468
|
+
}
|
|
469
|
+
if (!isAnalysisContext(context)) {
|
|
470
|
+
throw new Error('Invalid analysis context for pattern detection');
|
|
471
|
+
}
|
|
472
|
+
const patterns = await detectArchitecturalPatterns(context, files);
|
|
473
|
+
return {
|
|
474
|
+
content: [
|
|
475
|
+
{
|
|
476
|
+
type: 'text',
|
|
477
|
+
text: JSON.stringify(patterns),
|
|
478
|
+
},
|
|
479
|
+
],
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
case 'checkMemoryPressure': {
|
|
483
|
+
const memoryInfo = getMemoryUsage();
|
|
484
|
+
const highPressure = isMemoryPressureHigh();
|
|
485
|
+
return {
|
|
486
|
+
content: [
|
|
487
|
+
{
|
|
488
|
+
type: 'text',
|
|
489
|
+
text: JSON.stringify({
|
|
490
|
+
memoryUsage: memoryInfo,
|
|
491
|
+
highPressure,
|
|
492
|
+
recommendations: highPressure ? ['Perform cleanup', 'Reduce batch size'] : [],
|
|
493
|
+
}),
|
|
494
|
+
},
|
|
495
|
+
],
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
case 'performCleanup': {
|
|
499
|
+
const cleanupResult = await performMemoryCleanup();
|
|
500
|
+
return {
|
|
501
|
+
content: [
|
|
502
|
+
{
|
|
503
|
+
type: 'text',
|
|
504
|
+
text: JSON.stringify(cleanupResult),
|
|
505
|
+
},
|
|
506
|
+
],
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
case 'getUserConfirmation': {
|
|
510
|
+
const confirmation = await getUserConfirmation();
|
|
511
|
+
return {
|
|
512
|
+
content: [
|
|
513
|
+
{
|
|
514
|
+
type: 'text',
|
|
515
|
+
text: JSON.stringify({
|
|
516
|
+
approved: confirmation,
|
|
517
|
+
message: 'Auto-approved in non-interactive mode',
|
|
518
|
+
}),
|
|
519
|
+
},
|
|
520
|
+
],
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
case 'logToFile': {
|
|
524
|
+
if (!sessionId) {
|
|
525
|
+
throw new Error('Session ID required for logging');
|
|
526
|
+
}
|
|
527
|
+
const logResult = await logToFile(userMessage ?? 'Workflow action executed', sessionId);
|
|
528
|
+
return {
|
|
529
|
+
content: [
|
|
530
|
+
{
|
|
531
|
+
type: 'text',
|
|
532
|
+
text: JSON.stringify(logResult),
|
|
533
|
+
},
|
|
534
|
+
],
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
case 'completeAnalysis': {
|
|
538
|
+
if (!context || !sessionId) {
|
|
539
|
+
throw new Error('Context and session ID required for analysis completion');
|
|
540
|
+
}
|
|
541
|
+
if (!isAnalysisContext(context)) {
|
|
542
|
+
throw new Error('Invalid analysis context for analysis completion');
|
|
543
|
+
}
|
|
544
|
+
const completionResult = await completeAnalysisWorkflow(context, sessionId);
|
|
545
|
+
return {
|
|
546
|
+
content: [
|
|
547
|
+
{
|
|
548
|
+
type: 'text',
|
|
549
|
+
text: JSON.stringify(completionResult),
|
|
550
|
+
},
|
|
551
|
+
],
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
case 'removeWords':
|
|
555
|
+
case 'centralizeMocks':
|
|
556
|
+
case 'modernizeES2023':
|
|
557
|
+
case 'analyzeUtilization':
|
|
558
|
+
case 'generateDependencyIndex':
|
|
559
|
+
case 'runModernization': {
|
|
560
|
+
return {
|
|
561
|
+
content: [
|
|
562
|
+
{
|
|
563
|
+
type: 'text',
|
|
564
|
+
text: JSON.stringify({
|
|
565
|
+
action,
|
|
566
|
+
status: 'pending_implementation',
|
|
567
|
+
message: `${action} will be implemented in Phase 2 - delegating to specialized MCP tools`,
|
|
568
|
+
}),
|
|
569
|
+
},
|
|
570
|
+
],
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
case 'contextualAnalysis': {
|
|
574
|
+
if (!packagePath) {
|
|
575
|
+
throw new Error('Package path required for contextual analysis');
|
|
576
|
+
}
|
|
577
|
+
const contextualResult = await performContextualAnalysis(packagePath, agentType, sessionId, options ?? {}, signal);
|
|
578
|
+
return ok(contextualResult);
|
|
579
|
+
}
|
|
580
|
+
case 'safeWorkflow': {
|
|
581
|
+
if (!operation || !packagePath) {
|
|
582
|
+
throw new Error('Operation and package path required for safe workflow');
|
|
583
|
+
}
|
|
584
|
+
const safeResult = await performSafeWorkflow(operation, packagePath, agentType, riskLevel ?? 'medium', sessionId, signal);
|
|
585
|
+
return ok(safeResult);
|
|
586
|
+
}
|
|
587
|
+
case 'branchAwareExecution': {
|
|
588
|
+
if (!operation || !packagePath) {
|
|
589
|
+
throw new Error('Operation and package path required for branch-aware execution');
|
|
590
|
+
}
|
|
591
|
+
const branchResult = await performBranchAwareExecution(operation, packagePath, agentType, affectedFiles ?? [], sessionId, signal);
|
|
592
|
+
return ok(branchResult);
|
|
593
|
+
}
|
|
594
|
+
case 'sessionManagedWorkflow': {
|
|
595
|
+
if (!packagePath) {
|
|
596
|
+
throw new Error('Package path required for session-managed workflow');
|
|
597
|
+
}
|
|
598
|
+
const sessionResult = await performSessionManagedWorkflow(packagePath, options ?? {}, sessionId, signal);
|
|
599
|
+
return ok(sessionResult);
|
|
600
|
+
}
|
|
601
|
+
case 'streamFileDiscovery': {
|
|
602
|
+
if (!packagePath) {
|
|
603
|
+
throw new Error('Package path required for streaming file discovery');
|
|
604
|
+
}
|
|
605
|
+
const streamResult = await streamFileDiscovery(packagePath, options ?? {}, sessionId, signal);
|
|
606
|
+
return ok(streamResult);
|
|
607
|
+
}
|
|
608
|
+
case 'incrementalAnalysis': {
|
|
609
|
+
if (!packagePath || !files) {
|
|
610
|
+
throw new Error('Package path and files required for incremental analysis');
|
|
611
|
+
}
|
|
612
|
+
const incrementalResult = await performIncrementalAnalysis(packagePath, files, options ?? {}, sessionId, signal);
|
|
613
|
+
return ok(incrementalResult);
|
|
614
|
+
}
|
|
615
|
+
case 'loadAnalysisCheckpoint': {
|
|
616
|
+
if (!sessionId) {
|
|
617
|
+
throw new Error('Session ID required for loading checkpoint');
|
|
618
|
+
}
|
|
619
|
+
const checkpointId = asString(options?.checkpointId);
|
|
620
|
+
const checkpoint = await loadAnalysisCheckpoint(sessionId, checkpointId);
|
|
621
|
+
return ok(checkpoint);
|
|
622
|
+
}
|
|
623
|
+
case 'saveAnalysisCheckpoint': {
|
|
624
|
+
if (!sessionId || !analysisData) {
|
|
625
|
+
throw new Error('Session ID and analysis data required for saving checkpoint');
|
|
626
|
+
}
|
|
627
|
+
const savedCheckpoint = await saveAnalysisCheckpoint(sessionId, analysisData, packagePath, options ?? {});
|
|
628
|
+
return ok(savedCheckpoint);
|
|
629
|
+
}
|
|
630
|
+
case 'resumeAnalysis': {
|
|
631
|
+
if (!sessionId) {
|
|
632
|
+
throw new Error('Session ID required for resuming analysis');
|
|
633
|
+
}
|
|
634
|
+
const checkpointId = asString(options?.checkpointId);
|
|
635
|
+
const resumeResult = await resumeAnalysisFromCheckpoint(sessionId, checkpointId, signal);
|
|
636
|
+
return ok(resumeResult);
|
|
637
|
+
}
|
|
638
|
+
case 'streamBatchProcessing': {
|
|
639
|
+
if (!files) {
|
|
640
|
+
throw new Error('Files required for stream batch processing');
|
|
641
|
+
}
|
|
642
|
+
const batchResult = await performStreamBatchProcessing(files, options ?? {}, sessionId, signal);
|
|
643
|
+
return ok(batchResult);
|
|
644
|
+
}
|
|
645
|
+
case 'saveProgressCheckpoint': {
|
|
646
|
+
if (!sessionId) {
|
|
647
|
+
throw new Error('Session ID required for saving progress checkpoint');
|
|
648
|
+
}
|
|
649
|
+
const progressResult = await saveProgressToCheckpoint(sessionId, options ?? {}, packagePath, workingDirectory, signal);
|
|
650
|
+
return ok(progressResult);
|
|
651
|
+
}
|
|
652
|
+
case 'loadProgressCheckpoint': {
|
|
653
|
+
if (!sessionId) {
|
|
654
|
+
throw new Error('Session ID required for loading progress checkpoint');
|
|
655
|
+
}
|
|
656
|
+
const loadResult = await loadProgressFromCheckpoint(sessionId, options ?? {}, signal);
|
|
657
|
+
return ok(loadResult);
|
|
658
|
+
}
|
|
659
|
+
case 'listRecoverableSessions': {
|
|
660
|
+
const sessionDir = asString(options?.sessionDir);
|
|
661
|
+
const sessionsList = await listAllRecoverableSessions(sessionDir, signal);
|
|
662
|
+
return ok(sessionsList);
|
|
663
|
+
}
|
|
664
|
+
default:
|
|
665
|
+
throw new Error(`Unknown workflow action: ${action}`);
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
},
|
|
669
|
+
};
|
|
670
|
+
async function detectIfInWorktree(packagePath, signal) {
|
|
671
|
+
try {
|
|
672
|
+
safeThrowIfAborted(signal);
|
|
673
|
+
return {
|
|
674
|
+
isWorktree: packagePath.includes('/.git/worktrees/') || packagePath.includes('worktree'),
|
|
675
|
+
worktreePath: packagePath,
|
|
676
|
+
originalPath: packagePath,
|
|
677
|
+
branchName: 'main',
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
catch (error) {
|
|
681
|
+
if (error instanceof Error && error.message.includes('aborted')) {
|
|
682
|
+
throw error;
|
|
683
|
+
}
|
|
684
|
+
return {
|
|
685
|
+
isWorktree: false,
|
|
686
|
+
worktreePath: packagePath,
|
|
687
|
+
originalPath: packagePath,
|
|
688
|
+
branchName: 'unknown',
|
|
689
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
async function setupAnalysisContext(packagePath, skipWorktreeDetection = false, signal) {
|
|
694
|
+
const context = {
|
|
695
|
+
packagePath,
|
|
696
|
+
isWorktree: false,
|
|
697
|
+
isVercelProject: false,
|
|
698
|
+
hasNextJs: false,
|
|
699
|
+
hasTypeScript: false,
|
|
700
|
+
};
|
|
701
|
+
try {
|
|
702
|
+
safeThrowIfAborted(signal);
|
|
703
|
+
if (!skipWorktreeDetection) {
|
|
704
|
+
const worktreeInfo = await detectIfInWorktree(packagePath, signal);
|
|
705
|
+
context.isWorktree = worktreeInfo.isWorktree;
|
|
706
|
+
}
|
|
707
|
+
safeThrowIfAborted(signal);
|
|
708
|
+
try {
|
|
709
|
+
await fs.access(join(packagePath, 'tsconfig.json'));
|
|
710
|
+
context.hasTypeScript = true;
|
|
711
|
+
}
|
|
712
|
+
catch {
|
|
713
|
+
context.hasTypeScript = false;
|
|
714
|
+
}
|
|
715
|
+
context.hasNextJs = packagePath.includes('nextjs') || packagePath.includes('next');
|
|
716
|
+
try {
|
|
717
|
+
await fs.access(join(packagePath, 'vercel.json'));
|
|
718
|
+
context.isVercelProject = true;
|
|
719
|
+
}
|
|
720
|
+
catch {
|
|
721
|
+
try {
|
|
722
|
+
await fs.access(join(packagePath, '.vercel'));
|
|
723
|
+
context.isVercelProject = true;
|
|
724
|
+
}
|
|
725
|
+
catch {
|
|
726
|
+
context.isVercelProject = false;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return context;
|
|
730
|
+
}
|
|
731
|
+
catch (error) {
|
|
732
|
+
if (error instanceof Error && error.message.includes('aborted')) {
|
|
733
|
+
throw error;
|
|
734
|
+
}
|
|
735
|
+
return context;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
async function createOrResumeSession(userMessage, config) {
|
|
739
|
+
const sessionId = config.sessionId || `session-${crypto.randomUUID().substring(0, 8)}`;
|
|
740
|
+
const sessionData = {
|
|
741
|
+
sessionId,
|
|
742
|
+
startTime: Date.now(),
|
|
743
|
+
packagePath: config.packagePath,
|
|
744
|
+
options: config.options ?? {},
|
|
745
|
+
context: await setupAnalysisContext(config.packagePath),
|
|
746
|
+
};
|
|
747
|
+
return isStructuredCloneAvailable()
|
|
748
|
+
? enhancedClone(sessionData, { fallbackToJson: false }).data
|
|
749
|
+
: sessionData;
|
|
750
|
+
}
|
|
751
|
+
async function checkMCPToolAvailability() {
|
|
752
|
+
return {
|
|
753
|
+
available: [
|
|
754
|
+
'memory_monitor',
|
|
755
|
+
'path_manager',
|
|
756
|
+
'architecture_detector',
|
|
757
|
+
'batch_processor',
|
|
758
|
+
'file_discovery',
|
|
759
|
+
'security_scanner',
|
|
760
|
+
'test_runner',
|
|
761
|
+
'report_generator',
|
|
762
|
+
'code_analysis',
|
|
763
|
+
'worktree_manager',
|
|
764
|
+
'context_session_manager',
|
|
765
|
+
'pattern_analyzer',
|
|
766
|
+
'optimization_engine',
|
|
767
|
+
'dependency_analyzer',
|
|
768
|
+
],
|
|
769
|
+
unavailable: [],
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
async function discoverProjectFiles(packagePath, context, sessionId) {
|
|
773
|
+
return {
|
|
774
|
+
totalFiles: 0,
|
|
775
|
+
sourceFiles: [],
|
|
776
|
+
testFiles: [],
|
|
777
|
+
configFiles: [],
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
async function countWordRemovalTargets(packagePath) {
|
|
781
|
+
return {
|
|
782
|
+
totalTargets: 0,
|
|
783
|
+
byWord: {},
|
|
784
|
+
affectedFiles: [],
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
async function detectArchitecturalPatterns(context, files) {
|
|
788
|
+
return {
|
|
789
|
+
frameworks: [],
|
|
790
|
+
patterns: [],
|
|
791
|
+
antiPatterns: [],
|
|
792
|
+
recommendations: [
|
|
793
|
+
{
|
|
794
|
+
description: 'Consider using architectural patterns for better code organization',
|
|
795
|
+
priority: 2,
|
|
796
|
+
},
|
|
797
|
+
],
|
|
798
|
+
detectedFramework: 'generic',
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
function getMemoryUsage() {
|
|
802
|
+
if (typeof process !== 'undefined' && process.memoryUsage) {
|
|
803
|
+
const usage = process.memoryUsage();
|
|
804
|
+
return {
|
|
805
|
+
heapUsed: Math.round(usage.heapUsed / 1024 / 1024),
|
|
806
|
+
heapTotal: Math.round(usage.heapTotal / 1024 / 1024),
|
|
807
|
+
external: Math.round(usage.external / 1024 / 1024),
|
|
808
|
+
rss: Math.round(usage.rss / 1024 / 1024),
|
|
809
|
+
heapUtilization: Math.round((usage.heapUsed / usage.heapTotal) * 100),
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
return {
|
|
813
|
+
heapUsed: 0,
|
|
814
|
+
heapTotal: 0,
|
|
815
|
+
external: 0,
|
|
816
|
+
rss: 0,
|
|
817
|
+
heapUtilization: 0,
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
function isMemoryPressureHigh() {
|
|
821
|
+
const usage = getMemoryUsage();
|
|
822
|
+
const HIGH_MEMORY_THRESHOLD = 3000;
|
|
823
|
+
const HIGH_UTILIZATION_THRESHOLD = 85;
|
|
824
|
+
return (usage.heapUsed > HIGH_MEMORY_THRESHOLD || usage.heapUtilization > HIGH_UTILIZATION_THRESHOLD);
|
|
825
|
+
}
|
|
826
|
+
async function performMemoryCleanup() {
|
|
827
|
+
const memoryBefore = getMemoryUsage();
|
|
828
|
+
if (typeof global !== 'undefined' && global.gc) {
|
|
829
|
+
global.gc();
|
|
830
|
+
}
|
|
831
|
+
const memoryAfter = getMemoryUsage();
|
|
832
|
+
return {
|
|
833
|
+
memoryBefore,
|
|
834
|
+
memoryAfter,
|
|
835
|
+
cleaned: memoryBefore.heapUsed - memoryAfter.heapUsed,
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
async function getUserConfirmation() {
|
|
839
|
+
return true;
|
|
840
|
+
}
|
|
841
|
+
async function logToFile(message, sessionId) {
|
|
842
|
+
return {
|
|
843
|
+
logged: true,
|
|
844
|
+
sessionId,
|
|
845
|
+
message,
|
|
846
|
+
timestamp: new Date().toISOString(),
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
async function completeAnalysisWorkflow(context, sessionId) {
|
|
850
|
+
return {
|
|
851
|
+
sessionId,
|
|
852
|
+
completedAt: new Date().toISOString(),
|
|
853
|
+
context,
|
|
854
|
+
status: 'completed',
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
async function validateMainAgentContext(agentType, enforceWorktreeOnly, packagePath, signal) {
|
|
858
|
+
safeThrowIfAborted(signal);
|
|
859
|
+
if (agentType === 'main' && enforceWorktreeOnly) {
|
|
860
|
+
await detectIfInWorktree(packagePath ?? '.', signal);
|
|
861
|
+
return {
|
|
862
|
+
valid: true,
|
|
863
|
+
agentType: 'main',
|
|
864
|
+
enforceWorktreeOnly: true,
|
|
865
|
+
policy: 'WORKTREE_ONLY_ABSOLUTE',
|
|
866
|
+
message: 'Main agent will create worktree for safe isolation',
|
|
867
|
+
worktreeRequired: true,
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
return {
|
|
871
|
+
valid: true,
|
|
872
|
+
agentType: agentType ?? 'unknown',
|
|
873
|
+
enforceWorktreeOnly: false,
|
|
874
|
+
policy: 'FLEXIBLE',
|
|
875
|
+
message: 'Subagent with flexible branch strategy',
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
async function detectCallContext(agentType, sessionId) {
|
|
879
|
+
const stack = new Error().stack ?? '';
|
|
880
|
+
const stackLines = stack.split('\n');
|
|
881
|
+
const calledFromClaude = stackLines.some(line => line.includes('claude-code-agent'));
|
|
882
|
+
const calledFromTask = stackLines.some(line => line.includes('Task') || line.includes('agent-router'));
|
|
883
|
+
const calledFromScript = stackLines.some(line => line.includes('.mjs') || line.includes('script'));
|
|
884
|
+
const executionContext = {
|
|
885
|
+
isScriptExecution: calledFromScript,
|
|
886
|
+
isTaskExecution: calledFromTask,
|
|
887
|
+
isDirectCall: !calledFromClaude && !calledFromTask,
|
|
888
|
+
hasParentAgent: agentType === 'main',
|
|
889
|
+
};
|
|
890
|
+
return {
|
|
891
|
+
calledByMainAgent: agentType === 'main',
|
|
892
|
+
directCall: agentType !== 'main' && !calledFromTask,
|
|
893
|
+
sessionId: sessionId || `ctx_${Date.now()}`,
|
|
894
|
+
timestamp: new Date().toISOString(),
|
|
895
|
+
contextType: agentType === 'main'
|
|
896
|
+
? 'main_agent_orchestration'
|
|
897
|
+
: calledFromTask
|
|
898
|
+
? 'subagent_task_execution'
|
|
899
|
+
: 'direct_subagent_call',
|
|
900
|
+
executionContext,
|
|
901
|
+
callStack: stackLines.slice(0, 5).map(line => line.trim()),
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
async function confirmInBranchRisks(operation, riskLevel, affectedFiles, userRequestedInBranch) {
|
|
905
|
+
const RISK_MESSAGES = {
|
|
906
|
+
low: 'Low risk operation - primarily documentation or reporting changes',
|
|
907
|
+
medium: 'Medium risk operation - may affect configuration or non-critical files',
|
|
908
|
+
high: 'High risk operation - modifies source code, could break compilation',
|
|
909
|
+
critical: 'Critical risk operation - affects dependencies, build system, or core architecture',
|
|
910
|
+
};
|
|
911
|
+
const riskInfo = {
|
|
912
|
+
operation,
|
|
913
|
+
riskLevel,
|
|
914
|
+
affectedFiles,
|
|
915
|
+
message: RISK_MESSAGES[riskLevel] ?? 'Unknown risk level',
|
|
916
|
+
recommendations: [],
|
|
917
|
+
};
|
|
918
|
+
if (riskLevel === 'high' || riskLevel === 'critical') {
|
|
919
|
+
riskInfo.recommendations = [
|
|
920
|
+
'Backup branch will be created automatically',
|
|
921
|
+
'Compilation validation required after changes',
|
|
922
|
+
'Rollback plan prepared in case of failure',
|
|
923
|
+
'Consider using worktree mode instead for maximum safety',
|
|
924
|
+
];
|
|
925
|
+
}
|
|
926
|
+
const userConfirmed = userRequestedInBranch === true;
|
|
927
|
+
let confirmed;
|
|
928
|
+
const isLowRisk = riskLevel === 'low';
|
|
929
|
+
const isMediumRiskWithConsent = riskLevel === 'medium' && userConfirmed;
|
|
930
|
+
const isHighRiskWithConsent = (riskLevel === 'high' || riskLevel === 'critical') && userConfirmed;
|
|
931
|
+
if (isLowRisk) {
|
|
932
|
+
confirmed = true;
|
|
933
|
+
}
|
|
934
|
+
else if (isMediumRiskWithConsent) {
|
|
935
|
+
confirmed = true;
|
|
936
|
+
}
|
|
937
|
+
else if (isHighRiskWithConsent) {
|
|
938
|
+
confirmed = true;
|
|
939
|
+
}
|
|
940
|
+
else {
|
|
941
|
+
confirmed = false;
|
|
942
|
+
}
|
|
943
|
+
return {
|
|
944
|
+
...riskInfo,
|
|
945
|
+
confirmed,
|
|
946
|
+
userExplicitlyRequested: userConfirmed,
|
|
947
|
+
timestamp: new Date().toISOString(),
|
|
948
|
+
warningShown: true,
|
|
949
|
+
backupRequired: riskLevel === 'high' || riskLevel === 'critical',
|
|
950
|
+
acknowledgedRisks: true,
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
async function createBackupBranch(agentName, operation, packagePath) {
|
|
954
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
955
|
+
const branchName = `${agentName}-backup-${timestamp}`;
|
|
956
|
+
const { exec } = await import('node:child_process');
|
|
957
|
+
const { promisify } = await import('node:util');
|
|
958
|
+
const execAsync = promisify(exec);
|
|
959
|
+
let created = false;
|
|
960
|
+
try {
|
|
961
|
+
if (packagePath) {
|
|
962
|
+
process.chdir(packagePath);
|
|
963
|
+
}
|
|
964
|
+
await execAsync(`git checkout -b ${branchName}`);
|
|
965
|
+
created = true;
|
|
966
|
+
}
|
|
967
|
+
catch (error) {
|
|
968
|
+
logWarn('Failed to create backup branch', {
|
|
969
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
970
|
+
branchName,
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
return {
|
|
974
|
+
backupBranch: branchName,
|
|
975
|
+
created,
|
|
976
|
+
agentName,
|
|
977
|
+
operation,
|
|
978
|
+
timestamp,
|
|
979
|
+
packagePath: packagePath ?? '.',
|
|
980
|
+
commands: [
|
|
981
|
+
`git checkout -b ${branchName}`,
|
|
982
|
+
`git add -A`,
|
|
983
|
+
`git commit -m "Backup before ${agentName} ${operation} operation"`,
|
|
984
|
+
],
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
async function validateBranchStrategy(operation, agentType, calledDirectly, userRequestedInBranch) {
|
|
988
|
+
const OPERATION_RISKS = {
|
|
989
|
+
security_scan: 'low',
|
|
990
|
+
report_generation: 'low',
|
|
991
|
+
test_execution: 'low',
|
|
992
|
+
code_transformation: 'high',
|
|
993
|
+
dependency_updates: 'critical',
|
|
994
|
+
mock_centralization: 'high',
|
|
995
|
+
es2023_modernization: 'high',
|
|
996
|
+
};
|
|
997
|
+
const risk = OPERATION_RISKS[operation] ?? 'medium';
|
|
998
|
+
if (agentType === 'main') {
|
|
999
|
+
return {
|
|
1000
|
+
allowInBranch: false,
|
|
1001
|
+
reason: 'Main agent enforces worktree-only policy',
|
|
1002
|
+
recommendedMode: 'worktree',
|
|
1003
|
+
riskLevel: risk,
|
|
1004
|
+
safe: true,
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
if (calledDirectly && userRequestedInBranch) {
|
|
1008
|
+
const allowInBranch = risk === 'low' || risk === 'medium';
|
|
1009
|
+
return {
|
|
1010
|
+
allowInBranch,
|
|
1011
|
+
reason: allowInBranch
|
|
1012
|
+
? 'Low/medium risk operation approved for in-branch mode'
|
|
1013
|
+
: 'High/critical risk operation requires worktree isolation',
|
|
1014
|
+
recommendedMode: allowInBranch ? 'in-branch' : 'worktree',
|
|
1015
|
+
riskLevel: risk,
|
|
1016
|
+
safe: true,
|
|
1017
|
+
requiresBackup: risk === 'high' || risk === 'critical',
|
|
1018
|
+
requiresConfirmation: true,
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
return {
|
|
1022
|
+
allowInBranch: false,
|
|
1023
|
+
reason: 'Default safety mode - worktree isolation recommended',
|
|
1024
|
+
recommendedMode: 'worktree',
|
|
1025
|
+
riskLevel: risk,
|
|
1026
|
+
safe: true,
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
async function performContextualAnalysis(packagePath, agentType, sessionId, options = {}, signal) {
|
|
1030
|
+
safeThrowIfAborted(signal);
|
|
1031
|
+
try {
|
|
1032
|
+
const context = await setupAnalysisContext(packagePath, false, signal);
|
|
1033
|
+
const executionContextResult = await workflowOrchestratorTool.execute({
|
|
1034
|
+
action: 'prepareExecutionContext',
|
|
1035
|
+
agentType: agentType ?? 'subagent',
|
|
1036
|
+
packagePath,
|
|
1037
|
+
calledDirectly: false,
|
|
1038
|
+
signal,
|
|
1039
|
+
});
|
|
1040
|
+
const executionContext = asRecord(parseFirstContentJson(executionContextResult)) ?? {};
|
|
1041
|
+
const session = await createOrResumeSession('', {
|
|
1042
|
+
packagePath,
|
|
1043
|
+
sessionId,
|
|
1044
|
+
options: options ?? {},
|
|
1045
|
+
});
|
|
1046
|
+
const discovery = await runWithContext({ toolName: 'workflow_orchestrator', metadata: { action: 'discoverFiles' } }, () => discoverProjectFiles(packagePath, context, sessionId));
|
|
1047
|
+
const patterns = await detectArchitecturalPatterns(context, discovery.sourceFiles);
|
|
1048
|
+
const mcpStatus = await checkMCPToolAvailability();
|
|
1049
|
+
return {
|
|
1050
|
+
contextAware: true,
|
|
1051
|
+
sessionId: session.sessionId,
|
|
1052
|
+
context: {
|
|
1053
|
+
analysis: context,
|
|
1054
|
+
execution: executionContext,
|
|
1055
|
+
session: session.context,
|
|
1056
|
+
discovery,
|
|
1057
|
+
patterns,
|
|
1058
|
+
mcpStatus,
|
|
1059
|
+
},
|
|
1060
|
+
recommendations: [
|
|
1061
|
+
...(asBoolean(executionContext['worktreeRequired'])
|
|
1062
|
+
? [
|
|
1063
|
+
{
|
|
1064
|
+
type: 'safety',
|
|
1065
|
+
description: 'Use worktree isolation for this analysis',
|
|
1066
|
+
priority: 1,
|
|
1067
|
+
},
|
|
1068
|
+
]
|
|
1069
|
+
: []),
|
|
1070
|
+
...patterns.recommendations.map((rec) => ({
|
|
1071
|
+
type: 'architectural',
|
|
1072
|
+
description: rec.description,
|
|
1073
|
+
priority: rec.priority ?? 2,
|
|
1074
|
+
})),
|
|
1075
|
+
],
|
|
1076
|
+
nextSteps: [
|
|
1077
|
+
context.isWorktree
|
|
1078
|
+
? 'Continue in current worktree'
|
|
1079
|
+
: 'Consider creating worktree for safety',
|
|
1080
|
+
`Use ${patterns.detectedFramework ?? 'generic'} specific analysis patterns`,
|
|
1081
|
+
mcpStatus.available.length > 0 ? 'MCP tools ready' : 'Some MCP tools unavailable',
|
|
1082
|
+
],
|
|
1083
|
+
completedAt: new Date().toISOString(),
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
catch (error) {
|
|
1087
|
+
return {
|
|
1088
|
+
success: false,
|
|
1089
|
+
error: error instanceof Error ? error.message : 'Unknown error in contextual analysis',
|
|
1090
|
+
partialResults: {
|
|
1091
|
+
packagePath,
|
|
1092
|
+
agentType,
|
|
1093
|
+
sessionId,
|
|
1094
|
+
},
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
async function performSafeWorkflow(operation, packagePath, agentType, riskLevel = 'medium', sessionId, signal) {
|
|
1099
|
+
safeThrowIfAborted(signal);
|
|
1100
|
+
try {
|
|
1101
|
+
const strategy = await validateBranchStrategy(operation, agentType, agentType === 'main', false);
|
|
1102
|
+
let backup;
|
|
1103
|
+
if (strategy.requiresBackup) {
|
|
1104
|
+
backup = await createBackupBranch(agentType ?? 'workflow', operation, packagePath);
|
|
1105
|
+
}
|
|
1106
|
+
let confirmation;
|
|
1107
|
+
if (strategy.requiresConfirmation || riskLevel === 'high' || riskLevel === 'critical') {
|
|
1108
|
+
confirmation = await confirmInBranchRisks(operation, riskLevel, [], false);
|
|
1109
|
+
}
|
|
1110
|
+
const executionContextResult = await workflowOrchestratorTool.execute({
|
|
1111
|
+
action: 'prepareExecutionContext',
|
|
1112
|
+
agentType: agentType ?? 'subagent',
|
|
1113
|
+
packagePath,
|
|
1114
|
+
calledDirectly: strategy.recommendedMode === 'worktree',
|
|
1115
|
+
signal,
|
|
1116
|
+
});
|
|
1117
|
+
const executionContext = asRecord(parseFirstContentJson(executionContextResult)) ?? {};
|
|
1118
|
+
if (sessionId) {
|
|
1119
|
+
SESSION_CONTEXTS.set(sessionId, executionContext);
|
|
1120
|
+
}
|
|
1121
|
+
const memoryInfo = getMemoryUsage();
|
|
1122
|
+
const memoryStatus = {
|
|
1123
|
+
highPressure: isMemoryPressureHigh(),
|
|
1124
|
+
usage: memoryInfo,
|
|
1125
|
+
};
|
|
1126
|
+
return {
|
|
1127
|
+
safeExecution: true,
|
|
1128
|
+
sessionId,
|
|
1129
|
+
operation,
|
|
1130
|
+
strategy,
|
|
1131
|
+
backup: backup
|
|
1132
|
+
? {
|
|
1133
|
+
created: true,
|
|
1134
|
+
branchName: backup.backupBranch,
|
|
1135
|
+
backupId: backup.timestamp,
|
|
1136
|
+
}
|
|
1137
|
+
: { created: false },
|
|
1138
|
+
confirmation: confirmation
|
|
1139
|
+
? {
|
|
1140
|
+
confirmed: confirmation.confirmed,
|
|
1141
|
+
acknowledgedRisks: confirmation.acknowledgedRisks,
|
|
1142
|
+
}
|
|
1143
|
+
: { confirmed: true },
|
|
1144
|
+
executionContext,
|
|
1145
|
+
memoryStatus,
|
|
1146
|
+
readyToExecute: strategy.safe && !memoryStatus.highPressure && (!confirmation || confirmation.confirmed),
|
|
1147
|
+
safeguards: {
|
|
1148
|
+
branchIsolation: strategy.recommendedMode === 'worktree',
|
|
1149
|
+
backupCreated: Boolean(backup),
|
|
1150
|
+
userConfirmed: !confirmation || confirmation.confirmed,
|
|
1151
|
+
memoryMonitored: true,
|
|
1152
|
+
contextTracked: Boolean(sessionId),
|
|
1153
|
+
},
|
|
1154
|
+
preparedAt: new Date().toISOString(),
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
catch (error) {
|
|
1158
|
+
return {
|
|
1159
|
+
success: false,
|
|
1160
|
+
error: error instanceof Error ? error.message : 'Unknown error in safe workflow',
|
|
1161
|
+
operation,
|
|
1162
|
+
riskLevel,
|
|
1163
|
+
failedAt: 'preparation',
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
async function performBranchAwareExecution(operation, packagePath, agentType, affectedFiles = [], sessionId, signal) {
|
|
1168
|
+
safeThrowIfAborted(signal);
|
|
1169
|
+
try {
|
|
1170
|
+
const callContext = await detectCallContext(agentType, sessionId);
|
|
1171
|
+
const mainAgentValidation = await validateMainAgentContext(agentType, agentType === 'main', packagePath, signal);
|
|
1172
|
+
const worktreeStatus = await detectIfInWorktree(packagePath, signal);
|
|
1173
|
+
const executionMode = determineExecutionMode(agentType ?? 'subagent', callContext.calledByMainAgent, worktreeStatus.isWorktree, mainAgentValidation.worktreeRequired || false);
|
|
1174
|
+
let workflowResult;
|
|
1175
|
+
if (executionMode.mode === 'worktree') {
|
|
1176
|
+
const worktreeResult = await worktreeManagerTool.execute({
|
|
1177
|
+
action: worktreeStatus.isWorktree ? 'validateWorktreeStructure' : 'createAnalysisWorktree',
|
|
1178
|
+
packagePath,
|
|
1179
|
+
sessionId,
|
|
1180
|
+
signal,
|
|
1181
|
+
});
|
|
1182
|
+
workflowResult = {
|
|
1183
|
+
mode: 'worktree',
|
|
1184
|
+
worktreeCreated: !worktreeStatus.isWorktree,
|
|
1185
|
+
worktreeStatus: worktreeResult.content,
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
else {
|
|
1189
|
+
workflowResult = {
|
|
1190
|
+
mode: 'in-branch',
|
|
1191
|
+
branchProtection: await createBranchProtection(operation, affectedFiles),
|
|
1192
|
+
riskMitigation: await setupRiskMitigation(operation, packagePath),
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
return {
|
|
1196
|
+
branchAware: true,
|
|
1197
|
+
sessionId,
|
|
1198
|
+
operation,
|
|
1199
|
+
context: {
|
|
1200
|
+
callContext,
|
|
1201
|
+
mainAgentValidation,
|
|
1202
|
+
worktreeStatus,
|
|
1203
|
+
executionMode,
|
|
1204
|
+
affectedFiles,
|
|
1205
|
+
},
|
|
1206
|
+
workflow: workflowResult,
|
|
1207
|
+
recommendations: [
|
|
1208
|
+
...executionMode.warnings.map((warning) => ({
|
|
1209
|
+
type: 'warning',
|
|
1210
|
+
description: warning,
|
|
1211
|
+
priority: 2,
|
|
1212
|
+
})),
|
|
1213
|
+
...(executionMode.mode === 'worktree'
|
|
1214
|
+
? [
|
|
1215
|
+
{
|
|
1216
|
+
type: 'isolation',
|
|
1217
|
+
description: 'Changes isolated in worktree for safety',
|
|
1218
|
+
priority: 1,
|
|
1219
|
+
},
|
|
1220
|
+
]
|
|
1221
|
+
: [
|
|
1222
|
+
{
|
|
1223
|
+
type: 'monitoring',
|
|
1224
|
+
description: 'In-branch execution with enhanced monitoring',
|
|
1225
|
+
priority: 2,
|
|
1226
|
+
},
|
|
1227
|
+
]),
|
|
1228
|
+
],
|
|
1229
|
+
executedAt: new Date().toISOString(),
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1232
|
+
catch (error) {
|
|
1233
|
+
return {
|
|
1234
|
+
success: false,
|
|
1235
|
+
error: error instanceof Error ? error.message : 'Unknown error in branch-aware execution',
|
|
1236
|
+
operation,
|
|
1237
|
+
agentType,
|
|
1238
|
+
affectedFiles: affectedFiles.length,
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
async function performSessionManagedWorkflow(packagePath, options = {}, sessionId, signal) {
|
|
1243
|
+
safeThrowIfAborted(signal);
|
|
1244
|
+
try {
|
|
1245
|
+
const session = await createOrResumeSession('', {
|
|
1246
|
+
packagePath,
|
|
1247
|
+
sessionId,
|
|
1248
|
+
options: options ?? {},
|
|
1249
|
+
});
|
|
1250
|
+
const context = await setupAnalysisContext(packagePath, false, signal);
|
|
1251
|
+
SESSION_CONTEXTS.set(session.sessionId, {
|
|
1252
|
+
packagePath,
|
|
1253
|
+
context,
|
|
1254
|
+
startedAt: new Date().toISOString(),
|
|
1255
|
+
options,
|
|
1256
|
+
});
|
|
1257
|
+
const memoryMonitor = await startMemoryMonitoring(session.sessionId);
|
|
1258
|
+
const cleanupPlan = await setupAutomaticCleanup(session.sessionId, {
|
|
1259
|
+
removeTemporaryFiles: true,
|
|
1260
|
+
clearSessionCache: true,
|
|
1261
|
+
logCompletion: true,
|
|
1262
|
+
});
|
|
1263
|
+
const workflowExecution = {
|
|
1264
|
+
session,
|
|
1265
|
+
context,
|
|
1266
|
+
memoryMonitor,
|
|
1267
|
+
cleanupPlan,
|
|
1268
|
+
managementFeatures: {
|
|
1269
|
+
automaticCleanup: true,
|
|
1270
|
+
memoryMonitoring: true,
|
|
1271
|
+
contextPersistence: true,
|
|
1272
|
+
errorRecovery: true,
|
|
1273
|
+
progressTracking: true,
|
|
1274
|
+
},
|
|
1275
|
+
};
|
|
1276
|
+
await logWorkflowStart(session.sessionId, {
|
|
1277
|
+
operation: 'session_managed_workflow',
|
|
1278
|
+
packagePath,
|
|
1279
|
+
options,
|
|
1280
|
+
features: workflowExecution.managementFeatures,
|
|
1281
|
+
});
|
|
1282
|
+
return {
|
|
1283
|
+
sessionManaged: true,
|
|
1284
|
+
sessionId: session.sessionId,
|
|
1285
|
+
workflow: workflowExecution,
|
|
1286
|
+
capabilities: {
|
|
1287
|
+
contextAware: true,
|
|
1288
|
+
memoryManaged: true,
|
|
1289
|
+
autoCleanup: true,
|
|
1290
|
+
errorRecoverable: true,
|
|
1291
|
+
progressVisible: true,
|
|
1292
|
+
},
|
|
1293
|
+
controls: {
|
|
1294
|
+
pause: () => pauseSession(session.sessionId),
|
|
1295
|
+
resume: () => resumeSession(session.sessionId),
|
|
1296
|
+
cleanup: () => performSessionCleanup(session.sessionId),
|
|
1297
|
+
status: () => getSessionStatus(session.sessionId),
|
|
1298
|
+
},
|
|
1299
|
+
startedAt: new Date().toISOString(),
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
catch (error) {
|
|
1303
|
+
if (sessionId) {
|
|
1304
|
+
await performSessionCleanup(sessionId).catch(() => {
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
return {
|
|
1308
|
+
success: false,
|
|
1309
|
+
error: error instanceof Error ? error.message : 'Unknown error in session-managed workflow',
|
|
1310
|
+
packagePath,
|
|
1311
|
+
sessionId,
|
|
1312
|
+
cleanupAttempted: true,
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
function determineExecutionMode(agentType, calledByMainAgent, inWorktree, requiresWorktree) {
|
|
1317
|
+
const warnings = [];
|
|
1318
|
+
if (agentType === 'main' || requiresWorktree) {
|
|
1319
|
+
return {
|
|
1320
|
+
mode: 'worktree',
|
|
1321
|
+
reason: 'Main agent or high-risk operation requires worktree isolation',
|
|
1322
|
+
warnings,
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
if (calledByMainAgent && !inWorktree) {
|
|
1326
|
+
warnings.push('Called by main agent but not in worktree - creating worktree');
|
|
1327
|
+
return {
|
|
1328
|
+
mode: 'worktree',
|
|
1329
|
+
reason: 'Main agent delegation requires worktree',
|
|
1330
|
+
warnings,
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
if (inWorktree) {
|
|
1334
|
+
return {
|
|
1335
|
+
mode: 'worktree',
|
|
1336
|
+
reason: 'Already in worktree - continuing in isolation',
|
|
1337
|
+
warnings,
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1340
|
+
return {
|
|
1341
|
+
mode: 'in-branch',
|
|
1342
|
+
reason: 'Direct subagent call - in-branch execution with safeguards',
|
|
1343
|
+
warnings,
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
async function createBranchProtection(operation, affectedFiles) {
|
|
1347
|
+
return {
|
|
1348
|
+
enabled: true,
|
|
1349
|
+
operation,
|
|
1350
|
+
affectedFiles,
|
|
1351
|
+
protections: [
|
|
1352
|
+
'Backup created before modifications',
|
|
1353
|
+
'Change tracking enabled',
|
|
1354
|
+
'Rollback capability maintained',
|
|
1355
|
+
'File-level monitoring active',
|
|
1356
|
+
],
|
|
1357
|
+
createdAt: new Date().toISOString(),
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
async function setupRiskMitigation(operation, packagePath) {
|
|
1361
|
+
return {
|
|
1362
|
+
operation,
|
|
1363
|
+
packagePath,
|
|
1364
|
+
mitigations: [
|
|
1365
|
+
'Incremental change application',
|
|
1366
|
+
'Validation at each step',
|
|
1367
|
+
'Early failure detection',
|
|
1368
|
+
'Automatic rollback on critical errors',
|
|
1369
|
+
],
|
|
1370
|
+
monitoringLevel: 'enhanced',
|
|
1371
|
+
setupAt: new Date().toISOString(),
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
async function startMemoryMonitoring(sessionId) {
|
|
1375
|
+
return {
|
|
1376
|
+
sessionId,
|
|
1377
|
+
monitoring: true,
|
|
1378
|
+
thresholds: {
|
|
1379
|
+
warning: '80%',
|
|
1380
|
+
critical: '90%',
|
|
1381
|
+
emergency: '95%',
|
|
1382
|
+
},
|
|
1383
|
+
interval: 30000,
|
|
1384
|
+
startedAt: new Date().toISOString(),
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
async function setupAutomaticCleanup(sessionId, options) {
|
|
1388
|
+
return {
|
|
1389
|
+
sessionId,
|
|
1390
|
+
enabled: true,
|
|
1391
|
+
options,
|
|
1392
|
+
triggers: ['workflow_completion', 'error_termination', 'manual_cleanup', 'session_timeout'],
|
|
1393
|
+
scheduledAt: new Date().toISOString(),
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
async function logWorkflowStart(sessionId, details) {
|
|
1397
|
+
const logEntry = {
|
|
1398
|
+
sessionId,
|
|
1399
|
+
event: 'workflow_start',
|
|
1400
|
+
timestamp: new Date().toISOString(),
|
|
1401
|
+
details,
|
|
1402
|
+
};
|
|
1403
|
+
logInfo('[Workflow Orchestrator]', logEntry);
|
|
1404
|
+
return logEntry;
|
|
1405
|
+
}
|
|
1406
|
+
async function pauseSession(sessionId) {
|
|
1407
|
+
return { sessionId, paused: true, pausedAt: new Date().toISOString() };
|
|
1408
|
+
}
|
|
1409
|
+
async function resumeSession(sessionId) {
|
|
1410
|
+
return { sessionId, resumed: true, resumedAt: new Date().toISOString() };
|
|
1411
|
+
}
|
|
1412
|
+
async function performSessionCleanup(sessionId) {
|
|
1413
|
+
return { sessionId, cleaned: true, cleanedAt: new Date().toISOString() };
|
|
1414
|
+
}
|
|
1415
|
+
async function getSessionStatus(sessionId) {
|
|
1416
|
+
return {
|
|
1417
|
+
sessionId,
|
|
1418
|
+
status: 'active',
|
|
1419
|
+
checkedAt: new Date().toISOString(),
|
|
1420
|
+
uptime: process.uptime() * 1000,
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
function getSessionDirectory(sessionId) {
|
|
1424
|
+
const baseDir = join(tmpdir(), 'claude-agent-sessions');
|
|
1425
|
+
return sessionId ? join(baseDir, sessionId) : baseDir;
|
|
1426
|
+
}
|
|
1427
|
+
async function streamFileDiscovery(packagePath, options = {}, sessionId, signal) {
|
|
1428
|
+
const monitor = getGlobalMemoryMonitor({ enableAutoGC: true });
|
|
1429
|
+
monitor.startMonitoring();
|
|
1430
|
+
const batchSize = asNumber(options.batchSize) ?? 500;
|
|
1431
|
+
const results = [];
|
|
1432
|
+
const errors = [];
|
|
1433
|
+
let processedFiles = 0;
|
|
1434
|
+
const memoryStats = {
|
|
1435
|
+
peakUsageMB: 0,
|
|
1436
|
+
averageUsageMB: 0,
|
|
1437
|
+
gcTriggered: 0,
|
|
1438
|
+
};
|
|
1439
|
+
try {
|
|
1440
|
+
const context = await setupAnalysisContext(packagePath, false, signal);
|
|
1441
|
+
const fileDiscovery = await discoverProjectFiles(packagePath, context, sessionId);
|
|
1442
|
+
const allFiles = [
|
|
1443
|
+
...fileDiscovery.sourceFiles,
|
|
1444
|
+
...fileDiscovery.testFiles,
|
|
1445
|
+
...fileDiscovery.configFiles,
|
|
1446
|
+
];
|
|
1447
|
+
if (allFiles.length === 0) {
|
|
1448
|
+
return {
|
|
1449
|
+
success: true,
|
|
1450
|
+
totalFiles: 0,
|
|
1451
|
+
processedFiles: 0,
|
|
1452
|
+
batchesCompleted: 0,
|
|
1453
|
+
totalBatches: 0,
|
|
1454
|
+
results: [],
|
|
1455
|
+
errors: [],
|
|
1456
|
+
memoryStats,
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
const batchProcessor = new BatchProcessorEngine({
|
|
1460
|
+
batchSize,
|
|
1461
|
+
memoryThreshold: 80,
|
|
1462
|
+
enableGC: true,
|
|
1463
|
+
sessionId,
|
|
1464
|
+
});
|
|
1465
|
+
const processBatch = async (batch, batchIndex, batchSignal) => {
|
|
1466
|
+
safeThrowIfAborted(batchSignal);
|
|
1467
|
+
const batchResults = [];
|
|
1468
|
+
for (const file of batch) {
|
|
1469
|
+
try {
|
|
1470
|
+
const stat = await fs.stat(file);
|
|
1471
|
+
const fileAnalysis = await analyzeFileContent(file, {
|
|
1472
|
+
packagePath: packagePath ?? '.',
|
|
1473
|
+
sessionId: sessionId ?? 'default',
|
|
1474
|
+
batchIndex,
|
|
1475
|
+
signal: batchSignal,
|
|
1476
|
+
});
|
|
1477
|
+
const fileInfo = {
|
|
1478
|
+
path: file,
|
|
1479
|
+
size: stat.size,
|
|
1480
|
+
type: getFileType(file),
|
|
1481
|
+
processed: true,
|
|
1482
|
+
batchIndex,
|
|
1483
|
+
lastModified: stat.mtime.getTime(),
|
|
1484
|
+
analysis: fileAnalysis,
|
|
1485
|
+
};
|
|
1486
|
+
batchResults.push(fileInfo);
|
|
1487
|
+
if (sessionId && batchIndex % 5 === 0) {
|
|
1488
|
+
await updateSessionProgress(sessionId, file, batchResults.length);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
catch (error) {
|
|
1492
|
+
const fileError = new Error(`Analysis failed for ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
1493
|
+
fileError.path = file;
|
|
1494
|
+
fileError.batchIndex = batchIndex;
|
|
1495
|
+
fileError.timestamp = Date.now();
|
|
1496
|
+
errors.push(fileError);
|
|
1497
|
+
batchResults.push({
|
|
1498
|
+
path: file,
|
|
1499
|
+
size: 0,
|
|
1500
|
+
type: 'unknown',
|
|
1501
|
+
processed: false,
|
|
1502
|
+
batchIndex,
|
|
1503
|
+
error: fileError.message,
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
return batchResults;
|
|
1508
|
+
};
|
|
1509
|
+
batchProcessor.onProgress(progress => {
|
|
1510
|
+
processedFiles = progress.processedItems;
|
|
1511
|
+
const currentSnapshot = monitor.getMemoryStats();
|
|
1512
|
+
memoryStats.peakUsageMB = Math.max(memoryStats.peakUsageMB, currentSnapshot.current.heapUsed);
|
|
1513
|
+
});
|
|
1514
|
+
const batchResult = await batchProcessor.process(allFiles, processBatch, signal);
|
|
1515
|
+
results.push(...batchResult.results);
|
|
1516
|
+
errors.push(...batchResult.errors);
|
|
1517
|
+
const finalSnapshot = monitor.getMemoryStats();
|
|
1518
|
+
memoryStats.gcTriggered = finalSnapshot.gcHistory.length;
|
|
1519
|
+
memoryStats.averageUsageMB = memoryStats.peakUsageMB * 0.7;
|
|
1520
|
+
return {
|
|
1521
|
+
success: batchResult.success,
|
|
1522
|
+
totalFiles: allFiles.length,
|
|
1523
|
+
processedFiles: batchResult.progress.processedItems,
|
|
1524
|
+
batchesCompleted: batchResult.progress.completedBatches,
|
|
1525
|
+
totalBatches: batchResult.progress.totalBatches,
|
|
1526
|
+
results,
|
|
1527
|
+
errors,
|
|
1528
|
+
memoryStats,
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
catch (error) {
|
|
1532
|
+
errors.push(error instanceof Error ? error : new Error(String(error)));
|
|
1533
|
+
return {
|
|
1534
|
+
success: false,
|
|
1535
|
+
totalFiles: 0,
|
|
1536
|
+
processedFiles,
|
|
1537
|
+
batchesCompleted: 0,
|
|
1538
|
+
totalBatches: 0,
|
|
1539
|
+
results,
|
|
1540
|
+
errors,
|
|
1541
|
+
memoryStats,
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
finally {
|
|
1545
|
+
monitor.stopMonitoring();
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
async function performIncrementalAnalysis(packagePath, files, options = {}, sessionId, signal) {
|
|
1549
|
+
const checkpointInterval = asNumber(options.checkpointInterval) ?? 100;
|
|
1550
|
+
const batchSize = asNumber(options.batchSize) ?? 50;
|
|
1551
|
+
let checkpoint = null;
|
|
1552
|
+
let startIndex = 0;
|
|
1553
|
+
if (sessionId) {
|
|
1554
|
+
try {
|
|
1555
|
+
checkpoint = await loadAnalysisCheckpoint(sessionId);
|
|
1556
|
+
if (checkpoint) {
|
|
1557
|
+
startIndex = checkpoint.processedFiles.length;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
catch (_error) {
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
const remainingFiles = files.slice(startIndex);
|
|
1564
|
+
const results = checkpoint?.analysisResults
|
|
1565
|
+
? Object.values(checkpoint.analysisResults)
|
|
1566
|
+
: [];
|
|
1567
|
+
const errors = checkpoint?.errors ?? [];
|
|
1568
|
+
try {
|
|
1569
|
+
let processedCount = startIndex;
|
|
1570
|
+
const batchCount = Math.ceil(startIndex / batchSize);
|
|
1571
|
+
const batchProcessor = new BatchProcessorEngine({
|
|
1572
|
+
batchSize,
|
|
1573
|
+
memoryThreshold: 75,
|
|
1574
|
+
enableGC: true,
|
|
1575
|
+
sessionId: sessionId || `incremental_${Date.now()}`,
|
|
1576
|
+
});
|
|
1577
|
+
const processBatch = async (batch, batchIndex) => {
|
|
1578
|
+
const batchResults = [];
|
|
1579
|
+
for (const file of batch) {
|
|
1580
|
+
safeThrowIfAborted(signal);
|
|
1581
|
+
try {
|
|
1582
|
+
let analysisResult;
|
|
1583
|
+
try {
|
|
1584
|
+
const stats = await fs.stat(file);
|
|
1585
|
+
const extension = extname(file);
|
|
1586
|
+
analysisResult = {
|
|
1587
|
+
file,
|
|
1588
|
+
analyzed: true,
|
|
1589
|
+
timestamp: Date.now(),
|
|
1590
|
+
batchIndex: batchCount + batchIndex,
|
|
1591
|
+
fileStats: {
|
|
1592
|
+
size: stats.size,
|
|
1593
|
+
extension,
|
|
1594
|
+
isDirectory: stats.isDirectory(),
|
|
1595
|
+
lastModified: stats.mtime.toISOString(),
|
|
1596
|
+
},
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1599
|
+
catch (fileError) {
|
|
1600
|
+
analysisResult = {
|
|
1601
|
+
file,
|
|
1602
|
+
analyzed: false,
|
|
1603
|
+
error: fileError instanceof Error ? fileError.message : 'Unknown file error',
|
|
1604
|
+
timestamp: Date.now(),
|
|
1605
|
+
batchIndex: batchCount + batchIndex,
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1608
|
+
batchResults.push(analysisResult);
|
|
1609
|
+
processedCount++;
|
|
1610
|
+
if (sessionId && processedCount % checkpointInterval === 0) {
|
|
1611
|
+
await saveAnalysisCheckpoint(sessionId, {
|
|
1612
|
+
processedFiles: files.slice(0, processedCount),
|
|
1613
|
+
results: [...results, ...batchResults],
|
|
1614
|
+
currentBatch: batchCount + batchIndex,
|
|
1615
|
+
}, packagePath, options);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
catch (error) {
|
|
1619
|
+
errors.push(error instanceof Error ? error : new Error(String(error)));
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
return batchResults;
|
|
1623
|
+
};
|
|
1624
|
+
const batchResult = await batchProcessor.process(remainingFiles, processBatch, signal);
|
|
1625
|
+
results.push(...batchResult.results);
|
|
1626
|
+
if (sessionId) {
|
|
1627
|
+
await saveAnalysisCheckpoint(sessionId, {
|
|
1628
|
+
processedFiles: files.slice(0, processedCount),
|
|
1629
|
+
results,
|
|
1630
|
+
currentBatch: batchResult.progress.completedBatches,
|
|
1631
|
+
completed: true,
|
|
1632
|
+
}, packagePath, options);
|
|
1633
|
+
}
|
|
1634
|
+
return {
|
|
1635
|
+
success: batchResult.success,
|
|
1636
|
+
totalFiles: files.length,
|
|
1637
|
+
processedFiles: processedCount,
|
|
1638
|
+
batchesCompleted: batchResult.progress.completedBatches,
|
|
1639
|
+
totalBatches: batchResult.progress.totalBatches,
|
|
1640
|
+
results,
|
|
1641
|
+
errors: [...errors, ...batchResult.errors],
|
|
1642
|
+
checkpointId: checkpoint?.checkpointId,
|
|
1643
|
+
memoryStats: {
|
|
1644
|
+
peakUsageMB: batchResult.metrics.memoryPeak,
|
|
1645
|
+
averageUsageMB: batchResult.metrics.memoryPeak * 0.7,
|
|
1646
|
+
gcTriggered: batchResult.metrics.gcTriggerCount,
|
|
1647
|
+
},
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
catch (error) {
|
|
1651
|
+
errors.push(error instanceof Error ? error : new Error(String(error)));
|
|
1652
|
+
return {
|
|
1653
|
+
success: false,
|
|
1654
|
+
totalFiles: files.length,
|
|
1655
|
+
processedFiles: startIndex,
|
|
1656
|
+
batchesCompleted: 0,
|
|
1657
|
+
totalBatches: 0,
|
|
1658
|
+
results,
|
|
1659
|
+
errors,
|
|
1660
|
+
memoryStats: { peakUsageMB: 0, averageUsageMB: 0, gcTriggered: 0 },
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
async function loadAnalysisCheckpoint(sessionId, checkpointId) {
|
|
1665
|
+
try {
|
|
1666
|
+
const sessionDir = getSessionDirectory(sessionId);
|
|
1667
|
+
const checkpointFile = checkpointId
|
|
1668
|
+
? join(sessionDir, `checkpoint_${checkpointId}.json`)
|
|
1669
|
+
: join(sessionDir, 'latest_checkpoint.json');
|
|
1670
|
+
const data = await fs.readFile(checkpointFile, 'utf-8');
|
|
1671
|
+
return JSON.parse(data);
|
|
1672
|
+
}
|
|
1673
|
+
catch (_error) {
|
|
1674
|
+
return null;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
async function saveAnalysisCheckpoint(sessionId, analysisData, packagePath, options = {}) {
|
|
1678
|
+
try {
|
|
1679
|
+
const sessionDir = getSessionDirectory(sessionId);
|
|
1680
|
+
await fs.mkdir(sessionDir, { recursive: true });
|
|
1681
|
+
const checkpointId = asString(options.checkpointId) ?? `checkpoint_${Date.now()}`;
|
|
1682
|
+
const analysisResults = Array.isArray(analysisData.results)
|
|
1683
|
+
? { items: analysisData.results }
|
|
1684
|
+
: (asRecord(analysisData.results) ?? {});
|
|
1685
|
+
const checkpoint = {
|
|
1686
|
+
sessionId,
|
|
1687
|
+
checkpointId,
|
|
1688
|
+
timestamp: Date.now(),
|
|
1689
|
+
totalFiles: analysisData.totalFiles ?? 0,
|
|
1690
|
+
processedFiles: analysisData.processedFiles ?? [],
|
|
1691
|
+
currentBatch: analysisData.currentBatch ?? 0,
|
|
1692
|
+
totalBatches: analysisData.totalBatches ?? 0,
|
|
1693
|
+
analysisResults,
|
|
1694
|
+
memorySnapshot: { timestamp: Date.now(), usage: getMemoryUsage() },
|
|
1695
|
+
errors: analysisData.errors ?? [],
|
|
1696
|
+
metadata: {
|
|
1697
|
+
packagePath: packagePath ?? '',
|
|
1698
|
+
workingDirectory: asString(options.workingDirectory),
|
|
1699
|
+
batchSize: asNumber(options.batchSize) ?? 100,
|
|
1700
|
+
startTime: asNumber(options.startTime) ?? Date.now(),
|
|
1701
|
+
lastSaveTime: Date.now(),
|
|
1702
|
+
},
|
|
1703
|
+
};
|
|
1704
|
+
const checkpointFile = join(sessionDir, `checkpoint_${checkpointId}.json`);
|
|
1705
|
+
const latestFile = join(sessionDir, 'latest_checkpoint.json');
|
|
1706
|
+
await Promise.all([
|
|
1707
|
+
fs.writeFile(checkpointFile, JSON.stringify(checkpoint, null, 2)),
|
|
1708
|
+
fs.writeFile(latestFile, JSON.stringify(checkpoint, null, 2)),
|
|
1709
|
+
]);
|
|
1710
|
+
return {
|
|
1711
|
+
checkpointId,
|
|
1712
|
+
saved: true,
|
|
1713
|
+
path: checkpointFile,
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
catch (error) {
|
|
1717
|
+
throw new Error(`Failed to save checkpoint: ${error instanceof Error ? error.message : String(error)}`);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
async function resumeAnalysisFromCheckpoint(sessionId, checkpointId, signal) {
|
|
1721
|
+
try {
|
|
1722
|
+
const checkpoint = await loadAnalysisCheckpoint(sessionId, checkpointId);
|
|
1723
|
+
if (!checkpoint) {
|
|
1724
|
+
return {
|
|
1725
|
+
resumed: false,
|
|
1726
|
+
checkpoint: null,
|
|
1727
|
+
message: 'No checkpoint found for session',
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
const maxAge = 24 * 60 * 60 * 1000;
|
|
1731
|
+
if (Date.now() - checkpoint.timestamp > maxAge) {
|
|
1732
|
+
return {
|
|
1733
|
+
resumed: false,
|
|
1734
|
+
checkpoint,
|
|
1735
|
+
message: 'Checkpoint is too old to resume safely',
|
|
1736
|
+
};
|
|
1737
|
+
}
|
|
1738
|
+
return {
|
|
1739
|
+
resumed: true,
|
|
1740
|
+
checkpoint,
|
|
1741
|
+
message: `Resumed from checkpoint with ${checkpoint.processedFiles.length} files already processed`,
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
catch (error) {
|
|
1745
|
+
return {
|
|
1746
|
+
resumed: false,
|
|
1747
|
+
checkpoint: null,
|
|
1748
|
+
message: `Failed to resume from checkpoint: ${error instanceof Error ? error.message : String(error)}`,
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
async function performStreamBatchProcessing(files, options = {}, sessionId, signal) {
|
|
1753
|
+
const batchSize = asNumber(options.batchSize) ?? 100;
|
|
1754
|
+
const memoryThreshold = asNumber(options.memoryThreshold) ?? 80;
|
|
1755
|
+
try {
|
|
1756
|
+
const batchProcessor = new BatchProcessorEngine({
|
|
1757
|
+
batchSize,
|
|
1758
|
+
memoryThreshold,
|
|
1759
|
+
enableGC: true,
|
|
1760
|
+
batchDelay: asNumber(options.batchDelay) ?? 500,
|
|
1761
|
+
sessionId: sessionId || `stream_${Date.now()}`,
|
|
1762
|
+
});
|
|
1763
|
+
const processBatch = async (batch, batchIndex) => {
|
|
1764
|
+
safeThrowIfAborted(signal);
|
|
1765
|
+
const batchResults = [];
|
|
1766
|
+
for (const file of batch) {
|
|
1767
|
+
let result;
|
|
1768
|
+
try {
|
|
1769
|
+
const stats = await fs.stat(file);
|
|
1770
|
+
const extension = extname(file);
|
|
1771
|
+
const fileBasename = basename(file);
|
|
1772
|
+
result = {
|
|
1773
|
+
file,
|
|
1774
|
+
processed: true,
|
|
1775
|
+
timestamp: Date.now(),
|
|
1776
|
+
batchIndex,
|
|
1777
|
+
memoryUsed: process.memoryUsage().heapUsed,
|
|
1778
|
+
fileInfo: {
|
|
1779
|
+
name: fileBasename,
|
|
1780
|
+
extension,
|
|
1781
|
+
size: stats.size,
|
|
1782
|
+
lastModified: stats.mtime,
|
|
1783
|
+
isValid: true,
|
|
1784
|
+
},
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
catch (error) {
|
|
1788
|
+
result = {
|
|
1789
|
+
file,
|
|
1790
|
+
processed: false,
|
|
1791
|
+
error: error instanceof Error ? error.message : 'Processing error',
|
|
1792
|
+
timestamp: Date.now(),
|
|
1793
|
+
batchIndex,
|
|
1794
|
+
memoryUsed: process.memoryUsage().heapUsed,
|
|
1795
|
+
fileInfo: {
|
|
1796
|
+
name: basename(file),
|
|
1797
|
+
isValid: false,
|
|
1798
|
+
},
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1801
|
+
batchResults.push(result);
|
|
1802
|
+
}
|
|
1803
|
+
return batchResults;
|
|
1804
|
+
};
|
|
1805
|
+
const result = await batchProcessor.process(files, processBatch, signal);
|
|
1806
|
+
return {
|
|
1807
|
+
success: result.success,
|
|
1808
|
+
totalFiles: files.length,
|
|
1809
|
+
processedFiles: result.progress.processedItems,
|
|
1810
|
+
batchesCompleted: result.progress.completedBatches,
|
|
1811
|
+
totalBatches: result.progress.totalBatches,
|
|
1812
|
+
results: result.results,
|
|
1813
|
+
errors: result.errors,
|
|
1814
|
+
memoryStats: {
|
|
1815
|
+
peakUsageMB: result.metrics.memoryPeak,
|
|
1816
|
+
averageUsageMB: result.metrics.memoryPeak * 0.8,
|
|
1817
|
+
gcTriggered: result.metrics.gcTriggerCount,
|
|
1818
|
+
},
|
|
1819
|
+
};
|
|
1820
|
+
}
|
|
1821
|
+
catch (error) {
|
|
1822
|
+
return {
|
|
1823
|
+
success: false,
|
|
1824
|
+
totalFiles: files.length,
|
|
1825
|
+
processedFiles: 0,
|
|
1826
|
+
batchesCompleted: 0,
|
|
1827
|
+
totalBatches: 0,
|
|
1828
|
+
results: [],
|
|
1829
|
+
errors: [error instanceof Error ? error : new Error(String(error))],
|
|
1830
|
+
memoryStats: { peakUsageMB: 0, averageUsageMB: 0, gcTriggered: 0 },
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
async function saveProgressToCheckpoint(sessionId, options, packagePath, workingDirectory, signal) {
|
|
1835
|
+
safeThrowIfAborted(signal);
|
|
1836
|
+
try {
|
|
1837
|
+
const recoveryManager = getSessionRecoveryManager({
|
|
1838
|
+
sessionDir: asString(options['sessionDir']) ?? '.claude-sessions',
|
|
1839
|
+
});
|
|
1840
|
+
const sessionContext = SESSION_CONTEXTS.get(sessionId) ?? {};
|
|
1841
|
+
const sessionPackagePath = asString(sessionContext['packagePath']);
|
|
1842
|
+
const sessionWorkingDirectory = asString(sessionContext['workingDirectory']);
|
|
1843
|
+
const sessionProcessingState = asRecord(sessionContext['processingState']) ?? {};
|
|
1844
|
+
const sessionCompletedFiles = asStringArray(sessionContext['completedFiles']) ?? [];
|
|
1845
|
+
const sessionPendingFiles = asStringArray(sessionContext['pendingFiles']) ?? [];
|
|
1846
|
+
const sessionResults = asRecord(sessionContext['results']) ?? {};
|
|
1847
|
+
const sessionErrors = normalizeSessionCheckpointErrors(sessionContext['errors']);
|
|
1848
|
+
const sessionStartTime = asNumber(sessionContext['startTime']) ?? Date.now();
|
|
1849
|
+
const sessionFilesProcessed = asNumber(sessionContext['filesProcessed']) ?? 0;
|
|
1850
|
+
const sessionUserMessage = asString(sessionContext['userMessage']);
|
|
1851
|
+
const sessionOptions = asRecord(sessionContext['options']) ?? {};
|
|
1852
|
+
const sessionCurrentPhase = asString(sessionContext['currentPhase']);
|
|
1853
|
+
const sessionCurrentWorkingDirectory = asString(sessionContext['workingDirectory']);
|
|
1854
|
+
const checkpoint = {
|
|
1855
|
+
sessionId,
|
|
1856
|
+
timestamp: Date.now(),
|
|
1857
|
+
agentType: asString(options['agentType']) ?? 'code-quality',
|
|
1858
|
+
packagePath: packagePath ?? sessionPackagePath ?? process.cwd(),
|
|
1859
|
+
workingDirectory: workingDirectory ?? sessionWorkingDirectory ?? sessionCurrentWorkingDirectory,
|
|
1860
|
+
progress: {
|
|
1861
|
+
phase: asString(options['currentPhase']) ?? sessionCurrentPhase ?? 'unknown',
|
|
1862
|
+
completedSteps: asNumber(options['completedSteps']) ?? 0,
|
|
1863
|
+
totalSteps: asNumber(options['totalSteps']) ?? 1,
|
|
1864
|
+
currentStep: asString(options['currentStep']) ?? 'processing',
|
|
1865
|
+
processingState: {
|
|
1866
|
+
lastProcessedFile: asString(options['lastProcessedFile']),
|
|
1867
|
+
currentBatch: asNumber(options['currentBatch']) ?? 0,
|
|
1868
|
+
batchSize: asNumber(options['batchSize']) ?? 100,
|
|
1869
|
+
analysisConfig: asRecord(options['analysisConfig']) ?? {},
|
|
1870
|
+
...sessionProcessingState,
|
|
1871
|
+
},
|
|
1872
|
+
},
|
|
1873
|
+
analysis: {
|
|
1874
|
+
completedFiles: asStringArray(options['completedFiles']) ?? sessionCompletedFiles,
|
|
1875
|
+
pendingFiles: asStringArray(options['pendingFiles']) ?? sessionPendingFiles,
|
|
1876
|
+
results: asRecord(options['analysisResults']) ?? sessionResults,
|
|
1877
|
+
errors: normalizeSessionCheckpointErrors(options['errors'] ?? sessionErrors),
|
|
1878
|
+
},
|
|
1879
|
+
context: {
|
|
1880
|
+
userMessage: asString(options['userMessage']) ?? sessionUserMessage,
|
|
1881
|
+
options: asRecord(options['contextOptions']) ?? sessionOptions,
|
|
1882
|
+
environment: {
|
|
1883
|
+
NODE_VERSION: process.version,
|
|
1884
|
+
PLATFORM: process.platform,
|
|
1885
|
+
MEMORY_LIMIT: process.env.AGENT_MEMORY_LIMIT_MB ?? '6144',
|
|
1886
|
+
WORKING_DIRECTORY: workingDirectory ?? process.cwd(),
|
|
1887
|
+
PACKAGE_PATH: packagePath || process.cwd(),
|
|
1888
|
+
},
|
|
1889
|
+
},
|
|
1890
|
+
metrics: {
|
|
1891
|
+
startTime: sessionStartTime,
|
|
1892
|
+
lastUpdateTime: Date.now(),
|
|
1893
|
+
memoryUsage: Math.round(process.memoryUsage().heapUsed / 1024 / 1024),
|
|
1894
|
+
filesProcessed: asNumber(options['filesProcessed']) ?? sessionFilesProcessed,
|
|
1895
|
+
errorsEncountered: (Array.isArray(options['errors']) ? options['errors'].length : 0) + sessionErrors.length,
|
|
1896
|
+
},
|
|
1897
|
+
};
|
|
1898
|
+
const saved = await recoveryManager.saveCheckpoint(checkpoint);
|
|
1899
|
+
if (saved) {
|
|
1900
|
+
SESSION_CONTEXTS.set(sessionId, {
|
|
1901
|
+
...sessionContext,
|
|
1902
|
+
lastCheckpoint: checkpoint.timestamp,
|
|
1903
|
+
checkpointSaved: true,
|
|
1904
|
+
});
|
|
1905
|
+
return {
|
|
1906
|
+
success: true,
|
|
1907
|
+
checkpointId: sessionId,
|
|
1908
|
+
savedAt: checkpoint.timestamp,
|
|
1909
|
+
progressData: {
|
|
1910
|
+
phase: checkpoint.progress.phase,
|
|
1911
|
+
completedSteps: checkpoint.progress.completedSteps,
|
|
1912
|
+
totalSteps: checkpoint.progress.totalSteps,
|
|
1913
|
+
filesProcessed: checkpoint.metrics.filesProcessed,
|
|
1914
|
+
memoryUsage: checkpoint.metrics.memoryUsage,
|
|
1915
|
+
},
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1918
|
+
else {
|
|
1919
|
+
throw new Error('Failed to save checkpoint to disk');
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
catch (error) {
|
|
1923
|
+
return {
|
|
1924
|
+
success: false,
|
|
1925
|
+
checkpointId: sessionId,
|
|
1926
|
+
savedAt: 0,
|
|
1927
|
+
progressData: {
|
|
1928
|
+
phase: 'error',
|
|
1929
|
+
completedSteps: 0,
|
|
1930
|
+
totalSteps: 0,
|
|
1931
|
+
filesProcessed: 0,
|
|
1932
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1933
|
+
},
|
|
1934
|
+
};
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
async function loadProgressFromCheckpoint(sessionId, options, signal) {
|
|
1938
|
+
safeThrowIfAborted(signal);
|
|
1939
|
+
try {
|
|
1940
|
+
const recoveryManager = getSessionRecoveryManager({
|
|
1941
|
+
sessionDir: asString(options['sessionDir']) ?? '.claude-sessions',
|
|
1942
|
+
});
|
|
1943
|
+
const recoveryResult = await recoveryManager.recoverSession(sessionId);
|
|
1944
|
+
if (recoveryResult.success && recoveryResult.checkpoint) {
|
|
1945
|
+
SESSION_CONTEXTS.set(sessionId, {
|
|
1946
|
+
packagePath: recoveryResult.checkpoint.packagePath,
|
|
1947
|
+
workingDirectory: recoveryResult.checkpoint.workingDirectory,
|
|
1948
|
+
currentPhase: recoveryResult.checkpoint.progress.phase,
|
|
1949
|
+
completedFiles: recoveryResult.checkpoint.analysis.completedFiles,
|
|
1950
|
+
pendingFiles: recoveryResult.checkpoint.analysis.pendingFiles,
|
|
1951
|
+
results: recoveryResult.checkpoint.analysis.results,
|
|
1952
|
+
errors: recoveryResult.checkpoint.analysis.errors,
|
|
1953
|
+
startTime: recoveryResult.checkpoint.metrics.startTime,
|
|
1954
|
+
filesProcessed: recoveryResult.checkpoint.metrics.filesProcessed,
|
|
1955
|
+
userMessage: recoveryResult.checkpoint.context.userMessage,
|
|
1956
|
+
options: recoveryResult.checkpoint.context.options,
|
|
1957
|
+
processingState: recoveryResult.checkpoint.progress.processingState,
|
|
1958
|
+
checkpointLoaded: true,
|
|
1959
|
+
loadedAt: Date.now(),
|
|
1960
|
+
});
|
|
1961
|
+
return {
|
|
1962
|
+
success: true,
|
|
1963
|
+
checkpoint: recoveryResult.checkpoint,
|
|
1964
|
+
resumeData: recoveryResult.resumeData,
|
|
1965
|
+
};
|
|
1966
|
+
}
|
|
1967
|
+
else {
|
|
1968
|
+
return {
|
|
1969
|
+
success: false,
|
|
1970
|
+
error: recoveryResult.error ?? 'Failed to recover session',
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
catch (error) {
|
|
1975
|
+
return {
|
|
1976
|
+
success: false,
|
|
1977
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
async function listAllRecoverableSessions(sessionDir, signal) {
|
|
1982
|
+
safeThrowIfAborted(signal);
|
|
1983
|
+
try {
|
|
1984
|
+
const recoveryManager = getSessionRecoveryManager({
|
|
1985
|
+
sessionDir: sessionDir ?? '.claude-sessions',
|
|
1986
|
+
});
|
|
1987
|
+
const sessionSummaries = await recoveryManager.listRecoverableSessions();
|
|
1988
|
+
const sessions = sessionSummaries.map(summary => ({
|
|
1989
|
+
sessionId: summary.sessionId,
|
|
1990
|
+
agentType: summary.agentType,
|
|
1991
|
+
lastUpdate: summary.lastUpdate,
|
|
1992
|
+
status: summary.status,
|
|
1993
|
+
progress: summary.progress,
|
|
1994
|
+
filesProcessed: summary.filesProcessed,
|
|
1995
|
+
packagePath: '',
|
|
1996
|
+
}));
|
|
1997
|
+
const recoverableSessions = sessions.filter(s => s.status === 'crashed' || s.status === 'active').length;
|
|
1998
|
+
return {
|
|
1999
|
+
sessions,
|
|
2000
|
+
totalSessions: sessions.length,
|
|
2001
|
+
recoverableSessions,
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
catch (_error) {
|
|
2005
|
+
return {
|
|
2006
|
+
sessions: [],
|
|
2007
|
+
totalSessions: 0,
|
|
2008
|
+
recoverableSessions: 0,
|
|
2009
|
+
};
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
async function analyzeFileContent(filePath, context) {
|
|
2013
|
+
const { packagePath: _packagePath, sessionId, batchIndex, signal } = context;
|
|
2014
|
+
try {
|
|
2015
|
+
safeThrowIfAborted(signal);
|
|
2016
|
+
const content = await fs.readFile(filePath, 'utf8');
|
|
2017
|
+
const analysis = {
|
|
2018
|
+
lineCount: content.split('\n').length,
|
|
2019
|
+
characterCount: content.length,
|
|
2020
|
+
fileType: getFileType(filePath),
|
|
2021
|
+
hasTypeScript: filePath.endsWith('.ts') || filePath.endsWith('.tsx'),
|
|
2022
|
+
hasReact: content.includes('React') || content.includes('jsx'),
|
|
2023
|
+
imports: extractImports(content),
|
|
2024
|
+
exports: extractExports(content),
|
|
2025
|
+
complexity: estimateComplexity(content),
|
|
2026
|
+
lastAnalyzed: Date.now(),
|
|
2027
|
+
sessionId,
|
|
2028
|
+
batchIndex,
|
|
2029
|
+
};
|
|
2030
|
+
return analysis;
|
|
2031
|
+
}
|
|
2032
|
+
catch (error) {
|
|
2033
|
+
return {
|
|
2034
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2035
|
+
fileType: getFileType(filePath),
|
|
2036
|
+
lastAnalyzed: Date.now(),
|
|
2037
|
+
sessionId,
|
|
2038
|
+
batchIndex,
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
function getFileType(filePath) {
|
|
2043
|
+
const ext = extname(filePath).toLowerCase();
|
|
2044
|
+
const typeMap = {
|
|
2045
|
+
'.ts': 'typescript',
|
|
2046
|
+
'.tsx': 'typescript-react',
|
|
2047
|
+
'.js': 'javascript',
|
|
2048
|
+
'.jsx': 'javascript-react',
|
|
2049
|
+
'.json': 'json',
|
|
2050
|
+
'.md': 'markdown',
|
|
2051
|
+
'.yml': 'yaml',
|
|
2052
|
+
'.yaml': 'yaml',
|
|
2053
|
+
'.css': 'css',
|
|
2054
|
+
'.scss': 'scss',
|
|
2055
|
+
'.sass': 'sass',
|
|
2056
|
+
'.html': 'html',
|
|
2057
|
+
'.py': 'python',
|
|
2058
|
+
'.sh': 'shell',
|
|
2059
|
+
'.mjs': 'javascript-module',
|
|
2060
|
+
};
|
|
2061
|
+
return typeMap[ext] ?? 'unknown';
|
|
2062
|
+
}
|
|
2063
|
+
function extractImports(content) {
|
|
2064
|
+
const importRegex = /^import\s[^;]*?from\s+['"`]([^'"`]+)['"`]/gmu;
|
|
2065
|
+
const requireRegex = /require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/gu;
|
|
2066
|
+
const imports = [];
|
|
2067
|
+
let match;
|
|
2068
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
2069
|
+
const imported = match[1];
|
|
2070
|
+
if (imported) {
|
|
2071
|
+
imports.push(imported);
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
while ((match = requireRegex.exec(content)) !== null) {
|
|
2075
|
+
const required = match[1];
|
|
2076
|
+
if (required) {
|
|
2077
|
+
imports.push(required);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
return imports;
|
|
2081
|
+
}
|
|
2082
|
+
function extractExports(content) {
|
|
2083
|
+
const exportRegex = /^export\s+(?:const|let|var|function|class)\s+(\w+)/gmu;
|
|
2084
|
+
const exports = [];
|
|
2085
|
+
let match;
|
|
2086
|
+
while ((match = exportRegex.exec(content)) !== null) {
|
|
2087
|
+
const exported = match[1];
|
|
2088
|
+
if (exported) {
|
|
2089
|
+
exports.push(exported);
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
return exports;
|
|
2093
|
+
}
|
|
2094
|
+
function estimateComplexity(content) {
|
|
2095
|
+
const indicators = [
|
|
2096
|
+
/\bif\b/g,
|
|
2097
|
+
/\belse\b/g,
|
|
2098
|
+
/\bfor\b/g,
|
|
2099
|
+
/\bwhile\b/g,
|
|
2100
|
+
/\bswitch\b/g,
|
|
2101
|
+
/\bcatch\b/g,
|
|
2102
|
+
/\btry\b/g,
|
|
2103
|
+
/\?\s*:/g,
|
|
2104
|
+
];
|
|
2105
|
+
let complexity = 1;
|
|
2106
|
+
for (const regex of indicators) {
|
|
2107
|
+
const matches = content.match(regex);
|
|
2108
|
+
if (matches) {
|
|
2109
|
+
complexity += matches.length;
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
return complexity;
|
|
2113
|
+
}
|
|
2114
|
+
async function updateSessionProgress(sessionId, currentFile, filesProcessed) {
|
|
2115
|
+
try {
|
|
2116
|
+
const recoveryManager = getSessionRecoveryManager();
|
|
2117
|
+
const checkpoint = await recoveryManager.loadCheckpoint(sessionId);
|
|
2118
|
+
if (checkpoint) {
|
|
2119
|
+
checkpoint.progress.currentStep = `Processing: ${currentFile}`;
|
|
2120
|
+
checkpoint.analysis.completedFiles.push(currentFile);
|
|
2121
|
+
checkpoint.metrics.filesProcessed = filesProcessed;
|
|
2122
|
+
checkpoint.metrics.lastUpdateTime = Date.now();
|
|
2123
|
+
checkpoint.metrics.memoryUsage = Math.round(process.memoryUsage().heapUsed / 1024 / 1024);
|
|
2124
|
+
await recoveryManager.saveCheckpoint(checkpoint);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
catch (error) {
|
|
2128
|
+
logWarn('Failed to update session progress', { error });
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
//# sourceMappingURL=workflow-orchestrator.js.map
|