@collective-intelligence/ai 0.0.0-stage → 0.7.1

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 (172) hide show
  1. package/AGENTS.md +52 -0
  2. package/README.md +462 -2
  3. package/dist/api/access-check.d.ts +18 -0
  4. package/dist/api/answer-sources.d.ts +48 -0
  5. package/dist/api/attachments-api.d.ts +187 -0
  6. package/dist/api/catalog-api.d.ts +408 -0
  7. package/dist/api/chat-api.d.ts +2401 -0
  8. package/dist/api/chat-surface-api.d.ts +4186 -0
  9. package/dist/api/compaction.d.ts +52 -0
  10. package/dist/api/conversations.d.ts +107 -0
  11. package/dist/api/errors.d.ts +117 -0
  12. package/dist/api/feedback-api.d.ts +185 -0
  13. package/dist/api/files.d.ts +22 -0
  14. package/dist/api/ids.d.ts +33 -0
  15. package/dist/api/index.d.ts +21 -0
  16. package/dist/api/intents-api.d.ts +65 -0
  17. package/dist/api/place-context.d.ts +34 -0
  18. package/dist/api/projects-api.d.ts +718 -0
  19. package/dist/api/speech-api.d.ts +345 -0
  20. package/dist/api/transcript.d.ts +260 -0
  21. package/dist/api/turns.d.ts +196 -0
  22. package/dist/api.d.ts +21 -0
  23. package/dist/api.js +1 -0
  24. package/dist/domain/access.d.ts +29 -0
  25. package/dist/domain/context-trail.d.ts +65 -0
  26. package/dist/domain/data-parts.d.ts +247 -0
  27. package/dist/domain/errors.d.ts +28 -0
  28. package/dist/domain/index.d.ts +14 -0
  29. package/dist/domain/intents.d.ts +101 -0
  30. package/dist/domain/message.d.ts +173 -0
  31. package/dist/domain/place.d.ts +17 -0
  32. package/dist/domain/runtime-value.d.ts +16 -0
  33. package/dist/domain-50vzrrp9.js +2 -0
  34. package/dist/domain-5fpd4fte.js +1 -0
  35. package/dist/domain-9wzbv87n.js +2 -0
  36. package/dist/domain-g97xs965.js +2 -0
  37. package/dist/domain-hk3yw2m7.js +1 -0
  38. package/dist/domain-qyts6dgz.js +0 -0
  39. package/dist/domain-s07s1ry1.js +2 -0
  40. package/dist/domain.d.ts +14 -0
  41. package/dist/domain.js +1 -0
  42. package/dist/headless/access/access-store.d.ts +28 -0
  43. package/dist/headless/access/visibility.d.ts +24 -0
  44. package/dist/headless/blocked-state.d.ts +21 -0
  45. package/dist/headless/chat-registry.d.ts +63 -0
  46. package/dist/headless/chat-session-provider.d.ts +109 -0
  47. package/dist/headless/chat-surface.d.ts +4210 -0
  48. package/dist/headless/host-ports.d.ts +146 -0
  49. package/dist/headless/index.d.ts +33 -0
  50. package/dist/headless/intents/card-ends.d.ts +22 -0
  51. package/dist/headless/intents/intent-call.d.ts +28 -0
  52. package/dist/headless/intents/intents-provider.d.ts +108 -0
  53. package/dist/headless/intents/page-registry.d.ts +129 -0
  54. package/dist/headless/intents/use-intent-dispatch.d.ts +60 -0
  55. package/dist/headless/intents/use-intents.d.ts +11 -0
  56. package/dist/headless/intents/use-returned-intent-handle.d.ts +11 -0
  57. package/dist/headless/launch/chat-launch.d.ts +42 -0
  58. package/dist/headless/launch/launch-target.d.ts +25 -0
  59. package/dist/headless/launch/submit.d.ts +29 -0
  60. package/dist/headless/run-state.d.ts +16 -0
  61. package/dist/headless/sent-files.d.ts +20 -0
  62. package/dist/headless/server-started-turn-follow.proof.d.ts +26 -0
  63. package/dist/headless/session-machine.d.ts +745 -0
  64. package/dist/headless/trail/buffer.d.ts +48 -0
  65. package/dist/headless/trail/json-ld.d.ts +10 -0
  66. package/dist/headless/trail/switches.d.ts +10 -0
  67. package/dist/headless/trail/trail-provider.d.ts +53 -0
  68. package/dist/headless/transcript-messages.d.ts +26 -0
  69. package/dist/headless.d.ts +33 -0
  70. package/dist/headless.js +2 -0
  71. package/dist/transport/chat-client.d.ts +25 -0
  72. package/dist/transport/chat-transport.d.ts +57 -0
  73. package/dist/transport/index.d.ts +6 -0
  74. package/dist/transport/simulated-chat-transport.d.ts +39 -0
  75. package/dist/transport.d.ts +6 -0
  76. package/dist/transport.js +1 -0
  77. package/dist/views/assistant-sidebar/assistant-sidebar.d.ts +15 -0
  78. package/dist/views/assistant-sidebar/layout.d.ts +47 -0
  79. package/dist/views/assistant-sidebar/toggle.d.ts +14 -0
  80. package/dist/views/assistant-sidebar/use-shortcut.d.ts +11 -0
  81. package/dist/views/blocked/chat-blocked-state.d.ts +15 -0
  82. package/dist/views/chat-operations.d.ts +46 -0
  83. package/dist/views/chat-root.d.ts +14 -0
  84. package/dist/views/chat.d.ts +51 -0
  85. package/dist/views/composer/capability-picker.d.ts +77 -0
  86. package/dist/views/composer/capability-pickers.d.ts +24 -0
  87. package/dist/views/composer/chat-composer.d.ts +15 -0
  88. package/dist/views/composer/composer-picks.d.ts +31 -0
  89. package/dist/views/composer/composer-trail.d.ts +21 -0
  90. package/dist/views/composer/draft-attachments.d.ts +36 -0
  91. package/dist/views/composer/queued-messages.d.ts +9 -0
  92. package/dist/views/composer/send-menu.d.ts +11 -0
  93. package/dist/views/composer/slash-suggestions.d.ts +37 -0
  94. package/dist/views/composer/trail-chips.d.ts +15 -0
  95. package/dist/views/composer/voice-input/microphone.d.ts +14 -0
  96. package/dist/views/composer/voice-input/remote-transcription.d.ts +12 -0
  97. package/dist/views/composer/voice-input/use-voice-input.d.ts +30 -0
  98. package/dist/views/composer/voice-input/voice-input.d.ts +15 -0
  99. package/dist/views/dock/chat-dock.d.ts +57 -0
  100. package/dist/views/dock/dock-session.d.ts +22 -0
  101. package/dist/views/header/chat-header.d.ts +10 -0
  102. package/dist/views/header/compaction-controls.d.ts +17 -0
  103. package/dist/views/header/memory-switch.d.ts +16 -0
  104. package/dist/views/index.d.ts +58 -0
  105. package/dist/views/intents/form-fields.d.ts +38 -0
  106. package/dist/views/intents/intent-card.d.ts +61 -0
  107. package/dist/views/intents/intent-form.d.ts +23 -0
  108. package/dist/views/intents/intent-notices.d.ts +39 -0
  109. package/dist/views/intents/intent-trigger.d.ts +46 -0
  110. package/dist/views/intents/labels.d.ts +23 -0
  111. package/dist/views/labels/en.d.ts +3 -0
  112. package/dist/views/labels/index.d.ts +13 -0
  113. package/dist/views/labels/it.d.ts +3 -0
  114. package/dist/views/labels/types.d.ts +7 -0
  115. package/dist/views/launch/chat-launch-button.d.ts +21 -0
  116. package/dist/views/parts/answer-feedback.d.ts +26 -0
  117. package/dist/views/parts/evidence-part.d.ts +8 -0
  118. package/dist/views/parts/file-part.d.ts +8 -0
  119. package/dist/views/parts/image-generation-part.d.ts +9 -0
  120. package/dist/views/parts/image-generation.d.ts +84 -0
  121. package/dist/views/parts/intent-card-part.d.ts +8 -0
  122. package/dist/views/parts/memory-evidence-part.d.ts +7 -0
  123. package/dist/views/parts/message-parts.d.ts +21 -0
  124. package/dist/views/parts/question-part.d.ts +8 -0
  125. package/dist/views/parts/read-aloud.d.ts +23 -0
  126. package/dist/views/parts/reasoning-part.d.ts +8 -0
  127. package/dist/views/parts/steering-message-part.d.ts +7 -0
  128. package/dist/views/parts/text-part.d.ts +4 -0
  129. package/dist/views/parts/tool-part.d.ts +11 -0
  130. package/dist/views/parts/types.d.ts +103 -0
  131. package/dist/views/parts/use-read-aloud.d.ts +13 -0
  132. package/dist/views/run-trace/message-run.d.ts +17 -0
  133. package/dist/views/run-trace/run-stream.d.ts +128 -0
  134. package/dist/views/run-trace/run-trace-parts.d.ts +26 -0
  135. package/dist/views/run-trace/run-trace.d.ts +31 -0
  136. package/dist/views/sidebar/conversation-dialogs.d.ts +38 -0
  137. package/dist/views/sidebar/conversation-row.d.ts +23 -0
  138. package/dist/views/sidebar/conversation-sidebar.d.ts +10 -0
  139. package/dist/views/sidebar/date-groups.d.ts +12 -0
  140. package/dist/views/sidebar/history-filter.d.ts +57 -0
  141. package/dist/views/sidebar/projects/project-dialogs.d.ts +40 -0
  142. package/dist/views/sidebar/projects/project-files.d.ts +16 -0
  143. package/dist/views/sidebar/projects/project-groups.d.ts +19 -0
  144. package/dist/views/sidebar/projects/project-view.d.ts +21 -0
  145. package/dist/views/sidebar/projects/projects-section.d.ts +21 -0
  146. package/dist/views/sidebar/projects/use-chat-projects.d.ts +32 -0
  147. package/dist/views/slots.d.ts +148 -0
  148. package/dist/views/transcript/chat-transcript.d.ts +13 -0
  149. package/dist/views/transcript/sent-trail.d.ts +13 -0
  150. package/dist/views/transcript/use-image-reload.d.ts +16 -0
  151. package/dist/views.d.ts +58 -0
  152. package/dist/views.js +3 -0
  153. package/docs/guide/ai/index.md +377 -0
  154. package/docs/guide/ai/studio.md +245 -0
  155. package/docs/guide/data/connectors.md +267 -0
  156. package/docs/guide/data/datasets.md +145 -0
  157. package/docs/guide/data/documents.md +235 -0
  158. package/docs/guide/data/index.md +62 -0
  159. package/docs/guide/data/knowledge.md +214 -0
  160. package/docs/guide/develop/extensions.md +299 -0
  161. package/docs/guide/develop/external-apps.md +279 -0
  162. package/docs/guide/develop/infrastructure.md +135 -0
  163. package/docs/guide/develop/sdks.md +233 -0
  164. package/docs/guide/index.md +83 -0
  165. package/docs/guide/platform/access.md +311 -0
  166. package/docs/guide/platform/architecture.md +166 -0
  167. package/docs/guide/platform/built-ins.md +225 -0
  168. package/docs/guide/platform/entrypoints.md +318 -0
  169. package/docs/guide/scenarios/index.md +130 -0
  170. package/docs/guide/template/index.md +295 -0
  171. package/docs/guide/template/state-machines.md +294 -0
  172. package/package.json +123 -4
