@proveanything/smartlinks 2.1.39 → 2.1.41

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 (121) hide show
  1. package/README.md +754 -754
  2. package/dist/README.md +573 -573
  3. package/dist/adminCardsView.js +55 -55
  4. package/dist/adminViews.d.ts +1 -1
  5. package/dist/adminViews.js +3 -1
  6. package/dist/ai-tools.d.ts +2 -1
  7. package/dist/ai-tools.js +3 -0
  8. package/dist/api/ai.d.ts +2 -21
  9. package/dist/api/ai.js +0 -35
  10. package/dist/api/collection.d.ts +8 -1
  11. package/dist/api/collection.js +10 -0
  12. package/dist/api/index.d.ts +1 -0
  13. package/dist/api/index.js +1 -0
  14. package/dist/api/knowledge.d.ts +64 -0
  15. package/dist/api/knowledge.js +97 -0
  16. package/dist/baseline.css +194 -194
  17. package/dist/docs/API_SUMMARY.md +1046 -964
  18. package/dist/docs/admin-cards.md +189 -189
  19. package/dist/docs/admin-views.md +257 -255
  20. package/dist/docs/agent-tools.md +156 -156
  21. package/dist/docs/ai-tools-and-skills.md +180 -180
  22. package/dist/docs/ai.md +1721 -1834
  23. package/dist/docs/analytics.md +39 -39
  24. package/dist/docs/app-data-storage.md +277 -277
  25. package/dist/docs/app-docs.md +73 -73
  26. package/dist/docs/app-manifest.md +852 -852
  27. package/dist/docs/app-records-pattern.md +388 -388
  28. package/dist/docs/appConfig.md +550 -550
  29. package/dist/docs/assistant-apps.md +172 -172
  30. package/dist/docs/assistant-context.md +119 -119
  31. package/dist/docs/bookings.md +442 -442
  32. package/dist/docs/comms.md +686 -686
  33. package/dist/docs/connectors.md +340 -340
  34. package/dist/docs/css-baseline.md +133 -133
  35. package/dist/docs/customer-guide.md +70 -70
  36. package/dist/docs/deploying-apps.md +340 -340
  37. package/dist/docs/entitlements.md +90 -90
  38. package/dist/docs/files.md +69 -69
  39. package/dist/docs/host-dependency-contract.md +210 -210
  40. package/dist/docs/integrations.md +322 -322
  41. package/dist/docs/interactions.md +545 -545
  42. package/dist/docs/item-context.md +181 -181
  43. package/dist/docs/knowledge.md +102 -0
  44. package/dist/docs/lots.md +111 -111
  45. package/dist/docs/loyalty.md +352 -352
  46. package/dist/docs/members.md +182 -182
  47. package/dist/docs/mobile-admin-container.md +693 -693
  48. package/dist/docs/operations.md +281 -281
  49. package/dist/docs/overview.md +482 -482
  50. package/dist/docs/proof-comms-triggers.md +142 -142
  51. package/dist/docs/proof-ownership-transfer.md +155 -155
  52. package/dist/docs/proof-product-data-scoping.md +462 -462
  53. package/dist/docs/proof-share-grants.md +305 -305
  54. package/dist/docs/realtime.md +138 -138
  55. package/dist/docs/records-admin-pattern.md +304 -304
  56. package/dist/docs/standard-query.md +187 -187
  57. package/dist/docs/tag-codes.md +97 -97
  58. package/dist/docs/theme-tokens.md +252 -252
  59. package/dist/docs/wallet-passes.md +107 -107
  60. package/dist/docs/websites.md +123 -123
  61. package/dist/openapi.yaml +320 -306
  62. package/dist/theme-boot.js +78 -78
  63. package/dist/theme.css +75 -75
  64. package/dist/types/ai.d.ts +9 -91
  65. package/dist/types/appManifest.d.ts +21 -0
  66. package/dist/types/collection.d.ts +26 -0
  67. package/dist/types/index.d.ts +1 -0
  68. package/dist/types/index.js +1 -0
  69. package/dist/types/knowledge.d.ts +120 -0
  70. package/dist/types/knowledge.js +2 -0
  71. package/docs/API_SUMMARY.md +1046 -964
  72. package/docs/admin-cards.md +189 -189
  73. package/docs/admin-views.md +257 -255
  74. package/docs/agent-tools.md +156 -156
  75. package/docs/ai-tools-and-skills.md +180 -180
  76. package/docs/ai.md +1721 -1834
  77. package/docs/analytics.md +39 -39
  78. package/docs/app-data-storage.md +277 -277
  79. package/docs/app-docs.md +73 -73
  80. package/docs/app-manifest.md +852 -852
  81. package/docs/app-records-pattern.md +388 -388
  82. package/docs/appConfig.md +550 -550
  83. package/docs/assistant-apps.md +172 -172
  84. package/docs/assistant-context.md +119 -119
  85. package/docs/bookings.md +442 -442
  86. package/docs/comms.md +686 -686
  87. package/docs/connectors.md +340 -340
  88. package/docs/css-baseline.md +133 -133
  89. package/docs/customer-guide.md +70 -70
  90. package/docs/deploying-apps.md +340 -340
  91. package/docs/entitlements.md +90 -90
  92. package/docs/files.md +69 -69
  93. package/docs/host-dependency-contract.md +210 -210
  94. package/docs/integrations.md +322 -322
  95. package/docs/interactions.md +545 -545
  96. package/docs/item-context.md +181 -181
  97. package/docs/knowledge.md +102 -0
  98. package/docs/lots.md +111 -111
  99. package/docs/loyalty.md +352 -352
  100. package/docs/members.md +182 -182
  101. package/docs/mobile-admin-container.md +693 -693
  102. package/docs/operations.md +281 -281
  103. package/docs/overview.md +482 -482
  104. package/docs/proof-comms-triggers.md +142 -142
  105. package/docs/proof-ownership-transfer.md +155 -155
  106. package/docs/proof-product-data-scoping.md +462 -462
  107. package/docs/proof-share-grants.md +305 -305
  108. package/docs/realtime.md +138 -138
  109. package/docs/standard-query.md +187 -187
  110. package/docs/tag-codes.md +97 -97
  111. package/docs/theme-lookbook.v1.json +120 -120
  112. package/docs/theme-tokens.md +252 -252
  113. package/docs/wallet-passes.md +107 -107
  114. package/docs/websites.md +123 -123
  115. package/openapi.yaml +320 -306
  116. package/package.json +87 -87
  117. package/scripts/headless-check.mjs +87 -87
  118. package/scripts/lib/bare-imports.mjs +57 -57
  119. package/scripts/lib/keyed-app-data.mjs +21 -21
  120. package/scripts/publish.mjs +272 -272
  121. package/scripts/register-release.mjs +91 -91
@@ -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`.