@theaiplatform/miniapp-sdk 0.3.3 → 0.4.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.
@@ -0,0 +1,361 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://the-ai-platform.dev/schemas/tap.test.schema.json",
4
+ "title": "The AI Platform miniapp test descriptor",
5
+ "description": "Strict schema-v2 descriptor for deterministic miniapp test profiles and matrix entries. Required origins, effects, credentials, and capabilities are preflight requirements only and never grant host authority.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "schemaVersion",
10
+ "packageId",
11
+ "configPath",
12
+ "profiles",
13
+ "matrix"
14
+ ],
15
+ "properties": {
16
+ "$schema": {
17
+ "type": "string",
18
+ "const": "https://the-ai-platform.dev/schemas/tap.test.schema.json"
19
+ },
20
+ "schemaVersion": {
21
+ "type": "integer",
22
+ "const": 2
23
+ },
24
+ "packageId": {
25
+ "$ref": "#/$defs/packageId"
26
+ },
27
+ "configPath": {
28
+ "$ref": "#/$defs/confinedPath"
29
+ },
30
+ "testMatch": {
31
+ "$ref": "#/$defs/testMatch"
32
+ },
33
+ "profiles": {
34
+ "type": "object",
35
+ "minProperties": 1,
36
+ "maxProperties": 64,
37
+ "propertyNames": {
38
+ "$ref": "#/$defs/id"
39
+ },
40
+ "additionalProperties": {
41
+ "$ref": "#/$defs/profile"
42
+ }
43
+ },
44
+ "matrix": {
45
+ "type": "array",
46
+ "minItems": 1,
47
+ "maxItems": 256,
48
+ "items": {
49
+ "$ref": "#/$defs/matrixEntry"
50
+ }
51
+ },
52
+ "waivers": {
53
+ "type": "array",
54
+ "maxItems": 128,
55
+ "items": {
56
+ "$ref": "#/$defs/waiver"
57
+ }
58
+ }
59
+ },
60
+ "$defs": {
61
+ "trimmed": {
62
+ "type": "string",
63
+ "minLength": 1,
64
+ "maxLength": 256,
65
+ "pattern": "^\\S(?:.*\\S)?$"
66
+ },
67
+ "id": {
68
+ "type": "string",
69
+ "minLength": 1,
70
+ "maxLength": 128,
71
+ "pattern": "^[a-z0-9][a-z0-9._:-]*$"
72
+ },
73
+ "actionId": {
74
+ "type": "string",
75
+ "minLength": 1,
76
+ "maxLength": 128,
77
+ "pattern": "^(?:\\*|do:\\*|[a-z0-9][a-z0-9._:-]*)$"
78
+ },
79
+ "capabilityId": {
80
+ "type": "string",
81
+ "minLength": 8,
82
+ "maxLength": 2048,
83
+ "pattern": "^(?:action:[a-z0-9][a-z0-9._:-]*|effect:[a-z0-9][a-z0-9._-]*:\\S+)$"
84
+ },
85
+ "effectToken": {
86
+ "type": "string",
87
+ "minLength": 10,
88
+ "maxLength": 2048,
89
+ "pattern": "^effect:[a-z0-9][a-z0-9._-]*:\\S+$"
90
+ },
91
+ "packageId": {
92
+ "type": "string",
93
+ "minLength": 1,
94
+ "maxLength": 256,
95
+ "pattern": "^[A-Za-z0-9@][A-Za-z0-9@/._:-]*$"
96
+ },
97
+ "confinedPath": {
98
+ "type": "string",
99
+ "minLength": 1,
100
+ "maxLength": 1024,
101
+ "pattern": "^(?!/)(?![A-Za-z]:)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.(?:/|$)).+$"
102
+ },
103
+ "confinedGlob": {
104
+ "type": "string",
105
+ "minLength": 1,
106
+ "maxLength": 1024,
107
+ "pattern": "^(?!/)(?![A-Za-z]:)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.(?:/|$)).+$"
108
+ },
109
+ "testMatch": {
110
+ "type": "array",
111
+ "minItems": 1,
112
+ "maxItems": 128,
113
+ "uniqueItems": true,
114
+ "items": {
115
+ "$ref": "#/$defs/confinedGlob"
116
+ }
117
+ },
118
+ "stringIdSet": {
119
+ "type": "array",
120
+ "maxItems": 128,
121
+ "uniqueItems": true,
122
+ "items": {
123
+ "$ref": "#/$defs/id"
124
+ }
125
+ },
126
+ "fileSet": {
127
+ "type": "array",
128
+ "maxItems": 64,
129
+ "uniqueItems": true,
130
+ "items": {
131
+ "allOf": [
132
+ {
133
+ "$ref": "#/$defs/confinedPath"
134
+ },
135
+ {
136
+ "type": "string",
137
+ "pattern": "\\.json$"
138
+ }
139
+ ]
140
+ }
141
+ },
142
+ "originSet": {
143
+ "type": "array",
144
+ "maxItems": 128,
145
+ "uniqueItems": true,
146
+ "items": {
147
+ "type": "string",
148
+ "minLength": 8,
149
+ "maxLength": 2048,
150
+ "pattern": "^https?://[^/?#]+$"
151
+ }
152
+ },
153
+ "viewport": {
154
+ "type": "object",
155
+ "additionalProperties": false,
156
+ "required": ["width", "height"],
157
+ "properties": {
158
+ "width": {
159
+ "type": "integer",
160
+ "minimum": 320,
161
+ "maximum": 8192
162
+ },
163
+ "height": {
164
+ "type": "integer",
165
+ "minimum": 200,
166
+ "maximum": 8192
167
+ }
168
+ }
169
+ },
170
+ "environment": {
171
+ "type": "object",
172
+ "additionalProperties": false,
173
+ "required": [
174
+ "viewport",
175
+ "locale",
176
+ "timezone",
177
+ "theme",
178
+ "reducedMotion",
179
+ "seed"
180
+ ],
181
+ "properties": {
182
+ "viewport": {
183
+ "$ref": "#/$defs/viewport"
184
+ },
185
+ "locale": {
186
+ "type": "string",
187
+ "minLength": 2,
188
+ "maxLength": 64,
189
+ "pattern": "^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$"
190
+ },
191
+ "timezone": {
192
+ "type": "string",
193
+ "minLength": 1,
194
+ "maxLength": 128
195
+ },
196
+ "theme": {
197
+ "enum": ["light", "dark"]
198
+ },
199
+ "reducedMotion": {
200
+ "type": "boolean"
201
+ },
202
+ "seed": {
203
+ "type": "integer",
204
+ "minimum": 0,
205
+ "maximum": 4294967295
206
+ },
207
+ "fixedNow": {
208
+ "type": "string",
209
+ "minLength": 20,
210
+ "maxLength": 64,
211
+ "format": "date-time",
212
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?Z$"
213
+ }
214
+ }
215
+ },
216
+ "capturePolicy": {
217
+ "enum": ["off", "failure-only", "always"]
218
+ },
219
+ "artifacts": {
220
+ "type": "object",
221
+ "additionalProperties": false,
222
+ "required": ["trace", "screenshots"],
223
+ "properties": {
224
+ "trace": {
225
+ "$ref": "#/$defs/capturePolicy"
226
+ },
227
+ "screenshots": {
228
+ "$ref": "#/$defs/capturePolicy"
229
+ },
230
+ "maxBytes": {
231
+ "type": "integer",
232
+ "minimum": 1024,
233
+ "maximum": 67108864
234
+ }
235
+ }
236
+ },
237
+ "profile": {
238
+ "type": "object",
239
+ "additionalProperties": false,
240
+ "required": [
241
+ "surface",
242
+ "target",
243
+ "mode",
244
+ "permissionScenario",
245
+ "environment",
246
+ "artifacts"
247
+ ],
248
+ "properties": {
249
+ "surface": {
250
+ "$ref": "#/$defs/id"
251
+ },
252
+ "target": {
253
+ "enum": [
254
+ "desktop",
255
+ "mobile",
256
+ "quickjs",
257
+ "worker",
258
+ "node",
259
+ "workflow-host"
260
+ ]
261
+ },
262
+ "mode": {
263
+ "enum": ["surface", "live"]
264
+ },
265
+ "permissionScenario": {
266
+ "$ref": "#/$defs/id"
267
+ },
268
+ "deniedActions": {
269
+ "type": "array",
270
+ "maxItems": 128,
271
+ "uniqueItems": true,
272
+ "items": {
273
+ "$ref": "#/$defs/actionId"
274
+ }
275
+ },
276
+ "fixtureFiles": {
277
+ "$ref": "#/$defs/fileSet"
278
+ },
279
+ "httpRouteFiles": {
280
+ "$ref": "#/$defs/fileSet"
281
+ },
282
+ "requiredOrigins": {
283
+ "$ref": "#/$defs/originSet"
284
+ },
285
+ "requiredEffects": {
286
+ "type": "array",
287
+ "maxItems": 128,
288
+ "uniqueItems": true,
289
+ "items": {
290
+ "$ref": "#/$defs/effectToken"
291
+ }
292
+ },
293
+ "credentialSlots": {
294
+ "type": "array",
295
+ "maxItems": 64,
296
+ "uniqueItems": true,
297
+ "items": {
298
+ "$ref": "#/$defs/id"
299
+ }
300
+ },
301
+ "environment": {
302
+ "$ref": "#/$defs/environment"
303
+ },
304
+ "artifacts": {
305
+ "$ref": "#/$defs/artifacts"
306
+ }
307
+ }
308
+ },
309
+ "matrixEntry": {
310
+ "type": "object",
311
+ "additionalProperties": false,
312
+ "required": ["id", "profile"],
313
+ "properties": {
314
+ "id": {
315
+ "$ref": "#/$defs/id"
316
+ },
317
+ "profile": {
318
+ "$ref": "#/$defs/id"
319
+ },
320
+ "testMatch": {
321
+ "$ref": "#/$defs/testMatch"
322
+ },
323
+ "capabilities": {
324
+ "type": "array",
325
+ "maxItems": 128,
326
+ "uniqueItems": true,
327
+ "items": {
328
+ "$ref": "#/$defs/capabilityId"
329
+ }
330
+ }
331
+ }
332
+ },
333
+ "waiver": {
334
+ "type": "object",
335
+ "additionalProperties": false,
336
+ "required": ["capability", "reason"],
337
+ "properties": {
338
+ "capability": {
339
+ "$ref": "#/$defs/capabilityId"
340
+ },
341
+ "reason": {
342
+ "type": "string",
343
+ "minLength": 1,
344
+ "maxLength": 2048,
345
+ "pattern": "^\\S(?:[\\s\\S]*\\S)?$"
346
+ },
347
+ "issue": {
348
+ "type": "string",
349
+ "minLength": 8,
350
+ "maxLength": 2048,
351
+ "format": "uri"
352
+ },
353
+ "expiresAt": {
354
+ "type": "string",
355
+ "maxLength": 64,
356
+ "format": "date-time"
357
+ }
358
+ }
359
+ }
360
+ }
361
+ }
package/dist/ui/wasm.js CHANGED
@@ -9313,7 +9313,8 @@ const iconVariants = cva('', {
9313
9313
  });
