@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.
Files changed (147) hide show
  1. package/README.md +2 -0
  2. package/dist/credentials/static.d.ts +9 -0
  3. package/dist/credentials/static.d.ts.map +1 -0
  4. package/dist/credentials/static.js +12 -0
  5. package/dist/credentials/static.js.map +1 -0
  6. package/dist/index.d.ts +6 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +5 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/interfaces/builder.d.ts +11 -1
  11. package/dist/interfaces/builder.d.ts.map +1 -1
  12. package/dist/interfaces/collect-server-descriptors.d.ts +12 -0
  13. package/dist/interfaces/collect-server-descriptors.d.ts.map +1 -0
  14. package/dist/interfaces/collect-server-descriptors.js +19 -0
  15. package/dist/interfaces/collect-server-descriptors.js.map +1 -0
  16. package/dist/interfaces/index.d.ts +3 -2
  17. package/dist/interfaces/index.d.ts.map +1 -1
  18. package/dist/interfaces/index.js.map +1 -1
  19. package/dist/interfaces/mcp-connection-strategy.d.ts +29 -2
  20. package/dist/interfaces/mcp-connection-strategy.d.ts.map +1 -1
  21. package/dist/interfaces/mcp-server-from-factory.d.ts +15 -0
  22. package/dist/interfaces/mcp-server-from-factory.d.ts.map +1 -0
  23. package/dist/interfaces/mcp-server-from-factory.js +37 -0
  24. package/dist/interfaces/mcp-server-from-factory.js.map +1 -0
  25. package/dist/interfaces/mcp-server.d.ts +24 -0
  26. package/dist/interfaces/mcp-server.d.ts.map +1 -0
  27. package/dist/interfaces/mcp-server.js +2 -0
  28. package/dist/interfaces/mcp-server.js.map +1 -0
  29. package/dist/interfaces/pipeline-plugin.d.ts +16 -6
  30. package/dist/interfaces/pipeline-plugin.d.ts.map +1 -1
  31. package/dist/interfaces/plugin.d.ts +11 -3
  32. package/dist/interfaces/plugin.d.ts.map +1 -1
  33. package/dist/interfaces/rag.d.ts +133 -23
  34. package/dist/interfaces/rag.d.ts.map +1 -1
  35. package/dist/interfaces/rag.js.map +1 -1
  36. package/dist/interfaces/tool-catalog.d.ts +4 -2
  37. package/dist/interfaces/tool-catalog.d.ts.map +1 -1
  38. package/dist/interfaces/tool-catalog.js.map +1 -1
  39. package/dist/interfaces/types.d.ts +2 -1
  40. package/dist/interfaces/types.d.ts.map +1 -1
  41. package/dist/interfaces/types.js.map +1 -1
  42. package/dist/llm/base-llm-provider.d.ts +29 -4
  43. package/dist/llm/base-llm-provider.d.ts.map +1 -1
  44. package/dist/llm/base-llm-provider.js +45 -9
  45. package/dist/llm/base-llm-provider.js.map +1 -1
  46. package/dist/logger/normalise-logger.d.ts +28 -0
  47. package/dist/logger/normalise-logger.d.ts.map +1 -0
  48. package/dist/logger/normalise-logger.js +50 -0
  49. package/dist/logger/normalise-logger.js.map +1 -0
  50. package/dist/logger/text-logger.d.ts +14 -0
  51. package/dist/logger/text-logger.d.ts.map +1 -0
  52. package/dist/logger/text-logger.js +2 -0
  53. package/dist/logger/text-logger.js.map +1 -0
  54. package/dist/policy/fallback-llm-call-strategy.d.ts +3 -3
  55. package/dist/policy/fallback-llm-call-strategy.d.ts.map +1 -1
  56. package/dist/policy/fallback-llm-call-strategy.js +3 -2
  57. package/dist/policy/fallback-llm-call-strategy.js.map +1 -1
  58. package/dist/rag/catalog/index.d.ts +2 -0
  59. package/dist/rag/catalog/index.d.ts.map +1 -0
  60. package/dist/rag/catalog/index.js +2 -0
  61. package/dist/rag/catalog/index.js.map +1 -0
  62. package/dist/rag/catalog/validation.d.ts +56 -0
  63. package/dist/rag/catalog/validation.d.ts.map +1 -0
  64. package/dist/rag/catalog/validation.js +168 -0
  65. package/dist/rag/catalog/validation.js.map +1 -0
  66. package/dist/rag/corrections/errors.d.ts +69 -0
  67. package/dist/rag/corrections/errors.d.ts.map +1 -1
  68. package/dist/rag/corrections/errors.js +98 -0
  69. package/dist/rag/corrections/errors.js.map +1 -1
  70. package/dist/rag/identity-filter.d.ts +19 -0
  71. package/dist/rag/identity-filter.d.ts.map +1 -0
  72. package/dist/rag/identity-filter.js +31 -0
  73. package/dist/rag/identity-filter.js.map +1 -0
  74. package/dist/rag/in-memory-rag.d.ts +3 -1
  75. package/dist/rag/in-memory-rag.d.ts.map +1 -1
  76. package/dist/rag/in-memory-rag.js +20 -15
  77. package/dist/rag/in-memory-rag.js.map +1 -1
  78. package/dist/rag/index.d.ts +3 -0
  79. package/dist/rag/index.d.ts.map +1 -1
  80. package/dist/rag/index.js +2 -0
  81. package/dist/rag/index.js.map +1 -1
  82. package/dist/rag/mcp-tools/index.d.ts +1 -1
  83. package/dist/rag/mcp-tools/index.d.ts.map +1 -1
  84. package/dist/rag/mcp-tools/index.js.map +1 -1
  85. package/dist/rag/mcp-tools/rag-collection-tools.d.ts +36 -5
  86. package/dist/rag/mcp-tools/rag-collection-tools.d.ts.map +1 -1
  87. package/dist/rag/mcp-tools/rag-collection-tools.js +128 -54
  88. package/dist/rag/mcp-tools/rag-collection-tools.js.map +1 -1
  89. package/dist/rag/providers/base-provider.d.ts +8 -6
  90. package/dist/rag/providers/base-provider.d.ts.map +1 -1
  91. package/dist/rag/providers/base-provider.js +18 -0
  92. package/dist/rag/providers/base-provider.js.map +1 -1
  93. package/dist/rag/providers/in-memory-rag-provider.d.ts +11 -8
  94. package/dist/rag/providers/in-memory-rag-provider.d.ts.map +1 -1
  95. package/dist/rag/providers/in-memory-rag-provider.js +13 -5
  96. package/dist/rag/providers/in-memory-rag-provider.js.map +1 -1
  97. package/dist/rag/providers/vector-rag-provider.d.ts +11 -8
  98. package/dist/rag/providers/vector-rag-provider.d.ts.map +1 -1
  99. package/dist/rag/providers/vector-rag-provider.js +13 -5
  100. package/dist/rag/providers/vector-rag-provider.js.map +1 -1
  101. package/dist/rag/registry/index.d.ts +1 -0
  102. package/dist/rag/registry/index.d.ts.map +1 -1
  103. package/dist/rag/registry/index.js +1 -0
  104. package/dist/rag/registry/index.js.map +1 -1
  105. package/dist/rag/registry/simple-rag-registry.d.ts +90 -15
  106. package/dist/rag/registry/simple-rag-registry.d.ts.map +1 -1
  107. package/dist/rag/registry/simple-rag-registry.js +331 -57
  108. package/dist/rag/registry/simple-rag-registry.js.map +1 -1
  109. package/dist/rag/registry/store-key.d.ts +15 -0
  110. package/dist/rag/registry/store-key.d.ts.map +1 -0
  111. package/dist/rag/registry/store-key.js +25 -0
  112. package/dist/rag/registry/store-key.js.map +1 -0
  113. package/dist/rag/search-strategy.d.ts +9 -0
  114. package/dist/rag/search-strategy.d.ts.map +1 -1
  115. package/dist/rag/search-strategy.js +49 -22
  116. package/dist/rag/search-strategy.js.map +1 -1
  117. package/dist/rag/tokenizer.d.ts +17 -0
  118. package/dist/rag/tokenizer.d.ts.map +1 -0
  119. package/dist/rag/tokenizer.js +38 -0
  120. package/dist/rag/tokenizer.js.map +1 -0
  121. package/dist/rag/vector-rag.d.ts +2 -2
  122. package/dist/rag/vector-rag.d.ts.map +1 -1
  123. package/dist/rag/vector-rag.js +29 -21
  124. package/dist/rag/vector-rag.js.map +1 -1
  125. package/dist/resilience/embedder-resilience.d.ts +2 -2
  126. package/dist/resilience/embedder-resilience.d.ts.map +1 -1
  127. package/dist/resilience/embedder-resilience.js +3 -1
  128. package/dist/resilience/embedder-resilience.js.map +1 -1
  129. package/dist/testing/rag-filter-conformance.d.ts +60 -0
  130. package/dist/testing/rag-filter-conformance.d.ts.map +1 -0
  131. package/dist/testing/rag-filter-conformance.js +379 -0
  132. package/dist/testing/rag-filter-conformance.js.map +1 -0
  133. package/dist/types.d.ts +11 -2
  134. package/dist/types.d.ts.map +1 -1
  135. package/package.json +8 -1
  136. package/dist/interfaces/failure-strategy.d.ts +0 -95
  137. package/dist/interfaces/failure-strategy.d.ts.map +0 -1
  138. package/dist/interfaces/failure-strategy.js +0 -96
  139. package/dist/interfaces/failure-strategy.js.map +0 -1
  140. package/dist/llm/rate-limit.d.ts +0 -165
  141. package/dist/llm/rate-limit.d.ts.map +0 -1
  142. package/dist/llm/rate-limit.js +0 -394
  143. package/dist/llm/rate-limit.js.map +0 -1
  144. package/dist/resilience/status.d.ts +0 -29
  145. package/dist/resilience/status.d.ts.map +0 -1
  146. package/dist/resilience/status.js +0 -51
  147. package/dist/resilience/status.js.map +0 -1
