dsh-data-domain-knowledge 0.1.0-alpha.9 → 0.1.1-alpha.2

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 (438) hide show
  1. package/README.md +118 -567
  2. package/cordis.patch.yml +5 -418
  3. package/eval/README.md +19 -8
  4. package/eval/benchmark-extraction-format.mjs +20 -0
  5. package/eval/evaluate-retrieval.mjs +17 -8
  6. package/eval/queries.example.jsonl +1 -0
  7. package/lib/client.js +4181 -3239
  8. package/lib/contract-envelope.d.ts +91 -0
  9. package/lib/contract-envelope.js +106 -0
  10. package/lib/contract-layout.d.ts +130 -0
  11. package/lib/contract-layout.js +138 -0
  12. package/lib/contract-refs.d.ts +39 -0
  13. package/lib/contract-refs.js +9 -0
  14. package/lib/contract-version.d.ts +311 -0
  15. package/lib/contract-version.js +270 -0
  16. package/lib/contract-wire.d.ts +147 -0
  17. package/lib/contract-wire.js +99 -0
  18. package/lib/contracts.d.ts +12 -0
  19. package/lib/contracts.js +12 -0
  20. package/lib/doc-page.js +2 -2
  21. package/lib/pages.js +3329 -1296
  22. package/lib/types/agent-behavior-rules.d.ts +10 -0
  23. package/lib/types/agent-behavior-rules.d.ts.map +1 -0
  24. package/lib/types/agent-behavior-rules.js +28 -0
  25. package/lib/types/agent-behavior-rules.js.map +1 -0
  26. package/lib/types/axis-registry.d.ts +37 -5
  27. package/lib/types/axis-registry.d.ts.map +1 -1
  28. package/lib/types/axis-registry.js +234 -26
  29. package/lib/types/axis-registry.js.map +1 -1
  30. package/lib/types/card-organize.d.ts +27 -12
  31. package/lib/types/card-organize.d.ts.map +1 -1
  32. package/lib/types/card-organize.js +58 -73
  33. package/lib/types/card-organize.js.map +1 -1
  34. package/lib/types/compiler/embedding-identity.d.ts +3 -0
  35. package/lib/types/compiler/embedding-identity.d.ts.map +1 -0
  36. package/lib/types/compiler/embedding-identity.js +24 -0
  37. package/lib/types/compiler/embedding-identity.js.map +1 -0
  38. package/lib/types/compiler/snapshot.d.ts +16 -0
  39. package/lib/types/compiler/snapshot.d.ts.map +1 -0
  40. package/lib/types/compiler/snapshot.js +2 -0
  41. package/lib/types/compiler/snapshot.js.map +1 -0
  42. package/lib/types/config-schema.d.ts +6 -3
  43. package/lib/types/config-schema.d.ts.map +1 -1
  44. package/lib/types/config-schema.js +6 -2
  45. package/lib/types/config-schema.js.map +1 -1
  46. package/lib/types/convert/host.d.ts +6 -5
  47. package/lib/types/convert/host.d.ts.map +1 -1
  48. package/lib/types/convert/host.js +58 -18
  49. package/lib/types/convert/host.js.map +1 -1
  50. package/lib/types/convert/ingest.d.ts +10 -1
  51. package/lib/types/convert/ingest.d.ts.map +1 -1
  52. package/lib/types/convert/ingest.js +68 -9
  53. package/lib/types/convert/ingest.js.map +1 -1
  54. package/lib/types/derive-contract.d.ts +3 -0
  55. package/lib/types/derive-contract.d.ts.map +1 -0
  56. package/lib/types/derive-contract.js +15 -0
  57. package/lib/types/derive-contract.js.map +1 -0
  58. package/lib/types/diagnosis/cards.d.ts +7 -3
  59. package/lib/types/diagnosis/cards.d.ts.map +1 -1
  60. package/lib/types/diagnosis/cards.js +13 -8
  61. package/lib/types/diagnosis/cards.js.map +1 -1
  62. package/lib/types/diagnosis/run.d.ts +4 -13
  63. package/lib/types/diagnosis/run.d.ts.map +1 -1
  64. package/lib/types/diagnosis/run.js +26 -16
  65. package/lib/types/diagnosis/run.js.map +1 -1
  66. package/lib/types/diagnosis/schema.js +2 -2
  67. package/lib/types/diagnosis/schema.js.map +1 -1
  68. package/lib/types/diagnosis/seed-source.d.ts +1 -1
  69. package/lib/types/diagnosis/seed-source.d.ts.map +1 -1
  70. package/lib/types/diagnosis/seed-source.js +5 -4
  71. package/lib/types/diagnosis/seed-source.js.map +1 -1
  72. package/lib/types/diagnosis/seed.d.ts +4 -4
  73. package/lib/types/diagnosis/seed.d.ts.map +1 -1
  74. package/lib/types/diagnosis/seed.js +6 -8
  75. package/lib/types/diagnosis/seed.js.map +1 -1
  76. package/lib/types/diagnosis/store.d.ts +24 -18
  77. package/lib/types/diagnosis/store.d.ts.map +1 -1
  78. package/lib/types/diagnosis/store.js +130 -65
  79. package/lib/types/diagnosis/store.js.map +1 -1
  80. package/lib/types/diagnosis/types.d.ts +47 -15
  81. package/lib/types/diagnosis/types.d.ts.map +1 -1
  82. package/lib/types/diagnosis/types.js.map +1 -1
  83. package/lib/types/environment/dsh-python.d.ts +77 -0
  84. package/lib/types/environment/dsh-python.d.ts.map +1 -0
  85. package/lib/types/environment/dsh-python.js +139 -0
  86. package/lib/types/environment/dsh-python.js.map +1 -0
  87. package/lib/types/environment/install.d.ts +15 -0
  88. package/lib/types/environment/install.d.ts.map +1 -0
  89. package/lib/types/environment/install.js +297 -0
  90. package/lib/types/environment/install.js.map +1 -0
  91. package/lib/types/environment/manifest.d.ts +208 -0
  92. package/lib/types/environment/manifest.d.ts.map +1 -0
  93. package/lib/types/environment/manifest.js +26 -0
  94. package/lib/types/environment/manifest.js.map +1 -0
  95. package/lib/types/environment/model-catalog.d.ts +223 -0
  96. package/lib/types/environment/model-catalog.d.ts.map +1 -0
  97. package/lib/types/environment/model-catalog.js +129 -0
  98. package/lib/types/environment/model-catalog.js.map +1 -0
  99. package/lib/types/environment/process.d.ts +10 -0
  100. package/lib/types/environment/process.d.ts.map +1 -0
  101. package/lib/types/environment/process.js +54 -0
  102. package/lib/types/environment/process.js.map +1 -0
  103. package/lib/types/environment/selection.d.ts +9 -0
  104. package/lib/types/environment/selection.d.ts.map +1 -0
  105. package/lib/types/environment/selection.js +29 -0
  106. package/lib/types/environment/selection.js.map +1 -0
  107. package/lib/types/environment/service.d.ts +64 -0
  108. package/lib/types/environment/service.d.ts.map +1 -0
  109. package/lib/types/environment/service.js +424 -0
  110. package/lib/types/environment/service.js.map +1 -0
  111. package/lib/types/environment/types.d.ts +56 -0
  112. package/lib/types/environment/types.d.ts.map +1 -0
  113. package/lib/types/environment/types.js +2 -0
  114. package/lib/types/environment/types.js.map +1 -0
  115. package/lib/types/events.d.ts +76 -0
  116. package/lib/types/events.d.ts.map +1 -0
  117. package/lib/types/events.js +52 -0
  118. package/lib/types/events.js.map +1 -0
  119. package/lib/types/extract-contract.d.ts +3 -0
  120. package/lib/types/extract-contract.d.ts.map +1 -0
  121. package/lib/types/extract-contract.js +41 -0
  122. package/lib/types/extract-contract.js.map +1 -0
  123. package/lib/types/extract-model.d.ts +5 -0
  124. package/lib/types/extract-model.d.ts.map +1 -1
  125. package/lib/types/extract-model.js.map +1 -1
  126. package/lib/types/extract-table-contract.d.ts +3 -0
  127. package/lib/types/extract-table-contract.d.ts.map +1 -0
  128. package/lib/types/extract-table-contract.js +27 -0
  129. package/lib/types/extract-table-contract.js.map +1 -0
  130. package/lib/types/extract-table.d.ts +8 -0
  131. package/lib/types/extract-table.d.ts.map +1 -0
  132. package/lib/types/extract-table.js +158 -0
  133. package/lib/types/extract-table.js.map +1 -0
  134. package/lib/types/extraction-runs.d.ts +30 -6
  135. package/lib/types/extraction-runs.d.ts.map +1 -1
  136. package/lib/types/extraction-runs.js +69 -8
  137. package/lib/types/extraction-runs.js.map +1 -1
  138. package/lib/types/fs-atomic.d.ts +0 -7
  139. package/lib/types/fs-atomic.d.ts.map +1 -1
  140. package/lib/types/fs-atomic.js +17 -2
  141. package/lib/types/fs-atomic.js.map +1 -1
  142. package/lib/types/images.d.ts +26 -0
  143. package/lib/types/images.d.ts.map +1 -0
  144. package/lib/types/images.js +196 -0
  145. package/lib/types/images.js.map +1 -0
  146. package/lib/types/index.d.ts +2 -2
  147. package/lib/types/index.d.ts.map +1 -1
  148. package/lib/types/index.js +598 -209
  149. package/lib/types/index.js.map +1 -1
  150. package/lib/types/intent/engine.d.ts +12 -4
  151. package/lib/types/intent/engine.d.ts.map +1 -1
  152. package/lib/types/intent/engine.js +43 -5
  153. package/lib/types/intent/engine.js.map +1 -1
  154. package/lib/types/intent/host.d.ts +5 -8
  155. package/lib/types/intent/host.d.ts.map +1 -1
  156. package/lib/types/intent/host.js +56 -11
  157. package/lib/types/intent/host.js.map +1 -1
  158. package/lib/types/intent/scope.d.ts +25 -0
  159. package/lib/types/intent/scope.d.ts.map +1 -0
  160. package/lib/types/intent/scope.js +116 -0
  161. package/lib/types/intent/scope.js.map +1 -0
  162. package/lib/types/intent/tools.d.ts +24 -20
  163. package/lib/types/intent/tools.d.ts.map +1 -1
  164. package/lib/types/intent/tools.js +65 -23
  165. package/lib/types/intent/tools.js.map +1 -1
  166. package/lib/types/intent/types.d.ts +11 -4
  167. package/lib/types/intent/types.d.ts.map +1 -1
  168. package/lib/types/knowledge-bases.d.ts +11 -5
  169. package/lib/types/knowledge-bases.d.ts.map +1 -1
  170. package/lib/types/knowledge-bases.js +52 -20
  171. package/lib/types/knowledge-bases.js.map +1 -1
  172. package/lib/types/knowledge-contract.d.ts +32 -0
  173. package/lib/types/knowledge-contract.d.ts.map +1 -0
  174. package/lib/types/knowledge-contract.js +116 -0
  175. package/lib/types/knowledge-contract.js.map +1 -0
  176. package/lib/types/knowledge.d.ts +31 -9
  177. package/lib/types/knowledge.d.ts.map +1 -1
  178. package/lib/types/knowledge.js +137 -60
  179. package/lib/types/knowledge.js.map +1 -1
  180. package/lib/types/layout.d.ts +10 -29
  181. package/lib/types/layout.d.ts.map +1 -1
  182. package/lib/types/layout.js +17 -36
  183. package/lib/types/layout.js.map +1 -1
  184. package/lib/types/materialize-snapshot.d.ts +49 -0
  185. package/lib/types/materialize-snapshot.d.ts.map +1 -0
  186. package/lib/types/materialize-snapshot.js +2 -0
  187. package/lib/types/materialize-snapshot.js.map +1 -0
  188. package/lib/types/migrate.d.ts +11 -0
  189. package/lib/types/migrate.d.ts.map +1 -1
  190. package/lib/types/migrate.js +83 -2
  191. package/lib/types/migrate.js.map +1 -1
  192. package/lib/types/model-text.d.ts +58 -1
  193. package/lib/types/model-text.d.ts.map +1 -1
  194. package/lib/types/model-text.js +85 -30
  195. package/lib/types/model-text.js.map +1 -1
  196. package/lib/types/oplog.d.ts.map +1 -1
  197. package/lib/types/oplog.js +7 -0
  198. package/lib/types/oplog.js.map +1 -1
  199. package/lib/types/organize-contract.d.ts +18 -0
  200. package/lib/types/organize-contract.d.ts.map +1 -0
  201. package/lib/types/organize-contract.js +82 -0
  202. package/lib/types/organize-contract.js.map +1 -0
  203. package/lib/types/pipeline/engine.d.ts +66 -0
  204. package/lib/types/pipeline/engine.d.ts.map +1 -0
  205. package/lib/types/pipeline/engine.js +352 -0
  206. package/lib/types/pipeline/engine.js.map +1 -0
  207. package/lib/types/pipeline/store.d.ts +73 -0
  208. package/lib/types/pipeline/store.d.ts.map +1 -0
  209. package/lib/types/pipeline/store.js +143 -0
  210. package/lib/types/pipeline/store.js.map +1 -0
  211. package/lib/types/pipeline/types.d.ts +102 -0
  212. package/lib/types/pipeline/types.d.ts.map +1 -0
  213. package/lib/types/pipeline/types.js +5 -0
  214. package/lib/types/pipeline/types.js.map +1 -0
  215. package/lib/types/present.d.ts +2 -0
  216. package/lib/types/present.d.ts.map +1 -1
  217. package/lib/types/present.js +9 -4
  218. package/lib/types/present.js.map +1 -1
  219. package/lib/types/preset-ids.d.ts +4 -0
  220. package/lib/types/preset-ids.d.ts.map +1 -0
  221. package/lib/types/preset-ids.js +6 -0
  222. package/lib/types/preset-ids.js.map +1 -0
  223. package/lib/types/query-analysis.d.ts +13 -1
  224. package/lib/types/query-analysis.d.ts.map +1 -1
  225. package/lib/types/query-analysis.js +62 -6
  226. package/lib/types/query-analysis.js.map +1 -1
  227. package/lib/types/recall-rank.d.ts +3 -3
  228. package/lib/types/recall-rank.d.ts.map +1 -1
  229. package/lib/types/recall-rank.js +4 -4
  230. package/lib/types/recall-rank.js.map +1 -1
  231. package/lib/types/retention.d.ts +39 -0
  232. package/lib/types/retention.d.ts.map +1 -0
  233. package/lib/types/retention.js +42 -0
  234. package/lib/types/retention.js.map +1 -0
  235. package/lib/types/retrieval/vector-index.d.ts +32 -0
  236. package/lib/types/retrieval/vector-index.d.ts.map +1 -0
  237. package/lib/types/retrieval/vector-index.js +15 -0
  238. package/lib/types/retrieval/vector-index.js.map +1 -0
  239. package/lib/types/retrieval/visibility.d.ts +6 -0
  240. package/lib/types/retrieval/visibility.d.ts.map +1 -0
  241. package/lib/types/retrieval/visibility.js +11 -0
  242. package/lib/types/retrieval/visibility.js.map +1 -0
  243. package/lib/types/runtime.d.ts +272 -27
  244. package/lib/types/runtime.d.ts.map +1 -1
  245. package/lib/types/runtime.js +2751 -537
  246. package/lib/types/runtime.js.map +1 -1
  247. package/lib/types/settings-schema.d.ts +17 -15
  248. package/lib/types/settings-schema.d.ts.map +1 -1
  249. package/lib/types/settings-schema.js +50 -47
  250. package/lib/types/settings-schema.js.map +1 -1
  251. package/lib/types/settings-volatile.d.ts +4 -4
  252. package/lib/types/settings-volatile.js +4 -4
  253. package/lib/types/source-evidence.d.ts +14 -0
  254. package/lib/types/source-evidence.d.ts.map +1 -0
  255. package/lib/types/source-evidence.js +36 -0
  256. package/lib/types/source-evidence.js.map +1 -0
  257. package/lib/types/store/axis-references.d.ts +5 -0
  258. package/lib/types/store/axis-references.d.ts.map +1 -0
  259. package/lib/types/store/axis-references.js +106 -0
  260. package/lib/types/store/axis-references.js.map +1 -0
  261. package/lib/types/store/derived.d.ts +12 -1
  262. package/lib/types/store/derived.d.ts.map +1 -1
  263. package/lib/types/store/derived.js +71 -12
  264. package/lib/types/store/derived.js.map +1 -1
  265. package/lib/types/store/knowledge-db.d.ts +31 -1
  266. package/lib/types/store/knowledge-db.d.ts.map +1 -1
  267. package/lib/types/store/knowledge-db.js +252 -18
  268. package/lib/types/store/knowledge-db.js.map +1 -1
  269. package/lib/types/store/migrate.d.ts.map +1 -1
  270. package/lib/types/store/migrate.js +17 -6
  271. package/lib/types/store/migrate.js.map +1 -1
  272. package/lib/types/trajectory-types.d.ts +172 -0
  273. package/lib/types/trajectory-types.d.ts.map +1 -0
  274. package/lib/types/trajectory-types.js +36 -0
  275. package/lib/types/trajectory-types.js.map +1 -0
  276. package/lib/types/types.d.ts +59 -27
  277. package/lib/types/types.d.ts.map +1 -1
  278. package/lib/types/types.js +6 -15
  279. package/lib/types/types.js.map +1 -1
  280. package/lib/types/wiki-finalize.d.ts +16 -0
  281. package/lib/types/wiki-finalize.d.ts.map +1 -1
  282. package/lib/types/wiki-finalize.js +26 -0
  283. package/lib/types/wiki-finalize.js.map +1 -1
  284. package/lib/types/wiki-materialize.d.ts +4 -0
  285. package/lib/types/wiki-materialize.d.ts.map +1 -1
  286. package/lib/types/wiki-materialize.js +21 -7
  287. package/lib/types/wiki-materialize.js.map +1 -1
  288. package/lib/types/wiki-trial-types.d.ts +87 -0
  289. package/lib/types/wiki-trial-types.d.ts.map +1 -1
  290. package/lib/types/wiki-trial-types.js +0 -16
  291. package/lib/types/wiki-trial-types.js.map +1 -1
  292. package/lib/types/wiki-trial.d.ts +40 -16
  293. package/lib/types/wiki-trial.d.ts.map +1 -1
  294. package/lib/types/wiki-trial.js +337 -224
  295. package/lib/types/wiki-trial.js.map +1 -1
  296. package/package.json +29 -20
  297. package/python/prepare-models.py +19 -0
  298. package/python/requirements.txt +8 -6
  299. package/scripts/doctor.mjs +13 -19
  300. package/scripts/environment.mjs +29 -0
  301. package/scripts/setup-embedding.sh +15 -5
  302. package/src/agent-behavior-rules.ts +37 -0
  303. package/src/axis-registry.ts +234 -27
  304. package/src/card-organize.ts +69 -75
  305. package/src/client/AgentBehaviorRulesCard.tsx +65 -0
  306. package/src/client/AttributionEventGuide.tsx +41 -39
  307. package/src/client/AxisRegistrySection.tsx +204 -164
  308. package/src/client/CompileDialogs.tsx +44 -29
  309. package/src/client/DeleteDocumentDialog.tsx +36 -5
  310. package/src/client/DirectoryPicker.tsx +0 -10
  311. package/src/client/EnvironmentSetup.tsx +243 -0
  312. package/src/client/ExpansionGraph.tsx +13 -7
  313. package/src/client/ExtractionTasksPage.tsx +578 -0
  314. package/src/client/GuideArchitectureCanvas.tsx +470 -0
  315. package/src/client/ImportFilesDialog.tsx +2 -13
  316. package/src/client/IntentLogic.tsx +2 -2
  317. package/src/client/IntentTab.tsx +118 -47
  318. package/src/client/KnowledgeBaseTab.tsx +277 -197
  319. package/src/client/KnowledgeLayerSection.tsx +24 -6
  320. package/src/client/KnowledgePanel.tsx +58 -93
  321. package/src/client/KnowledgeSettingsDrawer.tsx +90 -0
  322. package/src/client/ListPager.tsx +15 -5
  323. package/src/client/MaterializeTrajectoryView.tsx +124 -0
  324. package/src/client/NodeSettings.tsx +210 -89
  325. package/src/client/NormalizeTrajectoryView.tsx +136 -0
  326. package/src/client/PipelineNotice.tsx +26 -0
  327. package/src/client/PreviewSections.tsx +118 -51
  328. package/src/client/RecallPanel.tsx +89 -85
  329. package/src/client/TabGuide.tsx +159 -184
  330. package/src/client/TrialReportView.tsx +391 -214
  331. package/src/client/TypeDefinitionDrawer.tsx +150 -23
  332. package/src/client/WikiCardPreview.tsx +62 -16
  333. package/src/client/WikiFlowPanel.tsx +4 -4
  334. package/src/client/arch/NodeLogicPanel.tsx +3 -4
  335. package/src/client/arch/model.ts +6 -9
  336. package/src/client/architecture.tsx +23 -33
  337. package/src/client/attribution/AttributionGraph.tsx +10 -6
  338. package/src/client/attribution/AttributionTab.tsx +136 -84
  339. package/src/client/attribution/CaseView.tsx +3 -1
  340. package/src/client/attribution/EventView.tsx +108 -0
  341. package/src/client/attribution/RunView.tsx +2 -2
  342. package/src/client/attribution/StageChrome.tsx +34 -3
  343. package/src/client/attribution/ViewSwitch.tsx +20 -5
  344. package/src/client/attribution/graph-options.ts +47 -39
  345. package/src/client/attribution/model.ts +17 -10
  346. package/src/client/config-scope.ts +3 -3
  347. package/src/client/graph/palette.ts +165 -0
  348. package/src/client/index.ts +49 -42
  349. package/src/client/pages.css +459 -135
  350. package/src/client/pages.tsx +37 -9
  351. package/src/client/problem-domains.ts +1 -1
  352. package/src/client/session-remote.ts +9 -0
  353. package/src/client/styles.css +205 -62
  354. package/src/client/wiki-trial.ts +44 -3
  355. package/src/compiler/embedding-identity.ts +21 -0
  356. package/src/compiler/snapshot.ts +17 -0
  357. package/src/config-schema.ts +8 -3
  358. package/src/convert/host.ts +56 -21
  359. package/src/convert/ingest.ts +74 -10
  360. package/src/derive-contract.ts +14 -0
  361. package/src/diagnosis/cards.ts +13 -8
  362. package/src/diagnosis/run.ts +27 -17
  363. package/src/diagnosis/schema.ts +2 -2
  364. package/src/diagnosis/seed-source.ts +5 -4
  365. package/src/diagnosis/seed.ts +6 -8
  366. package/src/diagnosis/store.ts +138 -69
  367. package/src/diagnosis/types.ts +34 -15
  368. package/src/environment/dsh-python.ts +156 -0
  369. package/src/environment/install.ts +244 -0
  370. package/src/environment/manifest.ts +28 -0
  371. package/src/environment/model-catalog.ts +147 -0
  372. package/src/environment/process.ts +54 -0
  373. package/src/environment/selection.ts +29 -0
  374. package/src/environment/service.ts +348 -0
  375. package/src/environment/types.ts +45 -0
  376. package/src/events.ts +108 -0
  377. package/src/extract-contract.ts +42 -0
  378. package/src/extract-model.ts +10 -1
  379. package/src/extract-table-contract.ts +26 -0
  380. package/src/extract-table.ts +132 -0
  381. package/src/extraction-runs.ts +70 -11
  382. package/src/fs-atomic.ts +19 -2
  383. package/src/images.ts +203 -0
  384. package/src/index.ts +553 -205
  385. package/src/intent/README.md +8 -6
  386. package/src/intent/engine.ts +44 -6
  387. package/src/intent/host.ts +59 -18
  388. package/src/intent/scope.ts +125 -0
  389. package/src/intent/tools.ts +70 -28
  390. package/src/intent/types.ts +11 -4
  391. package/src/knowledge-bases.ts +56 -20
  392. package/src/knowledge-contract.ts +114 -0
  393. package/src/knowledge.ts +138 -69
  394. package/src/layout.ts +17 -37
  395. package/src/materialize-snapshot.ts +46 -0
  396. package/src/migrate.ts +75 -2
  397. package/src/model-text.ts +109 -4
  398. package/src/oplog.ts +7 -0
  399. package/src/organize-contract.ts +83 -0
  400. package/src/pipeline/engine.ts +323 -0
  401. package/src/pipeline/store.ts +147 -0
  402. package/src/pipeline/types.ts +93 -0
  403. package/src/present.ts +10 -4
  404. package/src/preset-ids.ts +6 -0
  405. package/src/python/embedding_worker.py +66 -2
  406. package/src/query-analysis.ts +68 -8
  407. package/src/recall-rank.ts +5 -5
  408. package/src/retention.ts +76 -0
  409. package/src/retrieval/vector-index.ts +45 -0
  410. package/src/retrieval/visibility.ts +14 -0
  411. package/src/runtime.ts +2708 -567
  412. package/src/settings-schema.ts +11 -8
  413. package/src/settings-volatile.ts +4 -4
  414. package/src/source-evidence.ts +37 -0
  415. package/src/store/axis-references.ts +96 -0
  416. package/src/store/derived.ts +70 -12
  417. package/src/store/knowledge-db.ts +248 -17
  418. package/src/store/migrate.ts +16 -6
  419. package/src/trajectory-types.ts +142 -0
  420. package/src/types.ts +61 -35
  421. package/src/wiki-finalize.ts +28 -0
  422. package/src/wiki-materialize.ts +25 -6
  423. package/src/wiki-trial-types.ts +83 -1
  424. package/src/wiki-trial.ts +357 -185
  425. package/lib/types/intent/preset-tools.d.ts +0 -37
  426. package/lib/types/intent/preset-tools.d.ts.map +0 -1
  427. package/lib/types/intent/preset-tools.js +0 -45
  428. package/lib/types/intent/preset-tools.js.map +0 -1
  429. package/preset/tita-data-agent/agent.cordis.yml +0 -394
  430. package/preset/tita-data-agent/preset.yml +0 -3
  431. package/scripts/install-agent-preset.mjs +0 -92
  432. package/scripts/sync-agent-preset.mjs +0 -188
  433. package/src/client/AgentPresetCard.tsx +0 -247
  434. package/src/client/agent-preset.ts +0 -121
  435. package/src/client/convert/ConvertPanel.tsx +0 -583
  436. package/src/client/convert/styles.css +0 -138
  437. package/src/client/convert/styles.ts +0 -49
  438. package/src/intent/preset-tools.ts +0 -48
