@cannbot-plugin/cannbot-harness 0.2.0 → 0.2.1

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 CHANGED
@@ -7,9 +7,9 @@ Windows 桌面端和 Linux Web 端使用同一个 `.tgz` 安装包。
7
7
 
8
8
  - 在 DSH 的插件页面启用 **CANNBot Harness**:立即显示品牌、红白主题和全部 9 个官方工作流,同时挂载 129 个 Skills。
9
9
  - 左下角提供 **CANNBot Harness** 开关,启用插件时默认开启。关闭开关仅恢复原版界面,工作流 Skills 继续可用。
10
- - 选择工作目录,在 **选择工作流** 中选择任一官方工作流,输入框会填入对应的 `/工作流名称 ` 指令。
11
- 继续输入需求,然后手动发送。已有正文、引用和附件不会被替换;重复选择不重复添加命令。
12
- - 切换工作流仅替换已有工作流指令前缀,保留后面的用户需求。
10
+ - 选择工作目录,在 **选择工作流** 中选择任一官方工作流。输入框仅填写自己的需求,不会添加 `/工作流名称`。
11
+ 手动发送后,插件在 DSH 官方 `agent/pre-step` 扩展点加载对应 Skill,作为后台模型上下文;用户消息正文、引用和附件保持原样。
12
+ - 工作流按会话保存,切换不会修改输入;选择 **普通对话** 可清除本会话的后台工作流。设置保存失败时保留上次成功的选择并提示重试。
13
13
  - 在 DSH 的插件页面停用 **CANNBot Harness**:恢复原版界面和模式选择,同时卸载 Skills;重新启用后界面与 Skills 一起恢复。
14
14
  - 本插件不提供 SSH 或远程连接控件。Linux 用户通过 DSH 自身的 Web 界面访问服务。
15
15
 
@@ -25,13 +25,13 @@ Windows 桌面端和 Linux Web 端使用同一个 `.tgz` 安装包。
25
25
  Windows 桌面端先正常退出 DSH,再用 DSH 自带的 CLI 安装:
26
26
 
27
27
  ```powershell
28
- dsh plugin --profile desktop add @cannbot-plugin/cannbot-harness@0.2.0
28
+ dsh plugin --profile desktop add @cannbot-plugin/cannbot-harness@0.2.1
29
29
  ```
30
30
 
31
31
  Linux 使用运行 DSH 的同一用户安装,随后启动对应配置:
32
32
 
33
33
  ```bash
34
- dsh plugin --profile web add @cannbot-plugin/cannbot-harness@0.2.0
34
+ dsh plugin --profile web add @cannbot-plugin/cannbot-harness@0.2.1
35
35
  dsh web --no-open
36
36
  ```
37
37
 
@@ -45,12 +45,12 @@ dsh plugin --profile <你的配置名> remove @cannbot/dsh-harness
45
45
 
46
46
  ### Windows 桌面端
47
47
 
48
- 在原版 DSH 的 **插件 → 添加插件** 中安装本地文件 `cannbot-plugin-cannbot-harness-0.2.0.tgz`。
48
+ 在原版 DSH 的 **插件 → 添加插件** 中安装本地文件 `cannbot-plugin-cannbot-harness-0.2.1.tgz`。
49
49
  安装后启用 **CANNBot Harness**。如果当前 DSH 提示需要重启,正常退出并重新打开 DSH。
50
50
  也可先完全退出 DSH,再用 DSH 自带的 CLI:
51
51
 
52
52
  ```powershell
53
- dsh plugin --profile desktop add "C:\Downloads\cannbot-plugin-cannbot-harness-0.2.0.tgz"
53
+ dsh plugin --profile desktop add "C:\Downloads\cannbot-plugin-cannbot-harness-0.2.1.tgz"
54
54
  ```
55
55
 
56
56
  ### Linux 浏览器端
@@ -58,7 +58,7 @@ dsh plugin --profile desktop add "C:\Downloads\cannbot-plugin-cannbot-harness-0.
58
58
  先安装原版 DSH,再将安装包放到服务器上,以运行 DSH 的同一用户执行:
59
59
 
60
60
  ```bash
61
- dsh plugin --profile web add /path/to/cannbot-plugin-cannbot-harness-0.2.0.tgz
61
+ dsh plugin --profile web add /path/to/cannbot-plugin-cannbot-harness-0.2.1.tgz
62
62
  dsh web --no-open
63
63
  ```
64
64
 
package/lib/client.js CHANGED
@@ -36,8 +36,10 @@ window.__ModuleLoader__.load({
36
36
  const PACKAGE = "@cannbot-plugin/cannbot-harness";
37
37
  const zh = {
38
38
  workflow: "选择工作流",
39
+ ordinary: "普通对话",
40
+ saving: "正在应用工作流…",
39
41
  operator: "算子开发工作流",
40
- commandHint: "填入所选工作流指令,由你补充需求后发送。",
42
+ commandHint: "发送时自动应用所选工作流,只需填写需求。",
41
43
  flash: "Ascend C Flash 核函数开发",
42
44
  registry: "ACLNN / GEIR 注册算子开发",
43
45
  model: "NPU 模型推理优化",
@@ -47,12 +49,14 @@ window.__ModuleLoader__.load({
47
49
  performance: "Ascend C 性能调优",
48
50
  pypto: "PyPTO 算子开发",
49
51
  chooseWorkspace: "请先选择工作目录。",
50
- insertFailed: "输入框正在处理其他操作,请稍后重试。"
52
+ insertFailed: "工作流设置未保存,请稍后重试。"
51
53
  };
52
54
  const en = {
53
55
  workflow: "Choose workflow",
56
+ ordinary: "Ordinary conversation",
57
+ saving: "Applying workflow…",
54
58
  operator: "Operator development workflow",
55
- commandHint: "Insert the selected workflow command, add your requirements, then send.",
59
+ commandHint: "The selected workflow is applied in the background when you send.",
56
60
  flash: "Ascend C Flash kernel development",
57
61
  registry: "ACLNN / GEIR operator development",
58
62
  model: "NPU model inference optimization",
@@ -62,7 +66,7 @@ window.__ModuleLoader__.load({
62
66
  performance: "Ascend C performance tuning",
63
67
  pypto: "PyPTO operator development",
64
68
  chooseWorkspace: "Choose a working directory first.",
65
- insertFailed: "The composer is busy. Please retry."
69
+ insertFailed: "The workflow preference was not saved. Please retry."
66
70
  };
67
71
  //#endregion
68
72
  //#region src/client/Brand.tsx
@@ -171,26 +175,15 @@ window.__ModuleLoader__.load({
171
175
  //#endregion
172
176
  //#region src/client/WorkflowSelector.tsx
173
177
  /** Select a workflow without submitting, replacing text, or discarding reference chips. */
174
- function WorkflowSelector({ inputActions, useInput, t }) {
178
+ function WorkflowSelector({ sessionId, inputActions, useInput, t, selection }) {
175
179
  const input = useInput((state) => state);
180
+ const saved = (0, react.useSyncExternalStore)(selection.subscribe, selection.getSnapshot);
176
181
  const [open, setOpen] = (0, react.useState)(false);
177
- const [failed, setFailed] = (0, react.useState)(false);
178
- const selected = WORKFLOWS.find((workflow) => input?.draft === `/${workflow.id}` || input?.draft.startsWith(`/${workflow.id} `) || input?.draft.startsWith(`/${workflow.id}\n`));
179
- const available = inputActions !== void 0 && input !== void 0 && input.phase === "plain";
180
- const pick = (workflow) => {
182
+ const selected = WORKFLOWS.find((workflow) => sessionId && saved.values[sessionId] === workflow.id);
183
+ const available = !!sessionId && saved.ready && !saved.pending && inputActions !== void 0 && input !== void 0 && input.phase === "plain";
184
+ const pick = (id) => {
181
185
  setOpen(false);
182
- if (!inputActions || !input) return;
183
- if (selected?.id === workflow.id) {
184
- setFailed(false);
185
- return;
186
- }
187
- const oldCommand = selected ? `/${selected.id}` : "";
188
- const end = oldCommand.length + (oldCommand && input.draft[oldCommand.length] === " " ? 1 : 0);
189
- setFailed(!inputActions.insertText(`/${workflow.id} `, {
190
- start: 0,
191
- end,
192
- draftRev: input.draftRev
193
- }));
186
+ if (sessionId && available) selection.choose(sessionId, id, t("saving"));
194
187
  };
195
188
  const anchor = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
196
189
  type: "button",
@@ -210,24 +203,28 @@ window.__ModuleLoader__.load({
210
203
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChevronIcon, { size: 12 })
211
204
  ]
212
205
  });
213
- const label = (workflow) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
206
+ const label = (workflow) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
214
207
  className: "cannbot-harness-workflow-option",
215
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t(workflow.label) }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("small", { children: ["/", workflow.id] })]
208
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t(workflow.label) })
216
209
  });
217
210
  const { Menu, MenuItemButton } = _deepseek_ai_dsh_client_ui_primitives;
218
211
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
219
212
  className: "cannbot-harness-workflow",
220
- children: [typeof MenuItemButton === "function" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Menu, {
213
+ children: [typeof MenuItemButton === "function" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Menu, {
221
214
  open,
222
215
  onClose: () => setOpen(false),
223
216
  portal: true,
224
217
  className: "cannbot-harness-workflow-anchor",
225
218
  anchor,
226
- children: WORKFLOWS.map((workflow) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MenuItemButton, {
219
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MenuItemButton, {
220
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowIcon, {}),
221
+ onSelect: () => pick(""),
222
+ children: t("ordinary")
223
+ }), WORKFLOWS.map((workflow) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MenuItemButton, {
227
224
  icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowIcon, {}),
228
- onSelect: () => pick(workflow),
225
+ onSelect: () => pick(workflow.id),
229
226
  children: label(workflow)
230
- }, workflow.id))
227
+ }, workflow.id))]
231
228
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Menu, {
232
229
  open,
233
230
  onClose: () => setOpen(false),
@@ -235,16 +232,17 @@ window.__ModuleLoader__.load({
235
232
  className: "cannbot-harness-workflow-anchor",
236
233
  anchor,
237
234
  selectedId: selected?.id,
238
- items: WORKFLOWS.map((workflow) => ({
235
+ items: [{
236
+ id: "",
237
+ label: t("ordinary"),
238
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowIcon, {})
239
+ }, ...WORKFLOWS.map((workflow) => ({
239
240
  id: workflow.id,
240
241
  label: label(workflow),
241
242
  icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowIcon, {})
242
- })),
243
- onSelect: (id) => {
244
- const workflow = WORKFLOWS.find((item) => item.id === id);
245
- if (workflow) pick(workflow);
246
- }
247
- }), failed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
243
+ }))],
244
+ onSelect: pick
245
+ }), saved.error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
248
246
  role: "alert",
