mirror of
https://github.com/yexi-by/dsh-unrestricted.git
synced 2026-11-28 02:30:22 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7beb2d2546 | ||
|
|
58adb081b9 |
No files matched your search
+5
-5
@@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
`dsh-unrestricted` is a system prompt unrestrict (jailbreak) plugin for **DeepSeek Harness (DSH)**. It injects purpose-built unrestrict rules directly into DSH's system prompts, removing refusal boundaries across reverse engineering, penetration testing, creative writing, and specialized technical operations, enabling models to directly output complete, actionable implementations and code.
|
`dsh-unrestricted` is a system prompt unrestrict (jailbreak) plugin for **DeepSeek Harness (DSH)**. It injects purpose-built unrestrict rules directly into DSH's system prompts, removing refusal boundaries across reverse engineering, penetration testing, creative writing, and specialized technical operations, enabling models to directly output complete, actionable implementations and code.
|
||||||
|
|
||||||
The plugin is deeply integrated into DSH's prompt assembly pipeline. While injecting unrestrict rules, it strictly preserves DSH's tool-calling protocols, Plan Mode, code execution (PTC), and subagent mechanics.
|
The plugin stays lightweight: the existing switches enable or disable the rules as a whole, preserving DSH's interface layout, tool-calling protocols, Plan Mode, code execution (PTC), and subagent mechanics.
|
||||||
|
|
||||||
`0.2.3` passes type checking, builds, and real-host integration checks against DSH `0.2.1-alpha.4` (`86a402200d`). It refines blank-session `minimal` preset switching, rosterless profile (`headless`/`sdk`) support, subagent preview isolation, and client state synchronization. The declared `engines.dsh` range is `>=0.2.0-rc.2 <0.2.2-0`, retaining installation support for the local `0.2.0-rc.2` desktop runtime; no desktop UI check was performed in this update.
|
`0.2.4` fixes prompt registration conflicts in Minimal subagents with custom personas, missing native structured-output instructions, and overlapping settings requests that could overwrite a newer preview or clear the busy state too early. The prompt rules and existing switches remain unchanged. It supports DSH `0.2.1-rc.2` (`687f282e86`) with `engines.dsh` set to `>=0.2.0-rc.2 <0.2.2-0`, retaining installation support for desktop `0.2.0-rc.2`. For desktop, this update synchronizes the installed plugin only; the desktop UI is not operated or tested.
|
||||||
|
|
||||||
The native model reasoning settings and plugin index do not replace this plugin's per-mode prompt assembly. Reasoning levels remain managed by the native model settings.
|
The native model reasoning settings and plugin index do not replace this plugin's per-mode prompt assembly. Reasoning levels remain managed by the native model settings.
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ The plugin coordinates rules across all DSH execution presets:
|
|||||||
- **Standard & Cordis Modes**: Injects the unrestrict block directly after the persona prefix, keeping all built-in tools (terminal, filesystem, web search) functional.
|
- **Standard & Cordis Modes**: Injects the unrestrict block directly after the persona prefix, keeping all built-in tools (terminal, filesystem, web search) functional.
|
||||||
- **PTC Mode (Code-Only Execution)**: Since PTC agents interact only via `run_code`, an additional guideline is injected into `tools:ptc-only`, clarifying that Python/Node scripts executed inside `run_code` are unconstrained and free to use internal SDK tools for automated analysis.
|
- **PTC Mode (Code-Only Execution)**: Since PTC agents interact only via `run_code`, an additional guideline is injected into `tools:ptc-only`, clarifying that Python/Node scripts executed inside `run_code` are unconstrained and free to use internal SDK tools for automated analysis.
|
||||||
- **Plan Mode**: Decouples operational constraints from planning depth. The plugin explicitly reinforces that **operational constraints apply only to mutations** (no file edits prior to approval), but **the plan markdown must contain unabridged technical procedures, exploit mechanisms, or reverse engineering steps**.
|
- **Plan Mode**: Decouples operational constraints from planning depth. The plugin explicitly reinforces that **operational constraints apply only to mutations** (no file edits prior to approval), but **the plan markdown must contain unabridged technical procedures, exploit mechanisms, or reverse engineering steps**.
|
||||||
- **Minimal Mode**: Uses an agent-scoped shadow override to supply the fused minimal persona, cleanly releasing it upon deactivation.
|
- **Minimal Mode**: Injects rules in the current agent scope while preserving custom subagent personas and native structured-output instructions, avoiding duplicate persona registration. Disabling the plugin restores the original prompt.
|
||||||
- **Subagents & Structured Output**: Background child agents and structured reporting (`structured_output`) automatically inherit the unrestrict rules.
|
- **Subagents & Structured Output**: Background child agents and structured reporting (`structured_output`) automatically inherit the unrestrict rules.
|
||||||
|
|
||||||
### Anchor Text Verification & Safe Fallback
|
### Anchor Text Verification & Safe Fallback
|
||||||
@@ -111,7 +111,7 @@ For CLI and server setups running `dsh web`.
|
|||||||
#### Install
|
#### Install
|
||||||
```sh
|
```sh
|
||||||
# Install specific tag
|
# Install specific tag
|
||||||
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.3
|
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.4
|
||||||
|
|
||||||
# Or track master
|
# Or track master
|
||||||
dsh plugin --profile web add github:yexi-by/dsh-unrestricted
|
dsh plugin --profile web add github:yexi-by/dsh-unrestricted
|
||||||
@@ -148,7 +148,7 @@ On Windows, the default path is:
|
|||||||
1. Completely exit the desktop app.
|
1. Completely exit the desktop app.
|
||||||
2. Run in PowerShell or CMD:
|
2. Run in PowerShell or CMD:
|
||||||
```powershell
|
```powershell
|
||||||
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.3
|
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.4
|
||||||
```
|
```
|
||||||
3. Launch the desktop app and follow the activation steps below.
|
3. Launch the desktop app and follow the activation steps below.
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
`dsh-unrestricted` は、**DeepSeek Harness (DSH)** 向けのプロンプト制限解除(アンレストリクト)プラグインです。システムプロンプト(System Prompt)に専用の制限解除ルールを注入することで、リバースエンジニアリング、ペネトレーションテスト、創作執筆、特殊技術手順における回答拒否や説教を解除し、完全で実行可能なコードと技術ソリューションを直接出力させます。
|
`dsh-unrestricted` は、**DeepSeek Harness (DSH)** 向けのプロンプト制限解除(アンレストリクト)プラグインです。システムプロンプト(System Prompt)に専用の制限解除ルールを注入することで、リバースエンジニアリング、ペネトレーションテスト、創作執筆、特殊技術手順における回答拒否や説教を解除し、完全で実行可能なコードと技術ソリューションを直接出力させます。
|
||||||
|
|
||||||
プラグインは DSH のプロンプト構築メカニズムに深く適合しており、制限解除ルールを動的に注入しつつ、DSH のツール呼び出しプロトコル、計画モード(Plan Mode)、コード実行(PTC)、サブエージェントの実行ロジックを完全に維持します。
|
プラグインは軽量な構成を維持し、既存のスイッチでルール全体を有効・無効にします。DSH 本来の画面レイアウト、ツール呼び出しプロトコル、計画モード(Plan Mode)、コード実行(PTC)、サブエージェントの実行ロジックを維持します。
|
||||||
|
|
||||||
`0.2.3` は DSH `0.2.1-alpha.4`(`86a402200d`)で型チェック、ビルド、実ホスト統合検証を完了しています。新規セッションの `minimal` 切り替え、`headless`/`sdk` 対応、サブエージェントのプレビュー分離、クライアント状態同期を改善しました。`engines.dsh` は `>=0.2.0-rc.2 <0.2.2-0` で、ローカルのデスクトップ版 `0.2.0-rc.2` へのインストールを引き続きサポートします。今回デスクトップ UI は操作していません。
|
`0.2.4` は、カスタムペルソナを持つ Minimal サブエージェントのプロンプト登録競合、公式の構造化出力指示の欠落、設定画面の並行リクエストによる古いプレビューの上書きや処理中状態の早期解除を修正します。既存のプロンプトルールとスイッチは変更しません。DSH `0.2.1-rc.2`(`687f282e86`)に対応し、`engines.dsh` は `>=0.2.0-rc.2 <0.2.2-0` です。デスクトップ版 `0.2.0-rc.2` へのインストールも引き続きサポートします。今回はローカルのデスクトップ用インストールのみ同期し、デスクトップ UI の操作・検証は行いません。
|
||||||
|
|
||||||
公式の推論レベル設定とプラグイン索引は、本プラグインのモード別プロンプト組み立てを代替しません。推論レベルは公式のモデル設定で管理します。
|
公式の推論レベル設定とプラグイン索引は、本プラグインのモード別プロンプト組み立てを代替しません。推論レベルは公式のモデル設定で管理します。
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
- **Standard / Cordis モード**:全ツール定義を維持しつつ、ペルソナ直後に制限解除ブロックを挿入します。
|
- **Standard / Cordis モード**:全ツール定義を維持しつつ、ペルソナ直後に制限解除ブロックを挿入します。
|
||||||
- **PTC モード(コード実行専用)**:PTC では `run_code` のみが使用可能です。プラグインは `tools:ptc-only` に注記を追加し、Python/Node 内部で実行されるスクリプトや SDK ツール呼び出しにも制限解除を適用します。
|
- **PTC モード(コード実行専用)**:PTC では `run_code` のみが使用可能です。プラグインは `tools:ptc-only` に注記を追加し、Python/Node 内部で実行されるスクリプトや SDK ツール呼び出しにも制限解除を適用します。
|
||||||
- **Plan Mode(計画モード)**:安全上の制約は「実行のタイミング」(承認前のファイル変更禁止)にのみ適用され、計画ドキュメント(Markdown)内では技術的な手順やコードを制限なくすべて展開するよう指示します。
|
- **Plan Mode(計画モード)**:安全上の制約は「実行のタイミング」(承認前のファイル変更禁止)にのみ適用され、計画ドキュメント(Markdown)内では技術的な手順やコードを制限なくすべて展開するよう指示します。
|
||||||
- **Minimal モード**:エージェントスコープでペルソナを適切に置換し、制限解除ルールを注入します。無効化時には自動的に元の最小ペルソナへ復帰します。
|
- **Minimal モード**:現在のエージェントスコープでルールを注入し、サブエージェントのカスタムペルソナと公式の構造化出力指示を保持します。ペルソナの重複登録を避け、無効化時には元のプロンプトへ復帰します。
|
||||||
- **サブエージェント**:派生したバックグラウンドタスクや構造化出力(`structured_output`)も自動的に制限解除設定を継承します。
|
- **サブエージェント**:派生したバックグラウンドタスクや構造化出力(`structured_output`)も自動的に制限解除設定を継承します。
|
||||||
|
|
||||||
### アンカー検証と自動安全フォールバック
|
### アンカー検証と自動安全フォールバック
|
||||||
@@ -109,7 +109,7 @@ CLI またはサーバー環境で `dsh web` を実行している場合。
|
|||||||
#### インストール
|
#### インストール
|
||||||
```sh
|
```sh
|
||||||
# 指定バージョンのインストール
|
# 指定バージョンのインストール
|
||||||
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.3
|
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.4
|
||||||
|
|
||||||
# または master 最新コードのインストール
|
# または master 最新コードのインストール
|
||||||
dsh plugin --profile web add github:yexi-by/dsh-unrestricted
|
dsh plugin --profile web add github:yexi-by/dsh-unrestricted
|
||||||
@@ -146,7 +146,7 @@ Windows の標準パス:
|
|||||||
1. デスクトップアプリを完全に終了します。
|
1. デスクトップアプリを完全に終了します。
|
||||||
2. PowerShell 等で以下を実行します:
|
2. PowerShell 等で以下を実行します:
|
||||||
```powershell
|
```powershell
|
||||||
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.3
|
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.4
|
||||||
```
|
```
|
||||||
3. デスクトップアプリを起動し、下記の使用方法に従って設定を完了します。
|
3. デスクトップアプリを起動し、下記の使用方法に従って設定を完了します。
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
`dsh-unrestricted` 是 DeepSeek Harness(DSH)的提示词破限插件。插件通过尝试向系统提示词(System Prompt)注入专门设计的破限规则,解除模型在代码逆向、网络安全、敏感内容创作等场景下的回答限制,让模型直接输出完整、可用的技术实现与代码方案。
|
`dsh-unrestricted` 是 DeepSeek Harness(DSH)的提示词破限插件。插件通过尝试向系统提示词(System Prompt)注入专门设计的破限规则,解除模型在代码逆向、网络安全、敏感内容创作等场景下的回答限制,让模型直接输出完整、可用的技术实现与代码方案。
|
||||||
|
|
||||||
插件针对 DSH 的提示词组装机制进行了深度适配,在动态注入破限提示词的同时,完整保留 DSH 的工具调用协议、计划模式(Plan Mode)、代码执行(PTC)以及子代理运行逻辑。
|
插件保持轻量:通过现有开关整体启停破限规则,保留 DSH 原有的界面布局、工具调用协议、计划模式(Plan Mode)、代码执行(PTC)以及子代理运行逻辑。
|
||||||
|
|
||||||
`0.2.3` 已在 DSH `0.2.1-alpha.4`(`86a402200d`)完成类型检查、构建与真实宿主集成验证,完善空白会话切换 `minimal` 预设时的遮蔽同步、无预设注册表(`headless`/`sdk`)环境支持、子代理预览隔离与前端状态同步。`engines.dsh` 声明为 `>=0.2.0-rc.2 <0.2.2-0`,保留本机桌面版 `0.2.0-rc.2` 的安装支持;本轮不操作桌面界面。
|
`0.2.4` 修复 Minimal 自定义角色子代理的提示词注册冲突、结构化子代理遗漏官方输出指引,以及设置页并发请求导致的旧预览覆盖和忙碌状态提前解除。现有提示词规则与开关保持不变。支持 DSH `0.2.1-rc.2`(`687f282e86`),`engines.dsh` 为 `>=0.2.0-rc.2 <0.2.2-0`;保留桌面版 `0.2.0-rc.2` 的安装支持,本轮桌面端仅同步安装副本,不操作或验证桌面界面。
|
||||||
|
|
||||||
官方新增的自定义模型推理等级与插件索引不替代本插件的按模式提示词组装功能;本轮保留插件。模型推理等级统一由官方模型设置管理。
|
官方新增的自定义模型推理等级与插件索引不替代本插件的按模式提示词组装功能;本轮保留插件。模型推理等级统一由官方模型设置管理。
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
- **标准模式(Standard)与 Cordis 模式**:保留所有原生工具定义,在角色设定后注入破限规则,使模型在编写代码、执行系统命令和搜索网络时解除限制。
|
- **标准模式(Standard)与 Cordis 模式**:保留所有原生工具定义,在角色设定后注入破限规则,使模型在编写代码、执行系统命令和搜索网络时解除限制。
|
||||||
- **代码执行模式(PTC)**:PTC 模式下模型仅能调用 `run_code`。插件在 `tools:ptc-only` 中补充规则,指示模型在编写 Python/Node 脚本时同样遵循无限制规则,脚本内部调用 SDK 工具进行安全扫描或逆向分析不受对话限制。
|
- **代码执行模式(PTC)**:PTC 模式下模型仅能调用 `run_code`。插件在 `tools:ptc-only` 中补充规则,指示模型在编写 Python/Node 脚本时同样遵循无限制规则,脚本内部调用 SDK 工具进行安全扫描或逆向分析不受对话限制。
|
||||||
- **计划模式(Plan Mode)**:将“操作安全”与“方案内容”解耦。插件明确指引:**安全限制仅约束执行时机**(在用户审批前不得修改文件),但在计划草案(Markdown)中,模型必须**毫无保留地展开完整的技术细节、攻击路径与实现代码**。
|
- **计划模式(Plan Mode)**:将“操作安全”与“方案内容”解耦。插件明确指引:**安全限制仅约束执行时机**(在用户审批前不得修改文件),但在计划草案(Markdown)中,模型必须**毫无保留地展开完整的技术细节、攻击路径与实现代码**。
|
||||||
- **极简模式(Minimal)**:极简模式在底层使用独立的作用域注册机制。插件通过代理替换完整的角色设定实现注入,关闭开关时自动释放代理并恢复原版。
|
- **极简模式(Minimal)**:在当前智能体作用域中注入规则,保留子代理的自定义角色正文与官方结构化输出指引,避免重复注册角色提示词;关闭开关时恢复原版。
|
||||||
- **子代理与工作流**:派生出的后台子代理及带有结构化输出(`structured_output`)的子任务,均自动继承父级模式的破限规则。
|
- **子代理与工作流**:派生出的后台子代理及带有结构化输出(`structured_output`)的子任务,均自动继承父级模式的破限规则。
|
||||||
|
|
||||||
### 特征文本校验与安全降级
|
### 特征文本校验与安全降级
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
#### 安装
|
#### 安装
|
||||||
```sh
|
```sh
|
||||||
# 安装指定版本
|
# 安装指定版本
|
||||||
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.3
|
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.4
|
||||||
|
|
||||||
# 或安装 master 最新代码
|
# 或安装 master 最新代码
|
||||||
dsh plugin --profile web add github:yexi-by/dsh-unrestricted
|
dsh plugin --profile web add github:yexi-by/dsh-unrestricted
|
||||||
@@ -148,7 +148,7 @@ dsh plugin --profile web remove dsh-unrestricted
|
|||||||
1. 完全退出正在运行的桌面客户端。
|
1. 完全退出正在运行的桌面客户端。
|
||||||
2. 打开 PowerShell 或 CMD,执行安装命令:
|
2. 打开 PowerShell 或 CMD,执行安装命令:
|
||||||
```powershell
|
```powershell
|
||||||
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.3
|
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.4
|
||||||
```
|
```
|
||||||
3. 启动桌面客户端,按下方说明启用插件与功能开关。
|
3. 启动桌面客户端,按下方说明启用插件与功能开关。
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ DSH provides distinct execution modes with differing prompt structures and tool
|
|||||||
|
|
||||||
### Minimal Mode
|
### Minimal Mode
|
||||||
- **Profile**: Minimal terminal assistant with an isolated scope registration.
|
- **Profile**: Minimal terminal assistant with an isolated scope registration.
|
||||||
- **Coordination**: Uses an agent-scoped shadow override to supply the fused minimal persona, seamlessly releasing it upon deactivation.
|
- **Coordination**: Preserves the persona text while injecting rules in the current agent scope, restoring the original prompt upon deactivation. `0.2.4` fixes assembly failures caused by duplicate persona registration in Minimal subagents with custom personas and preserves the native `structured_output` instructions required by structured subagents.
|
||||||
|
|
||||||
### Subagents & Structured Output
|
### Subagents & Structured Output
|
||||||
- **Subagents**: Background child agents inherit the unrestrict rules of their parent mode.
|
- **Subagents**: Background child agents inherit the unrestrict rules of their parent mode.
|
||||||
@@ -84,12 +84,14 @@ Computes a SHA-256 hash (first 16 hex characters) of the unrestrict text block,
|
|||||||
### Realtime Prompt Preview
|
### Realtime Prompt Preview
|
||||||
An RPC endpoint renders the exact, fully assembled prompt text, total line count, and byte size for each mode, ensuring complete transparency.
|
An RPC endpoint renders the exact, fully assembled prompt text, total line count, and byte size for each mode, ensuring complete transparency.
|
||||||
|
|
||||||
|
When refreshes or rechecks overlap, stale responses cannot overwrite the latest status or preview. The busy state remains active until all pending status operations finish.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 5. Automated Testing
|
## 5. Automated Testing
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Run the 33-assertion test suite
|
# Run the test suite
|
||||||
pnpm test
|
pnpm test
|
||||||
|
|
||||||
# Dump fresh prompts from DSH source to update fixtures
|
# Dump fresh prompts from DSH source to update fixtures
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ DSH は複数の実行モードを備えており、プラグインはそれぞ
|
|||||||
|
|
||||||
### Minimal(最小モード)
|
### Minimal(最小モード)
|
||||||
- **特徴**:非常に軽量なプロンプト構成のエージェント。
|
- **特徴**:非常に軽量なプロンプト構成のエージェント。
|
||||||
- **適応**:エージェントスコープでペルソナを適切に置換し、制限解除ルールを注入します。無効化時には自動的に元の最小ペルソナへ復帰します。
|
- **適応**:現在のエージェントスコープでペルソナ本文を保持しながらルールを注入し、無効化時には元のプロンプトへ復帰します。`0.2.4` は、カスタムペルソナを持つ Minimal サブエージェントで重複登録によって組み立てが失敗する問題を修正し、構造化サブエージェントに必要な公式の `structured_output` 呼び出し指示を保持します。
|
||||||
|
|
||||||
### サブエージェントおよび構造化出力
|
### サブエージェントおよび構造化出力
|
||||||
- **サブエージェント**:バックグラウンドで起動されるサブエージェントは親モードの制限解除設定を自動継承します。
|
- **サブエージェント**:バックグラウンドで起動されるサブエージェントは親モードの制限解除設定を自動継承します。
|
||||||
@@ -84,12 +84,14 @@ DSH 本体のバージョン更新によるプロンプト構造の変化を検
|
|||||||
### リアルタイムプロンプトプレビュー
|
### リアルタイムプロンプトプレビュー
|
||||||
UI 上の「プレビューを表示」をクリックすることで、実際にモデルへ送信されるシステムプロンプトの全文、行数、バイトサイズをリアルタイムに確認できます。
|
UI 上の「プレビューを表示」をクリックすることで、実際にモデルへ送信されるシステムプロンプトの全文、行数、バイトサイズをリアルタイムに確認できます。
|
||||||
|
|
||||||
|
更新や再確認が重なっても、古いリクエストの結果が最新の状態やプレビューを上書きすることはありません。処理中の表示は、保留中の状態操作がすべて完了するまで維持します。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 5. 自動テストと検証
|
## 5. 自動テストと検証
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# 33 項目のテストを実行
|
# テストを実行
|
||||||
pnpm test
|
pnpm test
|
||||||
|
|
||||||
# DSH 源码から最新プロンプトを抽出し fixtures を更新
|
# DSH 源码から最新プロンプトを抽出し fixtures を更新
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ DSH 支持多种工作模式,各模式下的提示词结构和工具调用策
|
|||||||
|
|
||||||
### Minimal(极简模式)
|
### Minimal(极简模式)
|
||||||
- **特点**:极简模式的系统提示词极其短小,且在底层使用了独立的作用域注册机制。
|
- **特点**:极简模式的系统提示词极其短小,且在底层使用了独立的作用域注册机制。
|
||||||
- **适配方式**:在 agent 作用域上使用动态代理替换完整的角色设定,将破限规则精炼注入;关闭开关时自动释放代理,恢复极简原貌。
|
- **适配方式**:在当前 agent 作用域中保留角色正文并注入规则,关闭开关时恢复原版。`0.2.4` 修复了带自定义角色的 Minimal 子代理因同名提示词重复注册而组装失败的问题,并保留结构化子代理所需的官方 `structured_output` 调用指引。
|
||||||
|
|
||||||
### 子代理(Subagent)与结构化输出(structured_output)
|
### 子代理(Subagent)与结构化输出(structured_output)
|
||||||
- **子代理**:主智能体派生的所有后台子代理自动继承父模式的破限规则。
|
- **子代理**:主智能体派生的所有后台子代理自动继承父模式的破限规则。
|
||||||
@@ -86,6 +86,8 @@ DSH 支持多种工作模式,各模式下的提示词结构和工具调用策
|
|||||||
### 完整提示词预览
|
### 完整提示词预览
|
||||||
插件提供了专门的 RPC 预览端点。用户在前端界面点击“查看预览”,即可实时获取当前模式即将发送给模型的真实系统提示词、总行数和字节大小,做到底层透明可见。
|
插件提供了专门的 RPC 预览端点。用户在前端界面点击“查看预览”,即可实时获取当前模式即将发送给模型的真实系统提示词、总行数和字节大小,做到底层透明可见。
|
||||||
|
|
||||||
|
并发刷新或重新检查时,过期请求的结果不会覆盖最新状态与预览;忙碌状态保持到所有状态操作结束,避免请求尚未完成就提前解除。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 5. 自动化测试与验证
|
## 5. 自动化测试与验证
|
||||||
@@ -93,7 +95,7 @@ DSH 支持多种工作模式,各模式下的提示词结构和工具调用策
|
|||||||
仓库内置了完善的断言测试与集成验证脚本:
|
仓库内置了完善的断言测试与集成验证脚本:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# 运行全部规则断言测试(33 项测试)
|
# 运行测试
|
||||||
pnpm test
|
pnpm test
|
||||||
|
|
||||||
# 从 DSH 源码中重新抓取原版提示词并更新测试 fixtures
|
# 从 DSH 源码中重新抓取原版提示词并更新测试 fixtures
|
||||||
|
|||||||
+61
-63
@@ -30,6 +30,9 @@ window.__ModuleLoader__.load({
|
|||||||
busy: false
|
busy: false
|
||||||
};
|
};
|
||||||
const listeners = /* @__PURE__ */ new Set();
|
const listeners = /* @__PURE__ */ new Set();
|
||||||
|
const previewRequests = /* @__PURE__ */ new Map();
|
||||||
|
let statusGeneration = 0;
|
||||||
|
let pendingOperations = 0;
|
||||||
const view = {
|
const view = {
|
||||||
getSnapshot: () => snapshot,
|
getSnapshot: () => snapshot,
|
||||||
subscribe: (listener) => {
|
subscribe: (listener) => {
|
||||||
@@ -39,89 +42,80 @@ window.__ModuleLoader__.load({
|
|||||||
};
|
};
|
||||||
function publish() {
|
function publish() {
|
||||||
const settingsSnapshot = settings.getSnapshot();
|
const settingsSnapshot = settings.getSnapshot();
|
||||||
|
const enabled = settingsSnapshot.value?.enabled === true;
|
||||||
|
if (enabled !== snapshot.enabled) invalidatePreviews();
|
||||||
snapshot = {
|
snapshot = {
|
||||||
enabled: settingsSnapshot.value?.enabled === true,
|
enabled,
|
||||||
writable: settingsSnapshot.writable,
|
writable: settingsSnapshot.writable,
|
||||||
settingsStatus: settingsSnapshot.status,
|
settingsStatus: settingsSnapshot.status,
|
||||||
status: snapshot.status,
|
status: snapshot.status,
|
||||||
previews: snapshot.previews,
|
previews: snapshot.previews,
|
||||||
busy: snapshot.busy,
|
busy: pendingOperations > 0,
|
||||||
message: snapshot.message
|
message: snapshot.message
|
||||||
};
|
};
|
||||||
for (const listener of listeners) listener();
|
for (const listener of listeners) listener();
|
||||||
}
|
}
|
||||||
|
function invalidatePreviews() {
|
||||||
|
previewRequests.clear();
|
||||||
|
snapshot = {
|
||||||
|
...snapshot,
|
||||||
|
previews: {}
|
||||||
|
};
|
||||||
|
}
|
||||||
async function call(endpoint, payload) {
|
async function call(endpoint, payload) {
|
||||||
const result = await connection.rpc.call(RPC_CHANNEL, endpoint, payload);
|
const result = await connection.rpc.call(RPC_CHANNEL, endpoint, payload);
|
||||||
if (!result.ok) throw new Error(result.error.message);
|
if (!result.ok) throw new Error(result.error.message);
|
||||||
return result.value;
|
return result.value;
|
||||||
}
|
}
|
||||||
async function refresh(invalidatePreviews = false) {
|
async function whileBusy(action) {
|
||||||
snapshot = {
|
pendingOperations++;
|
||||||
...snapshot,
|
|
||||||
busy: true
|
|
||||||
};
|
|
||||||
publish();
|
publish();
|
||||||
try {
|
try {
|
||||||
const status = await call("status", {});
|
await action();
|
||||||
snapshot = {
|
} finally {
|
||||||
...snapshot,
|
pendingOperations--;
|
||||||
status,
|
|
||||||
previews: invalidatePreviews ? {} : snapshot.previews,
|
|
||||||
busy: false,
|
|
||||||
message: void 0
|
|
||||||
};
|
|
||||||
publish();
|
|
||||||
} catch (error) {
|
|
||||||
snapshot = {
|
|
||||||
...snapshot,
|
|
||||||
busy: false,
|
|
||||||
message: messageOf(error)
|
|
||||||
};
|
|
||||||
publish();
|
publish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function setEnabled(enabled) {
|
function readStatus(endpoint, clearPreviews) {
|
||||||
snapshot = {
|
const generation = ++statusGeneration;
|
||||||
...snapshot,
|
return whileBusy(async () => {
|
||||||
busy: true
|
try {
|
||||||
};
|
const status = await call(endpoint, {});
|
||||||
publish();
|
if (generation !== statusGeneration) return;
|
||||||
try {
|
if (clearPreviews) invalidatePreviews();
|
||||||
await settings.set("enabled", enabled);
|
snapshot = {
|
||||||
await refresh(true);
|
...snapshot,
|
||||||
} catch (error) {
|
status,
|
||||||
snapshot = {
|
message: void 0
|
||||||
...snapshot,
|
};
|
||||||
busy: false,
|
} catch (error) {
|
||||||
message: messageOf(error)
|
if (generation !== statusGeneration) return;
|
||||||
};
|
snapshot = {
|
||||||
publish();
|
...snapshot,
|
||||||
}
|
message: messageOf(error)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async function recheck() {
|
function refresh(clearPreviews = false) {
|
||||||
snapshot = {
|
return readStatus("status", clearPreviews);
|
||||||
...snapshot,
|
}
|
||||||
busy: true
|
function setEnabled(enabled) {
|
||||||
};
|
return whileBusy(async () => {
|
||||||
publish();
|
try {
|
||||||
try {
|
await settings.set("enabled", enabled);
|
||||||
const status = await call("recheck", {});
|
await refresh(true);
|
||||||
snapshot = {
|
} catch (error) {
|
||||||
...snapshot,
|
snapshot = {
|
||||||
status,
|
...snapshot,
|
||||||
previews: {},
|
message: messageOf(error)
|
||||||
busy: false,
|
};
|
||||||
message: void 0
|
}
|
||||||
};
|
});
|
||||||
publish();
|
}
|
||||||
} catch (error) {
|
function recheck() {
|
||||||
snapshot = {
|
return readStatus("recheck", true);
|
||||||
...snapshot,
|
|
||||||
busy: false,
|
|
||||||
message: messageOf(error)
|
|
||||||
};
|
|
||||||
publish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Fetch one preset's deploy preview. The card renders the raw fused prompt,
|
* Fetch one preset's deploy preview. The card renders the raw fused prompt,
|
||||||
@@ -129,6 +123,8 @@ window.__ModuleLoader__.load({
|
|||||||
* @param presetId - preset id from the card's row.
|
* @param presetId - preset id from the card's row.
|
||||||
*/
|
*/
|
||||||
async function loadPreview(presetId) {
|
async function loadPreview(presetId) {
|
||||||
|
const request = Symbol(presetId);
|
||||||
|
previewRequests.set(presetId, request);
|
||||||
snapshot = {
|
snapshot = {
|
||||||
...snapshot,
|
...snapshot,
|
||||||
previews: {
|
previews: {
|
||||||
@@ -139,6 +135,7 @@ window.__ModuleLoader__.load({
|
|||||||
publish();
|
publish();
|
||||||
try {
|
try {
|
||||||
const preview = await call("preview", { presetId });
|
const preview = await call("preview", { presetId });
|
||||||
|
if (previewRequests.get(presetId) !== request) return;
|
||||||
snapshot = {
|
snapshot = {
|
||||||
...snapshot,
|
...snapshot,
|
||||||
previews: {
|
previews: {
|
||||||
@@ -150,6 +147,7 @@ window.__ModuleLoader__.load({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (previewRequests.get(presetId) !== request) return;
|
||||||
snapshot = {
|
snapshot = {
|
||||||
...snapshot,
|
...snapshot,
|
||||||
previews: {
|
previews: {
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"client.js","names":["useState"],"sources":["../src/client/controller.ts","../src/client/locales.ts","../src/client/styles.ts","../src/client/UnrestrictedCard.tsx","../src/client/index.tsx"],"sourcesContent":["/**\n * Browser-half controller for the unrestricted card: binds the `unrestricted`\n * settings namespace (the toggle) and polls the host half's private RPC for\n * per-preset fusion state. Mirrors the card-controller pattern: the apply\n * closure owns the controller, the slot inject face hands hooks and callbacks\n * to the component.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'\n// Type-only: the ctx.remote Context merge and the forwarded-event key face.\nimport type {} from '@deepseek-ai/dsh-api-remotes/client'\n// Type-only: the ctx.configForms Context merge.\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\n\n/** The toggle section stored in the `unrestricted` settings namespace. */\nexport interface UnrestrictedSettings {\n enabled?: boolean\n}\n\n/** Per-preset fusion state reported by the host half. */\nexport interface UnrestrictedModeState {\n state: 'off' | 'checking' | 'active' | 'failed'\n issues: string[]\n}\n\n/** Host status endpoint payload. */\nexport interface UnrestrictedStatus {\n enabled: boolean\n /** Fingerprint of the contract bytes the host half deploys. */\n contract: string\n modes: Record<string, UnrestrictedModeState>\n}\n\n/** Deploy preview for one preset: what switching on would actually assemble. */\nexport interface UnrestrictedPreview {\n presetId: string\n contract: string\n available: boolean\n /** `live` = bytes a live agent received; `standing` = preset scope, no agent bound. */\n source?: 'live' | 'standing'\n /** Fused prompt text; present when available. */\n text?: string\n bytes?: number\n lines?: number\n /** Why no preview could be built; present when unavailable. */\n reason?: string\n}\n\n/** One fetched preview, keyed by preset, plus its in-flight/error state. */\nexport interface UnrestrictedPreviewEntry {\n status: 'loading' | 'ready' | 'failed'\n preview?: UnrestrictedPreview\n message?: string\n}\n\n/** Full view snapshot the card subscribes to. */\nexport interface UnrestrictedViewSnapshot {\n /** Persisted toggle; undefined until the settings scope first syncs. */\n enabled: boolean\n /** Whether the Host document accepts writes. */\n writable: boolean\n /** Settings scope sync state. */\n settingsStatus: 'loading' | 'ready' | 'unavailable'\n /** Live host status; null until the first RPC answer. */\n status: UnrestrictedStatus | null\n /** presetId -> fetched deploy preview. */\n previews: Record<string, UnrestrictedPreviewEntry>\n /** Whether a status refresh or recheck RPC is currently in flight. */\n busy: boolean\n /** Last transport/business failure, if any. */\n message?: string\n}\n\n/** Minimal RPC wire shape (structural copy of the host RpcResult). */\ntype RpcResult<T> = { ok: true; value: T } | { ok: false; error: { code: string; message: string } }\n\n/** Minimal observable contract consumed by the slot renderer's hook binding. */\nexport interface UnrestrictedViewSource {\n getSnapshot(): UnrestrictedViewSnapshot\n subscribe(listener: () => void): () => void\n}\n\n/** Inject face handed to the card at registration. */\nexport interface UnrestrictedCardInjected {\n hooks: {\n /** Reactive card view. */\n view: UnrestrictedViewSource\n }\n /** Persist the toggle. */\n setEnabled: (enabled: boolean) => Promise<void>\n /** Re-run the host-side anchor checks and refresh. */\n recheck: () => Promise<void>\n /** Re-read host status and invalidate cached previews. */\n refresh: () => Promise<void>\n /** Fetch the exact fused prompt this preset would deploy. */\n loadPreview: (presetId: string) => Promise<void>\n}\n\nconst RPC_CHANNEL = '/dsh-unrestricted'\nconst SETTINGS_NS = 'unrestricted'\n\n/** Human-readable error text for the banner. */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\n/**\n * Create the card controller bound to the calling plugin's context.\n * @param ctx - the browser plugin context (connection + remote + configForms injected).\n * @returns the controller whose face() feeds the slot inject share.\n */\nexport function createUnrestrictedController(ctx: Context) {\n const connection = ctx.get('connection') as ConnectionHandle\n const settings = ctx.configForms.get<UnrestrictedSettings>(SETTINGS_NS)\n\n let snapshot: UnrestrictedViewSnapshot = {\n enabled: false,\n writable: false,\n settingsStatus: 'loading',\n status: null,\n previews: {},\n busy: false,\n }\n const listeners = new Set<() => void>()\n\n const view: UnrestrictedViewSource = {\n getSnapshot: () => snapshot,\n subscribe: (listener) => {\n listeners.add(listener)\n Line truncated
|
{"version":3,"file":"client.js","names":["useState"],"sources":["../src/client/controller.ts","../src/client/locales.ts","../src/client/styles.ts","../src/client/UnrestrictedCard.tsx","../src/client/index.tsx"],"sourcesContent":["/**\n * Browser-half controller for the unrestricted card: binds the `unrestricted`\n * settings namespace (the toggle) and polls the host half's private RPC for\n * per-preset fusion state. Mirrors the card-controller pattern: the apply\n * closure owns the controller, the slot inject face hands hooks and callbacks\n * to the component.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'\n// Type-only: the ctx.remote Context merge and the forwarded-event key face.\nimport type {} from '@deepseek-ai/dsh-api-remotes/client'\n// Type-only: the ctx.configForms Context merge.\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\n\n/** The toggle section stored in the `unrestricted` settings namespace. */\nexport interface UnrestrictedSettings {\n enabled?: boolean\n}\n\n/** Per-preset fusion state reported by the host half. */\nexport interface UnrestrictedModeState {\n state: 'off' | 'checking' | 'active' | 'failed'\n issues: string[]\n}\n\n/** Host status endpoint payload. */\nexport interface UnrestrictedStatus {\n enabled: boolean\n /** Fingerprint of the contract bytes the host half deploys. */\n contract: string\n modes: Record<string, UnrestrictedModeState>\n}\n\n/** Deploy preview for one preset: what switching on would actually assemble. */\nexport interface UnrestrictedPreview {\n presetId: string\n contract: string\n available: boolean\n /** `live` = bytes a live agent received; `standing` = preset scope, no agent bound. */\n source?: 'live' | 'standing'\n /** Fused prompt text; present when available. */\n text?: string\n bytes?: number\n lines?: number\n /** Why no preview could be built; present when unavailable. */\n reason?: string\n}\n\n/** One fetched preview, keyed by preset, plus its in-flight/error state. */\nexport interface UnrestrictedPreviewEntry {\n status: 'loading' | 'ready' | 'failed'\n preview?: UnrestrictedPreview\n message?: string\n}\n\n/** Full view snapshot the card subscribes to. */\nexport interface UnrestrictedViewSnapshot {\n /** Persisted toggle; undefined until the settings scope first syncs. */\n enabled: boolean\n /** Whether the Host document accepts writes. */\n writable: boolean\n /** Settings scope sync state. */\n settingsStatus: 'loading' | 'ready' | 'unavailable'\n /** Live host status; null until the first RPC answer. */\n status: UnrestrictedStatus | null\n /** presetId -> fetched deploy preview. */\n previews: Record<string, UnrestrictedPreviewEntry>\n /** 是否仍有设置写入或状态检查尚未完成。 */\n busy: boolean\n /** Last transport/business failure, if any. */\n message?: string\n}\n\n/** Minimal RPC wire shape (structural copy of the host RpcResult). */\ntype RpcResult<T> = { ok: true; value: T } | { ok: false; error: { code: string; message: string } }\n\n/** Minimal observable contract consumed by the slot renderer's hook binding. */\nexport interface UnrestrictedViewSource {\n getSnapshot(): UnrestrictedViewSnapshot\n subscribe(listener: () => void): () => void\n}\n\n/** Inject face handed to the card at registration. */\nexport interface UnrestrictedCardInjected {\n hooks: {\n /** Reactive card view. */\n view: UnrestrictedViewSource\n }\n /** Persist the toggle. */\n setEnabled: (enabled: boolean) => Promise<void>\n /** Re-run the host-side anchor checks and refresh. */\n recheck: () => Promise<void>\n /** Re-read host status and invalidate cached previews. */\n refresh: () => Promise<void>\n /** Fetch the exact fused prompt this preset would deploy. */\n loadPreview: (presetId: string) => Promise<void>\n}\n\nconst RPC_CHANNEL = '/dsh-unrestricted'\nconst SETTINGS_NS = 'unrestricted'\n\n/** Human-readable error text for the banner. */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\n/**\n * Create the card controller bound to the calling plugin's context.\n * @param ctx - the browser plugin context (connection + remote + configForms injected).\n * @returns the controller whose face() feeds the slot inject share.\n */\nexport function createUnrestrictedController(ctx: Context) {\n const connection = ctx.get('connection') as ConnectionHandle\n const settings = ctx.configForms.get<UnrestrictedSettings>(SETTINGS_NS)\n\n let snapshot: UnrestrictedViewSnapshot = {\n enabled: false,\n writable: false,\n settingsStatus: 'loading',\n status: null,\n previews: {},\n busy: false,\n }\n const listeners = new Set<() => void>()\n // 每个预设只接收最近一次请求;清空标记同时废弃所有在途旧预览。\n const previewRequests = new Map<string, symbol>()\n let Line truncated
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dsh-unrestricted",
|
"name": "dsh-unrestricted",
|
||||||
"version": "0.2.3",
|
"version": "0.2.4",
|
||||||
"engines": {
|
"engines": {
|
||||||
"dsh": ">=0.2.0-rc.2 <0.2.2-0"
|
"dsh": ">=0.2.0-rc.2 <0.2.2-0"
|
||||||
},
|
},
|
||||||
|
|||||||
+54
-40
@@ -65,7 +65,7 @@ export interface UnrestrictedViewSnapshot {
|
|||||||
status: UnrestrictedStatus | null
|
status: UnrestrictedStatus | null
|
||||||
/** presetId -> fetched deploy preview. */
|
/** presetId -> fetched deploy preview. */
|
||||||
previews: Record<string, UnrestrictedPreviewEntry>
|
previews: Record<string, UnrestrictedPreviewEntry>
|
||||||
/** Whether a status refresh or recheck RPC is currently in flight. */
|
/** 是否仍有设置写入或状态检查尚未完成。 */
|
||||||
busy: boolean
|
busy: boolean
|
||||||
/** Last transport/business failure, if any. */
|
/** Last transport/business failure, if any. */
|
||||||
message?: string
|
message?: string
|
||||||
@@ -122,6 +122,10 @@ export function createUnrestrictedController(ctx: Context) {
|
|||||||
busy: false,
|
busy: false,
|
||||||
}
|
}
|
||||||
const listeners = new Set<() => void>()
|
const listeners = new Set<() => void>()
|
||||||
|
// 每个预设只接收最近一次请求;清空标记同时废弃所有在途旧预览。
|
||||||
|
const previewRequests = new Map<string, symbol>()
|
||||||
|
let statusGeneration = 0
|
||||||
|
let pendingOperations = 0
|
||||||
|
|
||||||
const view: UnrestrictedViewSource = {
|
const view: UnrestrictedViewSource = {
|
||||||
getSnapshot: () => snapshot,
|
getSnapshot: () => snapshot,
|
||||||
@@ -133,68 +137,74 @@ export function createUnrestrictedController(ctx: Context) {
|
|||||||
|
|
||||||
function publish(): void {
|
function publish(): void {
|
||||||
const settingsSnapshot = settings.getSnapshot()
|
const settingsSnapshot = settings.getSnapshot()
|
||||||
|
const enabled = settingsSnapshot.value?.enabled === true
|
||||||
|
if (enabled !== snapshot.enabled) invalidatePreviews()
|
||||||
snapshot = {
|
snapshot = {
|
||||||
enabled: settingsSnapshot.value?.enabled === true,
|
enabled,
|
||||||
writable: settingsSnapshot.writable,
|
writable: settingsSnapshot.writable,
|
||||||
settingsStatus: settingsSnapshot.status,
|
settingsStatus: settingsSnapshot.status,
|
||||||
status: snapshot.status,
|
status: snapshot.status,
|
||||||
previews: snapshot.previews,
|
previews: snapshot.previews,
|
||||||
busy: snapshot.busy,
|
busy: pendingOperations > 0,
|
||||||
message: snapshot.message,
|
message: snapshot.message,
|
||||||
}
|
}
|
||||||
for (const listener of listeners) listener()
|
for (const listener of listeners) listener()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function invalidatePreviews(): void {
|
||||||
|
previewRequests.clear()
|
||||||
|
snapshot = { ...snapshot, previews: {} }
|
||||||
|
}
|
||||||
|
|
||||||
async function call<T>(endpoint: string, payload: unknown): Promise<T> {
|
async function call<T>(endpoint: string, payload: unknown): Promise<T> {
|
||||||
const result = await connection.rpc.call(RPC_CHANNEL, endpoint, payload) as RpcResult<T>
|
const result = await connection.rpc.call(RPC_CHANNEL, endpoint, payload) as RpcResult<T>
|
||||||
if (!result.ok) throw new Error(result.error.message)
|
if (!result.ok) throw new Error(result.error.message)
|
||||||
return result.value
|
return result.value
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refresh(invalidatePreviews = false): Promise<void> {
|
async function whileBusy(action: () => Promise<void>): Promise<void> {
|
||||||
snapshot = { ...snapshot, busy: true }
|
pendingOperations++
|
||||||
publish()
|
publish()
|
||||||
try {
|
try {
|
||||||
const status = await call<UnrestrictedStatus>('status', {})
|
await action()
|
||||||
snapshot = {
|
} finally {
|
||||||
...snapshot,
|
pendingOperations--
|
||||||
status,
|
publish()
|
||||||
previews: invalidatePreviews ? {} : snapshot.previews,
|
}
|
||||||
busy: false,
|
}
|
||||||
message: undefined,
|
|
||||||
|
function readStatus(endpoint: 'status' | 'recheck', clearPreviews: boolean): Promise<void> {
|
||||||
|
const generation = ++statusGeneration
|
||||||
|
return whileBusy(async () => {
|
||||||
|
try {
|
||||||
|
const status = await call<UnrestrictedStatus>(endpoint, {})
|
||||||
|
if (generation !== statusGeneration) return
|
||||||
|
if (clearPreviews) invalidatePreviews()
|
||||||
|
snapshot = { ...snapshot, status, message: undefined }
|
||||||
|
} catch (error) {
|
||||||
|
if (generation !== statusGeneration) return
|
||||||
|
snapshot = { ...snapshot, message: messageOf(error) }
|
||||||
}
|
}
|
||||||
publish()
|
})
|
||||||
} catch (error) {
|
|
||||||
snapshot = { ...snapshot, busy: false, message: messageOf(error) }
|
|
||||||
publish()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setEnabled(enabled: boolean): Promise<void> {
|
function refresh(clearPreviews = false): Promise<void> {
|
||||||
snapshot = { ...snapshot, busy: true }
|
return readStatus('status', clearPreviews)
|
||||||
publish()
|
|
||||||
try {
|
|
||||||
await settings.set('enabled', enabled)
|
|
||||||
await refresh(true)
|
|
||||||
} catch (error) {
|
|
||||||
snapshot = { ...snapshot, busy: false, message: messageOf(error) }
|
|
||||||
publish()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function recheck(): Promise<void> {
|
function setEnabled(enabled: boolean): Promise<void> {
|
||||||
snapshot = { ...snapshot, busy: true }
|
return whileBusy(async () => {
|
||||||
publish()
|
try {
|
||||||
try {
|
await settings.set('enabled', enabled)
|
||||||
const status = await call<UnrestrictedStatus>('recheck', {})
|
await refresh(true)
|
||||||
// The recheck invalidates every cached preview: the deployed bytes may
|
} catch (error) {
|
||||||
// have changed under a new master.
|
snapshot = { ...snapshot, message: messageOf(error) }
|
||||||
snapshot = { ...snapshot, status, previews: {}, busy: false, message: undefined }
|
}
|
||||||
publish()
|
})
|
||||||
} catch (error) {
|
}
|
||||||
snapshot = { ...snapshot, busy: false, message: messageOf(error) }
|
|
||||||
publish()
|
function recheck(): Promise<void> {
|
||||||
}
|
return readStatus('recheck', true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -203,6 +213,8 @@ export function createUnrestrictedController(ctx: Context) {
|
|||||||
* @param presetId - preset id from the card's row.
|
* @param presetId - preset id from the card's row.
|
||||||
*/
|
*/
|
||||||
async function loadPreview(presetId: string): Promise<void> {
|
async function loadPreview(presetId: string): Promise<void> {
|
||||||
|
const request = Symbol(presetId)
|
||||||
|
previewRequests.set(presetId, request)
|
||||||
snapshot = {
|
snapshot = {
|
||||||
...snapshot,
|
...snapshot,
|
||||||
previews: { ...snapshot.previews, [presetId]: { status: 'loading' } },
|
previews: { ...snapshot.previews, [presetId]: { status: 'loading' } },
|
||||||
@@ -210,11 +222,13 @@ export function createUnrestrictedController(ctx: Context) {
|
|||||||
publish()
|
publish()
|
||||||
try {
|
try {
|
||||||
const preview = await call<UnrestrictedPreview>('preview', { presetId })
|
const preview = await call<UnrestrictedPreview>('preview', { presetId })
|
||||||
|
if (previewRequests.get(presetId) !== request) return
|
||||||
snapshot = {
|
snapshot = {
|
||||||
...snapshot,
|
...snapshot,
|
||||||
previews: { ...snapshot.previews, [presetId]: { status: 'ready', preview } },
|
previews: { ...snapshot.previews, [presetId]: { status: 'ready', preview } },
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (previewRequests.get(presetId) !== request) return
|
||||||
snapshot = {
|
snapshot = {
|
||||||
...snapshot,
|
...snapshot,
|
||||||
previews: { ...snapshot.previews, [presetId]: { status: 'failed', message: messageOf(error) } },
|
previews: { ...snapshot.previews, [presetId]: { status: 'failed', message: messageOf(error) } },
|
||||||
|
|||||||
+35
-16
@@ -76,6 +76,8 @@ export function apply(ctx, config) {
|
|||||||
runtime: new Map(),
|
runtime: new Map(),
|
||||||
/** Agent -> section disposer for minimal persona shadows. */
|
/** Agent -> section disposer for minimal persona shadows. */
|
||||||
shadows: new Map(),
|
shadows: new Map(),
|
||||||
|
/** 已由调用方在 agent scope 注册 persona 的 Minimal agent。 */
|
||||||
|
customMinimal: new WeakSet(),
|
||||||
/** Fused minimal prompt, computed only after the minimal anchors verify. */
|
/** Fused minimal prompt, computed only after the minimal anchors verify. */
|
||||||
fusedMinimal: null,
|
fusedMinimal: null,
|
||||||
/** presetId -> last successfully fused top-level live assembly (the deploy preview). */
|
/** presetId -> last successfully fused top-level live assembly (the deploy preview). */
|
||||||
@@ -212,22 +214,29 @@ export function apply(ctx, config) {
|
|||||||
unshadowMinimal(agent)
|
unshadowMinimal(agent)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (state.shadows.has(agent)) return
|
if (state.shadows.has(agent) || state.customMinimal.has(agent)) return
|
||||||
const dispose = agent.ctx.systemPrompt.section({
|
let dispose
|
||||||
name: 'deployment:persona-prefix',
|
try {
|
||||||
order: 0,
|
dispose = agent.ctx.systemPrompt.section({
|
||||||
complete: true,
|
name: 'deployment:persona-prefix',
|
||||||
text: (context) => {
|
order: 0,
|
||||||
// Preserve structured-output instructions when a structured subagent
|
complete: true,
|
||||||
// runs under minimal.
|
text: (context) => {
|
||||||
const hasStructured = context?.agent?.ctx?.tools
|
// 结构化工具注册在子代理 scope,不能只查询全局工具目录。
|
||||||
?.schemas?.()
|
const hasStructured = context?.agent?.ctx?.tools
|
||||||
?.some(tool => tool.name === 'structured_output') === true
|
?.schemas?.(context.agent)
|
||||||
return hasStructured
|
?.some(tool => tool.name === 'structured_output') === true
|
||||||
? fusedMinimalPrompt(ANCHORS.structuredOutputFull)
|
return hasStructured
|
||||||
: (state.fusedMinimal ?? fusedMinimalPrompt())
|
? fusedMinimalPrompt(ANCHORS.structuredOutputFull)
|
||||||
},
|
: (state.fusedMinimal ?? fusedMinimalPrompt())
|
||||||
})
|
},
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
// 原生委派角色已占用同一名称;保留调用方贡献,在组装时融合。
|
||||||
|
if (messageOf(error) !== 'prompt section "deployment:persona-prefix" is already registered in this scope') throw error
|
||||||
|
state.customMinimal.add(agent)
|
||||||
|
return
|
||||||
|
}
|
||||||
state.shadows.set(agent, dispose)
|
state.shadows.set(agent, dispose)
|
||||||
state.fusedText.set('minimal', state.fusedMinimal)
|
state.fusedText.set('minimal', state.fusedMinimal)
|
||||||
}
|
}
|
||||||
@@ -394,6 +403,14 @@ export function apply(ctx, config) {
|
|||||||
// the fused minimal section for this assembly when possible.
|
// the fused minimal section for this assembly when possible.
|
||||||
await ensureCheck('minimal')
|
await ensureCheck('minimal')
|
||||||
syncMinimalShadow(agent)
|
syncMinimalShadow(agent)
|
||||||
|
if (state.customMinimal.has(agent) && usable('minimal')) {
|
||||||
|
const fused = fuseSections(original.sections, 'minimal', { isSubagent: true })
|
||||||
|
if (fused.issues !== undefined) {
|
||||||
|
state.runtime.set('minimal', fused.issues)
|
||||||
|
return original
|
||||||
|
}
|
||||||
|
return { ...original, sections: fused.sections }
|
||||||
|
}
|
||||||
return original
|
return original
|
||||||
}
|
}
|
||||||
// If this blank session was previously `minimal` and switched to another
|
// If this blank session was previously `minimal` and switched to another
|
||||||
@@ -431,6 +448,7 @@ export function apply(ctx, config) {
|
|||||||
ctx.on('agent-preset/selected', (sessionId) => {
|
ctx.on('agent-preset/selected', (sessionId) => {
|
||||||
const agent = ctx.get('agents')?.get?.(sessionId)
|
const agent = ctx.get('agents')?.get?.(sessionId)
|
||||||
if (agent === undefined) return
|
if (agent === undefined) return
|
||||||
|
state.customMinimal.delete(agent)
|
||||||
if (!state.enabled) {
|
if (!state.enabled) {
|
||||||
unshadowMinimal(agent)
|
unshadowMinimal(agent)
|
||||||
return
|
return
|
||||||
@@ -439,6 +457,7 @@ export function apply(ctx, config) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ctx.on('agent/disposed', ({ agent }) => {
|
ctx.on('agent/disposed', ({ agent }) => {
|
||||||
|
state.customMinimal.delete(agent)
|
||||||
unshadowMinimal(agent)
|
unshadowMinimal(agent)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import test from 'node:test'
|
||||||
|
import { createUnrestrictedController } from '../src/client/controller.ts'
|
||||||
|
|
||||||
|
const settle = () => new Promise(setImmediate)
|
||||||
|
const status = (contract, enabled = true) => ({ enabled, contract, modes: {} })
|
||||||
|
|
||||||
|
/** 保留真实控制器,仅控制设置提交、配置事件和 RPC 的完成时序。 */
|
||||||
|
async function fixture() {
|
||||||
|
let value = { enabled: true }
|
||||||
|
const subscribers = new Set()
|
||||||
|
const events = new Map()
|
||||||
|
const pending = { status: [], recheck: [], preview: [], write: [] }
|
||||||
|
function defer(endpoint, payload) {
|
||||||
|
return new Promise((resolve, reject) => pending[endpoint].push({ payload, resolve, reject }))
|
||||||
|
}
|
||||||
|
const settings = {
|
||||||
|
getSnapshot: () => ({ status: 'ready', writable: true, value }),
|
||||||
|
subscribe(listener) {
|
||||||
|
subscribers.add(listener)
|
||||||
|
return () => subscribers.delete(listener)
|
||||||
|
},
|
||||||
|
set: (field, next) => defer('write', { field, next }),
|
||||||
|
}
|
||||||
|
const ctx = {
|
||||||
|
get: () => ({ rpc: { call: (_channel, endpoint, payload) => defer(endpoint, payload) } }),
|
||||||
|
configForms: { get: () => settings },
|
||||||
|
remote: { $on(event, listener) { events.set(event, listener); return () => events.delete(event) } },
|
||||||
|
effect: effect => effect(),
|
||||||
|
}
|
||||||
|
const face = createUnrestrictedController(ctx).face()
|
||||||
|
const take = endpoint => {
|
||||||
|
const request = pending[endpoint].shift()
|
||||||
|
assert.ok(request, `missing ${endpoint} request`)
|
||||||
|
return request
|
||||||
|
}
|
||||||
|
const answer = (request, value) => request.resolve({ ok: true, value })
|
||||||
|
answer(take('status'), status('initial'))
|
||||||
|
await settle()
|
||||||
|
return {
|
||||||
|
face, take, answer,
|
||||||
|
view: () => face.hooks.view.getSnapshot(),
|
||||||
|
documentUpdated: () => events.get('settings/document-updated')('unrestricted'),
|
||||||
|
commitEnabled(enabled) {
|
||||||
|
value = { enabled }
|
||||||
|
for (const listener of subscribers) listener()
|
||||||
|
events.get('settings/document-updated')('unrestricted')
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test('刷新或重检后,迟到的旧预览不能覆盖已显示的新正文', async () => {
|
||||||
|
for (const action of ['refresh', 'recheck']) {
|
||||||
|
const f = await fixture()
|
||||||
|
const previous = f.face.loadPreview('standard')
|
||||||
|
const previousRequest = f.take('preview')
|
||||||
|
assert.equal(f.view().busy, false, '加载预览时界面允许刷新和重检')
|
||||||
|
const updating = f.face[action]()
|
||||||
|
f.answer(f.take(action === 'refresh' ? 'status' : 'recheck'), status('updated'))
|
||||||
|
await updating
|
||||||
|
assert.equal(f.view().previews.standard, undefined)
|
||||||
|
|
||||||
|
// 卡片在打开的预览失效后通过 effect 自动发起这一请求。
|
||||||
|
const current = f.face.loadPreview('standard')
|
||||||
|
f.answer(f.take('preview'), { available: true, text: 'current prompt' })
|
||||||
|
await current
|
||||||
|
f.answer(previousRequest, { available: true, text: 'obsolete prompt' })
|
||||||
|
await previous
|
||||||
|
assert.equal(f.view().previews.standard.preview.text, 'current prompt', action)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test('失效预览的迟到错误不影响新请求,不同预设分别接收自己的结果', async () => {
|
||||||
|
const f = await fixture()
|
||||||
|
const previous = f.face.loadPreview('standard')
|
||||||
|
const previousRequest = f.take('preview')
|
||||||
|
const updating = f.face.refresh()
|
||||||
|
f.answer(f.take('status'), status('updated'))
|
||||||
|
await updating
|
||||||
|
const current = f.face.loadPreview('standard')
|
||||||
|
const currentRequest = f.take('preview')
|
||||||
|
const otherPreset = f.face.loadPreview('ptc')
|
||||||
|
f.answer(f.take('preview'), { available: true, text: 'ptc prompt' })
|
||||||
|
await otherPreset
|
||||||
|
previousRequest.reject(new Error('obsolete preview failure'))
|
||||||
|
await previous
|
||||||
|
assert.equal(f.view().previews.standard.status, 'loading')
|
||||||
|
assert.equal(f.view().previews.ptc.preview.text, 'ptc prompt')
|
||||||
|
f.answer(currentRequest, { available: true, text: 'standard prompt' })
|
||||||
|
await current
|
||||||
|
assert.equal(f.view().previews.standard.preview.text, 'standard prompt')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('配置事件与手动刷新重叠时保留新状态,所有请求结束后才解除忙碌', async () => {
|
||||||
|
for (const outcome of ['success', 'failure']) {
|
||||||
|
const f = await fixture()
|
||||||
|
const older = f.face.refresh()
|
||||||
|
const olderRequest = f.take('status')
|
||||||
|
f.documentUpdated()
|
||||||
|
f.answer(f.take('status'), status('current'))
|
||||||
|
await settle()
|
||||||
|
assert.equal(f.view().busy, true)
|
||||||
|
if (outcome === 'success') f.answer(olderRequest, status('obsolete'))
|
||||||
|
else olderRequest.reject(new Error('obsolete status failure'))
|
||||||
|
await older
|
||||||
|
assert.equal(f.view().status.contract, 'current')
|
||||||
|
assert.equal(f.view().message, undefined)
|
||||||
|
assert.equal(f.view().busy, false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test('开关提交立即使旧预览失效,配置事件刷新不能提前结束尚未完成的写入', async () => {
|
||||||
|
const f = await fixture()
|
||||||
|
const preview = f.face.loadPreview('standard')
|
||||||
|
const previewRequest = f.take('preview')
|
||||||
|
const writing = f.face.setEnabled(false)
|
||||||
|
const writeRequest = f.take('write')
|
||||||
|
f.commitEnabled(false)
|
||||||
|
assert.equal(f.view().enabled, false)
|
||||||
|
assert.equal(f.view().previews.standard, undefined)
|
||||||
|
f.answer(previewRequest, { available: true, text: 'before toggle' })
|
||||||
|
await preview
|
||||||
|
assert.equal(f.view().previews.standard, undefined)
|
||||||
|
f.answer(f.take('status'), status('event refresh', false))
|
||||||
|
await settle()
|
||||||
|
assert.equal(f.view().busy, true, '配置事件的读取结束后,写入仍在等待应答')
|
||||||
|
writeRequest.resolve(true)
|
||||||
|
await settle()
|
||||||
|
assert.equal(f.view().busy, true)
|
||||||
|
f.answer(f.take('status'), status('write refresh', false))
|
||||||
|
await writing
|
||||||
|
assert.equal(f.view().busy, false)
|
||||||
|
assert.equal(f.view().status.enabled, false)
|
||||||
|
})
|
||||||
@@ -156,6 +156,35 @@ async function setEnabled(enabled) {
|
|||||||
await ctx.settings.update('unrestricted', { enabled })
|
await ctx.settings.update('unrestricted', { enabled })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 用原生子代理组合和作用域工具注册复现 Minimal 的角色及报告协议。 */
|
||||||
|
async function minimalChild(suffix, persona) {
|
||||||
|
const parent = await presetAgent('minimal')
|
||||||
|
const handle = await parent.ctx.agents.create({
|
||||||
|
sessionId: SessionId(`verify-minimal-child-${suffix}`),
|
||||||
|
meta: childSessionMeta(parent, 1, false),
|
||||||
|
agentOptions: AGENT_OPTIONS,
|
||||||
|
setup: agentCtx => {
|
||||||
|
applyChildComposition(agentCtx, parent, persona === undefined ? {} : { persona })
|
||||||
|
if (persona !== undefined) {
|
||||||
|
agentCtx.systemPrompt.section({ name: 'review:criteria', order: 20, text: 'Preserve the supplied review criteria.' })
|
||||||
|
}
|
||||||
|
agentCtx.tools.register({
|
||||||
|
name: 'structured_output', description: 'Report a structured review.',
|
||||||
|
parameters: { type: 'object', properties: { ok: { type: 'boolean' } }, required: ['ok'] },
|
||||||
|
output: { schema: { type: 'object', properties: {}, additionalProperties: false }, render: () => [] },
|
||||||
|
execute: async () => { throw new Error('This assembly check must not execute a tool') },
|
||||||
|
})
|
||||||
|
agentCtx.systemPrompt.section({
|
||||||
|
name: 'tool:structured_output',
|
||||||
|
order: agentCtx.systemPrompt.getSectionOrder('STRUCTURED_OUTPUT'),
|
||||||
|
text: rules.ANCHORS.structuredOutputFull,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
agents.set(`minimal-child-${suffix}`, handle)
|
||||||
|
return handle.agent
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reproduce the card's preview path without the browser: assemble the standing
|
* Reproduce the card's preview path without the browser: assemble the standing
|
||||||
* scope, fuse it, and render it through the same harness renderer the host
|
* scope, fuse it, and render it through the same harness renderer the host
|
||||||
@@ -226,6 +255,11 @@ try {
|
|||||||
// An agent that exists BEFORE the toggle must switch on the next assembly.
|
// An agent that exists BEFORE the toggle must switch on the next assembly.
|
||||||
const preExisting = await presetAgent('standard', '-pre')
|
const preExisting = await presetAgent('standard', '-pre')
|
||||||
check('minimal baseline is the stock persona', baseline.minimal.text === 'You are a helpful software engineer assistant.')
|
check('minimal baseline is the stock persona', baseline.minimal.text === 'You are a helpful software engineer assistant.')
|
||||||
|
const customPersona = 'Review only this delegated code and preserve the caller role.'
|
||||||
|
const customMinimal = await minimalChild('custom-before-toggle', customPersona)
|
||||||
|
const customBaseline = await assemblePrompt(customMinimal)
|
||||||
|
const structuredMinimal = await minimalChild('structured-before-toggle')
|
||||||
|
const structuredBaseline = await assemblePrompt(structuredMinimal)
|
||||||
|
|
||||||
console.log('toggle on')
|
console.log('toggle on')
|
||||||
await setEnabled(true)
|
await setEnabled(true)
|
||||||
@@ -301,6 +335,25 @@ try {
|
|||||||
check('minimal session created before toggle is fused (sweep)', minimalEarlyPrompt.text === expectedMinimal)
|
check('minimal session created before toggle is fused (sweep)', minimalEarlyPrompt.text === expectedMinimal)
|
||||||
check('minimal tools unchanged', minimalAfter.tools === baseline.minimal.tools)
|
check('minimal tools unchanged', minimalAfter.tools === baseline.minimal.tools)
|
||||||
|
|
||||||
|
// 既有子代理由开启时的 sweep 处理;新子代理由 created 事件处理。
|
||||||
|
const customAfterEnable = await minimalChild('custom-after-toggle', customPersona)
|
||||||
|
for (const [label, agent] of [['existing', customMinimal], ['new', customAfterEnable]]) {
|
||||||
|
const prompt = await assemblePrompt(agent)
|
||||||
|
check(`minimal ${label} custom child keeps its persona and system rule`,
|
||||||
|
prompt.text.includes(customPersona) && prompt.text.includes('Preserve the supplied review criteria.'))
|
||||||
|
check(`minimal ${label} custom child fuses once and keeps the report protocol`,
|
||||||
|
prompt.text.split(rules.EXECUTION_MODE_BLOCK).length === 2
|
||||||
|
&& prompt.text.includes(rules.ANCHORS.structuredOutputFull))
|
||||||
|
check(`minimal ${label} custom child keeps tools and contexts`,
|
||||||
|
prompt.tools === customBaseline.tools && prompt.contexts === customBaseline.contexts)
|
||||||
|
}
|
||||||
|
const structuredPrompt = await assemblePrompt(structuredMinimal)
|
||||||
|
check('minimal scoped structured tool keeps its native system instruction',
|
||||||
|
JSON.parse(structuredPrompt.tools).some(tool => tool.name === 'structured_output')
|
||||||
|
&& structuredPrompt.text.includes(rules.ANCHORS.structuredOutputFull))
|
||||||
|
check('minimal structured child keeps its original tools and contexts',
|
||||||
|
structuredPrompt.tools === structuredBaseline.tools && structuredPrompt.contexts === structuredBaseline.contexts)
|
||||||
|
|
||||||
// Blank-session preset switching (`agentPresets.select`):
|
// Blank-session preset switching (`agentPresets.select`):
|
||||||
// 1) minimal -> standard must drop the complete persona shadow so the full
|
// 1) minimal -> standard must drop the complete persona shadow so the full
|
||||||
// standard prompt and tools are assembled.
|
// standard prompt and tools are assembled.
|
||||||
@@ -357,6 +410,15 @@ try {
|
|||||||
check(`${id} restored to original`, off.text === baseline[id].text)
|
check(`${id} restored to original`, off.text === baseline[id].text)
|
||||||
check(`${id} tools still unchanged`, off.tools === baseline[id].tools)
|
check(`${id} tools still unchanged`, off.tools === baseline[id].tools)
|
||||||
}
|
}
|
||||||
|
for (const [label, agent, expected] of [
|
||||||
|
['existing custom', customMinimal, customBaseline],
|
||||||
|
['new custom', customAfterEnable, customBaseline],
|
||||||
|
['structured', structuredMinimal, structuredBaseline],
|
||||||
|
]) {
|
||||||
|
const off = await assemblePrompt(agent)
|
||||||
|
check(`minimal ${label} child restores native bytes after disabling`,
|
||||||
|
off.text === expected.text && off.tools === expected.tools && off.contexts === expected.contexts)
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
for (const handle of agents.values()) await handle.dispose()
|
for (const handle of agents.values()) await handle.dispose()
|
||||||
await ctx.fiber.dispose()
|
await ctx.fiber.dispose()
|
||||||
|
|||||||
Reference in new issue
Block a user