@webskill/chatbot 0.27.0 → 0.28.0-next.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/dist/index.d.ts CHANGED
@@ -1559,6 +1559,8 @@ declare const chatbotDictionary: {
1559
1559
  'interaction.sandbox.readReference': string;
1560
1560
  'interaction.sandbox.readAsset': string;
1561
1561
  'interaction.sandbox.fetchData': string;
1562
+ 'interaction.controller.dataSource': string;
1563
+ 'interaction.controller.linkedDocument': string;
1562
1564
  'interaction.sandbox.writeArtifact': string;
1563
1565
  'interaction.sandbox.confirm': string;
1564
1566
  'interaction.traceEvidence.title': string;
@@ -2020,6 +2022,8 @@ declare const chatbotDictionary: {
2020
2022
  'interaction.sandbox.readReference': string;
2021
2023
  'interaction.sandbox.readAsset': string;
2022
2024
  'interaction.sandbox.fetchData': string;
2025
+ 'interaction.controller.dataSource': string;
2026
+ 'interaction.controller.linkedDocument': string;
2023
2027
  'interaction.sandbox.writeArtifact': string;
2024
2028
  'interaction.sandbox.confirm': string;
2025
2029
  'interaction.traceEvidence.title': string;
@@ -2484,6 +2488,8 @@ declare const useT: () => TranslateFn<{
2484
2488
  'interaction.sandbox.readReference': string;
2485
2489
  'interaction.sandbox.readAsset': string;
2486
2490
  'interaction.sandbox.fetchData': string;
2491
+ 'interaction.controller.dataSource': string;
2492
+ 'interaction.controller.linkedDocument': string;
2487
2493
  'interaction.sandbox.writeArtifact': string;
2488
2494
  'interaction.sandbox.confirm': string;
2489
2495
  'interaction.traceEvidence.title': string;
@@ -2945,6 +2951,8 @@ declare const useT: () => TranslateFn<{
2945
2951
  'interaction.sandbox.readReference': string;
2946
2952
  'interaction.sandbox.readAsset': string;
2947
2953
  'interaction.sandbox.fetchData': string;
2954
+ 'interaction.controller.dataSource': string;
2955
+ 'interaction.controller.linkedDocument': string;
2948
2956
  'interaction.sandbox.writeArtifact': string;
2949
2957
  'interaction.sandbox.confirm': string;
2950
2958
  'interaction.traceEvidence.title': string;
@@ -3500,6 +3508,6 @@ declare function ErrorCard({ code, message, loopLimits, onOpenSettings, onDismis
3500
3508
  * Version of the published `@webskill/chatbot` package, injected at build time.
3501
3509
  * @stable
3502
3510
  */
3503
- declare const CHATBOT_VERSION = "0.27.0";
3511
+ declare const CHATBOT_VERSION = "0.28.0-next.1";
3504
3512
  //#endregion
3505
3513
  export { A2uiSurfaceHost, type A2uiSurfaceHostProps, A2uiSurfaceSnapshotHost, type A2uiSurfaceSnapshotHostProps, type AppearanceChange, CHATBOT_VERSION, type ChatAttachmentInput, type ChatAttachmentMeta, type ChatComponent, type ChatComponentCallRecord, type ChatComponentConfirmation, type ChatComponentCredentialField, type ChatComponentInvokeContext, type ChatComponentOutcome, type ChatComponentStore, type ChatComponentText, 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, ChatbotVisionDelegate, type ChatbotVisionDelegateOptions, CompositeUiBridge, type CompositeUiBridgeDeps, DEFAULT_RENDERER_CAPABILITIES, DEFAULT_RUNTIME_CONFIG_STORAGE_KEY, type DownloadableFile, type DwgHost, ErrorCard, type ErrorCardProps, type HttpMessageComponentOptions, 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, type VisionDelegationConsent, type VisionDelegationEndpoint, WEB_OFFICE_TEMPLATE_PREFIX, chatbotDictionary, configureA2uiMarkdown, createHttpMessageComponent, createLocalStorageRuntimeConfigStore, createMemoryRuntimeConfigStore, isLlmEntryUsable, pickUsableLlmEntry, probeA2uiAvailability, probeOpenUiAvailability, sandboxExecutorDeps, useT };
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import { ActionBarPrimitive, AttachmentPrimitive, AuiProvider, ComposerPrimitive
23
23
  import { BrowserWorkerScriptExecutor, WebOfficePolicy, capturePhoto, checkCameraAvailability, checkDictationAvailability, compressImageToBudget, createEncryptedMemoryStore, createLlmClient, createWebOfficeToolSource, deleteMemoryEncryptionKey, openCamera, openMemoryEncryptionKey, probeChromeBuiltinAvailability, startDictation, toDocumentImage } from "@webskill/sdk/browser";
24
24
  import { JsonRenderSpecSurface, NativeSpecSurface, OpenUiSpecSurface, ReactBridgeState, SpecInteractionChannel, SurfaceFormTextsProvider, UiSurfaceSnapshotList, probeJsonRenderAvailability } from "@webskill/sdk/ui-react";
25
25
  import { A2UI_SPEC_FORM_PATH, collectFormScopes, createUiCatalogToolSource, fromA2uiSpecAction, fromA2uiSurfaceAction, interactionToFormModel, interactionToUiSpec, loadOpenUiPeers, loadWebSkillLitCatalog, renderMiniChart, shapeInteractionValue, toA2uiSpecMessages, toA2uiSurfaceAction, toVercelToolInvocation, uiCatalog } from "@webskill/sdk/ui";
26
- import { DownloadedFilePolicy, PAGE_ACTION_KINDS, SCROLL_DIRECTIONS, TodoStore, createDelegationToolSource, createDocumentToolSource, createDownloadedFileToolSource, createDwgToolSource, createPageActionToolSource, createPageImageToolSource, createPagePerceptionToolSource, createRemoteImageToolSource, createSkillGenerationToolSource, createSpreadsheetToolSource, createTabWorksetToolSource, createTableQueryToolSource, createTemplateToolSource, createTodoToolSource, isStreamingTableWorkbook, profileStreamingTable, profileTable, sniffDocumentFormat, summarizeStreamingWorkbook, withDelegationOrigin } from "@webskill/sdk/agent";
26
+ import { DownloadedFilePolicy, ImageSourceAuthorizer, PAGE_ACTION_KINDS, SCROLL_DIRECTIONS, TodoStore, createDelegationToolSource, createDocumentToolSource, createDownloadedFileToolSource, createDwgToolSource, createPageActionToolSource, createPageImageToolSource, createPagePerceptionToolSource, createRemoteImageToolSource, createSkillGenerationToolSource, createSpreadsheetToolSource, createTabWorksetToolSource, createTableQueryToolSource, createTemplateToolSource, createTodoToolSource, fetchRemoteImageArtifact, isStreamingTableWorkbook, profileStreamingTable, profileTable, sniffDocumentFormat, summarizeStreamingWorkbook, withDelegationOrigin } from "@webskill/sdk/agent";
27
27
  import { DataRenderers, Tools } from "@assistant-ui/core/react";
28
28
  import { ModelContext, Suggestions } from "@assistant-ui/core/store";
29
29
  import { Derived, attachTransformScopes, useClientLookup, useClientResource } from "@assistant-ui/store";
@@ -26643,6 +26643,8 @@ const chatbotDictionary = defineDictionary({
26643
26643
  "interaction.sandbox.readReference": "Allow the skill “{skill}” to read the reference file “{path}”?",
26644
26644
  "interaction.sandbox.readAsset": "Allow the skill “{skill}” to read the bundled asset “{path}”?",
26645
26645
  "interaction.sandbox.fetchData": "Allow the skill “{skill}” to fetch the data source “{source}”?",
26646
+ "interaction.controller.dataSource": "Allow the assistant to fetch the browser data source “{source}”?",
26647
+ "interaction.controller.linkedDocument": "Allow the assistant to read this linked document? {url}",
26646
26648
  "interaction.sandbox.writeArtifact": "Allow the skill “{skill}” to write the artifact “{path}”?",
26647
26649
  "interaction.sandbox.confirm": "The skill “{skill}” asks for confirmation:",
26648
26650
  "interaction.traceEvidence.title": "Steps this skill claims",
@@ -27104,6 +27106,8 @@ const chatbotDictionary = defineDictionary({
27104
27106
  "interaction.sandbox.readReference": "允许技能「{skill}」读取参考资料「{path}」吗?",
27105
27107
  "interaction.sandbox.readAsset": "允许技能「{skill}」读取随附文件「{path}」吗?",
27106
27108
  "interaction.sandbox.fetchData": "允许技能「{skill}」访问数据源「{source}」吗?",
27109
+ "interaction.controller.dataSource": "允许助手访问浏览器中的数据源「{source}」吗?",
27110
+ "interaction.controller.linkedDocument": "允许助手读取这份链接文档吗?{url}",
27107
27111
  "interaction.sandbox.writeArtifact": "允许技能「{skill}」写出产物「{path}」吗?",
27108
27112
  "interaction.sandbox.confirm": "技能「{skill}」请求确认:",
27109
27113
  "interaction.traceEvidence.title": "该技能声称的步骤",
@@ -28133,89 +28137,6 @@ function createComponentToolSource(options) {
28133
28137
  };
28134
28138
  }
28135
28139
 
28136
- //#endregion
28137
- //#region src/core/imageSource.ts
28138
- /**
28139
- * 授权卡的自述作用域(FR-11.10 / AC-G6)。
28140
- *
28141
- * 卡上写的范围与实际记忆的范围**由这一个函数同时导出**:
28142
- * `key` 直接就是 `ImageSourceAuthorizer` 存进集合里的那个值,
28143
- * `labelKey` 是复选框旁那句话。两者不可能分叉,因为只有一处。
28144
- *
28145
- * 出的是**字典键**而不是成品文案:这里是同步路径,读不到语言,
28146
- * 写死一种语言就把复选框固定成英文了。
28147
- * @experimental
28148
- */
28149
- function describeImageSourceScope(kind) {
28150
- return {
28151
- key: kind,
28152
- labelKey: kind === "page-image" ? "interaction.imageSource.rememberPageImage" : "interaction.imageSource.rememberRemoteImage"
28153
- };
28154
- }
28155
- const MESSAGES = {
28156
- "page-image": "Allow the assistant to copy a picture from the page you are on into the document it is preparing? The picture is saved with this conversation’s files.",
28157
- "remote-image": "Allow the assistant to download an image from the web into the document it is preparing? The site hosting it will see that the request came from you."
28158
- };
28159
- /**
28160
- * 图片来源的会话内授权(分册 11 §3.3)。
28161
- *
28162
- * 记忆随会话生灭:`forgetSessionDecisions()` 在新建 / 切换会话时调,新会话重新问。
28163
- * 没有任何持久化端口——本版刻意不做跨会话记忆,那是比用户预期更宽的授权。
28164
- * @experimental
28165
- */
28166
- var ImageSourceAuthorizer = class {
28167
- #ui;
28168
- #approved = /* @__PURE__ */ new Set();
28169
- /** 同一类来源的并发请求搭同一次询问,不各弹各的(同视觉委派 FR-26.8) */
28170
- #asking = /* @__PURE__ */ new Map();
28171
- #seq = 0;
28172
- constructor(options) {
28173
- this.#ui = options.ui;
28174
- }
28175
- forgetSessionDecisions() {
28176
- this.#approved.clear();
28177
- }
28178
- /**
28179
- * 记忆粒度是**来源类型**,不是域名(FR-13.7)。因此同一类的并发请求搭同一次询问,
28180
- * 卡上也只会出现其中一个 URL——这正是为什么卡文必须把
28181
- * 「本次对话内所有外链图片」说出来,而不是只展示那一个域名。
28182
- */
28183
- async authorize(kind, details = {}) {
28184
- if (this.#approved.has(kind)) return true;
28185
- const pending = this.#asking.get(kind);
28186
- if (pending !== void 0) return await pending;
28187
- const ask = this.#ask(kind, details);
28188
- this.#asking.set(kind, ask);
28189
- try {
28190
- return await ask;
28191
- } finally {
28192
- this.#asking.delete(kind);
28193
- }
28194
- }
28195
- async #ask(kind, details) {
28196
- this.#seq += 1;
28197
- const scope = describeImageSourceScope(kind);
28198
- const { note, url } = details;
28199
- const response = await this.#ui.request({
28200
- type: "authorize",
28201
- id: `image-source-${kind}-${String(this.#seq)}`,
28202
- capability: "readImageSource",
28203
- message: note === void 0 ? MESSAGES[kind] : `${MESSAGES[kind]} The assistant says: ${note}`,
28204
- details: {
28205
- kind: scope.key,
28206
- ...note === void 0 ? {} : { note },
28207
- ...url === void 0 ? {} : { url },
28208
- rememberable: true,
28209
- rememberScope: "session",
28210
- rememberLabelKey: scope.labelKey
28211
- }
28212
- });
28213
- if (response.cancelled === true || response.value === false) return false;
28214
- if (response.remembered === true) this.#approved.add(scope.key);
28215
- return true;
28216
- }
28217
- };
28218
-
28219
28140
  //#endregion
28220
28141
  //#region src/core/markdownBoundary.ts
28221
28142
  /**
@@ -29777,40 +29698,18 @@ var ChatEngine = class {
29777
29698
  * 「先抓回来再丢掉」时用户的 IP 已经交出去了。
29778
29699
  */
29779
29700
  async #fetchRemoteImage(host, artifacts, input, runId) {
29780
- if (runId === void 0) throw new WebSkillError("TOOL_EXECUTION_FAILED", "Downloading an image requires an active run.");
29781
- const note = input.note === void 0 ? void 0 : sanitizeUntrustedLine(input.note);
29782
- if (!await (this.#imageSources ??= new ImageSourceAuthorizer({ ui: this.#uiBridge })).authorize("remote-image", {
29783
- ...note === void 0 ? {} : { note },
29784
- url: sanitizeUntrustedLine(input.url)
29785
- })) return {
29786
- reason: "the user declined to let the assistant download images from the web",
29787
- kind: "declined"
29788
- };
29789
- const fetched = await host.fetch(input.url, MAX_DOCUMENT_IMAGE_BYTES);
29790
- if ("kind" in fetched) return {
29791
- reason: fetched.reason,
29792
- kind: fetched.kind
29793
- };
29794
- const seq = (this.#remoteImageSeq.get(runId) ?? 0) + 1;
29795
- this.#remoteImageSeq.set(runId, seq);
29796
- const path = `remote-image-${String(seq)}.${fetched.mimeType === "image/jpeg" ? "jpg" : "png"}`;
29797
- await artifacts.createBinaryArtifact({
29701
+ return await fetchRemoteImageArtifact({
29702
+ host,
29703
+ artifacts,
29704
+ authorizer: this.#imageSources ??= new ImageSourceAuthorizer({ ui: this.#uiBridge }),
29705
+ input,
29798
29706
  runId,
29799
- path,
29800
- content: Uint8Array.from(atob(fetched.data), (char) => char.charCodeAt(0)),
29801
- mimeType: fetched.mimeType,
29802
- metadata: { resultCard: false }
29707
+ nextPath: (mimeType) => {
29708
+ const seq = (this.#remoteImageSeq.get(runId ?? "") ?? 0) + 1;
29709
+ this.#remoteImageSeq.set(runId ?? "", seq);
29710
+ return `remote-image-${String(seq)}.${mimeType === "image/jpeg" ? "jpg" : "png"}`;
29711
+ }
29803
29712
  });
29804
- return {
29805
- artifact: `artifact:${path}`,
29806
- width: fetched.width,
29807
- height: fetched.height,
29808
- bytes: fetched.bytes,
29809
- ...input.describe === true ? {
29810
- data: fetched.data,
29811
- mimeType: fetched.mimeType
29812
- } : {}
29813
- };
29814
29713
  }
29815
29714
  /**
29816
29715
  * 这次 run 激活过的技能名。它是授权告知的主语,因此**不能**由发出 surface 的技能自报——
@@ -32881,6 +32780,17 @@ function localizedAuthorizeMessage(request, t) {
32881
32780
  const component = componentDetails(request.details);
32882
32781
  if (component !== void 0) return componentMessage(component, t);
32883
32782
  }
32783
+ if (request.capability === "readLinkedDocument") {
32784
+ const details = request.details;
32785
+ const url = typeof details === "object" && details !== null ? details["url"] : void 0;
32786
+ if (typeof url !== "string") return void 0;
32787
+ return t("interaction.controller.linkedDocument", { url });
32788
+ }
32789
+ if (request.capability === "fetchData") {
32790
+ const details = request.details;
32791
+ const record = typeof details === "object" && details !== null ? details : {};
32792
+ if (record["skill"] === void 0 && typeof record["sourceId"] === "string") return t("interaction.controller.dataSource", { source: record["sourceId"] });
32793
+ }
32884
32794
  if (request.capability === "readReference" || request.capability === "readAsset" || request.capability === "writeArtifact" || request.capability === "fetchData" || request.capability === "confirm") {
32885
32795
  const details = sandboxDetails(request.details);
32886
32796
  if (details === void 0) return void 0;
@@ -47789,7 +47699,7 @@ function VercelPayloadPreview({ bridge }) {
47789
47699
  * Version of the published `@webskill/chatbot` package, injected at build time.
47790
47700
  * @stable
47791
47701
  */
47792
- const CHATBOT_VERSION = "0.27.0";
47702
+ const CHATBOT_VERSION = "0.28.0-next.1";
47793
47703
 
47794
47704
  //#endregion
47795
47705
  export { A2uiSurfaceHost, A2uiSurfaceSnapshotHost, CHATBOT_VERSION, ChatEngine, Chatbot, ChatbotVisionDelegate, CompositeUiBridge, DEFAULT_RENDERER_CAPABILITIES, DEFAULT_RUNTIME_CONFIG_STORAGE_KEY, ErrorCard, InteractionCard, InterruptedBanner, OpenUiSurfaceHost, OpenUiSurfaceSnapshotHost, ResultBlockList, ResultBlocksPro, SkillBadges, SpecInteraction, VercelPayloadPreview, VercelSurfaceHost, VercelSurfaceSnapshotHost, WEB_OFFICE_TEMPLATE_PREFIX, chatbotDictionary, configureA2uiMarkdown, createHttpMessageComponent, 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.27.0",
3
+ "version": "0.28.0-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -38,7 +38,7 @@
38
38
  "@a2ui/web_core": "^0.10.5",
39
39
  "@lit/context": "^1.1.0",
40
40
  "@openuidev/react-lang": "0.2.8",
41
- "@webskill/sdk": "^0.30.0",
41
+ "@webskill/sdk": "^0.31.0-next.1",
42
42
  "mermaid": "^12.0.0",
43
43
  "react": ">=19.0.0",
44
44
  "react-dom": ">=19.0.0",