@collective-intelligence/ai 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -226,7 +226,7 @@ Your server invokes an Agent with `agents.invoke({ agentId, input })`, which ret
226
226
 
227
227
  For a multi-turn chat, use the shared chat. Start a Conversation with the Agent with `ci.chat.createConversation({ organizationId, payload: { agentId } })`, send each message with `createChatClient(ci, { organizationId }).send({ conversationId, message })` from `@collective-intelligence/external-apps-server-sdk/chat`, and read earlier turns with `ci.chat.getTranscript`. Each turn is an ordinary Agent run, and the earlier successful turns, with their saved Agent Output, become the model's conversation history. A message sent while a turn still runs steers that turn and starts no second turn, and a resend with the same message `id` adds nothing.
228
228
 
229
- `send` resolves `{ ok: true, value, runId }`: `runId` is the id of the turn's run, which the answer message also carries as `metadata.invocationId`, and `turnRunId(message)` reads it from any answer message. `runs.get`, `runs.sources` and `runs.feedback` accept that id like the `runId` of `agents.invoke`. They answer only the caller that owns the Conversation (the member, the app server or the visitor) through the application where the Conversation started, and answer `not_found` to every other caller. As for any run, only a signed-in member reads `runs.sources` and gives `runs.feedback`. `runs.get` gives the status and `result: { message, output? }`, where `output` is the Agent Output that the turn saved. `runs.feedback` also rates a succeeded turn whose answer is only its Agent Output, with the Output's JSON text as the rated answer; a turn with neither text nor Output has no answer to rate and gets `not_found`. The member can also rate and clear the answer with `ci.chat.putAnswerFeedback` and `ci.chat.clearAnswerFeedback` (`params: { invocationId: runId }`); it is the same rating. Each completed Agent turn with an answer to rate (its text or its Agent Output) of `ci.chat.getTranscript` gives that member `feedbackTargetId` (the turn's run id) and `currentUserFeedback`, so the app shows a saved rating again after a reload. `runs.sources` gives the searched Document Versions with their pages and a download link. `runs.stream` and `runs.cancel` read only runs that `agents.invoke` started: follow a turn with `GET /runs/:runId/stream` of the chat mount, and stop it with `ci.chat.cancelTurn`.
229
+ `send` resolves `{ ok: true, value, runId }`: `runId` is the id of the turn's run, which the answer message also carries as `metadata.invocationId`, and `turnRunId(message)` reads it from any answer message. `runs.get`, `runs.stream`, `runs.cancel`, `runs.sources` and `runs.feedback` accept that id like the `runId` of `agents.invoke`. They answer only the caller that owns the Conversation (the member, the app server or the visitor) through the application where the Conversation started, and answer `not_found` to every other caller. As for any run, only a signed-in member reads `runs.sources` and gives `runs.feedback`. `runs.get` gives the status and `result: { message, output? }`, where `output` is the Agent Output that the turn saved. `runs.feedback` also rates a succeeded turn whose answer is only its Agent Output, with the Output's JSON text as the rated answer; a turn with neither text nor Output has no answer to rate and gets `not_found`. The member can also rate and clear the answer with `ci.chat.putAnswerFeedback` and `ci.chat.clearAnswerFeedback` (`params: { invocationId: runId }`); it is the same rating. Each completed Agent turn with an answer to rate (its text or its Agent Output) of `ci.chat.getTranscript` gives that member `feedbackTargetId` (the turn's run id) and `currentUserFeedback`, so the app shows a saved rating again after a reload. `runs.sources` gives the searched Document Versions with their pages and a download link. `runs.stream` pages the turn's events as for `agents.invoke`: `accepted`, the `agent.*` events and the application events that its tools publish, then one terminal event with the `runs.get` result. `runs.cancel` stops the turn. The answer itself streams from `GET /runs/:runId/stream` of the chat mount.
230
230
 
231
231
  Anonymous visitors can chat with an Agent only when its audience has `anonymous: [app]` for that application and the call passes `caller: { kind: "anonymous_visitor", visitor: { issuer, subjectId } }`. Their turns run with the Agent's own bindings, never with the application's grants, and visitors never see each other's conversations.
232
232
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Which @collective-intelligence package to import, from which subpath, with which Effect setup and which versions.
4
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.
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
6
 
7
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
8
 
@@ -38,19 +38,21 @@ The right side is `apps/web`. Its browser code talks to its own server through a
38
38
 
39
39
  ## The packages
40
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 |
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 |
54
56
 
55
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.
56
58
 
@@ -154,9 +156,22 @@ handlers: createExternalApplicationBffNextHandlers({
154
156
 
155
157
  [External apps](external-apps.md) covers sign-in, the BFF and fixed workflow routes in detail.
156
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
+
157
172
  ## Effect
158
173
 
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.
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.
160
175
 
161
176
  Effect APIs always come from a `/effect` subpath, and the lint rule `effect-subpath` reports an Effect import from anywhere else.
162
177
 
@@ -206,7 +221,8 @@ Some names from older examples no longer exist. An old server SDK subpath fails
206
221
  | `external-apps-server-sdk/runtime/effect` | `external-apps-server-sdk/effect` |
207
222
  | `external-apps-server-sdk/persistence/drizzle/effect` | `external-apps-server-sdk/effect` plus `/effect/node-postgres` |
208
223
  | `external-apps-server-sdk/runtime/next` | `external-apps-server-sdk/next` |
209
- | `external-apps-server-sdk/knowledge-sources/payload` | `ciPayloadPlugin` from `external-apps-server-sdk/payload`, which serves the site's collections as a Gateway |
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` |
210
226
 
211
227
  The two removed packages stopped at version 0.2.0, and npm marks them deprecated.
212
228
 
@@ -219,6 +235,8 @@ The two removed packages stopped at version 0.2.0, and npm marks them deprecated
219
235
  | Render a custom widget in Studio | `extensions-sdk-frontend` for the catalog and `extensions-sdk-frontend-react` (`/studio`, `/studio-api`) |
220
236
  | Sign users in with CI and proxy record reads and writes from a Next.js server | `external-apps-server-sdk` (`/auth/federated`, `/next`) |
221
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` |
222
240
  | Show and edit CI records on a browser page | `external-apps-client-sdk-react` (`/resources`) |
223
241
  | Call CI from a browser without React | `external-apps-client-sdk` |
224
242
  | Reuse CI design-system components | `ui-react` |
@@ -256,17 +256,19 @@ Code in the template imports CI packages and its own workspaces by package name
256
256
 
257
257
  The SDKs split by where the code runs. [SDKs](../develop/sdks.md) has the full map; these are the subpaths you meet most.
258
258
 
259
- | Package | Runs | Holds | Main subpaths |
260
- | --------------------------------------------------------- | ------------ | ------------------------------------------------------------------------ | ---------------------------------------------------------- |
261
- | `@collective-intelligence/extensions-sdk` | Inside CI | Declarations such as `declarePackage`, `declareAgent`, `declareWorkflow` | `.`, `./effect` |
262
- | `@collective-intelligence/extensions-sdk-backend` | Inside CI | Contracts for backend tools and connectors | `.`, `./effect` |
263
- | `@collective-intelligence/extensions-sdk-frontend` | Inside CI | Framework-neutral frontend catalog | `.`, `./effect` |
264
- | `@collective-intelligence/extensions-sdk-frontend-react` | Inside CI | React bindings for Studio and Dashboard contributions | `./studio`, `./dashboard`, `./studio-api`, `./effect` |
265
- | `@collective-intelligence/external-apps-server-sdk` | Your server | Server client, BFF, authentication, Gateway | `.`, `./auth/federated`, `./effect`, `./next`, `./gateway` |
266
- | `@collective-intelligence/external-apps-client-sdk` | Your browser | React-free client and Realtime | `.`, `./resources`, `./effect` |
267
- | `@collective-intelligence/external-apps-client-sdk-react` | Your browser | React hooks, including the entity hooks in `./resources` | `.`, `./resources`, `./effect` |
268
-
269
- Every SDK puts its Promise API at the root and its Effect services, Layers, errors and Schemas at `/effect`. `effect` is a required peer of every SDK, so install it next to the SDK and keep one `effect` version in the app. Optional peers such as Next.js, Express, Drizzle, Better Auth and the AI SDK sit behind their own subpaths, so importing the server SDK root never loads them. In the template, `/next` is imported only inside `apps/web/src/server`, because `/next` loads Next.js and `/effect` does not.
259
+ | Package | Runs | Holds | Main subpaths |
260
+ | ----------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------ | ---------------------------------------------------------- |
261
+ | `@collective-intelligence/extensions-sdk` | Inside CI | Declarations such as `declarePackage`, `declareAgent`, `declareWorkflow` | `.`, `./effect` |
262
+ | `@collective-intelligence/extensions-sdk-backend` | Inside CI | Contracts for backend tools and connectors | `.`, `./effect` |
263
+ | `@collective-intelligence/extensions-sdk-frontend` | Inside CI | Framework-neutral frontend catalog | `.`, `./effect` |
264
+ | `@collective-intelligence/extensions-sdk-frontend-react` | Inside CI | React bindings for Studio and Dashboard contributions | `./studio`, `./dashboard`, `./studio-api`, `./effect` |
265
+ | `@collective-intelligence/external-apps-server-sdk` | Your server | Server client, BFF, authentication, Gateway | `.`, `./auth/federated`, `./effect`, `./next`, `./gateway` |
266
+ | `@collective-intelligence/external-apps-server-sdk-payload` | Your Payload Site | Payload Plugin, Payload Package Helpers, `payload ci-generate` | `.`, `./package`, `./ci-generate` |
267
+ | `@collective-intelligence/external-apps-server-sdk-strapi` | Your Strapi 5 site | Strapi 5 adapter that serves documents through a Gateway | `.` |
268
+ | `@collective-intelligence/external-apps-client-sdk` | Your browser | React-free client and Realtime | `.`, `./resources`, `./effect` |
269
+ | `@collective-intelligence/external-apps-client-sdk-react` | Your browser | React hooks, including the entity hooks in `./resources` | `.`, `./resources`, `./effect` |
270
+
271
+ Every SDK puts its Promise API at the root and its Effect services, Layers, errors and Schemas at `/effect`; the two CMS SDKs, the Payload SDK and the Strapi SDK, have no `/effect`. `effect` is a required peer of every SDK (the Strapi SDK gets it through the server SDK), so install it next to the SDK and keep one `effect` version in the app. Optional peers such as Next.js, Express, Drizzle, Better Auth and the AI SDK sit behind their own subpaths, so importing the server SDK root never loads them. In the template, `/next` is imported only inside `apps/web/src/server`, because `/next` loads Next.js and `/effect` does not.
270
272
 
271
273
  ### Template domain parts
272
274
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collective-intelligence/ai",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "The Collective Intelligence AI package: the CI message domain, the chat contract, the chat transports, the headless chat session and the chat views, one subpath per layer.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -58,8 +58,8 @@
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@ai-sdk/react": "^4.0.177",
61
- "@collective-intelligence/effect-xstate": "0.11.0",
62
- "@collective-intelligence/ui-react": "0.11.0",
61
+ "@collective-intelligence/effect-xstate": "0.13.0",
62
+ "@collective-intelligence/ui-react": "0.13.0",
63
63
  "@tanstack/react-query": "^5.101.4",
64
64
  "@xstate/react": "^6.1.0",
65
65
  "ai": ">=7.0.173 <8",
@@ -95,8 +95,8 @@
95
95
  },
96
96
  "devDependencies": {
97
97
  "@ai-sdk/react": "4.0.177",
98
- "@collective-intelligence/effect-xstate": "0.11.0",
99
- "@collective-intelligence/ui-react": "0.11.0",
98
+ "@collective-intelligence/effect-xstate": "0.13.0",
99
+ "@collective-intelligence/ui-react": "0.13.0",
100
100
  "@effect/eslint-plugin": "0.3.2",
101
101
  "@oxlint/plugins": "1.94.0",
102
102
  "@punks/lints": "0.2.0",
@@ -121,5 +121,5 @@
121
121
  "vitest": "5.0.2",
122
122
  "xstate": "5.33.3"
123
123
  },
124
- "gitHead": "8d52a59042026b9044f6e4c49084efbd34868c0c"
124
+ "gitHead": "d3e93c4287307c474b0bf32c386a1471fe67ce2c"
125
125
  }