@objectstack/knowledge-ragflow 16.1.0 → 17.0.0-rc.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/CHANGELOG.md +338 -0
- package/package.json +9 -4
- package/.turbo/turbo-build.log +0 -22
- package/src/__tests__/ragflow-adapter.test.ts +0 -160
- package/src/index.ts +0 -307
- package/tsconfig.json +0 -20
- package/vitest.config.ts +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,343 @@
|
|
|
1
1
|
# @objectstack/knowledge-ragflow
|
|
2
2
|
|
|
3
|
+
## 17.0.0-rc.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2e836de: chore(packaging): CHANGELOG.md ships in every npm tarball (#4261)
|
|
8
|
+
|
|
9
|
+
The AGENTS.md post-task checklist requires breaking changesets to carry their
|
|
10
|
+
FROM → TO migration because "this text ships to consumers as `CHANGELOG.md`
|
|
11
|
+
inside the npm package and is what an upgrading agent greps after the tombstone
|
|
12
|
+
error." That delivery path was severed for 68 of the 69 publishable packages:
|
|
13
|
+
npm packs `package.json` / `README*` / `LICENSE*` unconditionally but — unlike
|
|
14
|
+
older npm versions — not `CHANGELOG.md`, and the canonical
|
|
15
|
+
`"files": ["dist", "README.md"]` whitelist never named it. Measured on npm
|
|
16
|
+
10.9.7: `npm pack --dry-run` on `@objectstack/types` shipped 3 files while its
|
|
17
|
+
70KB `CHANGELOG.md` stayed behind. Only `@objectstack/spec` listed it
|
|
18
|
+
explicitly.
|
|
19
|
+
|
|
20
|
+
The tombstone-error scenario is precisely the one where the repo is out of
|
|
21
|
+
reach — the upgrading agent has `node_modules` and nothing else — so the
|
|
22
|
+
migration text has to ride in the tarball. Every publishable package now
|
|
23
|
+
declares `CHANGELOG.md` in `files`, and the canonical whitelist is
|
|
24
|
+
`["dist", "README.md", "CHANGELOG.md"]`.
|
|
25
|
+
|
|
26
|
+
The other half is the gate: `check:published-files` gains a fifth invariant,
|
|
27
|
+
COMPLETE — a whitelist that fails to cover `CHANGELOG.md` fails the
|
|
28
|
+
always-required lint job, so the next package cannot silently sever the path
|
|
29
|
+
again. `@objectstack/spec`'s per-package EXTRA_ENTRIES exemption dissolves
|
|
30
|
+
into the canonical set.
|
|
31
|
+
|
|
32
|
+
Consumer-visible change: one more file per install (the package's changelog,
|
|
33
|
+
e.g. 70.8KB for `@objectstack/types`), and `grep -r "removed key"
|
|
34
|
+
node_modules/@objectstack/*/CHANGELOG.md` now finds the migration it was
|
|
35
|
+
promised.
|
|
36
|
+
|
|
37
|
+
- cc2de0e: chore(packaging): 20 packages stop publishing their sources, tests and build tooling (#4248)
|
|
38
|
+
|
|
39
|
+
These 20 packages declared no `files` field, so npm fell back to packing the
|
|
40
|
+
whole package directory. `npm pack --dry-run` on `@objectstack/plugin-webhooks`
|
|
41
|
+
listed **21 files** — 15 under `src/`, three of them unit tests
|
|
42
|
+
(`auto-enqueuer.test.ts`, `bootstrap-declared-webhooks.test.ts`, …), plus the
|
|
43
|
+
build-time `scripts/i18n-extract.config.ts`. `dist/` lands on top of that at
|
|
44
|
+
publish time rather than instead of it, so consumers were installing the
|
|
45
|
+
TypeScript sources and the test suite alongside the artifact they asked for.
|
|
46
|
+
|
|
47
|
+
Each now declares `"files": ["dist", "README.md"]`, matching the 29 packages
|
|
48
|
+
that already did. Nothing a consumer imports moves: every `main` / `types` /
|
|
49
|
+
`exports` target in all 20 already resolved inside `dist/`, which the new
|
|
50
|
+
`check:published-files` guard verifies rather than assumes. The visible change
|
|
51
|
+
is a smaller install and a smaller dependency-scanning surface — `npm pack` on
|
|
52
|
+
`@objectstack/plugin-webhooks` now yields 2 files plus `dist/`.
|
|
53
|
+
|
|
54
|
+
The other half of the fix is the gate. Half the packages declaring `files` and
|
|
55
|
+
half not was the #3786 shape — a hand-copied convention with nothing enforcing
|
|
56
|
+
it, where whoever forgets the line gets no signal at all. `check:published-files`
|
|
57
|
+
(new, wired into the always-required `lint` job) holds every non-private
|
|
58
|
+
workspace package to four invariants: `files` is **declared**; it is
|
|
59
|
+
**sufficient** (covers every entry point, so tightening a whitelist cannot ship
|
|
60
|
+
a package that fails to resolve); it is **minimal** (admits no test, test-harness
|
|
61
|
+
config or build script); and anything beyond `dist` + `README.md` is
|
|
62
|
+
**registered** with a reason, reconciled in both directions so a stale exemption
|
|
63
|
+
is an error rather than dead text. `@objectstack/spec` is the one package with
|
|
64
|
+
registered extras — its `.zod.ts` sources, JSON Schemas, liveness ledgers and
|
|
65
|
+
`CHANGELOG.md` are product, not build input.
|
|
66
|
+
|
|
67
|
+
This also closes an assumption #4206 was resting on. Excluding `<pkg>/scripts/**`
|
|
68
|
+
from the docs-drift implementation test is sound only while no package publishes
|
|
69
|
+
`scripts/` as runtime code; that held, but it held because someone read all three
|
|
70
|
+
offenders by hand. It is now checked on every PR.
|
|
71
|
+
|
|
72
|
+
- Updated dependencies [6a67d7a]
|
|
73
|
+
- Updated dependencies [0ecc656]
|
|
74
|
+
- Updated dependencies [06772eb]
|
|
75
|
+
- Updated dependencies [270650f]
|
|
76
|
+
- Updated dependencies [3aef718]
|
|
77
|
+
- Updated dependencies [1ea6bce]
|
|
78
|
+
- Updated dependencies [c1dcacd]
|
|
79
|
+
- Updated dependencies [ad303ed]
|
|
80
|
+
- Updated dependencies [32ccb23]
|
|
81
|
+
- Updated dependencies [f5a4ef0]
|
|
82
|
+
- Updated dependencies [2d3e255]
|
|
83
|
+
- Updated dependencies [7d7521f]
|
|
84
|
+
- Updated dependencies [5dc4d02]
|
|
85
|
+
- Updated dependencies [05154a1]
|
|
86
|
+
- Updated dependencies [9b6fe7c]
|
|
87
|
+
- Updated dependencies [8c711fb]
|
|
88
|
+
- Updated dependencies [09e4547]
|
|
89
|
+
- Updated dependencies [91f4c78]
|
|
90
|
+
- Updated dependencies [820eff9]
|
|
91
|
+
- Updated dependencies [8d895ff]
|
|
92
|
+
- Updated dependencies [f6472d7]
|
|
93
|
+
- Updated dependencies [78caf51]
|
|
94
|
+
- Updated dependencies [62a789b]
|
|
95
|
+
- Updated dependencies [789ad63]
|
|
96
|
+
- Updated dependencies [2af1988]
|
|
97
|
+
- Updated dependencies [0af50a3]
|
|
98
|
+
- Updated dependencies [2e836de]
|
|
99
|
+
- Updated dependencies [12a19a8]
|
|
100
|
+
- Updated dependencies [41dcda3]
|
|
101
|
+
- Updated dependencies [c8124e5]
|
|
102
|
+
- Updated dependencies [a1a4140]
|
|
103
|
+
- Updated dependencies [217e2e6]
|
|
104
|
+
- Updated dependencies [86a71d1]
|
|
105
|
+
- Updated dependencies [d5c75e2]
|
|
106
|
+
- Updated dependencies [03d26f7]
|
|
107
|
+
- Updated dependencies [4384921]
|
|
108
|
+
- Updated dependencies [3c628ce]
|
|
109
|
+
- Updated dependencies [7cb922e]
|
|
110
|
+
- Updated dependencies [1d22114]
|
|
111
|
+
- Updated dependencies [b5f9397]
|
|
112
|
+
- Updated dependencies [ed77493]
|
|
113
|
+
- Updated dependencies [58a03d2]
|
|
114
|
+
- Updated dependencies [dc530b4]
|
|
115
|
+
- Updated dependencies [e59786e]
|
|
116
|
+
- Updated dependencies [bcf1112]
|
|
117
|
+
- Updated dependencies [9774b78]
|
|
118
|
+
- Updated dependencies [b07d829]
|
|
119
|
+
- Updated dependencies [a648e96]
|
|
120
|
+
- Updated dependencies [a47ac06]
|
|
121
|
+
- Updated dependencies [e4c61a7]
|
|
122
|
+
- Updated dependencies [cc60165]
|
|
123
|
+
- Updated dependencies [081aa6f]
|
|
124
|
+
- Updated dependencies [91f4c78]
|
|
125
|
+
- Updated dependencies [e8d0c21]
|
|
126
|
+
- Updated dependencies [45dc446]
|
|
127
|
+
- Updated dependencies [c1d44f7]
|
|
128
|
+
- Updated dependencies [ab9fb5c]
|
|
129
|
+
- Updated dependencies [f985b3f]
|
|
130
|
+
- Updated dependencies [9a4932a]
|
|
131
|
+
- Updated dependencies [f9fc874]
|
|
132
|
+
- Updated dependencies [011b386]
|
|
133
|
+
- Updated dependencies [7777e8f]
|
|
134
|
+
- Updated dependencies [507b92a]
|
|
135
|
+
- Updated dependencies [7309c81]
|
|
136
|
+
- Updated dependencies [20bc1ec]
|
|
137
|
+
- Updated dependencies [90c2b15]
|
|
138
|
+
- Updated dependencies [42eeb7d]
|
|
139
|
+
- Updated dependencies [01e124d]
|
|
140
|
+
- Updated dependencies [7ce02eb]
|
|
141
|
+
- Updated dependencies [a13827e]
|
|
142
|
+
- Updated dependencies [7733604]
|
|
143
|
+
- Updated dependencies [40e420f]
|
|
144
|
+
- Updated dependencies [d13004a]
|
|
145
|
+
- Updated dependencies [be7360c]
|
|
146
|
+
- Updated dependencies [5b47ab5]
|
|
147
|
+
- Updated dependencies [b09d8d9]
|
|
148
|
+
- Updated dependencies [b09d8d9]
|
|
149
|
+
- Updated dependencies [8675db6]
|
|
150
|
+
- Updated dependencies [b09d8d9]
|
|
151
|
+
- Updated dependencies [3eb1b2b]
|
|
152
|
+
- Updated dependencies [59b85c0]
|
|
153
|
+
- Updated dependencies [6e357ed]
|
|
154
|
+
- Updated dependencies [d6938bf]
|
|
155
|
+
- Updated dependencies [31e0be9]
|
|
156
|
+
- Updated dependencies [4bfd455]
|
|
157
|
+
- Updated dependencies [ffd2ce2]
|
|
158
|
+
- Updated dependencies [62f8017]
|
|
159
|
+
- Updated dependencies [a831df1]
|
|
160
|
+
- Updated dependencies [f752ee3]
|
|
161
|
+
- Updated dependencies [a1b61e0]
|
|
162
|
+
- Updated dependencies [cd6b9f2]
|
|
163
|
+
- Updated dependencies [2cb6d3c]
|
|
164
|
+
- Updated dependencies [af2a095]
|
|
165
|
+
- Updated dependencies [ec796d5]
|
|
166
|
+
- Updated dependencies [e87fea1]
|
|
167
|
+
- Updated dependencies [c65e529]
|
|
168
|
+
- Updated dependencies [3ca34c1]
|
|
169
|
+
- Updated dependencies [239c3a3]
|
|
170
|
+
- Updated dependencies [94a0bbc]
|
|
171
|
+
- Updated dependencies [d6bfb3d]
|
|
172
|
+
- Updated dependencies [a2266a6]
|
|
173
|
+
- Updated dependencies [d25a0ec]
|
|
174
|
+
- Updated dependencies [667b83e]
|
|
175
|
+
- Updated dependencies [627b188]
|
|
176
|
+
- Updated dependencies [8d4eae7]
|
|
177
|
+
- Updated dependencies [857a6cf]
|
|
178
|
+
- Updated dependencies [65a3a84]
|
|
179
|
+
- Updated dependencies [ccd9397]
|
|
180
|
+
- Updated dependencies [bca935b]
|
|
181
|
+
- Updated dependencies [d92c72d]
|
|
182
|
+
- Updated dependencies [c54c822]
|
|
183
|
+
- Updated dependencies [8dcc0f5]
|
|
184
|
+
- Updated dependencies [75b9e51]
|
|
185
|
+
- Updated dependencies [0a2f233]
|
|
186
|
+
- Updated dependencies [8621cdd]
|
|
187
|
+
- Updated dependencies [6f23667]
|
|
188
|
+
- Updated dependencies [5d21a48]
|
|
189
|
+
- Updated dependencies [19365b7]
|
|
190
|
+
- Updated dependencies [b7ed26d]
|
|
191
|
+
- Updated dependencies [b3a3d83]
|
|
192
|
+
- Updated dependencies [7a55913]
|
|
193
|
+
- Updated dependencies [35accbf]
|
|
194
|
+
- Updated dependencies [6038de7]
|
|
195
|
+
- Updated dependencies [eb95d97]
|
|
196
|
+
- Updated dependencies [e4c2dc8]
|
|
197
|
+
- Updated dependencies [1bd2795]
|
|
198
|
+
- Updated dependencies [8186a70]
|
|
199
|
+
- Updated dependencies [a329cca]
|
|
200
|
+
- Updated dependencies [6eec18c]
|
|
201
|
+
- Updated dependencies [4d7bebf]
|
|
202
|
+
- Updated dependencies [821ac7a]
|
|
203
|
+
- Updated dependencies [8f81731]
|
|
204
|
+
- Updated dependencies [8b50cb3]
|
|
205
|
+
- Updated dependencies [8c2db68]
|
|
206
|
+
- Updated dependencies [22b5e54]
|
|
207
|
+
- Updated dependencies [0166bd5]
|
|
208
|
+
- Updated dependencies [9b702dc]
|
|
209
|
+
- Updated dependencies [ab16331]
|
|
210
|
+
- @objectstack/spec@17.0.0-rc.1
|
|
211
|
+
- @objectstack/core@17.0.0-rc.1
|
|
212
|
+
- @objectstack/service-knowledge@17.0.0-rc.1
|
|
213
|
+
|
|
214
|
+
## 17.0.0-rc.0
|
|
215
|
+
|
|
216
|
+
### Patch Changes
|
|
217
|
+
|
|
218
|
+
- Updated dependencies [50616d9]
|
|
219
|
+
- Updated dependencies [08b5a3d]
|
|
220
|
+
- Updated dependencies [d99aeb3]
|
|
221
|
+
- Updated dependencies [4727eb8]
|
|
222
|
+
- Updated dependencies [f63cd09]
|
|
223
|
+
- Updated dependencies [fa3d0cf]
|
|
224
|
+
- Updated dependencies [af5a224]
|
|
225
|
+
- Updated dependencies [71f76e1]
|
|
226
|
+
- Updated dependencies [37b1346]
|
|
227
|
+
- Updated dependencies [99736a0]
|
|
228
|
+
- Updated dependencies [fe67e34]
|
|
229
|
+
- Updated dependencies [fdb4f50]
|
|
230
|
+
- Updated dependencies [1bd5652]
|
|
231
|
+
- Updated dependencies [14252d3]
|
|
232
|
+
- Updated dependencies [7fb436c]
|
|
233
|
+
- Updated dependencies [879ea13]
|
|
234
|
+
- Updated dependencies [201b31f]
|
|
235
|
+
- Updated dependencies [e2616e0]
|
|
236
|
+
- Updated dependencies [6fdc5c6]
|
|
237
|
+
- Updated dependencies [8b9d71e]
|
|
238
|
+
- Updated dependencies [33f5e23]
|
|
239
|
+
- Updated dependencies [259af21]
|
|
240
|
+
- Updated dependencies [587fc91]
|
|
241
|
+
- Updated dependencies [1986594]
|
|
242
|
+
- Updated dependencies [ad4af62]
|
|
243
|
+
- Updated dependencies [d44dbfa]
|
|
244
|
+
- Updated dependencies [474fe39]
|
|
245
|
+
- Updated dependencies [0bc685a]
|
|
246
|
+
- Updated dependencies [b949059]
|
|
247
|
+
- Updated dependencies [be1c52c]
|
|
248
|
+
- Updated dependencies [c5ff96d]
|
|
249
|
+
- Updated dependencies [84e7be9]
|
|
250
|
+
- Updated dependencies [a6c3f38]
|
|
251
|
+
- Updated dependencies [debc23a]
|
|
252
|
+
- Updated dependencies [0f8ad09]
|
|
253
|
+
- Updated dependencies [8f9689f]
|
|
254
|
+
- Updated dependencies [57a3bb3]
|
|
255
|
+
- Updated dependencies [5f9a987]
|
|
256
|
+
- Updated dependencies [db02d47]
|
|
257
|
+
- Updated dependencies [0bfdf46]
|
|
258
|
+
- Updated dependencies [376a061]
|
|
259
|
+
- Updated dependencies [7c7e246]
|
|
260
|
+
- Updated dependencies [f35cdc5]
|
|
261
|
+
- Updated dependencies [9ea2bc5]
|
|
262
|
+
- Updated dependencies [c2d9098]
|
|
263
|
+
- Updated dependencies [a227ed7]
|
|
264
|
+
- Updated dependencies [9613396]
|
|
265
|
+
- Updated dependencies [e47b342]
|
|
266
|
+
- Updated dependencies [4ed7ed4]
|
|
267
|
+
- Updated dependencies [2fa4ca1]
|
|
268
|
+
- Updated dependencies [f5a2320]
|
|
269
|
+
- Updated dependencies [deb538f]
|
|
270
|
+
- Updated dependencies [5b89711]
|
|
271
|
+
- Updated dependencies [0c8a22f]
|
|
272
|
+
- Updated dependencies [763931e]
|
|
273
|
+
- Updated dependencies [de9af8a]
|
|
274
|
+
- Updated dependencies [c4df271]
|
|
275
|
+
- Updated dependencies [a41ba5c]
|
|
276
|
+
- Updated dependencies [189854c]
|
|
277
|
+
- Updated dependencies [0e3a226]
|
|
278
|
+
- Updated dependencies [1d4756e]
|
|
279
|
+
- Updated dependencies [720c5ad]
|
|
280
|
+
- Updated dependencies [a8d1e24]
|
|
281
|
+
- Updated dependencies [41642b0]
|
|
282
|
+
- Updated dependencies [4cca74c]
|
|
283
|
+
- Updated dependencies [88ef03e]
|
|
284
|
+
- Updated dependencies [9e2caf3]
|
|
285
|
+
- Updated dependencies [81ce41a]
|
|
286
|
+
- Updated dependencies [85e1e4e]
|
|
287
|
+
- Updated dependencies [dac6a08]
|
|
288
|
+
- Updated dependencies [394b7a1]
|
|
289
|
+
- Updated dependencies [677b591]
|
|
290
|
+
- Updated dependencies [d77d1b7]
|
|
291
|
+
- Updated dependencies [5b79a34]
|
|
292
|
+
- Updated dependencies [c757854]
|
|
293
|
+
- Updated dependencies [0045682]
|
|
294
|
+
- Updated dependencies [2a5f04a]
|
|
295
|
+
- Updated dependencies [4f740b0]
|
|
296
|
+
- Updated dependencies [67452d1]
|
|
297
|
+
- Updated dependencies [0fc6219]
|
|
298
|
+
- Updated dependencies [605e190]
|
|
299
|
+
- Updated dependencies [c6c59f1]
|
|
300
|
+
- Updated dependencies [b0e78a8]
|
|
301
|
+
- Updated dependencies [f31cc8d]
|
|
302
|
+
- Updated dependencies [f343dc4]
|
|
303
|
+
- Updated dependencies [8269e32]
|
|
304
|
+
- Updated dependencies [74f7339]
|
|
305
|
+
- Updated dependencies [a6c35a2]
|
|
306
|
+
- Updated dependencies [c2f1002]
|
|
307
|
+
- Updated dependencies [f163028]
|
|
308
|
+
- Updated dependencies [f07808c]
|
|
309
|
+
- Updated dependencies [7ffc3d3]
|
|
310
|
+
- Updated dependencies [88346ba]
|
|
311
|
+
- Updated dependencies [4631592]
|
|
312
|
+
- Updated dependencies [32ff033]
|
|
313
|
+
- Updated dependencies [5ac93d4]
|
|
314
|
+
- Updated dependencies [93f267f]
|
|
315
|
+
- Updated dependencies [0024abf]
|
|
316
|
+
- Updated dependencies [acbf364]
|
|
317
|
+
- Updated dependencies [7687f7b]
|
|
318
|
+
- Updated dependencies [1659072]
|
|
319
|
+
- Updated dependencies [abceb0d]
|
|
320
|
+
- Updated dependencies [0c302a7]
|
|
321
|
+
- Updated dependencies [6633337]
|
|
322
|
+
- Updated dependencies [f00d8d4]
|
|
323
|
+
- Updated dependencies [503be86]
|
|
324
|
+
- Updated dependencies [cde1975]
|
|
325
|
+
- Updated dependencies [0bc685a]
|
|
326
|
+
- Updated dependencies [11949fc]
|
|
327
|
+
- Updated dependencies [b098b0e]
|
|
328
|
+
- Updated dependencies [4d00b13]
|
|
329
|
+
- Updated dependencies [57bab76]
|
|
330
|
+
- Updated dependencies [b90086a]
|
|
331
|
+
- Updated dependencies [b95577a]
|
|
332
|
+
- Updated dependencies [83c161f]
|
|
333
|
+
- Updated dependencies [d8c4957]
|
|
334
|
+
- Updated dependencies [f24cb83]
|
|
335
|
+
- Updated dependencies [5dbbb92]
|
|
336
|
+
- Updated dependencies [69f1dfd]
|
|
337
|
+
- @objectstack/spec@17.0.0-rc.0
|
|
338
|
+
- @objectstack/core@17.0.0-rc.0
|
|
339
|
+
- @objectstack/service-knowledge@17.0.0-rc.0
|
|
340
|
+
|
|
3
341
|
## 16.1.0
|
|
4
342
|
|
|
5
343
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/knowledge-ragflow",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0-rc.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "RAGFlow knowledge adapter for ObjectStack — production-grade RAG via the Apache 2.0 RAGFlow REST API.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@objectstack/core": "
|
|
17
|
-
"@objectstack/service-knowledge": "
|
|
18
|
-
"@objectstack/spec": "
|
|
16
|
+
"@objectstack/core": "17.0.0-rc.1",
|
|
17
|
+
"@objectstack/service-knowledge": "17.0.0-rc.1",
|
|
18
|
+
"@objectstack/spec": "17.0.0-rc.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^26.1.1",
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"rag",
|
|
29
29
|
"ragflow"
|
|
30
30
|
],
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md",
|
|
34
|
+
"CHANGELOG.md"
|
|
35
|
+
],
|
|
31
36
|
"scripts": {
|
|
32
37
|
"build": "tsup --config ../../../tsup.config.ts",
|
|
33
38
|
"dev": "tsc -w",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @objectstack/knowledge-ragflow@16.1.0 build /home/runner/work/objectstack/objectstack/packages/plugins/knowledge-ragflow
|
|
3
|
-
> tsup --config ../../../tsup.config.ts
|
|
4
|
-
|
|
5
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.5.1
|
|
8
|
-
[34mCLI[39m Using tsup config: /home/runner/work/objectstack/objectstack/tsup.config.ts
|
|
9
|
-
[34mCLI[39m Target: es2020
|
|
10
|
-
[34mCLI[39m Cleaning output folder
|
|
11
|
-
[34mESM[39m Build start
|
|
12
|
-
[34mCJS[39m Build start
|
|
13
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m6.41 KB[39m
|
|
14
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[32m15.10 KB[39m
|
|
15
|
-
[32mESM[39m ⚡️ Build success in 109ms
|
|
16
|
-
[32mCJS[39m [1mdist/index.js [22m[32m7.49 KB[39m
|
|
17
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m15.14 KB[39m
|
|
18
|
-
[32mCJS[39m ⚡️ Build success in 109ms
|
|
19
|
-
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in 13700ms
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m2.39 KB[39m
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m2.39 KB[39m
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
import { describe, it, expect } from 'vitest';
|
|
4
|
-
import { KnowledgeRagflowAdapter, type FetchLike } from '../index';
|
|
5
|
-
import type { KnowledgeSource, KnowledgeDocument } from '@objectstack/spec/ai';
|
|
6
|
-
|
|
7
|
-
const source: KnowledgeSource = {
|
|
8
|
-
id: 'docs',
|
|
9
|
-
label: 'Docs',
|
|
10
|
-
adapter: 'ragflow',
|
|
11
|
-
source: { kind: 'http', urls: ['https://docs.example.com'] } as KnowledgeSource['source'],
|
|
12
|
-
options: { datasetId: 'ds_42' },
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function fakeFetch(handler: (url: string, init?: any) => unknown): { fetch: FetchLike; calls: Array<{ url: string; init: any }> } {
|
|
16
|
-
const calls: Array<{ url: string; init: any }> = [];
|
|
17
|
-
const fetch: FetchLike = async (url, init) => {
|
|
18
|
-
calls.push({ url, init });
|
|
19
|
-
const out = await Promise.resolve(handler(url, init));
|
|
20
|
-
const body = typeof out === 'string' ? out : JSON.stringify(out ?? {});
|
|
21
|
-
return {
|
|
22
|
-
ok: true,
|
|
23
|
-
status: 200,
|
|
24
|
-
statusText: 'OK',
|
|
25
|
-
text: async () => body,
|
|
26
|
-
json: async () => JSON.parse(body),
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
return { fetch, calls };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
describe('KnowledgeRagflowAdapter', () => {
|
|
33
|
-
it('rejects sources without datasetId', async () => {
|
|
34
|
-
const { fetch } = fakeFetch(() => ({}));
|
|
35
|
-
const a = new KnowledgeRagflowAdapter({ endpoint: 'http://x', apiKey: 'k', fetch });
|
|
36
|
-
const bad: KnowledgeSource = { ...source, options: {} as Record<string, unknown> };
|
|
37
|
-
await expect(a.search('q', { source: bad, topK: 1 })).rejects.toThrow(/datasetId/);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('upsert deletes-then-creates chunks and stamps objectstack metadata', async () => {
|
|
41
|
-
const { fetch, calls } = fakeFetch((url) => {
|
|
42
|
-
if (url.includes('/api/v1/retrieval')) return { code: 0, data: { chunks: [] } };
|
|
43
|
-
return { code: 0, data: {} };
|
|
44
|
-
});
|
|
45
|
-
const a = new KnowledgeRagflowAdapter({ endpoint: 'http://r', apiKey: 'k', fetch });
|
|
46
|
-
const doc: KnowledgeDocument = {
|
|
47
|
-
id: 'd1',
|
|
48
|
-
sourceId: 'docs',
|
|
49
|
-
sourceRecordId: 'rec_1',
|
|
50
|
-
content: 'hello world',
|
|
51
|
-
title: 'Greeting',
|
|
52
|
-
metadata: { topic: 'intro' },
|
|
53
|
-
};
|
|
54
|
-
await a.upsert([doc], { source });
|
|
55
|
-
// First call: lookup existing chunks; second: create chunk
|
|
56
|
-
const createCall = calls.find((c) => c.url.endsWith('/api/v1/datasets/ds_42/chunks') && c.init.method === 'POST');
|
|
57
|
-
expect(createCall).toBeDefined();
|
|
58
|
-
const body = JSON.parse(createCall!.init.body);
|
|
59
|
-
expect(body.content).toBe('hello world');
|
|
60
|
-
expect(body.metadata.objectstack_doc_id).toBe('d1');
|
|
61
|
-
expect(body.metadata.objectstack_record_id).toBe('rec_1');
|
|
62
|
-
expect(body.metadata.objectstack_source_id).toBe('docs');
|
|
63
|
-
expect(body.metadata.topic).toBe('intro');
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('search maps ragflow chunks to KnowledgeHit shape', async () => {
|
|
67
|
-
const { fetch, calls } = fakeFetch(() => ({
|
|
68
|
-
code: 0,
|
|
69
|
-
data: {
|
|
70
|
-
chunks: [
|
|
71
|
-
{
|
|
72
|
-
id: 'c1',
|
|
73
|
-
content: 'snippet one',
|
|
74
|
-
similarity: 0.91,
|
|
75
|
-
metadata: { objectstack_doc_id: 'd1', objectstack_record_id: 'rec_1', title: 'T1' },
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
id: 'c2',
|
|
79
|
-
content: 'snippet two',
|
|
80
|
-
similarity: 0.7,
|
|
81
|
-
metadata: { objectstack_doc_id: 'd2' },
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
}));
|
|
86
|
-
const a = new KnowledgeRagflowAdapter({ endpoint: 'http://r', apiKey: 'k', fetch });
|
|
87
|
-
const hits = await a.search('hello', { source, topK: 5 });
|
|
88
|
-
expect(hits).toHaveLength(2);
|
|
89
|
-
expect(hits[0]).toMatchObject({
|
|
90
|
-
chunkId: 'c1',
|
|
91
|
-
documentId: 'd1',
|
|
92
|
-
sourceId: 'docs',
|
|
93
|
-
sourceRecordId: 'rec_1',
|
|
94
|
-
score: 0.91,
|
|
95
|
-
snippet: 'snippet one',
|
|
96
|
-
title: 'T1',
|
|
97
|
-
});
|
|
98
|
-
expect(hits[1].sourceRecordId).toBeUndefined();
|
|
99
|
-
// Authorization header present
|
|
100
|
-
const last = calls.at(-1)!;
|
|
101
|
-
expect(last.init.headers.authorization).toBe('Bearer k');
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('search honours rerankModel + similarityThreshold + filter', async () => {
|
|
105
|
-
const { fetch, calls } = fakeFetch(() => ({ code: 0, data: { chunks: [] } }));
|
|
106
|
-
const a = new KnowledgeRagflowAdapter({ endpoint: 'http://r', apiKey: 'k', fetch });
|
|
107
|
-
const s: KnowledgeSource = {
|
|
108
|
-
...source,
|
|
109
|
-
options: { datasetId: 'ds_42', rerankModel: 'bge-reranker', similarityThreshold: 0.6 },
|
|
110
|
-
};
|
|
111
|
-
await a.search('q', { source: s, topK: 3, filter: { tag: 'a' } });
|
|
112
|
-
const body = JSON.parse(calls[0].init.body);
|
|
113
|
-
expect(body.rerank_id).toBe('bge-reranker');
|
|
114
|
-
expect(body.similarity_threshold).toBe(0.6);
|
|
115
|
-
expect(body.metadata_condition).toEqual({ tag: 'a' });
|
|
116
|
-
expect(body.top_k).toBe(3);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('delete looks up chunks then issues DELETE with chunk_ids', async () => {
|
|
120
|
-
const { fetch, calls } = fakeFetch((url) => {
|
|
121
|
-
if (url.includes('/api/v1/retrieval')) {
|
|
122
|
-
return { code: 0, data: { chunks: [{ id: 'c1' }, { id: 'c2' }] } };
|
|
123
|
-
}
|
|
124
|
-
return { code: 0, data: {} };
|
|
125
|
-
});
|
|
126
|
-
const a = new KnowledgeRagflowAdapter({ endpoint: 'http://r', apiKey: 'k', fetch });
|
|
127
|
-
await a.delete(['d1'], { source });
|
|
128
|
-
const del = calls.find((c) => c.init.method === 'DELETE');
|
|
129
|
-
expect(del).toBeDefined();
|
|
130
|
-
expect(JSON.parse(del!.init.body)).toEqual({ chunk_ids: ['c1', 'c2'] });
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('healthCheck pings dataset list', async () => {
|
|
134
|
-
const { fetch } = fakeFetch(() => ({ code: 0, data: { datasets: [] } }));
|
|
135
|
-
const a = new KnowledgeRagflowAdapter({ endpoint: 'http://r', apiKey: 'k', fetch });
|
|
136
|
-
const h = await a.healthCheck();
|
|
137
|
-
expect(h.ok).toBe(true);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('healthCheck reports failure when request throws', async () => {
|
|
141
|
-
const fetch: FetchLike = async () => {
|
|
142
|
-
throw new Error('boom');
|
|
143
|
-
};
|
|
144
|
-
const a = new KnowledgeRagflowAdapter({ endpoint: 'http://r', apiKey: 'k', fetch });
|
|
145
|
-
const h = await a.healthCheck();
|
|
146
|
-
expect(h.ok).toBe(false);
|
|
147
|
-
expect(h.message).toMatch(/boom/);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('throws on non-zero RAGFlow error code', async () => {
|
|
151
|
-
const { fetch } = fakeFetch(() => ({ code: 102, message: 'bad request' }));
|
|
152
|
-
const a = new KnowledgeRagflowAdapter({ endpoint: 'http://r', apiKey: 'k', fetch });
|
|
153
|
-
await expect(a.search('q', { source, topK: 1 })).rejects.toThrow(/bad request/);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('constructor validates endpoint and apiKey', () => {
|
|
157
|
-
expect(() => new KnowledgeRagflowAdapter({ endpoint: '', apiKey: 'k', fetch: (async () => ({}) as any) })).toThrow(/endpoint/);
|
|
158
|
-
expect(() => new KnowledgeRagflowAdapter({ endpoint: 'http://x', apiKey: '', fetch: (async () => ({}) as any) })).toThrow(/apiKey/);
|
|
159
|
-
});
|
|
160
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
import type { Plugin, PluginContext } from '@objectstack/core';
|
|
4
|
-
import type {
|
|
5
|
-
IKnowledgeAdapter,
|
|
6
|
-
IKnowledgeService,
|
|
7
|
-
AdapterContext,
|
|
8
|
-
AdapterSearchOptions,
|
|
9
|
-
} from '@objectstack/spec/contracts';
|
|
10
|
-
import type {
|
|
11
|
-
KnowledgeDocument,
|
|
12
|
-
KnowledgeHit,
|
|
13
|
-
KnowledgeSource,
|
|
14
|
-
} from '@objectstack/spec/ai';
|
|
15
|
-
import { KNOWLEDGE_SERVICE } from '@objectstack/spec/contracts';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Subset of `fetch` used by the adapter. Inject in tests; defaults to
|
|
19
|
-
* the global `fetch`.
|
|
20
|
-
*/
|
|
21
|
-
export type FetchLike = (
|
|
22
|
-
input: string,
|
|
23
|
-
init?: {
|
|
24
|
-
method?: string;
|
|
25
|
-
headers?: Record<string, string>;
|
|
26
|
-
body?: string;
|
|
27
|
-
signal?: AbortSignal;
|
|
28
|
-
},
|
|
29
|
-
) => Promise<{
|
|
30
|
-
ok: boolean;
|
|
31
|
-
status: number;
|
|
32
|
-
statusText: string;
|
|
33
|
-
text(): Promise<string>;
|
|
34
|
-
json(): Promise<unknown>;
|
|
35
|
-
}>;
|
|
36
|
-
|
|
37
|
-
export interface KnowledgeRagflowAdapterOptions {
|
|
38
|
-
/** RAGFlow endpoint, e.g. `http://localhost:9380`. */
|
|
39
|
-
endpoint: string;
|
|
40
|
-
/** RAGFlow API key (Bearer token). */
|
|
41
|
-
apiKey: string;
|
|
42
|
-
/** Adapter id. @default 'ragflow' */
|
|
43
|
-
id?: string;
|
|
44
|
-
/** Override `fetch` for tests. */
|
|
45
|
-
fetch?: FetchLike;
|
|
46
|
-
/** Request timeout in milliseconds. @default 30000 */
|
|
47
|
-
timeoutMs?: number;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
interface RagflowSourceOptions {
|
|
51
|
-
datasetId: string;
|
|
52
|
-
/** Optional rerank model id (overrides dataset default). */
|
|
53
|
-
rerankModel?: string;
|
|
54
|
-
/** Optional similarity threshold passed through to RAGFlow. */
|
|
55
|
-
similarityThreshold?: number;
|
|
56
|
-
/** Optional vector vs keyword weight in [0,1]. */
|
|
57
|
-
vectorSimilarityWeight?: number;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function extractRagflowOptions(source: KnowledgeSource): RagflowSourceOptions {
|
|
61
|
-
const opts = ((source as unknown as { options?: Record<string, unknown> }).options ?? {}) as
|
|
62
|
-
Record<string, unknown>;
|
|
63
|
-
const datasetId = opts.datasetId;
|
|
64
|
-
if (typeof datasetId !== 'string' || !datasetId) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
`RAGFlow adapter requires source.options.datasetId on source '${source.id}'`,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
datasetId,
|
|
71
|
-
rerankModel: typeof opts.rerankModel === 'string' ? opts.rerankModel : undefined,
|
|
72
|
-
similarityThreshold:
|
|
73
|
-
typeof opts.similarityThreshold === 'number' ? opts.similarityThreshold : undefined,
|
|
74
|
-
vectorSimilarityWeight:
|
|
75
|
-
typeof opts.vectorSimilarityWeight === 'number'
|
|
76
|
-
? opts.vectorSimilarityWeight
|
|
77
|
-
: undefined,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* RAGFlow adapter. Maps {@link KnowledgeDocument} upserts to the
|
|
83
|
-
* dataset's chunk API, delegates retrieval to `/api/v1/retrieval`, and
|
|
84
|
-
* returns {@link KnowledgeHit}s with `sourceRecordId` preserved so the
|
|
85
|
-
* orchestrator can run a permission re-check.
|
|
86
|
-
*/
|
|
87
|
-
export class KnowledgeRagflowAdapter implements IKnowledgeAdapter {
|
|
88
|
-
readonly id: string;
|
|
89
|
-
private readonly endpoint: string;
|
|
90
|
-
private readonly apiKey: string;
|
|
91
|
-
private readonly fetchImpl: FetchLike;
|
|
92
|
-
private readonly timeoutMs: number;
|
|
93
|
-
|
|
94
|
-
constructor(opts: KnowledgeRagflowAdapterOptions) {
|
|
95
|
-
if (!opts.endpoint) throw new Error('RAGFlow adapter: endpoint required');
|
|
96
|
-
if (!opts.apiKey) throw new Error('RAGFlow adapter: apiKey required');
|
|
97
|
-
this.id = opts.id ?? 'ragflow';
|
|
98
|
-
this.endpoint = opts.endpoint.replace(/\/+$/, '');
|
|
99
|
-
this.apiKey = opts.apiKey;
|
|
100
|
-
this.fetchImpl = opts.fetch ?? ((globalThis as { fetch?: FetchLike }).fetch as FetchLike);
|
|
101
|
-
this.timeoutMs = opts.timeoutMs ?? 30000;
|
|
102
|
-
if (!this.fetchImpl) {
|
|
103
|
-
throw new Error('RAGFlow adapter: no fetch available; pass options.fetch');
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async upsert(docs: KnowledgeDocument[], ctx: AdapterContext): Promise<void> {
|
|
108
|
-
const { datasetId } = extractRagflowOptions(ctx.source);
|
|
109
|
-
// RAGFlow models documents in two layers: documents (file-like) and
|
|
110
|
-
// chunks (text blocks). We treat each KnowledgeDocument as a single
|
|
111
|
-
// chunk-set: delete existing chunks with the same external id, then
|
|
112
|
-
// upload as `content` chunks tagged with our document id.
|
|
113
|
-
for (const doc of docs) {
|
|
114
|
-
await this.deleteChunksByDocumentId(datasetId, doc.id);
|
|
115
|
-
await this.request(`/api/v1/datasets/${datasetId}/chunks`, {
|
|
116
|
-
method: 'POST',
|
|
117
|
-
body: JSON.stringify({
|
|
118
|
-
content: doc.content,
|
|
119
|
-
// RAGFlow accepts arbitrary metadata used for filtering at
|
|
120
|
-
// retrieval time. We always stamp `objectstack_doc_id` so
|
|
121
|
-
// delete() can find these chunks again.
|
|
122
|
-
important_keywords: doc.title ? [doc.title] : undefined,
|
|
123
|
-
metadata: {
|
|
124
|
-
...(doc.metadata ?? {}),
|
|
125
|
-
objectstack_doc_id: doc.id,
|
|
126
|
-
objectstack_source_id: doc.sourceId,
|
|
127
|
-
objectstack_record_id: doc.sourceRecordId,
|
|
128
|
-
title: doc.title,
|
|
129
|
-
},
|
|
130
|
-
}),
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async delete(documentIds: string[], ctx: AdapterContext): Promise<void> {
|
|
136
|
-
const { datasetId } = extractRagflowOptions(ctx.source);
|
|
137
|
-
for (const id of documentIds) {
|
|
138
|
-
await this.deleteChunksByDocumentId(datasetId, id);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async search(query: string, opts: AdapterSearchOptions): Promise<KnowledgeHit[]> {
|
|
143
|
-
const { datasetId, rerankModel, similarityThreshold, vectorSimilarityWeight } =
|
|
144
|
-
extractRagflowOptions(opts.source);
|
|
145
|
-
const body: Record<string, unknown> = {
|
|
146
|
-
question: query,
|
|
147
|
-
dataset_ids: [datasetId],
|
|
148
|
-
top_k: opts.topK,
|
|
149
|
-
keyword: true,
|
|
150
|
-
};
|
|
151
|
-
if (rerankModel) body.rerank_id = rerankModel;
|
|
152
|
-
if (typeof similarityThreshold === 'number') body.similarity_threshold = similarityThreshold;
|
|
153
|
-
if (typeof vectorSimilarityWeight === 'number')
|
|
154
|
-
body.vector_similarity_weight = vectorSimilarityWeight;
|
|
155
|
-
if (opts.filter) body.metadata_condition = { ...opts.filter };
|
|
156
|
-
|
|
157
|
-
const res = await this.request('/api/v1/retrieval', {
|
|
158
|
-
method: 'POST',
|
|
159
|
-
body: JSON.stringify(body),
|
|
160
|
-
});
|
|
161
|
-
const data = (res?.data ?? {}) as { chunks?: RagflowChunkHit[] };
|
|
162
|
-
const chunks = data.chunks ?? [];
|
|
163
|
-
return chunks.slice(0, opts.topK).map<KnowledgeHit>((c) => {
|
|
164
|
-
const md = (c.metadata ?? {}) as Record<string, unknown>;
|
|
165
|
-
const docId =
|
|
166
|
-
(md.objectstack_doc_id as string | undefined) ??
|
|
167
|
-
c.document_id ??
|
|
168
|
-
c.doc_id ??
|
|
169
|
-
c.id;
|
|
170
|
-
const recordId = md.objectstack_record_id as string | undefined;
|
|
171
|
-
return {
|
|
172
|
-
chunkId: c.id ?? `${docId}#${c.position ?? 0}`,
|
|
173
|
-
documentId: docId ?? c.id ?? 'unknown',
|
|
174
|
-
sourceId: opts.source.id,
|
|
175
|
-
sourceRecordId: recordId,
|
|
176
|
-
score: c.similarity ?? c.score ?? 0,
|
|
177
|
-
snippet: c.content ?? c.content_with_weight ?? '',
|
|
178
|
-
title: (md.title as string | undefined) ?? c.document_name,
|
|
179
|
-
metadata: md,
|
|
180
|
-
};
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
async healthCheck(): Promise<{ ok: boolean; message?: string }> {
|
|
185
|
-
try {
|
|
186
|
-
await this.request('/api/v1/datasets?page=1&page_size=1', { method: 'GET' });
|
|
187
|
-
return { ok: true };
|
|
188
|
-
} catch (err) {
|
|
189
|
-
return { ok: false, message: err instanceof Error ? err.message : String(err) };
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
private async deleteChunksByDocumentId(datasetId: string, docId: string): Promise<void> {
|
|
194
|
-
// Find chunks with our stamped metadata, then delete by chunk id.
|
|
195
|
-
const found = (await this.request(`/api/v1/retrieval`, {
|
|
196
|
-
method: 'POST',
|
|
197
|
-
body: JSON.stringify({
|
|
198
|
-
question: docId,
|
|
199
|
-
dataset_ids: [datasetId],
|
|
200
|
-
top_k: 256,
|
|
201
|
-
keyword: false,
|
|
202
|
-
metadata_condition: { objectstack_doc_id: docId },
|
|
203
|
-
}),
|
|
204
|
-
})) as { data?: { chunks?: Array<{ id?: string }> } };
|
|
205
|
-
const ids = (found.data?.chunks ?? [])
|
|
206
|
-
.map((c) => c.id)
|
|
207
|
-
.filter((x): x is string => typeof x === 'string');
|
|
208
|
-
if (ids.length === 0) return;
|
|
209
|
-
await this.request(`/api/v1/datasets/${datasetId}/chunks`, {
|
|
210
|
-
method: 'DELETE',
|
|
211
|
-
body: JSON.stringify({ chunk_ids: ids }),
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
private async request(
|
|
216
|
-
path: string,
|
|
217
|
-
init: { method: string; body?: string },
|
|
218
|
-
): Promise<{ data?: unknown; code?: number; message?: string }> {
|
|
219
|
-
const controller = new AbortController();
|
|
220
|
-
const t = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
221
|
-
try {
|
|
222
|
-
const res = await this.fetchImpl(`${this.endpoint}${path}`, {
|
|
223
|
-
method: init.method,
|
|
224
|
-
headers: {
|
|
225
|
-
'content-type': 'application/json',
|
|
226
|
-
authorization: `Bearer ${this.apiKey}`,
|
|
227
|
-
},
|
|
228
|
-
body: init.body,
|
|
229
|
-
signal: controller.signal,
|
|
230
|
-
});
|
|
231
|
-
const raw = await res.text();
|
|
232
|
-
let parsed: { data?: unknown; code?: number; message?: string } = {};
|
|
233
|
-
if (raw) {
|
|
234
|
-
try {
|
|
235
|
-
parsed = JSON.parse(raw) as typeof parsed;
|
|
236
|
-
} catch {
|
|
237
|
-
if (!res.ok) {
|
|
238
|
-
throw new Error(
|
|
239
|
-
`RAGFlow ${init.method} ${path} → ${res.status} ${res.statusText}: ${raw.slice(0, 200)}`,
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
if (!res.ok || (typeof parsed.code === 'number' && parsed.code !== 0 && parsed.code !== 200)) {
|
|
245
|
-
throw new Error(
|
|
246
|
-
`RAGFlow ${init.method} ${path} → ${res.status} ${res.statusText}${
|
|
247
|
-
parsed.message ? ` (${parsed.message})` : ''
|
|
248
|
-
}`,
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
return parsed;
|
|
252
|
-
} finally {
|
|
253
|
-
clearTimeout(t);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
interface RagflowChunkHit {
|
|
259
|
-
id?: string;
|
|
260
|
-
document_id?: string;
|
|
261
|
-
doc_id?: string;
|
|
262
|
-
document_name?: string;
|
|
263
|
-
content?: string;
|
|
264
|
-
content_with_weight?: string;
|
|
265
|
-
similarity?: number;
|
|
266
|
-
score?: number;
|
|
267
|
-
position?: number;
|
|
268
|
-
metadata?: Record<string, unknown>;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/* ---------------------------------------------------------------- */
|
|
272
|
-
/* Kernel plugin glue */
|
|
273
|
-
/* ---------------------------------------------------------------- */
|
|
274
|
-
|
|
275
|
-
export interface KnowledgeRagflowPluginOptions extends KnowledgeRagflowAdapterOptions {}
|
|
276
|
-
|
|
277
|
-
export class KnowledgeRagflowPlugin implements Plugin {
|
|
278
|
-
name = 'com.objectstack.plugin.knowledge-ragflow';
|
|
279
|
-
version = '0.1.0';
|
|
280
|
-
type = 'standard';
|
|
281
|
-
|
|
282
|
-
private readonly adapter: KnowledgeRagflowAdapter;
|
|
283
|
-
|
|
284
|
-
constructor(opts: KnowledgeRagflowPluginOptions) {
|
|
285
|
-
this.adapter = new KnowledgeRagflowAdapter(opts);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
async init(_ctx: PluginContext): Promise<void> {
|
|
289
|
-
// No-op: actual registration happens in start() once service is available.
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
async start(ctx: PluginContext): Promise<void> {
|
|
293
|
-
let svc: IKnowledgeService | undefined;
|
|
294
|
-
try {
|
|
295
|
-
svc = ctx.getService<IKnowledgeService>(KNOWLEDGE_SERVICE);
|
|
296
|
-
} catch {
|
|
297
|
-
ctx.logger.warn?.(
|
|
298
|
-
'KnowledgeRagflowPlugin: IKnowledgeService not registered — install KnowledgeServicePlugin first.',
|
|
299
|
-
);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
svc.registerAdapter(this.adapter.id, this.adapter);
|
|
303
|
-
ctx.logger.info?.(
|
|
304
|
-
`KnowledgeRagflowPlugin: adapter '${this.adapter.id}' registered (endpoint=${(this.adapter as unknown as { endpoint: string }).endpoint}).`,
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "ES2020",
|
|
5
|
-
"module": "ES2020",
|
|
6
|
-
"moduleResolution": "bundler",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"outDir": "./dist",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"noUnusedLocals": false,
|
|
13
|
-
"noUnusedParameters": false,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"types": ["node"],
|
|
16
|
-
"rootDir": "./src"
|
|
17
|
-
},
|
|
18
|
-
"include": ["src/**/*"],
|
|
19
|
-
"exclude": ["node_modules", "dist"]
|
|
20
|
-
}
|
package/vitest.config.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
import { defineConfig } from 'vitest/config';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
test: {
|
|
8
|
-
globals: true,
|
|
9
|
-
environment: 'node',
|
|
10
|
-
},
|
|
11
|
-
resolve: {
|
|
12
|
-
alias: {
|
|
13
|
-
'@objectstack/core': path.resolve(__dirname, '../../core/src/index.ts'),
|
|
14
|
-
'@objectstack/service-knowledge': path.resolve(__dirname, '../../services/service-knowledge/src/index.ts'),
|
|
15
|
-
'@objectstack/spec/ai': path.resolve(__dirname, '../../spec/src/ai/index.ts'),
|
|
16
|
-
'@objectstack/spec/contracts': path.resolve(__dirname, '../../spec/src/contracts/index.ts'),
|
|
17
|
-
'@objectstack/spec/data': path.resolve(__dirname, '../../spec/src/data/index.ts'),
|
|
18
|
-
'@objectstack/spec/kernel': path.resolve(__dirname, '../../spec/src/kernel/index.ts'),
|
|
19
|
-
'@objectstack/spec/system': path.resolve(__dirname, '../../spec/src/system/index.ts'),
|
|
20
|
-
'@objectstack/spec': path.resolve(__dirname, '../../spec/src/index.ts'),
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|