@dsh-workbench/shared 1.5.1 → 1.5.2-alpha.0

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.
@@ -36,6 +36,8 @@ export interface ApprovalCall {
36
36
  * (连问都不该问,`reason` 原样交给 agent)、`ask` 要用户点头(`headline` 是具体标题;没有它时
37
37
  * `question` 接在明细后,`fallback` 是没明细时的整句;`noteInDetail` 为真表示模块把 agent 的附注
38
38
  * 画在自己的详情座里,标题只留动作、不再追加)。
39
+ * `preflight` 是在显示审批之前先执行的机器检查:返回非空字符串表示这次执行不了,原样交给 agent、
40
+ * 用户不会被询问;返回空表示照常询问;抛出同样转成 `deny`(不会静默放行)。
39
41
  */
40
42
  export type ApprovalVerdict = {
41
43
  readonly kind: 'read';
@@ -51,6 +53,7 @@ export type ApprovalVerdict = {
51
53
  readonly question: ApprovalDetail;
52
54
  readonly fallback: ApprovalDetail;
53
55
  readonly noteInDetail?: boolean;
56
+ readonly preflight?: (() => Promise<string | undefined>) | undefined;
54
57
  };
55
58
  export type ApprovalPolicy = (call: ApprovalCall) => ApprovalVerdict | undefined;
56
59
  /**
@@ -75,6 +75,17 @@ export async function approvalFor(call, context = {}) {
75
75
  '下一步:在模块的 needsApproval 中补一条审批(包含「这次会发生什么」)。',
76
76
  };
77
77
  }
78
+ if (verdict.preflight !== undefined) {
79
+ let blocked;
80
+ try {
81
+ blocked = await verdict.preflight();
82
+ }
83
+ catch (error) {
84
+ return { kind: 'deny', reason: `审批前的检查没有完成,已拒绝这次调用:${messageOf(error)}` };
85
+ }
86
+ if (blocked !== undefined && blocked.trim() !== '')
87
+ return { kind: 'deny', reason: blocked.trim() };
88
+ }
78
89
  let facts;
79
90
  try {
80
91
  facts = await context.detailOf?.(call);
@@ -1,7 +1,7 @@
1
1
  import type { SlotRegistry } from '@deepseek-ai/dsh-client-ui-renderer/client';
2
2
  import type { PropsRenderSlots, SlotLabel } from '@deepseek-ai/dsh-client-ui-slots';
3
3
  import type { SessionInput as OfficialSessionInput } from '@deepseek-ai/dsh-client-ui-conversation/client';
4
- import type { SessionStatus as OfficialSessionStatus } from '@deepseek-ai/dsh-client-ui-session/client';
4
+ import type { SessionStatus as OfficialSessionStatus } from '@deepseek-ai/dsh-client-ui-session-status/client';
5
5
  import type { SessionSummary as OfficialSessionSummary } from '@deepseek-ai/dsh-api-session-controller/client';
6
6
  import type { WorkspaceSnapshot as OfficialWorkspaceSnapshot, WorkspaceView as OfficialWorkspaceView } from '@deepseek-ai/dsh-api-workspace-controller/client';
7
7
  import type { SubagentCatalogEntry as OfficialSubagentCatalogEntry } from '@deepseek-ai/dsh-subagent';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-workbench/shared",
3
- "version": "1.5.1",
3
+ "version": "1.5.2-alpha.0",
4
4
  "description": "工作台与模块共享的纯代码与契约类型:类型、纯逻辑、哑组件、平台解析。宿主侧的东西从 /host 进(不影响浏览器产物)。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,53 +30,57 @@
30
30
  "access": "public"
31
31
  },
32
32
  "peerDependencies": {
33
- "react": "*",
34
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.2"
33
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.3-alpha.2",
34
+ "react": "*"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@arch-guard/core": "^0.12.0",
38
- "@deepseek-ai/dsh-agent": "^0.2.2-rc.2",
39
- "@deepseek-ai/dsh-agent-preset": "^0.2.2-rc.2",
40
- "@deepseek-ai/dsh-agent-preset-registry": "^0.2.2-rc.2",
41
- "@deepseek-ai/dsh-api-gateway": "^0.2.2-rc.2",
42
- "@deepseek-ai/dsh-api-remote-access": "^0.2.2-rc.2",
43
- "@deepseek-ai/dsh-api-remotes": "^0.2.2-rc.2",
44
- "@deepseek-ai/dsh-api-session-controller": "^0.2.2-rc.2",
45
- "@deepseek-ai/dsh-api-workspace-controller": "^0.2.2-rc.2",
46
- "@deepseek-ai/dsh-app-boot": "^0.2.2-rc.2",
47
- "@deepseek-ai/dsh-client-locale": "^0.2.2-rc.2",
48
- "@deepseek-ai/dsh-client-shortcuts": "^0.2.2-rc.2",
49
- "@deepseek-ai/dsh-client-store": "^0.2.2-rc.2",
50
- "@deepseek-ai/dsh-client-ui-commands": "^0.2.2-rc.2",
51
- "@deepseek-ai/dsh-client-ui-context-menu": "^0.2.2-rc.2",
52
- "@deepseek-ai/dsh-client-ui-conversation": "^0.2.2-rc.2",
53
- "@deepseek-ai/dsh-client-ui-input-trigger": "^0.2.2-rc.2",
54
- "@deepseek-ai/dsh-client-ui-layout": "^0.2.2-rc.2",
55
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.2",
56
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.2",
57
- "@deepseek-ai/dsh-client-ui-session": "^0.2.2-rc.2",
58
- "@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.2",
59
- "@deepseek-ai/dsh-client-ui-sidebar-right": "^0.2.2-rc.2",
60
- "@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.2",
61
- "@deepseek-ai/dsh-client-ui-workspace": "^0.2.2-rc.2",
62
- "@deepseek-ai/dsh-hmr": "^0.2.2-rc.2",
63
- "@deepseek-ai/dsh-home-paths": "^0.2.2-rc.2",
64
- "@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.2",
65
- "@deepseek-ai/dsh-llm": "^0.2.2-rc.2",
66
- "@deepseek-ai/dsh-mcp-client": "^0.2.2-rc.2",
67
- "@deepseek-ai/dsh-package-manifest": "^0.2.2-rc.2",
68
- "@deepseek-ai/dsh-plugin-manager": "^0.2.2-rc.2",
69
- "@deepseek-ai/dsh-sandbox": "^0.2.2-rc.2",
70
- "@deepseek-ai/dsh-sandbox-policy": "^0.2.2-rc.2",
71
- "@deepseek-ai/dsh-session": "^0.2.2-rc.2",
72
- "@deepseek-ai/dsh-session-projection": "^0.2.2-rc.2",
73
- "@deepseek-ai/dsh-shell": "^0.2.2-rc.2",
74
- "@deepseek-ai/dsh-subagent": "^0.2.2-rc.2",
75
- "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.2",
76
- "@deepseek-ai/dsh-tools": "^0.2.2-rc.2",
77
- "@deepseek-ai/dsh-typert-protocol": "^0.2.2-rc.2",
78
- "@deepseek-ai/dsh-user-approval": "^0.2.2-rc.2",
79
- "@deepseek-ai/dsh-workspace": "^0.2.2-rc.2",
38
+ "@deepseek-ai/cordis-plugin-group": "1.2.0-alpha.1",
39
+ "@deepseek-ai/cordis-plugin-include": "1.2.0-alpha.1",
40
+ "@deepseek-ai/cordis-plugin-timer": "1.3.0-alpha.1",
41
+ "@deepseek-ai/dsh-agent": "^0.2.3-alpha.2",
42
+ "@deepseek-ai/dsh-agent-preset": "^0.2.3-alpha.2",
43
+ "@deepseek-ai/dsh-agent-preset-registry": "^0.2.3-alpha.2",
44
+ "@deepseek-ai/dsh-api-gateway": "^0.2.3-alpha.2",
45
+ "@deepseek-ai/dsh-api-remote-access": "^0.2.3-alpha.2",
46
+ "@deepseek-ai/dsh-api-remotes": "^0.2.3-alpha.2",
47
+ "@deepseek-ai/dsh-api-session-controller": "^0.2.3-alpha.2",
48
+ "@deepseek-ai/dsh-api-workspace-controller": "^0.2.3-alpha.2",
49
+ "@deepseek-ai/dsh-app-boot": "^0.2.3-alpha.2",
50
+ "@deepseek-ai/dsh-client-locale": "^0.2.3-alpha.2",
51
+ "@deepseek-ai/dsh-client-shortcuts": "^0.2.3-alpha.2",
52
+ "@deepseek-ai/dsh-client-store": "^0.2.3-alpha.2",
53
+ "@deepseek-ai/dsh-client-ui-commands": "^0.2.3-alpha.2",
54
+ "@deepseek-ai/dsh-client-ui-context-menu": "^0.2.3-alpha.2",
55
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.2.3-alpha.2",
56
+ "@deepseek-ai/dsh-client-ui-input-trigger": "^0.2.3-alpha.2",
57
+ "@deepseek-ai/dsh-client-ui-layout": "^0.2.3-alpha.2",
58
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.3-alpha.2",
59
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.3-alpha.2",
60
+ "@deepseek-ai/dsh-client-ui-session": "^0.2.3-alpha.2",
61
+ "@deepseek-ai/dsh-client-ui-session-status": "^0.2.3-alpha.2",
62
+ "@deepseek-ai/dsh-client-ui-settings": "^0.2.3-alpha.2",
63
+ "@deepseek-ai/dsh-client-ui-sidebar-right": "^0.2.3-alpha.2",
64
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.3-alpha.2",
65
+ "@deepseek-ai/dsh-client-ui-workspace": "^0.2.3-alpha.2",
66
+ "@deepseek-ai/dsh-hmr": "^0.2.3-alpha.2",
67
+ "@deepseek-ai/dsh-home-paths": "^0.2.3-alpha.2",
68
+ "@deepseek-ai/dsh-host-webserver": "^0.2.3-alpha.2",
69
+ "@deepseek-ai/dsh-llm": "^0.2.3-alpha.2",
70
+ "@deepseek-ai/dsh-mcp-client": "^0.2.3-alpha.2",
71
+ "@deepseek-ai/dsh-package-manifest": "^0.2.3-alpha.2",
72
+ "@deepseek-ai/dsh-plugin-manager": "^0.2.3-alpha.2",
73
+ "@deepseek-ai/dsh-sandbox": "^0.2.3-alpha.2",
74
+ "@deepseek-ai/dsh-sandbox-policy": "^0.2.3-alpha.2",
75
+ "@deepseek-ai/dsh-session": "^0.2.3-alpha.2",
76
+ "@deepseek-ai/dsh-session-projection": "^0.2.3-alpha.2",
77
+ "@deepseek-ai/dsh-shell": "^0.2.3-alpha.2",
78
+ "@deepseek-ai/dsh-subagent": "^0.2.3-alpha.2",
79
+ "@deepseek-ai/dsh-system-prompt": "^0.2.3-alpha.2",
80
+ "@deepseek-ai/dsh-tools": "^0.2.3-alpha.2",
81
+ "@deepseek-ai/dsh-typert-protocol": "^0.2.3-alpha.2",
82
+ "@deepseek-ai/dsh-user-approval": "^0.2.3-alpha.2",
83
+ "@deepseek-ai/dsh-workspace": "^0.2.3-alpha.2",
80
84
  "@types/node": "^24.19.0",
81
85
  "@types/proper-lockfile": "^4.1.4",
82
86
  "@types/react": "^19.3.0",
@@ -88,8 +92,8 @@
88
92
  "vitest": "^5.0.2"
89
93
  },
90
94
  "dependencies": {
91
- "@deepseek-ai/cordis": "4.1.0",
92
- "@deepseek-ai/cordis-plugin-loader": "1.1.0",
95
+ "@deepseek-ai/cordis": "4.2.0-alpha.1",
96
+ "@deepseek-ai/cordis-plugin-loader": "1.2.0-alpha.1",
93
97
  "dayjs": "^1.11.23",
94
98
  "execa": "^10.2.0",
95
99
  "proper-lockfile": "^4.1.2",
@@ -82,6 +82,8 @@ export interface ApprovalCall {
82
82
  * (连问都不该问,`reason` 原样交给 agent)、`ask` 要用户点头(`headline` 是具体标题;没有它时
83
83
  * `question` 接在明细后,`fallback` 是没明细时的整句;`noteInDetail` 为真表示模块把 agent 的附注
84
84
  * 画在自己的详情座里,标题只留动作、不再追加)。
85
+ * `preflight` 是在显示审批之前先执行的机器检查:返回非空字符串表示这次执行不了,原样交给 agent、
86
+ * 用户不会被询问;返回空表示照常询问;抛出同样转成 `deny`(不会静默放行)。
85
87
  */
86
88
  export type ApprovalVerdict =
87
89
  | { readonly kind: 'read' }
@@ -97,6 +99,7 @@ export type ApprovalVerdict =
97
99
  readonly question: ApprovalDetail;
98
100
  readonly fallback: ApprovalDetail;
99
101
  readonly noteInDetail?: boolean;
102
+ readonly preflight?: (() => Promise<string | undefined>) | undefined;
100
103
  };
101
104
 
102
105
  export type ApprovalPolicy = (call: ApprovalCall) => ApprovalVerdict | undefined;
@@ -164,6 +167,16 @@ export async function approvalFor(
164
167
  };
165
168
  }
