@collective-intelligence/external-apps-server-sdk-payload 0.0.0-stage → 0.13.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 (61) hide show
  1. package/AGENTS.md +49 -0
  2. package/README.md +121 -2
  3. package/dist/ci-generate/declarations/ci-generate/generate.d.ts +10 -0
  4. package/dist/ci-generate/declarations/entrypoints/ci-generate.d.ts +6 -0
  5. package/dist/ci-generate/declarations/knowledge/body.d.ts +32 -0
  6. package/dist/ci-generate/declarations/knowledge/files.d.ts +42 -0
  7. package/dist/ci-generate/declarations/knowledge/manifest.d.ts +19 -0
  8. package/dist/ci-generate/declarations/package/builder.d.ts +63 -0
  9. package/dist/ci-generate/declarations/package/contract.d.ts +16 -0
  10. package/dist/ci-generate/declarations/package/stamped-fields.d.ts +7 -0
  11. package/dist/ci-generate/declarations/plugin/editor-field.d.ts +20 -0
  12. package/dist/ci-generate/declarations/plugin/integration-user.d.ts +11 -0
  13. package/dist/ci-generate/declarations/plugin/parts.d.ts +81 -0
  14. package/dist/ci-generate.d.ts +1 -0
  15. package/dist/ci-generate.js +2 -0
  16. package/dist/index/declarations/ci-generate/generate.d.ts +10 -0
  17. package/dist/index/declarations/entrypoints/index.d.ts +6 -0
  18. package/dist/index/declarations/knowledge/body.d.ts +32 -0
  19. package/dist/index/declarations/knowledge/files.d.ts +42 -0
  20. package/dist/index/declarations/knowledge/identity.d.ts +27 -0
  21. package/dist/index/declarations/knowledge/manifest.d.ts +19 -0
  22. package/dist/index/declarations/knowledge/push-job.d.ts +8 -0
  23. package/dist/index/declarations/knowledge/source.d.ts +24 -0
  24. package/dist/index/declarations/operations/conflict.d.ts +22 -0
  25. package/dist/index/declarations/operations/markdown.d.ts +25 -0
  26. package/dist/index/declarations/operations/operations.d.ts +30 -0
  27. package/dist/index/declarations/operations/write-back.d.ts +8 -0
  28. package/dist/index/declarations/package/builder.d.ts +63 -0
  29. package/dist/index/declarations/package/contract.d.ts +16 -0
  30. package/dist/index/declarations/package/stamped-fields.d.ts +7 -0
  31. package/dist/index/declarations/plugin/editor-field.d.ts +20 -0
  32. package/dist/index/declarations/plugin/grant-store.d.ts +21 -0
  33. package/dist/index/declarations/plugin/integration-user.d.ts +11 -0
  34. package/dist/index/declarations/plugin/parts.d.ts +81 -0
  35. package/dist/index/declarations/plugin/plugin.d.ts +10 -0
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +7 -0
  38. package/dist/package.d.ts +134 -0
  39. package/dist/package.js +24 -0
  40. package/docs/guide/ai/index.md +379 -0
  41. package/docs/guide/ai/studio.md +245 -0
  42. package/docs/guide/data/connectors.md +267 -0
  43. package/docs/guide/data/datasets.md +145 -0
  44. package/docs/guide/data/documents.md +235 -0
  45. package/docs/guide/data/index.md +62 -0
  46. package/docs/guide/data/knowledge.md +214 -0
  47. package/docs/guide/develop/extensions.md +299 -0
  48. package/docs/guide/develop/external-apps.md +289 -0
  49. package/docs/guide/develop/infrastructure.md +135 -0
  50. package/docs/guide/develop/sdks.md +252 -0
  51. package/docs/guide/index.md +83 -0
  52. package/docs/guide/platform/access.md +311 -0
  53. package/docs/guide/platform/architecture.md +166 -0
  54. package/docs/guide/platform/built-ins.md +225 -0
  55. package/docs/guide/platform/entrypoints.md +320 -0
  56. package/docs/guide/scenarios/index.md +130 -0
  57. package/docs/guide/template/index.md +295 -0
  58. package/docs/guide/template/state-machines.md +294 -0
  59. package/docs/payload-connector.md +890 -0
  60. package/docs/payload-page-editor-skill.md +284 -0
  61. package/package.json +79 -4