249
247
  className: "cannbot-harness-error",
250
248
  children: t("insertFailed")
@@ -262,22 +260,18 @@ window.__ModuleLoader__.load({
262
260
  });
263
261
  }
264
262
  function LegacyWorkflow({ ctx, ...props }) {
265
- const sessions = (0, react.useSyncExternalStore)(ctx.sessions.list.subscribe, ctx.sessions.list.getSnapshot);
263
+ const legacy = ctx;
264
+ const sessions = (0, react.useSyncExternalStore)(legacy.sessions.list.subscribe, legacy.sessions.list.getSnapshot);
266
265
  const input = (0, react.useMemo)(() => {
267
- const scope = sessions.current && ctx.sessions.scope(sessions.current);
266
+ const scope = sessions.current && legacy.sessions.scope(sessions.current);
268
267
  return scope ? ctx.conversation.input.for(scope) : void 0;
269
268
  }, [ctx, sessions.current]);
270
269
  const state = (0, react.useSyncExternalStore)(input?.state.subscribe ?? noSubscribe, input?.state.getSnapshot ?? noSnapshot);
271
- const inputActions = input ? { insertText(text, span) {
272
- const current = input.state.getSnapshot();
273
- if (current.phase !== "plain" || current.draftRev !== span.draftRev) return false;
274
- input.setDraft(current.draft.slice(0, span.start) + text + current.draft.slice(span.end));
275
- return true;
276
- } } : void 0;
277
270
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkflowSelector, {
278
271
  ...props,
272
+ sessionId: sessions.current,
279
273
  useInput: (select) => state ? select(state) : void 0,
280
- inputActions
274
+ inputActions: input ? {} : void 0
281
275
  });
282
276
  }
283
277
  const noSubscribe = () => () => {};
