@aipanel/dsh-client 1.3.8 → 1.3.10

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.
Files changed (2) hide show
  1. package/lib/client.js +55 -11
  2. package/package.json +13 -13
package/lib/client.js CHANGED
@@ -30,6 +30,8 @@ __export(index_exports, {
30
30
  module.exports = __toCommonJS(index_exports);
31
31
 
32
32
  // ../../core/es/common/constants.mjs
33
+ var DEPENDENCY_DIR_NAME = "node_modules";
34
+ var DEPENDENCY_SOURCE_NOTE = `\u4F9D\u8D56\u5305\u5185\u6587\u4EF6\uFF08${DEPENDENCY_DIR_NAME}\uFF09\uFF1A\u901A\u5E38\u4E0D\u5E94\u76F4\u63A5\u4FEE\u6539\uFF0C\u9875\u9762\u884C\u4E3A\u8BF7\u6539\u9879\u76EE\u5185\u6E90\u7801`;
33
35
  var EXT_BROADCAST = {
34
36
  PAGE_CONTEXT: "PAGE_CONTEXT",
35
37
  THEME_CHANGE: "THEME_CHANGE",
@@ -43,6 +45,8 @@ var EXT_MSG = {
43
45
  REQUEST_PAGE_CONTEXT: "REQUEST_PAGE_CONTEXT",
44
46
  SELECTION_START: "SELECTION_START",
45
47
  SELECTION_STOP: "SELECTION_STOP",
48
+ /** Side Panel → 目标 Tab:请目标页定位某个已选节点(跳回其页面并呼吸高亮) */
49
+ LOCATE_NODE: "LOCATE_NODE",
46
50
  CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__",
47
51
  /** Side Panel → Background:立即轮询一次并回传当前服务信息 */
48
52
  FORCE_POLL: "FORCE_POLL"
@@ -70,7 +74,9 @@ var WIDGET_MSG = {
70
74
  /** 无 deepLink 能力的 Provider:通知 iframe 聚焦指定会话 */
71
75
  FOCUS_SESSION: "AIPANEL_FOCUS_SESSION",
72
76
  /** 无 deepLink 能力的 Provider:iframe 确认目标会话已激活且渲染稳定(携带 sessionId) */
73
- SESSION_READY: "AIPANEL_SESSION_READY"
77
+ SESSION_READY: "AIPANEL_SESSION_READY",
78
+ /** iframe → 宿主:点节点 chip 时把该节点交回挂件,跳回它被选中时的页面并闪烁高亮;载荷 { element } */
79
+ LOCATE_NODE: "AIPANEL_LOCATE_NODE"
74
80
  };
75
81
  var VUE_DEVTOOLS_TIMELINE_INCLUDE = {
76
82
  SUMMARY: "summary",
@@ -402,6 +408,21 @@ function buildLayoutOverridesCss() {
402
408
  ].join("\n");
403
409
  }
404
410
 
411
+ // dsh-client/src/client/node-reference.ts
412
+ function parseElementRef(ref) {
413
+ try {
414
+ const element = JSON.parse(ref);
415
+ return element && typeof element === "object" ? element : null;
416
+ } catch {
417
+ return null;
418
+ }
419
+ }
420
+ function serializeElementRef(ref) {
421
+ const element = parseElementRef(ref);
422
+ if (!element) return `@${ref}`;
423
+ return toNodeMention(ensureNodeId(element));
424
+ }
425
+
405
426
  // dsh-client/src/client/index.ts
406
427
  var MSG = WIDGET_MSG;
407
428
  var inject = ["slots", "sessions", "inputTriggers", "conversation", "uiWorkspace"];
@@ -411,15 +432,6 @@ var FOCUS_INFLIGHT_TIMEOUT_MS = 1e4;
411
432
  function elementContextRef(e) {
412
433
  return JSON.stringify(e);
413
434
  }
414
- function serializeElement(ref) {
415
- try {
416
- const e = JSON.parse(ref);
417
- if (!e || typeof e !== "object") throw new Error("not an element payload");
418
- return toNodeMention(ensureNodeId(e));
419
- } catch {
420
- return `@${ref}`;
421
- }
422
- }
423
435
  function toReference(e) {
424
436
  const mark = `\u8282\u70B9[${ensureNodeId(e)}]`;
425
437
  return {
@@ -430,6 +442,17 @@ function toReference(e) {
430
442
  clipboardText: `@${mark}`
431
443
  };
432
444
  }
445
+ var elementRegistry = /* @__PURE__ */ new Map();
446
+ var lexiconListeners = /* @__PURE__ */ new Set();
447
+ function notifyLexicon() {
448
+ for (const listener of lexiconListeners) listener();
449
+ }
450
+ function nodeLexicon() {
451
+ return [...elementRegistry.keys()].map((id) => `\u8282\u70B9[${id}]`);
452
+ }
453
+ function nodeIdOfRef(ref) {
454
+ return /n[0-9a-z]+/.exec(ref)?.[0] ?? null;
455
+ }
433
456
  function isEmbedded() {
434
457
  try {
435
458
  return window.parent !== window;
@@ -641,6 +664,9 @@ function apply(ctx, config = {}) {
641
664
  }
642
665
  if (!inputFor) return;
643
666
  const reference = toReference(element);
667
+ const nodeId = ensureNodeId(element);
668
+ elementRegistry.set(nodeId, element);
669
+ notifyLexicon();
644
670
  const attempt = (left) => {
645
671
  let applied = false;
646
672
  try {
@@ -699,9 +725,27 @@ function apply(ctx, config = {}) {
699
725
  name: "aipanel",
700
726
  candidates: async () => [],
701
727
  onPick: () => void 0,
728
+ /**
729
+ * 点 chip:把节点交回父窗(AIPanel 挂件),由挂件跳回它被选中时的页面并呼吸高亮。
730
+ * composer 里的 chip,`ref` 是元素 JSON;发送后只剩 `@节点[id]` 标记,按 id 反查元素表。
731
+ * 独立打开 dsh(非嵌入式)时没有可交的宿主,返回 false 保留编辑器原有手势。
732
+ */
733
+ openReference(_session, reference) {
734
+ const nodeId = nodeIdOfRef(reference.ref);
735
+ const element = parseElementRef(reference.ref) ?? (nodeId ? elementRegistry.get(nodeId) ?? null : null);
736
+ if (!element || !isEmbedded()) return false;
737
+ postToHost(MSG.LOCATE_NODE, { element });
738
+ return true;
739
+ },
702
740
  codec: {
703
741
  clipboardText: (ref) => ref,
704
- serialize: async (ref) => serializeElement(ref)
742
+ serialize: async (ref) => serializeElementRef(ref)
743
+ },
744
+ /** @ 之后的名录:让发送后剩下的 `@节点[id]` 文本也能被本 source 认领/装饰 */
745
+ lexicon: () => nodeLexicon(),
746
+ subscribeLexicon: (_session, listener) => {
747
+ lexiconListeners.add(listener);
748
+ return () => lexiconListeners.delete(listener);
705
749
  }
706
750
  };
707
751
  ctx.effect(() => inputTriggers.registerSource(source), "aipanel: @ codec source");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aipanel/dsh-client",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
4
4
  "type": "module",
5
5
  "description": "AIPanel 浏览器侧插件(dsh web Web Client):注册 @aipanel 文件引用 source,选中元素以 file chip 高亮插入并可供模型解析。",
6
6
  "publishConfig": {
@@ -11,18 +11,18 @@
11
11
  "lib"
12
12
  ],
13
13
  "devDependencies": {
14
- "@aipanel/core": "1.3.8",
15
- "@deepseek-ai/cordis": "~4.0.4",
16
- "@deepseek-ai/dsh-api-session-controller": "^0.1.7-alpha.2",
17
- "@deepseek-ai/dsh-client-store": "^0.1.7-alpha.2",
18
- "@deepseek-ai/dsh-client-ui-conversation": "^0.1.7-alpha.2",
19
- "@deepseek-ai/dsh-client-ui-input-trigger": "^0.1.7-alpha.2",
20
- "@deepseek-ai/dsh-client-ui-primitives": "^0.1.7-alpha.2",
21
- "@deepseek-ai/dsh-client-ui-session": "^0.1.7-alpha.2",
22
- "@deepseek-ai/dsh-client-ui-theme": "^0.1.7-alpha.2",
23
- "@deepseek-ai/dsh-client-ui-tool": "^0.1.7-alpha.2",
24
- "@deepseek-ai/dsh-client-ui-workspace": "^0.1.7-alpha.2",
25
- "@deepseek-ai/dsh-session": "^0.1.7-alpha.2",
14
+ "@aipanel/core": "1.3.10",
15
+ "@deepseek-ai/cordis": "^4.0.4",
16
+ "@deepseek-ai/dsh-api-session-controller": "^0.2.0-rc.1",
17
+ "@deepseek-ai/dsh-client-store": "^0.2.0-rc.1",
18
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.2.0-rc.1",
19
+ "@deepseek-ai/dsh-client-ui-input-trigger": "^0.2.0-rc.1",
20
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.2.0-rc.1",
21
+ "@deepseek-ai/dsh-client-ui-session": "^0.2.0-rc.1",
22
+ "@deepseek-ai/dsh-client-ui-theme": "^0.2.0-rc.1",
23
+ "@deepseek-ai/dsh-client-ui-tool": "^0.2.0-rc.1",
24
+ "@deepseek-ai/dsh-client-ui-workspace": "^0.2.0-rc.1",
25
+ "@deepseek-ai/dsh-session": "^0.2.0-rc.1",
26
26
  "@types/react": "^18.3.0",
27
27
  "esbuild": "^0.25.0",
28
28
  "react": "^18.3.0"