dsh-workbench-host 0.0.0-stage → 0.6.5

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,5 @@
1
+ - insert:
2
+ - id: workbench
3
+ name: 'dsh-workbench-host'
4
+ config:
5
+ enabled: true
@@ -0,0 +1,25 @@
1
+ /** Preserve actionable business errors in both text-only Workbench and UI RPC. */
2
+ export function actionErrorText(error) {
3
+ const e = error;
4
+ const message = String(e?.message ?? error);
5
+ const code = e?.code === undefined ? "" : String(e.code);
6
+ const headline = code && !message.includes(code) ? code + ":" + message : message;
7
+ return headline + (e?.details === undefined ? "" : "\n详细信息:" + JSON.stringify(e.details, null, 2));
8
+ }
9
+ /** Runtime validation belongs to each action; expose nested combinators in human help too. */
10
+ export function schemaChoices(schema, path = "args") {
11
+ if (!schema || typeof schema !== "object")
12
+ return [];
13
+ const lines = [];
14
+ if (Array.isArray(schema.oneOf)) {
15
+ lines.push(path + " 必须恰好满足一个分支(oneOf,不能同时提供互斥目标):");
16
+ schema.oneOf.forEach((branch, i) => {
17
+ lines.push(" " + (i + 1) + ". " + (branch.description || branch.title || "必填 " + (branch.required || []).join("、")) + ";约束 " + JSON.stringify(branch));
18
+ });
19
+ }
20
+ for (const [name, child] of Object.entries(schema.properties || {}))
21
+ lines.push(...schemaChoices(child, path + "." + name));
22
+ if (schema.items)
23
+ lines.push(...schemaChoices(schema.items, path + "[]"));
24
+ return lines;
25
+ }
@@ -0,0 +1,475 @@
1
+ import { actionErrorText, schemaChoices } from "./action-output.js";
2
+ import { createTaskTargets } from "./task-targets.js";
3
+ import { createCapabilities } from "./capabilities.js";
4
+ export function createActions({ domains, SHELL_VERSION, publicInfo, audit, clock, emit, db }) {
5
+ /** 宿主内置的元 action 归属域(不参与备份,也不是业务插件)。 */
6
+ const META_DOMAIN = "wb-shell";
7
+ /**
8
+ * 宿主元 action:与业务域共用同一套 schema 发现(actions.list/help)与分发、审计链路,
9
+ * 但不需要注册成插件域,统一归在 wb-shell 下。
10
+ */
11
+ const META_ACTIONS = new Map();
12
+ META_ACTIONS.set("audit.list", {
13
+ description: "查询本机审计日志:谁在何时通过哪个入口(agent/ui/sync)调了哪个 action、成功与否、耗时与目标。只读 action 默认不记;参数里的密码/token/保险箱值一律脱敏为 ***。",
14
+ input: {
15
+ type: "object",
16
+ properties: {
17
+ action: { type: "string", description: "精确匹配 action 名,如 tasks.update" },
18
+ actionPrefix: { type: "string", description: "按 action 前缀过滤,如 tasks. 或 tags." },
19
+ actor: { type: "string", description: "入口过滤:agent / ui / sync / other" },
20
+ domain: { type: "string", description: "业务域 id 过滤,如 wb-addon-tasks" },
21
+ ok: { type: ["boolean", "string", "number"], description: "只看成功(true/1)或只看失败(false/0)" },
22
+ q: { type: "string", description: "在 action / target / error 中模糊搜索" },
23
+ target: { type: "string", description: "目标过滤,如 id=01a1… 或任务 id / 标签名" },
24
+ since: { type: ["number", "string"], description: "起始时间:毫秒时间戳或 YYYY-MM-DD" },
25
+ until: { type: ["number", "string"], description: "结束时间:毫秒时间戳或 YYYY-MM-DD(含当天)" },
26
+ page: { type: "number", description: "页码,从 1 开始" },
27
+ pageSize: { type: "number", description: "每页条数,默认 50,上限 200" },
28
+ },
29
+ required: [],
30
+ },
31
+ examples: [{ pageSize: 20, ok: "false" }, { actionPrefix: "tasks.", since: "2026-11-01" }],
32
+ execute: (args) => audit.list(args),
33
+ render: (result) => renderAuditList(result),
34
+ });
35
+ META_ACTIONS.set("audit.get", {
36
+ description: "按 id 查看一条审计记录的完整内容(参数与结果摘要已脱敏、超长已截断)。",
37
+ input: {
38
+ type: "object",
39
+ properties: { id: { type: "number", description: "audit.list 返回的记录 id" } },
40
+ required: ["id"],
41
+ },
42
+ examples: [{ id: 1 }],
43
+ execute: (args) => {
44
+ const id = Number(args.id);
45
+ if (!Number.isFinite(id) || id <= 0)
46
+ throw new Error("id 必须是正整数");
47
+ const record = audit.get(id);
48
+ if (!record)
49
+ throw new Error("没有该审计记录:" + id);
50
+ return record;
51
+ },
52
+ render: (result) => renderAuditRecord(result),
53
+ });
54
+ META_ACTIONS.set("audit.stats", {
55
+ description: "审计统计:区间内总数、失败数、按 action / 入口 / 天的分布。用于回答「这几天改了什么、失败多不多」。",
56
+ input: {
57
+ type: "object",
58
+ properties: { rangeDays: { type: ["number", "string"], description: "统计最近多少天,默认 30,范围 1..3650" } },
59
+ required: [],
60
+ },
61
+ examples: [{ rangeDays: 7 }],
62
+ execute: (args) => audit.stats(args.rangeDays ?? 30),
63
+ render: (result) => renderAuditStats(result),
64
+ });
65
+ META_ACTIONS.set("audit.prune", {
66
+ description: "按保留期清理旧审计(默认 90 天,可用 meta.audit.retentionDays 调整)。删除不可恢复,日常无需调用。",
67
+ input: {
68
+ type: "object",
69
+ properties: { retentionDays: { type: "number", description: "保留天数,1..3650;省略则用当前配置" } },
70
+ required: [],
71
+ },
72
+ examples: [{ retentionDays: 30 }],
73
+ execute: (args) => audit.prune(args.retentionDays),
74
+ render: (result) => "已清理 " + result.deleted + " 条审计(保留 " + result.retentionDays + " 天,截止 " + new Date(result.cutoff).toISOString() + ")",
75
+ });
76
+ function renderAuditList(meta) {
77
+ const lines = [
78
+ "审计日志 " + meta.total + " 条(返回 " + meta.returned + " 条 · 第 " + meta.page + " 页 · 每页 " + meta.pageSize + ")",
79
+ ];
80
+ if (!meta.records.length)
81
+ lines.push("(没有符合条件的记录)");
82
+ for (const r of meta.records) {
83
+ lines.push("");
84
+ lines.push("#" + r.id + " " + r.time + " · " + r.actor + " · " + r.action + (r.ok ? "" : " ✗ 失败") +
85
+ (r.durationMs ? " · " + r.durationMs + "ms" : ""));
86
+ if (r.target)
87
+ lines.push(" 目标:" + r.target);
88
+ if (r.error)
89
+ lines.push(" 错误:" + String(r.error).slice(0, 500));
90
+ if (r.args)
91
+ lines.push(" 参数:" + String(r.args).slice(0, 300));
92
+ }
93
+ return lines.join("\n");
94
+ }
95
+ function renderAuditRecord(r) {
96
+ const lines = [
97
+ "#" + r.id + " " + r.time,
98
+ "入口:" + r.actor + " · 域:" + (r.domain || "(未知)") + " · " + (r.ok ? "成功" : "失败") + " · " + r.durationMs + "ms",
99
+ "action:" + r.action,
100
+ ];
101
+ if (r.target)
102
+ lines.push("目标:" + r.target);
103
+ if (r.error)
104
+ lines.push("错误:" + r.error);
105
+ lines.push("", "参数:", r.args ? prettyJson(r.args) : "(无)", "", "结果:", r.result ? prettyJson(r.result) : "(无)");
106
+ return lines.join("\n");
107
+ }
108
+ function prettyJson(text) {
109
+ try {
110
+ return JSON.stringify(JSON.parse(text), null, 2);
111
+ }
112
+ catch {
113
+ return String(text);
114
+ }
115
+ }
116
+ function renderAuditStats(s) {
117
+ const lines = ["最近 " + s.rangeDays + " 天:共 " + s.total + " 条,失败 " + s.failed + " 条"];
118
+ if (s.byAction.length) {
119
+ lines.push("", "按 action:");
120
+ for (const a of s.byAction)
121
+ lines.push(" " + a.action + " × " + a.count + (a.failed ? "(失败 " + a.failed + ")" : ""));
122
+ }
123
+ if (s.byActor.length) {
124
+ lines.push("", "按入口:");
125
+ for (const a of s.byActor)
126
+ lines.push(" " + a.actor + " × " + a.count);
127
+ }
128
+ if (s.byDay.length) {
129
+ lines.push("", "按天:");
130
+ for (const d of s.byDay)
131
+ lines.push(" " + d.day + " × " + d.count + (d.failed ? "(失败 " + d.failed + ")" : ""));
132
+ }
133
+ return lines.join("\n");
134
+ }
135
+ /** 旧版 Workbench 顶层 schema 里的“通用字段”,多数 action 并不接受。 */
136
+ const TRAP_FIELDS = ["due_at", "note", "tags", "tagIds", "dirIds", "parentId", "deadline", "start_at", "assignee", "limit"];
137
+ const taskTargets = createTaskTargets(db, domains, invoke);
138
+ META_ACTIONS.set("capabilities.setTaskTarget", taskTargets.setAction);
139
+ const { capabilityListMeta, renderCapabilityList, capabilityGetMeta, renderCapability } = createCapabilities({ domains, SHELL_VERSION, actionEntry, taskTargets });
140
+ function findActionDef(name) {
141
+ const meta = META_ACTIONS.get(name);
142
+ if (meta)
143
+ return { def: meta, domainId: META_DOMAIN };
144
+ for (const rec of domains.values()) {
145
+ const def = rec.actions.get(name);
146
+ if (def)
147
+ return { def, domainId: rec.def.id };
148
+ }
149
+ return null;
150
+ }
151
+ function actionParams(def) {
152
+ const input = (def.input ?? {});
153
+ const props = input && typeof input === "object" && input.properties && typeof input.properties === "object"
154
+ ? input.properties
155
+ : {};
156
+ const required = input && Array.isArray(input.required) ? input.required : [];
157
+ return { props, required: required.filter((key) => Object.prototype.hasOwnProperty.call(props, key)) };
158
+ }
159
+ function actionEntry(name, domainId, def) {
160
+ const { props, required } = actionParams(def);
161
+ return {
162
+ name,
163
+ domain: domainId,
164
+ description: def.description ?? "",
165
+ required,
166
+ params: Object.keys(props),
167
+ input: def.input ?? { type: "object", properties: {} },
168
+ };
169
+ }
170
+ /** actions.list:把已注册 action 的“真实入参”暴露给 agent,避免按顶层通用 schema 猜字段。 */
171
+ function listActionsMeta(args) {
172
+ const raw = args.domain === undefined || args.domain === null ? "" : String(args.domain).trim();
173
+ const matchDomain = (domainId) => !raw || domainId === raw || domainId === "wb-addon-" + raw;
174
+ const matchAction = (name, domainId) => !raw || matchDomain(domainId) || name === raw || name.split(".")[0] === raw;
175
+ const all = [];
176
+ for (const rec of domains.values()) {
177
+ for (const [name, def] of rec.actions) {
178
+ if (matchAction(name, rec.def.id))
179
+ all.push(actionEntry(name, rec.def.id, def));
180
+ }
181
+ }
182
+ for (const [name, def] of META_ACTIONS) {
183
+ if (matchAction(name, META_DOMAIN))
184
+ all.push(actionEntry(name, META_DOMAIN, def));
185
+ }
186
+ const ids = new Set(all.map((a) => a.domain));
187
+ const domainsOut = [...domains.values()]
188
+ .filter((rec) => ids.has(rec.def.id))
189
+ .map((rec) => {
190
+ const info = publicInfo(rec);
191
+ return {
192
+ id: info.id,
193
+ title: info.title,
194
+ version: info.version,
195
+ enabled: info.enabled,
196
+ error: info.error,
197
+ actionCount: rec.actions.size,
198
+ };
199
+ });
200
+ if (ids.has(META_DOMAIN)) {
201
+ domainsOut.push({
202
+ id: META_DOMAIN,
203
+ title: "宿主元 action(能力发现与审计)",
204
+ version: SHELL_VERSION,
205
+ enabled: true,
206
+ error: null,
207
+ actionCount: 4 + META_ACTIONS.size,
208
+ });
209
+ }
210
+ const detail = args.detail === true;
211
+ return {
212
+ shellVersion: SHELL_VERSION,
213
+ domains: domainsOut,
214
+ actions: detail
215
+ ? all
216
+ : all.map((a) => ({ name: a.name, domain: a.domain, description: a.description, required: a.required, params: a.params })),
217
+ };
218
+ }
219
+ function renderActionList(meta) {
220
+ const lines = ["工作台 " + meta.shellVersion + " · " + meta.domains.length + " 个域 · " + meta.actions.length + " 个 action"];
221
+ for (const d of meta.domains) {
222
+ lines.push("", "[" + d.id + "] " + d.title + " v" + d.version + (d.enabled ? "" : "(未启用:" + d.error + ")"));
223
+ for (const a of meta.actions) {
224
+ if (a.domain !== d.id)
225
+ continue;
226
+ lines.push(" " + a.name + (a.description ? " — " + a.description : ""));
227
+ const params = a.params ?? [];
228
+ lines.push(" 参数:" +
229
+ (params.length
230
+ ? params.map((p) => (a.required.indexOf(p) >= 0 ? p : p + "?")).join(", ")
231
+ : "无(直接调用即可)"));
232
+ }
233
+ }
234
+ lines.push("", '查看完整 JSON Schema 与示例:Workbench({ action: "actions.help", args: { action: "<name>" } })');
235
+ return lines.join("\n");
236
+ }
237
+ /** actions.help:单个 action 的完整 schema + 参数说明 + 示例。 */
238
+ function helpActionMeta(args) {
239
+ const name = String(args.action ?? args.name ?? "").trim();
240
+ if (!name)
241
+ throw new Error("缺少 action;先用 actions.list 查看可用 action");
242
+ const found = findActionDef(name);
243
+ if (!found)
244
+ throw new Error("没有该 action:" + name + ";先用 actions.list 查看可用 action");
245
+ const entry = actionEntry(name, found.domainId, found.def);
246
+ const { props } = actionParams(found.def);
247
+ const params = Object.keys(props).map((key) => ({
248
+ name: key,
249
+ type: Array.isArray(props[key]?.type) ? props[key].type.join("|") : (props[key]?.type ?? "any"),
250
+ required: entry.required.indexOf(key) >= 0,
251
+ description: props[key]?.description ?? "",
252
+ enum: props[key]?.enum,
253
+ }));
254
+ return {
255
+ name,
256
+ domain: entry.domain,
257
+ description: entry.description,
258
+ input: entry.input,
259
+ params,
260
+ examples: found.def.examples ?? [],
261
+ };
262
+ }
263
+ function renderActionHelp(help) {
264
+ const lines = [help.name + " · " + help.domain, help.description || "(无描述)", "", "参数:"];
265
+ if (!help.params.length)
266
+ lines.push(" 无");
267
+ for (const p of help.params) {
268
+ lines.push(" " + p.name + (p.required ? "*" : "") + " (" + p.type + ")" + (p.description ? " — " + p.description : "") +
269
+ (Array.isArray(p.enum) ? ";可选值:" + p.enum.join(" / ") : ""));
270
+ }
271
+ lines.push(...schemaChoices(help.input));
272
+ lines.push("", "JSON Schema:", JSON.stringify(help.input, null, 2));
273
+ if (help.examples.length) {
274
+ lines.push("", "示例:");
275
+ for (const ex of help.examples) {
276
+ lines.push(" Workbench(" + JSON.stringify({ action: help.name, args: ex }) + ")");
277
+ }
278
+ }
279
+ return lines.join("\n");
280
+ }
281
+ function actionNames() {
282
+ const out = [];
283
+ for (const rec of domains.values()) {
284
+ for (const [action, def] of rec.actions) {
285
+ out.push({ name: action, domainId: rec.def.id, description: def.description });
286
+ }
287
+ }
288
+ for (const [name, def] of META_ACTIONS) {
289
+ out.push({ name, domainId: META_DOMAIN, description: def.description });
290
+ }
291
+ out.push({ name: "capabilities.list", domainId: META_DOMAIN, description: "列出各业务插件记录什么、首选哪个 action" });
292
+ out.push({ name: "capabilities.get", domainId: META_DOMAIN, description: "查看单个业务插件的完整能力清单与 action 列表" });
293
+ out.push({ name: "actions.list", domainId: META_DOMAIN, description: "列出已安装业务域的 action、参数与必填项" });
294
+ out.push({ name: "actions.help", domainId: META_DOMAIN, description: "查看单个 action 的完整 JSON Schema、参数说明与示例" });
295
+ return out;
296
+ }
297
+ async function invoke(action, args, origin) {
298
+ // 审计只在分发外层做一次:成功按实际 domainId 记,失败记下错误后原样抛出。
299
+ // 能力发现与审计自身不记录,避免自举递归和噪声。
300
+ const audited = !/^(capabilities|actions|audit)\./.test(action);
301
+ const started = clock.now();
302
+ try {
303
+ const out = await invokeAction(action, args, origin);
304
+ if (audited) {
305
+ audit.record({
306
+ action,
307
+ domain: out.domainId,
308
+ actor: origin,
309
+ ok: true,
310
+ args,
311
+ result: out.result,
312
+ durationMs: clock.now() - started,
313
+ });
314
+ }
315
+ return out;
316
+ }
317
+ catch (e) {
318
+ if (audited) {
319
+ const target = findActionDef(action);
320
+ audit.record({
321
+ action,
322
+ domain: target ? target.domainId : "",
323
+ actor: origin,
324
+ ok: false,
325
+ error: String((e && e.message) || e),
326
+ args,
327
+ durationMs: clock.now() - started,
328
+ });
329
+ }
330
+ throw e;
331
+ }
332
+ }
333
+ async function invokeAction(action, args, origin) {
334
+ if (action === "capabilities.list") {
335
+ const result = await capabilityListMeta(args);
336
+ return { result, text: renderCapabilityList(result), domainId: META_DOMAIN };
337
+ }
338
+ if (action === "capabilities.get") {
339
+ const result = await capabilityGetMeta(args);
340
+ return { result, text: renderCapability(result), domainId: META_DOMAIN };
341
+ }
342
+ if (action === "actions.list") {
343
+ const result = listActionsMeta(args);
344
+ return { result, text: renderActionList(result), domainId: META_DOMAIN };
345
+ }
346
+ if (action === "actions.help") {
347
+ const result = helpActionMeta(args);
348
+ return { result, text: renderActionHelp(result), domainId: META_DOMAIN };
349
+ }
350
+ const meta = META_ACTIONS.get(action);
351
+ if (meta) {
352
+ const result = await meta.execute(args, {
353
+ origin,
354
+ emit: (event, data) => emit("domain-event", { domainId: META_DOMAIN, event, data: data ?? null }),
355
+ });
356
+ return {
357
+ result,
358
+ text: meta.render ? meta.render(result) : JSON.stringify(result),
359
+ domainId: META_DOMAIN,
360
+ };
361
+ }
362
+ for (const rec of domains.values()) {
363
+ const def = rec.actions.get(action);
364
+ if (!def)
365
+ continue;
366
+ const result = await def.execute(args, {
367
+ origin,
368
+ emit: (event, data) => emit("domain-event", { domainId: rec.def.id, event, data: data ?? null }),
369
+ });
370
+ return {
371
+ result,
372
+ text: def.render ? def.render(result) : JSON.stringify(result),
373
+ domainId: rec.def.id,
374
+ };
375
+ }
376
+ throw new Error("没有业务插件注册 action:" + action);
377
+ }
378
+ function installTool(ctx) {
379
+ // ── Agent 工具:Workbench(单工具多 action,action 由已注册业务域动态提供)──
380
+ ctx.tools?.register({
381
+ name: "Workbench",
382
+ timeoutMs: 60_000,
383
+ description: "个人工作台。action 由已安装业务插件提供(tasks.* / taskNodes.* / tags.* / sites.* / siteTags.* / siteNodes.*)," +
384
+ "宿主另提供 capabilities.list / capabilities.get 查看各插件记录什么、任务归属显式配置及首选 action;capabilities.setTaskTarget 配置 domain→tableId。" +
385
+ "物品用 storage.create,开发工作用 tasks.create;创建任务前用 tasks.capabilities / tasks.resolveTable 明确目标,不能默认第一张表。" +
386
+ "actions.list / actions.help 用于自举:先 actions.list 看有哪些 action,再 actions.help 看真实字段。" +
387
+ "审计留痕可直接查 audit.list / audit.get / audit.stats(本机行为账本:谁在何时调了什么、成功与否,参数已脱敏)。" +
388
+ "入参统一放进 args;不要再按旧版顶层字段(due_at / tags / parentId 等)猜参数。" +
389
+ "安装或卸载业务插件请使用 DSH 的插件管理,不在本工具里做。",
390
+ parameters: {
391
+ type: "object",
392
+ properties: {
393
+ action: {
394
+ type: "string",
395
+ description: "action 名,如 capabilities.list / capabilities.get / actions.list / tasks.list / tasks.create / tags.create / sites.list",
396
+ },
397
+ args: {
398
+ type: "object",
399
+ description: "该 action 的入参对象;字段名与类型以 actions.help 的返回为准",
400
+ additionalProperties: true,
401
+ },
402
+ },
403
+ required: ["action"],
404
+ // 兼容旧调用:未放进 args 的顶层字段仍会被采纳(但会按 action 的真实 schema 校验并提示被忽略项)
405
+ additionalProperties: true,
406
+ },
407
+ output: {
408
+ schema: { type: "object", properties: { text: { type: "string" } } },
409
+ render: (_a, v) => [{ type: "text", text: v.text }],
410
+ },
411
+ execute: async (args) => {
412
+ const raw = String(args.action || "");
413
+ try {
414
+ if (!raw)
415
+ return { text: "错误:缺少 action(先调用 actions.list)" };
416
+ // 兼容旧工具调用:无命名空间的 list/create/... 映射到 tasks.*
417
+ const action = raw.indexOf(".") >= 0 ? raw : "tasks." + raw;
418
+ const flat = { ...args };
419
+ delete flat.action;
420
+ const nested = flat.args;
421
+ delete flat.args;
422
+ const payload = {};
423
+ if (nested && typeof nested === "object" && !Array.isArray(nested)) {
424
+ Object.assign(payload, nested);
425
+ }
426
+ for (const [key, value] of Object.entries(flat)) {
427
+ if (Object.prototype.hasOwnProperty.call(payload, key) && JSON.stringify(payload[key]) !== JSON.stringify(value)) {
428
+ return { text: "错误:参数 " + key + " 同时出现在 args 和顶层且值不同,请只传一处" };
429
+ }
430
+ payload[key] = value;
431
+ }
432
+ // 旧版 Workbench schema 里有一批“看起来通用、实际没人接”的字段:若该 action 的
433
+ // 真实 schema 不声明它们,就明确提示已忽略,而不是静默丢参。
434
+ const known = new Set();
435
+ const found = findActionDef(action);
436
+ if (found)
437
+ for (const key of Object.keys(actionParams(found.def).props))
438
+ known.add(key);
439
+ const ignored = [];
440
+ for (const key of TRAP_FIELDS) {
441
+ if (Object.prototype.hasOwnProperty.call(payload, key) && !known.has(key)) {
442
+ ignored.push(key + "=" + JSON.stringify(payload[key]));
443
+ delete payload[key];
444
+ }
445
+ }
446
+ const r = await invoke(action, payload, "agent");
447
+ const warning = ignored.length
448
+ ? "⚠ " + action + " 不接受这些参数,已忽略:\n " + ignored.join("\n ") +
449
+ "\n(真实字段名以 actions.help 为准)\n\n"
450
+ : "";
451
+ return { text: warning + r.text };
452
+ }
453
+ catch (e) {
454
+ return { text: "错误:" + actionErrorText(e) };
455
+ }
456
+ },
457
+ });
458
+ }
459
+ /**
460
+ * 只读 schema 快照:给 /workbench/api/schema 的 Action 页调试用。
461
+ * 与 actions.list(detail=true) 同源(同一份 actionEntry + 注册表),额外带上每个 action 的示例;
462
+ * 只读取运行时注册,不执行任何 action、不写库、不产生审计记录。
463
+ */
464
+ function schemaSnapshot(domain) {
465
+ const wanted = String(domain ?? "").trim();
466
+ const meta = listActionsMeta({ detail: true, ...(wanted ? { domain: wanted } : {}) });
467
+ const actions = meta.actions.map((entry) => {
468
+ const found = findActionDef(entry.name);
469
+ const examples = found && Array.isArray(found.def.examples) ? found.def.examples : [];
470
+ return { ...entry, examples };
471
+ });
472
+ return { shellVersion: meta.shellVersion, domains: meta.domains, actions };
473
+ }
474
+ return { invoke, actionNames, installTool, schemaSnapshot };
475
+ }