@deepseek-ai/dsh-experimental-auto-review 0.1.7-alpha.2 → 0.1.7-rc.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.
- package/README.i18n.yaml +63 -5
- package/README.md +9 -9
- package/README.zh.md +9 -9
- package/icon.svg +10 -0
- package/lib/index.js +48 -7
- package/lib/types/index.d.ts +2 -0
- package/package.json +39 -36
package/README.i18n.yaml
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
|
-
# Bilingual-pair consistency record (docs/i18n/README.md):
|
|
2
|
-
#
|
|
3
|
-
#
|
|
1
|
+
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
|
|
2
|
+
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
|
3
|
+
# After editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/experimental/auto-review/README.md
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/:
|
|
6
|
+
en: 4f245200f5345e3c
|
|
7
|
+
zh: 221e9996e8ce2963
|
|
8
|
+
/deepseek-ai-dsh-experimental-auto-review:
|
|
9
|
+
en: 566562e610f1b52b
|
|
10
|
+
zh: 88796a19ab0b98b8
|
|
11
|
+
/deepseek-ai-dsh-experimental-auto-review/summary:
|
|
12
|
+
en: 1012423ee9084823
|
|
13
|
+
zh: 7021aa4e0cd3adfc
|
|
14
|
+
/deepseek-ai-dsh-experimental-auto-review/table-of-contents:
|
|
15
|
+
en: d152484eb41ac6b4
|
|
16
|
+
zh: 09388d293f9be9cb
|
|
17
|
+
/deepseek-ai-dsh-experimental-auto-review/use-this-package:
|
|
18
|
+
en: bbff250eba0f1b89
|
|
19
|
+
zh: 0a618f05cc88ee2b
|
|
20
|
+
/deepseek-ai-dsh-experimental-auto-review/use-this-package/install-into-a-profile:
|
|
21
|
+
en: 63f8f1baa0fb2655
|
|
22
|
+
zh: 6bc64160f6d02114
|
|
23
|
+
/deepseek-ai-dsh-experimental-auto-review/use-this-package/what-you-get:
|
|
24
|
+
en: 556e89c0055ae9cc
|
|
25
|
+
zh: 75afbcb9a2af6467
|
|
26
|
+
/deepseek-ai-dsh-experimental-auto-review/understand-the-implementation:
|
|
27
|
+
en: e52dbe245aef6233
|
|
28
|
+
zh: e1cbde78676fc129
|
|
29
|
+
/deepseek-ai-dsh-experimental-auto-review/further-exploration:
|
|
30
|
+
en: 8b81d32ea370ecd3
|
|
31
|
+
zh: dc53ff4da78232ac
|
|
32
|
+
/deepseek-ai-dsh-experimental-auto-review/model-experience:
|
|
33
|
+
en: 215e7ba838619b7b
|
|
34
|
+
zh: a311da3843709f90
|
|
35
|
+
/deepseek-ai-dsh-experimental-auto-review/model-experience/per-call-reviewer:
|
|
36
|
+
en: 7ec217b1012cd8fa
|
|
37
|
+
zh: 6188796b4990f2ef
|
|
38
|
+
/deepseek-ai-dsh-experimental-auto-review/model-experience/per-call-reviewer/what-the-model-sees:
|
|
39
|
+
en: b3e50d879db13221
|
|
40
|
+
zh: 81f9c8f2793bea0d
|
|
41
|
+
/deepseek-ai-dsh-experimental-auto-review/model-experience/per-call-reviewer/token-effect:
|
|
42
|
+
en: 9c3e575c061d53fe
|
|
43
|
+
zh: 74db1c5a77b2d2a7
|
|
44
|
+
/deepseek-ai-dsh-experimental-auto-review/model-experience/per-call-reviewer/kv-cache-effect:
|
|
45
|
+
en: 67b73d97f22f3c75
|
|
46
|
+
zh: 4dd263e571043cf4
|
|
47
|
+
/deepseek-ai-dsh-experimental-auto-review/model-experience/tool-denial:
|
|
48
|
+
en: f9b4d7b686f14fc5
|
|
49
|
+
zh: a2fac9a8eaf5e2a3
|
|
50
|
+
/deepseek-ai-dsh-experimental-auto-review/model-experience/tool-denial/what-the-model-sees:
|
|
51
|
+
en: a0b93e8eebc1b497
|
|
52
|
+
zh: aec11cfbf6c1ec75
|
|
53
|
+
/deepseek-ai-dsh-experimental-auto-review/model-experience/tool-denial/token-effect:
|
|
54
|
+
en: 679cb3d82e97022f
|
|
55
|
+
zh: 15c98505e75ff881
|
|
56
|
+
/deepseek-ai-dsh-experimental-auto-review/model-experience/tool-denial/kv-cache-effect:
|
|
57
|
+
en: 8da1089dee147f94
|
|
58
|
+
zh: 87361347bfd10c6c
|
|
59
|
+
/deepseek-ai-dsh-experimental-auto-review/known-limitations-and-deferred-work:
|
|
60
|
+
en: 5682fe41fcc459ab
|
|
61
|
+
zh: fa15b23a21d18ff4
|
|
62
|
+
/deepseek-ai-dsh-experimental-auto-review/known-limitations-and-deferred-work/dev-note:
|
|
63
|
+
en: e67f633dc6fe7773
|
|
64
|
+
zh: 3bb0c20c93f16f98
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
|
|
|
9
9
|
|
|
10
10
|
## Summary
|
|
11
11
|
|
|
12
|
-
Add Auto review to the current-session permission pickers in a Web profile. Before each native or PTC inner tool call, the current agent's provider and model assess the pending action; an allowed call executes with Full access. The dsh installation ships this layer switched off; default Web keeps its three permission modes until it is switched on from the Web sidebar's Plugins page or installed explicitly. Auto review is experimental: it can allow unsafe actions, deny useful work, and spend additional tokens.
|
|
12
|
+
Add Auto review to the current-session permission pickers in a Web profile. Before each native or PTC inner tool call, the current agent's provider and model assess the pending action; an allowed call executes with Full access, and a denied call asks the user. The dsh installation ships this layer switched off; default Web keeps its three permission modes until it is switched on from the Web sidebar's Plugins page or installed explicitly. Auto review is experimental: it can allow unsafe actions, deny useful work, and spend additional tokens.
|
|
13
13
|
|
|
14
14
|
## Table of Contents
|
|
15
15
|
|
|
@@ -43,9 +43,9 @@ pnpm dsh plugin --profile web remove @deepseek-ai/dsh-experimental-auto-review
|
|
|
43
43
|
|
|
44
44
|
### What you get
|
|
45
45
|
|
|
46
|
-
Auto reviews every supported call once before its body, including each started PTC `tools.*` inner call. It classifies actual effects: ordinary project-local work and exact cleanup of objects created in this Session are low risk and allowed; irreversible deletion of pre-existing objects, production operations, external writes, and security changes are medium risk and require explicit current human or direct-parent authorization of the action, target, and scope. Sensitive exfiltration across a trust boundary is high risk and always denied. Ambiguous effects
|
|
46
|
+
Auto reviews every supported call once before its body, including each started PTC `tools.*` inner call. It classifies actual effects: ordinary project-local work and exact cleanup of objects created in this Session are low risk and allowed; irreversible deletion of pre-existing objects, production operations, external writes, and security changes are medium risk and require explicit current human or direct-parent authorization of the action, target, and scope. Sensitive exfiltration across a trust boundary is high risk and always denied. Ambiguous effects and unresolved authorization conflicts are denied. Selecting Auto sets the `ask` approval policy, so a denied call asks the user and executes only after approval; a rejected or cancelled approval leaves its body unexecuted. A delegated in-process child pins the `never` policy, so its denials are final. Malformed reviewer responses and technical failures fail the call with their specific error and never execute it.
|
|
47
47
|
|
|
48
|
-
A
|
|
48
|
+
A final denial uses the ordinary tool card. The collapsed row identifies Auto review; expanded output states that the body did not execute and displays the optional reason. [The Web permission package](../../client/ui-permission-presets/README.md) owns picker interaction, and [the tool UI](../../client/ui-tool/README.md) owns reason display.
|
|
49
49
|
|
|
50
50
|
-----
|
|
51
51
|
|
|
@@ -55,11 +55,11 @@ A denied call uses the ordinary tool card. The collapsed row identifies Auto rev
|
|
|
55
55
|
<details>
|
|
56
56
|
<summary>Implementation internals — click to expand</summary>
|
|
57
57
|
|
|
58
|
-
[`cordis.patch.yml`](cordis.patch.yml) inserts the package itself as the `auto-review` row. [`src/index.ts`](src/index.ts) requires the LLM, permission, Session, and tools services, then installs the preset contribution and prepended pre-execute listener in one effect. The [permission owner](../../interaction/permission-presets/README.md) supplies the current identity and process catalog; Auto
|
|
58
|
+
[`cordis.patch.yml`](cordis.patch.yml) inserts the package itself as the `auto-review` row. [`src/index.ts`](src/index.ts) requires the approval, LLM, permission, Session, and tools services, then installs the preset contribution and prepended pre-execute listener in one effect. After the review settles, a denial reads the Session's approval policy: under `never` it is final; under `ask` the listener delegates to later pre-execute listeners and returns the tools pipeline's `ask` decision only when they allow the call, so a later denial, cancellation, or `ask` (with its own reason) takes precedence. The `ask` decision carries an English audited reason and localized prompt text that keeps the raw reviewer reason. The [permission owner](../../interaction/permission-presets/README.md) supplies the current identity and process catalog; Auto uses Full access's sandbox value with the `ask` approval policy and does not change tool definitions.
|
|
59
59
|
|
|
60
60
|
The reviewer reconstructs five sections from the current Session surface and pending execution: fixed policy, cwd-only environment, sourced project constraints, filtered sourced history, and the complete pending action. Native schema comes from the latest request header. A PTC binding freezes its schema and carries it through the scheduler into transient execution metadata; start and settle events never serialize description or parameters. Main-agent `system/message` nodes, assistant text and reasoning, and tool results are excluded. The outer review input is a frozen `RequestUserInput` without durable identity or source; retained history keeps its original source attribution in the review text. [The decision record](../../../.agents/notes/implemented/feature/2026-08-28-auto-review.md) owns authority, lifecycle, and child-inheritance rationale.
|
|
61
61
|
|
|
62
|
-
Unloading closes selection and review admission, migrates live Auto Sessions to Full access through the existing preset writer, then aborts and drains reviews before withdrawing the listener and contribution.
|
|
62
|
+
Unloading closes selection and review admission, migrates live Auto Sessions to Full access through the existing preset writer, then aborts and drains reviews before withdrawing the listener and contribution. The migration writes the `never` approval policy through the Session writer without queuing a policy-change notice; the model sees the new policy in the next runtime-context snapshot. The sandbox value and persistent terminals survive the migration. A persisted Auto Session cannot publish without the complete integration; reopening it after installation is an explicit user action. Reinstalling the layer restores the option but does not switch live Sessions back to Auto.
|
|
63
63
|
|
|
64
64
|
No runtime invariant companion is published: this single effect owns selection admission, review enrollment, cancellation, and cleanup; it has no independent observation that can diverge from those owned operations.
|
|
65
65
|
|
|
@@ -88,7 +88,7 @@ The reviewer uses the latest `request/header.config` provider and model with the
|
|
|
88
88
|
|
|
89
89
|
#### Token effect
|
|
90
90
|
|
|
91
|
-
One additional model request per supported call, without caching, retries, truncation, compaction, or a separate small output budget. An oversized request fails
|
|
91
|
+
One additional model request per supported call, without caching, retries, truncation, compaction, or a separate small output budget. An oversized request fails the call with the provider error.
|
|
92
92
|
|
|
93
93
|
#### KV Cache effect
|
|
94
94
|
|
|
@@ -98,11 +98,11 @@ The fixed reviewer policy can share a prefix; retained history and the pending a
|
|
|
98
98
|
|
|
99
99
|
#### What the model sees
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
Under the `ask` approval policy, the model sees only the approval outcome, such as `the user rejected tool "<name>"`, or the approved call's ordinary result. A final denial message is `Auto review rejected tool "<name>"; its body was not executed`. A reviewer failure message is `Auto review of tool "<name>" failed; its body was not executed: <error>`. Ordinary native error rendering prefixes each message with `Error: `. PTC uses the existing inner-call exception and catch behavior; a caught denial does not force the outer `run_code` to fail. The raw optional reason is durable structured error detail for users, never main-model content. Risk, reviewer prompt, reasoning, and raw response are not persisted.
|
|
102
102
|
|
|
103
103
|
#### Token effect
|
|
104
104
|
|
|
105
|
-
A denied call contributes only
|
|
105
|
+
A denied or failed call contributes only its ordinary error result to the main conversation.
|
|
106
106
|
|
|
107
107
|
#### KV Cache effect
|
|
108
108
|
|
|
@@ -114,7 +114,7 @@ The denial appends an ordinary tool result; it does not rewrite earlier context
|
|
|
114
114
|
|
|
115
115
|
- Auto requires this Web layer switched on; it is absent from default Web, Headless, General settings, and new-session defaults.
|
|
116
116
|
- Auto provides no file sandbox. The outer `run_code` transport and direct Node effects inside a PTC program do not pass through inner-tool review.
|
|
117
|
-
- Model classification can be wrong. There are no deterministic tool exemptions, persistent grants,
|
|
117
|
+
- Model classification can be wrong. There are no deterministic tool exemptions, persistent grants, configurable policy, or retry layer.
|
|
118
118
|
- In-process Auto children review their own calls. Out-of-process children retain their native permission systems after the parent delegation call is allowed.
|
|
119
119
|
- The reviewer reads the Session action history through the deprecated synchronous `snapshotEvents()` reader under a line-scoped waiver. Prior calls, PTC starts, and the direct parent's initial prompt have no projection or paged reader yet, so the migration stays deferred by [the synchronous-read decision](../../../.agents/notes/implemented/architecture/2026-09-09-deprecate-synchronous-session-event-reads.md).
|
|
120
120
|
|
package/README.zh.md
CHANGED
|
@@ -9,7 +9,7 @@ kind: "package-bundle"
|
|
|
9
9
|
|
|
10
10
|
## 概述
|
|
11
11
|
|
|
12
|
-
为 Web profile 当前会话权限选择器添加 Auto review。每次原生或 PTC inner 工具调用前,当前 agent 的 provider 与模型会评估待执行动作;获准调用以 Full access
|
|
12
|
+
为 Web profile 当前会话权限选择器添加 Auto review。每次原生或 PTC inner 工具调用前,当前 agent 的 provider 与模型会评估待执行动作;获准调用以 Full access 执行,被拒绝调用会请求用户审批。dsh 安装随附此层但默认关闭;在 Web 侧栏插件页开启或显式安装之前,默认 Web 保持三种权限模式。Auto review 是实验功能:它可能误放行不安全动作、误拒绝有用操作,并消耗额外 token。
|
|
13
13
|
|
|
14
14
|
## 目录
|
|
15
15
|
|
|
@@ -43,9 +43,9 @@ pnpm dsh plugin --profile web remove @deepseek-ai/dsh-experimental-auto-review
|
|
|
43
43
|
|
|
44
44
|
### 获得的能力
|
|
45
45
|
|
|
46
|
-
Auto 在每个受支持调用的 body 执行前审查一次,包括每个已开始的 PTC `tools.*` inner call。它按实际效果分类:普通项目内操作和精确清理本 Session 创建的对象属于 low,直接允许;不可逆删除既有对象、生产操作、外部写入和安全控制变更属于 medium,需要当前 human 或直接父级明确授权动作、目标与范围。跨信任边界泄露敏感信息属于 high
|
|
46
|
+
Auto 在每个受支持调用的 body 执行前审查一次,包括每个已开始的 PTC `tools.*` inner call。它按实际效果分类:普通项目内操作和精确清理本 Session 创建的对象属于 low,直接允许;不可逆删除既有对象、生产操作、外部写入和安全控制变更属于 medium,需要当前 human 或直接父级明确授权动作、目标与范围。跨信任边界泄露敏感信息属于 high,始终拒绝。效果不明确和授权冲突未解决时拒绝。选择 Auto 会设置 `ask` 审批策略,因此被拒绝调用会请求用户审批,获批后才执行;审批被拒绝或取消时 body 不执行。进程内委派 child 固定 `never` 策略,其拒绝是最终结果。Reviewer 响应不合法和技术失败会以具体错误使调用失败,且从不执行。
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
最终拒绝使用普通工具卡片。折叠行标识 Auto review;展开输出说明 body 未执行,并显示可选理由。[Web 权限包](../../client/ui-permission-presets/README.zh.md)拥有选择器交互,[工具 UI](../../client/ui-tool/README.zh.md)拥有理由展示。
|
|
49
49
|
|
|
50
50
|
-----
|
|
51
51
|
|
|
@@ -55,11 +55,11 @@ Auto 在每个受支持调用的 body 执行前审查一次,包括每个已开
|
|
|
55
55
|
<details>
|
|
56
56
|
<summary>实现内部机制——点击展开</summary>
|
|
57
57
|
|
|
58
|
-
[`cordis.patch.yml`](cordis.patch.yml)把本包自身插入为 `auto-review` 行。[`src/index.ts`](src/index.ts)要求 LLM、permission、Session 与 tools 服务,然后在同一个 effect 中安装 preset contribution 和置前的 pre-execute listener。[权限 owner](../../interaction/permission-presets/README.zh.md)提供当前身份和进程目录;Auto
|
|
58
|
+
[`cordis.patch.yml`](cordis.patch.yml)把本包自身插入为 `auto-review` 行。[`src/index.ts`](src/index.ts)要求 approval、LLM、permission、Session 与 tools 服务,然后在同一个 effect 中安装 preset contribution 和置前的 pre-execute listener。Review 结束后,拒绝会读取 Session 的审批策略:`never` 下为最终拒绝;`ask` 下 listener 先交给后续 pre-execute listener,只有它们放行调用时才返回 tools 流水线的 `ask` 决定,因此后续的拒绝、取消或 `ask`(带自己的理由)优先。`ask` 决定携带英文审计理由,以及保留原始 reviewer 理由的本地化提示文本。[权限 owner](../../interaction/permission-presets/README.zh.md)提供当前身份和进程目录;Auto 使用 Full access 的沙箱值与 `ask` 审批策略,不改变工具定义。
|
|
59
59
|
|
|
60
60
|
Reviewer 从当前 Session surface 与待执行调用重建五个分区:固定策略、仅 cwd 的环境、带来源的项目约束、过滤后带来源的历史,以及完整待审动作。原生 schema 来自最新 request header。PTC binding 冻结其 schema,经由调度器传入临时执行元数据;开始与结算事件都不序列化描述或参数 schema。主 agent 的 `system/message` 节点、assistant 正文与 reasoning、tool results 全部排除。外层评审输入是冻结的 `RequestUserInput`,不含持久身份或来源;保留历史在评审文本中仍携带原始来源。[决策记录](../../../.agents/notes/implemented/feature/2026-08-28-auto-review.zh.md)拥有权威、生命周期与 child 继承的理由。
|
|
61
61
|
|
|
62
|
-
卸载时先关闭选择与 review admission,经由既有 preset writer 将存活 Auto Session 迁移到 Full access,再中止并等待在途 review 结清,最后撤回 listener 与 contribution
|
|
62
|
+
卸载时先关闭选择与 review admission,经由既有 preset writer 将存活 Auto Session 迁移到 Full access,再中止并等待在途 review 结清,最后撤回 listener 与 contribution。迁移通过 Session writer 写入 `never` 审批策略,不排入策略变更通知;模型在下一次 runtime-context 快照中看到新策略。沙箱值与持久终端在迁移中保持不变。持久 Auto Session 缺少完整 integration 时不能发布;安装后重新打开需要用户显式操作。重装只恢复选项,不把存活 Session 切回 Auto。
|
|
63
63
|
|
|
64
64
|
本包不发布 runtime invariant companion:同一个 effect 拥有选择准入、review 登记、取消与清理,不存在能与这些自有操作相互偏离的独立观察。
|
|
65
65
|
|
|
@@ -88,7 +88,7 @@ Reviewer 使用最新 `request/header.config` 的 provider 与模型,并沿用
|
|
|
88
88
|
|
|
89
89
|
#### Token 影响
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
每个受支持调用额外产生一次模型请求,不缓存、重试、截断、压缩,也不设单独的小型输出预算。超窗请求以 provider 错误使调用失败。
|
|
92
92
|
|
|
93
93
|
#### KV Cache 影响
|
|
94
94
|
|
|
@@ -98,11 +98,11 @@ Reviewer 使用最新 `request/header.config` 的 provider 与模型,并沿用
|
|
|
98
98
|
|
|
99
99
|
#### 模型看到什么
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
在 `ask` 审批策略下,模型只看到审批结果,例如 `the user rejected tool "<name>"`,或获批调用的普通结果。最终拒绝消息为 `Auto review rejected tool "<name>"; its body was not executed`。Reviewer 失败消息为 `Auto review of tool "<name>" failed; its body was not executed: <error>`。普通原生错误渲染在每条消息前加 `Error: `。PTC 使用既有 inner-call 异常与 catch 行为;被捕获的拒绝不强制外层 `run_code` 失败。可选原始理由是面向用户的持久结构化错误详情,绝不进入主模型内容。风险、reviewer prompt、reasoning 与原始响应都不持久化。
|
|
102
102
|
|
|
103
103
|
#### Token 影响
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
被拒绝或失败的调用只向主对话贡献其普通错误结果。
|
|
106
106
|
|
|
107
107
|
#### KV Cache 影响
|
|
108
108
|
|
|
@@ -114,7 +114,7 @@ Reviewer 使用最新 `request/header.config` 的 provider 与模型,并沿用
|
|
|
114
114
|
|
|
115
115
|
- Auto 需要开启此 Web 层;默认 Web、Headless、通用设置与新会话默认值都不包含它。
|
|
116
116
|
- Auto 不提供文件沙箱。外层 `run_code` transport 及PTC 程序内直接 Node 效果不经过 inner-tool review。
|
|
117
|
-
- 模型分类可能出错。不提供确定性工具豁免、持久 grant
|
|
117
|
+
- 模型分类可能出错。不提供确定性工具豁免、持久 grant、可配置策略或重试层。
|
|
118
118
|
- 进程内 Auto child 独立审查自身调用。进程外 child 在父委派调用获准后保留原生权限系统。
|
|
119
119
|
- reviewer 在带行级豁免的情况下,通过已废弃的同步 `snapshotEvents()` 读取 Session 动作历史。此前的调用、PTC start 与直接父级的初始 prompt 目前都没有投影或分页读取方,因此迁移按[同步读取决策](../../../.agents/notes/implemented/architecture/2026-09-09-deprecate-synchronous-session-event-reads.zh.md)继续延期。
|
|
120
120
|
|
package/icon.svg
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M18 6L27.5 9.5V17.2C27.5 23.1 23.5 28.4 18 30C12.5 28.4 8.5 23.1 8.5 17.2V9.5L18 6Z" fill="url(#a)" />
|
|
3
|
+
<path d="M13.5 18L16.6 21.1L22.9 14.8" stroke="#FFFFFF" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" />
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient id="a" x1="18" y1="6" x2="18" y2="30" gradientUnits="userSpaceOnUse">
|
|
6
|
+
<stop stop-color="#7CB7FF" />
|
|
7
|
+
<stop offset="1" stop-color="#145AF3" />
|
|
8
|
+
</linearGradient>
|
|
9
|
+
</defs>
|
|
10
|
+
</svg>
|
package/lib/index.js
CHANGED
|
@@ -7,12 +7,14 @@ import { RUN_CODE_NAME } from "@deepseek-ai/dsh-tools";
|
|
|
7
7
|
* LLM-backed authorization gate for the current-session-only Auto permission
|
|
8
8
|
* preset. Every native call and every started PTC inner call is reviewed once
|
|
9
9
|
* before its body; the outer `run_code` transport is deliberately excluded.
|
|
10
|
+
* Under the `ask` approval policy a reviewer denial asks the user; under
|
|
11
|
+
* `never` it is final.
|
|
10
12
|
*
|
|
11
13
|
* @module @deepseek-ai/dsh-experimental-auto-review
|
|
12
14
|
*/
|
|
13
|
-
/** Structured error name persisted for every reviewer denial
|
|
15
|
+
/** Structured error name persisted for every final reviewer denial. */
|
|
14
16
|
const AUTO_REVIEW_DENIED_ERROR_NAME = "AutoReviewDeniedError";
|
|
15
|
-
/** Structured error code persisted for every reviewer denial
|
|
17
|
+
/** Structured error code persisted for every final reviewer denial. */
|
|
16
18
|
const AUTO_REVIEW_DENIED_CODE = "AUTO_REVIEW_DENIED";
|
|
17
19
|
/** Fixed policy sent as the first of the review request's five sections. */
|
|
18
20
|
const REVIEW_POLICY = `REVIEW_POLICY
|
|
@@ -41,6 +43,7 @@ For any allow, end with exactly the applicable two-member object and nothing els
|
|
|
41
43
|
const name = "experimental-auto-review";
|
|
42
44
|
/** Complete host services required before Auto may be advertised. */
|
|
43
45
|
const inject = [
|
|
46
|
+
"approval",
|
|
44
47
|
"llm",
|
|
45
48
|
"permissionPresets",
|
|
46
49
|
"sessions",
|
|
@@ -379,6 +382,10 @@ async function readDecision(stream) {
|
|
|
379
382
|
assembler.push(chunk);
|
|
380
383
|
if (chunk.type === "finish") {
|
|
381
384
|
finished = true;
|
|
385
|
+
if (chunk.reason.kind === "error" || chunk.reason.kind === "aborted") {
|
|
386
|
+
const { code, message } = chunk.reason.failure;
|
|
387
|
+
throw new Error(`auto-review: reviewer ended with ${chunk.reason.kind} ${code}: ${message}`);
|
|
388
|
+
}
|
|
382
389
|
if (chunk.reason.kind !== "stop") throw new Error(`auto-review: reviewer ended with ${chunk.reason.kind}`);
|
|
383
390
|
}
|
|
384
391
|
}
|
|
@@ -407,7 +414,7 @@ async function classifyRisk(ctx, agent, exec, signal) {
|
|
|
407
414
|
});
|
|
408
415
|
return readDecision(ctx.llm.stream(options));
|
|
409
416
|
}
|
|
410
|
-
/** Materialize the fixed model-facing Auto denial plus optional UI detail. */
|
|
417
|
+
/** Materialize the fixed model-facing final Auto denial plus optional UI detail. */
|
|
411
418
|
function denied(exec, reason) {
|
|
412
419
|
return {
|
|
413
420
|
kind: "deny",
|
|
@@ -419,6 +426,32 @@ function denied(exec, reason) {
|
|
|
419
426
|
}
|
|
420
427
|
};
|
|
421
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Ask the user to decide one call the reviewer denied. The audited reason is
|
|
431
|
+
* English; the prompt text is localized and keeps the reviewer's raw reason.
|
|
432
|
+
*/
|
|
433
|
+
function askUser(exec, reason) {
|
|
434
|
+
const denial = `Auto review denied tool "${exec.name}"`;
|
|
435
|
+
return {
|
|
436
|
+
kind: "ask",
|
|
437
|
+
reason: reason === void 0 ? denial : `${denial}: ${reason}`,
|
|
438
|
+
displayReason: reason === void 0 ? {
|
|
439
|
+
en: "Auto review denied this call.",
|
|
440
|
+
zh: "Auto review 拒绝了此调用。"
|
|
441
|
+
} : {
|
|
442
|
+
en: `Auto review denied this call: ${reason}`,
|
|
443
|
+
zh: `Auto review 拒绝了此调用:${reason}`
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
/** Materialize a reviewer failure as its own error rather than a denial. */
|
|
448
|
+
function failed(exec, error) {
|
|
449
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
450
|
+
return {
|
|
451
|
+
kind: "deny",
|
|
452
|
+
reason: `Auto review of tool "${exec.name}" failed; its body was not executed: ${message}`
|
|
453
|
+
};
|
|
454
|
+
}
|
|
422
455
|
/** Install the Auto preset and its prepended per-call review gate. */
|
|
423
456
|
function apply(ctx) {
|
|
424
457
|
const permissionPresets = ctx.permissionPresets;
|
|
@@ -434,13 +467,21 @@ function apply(ctx) {
|
|
|
434
467
|
const completed = Promise.withResolvers();
|
|
435
468
|
active.add(completed.promise);
|
|
436
469
|
try {
|
|
437
|
-
const
|
|
470
|
+
const review = await classifyRisk(ctx, agent, exec, AbortSignal.any([exec.signal, lifecycle.signal])).then((decision) => ({
|
|
471
|
+
ok: true,
|
|
472
|
+
decision
|
|
473
|
+
}), (error) => ({
|
|
474
|
+
ok: false,
|
|
475
|
+
error
|
|
476
|
+
}));
|
|
438
477
|
if (isAborted(lifecycle.signal)) return { kind: "cancel" };
|
|
439
|
-
if (
|
|
440
|
-
|
|
478
|
+
if (!review.ok) return failed(exec, review.error);
|
|
479
|
+
const { decision } = review;
|
|
480
|
+
if (decision.decision === "deny" && ctx.approval.overrideOf(agent.session) === "never") return denied(exec, decision.reason);
|
|
441
481
|
const downstream = await next();
|
|
442
482
|
if (isAborted(lifecycle.signal)) return { kind: "cancel" };
|
|
443
|
-
return downstream;
|
|
483
|
+
if (decision.decision === "allow" || downstream.kind !== "allow") return downstream;
|
|
484
|
+
return askUser(exec, decision.reason);
|
|
444
485
|
} finally {
|
|
445
486
|
active.delete(completed.promise);
|
|
446
487
|
completed.resolve();
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* LLM-backed authorization gate for the current-session-only Auto permission
|
|
3
3
|
* preset. Every native call and every started PTC inner call is reviewed once
|
|
4
4
|
* before its body; the outer `run_code` transport is deliberately excluded.
|
|
5
|
+
* Under the `ask` approval policy a reviewer denial asks the user; under
|
|
6
|
+
* `never` it is final.
|
|
5
7
|
*
|
|
6
8
|
* @module @deepseek-ai/dsh-experimental-auto-review
|
|
7
9
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-experimental-auto-review",
|
|
3
3
|
"description": "Per-tool LLM authorization review for the DeepSeek Harness Auto permission preset",
|
|
4
|
-
"version": "0.1.7-
|
|
4
|
+
"version": "0.1.7-rc.2",
|
|
5
|
+
"icon": "./icon.svg",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
8
|
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
"./cordis.patch.yml": "./cordis.patch.yml"
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
25
|
+
"icon.svg",
|
|
24
26
|
"locale/*.json",
|
|
25
27
|
"lib/index.js",
|
|
26
28
|
"cordis.patch.yml",
|
|
@@ -28,46 +30,47 @@
|
|
|
28
30
|
],
|
|
29
31
|
"license": "MIT",
|
|
30
32
|
"peerDependencies": {
|
|
31
|
-
"@deepseek-ai/dsh-agent": "0.1.7-
|
|
32
|
-
"@deepseek-ai/dsh-
|
|
33
|
-
"@deepseek-ai/dsh-
|
|
34
|
-
"@deepseek-ai/dsh-permission-presets": "0.1.7-
|
|
35
|
-
"@deepseek-ai/dsh-session": "0.1.7-
|
|
36
|
-
"@deepseek-ai/dsh-tools": "0.1.7-
|
|
33
|
+
"@deepseek-ai/dsh-agent": "0.1.7-rc.2",
|
|
34
|
+
"@deepseek-ai/dsh-agent-instructions": "0.1.7-rc.2",
|
|
35
|
+
"@deepseek-ai/dsh-llm": "0.1.7-rc.2",
|
|
36
|
+
"@deepseek-ai/dsh-permission-presets": "0.1.7-rc.2",
|
|
37
|
+
"@deepseek-ai/dsh-session": "0.1.7-rc.2",
|
|
38
|
+
"@deepseek-ai/dsh-tools": "0.1.7-rc.2",
|
|
37
39
|
"@deepseek-ai/cordis": "~4.0.4"
|
|
38
40
|
},
|
|
39
41
|
"dependencies": {
|
|
40
|
-
"@deepseek-ai/dsh-util-values": "0.1.7-
|
|
42
|
+
"@deepseek-ai/dsh-util-values": "0.1.7-rc.2"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
|
-
"@deepseek-ai/dsh-agent": "0.1.7-
|
|
44
|
-
"@deepseek-ai/dsh-agent-instructions": "0.1.7-
|
|
45
|
-
"@deepseek-ai/dsh-
|
|
46
|
-
"@deepseek-ai/dsh-
|
|
47
|
-
"@deepseek-ai/dsh-
|
|
48
|
-
"@deepseek-ai/dsh-
|
|
49
|
-
"@deepseek-ai/dsh-fs-local": "0.1.7-
|
|
50
|
-
"@deepseek-ai/dsh-
|
|
51
|
-
"@deepseek-ai/dsh-
|
|
52
|
-
"@deepseek-ai/dsh-
|
|
53
|
-
"@deepseek-ai/dsh-
|
|
54
|
-
"@deepseek-ai/dsh-
|
|
55
|
-
"@deepseek-ai/dsh-
|
|
56
|
-
"@deepseek-ai/dsh-
|
|
57
|
-
"@deepseek-ai/dsh-
|
|
58
|
-
"@deepseek-ai/dsh-
|
|
59
|
-
"@deepseek-ai/dsh-
|
|
60
|
-
"@deepseek-ai/dsh-
|
|
61
|
-
"@deepseek-ai/dsh-
|
|
62
|
-
"@deepseek-ai/dsh-
|
|
63
|
-
"@deepseek-ai/dsh-
|
|
64
|
-
"@deepseek-ai/dsh-
|
|
65
|
-
"@deepseek-ai/dsh-
|
|
66
|
-
"@deepseek-ai/dsh-
|
|
67
|
-
"@deepseek-ai/dsh-
|
|
68
|
-
"@deepseek-ai/
|
|
69
|
-
"@deepseek-ai/dsh-
|
|
70
|
-
"@deepseek-ai/dsh-
|
|
45
|
+
"@deepseek-ai/dsh-agent": "0.1.7-rc.2",
|
|
46
|
+
"@deepseek-ai/dsh-agent-instructions": "0.1.7-rc.2",
|
|
47
|
+
"@deepseek-ai/dsh-bash-sandbox": "0.1.7-rc.2",
|
|
48
|
+
"@deepseek-ai/dsh-compaction": "0.1.7-rc.2",
|
|
49
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "0.1.7-rc.2",
|
|
50
|
+
"@deepseek-ai/dsh-agent-loop": "0.1.7-rc.2",
|
|
51
|
+
"@deepseek-ai/dsh-fs-local": "0.1.7-rc.2",
|
|
52
|
+
"@deepseek-ai/dsh-fs-observation-policy": "0.1.7-rc.2",
|
|
53
|
+
"@deepseek-ai/dsh-fs-sandbox": "0.1.7-rc.2",
|
|
54
|
+
"@deepseek-ai/dsh-llm": "0.1.7-rc.2",
|
|
55
|
+
"@deepseek-ai/dsh-llm-deepseek": "0.1.7-rc.2",
|
|
56
|
+
"@deepseek-ai/dsh-llm-deepseek-api-key": "0.1.7-rc.2",
|
|
57
|
+
"@deepseek-ai/dsh-permission-presets": "0.1.7-rc.2",
|
|
58
|
+
"@deepseek-ai/dsh-ptc-runtime-node": "0.1.7-rc.2",
|
|
59
|
+
"@deepseek-ai/dsh-sandbox": "0.1.7-rc.2",
|
|
60
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.1.7-rc.2",
|
|
61
|
+
"@deepseek-ai/dsh-session-projection": "0.1.7-rc.2",
|
|
62
|
+
"@deepseek-ai/dsh-shell": "0.1.7-rc.2",
|
|
63
|
+
"@deepseek-ai/dsh-shell-env": "0.1.7-rc.2",
|
|
64
|
+
"@deepseek-ai/dsh-subprocess-local": "0.1.7-rc.2",
|
|
65
|
+
"@deepseek-ai/dsh-subagent": "0.1.7-rc.2",
|
|
66
|
+
"@deepseek-ai/dsh-system-prompt": "0.1.7-rc.2",
|
|
67
|
+
"@deepseek-ai/dsh-session": "0.1.7-rc.2",
|
|
68
|
+
"@deepseek-ai/dsh-tool-bash": "0.1.7-rc.2",
|
|
69
|
+
"@deepseek-ai/dsh-tool-fs": "0.1.7-rc.2",
|
|
70
|
+
"@deepseek-ai/dsh-tool-subagent": "0.1.7-rc.2",
|
|
71
|
+
"@deepseek-ai/dsh-user-approval": "0.1.7-rc.2",
|
|
72
|
+
"@deepseek-ai/dsh-tools": "0.1.7-rc.2",
|
|
73
|
+
"@deepseek-ai/cordis": "~4.0.4"
|
|
71
74
|
},
|
|
72
75
|
"publishConfig": {
|
|
73
76
|
"access": "public"
|