@glassly/miniapp 0.4.2-dev.1193 → 0.4.3-beta.1211

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 (85) hide show
  1. package/dist/display/index.d.ts +2 -1
  2. package/dist/display/index.d.ts.map +1 -1
  3. package/dist/display/index.js +1 -1
  4. package/dist/display/index.js.map +1 -1
  5. package/dist/display/profiles/index.d.ts +3 -2
  6. package/dist/display/profiles/index.d.ts.map +1 -1
  7. package/dist/display/profiles/index.js +2 -3
  8. package/dist/display/profiles/index.js.map +1 -1
  9. package/dist/display/profiles/nimo.d.ts +10 -3
  10. package/dist/display/profiles/nimo.d.ts.map +1 -1
  11. package/dist/display/profiles/nimo.js +35 -3
  12. package/dist/display/profiles/nimo.js.map +1 -1
  13. package/dist/display/profiles/textProfile.d.ts +24 -0
  14. package/dist/display/profiles/textProfile.d.ts.map +1 -0
  15. package/dist/display/profiles/textProfile.js +48 -0
  16. package/dist/display/profiles/textProfile.js.map +1 -0
  17. package/dist/display/profiles/types.d.ts +5 -0
  18. package/dist/display/profiles/types.d.ts.map +1 -1
  19. package/dist/display/scene/degrade.d.ts +1 -1
  20. package/dist/display/scene/degrade.js +1 -1
  21. package/dist/display/scene/process.d.ts.map +1 -1
  22. package/dist/display/scene/process.js +2 -3
  23. package/dist/display/scene/process.js.map +1 -1
  24. package/dist/host/actionInvoke.d.ts +44 -0
  25. package/dist/host/actionInvoke.d.ts.map +1 -0
  26. package/dist/host/actionInvoke.js +87 -0
  27. package/dist/host/actionInvoke.js.map +1 -0
  28. package/dist/host/gestureClaims.d.ts +37 -0
  29. package/dist/host/gestureClaims.d.ts.map +1 -0
  30. package/dist/host/gestureClaims.js +45 -0
  31. package/dist/host/gestureClaims.js.map +1 -0
  32. package/dist/host/index.d.ts +8 -0
  33. package/dist/host/index.d.ts.map +1 -1
  34. package/dist/host/index.js +9 -0
  35. package/dist/host/index.js.map +1 -1
  36. package/dist/host/manifestActions.d.ts +69 -0
  37. package/dist/host/manifestActions.d.ts.map +1 -0
  38. package/dist/host/manifestActions.js +89 -0
  39. package/dist/host/manifestActions.js.map +1 -0
  40. package/dist/host/memory/MemoryStore.d.ts +178 -0
  41. package/dist/host/memory/MemoryStore.d.ts.map +1 -0
  42. package/dist/host/memory/MemoryStore.js +615 -0
  43. package/dist/host/memory/MemoryStore.js.map +1 -0
  44. package/dist/host/memory/search.d.ts +72 -0
  45. package/dist/host/memory/search.d.ts.map +1 -0
  46. package/dist/host/memory/search.js +188 -0
  47. package/dist/host/memory/search.js.map +1 -0
  48. package/dist/host/miniappPermissions.d.ts +16 -0
  49. package/dist/host/miniappPermissions.d.ts.map +1 -0
  50. package/dist/host/miniappPermissions.js +7 -0
  51. package/dist/host/miniappPermissions.js.map +1 -0
  52. package/dist/host/settingsBridge.d.ts +49 -0
  53. package/dist/host/settingsBridge.d.ts.map +1 -0
  54. package/dist/host/settingsBridge.js +110 -0
  55. package/dist/host/settingsBridge.js.map +1 -0
  56. package/dist/host/widgetPlacements.d.ts +44 -0
  57. package/dist/host/widgetPlacements.d.ts.map +1 -0
  58. package/dist/host/widgetPlacements.js +84 -0
  59. package/dist/host/widgetPlacements.js.map +1 -0
  60. package/dist/session.d.ts +6 -0
  61. package/dist/session.d.ts.map +1 -1
  62. package/dist/session.js.map +1 -1
  63. package/package.json +2 -2
  64. package/src/display/index.ts +4 -3
  65. package/src/display/profiles/index.ts +4 -4
  66. package/src/display/profiles/nimo.ts +38 -3
  67. package/src/display/profiles/textProfile.ts +62 -0
  68. package/src/display/profiles/types.ts +2 -0
  69. package/src/display/scene/degrade.ts +1 -1
  70. package/src/display/scene/process.ts +2 -3
  71. package/src/host/actionInvoke.ts +110 -0
  72. package/src/host/gestureClaims.ts +77 -0
  73. package/src/host/index.ts +10 -0
  74. package/src/host/manifestActions.ts +152 -0
  75. package/src/host/memory/MemoryStore.ts +704 -0
  76. package/src/host/memory/search.ts +214 -0
  77. package/src/host/miniappPermissions.ts +19 -0
  78. package/src/host/settingsBridge.ts +119 -0
  79. package/src/host/widgetPlacements.ts +135 -0
  80. package/src/session.ts +6 -0
  81. package/dist/display/profiles/z100.d.ts +0 -33
  82. package/dist/display/profiles/z100.d.ts.map +0 -1
  83. package/dist/display/profiles/z100.js +0 -182
  84. package/dist/display/profiles/z100.js.map +0 -1
  85. package/src/display/profiles/z100.ts +0 -198