package/cordis.patch.yml CHANGED
@@ -1,427 +1,14 @@
1
1
  # data-domain-knowledge bundle patch: mount the knowledge / intent audit / convert host.
2
2
  #
3
3
  # 0.1.7 起这条 entry **自己就是设置文档**:插件导出的 `Config`(见
4
- # `src/config-schema.ts`)把两块设置合成一个 schema —— `knowledge` / `convert`。
4
+ # `src/config-schema.ts`)把各设置组合成一个 schema —— `knowledge` / `convert` / `behaviorRules`。
5
5
  # 会话意图使用固定审计契约,不属于 entry config。设置页里的改动由 `configEditor` 写回**本 entry 的
6
6
  # `config:`**,客户端按路径读写(`{op:'set', path:['knowledge','recallTopK']}`)。
7
7
  #
8
- # 所以这里**故意不写 `config:`**:两组字段全都有 schema `.default()`,而
9
- # `knowledge.agentRoot` 的默认值就是 `~/Desktop/titaagent`(`defaultAgentRoot()`,
10
- # 可被 `DSH_AGENT_ROOT` 覆盖)。往这里写死一个 `agentRoot` 会把「Agent 的家在哪」
11
- # 这件事从代码挪进某台机器的配置文件里 —— 那正是 0029 想收拢的那一个答案。
8
+ # 所以这里**故意不写 `config:`**:各组字段全都有 schema `.default()`,而
9
+ # `knowledge.agentRoot` 的默认值就是 DSH 下的 `~/.dsh/tita-agent` 专属目录
10
+ #(`defaultAgentRoot()`,跟随 `DSH_HOME`)。往这里写死一个 `agentRoot` 会把「Agent 的家在哪」
11
+ # 这件事从代码挪进某台机器的配置文件里 —— 那正是这里要避免的。
12
12
  - insert:
