@lynn123411/dsh-subagent-judge-dispatch 0.6.7 → 0.6.9

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.md CHANGED
@@ -8,13 +8,14 @@
8
8
 
9
9
  - **清单由你写**:任务类型是一张表格,每一行写一段判定依据、选一个模型、选一个思考强度。模型从宿主那份「子代理可选用哪些模型」设置里读,强度从该模型自己声明的档位里读:档位读得到时强度栏是下拉,读不到时退回自由填写格。没填完的行、没有描述的行、描述和别的行重复的行,编号下面各有一句提示;它们照常写进配置,只是暂时不生效或判不准。每一行还有一个开关:关掉的行留在清单里,但不参与判断,也不占编号。
10
10
  - **只改两样**:只改写子代理使用的模型与思考强度,不改名字、不改标题、不动主对话,其余一概沿用 DSH 原本的派工流程。
11
- - **判断永不打断派工**:连不上、超过 5 秒、答复对不上清单、答复为空,这四种都算判断失败;失败时一个字段都不写,子代理保持宿主已经为它解析好的那条子路由,不重试。代价是每次派工最多多等 5 秒。
11
+ - **判断永不打断派工**:判断和路线校验共用 5 秒。判断服务不可用、答复不符合清单、校验失败或时间用完时,子代理沿用宿主已经解析好的路线。
12
12
  - **导入导出**:任务类型清单与判断服务设置都能按纯 JSON 复制走,也能粘贴回来;粘进来的那一份直接替换并立即写入。判断服务那一份只含地址与判断模型,不含密钥。
13
13
  - **完整预览**:看一眼真正会发给判断服务的整段内容,派工标签与任务正文那两处标注「派工时才填」。
14
14
  - **当场试通**:判断服务的地址填完就能试一下通不通,不用等第一次派工失败。
15
+ - **试判样例**:输入任务并主动发送,将正文和已保存的类型清单发给配置的判断服务,显示所选路线和宿主校验结果;不派工、不记日志。
15
16
  - **地址自动补路径**:端点地址填到主机就行,发请求时自动补上 `/v1/systemone`;地址里已经带了 `/v1/systemone` 或 `/systemone` 就原样用,只填到 `/v1` 就只补 `/systemone`。
16
17
  - **密钥直接填**:判断服务要用的密钥就填在配置卡片里,存进 DSH 的凭据文件,只写不读;页面不会把它显示回来。
17
- - **结果日志**:每个判过的子代理记一行——结果、选择、主代理、子代理、时间、耗时。结果写「类型 3」或「未判成」;选择一栏写模型与强度,悬停再补上供应商。点开一行看这次真正发给判断模型的完整内容,长内容自己折行、框里滚动。日志写进 DSH 家目录,重启之后还在;配置页里只列最近 10 条。
18
+ - **结果日志**:记录结果、路线、时间和耗时。点开一行可看判断模型、可选类型数和输入长度。配置页显示最近 10 条,磁盘最多保留 200 条。
18
19
 
19
20
  ## 安装与开关
20
21
 
@@ -34,7 +35,7 @@ dsh plugin --profile web add @lynn123411/dsh-subagent-judge-dispatch
34
35
 
35
36
  模型与推理等级菜单中可以按会话开关判断;关闭后该会话及其嵌套子代理的派工不判断,也不记日志。插件页的配置卡片可以设置会话默认是否开启,安装后默认开启;会话自己的选择优先于默认值。「记录日志」关掉后照常判断,只是不写日志文件。整条 loader entry 关掉时插件完全不加载。任务类型清单里每一行还有自己的开关,关掉的行不参与判断,也不占编号。
36
37
 
37
- 宿主半边声明的服务(`inject`):`credentials`、`sessions`、`sessionTitle`;`connection` 经 `ctx.inject` 取,取不到时插件照常加载、只是没有那三条读取通道;`settings` 同样经 `ctx.inject` 取,用来声明本条目不走宿主自动生成的设置页。
38
+ 宿主半边声明的服务(`inject`):`credentials`、`sessions`;`connection` 经 `ctx.inject` 取,取不到时插件照常加载、只是没有那三条读取通道;`settings` 同样经 `ctx.inject` 取,用来声明本条目不走宿主自动生成的设置页。
38
39
 
39
40
  客户端半边有两层声明,两层都要写(见 `docs/rules/client-wiring.md`):
40
41
 
@@ -54,7 +55,7 @@ dsh plugin --profile web add @lynn123411/dsh-subagent-judge-dispatch
54
55
  | `logEnabled` | true | 判断结果写不写进日志文件。 |
55
56
  | `endpointUrl` | 空 | 判断服务地址,按读者填的原样存,发请求时才补路径。 |
56
57
  | `judgeModel` | 空 | 判断模型 id。 |
57
- | `rows` | `[]` | 任务类型清单,按页面顺序;每行四个文字字段 `description`、`provider`、`model`、`effort` 与一个开关 `enabled`(缺省 true)。行没有编号字段——编号只数打开且填全的行,按数组位置从 1 连续;关掉或没填全的行不占编号,删一行、改完一行、换一个顺序,后面的自动重排。 |
58
+ | `rows` | `[]` | 任务类型清单,按页面顺序;每行包含 `description`、`provider`、`model`、`effort`、开关 `enabled` 和随机标识 `stableId`。编号只数打开且填全的行,按数组位置从 1 连续;保存清单时为缺少标识的旧行补上标识。 |
58
59
 
59
60
  字段都标了 `.volatile()`:改它们不重挂这条 loader entry,接线每次派工现读当前值。
60
61
 
@@ -64,7 +65,7 @@ dsh plugin --profile web add @lynn123411/dsh-subagent-judge-dispatch
64
65
  - **草稿按字段保留**:宿主每次发布配置,只有读者改过、且改动与「本页上次看到的已提交值」不同的那一项才留在页面上,其余跟着宿主走。按整节保留会让一次写入把读者没碰过的字段写回去,等于撤掉别的页面刚做的改动。
65
66
  - **失败就地报**:写入没落地时,那句错误出现在发起写入的那一节最后一行,两节各报各的;它留到下一次写入真的落地才消失,读者再改一下并离开输入框就会重试,不弹窗打断。密钥写失败只在密钥那一行说一次。
66
67
  - **密钥只写不读**:引用名是插件自己的常量 `SUBAGENT_JUDGE_API_KEY`,不是页面填的字段——读者只要把密钥贴进来,不必知道什么是凭据引用。密钥值交给凭据服务之后立刻从页面状态里清掉;页面只显示「已存 / 还没有」。页面没有凭据通道(非回环地址)时,输入框禁用,并有一行字说明原因。
67
- - **依赖官方配置**:任务类型能选什么由宿主那份「允许 Agent 为子智能体选择模型」决定,所以这一节顶部写明这件事,并给一个「去设置」入口。宿主没有「按 id 打开某张官方卡片」的跨插件调用,跳转分两步:`pluginNavigation.openList()` 回到插件页列表,再按下 `[data-plugin-item="subagent"]` 那张卡片——第二步用的是插件页公开的 `data-plugin-item` 属性,不碰它的私有 store;页面没有 `pluginNavigation` 时入口不显示。
68
+ - **依赖官方配置**:在「插件 → 官方 → 子智能体」开启「允许 Agent 为子智能体选择模型」,并添加允许的提供方和模型。关闭开关、列表不可用、模型不在允许列表中,或模型不支持选定的推理等级时,子代理沿用原路线。
68
69
 
69
70
  ## 实现
70
71
 
@@ -76,11 +77,13 @@ dsh plugin --profile web add @lynn123411/dsh-subagent-judge-dispatch
76
77
 
