@dp-bohrium/widget-sdk 0.6.0 → 0.7.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.
Files changed (36) hide show
  1. package/AGENTS.md +6 -3
  2. package/CHANGELOG.md +21 -0
  3. package/README.md +7 -16
  4. package/assets/schemas/widget-runtime-contracts.schema.json +7 -3
  5. package/assets/toolchain.json +13 -9
  6. package/dist/cli.mjs +155 -114
  7. package/dist/contracts.d.ts +1 -1
  8. package/dist/contracts.js +2 -1
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +17 -11
  11. package/dist/manifest.d.ts +1 -1
  12. package/dist/protocol/generated-host-runtime-config.d.ts +551 -0
  13. package/dist/protocol/generated-manifest.d.ts +192 -0
  14. package/dist/protocol/generated-plugin-manifest.d.ts +176 -0
  15. package/dist/protocol/generated-runtime-contracts.d.ts +1224 -0
  16. package/dist/protocol/index.d.ts +43 -0
  17. package/dist/protocol/plugin-manifest.d.ts +30 -0
  18. package/dist/protocol/widget-events.d.ts +13 -0
  19. package/dist/runtime/bootstrap.d.ts +1 -1
  20. package/dist/runtime/client.d.ts +1 -1
  21. package/dist/runtime/event-validation.d.ts +1 -1
  22. package/dist/runtime/events.d.ts +1 -1
  23. package/dist/runtime/files.d.ts +1 -1
  24. package/dist/runtime/index.d.ts +1 -1
  25. package/dist/runtime/index.js +1 -1
  26. package/dist/runtime/mock-host.d.ts +1 -1
  27. package/dist/runtime/network.d.ts +1 -1
  28. package/dist/runtime/protocol-endpoint.d.ts +1 -1
  29. package/dist/runtime/service.d.ts +2 -2
  30. package/dist/runtime/transport.d.ts +1 -1
  31. package/dist/{runtime-D7KxTtdu.js → runtime-DZA7Gqzl.js} +1 -1
  32. package/dist/widget-events-BT0QxR-H.js +65 -0
  33. package/dist/widget.d.ts +2 -2
  34. package/llms.txt +2 -3
  35. package/package.json +4 -6
  36. package/schemas/widget-runtime-contracts.schema.json +7 -3
