@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
|
@@ -1,312 +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.CompressionService = void 0;
|
|
37
|
-
const zlib = __importStar(require("zlib"));
|
|
38
|
-
const util_1 = require("util");
|
|
39
|
-
const context_types_1 = require("../../types/context-types");
|
|
40
|
-
const gzip = (0, util_1.promisify)(zlib.gzip);
|
|
41
|
-
const gunzip = (0, util_1.promisify)(zlib.gunzip);
|
|
42
|
-
const deflate = (0, util_1.promisify)(zlib.deflate);
|
|
43
|
-
const inflate = (0, util_1.promisify)(zlib.inflate);
|
|
44
|
-
const LAYER_COMPRESSION_SETTINGS = {
|
|
45
|
-
[context_types_1.ContextLayer.CRITICAL]: {
|
|
46
|
-
enabled: false,
|
|
47
|
-
aggressiveness: 'none',
|
|
48
|
-
level: 0
|
|
49
|
-
},
|
|
50
|
-
[context_types_1.ContextLayer.IMPORTANT]: {
|
|
51
|
-
enabled: true,
|
|
52
|
-
aggressiveness: 'light',
|
|
53
|
-
level: 3
|
|
54
|
-
},
|
|
55
|
-
[context_types_1.ContextLayer.USEFUL]: {
|
|
56
|
-
enabled: true,
|
|
57
|
-
aggressiveness: 'medium',
|
|
58
|
-
level: 6
|
|
59
|
-
},
|
|
60
|
-
[context_types_1.ContextLayer.EPHEMERAL]: {
|
|
61
|
-
enabled: true,
|
|
62
|
-
aggressiveness: 'aggressive',
|
|
63
|
-
level: 9
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const DEFAULT_COMPRESSION_CONFIG = {
|
|
67
|
-
enabled: true,
|
|
68
|
-
algorithm: 'gzip',
|
|
69
|
-
level: 6,
|
|
70
|
-
layerSettings: LAYER_COMPRESSION_SETTINGS
|
|
71
|
-
};
|
|
72
|
-
class CompressionService {
|
|
73
|
-
constructor(config = {}) {
|
|
74
|
-
this.config = { ...DEFAULT_COMPRESSION_CONFIG, ...config };
|
|
75
|
-
this.stats = {
|
|
76
|
-
totalOperations: 0,
|
|
77
|
-
averageRatio: 1.0,
|
|
78
|
-
totalSizeReduction: 0,
|
|
79
|
-
averageCompressionTime: 0
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
async compress(classified) {
|
|
83
|
-
const startTime = process.hrtime.bigint();
|
|
84
|
-
try {
|
|
85
|
-
const compressedLayers = {};
|
|
86
|
-
let totalOriginalSize = 0;
|
|
87
|
-
let totalCompressedSize = 0;
|
|
88
|
-
for (const [layerName, layerData] of Object.entries(classified)) {
|
|
89
|
-
const layer = layerName;
|
|
90
|
-
const layerConfig = this.config.layerSettings[layer];
|
|
91
|
-
if (!layerConfig.enabled || !this.config.enabled) {
|
|
92
|
-
const safeData = layerData || {};
|
|
93
|
-
compressedLayers[layer] = safeData;
|
|
94
|
-
const serialized = JSON.stringify(safeData);
|
|
95
|
-
totalOriginalSize += Buffer.byteLength(serialized, 'utf8');
|
|
96
|
-
totalCompressedSize += Buffer.byteLength(serialized, 'utf8');
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
const result = await this.compressLayer(layerData, layer, layerConfig.aggressiveness);
|
|
100
|
-
compressedLayers[layer] = result.data;
|
|
101
|
-
totalOriginalSize += result.originalSize;
|
|
102
|
-
totalCompressedSize += result.compressedSize;
|
|
103
|
-
}
|
|
104
|
-
const serializedData = JSON.stringify(compressedLayers);
|
|
105
|
-
let finalCompressedBuffer;
|
|
106
|
-
if (this.config.enabled) {
|
|
107
|
-
finalCompressedBuffer = await this.applyAlgorithmCompression(Buffer.from(serializedData, 'utf8'), this.config.level);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
finalCompressedBuffer = Buffer.from(serializedData, 'utf8');
|
|
111
|
-
}
|
|
112
|
-
const finalOriginalSize = Buffer.byteLength(serializedData, 'utf8');
|
|
113
|
-
const finalCompressedSize = finalCompressedBuffer.length;
|
|
114
|
-
if (!this.config.enabled) {
|
|
115
|
-
return {
|
|
116
|
-
data: finalCompressedBuffer,
|
|
117
|
-
originalSize: finalCompressedSize,
|
|
118
|
-
compressedSize: finalCompressedSize,
|
|
119
|
-
compressionRatio: 1.0,
|
|
120
|
-
algorithm: 'none'
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
const compressionRatio = totalOriginalSize > 0 ? totalOriginalSize / finalCompressedSize : 1.0;
|
|
124
|
-
const endTime = process.hrtime.bigint();
|
|
125
|
-
const compressionTimeMs = Number(endTime - startTime) / 1000000;
|
|
126
|
-
this.updateStats(compressionRatio, totalOriginalSize - finalCompressedSize, compressionTimeMs);
|
|
127
|
-
return {
|
|
128
|
-
data: finalCompressedBuffer,
|
|
129
|
-
originalSize: totalOriginalSize,
|
|
130
|
-
compressedSize: finalCompressedSize,
|
|
131
|
-
compressionRatio,
|
|
132
|
-
algorithm: this.config.enabled ? this.config.algorithm : 'none'
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
console.warn('Compression failed, falling back to uncompressed data:', error);
|
|
137
|
-
return this.createUncompressedBlob(classified);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
async decompress(blob) {
|
|
141
|
-
try {
|
|
142
|
-
if (blob.algorithm === 'none') {
|
|
143
|
-
return JSON.parse(blob.data.toString('utf8'));
|
|
144
|
-
}
|
|
145
|
-
const decompressedBuffer = await this.applyAlgorithmDecompression(blob.data);
|
|
146
|
-
const decompressedData = JSON.parse(decompressedBuffer.toString('utf8'));
|
|
147
|
-
const rawContext = {};
|
|
148
|
-
for (const [layerName, layerData] of Object.entries(decompressedData)) {
|
|
149
|
-
const layer = layerName;
|
|
150
|
-
const layerConfig = this.config.layerSettings[layer];
|
|
151
|
-
if (!layerConfig.enabled) {
|
|
152
|
-
Object.assign(rawContext, layerData);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
const decompressedLayerData = await this.decompressLayer(layerData, layer);
|
|
156
|
-
Object.assign(rawContext, decompressedLayerData);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return Object.freeze(rawContext);
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
throw new Error(`Decompression failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
getStats() {
|
|
166
|
-
return { ...this.stats };
|
|
167
|
-
}
|
|
168
|
-
resetStats() {
|
|
169
|
-
this.stats = {
|
|
170
|
-
totalOperations: 0,
|
|
171
|
-
averageRatio: 1.0,
|
|
172
|
-
totalSizeReduction: 0,
|
|
173
|
-
averageCompressionTime: 0
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
updateConfig(newConfig) {
|
|
177
|
-
this.config = { ...this.config, ...newConfig };
|
|
178
|
-
}
|
|
179
|
-
async compressLayer(layerData, layer, aggressiveness) {
|
|
180
|
-
const safeLayerData = layerData || {};
|
|
181
|
-
const serialized = JSON.stringify(safeLayerData);
|
|
182
|
-
const originalSize = Buffer.byteLength(serialized, 'utf8');
|
|
183
|
-
if (aggressiveness === 'none') {
|
|
184
|
-
return {
|
|
185
|
-
data: safeLayerData,
|
|
186
|
-
originalSize,
|
|
187
|
-
compressedSize: originalSize
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
let processedData = safeLayerData;
|
|
191
|
-
switch (aggressiveness) {
|
|
192
|
-
case 'light':
|
|
193
|
-
processedData = this.applyLightCompression(layerData);
|
|
194
|
-
break;
|
|
195
|
-
case 'medium':
|
|
196
|
-
processedData = this.applyMediumCompression(layerData);
|
|
197
|
-
break;
|
|
198
|
-
case 'aggressive':
|
|
199
|
-
processedData = this.applyAggressiveCompression(layerData);
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
const processedSerialized = JSON.stringify(processedData);
|
|
203
|
-
const compressedSize = Buffer.byteLength(processedSerialized, 'utf8');
|
|
204
|
-
return {
|
|
205
|
-
data: processedData,
|
|
206
|
-
originalSize,
|
|
207
|
-
compressedSize
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
async decompressLayer(layerData, layer) {
|
|
211
|
-
return layerData;
|
|
212
|
-
}
|
|
213
|
-
applyLightCompression(data) {
|
|
214
|
-
const compressed = {};
|
|
215
|
-
for (const [key, value] of Object.entries(data)) {
|
|
216
|
-
if (typeof value === 'string') {
|
|
217
|
-
compressed[key] = value.replace(/\s+/g, ' ').trim();
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
compressed[key] = value;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return compressed;
|
|
224
|
-
}
|
|
225
|
-
applyMediumCompression(data) {
|
|
226
|
-
const compressed = {};
|
|
227
|
-
for (const [key, value] of Object.entries(data)) {
|
|
228
|
-
if (typeof value === 'string') {
|
|
229
|
-
let processedValue = value.replace(/\s+/g, ' ').trim();
|
|
230
|
-
if (processedValue.length > 1000) {
|
|
231
|
-
processedValue = processedValue.substring(0, 950) + '...[truncated]';
|
|
232
|
-
}
|
|
233
|
-
compressed[key] = processedValue;
|
|
234
|
-
}
|
|
235
|
-
else if (Array.isArray(value) && value.length > 50) {
|
|
236
|
-
compressed[key] = [...value.slice(0, 50), '...[truncated]'];
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
compressed[key] = value;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return compressed;
|
|
243
|
-
}
|
|
244
|
-
applyAggressiveCompression(data) {
|
|
245
|
-
const compressed = {};
|
|
246
|
-
for (const [key, value] of Object.entries(data)) {
|
|
247
|
-
if (key.includes('debug') || key.includes('temp') || key.includes('timestamp')) {
|
|
248
|
-
continue;
|
|
249
|
-
}
|
|
250
|
-
if (typeof value === 'string') {
|
|
251
|
-
let processedValue = value.replace(/\s+/g, ' ').trim();
|
|
252
|
-
if (processedValue.length > 200) {
|
|
253
|
-
processedValue = processedValue.substring(0, 100) +
|
|
254
|
-
'...[compressed]...' +
|
|
255
|
-
processedValue.substring(processedValue.length - 50);
|
|
256
|
-
}
|
|
257
|
-
compressed[key] = processedValue;
|
|
258
|
-
}
|
|
259
|
-
else if (Array.isArray(value) && value.length > 10) {
|
|
260
|
-
compressed[key] = [...value.slice(0, 5), '...[compressed]', ...value.slice(-2)];
|
|
261
|
-
}
|
|
262
|
-
else if (typeof value === 'object' && value !== null) {
|
|
263
|
-
compressed[key] = this.applyAggressiveCompression(value);
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
compressed[key] = value;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
return compressed;
|
|
270
|
-
}
|
|
271
|
-
async applyAlgorithmCompression(data, level) {
|
|
272
|
-
const options = { level };
|
|
273
|
-
switch (this.config.algorithm) {
|
|
274
|
-
case 'gzip':
|
|
275
|
-
return await gzip(data, options);
|
|
276
|
-
case 'deflate':
|
|
277
|
-
return await deflate(data, options);
|
|
278
|
-
default:
|
|
279
|
-
throw new Error(`Unsupported compression algorithm: ${this.config.algorithm}`);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
async applyAlgorithmDecompression(data) {
|
|
283
|
-
switch (this.config.algorithm) {
|
|
284
|
-
case 'gzip':
|
|
285
|
-
return await gunzip(data);
|
|
286
|
-
case 'deflate':
|
|
287
|
-
return await inflate(data);
|
|
288
|
-
default:
|
|
289
|
-
throw new Error(`Unsupported compression algorithm: ${this.config.algorithm}`);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
createUncompressedBlob(classified) {
|
|
293
|
-
const serialized = JSON.stringify(classified);
|
|
294
|
-
const data = Buffer.from(serialized, 'utf8');
|
|
295
|
-
const size = data.length;
|
|
296
|
-
return {
|
|
297
|
-
data,
|
|
298
|
-
originalSize: size,
|
|
299
|
-
compressedSize: size,
|
|
300
|
-
compressionRatio: 1.0,
|
|
301
|
-
algorithm: 'none'
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
updateStats(ratio, sizeReduction, timeMs) {
|
|
305
|
-
const prevOps = this.stats.totalOperations;
|
|
306
|
-
this.stats.totalOperations += 1;
|
|
307
|
-
this.stats.averageRatio = (this.stats.averageRatio * prevOps + ratio) / this.stats.totalOperations;
|
|
308
|
-
this.stats.totalSizeReduction += sizeReduction;
|
|
309
|
-
this.stats.averageCompressionTime = (this.stats.averageCompressionTime * prevOps + timeMs) / this.stats.totalOperations;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
exports.CompressionService = CompressionService;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { IContextManagementService, IContextPersistenceService, SaveCheckpointParams, SaveCheckpointResult, LoadCheckpointParams, LoadCheckpointResult, ListCheckpointsParams, CheckpointMetadata, MarkCriticalParams, MarkCriticalResult } from '../../types/context-types';
|
|
2
|
-
import { IContextStorage } from '../../infrastructure/storage/context-storage';
|
|
3
|
-
interface ContextManagementMetrics {
|
|
4
|
-
totalSaveOperations: number;
|
|
5
|
-
totalLoadOperations: number;
|
|
6
|
-
totalListOperations: number;
|
|
7
|
-
totalMarkCriticalOperations: number;
|
|
8
|
-
averageSaveTime: number;
|
|
9
|
-
averageLoadTime: number;
|
|
10
|
-
lastOperationTime: number;
|
|
11
|
-
errorCount: number;
|
|
12
|
-
}
|
|
13
|
-
export declare class ContextManagementService implements IContextManagementService {
|
|
14
|
-
private readonly persistenceService;
|
|
15
|
-
private readonly storage;
|
|
16
|
-
private metrics;
|
|
17
|
-
constructor(persistenceService: IContextPersistenceService, storage: IContextStorage);
|
|
18
|
-
saveCheckpoint(params: SaveCheckpointParams): Promise<SaveCheckpointResult>;
|
|
19
|
-
loadCheckpoint(params: LoadCheckpointParams): Promise<LoadCheckpointResult>;
|
|
20
|
-
listCheckpoints(params: ListCheckpointsParams): Promise<CheckpointMetadata[]>;
|
|
21
|
-
markCritical(params: MarkCriticalParams): Promise<MarkCriticalResult>;
|
|
22
|
-
getMetrics(): ContextManagementMetrics;
|
|
23
|
-
resetMetrics(): void;
|
|
24
|
-
private generateSessionId;
|
|
25
|
-
private generateCheckpointId;
|
|
26
|
-
private isContextUnchanged;
|
|
27
|
-
private getLastCheckpointId;
|
|
28
|
-
private countLayers;
|
|
29
|
-
private upsertSessionInfo;
|
|
30
|
-
private updateSaveMetrics;
|
|
31
|
-
private updateLoadMetrics;
|
|
32
|
-
private updateListMetrics;
|
|
33
|
-
private updateMarkCriticalMetrics;
|
|
34
|
-
private calculateMovingAverage;
|
|
35
|
-
private hashContext;
|
|
36
|
-
private getLastCheckpointData;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
@@ -1,301 +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.ContextManagementService = void 0;
|
|
37
|
-
const crypto = __importStar(require("crypto"));
|
|
38
|
-
const error_handler_1 = require("../../core/error-handler");
|
|
39
|
-
class ContextManagementService {
|
|
40
|
-
constructor(persistenceService, storage) {
|
|
41
|
-
this.persistenceService = persistenceService;
|
|
42
|
-
this.storage = storage;
|
|
43
|
-
this.metrics = {
|
|
44
|
-
totalSaveOperations: 0,
|
|
45
|
-
totalLoadOperations: 0,
|
|
46
|
-
totalListOperations: 0,
|
|
47
|
-
totalMarkCriticalOperations: 0,
|
|
48
|
-
averageSaveTime: 0,
|
|
49
|
-
averageLoadTime: 0,
|
|
50
|
-
lastOperationTime: 0,
|
|
51
|
-
errorCount: 0
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
async saveCheckpoint(params) {
|
|
55
|
-
const startTimeMs = Date.now();
|
|
56
|
-
try {
|
|
57
|
-
const frozenParams = Object.freeze({ ...params });
|
|
58
|
-
const frozenContext = Object.freeze({ ...frozenParams.context });
|
|
59
|
-
const sessionId = frozenParams.sessionId || this.generateSessionId(frozenContext);
|
|
60
|
-
const lastCheckpointData = await this.getLastCheckpointData(sessionId);
|
|
61
|
-
const currentHash = this.hashContext(frozenParams.context);
|
|
62
|
-
if (!frozenParams.force && lastCheckpointData && lastCheckpointData.contextHash === currentHash) {
|
|
63
|
-
return {
|
|
64
|
-
checkpointId: lastCheckpointData.id || 'none',
|
|
65
|
-
sessionId,
|
|
66
|
-
status: 'SKIPPED_UNCHANGED',
|
|
67
|
-
sizeBytes: lastCheckpointData.contextSizeBytes || undefined
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
const pipelineResult = await this.persistenceService.processPersistencePipeline(frozenParams.context, '');
|
|
71
|
-
const checkpointId = this.generateCheckpointId(sessionId);
|
|
72
|
-
const metadata = {
|
|
73
|
-
id: checkpointId,
|
|
74
|
-
sessionId,
|
|
75
|
-
name: frozenParams.metadata?.name,
|
|
76
|
-
agentId: 'default',
|
|
77
|
-
createdAt: new Date().toISOString(),
|
|
78
|
-
tags: frozenParams.metadata?.tags,
|
|
79
|
-
contextSizeBytes: pipelineResult.compressed.compressedSize,
|
|
80
|
-
contextHash: currentHash,
|
|
81
|
-
blobPath: '',
|
|
82
|
-
classificationSummary: {
|
|
83
|
-
criticalCount: this.countLayers(pipelineResult.classified, 'CRITICAL'),
|
|
84
|
-
importantCount: this.countLayers(pipelineResult.classified, 'IMPORTANT'),
|
|
85
|
-
usefulCount: this.countLayers(pipelineResult.classified, 'USEFUL'),
|
|
86
|
-
ephemeralCount: this.countLayers(pipelineResult.classified, 'EPHEMERAL')
|
|
87
|
-
},
|
|
88
|
-
status: 'active'
|
|
89
|
-
};
|
|
90
|
-
await this.storage.saveCheckpoint(metadata, pipelineResult.compressed);
|
|
91
|
-
await this.upsertSessionInfo(sessionId);
|
|
92
|
-
const endTime = Date.now();
|
|
93
|
-
this.updateSaveMetrics(endTime - startTimeMs);
|
|
94
|
-
return {
|
|
95
|
-
checkpointId,
|
|
96
|
-
sessionId,
|
|
97
|
-
status: 'SAVED',
|
|
98
|
-
sizeBytes: pipelineResult.compressed.compressedSize
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
this.metrics.errorCount++;
|
|
103
|
-
throw new Error(`Failed to save checkpoint: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
async loadCheckpoint(params) {
|
|
107
|
-
const startTime = process.hrtime.bigint();
|
|
108
|
-
try {
|
|
109
|
-
const frozenParams = Object.freeze({ ...params });
|
|
110
|
-
if (!frozenParams.checkpointId && !frozenParams.sessionId) {
|
|
111
|
-
throw new Error('Either checkpointId or sessionId must be provided');
|
|
112
|
-
}
|
|
113
|
-
let checkpointId;
|
|
114
|
-
if (frozenParams.checkpointId) {
|
|
115
|
-
checkpointId = frozenParams.checkpointId;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
const checkpoints = await this.storage.listCheckpoints(frozenParams.sessionId, 1, 0);
|
|
119
|
-
if (!checkpoints || checkpoints.length === 0) {
|
|
120
|
-
throw new Error(`No checkpoints found for session: ${frozenParams.sessionId}`);
|
|
121
|
-
}
|
|
122
|
-
checkpointId = checkpoints[0].id;
|
|
123
|
-
}
|
|
124
|
-
const checkpointData = await this.storage.loadCheckpoint(checkpointId);
|
|
125
|
-
if (!checkpointData) {
|
|
126
|
-
throw new error_handler_1.CheckpointNotFoundError(checkpointId);
|
|
127
|
-
}
|
|
128
|
-
const restorationResult = await this.persistenceService.restoreFromPersistence(checkpointData.blob);
|
|
129
|
-
const metadata = checkpointData.metadata;
|
|
130
|
-
if (!metadata) {
|
|
131
|
-
throw new error_handler_1.CheckpointNotFoundError(checkpointId);
|
|
132
|
-
}
|
|
133
|
-
const endTime = process.hrtime.bigint();
|
|
134
|
-
this.updateLoadMetrics(endTime);
|
|
135
|
-
return {
|
|
136
|
-
checkpointId,
|
|
137
|
-
sessionId: metadata.sessionId,
|
|
138
|
-
context: restorationResult.context,
|
|
139
|
-
metadata: {
|
|
140
|
-
name: metadata.name,
|
|
141
|
-
tags: metadata.tags,
|
|
142
|
-
createdAt: metadata.createdAt,
|
|
143
|
-
contextSizeBytes: metadata.contextSizeBytes
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
catch (error) {
|
|
148
|
-
this.metrics.errorCount++;
|
|
149
|
-
throw new Error(`Failed to load checkpoint: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async listCheckpoints(params) {
|
|
153
|
-
const startTime = process.hrtime.bigint();
|
|
154
|
-
try {
|
|
155
|
-
const frozenParams = Object.freeze({ ...params });
|
|
156
|
-
const checkpoints = await this.storage.listCheckpoints(frozenParams.sessionId, frozenParams.limit || 20, frozenParams.offset || 0);
|
|
157
|
-
const endTime = process.hrtime.bigint();
|
|
158
|
-
this.updateListMetrics(endTime);
|
|
159
|
-
return checkpoints;
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
this.metrics.errorCount++;
|
|
163
|
-
throw new Error(`Failed to list checkpoints: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
async markCritical(params) {
|
|
167
|
-
const startTime = process.hrtime.bigint();
|
|
168
|
-
try {
|
|
169
|
-
const frozenParams = Object.freeze({ ...params });
|
|
170
|
-
const classificationEngine = this.persistenceService.getClassificationEngine();
|
|
171
|
-
await classificationEngine.markCritical(frozenParams.sessionId, frozenParams.contextKey);
|
|
172
|
-
const endTime = process.hrtime.bigint();
|
|
173
|
-
this.updateMarkCriticalMetrics(endTime);
|
|
174
|
-
return {
|
|
175
|
-
status: 'SUCCESS',
|
|
176
|
-
message: `Key '${frozenParams.contextKey}' marked as critical for session '${frozenParams.sessionId}'`
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
this.metrics.errorCount++;
|
|
181
|
-
throw new Error(`Failed to mark critical: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
getMetrics() {
|
|
185
|
-
return Object.freeze({ ...this.metrics });
|
|
186
|
-
}
|
|
187
|
-
resetMetrics() {
|
|
188
|
-
this.metrics = {
|
|
189
|
-
totalSaveOperations: 0,
|
|
190
|
-
totalLoadOperations: 0,
|
|
191
|
-
totalListOperations: 0,
|
|
192
|
-
totalMarkCriticalOperations: 0,
|
|
193
|
-
averageSaveTime: 0,
|
|
194
|
-
averageLoadTime: 0,
|
|
195
|
-
lastOperationTime: 0,
|
|
196
|
-
errorCount: 0
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
generateSessionId(context) {
|
|
200
|
-
const contextString = JSON.stringify(context, Object.keys(context).sort());
|
|
201
|
-
const hash = crypto.createHash('sha256').update(contextString).digest('hex');
|
|
202
|
-
return `session_${hash.substring(0, 16)}`;
|
|
203
|
-
}
|
|
204
|
-
generateCheckpointId(sessionId) {
|
|
205
|
-
const timestamp = Date.now();
|
|
206
|
-
const randomSuffix = crypto.randomBytes(4).toString('hex');
|
|
207
|
-
return `${sessionId}_checkpoint_${timestamp}_${randomSuffix}`;
|
|
208
|
-
}
|
|
209
|
-
async isContextUnchanged(sessionId, context) {
|
|
210
|
-
try {
|
|
211
|
-
const lastCheckpointData = await this.getLastCheckpointData(sessionId);
|
|
212
|
-
if (!lastCheckpointData.contextHash) {
|
|
213
|
-
return false;
|
|
214
|
-
}
|
|
215
|
-
const currentHash = this.hashContext(context);
|
|
216
|
-
return currentHash === lastCheckpointData.contextHash;
|
|
217
|
-
}
|
|
218
|
-
catch (error) {
|
|
219
|
-
console.warn(`Failed to check context changes: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
async getLastCheckpointId(sessionId) {
|
|
224
|
-
const lastCheckpointData = await this.getLastCheckpointData(sessionId);
|
|
225
|
-
return lastCheckpointData.id || null;
|
|
226
|
-
}
|
|
227
|
-
countLayers(classified, layerType) {
|
|
228
|
-
if (!classified || typeof classified !== 'object') {
|
|
229
|
-
return 0;
|
|
230
|
-
}
|
|
231
|
-
const layer = classified[layerType];
|
|
232
|
-
if (!layer || typeof layer !== 'object') {
|
|
233
|
-
return 0;
|
|
234
|
-
}
|
|
235
|
-
return Object.keys(layer).length;
|
|
236
|
-
}
|
|
237
|
-
async upsertSessionInfo(sessionId) {
|
|
238
|
-
try {
|
|
239
|
-
const sessionInfo = {
|
|
240
|
-
id: sessionId,
|
|
241
|
-
createdAt: new Date().toISOString(),
|
|
242
|
-
lastAccessedAt: new Date().toISOString(),
|
|
243
|
-
totalSizeBytes: 0
|
|
244
|
-
};
|
|
245
|
-
await this.storage.upsertSession(sessionInfo);
|
|
246
|
-
}
|
|
247
|
-
catch (error) {
|
|
248
|
-
console.warn(`Failed to update session info: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
updateSaveMetrics(operationTime) {
|
|
252
|
-
this.metrics.totalSaveOperations++;
|
|
253
|
-
this.metrics.averageSaveTime = this.calculateMovingAverage(this.metrics.averageSaveTime, operationTime, this.metrics.totalSaveOperations);
|
|
254
|
-
this.metrics.lastOperationTime = operationTime;
|
|
255
|
-
}
|
|
256
|
-
updateLoadMetrics(startTime) {
|
|
257
|
-
const endTime = process.hrtime.bigint();
|
|
258
|
-
const operationTime = Number(endTime - startTime) / 1000000;
|
|
259
|
-
this.metrics.totalLoadOperations++;
|
|
260
|
-
this.metrics.averageLoadTime = this.calculateMovingAverage(this.metrics.averageLoadTime, operationTime, this.metrics.totalLoadOperations);
|
|
261
|
-
this.metrics.lastOperationTime = operationTime;
|
|
262
|
-
}
|
|
263
|
-
updateListMetrics(startTime) {
|
|
264
|
-
const endTime = process.hrtime.bigint();
|
|
265
|
-
const operationTime = Number(endTime - startTime) / 1000000;
|
|
266
|
-
this.metrics.totalListOperations++;
|
|
267
|
-
this.metrics.lastOperationTime = operationTime;
|
|
268
|
-
}
|
|
269
|
-
updateMarkCriticalMetrics(startTime) {
|
|
270
|
-
const endTime = process.hrtime.bigint();
|
|
271
|
-
const operationTime = Number(endTime - startTime) / 1000000;
|
|
272
|
-
this.metrics.totalMarkCriticalOperations++;
|
|
273
|
-
this.metrics.lastOperationTime = operationTime;
|
|
274
|
-
}
|
|
275
|
-
calculateMovingAverage(currentAverage, newValue, count) {
|
|
276
|
-
return ((currentAverage * (count - 1)) + newValue) / count;
|
|
277
|
-
}
|
|
278
|
-
hashContext(context) {
|
|
279
|
-
const contextString = JSON.stringify(context, Object.keys(context).sort());
|
|
280
|
-
return crypto.createHash('sha256').update(contextString).digest('hex');
|
|
281
|
-
}
|
|
282
|
-
async getLastCheckpointData(sessionId) {
|
|
283
|
-
try {
|
|
284
|
-
const checkpoints = await this.storage.listCheckpoints(sessionId, 1, 0);
|
|
285
|
-
if (!checkpoints || checkpoints.length === 0) {
|
|
286
|
-
return { id: undefined, contextSizeBytes: undefined, contextHash: undefined };
|
|
287
|
-
}
|
|
288
|
-
const checkpoint = checkpoints[0];
|
|
289
|
-
return {
|
|
290
|
-
id: checkpoint.id,
|
|
291
|
-
contextSizeBytes: checkpoint.contextSizeBytes,
|
|
292
|
-
contextHash: checkpoint.contextHash
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
catch (error) {
|
|
296
|
-
console.warn(`Failed to get last checkpoint data for session ${sessionId}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
297
|
-
return { id: undefined, contextSizeBytes: undefined, contextHash: undefined };
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
exports.ContextManagementService = ContextManagementService;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { EnhancedContext } from '../../types/workflow-types';
|
|
2
|
-
type ConditionContext = Record<string, any>;
|
|
3
|
-
export declare class ContextOptimizer {
|
|
4
|
-
static createEnhancedContext(base: ConditionContext, enhancements: Partial<EnhancedContext>): EnhancedContext;
|
|
5
|
-
static mergeLoopState(context: EnhancedContext, loopId: string, loopState: any): EnhancedContext;
|
|
6
|
-
static addWarnings(context: EnhancedContext, category: string, key: string, warnings: string[]): EnhancedContext;
|
|
7
|
-
static hasProperty(context: ConditionContext, property: string): boolean;
|
|
8
|
-
static getProperty(context: ConditionContext, property: string): any;
|
|
9
|
-
static getOwnPropertiesSize(context: ConditionContext): number;
|
|
10
|
-
}
|
|
11
|
-
export {};
|