@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
package/dist/application/app.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.METHOD_NAMES = exports.ApplicationMediator = void 0;
|
|
37
|
-
exports.buildWorkflowApplication = buildWorkflowApplication;
|
|
38
|
-
const error_handler_1 = require("../core/error-handler");
|
|
39
|
-
const mcp_types_1 = require("../types/mcp-types");
|
|
40
|
-
class ApplicationMediator {
|
|
41
|
-
constructor(validator) {
|
|
42
|
-
this.handlers = new Map();
|
|
43
|
-
this.validateFn = validator.validate.bind(validator);
|
|
44
|
-
}
|
|
45
|
-
register(method, handler) {
|
|
46
|
-
if (this.handlers.has(method)) {
|
|
47
|
-
throw new Error(`Method already registered: ${method}`);
|
|
48
|
-
}
|
|
49
|
-
this.handlers.set(method, handler);
|
|
50
|
-
}
|
|
51
|
-
async execute(method, params) {
|
|
52
|
-
const handler = this.handlers.get(method);
|
|
53
|
-
if (!handler) {
|
|
54
|
-
throw new error_handler_1.MCPError(mcp_types_1.MCPErrorCodes.METHOD_NOT_FOUND, 'Method not found', { method });
|
|
55
|
-
}
|
|
56
|
-
this.validateFn(method, params);
|
|
57
|
-
const result = await handler(params);
|
|
58
|
-
if (this.responseValidate) {
|
|
59
|
-
this.responseValidate(method, result);
|
|
60
|
-
}
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
|
-
setResponseValidator(fn) {
|
|
64
|
-
this.responseValidate = fn;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.ApplicationMediator = ApplicationMediator;
|
|
68
|
-
const request_validator_1 = require("../validation/request-validator");
|
|
69
|
-
const response_validator_1 = require("../validation/response-validator");
|
|
70
|
-
const list_workflows_1 = require("./use-cases/list-workflows");
|
|
71
|
-
const get_workflow_1 = require("./use-cases/get-workflow");
|
|
72
|
-
const get_next_step_1 = require("./use-cases/get-next-step");
|
|
73
|
-
const simple_output_decorator_1 = require("./decorators/simple-output-decorator");
|
|
74
|
-
exports.METHOD_NAMES = {
|
|
75
|
-
WORKFLOW_LIST: 'workflow_list',
|
|
76
|
-
WORKFLOW_GET: 'workflow_get',
|
|
77
|
-
WORKFLOW_NEXT: 'workflow_next',
|
|
78
|
-
INITIALIZE: 'initialize',
|
|
79
|
-
TOOLS_LIST: 'tools/list',
|
|
80
|
-
SHUTDOWN: 'shutdown'
|
|
81
|
-
};
|
|
82
|
-
function buildWorkflowApplication(workflowService, validator = request_validator_1.requestValidator, enableOutputOptimization = true) {
|
|
83
|
-
const app = new ApplicationMediator(validator);
|
|
84
|
-
app.setResponseValidator((method, result) => response_validator_1.responseValidator.validate(method, result));
|
|
85
|
-
const listWorkflowsUseCase = (0, list_workflows_1.createListWorkflows)(workflowService);
|
|
86
|
-
const getWorkflowUseCase = (0, get_workflow_1.createGetWorkflow)(workflowService);
|
|
87
|
-
const getNextStepUseCase = (0, get_next_step_1.createGetNextStep)(workflowService);
|
|
88
|
-
app.register(exports.METHOD_NAMES.WORKFLOW_LIST, async (_params) => {
|
|
89
|
-
const workflows = await listWorkflowsUseCase();
|
|
90
|
-
return { workflows };
|
|
91
|
-
});
|
|
92
|
-
app.register(exports.METHOD_NAMES.WORKFLOW_GET, async (params) => {
|
|
93
|
-
return getWorkflowUseCase(params.id, params.mode);
|
|
94
|
-
});
|
|
95
|
-
app.register(exports.METHOD_NAMES.WORKFLOW_NEXT, async (params) => {
|
|
96
|
-
return getNextStepUseCase(params.workflowId, params.completedSteps || [], params.context);
|
|
97
|
-
});
|
|
98
|
-
app.register(exports.METHOD_NAMES.INITIALIZE, async (params) => {
|
|
99
|
-
const { initializeHandler } = await Promise.resolve().then(() => __importStar(require('../tools/mcp_initialize')));
|
|
100
|
-
return (await initializeHandler({ id: 0, params, method: 'initialize', jsonrpc: '2.0' })).result;
|
|
101
|
-
});
|
|
102
|
-
app.register(exports.METHOD_NAMES.TOOLS_LIST, async (params) => {
|
|
103
|
-
const { toolsListHandler } = await Promise.resolve().then(() => __importStar(require('../tools/mcp_tools_list')));
|
|
104
|
-
return (await toolsListHandler({ id: 0, params, method: 'tools/list', jsonrpc: '2.0' })).result;
|
|
105
|
-
});
|
|
106
|
-
app.register(exports.METHOD_NAMES.SHUTDOWN, async (params) => {
|
|
107
|
-
const { shutdownHandler } = await Promise.resolve().then(() => __importStar(require('../tools/mcp_shutdown')));
|
|
108
|
-
return (await shutdownHandler({ id: 0, params, method: 'shutdown', jsonrpc: '2.0' })).result;
|
|
109
|
-
});
|
|
110
|
-
if (enableOutputOptimization) {
|
|
111
|
-
return new simple_output_decorator_1.SimpleOutputDecorator(app);
|
|
112
|
-
}
|
|
113
|
-
return app;
|
|
114
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/application/app.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { IApplicationMediator } from '../app';
|
|
2
|
-
export declare class SimpleOutputDecorator implements IApplicationMediator {
|
|
3
|
-
private readonly wrapped;
|
|
4
|
-
constructor(wrapped: IApplicationMediator);
|
|
5
|
-
execute(method: string, params: any): Promise<any>;
|
|
6
|
-
register(method: string, handler: any): void;
|
|
7
|
-
setResponseValidator(fn: (method: string, result: any) => void): void;
|
|
8
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SimpleOutputDecorator = void 0;
|
|
4
|
-
const CONTEXT_OPTIMIZATION_TEXT = `
|
|
5
|
-
|
|
6
|
-
**CONTEXT OPTIMIZATION REQUIREMENTS**:
|
|
7
|
-
|
|
8
|
-
The MCP server is STATELESS. You MUST send required data with each request:
|
|
9
|
-
|
|
10
|
-
**ALWAYS INCLUDE:**
|
|
11
|
-
1. \`workflowId\` - Required for all calls
|
|
12
|
-
2. \`completedSteps\` - Full array of completed step IDs
|
|
13
|
-
3. **Condition Variables** - ANY variable used in step \`runCondition\` fields
|
|
14
|
-
4. **Template Variables** - ANY variable referenced in {{templates}} in prompts/titles
|
|
15
|
-
5. **Your New/Modified Variables** - Variables you created or changed in this step
|
|
16
|
-
|
|
17
|
-
**CONDITIONALLY INCLUDE:**
|
|
18
|
-
- **Loop Variables** (when in a loop): \`currentIteration\`, \`currentItem\`, \`currentIndex\`
|
|
19
|
-
- **Active Loop State**: Only \`_loopState[currentLoopId]\` if currently in a loop
|
|
20
|
-
- **Referenced Variables**: Any variable that future steps might need
|
|
21
|
-
|
|
22
|
-
**NEVER INCLUDE:**
|
|
23
|
-
- Large arrays that aren't being actively iterated (e.g., \`implementationSteps\` array)
|
|
24
|
-
- Stale loop states from completed loops
|
|
25
|
-
- Unreferenced historical data
|
|
26
|
-
- Variables only used in completed steps
|
|
27
|
-
|
|
28
|
-
**SIZE TARGETS:**
|
|
29
|
-
- Normal steps: < 2KB
|
|
30
|
-
- Loop iterations: < 5KB
|
|
31
|
-
- Complex state: < 10KB
|
|
32
|
-
|
|
33
|
-
**EXAMPLE - Loop Context:**
|
|
34
|
-
\`\`\`json
|
|
35
|
-
{
|
|
36
|
-
"workflowId": "coding-task-workflow-with-loops",
|
|
37
|
-
"completedSteps": ["phase-1", "phase-2", "loop-step-1"],
|
|
38
|
-
"context": {
|
|
39
|
-
// Required: condition/template variables
|
|
40
|
-
"taskComplexity": "Medium",
|
|
41
|
-
"totalImplementationSteps": 8,
|
|
42
|
-
"currentStepNumber": 3,
|
|
43
|
-
|
|
44
|
-
// Required: your changes
|
|
45
|
-
"stepCompleted": true,
|
|
46
|
-
"testResults": "passed",
|
|
47
|
-
|
|
48
|
-
// Required: active loop state only
|
|
49
|
-
"_loopState": {
|
|
50
|
-
"phase-6-loop": { "iteration": 3 }
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
// DON'T include:
|
|
54
|
-
// - implementationSteps: [...] // Large array
|
|
55
|
-
// - analysisResults: {...} // From phase 1
|
|
56
|
-
// - _loopState.oldLoop: {...} // Completed loop
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
\`\`\`
|
|
60
|
-
|
|
61
|
-
**VALIDATION CHECK**: Before sending, verify you have ALL variables referenced in:
|
|
62
|
-
- The next step's \`runCondition\`
|
|
63
|
-
- Any {{variable}} in the next step's prompts
|
|
64
|
-
- Variables needed for loop control`;
|
|
65
|
-
class SimpleOutputDecorator {
|
|
66
|
-
constructor(wrapped) {
|
|
67
|
-
this.wrapped = wrapped;
|
|
68
|
-
}
|
|
69
|
-
async execute(method, params) {
|
|
70
|
-
const result = await this.wrapped.execute(method, params);
|
|
71
|
-
if (method === 'workflow_next' && result?.guidance?.prompt) {
|
|
72
|
-
return {
|
|
73
|
-
...result,
|
|
74
|
-
guidance: {
|
|
75
|
-
...result.guidance,
|
|
76
|
-
prompt: result.guidance.prompt + CONTEXT_OPTIMIZATION_TEXT
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
register(method, handler) {
|
|
83
|
-
this.wrapped.register(method, handler);
|
|
84
|
-
}
|
|
85
|
-
setResponseValidator(fn) {
|
|
86
|
-
this.wrapped.setResponseValidator(fn);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.SimpleOutputDecorator = SimpleOutputDecorator;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ContextLayer, ClassificationRules, ClassifiedContext, RawContext } from '../../types/context-types';
|
|
2
|
-
export interface IClassificationEngine {
|
|
3
|
-
classify(context: RawContext, rules?: ClassificationRules): Promise<ClassifiedContext>;
|
|
4
|
-
loadRules(config?: Partial<ClassificationRules>): Promise<void>;
|
|
5
|
-
addOverride(sessionId: string, contextKey: string, layer: ContextLayer): void;
|
|
6
|
-
removeOverride(sessionId: string, contextKey: string): void;
|
|
7
|
-
markCritical(sessionId: string, contextKey: string): Promise<void>;
|
|
8
|
-
getStats(): ClassificationStats;
|
|
9
|
-
}
|
|
10
|
-
export interface ClassificationStats {
|
|
11
|
-
totalClassifications: number;
|
|
12
|
-
layerDistribution: Record<ContextLayer, number>;
|
|
13
|
-
overrideCount: number;
|
|
14
|
-
averageProcessingTime: number;
|
|
15
|
-
}
|
|
16
|
-
export declare class ClassificationEngine implements IClassificationEngine {
|
|
17
|
-
private rules;
|
|
18
|
-
private overrides;
|
|
19
|
-
private stats;
|
|
20
|
-
constructor(initialRules?: ClassificationRules);
|
|
21
|
-
classify(context: RawContext, rules?: ClassificationRules): Promise<ClassifiedContext>;
|
|
22
|
-
loadRules(config?: Partial<ClassificationRules>): Promise<void>;
|
|
23
|
-
addOverride(sessionId: string, contextKey: string, layer: ContextLayer): void;
|
|
24
|
-
removeOverride(sessionId: string, contextKey: string): void;
|
|
25
|
-
markCritical(sessionId: string, contextKey: string): Promise<void>;
|
|
26
|
-
getStats(): ClassificationStats;
|
|
27
|
-
private classifyKeyValue;
|
|
28
|
-
private applyPatternMatching;
|
|
29
|
-
private matchesPattern;
|
|
30
|
-
private applyHeuristics;
|
|
31
|
-
private updateStats;
|
|
32
|
-
private getDefaultRules;
|
|
33
|
-
}
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClassificationEngine = void 0;
|
|
4
|
-
const context_types_1 = require("../../types/context-types");
|
|
5
|
-
class ClassificationEngine {
|
|
6
|
-
constructor(initialRules) {
|
|
7
|
-
this.overrides = new Map();
|
|
8
|
-
this.rules = initialRules || this.getDefaultRules();
|
|
9
|
-
this.stats = {
|
|
10
|
-
totalClassifications: 0,
|
|
11
|
-
layerDistribution: {
|
|
12
|
-
[context_types_1.ContextLayer.CRITICAL]: 0,
|
|
13
|
-
[context_types_1.ContextLayer.IMPORTANT]: 0,
|
|
14
|
-
[context_types_1.ContextLayer.USEFUL]: 0,
|
|
15
|
-
[context_types_1.ContextLayer.EPHEMERAL]: 0
|
|
16
|
-
},
|
|
17
|
-
overrideCount: 0,
|
|
18
|
-
averageProcessingTime: 0
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
async classify(context, rules) {
|
|
22
|
-
const startTime = process.hrtime.bigint();
|
|
23
|
-
const activeRules = rules || this.rules;
|
|
24
|
-
const classified = {
|
|
25
|
-
[context_types_1.ContextLayer.CRITICAL]: {},
|
|
26
|
-
[context_types_1.ContextLayer.IMPORTANT]: {},
|
|
27
|
-
[context_types_1.ContextLayer.USEFUL]: {},
|
|
28
|
-
[context_types_1.ContextLayer.EPHEMERAL]: {}
|
|
29
|
-
};
|
|
30
|
-
for (const [key, value] of Object.entries(context)) {
|
|
31
|
-
const layer = this.classifyKeyValue(key, value, activeRules);
|
|
32
|
-
classified[layer][key] = value;
|
|
33
|
-
}
|
|
34
|
-
this.updateStats(startTime, classified);
|
|
35
|
-
return Object.freeze(classified);
|
|
36
|
-
}
|
|
37
|
-
async loadRules(config) {
|
|
38
|
-
if (config) {
|
|
39
|
-
this.rules = {
|
|
40
|
-
patterns: { ...this.rules.patterns, ...config.patterns },
|
|
41
|
-
heuristics: { ...this.rules.heuristics, ...config.heuristics },
|
|
42
|
-
overrides: { ...this.rules.overrides, ...config.overrides }
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
addOverride(sessionId, contextKey, layer) {
|
|
47
|
-
if (!this.overrides.has(sessionId)) {
|
|
48
|
-
this.overrides.set(sessionId, new Map());
|
|
49
|
-
}
|
|
50
|
-
const sessionOverrides = this.overrides.get(sessionId);
|
|
51
|
-
sessionOverrides.set(contextKey, layer);
|
|
52
|
-
this.stats.overrideCount++;
|
|
53
|
-
}
|
|
54
|
-
removeOverride(sessionId, contextKey) {
|
|
55
|
-
const sessionOverrides = this.overrides.get(sessionId);
|
|
56
|
-
if (sessionOverrides && sessionOverrides.has(contextKey)) {
|
|
57
|
-
sessionOverrides.delete(contextKey);
|
|
58
|
-
this.stats.overrideCount = Math.max(0, this.stats.overrideCount - 1);
|
|
59
|
-
if (sessionOverrides.size === 0) {
|
|
60
|
-
this.overrides.delete(sessionId);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
async markCritical(sessionId, contextKey) {
|
|
65
|
-
this.addOverride(sessionId, contextKey, context_types_1.ContextLayer.CRITICAL);
|
|
66
|
-
console.log(`✓ Marked key '${contextKey}' as CRITICAL for session '${sessionId}'`);
|
|
67
|
-
}
|
|
68
|
-
getStats() {
|
|
69
|
-
return { ...this.stats };
|
|
70
|
-
}
|
|
71
|
-
classifyKeyValue(key, value, rules, sessionId) {
|
|
72
|
-
if (sessionId) {
|
|
73
|
-
const sessionOverrides = this.overrides.get(sessionId);
|
|
74
|
-
const override = sessionOverrides?.get(key);
|
|
75
|
-
if (override) {
|
|
76
|
-
return override;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (rules.overrides[key]) {
|
|
80
|
-
return rules.overrides[key];
|
|
81
|
-
}
|
|
82
|
-
const patternLayer = this.applyPatternMatching(key, value, rules);
|
|
83
|
-
if (patternLayer) {
|
|
84
|
-
return patternLayer;
|
|
85
|
-
}
|
|
86
|
-
return this.applyHeuristics(key, value, rules);
|
|
87
|
-
}
|
|
88
|
-
applyPatternMatching(key, value, rules) {
|
|
89
|
-
let bestMatch = null;
|
|
90
|
-
for (const [layer, patterns] of Object.entries(rules.patterns)) {
|
|
91
|
-
for (const pattern of patterns) {
|
|
92
|
-
if (this.matchesPattern(key, value, pattern)) {
|
|
93
|
-
if (!bestMatch || pattern.weight > bestMatch.weight) {
|
|
94
|
-
bestMatch = { layer: layer, weight: pattern.weight };
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return bestMatch?.layer || null;
|
|
100
|
-
}
|
|
101
|
-
matchesPattern(key, value, pattern) {
|
|
102
|
-
const keyRegex = new RegExp(pattern.keyPattern, 'i');
|
|
103
|
-
if (!keyRegex.test(key)) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
if (pattern.valuePattern) {
|
|
107
|
-
const valueStr = typeof value === 'string' ? value : JSON.stringify(value);
|
|
108
|
-
const valueRegex = new RegExp(pattern.valuePattern, 'i');
|
|
109
|
-
if (!valueRegex.test(valueStr)) {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
applyHeuristics(key, value, rules) {
|
|
116
|
-
const heuristics = rules.heuristics;
|
|
117
|
-
const valueStr = typeof value === 'string' ? value :
|
|
118
|
-
value === undefined ? 'undefined' :
|
|
119
|
-
value === null ? 'null' :
|
|
120
|
-
JSON.stringify(value);
|
|
121
|
-
const contentLength = valueStr.length;
|
|
122
|
-
let keywordScore = 0;
|
|
123
|
-
for (const [keyword, weight] of Object.entries(heuristics.keywordWeights)) {
|
|
124
|
-
const regex = new RegExp(keyword, 'gi');
|
|
125
|
-
const matches = (key + ' ' + valueStr).match(regex);
|
|
126
|
-
if (matches) {
|
|
127
|
-
keywordScore += matches.length * weight;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (keywordScore >= 10 || contentLength >= heuristics.lengthThresholds[context_types_1.ContextLayer.CRITICAL]) {
|
|
131
|
-
return context_types_1.ContextLayer.CRITICAL;
|
|
132
|
-
}
|
|
133
|
-
else if (keywordScore >= 5 || contentLength >= heuristics.lengthThresholds[context_types_1.ContextLayer.IMPORTANT]) {
|
|
134
|
-
return context_types_1.ContextLayer.IMPORTANT;
|
|
135
|
-
}
|
|
136
|
-
else if (contentLength >= heuristics.lengthThresholds[context_types_1.ContextLayer.USEFUL]) {
|
|
137
|
-
return context_types_1.ContextLayer.USEFUL;
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
return heuristics.defaultLayer;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
updateStats(startTime, classified) {
|
|
144
|
-
const endTime = process.hrtime.bigint();
|
|
145
|
-
const processingTime = Number(endTime - startTime) / 1000000;
|
|
146
|
-
this.stats.totalClassifications++;
|
|
147
|
-
this.stats.averageProcessingTime =
|
|
148
|
-
(this.stats.averageProcessingTime * (this.stats.totalClassifications - 1) + processingTime) /
|
|
149
|
-
this.stats.totalClassifications;
|
|
150
|
-
for (const [layer, content] of Object.entries(classified)) {
|
|
151
|
-
const itemCount = Object.keys(content).length;
|
|
152
|
-
this.stats.layerDistribution[layer] += itemCount;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
getDefaultRules() {
|
|
156
|
-
return {
|
|
157
|
-
patterns: {
|
|
158
|
-
[context_types_1.ContextLayer.CRITICAL]: [
|
|
159
|
-
{
|
|
160
|
-
keyPattern: '^(goal|objective|target|requirement|result|answer|decision|conclusion)s?$',
|
|
161
|
-
weight: 100,
|
|
162
|
-
description: 'Core workflow objectives and final results'
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
keyPattern: '^(user|customer|client).*',
|
|
166
|
-
weight: 90,
|
|
167
|
-
description: 'User-related information and requirements'
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
keyPattern: '^(error|failure|critical|urgent|important).*',
|
|
171
|
-
weight: 85,
|
|
172
|
-
description: 'Critical errors and urgent items'
|
|
173
|
-
}
|
|
174
|
-
],
|
|
175
|
-
[context_types_1.ContextLayer.IMPORTANT]: [
|
|
176
|
-
{
|
|
177
|
-
keyPattern: '^(plan|strategy|approach|method|process|workflow)s?$',
|
|
178
|
-
weight: 80,
|
|
179
|
-
description: 'Planning and strategic information'
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
keyPattern: '^(config|settings|parameters).*',
|
|
183
|
-
weight: 70,
|
|
184
|
-
description: 'Configuration and settings'
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
keyPattern: '^(state|status|progress).*',
|
|
188
|
-
weight: 65,
|
|
189
|
-
description: 'Current state and progress tracking'
|
|
190
|
-
}
|
|
191
|
-
],
|
|
192
|
-
[context_types_1.ContextLayer.USEFUL]: [
|
|
193
|
-
{
|
|
194
|
-
keyPattern: '^(data|content|information|details).*',
|
|
195
|
-
weight: 50,
|
|
196
|
-
description: 'Supporting data and detailed information'
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
keyPattern: '^(example|sample|demo)s?.*',
|
|
200
|
-
weight: 45,
|
|
201
|
-
description: 'Examples and demonstrations'
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
keyPattern: '^(analysis|report|summary).*',
|
|
205
|
-
weight: 40,
|
|
206
|
-
description: 'Analysis results and reports'
|
|
207
|
-
}
|
|
208
|
-
],
|
|
209
|
-
[context_types_1.ContextLayer.EPHEMERAL]: [
|
|
210
|
-
{
|
|
211
|
-
keyPattern: '^(temp|temporary|cache|buffer).*',
|
|
212
|
-
weight: 20,
|
|
213
|
-
description: 'Temporary data and cache'
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
keyPattern: '.*(debug|log|trace|timestamp).*',
|
|
217
|
-
weight: 15,
|
|
218
|
-
description: 'Debug information and logs'
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
keyPattern: '^(_|internal).*',
|
|
222
|
-
weight: 10,
|
|
223
|
-
description: 'Internal system metadata'
|
|
224
|
-
}
|
|
225
|
-
]
|
|
226
|
-
},
|
|
227
|
-
heuristics: {
|
|
228
|
-
lengthThresholds: {
|
|
229
|
-
[context_types_1.ContextLayer.CRITICAL]: 1000,
|
|
230
|
-
[context_types_1.ContextLayer.IMPORTANT]: 500,
|
|
231
|
-
[context_types_1.ContextLayer.USEFUL]: 100,
|
|
232
|
-
[context_types_1.ContextLayer.EPHEMERAL]: 0
|
|
233
|
-
},
|
|
234
|
-
keywordWeights: {
|
|
235
|
-
'goal': 15,
|
|
236
|
-
'objective': 15,
|
|
237
|
-
'requirement': 12,
|
|
238
|
-
'critical': 10,
|
|
239
|
-
'important': 8,
|
|
240
|
-
'urgent': 8,
|
|
241
|
-
'user': 7,
|
|
242
|
-
'error': 7,
|
|
243
|
-
'failure': 7,
|
|
244
|
-
'plan': 6,
|
|
245
|
-
'strategy': 6,
|
|
246
|
-
'config': 5,
|
|
247
|
-
'data': 3,
|
|
248
|
-
'example': 2,
|
|
249
|
-
'debug': 1,
|
|
250
|
-
'temp': 1
|
|
251
|
-
},
|
|
252
|
-
defaultLayer: context_types_1.ContextLayer.USEFUL
|
|
253
|
-
},
|
|
254
|
-
overrides: {}
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
exports.ClassificationEngine = ClassificationEngine;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ICompressionService, ClassifiedContext, CompressedBlob, RawContext, CompressionConfig, CompressionStats } from '../../types/context-types';
|
|
2
|
-
export declare class CompressionService implements ICompressionService {
|
|
3
|
-
private config;
|
|
4
|
-
private stats;
|
|
5
|
-
constructor(config?: Partial<CompressionConfig>);
|
|
6
|
-
compress(classified: ClassifiedContext): Promise<CompressedBlob>;
|
|
7
|
-
decompress(blob: CompressedBlob): Promise<RawContext>;
|
|
8
|
-
getStats(): CompressionStats;
|
|
9
|
-
resetStats(): void;
|
|
10
|
-
updateConfig(newConfig: Partial<CompressionConfig>): void;
|
|
11
|
-
private compressLayer;
|
|
12
|
-
private decompressLayer;
|
|
13
|
-
private applyLightCompression;
|
|
14
|
-
private applyMediumCompression;
|
|
15
|
-
private applyAggressiveCompression;
|
|
16
|
-
private applyAlgorithmCompression;
|
|
17
|
-
private applyAlgorithmDecompression;
|
|
18
|
-
private createUncompressedBlob;
|
|
19
|
-
private updateStats;
|
|
20
|
-
}
|