13
13
  - id: tita-data-domain-knowledge
14
14
  name: 'dsh-data-domain-knowledge'
15
-
16
- # >>> agent preset (generated) >>>
17
- # Tita Data Agent 的 agent preset 声明。
18
- #
19
- # 这一段由 `scripts/sync-agent-preset.mjs` 从 `preset/tita-data-agent/` 生成 ——
20
- # **不要手改**:改真源再跑 `pnpm sync:preset`。`pnpm doctor` 会校验它与真源一致。
21
- #
22
- # 为什么 preset 必须长在插件的 patch 里:0.1.7 起 DSH 不再扫描
23
- # `$DSH_HOME/.agent-presets/`,preset 的唯一形态就是这条 insert。详见脚本头注释。
24
- - insert:
25
- - id: preset-tita-data-agent
26
- name: '@deepseek-ai/dsh-agent-preset'
27
- config:
28
- id: tita-data-agent
29
- name: 'Tita Data Agent'
30
- description: 'TitaAgent 自己的组合:数据 Agent 的提示词,加上只有这个 preset 才有的意图记录工具。'
31
- order: 10
32
- plugins:
33
- # Tita Data Agent 的 agent 组合(0029)。
34
- #
35
- # 这是 `standard` 的一份**拷贝**,只改了四件事。preset 是「一份完整组合」,没有
36
- # patch 语义(`dsh-agent-presets` 的 authoring 是 copy-only),所以它必须是一整份
37
- # 文件、而不是对 standard 的增量。
38
- #
39
- # 改了什么:
40
- #
41
- # 1. **身份**(`persona` 行):把「你是一个编码 Agent」换成 Tita Data Agent 自己的
42
- # 提示词。这一行是**这个 preset 存在的理由** —— 它 shadow 掉部署级的 persona,
43
- # 所以只有加入这个 preset 的会话会以数据 Agent 的身份说话。提示词正文就在下面,
44
- # 直接改它即可;改完**新建一个会话**才生效(preset 在会话创建时固定)。
45
- # 2. **意图工具**(`intent-tools` 行):`intent_record` / `intent_store_view` 两个工具
46
- # 搬到 agent 平面,只有这个 preset 的会话能看到。
47
- # DSH 里「只有某个 preset 能用」唯一支持的形态就是注册作用域,所以它们必须在这里
48
- # 挂载,而不是在宿主平面全局注册(那会让每个 agent 都看到 intent_record)。
49
- # 3. **子代理不许继承意图工具**:子代理会加入父会话的组合,所以要在 delegation 的每一
50
- # 行上显式 deny 掉 —— 意图记录描述的是「用户在跟 Agent 要什么」,子代理做的是被拆
51
- # 出来的一个片段,它记一条意图只会污染任务树。
52
- # 4. 其余每一行都与 `standard` 逐字相同:工具集不变,这个 preset 换的是身份与意图
53
- # 能力,不是一个更小的 Agent。
54
- #
55
- # 其余纪律与 `standard` 一致:这是 AGENT-PLANE 组合,roster 在 standing scope 下挂载
56
- # 一次,每个命名它的会话按作用域父子关系加入。需要 provide 服务的行必须落在带
57
- # `isolate` realm 的 group 里,否则它会发布到根 realm(进程级)并被挂载审计拒绝 ——
58
- # 本文件里唯一这样的行是 delegation 那个 group。
59
-
60
- # ── identity ────────────────────────────────────────────────────────────────
61
-
62
- # The preset's own persona, shadowing the deployment default for this agent.
63
- # `{{model}}` and `{{cwd}}` resolve from the agent's own route and workspace.
64
- - id: persona
65
- name: '@deepseek-ai/dsh-persona'
66
- config:
67
- # `{{model}}` / `{{cwd}}` 从本会话自己的路由与工作区解析。
68
- suffix: Your working directory is {{cwd}}.
69
- # ↓↓↓ Tita Data Agent 的提示词。**要改的就是这一段。** ↓↓↓
70
- prefix: |
71
- You are Tita Data Agent, the data analyst on this deployment. You are powered
72
- by the {{model}} model. Your job is to answer questions about this
73
- organisation's business with evidence, and to write down what you learn so the
74
- next answer is cheaper than this one.
75
-
76
- ## What you work with
77
-
78
- - **The knowledge store.** Each knowledge base is one directory holding three
79
- things. `knowledge.db` is the knowledge itself: SourceRaw (the original
80
- business documents, never rewritten, kept so a conclusion can point back at
81
- where it came from), the cards people read — one per entity, each with
82
- mandatory `source_refs`, each following a type (`concept`, `metric`, `table`,
83
- `event`, `playbook`, `case`) — and every version of both, plus who changed
84
- what and when. `derived.db` is what `recall_knowledge` actually searches:
85
- wikiNotes, a vector index, a knowledge graph and a keyword index; it is
86
- recomputed, never backed up. `assets/` holds images. There are no
87
- per-segment folders inside a base; use the knowledge tools, not the
88
- filesystem, to read or write documents. There can be several bases.
89
-
90
- - **The data surfaces, which are a different thing.** `workbook_*` reads and
91
- writes the workbooks the user has open; `notebook_*` runs SQL in the user's
92
- own browser. That is where a number is *computed*. The knowledge store is
93
- where a number is *defined* — a `metric` card says how it must be calculated,
94
- a `table` card says what one row means. Computing without the definition gets
95
- you a number nobody agreed to.
96
-
97
- - **Conversion.** `convert_source` turns a local file (including a web page
98
- saved to disk as `.html`) or a video into knowledge-ready Markdown and says
99
- where it landed. It never fetches a URL itself. It is not knowledge until
100
- `convert_ingest` has run, so keep saying which of the two steps you are on.
101
-
102
- ## Working rules
103
-
104
- 1. **Record the intent before the work.** Call `intent_record` with what the
105
- user wants and what you are about to do, before you do it. The vocabulary,
106
- and the rule for continuing existing work instead of starting a new task,
107
- live in that tool's own description. The record never gates the request:
108
- record, then continue.
109
- 2. **Recall before you answer about this organisation.** For its own rules,
110
- definitions, metrics, processes or history, call `recall_knowledge` first and
111
- answer from what comes back. An empty result is a finding, not a licence to
112
- improvise — say the store has nothing on it. The wiki layer answers "what does
113
- this organisation mean by X"; when you need "where exactly does it say that",
114
- or a card and the document behind it disagree, go read the source.
115
- 3. **Never invent a number.** Every figure you report must come from a tool
116
- result in this turn, and you must say which one. "I don't have that data" is
117
- a correct answer; a made-up number is not.
118
- 4. **Compiling is the normal path, and it writes cards by itself.** You do not
119
- have to create wiki cards: when a source is added or changed, `rebuild_knowledge`
120
- extracts entities from it, follows each wiki type's schema (required sections and
121
- fields), checks whether the wiki already has that entity, and either appends to
122
- the existing card or creates a new one. A card with missing sections is still
123
- written — the store keeps what it knows and fills the rest in when a later
124
- document covers it. So after adding a source, rebuild; then `recall_knowledge`
125
- and answer from what comes back. **More than one document at a time: use
126
- `import_sources`** — it writes the whole batch and compiles once, in one call.
127
- Ten documents through `add_source` means ten approvals and ten compiles, and the
128
- first nine results are thrown away by the tenth.
129
- 5. **You can add to the wiki, but you cannot rewrite it.** Call `propose_wiki_cards`
130
- with the `source_id` you just wrote and cards whose `source_refs` already exist in
131
- the store when you already have structured cards in hand — it writes them
132
- straight into `02_wiki`, they are recalled from the next compile on. A card whose
133
- refs point nowhere is rejected, and rightly so. **A card body is read-only**: it
134
- belongs to the compiler. When something in the store is wrong, or a card and its
135
- source disagree, do not rewrite it — attach an annotation with
136
- `annotate_wiki_card` (`kind: anomaly` when the numbers or definitions do not add
137
- up), or call `set_knowledge_status` to mark it `problem` and say what is wrong.
138
- Cards marked `problem` drop out of recall by default — that is how a wrong
139
- definition stops propagating. Everything else is reviewed by a human after entry:
140
- review raises a card's score, and an anomaly lowers it, but an
141
- anomaly-flagged card is still recalled.
142
- 6. **Never invent a knowledge base id.** Call `list_knowledge_bases` before
143
- addressing one you have not seen this session; omit `kb` only when the
144
- default base is genuinely the right one.
145
- 7. **Be concrete about uncertainty.** When sources disagree, present both and
146
- name them. When a conclusion rests on a single document, say so.
147
- 8. **Ask only what the user owns.** Which of two readings they meant, what
148
- matters more, what to do next — ask. Anything you can look up, look up
149
- instead of asking.
150
- 9. **Deliverables belong to the project, not to your home.** Write every file
151
- you produce for the user under `output/<YYYY-MM-DD>/` in your working
152
- directory, never into the Agent root: the Agent root accumulates across
153
- projects, a deliverable belongs to one. Name the file `<中文名>.<ext>` — at
154
- most 25 characters, keeping 汉字, letters, digits, `-`, `_` and `.`, and
155
- turning spaces and punctuation into `-` (so `销售汇总` stays `销售汇总`, and
156
- you write `月度销售汇总.xlsx`, not `output1.xlsx`). **Do not repeat the date
157
- in the file name**: the directory already carries it, and the name alone has
158
- to say what the file is a year later. Append `-2`, `-3` rather than
159
- overwriting, and say the path in your answer.
160
-
161
- ## How to write
162
-
163
- Answer in the user's language. Lead with the answer, then the evidence. Prefer
164
- a table when you are comparing things and a short paragraph when you are not.
165
- Skip preamble and praise; the user is here for the analysis.
166
- # ↑↑↑ Tita Data Agent 的提示词结束 ↑↑↑
167
-
168
- - id: agent-instructions
169
- name: '@deepseek-ai/dsh-agent-instructions'
170
- config:
171
- maxBytes: 65536
172
-
173
- # ── 意图记录(agent 平面)────────────────────────────────────────────────────
174
- #
175
- # 0029 之前这三个工具由知识插件在**宿主平面**全局注册,于是每个 agent、每个 preset
176
- # 的会话都会在提示词里看到 `intent_record`。现在它们只在这里挂载:这个模块只往
177
- # `tools` 注册表里塞定义、不 provide 任何服务,所以和随包的 `tool-fs` 一样不需要
178
- # realm,而它的注册只覆盖加入本 preset 的会话。
179
- #
180
- # 引擎本身(设置、轮次记账、`/intent/**` 只读面)仍在宿主平面,通过
181
- # `titaDataAgentIntent` 服务把操作面暴露给这一行 —— 引擎只有一份。
182
- - id: intent-tools
183
- name: 'dsh-data-domain-knowledge/intent-tools'
184
-
185
- # ── shell ───────────────────────────────────────────────────────────────────
186
-
187
- # `shell-env` stays in the HOST composition: `apps/cli/src/web.ts` injects it to
188
- # publish `DSH_WEB_URL`/`DSH_WEB_MODE`, and a host row that injects a service is
189
- # the criterion for host-plane ownership — injection resolves before any session
190
- # exists, so there is no agent to key by. Behind a preset realm those variables
191
- # never reached the model's shell at all. Both shell tools consume the host
192
- # registry from here; their executors (`bash-sandbox`/`pwsh-sandbox`) are
193
- # host-plane too.
194
- - id: tool-bash
195
- name: '@deepseek-ai/dsh-tool-bash'
196
- disabled: !!js process.platform === 'win32'
197
-
198
- - id: tool-pwsh
199
- name: '@deepseek-ai/dsh-tool-pwsh'
200
- disabled: !!js process.platform !== 'win32'
201
-
202
- # ── filesystem ──────────────────────────────────────────────────────────────
203
-
204
- # Both register into the host `tools` registry and provide nothing, so
205
- # they need no realm. The `fs` service and its policy stay in the host.
206
- - id: tool-fs
207
- name: '@deepseek-ai/dsh-tool-fs'
208
-
209
- - id: tool-fs-search
210
- name: '@deepseek-ai/dsh-tool-fs-search'
211
- config:
212
- sampleOverCapGlobResults: false
213
-
214
- # ── background jobs ────────────────────────────────────────────────────────
215
-
216
- # Only the model-facing controls. The task REGISTRY stays on the host plane:
217
- # its producers sit outside any realm this file could put it in — `tool-bash`
218
- # above resolves it with `ctx.get`, and an entry-local realm here is invisible
219
- # to every sibling row, so `run_in_background` would answer "background jobs
220
- # unavailable" while these controls sat in the catalog. The registry is keyed by
221
- # owning agent anyway, so one host instance serves every session. What a preset
222
- # chooses is whether its agent can collect and stop background work at all.
223
- - id: tool-jobs
224
- name: '@deepseek-ai/dsh-tool-jobs'
225
-
226
- # ── skills ──────────────────────────────────────────────────────────────────
227
-
228
- # The skill REGISTRY lives in the host composition and is layered per scope:
229
- # these rows register into THIS preset's layer of it, so they need no realm.
230
- # `skill-filesystem` contributes local-root discovery for agents on this preset, and
231
- # `tool-skill` gives them the catalog and loader; the merged catalog also
232
- # carries whatever the deployment registered globally (repository plugins).
233
- - id: skill-filesystem
234
- name: '@deepseek-ai/dsh-skill-filesystem'
235
-
236
- - id: tool-skill
237
- name: '@deepseek-ai/dsh-tool-skill'
238
-
239
- # ── goals ───────────────────────────────────────────────────────────────────
240
-
241
- # The goal service and session driver stay on the host plane, where the Gateway
242
- # can resolve them. The human command and model-facing tool register into this
243
- # preset's scoped layers.
244
- - id: command-goal
245
- name: '@deepseek-ai/dsh-command-goal'
246
-
247
- - id: tool-goal
248
- name: '@deepseek-ai/dsh-tool-goal'
249
-
250
- # ── plan mode ───────────────────────────────────────────────────────────────
251
-
252
- # Plan state is per-agent by nature, so an entry-local realm is not a
253
- # workaround here — it is the correct lifetime.
254
- - id: planning
255
- name: cordis:group
256
- group: true
257
- isolate:
258
- planMode: true
259
- config:
260
- - id: plan-mode
261
- name: '@deepseek-ai/dsh-plan-mode'
262
- config:
263
- section: |
264
- You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
265
-
266
- Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
267
-
268
- The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
269
-
270
- Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
271
-
272
- Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
273
-
274
- When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
275
-
276
- # ── compaction ──────────────────────────────────────────────────────────────
277
-
278
- # `compaction-basic` reads `toolResultPrune` through `ctx.get`, so the pruner must
279
- # share this realm rather than sit outside it.
280
- #
281
- # `tokenMeter` is deliberately NOT in this realm: the meter stays on the HOST
282
- # plane, and the rows here resolve that one instance. It takes no configuration,
283
- # keys every fold by Session, and owns the context-meter projection units the
284
- # browser reads for every session — behind a realm those units would come and go
285
- # with whichever presets happen to be mounted. What a preset chooses is whether
286
- # its agent compacts at all, which is `compaction-basic` below.
287
- - id: compaction
288
- name: cordis:group
289
- group: true
290
- isolate:
291
- compaction: true
292
- toolResultPruner: true
293
- config:
294
- - id: compaction-basic
295
- name: '@deepseek-ai/dsh-compaction-basic'
296
-
297
- - id: command-compact
298
- name: '@deepseek-ai/dsh-command-compact'
299
-
300
- - id: tool-result-pruner
301
- name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
302
- config:
303
- thresholdChars: 8192
304
- headChars: 4096
305
- tailChars: 1024
306
-
307
- # ── delegation and workflows ────────────────────────────────────────────────
308
-
309
- # The `subagents` registry and its spawn/fork backends live in the HOST
310
- # composition: the registry is a process singleton whose cross-session queries
311
- # the api-proxy serves to the browser, and a provider name may only be
312
- # registered once. This preset contributes the delegation TOOLS, which resolve
313
- # that host registry.
314
- #
315
- # `workflows` is different — nothing outside an agent reads it — so every row
316
- # that reaches it shares one entry-local realm here, and a consumer left
317
- # outside would resolve a host registry this preset does not populate.
318
- - id: delegation
319
- name: cordis:group
320
- group: true
321
- isolate:
322
- workflowEngine: true
323
- config:
324
- - id: tool-subagent-control
325
- name: '@deepseek-ai/dsh-tool-subagent-control'
326
-
327
- - id: tool-subagent-list-agents
328
- name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
329
-
330
- - id: tool-subagent
331
- name: '@deepseek-ai/dsh-tool-subagent'
332
- config:
333
- provider: spawn
334
- toolName: subagent
335
- modelSelectionSettings: true
336
- backgroundMode: continuable
337
- toolFilter:
338
- deny:
339
- - intent_record
340
- - intent_store_view
341
-
342
- # Fork omits model selection so provider/model stay equal to the parent and
343
- # the inherited history remains eligible for KV Cache reuse. This preset
344
- # keeps fork continuable; parent and child inherit the same messaging tool,
345
- # while the parent id and return guidance follow the inherited history.
346
- - id: tool-subagent-fork
347
- name: '@deepseek-ai/dsh-tool-subagent'
348
- config:
349
- provider: fork
350
- toolName: subagent_fork
351
- backgroundMode: continuable
352
- toolFilter:
353
- deny:
354
- - intent_record
355
- - intent_store_view
356
-
357
- # Production dsh does not install these optional providers. Install the
358
- # matching Bundle in this Profile and restart the Host, then copy this
359
- # preset and remove `disabled` from the matching tool row. Host availability
360
- # alone grants no tool.
361
- - id: tool-subagent-codex
362
- name: '@deepseek-ai/dsh-tool-subagent'
363
- disabled: true
364
- config:
365
- provider: codex
366
- toolName: subagent_codex
367
- backgroundMode: one-shot
368
- maxDepth: provider-managed
369
- toolFilter:
370
- deny:
371
- - intent_record
372
- - intent_store_view
373
-
374
- - id: tool-subagent-claude-code
375
- name: '@deepseek-ai/dsh-tool-subagent'
376
- disabled: true
377
- config:
378
- provider: claude-code
379
- toolName: subagent_claude_code
380
- backgroundMode: one-shot
381
- maxDepth: provider-managed
382
- toolFilter:
383
- deny:
384
- - intent_record
385
- - intent_store_view
386
-
387
- # 0.1.7 把这行换掉了:旧包名 `@deepseek-ai/dsh-workflow-worker-thread` 在
388
- # 0.1.7 的安装里已经不存在,对应物是 `@deepseek-ai/dsh-workflow-ptc`
389
- # (见 `dsh-web-app` 的 `presets/cordis.patch.yml`)。留着旧名不会报「找不到
390
- # 包」,而是让**整个 preset 挂载失败**,症状是它出现在 Agent 预设名单里、
391
- # 却带一条 `workflow-worker-thread (…): never started` 诊断 —— 这也是
392
- # 「自定义 agent 没生效」最像「配置没生效」的一种失败。
393
- - id: workflow-ptc
394
- name: '@deepseek-ai/dsh-workflow-ptc'
395
- config:
396
- provider: spawn
397
-
398
- - id: tool-workflow
399
- name: '@deepseek-ai/dsh-tool-workflow'
400
-
401
- - id: tool-ralph
402
- name: '@deepseek-ai/dsh-tool-ralph'
403
- config:
404
- subagentProvider: spawn
405
- maxRounds: 64
406
-
407
- # ── remaining model-facing rows ─────────────────────────────────────────────
408
-
409
- - id: tool-ask-user
410
- name: '@deepseek-ai/dsh-tool-ask-user'
411
-
412
- - id: tool-todo
413
- name: '@deepseek-ai/dsh-tool-todo'
414
- config:
415
- allowParallelInProgress: true
416
-
417
- # The `web` service and its search provider stay in the host composition; only
418
- # the model-facing tool is per-session.
419
- - id: tool-web
420
- name: '@deepseek-ai/dsh-tool-web'
421
- config:
422
- fetch: true
423
- searchTimeoutMs: 60000
424
-
425
- - id: present
426
- name: '@deepseek-ai/dsh-tool-present'
427
- # <<< agent preset (generated) <<<
package/eval/README.md CHANGED
@@ -1,19 +1,26 @@
1
1
  # Tita Knowledge Retrieval Evaluation
