@collective-intelligence/ai 0.0.0-placeholder.0 → 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.
- package/AGENTS.md +52 -0
- package/README.md +463 -1
- package/dist/api/access-check.d.ts +18 -0
- package/dist/api/answer-sources.d.ts +48 -0
- package/dist/api/attachments-api.d.ts +187 -0
- package/dist/api/catalog-api.d.ts +408 -0
- package/dist/api/chat-api.d.ts +2401 -0
- package/dist/api/chat-surface-api.d.ts +4186 -0
- package/dist/api/compaction.d.ts +52 -0
- package/dist/api/conversations.d.ts +107 -0
- package/dist/api/errors.d.ts +117 -0
- package/dist/api/feedback-api.d.ts +185 -0
- package/dist/api/files.d.ts +22 -0
- package/dist/api/ids.d.ts +33 -0
- package/dist/api/index.d.ts +21 -0
- package/dist/api/intents-api.d.ts +65 -0
- package/dist/api/place-context.d.ts +34 -0
- package/dist/api/projects-api.d.ts +718 -0
- package/dist/api/speech-api.d.ts +345 -0
- package/dist/api/transcript.d.ts +260 -0
- package/dist/api/turns.d.ts +196 -0
- package/dist/api.d.ts +21 -0
- package/dist/api.js +1 -0
- package/dist/domain/access.d.ts +29 -0
- package/dist/domain/context-trail.d.ts +65 -0
- package/dist/domain/data-parts.d.ts +247 -0
- package/dist/domain/errors.d.ts +28 -0
- package/dist/domain/index.d.ts +14 -0
- package/dist/domain/intents.d.ts +101 -0
- package/dist/domain/message.d.ts +173 -0
- package/dist/domain/place.d.ts +17 -0
- package/dist/domain/runtime-value.d.ts +16 -0
- package/dist/domain-50vzrrp9.js +2 -0
- package/dist/domain-5fpd4fte.js +1 -0
- package/dist/domain-9wzbv87n.js +2 -0
- package/dist/domain-g97xs965.js +2 -0
- package/dist/domain-hk3yw2m7.js +1 -0
- package/dist/domain-qyts6dgz.js +0 -0
- package/dist/domain-s07s1ry1.js +2 -0
- package/dist/domain.d.ts +14 -0
- package/dist/domain.js +1 -0
- package/dist/headless/access/access-store.d.ts +28 -0
- package/dist/headless/access/visibility.d.ts +24 -0
- package/dist/headless/blocked-state.d.ts +21 -0
- package/dist/headless/chat-registry.d.ts +63 -0
- package/dist/headless/chat-session-provider.d.ts +109 -0
- package/dist/headless/chat-surface.d.ts +4210 -0
- package/dist/headless/host-ports.d.ts +146 -0
- package/dist/headless/index.d.ts +33 -0
- package/dist/headless/intents/card-ends.d.ts +22 -0
- package/dist/headless/intents/intent-call.d.ts +28 -0
- package/dist/headless/intents/intents-provider.d.ts +108 -0
- package/dist/headless/intents/page-registry.d.ts +129 -0
- package/dist/headless/intents/use-intent-dispatch.d.ts +60 -0
- package/dist/headless/intents/use-intents.d.ts +11 -0
- package/dist/headless/intents/use-returned-intent-handle.d.ts +11 -0
- package/dist/headless/launch/chat-launch.d.ts +42 -0
- package/dist/headless/launch/launch-target.d.ts +25 -0
- package/dist/headless/launch/submit.d.ts +29 -0
- package/dist/headless/run-state.d.ts +16 -0
- package/dist/headless/sent-files.d.ts +20 -0
- package/dist/headless/server-started-turn-follow.proof.d.ts +26 -0
- package/dist/headless/session-machine.d.ts +745 -0
- package/dist/headless/trail/buffer.d.ts +48 -0
- package/dist/headless/trail/json-ld.d.ts +10 -0
- package/dist/headless/trail/switches.d.ts +10 -0
- package/dist/headless/trail/trail-provider.d.ts +53 -0
- package/dist/headless/transcript-messages.d.ts +26 -0
- package/dist/headless.d.ts +33 -0
- package/dist/headless.js +2 -0
- package/dist/transport/chat-client.d.ts +25 -0
- package/dist/transport/chat-transport.d.ts +57 -0
- package/dist/transport/index.d.ts +6 -0
- package/dist/transport/simulated-chat-transport.d.ts +39 -0
- package/dist/transport.d.ts +6 -0
- package/dist/transport.js +1 -0
- package/dist/views/assistant-sidebar/assistant-sidebar.d.ts +15 -0
- package/dist/views/assistant-sidebar/layout.d.ts +47 -0
- package/dist/views/assistant-sidebar/toggle.d.ts +14 -0
- package/dist/views/assistant-sidebar/use-shortcut.d.ts +11 -0
- package/dist/views/blocked/chat-blocked-state.d.ts +15 -0
- package/dist/views/chat-operations.d.ts +46 -0
- package/dist/views/chat-root.d.ts +14 -0
- package/dist/views/chat.d.ts +51 -0
- package/dist/views/composer/capability-picker.d.ts +77 -0
- package/dist/views/composer/capability-pickers.d.ts +24 -0
- package/dist/views/composer/chat-composer.d.ts +15 -0
- package/dist/views/composer/composer-picks.d.ts +31 -0
- package/dist/views/composer/composer-trail.d.ts +21 -0
- package/dist/views/composer/draft-attachments.d.ts +36 -0
- package/dist/views/composer/queued-messages.d.ts +9 -0
- package/dist/views/composer/send-menu.d.ts +11 -0
- package/dist/views/composer/slash-suggestions.d.ts +37 -0
- package/dist/views/composer/trail-chips.d.ts +15 -0
- package/dist/views/composer/voice-input/microphone.d.ts +14 -0
- package/dist/views/composer/voice-input/remote-transcription.d.ts +12 -0
- package/dist/views/composer/voice-input/use-voice-input.d.ts +30 -0
- package/dist/views/composer/voice-input/voice-input.d.ts +15 -0
- package/dist/views/dock/chat-dock.d.ts +57 -0
- package/dist/views/dock/dock-session.d.ts +22 -0
- package/dist/views/header/chat-header.d.ts +10 -0
- package/dist/views/header/compaction-controls.d.ts +17 -0
- package/dist/views/header/memory-switch.d.ts +16 -0
- package/dist/views/index.d.ts +58 -0
- package/dist/views/intents/form-fields.d.ts +38 -0
- package/dist/views/intents/intent-card.d.ts +61 -0
- package/dist/views/intents/intent-form.d.ts +23 -0
- package/dist/views/intents/intent-notices.d.ts +39 -0
- package/dist/views/intents/intent-trigger.d.ts +46 -0
- package/dist/views/intents/labels.d.ts +23 -0
- package/dist/views/labels/en.d.ts +3 -0
- package/dist/views/labels/index.d.ts +13 -0
- package/dist/views/labels/it.d.ts +3 -0
- package/dist/views/labels/types.d.ts +7 -0
- package/dist/views/launch/chat-launch-button.d.ts +21 -0
- package/dist/views/parts/answer-feedback.d.ts +26 -0
- package/dist/views/parts/evidence-part.d.ts +8 -0
- package/dist/views/parts/file-part.d.ts +8 -0
- package/dist/views/parts/image-generation-part.d.ts +9 -0
- package/dist/views/parts/image-generation.d.ts +84 -0
- package/dist/views/parts/intent-card-part.d.ts +8 -0
- package/dist/views/parts/memory-evidence-part.d.ts +7 -0
- package/dist/views/parts/message-parts.d.ts +21 -0
- package/dist/views/parts/question-part.d.ts +8 -0
- package/dist/views/parts/read-aloud.d.ts +23 -0
- package/dist/views/parts/reasoning-part.d.ts +8 -0
- package/dist/views/parts/steering-message-part.d.ts +7 -0
- package/dist/views/parts/text-part.d.ts +4 -0
- package/dist/views/parts/tool-part.d.ts +11 -0
- package/dist/views/parts/types.d.ts +103 -0
- package/dist/views/parts/use-read-aloud.d.ts +13 -0
- package/dist/views/run-trace/message-run.d.ts +17 -0
- package/dist/views/run-trace/run-stream.d.ts +128 -0
- package/dist/views/run-trace/run-trace-parts.d.ts +26 -0
- package/dist/views/run-trace/run-trace.d.ts +31 -0
- package/dist/views/sidebar/conversation-dialogs.d.ts +38 -0
- package/dist/views/sidebar/conversation-row.d.ts +23 -0
- package/dist/views/sidebar/conversation-sidebar.d.ts +10 -0
- package/dist/views/sidebar/date-groups.d.ts +12 -0
- package/dist/views/sidebar/history-filter.d.ts +57 -0
- package/dist/views/sidebar/projects/project-dialogs.d.ts +40 -0
- package/dist/views/sidebar/projects/project-files.d.ts +16 -0
- package/dist/views/sidebar/projects/project-groups.d.ts +19 -0
- package/dist/views/sidebar/projects/project-view.d.ts +21 -0
- package/dist/views/sidebar/projects/projects-section.d.ts +21 -0
- package/dist/views/sidebar/projects/use-chat-projects.d.ts +32 -0
- package/dist/views/slots.d.ts +148 -0
- package/dist/views/transcript/chat-transcript.d.ts +13 -0
- package/dist/views/transcript/sent-trail.d.ts +13 -0
- package/dist/views/transcript/use-image-reload.d.ts +16 -0
- package/dist/views.d.ts +58 -0
- package/dist/views.js +3 -0
- package/docs/guide/ai/index.md +377 -0
- package/docs/guide/ai/studio.md +245 -0
- package/docs/guide/data/connectors.md +267 -0
- package/docs/guide/data/datasets.md +145 -0
- package/docs/guide/data/documents.md +235 -0
- package/docs/guide/data/index.md +62 -0
- package/docs/guide/data/knowledge.md +214 -0
- package/docs/guide/develop/extensions.md +299 -0
- package/docs/guide/develop/external-apps.md +279 -0
- package/docs/guide/develop/infrastructure.md +135 -0
- package/docs/guide/develop/sdks.md +233 -0
- package/docs/guide/index.md +83 -0
- package/docs/guide/platform/access.md +311 -0
- package/docs/guide/platform/architecture.md +166 -0
- package/docs/guide/platform/built-ins.md +225 -0
- package/docs/guide/platform/entrypoints.md +318 -0
- package/docs/guide/scenarios/index.md +130 -0
- package/docs/guide/template/index.md +295 -0
- package/docs/guide/template/state-machines.md +294 -0
- package/package.json +120 -4
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Infrastructure
|
|
2
|
+
|
|
3
|
+
The resources that a CI deployment runs, what each one is for, and how the Amazon EKS blueprint maps them to AWS services.
|
|
4
|
+
|
|
5
|
+
The CI deployment that your demo connects to provides every resource on this page. You do not provision or run any of them. This page explains what runs where, so that you know what sits behind the API when your package or your web app calls CI. The [Platform architecture](../platform/architecture.md) page introduces the same parts from the builder's side.
|
|
6
|
+
|
|
7
|
+
## Runtime resources
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
flowchart LR
|
|
11
|
+
subgraph outside["Outside the CI deployment"]
|
|
12
|
+
browser["Browser"]
|
|
13
|
+
studio["Studio desktop app"]
|
|
14
|
+
webapp["Your web app (BFF)"]
|
|
15
|
+
end
|
|
16
|
+
subgraph deployment["CI deployment"]
|
|
17
|
+
gateway["Gateway"]
|
|
18
|
+
dashboard["Dashboard and Studio install page"]
|
|
19
|
+
api["Backend API"]
|
|
20
|
+
workers["Background and interactive workers"]
|
|
21
|
+
compute["Compute"]
|
|
22
|
+
media["Media"]
|
|
23
|
+
pg[("PostgreSQL with pgvector")]
|
|
24
|
+
broker["Message broker"]
|
|
25
|
+
storage[("Object storage")]
|
|
26
|
+
end
|
|
27
|
+
ai["AI model providers"]
|
|
28
|
+
browser --> gateway
|
|
29
|
+
studio --> gateway
|
|
30
|
+
webapp -->|"Application API"| gateway
|
|
31
|
+
gateway --> dashboard
|
|
32
|
+
gateway --> api
|
|
33
|
+
gateway --> media
|
|
34
|
+
api --> pg
|
|
35
|
+
workers --> pg
|
|
36
|
+
api -->|"wake signals"| broker
|
|
37
|
+
broker --> workers
|
|
38
|
+
broker -->|"Compute jobs"| compute
|
|
39
|
+
compute -->|"results"| api
|
|
40
|
+
compute -->|"presigned URLs"| storage
|
|
41
|
+
browser -->|"signed upload"| storage
|
|
42
|
+
media -->|"signed source links"| storage
|
|
43
|
+
workers --> ai
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
| Resource | What it is for |
|
|
47
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
48
|
+
| Gateway | Receives all HTTP traffic and routes it to the Dashboard, the backend API and Media. |
|
|
49
|
+
| Dashboard | A static web app that calls the backend API for all its data. It also serves the public Studio install page of each Organization, where people download Studio and connect it with one button. |
|
|
50
|
+
| Backend API | Serves every HTTP route that the Dashboard, Studio, the CLI and your app call. It stores long work and returns at once; workers run that work. |
|
|
51
|
+
| Workers | Background workers run long jobs, and interactive workers run the agent and tool work that users wait for. |
|
|
52
|
+
| Compute | Runs transcription, transcoding and conversion from a queue. Each capability has its own slots, so a long transcode does not block transcription. |
|
|
53
|
+
| Media | Serves file bytes and image transforms from URLs that the backend signs. No file byte passes through a backend endpoint. |
|
|
54
|
+
| PostgreSQL | Holds the authoritative data in two databases: one for application data, Knowledge and queued work, and one for datasets. The pgvector extension stores embeddings for semantic search. |
|
|
55
|
+
| Message broker | Carries wake signals from the API to the workers, broadcast events between backend processes, and the job queues of Compute. A wake signal is only a hint: workers find their work in PostgreSQL. |
|
|
56
|
+
| Object storage | Holds every file. Studio installers and updates, and archived rows, have their own stores next to the store for application files. |
|
|
57
|
+
| Cache | There is no separate cache service. Each backend process keeps hot reads, such as schemas, policies and settings, in memory, and broadcast events clear stale entries in every process. |
|
|
58
|
+
| Email provider | Sends platform email. Every message goes through a durable queue in PostgreSQL before the provider receives it. |
|
|
59
|
+
| AI model providers | External model services that agents, Skills and embeddings call. A Tenant admin chooses the available models; the blueprints do not provision them. |
|
|
60
|
+
| Logs | Every backend process and Compute write structured logs, and the CI deployment forwards them to a log service. |
|
|
61
|
+
|
|
62
|
+
## What this means for your code
|
|
63
|
+
|
|
64
|
+
File uploads go straight from the browser to object storage. Your BFF asks CI for an upload slot, and the browser sends the bytes with one signed PUT. A Knowledge file field accepts a file up to its `maxBytes`, and never above the limit of the CI deployment, which is 1 GiB by default and at most 2 GiB. The browser must send the URL, the method and every header that CI returns. Your BFF never streams file bytes. The [External apps](external-apps.md) page shows the flow in the template.
|
|
65
|
+
|
|
66
|
+
Event streams, such as a chat answer, stay open through a heartbeat. The gateway closes a request that sends no bytes for 120 seconds and caps every response at 10 minutes. The backend sends a comment line on every event stream each 20 seconds, so a slow model does not cut the stream. If your BFF forwards a stream, pass each chunk on as it arrives so the heartbeat reaches the browser.
|
|
67
|
+
|
|
68
|
+
Long work is asynchronous. When your app starts an agent run or a workflow, the API stores the run and returns, and a worker runs it. A slow broker delays work, because workers always read their work from PostgreSQL.
|
|
69
|
+
|
|
70
|
+
Configuration changes reach every backend process. When a schema, a policy or a setting changes, a broadcast event clears the cached copy in each process after the write commits. If that event is lost, the cached copy still expires after a short time limit.
|
|
71
|
+
|
|
72
|
+
## The Amazon EKS blueprint
|
|
73
|
+
|
|
74
|
+
A blueprint is the infrastructure code and the deployment configuration that turn the resources above into cloud services. Running CI deployments use the Amazon Elastic Kubernetes Service (EKS) blueprint. Blueprints also exist for Azure Kubernetes Service (AKS) and Azure Container Apps (ACA).
|
|
75
|
+
|
|
76
|
+
The EKS blueprint has three layers. Infrastructure as code creates the AWS foundation: the network, the cluster, the image registry, DNS, and the managed databases and buckets of each CI deployment. Helm charts describe the workloads, and Argo CD keeps the cluster in line with them. Release pins name the exact image of each service, so a new CI release is a change of pins that Argo CD rolls out.
|
|
77
|
+
|
|
78
|
+
```mermaid
|
|
79
|
+
flowchart LR
|
|
80
|
+
users["Browser, Studio and your web app"]
|
|
81
|
+
cdn["Amazon CloudFront"]
|
|
82
|
+
nlb["Network Load Balancer"]
|
|
83
|
+
subgraph eks["Amazon EKS cluster"]
|
|
84
|
+
gateway["Envoy Gateway"]
|
|
85
|
+
dashboard["Dashboard"]
|
|
86
|
+
api["Backend API"]
|
|
87
|
+
workers["Workers"]
|
|
88
|
+
compute["Compute"]
|
|
89
|
+
media["Media"]
|
|
90
|
+
rabbit["RabbitMQ"]
|
|
91
|
+
end
|
|
92
|
+
rds[("Amazon RDS for PostgreSQL or CloudNativePG")]
|
|
93
|
+
s3[("Amazon S3")]
|
|
94
|
+
ses["Amazon SES"]
|
|
95
|
+
secrets["AWS Secrets Manager"]
|
|
96
|
+
ecr["Amazon ECR"]
|
|
97
|
+
users --> nlb
|
|
98
|
+
users -->|"media URLs"| cdn
|
|
99
|
+
cdn --> nlb
|
|
100
|
+
nlb --> gateway
|
|
101
|
+
gateway --> dashboard
|
|
102
|
+
gateway --> api
|
|
103
|
+
gateway --> media
|
|
104
|
+
api --> rds
|
|
105
|
+
workers --> rds
|
|
106
|
+
api --> rabbit
|
|
107
|
+
rabbit --> workers
|
|
108
|
+
rabbit --> compute
|
|
109
|
+
compute --> s3
|
|
110
|
+
media --> s3
|
|
111
|
+
eks -->|"email"| ses
|
|
112
|
+
secrets -.->|"credentials"| eks
|
|
113
|
+
ecr -.->|"images"| eks
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
| Resource | AWS service |
|
|
117
|
+
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
118
|
+
| Containers | Amazon EKS with a managed node group. Images come from Amazon Elastic Container Registry (ECR). |
|
|
119
|
+
| Gateway | Envoy Gateway behind a Network Load Balancer. Amazon Route 53 holds the DNS records, and cert-manager issues the certificates. |
|
|
120
|
+
| PostgreSQL | Amazon Relational Database Service (RDS) for PostgreSQL in private subnets, or CloudNativePG in the cluster on encrypted Amazon Elastic Block Store (EBS) volumes. Each CI deployment chooses one. |
|
|
121
|
+
| Message broker | RabbitMQ in the cluster. |
|
|
122
|
+
| Object storage | Amazon Simple Storage Service (S3) buckets for the files and the archive of each CI deployment, and shared buckets for Studio releases. |
|
|
123
|
+
| Media CDN | Amazon CloudFront in front of Media. |
|
|
124
|
+
| Email | Amazon Simple Email Service (SES). |
|
|
125
|
+
| Secrets | AWS Secrets Manager. External Secrets copies the values into the cluster. |
|
|
126
|
+
| Workload identity | EKS Pod Identity, so pods reach S3 and Secrets Manager without stored keys. |
|
|
127
|
+
| Logs and metrics | Datadog receives the logs. Amazon CloudWatch Container Insights collects the cluster metrics. |
|
|
128
|
+
|
|
129
|
+
One EKS cluster can host several CI deployments. Each CI deployment has its own Kubernetes namespace with its own backend, Compute, database, message broker and storage, and it can hold several Organizations. All CI deployments on the cluster share the gateway and Media.
|
|
130
|
+
|
|
131
|
+
## Next pages
|
|
132
|
+
|
|
133
|
+
- [Platform architecture](../platform/architecture.md): Tenants, Organizations, surfaces and the three integration models.
|
|
134
|
+
- [External apps](external-apps.md): Build the web app that calls CI, including direct uploads.
|
|
135
|
+
- [Knowledge](../data/knowledge.md): Records, schemas and semantic search on PostgreSQL.
|
|
@@ -0,0 +1,233 @@
|
|
|
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.
|
|
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/ui-react` | Both sides | `/ui`, `/resources`, `/icons`, `/hooks`, `/tokens/theme` | CI design-system components that take display-ready props |
|
|
51
|
+
| `@collective-intelligence/cli` | Your machine or pipeline | `ci` binary | Sign in, build and deploy packages, enroll an app |
|
|
52
|
+
| `@collective-intelligence/lint` | Development | `recommended` | Oxlint rules that keep the solution layout and Effect imports correct |
|
|
53
|
+
| `@collective-intelligence/schema-codegen` | Development | `.` | Generate TypeScript, Zod or Effect Schema source from package schemas |
|
|
54
|
+
|
|
55
|
+
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.
|
|
56
|
+
|
|
57
|
+
The `ci` binary runs on Bun. Install it globally and keep it current with `ci upgrade`:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm install -g @collective-intelligence/cli
|
|
61
|
+
ci login <api-url> --organization <organization-id>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`@collective-intelligence/lint` needs `oxlint` 1.82.0 or later:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { recommended } from "@collective-intelligence/lint"
|
|
68
|
+
import { defineConfig } from "oxlint"
|
|
69
|
+
export default defineConfig({ extends: [recommended] })
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Code that runs inside CI
|
|
73
|
+
|
|
74
|
+
### Declarations with `extensions-sdk`
|
|
75
|
+
|
|
76
|
+
`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.
|
|
77
|
+
|
|
78
|
+
### Backend code with `extensions-sdk-backend`
|
|
79
|
+
|
|
80
|
+
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:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import {
|
|
84
|
+
PackageTool,
|
|
85
|
+
type PackageRuntimeContext
|
|
86
|
+
} from "@collective-intelligence/extensions-sdk-backend"
|
|
87
|
+
|
|
88
|
+
export class EchoTool extends PackageTool<{ text: string }, string> {
|
|
89
|
+
execute(
|
|
90
|
+
input: { text: string },
|
|
91
|
+
_context: PackageRuntimeContext
|
|
92
|
+
): PromiseLike<string> {
|
|
93
|
+
return Promise.resolve(input.text)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
> **Warning:** One Worker serves every Organization that invokes the same package release,
|
|
99
|
+
> and several calls can run at the same time. Read the Organization,
|
|
100
|
+
> capabilities and configuration only from the per-call `context`, and never
|
|
101
|
+
> keep tenant data in module-level variables.
|
|
102
|
+
> [Extensions](extensions.md) describes the other runtime rules.
|
|
103
|
+
|
|
104
|
+
### Studio widgets with `extensions-sdk-frontend` and `extensions-sdk-frontend-react`
|
|
105
|
+
|
|
106
|
+
`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.
|
|
107
|
+
|
|
108
|
+
`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:
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import { studioViewScope } from "@collective-intelligence/extensions-sdk-frontend-react/studio"
|
|
112
|
+
import { studioViewDataSearchOptions } from "@collective-intelligence/extensions-sdk-frontend-react/studio-api"
|
|
113
|
+
import { Card, Progress } from "@collective-intelligence/ui-react/ui"
|
|
114
|
+
import { useQuery } from "@tanstack/react-query"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`/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.
|
|
118
|
+
|
|
119
|
+
## Code that runs in your app
|
|
120
|
+
|
|
121
|
+
`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`.
|
|
122
|
+
|
|
123
|
+
`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`.
|
|
124
|
+
|
|
125
|
+
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.
|
|
126
|
+
|
|
127
|
+
### Server SDK subpaths an external app uses
|
|
128
|
+
|
|
129
|
+
`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:
|
|
130
|
+
|
|
131
|
+
| Subpath | What you get |
|
|
132
|
+
| ----------------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
133
|
+
| `.` | `createServerClient`, for calls from your server to CI with the application's credentials |
|
|
134
|
+
| `/auth/federated` | CI sign-in, the sealed session, token verification and `readApplicationEnrollment` |
|
|
135
|
+
| `/effect` | `layerServerClient` and the Effect `ServerClient` service |
|
|
136
|
+
| `/next` | `createExternalApplicationBffNextHandlers`, `createFixedWorkflowRoute`, `nextInvalidate`, `createRealtimeRevalidateHandler` |
|
|
137
|
+
|
|
138
|
+
The template mounts its whole BFF with one call:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
handlers: createExternalApplicationBffNextHandlers({
|
|
142
|
+
auth: ci.auth,
|
|
143
|
+
capabilities: { basePath: "/api", tenantUrl: ci.tenantUrl },
|
|
144
|
+
ciResources: {
|
|
145
|
+
bindings: [{ definition: leadContract, schemaFqn: leadSchemaFqn }, ...],
|
|
146
|
+
invalidate: nextInvalidate,
|
|
147
|
+
organizationId: ci.organizationId,
|
|
148
|
+
tenantUrl: ci.tenantUrl,
|
|
149
|
+
},
|
|
150
|
+
publicOrigin: ci.publicOrigin,
|
|
151
|
+
realtime: { ... },
|
|
152
|
+
})
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
[External apps](external-apps.md) covers sign-in, the BFF and fixed workflow routes in detail.
|
|
156
|
+
|
|
157
|
+
## Effect
|
|
158
|
+
|
|
159
|
+
`effect` `^4.1.0` is a required peer of `extensions-sdk`, `extensions-sdk-backend`, both frontend extension packages and the three `external-apps-*` packages. The SDKs do not bundle it, so install it in your app and keep one version across the workspace.
|
|
160
|
+
|
|
161
|
+
Effect APIs always come from a `/effect` subpath, and the lint rule `effect-subpath` reports an Effect import from anywhere else.
|
|
162
|
+
|
|
163
|
+
| Package | What `/effect` holds |
|
|
164
|
+
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
165
|
+
| `extensions-sdk`, `extensions-sdk-frontend` | Nothing. These packages have no I/O client, so they need no Effect service. |
|
|
166
|
+
| `extensions-sdk-backend` | `effectSchema` and the Effect Dataset Provider ports |
|
|
167
|
+
| `extensions-sdk-frontend-react` | The `StudioApi` service, `fromEffect`, `EffectRuntimeProvider`, `useEffectRuntime` and `QueryCache` for writes in a widget |
|
|
168
|
+
| `external-apps-client-sdk-react` | The Effect bridge for XState machines |
|
|
169
|
+
| `external-apps-server-sdk` | `layerServerClient` and `ServerClient`; `/effect/next` adds the Next layer and `/effect/node-postgres` adds `layerNodePostgres` |
|
|
170
|
+
|
|
171
|
+
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 }`:
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
input: effectSchema(leadScoreInputSchema),
|
|
175
|
+
output: effectSchema(leadScoreSchema, { codec: true }),
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Versions
|
|
179
|
+
|
|
180
|
+
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.
|
|
181
|
+
|
|
182
|
+
At the time of writing, the template catalog pins these versions:
|
|
183
|
+
|
|
184
|
+
| Package | Version |
|
|
185
|
+
| -------------------------------- | ------- |
|
|
186
|
+
| `extensions-sdk` | 0.2.6 |
|
|
187
|
+
| `extensions-sdk-backend` | 0.2.7 |
|
|
188
|
+
| `extensions-sdk-frontend` | 0.2.6 |
|
|
189
|
+
| `extensions-sdk-frontend-react` | 0.2.12 |
|
|
190
|
+
| `external-apps-client-sdk` | 0.2.16 |
|
|
191
|
+
| `external-apps-client-sdk-react` | 0.2.25 |
|
|
192
|
+
| `external-apps-server-sdk` | 0.2.21 |
|
|
193
|
+
| `lint` | 0.2.4 |
|
|
194
|
+
| `ui-react` | 0.2.3 |
|
|
195
|
+
| `effect` | 4.1.0 |
|
|
196
|
+
|
|
197
|
+
> **Note:** The release workflow bumps the template pins after each npm release. Copy the
|
|
198
|
+
> catalog from the current template instead of this table.
|
|
199
|
+
|
|
200
|
+
Some names from older examples no longer exist. An old server SDK subpath fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`, and the lint rule `effect-subpath` reports it.
|
|
201
|
+
|
|
202
|
+
| Old import | Use instead |
|
|
203
|
+
| -------------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
204
|
+
| `@collective-intelligence/extensions-sdk-backend-effect` | `@collective-intelligence/extensions-sdk-backend/effect`, same export names |
|
|
205
|
+
| `@collective-intelligence/extensions-sdk-backend-zod` | Effect Schema through `effectSchema` from `extensions-sdk-backend/effect` |
|
|
206
|
+
| `external-apps-server-sdk/runtime/effect` | `external-apps-server-sdk/effect` |
|
|
207
|
+
| `external-apps-server-sdk/persistence/drizzle/effect` | `external-apps-server-sdk/effect` plus `/effect/node-postgres` |
|
|
208
|
+
| `external-apps-server-sdk/runtime/next` | `external-apps-server-sdk/next` |
|
|
209
|
+
|
|
210
|
+
The two removed packages stopped at version 0.2.0, and npm marks them deprecated.
|
|
211
|
+
|
|
212
|
+
## Pick a package
|
|
213
|
+
|
|
214
|
+
| I want to | Use |
|
|
215
|
+
| ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
216
|
+
| Declare a schema, tool, Agent, workflow, Studio app, group or Access Profile | `extensions-sdk` |
|
|
217
|
+
| Write the code a tool or connector runs inside CI | `extensions-sdk-backend`, with `/effect` for Effect schemas |
|
|
218
|
+
| Render a custom widget in Studio | `extensions-sdk-frontend` for the catalog and `extensions-sdk-frontend-react` (`/studio`, `/studio-api`) |
|
|
219
|
+
| Sign users in with CI and proxy record reads and writes from a Next.js server | `external-apps-server-sdk` (`/auth/federated`, `/next`) |
|
|
220
|
+
| Call CI from server code with the application's credentials | `external-apps-server-sdk` root or `/effect` |
|
|
221
|
+
| Show and edit CI records on a browser page | `external-apps-client-sdk-react` (`/resources`) |
|
|
222
|
+
| Call CI from a browser without React | `external-apps-client-sdk` |
|
|
223
|
+
| Reuse CI design-system components | `ui-react` |
|
|
224
|
+
| Build, deploy, enroll an app or sign in | `cli` |
|
|
225
|
+
| Generate types from package schemas | `ci package codegen`, which wraps `schema-codegen` |
|
|
226
|
+
| Enforce the solution layout | `lint` |
|
|
227
|
+
|
|
228
|
+
## Related pages
|
|
229
|
+
|
|
230
|
+
- [Extensions](extensions.md)
|
|
231
|
+
- [External apps](external-apps.md)
|
|
232
|
+
- [Template](../template/index.md)
|
|
233
|
+
- [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.
|