@dp-bohrium/widget-sdk 0.8.0 → 0.10.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 (38) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +25 -0
  3. package/README.md +0 -7
  4. package/assets/schemas/widget-manifest.schema.json +0 -12
  5. package/assets/schemas/widget-runtime-contracts.schema.json +906 -272
  6. package/assets/toolchain.json +8 -8
  7. package/conformance/development-diagnostics.json +128 -0
  8. package/dist/cli.mjs +184 -14
  9. package/dist/compatibility/testing.js +1 -1
  10. package/dist/contracts.js +3 -2
  11. package/dist/development-guards-COvBR0G1.js +136 -0
  12. package/dist/{dsh-BlpXm2Bv.mjs → dsh-BJWUB8Nq.mjs} +1308 -516
  13. package/dist/index.d.ts +2 -2
  14. package/dist/index.js +53 -17
  15. package/dist/protocol/development-guards.d.ts +9 -0
  16. package/dist/protocol/generated-development-policy.d.ts +22 -0
  17. package/dist/protocol/generated-host-runtime-config.d.ts +0 -22
  18. package/dist/protocol/generated-manifest.d.ts +0 -8
  19. package/dist/protocol/generated-plugin-manifest.d.ts +0 -8
  20. package/dist/protocol/generated-runtime-contracts.d.ts +230 -128
  21. package/dist/protocol/index.d.ts +7 -2
  22. package/dist/protocol/widget-recovery.d.ts +19 -0
  23. package/dist/{protocol-endpoint-CDz-YDGT.js → protocol-endpoint-DbT0OJNu.js} +5 -0
  24. package/dist/runtime/bootstrap.d.ts +3 -1
  25. package/dist/runtime/client.d.ts +5 -1
  26. package/dist/runtime/index.js +2 -2
  27. package/dist/runtime/protocol-endpoint.d.ts +5 -5
  28. package/dist/runtime/transport.d.ts +9 -9
  29. package/dist/{runtime-D2xmZVSb.js → runtime-Bn_ee8xy.js} +39 -5
  30. package/dist/widget-recovery-BF_sSUZX.js +472 -0
  31. package/dist/widget.d.ts +1 -41
  32. package/llms.txt +13 -1
  33. package/package.json +1 -1
  34. package/schemas/widget-manifest.schema.json +0 -12
  35. package/schemas/widget-runtime-contracts.schema.json +906 -272
  36. package/conformance/bridge/tasks-list-request.json +0 -17
  37. package/conformance/bridge/tasks-watch-request.json +0 -18
  38. package/dist/widget-events-gsKJbjqg.js +0 -65