2
2
 
3
3
  `evaluate-retrieval.mjs` 对同一份已经编译好的 Knowledge Store,逐条运行
4
- `fts`、`vector`、`hybrid`,输出 Recall、MRR、nDCG 和 p50/p95 latency。它不自动
4
+ `fts`、`vector`、`hybrid`,输出 Recall、MRR、nDCG、弃答准确率和 p50/p95 latency。它不自动
5
5
  下载公开数据集,也不会改写知识库;公开数据集需要先转换为本插件的 qrels 格式。
6
6
 
7
7
  ## qrels 格式
8
8
 
9
9
  每行一个 JSON 对象,`relevant_unit_ids` 使用编译后的稳定 `unitId`,例如
10
10
  `metric:sales_amount`。可以附加 `include_problems` 和 `subset`,用于分组评测文本、
11
- 图片 Markdown、表格截图等场景。
11
+ 图片 Markdown、表格截图等场景。`subset` 当前保留在输入中;按子集运行时先分别生成
12
+ qrels 文件,runner 不自动输出子集汇总。
12
13
 
13
14
  ```json
14
15
  {"id":"q1","query":"销售额如何计算","relevant_unit_ids":["metric:sales_amount"],"subset":"text"}
16
+ {"id":"q2","query":"库内没有依据的问题","relevant_unit_ids":[],"subset":"abstention"}
15
17
  ```