77
78
  先是派出这次活的标签(`subagent/descriptor` 的 `label`,宿主用它当子会话标题),再是任务正文原文,两段之间空一行。标签只有三五个词,是派工方写的摘要;正文才是「这个活到底要做什么」。只发标签,判断只能看出个大概方向;只发正文,遇到开头是套话的任务就丢了派工方的意图。
78
79
 
79
- 任务正文怎么取:新建的子代理从父会话刚记录的派工调用里取,恢复或继续的子代理从自己那条 `source.kind === 'user'` 的消息里取。新建那一刻子代理自己的日志里还没有任务——宿主在创建监听器返回后才把 prompt 投进它的收件箱。父会话的派工调用有两种记录形状,两种都要认:模型直接调工具留 `tool/call`(`arguments` 是模型产出的 JSON 字符串),在 `run_code` 程序里调工具留 `tool/ptc-dispatch-start`(`arguments` 已经是对象)。两种事件都在调用开始时落盘、早于工具本体执行,所以创建子代理时都读得到;按派工方写的描述(与子代理 `subagent/descriptor` 的 `label` 同一个字符串)认出是哪一次调用,对不上时取最新一条带 prompt 的。子代理自己的消息按 `source.kind === 'user'` 认:用户角色不等于任务——工作目录提示、工作区指令、运行时快照、技能清单、时间快照都写成用户消息,按来源筛才分得开;这条消息在日志里以两种形状出现,收件箱里的待办(`agent/inbox/spliced` 的 `inserted`)与认领后写成的 `user/message`,两种都认。宿主的返回指引(「你的父代理 id 是……完事用 `send_message` 回报」)是那条消息末尾追加的一个文本块,讲的是怎么交作业,不算任务,取正文时整块去掉。
80
+ 新建时,宿主在 `agent/created` 监听器返回后才投递初始任务。插件只在直接父会话当前步骤查找尚未结束的 `subagent` 或 `subagent_fork` 调用,要求派工描述与子代理 `subagent/descriptor` 的标签唯一匹配。直接调用和 `run_code` 内部调用分别对应 `tool/call` 与 `tool/ptc-dispatch-start`。找不到唯一匹配时,子代理沿用原路线。
81
+
82
+ 恢复时,插件通过父会话的 `subagent/catalog` 定位本子代理的原始派工,并核对初始任务。初始任务的来源是直接父会话发出的 `agent-message`,可以出现在收件箱的 `agent/inbox/spliced` 中,也可以已经写成 `user/message`。取正文时去掉开头的发件人提示和末尾的回报说明。找不到原始派工的恢复会话沿用原路线。
80
83
 
81
84
  只读子代理自己的事件:`ownEvents()`(或 `snapshotEvents(inheritedEventCount)`)是子代理自己产生的那一段。不能从日志开头读——叉出来的子代理,日志前缀是父代理已完成的回合,从开头读会把祖先的标签和父对话的第一条消息送给判断模型。
82
85
 
83
- 长任务按头尾截:正文留开头 1400 字与结尾 400 字,中间省掉多少字写在省略号里(`… (N characters omitted) …`)。补充要求常写在末尾,所以留尾不留中;把省掉的字数写出来,读者看日志里那段请求才分得清「截断了」和「本来就这么短」。这句标记用英文,是判断协议本身的语言。
86
+ 发给判断服务的长任务保留开头 1400 字和结尾 400 字,中间标明省略字数。
84
87
 
85
88
  ### 判断协议
86
89
 
@@ -88,9 +91,9 @@ dsh plugin --profile web add @lynn123411/dsh-subagent-judge-dispatch
88
91
 
89
92
  预览、真正发出的请求与答复匹配读的是同一份编号:关掉或没填全的行在这三处都不出现,所以预览里是编号 2 的那一行,就是答复「2」会选中的那一行。
90
93
 
91
- 写入铁律:模型、强度、提供方三项一起写。`resolveChildAgentOptions` 在「换了模型但没给强度」时会删掉继承来的强度,所以三项必须同进同出。
94
+ 提供方、模型和推理等级一次写入。派工调用显式指定路线,或子会话已经记录了模型选择或使用记录时,插件保留原路线。写入前,插件查宿主当前的子代理允许列表,并用 `llm.resolveCallConfig()` 校验这组提供方、模型和推理等级。模型校验返回后再核对允许列表,避免应用在校验期间撤销的路线。
92
95
 
93
- 兜底:任何失败都一个字段都不写,把宿主解析好的那个调用配置按身份原样退回——不是「把主代理的值再写一遍」,而是根本不碰它。这是 `decideRewrite` 返回 `none`、`applyDecision` 原样返回入参所保证的。
96
+ 判断失败或预检失败时,子代理沿用宿主已解析好的路线。
94
97
 
95
98
  端点地址补全:页面只存读者填的那一段地址,真正请求的地址在发请求时算出来——已经以 `/v1/systemone` 或 `/systemone` 结尾就原样用,只填到 `/v1` 就补 `/systemone`,更短的补 `/v1/systemone`。地址与模型两格都不预填值,占位提示给出例子。
96
99
 
@@ -98,11 +101,9 @@ dsh plugin --profile web add @lynn123411/dsh-subagent-judge-dispatch
98
101
 
99
102
  ### 日志
100
103
 
101
- 判断日志写在 `~/.dsh/dsh-subagent-judge-dispatch/judgements.json`(跟随 `DSH_HOME`),文件留最近 200 条,配置页只列最近 10 条。日志页的「优化任务类型描述」可复制一段分析最近 100 条日志、查找可能误判并建议优化任务类型描述的请求,粘贴到会话中使用。连续追加合并成一次写入,先写临时文件再改名,进程崩了也不会留下半份文档;一条记录的字段缺了,留住它带着的那部分,不连累整份文件。
102
-
103
- 表格「子代理」一栏只放派工标签(没有标签时退回正文开头,截到 60 字),不把判断模型读过的那一整段塞回去——那一整段在同一行的弹窗里能看到。日志是一张六列表:结果(`类型 3` / `未判成`)、选择(`模型 · 强度`,悬停补上供应商)、主代理、子代理、时间、耗时。结果在最左,读者扫一眼先看「判成了没有」;选择一栏只写各条之间真正不同的两样,供应商几乎每行都一样,悬停才把整段路 `供应商 · 模型 · 强度` 写出来。没判成的原因同样不在格子里展开,悬停才说——那一列宽度是给编号留的。放不下的格子截断,气泡用宿主的 `Tooltip`(原生 `title` 键盘够不到)。
104
+ 判断日志写在 `~/.dsh/dsh-subagent-judge-dispatch/judgements.json`(跟随 `DSH_HOME`)。多个进程在同一个文件锁内读取并合并最新记录,再原子替换文件。
104
105
 
105
- 点一行看的是这段提示词:弹窗里只有这次真正发给判断模型的请求体,任务文字也在里面。正文按字符折行,不给长行留横向滚动;高度超出一屏就在框里竖向滚动。这条请求体由发出请求的那一处格式化后原样存进日志,页面没有第二次拼装的机会——`scripts/smoke-host.mjs` 断言日志里那一段与发出去的请求体同值。
106
+ 「选择」列显示模型和推理等级,悬停可以查看提供方。「未判成」结果的悬停提示说明失败原因。类型编号是判断时的编号;悬停显示随机行标识,旧记录或尚未保存标识的行提示无法追溯。行标识不记录判断条件,行内容后来改动时不能还原原描述。点开日志行可看当次请求的数值和模型信息。读取失败时保留已有列表并可刷新重试。日志不保存任务正文、派工标签、会话标题或判断条件。日志页的「分析判断结果」可复制一段统计最近 100 条日志的请求。
106
107
 