@@ -0,0 +1,152 @@
1
+ /**
2
+ * A manifest-declared action a miniapp exposes for other miniapps to invoke
3
+ * via `session.actions`. Populated from `miniapp.json`'s `actions` field.
4
+ * Shape maps 1:1 onto an MCP tool (id→name, description, parameters→inputSchema).
5
+ */
6
+ export interface DeclaredAction {
7
+ id: string
8
+ description: string
9
+ /** JSON-Schema input descriptor (MCP-compatible subset). */
10
+ parameters?: Record<string, unknown>
11
+ /** JSON-Schema descriptor for the action's structured result. */
12
+ outputSchema?: Record<string, unknown>
13
+ /**
14
+ * Who may invoke the action: "public" (default — any installed miniapp) or
15
+ * "system" (system miniapps such as the AI assistant only).
16
+ */
17
+ visibility?: "public" | "system"
18
+ }
19
+
20
+ export type DeclaredWidgetSize = "XS" | "XSM" | "SM" | "MD" | "LG"
21
+
22
+ /** A dashboard widget a miniapp declares in `miniapp.json` and serves through `session.widgets`. */
23
+ export interface DeclaredWidget {
24
+ id: string
25
+ name: string
26
+ sizes: DeclaredWidgetSize[]
27
+ defaultSize: DeclaredWidgetSize
28
+ /** Lists the `EX` size: a tap on the selected widget can expand it to the full screen. */
29
+ expandable: boolean
30
+ /** A tap expands it rather than activating the card: expandable, and the wearer left expansion on. */
31
+ expandOnTap: boolean
32
+ }
33
+
34
+ /** The subset of ClientApp that action-listing needs (structural, no cycle on applet types). */
35
+ export interface ActionListApp {
36
+ packageName: string
37
+ name: string
38
+ actions?: DeclaredAction[]
39
+ compatibility?: {isCompatible: boolean}
40
+ }
41
+
42
+ /** One row of `session.actions.list` — a flat, MCP-tool-shaped descriptor. */
43
+ export interface ActionListRow {
44
+ packageName: string
45
+ appName: string
46
+ id: string
47
+ description: string
48
+ parameters?: Record<string, unknown>
49
+ outputSchema?: Record<string, unknown>
50
+ }
51
+
52
+ /**
53
+ * Project the installed-app set into the caller's invokable-action rows:
54
+ * excludes the caller's own actions, incompatible apps, and placeholder
55
+ * packages; `visibility: "system"` actions only surface for system callers.
56
+ */
57
+ export function visibleActionRows(
58
+ apps: ActionListApp[],
59
+ callerPackageName: string,
60
+ callerIsSystem: boolean,
61
+ ): ActionListRow[] {
62
+ const rows: ActionListRow[] = []
63
+ for (const app of apps) {
64
+ if (!app.packageName || app.packageName === callerPackageName || app.packageName.includes("@empty")) continue
65
+ if (app.compatibility?.isCompatible === false) continue
66
+ for (const action of app.actions ?? []) {
67
+ if (action.visibility === "system" && !callerIsSystem) continue
68
+ rows.push({
69
+ packageName: app.packageName,
70
+ appName: app.name,
71
+ id: action.id,
72
+ description: action.description,
73
+ ...(action.parameters ? {parameters: action.parameters} : {}),
74
+ ...(action.outputSchema ? {outputSchema: action.outputSchema} : {}),
75
+ })
76
+ }
77
+ }
78
+ return rows
79
+ }
80
+
81
+ /**
82
+ * Normalize manifest actions defensively for installed and dev-sideloaded
83
+ * bundles. Input and output schemas are passed through as opaque JSON Schema.
84
+ */
85
+ export function normalizeManifestActions(raw: unknown): DeclaredAction[] {
86
+ if (!Array.isArray(raw)) return []
87
+ const out: DeclaredAction[] = []
88
+ for (const a of raw as Array<{
89
+ id?: unknown
90
+ description?: unknown
91
+ parameters?: unknown
92
+ outputSchema?: unknown
93
+ visibility?: unknown
94
+ }>) {
95
+ if (a && typeof a.id === "string" && typeof a.description === "string") {
96
+ out.push({
97
+ id: a.id,
98
+ description: a.description,
99
+ ...(a.parameters && typeof a.parameters === "object" && !Array.isArray(a.parameters)
100
+ ? {parameters: a.parameters as Record<string, unknown>}
101
+ : {}),
102
+ ...(a.outputSchema && typeof a.outputSchema === "object" && !Array.isArray(a.outputSchema)
103
+ ? {outputSchema: a.outputSchema as Record<string, unknown>}
104
+ : {}),
105
+ // Unknown/absent values fall back to the default ("public") by omission.
106
+ ...(a.visibility === "system" || a.visibility === "public" ? {visibility: a.visibility} : {}),
107
+ })
108
+ }
109
+ }
110
+ return out
111
+ }
112
+
113
+ const WIDGET_SIZES: readonly DeclaredWidgetSize[] = ["XS", "XSM", "SM", "MD", "LG"]
114
+ const isWidgetSize = (value: unknown): value is DeclaredWidgetSize =>
115
+ (WIDGET_SIZES as readonly unknown[]).includes(value)
116
+
117
+ /**
118
+ * Normalize manifest widgets for installed and dev-sideloaded bundles: an
119
+ * entry without an id, a name or a usable card size is dropped, repeats of a
120
+ * size are folded, and a default size the widget does not offer becomes
121
+ * its first size. Listing `EX` makes a widget expandable; it is not a card
122
+ * size. Taps expand it until the wearer turns that off (AppRegistry applies
123
+ * the choice).
124
+ */
125
+ export function normalizeManifestWidgets(raw: unknown): DeclaredWidget[] {
126
+ if (!Array.isArray(raw)) return []
127
+ const out: DeclaredWidget[] = []
128
+ const seen = new Set<string>()
129
+ for (const w of raw as Array<{
130
+ id?: unknown
131
+ name?: unknown
132
+ sizes?: unknown
133
+ defaultSize?: unknown
134
+ expandable?: unknown
135
+ }>) {
136
+ if (!w || typeof w.id !== "string" || !w.id || typeof w.name !== "string" || !w.name || seen.has(w.id)) continue
137
+ const sizes = Array.isArray(w.sizes) ? Array.from(new Set(w.sizes.filter(isWidgetSize))) : []
138
+ if (sizes.length === 0) continue
139
+ seen.add(w.id)
140
+ // `expandable: true` is how bundles from before `EX` said the same.
141
+ const expandable = (Array.isArray(w.sizes) && w.sizes.includes("EX")) || w.expandable === true
142
+ out.push({
143
+ id: w.id,
144
+ name: w.name,
145
+ sizes,
146
+ defaultSize: isWidgetSize(w.defaultSize) && sizes.includes(w.defaultSize) ? w.defaultSize : sizes[0],
147
+ expandable,
148
+ expandOnTap: expandable,
149
+ })
150
+ }
151
+ return out
152
+ }