@dotsetlabs/bellwether 0.10.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/CHANGELOG.md +291 -0
- package/LICENSE +21 -0
- package/README.md +739 -0
- package/dist/auth/credentials.d.ts +64 -0
- package/dist/auth/credentials.js +218 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.js +6 -0
- package/dist/auth/keychain.d.ts +64 -0
- package/dist/auth/keychain.js +268 -0
- package/dist/baseline/ab-testing.d.ts +80 -0
- package/dist/baseline/ab-testing.js +236 -0
- package/dist/baseline/ai-compatibility-scorer.d.ts +95 -0
- package/dist/baseline/ai-compatibility-scorer.js +606 -0
- package/dist/baseline/calibration.d.ts +77 -0
- package/dist/baseline/calibration.js +136 -0
- package/dist/baseline/category-matching.d.ts +85 -0
- package/dist/baseline/category-matching.js +289 -0
- package/dist/baseline/change-impact-analyzer.d.ts +98 -0
- package/dist/baseline/change-impact-analyzer.js +592 -0
- package/dist/baseline/comparator.d.ts +64 -0
- package/dist/baseline/comparator.js +916 -0
- package/dist/baseline/confidence.d.ts +55 -0
- package/dist/baseline/confidence.js +122 -0
- package/dist/baseline/converter.d.ts +61 -0
- package/dist/baseline/converter.js +585 -0
- package/dist/baseline/dependency-analyzer.d.ts +89 -0
- package/dist/baseline/dependency-analyzer.js +567 -0
- package/dist/baseline/deprecation-tracker.d.ts +133 -0
- package/dist/baseline/deprecation-tracker.js +322 -0
- package/dist/baseline/diff.d.ts +55 -0
- package/dist/baseline/diff.js +1584 -0
- package/dist/baseline/documentation-scorer.d.ts +205 -0
- package/dist/baseline/documentation-scorer.js +466 -0
- package/dist/baseline/embeddings.d.ts +118 -0
- package/dist/baseline/embeddings.js +251 -0
- package/dist/baseline/error-analyzer.d.ts +198 -0
- package/dist/baseline/error-analyzer.js +721 -0
- package/dist/baseline/evaluation/evaluator.d.ts +42 -0
- package/dist/baseline/evaluation/evaluator.js +323 -0
- package/dist/baseline/evaluation/expanded-dataset.d.ts +45 -0
- package/dist/baseline/evaluation/expanded-dataset.js +1164 -0
- package/dist/baseline/evaluation/golden-dataset.d.ts +58 -0
- package/dist/baseline/evaluation/golden-dataset.js +717 -0
- package/dist/baseline/evaluation/index.d.ts +15 -0
- package/dist/baseline/evaluation/index.js +15 -0
- package/dist/baseline/evaluation/types.d.ts +186 -0
- package/dist/baseline/evaluation/types.js +8 -0
- package/dist/baseline/external-dependency-detector.d.ts +181 -0
- package/dist/baseline/external-dependency-detector.js +524 -0
- package/dist/baseline/golden-output.d.ts +162 -0
- package/dist/baseline/golden-output.js +636 -0
- package/dist/baseline/health-scorer.d.ts +174 -0
- package/dist/baseline/health-scorer.js +451 -0
- package/dist/baseline/incremental-checker.d.ts +97 -0
- package/dist/baseline/incremental-checker.js +174 -0
- package/dist/baseline/index.d.ts +31 -0
- package/dist/baseline/index.js +42 -0
- package/dist/baseline/migration-generator.d.ts +137 -0
- package/dist/baseline/migration-generator.js +554 -0
- package/dist/baseline/migrations.d.ts +60 -0
- package/dist/baseline/migrations.js +197 -0
- package/dist/baseline/performance-tracker.d.ts +214 -0
- package/dist/baseline/performance-tracker.js +577 -0
- package/dist/baseline/pr-comment-generator.d.ts +117 -0
- package/dist/baseline/pr-comment-generator.js +546 -0
- package/dist/baseline/response-fingerprint.d.ts +127 -0
- package/dist/baseline/response-fingerprint.js +728 -0
- package/dist/baseline/response-schema-tracker.d.ts +129 -0
- package/dist/baseline/response-schema-tracker.js +420 -0
- package/dist/baseline/risk-scorer.d.ts +54 -0
- package/dist/baseline/risk-scorer.js +434 -0
- package/dist/baseline/saver.d.ts +89 -0
- package/dist/baseline/saver.js +554 -0
- package/dist/baseline/scenario-generator.d.ts +151 -0
- package/dist/baseline/scenario-generator.js +905 -0
- package/dist/baseline/schema-compare.d.ts +86 -0
- package/dist/baseline/schema-compare.js +557 -0
- package/dist/baseline/schema-evolution.d.ts +189 -0
- package/dist/baseline/schema-evolution.js +467 -0
- package/dist/baseline/semantic.d.ts +203 -0
- package/dist/baseline/semantic.js +908 -0
- package/dist/baseline/synonyms.d.ts +60 -0
- package/dist/baseline/synonyms.js +386 -0
- package/dist/baseline/telemetry.d.ts +165 -0
- package/dist/baseline/telemetry.js +294 -0
- package/dist/baseline/test-pruner.d.ts +120 -0
- package/dist/baseline/test-pruner.js +387 -0
- package/dist/baseline/types.d.ts +449 -0
- package/dist/baseline/types.js +5 -0
- package/dist/baseline/version.d.ts +138 -0
- package/dist/baseline/version.js +206 -0
- package/dist/cache/index.d.ts +5 -0
- package/dist/cache/index.js +5 -0
- package/dist/cache/response-cache.d.ts +151 -0
- package/dist/cache/response-cache.js +287 -0
- package/dist/ci/index.d.ts +60 -0
- package/dist/ci/index.js +342 -0
- package/dist/cli/commands/auth.d.ts +12 -0
- package/dist/cli/commands/auth.js +352 -0
- package/dist/cli/commands/badge.d.ts +3 -0
- package/dist/cli/commands/badge.js +74 -0
- package/dist/cli/commands/baseline-accept.d.ts +15 -0
- package/dist/cli/commands/baseline-accept.js +178 -0
- package/dist/cli/commands/baseline-migrate.d.ts +12 -0
- package/dist/cli/commands/baseline-migrate.js +164 -0
- package/dist/cli/commands/baseline.d.ts +14 -0
- package/dist/cli/commands/baseline.js +449 -0
- package/dist/cli/commands/beta.d.ts +10 -0
- package/dist/cli/commands/beta.js +231 -0
- package/dist/cli/commands/check.d.ts +11 -0
- package/dist/cli/commands/check.js +820 -0
- package/dist/cli/commands/cloud/badge.d.ts +3 -0
- package/dist/cli/commands/cloud/badge.js +74 -0
- package/dist/cli/commands/cloud/diff.d.ts +6 -0
- package/dist/cli/commands/cloud/diff.js +79 -0
- package/dist/cli/commands/cloud/history.d.ts +6 -0
- package/dist/cli/commands/cloud/history.js +102 -0
- package/dist/cli/commands/cloud/link.d.ts +9 -0
- package/dist/cli/commands/cloud/link.js +119 -0
- package/dist/cli/commands/cloud/login.d.ts +7 -0
- package/dist/cli/commands/cloud/login.js +499 -0
- package/dist/cli/commands/cloud/projects.d.ts +6 -0
- package/dist/cli/commands/cloud/projects.js +44 -0
- package/dist/cli/commands/cloud/shared.d.ts +7 -0
- package/dist/cli/commands/cloud/shared.js +42 -0
- package/dist/cli/commands/cloud/teams.d.ts +8 -0
- package/dist/cli/commands/cloud/teams.js +169 -0
- package/dist/cli/commands/cloud/upload.d.ts +8 -0
- package/dist/cli/commands/cloud/upload.js +181 -0
- package/dist/cli/commands/contract.d.ts +11 -0
- package/dist/cli/commands/contract.js +280 -0
- package/dist/cli/commands/discover.d.ts +3 -0
- package/dist/cli/commands/discover.js +82 -0
- package/dist/cli/commands/eval.d.ts +9 -0
- package/dist/cli/commands/eval.js +187 -0
- package/dist/cli/commands/explore.d.ts +11 -0
- package/dist/cli/commands/explore.js +437 -0
- package/dist/cli/commands/feedback.d.ts +9 -0
- package/dist/cli/commands/feedback.js +174 -0
- package/dist/cli/commands/golden.d.ts +12 -0
- package/dist/cli/commands/golden.js +407 -0
- package/dist/cli/commands/history.d.ts +10 -0
- package/dist/cli/commands/history.js +202 -0
- package/dist/cli/commands/init.d.ts +9 -0
- package/dist/cli/commands/init.js +219 -0
- package/dist/cli/commands/interview.d.ts +3 -0
- package/dist/cli/commands/interview.js +903 -0
- package/dist/cli/commands/link.d.ts +10 -0
- package/dist/cli/commands/link.js +169 -0
- package/dist/cli/commands/login.d.ts +7 -0
- package/dist/cli/commands/login.js +499 -0
- package/dist/cli/commands/preset.d.ts +33 -0
- package/dist/cli/commands/preset.js +297 -0
- package/dist/cli/commands/profile.d.ts +33 -0
- package/dist/cli/commands/profile.js +286 -0
- package/dist/cli/commands/registry.d.ts +11 -0
- package/dist/cli/commands/registry.js +146 -0
- package/dist/cli/commands/shared.d.ts +79 -0
- package/dist/cli/commands/shared.js +196 -0
- package/dist/cli/commands/teams.d.ts +8 -0
- package/dist/cli/commands/teams.js +169 -0
- package/dist/cli/commands/test.d.ts +9 -0
- package/dist/cli/commands/test.js +500 -0
- package/dist/cli/commands/upload.d.ts +8 -0
- package/dist/cli/commands/upload.js +223 -0
- package/dist/cli/commands/validate-config.d.ts +6 -0
- package/dist/cli/commands/validate-config.js +35 -0
- package/dist/cli/commands/verify.d.ts +11 -0
- package/dist/cli/commands/verify.js +283 -0
- package/dist/cli/commands/watch.d.ts +12 -0
- package/dist/cli/commands/watch.js +253 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +178 -0
- package/dist/cli/interactive.d.ts +47 -0
- package/dist/cli/interactive.js +216 -0
- package/dist/cli/output/terminal-reporter.d.ts +19 -0
- package/dist/cli/output/terminal-reporter.js +104 -0
- package/dist/cli/output.d.ts +226 -0
- package/dist/cli/output.js +438 -0
- package/dist/cli/utils/env.d.ts +5 -0
- package/dist/cli/utils/env.js +14 -0
- package/dist/cli/utils/progress.d.ts +59 -0
- package/dist/cli/utils/progress.js +206 -0
- package/dist/cli/utils/server-context.d.ts +10 -0
- package/dist/cli/utils/server-context.js +36 -0
- package/dist/cloud/auth.d.ts +144 -0
- package/dist/cloud/auth.js +374 -0
- package/dist/cloud/client.d.ts +24 -0
- package/dist/cloud/client.js +65 -0
- package/dist/cloud/http-client.d.ts +38 -0
- package/dist/cloud/http-client.js +215 -0
- package/dist/cloud/index.d.ts +23 -0
- package/dist/cloud/index.js +25 -0
- package/dist/cloud/mock-client.d.ts +107 -0
- package/dist/cloud/mock-client.js +545 -0
- package/dist/cloud/types.d.ts +515 -0
- package/dist/cloud/types.js +15 -0
- package/dist/config/defaults.d.ts +160 -0
- package/dist/config/defaults.js +169 -0
- package/dist/config/loader.d.ts +24 -0
- package/dist/config/loader.js +122 -0
- package/dist/config/template.d.ts +42 -0
- package/dist/config/template.js +647 -0
- package/dist/config/validator.d.ts +2112 -0
- package/dist/config/validator.js +658 -0
- package/dist/constants/cloud.d.ts +107 -0
- package/dist/constants/cloud.js +110 -0
- package/dist/constants/core.d.ts +521 -0
- package/dist/constants/core.js +556 -0
- package/dist/constants/testing.d.ts +1283 -0
- package/dist/constants/testing.js +1568 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.js +10 -0
- package/dist/contract/index.d.ts +6 -0
- package/dist/contract/index.js +5 -0
- package/dist/contract/validator.d.ts +177 -0
- package/dist/contract/validator.js +574 -0
- package/dist/cost/index.d.ts +6 -0
- package/dist/cost/index.js +5 -0
- package/dist/cost/tracker.d.ts +134 -0
- package/dist/cost/tracker.js +313 -0
- package/dist/discovery/discovery.d.ts +16 -0
- package/dist/discovery/discovery.js +173 -0
- package/dist/discovery/types.d.ts +51 -0
- package/dist/discovery/types.js +2 -0
- package/dist/docs/agents.d.ts +3 -0
- package/dist/docs/agents.js +995 -0
- package/dist/docs/contract.d.ts +51 -0
- package/dist/docs/contract.js +1681 -0
- package/dist/docs/generator.d.ts +4 -0
- package/dist/docs/generator.js +4 -0
- package/dist/docs/html-reporter.d.ts +9 -0
- package/dist/docs/html-reporter.js +757 -0
- package/dist/docs/index.d.ts +10 -0
- package/dist/docs/index.js +11 -0
- package/dist/docs/junit-reporter.d.ts +18 -0
- package/dist/docs/junit-reporter.js +210 -0
- package/dist/docs/report.d.ts +14 -0
- package/dist/docs/report.js +44 -0
- package/dist/docs/sarif-reporter.d.ts +19 -0
- package/dist/docs/sarif-reporter.js +335 -0
- package/dist/docs/shared.d.ts +35 -0
- package/dist/docs/shared.js +162 -0
- package/dist/docs/templates.d.ts +12 -0
- package/dist/docs/templates.js +76 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.js +6 -0
- package/dist/errors/retry.d.ts +92 -0
- package/dist/errors/retry.js +323 -0
- package/dist/errors/types.d.ts +321 -0
- package/dist/errors/types.js +584 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +32 -0
- package/dist/interview/dependency-resolver.d.ts +11 -0
- package/dist/interview/dependency-resolver.js +32 -0
- package/dist/interview/interviewer.d.ts +232 -0
- package/dist/interview/interviewer.js +1939 -0
- package/dist/interview/mock-response-generator.d.ts +7 -0
- package/dist/interview/mock-response-generator.js +102 -0
- package/dist/interview/orchestrator.d.ts +237 -0
- package/dist/interview/orchestrator.js +1296 -0
- package/dist/interview/rate-limiter.d.ts +15 -0
- package/dist/interview/rate-limiter.js +55 -0
- package/dist/interview/response-validator.d.ts +10 -0
- package/dist/interview/response-validator.js +132 -0
- package/dist/interview/schema-inferrer.d.ts +8 -0
- package/dist/interview/schema-inferrer.js +71 -0
- package/dist/interview/schema-test-generator.d.ts +71 -0
- package/dist/interview/schema-test-generator.js +834 -0
- package/dist/interview/smart-value-generator.d.ts +155 -0
- package/dist/interview/smart-value-generator.js +554 -0
- package/dist/interview/stateful-test-runner.d.ts +19 -0
- package/dist/interview/stateful-test-runner.js +106 -0
- package/dist/interview/types.d.ts +561 -0
- package/dist/interview/types.js +2 -0
- package/dist/llm/anthropic.d.ts +41 -0
- package/dist/llm/anthropic.js +355 -0
- package/dist/llm/client.d.ts +123 -0
- package/dist/llm/client.js +42 -0
- package/dist/llm/factory.d.ts +38 -0
- package/dist/llm/factory.js +145 -0
- package/dist/llm/fallback.d.ts +140 -0
- package/dist/llm/fallback.js +379 -0
- package/dist/llm/index.d.ts +18 -0
- package/dist/llm/index.js +15 -0
- package/dist/llm/ollama.d.ts +37 -0
- package/dist/llm/ollama.js +330 -0
- package/dist/llm/openai.d.ts +25 -0
- package/dist/llm/openai.js +320 -0
- package/dist/llm/token-budget.d.ts +161 -0
- package/dist/llm/token-budget.js +395 -0
- package/dist/logging/logger.d.ts +70 -0
- package/dist/logging/logger.js +130 -0
- package/dist/metrics/collector.d.ts +106 -0
- package/dist/metrics/collector.js +547 -0
- package/dist/metrics/index.d.ts +7 -0
- package/dist/metrics/index.js +7 -0
- package/dist/metrics/prometheus.d.ts +20 -0
- package/dist/metrics/prometheus.js +241 -0
- package/dist/metrics/types.d.ts +209 -0
- package/dist/metrics/types.js +5 -0
- package/dist/persona/builtins.d.ts +54 -0
- package/dist/persona/builtins.js +219 -0
- package/dist/persona/index.d.ts +8 -0
- package/dist/persona/index.js +8 -0
- package/dist/persona/loader.d.ts +30 -0
- package/dist/persona/loader.js +190 -0
- package/dist/persona/types.d.ts +144 -0
- package/dist/persona/types.js +5 -0
- package/dist/persona/validation.d.ts +94 -0
- package/dist/persona/validation.js +332 -0
- package/dist/prompts/index.d.ts +5 -0
- package/dist/prompts/index.js +5 -0
- package/dist/prompts/templates.d.ts +180 -0
- package/dist/prompts/templates.js +431 -0
- package/dist/registry/client.d.ts +49 -0
- package/dist/registry/client.js +191 -0
- package/dist/registry/index.d.ts +7 -0
- package/dist/registry/index.js +6 -0
- package/dist/registry/types.d.ts +140 -0
- package/dist/registry/types.js +6 -0
- package/dist/scenarios/evaluator.d.ts +43 -0
- package/dist/scenarios/evaluator.js +206 -0
- package/dist/scenarios/index.d.ts +10 -0
- package/dist/scenarios/index.js +9 -0
- package/dist/scenarios/loader.d.ts +20 -0
- package/dist/scenarios/loader.js +285 -0
- package/dist/scenarios/types.d.ts +153 -0
- package/dist/scenarios/types.js +8 -0
- package/dist/security/index.d.ts +17 -0
- package/dist/security/index.js +18 -0
- package/dist/security/payloads.d.ts +61 -0
- package/dist/security/payloads.js +268 -0
- package/dist/security/security-tester.d.ts +42 -0
- package/dist/security/security-tester.js +582 -0
- package/dist/security/types.d.ts +166 -0
- package/dist/security/types.js +8 -0
- package/dist/transport/base-transport.d.ts +59 -0
- package/dist/transport/base-transport.js +38 -0
- package/dist/transport/http-transport.d.ts +67 -0
- package/dist/transport/http-transport.js +238 -0
- package/dist/transport/mcp-client.d.ts +141 -0
- package/dist/transport/mcp-client.js +496 -0
- package/dist/transport/sse-transport.d.ts +88 -0
- package/dist/transport/sse-transport.js +316 -0
- package/dist/transport/stdio-transport.d.ts +43 -0
- package/dist/transport/stdio-transport.js +238 -0
- package/dist/transport/types.d.ts +125 -0
- package/dist/transport/types.js +16 -0
- package/dist/utils/concurrency.d.ts +123 -0
- package/dist/utils/concurrency.js +213 -0
- package/dist/utils/formatters.d.ts +16 -0
- package/dist/utils/formatters.js +37 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/jsonpath.d.ts +87 -0
- package/dist/utils/jsonpath.js +326 -0
- package/dist/utils/markdown.d.ts +113 -0
- package/dist/utils/markdown.js +265 -0
- package/dist/utils/network.d.ts +14 -0
- package/dist/utils/network.js +17 -0
- package/dist/utils/sanitize.d.ts +92 -0
- package/dist/utils/sanitize.js +191 -0
- package/dist/utils/semantic.d.ts +194 -0
- package/dist/utils/semantic.js +1051 -0
- package/dist/utils/smart-truncate.d.ts +94 -0
- package/dist/utils/smart-truncate.js +361 -0
- package/dist/utils/timeout.d.ts +153 -0
- package/dist/utils/timeout.js +205 -0
- package/dist/utils/yaml-parser.d.ts +58 -0
- package/dist/utils/yaml-parser.js +86 -0
- package/dist/validation/index.d.ts +32 -0
- package/dist/validation/index.js +32 -0
- package/dist/validation/semantic-test-generator.d.ts +50 -0
- package/dist/validation/semantic-test-generator.js +176 -0
- package/dist/validation/semantic-types.d.ts +66 -0
- package/dist/validation/semantic-types.js +94 -0
- package/dist/validation/semantic-validator.d.ts +38 -0
- package/dist/validation/semantic-validator.js +340 -0
- package/dist/verification/index.d.ts +6 -0
- package/dist/verification/index.js +5 -0
- package/dist/verification/types.d.ts +133 -0
- package/dist/verification/types.js +5 -0
- package/dist/verification/verifier.d.ts +30 -0
- package/dist/verification/verifier.js +309 -0
- package/dist/version.d.ts +19 -0
- package/dist/version.js +48 -0
- package/dist/workflow/auto-generator.d.ts +27 -0
- package/dist/workflow/auto-generator.js +513 -0
- package/dist/workflow/discovery.d.ts +40 -0
- package/dist/workflow/discovery.js +195 -0
- package/dist/workflow/executor.d.ts +82 -0
- package/dist/workflow/executor.js +611 -0
- package/dist/workflow/index.d.ts +10 -0
- package/dist/workflow/index.js +10 -0
- package/dist/workflow/loader.d.ts +24 -0
- package/dist/workflow/loader.js +194 -0
- package/dist/workflow/state-tracker.d.ts +98 -0
- package/dist/workflow/state-tracker.js +424 -0
- package/dist/workflow/types.d.ts +337 -0
- package/dist/workflow/types.js +5 -0
- package/package.json +94 -0
- package/schemas/bellwether-check.schema.json +651 -0
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comprehensive error types for Bellwether.
|
|
3
|
+
*
|
|
4
|
+
* Error hierarchy:
|
|
5
|
+
* - BellwetherError (base)
|
|
6
|
+
* - TransportError (MCP communication)
|
|
7
|
+
* - LLMError (LLM provider issues)
|
|
8
|
+
* - InterviewError (interview execution)
|
|
9
|
+
* - WorkflowError (workflow execution)
|
|
10
|
+
* - ConfigError (configuration issues)
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Base error class for all Bellwether errors.
|
|
14
|
+
*/
|
|
15
|
+
export class BellwetherError extends Error {
|
|
16
|
+
/** Error code for programmatic handling */
|
|
17
|
+
code;
|
|
18
|
+
/** Error severity */
|
|
19
|
+
severity;
|
|
20
|
+
/** Whether this error is retryable */
|
|
21
|
+
retryable;
|
|
22
|
+
/** Error context for debugging */
|
|
23
|
+
context;
|
|
24
|
+
/** Original error if this wraps another */
|
|
25
|
+
cause;
|
|
26
|
+
constructor(message, options) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.name = 'BellwetherError';
|
|
29
|
+
this.code = options.code;
|
|
30
|
+
this.severity = options.severity ?? 'medium';
|
|
31
|
+
this.retryable = options.retryable ?? 'unknown';
|
|
32
|
+
this.context = options.context ?? {};
|
|
33
|
+
this.cause = options.cause;
|
|
34
|
+
// Maintain proper stack trace
|
|
35
|
+
if (Error.captureStackTrace) {
|
|
36
|
+
Error.captureStackTrace(this, this.constructor);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create a new error with additional context.
|
|
41
|
+
*/
|
|
42
|
+
withContext(additionalContext) {
|
|
43
|
+
return new BellwetherError(this.message, {
|
|
44
|
+
code: this.code,
|
|
45
|
+
severity: this.severity,
|
|
46
|
+
retryable: this.retryable,
|
|
47
|
+
context: { ...this.context, ...additionalContext },
|
|
48
|
+
cause: this.cause,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Convert to JSON for logging.
|
|
53
|
+
*/
|
|
54
|
+
toJSON() {
|
|
55
|
+
return {
|
|
56
|
+
name: this.name,
|
|
57
|
+
code: this.code,
|
|
58
|
+
message: this.message,
|
|
59
|
+
severity: this.severity,
|
|
60
|
+
retryable: this.retryable,
|
|
61
|
+
context: this.context,
|
|
62
|
+
cause: this.cause
|
|
63
|
+
? {
|
|
64
|
+
name: this.cause.name,
|
|
65
|
+
message: this.cause.message,
|
|
66
|
+
}
|
|
67
|
+
: undefined,
|
|
68
|
+
stack: this.stack,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Base class for transport-related errors.
|
|
74
|
+
*/
|
|
75
|
+
export class TransportError extends BellwetherError {
|
|
76
|
+
constructor(message, options) {
|
|
77
|
+
super(message, options);
|
|
78
|
+
this.name = 'TransportError';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Connection failed or was lost.
|
|
83
|
+
*/
|
|
84
|
+
export class ConnectionError extends TransportError {
|
|
85
|
+
constructor(message, context, cause) {
|
|
86
|
+
super(message, {
|
|
87
|
+
code: 'TRANSPORT_CONNECTION_FAILED',
|
|
88
|
+
severity: 'high',
|
|
89
|
+
retryable: 'retryable',
|
|
90
|
+
context,
|
|
91
|
+
cause,
|
|
92
|
+
});
|
|
93
|
+
this.name = 'ConnectionError';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Request timed out.
|
|
98
|
+
*/
|
|
99
|
+
export class TimeoutError extends TransportError {
|
|
100
|
+
/** Timeout value in milliseconds */
|
|
101
|
+
timeoutMs;
|
|
102
|
+
constructor(message, timeoutMs, context, cause) {
|
|
103
|
+
super(message, {
|
|
104
|
+
code: 'TRANSPORT_TIMEOUT',
|
|
105
|
+
severity: 'medium',
|
|
106
|
+
retryable: 'retryable',
|
|
107
|
+
context: { ...context, metadata: { ...context?.metadata, timeoutMs } },
|
|
108
|
+
cause,
|
|
109
|
+
});
|
|
110
|
+
this.name = 'TimeoutError';
|
|
111
|
+
this.timeoutMs = timeoutMs;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Server process exited unexpectedly.
|
|
116
|
+
*/
|
|
117
|
+
export class ServerExitError extends TransportError {
|
|
118
|
+
/** Exit code if available */
|
|
119
|
+
exitCode;
|
|
120
|
+
/** Exit signal if available */
|
|
121
|
+
signal;
|
|
122
|
+
constructor(message, exitCode, signal, context) {
|
|
123
|
+
super(message, {
|
|
124
|
+
code: 'TRANSPORT_SERVER_EXIT',
|
|
125
|
+
severity: 'high',
|
|
126
|
+
retryable: 'terminal',
|
|
127
|
+
context: { ...context, metadata: { ...context?.metadata, exitCode, signal } },
|
|
128
|
+
});
|
|
129
|
+
this.name = 'ServerExitError';
|
|
130
|
+
this.exitCode = exitCode;
|
|
131
|
+
this.signal = signal;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Protocol error (invalid message format, etc).
|
|
136
|
+
*/
|
|
137
|
+
export class ProtocolError extends TransportError {
|
|
138
|
+
constructor(message, context, cause) {
|
|
139
|
+
super(message, {
|
|
140
|
+
code: 'TRANSPORT_PROTOCOL_ERROR',
|
|
141
|
+
severity: 'high',
|
|
142
|
+
retryable: 'terminal',
|
|
143
|
+
context,
|
|
144
|
+
cause,
|
|
145
|
+
});
|
|
146
|
+
this.name = 'ProtocolError';
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Buffer overflow during message processing.
|
|
151
|
+
*/
|
|
152
|
+
export class BufferOverflowError extends TransportError {
|
|
153
|
+
/** Current buffer size */
|
|
154
|
+
bufferSize;
|
|
155
|
+
/** Maximum allowed size */
|
|
156
|
+
maxSize;
|
|
157
|
+
constructor(bufferSize, maxSize, context) {
|
|
158
|
+
super(`Buffer overflow: ${bufferSize} bytes exceeds maximum ${maxSize} bytes`, {
|
|
159
|
+
code: 'TRANSPORT_BUFFER_OVERFLOW',
|
|
160
|
+
severity: 'high',
|
|
161
|
+
retryable: 'terminal',
|
|
162
|
+
context: { ...context, metadata: { bufferSize, maxSize } },
|
|
163
|
+
});
|
|
164
|
+
this.name = 'BufferOverflowError';
|
|
165
|
+
this.bufferSize = bufferSize;
|
|
166
|
+
this.maxSize = maxSize;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Base class for LLM-related errors.
|
|
171
|
+
*/
|
|
172
|
+
export class LLMError extends BellwetherError {
|
|
173
|
+
/** LLM provider name */
|
|
174
|
+
provider;
|
|
175
|
+
/** Model name if available */
|
|
176
|
+
model;
|
|
177
|
+
constructor(message, provider, options) {
|
|
178
|
+
super(message, {
|
|
179
|
+
code: options.code,
|
|
180
|
+
severity: options.severity,
|
|
181
|
+
retryable: options.retryable,
|
|
182
|
+
context: {
|
|
183
|
+
...options.context,
|
|
184
|
+
metadata: { ...options.context?.metadata, provider, model: options.model },
|
|
185
|
+
},
|
|
186
|
+
cause: options.cause,
|
|
187
|
+
});
|
|
188
|
+
this.name = 'LLMError';
|
|
189
|
+
this.provider = provider;
|
|
190
|
+
this.model = options.model;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Authentication/API key error.
|
|
195
|
+
*/
|
|
196
|
+
export class LLMAuthError extends LLMError {
|
|
197
|
+
constructor(provider, model, context, cause) {
|
|
198
|
+
super('LLM authentication failed - check API key', provider, {
|
|
199
|
+
code: 'LLM_AUTH_FAILED',
|
|
200
|
+
model,
|
|
201
|
+
severity: 'critical',
|
|
202
|
+
retryable: 'terminal',
|
|
203
|
+
context,
|
|
204
|
+
cause,
|
|
205
|
+
});
|
|
206
|
+
this.name = 'LLMAuthError';
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Rate limit exceeded.
|
|
211
|
+
*/
|
|
212
|
+
export class LLMRateLimitError extends LLMError {
|
|
213
|
+
/** Retry after in milliseconds if known */
|
|
214
|
+
retryAfterMs;
|
|
215
|
+
constructor(provider, retryAfterMs, model, context, cause) {
|
|
216
|
+
super('LLM rate limit exceeded', provider, {
|
|
217
|
+
code: 'LLM_RATE_LIMITED',
|
|
218
|
+
model,
|
|
219
|
+
severity: 'medium',
|
|
220
|
+
retryable: 'retryable',
|
|
221
|
+
context: { ...context, metadata: { ...context?.metadata, retryAfterMs } },
|
|
222
|
+
cause,
|
|
223
|
+
});
|
|
224
|
+
this.name = 'LLMRateLimitError';
|
|
225
|
+
this.retryAfterMs = retryAfterMs;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Quota/credits exhausted.
|
|
230
|
+
*/
|
|
231
|
+
export class LLMQuotaError extends LLMError {
|
|
232
|
+
constructor(provider, model, context, cause) {
|
|
233
|
+
super('LLM quota or credits exhausted', provider, {
|
|
234
|
+
code: 'LLM_QUOTA_EXHAUSTED',
|
|
235
|
+
model,
|
|
236
|
+
severity: 'critical',
|
|
237
|
+
retryable: 'terminal',
|
|
238
|
+
context,
|
|
239
|
+
cause,
|
|
240
|
+
});
|
|
241
|
+
this.name = 'LLMQuotaError';
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Model refused to complete request (content policy, etc).
|
|
246
|
+
*/
|
|
247
|
+
export class LLMRefusalError extends LLMError {
|
|
248
|
+
/** Refusal reason if available */
|
|
249
|
+
reason;
|
|
250
|
+
constructor(provider, reason, model, context, cause) {
|
|
251
|
+
super(reason ? `LLM refused request: ${reason}` : 'LLM refused request', provider, {
|
|
252
|
+
code: 'LLM_REFUSED',
|
|
253
|
+
model,
|
|
254
|
+
severity: 'medium',
|
|
255
|
+
retryable: 'terminal', // Different prompt might work, but same prompt won't
|
|
256
|
+
context: { ...context, metadata: { ...context?.metadata, reason } },
|
|
257
|
+
cause,
|
|
258
|
+
});
|
|
259
|
+
this.name = 'LLMRefusalError';
|
|
260
|
+
this.reason = reason;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* LLM response parsing failed.
|
|
265
|
+
*/
|
|
266
|
+
export class LLMParseError extends LLMError {
|
|
267
|
+
/** Raw response that couldn't be parsed */
|
|
268
|
+
rawResponse;
|
|
269
|
+
constructor(provider, rawResponse, model, context, cause) {
|
|
270
|
+
super('Failed to parse LLM response', provider, {
|
|
271
|
+
code: 'LLM_PARSE_ERROR',
|
|
272
|
+
model,
|
|
273
|
+
severity: 'medium',
|
|
274
|
+
retryable: 'retryable', // Different response might parse
|
|
275
|
+
context: {
|
|
276
|
+
...context,
|
|
277
|
+
metadata: {
|
|
278
|
+
...context?.metadata,
|
|
279
|
+
rawResponsePreview: rawResponse?.slice(0, 200),
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
cause,
|
|
283
|
+
});
|
|
284
|
+
this.name = 'LLMParseError';
|
|
285
|
+
this.rawResponse = rawResponse;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* LLM connection failed.
|
|
290
|
+
*/
|
|
291
|
+
export class LLMConnectionError extends LLMError {
|
|
292
|
+
constructor(provider, model, context, cause) {
|
|
293
|
+
super(`Failed to connect to LLM provider: ${provider}`, provider, {
|
|
294
|
+
code: 'LLM_CONNECTION_FAILED',
|
|
295
|
+
model,
|
|
296
|
+
severity: 'high',
|
|
297
|
+
retryable: 'retryable',
|
|
298
|
+
context,
|
|
299
|
+
cause,
|
|
300
|
+
});
|
|
301
|
+
this.name = 'LLMConnectionError';
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Base class for interview-related errors.
|
|
306
|
+
*/
|
|
307
|
+
export class InterviewError extends BellwetherError {
|
|
308
|
+
constructor(message, options) {
|
|
309
|
+
super(message, options);
|
|
310
|
+
this.name = 'InterviewError';
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Tool call failed.
|
|
315
|
+
*/
|
|
316
|
+
export class ToolCallError extends InterviewError {
|
|
317
|
+
/** Tool name */
|
|
318
|
+
toolName;
|
|
319
|
+
/** Arguments passed to tool */
|
|
320
|
+
args;
|
|
321
|
+
constructor(toolName, args, message, context, cause) {
|
|
322
|
+
super(`Tool call failed for '${toolName}': ${message}`, {
|
|
323
|
+
code: 'INTERVIEW_TOOL_CALL_FAILED',
|
|
324
|
+
severity: 'medium',
|
|
325
|
+
retryable: 'retryable',
|
|
326
|
+
context: { ...context, tool: toolName, metadata: { ...context?.metadata, args } },
|
|
327
|
+
cause,
|
|
328
|
+
});
|
|
329
|
+
this.name = 'ToolCallError';
|
|
330
|
+
this.toolName = toolName;
|
|
331
|
+
this.args = args;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Discovery failed.
|
|
336
|
+
*/
|
|
337
|
+
export class DiscoveryError extends InterviewError {
|
|
338
|
+
constructor(message, context, cause) {
|
|
339
|
+
super(`Server discovery failed: ${message}`, {
|
|
340
|
+
code: 'INTERVIEW_DISCOVERY_FAILED',
|
|
341
|
+
severity: 'high',
|
|
342
|
+
retryable: 'retryable',
|
|
343
|
+
context,
|
|
344
|
+
cause,
|
|
345
|
+
});
|
|
346
|
+
this.name = 'DiscoveryError';
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Question generation failed.
|
|
351
|
+
*/
|
|
352
|
+
export class QuestionGenerationError extends InterviewError {
|
|
353
|
+
constructor(toolName, context, cause) {
|
|
354
|
+
super(`Failed to generate questions for tool '${toolName}'`, {
|
|
355
|
+
code: 'INTERVIEW_QUESTION_GEN_FAILED',
|
|
356
|
+
severity: 'low',
|
|
357
|
+
retryable: 'retryable',
|
|
358
|
+
context: { ...context, tool: toolName },
|
|
359
|
+
cause,
|
|
360
|
+
});
|
|
361
|
+
this.name = 'QuestionGenerationError';
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Analysis/synthesis failed.
|
|
366
|
+
*/
|
|
367
|
+
export class AnalysisError extends InterviewError {
|
|
368
|
+
constructor(phase, context, cause) {
|
|
369
|
+
super(`Failed to analyze ${phase}`, {
|
|
370
|
+
code: `INTERVIEW_${phase.toUpperCase()}_ANALYSIS_FAILED`,
|
|
371
|
+
severity: 'low',
|
|
372
|
+
retryable: 'retryable',
|
|
373
|
+
context: { ...context, metadata: { ...context?.metadata, phase } },
|
|
374
|
+
cause,
|
|
375
|
+
});
|
|
376
|
+
this.name = 'AnalysisError';
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Base class for workflow-related errors.
|
|
381
|
+
*/
|
|
382
|
+
export class WorkflowError extends BellwetherError {
|
|
383
|
+
/** Workflow ID */
|
|
384
|
+
workflowId;
|
|
385
|
+
/** Workflow name */
|
|
386
|
+
workflowName;
|
|
387
|
+
constructor(message, workflowId, options) {
|
|
388
|
+
super(message, {
|
|
389
|
+
code: options.code,
|
|
390
|
+
severity: options.severity,
|
|
391
|
+
retryable: options.retryable,
|
|
392
|
+
context: {
|
|
393
|
+
...options.context,
|
|
394
|
+
workflow: workflowId,
|
|
395
|
+
metadata: { ...options.context?.metadata, workflowName: options.workflowName },
|
|
396
|
+
},
|
|
397
|
+
cause: options.cause,
|
|
398
|
+
});
|
|
399
|
+
this.name = 'WorkflowError';
|
|
400
|
+
this.workflowId = workflowId;
|
|
401
|
+
this.workflowName = options.workflowName;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Workflow step failed.
|
|
406
|
+
*/
|
|
407
|
+
export class WorkflowStepError extends WorkflowError {
|
|
408
|
+
/** Step index (0-based) */
|
|
409
|
+
stepIndex;
|
|
410
|
+
/** Tool name for this step */
|
|
411
|
+
toolName;
|
|
412
|
+
constructor(workflowId, stepIndex, toolName, message, workflowName, context, cause) {
|
|
413
|
+
super(`Workflow step ${stepIndex + 1} failed (${toolName}): ${message}`, workflowId, {
|
|
414
|
+
code: 'WORKFLOW_STEP_FAILED',
|
|
415
|
+
workflowName,
|
|
416
|
+
severity: 'medium',
|
|
417
|
+
retryable: 'retryable',
|
|
418
|
+
context: { ...context, stepIndex, tool: toolName },
|
|
419
|
+
cause,
|
|
420
|
+
});
|
|
421
|
+
this.name = 'WorkflowStepError';
|
|
422
|
+
this.stepIndex = stepIndex;
|
|
423
|
+
this.toolName = toolName;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Argument resolution failed (JSON path evaluation).
|
|
428
|
+
*/
|
|
429
|
+
export class ArgResolutionError extends WorkflowError {
|
|
430
|
+
/** The path expression that failed */
|
|
431
|
+
pathExpression;
|
|
432
|
+
/** Step index where resolution failed */
|
|
433
|
+
stepIndex;
|
|
434
|
+
constructor(workflowId, stepIndex, pathExpression, message, workflowName, context) {
|
|
435
|
+
super(`Argument resolution failed at step ${stepIndex + 1}: ${message}`, workflowId, {
|
|
436
|
+
code: 'WORKFLOW_ARG_RESOLUTION_FAILED',
|
|
437
|
+
workflowName,
|
|
438
|
+
severity: 'medium',
|
|
439
|
+
retryable: 'terminal', // Path expression won't change
|
|
440
|
+
context: {
|
|
441
|
+
...context,
|
|
442
|
+
stepIndex,
|
|
443
|
+
metadata: { ...context?.metadata, pathExpression },
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
this.name = 'ArgResolutionError';
|
|
447
|
+
this.pathExpression = pathExpression;
|
|
448
|
+
this.stepIndex = stepIndex;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Assertion failed during workflow execution.
|
|
453
|
+
*/
|
|
454
|
+
export class AssertionError extends WorkflowError {
|
|
455
|
+
/** The assertion that failed */
|
|
456
|
+
assertion;
|
|
457
|
+
/** Actual value received */
|
|
458
|
+
actualValue;
|
|
459
|
+
constructor(workflowId, stepIndex, assertion, actualValue, workflowName, context) {
|
|
460
|
+
super(`Assertion failed at step ${stepIndex + 1}: ${assertion}`, workflowId, {
|
|
461
|
+
code: 'WORKFLOW_ASSERTION_FAILED',
|
|
462
|
+
workflowName,
|
|
463
|
+
severity: 'medium',
|
|
464
|
+
retryable: 'terminal', // Same input = same assertion failure
|
|
465
|
+
context: {
|
|
466
|
+
...context,
|
|
467
|
+
stepIndex,
|
|
468
|
+
metadata: { ...context?.metadata, assertion, actualValue },
|
|
469
|
+
},
|
|
470
|
+
});
|
|
471
|
+
this.name = 'AssertionError';
|
|
472
|
+
this.assertion = assertion;
|
|
473
|
+
this.actualValue = actualValue;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Configuration-related error.
|
|
478
|
+
*/
|
|
479
|
+
export class ConfigError extends BellwetherError {
|
|
480
|
+
constructor(message, context, cause) {
|
|
481
|
+
super(message, {
|
|
482
|
+
code: 'CONFIG_ERROR',
|
|
483
|
+
severity: 'high',
|
|
484
|
+
retryable: 'terminal',
|
|
485
|
+
context,
|
|
486
|
+
cause,
|
|
487
|
+
});
|
|
488
|
+
this.name = 'ConfigError';
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Configuration file not found.
|
|
493
|
+
*/
|
|
494
|
+
export class ConfigNotFoundError extends ConfigError {
|
|
495
|
+
/** Path that was searched */
|
|
496
|
+
path;
|
|
497
|
+
constructor(path, context) {
|
|
498
|
+
super(`Configuration file not found: ${path}`, {
|
|
499
|
+
...context,
|
|
500
|
+
metadata: { ...context?.metadata, path },
|
|
501
|
+
});
|
|
502
|
+
this.name = 'ConfigNotFoundError';
|
|
503
|
+
this.path = path;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Configuration validation failed.
|
|
508
|
+
*/
|
|
509
|
+
export class ConfigValidationError extends ConfigError {
|
|
510
|
+
/** Validation errors */
|
|
511
|
+
validationErrors;
|
|
512
|
+
constructor(errors, context) {
|
|
513
|
+
super(`Configuration validation failed:\n${errors.map((e) => ` - ${e}`).join('\n')}`, {
|
|
514
|
+
...context,
|
|
515
|
+
metadata: { ...context?.metadata, validationErrors: errors },
|
|
516
|
+
});
|
|
517
|
+
this.name = 'ConfigValidationError';
|
|
518
|
+
this.validationErrors = errors;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Check if an error is a BellwetherError.
|
|
523
|
+
*/
|
|
524
|
+
export function isBellwetherError(error) {
|
|
525
|
+
return error instanceof BellwetherError;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Check if an error is retryable.
|
|
529
|
+
*/
|
|
530
|
+
export function isRetryable(error) {
|
|
531
|
+
if (isBellwetherError(error)) {
|
|
532
|
+
return error.retryable === 'retryable';
|
|
533
|
+
}
|
|
534
|
+
// For unknown errors, default to retryable for transient issues
|
|
535
|
+
if (error instanceof Error) {
|
|
536
|
+
const message = error.message.toLowerCase();
|
|
537
|
+
return (message.includes('timeout') ||
|
|
538
|
+
message.includes('econnreset') ||
|
|
539
|
+
message.includes('econnrefused') ||
|
|
540
|
+
message.includes('rate limit') ||
|
|
541
|
+
message.includes('429'));
|
|
542
|
+
}
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Wrap an unknown error in a BellwetherError.
|
|
547
|
+
*/
|
|
548
|
+
export function wrapError(error, context) {
|
|
549
|
+
if (isBellwetherError(error)) {
|
|
550
|
+
return context ? error.withContext(context) : error;
|
|
551
|
+
}
|
|
552
|
+
const originalError = error instanceof Error ? error : new Error(String(error));
|
|
553
|
+
return new BellwetherError(originalError.message, {
|
|
554
|
+
code: 'UNKNOWN_ERROR',
|
|
555
|
+
severity: 'medium',
|
|
556
|
+
retryable: 'unknown',
|
|
557
|
+
context,
|
|
558
|
+
cause: originalError,
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Extract error message from any error type.
|
|
563
|
+
*/
|
|
564
|
+
export function getErrorMessage(error) {
|
|
565
|
+
if (isBellwetherError(error)) {
|
|
566
|
+
return error.message;
|
|
567
|
+
}
|
|
568
|
+
if (error instanceof Error) {
|
|
569
|
+
return error.message;
|
|
570
|
+
}
|
|
571
|
+
return String(error);
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Create timing context for error tracking.
|
|
575
|
+
*/
|
|
576
|
+
export function createTimingContext(startedAt) {
|
|
577
|
+
const failedAt = new Date();
|
|
578
|
+
return {
|
|
579
|
+
startedAt,
|
|
580
|
+
failedAt,
|
|
581
|
+
durationMs: failedAt.getTime() - startedAt.getTime(),
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
//# sourceMappingURL=types.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bellwether - Interview MCP servers to generate behavioral documentation
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { MCPClient, type MCPClientOptions } from './transport/mcp-client.js';
|
|
7
|
+
export { BaseTransport, type BaseTransportConfig, type TransportType } from './transport/base-transport.js';
|
|
8
|
+
export { StdioTransport, type StdioTransportConfig } from './transport/stdio-transport.js';
|
|
9
|
+
export { SSETransport, type SSETransportConfig } from './transport/sse-transport.js';
|
|
10
|
+
export { HTTPTransport, type HTTPTransportConfig } from './transport/http-transport.js';
|
|
11
|
+
export type { JSONRPCRequest, JSONRPCResponse, JSONRPCError, JSONRPCMessage, MCPTool, MCPPrompt, MCPResource, MCPServerCapabilities, MCPServerInfo, MCPInitializeResult, MCPToolCallResult, MCPResourceReadResult, MCPContentBlock, } from './transport/types.js';
|
|
12
|
+
export { discover, parseToolDetail, summarizeDiscovery } from './discovery/discovery.js';
|
|
13
|
+
export type { DiscoveryResult, ToolDetail, ToolInputSchema } from './discovery/types.js';
|
|
14
|
+
export { Interviewer, DEFAULT_CONFIG } from './interview/interviewer.js';
|
|
15
|
+
export { Orchestrator } from './interview/orchestrator.js';
|
|
16
|
+
export type { InterviewConfig, InterviewResult, InterviewQuestion, ToolProfile, ToolInteraction, InterviewMetadata, PromptProfile, PromptInteraction, ResourceProfile, ResourceInteraction, ResourceQuestion, } from './interview/types.js';
|
|
17
|
+
export type { LLMClient, Message, CompletionOptions } from './llm/client.js';
|
|
18
|
+
export { OpenAIClient, type OpenAIClientOptions } from './llm/openai.js';
|
|
19
|
+
export { generateAgentsMd, generateContractMd, generateJsonReport } from './docs/generator.js';
|
|
20
|
+
export { loadConfig, ConfigNotFoundError } from './config/loader.js';
|
|
21
|
+
export type { BellwetherConfig } from './config/loader.js';
|
|
22
|
+
export { validateConfig, findConfigFile } from './config/validator.js';
|
|
23
|
+
export { generateConfigTemplate, generatePresetConfig, PRESETS } from './config/template.js';
|
|
24
|
+
export { createLogger, getLogger, configureLogger, resetLogger, childLogger, startTiming, LOG_LEVEL_VALUES, isLevelEnabled, } from './logging/logger.js';
|
|
25
|
+
export type { LogLevel, LoggerConfig, Logger, TimingResult } from './logging/logger.js';
|
|
26
|
+
export { loadScenariosFromFile, tryLoadDefaultScenarios, generateSampleScenariosYaml, DEFAULT_SCENARIOS_FILE, evaluateAssertion, evaluateAssertions, getValueAtPath, formatAssertionResults, } from './scenarios/index.js';
|
|
27
|
+
export type { TestScenario, PromptScenario, ScenarioAssertion, AssertionCondition, LoadedScenarios, AssertionResult, ScenarioResult, } from './scenarios/index.js';
|
|
28
|
+
export { RegistryClient, REGISTRY_BASE_URL, API_VERSION, generateRunCommand, generatePackageCommand, formatServerEntry, formatServerList, } from './registry/index.js';
|
|
29
|
+
export type { RegistryRepository, RegistryPackageArgument, RegistryTransport, RegistryPackage, RegistryServerMeta, RegistryServer, RegistryServerEntry, RegistryResponseMetadata, RegistryServersResponse, ListServersOptions, } from './registry/index.js';
|
|
30
|
+
export { generateVerificationResult, generateVerificationReport, generateVerificationBadge, generateBadgeUrl, generateBadgeMarkdown, isVerificationValid, } from './verification/index.js';
|
|
31
|
+
export type { VerificationStatus, VerificationTier, VerificationResult, VerificationBadge, VerificationConfig, VerificationReport, VerificationSubmission, } from './verification/index.js';
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bellwether - Interview MCP servers to generate behavioral documentation
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
// Transport layer
|
|
7
|
+
export { MCPClient } from './transport/mcp-client.js';
|
|
8
|
+
export { BaseTransport } from './transport/base-transport.js';
|
|
9
|
+
export { StdioTransport } from './transport/stdio-transport.js';
|
|
10
|
+
export { SSETransport } from './transport/sse-transport.js';
|
|
11
|
+
export { HTTPTransport } from './transport/http-transport.js';
|
|
12
|
+
// Discovery
|
|
13
|
+
export { discover, parseToolDetail, summarizeDiscovery } from './discovery/discovery.js';
|
|
14
|
+
// Interview
|
|
15
|
+
export { Interviewer, DEFAULT_CONFIG } from './interview/interviewer.js';
|
|
16
|
+
export { Orchestrator } from './interview/orchestrator.js';
|
|
17
|
+
export { OpenAIClient } from './llm/openai.js';
|
|
18
|
+
// Documentation
|
|
19
|
+
export { generateAgentsMd, generateContractMd, generateJsonReport } from './docs/generator.js';
|
|
20
|
+
// Config
|
|
21
|
+
export { loadConfig, ConfigNotFoundError } from './config/loader.js';
|
|
22
|
+
export { validateConfig, findConfigFile } from './config/validator.js';
|
|
23
|
+
export { generateConfigTemplate, generatePresetConfig, PRESETS } from './config/template.js';
|
|
24
|
+
// Logging
|
|
25
|
+
export { createLogger, getLogger, configureLogger, resetLogger, childLogger, startTiming, LOG_LEVEL_VALUES, isLevelEnabled, } from './logging/logger.js';
|
|
26
|
+
// Scenarios
|
|
27
|
+
export { loadScenariosFromFile, tryLoadDefaultScenarios, generateSampleScenariosYaml, DEFAULT_SCENARIOS_FILE, evaluateAssertion, evaluateAssertions, getValueAtPath, formatAssertionResults, } from './scenarios/index.js';
|
|
28
|
+
// Registry
|
|
29
|
+
export { RegistryClient, REGISTRY_BASE_URL, API_VERSION, generateRunCommand, generatePackageCommand, formatServerEntry, formatServerList, } from './registry/index.js';
|
|
30
|
+
// Verification
|
|
31
|
+
export { generateVerificationResult, generateVerificationReport, generateVerificationBadge, generateBadgeUrl, generateBadgeMarkdown, isVerificationValid, } from './verification/index.js';
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MCPTool } from '../transport/types.js';
|
|
2
|
+
import type { ToolDependencyInfo } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve tool dependencies from schema analysis.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveToolDependencies(tools: MCPTool[]): ToolDependencyInfo[];
|
|
7
|
+
/**
|
|
8
|
+
* Get tools ordered by dependency sequence.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getDependencyOrder(dependencies: ToolDependencyInfo[]): string[];
|
|
11
|
+
//# sourceMappingURL=dependency-resolver.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { analyzeDependencies } from '../baseline/dependency-analyzer.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve tool dependencies from schema analysis.
|
|
4
|
+
*/
|
|
5
|
+
export function resolveToolDependencies(tools) {
|
|
6
|
+
const graph = analyzeDependencies(tools);
|
|
7
|
+
const layerMap = new Map();
|
|
8
|
+
graph.layers.forEach((layer, index) => {
|
|
9
|
+
for (const toolName of layer) {
|
|
10
|
+
layerMap.set(toolName, index);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return tools.map((tool) => {
|
|
14
|
+
const dependsOn = graph.edges.filter((e) => e.to === tool.name).map((e) => e.from);
|
|
15
|
+
const provides = graph.edges.filter((e) => e.from === tool.name).map((e) => e.to);
|
|
16
|
+
return {
|
|
17
|
+
tool: tool.name,
|
|
18
|
+
dependsOn: Array.from(new Set(dependsOn)),
|
|
19
|
+
providesOutputFor: Array.from(new Set(provides)),
|
|
20
|
+
sequencePosition: layerMap.get(tool.name) ?? 0,
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get tools ordered by dependency sequence.
|
|
26
|
+
*/
|
|
27
|
+
export function getDependencyOrder(dependencies) {
|
|
28
|
+
return [...dependencies]
|
|
29
|
+
.sort((a, b) => a.sequencePosition - b.sequencePosition || a.tool.localeCompare(b.tool))
|
|
30
|
+
.map((d) => d.tool);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=dependency-resolver.js.map
|