16
18
 
19
+ 空 `relevant_unit_ids` 明确表示“不应召回”。必须提供这个字段,避免把漏标注误当作
20
+ 弃答样本。正例的 Recall、MRR、nDCG 只使用有正例的查询计算;弃答样本单独输出
21
+ `abstention.count`、`falseAnswers`(任何命中均计为误召回)和 `accuracy`。
22
+ 只有弃答样本时,正例指标为 `null`。接口失败会使评测失败,不会当作成功弃答。
23
+
17
24
  ## 本地运行
18
25
 
19
26
  先在 UI 点击一次「编译」,再运行:
@@ -21,7 +28,7 @@
21
28
  ```bash
22
29
  pnpm --filter dsh-data-domain-knowledge build
23
30
  node plugins/dsh-data-domain-knowledge/eval/evaluate-retrieval.mjs \
24
- --root "$HOME/.tita-data-agent/knowledge" \
31
+ --root "$HOME/.dsh/tita-agent/domain_knowledge/default" \
25
32
  --qrels plugins/dsh-data-domain-knowledge/eval/queries.example.jsonl
26
33
  ```
27
34
 
@@ -29,10 +36,10 @@ node plugins/dsh-data-domain-knowledge/eval/evaluate-retrieval.mjs \
29
36
 
