@exaudeus/workrail 0.8.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +157 -403
- package/dist/application/services/enhanced-loop-validator.d.ts +2 -2
- package/dist/application/services/enhanced-loop-validator.js +12 -2
- package/dist/application/services/validation-engine.d.ts +8 -29
- package/dist/application/services/validation-engine.js +38 -21
- package/dist/application/services/workflow-compiler.d.ts +18 -0
- package/dist/application/services/workflow-compiler.js +79 -0
- package/dist/application/services/workflow-interpreter.d.ts +31 -0
- package/dist/application/services/workflow-interpreter.js +280 -0
- package/dist/application/services/workflow-service.d.ts +34 -32
- package/dist/application/services/workflow-service.js +93 -425
- package/dist/application/use-cases/get-next-step.d.ts +6 -10
- package/dist/application/use-cases/get-next-step.js +2 -6
- package/dist/application/use-cases/get-workflow.d.ts +8 -6
- package/dist/application/use-cases/get-workflow.js +42 -33
- package/dist/application/use-cases/list-workflows.d.ts +3 -3
- package/dist/application/use-cases/validate-step-output.d.ts +4 -4
- package/dist/application/use-cases/validate-workflow-file.d.ts +46 -0
- package/dist/application/use-cases/validate-workflow-file.js +57 -0
- package/dist/cli/commands/cleanup.d.ts +8 -0
- package/dist/cli/commands/cleanup.js +20 -0
- package/dist/cli/commands/index.d.ts +7 -0
- package/dist/cli/commands/index.js +21 -0
- package/dist/cli/commands/init.d.ts +11 -0
- package/dist/cli/commands/init.js +49 -0
- package/dist/cli/commands/list.d.ts +9 -0
- package/dist/cli/commands/list.js +34 -0
- package/dist/cli/commands/migrate.d.ts +78 -0
- package/dist/cli/commands/migrate.js +248 -0
- package/dist/cli/commands/sources.d.ts +21 -0
- package/dist/cli/commands/sources.js +87 -0
- package/dist/cli/commands/start.d.ts +8 -0
- package/dist/cli/commands/start.js +16 -0
- package/dist/cli/commands/validate.d.ts +6 -0
- package/dist/cli/commands/validate.js +55 -0
- package/dist/cli/interpret-result.d.ts +4 -0
- package/dist/cli/interpret-result.js +24 -0
- package/dist/cli/output-formatter.d.ts +10 -0
- package/dist/cli/output-formatter.js +97 -0
- package/dist/cli/types/cli-result.d.ts +23 -0
- package/dist/cli/types/cli-result.js +30 -0
- package/dist/cli/types/exit-code.d.ts +13 -0
- package/dist/cli/types/exit-code.js +23 -0
- package/dist/cli/types/index.d.ts +4 -0
- package/dist/cli/types/index.js +11 -0
- package/dist/cli.js +84 -278
- package/dist/config/app-config.d.ts +40 -0
- package/dist/config/app-config.js +58 -0
- package/dist/config/feature-flags.d.ts +10 -2
- package/dist/config/feature-flags.js +74 -12
- package/dist/core/error-handler.d.ts +18 -27
- package/dist/core/error-handler.js +24 -218
- package/dist/di/container.d.ts +12 -0
- package/dist/di/container.js +244 -0
- package/dist/di/tokens.d.ts +40 -0
- package/dist/di/tokens.js +42 -0
- package/dist/domain/execution/error.d.ts +32 -0
- package/dist/domain/execution/error.js +24 -0
- package/dist/domain/execution/event.d.ts +7 -0
- package/dist/domain/execution/event.js +11 -0
- package/dist/domain/execution/ids.d.ts +9 -0
- package/dist/domain/execution/ids.js +9 -0
- package/dist/domain/execution/result.d.ts +3 -0
- package/dist/domain/execution/result.js +10 -0
- package/dist/domain/execution/state.d.ts +57 -0
- package/dist/domain/execution/state.js +28 -0
- package/dist/errors/app-error.d.ts +23 -0
- package/dist/errors/factories.d.ts +6 -0
- package/dist/errors/factories.js +21 -0
- package/dist/errors/formatter.d.ts +2 -0
- package/dist/errors/formatter.js +32 -0
- package/dist/errors/index.d.ts +3 -0
- package/dist/errors/index.js +7 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +10 -25
- package/dist/infrastructure/index.d.ts +0 -1
- package/dist/infrastructure/index.js +0 -1
- package/dist/infrastructure/session/DashboardHeartbeat.d.ts +8 -0
- package/dist/infrastructure/session/DashboardHeartbeat.js +39 -0
- package/dist/infrastructure/session/DashboardLockRelease.d.ts +2 -0
- package/dist/infrastructure/session/DashboardLockRelease.js +29 -0
- package/dist/infrastructure/session/HttpServer.d.ts +25 -6
- package/dist/infrastructure/session/HttpServer.js +245 -90
- package/dist/infrastructure/session/SessionDataNormalizer.js +12 -2
- package/dist/infrastructure/session/SessionDataValidator.js +12 -2
- package/dist/infrastructure/session/SessionManager.d.ts +5 -3
- package/dist/infrastructure/session/SessionManager.js +52 -6
- package/dist/infrastructure/storage/caching-workflow-storage.d.ts +30 -6
- package/dist/infrastructure/storage/caching-workflow-storage.js +105 -23
- package/dist/infrastructure/storage/enhanced-multi-source-workflow-storage.d.ts +13 -9
- package/dist/infrastructure/storage/enhanced-multi-source-workflow-storage.js +45 -39
- package/dist/infrastructure/storage/file-workflow-storage.d.ts +10 -8
- package/dist/infrastructure/storage/file-workflow-storage.js +48 -56
- package/dist/infrastructure/storage/git-workflow-storage.d.ts +7 -22
- package/dist/infrastructure/storage/git-workflow-storage.js +48 -103
- package/dist/infrastructure/storage/in-memory-storage.d.ts +10 -6
- package/dist/infrastructure/storage/in-memory-storage.js +18 -13
- package/dist/infrastructure/storage/plugin-workflow-storage.d.ts +6 -18
- package/dist/infrastructure/storage/plugin-workflow-storage.js +29 -51
- package/dist/infrastructure/storage/remote-workflow-storage.d.ts +8 -17
- package/dist/infrastructure/storage/remote-workflow-storage.js +33 -156
- package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts +21 -13
- package/dist/infrastructure/storage/schema-validating-workflow-storage.js +86 -24
- package/dist/infrastructure/storage/storage.d.ts +7 -5
- package/dist/infrastructure/storage/storage.js +7 -6
- package/dist/manifest.json +1093 -0
- package/dist/mcp/error-mapper.d.ts +9 -0
- package/dist/mcp/error-mapper.js +66 -0
- package/dist/mcp/handlers/session.d.ts +34 -0
- package/dist/mcp/handlers/session.js +135 -0
- package/dist/mcp/handlers/v2-workflow.d.ts +4 -0
- package/dist/mcp/handlers/v2-workflow.js +112 -0
- package/dist/mcp/handlers/workflow.d.ts +45 -0
- package/dist/mcp/handlers/workflow.js +167 -0
- package/dist/mcp/index.d.ts +16 -0
- package/dist/mcp/index.js +51 -0
- package/dist/mcp/output-schemas.d.ts +317 -0
- package/dist/mcp/output-schemas.js +91 -0
- package/dist/mcp/server.d.ts +3 -0
- package/dist/mcp/server.js +258 -0
- package/dist/mcp/tool-description-provider.d.ts +16 -0
- package/dist/mcp/tool-description-provider.js +43 -0
- package/dist/mcp/tool-descriptions.d.ts +2 -0
- package/dist/mcp/tool-descriptions.js +109 -0
- package/dist/mcp/tool-factory.d.ts +23 -0
- package/dist/mcp/tool-factory.js +14 -0
- package/dist/mcp/tools.d.ts +156 -0
- package/dist/mcp/tools.js +196 -0
- package/dist/mcp/types/tool-description-types.d.ts +8 -0
- package/dist/mcp/types/tool-description-types.js +24 -0
- package/dist/mcp/types.d.ts +25 -0
- package/dist/mcp/types.js +15 -0
- package/dist/mcp/v2/tool-registry.d.ts +11 -0
- package/dist/mcp/v2/tool-registry.js +26 -0
- package/dist/mcp/v2/tools.d.ts +20 -0
- package/dist/mcp/v2/tools.js +17 -0
- package/dist/mcp/validation/bounded-json.d.ts +3 -0
- package/dist/mcp/validation/bounded-json.js +22 -0
- package/dist/mcp/validation/workflow-next-prevalidate.d.ts +9 -0
- package/dist/mcp/validation/workflow-next-prevalidate.js +83 -0
- package/dist/mcp/zod-to-json-schema.d.ts +17 -0
- package/dist/mcp/zod-to-json-schema.js +134 -0
- package/dist/mcp-server.d.ts +1 -1
- package/dist/mcp-server.js +6 -424
- package/dist/runtime/adapters/in-memory-shutdown-events.d.ts +6 -0
- package/dist/runtime/adapters/in-memory-shutdown-events.js +20 -0
- package/dist/runtime/adapters/node-process-signals.d.ts +4 -0
- package/dist/runtime/adapters/node-process-signals.js +11 -0
- package/dist/runtime/adapters/node-process-terminator.d.ts +4 -0
- package/dist/runtime/adapters/node-process-terminator.js +17 -0
- package/dist/runtime/adapters/noop-process-signals.d.ts +4 -0
- package/dist/runtime/adapters/noop-process-signals.js +8 -0
- package/dist/runtime/adapters/throwing-process-terminator.d.ts +4 -0
- package/dist/runtime/adapters/throwing-process-terminator.js +9 -0
- package/dist/runtime/assert-never.d.ts +1 -0
- package/dist/runtime/assert-never.js +6 -0
- package/dist/runtime/brand.d.ts +5 -0
- package/dist/runtime/ports/process-signals.d.ts +4 -0
- package/dist/runtime/ports/process-signals.js +2 -0
- package/dist/runtime/ports/process-terminator.d.ts +8 -0
- package/dist/runtime/ports/process-terminator.js +2 -0
- package/dist/runtime/ports/shutdown-events.d.ts +11 -0
- package/dist/runtime/ports/shutdown-events.js +2 -0
- package/dist/runtime/process-lifecycle-policy.d.ts +5 -0
- package/dist/runtime/process-lifecycle-policy.js +2 -0
- package/dist/runtime/result.d.ts +17 -0
- package/dist/runtime/result.js +31 -0
- package/dist/runtime/runtime-mode.d.ts +9 -0
- package/dist/runtime/runtime-mode.js +2 -0
- package/dist/types/storage.d.ts +16 -5
- package/dist/types/storage.js +8 -0
- package/dist/types/validation.d.ts +27 -0
- package/dist/types/validation.js +10 -0
- package/dist/types/workflow-definition.d.ts +63 -0
- package/dist/types/workflow-definition.js +33 -0
- package/dist/types/workflow-source.d.ts +51 -0
- package/dist/types/workflow-source.js +128 -0
- package/dist/types/workflow.d.ts +28 -0
- package/dist/types/workflow.js +96 -0
- package/dist/utils/workflow-init.d.ts +1 -0
- package/dist/utils/workflow-init.js +38 -0
- package/dist/v2/durable-core/canonical/hashing.d.ts +11 -0
- package/dist/v2/durable-core/canonical/hashing.js +13 -0
- package/dist/v2/durable-core/canonical/jcs.d.ts +11 -0
- package/dist/v2/durable-core/canonical/jcs.js +65 -0
- package/dist/v2/durable-core/canonical/json-types.d.ts +6 -0
- package/dist/v2/durable-core/canonical/json-types.js +2 -0
- package/dist/v2/durable-core/canonical/json-zod.d.ts +2 -0
- package/dist/v2/durable-core/canonical/json-zod.js +7 -0
- package/dist/v2/durable-core/canonical/jsonl.d.ts +4 -0
- package/dist/v2/durable-core/canonical/jsonl.js +13 -0
- package/dist/v2/durable-core/ids/index.d.ts +23 -0
- package/dist/v2/durable-core/ids/index.js +46 -0
- package/dist/v2/durable-core/schemas/compiled-workflow/index.d.ts +47 -0
- package/dist/v2/durable-core/schemas/compiled-workflow/index.js +17 -0
- package/dist/v2/durable-core/schemas/session/events.d.ts +1812 -0
- package/dist/v2/durable-core/schemas/session/events.js +328 -0
- package/dist/v2/durable-core/schemas/session/index.d.ts +2 -0
- package/dist/v2/durable-core/schemas/session/index.js +8 -0
- package/dist/v2/durable-core/schemas/session/manifest.d.ts +57 -0
- package/dist/v2/durable-core/schemas/session/manifest.js +30 -0
- package/dist/v2/infra/local/crypto/index.d.ts +5 -0
- package/dist/v2/infra/local/crypto/index.js +12 -0
- package/dist/v2/infra/local/data-dir/index.d.ts +13 -0
- package/dist/v2/infra/local/data-dir/index.js +69 -0
- package/dist/v2/infra/local/fs/index.d.ts +26 -0
- package/dist/v2/infra/local/fs/index.js +156 -0
- package/dist/v2/infra/local/pinned-workflow-store/index.d.ts +11 -0
- package/dist/v2/infra/local/pinned-workflow-store/index.js +85 -0
- package/dist/v2/infra/local/session-lock/index.d.ts +12 -0
- package/dist/v2/infra/local/session-lock/index.js +44 -0
- package/dist/v2/infra/local/session-store/index.d.ts +22 -0
- package/dist/v2/infra/local/session-store/index.js +358 -0
- package/dist/v2/infra/local/sha256/index.d.ts +5 -0
- package/dist/v2/infra/local/sha256/index.js +12 -0
- package/dist/v2/ports/data-dir.port.d.ts +9 -0
- package/dist/v2/ports/data-dir.port.js +2 -0
- package/dist/v2/ports/fs.port.d.ts +41 -0
- package/dist/v2/ports/fs.port.js +2 -0
- package/dist/v2/ports/pinned-workflow-store.port.d.ts +11 -0
- package/dist/v2/ports/pinned-workflow-store.port.js +2 -0
- package/dist/v2/ports/session-event-log-store.port.d.ts +37 -0
- package/dist/v2/ports/session-event-log-store.port.js +2 -0
- package/dist/v2/ports/session-lock.port.d.ts +23 -0
- package/dist/v2/ports/session-lock.port.js +2 -0
- package/dist/v2/ports/sha256.port.d.ts +4 -0
- package/dist/v2/ports/sha256.port.js +2 -0
- package/dist/v2/projections/advance-outcomes.d.ts +23 -0
- package/dist/v2/projections/advance-outcomes.js +23 -0
- package/dist/v2/projections/capabilities.d.ts +27 -0
- package/dist/v2/projections/capabilities.js +33 -0
- package/dist/v2/projections/gaps.d.ts +29 -0
- package/dist/v2/projections/gaps.js +49 -0
- package/dist/v2/projections/node-outputs.d.ts +34 -0
- package/dist/v2/projections/node-outputs.js +73 -0
- package/dist/v2/projections/preferences.d.ts +28 -0
- package/dist/v2/projections/preferences.js +50 -0
- package/dist/v2/projections/run-dag.d.ts +42 -0
- package/dist/v2/projections/run-dag.js +186 -0
- package/dist/v2/projections/run-status-signals.d.ts +26 -0
- package/dist/v2/projections/run-status-signals.js +49 -0
- package/dist/v2/projections/session-health.d.ts +18 -0
- package/dist/v2/projections/session-health.js +15 -0
- package/dist/v2/read-only/v1-to-v2-shim.d.ts +3 -0
- package/dist/v2/read-only/v1-to-v2-shim.js +38 -0
- package/package.json +35 -10
- package/spec/mcp-api-v1.0.md +5 -5
- package/web/assets/services/data-normalizer.js +17 -2
- package/web/assets/services/pattern-recognizer.js +3 -1
- package/web/assets/services/session-data.js +13 -8
- package/web/assets/utils/formatters.js +34 -23
- package/workflows/CHANGELOG-bug-investigation.md +4 -4
- package/workflows/coding-task-workflow-agentic.json +262 -0
- package/workflows/design-thinking-workflow-autonomous.agentic.json +215 -0
- package/workflows/design-thinking-workflow.json +198 -0
- package/workflows/mr-review-workflow.agentic.json +538 -0
- package/workflows/routines/context-gathering.json +0 -4
- package/dist/application/app.d.ts +0 -29
- package/dist/application/app.d.ts.map +0 -1
- package/dist/application/app.js +0 -114
- package/dist/application/app.js.map +0 -1
- package/dist/application/decorators/simple-output-decorator.d.ts +0 -8
- package/dist/application/decorators/simple-output-decorator.js +0 -89
- package/dist/application/services/classification-engine.d.ts +0 -33
- package/dist/application/services/classification-engine.js +0 -258
- package/dist/application/services/compression-service.d.ts +0 -20
- package/dist/application/services/compression-service.js +0 -312
- package/dist/application/services/context-management-service.d.ts +0 -38
- package/dist/application/services/context-management-service.js +0 -301
- package/dist/application/services/context-optimizer.d.ts +0 -11
- package/dist/application/services/context-optimizer.js +0 -62
- package/dist/application/services/context-persistence-service.d.ts +0 -45
- package/dist/application/services/context-persistence-service.js +0 -273
- package/dist/application/services/documentation-service.d.ts +0 -20
- package/dist/application/services/documentation-service.js +0 -155
- package/dist/application/services/enhanced-error-service.d.ts.map +0 -1
- package/dist/application/services/enhanced-error-service.js.map +0 -1
- package/dist/application/services/loop-context-optimizer.d.ts +0 -8
- package/dist/application/services/loop-context-optimizer.js +0 -114
- package/dist/application/services/loop-execution-context.d.ts +0 -23
- package/dist/application/services/loop-execution-context.js +0 -188
- package/dist/application/services/loop-step-resolver.d.ts +0 -11
- package/dist/application/services/loop-step-resolver.js +0 -70
- package/dist/application/services/validation-engine.d.ts.map +0 -1
- package/dist/application/services/validation-engine.js.map +0 -1
- package/dist/application/services/workflow-service.d.ts.map +0 -1
- package/dist/application/services/workflow-service.js.map +0 -1
- package/dist/application/use-cases/get-next-step.d.ts.map +0 -1
- package/dist/application/use-cases/get-next-step.js.map +0 -1
- package/dist/application/use-cases/get-workflow-docs.d.ts +0 -4
- package/dist/application/use-cases/get-workflow-docs.js +0 -12
- package/dist/application/use-cases/get-workflow.d.ts.map +0 -1
- package/dist/application/use-cases/get-workflow.js.map +0 -1
- package/dist/application/use-cases/get-workrail-help.d.ts +0 -4
- package/dist/application/use-cases/get-workrail-help.js +0 -12
- package/dist/application/use-cases/list-workflows.d.ts.map +0 -1
- package/dist/application/use-cases/list-workflows.js.map +0 -1
- package/dist/application/use-cases/validate-step-output.d.ts.map +0 -1
- package/dist/application/use-cases/validate-step-output.js.map +0 -1
- package/dist/application/use-cases/validate-workflow-json.d.ts.map +0 -1
- package/dist/application/use-cases/validate-workflow-json.js.map +0 -1
- package/dist/application/validation.d.ts.map +0 -1
- package/dist/application/validation.js.map +0 -1
- package/dist/cli/migrate-workflow.d.ts +0 -22
- package/dist/cli/migrate-workflow.js +0 -196
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/container.d.ts +0 -15
- package/dist/container.d.ts.map +0 -1
- package/dist/container.js +0 -25
- package/dist/container.js.map +0 -1
- package/dist/core/error-handler.d.ts.map +0 -1
- package/dist/core/error-handler.js.map +0 -1
- package/dist/domain/index.d.ts +0 -2
- package/dist/domain/index.d.ts.map +0 -1
- package/dist/domain/index.js +0 -18
- package/dist/domain/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/infrastructure/index.d.ts.map +0 -1
- package/dist/infrastructure/index.js.map +0 -1
- package/dist/infrastructure/rpc/handler.d.ts +0 -17
- package/dist/infrastructure/rpc/handler.d.ts.map +0 -1
- package/dist/infrastructure/rpc/handler.js +0 -78
- package/dist/infrastructure/rpc/handler.js.map +0 -1
- package/dist/infrastructure/rpc/index.d.ts +0 -1
- package/dist/infrastructure/rpc/index.d.ts.map +0 -1
- package/dist/infrastructure/rpc/index.js +0 -17
- package/dist/infrastructure/rpc/index.js.map +0 -1
- package/dist/infrastructure/rpc/server.d.ts +0 -3
- package/dist/infrastructure/rpc/server.d.ts.map +0 -1
- package/dist/infrastructure/rpc/server.js +0 -37
- package/dist/infrastructure/rpc/server.js.map +0 -1
- package/dist/infrastructure/storage/caching-workflow-storage.d.ts.map +0 -1
- package/dist/infrastructure/storage/caching-workflow-storage.js.map +0 -1
- package/dist/infrastructure/storage/context-storage.d.ts +0 -150
- package/dist/infrastructure/storage/context-storage.js +0 -40
- package/dist/infrastructure/storage/file-workflow-storage.d.ts.map +0 -1
- package/dist/infrastructure/storage/file-workflow-storage.js.map +0 -1
- package/dist/infrastructure/storage/filesystem-blob-storage.d.ts +0 -27
- package/dist/infrastructure/storage/filesystem-blob-storage.js +0 -363
- package/dist/infrastructure/storage/git-workflow-storage.d.ts.map +0 -1
- package/dist/infrastructure/storage/git-workflow-storage.js.map +0 -1
- package/dist/infrastructure/storage/hybrid-context-storage.d.ts +0 -29
- package/dist/infrastructure/storage/hybrid-context-storage.js +0 -400
- package/dist/infrastructure/storage/in-memory-storage.d.ts.map +0 -1
- package/dist/infrastructure/storage/in-memory-storage.js.map +0 -1
- package/dist/infrastructure/storage/index.d.ts.map +0 -1
- package/dist/infrastructure/storage/index.js.map +0 -1
- package/dist/infrastructure/storage/migrations/001_initial_schema.sql +0 -38
- package/dist/infrastructure/storage/migrations/002_context_concurrency_enhancements.sql +0 -234
- package/dist/infrastructure/storage/migrations/003_classification_overrides.sql +0 -20
- package/dist/infrastructure/storage/multi-directory-workflow-storage.d.ts +0 -32
- package/dist/infrastructure/storage/multi-directory-workflow-storage.d.ts.map +0 -1
- package/dist/infrastructure/storage/multi-directory-workflow-storage.js +0 -184
- package/dist/infrastructure/storage/multi-directory-workflow-storage.js.map +0 -1
- package/dist/infrastructure/storage/plugin-workflow-storage.d.ts.map +0 -1
- package/dist/infrastructure/storage/plugin-workflow-storage.js.map +0 -1
- package/dist/infrastructure/storage/remote-workflow-storage.d.ts.map +0 -1
- package/dist/infrastructure/storage/remote-workflow-storage.js.map +0 -1
- package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts.map +0 -1
- package/dist/infrastructure/storage/schema-validating-workflow-storage.js.map +0 -1
- package/dist/infrastructure/storage/sqlite-metadata-storage.d.ts +0 -35
- package/dist/infrastructure/storage/sqlite-metadata-storage.js +0 -410
- package/dist/infrastructure/storage/sqlite-migrator.d.ts +0 -46
- package/dist/infrastructure/storage/sqlite-migrator.js +0 -293
- package/dist/infrastructure/storage/storage.d.ts.map +0 -1
- package/dist/infrastructure/storage/storage.js.map +0 -1
- package/dist/mcp-server.d.ts.map +0 -1
- package/dist/mcp-server.js.map +0 -1
- package/dist/tools/mcp_initialize.d.ts +0 -2
- package/dist/tools/mcp_initialize.d.ts.map +0 -1
- package/dist/tools/mcp_initialize.js +0 -45
- package/dist/tools/mcp_initialize.js.map +0 -1
- package/dist/tools/mcp_shutdown.d.ts +0 -2
- package/dist/tools/mcp_shutdown.d.ts.map +0 -1
- package/dist/tools/mcp_shutdown.js +0 -10
- package/dist/tools/mcp_shutdown.js.map +0 -1
- package/dist/tools/mcp_tools_list.d.ts +0 -2
- package/dist/tools/mcp_tools_list.d.ts.map +0 -1
- package/dist/tools/mcp_tools_list.js +0 -60
- package/dist/tools/mcp_tools_list.js.map +0 -1
- package/dist/tools/session-tools.d.ts +0 -5
- package/dist/tools/session-tools.js +0 -270
- package/dist/types/context-types.d.ts +0 -236
- package/dist/types/context-types.js +0 -10
- package/dist/types/documentation-types.d.ts +0 -37
- package/dist/types/loop-context-optimizer.d.ts +0 -7
- package/dist/types/mcp-types.d.ts +0 -273
- package/dist/types/mcp-types.d.ts.map +0 -1
- package/dist/types/mcp-types.js +0 -19
- package/dist/types/mcp-types.js.map +0 -1
- package/dist/types/server.d.ts.map +0 -1
- package/dist/types/server.js.map +0 -1
- package/dist/types/storage.d.ts.map +0 -1
- package/dist/types/storage.js.map +0 -1
- package/dist/types/workflow-types.d.ts +0 -336
- package/dist/types/workflow-types.d.ts.map +0 -1
- package/dist/types/workflow-types.js +0 -20
- package/dist/types/workflow-types.js.map +0 -1
- package/dist/utils/condition-evaluator.d.ts.map +0 -1
- package/dist/utils/condition-evaluator.js.map +0 -1
- package/dist/utils/config.d.ts +0 -149
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js +0 -251
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/storage-security.d.ts.map +0 -1
- package/dist/utils/storage-security.js.map +0 -1
- package/dist/validation/request-validator.d.ts +0 -8
- package/dist/validation/request-validator.d.ts.map +0 -1
- package/dist/validation/request-validator.js +0 -32
- package/dist/validation/request-validator.js.map +0 -1
- package/dist/validation/response-validator.d.ts +0 -8
- package/dist/validation/response-validator.d.ts.map +0 -1
- package/dist/validation/response-validator.js +0 -110
- package/dist/validation/response-validator.js.map +0 -1
- package/dist/validation/schemas.d.ts +0 -1
- package/dist/validation/schemas.d.ts.map +0 -1
- package/dist/validation/schemas.js +0 -53
- package/dist/validation/schemas.js.map +0 -1
- /package/dist/{types/documentation-types.js → errors/app-error.js} +0 -0
- /package/dist/{types/loop-context-optimizer.js → runtime/brand.js} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
2
|
+
import type { DomainEventV1 } from '../durable-core/schemas/session/index.js';
|
|
3
|
+
export type ProjectionError = {
|
|
4
|
+
readonly code: 'PROJECTION_INVARIANT_VIOLATION';
|
|
5
|
+
readonly message: string;
|
|
6
|
+
} | {
|
|
7
|
+
readonly code: 'PROJECTION_CORRUPTION_DETECTED';
|
|
8
|
+
readonly message: string;
|
|
9
|
+
};
|
|
10
|
+
type GapRecordedEventV1 = Extract<DomainEventV1, {
|
|
11
|
+
kind: 'gap_recorded';
|
|
12
|
+
}>;
|
|
13
|
+
export interface GapV2 {
|
|
14
|
+
readonly gapId: string;
|
|
15
|
+
readonly severity: GapRecordedEventV1['data']['severity'];
|
|
16
|
+
readonly reason: GapRecordedEventV1['data']['reason'];
|
|
17
|
+
readonly summary: string;
|
|
18
|
+
readonly recordedAtEventIndex: number;
|
|
19
|
+
readonly nodeId: string;
|
|
20
|
+
readonly runId: string;
|
|
21
|
+
readonly resolution: GapRecordedEventV1['data']['resolution'];
|
|
22
|
+
}
|
|
23
|
+
export interface GapsProjectionV2 {
|
|
24
|
+
readonly byGapId: Readonly<Record<string, GapV2>>;
|
|
25
|
+
readonly resolvedGapIds: ReadonlySet<string>;
|
|
26
|
+
readonly unresolvedCriticalByRunId: Readonly<Record<string, readonly GapV2[]>>;
|
|
27
|
+
}
|
|
28
|
+
export declare function projectGapsV2(events: readonly DomainEventV1[]): Result<GapsProjectionV2, ProjectionError>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectGapsV2 = projectGapsV2;
|
|
4
|
+
const neverthrow_1 = require("neverthrow");
|
|
5
|
+
function projectGapsV2(events) {
|
|
6
|
+
for (let i = 1; i < events.length; i++) {
|
|
7
|
+
if (events[i].eventIndex < events[i - 1].eventIndex) {
|
|
8
|
+
return (0, neverthrow_1.err)({ code: 'PROJECTION_INVARIANT_VIOLATION', message: 'Events must be sorted by eventIndex ascending' });
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const byGapId = {};
|
|
12
|
+
const resolved = new Set();
|
|
13
|
+
for (const e of events) {
|
|
14
|
+
if (e.kind !== 'gap_recorded')
|
|
15
|
+
continue;
|
|
16
|
+
const gap = {
|
|
17
|
+
gapId: e.data.gapId,
|
|
18
|
+
severity: e.data.severity,
|
|
19
|
+
reason: e.data.reason,
|
|
20
|
+
summary: e.data.summary,
|
|
21
|
+
recordedAtEventIndex: e.eventIndex,
|
|
22
|
+
nodeId: e.scope.nodeId,
|
|
23
|
+
runId: e.scope.runId,
|
|
24
|
+
resolution: e.data.resolution,
|
|
25
|
+
};
|
|
26
|
+
byGapId[gap.gapId] = gap;
|
|
27
|
+
if (gap.resolution.kind === 'resolves') {
|
|
28
|
+
resolved.add(gap.resolution.resolvesGapId);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const unresolvedCriticalByRunId = {};
|
|
32
|
+
for (const gap of Object.values(byGapId)) {
|
|
33
|
+
if (resolved.has(gap.gapId))
|
|
34
|
+
continue;
|
|
35
|
+
if (gap.resolution.kind !== 'unresolved')
|
|
36
|
+
continue;
|
|
37
|
+
if (gap.severity !== 'critical')
|
|
38
|
+
continue;
|
|
39
|
+
const list = unresolvedCriticalByRunId[gap.runId] ?? [];
|
|
40
|
+
list.push(gap);
|
|
41
|
+
unresolvedCriticalByRunId[gap.runId] = list;
|
|
42
|
+
}
|
|
43
|
+
for (const runId of Object.keys(unresolvedCriticalByRunId)) {
|
|
44
|
+
unresolvedCriticalByRunId[runId] = unresolvedCriticalByRunId[runId]
|
|
45
|
+
.slice()
|
|
46
|
+
.sort((a, b) => a.recordedAtEventIndex - b.recordedAtEventIndex || a.gapId.localeCompare(b.gapId));
|
|
47
|
+
}
|
|
48
|
+
return (0, neverthrow_1.ok)({ byGapId, resolvedGapIds: resolved, unresolvedCriticalByRunId });
|
|
49
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
2
|
+
import type { DomainEventV1 } from '../durable-core/schemas/session/index.js';
|
|
3
|
+
export type ProjectionError = {
|
|
4
|
+
readonly code: 'PROJECTION_INVARIANT_VIOLATION';
|
|
5
|
+
readonly message: string;
|
|
6
|
+
} | {
|
|
7
|
+
readonly code: 'PROJECTION_CORRUPTION_DETECTED';
|
|
8
|
+
readonly message: string;
|
|
9
|
+
};
|
|
10
|
+
export type OutputChannelV2 = 'recap' | 'artifact';
|
|
11
|
+
export type OutputPayloadV2 = {
|
|
12
|
+
readonly payloadKind: 'notes';
|
|
13
|
+
readonly notesMarkdown: string;
|
|
14
|
+
} | {
|
|
15
|
+
readonly payloadKind: 'artifact_ref';
|
|
16
|
+
readonly sha256: string;
|
|
17
|
+
readonly contentType: string;
|
|
18
|
+
readonly byteLength: number;
|
|
19
|
+
};
|
|
20
|
+
export interface NodeOutputV2 {
|
|
21
|
+
readonly outputId: string;
|
|
22
|
+
readonly outputChannel: OutputChannelV2;
|
|
23
|
+
readonly payload: OutputPayloadV2;
|
|
24
|
+
readonly supersedesOutputId?: string;
|
|
25
|
+
readonly createdAtEventIndex: number;
|
|
26
|
+
}
|
|
27
|
+
export interface NodeOutputsViewV2 {
|
|
28
|
+
readonly historyByChannel: Readonly<Record<OutputChannelV2, readonly NodeOutputV2[]>>;
|
|
29
|
+
readonly currentByChannel: Readonly<Record<OutputChannelV2, readonly NodeOutputV2[]>>;
|
|
30
|
+
}
|
|
31
|
+
export interface NodeOutputsProjectionV2 {
|
|
32
|
+
readonly nodesById: Readonly<Record<string, NodeOutputsViewV2>>;
|
|
33
|
+
}
|
|
34
|
+
export declare function projectNodeOutputsV2(events: readonly DomainEventV1[]): Result<NodeOutputsProjectionV2, ProjectionError>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectNodeOutputsV2 = projectNodeOutputsV2;
|
|
4
|
+
const neverthrow_1 = require("neverthrow");
|
|
5
|
+
function projectNodeOutputsV2(events) {
|
|
6
|
+
const byNode = {};
|
|
7
|
+
const ensure = (nodeId) => {
|
|
8
|
+
const existing = byNode[nodeId];
|
|
9
|
+
if (existing)
|
|
10
|
+
return existing;
|
|
11
|
+
const created = { byChannel: { recap: [], artifact: [] } };
|
|
12
|
+
byNode[nodeId] = created;
|
|
13
|
+
return created;
|
|
14
|
+
};
|
|
15
|
+
for (let i = 1; i < events.length; i++) {
|
|
16
|
+
if (events[i].eventIndex < events[i - 1].eventIndex) {
|
|
17
|
+
return (0, neverthrow_1.err)({ code: 'PROJECTION_INVARIANT_VIOLATION', message: 'Events must be sorted by eventIndex ascending' });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
for (const e of events) {
|
|
21
|
+
if (e.kind !== 'node_output_appended')
|
|
22
|
+
continue;
|
|
23
|
+
const nodeId = e.scope.nodeId;
|
|
24
|
+
const out = {
|
|
25
|
+
outputId: e.data.outputId,
|
|
26
|
+
outputChannel: e.data.outputChannel,
|
|
27
|
+
payload: e.data.payload,
|
|
28
|
+
supersedesOutputId: e.data.supersedesOutputId,
|
|
29
|
+
createdAtEventIndex: e.eventIndex,
|
|
30
|
+
};
|
|
31
|
+
ensure(nodeId).byChannel[out.outputChannel].push(out);
|
|
32
|
+
}
|
|
33
|
+
const nodesById = {};
|
|
34
|
+
for (const [nodeId, record] of Object.entries(byNode)) {
|
|
35
|
+
const historyByChannel = {
|
|
36
|
+
recap: record.byChannel.recap,
|
|
37
|
+
artifact: record.byChannel.artifact,
|
|
38
|
+
};
|
|
39
|
+
const currentByChannel = {
|
|
40
|
+
recap: [],
|
|
41
|
+
artifact: [],
|
|
42
|
+
};
|
|
43
|
+
for (const channel of ['recap', 'artifact']) {
|
|
44
|
+
const history = historyByChannel[channel];
|
|
45
|
+
const superseded = new Set();
|
|
46
|
+
for (const o of history) {
|
|
47
|
+
if (!o.supersedesOutputId)
|
|
48
|
+
continue;
|
|
49
|
+
const target = history.find((x) => x.outputId === o.supersedesOutputId);
|
|
50
|
+
if (!target) {
|
|
51
|
+
return (0, neverthrow_1.err)({
|
|
52
|
+
code: 'PROJECTION_CORRUPTION_DETECTED',
|
|
53
|
+
message: `supersedesOutputId references missing output (nodeId=${nodeId}, channel=${channel}, supersedes=${o.supersedesOutputId})`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
superseded.add(o.supersedesOutputId);
|
|
57
|
+
}
|
|
58
|
+
const current = history.filter((o) => !superseded.has(o.outputId));
|
|
59
|
+
if (channel === 'recap' && current.length > 1) {
|
|
60
|
+
return (0, neverthrow_1.err)({
|
|
61
|
+
code: 'PROJECTION_CORRUPTION_DETECTED',
|
|
62
|
+
message: `Multiple current recap outputs detected for nodeId=${nodeId}`,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
currentByChannel[channel] = current;
|
|
66
|
+
}
|
|
67
|
+
nodesById[nodeId] = {
|
|
68
|
+
historyByChannel,
|
|
69
|
+
currentByChannel,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return (0, neverthrow_1.ok)({ nodesById });
|
|
73
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
2
|
+
import type { DomainEventV1 } from '../durable-core/schemas/session/index.js';
|
|
3
|
+
export type ProjectionError = {
|
|
4
|
+
readonly code: 'PROJECTION_INVARIANT_VIOLATION';
|
|
5
|
+
readonly message: string;
|
|
6
|
+
} | {
|
|
7
|
+
readonly code: 'PROJECTION_CORRUPTION_DETECTED';
|
|
8
|
+
readonly message: string;
|
|
9
|
+
};
|
|
10
|
+
type PreferencesChangedEventV1 = Extract<DomainEventV1, {
|
|
11
|
+
kind: 'preferences_changed';
|
|
12
|
+
}>;
|
|
13
|
+
export type AutonomyV2 = 'guided' | 'full_auto_stop_on_user_deps' | 'full_auto_never_stop';
|
|
14
|
+
export type RiskPolicyV2 = 'conservative' | 'balanced' | 'aggressive';
|
|
15
|
+
export interface EffectivePreferencesV2 {
|
|
16
|
+
readonly autonomy: AutonomyV2;
|
|
17
|
+
readonly riskPolicy: RiskPolicyV2;
|
|
18
|
+
}
|
|
19
|
+
export interface NodePreferencesV2 {
|
|
20
|
+
readonly nodeId: string;
|
|
21
|
+
readonly effective: EffectivePreferencesV2;
|
|
22
|
+
readonly changesAtThisNode: readonly PreferencesChangedEventV1[];
|
|
23
|
+
}
|
|
24
|
+
export interface PreferencesProjectionV2 {
|
|
25
|
+
readonly byNodeId: Readonly<Record<string, NodePreferencesV2>>;
|
|
26
|
+
}
|
|
27
|
+
export declare function projectPreferencesV2(events: readonly DomainEventV1[], parentByNodeId: Readonly<Record<string, string | null>>): Result<PreferencesProjectionV2, ProjectionError>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectPreferencesV2 = projectPreferencesV2;
|
|
4
|
+
const neverthrow_1 = require("neverthrow");
|
|
5
|
+
const defaultPrefs = { autonomy: 'guided', riskPolicy: 'conservative' };
|
|
6
|
+
function projectPreferencesV2(events, parentByNodeId) {
|
|
7
|
+
for (let i = 1; i < events.length; i++) {
|
|
8
|
+
if (events[i].eventIndex < events[i - 1].eventIndex) {
|
|
9
|
+
return (0, neverthrow_1.err)({ code: 'PROJECTION_INVARIANT_VIOLATION', message: 'Events must be sorted by eventIndex ascending' });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const changesByNodeId = {};
|
|
13
|
+
for (const e of events) {
|
|
14
|
+
if (e.kind !== 'preferences_changed')
|
|
15
|
+
continue;
|
|
16
|
+
const list = changesByNodeId[e.scope.nodeId] ?? [];
|
|
17
|
+
list.push(e);
|
|
18
|
+
changesByNodeId[e.scope.nodeId] = list;
|
|
19
|
+
}
|
|
20
|
+
const byNodeId = {};
|
|
21
|
+
const ancestorChainOf = (nodeId) => {
|
|
22
|
+
const chain = [];
|
|
23
|
+
let cur = nodeId;
|
|
24
|
+
const visited = new Set();
|
|
25
|
+
while (cur) {
|
|
26
|
+
if (visited.has(cur))
|
|
27
|
+
break;
|
|
28
|
+
visited.add(cur);
|
|
29
|
+
chain.push(cur);
|
|
30
|
+
cur = parentByNodeId[cur] ?? null;
|
|
31
|
+
}
|
|
32
|
+
return chain.reverse();
|
|
33
|
+
};
|
|
34
|
+
for (const nodeId of Object.keys(parentByNodeId)) {
|
|
35
|
+
const chain = ancestorChainOf(nodeId);
|
|
36
|
+
let effective = defaultPrefs;
|
|
37
|
+
const changesAtThisNode = [];
|
|
38
|
+
for (const ancestor of chain) {
|
|
39
|
+
const changes = changesByNodeId[ancestor] ?? [];
|
|
40
|
+
for (const change of changes) {
|
|
41
|
+
effective = change.data.effective;
|
|
42
|
+
if (ancestor === nodeId) {
|
|
43
|
+
changesAtThisNode.push(change);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
byNodeId[nodeId] = { nodeId, effective, changesAtThisNode };
|
|
48
|
+
}
|
|
49
|
+
return (0, neverthrow_1.ok)({ byNodeId });
|
|
50
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
2
|
+
import type { DomainEventV1 } from '../durable-core/schemas/session/index.js';
|
|
3
|
+
export type NodeKindV2 = 'step' | 'checkpoint';
|
|
4
|
+
export type EdgeKindV2 = 'acked_step' | 'checkpoint';
|
|
5
|
+
export type ProjectionError = {
|
|
6
|
+
readonly code: 'PROJECTION_INVARIANT_VIOLATION';
|
|
7
|
+
readonly message: string;
|
|
8
|
+
} | {
|
|
9
|
+
readonly code: 'PROJECTION_CORRUPTION_DETECTED';
|
|
10
|
+
readonly message: string;
|
|
11
|
+
};
|
|
12
|
+
export interface RunDagNodeV2 {
|
|
13
|
+
readonly nodeId: string;
|
|
14
|
+
readonly nodeKind: NodeKindV2;
|
|
15
|
+
readonly parentNodeId: string | null;
|
|
16
|
+
readonly workflowHash: string;
|
|
17
|
+
readonly snapshotRef: string;
|
|
18
|
+
readonly createdAtEventIndex: number;
|
|
19
|
+
}
|
|
20
|
+
export interface RunDagEdgeV2 {
|
|
21
|
+
readonly edgeKind: EdgeKindV2;
|
|
22
|
+
readonly fromNodeId: string;
|
|
23
|
+
readonly toNodeId: string;
|
|
24
|
+
readonly cause: {
|
|
25
|
+
readonly kind: string;
|
|
26
|
+
readonly eventId: string;
|
|
27
|
+
};
|
|
28
|
+
readonly createdAtEventIndex: number;
|
|
29
|
+
}
|
|
30
|
+
export interface RunDagRunV2 {
|
|
31
|
+
readonly runId: string;
|
|
32
|
+
readonly workflowId: string | null;
|
|
33
|
+
readonly workflowHash: string | null;
|
|
34
|
+
readonly nodesById: Readonly<Record<string, RunDagNodeV2>>;
|
|
35
|
+
readonly edges: readonly RunDagEdgeV2[];
|
|
36
|
+
readonly tipNodeIds: readonly string[];
|
|
37
|
+
readonly preferredTipNodeId: string | null;
|
|
38
|
+
}
|
|
39
|
+
export interface RunDagProjectionV2 {
|
|
40
|
+
readonly runsById: Readonly<Record<string, RunDagRunV2>>;
|
|
41
|
+
}
|
|
42
|
+
export declare function projectRunDagV2(events: readonly DomainEventV1[]): Result<RunDagProjectionV2, ProjectionError>;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectRunDagV2 = projectRunDagV2;
|
|
4
|
+
const neverthrow_1 = require("neverthrow");
|
|
5
|
+
function projectRunDagV2(events) {
|
|
6
|
+
for (let i = 1; i < events.length; i++) {
|
|
7
|
+
if (events[i].eventIndex < events[i - 1].eventIndex) {
|
|
8
|
+
return (0, neverthrow_1.err)({
|
|
9
|
+
code: 'PROJECTION_INVARIANT_VIOLATION',
|
|
10
|
+
message: 'Events must be sorted by eventIndex ascending',
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const runs = {};
|
|
15
|
+
const ensureRun = (runId) => {
|
|
16
|
+
const existing = runs[runId];
|
|
17
|
+
if (existing)
|
|
18
|
+
return existing;
|
|
19
|
+
const created = {
|
|
20
|
+
runId,
|
|
21
|
+
workflowId: null,
|
|
22
|
+
workflowHash: null,
|
|
23
|
+
nodesById: {},
|
|
24
|
+
edges: [],
|
|
25
|
+
tipNodeIds: [],
|
|
26
|
+
preferredTipNodeId: null,
|
|
27
|
+
};
|
|
28
|
+
runs[runId] = created;
|
|
29
|
+
return created;
|
|
30
|
+
};
|
|
31
|
+
for (const e of events) {
|
|
32
|
+
switch (e.kind) {
|
|
33
|
+
case 'run_started': {
|
|
34
|
+
const runId = e.scope.runId;
|
|
35
|
+
const run = ensureRun(runId);
|
|
36
|
+
if (run.workflowHash && run.workflowHash !== e.data.workflowHash) {
|
|
37
|
+
return (0, neverthrow_1.err)({
|
|
38
|
+
code: 'PROJECTION_CORRUPTION_DETECTED',
|
|
39
|
+
message: `run_started workflowHash mismatch for runId=${runId}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
run.workflowId = e.data.workflowId;
|
|
43
|
+
run.workflowHash = e.data.workflowHash;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case 'node_created': {
|
|
47
|
+
const runId = e.scope.runId;
|
|
48
|
+
const nodeId = e.scope.nodeId;
|
|
49
|
+
const run = ensureRun(runId);
|
|
50
|
+
const existing = run.nodesById[nodeId];
|
|
51
|
+
const node = {
|
|
52
|
+
nodeId,
|
|
53
|
+
nodeKind: e.data.nodeKind,
|
|
54
|
+
parentNodeId: e.data.parentNodeId,
|
|
55
|
+
workflowHash: e.data.workflowHash,
|
|
56
|
+
snapshotRef: e.data.snapshotRef,
|
|
57
|
+
createdAtEventIndex: e.eventIndex,
|
|
58
|
+
};
|
|
59
|
+
if (existing) {
|
|
60
|
+
if (JSON.stringify(existing) !== JSON.stringify(node)) {
|
|
61
|
+
return (0, neverthrow_1.err)({
|
|
62
|
+
code: 'PROJECTION_CORRUPTION_DETECTED',
|
|
63
|
+
message: `node_created conflict for runId=${runId} nodeId=${nodeId}`,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
if (node.parentNodeId && !run.nodesById[node.parentNodeId]) {
|
|
69
|
+
return (0, neverthrow_1.err)({
|
|
70
|
+
code: 'PROJECTION_INVARIANT_VIOLATION',
|
|
71
|
+
message: `node_created references missing parentNodeId=${node.parentNodeId} (runId=${runId} nodeId=${nodeId})`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
run.nodesById[nodeId] = node;
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case 'edge_created': {
|
|
79
|
+
const runId = e.scope.runId;
|
|
80
|
+
const run = ensureRun(runId);
|
|
81
|
+
const edge = {
|
|
82
|
+
edgeKind: e.data.edgeKind,
|
|
83
|
+
fromNodeId: e.data.fromNodeId,
|
|
84
|
+
toNodeId: e.data.toNodeId,
|
|
85
|
+
cause: e.data.cause,
|
|
86
|
+
createdAtEventIndex: e.eventIndex,
|
|
87
|
+
};
|
|
88
|
+
const from = run.nodesById[edge.fromNodeId];
|
|
89
|
+
const to = run.nodesById[edge.toNodeId];
|
|
90
|
+
if (!from || !to) {
|
|
91
|
+
return (0, neverthrow_1.err)({
|
|
92
|
+
code: 'PROJECTION_INVARIANT_VIOLATION',
|
|
93
|
+
message: `edge_created references missing node(s) (runId=${runId} from=${edge.fromNodeId} to=${edge.toNodeId})`,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (to.parentNodeId !== edge.fromNodeId) {
|
|
97
|
+
return (0, neverthrow_1.err)({
|
|
98
|
+
code: 'PROJECTION_CORRUPTION_DETECTED',
|
|
99
|
+
message: `edge_created violates parent linkage (runId=${runId} to.parentNodeId=${String(to.parentNodeId)} from=${edge.fromNodeId})`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
run.edges.push(edge);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
default:
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
for (const runId of Object.keys(runs)) {
|
|
110
|
+
const run = runs[runId];
|
|
111
|
+
const hasOutgoing = new Set(run.edges.map((e) => e.fromNodeId));
|
|
112
|
+
const tips = Object.keys(run.nodesById).filter((id) => !hasOutgoing.has(id)).sort();
|
|
113
|
+
run.tipNodeIds = tips;
|
|
114
|
+
if (tips.length === 0) {
|
|
115
|
+
run.preferredTipNodeId = null;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const parentById = {};
|
|
119
|
+
for (const n of Object.values(run.nodesById))
|
|
120
|
+
parentById[n.nodeId] = n.parentNodeId;
|
|
121
|
+
const ancestryOf = (leafId) => {
|
|
122
|
+
const set = new Set();
|
|
123
|
+
let cur = leafId;
|
|
124
|
+
while (cur) {
|
|
125
|
+
if (set.has(cur))
|
|
126
|
+
break;
|
|
127
|
+
set.add(cur);
|
|
128
|
+
cur = parentById[cur] ?? null;
|
|
129
|
+
}
|
|
130
|
+
return set;
|
|
131
|
+
};
|
|
132
|
+
const lastActivityFor = (leafId) => {
|
|
133
|
+
const ancestors = ancestryOf(leafId);
|
|
134
|
+
let max = run.nodesById[leafId].createdAtEventIndex;
|
|
135
|
+
for (const e of events) {
|
|
136
|
+
if (e.kind === 'edge_created') {
|
|
137
|
+
if (ancestors.has(e.data.fromNodeId) || ancestors.has(e.data.toNodeId)) {
|
|
138
|
+
if (e.eventIndex > max)
|
|
139
|
+
max = e.eventIndex;
|
|
140
|
+
}
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const nodeId = e.scope?.nodeId;
|
|
144
|
+
if (nodeId && ancestors.has(nodeId)) {
|
|
145
|
+
if (e.eventIndex > max)
|
|
146
|
+
max = e.eventIndex;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return max;
|
|
150
|
+
};
|
|
151
|
+
let bestTip = tips[0];
|
|
152
|
+
let bestActivity = lastActivityFor(bestTip);
|
|
153
|
+
for (let i = 1; i < tips.length; i++) {
|
|
154
|
+
const tip = tips[i];
|
|
155
|
+
const activity = lastActivityFor(tip);
|
|
156
|
+
if (activity > bestActivity) {
|
|
157
|
+
bestTip = tip;
|
|
158
|
+
bestActivity = activity;
|
|
159
|
+
}
|
|
160
|
+
else if (activity === bestActivity) {
|
|
161
|
+
const bestCreated = run.nodesById[bestTip].createdAtEventIndex;
|
|
162
|
+
const tipCreated = run.nodesById[tip].createdAtEventIndex;
|
|
163
|
+
if (tipCreated > bestCreated) {
|
|
164
|
+
bestTip = tip;
|
|
165
|
+
}
|
|
166
|
+
else if (tipCreated === bestCreated && tip < bestTip) {
|
|
167
|
+
bestTip = tip;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
run.preferredTipNodeId = bestTip;
|
|
172
|
+
}
|
|
173
|
+
const runsById = {};
|
|
174
|
+
for (const [runId, run] of Object.entries(runs)) {
|
|
175
|
+
runsById[runId] = {
|
|
176
|
+
runId,
|
|
177
|
+
workflowId: run.workflowId,
|
|
178
|
+
workflowHash: run.workflowHash,
|
|
179
|
+
nodesById: run.nodesById,
|
|
180
|
+
edges: run.edges,
|
|
181
|
+
tipNodeIds: run.tipNodeIds,
|
|
182
|
+
preferredTipNodeId: run.preferredTipNodeId,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return (0, neverthrow_1.ok)({ runsById });
|
|
186
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
2
|
+
import type { DomainEventV1 } from '../durable-core/schemas/session/index.js';
|
|
3
|
+
export type ProjectionError = {
|
|
4
|
+
readonly code: 'PROJECTION_INVARIANT_VIOLATION';
|
|
5
|
+
readonly message: string;
|
|
6
|
+
} | {
|
|
7
|
+
readonly code: 'PROJECTION_CORRUPTION_DETECTED';
|
|
8
|
+
readonly message: string;
|
|
9
|
+
};
|
|
10
|
+
export type AutonomyV2 = 'guided' | 'full_auto_stop_on_user_deps' | 'full_auto_never_stop';
|
|
11
|
+
export type RiskPolicyV2 = 'conservative' | 'balanced' | 'aggressive';
|
|
12
|
+
export interface PreferencesSnapshotV2 {
|
|
13
|
+
readonly autonomy: AutonomyV2;
|
|
14
|
+
readonly riskPolicy: RiskPolicyV2;
|
|
15
|
+
}
|
|
16
|
+
export interface RunStatusSignalsV2 {
|
|
17
|
+
readonly runId: string;
|
|
18
|
+
readonly preferredTipNodeId: string | null;
|
|
19
|
+
readonly effectivePreferencesAtTip: PreferencesSnapshotV2;
|
|
20
|
+
readonly hasUnresolvedCriticalGaps: boolean;
|
|
21
|
+
readonly isBlocked: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface RunStatusSignalsProjectionV2 {
|
|
24
|
+
readonly byRunId: Readonly<Record<string, RunStatusSignalsV2>>;
|
|
25
|
+
}
|
|
26
|
+
export declare function projectRunStatusSignalsV2(events: readonly DomainEventV1[]): Result<RunStatusSignalsProjectionV2, ProjectionError>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectRunStatusSignalsV2 = projectRunStatusSignalsV2;
|
|
4
|
+
const neverthrow_1 = require("neverthrow");
|
|
5
|
+
const run_dag_js_1 = require("./run-dag.js");
|
|
6
|
+
const gaps_js_1 = require("./gaps.js");
|
|
7
|
+
const advance_outcomes_js_1 = require("./advance-outcomes.js");
|
|
8
|
+
function projectRunStatusSignalsV2(events) {
|
|
9
|
+
const dagRes = (0, run_dag_js_1.projectRunDagV2)(events);
|
|
10
|
+
if (dagRes.isErr())
|
|
11
|
+
return (0, neverthrow_1.err)(dagRes.error);
|
|
12
|
+
const dag = dagRes.value;
|
|
13
|
+
const gapsRes = (0, gaps_js_1.projectGapsV2)(events);
|
|
14
|
+
if (gapsRes.isErr())
|
|
15
|
+
return (0, neverthrow_1.err)(gapsRes.error);
|
|
16
|
+
const gaps = gapsRes.value;
|
|
17
|
+
const advanceRes = (0, advance_outcomes_js_1.projectAdvanceOutcomesV2)(events);
|
|
18
|
+
if (advanceRes.isErr())
|
|
19
|
+
return (0, neverthrow_1.err)(advanceRes.error);
|
|
20
|
+
const advances = advanceRes.value;
|
|
21
|
+
const prefsByNodeId = {};
|
|
22
|
+
for (const e of events) {
|
|
23
|
+
if (e.kind !== 'preferences_changed')
|
|
24
|
+
continue;
|
|
25
|
+
prefsByNodeId[e.scope.nodeId] = e.data.effective;
|
|
26
|
+
}
|
|
27
|
+
const defaultPrefs = { autonomy: 'guided', riskPolicy: 'conservative' };
|
|
28
|
+
const byRunId = {};
|
|
29
|
+
for (const [runId, run] of Object.entries(dag.runsById)) {
|
|
30
|
+
const tip = run.preferredTipNodeId;
|
|
31
|
+
const prefs = tip ? prefsByNodeId[tip] ?? defaultPrefs : defaultPrefs;
|
|
32
|
+
const critical = gaps.unresolvedCriticalByRunId[runId] ?? [];
|
|
33
|
+
const hasUnresolvedCriticalGaps = critical.length > 0;
|
|
34
|
+
const hasBlockingCategoryGap = (gaps.unresolvedCriticalByRunId[runId] ?? []).some((g) => g.reason.category === 'user_only_dependency' ||
|
|
35
|
+
g.reason.category === 'contract_violation' ||
|
|
36
|
+
g.reason.category === 'capability_missing');
|
|
37
|
+
const latestAdvance = tip ? advances.byNodeId[tip] : undefined;
|
|
38
|
+
const blockedByAdvance = latestAdvance?.outcome.kind === 'blocked';
|
|
39
|
+
const isBlocked = prefs.autonomy !== 'full_auto_never_stop' && (blockedByAdvance || hasBlockingCategoryGap);
|
|
40
|
+
byRunId[runId] = {
|
|
41
|
+
runId,
|
|
42
|
+
preferredTipNodeId: tip,
|
|
43
|
+
effectivePreferencesAtTip: prefs,
|
|
44
|
+
hasUnresolvedCriticalGaps,
|
|
45
|
+
isBlocked,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return (0, neverthrow_1.ok)({ byRunId });
|
|
49
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
2
|
+
import type { LoadedSessionTruthV2 } from '../ports/session-event-log-store.port.js';
|
|
3
|
+
export type SessionHealthV2 = {
|
|
4
|
+
readonly kind: 'healthy';
|
|
5
|
+
} | {
|
|
6
|
+
readonly kind: 'corrupted';
|
|
7
|
+
readonly reason: {
|
|
8
|
+
readonly code: 'MANIFEST_INVALID';
|
|
9
|
+
readonly message: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly code: 'EVENT_LOG_INVALID';
|
|
12
|
+
readonly message: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly code: 'RUN_DAG_INVALID';
|
|
15
|
+
readonly message: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare function projectSessionHealthV2(truth: LoadedSessionTruthV2): Result<SessionHealthV2, never>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectSessionHealthV2 = projectSessionHealthV2;
|
|
4
|
+
const neverthrow_1 = require("neverthrow");
|
|
5
|
+
const run_dag_js_1 = require("./run-dag.js");
|
|
6
|
+
function projectSessionHealthV2(truth) {
|
|
7
|
+
const dag = (0, run_dag_js_1.projectRunDagV2)(truth.events);
|
|
8
|
+
if (dag.isErr()) {
|
|
9
|
+
return (0, neverthrow_1.ok)({
|
|
10
|
+
kind: 'corrupted',
|
|
11
|
+
reason: { code: 'RUN_DAG_INVALID', message: dag.error.message },
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return (0, neverthrow_1.ok)({ kind: 'healthy' });
|
|
15
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compileV1WorkflowToV2CompiledSnapshotV1 = compileV1WorkflowToV2CompiledSnapshotV1;
|
|
4
|
+
function compileV1WorkflowToV2CompiledSnapshotV1(workflow) {
|
|
5
|
+
const firstStep = workflow.definition.steps[0];
|
|
6
|
+
if (!firstStep) {
|
|
7
|
+
return {
|
|
8
|
+
schemaVersion: 1,
|
|
9
|
+
sourceKind: 'v1_shim',
|
|
10
|
+
workflowId: workflow.definition.id,
|
|
11
|
+
name: workflow.definition.name,
|
|
12
|
+
description: workflow.definition.description,
|
|
13
|
+
version: workflow.definition.version,
|
|
14
|
+
preview: {
|
|
15
|
+
stepId: '(missing)',
|
|
16
|
+
title: 'Invalid workflow: missing first step',
|
|
17
|
+
prompt: 'This workflow has no steps. It is invalid and cannot be previewed.',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const isLoop = firstStep.type === 'loop';
|
|
22
|
+
const prompt = !isLoop && typeof firstStep.prompt === 'string'
|
|
23
|
+
? firstStep.prompt
|
|
24
|
+
: `Loop step '${firstStep.id}' cannot be previewed in v2 Slice 1 (loop execution/compilation not implemented yet).`;
|
|
25
|
+
return {
|
|
26
|
+
schemaVersion: 1,
|
|
27
|
+
sourceKind: 'v1_shim',
|
|
28
|
+
workflowId: workflow.definition.id,
|
|
29
|
+
name: workflow.definition.name,
|
|
30
|
+
description: workflow.definition.description,
|
|
31
|
+
version: workflow.definition.version,
|
|
32
|
+
preview: {
|
|
33
|
+
stepId: firstStep.id,
|
|
34
|
+
title: firstStep.title ?? firstStep.id,
|
|
35
|
+
prompt,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|