@@ -0,0 +1,43 @@
1
+ /** Public Widget contract surface. Runtime host/client APIs are deferred. */
2
+ import type { FallbackBinding, LoadableBinding } from "./generated-host-runtime-config.js";
3
+ import type { BridgeEnvelopeBase, GrantedCapability, HostToWidgetMessage, RenderRequest, WidgetError, WidgetToHostMessage } from "./generated-runtime-contracts.js";
4
+ /**
5
+ * Every type is re-exported from the module generated out of the schema that
6
+ * owns it. The Host Config module also contains inlined `$ref` copies of
7
+ * Manifest and Runtime definitions; re-exporting those copies would let the
8
+ * public surface drift from the canonical contract.
9
+ */
10
+ export type { FallbackBinding, HostServiceAuthorization, HostServiceAuthorizationGranted, HostServiceAuthorizationRequired, LoadableBinding, NetworkAuthority, RuntimeAuthority, WidgetHostRuntimeConfig, WidgetServiceAccess, } from "./generated-host-runtime-config.js";
11
+ export type { ActivationEvents, HostUserPermission, HostUserPermissions, RequestedPresentationCapability, RequestedRegionCapability, StateCapabilityRequest, TasksCapabilityRequest, WidgetContributionConfig, WidgetManifest, } from "./generated-manifest.js";
12
+ export type { WidgetContribution, WidgetFilePreviewContribution, WidgetPanelContribution, WidgetPluginContributions, } from "./generated-plugin-manifest.js";
13
+ export type { BridgeEnvelopeBase, CapabilityRequest, CapabilityRequestMessage, CapabilityResult, CapabilityResultMessage, ComputeReviewRequestedPublicWidgetEvent, ComputeReviewRequestedPublicWidgetEventPayload, DisposeMessage, EmptyPublicWidgetEventPayload, ErrorMessage, FileDownloadResult, FileMutationId, FilePreviewContent, FilePreviewRenderRequest, FileReadInput, FileReadResult, FileReference, FileRevision, FileWriteInput, FileWriteResult, FocusBoundaryPresentationCapabilityRequest, GrantedCapability, GrantedPresentationCapability, GrantedRegionCapability, HostToWidgetMessage, HostUserAction, HostUserEmailReadInput, HostUserEmailReadOutput, HostUserProfileReadInput, HostUserProfileReadOutput, HostUserService, HostUserServiceRequest, InitMessage, InitPayload, JsonValue, PanelContent, PanelRenderRequest, PresentationCapabilityOutput, PresentationCapabilityRequest, PresentationCapabilityResult, PublicWidgetEvent, PublicWidgetEventBase, PublicWidgetEventId, PublicWidgetEventOccurredAt, PublicWidgetEventTopic, PublicWidgetSessionId, PublicWidgetWorkflowId, ReadyMessage, RegionCapabilityRequest, RegionCapabilityResult, RenderMessage, RenderRequest, RenderRequestBase, RenderState, ResizeMessage, ResourceBudget, SandboxApprovalRequestedPublicWidgetEvent, SandboxApprovalRequestedPublicWidgetEventPayload, SandboxApprovedPublicWidgetEvent, SandboxApprovedPublicWidgetEventPayload, SandboxDeniedPublicWidgetEvent, TaskListField, TaskListItem, TaskListPage, TaskObservationBatch, TaskObservationEvent, TaskObservationSnapshot, TaskStatus, Theme, ThemeMode, ToolCallPublicWidgetEvent, ToolCallPublicWidgetEventPayload, ToolLifecycleEvent, ToolResultArtifact, ToolResultContent, ToolResultEnvelope, ToolResultMetric, ToolResultNotice, ToolResultProvenance, ToolResultPublicWidgetEvent, ToolResultPublicWidgetEventPayload, ToolResultRenderRequest, UiStateResult, UiStateWriteResult, UserInputRequestedPublicWidgetEvent, UserInputRequestedPublicWidgetEventPayload, WidgetContributionKind, WidgetError, WidgetEvent, WidgetEventBatch, WidgetEventMessage, WidgetLiveEvent, WidgetNetworkFetchInput, WidgetNetworkFetchOutput, WidgetNetworkLimits, WidgetRenderContext, WidgetServicePermission, WidgetServicePermissions, WidgetToHostMessage, WorkflowDonePublicWidgetEvent, WorkflowDonePublicWidgetEventPayload, WorkflowErrorPublicWidgetEvent, WorkflowErrorPublicWidgetEventPayload, WorkflowStartedPublicWidgetEvent, WorkflowStartedPublicWidgetEventPayload, } from "./generated-runtime-contracts.js";
14
+ export type { WidgetActivationEvent, WidgetActivationEvents, WidgetPluginManifest, WidgetToolPhase, } from "./plugin-manifest.js";
15
+ export { isWidgetActivationEvent, WIDGET_ACTIVATION_EVENTS, } from "./plugin-manifest.js";
16
+ export type { WidgetEventName } from "./widget-events.js";
17
+ export { isWidgetEventName, WIDGET_EVENT_NAMES } from "./widget-events.js";
18
+ /**
19
+ * Host API 协议版本,当前固定为 `1`,由各 Schema 的 `hostApiVersion`(`const: 1`)
20
+ * 唯一决定。它与包 SemVer 正交,不要用 `2` 之类不存在的值。
21
+ */
22
+ export type HostApiVersion = 1;
23
+ /** `RenderRequest` 的等价别名;用 `request.contribution` 收窄后访问对应 `content`。 */
24
+ export type WidgetRenderRequest = RenderRequest;
25
+ /** Host → Widget 与 Widget → Host 双向 Bridge 消息的联合。 */
26
+ export type WidgetProtocolMessage = HostToWidgetMessage | WidgetToHostMessage;
27
+ /**
28
+ * `GrantedCapability` 中只读文件能力名的联合:
29
+ * `files.list` / `files.metadata` / `files.read` / `files.download`;不包含 `files.write`。
30
+ */
31
+ export type ReadonlyFileCapability = Extract<GrantedCapability["name"], "files.list" | "files.metadata" | "files.read" | "files.download">;
32
+ /** `WidgetError.code` 的字符串字面量联合。 */
33
+ export type WidgetErrorCode = WidgetError["code"];
34
+ /**
35
+ * 带泛型 `type` / `payload` 的 Bridge 信封;默认 `type` 为 string、`payload` 为
36
+ * unknown。具体消息建议直接用 `HostToWidgetMessage` / `WidgetToHostMessage` 的成员。
37
+ */
38
+ export type BridgeEnvelope<TType extends string = string, TPayload = unknown> = BridgeEnvelopeBase & {
39
+ type: TType;
40
+ payload: TPayload;
41
+ };
42
+ /** 可加载绑定与降级绑定的联合,即 Host Runtime Config 中一条 binding 的两种结果。 */
43
+ export type ResolvedWidgetBinding = LoadableBinding | FallbackBinding;
@@ -0,0 +1,30 @@
1
+ import type { WidgetPluginManifest as GeneratedWidgetPluginManifest } from "./generated-plugin-manifest.js";
2
+ /** 工具调用事件阶段;用于拼出 `tool-call-<phase>:<toolName>` 形式的激活事件。 */
3
+ export type WidgetToolPhase = "generating" | "waiting" | "running" | "result" | "error";
4
+ /**
5
+ * Widget Host 公开的固定激活事件。数组同时作为清单编辑器文档和 Host
6
+ * 运行时校验的单一事实源;带工具名的事件使用下方的动态形式。
7
+ */
8
+ export declare const WIDGET_ACTIVATION_EVENTS: readonly ["session.start", "turn-start", "turn-end", "step-start", "step-end", "tool-call-generating", "tool-call-waiting", "tool-call-running", "tool-call-result", "tool-call-error", "workspace-file-changed", "workspace-tree-refresh", "workspace-file-opened", "ui-tool-opened", "ui-panel-focused", "host-surface-changed"];
9
+ type WidgetFixedActivationEvent = (typeof WIDGET_ACTIVATION_EVENTS)[number];
10
+ /**
11
+ * `activationEvents` 可声明的值:固定事件,或按工具名筛选的
12
+ * `tool-call-<phase>:<toolName>` 动态形式。
13
+ */
14
+ export type WidgetActivationEvent = WidgetFixedActivationEvent | `tool-call-${WidgetToolPhase}:${string}`;
15
+ /** 至少一个元素、按声明顺序的只读激活事件元组(作者侧清单使用)。 */
16
+ export type WidgetActivationEvents = readonly [
17
+ WidgetActivationEvent,
18
+ ...WidgetActivationEvent[]
19
+ ];
20
+ /**
21
+ * 判断一个字符串是否为合法激活事件(固定事件或带工具名的动态形式)。
22
+ * @param value 待检查的字符串。
23
+ * @returns 若命中固定目录或工具事件模式则收窄为 `WidgetActivationEvent`。
24
+ */
25
+ export declare function isWidgetActivationEvent(value: unknown): value is WidgetActivationEvent;
26
+ /** 作者侧 Manifest 类型;激活事件类型与 JSON Schema 共用同一事实源。 */
27
+ export type WidgetPluginManifest = Omit<GeneratedWidgetPluginManifest, "activationEvents"> & {
28
+ readonly activationEvents?: WidgetActivationEvents;
29
+ };
30
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Host 主动推送给已激活 Widget 的实时事件。`session.start` 只用于激活索引,
3
+ * 不属于这组运行期事件;激活后首个可用快照通过 `context.render` 交付。
4
+ */
5
+ export declare const WIDGET_EVENT_NAMES: readonly ["turn-start", "turn-end", "step-start", "step-end", "tool-call-generating", "tool-call-waiting", "tool-call-running", "tool-call-result", "tool-call-error", "workspace-file-changed", "workspace-tree-refresh", "workspace-file-opened", "ui-tool-opened", "ui-panel-focused", "host-surface-changed"];
6
+ /** `context.events.on` 可监听的实时事件名;不含仅用于激活的 `session.start`。 */
7
+ export type WidgetEventName = (typeof WIDGET_EVENT_NAMES)[number];
8
+ /**
9
+ * 判断一个字符串是否为合法的实时事件名。
10
+ * @param value 待检查的字符串。
11
+ * @returns 若 `value` 命中 `WIDGET_EVENT_NAMES` 则收窄为 `WidgetEventName`。
12
+ */
13
+ export declare function isWidgetEventName(value: unknown): value is WidgetEventName;
@@ -1,4 +1,4 @@
1
- import type { CapabilityRequest, CapabilityResult, InitPayload, PresentationCapabilityResult, RegionCapabilityResult, RenderRequest, WidgetError, WidgetLiveEvent } from "@dp-bohrium/widget-contracts";
1
+ import type { CapabilityRequest, CapabilityResult, InitPayload, PresentationCapabilityResult, RegionCapabilityResult, RenderRequest, WidgetError, WidgetLiveEvent } from "../protocol/index.js";
2
2
  import { type PresentationFocusDirection, type PresentationSurface, type RegionName, type WidgetCapabilityRequestOptions, type WidgetClientEvents, type WidgetClientState } from "./client.js";