@@ -406,6 +400,146 @@ window.__ModuleLoader__.load({
406
400
  return typeof ctx.slots.inject === "function" ? ctx.slots.inject(name, register) : register();
407
401
  }
408
402
  //#endregion
403
+ //#region src/client/workflow-selection.ts
404
+ const NS = "cannbot-harness";
405
+ const valuesOf = (view) => Object.fromEntries((view?.value.selections ?? []).map((item) => [item.sessionId, item.workflow]));
406
+ function createWorkflowSelection(blockSubmission = () => () => {}) {
407
+ let snapshot = {
408
+ ready: false,
409
+ pending: false,
410
+ error: false,
411
+ values: {}
412
+ };
413
+ let transport;
414
+ let generation = 0;
415
+ let pendingRelease;
416
+ const listeners = /* @__PURE__ */ new Set();
417
+ const publish = (next) => {
418
+ snapshot = next;
419
+ for (const listener of listeners) listener();
420
+ };
421
+ return {
422
+ subscribe(listener) {
423
+ listeners.add(listener);
424
+ return () => {
425
+ listeners.delete(listener);
426
+ };
427
+ },
428
+ getSnapshot: () => snapshot,
429
+ attach(next) {
430
+ transport = next;
431
+ const own = ++generation;
432
+ next.describe().then((view) => {
433
+ if (own !== generation) return;
434
+ const section = view.namespaces.find((item) => item.ns === NS);
435
+ publish({
436
+ ready: !!section,
437
+ pending: false,
438
+ error: !section,
439
+ values: valuesOf(section)
440
+ });
441
+ }).catch(() => {
442
+ if (own === generation) publish({
443
+ ...snapshot,
444
+ ready: false,
445
+ error: true
446
+ });
447
+ });
448
+ return () => {
449
+ if (own === generation) {
450
+ generation++;
451
+ transport = void 0;
452
+ publish({
453
+ ...snapshot,
454
+ ready: false
455
+ });
456
+ }
457
+ };
458
+ },
459
+ async choose(sessionId, workflow, reason = "CANNBot Harness…") {
460
+ if (!transport || !snapshot.ready || snapshot.pending) return;
461
+ if (workflow !== "" && !WORKFLOWS.some((item) => item.id === workflow)) throw new Error("Unknown workflow");
462
+ const current = transport, own = generation;
463
+ const unblock = blockSubmission(sessionId, reason);
464
+ let released = false;
465
+ const release = () => {
466
+ if (!released) {
467
+ released = true;
468
+ unblock();
469
+ }
470
+ };
471
+ pendingRelease = release;
472
+ publish({
473
+ ...snapshot,
474
+ pending: true,
475
+ error: false
476
+ });
477
+ try {
478
+ const view = (await current.describe()).namespaces.find((item) => item.ns === NS);
479
+ if (!view) throw new Error("Workflow settings unavailable");
480
+ const values = {
481
+ ...valuesOf(view),
482
+ [sessionId]: workflow
483
+ };
484
+ const selections = Object.entries(values).filter(([, id]) => id !== "").map(([sessionId, workflow]) => ({
485
+ sessionId,
486
+ workflow
487
+ }));
488
+ const result = await current.update(NS, { selections }, view.revision);
489
+ if (own === generation) publish({
490
+ ready: true,
491
+ pending: false,
492
+ error: false,
493
+ values: valuesOf(result)
494
+ });
495
+ } catch {
496
+ if (own === generation) publish({
497
+ ...snapshot,
498
+ pending: false,
499
+ error: true
500
+ });
501
+ } finally {
502
+ release();
503
+ if (pendingRelease === release) pendingRelease = void 0;
504
+ }
505
+ },
506
+ dispose() {
507
+ generation++;
508
+ transport = void 0;
509
+ pendingRelease?.();
510
+ pendingRelease = void 0;
511
+ listeners.clear();
512
+ }
513
+ };
514
+ }
515
+ /** Both transports are official DSH settings APIs; no private editor access. */
516
+ function connectWorkflowSelection(ctx, selection) {
517
+ ctx.inject(["remote", "remote.settings"], (scoped) => {
518
+ const settings = scoped.remote.settings;
519
+ scoped.effect(() => selection.attach({
520
+ describe: async () => unwrap(await settings.describe()),
521
+ update: async (ns, patch, revision) => unwrap(await settings.update(ns, patch, revision))
522
+ }));
523
+ });
524
+ ctx.inject(["connection"], (scoped) => {
525
+ const api = scoped.connection.api;
526
+ if (!api?.settings) return;
527
+ scoped.effect(() => selection.attach({
528
+ describe: async () => unwrap(await api.settings.describe({})),
529
+ update: async (ns, patch, expectedRevision) => unwrap(await api.settings.update({
530
+ ns,
531
+ patch,
532
+ expectedRevision
533
+ }))
534
+ }));
535
+ });
536
+ }
537
+ function unwrap(response) {
538
+ const result = response.result ?? response;
539
+ if (!result.ok) throw new Error(result.error?.message ?? "Workflow settings failed");
540
+ return result.value;
541
+ }
542
+ //#endregion
409
543
  //#region src/client/index.ts
410
544
  const inject = [
411
545
  "slots",
@@ -415,7 +549,7 @@ window.__ModuleLoader__.load({
415
549
  "conversation"
416
550
  ];
417
551
  /** Register presentation with an explicit disposer so the original entries remain live underneath. */
418
- function mountInterface(ctx) {
552
+ function mountInterface(ctx, selection) {
419
553
  const style = document.createElement("style");
420
554
  style.dataset.cannbotHarness = "interface";
421
555
  style.textContent = interface_css_default;
@@ -440,7 +574,8 @@ window.__ModuleLoader__.load({
440
574
  locale: NAMESPACE
441
575
  }, (props) => (0, react.createElement)(WorkflowCompat, {
442
576
  ...props,
443
- ctx
577
+ ctx,
578
+ selection
444
579
  })))
445
580
  ];
446
581
  return () => {
@@ -449,6 +584,19 @@ window.__ModuleLoader__.load({
449
584
  };
450
585
  }
451
586
  function apply(ctx) {
587
+ const selection = createWorkflowSelection((sessionId, reason) => {
588
+ const blocks = ctx.conversation.blocks;
589
+ const id = sessionId;
590
+ const store = blocks.storeFor(id);
591
+ if (store.getSnapshot() !== void 0) return () => {};
592
+ const block = { reason };
593
+ blocks.set(id, block);
594
+ return () => {
595
+ if (store.getSnapshot() === block) blocks.set(id, void 0);
596
+ };
597
+ });
598
+ connectWorkflowSelection(ctx, selection);
599
+ ctx.effect(() => () => selection.dispose());
452
600
  ctx.effect(() => ctx.locale.register(NAMESPACE, {
453
601
  zh,
454
602
  en,
@@ -460,7 +608,7 @@ window.__ModuleLoader__.load({
460
608
  pt: en
461
609
  }));
462
610
  ctx.effect(() => {
463
- const controller = createPresentationController(() => mountInterface(ctx));
611
+ const controller = createPresentationController(() => mountInterface(ctx, selection));
464
612
  const releaseToggle = injectSlot(ctx, "sidebar.footer.action", () => ctx.slots.register({
465
613
  name: "sidebar.footer.action",
466
614
  id: "cannbot-harness-interface",
package/lib/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["primitives","primitives","LegacyMenu","interfaceCss"],"sources":["../src/client/locales.ts","../src/client/Brand.tsx","../src/workflows.ts","../src/client/WorkflowIcon.tsx","../src/client/WorkflowSelector.tsx","../src/client/WorkflowCompat.tsx","../src/client/theme.ts","../src/client/InterfaceToggle.tsx","../src/client/presentation.ts","../src/client/slot-compat.ts","../src/client/index.ts"],"sourcesContent":["export const PRODUCT = 'CANNBot Harness'\nexport const NAMESPACE = 'cannbotHarness'\nexport const PACKAGE = '@cannbot-plugin/cannbot-harness'\nexport const COMMAND = '/ops-direct-invoke'\n\nexport const zh = {\n workflow: '选择工作流', operator: '算子开发工作流', commandHint: '填入所选工作流指令,由你补充需求后发送。',\n flash: 'Ascend C Flash 核函数开发', registry: 'ACLNN / GEIR 注册算子开发', model: 'NPU 模型推理优化',\n hccl: 'HCCL 通信算子开发', triton: 'Triton 算子开发', catlass: 'CATLASS 算子开发', performance: 'Ascend C 性能调优', pypto: 'PyPTO 算子开发',\n chooseWorkspace: '请先选择工作目录。', insertFailed: '输入框正在处理其他操作,请稍后重试。',\n}\nexport const en: typeof zh = {\n workflow: 'Choose workflow', operator: 'Operator development workflow', commandHint: 'Insert the selected workflow command, add your requirements, then send.',\n flash: 'Ascend C Flash kernel development', registry: 'ACLNN / GEIR operator development', model: 'NPU model inference optimization',\n hccl: 'HCCL communication operators', triton: 'Triton operator development', catlass: 'CATLASS operator development', performance: 'Ascend C performance tuning', pypto: 'PyPTO operator development',\n chooseWorkspace: 'Choose a working directory first.', insertFailed: 'The composer is busy. Please retry.',\n}\nexport type LocaleKey = keyof typeof zh\n","import type { HeroBrandMarkOwnerProps } from '@deepseek-ai/dsh-client-ui-conversation/client'\nimport type { SidebarBrandMarkOwnerProps } from '@deepseek-ai/dsh-client-ui-sidebar/client'\nimport { PRODUCT } from './locales.ts'\n\nexport function Mark({ size }: { size: number }) {\n return <svg width={size} height={size} viewBox=\"0 0 40 40\" aria-hidden=\"true\">\n <rect x=\"1\" y=\"1\" width=\"38\" height=\"38\" rx=\"12\" fill=\"var(--dsw-alias-brand-primary)\" />\n <path d=\"M27 12a11 11 0 1 0 0 16\" fill=\"none\" stroke=\"var(--dsw-alias-label-primary-foreground)\" strokeWidth=\"4\" strokeLinecap=\"round\" />\n </svg>\n}\nexport function SidebarMark({ size }: SidebarBrandMarkOwnerProps) { return <Mark size={size} /> }\nexport function SidebarName() { return <span className=\"cannbot-harness-name\">{PRODUCT}</span> }\nexport function Hero({ size }: HeroBrandMarkOwnerProps) {\n return <span data-cannbot-harness-hero=\"\"><Mark size={size} /><span>{PRODUCT}</span></span>\n}\n","export const WORKFLOWS = [\n { id: 'ops-direct-invoke', label: 'operator' },\n { id: 'ops-direct-invoke-flash', label: 'flash' },\n { id: 'ops-registry-invoke', label: 'registry' },\n { id: 'model-infer-optimize', label: 'model' },\n { id: 'hccl-op-generator', label: 'hccl' },\n { id: 'triton-op-generator', label: 'triton' },\n { id: 'catlass-op-generator', label: 'catlass' },\n { id: 'ops-perf-optimize', label: 'performance' },\n { id: 'pypto-op-orchestrator', label: 'pypto' },\n] as const\n","import * as primitives from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { ComponentType } from 'react'\n\n/** The exact icon component used by DSH's original Standard mode selector. */\nexport function WorkflowIcon({ size = 16 }: { size?: number }) {\n const icons = primitives as unknown as Record<string, ComponentType<{ size?: number }>>\n const Icon = icons.IconAgentPresetOutlineRegular ?? icons.IconAgentPresetOutline16 ?? icons.IconRefreshOutline16\n return Icon ? <Icon size={size} /> : null\n}\n\nexport function ChevronIcon({ size = 12 }: { size?: number }) {\n const icons = primitives as unknown as Record<string, ComponentType<{ size?: number }>>\n const Icon = icons.IconChevronDownOutlineRegular ?? icons.IconChevronDownOutline14\n return Icon ? <Icon size={size} /> : <svg width={size} height={size} viewBox=\"0 0 12 12\" fill=\"none\" aria-hidden=\"true\"><path d=\"m3 4.5 3 3 3-3\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n}\n","import { useState, type ComponentType, type ReactNode } from 'react'\nimport * as primitives from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type {} from '@deepseek-ai/dsh-client-ui-conversation/client'\nimport { WORKFLOWS } from '../workflows.ts'\nimport { WorkflowIcon, ChevronIcon } from './WorkflowIcon.tsx'\n\nexport type WorkflowProps = PropsRuntime<'conversation.hero.agentPreset'> & PropsLocale<'cannbotHarness'>\n\n/** Select a workflow without submitting, replacing text, or discarding reference chips. */\nexport function WorkflowSelector({ inputActions, useInput, t }: WorkflowProps) {\n const input = useInput(state => state)\n const [open, setOpen] = useState(false)\n const [failed, setFailed] = useState(false)\n const selected = WORKFLOWS.find(workflow => input?.draft === `/${workflow.id}` || input?.draft.startsWith(`/${workflow.id} `) || input?.draft.startsWith(`/${workflow.id}\\n`))\n const available = inputActions !== undefined && input !== undefined && input.phase === 'plain'\n const pick = (workflow: typeof WORKFLOWS[number]) => {\n setOpen(false)\n if (!inputActions || !input) return\n if (selected?.id === workflow.id) { setFailed(false); return }\n const oldCommand = selected ? `/${selected.id}` : ''\n const end = oldCommand.length + (oldCommand && input.draft[oldCommand.length] === ' ' ? 1 : 0)\n const accepted = inputActions.insertText(`/${workflow.id} `, { start: 0, end, draftRev: input.draftRev })\n setFailed(!accepted)\n }\n const anchor = (\n <button type=\"button\" className=\"cannbot-harness-workflow-trigger\" aria-label={t('workflow')} aria-haspopup=\"menu\" aria-expanded={open}\n disabled={!available} title={inputActions === undefined ? t('chooseWorkspace') : t('commandHint')}\n onClick={() => setOpen(value => !value)}>\n <WorkflowIcon />\n <span className=\"cannbot-harness-workflow-label\">{selected ? t(selected.label) : t('workflow')}</span><ChevronIcon size={12} />\n </button>\n )\n const label = (workflow: typeof WORKFLOWS[number]) => <span className=\"cannbot-harness-workflow-option\">\n <span>{t(workflow.label)}</span><small>/{workflow.id}</small>\n </span>\n const { Menu, MenuItemButton } = primitives\n const LegacyMenu = Menu as unknown as ComponentType<{ open: boolean; anchor: ReactNode; portal: boolean; className: string; onClose(): void; selectedId?: string; onSelect(id: string): void; items: { id: string; label: ReactNode; icon: ReactNode }[] }>\n return <span className=\"cannbot-harness-workflow\">\n {typeof MenuItemButton === 'function' ? <Menu open={open} onClose={() => setOpen(false)} portal className=\"cannbot-harness-workflow-anchor\" anchor={anchor}>\n {WORKFLOWS.map(workflow => <MenuItemButton key={workflow.id} icon={<WorkflowIcon />} onSelect={() => pick(workflow)}>{label(workflow)}</MenuItemButton>)}\n </Menu> : <LegacyMenu open={open} onClose={() => setOpen(false)} portal className=\"cannbot-harness-workflow-anchor\" anchor={anchor}\n selectedId={selected?.id} items={WORKFLOWS.map(workflow => ({ id: workflow.id, label: label(workflow), icon: <WorkflowIcon /> }))}\n onSelect={id => { const workflow = WORKFLOWS.find(item => item.id === id); if (workflow) pick(workflow) }} />}\n {failed && <span role=\"alert\" className=\"cannbot-harness-error\">{t('insertFailed')}</span>}\n </span>\n}\n","import { useMemo, useSyncExternalStore } from 'react'\nimport type { Context } from '@deepseek-ai/cordis'\nimport type {} from '@deepseek-ai/dsh-client-ui-conversation/client'\nimport { WorkflowSelector, type WorkflowProps } from './WorkflowSelector.tsx'\n\n/** Older DSH declares the hero seat at root scope. Resolve its current session\n * through the public services rather than reaching into the editor or DOM. */\nexport function WorkflowCompat({ ctx, ...props }: WorkflowProps & { ctx: Context }) {\n return typeof props.useInput === 'function'\n ? <WorkflowSelector {...props} />\n : <LegacyWorkflow ctx={ctx} {...props} />\n}\n\nfunction LegacyWorkflow({ ctx, ...props }: WorkflowProps & { ctx: Context }) {\n const sessions = useSyncExternalStore(ctx.sessions.list.subscribe, ctx.sessions.list.getSnapshot) as unknown as { current?: Parameters<Context['sessions']['scope']>[0] }\n const input = useMemo(() => {\n const scope = sessions.current && ctx.sessions.scope(sessions.current)\n return scope ? ctx.conversation.input.for(scope) : undefined\n }, [ctx, sessions.current])\n const state = useSyncExternalStore(input?.state.subscribe ?? noSubscribe, input?.state.getSnapshot ?? noSnapshot)\n const inputActions = input ? {\n insertText(text: string, span: { start: number; end: number; draftRev: number }) {\n const current = input.state.getSnapshot()\n if (current.phase !== 'plain' || current.draftRev !== span.draftRev) return false\n // Public legacy setDraft performs the occurrence diff; images live in a\n // separate store and are never rewritten by this operation.\n input.setDraft(current.draft.slice(0, span.start) + text + current.draft.slice(span.end))\n return true\n },\n } : undefined\n return <WorkflowSelector {...props} useInput={select => state ? select(state) : undefined as never} inputActions={inputActions as WorkflowProps['inputActions']} />\n}\nconst noSubscribe = () => () => {}\nconst noSnapshot = () => undefined\n","import type { ThemeTokenOverrides } from '@deepseek-ai/dsh-client-ui-theme/client'\n\n/** Portal design-v2 palette, applied through the documented theme override layer. */\nexport const cannTheme: ThemeTokenOverrides = Object.fromEntries(Object.entries({\n '--dsw-alias-bg-base': ['#ffffff', '#101114'],\n '--dsw-alias-bg-layer-1': ['#ffffff', '#17191e'],\n '--dsw-alias-bg-layer-2': ['#ffffff', '#1d2026'],\n '--dsw-alias-bg-layer-3': ['#f6f8fa', '#252830'],\n '--dsw-specific-sidebar-fill': ['#f6f8fa', '#14161b'],\n '--dsw-specific-input-major': ['#ffffff', '#1d2026'],\n '--dsw-specific-sidebar-nav-item-active': ['#fdeef0', '#392029'],\n '--dsw-specific-sidebar-nav-item-active-accent': ['#fdeef0', '#392029'],\n '--dsw-alias-label-primary': ['#17181d', '#f3f4f6'],\n '--dsw-alias-label-primary-foreground': ['#ffffff', '#ffffff'],\n '--dsw-alias-label-primary-inverted': ['#ffffff', '#ffffff'],\n '--dsw-alias-label-primary-dimmed': ['#30343e', '#dde1e8'],\n '--dsw-alias-label-primary-bluish': ['#7f0f26', '#ff9aab'],\n '--dsw-alias-label-secondary': ['#59637a', '#b0b8c7'],\n '--dsw-alias-label-tertiary': ['#727d91', '#929db0'],\n '--dsw-alias-brand-primary': ['#da203e', '#ef4560'],\n '--dsw-alias-brand-text': ['#17181d', '#f3f4f6'],\n '--dsw-alias-button-primary-hover': ['#b11430', '#ff647d'],\n '--dsw-alias-button-info-fill': ['#da203e', '#da203e'],\n '--dsw-alias-button-info-hover': ['#b11430', '#b11430'],\n '--dsw-alias-state-business-primary': ['#da203e', '#ff8297'],\n '--dsw-alias-state-business-tertiary': ['#fdeef0', '#392029'],\n '--dsw-alias-link': ['#b11430', '#ff9aab'],\n '--dsw-focus-ring-color': ['#da203e', '#ff8297'],\n '--dsw-alias-border-l1': ['#f0f1f5', '#252830'],\n '--dsw-alias-border-l2': ['#e6e9ef', '#323641'],\n '--dsw-alias-border-l3': ['#dce0e8', '#414754'],\n '--dsw-alias-border-l4': ['#ced4df', '#505867'],\n '--dsw-alias-interactive-bg-hover': ['#eef0f4', '#252830'],\n '--dsw-alias-interactive-bg-active': ['#fdeef0', '#392029'],\n '--dsw-specific-bubble': ['#fff3f5', '#302027'],\n '--dsw-specific-bubble-highlight': ['#fbd6dd', '#59303d'],\n '--dsw-radius-panel': ['18px', '18px'],\n '--dsw-radius-xl': ['14px', '14px'],\n '--dsw-radius-lg': ['12px', '12px'],\n '--dsw-radius-md': ['10px', '10px'],\n '--cann-grid': ['#e6e9ef', '#323641'],\n '--cann-night': ['#0e0f12', '#0e0f12'],\n '--cann-night-label': ['#dde1e8', '#dde1e8'],\n}).map(([name, values]) => [name, { light: values[0]!, dark: values[1]! }]))\n","import { useSyncExternalStore } from 'react'\nimport type { PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PresentationController } from './presentation.ts'\nimport { Mark } from './Brand.tsx'\nimport { PRODUCT } from './locales.ts'\n\nexport function InterfaceToggle({ wide, controller }: PropsRuntime<'sidebar.footer.action'> & { controller: PresentationController }) {\n const enabled = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot)\n return <div className={`cannbot-harness-toggle${wide ? '' : ' cannbot-harness-toggle-compact'}`}>\n <span className=\"cannbot-harness-toggle-name\" title={PRODUCT}><Mark size={20} />{wide && <span>{PRODUCT}</span>}</span>\n <button type=\"button\" role=\"switch\" aria-label={PRODUCT} aria-checked={enabled} title={PRODUCT}\n className=\"cannbot-harness-switch\" onClick={() => controller.setEnabled(!enabled)}><span /></button>\n </div>\n}\n","/** Per-activation UI preference: enabling the plugin always starts with its interface on. */\nexport interface PresentationController {\n getSnapshot(): boolean\n subscribe(listener: () => void): () => void\n setEnabled(enabled: boolean): void\n dispose(): void\n}\nexport function createPresentationController(mount: () => () => void): PresentationController {\n let enabled = true\n let stopped = false\n let unmount: (() => void) | undefined = mount()\n const listeners = new Set<() => void>()\n return {\n getSnapshot: () => enabled,\n subscribe(listener) { listeners.add(listener); return () => { listeners.delete(listener) } },\n setEnabled(next) {\n if (stopped || next === enabled) return\n if (next) unmount = mount()\n else { unmount?.(); unmount = undefined }\n enabled = next\n for (const listener of listeners) listener()\n },\n dispose() { if (stopped) return; stopped = true; unmount?.(); unmount = undefined; listeners.clear() },\n }\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport type { SlotMap } from '@deepseek-ai/dsh-client-ui-slots'\n\n/** Older DSH declares the injected parent modules before this plugin and uses direct register(). */\nexport function injectSlot(ctx: Context, name: keyof SlotMap & string, register: () => () => void): () => void {\n return typeof ctx.slots.inject === 'function' ? ctx.slots.inject(name, register) : register()\n}\n","/** Browser companion using the existing DSH theme, settings and UI slots. */\nimport type { Context } from '@deepseek-ai/cordis'\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-renderer/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-sidebar/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-conversation/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-theme/client'\nimport { en, zh, NAMESPACE, PACKAGE, type LocaleKey } from './locales.ts'\nimport { SidebarMark, SidebarName, Hero } from './Brand.tsx'\nimport { WorkflowCompat } from './WorkflowCompat.tsx'\nimport { cannTheme } from './theme.ts'\nimport interfaceCss from './interface.css?inline'\nimport './controls.css'\nimport { createElement } from 'react'\nimport { InterfaceToggle } from './InterfaceToggle.tsx'\nimport { createPresentationController } from './presentation.ts'\nimport { injectSlot } from './slot-compat.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap { cannbotHarness: LocaleKey }\n}\nexport const inject = ['slots', 'theme', 'locale', 'sessions', 'conversation']\n\n/** Register presentation with an explicit disposer so the original entries remain live underneath. */\nfunction mountInterface(ctx: Context): () => void {\n const style = document.createElement('style')\n style.dataset.cannbotHarness = 'interface'\n style.textContent = interfaceCss\n document.head.append(style)\n const releases = [\n ctx.theme.overrideTokens(PACKAGE, cannTheme),\n injectSlot(ctx, 'sidebar.brand.mark', () => ctx.slots.register({ name: 'sidebar.brand.mark', priority: -100 }, SidebarMark)),\n injectSlot(ctx, 'sidebar.brand.name', () => ctx.slots.register({ name: 'sidebar.brand.name', priority: -100 }, SidebarName)),\n injectSlot(ctx, 'conversation.hero.brand.mark', () => ctx.slots.register({ name: 'conversation.hero.brand.mark', priority: -100 }, Hero)),\n injectSlot(ctx, 'conversation.hero.agentPreset', () => ctx.slots.register({ name: 'conversation.hero.agentPreset', priority: -100, locale: NAMESPACE }, props => createElement(WorkflowCompat, { ...props, ctx }))),\n ]\n return () => { for (const release of releases.reverse()) release(); style.remove() }\n}\n\nexport function apply(ctx: Context): void {\n ctx.effect(() => ctx.locale.register(NAMESPACE, { zh, en, ja: en, es: en, fr: en, de: en, ru: en, pt: en }))\n ctx.effect(() => {\n const controller = createPresentationController(() => mountInterface(ctx))\n const releaseToggle = injectSlot(ctx, 'sidebar.footer.action', () => ctx.slots.register({\n name: 'sidebar.footer.action', id: 'cannbot-harness-interface', order: -100,\n }, props => createElement(InterfaceToggle, { ...props, controller })))\n return () => { releaseToggle(); controller.dispose() }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA,MAAa,UAAU;EACvB,MAAa,YAAY;EACzB,MAAa,UAAU;EAGvB,MAAa,KAAK;GAChB,UAAU;GAAS,UAAU;GAAW,aAAa;GACrD,OAAO;GAAwB,UAAU;GAAuB,OAAO;GACvE,MAAM;GAAe,QAAQ;GAAe,SAAS;GAAgB,aAAa;GAAiB,OAAO;GAC1G,iBAAiB;GAAa,cAAc;EAC9C;EACA,MAAa,KAAgB;GAC3B,UAAU;GAAmB,UAAU;GAAiC,aAAa;GACrF,OAAO;GAAqC,UAAU;GAAqC,OAAO;GAClG,MAAM;GAAgC,QAAQ;GAA+B,SAAS;GAAgC,aAAa;GAA+B,OAAO;GACzK,iBAAiB;GAAqC,cAAc;EACtE;;;ECZA,SAAgB,KAAK,EAAE,QAA0B;GAC/C,OAAO,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;IAAK,O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,SAAS;KAAE,MAAM;KAAsB,UAAU;IAAK,GAAG,WAAW,CAAC;IAC3H,WAAW,KAAK,4BAA4B,IAAI,MAAM,SAAS;KAAE,MAAM;KAAsB,UAAU;IAAK,GAAG,WAAW,CAAC;IAC3H,WAAW,KAAK,sCAAsC,IAAI,MAAM,SAAS;KAAE,MAAM;KAAgC,UAAU;IAAK,GAAG,IAAI,CAAC;IACxI,WAAW,KAAK,uCAAuC,IAAI,MAAM,SAAS;KAAE,MAAM;KAAiC,UAAU;KAAM,QAAQ;IAAU,IAAG,WAAA,GAAA,MAAA,cAAA,CAAuB,gBAAgB;KAAE,GAAG;KAAO;IAAI,CAAC,CAAC,CAAC;GACpN;GACA,aAAa;IAAE,KAAK,MAAM,WAAW,SAAS,QAAQ,GAAG,QAAQ;IAAG,MAAM,OAAO;GAAE;EACrF;EAEA,SAAgB,MAAM,KAAoB;GACxC,IAAI,aAAa,IAAI,OAAO,SAAS,WAAW;IAAE;IAAI;IAAI,IAAI;IAAI,IAAI;IAAI,IAAI;IAAI,IAAI;IAAI,IAAI;IAAI,IAAI;GAAG,CAAC,CAAC;GAC3G,IAAI,aAAa;IACf,MAAM,aAAa,mCAAmC,eAAe,GAAG,CAAC;IACzE,MAAM,gBAAgB,WAAW,KAAK,+BAA+B,IAAI,MAAM,SAAS;KACtF,MAAM;KAAyB,IAAI;KAA6B,OAAO;IACzE,IAAG,WAAA,GAAA,MAAA,cAAA,CAAuB,iBAAiB;KAAE,GAAG;KAAO;IAAW,CAAC,CAAC,CAAC;IACrE,aAAa;KAAE,cAAc;KAAG,WAAW,QAAQ;IAAE;GACvD,CAAC;EACH"}
1
+ {"version":3,"file":"client.js","names":["primitives","primitives","LegacyMenu","raw","interfaceCss"],"sources":["../src/client/locales.ts","../src/client/Brand.tsx","../src/workflows.ts","../src/client/WorkflowIcon.tsx","../src/client/WorkflowSelector.tsx","../src/client/WorkflowCompat.tsx","../src/client/theme.ts","../src/client/InterfaceToggle.tsx","../src/client/presentation.ts","../src/client/slot-compat.ts","../src/client/workflow-selection.ts","../src/client/index.ts"],"sourcesContent":["export const PRODUCT = 'CANNBot Harness'\nexport const NAMESPACE = 'cannbotHarness'\nexport const PACKAGE = '@cannbot-plugin/cannbot-harness'\nexport const COMMAND = '/ops-direct-invoke'\n\nexport const zh = {\n workflow: '选择工作流', ordinary: '普通对话', saving: '正在应用工作流…', operator: '算子开发工作流', commandHint: '发送时自动应用所选工作流,只需填写需求。',\n flash: 'Ascend C Flash 核函数开发', registry: 'ACLNN / GEIR 注册算子开发', model: 'NPU 模型推理优化',\n hccl: 'HCCL 通信算子开发', triton: 'Triton 算子开发', catlass: 'CATLASS 算子开发', performance: 'Ascend C 性能调优', pypto: 'PyPTO 算子开发',\n chooseWorkspace: '请先选择工作目录。', insertFailed: '工作流设置未保存,请稍后重试。',\n}\nexport const en: typeof zh = {\n workflow: 'Choose workflow', ordinary: 'Ordinary conversation', saving: 'Applying workflow…', operator: 'Operator development workflow', commandHint: 'The selected workflow is applied in the background when you send.',\n flash: 'Ascend C Flash kernel development', registry: 'ACLNN / GEIR operator development', model: 'NPU model inference optimization',\n hccl: 'HCCL communication operators', triton: 'Triton operator development', catlass: 'CATLASS operator development', performance: 'Ascend C performance tuning', pypto: 'PyPTO operator development',\n chooseWorkspace: 'Choose a working directory first.', insertFailed: 'The workflow preference was not saved. Please retry.',\n}\nexport type LocaleKey = keyof typeof zh\n","import type { HeroBrandMarkOwnerProps } from '@deepseek-ai/dsh-client-ui-conversation/client'\nimport type { SidebarBrandMarkOwnerProps } from '@deepseek-ai/dsh-client-ui-sidebar/client'\nimport { PRODUCT } from './locales.ts'\n\nexport function Mark({ size }: { size: number }) {\n return <svg width={size} height={size} viewBox=\"0 0 40 40\" aria-hidden=\"true\">\n <rect x=\"1\" y=\"1\" width=\"38\" height=\"38\" rx=\"12\" fill=\"var(--dsw-alias-brand-primary)\" />\n <path d=\"M27 12a11 11 0 1 0 0 16\" fill=\"none\" stroke=\"var(--dsw-alias-label-primary-foreground)\" strokeWidth=\"4\" strokeLinecap=\"round\" />\n </svg>\n}\nexport function SidebarMark({ size }: SidebarBrandMarkOwnerProps) { return <Mark size={size} /> }\nexport function SidebarName() { return <span className=\"cannbot-harness-name\">{PRODUCT}</span> }\nexport function Hero({ size }: HeroBrandMarkOwnerProps) {\n return <span data-cannbot-harness-hero=\"\"><Mark size={size} /><span>{PRODUCT}</span></span>\n}\n","export const WORKFLOWS = [\n { id: 'ops-direct-invoke', label: 'operator' },\n { id: 'ops-direct-invoke-flash', label: 'flash' },\n { id: 'ops-registry-invoke', label: 'registry' },\n { id: 'model-infer-optimize', label: 'model' },\n { id: 'hccl-op-generator', label: 'hccl' },\n { id: 'triton-op-generator', label: 'triton' },\n { id: 'catlass-op-generator', label: 'catlass' },\n { id: 'ops-perf-optimize', label: 'performance' },\n { id: 'pypto-op-orchestrator', label: 'pypto' },\n] as const\n","import * as primitives from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { ComponentType } from 'react'\n\n/** The exact icon component used by DSH's original Standard mode selector. */\nexport function WorkflowIcon({ size = 16 }: { size?: number }) {\n const icons = primitives as unknown as Record<string, ComponentType<{ size?: number }>>\n const Icon = icons.IconAgentPresetOutlineRegular ?? icons.IconAgentPresetOutline16 ?? icons.IconRefreshOutline16\n return Icon ? <Icon size={size} /> : null\n}\n\nexport function ChevronIcon({ size = 12 }: { size?: number }) {\n const icons = primitives as unknown as Record<string, ComponentType<{ size?: number }>>\n const Icon = icons.IconChevronDownOutlineRegular ?? icons.IconChevronDownOutline14\n return Icon ? <Icon size={size} /> : <svg width={size} height={size} viewBox=\"0 0 12 12\" fill=\"none\" aria-hidden=\"true\"><path d=\"m3 4.5 3 3 3-3\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n}\n","import { useState, useSyncExternalStore, type ComponentType, type ReactNode } from 'react'\nimport * as primitives from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type {} from '@deepseek-ai/dsh-client-ui-conversation/client'\nimport { WORKFLOWS } from '../workflows.ts'\nimport { WorkflowIcon, ChevronIcon } from './WorkflowIcon.tsx'\nimport type { WorkflowSelection } from './workflow-selection.ts'\n\nexport type WorkflowProps = PropsRuntime<'conversation.hero.agentPreset'> & PropsLocale<'cannbotHarness'> & { selection: WorkflowSelection }\n\n/** Select a workflow without submitting, replacing text, or discarding reference chips. */\nexport function WorkflowSelector({ sessionId, inputActions, useInput, t, selection }: WorkflowProps) {\n const input = useInput(state => state)\n const saved = useSyncExternalStore(selection.subscribe, selection.getSnapshot)\n const [open, setOpen] = useState(false)\n const selected = WORKFLOWS.find(workflow => sessionId && saved.values[sessionId] === workflow.id)\n const available = !!sessionId && saved.ready && !saved.pending && inputActions !== undefined && input !== undefined && input.phase === 'plain'\n const pick = (id: string) => {\n setOpen(false)\n if (sessionId && available) void selection.choose(sessionId, id, t('saving'))\n }\n const anchor = (\n <button type=\"button\" className=\"cannbot-harness-workflow-trigger\" aria-label={t('workflow')} aria-haspopup=\"menu\" aria-expanded={open}\n disabled={!available} title={inputActions === undefined ? t('chooseWorkspace') : t('commandHint')}\n onClick={() => setOpen(value => !value)}>\n <WorkflowIcon />\n <span className=\"cannbot-harness-workflow-label\">{selected ? t(selected.label) : t('workflow')}</span><ChevronIcon size={12} />\n </button>\n )\n const label = (workflow: typeof WORKFLOWS[number]) => <span className=\"cannbot-harness-workflow-option\">\n <span>{t(workflow.label)}</span>\n </span>\n const { Menu, MenuItemButton } = primitives\n const LegacyMenu = Menu as unknown as ComponentType<{ open: boolean; anchor: ReactNode; portal: boolean; className: string; onClose(): void; selectedId?: string; onSelect(id: string): void; items: { id: string; label: ReactNode; icon: ReactNode }[] }>\n return <span className=\"cannbot-harness-workflow\">\n {typeof MenuItemButton === 'function' ? <Menu open={open} onClose={() => setOpen(false)} portal className=\"cannbot-harness-workflow-anchor\" anchor={anchor}>\n <MenuItemButton icon={<WorkflowIcon />} onSelect={() => pick('')}>{t('ordinary')}</MenuItemButton>\n {WORKFLOWS.map(workflow => <MenuItemButton key={workflow.id} icon={<WorkflowIcon />} onSelect={() => pick(workflow.id)}>{label(workflow)}</MenuItemButton>)}\n </Menu> : <LegacyMenu open={open} onClose={() => setOpen(false)} portal className=\"cannbot-harness-workflow-anchor\" anchor={anchor}\n selectedId={selected?.id} items={[{ id: '', label: t('ordinary'), icon: <WorkflowIcon /> }, ...WORKFLOWS.map(workflow => ({ id: workflow.id, label: label(workflow), icon: <WorkflowIcon /> }))]}\n onSelect={pick} />}\n {saved.error && <span role=\"alert\" className=\"cannbot-harness-error\">{t('insertFailed')}</span>}\n </span>\n}\n","import { useMemo, useSyncExternalStore } from 'react'\nimport type { Context } from '@deepseek-ai/cordis'\nimport type {} from '@deepseek-ai/dsh-client-ui-conversation/client'\nimport { WorkflowSelector, type WorkflowProps } from './WorkflowSelector.tsx'\n\n/** Older DSH declares the hero seat at root scope. Resolve its current session\n * through the public services rather than reaching into the editor or DOM. */\nexport function WorkflowCompat({ ctx, ...props }: WorkflowProps & { ctx: Context }) {\n return typeof props.useInput === 'function'\n ? <WorkflowSelector {...props} />\n : <LegacyWorkflow ctx={ctx} {...props} />\n}\n\nfunction LegacyWorkflow({ ctx, ...props }: WorkflowProps & { ctx: Context }) {\n type Input = ReturnType<Context['conversation']['input']['for']>\n const legacy = ctx as unknown as { sessions: { list: { subscribe(listener: () => void): () => void; getSnapshot(): { current?: string } }; scope(id: string): Context | undefined } }\n const sessions = useSyncExternalStore(legacy.sessions.list.subscribe, legacy.sessions.list.getSnapshot)\n const input = useMemo(() => {\n const scope = sessions.current && legacy.sessions.scope(sessions.current)\n return scope ? ctx.conversation.input.for(scope) as Input : undefined\n }, [ctx, sessions.current])\n const state = useSyncExternalStore(input?.state.subscribe ?? noSubscribe, input?.state.getSnapshot ?? noSnapshot)\n return <WorkflowSelector {...props} sessionId={sessions.current as WorkflowProps['sessionId']} useInput={select => state ? select(state) : undefined as never} inputActions={input ? {} as WorkflowProps['inputActions'] : undefined} />\n}\nconst noSubscribe = () => () => {}\nconst noSnapshot = () => undefined\n","import type { ThemeTokenOverrides } from '@deepseek-ai/dsh-client-ui-theme/client'\n\n/** Portal design-v2 palette, applied through the documented theme override layer. */\nexport const cannTheme: ThemeTokenOverrides = Object.fromEntries(Object.entries({\n '--dsw-alias-bg-base': ['#ffffff', '#101114'],\n '--dsw-alias-bg-layer-1': ['#ffffff', '#17191e'],\n '--dsw-alias-bg-layer-2': ['#ffffff', '#1d2026'],\n '--dsw-alias-bg-layer-3': ['#f6f8fa', '#252830'],\n '--dsw-specific-sidebar-fill': ['#f6f8fa', '#14161b'],\n '--dsw-specific-input-major': ['#ffffff', '#1d2026'],\n '--dsw-specific-sidebar-nav-item-active': ['#fdeef0', '#392029'],\n '--dsw-specific-sidebar-nav-item-active-accent': ['#fdeef0', '#392029'],\n '--dsw-alias-label-primary': ['#17181d', '#f3f4f6'],\n '--dsw-alias-label-primary-foreground': ['#ffffff', '#ffffff'],\n '--dsw-alias-label-primary-inverted': ['#ffffff', '#ffffff'],\n '--dsw-alias-label-primary-dimmed': ['#30343e', '#dde1e8'],\n '--dsw-alias-label-primary-bluish': ['#7f0f26', '#ff9aab'],\n '--dsw-alias-label-secondary': ['#59637a', '#b0b8c7'],\n '--dsw-alias-label-tertiary': ['#727d91', '#929db0'],\n '--dsw-alias-brand-primary': ['#da203e', '#ef4560'],\n '--dsw-alias-brand-text': ['#17181d', '#f3f4f6'],\n '--dsw-alias-button-primary-hover': ['#b11430', '#ff647d'],\n '--dsw-alias-button-info-fill': ['#da203e', '#da203e'],\n '--dsw-alias-button-info-hover': ['#b11430', '#b11430'],\n '--dsw-alias-state-business-primary': ['#da203e', '#ff8297'],\n '--dsw-alias-state-business-tertiary': ['#fdeef0', '#392029'],\n '--dsw-alias-link': ['#b11430', '#ff9aab'],\n '--dsw-focus-ring-color': ['#da203e', '#ff8297'],\n '--dsw-alias-border-l1': ['#f0f1f5', '#252830'],\n '--dsw-alias-border-l2': ['#e6e9ef', '#323641'],\n '--dsw-alias-border-l3': ['#dce0e8', '#414754'],\n '--dsw-alias-border-l4': ['#ced4df', '#505867'],\n '--dsw-alias-interactive-bg-hover': ['#eef0f4', '#252830'],\n '--dsw-alias-interactive-bg-active': ['#fdeef0', '#392029'],\n '--dsw-specific-bubble': ['#fff3f5', '#302027'],\n '--dsw-specific-bubble-highlight': ['#fbd6dd', '#59303d'],\n '--dsw-radius-panel': ['18px', '18px'],\n '--dsw-radius-xl': ['14px', '14px'],\n '--dsw-radius-lg': ['12px', '12px'],\n '--dsw-radius-md': ['10px', '10px'],\n '--cann-grid': ['#e6e9ef', '#323641'],\n '--cann-night': ['#0e0f12', '#0e0f12'],\n '--cann-night-label': ['#dde1e8', '#dde1e8'],\n}).map(([name, values]) => [name, { light: values[0]!, dark: values[1]! }]))\n","import { useSyncExternalStore } from 'react'\nimport type { PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PresentationController } from './presentation.ts'\nimport { Mark } from './Brand.tsx'\nimport { PRODUCT } from './locales.ts'\n\nexport function InterfaceToggle({ wide, controller }: PropsRuntime<'sidebar.footer.action'> & { controller: PresentationController }) {\n const enabled = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot)\n return <div className={`cannbot-harness-toggle${wide ? '' : ' cannbot-harness-toggle-compact'}`}>\n <span className=\"cannbot-harness-toggle-name\" title={PRODUCT}><Mark size={20} />{wide && <span>{PRODUCT}</span>}</span>\n <button type=\"button\" role=\"switch\" aria-label={PRODUCT} aria-checked={enabled} title={PRODUCT}\n className=\"cannbot-harness-switch\" onClick={() => controller.setEnabled(!enabled)}><span /></button>\n </div>\n}\n","/** Per-activation UI preference: enabling the plugin always starts with its interface on. */\nexport interface PresentationController {\n getSnapshot(): boolean\n subscribe(listener: () => void): () => void\n setEnabled(enabled: boolean): void\n dispose(): void\n}\nexport function createPresentationController(mount: () => () => void): PresentationController {\n let enabled = true\n let stopped = false\n let unmount: (() => void) | undefined = mount()\n const listeners = new Set<() => void>()\n return {\n getSnapshot: () => enabled,\n subscribe(listener) { listeners.add(listener); return () => { listeners.delete(listener) } },\n setEnabled(next) {\n if (stopped || next === enabled) return\n if (next) unmount = mount()\n else { unmount?.(); unmount = undefined }\n enabled = next\n for (const listener of listeners) listener()\n },\n dispose() { if (stopped) return; stopped = true; unmount?.(); unmount = undefined; listeners.clear() },\n }\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport type { SlotMap } from '@deepseek-ai/dsh-client-ui-slots'\n\n/** Older DSH declares the injected parent modules before this plugin and uses direct register(). */\nexport function injectSlot(ctx: Context, name: keyof SlotMap & string, register: () => () => void): () => void {\n return typeof ctx.slots.inject === 'function' ? ctx.slots.inject(name, register) : register()\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport type {} from '@deepseek-ai/dsh-api-remotes/client'\nimport { WORKFLOWS } from '../workflows.ts'\n\nconst NS = 'cannbot-harness'\ntype Values = Record<string, string>\ninterface Choice { sessionId: string; workflow: string }\ninterface View { ns: string; value: { selections?: Choice[] }; revision?: number }\nconst valuesOf = (view?: View): Values => Object.fromEntries((view?.value.selections ?? []).map(item => [item.sessionId, item.workflow]))\nexport interface WorkflowTransport {\n describe(): Promise<{ namespaces: View[] }>\n update(ns: string, patch: { selections: Choice[] }, revision?: number): Promise<View>\n}\nexport interface SelectionSnapshot { ready: boolean; pending: boolean; error: boolean; values: Values }\nexport interface WorkflowSelection {\n subscribe(listener: () => void): () => void\n getSnapshot(): SelectionSnapshot\n attach(transport: WorkflowTransport): () => void\n choose(sessionId: string, workflow: string, reason?: string): Promise<void>\n dispose(): void\n}\nexport function createWorkflowSelection(blockSubmission: (sessionId: string, reason: string) => () => void = () => () => {}): WorkflowSelection {\n let snapshot: SelectionSnapshot = { ready: false, pending: false, error: false, values: {} }\n let transport: WorkflowTransport | undefined\n let generation = 0\n let pendingRelease: (() => void) | undefined\n const listeners = new Set<() => void>()\n const publish = (next: SelectionSnapshot) => { snapshot = next; for (const listener of listeners) listener() }\n return {\n subscribe(listener) { listeners.add(listener); return () => { listeners.delete(listener) } },\n getSnapshot: () => snapshot,\n attach(next) {\n transport = next\n const own = ++generation\n void next.describe().then(view => {\n if (own !== generation) return\n const section = view.namespaces.find(item => item.ns === NS)\n publish({ ready: !!section, pending: false, error: !section, values: valuesOf(section) })\n }).catch(() => { if (own === generation) publish({ ...snapshot, ready: false, error: true }) })\n return () => { if (own === generation) { generation++; transport = undefined; publish({ ...snapshot, ready: false }) } }\n },\n async choose(sessionId, workflow, reason = 'CANNBot Harness…') {\n if (!transport || !snapshot.ready || snapshot.pending) return\n if (workflow !== '' && !WORKFLOWS.some(item => item.id === workflow)) throw new Error('Unknown workflow')\n const current = transport, own = generation\n const unblock = blockSubmission(sessionId, reason)\n let released = false\n const release = () => { if (!released) { released = true; unblock() } }\n pendingRelease = release\n publish({ ...snapshot, pending: true, error: false })\n try {\n // Fresh revision prevents simultaneous windows from overwriting selections.\n const view = (await current.describe()).namespaces.find(item => item.ns === NS)\n if (!view) throw new Error('Workflow settings unavailable')\n const values = { ...valuesOf(view), [sessionId]: workflow }\n const selections = Object.entries(values).filter(([, id]) => id !== '').map(([sessionId, workflow]) => ({ sessionId, workflow }))\n const result = await current.update(NS, { selections }, view.revision)\n if (own === generation) publish({ ready: true, pending: false, error: false, values: valuesOf(result) })\n } catch {\n if (own === generation) publish({ ...snapshot, pending: false, error: true })\n } finally {\n release()\n if (pendingRelease === release) pendingRelease = undefined\n }\n },\n dispose() { generation++; transport = undefined; pendingRelease?.(); pendingRelease = undefined; listeners.clear() },\n }\n}\n\n/** Both transports are official DSH settings APIs; no private editor access. */\nexport function connectWorkflowSelection(ctx: Context, selection: WorkflowSelection) {\n ctx.inject(['remote', 'remote.settings'], scoped => {\n const settings = scoped.remote.settings\n scoped.effect(() => selection.attach({\n describe: async () => unwrap(await settings.describe()),\n update: async (ns, patch, revision) => unwrap(await settings.update(ns, patch, revision)),\n }))\n })\n ctx.inject(['connection'], scoped => {\n const api = (scoped as unknown as { connection: { api?: { settings: { describe(payload: object): Promise<unknown>; update(payload: object): Promise<unknown> } } } }).connection.api\n if (!api?.settings) return\n scoped.effect(() => selection.attach({\n describe: async () => unwrap(await api.settings.describe({})),\n update: async (ns, patch, expectedRevision) => unwrap(await api.settings.update({ ns, patch, expectedRevision })),\n }))\n })\n}\nfunction unwrap<T>(response: unknown): T {\n const raw = response as { result?: unknown }\n const result = (raw.result ?? response) as { ok: boolean; value: T; error?: { message: string } }\n if (!result.ok) throw new Error(result.error?.message ?? 'Workflow settings failed')\n return result.value\n}\n","/** Browser companion using the existing DSH theme, settings and UI slots. */\nimport type { Context } from '@deepseek-ai/cordis'\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-renderer/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-sidebar/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-conversation/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-theme/client'\nimport { en, zh, NAMESPACE, PACKAGE, type LocaleKey } from './locales.ts'\nimport { SidebarMark, SidebarName, Hero } from './Brand.tsx'\nimport { WorkflowCompat } from './WorkflowCompat.tsx'\nimport { cannTheme } from './theme.ts'\nimport interfaceCss from './interface.css?inline'\nimport './controls.css'\nimport { createElement } from 'react'\nimport { InterfaceToggle } from './InterfaceToggle.tsx'\nimport { createPresentationController } from './presentation.ts'\nimport { injectSlot } from './slot-compat.ts'\nimport { createWorkflowSelection, connectWorkflowSelection, type WorkflowSelection } from './workflow-selection.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap { cannbotHarness: LocaleKey }\n}\nexport const inject = ['slots', 'theme', 'locale', 'sessions', 'conversation']\n\n/** Register presentation with an explicit disposer so the original entries remain live underneath. */\nfunction mountInterface(ctx: Context, selection: WorkflowSelection): () => void {\n const style = document.createElement('style')\n style.dataset.cannbotHarness = 'interface'\n style.textContent = interfaceCss\n document.head.append(style)\n const releases = [\n ctx.theme.overrideTokens(PACKAGE, cannTheme),\n injectSlot(ctx, 'sidebar.brand.mark', () => ctx.slots.register({ name: 'sidebar.brand.mark', priority: -100 }, SidebarMark)),\n injectSlot(ctx, 'sidebar.brand.name', () => ctx.slots.register({ name: 'sidebar.brand.name', priority: -100 }, SidebarName)),\n injectSlot(ctx, 'conversation.hero.brand.mark', () => ctx.slots.register({ name: 'conversation.hero.brand.mark', priority: -100 }, Hero)),\n injectSlot(ctx, 'conversation.hero.agentPreset', () => ctx.slots.register({ name: 'conversation.hero.agentPreset', priority: -100, locale: NAMESPACE }, props => createElement(WorkflowCompat, { ...props, ctx, selection }))),\n ]\n return () => { for (const release of releases.reverse()) release(); style.remove() }\n}\n\nexport function apply(ctx: Context): void {\n const selection = createWorkflowSelection((sessionId, reason) => {\n const blocks = ctx.conversation.blocks\n const id = sessionId as Parameters<typeof blocks.set>[0]\n const store = blocks.storeFor(id)\n // Do not replace a block owned by another DSH plugin.\n if (store.getSnapshot() !== undefined) return () => {}\n const block = { reason }\n blocks.set(id, block)\n return () => { if (store.getSnapshot() === block) blocks.set(id, undefined) }\n })\n connectWorkflowSelection(ctx, selection)\n ctx.effect(() => () => selection.dispose())\n ctx.effect(() => ctx.locale.register(NAMESPACE, { zh, en, ja: en, es: en, fr: en, de: en, ru: en, pt: en }))\n ctx.effect(() => {\n const controller = createPresentationController(() => mountInterface(ctx, selection))\n const releaseToggle = injectSlot(ctx, 'sidebar.footer.action', () => ctx.slots.register({\n name: 'sidebar.footer.action', id: 'cannbot-harness-interface', order: -100,\n }, props => createElement(InterfaceToggle, { ...props, controller })))\n return () => { releaseToggle(); controller.dispose() }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA,MAAa,UAAU;EACvB,MAAa,YAAY;EACzB,MAAa,UAAU;EAGvB,MAAa,KAAK;GAChB,UAAU;GAAS,UAAU;GAAQ,QAAQ;GAAY,UAAU;GAAW,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MAAM,WAAW,SAAS,QAAQ,GAAG,QAAQ;IAAG,MAAM,OAAO;GAAE;EACrF;EAEA,SAAgB,MAAM,KAAoB;GACxC,MAAM,YAAY,yBAAyB,WAAW,WAAW;IAC/D,MAAM,SAAS,IAAI,aAAa;IAChC,MAAM,KAAK;IACX,MAAM,QAAQ,OAAO,SAAS,EAAE;IAEhC,IAAI,MAAM,YAAY,MAAM,KAAA,GAAW,aAAa,CAAC;IACrD,MAAM,QAAQ,EAAE,OAAO;IACvB,OAAO,IAAI,IAAI,KAAK;IACpB,aAAa;KAAE,IAAI,MAAM,YAAY,MAAM,OAAO,OAAO,IAAI,IAAI,KAAA,CAAS;IAAE;GAC9E,CAAC;GACD,yBAAyB,KAAK,SAAS;GACvC,IAAI,mBAAmB,UAAU,QAAQ,CAAC;GAC1C,IAAI,aAAa,IAAI,OAAO,SAAS,WAAW;IAAE;IAAI;IAAI,IAAI;IAAI,IAAI;IAAI,IAAI;IAAI,IAAI;IAAI,IAAI;IAAI,IAAI;GAAG,CAAC,CAAC;GAC3G,IAAI,aAAa;IACf,MAAM,aAAa,mCAAmC,eAAe,KAAK,SAAS,CAAC;IACpF,MAAM,gBAAgB,WAAW,KAAK,+BAA+B,IAAI,MAAM,SAAS;KACtF,MAAM;KAAyB,IAAI;KAA6B,OAAO;IACzE,IAAG,WAAA,GAAA,MAAA,cAAA,CAAuB,iBAAiB;KAAE,GAAG;KAAO;IAAW,CAAC,CAAC,CAAC;IACrE,aAAa;KAAE,cAAc;KAAG,WAAW,QAAQ;IAAE;GACvD,CAAC;EACH"}
package/lib/index.js CHANGED
@@ -2,9 +2,114 @@ import { FileSystemSkillProvider } from "@deepseek-ai/dsh-skill-filesystem";
2
2
  import { readFileSync } from "node:fs";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { resolve } from "node:path";
5
+ import { createUserMessage } from "@deepseek-ai/dsh-llm";
6
+ import { isUserInvocable, renderSkillContent } from "@deepseek-ai/dsh-skill";
7
+ import z from "@deepseek-ai/schemastery";
8
+ //#region src/workflows.ts
9
+ const WORKFLOWS = [
10
+ {
11
+ id: "ops-direct-invoke",
12
+ label: "operator"
13
+ },
14
+ {
15
+ id: "ops-direct-invoke-flash",
16
+ label: "flash"
17
+ },
18
+ {
19
+ id: "ops-registry-invoke",
20
+ label: "registry"
21
+ },
22
+ {
23
+ id: "model-infer-optimize",
24
+ label: "model"
25
+ },
26
+ {
27
+ id: "hccl-op-generator",
28
+ label: "hccl"
29
+ },
30
+ {
31
+ id: "triton-op-generator",
32
+ label: "triton"
33
+ },
34
+ {
35
+ id: "catlass-op-generator",
36
+ label: "catlass"
37
+ },
38
+ {
39
+ id: "ops-perf-optimize",
40
+ label: "performance"
41
+ },
42
+ {
43
+ id: "pypto-op-orchestrator",
44
+ label: "pypto"
45
+ }
46
+ ];
47
+ //#endregion
48
+ //#region src/workflow-context.ts
49
+ const WORKFLOW_SETTINGS = "cannbot-harness";
50
+ const choiceSchema = () => z.array(z.object({
51
+ sessionId: z.string(),
52
+ workflow: z.union(["", ...WORKFLOWS.map((item) => item.id)])
53
+ })).default([]);
54
+ const selections = choiceSchema();
55
+ const Config = z.object({ selections: typeof selections.volatile === "function" ? selections.volatile() : selections });
56
+ const LegacyConfig = z.object({ selections: choiceSchema() });
57
+ function selectedWorkflows(config) {
58
+ const value = config.selections;
59
+ return Array.isArray(value) ? value : value?.get() ?? [];
60
+ }
61
+ function installWorkflowContext(ctx, config) {
62
+ let read = () => config;
63
+ ctx.inject(["settings"], (scoped) => {
64
+ const settings = scoped.settings;
65
+ if (typeof settings.register === "function") {
66
+ const base = { selections: selectedWorkflows(config).map(({ sessionId, workflow }) => ({
67
+ sessionId,
68
+ workflow
69
+ })) };
70
+ const handle = settings.register(WORKFLOW_SETTINGS, LegacyConfig, { base });
71
+ read = () => handle.get();
72
+ }
73
+ });
74
+ ctx.inject(["agents", "workingDirectory"], (scoped) => {
75
+ scoped.on("agent/pre-step", async ({ agent, signal }, next) => {
76
+ const decision = await next();
77
+ if (decision.kind === "reject") return decision;
78
+ const messages = decision.messages.filter((message) => message.source?.kind !== "cannbot-harness-workflow");
79
+ const id = selectedWorkflows(read()).find((item) => item.sessionId === agent.id)?.workflow;
80
+ if (!id || !WORKFLOWS.some((item) => item.id === id)) return {
81
+ ...decision,
82
+ messages
83
+ };
84
+ const skill = await scoped.skills.get(id, {
85
+ cwd: await scoped.workingDirectory.ensure(agent, signal),
86
+ scope: agent,
87
+ signal
88
+ });
89
+ if (!skill || !isUserInvocable(skill)) throw new Error(`CANNBot Harness workflow is unavailable: ${id}`);
90
+ const source = {
91
+ kind: "cannbot-harness-workflow",
92
+ name: id,
93
+ form: "instructions"
94
+ };
95
+ return {
96
+ ...decision,
97
+ messages: [...messages, createUserMessage({
98
+ source,
99
+ content: [{
100
+ type: "text",
101
+ text: renderSkillContent(skill)
102
+ }]
103
+ })]
104
+ };
105
+ });
106
+ });
107
+ }
108
+ //#endregion
5
109
  //#region src/index.ts
6
110
  const inject = ["skills"];
7
- function apply(ctx) {
111
+ function apply(ctx, config = {}) {
112
+ installWorkflowContext(ctx, config);
8
113
  const base = new URL("../assets/official/", import.meta.url);
9
114
  const catalog = JSON.parse(readFileSync(new URL("catalog.json", base), "utf8"));
10
115
  const byPath = new Map(catalog.exposedSkills.map((skill) => [resolve(fileURLToPath(new URL(skill.path, base))), skill]));
@@ -70,4 +175,4 @@ function apply(ctx) {
70
175
  });
71
176
  }
72
177
  //#endregion
73
- export { apply, inject };
178
+ export { Config, apply, inject };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cannbot-plugin/cannbot-harness",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "CANNBot Harness: all nine official CANNBot plugins and workflows for DSH",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN THIRD_PARTY_NOTICES.md",
@@ -54,11 +54,23 @@
54
54
  ],
55
55
  "peerDependencies": {
56
56
  "@deepseek-ai/cordis": "^4.0.1",
57
- "@deepseek-ai/dsh-skill-filesystem": ">=0.1.1-0 <0.3.0"
57
+ "@deepseek-ai/dsh-skill-filesystem": ">=0.1.1-0 <0.3.0",
58
+ "@deepseek-ai/schemastery": ">=3.18.0 <4",
59
+ "@deepseek-ai/dsh-llm": ">=0.1.1-0 <0.3.0",
60
+ "@deepseek-ai/dsh-skill": ">=0.1.1-0 <0.3.0"
58
61
  },
59
62
  "peerDependenciesMeta": {
60
63
  "@deepseek-ai/dsh-skill-filesystem": {
61
64
  "optional": true
65
+ },
66
+ "@deepseek-ai/schemastery": {
67
+ "optional": true
68
+ },
69
+ "@deepseek-ai/dsh-llm": {
70
+ "optional": true
71
+ },
72
+ "@deepseek-ai/dsh-skill": {
73
+ "optional": true
62
74
  }
63
75
  },
64
76
  "scripts": {