166
169
 
170
+ if (verdict.preflight !== undefined) {
171
+ let blocked: string | undefined;
172
+ try {
173
+ blocked = await verdict.preflight();
174
+ } catch (error) {
175
+ return { kind: 'deny', reason: `审批前的检查没有完成,已拒绝这次调用:${messageOf(error)}` };
176
+ }
177
+ if (blocked !== undefined && blocked.trim() !== '') return { kind: 'deny', reason: blocked.trim() };
178
+ }
179
+
167
180
  let facts: ApprovalFacts | undefined;
168
181
  try {
169
182
  facts = await context.detailOf?.(call);
@@ -12,6 +12,7 @@ import type {} from '@deepseek-ai/dsh-client-ui-input-trigger/client';
12
12
  import type {} from '@deepseek-ai/dsh-client-ui-layout/client';
13
13
  import type {} from '@deepseek-ai/dsh-client-ui-renderer/client';
14
14
  import type {} from '@deepseek-ai/dsh-client-ui-session/client';
15
+ import type {} from '@deepseek-ai/dsh-client-ui-session-status/client';
15
16
  import type {} from '@deepseek-ai/dsh-client-ui-sidebar-right/client';
16
17
  import type {} from '@deepseek-ai/dsh-client-ui-settings/client';
17
18
  import type {} from '@deepseek-ai/dsh-client-ui-workspace/client';
@@ -19,7 +20,7 @@ import type {} from '@deepseek-ai/dsh-subagent';
19
20
  import type { SlotRegistry } from '@deepseek-ai/dsh-client-ui-renderer/client';
20
21
  import type { PropsRenderSlots, SlotLabel } from '@deepseek-ai/dsh-client-ui-slots';
21
22
  import type { SessionInput as OfficialSessionInput } from '@deepseek-ai/dsh-client-ui-conversation/client';
22
- import type { SessionStatus as OfficialSessionStatus } from '@deepseek-ai/dsh-client-ui-session/client';
23
+ import type { SessionStatus as OfficialSessionStatus } from '@deepseek-ai/dsh-client-ui-session-status/client';
23
24
  import type { SessionSummary as OfficialSessionSummary } from '@deepseek-ai/dsh-api-session-controller/client';
24
25
  import type {
25
26
  WorkspaceSnapshot as OfficialWorkspaceSnapshot,