@glassly/miniapp-cli 0.1.1-dev.0 → 0.1.2-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glassly/miniapp-cli",
3
- "version": "0.1.1-dev.0",
3
+ "version": "0.1.2-beta.0",
4
4
  "description": "Build tooling for Glassly miniapps: dev server, packer, manifest validation, and JSON Schema. The `glassly` command that drives it ships in @glassly/cli.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -123,7 +123,8 @@
123
123
  "AI",
124
124
  "SPEAKERS",
125
125
  "MANAGE_MINIAPPS",
126
- "PLATFORM_SETTINGS"
126
+ "PLATFORM_SETTINGS",
127
+ "HOST_WIDGETS"
127
128
  ],
128
129
  "description": "Permission type"
129
130
  },
@@ -178,6 +179,56 @@
178
179
  }
179
180
  }
180
181
  },
182
+ "widgets": {
183
+ "type": "array",
184
+ "description": "Dashboard widgets the miniapp serves through session.widgets.provide; the dashboard lists them under the app name.",
185
+ "items": {
186
+ "type": "object",
187
+ "required": [
188
+ "id",
189
+ "name",
190
+ "sizes"
191
+ ],
192
+ "additionalProperties": false,
193
+ "properties": {
194
+ "id": {
195
+ "type": "string",
196
+ "pattern": "^[a-z][a-z0-9_]*$",
197
+ "maxLength": 64,
198
+ "description": "Unique-within-app widget id (lowercase, starts with a letter)."
199
+ },
200
+ "name": {
201
+ "type": "string",
202
+ "description": "Shown on the dashboard's Widgets page."
203
+ },
204
+ "sizes": {
205
+ "type": "array",
206
+ "minItems": 1,
207
+ "uniqueItems": true,
208
+ "items": {
209
+ "type": "string",
210
+ "enum": [
211
+ "XS",
212
+ "SM",
213
+ "MD",
214
+ "LG"
215
+ ]
216
+ },
217
+ "description": "The sizes the widget draws at, smallest first."
218
+ },
219
+ "defaultSize": {
220
+ "type": "string",
221
+ "enum": [
222
+ "XS",
223
+ "SM",
224
+ "MD",
225
+ "LG"
226
+ ],
227
+ "description": "The size it takes when turned on; defaults to the first of sizes."
228
+ }
229
+ }
230
+ }
231
+ },
181
232
  "actions": {
182
233
  "type": "array",
183
234
  "description": "Actions other miniapps can discover and invoke via session.actions. Maps 1:1 onto MCP tools.",
package/src/manifest.ts CHANGED
@@ -68,6 +68,25 @@ export interface ManifestAction {
68
68
  outputSchema?: Record<string, unknown>;
69
69
  }
70
70
 
71
+ export const WIDGET_SIZES = ['XS', 'SM', 'MD', 'LG'] as const;
72
+ export type WidgetSize = (typeof WIDGET_SIZES)[number];
73
+
74
+ /**
75
+ * A dashboard widget this miniapp provides through session.widgets. The
76
+ * dashboard lists it under the app's name; the wearer places it at one of
77
+ * the sizes it offers.
78
+ */
79
+ export interface ManifestWidget {
80
+ /** Unique-within-app id, ^[a-z][a-z0-9_]*$, ≤64 chars. */
81
+ id: string;
82
+ /** Shown on the dashboard's Widgets page. */
83
+ name: string;
84
+ /** The sizes the widget draws at, smallest first. Non-empty. */
85
+ sizes: WidgetSize[];
86
+ /** The size it takes when turned on; defaults to the first of `sizes`. */
87
+ defaultSize?: WidgetSize;
88
+ }
89
+
71
90
  export interface MiniappManifestV1 {
72
91
  packageName: string;
73
92
  version: string;
@@ -97,6 +116,8 @@ export interface MiniappManifestV1 {
97
116
  alwaysOn?: boolean;
98
117
  /** Actions other (system) miniapps can invoke via session.actions. */
99
118
  actions?: ManifestAction[];
119
+ /** Dashboard widgets served through session.widgets.provide. */
120
+ widgets?: ManifestWidget[];
100
121
  }
101
122
 
102
123
  const ACTION_ID_RE = /^[a-z][a-z0-9_]*$/;
@@ -372,5 +393,44 @@ export function validateManifest(manifest: unknown): { valid: boolean; errors: s
372
393
  }
373
394
  }
374
395
 
396
+ // widgets — optional array of {id, name, sizes, defaultSize?}: the dashboard
397
+ // widgets the miniapp serves through session.widgets.provide.
398
+ if (m.widgets !== undefined) {
399
+ if (!Array.isArray(m.widgets)) {
400
+ errors.push('widgets must be an array of {id, name, sizes, defaultSize?} objects');
401
+ } else {
402
+ const seenIds = new Set<string>();
403
+ m.widgets.forEach((widget, i) => {
404
+ if (typeof widget !== 'object' || widget === null) {
405
+ errors.push(`widgets[${i}] must be an object like {"id": "now_playing", "name": "Now Playing", "sizes": ["SM", "MD"]}`);
406
+ return;
407
+ }
408
+ const w = widget as Record<string, unknown>;
409
+ if (typeof w.id !== 'string' || !ACTION_ID_RE.test(w.id)) {
410
+ errors.push(
411
+ `widgets[${i}].id must match ^[a-z][a-z0-9_]*$ (lowercase, start with a letter). Got: ${JSON.stringify(w.id)}`,
412
+ );
413
+ } else if (w.id.length > 64) {
414
+ errors.push(`widgets[${i}].id must be 64 characters or fewer`);
415
+ } else if (seenIds.has(w.id)) {
416
+ errors.push(`widgets[${i}].id "${w.id}" is duplicated — widget ids must be unique within a miniapp`);
417
+ } else {
418
+ seenIds.add(w.id);
419
+ }
420
+ if (typeof w.name !== 'string' || !w.name.trim()) {
421
+ errors.push(`widgets[${i}].name is required and must be a non-empty string`);
422
+ }
423
+ const sizes = Array.isArray(w.sizes) ? w.sizes : null;
424
+ if (!sizes || sizes.length === 0 || sizes.some((size) => !(WIDGET_SIZES as readonly unknown[]).includes(size))) {
425
+ errors.push(`widgets[${i}].sizes must be a non-empty array of ${WIDGET_SIZES.join(' | ')}`);
426
+ } else if (new Set(sizes).size !== sizes.length) {
427
+ errors.push(`widgets[${i}].sizes must not repeat a size`);
428
+ } else if (w.defaultSize !== undefined && !sizes.includes(w.defaultSize)) {
429
+ errors.push(`widgets[${i}].defaultSize must be one of its sizes`);
430
+ }
431
+ });
432
+ }
433
+ }
434
+
375
435
  return { valid: errors.length === 0, errors };
376
436
  }