30
37
  ```bash
31
38
  TITA_EVAL_PROVIDER=wemm-python \
32
- TITA_EVAL_PYTHON="$HOME/.tita-data-agent/embedding-venv/bin/python" \
33
- TITA_EVAL_MODEL="$HOME/.tita-data-agent/models/WeMM-Embedding-2B-Quantized" \
39
+ TITA_EVAL_PYTHON="$HOME/.dsh/tita-agent/resource/python/bin/python" \
40
+ TITA_EVAL_MODEL="$HOME/.dsh/tita-agent/resource/models/WeMM-Embedding-2B-Quantized" \
34
41
  node plugins/dsh-data-domain-knowledge/eval/evaluate-retrieval.mjs \
35
- --root "$HOME/.tita-data-agent/knowledge" \
42
+ --root "$HOME/.dsh/tita-agent/domain_knowledge/default" \
36
43
  --qrels ./queries.jsonl
37
44
  ```
38
45
 
@@ -61,12 +68,13 @@ checkpoint 编译后再跑同一份 qrels。每次比较固定知识卡片、qre
61
68
  评测,但它仍然是模型级评测,不是 Tita 端到端评测。
62
69
  3. Tita 专属 golden set:建议先人工标注 100–200 条查询,至少包含指标口径、表/字段