107
108
  ### 导入导出
108
109
 
@@ -126,13 +127,13 @@ dsh plugin --profile web add @lynn123411/dsh-subagent-judge-dispatch
126
127
 
127
128
  ## 限制
128
129
 
129
- - 每次派工最多多等 5 秒;判断失败不重试。
130
- - 编号按位置算:关掉一行、填完一行或换一个顺序,后面的编号都会重排;日志里早先记下的编号可能因此指向另一行。
130
+ - 判断服务和宿主路线校验共用 5 秒,时间用完时沿用原路线。
131
+ - 编号按位置算,清单改变后会重排;旧日志没有行标识时不能确定当时的类型,删除或导入替换的行也无法与新行关联。
131
132
  - 每个子代理只判一次,插件卸载或重载后这份记录清空。
132
- - 写进去的模型或强度若无效,报错发生在子代理自己的第一次请求上,不在判断失败的兜底范围内。
133
+ - 宿主未开启子代理模型选择时,派工沿用宿主原路线。
133
134
  - 日志文件留最近 200 条,配置页只列最近 10 条。
134
135
  - 判断协议里的截断标记与失败原因用英文,不随界面语言变。
135
- - 任务类型能选什么由宿主那份「允许 Agent 为子智能体选择模型」决定;那份配置空着时,模型栏没有可选项。
136
+ - 任务类型的模型选项来自官方子代理设置中的允许列表。
136
137
 
137
138
  ## 验证
138
139
 
@@ -142,11 +143,11 @@ cd plugins/dsh-subagent-judge-dispatch && pnpm check
142
143
 
143
144
  `check` = `typecheck` + `build` + 五个自检 + `assert:lib-untracked`:
144
145
 
145
- - **`scripts/test-decision.mjs`** 打的是 `src/`(Node 直接跑 `.ts`),守判断与改写这条纯逻辑:失败时按身份退回同一个对象(不是深比较——深比较会放过「复制一份再写回原值」这种仍然算覆盖的写法)、三项同写、残缺行不生效、答复读取的三种形状与七种空答复、四种失败原因各自的归类、超时不重试、日志文件留 200 条、页面只取最近 10 条、换一个 LogStore 实例也读得回来、文件缺失或残缺都不抛、读出来是副本,编号按位置从 1 连着。它还守判断模型读到的输入:标签在前正文在后、没标签时只发正文、两样都没有时输入为空、短任务一字不动、长任务留头尾并写明省掉多少字、刚好到上限的不算截断;端点地址的补全;以及「判断带回的提示词就是发出去的那一段」;它还守清单的开关与编号:关掉或没填全的行不占编号也不进判断请求、有效清单的编号从 1 连续没有缺号、预览与答复读同一份编号、判断选中一个被关掉的行时不改写。
146
- - **`scripts/smoke-host.mjs`** 起真 cordis `Context`,把 `agent/created` 钩子按宿主的方式跑一遍(判定后断言 `agent.model.select()` 收到了什么;判定没成时断言一次都没调):主代理不被判断、同一子代理只判一次、两个开关各自的短路、发送出去的请求体形状、判断输入是标签加正文两段、正文按 `source.kind` 取、新建子代理时从父会话刚记录的派工调用里按标签取正文(两种记录形状各一组用例)、派工消息还在收件箱里与已经落盘成 `user/message` 两种形状都读得到、宿主追加的返回指引不送进去、长任务留头尾、没有描述时取任务正文、叉出来的子代理只读自己的事件、日志的子代理一栏只写标签、判断过的记忆有上限;关掉或没填全的类型不发给判断模型且编号连续、预览路由与判断请求读同一份编号、全部关掉时不判断。它另起一个挂着 `connection` 的实例,从日志路由读回那一行,断言 `prompt` 与真正发出去的请求体同值。
146
+ - **`scripts/test-decision.mjs`** 直接验证判断请求、答复匹配、超时、类型编号与日志保留。用四个进程同时追加日志,核对磁盘保留完整的最新 200 条。
147
+ - **`scripts/smoke-host.mjs`** 用 Cordis `Context` 验证 `agent/created` 的派工关联、原路线保留、实时允许名单、推理等级校验、共享时限与无任务正文的日志;模拟判断服务检查样例正文、路线校验和不记日志。使用真实 Connection 验证 `/api` 必须认证、匿名凭据被拒、非 owner 无法触发样例判断。
147
148
  - **`scripts/smoke-client.mjs`** 按 Web shell 的方式装载 `lib/client.js`(`window.__ModuleLoader__.load` 桩件),喂假 cordis 服务:断言卡片注册进 `plugins.bundle.config`、key 是包名、走 `slots.inject`、读本插件自己的命名空间与宿主那份「子代理可选用哪些模型」设置、以宿主在服务本条目为挂载条件、样式表在 `apply()` 追加一次且没写死色值,以及 zh/en 键集一致。它的守卫带反例断言(「守卫拒绝未声明的服务读取」必须抛)。
148
- - **`scripts/test-card.mjs`** 打的是 `src/`,守配置卡片这层状态机:文字格只在提交时写且只写改过的那一项、开关与行的增删当场写、连续两次提交合并成一次写、没填完的行照常写入而页面只在行上提示、宿主回 `false` 算没写进去、密钥跟着判断服务那次提交一起写且写的是固定引用名、密钥值从不进页面状态、草稿按字段保留,「选择」一列只写模型与强度、悬停才带上供应商,清单与判断服务设置各自的 JSON 导出与导入认什么、拒什么,以及官方配置入口的有无与调用。
149
- - **`scripts/test-render.mjs`** 用真 react 把卡片画进 jsdom:没有保存按钮,两节标题行的动作顺序、行上只剩「删掉」、预览单独在卡片最下面那条栏里;任务类型那一节写明依赖的官方配置,点入口先回插件页列表、再按下那张官方卡片;文字格离开才写、写的是这一格的新值,行的问题写在编号列下方;日志表是六列且顺序固定,结果写「类型 3」/「未判成」,选择格只写模型与强度、供应商在悬停气泡里,导出把清单按纯 JSON 写进剪贴板、导入直接替换并立即写入且三种坏输入各报各的话,没判成的原因挂在宿主的 `Tooltip` 上而不是原生 `title`。`ui-primitives` 走替身(真组件是浏览器 ESM、带 `.css` 导入,Node 里跑不起来),所以它验的是本插件的视图结构,外观与浮层定位要在真浏览器里看。
149
+ - **`scripts/test-card.mjs`** 打的是 `src/`,守配置卡片状态机、失败的日志读取与重试、行标识在排序后保持不变,以及清单与判断服务设置的导入导出。
150
+ - **`scripts/test-render.mjs`** 用真 react 把卡片画进 jsdom,验证配置、导入导出和日志表,旧记录的编号说明挂在 `Tooltip` 上。`ui-primitives` 走替身,外观与浮层定位要在真浏览器里看。
150
151
  - **`assert-lib-untracked.mjs`**:`lib/` 是构建镜像,不入 git。
151
152
 
152
153
  要肉眼确认页面上的形态,用仓库的 `node tools/verify-client.mjs dsh-subagent-judge-dispatch --needle '<你新写的文案>'`。
package/lib/client.js CHANGED
@@ -129,29 +129,6 @@ function setupPluginPage(slots, register) {
129
129
  return slots.inject(BUNDLE_CONFIG_SLOT, register);
130
130
  }
131
131
 
