dsh-workbench-host 0.7.0 → 0.8.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.
@@ -0,0 +1,64 @@
1
+ /**
2
+ * 四个由 invokeAction 最前面特殊分发的内置 action(注册表里没有它们的 execute,
3
+ * 也不能放进 META_ACTIONS,否则会被 META 通用分发吃掉)。
4
+ * 仍然要出现在 actions.list({ domain: "wb-shell" }) 里:界面要看得见、能配置它们的 agent 开关。
5
+ */
6
+ export const BUILTIN_ACTIONS = new Map([
7
+ [
8
+ "capabilities.list",
9
+ {
10
+ description: "列出每个业务插件记录什么、任务归属与首选 action;可按 domain 过滤。",
11
+ input: {
12
+ type: "object",
13
+ properties: { domain: { type: "string", description: "只看某个业务域 id,如 wb-addon-tasks" } },
14
+ },
15
+ execute: () => {
16
+ throw new Error("内置 action 由宿主特殊分发");
17
+ },
18
+ },
19
+ ],
20
+ [
21
+ "capabilities.get",
22
+ {
23
+ description: "查看单个业务插件的完整能力清单(记录内容、warnings、首选 action 与 action 列表)。",
24
+ input: {
25
+ type: "object",
26
+ properties: { domain: { type: "string", description: "业务域 id,如 wb-addon-tasks" } },
27
+ required: ["domain"],
28
+ },
29
+ execute: () => {
30
+ throw new Error("内置 action 由宿主特殊分发");
31
+ },
32
+ },
33
+ ],
34
+ [
35
+ "actions.list",
36
+ {
37
+ description: "列出已安装业务域的 action、参数与必填项;domain 过滤、detail=true 给全量 schema。",
38
+ input: {
39
+ type: "object",
40
+ properties: {
41
+ domain: { type: "string", description: "按域过滤(也可传 wb-shell 只看宿主 action)" },
42
+ detail: { type: "boolean", description: "true 时返回每个 action 的完整 input schema" },
43
+ },
44
+ },
45
+ execute: () => {
46
+ throw new Error("内置 action 由宿主特殊分发");
47
+ },
48
+ },
49
+ ],
50
+ [
51
+ "actions.help",
52
+ {
53
+ description: "查看单个 action 的完整 JSON Schema、参数说明与示例。",
54
+ input: {
55
+ type: "object",
56
+ properties: { action: { type: "string", description: "action 名,如 tasks.create" } },
57
+ required: ["action"],
58
+ },
59
+ execute: () => {
60
+ throw new Error("内置 action 由宿主特殊分发");
61
+ },
62
+ },
63
+ ],
64
+ ]);
@@ -1,5 +1,5 @@
1
1
  import { renderTaskTarget } from "./task-targets.js";
2
- export function createCapabilities({ domains, SHELL_VERSION, actionEntry, taskTargets }) {
2
+ export function createCapabilities({ domains, SHELL_VERSION, actionEntry, taskTargets, agentVisible }) {
3
3
  function findDomain(raw) {
4
4
  const key = String(raw ?? "").trim();
5
5
  if (!key)
@@ -123,7 +123,7 @@ export function createCapabilities({ domains, SHELL_VERSION, actionEntry, taskTa
123
123
  };
124
124
  }
125
125
  /** capabilities.list:聚合各插件“记录什么、首选哪个 action”,给 agent 做统一发现。 */
126
- async function capabilityListMeta(args) {
126
+ async function capabilityListMeta(args, origin = "ui") {
127
127
  const kind = args.kind === undefined || args.kind === null ? "" : String(args.kind).trim();
128
128
  const out = [];
129
129
  for (const rec of domains.values()) {
@@ -138,7 +138,9 @@ export function createCapabilities({ domains, SHELL_VERSION, actionEntry, taskTa
138
138
  error: rec.error,
139
139
  summary: cap.summary,
140
140
  source: cap.source,
141
- actionCount: rec.actions.size,
141
+ actionCount: origin === "agent"
142
+ ? [...rec.actions].filter(([action, def]) => agentVisible(action, def)).length
143
+ : rec.actions.size,
142
144
  requires: cap.requires ?? [],
143
145
  missingRequires: cap.missingRequires ?? [],
144
146
  records: cap.records.map((r) => ({
@@ -177,7 +179,7 @@ export function createCapabilities({ domains, SHELL_VERSION, actionEntry, taskTa
177
179
  return lines.join("\n");
178
180
  }
179
181
  /** capabilities.get:单个业务域的完整能力清单 + action 摘要(字段细节仍走 actions.help)。 */
180
- async function capabilityGetMeta(args) {
182
+ async function capabilityGetMeta(args, origin = "ui") {
181
183
  const name = String(args.domain ?? args.id ?? "").trim();
182
184
  if (!name)
183
185
  throw new Error("缺少 domain;先用 capabilities.list 查看可用业务域");
@@ -206,7 +208,10 @@ export function createCapabilities({ domains, SHELL_VERSION, actionEntry, taskTa
206
208
  missingRequires: cap.missingRequires ?? [],
207
209
  },
208
210
  source: cap.source,
209
- actions: [...rec.actions].map(([action, def]) => actionEntry(action, rec.def.id, def)),
211
+ // capabilities.get 也是 agent 的发现入口:被本机关闭的 action 不列给它(ui 仍看全量)。
212
+ actions: [...rec.actions]
213
+ .filter(([action, def]) => origin !== "agent" || agentVisible(action, def))
214
+ .map(([action, def]) => actionEntry(action, rec.def.id, def)),
210
215
  warnings: cap.warnings,
211
216
  };
212
217
  }
package/lib/index.js CHANGED
@@ -23,7 +23,7 @@ export const inject = ["webServer", "tools", "connection"];
23
23
  const WB_HOME = process.env.WB_HOME ?? join(homedir(), ".dsh", "workbench");
24
24
  const CLOUD_DEFAULT = process.env.WB_CLOUD_URL ?? "http://127.0.0.1:8791";
25
25
  /** 宿主 API 版本:业务插件用它做兼容判断。 */
26
- export const SHELL_VERSION = "0.7.0";
26
+ export const SHELL_VERSION = "0.8.0";
27
27
  const DOMAIN_ID_RE = /^[a-z][a-z0-9_-]{2,63}$/;
28
28
  const ACTION_RE = /^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+$/i;
29
29
  function loadCreds() {
@@ -228,8 +228,8 @@ export class AuditLog {
228
228
  const action = String(input.action || "").trim();
229
229
  if (!action)
230
230
  return null;
231
- // 自举元 action 与审计自身不记
232
- if (action.startsWith("audit.") || action.startsWith("actions.") || action.startsWith("capabilities.")) {
231
+ // 自举元 action 与审计自身不记;显式 force 的安全事件(如改权限开关、被策略拦截)例外。
232
+ if (!input.force && (action.startsWith("audit.") || action.startsWith("actions.") || action.startsWith("capabilities."))) {
233
233
  return null;
234
234
  }
235
235
  if (!input.force && isReadAction(action) && !this.recordsReads())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workbench-host",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "engines": {