@@ -80,20 +80,6 @@ export type GrantedCapability = ({
80
80
  pageSize: number;
81
81
  minPollMs: number;
82
82
  };
83
- } | {
84
- name: "tasks.list";
85
- limits: {
86
- callsPerMinute: number;
87
- pageSize: number;
88
- minPollMs: number;
89
- };
90
- } | {
91
- name: "tasks.watch";
92
- limits: {
93
- callsPerMinute: number;
94
- pageSize: number;
95
- minPollMs: number;
96
- };
97
83
  } | {
98
84
  name: "ui.state";
99
85
  limits: {
@@ -286,19 +272,6 @@ export type CapabilityRequest = ({
286
272
  file: FileReference;
287
273
  suggestedName: string;
288
274
  };
289
- } | {
290
- operation: "tasks.list";
291
- input: {
292
- cursor?: string;
293
- limit?: number;
294
- };
295
- } | {
296
- operation: "tasks.watch";
297
- input: {
298
- taskId: string;
299
- cursor?: string;
300
- limit?: number;
301
- };
302
275
  } | {
303
276
  operation: "ui.state";
304
277
  input: ({
@@ -513,10 +486,6 @@ export type RegionCapabilityResult = ({
513
486
  message: string;
514
487
  retryable: boolean;
515
488
  });
516
- /**
517
- * Host 投影给 Widget 的统一任务状态。
518
- */
519
- export type TaskStatus = ("queued" | "running" | "succeeded" | "failed" | "cancelled" | "expired");
520
489
  /**
521
490
  * Host 用户服务标识;固定为 host.user。
522
491
  */
@@ -545,6 +514,124 @@ export type HostUserServiceRequest = ({
545
514
  action: "email.read";
546
515
  payload: HostUserEmailReadInput;
547
516
  });
517
+ /**
518
+ * 受控字段诊断或工程相对源码位置;不携带原始对象。
519
+ */
520
+ export type WidgetDiagnosticDetail = ({
521
+ field: string;
522
+ expected?: string;
523
+ observed?: string;
524
+ } | {
525
+ file: string;
526
+ line: number;
527
+ column: number;
528
+ excerpt?: string;
529
+ });
530
+ /**
531
+ * 保留 transport、HTTP 与非法响应事实;不包含 URL 或原始响应。
532
+ */
533
+ export type WidgetDiagnosticIO = ({
534
+ kind: ("transport" | "invalid-response");
535
+ sourceCode?: string;
536
+ } | {
537
+ kind: "http";
538
+ status: number;
539
+ sourceCode?: string;
540
+ });
541
+ /**
542
+ * 恢复动作的语义及类型化参数;可信宿主绑定已有工具,不包含任意命令。
543
+ */
544
+ export type WidgetRecoveryAction = ({
545
+ id: "inspect";
546
+ params: {
547
+ area: ("toolchain" | "host-bridge" | "configuration" | "bundle" | "handshake" | "render" | "capability" | "lease" | "operation-outcome" | "runtime");
548
+ };
549
+ } | {
550
+ id: "wait";
551
+ params: {
552
+ milestone: ("budget-reset" | "connection-restored");
553
+ retryAfterMs?: number;
554
+ };
555
+ } | {
556
+ id: "edit-project";
557
+ params: {
558
+ evidence: "diagnostics";
559
+ };
560
+ } | {
561
+ id: "build-project";
562
+ params: {
563
+ target: "current-project";
564
+ };
565
+ } | {
566
+ id: "refresh-preview";
567
+ params: {
568
+ target: "current-project";
569
+ };
570
+ } | {
571
+ id: "verify-scenario";
572
+ params: {
573
+ target: ("current-attempt" | "next-built-generation");
574
+ scenarioId?: string;
575
+ };
576
+ } | {
577
+ id: "request-external-action";
578
+ params: {
579
+ reason: ("authorization" | "host-support" | "host-start" | "credentials");
580
+ };
581
+ } | {
582
+ id: "stop-preview";
583
+ params: {
584
+ target: "current-preview";
585
+ };
586
+ });
587
+ /**
588
+ * 经 offer/connect 显式选择的开发扩展;不授予 capability。
589
+ */
590
+ export type WidgetDevelopmentExtension = "development-diagnostics-v1";
591
+ /**
592
+ * 仅表示受管渲染处理器的处理结果,不代表视觉或业务验收。
593
+ */
594
+ export type WidgetRenderResult = ({
595
+ requestId: string;
596
+ revision: number;
597
+ outcome: ("handled" | "superseded");
598
+ } | {
599
+ requestId: string;
600
+ revision: number;
601
+ outcome: "failed";
602
+ diagnostic: WidgetRenderFailureDiagnostic;
603
+ });
604
+ /**
605
+ * 失败处理回执的 SDK 请求诊断;接收方还须匹配当前 requestId。
606
+ */
607
+ export type WidgetRenderFailureDiagnostic = (WidgetGuestDiagnostic & {
608
+ correlationId: string;
609
+ phase?: ("render" | "update");
610
+ });
611
+ /**
612
+ * Guest 仅声明 SDK 诊断事实,不得冒充 Host 或工具链。
613
+ */
614
+ export type WidgetGuestDiagnostic = (WidgetDevelopmentDiagnostic & {
615
+ source: "sdk";
616
+ });
617
+ /**
618
+ * 扩展 profile 下的 Widget → Host 消息;原 WidgetToHostMessage 不扩展。
619
+ */
620
+ export type WidgetDevelopmentMessage = (WidgetToHostMessage | WidgetDiagnosticMessage | WidgetRenderResultMessage);
621
+ /**
622
+ * 经协商的开发扩展 Bridge 消息;仍受现有通道与消息预算约束。
623
+ */
624
+ export type WidgetDiagnosticMessage = (BridgeEnvelopeBase & {
625
+ type: "diagnostic";
626
+ payload: WidgetGuestDiagnostic;
627
+ });
628
+ /**
629
+ * 经协商的开发扩展 Bridge 消息;仍受现有通道与消息预算约束。
630
+ */
631
+ export type WidgetRenderResultMessage = (BridgeEnvelopeBase & {
632
+ type: "render-result";
633
+ payload: WidgetRenderResult;
634
+ });
548
635
  /**
549
636
  * Runtime 契约的汇总根容器;仅用于代码生成与符合性校验,不直接对外签发。
550
637
  */
@@ -569,12 +656,6 @@ export interface WidgetRuntimeContracts {
569
656
  fileDownloadResult?: FileDownloadResult;
570
657
  fileReadResult?: FileReadResult;
571
658
  fileWriteResult?: FileWriteResult;
572
- taskObservationSnapshot?: TaskObservationSnapshot;
573
- taskObservationEvent?: TaskObservationEvent;
574
- taskObservationBatch?: TaskObservationBatch;
575
- taskListField?: TaskListField;
576
- taskListItem?: TaskListItem;
577
- taskListPage?: TaskListPage;
578
659
  toolResultEnvelope?: ToolResultEnvelope;
579
660
  uiStateResult?: UiStateResult;
580
661
  uiStateWriteResult?: UiStateWriteResult;
@@ -585,6 +666,14 @@ export interface WidgetRuntimeContracts {
585
666
  hostUserEmailReadInput?: HostUserEmailReadInput;
586
667
  hostUserEmailReadOutput?: HostUserEmailReadOutput;
587
668
  hostUserServiceRequest?: HostUserServiceRequest;
669
+ widgetDevelopmentDiagnostic?: WidgetDevelopmentDiagnostic;
670
+ widgetRecoveryContext?: WidgetRecoveryContext;
671
+ widgetRecoveryPlan?: WidgetRecoveryPlan;
672
+ widgetRecoveryRule?: WidgetRecoveryRule;
673
+ widgetDevelopmentOffer?: WidgetDevelopmentOffer;
674
+ widgetDevelopmentConnect?: WidgetDevelopmentConnect;
675
+ widgetRenderResult?: WidgetRenderResult;
676
+ widgetDevelopmentMessage?: WidgetDevelopmentMessage;
588
677
  }
589
678
  /**
590
679
  * 渲染请求公共字段:schemaVersion、requestId、instanceId、revision、state、context。
@@ -1095,130 +1184,143 @@ export interface FileWriteResult {
1095
1184
  mutationId: FileMutationId;
1096
1185
  }
1097
1186
  /**
1098
- * 任务观察的当前快照:taskId、status 与 updatedAt;progress、message 可选。
1187
+ * 受限 UI 状态读取结果。
1099
1188
  */
1100
- export interface TaskObservationSnapshot {
1101
- taskId: string;
1102
- status: TaskStatus;
1103
- progress?: number;
1104
- message?: string;
1105
- updatedAt: string;
1189
+ export interface UiStateResult {
1190
+ found: boolean;
1191
+ value?: JsonValue;
1106
1192
  }
1107
1193
  /**
1108
- * 任务观察流中的单条事件;payload 由服务端裁剪。
1194
+ * 受限 UI 状态写入结果。
1109
1195
  */
1110
- export interface TaskObservationEvent {
1111
- id: string;
1112
- type: ("started" | "progress" | "succeeded" | "failed" | "cancelled" | "expired");
1113
- occurredAt: string;
1114
- payload: JsonValue;
1196
+ export interface UiStateWriteResult {
1197
+ status: "saved";
1115
1198
  }
1116
1199
  /**
1117
- * 任务观察的一页结果:快照 + 有限事件页 + 游标。
1200
+ * 读取用户资料的结果;含稳定 userId 与展示名。
1118
1201
  */
1119
- export interface TaskObservationBatch {
1202
+ export interface HostUserProfileReadOutput {
1203
+ userId: string;
1204
+ displayName: string;
1205
+ }
1206
+ /**
1207
+ * 读取用户邮箱的结果;email 为地址或 null。
1208
+ */
1209
+ export interface HostUserEmailReadOutput {
1210
+ email: (string | null);
1211
+ }
1212
+ /**
1213
+ * 可信出口的标准诊断;恢复指令和 scope 由宿主另行生成。
1214
+ */
1215
+ export interface WidgetDevelopmentDiagnostic {
1120
1216
  schemaVersion: 1;
1121
- taskId: string;
1122
- cursor: string;
1123
- reset: boolean;
1124
- hasMore: boolean;
1125
- snapshot: TaskObservationSnapshot;
1217
+ source: ("sdk" | "host" | "toolchain");
1218
+ code: string;
1219
+ sourceCode?: string;
1220
+ phase: ("discovery" | "build" | "config" | "load" | "handshake" | "render" | "update" | "capability" | "dispose");
1221
+ sourcePhase?: string;
1222
+ operation: string;
1223
+ severity: ("warning" | "request-error" | "instance-failure");
1224
+ message: string;
1225
+ retryable?: boolean;
1226
+ correlationId?: string;
1126
1227
  /**
1127
- * @maxItems 100
1228
+ * @maxItems 8
1128
1229
  */
1129
- events: TaskObservationEvent[];
1230
+ diagnostics?: [] | [WidgetDiagnosticDetail] | [WidgetDiagnosticDetail, WidgetDiagnosticDetail] | [WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail] | [WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail] | [WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail] | [WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail] | [WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail] | [WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail, WidgetDiagnosticDetail];
1231
+ io?: WidgetDiagnosticIO;
1130
1232
  }
1131
1233
  /**
1132
- * 任务列表中的受限展示字段;key 是稳定机器键,value 是 Host 裁剪后的展示文本。
1234
+ * 复用工具执行结果语义的可信恢复上下文;缺失字段表示未知,不能授权重放。
1133
1235
  */
1134
- export interface TaskListField {
1135
- /**
1136
- * 展示字段的稳定机器键,例如 machine 或 command。
1137
- */
1138
- key: string;
1139
- /**
1140
- * Host 完成授权与裁剪后的展示文本。
1141
- */
1142
- value: string;
1236
+ export interface WidgetRecoveryContext {
1237
+ progress?: WidgetRecoveryProgress;
1238
+ executionState?: ("not_started" | "finished" | "partial" | "unknown");
1239
+ mayHaveExecuted?: boolean;
1143
1240
  }
1144
1241
  /**
1145
- * Host 已授权发现的任务摘要;taskId 是可继续传给 tasks.watch 的不透明引用。
1242
+ * 可信宿主观察到的恢复进展;重复故障无新证据时不能重复同一修复。
1146
1243
  */
1147
- export interface TaskListItem {
1148
- /**
1149
- * 可继续传给 tasks.watch 的 Host 不透明任务引用。
1150
- */
1151
- taskId: string;
1152
- /**
1153
- * 任务来源类型的稳定机器键。
1154
- */
1155
- kind: string;
1156
- /**
1157
- * 任务的安全展示名称。
1158
- */
1159
- name: string;
1160
- status: TaskStatus;
1161
- /**
1162
- * 可选执行进度,取值范围为 0 到 1。
1163
- */
1164
- progress?: number;
1165
- /**
1166
- * Host 裁剪后的可选状态说明。
1167
- */
1168
- message?: string;
1169
- /**
1170
- * 任务摘要最后更新时间,使用 UTC ISO 8601 字符串。
1171
- */
1172
- updatedAt: string;
1173
- /**
1174
- * 任务面板可展示的受限附加字段。
1175
- *
1176
- * @maxItems 32
1177
- */
1178
- fields: TaskListField[];
1244
+ export interface WidgetRecoveryProgress {
1245
+ repeated: boolean;
1246
+ hasNewEvidence: boolean;
1179
1247
  }
1180
1248
  /**
1181
- * Host 已授权任务摘要的一页结果;nextCursor 缺失表示当前页已到末尾。
1249
+ * 可信宿主选择的恢复计划;不能由 Guest 的诊断 payload 指定。
1182
1250
  */
1183
- export interface TaskListPage {
1184
- /**
1185
- * 任务列表页结构版本,当前固定为 1。
1186
- */
1251
+ export interface WidgetRecoveryPlan {
1252
+ progress?: WidgetRecoveryProgress;
1187
1253
  schemaVersion: 1;
1254
+ ruleId: string;
1255
+ ruleVersion: number;
1256
+ disposition: ("retry" | "repair" | "inspect" | "external-action" | "stop");
1257
+ nextAction: WidgetRecoveryAction;
1258
+ verification: WidgetRecoveryVerification;
1259
+ guidance: string;
1188
1260
  /**
1189
- * 当前页中 Host 已授权的任务摘要。
1261
+ * 首项动作完成后的有限恢复步骤;宿主逐步验证前置条件,不原样盲目重放。
1190
1262
  *
1191
- * @maxItems 100
1192
- */
1193
- tasks: TaskListItem[];
1194
- /**
1195
- * 下一页的不透明游标;缺失表示当前列表已到末尾。
1263
+ * @maxItems 8
1196
1264
  */
1197
- nextCursor?: string;
1265
+ followUpActions: [] | [WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction];
1198
1266
  }
1199
1267
  /**
1200
- * 受限 UI 状态读取结果。
1268
+ * 恢复复验目标;下一成功构建须在取得回执后绑定实际产物。
1201
1269
  */
1202
- export interface UiStateResult {
1203
- found: boolean;
1204
- value?: JsonValue;
1270
+ export interface WidgetRecoveryVerification {
1271
+ target: ("current-attempt" | "next-built-generation" | "original-operation");
1272
+ milestone: ("diagnostics-updated" | "render-handled" | "scenario-passed" | "operation-confirmed");
1273
+ scenarioId?: string;
1205
1274
  }
1206
1275
  /**
1207
- * 受限 UI 状态写入结果。
1276
+ * 公共恢复规则目录条目;空 codes 仅用于显式 unknown 回退。
1208
1277
  */
1209
- export interface UiStateWriteResult {
1210
- status: "saved";
1278
+ export interface WidgetRecoveryRule {
1279
+ id: string;
1280
+ version: number;
1281
+ /**
1282
+ * @minItems 1
1283
+ * @maxItems 3
1284
+ */
1285
+ sources: [("sdk" | "host" | "toolchain")] | [("sdk" | "host" | "toolchain"), ("sdk" | "host" | "toolchain")] | [("sdk" | "host" | "toolchain"), ("sdk" | "host" | "toolchain"), ("sdk" | "host" | "toolchain")];
1286
+ /**
1287
+ * @maxItems 64
1288
+ */
1289
+ codes: string[];
1290
+ disposition: ("retry" | "repair" | "inspect" | "external-action" | "stop");
1291
+ nextAction: WidgetRecoveryAction;
1292
+ verification: WidgetRecoveryVerification;
1293
+ guidance: string;
1294
+ /**
1295
+ * 首项动作完成后的有限恢复步骤;宿主逐步验证前置条件,不原样盲目重放。
1296
+ *
1297
+ * @maxItems 8
1298
+ */
1299
+ followUpActions: [] | [WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction] | [WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction, WidgetRecoveryAction];
1211
1300
  }
1212
1301
  /**
1213
- * 读取用户资料的结果;含稳定 userId 与展示名。
1302
+ * 独立于旧 bootstrap-ready 的支持声明,接收方仍须校验 frame 来源和挂载尝试。
1214
1303
  */
1215
- export interface HostUserProfileReadOutput {
1216
- userId: string;
1217
- displayName: string;
1304
+ export interface WidgetDevelopmentOffer {
1305
+ type: "widget-bootstrap-offer";
1306
+ protocolVersion: 1;
1307
+ /**
1308
+ * @minItems 1
1309
+ * @maxItems 1
1310
+ */
1311
+ extensions: [WidgetDevelopmentExtension];
1218
1312
  }
1219
1313
  /**
1220
- * 读取用户邮箱的结果;email 为地址或 null。
1314
+ * 仅在收到当前 iframe 合法 offer 后使用的扩展 connect;旧形状保持不变。
1221
1315
  */
1222
- export interface HostUserEmailReadOutput {
1223
- email: (string | null);
1316
+ export interface WidgetDevelopmentConnect {
1317
+ type: "widget-host-connect";
1318
+ protocolVersion: 1;
1319
+ channelId: string;
1320
+ initPayload: InitPayload;
1321
+ /**
1322
+ * @minItems 1
1323
+ * @maxItems 1
1324
+ */
1325
+ extensions: [WidgetDevelopmentExtension];
1224
1326
  }
@@ -8,9 +8,9 @@ import type { BridgeEnvelopeBase, GrantedCapability, HostToWidgetMessage, Render
8
8
  * public surface drift from the canonical contract.
9
9
  */
10
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";
11
+ export type { ActivationEvents, HostUserPermission, HostUserPermissions, RequestedPresentationCapability, RequestedRegionCapability, StateCapabilityRequest, WidgetContributionConfig, WidgetManifest, } from "./generated-manifest.js";
12
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";
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, 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
14
  export type { WidgetActivationEvent, WidgetActivationEvents, WidgetPluginManifest, WidgetToolPhase, } from "./plugin-manifest.js";
15
15
  export { isWidgetActivationEvent, WIDGET_ACTIVATION_EVENTS, } from "./plugin-manifest.js";
16
16
  export type { WidgetEventName } from "./widget-events.js";
@@ -41,3 +41,8 @@ export type BridgeEnvelope<TType extends string = string, TPayload = unknown> =
41
41
  };
42
42
  /** 可加载绑定与降级绑定的联合,即 Host Runtime Config 中一条 binding 的两种结果。 */
43
43
  export type ResolvedWidgetBinding = LoadableBinding | FallbackBinding;
44
+ export { isWidgetDevelopmentOffer, isWidgetGuestDiagnostic, isWidgetRenderResult, } from "./development-guards.js";
45
+ export type { WidgetDevelopmentConnect, WidgetDevelopmentDiagnostic, WidgetDevelopmentExtension, WidgetDevelopmentMessage, WidgetDevelopmentOffer, WidgetDiagnosticDetail, WidgetDiagnosticIO, WidgetDiagnosticMessage, WidgetGuestDiagnostic, WidgetRecoveryAction, WidgetRecoveryContext, WidgetRecoveryPlan, WidgetRecoveryProgress, WidgetRecoveryRule, WidgetRecoveryVerification, WidgetRenderResult, WidgetRenderResultMessage, } from "./generated-runtime-contracts.js";
46
+ export { createWidgetRecoveryPlan, findWidgetRecoveryRule, projectWidgetCapabilityDiagnostic, projectWidgetRuntimeDiagnostic, projectWidgetToolchainDiagnostic, selectWidgetDevelopmentExtensions, WIDGET_RECOVERY_RULES, } from "./widget-recovery.js";
47
+ /** SDK 运行层使用的已协商消息;旧 WidgetProtocolMessage 联合保持不变。 */
48
+ export type WidgetRuntimeProtocolMessage = WidgetProtocolMessage | import("./generated-runtime-contracts.js").WidgetDevelopmentMessage;
@@ -0,0 +1,19 @@
1
+ import type { CapabilityResult, WidgetDevelopmentDiagnostic, WidgetDevelopmentExtension, WidgetDevelopmentOffer, WidgetError, WidgetGuestDiagnostic, WidgetRecoveryContext, WidgetRecoveryPlan, WidgetRecoveryRule } from "./generated-runtime-contracts.js";
2
+ /** 包含 unknown 与操作核对规则,Agent 可按 plan.ruleId 定位每个实际计划。 */
3
+ export declare const WIDGET_RECOVERY_RULES: readonly WidgetRecoveryRule[];
4
+ /** 根据稳定码选择通用规则;未知码明确走排查,不匹配自由文本。 */
5
+ export declare function findWidgetRecoveryRule(diagnostic: Pick<WidgetDevelopmentDiagnostic, "source" | "code">): WidgetRecoveryRule;
6
+ /** 纯规则选择,不运行工具;宿主仍须校验实际能力、权限、scope 与恢复预算。 */
7
+ export declare function createWidgetRecoveryPlan(diagnostic: WidgetDevelopmentDiagnostic, context?: WidgetRecoveryContext): WidgetRecoveryPlan;
8
+ /** 只投影已校验的稳定字段;Guest message、context 和恢复文字不进入可信诊断。 */
9
+ export declare function projectWidgetRuntimeDiagnostic(error: WidgetError, operation: string, diagnostics?: WidgetDevelopmentDiagnostic["diagnostics"]): WidgetGuestDiagnostic;
10
+ /** 能力拒绝只影响当前请求;不把它投影为实例终态。 */
11
+ export declare function projectWidgetCapabilityDiagnostic(failure: Extract<CapabilityResult, {
12
+ ok: false;
13
+ }>, operation: string): WidgetDevelopmentDiagnostic;
14
+ /** 工程错误仅提取稳定 code;原始 stdout/stderr 由可信工具单独脱敏投影。 */
15
+ export declare function projectWidgetToolchainDiagnostic(error: {
16
+ code: string;
17
+ }, operation: string, phase: "discovery" | "build" | "config"): WidgetDevelopmentDiagnostic;
18
+ /** 仅选择双方声明的扩展;实际 frame 来源和当前 attempt 仍由 Host 校验。 */
19
+ export declare function selectWidgetDevelopmentExtensions(offer: WidgetDevelopmentOffer | undefined, supported: readonly WidgetDevelopmentExtension[]): readonly WidgetDevelopmentExtension[];
@@ -1,5 +1,8 @@
1
+ import { n as isWidgetGuestDiagnostic, r as isWidgetRenderResult } from "./development-guards-COvBR0G1.js";
1
2
  //#region src/runtime/transport.ts
2
3
  const protocolMessageTypes = /* @__PURE__ */ new Set([
4
+ "diagnostic",
5
+ "render-result",
3
6
  "init",
4
7
  "render",
5
8
  "update",
@@ -25,6 +28,8 @@ function isFiniteNonNegative(value) {
25
28
  }
26
29
  function isProtocolPayload(type, payload) {
27
30
  switch (type) {
31
+ case "diagnostic": return isWidgetGuestDiagnostic(payload);
32
+ case "render-result": return isWidgetRenderResult(payload);
28
33
  case "init": return hasRequiredKeys(payload, [
29
34
  "instanceId",
30
35
  "locale",
@@ -1,4 +1,4 @@
1
- import type { CapabilityRequest, CapabilityResult, InitPayload, PresentationCapabilityResult, RegionCapabilityResult, RenderRequest, WidgetError, WidgetLiveEvent } from "../protocol/index.js";
1
+ import type { CapabilityRequest, CapabilityResult, InitPayload, PresentationCapabilityResult, RegionCapabilityResult, RenderRequest, WidgetError, WidgetGuestDiagnostic, WidgetLiveEvent, WidgetRenderResult } 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";
@@ -109,6 +109,8 @@ export declare class WidgetRuntimeClient {
109
109
  private stopPresentationKeyboard;
110
110
  dispose(): void;
111
111
  private receiveConnection;
112
+ reportDevelopmentDiagnostic(diagnostic: WidgetGuestDiagnostic): void;
113
+ reportRenderResult(result: WidgetRenderResult): void;
112
114
  private requireClient;
113
115
  private removeConnectionListener;
114
116
  private failConnection;
@@ -1,4 +1,4 @@
1
- import type { CapabilityRequest, CapabilityResult, GrantedCapability, InitPayload, PresentationCapabilityRequest, PresentationCapabilityResult, RegionCapabilityRequest, RegionCapabilityResult, RenderRequest, WidgetError, WidgetLiveEvent } from "../protocol/index.js";
1
+ import type { CapabilityRequest, CapabilityResult, GrantedCapability, InitPayload, PresentationCapabilityRequest, PresentationCapabilityResult, RegionCapabilityRequest, RegionCapabilityResult, RenderRequest, WidgetError, WidgetGuestDiagnostic, WidgetLiveEvent, WidgetRenderResult } 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";
@@ -8,6 +8,7 @@ export interface WidgetClientOptions {
8
8
  widgetSdkVersion: string;
9
9
  hostApiVersion?: 1;
10
10
  initialPayload?: InitPayload;
11
+ developmentDiagnostics?: boolean;
11
12
  handshakeTimeoutMs?: number;
12
13
  capabilityTimeoutMs?: number;
13
14
  createMessageId?: () => string;
@@ -48,6 +49,7 @@ export declare class WidgetClient {
48
49
  private readonly endpoint;
49
50
  private readonly widgetSdkVersion;
50
51
  private readonly channelId;
52
+ private readonly developmentDiagnostics;
51
53
  private readonly handshakeTimeoutMs;
52
54
  private readonly capabilityTimeoutMs;
53
55
  private readonly createMessageId;
@@ -81,6 +83,8 @@ export declare class WidgetClient {
81
83
  private receive;
82
84
  private initialize;
83
85
  private initializeAsync;
86
+ reportDevelopmentDiagnostic(diagnostic: WidgetGuestDiagnostic): void;
87
+ reportRenderResult(result: WidgetRenderResult): void;
84
88
  private send;
85
89
  private assertUsable;
86
90
  private acceptsRender;
@@ -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-D2xmZVSb.js";
2
- import { i as isWidgetProtocolMessage, r as MessagePortTransport } from "../protocol-endpoint-CDz-YDGT.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-Bn_ee8xy.js";
2
+ import { i as isWidgetProtocolMessage, r as MessagePortTransport } from "../protocol-endpoint-DbT0OJNu.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,17 +1,17 @@
1
- import type { WidgetProtocolMessage } from "../protocol/index.js";
1
+ import type { WidgetRuntimeProtocolMessage } 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];
5
- export type ProtocolMessageBody<TMessage extends WidgetProtocolMessage> = TMessage extends WidgetProtocolMessage ? Omit<TMessage, EnvelopeField> : never;
6
- interface ProtocolEndpointOptions<TInbound extends WidgetProtocolMessage> {
5
+ export type ProtocolMessageBody<TMessage extends WidgetRuntimeProtocolMessage> = TMessage extends WidgetRuntimeProtocolMessage ? Omit<TMessage, EnvelopeField> : never;
6
+ interface ProtocolEndpointOptions<TInbound extends WidgetRuntimeProtocolMessage> {
7
7
  transport: WidgetTransport;
8
8
  channelId: string;
9
9
  createMessageId: () => string;
10
- acceptsInbound: (message: WidgetProtocolMessage) => message is TInbound;
10
+ acceptsInbound: (message: WidgetRuntimeProtocolMessage) => message is TInbound;
11
11
  onMessage: (message: TInbound) => void;
12
12
  onError?: (error: Error) => void;
13
13
  }
14
- export declare class ProtocolEndpoint<TInbound extends WidgetProtocolMessage, TOutbound extends WidgetProtocolMessage> {
14
+ export declare class ProtocolEndpoint<TInbound extends WidgetRuntimeProtocolMessage, TOutbound extends WidgetRuntimeProtocolMessage> {
15
15
  private readonly transport;
16
16
  private readonly channelId;
17
17
  private readonly createMessageId;
@@ -1,7 +1,7 @@
1
- import type { WidgetProtocolMessage } from "../protocol/index.js";
1
+ import type { WidgetRuntimeProtocolMessage } from "../protocol/index.js";
2
2
  export interface WidgetTransport {
3
- send(message: WidgetProtocolMessage): void;
4
- onMessage(listener: (message: WidgetProtocolMessage) => void): () => void;
3
+ send(message: WidgetRuntimeProtocolMessage): void;
4
+ onMessage(listener: (message: WidgetRuntimeProtocolMessage) => void): () => void;
5
5
  onError?(listener: (error: Error) => void): () => void;
6
6
  close(): void;
7
7
  }
@@ -9,7 +9,7 @@ export interface WidgetTransport {
9
9
  export interface WidgetMessagePort {
10
10
  onmessage: ((event: MessageEvent<unknown>) => void) | null;
11
11
  onmessageerror?: ((event: MessageEvent<unknown>) => void) | null;
12
- postMessage(message: WidgetProtocolMessage): void;
12
+ postMessage(message: WidgetRuntimeProtocolMessage): void;
13
13
  start?: () => void;
14
14
  close(): void;
15
15
  }
@@ -17,14 +17,14 @@ export interface WidgetMessagePort {
17
17
  * Performs the inexpensive checks that are possible at the transport edge.
18
18
  * Payload-specific validation stays with the contract/conformance layer.
19
19
  */
20
- export declare function isWidgetProtocolMessage(value: unknown): value is WidgetProtocolMessage;
20
+ export declare function isWidgetProtocolMessage(value: unknown): value is WidgetRuntimeProtocolMessage;
21
21
  export declare class MemoryTransport implements WidgetTransport {
22
22
  private peer?;
23
23
  private readonly listeners;
24
24
  private closed;
25
25
  static pair(): readonly [MemoryTransport, MemoryTransport];
26
- send(message: WidgetProtocolMessage): void;
27
- onMessage(listener: (message: WidgetProtocolMessage) => void): () => void;
26
+ send(message: WidgetRuntimeProtocolMessage): void;
27
+ onMessage(listener: (message: WidgetRuntimeProtocolMessage) => void): () => void;
28
28
  onError(): () => void;
29
29
  close(): void;
30
30
  }
@@ -35,8 +35,8 @@ export declare class MessagePortTransport implements WidgetTransport {
35
35
  private readonly errorListeners;
36
36
  private closed;
37
37
  constructor(port: WidgetMessagePort);
38
- send(message: WidgetProtocolMessage): void;
39
- onMessage(listener: (message: WidgetProtocolMessage) => void): () => void;
38
+ send(message: WidgetRuntimeProtocolMessage): void;
39
+ onMessage(listener: (message: WidgetRuntimeProtocolMessage) => void): () => void;
40
40
  onError(listener: (error: Error) => void): () => void;
41
41
  private reportError;
42
42
  close(): void;