@proveanything/smartlinks 2.2.1 → 3.0.0-alpha.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.
Files changed (330) hide show
  1. package/README.md +741 -754
  2. package/dist/README.md +573 -573
  3. package/dist/adminCardsView.js +55 -55
  4. package/dist/api/adminCards.d.ts +8 -0
  5. package/dist/api/adminCards.js +9 -1
  6. package/dist/api/ai.d.ts +22 -11
  7. package/dist/api/ai.js +18 -14
  8. package/dist/api/analytics.d.ts +13 -0
  9. package/dist/api/analytics.js +13 -0
  10. package/dist/api/appConfiguration.d.ts +17 -14
  11. package/dist/api/appConfiguration.js +14 -12
  12. package/dist/api/appObjects.d.ts +80 -16
  13. package/dist/api/appObjects.js +74 -11
  14. package/dist/api/asset.d.ts +55 -19
  15. package/dist/api/asset.js +52 -32
  16. package/dist/api/attestation.d.ts +3 -2
  17. package/dist/api/attestation.js +1 -1
  18. package/dist/api/attestations.d.ts +22 -7
  19. package/dist/api/attestations.js +22 -7
  20. package/dist/api/authKit.d.ts +22 -5
  21. package/dist/api/authKit.js +21 -4
  22. package/dist/api/batch.d.ts +23 -16
  23. package/dist/api/batch.js +19 -13
  24. package/dist/api/bookings.d.ts +45 -9
  25. package/dist/api/bookings.js +39 -3
  26. package/dist/api/broadcasts.d.ts +26 -6
  27. package/dist/api/broadcasts.js +22 -2
  28. package/dist/api/claimSet.d.ts +48 -13
  29. package/dist/api/claimSet.js +43 -7
  30. package/dist/api/collection.d.ts +20 -6
  31. package/dist/api/collection.js +19 -8
  32. package/dist/api/comms.d.ts +43 -12
  33. package/dist/api/comms.js +43 -13
  34. package/dist/api/conditions.d.ts +12 -2
  35. package/dist/api/conditions.js +10 -1
  36. package/dist/api/config.d.ts +15 -2
  37. package/dist/api/config.js +12 -0
  38. package/dist/api/contact.d.ts +34 -13
  39. package/dist/api/contact.js +35 -10
  40. package/dist/api/containers.d.ts +41 -23
  41. package/dist/api/containers.js +37 -21
  42. package/dist/api/crate.d.ts +9 -8
  43. package/dist/api/crate.js +8 -8
  44. package/dist/api/dpp.d.ts +58 -10
  45. package/dist/api/dpp.js +57 -15
  46. package/dist/api/facets.d.ts +71 -0
  47. package/dist/api/facets.js +71 -0
  48. package/dist/api/files.d.ts +11 -5
  49. package/dist/api/files.js +9 -1
  50. package/dist/api/form.d.ts +9 -2
  51. package/dist/api/form.js +7 -1
  52. package/dist/api/index.d.ts +0 -1
  53. package/dist/api/index.js +0 -1
  54. package/dist/api/integrations.d.ts +82 -27
  55. package/dist/api/integrations.js +63 -7
  56. package/dist/api/interactions.d.ts +42 -6
  57. package/dist/api/interactions.js +41 -5
  58. package/dist/api/jobs.d.ts +9 -2
  59. package/dist/api/jobs.js +6 -0
  60. package/dist/api/journeys.d.ts +13 -2
  61. package/dist/api/journeys.js +10 -1
  62. package/dist/api/journeysAnalytics.d.ts +12 -3
  63. package/dist/api/journeysAnalytics.js +9 -1
  64. package/dist/api/knowledge.d.ts +43 -10
  65. package/dist/api/knowledge.js +37 -5
  66. package/dist/api/location.d.ts +10 -3
  67. package/dist/api/location.js +7 -1
  68. package/dist/api/lots.d.ts +40 -13
  69. package/dist/api/lots.js +38 -8
  70. package/dist/api/loyalty.d.ts +70 -12
  71. package/dist/api/loyalty.js +60 -3
  72. package/dist/api/nfc.d.ts +8 -2
  73. package/dist/api/nfc.js +6 -1
  74. package/dist/api/order.d.ts +51 -160
  75. package/dist/api/order.js +46 -208
  76. package/dist/api/partner.d.ts +41 -8
  77. package/dist/api/partner.js +36 -4
  78. package/dist/api/products.d.ts +41 -8
  79. package/dist/api/products.js +33 -4
  80. package/dist/api/proof.d.ts +50 -13
  81. package/dist/api/proof.js +43 -7
  82. package/dist/api/realtime.d.ts +1 -11
  83. package/dist/api/realtime.js +1 -22
  84. package/dist/api/secrets.d.ts +25 -5
  85. package/dist/api/secrets.js +21 -2
  86. package/dist/api/segments.d.ts +26 -6
  87. package/dist/api/segments.js +22 -2
  88. package/dist/api/serviceAccounts.d.ts +8 -1
  89. package/dist/api/serviceAccounts.js +8 -1
  90. package/dist/api/shop.d.ts +41 -13
  91. package/dist/api/shop.js +35 -4
  92. package/dist/api/subscriptions.d.ts +47 -12
  93. package/dist/api/subscriptions.js +40 -4
  94. package/dist/api/tags.d.ts +40 -19
  95. package/dist/api/tags.js +38 -18
  96. package/dist/api/template.d.ts +31 -3
  97. package/dist/api/template.js +27 -0
  98. package/dist/api/translations.d.ts +17 -2
  99. package/dist/api/translations.js +14 -0
  100. package/dist/api/userGroups.d.ts +35 -9
  101. package/dist/api/userGroups.js +30 -5
  102. package/dist/api/variant.d.ts +11 -3
  103. package/dist/api/variant.js +9 -2
  104. package/dist/api/wallet.d.ts +23 -10
  105. package/dist/api/wallet.js +20 -2
  106. package/dist/apiVersion.d.ts +1 -1
  107. package/dist/apiVersion.js +1 -1
  108. package/dist/baseline.css +194 -194
  109. package/dist/docs/API_SUMMARY.md +1389 -2298
  110. package/dist/docs/PRODUCT_FACETS_SDK.md +10 -15
  111. package/dist/docs/admin-cards.md +189 -189
  112. package/dist/docs/admin-lists-and-pickers.md +1 -1
  113. package/dist/docs/agent-tools.md +156 -156
  114. package/dist/docs/ai-tools-and-skills.md +180 -180
  115. package/dist/docs/ai.md +1721 -1721
  116. package/dist/docs/analytics.md +3 -2
  117. package/dist/docs/api-versions.md +85 -76
  118. package/dist/docs/app-data-storage.md +277 -277
  119. package/dist/docs/app-docs.md +73 -73
  120. package/dist/docs/app-manifest.md +852 -852
  121. package/dist/docs/app-objects.md +38 -50
  122. package/dist/docs/app-records-pattern.md +388 -388
  123. package/dist/docs/appConfig.md +550 -550
  124. package/dist/docs/assets.md +17 -3
  125. package/dist/docs/assistant-apps.md +172 -172
  126. package/dist/docs/assistant-context.md +119 -119
  127. package/dist/docs/attestations.md +5 -4
  128. package/dist/docs/auth-kit.md +1 -1
  129. package/dist/docs/bookings.md +442 -442
  130. package/dist/docs/comms.md +689 -686
  131. package/dist/docs/connectors.md +340 -340
  132. package/dist/docs/contact-search.md +4 -3
  133. package/dist/docs/container-tracking.md +7 -7
  134. package/dist/docs/css-baseline.md +133 -133
  135. package/dist/docs/customer-guide.md +70 -70
  136. package/dist/docs/deploying-apps.md +340 -340
  137. package/dist/docs/dpp.md +115 -115
  138. package/dist/docs/entitlements.md +90 -90
  139. package/dist/docs/executor.md +1 -1
  140. package/dist/docs/files.md +69 -69
  141. package/dist/docs/forms.md +1 -1
  142. package/dist/docs/headless-providers.md +3 -3
  143. package/dist/docs/host-dependency-contract.md +252 -210
  144. package/dist/docs/i18n.md +292 -46
  145. package/dist/docs/integrations.md +322 -322
  146. package/dist/docs/interactions.md +544 -545
  147. package/dist/docs/item-context.md +181 -181
  148. package/dist/docs/knowledge.md +105 -102
  149. package/dist/docs/lists.md +114 -0
  150. package/dist/docs/lots.md +112 -111
  151. package/dist/docs/loyalty.md +348 -352
  152. package/dist/docs/members.md +183 -183
  153. package/dist/docs/memberships.md +150 -149
  154. package/dist/docs/mobile-admin-container.md +693 -693
  155. package/dist/docs/operations.md +281 -281
  156. package/dist/docs/overview.md +485 -485
  157. package/dist/docs/proof-claiming-methods.md +6 -6
  158. package/dist/docs/proof-comms-triggers.md +142 -142
  159. package/dist/docs/proof-ownership-transfer.md +155 -155
  160. package/dist/docs/proof-product-data-scoping.md +462 -462
  161. package/dist/docs/proof-share-grants.md +305 -305
  162. package/dist/docs/realtime.md +139 -138
  163. package/dist/docs/records-admin-pattern.md +304 -304
  164. package/dist/docs/server-functions.md +2 -2
  165. package/dist/docs/service-accounts.md +64 -64
  166. package/dist/docs/shop.md +4 -2
  167. package/dist/docs/site-seo.md +2 -1
  168. package/dist/docs/standard-query.md +187 -187
  169. package/dist/docs/tag-codes.md +97 -97
  170. package/dist/docs/tag-ranges.md +106 -106
  171. package/dist/docs/theme-tokens.md +252 -252
  172. package/dist/docs/translations.md +6 -1
  173. package/dist/docs/upgrading-to-3.md +430 -0
  174. package/dist/docs/user-groups.md +4 -4
  175. package/dist/docs/utils.md +1 -1
  176. package/dist/docs/wallet-passes.md +107 -107
  177. package/dist/docs/websites.md +123 -123
  178. package/dist/headless.d.ts +1 -1
  179. package/dist/headless.js +2 -2
  180. package/dist/http.d.ts +15 -2
  181. package/dist/http.js +60 -2
  182. package/dist/i18n.d.ts +2 -14
  183. package/dist/i18n.js +6 -23
  184. package/dist/index.d.ts +7 -8
  185. package/dist/index.js +2 -0
  186. package/dist/list.d.ts +24 -0
  187. package/dist/list.js +80 -0
  188. package/dist/mobile-admin/types.d.ts +0 -16
  189. package/dist/openapi.yaml +290 -2723
  190. package/dist/shared-dependencies.d.ts +3 -3
  191. package/dist/shared-dependencies.js +13 -5
  192. package/dist/site.d.ts +1 -7
  193. package/dist/site.js +1 -14
  194. package/dist/theme-boot.js +82 -82
  195. package/dist/theme.css +75 -75
  196. package/dist/types/adminCards.d.ts +6 -3
  197. package/dist/types/ai.d.ts +0 -6
  198. package/dist/types/analytics.d.ts +5 -8
  199. package/dist/types/appManifest.d.ts +4 -5
  200. package/dist/types/appObjects.d.ts +14 -18
  201. package/dist/types/appObjects.js +0 -1
  202. package/dist/types/appOptions.d.ts +18 -0
  203. package/dist/types/asset.d.ts +3 -22
  204. package/dist/types/attestations.d.ts +7 -10
  205. package/dist/types/batch.d.ts +6 -14
  206. package/dist/types/bookings.d.ts +22 -4
  207. package/dist/types/broadcasts.d.ts +5 -13
  208. package/dist/types/broadcasts.js +0 -1
  209. package/dist/types/claimSet.d.ts +0 -5
  210. package/dist/types/comms.d.ts +11 -9
  211. package/dist/types/contact.d.ts +5 -29
  212. package/dist/types/contact.js +0 -13
  213. package/dist/types/containers.d.ts +15 -26
  214. package/dist/types/crate.d.ts +4 -12
  215. package/dist/types/dpp.d.ts +3 -3
  216. package/dist/types/dpp.js +0 -1
  217. package/dist/types/error.d.ts +8 -5
  218. package/dist/types/error.js +12 -5
  219. package/dist/types/facets.d.ts +15 -15
  220. package/dist/types/index.d.ts +1 -0
  221. package/dist/types/index.js +1 -0
  222. package/dist/types/integrations.d.ts +3 -28
  223. package/dist/types/interaction.d.ts +3 -9
  224. package/dist/types/jobs.d.ts +3 -8
  225. package/dist/types/jobs.js +0 -1
  226. package/dist/types/journeys.d.ts +3 -8
  227. package/dist/types/journeys.js +0 -1
  228. package/dist/types/journeysAnalytics.d.ts +0 -1
  229. package/dist/types/list.d.ts +24 -0
  230. package/dist/types/list.js +2 -0
  231. package/dist/types/location.d.ts +0 -4
  232. package/dist/types/lots.d.ts +0 -9
  233. package/dist/types/loyalty.d.ts +0 -9
  234. package/dist/types/order.d.ts +7 -134
  235. package/dist/types/product.d.ts +11 -24
  236. package/dist/types/proof.d.ts +16 -0
  237. package/dist/types/realtime.d.ts +0 -29
  238. package/dist/types/segments.d.ts +5 -13
  239. package/dist/types/segments.js +0 -1
  240. package/dist/types/serviceAccounts.d.ts +3 -2
  241. package/dist/types/serviceAccounts.js +0 -1
  242. package/dist/types/shop.d.ts +5 -12
  243. package/dist/types/shop.js +0 -4
  244. package/dist/types/subscriptions.d.ts +18 -0
  245. package/dist/types/subscriptions.js +0 -8
  246. package/dist/types/tags.d.ts +6 -16
  247. package/dist/types/tags.js +0 -7
  248. package/dist/types/translations.d.ts +3 -9
  249. package/dist/types/variant.d.ts +0 -2
  250. package/dist/version.d.ts +1 -1
  251. package/dist/version.js +1 -1
  252. package/docs/API_SUMMARY.md +1389 -2298
  253. package/docs/PRODUCT_FACETS_SDK.md +10 -15
  254. package/docs/admin-cards.md +189 -189
  255. package/docs/admin-lists-and-pickers.md +1 -1
  256. package/docs/agent-tools.md +156 -156
  257. package/docs/ai-tools-and-skills.md +180 -180
  258. package/docs/ai.md +1721 -1721
  259. package/docs/analytics.md +3 -2
  260. package/docs/api-versions.md +85 -76
  261. package/docs/app-data-storage.md +277 -277
  262. package/docs/app-docs.md +73 -73
  263. package/docs/app-manifest.md +852 -852
  264. package/docs/app-objects.md +38 -50
  265. package/docs/app-records-pattern.md +388 -388
  266. package/docs/appConfig.md +550 -550
  267. package/docs/assets.md +17 -3
  268. package/docs/assistant-apps.md +172 -172
  269. package/docs/assistant-context.md +119 -119
  270. package/docs/attestations.md +5 -4
  271. package/docs/auth-kit.md +1 -1
  272. package/docs/bookings.md +442 -442
  273. package/docs/comms.md +689 -686
  274. package/docs/connectors.md +340 -340
  275. package/docs/contact-search.md +4 -3
  276. package/docs/container-tracking.md +7 -7
  277. package/docs/css-baseline.md +133 -133
  278. package/docs/customer-guide.md +70 -70
  279. package/docs/deploying-apps.md +340 -340
  280. package/docs/dpp.md +115 -115
  281. package/docs/entitlements.md +90 -90
  282. package/docs/executor.md +1 -1
  283. package/docs/files.md +69 -69
  284. package/docs/forms.md +1 -1
  285. package/docs/headless-providers.md +3 -3
  286. package/docs/host-dependency-contract.md +252 -210
  287. package/docs/i18n.md +292 -46
  288. package/docs/integrations.md +322 -322
  289. package/docs/interactions.md +544 -545
  290. package/docs/item-context.md +181 -181
  291. package/docs/knowledge.md +105 -102
  292. package/docs/lists.md +114 -0
  293. package/docs/lots.md +112 -111
  294. package/docs/loyalty.md +348 -352
  295. package/docs/members.md +183 -183
  296. package/docs/memberships.md +150 -149
  297. package/docs/mobile-admin-container.md +693 -693
  298. package/docs/operations.md +281 -281
  299. package/docs/overview.md +485 -485
  300. package/docs/proof-claiming-methods.md +6 -6
  301. package/docs/proof-comms-triggers.md +142 -142
  302. package/docs/proof-ownership-transfer.md +155 -155
  303. package/docs/proof-product-data-scoping.md +462 -462
  304. package/docs/proof-share-grants.md +305 -305
  305. package/docs/realtime.md +139 -138
  306. package/docs/server-functions.md +2 -2
  307. package/docs/service-accounts.md +64 -64
  308. package/docs/shop.md +4 -2
  309. package/docs/site-seo.md +2 -1
  310. package/docs/standard-query.md +187 -187
  311. package/docs/tag-codes.md +97 -97
  312. package/docs/tag-ranges.md +106 -106
  313. package/docs/theme-lookbook.v1.json +120 -120
  314. package/docs/theme-tokens.md +252 -252
  315. package/docs/translations.md +6 -1
  316. package/docs/upgrading-to-3.md +430 -0
  317. package/docs/user-groups.md +4 -4
  318. package/docs/utils.md +1 -1
  319. package/docs/wallet-passes.md +107 -107
  320. package/docs/websites.md +123 -123
  321. package/openapi.yaml +290 -2723
  322. package/package.json +91 -87
  323. package/scripts/headless-check.mjs +87 -87
  324. package/scripts/lib/bare-imports.mjs +57 -57
  325. package/scripts/lib/keyed-app-data.mjs +21 -21
  326. package/scripts/lib/upgrade.mjs +512 -0
  327. package/scripts/publish.mjs +272 -272
  328. package/scripts/register-release.mjs +91 -91
  329. package/scripts/upgrade.mjs +56 -0
  330. package/upgrade/3.json +2213 -0