132
- // src/client/settings/official-settings.ts
133
- var SUBAGENT_ITEM_ID = "subagent";
134
- var OPEN_BUDGET_MS = 1500;
135
- var OPEN_POLL_MS = 50;
136
- function createOfficialSettingsOpener(navigation) {
137
- if (navigation === void 0 || typeof navigation.openList !== "function") return null;
138
- return () => {
139
- navigation.openList();
140
- const deadline = Date.now() + OPEN_BUDGET_MS;
141
- const press = () => {
142
- const card = document.querySelector(
143
- `[data-plugin-item="${SUBAGENT_ITEM_ID}"] button`
144
- );
145
- if (card !== null) {
146
- card.click();
147
- return;
148
- }
149
- if (Date.now() < deadline) setTimeout(press, OPEN_POLL_MS);
150
- };
151
- setTimeout(press, 0);
152
- };
153
- }
154
-
155
132
  // src/server/judge-prompt.ts
156
133
  function isSelectableRow(row) {
157
134
  return row.provider.trim() !== "" && row.model.trim() !== "" && row.effort.trim() !== "";
@@ -165,6 +142,7 @@ var ALLOWED_MODELS_NAMESPACE = "subagent-model-selection-settings";
165
142
  var LOG_ROUTE_PATH = "/api/dsh-subagent-judge-dispatch/log";
166
143
  var PREVIEW_ROUTE_PATH = "/api/dsh-subagent-judge-dispatch/preview";
167
144
  var PROBE_ROUTE_PATH = "/api/dsh-subagent-judge-dispatch/probe";
145
+ var SAMPLE_ROUTE_PATH = "/api/dsh-subagent-judge-dispatch/sample";
168
146
  async function readJson(response) {
169
147
  try {
170
148
  return await response.json();
@@ -175,14 +153,11 @@ async function readJson(response) {
175
153
  function createDispatchRemote() {
176
154
  return {
177
155
  async log() {
178
- try {
179
- const response = await fetch(LOG_ROUTE_PATH);
180
- if (!response.ok) return [];
181
- const body = await readJson(response);
182
- return Array.isArray(body?.entries) ? body.entries : [];
183
- } catch {
184
- return [];
185
- }
156
+ const response = await fetch(LOG_ROUTE_PATH);
157
+ if (!response.ok) throw new Error("Log request failed");
158
+ const body = await readJson(response);
159
+ if (body?.ok !== true || !Array.isArray(body.entries)) throw new Error("Invalid log response");
160
+ return body.entries;
186
161
  },
187
162
  async preview() {
188
163
  try {
@@ -208,6 +183,15 @@ function createDispatchRemote() {
208
183
  } catch {
209
184
  return { ok: false, latencyMs: 0, reason: "unreachable" };
210
185
  }
186
+ },
187
+ async sample(task) {
188
+ const response = await fetch(SAMPLE_ROUTE_PATH, {
189
+ method: "POST",
190
+ headers: { "content-type": "application/json" },
191
+ body: JSON.stringify({ task })
192
+ });
193
+ if (!response.ok) throw new Error("Sample request failed");
194
+ return await readJson(response) ?? { ok: false, reason: "unreachable" };
211
195
  }
212
196
  };
213
197
  }
@@ -215,6 +199,7 @@ function readRow(value) {
215
199
  const record = typeof value === "object" && value !== null ? value : {};
216
200
  const text = (key) => typeof record[key] === "string" ? record[key] : "";
217
201
  return {
202
+ ...typeof record.stableId === "string" && record.stableId !== "" ? { stableId: record.stableId } : {},
218
203
  description: text("description"),
219
204
  provider: text("provider"),
220
205
  model: text("model"),
@@ -406,7 +391,6 @@ var DispatchCardStore = class {
406
391
  credentials = null;
407
392
  offForm = null;
408
393
  offAllowed = null;
409
- officialSettingsOpener = null;
410
394
  translate = (key) => key;
411
395
  /** Bind the Host services; re-binding detaches the previous subscriptions. */
412
396
  attach(options) {
@@ -417,7 +401,6 @@ var DispatchCardStore = class {
417
401
  this.session = options.session;
418
402
  this.remote = options.remote;
419
403
  this.credentials = options.credentials;
420
- this.officialSettingsOpener = options.officialSettingsOpener;
421
404
  this.translate = options.t;
422
405
  this.state = {
423
406
  ...this.state,
@@ -654,7 +637,9 @@ var DispatchCardStore = class {
654
637
  ops.push({ op: "set", path: ["logEnabled"], value: this.state.logEnabled });
655
638
  }
656
639
  } else if (JSON.stringify(this.state.rows) !== JSON.stringify(this.state.committed.rows)) {
657
- ops.push({ op: "set", path: ["rows"], value: this.state.rows.map((row) => ({ ...row })) });
640
+ const rows = this.state.rows.map((row) => readRow({ ...row, stableId: row.stableId || crypto.randomUUID() }));
641
+ this.state = { ...this.state, rows };
642
+ ops.push({ op: "set", path: ["rows"], value: rows });
658
643
  }
659
644
  const typedKey = section === "judge" ? this.state.key.text.trim() : "";
660
645
  if (ops.length === 0 && typedKey === "") {
@@ -726,17 +711,13 @@ var DispatchCardStore = class {
726
711
  return { ok: false, error: message };
727
712
  }
728
713
  }
729
- /** Whether this page can open the official setting the type list depends on. */
730
- canOpenOfficialSettings() {
731
- return this.officialSettingsOpener !== null;
732
- }
733
- /** Open the official setting the type list depends on. */
734
- openOfficialSettings() {
735
- this.officialSettingsOpener?.();
736
- }
737
714
  /** Read the runtime log from the Host. */
738
715
  async refreshLog() {
739
- if (this.remote === null) return;
716
+ if (this.remote === null) {
717
+ this.state = { ...this.state, logLoaded: true, logFailed: true };
718
+ this.notify();
719
+ return;
720
+ }
740
721
  try {
741
722
  const entries = await this.remote.log();
742
723
  this.state = { ...this.state, log: entries, logLoaded: true, logFailed: false };
@@ -763,6 +744,13 @@ var DispatchCardStore = class {
763
744
  return { ok: false, latencyMs: 0, reason: "unreachable" };
764
745
  }
765
746
  }
747
+ async sample(task) {
748
+ try {
749
+ return await this.remote?.sample?.(task) ?? { ok: false, reason: "unreachable" };
750
+ } catch {
751
+ return { ok: false, reason: "unreachable" };
752
+ }
753
+ }
766
754
  /** The effort ids available for one row's currently selected model. */
767
755
  effortsFor(row) {
768
756
  return this.state.models.find(
@@ -833,6 +821,7 @@ var en = {
833
821
  "reason.timeout": "it did not answer within 5 seconds",
834
822
  "reason.unmatched": "the answer named no listed type",
835
823
  "reason.incomplete": "the selected type is not filled in",
824
+ "reason.unavailable-route": "the selected model or effort is unavailable",
836
825
  "reason.other": "other",
837
826
  "reason.unknown": "unknown reason",
838
827
  "rows.title": "Task types",
@@ -851,8 +840,7 @@ var en = {
851
840
  "rows.effortPlaceholder": "Not chosen",
852
841
  "rows.incomplete": "Not used",
853
842
  "rows.descriptionPlaceholder": "What kind of job is this? Write as much as you like.",
854
- "rows.dependsOn": 'Depends on the official setting "Allow agents to choose models for Subagents".',
855
- "rows.dependsOnOpen": "Open",
843
+ "rows.dependsOn": "Under Plugins \u2192 Official \u2192 Subagent, enable model selection and add allowed models. If it is off, the child keeps its original model.",
856
844
  "rows.allowedEmpty": "The official setting offers no model yet; fill it in and the options appear here.",
857
845
  "rows.importOpen": "Import",
858
846
  "rows.export": "Export",
@@ -878,26 +866,33 @@ var en = {
878
866
  "write.invalid": "This could not be written.",
879
867
  "write.refused": "The host did not accept this write.",
880
868
  "log.title": "Judgement log",
881
- "log.desc": "The most recent 10 judgements, newest first; the file keeps more. Click one to see the exact prompt that was sent.",
869
+ "log.desc": "The 10 most recent judgements. Open an entry to see its request metrics.",
882
870
  "log.empty": "No judgement has run yet.",
883
871
  "log.colResult": "Result",
884
872
  "log.colChoice": "Choice",
885
- "log.colParent": "Main agent",
886
- "log.colChild": "Subagent",
887
873
  "log.colTime": "Time",
888
874
  "log.colLatency": "Took",
889
875
  "log.resultJudged": "Type {id}",
876
+ "log.resultHistorical": "Type {id} at the time",
890
877
  "log.resultInherited": "No match",
891
- "log.promptTitle": "The prompt sent to the judge",
892
- "log.promptDesc": "Exactly the request body this judgement sent.",
878
+ "log.promptTitle": "Judgement request metrics",
879
+ "log.promptDesc": "Judge model, number of offered choices, and input length.",
893
880
  "log.promptClose": "Close",
894
- "log.promptEmpty": "No request was sent for this judgement.",
895
- "log.copyAnalysis": "Improve task type descriptions",
896
- "log.analysisPrompt": "Analyze the latest 100 judgement log entries in the DSH home (DSH_HOME, default ~/.dsh) at dsh-subagent-judge-dispatch/judgements.json. Compare each task and selected type with the criteria recorded in that request; type descriptions and numbering may have changed. Identify possible misclassifications with examples, explain uncertainty and missing or truncated task text, and suggest improved task type descriptions. Read the current task types and preserve their model and effort settings. Do not change the configuration unless asked.",
881
+ "log.promptEmpty": "No judge request was attempted.",
882
+ "log.copyAnalysis": "Analyze judgement results",
883
+ "log.analysisPrompt": "Analyze the latest 100 records in dsh-subagent-judge-dispatch/judgements.json under DSH_HOME (default ~/.dsh). Summarize results by type, fallback reasons, and latency. Type numbering can change when the list is edited. Do not infer whether individual tasks were classified correctly from metrics alone.",
897
884
  "log.analysisCopied": "Analysis prompt copied.",
898
885
  "log.analysisCopyFailed": "Could not copy to the clipboard.",
899
886
  "log.refresh": "Refresh",
900
887
  "log.loadFailed": "The log could not be read.",
888
+ "log.typeKey": "Type identifier: {key}; number at the time of judgement.",
889
+ "log.legacyType": "Historical number; the original type cannot be identified after edits.",
890
+ "sample.title": "Try a sample task",
891
+ "sample.desc": "Sending will transmit this text and the configured type list to the configured judgement service. Uses saved settings; does not dispatch a subagent or write a log.",
892
+ "sample.send": "Send sample for judgement",
893
+ "sample.running": "Judging\u2026",
894
+ "sample.valid": "Route validation passed.",
895
+ "sample.failed": "Judgement or route validation failed:",
901
896
  "ms": "{value} ms"
902
897
  };
903
898
  var zh = {
@@ -944,9 +939,10 @@ var zh = {
944
939
  "judge.probeFail": "\u7528\u4E0D\u4E86\uFF1A{reason}",
945
940
  "reason.unconfigured": "\u7AEF\u70B9\u5730\u5740\u6216\u5224\u65AD\u6A21\u578B\u8FD8\u6CA1\u586B",
946
941
  "reason.unreachable": "\u8FDE\u4E0D\u4E0A\u8FD9\u4E2A\u5730\u5740",
947
- "reason.timeout": "\u7B49\u4E86 5 \u79D2\u6CA1\u56DE",
942
+ "reason.timeout": "\u5224\u65AD\u6216\u8DEF\u7EBF\u6821\u9A8C\u8D85\u8FC7 5 \u79D2",
948
943
  "reason.unmatched": "\u7B54\u590D\u5BF9\u4E0D\u4E0A\u6E05\u5355",
949
944
  "reason.incomplete": "\u9009\u4E2D\u7684\u7C7B\u578B\u6CA1\u586B\u5168",
945
+ "reason.unavailable-route": "\u9009\u4E2D\u7684\u6A21\u578B\u6216\u63A8\u7406\u7B49\u7EA7\u5F53\u524D\u4E0D\u53EF\u7528",
950
946
  "reason.other": "\u5176\u4ED6",
951
947
  "reason.unknown": "\u539F\u56E0\u4E0D\u660E",
952
948
  "rows.title": "\u4EFB\u52A1\u7C7B\u578B",
@@ -965,8 +961,7 @@ var zh = {
965
961
  "rows.effortPlaceholder": "\u8FD8\u6CA1\u9009",
966
962
  "rows.incomplete": "\u4E0D\u751F\u6548",
967
963
  "rows.descriptionPlaceholder": "\u8FD9\u662F\u54EA\u79CD\u6D3B\uFF1F\u5199\u591A\u5C11\u90FD\u884C\u3002",
968
- "rows.dependsOn": "\u4F9D\u8D56\u5B98\u65B9\u914D\u7F6E\u300C\u5141\u8BB8 Agent \u4E3A\u5B50\u667A\u80FD\u4F53\u9009\u62E9\u6A21\u578B\u300D\u3002",
969
- "rows.dependsOnOpen": "\u53BB\u8BBE\u7F6E",
964
+ "rows.dependsOn": "\u8BF7\u5728\u300C\u63D2\u4EF6 \u2192 \u5B98\u65B9 \u2192 \u5B50\u667A\u80FD\u4F53\u300D\u4E2D\u5F00\u542F\u6A21\u578B\u9009\u62E9\u5E76\u6DFB\u52A0\u5141\u8BB8\u7684\u6A21\u578B\u3002\u5173\u95ED\u65F6\uFF0C\u5B50\u4EE3\u7406\u6CBF\u7528\u539F\u8DEF\u7EBF\u3002",
970
965
  "rows.allowedEmpty": "\u5B98\u65B9\u914D\u7F6E\u91CC\u8FD8\u6CA1\u6709\u53EF\u9009\u6A21\u578B\uFF0C\u586B\u4E0A\u4E4B\u540E\u8FD9\u91CC\u624D\u6709\u53EF\u9009\u9879\u3002",
971
966
  "rows.importOpen": "\u5BFC\u5165",
972
967
  "rows.export": "\u5BFC\u51FA",
@@ -992,26 +987,33 @@ var zh = {
992
987
  "write.invalid": "\u8FD9\u6B21\u5199\u5165\u6CA1\u88AB\u63A5\u53D7\u3002",
993
988
  "write.refused": "\u5BBF\u4E3B\u6CA1\u6709\u63A5\u53D7\u8FD9\u6B21\u5199\u5165\u3002",
994
989
  "log.title": "\u5224\u65AD\u65E5\u5FD7",
995
- "log.desc": "\u6700\u8FD1 10 \u6761\u5224\u65AD\uFF0C\u65B0\u7684\u5728\u6700\u524D\u9762\uFF1B\u6587\u4EF6\u91CC\u7559\u5F97\u66F4\u591A\u3002\u70B9\u4E00\u884C\u770B\u8FD9\u6B21\u53D1\u7ED9\u5224\u65AD\u6A21\u578B\u7684\u90A3\u6BB5\u5185\u5BB9\u3002",
990
+ "log.desc": "\u663E\u793A\u6700\u8FD1 10 \u6B21\u5224\u65AD\u3002\u70B9\u5F00\u4E00\u884C\u67E5\u770B\u5F53\u6B21\u8BF7\u6C42\u7684\u7EDF\u8BA1\u3002",
996
991
  "log.empty": "\u8FD8\u6CA1\u6709\u5224\u65AD\u8FC7\u3002",
997
992
  "log.colResult": "\u7ED3\u679C",
998
993
  "log.colChoice": "\u9009\u62E9",
999
- "log.colParent": "\u4E3B\u4EE3\u7406",
1000
- "log.colChild": "\u5B50\u4EE3\u7406",
1001
994
  "log.colTime": "\u65F6\u95F4",
1002
995
  "log.colLatency": "\u8017\u65F6",
1003
996
  "log.resultJudged": "\u7C7B\u578B {id}",
997
+ "log.resultHistorical": "\u5F53\u65F6\u7684\u7C7B\u578B {id}",
1004
998
  "log.resultInherited": "\u672A\u5224\u6210",
1005
- "log.promptTitle": "\u53D1\u7ED9\u5224\u65AD\u6A21\u578B\u7684\u5185\u5BB9",
1006
- "log.promptDesc": "\u8FD9\u6B21\u5224\u65AD\u771F\u6B63\u53D1\u51FA\u53BB\u7684\u8BF7\u6C42\u4F53\u3002",
999
+ "log.promptTitle": "\u5224\u65AD\u8BF7\u6C42\u7EDF\u8BA1",
1000
+ "log.promptDesc": "\u5224\u65AD\u6A21\u578B\u3001\u53EF\u9009\u7C7B\u578B\u6570\u548C\u8F93\u5165\u957F\u5EA6\u3002",
1007
1001
  "log.promptClose": "\u5173\u95ED",
1008
- "log.promptEmpty": "\u8FD9\u6B21\u5224\u65AD\u6CA1\u6709\u53D1\u51FA\u8BF7\u6C42\u3002",
1009
- "log.copyAnalysis": "\u4F18\u5316\u4EFB\u52A1\u7C7B\u578B\u63CF\u8FF0",
1010
- "log.analysisPrompt": "\u8BF7\u5206\u6790 DSH \u5BB6\u76EE\u5F55\uFF08DSH_HOME\uFF0C\u9ED8\u8BA4 ~/.dsh\uFF09\u4E0B dsh-subagent-judge-dispatch/judgements.json \u4E2D\u6700\u8FD1 100 \u6761\u5224\u65AD\u65E5\u5FD7\u3002\u9010\u6761\u7ED3\u5408\u4EFB\u52A1\u5185\u5BB9\u3001\u9009\u62E9\u7ED3\u679C\u548C\u5F53\u6B21\u8BF7\u6C42\u4E2D\u8BB0\u5F55\u7684\u4EFB\u52A1\u7C7B\u578B\u63CF\u8FF0\uFF0C\u627E\u51FA\u53EF\u80FD\u7684\u8BEF\u5224\u5E76\u4E3E\u4F8B\u8BF4\u660E\uFF1B\u7C7B\u578B\u63CF\u8FF0\u548C\u7F16\u53F7\u53EF\u80FD\u968F\u65F6\u95F4\u53D8\u5316\u3002\u8BF4\u660E\u8BC1\u636E\u4E0D\u8DB3\u3001\u4EFB\u52A1\u6B63\u6587\u7F3A\u5931\u6216\u88AB\u622A\u65AD\u7684\u60C5\u51B5\uFF0C\u5E76\u7ED9\u51FA\u5F53\u524D\u4EFB\u52A1\u7C7B\u578B\u63CF\u8FF0\u7684\u4F18\u5316\u5EFA\u8BAE\u3002\u8BF7\u8BFB\u53D6\u5F53\u524D\u4EFB\u52A1\u7C7B\u578B\uFF0C\u4FDD\u7559\u6A21\u578B\u548C\u5F3A\u5EA6\u914D\u7F6E\uFF1B\u672A\u7ECF\u8981\u6C42\u4E0D\u8981\u4FEE\u6539\u914D\u7F6E\u3002",
1002
+ "log.promptEmpty": "\u8FD9\u6B21\u6CA1\u6709\u5C1D\u8BD5\u53D1\u9001\u5224\u65AD\u8BF7\u6C42\u3002",
1003
+ "log.copyAnalysis": "\u5206\u6790\u5224\u65AD\u7ED3\u679C",
1004
+ "log.analysisPrompt": "\u8BF7\u5206\u6790 DSH \u5BB6\u76EE\u5F55\uFF08DSH_HOME\uFF0C\u9ED8\u8BA4 ~/.dsh\uFF09\u4E0B dsh-subagent-judge-dispatch/judgements.json \u4E2D\u6700\u8FD1 100 \u6761\u5224\u65AD\u8BB0\u5F55\u3002\u7EDF\u8BA1\u5404\u7C7B\u578B\u7684\u5224\u65AD\u6B21\u6570\u3001\u5931\u8D25\u539F\u56E0\u548C\u8017\u65F6\u3002\u6E05\u5355\u6539\u52A8\u540E\u7C7B\u578B\u7F16\u53F7\u53EF\u80FD\u53D8\u5316\uFF0C\u4EC5\u51ED\u8FD9\u4E9B\u6307\u6807\u65E0\u6CD5\u5224\u65AD\u5355\u4E2A\u4EFB\u52A1\u662F\u5426\u88AB\u6B63\u786E\u5F52\u7C7B\u3002",
1011
1005
  "log.analysisCopied": "\u5DF2\u590D\u5236\u5206\u6790\u63D0\u793A\u8BCD\u3002",
1012
1006
  "log.analysisCopyFailed": "\u590D\u5236\u5230\u526A\u8D34\u677F\u6CA1\u6210\u529F\u3002",
1013
1007
  "log.refresh": "\u5237\u65B0",
1014
1008
  "log.loadFailed": "\u65E5\u5FD7\u8BFB\u4E0D\u51FA\u6765\u3002",
1009
+ "log.typeKey": "\u7C7B\u578B\u6807\u8BC6\uFF1A{key}\uFF1B\u7F16\u53F7\u662F\u5224\u65AD\u65F6\u7684\u7F16\u53F7\u3002",
1010
+ "log.legacyType": "\u8FD9\u662F\u5F53\u65F6\u7684\u7F16\u53F7\uFF1B\u6E05\u5355\u4FEE\u6539\u540E\u65E0\u6CD5\u786E\u5B9A\u539F\u6765\u7684\u7C7B\u578B\u3002",
1011
+ "sample.title": "\u8BD5\u5224\u6837\u4F8B\u4EFB\u52A1",
1012
+ "sample.desc": "\u53D1\u9001\u540E\uFF0C\u8FD9\u6BB5\u6587\u5B57\u548C\u5DF2\u4FDD\u5B58\u7684\u7C7B\u578B\u6E05\u5355\u4F1A\u53D1\u7ED9\u914D\u7F6E\u7684\u5224\u65AD\u670D\u52A1\u3002\u4F7F\u7528\u5DF2\u4FDD\u5B58\u7684\u8BBE\u7F6E\uFF0C\u4E0D\u4F1A\u6D3E\u51FA\u5B50\u4EE3\u7406\u6216\u5199\u5165\u65E5\u5FD7\u3002",
1013
+ "sample.send": "\u53D1\u9001\u6837\u4F8B\u5E76\u8BD5\u5224",
1014
+ "sample.running": "\u6B63\u5728\u5224\u65AD\u2026",
1015
+ "sample.valid": "\u8DEF\u7EBF\u6821\u9A8C\u901A\u8FC7\u3002",
1016
+ "sample.failed": "\u5224\u65AD\u6216\u8DEF\u7EBF\u6821\u9A8C\u5931\u8D25\uFF1A",
1015
1017
  "ms": "{value} \u6BEB\u79D2"
1016
1018
  };
1017
1019
  function apply(ctx) {
@@ -1108,11 +1110,7 @@ var CARD_CSS = `
1108
1110
  /* \u6807\u9898\u884C\u53F3\u7AEF\u7684\u4E00\u7EC4\u52A8\u4F5C\uFF1A\u8BD5\u901A\u3001\u5BFC\u5165\u3001\u5BFC\u51FA\u3001\u52A0\u4E00\u884C\u90FD\u6392\u5728\u8FD9\u91CC\u3002 */
1109
1111
  .dsh-judge-actions-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
1110
1112
  /* \u4EFB\u52A1\u7C7B\u578B\u90A3\u4E00\u8282\u9876\u90E8\u7684\u4E00\u884C\uFF1A\u4F9D\u8D56\u54EA\u4EFD\u5B98\u65B9\u914D\u7F6E\uFF0C\u4EE5\u53CA\u53BB\u90A3\u91CC\u7684\u5165\u53E3\u3002 */
1111
- .dsh-judge-dependency { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px; }
1112
- .dsh-judge-dependency .dsh-judge-desc { max-width: none; }
1113
1113
  /* \u5165\u53E3\u6309\u94FE\u63A5\u7684\u6837\u5B50\u8D70\uFF1A\u6CA1\u6709\u6309\u94AE\u7684\u76D2\u5B50\u548C\u5E95\u8272\uFF0C\u53EA\u5728\u60AC\u505C\u65F6\u52A0\u4E0B\u5212\u7EBF\u3002 */
1114
- .dsh-judge-link { height: auto; padding: 0 2px; color: var(--dsw-alias-link); font: var(--dsw-font-xxs-12); }
1115
- .dsh-judge-link:hover { color: var(--dsw-alias-link); background: none; text-decoration: underline; }
1116
1114
  /* \u5361\u7247\u6700\u4E0B\u9762\u7684\u51FA\u53E3\uFF1A\u53EA\u6709\u9884\u89C8\u8FD9\u4E00\u4EF6\u8DE8\u8282\u7684\u52A8\u4F5C\uFF0C\u9760\u53F3\u4E0E\u4E24\u8282\u7684\u53F3\u8FB9\u7F18\u5BF9\u9F50\u3002 */
1117
1115
  .dsh-judge-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
1118
1116
  .dsh-judge-hint { color: var(--dsw-alias-label-tertiary); font: var(--dsw-font-xxs-12); }
@@ -1139,9 +1137,8 @@ var CARD_CSS = `
1139
1137
  .dsh-judge-row-off .dsh-judge-field { opacity: 0.6; }
1140
1138
  .dsh-judge-cell-actions { display: flex; gap: 6px; }
1141
1139
  .dsh-judge-log { display: flex; flex-direction: column; gap: 4px; font: var(--dsw-font-xxs-12); }
1142
- /* \u516D\u5217\u7684\u5BBD\u5EA6\u6309\u5185\u5BB9\u5B9A\uFF1A\u7ED3\u679C\u4E0E\u65F6\u95F4\u662F\u5B9A\u957F\u7684\uFF0C\u9009\u62E9\u6700\u957F\u3001\u4E3B\u4EE3\u7406\u4E0E\u5B50\u4EE3\u7406\u5404\u5360\u4E00\u4EFD\u4F59\u91CF\u3002
1143
- minmax(0, \u2026) \u662F\u622A\u65AD\u7684\u524D\u63D0\u2014\u2014\u4E0D\u7ED9\u4E0B\u9650\u5F52\u96F6\uFF0C\u957F\u5185\u5BB9\u4F1A\u628A\u6574\u5217\u6491\u51FA\u53BB\u3002 */
1144
- .dsh-judge-log-row { display: grid; grid-template-columns: 72px minmax(0, 2.2fr) minmax(0, 1.2fr) minmax(0, 1.2fr) 62px 74px; gap: 8px; align-items: center; text-align: left; border: 0; background: none; padding: 6px 4px; border-radius: var(--dsw-radius-sm); cursor: pointer; color: inherit; font: inherit; }
1140
+ /* Allow the model column to shrink so long names can be clipped. */
1141
+ .dsh-judge-log-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) 62px 74px; gap: 8px; align-items: center; text-align: left; border: 0; background: none; padding: 6px 4px; border-radius: var(--dsw-radius-sm); cursor: pointer; color: inherit; font: inherit; }
1145
1142
  .dsh-judge-cell-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1146
1143
  .dsh-judge-log-row:hover { background: var(--dsw-alias-interactive-bg-hover); }
1147
1144
  .dsh-judge-log-head { font-weight: 600; color: var(--dsw-alias-label-tertiary); cursor: default; }
@@ -1156,14 +1153,15 @@ var CARD_CSS = `
1156
1153
  .dsh-judge-paste:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-alias-state-business-primary); }
1157
1154
  `;
1158
1155
  function injectCardStyles() {
1159
- if (typeof document === "undefined") return;
1160
- if (document.getElementById(STYLE_ID) !== null) return;
1156
+ if (typeof document === "undefined" || document.getElementById(STYLE_ID) !== null) return () => {
1157
+ };
1161
1158
  const element = document.createElement("style");
1162
1159
  element.id = STYLE_ID;
1163
1160
  element.dataset.plugin = PLUGIN_NAME;
1164
1161
  element.dataset.pluginCss = `${PLUGIN_NAME}/settings/ui`;
1165
1162
  element.textContent = CARD_CSS;
1166
1163
  document.head.appendChild(element);
1164
+ return () => element.remove();
1167
1165
  }
1168
1166
  var STYLE_ID = "dsh-subagent-judge-dispatch-styles";
1169
1167
  var PLUGIN_NAME = "@lynn123411/dsh-subagent-judge-dispatch";
@@ -1176,6 +1174,9 @@ function JudgeDispatchPanel(props) {
1176
1174
  const [previewOpen, setPreviewOpen] = (0, import_react2.useState)(false);
1177
1175
  const [probing, setProbing] = (0, import_react2.useState)(false);
1178
1176
  const [probeResult, setProbeResult] = (0, import_react2.useState)(null);
1177
+ const [sampleTask, setSampleTask] = (0, import_react2.useState)("");
1178
+ const [sampling, setSampling] = (0, import_react2.useState)(false);
1179
+ const [sampleResult, setSampleResult] = (0, import_react2.useState)(null);
1179
1180
  const [detail, setDetail] = (0, import_react2.useState)(null);
1180
1181
  const [openMenu, setOpenMenu] = (0, import_react2.useState)(null);
1181
1182
  const [importSection, setImportSection] = (0, import_react2.useState)(null);
@@ -1290,6 +1291,7 @@ function JudgeDispatchPanel(props) {
1290
1291
  }
1291
1292
  ) }),
1292
1293
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("td", { children: [
1294
+ draft.stableId && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-judge-hint", children: t("log.typeKey").replace("{key}", draft.stableId) }),
1293
1295
  rowHints(state.rows, index, t).map((hint) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-judge-off", children: hint }, hint)),
1294
1296
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1295
1297
  "textarea",
@@ -1548,19 +1550,7 @@ function JudgeDispatchPanel(props) {
1548
1550
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", onClick: () => dispatchCardStore.addRow(), children: t("rows.add") })
1549
1551
  ] })
1550
1552
  ] }),
1551
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-judge-dependency", children: [
1552
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-judge-desc", children: t("rows.dependsOn") }),
1553
- dispatchCardStore.canOpenOfficialSettings() && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1554
- import_dsh_client_ui_primitives2.Button,
1555
- {
1556
- variant: "ghost",
1557
- size: "sm",
1558
- className: "dsh-judge-link",
1559
- onClick: () => dispatchCardStore.openOfficialSettings(),
1560
- children: t("rows.dependsOnOpen")
1561
- }
1562
- )
1563
- ] }),
1553
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-desc", children: t("rows.dependsOn") }),
1564
1554
  state.models.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-off", children: t("rows.allowedEmpty") }),
1565
1555
  state.rows.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-desc", children: t("rows.empty") }),
1566
1556
  state.rows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("table", { className: "dsh-judge-table", children: [
@@ -1576,7 +1566,25 @@ function JudgeDispatchPanel(props) {
1576
1566
  copyNote !== null && copyNote.section === "rows" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: copyNote.ok ? "dsh-judge-note-ok" : "dsh-judge-note-bad", role: "status", children: copyNote.text }),
1577
1567
  failure("rows")
1578
1568
  ] }),
1579
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-footer", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", onClick: () => void openPreview(), children: t("preview.open") }) })
1569
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-footer", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", onClick: () => void openPreview(), children: t("preview.open") }) }),
1570
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-judge-section", children: [
1571
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-title", children: t("sample.title") }),
1572
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-desc", children: t("sample.desc") }),
1573
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("textarea", { "aria-label": t("sample.title"), value: sampleTask, maxLength: 1e4, onChange: (event) => setSampleTask(event.target.value) }),
1574
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", disabled: sampling || !sampleTask.trim() || state.writing !== "", onClick: () => void (async () => {
1575
+ setSampling(true);
1576
+ await dispatchCardStore.flush();
1577
+ const current = dispatchCardStore.getState();
1578
+ if (current.writeFailed || current.key.failed || current.endpointUrl !== current.committed.endpointUrl || current.judgeModel !== current.committed.judgeModel || JSON.stringify(current.rows) !== JSON.stringify(current.committed.rows)) setSampleResult({ ok: false, reason: "write" });
1579
+ else setSampleResult(await dispatchCardStore.sample(sampleTask));
1580
+ setSampling(false);
1581
+ })(), children: sampling ? t("sample.running") : t("sample.send") }),
1582
+ sampleResult && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { role: "status", children: [
1583
+ sampleResult.typeId != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: t("log.resultJudged").replace("{id}", String(sampleResult.typeId)) }),
1584
+ sampleResult.route && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: [sampleResult.route.provider, sampleResult.route.model, sampleResult.route.reasoningEffort].join(" \xB7 ") }),
1585
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: sampleResult.ok ? t("sample.valid") : `${t("sample.failed")} ${sampleResult.reason === "write" ? t("write.invalid") : reasonText(sampleResult.reason)}` })
1586
+ ] })
1587
+ ] })
1580
1588
  ] });
