@weavelogic/knowledge-graph-agent 0.2.0 → 0.3.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 +686 -304
- 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/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/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/index.d.ts.map +1 -1
- package/dist/cli/index.js +40 -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/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 +30 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +173 -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/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 +13 -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 +663 -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/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/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 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../src/sops/types.ts"],"sourcesContent":["/**\n * AI-SDLC SOP Types and Schemas\n *\n * Type definitions for AI-SDLC Standard Operating Procedures integration.\n * Based on https://github.com/AISDLC/AI-SDLC-SOPs\n *\n * @module sops/types\n */\n\n/**\n * SOP Categories aligned with AI-SDLC framework\n */\nexport enum SOPCategory {\n /** Program and Project Management (1000-1010) */\n PROGRAM_MANAGEMENT = 'program-management',\n\n /** Operational and Maintenance (1011-1060) */\n OPERATIONS = 'operations',\n\n /** Training and Development (1100-1220) */\n DEVELOPMENT = 'development',\n\n /** Governance and Specialized Controls (1300-2000) */\n GOVERNANCE = 'governance',\n\n /** Quality Records (2000+) */\n QUALITY = 'quality',\n}\n\n/**\n * SOP Compliance Status\n */\nexport enum ComplianceStatus {\n /** Fully compliant with SOP requirements */\n COMPLIANT = 'compliant',\n\n /** Partially compliant - some requirements met */\n PARTIAL = 'partial',\n\n /** Not compliant - requirements not met */\n NON_COMPLIANT = 'non-compliant',\n\n /** Not applicable to this project */\n NOT_APPLICABLE = 'not-applicable',\n\n /** Not yet assessed */\n PENDING = 'pending',\n}\n\n/**\n * SOP Priority/Risk Level\n */\nexport enum SOPPriority {\n /** Critical - Must be addressed immediately */\n CRITICAL = 'critical',\n\n /** High - Should be addressed soon */\n HIGH = 'high',\n\n /** Medium - Address in normal course */\n MEDIUM = 'medium',\n\n /** Low - Nice to have */\n LOW = 'low',\n}\n\n/**\n * AI-IRB Review Status\n */\nexport enum IRBStatus {\n /** Requires IRB review */\n REQUIRED = 'required',\n\n /** IRB review in progress */\n IN_REVIEW = 'in-review',\n\n /** IRB approved */\n APPROVED = 'approved',\n\n /** IRB approval not required */\n NOT_REQUIRED = 'not-required',\n\n /** IRB review pending */\n PENDING = 'pending',\n}\n\n/**\n * Knowledge Graph Layer Types\n */\nexport enum GraphLayer {\n /** Foundation layer - AI-SDLC SOPs reference */\n STANDARDS = 'standards',\n\n /** Project implementation layer */\n PROJECT = 'project',\n\n /** Compliance overlay showing gaps */\n COMPLIANCE = 'compliance',\n\n /** Custom overlay */\n CUSTOM = 'custom',\n}\n\n/**\n * SOP Requirement definition\n */\nexport interface SOPRequirement {\n /** Requirement ID */\n id: string;\n\n /** Requirement description */\n description: string;\n\n /** Whether this requirement is mandatory */\n mandatory: boolean;\n\n /** Verification method */\n verification: 'document' | 'test' | 'review' | 'audit' | 'automated';\n\n /** Evidence required for compliance */\n evidence: string[];\n\n /** Related artifacts */\n artifacts?: string[];\n}\n\n/**\n * SOP Checkpoint definition\n */\nexport interface SOPCheckpoint {\n /** Checkpoint ID */\n id: string;\n\n /** Checkpoint name */\n name: string;\n\n /** When this checkpoint should be triggered */\n trigger: 'phase-start' | 'phase-end' | 'milestone' | 'continuous' | 'scheduled';\n\n /** Phase this checkpoint applies to */\n phase?: string;\n\n /** Requirements to verify at this checkpoint */\n requirements: string[];\n\n /** AI-IRB involvement */\n irbRequired: boolean;\n\n /** Approval authorities */\n approvers: string[];\n}\n\n/**\n * SOP Definition\n */\nexport interface SOPDefinition {\n /** SOP ID (e.g., \"SOP-1200-01-AI\") */\n id: string;\n\n /** SOP number (e.g., 1200) */\n number: number;\n\n /** SOP title */\n title: string;\n\n /** SOP description */\n description: string;\n\n /** SOP category */\n category: SOPCategory;\n\n /** Priority/risk level */\n priority: SOPPriority;\n\n /** Version */\n version: string;\n\n /** Source URL */\n sourceUrl: string;\n\n /** Scope description */\n scope: string;\n\n /** Requirements */\n requirements: SOPRequirement[];\n\n /** Checkpoints */\n checkpoints: SOPCheckpoint[];\n\n /** Related SOPs */\n relatedSOPs: string[];\n\n /** Tags for searching */\n tags: string[];\n\n /** Whether AI-IRB review is typically required */\n irbTypicallyRequired: boolean;\n\n /** Applicable project types */\n applicableTo: string[];\n}\n\n/**\n * Project SOP Assessment\n */\nexport interface SOPAssessment {\n /** SOP ID being assessed */\n sopId: string;\n\n /** Current compliance status */\n status: ComplianceStatus;\n\n /** Compliance score (0-100) */\n score: number;\n\n /** Requirements met */\n requirementsMet: string[];\n\n /** Requirements not met (gaps) */\n requirementsGaps: string[];\n\n /** Evidence provided */\n evidence: Record<string, string>;\n\n /** AI-IRB status */\n irbStatus: IRBStatus;\n\n /** Assessment date */\n assessedAt: Date;\n\n /** Assessor */\n assessedBy: string;\n\n /** Notes */\n notes: string;\n\n /** Remediation plan if non-compliant */\n remediationPlan?: string;\n\n /** Target compliance date */\n targetDate?: Date;\n}\n\n/**\n * Compliance Gap\n */\nexport interface ComplianceGap {\n /** Gap ID */\n id: string;\n\n /** SOP ID */\n sopId: string;\n\n /** Requirement ID */\n requirementId: string;\n\n /** Gap description */\n description: string;\n\n /** Priority */\n priority: SOPPriority;\n\n /** Impact description */\n impact: string;\n\n /** Recommended remediation */\n remediation: string;\n\n /** Effort estimate */\n effort: 'low' | 'medium' | 'high';\n\n /** Status */\n status: 'open' | 'in-progress' | 'resolved' | 'accepted-risk';\n\n /** Created date */\n createdAt: Date;\n\n /** Resolved date */\n resolvedAt?: Date;\n}\n\n/**\n * Graph Layer Definition\n */\nexport interface LayerDefinition {\n /** Layer ID */\n id: string;\n\n /** Layer name */\n name: string;\n\n /** Layer type */\n type: GraphLayer;\n\n /** Layer description */\n description: string;\n\n /** Whether layer is visible */\n visible: boolean;\n\n /** Layer order (for rendering) */\n order: number;\n\n /** Node filter for this layer */\n nodeFilter?: (node: LayerNode) => boolean;\n\n /** Edge filter for this layer */\n edgeFilter?: (edge: LayerEdge) => boolean;\n\n /** Metadata */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Layer Node - extends base node with layer info\n */\nexport interface LayerNode {\n /** Node ID */\n id: string;\n\n /** Node title */\n title: string;\n\n /** Node type */\n type: string;\n\n /** Layer this node belongs to */\n layer: GraphLayer;\n\n /** SOP reference (for standards layer) */\n sopRef?: string;\n\n /** Compliance status (for compliance layer) */\n complianceStatus?: ComplianceStatus;\n\n /** Tags */\n tags: string[];\n\n /** Metadata */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Layer Edge - extends base edge with layer info\n */\nexport interface LayerEdge {\n /** Source node ID */\n source: string;\n\n /** Target node ID */\n target: string;\n\n /** Edge type */\n type: 'implements' | 'references' | 'depends-on' | 'compliance-gap' | 'wikilink';\n\n /** Layer this edge belongs to */\n layer: GraphLayer;\n\n /** Weight */\n weight: number;\n\n /** Metadata */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Multi-Layer Graph\n */\nexport interface MultiLayerGraph {\n /** Graph ID */\n id: string;\n\n /** Graph name */\n name: string;\n\n /** Layers */\n layers: LayerDefinition[];\n\n /** All nodes across layers */\n nodes: LayerNode[];\n\n /** All edges across layers */\n edges: LayerEdge[];\n\n /** Cross-layer edges (connecting nodes in different layers) */\n crossLayerEdges: LayerEdge[];\n\n /** Metadata */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Compliance Report\n */\nexport interface ComplianceReport {\n /** Report ID */\n id: string;\n\n /** Project name */\n projectName: string;\n\n /** Report generation date */\n generatedAt: Date;\n\n /** Overall compliance score (0-100) */\n overallScore: number;\n\n /** SOP assessments */\n assessments: SOPAssessment[];\n\n /** Open gaps */\n gaps: ComplianceGap[];\n\n /** Summary by category */\n categoryScores: Record<SOPCategory, number>;\n\n /** Summary by priority */\n priorityBreakdown: Record<SOPPriority, { total: number; compliant: number }>;\n\n /** AI-IRB summary */\n irbSummary: {\n required: number;\n approved: number;\n pending: number;\n inReview: number;\n };\n\n /** Recommendations */\n recommendations: string[];\n}\n\n/**\n * SOP Node Frontmatter - extends standard frontmatter with SOP fields\n */\nexport interface SOPFrontmatter {\n /** Standard frontmatter fields */\n title?: string;\n type?: string;\n status?: string;\n created?: string;\n updated?: string;\n tags?: string[];\n\n /** SOP-specific fields */\n sop?: {\n /** SOP ID reference */\n id?: string;\n\n /** Compliance status */\n status?: ComplianceStatus;\n\n /** AI-IRB status */\n irbStatus?: IRBStatus;\n\n /** Requirements addressed */\n requirements?: string[];\n\n /** Evidence links */\n evidence?: string[];\n\n /** Last assessment date */\n assessedAt?: string;\n\n /** Assessor */\n assessedBy?: string;\n\n /** Notes */\n notes?: string;\n };\n\n /** Layer assignment */\n layer?: GraphLayer;\n}\n\n/**\n * SOP Configuration\n */\nexport interface SOPConfig {\n /** Whether SOP compliance is enabled */\n enabled: boolean;\n\n /** Source repository for SOPs */\n sourceRepo: string;\n\n /** SOP version/tag to use */\n version: string;\n\n /** Categories to include */\n categories: SOPCategory[];\n\n /** Custom SOP definitions */\n customSOPs?: SOPDefinition[];\n\n /** Default IRB requirement */\n defaultIRBRequired: boolean;\n\n /** Auto-assessment configuration */\n autoAssess?: {\n /** Enable auto-assessment */\n enabled: boolean;\n\n /** Patterns to match for compliance */\n patterns: Record<string, string[]>;\n };\n}\n"],"names":["SOPCategory","ComplianceStatus","SOPPriority","IRBStatus","GraphLayer"],"mappings":"AAYO,IAAK,gCAAAA,iBAAL;AAELA,eAAA,oBAAA,IAAqB;AAGrBA,eAAA,YAAA,IAAa;AAGbA,eAAA,aAAA,IAAc;AAGdA,eAAA,YAAA,IAAa;AAGbA,eAAA,SAAA,IAAU;AAdA,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AAoBL,IAAK,qCAAAC,sBAAL;AAELA,oBAAA,WAAA,IAAY;AAGZA,oBAAA,SAAA,IAAU;AAGVA,oBAAA,eAAA,IAAgB;AAGhBA,oBAAA,gBAAA,IAAiB;AAGjBA,oBAAA,SAAA,IAAU;AAdA,SAAAA;AAAA,GAAA,oBAAA,CAAA,CAAA;AAoBL,IAAK,gCAAAC,iBAAL;AAELA,eAAA,UAAA,IAAW;AAGXA,eAAA,MAAA,IAAO;AAGPA,eAAA,QAAA,IAAS;AAGTA,eAAA,KAAA,IAAM;AAXI,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AAiBL,IAAK,8BAAAC,eAAL;AAELA,aAAA,UAAA,IAAW;AAGXA,aAAA,WAAA,IAAY;AAGZA,aAAA,UAAA,IAAW;AAGXA,aAAA,cAAA,IAAe;AAGfA,aAAA,SAAA,IAAU;AAdA,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAoBL,IAAK,+BAAAC,gBAAL;AAELA,cAAA,WAAA,IAAY;AAGZA,cAAA,SAAA,IAAU;AAGVA,cAAA,YAAA,IAAa;AAGbA,cAAA,QAAA,IAAS;AAXC,SAAAA;AAAA,GAAA,cAAA,CAAA,CAAA;"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Recovery System
|
|
3
|
+
*
|
|
4
|
+
* Provides intelligent retry strategies with exponential backoff,
|
|
5
|
+
* jitter, and circuit breaker patterns. Based on weaver recovery patterns.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/error-recovery
|
|
8
|
+
*/
|
|
9
|
+
import { type ClassifiedError } from './error-taxonomy.js';
|
|
10
|
+
/**
|
|
11
|
+
* Retry configuration options
|
|
12
|
+
*/
|
|
13
|
+
export interface RetryOptions {
|
|
14
|
+
/** Maximum number of retry attempts (default: 3) */
|
|
15
|
+
maxRetries?: number;
|
|
16
|
+
/** Initial delay in milliseconds (default: 1000) */
|
|
17
|
+
initialDelay?: number;
|
|
18
|
+
/** Maximum delay in milliseconds (default: 30000) */
|
|
19
|
+
maxDelay?: number;
|
|
20
|
+
/** Backoff factor for exponential backoff (default: 2) */
|
|
21
|
+
backoffFactor?: number;
|
|
22
|
+
/** Whether to add random jitter (default: true) */
|
|
23
|
+
jitter?: boolean;
|
|
24
|
+
/** Jitter factor (0-1, default: 0.1) */
|
|
25
|
+
jitterFactor?: number;
|
|
26
|
+
/** Custom function to determine if error is retryable */
|
|
27
|
+
isRetryable?: (error: unknown) => boolean;
|
|
28
|
+
/** Called before each retry attempt */
|
|
29
|
+
onRetry?: (error: ClassifiedError, attempt: number, delay: number) => void;
|
|
30
|
+
/** Abort signal for cancellation */
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Result of a retry operation
|
|
35
|
+
*/
|
|
36
|
+
export interface RetryResult<T> {
|
|
37
|
+
/** Whether the operation succeeded */
|
|
38
|
+
success: boolean;
|
|
39
|
+
/** The result value (if successful) */
|
|
40
|
+
value?: T;
|
|
41
|
+
/** The final error (if failed) */
|
|
42
|
+
error?: ClassifiedError;
|
|
43
|
+
/** Number of attempts made */
|
|
44
|
+
attempts: number;
|
|
45
|
+
/** Total time spent in milliseconds */
|
|
46
|
+
totalTime: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Circuit breaker state
|
|
50
|
+
*/
|
|
51
|
+
export declare enum CircuitState {
|
|
52
|
+
CLOSED = "closed",
|
|
53
|
+
OPEN = "open",
|
|
54
|
+
HALF_OPEN = "half_open"
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Circuit breaker configuration
|
|
58
|
+
*/
|
|
59
|
+
export interface CircuitBreakerOptions {
|
|
60
|
+
/** Number of failures before opening circuit (default: 5) */
|
|
61
|
+
failureThreshold?: number;
|
|
62
|
+
/** Time in ms before testing circuit again (default: 30000) */
|
|
63
|
+
resetTimeout?: number;
|
|
64
|
+
/** Number of successful tests before fully closing (default: 2) */
|
|
65
|
+
successThreshold?: number;
|
|
66
|
+
/** Whether to track errors by type (default: false) */
|
|
67
|
+
trackByErrorType?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Circuit breaker for protecting against cascading failures
|
|
71
|
+
*/
|
|
72
|
+
export declare class CircuitBreaker {
|
|
73
|
+
private state;
|
|
74
|
+
private failures;
|
|
75
|
+
private successCount;
|
|
76
|
+
private lastFailureTime;
|
|
77
|
+
private readonly options;
|
|
78
|
+
constructor(options?: CircuitBreakerOptions);
|
|
79
|
+
/**
|
|
80
|
+
* Get current circuit state
|
|
81
|
+
*/
|
|
82
|
+
getState(): CircuitState;
|
|
83
|
+
/**
|
|
84
|
+
* Check if circuit allows execution
|
|
85
|
+
*/
|
|
86
|
+
canExecute(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Record a successful execution
|
|
89
|
+
*/
|
|
90
|
+
recordSuccess(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Record a failed execution
|
|
93
|
+
*/
|
|
94
|
+
recordFailure(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Reset the circuit breaker
|
|
97
|
+
*/
|
|
98
|
+
reset(): void;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Calculate delay with exponential backoff
|
|
102
|
+
*
|
|
103
|
+
* @param attempt - The current attempt number (1-based)
|
|
104
|
+
* @param options - Retry options
|
|
105
|
+
* @returns Delay in milliseconds
|
|
106
|
+
*/
|
|
107
|
+
export declare function calculateBackoff(attempt: number, options?: Pick<RetryOptions, 'initialDelay' | 'maxDelay' | 'backoffFactor' | 'jitter' | 'jitterFactor'>): number;
|
|
108
|
+
/**
|
|
109
|
+
* Sleep for specified duration
|
|
110
|
+
*
|
|
111
|
+
* @param ms - Duration in milliseconds
|
|
112
|
+
* @param signal - Optional abort signal
|
|
113
|
+
*/
|
|
114
|
+
export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Execute operation with automatic retry
|
|
117
|
+
*
|
|
118
|
+
* @param operation - The async operation to execute
|
|
119
|
+
* @param options - Retry configuration
|
|
120
|
+
* @returns Result containing value or error
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const result = await withRetry(
|
|
125
|
+
* () => fetchData(),
|
|
126
|
+
* { maxRetries: 5, onRetry: (err, attempt) => console.log(`Retry ${attempt}`) }
|
|
127
|
+
* );
|
|
128
|
+
*
|
|
129
|
+
* if (result.success) {
|
|
130
|
+
* console.log('Data:', result.value);
|
|
131
|
+
* } else {
|
|
132
|
+
* console.error('Failed after', result.attempts, 'attempts');
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export declare function withRetry<T>(operation: () => Promise<T>, options?: RetryOptions): Promise<RetryResult<T>>;
|
|
137
|
+
/**
|
|
138
|
+
* Execute operation with automatic retry (throws on failure)
|
|
139
|
+
*
|
|
140
|
+
* @param operation - The async operation to execute
|
|
141
|
+
* @param options - Retry configuration
|
|
142
|
+
* @returns The operation result
|
|
143
|
+
* @throws The last error if all retries fail
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* try {
|
|
148
|
+
* const data = await retry(() => fetchData(), { maxRetries: 3 });
|
|
149
|
+
* console.log('Data:', data);
|
|
150
|
+
* } catch (error) {
|
|
151
|
+
* console.error('All retries failed:', error);
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare function retry<T>(operation: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
156
|
+
/**
|
|
157
|
+
* Fallback chain options
|
|
158
|
+
*/
|
|
159
|
+
export interface FallbackOptions<T> {
|
|
160
|
+
/** Called when primary operation fails */
|
|
161
|
+
onFallback?: (error: ClassifiedError, index: number) => void;
|
|
162
|
+
/** Abort signal */
|
|
163
|
+
signal?: AbortSignal;
|
|
164
|
+
/** Default value if all operations fail */
|
|
165
|
+
defaultValue?: T;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Execute with fallback chain
|
|
169
|
+
*
|
|
170
|
+
* Tries each operation in sequence until one succeeds.
|
|
171
|
+
*
|
|
172
|
+
* @param operations - Array of fallback operations
|
|
173
|
+
* @param options - Fallback configuration
|
|
174
|
+
* @returns The first successful result or default value
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* const data = await withFallback(
|
|
179
|
+
* [
|
|
180
|
+
* () => fetchFromPrimary(),
|
|
181
|
+
* () => fetchFromSecondary(),
|
|
182
|
+
* () => fetchFromCache(),
|
|
183
|
+
* ],
|
|
184
|
+
* { defaultValue: { cached: true, data: [] } }
|
|
185
|
+
* );
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
export declare function withFallback<T>(operations: Array<() => Promise<T>>, options?: FallbackOptions<T>): Promise<T>;
|
|
189
|
+
/**
|
|
190
|
+
* Execute with circuit breaker
|
|
191
|
+
*
|
|
192
|
+
* @param operation - The operation to execute
|
|
193
|
+
* @param breaker - Circuit breaker instance
|
|
194
|
+
* @returns The operation result
|
|
195
|
+
* @throws If circuit is open or operation fails
|
|
196
|
+
*/
|
|
197
|
+
export declare function withCircuitBreaker<T>(operation: () => Promise<T>, breaker: CircuitBreaker): Promise<T>;
|
|
198
|
+
/**
|
|
199
|
+
* Create a retryable version of an async function
|
|
200
|
+
*
|
|
201
|
+
* @param fn - The async function to wrap
|
|
202
|
+
* @param options - Default retry options
|
|
203
|
+
* @returns A new function that automatically retries on failure
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* const fetchWithRetry = retryable(
|
|
208
|
+
* (url: string) => fetch(url),
|
|
209
|
+
* { maxRetries: 3 }
|
|
210
|
+
* );
|
|
211
|
+
*
|
|
212
|
+
* const response = await fetchWithRetry('https://api.example.com/data');
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export declare function retryable<TArgs extends unknown[], TResult>(fn: (...args: TArgs) => Promise<TResult>, options?: RetryOptions): (...args: TArgs) => Promise<TResult>;
|
|
216
|
+
/**
|
|
217
|
+
* Error class for retries exhausted
|
|
218
|
+
*/
|
|
219
|
+
export declare class RetriesExhaustedError extends Error {
|
|
220
|
+
readonly lastError: ClassifiedError;
|
|
221
|
+
readonly attempts: number;
|
|
222
|
+
constructor(lastError: ClassifiedError, attempts: number);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Error class for circuit breaker open
|
|
226
|
+
*/
|
|
227
|
+
export declare class CircuitOpenError extends Error {
|
|
228
|
+
constructor(message?: string);
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=error-recovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-recovery.d.ts","sourceRoot":"","sources":["../../src/utils/error-recovery.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAGL,KAAK,eAAe,EAGrB,MAAM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AAE,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE7D,mBAAmB;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,CAAC,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAClC,UAAU,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EACnC,OAAO,GAAE,eAAe,CAAC,CAAC,CAAM,GAC/B,OAAO,CAAC,CAAC,CAAC,CA6BZ;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACxC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,EACxD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,EACxC,OAAO,GAAE,YAAiB,GACzB,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,CAEtC;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAgB,SAAS,EAAE,eAAe,CAAC;IAC3C,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAErB,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM;CAMzD;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,SAA4B;CAIhD"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { isRetryableError, classifyError, isRateLimitError } from "./error-taxonomy.js";
|
|
2
|
+
var CircuitState = /* @__PURE__ */ ((CircuitState2) => {
|
|
3
|
+
CircuitState2["CLOSED"] = "closed";
|
|
4
|
+
CircuitState2["OPEN"] = "open";
|
|
5
|
+
CircuitState2["HALF_OPEN"] = "half_open";
|
|
6
|
+
return CircuitState2;
|
|
7
|
+
})(CircuitState || {});
|
|
8
|
+
class CircuitBreaker {
|
|
9
|
+
state = "closed";
|
|
10
|
+
failures = 0;
|
|
11
|
+
successCount = 0;
|
|
12
|
+
lastFailureTime = 0;
|
|
13
|
+
options;
|
|
14
|
+
constructor(options = {}) {
|
|
15
|
+
this.options = {
|
|
16
|
+
failureThreshold: options.failureThreshold ?? 5,
|
|
17
|
+
resetTimeout: options.resetTimeout ?? 3e4,
|
|
18
|
+
successThreshold: options.successThreshold ?? 2,
|
|
19
|
+
trackByErrorType: options.trackByErrorType ?? false
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get current circuit state
|
|
24
|
+
*/
|
|
25
|
+
getState() {
|
|
26
|
+
if (this.state === "open" && Date.now() - this.lastFailureTime >= this.options.resetTimeout) {
|
|
27
|
+
this.state = "half_open";
|
|
28
|
+
this.successCount = 0;
|
|
29
|
+
}
|
|
30
|
+
return this.state;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Check if circuit allows execution
|
|
34
|
+
*/
|
|
35
|
+
canExecute() {
|
|
36
|
+
const state = this.getState();
|
|
37
|
+
return state === "closed" || state === "half_open";
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Record a successful execution
|
|
41
|
+
*/
|
|
42
|
+
recordSuccess() {
|
|
43
|
+
if (this.state === "half_open") {
|
|
44
|
+
this.successCount++;
|
|
45
|
+
if (this.successCount >= this.options.successThreshold) {
|
|
46
|
+
this.state = "closed";
|
|
47
|
+
this.failures = 0;
|
|
48
|
+
this.successCount = 0;
|
|
49
|
+
}
|
|
50
|
+
} else if (this.state === "closed") {
|
|
51
|
+
this.failures = 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Record a failed execution
|
|
56
|
+
*/
|
|
57
|
+
recordFailure() {
|
|
58
|
+
this.failures++;
|
|
59
|
+
this.lastFailureTime = Date.now();
|
|
60
|
+
if (this.state === "half_open") {
|
|
61
|
+
this.state = "open";
|
|
62
|
+
this.successCount = 0;
|
|
63
|
+
} else if (this.failures >= this.options.failureThreshold) {
|
|
64
|
+
this.state = "open";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Reset the circuit breaker
|
|
69
|
+
*/
|
|
70
|
+
reset() {
|
|
71
|
+
this.state = "closed";
|
|
72
|
+
this.failures = 0;
|
|
73
|
+
this.successCount = 0;
|
|
74
|
+
this.lastFailureTime = 0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function calculateBackoff(attempt, options = {}) {
|
|
78
|
+
const initialDelay = options.initialDelay ?? 1e3;
|
|
79
|
+
const maxDelay = options.maxDelay ?? 3e4;
|
|
80
|
+
const backoffFactor = options.backoffFactor ?? 2;
|
|
81
|
+
const jitter = options.jitter ?? true;
|
|
82
|
+
const jitterFactor = options.jitterFactor ?? 0.1;
|
|
83
|
+
let delay = initialDelay * Math.pow(backoffFactor, attempt - 1);
|
|
84
|
+
delay = Math.min(delay, maxDelay);
|
|
85
|
+
if (jitter) {
|
|
86
|
+
const jitterAmount = delay * jitterFactor;
|
|
87
|
+
delay = delay + (Math.random() * 2 - 1) * jitterAmount;
|
|
88
|
+
}
|
|
89
|
+
return Math.round(delay);
|
|
90
|
+
}
|
|
91
|
+
function sleep(ms, signal) {
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
if (signal?.aborted) {
|
|
94
|
+
reject(new Error("Aborted"));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const timeout = setTimeout(resolve, ms);
|
|
98
|
+
signal?.addEventListener("abort", () => {
|
|
99
|
+
clearTimeout(timeout);
|
|
100
|
+
reject(new Error("Aborted"));
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async function withRetry(operation, options = {}) {
|
|
105
|
+
const maxRetries = options.maxRetries ?? 3;
|
|
106
|
+
const isRetryable = options.isRetryable ?? isRetryableError;
|
|
107
|
+
const startTime = Date.now();
|
|
108
|
+
let attempt = 0;
|
|
109
|
+
let lastError;
|
|
110
|
+
while (attempt <= maxRetries) {
|
|
111
|
+
try {
|
|
112
|
+
if (options.signal?.aborted) {
|
|
113
|
+
throw new Error("Operation aborted");
|
|
114
|
+
}
|
|
115
|
+
const value = await operation();
|
|
116
|
+
return {
|
|
117
|
+
success: true,
|
|
118
|
+
value,
|
|
119
|
+
attempts: attempt + 1,
|
|
120
|
+
totalTime: Date.now() - startTime
|
|
121
|
+
};
|
|
122
|
+
} catch (error) {
|
|
123
|
+
const classified = classifyError(error);
|
|
124
|
+
lastError = classified;
|
|
125
|
+
attempt++;
|
|
126
|
+
if (attempt > maxRetries) {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
if (!isRetryable(error)) {
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
let delay = calculateBackoff(attempt, options);
|
|
133
|
+
if (isRateLimitError(error) && classified.suggestedDelay > delay) {
|
|
134
|
+
delay = classified.suggestedDelay;
|
|
135
|
+
}
|
|
136
|
+
options.onRetry?.(classified, attempt, delay);
|
|
137
|
+
try {
|
|
138
|
+
await sleep(delay, options.signal);
|
|
139
|
+
} catch {
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
success: false,
|
|
146
|
+
error: lastError,
|
|
147
|
+
attempts: attempt,
|
|
148
|
+
totalTime: Date.now() - startTime
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async function retry(operation, options = {}) {
|
|
152
|
+
const result = await withRetry(operation, options);
|
|
153
|
+
if (result.success) {
|
|
154
|
+
return result.value;
|
|
155
|
+
}
|
|
156
|
+
throw result.error?.original ?? new Error("Operation failed");
|
|
157
|
+
}
|
|
158
|
+
async function withFallback(operations, options = {}) {
|
|
159
|
+
if (operations.length === 0) {
|
|
160
|
+
if (options.defaultValue !== void 0) {
|
|
161
|
+
return options.defaultValue;
|
|
162
|
+
}
|
|
163
|
+
throw new Error("No fallback operations provided");
|
|
164
|
+
}
|
|
165
|
+
let lastError;
|
|
166
|
+
for (let i = 0; i < operations.length; i++) {
|
|
167
|
+
try {
|
|
168
|
+
if (options.signal?.aborted) {
|
|
169
|
+
throw new Error("Operation aborted");
|
|
170
|
+
}
|
|
171
|
+
return await operations[i]();
|
|
172
|
+
} catch (error) {
|
|
173
|
+
const classified = classifyError(error);
|
|
174
|
+
lastError = classified;
|
|
175
|
+
options.onFallback?.(classified, i);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (options.defaultValue !== void 0) {
|
|
179
|
+
return options.defaultValue;
|
|
180
|
+
}
|
|
181
|
+
throw lastError?.original ?? new Error("All fallback operations failed");
|
|
182
|
+
}
|
|
183
|
+
async function withCircuitBreaker(operation, breaker) {
|
|
184
|
+
if (!breaker.canExecute()) {
|
|
185
|
+
throw new Error("Circuit breaker is open");
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
const result = await operation();
|
|
189
|
+
breaker.recordSuccess();
|
|
190
|
+
return result;
|
|
191
|
+
} catch (error) {
|
|
192
|
+
breaker.recordFailure();
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function retryable(fn, options = {}) {
|
|
197
|
+
return (...args) => retry(() => fn(...args), options);
|
|
198
|
+
}
|
|
199
|
+
class RetriesExhaustedError extends Error {
|
|
200
|
+
lastError;
|
|
201
|
+
attempts;
|
|
202
|
+
constructor(lastError, attempts) {
|
|
203
|
+
super(`All ${attempts} retry attempts exhausted: ${lastError.message}`);
|
|
204
|
+
this.name = "RetriesExhaustedError";
|
|
205
|
+
this.lastError = lastError;
|
|
206
|
+
this.attempts = attempts;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
class CircuitOpenError extends Error {
|
|
210
|
+
constructor(message = "Circuit breaker is open") {
|
|
211
|
+
super(message);
|
|
212
|
+
this.name = "CircuitOpenError";
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
export {
|
|
216
|
+
CircuitBreaker,
|
|
217
|
+
CircuitOpenError,
|
|
218
|
+
CircuitState,
|
|
219
|
+
RetriesExhaustedError,
|
|
220
|
+
calculateBackoff,
|
|
221
|
+
retry,
|
|
222
|
+
retryable,
|
|
223
|
+
sleep,
|
|
224
|
+
withCircuitBreaker,
|
|
225
|
+
withFallback,
|
|
226
|
+
withRetry
|
|
227
|
+
};
|
|
228
|
+
//# sourceMappingURL=error-recovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-recovery.js","sources":["../../src/utils/error-recovery.ts"],"sourcesContent":["/**\n * Error Recovery System\n *\n * Provides intelligent retry strategies with exponential backoff,\n * jitter, and circuit breaker patterns. Based on weaver recovery patterns.\n *\n * @module utils/error-recovery\n */\n\nimport {\n classifyError,\n ErrorCategory,\n type ClassifiedError,\n isRetryableError,\n isRateLimitError,\n} from './error-taxonomy.js';\n\n/**\n * Retry configuration options\n */\nexport interface RetryOptions {\n /** Maximum number of retry attempts (default: 3) */\n maxRetries?: number;\n\n /** Initial delay in milliseconds (default: 1000) */\n initialDelay?: number;\n\n /** Maximum delay in milliseconds (default: 30000) */\n maxDelay?: number;\n\n /** Backoff factor for exponential backoff (default: 2) */\n backoffFactor?: number;\n\n /** Whether to add random jitter (default: true) */\n jitter?: boolean;\n\n /** Jitter factor (0-1, default: 0.1) */\n jitterFactor?: number;\n\n /** Custom function to determine if error is retryable */\n isRetryable?: (error: unknown) => boolean;\n\n /** Called before each retry attempt */\n onRetry?: (error: ClassifiedError, attempt: number, delay: number) => void;\n\n /** Abort signal for cancellation */\n signal?: AbortSignal;\n}\n\n/**\n * Result of a retry operation\n */\nexport interface RetryResult<T> {\n /** Whether the operation succeeded */\n success: boolean;\n\n /** The result value (if successful) */\n value?: T;\n\n /** The final error (if failed) */\n error?: ClassifiedError;\n\n /** Number of attempts made */\n attempts: number;\n\n /** Total time spent in milliseconds */\n totalTime: number;\n}\n\n/**\n * Circuit breaker state\n */\nexport enum CircuitState {\n CLOSED = 'closed',\n OPEN = 'open',\n HALF_OPEN = 'half_open',\n}\n\n/**\n * Circuit breaker configuration\n */\nexport interface CircuitBreakerOptions {\n /** Number of failures before opening circuit (default: 5) */\n failureThreshold?: number;\n\n /** Time in ms before testing circuit again (default: 30000) */\n resetTimeout?: number;\n\n /** Number of successful tests before fully closing (default: 2) */\n successThreshold?: number;\n\n /** Whether to track errors by type (default: false) */\n trackByErrorType?: boolean;\n}\n\n/**\n * Circuit breaker for protecting against cascading failures\n */\nexport class CircuitBreaker {\n private state = CircuitState.CLOSED;\n private failures = 0;\n private successCount = 0;\n private lastFailureTime = 0;\n private readonly options: Required<CircuitBreakerOptions>;\n\n constructor(options: CircuitBreakerOptions = {}) {\n this.options = {\n failureThreshold: options.failureThreshold ?? 5,\n resetTimeout: options.resetTimeout ?? 30000,\n successThreshold: options.successThreshold ?? 2,\n trackByErrorType: options.trackByErrorType ?? false,\n };\n }\n\n /**\n * Get current circuit state\n */\n getState(): CircuitState {\n // Check if we should transition from OPEN to HALF_OPEN\n if (\n this.state === CircuitState.OPEN &&\n Date.now() - this.lastFailureTime >= this.options.resetTimeout\n ) {\n this.state = CircuitState.HALF_OPEN;\n this.successCount = 0;\n }\n return this.state;\n }\n\n /**\n * Check if circuit allows execution\n */\n canExecute(): boolean {\n const state = this.getState();\n return state === CircuitState.CLOSED || state === CircuitState.HALF_OPEN;\n }\n\n /**\n * Record a successful execution\n */\n recordSuccess(): void {\n if (this.state === CircuitState.HALF_OPEN) {\n this.successCount++;\n if (this.successCount >= this.options.successThreshold) {\n this.state = CircuitState.CLOSED;\n this.failures = 0;\n this.successCount = 0;\n }\n } else if (this.state === CircuitState.CLOSED) {\n // Reset failures on success\n this.failures = 0;\n }\n }\n\n /**\n * Record a failed execution\n */\n recordFailure(): void {\n this.failures++;\n this.lastFailureTime = Date.now();\n\n if (this.state === CircuitState.HALF_OPEN) {\n // Any failure in half-open returns to open\n this.state = CircuitState.OPEN;\n this.successCount = 0;\n } else if (this.failures >= this.options.failureThreshold) {\n this.state = CircuitState.OPEN;\n }\n }\n\n /**\n * Reset the circuit breaker\n */\n reset(): void {\n this.state = CircuitState.CLOSED;\n this.failures = 0;\n this.successCount = 0;\n this.lastFailureTime = 0;\n }\n}\n\n/**\n * Calculate delay with exponential backoff\n *\n * @param attempt - The current attempt number (1-based)\n * @param options - Retry options\n * @returns Delay in milliseconds\n */\nexport function calculateBackoff(\n attempt: number,\n options: Pick<RetryOptions, 'initialDelay' | 'maxDelay' | 'backoffFactor' | 'jitter' | 'jitterFactor'> = {}\n): number {\n const initialDelay = options.initialDelay ?? 1000;\n const maxDelay = options.maxDelay ?? 30000;\n const backoffFactor = options.backoffFactor ?? 2;\n const jitter = options.jitter ?? true;\n const jitterFactor = options.jitterFactor ?? 0.1;\n\n // Calculate exponential delay\n let delay = initialDelay * Math.pow(backoffFactor, attempt - 1);\n\n // Cap at maximum\n delay = Math.min(delay, maxDelay);\n\n // Add jitter if enabled\n if (jitter) {\n const jitterAmount = delay * jitterFactor;\n delay = delay + (Math.random() * 2 - 1) * jitterAmount;\n }\n\n return Math.round(delay);\n}\n\n/**\n * Sleep for specified duration\n *\n * @param ms - Duration in milliseconds\n * @param signal - Optional abort signal\n */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(new Error('Aborted'));\n return;\n }\n\n const timeout = setTimeout(resolve, ms);\n\n signal?.addEventListener('abort', () => {\n clearTimeout(timeout);\n reject(new Error('Aborted'));\n });\n });\n}\n\n/**\n * Execute operation with automatic retry\n *\n * @param operation - The async operation to execute\n * @param options - Retry configuration\n * @returns Result containing value or error\n *\n * @example\n * ```typescript\n * const result = await withRetry(\n * () => fetchData(),\n * { maxRetries: 5, onRetry: (err, attempt) => console.log(`Retry ${attempt}`) }\n * );\n *\n * if (result.success) {\n * console.log('Data:', result.value);\n * } else {\n * console.error('Failed after', result.attempts, 'attempts');\n * }\n * ```\n */\nexport async function withRetry<T>(\n operation: () => Promise<T>,\n options: RetryOptions = {}\n): Promise<RetryResult<T>> {\n const maxRetries = options.maxRetries ?? 3;\n const isRetryable = options.isRetryable ?? isRetryableError;\n\n const startTime = Date.now();\n let attempt = 0;\n let lastError: ClassifiedError | undefined;\n\n while (attempt <= maxRetries) {\n try {\n // Check for abort\n if (options.signal?.aborted) {\n throw new Error('Operation aborted');\n }\n\n const value = await operation();\n return {\n success: true,\n value,\n attempts: attempt + 1,\n totalTime: Date.now() - startTime,\n };\n } catch (error) {\n const classified = classifyError(error);\n lastError = classified;\n attempt++;\n\n // Don't retry if we've exhausted attempts\n if (attempt > maxRetries) {\n break;\n }\n\n // Don't retry non-retryable errors\n if (!isRetryable(error)) {\n break;\n }\n\n // Calculate delay\n let delay = calculateBackoff(attempt, options);\n\n // Use suggested delay for rate limits (often includes Retry-After header)\n if (isRateLimitError(error) && classified.suggestedDelay > delay) {\n delay = classified.suggestedDelay;\n }\n\n // Notify about retry\n options.onRetry?.(classified, attempt, delay);\n\n // Wait before retry\n try {\n await sleep(delay, options.signal);\n } catch {\n // Aborted during sleep\n break;\n }\n }\n }\n\n return {\n success: false,\n error: lastError,\n attempts: attempt,\n totalTime: Date.now() - startTime,\n };\n}\n\n/**\n * Execute operation with automatic retry (throws on failure)\n *\n * @param operation - The async operation to execute\n * @param options - Retry configuration\n * @returns The operation result\n * @throws The last error if all retries fail\n *\n * @example\n * ```typescript\n * try {\n * const data = await retry(() => fetchData(), { maxRetries: 3 });\n * console.log('Data:', data);\n * } catch (error) {\n * console.error('All retries failed:', error);\n * }\n * ```\n */\nexport async function retry<T>(\n operation: () => Promise<T>,\n options: RetryOptions = {}\n): Promise<T> {\n const result = await withRetry(operation, options);\n\n if (result.success) {\n return result.value as T;\n }\n\n // Throw the original error\n throw result.error?.original ?? new Error('Operation failed');\n}\n\n/**\n * Fallback chain options\n */\nexport interface FallbackOptions<T> {\n /** Called when primary operation fails */\n onFallback?: (error: ClassifiedError, index: number) => void;\n\n /** Abort signal */\n signal?: AbortSignal;\n\n /** Default value if all operations fail */\n defaultValue?: T;\n}\n\n/**\n * Execute with fallback chain\n *\n * Tries each operation in sequence until one succeeds.\n *\n * @param operations - Array of fallback operations\n * @param options - Fallback configuration\n * @returns The first successful result or default value\n *\n * @example\n * ```typescript\n * const data = await withFallback(\n * [\n * () => fetchFromPrimary(),\n * () => fetchFromSecondary(),\n * () => fetchFromCache(),\n * ],\n * { defaultValue: { cached: true, data: [] } }\n * );\n * ```\n */\nexport async function withFallback<T>(\n operations: Array<() => Promise<T>>,\n options: FallbackOptions<T> = {}\n): Promise<T> {\n if (operations.length === 0) {\n if (options.defaultValue !== undefined) {\n return options.defaultValue;\n }\n throw new Error('No fallback operations provided');\n }\n\n let lastError: ClassifiedError | undefined;\n\n for (let i = 0; i < operations.length; i++) {\n try {\n if (options.signal?.aborted) {\n throw new Error('Operation aborted');\n }\n\n return await operations[i]();\n } catch (error) {\n const classified = classifyError(error);\n lastError = classified;\n options.onFallback?.(classified, i);\n }\n }\n\n if (options.defaultValue !== undefined) {\n return options.defaultValue;\n }\n\n throw lastError?.original ?? new Error('All fallback operations failed');\n}\n\n/**\n * Execute with circuit breaker\n *\n * @param operation - The operation to execute\n * @param breaker - Circuit breaker instance\n * @returns The operation result\n * @throws If circuit is open or operation fails\n */\nexport async function withCircuitBreaker<T>(\n operation: () => Promise<T>,\n breaker: CircuitBreaker\n): Promise<T> {\n if (!breaker.canExecute()) {\n throw new Error('Circuit breaker is open');\n }\n\n try {\n const result = await operation();\n breaker.recordSuccess();\n return result;\n } catch (error) {\n breaker.recordFailure();\n throw error;\n }\n}\n\n/**\n * Create a retryable version of an async function\n *\n * @param fn - The async function to wrap\n * @param options - Default retry options\n * @returns A new function that automatically retries on failure\n *\n * @example\n * ```typescript\n * const fetchWithRetry = retryable(\n * (url: string) => fetch(url),\n * { maxRetries: 3 }\n * );\n *\n * const response = await fetchWithRetry('https://api.example.com/data');\n * ```\n */\nexport function retryable<TArgs extends unknown[], TResult>(\n fn: (...args: TArgs) => Promise<TResult>,\n options: RetryOptions = {}\n): (...args: TArgs) => Promise<TResult> {\n return (...args: TArgs) => retry(() => fn(...args), options);\n}\n\n/**\n * Error class for retries exhausted\n */\nexport class RetriesExhaustedError extends Error {\n public readonly lastError: ClassifiedError;\n public readonly attempts: number;\n\n constructor(lastError: ClassifiedError, attempts: number) {\n super(`All ${attempts} retry attempts exhausted: ${lastError.message}`);\n this.name = 'RetriesExhaustedError';\n this.lastError = lastError;\n this.attempts = attempts;\n }\n}\n\n/**\n * Error class for circuit breaker open\n */\nexport class CircuitOpenError extends Error {\n constructor(message = 'Circuit breaker is open') {\n super(message);\n this.name = 'CircuitOpenError';\n }\n}\n"],"names":["CircuitState"],"mappings":";AAwEO,IAAK,iCAAAA,kBAAL;AACLA,gBAAA,QAAA,IAAS;AACTA,gBAAA,MAAA,IAAO;AACPA,gBAAA,WAAA,IAAY;AAHF,SAAAA;AAAA,GAAA,gBAAA,CAAA,CAAA;AA0BL,MAAM,eAAe;AAAA,EAClB,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,eAAe;AAAA,EACf,kBAAkB;AAAA,EACT;AAAA,EAEjB,YAAY,UAAiC,IAAI;AAC/C,SAAK,UAAU;AAAA,MACb,kBAAkB,QAAQ,oBAAoB;AAAA,MAC9C,cAAc,QAAQ,gBAAgB;AAAA,MACtC,kBAAkB,QAAQ,oBAAoB;AAAA,MAC9C,kBAAkB,QAAQ,oBAAoB;AAAA,IAAA;AAAA,EAElD;AAAA;AAAA;AAAA;AAAA,EAKA,WAAyB;AAEvB,QACE,KAAK,UAAU,UACf,KAAK,QAAQ,KAAK,mBAAmB,KAAK,QAAQ,cAClD;AACA,WAAK,Q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7D;AAKO,MAAM,8BAA8B,MAAM;AAAA,EAC/B;AAAA,EACA;AAAA,EAEhB,YAAY,WAA4B,UAAkB;AACxD,UAAM,OAAO,QAAQ,8BAA8B,UAAU,OAAO,EAAE;AACtE,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,WAAW;AAAA,EAClB;AACF;AAKO,MAAM,yBAAyB,MAAM;AAAA,EAC1C,YAAY,UAAU,2BAA2B;AAC/C,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Taxonomy System
|
|
3
|
+
*
|
|
4
|
+
* Provides structured error classification for intelligent retry strategies
|
|
5
|
+
* and graceful degradation. Based on weaver error handling patterns.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/error-taxonomy
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Error categories for classification and recovery strategy selection
|
|
11
|
+
*/
|
|
12
|
+
export declare enum ErrorCategory {
|
|
13
|
+
/** Transient errors that may succeed on retry (network hiccups, temporary failures) */
|
|
14
|
+
TRANSIENT = "transient",
|
|
15
|
+
/** Permanent errors that won't succeed on retry (invalid input, missing resources) */
|
|
16
|
+
PERMANENT = "permanent",
|
|
17
|
+
/** Rate limit errors requiring backoff (429 responses) */
|
|
18
|
+
RATE_LIMIT = "rate_limit",
|
|
19
|
+
/** Network connectivity errors (DNS, connection refused) */
|
|
20
|
+
NETWORK = "network",
|
|
21
|
+
/** Input validation errors (schema violations, type mismatches) */
|
|
22
|
+
VALIDATION = "validation",
|
|
23
|
+
/** Resource errors (file not found, permissions) */
|
|
24
|
+
RESOURCE = "resource",
|
|
25
|
+
/** Configuration errors (missing config, invalid settings) */
|
|
26
|
+
CONFIGURATION = "configuration",
|
|
27
|
+
/** Timeout errors (operation exceeded time limit) */
|
|
28
|
+
TIMEOUT = "timeout",
|
|
29
|
+
/** Unknown errors that couldn't be classified */
|
|
30
|
+
UNKNOWN = "unknown"
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Error severity levels
|
|
34
|
+
*/
|
|
35
|
+
export declare enum ErrorSeverity {
|
|
36
|
+
/** Informational - operation can continue */
|
|
37
|
+
INFO = "info",
|
|
38
|
+
/** Warning - operation continues with degraded functionality */
|
|
39
|
+
WARNING = "warning",
|
|
40
|
+
/** Error - operation failed but system stable */
|
|
41
|
+
ERROR = "error",
|
|
42
|
+
/** Critical - operation failed, may affect system stability */
|
|
43
|
+
CRITICAL = "critical",
|
|
44
|
+
/** Fatal - system cannot continue */
|
|
45
|
+
FATAL = "fatal"
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Classified error with metadata
|
|
49
|
+
*/
|
|
50
|
+
export interface ClassifiedError {
|
|
51
|
+
/** Original error */
|
|
52
|
+
original: Error | unknown;
|
|
53
|
+
/** Classified category */
|
|
54
|
+
category: ErrorCategory;
|
|
55
|
+
/** Error severity */
|
|
56
|
+
severity: ErrorSeverity;
|
|
57
|
+
/** Whether retry is recommended */
|
|
58
|
+
retryable: boolean;
|
|
59
|
+
/** Suggested delay before retry (milliseconds) */
|
|
60
|
+
suggestedDelay: number;
|
|
61
|
+
/** Error message */
|
|
62
|
+
message: string;
|
|
63
|
+
/** Error code if available */
|
|
64
|
+
code?: string;
|
|
65
|
+
/** HTTP status code if applicable */
|
|
66
|
+
statusCode?: number;
|
|
67
|
+
/** Additional context */
|
|
68
|
+
context?: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Classify an error into a category with recovery metadata
|
|
72
|
+
*
|
|
73
|
+
* @param error - The error to classify
|
|
74
|
+
* @returns Classified error with recovery recommendations
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* try {
|
|
79
|
+
* await fetchData();
|
|
80
|
+
* } catch (error) {
|
|
81
|
+
* const classified = classifyError(error);
|
|
82
|
+
* if (classified.retryable) {
|
|
83
|
+
* await delay(classified.suggestedDelay);
|
|
84
|
+
* return retry();
|
|
85
|
+
* }
|
|
86
|
+
* throw error;
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function classifyError(error: unknown): ClassifiedError;
|
|
91
|
+
/**
|
|
92
|
+
* Check if an error is retryable
|
|
93
|
+
*
|
|
94
|
+
* @param error - The error to check
|
|
95
|
+
* @returns Whether the error is retryable
|
|
96
|
+
*/
|
|
97
|
+
export declare function isRetryableError(error: unknown): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Check if an error is transient (temporary failure)
|
|
100
|
+
*
|
|
101
|
+
* @param error - The error to check
|
|
102
|
+
* @returns Whether the error is transient
|
|
103
|
+
*/
|
|
104
|
+
export declare function isTransientError(error: unknown): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Check if an error is a rate limit error
|
|
107
|
+
*
|
|
108
|
+
* @param error - The error to check
|
|
109
|
+
* @returns Whether the error is a rate limit error
|
|
110
|
+
*/
|
|
111
|
+
export declare function isRateLimitError(error: unknown): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Check if an error is permanent (won't succeed on retry)
|
|
114
|
+
*
|
|
115
|
+
* @param error - The error to check
|
|
116
|
+
* @returns Whether the error is permanent
|
|
117
|
+
*/
|
|
118
|
+
export declare function isPermanentError(error: unknown): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Custom error class for knowledge graph operations
|
|
121
|
+
*/
|
|
122
|
+
export declare class KnowledgeGraphError extends Error {
|
|
123
|
+
readonly category: ErrorCategory;
|
|
124
|
+
readonly severity: ErrorSeverity;
|
|
125
|
+
readonly retryable: boolean;
|
|
126
|
+
readonly code?: string;
|
|
127
|
+
readonly context?: Record<string, unknown>;
|
|
128
|
+
constructor(message: string, options?: {
|
|
129
|
+
category?: ErrorCategory;
|
|
130
|
+
severity?: ErrorSeverity;
|
|
131
|
+
retryable?: boolean;
|
|
132
|
+
code?: string;
|
|
133
|
+
context?: Record<string, unknown>;
|
|
134
|
+
cause?: Error;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Create a validation error
|
|
139
|
+
*/
|
|
140
|
+
export declare function createValidationError(message: string, context?: Record<string, unknown>): KnowledgeGraphError;
|
|
141
|
+
/**
|
|
142
|
+
* Create a configuration error
|
|
143
|
+
*/
|
|
144
|
+
export declare function createConfigurationError(message: string, context?: Record<string, unknown>): KnowledgeGraphError;
|
|
145
|
+
/**
|
|
146
|
+
* Create a resource error
|
|
147
|
+
*/
|
|
148
|
+
export declare function createResourceError(message: string, context?: Record<string, unknown>): KnowledgeGraphError;
|
|
149
|
+
//# sourceMappingURL=error-taxonomy.d.ts.map
|