@mcp-abap-adt/llm-agent 25.0.0 → 27.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/credentials/static.d.ts +9 -0
- package/dist/credentials/static.d.ts.map +1 -0
- package/dist/credentials/static.js +12 -0
- package/dist/credentials/static.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/builder.d.ts +11 -1
- package/dist/interfaces/builder.d.ts.map +1 -1
- package/dist/interfaces/collect-server-descriptors.d.ts +12 -0
- package/dist/interfaces/collect-server-descriptors.d.ts.map +1 -0
- package/dist/interfaces/collect-server-descriptors.js +19 -0
- package/dist/interfaces/collect-server-descriptors.js.map +1 -0
- package/dist/interfaces/index.d.ts +3 -2
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/mcp-connection-strategy.d.ts +29 -2
- package/dist/interfaces/mcp-connection-strategy.d.ts.map +1 -1
- package/dist/interfaces/mcp-server-from-factory.d.ts +15 -0
- package/dist/interfaces/mcp-server-from-factory.d.ts.map +1 -0
- package/dist/interfaces/mcp-server-from-factory.js +37 -0
- package/dist/interfaces/mcp-server-from-factory.js.map +1 -0
- package/dist/interfaces/mcp-server.d.ts +24 -0
- package/dist/interfaces/mcp-server.d.ts.map +1 -0
- package/dist/interfaces/mcp-server.js +2 -0
- package/dist/interfaces/mcp-server.js.map +1 -0
- package/dist/interfaces/pipeline-plugin.d.ts +16 -6
- package/dist/interfaces/pipeline-plugin.d.ts.map +1 -1
- package/dist/interfaces/plugin.d.ts +11 -3
- package/dist/interfaces/plugin.d.ts.map +1 -1
- package/dist/interfaces/rag.d.ts +133 -23
- package/dist/interfaces/rag.d.ts.map +1 -1
- package/dist/interfaces/rag.js.map +1 -1
- package/dist/interfaces/tool-catalog.d.ts +4 -2
- package/dist/interfaces/tool-catalog.d.ts.map +1 -1
- package/dist/interfaces/tool-catalog.js.map +1 -1
- package/dist/interfaces/types.d.ts +2 -1
- package/dist/interfaces/types.d.ts.map +1 -1
- package/dist/interfaces/types.js.map +1 -1
- package/dist/llm/base-llm-provider.d.ts +29 -4
- package/dist/llm/base-llm-provider.d.ts.map +1 -1
- package/dist/llm/base-llm-provider.js +45 -9
- package/dist/llm/base-llm-provider.js.map +1 -1
- package/dist/logger/normalise-logger.d.ts +28 -0
- package/dist/logger/normalise-logger.d.ts.map +1 -0
- package/dist/logger/normalise-logger.js +50 -0
- package/dist/logger/normalise-logger.js.map +1 -0
- package/dist/logger/text-logger.d.ts +14 -0
- package/dist/logger/text-logger.d.ts.map +1 -0
- package/dist/logger/text-logger.js +2 -0
- package/dist/logger/text-logger.js.map +1 -0
- package/dist/policy/fallback-llm-call-strategy.d.ts +3 -3
- package/dist/policy/fallback-llm-call-strategy.d.ts.map +1 -1
- package/dist/policy/fallback-llm-call-strategy.js +3 -2
- package/dist/policy/fallback-llm-call-strategy.js.map +1 -1
- package/dist/rag/catalog/index.d.ts +2 -0
- package/dist/rag/catalog/index.d.ts.map +1 -0
- package/dist/rag/catalog/index.js +2 -0
- package/dist/rag/catalog/index.js.map +1 -0
- package/dist/rag/catalog/validation.d.ts +56 -0
- package/dist/rag/catalog/validation.d.ts.map +1 -0
- package/dist/rag/catalog/validation.js +168 -0
- package/dist/rag/catalog/validation.js.map +1 -0
- package/dist/rag/corrections/errors.d.ts +69 -0
- package/dist/rag/corrections/errors.d.ts.map +1 -1
- package/dist/rag/corrections/errors.js +98 -0
- package/dist/rag/corrections/errors.js.map +1 -1
- package/dist/rag/identity-filter.d.ts +19 -0
- package/dist/rag/identity-filter.d.ts.map +1 -0
- package/dist/rag/identity-filter.js +31 -0
- package/dist/rag/identity-filter.js.map +1 -0
- package/dist/rag/in-memory-rag.d.ts +3 -1
- package/dist/rag/in-memory-rag.d.ts.map +1 -1
- package/dist/rag/in-memory-rag.js +20 -15
- package/dist/rag/in-memory-rag.js.map +1 -1
- package/dist/rag/index.d.ts +3 -0
- package/dist/rag/index.d.ts.map +1 -1
- package/dist/rag/index.js +2 -0
- package/dist/rag/index.js.map +1 -1
- package/dist/rag/mcp-tools/index.d.ts +1 -1
- package/dist/rag/mcp-tools/index.d.ts.map +1 -1
- package/dist/rag/mcp-tools/index.js.map +1 -1
- package/dist/rag/mcp-tools/rag-collection-tools.d.ts +36 -5
- package/dist/rag/mcp-tools/rag-collection-tools.d.ts.map +1 -1
- package/dist/rag/mcp-tools/rag-collection-tools.js +128 -54
- package/dist/rag/mcp-tools/rag-collection-tools.js.map +1 -1
- package/dist/rag/providers/base-provider.d.ts +8 -6
- package/dist/rag/providers/base-provider.d.ts.map +1 -1
- package/dist/rag/providers/base-provider.js +18 -0
- package/dist/rag/providers/base-provider.js.map +1 -1
- package/dist/rag/providers/in-memory-rag-provider.d.ts +11 -8
- package/dist/rag/providers/in-memory-rag-provider.d.ts.map +1 -1
- package/dist/rag/providers/in-memory-rag-provider.js +13 -5
- package/dist/rag/providers/in-memory-rag-provider.js.map +1 -1
- package/dist/rag/providers/vector-rag-provider.d.ts +11 -8
- package/dist/rag/providers/vector-rag-provider.d.ts.map +1 -1
- package/dist/rag/providers/vector-rag-provider.js +13 -5
- package/dist/rag/providers/vector-rag-provider.js.map +1 -1
- package/dist/rag/registry/index.d.ts +1 -0
- package/dist/rag/registry/index.d.ts.map +1 -1
- package/dist/rag/registry/index.js +1 -0
- package/dist/rag/registry/index.js.map +1 -1
- package/dist/rag/registry/simple-rag-registry.d.ts +90 -15
- package/dist/rag/registry/simple-rag-registry.d.ts.map +1 -1
- package/dist/rag/registry/simple-rag-registry.js +331 -57
- package/dist/rag/registry/simple-rag-registry.js.map +1 -1
- package/dist/rag/registry/store-key.d.ts +15 -0
- package/dist/rag/registry/store-key.d.ts.map +1 -0
- package/dist/rag/registry/store-key.js +25 -0
- package/dist/rag/registry/store-key.js.map +1 -0
- package/dist/rag/search-strategy.d.ts +9 -0
- package/dist/rag/search-strategy.d.ts.map +1 -1
- package/dist/rag/search-strategy.js +49 -22
- package/dist/rag/search-strategy.js.map +1 -1
- package/dist/rag/tokenizer.d.ts +17 -0
- package/dist/rag/tokenizer.d.ts.map +1 -0
- package/dist/rag/tokenizer.js +38 -0
- package/dist/rag/tokenizer.js.map +1 -0
- package/dist/rag/vector-rag.d.ts +2 -2
- package/dist/rag/vector-rag.d.ts.map +1 -1
- package/dist/rag/vector-rag.js +29 -21
- package/dist/rag/vector-rag.js.map +1 -1
- package/dist/resilience/embedder-resilience.d.ts +2 -2
- package/dist/resilience/embedder-resilience.d.ts.map +1 -1
- package/dist/resilience/embedder-resilience.js +3 -1
- package/dist/resilience/embedder-resilience.js.map +1 -1
- package/dist/testing/rag-filter-conformance.d.ts +60 -0
- package/dist/testing/rag-filter-conformance.d.ts.map +1 -0
- package/dist/testing/rag-filter-conformance.js +379 -0
- package/dist/testing/rag-filter-conformance.js.map +1 -0
- package/dist/types.d.ts +11 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -1
- package/dist/interfaces/failure-strategy.d.ts +0 -95
- package/dist/interfaces/failure-strategy.d.ts.map +0 -1
- package/dist/interfaces/failure-strategy.js +0 -96
- package/dist/interfaces/failure-strategy.js.map +0 -1
- package/dist/llm/rate-limit.d.ts +0 -165
- package/dist/llm/rate-limit.d.ts.map +0 -1
- package/dist/llm/rate-limit.js +0 -394
- package/dist/llm/rate-limit.js.map +0 -1
- package/dist/resilience/status.d.ts +0 -29
- package/dist/resilience/status.d.ts.map +0 -1
- package/dist/resilience/status.js +0 -51
- package/dist/resilience/status.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normaliseLogger } from '../logger/normalise-logger.js';
|
|
1
2
|
import { NonStreamingLlmCallStrategy } from './non-streaming-llm-call-strategy.js';
|
|
2
3
|
import { StreamingLlmCallStrategy } from './streaming-llm-call-strategy.js';
|
|
3
4
|
/**
|
|
@@ -5,12 +6,12 @@ import { StreamingLlmCallStrategy } from './streaming-llm-call-strategy.js';
|
|
|
5
6
|
* via non-streaming. All subsequent calls use non-streaming for this instance.
|
|
6
7
|
*/
|
|
7
8
|
export class FallbackLlmCallStrategy {
|
|
8
|
-
logger;
|
|
9
9
|
streamingDisabled = false;
|
|
10
10
|
streaming = new StreamingLlmCallStrategy();
|
|
11
11
|
nonStreaming = new NonStreamingLlmCallStrategy();
|
|
12
|
+
logger;
|
|
12
13
|
constructor(logger) {
|
|
13
|
-
this.logger = logger;
|
|
14
|
+
this.logger = logger ? normaliseLogger(logger) : undefined;
|
|
14
15
|
}
|
|
15
16
|
async *call(llm, messages, tools, options) {
|
|
16
17
|
if (this.streamingDisabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fallback-llm-call-strategy.js","sourceRoot":"","sources":["../../src/policy/fallback-llm-call-strategy.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E;;;GAGG;AACH,MAAM,OAAO,uBAAuB;
|
|
1
|
+
{"version":3,"file":"fallback-llm-call-strategy.js","sourceRoot":"","sources":["../../src/policy/fallback-llm-call-strategy.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAC1B,iBAAiB,GAAG,KAAK,CAAC;IACjB,SAAS,GAAG,IAAI,wBAAwB,EAAE,CAAC;IAC3C,YAAY,GAAG,IAAI,2BAA2B,EAAE,CAAC;IACjD,MAAM,CAAW;IAElC,YAAY,MAAkB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,C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BAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,YAAY,EACZ,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rag/catalog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EAGxB,YAAY,EACZ,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { RagCatalogDescription, RagCollectionOwner, RagCollectionRecord, RagJsonValue } from '../../interfaces/rag.js';
|
|
2
|
+
import type { Result } from '../../interfaces/types.js';
|
|
3
|
+
import { InvalidAttributesError, InvalidOwnerError } from '../corrections/errors.js';
|
|
4
|
+
/**
|
|
5
|
+
* Attributes as a catalog can return them: JSON with finite numbers, no cycle,
|
|
6
|
+
* plain objects and arrays only. Called by both createCollection contracts
|
|
7
|
+
* BEFORE anything is created, and on every catalog row read back.
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateRagAttributes(value: unknown): Result<RagJsonValue | undefined, InvalidAttributesError>;
|
|
10
|
+
/**
|
|
11
|
+
* The owner as the union demands it, for input no compiler checked: the scope,
|
|
12
|
+
* and only the key that scope selects, non-empty. Called by both
|
|
13
|
+
* createCollection contracts before any backend access, and on every catalog
|
|
14
|
+
* row read back.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateRagOwner(input: unknown): Result<RagCollectionOwner, InvalidOwnerError>;
|
|
17
|
+
/** The owner's key in the flat shape RagCollectionMeta carries. */
|
|
18
|
+
export declare function ragOwnerKeys(owner: RagCollectionOwner): {
|
|
19
|
+
sessionId?: string;
|
|
20
|
+
userId?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The stored form of attributes: JSON text, or null for none. Text rather than a
|
|
24
|
+
* backend's JSON type, so `null` and absent stay apart and nothing is normalized.
|
|
25
|
+
*/
|
|
26
|
+
export declare function encodeRagAttributes(value: RagJsonValue | undefined): string | null;
|
|
27
|
+
/** One catalog row as a provider read it, before anything is trusted. */
|
|
28
|
+
export type RagCatalogRow = {
|
|
29
|
+
readonly storeName?: unknown;
|
|
30
|
+
readonly name?: unknown;
|
|
31
|
+
readonly scope?: unknown;
|
|
32
|
+
readonly userId?: unknown;
|
|
33
|
+
readonly sessionId?: unknown;
|
|
34
|
+
/** What encodeRagAttributes produced; null or absent → no attributes. */
|
|
35
|
+
readonly attributesJson?: unknown;
|
|
36
|
+
};
|
|
37
|
+
export type RagCatalogRowParse = {
|
|
38
|
+
readonly ok: true;
|
|
39
|
+
readonly record: RagCollectionRecord;
|
|
40
|
+
} | {
|
|
41
|
+
readonly ok: false;
|
|
42
|
+
readonly rejected: {
|
|
43
|
+
readonly storeName?: string;
|
|
44
|
+
readonly reason: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A catalog row is storage outside any compiler, so it is checked at this
|
|
49
|
+
* boundary: no store name, no logical name, no or an unknown scope, a missing
|
|
50
|
+
* owner key, or attributes that are not JSON text make it a rejection, never a
|
|
51
|
+
* record (§6.3).
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseRagCollectionRecord(row: RagCatalogRow): RagCatalogRowParse;
|
|
54
|
+
/** Sorts rows into records and rejections; one bad row fails nothing. */
|
|
55
|
+
export declare function describeRagCatalogRows(rows: readonly RagCatalogRow[]): RagCatalogDescription;
|
|
56
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/rag/catalog/validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACb,MAAM,yBAAyB,CAAC;AACjC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MAAM,CAAC;QAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACzB,CAAC;CACH,CAAC;AAEN;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,aAAa,GACjB,kBAAkB,CAmCpB;AAED,yEAAyE;AACzE,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,SAAS,aAAa,EAAE,GAC7B,qBAAqB,CASvB"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { InvalidAttributesError, InvalidOwnerError, } from '../corrections/errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Attributes as a catalog can return them: JSON with finite numbers, no cycle,
|
|
4
|
+
* plain objects and arrays only. Called by both createCollection contracts
|
|
5
|
+
* BEFORE anything is created, and on every catalog row read back.
|
|
6
|
+
*/
|
|
7
|
+
export function validateRagAttributes(value) {
|
|
8
|
+
if (value === undefined)
|
|
9
|
+
return { ok: true, value: undefined };
|
|
10
|
+
const problem = findNonJson(value, '$', new Set());
|
|
11
|
+
return problem === undefined
|
|
12
|
+
? { ok: true, value: value }
|
|
13
|
+
: { ok: false, error: new InvalidAttributesError(problem) };
|
|
14
|
+
}
|
|
15
|
+
function findNonJson(value, path, ancestors) {
|
|
16
|
+
if (value === null)
|
|
17
|
+
return undefined;
|
|
18
|
+
switch (typeof value) {
|
|
19
|
+
case 'string':
|
|
20
|
+
case 'boolean':
|
|
21
|
+
return undefined;
|
|
22
|
+
case 'number':
|
|
23
|
+
return Number.isFinite(value)
|
|
24
|
+
? undefined
|
|
25
|
+
: `${path} is ${String(value)}, which JSON turns into null`;
|
|
26
|
+
case 'undefined':
|
|
27
|
+
return `${path} is undefined, which JSON drops`;
|
|
28
|
+
case 'object':
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
return `${path} is a ${typeof value}, which has no JSON form`;
|
|
32
|
+
}
|
|
33
|
+
const obj = value;
|
|
34
|
+
if (ancestors.has(obj))
|
|
35
|
+
return `${path} is a cycle`;
|
|
36
|
+
ancestors.add(obj);
|
|
37
|
+
try {
|
|
38
|
+
if (Array.isArray(obj)) {
|
|
39
|
+
for (let i = 0; i < obj.length; i++) {
|
|
40
|
+
const found = findNonJson(obj[i], `${path}[${i}]`, ancestors);
|
|
41
|
+
if (found !== undefined)
|
|
42
|
+
return found;
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const proto = Object.getPrototypeOf(obj);
|
|
47
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
48
|
+
const ctor = proto.constructor;
|
|
49
|
+
return `${path} is a ${ctor?.name ?? 'class'} instance, which JSON would not return as it is`;
|
|
50
|
+
}
|
|
51
|
+
for (const [key, child] of Object.entries(obj)) {
|
|
52
|
+
const found = findNonJson(child, `${path}.${key}`, ancestors);
|
|
53
|
+
if (found !== undefined)
|
|
54
|
+
return found;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
ancestors.delete(obj);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The owner as the union demands it, for input no compiler checked: the scope,
|
|
64
|
+
* and only the key that scope selects, non-empty. Called by both
|
|
65
|
+
* createCollection contracts before any backend access, and on every catalog
|
|
66
|
+
* row read back.
|
|
67
|
+
*/
|
|
68
|
+
export function validateRagOwner(input) {
|
|
69
|
+
const o = (typeof input === 'object' && input !== null ? input : {});
|
|
70
|
+
switch (o.scope) {
|
|
71
|
+
case 'global':
|
|
72
|
+
return { ok: true, value: { scope: 'global' } };
|
|
73
|
+
case 'user':
|
|
74
|
+
return typeof o.userId === 'string' && o.userId !== ''
|
|
75
|
+
? { ok: true, value: { scope: 'user', userId: o.userId } }
|
|
76
|
+
: {
|
|
77
|
+
ok: false,
|
|
78
|
+
error: new InvalidOwnerError('a user collection needs a non-empty userId'),
|
|
79
|
+
};
|
|
80
|
+
case 'session':
|
|
81
|
+
return typeof o.sessionId === 'string' && o.sessionId !== ''
|
|
82
|
+
? { ok: true, value: { scope: 'session', sessionId: o.sessionId } }
|
|
83
|
+
: {
|
|
84
|
+
ok: false,
|
|
85
|
+
error: new InvalidOwnerError('a session collection needs a non-empty sessionId'),
|
|
86
|
+
};
|
|
87
|
+
case undefined:
|
|
88
|
+
return { ok: false, error: new InvalidOwnerError('no scope') };
|
|
89
|
+
default:
|
|
90
|
+
return {
|
|
91
|
+
ok: false,
|
|
92
|
+
error: new InvalidOwnerError(`unknown scope '${String(o.scope)}'`),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** The owner's key in the flat shape RagCollectionMeta carries. */
|
|
97
|
+
export function ragOwnerKeys(owner) {
|
|
98
|
+
if (owner.scope === 'session')
|
|
99
|
+
return { sessionId: owner.sessionId };
|
|
100
|
+
if (owner.scope === 'user')
|
|
101
|
+
return { userId: owner.userId };
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The stored form of attributes: JSON text, or null for none. Text rather than a
|
|
106
|
+
* backend's JSON type, so `null` and absent stay apart and nothing is normalized.
|
|
107
|
+
*/
|
|
108
|
+
export function encodeRagAttributes(value) {
|
|
109
|
+
return value === undefined ? null : JSON.stringify(value);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A catalog row is storage outside any compiler, so it is checked at this
|
|
113
|
+
* boundary: no store name, no logical name, no or an unknown scope, a missing
|
|
114
|
+
* owner key, or attributes that are not JSON text make it a rejection, never a
|
|
115
|
+
* record (§6.3).
|
|
116
|
+
*/
|
|
117
|
+
export function parseRagCollectionRecord(row) {
|
|
118
|
+
const storeName = typeof row.storeName === 'string' && row.storeName !== ''
|
|
119
|
+
? row.storeName
|
|
120
|
+
: undefined;
|
|
121
|
+
const reject = (reason) => ({
|
|
122
|
+
ok: false,
|
|
123
|
+
rejected: storeName === undefined ? { reason } : { storeName, reason },
|
|
124
|
+
});
|
|
125
|
+
if (storeName === undefined)
|
|
126
|
+
return reject('no store name');
|
|
127
|
+
const name = row.name;
|
|
128
|
+
if (typeof name !== 'string' || name === '')
|
|
129
|
+
return reject('no logical name');
|
|
130
|
+
const owner = validateRagOwner(row);
|
|
131
|
+
if (!owner.ok)
|
|
132
|
+
return reject(owner.error.reason);
|
|
133
|
+
const json = row.attributesJson;
|
|
134
|
+
if (json === null || json === undefined) {
|
|
135
|
+
return { ok: true, record: { ...owner.value, storeName, name } };
|
|
136
|
+
}
|
|
137
|
+
if (typeof json !== 'string') {
|
|
138
|
+
return reject(`attributes are stored as ${typeof json}, not as JSON text`);
|
|
139
|
+
}
|
|
140
|
+
let parsed;
|
|
141
|
+
try {
|
|
142
|
+
parsed = JSON.parse(json);
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
return reject(`attributes are not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
|
|
146
|
+
}
|
|
147
|
+
const attributes = validateRagAttributes(parsed);
|
|
148
|
+
if (!attributes.ok)
|
|
149
|
+
return reject(attributes.error.reason);
|
|
150
|
+
return {
|
|
151
|
+
ok: true,
|
|
152
|
+
record: { ...owner.value, storeName, name, attributes: attributes.value },
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/** Sorts rows into records and rejections; one bad row fails nothing. */
|
|
156
|
+
export function describeRagCatalogRows(rows) {
|
|
157
|
+
const records = [];
|
|
158
|
+
const rejected = [];
|
|
159
|
+
for (const row of rows) {
|
|
160
|
+
const parsed = parseRagCollectionRecord(row);
|
|
161
|
+
if (parsed.ok)
|
|
162
|
+
records.push(parsed.record);
|
|
163
|
+
else
|
|
164
|
+
rejected.push(parsed.rejected);
|
|
165
|
+
}
|
|
166
|
+
return { records, rejected };
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/rag/catalog/validation.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,sBA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GAAG,CAAC,CAAC;QAC7C,IAAI,MAAM,CAAC,EAAE;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;;YACtC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RagCollectionScope } from '../../interfaces/rag.js';
|
|
1
2
|
import { RagError } from '../../interfaces/types.js';
|
|
2
3
|
export declare class ReadOnlyError extends RagError {
|
|
3
4
|
constructor(collectionName: string);
|
|
@@ -17,7 +18,75 @@ export declare class ProviderNotFoundError extends RagError {
|
|
|
17
18
|
export declare class CollectionNotFoundError extends RagError {
|
|
18
19
|
constructor(collectionName: string);
|
|
19
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* A collection was unregistered, but nothing could delete its data: its
|
|
23
|
+
* provider is gone, or it has no `deleteCollection` and its store no
|
|
24
|
+
* `writer().clearAll()`.
|
|
25
|
+
*/
|
|
26
|
+
export declare class DeleteUnsupportedError extends RagError {
|
|
27
|
+
constructor(collectionName: string, reason: string);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A session was closed — every one of its collections unregistered — but the
|
|
31
|
+
* data of some could not be deleted. `failures` names each, with its error.
|
|
32
|
+
*/
|
|
33
|
+
export declare class SessionCloseIncompleteError extends RagError {
|
|
34
|
+
readonly failures: ReadonlyArray<{
|
|
35
|
+
name: string;
|
|
36
|
+
error: RagError;
|
|
37
|
+
}>;
|
|
38
|
+
constructor(sessionId: string, failures: ReadonlyArray<{
|
|
39
|
+
name: string;
|
|
40
|
+
error: RagError;
|
|
41
|
+
}>);
|
|
42
|
+
}
|
|
20
43
|
export declare class ScopeViolationError extends RagError {
|
|
21
44
|
constructor(collectionName: string, reason: string);
|
|
22
45
|
}
|
|
46
|
+
/** Attributes JSON would not return unchanged: NaN, ±Infinity, a cycle, or no JSON form. */
|
|
47
|
+
export declare class InvalidAttributesError extends RagError {
|
|
48
|
+
readonly reason: string;
|
|
49
|
+
constructor(reason: string);
|
|
50
|
+
}
|
|
51
|
+
/** A scope without the owner key it selects, or no known scope at all. */
|
|
52
|
+
export declare class InvalidOwnerError extends RagError {
|
|
53
|
+
readonly reason: string;
|
|
54
|
+
constructor(reason: string);
|
|
55
|
+
}
|
|
56
|
+
/** The collection is taken: its catalog record (or a registry entry) exists. */
|
|
57
|
+
export declare class DuplicateCollectionError extends RagError {
|
|
58
|
+
constructor(collectionName: string, detail?: string);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A store exists without a catalog record — at this moment: another session may
|
|
62
|
+
* be creating or deleting it, so a retry later may find a finished collection or
|
|
63
|
+
* a free name. Adopt it with `adoptExisting`, or remove it.
|
|
64
|
+
*/
|
|
65
|
+
export declare class OrphanStoreError extends RagError {
|
|
66
|
+
readonly storeName: string;
|
|
67
|
+
constructor(storeName: string, reason: string);
|
|
68
|
+
}
|
|
69
|
+
/** A name held in several scopes of one registry, addressed without a scope. */
|
|
70
|
+
export declare class AmbiguousCollectionError extends RagError {
|
|
71
|
+
readonly scopes: readonly RagCollectionScope[];
|
|
72
|
+
constructor(collectionName: string, scopes: readonly RagCollectionScope[]);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The first step of a catalogued deletion failed: the record could not be
|
|
76
|
+
* removed, so the data was not touched and nothing was deleted — retry it.
|
|
77
|
+
*/
|
|
78
|
+
export declare class CatalogRecordDeleteError extends RagError {
|
|
79
|
+
readonly storeName: string;
|
|
80
|
+
constructor(storeName: string, reason: string);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A global named into a prefix the `ragStores` projection gives another scope
|
|
84
|
+
* (§6.4): it would take that scope's key, and one entry would silently
|
|
85
|
+
* overwrite the other. Thrown by `register` and `adopt`, returned by
|
|
86
|
+
* `createCollection` (Tasks B23, B24).
|
|
87
|
+
*/
|
|
88
|
+
export declare class ReservedCollectionNameError extends RagError {
|
|
89
|
+
readonly prefix: string;
|
|
90
|
+
constructor(collectionName: string, prefix: string);
|
|
91
|
+
}
|
|
23
92
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/rag/corrections/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,cAAc,EAAE,MAAM;CAInC;AAED,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,YAAY,EAAE,MAAM;CAIjC;AAED,qBAAa,0BAA2B,SAAQ,QAAQ;gBAC1C,GAAG,EAAE,MAAM;CAOxB;AAED,qBAAa,qBAAsB,SAAQ,QAAQ;gBACrC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAOhD;AAED,qBAAa,qBAAsB,SAAQ,QAAQ;gBACrC,YAAY,EAAE,MAAM;CAOjC;AAED,qBAAa,uBAAwB,SAAQ,QAAQ;gBACvC,cAAc,EAAE,MAAM;CAOnC;AAED,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAOnD"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/rag/corrections/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,cAAc,EAAE,MAAM;CAInC;AAED,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,YAAY,EAAE,MAAM;CAIjC;AAED,qBAAa,0BAA2B,SAAQ,QAAQ;gBAC1C,GAAG,EAAE,MAA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jB;AAED,gFAAgF;AAChF,qBAAa,wBAAyB,SAAQ,QAAQ;IAGlD,QAAQ,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE;gBAD9C,cAAc,EAAE,MAAM,EACb,MAAM,EAAE,SAAS,kBAAkB,EAAE;CAQjD;AAED;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,QAAQ;IAElD,QAAQ,CAAC,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM,EAC1B,MAAM,EAAE,MAAM;CAQjB;AAED;;;;;GAKG;AACH,qBAAa,2BAA4B,SAAQ,QAAQ;IAGrD,QAAQ,CAAC,MAAM,EAAE,MAAM;gBADvB,cAAc,EAAE,MAAM,EACb,MAAM,EAAE,MAAM;CAQ1B"}
|
|
@@ -35,10 +35,108 @@ export class CollectionNotFoundError extends RagError {
|
|
|
35
35
|
this.name = 'CollectionNotFoundError';
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* A collection was unregistered, but nothing could delete its data: its
|
|
40
|
+
* provider is gone, or it has no `deleteCollection` and its store no
|
|
41
|
+
* `writer().clearAll()`.
|
|
42
|
+
*/
|
|
43
|
+
export class DeleteUnsupportedError extends RagError {
|
|
44
|
+
constructor(collectionName, reason) {
|
|
45
|
+
super(`Collection '${collectionName}' was unregistered, but its data was not deleted: ${reason}`, 'RAG_DELETE_UNSUPPORTED');
|
|
46
|
+
this.name = 'DeleteUnsupportedError';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A session was closed — every one of its collections unregistered — but the
|
|
51
|
+
* data of some could not be deleted. `failures` names each, with its error.
|
|
52
|
+
*/
|
|
53
|
+
export class SessionCloseIncompleteError extends RagError {
|
|
54
|
+
failures;
|
|
55
|
+
constructor(sessionId, failures) {
|
|
56
|
+
super(`Session '${sessionId}' closed, but the data of ${failures.length} collection(s) could not be deleted: ${failures
|
|
57
|
+
.map((f) => `${f.name}: ${f.error.message}`)
|
|
58
|
+
.join('; ')}`, 'RAG_SESSION_CLOSE_INCOMPLETE');
|
|
59
|
+
this.failures = failures;
|
|
60
|
+
this.name = 'SessionCloseIncompleteError';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
38
63
|
export class ScopeViolationError extends RagError {
|
|
39
64
|
constructor(collectionName, reason) {
|
|
40
65
|
super(`Scope violation on '${collectionName}': ${reason}`, 'RAG_SCOPE_VIOLATION');
|
|
41
66
|
this.name = 'ScopeViolationError';
|
|
42
67
|
}
|
|
43
68
|
}
|
|
69
|
+
/** Attributes JSON would not return unchanged: NaN, ±Infinity, a cycle, or no JSON form. */
|
|
70
|
+
export class InvalidAttributesError extends RagError {
|
|
71
|
+
reason;
|
|
72
|
+
constructor(reason) {
|
|
73
|
+
super(`Collection attributes cannot be stored as JSON unchanged: ${reason}`, 'RAG_INVALID_ATTRIBUTES');
|
|
74
|
+
this.reason = reason;
|
|
75
|
+
this.name = 'InvalidAttributesError';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** A scope without the owner key it selects, or no known scope at all. */
|
|
79
|
+
export class InvalidOwnerError extends RagError {
|
|
80
|
+
reason;
|
|
81
|
+
constructor(reason) {
|
|
82
|
+
super(`Collection owner is invalid: ${reason}`, 'RAG_INVALID_OWNER');
|
|
83
|
+
this.reason = reason;
|
|
84
|
+
this.name = 'InvalidOwnerError';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** The collection is taken: its catalog record (or a registry entry) exists. */
|
|
88
|
+
export class DuplicateCollectionError extends RagError {
|
|
89
|
+
constructor(collectionName, detail) {
|
|
90
|
+
super(`Collection '${collectionName}' already exists${detail ? `: ${detail}` : ''}`, 'RAG_DUPLICATE_COLLECTION');
|
|
91
|
+
this.name = 'DuplicateCollectionError';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A store exists without a catalog record — at this moment: another session may
|
|
96
|
+
* be creating or deleting it, so a retry later may find a finished collection or
|
|
97
|
+
* a free name. Adopt it with `adoptExisting`, or remove it.
|
|
98
|
+
*/
|
|
99
|
+
export class OrphanStoreError extends RagError {
|
|
100
|
+
storeName;
|
|
101
|
+
constructor(storeName, reason) {
|
|
102
|
+
super(`Store '${storeName}' has no catalog record: ${reason}`, 'RAG_ORPHAN_STORE');
|
|
103
|
+
this.storeName = storeName;
|
|
104
|
+
this.name = 'OrphanStoreError';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** A name held in several scopes of one registry, addressed without a scope. */
|
|
108
|
+
export class AmbiguousCollectionError extends RagError {
|
|
109
|
+
scopes;
|
|
110
|
+
constructor(collectionName, scopes) {
|
|
111
|
+
super(`Collection '${collectionName}' exists in several scopes (${scopes.join(', ')}); name the scope`, 'RAG_AMBIGUOUS_COLLECTION');
|
|
112
|
+
this.scopes = scopes;
|
|
113
|
+
this.name = 'AmbiguousCollectionError';
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The first step of a catalogued deletion failed: the record could not be
|
|
118
|
+
* removed, so the data was not touched and nothing was deleted — retry it.
|
|
119
|
+
*/
|
|
120
|
+
export class CatalogRecordDeleteError extends RagError {
|
|
121
|
+
storeName;
|
|
122
|
+
constructor(storeName, reason) {
|
|
123
|
+
super(`The catalog record of store '${storeName}' could not be deleted, so nothing was deleted: ${reason}`, 'RAG_CATALOG_RECORD_DELETE');
|
|
124
|
+
this.storeName = storeName;
|
|
125
|
+
this.name = 'CatalogRecordDeleteError';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A global named into a prefix the `ragStores` projection gives another scope
|
|
130
|
+
* (§6.4): it would take that scope's key, and one entry would silently
|
|
131
|
+
* overwrite the other. Thrown by `register` and `adopt`, returned by
|
|
132
|
+
* `createCollection` (Tasks B23, B24).
|
|
133
|
+
*/
|
|
134
|
+
export class ReservedCollectionNameError extends RagError {
|
|
135
|
+
prefix;
|
|
136
|
+
constructor(collectionName, prefix) {
|
|
137
|
+
super(`A global collection may not be named '${collectionName}': the prefix '${prefix}' is reserved for the ${prefix.slice(0, -1)} scope`, 'RAG_RESERVED_COLLECTION_NAME');
|
|
138
|
+
this.prefix = prefix;
|
|
139
|
+
this.name = 'ReservedCollectionNameError';
|
|
140
|
+
}
|
|
141
|
+
}
|
|
44
142
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/rag/corrections/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/rag/corrections/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,MAAM,OAAO,aAAc,SAAQ,QAAQ;IACzC,YAAY,cAAsB;QAChC,KAAK,CAAC,eAAe,cAAc,gBAAgB,EAAE,eAAe,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAC1C,YAAY,YAAoB;QAC9B,KAAK,CAAC,GAAG,YAAY,uBAAuB,EAAE,gBAAgB,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,0BAA2B,SAAQ,QAAQ;IACtD,YAAY,GAAW;QACrB,KAAK,CACH,iBAAiB,GAAG,uEAAuE,EAC3F,6BAA6B,CAC9B,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,QAAQ;IACjD,YAAY,YAAoB,EAAE,KAAa;QAC7C,KAAK,CACH,aAAa,YAAY,6BAA6B,KAAK,GAAG,EAC9D,uBAAuB,CACxB,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;A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B,CAAC;QALO,WAAM,GAAN,MAAM,CAA+B;QAM9C,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,wBAAyB,SAAQ,QAAQ;IAEzC;IADX,YACW,SAAiB,EAC1B,MAAc;QAEd,KAAK,CACH,gCAAgC,SAAS,mDAAmD,MAAM,EAAE,EACpG,2BAA2B,CAC5B,CAAC;QANO,cAAS,GAAT,SAAS,CAAQ;QAO1B,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,2BAA4B,SAAQ,QAAQ;IAG5C;IAFX,YACE,cAAsB,EACb,MAAc;QAEvB,KAAK,CACH,yCAAyC,cAAc,kBAAkB,MAAM,yBAAyB,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EACnI,8BAA8B,CAC/B,CAAC;QALO,WAAM,GAAN,MAAM,CAAQ;QAMvB,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CallOptions, RagMetadata } from '../interfaces/types.js';
|
|
2
|
+
/** The identity part of `CallOptions.ragFilter` every `IRag` store honours. */
|
|
3
|
+
export interface RagIdentityFilter {
|
|
4
|
+
sessionId?: string;
|
|
5
|
+
userId?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The `sessionId` / `userId` a query is scoped to, or `undefined` when it is
|
|
9
|
+
* scoped to neither. Only string values count, so an absent key and an
|
|
10
|
+
* explicit `undefined` both mean "not filtered".
|
|
11
|
+
*/
|
|
12
|
+
export declare function ragIdentityFilter(options?: CallOptions): RagIdentityFilter | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Whether a record belongs to the scope of `filter`. A record without the
|
|
15
|
+
* filtered key does not match — an unowned record is never shown to a scoped
|
|
16
|
+
* query. Stores apply this BEFORE top-k.
|
|
17
|
+
*/
|
|
18
|
+
export declare function matchesRagIdentity(metadata: RagMetadata, filter: RagIdentityFilter | undefined): boolean;
|
|
19
|
+
//# sourceMappingURL=identity-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-filter.d.ts","sourceRoot":"","sources":["../../src/rag/identity-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEvE,+EAA+E;AAC/E,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,WAAW,GACpB,iBAAiB,GAAG,SAAS,CAS/B;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,WAAW,EACrB,MAAM,EAAE,iBAAiB,GAAG,SAAS,GACpC,OAAO,CAOT"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sessionId` / `userId` a query is scoped to, or `undefined` when it is
|
|
3
|
+
* scoped to neither. Only string values count, so an absent key and an
|
|
4
|
+
* explicit `undefined` both mean "not filtered".
|
|
5
|
+
*/
|
|
6
|
+
export function ragIdentityFilter(options) {
|
|
7
|
+
const f = options?.ragFilter;
|
|
8
|
+
const sessionId = typeof f?.sessionId === 'string' ? f.sessionId : undefined;
|
|
9
|
+
const userId = typeof f?.userId === 'string' ? f.userId : undefined;
|
|
10
|
+
if (sessionId === undefined && userId === undefined)
|
|
11
|
+
return undefined;
|
|
12
|
+
return {
|
|
13
|
+
...(sessionId !== undefined ? { sessionId } : {}),
|
|
14
|
+
...(userId !== undefined ? { userId } : {}),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether a record belongs to the scope of `filter`. A record without the
|
|
19
|
+
* filtered key does not match — an unowned record is never shown to a scoped
|
|
20
|
+
* query. Stores apply this BEFORE top-k.
|
|
21
|
+
*/
|
|
22
|
+
export function matchesRagIdentity(metadata, filter) {
|
|
23
|
+
if (!filter)
|
|
24
|
+
return true;
|
|
25
|
+
if (filter.sessionId !== undefined && metadata.sessionId !== filter.sessionId)
|
|
26
|
+
return false;
|
|
27
|
+
if (filter.userId !== undefined && metadata.userId !== filter.userId)
|
|
28
|
+
return false;
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=identity-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-filter.js","sourceRoot":"","sources":["../../src/rag/identity-filter.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAqB;IAErB,MAAM,CAAC,GAAG,OAAO,EAAE,SAAS,CAAC;IAC7B,MAAM,SAAS,GAAG,OAAO,CAAC,EAAE,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7E,MAAM,MAAM,GAAG,OAAO,CAAC,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACpE,IAAI,SAAS,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACtE,OAAO;QACL,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5C,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAqB,EACrB,MAAqC;IAErC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,QAAQ,CAAC,SAAS,KAAK,MAAM,CAAC,SAAS;QAC3E,OAAO,KAAK,CAAC;IACf,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;QAClE,OAAO,KAAK,CAAC;IACf,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -4,7 +4,9 @@ import type { CallOptions, RagMetadata, RagResult, Result } from '../interfaces/
|
|
|
4
4
|
import { RagError } from '../interfaces/types.js';
|
|
5
5
|
import type { IDocumentEnricher, IQueryPreprocessor } from './preprocessor.js';
|
|
6
6
|
export interface InMemoryRagConfig {
|
|
7
|
-
/** Cosine similarity above which upsert
|
|
7
|
+
/** Cosine similarity above which an upsert without an id updates an existing
|
|
8
|
+
* record without an id (a record with an id is replaced only by the same id).
|
|
9
|
+
* Default: 0.92 */
|
|
8
10
|
dedupThreshold?: number;
|
|
9
11
|
/** Namespace for this store. Records with different namespace are invisible to query. */
|
|
10
12
|
namespace?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory-rag.d.ts","sourceRoot":"","sources":["../../src/rag/in-memory-rag.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,MAAM,EACP,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"in-memory-rag.d.ts","sourceRoot":"","sources":["../../src/rag/in-memory-rag.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,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