1581
1589
  const log = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-panel", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-judge-section", children: [
1582
1590
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-judge-head", children: [
@@ -1589,13 +1597,11 @@ function JudgeDispatchPanel(props) {
1589
1597
  logCopyResult !== null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: logCopyResult ? "dsh-judge-note-ok" : "dsh-judge-note-bad", role: "status", children: t(logCopyResult ? "log.analysisCopied" : "log.analysisCopyFailed") }),
1590
1598
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-desc", children: t("log.desc") }),
1591
1599
  state.logFailed && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-note-bad", children: t("log.loadFailed") }),
1592
- state.logLoaded && state.log.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-desc", children: t("log.empty") }),
1600
+ state.logLoaded && !state.logFailed && state.log.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-desc", children: t("log.empty") }),
1593
1601
  state.log.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-judge-log", children: [
1594
1602
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-judge-log-row dsh-judge-log-head", children: [
1595
1603
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("log.colResult") }),
1596
1604
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("log.colChoice") }),
1597
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("log.colParent") }),
1598
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("log.colChild") }),
1599
1605
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("log.colTime") }),
1600
1606
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("log.colLatency") })
1601
1607
  ] }),
@@ -1603,7 +1609,7 @@ function JudgeDispatchPanel(props) {
1603
1609
  const result = entry.typeId === null ? {
1604
1610
  text: t("log.resultInherited"),
1605
1611
  hint: entry.reason === void 0 ? "" : reasonText(entry.reason)
1606
- } : { text: t("log.resultJudged").replace("{id}", String(entry.typeId)), hint: "" };
1612
+ } : { text: t("log.resultHistorical").replace("{id}", String(entry.typeId)), hint: entry.typeKey ? t("log.typeKey").replace("{key}", entry.typeKey) : t("log.legacyType") };
1607
1613
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1608
1614
  "button",
