@deepseek-ai/dsh-tool-session-query 0.0.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, DeepSeek
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,6 @@
1
+ # Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
2
+ # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
+ # after editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/session-query/tool-session-query/README.md
5
+ README.md: d973daf1124c4be05f7335b18661d431d45be39f
6
+ README.zh.md: 18ff18520ba8bb9d3d3dba5091d6281a0a47b78a
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # @deepseek-ai/dsh-tool-session-query
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ Workspace-authorized model tools over `ctx.sessionQuery`. The opt-in package depends only on the unified interface and registers `session_search`, `session_event_search`, `session_trace`, `session_event_trace`, and `session_event_read`; shipped host compositions do not mount it by default.
6
+
7
+ ## Configuration
8
+
9
+ | Key | Default | Meaning |
10
+ |---|---:|---|
11
+ | `maxSearchResults` | `100` | Maximum authorized non-self hits collected across internal provider pages |
12
+ | `searchTimeoutMs` | `30000` | Cooperative deadline attached to both full-text search tools |
13
+
14
+ The caller comes exclusively from `ToolExecution.exec.agent`. Cross-session access requires exact equality between the target and caller session `cwd` values; a caller without `cwd` can inspect only itself. Search never exposes provider cursors, offsets, page sizes, or a model-controlled limit. Because one search consumes generation-bound provider cursors internally, both search tools execute exclusively with sibling tool calls; the three exact trace/read tools opt into parallel execution. Every exact executor passes its unchanged execution signal through authorization and the service trace/read, so cancellation waits for cooperative persistence cleanup and retains the signal's exact reason. Timestamps at the tool boundary require an explicit `Z` or numeric offset and become inclusive epoch-millisecond filters.
15
+
16
+ `session_search` always omits the caller session. Requested parent ids are deduplicated and checked against caller-workspace authority before FTS; only authorized ids reach the provider, while missing and cross-workspace guesses behave identically and the root marker remains independently ORed. A current-session `session_event_search` stops immediately before the step that invoked it, so the active assistant output and logged tool call cannot match themselves. Direct targets are authorized before trace, event, or title reads. Lineage output replaces unauthorized ancestor and descendant boundaries with markers that contain no hidden session id.
17
+
18
+ Every trusted `ctx.sessionQuery` call crosses one model-boundary sanitizer. Caller cancellation is checked first and preserved exactly. Available corpus and provider diagnostics, including safely inspectable nested causes, are logged internally on a best-effort basis; unprintable failures use a fixed log placeholder. Diagnostic formatting and error classification are independently guarded, so an unprintable cause cannot escape or prevent a safely classified outer error, while unsafe classification or logging falls back to the fixed `SESSION_QUERY_TOOL_FAILED` code and message. Local argument-validation and authorization errors retain their precise tool-owned messages.
19
+
20
+ The package deliberately performs no byte or character truncation and does not import a spill backend. Deployments that need bounded inline output mount `@deepseek-ai/dsh-spill-policy`, which can replace the rendered text after execution while retaining the complete result.
21
+
22
+ ## Model Experience
23
+
24
+ ### System prompt
25
+
26
+ #### What the model sees
27
+
28
+ The model receives one fixed prior-history guidance section.
29
+
30
+ ##### Prior-history guidance
31
+
32
+ ```markdown
33
+ Use session_search to find relevant work from prior sessions, or session_event_search to search earlier events in one session. Search results are cursor-free and workspace-scoped. Follow a useful hit with session_trace, session_event_trace, or session_event_read when you need lineage, relationships, or exact data.
34
+ ```
35
+
36
+ #### Token effect
37
+
38
+ One fixed concise section is present on each request while the plugin is mounted.
39
+
40
+ #### KV Cache effect
41
+
42
+ Prefix-stable while the plugin and guidance text are unchanged.
43
+
44
+ ### Tool schemas
45
+
46
+ #### What the model sees
47
+
48
+ The model sees the generated [`session_search`, `session_event_search`, `session_trace`, `session_event_trace`, and `session_event_read` schemas](../../../docs/tool-catalog.md#deepseek-aidsh-tool-session-query). Search filters add fixed schema tokens, while cursors, workspace paths, output pagination, and model-controlled result limits remain absent.
49
+
50
+ #### Token effect
51
+
52
+ Five fixed read-only schemas are sent on each request while visible.
53
+
54
+ #### KV Cache effect
55
+
56
+ Prefix-stable while tool visibility and definitions are unchanged.
57
+
58
+ ### Tool results
59
+
60
+ #### What the model sees
61
+
62
+ Each successful call emits one plain-text block. Search results include titles and best-match excerpts; traces include all authorized relationships; event reads include unabridged target JSON. The generic spill policy may replace oversized inline text with its preview, opaque locator, and retrieval hint.
63
+
64
+ #### Token effect
65
+
66
+ Results are data-dependent and remain in logged tool history until compaction; `maxSearchResults` bounds search-hit count.
67
+
68
+ #### KV Cache effect
69
+
70
+ Append-only result text follows the reusable request prefix and does not invalidate earlier cache entries.
71
+
72
+ ## Known Limitations and Deferred Work
73
+
74
+ - Search returns at most the deployment cap and asks the model to narrow its query when more matches exist; it offers no continuation token.
75
+ - Workspace identity is conservative exact-string `cwd` equality, so symlink-equivalent paths do not share authority.
76
+ - Custom compositions without the generic spill policy accept complete trace and event payloads inline.
package/README.zh.md ADDED
@@ -0,0 +1,76 @@
1
+ # @deepseek-ai/dsh-tool-session-query
2
+
3
+ [English](README.md) | 中文
4
+
5
+ 位于 `ctx.sessionQuery` 之上、经工作区授权的模型工具。该 opt-in 包只依赖统一接口,并注册 `session_search`、`session_event_search`、`session_trace`、`session_event_trace` 和 `session_event_read`;已发布的宿主组合默认不挂载它。
6
+
7
+ ## 配置
8
+
9
+ | 键 | 默认值 | 含义 |
10
+ |---|---:|---|
11
+ | `maxSearchResults` | `100` | 在内部提供方分页中收集的最大已授权非自身命中数 |
12
+ | `searchTimeoutMs` | `30000` | 附加到两个全文搜索工具的协作式截止时间 |
13
+
14
+ 调用方只能来自 `ToolExecution.exec.agent`。跨会话访问要求目标和调用方会话的 `cwd` 值严格相等;没有 `cwd` 的调用方只能检查自己。搜索绝不公开提供方游标、偏移、分页大小或模型可控上限。由于一次搜索会在内部消费与世代绑定的提供方游标,两个搜索工具都与同级工具调用排他执行;三个精确跟踪/读取工具选择并行执行。每个精确执行器都将未更改的执行信号传递给授权和服务跟踪/读取,因此取消会等待协作式持久化清理,并保留信号的精确原因。工具边界上的时间戳要求显式 `Z` 或数字偏移,并转换为包含端点的 epoch 毫秒过滤器。
15
+
16
+ `session_search` 始终省略调用方会话。请求的父 id 会被去重,并在 FTS 前根据调用方工作区权限检查;只有已授权 id 会到达提供方,而缺失猜测和跨工作区猜测的行为完全相同,root 标记仍独立使用 OR。当前会话中的 `session_event_search` 会在调用它的步骤之前立即停止,因此当前 assistant 输出和已记录工具调用无法匹配自身。直接目标在跟踪、事件或标题读取前完成授权。血缘输出会用不含隐藏会话 id 的标记替换未授权祖先和后代边界。
17
+
18
+ 每个可信 `ctx.sessionQuery` 调用都会经过一个模型边界净化器。首先检查调用方取消,并精确保留。可获取的语料库诊断信息和提供方诊断信息(包括可安全检查的嵌套原因)会尽力记录到内部日志;不可打印的失败使用固定日志占位符。诊断格式化和错误分类各自独立受保护,因此不可打印的原因无法逃逸,也无法阻止已安全分类的外层错误;不安全的分类或日志记录则回退到固定 `SESSION_QUERY_TOOL_FAILED` 代码和消息。本地参数验证和授权错误保留精确的工具自有消息。
19
+
20
+ 该包刻意不执行字节或字符截断,也不导入 spill 后端。需要限制内联输出的部署应挂载 `@deepseek-ai/dsh-spill-policy`,它可在执行后替换已渲染文本,同时保留完整结果。
21
+
22
+ ## 模型体验
23
+
24
+ ### 系统提示词
25
+
26
+ #### 模型看到的内容
27
+
28
+ 模型会收到一个固定的既往历史指引章节。
29
+
30
+ ##### 既往历史指引
31
+
32
+ ```markdown
33
+ Use session_search to find relevant work from prior sessions, or session_event_search to search earlier events in one session. Search results are cursor-free and workspace-scoped. Follow a useful hit with session_trace, session_event_trace, or session_event_read when you need lineage, relationships, or exact data.
34
+ ```
35
+
36
+ #### Token 影响
37
+
38
+ 插件挂载期间,每次请求都存在一个固定精简章节。
39
+
40
+ #### KV Cache 影响
41
+
42
+ 插件和指引文本不变时,前缀稳定。
43
+
44
+ ### 工具 schema
45
+
46
+ #### 模型看到的内容
47
+
48
+ 模型会看到生成的 [`session_search`、`session_event_search`、`session_trace`、`session_event_trace` 和 `session_event_read` schema](../../../docs/tool-catalog.md#deepseek-aidsh-tool-session-query)。搜索过滤器会增加固定 schema token,而游标、工作区路径、输出分页和模型可控结果上限仍不存在。
49
+
50
+ #### Token 影响
51
+
52
+ 可见期间,每次请求都会发送 5 个固定只读 schema。
53
+
54
+ #### KV Cache 影响
55
+
56
+ 工具可见性和定义不变时,前缀稳定。
57
+
58
+ ### 工具结果
59
+
60
+ #### 模型看到的内容
61
+
62
+ 每次成功调用都会发出一个纯文本块。搜索结果包含标题和最佳匹配摘录;跟踪包含全部已授权关系;事件读取包含未经删节的目标 JSON。通用 spill 策略可以将过大的内联文本替换为预览、不透明定位信息和取回指引。
63
+
64
+ #### Token 影响
65
+
66
+ 结果取决于数据,并保留在已记录工具历史中直到压缩(compaction);`maxSearchResults` 限制搜索命中数。
67
+
68
+ #### KV Cache 影响
69
+
70
+ 仅追加的结果文本位于可重用请求前缀之后,不会使较早的缓存条目失效。
71
+
72
+ ## 已知限制与暂缓事项
73
+
74
+ - 搜索最多返回部署上限,匹配更多时会请模型缩小查询;不提供延续 token。
75
+ - 工作区身份使用保守的字符串精确 `cwd` 相等性,因此符号链接等价的路径不共享权限。
76
+ - 未挂载通用 spill 策略的自定义组合会以内联方式接收完整跟踪和事件载荷。