@exaudeus/workrail 0.8.5 → 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 +80 -54
- 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/bug-investigation.agentic.json +156 -56
- 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/workflows/routines/ideation.json +73 -0
- 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
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.GitWorkflowStorage = void 0;
|
|
7
|
+
const workflow_1 = require("../../types/workflow");
|
|
7
8
|
const child_process_1 = require("child_process");
|
|
8
9
|
const util_1 = require("util");
|
|
9
10
|
const path_1 = __importDefault(require("path"));
|
|
@@ -16,16 +17,17 @@ const logger_1 = require("../../utils/logger");
|
|
|
16
17
|
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
17
18
|
const logger = (0, logger_1.createLogger)('GitWorkflowStorage');
|
|
18
19
|
class GitWorkflowStorage {
|
|
19
|
-
constructor(config) {
|
|
20
|
+
constructor(config, source) {
|
|
21
|
+
this.kind = 'single';
|
|
20
22
|
this.lastSync = 0;
|
|
21
23
|
this.isCloning = false;
|
|
22
24
|
this.config = this.validateAndNormalizeConfig(config);
|
|
23
25
|
this.localPath = this.config.localPath;
|
|
26
|
+
this.source = source ?? (0, workflow_1.createGitRepositorySource)(this.config.repositoryUrl, this.config.branch, this.localPath);
|
|
24
27
|
logger.info('Git workflow storage initialized', {
|
|
25
28
|
repositoryUrl: this.config.repositoryUrl,
|
|
26
29
|
branch: this.config.branch,
|
|
27
|
-
localPath: this.localPath
|
|
28
|
-
syncInterval: this.config.syncInterval
|
|
30
|
+
localPath: this.localPath
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
validateAndNormalizeConfig(config) {
|
|
@@ -39,8 +41,7 @@ class GitWorkflowStorage {
|
|
|
39
41
|
maxFileSizeBytes: config.maxFileSize || 1024 * 1024
|
|
40
42
|
});
|
|
41
43
|
const defaultCacheDir = path_1.default.join(os_1.default.homedir(), '.workrail', 'cache');
|
|
42
|
-
const localPath = config.localPath ||
|
|
43
|
-
path_1.default.join(defaultCacheDir, 'community-workflows');
|
|
44
|
+
const localPath = config.localPath || path_1.default.join(defaultCacheDir, 'community-workflows');
|
|
44
45
|
if (!config.skipSandboxCheck) {
|
|
45
46
|
try {
|
|
46
47
|
const safeBaseDir = config.localPath
|
|
@@ -64,27 +65,27 @@ class GitWorkflowStorage {
|
|
|
64
65
|
}
|
|
65
66
|
isValidGitUrl(url) {
|
|
66
67
|
const sshPattern = /^git@[\w.-]+:[\w\/-]+\.git$/;
|
|
67
|
-
if (sshPattern.test(url))
|
|
68
|
+
if (sshPattern.test(url))
|
|
68
69
|
return true;
|
|
69
|
-
|
|
70
|
-
if (url.startsWith('ssh://')) {
|
|
70
|
+
if (url.startsWith('ssh://'))
|
|
71
71
|
return true;
|
|
72
|
-
|
|
73
|
-
if (url.startsWith('/') || url.startsWith('file://')) {
|
|
72
|
+
if (url.startsWith('/') || url.startsWith('file://'))
|
|
74
73
|
return true;
|
|
75
|
-
}
|
|
76
74
|
try {
|
|
77
75
|
const parsed = new URL(url);
|
|
78
|
-
const allowedHosts = [
|
|
79
|
-
'github.com', 'gitlab.com', 'bitbucket.org',
|
|
80
|
-
'dev.azure.com', 'sourceforge.net'
|
|
81
|
-
];
|
|
82
76
|
if (parsed.protocol === 'https:' || parsed.protocol === 'git:') {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
const hostname = parsed.hostname;
|
|
78
|
+
const pathname = parsed.pathname;
|
|
79
|
+
if (!hostname || hostname.length === 0)
|
|
80
|
+
return false;
|
|
81
|
+
if (!pathname || pathname === '/')
|
|
82
|
+
return false;
|
|
83
|
+
if (hostname.includes('..') || pathname.includes('..'))
|
|
84
|
+
return false;
|
|
86
85
|
return true;
|
|
87
86
|
}
|
|
87
|
+
if (parsed.protocol === 'file:')
|
|
88
|
+
return true;
|
|
88
89
|
return false;
|
|
89
90
|
}
|
|
90
91
|
catch {
|
|
@@ -111,7 +112,6 @@ class GitWorkflowStorage {
|
|
|
111
112
|
}
|
|
112
113
|
const files = await promises_1.default.readdir(workflowsPath);
|
|
113
114
|
const jsonFiles = files.filter(f => f.endsWith('.json'));
|
|
114
|
-
logger.debug('Found workflow files', { count: jsonFiles.length });
|
|
115
115
|
if (jsonFiles.length > this.config.maxFiles) {
|
|
116
116
|
throw new error_handler_1.StorageError(`Too many workflow files (${jsonFiles.length}), maximum allowed: ${this.config.maxFiles}`);
|
|
117
117
|
}
|
|
@@ -123,13 +123,12 @@ class GitWorkflowStorage {
|
|
|
123
123
|
const stats = await promises_1.default.stat(filePath);
|
|
124
124
|
(0, storage_security_1.validateFileSize)(stats.size, this.config.maxFileSize, file);
|
|
125
125
|
const content = await promises_1.default.readFile(filePath, 'utf-8');
|
|
126
|
-
const
|
|
127
|
-
const expectedFilename = `${(0, storage_security_1.sanitizeId)(
|
|
126
|
+
const definition = JSON.parse(content);
|
|
127
|
+
const expectedFilename = `${(0, storage_security_1.sanitizeId)(definition.id)}.json`;
|
|
128
128
|
if (file !== expectedFilename) {
|
|
129
|
-
throw new error_handler_1.InvalidWorkflowError(
|
|
129
|
+
throw new error_handler_1.InvalidWorkflowError(definition.id, `Workflow ID '${definition.id}' doesn't match filename '${file}'`);
|
|
130
130
|
}
|
|
131
|
-
workflows.push(
|
|
132
|
-
logger.debug('Loaded workflow', { id: workflow.id, name: workflow.name });
|
|
131
|
+
workflows.push((0, workflow_1.createWorkflow)(definition, this.source));
|
|
133
132
|
}
|
|
134
133
|
catch (error) {
|
|
135
134
|
if (error instanceof error_handler_1.SecurityError || error instanceof error_handler_1.InvalidWorkflowError) {
|
|
@@ -140,15 +139,12 @@ class GitWorkflowStorage {
|
|
|
140
139
|
}
|
|
141
140
|
logger.info('Successfully loaded workflows from Git repository', {
|
|
142
141
|
repositoryUrl: this.config.repositoryUrl,
|
|
143
|
-
count: workflows.length
|
|
144
|
-
workflows: workflows.map(w => ({ id: w.id, name: w.name }))
|
|
142
|
+
count: workflows.length
|
|
145
143
|
});
|
|
146
144
|
return workflows;
|
|
147
145
|
}
|
|
148
146
|
catch (error) {
|
|
149
|
-
logger.error('Failed to load workflows from Git repository', error
|
|
150
|
-
repositoryUrl: this.config.repositoryUrl
|
|
151
|
-
});
|
|
147
|
+
logger.error('Failed to load workflows from Git repository', error);
|
|
152
148
|
if (error instanceof error_handler_1.StorageError || error instanceof error_handler_1.SecurityError || error instanceof error_handler_1.InvalidWorkflowError) {
|
|
153
149
|
throw error;
|
|
154
150
|
}
|
|
@@ -158,23 +154,17 @@ class GitWorkflowStorage {
|
|
|
158
154
|
async getWorkflowById(id) {
|
|
159
155
|
const sanitizedId = (0, storage_security_1.sanitizeId)(id);
|
|
160
156
|
const workflows = await this.loadAllWorkflows();
|
|
161
|
-
return workflows.find(w => w.id === sanitizedId) || null;
|
|
157
|
+
return workflows.find(w => w.definition.id === sanitizedId) || null;
|
|
162
158
|
}
|
|
163
159
|
async listWorkflowSummaries() {
|
|
164
160
|
const workflows = await this.loadAllWorkflows();
|
|
165
|
-
return workflows.map(
|
|
166
|
-
id: workflow.id,
|
|
167
|
-
name: workflow.name,
|
|
168
|
-
description: workflow.description,
|
|
169
|
-
category: 'community',
|
|
170
|
-
version: workflow.version
|
|
171
|
-
}));
|
|
161
|
+
return workflows.map(workflow_1.toWorkflowSummary);
|
|
172
162
|
}
|
|
173
|
-
async save(
|
|
163
|
+
async save(definition) {
|
|
174
164
|
try {
|
|
175
|
-
const sanitizedId = (0, storage_security_1.sanitizeId)(
|
|
176
|
-
if (
|
|
177
|
-
throw new error_handler_1.InvalidWorkflowError(
|
|
165
|
+
const sanitizedId = (0, storage_security_1.sanitizeId)(definition.id);
|
|
166
|
+
if (definition.id !== sanitizedId) {
|
|
167
|
+
throw new error_handler_1.InvalidWorkflowError(definition.id, `Invalid workflow ID: ${definition.id}`);
|
|
178
168
|
}
|
|
179
169
|
await this.ensureRepository();
|
|
180
170
|
const workflowsPath = path_1.default.join(this.localPath, 'workflows');
|
|
@@ -182,10 +172,10 @@ class GitWorkflowStorage {
|
|
|
182
172
|
const filename = `${sanitizedId}.json`;
|
|
183
173
|
const filePath = path_1.default.join(workflowsPath, filename);
|
|
184
174
|
(0, storage_security_1.assertWithinBase)(filePath, workflowsPath);
|
|
185
|
-
const content = JSON.stringify(
|
|
186
|
-
(0, storage_security_1.validateFileSize)(Buffer.byteLength(content, 'utf-8'), this.config.maxFileSize,
|
|
175
|
+
const content = JSON.stringify(definition, null, 2);
|
|
176
|
+
(0, storage_security_1.validateFileSize)(Buffer.byteLength(content, 'utf-8'), this.config.maxFileSize, definition.id);
|
|
187
177
|
await promises_1.default.writeFile(filePath, content);
|
|
188
|
-
await this.gitCommitAndPush(
|
|
178
|
+
await this.gitCommitAndPush(definition);
|
|
189
179
|
}
|
|
190
180
|
catch (error) {
|
|
191
181
|
if (error instanceof error_handler_1.SecurityError || error instanceof error_handler_1.InvalidWorkflowError) {
|
|
@@ -209,9 +199,8 @@ class GitWorkflowStorage {
|
|
|
209
199
|
}
|
|
210
200
|
const shouldSync = !(0, fs_1.existsSync)(this.localPath) ||
|
|
211
201
|
(Date.now() - this.lastSync) > (this.config.syncInterval * 60 * 1000);
|
|
212
|
-
if (!shouldSync)
|
|
202
|
+
if (!shouldSync)
|
|
213
203
|
return;
|
|
214
|
-
}
|
|
215
204
|
this.isCloning = true;
|
|
216
205
|
try {
|
|
217
206
|
if (!(0, fs_1.existsSync)(this.localPath)) {
|
|
@@ -232,97 +221,70 @@ class GitWorkflowStorage {
|
|
|
232
221
|
async cloneRepository() {
|
|
233
222
|
logger.info('Cloning Git repository', {
|
|
234
223
|
repositoryUrl: this.config.repositoryUrl,
|
|
235
|
-
branch: this.config.branch
|
|
236
|
-
localPath: this.localPath
|
|
224
|
+
branch: this.config.branch
|
|
237
225
|
});
|
|
238
226
|
const parentDir = path_1.default.dirname(this.localPath);
|
|
239
227
|
await promises_1.default.mkdir(parentDir, { recursive: true });
|
|
240
228
|
let cloneUrl = this.config.repositoryUrl;
|
|
241
229
|
if (cloneUrl.startsWith('/')) {
|
|
242
230
|
cloneUrl = `file://${cloneUrl}`;
|
|
243
|
-
logger.debug('Converted local path to file:// URL', { cloneUrl });
|
|
244
231
|
}
|
|
245
232
|
if (!this.isSshUrl(this.config.repositoryUrl) && this.config.authToken && cloneUrl.startsWith('https://')) {
|
|
246
233
|
cloneUrl = cloneUrl.replace('https://', `https://${this.config.authToken}@`);
|
|
247
|
-
logger.debug('Injected auth token into URL');
|
|
248
234
|
}
|
|
249
235
|
const escapedUrl = this.escapeShellArg(cloneUrl);
|
|
250
236
|
const escapedBranch = this.escapeShellArg(this.config.branch);
|
|
251
237
|
const escapedPath = this.escapeShellArg(this.localPath);
|
|
252
238
|
let command = `git clone --branch ${escapedBranch} ${escapedUrl} ${escapedPath}`;
|
|
253
239
|
try {
|
|
254
|
-
logger.debug('Executing git clone', { branch: this.config.branch });
|
|
255
240
|
await execAsync(command, { timeout: 60000 });
|
|
256
241
|
logger.info('Successfully cloned repository', { branch: this.config.branch });
|
|
257
242
|
}
|
|
258
243
|
catch (error) {
|
|
259
244
|
const errorMsg = error.message;
|
|
260
245
|
if (errorMsg.includes('Remote branch') && errorMsg.includes('not found')) {
|
|
261
|
-
logger.warn('Requested branch not found, trying default branch', {
|
|
262
|
-
requestedBranch: this.config.branch
|
|
263
|
-
});
|
|
264
246
|
command = `git clone ${escapedUrl} ${escapedPath}`;
|
|
265
247
|
try {
|
|
266
248
|
await execAsync(command, { timeout: 60000 });
|
|
267
249
|
const { stdout } = await execAsync('git rev-parse --abbrev-ref HEAD', { cwd: this.localPath });
|
|
268
|
-
|
|
269
|
-
logger.info('Successfully cloned with default branch', {
|
|
270
|
-
requestedBranch: this.config.branch,
|
|
271
|
-
actualBranch
|
|
272
|
-
});
|
|
273
|
-
this.config.branch = actualBranch;
|
|
250
|
+
this.config.branch = stdout.trim();
|
|
274
251
|
}
|
|
275
252
|
catch (fallbackError) {
|
|
276
|
-
logger.error('Failed to clone repository with fallback', fallbackError);
|
|
277
253
|
throw new error_handler_1.StorageError(`Failed to clone workflow repository: ${fallbackError.message}`);
|
|
278
254
|
}
|
|
279
255
|
}
|
|
280
256
|
else {
|
|
281
|
-
logger.error('Failed to clone repository', error, { branch: this.config.branch });
|
|
282
257
|
throw new error_handler_1.StorageError(`Failed to clone workflow repository: ${errorMsg}`);
|
|
283
258
|
}
|
|
284
259
|
}
|
|
285
260
|
}
|
|
286
261
|
async pullRepository() {
|
|
287
|
-
logger.debug('Pulling latest changes from Git repository', {
|
|
288
|
-
branch: this.config.branch,
|
|
289
|
-
localPath: this.localPath
|
|
290
|
-
});
|
|
291
262
|
const escapedPath = this.escapeShellArg(this.localPath);
|
|
292
263
|
const escapedBranch = this.escapeShellArg(this.config.branch);
|
|
293
264
|
try {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
await execAsync(fetchCommand, { timeout: 30000 });
|
|
297
|
-
await execAsync(resetCommand, { timeout: 30000 });
|
|
298
|
-
logger.info('Successfully updated repository', { branch: this.config.branch });
|
|
265
|
+
await execAsync(`cd ${escapedPath} && git fetch origin ${escapedBranch}`, { timeout: 30000 });
|
|
266
|
+
await execAsync(`cd ${escapedPath} && git reset --hard origin/${escapedBranch}`, { timeout: 30000 });
|
|
299
267
|
}
|
|
300
|
-
catch
|
|
268
|
+
catch {
|
|
301
269
|
try {
|
|
302
|
-
|
|
303
|
-
await execAsync(pullCommand, { timeout: 30000 });
|
|
304
|
-
logger.info('Successfully updated repository via pull', { branch: this.config.branch });
|
|
270
|
+
await execAsync(`cd ${escapedPath} && git pull origin ${escapedBranch}`, { timeout: 30000 });
|
|
305
271
|
}
|
|
306
272
|
catch (pullError) {
|
|
307
|
-
logger.warn('Git pull failed, using cached version', pullError
|
|
308
|
-
repositoryUrl: this.config.repositoryUrl,
|
|
309
|
-
branch: this.config.branch
|
|
310
|
-
});
|
|
273
|
+
logger.warn('Git pull failed, using cached version', pullError);
|
|
311
274
|
}
|
|
312
275
|
}
|
|
313
276
|
}
|
|
314
|
-
async gitCommitAndPush(
|
|
277
|
+
async gitCommitAndPush(definition) {
|
|
315
278
|
const escapedPath = this.escapeShellArg(this.localPath);
|
|
316
|
-
const escapedFilename = this.escapeShellArg(`workflows/${
|
|
317
|
-
const escapedMessage = this.escapeShellArg(`Add/update workflow: ${
|
|
279
|
+
const escapedFilename = this.escapeShellArg(`workflows/${definition.id}.json`);
|
|
280
|
+
const escapedMessage = this.escapeShellArg(`Add/update workflow: ${definition.name}`);
|
|
318
281
|
const escapedBranch = this.escapeShellArg(this.config.branch);
|
|
319
|
-
const
|
|
282
|
+
const command = [
|
|
320
283
|
`cd ${escapedPath}`,
|
|
321
284
|
`git add ${escapedFilename}`,
|
|
322
285
|
`git commit -m ${escapedMessage}`,
|
|
323
286
|
`git push origin ${escapedBranch}`
|
|
324
|
-
];
|
|
325
|
-
const command = commands.join(' && ');
|
|
287
|
+
].join(' && ');
|
|
326
288
|
try {
|
|
327
289
|
await execAsync(command, { timeout: 60000 });
|
|
328
290
|
}
|
|
@@ -335,20 +297,3 @@ class GitWorkflowStorage {
|
|
|
335
297
|
}
|
|
336
298
|
}
|
|
337
299
|
exports.GitWorkflowStorage = GitWorkflowStorage;
|
|
338
|
-
exports.COMMUNITY_WORKFLOW_REPOS = {
|
|
339
|
-
official: {
|
|
340
|
-
repositoryUrl: 'https://github.com/EtienneBBeaulac/workrail-community-workflows.git',
|
|
341
|
-
branch: 'main',
|
|
342
|
-
syncInterval: 60,
|
|
343
|
-
maxFileSize: 1024 * 1024,
|
|
344
|
-
maxFiles: 100
|
|
345
|
-
},
|
|
346
|
-
personal: {
|
|
347
|
-
repositoryUrl: 'https://github.com/username/my-workflows.git',
|
|
348
|
-
branch: 'main',
|
|
349
|
-
syncInterval: 30,
|
|
350
|
-
authToken: process.env['GITHUB_TOKEN'],
|
|
351
|
-
maxFileSize: 1024 * 1024,
|
|
352
|
-
maxFiles: 50
|
|
353
|
-
}
|
|
354
|
-
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { Workflow, WorkflowSummary } from '../../types/
|
|
1
|
+
import { Workflow, WorkflowSummary, WorkflowDefinition, WorkflowSource } from '../../types/workflow';
|
|
2
2
|
import { IWorkflowStorage } from '../../types/storage';
|
|
3
3
|
export declare class InMemoryWorkflowStorage implements IWorkflowStorage {
|
|
4
|
+
readonly kind: "single";
|
|
5
|
+
readonly source: WorkflowSource;
|
|
4
6
|
private workflows;
|
|
5
|
-
constructor(
|
|
6
|
-
setWorkflows(
|
|
7
|
-
|
|
7
|
+
constructor(definitions?: readonly WorkflowDefinition[], source?: WorkflowSource);
|
|
8
|
+
setWorkflows(definitions: readonly WorkflowDefinition[]): void;
|
|
9
|
+
setWorkflowsRaw(workflows: readonly Workflow[]): void;
|
|
10
|
+
loadAllWorkflows(): Promise<readonly Workflow[]>;
|
|
8
11
|
getWorkflowById(id: string): Promise<Workflow | null>;
|
|
9
|
-
listWorkflowSummaries(): Promise<WorkflowSummary[]>;
|
|
10
|
-
save(
|
|
12
|
+
listWorkflowSummaries(): Promise<readonly WorkflowSummary[]>;
|
|
13
|
+
save(definition: WorkflowDefinition): Promise<void>;
|
|
11
14
|
}
|
|
15
|
+
export declare function createTestStorage(definitions?: readonly WorkflowDefinition[], source?: WorkflowSource): InMemoryWorkflowStorage;
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InMemoryWorkflowStorage = void 0;
|
|
4
|
+
exports.createTestStorage = createTestStorage;
|
|
5
|
+
const workflow_1 = require("../../types/workflow");
|
|
4
6
|
class InMemoryWorkflowStorage {
|
|
5
|
-
constructor(
|
|
6
|
-
this.
|
|
7
|
+
constructor(definitions = [], source = (0, workflow_1.createBundledSource)()) {
|
|
8
|
+
this.kind = 'single';
|
|
9
|
+
this.source = source;
|
|
10
|
+
this.workflows = definitions.map(def => (0, workflow_1.createWorkflow)(def, source));
|
|
11
|
+
}
|
|
12
|
+
setWorkflows(definitions) {
|
|
13
|
+
this.workflows = definitions.map(def => (0, workflow_1.createWorkflow)(def, this.source));
|
|
7
14
|
}
|
|
8
|
-
|
|
15
|
+
setWorkflowsRaw(workflows) {
|
|
9
16
|
this.workflows = [...workflows];
|
|
10
17
|
}
|
|
11
18
|
async loadAllWorkflows() {
|
|
12
19
|
return [...this.workflows];
|
|
13
20
|
}
|
|
14
21
|
async getWorkflowById(id) {
|
|
15
|
-
return this.workflows.find((wf) => wf.id === id) || null;
|
|
22
|
+
return this.workflows.find((wf) => wf.definition.id === id) || null;
|
|
16
23
|
}
|
|
17
24
|
async listWorkflowSummaries() {
|
|
18
|
-
return this.workflows.map(
|
|
19
|
-
id: workflow.id,
|
|
20
|
-
name: workflow.name,
|
|
21
|
-
description: workflow.description,
|
|
22
|
-
category: 'default',
|
|
23
|
-
version: workflow.version
|
|
24
|
-
}));
|
|
25
|
+
return this.workflows.map(workflow_1.toWorkflowSummary);
|
|
25
26
|
}
|
|
26
|
-
async save(
|
|
27
|
-
const index = this.workflows.findIndex((w) => w.id ===
|
|
27
|
+
async save(definition) {
|
|
28
|
+
const index = this.workflows.findIndex((w) => w.definition.id === definition.id);
|
|
29
|
+
const workflow = (0, workflow_1.createWorkflow)(definition, this.source);
|
|
28
30
|
if (index >= 0) {
|
|
29
31
|
this.workflows[index] = workflow;
|
|
30
32
|
}
|
|
@@ -34,3 +36,6 @@ class InMemoryWorkflowStorage {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
exports.InMemoryWorkflowStorage = InMemoryWorkflowStorage;
|
|
39
|
+
function createTestStorage(definitions = [], source) {
|
|
40
|
+
return new InMemoryWorkflowStorage(definitions, source);
|
|
41
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IWorkflowStorage } from '../../types/storage';
|
|
2
|
-
import { Workflow, WorkflowSummary } from '../../types/
|
|
2
|
+
import { Workflow, WorkflowSummary, WorkflowSource } from '../../types/workflow';
|
|
3
3
|
export interface WorkflowPlugin {
|
|
4
4
|
name: string;
|
|
5
5
|
version: string;
|
|
@@ -26,15 +26,17 @@ export interface ValidatedPluginWorkflowConfig extends Required<PluginWorkflowCo
|
|
|
26
26
|
maxPlugins: number;
|
|
27
27
|
}
|
|
28
28
|
export declare class PluginWorkflowStorage implements IWorkflowStorage {
|
|
29
|
+
readonly kind: "single";
|
|
30
|
+
readonly source: WorkflowSource;
|
|
29
31
|
private readonly config;
|
|
30
32
|
private pluginCache;
|
|
31
33
|
private lastScan;
|
|
32
|
-
constructor(config?: PluginWorkflowConfig);
|
|
34
|
+
constructor(config?: PluginWorkflowConfig, source?: WorkflowSource);
|
|
33
35
|
private validateAndNormalizeConfig;
|
|
34
36
|
private getDefaultPluginPaths;
|
|
35
|
-
loadAllWorkflows(): Promise<Workflow[]>;
|
|
37
|
+
loadAllWorkflows(): Promise<readonly Workflow[]>;
|
|
36
38
|
getWorkflowById(id: string): Promise<Workflow | null>;
|
|
37
|
-
listWorkflowSummaries(): Promise<WorkflowSummary[]>;
|
|
39
|
+
listWorkflowSummaries(): Promise<readonly WorkflowSummary[]>;
|
|
38
40
|
save(): Promise<void>;
|
|
39
41
|
private scanPlugins;
|
|
40
42
|
private isWorkflowPlugin;
|
|
@@ -43,17 +45,3 @@ export declare class PluginWorkflowStorage implements IWorkflowStorage {
|
|
|
43
45
|
getLoadedPlugins(): WorkflowPlugin[];
|
|
44
46
|
getConfig(): ValidatedPluginWorkflowConfig;
|
|
45
47
|
}
|
|
46
|
-
export declare const PLUGIN_WORKFLOW_CONFIGS: {
|
|
47
|
-
development: {
|
|
48
|
-
scanInterval: number;
|
|
49
|
-
maxFileSize: number;
|
|
50
|
-
maxFiles: number;
|
|
51
|
-
maxPlugins: number;
|
|
52
|
-
};
|
|
53
|
-
production: {
|
|
54
|
-
scanInterval: number;
|
|
55
|
-
maxFileSize: number;
|
|
56
|
-
maxFiles: number;
|
|
57
|
-
maxPlugins: number;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
@@ -3,17 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.PluginWorkflowStorage = void 0;
|
|
7
|
+
const workflow_1 = require("../../types/workflow");
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
10
|
const fs_1 = require("fs");
|
|
10
11
|
const storage_security_1 = require("../../utils/storage-security");
|
|
11
12
|
const error_handler_1 = require("../../core/error-handler");
|
|
12
13
|
class PluginWorkflowStorage {
|
|
13
|
-
constructor(config = {}) {
|
|
14
|
+
constructor(config = {}, source) {
|
|
15
|
+
this.kind = 'single';
|
|
14
16
|
this.pluginCache = new Map();
|
|
15
17
|
this.lastScan = 0;
|
|
16
18
|
this.config = this.validateAndNormalizeConfig(config);
|
|
19
|
+
this.source = source ?? (0, workflow_1.createPluginSource)('plugins', '1.0.0');
|
|
17
20
|
}
|
|
18
21
|
validateAndNormalizeConfig(config) {
|
|
19
22
|
const securityOptions = (0, storage_security_1.validateSecurityOptions)({
|
|
@@ -50,10 +53,7 @@ class PluginWorkflowStorage {
|
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
catch {
|
|
53
|
-
const commonPaths = [
|
|
54
|
-
'/usr/local/lib/node_modules',
|
|
55
|
-
'/usr/lib/node_modules'
|
|
56
|
-
];
|
|
56
|
+
const commonPaths = ['/usr/local/lib/node_modules', '/usr/lib/node_modules'];
|
|
57
57
|
for (const commonPath of commonPaths) {
|
|
58
58
|
if ((0, fs_1.existsSync)(commonPath)) {
|
|
59
59
|
paths.push(commonPath);
|
|
@@ -85,17 +85,11 @@ class PluginWorkflowStorage {
|
|
|
85
85
|
async getWorkflowById(id) {
|
|
86
86
|
const sanitizedId = (0, storage_security_1.sanitizeId)(id);
|
|
87
87
|
const workflows = await this.loadAllWorkflows();
|
|
88
|
-
return workflows.find(w => w.id === sanitizedId) || null;
|
|
88
|
+
return workflows.find(w => w.definition.id === sanitizedId) || null;
|
|
89
89
|
}
|
|
90
90
|
async listWorkflowSummaries() {
|
|
91
91
|
const workflows = await this.loadAllWorkflows();
|
|
92
|
-
return workflows.map(
|
|
93
|
-
id: workflow.id,
|
|
94
|
-
name: workflow.name,
|
|
95
|
-
description: workflow.description,
|
|
96
|
-
category: 'plugin',
|
|
97
|
-
version: workflow.version
|
|
98
|
-
}));
|
|
92
|
+
return workflows.map(workflow_1.toWorkflowSummary);
|
|
99
93
|
}
|
|
100
94
|
async save() {
|
|
101
95
|
throw new error_handler_1.StorageError('Plugin-based storage is read-only. Publish workflows as npm packages instead.');
|
|
@@ -108,9 +102,8 @@ class PluginWorkflowStorage {
|
|
|
108
102
|
this.pluginCache.clear();
|
|
109
103
|
let pluginCount = 0;
|
|
110
104
|
for (const pluginPath of this.config.pluginPaths) {
|
|
111
|
-
if (!(0, fs_1.existsSync)(pluginPath))
|
|
105
|
+
if (!(0, fs_1.existsSync)(pluginPath))
|
|
112
106
|
continue;
|
|
113
|
-
}
|
|
114
107
|
try {
|
|
115
108
|
(0, storage_security_1.assertWithinBase)(pluginPath, pluginPath);
|
|
116
109
|
const entries = await promises_1.default.readdir(pluginPath);
|
|
@@ -145,9 +138,8 @@ class PluginWorkflowStorage {
|
|
|
145
138
|
try {
|
|
146
139
|
(0, storage_security_1.assertWithinBase)(pluginPath, path_1.default.dirname(pluginPath));
|
|
147
140
|
const packageJsonPath = path_1.default.join(pluginPath, 'package.json');
|
|
148
|
-
if (!(0, fs_1.existsSync)(packageJsonPath))
|
|
141
|
+
if (!(0, fs_1.existsSync)(packageJsonPath))
|
|
149
142
|
return null;
|
|
150
|
-
}
|
|
151
143
|
(0, storage_security_1.assertWithinBase)(packageJsonPath, pluginPath);
|
|
152
144
|
const packageStats = await promises_1.default.stat(packageJsonPath);
|
|
153
145
|
(0, storage_security_1.validateFileSize)(packageStats.size, Math.min(this.config.maxFileSize, 64 * 1024), 'package.json');
|
|
@@ -159,27 +151,27 @@ class PluginWorkflowStorage {
|
|
|
159
151
|
catch (parseError) {
|
|
160
152
|
throw new error_handler_1.InvalidWorkflowError(pluginPath, `Invalid package.json: ${parseError.message}`);
|
|
161
153
|
}
|
|
162
|
-
if (!packageJson
|
|
154
|
+
if (!packageJson['workrail'] || !packageJson['workrail']['workflows']) {
|
|
163
155
|
return null;
|
|
164
156
|
}
|
|
165
|
-
if (!packageJson
|
|
166
|
-
throw new error_handler_1.InvalidWorkflowError(pluginPath,
|
|
157
|
+
if (!packageJson['name'] || typeof packageJson['name'] !== 'string') {
|
|
158
|
+
throw new error_handler_1.InvalidWorkflowError(pluginPath, 'Invalid package name');
|
|
167
159
|
}
|
|
168
160
|
const workflowsPath = path_1.default.join(pluginPath, 'workflows');
|
|
169
|
-
if (!(0, fs_1.existsSync)(workflowsPath))
|
|
161
|
+
if (!(0, fs_1.existsSync)(workflowsPath))
|
|
170
162
|
return null;
|
|
171
|
-
}
|
|
172
163
|
(0, storage_security_1.assertWithinBase)(workflowsPath, pluginPath);
|
|
173
|
-
const
|
|
164
|
+
const pluginSource = (0, workflow_1.createPluginSource)(packageJson['name'], packageJson['version'] || '0.0.0');
|
|
165
|
+
const workflows = await this.loadWorkflowsFromDirectory(workflowsPath, pluginSource);
|
|
174
166
|
return {
|
|
175
|
-
name: packageJson
|
|
176
|
-
version: packageJson
|
|
167
|
+
name: packageJson['name'],
|
|
168
|
+
version: packageJson['version'] || '0.0.0',
|
|
177
169
|
workflows,
|
|
178
170
|
metadata: {
|
|
179
|
-
author: packageJson
|
|
180
|
-
description: packageJson
|
|
181
|
-
homepage: packageJson
|
|
182
|
-
repository: packageJson
|
|
171
|
+
author: packageJson['author'],
|
|
172
|
+
description: packageJson['description'],
|
|
173
|
+
homepage: packageJson['homepage'],
|
|
174
|
+
repository: packageJson['repository']?.['url'] || packageJson['repository']
|
|
183
175
|
}
|
|
184
176
|
};
|
|
185
177
|
}
|
|
@@ -190,7 +182,7 @@ class PluginWorkflowStorage {
|
|
|
190
182
|
throw new error_handler_1.StorageError(`Failed to load plugin from ${pluginPath}: ${error.message}`);
|
|
191
183
|
}
|
|
192
184
|
}
|
|
193
|
-
async loadWorkflowsFromDirectory(workflowsPath) {
|
|
185
|
+
async loadWorkflowsFromDirectory(workflowsPath, pluginSource) {
|
|
194
186
|
const workflows = [];
|
|
195
187
|
try {
|
|
196
188
|
const files = await promises_1.default.readdir(workflowsPath);
|
|
@@ -205,18 +197,18 @@ class PluginWorkflowStorage {
|
|
|
205
197
|
const stats = await promises_1.default.stat(filePath);
|
|
206
198
|
(0, storage_security_1.validateFileSize)(stats.size, this.config.maxFileSize, file);
|
|
207
199
|
const content = await promises_1.default.readFile(filePath, 'utf-8');
|
|
208
|
-
let
|
|
200
|
+
let definition;
|
|
209
201
|
try {
|
|
210
|
-
|
|
202
|
+
definition = JSON.parse(content);
|
|
211
203
|
}
|
|
212
204
|
catch (parseError) {
|
|
213
205
|
throw new error_handler_1.InvalidWorkflowError(file, `Invalid JSON in workflow file: ${parseError.message}`);
|
|
214
206
|
}
|
|
215
|
-
const sanitizedId = (0, storage_security_1.sanitizeId)(
|
|
216
|
-
if (
|
|
217
|
-
throw new error_handler_1.InvalidWorkflowError(
|
|
207
|
+
const sanitizedId = (0, storage_security_1.sanitizeId)(definition.id);
|
|
208
|
+
if (definition.id !== sanitizedId) {
|
|
209
|
+
throw new error_handler_1.InvalidWorkflowError(definition.id, `Invalid workflow ID in file ${file}`);
|
|
218
210
|
}
|
|
219
|
-
workflows.push(
|
|
211
|
+
workflows.push((0, workflow_1.createWorkflow)(definition, pluginSource));
|
|
220
212
|
}
|
|
221
213
|
catch (error) {
|
|
222
214
|
if (error instanceof error_handler_1.SecurityError || error instanceof error_handler_1.InvalidWorkflowError) {
|
|
@@ -242,17 +234,3 @@ class PluginWorkflowStorage {
|
|
|
242
234
|
}
|
|
243
235
|
}
|
|
244
236
|
exports.PluginWorkflowStorage = PluginWorkflowStorage;
|
|
245
|
-
exports.PLUGIN_WORKFLOW_CONFIGS = {
|
|
246
|
-
development: {
|
|
247
|
-
scanInterval: 60000,
|
|
248
|
-
maxFileSize: 2 * 1024 * 1024,
|
|
249
|
-
maxFiles: 100,
|
|
250
|
-
maxPlugins: 50
|
|
251
|
-
},
|
|
252
|
-
production: {
|
|
253
|
-
scanInterval: 300000,
|
|
254
|
-
maxFileSize: 1024 * 1024,
|
|
255
|
-
maxFiles: 50,
|
|
256
|
-
maxPlugins: 20
|
|
257
|
-
}
|
|
258
|
-
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IWorkflowStorage } from '../../types/storage';
|
|
2
|
-
import { Workflow, WorkflowSummary } from '../../types/
|
|
2
|
+
import { Workflow, WorkflowSummary, WorkflowDefinition, WorkflowSource } from '../../types/workflow';
|
|
3
3
|
import { StorageSecurityOptions } from '../../utils/storage-security';
|
|
4
4
|
export interface RemoteWorkflowRegistryConfig extends StorageSecurityOptions {
|
|
5
5
|
baseUrl: string;
|
|
@@ -9,26 +9,17 @@ export interface RemoteWorkflowRegistryConfig extends StorageSecurityOptions {
|
|
|
9
9
|
userAgent?: string;
|
|
10
10
|
}
|
|
11
11
|
export declare class RemoteWorkflowStorage implements IWorkflowStorage {
|
|
12
|
+
readonly kind: "single";
|
|
13
|
+
readonly source: WorkflowSource;
|
|
12
14
|
private readonly config;
|
|
13
15
|
private readonly securityOptions;
|
|
14
|
-
constructor(config: RemoteWorkflowRegistryConfig);
|
|
16
|
+
constructor(config: RemoteWorkflowRegistryConfig, source?: WorkflowSource);
|
|
15
17
|
private validateConfig;
|
|
16
|
-
loadAllWorkflows(): Promise<Workflow[]>;
|
|
18
|
+
loadAllWorkflows(): Promise<readonly Workflow[]>;
|
|
17
19
|
getWorkflowById(id: string): Promise<Workflow | null>;
|
|
18
|
-
listWorkflowSummaries(): Promise<WorkflowSummary[]>;
|
|
19
|
-
save(
|
|
20
|
+
listWorkflowSummaries(): Promise<readonly WorkflowSummary[]>;
|
|
21
|
+
save(definition: WorkflowDefinition): Promise<void>;
|
|
20
22
|
private fetchWithRetry;
|
|
21
23
|
private parseResponse;
|
|
22
|
-
private
|
|
23
|
-
private validateSummaries;
|
|
24
|
-
private validateWorkflowForSave;
|
|
25
|
-
}
|
|
26
|
-
export declare class CommunityWorkflowStorage implements IWorkflowStorage {
|
|
27
|
-
private readonly sources;
|
|
28
|
-
private readonly remoteStorage;
|
|
29
|
-
constructor(bundledStorage: IWorkflowStorage, localStorage: IWorkflowStorage, remoteConfig: RemoteWorkflowRegistryConfig);
|
|
30
|
-
loadAllWorkflows(): Promise<Workflow[]>;
|
|
31
|
-
getWorkflowById(id: string): Promise<Workflow | null>;
|
|
32
|
-
listWorkflowSummaries(): Promise<WorkflowSummary[]>;
|
|
33
|
-
save(workflow: Workflow): Promise<void>;
|
|
24
|
+
private validateDefinitions;
|
|
34
25
|
}
|