1609
1615
  {
@@ -1613,8 +1619,6 @@ function JudgeDispatchPanel(props) {
1613
1619
  children: [
1614
1620
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LogCell, { text: result.text, hint: result.hint }),
1615
1621
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LogCell, { text: describeModel(entry) || "\u2014", hint: describeChoice(entry) }),
1616
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LogCell, { text: entry.parentTitle || "\u2014" }),
1617
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LogCell, { text: entry.childLabel || "\u2014" }),
1618
1622
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: new Date(entry.at).toLocaleTimeString() }),
1619
1623
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("ms").replace("{value}", String(entry.latencyMs)) })
1620
1624
  ]
@@ -1697,10 +1701,10 @@ function JudgeDispatchPanel(props) {
1697
1701
  closeLabel: t("log.promptClose"),
1698
1702
  description: t("log.promptDesc"),
1699
1703
  className: "dsh-judge-modal",
1700
- children: detail !== null && (detail.prompt === "" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-desc", children: t("log.promptEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-prompt", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1704
+ children: detail !== null && (detail.metrics === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-desc", children: t("log.promptEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-judge-prompt", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1701
1705
  import_dsh_client_ui_primitives2.CodeBlock,
1702
1706
  {
1703
- code: detail.prompt,
1707
+ code: JSON.stringify(detail.metrics, null, 2),
1704
1708
  copyLabel: t("preview.copy"),
1705
1709
  copiedLabel: t("preview.copied")
1706
1710
  }
@@ -1722,11 +1726,6 @@ function setupSettingsUi(ctx) {
1722
1726
  remote: createDispatchRemote(),
1723
1727
  // The judgement key is written here; its value never rides a response.
1724
1728
  credentials: ctx.remote?.credentials ?? null,
1725
- // The type list's options come from the host's own official setting; this
1726
- // is the one jump to it the page can make.
1727
- officialSettingsOpener: createOfficialSettingsOpener(
1728
- ctx.get?.("pluginNavigation")
1729
- ),
1730
1729
  t
1731
1730
  });
1732
1731
  } catch (error) {
@@ -1749,7 +1748,7 @@ function setupSettingsUi(ctx) {
1749
1748
  var name = "@lynn123411/dsh-subagent-judge-dispatch";
1750
1749
  var inject = ["slots", "configForms", "remote", "remote.session", "remote.credentials", "locale"];
1751
1750
  function apply2(ctx) {
1752
- injectCardStyles();
1751
+ ctx.effect(injectCardStyles, "dsh-subagent-judge-dispatch: card styles");
1753
1752
  apply(ctx);
1754
1753
  ctx.slots.inject(MODEL_OPTIONS_SLOT, () => ctx.slots.register({
1755
1754
  name: MODEL_OPTIONS_SLOT,