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
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import { generateId } from '../utils/id.js';
|
|
2
|
+
import { WorkflowLogger } from './logger.js';
|
|
3
|
+
import { getObservedState } from '../decorators/observed-state.js';
|
|
4
|
+
import { createWorkflowContext } from './workflow-context.js';
|
|
5
|
+
/**
|
|
6
|
+
* Base class for all workflows
|
|
7
|
+
* Supports both class-based (subclass with run()) and functional (executor) patterns
|
|
8
|
+
*
|
|
9
|
+
* @example Class-based pattern:
|
|
10
|
+
* ```ts
|
|
11
|
+
* class MyWorkflow extends Workflow {
|
|
12
|
+
* async run() {
|
|
13
|
+
* this.setStatus('running');
|
|
14
|
+
* // workflow logic
|
|
15
|
+
* this.setStatus('completed');
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example Functional pattern:
|
|
21
|
+
* ```ts
|
|
22
|
+
* const workflow = new Workflow({ name: 'MyWorkflow' }, async (ctx) => {
|
|
23
|
+
* await ctx.step('step1', async () => {
|
|
24
|
+
* // step logic
|
|
25
|
+
* });
|
|
26
|
+
* });
|
|
27
|
+
* await workflow.run();
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export class Workflow {
|
|
31
|
+
/** Unique identifier for this workflow instance */
|
|
32
|
+
id;
|
|
33
|
+
/** Parent workflow (null for root workflows) */
|
|
34
|
+
parent = null;
|
|
35
|
+
/** Child workflows */
|
|
36
|
+
children = [];
|
|
37
|
+
/** Current execution status */
|
|
38
|
+
status = 'idle';
|
|
39
|
+
/** Logger instance for this workflow */
|
|
40
|
+
logger;
|
|
41
|
+
/** The node representation of this workflow */
|
|
42
|
+
node;
|
|
43
|
+
/** Observers (only populated on root workflow) */
|
|
44
|
+
observers = [];
|
|
45
|
+
/** Optional executor function for functional workflows */
|
|
46
|
+
executor;
|
|
47
|
+
/** Workflow configuration */
|
|
48
|
+
config;
|
|
49
|
+
/**
|
|
50
|
+
* Create a new workflow instance
|
|
51
|
+
*
|
|
52
|
+
* @overload Class-based pattern
|
|
53
|
+
* @param name Human-readable name (defaults to class name)
|
|
54
|
+
* @param parent Optional parent workflow
|
|
55
|
+
*
|
|
56
|
+
* @overload Functional pattern
|
|
57
|
+
* @param config Workflow configuration
|
|
58
|
+
* @param executor Executor function
|
|
59
|
+
*/
|
|
60
|
+
constructor(name, parentOrExecutor) {
|
|
61
|
+
this.id = generateId();
|
|
62
|
+
// Parse overloaded arguments
|
|
63
|
+
if (typeof name === 'object' && name !== null) {
|
|
64
|
+
// Functional pattern: constructor(config, executor)
|
|
65
|
+
this.config = name;
|
|
66
|
+
this.executor = parentOrExecutor;
|
|
67
|
+
this.parent = null;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// Class-based pattern: constructor(name, parent)
|
|
71
|
+
this.config = { name: name ?? this.constructor.name };
|
|
72
|
+
this.parent = parentOrExecutor ?? null;
|
|
73
|
+
}
|
|
74
|
+
// Validate workflow name (after config is normalized)
|
|
75
|
+
if (typeof this.config.name === 'string') {
|
|
76
|
+
const trimmedName = this.config.name.trim();
|
|
77
|
+
if (trimmedName.length === 0) {
|
|
78
|
+
throw new Error('Workflow name cannot be empty or whitespace only');
|
|
79
|
+
}
|
|
80
|
+
if (this.config.name.length > 100) {
|
|
81
|
+
throw new Error('Workflow name cannot exceed 100 characters');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Create the node representation
|
|
85
|
+
this.node = {
|
|
86
|
+
id: this.id,
|
|
87
|
+
name: this.config.name ?? this.constructor.name,
|
|
88
|
+
parent: this.parent?.node ?? null,
|
|
89
|
+
children: [],
|
|
90
|
+
status: 'idle',
|
|
91
|
+
logs: [],
|
|
92
|
+
events: [],
|
|
93
|
+
stateSnapshot: null,
|
|
94
|
+
};
|
|
95
|
+
// Create logger with root observers
|
|
96
|
+
this.logger = new WorkflowLogger(this.node, this.getRootObservers());
|
|
97
|
+
// Attach to parent if provided
|
|
98
|
+
if (this.parent) {
|
|
99
|
+
this.parent.attachChild(this);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get observers from the root workflow
|
|
104
|
+
* Traverses up the tree to find the root
|
|
105
|
+
* Uses cycle detection to prevent infinite loops from circular parent-child relationships
|
|
106
|
+
*/
|
|
107
|
+
getRootObservers() {
|
|
108
|
+
const visited = new Set();
|
|
109
|
+
let root = this;
|
|
110
|
+
let current = this;
|
|
111
|
+
while (current) {
|
|
112
|
+
if (visited.has(current)) {
|
|
113
|
+
throw new Error('Circular parent-child relationship detected');
|
|
114
|
+
}
|
|
115
|
+
visited.add(current);
|
|
116
|
+
root = current;
|
|
117
|
+
current = current.parent;
|
|
118
|
+
}
|
|
119
|
+
return root.observers;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Check if this workflow is a descendant of the given ancestor workflow.
|
|
123
|
+
*
|
|
124
|
+
* Traverses the parent chain upward looking for the ancestor reference.
|
|
125
|
+
* Uses a visited Set to detect cycles during traversal. This method provides
|
|
126
|
+
* a convenient way to check workflow hierarchy relationships without manually
|
|
127
|
+
* traversing the parent chain.
|
|
128
|
+
*
|
|
129
|
+
* @warning This method reveals workflow hierarchy information. If your
|
|
130
|
+
* application exposes workflows via an API, ensure you implement proper
|
|
131
|
+
* access control to prevent unauthorized topology discovery. Note that
|
|
132
|
+
* the `parent` and `children` properties are already public, so this
|
|
133
|
+
* method does not expose any new information beyond what is currently
|
|
134
|
+
* accessible.
|
|
135
|
+
*
|
|
136
|
+
* **Time Complexity**: O(d) where d is the depth of the hierarchy
|
|
137
|
+
* **Space Complexity**: O(d) for the visited Set in worst case (cycle detection)
|
|
138
|
+
*
|
|
139
|
+
* @example Check if a workflow belongs to a specific hierarchy
|
|
140
|
+
* ```typescript
|
|
141
|
+
* const root = new Workflow('root');
|
|
142
|
+
* const child = new Workflow('child', { parent: root });
|
|
143
|
+
*
|
|
144
|
+
* if (child.isDescendantOf(root)) {
|
|
145
|
+
* console.log('Child is in root hierarchy');
|
|
146
|
+
* }
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @example Validate before attaching to prevent circular references
|
|
150
|
+
* ```typescript
|
|
151
|
+
* if (!newChild.isDescendantOf(parent)) {
|
|
152
|
+
* parent.attachChild(newChild);
|
|
153
|
+
* } else {
|
|
154
|
+
* throw new Error('Would create circular reference');
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example Check for ancestor relationship in conditional logic
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const isInProductionBranch = workflow.isDescendantOf(productionRoot);
|
|
161
|
+
* if (isInProductionBranch) {
|
|
162
|
+
* // Apply production-specific logic
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @param ancestor - The potential ancestor workflow to check
|
|
167
|
+
* @returns true if ancestor is found in parent chain, false otherwise
|
|
168
|
+
* @throws {Error} If a cycle is detected during traversal (indicates corrupted tree structure)
|
|
169
|
+
*/
|
|
170
|
+
isDescendantOf(ancestor) {
|
|
171
|
+
const visited = new Set();
|
|
172
|
+
let current = this.parent;
|
|
173
|
+
while (current !== null) {
|
|
174
|
+
if (visited.has(current)) {
|
|
175
|
+
throw new Error('Circular parent-child relationship detected');
|
|
176
|
+
}
|
|
177
|
+
visited.add(current);
|
|
178
|
+
if (current === ancestor) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
current = current.parent;
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get the root workflow
|
|
187
|
+
* Uses cycle detection to prevent infinite loops from circular parent-child relationships
|
|
188
|
+
*/
|
|
189
|
+
getRoot() {
|
|
190
|
+
const visited = new Set();
|
|
191
|
+
let root = this;
|
|
192
|
+
let current = this;
|
|
193
|
+
while (current) {
|
|
194
|
+
if (visited.has(current)) {
|
|
195
|
+
throw new Error('Circular parent-child relationship detected');
|
|
196
|
+
}
|
|
197
|
+
visited.add(current);
|
|
198
|
+
root = current;
|
|
199
|
+
current = current.parent;
|
|
200
|
+
}
|
|
201
|
+
return root;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Add an observer to this workflow (must be root)
|
|
205
|
+
* @throws Error if called on non-root workflow
|
|
206
|
+
*/
|
|
207
|
+
addObserver(observer) {
|
|
208
|
+
if (this.parent) {
|
|
209
|
+
throw new Error('Observers can only be added to root workflows');
|
|
210
|
+
}
|
|
211
|
+
this.observers.push(observer);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Remove an observer from this workflow
|
|
215
|
+
*/
|
|
216
|
+
removeObserver(observer) {
|
|
217
|
+
const index = this.observers.indexOf(observer);
|
|
218
|
+
if (index !== -1) {
|
|
219
|
+
this.observers.splice(index, 1);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Attach a child workflow to this parent workflow.
|
|
224
|
+
*
|
|
225
|
+
* Validates that the child can be attached by checking:
|
|
226
|
+
* 1. Child is not already attached to this parent workflow
|
|
227
|
+
* 2. Child does not have a different parent (enforces single-parent invariant)
|
|
228
|
+
* 3. Child is not an ancestor of this parent (prevents circular references)
|
|
229
|
+
*
|
|
230
|
+
* **Structural Changes:**
|
|
231
|
+
* - Adds child to this.children array (workflow tree)
|
|
232
|
+
* - Adds child.node to this.node.children array (node tree)
|
|
233
|
+
* - Sets child.parent = this (workflow tree)
|
|
234
|
+
* - Sets child.node.parent = this.node (node tree)
|
|
235
|
+
* - Emits childAttached event to notify observers
|
|
236
|
+
*
|
|
237
|
+
* **Invariants Maintained:**
|
|
238
|
+
* - Single-parent rule: A workflow can only have one parent
|
|
239
|
+
* - 1:1 tree mirror: workflow tree and node tree stay synchronized
|
|
240
|
+
* - No cycles: A workflow cannot be its own ancestor
|
|
241
|
+
*
|
|
242
|
+
* **Cycle Detection:**
|
|
243
|
+
* - Uses isDescendantOf() helper with Set-based cycle detection
|
|
244
|
+
* - Throws immediately if circular reference would be created
|
|
245
|
+
*
|
|
246
|
+
* @param child - The child workflow to attach
|
|
247
|
+
* @throws {Error} If the child is already attached to this workflow
|
|
248
|
+
* @throws {Error} If the child already has a different parent (use detachChild() first for reparenting)
|
|
249
|
+
* @throws {Error} If the child is an ancestor of this parent (would create circular reference)
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* const parent = new Workflow('Parent');
|
|
254
|
+
* const child = new Workflow('Child');
|
|
255
|
+
* parent.attachChild(child);
|
|
256
|
+
* // child.parent === parent
|
|
257
|
+
* // parent.children.includes(child) === true
|
|
258
|
+
* ```
|
|
259
|
+
*
|
|
260
|
+
* @example Reparenting workflow
|
|
261
|
+
* ```ts
|
|
262
|
+
* const parent1 = new Workflow('Parent1');
|
|
263
|
+
* const parent2 = new Workflow('Parent2');
|
|
264
|
+
* const child = new Workflow('Child', parent1); // Attached to parent1
|
|
265
|
+
*
|
|
266
|
+
* // Later, move child to parent2
|
|
267
|
+
* parent1.detachChild(child);
|
|
268
|
+
* parent2.attachChild(child);
|
|
269
|
+
* // child.parent === parent2
|
|
270
|
+
* ```
|
|
271
|
+
*
|
|
272
|
+
* @see detachChild - For detaching children (enables reparenting)
|
|
273
|
+
* @see isDescendantOf - Private helper for circular reference detection
|
|
274
|
+
*/
|
|
275
|
+
attachChild(child) {
|
|
276
|
+
if (this.children.includes(child)) {
|
|
277
|
+
throw new Error('Child already attached to this workflow');
|
|
278
|
+
}
|
|
279
|
+
// Check if child already has a different parent
|
|
280
|
+
if (child.parent !== null && child.parent !== this) {
|
|
281
|
+
const errorMessage = `Child '${child.node.name}' already has a parent '${child.parent.node.name}'. ` +
|
|
282
|
+
`A workflow can only have one parent. ` +
|
|
283
|
+
`Use detachChild() on '${child.parent.node.name}' first if you need to reparent.`;
|
|
284
|
+
console.error(errorMessage);
|
|
285
|
+
throw new Error(errorMessage);
|
|
286
|
+
}
|
|
287
|
+
// Check if child is an ancestor (would create circular reference)
|
|
288
|
+
if (this.isDescendantOf(child)) {
|
|
289
|
+
const errorMessage = `Cannot attach child '${child.node.name}' - it is an ancestor of '${this.node.name}'. ` +
|
|
290
|
+
`This would create a circular reference.`;
|
|
291
|
+
console.error(errorMessage);
|
|
292
|
+
throw new Error(errorMessage);
|
|
293
|
+
}
|
|
294
|
+
// Update child's parent if it's currently null
|
|
295
|
+
if (child.parent === null) {
|
|
296
|
+
child.parent = this;
|
|
297
|
+
child.node.parent = this.node; // Maintain 1:1 mirror between workflow tree and node tree
|
|
298
|
+
}
|
|
299
|
+
this.children.push(child);
|
|
300
|
+
this.node.children.push(child.node);
|
|
301
|
+
// Emit child attached event
|
|
302
|
+
this.emitEvent({
|
|
303
|
+
type: 'childAttached',
|
|
304
|
+
parentId: this.id,
|
|
305
|
+
child: child.node,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Detach a child workflow from this parent workflow.
|
|
310
|
+
*
|
|
311
|
+
* Removes the child from both the workflow tree (this.children) and
|
|
312
|
+
* the node tree (this.node.children), clears the child's parent reference,
|
|
313
|
+
* and emits a childDetached event to notify observers.
|
|
314
|
+
*
|
|
315
|
+
* This enables reparenting workflows: oldParent.detachChild(child); newParent.attachChild(child);
|
|
316
|
+
*
|
|
317
|
+
* @param child - The child workflow to detach
|
|
318
|
+
* @throws {Error} If the child is not attached to this parent workflow
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```ts
|
|
322
|
+
* const parent = new Workflow('Parent');
|
|
323
|
+
* const child = new Workflow('Child', parent);
|
|
324
|
+
*
|
|
325
|
+
* // Later, reparent to a different parent
|
|
326
|
+
* parent.detachChild(child);
|
|
327
|
+
* newParent.attachChild(child);
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
detachChild(child) {
|
|
331
|
+
// Validate child is actually attached
|
|
332
|
+
const index = this.children.indexOf(child);
|
|
333
|
+
if (index === -1) {
|
|
334
|
+
throw new Error(`Child '${child.node.name}' is not attached to workflow '${this.node.name}'`);
|
|
335
|
+
}
|
|
336
|
+
// Remove from workflow tree (this.children array)
|
|
337
|
+
this.children.splice(index, 1);
|
|
338
|
+
// Remove from node tree (this.node.children array)
|
|
339
|
+
const nodeIndex = this.node.children.indexOf(child.node);
|
|
340
|
+
if (nodeIndex !== -1) {
|
|
341
|
+
this.node.children.splice(nodeIndex, 1);
|
|
342
|
+
}
|
|
343
|
+
// Clear child's parent reference (both workflow tree and node tree)
|
|
344
|
+
child.parent = null;
|
|
345
|
+
child.node.parent = null; // Maintain 1:1 mirror between workflow tree and node tree
|
|
346
|
+
// Emit childDetached event
|
|
347
|
+
this.emitEvent({
|
|
348
|
+
type: 'childDetached',
|
|
349
|
+
parentId: this.id,
|
|
350
|
+
childId: child.id,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Emit an event to all root observers
|
|
355
|
+
*/
|
|
356
|
+
emitEvent(event) {
|
|
357
|
+
this.node.events.push(event);
|
|
358
|
+
const observers = this.getRootObservers();
|
|
359
|
+
for (const obs of observers) {
|
|
360
|
+
try {
|
|
361
|
+
obs.onEvent(event);
|
|
362
|
+
// Also notify tree changed for tree update events
|
|
363
|
+
if (event.type === 'treeUpdated' || event.type === 'childAttached' || event.type === 'childDetached') {
|
|
364
|
+
obs.onTreeChanged(this.getRoot().node);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
catch (err) {
|
|
368
|
+
this.logger.error('Observer onEvent error', { error: err, eventType: event.type });
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Capture and emit a state snapshot
|
|
374
|
+
*/
|
|
375
|
+
snapshotState() {
|
|
376
|
+
const snapshot = getObservedState(this);
|
|
377
|
+
this.node.stateSnapshot = snapshot;
|
|
378
|
+
// Notify observers
|
|
379
|
+
const observers = this.getRootObservers();
|
|
380
|
+
for (const obs of observers) {
|
|
381
|
+
try {
|
|
382
|
+
obs.onStateUpdated(this.node);
|
|
383
|
+
}
|
|
384
|
+
catch (err) {
|
|
385
|
+
this.logger.error('Observer onStateUpdated error', { error: err, nodeId: this.node.id });
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
// Emit snapshot event
|
|
389
|
+
this.emitEvent({
|
|
390
|
+
type: 'stateSnapshot',
|
|
391
|
+
node: this.node,
|
|
392
|
+
});
|
|
393
|
+
// Emit treeUpdated event to trigger tree debugger rebuild
|
|
394
|
+
this.emitEvent({ type: 'treeUpdated', root: this.getRoot().node });
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Update workflow status and sync with node
|
|
398
|
+
*/
|
|
399
|
+
setStatus(status) {
|
|
400
|
+
this.status = status;
|
|
401
|
+
this.node.status = status;
|
|
402
|
+
this.emitEvent({ type: 'treeUpdated', root: this.getRoot().node });
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Get the node representation of this workflow
|
|
406
|
+
*/
|
|
407
|
+
getNode() {
|
|
408
|
+
return this.node;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Run the workflow
|
|
412
|
+
*
|
|
413
|
+
* For functional workflows (created with executor), runs the executor function.
|
|
414
|
+
* For class-based workflows (subclasses), this should be overridden.
|
|
415
|
+
*
|
|
416
|
+
* @returns Workflow result
|
|
417
|
+
*/
|
|
418
|
+
async run(..._args) {
|
|
419
|
+
if (this.executor) {
|
|
420
|
+
return this.runFunctional();
|
|
421
|
+
}
|
|
422
|
+
// Class-based workflows must override this method
|
|
423
|
+
throw new Error('Workflow.run() must be overridden in subclass or provide executor in constructor');
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Run a functional workflow with context
|
|
427
|
+
*/
|
|
428
|
+
async runFunctional() {
|
|
429
|
+
if (!this.executor) {
|
|
430
|
+
throw new Error('No executor provided');
|
|
431
|
+
}
|
|
432
|
+
const startTime = Date.now();
|
|
433
|
+
this.setStatus('running');
|
|
434
|
+
// Create workflow context
|
|
435
|
+
const ctx = createWorkflowContext(this, this.parent?.id, this.config.enableReflection ? { enabled: true } : undefined);
|
|
436
|
+
try {
|
|
437
|
+
const result = await this.executor(ctx);
|
|
438
|
+
this.setStatus('completed');
|
|
439
|
+
return {
|
|
440
|
+
data: result,
|
|
441
|
+
node: this.node,
|
|
442
|
+
duration: Date.now() - startTime,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
this.setStatus('failed');
|
|
447
|
+
// Emit error event
|
|
448
|
+
this.emitEvent({
|
|
449
|
+
type: 'error',
|
|
450
|
+
node: this.node,
|
|
451
|
+
error: {
|
|
452
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
453
|
+
original: error,
|
|
454
|
+
workflowId: this.id,
|
|
455
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
456
|
+
state: getObservedState(this),
|
|
457
|
+
logs: [...this.node.logs],
|
|
458
|
+
},
|
|
459
|
+
});
|
|
460
|
+
throw error;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
//# sourceMappingURL=workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/core/workflow.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAO9D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,QAAQ;IACnB,mDAAmD;IACnC,EAAE,CAAS;IAE3B,gDAAgD;IACzC,MAAM,GAAoB,IAAI,CAAC;IAEtC,sBAAsB;IACf,QAAQ,GAAe,EAAE,CAAC;IAEjC,+BAA+B;IACxB,MAAM,GAAmB,MAAM,CAAC;IAEvC,wCAAwC;IACrB,MAAM,CAAiB;IAE1C,+CAA+C;IAC/B,IAAI,CAAe;IAEnC,kDAAkD;IAC1C,SA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,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/debugger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { WorkflowNode, WorkflowEvent, WorkflowObserver, LogEntry } from '../types/index.js';
|
|
2
|
+
import { Observable } from '../utils/observable.js';
|
|
3
|
+
import type { Workflow } from '../core/workflow.js';
|
|
4
|
+
/**
|
|
5
|
+
* Tree debugger for real-time workflow visualization
|
|
6
|
+
* Implements WorkflowObserver to receive all events
|
|
7
|
+
*/
|
|
8
|
+
export declare class WorkflowTreeDebugger implements WorkflowObserver {
|
|
9
|
+
/** Root node of the workflow tree */
|
|
10
|
+
private root;
|
|
11
|
+
/** Observable stream of workflow events */
|
|
12
|
+
readonly events: Observable<WorkflowEvent>;
|
|
13
|
+
/** Node lookup map for quick access */
|
|
14
|
+
private nodeMap;
|
|
15
|
+
/**
|
|
16
|
+
* Create a tree debugger attached to a workflow
|
|
17
|
+
* @param workflow The root workflow to debug
|
|
18
|
+
*/
|
|
19
|
+
constructor(workflow: Workflow);
|
|
20
|
+
/**
|
|
21
|
+
* Build node lookup map recursively
|
|
22
|
+
*/
|
|
23
|
+
private buildNodeMap;
|
|
24
|
+
/**
|
|
25
|
+
* Remove entire subtree from node map using BFS traversal
|
|
26
|
+
* O(k) complexity where k = number of nodes in subtree
|
|
27
|
+
* Uses iterative BFS to avoid stack overflow on deep trees
|
|
28
|
+
*/
|
|
29
|
+
private removeSubtreeNodes;
|
|
30
|
+
onLog(_entry: LogEntry): void;
|
|
31
|
+
onEvent(event: WorkflowEvent): void;
|
|
32
|
+
onStateUpdated(_node: WorkflowNode): void;
|
|
33
|
+
onTreeChanged(root: WorkflowNode): void;
|
|
34
|
+
/**
|
|
35
|
+
* Get the current tree root
|
|
36
|
+
*/
|
|
37
|
+
getTree(): WorkflowNode;
|
|
38
|
+
/**
|
|
39
|
+
* Get a node by ID
|
|
40
|
+
*/
|
|
41
|
+
getNode(id: string): WorkflowNode | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Render tree as ASCII string
|
|
44
|
+
* @param node Starting node (defaults to root)
|
|
45
|
+
*/
|
|
46
|
+
toTreeString(node?: WorkflowNode): string;
|
|
47
|
+
/**
|
|
48
|
+
* Recursive tree rendering
|
|
49
|
+
*/
|
|
50
|
+
private renderTree;
|
|
51
|
+
/**
|
|
52
|
+
* Render logs as formatted string
|
|
53
|
+
* @param node Starting node (defaults to root, includes descendants)
|
|
54
|
+
*/
|
|
55
|
+
toLogString(node?: WorkflowNode): string;
|
|
56
|
+
/**
|
|
57
|
+
* Collect all logs from a node and its descendants
|
|
58
|
+
*/
|
|
59
|
+
private collectLogs;
|
|
60
|
+
/**
|
|
61
|
+
* Get summary statistics for the tree
|
|
62
|
+
*/
|
|
63
|
+
getStats(): {
|
|
64
|
+
totalNodes: number;
|
|
65
|
+
byStatus: Record<string, number>;
|
|
66
|
+
totalLogs: number;
|
|
67
|
+
totalEvents: number;
|
|
68
|
+
};
|
|
69
|
+
private collectStats;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=tree-debugger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-debugger.d.ts","sourceRoot":"","sources":["../../src/debugger/tree-debugger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAapD;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,gBAAgB;IAC3D,qCAAqC;IACrC,OAAO,CAAC,IAAI,CAAe;IAE3B,2CAA2C;IAC3C,SAAgB,M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