@yfwu2020/dsh-selection-explain 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +103 -13
- package/assets/code.png +0 -0
- package/assets/stage1.png +0 -0
- package/assets/stage2.png +0 -0
- package/assets/web.png +0 -0
- package/cordis.patch.yml +4 -0
- package/lib/client.js +727 -1
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +20 -0
- package/package.json +5 -2
- package/scripts/build-demo-pages.mjs +296 -0
- package/scripts/crop-png.mjs +142 -0
- package/scripts/smoke-bridge.mjs +365 -0
- package/scripts/test-bridge.mjs +408 -0
- package/scripts/test-client.mjs +221 -1
- package/src/client/index.js +727 -1
- package/src/index.ts +18 -0
package/src/index.ts
CHANGED
|
@@ -90,6 +90,16 @@ export interface Config {
|
|
|
90
90
|
toolReadRoot: string
|
|
91
91
|
/** 追问(对话小窗)用的推理档位:通常比首次解读轻,响应更快。 */
|
|
92
92
|
chatReasoningEffort: string
|
|
93
|
+
/**
|
|
94
|
+
* 侧边栏 HTML 预览里的划词桥(默认开)。
|
|
95
|
+
*
|
|
96
|
+
* 侧边栏的预览是不透明源沙箱 iframe,父页面读不到里面的选区 —— 只有往被预览的
|
|
97
|
+
* 文档里注入一段桥脚本才能划词。代价:预览帧要多一个 `allow-scripts`
|
|
98
|
+
* (仍然**没有** `allow-same-origin`,预览页读不到 GUI 数据),基础预览那份
|
|
99
|
+
* 已清洗过的 HTML 的 CSP 会从 `script-src 'none'` 放宽到 `'unsafe-inline'`。
|
|
100
|
+
* 关掉 = 侧边栏网页里不弹「解读」按钮。
|
|
101
|
+
*/
|
|
102
|
+
bridgeSidebarPreview: boolean
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
/** 配置 schema(缺省值即推荐值)。 */
|
|
@@ -145,6 +155,11 @@ export const Config = z.object({
|
|
|
145
155
|
toolResultMaxChars: z.number().min(200).max(20000).default(3000),
|
|
146
156
|
toolReadRoot: z.string().default(''),
|
|
147
157
|
chatReasoningEffort: z.string().default('high'),
|
|
158
|
+
/**
|
|
159
|
+
* 侧边栏 HTML 预览里的划词桥。关掉就不往预览帧里注入桥脚本,
|
|
160
|
+
* 侧边栏网页里选中文字不会再弹「解读」。
|
|
161
|
+
*/
|
|
162
|
+
bridgeSidebarPreview: z.boolean().default(true),
|
|
148
163
|
})
|
|
149
164
|
|
|
150
165
|
/** 联网类工具名:用来判断"首选里的联网工具在不在"。 */
|
|
@@ -843,6 +858,7 @@ export function apply(ctx: Context, rawConfig: Config): void {
|
|
|
843
858
|
toolResultMaxChars: rawConfig?.toolResultMaxChars ?? 3000,
|
|
844
859
|
toolReadRoot: rawConfig?.toolReadRoot ?? '',
|
|
845
860
|
chatReasoningEffort: rawConfig?.chatReasoningEffort ?? 'high',
|
|
861
|
+
bridgeSidebarPreview: rawConfig?.bridgeSidebarPreview ?? true,
|
|
846
862
|
}
|
|
847
863
|
|
|
848
864
|
/** 兜底路由:第一次真实 LLM 调用后捕获。 */
|
|
@@ -1401,6 +1417,8 @@ export function apply(ctx: Context, rawConfig: Config): void {
|
|
|
1401
1417
|
fetchBlocked,
|
|
1402
1418
|
},
|
|
1403
1419
|
sessionContext: config.sessionContext && typeof sessionQuery?.readSurface === 'function',
|
|
1420
|
+
// 侧边栏 HTML 预览里的划词桥开关:客户端据此决定要不要往预览帧注入桥脚本
|
|
1421
|
+
bridgeSidebarPreview: config.bridgeSidebarPreview,
|
|
1404
1422
|
limits: {
|
|
1405
1423
|
maxSelectionChars: config.maxSelectionChars,
|
|
1406
1424
|
maxContextChars: config.maxContextChars,
|