@mcp-abap-adt/llm-agent-server-libs 19.1.2 → 19.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/factories/controller-factory.d.ts +18 -4
- package/dist/factories/controller-factory.d.ts.map +1 -1
- package/dist/factories/controller-factory.js +50 -10
- package/dist/factories/controller-factory.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/pipelines/controller.d.ts.map +1 -1
- package/dist/pipelines/controller.js +41 -0
- package/dist/pipelines/controller.js.map +1 -1
- package/dist/pipelines/dag.d.ts.map +1 -1
- package/dist/pipelines/dag.js +2 -1
- package/dist/pipelines/dag.js.map +1 -1
- package/dist/pipelines/flat.d.ts.map +1 -1
- package/dist/pipelines/flat.js +2 -1
- package/dist/pipelines/flat.js.map +1 -1
- package/dist/pipelines/linear.d.ts.map +1 -1
- package/dist/pipelines/linear.js +2 -1
- package/dist/pipelines/linear.js.map +1 -1
- package/dist/pipelines/register-skill-sources.d.ts +21 -0
- package/dist/pipelines/register-skill-sources.d.ts.map +1 -0
- package/dist/pipelines/register-skill-sources.js +57 -0
- package/dist/pipelines/register-skill-sources.js.map +1 -0
- package/dist/pipelines/server-context.d.ts +37 -1
- package/dist/pipelines/server-context.d.ts.map +1 -1
- package/dist/pipelines/server-context.js.map +1 -1
- package/dist/smart-agent/config.d.ts.map +1 -1
- package/dist/smart-agent/config.js +4 -0
- package/dist/smart-agent/config.js.map +1 -1
- package/dist/smart-agent/controller/artifacts.d.ts +116 -0
- package/dist/smart-agent/controller/artifacts.d.ts.map +1 -0
- package/dist/smart-agent/controller/artifacts.js +192 -0
- package/dist/smart-agent/controller/artifacts.js.map +1 -0
- package/dist/smart-agent/controller/board.d.ts +73 -0
- package/dist/smart-agent/controller/board.d.ts.map +1 -0
- package/dist/smart-agent/controller/board.js +233 -0
- package/dist/smart-agent/controller/board.js.map +1 -0
- package/dist/smart-agent/controller/controller-coordinator-handler.d.ts +67 -7
- package/dist/smart-agent/controller/controller-coordinator-handler.d.ts.map +1 -1
- package/dist/smart-agent/controller/controller-coordinator-handler.js +923 -61
- package/dist/smart-agent/controller/controller-coordinator-handler.js.map +1 -1
- package/dist/smart-agent/controller/finalizer.d.ts +48 -0
- package/dist/smart-agent/controller/finalizer.d.ts.map +1 -0
- package/dist/smart-agent/controller/finalizer.js +126 -0
- package/dist/smart-agent/controller/finalizer.js.map +1 -0
- package/dist/smart-agent/controller/memorizer.d.ts +2 -2
- package/dist/smart-agent/controller/memorizer.d.ts.map +1 -1
- package/dist/smart-agent/controller/memorizer.js +2 -2
- package/dist/smart-agent/controller/memorizer.js.map +1 -1
- package/dist/smart-agent/controller/outcome.d.ts +28 -0
- package/dist/smart-agent/controller/outcome.d.ts.map +1 -0
- package/dist/smart-agent/controller/outcome.js +30 -0
- package/dist/smart-agent/controller/outcome.js.map +1 -0
- package/dist/smart-agent/controller/planner.d.ts +28 -5
- package/dist/smart-agent/controller/planner.d.ts.map +1 -1
- package/dist/smart-agent/controller/planner.js +111 -29
- package/dist/smart-agent/controller/planner.js.map +1 -1
- package/dist/smart-agent/controller/reviewer.d.ts +48 -0
- package/dist/smart-agent/controller/reviewer.d.ts.map +1 -0
- package/dist/smart-agent/controller/reviewer.js +116 -0
- package/dist/smart-agent/controller/reviewer.js.map +1 -0
- package/dist/smart-agent/controller/run-scope.d.ts +50 -0
- package/dist/smart-agent/controller/run-scope.d.ts.map +1 -0
- package/dist/smart-agent/controller/run-scope.js +99 -0
- package/dist/smart-agent/controller/run-scope.js.map +1 -0
- package/dist/smart-agent/controller/session-bundle.d.ts +5 -0
- package/dist/smart-agent/controller/session-bundle.d.ts.map +1 -1
- package/dist/smart-agent/controller/session-bundle.js +27 -0
- package/dist/smart-agent/controller/session-bundle.js.map +1 -1
- package/dist/smart-agent/controller/types.d.ts +117 -7
- package/dist/smart-agent/controller/types.d.ts.map +1 -1
- package/dist/smart-agent/controller/types.js +30 -1
- package/dist/smart-agent/controller/types.js.map +1 -1
- package/dist/smart-agent/embedder-knowledge-index.d.ts +28 -0
- package/dist/smart-agent/embedder-knowledge-index.d.ts.map +1 -0
- package/dist/smart-agent/embedder-knowledge-index.js +71 -0
- package/dist/smart-agent/embedder-knowledge-index.js.map +1 -0
- package/dist/smart-agent/jsonl-knowledge-backend.d.ts +26 -10
- package/dist/smart-agent/jsonl-knowledge-backend.d.ts.map +1 -1
- package/dist/smart-agent/jsonl-knowledge-backend.js +81 -9
- package/dist/smart-agent/jsonl-knowledge-backend.js.map +1 -1
- package/dist/smart-agent/pg-pool.d.ts +58 -0
- package/dist/smart-agent/pg-pool.d.ts.map +1 -0
- package/dist/smart-agent/pg-pool.js +149 -0
- package/dist/smart-agent/pg-pool.js.map +1 -0
- package/dist/smart-agent/skill-plugins-config.d.ts +97 -0
- package/dist/smart-agent/skill-plugins-config.d.ts.map +1 -0
- package/dist/smart-agent/skill-plugins-config.js +318 -0
- package/dist/smart-agent/skill-plugins-config.js.map +1 -0
- package/dist/smart-agent/skill-plugins-config.test.d.ts +2 -0
- package/dist/smart-agent/skill-plugins-config.test.d.ts.map +1 -0
- package/dist/smart-agent/skill-plugins-config.test.js.map +1 -0
- package/dist/smart-agent/skill-plugins-host-factory.d.ts +98 -0
- package/dist/smart-agent/skill-plugins-host-factory.d.ts.map +1 -0
- package/dist/smart-agent/skill-plugins-host-factory.js +284 -0
- package/dist/smart-agent/skill-plugins-host-factory.js.map +1 -0
- package/dist/smart-agent/skill-plugins-host-factory.test.d.ts +2 -0
- package/dist/smart-agent/skill-plugins-host-factory.test.d.ts.map +1 -0
- package/dist/smart-agent/skill-plugins-host-factory.test.js.map +1 -0
- package/dist/smart-agent/smart-server.d.ts +25 -0
- package/dist/smart-agent/smart-server.d.ts.map +1 -1
- package/dist/smart-agent/smart-server.js +139 -6
- package/dist/smart-agent/smart-server.js.map +1 -1
- package/package.json +9 -7
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
/** Canonical identity fingerprint of a request: a hash of the NORMALIZED text
|
|
3
|
+
* (trimmed, internal whitespace collapsed). Used only for identity comparison —
|
|
4
|
+
* the verbatim request is kept separately for the finalizer. */
|
|
5
|
+
export function fingerprintRequest(request) {
|
|
6
|
+
const normalized = request.trim().replace(/\s+/g, ' ');
|
|
7
|
+
return createHash('sha256').update(normalized).digest('hex');
|
|
8
|
+
}
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Terminal store (separate keyed TTL store)
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
const TERMINAL_ARTIFACT_TYPE = 'controller-terminal';
|
|
13
|
+
/** Persist a terminal outcome keyed by runId with a TTL. Written into the same
|
|
14
|
+
* KnowledgeBackend as the bundle but under a distinct artifactType so it
|
|
15
|
+
* survives the next run's bundle reset (the TTL promise). `nowIso` is passed so
|
|
16
|
+
* the caller controls time. */
|
|
17
|
+
export async function writeTerminal(be, sessionId, runId, terminalOutcome, ttlMs, nowIso) {
|
|
18
|
+
const expiresAt = new Date(new Date(nowIso).getTime() + ttlMs).toISOString();
|
|
19
|
+
const entry = { runId, terminalOutcome, expiresAt };
|
|
20
|
+
await be.put(sessionId, {
|
|
21
|
+
content: JSON.stringify(entry),
|
|
22
|
+
metadata: {
|
|
23
|
+
traceId: sessionId,
|
|
24
|
+
turnId: sessionId,
|
|
25
|
+
stepperId: 'controller',
|
|
26
|
+
task: 'terminal',
|
|
27
|
+
artifactType: TERMINAL_ARTIFACT_TYPE,
|
|
28
|
+
runId,
|
|
29
|
+
createdAt: nowIso,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** Read the latest non-expired terminal outcome for runId, or undefined. */
|
|
34
|
+
export async function readTerminal(be, sessionId, runId, nowIso) {
|
|
35
|
+
const now = new Date(nowIso).getTime();
|
|
36
|
+
const entries = await be.scan(sessionId);
|
|
37
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
38
|
+
const e = entries[i];
|
|
39
|
+
if (e.metadata.artifactType !== TERMINAL_ARTIFACT_TYPE)
|
|
40
|
+
continue;
|
|
41
|
+
if (e.metadata.runId !== runId)
|
|
42
|
+
continue;
|
|
43
|
+
try {
|
|
44
|
+
const parsed = JSON.parse(e.content);
|
|
45
|
+
if (new Date(parsed.expiresAt).getTime() <= now)
|
|
46
|
+
return undefined;
|
|
47
|
+
return parsed.terminalOutcome;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// malformed — keep scanning backwards
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
/** The runIds whose terminal entries are expired as of nowIso (backends without
|
|
56
|
+
* delete simply ignore stale rows on read). */
|
|
57
|
+
export async function gcTerminal(be, sessionId, nowIso) {
|
|
58
|
+
const now = new Date(nowIso).getTime();
|
|
59
|
+
const expired = [];
|
|
60
|
+
for (const e of await be.scan(sessionId)) {
|
|
61
|
+
if (e.metadata.artifactType !== TERMINAL_ARTIFACT_TYPE)
|
|
62
|
+
continue;
|
|
63
|
+
try {
|
|
64
|
+
const parsed = JSON.parse(e.content);
|
|
65
|
+
if (new Date(parsed.expiresAt).getTime() <= now)
|
|
66
|
+
expired.push(parsed.runId);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// ignore
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return expired;
|
|
73
|
+
}
|
|
74
|
+
/** Strict ordered request classification. First matching branch wins. */
|
|
75
|
+
export function classifyRequest(input) {
|
|
76
|
+
const { bundle, incomingRequest, explicitKey, newRun, terminalExists } = input;
|
|
77
|
+
// 1. newRun overrides any replay.
|
|
78
|
+
if (newRun)
|
|
79
|
+
return { kind: 'fresh' };
|
|
80
|
+
// 2. Explicit key → STRICT routing, no fingerprint fallback.
|
|
81
|
+
if (explicitKey) {
|
|
82
|
+
if (terminalExists)
|
|
83
|
+
return { kind: 'replay', runId: explicitKey };
|
|
84
|
+
const live = bundle.runState === 'active' || bundle.runState === 'suspended';
|
|
85
|
+
if (explicitKey === bundle.runId && live)
|
|
86
|
+
return { kind: 'resume' };
|
|
87
|
+
return { kind: 'not-found' };
|
|
88
|
+
}
|
|
89
|
+
// 3. No key → fingerprint recovers ONLY an in-flight active run of the same
|
|
90
|
+
// request; a terminal fingerprint match starts fresh.
|
|
91
|
+
const live = bundle.runState === 'active' || bundle.runState === 'suspended';
|
|
92
|
+
const sameRequest = bundle.originalRequest !== undefined &&
|
|
93
|
+
fingerprintRequest(bundle.originalRequest) ===
|
|
94
|
+
fingerprintRequest(incomingRequest);
|
|
95
|
+
if (live && sameRequest)
|
|
96
|
+
return { kind: 'resume' };
|
|
97
|
+
return { kind: 'fresh' };
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=run-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-scope.js","sourceRoot":"","sources":["../../../src/smart-agent/controller/run-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAYzC;;iEAEiE;AACjE,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED,8EAA8E;AAC9E,4CAA4C;AAC5C,8EAA8E;AAE9E,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAarD;;;gCAGgC;AAChC,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,EAAoB,EACpB,SAAiB,EACjB,KAAa,EACb,eAAgC,EAChC,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,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;QAClE,MAAM,IAAI,GACR,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;QAClE,IAAI,WAAW,KAAK,MAAM,CAAC,KAAK,IAAI,IAAI;YAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QACpE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/B,CAAC;IAED,4EAA4E;IAC5E,yDAAyD;IACzD,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;IAC7E,MAAM,WAAW,GACf,MAAM,CAAC,eAAe,KAAK,SAAS;QACpC,kBAAkB,CAAC,MAAM,CAAC,eAAe,CAAC;YACxC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACxC,IAAI,IAAI,IAAI,WAAW;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -12,4 +12,9 @@ export declare function persistBundle(be: KnowledgeBackend, sessionId: string, b
|
|
|
12
12
|
* bundle if none exists or if the stored content cannot be parsed.
|
|
13
13
|
*/
|
|
14
14
|
export declare function hydrateBundle(be: KnowledgeBackend, sessionId: string): Promise<SessionBundle>;
|
|
15
|
+
/** Atomic fresh-run reset: clears EVERY run-scoped field and starts in
|
|
16
|
+
* `evaluating`. The caller mints + assigns a fresh `runId` and the new
|
|
17
|
+
* `originalRequest`. The terminal store (a separate keyed TTL store) is NOT
|
|
18
|
+
* touched here so a prior run's outcome stays replayable by its `runId`. */
|
|
19
|
+
export declare function resetRun(bundle: SessionBundle, originalRequest: string): void;
|
|
15
20
|
//# sourceMappingURL=session-bundle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-bundle.d.ts","sourceRoot":"","sources":["../../../src/smart-agent/controller/session-bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"session-bundle.d.ts","sourceRoot":"","sources":["../../../src/smart-agent/controller/session-bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAkB1D;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,gBAAgB,EACpB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,gBAAgB,EACpB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC,CAaxB;AAED;;;6EAG6E;AAC7E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI,CAsB7E"}
|
|
@@ -50,4 +50,31 @@ export async function hydrateBundle(be, sessionId) {
|
|
|
50
50
|
}
|
|
51
51
|
return emptyBundle();
|
|
52
52
|
}
|
|
53
|
+
/** Atomic fresh-run reset: clears EVERY run-scoped field and starts in
|
|
54
|
+
* `evaluating`. The caller mints + assigns a fresh `runId` and the new
|
|
55
|
+
* `originalRequest`. The terminal store (a separate keyed TTL store) is NOT
|
|
56
|
+
* touched here so a prior run's outcome stays replayable by its `runId`. */
|
|
57
|
+
export function resetRun(bundle, originalRequest) {
|
|
58
|
+
bundle.goal = '';
|
|
59
|
+
bundle.plannerPrivate = '';
|
|
60
|
+
bundle.budgets = { stepsUsed: 0, rewindsUsed: 0 };
|
|
61
|
+
bundle.plan = undefined;
|
|
62
|
+
bundle.planCursor = undefined;
|
|
63
|
+
bundle.pendingPlanDecisions = undefined;
|
|
64
|
+
bundle.pending = undefined;
|
|
65
|
+
bundle.lastOutcome = undefined;
|
|
66
|
+
bundle.runState = 'active';
|
|
67
|
+
bundle.runPhase = 'evaluating';
|
|
68
|
+
bundle.originalRequest = originalRequest;
|
|
69
|
+
bundle.nextSeq = 0;
|
|
70
|
+
bundle.inFlightStep = undefined;
|
|
71
|
+
bundle.evalCallInFlight = false;
|
|
72
|
+
bundle.plannerCallInFlight = false;
|
|
73
|
+
bundle.finalizeCallInFlight = false;
|
|
74
|
+
bundle.evalResumeCount = 0;
|
|
75
|
+
bundle.plannerResumeCount = 0;
|
|
76
|
+
bundle.finalizeAttempt = 0;
|
|
77
|
+
bundle.legacyFinalAnswer = undefined;
|
|
78
|
+
bundle.writeOrdinal = 0;
|
|
79
|
+
}
|
|
53
80
|
//# sourceMappingURL=session-bundle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-bundle.js","sourceRoot":"","sources":["../../../src/smart-agent/controller/session-bundle.ts"],"names":[],"mappings":"AAGA,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAEjD,MAAM,YAAY,GAAkB;IAClC,IAAI,EAAE,EAAE;IACR,cAAc,EAAE,EAAE;IAClB,OAAO,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE;CAC1C,CAAC;AAEF,SAAS,WAAW;IAClB,OAAO;QACL,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,cAAc,EAAE,YAAY,CAAC,cAAc;QAC3C,OAAO,EAAE,EAAE,GAAG,YAAY,CAAC,OAAO,EAAE;KACrC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,EAAoB,EACpB,SAAiB,EACjB,MAAqB;IAErB,MAAM,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE;QACtB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;QAC/B,QAAQ,EAAE;YACR,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,SAAS;YACjB,SAAS,EAAE,YAAY;YACvB,IAAI,EAAE,gBAAgB;YACtB,YAAY,EAAE,oBAAoB;YAClC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,EAAoB,EACpB,SAAiB;IAEjB,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzC,2EAA2E;IAC3E,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,KAAK,CAAC,QAAQ,CAAC,YAAY,KAAK,oBAAoB;YAAE,SAAS;QACnE,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAkB,CAAC;QACpD,CAAC;QAAC,MAAM,CAAC;YACP,4DAA4D;QAC9D,CAAC;IACH,CAAC;IACD,OAAO,WAAW,EAAE,CAAC;AACvB,CAAC"}
|
|
1
|
+
{"version":3,"file":"session-bundle.js","sourceRoot":"","sources":["../../../src/smart-agent/controller/session-bundle.ts"],"names":[],"mappings":"AAGA,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAEjD,MAAM,YAAY,GAAkB;IAClC,IAAI,EAAE,EAAE;IACR,cAAc,EAAE,EAAE;IAClB,OAAO,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE;CAC1C,CAAC;AAEF,SAAS,WAAW;IAClB,OAAO;QACL,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,cAAc,EAAE,YAAY,CAAC,cAAc;QAC3C,OAAO,EAAE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C;IAC3B,MAAM,CAAC,OAAO,GAAG,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;IAClD,MAAM,CAAC,IAAI,GAAG,SAAS,CAAC;IACxB,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,oBAAoB,GAAG,SAAS,CAAC;IACxC,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;IAC3B,MAAM,CAAC,WAAW,GAAG,SAAS,CAAC;IAC/B,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,MAAM,CAAC,QAAQ,GAAG,YAAwB,CAAC;IAC3C,MAAM,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,MAAM,CAAC,YAAY,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,MAAM,CAAC,mBAAmB,GAAG,KAAK,CAAC;IACnC,MAAM,CAAC,oBAAoB,GAAG,KAAK,CAAC;IACpC,MAAM,CAAC,eAAe,GAAG,CAAC,CAAC;IAC3B,MAAM,CAAC,kBAAkB,GAAG,CAAC,CAAC;IAC9B,MAAM,CAAC,eAAe,GAAG,CAAC,CAAC;IAC3B,MAAM,CAAC,iBAAiB,GAAG,SAAS,CAAC;IACrC,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { LlmUsage, StreamToolCall } from '@mcp-abap-adt/llm-agent';
|
|
1
|
+
import type { CallOptions, LlmUsage, Message, StreamToolCall } from '@mcp-abap-adt/llm-agent';
|
|
2
2
|
import type { SmartServerLlmConfig } from '../smart-server.js';
|
|
3
|
+
import type { PlanDecision } from './artifacts.js';
|
|
3
4
|
export type SubagentResult = {
|
|
4
5
|
kind: 'content';
|
|
5
6
|
content: string;
|
|
@@ -14,10 +15,32 @@ export type SubagentResult = {
|
|
|
14
15
|
usage?: LlmUsage;
|
|
15
16
|
};
|
|
16
17
|
export interface Step {
|
|
18
|
+
/** Stable plan-time identity (§F). 1:1 with a board entry; assigned at
|
|
19
|
+
* create-plan or fan-out. Optional only so older call-sites compile during
|
|
20
|
+
* the migration; the planner/handler always set it. */
|
|
21
|
+
stepId?: string;
|
|
17
22
|
name: string;
|
|
18
23
|
instructions: string;
|
|
19
24
|
type?: string;
|
|
25
|
+
/** Marks a discovery step whose result enumerates remaining work (§D). */
|
|
26
|
+
discovery?: true;
|
|
27
|
+
/** When this step REPLACES a failed step on replan, the superseded `stepId` (§F). */
|
|
28
|
+
supersedesStepId?: string;
|
|
29
|
+
/** Plain-language references this step depends on (English — planner invariant).
|
|
30
|
+
* Decided by the reviewer, not the doer; drives the per-reference evidence map. */
|
|
31
|
+
requires?: string[];
|
|
20
32
|
}
|
|
33
|
+
/** Contract cap on a step's dependency references. */
|
|
34
|
+
export declare const MAX_REQUIRES = 8;
|
|
35
|
+
/** A reference is a SHORT phrase, not a payload. */
|
|
36
|
+
export declare const MAX_REQUIRE_CHARS = 200;
|
|
37
|
+
/** Validate a step's optional `requires`. `undefined` for absent OR `[]` (a step
|
|
38
|
+
* with no deps — normalize to undefined; downstream falls back to whole-step
|
|
39
|
+
* recall); the trimmed array when valid; `false` (→ parse failure / retry) when
|
|
40
|
+
* malformed: a non-array, > MAX_REQUIRES entries, a non-string entry, or an entry
|
|
41
|
+
* empty / > MAX_REQUIRE_CHARS after trim (a huge reference must not reach the
|
|
42
|
+
* semantic query / embedder). */
|
|
43
|
+
export declare function validateRequires(v: unknown): string[] | undefined | false;
|
|
21
44
|
export type NextStep = {
|
|
22
45
|
kind: 'next';
|
|
23
46
|
step: Step;
|
|
@@ -42,6 +65,33 @@ export type PendingMarker = {
|
|
|
42
65
|
* a plain confirmation ("yes") commits IT rather than the literal answer. */
|
|
43
66
|
proposedTarget?: string;
|
|
44
67
|
};
|
|
68
|
+
export type RunState = 'idle' | 'active' | 'suspended' | 'terminal';
|
|
69
|
+
export type RunPhase = 'evaluating' | 'planning' | 'executing' | 'finalizing';
|
|
70
|
+
/** Controller-level (non-reviewer) failure that drives a replan with no reviewable
|
|
71
|
+
* artifact (e.g. the maxToolCalls budget). Persisted atomically with
|
|
72
|
+
* inFlightStep.phase='awaiting-replan' so a crash before the replan keeps the
|
|
73
|
+
* reason; fed to the planner, then cleared when the revised step is set. */
|
|
74
|
+
export interface ControlFailure {
|
|
75
|
+
reason: 'maxToolCalls';
|
|
76
|
+
seq: number;
|
|
77
|
+
}
|
|
78
|
+
export interface InFlightStep {
|
|
79
|
+
seq: number;
|
|
80
|
+
step: Step;
|
|
81
|
+
/** Fresh-execution counter (first dispatch / revised replan step). Part of the
|
|
82
|
+
* artifact identity (runId, seq, attempt). */
|
|
83
|
+
attempt: number;
|
|
84
|
+
/** Crash-replay counter of ONE attempt; reset on commit / fresh attempt. */
|
|
85
|
+
resumeCount: number;
|
|
86
|
+
phase: 'executing' | 'awaiting-replan';
|
|
87
|
+
/** Durable executor message log for this seq — the suspend/resume + crash-replay
|
|
88
|
+
* rebuild source; external tool results are appended here. */
|
|
89
|
+
transcript: Message[];
|
|
90
|
+
/** Durable external round-trip count; ++ persisted BEFORE each surfaced call. */
|
|
91
|
+
toolCallCount: number;
|
|
92
|
+
/** Why a controller-level replan (no reviewable artifact) — fed to the planner. */
|
|
93
|
+
controlFailure?: ControlFailure;
|
|
94
|
+
}
|
|
45
95
|
export interface SessionBundle {
|
|
46
96
|
goal: string;
|
|
47
97
|
plannerPrivate: string;
|
|
@@ -51,11 +101,38 @@ export interface SessionBundle {
|
|
|
51
101
|
};
|
|
52
102
|
plan?: Step[];
|
|
53
103
|
planCursor?: number;
|
|
104
|
+
/** Plan decisions the planner produced this turn (create/replan), NOT yet
|
|
105
|
+
* persisted. The controller drains + `writePlanDecision`s them after
|
|
106
|
+
* `planner.next()` returns and BEFORE dispatch (§A: planner constructs, controller
|
|
107
|
+
* persists; §F: every decision is a durable artifact). Cleared once drained, and
|
|
108
|
+
* on `resetRun`. */
|
|
109
|
+
pendingPlanDecisions?: PlanDecision[];
|
|
54
110
|
pending?: PendingMarker;
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
111
|
+
/** Last reviewed step outcome that drives the planner transition. */
|
|
112
|
+
lastOutcome?: 'advanced' | 'failed' | 'partial';
|
|
113
|
+
runId?: string;
|
|
114
|
+
runState?: RunState;
|
|
115
|
+
runPhase?: RunPhase;
|
|
116
|
+
/** The verbatim request that started this run (finalizer input + identity
|
|
117
|
+
* fingerprint source). */
|
|
118
|
+
originalRequest?: string;
|
|
119
|
+
nextSeq?: number;
|
|
120
|
+
inFlightStep?: InFlightStep;
|
|
121
|
+
evalCallInFlight?: boolean;
|
|
122
|
+
plannerCallInFlight?: boolean;
|
|
123
|
+
finalizeCallInFlight?: boolean;
|
|
124
|
+
evalResumeCount?: number;
|
|
125
|
+
plannerResumeCount?: number;
|
|
126
|
+
finalizeAttempt?: number;
|
|
127
|
+
/** Legacy (no-finalizer) answer: the planner's composed done.result, persisted
|
|
128
|
+
* durably in the same write that enters `finalizing`, so a crash before the
|
|
129
|
+
* terminal write recovers it (rather than emitting empty). Cleared by reset. */
|
|
130
|
+
legacyFinalAnswer?: string;
|
|
131
|
+
/** Monotonic per-run write ordinal; incremented BEFORE each artifact write so
|
|
132
|
+
* recall dedup can break createdAt ties by latest-write order. Reset to 0 by
|
|
133
|
+
* resetRun(); run-scoped ordinals are always comparable (recall filters by
|
|
134
|
+
* runId). */
|
|
135
|
+
writeOrdinal?: number;
|
|
59
136
|
}
|
|
60
137
|
/** A controller subagent role: a standalone LLM config plus an OPTIONAL
|
|
61
138
|
* per-role `hint`. The hint is appended to that role's system prompt and gives
|
|
@@ -76,6 +153,9 @@ export interface ControllerConfig {
|
|
|
76
153
|
evaluator: ControllerSubagentConfig;
|
|
77
154
|
planner: ControllerSubagentConfig;
|
|
78
155
|
executor: ControllerSubagentConfig;
|
|
156
|
+
/** Optional; default to the planner's config when absent (no breaking change). */
|
|
157
|
+
reviewer?: ControllerSubagentConfig;
|
|
158
|
+
finalizer?: ControllerSubagentConfig;
|
|
79
159
|
};
|
|
80
160
|
targetState: {
|
|
81
161
|
strategy: 'consumer-confirm' | 'semantic-distance' | 'auto';
|
|
@@ -90,7 +170,26 @@ export interface ControllerConfig {
|
|
|
90
170
|
maxRetries: number;
|
|
91
171
|
maxRewinds: number;
|
|
92
172
|
maxToolCalls?: number;
|
|
173
|
+
/** Durable fresh-attempt cap per step (bounds the non-advancing replan loop). */
|
|
174
|
+
maxStepAttempts?: number;
|
|
175
|
+
/** Durable crash-replay caps (one per LLM-invoking phase). */
|
|
176
|
+
maxStepResumes?: number;
|
|
177
|
+
maxPlannerResumes?: number;
|
|
178
|
+
maxEvalResumes?: number;
|
|
179
|
+
maxFinalizeRetries?: number;
|
|
180
|
+
/** In-process re-ask budget for judge (reviewer) provider/malformed failures. */
|
|
181
|
+
maxReviewRetries?: number;
|
|
182
|
+
/** Board render budget (§B). Defaulted in parseConfig; validated at load. */
|
|
183
|
+
maxDigestChars?: number;
|
|
184
|
+
maxIntentChars?: number;
|
|
185
|
+
maxActiveSteps?: number;
|
|
186
|
+
maxBoardChars?: number;
|
|
187
|
+
keepRecentDigests?: number;
|
|
93
188
|
};
|
|
189
|
+
/** Behaviour when the finalizer's retry budget is exhausted: 'error' → terminal
|
|
190
|
+
* control error (default); 'best-effort' → compose from approved results with an
|
|
191
|
+
* explicit incomplete marker. */
|
|
192
|
+
onFinalizeExhausted?: 'error' | 'best-effort';
|
|
94
193
|
}
|
|
95
194
|
export type PlannerKind = 'incremental' | 'adaptive';
|
|
96
195
|
export interface PlannerNextInput {
|
|
@@ -100,7 +199,7 @@ export interface PlannerNextInput {
|
|
|
100
199
|
* call / after a rewind / on resume). The adaptive planner replans on 'failed';
|
|
101
200
|
* the incremental planner ignores it. Cursor advance on 'advanced' happens in
|
|
102
201
|
* commit(), not here. */
|
|
103
|
-
lastOutcome?: 'advanced' | 'failed';
|
|
202
|
+
lastOutcome?: 'advanced' | 'failed' | 'partial';
|
|
104
203
|
/** True when re-asking after an unparsable reply (stern format reminder). */
|
|
105
204
|
retrying: boolean;
|
|
106
205
|
/** True on the first call of a turn that just resumed an EXTERNAL-tool result
|
|
@@ -109,13 +208,24 @@ export interface PlannerNextInput {
|
|
|
109
208
|
* plannerPrivate — instead of blindly re-running the suspended step (the
|
|
110
209
|
* executor prompt does NOT include plannerPrivate). Incremental ignores it. */
|
|
111
210
|
resumedExternal?: boolean;
|
|
211
|
+
/** The rendered step-state digest board (§B), reconstructed by the controller
|
|
212
|
+
* from artifacts before each call. When present + non-empty it is the
|
|
213
|
+
* AUTHORITATIVE step-state context, rendered ADDITIVELY ahead of the
|
|
214
|
+
* `plannerPrivate` tail (which still carries non-board deltas — clarify answers,
|
|
215
|
+
* the legacy external result). Empty/absent → the planner uses `plannerPrivate`
|
|
216
|
+
* alone (so the decision-less IncrementalPlanner is byte-identical to today). */
|
|
217
|
+
boardText?: string;
|
|
112
218
|
logUsage?: (role: string, u?: LlmUsage) => void;
|
|
219
|
+
/** Request-scoped call options (request logger / trace / cancellation signal).
|
|
220
|
+
* Threaded into the skills-recall hook so the recall embedding is metered,
|
|
221
|
+
* cancellable, and joins the request trace. */
|
|
222
|
+
options?: CallOptions;
|
|
113
223
|
}
|
|
114
224
|
export interface IControllerPlanner {
|
|
115
225
|
next(input: PlannerNextInput): Promise<NextStep | null>;
|
|
116
226
|
/** Optional: record a just-finished step's outcome so the planner's durable
|
|
117
227
|
* bookkeeping (e.g. the adaptive cursor) is updated and can be persisted in the
|
|
118
228
|
* SAME write that follows. Incremental does not implement it (no-op). */
|
|
119
|
-
commit?(bundle: SessionBundle, outcome: 'advanced' | 'failed'): void;
|
|
229
|
+
commit?(bundle: SessionBundle, outcome: 'advanced' | 'failed' | 'partial'): void;
|
|
120
230
|
}
|
|
121
231
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/smart-agent/controller/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/smart-agent/controller/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACR,OAAO,EACP,cAAc,EACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,QAAQ,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,cAAc,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,QAAQ,CAAA;CAAE,GACpE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvD,MAAM,WAAW,IAAI;IACnB;;4DAEwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;wFACoF;IACpF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,sDAAsD;AACtD,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,oDAAoD;AACpD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC;;;;;kCAKkC;AAClC,w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gBAAgB;IAC/B,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf;;;8BAG0B;IAC1B,WAAW,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;IAChD,6EAA6E;IAC7E,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;oFAIgF;IAChF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;sFAKkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;IAChD;;oDAEgD;IAChD,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IACxD;;8EAE0E;IAC1E,MAAM,CAAC,CACL,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,GACzC,IAAI,CAAC;CACT"}
|
|
@@ -1,2 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
/** Contract cap on a step's dependency references. */
|
|
2
|
+
export const MAX_REQUIRES = 8;
|
|
3
|
+
/** A reference is a SHORT phrase, not a payload. */
|
|
4
|
+
export const MAX_REQUIRE_CHARS = 200;
|
|
5
|
+
/** Validate a step's optional `requires`. `undefined` for absent OR `[]` (a step
|
|
6
|
+
* with no deps — normalize to undefined; downstream falls back to whole-step
|
|
7
|
+
* recall); the trimmed array when valid; `false` (→ parse failure / retry) when
|
|
8
|
+
* malformed: a non-array, > MAX_REQUIRES entries, a non-string entry, or an entry
|
|
9
|
+
* empty / > MAX_REQUIRE_CHARS after trim (a huge reference must not reach the
|
|
10
|
+
* semantic query / embedder). */
|
|
11
|
+
export function validateRequires(v) {
|
|
12
|
+
if (v === undefined)
|
|
13
|
+
return undefined;
|
|
14
|
+
if (!Array.isArray(v))
|
|
15
|
+
return false;
|
|
16
|
+
if (v.length === 0)
|
|
17
|
+
return undefined;
|
|
18
|
+
if (v.length > MAX_REQUIRES)
|
|
19
|
+
return false;
|
|
20
|
+
const out = [];
|
|
21
|
+
for (const r of v) {
|
|
22
|
+
if (typeof r !== 'string')
|
|
23
|
+
return false;
|
|
24
|
+
const t = r.trim();
|
|
25
|
+
if (t.length === 0 || t.length > MAX_REQUIRE_CHARS)
|
|
26
|
+
return false;
|
|
27
|
+
out.push(t);
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
2
31
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/smart-agent/controller/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/smart-agent/controller/types.ts"],"names":[],"mappings":"AA+BA,sDAAsD;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAC9B,oDAAoD;AACpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC;;;;;kCAKkC;AAClC,MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACtC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACrC,IAAI,CAAC,CAAC,MAAM,GAAG,YAAY;QAAE,OAAO,KAAK,CAAC;IAC1C,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACnB,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,iBAAiB;YAAE,OAAO,KAAK,CAAC;QACjE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACd,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CallOptions, IEmbedder, KnowledgeEntry, KnowledgeFilter } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
/** Cosine similarity of two vectors (0 when either is zero-length). Exported:
|
|
3
|
+
* reused by the controller's relevantExtract fragment-selector. */
|
|
4
|
+
export declare function cosine(a: number[], b: number[]): number;
|
|
5
|
+
/** Embedder-backed semantic index for the knowledge backend: filter PRE-cap, then
|
|
6
|
+
* cosine-rank, then top-K. The runId filter is applied to the candidate set
|
|
7
|
+
* BEFORE the cap, so a run's hits are never starved by other runs.
|
|
8
|
+
*
|
|
9
|
+
* Infrastructure artifact types (e.g. `controller-bundle`, `controller-terminal`)
|
|
10
|
+
* are skipped on upsert — they carry the full durable transcript and must NOT be
|
|
11
|
+
* embedded: they waste tokens and, once the bundle grows beyond the embedder's
|
|
12
|
+
* input limit, the JSONL rebuild fails permanently.
|
|
13
|
+
*
|
|
14
|
+
* Recallable content (a tool/step result) is embedded from a BOUNDED PREFIX
|
|
15
|
+
* (`maxEmbedChars`): a large MCP result (e.g. a full dictionary dump) can exceed
|
|
16
|
+
* the embedder's input limit (SAP AI Core text-embedding-3-small: 8192 tokens),
|
|
17
|
+
* which would 400 on upsert and break the JSONL rebuild permanently — and, since
|
|
18
|
+
* recall runs mid-run, stall the whole controller turn. Only the embedding VECTOR
|
|
19
|
+
* uses the prefix; the STORED entry keeps the full content, so recall still
|
|
20
|
+
* returns the complete result. The default (16000 chars ≈ ≤ 8000 tokens even at a
|
|
21
|
+
* pessimistic 2 chars/token) stays safely under the limit with ample ranking
|
|
22
|
+
* signal; override per deployment if needed. */
|
|
23
|
+
export declare function makeKnowledgeSemanticIndex(embedder: IEmbedder, skipArtifactTypes?: readonly string[], maxEmbedChars?: number): {
|
|
24
|
+
upsert(sid: string, e: KnowledgeEntry, options?: CallOptions): Promise<void>;
|
|
25
|
+
query(sid: string, text: string, k?: number, filter?: KnowledgeFilter, options?: CallOptions): Promise<readonly KnowledgeEntry[]>;
|
|
26
|
+
deleteSession(sid: string): void;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=embedder-knowledge-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedder-knowledge-index.d.ts","sourceRoot":"","sources":["../../src/smart-agent/embedder-knowledge-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,cAAc,EACd,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAQjC;oEACoE;AACpE,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAUvD;AAED;;;;;;;;;;;;;;;;;iDAiBiD;AACjD,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,SAAS,EACnB,iBAAiB,GAAE,SAAS,MAAM,EAGjC,EACD,aAAa,SAAQ;gBASZ,MAAM,KACR,cAAc,YACP,WAAW,GACpB,OAAO,CAAC,IAAI,CAAC;eAST,MAAM,QACL,MAAM,MACR,MAAM,WACD,eAAe,YACd,WAAW,GACpB,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC;uBAalB,MAAM,GAAG,IAAI;EAInC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { matchesKnowledgeFilter } from '@mcp-abap-adt/llm-agent-libs';
|
|
2
|
+
/** Cosine similarity of two vectors (0 when either is zero-length). Exported:
|
|
3
|
+
* reused by the controller's relevantExtract fragment-selector. */
|
|
4
|
+
export function cosine(a, b) {
|
|
5
|
+
let dot = 0;
|
|
6
|
+
let na = 0;
|
|
7
|
+
let nb = 0;
|
|
8
|
+
for (let i = 0; i < a.length; i++) {
|
|
9
|
+
dot += a[i] * b[i];
|
|
10
|
+
na += a[i] * a[i];
|
|
11
|
+
nb += b[i] * b[i];
|
|
12
|
+
}
|
|
13
|
+
return na && nb ? dot / (Math.sqrt(na) * Math.sqrt(nb)) : 0;
|
|
14
|
+
}
|
|
15
|
+
/** Embedder-backed semantic index for the knowledge backend: filter PRE-cap, then
|
|
16
|
+
* cosine-rank, then top-K. The runId filter is applied to the candidate set
|
|
17
|
+
* BEFORE the cap, so a run's hits are never starved by other runs.
|
|
18
|
+
*
|
|
19
|
+
* Infrastructure artifact types (e.g. `controller-bundle`, `controller-terminal`)
|
|
20
|
+
* are skipped on upsert — they carry the full durable transcript and must NOT be
|
|
21
|
+
* embedded: they waste tokens and, once the bundle grows beyond the embedder's
|
|
22
|
+
* input limit, the JSONL rebuild fails permanently.
|
|
23
|
+
*
|
|
24
|
+
* Recallable content (a tool/step result) is embedded from a BOUNDED PREFIX
|
|
25
|
+
* (`maxEmbedChars`): a large MCP result (e.g. a full dictionary dump) can exceed
|
|
26
|
+
* the embedder's input limit (SAP AI Core text-embedding-3-small: 8192 tokens),
|
|
27
|
+
* which would 400 on upsert and break the JSONL rebuild permanently — and, since
|
|
28
|
+
* recall runs mid-run, stall the whole controller turn. Only the embedding VECTOR
|
|
29
|
+
* uses the prefix; the STORED entry keeps the full content, so recall still
|
|
30
|
+
* returns the complete result. The default (16000 chars ≈ ≤ 8000 tokens even at a
|
|
31
|
+
* pessimistic 2 chars/token) stays safely under the limit with ample ranking
|
|
32
|
+
* signal; override per deployment if needed. */
|
|
33
|
+
export function makeKnowledgeSemanticIndex(embedder, skipArtifactTypes = [
|
|
34
|
+
'controller-bundle',
|
|
35
|
+
'controller-terminal',
|
|
36
|
+
], maxEmbedChars = 16000) {
|
|
37
|
+
const bySession = new Map();
|
|
38
|
+
// Bound the text handed to the embedder so an over-limit document never 400s
|
|
39
|
+
// (the full content is stored separately and returned by recall unchanged).
|
|
40
|
+
const embedInput = (text) => text.length > maxEmbedChars ? text.slice(0, maxEmbedChars) : text;
|
|
41
|
+
return {
|
|
42
|
+
async upsert(sid, e, options) {
|
|
43
|
+
// Skip infrastructure artifact types — never embed, never index.
|
|
44
|
+
if (skipArtifactTypes.includes(e.metadata.artifactType))
|
|
45
|
+
return;
|
|
46
|
+
const { vector } = await embedder.embed(embedInput(e.content), options);
|
|
47
|
+
const arr = bySession.get(sid);
|
|
48
|
+
if (arr)
|
|
49
|
+
arr.push({ entry: e, vector });
|
|
50
|
+
else
|
|
51
|
+
bySession.set(sid, [{ entry: e, vector }]);
|
|
52
|
+
},
|
|
53
|
+
async query(sid, text, k, filter, options) {
|
|
54
|
+
const all = bySession.get(sid) ?? [];
|
|
55
|
+
const scoped = filter
|
|
56
|
+
? all.filter((x) => matchesKnowledgeFilter(x.entry.metadata, filter))
|
|
57
|
+
: all; // PRE-cap
|
|
58
|
+
const { vector: q } = await embedder.embed(embedInput(text), options);
|
|
59
|
+
const ranked = scoped
|
|
60
|
+
.map((x) => ({ e: x.entry, s: cosine(q, x.vector) }))
|
|
61
|
+
.sort((a, b) => b.s - a.s)
|
|
62
|
+
.map((x) => x.e);
|
|
63
|
+
return k ? ranked.slice(0, k) : ranked;
|
|
64
|
+
},
|
|
65
|
+
// Session reuse must NOT return a deleted session's vectors.
|
|
66
|
+
deleteSession(sid) {
|
|
67
|
+
bySession.delete(sid);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=embedder-knowledge-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedder-knowledge-index.js","sourceRoot":"","sources":["../../src/smart-agent/embedder-knowledge-index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAOtE;oEACoE;AACpE,MAAM,UAAU,MAAM,CAAC,CAAW,EAAE,CAAW;IAC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CAAC;iBACzB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACnB,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACzC,CAAC;QACD,6DAA6D;QAC7D,aAAa,CAAC,GAAW;YACvB,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,19 +1,35 @@
|
|
|
1
|
-
import type { KnowledgeEntry } from '@mcp-abap-adt/llm-agent';
|
|
2
|
-
import type
|
|
1
|
+
import type { CallOptions, KnowledgeEntry, KnowledgeFilter } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import { type KnowledgeBackend } from '@mcp-abap-adt/llm-agent-libs';
|
|
3
|
+
/** Injected semantic index (embedder-backed); see makeKnowledgeSemanticIndex. */
|
|
4
|
+
interface SemanticIndex {
|
|
5
|
+
upsert(sid: string, e: KnowledgeEntry, options?: CallOptions): Promise<void>;
|
|
6
|
+
query(sid: string, text: string, k?: number, filter?: KnowledgeFilter, options?: CallOptions): Promise<readonly KnowledgeEntry[]>;
|
|
7
|
+
deleteSession(sid: string): void;
|
|
8
|
+
}
|
|
3
9
|
export declare class JsonlKnowledgeBackend implements KnowledgeBackend {
|
|
4
10
|
private readonly logDir;
|
|
5
|
-
/** Optional semantic index
|
|
11
|
+
/** Optional semantic index; when present query() ranks by similarity and the
|
|
12
|
+
* index is lazily rehydrated from the durable JSONL on first use. */
|
|
6
13
|
private readonly semantic?;
|
|
7
14
|
constructor(logDir: string,
|
|
8
|
-
/** Optional semantic index
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
query(sid: string, text: string, k?: number): Promise<readonly KnowledgeEntry[]>;
|
|
12
|
-
} | undefined);
|
|
15
|
+
/** Optional semantic index; when present query() ranks by similarity and the
|
|
16
|
+
* index is lazily rehydrated from the durable JSONL on first use. */
|
|
17
|
+
semantic?: SemanticIndex | undefined);
|
|
13
18
|
private file;
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
private readonly built;
|
|
20
|
+
private readonly chain;
|
|
21
|
+
private run;
|
|
22
|
+
/** Lazy rehydration of the in-process index from the durable JSONL. `options`
|
|
23
|
+
* is forwarded into every re-index `upsert` so the embedder receives the
|
|
24
|
+
* triggering request's requestLogger — the lazy rebuild's embedding cost is
|
|
25
|
+
* metered against the request that triggered it (not silently dropped). */
|
|
26
|
+
private build;
|
|
27
|
+
private append;
|
|
28
|
+
put(sid: string, entry: KnowledgeEntry, options?: CallOptions): Promise<void>;
|
|
29
|
+
semanticQuery(sid: string, text: string, k?: number, filter?: KnowledgeFilter, options?: CallOptions): Promise<readonly KnowledgeEntry[]>;
|
|
16
30
|
scan(sid: string): Promise<readonly KnowledgeEntry[]>;
|
|
17
31
|
deleteSession(sid: string): Promise<void>;
|
|
32
|
+
get semanticRecallCapable(): boolean;
|
|
18
33
|
}
|
|
34
|
+
export {};
|
|
19
35
|
//# sourceMappingURL=jsonl-knowledge-backend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl-knowledge-backend.d.ts","sourceRoot":"","sources":["../../src/smart-agent/jsonl-knowledge-backend.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"jsonl-knowledge-backend.d.ts","sourceRoot":"","sources":["../../src/smart-agent/jsonl-knowledge-backend.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,eAAe,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,8BAA8B,CAAC;AAEtC,iFAAiF;AACjF,UAAU,aAAa;IACrB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO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