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,206 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env npx tsx
|
|
2
|
-
/**
|
|
3
|
-
* Generates llms_full.txt by combining:
|
|
4
|
-
* 1. README.md and its linked markdown documentation files
|
|
5
|
-
* 2. Examples README and all example source files
|
|
6
|
-
*
|
|
7
|
-
* Future-proof design:
|
|
8
|
-
* - Auto-discovers markdown files linked from README.md (docs/*.md pattern)
|
|
9
|
-
* - Auto-discovers all example files matching examples/examples/*.ts
|
|
10
|
-
* - New docs and examples are automatically included without script changes
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import * as fs from "fs";
|
|
14
|
-
import * as path from "path";
|
|
15
|
-
import { fileURLToPath } from "url";
|
|
16
|
-
|
|
17
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
-
const __dirname = path.dirname(__filename);
|
|
19
|
-
const ROOT_DIR = path.resolve(__dirname, "..");
|
|
20
|
-
const OUTPUT_FILE = path.join(ROOT_DIR, "llms_full.txt");
|
|
21
|
-
|
|
22
|
-
interface Section {
|
|
23
|
-
title: string;
|
|
24
|
-
content: string;
|
|
25
|
-
filePath?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function readFile(filePath: string): string {
|
|
29
|
-
try {
|
|
30
|
-
return fs.readFileSync(filePath, "utf-8");
|
|
31
|
-
} catch (error) {
|
|
32
|
-
console.warn(`Warning: Could not read ${filePath}`);
|
|
33
|
-
return "";
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function extractMarkdownLinks(content: string, baseDir: string): string[] {
|
|
38
|
-
// Match markdown links: [text](path.md) - only .md files
|
|
39
|
-
const linkRegex = /\[([^\]]+)\]\(([^)]+\.md)\)/g;
|
|
40
|
-
const links: string[] = [];
|
|
41
|
-
let match;
|
|
42
|
-
|
|
43
|
-
while ((match = linkRegex.exec(content)) !== null) {
|
|
44
|
-
const linkPath = match[2];
|
|
45
|
-
// Only include relative links (not http/https)
|
|
46
|
-
if (!linkPath.startsWith("http://") && !linkPath.startsWith("https://")) {
|
|
47
|
-
const absolutePath = path.resolve(baseDir, linkPath);
|
|
48
|
-
if (fs.existsSync(absolutePath) && !links.includes(absolutePath)) {
|
|
49
|
-
links.push(absolutePath);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return links;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function discoverDocsMarkdown(): string[] {
|
|
58
|
-
const docsDir = path.join(ROOT_DIR, "docs");
|
|
59
|
-
if (!fs.existsSync(docsDir)) {
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return fs
|
|
64
|
-
.readdirSync(docsDir)
|
|
65
|
-
.filter((file) => file.endsWith(".md"))
|
|
66
|
-
.map((file) => path.join(docsDir, file))
|
|
67
|
-
.sort();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function discoverExamples(): string[] {
|
|
71
|
-
const examplesDir = path.join(ROOT_DIR, "examples", "examples");
|
|
72
|
-
if (!fs.existsSync(examplesDir)) {
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return fs
|
|
77
|
-
.readdirSync(examplesDir)
|
|
78
|
-
.filter((file) => file.endsWith(".ts"))
|
|
79
|
-
.sort() // Sorting ensures NN- prefixed files are in order
|
|
80
|
-
.map((file) => path.join(examplesDir, file));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function formatSection(section: Section): string {
|
|
84
|
-
const separator = "=".repeat(80);
|
|
85
|
-
const relativePath = section.filePath
|
|
86
|
-
? path.relative(ROOT_DIR, section.filePath)
|
|
87
|
-
: "";
|
|
88
|
-
|
|
89
|
-
let header = `${separator}\n${section.title}`;
|
|
90
|
-
if (relativePath) {
|
|
91
|
-
header += `\nFile: ${relativePath}`;
|
|
92
|
-
}
|
|
93
|
-
header += `\n${separator}\n\n`;
|
|
94
|
-
|
|
95
|
-
return header + section.content.trim() + "\n\n";
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function generateLlmsFull(): void {
|
|
99
|
-
const sections: Section[] = [];
|
|
100
|
-
const processedFiles = new Set<string>();
|
|
101
|
-
|
|
102
|
-
// 1. Main README
|
|
103
|
-
const readmePath = path.join(ROOT_DIR, "README.md");
|
|
104
|
-
const readmeContent = readFile(readmePath);
|
|
105
|
-
if (readmeContent) {
|
|
106
|
-
sections.push({
|
|
107
|
-
title: "PROJECT README",
|
|
108
|
-
content: readmeContent,
|
|
109
|
-
filePath: readmePath,
|
|
110
|
-
});
|
|
111
|
-
processedFiles.add(readmePath);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// 2. Documentation files from docs/ directory
|
|
115
|
-
// First, get links from README to preserve intended order
|
|
116
|
-
const linkedDocs = extractMarkdownLinks(readmeContent, ROOT_DIR);
|
|
117
|
-
// Then discover all docs to catch any not linked
|
|
118
|
-
const allDocs = discoverDocsMarkdown();
|
|
119
|
-
|
|
120
|
-
// Process linked docs first (preserves README order)
|
|
121
|
-
for (const docPath of linkedDocs) {
|
|
122
|
-
if (
|
|
123
|
-
docPath.includes("/docs/") &&
|
|
124
|
-
!processedFiles.has(docPath) &&
|
|
125
|
-
fs.existsSync(docPath)
|
|
126
|
-
) {
|
|
127
|
-
const content = readFile(docPath);
|
|
128
|
-
const fileName = path.basename(docPath, ".md").toUpperCase();
|
|
129
|
-
sections.push({
|
|
130
|
-
title: `DOCUMENTATION: ${fileName}`,
|
|
131
|
-
content,
|
|
132
|
-
filePath: docPath,
|
|
133
|
-
});
|
|
134
|
-
processedFiles.add(docPath);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Add any docs not linked from README
|
|
139
|
-
for (const docPath of allDocs) {
|
|
140
|
-
if (!processedFiles.has(docPath)) {
|
|
141
|
-
const content = readFile(docPath);
|
|
142
|
-
const fileName = path.basename(docPath, ".md").toUpperCase();
|
|
143
|
-
sections.push({
|
|
144
|
-
title: `DOCUMENTATION: ${fileName}`,
|
|
145
|
-
content,
|
|
146
|
-
filePath: docPath,
|
|
147
|
-
});
|
|
148
|
-
processedFiles.add(docPath);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// 3. Examples README
|
|
153
|
-
const examplesReadmePath = path.join(ROOT_DIR, "examples", "README.md");
|
|
154
|
-
if (fs.existsSync(examplesReadmePath)) {
|
|
155
|
-
const content = readFile(examplesReadmePath);
|
|
156
|
-
sections.push({
|
|
157
|
-
title: "EXAMPLES OVERVIEW",
|
|
158
|
-
content,
|
|
159
|
-
filePath: examplesReadmePath,
|
|
160
|
-
});
|
|
161
|
-
processedFiles.add(examplesReadmePath);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// 4. All example source files
|
|
165
|
-
const examples = discoverExamples();
|
|
166
|
-
for (const examplePath of examples) {
|
|
167
|
-
const content = readFile(examplePath);
|
|
168
|
-
const fileName = path.basename(examplePath);
|
|
169
|
-
// Extract example number and name from filename (e.g., "01-basic-workflow.ts")
|
|
170
|
-
const match = fileName.match(/^(\d+)-(.+)\.ts$/);
|
|
171
|
-
const exampleName = match
|
|
172
|
-
? `Example ${parseInt(match[1])}: ${match[2].replace(/-/g, " ")}`
|
|
173
|
-
: fileName;
|
|
174
|
-
|
|
175
|
-
sections.push({
|
|
176
|
-
title: `EXAMPLE: ${exampleName.toUpperCase()}`,
|
|
177
|
-
content,
|
|
178
|
-
filePath: examplePath,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Build output
|
|
183
|
-
const header = `GROUNDSWELL - LLM DOCUMENTATION
|
|
184
|
-
Generated: ${new Date().toISOString()}
|
|
185
|
-
${"=".repeat(80)}
|
|
186
|
-
|
|
187
|
-
This file contains the complete documentation and examples for the Groundswell project.
|
|
188
|
-
It is auto-generated by scripts/generate-llms-full.ts
|
|
189
|
-
|
|
190
|
-
Contents:
|
|
191
|
-
${sections.map((s, i) => ` ${i + 1}. ${s.title}`).join("\n")}
|
|
192
|
-
|
|
193
|
-
`;
|
|
194
|
-
|
|
195
|
-
const output =
|
|
196
|
-
header + sections.map((section) => formatSection(section)).join("\n");
|
|
197
|
-
|
|
198
|
-
// Write output
|
|
199
|
-
fs.writeFileSync(OUTPUT_FILE, output);
|
|
200
|
-
console.log(`Generated ${path.relative(process.cwd(), OUTPUT_FILE)}`);
|
|
201
|
-
console.log(`Total sections: ${sections.length}`);
|
|
202
|
-
console.log(`Total size: ${(output.length / 1024).toFixed(1)} KB`);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Run
|
|
206
|
-
generateLlmsFull();
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import {
|
|
4
|
-
Workflow,
|
|
5
|
-
Prompt,
|
|
6
|
-
Step,
|
|
7
|
-
WorkflowObserver,
|
|
8
|
-
WorkflowEvent,
|
|
9
|
-
runInContext,
|
|
10
|
-
type AgentExecutionContext,
|
|
11
|
-
createEventTreeHandle,
|
|
12
|
-
} from '../../index.js';
|
|
13
|
-
|
|
14
|
-
// Mock workflow that simulates agent prompt execution within steps
|
|
15
|
-
class MockAgentWorkflow extends Workflow {
|
|
16
|
-
public events: WorkflowEvent[] = [];
|
|
17
|
-
|
|
18
|
-
@Step({ name: 'step1' })
|
|
19
|
-
async executeStep1(): Promise<string> {
|
|
20
|
-
return 'step1-result';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@Step({ name: 'step2' })
|
|
24
|
-
async executeStep2(): Promise<string> {
|
|
25
|
-
return 'step2-result';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async run(): Promise<string> {
|
|
29
|
-
this.setStatus('running');
|
|
30
|
-
await this.executeStep1();
|
|
31
|
-
await this.executeStep2();
|
|
32
|
-
this.setStatus('completed');
|
|
33
|
-
return 'done';
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
describe('Agent-Workflow Integration', () => {
|
|
38
|
-
it('should establish context in @Step decorated methods', async () => {
|
|
39
|
-
const workflow = new MockAgentWorkflow('TestWorkflow');
|
|
40
|
-
const events: WorkflowEvent[] = [];
|
|
41
|
-
|
|
42
|
-
const observer: WorkflowObserver = {
|
|
43
|
-
onLog: () => {},
|
|
44
|
-
onEvent: (event) => events.push(event),
|
|
45
|
-
onStateUpdated: () => {},
|
|
46
|
-
onTreeChanged: () => {},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
workflow.addObserver(observer);
|
|
50
|
-
await workflow.run();
|
|
51
|
-
|
|
52
|
-
// Should have step start/end events
|
|
53
|
-
const stepStarts = events.filter((e) => e.type === 'stepStart');
|
|
54
|
-
const stepEnds = events.filter((e) => e.type === 'stepEnd');
|
|
55
|
-
|
|
56
|
-
expect(stepStarts).toHaveLength(2);
|
|
57
|
-
expect(stepEnds).toHaveLength(2);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('should track events emitted from within step context', async () => {
|
|
61
|
-
const emittedEvents: WorkflowEvent[] = [];
|
|
62
|
-
|
|
63
|
-
class ContextTrackingWorkflow extends Workflow {
|
|
64
|
-
@Step({ name: 'tracked-step' })
|
|
65
|
-
async trackedStep(): Promise<void> {
|
|
66
|
-
// This simulates what happens when Agent.prompt() is called
|
|
67
|
-
// The context should be available
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async run(): Promise<void> {
|
|
71
|
-
this.setStatus('running');
|
|
72
|
-
await this.trackedStep();
|
|
73
|
-
this.setStatus('completed');
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const workflow = new ContextTrackingWorkflow('ContextTest');
|
|
78
|
-
const observer: WorkflowObserver = {
|
|
79
|
-
onLog: () => {},
|
|
80
|
-
onEvent: (event) => emittedEvents.push(event),
|
|
81
|
-
onStateUpdated: () => {},
|
|
82
|
-
onTreeChanged: () => {},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
workflow.addObserver(observer);
|
|
86
|
-
await workflow.run();
|
|
87
|
-
|
|
88
|
-
// Verify step events were emitted
|
|
89
|
-
expect(emittedEvents.some((e) => e.type === 'stepStart')).toBe(true);
|
|
90
|
-
expect(emittedEvents.some((e) => e.type === 'stepEnd')).toBe(true);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should support functional workflow pattern with step()', async () => {
|
|
94
|
-
const events: WorkflowEvent[] = [];
|
|
95
|
-
|
|
96
|
-
const workflow = new Workflow<string>({ name: 'FunctionalWorkflow' }, async (ctx) => {
|
|
97
|
-
await ctx.step('step-a', async () => {
|
|
98
|
-
return 'a';
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
await ctx.step('step-b', async () => {
|
|
102
|
-
return 'b';
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
return 'completed';
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const observer: WorkflowObserver = {
|
|
109
|
-
onLog: () => {},
|
|
110
|
-
onEvent: (event) => events.push(event),
|
|
111
|
-
onStateUpdated: () => {},
|
|
112
|
-
onTreeChanged: () => {},
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
workflow.addObserver(observer);
|
|
116
|
-
const result = await workflow.run();
|
|
117
|
-
|
|
118
|
-
expect(result).toEqual({
|
|
119
|
-
data: 'completed',
|
|
120
|
-
node: expect.any(Object),
|
|
121
|
-
duration: expect.any(Number),
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
const stepStarts = events.filter((e) => e.type === 'stepStart');
|
|
125
|
-
const stepEnds = events.filter((e) => e.type === 'stepEnd');
|
|
126
|
-
|
|
127
|
-
expect(stepStarts).toHaveLength(2);
|
|
128
|
-
expect(stepEnds).toHaveLength(2);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('should nest step events under workflow in tree', async () => {
|
|
132
|
-
const workflow = new Workflow<string>({ name: 'TreeTestWorkflow' }, async (ctx) => {
|
|
133
|
-
await ctx.step('nested-step', async () => {
|
|
134
|
-
return 'nested';
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
return 'done';
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
const result = await workflow.run();
|
|
141
|
-
const node = workflow.getNode();
|
|
142
|
-
|
|
143
|
-
// Check that the workflow node has children (the step nodes)
|
|
144
|
-
expect(node.children.length).toBeGreaterThan(0);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('should propagate context through async boundaries', async () => {
|
|
148
|
-
let contextWasAvailable = false;
|
|
149
|
-
|
|
150
|
-
const workflow = new Workflow<boolean>({ name: 'AsyncContextWorkflow' }, async (ctx) => {
|
|
151
|
-
await ctx.step('async-step', async () => {
|
|
152
|
-
// Simulate async operation
|
|
153
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
154
|
-
|
|
155
|
-
// The context should still be available after async boundary
|
|
156
|
-
// This is verified by the step completing successfully
|
|
157
|
-
contextWasAvailable = true;
|
|
158
|
-
return 'async-result';
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
return contextWasAvailable;
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
const result = await workflow.run();
|
|
165
|
-
// For functional workflows, result is WorkflowResult<T>
|
|
166
|
-
expect((result as { data: boolean }).data).toBe(true);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('should create EventTreeHandle from workflow', async () => {
|
|
170
|
-
const workflow = new Workflow<void>({ name: 'EventTreeWorkflow' }, async (ctx) => {
|
|
171
|
-
await ctx.step('tree-step', async () => {});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
await workflow.run();
|
|
175
|
-
|
|
176
|
-
const treeHandle = createEventTreeHandle(workflow.getNode());
|
|
177
|
-
expect(treeHandle.root).toBeDefined();
|
|
178
|
-
expect(treeHandle.root.name).toBe('EventTreeWorkflow');
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it('should handle errors in steps', async () => {
|
|
182
|
-
const events: WorkflowEvent[] = [];
|
|
183
|
-
|
|
184
|
-
const workflow = new Workflow<void>({ name: 'ErrorWorkflow' }, async (ctx) => {
|
|
185
|
-
await ctx.step('failing-step', async () => {
|
|
186
|
-
throw new Error('Step failed');
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
const observer: WorkflowObserver = {
|
|
191
|
-
onLog: () => {},
|
|
192
|
-
onEvent: (event) => events.push(event),
|
|
193
|
-
onStateUpdated: () => {},
|
|
194
|
-
onTreeChanged: () => {},
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
workflow.addObserver(observer);
|
|
198
|
-
|
|
199
|
-
await expect(workflow.run()).rejects.toThrow('Step failed');
|
|
200
|
-
|
|
201
|
-
const errorEvents = events.filter((e) => e.type === 'error');
|
|
202
|
-
// Error is emitted both from the step context and from the workflow
|
|
203
|
-
expect(errorEvents.length).toBeGreaterThanOrEqual(1);
|
|
204
|
-
expect(workflow.status).toBe('failed');
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
describe('Prompt Integration', () => {
|
|
209
|
-
it('should create type-safe prompts with Zod schemas', () => {
|
|
210
|
-
const responseSchema = z.object({
|
|
211
|
-
answer: z.string(),
|
|
212
|
-
confidence: z.number().min(0).max(1),
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
const prompt = new Prompt({
|
|
216
|
-
user: 'What is 2 + 2?',
|
|
217
|
-
responseFormat: responseSchema,
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
// Valid response
|
|
221
|
-
const valid = prompt.validateResponse({ answer: '4', confidence: 0.99 });
|
|
222
|
-
expect(valid).toEqual({ answer: '4', confidence: 0.99 });
|
|
223
|
-
|
|
224
|
-
// Invalid response should throw
|
|
225
|
-
expect(() => prompt.validateResponse({ answer: '4' })).toThrow();
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('should support complex nested schemas', () => {
|
|
229
|
-
const schema = z.object({
|
|
230
|
-
items: z.array(
|
|
231
|
-
z.object({
|
|
232
|
-
id: z.number(),
|
|
233
|
-
name: z.string(),
|
|
234
|
-
tags: z.array(z.string()),
|
|
235
|
-
})
|
|
236
|
-
),
|
|
237
|
-
metadata: z.object({
|
|
238
|
-
total: z.number(),
|
|
239
|
-
page: z.number(),
|
|
240
|
-
}),
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
const prompt = new Prompt({
|
|
244
|
-
user: 'List items',
|
|
245
|
-
responseFormat: schema,
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
const result = prompt.validateResponse({
|
|
249
|
-
items: [{ id: 1, name: 'Item 1', tags: ['a', 'b'] }],
|
|
250
|
-
metadata: { total: 1, page: 1 },
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
expect(result.items).toHaveLength(1);
|
|
254
|
-
expect(result.metadata.total).toBe(1);
|
|
255
|
-
});
|
|
256
|
-
});
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
TDDOrchestrator,
|
|
4
|
-
WorkflowTreeDebugger,
|
|
5
|
-
WorkflowEvent,
|
|
6
|
-
WorkflowObserver,
|
|
7
|
-
} from '../../index.js';
|
|
8
|
-
|
|
9
|
-
describe('Tree Mirroring Integration', () => {
|
|
10
|
-
it('should create 1:1 tree mirror of workflow execution', async () => {
|
|
11
|
-
const orchestrator = new TDDOrchestrator('TDDOrchestrator');
|
|
12
|
-
(orchestrator as any).maxCycles = 1; // Limit to one cycle for test
|
|
13
|
-
|
|
14
|
-
const debugger_ = new WorkflowTreeDebugger(orchestrator);
|
|
15
|
-
const events: WorkflowEvent[] = [];
|
|
16
|
-
|
|
17
|
-
debugger_.events.subscribe({
|
|
18
|
-
next: (event) => events.push(event),
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
await orchestrator.run();
|
|
23
|
-
} catch {
|
|
24
|
-
// May fail due to random test failures, that's ok
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Verify tree structure
|
|
28
|
-
const tree = debugger_.getTree();
|
|
29
|
-
expect(tree.name).toBe('TDDOrchestrator');
|
|
30
|
-
|
|
31
|
-
// Should have at least one child (the cycle)
|
|
32
|
-
expect(tree.children.length).toBeGreaterThanOrEqual(1);
|
|
33
|
-
|
|
34
|
-
// Child should be named Cycle-N
|
|
35
|
-
const cycleChild = tree.children.find((c) => c.name.startsWith('Cycle-'));
|
|
36
|
-
expect(cycleChild).toBeDefined();
|
|
37
|
-
|
|
38
|
-
// Verify events were captured
|
|
39
|
-
expect(events.some((e) => e.type === 'stepStart')).toBe(true);
|
|
40
|
-
expect(events.some((e) => e.type === 'taskStart')).toBe(true);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should propagate events to root observer', async () => {
|
|
44
|
-
const orchestrator = new TDDOrchestrator('Root');
|
|
45
|
-
(orchestrator as any).maxCycles = 1;
|
|
46
|
-
|
|
47
|
-
const allEvents: WorkflowEvent[] = [];
|
|
48
|
-
const allLogs: any[] = [];
|
|
49
|
-
|
|
50
|
-
const observer: WorkflowObserver = {
|
|
51
|
-
onLog: (entry) => allLogs.push(entry),
|
|
52
|
-
onEvent: (event) => allEvents.push(event),
|
|
53
|
-
onStateUpdated: () => {},
|
|
54
|
-
onTreeChanged: () => {},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
orchestrator.addObserver(observer);
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
await orchestrator.run();
|
|
61
|
-
} catch {
|
|
62
|
-
// May fail
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Events from child workflows should reach root
|
|
66
|
-
expect(allLogs.length).toBeGreaterThan(0);
|
|
67
|
-
expect(allEvents.length).toBeGreaterThan(0);
|
|
68
|
-
|
|
69
|
-
// Should have events from both parent and child
|
|
70
|
-
const parentEvents = allEvents.filter(
|
|
71
|
-
(e) => 'node' in e && e.node.name === 'Root'
|
|
72
|
-
);
|
|
73
|
-
const childEvents = allEvents.filter(
|
|
74
|
-
(e) => 'node' in e && e.node.name.startsWith('Cycle-')
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
expect(parentEvents.length).toBeGreaterThan(0);
|
|
78
|
-
expect(childEvents.length).toBeGreaterThan(0);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should include state snapshot on error', async () => {
|
|
82
|
-
const orchestrator = new TDDOrchestrator('ErrorTest');
|
|
83
|
-
(orchestrator as any).maxCycles = 1;
|
|
84
|
-
|
|
85
|
-
const errorEvents: WorkflowEvent[] = [];
|
|
86
|
-
|
|
87
|
-
orchestrator.addObserver({
|
|
88
|
-
onLog: () => {},
|
|
89
|
-
onEvent: (event) => {
|
|
90
|
-
if (event.type === 'error') {
|
|
91
|
-
errorEvents.push(event);
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
onStateUpdated: () => {},
|
|
95
|
-
onTreeChanged: () => {},
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
try {
|
|
99
|
-
await orchestrator.run();
|
|
100
|
-
} catch {
|
|
101
|
-
// Expected
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// If there was an error, it should have state
|
|
105
|
-
if (errorEvents.length > 0) {
|
|
106
|
-
const errEvent = errorEvents[0];
|
|
107
|
-
if (errEvent.type === 'error') {
|
|
108
|
-
expect(errEvent.error.state).toBeDefined();
|
|
109
|
-
expect(errEvent.error.logs).toBeDefined();
|
|
110
|
-
expect(errEvent.error.workflowId).toBeDefined();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|