webmcp-cli 1.0.0 → 1.2.1
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/dist/agent/features/agent-simulator.d.ts +67 -0
- package/dist/agent/features/agent-simulator.js +368 -0
- package/dist/agent/features/agent-simulator.js.map +1 -0
- package/dist/agent/features/index.d.ts +8 -0
- package/dist/agent/features/index.js +9 -0
- package/dist/agent/features/index.js.map +1 -0
- package/dist/agent/features/simulation-judge.d.ts +78 -0
- package/dist/agent/features/simulation-judge.js +276 -0
- package/dist/agent/features/simulation-judge.js.map +1 -0
- package/dist/agent/features/test-case-generator.d.ts +35 -0
- package/dist/agent/features/test-case-generator.js +257 -0
- package/dist/agent/features/test-case-generator.js.map +1 -0
- package/dist/agent/index.d.ts +7 -0
- package/dist/agent/index.js +10 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/llm-client.d.ts +76 -0
- package/dist/agent/llm-client.js +198 -0
- package/dist/agent/llm-client.js.map +1 -0
- package/dist/audit/run-single-page-audit.d.ts +41 -0
- package/dist/audit/run-single-page-audit.js +103 -0
- package/dist/audit/run-single-page-audit.js.map +1 -0
- package/dist/bin/webmcp.d.ts +5 -0
- package/dist/bin/webmcp.js +14 -0
- package/dist/bin/webmcp.js.map +1 -0
- package/dist/browser/audit-runner.d.ts +30 -0
- package/dist/browser/audit-runner.js +77 -0
- package/dist/browser/audit-runner.js.map +1 -0
- package/dist/browser/index.d.ts +6 -0
- package/dist/browser/index.js +7 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/interceptor.d.ts +68 -0
- package/dist/browser/interceptor.js +257 -0
- package/dist/browser/interceptor.js.map +1 -0
- package/dist/browser/playwright.d.ts +98 -0
- package/dist/browser/playwright.js +158 -0
- package/dist/browser/playwright.js.map +1 -0
- package/dist/cli/commands/audit.d.ts +12 -0
- package/dist/cli/commands/audit.js +349 -0
- package/dist/cli/commands/audit.js.map +1 -0
- package/dist/cli/commands/interactive.d.ts +10 -0
- package/dist/cli/commands/interactive.js +34 -0
- package/dist/cli/commands/interactive.js.map +1 -0
- package/dist/cli/index.d.ts +17 -0
- package/dist/cli/index.js +84 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/options/parse-audit-options.d.ts +12 -0
- package/dist/cli/options/parse-audit-options.js +64 -0
- package/dist/cli/options/parse-audit-options.js.map +1 -0
- package/dist/core/constants.d.ts +102 -0
- package/dist/core/constants.js +214 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/types/audit.d.ts +260 -0
- package/dist/core/types/audit.js +5 -0
- package/dist/core/types/audit.js.map +1 -0
- package/dist/core/types/index.d.ts +6 -0
- package/dist/core/types/index.js +7 -0
- package/dist/core/types/index.js.map +1 -0
- package/dist/core/types/rule.d.ts +190 -0
- package/dist/core/types/rule.js +26 -0
- package/dist/core/types/rule.js.map +1 -0
- package/dist/core/types/tool.d.ts +312 -0
- package/dist/core/types/tool.js +6 -0
- package/dist/core/types/tool.js.map +1 -0
- package/dist/detection/declarative.d.ts +27 -0
- package/dist/detection/declarative.js +343 -0
- package/dist/detection/declarative.js.map +1 -0
- package/dist/detection/imperative.d.ts +38 -0
- package/dist/detection/imperative.js +99 -0
- package/dist/detection/imperative.js.map +1 -0
- package/dist/detection/index.d.ts +5 -0
- package/dist/detection/index.js +6 -0
- package/dist/detection/index.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/advice-service.d.ts +38 -0
- package/dist/llm/advice-service.js +243 -0
- package/dist/llm/advice-service.js.map +1 -0
- package/dist/llm/evaluator.d.ts +89 -0
- package/dist/llm/evaluator.js +274 -0
- package/dist/llm/evaluator.js.map +1 -0
- package/dist/llm/index.d.ts +11 -0
- package/dist/llm/index.js +15 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/json-response.d.ts +12 -0
- package/dist/llm/json-response.js +67 -0
- package/dist/llm/json-response.js.map +1 -0
- package/dist/llm/providers/mock.d.ts +29 -0
- package/dist/llm/providers/mock.js +324 -0
- package/dist/llm/providers/mock.js.map +1 -0
- package/dist/llm/providers/openrouter.d.ts +53 -0
- package/dist/llm/providers/openrouter.js +321 -0
- package/dist/llm/providers/openrouter.js.map +1 -0
- package/dist/llm/request-cache.d.ts +28 -0
- package/dist/llm/request-cache.js +99 -0
- package/dist/llm/request-cache.js.map +1 -0
- package/dist/llm/types.d.ts +233 -0
- package/dist/llm/types.js +7 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/rules/best-practices/BP-001.d.ts +11 -0
- package/dist/rules/best-practices/BP-001.js +56 -0
- package/dist/rules/best-practices/BP-001.js.map +1 -0
- package/dist/rules/best-practices/BP-002.d.ts +11 -0
- package/dist/rules/best-practices/BP-002.js +63 -0
- package/dist/rules/best-practices/BP-002.js.map +1 -0
- package/dist/rules/best-practices/BP-003.d.ts +11 -0
- package/dist/rules/best-practices/BP-003.js +68 -0
- package/dist/rules/best-practices/BP-003.js.map +1 -0
- package/dist/rules/coverage/COV-001.d.ts +8 -0
- package/dist/rules/coverage/COV-001.js +51 -0
- package/dist/rules/coverage/COV-001.js.map +1 -0
- package/dist/rules/description/DESC-003.d.ts +13 -0
- package/dist/rules/description/DESC-003.js +96 -0
- package/dist/rules/description/DESC-003.js.map +1 -0
- package/dist/rules/description/DESC-004.d.ts +8 -0
- package/dist/rules/description/DESC-004.js +61 -0
- package/dist/rules/description/DESC-004.js.map +1 -0
- package/dist/rules/description/DESC-005.d.ts +12 -0
- package/dist/rules/description/DESC-005.js +70 -0
- package/dist/rules/description/DESC-005.js.map +1 -0
- package/dist/rules/description/index.d.ts +4 -0
- package/dist/rules/description/index.js +5 -0
- package/dist/rules/description/index.js.map +1 -0
- package/dist/rules/implementation/IMP-001.d.ts +10 -0
- package/dist/rules/implementation/IMP-001.js +36 -0
- package/dist/rules/implementation/IMP-001.js.map +1 -0
- package/dist/rules/implementation/IMP-003.d.ts +9 -0
- package/dist/rules/implementation/IMP-003.js +45 -0
- package/dist/rules/implementation/IMP-003.js.map +1 -0
- package/dist/rules/implementation/IMP-004.d.ts +9 -0
- package/dist/rules/implementation/IMP-004.js +48 -0
- package/dist/rules/implementation/IMP-004.js.map +1 -0
- package/dist/rules/implementation/IMP-005.d.ts +9 -0
- package/dist/rules/implementation/IMP-005.js +54 -0
- package/dist/rules/implementation/IMP-005.js.map +1 -0
- package/dist/rules/implementation/IMP-007.d.ts +8 -0
- package/dist/rules/implementation/IMP-007.js +79 -0
- package/dist/rules/implementation/IMP-007.js.map +1 -0
- package/dist/rules/implementation/IMP-013.d.ts +9 -0
- package/dist/rules/implementation/IMP-013.js +55 -0
- package/dist/rules/implementation/IMP-013.js.map +1 -0
- package/dist/rules/implementation/index.d.ts +9 -0
- package/dist/rules/implementation/index.js +10 -0
- package/dist/rules/implementation/index.js.map +1 -0
- package/dist/rules/index.d.ts +51 -0
- package/dist/rules/index.js +100 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/llm/LLM-001.d.ts +14 -0
- package/dist/rules/llm/LLM-001.js +78 -0
- package/dist/rules/llm/LLM-001.js.map +1 -0
- package/dist/rules/llm/LLM-002.d.ts +14 -0
- package/dist/rules/llm/LLM-002.js +77 -0
- package/dist/rules/llm/LLM-002.js.map +1 -0
- package/dist/rules/llm/LLM-003.d.ts +16 -0
- package/dist/rules/llm/LLM-003.js +82 -0
- package/dist/rules/llm/LLM-003.js.map +1 -0
- package/dist/rules/llm/LLM-004.d.ts +14 -0
- package/dist/rules/llm/LLM-004.js +87 -0
- package/dist/rules/llm/LLM-004.js.map +1 -0
- package/dist/rules/llm/LLM-005.d.ts +16 -0
- package/dist/rules/llm/LLM-005.js +105 -0
- package/dist/rules/llm/LLM-005.js.map +1 -0
- package/dist/rules/llm/index.d.ts +10 -0
- package/dist/rules/llm/index.js +11 -0
- package/dist/rules/llm/index.js.map +1 -0
- package/dist/rules/runner.d.ts +54 -0
- package/dist/rules/runner.js +138 -0
- package/dist/rules/runner.js.map +1 -0
- package/dist/rules/schema/SCHEMA-001.d.ts +9 -0
- package/dist/rules/schema/SCHEMA-001.js +57 -0
- package/dist/rules/schema/SCHEMA-001.js.map +1 -0
- package/dist/rules/schema/SCHEMA-002.d.ts +9 -0
- package/dist/rules/schema/SCHEMA-002.js +59 -0
- package/dist/rules/schema/SCHEMA-002.js.map +1 -0
- package/dist/rules/schema/SCHEMA-003.d.ts +10 -0
- package/dist/rules/schema/SCHEMA-003.js +66 -0
- package/dist/rules/schema/SCHEMA-003.js.map +1 -0
- package/dist/rules/schema/SCHEMA-011.d.ts +10 -0
- package/dist/rules/schema/SCHEMA-011.js +62 -0
- package/dist/rules/schema/SCHEMA-011.js.map +1 -0
- package/dist/rules/security/SEC-001.d.ts +12 -0
- package/dist/rules/security/SEC-001.js +66 -0
- package/dist/rules/security/SEC-001.js.map +1 -0
- package/dist/rules/utils/keywords.d.ts +35 -0
- package/dist/rules/utils/keywords.js +100 -0
- package/dist/rules/utils/keywords.js.map +1 -0
- package/dist/scoring/calculator.d.ts +27 -0
- package/dist/scoring/calculator.js +194 -0
- package/dist/scoring/calculator.js.map +1 -0
- package/dist/scoring/grades.d.ts +34 -0
- package/dist/scoring/grades.js +167 -0
- package/dist/scoring/grades.js.map +1 -0
- package/dist/scoring/index.d.ts +5 -0
- package/dist/scoring/index.js +6 -0
- package/dist/scoring/index.js.map +1 -0
- package/dist/ui/banner.d.ts +21 -0
- package/dist/ui/banner.js +60 -0
- package/dist/ui/banner.js.map +1 -0
- package/dist/ui/design-tokens.d.ts +23 -0
- package/dist/ui/design-tokens.js +58 -0
- package/dist/ui/design-tokens.js.map +1 -0
- package/dist/ui/findings.d.ts +23 -0
- package/dist/ui/findings.js +190 -0
- package/dist/ui/findings.js.map +1 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.js +10 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/ink/App.d.ts +14 -0
- package/dist/ui/ink/App.js +113 -0
- package/dist/ui/ink/App.js.map +1 -0
- package/dist/ui/ink/FullScreenLayout.d.ts +16 -0
- package/dist/ui/ink/FullScreenLayout.js +29 -0
- package/dist/ui/ink/FullScreenLayout.js.map +1 -0
- package/dist/ui/ink/InteractiveApp.d.ts +28 -0
- package/dist/ui/ink/InteractiveApp.js +229 -0
- package/dist/ui/ink/InteractiveApp.js.map +1 -0
- package/dist/ui/ink/RealAuditApp.d.ts +19 -0
- package/dist/ui/ink/RealAuditApp.js +170 -0
- package/dist/ui/ink/RealAuditApp.js.map +1 -0
- package/dist/ui/ink/components/AnimatedProgressBar.d.ts +20 -0
- package/dist/ui/ink/components/AnimatedProgressBar.js +46 -0
- package/dist/ui/ink/components/AnimatedProgressBar.js.map +1 -0
- package/dist/ui/ink/components/AsciiLogo.d.ts +12 -0
- package/dist/ui/ink/components/AsciiLogo.js +35 -0
- package/dist/ui/ink/components/AsciiLogo.js.map +1 -0
- package/dist/ui/ink/components/CategoryBars.d.ts +18 -0
- package/dist/ui/ink/components/CategoryBars.js +18 -0
- package/dist/ui/ink/components/CategoryBars.js.map +1 -0
- package/dist/ui/ink/components/FindingsTable.d.ts +18 -0
- package/dist/ui/ink/components/FindingsTable.js +19 -0
- package/dist/ui/ink/components/FindingsTable.js.map +1 -0
- package/dist/ui/ink/components/Footer.d.ts +15 -0
- package/dist/ui/ink/components/Footer.js +20 -0
- package/dist/ui/ink/components/Footer.js.map +1 -0
- package/dist/ui/ink/components/Header.d.ts +11 -0
- package/dist/ui/ink/components/Header.js +12 -0
- package/dist/ui/ink/components/Header.js.map +1 -0
- package/dist/ui/ink/components/LinkList.d.ts +17 -0
- package/dist/ui/ink/components/LinkList.js +44 -0
- package/dist/ui/ink/components/LinkList.js.map +1 -0
- package/dist/ui/ink/components/Navigation.d.ts +26 -0
- package/dist/ui/ink/components/Navigation.js +62 -0
- package/dist/ui/ink/components/Navigation.js.map +1 -0
- package/dist/ui/ink/components/ProgressBar.d.ts +15 -0
- package/dist/ui/ink/components/ProgressBar.js +14 -0
- package/dist/ui/ink/components/ProgressBar.js.map +1 -0
- package/dist/ui/ink/components/ScoreCard.d.ts +30 -0
- package/dist/ui/ink/components/ScoreCard.js +26 -0
- package/dist/ui/ink/components/ScoreCard.js.map +1 -0
- package/dist/ui/ink/components/SimulationResults.d.ts +33 -0
- package/dist/ui/ink/components/SimulationResults.js +23 -0
- package/dist/ui/ink/components/SimulationResults.js.map +1 -0
- package/dist/ui/ink/components/Spinner.d.ts +11 -0
- package/dist/ui/ink/components/Spinner.js +12 -0
- package/dist/ui/ink/components/Spinner.js.map +1 -0
- package/dist/ui/ink/components/ToolCard.d.ts +23 -0
- package/dist/ui/ink/components/ToolCard.js +20 -0
- package/dist/ui/ink/components/ToolCard.js.map +1 -0
- package/dist/ui/ink/components/shared/Badge.d.ts +21 -0
- package/dist/ui/ink/components/shared/Badge.js +39 -0
- package/dist/ui/ink/components/shared/Badge.js.map +1 -0
- package/dist/ui/ink/components/shared/Card.d.ts +18 -0
- package/dist/ui/ink/components/shared/Card.js +11 -0
- package/dist/ui/ink/components/shared/Card.js.map +1 -0
- package/dist/ui/ink/components/shared/HelpOverlay.d.ts +10 -0
- package/dist/ui/ink/components/shared/HelpOverlay.js +28 -0
- package/dist/ui/ink/components/shared/HelpOverlay.js.map +1 -0
- package/dist/ui/ink/components/shared/LoadingWithTimeout.d.ts +11 -0
- package/dist/ui/ink/components/shared/LoadingWithTimeout.js +21 -0
- package/dist/ui/ink/components/shared/LoadingWithTimeout.js.map +1 -0
- package/dist/ui/ink/components/shared/Menu.d.ts +23 -0
- package/dist/ui/ink/components/shared/Menu.js +43 -0
- package/dist/ui/ink/components/shared/Menu.js.map +1 -0
- package/dist/ui/ink/components/shared/Table.d.ts +23 -0
- package/dist/ui/ink/components/shared/Table.js +40 -0
- package/dist/ui/ink/components/shared/Table.js.map +1 -0
- package/dist/ui/ink/components/views/CrawlingView.d.ts +12 -0
- package/dist/ui/ink/components/views/CrawlingView.js +34 -0
- package/dist/ui/ink/components/views/CrawlingView.js.map +1 -0
- package/dist/ui/ink/components/views/DashboardView.d.ts +21 -0
- package/dist/ui/ink/components/views/DashboardView.js +51 -0
- package/dist/ui/ink/components/views/DashboardView.js.map +1 -0
- package/dist/ui/ink/components/views/FindingDetailView.d.ts +16 -0
- package/dist/ui/ink/components/views/FindingDetailView.js +34 -0
- package/dist/ui/ink/components/views/FindingDetailView.js.map +1 -0
- package/dist/ui/ink/components/views/FindingsView.d.ts +16 -0
- package/dist/ui/ink/components/views/FindingsView.js +79 -0
- package/dist/ui/ink/components/views/FindingsView.js.map +1 -0
- package/dist/ui/ink/components/views/OnboardingView.d.ts +12 -0
- package/dist/ui/ink/components/views/OnboardingView.js +40 -0
- package/dist/ui/ink/components/views/OnboardingView.js.map +1 -0
- package/dist/ui/ink/components/views/SimulationView.d.ts +17 -0
- package/dist/ui/ink/components/views/SimulationView.js +53 -0
- package/dist/ui/ink/components/views/SimulationView.js.map +1 -0
- package/dist/ui/ink/components/views/TestCaseDetailView.d.ts +11 -0
- package/dist/ui/ink/components/views/TestCaseDetailView.js +53 -0
- package/dist/ui/ink/components/views/TestCaseDetailView.js.map +1 -0
- package/dist/ui/ink/components/views/ToolDetailView.d.ts +15 -0
- package/dist/ui/ink/components/views/ToolDetailView.js +25 -0
- package/dist/ui/ink/components/views/ToolDetailView.js.map +1 -0
- package/dist/ui/ink/components/views/ToolsView.d.ts +15 -0
- package/dist/ui/ink/components/views/ToolsView.js +43 -0
- package/dist/ui/ink/components/views/ToolsView.js.map +1 -0
- package/dist/ui/ink/demo.d.ts +6 -0
- package/dist/ui/ink/demo.js +254 -0
- package/dist/ui/ink/demo.js.map +1 -0
- package/dist/ui/ink/hooks/useAnimation.d.ts +29 -0
- package/dist/ui/ink/hooks/useAnimation.js +89 -0
- package/dist/ui/ink/hooks/useAnimation.js.map +1 -0
- package/dist/ui/ink/hooks/useAudit.d.ts +69 -0
- package/dist/ui/ink/hooks/useAudit.js +99 -0
- package/dist/ui/ink/hooks/useAudit.js.map +1 -0
- package/dist/ui/ink/hooks/useCrawlAnimation.d.ts +19 -0
- package/dist/ui/ink/hooks/useCrawlAnimation.js +204 -0
- package/dist/ui/ink/hooks/useCrawlAnimation.js.map +1 -0
- package/dist/ui/ink/hooks/useKeyboardNav.d.ts +23 -0
- package/dist/ui/ink/hooks/useKeyboardNav.js +81 -0
- package/dist/ui/ink/hooks/useKeyboardNav.js.map +1 -0
- package/dist/ui/ink/hooks/useNavigation.d.ts +16 -0
- package/dist/ui/ink/hooks/useNavigation.js +42 -0
- package/dist/ui/ink/hooks/useNavigation.js.map +1 -0
- package/dist/ui/ink/hooks/useTerminalSize.d.ts +10 -0
- package/dist/ui/ink/hooks/useTerminalSize.js +29 -0
- package/dist/ui/ink/hooks/useTerminalSize.js.map +1 -0
- package/dist/ui/ink/index.d.ts +43 -0
- package/dist/ui/ink/index.js +50 -0
- package/dist/ui/ink/index.js.map +1 -0
- package/dist/ui/ink/render.d.ts +24 -0
- package/dist/ui/ink/render.js +14 -0
- package/dist/ui/ink/render.js.map +1 -0
- package/dist/ui/ink/theme.d.ts +37 -0
- package/dist/ui/ink/theme.js +38 -0
- package/dist/ui/ink/theme.js.map +1 -0
- package/dist/ui/ink/types.d.ts +77 -0
- package/dist/ui/ink/types.js +5 -0
- package/dist/ui/ink/types.js.map +1 -0
- package/dist/ui/score-display.d.ts +16 -0
- package/dist/ui/score-display.js +201 -0
- package/dist/ui/score-display.js.map +1 -0
- package/dist/ui/spinner.d.ts +45 -0
- package/dist/ui/spinner.js +112 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/ui/utils.d.ts +13 -0
- package/dist/ui/utils.js +25 -0
- package/dist/ui/utils.js.map +1 -0
- package/package.json +61 -9
- package/index.js +0 -105
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for extracting JSON payloads from LLM responses.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Extract the first JSON object from an LLM response.
|
|
6
|
+
*
|
|
7
|
+
* Supports:
|
|
8
|
+
* - fenced code blocks: ```json ... ```
|
|
9
|
+
* - plain text responses containing a JSON object
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractJsonObject(response: string): string;
|
|
12
|
+
export declare function parseJsonObject<T>(response: string): T;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for extracting JSON payloads from LLM responses.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Extract the first JSON object from an LLM response.
|
|
6
|
+
*
|
|
7
|
+
* Supports:
|
|
8
|
+
* - fenced code blocks: ```json ... ```
|
|
9
|
+
* - plain text responses containing a JSON object
|
|
10
|
+
*/
|
|
11
|
+
export function extractJsonObject(response) {
|
|
12
|
+
const codeBlockMatch = response.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
13
|
+
const candidate = codeBlockMatch?.[1]?.trim() ?? response;
|
|
14
|
+
let depth = 0;
|
|
15
|
+
let start = -1;
|
|
16
|
+
let end = -1;
|
|
17
|
+
let inString = false;
|
|
18
|
+
let isEscaped = false;
|
|
19
|
+
for (let i = 0; i < candidate.length; i++) {
|
|
20
|
+
const char = candidate[i];
|
|
21
|
+
if (!char)
|
|
22
|
+
continue;
|
|
23
|
+
if (inString) {
|
|
24
|
+
if (isEscaped) {
|
|
25
|
+
isEscaped = false;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (char === '\\') {
|
|
29
|
+
isEscaped = true;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (char === '"') {
|
|
33
|
+
inString = false;
|
|
34
|
+
}
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (char === '"') {
|
|
38
|
+
inString = true;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (char === '{') {
|
|
42
|
+
if (depth === 0) {
|
|
43
|
+
start = i;
|
|
44
|
+
}
|
|
45
|
+
depth++;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (char === '}') {
|
|
49
|
+
if (depth > 0) {
|
|
50
|
+
depth--;
|
|
51
|
+
if (depth === 0 && start !== -1) {
|
|
52
|
+
end = i + 1;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (start === -1 || end === -1) {
|
|
59
|
+
throw new Error('No JSON object found in response');
|
|
60
|
+
}
|
|
61
|
+
return candidate.substring(start, end);
|
|
62
|
+
}
|
|
63
|
+
export function parseJsonObject(response) {
|
|
64
|
+
const json = extractJsonObject(response);
|
|
65
|
+
return JSON.parse(json);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=json-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-response.js","sourceRoot":"","sources":["../../src/llm/json-response.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACvE,MAAM,SAAS,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,QAAQ,CAAC;IAE1D,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC;IACb,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI;YAAE,SAAS;QAEpB,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,SAAS,EAAE,CAAC;gBACd,SAAS,GAAG,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ider
|
|
3
|
+
*
|
|
4
|
+
* For testing and when no API key is available.
|
|
5
|
+
* Returns static/heuristic-based responses.
|
|
6
|
+
*/
|
|
7
|
+
import type { LLMProvider, EvaluationResult, DescriptionEvalContext, DescriptionQualityReport } from '../types.js';
|
|
8
|
+
import type { DetectedTool } from '../../core/types/tool.js';
|
|
9
|
+
/**
|
|
10
|
+
* Mock LLM Provider implementation
|
|
11
|
+
*/
|
|
12
|
+
export declare class MockProvider implements LLMProvider {
|
|
13
|
+
name: string;
|
|
14
|
+
isAvailable(): boolean;
|
|
15
|
+
complete(prompt: string, _systemPrompt?: string): Promise<string>;
|
|
16
|
+
evaluateDescription(context: DescriptionEvalContext): Promise<EvaluationResult>;
|
|
17
|
+
getQualityReport(tool: DetectedTool): Promise<DescriptionQualityReport>;
|
|
18
|
+
private evaluateSpecificity;
|
|
19
|
+
private evaluatePositiveFraming;
|
|
20
|
+
private evaluateCompleteness;
|
|
21
|
+
private evaluateClarity;
|
|
22
|
+
private evaluateSteering;
|
|
23
|
+
private evaluateAtomicity;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a mock provider
|
|
27
|
+
*/
|
|
28
|
+
export declare function createMockProvider(): MockProvider;
|
|
29
|
+
export default MockProvider;
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock LLM Provider
|
|
3
|
+
*
|
|
4
|
+
* For testing and when no API key is available.
|
|
5
|
+
* Returns static/heuristic-based responses.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Ambiguous verbs to flag
|
|
9
|
+
*/
|
|
10
|
+
const AMBIGUOUS_VERBS = ['handle', 'process', 'do', 'manage', 'execute', 'run', 'perform'];
|
|
11
|
+
/**
|
|
12
|
+
* Specific/good verbs
|
|
13
|
+
*/
|
|
14
|
+
const SPECIFIC_VERBS = [
|
|
15
|
+
'search', 'find', 'get', 'fetch', 'retrieve', 'list',
|
|
16
|
+
'create', 'add', 'insert', 'book', 'reserve', 'submit',
|
|
17
|
+
'update', 'edit', 'modify', 'change',
|
|
18
|
+
'delete', 'remove', 'cancel',
|
|
19
|
+
'send', 'upload', 'download', 'export', 'import',
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Negative framing patterns
|
|
23
|
+
*/
|
|
24
|
+
const NEGATIVE_PATTERNS = [
|
|
25
|
+
/\bdo not\b/i,
|
|
26
|
+
/\bdon't\b/i,
|
|
27
|
+
/\bnever\b/i,
|
|
28
|
+
/\bavoid\b/i,
|
|
29
|
+
/\bcannot\b/i,
|
|
30
|
+
/\bwon't\b/i,
|
|
31
|
+
/\bshould not\b/i,
|
|
32
|
+
/\bshouldn't\b/i,
|
|
33
|
+
];
|
|
34
|
+
/**
|
|
35
|
+
* Non-atomic patterns
|
|
36
|
+
*/
|
|
37
|
+
const NON_ATOMIC_PATTERNS = [
|
|
38
|
+
/\band\b.*\band\b/i, // Multiple "and"
|
|
39
|
+
/\b(also|additionally)\b/i, // Adding more functions
|
|
40
|
+
/\bor\b.*\bor\b/i, // Multiple "or"
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* Mock LLM Provider implementation
|
|
44
|
+
*/
|
|
45
|
+
export class MockProvider {
|
|
46
|
+
name = 'mock';
|
|
47
|
+
isAvailable() {
|
|
48
|
+
return true; // Always available
|
|
49
|
+
}
|
|
50
|
+
async complete(prompt, _systemPrompt) {
|
|
51
|
+
// Return a simple mock response
|
|
52
|
+
return JSON.stringify({
|
|
53
|
+
passed: true,
|
|
54
|
+
score: 7,
|
|
55
|
+
reasoning: 'Mock evaluation - LLM not available',
|
|
56
|
+
issues: [],
|
|
57
|
+
suggestions: ['Configure OPENROUTER_API_KEY for detailed LLM analysis'],
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async evaluateDescription(context) {
|
|
61
|
+
const { name, description, aspect } = context;
|
|
62
|
+
const textToAnalyze = `${name} ${description}`;
|
|
63
|
+
switch (aspect) {
|
|
64
|
+
case 'specificity':
|
|
65
|
+
return this.evaluateSpecificity(name, description);
|
|
66
|
+
case 'positive-framing':
|
|
67
|
+
return this.evaluatePositiveFraming(description);
|
|
68
|
+
case 'completeness':
|
|
69
|
+
return this.evaluateCompleteness(description);
|
|
70
|
+
case 'clarity':
|
|
71
|
+
return this.evaluateClarity(description);
|
|
72
|
+
case 'steering':
|
|
73
|
+
return this.evaluateSteering(name, description);
|
|
74
|
+
case 'atomicity':
|
|
75
|
+
return this.evaluateAtomicity(textToAnalyze);
|
|
76
|
+
default:
|
|
77
|
+
return {
|
|
78
|
+
passed: true,
|
|
79
|
+
score: 5,
|
|
80
|
+
reasoning: 'Mock evaluation - aspect not implemented',
|
|
81
|
+
suggestions: ['Use LLM for detailed evaluation'],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async getQualityReport(tool) {
|
|
86
|
+
const specificity = await this.evaluateSpecificity(tool.name, tool.description);
|
|
87
|
+
const positiveFraming = await this.evaluatePositiveFraming(tool.description);
|
|
88
|
+
const completeness = await this.evaluateCompleteness(tool.description);
|
|
89
|
+
const clarity = await this.evaluateClarity(tool.description);
|
|
90
|
+
const steering = await this.evaluateSteering(tool.name, tool.description);
|
|
91
|
+
const atomicity = await this.evaluateAtomicity(`${tool.name} ${tool.description}`);
|
|
92
|
+
// Calculate weighted average
|
|
93
|
+
const weights = {
|
|
94
|
+
clarity: 20,
|
|
95
|
+
specificity: 15,
|
|
96
|
+
positiveFraming: 10,
|
|
97
|
+
completeness: 20,
|
|
98
|
+
steeringPerformance: 25,
|
|
99
|
+
atomicity: 10,
|
|
100
|
+
};
|
|
101
|
+
const overallScore = Math.round((clarity.score * weights.clarity +
|
|
102
|
+
specificity.score * weights.specificity +
|
|
103
|
+
positiveFraming.score * weights.positiveFraming +
|
|
104
|
+
completeness.score * weights.completeness +
|
|
105
|
+
steering.score * weights.steeringPerformance +
|
|
106
|
+
atomicity.score * weights.atomicity) / 10);
|
|
107
|
+
const allIssues = [];
|
|
108
|
+
[specificity, positiveFraming, completeness, clarity, steering, atomicity].forEach((result) => {
|
|
109
|
+
if (result.issues)
|
|
110
|
+
allIssues.push(...result.issues);
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
overallScore,
|
|
114
|
+
aspects: {
|
|
115
|
+
clarity,
|
|
116
|
+
specificity,
|
|
117
|
+
positiveFraming,
|
|
118
|
+
completeness,
|
|
119
|
+
steeringPerformance: steering,
|
|
120
|
+
atomicity,
|
|
121
|
+
},
|
|
122
|
+
summary: `Heuristic analysis of "${tool.name}". Score: ${overallScore}/100. Configure OPENROUTER_API_KEY for AI-powered analysis.`,
|
|
123
|
+
priorityImprovements: allIssues.slice(0, 3),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
evaluateSpecificity(name, description) {
|
|
127
|
+
const lowerName = name.toLowerCase();
|
|
128
|
+
const issues = [];
|
|
129
|
+
const suggestions = [];
|
|
130
|
+
// Check for ambiguous verbs
|
|
131
|
+
const hasAmbiguous = AMBIGUOUS_VERBS.some((verb) => lowerName.includes(verb));
|
|
132
|
+
const hasSpecific = SPECIFIC_VERBS.some((verb) => lowerName.includes(verb));
|
|
133
|
+
let score = 7;
|
|
134
|
+
if (hasAmbiguous) {
|
|
135
|
+
score -= 3;
|
|
136
|
+
issues.push(`Tool name uses ambiguous verb pattern`);
|
|
137
|
+
suggestions.push('Use specific verbs like search, create, delete, book');
|
|
138
|
+
}
|
|
139
|
+
if (!hasSpecific && !hasAmbiguous) {
|
|
140
|
+
score -= 1;
|
|
141
|
+
issues.push('Tool name could be more action-oriented');
|
|
142
|
+
}
|
|
143
|
+
if (description.length < 20) {
|
|
144
|
+
score -= 2;
|
|
145
|
+
issues.push('Description is too short to be specific');
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
passed: score >= 7,
|
|
149
|
+
score: Math.max(0, score),
|
|
150
|
+
reasoning: hasSpecific
|
|
151
|
+
? 'Tool name uses specific action verb'
|
|
152
|
+
: hasAmbiguous
|
|
153
|
+
? 'Tool name uses ambiguous verb (handle/process/do)'
|
|
154
|
+
: 'Tool name could be more descriptive',
|
|
155
|
+
issues,
|
|
156
|
+
suggestions,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
evaluatePositiveFraming(description) {
|
|
160
|
+
const issues = [];
|
|
161
|
+
const suggestions = [];
|
|
162
|
+
let score = 10;
|
|
163
|
+
for (const pattern of NEGATIVE_PATTERNS) {
|
|
164
|
+
if (pattern.test(description)) {
|
|
165
|
+
score -= 2;
|
|
166
|
+
issues.push(`Description contains negative framing: "${description.match(pattern)?.[0]}"`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (issues.length > 0) {
|
|
170
|
+
suggestions.push('Rewrite using positive instructions (what it DOES, not what it doesn\'t)');
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
passed: score >= 7,
|
|
174
|
+
score: Math.max(0, score),
|
|
175
|
+
reasoning: issues.length === 0
|
|
176
|
+
? 'Description uses positive framing'
|
|
177
|
+
: 'Description contains negative language patterns',
|
|
178
|
+
issues,
|
|
179
|
+
suggestions,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
evaluateCompleteness(description) {
|
|
183
|
+
const issues = [];
|
|
184
|
+
const suggestions = [];
|
|
185
|
+
let score = 10;
|
|
186
|
+
if (description.length < 20) {
|
|
187
|
+
score -= 3;
|
|
188
|
+
issues.push('Description is too short');
|
|
189
|
+
suggestions.push('Expand description to at least 20 characters');
|
|
190
|
+
}
|
|
191
|
+
if (description.length < 50) {
|
|
192
|
+
score -= 1;
|
|
193
|
+
issues.push('Description could be more detailed');
|
|
194
|
+
}
|
|
195
|
+
// Check for "what" indicators
|
|
196
|
+
const hasWhat = /\b(returns?|provides?|gets?|fetches?|searches?|creates?|deletes?)\b/i.test(description);
|
|
197
|
+
if (!hasWhat) {
|
|
198
|
+
score -= 2;
|
|
199
|
+
issues.push('Description doesn\'t clearly state what the tool does');
|
|
200
|
+
suggestions.push('Start with an action verb explaining what the tool does');
|
|
201
|
+
}
|
|
202
|
+
// Check for "when" indicators
|
|
203
|
+
const hasWhen = /\b(when|for|to|if)\b/i.test(description);
|
|
204
|
+
if (!hasWhen) {
|
|
205
|
+
score -= 1;
|
|
206
|
+
issues.push('Description doesn\'t explain when to use the tool');
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
passed: score >= 7,
|
|
210
|
+
score: Math.max(0, score),
|
|
211
|
+
reasoning: issues.length === 0
|
|
212
|
+
? 'Description is complete'
|
|
213
|
+
: `Description has ${issues.length} completeness issue(s)`,
|
|
214
|
+
issues,
|
|
215
|
+
suggestions,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
evaluateClarity(description) {
|
|
219
|
+
const issues = [];
|
|
220
|
+
let score = 10;
|
|
221
|
+
// Very short descriptions are unclear
|
|
222
|
+
if (description.length < 10) {
|
|
223
|
+
score -= 4;
|
|
224
|
+
issues.push('Description is too short to be clear');
|
|
225
|
+
}
|
|
226
|
+
// Check for technical jargon without explanation
|
|
227
|
+
const jargonPatterns = [
|
|
228
|
+
/\bAPI\b(?![^a-z]*(?:endpoint|call|request))/i,
|
|
229
|
+
/\bJSON\b/i,
|
|
230
|
+
/\bREST\b/i,
|
|
231
|
+
/\bGRPC\b/i,
|
|
232
|
+
];
|
|
233
|
+
for (const pattern of jargonPatterns) {
|
|
234
|
+
if (pattern.test(description)) {
|
|
235
|
+
score -= 1;
|
|
236
|
+
issues.push('Description contains technical jargon');
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
passed: score >= 7,
|
|
242
|
+
score: Math.max(0, score),
|
|
243
|
+
reasoning: issues.length === 0
|
|
244
|
+
? 'Description is clear and understandable'
|
|
245
|
+
: `Description has clarity issues: ${issues.join(', ')}`,
|
|
246
|
+
issues,
|
|
247
|
+
suggestions: issues.length > 0 ? ['Write for AI agents, not developers'] : [],
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
evaluateSteering(name, description) {
|
|
251
|
+
const issues = [];
|
|
252
|
+
const suggestions = [];
|
|
253
|
+
let score = 10;
|
|
254
|
+
// Good steering needs:
|
|
255
|
+
// 1. Clear action verb in name
|
|
256
|
+
// 2. Sufficient description length
|
|
257
|
+
// 3. Specific use case indicators
|
|
258
|
+
const hasActionVerb = SPECIFIC_VERBS.some((v) => name.toLowerCase().includes(v));
|
|
259
|
+
if (!hasActionVerb) {
|
|
260
|
+
score -= 2;
|
|
261
|
+
issues.push('Name lacks clear action verb for AI routing');
|
|
262
|
+
}
|
|
263
|
+
if (description.length < 30) {
|
|
264
|
+
score -= 2;
|
|
265
|
+
issues.push('Description too short for good AI steering');
|
|
266
|
+
suggestions.push('Provide more context for AI to understand when to use this tool');
|
|
267
|
+
}
|
|
268
|
+
// Check for parameter hints in description
|
|
269
|
+
const hasParamHints = /\b(with|using|by|specify|provide)\b/i.test(description);
|
|
270
|
+
if (!hasParamHints && description.length > 20) {
|
|
271
|
+
score -= 1;
|
|
272
|
+
issues.push('Description could mention key parameters');
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
passed: score >= 7,
|
|
276
|
+
score: Math.max(0, score),
|
|
277
|
+
reasoning: issues.length === 0
|
|
278
|
+
? 'Description provides good steering for AI agents'
|
|
279
|
+
: 'Description could better guide AI agents',
|
|
280
|
+
issues,
|
|
281
|
+
suggestions,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
evaluateAtomicity(text) {
|
|
285
|
+
const issues = [];
|
|
286
|
+
let score = 10;
|
|
287
|
+
for (const pattern of NON_ATOMIC_PATTERNS) {
|
|
288
|
+
if (pattern.test(text)) {
|
|
289
|
+
score -= 2;
|
|
290
|
+
issues.push('Tool may be doing multiple things');
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// Count action verbs
|
|
295
|
+
let verbCount = 0;
|
|
296
|
+
for (const verb of SPECIFIC_VERBS) {
|
|
297
|
+
if (text.toLowerCase().includes(verb))
|
|
298
|
+
verbCount++;
|
|
299
|
+
}
|
|
300
|
+
if (verbCount > 2) {
|
|
301
|
+
score -= 2;
|
|
302
|
+
issues.push(`Tool description mentions ${verbCount} different actions`);
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
passed: score >= 7,
|
|
306
|
+
score: Math.max(0, score),
|
|
307
|
+
reasoning: issues.length === 0
|
|
308
|
+
? 'Tool appears to be atomic (single function)'
|
|
309
|
+
: 'Tool may be trying to do too many things',
|
|
310
|
+
issues,
|
|
311
|
+
suggestions: issues.length > 0
|
|
312
|
+
? ['Consider splitting into multiple focused tools']
|
|
313
|
+
: [],
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Create a mock provider
|
|
319
|
+
*/
|
|
320
|
+
export function createMockProvider() {
|
|
321
|
+
return new MockProvider();
|
|
322
|
+
}
|
|
323
|
+
export default MockProvider;
|
|
324
|
+
//# sourceMappingURL=mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../../../src/llm/providers/mock.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAE3F;;GAEG;AACH,MAAM,cAAc,GAAG;IACrB,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM;IACpD,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ;IACtD,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ;IACpC,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IAC5B,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,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,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,YAAY,EAAE,CAAC;AAC5B,CAAC;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenRouter LLM Provider
|
|
3
|
+
*
|
|
4
|
+
* Uses OpenRouter's OpenAI-compatible API to access various models
|
|
5
|
+
* including Claude.
|
|
6
|
+
*/
|
|
7
|
+
import type { LLMProvider, LLMConfig, EvaluationResult, DescriptionEvalContext, DescriptionQualityReport } from '../types.js';
|
|
8
|
+
import type { DetectedTool } from '../../core/types/tool.js';
|
|
9
|
+
/**
|
|
10
|
+
* OpenRouter LLM Provider implementation
|
|
11
|
+
*/
|
|
12
|
+
export declare class OpenRouterProvider implements LLMProvider {
|
|
13
|
+
name: string;
|
|
14
|
+
private config;
|
|
15
|
+
constructor(config?: Partial<LLMConfig>);
|
|
16
|
+
/**
|
|
17
|
+
* Check if the provider has valid credentials
|
|
18
|
+
*/
|
|
19
|
+
isAvailable(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Send a prompt and get a response
|
|
22
|
+
*/
|
|
23
|
+
complete(prompt: string, systemPrompt?: string): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Evaluate a specific aspect of a tool description
|
|
26
|
+
*/
|
|
27
|
+
evaluateDescription(context: DescriptionEvalContext): Promise<EvaluationResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Get a comprehensive quality report for a tool
|
|
30
|
+
*/
|
|
31
|
+
getQualityReport(tool: DetectedTool): Promise<DescriptionQualityReport>;
|
|
32
|
+
/**
|
|
33
|
+
* Build the evaluation prompt for a specific aspect
|
|
34
|
+
*/
|
|
35
|
+
private buildEvaluationPrompt;
|
|
36
|
+
/**
|
|
37
|
+
* Build the comprehensive quality report prompt
|
|
38
|
+
*/
|
|
39
|
+
private buildQualityReportPrompt;
|
|
40
|
+
/**
|
|
41
|
+
* Parse the evaluation response from LLM
|
|
42
|
+
*/
|
|
43
|
+
private parseEvaluationResponse;
|
|
44
|
+
/**
|
|
45
|
+
* Parse the quality report response from LLM
|
|
46
|
+
*/
|
|
47
|
+
private parseQualityReport;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create an OpenRouter provider with environment configuration
|
|
51
|
+
*/
|
|
52
|
+
export declare function createOpenRouterProvider(config?: Partial<LLMConfig>): OpenRouterProvider;
|
|
53
|
+
export default OpenRouterProvider;
|