@mcp-abap-adt/llm-agent-libs 12.0.2 → 12.0.3
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/adapters/index.d.ts +4 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +4 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/llm-adapter.d.ts +24 -0
- package/dist/adapters/llm-adapter.d.ts.map +1 -0
- package/dist/adapters/llm-adapter.js +345 -0
- package/dist/adapters/llm-adapter.js.map +1 -0
- package/dist/adapters/llm-provider-bridge.d.ts +30 -0
- package/dist/adapters/llm-provider-bridge.d.ts.map +1 -0
- package/dist/adapters/llm-provider-bridge.js +122 -0
- package/dist/adapters/llm-provider-bridge.js.map +1 -0
- package/dist/adapters/non-streaming-llm.d.ts +18 -0
- package/dist/adapters/non-streaming-llm.d.ts.map +1 -0
- package/dist/adapters/non-streaming-llm.js +44 -0
- package/dist/adapters/non-streaming-llm.js.map +1 -0
- package/dist/agent.d.ts +227 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +1534 -0
- package/dist/agent.js.map +1 -0
- package/dist/builder.d.ts +260 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +949 -0
- package/dist/builder.js.map +1 -0
- package/dist/classifier/index.d.ts +3 -0
- package/dist/classifier/index.d.ts.map +1 -0
- package/dist/classifier/index.js +2 -0
- package/dist/classifier/index.js.map +1 -0
- package/dist/classifier/llm-classifier.d.ts +20 -0
- package/dist/classifier/llm-classifier.d.ts.map +1 -0
- package/dist/classifier/llm-classifier.js +128 -0
- package/dist/classifier/llm-classifier.js.map +1 -0
- package/dist/config/config-watcher.d.ts +54 -0
- package/dist/config/config-watcher.d.ts.map +1 -0
- package/dist/config/config-watcher.js +107 -0
- package/dist/config/config-watcher.js.map +1 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +2 -0
- package/dist/config/index.js.map +1 -0
- package/dist/context/context-assembler.d.ts +49 -0
- package/dist/context/context-assembler.d.ts.map +1 -0
- package/dist/context/context-assembler.js +184 -0
- package/dist/context/context-assembler.js.map +1 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +2 -0
- package/dist/context/index.js.map +1 -0
- package/dist/health/health-checker.d.ts +21 -0
- package/dist/health/health-checker.d.ts.map +1 -0
- package/dist/health/health-checker.js +52 -0
- package/dist/health/health-checker.js.map +1 -0
- package/dist/health/index.d.ts +3 -0
- package/dist/health/index.d.ts.map +1 -0
- package/dist/health/index.js +2 -0
- package/dist/health/index.js.map +1 -0
- package/dist/health/types.d.ts +2 -0
- package/dist/health/types.d.ts.map +1 -0
- package/dist/health/types.js +2 -0
- package/dist/health/types.js.map +1 -0
- package/dist/history/history-memory.d.ts +12 -0
- package/dist/history/history-memory.d.ts.map +1 -0
- package/dist/history/history-memory.js +26 -0
- package/dist/history/history-memory.js.map +1 -0
- package/dist/history/history-summarizer.d.ts +10 -0
- package/dist/history/history-summarizer.d.ts.map +1 -0
- package/dist/history/history-summarizer.js +27 -0
- package/dist/history/history-summarizer.js.map +1 -0
- package/dist/history/index.d.ts +3 -0
- package/dist/history/index.d.ts.map +1 -0
- package/dist/history/index.js +3 -0
- package/dist/history/index.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/mcp-connection-strategy.d.ts +2 -0
- package/dist/interfaces/mcp-connection-strategy.d.ts.map +1 -0
- package/dist/interfaces/mcp-connection-strategy.js +2 -0
- package/dist/interfaces/mcp-connection-strategy.js.map +1 -0
- package/dist/interfaces/model-resolver.d.ts +2 -0
- package/dist/interfaces/model-resolver.d.ts.map +1 -0
- package/dist/interfaces/model-resolver.js +2 -0
- package/dist/interfaces/model-resolver.js.map +1 -0
- package/dist/interfaces/pipeline.d.ts +123 -0
- package/dist/interfaces/pipeline.d.ts.map +1 -0
- package/dist/interfaces/pipeline.js +13 -0
- package/dist/interfaces/pipeline.js.map +1 -0
- package/dist/logger/console-logger.d.ts +7 -0
- package/dist/logger/console-logger.d.ts.map +1 -0
- package/dist/logger/console-logger.js +12 -0
- package/dist/logger/console-logger.js.map +1 -0
- package/dist/logger/default-request-logger.d.ts +17 -0
- package/dist/logger/default-request-logger.d.ts.map +1 -0
- package/dist/logger/default-request-logger.js +86 -0
- package/dist/logger/default-request-logger.js.map +1 -0
- package/dist/logger/index.d.ts +3 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +2 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/noop-request-logger.d.ts +11 -0
- package/dist/logger/noop-request-logger.d.ts.map +1 -0
- package/dist/logger/noop-request-logger.js +20 -0
- package/dist/logger/noop-request-logger.js.map +1 -0
- package/dist/logger/session-logger.d.ts +10 -0
- package/dist/logger/session-logger.d.ts.map +1 -0
- package/dist/logger/session-logger.js +40 -0
- package/dist/logger/session-logger.js.map +1 -0
- package/dist/metrics/in-memory-metrics.d.ts +36 -0
- package/dist/metrics/in-memory-metrics.d.ts.map +1 -0
- package/dist/metrics/in-memory-metrics.js +87 -0
- package/dist/metrics/in-memory-metrics.js.map +1 -0
- package/dist/metrics/index.d.ts +4 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +3 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/noop-metrics.d.ts +17 -0
- package/dist/metrics/noop-metrics.d.ts.map +1 -0
- package/dist/metrics/noop-metrics.js +22 -0
- package/dist/metrics/noop-metrics.js.map +1 -0
- package/dist/metrics/types.d.ts +2 -0
- package/dist/metrics/types.d.ts.map +1 -0
- package/dist/metrics/types.js +2 -0
- package/dist/metrics/types.js.map +1 -0
- package/dist/otel/index.d.ts +2 -0
- package/dist/otel/index.d.ts.map +1 -0
- package/dist/otel/index.js +2 -0
- package/dist/otel/index.js.map +1 -0
- package/dist/otel/otel-tracer-adapter.d.ts +15 -0
- package/dist/otel/otel-tracer-adapter.d.ts.map +1 -0
- package/dist/otel/otel-tracer-adapter.js +62 -0
- package/dist/otel/otel-tracer-adapter.js.map +1 -0
- package/dist/pipeline/condition-evaluator.d.ts +35 -0
- package/dist/pipeline/condition-evaluator.d.ts.map +1 -0
- package/dist/pipeline/condition-evaluator.js +143 -0
- package/dist/pipeline/condition-evaluator.js.map +1 -0
- package/dist/pipeline/context.d.ts +119 -0
- package/dist/pipeline/context.d.ts.map +1 -0
- package/dist/pipeline/context.js +19 -0
- package/dist/pipeline/context.js.map +1 -0
- package/dist/pipeline/default-pipeline.d.ts +69 -0
- package/dist/pipeline/default-pipeline.d.ts.map +1 -0
- package/dist/pipeline/default-pipeline.js +276 -0
- package/dist/pipeline/default-pipeline.js.map +1 -0
- package/dist/pipeline/executor.d.ts +54 -0
- package/dist/pipeline/executor.d.ts.map +1 -0
- package/dist/pipeline/executor.js +133 -0
- package/dist/pipeline/executor.js.map +1 -0
- package/dist/pipeline/handlers/assemble.d.ts +16 -0
- package/dist/pipeline/handlers/assemble.d.ts.map +1 -0
- package/dist/pipeline/handlers/assemble.js +72 -0
- package/dist/pipeline/handlers/assemble.js.map +1 -0
- package/dist/pipeline/handlers/build-tool-query.d.ts +30 -0
- package/dist/pipeline/handlers/build-tool-query.d.ts.map +1 -0
- package/dist/pipeline/handlers/build-tool-query.js +80 -0
- package/dist/pipeline/handlers/build-tool-query.js.map +1 -0
- package/dist/pipeline/handlers/classify.d.ts +21 -0
- package/dist/pipeline/handlers/classify.d.ts.map +1 -0
- package/dist/pipeline/handlers/classify.js +60 -0
- package/dist/pipeline/handlers/classify.js.map +1 -0
- package/dist/pipeline/handlers/expand.d.ts +16 -0
- package/dist/pipeline/handlers/expand.d.ts.map +1 -0
- package/dist/pipeline/handlers/expand.js +24 -0
- package/dist/pipeline/handlers/expand.js.map +1 -0
- package/dist/pipeline/handlers/history-upsert.d.ts +29 -0
- package/dist/pipeline/handlers/history-upsert.d.ts.map +1 -0
- package/dist/pipeline/handlers/history-upsert.js +75 -0
- package/dist/pipeline/handlers/history-upsert.js.map +1 -0
- package/dist/pipeline/handlers/index.d.ts +31 -0
- package/dist/pipeline/handlers/index.d.ts.map +1 -0
- package/dist/pipeline/handlers/index.js +44 -0
- package/dist/pipeline/handlers/index.js.map +1 -0
- package/dist/pipeline/handlers/rag-query.d.ts +27 -0
- package/dist/pipeline/handlers/rag-query.d.ts.map +1 -0
- package/dist/pipeline/handlers/rag-query.js +117 -0
- package/dist/pipeline/handlers/rag-query.js.map +1 -0
- package/dist/pipeline/handlers/rerank.d.ts +16 -0
- package/dist/pipeline/handlers/rerank.d.ts.map +1 -0
- package/dist/pipeline/handlers/rerank.js +27 -0
- package/dist/pipeline/handlers/rerank.js.map +1 -0
- package/dist/pipeline/handlers/skill-select.d.ts +18 -0
- package/dist/pipeline/handlers/skill-select.d.ts.map +1 -0
- package/dist/pipeline/handlers/skill-select.js +88 -0
- package/dist/pipeline/handlers/skill-select.js.map +1 -0
- package/dist/pipeline/handlers/summarize.d.ts +17 -0
- package/dist/pipeline/handlers/summarize.d.ts.map +1 -0
- package/dist/pipeline/handlers/summarize.js +56 -0
- package/dist/pipeline/handlers/summarize.js.map +1 -0
- package/dist/pipeline/handlers/tool-loop.d.ts +32 -0
- package/dist/pipeline/handlers/tool-loop.d.ts.map +1 -0
- package/dist/pipeline/handlers/tool-loop.js +734 -0
- package/dist/pipeline/handlers/tool-loop.js.map +1 -0
- package/dist/pipeline/handlers/tool-select.d.ts +21 -0
- package/dist/pipeline/handlers/tool-select.d.ts.map +1 -0
- package/dist/pipeline/handlers/tool-select.js +109 -0
- package/dist/pipeline/handlers/tool-select.js.map +1 -0
- package/dist/pipeline/handlers/translate.d.ts +17 -0
- package/dist/pipeline/handlers/translate.d.ts.map +1 -0
- package/dist/pipeline/handlers/translate.js +42 -0
- package/dist/pipeline/handlers/translate.js.map +1 -0
- package/dist/pipeline/index.d.ts +14 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +16 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/stage-handler.d.ts +27 -0
- package/dist/pipeline/stage-handler.d.ts.map +1 -0
- package/dist/pipeline/stage-handler.js +25 -0
- package/dist/pipeline/stage-handler.js.map +1 -0
- package/dist/pipeline/types.d.ts +5 -0
- package/dist/pipeline/types.d.ts.map +1 -0
- package/dist/pipeline/types.js +2 -0
- package/dist/pipeline/types.js.map +1 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +3 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/loader.d.ts +67 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +114 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/types.d.ts +24 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +86 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/policy/heuristic-injection-detector.d.ts +5 -0
- package/dist/policy/heuristic-injection-detector.d.ts.map +1 -0
- package/dist/policy/heuristic-injection-detector.js +36 -0
- package/dist/policy/heuristic-injection-detector.js.map +1 -0
- package/dist/policy/index.d.ts +6 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +5 -0
- package/dist/policy/index.js.map +1 -0
- package/dist/policy/mixed-tool-call-handler.d.ts +15 -0
- package/dist/policy/mixed-tool-call-handler.d.ts.map +1 -0
- package/dist/policy/mixed-tool-call-handler.js +49 -0
- package/dist/policy/mixed-tool-call-handler.js.map +1 -0
- package/dist/policy/pending-tool-results-registry.d.ts +25 -0
- package/dist/policy/pending-tool-results-registry.d.ts.map +1 -0
- package/dist/policy/pending-tool-results-registry.js +50 -0
- package/dist/policy/pending-tool-results-registry.js.map +1 -0
- package/dist/policy/tool-availability-registry.d.ts +21 -0
- package/dist/policy/tool-availability-registry.d.ts.map +1 -0
- package/dist/policy/tool-availability-registry.js +77 -0
- package/dist/policy/tool-availability-registry.js.map +1 -0
- package/dist/policy/tool-policy-guard.d.ts +8 -0
- package/dist/policy/tool-policy-guard.d.ts.map +1 -0
- package/dist/policy/tool-policy-guard.js +40 -0
- package/dist/policy/tool-policy-guard.js.map +1 -0
- package/dist/policy/types.d.ts +51 -0
- package/dist/policy/types.d.ts.map +1 -0
- package/dist/policy/types.js +17 -0
- package/dist/policy/types.js.map +1 -0
- package/dist/providers.d.ts +48 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +192 -0
- package/dist/providers.js.map +1 -0
- package/dist/reranker/index.d.ts +4 -0
- package/dist/reranker/index.d.ts.map +1 -0
- package/dist/reranker/index.js +3 -0
- package/dist/reranker/index.js.map +1 -0
- package/dist/reranker/llm-reranker.d.ts +10 -0
- package/dist/reranker/llm-reranker.d.ts.map +1 -0
- package/dist/reranker/llm-reranker.js +55 -0
- package/dist/reranker/llm-reranker.js.map +1 -0
- package/dist/reranker/noop-reranker.d.ts +6 -0
- package/dist/reranker/noop-reranker.d.ts.map +1 -0
- package/dist/reranker/noop-reranker.js +6 -0
- package/dist/reranker/noop-reranker.js.map +1 -0
- package/dist/reranker/types.d.ts +2 -0
- package/dist/reranker/types.d.ts.map +1 -0
- package/dist/reranker/types.js +2 -0
- package/dist/reranker/types.js.map +1 -0
- package/dist/resilience/rate-limiter-llm.d.ts +17 -0
- package/dist/resilience/rate-limiter-llm.d.ts.map +1 -0
- package/dist/resilience/rate-limiter-llm.js +30 -0
- package/dist/resilience/rate-limiter-llm.js.map +1 -0
- package/dist/resilience/retry-llm.d.ts +32 -0
- package/dist/resilience/retry-llm.d.ts.map +1 -0
- package/dist/resilience/retry-llm.js +103 -0
- package/dist/resilience/retry-llm.js.map +1 -0
- package/dist/resilience/token-bucket-rate-limiter.d.ts +21 -0
- package/dist/resilience/token-bucket-rate-limiter.d.ts.map +1 -0
- package/dist/resilience/token-bucket-rate-limiter.js +32 -0
- package/dist/resilience/token-bucket-rate-limiter.js.map +1 -0
- package/dist/session/index.d.ts +4 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +3 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/noop-session-manager.d.ts +8 -0
- package/dist/session/noop-session-manager.d.ts.map +1 -0
- package/dist/session/noop-session-manager.js +11 -0
- package/dist/session/noop-session-manager.js.map +1 -0
- package/dist/session/session-manager.d.ts +13 -0
- package/dist/session/session-manager.d.ts.map +1 -0
- package/dist/session/session-manager.js +20 -0
- package/dist/session/session-manager.js.map +1 -0
- package/dist/session/types.d.ts +2 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +2 -0
- package/dist/session/types.js.map +1 -0
- package/dist/skills/claude-skill-manager.d.ts +24 -0
- package/dist/skills/claude-skill-manager.d.ts.map +1 -0
- package/dist/skills/claude-skill-manager.js +81 -0
- package/dist/skills/claude-skill-manager.js.map +1 -0
- package/dist/skills/codex-skill-manager.d.ts +20 -0
- package/dist/skills/codex-skill-manager.d.ts.map +1 -0
- package/dist/skills/codex-skill-manager.js +75 -0
- package/dist/skills/codex-skill-manager.js.map +1 -0
- package/dist/skills/filesystem-skill-manager.d.ts +17 -0
- package/dist/skills/filesystem-skill-manager.d.ts.map +1 -0
- package/dist/skills/filesystem-skill-manager.js +48 -0
- package/dist/skills/filesystem-skill-manager.js.map +1 -0
- package/dist/skills/filesystem-skill.d.ts +25 -0
- package/dist/skills/filesystem-skill.d.ts.map +1 -0
- package/dist/skills/filesystem-skill.js +110 -0
- package/dist/skills/filesystem-skill.js.map +1 -0
- package/dist/skills/index.d.ts +9 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +9 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/skill-utils.d.ts +15 -0
- package/dist/skills/skill-utils.d.ts.map +1 -0
- package/dist/skills/skill-utils.js +46 -0
- package/dist/skills/skill-utils.js.map +1 -0
- package/dist/testing/index.d.ts +118 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +351 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/tracer/index.d.ts +3 -0
- package/dist/tracer/index.d.ts.map +1 -0
- package/dist/tracer/index.js +2 -0
- package/dist/tracer/index.js.map +1 -0
- package/dist/tracer/noop-tracer.d.ts +5 -0
- package/dist/tracer/noop-tracer.d.ts.map +1 -0
- package/dist/tracer/noop-tracer.js +16 -0
- package/dist/tracer/noop-tracer.js.map +1 -0
- package/dist/tracer/types.d.ts +2 -0
- package/dist/tracer/types.d.ts.map +1 -0
- package/dist/tracer/types.js +2 -0
- package/dist/tracer/types.js.map +1 -0
- package/dist/utils/lazy.d.ts +51 -0
- package/dist/utils/lazy.d.ts.map +1 -0
- package/dist/utils/lazy.js +127 -0
- package/dist/utils/lazy.js.map +1 -0
- package/dist/utils/parse-frontmatter.d.ts +15 -0
- package/dist/utils/parse-frontmatter.d.ts.map +1 -0
- package/dist/utils/parse-frontmatter.js +22 -0
- package/dist/utils/parse-frontmatter.js.map +1 -0
- package/dist/validator/index.d.ts +3 -0
- package/dist/validator/index.d.ts.map +1 -0
- package/dist/validator/index.js +2 -0
- package/dist/validator/index.js.map +1 -0
- package/dist/validator/noop-validator.d.ts +6 -0
- package/dist/validator/noop-validator.d.ts.map +1 -0
- package/dist/validator/noop-validator.js +6 -0
- package/dist/validator/noop-validator.js.map +1 -0
- package/dist/validator/types.d.ts +3 -0
- package/dist/validator/types.d.ts.map +1 -0
- package/dist/validator/types.js +2 -0
- package/dist/validator/types.js.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { AssemblerError, } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
export const DEFAULT_REASONING_INSTRUCTION = `IMPORTANT: Always start your response with a brief <reasoning> block.
|
|
3
|
+
Explain:
|
|
4
|
+
1. Which tools you selected and why.
|
|
5
|
+
2. How you interpreted the retrieved context.
|
|
6
|
+
3. Your step-by-step strategy for the current turn.
|
|
7
|
+
The reasoning block must be visible to the user and placed at the very beginning.`;
|
|
8
|
+
const DEFAULT_SECTION_HEADERS = {
|
|
9
|
+
facts: 'Known Facts',
|
|
10
|
+
feedback: 'Feedback',
|
|
11
|
+
state: 'Current State',
|
|
12
|
+
history: 'Relevant History',
|
|
13
|
+
};
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Module-private helpers
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
/** Type guard: ToolCallRecord has `call` and `result`, Message has `role`. */
|
|
18
|
+
function isToolCallRecord(item) {
|
|
19
|
+
return (typeof item === 'object' &&
|
|
20
|
+
item !== null &&
|
|
21
|
+
'call' in item &&
|
|
22
|
+
'result' in item);
|
|
23
|
+
}
|
|
24
|
+
/** Approximate token count: ceil(text.length / 4) */
|
|
25
|
+
function estimateTokens(text) {
|
|
26
|
+
return Math.ceil(text.length / 4);
|
|
27
|
+
}
|
|
28
|
+
/** Single RagResult → "- <text> [score: 0.92]" (provenance) or "- <text>" */
|
|
29
|
+
function formatRagEntry(r, provenance) {
|
|
30
|
+
if (provenance) {
|
|
31
|
+
return `- ${r.text} [score: ${r.score.toFixed(2)}]`;
|
|
32
|
+
}
|
|
33
|
+
return `- ${r.text}`;
|
|
34
|
+
}
|
|
35
|
+
/** Header + entries → "## Header\n- e1\n- e2" or '' if entries empty */
|
|
36
|
+
function buildSection(header, entries) {
|
|
37
|
+
if (entries.length === 0)
|
|
38
|
+
return '';
|
|
39
|
+
return `## ${header}\n${entries.join('\n')}`;
|
|
40
|
+
}
|
|
41
|
+
/** Derive a display header from a store key (e.g. 'my_store' → 'My Store') */
|
|
42
|
+
function titleCase(key) {
|
|
43
|
+
return key.replace(/[_-]/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
|
44
|
+
}
|
|
45
|
+
/** Combine all sections into system message content */
|
|
46
|
+
function buildSystemContent(ragResults, provenance, sectionHeaders, recentActions) {
|
|
47
|
+
const sections = [];
|
|
48
|
+
for (const [key, results] of Object.entries(ragResults)) {
|
|
49
|
+
const header = sectionHeaders[key] ?? titleCase(key);
|
|
50
|
+
const section = buildSection(header, results.map((r) => formatRagEntry(r, provenance)));
|
|
51
|
+
if (section)
|
|
52
|
+
sections.push(section);
|
|
53
|
+
}
|
|
54
|
+
if (recentActions && recentActions.length > 0) {
|
|
55
|
+
const section = buildSection('Recent Actions', recentActions.map((a) => `- ${a}`));
|
|
56
|
+
if (section)
|
|
57
|
+
sections.push(section);
|
|
58
|
+
}
|
|
59
|
+
return sections.join('\n\n');
|
|
60
|
+
}
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// Token budgeting
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
/**
|
|
65
|
+
* Drop entries until total token count fits within budget.
|
|
66
|
+
* Trims stores in reverse insertion order, then tools last.
|
|
67
|
+
*/
|
|
68
|
+
function applyTokenBudget(ragResults, actionTokens, maxTokens, provenance, sectionHeaders, recentActions) {
|
|
69
|
+
const mutableResults = {};
|
|
70
|
+
for (const [key, arr] of Object.entries(ragResults)) {
|
|
71
|
+
mutableResults[key] = [...arr];
|
|
72
|
+
}
|
|
73
|
+
const storeKeys = Object.keys(mutableResults);
|
|
74
|
+
const totalTokens = () => {
|
|
75
|
+
const content = buildSystemContent(mutableResults, provenance, sectionHeaders, recentActions);
|
|
76
|
+
return actionTokens + estimateTokens(content);
|
|
77
|
+
};
|
|
78
|
+
while (totalTokens() > maxTokens) {
|
|
79
|
+
let trimmed = false;
|
|
80
|
+
for (let i = storeKeys.length - 1; i >= 0; i--) {
|
|
81
|
+
const key = storeKeys[i];
|
|
82
|
+
if (mutableResults[key].length > 0) {
|
|
83
|
+
mutableResults[key] = mutableResults[key].slice(0, -1);
|
|
84
|
+
trimmed = true;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!trimmed)
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
return mutableResults;
|
|
92
|
+
}
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
// ContextAssembler
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
export class ContextAssembler {
|
|
97
|
+
maxTokens;
|
|
98
|
+
systemPromptPreamble;
|
|
99
|
+
includeProvenance;
|
|
100
|
+
showReasoning;
|
|
101
|
+
reasoningInstruction;
|
|
102
|
+
sectionHeaders;
|
|
103
|
+
historyRecencyWindow;
|
|
104
|
+
constructor(config) {
|
|
105
|
+
this.maxTokens = config?.maxTokens;
|
|
106
|
+
this.systemPromptPreamble = config?.systemPromptPreamble;
|
|
107
|
+
this.includeProvenance = config?.includeProvenance ?? false;
|
|
108
|
+
this.showReasoning = config?.showReasoning ?? false;
|
|
109
|
+
this.reasoningInstruction = config?.reasoningInstruction;
|
|
110
|
+
this.sectionHeaders = {
|
|
111
|
+
...DEFAULT_SECTION_HEADERS,
|
|
112
|
+
...config?.sectionHeaders,
|
|
113
|
+
};
|
|
114
|
+
this.historyRecencyWindow = config?.historyRecencyWindow;
|
|
115
|
+
}
|
|
116
|
+
async assemble(action, retrieved, history, options) {
|
|
117
|
+
try {
|
|
118
|
+
if (options?.signal?.aborted) {
|
|
119
|
+
return { ok: false, error: new AssemblerError('Aborted', 'ABORTED') };
|
|
120
|
+
}
|
|
121
|
+
// Sort all RAG results by score descending
|
|
122
|
+
const sortedResults = {};
|
|
123
|
+
for (const [key, results] of Object.entries(retrieved.ragResults)) {
|
|
124
|
+
sortedResults[key] = [...results].sort((a, b) => b.score - a.score);
|
|
125
|
+
}
|
|
126
|
+
let finalResults = sortedResults;
|
|
127
|
+
if (this.maxTokens !== undefined) {
|
|
128
|
+
finalResults = applyTokenBudget(sortedResults, estimateTokens(action.text), this.maxTokens, this.includeProvenance, this.sectionHeaders, retrieved.recentActions);
|
|
129
|
+
}
|
|
130
|
+
const systemContent = buildSystemContent(finalResults, this.includeProvenance, this.sectionHeaders, retrieved.recentActions);
|
|
131
|
+
const messages = [];
|
|
132
|
+
const preamble = this.systemPromptPreamble ?? '';
|
|
133
|
+
const toolGuidance = 'Use available tools when they can accomplish the task. When an action is impossible with available tools — say so clearly and do not attempt it.';
|
|
134
|
+
if (preamble || systemContent || this.showReasoning) {
|
|
135
|
+
const parts = [
|
|
136
|
+
preamble,
|
|
137
|
+
toolGuidance,
|
|
138
|
+
this.showReasoning
|
|
139
|
+
? this.reasoningInstruction || DEFAULT_REASONING_INSTRUCTION
|
|
140
|
+
: '',
|
|
141
|
+
systemContent,
|
|
142
|
+
].filter(Boolean);
|
|
143
|
+
messages.push({ role: 'system', content: parts.join('\n\n') });
|
|
144
|
+
}
|
|
145
|
+
// Separate regular messages from tool call records
|
|
146
|
+
const regularMessages = [];
|
|
147
|
+
const toolMessages = [];
|
|
148
|
+
for (const item of history) {
|
|
149
|
+
if (isToolCallRecord(item)) {
|
|
150
|
+
const raw = item.result.content;
|
|
151
|
+
const text = typeof raw === 'string' ? raw : JSON.stringify(raw);
|
|
152
|
+
toolMessages.push({
|
|
153
|
+
role: 'tool',
|
|
154
|
+
content: `${item.call.name}: ${text}`,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
else if (item.role !== 'system') {
|
|
158
|
+
regularMessages.push(item);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Apply recency window — keep only the last N messages from client history.
|
|
162
|
+
// Older messages are excluded; they are available via RAG stores if needed.
|
|
163
|
+
const windowedMessages = this.historyRecencyWindow !== undefined &&
|
|
164
|
+
regularMessages.length > this.historyRecencyWindow
|
|
165
|
+
? regularMessages.slice(-this.historyRecencyWindow)
|
|
166
|
+
: regularMessages;
|
|
167
|
+
if (windowedMessages.length > 0) {
|
|
168
|
+
messages.push(...windowedMessages);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
messages.push({ role: 'user', content: action.text });
|
|
172
|
+
}
|
|
173
|
+
messages.push(...toolMessages);
|
|
174
|
+
return { ok: true, value: messages };
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
return {
|
|
178
|
+
ok: false,
|
|
179
|
+
error: new AssemblerError(String(err), 'ASSEMBLER_ERROR'),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=context-assembler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-assembler.js","sourceRoot":"","sources":["../../src/context/context-assembler.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,cAAc,GAOf,MAAM,yBAAyB,CAAC;AAqCjC,MAAM,CAAC,MAAM,6BAA6B,GAAG;;;;;kFAKqC,CAAC;AAEnF,MAAM,uBAAuB,GAA2B;IACtD,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,eAAe;IACtB,OAAO,EAAE,kBAAkB;CAC5B,CAAC;AAEF,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E,8EAA8E;AAC9E,SAAS,gBAAgB,CAAC,IAAa;IACrC,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,MAAM,IAAI,IAAI;QACd,QAAQ,IAAI,IAAI,CACjB,CAAC;AACJ,CAAC;AAED,qDAAqD;AACrD,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,6EAA6E;AAC7E,SAAS,cAAc,CAAC,CAAY,EAAE,UAAmB;IACvD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,KAAK,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACtD,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC;AAED,wEAAwE;AACxE,SAAS,YAAY,CAAC,MAAc,EAAE,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C,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,iBAAiB,CAAC;aAC1D,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CircuitBreaker } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import type { SmartAgent } from '../agent.js';
|
|
3
|
+
import type { InMemoryMetrics } from '../metrics/in-memory-metrics.js';
|
|
4
|
+
import type { HealthStatus } from './types.js';
|
|
5
|
+
export interface HealthCheckerDeps {
|
|
6
|
+
agent: SmartAgent;
|
|
7
|
+
startTime: number;
|
|
8
|
+
version: string;
|
|
9
|
+
circuitBreakers?: CircuitBreaker[];
|
|
10
|
+
metrics?: InMemoryMetrics;
|
|
11
|
+
}
|
|
12
|
+
export declare class HealthChecker {
|
|
13
|
+
private readonly agent;
|
|
14
|
+
private readonly startTime;
|
|
15
|
+
private readonly version;
|
|
16
|
+
private readonly circuitBreakers;
|
|
17
|
+
private readonly metrics?;
|
|
18
|
+
constructor(deps: HealthCheckerDeps);
|
|
19
|
+
check(): Promise<HealthStatus>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=health-checker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-checker.d.ts","sourceRoot":"","sources":["../../src/health/health-checker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmB;IACnD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAkB;gBAE/B,IAAI,EAAE,iBAAiB;IAQ7B,KAAK,IAAI,OAAO,CAAC,YAAY,CAAC;CA6CrC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export class HealthChecker {
|
|
2
|
+
agent;
|
|
3
|
+
startTime;
|
|
4
|
+
version;
|
|
5
|
+
circuitBreakers;
|
|
6
|
+
metrics;
|
|
7
|
+
constructor(deps) {
|
|
8
|
+
this.agent = deps.agent;
|
|
9
|
+
this.startTime = deps.startTime;
|
|
10
|
+
this.version = deps.version;
|
|
11
|
+
this.circuitBreakers = deps.circuitBreakers ?? [];
|
|
12
|
+
this.metrics = deps.metrics;
|
|
13
|
+
}
|
|
14
|
+
async check() {
|
|
15
|
+
const healthResult = await this.agent.healthCheck();
|
|
16
|
+
const components = healthResult.ok
|
|
17
|
+
? healthResult.value
|
|
18
|
+
: { llm: false, rag: false, mcp: [] };
|
|
19
|
+
const cbStatuses = this.circuitBreakers.length > 0
|
|
20
|
+
? this.circuitBreakers.map((cb, i) => ({
|
|
21
|
+
index: i,
|
|
22
|
+
state: cb.state,
|
|
23
|
+
}))
|
|
24
|
+
: undefined;
|
|
25
|
+
const metricsSnapshot = this.metrics?.snapshot();
|
|
26
|
+
// Determine overall status
|
|
27
|
+
const llmOk = components.llm;
|
|
28
|
+
const ragOk = components.rag;
|
|
29
|
+
const mcpAllOk = components.mcp.length === 0 || components.mcp.every((m) => m.ok);
|
|
30
|
+
const anyCircuitOpen = this.circuitBreakers.some((cb) => cb.state === 'open');
|
|
31
|
+
let status;
|
|
32
|
+
if (!llmOk) {
|
|
33
|
+
status = 'unhealthy';
|
|
34
|
+
}
|
|
35
|
+
else if (!ragOk || !mcpAllOk || anyCircuitOpen) {
|
|
36
|
+
status = 'degraded';
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
status = 'healthy';
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
status,
|
|
43
|
+
uptime: Date.now() - this.startTime,
|
|
44
|
+
version: this.version,
|
|
45
|
+
timestamp: new Date().toISOString(),
|
|
46
|
+
components,
|
|
47
|
+
...(cbStatuses ? { circuitBreakers: cbStatuses } : {}),
|
|
48
|
+
...(metricsSnapshot ? { metrics: metricsSnapshot } : {}),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=health-checker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-checker.js","sourceRoot":"","sources":["../../src/health/health-checker.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,aAAa;IACP,KAAK,CAAa;IAClB,SAAS,CAAS;IAClB,OAAO,CAAS;IAChB,eAAe,CAAmB;IAClC,OAAO,CAAmB;IAE3C,YAAY,IAAuB;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC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AE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,KAAK,MAAM,CAC5B,CAAC;QAEF,IAAI,MAA4C,CAAC;QACjD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,GAAG,WAAW,CAAC;QACvB,CAAC;aAAM,IAAI,CAAC,KAAK,IAAI,CAAC,QAAQ,IAAI,cAAc,EAAE,CAAC;YACjD,MAAM,GAAG,UAAU,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,SAAS,CAAC;QACrB,CAAC;QAED,OAAO;YACL,MAAM;YACN,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS;YACnC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,UAAU;YACV,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACtD,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACzD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/health/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,GACb,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/health/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/health/types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,GACb,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/health/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IHistoryMemory } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
export declare class HistoryMemory implements IHistoryMemory {
|
|
3
|
+
private readonly maxSize;
|
|
4
|
+
private readonly sessions;
|
|
5
|
+
constructor(opts?: {
|
|
6
|
+
maxSize?: number;
|
|
7
|
+
});
|
|
8
|
+
pushRecent(sessionId: string, summary: string): void;
|
|
9
|
+
getRecent(sessionId: string, limit: number): string[];
|
|
10
|
+
clear(sessionId: string): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=history-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-memory.d.ts","sourceRoot":"","sources":["../../src/history/history-memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+B;gBAE5C,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAIvC,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAYpD,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAKrD,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAG/B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class HistoryMemory {
|
|
2
|
+
maxSize;
|
|
3
|
+
sessions = new Map();
|
|
4
|
+
constructor(opts) {
|
|
5
|
+
this.maxSize = opts?.maxSize ?? 50;
|
|
6
|
+
}
|
|
7
|
+
pushRecent(sessionId, summary) {
|
|
8
|
+
let entries = this.sessions.get(sessionId);
|
|
9
|
+
if (!entries) {
|
|
10
|
+
entries = [];
|
|
11
|
+
this.sessions.set(sessionId, entries);
|
|
12
|
+
}
|
|
13
|
+
entries.push(summary);
|
|
14
|
+
if (entries.length > this.maxSize) {
|
|
15
|
+
entries.splice(0, entries.length - this.maxSize);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
getRecent(sessionId, limit) {
|
|
19
|
+
const entries = this.sessions.get(sessionId) ?? [];
|
|
20
|
+
return entries.slice(-limit);
|
|
21
|
+
}
|
|
22
|
+
clear(sessionId) {
|
|
23
|
+
this.sessions.delete(sessionId);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=history-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-memory.js","sourceRoot":"","sources":["../../src/history/history-memory.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;IACP,OAAO,CAAS;IAChB,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;IAExD,YAAY,IAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;IACrC,CAAC;IAED,UAAU,CAAC,SAAiB,EAAE,OAAe;QAC3C,IAAI,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,SAAS,CAAC,SAAiB,EAAE,KAAa;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACnD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,SAAiB;QACrB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CallOptions, HistoryTurn, IHistorySummarizer, ILlm, LlmError, Result } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
export declare class HistorySummarizer implements IHistorySummarizer {
|
|
3
|
+
private readonly llm;
|
|
4
|
+
private readonly prompt;
|
|
5
|
+
constructor(llm: ILlm, opts?: {
|
|
6
|
+
prompt?: string;
|
|
7
|
+
});
|
|
8
|
+
summarize(turn: HistoryTurn, options?: CallOptions): Promise<Result<string, LlmError>>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=history-summarizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-summarizer.d.ts","sourceRoot":"","sources":["../../src/history/history-summarizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,IAAI,EACJ,QAAQ,EAER,MAAM,EACP,MAAM,yBAAyB,CAAC;AAKjC,qBAAa,iBAAkB,YAAW,kBAAkB;IAIxD,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAGb,GAAG,EAAE,IAAI,EAC1B,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAKtB,SAAS,CACb,IAAI,EAAE,WAAW,EACjB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CAmBrC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const DEFAULT_PROMPT = 'Summarize in one sentence: what the user requested and what was done. Include key identifiers (class names, table names, etc). Do not include greetings or filler.';
|
|
2
|
+
export class HistorySummarizer {
|
|
3
|
+
llm;
|
|
4
|
+
prompt;
|
|
5
|
+
constructor(llm, opts) {
|
|
6
|
+
this.llm = llm;
|
|
7
|
+
this.prompt = opts?.prompt ?? DEFAULT_PROMPT;
|
|
8
|
+
}
|
|
9
|
+
async summarize(turn, options) {
|
|
10
|
+
const toolSection = turn.toolCalls.length > 0
|
|
11
|
+
? `\nTools called: ${turn.toolCalls.map((tc) => `${tc.name}(${JSON.stringify(tc.arguments)})`).join(', ')}` +
|
|
12
|
+
`\nTool results: ${turn.toolResults.map((tr) => `${tr.tool}: ${tr.content.slice(0, 200)}`).join('; ')}`
|
|
13
|
+
: '';
|
|
14
|
+
const messages = [
|
|
15
|
+
{ role: 'system', content: this.prompt },
|
|
16
|
+
{
|
|
17
|
+
role: 'user',
|
|
18
|
+
content: `User request: ${turn.userText}\nAssistant response: ${turn.assistantText}${toolSection}`,
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
const result = await this.llm.chat(messages, undefined, options);
|
|
22
|
+
if (!result.ok)
|
|
23
|
+
return result;
|
|
24
|
+
return { ok: true, value: result.value.content.trim() };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=history-summarizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-summarizer.js","sourceRoot":"","sources":["../../src/history/history-summarizer.ts"],"names":[],"mappings":"AAUA,MAAM,cAAc,GAClB,oKAAoK,CAAC;AAEvK,MAAM,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CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;IAC1D,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/history/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/history/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mcp-abap-adt/llm-agent-libs — core SmartAgent composition surface.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the runtime composition classes that are needed to build a
|
|
5
|
+
* SmartAgent without depending on @mcp-abap-adt/llm-agent-server.
|
|
6
|
+
*/
|
|
7
|
+
export { type AgentCallOptions, type BaseAgentLlmBridge, LlmAdapter, type LlmAdapterProviderInfo, } from './adapters/llm-adapter.js';
|
|
8
|
+
export { LlmProviderBridge } from './adapters/llm-provider-bridge.js';
|
|
9
|
+
export { NonStreamingLlm } from './adapters/non-streaming-llm.js';
|
|
10
|
+
export { OrchestratorError, SmartAgent, type SmartAgentConfig, type SmartAgentDeps, type SmartAgentRagStores, type SmartAgentReconfigureOptions, type SmartAgentResponse, type StopReason, } from './agent.js';
|
|
11
|
+
export { type BuilderMcpConfig, type BuilderPromptsConfig, SmartAgentBuilder, type SmartAgentBuilderConfig, type SmartAgentHandle, } from './builder.js';
|
|
12
|
+
export { ConfigWatcher, type ConfigWatcherOptions, type HotReloadableConfig, } from './config/config-watcher.js';
|
|
13
|
+
export { HealthChecker, type HealthCheckerDeps, } from './health/health-checker.js';
|
|
14
|
+
export { HistoryMemory } from './history/history-memory.js';
|
|
15
|
+
export { HistorySummarizer } from './history/history-summarizer.js';
|
|
16
|
+
export type { IPipeline, PipelineDeps, PipelineResult, } from './interfaces/pipeline.js';
|
|
17
|
+
export { DefaultRequestLogger } from './logger/default-request-logger.js';
|
|
18
|
+
export { NoopRequestLogger } from './logger/noop-request-logger.js';
|
|
19
|
+
export { SessionLogger } from './logger/session-logger.js';
|
|
20
|
+
export { type CounterSnapshot, type HistogramSnapshot, InMemoryMetrics, type MetricsSnapshot, } from './metrics/in-memory-metrics.js';
|
|
21
|
+
export { NoopMetrics } from './metrics/noop-metrics.js';
|
|
22
|
+
export { type BuiltInStageType, buildDefaultHandlerRegistry, type ControlFlowType, DefaultPipeline, evaluateCondition, type IStageHandler, type PipelineContext, PipelineExecutor, type StageDefinition, type StageType, } from './pipeline/index.js';
|
|
23
|
+
export type { IPluginLoader, LoadedPlugins, PluginExports, } from './plugins/index.js';
|
|
24
|
+
export { emptyLoadedPlugins, FileSystemPluginLoader, type FileSystemPluginLoaderConfig, getDefaultPluginDirs, loadPlugins, mergePluginExports, } from './plugins/index.js';
|
|
25
|
+
export { DefaultModelResolver, type MakeLlmConfig, makeDefaultLlm, makeLlm, } from './providers.js';
|
|
26
|
+
export { LlmReranker } from './reranker/llm-reranker.js';
|
|
27
|
+
export { NoopReranker } from './reranker/noop-reranker.js';
|
|
28
|
+
export { RateLimiterLlm } from './resilience/rate-limiter-llm.js';
|
|
29
|
+
export { RetryLlm, type RetryOptions } from './resilience/retry-llm.js';
|
|
30
|
+
export { type TokenBucketConfig, TokenBucketRateLimiter, } from './resilience/token-bucket-rate-limiter.js';
|
|
31
|
+
export { NoopSessionManager } from './session/noop-session-manager.js';
|
|
32
|
+
export { SessionManager } from './session/session-manager.js';
|
|
33
|
+
export { ClaudeSkillManager, CodexSkillManager, FileSystemSkillManager, } from './skills/index.js';
|
|
34
|
+
export { NoopTracer } from './tracer/noop-tracer.js';
|
|
35
|
+
export { LazyInitError, type LazyOptions, lazy } from './utils/lazy.js';
|
|
36
|
+
export { NoopValidator } from './validator/noop-validator.js';
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,UAAU,EACV,KAAK,sBAAsB,GAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EACvB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AAIpB,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,iBAAiB,EACjB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AAItB,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EACL,aAAa,EACb,KAAK,iBAAiB,GACvB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,YAAY,EACV,SAAS,EACT,YAAY,EACZ,cAAc,GACf,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EA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O,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mcp-abap-adt/llm-agent-libs — core SmartAgent composition surface.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the runtime composition classes that are needed to build a
|
|
5
|
+
* SmartAgent without depending on @mcp-abap-adt/llm-agent-server.
|
|
6
|
+
*/
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Adapters
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
export { LlmAdapter, } from './adapters/llm-adapter.js';
|
|
11
|
+
export { LlmProviderBridge } from './adapters/llm-provider-bridge.js';
|
|
12
|
+
export { NonStreamingLlm } from './adapters/non-streaming-llm.js';
|
|
13
|
+
export { OrchestratorError, SmartAgent, } from './agent.js';
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Builder + agent
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
export { SmartAgentBuilder, } from './builder.js';
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Config
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
export { ConfigWatcher, } from './config/config-watcher.js';
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Health
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
export { HealthChecker, } from './health/health-checker.js';
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// History
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
export { HistoryMemory } from './history/history-memory.js';
|
|
30
|
+
export { HistorySummarizer } from './history/history-summarizer.js';
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Logger
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
export { DefaultRequestLogger } from './logger/default-request-logger.js';
|
|
35
|
+
export { NoopRequestLogger } from './logger/noop-request-logger.js';
|
|
36
|
+
export { SessionLogger } from './logger/session-logger.js';
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Metrics
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
export { InMemoryMetrics, } from './metrics/in-memory-metrics.js';
|
|
41
|
+
export { NoopMetrics } from './metrics/noop-metrics.js';
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Pipeline
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
export { buildDefaultHandlerRegistry, DefaultPipeline, evaluateCondition, PipelineExecutor, } from './pipeline/index.js';
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
// Plugins
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
export { emptyLoadedPlugins, FileSystemPluginLoader, getDefaultPluginDirs, loadPlugins, mergePluginExports, } from './plugins/index.js';
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// Providers (LLM)
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
export { DefaultModelResolver, makeDefaultLlm, makeLlm, } from './providers.js';
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// Reranker
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
export { LlmReranker } from './reranker/llm-reranker.js';
|
|
58
|
+
export { NoopReranker } from './reranker/noop-reranker.js';
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Resilience
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
export { RateLimiterLlm } from './resilience/rate-limiter-llm.js';
|
|
63
|
+
export { RetryLlm } from './resilience/retry-llm.js';
|
|
64
|
+
export { TokenBucketRateLimiter, } from './resilience/token-bucket-rate-limiter.js';
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// Session
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
export { NoopSessionManager } from './session/noop-session-manager.js';
|
|
69
|
+
export { SessionManager } from './session/session-manager.js';
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
// Skills
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
export { ClaudeSkillManager, CodexSkillManager, FileSystemSkillManager, } from './skills/index.js';
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// Tracer
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
export { NoopTracer } from './tracer/noop-tracer.js';
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// Utils
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
export { LazyInitError, lazy } from './utils/lazy.js';
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Validator
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
export { NoopValidator } from './validator/noop-validator.js';
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,8EAA8E;AAC9E,WAAW;AACX,8EAA8E;AAC9E,OAAO,EAGL,UAAU,GAEX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,UAAU,GAOX,MAAM,YAAY,CAAC;AACpB,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAC9E,OAAO,EAGL,iBAAiB,GAGlB,MAAM,cAAc,CAAC;AACtB,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAC9E,OAAO,EACL,aAAa,GAGd,MAAM,4BAA4B,CAAC;AACpC,8EAA8E;AAC9E,SAAS;AACT,8E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AM,2BAA2B,CAAC;AACxE,OAAO,EAEL,sBAAsB,GACvB,MAAM,2CAA2C,CAAC;AAEnD,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAC9E,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,8EAA8E;AAC9E,QAAQ;AACR,8EAA8E;AAC9E,OAAO,EAAE,aAAa,EAAoB,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAExE,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-connection-strategy.d.ts","sourceRoot":"","sources":["../../src/interfaces/mcp-connection-strategy.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-connection-strategy.js","sourceRoot":"","sources":["../../src/interfaces/mcp-connection-strategy.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-resolver.d.ts","sourceRoot":"","sources":["../../src/interfaces/model-resolver.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-resolver.js","sourceRoot":"","sources":["../../src/interfaces/model-resolver.ts"],"names":[],"mappings":""}
|