9314
9314
  function icon_Icon({ className, color, icon: IconComponent, size, ...props }) {
9315
9315
  const iconSize = ICON_SIZES[size ?? 'default'];
9316
- return /*#__PURE__*/ __rspack_external_react.createElement(IconComponent, {
9316
+ const RenderIcon = IconComponent;
9317
+ return /*#__PURE__*/ __rspack_external_react.createElement(RenderIcon, {
9317
9318
  "aria-hidden": "true",
9318
9319
  size: iconSize,
9319
9320
  className: utils_cn(iconVariants({
package/dist/ui.d.ts CHANGED
@@ -9,7 +9,6 @@ import { GroupProps } from 'react-resizable-panels';
9
9
  import { HTMLAttributes } from 'react';
10
10
  import { JSX } from 'react/jsx-runtime';
11
11
  import * as LabelPrimitive from '@radix-ui/react-label';
12
- import type { LucideIcon } from 'lucide-react';
13
12
  import { PanelProps } from 'react-resizable-panels';
14
13
  import * as ProgressPrimitive from '@radix-ui/react-progress';
15
14
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
@@ -429,8 +428,19 @@ declare const headingVariants: (props?: ({
429
428
  */
430
429
  export declare function Icon({ className, color, icon: IconComponent, size, ...props }: IconProps): JSX.Element;
431
430
 
432
- declare interface IconProps extends Omit<React_2.ComponentPropsWithoutRef<LucideIcon>, 'color' | 'size'>, VariantProps<typeof iconVariants> {
433
- icon: LucideIcon;
431
+ /**
432
+ * Patch-stable callable shape for Lucide-compatible icons.
433
+ *
434
+ * Lucide's public `LucideIcon` type embeds the physical React type instance
435
+ * from its installation. Re-exporting it makes linked SDKs reject otherwise
436
+ * compatible consumer Lucide/React patches. The never-argument callable
437
+ * proves this is a component without coupling its props or return value.
438
+ */
439
+ export declare type IconComponent = (...arguments_: never[]) => unknown;
440
+
441
+ export declare interface IconProps extends Omit<React_2.SVGProps<SVGSVGElement>, 'absoluteStrokeWidth' | 'color' | 'ref' | 'size'>, VariantProps<typeof iconVariants> {
442
+ absoluteStrokeWidth?: boolean;
443
+ icon: IconComponent;
434
444
  }
435
445
 
436
446
  /**
@@ -520,7 +530,7 @@ export declare namespace MiniAppIconButton {
520
530
  }
521
531
 
522
532
  export declare interface MiniAppIconButtonProps extends Omit<ButtonProps, 'children'> {
523
- icon: LucideIcon;
533
+ icon: IconComponent;
524
534
  label: string;
525
535
  tooltipSide?: React_2.ComponentProps<typeof TooltipContent>['side'];
526
536
  }
package/dist/ui.js CHANGED
@@ -9727,7 +9727,8 @@ const iconVariants = cva('', {
9727
9727
  });
9728
9728
  function icon_Icon({ className, color, icon: IconComponent, size, ...props }) {
9729
9729
  const iconSize = ICON_SIZES[size ?? 'default'];
9730
- return /*#__PURE__*/ __rspack_external_react.createElement(IconComponent, {
9730
+ const RenderIcon = IconComponent;
9731
+ return /*#__PURE__*/ __rspack_external_react.createElement(RenderIcon, {
9731
9732
  "aria-hidden": "true",
9732
9733
  size: iconSize,
9733
9734
  className: cn(iconVariants({
@@ -10,6 +10,19 @@ declare type MiniAppJsonValue = null | boolean | number | string | MiniAppJsonVa
10
10
  */
11
11
  export declare function mountVsCodeWebview(container: HTMLElement, context: TapFederatedSurfaceMountContext, options: TapVsCodeWebviewBridgeOptions): TapVsCodeWebviewMount;
12
12
 
13
+ /**
14
+ * Host-owned entropy for release-scoped identifiers.
15
+ *
16
+ * Ordinary TAP surfaces use the browser's cryptographically strong UUID
17
+ * source. Test Lab mounts derive a deterministic stream from the selected
18
+ * profile seed and exact frame identity, then reset it before each mount so
19
+ * app-owned state is reproducible without weakening production identifiers,
20
+ * colliding across retained remounts, or relying on ambient test globals.
21
+ */
22
+ declare interface TapFederatedSurfaceEntropy {
23
+ randomUUID(): string;
24
+ }
25
+
13
26
  /**
14
27
  * Read-only authority projected by TAP for the exact package release/frame.
15
28
  * A candidate frame starts without authority and may only perform host-backed
@@ -40,6 +53,7 @@ declare interface TapFederatedSurfaceMountContext {
40
53
  readonly channelId?: string;
41
54
  readonly conversationId?: string;
42
55
  readonly events: TapPackageEventPublisher;
56
+ readonly entropy: TapFederatedSurfaceEntropy;
43
57
  readonly hostAuthority: TapFederatedSurfaceHostAuthority;
44
58
  }
45
59
 
package/dist/web.d.ts CHANGED
@@ -136,6 +136,29 @@ declare type MiniAppAuthApi = {
136
136
  getUserProfile(): MiniAppMaybePromise<MiniAppUserProfile | null>;
137
137
  };
138
138
 
139
+ /**
140
+ * Read-only authorization introspection for custom surface behavior.
141
+ *
142
+ * The host rejects action IDs that are not declared by the exact mounted
143
+ * surface. A declared action resolves to the current dynamic allow/deny
144
+ * decision without executing the action.
145
+ */
146
+ declare type MiniAppAuthorizationApi = {
147
+ check(options: MiniAppAuthorizationCheckOptions): Promise<MiniAppAuthorizationCheckResult>;
148
+ };
149
+
150
+ /** Canonical autonomy requested for one descriptor-declared package action. */
151
+ declare type MiniAppAuthorizationAutonomy = 'listen' | 'plan' | 'do';
152
+
153
+ declare type MiniAppAuthorizationCheckOptions = {
154
+ actionId: string;
155
+ autonomy: MiniAppAuthorizationAutonomy;
156
+ };
157
+
158
+ declare type MiniAppAuthorizationCheckResult = {
159
+ allowed: boolean;
160
+ };
161
+
139
162
  /**
140
163
  * @capability miniapp-platform
141
164
  */
@@ -358,6 +381,7 @@ export declare type MiniAppPlatformApi = {
358
381
  navigation: {
359
382
  open(options: OpenNavigationOptions): void | Promise<void>;
360
383
  };
384
+ authorization: MiniAppAuthorizationApi;
361
385
  chat: MiniAppChatApi;
362
386
  storage: MiniAppStorageApi;
363
387
  session: MiniAppSessionApi;
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@theaiplatform/miniapp-sdk",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "TypeScript SDK for building, testing, and shipping portable miniapps on The AI Platform.",
5
+ "tapMiniappTestAdapterProtocol": 1,
5
6
  "type": "module",
7
+ "bin": {
8
+ "tap-miniapp-test": "./dist/bin/tap-miniapp-test.js"
9
+ },
6
10
  "engines": {
7
11
  "node": ">=20"
8
12
  },
@@ -67,7 +71,12 @@
67
71
  "./testing/rstest": {
68
72
  "types": "./dist/testing/rstest.d.ts",
69
73
  "import": "./dist/testing/rstest.js"
70
- }
74
+ },
75
+ "./testing/rstest-config": {
76
+ "types": "./dist/testing/rstest-config.d.ts",
77
+ "import": "./dist/testing/rstest-config.js"
78
+ },
79
+ "./testing/tap.test.schema.json": "./dist/testing/tap.test.schema.json"
71
80
  },
72
81
  "main": "./dist/index.js",
73
82
  "types": "./dist/index.d.ts",
@@ -82,7 +91,7 @@
82
91
  ],
83
92
  "scripts": {
84
93
  "prepack": "pnpm run build",
85
- "build": "rm -rf dist && rslib build && node scripts/copy-rspack-loaders.mjs && node scripts/build-ui-styles.mjs",
94
+ "build": "rm -rf dist && rslib build && node scripts/copy-tap-test-schema.mjs && node scripts/copy-rspack-loaders.mjs && node scripts/build-ui-styles.mjs",
86
95
  "test:unit": "rstest run",
87
96
  "typecheck": "tsc6 --noEmit"
88
97
  },
@@ -140,7 +149,12 @@
140
149
  "./testing/rstest": {
141
150
  "types": "./dist/testing/rstest.d.ts",
142
151
  "import": "./dist/testing/rstest.js"
143
- }
152
+ },
153
+ "./testing/rstest-config": {
154
+ "types": "./dist/testing/rstest-config.d.ts",
155
+ "import": "./dist/testing/rstest-config.js"
156
+ },
157
+ "./testing/tap.test.schema.json": "./dist/testing/tap.test.schema.json"
144
158
  }
145
159
  },
146
160
  "peerDependencies": {