@proveanything/smartlinks 3.0.0-alpha.2 → 3.0.0-alpha.3

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 (151) hide show
  1. package/README.md +741 -741
  2. package/dist/README.md +573 -573
  3. package/dist/adminCardsView.js +55 -55
  4. package/dist/api/bookings.d.ts +49 -2
  5. package/dist/api/bookings.js +59 -2
  6. package/dist/api/index.d.ts +1 -0
  7. package/dist/api/index.js +1 -0
  8. package/dist/api/payments.d.ts +60 -0
  9. package/dist/api/payments.js +94 -0
  10. package/dist/api/realtime.d.ts +3 -0
  11. package/dist/api/realtime.js +10 -2
  12. package/dist/baseline.css +194 -194
  13. package/dist/dataChanged.d.ts +74 -0
  14. package/dist/dataChanged.js +162 -0
  15. package/dist/docs/API_SUMMARY.md +1086 -858
  16. package/dist/docs/admin-cards.md +189 -189
  17. package/dist/docs/agent-tools.md +156 -156
  18. package/dist/docs/ai-tools-and-skills.md +180 -180
  19. package/dist/docs/ai.md +1721 -1721
  20. package/dist/docs/api-versions.md +85 -85
  21. package/dist/docs/app-data-storage.md +277 -277
  22. package/dist/docs/app-docs.md +73 -73
  23. package/dist/docs/app-manifest.md +852 -852
  24. package/dist/docs/app-records-pattern.md +388 -388
  25. package/dist/docs/appConfig.md +550 -550
  26. package/dist/docs/assistant-apps.md +172 -172
  27. package/dist/docs/assistant-context.md +119 -119
  28. package/dist/docs/bookings.md +105 -8
  29. package/dist/docs/caching.md +32 -3
  30. package/dist/docs/comms.md +689 -689
  31. package/dist/docs/connectors.md +340 -340
  32. package/dist/docs/css-baseline.md +133 -133
  33. package/dist/docs/customer-guide.md +70 -70
  34. package/dist/docs/data-changed.md +91 -0
  35. package/dist/docs/deploying-apps.md +340 -340
  36. package/dist/docs/dpp.md +115 -115
  37. package/dist/docs/entitlements.md +90 -90
  38. package/dist/docs/files.md +69 -69
  39. package/dist/docs/host-dependency-contract.md +252 -252
  40. package/dist/docs/iframe-responder.md +11 -0
  41. package/dist/docs/integrations.md +322 -322
  42. package/dist/docs/interactions.md +544 -544
  43. package/dist/docs/item-context.md +181 -181
  44. package/dist/docs/knowledge.md +105 -105
  45. package/dist/docs/lists.md +157 -157
  46. package/dist/docs/lots.md +112 -112
  47. package/dist/docs/loyalty.md +348 -348
  48. package/dist/docs/members.md +183 -183
  49. package/dist/docs/memberships.md +150 -150
  50. package/dist/docs/mobile-admin-container.md +693 -693
  51. package/dist/docs/operations.md +281 -281
  52. package/dist/docs/overview.md +487 -485
  53. package/dist/docs/payments.md +94 -0
  54. package/dist/docs/proof-comms-triggers.md +142 -142
  55. package/dist/docs/proof-ownership-transfer.md +155 -155
  56. package/dist/docs/proof-product-data-scoping.md +462 -462
  57. package/dist/docs/proof-share-grants.md +305 -305
  58. package/dist/docs/realtime.md +149 -139
  59. package/dist/docs/records-admin-pattern.md +304 -304
  60. package/dist/docs/service-accounts.md +64 -64
  61. package/dist/docs/standard-query.md +196 -187
  62. package/dist/docs/tag-codes.md +97 -97
  63. package/dist/docs/tag-ranges.md +106 -106
  64. package/dist/docs/theme-tokens.md +252 -252
  65. package/dist/docs/upgrading-to-3.md +550 -532
  66. package/dist/docs/wallet-passes.md +107 -107
  67. package/dist/docs/websites.md +123 -123
  68. package/dist/http.d.ts +6 -3
  69. package/dist/http.js +48 -19
  70. package/dist/iframeResponder.d.ts +7 -0
  71. package/dist/iframeResponder.js +10 -0
  72. package/dist/index.d.ts +2 -0
  73. package/dist/index.js +2 -0
  74. package/dist/openapi.yaml +426 -3
  75. package/dist/testing/bookingsMemory.d.ts +29 -1
  76. package/dist/testing/bookingsMemory.js +89 -1
  77. package/dist/testing/index.js +4 -1
  78. package/dist/theme-boot.js +82 -82
  79. package/dist/theme.css +75 -75
  80. package/dist/types/appManifest.d.ts +26 -4
  81. package/dist/types/bookings.d.ts +99 -1
  82. package/dist/types/index.d.ts +1 -0
  83. package/dist/types/index.js +1 -0
  84. package/dist/types/payments.d.ts +101 -0
  85. package/dist/types/payments.js +5 -0
  86. package/dist/types/realtime.d.ts +5 -1
  87. package/dist/version.d.ts +1 -1
  88. package/dist/version.js +1 -1
  89. package/docs/API_SUMMARY.md +1086 -858
  90. package/docs/admin-cards.md +189 -189
  91. package/docs/agent-tools.md +156 -156
  92. package/docs/ai-tools-and-skills.md +180 -180
  93. package/docs/ai.md +1721 -1721
  94. package/docs/api-versions.md +85 -85
  95. package/docs/app-data-storage.md +277 -277
  96. package/docs/app-docs.md +73 -73
  97. package/docs/app-manifest.md +852 -852
  98. package/docs/app-records-pattern.md +388 -388
  99. package/docs/appConfig.md +550 -550
  100. package/docs/assistant-apps.md +172 -172
  101. package/docs/assistant-context.md +119 -119
  102. package/docs/bookings.md +105 -8
  103. package/docs/caching.md +32 -3
  104. package/docs/comms.md +689 -689
  105. package/docs/connectors.md +340 -340
  106. package/docs/css-baseline.md +133 -133
  107. package/docs/customer-guide.md +70 -70
  108. package/docs/data-changed.md +91 -0
  109. package/docs/deploying-apps.md +340 -340
  110. package/docs/dpp.md +115 -115
  111. package/docs/entitlements.md +90 -90
  112. package/docs/files.md +69 -69
  113. package/docs/host-dependency-contract.md +252 -252
  114. package/docs/iframe-responder.md +11 -0
  115. package/docs/integrations.md +322 -322
  116. package/docs/interactions.md +544 -544
  117. package/docs/item-context.md +181 -181
  118. package/docs/knowledge.md +105 -105
  119. package/docs/lists.md +157 -157
  120. package/docs/lots.md +112 -112
  121. package/docs/loyalty.md +348 -348
  122. package/docs/members.md +183 -183
  123. package/docs/memberships.md +150 -150
  124. package/docs/mobile-admin-container.md +693 -693
  125. package/docs/operations.md +281 -281
  126. package/docs/overview.md +487 -485
  127. package/docs/payments.md +94 -0
  128. package/docs/proof-comms-triggers.md +142 -142
  129. package/docs/proof-ownership-transfer.md +155 -155
  130. package/docs/proof-product-data-scoping.md +462 -462
  131. package/docs/proof-share-grants.md +305 -305
  132. package/docs/realtime.md +149 -139
  133. package/docs/service-accounts.md +64 -64
  134. package/docs/standard-query.md +196 -187
  135. package/docs/tag-codes.md +97 -97
  136. package/docs/tag-ranges.md +106 -106
  137. package/docs/theme-lookbook.v1.json +120 -120
  138. package/docs/theme-tokens.md +252 -252
  139. package/docs/upgrading-to-3.md +550 -532
  140. package/docs/wallet-passes.md +107 -107
  141. package/docs/websites.md +123 -123
  142. package/openapi.yaml +426 -3
  143. package/package.json +91 -91
  144. package/scripts/headless-check.mjs +87 -87
  145. package/scripts/lib/bare-imports.mjs +57 -57
  146. package/scripts/lib/keyed-app-data.mjs +21 -21
  147. package/scripts/lib/upgrade.mjs +708 -668
  148. package/scripts/publish.mjs +272 -272
  149. package/scripts/register-release.mjs +91 -91
  150. package/scripts/upgrade.mjs +79 -79
  151. package/upgrade/3.json +2 -2
