@webskill/chatbot 0.11.0 → 0.12.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/dist/index.d.ts +55 -3
- package/dist/index.js +114 -9
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentLoopConfig, ApprovalScope, BridgeCapabilities, DataSourceInfo, DocxTextExtractor, ExternalSkillProvider, ExternalToolSource, FileSystemProvider, HookRunner, InteractionRequest, InteractionResponse, LifecycleEventInit, LinkedDocumentReader, LlmClient, NetworkPolicy, Page, PageQuery, PdfTextExtractor, RenderBlock, RenderResultRequest, RunSnapshot, RunSnapshotListEntry, RuntimePhase, RuntimeRun, ScriptExecutor, SessionStore, SkillCandidateMarker, SkillCatalogEntry, SkillIntegrityGuard, SkillOutcomeReporter, SkillStateGuard, UiBridge, UiSpecDrafts, UiSpecEvent, UiSpecSnapshot, UiSurfaceActionRequest, UiSurfaceActionResponse, UserProfile, UserProfileExport, WebSkillErrorCode, XlsxTextExtractor, diffUserProfile } from "@webskill/sdk";
|
|
1
|
+
import { AgentLoopConfig, ApprovalScope, BridgeCapabilities, DataSourceInfo, DocumentSurfaceHost, DocxTextExtractor, ExternalSkillProvider, ExternalToolSource, FileSystemProvider, HookRunner, InteractionRequest, InteractionResponse, LifecycleEventInit, LinkedDocumentReader, LlmClient, NetworkPolicy, Page, PageQuery, PdfTextExtractor, RenderBlock, RenderResultRequest, RunSnapshot, RunSnapshotListEntry, RuntimePhase, RuntimeRun, ScriptExecutor, SessionStore, SkillCandidateMarker, SkillCatalogEntry, SkillIntegrityGuard, SkillOutcomeReporter, SkillStateGuard, UiBridge, UiSpecDrafts, UiSpecEvent, UiSpecSnapshot, UiSurfaceActionRequest, UiSurfaceActionResponse, UserProfile, UserProfileExport, WebSkillErrorCode, XlsxTextExtractor, diffUserProfile } from "@webskill/sdk";
|
|
2
2
|
import { SandboxMode, TypeScriptSupportOptions } from "@webskill/sdk/browser";
|
|
3
3
|
import { CustomSurfaceActionEvent, ReactBridgeState, SpecInteractionChannel, SurfaceRegistry, UiSurfaceActionEvent } from "@webskill/sdk/ui-react";
|
|
4
4
|
import { DownloadedFileConsent, DownloadedFileReader, PageActionPolicy, PagePerceptionPolicy, PerceptionPagingBudget, PerceptionRecord, SkillCandidateSink, TodoItem } from "@webskill/sdk/agent";
|
|
@@ -57,6 +57,23 @@ interface DataSourceInfo$1 {
|
|
|
57
57
|
provenance?: 'page-declared' | 'tool-projection';
|
|
58
58
|
}
|
|
59
59
|
//#endregion
|
|
60
|
+
//#region ../runtime/src/interaction/documentSurface.d.ts
|
|
61
|
+
/**
|
|
62
|
+
* 渲染侧端口;由 chatbot 装配,`undefined` 表示本宿主没有文档面(按钮整个不渲染)。
|
|
63
|
+
*
|
|
64
|
+
* 收的是**产物文件名**,不是路径:路径由引擎按 run 拼出并做包含校验,
|
|
65
|
+
* 让声明树给完整路径等于凭空开一个读取面。
|
|
66
|
+
* @experimental
|
|
67
|
+
*/
|
|
68
|
+
interface DocumentSurfacePort {
|
|
69
|
+
open(request: {
|
|
70
|
+
runId: string;
|
|
71
|
+
artifact: string;
|
|
72
|
+
style?: string;
|
|
73
|
+
dataSource: string;
|
|
74
|
+
}): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
60
77
|
//#region ../runtime/src/sandbox/bridgeProtocol.d.ts
|
|
61
78
|
/**
|
|
62
79
|
* 能力模式:true 直通 / false 关闭(TOOL_UNSUPPORTED)/ 'require-approval' 调用前强制授权
|
|
@@ -201,6 +218,18 @@ interface RuntimeSandboxConfig {
|
|
|
201
218
|
* 而本能力的「需批准」是恒定的,放进去会凭空多出一个「开且不批准」的非法组合。
|
|
202
219
|
*/
|
|
203
220
|
downloadedFiles: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* 让技能脚本读用户本轮上传的文件(0.15.0 分册 17)。缺省 `false`。
|
|
223
|
+
*
|
|
224
|
+
* **不放进 `capabilities`**,理由同 `downloadedFiles`:本能力的「需批准」是恒定的。
|
|
225
|
+
* 关闭时脚本上下文里连那两个成员都不存在,而不是存在但总失败。
|
|
226
|
+
*/
|
|
227
|
+
uploadFiles: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* 单个上传文件交给脚本的字节上限(分册 17)。超出即拒,**不截断**
|
|
230
|
+
* ——截一半的 xlsx / 图片解不开,而脚本看不出它残缺。
|
|
231
|
+
*/
|
|
232
|
+
maxUploadFileBytes: number;
|
|
204
233
|
}
|
|
205
234
|
/**
|
|
206
235
|
* 只做类型擦除,不做类型检查。`esbuildUrl` 为绝对 http(s) 地址时按 `remoteUrl` 判定;
|
|
@@ -492,7 +521,7 @@ interface ChatbotHostAdapter {
|
|
|
492
521
|
* PDF 仍然默认直传,能读的端点拿到的还是原件;不注入即没有回退能力。
|
|
493
522
|
*/
|
|
494
523
|
pdfExtractor?: PdfTextExtractor;
|
|
495
|
-
/** 文档读取留痕出口(FR-22.6
|
|
524
|
+
/** 文档读取留痕出口(FR-22.6);分册 17 的 `upload.file.read` 也走这条 */
|
|
496
525
|
documentAudit?: {
|
|
497
526
|
append(event: {
|
|
498
527
|
type: string;
|
|
@@ -513,6 +542,15 @@ interface ChatbotHostAdapter {
|
|
|
513
542
|
/** 「不再询问」的记忆端口;不注入即每次都问 */
|
|
514
543
|
consent?: DownloadedFileConsent;
|
|
515
544
|
};
|
|
545
|
+
/**
|
|
546
|
+
* 文档投放面(0.15.0 分册 13)。宿主交出 viewer 页地址、投放前确认与审计出口,
|
|
547
|
+
* 三件都在 `createDocumentSurfaceHost` 的选项里。
|
|
548
|
+
*
|
|
549
|
+
* **不注入即 `OpenDocument` 按钮整个不渲染**——与 `pagePerception` 同一条装配规矩,
|
|
550
|
+
* 设置抽屉里没有也不会有开关。技能可经 `context.documentSurface` 提前探测。
|
|
551
|
+
* @experimental
|
|
552
|
+
*/
|
|
553
|
+
documentSurface?: DocumentSurfaceHost;
|
|
516
554
|
}
|
|
517
555
|
//#endregion
|
|
518
556
|
//#region src/core/chatEngine.d.ts
|
|
@@ -646,6 +684,16 @@ declare class ChatEngine {
|
|
|
646
684
|
setRenderer(renderer: RendererKind): void;
|
|
647
685
|
/** 非 native 三档共用的交互通道(Chatbot 的 SpecInteraction 订阅/attach;core 只产出 catalog 节点树) */
|
|
648
686
|
get interactionChannel(): SpecInteractionChannel;
|
|
687
|
+
/**
|
|
688
|
+
* 文档投放端口(0.15.0 分册 13)。宿主没注入 `adapter.documentSurface` 时为 `undefined`,
|
|
689
|
+
* 渲染侧据此整个不渲染按钮。
|
|
690
|
+
*
|
|
691
|
+
* 端口实现落在引擎里而不是宿主里,是因为「产物在哪、技能叫什么」这两件事只有引擎知道:
|
|
692
|
+
* 交给宿主就等于把产物目录布局变成宿主必须复刻的知识,两个宿主各抄一份必然分叉,
|
|
693
|
+
* 而那正是本册要消灭的东西。
|
|
694
|
+
* @experimental
|
|
695
|
+
*/
|
|
696
|
+
get documentSurface(): DocumentSurfacePort | undefined;
|
|
649
697
|
/** 探测 @a2ui/lit 是否安装(Appearance/设置区 A2UI 档置灰判定) */
|
|
650
698
|
probeA2uiAvailability(): Promise<boolean>;
|
|
651
699
|
onEvent(listener: (event: ChatEvent) => void): () => void;
|
|
@@ -1467,6 +1515,7 @@ declare const chatbotDictionary: {
|
|
|
1467
1515
|
'surface.readOnlySnapshot': string;
|
|
1468
1516
|
'surface.suggested': string;
|
|
1469
1517
|
'surface.useSuggestion': string;
|
|
1518
|
+
'surface.openDocument': string;
|
|
1470
1519
|
'surface.control.previousPage': string;
|
|
1471
1520
|
'surface.control.previous': string;
|
|
1472
1521
|
'surface.control.nextPage': string;
|
|
@@ -1828,6 +1877,7 @@ declare const chatbotDictionary: {
|
|
|
1828
1877
|
'surface.readOnlySnapshot': string;
|
|
1829
1878
|
'surface.suggested': string;
|
|
1830
1879
|
'surface.useSuggestion': string;
|
|
1880
|
+
'surface.openDocument': string;
|
|
1831
1881
|
'surface.control.previousPage': string;
|
|
1832
1882
|
'surface.control.previous': string;
|
|
1833
1883
|
'surface.control.nextPage': string;
|
|
@@ -2192,6 +2242,7 @@ declare const useT: () => TranslateFn<{
|
|
|
2192
2242
|
'surface.readOnlySnapshot': string;
|
|
2193
2243
|
'surface.suggested': string;
|
|
2194
2244
|
'surface.useSuggestion': string;
|
|
2245
|
+
'surface.openDocument': string;
|
|
2195
2246
|
'surface.control.previousPage': string;
|
|
2196
2247
|
'surface.control.previous': string;
|
|
2197
2248
|
'surface.control.nextPage': string;
|
|
@@ -2553,6 +2604,7 @@ declare const useT: () => TranslateFn<{
|
|
|
2553
2604
|
'surface.readOnlySnapshot': string;
|
|
2554
2605
|
'surface.suggested': string;
|
|
2555
2606
|
'surface.useSuggestion': string;
|
|
2607
|
+
'surface.openDocument': string;
|
|
2556
2608
|
'surface.control.previousPage': string;
|
|
2557
2609
|
'surface.control.previous': string;
|
|
2558
2610
|
'surface.control.nextPage': string;
|
|
@@ -3019,6 +3071,6 @@ declare function ErrorCard({ code, message, loopLimits, onOpenSettings, onDismis
|
|
|
3019
3071
|
* Version of the published `@webskill/chatbot` package, injected at build time.
|
|
3020
3072
|
* @stable
|
|
3021
3073
|
*/
|
|
3022
|
-
declare const CHATBOT_VERSION = "0.
|
|
3074
|
+
declare const CHATBOT_VERSION = "0.12.0";
|
|
3023
3075
|
//#endregion
|
|
3024
3076
|
export { A2uiSurfaceHost, type A2uiSurfaceHostProps, A2uiSurfaceSnapshotHost, type A2uiSurfaceSnapshotHostProps, type AppearanceChange, CHATBOT_VERSION, type ChatAttachmentInput, type ChatAttachmentMeta, type ChatContentPart, ChatEngine, type ChatEngineOptions, type ChatEvent, type ChatInteractionRecord, type ChatLayout, type ChatMessage, type ChatRunPhase, type ChatSessionListResult, type ChatSessionMeta, type ChatTheme, type ChatThinking, type ChatTokenUsage, type ChatToolCall, Chatbot, type ChatbotConfig, type ChatbotGovernancePorts, type ChatbotHostAdapter, type ChatbotProps, CompositeUiBridge, type CompositeUiBridgeDeps, DEFAULT_RENDERER_CAPABILITIES, DEFAULT_RUNTIME_CONFIG_STORAGE_KEY, type DownloadableFile, ErrorCard, type ErrorCardProps, InteractionCard, type InteractionCardProps, InterruptedBanner, type InterruptedBannerProps, type Locale, type LocalizedText, OpenUiSurfaceHost, type OpenUiSurfaceHostProps, OpenUiSurfaceSnapshotHost, type OpenUiSurfaceSnapshotHostProps, type QuickPrompt, type QuickPromptIconName, type RendererCapability, type RendererKind, type ResolvedChatLayout, ResultBlockList, type ResultBlockListProps, ResultBlocksPro, type ResultBlocksProProps, type RunSnapshot, type RuntimeAppearanceConfig, type RuntimeConfig, type RuntimeConfigStore, type RuntimeQuickPrompt, type RuntimeRendererId, type SandboxExecutorDeps, type SettingsSectionId, SkillBadges, SpecInteraction, type SpecInteractionProps, VercelPayloadPreview, type VercelPayloadPreviewProps, VercelSurfaceHost, type VercelSurfaceHostProps, VercelSurfaceSnapshotHost, type VercelSurfaceSnapshotHostProps, chatbotDictionary, configureA2uiMarkdown, createLocalStorageRuntimeConfigStore, createMemoryRuntimeConfigStore, isLlmEntryUsable, pickUsableLlmEntry, probeA2uiAvailability, probeOpenUiAvailability, sandboxExecutorDeps, useT };
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { t as yaml } from "./yaml-C888tCbJ.js";
|
|
|
6
6
|
import { t as json } from "./json-BOcU6nei.js";
|
|
7
7
|
import { t as typescript } from "./typescript-DAau_Qyl.js";
|
|
8
8
|
import { t as jsx$1 } from "./jsx-D2Jv0wvt.js";
|
|
9
|
-
import { BEHAVIOR_RECORDS_KEY, DEFAULT_LOOP_LIMITS, DEFAULT_USER_PROFILE_LIMITS, EventBus, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FsRunTraceStore, FsSessionStore, FsToolStepStore, FullDisclosureRouter, SUPPORTED_DOCUMENT_MIME, SerializingMemoryStore, SkillDiscovery, USER_PROFILE_KEY, WebSkillError, WebSkillRuntime, applyUserProfileImport, assertRemoteUrlAllowed, atomicWriteText, diffUserProfile, exportUserProfile, formatAttachmentText, isUnsupportedRunSnapshot, messageOf, readBehaviorRecords, readUserProfile, refineUserProfile, summarizeRunUsage, summarizeToolCalls, textParts } from "@webskill/sdk";
|
|
9
|
+
import { BEHAVIOR_RECORDS_KEY, DEFAULT_LOOP_LIMITS, DEFAULT_USER_PROFILE_LIMITS, EventBus, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FsRunTraceStore, FsSessionStore, FsToolStepStore, FullDisclosureRouter, SUPPORTED_DOCUMENT_MIME, SerializingMemoryStore, SkillDiscovery, USER_PROFILE_KEY, WebSkillError, WebSkillRuntime, applyUserProfileImport, assertRemoteUrlAllowed, assertSafePathSegment, atomicWriteText, diffUserProfile, exportUserProfile, formatAttachmentText, isUnsupportedRunSnapshot, messageOf, readBehaviorRecords, readUserProfile, refineUserProfile, resolveInsideRoot, sanitizeUntrustedLine, summarizeRunUsage, summarizeToolCalls, textParts } from "@webskill/sdk";
|
|
10
10
|
import { BrowserWorkerScriptExecutor, checkDictationAvailability, compressImageToBudget, createEncryptedMemoryStore, createLlmClient, deleteMemoryEncryptionKey, openMemoryEncryptionKey, probeChromeBuiltinAvailability, startDictation } from "@webskill/sdk/browser";
|
|
11
11
|
import { JsonRenderSpecSurface, NativeSpecSurface, OpenUiSpecSurface, ReactBridgeState, SpecInteractionChannel, SurfaceFormTextsProvider, UiSurfaceSnapshotList, probeJsonRenderAvailability } from "@webskill/sdk/ui-react";
|
|
12
12
|
import { A2UI_SPEC_FORM_PATH, collectFormScopes, createUiCatalogToolSource, fromA2uiSpecAction, fromA2uiSurfaceAction, interactionToFormModel, interactionToUiSpec, loadOpenUiPeers, loadWebSkillLitCatalog, renderMiniChart, shapeInteractionValue, toA2uiSpecMessages, toA2uiSurfaceAction, toVercelToolInvocation, uiCatalog } from "@webskill/sdk/ui";
|
|
@@ -30416,6 +30416,11 @@ const DEFAULT_MAX_DOCUMENT_TEXT_BYTES = 512e3;
|
|
|
30416
30416
|
* 结构化数据不是文档,量级差一个数量级;超出**只拒不截**——截断的 JSON 解不出来。
|
|
30417
30417
|
*/
|
|
30418
30418
|
const DEFAULT_MAX_DATA_SOURCE_BYTES = 1024e3;
|
|
30419
|
+
/**
|
|
30420
|
+
* 单个上传文件交给脚本的字节上限(0.15.0 分册 17,FR-17.5):20 MB。
|
|
30421
|
+
* 取得比模型图片预算宽:字节不进模型上下文,只进脚本,护的是内存不是 token。
|
|
30422
|
+
*/
|
|
30423
|
+
const DEFAULT_MAX_UPLOAD_FILE_BYTES = 20 * 1024 * 1024;
|
|
30419
30424
|
|
|
30420
30425
|
//#endregion
|
|
30421
30426
|
//#region ../runtime/src/engine/limits.ts
|
|
@@ -30589,7 +30594,9 @@ function defaultRuntimeConfig() {
|
|
|
30589
30594
|
allowPrivateHosts: false
|
|
30590
30595
|
},
|
|
30591
30596
|
typescript: { enabled: false },
|
|
30592
|
-
downloadedFiles: false
|
|
30597
|
+
downloadedFiles: false,
|
|
30598
|
+
uploadFiles: false,
|
|
30599
|
+
maxUploadFileBytes: DEFAULT_MAX_UPLOAD_FILE_BYTES
|
|
30593
30600
|
},
|
|
30594
30601
|
llm: { entries: [] },
|
|
30595
30602
|
agentCapabilities: {
|
|
@@ -31708,6 +31715,7 @@ const chatbotDictionary = defineDictionary({
|
|
|
31708
31715
|
"surface.readOnlySnapshot": "This is a saved record — its actions are no longer available.",
|
|
31709
31716
|
"surface.suggested": "Suggested:",
|
|
31710
31717
|
"surface.useSuggestion": "Use",
|
|
31718
|
+
"surface.openDocument": "Open document",
|
|
31711
31719
|
"surface.control.previousPage": "Previous page",
|
|
31712
31720
|
"surface.control.previous": "Previous",
|
|
31713
31721
|
"surface.control.nextPage": "Next page",
|
|
@@ -32069,6 +32077,7 @@ const chatbotDictionary = defineDictionary({
|
|
|
32069
32077
|
"surface.readOnlySnapshot": "这是已保存的记录,其中的操作已不可用。",
|
|
32070
32078
|
"surface.suggested": "建议:",
|
|
32071
32079
|
"surface.useSuggestion": "使用",
|
|
32080
|
+
"surface.openDocument": "打开文档",
|
|
32072
32081
|
"surface.control.previousPage": "上一页",
|
|
32073
32082
|
"surface.control.previous": "上一页",
|
|
32074
32083
|
"surface.control.nextPage": "下一页",
|
|
@@ -32597,11 +32606,18 @@ var ChatEngine = class {
|
|
|
32597
32606
|
#ready;
|
|
32598
32607
|
/** 已装配的 runtime(cancel 等同步委托用;未装配时为 undefined) */
|
|
32599
32608
|
#runtime;
|
|
32609
|
+
/**
|
|
32610
|
+
* 每轮 `send()` 开头刷新的运行时配置快照(0.15.0 分册 15 · FR-15.6)。
|
|
32611
|
+
* 只给那些必须同步回答、又不能等到重建运行时的开关用。
|
|
32612
|
+
*/
|
|
32613
|
+
#liveConfig;
|
|
32600
32614
|
#handles = /* @__PURE__ */ new Map();
|
|
32601
32615
|
#currentSessionId;
|
|
32602
32616
|
#listeners = /* @__PURE__ */ new Set();
|
|
32603
32617
|
/** runId → 已激活技能累积(skill-activated 事件用;终态清理) */
|
|
32604
32618
|
#runSkills = /* @__PURE__ */ new Map();
|
|
32619
|
+
/** 文档投放端口只构造一次:渲染侧把它放进 memo 依赖,每次取新对象会触发无谓重渲染 */
|
|
32620
|
+
#documentSurfacePort;
|
|
32605
32621
|
/** 当前渲染框架档(复合 uiBridge 分发;setRenderer 热切换) */
|
|
32606
32622
|
#renderer;
|
|
32607
32623
|
/** 非 native 三档共用的交互通道(Chatbot 的 SpecInteraction attach 后生效) */
|
|
@@ -32810,6 +32826,52 @@ var ChatEngine = class {
|
|
|
32810
32826
|
get interactionChannel() {
|
|
32811
32827
|
return this.#interactionChannel;
|
|
32812
32828
|
}
|
|
32829
|
+
/**
|
|
32830
|
+
* 文档投放端口(0.15.0 分册 13)。宿主没注入 `adapter.documentSurface` 时为 `undefined`,
|
|
32831
|
+
* 渲染侧据此整个不渲染按钮。
|
|
32832
|
+
*
|
|
32833
|
+
* 端口实现落在引擎里而不是宿主里,是因为「产物在哪、技能叫什么」这两件事只有引擎知道:
|
|
32834
|
+
* 交给宿主就等于把产物目录布局变成宿主必须复刻的知识,两个宿主各抄一份必然分叉,
|
|
32835
|
+
* 而那正是本册要消灭的东西。
|
|
32836
|
+
* @experimental
|
|
32837
|
+
*/
|
|
32838
|
+
get documentSurface() {
|
|
32839
|
+
const host = this.#adapter.documentSurface;
|
|
32840
|
+
if (!host) return void 0;
|
|
32841
|
+
return this.#documentSurfacePort ??= { open: async ({ runId, artifact, style, dataSource }) => {
|
|
32842
|
+
const dir = `${this.#chatRoot}/artifacts/${runId}`;
|
|
32843
|
+
const html = await this.#adapter.storage.readText(this.#artifactPath(dir, artifact));
|
|
32844
|
+
const css = style === void 0 ? void 0 : await this.#adapter.storage.readText(this.#artifactPath(dir, style));
|
|
32845
|
+
await host.open({
|
|
32846
|
+
skillName: await this.#skillNamesOfRun(runId),
|
|
32847
|
+
dataSource: sanitizeUntrustedLine(dataSource),
|
|
32848
|
+
document: {
|
|
32849
|
+
html,
|
|
32850
|
+
...css === void 0 ? {} : { css }
|
|
32851
|
+
}
|
|
32852
|
+
});
|
|
32853
|
+
} };
|
|
32854
|
+
}
|
|
32855
|
+
/**
|
|
32856
|
+
* 产物名 → 绝对路径。`assertSafePathSegment` + `resolveInsideRoot` 两道都不是可选写法:
|
|
32857
|
+
* 少了它们,「组件只收产物名」就退化成「组件收完整路径」,凭空开出一个读取面。
|
|
32858
|
+
*/
|
|
32859
|
+
#artifactPath(dir, artifact) {
|
|
32860
|
+
assertSafePathSegment(artifact, "artifact");
|
|
32861
|
+
return resolveInsideRoot(dir, artifact);
|
|
32862
|
+
}
|
|
32863
|
+
/**
|
|
32864
|
+
* 这次 run 激活过的技能名。它是授权告知的主语,因此**不能**由发出 surface 的技能自报——
|
|
32865
|
+
* 那等于让被授权方自己写授权提示。
|
|
32866
|
+
*
|
|
32867
|
+
* 进行中的 run 读内存累积;已结束的(历史消息里的按钮就是这种)读 trace,
|
|
32868
|
+
* 只读内存会在 run 收尾清表后得到空串。
|
|
32869
|
+
*/
|
|
32870
|
+
async #skillNamesOfRun(runId) {
|
|
32871
|
+
const live = this.#runSkills.get(runId);
|
|
32872
|
+
if (live && live.size > 0) return [...live].sort().join(", ");
|
|
32873
|
+
return [...(await this.#traceStore.get(runId).catch(() => void 0))?.activeSkills ?? []].sort().join(", ");
|
|
32874
|
+
}
|
|
32813
32875
|
/** 探测 @a2ui/lit 是否安装(Appearance/设置区 A2UI 档置灰判定) */
|
|
32814
32876
|
probeA2uiAvailability() {
|
|
32815
32877
|
return probeA2uiAvailability();
|
|
@@ -33007,6 +33069,7 @@ var ChatEngine = class {
|
|
|
33007
33069
|
async send(text, attachments = []) {
|
|
33008
33070
|
if (this.#disposed) throw new WebSkillError("RUN_FAILED", "This ChatEngine was disposed; create a new one to keep chatting.");
|
|
33009
33071
|
if (text.trim() === "" && attachments.length === 0) return;
|
|
33072
|
+
this.#liveConfig = await this.#runtimeConfigStore()?.load();
|
|
33010
33073
|
const admitted = await this.#admitAttachments(attachments);
|
|
33011
33074
|
const runtime = await this.#ensureReady();
|
|
33012
33075
|
const sessionId = this.#currentSessionId ?? (await this.createSession({ title: truncateTitle(text) })).id;
|
|
@@ -33034,12 +33097,36 @@ var ChatEngine = class {
|
|
|
33034
33097
|
});
|
|
33035
33098
|
const handle = this.#sessionHandle(runtime, sessionId);
|
|
33036
33099
|
try {
|
|
33037
|
-
const
|
|
33100
|
+
const uploadFiles = this.#uploadFilesFor(admitted.accepted);
|
|
33101
|
+
const result = await handle.run(prompt, uploadFiles ? { uploadFiles } : {});
|
|
33038
33102
|
await this.#finishRun(sessionId, result);
|
|
33039
33103
|
} catch (e) {
|
|
33040
33104
|
this.#emitError(e);
|
|
33041
33105
|
}
|
|
33042
33106
|
}
|
|
33107
|
+
/**
|
|
33108
|
+
* 本轮触发消息里的附件,包成只对这一次 run 生效的读取端口(0.15.0 分册 17)。
|
|
33109
|
+
* 开关关着就返回 undefined → 脚本上下文里那两个成员整个不存在,
|
|
33110
|
+
* 与「本轮没传附件」(空数组)分得开。
|
|
33111
|
+
*/
|
|
33112
|
+
#uploadFilesFor(attachments) {
|
|
33113
|
+
if (!(this.#liveConfig?.sandbox.uploadFiles ?? false)) return void 0;
|
|
33114
|
+
const files = attachments.map((a) => ({ ...a }));
|
|
33115
|
+
const infos = files.map((a) => ({
|
|
33116
|
+
id: a.id,
|
|
33117
|
+
name: a.name,
|
|
33118
|
+
contentType: a.contentType,
|
|
33119
|
+
size: a.size
|
|
33120
|
+
}));
|
|
33121
|
+
return {
|
|
33122
|
+
list: async () => infos,
|
|
33123
|
+
read: async (id) => {
|
|
33124
|
+
const attachment = files.find((a) => a.id === id);
|
|
33125
|
+
if (!attachment) throw new WebSkillError("UPLOAD_FILE_NOT_FOUND", `Upload file "${id}" is not part of the message that started this run`);
|
|
33126
|
+
return this.#adapter.storage.readBinary(`${this.attachmentsRoot}/${attachment.path}`);
|
|
33127
|
+
}
|
|
33128
|
+
};
|
|
33129
|
+
}
|
|
33043
33130
|
/** 附件落盘根目录(composer 附件适配器写入,send 时读回) */
|
|
33044
33131
|
get attachmentsRoot() {
|
|
33045
33132
|
return `${this.#chatRoot}/attachments`;
|
|
@@ -33185,6 +33272,13 @@ var ChatEngine = class {
|
|
|
33185
33272
|
return this.#ready;
|
|
33186
33273
|
}
|
|
33187
33274
|
/**
|
|
33275
|
+
* `sandbox.downloadedFiles` 的实时取值(分册 15 · FR-15.6)。
|
|
33276
|
+
* 优先读每轮 `send()` 刷新的快照;还没发过消息时回落到装配期的那一份。
|
|
33277
|
+
*/
|
|
33278
|
+
#sandboxDownloadedFiles(assembled) {
|
|
33279
|
+
return (this.#liveConfig ?? assembled)?.sandbox.downloadedFiles === true;
|
|
33280
|
+
}
|
|
33281
|
+
/**
|
|
33188
33282
|
* LLM 选择链:options.llm(demo/测试)→ `RuntimeConfig.llm` 里选中/默认的条目
|
|
33189
33283
|
* → 内置演示。streaming=false 时包装掉 stream(AgentLoop 走 complete)。
|
|
33190
33284
|
*/
|
|
@@ -33450,7 +33544,7 @@ var ChatEngine = class {
|
|
|
33450
33544
|
...this.#adapter.downloads ? [createDownloadedFileToolSource({ policy: new DownloadedFilePolicy({
|
|
33451
33545
|
reader: this.#adapter.downloads.reader,
|
|
33452
33546
|
ui: this.#uiBridge,
|
|
33453
|
-
capabilityEnabled: () => rc
|
|
33547
|
+
capabilityEnabled: () => this.#sandboxDownloadedFiles(rc),
|
|
33454
33548
|
imageCapable: async () => {
|
|
33455
33549
|
return entryCapabilities(pickLlmEntry(await this.#runtimeConfigStore()?.load(), this.#selectedModelId)).image;
|
|
33456
33550
|
},
|
|
@@ -33499,6 +33593,9 @@ var ChatEngine = class {
|
|
|
33499
33593
|
...this.#adapter.xlsxExtractor ? { xlsxExtractor: this.#adapter.xlsxExtractor } : {},
|
|
33500
33594
|
...this.#adapter.pdfExtractor ? { pdfExtractor: this.#adapter.pdfExtractor } : {},
|
|
33501
33595
|
...this.#adapter.documentAudit ? { documentAudit: this.#adapter.documentAudit } : {},
|
|
33596
|
+
...this.#adapter.documentAudit ? { uploadFileAudit: this.#adapter.documentAudit } : {},
|
|
33597
|
+
maxUploadFileBytes: rc?.sandbox.maxUploadFileBytes ?? defaultRuntimeConfig().sandbox.maxUploadFileBytes,
|
|
33598
|
+
...this.#adapter.documentSurface ? { documentSurface: true } : {},
|
|
33502
33599
|
...toolStepStore ? { toolSteps: toolStepStore } : {}
|
|
33503
33600
|
};
|
|
33504
33601
|
const runtime = new WebSkillRuntime({
|
|
@@ -33801,7 +33898,8 @@ function ChatbotSurfaceTexts({ children }) {
|
|
|
33801
33898
|
arrayFirstItemOnly: t("surface.arrayFirstItemOnly"),
|
|
33802
33899
|
readOnlySnapshot: t("surface.readOnlySnapshot"),
|
|
33803
33900
|
suggested: t("surface.suggested"),
|
|
33804
|
-
useSuggestion: t("surface.useSuggestion")
|
|
33901
|
+
useSuggestion: t("surface.useSuggestion"),
|
|
33902
|
+
openDocument: t("surface.openDocument")
|
|
33805
33903
|
}), [t]),
|
|
33806
33904
|
hostControlTexts: useMemo(() => ({
|
|
33807
33905
|
previousPage: t("surface.control.previousPage"),
|
|
@@ -45665,7 +45763,7 @@ function resolveByNonce(bridge, snapshots, event) {
|
|
|
45665
45763
|
* 一组 surface 快照 → 当前渲染档的宿主(分册 17)。
|
|
45666
45764
|
* 四档与原 `HistoricalSurfaces` 一一对应;差别只在 `bridge` 存在时补上动作/草稿回接。
|
|
45667
45765
|
*/
|
|
45668
|
-
function SurfaceByRenderer({ snapshots, renderer, registry, bridge }) {
|
|
45766
|
+
function SurfaceByRenderer({ snapshots, renderer, registry, bridge, documentSurface }) {
|
|
45669
45767
|
const drafts = bridge && snapshots[0]?.runId ? bridge.surfaceDrafts(snapshots[0].runId) : void 0;
|
|
45670
45768
|
const onDraftChange = bridge ? (event) => bridge.setSurfaceDraft(event.runId, event.surfaceId, event.value) : void 0;
|
|
45671
45769
|
if (renderer === "a2ui") {
|
|
@@ -45704,6 +45802,7 @@ function SurfaceByRenderer({ snapshots, renderer, registry, bridge }) {
|
|
|
45704
45802
|
return /* @__PURE__ */ jsx(UiSurfaceSnapshotList, {
|
|
45705
45803
|
snapshots,
|
|
45706
45804
|
...registry ? { registry } : {},
|
|
45805
|
+
...documentSurface ? { documentSurface } : {},
|
|
45707
45806
|
...bridge ? { onAction: (event) => resolveByNonce(bridge, snapshots, event) } : {},
|
|
45708
45807
|
...drafts ? { drafts } : {},
|
|
45709
45808
|
...onDraftChange ? { onDraftChange } : {}
|
|
@@ -45738,6 +45837,7 @@ function InlineSurface({ surfaceId }) {
|
|
|
45738
45837
|
snapshots: [snapshot],
|
|
45739
45838
|
...ctx.renderer ? { renderer: ctx.renderer } : {},
|
|
45740
45839
|
...ctx.registry ? { registry: ctx.registry } : {},
|
|
45840
|
+
...ctx.documentSurface ? { documentSurface: ctx.documentSurface } : {},
|
|
45741
45841
|
...!persisted && bridge ? { bridge } : {}
|
|
45742
45842
|
})
|
|
45743
45843
|
});
|
|
@@ -46571,7 +46671,7 @@ function SkillBadges({ skills }) {
|
|
|
46571
46671
|
//#endregion
|
|
46572
46672
|
//#region src/react/WebSkillMessageExtensions.tsx
|
|
46573
46673
|
/** WebSkill domain content rendered beneath a Base message without choosing its chat layout. */
|
|
46574
|
-
function WebSkillMessageExtensions({ message, onDownload, surfaceRegistry, renderer }) {
|
|
46674
|
+
function WebSkillMessageExtensions({ message, onDownload, surfaceRegistry, documentSurface, renderer }) {
|
|
46575
46675
|
const t = useT();
|
|
46576
46676
|
if (message.role === "user") return null;
|
|
46577
46677
|
const contentParts = message.contentParts ?? [];
|
|
@@ -46592,7 +46692,8 @@ function WebSkillMessageExtensions({ message, onDownload, surfaceRegistry, rende
|
|
|
46592
46692
|
children: /* @__PURE__ */ jsx(SurfaceByRenderer, {
|
|
46593
46693
|
snapshots: renderable,
|
|
46594
46694
|
...renderer ? { renderer } : {},
|
|
46595
|
-
...surfaceRegistry ? { registry: surfaceRegistry } : {}
|
|
46695
|
+
...surfaceRegistry ? { registry: surfaceRegistry } : {},
|
|
46696
|
+
...documentSurface ? { documentSurface } : {}
|
|
46596
46697
|
})
|
|
46597
46698
|
}) : null,
|
|
46598
46699
|
renderable.length < surfaces.filter((snapshot) => !inlineIds.has(snapshot.id)).length ? /* @__PURE__ */ jsx("p", {
|
|
@@ -46719,6 +46820,7 @@ function AssistantUiMessage(props) {
|
|
|
46719
46820
|
...props.bridge ? { bridge: props.bridge } : {},
|
|
46720
46821
|
...props.renderer ? { renderer: props.renderer } : {},
|
|
46721
46822
|
...props.surfaceRegistry ? { registry: props.surfaceRegistry } : {},
|
|
46823
|
+
...props.documentSurface ? { documentSurface: props.documentSurface } : {},
|
|
46722
46824
|
...props.onDownload ? { onDownload: props.onDownload } : {}
|
|
46723
46825
|
}), [
|
|
46724
46826
|
message?.surfaces,
|
|
@@ -46727,6 +46829,7 @@ function AssistantUiMessage(props) {
|
|
|
46727
46829
|
props.bridge,
|
|
46728
46830
|
props.renderer,
|
|
46729
46831
|
props.surfaceRegistry,
|
|
46832
|
+
props.documentSurface,
|
|
46730
46833
|
props.onDownload
|
|
46731
46834
|
]);
|
|
46732
46835
|
if (role === "user") return /* @__PURE__ */ jsxs("div", {
|
|
@@ -46782,6 +46885,7 @@ function AssistantUiMessage(props) {
|
|
|
46782
46885
|
message,
|
|
46783
46886
|
...props.onDownload ? { onDownload: props.onDownload } : {},
|
|
46784
46887
|
...props.surfaceRegistry ? { surfaceRegistry: props.surfaceRegistry } : {},
|
|
46888
|
+
...props.documentSurface ? { documentSurface: props.documentSurface } : {},
|
|
46785
46889
|
...props.renderer ? { renderer: props.renderer } : {}
|
|
46786
46890
|
}) : null,
|
|
46787
46891
|
/* @__PURE__ */ jsx(AssistantUiMessageActions, { ...props })
|
|
@@ -48621,6 +48725,7 @@ function Chatbot({ adapter, config, locale: localeProp, theme: themeProp, render
|
|
|
48621
48725
|
modelLabels,
|
|
48622
48726
|
resolveAttachmentUrl,
|
|
48623
48727
|
...surfaceRegistry ? { surfaceRegistry } : {},
|
|
48728
|
+
...engine.documentSurface ? { documentSurface: engine.documentSurface } : {},
|
|
48624
48729
|
renderer,
|
|
48625
48730
|
bridge: engine.bridge,
|
|
48626
48731
|
...adapter.navigation.openConsoleTrace ? { onViewTrace: adapter.navigation.openConsoleTrace } : {},
|
|
@@ -48756,7 +48861,7 @@ function VercelPayloadPreview({ bridge }) {
|
|
|
48756
48861
|
* Version of the published `@webskill/chatbot` package, injected at build time.
|
|
48757
48862
|
* @stable
|
|
48758
48863
|
*/
|
|
48759
|
-
const CHATBOT_VERSION = "0.
|
|
48864
|
+
const CHATBOT_VERSION = "0.12.0";
|
|
48760
48865
|
|
|
48761
48866
|
//#endregion
|
|
48762
48867
|
export { A2uiSurfaceHost, A2uiSurfaceSnapshotHost, CHATBOT_VERSION, ChatEngine, Chatbot, CompositeUiBridge, DEFAULT_RENDERER_CAPABILITIES, DEFAULT_RUNTIME_CONFIG_STORAGE_KEY, ErrorCard, InteractionCard, InterruptedBanner, OpenUiSurfaceHost, OpenUiSurfaceSnapshotHost, ResultBlockList, ResultBlocksPro, SkillBadges, SpecInteraction, VercelPayloadPreview, VercelSurfaceHost, VercelSurfaceSnapshotHost, chatbotDictionary, configureA2uiMarkdown, createLocalStorageRuntimeConfigStore, createMemoryRuntimeConfigStore, isLlmEntryUsable, pickUsableLlmEntry, probeA2uiAvailability, probeOpenUiAvailability, sandboxExecutorDeps, useT };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webskill/chatbot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@a2ui/web_core": "^0.10.5",
|
|
27
27
|
"@lit/context": "^1.1.0",
|
|
28
28
|
"@openuidev/react-lang": "0.2.8",
|
|
29
|
-
"@webskill/sdk": "^0.
|
|
29
|
+
"@webskill/sdk": "^0.15.0",
|
|
30
30
|
"react": ">=19.0.0",
|
|
31
31
|
"react-dom": ">=19.0.0",
|
|
32
32
|
"zod": "^3.25.0 || ^4.0.0"
|