@@ -128,7 +128,7 @@ GET /asset
128
128
  | `sort` | string | `createdAt` (default), `name`, `size`, `assetType` |
129
129
  | `order` | string | `desc` (default), `asc` |
130
130
  | `limit` | number | Max results (default 50, max 200) |
131
- | `offset` | number | Pagination offset |
131
+ | `cursor` | string | The `nextCursor` from the previous page |
132
132
  | `include` | string | `temporary`, `derived` (comma-separated): also list files that are normally left out |
133
133
 
134
134
  Lists show only what people put there. Temporary files and files extracted from other files (see
@@ -137,18 +137,32 @@ Lists show only what people put there. Temporary files and files extracted from
137
137
  **Response:**
138
138
 
139
139
  ```typescript
140
- { data: Asset[], total: number, limit: number, offset: number }
140
+ { items: Asset[], nextCursor: string | null, count?: number }
141
141
  ```
142
142
 
143
+ `nextCursor` is `null` on the last page. `count` (how many match in all) is there when you gave a `limit`
144
+ or a `cursor`.
145
+
143
146
  **SDK:**
144
147
 
145
148
  ```typescript
146
- const { data, total } = await Api.asset.listAdmin({
149
+ let page = await Api.asset.listAdmin({
147
150
  collectionId: 'my-collection',
148
151
  assetType: 'Image',
149
152
  labels: 'hero,banner',
150
153
  limit: 20,
151
154
  })
155
+ const images = [...page.items]
156
+ while (page.nextCursor) {
157
+ page = await Api.asset.listAdmin({
158
+ collectionId: 'my-collection',
159
+ assetType: 'Image',
160
+ labels: 'hero,banner',
161
+ limit: 20,
162
+ cursor: page.nextCursor,
163
+ })
164
+ images.push(...page.items)
165
+ }
152
166
  ```
153
167
 
154
168
  ---
@@ -1,172 +1,172 @@
1
- # The Studio assistant and your app
2
-
3
- SmartLinks admins have **one assistant**: an agent that works for the signed-in admin on one
4
- collection, with the admin's own authority, from a chat in Studio. It reads and changes data through
5
- the SmartLinks API, every write is a **change set** the admin can see and undo, and the things that
6
- can't be undone (deleting, sending, calling out, publishing, spending) wait for the admin's "Allow".
7
-
8
- This page is for app authors: how the assistant learns what your app is, how it is set up, and what it
9
- can do for the admin — without you building a chat of your own. Your app declares three things:
10
-
11
- | What | Where | Status |
12
- |---|---|---|
13
- | **Skills and knowledge** — plain-words procedures for the admin side, and the facts they need | `assistant` block in `app.manifest.json`, files under `public/assistant/` | this page |
14
- | **Tools** — logic the assistant should call rather than reimplement | server functions with an `agent` block (`audience: ["assistant"]` for assistant-only) | [agent-tools.md](agent-tools.md) |
15
- | **Setup** — questions, config schema, how to save | `app.admin.json` + `ai-guide.md` | [app-manifest.md](app-manifest.md#appadminjson) |
16
-
17
- An app with none of these still works with the assistant: it can read the app's records and config
18
- and change them through change sets. The declarations make it *good* at your app.
19
-
20
- ## The `assistant` block
21
-
22
- ```jsonc
23
- // app.manifest.json
24
- "assistant": {
25
- "skills": [
26
- { "name": "setup", "description": "First-time setup of the FAQ app: categories, tone, who answers", "file": "assistant/skills/setup.md" },
27
- { "name": "content", "description": "Adding, editing, ordering and retiring questions and answers", "file": "assistant/skills/content.md" }
28
- ],
29
- "knowledge": [
30
- { "name": "config-schema", "description": "JSON Schema of the app's config document", "file": "assistant/knowledge/config.schema.json" },
31
- { "name": "examples", "description": "Three worked examples of good FAQ content", "file": "assistant/knowledge/examples.md" }
32
- ],
33
- "preview": "/admin/preview?changeSet={id}"
34
- }
35
- ```
36
-
37
- The files sit in `public/assistant/` in your project and ship with every release like any other static
38
- file (they are read from the release's CDN folder, on the channel the collection runs your app on).
39
-
40
- The same block also says **what your app's data means** to the assistant (`purpose`, `objects`, `words`,
41
- `recipes`): which standard objects are what in your app, and which may only be changed through your
42
- actions. See **[assistant-context.md](assistant-context.md)**.
43
-
44
- ### How they are loaded
45
-
46
- When an admin opens a chat, the assistant's box gets the **index** of every installed app's skills: one
47
- line each, the description. Nothing else. A skill's body, and the knowledge files it names, are read
48
- only when the assistant decides the job needs them. Twenty apps with three skills each cost the
49
- conversation about sixty lines. So: write several focused skills rather than one long one, and spend
50
- care on the description — it is how the assistant decides to open the file.
51
-
52
- ### Writing a skill
53
-
54
- A skill is a markdown file: what this area of your app is for, what each setting means, how to read and
55
- change it, what a good result looks like, what to check afterwards. Write it for a capable colleague who
56
- has never seen your app. The assistant works through the SmartLinks API with a small CLI (`sl`), so say
57
- things in those terms:
58
-
59
- ```markdown
60
- ---
61
- name: faq-content
62
- description: Adding, editing, ordering and retiring questions and answers in the FAQ app
63
- ---
64
- # FAQ content
65
-
66
- Questions live as app records of type `question` (`sl get app/faq/records recordType=question`).
67
- Fields: `data.question`, `data.answer` (markdown), `data.category` (one of the categories in the app's
68
- config, `sl get app/faq` → `categories[]`), `data.order` (ascending), `status` (`published` | `draft`).
69
-
70
- ## Adding questions
71
- Plan one change set per batch: items `{ "op": "create", "entity": "record", "appId": "faq",
72
- "data": { "recordType": "question", "data": { … }, "status": "draft" } }`. Match on `data.question`
73
- (case-insensitive) before creating, so a re-run updates instead of duplicating.
74
-
75
- ## A good answer
76
- Two to five sentences, plain words, no marketing. Link to a product page when one exists
77
- (`/p/<collectionId>/<productId>`). Never invent policy: if the answer depends on something the admin
78
- hasn't said (returns window, delivery areas), ask.
79
-
80
- ## Check afterwards
81
- `sl get app/faq/records recordType=question status=draft` — read three back and make sure the
82
- category is one that exists.
83
- ```
84
-
85
- The frontmatter is optional; when it is missing, the manifest entry's `name` and `description` are used.
86
- Keep a skill under a few hundred lines; put long reference material in knowledge files and name them.
87
-
88
- ### Knowledge
89
-
90
- Knowledge files are what the skills refer to: the schema of your config document, record shapes, worked
91
- examples, a glossary of your app's words. The assistant reads them when a skill points at them (each
92
- skill is told where the app's knowledge files are).
93
-
94
- **Generate the schema, don't write it.** If your config is typed (a TypeScript interface, a zod schema),
95
- produce the JSON Schema at build time (`ts-json-schema-generator`, `zod-to-json-schema`) into
96
- `public/assistant/knowledge/`. A hand-written schema drifts the first week.
97
-
98
- ## Tools: when a skill is not enough
99
-
100
- Nearly every admin action is a read or a patch of config or records, and the assistant does those
101
- itself. Give it a **tool** only when a step can't be an API call it makes on its own:
102
-
103
- - logic that lives in your code (validate a layout, render a page from a design direction, compute
104
- something from your data model),
105
- - a write that must be atomic across several objects,
106
- - anything that needs your app's secrets.
107
-
108
- A tool is an http server function with an `agent` block
109
- ([agent-tools.md](agent-tools.md)); the assistant calls it as
110
- `sl post app/<appId>/functions/<name> '{ … }'`, under the function's own visibility, authority and
111
- capabilities. Set `"audience": ["assistant"]` to keep an assistant-only tool out of your in-app and
112
- public agent runs:
113
-
114
- ```jsonc
115
- {
116
- "name": "applyDesignDirection",
117
- "trigger": { "type": "http" },
118
- "visibility": "admin",
119
- "authority": "caller",
120
- "capabilities": ["sl:settings:write"],
121
- "agent": {
122
- "tool": true,
123
- "title": "Apply a design direction",
124
- "description": "Rewrites the theme, fonts and layout of the hub to match a named direction.",
125
- "input": { "type": "object", "properties": { "direction": { "type": "string" } }, "required": ["direction"] },
126
- "audience": ["assistant"]
127
- }
128
- }
129
- ```
130
-
131
- A tool that changes config should **return the patch, not apply it**, so the assistant can put it in a
132
- change set and the admin keeps undo. Tools that act directly are fine for reads and computations.
133
-
134
- ## How the assistant changes your config
135
-
136
- Your config document (`SL.appConfiguration`, `sl get app/<appId>`) and the collection's settings
137
- groups (`sl get settings/<group>`) are changed through change-set items:
138
-
139
- ```jsonc
140
- { "op": "update", "entity": "appConfig", "id": "<appId>", "data": { "theme": { "accent": "#0a7" } } }
141
- { "op": "update", "entity": "appConfig", "id": "<appId>", "scope": { "productId": "p1" }, "data": { … } }
142
- { "op": "update", "entity": "settings", "id": "hub", "data": { "pages": { "about": { … } } } }
143
- ```
144
-
145
- Saves deep-merge, as your own admin UI's saves do (nested objects merge, arrays replace). The whole
146
- document before the change is kept, so **undo puts it back exactly**. Say in your skills which keys
147
- are arrays, so the assistant sends the whole array when it changes one element.
148
-
149
- ### Preview before apply
150
-
151
- A planned change set can be rendered before it is applied. The API gives, for every document a set
152
- touches, the live document and the document as it would become:
153
-
154
- ```
155
- GET /admin/collection/:collectionId/assistant/changesets/:id/preview
156
- → { id, status, targets: [ { entity, id, scope?, before, after, ops } ] }
157
- ```
158
-
159
- Declare `assistant.preview` — a page of your admin surface that takes `{id}`, calls that endpoint
160
- with the admin's session, and renders `targets[].after` as your app would render the live config. The
161
- Studio panel then shows "Preview" on the change set, and the admin sees the result before saying yes.
162
-
163
- ## Checklist
164
-
165
- - `assistant.skills[]`: several focused skills with descriptions that say when they apply.
166
- - `assistant.knowledge[]`: the config schema generated from your types; record shapes; examples.
167
- - Every skill says which fields are arrays, what to match on before creating, what to check after.
168
- - Logic the assistant can't reproduce: a server function with `agent.tool` and `audience: ["assistant"]`,
169
- returning a patch for config changes.
170
- - `assistant.preview` when your app has a visual surface worth seeing before a change lands.
171
- - `ai-guide.md` still describes first-time setup for the setup wizard; the assistant reads it too when
172
- an app declares no skills.
1
+ # The Studio assistant and your app
2
+
3
+ SmartLinks admins have **one assistant**: an agent that works for the signed-in admin on one
4
+ collection, with the admin's own authority, from a chat in Studio. It reads and changes data through
5
+ the SmartLinks API, every write is a **change set** the admin can see and undo, and the things that
6
+ can't be undone (deleting, sending, calling out, publishing, spending) wait for the admin's "Allow".
7
+
8
+ This page is for app authors: how the assistant learns what your app is, how it is set up, and what it
9
+ can do for the admin — without you building a chat of your own. Your app declares three things:
10
+
11
+ | What | Where | Status |
12
+ |---|---|---|
13
+ | **Skills and knowledge** — plain-words procedures for the admin side, and the facts they need | `assistant` block in `app.manifest.json`, files under `public/assistant/` | this page |
14
+ | **Tools** — logic the assistant should call rather than reimplement | server functions with an `agent` block (`audience: ["assistant"]` for assistant-only) | [agent-tools.md](agent-tools.md) |
15
+ | **Setup** — questions, config schema, how to save | `app.admin.json` + `ai-guide.md` | [app-manifest.md](app-manifest.md#appadminjson) |
16
+
17
+ An app with none of these still works with the assistant: it can read the app's records and config
18
+ and change them through change sets. The declarations make it *good* at your app.
19
+
20
+ ## The `assistant` block
21
+
22
+ ```jsonc
23
+ // app.manifest.json
24
+ "assistant": {
25
+ "skills": [
26
+ { "name": "setup", "description": "First-time setup of the FAQ app: categories, tone, who answers", "file": "assistant/skills/setup.md" },
27
+ { "name": "content", "description": "Adding, editing, ordering and retiring questions and answers", "file": "assistant/skills/content.md" }
28
+ ],
29
+ "knowledge": [
30
+ { "name": "config-schema", "description": "JSON Schema of the app's config document", "file": "assistant/knowledge/config.schema.json" },
31
+ { "name": "examples", "description": "Three worked examples of good FAQ content", "file": "assistant/knowledge/examples.md" }
32
+ ],
33
+ "preview": "/admin/preview?changeSet={id}"
34
+ }
35
+ ```
36
+
37
+ The files sit in `public/assistant/` in your project and ship with every release like any other static
38
+ file (they are read from the release's CDN folder, on the channel the collection runs your app on).
39
+
40
+ The same block also says **what your app's data means** to the assistant (`purpose`, `objects`, `words`,
41
+ `recipes`): which standard objects are what in your app, and which may only be changed through your
42
+ actions. See **[assistant-context.md](assistant-context.md)**.
43
+
44
+ ### How they are loaded
45
+
46
+ When an admin opens a chat, the assistant's box gets the **index** of every installed app's skills: one
47
+ line each, the description. Nothing else. A skill's body, and the knowledge files it names, are read
48
+ only when the assistant decides the job needs them. Twenty apps with three skills each cost the
49
+ conversation about sixty lines. So: write several focused skills rather than one long one, and spend
50
+ care on the description — it is how the assistant decides to open the file.
51
+
52
+ ### Writing a skill
53
+
54
+ A skill is a markdown file: what this area of your app is for, what each setting means, how to read and
55
+ change it, what a good result looks like, what to check afterwards. Write it for a capable colleague who
56
+ has never seen your app. The assistant works through the SmartLinks API with a small CLI (`sl`), so say
57
+ things in those terms:
58
+
59
+ ```markdown
60
+ ---
61
+ name: faq-content
62
+ description: Adding, editing, ordering and retiring questions and answers in the FAQ app
63
+ ---
64
+ # FAQ content
65
+
66
+ Questions live as app records of type `question` (`sl get app/faq/records recordType=question`).
67
+ Fields: `data.question`, `data.answer` (markdown), `data.category` (one of the categories in the app's
68
+ config, `sl get app/faq` → `categories[]`), `data.order` (ascending), `status` (`published` | `draft`).
69
+
70
+ ## Adding questions
71
+ Plan one change set per batch: items `{ "op": "create", "entity": "record", "appId": "faq",
72
+ "data": { "recordType": "question", "data": { … }, "status": "draft" } }`. Match on `data.question`
73
+ (case-insensitive) before creating, so a re-run updates instead of duplicating.
74
+
75
+ ## A good answer
76
+ Two to five sentences, plain words, no marketing. Link to a product page when one exists
77
+ (`/p/<collectionId>/<productId>`). Never invent policy: if the answer depends on something the admin
78
+ hasn't said (returns window, delivery areas), ask.
79
+
80
+ ## Check afterwards
81
+ `sl get app/faq/records recordType=question status=draft` — read three back and make sure the
82
+ category is one that exists.
83
+ ```
84
+
85
+ The frontmatter is optional; when it is missing, the manifest entry's `name` and `description` are used.
86
+ Keep a skill under a few hundred lines; put long reference material in knowledge files and name them.
87
+
88
+ ### Knowledge
89
+
90
+ Knowledge files are what the skills refer to: the schema of your config document, record shapes, worked
91
+ examples, a glossary of your app's words. The assistant reads them when a skill points at them (each
92
+ skill is told where the app's knowledge files are).
93
+
94
+ **Generate the schema, don't write it.** If your config is typed (a TypeScript interface, a zod schema),
95
+ produce the JSON Schema at build time (`ts-json-schema-generator`, `zod-to-json-schema`) into
96
+ `public/assistant/knowledge/`. A hand-written schema drifts the first week.
97
+
98
+ ## Tools: when a skill is not enough
99
+
100
+ Nearly every admin action is a read or a patch of config or records, and the assistant does those
101
+ itself. Give it a **tool** only when a step can't be an API call it makes on its own:
102
+
103
+ - logic that lives in your code (validate a layout, render a page from a design direction, compute
104
+ something from your data model),
105
+ - a write that must be atomic across several objects,
106
+ - anything that needs your app's secrets.
107
+
108
+ A tool is an http server function with an `agent` block
109
+ ([agent-tools.md](agent-tools.md)); the assistant calls it as
110
+ `sl post app/<appId>/functions/<name> '{ … }'`, under the function's own visibility, authority and
111
+ capabilities. Set `"audience": ["assistant"]` to keep an assistant-only tool out of your in-app and
112
+ public agent runs:
113
+
114
+ ```jsonc
115
+ {
116
+ "name": "applyDesignDirection",
117
+ "trigger": { "type": "http" },
118
+ "visibility": "admin",
119
+ "authority": "caller",
120
+ "capabilities": ["sl:settings:write"],
121
+ "agent": {
122
+ "tool": true,
123
+ "title": "Apply a design direction",
124
+ "description": "Rewrites the theme, fonts and layout of the hub to match a named direction.",
125
+ "input": { "type": "object", "properties": { "direction": { "type": "string" } }, "required": ["direction"] },
126
+ "audience": ["assistant"]
127
+ }
128
+ }
129
+ ```
130
+
131
+ A tool that changes config should **return the patch, not apply it**, so the assistant can put it in a
132
+ change set and the admin keeps undo. Tools that act directly are fine for reads and computations.
133
+
134
+ ## How the assistant changes your config
135
+
136
+ Your config document (`SL.appConfiguration`, `sl get app/<appId>`) and the collection's settings
137
+ groups (`sl get settings/<group>`) are changed through change-set items:
138
+
139
+ ```jsonc
140
+ { "op": "update", "entity": "appConfig", "id": "<appId>", "data": { "theme": { "accent": "#0a7" } } }
141
+ { "op": "update", "entity": "appConfig", "id": "<appId>", "scope": { "productId": "p1" }, "data": { … } }
142
+ { "op": "update", "entity": "settings", "id": "hub", "data": { "pages": { "about": { … } } } }
143
+ ```
144
+
145
+ Saves deep-merge, as your own admin UI's saves do (nested objects merge, arrays replace). The whole
146
+ document before the change is kept, so **undo puts it back exactly**. Say in your skills which keys
147
+ are arrays, so the assistant sends the whole array when it changes one element.
148
+
149
+ ### Preview before apply
150
+
151
+ A planned change set can be rendered before it is applied. The API gives, for every document a set
152
+ touches, the live document and the document as it would become:
153
+
154
+ ```
155
+ GET /admin/collection/:collectionId/assistant/changesets/:id/preview
156
+ → { id, status, targets: [ { entity, id, scope?, before, after, ops } ] }
157
+ ```
158
+
159
+ Declare `assistant.preview` — a page of your admin surface that takes `{id}`, calls that endpoint
160
+ with the admin's session, and renders `targets[].after` as your app would render the live config. The
161
+ Studio panel then shows "Preview" on the change set, and the admin sees the result before saying yes.
162
+
163
+ ## Checklist
164
+
165
+ - `assistant.skills[]`: several focused skills with descriptions that say when they apply.
166
+ - `assistant.knowledge[]`: the config schema generated from your types; record shapes; examples.
167
+ - Every skill says which fields are arrays, what to match on before creating, what to check after.
168
+ - Logic the assistant can't reproduce: a server function with `agent.tool` and `audience: ["assistant"]`,
169
+ returning a patch for config changes.
170
+ - `assistant.preview` when your app has a visual surface worth seeing before a change lands.
171
+ - `ai-guide.md` still describes first-time setup for the setup wizard; the assistant reads it too when
172
+ an app declares no skills.
@@ -1,119 +1,119 @@
1
- # Telling the assistant what your app's data means
2
-
3
- SmartLinks keeps a business's data in standard objects: work orders, containers and stock, bookings,
4
- records, contacts, history. The assistant can read all of them. What it can't know is what they **mean in
5
- your app**: that a work order is a job, that a container of type `drum` is a drum of juice, that a
6
- booking with `data.event = "christmas-fair"` is a stall at the school fair.
7
-
8
- Tell it, in the manifest's `assistant` block, beside any skills and knowledge files
9
- ([assistant-apps.md](assistant-apps.md)). Four keys:
10
-
11
- ```jsonc
12
- // app.manifest.json
13
- "assistant": {
14
- "purpose": "Production manager for a fragrance filling and decorating factory: jobs from sales order to put-away.",
15
- "objects": [
16
- {
17
- "object": "workOrder",
18
- "where": { "appId": "accord-production" },
19
- "means": "A job.",
20
- "fields": {
21
- "ref": "job number, from the sales order",
22
- "kind": "job type: FillOnly, DecorateOnly, CompleteJob, PackagingOnly, Conversion",
23
- "dueAt": "target date",
24
- "data.stage": "the stage shown on screen",
25
- "stages": "picking, then decoration, filling, packaging (\"boxing\" on screen), wrapping"
26
- },
27
- "write": "actions"
28
- },
29
- { "object": "container", "where": { "containerType": "drum" }, "means": "A drum of bulk juice; its ref is the batch number.", "write": "actions" },
30
- { "object": "container", "where": { "containerType": "location" }, "means": "A place in the factory.", "write": "direct" },
31
- { "object": "history", "where": { "type": "job.*" }, "means": "A job's timeline.", "write": "none" }
32
- ],
33
- "words": {
34
- "GMP": "the batch manufacturing record printed for each job",
35
- "the diary": "production runs by day"
36
- },
37
- "recipes": [
38
- { "question": "What's on tomorrow?", "answer": "this app's work order stages planned for that day, by stage; show machine or crew" },
39
- { "question": "Which jobs are late?", "answer": "use the action jobs.late: it applies the app's own rule for late" }
40
- ]
41
- }
42
- ```
43
-
44
- | Key | What it is | Limit |
45
- |---|---|---|
46
- | `purpose` | One line on what the app or site is for. The assistant always has it in view. | 200 characters |
47
- | `objects` | What each standard object means here, and whether the assistant may change it. | 20 |
48
- | `words` | The business's own terms. | 40 |
49
- | `recipes` | How to answer the questions people actually ask. | 30 |
50
-
51
- All four together: at most 6,000 characters. The assistant reads this every time a question touches your
52
- app, so short wins. Anything malformed is left out and anything too long is cut (recipes first), without
53
- an error: check what you wrote reads well.
54
-
55
- ## Objects
56
-
57
- - **`object`**: the standard object: `workOrder`, `workOrderStage`, `container`, `stock`, `booking`,
58
- `record`, `contact`, `product`, `history`.
59
- - **`where`**: which ones, with the filters the SDK takes (`appId`, `containerType`, `recordType`,
60
- `data.<field>`).
61
- - **`means`**: what it is here, in a sentence.
62
- - **`fields`**: only the fields whose name doesn't say what they hold.
63
- - **`write`**: may the assistant change it?
64
-
65
- | `write` | Means |
66
- |---|---|
67
- | `direct` | Through the API, as a planned change the person applies. |
68
- | `actions` | **Only through one of your app's actions**, never another way. |
69
- | `none` | Never. |
70
- | absent | Nothing is said; the platform's usual rules apply. |
71
-
72
- **Record types you declared in the `data` block don't need repeating.** The assistant gets their titles
73
- and fields from there ([admin-lists-and-pickers.md](admin-lists-and-pickers.md)); add an `objects`
74
- entry only to say what one means or to set its `write` rule.
75
-
76
- ## Actions, when changing something has rules
77
-
78
- If creating or changing a thing involves rules that live in your code (a number from a counter, a check,
79
- someone who must be told), don't describe the rules and hope: mark the object `"write": "actions"` and
80
- give the assistant an **action** that does it. An action is one of your functions offered as a tool
81
- ([agent-tools.md](agent-tools.md)):
82
-
83
- ```jsonc
84
- {
85
- "name": "run.plan",
86
- "trigger": { "type": "http", "methods": ["POST"] },
87
- "agent": {
88
- "tool": true,
89
- "audience": ["assistant"],
90
- "title": "Plan a production run",
91
- "description": "Plan one stage of a job for a day, by hand or on a machine, with its crew.",
92
- "input": { "type": "object", "properties": { "job": { "type": "string" }, "stage": { "type": "string" }, "date": { "type": "string" } }, "required": ["job", "stage", "date"] },
93
- "approval": "require"
94
- }
95
- }
96
- ```
97
-
98
- Your rules then run in code every time. Keep actions few and coarse: one "find jobs" with filters, not
99
- five narrow ones. Use `"approval": "require"` for anything that changes or sends something: the person
100
- confirms it on a card.
101
-
102
- ## A site speaks for the business
103
-
104
- A site is the business's own app, so its description is about the **business**:
105
-
106
- - its `purpose` leads the assistant's map of the business;
107
- - it may describe objects that **other installed apps** keep. Narrow them with `where.appId`:
108
-
109
- ```jsonc
110
- { "object": "booking", "where": { "appId": "appointment-booking", "data.event": "christmas-fair" }, "means": "A stall at the Christmas fair." }
111
- ```
112
-
113
- - where the site and an app describe the same object, the site's meaning comes first.
114
-
115
- So "how many bookings for the Christmas fair?" is answered from the right bookings.
116
-
117
- ## Types
118
-
119
- `AppAssistantDeclaration` (`purpose`, `objects`, `words`, `recipes`), `AssistantObject`, `AssistantRecipe`.
1
+ # Telling the assistant what your app's data means
2
+
3
+ SmartLinks keeps a business's data in standard objects: work orders, containers and stock, bookings,
4
+ records, contacts, history. The assistant can read all of them. What it can't know is what they **mean in
5
+ your app**: that a work order is a job, that a container of type `drum` is a drum of juice, that a
6
+ booking with `data.event = "christmas-fair"` is a stall at the school fair.
7
+
8
+ Tell it, in the manifest's `assistant` block, beside any skills and knowledge files
9
+ ([assistant-apps.md](assistant-apps.md)). Four keys:
10
+
11
+ ```jsonc
12
+ // app.manifest.json
13
+ "assistant": {
14
+ "purpose": "Production manager for a fragrance filling and decorating factory: jobs from sales order to put-away.",
15
+ "objects": [
16
+ {
17
+ "object": "workOrder",
18
+ "where": { "appId": "accord-production" },
19
+ "means": "A job.",
20
+ "fields": {
21
+ "ref": "job number, from the sales order",
22
+ "kind": "job type: FillOnly, DecorateOnly, CompleteJob, PackagingOnly, Conversion",
23
+ "dueAt": "target date",
24
+ "data.stage": "the stage shown on screen",
25
+ "stages": "picking, then decoration, filling, packaging (\"boxing\" on screen), wrapping"
26
+ },
27
+ "write": "actions"
28
+ },
29
+ { "object": "container", "where": { "containerType": "drum" }, "means": "A drum of bulk juice; its ref is the batch number.", "write": "actions" },
30
+ { "object": "container", "where": { "containerType": "location" }, "means": "A place in the factory.", "write": "direct" },
31
+ { "object": "history", "where": { "type": "job.*" }, "means": "A job's timeline.", "write": "none" }
32
+ ],
33
+ "words": {
34
+ "GMP": "the batch manufacturing record printed for each job",
35
+ "the diary": "production runs by day"
36
+ },
37
+ "recipes": [
38
+ { "question": "What's on tomorrow?", "answer": "this app's work order stages planned for that day, by stage; show machine or crew" },
39
+ { "question": "Which jobs are late?", "answer": "use the action jobs.late: it applies the app's own rule for late" }
40
+ ]
41
+ }
42
+ ```
43
+
44
+ | Key | What it is | Limit |
45
+ |---|---|---|
46
+ | `purpose` | One line on what the app or site is for. The assistant always has it in view. | 200 characters |
47
+ | `objects` | What each standard object means here, and whether the assistant may change it. | 20 |
48
+ | `words` | The business's own terms. | 40 |
49
+ | `recipes` | How to answer the questions people actually ask. | 30 |
50
+
51
+ All four together: at most 6,000 characters. The assistant reads this every time a question touches your
52
+ app, so short wins. Anything malformed is left out and anything too long is cut (recipes first), without
53
+ an error: check what you wrote reads well.
54
+
55
+ ## Objects
56
+
57
+ - **`object`**: the standard object: `workOrder`, `workOrderStage`, `container`, `stock`, `booking`,
58
+ `record`, `contact`, `product`, `history`.
59
+ - **`where`**: which ones, with the filters the SDK takes (`appId`, `containerType`, `recordType`,
60
+ `data.<field>`).
61
+ - **`means`**: what it is here, in a sentence.
62
+ - **`fields`**: only the fields whose name doesn't say what they hold.
63
+ - **`write`**: may the assistant change it?
64
+
65
+ | `write` | Means |
66
+ |---|---|
67
+ | `direct` | Through the API, as a planned change the person applies. |
68
+ | `actions` | **Only through one of your app's actions**, never another way. |
69
+ | `none` | Never. |
70
+ | absent | Nothing is said; the platform's usual rules apply. |
71
+
72
+ **Record types you declared in the `data` block don't need repeating.** The assistant gets their titles
73
+ and fields from there ([admin-lists-and-pickers.md](admin-lists-and-pickers.md)); add an `objects`
74
+ entry only to say what one means or to set its `write` rule.
75
+
76
+ ## Actions, when changing something has rules
77
+
78
+ If creating or changing a thing involves rules that live in your code (a number from a counter, a check,
79
+ someone who must be told), don't describe the rules and hope: mark the object `"write": "actions"` and
80
+ give the assistant an **action** that does it. An action is one of your functions offered as a tool
81
+ ([agent-tools.md](agent-tools.md)):
82
+
83
+ ```jsonc
84
+ {
85
+ "name": "run.plan",
86
+ "trigger": { "type": "http", "methods": ["POST"] },
87
+ "agent": {
88
+ "tool": true,
89
+ "audience": ["assistant"],
90
+ "title": "Plan a production run",
91
+ "description": "Plan one stage of a job for a day, by hand or on a machine, with its crew.",
92
+ "input": { "type": "object", "properties": { "job": { "type": "string" }, "stage": { "type": "string" }, "date": { "type": "string" } }, "required": ["job", "stage", "date"] },
93
+ "approval": "require"
94
+ }
95
+ }
96
+ ```
97
+
98
+ Your rules then run in code every time. Keep actions few and coarse: one "find jobs" with filters, not
99
+ five narrow ones. Use `"approval": "require"` for anything that changes or sends something: the person
100
+ confirms it on a card.
101
+
102
+ ## A site speaks for the business
103
+
104
+ A site is the business's own app, so its description is about the **business**:
105
+
106
+ - its `purpose` leads the assistant's map of the business;
107
+ - it may describe objects that **other installed apps** keep. Narrow them with `where.appId`:
108
+
109
+ ```jsonc
110
+ { "object": "booking", "where": { "appId": "appointment-booking", "data.event": "christmas-fair" }, "means": "A stall at the Christmas fair." }
111
+ ```
112
+
113
+ - where the site and an app describe the same object, the site's meaning comes first.
114
+
115
+ So "how many bookings for the Christmas fair?" is answered from the right bookings.
116
+
117
+ ## Types
118
+
119
+ `AppAssistantDeclaration` (`purpose`, `objects`, `words`, `recipes`), `AssistantObject`, `AssistantRecipe`.