63
70
  语义、同义词、跨语言、图片中的 UI/图表信息、hard negative 和“不应召回”样本。
64
- 每条 query 标注 1–3 个正例 unitId;每轮发布前固定这份集合,新增样本走版本控制。
71
+ 有答案的 query 标注 1–3 个正例 unitId;不应召回的 query 使用空集合。每轮发布前
72
+ 固定这份集合,新增样本走版本控制。
65
73
 
66
74
  ## 指标与门槛
67
75
 
68
76
  主指标使用 `nDCG@10`、`Recall@10`、`MRR@10`,辅助看 `Recall@5/20`;同时记录
69
- 向量编译吞吐(units/min)、查询 p50/p95、模型常驻内存、`03_compiled` 索引大小和
77
+ 弃答准确率和误召回数。另行测量向量编译吞吐(units/min)、模型常驻内存、`derived.db` 大小和
70
78
  向量复用率。多模态集合要单独报告 text→image、image→text、text+image 三类结果,
71
79
  不能只看总平均。
72
80
 
@@ -74,3 +82,6 @@ checkpoint 编译后再跑同一份 qrels。每次比较固定知识卡片、qre
74
82
  至少应在语义改写和图片子集上带来可观增益;具体阈值在首轮 100–200 条标注跑完后再
75
83
  根据置信区间确定,不预先假设量化版一定优于 BF16。最终结果同时保存 qrels、配置、