@@ -0,0 +1,252 @@
1
+ # SDKs
2
+
3
+ Which @collective-intelligence package to import, from which subpath, with which Effect setup and which versions.
4
+
5
+ The SDK family splits by where your code runs. Code that you install into CI as part of a package uses the `@collective-intelligence/extensions-sdk*` packages. Code that you host yourself, such as a Next.js web app and its BFF, uses the `@collective-intelligence/external-apps-*` packages. A self-hosted content system, such as a Payload Site, uses a CMS SDK of that family.
6
+
7
+ The template keeps the families apart. Package code imports only `extensions-sdk*` and `ui-react`, browser code imports the client SDK, and confidential server code imports the server SDK.
8
+
9
+ ## Where your code runs
10
+
11
+ ```mermaid
12
+ flowchart LR
13
+ subgraph pkg["Package: apps/extensions and the ci parts"]
14
+ decl["Declarations<br/>extensions-sdk"]
15
+ impl["Tool and connector classes<br/>extensions-sdk-backend"]
16
+ widget["Studio widgets<br/>extensions-sdk-frontend(-react)"]
17
+ end
18
+ subgraph ci["Inside CI"]
19
+ backend["CI backend"]
20
+ hosts["Studio and Dashboard"]
21
+ end
22
+ subgraph app["Your app: apps/web"]
23
+ browser["Browser code<br/>external-apps-client-sdk(-react)"]
24
+ server["Server code and BFF<br/>external-apps-server-sdk"]
25
+ end
26
+ cli["ci CLI"]
27
+ pkg --> cli
28
+ cli -->|"ci deploy"| backend
29
+ impl -.->|"runs in"| backend
30
+ widget -.->|"renders in"| hosts
31
+ browser -->|"same-origin proxy"| server
32
+ server -->|"confidential credentials"| backend
33
+ ```
34
+
35
+ In the template, the left side is `apps/extensions` plus the `ci` part of each domain. The CLI builds that code into a release and installs it into your Organization. After install, CI runs the backend classes and Studio renders the widgets, so this code never runs in your app.
36
+
37
+ The right side is `apps/web`. Its browser code talks to its own server through a same-origin proxy, and the server calls CI with the application's confidential credentials. A browser can also call CI directly through the client SDK; in that case your app does not need the server SDK.
38
+
39
+ ## The packages
40
+
41
+ | Package | Runs where | Main subpaths | Use it for |
42
+ | ----------------------------------------------------------- | ------------------------------- | --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
43
+ | `@collective-intelligence/extensions-sdk` | Package build | `.`, `/effect` (empty) | Declare the package and its components with `declarePackage` and the other `declare*` functions |
44
+ | `@collective-intelligence/extensions-sdk-backend` | Inside CI, backend | `.`, `/effect` | Implement the code that tools, connectors and dataset providers run |
45
+ | `@collective-intelligence/extensions-sdk-frontend` | Inside CI, Studio and Dashboard | `.`, `/effect` (empty) | Declare the frontend catalog that a Host loads through `loadFrontendCatalog` |
46
+ | `@collective-intelligence/extensions-sdk-frontend-react` | Inside CI, Studio and Dashboard | `/studio`, `/studio-api`, `/dashboard`, `/workflow`, `/ui-react`, `/effect` | Write the React code of a Studio widget or Dashboard contribution |
47
+ | `@collective-intelligence/external-apps-client-sdk` | Your app, browser | `.`, `/resources`, `/effect` | Sign users in with CI and call CI operations without React |
48
+ | `@collective-intelligence/external-apps-client-sdk-react` | Your app, browser | `.`, `/resources`, `/effect` | Providers and entity hooks that read and write CI records |
49
+ | `@collective-intelligence/external-apps-server-sdk` | Your app, server only | `.`, `/auth/federated`, `/effect`, `/next`, `/admin` | BFF routes, sign-in and confidential calls to CI |
50
+ | `@collective-intelligence/external-apps-server-sdk-payload` | Your Payload Site, server only | `.`, `/package`, `/ci-generate` | Connect a Payload Site to CI: the Payload Plugin, and helpers for the site's CI package |
51
+ | `@collective-intelligence/external-apps-server-sdk-strapi` | Your Strapi 5 site, server only | `.` | Serve the documents of a Strapi 5 site to CI through a Gateway |
52
+ | `@collective-intelligence/ui-react` | Both sides | `/ui`, `/resources`, `/icons`, `/hooks`, `/tokens/theme` | CI design-system components that take display-ready props |
53
+ | `@collective-intelligence/cli` | Your machine or pipeline | `ci` binary | Sign in, build and deploy packages, enroll an app |
54
+ | `@collective-intelligence/lint` | Development | `recommended` | Oxlint rules that keep the solution layout and Effect imports correct |
55
+ | `@collective-intelligence/schema-codegen` | Development | `.` | Generate TypeScript, Zod or Effect Schema source from package schemas |
56
+
57
+ You rarely import `schema-codegen` yourself, because `ci package codegen --target zod|effect|types` calls it for you. Generated schemas describe the wire shape only, and the CI backend still validates every payload.
58
+
59
+ The `ci` binary runs on Bun. Install it globally and keep it current with `ci upgrade`:
60
+
61
+ ```bash
62
+ npm install -g @collective-intelligence/cli
63
+ ci login <api-url> --organization <organization-id>
64
+ ```
65
+
66
+ `@collective-intelligence/lint` needs `oxlint` 1.82.0 or later:
67
+
68
+ ```ts
69
+ import { recommended } from "@collective-intelligence/lint"
70
+ import { defineConfig } from "oxlint"
71
+ export default defineConfig({ extends: [recommended] })
72
+ ```
73
+
74
+ ## Code that runs inside CI
75
+
76
+ ### Declarations with `extensions-sdk`
77
+
78
+ `extensions-sdk` is the framework-neutral authoring contract. Its root loads no Effect, React, Zod, database or HTTP code, and it is the only entrypoint you import; do not deep-import its internal folders. Every declaration has the same shape, `declareX({ manifest, presentation, definition, implementation })`. `manifest` holds `{ fqn, version }`, `presentation` holds catalog metadata such as the display name, `definition` holds the serializable data for that kind, and `implementation` is a class constructor that only executable kinds such as tools take. [Extensions](extensions.md) lists what a package can declare.
79
+
80
+ ### Backend code with `extensions-sdk-backend`
81
+
82
+ This package holds the executable base classes, such as `PackageTool` and the connector and dataset provider classes, and the runtime context they receive. The root returns plain values and `PromiseLike` results, so it works without Effect:
83
+
84
+ ```ts
85
+ import {
86
+ PackageTool,
87
+ type PackageRuntimeContext
88
+ } from "@collective-intelligence/extensions-sdk-backend"
89
+
90
+ export class EchoTool extends PackageTool<{ text: string }, string> {
91
+ execute(
92
+ input: { text: string },
93
+ _context: PackageRuntimeContext
94
+ ): PromiseLike<string> {
95
+ return Promise.resolve(input.text)
96
+ }
97
+ }
98
+ ```
99
+
100
+ > **Warning:** One Worker serves every Organization that invokes the same package release,
101
+ > and several calls can run at the same time. Read the Organization,
102
+ > capabilities and configuration only from the per-call `context`, and never
103
+ > keep tenant data in module-level variables.
104
+ > [Extensions](extensions.md) describes the other runtime rules.
105
+
106
+ ### Studio widgets with `extensions-sdk-frontend` and `extensions-sdk-frontend-react`
107
+
108
+ `extensions-sdk-frontend` declares the catalog. Every Studio or Dashboard contribution exports a function named `loadFrontendCatalog`, and every `declareFrontendComponent` needs a `load: () => import("./x")` callback, because a bundled Host cannot import a renderer by module name.
109
+
110
+ `extensions-sdk-frontend-react` holds the React side. Studio passes a widget a `context` prop with `appId`, `organizationId`, `pageId` and `viewId`. In the builder preview, or before the app is published, `context` is `null`, so hide API calls until it has a value. The template's Lead score card imports from these subpaths:
111
+
112
+ ```tsx
113
+ import { studioViewScope } from "@collective-intelligence/extensions-sdk-frontend-react/studio"
114
+ import { studioViewDataSearchOptions } from "@collective-intelligence/extensions-sdk-frontend-react/studio-api"
115
+ import { Card, Progress } from "@collective-intelligence/ui-react/ui"
116
+ import { useQuery } from "@tanstack/react-query"
117
+ ```
118
+
119
+ `/studio-api` is a generated client for the backend operations a widget may call. Studio binds it to the signed-in user's session, so the widget configures no credentials and every request runs with that user's own permissions. Inside Studio and Dashboard the Host provides `react`, `react-dom` and `ui-react`. The CLI keeps `ui-react` external at build, so a widget shares the Host's copy.
120
+
121
+ ## Code that runs in your app
122
+
123
+ `external-apps-client-sdk` is browser-safe and React-free. It handles federated login with `createFederatedAuth` (OAuth authorization code with PKCE) and typed CI operations with `createClient(...).forOrganization(id)`. It holds no confidential credentials. Its `/resources` subpath exports `ResourceDefinition`, the portable contract that both the browser hooks and the BFF read. The template keeps the Lead contract in `@acme/lead/domain`.
124
+
125
+ `external-apps-client-sdk-react` adds `CollectiveIntelligenceProvider`, `CollectiveIntelligenceLoginProvider` and the entity hooks on `/resources`: `useEntityList`, `useEntityRecord`, `useEntityCreate`, `useEntityUpdate` and `useEntityDelete`. A write hook reports `conflict`, `rejected` and `uncertain` as well as `idle`, `pending` and `success`, and `resubmit()` repeats the exact same action when the user asks for it. Install its peers in your app: `react`, `react-dom`, `@tanstack/react-query`, `xstate`, `effect` and `@collective-intelligence/ui-react`.
126
+
127
+ The template's own pages use the template's shadcn/ui package, `@packages/ui-design-system`. `ui-react` appears in the Studio widget and in SDK toasts.
128
+
129
+ ### Server SDK subpaths an external app uses
130
+
131
+ `external-apps-server-sdk` runs only on your server, because it holds the application's client secret. Each framework peer loads only from its own subpath: `/next` loads `next`, while `/effect` loads no `next`, `pg` or `drizzle-orm`. Administrative APIs exist only on `/admin` and never reach the browser proxy. An external app uses four subpaths:
132
+
133
+ | Subpath | What you get |
134
+ | ----------------- | --------------------------------------------------------------------------------------------------------------------------- |
135
+ | `.` | `createServerClient`, for calls from your server to CI with the application's credentials |
136
+ | `/auth/federated` | CI sign-in, the sealed session, token verification and `readApplicationEnrollment` |
137
+ | `/effect` | `layerServerClient` and the Effect `ServerClient` service |
138
+ | `/next` | `createExternalApplicationBffNextHandlers`, `createFixedWorkflowRoute`, `nextInvalidate`, `createRealtimeRevalidateHandler` |
139
+
140
+ The template mounts its whole BFF with one call:
141
+
142
+ ```ts
143
+ handlers: createExternalApplicationBffNextHandlers({
144
+ auth: ci.auth,
145
+ capabilities: { basePath: "/api", tenantUrl: ci.tenantUrl },
146
+ ciResources: {
147
+ bindings: [{ definition: leadContract, schemaFqn: leadSchemaFqn }, ...],
148
+ invalidate: nextInvalidate,
149
+ organizationId: ci.organizationId,
150
+ tenantUrl: ci.tenantUrl,
151
+ },
152
+ publicOrigin: ci.publicOrigin,
153
+ realtime: { ... },
154
+ })
155
+ ```
156
+
157
+ [External apps](external-apps.md) covers sign-in, the BFF and fixed workflow routes in detail.
158
+
159
+ ### CMS SDKs for a self-hosted content system
160
+
161
+ A CMS SDK connects a self-hosted content system to CI. It serves the site's content through a Gateway, and CI reads it with its one built-in Knowledge Gateway connector, so CI needs no code for your content system. A CMS SDK depends on `external-apps-server-sdk` at the exact same version: install no other server SDK version next to it.
162
+
163
+ | Package | Subpath | What you get |
164
+ | ---------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
165
+ | `external-apps-server-sdk-payload` | `.` | `ciPayloadPlugin`, the Payload Plugin that serves the chosen collections and pushes each change |
166
+ | `external-apps-server-sdk-payload` | `/package` | The Payload Package Helpers `payloadGateway`, `payloadKnowledge`, `payloadGatewayPushGrant`, `payloadPageEditor`, `payloadPackageDependencies` and `payloadOperationContract`, for the site's CI package; it loads no Payload module |
167
+ | `external-apps-server-sdk-payload` | `/ci-generate` | The `payload ci-generate` command that the plugin adds; Payload loads it, so you do not import it |
168
+ | `external-apps-server-sdk-strapi` | `.` | `defineStrapiSource` and `defineStrapiGatewayPlugin`, which turn a Strapi Document Service into a Gateway resource |
169
+
170
+ The Payload SDK takes `extensions-sdk` as a peer at the exact version, so the helpers and your CI package share one copy. A hosted service, such as Notion, needs no CMS SDK: CI connects it with a built-in integration package.
171
+
172
+ ## Effect
173
+
174
+ `effect` `^4.1.0` is a required peer of `extensions-sdk`, `extensions-sdk-backend`, both frontend extension packages, the client SDK, the client React SDK, the server SDK and the Payload SDK. The Strapi SDK needs it through the server SDK. The SDKs do not bundle it, so install it in your app and keep one version across the workspace.
175
+
176
+ Effect APIs always come from a `/effect` subpath, and the lint rule `effect-subpath` reports an Effect import from anywhere else.
177
+
178
+ | Package | What `/effect` holds |
179
+ | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
180
+ | `extensions-sdk`, `extensions-sdk-frontend` | Nothing. These packages have no I/O client, so they need no Effect service. |
181
+ | `extensions-sdk-backend` | `effectSchema` and the Effect Dataset Provider ports |
182
+ | `extensions-sdk-frontend-react` | The `StudioApi` service, `fromEffect`, `EffectRuntimeProvider`, `useEffectRuntime` and `QueryCache` for writes in a widget |
183
+ | `external-apps-client-sdk-react` | The Effect bridge for XState machines |
184
+ | `external-apps-server-sdk` | `layerServerClient` and `ServerClient`; `/effect/next` adds the Next layer and `/effect/node-postgres` adds `layerNodePostgres` |
185
+
186
+ Tool schemas use Effect Schema through `effectSchema`. Effect's static types cannot tell whether a schema encodes safely, so `effectSchema(schema)` makes a decoder by default, and an output schema must opt in with `{ codec: true }`:
187
+
188
+ ```ts
189
+ input: effectSchema(leadScoreInputSchema),
190
+ output: effectSchema(leadScoreSchema, { codec: true }),
191
+ ```
192
+
193
+ ## Versions
194
+
195
+ Each package has its own version on npm, and the family has no lockstep release. `extensions-sdk` 0.2.6 and `ui-react` 0.2.6 do not come from the same release. The public SDKs depend on each other at exact versions. Install the set that the template pins, and when you upgrade, take the template's new pins.
196
+
197
+ At the time of writing, the template catalog pins these versions:
198
+
199
+ | Package | Version |
200
+ | -------------------------------- | ------- |
201
+ | `extensions-sdk` | 0.2.6 |
202
+ | `extensions-sdk-backend` | 0.2.7 |
203
+ | `extensions-sdk-frontend` | 0.2.6 |
204
+ | `extensions-sdk-frontend-react` | 0.2.12 |
205
+ | `external-apps-client-sdk` | 0.2.16 |
206
+ | `external-apps-client-sdk-react` | 0.2.25 |
207
+ | `external-apps-server-sdk` | 0.2.21 |
208
+ | `lint` | 0.2.4 |
209
+ | `ui-react` | 0.2.3 |
210
+ | `effect` | 4.1.0 |
211
+
212
+ > **Note:** The release workflow bumps the template pins after each npm release. Copy the
213
+ > catalog from the current template instead of this table.
214
+
215
+ Some names from older examples no longer exist. An old server SDK subpath fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`. The lint rule `effect-subpath` reports the old Effect paths, and `package-entrypoint` reports any subpath that the package does not export.
216
+
217
+ | Old import | Use instead |
218
+ | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
219
+ | `@collective-intelligence/extensions-sdk-backend-effect` | `@collective-intelligence/extensions-sdk-backend/effect`, same export names |
220
+ | `@collective-intelligence/extensions-sdk-backend-zod` | Effect Schema through `effectSchema` from `extensions-sdk-backend/effect` |
221
+ | `external-apps-server-sdk/runtime/effect` | `external-apps-server-sdk/effect` |
222
+ | `external-apps-server-sdk/persistence/drizzle/effect` | `external-apps-server-sdk/effect` plus `/effect/node-postgres` |
223
+ | `external-apps-server-sdk/runtime/next` | `external-apps-server-sdk/next` |
224
+ | `external-apps-server-sdk/knowledge-sources/payload` | `ciPayloadPlugin` from `external-apps-server-sdk-payload`, which serves the site's collections as a Gateway |
225
+ | `external-apps-server-sdk/knowledge-sources/strapi` | `external-apps-server-sdk-strapi`; take the resource types from `external-apps-server-sdk/resources` |
226
+
227
+ The two removed packages stopped at version 0.2.0, and npm marks them deprecated.
228
+
229
+ ## Pick a package
230
+
231
+ | I want to | Use |
232
+ | ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
233
+ | Declare a schema, tool, Agent, workflow, Studio app, group or Access Profile | `extensions-sdk` |
234
+ | Write the code a tool or connector runs inside CI | `extensions-sdk-backend`, with `/effect` for Effect schemas |
235
+ | Render a custom widget in Studio | `extensions-sdk-frontend` for the catalog and `extensions-sdk-frontend-react` (`/studio`, `/studio-api`) |
236
+ | Sign users in with CI and proxy record reads and writes from a Next.js server | `external-apps-server-sdk` (`/auth/federated`, `/next`) |
237
+ | Call CI from server code with the application's credentials | `external-apps-server-sdk` root or `/effect` |
238
+ | Connect a Payload Site to CI | `external-apps-server-sdk-payload`, with `/package` in the site's CI package |
239
+ | Connect a Strapi 5 site to CI | `external-apps-server-sdk-strapi` |
240
+ | Show and edit CI records on a browser page | `external-apps-client-sdk-react` (`/resources`) |
241
+ | Call CI from a browser without React | `external-apps-client-sdk` |
242
+ | Reuse CI design-system components | `ui-react` |
243
+ | Build, deploy, enroll an app or sign in | `cli` |
244
+ | Generate types from package schemas | `ci package codegen`, which wraps `schema-codegen` |
245
+ | Enforce the solution layout | `lint` |
246
+
247
+ ## Related pages
248
+
249
+ - [Extensions](extensions.md)
250
+ - [External apps](external-apps.md)
251
+ - [Template](../template/index.md)
252
+ - [Access](../platform/access.md)
@@ -0,0 +1,83 @@
1
+ # Start here
2
+
3
+ A guide for developers who build customer demos on the Collective Intelligence platform.
4
+
5
+ This guide is for developers who build customer demos on Collective Intelligence (CI). Each demo starts as a new repository generated from the `next-effect-app` solution template, and it ends as a web app that runs against a CI Organization. The pages explain what the platform offers, which parts a demo needs, and how the template puts them together.
6
+
7
+ ## How a demo fits on the platform
8
+
9
+ A demo has two halves that you deploy in different places. The extension package in `apps/extensions` is installed inside CI, where it declares the data, access rules and AI parts that the demo needs. The web app in `apps/web` runs outside CI, and its server calls CI on behalf of the signed-in user.
10
+
11
+ ```mermaid
12
+ flowchart LR
13
+ subgraph repo[Demo repository]
14
+ ext[apps/extensions]
15
+ web[apps/web]
16
+ end
17
+ subgraph ci[CI Organization]
18
+ pkg[Installed package]
19
+ api[CI API]
20
+ end
21
+ ext -- ci deploy --> pkg
22
+ browser[Browser] --> web
23
+ web -- server calls with the user's token --> api
24
+ pkg -. declares schemas, access and AI .-> api
25
+ ```
26
+
27
+ ## From template to running demo
28
+
29
+ 1. Generate a new repository from `next-effect-app` and rename the `@acme` packages. [The solution template](template/index.md) explains the layout you get.
30
+ 2. Choose the primitives for the scenario. [Choosing primitives](scenarios/index.md) maps common demo scenarios to the parts that fit them.
31
+ 3. Declare entities, access and AI parts in the packages' `ci/` folders. The [Data resources](data/index.md), [AI](ai/index.md) and [Grants and permissions](platform/access.md) pages describe each declaration.
32
+ 4. Build the screens and server routes of the web app with the [SDKs](develop/sdks.md), following the patterns in [External apps](develop/external-apps.md).
33
+ 5. Deploy the package to an Organization with `ci deploy`, as [Extensions](develop/extensions.md) describes, and point the web app at that Organization.
34
+
35
+ ## Sections
36
+
37
+ - [Platform](platform/architecture.md): What CI is made of, how people and apps enter it, and how access works.
38
+ - [Data resources](data/index.md): Where data lives: the Data resources Knowledge, Datasets and Documents, and the connectors that fill them.
39
+ - [AI](ai/index.md): Tools, Skills, Agents and workflows, and how they combine.
40
+ - [Build](develop/sdks.md): The SDKs, extension packages and external apps you write.
41
+ - [Template](template/index.md): The layout of `next-effect-app` and its state machine approach.
42
+ - [Scenarios](scenarios/index.md): Criteria for picking the primitives that fit a demo.
43
+
44
+ ## Where to begin
45
+
46
+ If you are starting a new demo, read [Platform architecture](platform/architecture.md) first, then [The solution template](template/index.md), and use [Choosing primitives](scenarios/index.md) to plan the scenario. If you are adding a feature to a demo that already runs, go straight to the page for that part: data questions belong in Data resources, model and automation questions in AI, and code questions in Build.
47
+
48
+ ## For agents
49
+
50
+ Agents can read this guide without a browser. `/llms.txt` lists every page with a link to its Markdown, `/llms-full.txt` returns the whole guide as one file, and each page has a Copy Markdown button and an Open menu for chat assistants. Search answers JSON at `/api/search?query=<terms>`.
51
+
52
+ The same guide ships inside the SDK packages. Every `@collective-intelligence/` SDK that has an `AGENTS.md` also has the guide under `docs/guide/`, so an agent that works in a demo repository finds it in `node_modules` next to the code it calls. To read the SDK source, clone the private mirror with `opensrc`:
53
+
54
+ ```bash
55
+ GITHUB_TOKEN=$(gh auth token) opensrc path collective-intelligence-solutions/sdks
56
+ ```
57
+
58
+ ## Pages
59
+
60
+ - Platform
61
+ - [Platform architecture](platform/architecture.md): The parts of Collective Intelligence, the three integration models, and how a package moves from build to install.
62
+ - [Entrypoints](platform/entrypoints.md): The ways people, apps and agents enter CI at runtime, and the package subpaths that your code imports.
63
+ - [Grants and permissions](platform/access.md): How CI decides what a user, a Group, an app or an API key may do, and how to change it in the template.
64
+ - [Built-in catalog](platform/built-ins.md): Every tool, workflow node, trigger, connector, schema, channel and MCP operation that CI ships, and which ones are already installed in an Organization.
65
+ - Data resources
66
+ - [Data resources](data/index.md): Choose between Knowledge, Datasets and Documents, and see where each kind keeps its data.
67
+ - [Knowledge](data/knowledge.md): Declare schemas, store typed records, query them, and read and watch them from an external app.
68
+ - [Datasets](data/datasets.md): Query typed tables of measurements, events and warehouse data, and control who can read them.
69
+ - [Documents](data/documents.md): Keep files in Document Collections, sync them from Microsoft 365 or Google Drive, control who reads them, and know when their content becomes searchable.
70
+ - [Connectors](data/connectors.md): Connect outside systems, map their fields to Knowledge schemas, and run and watch imports.
71
+ - AI
72
+ - [AI primitives](ai/index.md): Tools, Skills, Agents, workflows and Studio chat, how they compose, and how audiences, approvals, models, runs and timeouts behave.
73
+ - [Studio](ai/studio.md): 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.
74
+ - Build
75
+ - [SDKs](develop/sdks.md): Which @collective-intelligence package to import, from which subpath, with which Effect setup and which versions.
76
+ - [Extensions](develop/extensions.md): What a package declares, how the template wires it, how to deploy it with ci deploy, how to read a failed deploy, and the rules its code runs under.
77
+ - [External apps](develop/external-apps.md): Sign users in with CI, read and write their data through a BFF, cache shared reads and stay live with Realtime.
78
+ - [Infrastructure](develop/infrastructure.md): The resources that a CI deployment runs, what each one is for, and how the Amazon EKS blueprint maps them to AWS services.
79
+ - Template
80
+ - [The solution template](template/index.md): What you get from next-effect-app, where each piece of code goes, and how to take a new demo from local dev to an installed package.
81
+ - [State machines](template/state-machines.md): How next-effect-app models UI flows as XState machines with Effect actors, keeps server data in the QueryCache, resends uncertain writes safely, and checks hard flows with Models.
82
+ - Scenarios
83
+ - [Choosing primitives](scenarios/index.md): Questions, criteria and scenario patterns for picking the CI primitives a demo needs.