3
3
  import { type SubscribeWidgetEventsOptions, type WidgetEventSubscription, type WidgetToolHooks } from "./events.js";
4
4
  import type { WidgetNetworkClient } from "./network.js";
@@ -1,4 +1,4 @@
1
- import type { CapabilityRequest, CapabilityResult, GrantedCapability, InitPayload, PresentationCapabilityRequest, PresentationCapabilityResult, RegionCapabilityRequest, RegionCapabilityResult, RenderRequest, WidgetError, WidgetLiveEvent } from "@dp-bohrium/widget-contracts";
1
+ import type { CapabilityRequest, CapabilityResult, GrantedCapability, InitPayload, PresentationCapabilityRequest, PresentationCapabilityResult, RegionCapabilityRequest, RegionCapabilityResult, RenderRequest, WidgetError, WidgetLiveEvent } from "../protocol/index.js";
2
2
  import { type WidgetNetworkClient } from "./network.js";
3
3
  import type { WidgetTransport } from "./transport.js";
4
4
  export type WidgetClientState = "created" | "waiting-ready" | "ready" | "disposed";
@@ -1,3 +1,3 @@
1
- import type { ToolLifecycleEvent, WidgetEventBatch } from "@dp-bohrium/widget-contracts";
1
+ import type { ToolLifecycleEvent, WidgetEventBatch } from "../protocol/index.js";
2
2
  export declare function parseWidgetEventBatch(value: unknown): WidgetEventBatch;