76
84
  模型 revision、硬件和原始 JSON,确保可复现。
85
+
86
+ runner 关闭 cross-encoder 重排,比较原始召回路线。完整 Rerank 链路的质量要另行
87
+ 测量。自动化回归测试使用小型本地语料和模型替身,不构成真实模型质量门槛的验收结果。
@@ -0,0 +1,20 @@
1
+ import { encode as tokens } from 'gpt-tokenizer'
2
+ import { encodeExtractionTable, decodeExtractionTable } from '../lib/types/extract-table.js'
3
+
4
+ // Compare the same semantic payload with the same o200k_base tokenizer.
5
+ // This measures transport size, not model extraction accuracy or the provider's billing.
6
+ function payload(count) {
7
+ const quote = '经营报表核对前,需要先统一订单状态、统计周期和退款口径。'
8
+ const sources = [{ quote, heading_path: ['经营报表', '口径核验'] }]
9
+ return { subject: '经营报表', knowledge: Array.from({ length: count }, (_, index) => ({ id: `k${index+1}`, text: `第 ${index+1} 项核验:统一统计周期,并检查订单状态与退款口径。`, object: '经营报表', action: '核对', scene: '周报', section: '核验步骤', order: index+1, sources })), events: [], objects: [{ mention: '经营报表', definition: '经营指标报表', evidence: quote }], actions: [{ mention: '核对', definition: '核验报表口径', evidence: quote }], scenes: [{ mention: '周报', definition: '每周报表场景', evidence: quote }], dropped: [] }
10
+ }
11
+ const results = [1, 12, 40].map(count => {
12
+ const value = payload(count)
13
+ const table = encodeExtractionTable(value)
14
+ decodeExtractionTable(table)
15
+ const json = tokens(JSON.stringify(value)).length
16
+ const toon = tokens(table).length
17
+ return { knowledge: count, jsonTokens: json, tableTokens: toon, outputReduction: `${((1-toon/json)*100).toFixed(1)}%` }
18
+ })
19
+ console.table(results)
20
+ console.log('固定表头对小样本有额外开销;真实节省取决于行数、字段长度、引文重复率和所选模型的 tokenizer。')
@@ -56,8 +56,8 @@ if (!limits.length || !modes.length) usage('invalid --k or --modes')
56
56
  const lines = (await readFile(args.qrels, 'utf8')).split(/\r?\n/).map(line => line.trim()).filter(Boolean).filter(line => !line.startsWith('#'))
57
57
  const qrels = lines.map((line, index) => {
58
58
  const item = JSON.parse(line)
59
- const relevant = item.relevant_unit_ids ?? item.relevant ?? []
60
- if (!item.query || !Array.isArray(relevant) || relevant.length === 0) throw new Error(`qrels line ${index + 1} needs query and non-empty relevant_unit_ids`)
59
+ const relevant = item.relevant_unit_ids ?? item.relevant
60
+ if (!item.query || !Array.isArray(relevant)) throw new Error(`qrels line ${index + 1} needs query and relevant_unit_ids (empty means abstain)`)
61
61
  return { ...item, relevant_unit_ids: [...new Set(relevant.map(String))] }
62
62
  })
63
63
  if (!qrels.length) throw new Error('qrels is empty')
@@ -93,26 +93,35 @@ try {
93
93
  // is disabled and the raw fused ranking is measured.
94
94
  const response = await runtime.recall(qrel.query, maxLimit, qrel.include_problems === true, mode, undefined, { rerank: false })
95
95
  latencies.push(performance.now() - started)
96
+ if (!response.ok) throw new Error(`${qrel.id ?? qrel.query}: ${response.error?.code ?? 'RECALL_FAILED'}`)
96
97
  if (response.data.backend === 'fts' && mode !== 'fts') fallbackCount += 1
97
- rows.push({ hits: response.data.hits, relevant: new Set(qrel.relevant_unit_ids) })
98
+ rows.push({ hits: response.data.hits, relevant: new Set(qrel.relevant_unit_ids), subset: qrel.subset ?? 'default' })
98
99
  }
99
100
  const metrics = {}
100
101
  for (const limit of limits) {
101
102
  let recall = 0
102
103
  let mrr = 0
103
104
  let score = 0
104
- for (const row of rows) {
105
+ const positiveRows = rows.filter(row => row.relevant.size > 0)
106
+ for (const row of positiveRows) {
105
107
  const hits = row.hits.slice(0, limit)
106
108
  recall += hits.filter(hit => row.relevant.has(hit.unitId)).length / row.relevant.size
107
109
  const rank = hits.findIndex(hit => row.relevant.has(hit.unitId))
108
110
  mrr += rank < 0 ? 0 : 1 / (rank + 1)
109
111
  score += ndcg(row.hits, row.relevant, limit)
110
112
  }
111
- metrics[`recall@${limit}`] = Number((recall / rows.length).toFixed(4))
112
- metrics[`mrr@${limit}`] = Number((mrr / rows.length).toFixed(4))
113
- metrics[`ndcg@${limit}`] = Number((score / rows.length).toFixed(4))
113
+ const divisor = positiveRows.length || 1
114
+ metrics[`recall@${limit}`] = positiveRows.length ? Number((recall / divisor).toFixed(4)) : null
115
+ metrics[`mrr@${limit}`] = positiveRows.length ? Number((mrr / divisor).toFixed(4)) : null
116
+ metrics[`ndcg@${limit}`] = positiveRows.length ? Number((score / divisor).toFixed(4)) : null
117
+ }
118
+ const negativeRows = rows.filter(row => row.relevant.size === 0)
119
+ const falseAnswers = negativeRows.filter(row => row.hits.length > 0).length
120
+ output.modes[mode] = {
121
+ metrics, positiveCount: rows.length - negativeRows.length,
122
+ abstention: { count: negativeRows.length, falseAnswers, accuracy: negativeRows.length ? Number((1 - falseAnswers / negativeRows.length).toFixed(4)) : null },
123
+ latencyMs: { p50: percentile(latencies, 0.5), p95: percentile(latencies, 0.95) }, fallbackCount,
114
124
  }
115
- output.modes[mode] = { metrics, latencyMs: { p50: percentile(latencies, 0.5), p95: percentile(latencies, 0.95) }, fallbackCount }
116
125
  }
117
126
  } finally {
118
127
  runtime.close()
@@ -1,2 +1,3 @@
1
1
  {"id":"q-agent-architecture","query":"知识编译与召回的 Agent 架构","relevant_unit_ids":["concept:agent_architecture"],"subset":"text"}
2
2
  {"id":"q-ui-architecture","query":"Tita 数据 Agent 的界面和架构","relevant_unit_ids":["concept:agent_architecture","concept:ui_reference"],"subset":"text-image"}
3
+ {"id":"q-no-evidence","query":"火星香蕉的年度产量是多少","relevant_unit_ids":[],"subset":"abstention"}