@@ -18,6 +18,7 @@ const PERMISSION_HINTS: Record<AllowedPermission, string> = {
18
18
  SPEAKERS: "Required to resolve enrolled speaker ids to display names via session.speakers",
19
19
  MANAGE_MINIAPPS: "Required to list, start and stop other miniapps via session.miniapps",
20
20
  PLATFORM_SETTINGS: "Required to read and write platform settings via session.settings",
21
+ HOST_WIDGETS: "Required to list, place and drive other miniapps' dashboard widgets via session.widgets",
21
22
  }
22
23
 
23
24
  const HARDWARE_HINTS: Record<AllowedHardwareType, string> = {
package/src/schema.ts CHANGED
@@ -26,6 +26,7 @@ import {
26
26
  TAGLINE_MAX_LENGTH,
27
27
  TAGS_MAX_COUNT,
28
28
  TAG_MAX_LENGTH,
29
+ WIDGET_SIZES,
29
30
  } from './manifest.js';
30
31
 
31
32
  const SCHEMA_ID = 'https://schemas.glassly.com/miniapp/v1.json';
@@ -169,6 +170,36 @@ export function generateSchema(): Record<string, unknown> {
169
170
  },
170
171
  },
171
172
  },
173
+ widgets: {
174
+ type: 'array',
175
+ description: 'Dashboard widgets the miniapp serves through session.widgets.provide; the dashboard lists them under the app name.',
176
+ items: {
177
+ type: 'object',
178
+ required: ['id', 'name', 'sizes'],
179
+ additionalProperties: false,
180
+ properties: {
181
+ id: {
182
+ type: 'string',
183
+ pattern: '^[a-z][a-z0-9_]*$',
184
+ maxLength: 64,
185
+ description: 'Unique-within-app widget id (lowercase, starts with a letter).',
186
+ },
187
+ name: {type: 'string', description: "Shown on the dashboard's Widgets page."},
188
+ sizes: {
189
+ type: 'array',
190
+ minItems: 1,
191
+ uniqueItems: true,
192
+ items: {type: 'string', enum: [...WIDGET_SIZES]},
193
+ description: 'The sizes the widget draws at, smallest first.',
194
+ },
195
+ defaultSize: {
196
+ type: 'string',
197
+ enum: [...WIDGET_SIZES],
198
+ description: 'The size it takes when turned on; defaults to the first of sizes.',
199
+ },
200
+ },
201
+ },
202
+ },
172
203
  actions: {
173
204
  type: 'array',
174
205
  description: 'Actions other miniapps can discover and invoke via session.actions. Maps 1:1 onto MCP tools.',