@@ -1,8 +1,57 @@
1
+ import { createHash } from 'node:crypto';
1
2
  import { RagError } from '../../interfaces/types.js';
2
- import { CollectionNotFoundError, ProviderNotFoundError, } from '../corrections/errors.js';
3
+ import { ragOwnerKeys, validateRagAttributes, validateRagOwner, } from '../catalog/validation.js';
4
+ import { AmbiguousCollectionError, CatalogRecordDeleteError, CollectionNotFoundError, DeleteUnsupportedError, DuplicateCollectionError, ProviderNotFoundError, SessionCloseIncompleteError, } from '../corrections/errors.js';
3
5
  import { ImmutableEditStrategy } from '../strategies/edit/immutable.js';
6
+ import { reservedGlobalNameError } from './store-key.js';
7
+ /**
8
+ * The name a provider keeps a collection's data under.
9
+ *
10
+ * The collection name and a digest of its scope, its owner (the session for a
11
+ * session collection, the user for a user one) and the name. The same
12
+ * collection of the same owner always names the same store; another session or
13
+ * user names another one, so none opens a store someone else left. Because the
14
+ * name is deterministic, a second creation of a collection that exists is
15
+ * refused by the provider (RAG_DUPLICATE_COLLECTION when it has a record,
16
+ * RAG_ORPHAN_STORE when only its store is there) — a restart reattaches a
17
+ * collection by hydration (describeCollections, openCollection, adopt), never
18
+ * by creating it again (§6.3). It fits the strictest provider rules: letters,
19
+ * digits and underscores, not starting with a digit, at most 63 characters
20
+ * (PostgreSQL, HANA).
21
+ */
22
+ function storeNameFor(params) {
23
+ const owner = params.scope === 'session'
24
+ ? params.sessionId
25
+ : params.scope === 'user'
26
+ ? params.userId
27
+ : '';
28
+ const digest = createHash('sha256')
29
+ .update(JSON.stringify([params.scope, owner, params.collectionName]))
30
+ .digest('hex')
31
+ .slice(0, 12);
32
+ let base = params.collectionName.replace(/[^a-zA-Z0-9_]/g, '_');
33
+ if (!/^[a-zA-Z_]/.test(base))
34
+ base = `_${base}`;
35
+ return `${base.slice(0, 63 - digest.length - 1)}_${digest}`;
36
+ }
37
+ /** A collection is its scope and its name (§6.4); the owner is the registry's own. */
38
+ function keyOf(scope, name) {
39
+ return JSON.stringify([scope, name]);
40
+ }
41
+ const SCOPES = ['global', 'user', 'session'];
4
42
  export class SimpleRagRegistry {
43
+ /** Keyed by keyOf(scope, name). */
5
44
  entries = new Map();
45
+ /**
46
+ * Keys (scope, name) whose deletion is running. Absent to get, getEditor and
47
+ * list, so nothing reaches the collection; taken for createCollection,
48
+ * register and adopt, which refuse it — a taken name is refused, not queued
49
+ * (§6.3). The reservation is what lets a failed record deletion restore the
50
+ * entry: without it a creation could take the key in between.
51
+ */
52
+ deleting = new Set();
53
+ /** Keys (scope, name) being created, held until inserted or refused. */
54
+ creating = new Set();
6
55
  providerRegistry;
7
56
  mutationListener;
8
57
  setProviderRegistry(providerRegistry) {
@@ -14,44 +63,151 @@ export class SimpleRagRegistry {
14
63
  fireMutation() {
15
64
  this.mutationListener?.();
16
65
  }
66
+ /**
67
+ * The entry `name` addresses: with a scope, that scope's; without one, the
68
+ * entry of the one scope holding it — or AmbiguousCollectionError naming
69
+ * every scope that does. Never a silent precedence between scopes.
70
+ */
71
+ find(name, scope) {
72
+ if (scope) {
73
+ const key = keyOf(scope, name);
74
+ const entry = this.entries.get(key);
75
+ return { ok: true, found: entry ? { key, entry } : undefined };
76
+ }
77
+ const held = SCOPES.filter((s) => this.entries.has(keyOf(s, name)));
78
+ if (held.length > 1) {
79
+ return { ok: false, error: new AmbiguousCollectionError(name, held) };
80
+ }
81
+ if (held.length === 0)
82
+ return { ok: true };
83
+ const key = keyOf(held[0], name);
84
+ const entry = this.entries.get(key);
85
+ return { ok: true, found: { key, entry } };
86
+ }
87
+ findOrThrow(name, scope) {
88
+ const f = this.find(name, scope);
89
+ if (!f.ok)
90
+ throw f.error;
91
+ return f.found;
92
+ }
93
+ /** A key is taken while an entry holds it, or a creation or deletion runs. */
94
+ isTaken(key) {
95
+ return (this.entries.has(key) || this.creating.has(key) || this.deleting.has(key));
96
+ }
97
+ insert(key, entry) {
98
+ this.entries.set(key, entry);
99
+ this.fireMutation();
100
+ }
17
101
  register(name, rag, editor, meta) {
18
- if (this.entries.has(name)) {
19
- throw new Error(`Collection '${name}' is already registered`);
102
+ const scope = meta?.scope ?? 'global';
103
+ const reserved = reservedGlobalNameError(scope, name);
104
+ if (reserved)
105
+ throw reserved;
106
+ const key = keyOf(scope, name);
107
+ if (this.isTaken(key)) {
108
+ throw new DuplicateCollectionError(name, `already registered in scope '${scope}'`);
20
109
  }
21
110
  const editable = Boolean(editor) && !(editor instanceof ImmutableEditStrategy);
22
- this.entries.set(name, {
111
+ this.insert(key, {
23
112
  rag,
24
113
  editor,
114
+ storeName: name,
25
115
  meta: {
26
116
  name,
27
117
  displayName: meta?.displayName ?? name,
28
118
  description: meta?.description,
29
119
  editable,
30
- scope: meta?.scope ?? 'global',
120
+ scope,
31
121
  sessionId: meta?.sessionId,
32
122
  userId: meta?.userId,
33
123
  providerName: meta?.providerName,
34
124
  tags: meta?.tags,
35
125
  },
36
126
  });
127
+ }
128
+ /**
129
+ * Register a collection whose store EXISTS, from its catalog record (§6.3):
130
+ * under its logical name, with the store name the record gives. Creates
131
+ * nothing and asks no provider for anything. See IRagRegistry.adopt.
132
+ */
133
+ adopt(record, rag, editor, providerName) {
134
+ // A record may come from a caller no compiler saw: the one owner rule,
135
+ // and the owner it returns, with only the key its scope selects.
136
+ const owner = validateRagOwner(record);
137
+ if (!owner.ok)
138
+ throw owner.error;
139
+ const reserved = reservedGlobalNameError(owner.value.scope, record.name);
140
+ if (reserved)
141
+ throw reserved;
142
+ const key = keyOf(owner.value.scope, record.name);
143
+ if (this.isTaken(key)) {
144
+ throw new DuplicateCollectionError(record.name, `already registered in scope '${owner.value.scope}'`);
145
+ }
146
+ this.insert(key, {
147
+ rag,
148
+ editor,
149
+ // NOT record.name: the provider knows the store by its own name, and a
150
+ // deletion addressed to the logical name would miss it.
151
+ storeName: record.storeName,
152
+ meta: {
153
+ name: record.name,
154
+ displayName: record.name,
155
+ editable: Boolean(editor) && !(editor instanceof ImmutableEditStrategy),
156
+ scope: owner.value.scope,
157
+ ...ragOwnerKeys(owner.value),
158
+ providerName,
159
+ },
160
+ });
161
+ }
162
+ unregister(name, scope) {
163
+ const found = this.findOrThrow(name, scope);
164
+ if (!found)
165
+ return false;
166
+ this.entries.delete(found.key);
37
167
  this.fireMutation();
168
+ return true;
38
169
  }
39
- unregister(name) {
40
- const existed = this.entries.delete(name);
41
- if (existed)
42
- this.fireMutation();
43
- return existed;
170
+ get(name, scope) {
171
+ return this.findOrThrow(name, scope)?.entry.rag;
44
172
  }
45
- get(name) {
46
- return this.entries.get(name)?.rag;
173
+ getEditor(name, scope) {
174
+ return this.findOrThrow(name, scope)?.entry.editor;
47
175
  }
48
- getEditor(name) {
49
- return this.entries.get(name)?.editor;
176
+ /**
177
+ * Swap the store handle of an existing entry, keeping everything else — its
178
+ * editor, its provider, its store name and its meta — and tell the mutation
179
+ * listener. For a decorator such as the builder's circuit-breaker
180
+ * FallbackRag: re-registering would set the store name to the logical name
181
+ * and drop the provider, so a hydrated collection's delete would miss its
182
+ * store and its catalog record would come back (§6.3). The scope is
183
+ * required, so the lookup is never ambiguous. False when the entry is
184
+ * absent — including one currently reserved by an in-flight deletion (it is
185
+ * gone from `entries` already); never re-inserts.
186
+ */
187
+ replaceRag(name, scope, rag) {
188
+ const found = this.findOrThrow(name, scope);
189
+ if (!found)
190
+ return false;
191
+ found.entry.rag = rag;
192
+ this.fireMutation();
193
+ return true;
50
194
  }
51
195
  list() {
52
196
  return Array.from(this.entries.values()).map((e) => e.meta);
53
197
  }
54
198
  async createCollection(params) {
199
+ // Checked before anything else: an untyped caller's owner without its key
200
+ // would digest to a store every such caller shares (storeNameFor), and
201
+ // attributes JSON would change could not come back as given (§6.3).
202
+ const owner = validateRagOwner(params);
203
+ if (!owner.ok)
204
+ return owner;
205
+ const attributes = validateRagAttributes(params.attributes);
206
+ if (!attributes.ok)
207
+ return attributes;
208
+ const reserved = reservedGlobalNameError(owner.value.scope, params.collectionName);
209
+ if (reserved)
210
+ return { ok: false, error: reserved };
55
211
  if (!this.providerRegistry) {
56
212
  return {
57
213
  ok: false,
@@ -65,77 +221,195 @@ export class SimpleRagRegistry {
65
221
  error: new ProviderNotFoundError(params.providerName),
66
222
  };
67
223
  }
68
- // Preflight duplicate-name check.
69
- if (this.entries.has(params.collectionName)) {
224
+ // Preflight duplicate check, counting creations still running: two at
225
+ // once would share one store.
226
+ const key = keyOf(owner.value.scope, params.collectionName);
227
+ if (this.isTaken(key)) {
70
228
  return {
71
229
  ok: false,
72
- error: new RagError(`Collection '${params.collectionName}' already exists`, 'RAG_DUPLICATE_COLLECTION'),
230
+ error: new DuplicateCollectionError(params.collectionName, `the name is taken in scope '${owner.value.scope}'`),
73
231
  };
74
232
  }
75
- const created = await provider.createCollection(params.collectionName, {
76
- scope: params.scope,
77
- sessionId: params.sessionId,
78
- userId: params.userId,
233
+ this.creating.add(key);
234
+ try {
235
+ return await this.createUnder(provider, key, params, owner.value);
236
+ }
237
+ finally {
238
+ this.creating.delete(key);
239
+ }
240
+ }
241
+ async createUnder(provider, key, params, owner) {
242
+ // A provider that keeps stores by name gets one per owner; see storeNameFor.
243
+ const storeName = storeNameFor({
244
+ collectionName: params.collectionName,
245
+ ...owner,
246
+ });
247
+ // The logical name and the attributes go to the provider, because its
248
+ // catalog cannot return what it was never given (§6.3). Passed unread, and
249
+ // only when given, so `'attributes' in opts` reads the caller's intent.
250
+ const created = await provider.createCollection(storeName, {
251
+ ...owner,
252
+ collectionName: params.collectionName,
253
+ ...(params.attributes !== undefined
254
+ ? { attributes: params.attributes }
255
+ : {}),
256
+ ...(params.adoptExisting ? { adoptExisting: true } : {}),
79
257
  });
80
258
  if (!created.ok)
81
259
  return created;
82
- try {
83
- this.register(params.collectionName, created.value.rag, created.value.editor, {
260
+ // Inserted directly: the key has been held in `creating` since the
261
+ // preflight, so nothing can have taken it, and there is nothing to roll
262
+ // back — a rollback would delete a store whose catalog record the provider
263
+ // has just committed (§6.3).
264
+ const editor = created.value.editor;
265
+ const entry = {
266
+ rag: created.value.rag,
267
+ editor,
268
+ storeName,
269
+ meta: {
270
+ name: params.collectionName,
84
271
  displayName: params.displayName ?? params.collectionName,
85
272
  description: params.description,
86
- scope: params.scope,
87
- sessionId: params.sessionId,
88
- userId: params.userId,
273
+ editable: Boolean(editor) && !(editor instanceof ImmutableEditStrategy),
274
+ scope: owner.scope,
275
+ ...ragOwnerKeys(owner),
89
276
  providerName: params.providerName,
90
277
  tags: params.tags,
91
- });
278
+ },
279
+ };
280
+ this.insert(key, entry);
281
+ return { ok: true, value: entry.meta };
282
+ }
283
+ /**
284
+ * Delete a collection.
285
+ *
286
+ * It is unregistered first and its key reserved, so nothing reaches it and
287
+ * nothing takes its name while it is being deleted. Then its data goes: a
288
+ * collection a provider created is deleted by that provider's
289
+ * `deleteCollection` (which cannot throw — see deleteData) — which removes
290
+ * its catalog record before its data — or, where the provider has none,
291
+ * emptied through its store's `writer().clearAll()`. A collection
292
+ * registered without a provider is only unregistered. Nothing is retried.
293
+ *
294
+ * On CatalogRecordDeleteError nothing was deleted: record and data are both
295
+ * intact, so the same entry is registered again before the reservation ends,
296
+ * and the same call can be retried in place. Any other failure comes back as
297
+ * the error with the collection unregistered; its data may remain under a
298
+ * store name no other session or user is given (see storeNameFor).
299
+ *
300
+ * The reservation is released — and the entry restored first, if this was a
301
+ * CatalogRecordDeleteError — on every path, including a throwing
302
+ * `mutationListener`: that listener is consumer-injected and its own
303
+ * exception must never pin the key in `deleting` forever, nor skip the
304
+ * restore. Once state is settled, a listener exception is rethrown (so the
305
+ * caller sees it — never silently dropped); the delete's own Result is
306
+ * returned only when notifying succeeded.
307
+ */
308
+ async deleteCollection(name, scope) {
309
+ const f = this.find(name, scope);
310
+ if (!f.ok)
311
+ return { ok: false, error: f.error };
312
+ if (!f.found) {
313
+ return { ok: false, error: new CollectionNotFoundError(name) };
314
+ }
315
+ const { key, entry } = f.found;
316
+ this.entries.delete(key);
317
+ this.deleting.add(key);
318
+ let notifyFailed = false;
319
+ let notifyError;
320
+ try {
321
+ this.fireMutation();
92
322
  }
93
323
  catch (err) {
94
- // Defense-in-depth rollback: the preflight check should prevent this,
95
- // but if register throws anyway (subclass or race), roll the backend back.
324
+ notifyFailed = true;
325
+ notifyError = err;
326
+ }
327
+ // deleteData never throws (its own try/catch turns everything, including
328
+ // an injected provider registry throwing, into a Result), so this await
329
+ // cannot reject.
330
+ const result = await this.deleteData(name, entry);
331
+ const restoring = !result.ok && result.error instanceof CatalogRecordDeleteError;
332
+ try {
333
+ if (restoring) {
334
+ // Restored while the key is still reserved, so nothing slips in
335
+ // between.
336
+ this.entries.set(key, entry);
337
+ }
338
+ }
339
+ finally {
340
+ // Released on every path — success, any other failure, or a restore —
341
+ // whatever the mutation listener above did.
342
+ this.deleting.delete(key);
343
+ }
344
+ if (restoring) {
345
+ try {
346
+ this.fireMutation();
347
+ }
348
+ catch (err) {
349
+ if (!notifyFailed) {
350
+ notifyFailed = true;
351
+ notifyError = err;
352
+ }
353
+ }
354
+ }
355
+ if (notifyFailed)
356
+ throw notifyError;
357
+ return result;
358
+ }
359
+ async deleteData(name, entry) {
360
+ const providerName = entry.meta.providerName;
361
+ if (!providerName)
362
+ return { ok: true, value: undefined };
363
+ try {
364
+ // getProvider is an injected registry's call, not ours — it belongs
365
+ // inside this try along with everything else that can throw.
366
+ const provider = this.providerRegistry?.getProvider(providerName);
367
+ if (!provider) {
368
+ return {
369
+ ok: false,
370
+ error: new DeleteUnsupportedError(name, `provider '${providerName}' is not registered`),
371
+ };
372
+ }
96
373
  if (provider.deleteCollection) {
97
- await provider.deleteCollection(params.collectionName).catch(() => { });
374
+ return await provider.deleteCollection(entry.storeName);
98
375
  }
376
+ const writer = entry.rag.writer?.();
377
+ if (writer?.clearAll)
378
+ return await writer.clearAll();
379
+ }
380
+ catch (err) {
99
381
  return {
100
382
  ok: false,
101
383
  error: err instanceof RagError
102
384
  ? err
103
- : new RagError(String(err), 'RAG_REGISTER_FAILED'),
104
- };
105
- }
106
- const registered = this.entries.get(params.collectionName);
107
- if (!registered) {
108
- return {
109
- ok: false,
110
- error: new RagError(`Collection '${params.collectionName}' vanished after registration`, 'RAG_REGISTER_FAILED'),
385
+ : new RagError(`Deleting the data of collection '${name}' failed: ${err instanceof Error ? err.message : String(err)}`, 'RAG_DELETE_ERROR'),
111
386
  };
112
387
  }
113
- return { ok: true, value: registered.meta };
114
- }
115
- async deleteCollection(name) {
116
- const entry = this.entries.get(name);
117
- if (!entry) {
118
- return { ok: false, error: new CollectionNotFoundError(name) };
119
- }
120
- if (entry.meta.providerName && this.providerRegistry) {
121
- const provider = this.providerRegistry.getProvider(entry.meta.providerName);
122
- if (provider?.deleteCollection) {
123
- const res = await provider.deleteCollection(name);
124
- if (!res.ok)
125
- return res;
126
- }
127
- }
128
- this.unregister(name);
129
- return { ok: true, value: undefined };
388
+ return {
389
+ ok: false,
390
+ error: new DeleteUnsupportedError(name, `provider '${providerName}' has no deleteCollection, and its store no writer().clearAll()`),
391
+ };
130
392
  }
393
+ /**
394
+ * Delete every session-scoped collection of this session. Goes through all of
395
+ * them even when one fails — each is unregistered regardless (see
396
+ * deleteCollection) — and returns the failures together.
397
+ */
131
398
  async closeSession(sessionId) {
132
399
  const victims = Array.from(this.entries.values())
133
400
  .filter((e) => e.meta.scope === 'session' && e.meta.sessionId === sessionId)
134
401
  .map((e) => e.meta.name);
402
+ const failures = [];
135
403
  for (const name of victims) {
136
- const res = await this.deleteCollection(name);
404
+ const res = await this.deleteCollection(name, 'session');
137
405
  if (!res.ok)
138
- return res;
406
+ failures.push({ name, error: res.error });
407
+ }
408
+ if (failures.length > 0) {
409
+ return {
410
+ ok: false,
411
+ error: new SessionCloseIncompleteError(sessionId, failures),
412
+ };
139
413
  }
140
414
  return { ok: true, value: undefined };
141
415
  }
@@ -1 +1 @@
1
- {"version":3,"file":"simple-r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RagCollectionScope } from '../../interfaces/rag.js';
2
+ import { ReservedCollectionNameError } from '../corrections/errors.js';
3
+ /** The refusal for a global named into a reserved prefix, or undefined. */
4
+ export declare function reservedGlobalNameError(scope: RagCollectionScope, name: string): ReservedCollectionNameError | undefined;
5
+ /**
6
+ * The key a collection has in the `ragStores` projection: a global keeps its
7
+ * bare name, so every stage configuration naming one keeps working; a user or
8
+ * session collection is `user/<name>` or `session/<name>`. An absent scope is
9
+ * global, as `register` defaults it.
10
+ */
11
+ export declare function ragStoreKey(meta: {
12
+ readonly name: string;
13
+ readonly scope?: RagCollectionScope;
14
+ }): string;
15
+ //# sourceMappingURL=store-key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-key.d.ts","sourceRoot":"","sources":["../../../src/rag/registry/store-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AASvE,2EAA2E;AAC3E,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,kBAAkB,EACzB,IAAI,EAAE,MAAM,GACX,2BAA2B,GAAG,SAAS,CAIzC;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC;CACrC,GAAG,MAAM,CAGT"}
@@ -0,0 +1,25 @@
1
+ import { ReservedCollectionNameError } from '../corrections/errors.js';
2
+ /**
3
+ * The prefixes the `ragStores` projection gives the two owned scopes (§6.4). A
4
+ * global may not begin with one: it would take a key the projection gives
5
+ * another scope, and one entry would silently overwrite the other.
6
+ */
7
+ const RESERVED_GLOBAL_PREFIXES = ['user/', 'session/'];
8
+ /** The refusal for a global named into a reserved prefix, or undefined. */
9
+ export function reservedGlobalNameError(scope, name) {
10
+ if (scope !== 'global')
11
+ return undefined;
12
+ const prefix = RESERVED_GLOBAL_PREFIXES.find((p) => name.startsWith(p));
13
+ return prefix ? new ReservedCollectionNameError(name, prefix) : undefined;
14
+ }
15
+ /**
16
+ * The key a collection has in the `ragStores` projection: a global keeps its
17
+ * bare name, so every stage configuration naming one keeps working; a user or
18
+ * session collection is `user/<name>` or `session/<name>`. An absent scope is
19
+ * global, as `register` defaults it.
20
+ */
21
+ export function ragStoreKey(meta) {
22
+ const scope = meta.scope ?? 'global';
23
+ return scope === 'global' ? meta.name : `${scope}/${meta.name}`;
24
+ }
25
+ //# sourceMappingURL=store-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-key.js","sourceRoot":"","sources":["../../../src/rag/registry/store-key.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEvE;;;;GAIG;AACH,MAAM,wBAAwB,GAAG,CAAC,OAAO,EAAE,UAAU,CAAU,CAAC;AAEhE,2EAA2E;AAC3E,MAAM,UAAU,uBAAuB,CACrC,KAAyB,EACzB,IAAY;IAEZ,IAAI,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,MAAM,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,2BAA2B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAG3B;IACC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC;IACrC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;AAClE,CAAC"}
@@ -15,6 +15,15 @@ export interface IScoredResult {
15
15
  score: number;
16
16
  }
17
17
  export interface ISearchContext {
18
+ /**
19
+ * Term statistics over THIS query's candidates only — the records that
20
+ * passed the store's namespace / TTL / session / user filters — never over
21
+ * the whole store: store-wide statistics make one session's ranking depend
22
+ * on (and leak a signal about) another session's records. The built-in
23
+ * strategies do not read it; they compute the same statistics from the
24
+ * `candidates` they are given, so they are scoped whatever a caller passes.
25
+ * Kept for custom strategies.
26
+ */
18
27
  index: InvertedIndex;
19
28
  tokenize: (s: string) => string[];
20
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"search-strategy.d.ts","sourceRoot":"","sources":["../../src/rag/search-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,WAAW,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,KAAK,CACH,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,gBAAgB,EAAE,EAC9B,OAAO,EAAE,cAAc,GACtB,aAAa,EAAE,CAAC;CACpB;AA8CD,qBAAa,s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