@lynn123411/dsh-subagent-judge-dispatch 0.6.13 → 0.6.14
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 +2 -0
- package/cordis.patch.yml +0 -8
- package/lib/client.js +0 -88
- package/lib/client.js.map +2 -2
- package/lib/index.js +6 -18
- package/lib/index.js.map +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -104,6 +104,8 @@ dsh plugin --profile web add @lynn123411/dsh-subagent-judge-dispatch
|
|
|
104
104
|
|
|
105
105
|
判断日志写在 `~/.dsh/dsh-subagent-judge-dispatch/judgements.json`(跟随 `DSH_HOME`)。多个进程在同一个文件锁内读取并合并最新记录,再原子替换文件。
|
|
106
106
|
|
|
107
|
+
子代理恢复时,如果自己的会话里已有模型选择或请求记录,就沿用现有模型。这种恢复不会新增指派日志。新派工遇到已指定或已使用的模型时,日志仍会写明跳过原因。
|
|
108
|
+
|
|
107
109
|
日志可以按未判断、保留原模型和已应用规则筛选。结果、原因、模型、提供方、推理等级、时间和耗时各占一列,窄屏会换行并补上字段名。详情保留判断模型、当时选中的类型及其标识、各步耗时和已保存的正文。开启正文记录后,新日志最多保存 4 KiB 正文和 1 KiB 类型描述。正文和日志开关显示宿主已保存的状态,保存失败可在日志页重试。写入会保留最新的至多 200 条、总计至多 512 KiB。页面显示最近 10 条,读取失败时保留上一次的列表。「复制分析提示词」可复制一段用于分析磁盘上最近 100 条记录的提示词。
|
|
108
110
|
|
|
109
111
|
### 导入导出
|
package/cordis.patch.yml
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
# @lynn123411/dsh-subagent-judge-dispatch bundle patch
|
|
2
|
-
# 声明在 package.json 的 dsh.bundle.patch,`dsh plugin --profile web add` 后自动并入 profile 层栈。
|
|
3
|
-
#
|
|
4
|
-
# 这一条 insert 行同时承载两个半边(见 docs/rules/client-wiring.md):
|
|
5
|
-
# - 宿主半边:在那条行下注册插件本体(上面 src/index.ts 的 apply)。行在 root 层,
|
|
6
|
-
# 所以它落进全局层;要收窄到某个 preset,就在 preset 的 config.plugins 里另注册一行。
|
|
7
|
-
# - 浏览器半边:这条行是 root loader entry,dsh-client-modules 只对 root loader 的
|
|
8
|
-
# enabled entry 依据 dsh.client 声明服务浏览器半边(lib/client.js)。
|
|
9
1
|
- insert:
|
|
10
2
|
- id: dsh-subagent-judge-dispatch
|
|
11
3
|
name: '@lynn123411/dsh-subagent-judge-dispatch'
|
package/lib/client.js
CHANGED
|
@@ -1046,8 +1046,6 @@ function rowHints(rows, index, t) {
|
|
|
1046
1046
|
}
|
|
1047
1047
|
function exportRowsJson(rows) {
|
|
1048
1048
|
return JSON.stringify(
|
|
1049
|
-
// 空白行(读者按了「加一行」还没填)不写进 JSON:它没有内容可带走,写出去
|
|
1050
|
-
// 还会让这份文本自己读不回来。
|
|
1051
1049
|
rows.filter((row) => !isBlankRow(row)).map((row) => ({
|
|
1052
1050
|
description: row.description,
|
|
1053
1051
|
provider: row.provider,
|
|
@@ -1161,7 +1159,6 @@ var DispatchCardStore = class {
|
|
|
1161
1159
|
logLoading: false
|
|
1162
1160
|
};
|
|
1163
1161
|
listeners = /* @__PURE__ */ new Set();
|
|
1164
|
-
/** One commit at a time: a queued write reads the drafts as they stand when it runs. */
|
|
1165
1162
|
queue = Promise.resolve();
|
|
1166
1163
|
pendingOps = [];
|
|
1167
1164
|
form = null;
|
|
@@ -1176,7 +1173,6 @@ var DispatchCardStore = class {
|
|
|
1176
1173
|
offForm = null;
|
|
1177
1174
|
offAllowed = null;
|
|
1178
1175
|
translate = (key) => key;
|
|
1179
|
-
/** Bind the Host services; re-binding detaches the previous subscriptions. */
|
|
1180
1176
|
attach(options) {
|
|
1181
1177
|
this.offForm?.();
|
|
1182
1178
|
this.offAllowed?.();
|
|
@@ -1211,7 +1207,6 @@ var DispatchCardStore = class {
|
|
|
1211
1207
|
this.listeners.delete(listener);
|
|
1212
1208
|
};
|
|
1213
1209
|
}
|
|
1214
|
-
/** Read the Host's allowlist and the adapter catalogue into the model options. */
|
|
1215
1210
|
async loadModels() {
|
|
1216
1211
|
const revision = ++this.modelLoadRevision;
|
|
1217
1212
|
const snapshot = this.allowedForm?.getSnapshot();
|
|
@@ -1237,7 +1232,6 @@ var DispatchCardStore = class {
|
|
|
1237
1232
|
this.state = { ...this.state, models: buildModelOptions(allowed, groups), catalogRead };
|
|
1238
1233
|
this.notify();
|
|
1239
1234
|
}
|
|
1240
|
-
/** Read the status for the committed address; discard replies for an older address. */
|
|
1241
1235
|
async refreshKeyStatus() {
|
|
1242
1236
|
const revision = ++this.keyStatusRevision;
|
|
1243
1237
|
const endpoint = this.state.committed.endpointUrl;
|
|
@@ -1259,15 +1253,6 @@ var DispatchCardStore = class {
|
|
|
1259
1253
|
this.state = { ...this.state, key: { ...this.state.key, configured } };
|
|
1260
1254
|
this.notify();
|
|
1261
1255
|
}
|
|
1262
|
-
/**
|
|
1263
|
-
* Map the Host's resolved section into committed state and re-seed the drafts.
|
|
1264
|
-
*
|
|
1265
|
-
* Drafts are held FIELD BY FIELD, against the value this page last saw
|
|
1266
|
-
* committed. Holding a whole section instead would make a save write back a
|
|
1267
|
-
* field the reader never touched — reverting a change another page made to it —
|
|
1268
|
-
* while holding nothing would discard input mid-typing every time the Host
|
|
1269
|
-
* publishes.
|
|
1270
|
-
*/
|
|
1271
1256
|
deriveCommitted(notify = true) {
|
|
1272
1257
|
const snapshot = this.form?.getSnapshot();
|
|
1273
1258
|
const value = snapshot?.value;
|
|
@@ -1306,34 +1291,21 @@ var DispatchCardStore = class {
|
|
|
1306
1291
|
if (notify) this.notify();
|
|
1307
1292
|
if (keyOriginChanged) void this.refreshKeyStatus();
|
|
1308
1293
|
}
|
|
1309
|
-
/**
|
|
1310
|
-
* Stage one edit.
|
|
1311
|
-
*
|
|
1312
|
-
* A failure stays on screen until a write lands: the value it complains about
|
|
1313
|
-
* has not reached the document yet, so clearing it on the first keystroke would
|
|
1314
|
-
* say "fixed" while the drafts are still only on this page.
|
|
1315
|
-
*
|
|
1316
|
-
* @param patch - the state fields this edit changes.
|
|
1317
|
-
*/
|
|
1318
1294
|
stage(patch) {
|
|
1319
1295
|
this.state = { ...this.state, ...patch };
|
|
1320
1296
|
this.notify();
|
|
1321
1297
|
}
|
|
1322
|
-
/** Stage one top-level field; its control commits when focus leaves it. */
|
|
1323
1298
|
field(key, value) {
|
|
1324
1299
|
this.stage(key === "endpointUrl" ? { endpointUrl: value } : { judgeModel: value });
|
|
1325
1300
|
}
|
|
1326
|
-
/** Flip one switch and write it: a switch is one complete decision. */
|
|
1327
1301
|
toggle(key, value) {
|
|
1328
1302
|
this.stage({ [key]: value });
|
|
1329
1303
|
void this.commit(key === "enabled" ? "judge" : key);
|
|
1330
1304
|
}
|
|
1331
|
-
/** Stage the judgement key; its control commits when focus leaves it or on Enter. */
|
|
1332
1305
|
key(text) {
|
|
1333
1306
|
this.keyEndpoint = this.state.endpointUrl;
|
|
1334
1307
|
this.stage({ key: { ...this.state.key, text, failed: false, error: "" } });
|
|
1335
1308
|
}
|
|
1336
|
-
/** Stage one cell of one row; a text cell commits on blur, a menu choice at once. */
|
|
1337
1309
|
cell(index, key, value) {
|
|
1338
1310
|
if (key === "effort") {
|
|
1339
1311
|
this.chooseEffort(index, value);
|
|
@@ -1342,12 +1314,10 @@ var DispatchCardStore = class {
|
|
|
1342
1314
|
const rows = this.state.rows.map((row, at) => at === index ? { ...row, [key]: value } : row);
|
|
1343
1315
|
this.stage({ rows: key === "model" ? this.reconcileEffort(rows, index) : rows });
|
|
1344
1316
|
}
|
|
1345
|
-
/** Stage an explicit effort id, an empty draft, or the model default (undefined). */
|
|
1346
1317
|
chooseEffort(index, effort) {
|
|
1347
1318
|
const rows = this.state.rows.map((row, at) => at === index ? readRow({ ...row, effort: effort ?? "", useDefaultEffort: effort === void 0 }) : row);
|
|
1348
1319
|
this.stage({ rows });
|
|
1349
1320
|
}
|
|
1350
|
-
/** Drop an effort the freshly selected model does not declare. */
|
|
1351
1321
|
reconcileEffort(rows, index) {
|
|
1352
1322
|
const row = rows[index];
|
|
1353
1323
|
if (row === void 0) return rows;
|
|
@@ -1357,34 +1327,14 @@ var DispatchCardStore = class {
|
|
|
1357
1327
|
}
|
|
1358
1328
|
return rows;
|
|
1359
1329
|
}
|
|
1360
|
-
/** Append an empty row and write it: a new row is a decision like any other. */
|
|
1361
1330
|
addRow() {
|
|
1362
1331
|
this.stage({ rows: [...this.state.rows, { description: "", provider: "", model: "", effort: "", enabled: true }] });
|
|
1363
1332
|
void this.commit("rows");
|
|
1364
1333
|
}
|
|
1365
|
-
/**
|
|
1366
|
-
* Replace the list with an imported one and write it.
|
|
1367
|
-
*
|
|
1368
|
-
* The import dialog's own button is the confirmation, so the list it produces
|
|
1369
|
-
* is written at once rather than left as a draft the reader has to commit a
|
|
1370
|
-
* second time.
|
|
1371
|
-
*
|
|
1372
|
-
* @param rows - the rows read from the pasted JSON.
|
|
1373
|
-
* @param preserveUnlisted - keep existing rules omitted from the import.
|
|
1374
|
-
*/
|
|
1375
1334
|
replaceRows(rows, preserveUnlisted = false) {
|
|
1376
1335
|
this.stage({ rows: planRowsImport(this.state.rows, rows, preserveUnlisted).rows });
|
|
1377
1336
|
void this.commit("rows");
|
|
1378
1337
|
}
|
|
1379
|
-
/**
|
|
1380
|
-
* Replace the judgement service's connection settings with an imported set and
|
|
1381
|
-
* write them.
|
|
1382
|
-
*
|
|
1383
|
-
* The import dialog's own button is the confirmation, so the settings it
|
|
1384
|
-
* produces are written at once rather than left as a draft.
|
|
1385
|
-
*
|
|
1386
|
-
* @param draft - the settings read from the pasted JSON.
|
|
1387
|
-
*/
|
|
1388
1338
|
replaceJudgeConfig(draft) {
|
|
1389
1339
|
this.stage({
|
|
1390
1340
|
endpointUrl: draft.endpointUrl,
|
|
@@ -1404,27 +1354,10 @@ var DispatchCardStore = class {
|
|
|
1404
1354
|
this.stage({ rows });
|
|
1405
1355
|
void this.commit("rows");
|
|
1406
1356
|
}
|
|
1407
|
-
/** Delete one row and write the rest; the remaining rows renumber themselves. */
|
|
1408
1357
|
removeRow(index) {
|
|
1409
1358
|
this.stage({ rows: this.state.rows.filter((_row, at) => at !== index) });
|
|
1410
1359
|
void this.commit("rows");
|
|
1411
1360
|
}
|
|
1412
|
-
/**
|
|
1413
|
-
* Write one section's staged edits as one batch.
|
|
1414
|
-
*
|
|
1415
|
-
* The card queues commits so each one reads the latest drafts and committed
|
|
1416
|
-
* values after the previous commit settles. The shared form orders these
|
|
1417
|
-
* writes with the session menu's writes and supplies their revision fences.
|
|
1418
|
-
*
|
|
1419
|
-
* The judgement section also writes a typed key, so leaving the key field and
|
|
1420
|
-
* leaving the endpoint field are one kind of gesture. The type rows are written
|
|
1421
|
-
* whole rather than diffed: the array is one value, and a positional number is
|
|
1422
|
-
* derived from it, so a partial write could momentarily renumber the list under
|
|
1423
|
-
* a reader mid-write.
|
|
1424
|
-
*
|
|
1425
|
-
* @param section - which section's drafts to write.
|
|
1426
|
-
* @returns settlement after the write, whether it landed or not.
|
|
1427
|
-
*/
|
|
1428
1361
|
commit(section) {
|
|
1429
1362
|
this.queue = this.queue.then(() => this.write(section)).catch(() => {
|
|
1430
1363
|
this.pendingOps = [];
|
|
@@ -1436,15 +1369,10 @@ var DispatchCardStore = class {
|
|
|
1436
1369
|
});
|
|
1437
1370
|
return this.queue;
|
|
1438
1371
|
}
|
|
1439
|
-
/** Queue text drafts before leaving. Logging switches already queue their own writes. */
|
|
1440
1372
|
flush() {
|
|
1441
1373
|
void this.commit("judge");
|
|
1442
1374
|
return this.commit("rows");
|
|
1443
1375
|
}
|
|
1444
|
-
/**
|
|
1445
|
-
* The write itself, run from the queue.
|
|
1446
|
-
* @param section - which section's drafts to write.
|
|
1447
|
-
*/
|
|
1448
1376
|
async write(section) {
|
|
1449
1377
|
const form = this.form;
|
|
1450
1378
|
if (form === null || !this.state.writable) return;
|
|
@@ -1508,17 +1436,6 @@ var DispatchCardStore = class {
|
|
|
1508
1436
|
this.state = { ...this.state, writing: "", writeErrors };
|
|
1509
1437
|
this.notify();
|
|
1510
1438
|
}
|
|
1511
|
-
/**
|
|
1512
|
-
* Write one judgement key through the credentials service.
|
|
1513
|
-
*
|
|
1514
|
-
* The service resolves with `{ ok: false }` rather than rejecting when it
|
|
1515
|
-
* refuses a write, so that result decides the outcome. The key value is handed
|
|
1516
|
-
* straight to the service and is never copied into the page state.
|
|
1517
|
-
*
|
|
1518
|
-
* @param endpoint - the address in the form when the key was typed.
|
|
1519
|
-
* @param rawKey - the staged, still non-empty key text.
|
|
1520
|
-
* @returns whether the write landed, and the message when it did not.
|
|
1521
|
-
*/
|
|
1522
1439
|
async writeKey(endpoint, rawKey) {
|
|
1523
1440
|
const credentials = this.credentials;
|
|
1524
1441
|
this.state = { ...this.state, key: { ...this.state.key, writing: true } };
|
|
@@ -1552,7 +1469,6 @@ var DispatchCardStore = class {
|
|
|
1552
1469
|
return { ok: false, error: message };
|
|
1553
1470
|
}
|
|
1554
1471
|
}
|
|
1555
|
-
/** Read the runtime log from the Host. */
|
|
1556
1472
|
async refreshLog() {
|
|
1557
1473
|
if (this.state.logLoading) return;
|
|
1558
1474
|
const remote = this.remote;
|
|
@@ -1574,7 +1490,6 @@ var DispatchCardStore = class {
|
|
|
1574
1490
|
}
|
|
1575
1491
|
this.notify();
|
|
1576
1492
|
}
|
|
1577
|
-
/** Read the exact prompt a judgement would send. */
|
|
1578
1493
|
async preview(task = "", label = "") {
|
|
1579
1494
|
try {
|
|
1580
1495
|
return await this.remote?.preview?.(task, label) ?? null;
|
|
@@ -1582,7 +1497,6 @@ var DispatchCardStore = class {
|
|
|
1582
1497
|
return null;
|
|
1583
1498
|
}
|
|
1584
1499
|
}
|
|
1585
|
-
/** Test the judge endpoint against the committed settings. */
|
|
1586
1500
|
async probe() {
|
|
1587
1501
|
if (this.remote === null) return { ok: false, latencyMs: 0, reason: "unreachable" };
|
|
1588
1502
|
try {
|
|
@@ -1598,14 +1512,12 @@ var DispatchCardStore = class {
|
|
|
1598
1512
|
return { ok: false, reason: "unreachable" };
|
|
1599
1513
|
}
|
|
1600
1514
|
}
|
|
1601
|
-
/** The declared effort ids, or undefined when this model's metadata is unavailable. */
|
|
1602
1515
|
effortsFor(row) {
|
|
1603
1516
|
const option = this.state.models.find(
|
|
1604
1517
|
(candidate) => candidate.provider === row.provider && candidate.model === row.model
|
|
1605
1518
|
);
|
|
1606
1519
|
return option?.catalogued === true ? option.efforts : void 0;
|
|
1607
1520
|
}
|
|
1608
|
-
/** Whether one row will be offered to the judge (the server's own rule). */
|
|
1609
1521
|
rowUsable(row) {
|
|
1610
1522
|
return isOfferedRow(row);
|
|
1611
1523
|
}
|