dsh-plugin-dev-kb 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/CHANGELOG.md +186 -178
  2. package/README.en.md +172 -172
  3. package/README.md +183 -183
  4. package/kb/INDEX.md +236 -234
  5. package/kb/README.md +88 -88
  6. package/kb/extra/AGENTS.md +77 -77
  7. package/kb/extra/deepseek-llm-api-wire-extensions.md +162 -162
  8. package/kb/extra/deepseek-llm-api-wire-extensions.zh.md +162 -162
  9. package/kb/extra/defensive-patterns/package-surface.md +233 -232
  10. package/kb/extra/defensive-patterns/package-surface.zh.md +233 -232
  11. package/kb/extra/defensive-patterns/remote-and-api.md +117 -117
  12. package/kb/extra/defensive-patterns/remote-and-api.zh.md +117 -117
  13. package/kb/extra/development.md +221 -221
  14. package/kb/extra/development.zh.md +228 -228
  15. package/kb/extra/event-producer-consumer.md +133 -123
  16. package/kb/extra/event-producer-consumer.zh.md +135 -125
  17. package/kb/extra/module-graph.md +1961 -1888
  18. package/kb/extra/module-graph.zh.md +1963 -1890
  19. package/kb/extra/persistence-changes/2026-11-05-timeline-priority-notice.md +60 -0
  20. package/kb/extra/persistence-changes/2026-11-05-timeline-priority-notice.zh.md +60 -0
  21. package/kb/extra/persistence-changes/README.md +92 -92
  22. package/kb/extra/persistence-changes/README.zh.md +92 -92
  23. package/kb/extra/persistence-changes/historical-formats/README.md +75 -75
  24. package/kb/extra/persistence-changes/historical-formats/README.zh.md +75 -75
  25. package/kb/extra/persistence-changes/releases/README.md +103 -103
  26. package/kb/extra/persistence-changes/releases/README.zh.md +103 -103
  27. package/kb/extra/rescope.md +55 -55
  28. package/kb/extra/rescope.zh.md +55 -55
  29. package/kb/extra/subsystems/boot.md +631 -621
  30. package/kb/extra/subsystems/boot.zh.md +631 -621
  31. package/kb/extra/subsystems/computer-use.md +179 -137
  32. package/kb/extra/subsystems/computer-use.zh.md +179 -137
  33. package/kb/extra/subsystems/extensions.md +387 -384
  34. package/kb/extra/subsystems/extensions.zh.md +387 -384
  35. package/kb/extra/subsystems/feedback.md +418 -400
  36. package/kb/extra/subsystems/feedback.zh.md +418 -400
  37. package/kb/extra/subsystems/forge.md +2169 -1226
  38. package/kb/extra/subsystems/forge.zh.md +2171 -1226
  39. package/kb/extra/subsystems/liveshare.md +167 -158
  40. package/kb/extra/subsystems/liveshare.zh.md +167 -158
  41. package/kb/extra/subsystems/mcp.md +237 -234
  42. package/kb/extra/subsystems/mcp.zh.md +237 -234
  43. package/kb/extra/subsystems/office-kit.md +122 -0
  44. package/kb/extra/subsystems/office-kit.zh.md +122 -0
  45. package/kb/extra/subsystems/working-directory.md +95 -64
  46. package/kb/extra/subsystems/working-directory.zh.md +95 -64
  47. package/kb/extra/subsystems/worktrees.md +187 -127
  48. package/kb/extra/subsystems/worktrees.zh.md +187 -127
  49. package/kb/extra/upgrade-guide/v0.2.1-alpha.1/python-ptc-sandbox/guide.md +21 -21
  50. package/kb/extra/upgrade-guide/v0.2.1-alpha.1/python-ptc-sandbox/guide.zh.md +21 -21
  51. package/kb/extra/upgrade-guide/v0.2.1-rc.4/sandbox-unsupported-policy-error/guide.md +18 -0
  52. package/kb/extra/upgrade-guide/v0.2.1-rc.4/sandbox-unsupported-policy-error/guide.zh.md +18 -0
  53. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/llm-error-builtin-codes/guide.md +18 -0
  54. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/llm-error-builtin-codes/guide.zh.md +18 -0
  55. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-kit-package/guide.md +34 -0
  56. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-kit-package/guide.zh.md +34 -0
  57. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-operation-tools/guide.md +49 -0
  58. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-operation-tools/guide.zh.md +49 -0
  59. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-skill-resources/guide.md +36 -0
  60. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-skill-resources/guide.zh.md +36 -0
  61. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-notification-fields/guide.md +26 -0
  62. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-notification-fields/guide.zh.md +26 -0
  63. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-remote-provider/guide.md +22 -0
  64. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-remote-provider/guide.zh.md +22 -0
  65. package/kb/extra/upgrade-guide/v0.2.2-rc.1/archive-worktrees/guide.md +21 -0
  66. package/kb/extra/upgrade-guide/v0.2.2-rc.1/archive-worktrees/guide.zh.md +21 -0
  67. package/kb/extra/upgrade-guide/v0.2.2-rc.1/attachment-error-codes/guide.md +23 -0
  68. package/kb/extra/upgrade-guide/v0.2.2-rc.1/attachment-error-codes/guide.zh.md +23 -0
  69. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-ax-read-limits/guide.md +20 -0
  70. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-ax-read-limits/guide.zh.md +20 -0
  71. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-hover-ax-only/guide.md +18 -0
  72. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-hover-ax-only/guide.zh.md +18 -0
  73. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-native-platform/guide.md +23 -0
  74. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-native-platform/guide.zh.md +23 -0
  75. package/kb/extra/upgrade-guide/v0.2.2-rc.1/dsh-doc-skill/guide.md +35 -0
  76. package/kb/extra/upgrade-guide/v0.2.2-rc.1/dsh-doc-skill/guide.zh.md +35 -0
  77. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-change-request-overview/guide.md +26 -0
  78. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-change-request-overview/guide.zh.md +26 -0
  79. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-pinned-diff/guide.md +26 -0
  80. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-pinned-diff/guide.zh.md +26 -0
  81. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-review-reads/guide.md +19 -0
  82. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-review-reads/guide.zh.md +19 -0
  83. package/kb/extra/upgrade-guide/v0.2.2-rc.1/package-export-cleanup/guide.md +26 -0
  84. package/kb/extra/upgrade-guide/v0.2.2-rc.1/package-export-cleanup/guide.zh.md +26 -0
  85. package/kb/extra/upgrade-guide/v0.2.2-rc.1/plugin-update-method/guide.md +22 -0
  86. package/kb/extra/upgrade-guide/v0.2.2-rc.1/plugin-update-method/guide.zh.md +22 -0
  87. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-bootstrap-protocol/guide.md +25 -0
  88. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-bootstrap-protocol/guide.zh.md +25 -0
  89. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-inspect-output/guide.md +48 -0
  90. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-inspect-output/guide.zh.md +48 -0
  91. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-scoped-repl-default/guide.md +45 -0
  92. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-scoped-repl-default/guide.zh.md +45 -0
  93. package/kb/extra/upgrade-guide/v0.2.2-rc.1/runtime-context-reminders/guide.md +19 -0
  94. package/kb/extra/upgrade-guide/v0.2.2-rc.1/runtime-context-reminders/guide.zh.md +19 -0
  95. package/kb/extra/upgrade-guide/v0.2.2-rc.1/session-append-overloads/guide.md +17 -0
  96. package/kb/extra/upgrade-guide/v0.2.2-rc.1/session-append-overloads/guide.zh.md +17 -0
  97. package/kb/extra/upgrade-guide/v0.2.2-rc.1/subagent-interrupt-default/guide.md +27 -0
  98. package/kb/extra/upgrade-guide/v0.2.2-rc.1/subagent-interrupt-default/guide.zh.md +27 -0
  99. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-backend-cleanup-error/guide.md +20 -0
  100. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-backend-cleanup-error/guide.zh.md +20 -0
  101. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-bundle-sidebar-backend/guide.md +19 -0
  102. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-bundle-sidebar-backend/guide.zh.md +19 -0
  103. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-fetch-transport-error-codes/guide.md +18 -0
  104. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-fetch-transport-error-codes/guide.zh.md +18 -0
  105. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-search-billing/guide.md +41 -0
  106. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-search-billing/guide.zh.md +41 -0
  107. package/kb/extra/upgrade-guide/v0.2.2-rc.1/window-drag-regions/guide.md +21 -0
  108. package/kb/extra/upgrade-guide/v0.2.2-rc.1/window-drag-regions/guide.zh.md +21 -0
  109. package/kb/extra/upgrade-guide/v0.2.2-rc.2/client-module-metadata/guide.md +29 -0
  110. package/kb/extra/upgrade-guide/v0.2.2-rc.2/client-module-metadata/guide.zh.md +29 -0
  111. package/kb/extra/upgrade-guide/v0.2.2-rc.2/connection-page-peer/guide.md +25 -0
  112. package/kb/extra/upgrade-guide/v0.2.2-rc.2/connection-page-peer/guide.zh.md +25 -0
  113. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cordis-root-and-intercept-metadata/guide.md +31 -0
  114. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cordis-root-and-intercept-metadata/guide.zh.md +31 -0
  115. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-agents-without-preset/guide.md +24 -0
  116. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-agents-without-preset/guide.zh.md +24 -0
  117. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-macos-provider/guide.md +24 -0
  118. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-macos-provider/guide.zh.md +24 -0
  119. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-partial-observations/guide.md +19 -0
  120. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-partial-observations/guide.zh.md +19 -0
  121. package/kb/extra/upgrade-guide/v0.2.2-rc.2/deepseek-files-timeout/guide.md +15 -0
  122. package/kb/extra/upgrade-guide/v0.2.2-rc.2/deepseek-files-timeout/guide.zh.md +15 -0
  123. package/kb/extra/upgrade-guide/v0.2.2-rc.2/experimental-tool-error-codes/guide.md +28 -0
  124. package/kb/extra/upgrade-guide/v0.2.2-rc.2/experimental-tool-error-codes/guide.zh.md +28 -0
  125. package/kb/extra/upgrade-guide/v0.2.2-rc.2/package-export-cleanup/guide.md +36 -0
  126. package/kb/extra/upgrade-guide/v0.2.2-rc.2/package-export-cleanup/guide.zh.md +36 -0
  127. package/kb/extra/upgrade-guide/v0.2.2-rc.2/python-ptc-removal/guide.md +22 -0
  128. package/kb/extra/upgrade-guide/v0.2.2-rc.2/python-ptc-removal/guide.zh.md +22 -0
  129. package/kb/extra/upgrade-guide/v0.2.2-rc.2/session-status-package/guide.md +31 -0
  130. package/kb/extra/upgrade-guide/v0.2.2-rc.2/session-status-package/guide.zh.md +31 -0
  131. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shared-search-filter/guide.md +18 -0
  132. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shared-search-filter/guide.zh.md +18 -0
  133. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shell-fs-tool-error-codes/guide.md +30 -0
  134. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shell-fs-tool-error-codes/guide.zh.md +30 -0
  135. package/kb/extra/web-styling.md +57 -57
  136. package/kb/extra/web-styling.zh.md +57 -57
  137. package/kb/meta/search-index.json +4508 -3980
  138. package/kb/meta/source.json +18 -18
  139. package/kb/site/develop/practice/llm-adapter.md +192 -192
  140. package/kb/site/en/develop/practice/llm-adapter.md +192 -192
  141. package/kb/site/en/guide/desktop-uninstall-cleanup.md +63 -0
  142. package/kb/site/en/guide/plugin-market.md +153 -151
  143. package/kb/site/en/guide/providers.md +234 -234
  144. package/kb/site/en/guide/quickstart.md +35 -34
  145. package/kb/site/en/reference/capability-seams.md +789 -767
  146. package/kb/site/en/reference/config-catalog.md +5432 -5128
  147. package/kb/site/en/reference/cookbook/adding-a-package.md +175 -175
  148. package/kb/site/en/reference/cookbook/adding-a-tool.md +105 -104
  149. package/kb/site/en/reference/cookbook/extension-cookbook.md +178 -135
  150. package/kb/site/en/reference/cordis-api/context.md +373 -369
  151. package/kb/site/en/reference/cordis-api/fiber.md +457 -433
  152. package/kb/site/en/reference/cordis-api/inherited.md +44 -44
  153. package/kb/site/en/reference/cordis-api/service.md +118 -107
  154. package/kb/site/en/reference/experimental-persistence-catalog.md +36 -23
  155. package/kb/site/en/reference/index.md +174 -174
  156. package/kb/site/en/reference/persistence-catalog.md +9453 -9432
  157. package/kb/site/en/reference/subsystems/compaction.md +288 -288
  158. package/kb/site/en/reference/subsystems/core.md +1172 -1171
  159. package/kb/site/en/reference/subsystems/credentials.md +526 -497
  160. package/kb/site/en/reference/subsystems/filesystem.md +708 -708
  161. package/kb/site/en/reference/subsystems/index.md +82 -82
  162. package/kb/site/en/reference/subsystems/llm-streaming.md +1290 -1288
  163. package/kb/site/en/reference/subsystems/lsp.md +230 -206
  164. package/kb/site/en/reference/subsystems/persistence.md +451 -432
  165. package/kb/site/en/reference/subsystems/plan.md +91 -91
  166. package/kb/site/en/reference/subsystems/ptc-runtime.md +295 -261
  167. package/kb/site/en/reference/subsystems/sandbox.md +250 -232
  168. package/kb/site/en/reference/subsystems/session-query.md +525 -515
  169. package/kb/site/en/reference/subsystems/session-reference.md +231 -229
  170. package/kb/site/en/reference/subsystems/session.md +1478 -1431
  171. package/kb/site/en/reference/subsystems/sidebar-right.md +165 -165
  172. package/kb/site/en/reference/subsystems/skills.md +356 -356
  173. package/kb/site/en/reference/subsystems/slots.md +235 -231
  174. package/kb/site/en/reference/subsystems/terminal.md +188 -188
  175. package/kb/site/en/reference/subsystems/tools.md +902 -891
  176. package/kb/site/en/reference/subsystems/user-questions.md +330 -327
  177. package/kb/site/en/reference/subsystems/web-client.md +161 -104
  178. package/kb/site/en/reference/subsystems/web-server.md +434 -351
  179. package/kb/site/en/reference/subsystems/web.md +268 -268
  180. package/kb/site/en/reference/subsystems/workflow.md +287 -282
  181. package/kb/site/en/reference/subsystems/workspace.md +743 -651
  182. package/kb/site/en/reference/tool-catalog.md +2867 -2704
  183. package/kb/site/guide/desktop-uninstall-cleanup.md +63 -0
  184. package/kb/site/guide/plugin-market.md +153 -151
  185. package/kb/site/guide/providers.md +234 -234
  186. package/kb/site/guide/quickstart.md +35 -34
  187. package/kb/site/reference/capability-seams.md +789 -767
  188. package/kb/site/reference/config-catalog.md +5432 -5128
  189. package/kb/site/reference/cookbook/adding-a-package.md +175 -175
  190. package/kb/site/reference/cookbook/adding-a-tool.md +107 -106
  191. package/kb/site/reference/cookbook/extension-cookbook.md +182 -139
  192. package/kb/site/reference/cordis-api/context.md +373 -369
  193. package/kb/site/reference/cordis-api/fiber.md +459 -435
  194. package/kb/site/reference/cordis-api/inherited.md +44 -44
  195. package/kb/site/reference/cordis-api/service.md +118 -107
  196. package/kb/site/reference/experimental-persistence-catalog.md +36 -23
  197. package/kb/site/reference/index.md +178 -178
  198. package/kb/site/reference/persistence-catalog.md +9453 -9432
  199. package/kb/site/reference/subsystems/compaction.md +288 -288
  200. package/kb/site/reference/subsystems/core.md +1184 -1183
  201. package/kb/site/reference/subsystems/credentials.md +526 -497
  202. package/kb/site/reference/subsystems/filesystem.md +708 -708
  203. package/kb/site/reference/subsystems/index.md +82 -82
  204. package/kb/site/reference/subsystems/llm-streaming.md +1296 -1294
  205. package/kb/site/reference/subsystems/lsp.md +230 -206
  206. package/kb/site/reference/subsystems/persistence.md +451 -432
  207. package/kb/site/reference/subsystems/plan.md +91 -91
  208. package/kb/site/reference/subsystems/ptc-runtime.md +295 -261
  209. package/kb/site/reference/subsystems/sandbox.md +250 -232
  210. package/kb/site/reference/subsystems/session-query.md +525 -515
  211. package/kb/site/reference/subsystems/session-reference.md +231 -229
  212. package/kb/site/reference/subsystems/session.md +1482 -1435
  213. package/kb/site/reference/subsystems/sidebar-right.md +165 -165
  214. package/kb/site/reference/subsystems/skills.md +356 -356
  215. package/kb/site/reference/subsystems/slots.md +239 -235
  216. package/kb/site/reference/subsystems/terminal.md +188 -188
  217. package/kb/site/reference/subsystems/tools.md +902 -891
  218. package/kb/site/reference/subsystems/user-questions.md +330 -327
  219. package/kb/site/reference/subsystems/web-client.md +161 -104
  220. package/kb/site/reference/subsystems/web-server.md +434 -351
  221. package/kb/site/reference/subsystems/web.md +268 -268
  222. package/kb/site/reference/subsystems/workflow.md +287 -282
  223. package/kb/site/reference/subsystems/workspace.md +743 -651
  224. package/kb/site/reference/tool-catalog.md +2872 -2709
  225. package/lib/index.js +359 -359
  226. package/package.json +68 -68
  227. package/skills/dsh-plugin-dev-kb.md +71 -70
  228. package/kb/extra/subsystems/office-to-pdf.md +0 -87
  229. package/kb/extra/subsystems/office-to-pdf.zh.md +0 -87
