@mcp-abap-adt/llm-agent 2.9.2 → 2.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.
Files changed (134) hide show
  1. package/dist/index.d.ts +11 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +7 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/smart-agent/agent.d.ts +18 -1
  6. package/dist/smart-agent/agent.d.ts.map +1 -1
  7. package/dist/smart-agent/agent.js +176 -21
  8. package/dist/smart-agent/agent.js.map +1 -1
  9. package/dist/smart-agent/builder.d.ts +114 -51
  10. package/dist/smart-agent/builder.d.ts.map +1 -1
  11. package/dist/smart-agent/builder.js +234 -110
  12. package/dist/smart-agent/builder.js.map +1 -1
  13. package/dist/smart-agent/cli.d.ts +1 -0
  14. package/dist/smart-agent/cli.d.ts.map +1 -1
  15. package/dist/smart-agent/cli.js +2 -0
  16. package/dist/smart-agent/cli.js.map +1 -1
  17. package/dist/smart-agent/config/config-watcher.d.ts +4 -0
  18. package/dist/smart-agent/config/config-watcher.d.ts.map +1 -1
  19. package/dist/smart-agent/config/config-watcher.js +8 -0
  20. package/dist/smart-agent/config/config-watcher.js.map +1 -1
  21. package/dist/smart-agent/config.d.ts +2 -1
  22. package/dist/smart-agent/config.d.ts.map +1 -1
  23. package/dist/smart-agent/config.js +46 -4
  24. package/dist/smart-agent/config.js.map +1 -1
  25. package/dist/smart-agent/interfaces/index.d.ts +1 -1
  26. package/dist/smart-agent/interfaces/index.d.ts.map +1 -1
  27. package/dist/smart-agent/interfaces/index.js.map +1 -1
  28. package/dist/smart-agent/interfaces/rag.d.ts +16 -0
  29. package/dist/smart-agent/interfaces/rag.d.ts.map +1 -1
  30. package/dist/smart-agent/pipeline/condition-evaluator.d.ts +35 -0
  31. package/dist/smart-agent/pipeline/condition-evaluator.d.ts.map +1 -0
  32. package/dist/smart-agent/pipeline/condition-evaluator.js +143 -0
  33. package/dist/smart-agent/pipeline/condition-evaluator.js.map +1 -0
  34. package/dist/smart-agent/pipeline/context.d.ts +104 -0
  35. package/dist/smart-agent/pipeline/context.d.ts.map +1 -0
  36. package/dist/smart-agent/pipeline/context.js +19 -0
  37. package/dist/smart-agent/pipeline/context.js.map +1 -0
  38. package/dist/smart-agent/pipeline/default-pipeline.d.ts +45 -0
  39. package/dist/smart-agent/pipeline/default-pipeline.d.ts.map +1 -0
  40. package/dist/smart-agent/pipeline/default-pipeline.js +118 -0
  41. package/dist/smart-agent/pipeline/default-pipeline.js.map +1 -0
  42. package/dist/smart-agent/pipeline/executor.d.ts +54 -0
  43. package/dist/smart-agent/pipeline/executor.d.ts.map +1 -0
  44. package/dist/smart-agent/pipeline/executor.js +133 -0
  45. package/dist/smart-agent/pipeline/executor.js.map +1 -0
  46. package/dist/smart-agent/pipeline/handlers/assemble.d.ts +16 -0
  47. package/dist/smart-agent/pipeline/handlers/assemble.d.ts.map +1 -0
  48. package/dist/smart-agent/pipeline/handlers/assemble.js +57 -0
  49. package/dist/smart-agent/pipeline/handlers/assemble.js.map +1 -0
  50. package/dist/smart-agent/pipeline/handlers/classify.d.ts +21 -0
  51. package/dist/smart-agent/pipeline/handlers/classify.d.ts.map +1 -0
  52. package/dist/smart-agent/pipeline/handlers/classify.js +53 -0
  53. package/dist/smart-agent/pipeline/handlers/classify.js.map +1 -0
  54. package/dist/smart-agent/pipeline/handlers/expand.d.ts +16 -0
  55. package/dist/smart-agent/pipeline/handlers/expand.d.ts.map +1 -0
  56. package/dist/smart-agent/pipeline/handlers/expand.js +24 -0
  57. package/dist/smart-agent/pipeline/handlers/expand.js.map +1 -0
  58. package/dist/smart-agent/pipeline/handlers/index.d.ts +28 -0
  59. package/dist/smart-agent/pipeline/handlers/index.d.ts.map +1 -0
  60. package/dist/smart-agent/pipeline/handlers/index.js +39 -0
  61. package/dist/smart-agent/pipeline/handlers/index.js.map +1 -0
  62. package/dist/smart-agent/pipeline/handlers/rag-query.d.ts +25 -0
  63. package/dist/smart-agent/pipeline/handlers/rag-query.d.ts.map +1 -0
  64. package/dist/smart-agent/pipeline/handlers/rag-query.js +53 -0
  65. package/dist/smart-agent/pipeline/handlers/rag-query.js.map +1 -0
  66. package/dist/smart-agent/pipeline/handlers/rag-upsert.d.ts +17 -0
  67. package/dist/smart-agent/pipeline/handlers/rag-upsert.d.ts.map +1 -0
  68. package/dist/smart-agent/pipeline/handlers/rag-upsert.js +47 -0
  69. package/dist/smart-agent/pipeline/handlers/rag-upsert.js.map +1 -0
  70. package/dist/smart-agent/pipeline/handlers/rerank.d.ts +16 -0
  71. package/dist/smart-agent/pipeline/handlers/rerank.d.ts.map +1 -0
  72. package/dist/smart-agent/pipeline/handlers/rerank.js +38 -0
  73. package/dist/smart-agent/pipeline/handlers/rerank.js.map +1 -0
  74. package/dist/smart-agent/pipeline/handlers/summarize.d.ts +17 -0
  75. package/dist/smart-agent/pipeline/handlers/summarize.d.ts.map +1 -0
  76. package/dist/smart-agent/pipeline/handlers/summarize.js +47 -0
  77. package/dist/smart-agent/pipeline/handlers/summarize.js.map +1 -0
  78. package/dist/smart-agent/pipeline/handlers/tool-loop.d.ts +32 -0
  79. package/dist/smart-agent/pipeline/handlers/tool-loop.d.ts.map +1 -0
  80. package/dist/smart-agent/pipeline/handlers/tool-loop.js +416 -0
  81. package/dist/smart-agent/pipeline/handlers/tool-loop.js.map +1 -0
  82. package/dist/smart-agent/pipeline/handlers/tool-select.d.ts +21 -0
  83. package/dist/smart-agent/pipeline/handlers/tool-select.d.ts.map +1 -0
  84. package/dist/smart-agent/pipeline/handlers/tool-select.js +95 -0
  85. package/dist/smart-agent/pipeline/handlers/tool-select.js.map +1 -0
  86. package/dist/smart-agent/pipeline/handlers/translate.d.ts +18 -0
  87. package/dist/smart-agent/pipeline/handlers/translate.d.ts.map +1 -0
  88. package/dist/smart-agent/pipeline/handlers/translate.js +39 -0
  89. package/dist/smart-agent/pipeline/handlers/translate.js.map +1 -0
  90. package/dist/smart-agent/pipeline/index.d.ts +14 -0
  91. package/dist/smart-agent/pipeline/index.d.ts.map +1 -0
  92. package/dist/smart-agent/pipeline/index.js +16 -0
  93. package/dist/smart-agent/pipeline/index.js.map +1 -0
  94. package/dist/smart-agent/pipeline/stage-handler.d.ts +36 -0
  95. package/dist/smart-agent/pipeline/stage-handler.d.ts.map +1 -0
  96. package/dist/smart-agent/pipeline/stage-handler.js +24 -0
  97. package/dist/smart-agent/pipeline/stage-handler.js.map +1 -0
  98. package/dist/smart-agent/pipeline/types.d.ts +129 -0
  99. package/dist/smart-agent/pipeline/types.d.ts.map +1 -0
  100. package/dist/smart-agent/pipeline/types.js +54 -0
  101. package/dist/smart-agent/pipeline/types.js.map +1 -0
  102. package/dist/smart-agent/pipeline.d.ts +22 -6
  103. package/dist/smart-agent/pipeline.d.ts.map +1 -1
  104. package/dist/smart-agent/pipeline.js +5 -142
  105. package/dist/smart-agent/pipeline.js.map +1 -1
  106. package/dist/smart-agent/plugins/index.d.ts +4 -0
  107. package/dist/smart-agent/plugins/index.d.ts.map +1 -0
  108. package/dist/smart-agent/plugins/index.js +3 -0
  109. package/dist/smart-agent/plugins/index.js.map +1 -0
  110. package/dist/smart-agent/plugins/loader.d.ts +67 -0
  111. package/dist/smart-agent/plugins/loader.d.ts.map +1 -0
  112. package/dist/smart-agent/plugins/loader.js +114 -0
  113. package/dist/smart-agent/plugins/loader.js.map +1 -0
  114. package/dist/smart-agent/plugins/types.d.ts +149 -0
  115. package/dist/smart-agent/plugins/types.d.ts.map +1 -0
  116. package/dist/smart-agent/plugins/types.js +111 -0
  117. package/dist/smart-agent/plugins/types.js.map +1 -0
  118. package/dist/smart-agent/providers.d.ts +76 -0
  119. package/dist/smart-agent/providers.d.ts.map +1 -0
  120. package/dist/smart-agent/providers.js +173 -0
  121. package/dist/smart-agent/providers.js.map +1 -0
  122. package/dist/smart-agent/rag/embedder-factories.d.ts +9 -0
  123. package/dist/smart-agent/rag/embedder-factories.d.ts.map +1 -0
  124. package/dist/smart-agent/rag/embedder-factories.js +27 -0
  125. package/dist/smart-agent/rag/embedder-factories.js.map +1 -0
  126. package/dist/smart-agent/rag/index.d.ts +7 -0
  127. package/dist/smart-agent/rag/index.d.ts.map +1 -1
  128. package/dist/smart-agent/rag/index.js +4 -0
  129. package/dist/smart-agent/rag/index.js.map +1 -1
  130. package/dist/smart-agent/smart-server.d.ts +25 -1
  131. package/dist/smart-agent/smart-server.d.ts.map +1 -1
  132. package/dist/smart-agent/smart-server.js +122 -27
  133. package/dist/smart-agent/smart-server.js.map +1 -1
  134. package/package.json +2 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rag-query.d.ts","sourceRoot":"","sources":["../../../../src/smart-agent/pipeline/handlers/rag-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,qBAAa,eAAgB,YAAW,aAAa;IAC7C,OAAO,CACX,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,IAAI,EAAE,KAAK,GACV,OAAO,CAAC,OAAO,CAAC;CAuCpB"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * RagQueryHandler — queries a single RAG store.