3
3
  export declare function parseToolLifecycleEvent(value: unknown): ToolLifecycleEvent;
@@ -1,4 +1,4 @@
1
- import type { CapabilityRequest, GrantedCapability, ToolLifecycleEvent, WidgetEventBatch } from "@dp-bohrium/widget-contracts";
1
+ import type { CapabilityRequest, GrantedCapability, ToolLifecycleEvent, WidgetEventBatch } from "../protocol/index.js";
2
2
  export interface WidgetEventSubscription {
3
3
  readonly cursor: string | undefined;
4
4
  readonly closed: Promise<void>;
@@ -1,4 +1,4 @@
1
- import type { CapabilityRequest, CapabilityResult, FileReadInput, FileReadResult, FileWriteInput, FileWriteResult } from "@dp-bohrium/widget-contracts";
1
+ import type { CapabilityRequest, CapabilityResult, FileReadInput, FileReadResult, FileWriteInput, FileWriteResult } from "../protocol/index.js";
2
2
  import type { WidgetCapabilityRequestOptions, WidgetClientState } from "./client.js";
3
3
  type Failure = Extract<CapabilityResult, {
4
4
  ok: false;
@@ -1,4 +1,4 @@
1
- export type { RegionCapabilityResult } from "@dp-bohrium/widget-contracts";
1
+ export type { RegionCapabilityResult } from "../protocol/index.js";
2
2
  export type { CreateWidgetClientOptions, WidgetClientFactoryOptions, WidgetDisposeEvent, WidgetHostConnectMessage, WidgetLiveEventContext, WidgetLiveEventHandler, WidgetLiveEventName, WidgetRuntimeWindow, WidgetSize, } from "./bootstrap.js";
3
3
  export { createWidgetClient, isWidgetHostConnectMessage, WIDGET_BOOTSTRAP_READY, WIDGET_HOST_CONNECT, WIDGET_SDK_VERSION, WidgetRuntimeClient, } from "./bootstrap.js";
4
4
  export type { PresentationFocusDirection, PresentationSurface, RegionName, WidgetCapabilityRequestOptions, WidgetClientEvents, WidgetClientOptions, WidgetClientState, } from "./client.js";
@@ -1,3 +1,3 @@
1
- import { a as isWidgetHostConnectMessage, c as WidgetClient, i as createWidgetClient, l as WIDGET_SDK_VERSION, n as WIDGET_HOST_CONNECT, o as PRESENTATION_CONFIRMATION_TIMEOUT_MS, r as WidgetRuntimeClient, s as REGION_CONFIRMATION_TIMEOUT_MS, t as WIDGET_BOOTSTRAP_READY } from "../runtime-D7KxTtdu.js";
1
+ import { a as isWidgetHostConnectMessage, c as WidgetClient, i as createWidgetClient, l as WIDGET_SDK_VERSION, n as WIDGET_HOST_CONNECT, o as PRESENTATION_CONFIRMATION_TIMEOUT_MS, r as WidgetRuntimeClient, s as REGION_CONFIRMATION_TIMEOUT_MS, t as WIDGET_BOOTSTRAP_READY } from "../runtime-DZA7Gqzl.js";
2
2
  import { i as isWidgetProtocolMessage, r as MessagePortTransport } from "../protocol-endpoint-CDz-YDGT.js";
3
3
  export { MessagePortTransport, PRESENTATION_CONFIRMATION_TIMEOUT_MS, REGION_CONFIRMATION_TIMEOUT_MS, WIDGET_BOOTSTRAP_READY, WIDGET_HOST_CONNECT, WIDGET_SDK_VERSION, WidgetClient, WidgetRuntimeClient, createWidgetClient, isWidgetHostConnectMessage, isWidgetProtocolMessage };
@@ -1,4 +1,4 @@
1
- import type { CapabilityRequest, CapabilityResult, InitPayload, RenderRequest, WidgetError } from "@dp-bohrium/widget-contracts";
1
+ import type { CapabilityRequest, CapabilityResult, InitPayload, RenderRequest, WidgetError } from "../protocol/index.js";
2
2
  import type { WidgetTransport } from "./transport.js";
3
3
  export type MockWidgetHostState = "created" | "waiting-ready" | "ready" | "disposed";
4
4
  export interface MockWidgetHostOptions {
@@ -1,4 +1,4 @@
1
- import type { CapabilityRequest, CapabilityResult, WidgetNetworkFetchInput, WidgetNetworkFetchOutput } from "@dp-bohrium/widget-contracts";
1
+ import type { CapabilityRequest, CapabilityResult, WidgetNetworkFetchInput, WidgetNetworkFetchOutput } from "../protocol/index.js";
2
2
  import type { WidgetCapabilityRequestOptions, WidgetClientState } from "./client.js";
3
3
  export type WidgetNetworkFetchResult = Readonly<{
4
4
  ok: true;
@@ -1,4 +1,4 @@
1
- import type { WidgetProtocolMessage } from "@dp-bohrium/widget-contracts";
1
+ import type { WidgetProtocolMessage } from "../protocol/index.js";
2
2
  import { type WidgetTransport } from "./transport.js";
3
3
  declare const envelopeFields: readonly ["protocolVersion", "channelId", "messageId", "sequence"];
4
4
  type EnvelopeField = (typeof envelopeFields)[number];
@@ -1,4 +1,4 @@
1
- import type { CapabilityRequest, CapabilityResult, JsonValue } from "@dp-bohrium/widget-contracts";
1
+ import type { CapabilityRequest, CapabilityResult, JsonValue } from "../protocol/index.js";
2
2
  import type { WidgetCapabilityRequestOptions, WidgetClientState } from "./client.js";
3
3
  export type WidgetServiceInvokeInput = Extract<CapabilityRequest, {
4
4
  operation: "service.invoke";
@@ -37,7 +37,7 @@ export interface WidgetHostUserClient {
37
37
  }
38
38
  interface Dependencies {
39
39
  readonly state: () => WidgetClientState;
40
- readonly grant: () => Extract<import("@dp-bohrium/widget-contracts").GrantedCapability, {
40
+ readonly grant: () => Extract<import("../protocol/index.js").GrantedCapability, {
41
41
  name: "service.invoke";
42
42
  }> | undefined;
43
43
  readonly request: (request: CapabilityRequest, options?: WidgetCapabilityRequestOptions) => Promise<CapabilityResult>;
@@ -1,4 +1,4 @@
1
- import type { WidgetProtocolMessage } from "@dp-bohrium/widget-contracts";
1
+ import type { WidgetProtocolMessage } from "../protocol/index.js";
2
2
  export interface WidgetTransport {
3
3
  send(message: WidgetProtocolMessage): void;
4
4
  onMessage(listener: (message: WidgetProtocolMessage) => void): () => void;
@@ -2,7 +2,7 @@ import { r as MessagePortTransport, t as ProtocolEndpoint } from "./protocol-end
2
2
  //#endregion
3
3
  //#region src/runtime/version.ts
4
4
  /** 从当前安装的 SDK package.json 读取版本,插件作者不需要重复填写。 */
5
- const WIDGET_SDK_VERSION = "0.6.0";
5
+ const WIDGET_SDK_VERSION = "0.7.0";
6
6
  //#endregion
7
7
  //#region src/runtime/network.ts
8
8
  const failureReasons = /* @__PURE__ */ new Set([
@@ -0,0 +1,65 @@
1
+ //#region ../contracts/src/plugin-manifest.ts
2
+ /**
3
+ * Widget Host 公开的固定激活事件。数组同时作为清单编辑器文档和 Host
4
+ * 运行时校验的单一事实源;带工具名的事件使用下方的动态形式。
5
+ */
6
+ const WIDGET_ACTIVATION_EVENTS = [
7
+ "session.start",
8
+ "turn-start",
9
+ "turn-end",
10
+ "step-start",
11
+ "step-end",
12
+ "tool-call-generating",
13
+ "tool-call-waiting",
14
+ "tool-call-running",
15
+ "tool-call-result",
16
+ "tool-call-error",
17
+ "workspace-file-changed",
18
+ "workspace-tree-refresh",
19
+ "workspace-file-opened",
20
+ "ui-tool-opened",
21
+ "ui-panel-focused",
22
+ "host-surface-changed"
23
+ ];
24
+ const TOOL_EVENT_PATTERN = /^(?:tool-call-(?:generating|waiting|running|result|error)):[A-Za-z0-9_.:-]+$/u;
25
+ /**
26
+ * 判断一个字符串是否为合法激活事件(固定事件或带工具名的动态形式)。
27
+ * @param value 待检查的字符串。
28
+ * @returns 若命中固定目录或工具事件模式则收窄为 `WidgetActivationEvent`。
29
+ */
30
+ function isWidgetActivationEvent(value) {
31
+ return typeof value === "string" && (WIDGET_ACTIVATION_EVENTS.includes(value) || TOOL_EVENT_PATTERN.test(value));
32
+ }
33
+ //#endregion
34
+ //#region ../contracts/src/widget-events.ts
35
+ /**
36
+ * Host 主动推送给已激活 Widget 的实时事件。`session.start` 只用于激活索引,
37
+ * 不属于这组运行期事件;激活后首个可用快照通过 `context.render` 交付。
38
+ */
39
+ const WIDGET_EVENT_NAMES = [
40
+ "turn-start",
41
+ "turn-end",
42
+ "step-start",
43
+ "step-end",
44
+ "tool-call-generating",
45
+ "tool-call-waiting",
46
+ "tool-call-running",
47
+ "tool-call-result",
48
+ "tool-call-error",
49
+ "workspace-file-changed",
50
+ "workspace-tree-refresh",
51
+ "workspace-file-opened",
52
+ "ui-tool-opened",
53
+ "ui-panel-focused",
54
+ "host-surface-changed"
55
+ ];
56
+ /**
57
+ * 判断一个字符串是否为合法的实时事件名。
58
+ * @param value 待检查的字符串。
59
+ * @returns 若 `value` 命中 `WIDGET_EVENT_NAMES` 则收窄为 `WidgetEventName`。
60
+ */
61
+ function isWidgetEventName(value) {
62
+ return typeof value === "string" && WIDGET_EVENT_NAMES.includes(value);
63
+ }
64
+ //#endregion
65
+ export { isWidgetActivationEvent as i, isWidgetEventName as n, WIDGET_ACTIVATION_EVENTS as r, WIDGET_EVENT_NAMES as t };
package/dist/widget.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CapabilityRequest, CapabilityResult, FileDownloadResult, FileReadInput, FileReference, FileWriteInput, GrantedCapability, RegionCapabilityResult, RenderRequest, TaskListPage, TaskObservationBatch, Theme, UiStateResult, UiStateWriteResult, WidgetEventName, WidgetLiveEvent } from "@dp-bohrium/widget-contracts";
1
+ import type { CapabilityRequest, CapabilityResult, FileDownloadResult, FileReadInput, FileReference, FileWriteInput, GrantedCapability, RegionCapabilityResult, RenderRequest, TaskListPage, TaskObservationBatch, Theme, UiStateResult, UiStateWriteResult, WidgetEventName, WidgetLiveEvent } from "./protocol/index.js";
2
2
  import { type FileReadCapabilityResult, type FileWriteCapabilityResult } from "./runtime/files.js";
3
3
  import { type CreateWidgetClientOptions, type RegionName, type WidgetClientFactoryOptions, type WidgetClientState, type WidgetLiveEventContext, type WidgetLiveEventHandler } from "./runtime/index.js";
4
4
  import type { WidgetNetworkClient } from "./runtime/network.js";
@@ -96,7 +96,7 @@ export interface WidgetUiStateApi {
96
96
  readonly timeoutMs?: number;
97
97
  readonly signal?: AbortSignal;
98
98
  }): Promise<UiStateReadCapabilityResult>;
99
- write(key: string, value: import("@dp-bohrium/widget-contracts").JsonValue, options?: {
99
+ write(key: string, value: import("./protocol/index.js").JsonValue, options?: {
100
100
  readonly timeoutMs?: number;
101
101
  readonly signal?: AbortSignal;
102
102
  }): Promise<UiStateWriteCapabilityResult>;
package/llms.txt CHANGED
@@ -20,9 +20,8 @@
20
20
  - Host 协议校验语料:`@dp-bohrium/widget-sdk/conformance/*`
21
21
  - 工程命令:SDK 包内 `bohr-widget`(首次创建可用 `pnpm dlx @dp-bohrium/widget-sdk create ...`)
22
22
 
23
- 消费方直接声明或导入 contracts 的旧用法已废弃;统一入口切换发布 R1 前迁到 SDK 子入口。
24
- contracts 仍维护内部唯一源,不恢复旧作者执行器来支持历史工程。
25
- 新工程只直接声明精确 SDK 版本;`@dp-bohrium/widget-cli` 只按现行发布治理保留过渡分发、历史审计和废弃诊断,不由 SDK 回选。
23
+ 作者工程使用精确 SDK 版本,通过上述入口获取运行时、协议、测试工具与工程命令。
24
+ 升级旧工程时,按迁移指南准备候选并重新构建,不复用不匹配的执行器或旧 receipt。
26
25
 
27
26
  ## 使用原则
28
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dp-bohrium/widget-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Bohrium Widget 开发者 SDK:在 Widget Bundle 内与 Host 建立 Bridge,并暴露生命周期与能力协议。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -59,9 +59,6 @@
59
59
  "publishConfig": {
60
60
  "access": "public"
61
61
  },
62
- "dependencies": {
63
- "@dp-bohrium/widget-contracts": "0.6.0"
64
- },
65
62
  "devDependencies": {
66
63
  "@biomejs/biome": "^2.2.0",
67
64
  "@vitest/coverage-v8": "^3.2.4",
@@ -69,10 +66,11 @@
69
66
  "tsdown": "0.22.14",
70
67
  "typescript": "^5.8.3",
71
68
  "vitest": "^3.2.4",
69
+ "@dp-bohrium/widget-contracts": "0.7.0",
72
70
  "@dp-bohrium/widget-contract-testing": "0.1.0-alpha.0"
73
71
  },
74
72
  "scripts": {
75
- "build:runtime": "tsdown && tsc -b tsconfig.build.json --force --pretty false && node ../../scripts/schema/build-sdk-assets.mjs",
73
+ "build:runtime": "pnpm --filter @dp-bohrium/widget-contracts run build && tsdown && tsc -b tsconfig.build.json --force --pretty false && node ../../scripts/schema/build-sdk-assets.mjs",
76
74
  "build:cli": "node ../../scripts/schema/build-sdk-cli-assets.mjs && tsdown --config widget-cli.tsdown.config.ts && node --check dist/cli.mjs",
77
75
  "build": "pnpm build:runtime && pnpm --filter @dp-bohrium/widget-contract-testing build && pnpm build:cli",
78
76
  "typecheck": "tsc --noEmit",
@@ -86,7 +84,7 @@
86
84
  "lint": "biome check src test",
87
85
  "format:check": "biome check --linter-enabled=false src test",
88
86
  "package:contents": "node ../../scripts/quality/check-sdk-package-contents.mjs ../../.artifacts/dp-bohrium-widget-sdk-*.tgz",
89
- "consumer:canary": "CONSUMER_PACKAGE_NAME=@dp-bohrium/widget-sdk node ../../scripts/consumer/consumer-install.mjs ../../.artifacts/dp-bohrium-widget-sdk-*.tgz ../../.artifacts/dp-bohrium-widget-contracts-*.tgz",
87
+ "consumer:canary": "node ../../scripts/consumer/consumer-sdk-install.mjs ../../.artifacts/dp-bohrium-widget-sdk-*.tgz",
90
88
  "release:check-version": "WIDGET_PACKAGE_NAME=@dp-bohrium/widget-sdk node ../../scripts/release/check-registry-version.mjs",
91
89
  "check": "pnpm typecheck && pnpm test && pnpm fixture:build && pnpm fixture:pack:test && pnpm lint && pnpm format:check && pnpm --filter @dp-bohrium/widget-contract-testing build && pnpm build && pnpm fixture:pack && pnpm fixture:check"
92
90
  }
@@ -821,7 +821,6 @@
821
821
  "additionalProperties": false,
822
822
  "required": [
823
823
  "bytesPerRequest",
824
- "bytesPerRun",
825
824
  "callsPerMinute"
826
825
  ],
827
826
  "properties": {
@@ -830,6 +829,8 @@
830
829
  "minimum": 1
831
830
  },
832
831
  "bytesPerRun": {
832
+ "description": "历史读取累计额度字段,仅为兼容旧配置保留;当前 files.read 不累计或执行此额度,新宿主不再下发。",
833
+ "deprecated": true,
833
834
  "type": "integer",
834
835
  "minimum": 1
835
836
  },
@@ -1998,13 +1999,16 @@
1998
1999
  "additionalProperties": false,
1999
2000
  "required": [
2000
2001
  "readBytesPerRequest",
2001
- "readBytesPerRun",
2002
2002
  "callsPerMinute",
2003
2003
  "listPageSize"
2004
2004
  ],
2005
2005
  "properties": {
2006
2006
  "readBytesPerRequest": { "type": "integer", "minimum": 1 },
2007
- "readBytesPerRun": { "type": "integer", "minimum": 1 },
2007
+ "readBytesPerRun": {
2008
+ "description": "历史读取累计额度字段,仅为兼容旧配置保留;当前 files.read 不累计或执行此额度,新宿主不再下发。",
2009
+ "deprecated": true,
2010
+ "type": "integer", "minimum": 1
2011
+ },
2008
2012
  "callsPerMinute": { "type": "integer", "minimum": 1 },
2009
2013
  "listPageSize": { "type": "integer", "minimum": 1 },
2010
2014
  "writeBytesPerRequest": {