@aipanel/provider-deepseek 1.2.7 → 1.2.9

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.
@@ -1,181 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var bridge_script_exports = {};
19
- __export(bridge_script_exports, {
20
- generateBridgeScript: () => generateBridgeScript
21
- });
22
- module.exports = __toCommonJS(bridge_script_exports);
23
- var import_core = require("@aipanel/core");
24
- var import_constants = require("./constants.cjs");
25
- function generateBridgeScript(options = {}) {
26
- const { theme = "auto", diagnosticsEnabled = false } = options;
27
- return `
28
- (function() {
29
- const CURRENT_SESSION_KEY = ${JSON.stringify(import_constants.DSH_STORAGE_KEYS.CURRENT_SESSION)};
30
- const SELECTION_KEY = ${JSON.stringify(import_constants.DSH_STORAGE_KEYS.SELECTION)};
31
- const DIAGNOSTICS_KEY = ${JSON.stringify(import_constants.DSH_STORAGE_KEYS.DIAGNOSTICS_ENABLED)};
32
- const DIAGNOSTICS_ENABLED = ${JSON.stringify(diagnosticsEnabled)};
33
- const THEME = ${JSON.stringify(theme)};
34
-
35
- // \u8BCA\u65AD\u529F\u80FD\u5F00\u5173\uFF1A\u540C\u6B65\u5199\u5165\uFF08\u4E0D\u4F9D\u8D56 DOM\uFF09\uFF0C\u4FDD\u8BC1 dsh-client apply \u65F6\u5373\u53EF\u8BFB\u5230\u6807\u8BB0\u3002
36
- // bridge \u811A\u672C\u6CE8\u5165\u4E8E <head>\uFF0Cdsh-client \u63D2\u4EF6\u5728\u9875\u9762\u811A\u672C/React \u521D\u59CB\u5316\u540E\u624D apply\uFF0C
37
- // \u82E5\u7B49 DOMContentLoaded \u518D\u5199\u5219\u5B58\u5728\u65F6\u5E8F\u7ADE\u4E89\uFF0C\u89C6\u56FE\u53EF\u80FD\u6F0F\u6CE8\u518C\u3002
38
- try {
39
- if (DIAGNOSTICS_ENABLED) {
40
- localStorage.setItem(DIAGNOSTICS_KEY, "1");
41
- } else {
42
- localStorage.removeItem(DIAGNOSTICS_KEY);
43
- }
44
- } catch (e) { /* ignore */ }
45
-
46
- // \u6865\u63A5\u5C42\u901A\u77E5 dsh-client \u7684\u9009\u4E2D\u5143\u7D20\u63D2\u5165\u4E8B\u4EF6\uFF08\u4E0E opencode \u4E00\u81F4\uFF1A\u9009\u4E2D\u5373\u8FFD\u52A0\u5230\u5BF9\u8BDD\u6846\uFF09
47
- const INSERT_ELEMENT_EVENT = "aipanel:insert-element";
48
-
49
- // === \u8BB0\u5F55\u6700\u8FD1\u9009\u4E2D\u5143\u7D20 ===
50
- // \u4F9B dsh-client \u7684 @aipanel source \u4F5C\u4E3A\u5019\u9009\u8BFB\u53D6\uFF08\u53EF\u591A\u9009\uFF0C\u6700\u591A\u4FDD\u7559 20 \u4E2A\uFF09\uFF0C\u5E76\u6D3E\u53D1
51
- // aipanel:insert-element \u8BA9 dsh-client \u7ACB\u5373\u628A\u5143\u7D20\u8FFD\u52A0\u5230\u5F53\u524D\u4F1A\u8BDD\u8F93\u5165\u6846\u3002
52
- function pushSelection(element) {
53
- if (!element) return;
54
- try {
55
- var list = [];
56
- var raw = localStorage.getItem(SELECTION_KEY);
57
- if (raw) list = JSON.parse(raw) || [];
58
- if (!Array.isArray(list)) list = [];
59
- var exists = list.some(function (e) {
60
- return e && e.filePath === element.filePath && e.line === element.line;
61
- });
62
- if (!exists) list.unshift(element);
63
- if (list.length > 20) list.length = 20;
64
- localStorage.setItem(SELECTION_KEY, JSON.stringify(list));
65
- // \u901A\u77E5 dsh-client \u8FFD\u52A0\u5230\u5BF9\u8BDD\u6846\uFF08\u9009\u4E2D\u5373\u63D2\u5165\uFF0C\u65E0\u9700\u518D\u8F93\u5165 @\uFF09
66
- window.dispatchEvent(new CustomEvent(INSERT_ELEMENT_EVENT, {
67
- detail: { element: element }
68
- }));
69
- } catch (e) { /* ignore */ }
70
- }
71
-
72
- // === \u4E3B\u9898\u540C\u6B65\uFF08UI \u5448\u73B0\uFF1B\u6301\u4E45\u5316\u4EA4\u7531 dsh settings\u300Cui-theme.preference\u300D\uFF0C\u4E0D\u5728\u6B64\u5199 localStorage\uFF09===
73
- // dsh \u7684\u6697\u8272\u7531 body[data-ds-dark-theme] + colorScheme \u5448\u73B0\u3002
74
- // \u6CE8\u610F\uFF1Abridge \u53EF\u80FD\u88AB\u6CE8\u5165\u5230 <head>\uFF0C\u6B64\u65F6 document.body \u5C1A\u4E0D\u5B58\u5728\uFF0C\u987B\u5728 DOM ready \u540E\u518D\u6267\u884C\u3002
75
- // theme \u53C2\u6570\uFF1A"light" | "dark" | "auto"\uFF08auto \u4E0D\u5E72\u9884\uFF0C\u4EA4\u7ED9 dsh \u539F\u751F\u4E3B\u9898\u5904\u7406\uFF09\u3002
76
- function applyTheme(theme) {
77
- if (!document.body) return;
78
- if (theme === "dark") {
79
- document.body.setAttribute("data-ds-dark-theme", "");
80
- document.documentElement.style.colorScheme = "dark";
81
- } else if (theme === "light") {
82
- document.body.removeAttribute("data-ds-dark-theme");
83
- document.documentElement.style.colorScheme = "light";
84
- }
85
- }
86
-
87
- // === \u5E03\u5C40\u8986\u76D6 ===
88
- // \u9690\u85CF dsh \u7684\u4FA7\u8FB9\u680F\u5217\uFF0C\u907F\u514D\u4E0E AIPanel \u81EA\u5E26\u4F1A\u8BDD\u5217\u8868\u91CD\u590D\u3002
89
- // \u7A33\u5B9A\u951A\u70B9\uFF1AAppFrame \u6839\u7F51\u683C\u5728\u4FA7\u8FB9\u680F\u6298\u53E0\u65F6\u5E26 data-sidebar-collapsed\uFF08AIPanel \u7A84 iframe \u4E0B\u6052\u5B58\u5728\uFF09\uFF0C
90
- // \u4FA7\u8FB9\u680F\u5217\u662F\u6839\u7F51\u683C\u7684\u9996\u4E2A\u5B50\u5143\u7D20\u3002
91
- // \u6CE8\u610F\u4E0D\u80FD\u53EA display:none \u5143\u7D20\uFF1A\u663E\u5F0F gridTemplateColumns\uFF08\u5185\u8054\u6837\u5F0F\uFF09\u8F68\u9053\u4E0D\u4F1A\u56E0\u5B50\u9879
92
- // \u9690\u85CF\u800C\u6D88\u5931\uFF0C\u4F1A\u7559\u4E00\u6761\u7A7A\u767D\u5217\uFF0C\u987B\u628A\u9996\u5217\u8F68\u9053\u6539\u6210 auto\uFF08\u5B50\u9879\u9690\u85CF\u540E\u574D\u7F29\u4E3A 0\uFF09\u3002
93
- function applyLayoutOverrides() {
94
- try {
95
- if (document.getElementById("aipanel-layout-overrides")) return;
96
- var style = document.createElement("style");
97
- style.id = "aipanel-layout-overrides";
98
- style.textContent = [
99
- "[data-sidebar-collapsed] {",
100
- " grid-template-columns: auto !important;",
101
- "}",
102
- "[data-sidebar-collapsed] > :first-child {",
103
- " display: none !important;",
104
- "}",
105
- '[aria-label="\\u9009\\u62E9\\u5DE5\\u4F5C\\u533A"] {',
106
- " display: none !important;",
107
- "}",
108
- ].join("\\n");
109
- document.head.appendChild(style);
110
- } catch (e) { /* ignore */ }
111
- }
112
-
113
- // === \u6D88\u606F\u76D1\u542C ===
114
- window.addEventListener("message", function(event) {
115
- if (!event.data) return;
116
-
117
- // \u6838\u5FC3\u5C42\u901A\u77E5\uFF1A\u5207\u6362\u4E3B\u9898\uFF08\u5DE5\u5177\u680F\u4E3B\u9898\u6309\u94AE/\u8DDF\u968F\u7CFB\u7EDF\u53D8\u5316\uFF09\u3002\u52A8\u6001\u5E94\u7528\uFF0C\u65E0\u9700\u91CD\u8F7D\u3002
118
- if (event.data.type === ${JSON.stringify(import_core.WIDGET_MSG.SET_THEME)}) {
119
- applyTheme(event.data.theme);
120
- }
121
-
122
- // \u6838\u5FC3\u5C42\u901A\u77E5\uFF1A\u805A\u7126\u6307\u5B9A\u4F1A\u8BDD\uFF08\u65E0 deepLink \u6A21\u5F0F\uFF09\u3002
123
- // dsh \u7684\u9009\u4E2D\u6001\u6301\u4E45\u5316\u4E3A JSON.stringify({ sessionId, subagentAddress? })\uFF0CSPA \u542F\u52A8\u65F6\u636E\u6B64\u6062\u590D\u3002
124
- if (event.data.type === ${JSON.stringify(import_core.WIDGET_MSG.FOCUS_SESSION)}) {
125
- const sessionId = event.data.sessionId;
126
- if (!sessionId) return;
127
- try {
128
- localStorage.setItem(CURRENT_SESSION_KEY, JSON.stringify({ sessionId }));
129
- } catch (e) {
130
- console.warn("dsh bridge: failed to persist session selection", e);
131
- }
132
- // dsh SPA \u4ECE\u6301\u4E45\u5316\u9009\u4E2D\u6062\u590D\uFF0C\u5237\u65B0\u4EE5\u5207\u6362\u5230\u76EE\u6807\u4F1A\u8BDD
133
- location.reload();
134
- }
135
-
136
- // \u6838\u5FC3\u5C42\u901A\u77E5\uFF1A\u9875\u9762\u9009\u4E2D\u5143\u7D20 \u2192 \u8BB0\u5F55\uFF0C\u4F9B @aipanel \u83DC\u5355\u7B5B\u9009\u540E\u4EE5 reference \u63D2\u5165
137
- if (event.data.type === ${JSON.stringify(import_core.WIDGET_MSG.INSERT_FILE_PART)}) {
138
- pushSelection(event.data.element);
139
- }
140
- });
141
-
142
- // === \u5C31\u7EEA\u901A\u77E5 ===
143
- // \u4E0D\u518D\u7528 MutationObserver \u6BCF\u5E27\u53D1 READY\uFF08\u90A3\u4F1A\u5728 dsh \u521A\u6E32\u67D3\u3001\u76EE\u6807\u4F1A\u8BDD\u5C1A\u672A\u6FC0\u6D3B\u65F6\u5C31
144
- // \u63D0\u524D\u653E\u884C loading\uFF09\u3002\u6539\u4E3A\u76D1\u542C dsh-client \u63D2\u4EF6\u5728"\u76EE\u6807\u4F1A\u8BDD\u6FC0\u6D3B\u4E14\u6E32\u67D3\u7A33\u5B9A"\u540E\u6D3E\u53D1\u7684
145
- // aipanel:session-ready \u4E8B\u4EF6\uFF0C\u6536\u5230\u540E\u4E0A\u62A5 SESSION_READY{sessionId}\u3002
146
- // \u53EA\u53D1 SESSION_READY \u800C\u4E0D\u53D1 READY\uFF1A\u5BA2\u6237\u7AEF\u5DF2\u80FD\u51ED sessionId \u5339\u914D\u5F53\u524D\u4F1A\u8BDD\u51B3\u5B9A\u4F55\u65F6
147
- // \u653E\u884C loading / \u8865\u53D1\u805A\u7126\uFF1B\u907F\u514D\u4E0E"FOCUS_SESSION \u2192 reload \u2192 \u518D\u5C31\u7EEA"\u6784\u6210\u5237\u65B0\u6B7B\u5FAA\u73AF\u3002
148
- const SESSION_READY_EVENT = "aipanel:session-ready";
149
-
150
- function sendSessionReady(sessionId) {
151
- if (window.parent !== window) {
152
- window.parent.postMessage({
153
- type: ${JSON.stringify(import_core.WIDGET_MSG.SESSION_READY)},
154
- sessionId
155
- }, "*");
156
- }
157
- }
158
-
159
- window.addEventListener(SESSION_READY_EVENT, function(e) {
160
- const sessionId = e && e.detail && e.detail.sessionId;
161
- if (!sessionId) return;
162
- sendSessionReady(sessionId);
163
- });
164
-
165
- // \u4E3B\u9898\u540C\u6B65/\u5E03\u5C40\u8986\u76D6\u4ECD\u987B\u5728\u6BCF\u6B21\u9875\u9762\u52A0\u8F7D\u65F6\u751F\u6548\uFF08\u4E0E\u5C31\u7EEA\u5224\u5B9A\u89E3\u8026\uFF0C\u4E0D\u53C2\u4E0E loading \u653E\u884C\uFF09
166
- function init() {
167
- applyTheme(THEME);
168
- applyLayoutOverrides();
169
- }
170
- if (document.readyState === "loading") {
171
- document.addEventListener("DOMContentLoaded", init);
172
- } else {
173
- init();
174
- }
175
- })();
176
- `;
177
- }
178
- // Annotate the CommonJS export names for ESM import in node:
179
- 0 && (module.exports = {
180
- generateBridgeScript
181
- });
@@ -1,13 +0,0 @@
1
- export interface BridgeScriptOptions {
2
- /** 主题模式 */
3
- theme?: "light" | "dark" | "auto";
4
- /** 诊断功能开关(provider option enableDiagnostics;写入 localStorage 供 dsh-client 决定是否注册诊断视图) */
5
- diagnosticsEnabled?: boolean;
6
- }
7
- /**
8
- * 生成 PostMessage Bridge 脚本。
9
- * dsh 无正式"切换会话"URL 钩子,选中态持久化在 localStorage(CURRENT_SESSION),
10
- * 且 SPA 启动时会据此恢复选中——因此桥接采用"写入选中 + 刷新 iframe"的策略。
11
- * 若 dsh 后续暴露正式切会话接口,可替换以下 FOCUS_SESSION 分支。
12
- */
13
- export declare function generateBridgeScript(options?: BridgeScriptOptions): string;