@michengai/dsh-btw 1.0.8 → 1.0.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/CHANGELOG.md +6 -0
- package/CHANGELOG.zh-CN.md +6 -0
- package/lib/index.js +43 -8
- package/lib/types/server/tool-guard.d.ts +9 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.9] - 2026-10-26
|
|
4
|
+
|
|
5
|
+
- Deterministically block tool execution inside `/btw` bubbles: pre-register the child session id before the side question starts, so interception no longer depends on the host announcing the child agent in time (#21).
|
|
6
|
+
- Fall back to the child session's own descriptor when the host subagent projection carries no label, closing the remaining silent-allow path (#21).
|
|
7
|
+
- Harden the guard: an unreadable session snapshot now falls back to the previous allow-on-unknown behavior instead of surfacing an error in the tool call, and the pre-registered id is released as soon as the side question settles.
|
|
8
|
+
|
|
3
9
|
## [1.0.8] - 2026-10-24
|
|
4
10
|
|
|
5
11
|
- Upgrade build-time development dependencies: Bump all `@deepseek-ai/dsh-*` devDependencies to latest `0.2.1-rc.3` to keep type declarations and build toolchains strictly aligned.
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## [1.0.9] - 2026-10-26
|
|
4
|
+
|
|
5
|
+
- 彻底杜绝 `/btw` 气泡内工具调用穿透:在旁问启动前预先登记子会话 ID,拦截不再依赖宿主及时宣告子代理创建,气泡内执行 `ops_bash` 等工具必定被拒 (#21)。
|
|
6
|
+
- 宿主子代理投影未带 label 时回退读取子会话自身的 descriptor,堵上最后一处静默放行路径 (#21)。
|
|
7
|
+
- 加固拦截器:会话快照读取失败时回落到原有的「认不出即放行」语义,不再把异常冒进工具执行链;旁问一结束立即释放预登记 ID。
|
|
8
|
+
|
|
3
9
|
## [1.0.8] - 2026-10-24
|
|
4
10
|
|
|
5
11
|
- 升级编译期开发依赖:将全部 `@deepseek-ai/dsh-*` 开发依赖从 `0.2.1-rc.2` 同步对齐至最新的 `0.2.1-rc.3`,保持类型定义与构建环境完全一致。
|
package/lib/index.js
CHANGED
|
@@ -410,11 +410,15 @@ function lastDescriptorLabel(session, identityOf) {
|
|
|
410
410
|
if (!session) return void 0;
|
|
411
411
|
if (identityOf) {
|
|
412
412
|
const identity = identityOf(session);
|
|
413
|
-
|
|
413
|
+
if (typeof identity?.label === "string") return identity.label;
|
|
414
414
|
}
|
|
415
415
|
const events = session.snapshotEvents;
|
|
416
416
|
if (typeof events !== "function") return void 0;
|
|
417
|
-
|
|
417
|
+
try {
|
|
418
|
+
return descriptorLabel(events().findLast((item) => item.type === "subagent/descriptor")?.data);
|
|
419
|
+
} catch {
|
|
420
|
+
return void 0;
|
|
421
|
+
}
|
|
418
422
|
}
|
|
419
423
|
function identityOfFromContext(ctx) {
|
|
420
424
|
try {
|
|
@@ -434,20 +438,44 @@ function identityOfFromContext(ctx) {
|
|
|
434
438
|
}
|
|
435
439
|
function createAnswerOnlyGuard(labels, identityOf) {
|
|
436
440
|
const owned = /* @__PURE__ */ new WeakSet();
|
|
441
|
+
const ownedIds = /* @__PURE__ */ new Set();
|
|
437
442
|
const claim = (value) => {
|
|
438
|
-
if (value) owned.add(value);
|
|
443
|
+
if (value && typeof value === "object") owned.add(value);
|
|
444
|
+
};
|
|
445
|
+
const claimAgent = (agent) => {
|
|
446
|
+
if (!agent) return;
|
|
447
|
+
claim(agent);
|
|
448
|
+
if (typeof agent === "object" && "session" in agent) {
|
|
449
|
+
claim(agent.session);
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
const isOwnedId = (agent) => {
|
|
453
|
+
if (ownedIds.size === 0) return false;
|
|
454
|
+
if (typeof agent.id === "string" && ownedIds.has(agent.id)) return true;
|
|
455
|
+
const session = agent.session;
|
|
456
|
+
if (session && typeof session === "object") {
|
|
457
|
+
if (typeof session.id === "string" && ownedIds.has(session.id)) return true;
|
|
458
|
+
if (typeof session.header?.id === "string" && ownedIds.has(session.header.id)) return true;
|
|
459
|
+
}
|
|
460
|
+
return false;
|
|
439
461
|
};
|
|
440
462
|
const guard = ({ agent }) => {
|
|
441
463
|
if (!agent) return void 0;
|
|
464
|
+
if (isOwnedId(agent)) return DENY;
|
|
442
465
|
if (owned.has(agent) || agent.session !== void 0 && owned.has(agent.session)) return DENY;
|
|
443
466
|
const label = lastDescriptorLabel(agent.session, identityOf);
|
|
444
467
|
if (!label || !labels.has(label)) return void 0;
|
|
445
|
-
|
|
446
|
-
claim(agent.session);
|
|
468
|
+
claimAgent(agent);
|
|
447
469
|
return DENY;
|
|
448
470
|
};
|
|
449
471
|
guard.own = (agent) => {
|
|
450
|
-
|
|
472
|
+
claimAgent(agent);
|
|
473
|
+
};
|
|
474
|
+
guard.ownId = (id) => {
|
|
475
|
+
ownedIds.add(id);
|
|
476
|
+
return () => {
|
|
477
|
+
ownedIds.delete(id);
|
|
478
|
+
};
|
|
451
479
|
};
|
|
452
480
|
guard.recognize = (session, event) => {
|
|
453
481
|
if (event.type !== "subagent/descriptor") return;
|
|
@@ -527,6 +555,7 @@ ${request.question}`;
|
|
|
527
555
|
const maxTokens = typeof parentMaxTokens === "number" && parentMaxTokens > 0 ? Math.min(SIDE_MAX_OUTPUT_TOKENS, parentMaxTokens) : SIDE_MAX_OUTPUT_TOKENS;
|
|
528
556
|
if (typeof subagents.startActivation === "function") {
|
|
529
557
|
const childId = SessionId(globalThis.crypto.randomUUID());
|
|
558
|
+
const releaseChildId = protection.ownId(childId);
|
|
530
559
|
let childAgent;
|
|
531
560
|
try {
|
|
532
561
|
const stopCreated = ctx.on("agent/created", ({ agent }) => {
|
|
@@ -554,18 +583,24 @@ ${request.question}`;
|
|
|
554
583
|
} finally {
|
|
555
584
|
stopCreated();
|
|
556
585
|
}
|
|
586
|
+
void activation.result.then(() => releaseChildId(), () => releaseChildId());
|
|
557
587
|
return {
|
|
558
588
|
result: activation.result,
|
|
559
589
|
dispose: async () => {
|
|
560
590
|
try {
|
|
561
591
|
await activation.dispose();
|
|
562
592
|
} finally {
|
|
563
|
-
|
|
564
|
-
|
|
593
|
+
try {
|
|
594
|
+
await releaseChild(childAgent);
|
|
595
|
+
} finally {
|
|
596
|
+
releaseChildId();
|
|
597
|
+
releaseLabel(label);
|
|
598
|
+
}
|
|
565
599
|
}
|
|
566
600
|
}
|
|
567
601
|
};
|
|
568
602
|
} catch (error) {
|
|
603
|
+
releaseChildId();
|
|
569
604
|
releaseLabel(label);
|
|
570
605
|
throw error;
|
|
571
606
|
}
|
|
@@ -6,7 +6,14 @@ export interface SessionIdentityHint {
|
|
|
6
6
|
snapshotEvents?(): readonly SessionEventLike[];
|
|
7
7
|
}
|
|
8
8
|
export interface AgentIdentity {
|
|
9
|
-
|
|
9
|
+
id?: string;
|
|
10
|
+
session?: {
|
|
11
|
+
id?: string;
|
|
12
|
+
header?: {
|
|
13
|
+
id?: string;
|
|
14
|
+
};
|
|
15
|
+
snapshotEvents?(): readonly SessionEventLike[];
|
|
16
|
+
} | object;
|
|
10
17
|
}
|
|
11
18
|
export interface SubagentIdentityHint {
|
|
12
19
|
readonly label?: string;
|
|
@@ -17,6 +24,7 @@ export interface AnswerOnlyGuard {
|
|
|
17
24
|
agent?: AgentIdentity;
|
|
18
25
|
}): string | undefined;
|
|
19
26
|
own(agent: object): void;
|
|
27
|
+
ownId(id: string): () => void;
|
|
20
28
|
recognize(session: object, event: SessionEventLike): void;
|
|
21
29
|
}
|
|
22
30
|
/** 官方替换同步事件扫描:ctx.sessionProjections.snapshot(session, ['subagent']).values.subagent */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michengai/dsh-btw",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "DSH 一次性只读旁问插件:基于当前上下文回答,独立气泡,不执行工具 · One-shot read-only side-ask plugin: answers from current context in an independent bubble, no tool execution",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|