@@ -1,515 +1,525 @@
1
- ---
2
- editSource: "docs/subsystems/session-query.md"
3
- rawMarkdownPath: "en/reference/subsystems/session-query.md"
4
- outline: [2,3]
5
- ---
6
-
7
- # Session Query
8
-
9
- Query vocabulary over the live-preferred logical session corpus. The [Service Definition package](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/session-query/session-query) owns exact reads, source precedence, relationship tracing, semantic extraction, and provider-independent filters, while the [SQLite provider](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/session-query/session-query-sqlite) owns the concrete full-text index lifecycle.
10
-
11
- Source: [`packages/session-query/session-query/src/types.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session-query/session-query/src/types.ts)
12
-
13
- ## Logical records
14
-
15
- `SessionRecord` is returned by the cross-corpus list. It exposes source availability independently from the cloned live-preferred header. `SessionEventRecord` is a lightweight raw-log projection; classification uses the same `foldSurface()` transitions as model-history derivation.
16
-
17
- ```ts type-equiv
18
- /** Whether an event is current model context, replaced context, or raw-log-only. */
19
- type SessionEventSurface = 'current' | 'shadowed' | 'log-only'
20
- ```
21
-
22
- ```ts type-equiv
23
- /** Lightweight identity and source availability for one logical session. */
24
- interface SessionRecord {
25
- /** Cloned session header selected from the live-preferred corpus. */
26
- header: SessionHeader
27
- /** Whether the id currently exists in `ctx.sessions`. */
28
- live: boolean
29
- /** Whether the active persistence backend currently lists the id, including a created-but-unmaterialized session it already observes. */
30
- persisted: boolean
31
- /** Current for live Sessions; otherwise the persistence format status when reported. */
32
- formatStatus?: 'current' | 'migration-required'
33
- }
34
- ```
35
-
36
- `SessionLogSnapshot` is the complete detached, replay-validated raw log used by resume preflight. `SessionSurfaceSnapshot` is one exact-read surface observation rather than a retained subscription.
37
-
38
- ```ts type-equiv
39
- /** One validated detached observation of a logical session's complete raw log. */
40
- interface SessionLogSnapshot {
41
- /** Cloned session header selected from the same observation as `events`. */
42
- session: SessionHeader
43
- /** Exact number of fork-inherited events in the observed log. */
44
- inheritedEventCount: SessionLogOffset
45
- /** Cloned contiguous raw events after in-memory interrupted-turn balancing and replay validation. */
46
- events: SessionEvent[]
47
- }
48
- ```
49
-
50
- ```ts type-equiv
51
- /** One atomic live-preferred observation of a session's current model surface. */
52
- interface SessionSurfaceSnapshot {
53
- /** Cloned session header selected from the same corpus observation as `events`. */
54
- session: SessionHeader
55
- /** Exact number of fork-inherited events in the observed log. */
56
- inheritedEventCount: SessionLogOffset
57
- /** Highest raw-log seq included in the observation, or `null` for an empty log. */
58
- capturedThroughSeq: OptionalSessionSeq
59
- /** Cloned current surface events in model-history order. */
60
- events: SurfaceEvent[]
61
- }
62
- ```
63
-
64
- `SessionTitleObservation` applies the same atomic-observation rule to title folding, so an authorization consumer can validate the source header that supplied the title. Batch reads return one ordered `SessionTitleObservationResult` per unique requested id: operational failures remain local to that id, while cancellation rejects the complete operation.
65
-
66
- ```ts type-equiv
67
- /** Latest folded title bound to the same session-header observation. */
68
- interface SessionTitleObservation {
69
- /** Cloned header selected with the event log used for the title fold. */
70
- session: SessionHeader
71
- /** Latest title snapshot, absent when the observed log has no title. */
72
- title?: SessionTitleSnapshot
73
- }
74
- ```
75
-
76
- ```ts type-equiv
77
- /** One ordered result from a batch title observation. */
78
- type SessionTitleObservationResult =
79
- | {
80
- /** Requested session id. */
81
- sessionId: SessionId
82
- /** Successful atomic header/title observation. */
83
- status: 'fulfilled'
84
- /** Header and optional latest title from one logical source. */
85
- value: SessionTitleObservation
86
- }
87
- | {
88
- /** Requested session id. */
89
- sessionId: SessionId
90
- /** Operational failure isolated to this session. */
91
- status: 'rejected'
92
- /** Original failure from logical-source resolution or title folding. */
93
- reason: unknown
94
- }
95
- ```
96
-
97
- ```ts type-equiv
98
- /** Lightweight metadata for one event within a logical session. */
99
- interface SessionEventRecord {
100
- /** Session that owns the event. */
101
- sessionId: SessionId
102
- /** Monotonic event seq within the session. */
103
- seq: SessionSeq
104
- /** Discriminant of the session event. */
105
- type: SessionEventType
106
- /** Event timestamp in Unix epoch milliseconds. */
107
- time: number
108
- /** Event placement in the folded session surface. */
109
- surface: SessionEventSurface
110
- }
111
- ```
112
-
113
- ## Provider-independent filters and documents
114
-
115
- Session and event filter arrays are ANDed; values inside one list clause are ORed. Ranges are inclusive. The event `text` clause is a literal Unicode case-insensitive, whitespace-flexible regular-expression scan over extracted semantic text, independent of full-text providers.
116
-
117
- ```ts type-equiv
118
- /**
119
- * One logical-session predicate. A filter array is ANDed; `values` within a
120
- * clause are ORed.
121
- */
122
- type SessionResultFilter =
123
- | { kind: 'id'; values: readonly SessionId[] }
124
- | { kind: 'cwd'; values: readonly (string | null)[] }
125
- | ({ kind: 'created-at' } & SessionResultRange)
126
- | { kind: 'parent'; values: readonly (SessionId | null)[] }
127
- | { kind: 'availability'; values: readonly SessionAvailability[] }
128
- ```
129
-
130
- ```ts type-equiv
131
- /**
132
- * One event predicate. A filter array is ANDed; list-valued clauses are ORed.
133
- * Text is a literal, case-insensitive, whitespace-flexible semantic-text scan.
134
- */
135
- type SessionEventResultFilter =
136
- | ({ kind: 'seq' } & SessionResultRange)
137
- | ({ kind: 'time' } & SessionResultRange)
138
- | { kind: 'type'; values: readonly SessionEventType[] }
139
- | { kind: 'surface'; values: readonly SessionEventSurface[] }
140
- | { kind: 'text'; text: string }
141
- ```
142
-
143
- ```ts type-equiv
144
- /** Searchable semantic document derived from one session event. */
145
- interface SessionEventSearchDocument extends SessionEventRecord {
146
- /** First-party semantic text used by scan filters and full-text indexes. */
147
- text: string
148
- }
149
- ```
150
-
151
- `ctx.sessionQuery.filterSessions(filters)` applies `SessionResultFilter` to the complete logical corpus; `ctx.sessionQuery.filterEvents(sessionId, filters)` returns matching documents in ascending seq order. Messages, tool calls/results, todos, and failure/status detail contribute semantic text; reasoning blocks, blocked prompts, structural events, and stream chunks do not.
152
-
153
- ## Full-text search pages
154
-
155
- The combined `ctx.sessionQuery` seam has two full-text scopes. `searchSessions()` groups the corpus by strongest matching event; `searchEvents()` searches one session. Requests bind an opaque cursor to the normalized query, metadata filters, and limit. The event text scan is intentionally absent from provider metadata filters.
156
-
157
- ```ts type-equiv
158
- /** Provider-owned opaque continuation token returned by session search. */
159
- type SessionSearchCursor = Branded<'SessionSearchCursor'>
160
- ```
161
-
162
- ```ts type-equiv
163
- /** Cross-session full-text search request. */
164
- interface SessionSearchRequest {
165
- /** Full-text query interpreted as data, never executable FTS syntax. */
166
- query: string
167
- /** Logical-session predicates applied before event ranking. */
168
- sessionFilters?: readonly SessionResultFilter[]
169
- /** Event predicates applied before event ranking. */
170
- eventFilters?: readonly SessionEventMetadataFilter[]
171
- /** Maximum sessions in this page. */
172
- limit?: number
173
- /** Opaque cursor returned for the identical normalized request. */
174
- cursor?: SessionSearchCursor
175
- }
176
- ```
177
-
178
- ```ts type-equiv
179
- /** Within-session full-text search request. */
180
- interface SessionEventSearchRequest {
181
- /** Session whose live-preferred logical log is searched. */
182
- sessionId: SessionId
183
- /** Full-text query interpreted as data, never executable FTS syntax. */
184
- query: string
185
- /** Event predicates applied before ranking. */
186
- filters?: readonly SessionEventMetadataFilter[]
187
- /** Maximum events in this page. */
188
- limit?: number
189
- /** Opaque cursor returned for the identical normalized request. */
190
- cursor?: SessionSearchCursor
191
- }
192
- ```
193
-
194
- ```ts type-equiv
195
- /** One cursor-paginated result page. */
196
- interface SessionSearchPage<T> {
197
- /** Results for this page in contract-defined order. */
198
- items: readonly T[]
199
- /** Opaque continuation cursor, absent on the final page. */
200
- nextCursor?: SessionSearchCursor
201
- }
202
- ```
203
-
204
- Unlike grouped cross-session hits, a within-session search must also expose its observed target header even when the page contains no hits.
205
-
206
- ```ts type-equiv
207
- /** Event-search results bound to the indexed target-session observation. */
208
- interface SessionEventSearchPage extends SessionSearchPage<SessionEventSearchHit> {
209
- /** Cloned target header from the same indexed generation as `items`. */
210
- session: SessionHeader
211
- }
212
- ```
213
-
214
- ```ts type-equiv
215
- /** One event full-text search hit with a bounded plain-text excerpt. */
216
- interface SessionEventSearchHit extends SessionEventRecord {
217
- /** Plain text excerpt selected around the match. */
218
- snippet: string
219
- }
220
- ```
221
-
222
- ```ts type-equiv
223
- /** One grouped cross-session hit, ranked by its strongest matching event. */
224
- interface SessionSearchHit extends SessionRecord {
225
- /** Strongest matching event for this session. */
226
- bestMatch: SessionEventSearchHit
227
- }
228
- ```
229
-
230
- ## Session lineage
231
-
232
- `SessionLineageTrace` carries known parents in immediate-to-outward order and a forest of recursively nested direct descendants. The completeness discriminant makes a known root and a missing parent mutually exclusive.
233
-
234
- ```ts type-equiv
235
- /** Recursive descendant node in a session-lineage trace. */
236
- interface SessionLineageNode {
237
- /** Detached logical-corpus record for this descendant. */
238
- session: SessionRecord
239
- /** Direct children, each carrying its own recursive descendants. */
240
- descendants: SessionLineageNode[]
241
- }
242
- ```
243
-
244
- ```ts type-equiv
245
- /** Known ancestry and descendants for one logical session. */
246
- type SessionLineageTrace = {
247
- /** Detached record for the session that was traced. */
248
- target: SessionRecord
249
- /** Known parents from the immediate parent outward. */
250
- ancestors: SessionRecord[]
251
- /** Complete known descendant trees rooted at the target's direct children. */
252
- descendants: SessionLineageNode[]
253
- } & (
254
- | {
255
- /** The complete parent chain is present in the logical corpus. */
256
- complete: true
257
- /** Detached record at the top of the complete lineage. */
258
- root: SessionRecord
259
- }
260
- | {
261
- /** The parent chain leaves the visible logical corpus. */
262
- complete: false
263
- /** First parent id that is not present in the logical corpus. */
264
- unresolvedParentId: SessionId
265
- }
266
- )
267
- ```
268
-
269
- ## Bounded event reads
270
-
271
- The request addresses one raw seq and optional neighboring counts. The result carries a `SessionHeader` rather than availability flags so a known live target can remain independent of persistence health.
272
-
273
- ```ts type-equiv
274
- /** Request for one event plus raw neighboring log context. */
275
- interface SessionEventReadRequest {
276
- /** Session that owns the target event. */
277
- sessionId: SessionId
278
- /** Target event seq. */
279
- seq: SessionSeq
280
- /** Number of preceding raw events to include. */
281
- before?: number
282
- /** Number of following raw events to include. */
283
- after?: number
284
- }
285
- ```
286
-
287
- ```ts type-equiv
288
- /** Full target event and a bounded raw-log window. */
289
- interface SessionEventWindow {
290
- /** Cloned header for the live-preferred source read. */
291
- session: SessionHeader
292
- /** Exact number of fork-inherited events in the observed log. */
293
- inheritedEventCount: SessionLogOffset
294
- /** Full cloned target event. */
295
- target: SessionEvent
296
- /** Full cloned events from `startSeq` through `endSeq`. */
297
- events: SessionEvent[]
298
- /** First seq included in `events`. */
299
- startSeq: SessionSeq
300
- /** Last seq included in `events`. */
301
- endSeq: SessionSeq
302
- }
303
- ```
304
-
305
- ## Event relationships
306
-
307
- Event traces distinguish positional surface replacement from events cited as sources. Every seq list contains direct links except `replacementChain`, which follows immediate replacers from the target to the final positional replacement.
308
-
309
- ```ts type-equiv
310
- /** Request for direct surface replacements and relationships to cited source events around one event. */
311
- interface SessionEventTraceRequest {
312
- /** Session that owns the target event. */
313
- sessionId: SessionId
314
- /** Target event seq. */
315
- seq: SessionSeq
316
- }
317
- ```
318
-
319
- ```ts type-equiv
320
- /** Direct surface replacements and relationships to cited source events for one event. */
321
- interface SessionEventTrace {
322
- /** Lightweight target record. */
323
- target: SessionEventRecord
324
- /** Immediate positional replacement event, when the target was shadowed. */
325
- replacedBy?: SessionSeq
326
- /** Positional replacers from the immediate replacement to the final replacement. */
327
- replacementChain: SessionSeq[]
328
- /** Surface nodes directly removed when the target itself performed a replacement. */
329
- replacedEventSeqs: SessionSeq[]
330
- /** Earlier events cited directly as sources, in their recorded order. */
331
- sourceEventSeqs: SessionSeq[]
332
- /** Later events that directly cite the target as a source, in log order. */
333
- derivedEventSeqs: SessionSeq[]
334
- }
335
- ```
336
-
337
- ```ts type-equiv
338
- /** Event relationships bound to the same session-header observation. */
339
- interface SessionEventTraceObservation extends SessionEventTrace {
340
- /** Cloned header selected with the event log used for the trace. */
341
- session: SessionHeader
342
- }
343
- ```
344
-
345
- ## Errors
346
-
347
- The closed code union distinguishes request validation, missing targets, malformed surface logs, optional-backend failure, deployment-disabled search, and contradictory source metadata.
348
-
349
- ```ts type-equiv
350
- /** Stable machine-routable failure taxonomy for session reads, traces, and search. */
351
- type SessionQueryErrorCode =
352
- | 'SESSION_QUERY_ABORTED'
353
- | 'SESSION_QUERY_CORRUPT_SESSION'
354
- | 'SESSION_QUERY_EVENT_NOT_FOUND'
355
- | 'SESSION_QUERY_INDEX_FAILED'
356
- | 'SESSION_QUERY_INVALID_CONFIG'
357
- | 'SESSION_QUERY_INVALID_CURSOR'
358
- | 'SESSION_QUERY_INVALID_FILTER'
359
- | 'SESSION_QUERY_INVALID_LIMIT'
360
- | 'SESSION_QUERY_INVALID_QUERY'
361
- | 'SESSION_QUERY_INVALID_LINEAGE'
362
- | 'SESSION_QUERY_INVALID_SURFACE'
363
- | 'SESSION_QUERY_INVALID_WINDOW'
364
- | 'SESSION_QUERY_PERSISTENCE_FAILED'
365
- | 'SESSION_QUERY_SEARCH_DISABLED'
366
- | 'SESSION_QUERY_SESSION_NOT_FOUND'
367
- | 'SESSION_QUERY_STALE_CURSOR'
368
- | 'SESSION_QUERY_SOURCE_CONFLICT'
369
- ```
370
-
371
- <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
372
-
373
- <a id="cordis-surface"></a>
374
-
375
- ## Cordis API
376
-
377
- Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
378
-
379
- <a id="ctxsessionquery--sessionqueryengine-abstract-seam"></a>
380
-
381
- ### `ctx.sessionQuery` — `SessionQueryEngine` (abstract seam)
382
-
383
- Unified live-preferred session query service.
384
-
385
- Exact reads, filters, and traces are backend-independent concrete behavior. A backend implements full-text observation, reconciliation, ranking, cursor generations, and query execution on the same `ctx.sessionQuery` service.
386
-
387
- ```ts cordis-catalog
388
- /**
389
- * Observe one exact live or prepared Session without a persistence listing preflight.
390
- * @param sessionId - logical Session identity.
391
- * @param options - cancellation and projection selection for this read.
392
- * @returns a caller-owned observation lease.
393
- */
394
- observeSession( sessionId: SessionId, options: SessionObservationOptions = {}, ): Promise<SessionObservation>
395
-
396
- /**
397
- * Search the live-preferred logical corpus and group by session.
398
- * @param request - query text, metadata filters, page size, and cursor.
399
- * @param exec - optional cancellation control.
400
- * @returns session hits ranked by their strongest matching event.
401
- */
402
- abstract searchSessions( request: SessionSearchRequest, exec?: SessionSearchExecContext, ): Promise<SessionSearchPage<SessionSearchHit>>
403
-
404
- /**
405
- * Search events within one live-preferred logical session.
406
- * @param request - target session, query text, filters, page size, and cursor.
407
- * @param exec - optional cancellation control.
408
- * @returns matching event hits and their target header from one indexed generation.
409
- */
410
- abstract searchEvents( request: SessionEventSearchRequest, exec?: SessionSearchExecContext, ): Promise<SessionEventSearchPage>
411
-
412
- /**
413
- * List the complete logical corpus using live-preferred records.
414
- * @param signal - optional cancellation for persistence listing.
415
- * @returns deterministic newest-first cloned session records.
416
- */
417
- listSessions(signal?: AbortSignal): Promise<SessionRecord[]>
418
-
419
- /**
420
- * Read and replay-validate one complete logical session log without making it live.
421
- * @param sessionId - live or persisted session id to read.
422
- * @returns cloned header and complete raw event log from one observation.
423
- * @throws when persistence, header compatibility, or replay validation fails.
424
- */
425
- async readSession(sessionId: SessionId): Promise<SessionLogSnapshot>
426
-
427
- /**
428
- * Filter the complete logical corpus with provider-independent predicates.
429
- * @param filters - ANDed session metadata and availability clauses.
430
- * @param signal - optional cancellation for persistence listing.
431
- * @returns matching cloned records in deterministic newest-first order.
432
- */
433
- async filterSessions( filters: readonly SessionResultFilter[], signal?: AbortSignal, ): Promise<SessionRecord[]>
434
-
435
- /**
436
- * Fold the latest log-backed title from one live-preferred logical session.
437
- * @param sessionId - live or persisted session id to read.
438
- * @param signal - optional cancellation for source resolution and title folding.
439
- * @returns latest title snapshot, or `undefined` when the log has no title event.
440
- */
441
- async readTitle( sessionId: SessionId, signal?: AbortSignal, ): Promise<SessionTitleSnapshot | undefined>
442
-
443
- /**
444
- * Fold the latest title and return its source header from one corpus observation.
445
- * @param sessionId - live or persisted session id to read.
446
- * @param signal - optional cancellation for source resolution and title folding.
447
- * @returns cloned source header and optional latest title snapshot.
448
- */
449
- async readTitleSnapshot( sessionId: SessionId, signal?: AbortSignal, ): Promise<SessionTitleObservation>
450
-
451
- /**
452
- * Fold titles for unique sessions from one cancellable corpus observation.
453
- *
454
- * Results preserve first-occurrence input order. Operational failures stay
455
- * isolated per session, while cancellation rejects the complete operation.
456
- * @param sessionIds - live or persisted session ids to observe.
457
- * @param signal - optional cancellation shared by all source reads.
458
- * @returns one fulfilled or rejected result per unique requested id.
459
- */
460
- async readTitleSnapshots( sessionIds: readonly SessionId[], signal?: AbortSignal, ): Promise<SessionTitleObservationResult[]>
461
-
462
- /**
463
- * List lightweight raw-log event records for one logical session.
464
- * @param sessionId - live-preferred session id to read.
465
- * @returns event records in ascending seq order.
466
- */
467
- async listEvents(sessionId: SessionId): Promise<SessionEventRecord[]>
468
-
469
- /**
470
- * Scan first-party semantic event documents with provider-independent filters.
471
- * @param sessionId - live-preferred session id to scan.
472
- * @param filters - ANDed metadata and literal-text predicates.
473
- * @returns matching semantic documents in ascending seq order.
474
- */
475
- async filterEvents( sessionId: SessionId, filters: readonly SessionEventResultFilter[], ): Promise<SessionEventSearchDocument[]>
476
-
477
- /**
478
- * Read one session's complete current model surface from one corpus observation.
479
- * @param sessionId - live-preferred session id to read.
480
- * @returns cloned header, current surface, and the last sequence number included in the raw-log capture.
481
- * @throws when source resolution fails or the session surface is invalid.
482
- */
483
- async readSurface(sessionId: SessionId): Promise<SessionSurfaceSnapshot>
484
-
485
- /**
486
- * Trace known ancestry and descendants from one corpus observation.
487
- * @param sessionId - logical session id to trace.
488
- * @param signal - optional cancellation for persistence listing.
489
- * @returns a complete lineage or the first parent that could not be resolved.
490
- * @throws when corpus resolution fails, the target is absent, or its known ancestry cycles.
491
- */
492
- async traceSession(sessionId: SessionId, signal?: AbortSignal): Promise<SessionLineageTrace>
493
-
494
- /**
495
- * Trace one event's direct positional replacements and cited source events.
496
- * @param request - target session id and event seq.
497
- * @param signal - optional cancellation for persisted source resolution.
498
- * @returns source header, direct links, and the target's positional replacement chain.
499
- * @throws when source resolution fails, the target is absent, or surface/source-event validation fails.
500
- */
501
- async traceEvent(request: SessionEventTraceRequest, signal?: AbortSignal): Promise<SessionEventTraceObservation>
502
-
503
- /**
504
- * Read one full event plus a bounded raw-log context window.
505
- * @param request - target session/seq and context sizes.
506
- * @param signal - optional cancellation for persisted source resolution.
507
- * @returns cloned target and neighboring events.
508
- */
509
- async readEvent(request: SessionEventReadRequest, signal?: AbortSignal): Promise<SessionEventWindow>
510
- ```
511
-
512
- Types: [SessionId](./core.md) · [SessionTitleSnapshot](./session-title.md)
513
-
514
- Source: [`packages/session-query/session-query/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session-query/session-query/src/index.ts)
515
- <!-- END GENERATED cordis-surface -->
1
+ ---
2
+ editSource: "docs/subsystems/session-query.md"
3
+ rawMarkdownPath: "en/reference/subsystems/session-query.md"
4
+ outline: [2,3]
5
+ ---
6
+
7
+ # Session Query
8
+
9
+ Query vocabulary over the live-preferred logical session corpus. The [Service Definition package](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/session-query/session-query) owns exact reads, source precedence, relationship tracing, semantic extraction, and provider-independent filters, while the [SQLite provider](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/session-query/session-query-sqlite) owns the concrete full-text index lifecycle.
10
+
11
+ Source: [`packages/session-query/session-query/src/types.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session-query/session-query/src/types.ts)
12
+
13
+ ## Logical records
14
+
15
+ `SessionRecord` is returned by the cross-corpus list. It exposes source availability independently from the cloned live-preferred header. `SessionEventRecord` is a lightweight raw-log projection; classification uses the same `foldSurface()` transitions as model-history derivation.
16
+
17
+ ```ts type-equiv
18
+ /** Whether an event is current model context, replaced context, or raw-log-only. */
19
+ type SessionEventSurface = 'current' | 'shadowed' | 'log-only'
20
+ ```
21
+
22
+ ```ts type-equiv
23
+ /** Lightweight identity and source availability for one logical session. */
24
+ interface SessionRecord {
25
+ /** Cloned session header selected from the live-preferred corpus. */
26
+ header: SessionHeader
27
+ /** Whether the id currently exists in `ctx.sessions`. */
28
+ live: boolean
29
+ /** Whether the active persistence backend currently lists the id, including a created-but-unmaterialized session it already observes. */
30
+ persisted: boolean
31
+ /** Current for live Sessions; otherwise the persistence format status when reported. */
32
+ formatStatus?: 'current' | 'migration-required'
33
+ }
34
+ ```
35
+
36
+ `SessionLogSnapshot` is the complete detached, replay-validated raw log used by resume preflight. `SessionSurfaceSnapshot` is one exact-read surface observation rather than a retained subscription.
37
+
38
+ ```ts type-equiv
39
+ /** One validated detached observation of a logical session's complete raw log. */
40
+ interface SessionLogSnapshot {
41
+ /** Cloned session header selected from the same observation as `events`. */
42
+ session: SessionHeader
43
+ /** Exact number of fork-inherited events in the observed log. */
44
+ inheritedEventCount: SessionLogOffset
45
+ /** Cloned contiguous raw events after in-memory interrupted-turn balancing and replay validation. */
46
+ events: SessionEvent[]
47
+ }
48
+ ```
49
+
50
+ ```ts type-equiv
51
+ /** One atomic live-preferred observation of a session's current model surface. */
52
+ interface SessionSurfaceSnapshot {
53
+ /** Cloned session header selected from the same corpus observation as `events`. */
54
+ session: SessionHeader
55
+ /** Exact number of fork-inherited events in the observed log. */
56
+ inheritedEventCount: SessionLogOffset
57
+ /** Highest raw-log seq included in the observation, or `null` for an empty log. */
58
+ capturedThroughSeq: OptionalSessionSeq
59
+ /** Cloned current surface events in model-history order. */
60
+ events: SurfaceEvent[]
61
+ }
62
+ ```
63
+
64
+ `SessionTitleObservation` applies the same atomic-observation rule to title folding, so an authorization consumer can validate the source header that supplied the title. Batch reads return one ordered `SessionTitleObservationResult` per unique requested id: operational failures remain local to that id, while cancellation rejects the complete operation.
65
+
66
+ ```ts type-equiv
67
+ /** Latest folded title bound to the same session-header observation. */
68
+ interface SessionTitleObservation {
69
+ /** Cloned header selected with the event log used for the title fold. */
70
+ session: SessionHeader
71
+ /** Latest title snapshot, absent when the observed log has no title. */
72
+ title?: SessionTitleSnapshot
73
+ }
74
+ ```
75
+
76
+ ```ts type-equiv
77
+ /** One ordered result from a batch title observation. */
78
+ type SessionTitleObservationResult =
79
+ | {
80
+ /** Requested session id. */
81
+ sessionId: SessionId
82
+ /** Successful atomic header/title observation. */
83
+ status: 'fulfilled'
84
+ /** Header and optional latest title from one logical source. */
85
+ value: SessionTitleObservation
86
+ }
87
+ | {
88
+ /** Requested session id. */
89
+ sessionId: SessionId
90
+ /** Operational failure isolated to this session. */
91
+ status: 'rejected'
92
+ /** Original failure from logical-source resolution or title folding. */
93
+ reason: unknown
94
+ }
95
+ ```
96
+
97
+ ```ts type-equiv
98
+ /** Lightweight metadata for one event within a logical session. */
99
+ interface SessionEventRecord {
100
+ /** Session that owns the event. */
101
+ sessionId: SessionId
102
+ /** Monotonic event seq within the session. */
103
+ seq: SessionSeq
104
+ /** Discriminant of the session event. */
105
+ type: SessionEventType
106
+ /** Event timestamp in Unix epoch milliseconds. */
107
+ time: number
108
+ /** Event placement in the folded session surface. */
109
+ surface: SessionEventSurface
110
+ }
111
+ ```
112
+
113
+ ## Provider-independent filters and documents
114
+
115
+ Session and event filter arrays are ANDed; values inside one list clause are ORed. Ranges are inclusive. The event `text` clause is a literal Unicode case-insensitive, whitespace-flexible regular-expression scan over extracted semantic text, independent of full-text providers.
116
+
117
+ ```ts type-equiv
118
+ /**
119
+ * One logical-session predicate. A filter array is ANDed; `values` within a
120
+ * clause are ORed.
121
+ */
122
+ type SessionResultFilter =
123
+ | { kind: 'id'; values: readonly SessionId[] }
124
+ | { kind: 'cwd'; values: readonly (string | null)[] }
125
+ | ({ kind: 'created-at' } & SessionResultRange)
126
+ | { kind: 'parent'; values: readonly (SessionId | null)[] }
127
+ | { kind: 'availability'; values: readonly SessionAvailability[] }
128
+ ```
129
+
130
+ ```ts type-equiv
131
+ /**
132
+ * One event predicate. A filter array is ANDed; list-valued clauses are ORed.
133
+ * Text is a literal, case-insensitive, whitespace-flexible semantic-text scan.
134
+ */
135
+ type SessionEventResultFilter =
136
+ | ({ kind: 'seq' } & SessionResultRange)
137
+ | ({ kind: 'time' } & SessionResultRange)
138
+ | { kind: 'type'; values: readonly SessionEventType[] }
139
+ | { kind: 'surface'; values: readonly SessionEventSurface[] }
140
+ | { kind: 'text'; text: string }
141
+ ```
142
+
143
+ ```ts type-equiv
144
+ /** Searchable semantic document derived from one session event. */
145
+ interface SessionEventSearchDocument extends SessionEventRecord {
146
+ /** First-party semantic text used by scan filters and full-text indexes. */
147
+ text: string
148
+ }
149
+ ```
150
+
151
+ `ctx.sessionQuery.filterSessions(filters)` applies `SessionResultFilter` to the complete logical corpus; `ctx.sessionQuery.filterEvents(sessionId, filters)` returns matching documents in ascending seq order. Messages, tool calls/results, todos, and failure/status detail contribute semantic text; reasoning blocks, blocked prompts, structural events, and stream chunks do not.
152
+
153
+ ## Full-text search pages
154
+
155
+ The combined `ctx.sessionQuery` seam has two full-text scopes. `searchSessions()` groups the corpus by strongest matching event; `searchEvents()` searches one session. Requests bind an opaque cursor to the normalized query, metadata filters, and limit. The event text scan is intentionally absent from provider metadata filters.
156
+
157
+ ```ts type-equiv
158
+ /** Provider-owned opaque continuation token returned by session search. */
159
+ type SessionSearchCursor = Branded<'SessionSearchCursor'>
160
+ ```
161
+
162
+ ```ts type-equiv
163
+ /** Cross-session full-text search request. */
164
+ interface SessionSearchRequest {
165
+ /** Full-text query interpreted as data, never executable FTS syntax. */
166
+ query: string
167
+ /** Logical-session predicates applied before event ranking. */
168
+ sessionFilters?: readonly SessionResultFilter[]
169
+ /** Event predicates applied before event ranking. */
170
+ eventFilters?: readonly SessionEventMetadataFilter[]
171
+ /** Maximum sessions in this page. */
172
+ limit?: number
173
+ /** Opaque cursor returned for the identical normalized request. */
174
+ cursor?: SessionSearchCursor
175
+ }
176
+ ```
177
+
178
+ ```ts type-equiv
179
+ /** Within-session full-text search request. */
180
+ interface SessionEventSearchRequest {
181
+ /** Session whose live-preferred logical log is searched. */
182
+ sessionId: SessionId
183
+ /** Full-text query interpreted as data, never executable FTS syntax. */
184
+ query: string
185
+ /** Event predicates applied before ranking. */
186
+ filters?: readonly SessionEventMetadataFilter[]
187
+ /** Maximum events in this page. */
188
+ limit?: number
189
+ /** Opaque cursor returned for the identical normalized request. */
190
+ cursor?: SessionSearchCursor
191
+ }
192
+ ```
193
+
194
+ ```ts type-equiv
195
+ /** One cursor-paginated result page. */
196
+ interface SessionSearchPage<T> {
197
+ /** Results for this page in contract-defined order. */
198
+ items: readonly T[]
199
+ /** Opaque continuation cursor, absent on the final page. */
200
+ nextCursor?: SessionSearchCursor
201
+ }
202
+ ```
203
+
204
+ Unlike grouped cross-session hits, a within-session search must also expose its observed target header even when the page contains no hits.
205
+
206
+ ```ts type-equiv
207
+ /** Event-search results bound to the indexed target-session observation. */
208
+ interface SessionEventSearchPage extends SessionSearchPage<SessionEventSearchHit> {
209
+ /** Cloned target header from the same indexed generation as `items`. */
210
+ session: SessionHeader
211
+ }
212
+ ```
213
+
214
+ ```ts type-equiv
215
+ /** One event full-text search hit with a bounded plain-text excerpt. */
216
+ interface SessionEventSearchHit extends SessionEventRecord {
217
+ /** Plain text excerpt selected around the match. */
218
+ snippet: string
219
+ }
220
+ ```
221
+
222
+ ```ts type-equiv
223
+ /** One grouped cross-session hit, ranked by its strongest matching event. */
224
+ interface SessionSearchHit extends SessionRecord {
225
+ /** Strongest matching event for this session. */
226
+ bestMatch: SessionEventSearchHit
227
+ }
228
+ ```
229
+
230
+ ## Session lineage
231
+
232
+ `SessionLineageTrace` carries known parents in immediate-to-outward order and a forest of recursively nested direct descendants. The completeness discriminant makes a known root and a missing parent mutually exclusive.
233
+
234
+ ```ts type-equiv
235
+ /** Recursive descendant node in a session-lineage trace. */
236
+ interface SessionLineageNode {
237
+ /** Detached logical-corpus record for this descendant. */
238
+ session: SessionRecord
239
+ /** Direct children, each carrying its own recursive descendants. */
240
+ descendants: SessionLineageNode[]
241
+ }
242
+ ```
243
+
244
+ ```ts type-equiv
245
+ /** Known ancestry and descendants for one logical session. */
246
+ type SessionLineageTrace = {
247
+ /** Detached record for the session that was traced. */
248
+ target: SessionRecord
249
+ /** Known parents from the immediate parent outward. */
250
+ ancestors: SessionRecord[]
251
+ /** Complete known descendant trees rooted at the target's direct children. */
252
+ descendants: SessionLineageNode[]
253
+ } & (
254
+ | {
255
+ /** The complete parent chain is present in the logical corpus. */
256
+ complete: true
257
+ /** Detached record at the top of the complete lineage. */
258
+ root: SessionRecord
259
+ }
260
+ | {
261
+ /** The parent chain leaves the visible logical corpus. */
262
+ complete: false
263
+ /** First parent id that is not present in the logical corpus. */
264
+ unresolvedParentId: SessionId
265
+ }
266
+ )
267
+ ```
268
+
269
+ ## Bounded event reads
270
+
271
+ The request addresses one raw seq and optional neighboring counts. The result carries a `SessionHeader` rather than availability flags so a known live target can remain independent of persistence health.
272
+
273
+ ```ts type-equiv
274
+ /** Request for one event plus raw neighboring log context. */
275
+ interface SessionEventReadRequest {
276
+ /** Session that owns the target event. */
277
+ sessionId: SessionId
278
+ /** Target event seq. */
279
+ seq: SessionSeq
280
+ /** Number of preceding raw events to include. */
281
+ before?: number
282
+ /** Number of following raw events to include. */
283
+ after?: number
284
+ }
285
+ ```
286
+
287
+ ```ts type-equiv
288
+ /** Full target event and a bounded raw-log window. */
289
+ interface SessionEventWindow {
290
+ /** Cloned header for the live-preferred source read. */
291
+ session: SessionHeader
292
+ /** Exact number of fork-inherited events in the observed log. */
293
+ inheritedEventCount: SessionLogOffset
294
+ /** Full cloned target event. */
295
+ target: SessionEvent
296
+ /** Full cloned events from `startSeq` through `endSeq`. */
297
+ events: SessionEvent[]
298
+ /** First seq included in `events`. */
299
+ startSeq: SessionSeq
300
+ /** Last seq included in `events`. */
301
+ endSeq: SessionSeq
302
+ }
303
+ ```
304
+
305
+ ## Event relationships
306
+
307
+ Event traces distinguish positional surface replacement from events cited as sources. Every seq list contains direct links except `replacementChain`, which follows immediate replacers from the target to the final positional replacement.
308
+
309
+ ```ts type-equiv
310
+ /** Request for direct surface replacements and relationships to cited source events around one event. */
311
+ interface SessionEventTraceRequest {
312
+ /** Session that owns the target event. */
313
+ sessionId: SessionId
314
+ /** Target event seq. */
315
+ seq: SessionSeq
316
+ }
317
+ ```
318
+
319
+ ```ts type-equiv
320
+ /** Direct surface replacements and relationships to cited source events for one event. */
321
+ interface SessionEventTrace {
322
+ /** Lightweight target record. */
323
+ target: SessionEventRecord
324
+ /** Immediate positional replacement event, when the target was shadowed. */
325
+ replacedBy?: SessionSeq
326
+ /** Positional replacers from the immediate replacement to the final replacement. */
327
+ replacementChain: SessionSeq[]
328
+ /** Surface nodes directly removed when the target itself performed a replacement. */
329
+ replacedEventSeqs: SessionSeq[]
330
+ /** Earlier events cited directly as sources, in their recorded order. */
331
+ sourceEventSeqs: SessionSeq[]
332
+ /** Later events that directly cite the target as a source, in log order. */
333
+ derivedEventSeqs: SessionSeq[]
334
+ }
335
+ ```
336
+
337
+ ```ts type-equiv
338
+ /** Event relationships bound to the same session-header observation. */
339
+ interface SessionEventTraceObservation extends SessionEventTrace {
340
+ /** Cloned header selected with the event log used for the trace. */
341
+ session: SessionHeader
342
+ }
343
+ ```
344
+
345
+ ## Errors
346
+
347
+ The closed code union distinguishes request validation, missing targets, malformed surface logs, optional-backend failure, deployment-disabled search, and contradictory source metadata.
348
+
349
+ ```ts type-equiv
350
+ /** Stable machine-routable failure taxonomy for session reads, traces, and search. */
351
+ type SessionQueryErrorCode =
352
+ | 'SESSION_QUERY_ABORTED'
353
+ | 'SESSION_QUERY_CORRUPT_SESSION'
354
+ | 'SESSION_QUERY_EVENT_NOT_FOUND'
355
+ | 'SESSION_QUERY_INDEX_FAILED'
356
+ | 'SESSION_QUERY_INVALID_CONFIG'
357
+ | 'SESSION_QUERY_INVALID_CURSOR'
358
+ | 'SESSION_QUERY_INVALID_FILTER'
359
+ | 'SESSION_QUERY_INVALID_LIMIT'
360
+ | 'SESSION_QUERY_INVALID_QUERY'
361
+ | 'SESSION_QUERY_INVALID_LINEAGE'
362
+ | 'SESSION_QUERY_INVALID_SURFACE'
363
+ | 'SESSION_QUERY_INVALID_WINDOW'
364
+ | 'SESSION_QUERY_PERSISTENCE_FAILED'
365
+ | 'SESSION_QUERY_SEARCH_DISABLED'
366
+ | 'SESSION_QUERY_SESSION_NOT_FOUND'
367
+ | 'SESSION_QUERY_STALE_CURSOR'
368
+ | 'SESSION_QUERY_SOURCE_CONFLICT'
369
+ ```
370
+
371
+ <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
372
+
373
+ <a id="cordis-surface"></a>
374
+
375
+ ## Cordis API
376
+
377
+ Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
378
+
379
+ <a id="ctxsessionquery--sessionqueryengine-abstract-seam"></a>
380
+
381
+ ### `ctx.sessionQuery` — `SessionQueryEngine` (abstract seam)
382
+
383
+ Unified live-preferred session query service.
384
+
385
+ Exact reads, filters, and traces are backend-independent concrete behavior. A backend implements full-text observation, reconciliation, ranking, cursor generations, and query execution on the same `ctx.sessionQuery` service.
386
+
387
+ ```ts cordis-catalog
388
+ /**
389
+ * Observe one exact live or prepared Session without a persistence listing preflight.
390
+ * @param sessionId - logical Session identity.
391
+ * @param options - cancellation and projection selection for this read.
392
+ * @returns a caller-owned observation lease.
393
+ */
394
+ observeSession( sessionId: SessionId, options: SessionObservationOptions = {}, ): Promise<SessionObservation>
395
+
396
+ /**
397
+ * Inspect domain-owned state without attaching or resuming a cold Session.
398
+ * The getter runs synchronously after preparation and must not mutate or retain the Session.
399
+ * @param sessionId - logical Session identity.
400
+ * @param read - domain getter returning detached data.
401
+ * @param signal - preparation cancellation.
402
+ * @returns the getter's value at the current live or prepared cut.
403
+ */
404
+ inspectSession<T>(sessionId: SessionId, read: (session: Session) => T, signal?: AbortSignal): Promise<T>
405
+
406
+ /**
407
+ * Search the live-preferred logical corpus and group by session.
408
+ * @param request - query text, metadata filters, page size, and cursor.
409
+ * @param exec - optional cancellation control.
410
+ * @returns session hits ranked by their strongest matching event.
411
+ */
412
+ abstract searchSessions( request: SessionSearchRequest, exec?: SessionSearchExecContext, ): Promise<SessionSearchPage<SessionSearchHit>>
413
+
414
+ /**
415
+ * Search events within one live-preferred logical session.
416
+ * @param request - target session, query text, filters, page size, and cursor.
417
+ * @param exec - optional cancellation control.
418
+ * @returns matching event hits and their target header from one indexed generation.
419
+ */
420
+ abstract searchEvents( request: SessionEventSearchRequest, exec?: SessionSearchExecContext, ): Promise<SessionEventSearchPage>
421
+
422
+ /**
423
+ * List the complete logical corpus using live-preferred records.
424
+ * @param signal - optional cancellation for persistence listing.
425
+ * @returns deterministic newest-first cloned session records.
426
+ */
427
+ listSessions(signal?: AbortSignal): Promise<SessionRecord[]>
428
+
429
+ /**
430
+ * Read and replay-validate one complete logical session log without making it live.
431
+ * @param sessionId - live or persisted session id to read.
432
+ * @returns cloned header and complete raw event log from one observation.
433
+ * @throws when persistence, header compatibility, or replay validation fails.
434
+ */
435
+ async readSession(sessionId: SessionId): Promise<SessionLogSnapshot>
436
+
437
+ /**
438
+ * Filter the complete logical corpus with provider-independent predicates.
439
+ * @param filters - ANDed session metadata and availability clauses.
440
+ * @param signal - optional cancellation for persistence listing.
441
+ * @returns matching cloned records in deterministic newest-first order.
442
+ */
443
+ async filterSessions( filters: readonly SessionResultFilter[], signal?: AbortSignal, ): Promise<SessionRecord[]>
444
+
445
+ /**
446
+ * Fold the latest log-backed title from one live-preferred logical session.
447
+ * @param sessionId - live or persisted session id to read.
448
+ * @param signal - optional cancellation for source resolution and title folding.
449
+ * @returns latest title snapshot, or `undefined` when the log has no title event.
450
+ */
451
+ async readTitle( sessionId: SessionId, signal?: AbortSignal, ): Promise<SessionTitleSnapshot | undefined>
452
+
453
+ /**
454
+ * Fold the latest title and return its source header from one corpus observation.
455
+ * @param sessionId - live or persisted session id to read.
456
+ * @param signal - optional cancellation for source resolution and title folding.
457
+ * @returns cloned source header and optional latest title snapshot.
458
+ */
459
+ async readTitleSnapshot( sessionId: SessionId, signal?: AbortSignal, ): Promise<SessionTitleObservation>
460
+
461
+ /**
462
+ * Fold titles for unique sessions from one cancellable corpus observation.
463
+ *
464
+ * Results preserve first-occurrence input order. Operational failures stay
465
+ * isolated per session, while cancellation rejects the complete operation.
466
+ * @param sessionIds - live or persisted session ids to observe.
467
+ * @param signal - optional cancellation shared by all source reads.
468
+ * @returns one fulfilled or rejected result per unique requested id.
469
+ */
470
+ async readTitleSnapshots( sessionIds: readonly SessionId[], signal?: AbortSignal, ): Promise<SessionTitleObservationResult[]>
471
+
472
+ /**
473
+ * List lightweight raw-log event records for one logical session.
474
+ * @param sessionId - live-preferred session id to read.
475
+ * @returns event records in ascending seq order.
476
+ */
477
+ async listEvents(sessionId: SessionId): Promise<SessionEventRecord[]>
478
+
479
+ /**
480
+ * Scan first-party semantic event documents with provider-independent filters.
481
+ * @param sessionId - live-preferred session id to scan.
482
+ * @param filters - ANDed metadata and literal-text predicates.
483
+ * @returns matching semantic documents in ascending seq order.
484
+ */
485
+ async filterEvents( sessionId: SessionId, filters: readonly SessionEventResultFilter[], ): Promise<SessionEventSearchDocument[]>
486
+
487
+ /**
488
+ * Read one session's complete current model surface from one corpus observation.
489
+ * @param sessionId - live-preferred session id to read.
490
+ * @returns cloned header, current surface, and the last sequence number included in the raw-log capture.
491
+ * @throws when source resolution fails or the session surface is invalid.
492
+ */
493
+ async readSurface(sessionId: SessionId): Promise<SessionSurfaceSnapshot>
494
+
495
+ /**
496
+ * Trace known ancestry and descendants from one corpus observation.
497
+ * @param sessionId - logical session id to trace.
498
+ * @param signal - optional cancellation for persistence listing.
499
+ * @returns a complete lineage or the first parent that could not be resolved.
500
+ * @throws when corpus resolution fails, the target is absent, or its known ancestry cycles.
501
+ */
502
+ async traceSession(sessionId: SessionId, signal?: AbortSignal): Promise<SessionLineageTrace>
503
+
504
+ /**
505
+ * Trace one event's direct positional replacements and cited source events.
506
+ * @param request - target session id and event seq.
507
+ * @param signal - optional cancellation for persisted source resolution.
508
+ * @returns source header, direct links, and the target's positional replacement chain.
509
+ * @throws when source resolution fails, the target is absent, or surface/source-event validation fails.
510
+ */
511
+ async traceEvent(request: SessionEventTraceRequest, signal?: AbortSignal): Promise<SessionEventTraceObservation>
512
+
513
+ /**
514
+ * Read one full event plus a bounded raw-log context window.
515
+ * @param request - target session/seq and context sizes.
516
+ * @param signal - optional cancellation for persisted source resolution.
517
+ * @returns cloned target and neighboring events.
518
+ */
519
+ async readEvent(request: SessionEventReadRequest, signal?: AbortSignal): Promise<SessionEventWindow>
520
+ ```
521
+
522
+ Types: [Session](./session.md) · [SessionId](./core.md) · [SessionTitleSnapshot](./session-title.md)
523
+
524
+ Source: [`packages/session-query/session-query/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session-query/session-query/src/index.ts)
525
+ <!-- END GENERATED cordis-surface -->