3
+ *
4
+ * Reads: `ctx.ragText`, `ctx.ragStores`
5
+ * Writes: `ctx.ragResults[store]` where `store` is from config
6
+ *
7
+ * ## Config
8
+ *
9
+ * | Field | Type | Default | Description |
10
+ * |---------|--------|----------|--------------------------------------|
11
+ * | `store` | string | required | Which store: `'facts'`, `'feedback'`, `'state'` |
12
+ * | `k` | number | from ctx | Number of results to retrieve |
13
+ *
14
+ * ## Parallel safety
15
+ *
16
+ * Each instance writes to a different slot in `ctx.ragResults`, so
17
+ * multiple rag-query stages can safely run in parallel.
18
+ */
19
+ export class RagQueryHandler {
20
+ async execute(ctx, config, span) {
21
+ const storeName = config.store;
22
+ if (!storeName || !['facts', 'feedback', 'state'].includes(storeName)) {
23
+ span.setAttribute('error', `Invalid store: ${storeName}`);
24
+ return true; // non-fatal, skip
25
+ }
26
+ const k = config.k ?? ctx.config.ragQueryK ?? 10;
27
+ const store = ctx.ragStores[storeName];
28
+ span.setAttribute('store', storeName);
29
+ span.setAttribute('k', k);
30
+ const result = await store.query(ctx.ragText, k, ctx.options);
31
+ ctx.metrics.ragQueryCount.add(1, {
32
+ store: storeName,
33
+ hit: String(result.ok && result.value.length > 0),
34
+ });
35
+ if (result.ok) {
36
+ ctx.ragResults[storeName] = result.value;
37
+ span.setAttribute('results', result.value.length);
38
+ // Log RAG results with scores for diagnostics
39
+ ctx.options?.sessionLogger?.logStep(`rag_query_${storeName}`, {
40
+ query: ctx.ragText.slice(0, 200),
41
+ k,
42
+ resultCount: result.value.length,
43
+ results: result.value.map((r) => ({
44
+ id: r.metadata.id,
45
+ score: r.score,
46
+ text: r.text.slice(0, 120),
47
+ })),
48
+ });
49
+ }
50
+ return true;
51
+ }
52
+ }
53
+ //# sourceMappingURL=rag-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rag-query.js","sourceRoot":"","sources":["../../../../src/smart-agent/pipeline/handlers/rag-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,MAAM,OAAO,eAAe;IAC1B,KAAK,CAAC,OAAO,CACX,GAAoB,EACpB,MAA+B,EAC/B,IAAW;QAEX,MAAM,SAAS,GAAG,MAAM,CAAC,KAAe,CAAC;QACzC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACtE,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,kBAAkB,SAAS,EAAE,CAAC,CAAC;YAC1D,OAAO,IA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BACjB,KAAK,EAAE,CAAC,CAAC,KAAK;oBACd,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;iBAC3B,CAAC,CAAC;aACJ,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * RagUpsertHandler — upserts classified subprompts to RAG stores.
3
+ *
4
+ * Reads: `ctx.subprompts`, `ctx.ragStores`
5
+ * Writes: (side effect — data stored in RAG)
6
+ *
7
+ * Upserts subprompts of type `fact`, `state`, and `feedback` to their
8
+ * respective RAG stores. Skipped when `ragUpsertEnabled` is false.
9
+ */
10
+ import type { ISpan } from '../../tracer/types.js';
11
+ import type { PipelineContext } from '../context.js';
12
+ import type { IStageHandler } from '../stage-handler.js';
13
+ export declare class RagUpsertHandler implements IStageHandler {
14
+ execute(ctx: PipelineContext, _config: Record<string, unknown>, span: ISpan): Promise<boolean>;
15
+ private _buildMetadata;
16
+ }
17
+ //# sourceMappingURL=rag-upsert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rag-upsert.d.ts","sourceRoot":"","sources":["../../../../src/smart-agent/pipeline/handlers/rag-upsert.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,qBAAa,gBAAiB,YAAW,aAAa;IAC9C,OAAO,CACX,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,IAAI,EAAE,KAAK,GACV,OAAO,CAAC,OAAO,CAAC;IAmCnB,OAAO,CAAC,cAAc;CASvB"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * RagUpsertHandler — upserts classified subprompts to RAG stores.
3
+ *
4
+ * Reads: `ctx.subprompts`, `ctx.ragStores`
5
+ * Writes: (side effect — data stored in RAG)
6
+ *
7
+ * Upserts subprompts of type `fact`, `state`, and `feedback` to their
8
+ * respective RAG stores. Skipped when `ragUpsertEnabled` is false.
9
+ */
10
+ export class RagUpsertHandler {
11
+ async execute(ctx, _config, span) {
12
+ if (ctx.config.ragUpsertEnabled === false) {
13
+ span.setAttribute('skipped', true);
14
+ return true;
15
+ }
16
+ const others = ctx.subprompts.filter((sp) => sp.type === 'fact' || sp.type === 'state' || sp.type === 'feedback');
17
+ if (others.length === 0) {
18
+ span.setAttribute('count', 0);
19
+ return true;
20
+ }
21
+ const storeMap = new Map([
22
+ ['fact', ctx.ragStores.facts],
23
+ ['feedback', ctx.ragStores.feedback],
24
+ ['state', ctx.ragStores.state],
25
+ ]);
26
+ const metadata = this._buildMetadata(ctx);
27
+ await Promise.allSettled(others.map(async (sp) => {
28
+ const store = storeMap.get(sp.type);
29
+ if (store)
30
+ await store.upsert(sp.text, metadata, ctx.options);
31
+ }));
32
+ span.setAttribute('count', others.length);
33
+ return true;
34
+ }
35
+ _buildMetadata(ctx) {
36
+ const p = ctx.config.sessionPolicy;
37
+ if (!p)
38
+ return {};
39
+ const m = {};
40
+ if (p.namespace !== undefined)
41
+ m.namespace = p.namespace;
42
+ if (p.maxSessionAgeMs !== undefined)
43
+ m.ttl = Math.floor((Date.now() + p.maxSessionAgeMs) / 1000);
44
+ return m;
45
+ }
46
+ }
47
+ //# sourceMappingURL=rag-upsert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rag-upsert.js","sourceRoot":"","sources":["../../../../src/smart-agent/pipeline/handlers/rag-upsert.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,MAAM,OAAO,gBAAgB;IAC3B,KAAK,CAAC,OAAO,CACX,GAAoB,EACpB,OAAgC,EAChC,IAAW;QAEX,IAAI,GAAG,CAAC,MAAM,CAAC,gB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,CAAC,GAAoB;QACzC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC;QACnC,IAAI,CAAC,CAAC;YAAE,OAAO,EAAE,CAAC;QAClB,MAAM,CAAC,GAAgB,EAAE,CAAC;QAC1B,IAAI,CAAC,CAAC,SAAS,KAAK,SAAS;YAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC;QACzD,IAAI,CAAC,CAAC,eAAe,KAAK,SAAS;YACjC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC;QAC9D,OAAO,CAAC,CAAC;IACX,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * RerankHandler — re-scores RAG results using the injected reranker.
3
+ *
4
+ * Reads: `ctx.ragText`, `ctx.ragResults`
5
+ * Writes: `ctx.ragResults` (replaces with re-scored versions)
6
+ *
7
+ * Runs reranking on all three stores in parallel. Falls back to original
8
+ * results if reranking fails for a store.
9
+ */
10
+ import type { ISpan } from '../../tracer/types.js';
11
+ import type { PipelineContext } from '../context.js';
12
+ import type { IStageHandler } from '../stage-handler.js';
13
+ export declare class RerankHandler implements IStageHandler {
14
+ execute(ctx: PipelineContext, _config: Record<string, unknown>, span: ISpan): Promise<boolean>;
15
+ }
16
+ //# sourceMappingURL=rerank.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rerank.d.ts","sourceRoot":"","sources":["../../../../src/smart-agent/pipeline/handlers/rerank.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,qBAAa,aAAc,YAAW,aAAa;IAC3C,OAAO,CACX,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,IAAI,EAAE,KAAK,GACV,OAAO,CAAC,OAAO,CAAC;CAyBpB"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * RerankHandler — re-scores RAG results using the injected reranker.
3
+ *
4
+ * Reads: `ctx.ragText`, `ctx.ragResults`
5
+ * Writes: `ctx.ragResults` (replaces with re-scored versions)
6
+ *
7
+ * Runs reranking on all three stores in parallel. Falls back to original
8
+ * results if reranking fails for a store.
9
+ */
10
+ export class RerankHandler {
11
+ async execute(ctx, _config, span) {
12
+ const [rerankedFacts, rerankedFeedback, rerankedState] = await Promise.all([
13
+ ctx.ragResults.facts.length > 0
14
+ ? ctx.reranker.rerank(ctx.ragText, ctx.ragResults.facts, ctx.options)
15
+ : Promise.resolve({ ok: true, value: ctx.ragResults.facts }),
16
+ ctx.ragResults.feedback.length > 0
17
+ ? ctx.reranker.rerank(ctx.ragText, ctx.ragResults.feedback, ctx.options)
18
+ : Promise.resolve({
19
+ ok: true,
20
+ value: ctx.ragResults.feedback,
21
+ }),
22
+ ctx.ragResults.state.length > 0
23
+ ? ctx.reranker.rerank(ctx.ragText, ctx.ragResults.state, ctx.options)
24
+ : Promise.resolve({ ok: true, value: ctx.ragResults.state }),
25
+ ]);
26
+ if (rerankedFacts.ok)
27
+ ctx.ragResults.facts = rerankedFacts.value;
28
+ if (rerankedFeedback.ok)
29
+ ctx.ragResults.feedback = rerankedFeedback.value;
30
+ if (rerankedState.ok)
31
+ ctx.ragResults.state = rerankedState.value;
32
+ span.setAttribute('facts', ctx.ragResults.facts.length);
33
+ span.setAttribute('feedback', ctx.ragResults.feedback.length);
34
+ span.setAttribute('state', ctx.ragResults.state.length);
35
+ return true;
36
+ }
37
+ }
38
+ //# sourceMappingURL=rerank.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rerank.js","sourceRoot":"","sources":["../../../../src/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;SACxE,CAAC,CAAC;QAEH,IAAI,aAAa,CAAC,EAAE;YAAE,GAAG,CAAC,UAAU,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;QACjE,IAAI,gBAAgB,CAAC,EAAE;YAAE,GAAG,CAAC,UAAU,CAAC,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC;QAC1E,IAAI,aAAa,CAAC,EAAE;YAAE,GAAG,CAAC,UAAU,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;QAEjE,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACxD,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC9D,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * SummarizeHandler — condenses conversation history using helper LLM.
3
+ *
4
+ * Reads: `ctx.history`, `ctx.helperLlm`
5
+ * Writes: `ctx.history` (replaces with summarized version)
6
+ *
7
+ * Keeps the last 5 messages verbatim and summarizes the rest into a
8
+ * single system message. Skips silently if no helper LLM is available
9
+ * or history is too short.
10
+ */
11
+ import type { ISpan } from '../../tracer/types.js';
12
+ import type { PipelineContext } from '../context.js';
13
+ import type { IStageHandler } from '../stage-handler.js';
14
+ export declare class SummarizeHandler implements IStageHandler {
15
+ execute(ctx: PipelineContext, config: Record<string, unknown>, span: ISpan): Promise<boolean>;
16
+ }
17
+ //# sourceMappingURL=summarize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarize.d.ts","sourceRoot":"","sources":["../../../../src/smart-agent/pipeline/handlers/summarize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,qBAAa,gBAAiB,YAAW,aAAa;IAC9C,OAAO,CACX,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,IAAI,EAAE,KAAK,GACV,OAAO,CAAC,OAAO,CAAC;CA+CpB"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * SummarizeHandler — condenses conversation history using helper LLM.
3
+ *
4
+ * Reads: `ctx.history`, `ctx.helperLlm`
5
+ * Writes: `ctx.history` (replaces with summarized version)
6
+ *
7
+ * Keeps the last 5 messages verbatim and summarizes the rest into a
8
+ * single system message. Skips silently if no helper LLM is available
9
+ * or history is too short.
10
+ */
11
+ export class SummarizeHandler {
12
+ async execute(ctx, config, span) {
13
+ if (!ctx.helperLlm) {
14
+ span.setAttribute('skipped', true);
15
+ span.setAttribute('reason', 'no_helper_llm');
16
+ return true;
17
+ }
18
+ const limit = config.limit ?? ctx.config.historyAutoSummarizeLimit ?? 10;
19
+ if (ctx.history.length <= limit) {
20
+ span.setAttribute('skipped', true);
21
+ span.setAttribute('reason', 'history_under_limit');
22
+ return true;
23
+ }
24
+ const toSummarize = ctx.history.slice(0, -5);
25
+ const recent = ctx.history.slice(-5);
26
+ if (toSummarize.length === 0)
27
+ return true;
28
+ const prompt = ctx.config.historySummaryPrompt ??
29
+ 'Summarize the conversation so far in 2-3 sentences. Focus on the user goals and the current status of the task. Keep technical SAP terms as is.';
30
+ const res = await ctx.helperLlm.chat([...toSummarize, { role: 'system', content: prompt }], [], ctx.options);
31
+ if (!res.ok) {
32
+ // Non-fatal — keep original history
33
+ span.setAttribute('fallback', true);
34
+ return true;
35
+ }
36
+ ctx.history = [
37
+ {
38
+ role: 'system',
39
+ content: `Summary of previous conversation: ${res.value.content}`,
40
+ },
41
+ ...recent,
42
+ ];
43
+ span.setAttribute('summarized_count', toSummarize.length);
44
+ return true;
45
+ }
46
+ }
47
+ //# sourceMappingURL=summarize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarize.js","sourceRoot":"","sources":["../../../../src/smart-agent/pipeline/handlers/summarize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,MAAM,OAAO,gBAAgB;IAC3B,KAAK,CAAC,OAAO,CACX,GAAoB,EACpB,MAA+B,EAC/B,IAAW;QAEX,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;YACnB,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;YAC7C,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,KAAK,GACR,MAAM,CAAC,KAAgB,IAAI,GAAG,CAAC,MAAM,CAAC,yBAAyB,IAAI,EAAE,CAAC;QAEzE,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;YAChC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAE1C,MAAM,MAAM,GACV,GAAG,CAAC,MAAM,CAAC,oBAAoB;YAC/B,iJAAiJ,CAAC;QAEpJ,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAClC,CAAC,GAAG,WAAW,EAAE,EAAE,IAAI,EAAE,QAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAC9D,EAAE,EACF,GAAG,CAAC,OAAO,CACZ,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,oCAAoC;YACpC,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YACpC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,GAAG,CAAC,OAAO,GAAG;YACZ;gBACE,IAAI,EAAE,QAAiB;gBACvB,OAAO,EAAE,qCAAqC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE;aAClE;YACD,GAAG,MAAM;SACV,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * ToolLoopHandler — streaming LLM call + MCP tool execution loop.
3
+ *
4
+ * This is the "terminal" pipeline stage. It takes over the streaming yield
5
+ * mechanism to push SSE chunks back to the consumer.
6
+ *
7
+ * Reads: `ctx.assembledMessages`, `ctx.activeTools`, `ctx.toolClientMap`,
8
+ * `ctx.externalTools`, `ctx.mainLlm`
9
+ * Writes: yields chunks via `ctx.yield()`, updates `ctx.timing`
10
+ *
11
+ * ## Config
12
+ *
13
+ * | Field | Type | Default | Description |
14
+ * |--------------------|--------|-------------|---------------------------------|
15
+ * | `maxIterations` | number | from ctx | Max tool-loop iterations |
16
+ * | `maxToolCalls` | number | from ctx | Max total tool calls per request|
17
+ * | `heartbeatIntervalMs` | number | 5000 | SSE heartbeat interval (ms) |
18
+ *
19
+ * ## Includes
20
+ *
21
+ * - Output validation (re-prompts on invalid LLM output)
22
+ * - Tool call classification (internal / external / hallucinated / blocked)
23
+ * - Concurrent tool execution with heartbeat
24
+ * - Tool availability tracking (temporary blacklist)
25
+ */
26
+ import type { ISpan } from '../../tracer/types.js';
27
+ import type { PipelineContext } from '../context.js';
28
+ import type { IStageHandler } from '../stage-handler.js';
29
+ export declare class ToolLoopHandler implements IStageHandler {
30
+ execute(ctx: PipelineContext, config: Record<string, unknown>, parentSpan: ISpan): Promise<boolean>;
31
+ }
32
+ //# sourceMappingURL=tool-loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-loop.d.ts","sourceRoot":"","sources":["../../../../src/smart-agent/pipeline/handlers/tool-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAWH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAKnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,qBAAa,eAAgB,YAAW,aAAa;IAC7C,OAAO,CACX,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,EAAE,KAAK,GAChB,OAAO,CAAC,OAAO,CAAC;CAudpB"}