groundswell 0.0.1 → 0.0.3
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 +188 -0
- package/README.md +99 -5
- package/dist/__tests__/adversarial/attachChild-performance.test.d.ts +16 -0
- package/dist/__tests__/adversarial/attachChild-performance.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/attachChild-performance.test.js +187 -0
- package/dist/__tests__/adversarial/attachChild-performance.test.js.map +1 -0
- package/dist/__tests__/adversarial/circular-reference.test.d.ts +13 -0
- package/dist/__tests__/adversarial/circular-reference.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/circular-reference.test.js +92 -0
- package/dist/__tests__/adversarial/circular-reference.test.js.map +1 -0
- package/dist/__tests__/adversarial/complex-circular-reference.test.d.ts +16 -0
- package/dist/__tests__/adversarial/complex-circular-reference.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/complex-circular-reference.test.js +127 -0
- package/dist/__tests__/adversarial/complex-circular-reference.test.js.map +1 -0
- package/dist/__tests__/adversarial/concurrent-task-failures.test.d.ts +21 -0
- package/dist/__tests__/adversarial/concurrent-task-failures.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/concurrent-task-failures.test.js +667 -0
- package/dist/__tests__/adversarial/concurrent-task-failures.test.js.map +1 -0
- package/dist/__tests__/adversarial/deep-analysis.test.d.ts +6 -0
- package/dist/__tests__/adversarial/deep-analysis.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/deep-analysis.test.js +877 -0
- package/dist/__tests__/adversarial/deep-analysis.test.js.map +1 -0
- package/dist/__tests__/adversarial/deep-hierarchy-stress.test.d.ts +13 -0
- package/dist/__tests__/adversarial/deep-hierarchy-stress.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/deep-hierarchy-stress.test.js +186 -0
- package/dist/__tests__/adversarial/deep-hierarchy-stress.test.js.map +1 -0
- package/dist/__tests__/adversarial/e2e-prd-validation.test.d.ts +6 -0
- package/dist/__tests__/adversarial/e2e-prd-validation.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/e2e-prd-validation.test.js +626 -0
- package/dist/__tests__/adversarial/e2e-prd-validation.test.js.map +1 -0
- package/dist/__tests__/adversarial/edge-case.test.d.ts +6 -0
- package/dist/__tests__/adversarial/edge-case.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/edge-case.test.js +857 -0
- package/dist/__tests__/adversarial/edge-case.test.js.map +1 -0
- package/dist/__tests__/adversarial/error-merge-strategy.test.d.ts +20 -0
- package/dist/__tests__/adversarial/error-merge-strategy.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/error-merge-strategy.test.js +907 -0
- package/dist/__tests__/adversarial/error-merge-strategy.test.js.map +1 -0
- package/dist/__tests__/adversarial/incremental-performance.test.d.ts +2 -0
- package/dist/__tests__/adversarial/incremental-performance.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/incremental-performance.test.js +113 -0
- package/dist/__tests__/adversarial/incremental-performance.test.js.map +1 -0
- package/dist/__tests__/adversarial/node-map-update-benchmarks.test.d.ts +22 -0
- package/dist/__tests__/adversarial/node-map-update-benchmarks.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/node-map-update-benchmarks.test.js +383 -0
- package/dist/__tests__/adversarial/node-map-update-benchmarks.test.js.map +1 -0
- package/dist/__tests__/adversarial/observer-propagation.test.d.ts +21 -0
- package/dist/__tests__/adversarial/observer-propagation.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/observer-propagation.test.js +404 -0
- package/dist/__tests__/adversarial/observer-propagation.test.js.map +1 -0
- package/dist/__tests__/adversarial/parent-validation.test.d.ts +13 -0
- package/dist/__tests__/adversarial/parent-validation.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/parent-validation.test.js +128 -0
- package/dist/__tests__/adversarial/parent-validation.test.js.map +1 -0
- package/dist/__tests__/adversarial/prd-12-2-compliance.test.d.ts +20 -0
- package/dist/__tests__/adversarial/prd-12-2-compliance.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/prd-12-2-compliance.test.js +482 -0
- package/dist/__tests__/adversarial/prd-12-2-compliance.test.js.map +1 -0
- package/dist/__tests__/adversarial/prd-compliance.test.d.ts +6 -0
- package/dist/__tests__/adversarial/prd-compliance.test.d.ts.map +1 -0
- package/dist/__tests__/adversarial/prd-compliance.test.js +886 -0
- package/dist/__tests__/adversarial/prd-compliance.test.js.map +1 -0
- package/dist/__tests__/compatibility/backward-compatibility.test.d.ts +22 -0
- package/dist/__tests__/compatibility/backward-compatibility.test.d.ts.map +1 -0
- package/dist/__tests__/compatibility/backward-compatibility.test.js +1843 -0
- package/dist/__tests__/compatibility/backward-compatibility.test.js.map +1 -0
- package/dist/__tests__/helpers/index.d.ts +10 -0
- package/dist/__tests__/helpers/index.d.ts.map +1 -0
- package/dist/__tests__/helpers/index.js +10 -0
- package/dist/__tests__/helpers/index.js.map +1 -0
- package/dist/__tests__/helpers/tree-verification.d.ts +90 -0
- package/dist/__tests__/helpers/tree-verification.d.ts.map +1 -0
- package/dist/__tests__/helpers/tree-verification.js +202 -0
- package/dist/__tests__/helpers/tree-verification.js.map +1 -0
- package/dist/__tests__/integration/agent-workflow.test.d.ts +2 -0
- package/dist/__tests__/integration/agent-workflow.test.d.ts.map +1 -0
- package/dist/__tests__/integration/agent-workflow.test.js +256 -0
- package/dist/__tests__/integration/agent-workflow.test.js.map +1 -0
- package/dist/__tests__/integration/bidirectional-consistency.test.d.ts +14 -0
- package/dist/__tests__/integration/bidirectional-consistency.test.d.ts.map +1 -0
- package/dist/__tests__/integration/bidirectional-consistency.test.js +668 -0
- package/dist/__tests__/integration/bidirectional-consistency.test.js.map +1 -0
- package/dist/__tests__/integration/observer-logging.test.d.ts +2 -0
- package/dist/__tests__/integration/observer-logging.test.d.ts.map +1 -0
- package/dist/__tests__/integration/observer-logging.test.js +517 -0
- package/dist/__tests__/integration/observer-logging.test.js.map +1 -0
- package/dist/__tests__/integration/tree-mirroring.test.d.ts +2 -0
- package/dist/__tests__/integration/tree-mirroring.test.d.ts.map +1 -0
- package/dist/__tests__/integration/tree-mirroring.test.js +117 -0
- package/dist/__tests__/integration/tree-mirroring.test.js.map +1 -0
- package/dist/__tests__/integration/workflow-reparenting.test.d.ts +12 -0
- package/dist/__tests__/integration/workflow-reparenting.test.d.ts.map +1 -0
- package/dist/__tests__/integration/workflow-reparenting.test.js +239 -0
- package/dist/__tests__/integration/workflow-reparenting.test.js.map +1 -0
- package/dist/__tests__/unit/agent.test.d.ts +2 -0
- package/dist/__tests__/unit/agent.test.d.ts.map +1 -0
- package/dist/__tests__/unit/agent.test.js +143 -0
- package/dist/__tests__/unit/agent.test.js.map +1 -0
- package/dist/__tests__/unit/cache-key.test.d.ts +5 -0
- package/dist/__tests__/unit/cache-key.test.d.ts.map +1 -0
- package/dist/__tests__/unit/cache-key.test.js +145 -0
- package/dist/__tests__/unit/cache-key.test.js.map +1 -0
- package/dist/__tests__/unit/cache.test.d.ts +5 -0
- package/dist/__tests__/unit/cache.test.d.ts.map +1 -0
- package/dist/__tests__/unit/cache.test.js +132 -0
- package/dist/__tests__/unit/cache.test.js.map +1 -0
- package/dist/__tests__/unit/context.test.d.ts +2 -0
- package/dist/__tests__/unit/context.test.d.ts.map +1 -0
- package/dist/__tests__/unit/context.test.js +220 -0
- package/dist/__tests__/unit/context.test.js.map +1 -0
- package/dist/__tests__/unit/decorators.test.d.ts +2 -0
- package/dist/__tests__/unit/decorators.test.d.ts.map +1 -0
- package/dist/__tests__/unit/decorators.test.js +162 -0
- package/dist/__tests__/unit/decorators.test.js.map +1 -0
- package/dist/__tests__/unit/introspection-tools.test.d.ts +5 -0
- package/dist/__tests__/unit/introspection-tools.test.d.ts.map +1 -0
- package/dist/__tests__/unit/introspection-tools.test.js +191 -0
- package/dist/__tests__/unit/introspection-tools.test.js.map +1 -0
- package/dist/__tests__/unit/logger.test.d.ts +2 -0
- package/dist/__tests__/unit/logger.test.d.ts.map +1 -0
- package/dist/__tests__/unit/logger.test.js +241 -0
- package/dist/__tests__/unit/logger.test.js.map +1 -0
- package/dist/__tests__/unit/observable.test.d.ts +2 -0
- package/dist/__tests__/unit/observable.test.d.ts.map +1 -0
- package/dist/__tests__/unit/observable.test.js +251 -0
- package/dist/__tests__/unit/observable.test.js.map +1 -0
- package/dist/__tests__/unit/prompt.test.d.ts +2 -0
- package/dist/__tests__/unit/prompt.test.d.ts.map +1 -0
- package/dist/__tests__/unit/prompt.test.js +113 -0
- package/dist/__tests__/unit/prompt.test.js.map +1 -0
- package/dist/__tests__/unit/reflection.test.d.ts +5 -0
- package/dist/__tests__/unit/reflection.test.d.ts.map +1 -0
- package/dist/__tests__/unit/reflection.test.js +160 -0
- package/dist/__tests__/unit/reflection.test.js.map +1 -0
- package/dist/__tests__/unit/tree-debugger-incremental.test.d.ts +2 -0
- package/dist/__tests__/unit/tree-debugger-incremental.test.d.ts.map +1 -0
- package/dist/__tests__/unit/tree-debugger-incremental.test.js +136 -0
- package/dist/__tests__/unit/tree-debugger-incremental.test.js.map +1 -0
- package/dist/__tests__/unit/tree-debugger.test.d.ts +2 -0
- package/dist/__tests__/unit/tree-debugger.test.d.ts.map +1 -0
- package/dist/__tests__/unit/tree-debugger.test.js +69 -0
- package/dist/__tests__/unit/tree-debugger.test.js.map +1 -0
- package/dist/__tests__/unit/utils/workflow-error-utils.test.d.ts +2 -0
- package/dist/__tests__/unit/utils/workflow-error-utils.test.d.ts.map +1 -0
- package/dist/__tests__/unit/utils/workflow-error-utils.test.js +154 -0
- package/dist/__tests__/unit/utils/workflow-error-utils.test.js.map +1 -0
- package/dist/__tests__/unit/workflow-detachChild.test.d.ts +2 -0
- package/dist/__tests__/unit/workflow-detachChild.test.d.ts.map +1 -0
- package/dist/__tests__/unit/workflow-detachChild.test.js +76 -0
- package/dist/__tests__/unit/workflow-detachChild.test.js.map +1 -0
- package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.d.ts +2 -0
- package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.d.ts.map +1 -0
- package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.js +122 -0
- package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.js.map +1 -0
- package/dist/__tests__/unit/workflow-isDescendantOf.test.d.ts +2 -0
- package/dist/__tests__/unit/workflow-isDescendantOf.test.d.ts.map +1 -0
- package/dist/__tests__/unit/workflow-isDescendantOf.test.js +140 -0
- package/dist/__tests__/unit/workflow-isDescendantOf.test.js.map +1 -0
- package/dist/__tests__/unit/workflow.test.d.ts +2 -0
- package/dist/__tests__/unit/workflow.test.d.ts.map +1 -0
- package/dist/__tests__/unit/workflow.test.js +330 -0
- package/dist/__tests__/unit/workflow.test.js.map +1 -0
- package/dist/cache/cache-key.d.ts +66 -0
- package/dist/cache/cache-key.d.ts.map +1 -0
- package/dist/cache/cache-key.js +195 -0
- package/dist/cache/cache-key.js.map +1 -0
- package/dist/cache/cache.d.ts +104 -0
- package/dist/cache/cache.d.ts.map +1 -0
- package/dist/cache/cache.js +179 -0
- package/dist/cache/cache.js.map +1 -0
- package/{src/cache/index.ts → dist/cache/index.d.ts} +1 -1
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +6 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/core/agent.d.ts +112 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +426 -0
- package/dist/core/agent.js.map +1 -0
- package/{src/core/context.ts → dist/core/context.d.ts} +16 -67
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/context.js +80 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/event-tree.d.ts +72 -0
- package/dist/core/event-tree.d.ts.map +1 -0
- package/dist/core/event-tree.js +211 -0
- package/dist/core/event-tree.js.map +1 -0
- package/{src/core/factory.ts → dist/core/factory.d.ts} +6 -27
- package/dist/core/factory.d.ts.map +1 -0
- package/dist/core/factory.js +110 -0
- package/dist/core/factory.js.map +1 -0
- package/{src/core/index.ts → dist/core/index.d.ts} +2 -10
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/logger.d.ts +50 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +91 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/mcp-handler.d.ts +69 -0
- package/dist/core/mcp-handler.d.ts.map +1 -0
- package/dist/core/mcp-handler.js +143 -0
- package/dist/core/mcp-handler.js.map +1 -0
- package/dist/core/prompt.d.ts +80 -0
- package/dist/core/prompt.d.ts.map +1 -0
- package/dist/core/prompt.js +120 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/workflow-context.d.ts +57 -0
- package/dist/core/workflow-context.d.ts.map +1 -0
- package/dist/core/workflow-context.js +263 -0
- package/dist/core/workflow-context.js.map +1 -0
- package/dist/core/workflow.d.ts +241 -0
- package/dist/core/workflow.d.ts.map +1 -0
- package/dist/core/workflow.js +464 -0
- package/dist/core/workflow.js.map +1 -0
- package/dist/debugger/index.d.ts +2 -0
- package/dist/debugger/index.d.ts.map +1 -0
- package/{src/debugger/index.ts → dist/debugger/index.js} +1 -0
- package/dist/debugger/index.js.map +1 -0
- package/dist/debugger/tree-debugger.d.ts +71 -0
- package/dist/debugger/tree-debugger.d.ts.map +1 -0
- package/dist/debugger/tree-debugger.js +198 -0
- package/dist/debugger/tree-debugger.js.map +1 -0
- package/dist/decorators/index.d.ts +4 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/{src/decorators/index.ts → dist/decorators/index.js} +1 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/observed-state.d.ts +32 -0
- package/dist/decorators/observed-state.d.ts.map +1 -0
- package/dist/decorators/observed-state.js +79 -0
- package/dist/decorators/observed-state.js.map +1 -0
- package/dist/decorators/step.d.ts +15 -0
- package/dist/decorators/step.d.ts.map +1 -0
- package/dist/decorators/step.js +110 -0
- package/dist/decorators/step.js.map +1 -0
- package/dist/decorators/task.d.ts +50 -0
- package/dist/decorators/task.d.ts.map +1 -0
- package/dist/decorators/task.js +118 -0
- package/dist/decorators/task.js.map +1 -0
- package/dist/examples/index.d.ts +3 -0
- package/dist/examples/index.d.ts.map +1 -0
- package/{src/examples/index.ts → dist/examples/index.js} +1 -0
- package/dist/examples/index.js.map +1 -0
- package/dist/examples/tdd-orchestrator.d.ts +15 -0
- package/dist/examples/tdd-orchestrator.d.ts.map +1 -0
- package/dist/examples/tdd-orchestrator.js +121 -0
- package/dist/examples/tdd-orchestrator.js.map +1 -0
- package/dist/examples/test-cycle-workflow.d.ts +14 -0
- package/dist/examples/test-cycle-workflow.d.ts.map +1 -0
- package/dist/examples/test-cycle-workflow.js +116 -0
- package/dist/examples/test-cycle-workflow.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/reflection/index.d.ts +5 -0
- package/dist/reflection/index.d.ts.map +1 -0
- package/{src/reflection/index.ts → dist/reflection/index.js} +1 -1
- package/dist/reflection/index.js.map +1 -0
- package/dist/reflection/reflection.d.ts +84 -0
- package/dist/reflection/reflection.d.ts.map +1 -0
- package/dist/reflection/reflection.js +329 -0
- package/dist/reflection/reflection.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +11 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/introspection.d.ts +165 -0
- package/dist/tools/introspection.d.ts.map +1 -0
- package/dist/tools/introspection.js +324 -0
- package/dist/tools/introspection.js.map +1 -0
- package/dist/types/agent.d.ts +66 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +6 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/decorators.d.ts +31 -0
- package/dist/types/decorators.d.ts.map +1 -0
- package/dist/types/decorators.js +2 -0
- package/dist/types/decorators.js.map +1 -0
- package/dist/types/error-strategy.d.ts +13 -0
- package/dist/types/error-strategy.d.ts.map +1 -0
- package/dist/types/error-strategy.js +2 -0
- package/dist/types/error-strategy.js.map +1 -0
- package/dist/types/error.d.ts +20 -0
- package/dist/types/error.d.ts.map +1 -0
- package/dist/types/error.js +2 -0
- package/dist/types/error.js.map +1 -0
- package/dist/types/events.d.ts +87 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +2 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/logging.d.ts +24 -0
- package/dist/types/logging.d.ts.map +1 -0
- package/dist/types/logging.js +2 -0
- package/dist/types/logging.js.map +1 -0
- package/dist/types/observer.d.ts +18 -0
- package/dist/types/observer.d.ts.map +1 -0
- package/dist/types/observer.js +2 -0
- package/dist/types/observer.js.map +1 -0
- package/dist/types/prompt.d.ts +31 -0
- package/dist/types/prompt.d.ts.map +1 -0
- package/dist/types/prompt.js +6 -0
- package/dist/types/prompt.js.map +1 -0
- package/dist/types/reflection.d.ts +96 -0
- package/dist/types/reflection.d.ts.map +1 -0
- package/dist/types/reflection.js +24 -0
- package/dist/types/reflection.js.map +1 -0
- package/dist/types/sdk-primitives.d.ts +118 -0
- package/dist/types/sdk-primitives.d.ts.map +1 -0
- package/dist/types/sdk-primitives.js +6 -0
- package/dist/types/sdk-primitives.js.map +1 -0
- package/{src/types/snapshot.ts → dist/types/snapshot.d.ts} +5 -5
- package/dist/types/snapshot.d.ts.map +1 -0
- package/dist/types/snapshot.js +2 -0
- package/dist/types/snapshot.js.map +1 -0
- package/dist/types/workflow-context.d.ts +139 -0
- package/dist/types/workflow-context.d.ts.map +1 -0
- package/dist/types/workflow-context.js +8 -0
- package/dist/types/workflow-context.js.map +1 -0
- package/dist/types/workflow.d.ts +30 -0
- package/dist/types/workflow.d.ts.map +1 -0
- package/dist/types/workflow.js +2 -0
- package/dist/types/workflow.js.map +1 -0
- package/dist/utils/id.d.ts +6 -0
- package/dist/utils/id.d.ts.map +1 -0
- package/dist/utils/id.js +12 -0
- package/dist/utils/id.js.map +1 -0
- package/{src/utils/index.ts → dist/utils/index.d.ts} +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/observable.d.ts +54 -0
- package/dist/utils/observable.d.ts.map +1 -0
- package/dist/utils/observable.js +82 -0
- package/dist/utils/observable.js.map +1 -0
- package/dist/utils/workflow-error-utils.d.ts +22 -0
- package/dist/utils/workflow-error-utils.d.ts.map +1 -0
- package/dist/utils/workflow-error-utils.js +45 -0
- package/dist/utils/workflow-error-utils.js.map +1 -0
- package/package.json +7 -2
- package/.claude/settings.local.json +0 -9
- package/.claude/system_prompts/task-breakdown.md +0 -100
- package/PRPs/001-hierarchical-workflow-engine.md +0 -2438
- package/PRPs/PRDs/001-hierarchical-workflow-engine.md +0 -543
- package/PRPs/PRDs/002-agent-prompt.md +0 -390
- package/PRPs/PRDs/003-agent-prompt.md +0 -943
- package/PRPs/PRDs/004-agent-prompt.md +0 -1136
- package/PRPs/PRDs/tasks-001.json +0 -492
- package/PRPs/README.md +0 -83
- package/PRPs/templates/prp_base.md +0 -222
- package/docs/agent.md +0 -422
- package/docs/prompt.md +0 -419
- package/docs/workflow.md +0 -600
- package/examples/README.md +0 -244
- package/examples/examples/01-basic-workflow.ts +0 -100
- package/examples/examples/02-decorator-options.ts +0 -217
- package/examples/examples/03-parent-child.ts +0 -241
- package/examples/examples/04-observers-debugger.ts +0 -340
- package/examples/examples/05-error-handling.ts +0 -387
- package/examples/examples/06-concurrent-tasks.ts +0 -352
- package/examples/examples/07-agent-loops.ts +0 -432
- package/examples/examples/08-sdk-features.ts +0 -667
- package/examples/examples/09-reflection.ts +0 -573
- package/examples/examples/10-introspection.ts +0 -550
- package/examples/index.ts +0 -143
- package/examples/utils/helpers.ts +0 -57
- package/llms_full.txt +0 -5890
- package/plan/P1P2/PRP.md +0 -527
- package/plan/P1P2/research/LRU_CACHE_BEST_PRACTICES.md +0 -1929
- package/plan/P1P2/research/LRU_CACHE_CODE_PATTERNS.md +0 -857
- package/plan/P1P2/research/LRU_CACHE_INTEGRATION_GUIDE.md +0 -738
- package/plan/P1P2/research/LRU_CACHE_RESEARCH_INDEX.md +0 -424
- package/plan/P1P2/research/REFLECTION_INDEX.md +0 -291
- package/plan/P1P2/research/REFLECTION_RESEARCH_REPORT.md +0 -1342
- package/plan/P1P2/research/RESEARCH_SUMMARY.md +0 -342
- package/plan/P1P2/research/anthropic-sdk.md +0 -174
- package/plan/P1P2/research/async-local-storage.md +0 -200
- package/plan/P1P2/research/reflection-code-patterns.md +0 -1205
- package/plan/P1P2/research/reflection-decision-matrix.md +0 -421
- package/plan/P1P2/research/reflection-implementation-guide.md +0 -1341
- package/plan/P1P2/research/reflection-integration-guide.md +0 -834
- package/plan/P1P2/research/reflection-patterns.md +0 -1468
- package/plan/P1P2/research/reflection-quick-reference.md +0 -558
- package/plan/P1P2/research/zod-schema.md +0 -152
- package/plan/P3P4/PRP.md +0 -1388
- package/plan/P3P4/research/caching-lru.md +0 -116
- package/plan/P3P4/research/introspection-tools.md +0 -177
- package/plan/P3P4/research/reflection-patterns.md +0 -117
- package/plan/P4P5/PRP.md +0 -1136
- package/plan/P4P5/research/RESEARCH_SUMMARY.md +0 -151
- package/plan/architecture/external_deps.md +0 -358
- package/plan/architecture/system_context.md +0 -242
- package/plan/backlog.json +0 -867
- package/plan/research/INTROSPECTION_RESEARCH_SUMMARY.md +0 -378
- package/plan/research/README-INTROSPECTION.md +0 -352
- package/plan/research/agent-introspection-patterns.md +0 -1085
- package/plan/research/introspection-security-guide.md +0 -928
- package/plan/research/introspection-tool-examples.md +0 -875
- package/scripts/generate-llms-full.ts +0 -206
- package/src/__tests__/integration/agent-workflow.test.ts +0 -256
- package/src/__tests__/integration/tree-mirroring.test.ts +0 -114
- package/src/__tests__/unit/agent.test.ts +0 -169
- package/src/__tests__/unit/cache-key.test.ts +0 -182
- package/src/__tests__/unit/cache.test.ts +0 -172
- package/src/__tests__/unit/context.test.ts +0 -138
- package/src/__tests__/unit/decorators.test.ts +0 -100
- package/src/__tests__/unit/introspection-tools.test.ts +0 -277
- package/src/__tests__/unit/prompt.test.ts +0 -135
- package/src/__tests__/unit/reflection.test.ts +0 -210
- package/src/__tests__/unit/tree-debugger.test.ts +0 -85
- package/src/__tests__/unit/workflow.test.ts +0 -81
- package/src/cache/cache-key.ts +0 -244
- package/src/cache/cache.ts +0 -236
- package/src/core/agent.ts +0 -573
- package/src/core/event-tree.ts +0 -260
- package/src/core/logger.ts +0 -87
- package/src/core/mcp-handler.ts +0 -184
- package/src/core/prompt.ts +0 -150
- package/src/core/workflow-context.ts +0 -349
- package/src/core/workflow.ts +0 -302
- package/src/debugger/tree-debugger.ts +0 -210
- package/src/decorators/observed-state.ts +0 -95
- package/src/decorators/step.ts +0 -139
- package/src/decorators/task.ts +0 -96
- package/src/examples/tdd-orchestrator.ts +0 -65
- package/src/examples/test-cycle-workflow.ts +0 -64
- package/src/index.ts +0 -140
- package/src/reflection/reflection.ts +0 -407
- package/src/tools/index.ts +0 -36
- package/src/tools/introspection.ts +0 -464
- package/src/types/agent.ts +0 -90
- package/src/types/decorators.ts +0 -25
- package/src/types/error-strategy.ts +0 -13
- package/src/types/error.ts +0 -20
- package/src/types/events.ts +0 -74
- package/src/types/index.ts +0 -55
- package/src/types/logging.ts +0 -24
- package/src/types/observer.ts +0 -18
- package/src/types/prompt.ts +0 -40
- package/src/types/reflection.ts +0 -117
- package/src/types/sdk-primitives.ts +0 -128
- package/src/types/workflow-context.ts +0 -163
- package/src/types/workflow.ts +0 -37
- package/src/utils/id.ts +0 -11
- package/src/utils/observable.ts +0 -77
- package/tasks.json +0 -0
- package/tsconfig.json +0 -22
- package/vitest.config.ts +0 -16
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
WorkflowNode,
|
|
3
|
-
WorkflowEvent,
|
|
4
|
-
WorkflowObserver,
|
|
5
|
-
LogEntry,
|
|
6
|
-
} from '../types/index.js';
|
|
7
|
-
import { Observable } from '../utils/observable.js';
|
|
8
|
-
import type { Workflow } from '../core/workflow.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Status symbols for tree visualization
|
|
12
|
-
*/
|
|
13
|
-
const STATUS_SYMBOLS: Record<string, string> = {
|
|
14
|
-
idle: '○',
|
|
15
|
-
running: '◐',
|
|
16
|
-
completed: '✓',
|
|
17
|
-
failed: '✗',
|
|
18
|
-
cancelled: '⊘',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Tree debugger for real-time workflow visualization
|
|
23
|
-
* Implements WorkflowObserver to receive all events
|
|
24
|
-
*/
|
|
25
|
-
export class WorkflowTreeDebugger implements WorkflowObserver {
|
|
26
|
-
/** Root node of the workflow tree */
|
|
27
|
-
private root: WorkflowNode;
|
|
28
|
-
|
|
29
|
-
/** Observable stream of workflow events */
|
|
30
|
-
public readonly events: Observable<WorkflowEvent>;
|
|
31
|
-
|
|
32
|
-
/** Node lookup map for quick access */
|
|
33
|
-
private nodeMap: Map<string, WorkflowNode> = new Map();
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Create a tree debugger attached to a workflow
|
|
37
|
-
* @param workflow The root workflow to debug
|
|
38
|
-
*/
|
|
39
|
-
constructor(workflow: Workflow) {
|
|
40
|
-
this.root = workflow.getNode();
|
|
41
|
-
this.events = new Observable<WorkflowEvent>();
|
|
42
|
-
|
|
43
|
-
// Build initial node map
|
|
44
|
-
this.buildNodeMap(this.root);
|
|
45
|
-
|
|
46
|
-
// Register as observer on the workflow
|
|
47
|
-
workflow.addObserver(this);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Build node lookup map recursively
|
|
52
|
-
*/
|
|
53
|
-
private buildNodeMap(node: WorkflowNode): void {
|
|
54
|
-
this.nodeMap.set(node.id, node);
|
|
55
|
-
for (const child of node.children) {
|
|
56
|
-
this.buildNodeMap(child);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// WorkflowObserver implementation
|
|
61
|
-
|
|
62
|
-
onLog(_entry: LogEntry): void {
|
|
63
|
-
// Events are forwarded through the event stream
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
onEvent(event: WorkflowEvent): void {
|
|
67
|
-
// Rebuild node map on structural changes
|
|
68
|
-
if (event.type === 'childAttached') {
|
|
69
|
-
this.buildNodeMap(event.child);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Forward to event stream
|
|
73
|
-
this.events.next(event);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
onStateUpdated(_node: WorkflowNode): void {
|
|
77
|
-
// State updates are available through the node
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
onTreeChanged(root: WorkflowNode): void {
|
|
81
|
-
this.root = root;
|
|
82
|
-
this.nodeMap.clear();
|
|
83
|
-
this.buildNodeMap(root);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Public API
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Get the current tree root
|
|
90
|
-
*/
|
|
91
|
-
getTree(): WorkflowNode {
|
|
92
|
-
return this.root;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Get a node by ID
|
|
97
|
-
*/
|
|
98
|
-
getNode(id: string): WorkflowNode | undefined {
|
|
99
|
-
return this.nodeMap.get(id);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Render tree as ASCII string
|
|
104
|
-
* @param node Starting node (defaults to root)
|
|
105
|
-
*/
|
|
106
|
-
toTreeString(node?: WorkflowNode): string {
|
|
107
|
-
return this.renderTree(node ?? this.root, '', true, true);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Recursive tree rendering
|
|
112
|
-
*/
|
|
113
|
-
private renderTree(
|
|
114
|
-
node: WorkflowNode,
|
|
115
|
-
prefix: string,
|
|
116
|
-
isLast: boolean,
|
|
117
|
-
isRoot: boolean
|
|
118
|
-
): string {
|
|
119
|
-
let result = '';
|
|
120
|
-
|
|
121
|
-
// Status symbol and color indicator
|
|
122
|
-
const statusSymbol = STATUS_SYMBOLS[node.status] || '?';
|
|
123
|
-
const nodeInfo = `${statusSymbol} ${node.name} [${node.status}]`;
|
|
124
|
-
|
|
125
|
-
if (isRoot) {
|
|
126
|
-
result += nodeInfo + '\n';
|
|
127
|
-
} else {
|
|
128
|
-
const connector = isLast ? '└── ' : '├── ';
|
|
129
|
-
result += prefix + connector + nodeInfo + '\n';
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Render children
|
|
133
|
-
const childCount = node.children.length;
|
|
134
|
-
node.children.forEach((child, index) => {
|
|
135
|
-
const isLastChild = index === childCount - 1;
|
|
136
|
-
const childPrefix = isRoot ? '' : prefix + (isLast ? ' ' : '│ ');
|
|
137
|
-
result += this.renderTree(child, childPrefix, isLastChild, false);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Render logs as formatted string
|
|
145
|
-
* @param node Starting node (defaults to root, includes descendants)
|
|
146
|
-
*/
|
|
147
|
-
toLogString(node?: WorkflowNode): string {
|
|
148
|
-
const logs = this.collectLogs(node ?? this.root);
|
|
149
|
-
|
|
150
|
-
// Sort by timestamp
|
|
151
|
-
logs.sort((a, b) => a.timestamp - b.timestamp);
|
|
152
|
-
|
|
153
|
-
return logs
|
|
154
|
-
.map((log) => {
|
|
155
|
-
const time = new Date(log.timestamp).toISOString();
|
|
156
|
-
const level = log.level.toUpperCase().padEnd(5);
|
|
157
|
-
const nodeRef = this.nodeMap.get(log.workflowId);
|
|
158
|
-
const nodeName = nodeRef?.name ?? log.workflowId;
|
|
159
|
-
return `[${time}] ${level} [${nodeName}] ${log.message}`;
|
|
160
|
-
})
|
|
161
|
-
.join('\n');
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Collect all logs from a node and its descendants
|
|
166
|
-
*/
|
|
167
|
-
private collectLogs(node: WorkflowNode): LogEntry[] {
|
|
168
|
-
const logs: LogEntry[] = [...node.logs];
|
|
169
|
-
|
|
170
|
-
for (const child of node.children) {
|
|
171
|
-
logs.push(...this.collectLogs(child));
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return logs;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Get summary statistics for the tree
|
|
179
|
-
*/
|
|
180
|
-
getStats(): {
|
|
181
|
-
totalNodes: number;
|
|
182
|
-
byStatus: Record<string, number>;
|
|
183
|
-
totalLogs: number;
|
|
184
|
-
totalEvents: number;
|
|
185
|
-
} {
|
|
186
|
-
const stats = {
|
|
187
|
-
totalNodes: 0,
|
|
188
|
-
byStatus: {} as Record<string, number>,
|
|
189
|
-
totalLogs: 0,
|
|
190
|
-
totalEvents: 0,
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
this.collectStats(this.root, stats);
|
|
194
|
-
return stats;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
private collectStats(
|
|
198
|
-
node: WorkflowNode,
|
|
199
|
-
stats: ReturnType<typeof this.getStats>
|
|
200
|
-
): void {
|
|
201
|
-
stats.totalNodes++;
|
|
202
|
-
stats.byStatus[node.status] = (stats.byStatus[node.status] || 0) + 1;
|
|
203
|
-
stats.totalLogs += node.logs.length;
|
|
204
|
-
stats.totalEvents += node.events.length;
|
|
205
|
-
|
|
206
|
-
for (const child of node.children) {
|
|
207
|
-
this.collectStats(child, stats);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import type { StateFieldMetadata, SerializedWorkflowState } from '../types/index.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WeakMap storing field metadata keyed by class prototype
|
|
5
|
-
* Structure: Map<propertyKey, StateFieldMetadata>
|
|
6
|
-
*/
|
|
7
|
-
const OBSERVED_STATE_FIELDS = new WeakMap<object, Map<string, StateFieldMetadata>>();
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @ObservedState decorator
|
|
11
|
-
* Marks a class field for inclusion in state snapshots
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* class MyWorkflow extends Workflow {
|
|
15
|
-
* @ObservedState()
|
|
16
|
-
* currentStep!: string;
|
|
17
|
-
*
|
|
18
|
-
* @ObservedState({ redact: true })
|
|
19
|
-
* sensitiveData!: string;
|
|
20
|
-
*
|
|
21
|
-
* @ObservedState({ hidden: true })
|
|
22
|
-
* internalState!: object;
|
|
23
|
-
* }
|
|
24
|
-
*/
|
|
25
|
-
export function ObservedState(meta: StateFieldMetadata = {}) {
|
|
26
|
-
return function (
|
|
27
|
-
_value: undefined,
|
|
28
|
-
context: ClassFieldDecoratorContext
|
|
29
|
-
): void {
|
|
30
|
-
const propertyKey = String(context.name);
|
|
31
|
-
|
|
32
|
-
// Use addInitializer to register field when class is instantiated
|
|
33
|
-
context.addInitializer(function (this: unknown) {
|
|
34
|
-
const instance = this as object;
|
|
35
|
-
const proto = Object.getPrototypeOf(instance);
|
|
36
|
-
let map = OBSERVED_STATE_FIELDS.get(proto);
|
|
37
|
-
if (!map) {
|
|
38
|
-
map = new Map();
|
|
39
|
-
OBSERVED_STATE_FIELDS.set(proto, map);
|
|
40
|
-
}
|
|
41
|
-
map.set(propertyKey, meta);
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Get all observed state from an object instance
|
|
48
|
-
* Applies hidden and redact transformations
|
|
49
|
-
*/
|
|
50
|
-
export function getObservedState(obj: object): SerializedWorkflowState {
|
|
51
|
-
const proto = Object.getPrototypeOf(obj);
|
|
52
|
-
const map = OBSERVED_STATE_FIELDS.get(proto);
|
|
53
|
-
|
|
54
|
-
if (!map) {
|
|
55
|
-
return {};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const result: SerializedWorkflowState = {};
|
|
59
|
-
|
|
60
|
-
for (const [key, meta] of map) {
|
|
61
|
-
// Skip hidden fields
|
|
62
|
-
if (meta.hidden) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let value = (obj as Record<string, unknown>)[key];
|
|
67
|
-
|
|
68
|
-
// Redact sensitive fields
|
|
69
|
-
if (meta.redact) {
|
|
70
|
-
value = '***';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
result[key] = value;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Check if a field is observed on an object
|
|
81
|
-
*/
|
|
82
|
-
export function isFieldObserved(obj: object, fieldName: string): boolean {
|
|
83
|
-
const proto = Object.getPrototypeOf(obj);
|
|
84
|
-
const map = OBSERVED_STATE_FIELDS.get(proto);
|
|
85
|
-
return map?.has(fieldName) ?? false;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Get metadata for a specific field
|
|
90
|
-
*/
|
|
91
|
-
export function getFieldMetadata(obj: object, fieldName: string): StateFieldMetadata | undefined {
|
|
92
|
-
const proto = Object.getPrototypeOf(obj);
|
|
93
|
-
const map = OBSERVED_STATE_FIELDS.get(proto);
|
|
94
|
-
return map?.get(fieldName);
|
|
95
|
-
}
|
package/src/decorators/step.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import type { StepOptions, WorkflowError, WorkflowNode, LogEntry, WorkflowEvent } from '../types/index.js';
|
|
2
|
-
import { getObservedState } from './observed-state.js';
|
|
3
|
-
import { runInContext, type AgentExecutionContext } from '../core/context.js';
|
|
4
|
-
import { generateId } from '../utils/id.js';
|
|
5
|
-
|
|
6
|
-
// Type for workflow-like objects that @Step can decorate methods on
|
|
7
|
-
interface WorkflowLike {
|
|
8
|
-
id: string;
|
|
9
|
-
node: WorkflowNode;
|
|
10
|
-
logger: {
|
|
11
|
-
info(message: string, data?: unknown): void;
|
|
12
|
-
};
|
|
13
|
-
emitEvent(event: WorkflowEvent): void;
|
|
14
|
-
snapshotState(): void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @Step decorator
|
|
19
|
-
* Wraps a method to emit step events, handle errors, and optionally snapshot state
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* class MyWorkflow extends Workflow {
|
|
23
|
-
* @Step({ snapshotState: true, trackTiming: true })
|
|
24
|
-
* async processData() {
|
|
25
|
-
* // ... step logic
|
|
26
|
-
* }
|
|
27
|
-
* }
|
|
28
|
-
*/
|
|
29
|
-
export function Step(opts: StepOptions = {}) {
|
|
30
|
-
return function <This, Args extends unknown[], Return>(
|
|
31
|
-
originalMethod: (this: This, ...args: Args) => Promise<Return>,
|
|
32
|
-
context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Promise<Return>>
|
|
33
|
-
) {
|
|
34
|
-
const methodName = String(context.name);
|
|
35
|
-
|
|
36
|
-
// CRITICAL: Use regular function, not arrow function, to preserve 'this'
|
|
37
|
-
async function stepWrapper(this: This, ...args: Args): Promise<Return> {
|
|
38
|
-
// Cast to WorkflowLike for type safety when accessing workflow properties
|
|
39
|
-
const wf = this as unknown as WorkflowLike;
|
|
40
|
-
const stepName = opts.name ?? methodName;
|
|
41
|
-
const startTime = Date.now();
|
|
42
|
-
|
|
43
|
-
// Log start if requested
|
|
44
|
-
if (opts.logStart) {
|
|
45
|
-
wf.logger.info(`STEP START: ${stepName}`);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Emit step start event
|
|
49
|
-
wf.emitEvent({
|
|
50
|
-
type: 'stepStart',
|
|
51
|
-
node: wf.node,
|
|
52
|
-
step: stepName,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Create step node for hierarchy tracking
|
|
56
|
-
const stepNode: WorkflowNode = {
|
|
57
|
-
id: generateId(),
|
|
58
|
-
name: stepName,
|
|
59
|
-
parent: wf.node,
|
|
60
|
-
children: [],
|
|
61
|
-
status: 'running',
|
|
62
|
-
logs: [],
|
|
63
|
-
events: [],
|
|
64
|
-
stateSnapshot: null,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// Create execution context for agent/prompt operations within this step
|
|
68
|
-
const executionContext: AgentExecutionContext = {
|
|
69
|
-
workflowNode: stepNode,
|
|
70
|
-
emitEvent: (event: WorkflowEvent) => {
|
|
71
|
-
stepNode.events.push(event);
|
|
72
|
-
wf.emitEvent(event);
|
|
73
|
-
},
|
|
74
|
-
workflowId: wf.id,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
// Execute the original method within the execution context
|
|
79
|
-
// This allows Agent.prompt() calls to automatically capture events
|
|
80
|
-
const result = await runInContext(executionContext, async () => {
|
|
81
|
-
return originalMethod.call(this, ...args);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Update step node status
|
|
85
|
-
stepNode.status = 'completed';
|
|
86
|
-
|
|
87
|
-
// Snapshot state if requested
|
|
88
|
-
if (opts.snapshotState) {
|
|
89
|
-
wf.snapshotState();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Calculate duration and emit end event
|
|
93
|
-
const duration = Date.now() - startTime;
|
|
94
|
-
if (opts.trackTiming !== false) {
|
|
95
|
-
wf.emitEvent({
|
|
96
|
-
type: 'stepEnd',
|
|
97
|
-
node: wf.node,
|
|
98
|
-
step: stepName,
|
|
99
|
-
duration,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Log finish if requested
|
|
104
|
-
if (opts.logFinish) {
|
|
105
|
-
wf.logger.info(`STEP END: ${stepName} (${duration}ms)`);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return result;
|
|
109
|
-
} catch (err: unknown) {
|
|
110
|
-
// Update step node status
|
|
111
|
-
stepNode.status = 'failed';
|
|
112
|
-
// Create rich error with context
|
|
113
|
-
const error = err as Error;
|
|
114
|
-
const snap = getObservedState(this as object);
|
|
115
|
-
|
|
116
|
-
const workflowError: WorkflowError = {
|
|
117
|
-
message: error?.message ?? 'Unknown error',
|
|
118
|
-
original: err,
|
|
119
|
-
workflowId: wf.id,
|
|
120
|
-
stack: error?.stack,
|
|
121
|
-
state: snap,
|
|
122
|
-
logs: [...wf.node.logs] as LogEntry[],
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// Emit error event
|
|
126
|
-
wf.emitEvent({
|
|
127
|
-
type: 'error',
|
|
128
|
-
node: wf.node,
|
|
129
|
-
error: workflowError,
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// Re-throw the enriched error
|
|
133
|
-
throw workflowError;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return stepWrapper;
|
|
138
|
-
};
|
|
139
|
-
}
|
package/src/decorators/task.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type { TaskOptions, WorkflowNode, WorkflowEvent } from '../types/index.js';
|
|
2
|
-
|
|
3
|
-
// Type for workflow-like objects
|
|
4
|
-
interface WorkflowLike {
|
|
5
|
-
id: string;
|
|
6
|
-
node: WorkflowNode;
|
|
7
|
-
emitEvent(event: WorkflowEvent): void;
|
|
8
|
-
attachChild(child: WorkflowLike): void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Minimal Workflow type for checking if something is a workflow
|
|
12
|
-
interface WorkflowClass {
|
|
13
|
-
id: string;
|
|
14
|
-
parent: WorkflowLike | null;
|
|
15
|
-
run(...args: unknown[]): Promise<unknown>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @Task decorator
|
|
20
|
-
* Wraps a method that returns child workflow(s), automatically attaching them
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* class ParentWorkflow extends Workflow {
|
|
24
|
-
* @Task({ concurrent: true })
|
|
25
|
-
* async createChildren(): Promise<ChildWorkflow[]> {
|
|
26
|
-
* return [
|
|
27
|
-
* new ChildWorkflow('child1', this),
|
|
28
|
-
* new ChildWorkflow('child2', this),
|
|
29
|
-
* ];
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
*/
|
|
33
|
-
export function Task(opts: TaskOptions = {}) {
|
|
34
|
-
return function <This, Args extends unknown[], Return>(
|
|
35
|
-
originalMethod: (this: This, ...args: Args) => Promise<Return>,
|
|
36
|
-
context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Promise<Return>>
|
|
37
|
-
) {
|
|
38
|
-
const methodName = String(context.name);
|
|
39
|
-
|
|
40
|
-
// CRITICAL: Use regular function, not arrow function
|
|
41
|
-
async function taskWrapper(this: This, ...args: Args): Promise<Return> {
|
|
42
|
-
// Cast to WorkflowLike for type safety when accessing workflow properties
|
|
43
|
-
const wf = this as unknown as WorkflowLike;
|
|
44
|
-
const taskName = opts.name ?? methodName;
|
|
45
|
-
|
|
46
|
-
// Emit task start event
|
|
47
|
-
wf.emitEvent({
|
|
48
|
-
type: 'taskStart',
|
|
49
|
-
node: wf.node,
|
|
50
|
-
task: taskName,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Execute the original method
|
|
54
|
-
const result = await originalMethod.call(this, ...args);
|
|
55
|
-
|
|
56
|
-
// Process returned workflows
|
|
57
|
-
const workflows = Array.isArray(result) ? result : [result];
|
|
58
|
-
|
|
59
|
-
for (const workflow of workflows) {
|
|
60
|
-
// Type guard to check if it's a workflow
|
|
61
|
-
if (workflow && typeof workflow === 'object' && 'id' in workflow) {
|
|
62
|
-
const childWf = workflow as WorkflowClass;
|
|
63
|
-
|
|
64
|
-
// Only attach if not already attached (parent not set by constructor)
|
|
65
|
-
if (!childWf.parent) {
|
|
66
|
-
childWf.parent = wf;
|
|
67
|
-
wf.attachChild(childWf as unknown as WorkflowLike);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// If concurrent option is set and we have multiple workflows, run them in parallel
|
|
73
|
-
if (opts.concurrent && Array.isArray(result)) {
|
|
74
|
-
const runnable = workflows.filter(
|
|
75
|
-
(w): w is WorkflowClass =>
|
|
76
|
-
w && typeof w === 'object' && 'run' in w && typeof w.run === 'function'
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
if (runnable.length > 0) {
|
|
80
|
-
await Promise.all(runnable.map((w) => w.run()));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Emit task end event
|
|
85
|
-
wf.emitEvent({
|
|
86
|
-
type: 'taskEnd',
|
|
87
|
-
node: wf.node,
|
|
88
|
-
task: taskName,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return taskWrapper;
|
|
95
|
-
};
|
|
96
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Workflow } from '../core/workflow.js';
|
|
2
|
-
import { Step } from '../decorators/step.js';
|
|
3
|
-
import { Task } from '../decorators/task.js';
|
|
4
|
-
import { ObservedState } from '../decorators/observed-state.js';
|
|
5
|
-
import { TestCycleWorkflow } from './test-cycle-workflow.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Example parent workflow demonstrating TDD orchestration
|
|
9
|
-
*/
|
|
10
|
-
export class TDDOrchestrator extends Workflow {
|
|
11
|
-
@ObservedState()
|
|
12
|
-
cycleCount: number = 0;
|
|
13
|
-
|
|
14
|
-
@ObservedState()
|
|
15
|
-
maxCycles: number = 3;
|
|
16
|
-
|
|
17
|
-
@ObservedState({ redact: true })
|
|
18
|
-
apiKey: string = 'secret-key';
|
|
19
|
-
|
|
20
|
-
@Step({ logStart: true, logFinish: true })
|
|
21
|
-
async setupEnvironment(): Promise<void> {
|
|
22
|
-
this.logger.info('Setting up TDD environment');
|
|
23
|
-
// Simulate environment setup
|
|
24
|
-
await this.delay(50);
|
|
25
|
-
this.logger.debug('Environment ready');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@Task()
|
|
29
|
-
async runCycle(): Promise<TestCycleWorkflow> {
|
|
30
|
-
this.cycleCount++;
|
|
31
|
-
this.logger.info(`Starting cycle ${this.cycleCount}/${this.maxCycles}`);
|
|
32
|
-
return new TestCycleWorkflow(`Cycle-${this.cycleCount}`, this);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async run(): Promise<void> {
|
|
36
|
-
this.setStatus('running');
|
|
37
|
-
this.logger.info('TDD Orchestrator starting');
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
await this.setupEnvironment();
|
|
41
|
-
|
|
42
|
-
while (this.cycleCount < this.maxCycles) {
|
|
43
|
-
try {
|
|
44
|
-
const cycle = await this.runCycle();
|
|
45
|
-
await cycle.run();
|
|
46
|
-
this.logger.info(`Cycle ${this.cycleCount} completed successfully`);
|
|
47
|
-
} catch (error) {
|
|
48
|
-
this.logger.warn(`Cycle ${this.cycleCount} failed, continuing...`);
|
|
49
|
-
// In real implementation, analyze error and potentially restart
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
this.setStatus('completed');
|
|
54
|
-
this.logger.info('TDD Orchestrator completed all cycles');
|
|
55
|
-
} catch (error) {
|
|
56
|
-
this.setStatus('failed');
|
|
57
|
-
this.logger.error('TDD Orchestrator failed', { error });
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private delay(ms: number): Promise<void> {
|
|
63
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Workflow } from '../core/workflow.js';
|
|
2
|
-
import { Step } from '../decorators/step.js';
|
|
3
|
-
import { ObservedState } from '../decorators/observed-state.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Example child workflow demonstrating test cycle
|
|
7
|
-
*/
|
|
8
|
-
export class TestCycleWorkflow extends Workflow {
|
|
9
|
-
@ObservedState()
|
|
10
|
-
currentTest: string = '';
|
|
11
|
-
|
|
12
|
-
@ObservedState()
|
|
13
|
-
testResult: 'pending' | 'passed' | 'failed' = 'pending';
|
|
14
|
-
|
|
15
|
-
@Step({ snapshotState: true, trackTiming: true, logStart: true })
|
|
16
|
-
async generateTest(): Promise<string> {
|
|
17
|
-
this.logger.info('Generating test case');
|
|
18
|
-
this.currentTest = `test_${Date.now()}`;
|
|
19
|
-
// Simulate test generation
|
|
20
|
-
await this.delay(100);
|
|
21
|
-
return this.currentTest;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@Step({ trackTiming: true })
|
|
25
|
-
async runTest(): Promise<boolean> {
|
|
26
|
-
this.logger.info(`Running test: ${this.currentTest}`);
|
|
27
|
-
// Simulate test execution
|
|
28
|
-
await this.delay(200);
|
|
29
|
-
|
|
30
|
-
// Randomly pass or fail for demonstration
|
|
31
|
-
const passed = Math.random() > 0.3;
|
|
32
|
-
this.testResult = passed ? 'passed' : 'failed';
|
|
33
|
-
|
|
34
|
-
if (!passed) {
|
|
35
|
-
throw new Error(`Test ${this.currentTest} failed`);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@Step({ snapshotState: true })
|
|
42
|
-
async updateImplementation(): Promise<void> {
|
|
43
|
-
this.logger.info('Updating implementation based on test results');
|
|
44
|
-
await this.delay(150);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async run(): Promise<void> {
|
|
48
|
-
this.setStatus('running');
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
await this.generateTest();
|
|
52
|
-
await this.runTest();
|
|
53
|
-
await this.updateImplementation();
|
|
54
|
-
this.setStatus('completed');
|
|
55
|
-
} catch (error) {
|
|
56
|
-
this.setStatus('failed');
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private delay(ms: number): Promise<void> {
|
|
62
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
63
|
-
}
|
|
64
|
-
}
|