@@ -0,0 +1,377 @@
1
+ # AI primitives
2
+
3
+ Tools, Skills, Agents, workflows and Studio chat, how they compose, and how audiences, approvals, models, runs and timeouts behave.
4
+
5
+ The `next-effect-app` template ships two AI features. Its Lead qualifier Agent scores how ready a Lead is to convert, and its convert-lead workflow is the smallest workflow that the web app can start. That workflow only sets a workflow variable and writes no Lead record, so it is a starting point for your own steps. Both are built from the same small set of AI primitives, and a new demo feature usually starts as a copy of one of them. This page explains each primitive through those two features and ends with a table that helps you choose between them.
6
+
7
+ ## The building blocks
8
+
9
+ | Building block | What it is | Model inside | How it starts |
10
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
11
+ | Tool | A typed, callable capability, such as a Knowledge query, a message send, a web search or your own package code. Tools are grouped in tool collections. | No | A Skill, an Agent, a workflow node or a chat turn calls it. |
12
+ | Skill | Versioned instructions with model settings, permissions and a bounded set of tools, for one AI task. | Yes | Studio chat, a Studio Skill Form, the public Skill API, MCP, a workflow Skill node, or an Agent that holds it. |
13
+ | Agent | An Organization-owned actor with a Role, held Skills, its own tools and an optional typed output. | Yes | Your server invokes it, a person talks to it in Studio, or an event or a delegation from another Agent starts it. |
14
+ | Workflow | A durable graph of steps with triggers, versions, runs, pauses and approvals. | Only in Prompt and Skill nodes | A trigger fires: webhook, schedule, Knowledge record event, external application, MCP operation or on demand. |
15
+ | Studio chat | The conversation in [Studio](studio.md) in which Organization members use the agents, tools and Skills offered to them. | Yes | A member sends a message. |
16
+
17
+ The template's Lead qualifier composes three of these. A package declares the Lead score tool, a Lead scoring Skill that binds it, and an Agent that holds the Skill and is offered to the external application:
18
+
19
+ ```mermaid
20
+ flowchart LR
21
+ tool["Lead score tool"] -->|is created in| coll["Sales tool collection"]
22
+ skill["Lead scoring Skill"] -->|binds| tool
23
+ agent["Lead qualifier Agent"] -->|holds| skill
24
+ agent -->|lists directly| tool
25
+ agent -->|lists directly| kq["Knowledge query tool"]
26
+ agent -->|offered to| app["External application"]
27
+ ```
28
+
29
+ > **Warning:** A held Skill can use only the tools that its Agent also allows, which is why
30
+ > the Lead qualifier lists the Lead score tool again. When you add a tool to a
31
+ > Skill, add it to the Agent's `tools` list too.
32
+
33
+ ## Tools
34
+
35
+ Put deterministic logic in a tool and let the model orchestrate. The Lead score tool computes the 0 to 100 score from fixed points: 40 for a work email, 30 when the email domain matches the company, 30 when sales has qualified the Lead, and 100 when the Lead is already converted. The Skill tells the model to use that score as is, so the model never produces the number itself.
36
+
37
+ A package tool is a runtime class plus a declaration:
38
+
39
+ ```ts
40
+ export class LeadScoreTool extends PackageTool<LeadScoreInput, LeadScore> {
41
+ override async execute(lead: LeadScoreInput) {
42
+ return await Effect.runPromise(scoreLead(lead));
43
+ }
44
+ }
45
+
46
+ declareTool({
47
+ definition: {
48
+ audience,
49
+ autoActivate: true,
50
+ autoInstantiate: true,
51
+ bindingScopes: ["organization"],
52
+ capabilityType: "read",
53
+ effectKind: "read_only",
54
+ input: effectSchema(leadScoreInputSchema),
55
+ output: effectSchema(leadScoreSchema, { codec: true }),
56
+ toolGuidance: {
57
+ inputRequirementsSummary: "Needs the Lead's company and email, and its status when known.",
58
+ useWhen: "Score how ready one Lead is to convert, from 0 to 100.",
59
+ },
60
+ toolCollectionFqns: [salesToolCollectionFqn],
61
+ usageScopes: ["automation", "chat", "skill"],
62
+ },
63
+ implementation: LeadScoreTool,
64
+ ...
65
+ });
66
+ ```
67
+
68
+ `usageScopes` decides where the tool can appear: in a Skill, in chat, or in automation. The template needs `automation` so that the Lead qualifier Agent can use the tool. When you omit `usageScopes`, the tool appears in all three places, and an explicit empty list makes it unavailable everywhere. The model reads `toolGuidance.useWhen` and `toolGuidance.inputRequirementsSummary` to decide when to call the tool and what to pass, so write both for the model.
69
+
70
+ A package can also bind built-in tools for web search (Exa or Tavily, which need an API key), website scraping, image generation, email, notifications, OCR, speech transcription and synthesis, and report building. External applications can use `publish-run-event`. The [Built-in catalog](../platform/built-ins.md) lists every built-in tool and says which ones are ready after install.
71
+
72
+ ## Skills
73
+
74
+ A Skill's instructions are plain Markdown. The template's Lead scoring Skill uses numbered steps and one rule that stops the model from guessing:
75
+
76
+ ```ts
77
+ const instructions = `# Lead scoring
78
+
79
+ Score one Lead with the Lead score tool. Never guess a score.
80
+
81
+ 1. Read: Take the Lead's company, email, and status from Knowledge.
82
+ 2. Score: Call the Lead score tool once with those fields.
83
+ 3. Report: Use the tool's score as is. Explain it in one sentence from the tool's reasons.
84
+ `
85
+ ```
86
+
87
+ The package passes these instructions to `declareSkill({ definition: { audience, instructions, lifecycle, uses: { tools } } })`, and the template's `uses.tools` list holds only the Lead score tool. CI stores each Skill as a versioned package, and runtime always uses the active approved version.
88
+
89
+ The same Skill can run in Studio chat, in a Studio Skill Form, through the public Skill API (`skills_invoke`, then `runs_get` or `runs_stream`), through MCP `run_skill`, in a workflow Skill node, and inside an Agent that holds it. A Skill version can pin a model. Without a pin, it uses the model that the running Organization sets for Skill turns, which defaults to the `balanced` tier. A pinned model that does not resolve is a configuration error, and CI does not fall back to another model.
90
+
91
+ ## Agents
92
+
93
+ The template declares its Agent like this:
94
+
95
+ ```ts
96
+ declareAgent({
97
+ definition: {
98
+ audience: { applications: [application] },
99
+ behavioralBoundaries: ["Never change a Lead or create an Opportunity"],
100
+ lifecycle: { deployMode: "upsert", readonly: true },
101
+ objectives: ["Score how ready a Lead is to convert, from 0 to 100"],
102
+ operatingInstructions:
103
+ "Read the Lead from Knowledge, score it with the Lead scoring Skill, then submit the score with a one-sentence rationale.",
104
+ output: { schema: effectSchema(leadQualificationSchema, { codec: true }) },
105
+ responsibility: "Qualify Leads for the sales team",
106
+ uses: {
107
+ skills: [skill],
108
+ tools: ["builtin.core.knowledge.tools.query", tool]
109
+ }
110
+ },
111
+ manifest: { fqn: leadQualifierFqn, version },
112
+ presentation: {
113
+ description: "Scores a Lead's readiness to convert.",
114
+ displayName: "Lead qualifier"
115
+ }
116
+ })
117
+ ```
118
+
119
+ CI turns the Role into the run's system message in a fixed order: `responsibility`, `objectives`, `operatingInstructions`, `behavioralBoundaries` and the declared output contract. A catalog of the held Skills follows, with the reference, name and description of each. The task and its context, for example today's date, become the user message.
120
+
121
+ Held Skills load on demand. At first the Agent sees only the catalog. When it calls the CI-owned `load-skill` tool, it receives the Skill's instructions, and only then does CI offer that Skill's tool bindings to the model. A second tool, `read-skill-resource`, returns a reference, asset or script file of a loaded Skill.
122
+
123
+ `output: { schema }` takes a codec, so the app can keep one runtime schema in its contracts package. A succeeded run returns `{ message, output? }`. `message` is the final answer, and `output` is the structured Agent Output, already valid against the schema. `output` is absent when the run saved none, for example when the Agent asked a clarifying question.
124
+
125
+ An Agent without `activity` is idle and runs only when something triggers it: an invoke call, a conversation turn, an event or a delegation. The SDK also accepts `activity: { heartbeat, schedule }`. Before a demo depends on a package Agent that runs on a schedule or a heartbeat, confirm it with one trial run. Every Agent that a package declares is an Organization Agent.
126
+
127
+ FQN string references are not type-checked when you build. Install resolves them and rolls the package back when one is missing: each held Skill must be approved, each Agent or Skill tool must be an enabled tool of the Organization, and each audience reference must exist. Only a person can install a package that declares Agents or Skills; an install with no signed-in user fails.
128
+
129
+ ## Audiences
130
+
131
+ An audience is an allow-list with five keys:
132
+
133
+ - `organization: true` for the whole Organization
134
+ - `groups` for members of the listed Groups, including subgroups unless you set `coverage: "direct"`
135
+ - `profiles` for the listed Access Profiles
136
+ - `applications` for the listed external applications
137
+ - `anonymous` for anonymous visitors of the listed applications
138
+
139
+ An omitted or empty audience offers the item to nobody. Packages never name individual users; an admin adds users in the Dashboard. The template passes `salesMembers = { groups: [salesGroup] }` as the audience of the Sales tools, the Skill and the Studio app, so every Sales member gets them, and offers the Agent to the external application only.
140
+
141
+ A tool collection does not offer its tools to anyone, even when the collection has an audience. Each tool names its own audience, so set `audience` on every tool you declare.
142
+
143
+ Whether an admin's Dashboard edit to an audience survives the next deploy depends on the item. The deploy that creates a tool or tool collection writes its audience once, and later admin edits stay. Agents and Skills follow their `lifecycle`: `upsert` rewrites the declared audience on each deploy, `init_only` keeps admin edits, and `readonly` refuses them.
144
+
145
+ The declaration of an Agent sets the most it can do: its tools, scopes, approval controls and audience. An admin can only narrow that policy, for example by removing a tool or a Skill or by narrowing a binding's settings. These restrictions survive package updates and apply from the next run. [Access](../platform/access.md) explains Groups, Access Profiles and Access Grants.
146
+
147
+ ## Approvals
148
+
149
+ An entry in a `uses.tools` list can be a binding object instead of a bare reference. A binding can rename the tool, give it a Binding Description, set its Binding Settings and choose an approval mode, and you can bind one tool several times under different names:
150
+
151
+ ```ts
152
+ uses: {
153
+ tools: [
154
+ {
155
+ fqn: "builtin.core.knowledge.tools.query",
156
+ name: "lead-query",
157
+ description: "Search the Leads of the CRM",
158
+ settings: {
159
+ // The Knowledge tools' form marks this field "x-fqn-of": "knowledge-entity-schema".
160
+ allowedEntitySchemaIds: [leadSchemaFqn]
161
+ },
162
+ approval: { rule: "Escalations" }
163
+ }
164
+ ]
165
+ }
166
+ ```
167
+
168
+ `name`, `description` and `approval` work the same way for every tool. The model sees the Binding Description in place of the tool's own description. `settings` holds the tool's own options, and the tool's Binding Settings Form defines them, so install fails on a key that the form does not define. A field that the form marks with `x-fqn-of` takes FQNs, and install translates each FQN into the id of the installing Organization's record. Install fails when an FQN names no record of that Organization, and the error names every such FQN of the binding. A binding has no tool-specific property.
169
+
170
+ `approval` has three modes. `"never"` makes no approval request for the binding. `"always"` pauses for an explicit decision by the user who started the call, and that user's eligibility to approve does not approve the call. `{ rule: "<rule name>" }` uses an approval rule of the installing Organization, with that rule's reviewers and expiry. Install fails when no rule has the name, so create the rule in the target Organization before you install a package that uses one.
171
+
172
+ Approval pauses the call and leaves the tool visible. With `"always"`, the model still sees the tool definition and can decide to call it, and the call then waits for a person.
173
+
174
+ ### Approvals by caller
175
+
176
+ The same binding behaves differently for each kind of caller:
177
+
178
+ | Caller | What happens when a call needs approval |
179
+ | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
180
+ | Studio chat or a Skill run | The run pauses until a person decides. |
181
+ | Studio Skill Form | `ask_always` forces approval of every installed tool call, even on `never` bindings. `automatic` skips approval. Other authorization checks still apply. |
182
+ | Agent run | Nobody is there to approve. CI rechecks the binding, and unless the binding is denied, it approves the call by default, records it with the reason `unattended_default`, and runs it once. |
183
+ | Workflow | An Approval node pauses the workflow for a person. Approve and Reject both resume it with the decision data, so a reject branch can continue, for example to send a rejection email with the approver's `comment`. Reviewers see a preview of up to 32 next nodes for each decision. |
184
+
185
+ > **Note:** `"always"` does not stop an autonomous Agent the way it stops a chat user.
186
+ > When a demo must show a person approving, use Studio chat, a Skill Form or a
187
+ > workflow Approval node.
188
+
189
+ ### What approval does not do
190
+
191
+ An approval authorizes one attempt. It does not check the tool input and cannot make the call succeed: an approved Knowledge Query `search` call still fails when it has no `entitySchemaId`.
192
+
193
+ The reviewer never becomes the identity that runs the tool. After approval, the call resumes as the identity that started it, which can be a person, a service principal or an app server. CI rechecks that identity's current Organization authority, so a changed action, a rejection, an expiry or revoked access blocks the call. When the recipients or destination of a send change between approval and send, CI does not send. It opens a fresh approval request under the same identity, and that request needs a new decision. Reviewers see the facts of the pending action in Studio Notifications. CI freezes those facts when the request opens and shows secrets as omitted.
194
+
195
+ ## Models
196
+
197
+ An Organization configures one model for each standard tier: `complex`, `balanced`, `fast` and `super_fast`. Agents, Prompt nodes and other AI operations name a tier, never a vendor model. When the default model of a tier is missing, disabled or archived, every run that needs that tier is unavailable.
198
+
199
+ An Agent uses the tier in its `modelTier`, or `balanced` when it sets none. Its step limit is its `maxSteps`, or else the Organization setting `agentRunMaxSteps` (default 25, maximum 100), and a run that uses all its steps fails with `step_limit_reached`. A Skill's own model and iteration settings never apply inside an Agent run. Agents have no model preset, and CI rejects the old `modelPreset` field.
200
+
201
+ ## Runs are asynchronous
202
+
203
+ The gateway in front of CI cuts a request that stays silent for 120 seconds and caps every response at 10 minutes. Anything that can run longer than about 100 seconds must therefore return an id for the caller to poll, which is why Agent, Skill and workflow invocations all return a run id.
204
+
205
+ Studio chat turns, Skill runs, approval continuations, public Skill runs and MCP `run_skill` never execute inside the HTTP request. The request admits the run and returns its id, and a worker executes the run from a durable command queue. A client follows the run's stream, and a stream that ends cleanly does not mean the run has finished. Reconnect with the last sequence (`Last-Event-ID` or `afterSequence`) until the closing frame arrives.
206
+
207
+ Inside a run, a known tool error returns to the model as a tool result. The other calls in the same batch still run and the model can try again, so a successful Skill run can show failed calls in its trace.
208
+
209
+ ### Timeouts
210
+
211
+ | Limit | Default | Effect |
212
+ | ---------------------------------------------------------- | ------------------------------------------- | ----------------------------------------------------------------------------------------- |
213
+ | AI run deadline, `aiRunDeadlineSeconds` | 300 s, minimum 30 s | The run stops and fails with "The AI run timed out after N seconds." |
214
+ | Model call, `aiLlmCallTimeoutSeconds` | 180 s | Applies to each model call. Tool execution between calls does not count. |
215
+ | Interactive timeout on synchronous routes | 75 s | Failures surface before the 90 s request deadline. |
216
+ | Webhook response, `workflowWebhookResponseDeadlineSeconds` | 25 s, maximum 100 s | The webhook answers 202 with an id to monitor. |
217
+ | `await_result` trigger, `timeoutMs` | Set on each trigger; the template uses 90 s | The caller waits up to this long. Nodes never run inside the request. |
218
+ | Agent steps, `agentRunMaxSteps` | 25, maximum 100 | The run fails with `step_limit_reached`. |
219
+ | Workflow scheduler tick | 30 s | Each node-to-node continuation can wait for the next tick, so plan demo timing around it. |
220
+
221
+ ### Calling an Agent from your server
222
+
223
+ Your server invokes an Agent with `agents.invoke({ agentId, input })`, which returns `{ runId }`. Read the result with `runs.get`, or page through live events with `runs.stream`. The input carries `{ task, context?, attachments }`, with up to five files of 5 MiB each in PNG, JPEG, WebP, GIF, PDF, text, CSV, Markdown or JSON format. CI does not accept Office files.
224
+
225
+ `runs.stream` returns three kinds of event. `agent.tool` gives the tool name and its state (running, completed or failed) without arguments or results. `agent.reasoning` gives the provider's reasoning-summary text in batches, and `agent.context` gives input and output token counts for each model step. A page holds at most 100 events, so keep polling with the last cursor. Filter the reasoning text on your server before you show it to visitors.
226
+
227
+ For a multi-turn chat, call `conversations.continue({ agentId | conversationId, input, organizationId })` and read earlier turns with `conversations.history`. Each turn is an ordinary Agent run, and the earlier successful turns, with their saved Agent Output, become the model's conversation history. A continue call made while the previous turn still runs returns `conflict`, and an `idempotencyKey` replays the same turn on retry.
228
+
229
+ Anonymous visitors can chat with an Agent only when its audience has `anonymous: [app]` for that application and the call passes `callerKind: "anonymous_visitor"`. Their turns run with the Agent's own bindings, never with the application's grants, and visitors never see each other's conversations.
230
+
231
+ ## Workflows
232
+
233
+ A workflow graph runs from a trigger to a Workflow input node, through action nodes, to a Workflow output node. A trigger connects only to the Workflow input, and the Workflow output receives connections only from actions. The Workflow input and the Workflow output each carry a JSON Schema contract. The template's convert-lead workflow is the smallest useful example:
234
+
235
+ ```mermaid
236
+ flowchart LR
237
+ trigger["External application trigger"] -->|event| input["Workflow input"]
238
+ input --> mark["Set Variable: mark-converted"]
239
+ mark --> output["Workflow output"]
240
+ ```
241
+
242
+ Its one action node sets a fixed patch and declares how it behaves on dry runs, errors and retries:
243
+
244
+ ```ts
245
+ {
246
+ config: {},
247
+ id: "mark-converted",
248
+ inputs: { patch: { mode: "fixed", value: { converted: true } } },
249
+ metadata: {},
250
+ settings: {
251
+ dryRun: { mode: "allow" },
252
+ onError: { mode: "fail_run" },
253
+ retry: { mode: "disabled" },
254
+ },
255
+ templateFqn: "builtin.core.workflows.nodes.actions.set-variable",
256
+ templateVersion: "1.0.0",
257
+ }
258
+ ```
259
+
260
+ A workflow with a trigger needs a run-as service principal, and CI publishes it only with one. The template declares `servicePrincipal({ fqn: convertLeadRunnerFqn, groups: [], name: "Convert lead runner", version })` and selects it with `runIdentity: { mode: "service_principal", servicePrincipal: convertLeadRunnerFqn }` on the workflow.
261
+
262
+ ### Who a run acts as
263
+
264
+ Every tool call in a run uses the current grants of the identity that the run acts as. A workflow's `runIdentity` decides that identity for a person's start. In `triggering_user` mode, the default, the run acts as the person who starts it. In `service_principal` mode, a production run that a person starts from Studio or the Dashboard acts as the workflow's run-as service principal. A test run from the workflow editor always keeps its author's identity. A workflow that runs with no person, from a schedule, an event or an app call in service mode, needs `service_principal` mode, and CI refuses to publish an Organization workflow whose schedule or event trigger has no identity to run as.
265
+
266
+ | How the run starts | The run acts as |
267
+ | --------------------------------------------------------------------------- | ---------------------------------------------- |
268
+ | A Studio trigger form, or Run in the Dashboard, in `triggering_user` mode | The signed-in person |
269
+ | A Studio trigger form, or Run in the Dashboard, in `service_principal` mode | The run-as service principal |
270
+ | A test run from the workflow editor | The author |
271
+ | An external application call with the user's delegated token | The signed-in user |
272
+ | An external application call in service mode or with `runAsApplication` | The run-as service principal |
273
+ | A schedule, a webhook, a Knowledge record event or an MCP operation | The run-as service principal |
274
+ | An Invoke Workflow node (a child workflow) | The identity of the run that started the child |
275
+
276
+ An external application call with a delegated token acts as the user in both modes. The template's web app calls convert-lead with the user's delegated token, so a convert run from the web app acts as the signed-in Sales manager and not as `convertLeadRunner`, although the workflow is in `service_principal` mode. Agents follow the same rule: an Agent run acts as the person or app that started it, and an Agent that delegates to another Agent passes on that identity. An approval reviewer never becomes the identity of a run.
277
+
278
+ A service principal has no user identity in the tool catalog, which means user-scoped tool bindings never match it. Give it a tool through an Organization binding or through a Group it belongs to.
279
+
280
+ Each trigger has an invocation mode: `attach`, `detach`, or `await_result` with a `timeoutMs`. `detach` answers at once with a durable 202, and `await_result` waits up to its timeout. The convert-lead trigger uses `{ mode: "await_result", timeoutMs: 90_000 }`. The web app starts it from its server with `createFixedWorkflowRoute` from `@collective-intelligence/external-apps-server-sdk/next`. The server owns the workflow FQN, and the browser sends only the Lead id:
281
+
282
+ ```ts
283
+ const handle = createFixedWorkflowRoute<{ leadId: string }, { leadId: string }>(
284
+ {
285
+ ...options,
286
+ idempotencyKey: ({ leadId }) => `convert-lead:${leadId}`,
287
+ // The Workflows feature in the user's slice of the app's access; CI decides the run again.
288
+ requirement: convertLeadRequirement,
289
+ resourceId: "leads",
290
+ validate: (body, { leadId }) => {
291
+ const decoded = decodeConvertBody(body)
292
+ if (Option.isNone(decoded) || decoded.value.leadId !== leadId) {
293
+ throw new TypeError("invalid_request")
294
+ }
295
+ return { leadId }
296
+ }
297
+ }
298
+ )
299
+ ```
300
+
301
+ Call a workflow by `workflowId` or `workflowFqn`, never by slug. A package workflow keeps its declaration FQN in every install, while its id differs from one install to the next.
302
+
303
+ The core catalog has these triggers: Entity Created, Entity Updated (with optional watched fields), Entity Deleted, External application, MCP operation, On-demand, Schedule (cron) and Webhook. Its action nodes are Adapter, Approval, Code Block, File Content, File URL, HTTP Request, If, Invoke Workflow, Loop, Merge, Persist Artifact, Prompt, Set Variable, Skill, Stop Error, Stored File Link, Switch and Wait. Other core packages add nodes for Documents, speech and image generation.
304
+
305
+ Two of these action nodes run a model. Prompt generates text or structured JSON with a governed model: `mode` is `"text"` or `"structured"`, `model` optionally names a tier, and `responseSchema` shapes the structured result. It returns `{ kind: "text", text }` or `{ kind: "structured", object }`. The Skill node invokes a governed Skill by `skillId` and passes it an `inputMessage`. For code without a model, Code Block runs restricted JSON-only Python or JavaScript in an approved Docker runtime.
306
+
307
+ A field that is read at runtime can take an expression instead of a fixed value: `{ mode: "expression", languageVersion: 1, source }`. Structural fields stay fixed. Expressions use a closed, Mustache-shaped language that is not JavaScript. `{{ input.customer.email }}` reads the workflow input, and `{{ nodes["Fetch customer"].result.customer.email }}` reads an upstream node. A source that is exactly one interpolation keeps its JSON type, while any text around it makes the result a string. To convert a value, add a pipe such as `{{ input.amount | number }}`. The available pipes are `string`, `number`, `boolean`, `trim`, `lower`, `upper`, `length`, `first`, `last`, `floor`, `ceil` and `datetime`.
308
+
309
+ A package workflow has a `lifecycle` with `deployMode` set to `upsert` or `init_only`, plus `readonly`. The builder shows a readonly workflow as a view and accepts only layout changes. The template uses `init_only` with `readonly: false`, so admins can edit the deployed graph and later releases do not overwrite it.
310
+
311
+ In the builder, Save accepts an incomplete draft. Test and Publish validate the full graph. A full-workflow test needs a trigger and a Workflow input connected to an action, and otherwise fails with `trigger-required`, `input-target-required` or `node-not-found`. You can test a single node without a trigger.
312
+
313
+ ### Webhook triggers
314
+
315
+ A Webhook trigger accepts `POST` requests authenticated with an API key (`authentication: "api_key"`) on a `path` made of letters, digits and `._~-`. It passes the JSON body to the workflow as `event` and answers with JSON. The call waits for the workflow result for up to `workflowWebhookResponseDeadlineSeconds`, 25 seconds by default and 100 at most, and the response depends on the workflow's state at that point:
316
+
317
+ | Workflow state | Response |
318
+ | ----------------------------- | --------------------------------------------- |
319
+ | Completed | 200 with the workflow output JSON |
320
+ | Failed | 500 with `{ error, runId, status }` |
321
+ | Still running at the deadline | 202 with a `runId` or `deliveryId` to monitor |
322
+
323
+ ### Output contracts
324
+
325
+ A workflow's public result contains only what its declared output contract binds. CI never falls back to the output of an intermediate node, and it reports success only after it has validated and stored the declared result. `runs.get` returns `result: { nativeStatus: "completed", output }`. When reading the result fails, read the same `runId` again and do not send the business command a second time.
326
+
327
+ > **Warning:** The template's convert-lead workflow declares an empty output contract (`bindings: []`, `jsonSchema: { type: "object" }`), so it returns no business fields. Add output bindings when your workflow must return data.
328
+
329
+ ## How agents reach Knowledge, Documents and datasets
330
+
331
+ An agent reads data only through the tools it is bound to. The core packages provide these tools:
332
+
333
+ | Source | Tools |
334
+ | ----------- | ----------------------------------------------------------- |
335
+ | Knowledge | `catalog`, `query`, `mutate`, `knowledge-document-read` |
336
+ | Documents | `query` |
337
+ | Information | `advanced-retrieval`, `expand-passage`, `read-source-range` |
338
+ | Datasets | `query` |
339
+
340
+ Knowledge Query has seven intents: `autocomplete`, `search`, `facets`, `facet_values`, `count`, `get` and `relation_members`. `search`, `count` and the two facet intents need an `entitySchemaId`, and `get` needs an `entityId`. A missing id fails with `invalid_input`, so tell the model in the Skill or the Role to find schema ids with Knowledge `catalog` first and never to invent one. When a schema has record or indexed-file embeddings, Query also runs semantic retrieval on PostgreSQL with pgvector, and the model never sees the vectors or the embedding provider.
341
+
342
+ Two settings decide what these tools can read. The Binding Settings of a Knowledge tool narrow it to allowed or excluded domains and entity schemas (`allowedDomainIds`, `excludedDomainIds`, `allowedEntitySchemaIds` and `excludedEntitySchemaIds`), as the `lead-query` binding above does. The Information tools take `allowedEntitySchemaIds` in the same way, and when Advanced Retrieval loads Expand Passage and Read Source Range, they use its Binding Settings. `dataAccess` on `declareAgent`, `declareSkill` or `declareWorkflow` decides, separately for `knowledge`, `documents` and `datasets`, whose permission applies. With `"user"`, the run reads what the acting person can read. With the declaration's own kind (`"agent"`, `"skill"` or `"workflow"`), which is the default, the run reads its configured resources without the caller's permission on the source. `dataAccess` grants no extra tool bindings.
343
+
344
+ ```ts
345
+ const dataAccess = {
346
+ knowledge: "user",
347
+ documents: "agent"
348
+ } satisfies DataAccess<"agent">
349
+ ```
350
+
351
+ [Knowledge](../data/knowledge.md) and [Datasets](../data/datasets.md) explain the data that these tools read.
352
+
353
+ ## Tool, Skill, Agent or workflow
354
+
355
+ | | Tool | Skill | Agent | Workflow |
356
+ | --------------------- | --------------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
357
+ | Model inside | No | Yes | Yes | Only in Prompt and Skill nodes |
358
+ | Who decides the steps | Your code | The model, guided by the instructions | The model, guided by the Role and held Skills | The graph you build |
359
+ | How it starts | Another primitive or a chat turn calls it | Chat, Skill Form, API, MCP, workflow node or Agent | Your server, a Studio conversation, an event or a delegation | Webhook, schedule, record event, external application, MCP or on demand |
360
+ | Human approval | Set on its binding | The run pauses for a decision | Approved by default and recorded | Approval node |
361
+ | Output | Typed by its output schema | The run's result | `message` plus typed `output` | The declared output contract |
362
+ | Pick it when | You need one deterministic, typed action such as score, fetch or send | One AI task with a bounded tool set must run in several places | You need a long-lived Role with an audience, typed output, conversation history or unattended runs | The steps are fixed and you need triggers, approvals or a typed result |
363
+
364
+ Most features combine these primitives. The Lead qualifier uses a deterministic tool, a Skill that tells the model how to use it, and an Agent that holds the Skill for the external application. Convert-lead is a workflow because its one step is fixed and the web app waits for the result, so it needs no model. When a workflow step needs AI, use a Prompt or Skill node. [Scenarios](../scenarios/index.md) walks through more demo cases.
365
+
366
+ ## Not covered here
367
+
368
+ This page does not cover Personal Agents (admins create them in the Dashboard), Studio chat Projects, running Skill scripts, or the planned cancel and retry controls for Agent runs.
369
+
370
+ ## Related pages
371
+
372
+ - [Studio](studio.md)
373
+ - [Knowledge](../data/knowledge.md)
374
+ - [Datasets](../data/datasets.md)
375
+ - [Extensions](../develop/extensions.md)
376
+ - [Access](../platform/access.md)
377
+ - [Scenarios](../scenarios/index.md)
@@ -0,0 +1,245 @@
1
+ # Studio
2
+
3
+ How Organization members work in the Studio desktop app, how a package ships Studio apps, forms and widgets, and how Studio shares one solution with your external application.
4
+
5
+ Studio is the CI app where the people of an Organization do their work. They chat with agents, use Skills, open Studio apps, fill forms, decide approvals and find Documents. Admins set up the Organization in the Dashboard, and members use what it offers them in Studio. A package can ship a complete Studio app, and the `next-effect-app` template ships one: the Sales desk, which lists the same Leads that the template's web app reads and writes. This page uses the Sales desk as the running example.
6
+
7
+ ## Install and connect Studio
8
+
9
+ Studio is a desktop app. Each Organization has a Studio install page in the Dashboard at `/get-studio/<organization-id>`, and nobody types a backend URL:
10
+
11
+ 1. Open the install page and pick a platform: macOS (Apple Silicon or Intel), Windows or Linux. The page detects one for you.
12
+ 2. Download and install Studio, then keep it open.
13
+ 3. Click Connect Studio on the install page. The browser asks to open Collective Intelligence; choose Open.
14
+ 4. If the button does not work, click Copy connect link and paste the link in Studio under "Connect button didn't work?".
15
+
16
+ The connect link is signed, and the backend verifies it before Studio stores the connection. When the page says "Studio setup isn't finished for this organization", an Organization admin must complete the Studio setup first.
17
+
18
+ After it connects, Studio shows the Organization's name, cover and logo on its loading and login screens, also offline. Before it opens the workspace, Studio checks the Organization's Stable and Minimum desktop versions, and it saves the open tabs before it installs an update.
19
+
20
+ ## Who can open Studio
21
+
22
+ A member uses Studio only through the `studio` entry capability. The built-in Studio user profile holds it, together with the platform capabilities for conversations, agents, Knowledge, workflows, datasets and notifications. A guest acts only through the entry of an external application, so a guest cannot use Studio.
23
+
24
+ > **Warning:** The template's Sales rep and Sales manager profiles do not allow
25
+ > `core.studio`. Before a Sales member can open the Sales desk, check that the
26
+ > member also holds the Studio user profile or another profile that allows
27
+ > `core.studio`. [Access](../platform/access.md) explains profiles and grants.
28
+
29
+ What a person sees inside Studio still follows the grants. A Studio user reads no Knowledge record until a Knowledge Data Policy or a profile opens it, and a Studio app or page with an empty audience is offered to nobody.
30
+
31
+ ## What a Studio app holds
32
+
33
+ A Studio app is a set of sections and pages in a left sidebar. Each page holds views. Admins build apps in the Dashboard builder, and a package can declare one. These built-in pages are available to every app:
34
+
35
+ | Page | What it does |
36
+ | --------------- | --------------------------------------------------------------- |
37
+ | Chat | The conversational workspace with agents and Skills |
38
+ | Agents | Lists the agents offered to the person and starts conversations |
39
+ | Skills | Lists the Skills the person can use in chat |
40
+ | Approvals | Lists pending approval decisions |
41
+ | Notifications | Shows Studio notifications, including approval requests |
42
+ | Activity Center | The person's work inbox of activities in progress and done |
43
+ | Documents | Browses, searches and downloads Documents |
44
+
45
+ The built-in views are tabs, a responsive grid, a report, a schema list and a schema entity detail for Knowledge records, a Skill form, a trigger form, an agent form, workflow runs, agent runs and a Dataset area. Their references have the form `builtin:view.<name>`, for example `builtin:view.schema-list`, and pages use `builtin:page.<name>`.
46
+
47
+ ## Chat with agents
48
+
49
+ The Agents page lists every agent whose audience includes the person, and each one opens a conversation. When an agent is missing, check its audience first. The template's Lead qualifier has `audience: { applications: [application] }`, so the web app can call it and no Sales member sees it in Studio. To offer it to Sales members too, pass the Sales audience into the agent's declaration and keep the application:
50
+
51
+ ```ts
52
+ declareAgent({
53
+ definition: {
54
+ audience: { ...audience, applications: [application] }
55
+ // ...
56
+ }
57
+ // ...
58
+ })
59
+ ```
60
+
61
+ The template already passes `audience` (the Sales Group) into `leadQualificationComponents` for the tool and the Skill, so `leadQualifierAgent` needs that parameter as well. A tool binding with an approval mode pauses a chat turn until a person decides. [AI primitives](index.md) explains agents, Skills, tools and approvals in detail.
62
+
63
+ ## Ship a Studio app from a package
64
+
65
+ `declareStudioApp` declares a Declared Studio App, which CI creates and publishes when it installs the package. `declareStudioAppTemplate` instead declares a starting point that the builder copies into a new app, and the copy keeps no link to the package. These rules apply to a Declared Studio App:
66
+
67
+ - Its `lifecycle` is always `{ deployMode: "upsert", readonly: true }`, and the SDK refuses other values.
68
+ - The app and each page take an `audience`. Without one, CI offers them to nobody. Sections show while one of their pages is offered, and views follow their page.
69
+ - Studio never shows a page that the person cannot access, and it shows no empty placeholder for it.
70
+ - A later release finds the app by its FQN, so a new slug moves the same app.
71
+ - A missing workflow, trigger, agent, schema, component or audience reference makes the install write nothing.
72
+ - The builder shows the app as package-owned and read-only. Change it through a new release.
73
+ - An uninstall disables the app, and a new install enables it again.
74
+
75
+ The Sales desk has one section and one Leads page, offered to the Sales Group. The page places a Knowledge schema list and the Lead score card widget, both bound to the Lead schema:
76
+
77
+ ```ts
78
+ export const salesDeskApp = declareStudioApp({
79
+ definition: {
80
+ audience: salesMembers,
81
+ definition: {
82
+ name: "Sales desk",
83
+ slug: "acme-sales-desk",
84
+ sections: [
85
+ {
86
+ fqn: `${salesDeskAppFqn}.sections.sales`,
87
+ label: "Sales",
88
+ slug: "sales",
89
+ orderIndex: 0,
90
+ pages: [
91
+ {
92
+ audience: salesMembers,
93
+ fqn: `${salesDeskAppFqn}.pages.leads`,
94
+ label: "Leads",
95
+ slug: "leads",
96
+ kind: "generic",
97
+ routeSegment: "leads",
98
+ orderIndex: 0,
99
+ // No `mutations`: the list is read-only; the web app writes Leads.
100
+ views: [
101
+ {
102
+ componentRef: "builtin:view.schema-list",
103
+ dataBinding: { kind: "schema", schema: leadSchemaFqn },
104
+ fqn: `${salesDeskAppFqn}.views.leads-list`,
105
+ orderIndex: 0,
106
+ slot: "main"
107
+ },
108
+ {
109
+ componentRef: leadScoreCardComponentFqn,
110
+ dataBinding: { kind: "schema", schema: leadSchemaFqn },
111
+ fqn: `${salesDeskAppFqn}.views.lead-score`,
112
+ orderIndex: 1,
113
+ slot: "main"
114
+ }
115
+ ]
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ },
121
+ lifecycle: { deployMode: "upsert", readonly: true }
122
+ },
123
+ manifest: { fqn: salesDeskAppFqn, version: VERSION },
124
+ presentation: {
125
+ displayName: "Sales desk",
126
+ description: "Leads of the Acme CRM with the Lead score card."
127
+ }
128
+ })
129
+ ```
130
+
131
+ To let Sales members edit Leads in Studio, set `props.mutations.create`, `update` or `delete` on the schema list to `true`. A schema entity detail view becomes editable when `update` is on. Each write still passes the Lead write policy, which in the template requires CRM `manage`.
132
+
133
+ ## Forms
134
+
135
+ Three built-in views collect input and start a run. Each one runs as the Studio user who submits it:
136
+
137
+ | Form | Declared with | What it runs |
138
+ | ----------------------------------------- | --------------------------------------------------------------------------------------- | ----------------------------------------------------- |
139
+ | Trigger form, `builtin:view.trigger-form` | `withStudioTriggerForm(trigger, { organizationGroup, fields })` on an On-demand trigger | The workflow, once every field holds a valid value |
140
+ | Agent form, `builtin:view.agent-form` | `withStudioAgentForm(agent, { fields })` | The declared agent, with the field values as its task |
141
+ | Skill form, `builtin:view.skill-form` | The Dashboard builder | One Skill with structured input |
142
+
143
+ ### Trigger form fields
144
+
145
+ A trigger form shows and runs only for members of its `organizationGroup`, including subgroups. Its fields can be `text`, `textarea`, `number`, `boolean`, `enum`, `json` with a JSON Schema, `rich_text`, `file` (PDF, JPEG or PNG up to 10 MiB by default), `entities` (Knowledge records of one schema that the person can read) and `user_select` (Organization members). Workflow nodes read a value as `{{ trigger.form.<key> }}`. A link can open the form prefilled through the query parameter `prefill.<triggerRef>`, so put no secrets in such a link.
146
+
147
+ ### Agent forms
148
+
149
+ An agent form names its agent by FQN in `props.agentRef` and runs it inline within the agent's audience. The optional `props.resultWidget` names a widget that renders the agent's output. Agent form fields of type `file` or `entities` have no input yet: the view shows "This field cannot be filled in an agent form yet." and keeps Run disabled.
150
+
151
+ ### Form runs and approvals
152
+
153
+ A run from an agent form or a Skill form keeps its history, result, follow-ups, retries, cancellation and approvals together. A Skill form set to `ask_always` asks a person to approve every installed tool call, even on bindings set to `never`, and `automatic` skips approval. The other authorization checks still apply.
154
+
155
+ ## Run lists, Documents and datasets
156
+
157
+ The workflow runs view (`props.workflows`) and the agent runs view (`props.agents`) list the runs of the workflows or agents they name, for the people who can see the view. A retry starts a new run as the person who retries it, with the original input. A workflow retry needs an On-demand trigger on that version. The lists show status, times and error codes, and never inputs, outputs or messages.
158
+
159
+ The Documents page is a finder. A person browses the Document Collections and folders they can read, searches filenames and document content in one field, downloads the stored file of a Document Version, or opens a cloud file in its Microsoft or Google app. Studio has no built-in document viewer. [Documents](../data/documents.md) explains collections and versions.
160
+
161
+ The Dataset area lists the datasets a person can see, with each dataset's definition, policy, health, freshness and lineage. Its query workspace offers only the fields and operations that the dataset policy allows, and the create panel appears only for a person who can administer datasets. [Datasets](../data/datasets.md) explains the policies.
162
+
163
+ ## Approvals
164
+
165
+ The Approvals page lists the decisions that wait for the person. A notification for an approval shows the facts of the pending action, such as what it sends, to whom, and which Skill or workflow asks. CI freezes those facts when the request opens and shows secrets as omitted. The reviewer decides and never becomes the identity that runs the call.
166
+
167
+ ## Widgets from packages
168
+
169
+ A widget is a React component that a package ships and a Studio page places. The template's Lead score card needs four pieces:
170
+
171
+ 1. A backend declaration in the package's `components`: `declareStudioComponent` with `category: "widget"`, a `propsSchema` and a `sourceRef` that names the package's Studio contribution.
172
+ 2. A frontend declaration: `declareFrontendComponent` with a `load` callback and a `studio_component` target, returned by the package's `loadFrontendCatalog`.
173
+ 3. A hosted contribution for the Studio host in `declarePackage({ hostedContributions })`.
174
+ 4. A view of a Studio app that places the widget by its FQN in `componentRef`, as the Sales desk does.
175
+
176
+ ```ts
177
+ declareFrontendCatalogContribution({
178
+ compatibility: { react: "^19.0.0" },
179
+ fqn: leadScoreCardContributionFqn,
180
+ host: "studio",
181
+ load: async () => await import("./studio")
182
+ })
183
+ ```
184
+
185
+ Every placed widget gets a `context` prop with the app, page, view and published revision ids. The prop is `null` in the builder preview and before the app is published, so a widget renders an inert state then. The Lead score card shows a Preview badge in that case.
186
+
187
+ A widget holds no CI credentials. It calls CI through the Studio API client from `@collective-intelligence/extensions-sdk-frontend-react/studio-api`, which Studio binds to its own signed-in connection, so each request runs with the signed-in person's permissions. The client covers the view-data search, read and update calls and the reads of the two run-list views. The Lead score card reads the Leads of its own view:
188
+
189
+ ```tsx
190
+ const leads = useQuery({
191
+ ...studioViewDataSearchOptions({
192
+ ...studioViewScope(context),
193
+ body: { limit: SEARCH_LIMIT }
194
+ }),
195
+ select: leadsOf
196
+ })
197
+ ```
198
+
199
+ A widget writes through a `fromEffect` XState actor from `@collective-intelligence/extensions-sdk-frontend-react/effect` and mounts `EffectRuntimeProvider` at its root. Package widgets render in the Studio desktop app, which downloads and verifies the package release.
200
+
201
+ > **Note:** The Lead score card shows the stored `score` field of each Lead, or "Not
202
+ > scored yet" when the field is empty. People set that field in the web app's
203
+ > Lead form. The card runs no agent, and nothing in the template writes the Lead
204
+ > qualifier's score back to the Lead.
205
+
206
+ > **Warning:** An install of a package with a Studio contribution waits until a Studio
207
+ > desktop app of that Organization reports the release ready. A pipeline has no
208
+ > Studio, so pass `--skip-studio-readiness` to `ci deploy`, as the template
209
+ > does. A Studio that connects later loads the release then.
210
+
211
+ ## Studio and your external application
212
+
213
+ The template's package installs everything that Studio and the web app share. Studio people and web app users are the same CI users, and both sides read the same Lead records:
214
+
215
+ ```mermaid
216
+ flowchart LR
217
+ pkg["Extension package"] -->|installs| org["Organization"]
218
+ org --> desk["Sales desk in Studio"]
219
+ org --> app["External application and BFF"]
220
+ desk -->|reads| leads["Lead records"]
221
+ app -->|reads and writes| leads
222
+ ```
223
+
224
+ One `ci deploy` installs the Lead schema, the Sales Group and its grants, the external application, the convert-lead workflow, the Lead qualifier with its Skill and tool, and the Sales desk with its widget. The Sales Group's grants decide what a Sales member does in the web app, and the same Group is the audience of the Sales desk. A Lead that a Sales manager edits in the web app is the record that the Sales desk lists. The web app cuts each user's access to the application's Max Privileges, and Studio sessions have no such cut, so the same person can see more in Studio than through the app.
225
+
226
+ Workflows and agents can start from either side:
227
+
228
+ | Primitive | From the web app | From Studio |
229
+ | --------- | ----------------------------------------------------------------------------- | ------------------------------------------- |
230
+ | Workflow | An External application trigger, started by the server's Fixed workflow route | An On-demand trigger with a trigger form |
231
+ | Agent | `agents.invoke` or `conversations.continue` from the app server | The Agents and Chat pages, or an agent form |
232
+ | Audience | `applications: [application]` | `groups`, `profiles` or `organization` |
233
+
234
+ A trigger form needs a trigger that people start, so an External application trigger cannot back it. One workflow can declare both triggers when the same work must start from both sides. The template's convert-lead workflow has only the External application trigger.
235
+
236
+ A run acts as the identity that started it, and every tool call in the run uses that identity's current grants. A Sales manager who starts a workflow from Studio runs it as themselves when the workflow's `runIdentity` is `triggering_user`, and as the workflow's run-as service principal when it is `service_principal`. A run that no person starts acts as that service principal. [AI primitives](index.md) lists every case.
237
+
238
+ ## Related pages
239
+
240
+ - [AI primitives](index.md)
241
+ - [Access](../platform/access.md)
242
+ - [Extensions](../develop/extensions.md)
243
+ - [External apps](../develop/external-apps.md)
244
+ - [Documents](../data/documents.md)
245
+ - [Datasets](../data/datasets.md)