@dp-bohrium/widget-contracts 0.0.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/LICENSE +21 -0
- package/README.md +190 -0
- package/conformance/bridge/capability-request.json +23 -0
- package/conformance/bridge/network-fetch-denied.json +16 -0
- package/conformance/bridge/network-fetch-request.json +19 -0
- package/conformance/bridge/network-fetch-success.json +22 -0
- package/conformance/bridge/presentation-change-surface-request.json +14 -0
- package/conformance/bridge/presentation-close-request.json +14 -0
- package/conformance/bridge/presentation-close-success.json +11 -0
- package/conformance/bridge/presentation-downgrade-success.json +14 -0
- package/conformance/bridge/presentation-focus-backward-request.json +14 -0
- package/conformance/bridge/presentation-focus-boundary-success.json +14 -0
- package/conformance/bridge/presentation-focus-forward-request.json +14 -0
- package/conformance/bridge/presentation-init.json +70 -0
- package/conformance/bridge/presentation-policy-denied.json +16 -0
- package/conformance/bridge/presentation-present-request.json +14 -0
- package/conformance/bridge/presentation-user-denied.json +16 -0
- package/conformance/bridge/ready.json +11 -0
- package/conformance/bundles/minimal-file-preview/entry.js +1 -0
- package/conformance/bundles/minimal-file-preview/manifest.json +12 -0
- package/conformance/bundles/minimal-file-preview/samples/file-preview.json +1 -0
- package/conformance/bundles/minimal-panel/entry.js +1 -0
- package/conformance/bundles/minimal-panel/manifest.json +11 -0
- package/conformance/bundles/minimal-panel/samples/panel.json +1 -0
- package/conformance/bundles/minimal-tool-result/entry.js +1 -0
- package/conformance/bundles/minimal-tool-result/manifest.json +11 -0
- package/conformance/bundles/minimal-tool-result/samples/tool-result.json +1 -0
- package/conformance/file-responses/list.json +1 -0
- package/conformance/file-responses/metadata.json +11 -0
- package/conformance/file-responses/permission-denied.json +6 -0
- package/conformance/file-responses/resource-limit.json +1 -0
- package/conformance/file-responses/text-content.json +1 -0
- package/conformance/host-runtime-config/invalid-missing-manifest-fields.json +55 -0
- package/conformance/host-runtime-config/invalid-static-origins.json +60 -0
- package/conformance/host-runtime-config/valid.json +85 -0
- package/conformance/invalid-bridge-messages/network-fetch-mixed-case-forbidden-header.json +21 -0
- package/conformance/invalid-manifests/missing-target.json +11 -0
- package/conformance/invalid-manifests/presentation-duplicate-surfaces.json +16 -0
- package/conformance/invalid-manifests/presentation-empty-surfaces.json +14 -0
- package/conformance/invalid-manifests/presentation-unknown-surface.json +16 -0
- package/conformance/invalid-manifests/unknown-field.json +12 -0
- package/conformance/invalid-network-requests/mixed-case-forbidden-header.json +11 -0
- package/conformance/invalid-presentation-grants/duplicate-surfaces.json +5 -0
- package/conformance/invalid-presentation-grants/empty-surfaces.json +5 -0
- package/conformance/invalid-presentation-grants/false-confirmation.json +5 -0
- package/conformance/invalid-presentation-grants/missing-confirmation.json +4 -0
- package/conformance/invalid-presentation-grants/unknown-surface.json +5 -0
- package/conformance/invalid-presentation-requests/change-surface-missing-surface.json +4 -0
- package/conformance/invalid-presentation-requests/close-with-surface.json +4 -0
- package/conformance/invalid-presentation-requests/focus-boundary-missing-direction.json +4 -0
- package/conformance/invalid-presentation-requests/focus-boundary-unknown-direction.json +4 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-coordinates.json +9 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-event-provenance.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-generation.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-identity.json +12 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-key.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-modifiers.json +11 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-selector.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-surface.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-target.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-timestamp.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-z-index.json +8 -0
- package/conformance/invalid-presentation-requests/present-missing-surface.json +4 -0
- package/conformance/invalid-presentation-requests/unknown-surface.json +4 -0
- package/conformance/invalid-presentation-requests/widget-controls-coordinates.json +9 -0
- package/conformance/invalid-presentation-requests/widget-controls-geometry.json +8 -0
- package/conformance/invalid-presentation-requests/widget-controls-instance-id.json +8 -0
- package/conformance/invalid-presentation-requests/widget-controls-principal.json +8 -0
- package/conformance/invalid-presentation-requests/widget-controls-run-id.json +4 -0
- package/conformance/invalid-presentation-requests/widget-controls-widget-id.json +8 -0
- package/conformance/invalid-presentation-requests/widget-controls-widget-version-id.json +8 -0
- package/conformance/invalid-presentation-requests/widget-controls-z-index.json +4 -0
- package/conformance/invalid-render-inputs/malformed.json +17 -0
- package/conformance/manifests/valid-file-preview.json +12 -0
- package/conformance/manifests/valid-network.json +15 -0
- package/conformance/manifests/valid-panel.json +11 -0
- package/conformance/manifests/valid-presentation-panel.json +21 -0
- package/conformance/manifests/valid-tool-result.json +14 -0
- package/conformance/render-inputs/compatibility/literature-search-paper-results.json +75 -0
- package/conformance/render-inputs/compatibility/scientific-bibliography-bibtex.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-dataset-csv.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-manuscript-latex.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-manuscript-markdown.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-molecule-mol.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-molecule-mol2.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-notebook-ipynb.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-paper-pdf.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-protein-pdb.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-source-python.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-structure-cif.json +47 -0
- package/conformance/render-inputs/compatibility/scientific-structure-poscar.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-structure-stru.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-trajectory-xyz.json +10 -0
- package/conformance/render-inputs/compatibility/thinking-process-paper-search.json +25 -0
- package/conformance/render-inputs/compatibility/thinking-process-scholar-search.json +25 -0
- package/conformance/render-inputs/compatibility/thinking-process-web-search.json +25 -0
- package/conformance/render-inputs/compatibility/workspace-file-search.json +24 -0
- package/conformance/render-inputs/compatibility/workspace-file-tree.json +24 -0
- package/conformance/render-inputs/empty.json +10 -0
- package/conformance/render-inputs/file-preview.json +10 -0
- package/conformance/render-inputs/incremental-update.json +10 -0
- package/conformance/render-inputs/large.json +10 -0
- package/conformance/render-inputs/malformed.json +1 -0
- package/conformance/render-inputs/panel.json +10 -0
- package/conformance/render-inputs/partial-state-full-snapshot.json +40 -0
- package/conformance/render-inputs/tool-result.json +10 -0
- package/dist/generated-host-runtime-config.d.ts +246 -0
- package/dist/generated-host-runtime-config.js +3 -0
- package/dist/generated-manifest.d.ts +86 -0
- package/dist/generated-manifest.js +3 -0
- package/dist/generated-runtime-contracts.d.ts +401 -0
- package/dist/generated-runtime-contracts.js +3 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +2 -0
- package/package.json +55 -0
- package/schemas/host-runtime-config.schema.json +185 -0
- package/schemas/widget-manifest.schema.json +227 -0
- package/schemas/widget-runtime-contracts.schema.json +1478 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/** GENERATED FILE. Do not edit directly. */
|
|
2
|
+
export type WidgetSlot = ("tool-result" | "file-preview" | "panel");
|
|
3
|
+
export type RenderRequest = (ToolResultRenderRequest | FilePreviewRenderRequest | PanelRenderRequest);
|
|
4
|
+
export type ToolResultRenderRequest = (RenderRequestBase & {
|
|
5
|
+
slot: "tool-result";
|
|
6
|
+
content: ToolResultContent;
|
|
7
|
+
});
|
|
8
|
+
export type RenderState = ("loading" | "partial" | "complete" | "error");
|
|
9
|
+
export type ThemeMode = ("light" | "dark");
|
|
10
|
+
export type GrantedCapability = ({
|
|
11
|
+
name: "files.list";
|
|
12
|
+
limits: {
|
|
13
|
+
pageSize: number;
|
|
14
|
+
callsPerMinute: number;
|
|
15
|
+
};
|
|
16
|
+
} | {
|
|
17
|
+
name: "files.metadata";
|
|
18
|
+
limits: {
|
|
19
|
+
callsPerMinute: number;
|
|
20
|
+
};
|
|
21
|
+
} | {
|
|
22
|
+
name: "files.read";
|
|
23
|
+
limits: {
|
|
24
|
+
bytesPerRequest: number;
|
|
25
|
+
bytesPerRun: number;
|
|
26
|
+
callsPerMinute: number;
|
|
27
|
+
};
|
|
28
|
+
} | {
|
|
29
|
+
name: "events.read";
|
|
30
|
+
/**
|
|
31
|
+
* @minItems 1
|
|
32
|
+
* @maxItems 32
|
|
33
|
+
*/
|
|
34
|
+
topics: [string, ...(string)[]];
|
|
35
|
+
limits: {
|
|
36
|
+
callsPerMinute: number;
|
|
37
|
+
pageSize: number;
|
|
38
|
+
minPollMs: number;
|
|
39
|
+
};
|
|
40
|
+
} | {
|
|
41
|
+
name: "actions.invoke";
|
|
42
|
+
/**
|
|
43
|
+
* @minItems 1
|
|
44
|
+
* @maxItems 32
|
|
45
|
+
*/
|
|
46
|
+
actions: [string, ...(string)[]];
|
|
47
|
+
limits: {
|
|
48
|
+
callsPerMinute: number;
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
name: "network.fetch";
|
|
52
|
+
limits: WidgetNetworkLimits;
|
|
53
|
+
} | GrantedPresentationCapability);
|
|
54
|
+
export type PositiveInteger = number;
|
|
55
|
+
export type JsonValue = (null | boolean | number | string | JsonValue[] | {
|
|
56
|
+
[k: string]: JsonValue;
|
|
57
|
+
});
|
|
58
|
+
export type FilePreviewRenderRequest = (RenderRequestBase & {
|
|
59
|
+
slot: "file-preview";
|
|
60
|
+
content: FilePreviewContent;
|
|
61
|
+
});
|
|
62
|
+
export type PanelRenderRequest = (RenderRequestBase & {
|
|
63
|
+
slot: "panel";
|
|
64
|
+
content: PanelContent;
|
|
65
|
+
});
|
|
66
|
+
export type HostToWidgetMessage = (InitMessage | RenderMessage | CapabilityResultMessage | ErrorMessage | DisposeMessage);
|
|
67
|
+
export type InitMessage = (BridgeEnvelopeBase & {
|
|
68
|
+
type: "init";
|
|
69
|
+
payload: InitPayload;
|
|
70
|
+
});
|
|
71
|
+
export type RenderMessage = (BridgeEnvelopeBase & {
|
|
72
|
+
type: ("render" | "update");
|
|
73
|
+
payload: RenderRequest;
|
|
74
|
+
});
|
|
75
|
+
export type CapabilityResultMessage = (BridgeEnvelopeBase & {
|
|
76
|
+
type: "capability-result";
|
|
77
|
+
payload: {
|
|
78
|
+
requestId: string;
|
|
79
|
+
result: CapabilityResult;
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
export type CapabilityResult = ({
|
|
83
|
+
ok: true;
|
|
84
|
+
data: JsonValue;
|
|
85
|
+
} | {
|
|
86
|
+
ok: false;
|
|
87
|
+
reason: ("unsupported" | "permission-denied" | "resource-limit" | "invalid-reference" | "timeout" | "internal-error" | "network-consent-denied" | "network-policy-denied" | "network-transport-unavailable" | "network-request-too-large" | "network-response-too-large" | "network-rate-limited" | "network-redirect-denied" | "network-credential-unavailable" | "network-scope-invalid" | "network-dns-denied" | "network-error");
|
|
88
|
+
message: string;
|
|
89
|
+
retryable: boolean;
|
|
90
|
+
});
|
|
91
|
+
export type ErrorMessage = (BridgeEnvelopeBase & {
|
|
92
|
+
type: "error";
|
|
93
|
+
payload: WidgetError;
|
|
94
|
+
});
|
|
95
|
+
export type DisposeMessage = (BridgeEnvelopeBase & {
|
|
96
|
+
type: "dispose";
|
|
97
|
+
payload: {
|
|
98
|
+
reason: string;
|
|
99
|
+
deadlineMs: number;
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
export type WidgetToHostMessage = (ReadyMessage | ResizeMessage | CapabilityRequestMessage | ErrorMessage);
|
|
103
|
+
export type ReadyMessage = (BridgeEnvelopeBase & {
|
|
104
|
+
type: "ready";
|
|
105
|
+
payload: {
|
|
106
|
+
widgetSdkVersion: string;
|
|
107
|
+
hostApiVersion: 1;
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
export type ResizeMessage = (BridgeEnvelopeBase & {
|
|
111
|
+
type: "resize";
|
|
112
|
+
payload: {
|
|
113
|
+
width: number;
|
|
114
|
+
height: number;
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
export type CapabilityRequestMessage = (BridgeEnvelopeBase & {
|
|
118
|
+
type: "capability-request";
|
|
119
|
+
payload: {
|
|
120
|
+
requestId: string;
|
|
121
|
+
request: CapabilityRequest;
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
export type CapabilityRequest = ({
|
|
125
|
+
operation: "files.list";
|
|
126
|
+
input: {
|
|
127
|
+
directory: FileReference;
|
|
128
|
+
cursor?: string;
|
|
129
|
+
limit?: number;
|
|
130
|
+
};
|
|
131
|
+
} | {
|
|
132
|
+
operation: "files.metadata";
|
|
133
|
+
input: {
|
|
134
|
+
reference: FileReference;
|
|
135
|
+
};
|
|
136
|
+
} | {
|
|
137
|
+
operation: "files.read";
|
|
138
|
+
input: {
|
|
139
|
+
file: FileReference;
|
|
140
|
+
offset: number;
|
|
141
|
+
length: number;
|
|
142
|
+
encoding: ("utf8" | "base64");
|
|
143
|
+
};
|
|
144
|
+
} | {
|
|
145
|
+
operation: "events.read";
|
|
146
|
+
input: {
|
|
147
|
+
topic: string;
|
|
148
|
+
cursor?: string;
|
|
149
|
+
limit: number;
|
|
150
|
+
};
|
|
151
|
+
} | {
|
|
152
|
+
operation: "actions.invoke";
|
|
153
|
+
input: {
|
|
154
|
+
action: string;
|
|
155
|
+
idempotencyKey: string;
|
|
156
|
+
arguments: JsonValue;
|
|
157
|
+
};
|
|
158
|
+
} | {
|
|
159
|
+
operation: "network.fetch";
|
|
160
|
+
input: WidgetNetworkFetchInput;
|
|
161
|
+
} | PresentationCapabilityRequest);
|
|
162
|
+
export type PresentationCapabilityRequest = ({
|
|
163
|
+
operation: "ui.presentation";
|
|
164
|
+
input: ({
|
|
165
|
+
action: ("present" | "change-surface");
|
|
166
|
+
surface: ("workspace" | "floating" | "overlay");
|
|
167
|
+
} | {
|
|
168
|
+
action: "close";
|
|
169
|
+
});
|
|
170
|
+
} | FocusBoundaryPresentationCapabilityRequest);
|
|
171
|
+
export type FocusBoundaryPresentationCapabilityRequest = {
|
|
172
|
+
operation: "ui.presentation";
|
|
173
|
+
input: {
|
|
174
|
+
action: "focus-boundary";
|
|
175
|
+
direction: ("forward" | "backward");
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
export type PresentationCapabilityOutput = ({
|
|
179
|
+
action: ("present" | "change-surface");
|
|
180
|
+
surface: ("workspace" | "floating" | "overlay");
|
|
181
|
+
} | {
|
|
182
|
+
action: "close";
|
|
183
|
+
} | {
|
|
184
|
+
action: "focus-boundary";
|
|
185
|
+
direction: ("forward" | "backward");
|
|
186
|
+
});
|
|
187
|
+
export type PresentationCapabilityResult = ({
|
|
188
|
+
ok: true;
|
|
189
|
+
data: PresentationCapabilityOutput;
|
|
190
|
+
} | {
|
|
191
|
+
ok: false;
|
|
192
|
+
reason: ("unsupported" | "permission-denied" | "resource-limit" | "invalid-reference" | "timeout" | "internal-error" | "network-consent-denied" | "network-policy-denied" | "network-transport-unavailable" | "network-request-too-large" | "network-response-too-large" | "network-rate-limited" | "network-redirect-denied" | "network-credential-unavailable" | "network-scope-invalid" | "network-dns-denied" | "network-error");
|
|
193
|
+
message: string;
|
|
194
|
+
retryable: boolean;
|
|
195
|
+
});
|
|
196
|
+
export interface WidgetRuntimeContracts {
|
|
197
|
+
widgetSlot: WidgetSlot;
|
|
198
|
+
renderRequest: RenderRequest;
|
|
199
|
+
hostToWidgetMessage: HostToWidgetMessage;
|
|
200
|
+
widgetToHostMessage: WidgetToHostMessage;
|
|
201
|
+
capabilityRequest: CapabilityRequest;
|
|
202
|
+
capabilityResult: CapabilityResult;
|
|
203
|
+
widgetError: WidgetError;
|
|
204
|
+
resourceBudget: ResourceBudget;
|
|
205
|
+
widgetEventBatch?: WidgetEventBatch;
|
|
206
|
+
toolLifecycleEvent?: ToolLifecycleEvent;
|
|
207
|
+
widgetNetworkFetchOutput?: WidgetNetworkFetchOutput;
|
|
208
|
+
presentationCapabilityOutput?: PresentationCapabilityOutput;
|
|
209
|
+
presentationCapabilityResult?: PresentationCapabilityResult;
|
|
210
|
+
}
|
|
211
|
+
export interface RenderRequestBase {
|
|
212
|
+
schemaVersion: 1;
|
|
213
|
+
requestId: string;
|
|
214
|
+
instanceId: string;
|
|
215
|
+
revision: number;
|
|
216
|
+
state: RenderState;
|
|
217
|
+
context: WidgetRenderContext;
|
|
218
|
+
}
|
|
219
|
+
export interface WidgetRenderContext {
|
|
220
|
+
locale: string;
|
|
221
|
+
theme: Theme;
|
|
222
|
+
viewport: {
|
|
223
|
+
width: number;
|
|
224
|
+
height: number;
|
|
225
|
+
};
|
|
226
|
+
capabilities: GrantedCapability[];
|
|
227
|
+
correlationId: string;
|
|
228
|
+
}
|
|
229
|
+
export interface Theme {
|
|
230
|
+
mode: ThemeMode;
|
|
231
|
+
tokens: {
|
|
232
|
+
background: string;
|
|
233
|
+
foreground: string;
|
|
234
|
+
muted: string;
|
|
235
|
+
mutedForeground: string;
|
|
236
|
+
border: string;
|
|
237
|
+
primary: string;
|
|
238
|
+
danger: string;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
export interface WidgetNetworkLimits {
|
|
242
|
+
timeoutMs: PositiveInteger;
|
|
243
|
+
maxRedirects: PositiveInteger;
|
|
244
|
+
maxConcurrentRequests: PositiveInteger;
|
|
245
|
+
callsPerMinute: PositiveInteger;
|
|
246
|
+
requestHeaderBytes: PositiveInteger;
|
|
247
|
+
responseHeaderBytes: PositiveInteger;
|
|
248
|
+
requestBodyBytes: PositiveInteger;
|
|
249
|
+
responseBodyBytes: PositiveInteger;
|
|
250
|
+
}
|
|
251
|
+
export interface GrantedPresentationCapability {
|
|
252
|
+
name: "ui.presentation";
|
|
253
|
+
/**
|
|
254
|
+
* @minItems 1
|
|
255
|
+
* @maxItems 2
|
|
256
|
+
*/
|
|
257
|
+
surfaces: [("floating" | "overlay")] | [("floating" | "overlay"), ("floating" | "overlay")];
|
|
258
|
+
requiresHostConfirmation: true;
|
|
259
|
+
}
|
|
260
|
+
export interface ToolResultContent {
|
|
261
|
+
slot: "tool-result";
|
|
262
|
+
tool: {
|
|
263
|
+
name: string;
|
|
264
|
+
callId: string;
|
|
265
|
+
status: ("running" | "succeeded" | "failed" | "cancelled");
|
|
266
|
+
};
|
|
267
|
+
input: JsonValue;
|
|
268
|
+
result?: JsonValue;
|
|
269
|
+
error?: {
|
|
270
|
+
code: string;
|
|
271
|
+
message: string;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
export interface FilePreviewContent {
|
|
275
|
+
slot: "file-preview";
|
|
276
|
+
file: FileReference;
|
|
277
|
+
preview?: JsonValue;
|
|
278
|
+
}
|
|
279
|
+
export interface FileReference {
|
|
280
|
+
id: string;
|
|
281
|
+
kind: ("file" | "directory");
|
|
282
|
+
name: string;
|
|
283
|
+
extension?: string;
|
|
284
|
+
mimeType?: string;
|
|
285
|
+
size?: number;
|
|
286
|
+
}
|
|
287
|
+
export interface PanelContent {
|
|
288
|
+
slot: "panel";
|
|
289
|
+
panelType: string;
|
|
290
|
+
title?: string;
|
|
291
|
+
data: JsonValue;
|
|
292
|
+
}
|
|
293
|
+
export interface BridgeEnvelopeBase {
|
|
294
|
+
protocolVersion: 1;
|
|
295
|
+
channelId: string;
|
|
296
|
+
messageId: string;
|
|
297
|
+
sequence: number;
|
|
298
|
+
}
|
|
299
|
+
export interface InitPayload {
|
|
300
|
+
instanceId: string;
|
|
301
|
+
locale: string;
|
|
302
|
+
theme: Theme;
|
|
303
|
+
capabilities: GrantedCapability[];
|
|
304
|
+
resourceBudget: ResourceBudget;
|
|
305
|
+
}
|
|
306
|
+
export interface ResourceBudget {
|
|
307
|
+
version: 1;
|
|
308
|
+
bundle: {
|
|
309
|
+
compressedBytes: number;
|
|
310
|
+
expandedBytes: number;
|
|
311
|
+
fileCount: number;
|
|
312
|
+
singleFileBytes: number;
|
|
313
|
+
};
|
|
314
|
+
bridge: {
|
|
315
|
+
messageBytes: number;
|
|
316
|
+
messagesPerSecond: number;
|
|
317
|
+
pendingRequests: number;
|
|
318
|
+
};
|
|
319
|
+
files: {
|
|
320
|
+
readBytesPerRequest: number;
|
|
321
|
+
readBytesPerRun: number;
|
|
322
|
+
callsPerMinute: number;
|
|
323
|
+
listPageSize: number;
|
|
324
|
+
};
|
|
325
|
+
timeouts: {
|
|
326
|
+
bundleLoadMs: number;
|
|
327
|
+
handshakeMs: number;
|
|
328
|
+
firstRenderMs: number;
|
|
329
|
+
updateMs: number;
|
|
330
|
+
capabilityMs: number;
|
|
331
|
+
disposeGraceMs: number;
|
|
332
|
+
};
|
|
333
|
+
concurrency: {
|
|
334
|
+
activeIframesPerPage: number;
|
|
335
|
+
activeIframesPerRun: number;
|
|
336
|
+
hiddenRecycleMs: number;
|
|
337
|
+
};
|
|
338
|
+
retry: {
|
|
339
|
+
maxAttempts: number;
|
|
340
|
+
initialDelayMs: number;
|
|
341
|
+
maxDelayMs: number;
|
|
342
|
+
totalMs: number;
|
|
343
|
+
};
|
|
344
|
+
failure: {
|
|
345
|
+
consecutiveFailures: number;
|
|
346
|
+
windowMs: number;
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
export interface WidgetError {
|
|
350
|
+
code: ("BUNDLE_LOAD_FAILED" | "DIGEST_MISMATCH" | "RUNTIME_CONFIG_EXPIRED" | "WIDGET_VERSION_REVOKED" | "HOST_API_UNSUPPORTED" | "HANDSHAKE_TIMEOUT" | "MESSAGE_INVALID" | "CHANNEL_MISMATCH" | "MESSAGE_TOO_LARGE" | "MESSAGE_RATE_LIMITED" | "TOO_MANY_PENDING_REQUESTS" | "CAPABILITY_UNDECLARED" | "CAPABILITY_DENIED" | "CAPABILITY_UNSUPPORTED" | "CAPABILITY_TIMEOUT" | "FILE_REFERENCE_INVALID" | "FILE_PERMISSION_DENIED" | "RESOURCE_LIMIT" | "RENDER_FAILED" | "UPDATE_FAILED" | "WIDGET_CRASHED" | "INSTANCE_DISPOSED");
|
|
351
|
+
phase: ("load" | "handshake" | "render" | "update" | "capability" | "dispose");
|
|
352
|
+
message: string;
|
|
353
|
+
retryable: boolean;
|
|
354
|
+
correlationId: string;
|
|
355
|
+
}
|
|
356
|
+
export interface WidgetNetworkFetchInput {
|
|
357
|
+
url: string;
|
|
358
|
+
auth: ("none" | "optional" | "required");
|
|
359
|
+
method?: ("GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE");
|
|
360
|
+
headers?: WidgetNetworkRequestHeaders;
|
|
361
|
+
body?: string;
|
|
362
|
+
bodyEncoding?: ("utf8" | "base64");
|
|
363
|
+
redirect?: ("follow" | "manual" | "error");
|
|
364
|
+
}
|
|
365
|
+
export interface WidgetNetworkRequestHeaders {
|
|
366
|
+
[k: string]: string;
|
|
367
|
+
}
|
|
368
|
+
export interface WidgetEventBatch {
|
|
369
|
+
schemaVersion: 1;
|
|
370
|
+
topic: string;
|
|
371
|
+
cursor: string;
|
|
372
|
+
reset: boolean;
|
|
373
|
+
hasMore: boolean;
|
|
374
|
+
/**
|
|
375
|
+
* @maxItems 100
|
|
376
|
+
*/
|
|
377
|
+
events: WidgetEvent[];
|
|
378
|
+
snapshot?: JsonValue;
|
|
379
|
+
}
|
|
380
|
+
export interface WidgetEvent {
|
|
381
|
+
id: string;
|
|
382
|
+
type: string;
|
|
383
|
+
payload: JsonValue;
|
|
384
|
+
}
|
|
385
|
+
export interface ToolLifecycleEvent {
|
|
386
|
+
toolCallId: string;
|
|
387
|
+
toolName: string;
|
|
388
|
+
phase: ("started" | "completed" | "failed" | "cancelled");
|
|
389
|
+
}
|
|
390
|
+
export interface WidgetNetworkFetchOutput {
|
|
391
|
+
status: number;
|
|
392
|
+
statusText: string;
|
|
393
|
+
headers: NetworkHeaders;
|
|
394
|
+
body: string;
|
|
395
|
+
bodyEncoding: ("utf8" | "base64");
|
|
396
|
+
finalUrl: string;
|
|
397
|
+
redirected: boolean;
|
|
398
|
+
}
|
|
399
|
+
export interface NetworkHeaders {
|
|
400
|
+
[k: string]: string;
|
|
401
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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, LoadableBinding, NetworkAuthority, RuntimeAuthority, WidgetHostRuntimeConfig, } from "./generated-host-runtime-config.js";
|
|
11
|
+
export type { RequestedPresentationCapability, WidgetManifest, WidgetSlotConfig, } from "./generated-manifest.js";
|
|
12
|
+
export type { BridgeEnvelopeBase, CapabilityRequest, CapabilityRequestMessage, CapabilityResult, CapabilityResultMessage, DisposeMessage, ErrorMessage, FilePreviewContent, FilePreviewRenderRequest, FileReference, FocusBoundaryPresentationCapabilityRequest, GrantedCapability, GrantedPresentationCapability, HostToWidgetMessage, InitMessage, InitPayload, JsonValue, PanelContent, PanelRenderRequest, PresentationCapabilityOutput, PresentationCapabilityRequest, PresentationCapabilityResult, ReadyMessage, RenderMessage, RenderRequest, RenderRequestBase, RenderState, ResizeMessage, ResourceBudget, Theme, ThemeMode, ToolLifecycleEvent, ToolResultContent, ToolResultRenderRequest, WidgetError, WidgetEvent, WidgetEventBatch, WidgetNetworkFetchInput, WidgetNetworkFetchOutput, WidgetNetworkLimits, WidgetRenderContext, WidgetSlot, WidgetToHostMessage, } from "./generated-runtime-contracts.js";
|
|
13
|
+
export type HostApiVersion = 1;
|
|
14
|
+
export type WidgetRenderRequest = RenderRequest;
|
|
15
|
+
export type WidgetProtocolMessage = HostToWidgetMessage | WidgetToHostMessage;
|
|
16
|
+
export type ReadonlyFileCapability = Extract<GrantedCapability["name"], `files.${string}`>;
|
|
17
|
+
export type WidgetErrorCode = WidgetError["code"];
|
|
18
|
+
export type BridgeEnvelope<TType extends string = string, TPayload = unknown> = BridgeEnvelopeBase & {
|
|
19
|
+
type: TType;
|
|
20
|
+
payload: TPayload;
|
|
21
|
+
};
|
|
22
|
+
export type ResolvedWidgetBinding = LoadableBinding | FallbackBinding;
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dp-bohrium/widget-contracts",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Versioned Widget schemas and generated contract types.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20"
|
|
9
|
+
},
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./schemas/*.json": "./schemas/*.json",
|
|
17
|
+
"./conformance/*": "./conformance/*",
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"schemas",
|
|
23
|
+
"conformance",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"ajv": "^8.17.1",
|
|
32
|
+
"@biomejs/biome": "^2.2.0",
|
|
33
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
34
|
+
"@types/node": "^22.15.0",
|
|
35
|
+
"json-schema-to-typescript": "^15.0.4",
|
|
36
|
+
"typescript": "^5.8.3",
|
|
37
|
+
"vitest": "^3.2.4"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"generate:types": "node ../../scripts/schema/generate-types.mjs",
|
|
41
|
+
"schema:check": "node ../../scripts/schema/generate-types.mjs --check && node ../../scripts/schema/check-drift.mjs",
|
|
42
|
+
"typecheck": "node ../../scripts/schema/generate-types.mjs --check && tsc --noEmit",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:coverage": "vitest run --coverage",
|
|
45
|
+
"test:watch": "vitest",
|
|
46
|
+
"lint": "biome check src test",
|
|
47
|
+
"format:check": "biome check --linter-enabled=false src test",
|
|
48
|
+
"build": "tsc -b tsconfig.build.json --pretty false",
|
|
49
|
+
"check:surface": "node ../../scripts/quality/check-contract-surface.mjs",
|
|
50
|
+
"check:no-coupling": "node ../../scripts/quality/check-no-coupling.mjs",
|
|
51
|
+
"pack:check": "pnpm pack --pack-destination ../../.artifacts",
|
|
52
|
+
"package:contents": "node ../../scripts/quality/check-package-contents.mjs ../../.artifacts/dp-bohrium-widget-contracts-*.tgz",
|
|
53
|
+
"check": "pnpm schema:check && pnpm check:surface && pnpm check:no-coupling && pnpm typecheck && pnpm test && pnpm lint && pnpm format:check && pnpm build"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "host-runtime-config.schema.json",
|
|
4
|
+
"title": "Widget Host Runtime Config",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"schemaVersion",
|
|
9
|
+
"hostApiVersion",
|
|
10
|
+
"configId",
|
|
11
|
+
"runId",
|
|
12
|
+
"mode",
|
|
13
|
+
"issuedAt",
|
|
14
|
+
"expiresAt",
|
|
15
|
+
"recheckAt",
|
|
16
|
+
"securityProfile",
|
|
17
|
+
"resourceBudget",
|
|
18
|
+
"runtime",
|
|
19
|
+
"network",
|
|
20
|
+
"bindings"
|
|
21
|
+
],
|
|
22
|
+
"properties": {
|
|
23
|
+
"schemaVersion": { "const": 1 },
|
|
24
|
+
"hostApiVersion": { "const": 1 },
|
|
25
|
+
"configId": { "$ref": "#/$defs/Identifier" },
|
|
26
|
+
"runId": { "$ref": "#/$defs/Identifier" },
|
|
27
|
+
"mode": { "$ref": "#/$defs/Mode" },
|
|
28
|
+
"issuedAt": { "$ref": "#/$defs/Timestamp" },
|
|
29
|
+
"expiresAt": { "$ref": "#/$defs/Timestamp" },
|
|
30
|
+
"recheckAt": { "$ref": "#/$defs/Timestamp" },
|
|
31
|
+
"securityProfile": { "const": "runtime-security-profile-v1" },
|
|
32
|
+
"resourceBudget": {
|
|
33
|
+
"$ref": "widget-runtime-contracts.schema.json#/$defs/ResourceBudget"
|
|
34
|
+
},
|
|
35
|
+
"runtime": { "$ref": "#/$defs/RuntimeAuthority" },
|
|
36
|
+
"network": { "$ref": "#/$defs/NetworkAuthority" },
|
|
37
|
+
"bindings": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"items": {
|
|
40
|
+
"oneOf": [
|
|
41
|
+
{ "$ref": "#/$defs/LoadableBinding" },
|
|
42
|
+
{ "$ref": "#/$defs/FallbackBinding" }
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"$defs": {
|
|
48
|
+
"LoadableBinding": {
|
|
49
|
+
"title": "LoadableBinding",
|
|
50
|
+
"type": "object",
|
|
51
|
+
"additionalProperties": false,
|
|
52
|
+
"required": [
|
|
53
|
+
"status",
|
|
54
|
+
"bindingId",
|
|
55
|
+
"widgetId",
|
|
56
|
+
"widgetVersionId",
|
|
57
|
+
"digest",
|
|
58
|
+
"manifest",
|
|
59
|
+
"launch",
|
|
60
|
+
"grantedCapabilities"
|
|
61
|
+
],
|
|
62
|
+
"properties": {
|
|
63
|
+
"status": { "const": "loadable" },
|
|
64
|
+
"bindingId": { "$ref": "#/$defs/Identifier" },
|
|
65
|
+
"widgetId": { "$ref": "#/$defs/Identifier" },
|
|
66
|
+
"widgetVersionId": { "$ref": "#/$defs/Identifier" },
|
|
67
|
+
"digest": { "$ref": "#/$defs/Digest" },
|
|
68
|
+
"manifest": {
|
|
69
|
+
"$ref": "widget-manifest.schema.json"
|
|
70
|
+
},
|
|
71
|
+
"launch": { "$ref": "#/$defs/Launch" },
|
|
72
|
+
"grantedCapabilities": { "$ref": "#/$defs/GrantedCapabilities" }
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"FallbackBinding": {
|
|
76
|
+
"title": "FallbackBinding",
|
|
77
|
+
"type": "object",
|
|
78
|
+
"additionalProperties": false,
|
|
79
|
+
"required": [
|
|
80
|
+
"status",
|
|
81
|
+
"bindingId",
|
|
82
|
+
"widgetId",
|
|
83
|
+
"widgetVersionId",
|
|
84
|
+
"slot",
|
|
85
|
+
"reason"
|
|
86
|
+
],
|
|
87
|
+
"properties": {
|
|
88
|
+
"status": { "const": "fallback" },
|
|
89
|
+
"bindingId": { "$ref": "#/$defs/Identifier" },
|
|
90
|
+
"widgetId": { "$ref": "#/$defs/Identifier" },
|
|
91
|
+
"widgetVersionId": { "$ref": "#/$defs/Identifier" },
|
|
92
|
+
"slot": {
|
|
93
|
+
"$ref": "widget-manifest.schema.json#/$defs/WidgetSlotConfig"
|
|
94
|
+
},
|
|
95
|
+
"reason": { "$ref": "#/$defs/FallbackReason" }
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"RuntimeAuthority": {
|
|
99
|
+
"title": "RuntimeAuthority",
|
|
100
|
+
"type": "object",
|
|
101
|
+
"additionalProperties": false,
|
|
102
|
+
"required": ["origin", "catalogRevision"],
|
|
103
|
+
"properties": {
|
|
104
|
+
"origin": { "$ref": "#/$defs/RuntimeOrigin" },
|
|
105
|
+
"catalogRevision": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"minLength": 1,
|
|
108
|
+
"maxLength": 128,
|
|
109
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"NetworkAuthority": {
|
|
114
|
+
"title": "NetworkAuthority",
|
|
115
|
+
"type": "object",
|
|
116
|
+
"additionalProperties": false,
|
|
117
|
+
"required": ["mode", "policyVersion", "limits"],
|
|
118
|
+
"properties": {
|
|
119
|
+
"mode": { "enum": ["runtime-consent", "unavailable"] },
|
|
120
|
+
"policyVersion": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"minLength": 1,
|
|
123
|
+
"maxLength": 128,
|
|
124
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
|
|
125
|
+
},
|
|
126
|
+
"limits": {
|
|
127
|
+
"$ref": "widget-runtime-contracts.schema.json#/$defs/WidgetNetworkLimits"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"GrantedCapabilities": {
|
|
132
|
+
"title": "GrantedCapabilities",
|
|
133
|
+
"type": "array",
|
|
134
|
+
"items": {
|
|
135
|
+
"$ref": "widget-runtime-contracts.schema.json#/$defs/GrantedCapability"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"Launch": {
|
|
139
|
+
"title": "Launch",
|
|
140
|
+
"type": "object",
|
|
141
|
+
"additionalProperties": false,
|
|
142
|
+
"required": ["url", "expiresAt"],
|
|
143
|
+
"properties": {
|
|
144
|
+
"url": { "type": "string", "pattern": "^https?://" },
|
|
145
|
+
"expiresAt": { "$ref": "#/$defs/Timestamp" }
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"RuntimeOrigin": {
|
|
149
|
+
"title": "RuntimeOrigin",
|
|
150
|
+
"type": "string",
|
|
151
|
+
"maxLength": 253,
|
|
152
|
+
"pattern": "^(?:https://[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?::[0-9]{1,5})?|http://(?:localhost|127\\.0\\.0\\.1|\\[::1\\])(?::[0-9]{1,5})?)$"
|
|
153
|
+
},
|
|
154
|
+
"FallbackReason": {
|
|
155
|
+
"title": "FallbackReason",
|
|
156
|
+
"enum": [
|
|
157
|
+
"not-authorized",
|
|
158
|
+
"not-approved",
|
|
159
|
+
"delisted-for-new-use",
|
|
160
|
+
"revoked",
|
|
161
|
+
"host-api-unsupported",
|
|
162
|
+
"preview-not-allowed"
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
"Digest": {
|
|
166
|
+
"title": "Digest",
|
|
167
|
+
"type": "string",
|
|
168
|
+
"pattern": "^sha256:[0-9a-f]{64}$"
|
|
169
|
+
},
|
|
170
|
+
"Identifier": {
|
|
171
|
+
"title": "Identifier",
|
|
172
|
+
"type": "string",
|
|
173
|
+
"minLength": 1
|
|
174
|
+
},
|
|
175
|
+
"Mode": {
|
|
176
|
+
"title": "Mode",
|
|
177
|
+
"enum": ["preview", "published"]
|
|
178
|
+
},
|
|
179
|
+
"Timestamp": {
|
|
180
|
+
"title": "Timestamp",
|
|
181
|
+
"type": "string",
|
|
182
|
+
"pattern": "^\\d{4}-\\d{2}-\\d{2}T[^ ]+Z$"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|