@weavelogic/knowledge-graph-agent 0.2.0 → 0.4.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 +972 -303
- package/dist/_virtual/_commonjsHelpers.js +7 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/additionalItems.js +5 -0
- package/dist/_virtual/additionalItems.js.map +1 -0
- package/dist/_virtual/additionalProperties.js +5 -0
- package/dist/_virtual/additionalProperties.js.map +1 -0
- package/dist/_virtual/ajv.js +6 -0
- package/dist/_virtual/ajv.js.map +1 -0
- package/dist/_virtual/ajv2.js +5 -0
- package/dist/_virtual/ajv2.js.map +1 -0
- package/dist/_virtual/allOf.js +5 -0
- package/dist/_virtual/allOf.js.map +1 -0
- package/dist/_virtual/anyOf.js +5 -0
- package/dist/_virtual/anyOf.js.map +1 -0
- package/dist/_virtual/applicability.js +5 -0
- package/dist/_virtual/applicability.js.map +1 -0
- package/dist/_virtual/boolSchema.js +5 -0
- package/dist/_virtual/boolSchema.js.map +1 -0
- package/dist/_virtual/code.js +5 -0
- package/dist/_virtual/code.js.map +1 -0
- package/dist/_virtual/code2.js +5 -0
- package/dist/_virtual/code2.js.map +1 -0
- package/dist/_virtual/const.js +5 -0
- package/dist/_virtual/const.js.map +1 -0
- package/dist/_virtual/contains.js +5 -0
- package/dist/_virtual/contains.js.map +1 -0
- package/dist/_virtual/core.js +5 -0
- package/dist/_virtual/core.js.map +1 -0
- package/dist/_virtual/dataType.js +5 -0
- package/dist/_virtual/dataType.js.map +1 -0
- package/dist/_virtual/defaults.js +5 -0
- package/dist/_virtual/defaults.js.map +1 -0
- package/dist/_virtual/dependencies.js +5 -0
- package/dist/_virtual/dependencies.js.map +1 -0
- package/dist/_virtual/draft7.js +5 -0
- package/dist/_virtual/draft7.js.map +1 -0
- package/dist/_virtual/enum.js +5 -0
- package/dist/_virtual/enum.js.map +1 -0
- package/dist/_virtual/equal.js +5 -0
- package/dist/_virtual/equal.js.map +1 -0
- package/dist/_virtual/errors.js +5 -0
- package/dist/_virtual/errors.js.map +1 -0
- package/dist/_virtual/format.js +5 -0
- package/dist/_virtual/format.js.map +1 -0
- package/dist/_virtual/formats.js +5 -0
- package/dist/_virtual/formats.js.map +1 -0
- package/dist/_virtual/id.js +5 -0
- package/dist/_virtual/id.js.map +1 -0
- package/dist/_virtual/if.js +5 -0
- package/dist/_virtual/if.js.map +1 -0
- package/dist/_virtual/index.js +8 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/index10.js +5 -0
- package/dist/_virtual/index10.js.map +1 -0
- package/dist/_virtual/index11.js +5 -0
- package/dist/_virtual/index11.js.map +1 -0
- package/dist/_virtual/index12.js +5 -0
- package/dist/_virtual/index12.js.map +1 -0
- package/dist/_virtual/index2.js +5 -0
- package/dist/_virtual/index2.js.map +1 -0
- package/dist/_virtual/index3.js +5 -0
- package/dist/_virtual/index3.js.map +1 -0
- package/dist/_virtual/index4.js +5 -0
- package/dist/_virtual/index4.js.map +1 -0
- package/dist/_virtual/index5.js +5 -0
- package/dist/_virtual/index5.js.map +1 -0
- package/dist/_virtual/index6.js +5 -0
- package/dist/_virtual/index6.js.map +1 -0
- package/dist/_virtual/index7.js +5 -0
- package/dist/_virtual/index7.js.map +1 -0
- package/dist/_virtual/index8.js +5 -0
- package/dist/_virtual/index8.js.map +1 -0
- package/dist/_virtual/index9.js +5 -0
- package/dist/_virtual/index9.js.map +1 -0
- package/dist/_virtual/items.js +5 -0
- package/dist/_virtual/items.js.map +1 -0
- package/dist/_virtual/items2020.js +5 -0
- package/dist/_virtual/items2020.js.map +1 -0
- package/dist/_virtual/keyword.js +5 -0
- package/dist/_virtual/keyword.js.map +1 -0
- package/dist/_virtual/limit.js +5 -0
- package/dist/_virtual/limit.js.map +1 -0
- package/dist/_virtual/limitItems.js +5 -0
- package/dist/_virtual/limitItems.js.map +1 -0
- package/dist/_virtual/limitLength.js +5 -0
- package/dist/_virtual/limitLength.js.map +1 -0
- package/dist/_virtual/limitNumber.js +5 -0
- package/dist/_virtual/limitNumber.js.map +1 -0
- package/dist/_virtual/limitProperties.js +5 -0
- package/dist/_virtual/limitProperties.js.map +1 -0
- package/dist/_virtual/metadata.js +5 -0
- package/dist/_virtual/metadata.js.map +1 -0
- package/dist/_virtual/multipleOf.js +5 -0
- package/dist/_virtual/multipleOf.js.map +1 -0
- package/dist/_virtual/names.js +5 -0
- package/dist/_virtual/names.js.map +1 -0
- package/dist/_virtual/not.js +5 -0
- package/dist/_virtual/not.js.map +1 -0
- package/dist/_virtual/oneOf.js +5 -0
- package/dist/_virtual/oneOf.js.map +1 -0
- package/dist/_virtual/pattern.js +5 -0
- package/dist/_virtual/pattern.js.map +1 -0
- package/dist/_virtual/patternProperties.js +5 -0
- package/dist/_virtual/patternProperties.js.map +1 -0
- package/dist/_virtual/prefixItems.js +5 -0
- package/dist/_virtual/prefixItems.js.map +1 -0
- package/dist/_virtual/properties.js +5 -0
- package/dist/_virtual/properties.js.map +1 -0
- package/dist/_virtual/propertyNames.js +5 -0
- package/dist/_virtual/propertyNames.js.map +1 -0
- package/dist/_virtual/ref.js +5 -0
- package/dist/_virtual/ref.js.map +1 -0
- package/dist/_virtual/ref_error.js +5 -0
- package/dist/_virtual/ref_error.js.map +1 -0
- package/dist/_virtual/required.js +5 -0
- package/dist/_virtual/required.js.map +1 -0
- package/dist/_virtual/resolve.js +5 -0
- package/dist/_virtual/resolve.js.map +1 -0
- package/dist/_virtual/rules.js +5 -0
- package/dist/_virtual/rules.js.map +1 -0
- package/dist/_virtual/scope.js +5 -0
- package/dist/_virtual/scope.js.map +1 -0
- package/dist/_virtual/subschema.js +5 -0
- package/dist/_virtual/subschema.js.map +1 -0
- package/dist/_virtual/thenElse.js +5 -0
- package/dist/_virtual/thenElse.js.map +1 -0
- package/dist/_virtual/types.js +5 -0
- package/dist/_virtual/types.js.map +1 -0
- package/dist/_virtual/ucs2length.js +5 -0
- package/dist/_virtual/ucs2length.js.map +1 -0
- package/dist/_virtual/uniqueItems.js +5 -0
- package/dist/_virtual/uniqueItems.js.map +1 -0
- package/dist/_virtual/uri.js +5 -0
- package/dist/_virtual/uri.js.map +1 -0
- package/dist/_virtual/util.js +5 -0
- package/dist/_virtual/util.js.map +1 -0
- package/dist/_virtual/validation_error.js +5 -0
- package/dist/_virtual/validation_error.js.map +1 -0
- package/dist/agents/analyst-agent.d.ts +230 -0
- package/dist/agents/analyst-agent.d.ts.map +1 -0
- package/dist/agents/analyst-agent.js +793 -0
- package/dist/agents/analyst-agent.js.map +1 -0
- package/dist/agents/architect-agent.d.ts +248 -0
- package/dist/agents/architect-agent.d.ts.map +1 -0
- package/dist/agents/architect-agent.js +685 -0
- package/dist/agents/architect-agent.js.map +1 -0
- package/dist/agents/base-agent.d.ts +169 -0
- package/dist/agents/base-agent.d.ts.map +1 -0
- package/dist/agents/base-agent.js +441 -0
- package/dist/agents/base-agent.js.map +1 -0
- package/dist/agents/coder-agent.d.ts +191 -0
- package/dist/agents/coder-agent.d.ts.map +1 -0
- package/dist/agents/coder-agent.js +1008 -0
- package/dist/agents/coder-agent.js.map +1 -0
- package/dist/agents/index.d.ts +18 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +40 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/registry.d.ts +213 -0
- package/dist/agents/registry.d.ts.map +1 -0
- package/dist/agents/registry.js +419 -0
- package/dist/agents/registry.js.map +1 -0
- package/dist/agents/researcher-agent.d.ts +226 -0
- package/dist/agents/researcher-agent.d.ts.map +1 -0
- package/dist/agents/researcher-agent.js +572 -0
- package/dist/agents/researcher-agent.js.map +1 -0
- package/dist/agents/rules-engine.d.ts +320 -0
- package/dist/agents/rules-engine.d.ts.map +1 -0
- package/dist/agents/rules-engine.js +552 -0
- package/dist/agents/rules-engine.js.map +1 -0
- package/dist/agents/tester-agent.d.ts +219 -0
- package/dist/agents/tester-agent.d.ts.map +1 -0
- package/dist/agents/tester-agent.js +683 -0
- package/dist/agents/tester-agent.js.map +1 -0
- package/dist/agents/types.d.ts +425 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +57 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/audit/config.d.ts +150 -0
- package/dist/audit/config.d.ts.map +1 -0
- package/dist/audit/config.js +111 -0
- package/dist/audit/config.js.map +1 -0
- package/dist/audit/index.d.ts +38 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/services/audit-chain.d.ts +276 -0
- package/dist/audit/services/audit-chain.d.ts.map +1 -0
- package/dist/audit/services/audit-chain.js +502 -0
- package/dist/audit/services/audit-chain.js.map +1 -0
- package/dist/audit/services/index.d.ts +11 -0
- package/dist/audit/services/index.d.ts.map +1 -0
- package/dist/audit/services/syndication.d.ts +334 -0
- package/dist/audit/services/syndication.d.ts.map +1 -0
- package/dist/audit/services/syndication.js +589 -0
- package/dist/audit/services/syndication.js.map +1 -0
- package/dist/audit/types.d.ts +453 -0
- package/dist/audit/types.d.ts.map +1 -0
- package/dist/caching/index.d.ts +55 -0
- package/dist/caching/index.d.ts.map +1 -0
- package/dist/caching/index.js +206 -0
- package/dist/caching/index.js.map +1 -0
- package/dist/caching/lru-cache.d.ts +254 -0
- package/dist/caching/lru-cache.d.ts.map +1 -0
- package/dist/caching/types.d.ts +95 -0
- package/dist/caching/types.d.ts.map +1 -0
- package/dist/chunking/chunker.d.ts +94 -0
- package/dist/chunking/chunker.d.ts.map +1 -0
- package/dist/chunking/index.d.ts +125 -0
- package/dist/chunking/index.d.ts.map +1 -0
- package/dist/chunking/index.js +283 -0
- package/dist/chunking/index.js.map +1 -0
- package/dist/chunking/types.d.ts +92 -0
- package/dist/chunking/types.d.ts.map +1 -0
- package/dist/cli/commands/audit.d.ts +21 -0
- package/dist/cli/commands/audit.d.ts.map +1 -0
- package/dist/cli/commands/audit.js +621 -0
- package/dist/cli/commands/audit.js.map +1 -0
- package/dist/cli/commands/commit.d.ts +11 -0
- package/dist/cli/commands/commit.d.ts.map +1 -0
- package/dist/cli/commands/commit.js +379 -0
- package/dist/cli/commands/commit.js.map +1 -0
- package/dist/cli/commands/config.d.ts +8 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +107 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/cultivate.d.ts +16 -0
- package/dist/cli/commands/cultivate.d.ts.map +1 -0
- package/dist/cli/commands/cultivate.js +254 -0
- package/dist/cli/commands/cultivate.js.map +1 -0
- package/dist/cli/commands/diagnostics.d.ts +8 -0
- package/dist/cli/commands/diagnostics.d.ts.map +1 -0
- package/dist/cli/commands/diagnostics.js +140 -0
- package/dist/cli/commands/diagnostics.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +13 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/init-primitives.d.ts +19 -0
- package/dist/cli/commands/init-primitives.d.ts.map +1 -0
- package/dist/cli/commands/init-primitives.js +208 -0
- package/dist/cli/commands/init-primitives.js.map +1 -0
- package/dist/cli/commands/sop.d.ts +14 -0
- package/dist/cli/commands/sop.d.ts.map +1 -0
- package/dist/cli/commands/sop.js +598 -0
- package/dist/cli/commands/sop.js.map +1 -0
- package/dist/cli/commands/vector.d.ts +14 -0
- package/dist/cli/commands/vector.d.ts.map +1 -0
- package/dist/cli/commands/vector.js +429 -0
- package/dist/cli/commands/vector.js.map +1 -0
- package/dist/cli/commands/workflow.d.ts +12 -0
- package/dist/cli/commands/workflow.d.ts.map +1 -0
- package/dist/cli/commands/workflow.js +471 -0
- package/dist/cli/commands/workflow.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +66 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +153 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +141 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/manager.d.ts +136 -0
- package/dist/config/manager.d.ts.map +1 -0
- package/dist/config/types.d.ts +127 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/core/cache.d.ts +185 -0
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/cache.js +435 -0
- package/dist/core/cache.js.map +1 -0
- package/dist/cultivation/deep-analyzer.d.ts +129 -0
- package/dist/cultivation/deep-analyzer.d.ts.map +1 -0
- package/dist/cultivation/deep-analyzer.js +322 -0
- package/dist/cultivation/deep-analyzer.js.map +1 -0
- package/dist/cultivation/index.d.ts +13 -0
- package/dist/cultivation/index.d.ts.map +1 -0
- package/dist/cultivation/seed-generator.d.ts +92 -0
- package/dist/cultivation/seed-generator.d.ts.map +1 -0
- package/dist/cultivation/seed-generator.js +1033 -0
- package/dist/cultivation/seed-generator.js.map +1 -0
- package/dist/cultivation/types.d.ts +230 -0
- package/dist/cultivation/types.d.ts.map +1 -0
- package/dist/database/schemas/index.d.ts +85 -0
- package/dist/database/schemas/index.d.ts.map +1 -0
- package/dist/generators/claude-md.d.ts +7 -0
- package/dist/generators/claude-md.d.ts.map +1 -1
- package/dist/generators/claude-md.js.map +1 -1
- package/dist/generators/docs-init.d.ts +6 -0
- package/dist/generators/docs-init.d.ts.map +1 -1
- package/dist/generators/docs-init.js.map +1 -1
- package/dist/health/checks.d.ts +135 -0
- package/dist/health/checks.d.ts.map +1 -0
- package/dist/health/index.d.ts +119 -0
- package/dist/health/index.d.ts.map +1 -0
- package/dist/health/index.js +191 -0
- package/dist/health/index.js.map +1 -0
- package/dist/health/monitor.d.ts +146 -0
- package/dist/health/monitor.d.ts.map +1 -0
- package/dist/health/types.d.ts +135 -0
- package/dist/health/types.d.ts.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +182 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/auto-commit.d.ts +175 -0
- package/dist/integrations/auto-commit.d.ts.map +1 -0
- package/dist/integrations/auto-commit.js +399 -0
- package/dist/integrations/auto-commit.js.map +1 -0
- package/dist/integrations/git.d.ts +299 -0
- package/dist/integrations/git.d.ts.map +1 -0
- package/dist/integrations/git.js +465 -0
- package/dist/integrations/git.js.map +1 -0
- package/dist/mcp-server/bin.d.ts +11 -0
- package/dist/mcp-server/bin.d.ts.map +1 -0
- package/dist/mcp-server/handlers/index.d.ts +57 -0
- package/dist/mcp-server/handlers/index.d.ts.map +1 -0
- package/dist/mcp-server/handlers/index.js +235 -0
- package/dist/mcp-server/handlers/index.js.map +1 -0
- package/dist/mcp-server/index.d.ts +28 -0
- package/dist/mcp-server/index.d.ts.map +1 -0
- package/dist/mcp-server/server.d.ts +133 -0
- package/dist/mcp-server/server.d.ts.map +1 -0
- package/dist/mcp-server/server.js +280 -0
- package/dist/mcp-server/server.js.map +1 -0
- package/dist/mcp-server/tools/agents/index.d.ts +10 -0
- package/dist/mcp-server/tools/agents/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/agents/list.d.ts +19 -0
- package/dist/mcp-server/tools/agents/list.d.ts.map +1 -0
- package/dist/mcp-server/tools/agents/spawn.d.ts +19 -0
- package/dist/mcp-server/tools/agents/spawn.d.ts.map +1 -0
- package/dist/mcp-server/tools/audit/checkpoint.d.ts +58 -0
- package/dist/mcp-server/tools/audit/checkpoint.d.ts.map +1 -0
- package/dist/mcp-server/tools/audit/checkpoint.js +73 -0
- package/dist/mcp-server/tools/audit/checkpoint.js.map +1 -0
- package/dist/mcp-server/tools/audit/index.d.ts +53 -0
- package/dist/mcp-server/tools/audit/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/audit/index.js +12 -0
- package/dist/mcp-server/tools/audit/index.js.map +1 -0
- package/dist/mcp-server/tools/audit/query.d.ts +58 -0
- package/dist/mcp-server/tools/audit/query.d.ts.map +1 -0
- package/dist/mcp-server/tools/audit/query.js +125 -0
- package/dist/mcp-server/tools/audit/query.js.map +1 -0
- package/dist/mcp-server/tools/audit/sync.d.ts +58 -0
- package/dist/mcp-server/tools/audit/sync.d.ts.map +1 -0
- package/dist/mcp-server/tools/audit/sync.js +126 -0
- package/dist/mcp-server/tools/audit/sync.js.map +1 -0
- package/dist/mcp-server/tools/graph/generate.d.ts +21 -0
- package/dist/mcp-server/tools/graph/generate.d.ts.map +1 -0
- package/dist/mcp-server/tools/graph/index.d.ts +11 -0
- package/dist/mcp-server/tools/graph/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/graph/query.d.ts +22 -0
- package/dist/mcp-server/tools/graph/query.d.ts.map +1 -0
- package/dist/mcp-server/tools/graph/stats.d.ts +22 -0
- package/dist/mcp-server/tools/graph/stats.d.ts.map +1 -0
- package/dist/mcp-server/tools/health.d.ts +21 -0
- package/dist/mcp-server/tools/health.d.ts.map +1 -0
- package/dist/mcp-server/tools/index.d.ts +16 -0
- package/dist/mcp-server/tools/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/registry.d.ts +90 -0
- package/dist/mcp-server/tools/registry.d.ts.map +1 -0
- package/dist/mcp-server/tools/registry.js +753 -0
- package/dist/mcp-server/tools/registry.js.map +1 -0
- package/dist/mcp-server/tools/search/index.d.ts +10 -0
- package/dist/mcp-server/tools/search/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/search/nodes.d.ts +22 -0
- package/dist/mcp-server/tools/search/nodes.d.ts.map +1 -0
- package/dist/mcp-server/tools/search/tags.d.ts +22 -0
- package/dist/mcp-server/tools/search/tags.d.ts.map +1 -0
- package/dist/mcp-server/tools/vector/index.d.ts +12 -0
- package/dist/mcp-server/tools/vector/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/vector/index.js +12 -0
- package/dist/mcp-server/tools/vector/index.js.map +1 -0
- package/dist/mcp-server/tools/vector/search.d.ts +41 -0
- package/dist/mcp-server/tools/vector/search.d.ts.map +1 -0
- package/dist/mcp-server/tools/vector/search.js +224 -0
- package/dist/mcp-server/tools/vector/search.js.map +1 -0
- package/dist/mcp-server/tools/vector/trajectory.d.ts +39 -0
- package/dist/mcp-server/tools/vector/trajectory.d.ts.map +1 -0
- package/dist/mcp-server/tools/vector/trajectory.js +170 -0
- package/dist/mcp-server/tools/vector/trajectory.js.map +1 -0
- package/dist/mcp-server/tools/vector/upsert.d.ts +44 -0
- package/dist/mcp-server/tools/vector/upsert.d.ts.map +1 -0
- package/dist/mcp-server/tools/vector/upsert.js +175 -0
- package/dist/mcp-server/tools/vector/upsert.js.map +1 -0
- package/dist/mcp-server/tools/workflow/index.d.ts +29 -0
- package/dist/mcp-server/tools/workflow/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/workflow/index.js +12 -0
- package/dist/mcp-server/tools/workflow/index.js.map +1 -0
- package/dist/mcp-server/tools/workflow/list.d.ts +41 -0
- package/dist/mcp-server/tools/workflow/list.d.ts.map +1 -0
- package/dist/mcp-server/tools/workflow/list.js +195 -0
- package/dist/mcp-server/tools/workflow/list.js.map +1 -0
- package/dist/mcp-server/tools/workflow/start.d.ts +40 -0
- package/dist/mcp-server/tools/workflow/start.d.ts.map +1 -0
- package/dist/mcp-server/tools/workflow/start.js +165 -0
- package/dist/mcp-server/tools/workflow/start.js.map +1 -0
- package/dist/mcp-server/tools/workflow/status.d.ts +38 -0
- package/dist/mcp-server/tools/workflow/status.d.ts.map +1 -0
- package/dist/mcp-server/tools/workflow/status.js +97 -0
- package/dist/mcp-server/tools/workflow/status.js.map +1 -0
- package/dist/mcp-server/types/index.d.ts +286 -0
- package/dist/mcp-server/types/index.d.ts.map +1 -0
- package/dist/memory/index.d.ts +10 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/vault-sync.d.ts +212 -0
- package/dist/memory/vault-sync.d.ts.map +1 -0
- package/dist/memory/vault-sync.js +463 -0
- package/dist/memory/vault-sync.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +296 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +71 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +26 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +407 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1332 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +71 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +1 -0
- package/dist/node_modules/ajv/dist/ajv.js +84 -0
- package/dist/node_modules/ajv/dist/ajv.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js +160 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js +728 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js +152 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/errors.js +131 -0
- package/dist/node_modules/ajv/dist/compile/errors.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/index.js +234 -0
- package/dist/node_modules/ajv/dist/compile/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/names.js +44 -0
- package/dist/node_modules/ajv/dist/compile/names.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js +22 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js +163 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/rules.js +35 -0
- package/dist/node_modules/ajv/dist/compile/rules.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/util.js +173 -0
- package/dist/node_modules/ajv/dist/compile/util.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js +27 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js +58 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js +193 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js +43 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js +522 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js +126 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js +89 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
- package/dist/node_modules/ajv/dist/core.js +628 -0
- package/dist/node_modules/ajv/dist/core.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js +24 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +25 -0
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js +16 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js +30 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js +16 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js +20 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +59 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +114 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js +32 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +22 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js +100 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +103 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js +75 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +68 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js +64 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js +43 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js +36 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +64 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +81 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +22 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js +66 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +49 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +23 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js +140 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js +19 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js +27 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js +132 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js +114 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js +18 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js +31 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js +95 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js +16 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js +27 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js +36 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js +56 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +52 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js +34 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js +39 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +37 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +34 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +33 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js +34 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js +89 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +75 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/formats.js +209 -0
- package/dist/node_modules/ajv-formats/dist/formats.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/index.js +51 -0
- package/dist/node_modules/ajv-formats/dist/index.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/limit.js +80 -0
- package/dist/node_modules/ajv-formats/dist/limit.js.map +1 -0
- package/dist/node_modules/fast-deep-equal/index.js +39 -0
- package/dist/node_modules/fast-deep-equal/index.js.map +1 -0
- package/dist/node_modules/fast-uri/index.js +261 -0
- package/dist/node_modules/fast-uri/index.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/schemes.js +215 -0
- package/dist/node_modules/fast-uri/lib/schemes.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/utils.js +261 -0
- package/dist/node_modules/fast-uri/lib/utils.js.map +1 -0
- package/dist/node_modules/json-schema-traverse/index.js +92 -0
- package/dist/node_modules/json-schema-traverse/index.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/errors.js +37 -0
- package/dist/node_modules/zod/v4/classic/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/iso.js +43 -0
- package/dist/node_modules/zod/v4/classic/iso.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/parse.js +13 -0
- package/dist/node_modules/zod/v4/classic/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/schemas.js +688 -0
- package/dist/node_modules/zod/v4/classic/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/api.js +492 -0
- package/dist/node_modules/zod/v4/core/api.js.map +1 -0
- package/dist/node_modules/zod/v4/core/checks.js +405 -0
- package/dist/node_modules/zod/v4/core/checks.js.map +1 -0
- package/dist/node_modules/zod/v4/core/core.js +58 -0
- package/dist/node_modules/zod/v4/core/core.js.map +1 -0
- package/dist/node_modules/zod/v4/core/doc.js +38 -0
- package/dist/node_modules/zod/v4/core/doc.js.map +1 -0
- package/dist/node_modules/zod/v4/core/errors.js +82 -0
- package/dist/node_modules/zod/v4/core/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/core/parse.js +60 -0
- package/dist/node_modules/zod/v4/core/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/core/regexes.js +87 -0
- package/dist/node_modules/zod/v4/core/regexes.js.map +1 -0
- package/dist/node_modules/zod/v4/core/registries.js +52 -0
- package/dist/node_modules/zod/v4/core/registries.js.map +1 -0
- package/dist/node_modules/zod/v4/core/schemas.js +1283 -0
- package/dist/node_modules/zod/v4/core/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/util.js +341 -0
- package/dist/node_modules/zod/v4/core/util.js.map +1 -0
- package/dist/node_modules/zod/v4/core/versions.js +9 -0
- package/dist/node_modules/zod/v4/core/versions.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +2 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
- package/dist/reasoning/index.d.ts +74 -0
- package/dist/reasoning/index.d.ts.map +1 -0
- package/dist/reasoning/index.js +124 -0
- package/dist/reasoning/index.js.map +1 -0
- package/dist/reasoning/tracker.d.ts +210 -0
- package/dist/reasoning/tracker.d.ts.map +1 -0
- package/dist/reasoning/types.d.ts +146 -0
- package/dist/reasoning/types.d.ts.map +1 -0
- package/dist/recovery/backup.d.ts +110 -0
- package/dist/recovery/backup.d.ts.map +1 -0
- package/dist/recovery/index.d.ts +70 -0
- package/dist/recovery/index.d.ts.map +1 -0
- package/dist/recovery/index.js +186 -0
- package/dist/recovery/index.js.map +1 -0
- package/dist/recovery/integrity.d.ts +74 -0
- package/dist/recovery/integrity.d.ts.map +1 -0
- package/dist/recovery/types.d.ts +94 -0
- package/dist/recovery/types.d.ts.map +1 -0
- package/dist/services/index.d.ts +130 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +134 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/manager.d.ts +140 -0
- package/dist/services/manager.d.ts.map +1 -0
- package/dist/services/types.d.ts +106 -0
- package/dist/services/types.d.ts.map +1 -0
- package/dist/services/watchers.d.ts +95 -0
- package/dist/services/watchers.d.ts.map +1 -0
- package/dist/sops/compliance-checker.d.ts +83 -0
- package/dist/sops/compliance-checker.d.ts.map +1 -0
- package/dist/sops/compliance-checker.js +399 -0
- package/dist/sops/compliance-checker.js.map +1 -0
- package/dist/sops/gap-analyzer.d.ts +124 -0
- package/dist/sops/gap-analyzer.d.ts.map +1 -0
- package/dist/sops/gap-analyzer.js +313 -0
- package/dist/sops/gap-analyzer.js.map +1 -0
- package/dist/sops/index.d.ts +14 -0
- package/dist/sops/index.d.ts.map +1 -0
- package/dist/sops/overlay-manager.d.ts +115 -0
- package/dist/sops/overlay-manager.d.ts.map +1 -0
- package/dist/sops/overlay-manager.js +394 -0
- package/dist/sops/overlay-manager.js.map +1 -0
- package/dist/sops/registry.d.ts +73 -0
- package/dist/sops/registry.d.ts.map +1 -0
- package/dist/sops/registry.js +919 -0
- package/dist/sops/registry.js.map +1 -0
- package/dist/sops/types.d.ts +377 -0
- package/dist/sops/types.d.ts.map +1 -0
- package/dist/sops/types.js +46 -0
- package/dist/sops/types.js.map +1 -0
- package/dist/utils/error-recovery.d.ts +230 -0
- package/dist/utils/error-recovery.d.ts.map +1 -0
- package/dist/utils/error-recovery.js +228 -0
- package/dist/utils/error-recovery.js.map +1 -0
- package/dist/utils/error-taxonomy.d.ts +149 -0
- package/dist/utils/error-taxonomy.d.ts.map +1 -0
- package/dist/utils/error-taxonomy.js +260 -0
- package/dist/utils/error-taxonomy.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +139 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +311 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/vector/config.d.ts +300 -0
- package/dist/vector/config.d.ts.map +1 -0
- package/dist/vector/config.js +124 -0
- package/dist/vector/config.js.map +1 -0
- package/dist/vector/index.d.ts +50 -0
- package/dist/vector/index.d.ts.map +1 -0
- package/dist/vector/services/index.d.ts +13 -0
- package/dist/vector/services/index.d.ts.map +1 -0
- package/dist/vector/services/trajectory-tracker.d.ts +405 -0
- package/dist/vector/services/trajectory-tracker.d.ts.map +1 -0
- package/dist/vector/services/trajectory-tracker.js +445 -0
- package/dist/vector/services/trajectory-tracker.js.map +1 -0
- package/dist/vector/services/vector-store.d.ts +339 -0
- package/dist/vector/services/vector-store.d.ts.map +1 -0
- package/dist/vector/services/vector-store.js +748 -0
- package/dist/vector/services/vector-store.js.map +1 -0
- package/dist/vector/types.d.ts +677 -0
- package/dist/vector/types.d.ts.map +1 -0
- package/dist/workflow/adapters/goap-adapter.d.ts +196 -0
- package/dist/workflow/adapters/goap-adapter.d.ts.map +1 -0
- package/dist/workflow/adapters/goap-adapter.js +706 -0
- package/dist/workflow/adapters/goap-adapter.js.map +1 -0
- package/dist/workflow/adapters/index.d.ts +10 -0
- package/dist/workflow/adapters/index.d.ts.map +1 -0
- package/dist/workflow/config.d.ts +135 -0
- package/dist/workflow/config.d.ts.map +1 -0
- package/dist/workflow/config.js +92 -0
- package/dist/workflow/config.js.map +1 -0
- package/dist/workflow/handlers/index.d.ts +9 -0
- package/dist/workflow/handlers/index.d.ts.map +1 -0
- package/dist/workflow/handlers/webhook-handlers.d.ts +397 -0
- package/dist/workflow/handlers/webhook-handlers.d.ts.map +1 -0
- package/dist/workflow/handlers/webhook-handlers.js +454 -0
- package/dist/workflow/handlers/webhook-handlers.js.map +1 -0
- package/dist/workflow/index.d.ts +42 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/services/index.d.ts +9 -0
- package/dist/workflow/services/index.d.ts.map +1 -0
- package/dist/workflow/services/workflow-service.d.ts +318 -0
- package/dist/workflow/services/workflow-service.d.ts.map +1 -0
- package/dist/workflow/services/workflow-service.js +577 -0
- package/dist/workflow/services/workflow-service.js.map +1 -0
- package/dist/workflow/types.d.ts +470 -0
- package/dist/workflow/types.d.ts.map +1 -0
- package/dist/workflow/workflows/realtime-collab.d.ts +245 -0
- package/dist/workflow/workflows/realtime-collab.d.ts.map +1 -0
- package/dist/workflows/index.d.ts +11 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/registry.d.ts +118 -0
- package/dist/workflows/registry.d.ts.map +1 -0
- package/dist/workflows/registry.js +575 -0
- package/dist/workflows/registry.js.map +1 -0
- package/dist/workflows/types.d.ts +322 -0
- package/dist/workflows/types.d.ts.map +1 -0
- package/dist/workflows/types.js +16 -0
- package/dist/workflows/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
class AdvancedCache {
|
|
2
|
+
cache = /* @__PURE__ */ new Map();
|
|
3
|
+
config;
|
|
4
|
+
stats = {
|
|
5
|
+
hits: 0,
|
|
6
|
+
misses: 0,
|
|
7
|
+
hitRate: 0,
|
|
8
|
+
entryCount: 0,
|
|
9
|
+
currentSize: 0,
|
|
10
|
+
evictions: 0
|
|
11
|
+
};
|
|
12
|
+
constructor(config = {}) {
|
|
13
|
+
this.config = {
|
|
14
|
+
maxSize: config.maxSize || 100 * 1024 * 1024,
|
|
15
|
+
maxEntries: config.maxEntries || 1e4,
|
|
16
|
+
defaultTtl: config.defaultTtl || 36e5,
|
|
17
|
+
evictionPolicy: config.evictionPolicy || "lru",
|
|
18
|
+
enableStats: config.enableStats ?? true
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
get(key) {
|
|
22
|
+
const entry = this.cache.get(key);
|
|
23
|
+
if (!entry) {
|
|
24
|
+
if (this.config.enableStats) {
|
|
25
|
+
this.stats.misses++;
|
|
26
|
+
this.updateHitRate();
|
|
27
|
+
}
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
if (entry.ttl && Date.now() - entry.createdAt > entry.ttl) {
|
|
31
|
+
this.delete(key);
|
|
32
|
+
if (this.config.enableStats) {
|
|
33
|
+
this.stats.misses++;
|
|
34
|
+
this.updateHitRate();
|
|
35
|
+
}
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
entry.accessedAt = Date.now();
|
|
39
|
+
entry.accessCount++;
|
|
40
|
+
if (this.config.enableStats) {
|
|
41
|
+
this.stats.hits++;
|
|
42
|
+
this.updateHitRate();
|
|
43
|
+
}
|
|
44
|
+
return entry.value;
|
|
45
|
+
}
|
|
46
|
+
set(key, value, ttl) {
|
|
47
|
+
const size = this.estimateSize(value);
|
|
48
|
+
while (this.shouldEvict(size)) {
|
|
49
|
+
this.evictOne();
|
|
50
|
+
}
|
|
51
|
+
const entry = {
|
|
52
|
+
key,
|
|
53
|
+
value,
|
|
54
|
+
createdAt: Date.now(),
|
|
55
|
+
accessedAt: Date.now(),
|
|
56
|
+
accessCount: 1,
|
|
57
|
+
ttl: ttl || this.config.defaultTtl,
|
|
58
|
+
size
|
|
59
|
+
};
|
|
60
|
+
const existing = this.cache.get(key);
|
|
61
|
+
if (existing) {
|
|
62
|
+
this.stats.currentSize -= existing.size;
|
|
63
|
+
}
|
|
64
|
+
this.stats.currentSize += size;
|
|
65
|
+
this.cache.set(key, entry);
|
|
66
|
+
this.stats.entryCount = this.cache.size;
|
|
67
|
+
}
|
|
68
|
+
delete(key) {
|
|
69
|
+
const entry = this.cache.get(key);
|
|
70
|
+
if (entry) {
|
|
71
|
+
this.stats.currentSize -= entry.size;
|
|
72
|
+
this.cache.delete(key);
|
|
73
|
+
this.stats.entryCount = this.cache.size;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
has(key) {
|
|
79
|
+
const entry = this.cache.get(key);
|
|
80
|
+
if (!entry) return false;
|
|
81
|
+
if (entry.ttl && Date.now() - entry.createdAt > entry.ttl) {
|
|
82
|
+
this.delete(key);
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
clear() {
|
|
88
|
+
this.cache.clear();
|
|
89
|
+
this.stats.currentSize = 0;
|
|
90
|
+
this.stats.entryCount = 0;
|
|
91
|
+
}
|
|
92
|
+
getStats() {
|
|
93
|
+
return { ...this.stats };
|
|
94
|
+
}
|
|
95
|
+
keys() {
|
|
96
|
+
return Array.from(this.cache.keys());
|
|
97
|
+
}
|
|
98
|
+
size() {
|
|
99
|
+
return this.cache.size;
|
|
100
|
+
}
|
|
101
|
+
prune() {
|
|
102
|
+
let pruned = 0;
|
|
103
|
+
const now = Date.now();
|
|
104
|
+
for (const [key, entry] of this.cache) {
|
|
105
|
+
if (entry.ttl && now - entry.createdAt > entry.ttl) {
|
|
106
|
+
this.delete(key);
|
|
107
|
+
pruned++;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return pruned;
|
|
111
|
+
}
|
|
112
|
+
shouldEvict(newSize) {
|
|
113
|
+
if (this.cache.size >= this.config.maxEntries) return true;
|
|
114
|
+
if (this.stats.currentSize + newSize > this.config.maxSize) return true;
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
evictOne() {
|
|
118
|
+
if (this.cache.size === 0) return;
|
|
119
|
+
let keyToEvict = null;
|
|
120
|
+
switch (this.config.evictionPolicy) {
|
|
121
|
+
case "lru":
|
|
122
|
+
keyToEvict = this.findLRU();
|
|
123
|
+
break;
|
|
124
|
+
case "lfu":
|
|
125
|
+
keyToEvict = this.findLFU();
|
|
126
|
+
break;
|
|
127
|
+
case "fifo":
|
|
128
|
+
keyToEvict = this.findFIFO();
|
|
129
|
+
break;
|
|
130
|
+
case "ttl":
|
|
131
|
+
keyToEvict = this.findOldestTTL();
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
if (keyToEvict) {
|
|
135
|
+
this.delete(keyToEvict);
|
|
136
|
+
this.stats.evictions++;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
findLRU() {
|
|
140
|
+
let oldest = null;
|
|
141
|
+
let oldestKey = null;
|
|
142
|
+
for (const [key, entry] of this.cache) {
|
|
143
|
+
if (!oldest || entry.accessedAt < oldest.accessedAt) {
|
|
144
|
+
oldest = entry;
|
|
145
|
+
oldestKey = key;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return oldestKey;
|
|
149
|
+
}
|
|
150
|
+
findLFU() {
|
|
151
|
+
let least = null;
|
|
152
|
+
let leastKey = null;
|
|
153
|
+
for (const [key, entry] of this.cache) {
|
|
154
|
+
if (!least || entry.accessCount < least.accessCount) {
|
|
155
|
+
least = entry;
|
|
156
|
+
leastKey = key;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return leastKey;
|
|
160
|
+
}
|
|
161
|
+
findFIFO() {
|
|
162
|
+
let oldest = null;
|
|
163
|
+
let oldestKey = null;
|
|
164
|
+
for (const [key, entry] of this.cache) {
|
|
165
|
+
if (!oldest || entry.createdAt < oldest.createdAt) {
|
|
166
|
+
oldest = entry;
|
|
167
|
+
oldestKey = key;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return oldestKey;
|
|
171
|
+
}
|
|
172
|
+
findOldestTTL() {
|
|
173
|
+
let closestKey = null;
|
|
174
|
+
let closestExpiry = Infinity;
|
|
175
|
+
const now = Date.now();
|
|
176
|
+
for (const [key, entry] of this.cache) {
|
|
177
|
+
if (entry.ttl) {
|
|
178
|
+
const expiry = entry.createdAt + entry.ttl - now;
|
|
179
|
+
if (expiry < closestExpiry) {
|
|
180
|
+
closestKey = key;
|
|
181
|
+
closestExpiry = expiry;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return closestKey || this.findLRU();
|
|
186
|
+
}
|
|
187
|
+
estimateSize(value) {
|
|
188
|
+
try {
|
|
189
|
+
return JSON.stringify(value).length * 2;
|
|
190
|
+
} catch {
|
|
191
|
+
return 1024;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
updateHitRate() {
|
|
195
|
+
const total = this.stats.hits + this.stats.misses;
|
|
196
|
+
this.stats.hitRate = total > 0 ? this.stats.hits / total : 0;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function createAdvancedCache(config) {
|
|
200
|
+
return new AdvancedCache(config);
|
|
201
|
+
}
|
|
202
|
+
export {
|
|
203
|
+
AdvancedCache,
|
|
204
|
+
createAdvancedCache
|
|
205
|
+
};
|
|
206
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/caching/index.ts"],"sourcesContent":["/**\n * Advanced Caching Module\n *\n * Provides configurable caching with multiple eviction policies.\n */\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type EvictionPolicy = 'lru' | 'lfu' | 'fifo' | 'ttl';\n\nexport interface CacheEntry<T> {\n key: string;\n value: T;\n createdAt: number;\n accessedAt: number;\n accessCount: number;\n ttl?: number;\n size: number;\n}\n\nexport interface CacheConfig {\n maxSize?: number;\n maxEntries?: number;\n defaultTtl?: number;\n evictionPolicy?: EvictionPolicy;\n enableStats?: boolean;\n}\n\nexport interface CacheStats {\n hits: number;\n misses: number;\n hitRate: number;\n entryCount: number;\n currentSize: number;\n evictions: number;\n}\n\n// ============================================================================\n// Advanced Cache Implementation\n// ============================================================================\n\nexport class AdvancedCache<T = unknown> {\n private cache: Map<string, CacheEntry<T>> = new Map();\n private config: Required<CacheConfig>;\n private stats: CacheStats = {\n hits: 0,\n misses: 0,\n hitRate: 0,\n entryCount: 0,\n currentSize: 0,\n evictions: 0,\n };\n\n constructor(config: CacheConfig = {}) {\n this.config = {\n maxSize: config.maxSize || 100 * 1024 * 1024,\n maxEntries: config.maxEntries || 10000,\n defaultTtl: config.defaultTtl || 3600000,\n evictionPolicy: config.evictionPolicy || 'lru',\n enableStats: config.enableStats ?? true,\n };\n }\n\n get(key: string): T | undefined {\n const entry = this.cache.get(key);\n if (!entry) {\n if (this.config.enableStats) {\n this.stats.misses++;\n this.updateHitRate();\n }\n return undefined;\n }\n\n if (entry.ttl && Date.now() - entry.createdAt > entry.ttl) {\n this.delete(key);\n if (this.config.enableStats) {\n this.stats.misses++;\n this.updateHitRate();\n }\n return undefined;\n }\n\n entry.accessedAt = Date.now();\n entry.accessCount++;\n\n if (this.config.enableStats) {\n this.stats.hits++;\n this.updateHitRate();\n }\n\n return entry.value;\n }\n\n set(key: string, value: T, ttl?: number): void {\n const size = this.estimateSize(value);\n\n while (this.shouldEvict(size)) {\n this.evictOne();\n }\n\n const entry: CacheEntry<T> = {\n key,\n value,\n createdAt: Date.now(),\n accessedAt: Date.now(),\n accessCount: 1,\n ttl: ttl || this.config.defaultTtl,\n size,\n };\n\n const existing = this.cache.get(key);\n if (existing) {\n this.stats.currentSize -= existing.size;\n }\n this.stats.currentSize += size;\n\n this.cache.set(key, entry);\n this.stats.entryCount = this.cache.size;\n }\n\n delete(key: string): boolean {\n const entry = this.cache.get(key);\n if (entry) {\n this.stats.currentSize -= entry.size;\n this.cache.delete(key);\n this.stats.entryCount = this.cache.size;\n return true;\n }\n return false;\n }\n\n has(key: string): boolean {\n const entry = this.cache.get(key);\n if (!entry) return false;\n if (entry.ttl && Date.now() - entry.createdAt > entry.ttl) {\n this.delete(key);\n return false;\n }\n return true;\n }\n\n clear(): void {\n this.cache.clear();\n this.stats.currentSize = 0;\n this.stats.entryCount = 0;\n }\n\n getStats(): CacheStats {\n return { ...this.stats };\n }\n\n keys(): string[] {\n return Array.from(this.cache.keys());\n }\n\n size(): number {\n return this.cache.size;\n }\n\n prune(): number {\n let pruned = 0;\n const now = Date.now();\n\n for (const [key, entry] of this.cache) {\n if (entry.ttl && now - entry.createdAt > entry.ttl) {\n this.delete(key);\n pruned++;\n }\n }\n\n return pruned;\n }\n\n private shouldEvict(newSize: number): boolean {\n if (this.cache.size >= this.config.maxEntries) return true;\n if (this.stats.currentSize + newSize > this.config.maxSize) return true;\n return false;\n }\n\n private evictOne(): void {\n if (this.cache.size === 0) return;\n\n let keyToEvict: string | null = null;\n\n switch (this.config.evictionPolicy) {\n case 'lru':\n keyToEvict = this.findLRU();\n break;\n case 'lfu':\n keyToEvict = this.findLFU();\n break;\n case 'fifo':\n keyToEvict = this.findFIFO();\n break;\n case 'ttl':\n keyToEvict = this.findOldestTTL();\n break;\n }\n\n if (keyToEvict) {\n this.delete(keyToEvict);\n this.stats.evictions++;\n }\n }\n\n private findLRU(): string | null {\n let oldest: CacheEntry<T> | null = null;\n let oldestKey: string | null = null;\n\n for (const [key, entry] of this.cache) {\n if (!oldest || entry.accessedAt < oldest.accessedAt) {\n oldest = entry;\n oldestKey = key;\n }\n }\n return oldestKey;\n }\n\n private findLFU(): string | null {\n let least: CacheEntry<T> | null = null;\n let leastKey: string | null = null;\n\n for (const [key, entry] of this.cache) {\n if (!least || entry.accessCount < least.accessCount) {\n least = entry;\n leastKey = key;\n }\n }\n return leastKey;\n }\n\n private findFIFO(): string | null {\n let oldest: CacheEntry<T> | null = null;\n let oldestKey: string | null = null;\n\n for (const [key, entry] of this.cache) {\n if (!oldest || entry.createdAt < oldest.createdAt) {\n oldest = entry;\n oldestKey = key;\n }\n }\n return oldestKey;\n }\n\n private findOldestTTL(): string | null {\n let closest: CacheEntry<T> | null = null;\n let closestKey: string | null = null;\n let closestExpiry = Infinity;\n const now = Date.now();\n\n for (const [key, entry] of this.cache) {\n if (entry.ttl) {\n const expiry = entry.createdAt + entry.ttl - now;\n if (expiry < closestExpiry) {\n closest = entry;\n closestKey = key;\n closestExpiry = expiry;\n }\n }\n }\n return closestKey || this.findLRU();\n }\n\n private estimateSize(value: T): number {\n try {\n return JSON.stringify(value).length * 2;\n } catch {\n return 1024;\n }\n }\n\n private updateHitRate(): void {\n const total = this.stats.hits + this.stats.misses;\n this.stats.hitRate = total > 0 ? this.stats.hits / total : 0;\n }\n}\n\nexport function createAdvancedCache<T = unknown>(config?: CacheConfig): AdvancedCache<T> {\n return new AdvancedCache<T>(config);\n}\n"],"names":[],"mappings":"AA2CO,MAAM,cAA2B;AAAA,EAC9B,4BAAwC,IAAA;AAAA,EACxC;AAAA,EACA,QAAoB;AAAA,IAC1B,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AA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K,KAAK,KAAK,KAAK,OAAO;AACrC,UAAI,MAAM,KAAK;AACb,cAAM,SAAS,MAAM,YAAY,MAAM,MAAM;AAC7C,YAAI,SAAS,eAAe;AAE1B,uBAAa;AACb,0BAAgB;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AACA,WAAO,cAAc,KAAK,QAAA;AAAA,EAC5B;AAAA,EAEQ,aAAa,OAAkB;AACrC,QAAI;AACF,aAAO,KAAK,UAAU,KAAK,EAAE,SAAS;AAAA,IACxC,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEQ,gBAAsB;AAC5B,UAAM,QAAQ,KAAK,MAAM,OAAO,KAAK,MAAM;AAC3C,SAAK,MAAM,UAAU,QAAQ,IAAI,KAAK,MAAM,OAAO,QAAQ;AAAA,EAC7D;AACF;AAEO,SAAS,oBAAiC,QAAwC;AACvF,SAAO,IAAI,cAAiB,MAAM;AACpC;"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRU Cache Implementation
|
|
3
|
+
*
|
|
4
|
+
* Advanced cache implementation supporting multiple eviction policies,
|
|
5
|
+
* TTL management, tag-based operations, and comprehensive statistics.
|
|
6
|
+
*
|
|
7
|
+
* @module caching/lru-cache
|
|
8
|
+
*/
|
|
9
|
+
import { EventEmitter } from 'events';
|
|
10
|
+
import type { CacheConfig, CacheStats, EvictionPolicy, CacheSetOptions } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Cache event types emitted by AdvancedCache
|
|
13
|
+
*/
|
|
14
|
+
export interface CacheEvents<T> {
|
|
15
|
+
set: (key: string, value: T) => void;
|
|
16
|
+
get: (key: string, value: T | undefined) => void;
|
|
17
|
+
delete: (key: string) => void;
|
|
18
|
+
evict: (key: string) => void;
|
|
19
|
+
clear: () => void;
|
|
20
|
+
expire: (key: string) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Advanced Cache with multiple eviction policies
|
|
24
|
+
*
|
|
25
|
+
* Features:
|
|
26
|
+
* - LRU, LFU, FIFO, and TTL-based eviction policies
|
|
27
|
+
* - Tag-based grouping and batch operations
|
|
28
|
+
* - Automatic TTL expiration with periodic cleanup
|
|
29
|
+
* - Comprehensive statistics and monitoring
|
|
30
|
+
* - Event emission for cache operations
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const cache = new AdvancedCache<User>({
|
|
35
|
+
* maxSize: 50 * 1024 * 1024, // 50MB
|
|
36
|
+
* maxEntries: 1000,
|
|
37
|
+
* defaultTTL: 300000, // 5 minutes
|
|
38
|
+
* evictionPolicy: 'lru',
|
|
39
|
+
* onEvict: (key, value) => console.log(`Evicted: ${key}`)
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* cache.set('user:123', userData, { tags: ['user', 'active'] });
|
|
43
|
+
* const user = cache.get<User>('user:123');
|
|
44
|
+
*
|
|
45
|
+
* // Delete all entries with 'user' tag
|
|
46
|
+
* cache.deleteByTag('user');
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class AdvancedCache<T = any> extends EventEmitter {
|
|
50
|
+
private cache;
|
|
51
|
+
private config;
|
|
52
|
+
private stats;
|
|
53
|
+
private cleanupTimer?;
|
|
54
|
+
/**
|
|
55
|
+
* Create a new AdvancedCache instance
|
|
56
|
+
*
|
|
57
|
+
* @param config - Partial cache configuration (defaults will be applied)
|
|
58
|
+
*/
|
|
59
|
+
constructor(config?: Partial<CacheConfig>);
|
|
60
|
+
/**
|
|
61
|
+
* Get a value from the cache
|
|
62
|
+
*
|
|
63
|
+
* @param key - The cache key to retrieve
|
|
64
|
+
* @returns The cached value or undefined if not found/expired
|
|
65
|
+
*/
|
|
66
|
+
get<V extends T>(key: string): V | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Set a value in the cache
|
|
69
|
+
*
|
|
70
|
+
* @param key - The cache key
|
|
71
|
+
* @param value - The value to cache
|
|
72
|
+
* @param options - Optional settings for TTL and tags
|
|
73
|
+
*/
|
|
74
|
+
set(key: string, value: T, options?: CacheSetOptions): void;
|
|
75
|
+
/**
|
|
76
|
+
* Check if a key exists in the cache and is not expired
|
|
77
|
+
*
|
|
78
|
+
* @param key - The cache key to check
|
|
79
|
+
* @returns True if key exists and is not expired
|
|
80
|
+
*/
|
|
81
|
+
has(key: string): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Delete an entry from the cache
|
|
84
|
+
*
|
|
85
|
+
* @param key - The cache key to delete
|
|
86
|
+
* @returns True if the entry was deleted
|
|
87
|
+
*/
|
|
88
|
+
delete(key: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Clear all entries from the cache
|
|
91
|
+
*/
|
|
92
|
+
clear(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Get all entries with a specific tag
|
|
95
|
+
*
|
|
96
|
+
* @param tag - The tag to filter by
|
|
97
|
+
* @returns Array of values with the specified tag
|
|
98
|
+
*/
|
|
99
|
+
getByTag(tag: string): T[];
|
|
100
|
+
/**
|
|
101
|
+
* Get all keys with a specific tag
|
|
102
|
+
*
|
|
103
|
+
* @param tag - The tag to filter by
|
|
104
|
+
* @returns Array of keys with the specified tag
|
|
105
|
+
*/
|
|
106
|
+
getKeysByTag(tag: string): string[];
|
|
107
|
+
/**
|
|
108
|
+
* Delete all entries with a specific tag
|
|
109
|
+
*
|
|
110
|
+
* @param tag - The tag to filter by
|
|
111
|
+
* @returns Number of entries deleted
|
|
112
|
+
*/
|
|
113
|
+
deleteByTag(tag: string): number;
|
|
114
|
+
/**
|
|
115
|
+
* Get all unique tags in the cache
|
|
116
|
+
*
|
|
117
|
+
* @returns Set of all tags
|
|
118
|
+
*/
|
|
119
|
+
getTags(): Set<string>;
|
|
120
|
+
/**
|
|
121
|
+
* Get cache statistics
|
|
122
|
+
*
|
|
123
|
+
* @returns Current cache statistics
|
|
124
|
+
*/
|
|
125
|
+
getStats(): CacheStats;
|
|
126
|
+
/**
|
|
127
|
+
* Reset statistics counters
|
|
128
|
+
*/
|
|
129
|
+
resetStats(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Get the current eviction policy
|
|
132
|
+
*/
|
|
133
|
+
getEvictionPolicy(): EvictionPolicy;
|
|
134
|
+
/**
|
|
135
|
+
* Change the eviction policy
|
|
136
|
+
*
|
|
137
|
+
* @param policy - The new eviction policy
|
|
138
|
+
*/
|
|
139
|
+
setEvictionPolicy(policy: EvictionPolicy): void;
|
|
140
|
+
/**
|
|
141
|
+
* Get all keys in the cache
|
|
142
|
+
*
|
|
143
|
+
* @returns Array of all cache keys
|
|
144
|
+
*/
|
|
145
|
+
keys(): string[];
|
|
146
|
+
/**
|
|
147
|
+
* Get all values in the cache
|
|
148
|
+
*
|
|
149
|
+
* @returns Array of all cached values
|
|
150
|
+
*/
|
|
151
|
+
values(): T[];
|
|
152
|
+
/**
|
|
153
|
+
* Get all entries in the cache
|
|
154
|
+
*
|
|
155
|
+
* @returns Array of [key, value] pairs
|
|
156
|
+
*/
|
|
157
|
+
entries(): [string, T][];
|
|
158
|
+
/**
|
|
159
|
+
* Get the number of entries in the cache
|
|
160
|
+
*/
|
|
161
|
+
get size(): number;
|
|
162
|
+
/**
|
|
163
|
+
* Update the TTL for an existing entry
|
|
164
|
+
*
|
|
165
|
+
* @param key - The cache key
|
|
166
|
+
* @param ttl - New TTL in milliseconds
|
|
167
|
+
* @returns True if the entry was updated
|
|
168
|
+
*/
|
|
169
|
+
touch(key: string, ttl?: number): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Get or set a value using a factory function
|
|
172
|
+
*
|
|
173
|
+
* @param key - The cache key
|
|
174
|
+
* @param factory - Function to create value if not cached
|
|
175
|
+
* @param options - Optional settings for TTL and tags
|
|
176
|
+
* @returns The cached or newly created value
|
|
177
|
+
*/
|
|
178
|
+
getOrSet<V extends T>(key: string, factory: () => V | Promise<V>, options?: CacheSetOptions): Promise<V>;
|
|
179
|
+
/**
|
|
180
|
+
* Get or set a value synchronously using a factory function
|
|
181
|
+
*
|
|
182
|
+
* @param key - The cache key
|
|
183
|
+
* @param factory - Function to create value if not cached
|
|
184
|
+
* @param options - Optional settings for TTL and tags
|
|
185
|
+
* @returns The cached or newly created value
|
|
186
|
+
*/
|
|
187
|
+
getOrSetSync<V extends T>(key: string, factory: () => V, options?: CacheSetOptions): V;
|
|
188
|
+
/**
|
|
189
|
+
* Check if an entry is expired
|
|
190
|
+
*/
|
|
191
|
+
private isExpired;
|
|
192
|
+
/**
|
|
193
|
+
* Check if eviction is needed for a new entry of given size
|
|
194
|
+
*/
|
|
195
|
+
private needsEviction;
|
|
196
|
+
/**
|
|
197
|
+
* Evict one entry based on the eviction policy
|
|
198
|
+
*
|
|
199
|
+
* @returns True if an entry was evicted
|
|
200
|
+
*/
|
|
201
|
+
private evictOne;
|
|
202
|
+
/**
|
|
203
|
+
* Select a candidate for eviction based on policy
|
|
204
|
+
*/
|
|
205
|
+
private selectEvictionCandidate;
|
|
206
|
+
/**
|
|
207
|
+
* Compare two entries for eviction (returns true if entry should be evicted over candidate)
|
|
208
|
+
*/
|
|
209
|
+
private compareForEviction;
|
|
210
|
+
/**
|
|
211
|
+
* Estimate the size of a value in bytes
|
|
212
|
+
*/
|
|
213
|
+
private estimateSize;
|
|
214
|
+
/**
|
|
215
|
+
* Record access time for statistics
|
|
216
|
+
*/
|
|
217
|
+
private recordAccessTime;
|
|
218
|
+
/**
|
|
219
|
+
* Start periodic cleanup of expired entries
|
|
220
|
+
*/
|
|
221
|
+
private startCleanup;
|
|
222
|
+
/**
|
|
223
|
+
* Destroy the cache and release resources
|
|
224
|
+
*/
|
|
225
|
+
destroy(): void;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Create a new AdvancedCache instance
|
|
229
|
+
*
|
|
230
|
+
* @param config - Partial cache configuration
|
|
231
|
+
* @returns A new AdvancedCache instance
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const cache = createAdvancedCache<string>({
|
|
236
|
+
* maxEntries: 1000,
|
|
237
|
+
* evictionPolicy: 'lfu'
|
|
238
|
+
* });
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
export declare function createAdvancedCache<T = any>(config?: Partial<CacheConfig>): AdvancedCache<T>;
|
|
242
|
+
/**
|
|
243
|
+
* Create a cache with preloaded entries
|
|
244
|
+
*
|
|
245
|
+
* @param entries - Initial entries to populate the cache
|
|
246
|
+
* @param config - Partial cache configuration
|
|
247
|
+
* @returns A new AdvancedCache instance with preloaded entries
|
|
248
|
+
*/
|
|
249
|
+
export declare function createPreloadedCache<T = any>(entries: Array<{
|
|
250
|
+
key: string;
|
|
251
|
+
value: T;
|
|
252
|
+
options?: CacheSetOptions;
|
|
253
|
+
}>, config?: Partial<CacheConfig>): AdvancedCache<T>;
|
|
254
|
+
//# sourceMappingURL=lru-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-cache.d.ts","sourceRoot":"","sources":["../../src/caching/lru-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,EAAc,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIvG;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACrC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,CAAC;IACjD,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,EAAE,CAAC,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AM,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,eAAe,CAAA;CAAE,CAAC,EACpE,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAC5B,aAAa,CAAC,CAAC,CAAC,CAMlB"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advanced Caching Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the advanced caching system supporting multiple
|
|
5
|
+
* eviction policies, TTL management, and comprehensive cache statistics.
|
|
6
|
+
*
|
|
7
|
+
* @module caching/types
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Eviction policy for cache entries when capacity is reached
|
|
11
|
+
*
|
|
12
|
+
* - lru: Least Recently Used - evicts entries that haven't been accessed recently
|
|
13
|
+
* - lfu: Least Frequently Used - evicts entries with lowest access count
|
|
14
|
+
* - fifo: First In First Out - evicts oldest entries first
|
|
15
|
+
* - ttl: Time To Live - evicts entries closest to expiration
|
|
16
|
+
*/
|
|
17
|
+
export type EvictionPolicy = 'lru' | 'lfu' | 'fifo' | 'ttl';
|
|
18
|
+
/**
|
|
19
|
+
* Cache entry storing value with metadata for eviction decisions
|
|
20
|
+
*/
|
|
21
|
+
export interface CacheEntry<T> {
|
|
22
|
+
/** Unique key for the cache entry */
|
|
23
|
+
key: string;
|
|
24
|
+
/** The cached value */
|
|
25
|
+
value: T;
|
|
26
|
+
/** Estimated size of the entry in bytes */
|
|
27
|
+
size: number;
|
|
28
|
+
/** Unix timestamp when entry was created */
|
|
29
|
+
createdAt: number;
|
|
30
|
+
/** Unix timestamp when entry was last accessed */
|
|
31
|
+
accessedAt: number;
|
|
32
|
+
/** Number of times entry has been accessed */
|
|
33
|
+
accessCount: number;
|
|
34
|
+
/** Time-to-live in milliseconds (optional) */
|
|
35
|
+
ttl?: number;
|
|
36
|
+
/** Optional tags for grouping and batch operations */
|
|
37
|
+
tags?: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Configuration options for the cache
|
|
41
|
+
*/
|
|
42
|
+
export interface CacheConfig {
|
|
43
|
+
/** Maximum total size of cache in bytes */
|
|
44
|
+
maxSize: number;
|
|
45
|
+
/** Maximum number of entries in cache */
|
|
46
|
+
maxEntries: number;
|
|
47
|
+
/** Default TTL for entries in milliseconds */
|
|
48
|
+
defaultTTL: number;
|
|
49
|
+
/** Policy used for evicting entries when cache is full */
|
|
50
|
+
evictionPolicy: EvictionPolicy;
|
|
51
|
+
/** Optional callback when an entry is evicted */
|
|
52
|
+
onEvict?: (key: string, value: any) => void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Cache statistics for monitoring and diagnostics
|
|
56
|
+
*/
|
|
57
|
+
export interface CacheStats {
|
|
58
|
+
/** Current number of entries in cache */
|
|
59
|
+
entries: number;
|
|
60
|
+
/** Current total size of all entries in bytes */
|
|
61
|
+
size: number;
|
|
62
|
+
/** Total number of cache hits */
|
|
63
|
+
hits: number;
|
|
64
|
+
/** Total number of cache misses */
|
|
65
|
+
misses: number;
|
|
66
|
+
/** Hit rate as a ratio (0-1) */
|
|
67
|
+
hitRate: number;
|
|
68
|
+
/** Total number of evictions */
|
|
69
|
+
evictions: number;
|
|
70
|
+
/** Average access time in milliseconds */
|
|
71
|
+
avgAccessTime: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Options for cache set operations
|
|
75
|
+
*/
|
|
76
|
+
export interface CacheSetOptions {
|
|
77
|
+
/** TTL override for this entry in milliseconds */
|
|
78
|
+
ttl?: number;
|
|
79
|
+
/** Tags for grouping entries */
|
|
80
|
+
tags?: string[];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Result of a cache operation with timing information
|
|
84
|
+
*/
|
|
85
|
+
export interface CacheOperationResult<T> {
|
|
86
|
+
/** Whether the operation succeeded */
|
|
87
|
+
success: boolean;
|
|
88
|
+
/** The value if operation was successful */
|
|
89
|
+
value?: T;
|
|
90
|
+
/** Time taken for the operation in milliseconds */
|
|
91
|
+
duration: number;
|
|
92
|
+
/** Whether the result came from cache */
|
|
93
|
+
fromCache: boolean;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/caching/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,uBAAuB;IACvB,KAAK,EAAE,CAAC,CAAC;IACT,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,cAAc,EAAE,cAAc,CAAC;IAC/B,iDAAiD;IACjD,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,SAAS,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Chunker - Split large documents into manageable chunks
|
|
3
|
+
*
|
|
4
|
+
* Provides multiple chunking strategies for different content types:
|
|
5
|
+
* - Fixed: Simple character-based chunking with overlap
|
|
6
|
+
* - Semantic: Paragraph-based chunking respecting natural boundaries
|
|
7
|
+
* - Markdown: Respects markdown structure (headers, sections)
|
|
8
|
+
* - Code: Preserves code blocks and structure
|
|
9
|
+
* - Adaptive: Auto-selects the best strategy based on content
|
|
10
|
+
*
|
|
11
|
+
* @module chunking/chunker
|
|
12
|
+
*/
|
|
13
|
+
import type { ChunkOptions, ChunkResult, ChunkerConfig } from './types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Text Chunker class
|
|
16
|
+
*
|
|
17
|
+
* Splits documents into chunks using various strategies.
|
|
18
|
+
* Maintains document structure and provides metadata for each chunk.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Chunker {
|
|
21
|
+
private config;
|
|
22
|
+
private defaultOptions;
|
|
23
|
+
constructor(config?: Partial<ChunkerConfig>);
|
|
24
|
+
/**
|
|
25
|
+
* Chunk content using the specified or default strategy
|
|
26
|
+
*
|
|
27
|
+
* @param content - The content to chunk
|
|
28
|
+
* @param options - Chunking options
|
|
29
|
+
* @returns ChunkResult with all chunks and metadata
|
|
30
|
+
*/
|
|
31
|
+
chunk(content: string, options?: Partial<ChunkOptions>): ChunkResult;
|
|
32
|
+
/**
|
|
33
|
+
* Fixed-size chunking with optional overlap
|
|
34
|
+
*
|
|
35
|
+
* Simple character-based chunking. Best for uniform content
|
|
36
|
+
* where structure doesn't matter.
|
|
37
|
+
*/
|
|
38
|
+
private chunkFixed;
|
|
39
|
+
/**
|
|
40
|
+
* Semantic chunking based on paragraph boundaries
|
|
41
|
+
*
|
|
42
|
+
* Respects natural paragraph breaks (double newlines).
|
|
43
|
+
* Groups paragraphs until maxSize is reached.
|
|
44
|
+
*/
|
|
45
|
+
private chunkSemantic;
|
|
46
|
+
/**
|
|
47
|
+
* Markdown-aware chunking
|
|
48
|
+
*
|
|
49
|
+
* Respects markdown header structure. Each major section
|
|
50
|
+
* becomes its own chunk when possible.
|
|
51
|
+
*/
|
|
52
|
+
private chunkMarkdown;
|
|
53
|
+
/**
|
|
54
|
+
* Code-aware chunking
|
|
55
|
+
*
|
|
56
|
+
* Preserves code blocks (fenced with ```) as atomic units.
|
|
57
|
+
* Non-code sections are chunked semantically.
|
|
58
|
+
*/
|
|
59
|
+
private chunkCode;
|
|
60
|
+
/**
|
|
61
|
+
* Adaptive chunking - auto-selects best strategy
|
|
62
|
+
*
|
|
63
|
+
* Analyzes content to determine the best chunking strategy:
|
|
64
|
+
* - Code blocks present -> code strategy
|
|
65
|
+
* - Markdown headers present -> markdown strategy
|
|
66
|
+
* - Default -> semantic strategy
|
|
67
|
+
*/
|
|
68
|
+
private chunkAdaptive;
|
|
69
|
+
/**
|
|
70
|
+
* Create a chunk object with metadata
|
|
71
|
+
*/
|
|
72
|
+
private createChunk;
|
|
73
|
+
/**
|
|
74
|
+
* Detect content type from the content itself
|
|
75
|
+
*/
|
|
76
|
+
private detectType;
|
|
77
|
+
/**
|
|
78
|
+
* Get the current configuration
|
|
79
|
+
*/
|
|
80
|
+
getConfig(): ChunkerConfig;
|
|
81
|
+
/**
|
|
82
|
+
* Update configuration
|
|
83
|
+
*/
|
|
84
|
+
setConfig(config: Partial<ChunkerConfig>): void;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Create a new Chunker instance with optional configuration
|
|
88
|
+
*/
|
|
89
|
+
export declare function createChunker(config?: Partial<ChunkerConfig>): Chunker;
|
|
90
|
+
/**
|
|
91
|
+
* Convenience function to chunk a document without creating a Chunker instance
|
|
92
|
+
*/
|
|
93
|
+
export declare function chunkDocument(content: string, options?: Partial<ChunkOptions>): ChunkResult;
|
|
94
|
+
//# sourceMappingURL=chunker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunker.d.ts","sourceRoot":"","sources":["../../src/chunking/chunker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EACV,YAAY,EAGZ,WAAW,EACX,aAAa,EACd,MAAM,YAAY,CAAC;AAapB;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,cAAc,CAAe;gBAEzB,MAAM,GAAE,OAAO,CAAC,aAAa,CAAM;IAW/C;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,WAAW;IAqDpE;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAwBlB;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAmCrB;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IA4CrB;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAoDjB;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa;IAkBrB;;OAEG;IACH,OAAO,CAAC,WAAW;IA+BnB;;OAEG;IACH,OAAO,CAAC,UAAU;IA4BlB;;OAEG;IACH,SAAS,IAAI,aAAa;IAI1B;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI;CAShD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO,CAEtE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,WAAW,CAG3F"}
|