@@ -1,133 +1,133 @@
1
- # SmartLinks CSS baseline (`sl-baseline`)
2
-
3
- > **Status: SHIPPED — `v1`, frozen.** The SDK ships `@proveanything/smartlinks/baseline.css`
4
- > (+ `baseline.classes.json`); the Portal/Hub serve it and apps opt in via
5
- > `meta.cssBaseline: "v1"`. `v1` is frozen: an existing `sl-*` rule's meaning never changes;
6
- > new capability ships as `v2` alongside. Supersedes the earlier "shared Tailwind base" idea —
7
- > that approach (sharing raw generated Tailwind) was too large and could never safely change;
8
- > this is the version that survives being frozen for years.
9
-
10
- A small, **frozen, namespaced** set of structural CSS helpers the platform guarantees are
11
- present, so any sub-app — and any AI/markdown/dynamic content renderer inside one — can rely
12
- on them. It is **mechanics, not aesthetics**: layout, spacing, sizing, type scale,
13
- responsive flow, radius/border/shadow, and a little motion. It never defines colours, fonts,
14
- or components — those are brand data and per-app.
15
-
16
- It is the CSS sibling of the JS shared-dependency contract, and like that contract **the SDK
17
- is the source of truth**: the SDK authors and ships the baseline; hosts and apps consume it.
18
-
19
- ## Why this shape (and not the alternatives)
20
-
21
- - **Small + frozen** → maintainable for years. A 60–120-rule hand-authored contract can be
22
- honoured indefinitely; a giant generated Tailwind sheet can't.
23
- - **Namespaced (`sl-`)** → zero collision with an app's own Tailwind (`flex`, `p-4`) or the
24
- host. Apps use `sl-*` for the guaranteed floor *and* their own utilities side by side. This
25
- is what removes the cascade/coexistence fragility.
26
- - **A stable contract, decoupled from Tailwind underneath** → the SDK may build it with
27
- Tailwind 4/5/6 internally, but apps target `sl-*`, so Tailwind upgrades are free.
28
- - **Teachable** → ~100 stable primitives can be put in an AI prompt; the full Tailwind
29
- surface cannot. Dynamic/AI content gets a guaranteed floor instead of hand-rolling CSS.
30
- - **A floor, not a ceiling** → opt-in, additive; apps are free to ignore it or write their
31
- own CSS. It just guarantees a consistent structural baseline when they want it.
32
-
33
- ## Responsive: container-query-backed, breakpoint-named
34
-
35
- Apps render **both** as containers (in the host document) and as iframes. Plain viewport
36
- `@media` is inconsistent across those — in an iframe it sees the iframe size (usually right),
37
- in a container it sees the *host* viewport (wrong for a sub-region). So the responsive
38
- primitives are **container-query based** (`@container`), exposed with familiar breakpoint
39
- names so authors/AI still think "phone / tablet / desktop":
40
-
41
- - The app's mount root is a **container context** (`sl-container`, i.e. `container-type:
42
- inline-size`) — set by the host on container mounts and by the app root in iframe mode.
43
- - `sl-md-grid-2` then means "when **my** box is ≥ tablet width", correct in both embed modes.
44
- - Breakpoints (container widths): `sm` ≥ 480px, `md` ≥ 768px, `lg` ≥ 1024px.
45
-
46
- This is the "works well on mobile / tablet / desktop" house opinion, done correctly for an
47
- embed-first platform.
48
-
49
- ## The v1 surface (frozen)
50
-
51
- All names `sl-`-prefixed. Responsive variants exist only for the layout-flow primitives
52
- marked ✦ (as `sl-{sm|md|lg}-<name>`), to keep the set teachable and small.
53
-
54
- **Reset & a11y**
55
- `sl-reset` (border-box + margin:0 on self/descendants) · `sl-media` (max-width:100%,
56
- height:auto) · `sl-focus` (keyboard-only focus ring) · `sl-sr-only` · `sl-container`
57
- (responsive container context)
58
-
59
- **Display ✦** `sl-block` · `sl-inline-block` · `sl-inline` · `sl-flex` · `sl-inline-flex` ·
60
- `sl-grid` · `sl-hidden`
61
-
62
- **Flex ✦(direction)** `sl-flex-row` · `sl-flex-col` · `sl-flex-wrap` · `sl-flex-nowrap` ·
63
- `sl-items-{start,center,end,stretch,baseline}` · `sl-justify-{start,center,end,between,around}`
64
- · `sl-flex-1` · `sl-flex-auto` · `sl-grow-0` · `sl-shrink-0`
65
-
66
- **Grid ✦(columns)** `sl-grid-{2,3,4}` (collapse to 1 col below `sm`) · `sl-grid-auto`
67
- (auto-fit minmax) · `sl-col-span-full`
68
-
69
- **Spacing** — curated 8-step scale `0,1,2,3,4,5,6,7` ≈ `0, .25, .5, .75, 1, 1.5, 2, 3 rem`.
70
- Logical properties (RTL-safe): `sl-gap-{0..7}` · `sl-p-{0..7}` · `sl-px-{0..7}` ·
71
- `sl-py-{0..7}` · `sl-ps-{0..7}` / `sl-pe-{0..7}` (inline start/end) · `sl-m-{0..7}` ·
72
- `sl-mx-auto` · `sl-mt-{0..7}` · `sl-mb-{0..7}`
73
-
74
- **Sizing** `sl-w-full` · `sl-h-full` · `sl-min-w-0` · `sl-max-w-{reading(42rem),prose(65ch),
75
- page(72rem)}` · `sl-aspect-{square,wide(16/9)}`
76
-
77
- **Typography** — static rem scale (predictable in any embed; use the responsive `✦` align
78
- and per-breakpoint sizing where you want type to change). `sl-text-{xs,sm,base,lg,xl,2xl,3xl,
79
- 4xl}` · `sl-font-{normal,medium,semibold,bold}` · `sl-leading-{tight,normal,relaxed}` ·
80
- `sl-tracking-{tight,normal}` · `sl-text-{left,center,right}` ✦(align) · `sl-truncate` ·
81
- `sl-line-clamp-{2,3}` · `sl-balance` (text-wrap:balance) · `sl-pretty`
82
-
83
- **Radius / border / shadow** — neutral mechanics only (no brand colour). `sl-rounded-{sm,md,
84
- lg,xl,full}` · `sl-border` / `sl-border-0` (colour = `--sl-border`, a subtle
85
- `color-mix(currentColor 14%, transparent)` default, overridable) · `sl-shadow-{sm,md,lg}`
86
- (neutral)
87
-
88
- **Object-fit / overflow** `sl-cover` · `sl-contain` · `sl-overflow-hidden` · `sl-overflow-auto`
89
-
90
- **Position & layering** `sl-relative` · `sl-absolute` · `sl-sticky` · `sl-inset-0` ·
91
- `sl-z-{base,raised,overlay}` (named levels — a house layering convention so apps don't fight
92
- over z-index)
93
-
94
- **Motion** (small, reduced-motion-safe; keyframes are `sl-`-namespaced) `sl-transition`
95
- (standard ease/duration) · `sl-reveal` (fade-up on view) · `sl-hover-lift` · all motion is
96
- **disabled under `prefers-reduced-motion`**. Rich motion vocabularies stay per-app (and may
97
- become a separate versioned motion contract later if several apps want to share one).
98
-
99
- ### Explicitly NOT in the baseline (non-goals)
100
- - **No colours** — brand data, delivered via CSS variables / theme params.
101
- - **No fonts** — per-app; the baseline sets a *scale*, never a family.
102
- - **No components** — no buttons/cards/nav; those are per-app aesthetics.
103
- - **No full utility surface** — anything bespoke ships in the app's own scoped CSS.
104
-
105
- ## Delivery — one SDK source, two paths
106
-
107
- The SDK ships the compiled baseline as `@proveanything/smartlinks/baseline.css` (+ the
108
- machine-readable class list for the doctor). One authored source; two delivery mechanisms:
109
-
110
- | Embed mode | How the app gets it |
111
- |---|---|
112
- | **Container (ESM/UMD)** — same document as host | Host has already loaded `baseline.css`; the app **ships nothing** and just uses `sl-*`. Declares `meta.cssBaseline: "v1"`. |
113
- | **Iframe** — its own document | The app **imports the SDK's `baseline.css`** into its own document (it inherits nothing, exactly like it must carry its own modules). Byte-identical to the host copy. |
114
-
115
- Cascade: baseline loads first; app CSS after → app rules win ties. `sl-*` never collides with
116
- app utilities regardless.
117
-
118
- ## SDK / build support (kept minimal — no CSS surgery)
119
- - The SDK **exports `baseline.css`** (and `baseline.classes.json`), built in the SDK's own
120
- build so the file and the class list can't drift.
121
- - Manifest field **`meta.cssBaseline: "v1"`** — declares reliance so the host can guarantee
122
- it's present.
123
- - `smartlinks-doctor`: warn if an app declares `cssBaseline` but uses an `sl-*` class outside
124
- the declared version (the useful invariant — spirit of the JS import check). No subtraction
125
- tooling needed: `sl-*` is a fixed vocabulary apps just use.
126
-
127
- ## Versioning & freeze
128
- - `v1` is **frozen**: an existing `sl-*` class's meaning/output never changes in place.
129
- - New capability ships as `v2` **alongside** `v1` (both served), never a silent mutation.
130
- - Tailwind (or whatever builds it) may be upgraded underneath as long as the `sl-*` contract
131
- keeps its meaning.
132
- - Governance: additions to the surface go through review (it's a decades-long contract);
133
- err toward *stable and generous* over minimal, since the AI builders target it.
1
+ # SmartLinks CSS baseline (`sl-baseline`)
2
+
3
+ > **Status: SHIPPED — `v1`, frozen.** The SDK ships `@proveanything/smartlinks/baseline.css`
4
+ > (+ `baseline.classes.json`); the Portal/Hub serve it and apps opt in via
5
+ > `meta.cssBaseline: "v1"`. `v1` is frozen: an existing `sl-*` rule's meaning never changes;
6
+ > new capability ships as `v2` alongside. Supersedes the earlier "shared Tailwind base" idea —
7
+ > that approach (sharing raw generated Tailwind) was too large and could never safely change;
8
+ > this is the version that survives being frozen for years.
9
+
10
+ A small, **frozen, namespaced** set of structural CSS helpers the platform guarantees are
11
+ present, so any sub-app — and any AI/markdown/dynamic content renderer inside one — can rely
12
+ on them. It is **mechanics, not aesthetics**: layout, spacing, sizing, type scale,
13
+ responsive flow, radius/border/shadow, and a little motion. It never defines colours, fonts,
14
+ or components — those are brand data and per-app.
15
+
16
+ It is the CSS sibling of the JS shared-dependency contract, and like that contract **the SDK
17
+ is the source of truth**: the SDK authors and ships the baseline; hosts and apps consume it.
18
+
19
+ ## Why this shape (and not the alternatives)
20
+
21
+ - **Small + frozen** → maintainable for years. A 60–120-rule hand-authored contract can be
22
+ honoured indefinitely; a giant generated Tailwind sheet can't.
23
+ - **Namespaced (`sl-`)** → zero collision with an app's own Tailwind (`flex`, `p-4`) or the
24
+ host. Apps use `sl-*` for the guaranteed floor *and* their own utilities side by side. This
25
+ is what removes the cascade/coexistence fragility.
26
+ - **A stable contract, decoupled from Tailwind underneath** → the SDK may build it with
27
+ Tailwind 4/5/6 internally, but apps target `sl-*`, so Tailwind upgrades are free.
28
+ - **Teachable** → ~100 stable primitives can be put in an AI prompt; the full Tailwind
29
+ surface cannot. Dynamic/AI content gets a guaranteed floor instead of hand-rolling CSS.
30
+ - **A floor, not a ceiling** → opt-in, additive; apps are free to ignore it or write their
31
+ own CSS. It just guarantees a consistent structural baseline when they want it.
32
+
33
+ ## Responsive: container-query-backed, breakpoint-named
34
+
35
+ Apps render **both** as containers (in the host document) and as iframes. Plain viewport
36
+ `@media` is inconsistent across those — in an iframe it sees the iframe size (usually right),
37
+ in a container it sees the *host* viewport (wrong for a sub-region). So the responsive
38
+ primitives are **container-query based** (`@container`), exposed with familiar breakpoint
39
+ names so authors/AI still think "phone / tablet / desktop":
40
+
41
+ - The app's mount root is a **container context** (`sl-container`, i.e. `container-type:
42
+ inline-size`) — set by the host on container mounts and by the app root in iframe mode.
43
+ - `sl-md-grid-2` then means "when **my** box is ≥ tablet width", correct in both embed modes.
44
+ - Breakpoints (container widths): `sm` ≥ 480px, `md` ≥ 768px, `lg` ≥ 1024px.
45
+
46
+ This is the "works well on mobile / tablet / desktop" house opinion, done correctly for an
47
+ embed-first platform.
48
+
49
+ ## The v1 surface (frozen)
50
+
51
+ All names `sl-`-prefixed. Responsive variants exist only for the layout-flow primitives
52
+ marked ✦ (as `sl-{sm|md|lg}-<name>`), to keep the set teachable and small.
53
+
54
+ **Reset & a11y**
55
+ `sl-reset` (border-box + margin:0 on self/descendants) · `sl-media` (max-width:100%,
56
+ height:auto) · `sl-focus` (keyboard-only focus ring) · `sl-sr-only` · `sl-container`
57
+ (responsive container context)
58
+
59
+ **Display ✦** `sl-block` · `sl-inline-block` · `sl-inline` · `sl-flex` · `sl-inline-flex` ·
60
+ `sl-grid` · `sl-hidden`
61
+
62
+ **Flex ✦(direction)** `sl-flex-row` · `sl-flex-col` · `sl-flex-wrap` · `sl-flex-nowrap` ·
63
+ `sl-items-{start,center,end,stretch,baseline}` · `sl-justify-{start,center,end,between,around}`
64
+ · `sl-flex-1` · `sl-flex-auto` · `sl-grow-0` · `sl-shrink-0`
65
+
66
+ **Grid ✦(columns)** `sl-grid-{2,3,4}` (collapse to 1 col below `sm`) · `sl-grid-auto`
67
+ (auto-fit minmax) · `sl-col-span-full`
68
+
69
+ **Spacing** — curated 8-step scale `0,1,2,3,4,5,6,7` ≈ `0, .25, .5, .75, 1, 1.5, 2, 3 rem`.
70
+ Logical properties (RTL-safe): `sl-gap-{0..7}` · `sl-p-{0..7}` · `sl-px-{0..7}` ·
71
+ `sl-py-{0..7}` · `sl-ps-{0..7}` / `sl-pe-{0..7}` (inline start/end) · `sl-m-{0..7}` ·
72
+ `sl-mx-auto` · `sl-mt-{0..7}` · `sl-mb-{0..7}`
73
+
74
+ **Sizing** `sl-w-full` · `sl-h-full` · `sl-min-w-0` · `sl-max-w-{reading(42rem),prose(65ch),
75
+ page(72rem)}` · `sl-aspect-{square,wide(16/9)}`
76
+
77
+ **Typography** — static rem scale (predictable in any embed; use the responsive `✦` align
78
+ and per-breakpoint sizing where you want type to change). `sl-text-{xs,sm,base,lg,xl,2xl,3xl,
79
+ 4xl}` · `sl-font-{normal,medium,semibold,bold}` · `sl-leading-{tight,normal,relaxed}` ·
80
+ `sl-tracking-{tight,normal}` · `sl-text-{left,center,right}` ✦(align) · `sl-truncate` ·
81
+ `sl-line-clamp-{2,3}` · `sl-balance` (text-wrap:balance) · `sl-pretty`
82
+
83
+ **Radius / border / shadow** — neutral mechanics only (no brand colour). `sl-rounded-{sm,md,
84
+ lg,xl,full}` · `sl-border` / `sl-border-0` (colour = `--sl-border`, a subtle
85
+ `color-mix(currentColor 14%, transparent)` default, overridable) · `sl-shadow-{sm,md,lg}`
86
+ (neutral)
87
+
88
+ **Object-fit / overflow** `sl-cover` · `sl-contain` · `sl-overflow-hidden` · `sl-overflow-auto`
89
+
90
+ **Position & layering** `sl-relative` · `sl-absolute` · `sl-sticky` · `sl-inset-0` ·
91
+ `sl-z-{base,raised,overlay}` (named levels — a house layering convention so apps don't fight
92
+ over z-index)
93
+
94
+ **Motion** (small, reduced-motion-safe; keyframes are `sl-`-namespaced) `sl-transition`
95
+ (standard ease/duration) · `sl-reveal` (fade-up on view) · `sl-hover-lift` · all motion is
96
+ **disabled under `prefers-reduced-motion`**. Rich motion vocabularies stay per-app (and may
97
+ become a separate versioned motion contract later if several apps want to share one).
98
+
99
+ ### Explicitly NOT in the baseline (non-goals)
100
+ - **No colours** — brand data, delivered via CSS variables / theme params.
101
+ - **No fonts** — per-app; the baseline sets a *scale*, never a family.
102
+ - **No components** — no buttons/cards/nav; those are per-app aesthetics.
103
+ - **No full utility surface** — anything bespoke ships in the app's own scoped CSS.
104
+
105
+ ## Delivery — one SDK source, two paths
106
+
107
+ The SDK ships the compiled baseline as `@proveanything/smartlinks/baseline.css` (+ the
108
+ machine-readable class list for the doctor). One authored source; two delivery mechanisms:
109
+
110
+ | Embed mode | How the app gets it |
111
+ |---|---|
112
+ | **Container (ESM/UMD)** — same document as host | Host has already loaded `baseline.css`; the app **ships nothing** and just uses `sl-*`. Declares `meta.cssBaseline: "v1"`. |
113
+ | **Iframe** — its own document | The app **imports the SDK's `baseline.css`** into its own document (it inherits nothing, exactly like it must carry its own modules). Byte-identical to the host copy. |
114
+
115
+ Cascade: baseline loads first; app CSS after → app rules win ties. `sl-*` never collides with
116
+ app utilities regardless.
117
+
118
+ ## SDK / build support (kept minimal — no CSS surgery)
119
+ - The SDK **exports `baseline.css`** (and `baseline.classes.json`), built in the SDK's own
120
+ build so the file and the class list can't drift.
121
+ - Manifest field **`meta.cssBaseline: "v1"`** — declares reliance so the host can guarantee
122
+ it's present.
123
+ - `smartlinks-doctor`: warn if an app declares `cssBaseline` but uses an `sl-*` class outside
124
+ the declared version (the useful invariant — spirit of the JS import check). No subtraction
125
+ tooling needed: `sl-*` is a fixed vocabulary apps just use.
126
+
127
+ ## Versioning & freeze
128
+ - `v1` is **frozen**: an existing `sl-*` class's meaning/output never changes in place.
129
+ - New capability ships as `v2` **alongside** `v1` (both served), never a silent mutation.
130
+ - Tailwind (or whatever builds it) may be upgraded underneath as long as the `sl-*` contract
131
+ keeps its meaning.
132
+ - Governance: additions to the surface go through review (it's a decades-long contract);
133
+ err toward *stable and generous* over minimal, since the AI builders target it.
@@ -1,70 +1,70 @@
1
- # The customer guide
2
-
3
- A business's assistant for its visitors, in Portal and the Hub, by voice or by text. It knows the business
4
- (a brief written for visitors), where the visitor is (the product, the item scanned, the app on screen) and
5
- what that screen says, and it can open another app for them. The business switches it on and shapes it in
6
- Studio (Configure → Guide). Design: prove `server/docs/design/customer-assistant.md`.
7
-
8
- Everything that shapes the guide — its instructions, voice, tools and limits — is fixed by SmartLinks when a
9
- conversation starts. A page only says where the visitor is and what is on their screen.
10
-
11
- ---
12
-
13
- ## For a host (Portal, the Hub, a custom site)
14
-
15
- ```ts
16
- import * as SL from '@proveanything/smartlinks'
17
-
18
- const info = await SL.ai.guide.get(collectionId, 'portal') // { enabled, name, modes, suggestions, handoff }
19
- if (!info.enabled) return
20
-
21
- const chat = await SL.ai.guide.start(collectionId, {
22
- surface: 'portal', // or 'hub'
23
- mode: info.modes.start, // 'voice' or 'text'
24
- productId, proofId,
25
- apps: [{ id: 'recipes', title: 'Recipes' }], // the apps on the visitor's page: their pages come from the deep-link registry
26
- where: { appId: 'recipes', path: '/method' }, // where the visitor is now
27
- screen: await SL.ai.content.request({ frame: appIframe.contentWindow }),
28
- showApp: (appId) => openApp(appId),
29
- openPage: ({ appId, path, params }) => openApp(appId, path, params), // a page the guide chose (look_in → open_page)
30
- goTo: (productId) => openProduct(productId), // another product it found (find → go_to)
31
- onShow: (card) => showFound(card), // what find found, rows with goTo
32
- offerPerson: (handoff) => showContact(handoff),
33
- onState: setState, // idle | connecting | listening | hearing | thinking | speaking | paused | error
34
- onCaption: setCaption, // what it is saying or writing, as it goes
35
- onError: setError,
36
- })
37
-
38
- chat.pause(); chat.resume(); chat.stop()
39
- chat.send('What is it made of?') // text mode (works in voice mode too)
40
- chat.note('The visitor is now on Dishwasher DW-60 (product id p9), in Manual at /troubleshooting.') // where they are; it doesn't answer
41
- ```
42
-
43
- The guide knows the pages around the visitor from SmartLinks' deep-link registry (`linkable` in each app's
44
- manifest, and each app's config `linkable` per collection and per product; see deep-link-discovery.md).
45
- Register your pages there and the guide can open them by name.
46
-
47
- - Voice needs the microphone; ask for it on a tap (browsers require it).
48
- - A signed-in visitor (Auth Kit bearer on the SDK) owns their conversation; otherwise it is anonymous.
49
- - The guide's `read_screen` tool asks the app on screen what it shows (below). Pass `readScreen` to answer
50
- it yourself.
51
- - Limits per visitor and per business are set in Studio; a refusal comes back as `GUIDE_LIMIT` (429).
52
-
53
- ## For an app: say what your screen shows
54
-
55
- ```ts
56
- useEffect(() => SL.ai.content.provide(() => ({
57
- appId: 'pages',
58
- title: page.title,
59
- content: page.text, // plain words: the exhibit, the recipe, what this form is for
60
- })), [page])
61
- ```
62
-
63
- `provide` works the same in an iframe (the host asks by message) and as a direct component. Return what a
64
- person reading the screen would take in, not markup. Without it, a host may fall back to the page's text.
65
-
66
- ## Your own live conversation
67
-
68
- `SL.ai.live.start({ endpoints: { mint, tool, event }, mode, screenTools, … })` is the client the guide and the
69
- Studio assistant use: WebRTC straight to the realtime service with a key your server minted, tools split
70
- between the page (`screenTools`) and your server (`endpoints.tool`). See `src/live.ts`.
1
+ # The customer guide
2
+
3
+ A business's assistant for its visitors, in Portal and the Hub, by voice or by text. It knows the business
4
+ (a brief written for visitors), where the visitor is (the product, the item scanned, the app on screen) and
5
+ what that screen says, and it can open another app for them. The business switches it on and shapes it in
6
+ Studio (Configure → Guide). Design: prove `server/docs/design/customer-assistant.md`.
7
+
8
+ Everything that shapes the guide — its instructions, voice, tools and limits — is fixed by SmartLinks when a
9
+ conversation starts. A page only says where the visitor is and what is on their screen.
10
+
11
+ ---
12
+
13
+ ## For a host (Portal, the Hub, a custom site)
14
+
15
+ ```ts
16
+ import * as SL from '@proveanything/smartlinks'
17
+
18
+ const info = await SL.ai.guide.get(collectionId, 'portal') // { enabled, name, modes, suggestions, handoff }
19
+ if (!info.enabled) return
20
+
21
+ const chat = await SL.ai.guide.start(collectionId, {
22
+ surface: 'portal', // or 'hub'
23
+ mode: info.modes.start, // 'voice' or 'text'
24
+ productId, proofId,
25
+ apps: [{ id: 'recipes', title: 'Recipes' }], // the apps on the visitor's page: their pages come from the deep-link registry
26
+ where: { appId: 'recipes', path: '/method' }, // where the visitor is now
27
+ screen: await SL.ai.content.request({ frame: appIframe.contentWindow }),
28
+ showApp: (appId) => openApp(appId),
29
+ openPage: ({ appId, path, params }) => openApp(appId, path, params), // a page the guide chose (look_in → open_page)
30
+ goTo: (productId) => openProduct(productId), // another product it found (find → go_to)
31
+ onShow: (card) => showFound(card), // what find found, rows with goTo
32
+ offerPerson: (handoff) => showContact(handoff),
33
+ onState: setState, // idle | connecting | listening | hearing | thinking | speaking | paused | error
34
+ onCaption: setCaption, // what it is saying or writing, as it goes
35
+ onError: setError,
36
+ })
37
+
38
+ chat.pause(); chat.resume(); chat.stop()
39
+ chat.send('What is it made of?') // text mode (works in voice mode too)
40
+ chat.note('The visitor is now on Dishwasher DW-60 (product id p9), in Manual at /troubleshooting.') // where they are; it doesn't answer
41
+ ```
42
+
43
+ The guide knows the pages around the visitor from SmartLinks' deep-link registry (`linkable` in each app's
44
+ manifest, and each app's config `linkable` per collection and per product; see deep-link-discovery.md).
45
+ Register your pages there and the guide can open them by name.
46
+
47
+ - Voice needs the microphone; ask for it on a tap (browsers require it).
48
+ - A signed-in visitor (Auth Kit bearer on the SDK) owns their conversation; otherwise it is anonymous.
49
+ - The guide's `read_screen` tool asks the app on screen what it shows (below). Pass `readScreen` to answer
50
+ it yourself.
51
+ - Limits per visitor and per business are set in Studio; a refusal comes back as `GUIDE_LIMIT` (429).
52
+
53
+ ## For an app: say what your screen shows
54
+
55
+ ```ts
56
+ useEffect(() => SL.ai.content.provide(() => ({
57
+ appId: 'pages',
58
+ title: page.title,
59
+ content: page.text, // plain words: the exhibit, the recipe, what this form is for
60
+ })), [page])
61
+ ```
62
+
63
+ `provide` works the same in an iframe (the host asks by message) and as a direct component. Return what a
64
+ person reading the screen would take in, not markup. Without it, a host may fall back to the page's text.
65
+
66
+ ## Your own live conversation
67
+
68
+ `SL.ai.live.start({ endpoints: { mint, tool, event }, mode, screenTools, … })` is the client the guide and the
69
+ Studio assistant use: WebRTC straight to the realtime service with a key your server minted, tools split
70
+ between the page (`screenTools`) and your server (`endpoints.tool`). See `src/live.ts`.
@@ -0,0 +1,91 @@
1
+ # Data changed: an open screen reads again
2
+
3
+ Since 2.2.3 (and in SDK 3).
4
+
5
+ An admin screen is not the only thing that changes records. The assistant applies a change, another app
6
+ saves, another person edits. The screen that is open keeps showing what it loaded, and the person has to
7
+ reload to see the change. **Data changed** is the host telling the app, so it can read again.
8
+
9
+ It is one message, host to app:
10
+
11
+ ```js
12
+ { type: 'smartlinks:data-changed', collectionId: 'acme', changes: [{ type: 'product', id: 'p_1', status: 'updated' }], source: 'assistant' }
13
+ ```
14
+
15
+ Ids only, never data. The app reads again through the normal API, with the normal permissions.
16
+
17
+ ## In an app
18
+
19
+ ```tsx
20
+ import * as SL from '@proveanything/smartlinks'
21
+
22
+ useEffect(() => SL.onDataChanged((e) => {
23
+ if (e.collectionId && e.collectionId !== collectionId) return
24
+ if (e.touches({ type: 'product' })) queryClient.invalidateQueries({ queryKey: ['products'] })
25
+ if (e.touches({ type: 'product', id: productId })) queryClient.invalidateQueries({ queryKey: ['product', collectionId, productId] })
26
+ }), [collectionId, productId])
27
+ ```
28
+
29
+ - `SL.onDataChanged(listener)` returns a function that stops listening. It does nothing outside a frame.
30
+ - Before your listener runs, the SDK has already forgotten the reads it kept for what changed, so the
31
+ next read returns what the server has now. This happens even in an app that never calls `onDataChanged`.
32
+ - `e.changes` is what changed. It is **empty when the host can't say**: treat everything you show from
33
+ the collection as possibly changed.
34
+ - `e.touches({ type, id })` answers "might this be about my record?". It is true when a change matches
35
+ every field you give, and always true when `e.changes` is empty.
36
+ - `e.source` is who made the change when the host knows (`'assistant'`, `'app'`, `'person'`).
37
+
38
+ ### A form the person is filling in
39
+
40
+ Reading again must not throw away typing.
41
+
42
+ - **Untouched form:** fill it again from the new record.
43
+ - **Form with changes in it:** keep what the person typed. Say plainly that the record was changed
44
+ elsewhere, and offer to load the new version. Do not save the old copy over the new one without asking.
45
+
46
+ Compare the record you loaded with the one you just read (its `updatedAt`, or the fields the form shows)
47
+ before saying anything: "something changed" is not always about the record on screen.
48
+
49
+ ### One change word per kind of record
50
+
51
+ `type` uses the same words as realtime changes (`docs/realtime.md`): `product`, `proof`, `asset`, `record`,
52
+ `collection`, `collection.apps`, `settings`. A host may also send its own words for other records
53
+ (`contact`, `appConfig`). `id` is the record's id; `productId`, `proofId`, `appId` and `recordType` say
54
+ where it lives when that helps.
55
+
56
+ ## In a host
57
+
58
+ Send it after a change the app did not make itself.
59
+
60
+ ```ts
61
+ // Any host
62
+ SL.postDataChanged(iframe.contentWindow, { collectionId, changes: [{ type: 'product', id }], source: 'assistant' })
63
+
64
+ // With IframeResponder
65
+ responder.dataChanged({ collectionId, changes: [{ type: 'product', id }] })
66
+
67
+ // When you can't say what changed
68
+ SL.postDataChanged(iframe.contentWindow, { collectionId })
69
+ ```
70
+
71
+ Studio sends it to every open app frame when an assistant change set is applied or undone, when the
72
+ assistant finishes a step that writes, and when its turn ends.
73
+
74
+ ## What it is not
75
+
76
+ - It is not the realtime feed. `SL.realtime.onChange` (`docs/realtime.md`) is the server telling a page
77
+ that something changed, over a live connection. Data changed is the host passing a change it already
78
+ knows about into a frame, with no connection of the app's own. A host that listens to the realtime
79
+ feed can pass those changes on with the same message, so an app needs only `onDataChanged`.
80
+ - It does not carry data and it is not a save. Nothing is written by sending or hearing it.
81
+
82
+ ## What the SDK forgets
83
+
84
+ | The host says | The SDK forgets |
85
+ |---|---|
86
+ | Only products and proofs changed | Everything kept under that collection's products (the product, its lists, its proofs) |
87
+ | Anything else, or nothing specific | Everything kept for that collection |
88
+ | No collection given | Everything kept |
89
+
90
+ Admin reads are never kept in the first place (`docs/caching.md`), so this matters for public reads an
91
+ admin screen makes, and for apps on an SDK before 2.2.2.