@collective-intelligence/ai 0.0.0-stage → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +52 -0
- package/README.md +462 -2
- 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 +123 -4
package/AGENTS.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# `@collective-intelligence/ai`: agent guide
|
|
2
|
+
|
|
3
|
+
The AI package of Collective Intelligence (CI), one subpath per layer:
|
|
4
|
+
`./domain` (the CI message type, its Data Parts and schemas, `Place`, the
|
|
5
|
+
Intent types, errors and value helpers), `./api` (the chat contract and
|
|
6
|
+
`IntentsApi`), `./transport` (the chat transports), `./headless` (the chat
|
|
7
|
+
session, `IntentsProvider` and their hooks) and `./views` (the chat views and
|
|
8
|
+
the Intent controls). There is no root entry. The package `README.md` holds the full
|
|
9
|
+
API.
|
|
10
|
+
|
|
11
|
+
## Rules
|
|
12
|
+
|
|
13
|
+
- Install the required peers `ai` (`>=7.0.173 <8`) and `effect`. Install the
|
|
14
|
+
React peers only when you import `./headless` or `./views`.
|
|
15
|
+
- Import `./domain`, `./api` and `./transport` in server code: they import no
|
|
16
|
+
React. Import `./headless` and `./views` only in client components.
|
|
17
|
+
- Type every chat message as `CiUIMessage`, and give each AI SDK `Chat`
|
|
18
|
+
`dataPartSchemas: ciDataPartSchemas` and
|
|
19
|
+
`messageMetadataSchema: ciMessageMetadataSchema`.
|
|
20
|
+
- Branch on the `kind` of a `data-evidence` part (`table`, `sources`, `links`,
|
|
21
|
+
`summary`, `warnings`, `json`, `image`) and of a `data-run-status` part
|
|
22
|
+
(`next_turn`, `running_turn`).
|
|
23
|
+
- Answer a `ci_ask_user` tool part with `addToolOutput`, giving a
|
|
24
|
+
`CiAskUserOutput`: `{ kind: "option", optionId }` or
|
|
25
|
+
`{ kind: "free_text", text }`.
|
|
26
|
+
- Name a Place by `{ kind, id }` with `kind` one of `placeKinds`
|
|
27
|
+
(`studio_app`, `external_app`, `dashboard`).
|
|
28
|
+
- Branch on `AiError.code` (one of the eight `aiErrorCodes`) and `reason`, not
|
|
29
|
+
on `message`.
|
|
30
|
+
- Render `<Chat>` inside a `ChatSessionProvider` of the same Place, keyed by
|
|
31
|
+
the Place and the signed-in user. Give `<ChatDock>` and a `<RunTrace>`
|
|
32
|
+
outside a provider their own `api`.
|
|
33
|
+
- Dock the shared chat of an app with `AssistantSidebarLayout`, its
|
|
34
|
+
`AssistantSidebar` inside a `ChatSessionProvider` and an
|
|
35
|
+
`AssistantSidebarToggle`; pass the host `sessions` port so the open state
|
|
36
|
+
survives a page change. Use `ChatLaunchButton` for an "Ask AI" control.
|
|
37
|
+
- Render the Intent controls (`IntentTrigger`, `IntentForm`,
|
|
38
|
+
`VisibilityGate`) inside one `IntentsProvider` with an `IntentsApi`
|
|
39
|
+
adapter, and render one `IntentNotices` inside it. They need no chat and no
|
|
40
|
+
`ChatSessionProvider`; without an `IntentsApi` they render nothing.
|
|
41
|
+
- Theme the views from the host app: its Tailwind v4 stylesheet imports
|
|
42
|
+
`@collective-intelligence/ui-react/shadcn.css`, adds `@source` lines for
|
|
43
|
+
`@collective-intelligence/ai/dist` and `streamdown/dist/*.js`, sets the
|
|
44
|
+
shadcn and `--brand*` tokens on `:root` and their dark values on `.dark`.
|
|
45
|
+
- Port code that imports `@collective-intelligence/ai-core` or `ai-react`
|
|
46
|
+
with the old-to-new table in the README section "Migrating from ai-core and
|
|
47
|
+
ai-react".
|
|
48
|
+
|
|
49
|
+
## Platform guide
|
|
50
|
+
|
|
51
|
+
- [docs/guide/index.md](docs/guide/index.md): read before choosing CI primitives for a solution or demo, or when a task needs the platform model (architecture, access, data, AI, template).
|
|
52
|
+
- [docs/guide/platform/built-ins.md](docs/guide/platform/built-ins.md): read before declaring a tool, workflow node, trigger, connector, connection, schema or notification channel, to reuse the `builtin.` FQN that CI already ships and to check which built-in packages an Organization has installed.
|
package/README.md
CHANGED
|
@@ -1,3 +1,463 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @collective-intelligence/ai
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The AI package of Collective Intelligence (CI). One package, one subpath per
|
|
4
|
+
layer, and no root entry. Each layer imports only the layers below it:
|
|
5
|
+
|
|
6
|
+
| Subpath | Layer |
|
|
7
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
8
|
+
| `@collective-intelligence/ai/domain` | The CI message type, its Data Parts and schemas, `Place`, the typed errors and values |
|
|
9
|
+
| `@collective-intelligence/ai/api` | The chat contract |
|
|
10
|
+
| `@collective-intelligence/ai/transport` | The chat transports |
|
|
11
|
+
| `@collective-intelligence/ai/headless` | The chat session and its React hooks (`"use client"`) |
|
|
12
|
+
| `@collective-intelligence/ai/views` | The chat views (`"use client"`) |
|
|
13
|
+
|
|
14
|
+
`./domain`, `./api` and `./transport` import no React, `@ai-sdk/react` or
|
|
15
|
+
`xstate`, so a server can use them.
|
|
16
|
+
|
|
17
|
+
The package replaces `@collective-intelligence/ai-core` and
|
|
18
|
+
`@collective-intelligence/ai-react`; see
|
|
19
|
+
[Migrating from ai-core and ai-react](#migrating-from-ai-core-and-ai-react).
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
The package has no runtime dependency. Install its required peers `ai`
|
|
24
|
+
(`>=7.0.173 <8`) and `effect` (`^4.1.0`). The React layers also need the
|
|
25
|
+
optional peers `react`, `@ai-sdk/react`, `xstate`, `@xstate/react`,
|
|
26
|
+
`@collective-intelligence/effect-xstate`, `@tanstack/react-query` and
|
|
27
|
+
`@collective-intelligence/ui-react`. Install the two
|
|
28
|
+
`@collective-intelligence` peers of the same release as this package; every
|
|
29
|
+
public CI package ships at one version.
|
|
30
|
+
|
|
31
|
+
## The CI message
|
|
32
|
+
|
|
33
|
+
`CiUIMessage` is the AI SDK `UIMessage` of every CI chat:
|
|
34
|
+
`UIMessage<CiMessageMetadata, CiDataParts, CiTools>`.
|
|
35
|
+
|
|
36
|
+
- Data Parts: `data-draft-update` (new values for fields of one Dashboard
|
|
37
|
+
draft), `data-evidence` (the evidence of one tool result: `table`, `sources`,
|
|
38
|
+
`links`, `summary`, `warnings`, `json` or `image`), `data-memory-evidence`
|
|
39
|
+
(what the turn did with memories) and `data-run-status` (the turn that the
|
|
40
|
+
chat follows next).
|
|
41
|
+
- Metadata: `createdAt`, `feedbackTargetId`, `invocationId`, `traceLink` and,
|
|
42
|
+
on a user message, `turnOptions` (`CiTurnOptions`: `attachmentIds`,
|
|
43
|
+
`selectedCapabilities`, `directTool`, `selectedReportRunId`), each optional.
|
|
44
|
+
The chat send carries only the last message, so a turn's choices travel in
|
|
45
|
+
its user message.
|
|
46
|
+
- File parts: a user message shows each of its chat attachments as an AI
|
|
47
|
+
SDK `file` part (`filename`, `mediaType`, `url`) before its text. A
|
|
48
|
+
reloaded message shows the file through its Authorized Media URL (the
|
|
49
|
+
transcript's `mediaUrl`), and a sent message through an object URL of the
|
|
50
|
+
user's file until the chat reads the saved message. A file that storage
|
|
51
|
+
removed keeps its name with an empty `url`. The server reads the files of a
|
|
52
|
+
turn from `turnOptions.attachmentIds`, never from the file parts.
|
|
53
|
+
- Tools: `ci_ask_user` (`ciAskUserToolName`) is the question that the client
|
|
54
|
+
answers with `addToolOutput`. Any other tool asks for approval through the AI
|
|
55
|
+
SDK `needsApproval`.
|
|
56
|
+
|
|
57
|
+
`ciDataPartSchemas`, `ciMessageMetadataSchema` and `ciAskUserSchemas` hold the
|
|
58
|
+
schemas. Each is an Effect schema made a Standard Schema through
|
|
59
|
+
`Schema.toStandardSchemaV1`, so an AI SDK `Chat` takes it as it is:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { Chat } from "@ai-sdk/react"
|
|
63
|
+
import type { CiUIMessage } from "@collective-intelligence/ai/domain"
|
|
64
|
+
import {
|
|
65
|
+
ciDataPartSchemas,
|
|
66
|
+
ciMessageMetadataSchema
|
|
67
|
+
} from "@collective-intelligence/ai/domain"
|
|
68
|
+
|
|
69
|
+
const chat = new Chat<CiUIMessage>({
|
|
70
|
+
dataPartSchemas: ciDataPartSchemas,
|
|
71
|
+
messageMetadataSchema: ciMessageMetadataSchema,
|
|
72
|
+
transport
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## The chat contract
|
|
77
|
+
|
|
78
|
+
`@collective-intelligence/ai/api` holds `ChatSurfaceApi`, the Effect `HttpApi`
|
|
79
|
+
of every chat operation. The backend serves it under each mount prefix (the
|
|
80
|
+
Studio `/studio/ai`, the Dashboard `/admin` and External Apps
|
|
81
|
+
`/application/v1`), so every path in it is relative: `/chat/...` and
|
|
82
|
+
`/runs/:runId/stream`. It has six groups:
|
|
83
|
+
|
|
84
|
+
| Group | Operations |
|
|
85
|
+
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
86
|
+
| `ChatApi` | Conversations (list, create, get, update, delete, transcript), `POST /chat/:conversationId`, `GET /chat/:conversationId/stream`, `GET /runs/:runId/stream`, stop, Steering and Queued Messages, place context, compaction, evidence navigation, artifact progress |
|
|
87
|
+
| `ChatProjectsApi` | Projects and Project Files |
|
|
88
|
+
| `ChatAttachmentsApi` | Chat attachment upload and download URL |
|
|
89
|
+
| `ChatSpeechApi` | Voice clips, transcriptions, read-aloud parts and speech availability |
|
|
90
|
+
| `ChatFeedbackApi` | Answer feedback |
|
|
91
|
+
| `ChatCatalogApi` | The Agent, Skill and tool lists and the admitted file types |
|
|
92
|
+
|
|
93
|
+
The chat send, its resume and the run stream answer an AI SDK UI message
|
|
94
|
+
stream (`text/event-stream`); the resume answers 204 when no turn runs. Every
|
|
95
|
+
failure is the `CiError` envelope of the client SDKs, one per `aiErrorCodes`
|
|
96
|
+
code; a `forbidden` names its reason (`chatRefusalReasons`). The Studio-only
|
|
97
|
+
groups (activity handoffs, automations, workflows, capability preferences,
|
|
98
|
+
memory administration and the Approvals inbox) are not part of it.
|
|
99
|
+
|
|
100
|
+
`makeChatSurfaceClient({ baseUrl, transformClient? })` builds the typed client
|
|
101
|
+
of one mount; it needs an Effect `HttpClient`:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { makeChatSurfaceClient } from "@collective-intelligence/ai/api"
|
|
105
|
+
import * as Effect from "effect/Effect"
|
|
106
|
+
|
|
107
|
+
const listConversations = makeChatSurfaceClient({
|
|
108
|
+
baseUrl: "https://ci.example/application/v1"
|
|
109
|
+
}).pipe(
|
|
110
|
+
Effect.flatMap((client) => client.chat.listConversations({ query: {} }))
|
|
111
|
+
)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## The headless chat
|
|
115
|
+
|
|
116
|
+
`@collective-intelligence/ai/headless` runs a chat without the default view.
|
|
117
|
+
`ChatSessionProvider` takes the Place, the chat transport, the mount of the
|
|
118
|
+
typed `ChatSurfaceApi` client (`api`, the same `baseUrl` and `fetch`) and the
|
|
119
|
+
optional host ports (`AiHostPorts`: `files`, `speechInput`, `sessions`,
|
|
120
|
+
`flags`, `openTarget`, `messages`; a missing port hides its control).
|
|
121
|
+
`messages.sent` hears each message that starts a turn, with its
|
|
122
|
+
Conversation. `subject` narrows the session to the Conversations of one
|
|
123
|
+
Dashboard draft, and `historyScope` narrows the Conversation list to some
|
|
124
|
+
Places. The provider reads its props once: give it a `key` that changes with
|
|
125
|
+
the Place or the signed-in user to start a new session.
|
|
126
|
+
|
|
127
|
+
- `useChatSession()` gives the Chat Session: `status`, `blocked` (one of
|
|
128
|
+
`chatBlockedKinds`: `sign_in_to_chat`, `chat_not_available`,
|
|
129
|
+
`app_not_available`, `service_not_available`), the Conversations, the open
|
|
130
|
+
Conversation, the place context (read once), the Queued Messages as the
|
|
131
|
+
server lists them, `sendMode`, `busy`, `controls`, and the actions
|
|
132
|
+
`submit`, `queue`, `stop`, `selectConversation`, `newChat`, `setDraft`,
|
|
133
|
+
`setCapabilities`, `updateQueuedMessage`, `removeQueuedMessage`, `retry`.
|
|
134
|
+
`call(operation)` runs any other operation of the typed client and answers
|
|
135
|
+
an `AiResult`. `busy` is `true` while a send, a Stop or a queue change is
|
|
136
|
+
on its way: disable Send and "Send after this answer" meanwhile, as
|
|
137
|
+
`ChatComposer` does; a `submit` or `queue` then sets `failure` and sends
|
|
138
|
+
nothing. A send empties the draft as it leaves, so text typed meanwhile
|
|
139
|
+
stays, and a failed send gives its text back to an empty draft. A Stop
|
|
140
|
+
pressed before the stream names its turn waits for the turn id, then
|
|
141
|
+
cancels that turn.
|
|
142
|
+
- `useCiChat()` is `useChat({ chat })` over the AI SDK `Chat` of the open
|
|
143
|
+
Conversation: it owns the messages, the streaming status and the tool
|
|
144
|
+
approvals. Send through `submit`: while an answer runs, Send steers it.
|
|
145
|
+
`submit({ text, files })` uploads the files as chat attachments into the
|
|
146
|
+
open Conversation, or into the Conversation that the first message of a new
|
|
147
|
+
chat creates, before the turn starts; a message to a running answer takes
|
|
148
|
+
none.
|
|
149
|
+
|
|
150
|
+
The session follows the turns of the open chat: the next turn that an answer
|
|
151
|
+
names, a turn that a send started, and a turn whose stream closed before it
|
|
152
|
+
ended (`paused`, `reconciliation_required`, `waiting_for_input`), each through
|
|
153
|
+
`GET /chat/:conversationId/stream`.
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
"use client"
|
|
157
|
+
import {
|
|
158
|
+
ChatSessionProvider,
|
|
159
|
+
useChatSession,
|
|
160
|
+
useCiChat
|
|
161
|
+
} from "@collective-intelligence/ai/headless"
|
|
162
|
+
import { createChatTransport } from "@collective-intelligence/ai/transport"
|
|
163
|
+
|
|
164
|
+
const baseUrl = "https://ci.example/application/v1"
|
|
165
|
+
|
|
166
|
+
export const AppChat = () => (
|
|
167
|
+
<ChatSessionProvider
|
|
168
|
+
api={{ baseUrl }}
|
|
169
|
+
place={{ id: "app-1", kind: "external_app" }}
|
|
170
|
+
transport={createChatTransport({ baseUrl })}
|
|
171
|
+
>
|
|
172
|
+
<Messages />
|
|
173
|
+
</ChatSessionProvider>
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
const Messages = () => {
|
|
177
|
+
const session = useChatSession()
|
|
178
|
+
const { messages } = useCiChat()
|
|
179
|
+
return session.blocked === null ? (
|
|
180
|
+
<ol>
|
|
181
|
+
{messages.map((message) => (
|
|
182
|
+
<li key={message.id}>{message.role}</li>
|
|
183
|
+
))}
|
|
184
|
+
</ol>
|
|
185
|
+
) : (
|
|
186
|
+
<p>{session.blocked.kind}</p>
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## The default chat view
|
|
192
|
+
|
|
193
|
+
`@collective-intelligence/ai/views` holds `<Chat>`, the default chat with the
|
|
194
|
+
Studio layout: `ConversationSidebar` (the "This place" / "All listed places"
|
|
195
|
+
filter when the place context lists another allowed Place, the place name on
|
|
196
|
+
rows from another Place, and the Projects), `ChatHeader`, `ChatTranscript`,
|
|
197
|
+
`ChatComposer`, and `ChatBlockedState` for the four blocked states. Render it
|
|
198
|
+
inside the `ChatSessionProvider` of the same Place; it reads all data through
|
|
199
|
+
the headless hooks.
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
<ChatSessionProvider api={{ baseUrl }} place={place} transport={transport}>
|
|
203
|
+
<Chat locale="it" place={place} plainChat={false} slots={{ headerActions }} />
|
|
204
|
+
</ChatSessionProvider>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
- Props: `place`, `locale` (`en` or `it`, from `chatLabels`), `labels` (a
|
|
208
|
+
partial override; `{name}` placeholders, see `fillLabel`), `slots`
|
|
209
|
+
(`sidebarHeader`, `sidebarFooter`, `headerActions`, `emptyState`,
|
|
210
|
+
`messageFooter`, `composerAccessory`, `transcriptFooter`), `components`
|
|
211
|
+
(replaces a part by name), `classNames` (one per `data-part`),
|
|
212
|
+
`pinnedAgentId`, `plainChat` (default `true`) and `historyScope`. Inside an
|
|
213
|
+
`IntentsProvider` the chat is a Launch Target: `id` is the name that a Chat
|
|
214
|
+
Launch gives as its `target`, `preferred` makes it the chat that takes a
|
|
215
|
+
launch with no `target` (also while its session starts: it sends the
|
|
216
|
+
latest one once the session is ready), and `onLaunch` runs when a launch
|
|
217
|
+
reaches it, for example to open a collapsed panel.
|
|
218
|
+
- The composer: Send (and Enter) starts a turn, or sends a Steering Message
|
|
219
|
+
to the running answer; while an answer runs, the Send menu offers "Send
|
|
220
|
+
after this answer", which saves a Queued Message, and Stop stops the
|
|
221
|
+
answer. Above it, the waiting Queued Messages of the open Conversation, as
|
|
222
|
+
`listQueuedMessages` answers them, each with Edit and Remove. Files that the
|
|
223
|
+
user chooses, drops or pastes (of the chat attachment types, 10 files of
|
|
224
|
+
10 MB at most) go with the message; an Agent Conversation and a running
|
|
225
|
+
answer take none. The voice control shows when the speech availability
|
|
226
|
+
answer reports remote transcription and the host passes no `speechInput`
|
|
227
|
+
port (a host with that port renders its own voice control, for example in
|
|
228
|
+
`composerAccessory`); the transcribed text goes into the draft and is never
|
|
229
|
+
sent by itself. A budget refusal (`rate_limited`) and a refusal that no
|
|
230
|
+
retry fixes (`unavailable` with `retryable: false`, such as "No AI model
|
|
231
|
+
is available for Studio chat.") show their own message.
|
|
232
|
+
- `<Chat>` has no `theme` and no `colorScheme` prop: the host app styles it
|
|
233
|
+
(see [Styling](#styling)).
|
|
234
|
+
- Each finished answer shows its run as a closed line; opening it renders
|
|
235
|
+
`<RunTrace>` for the answer's turn.
|
|
236
|
+
- A user message shows each `file` part with the ui-react `attachment`
|
|
237
|
+
primitive (`FilePart`): an image with its preview and its name, any other
|
|
238
|
+
file, or a file without a URL, as a chip with its name.
|
|
239
|
+
`components.messageParts.File` replaces it.
|
|
240
|
+
- An answer shows its `data-memory-evidence` part (`MemoryEvidencePart`: the
|
|
241
|
+
used and saved counts, and the "Disabled" badge when memory was off) and
|
|
242
|
+
each call of the image tool as its generation (`ImageGenerationPart`: the
|
|
243
|
+
state, the error, the generated images and the provider, controls and cost
|
|
244
|
+
facts; never the prompt). `components.messageParts.ImageGeneration`
|
|
245
|
+
replaces it. While an answer that no longer streams waits for its images,
|
|
246
|
+
the transcript reads the messages again every 2 seconds
|
|
247
|
+
(`useChatSession().readMessages`) until the server published them.
|
|
248
|
+
|
|
249
|
+
`<ChatDock>` is the docked chat of a Dashboard draft: a pinned agent, no
|
|
250
|
+
Conversation sidebar, one Conversation per draft and a "New chat" action. It
|
|
251
|
+
runs its own Chat Session on the `api` and `transport` that the host passes,
|
|
252
|
+
and adds the `x-chat-subject: <kind>:<id>` header (`chatSubjectHeaderName`,
|
|
253
|
+
`chatSubjectHeaderValue`) to every request, send and resume of that session
|
|
254
|
+
only. It opens the latest Conversation of its draft from the server's list
|
|
255
|
+
(the `subject` filter), so it takes no `sessions` port. `onDraftUpdate` gets
|
|
256
|
+
each `data-draft-update` of the draft as the answer streams.
|
|
257
|
+
|
|
258
|
+
```tsx
|
|
259
|
+
<ChatDock
|
|
260
|
+
api={{ baseUrl }}
|
|
261
|
+
onDraftUpdate={applyToDraft}
|
|
262
|
+
pinnedAgentId={agentId}
|
|
263
|
+
place={{ id: organizationId, kind: "dashboard" }}
|
|
264
|
+
subject={{ id: draftId, kind: "skill_draft" }}
|
|
265
|
+
transport={transport}
|
|
266
|
+
/>
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
`<AssistantSidebarLayout>` docks the shared chat at the right side of the
|
|
270
|
+
app's pages: `sidebar` is an `<AssistantSidebar title>` inside its
|
|
271
|
+
`ChatSessionProvider`, and `<AssistantSidebarToggle>` in the top bar opens
|
|
272
|
+
and closes it. The open sidebar takes width from the page, and the user can
|
|
273
|
+
drag its edge. `AssistantSidebar` is a `<Chat>` with its own header (the
|
|
274
|
+
title, delete after a confirmation, Collapse; no "New chat") and is the
|
|
275
|
+
preferred Launch Target: a Chat Launch opens a collapsed sidebar. `Ctrl+J`
|
|
276
|
+
opens and closes it and `Ctrl+/` puts the cursor in its composer; the app
|
|
277
|
+
sets other keys with `shortcuts` (`AssistantSidebarShortcuts`). Pass the
|
|
278
|
+
host `sessions` port as `sessions` to keep the open state across pages
|
|
279
|
+
(`readAssistantSidebarOpen`, `writeAssistantSidebarOpen`).
|
|
280
|
+
|
|
281
|
+
```tsx
|
|
282
|
+
<AssistantSidebarLayout
|
|
283
|
+
sessions={sessions}
|
|
284
|
+
sidebar={
|
|
285
|
+
<ChatSessionProvider
|
|
286
|
+
api={api}
|
|
287
|
+
host={{ sessions }}
|
|
288
|
+
place={place}
|
|
289
|
+
transport={transport}
|
|
290
|
+
>
|
|
291
|
+
<AssistantSidebar place={place} title="Assistant" />
|
|
292
|
+
</ChatSessionProvider>
|
|
293
|
+
}
|
|
294
|
+
>
|
|
295
|
+
<header>
|
|
296
|
+
<AssistantSidebarToggle />
|
|
297
|
+
</header>
|
|
298
|
+
{page}
|
|
299
|
+
</AssistantSidebarLayout>
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
`<RunTrace runId>` shows a run as assistant message parts from
|
|
303
|
+
`GET /runs/:runId/stream`, read through the typed client: the run status, the
|
|
304
|
+
masked error of a failed run, the run trace link (from the stream's `start`
|
|
305
|
+
or `finish`), tool calls and reasoning as lines of the ui-react Trace, and the
|
|
306
|
+
other parts with the chat's renderers. It follows a running run live and
|
|
307
|
+
stops reading when it unmounts. Inside a `ChatSessionProvider` it reads
|
|
308
|
+
through the session; elsewhere pass `api`. A first-level reader's stream has
|
|
309
|
+
no text, no tool input or output and no trace link, so the trace shows only
|
|
310
|
+
the steps.
|
|
311
|
+
|
|
312
|
+
## Intents
|
|
313
|
+
|
|
314
|
+
An Intent is an application goal that a CI package declares and any surface
|
|
315
|
+
dispatches by its FQN. The Intent controls need no chat: they reach CI only
|
|
316
|
+
through `IntentsApi`, a contract of its own in `./api` (not a group of
|
|
317
|
+
`ChatSurfaceApi`).
|
|
318
|
+
|
|
319
|
+
| Layer | Intent exports |
|
|
320
|
+
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
321
|
+
| `./domain` | `IntentCatalogEntry`, `IntentDispatchOutcome`, `IntentDispatchEnd`, `IntentDispatchRecordState`, `IntentHandle`, `IntentResult`, `IntentResultTarget`, `IntentReturnPage`, `PreparedTurn`, `AccessTarget` |
|
|
322
|
+
| `./api` | `IntentsApi`, `IntentOperations`, `intentOperationIds`, `AccessCheckPort` |
|
|
323
|
+
| `./headless` | `IntentsProvider`, `useIntentDispatch`, `useIntents`, `useIntentResult`, `useReturnedIntentHandle`, `useLaunch`, `useHasLaunchTarget`, `useChatLaunchTarget`, `useVisibility`, `VisibilityGate` |
|
|
324
|
+
| `./views` | `IntentTrigger`, `IntentForm`, `IntentNotices`, `IntentCard`, `ChatLaunchButton` |
|
|
325
|
+
|
|
326
|
+
`IntentsApi` has one `call(op, input)` for the operations `dispatch`, `list`,
|
|
327
|
+
`read` and `wait`; it answers each failure as an `AiError`, and a refused
|
|
328
|
+
dispatch is an outcome. A host gives an adapter: the Studio over its Studio
|
|
329
|
+
Intent routes, an External App `createIntentsApi(org)` of
|
|
330
|
+
`@collective-intelligence/external-apps-client-sdk/chat`, a test a stub.
|
|
331
|
+
|
|
332
|
+
```tsx
|
|
333
|
+
import { IntentsProvider } from "@collective-intelligence/ai/headless"
|
|
334
|
+
import { IntentNotices, IntentTrigger } from "@collective-intelligence/ai/views"
|
|
335
|
+
|
|
336
|
+
;<IntentsProvider access={accessPort} api={intentsApi} caller={userId}>
|
|
337
|
+
<IntentTrigger fqn="acme.plans/create_plan" resultTarget="notification" />
|
|
338
|
+
<IntentNotices />
|
|
339
|
+
</IntentsProvider>
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
- `IntentsProvider` holds the AI Page Registry of the app: it keeps the wait
|
|
343
|
+
of a notification dispatch after its control leaves the screen, shows the
|
|
344
|
+
end in `<IntentNotices>`, and tells `useIntentResult` listeners. Give it a
|
|
345
|
+
`waits` port to resume the waits after a reload. Put one at the app root.
|
|
346
|
+
It caches the Intent catalog under its `IntentsApi` object and `caller`,
|
|
347
|
+
and starts a new registry for each `caller`: keep one `IntentsApi` object
|
|
348
|
+
for each Organization, and one `waits` store for each caller.
|
|
349
|
+
- `IntentTrigger` dispatches with the `notification` or `nothing` Result
|
|
350
|
+
Target, opens `IntentForm` on `needs_input`, and gives the Intent Result
|
|
351
|
+
through `onResult` or `render`. With the `chat` Result Target it makes a
|
|
352
|
+
Chat Launch to the chat that takes launches (`useLaunch`), and is disabled
|
|
353
|
+
while none does.
|
|
354
|
+
- A Chat Launch goes to the chat that it names as `target`, else to the
|
|
355
|
+
preferred chat, else to the nearest chat in scope, else to the
|
|
356
|
+
`launchFallback` of the `IntentsProvider`. A new Conversation takes the Agent
|
|
357
|
+
that the launch names, else the pinned Agent of the chat, else plain chat;
|
|
358
|
+
an Intent launch always starts plain chat. The `trail` entries of a launch
|
|
359
|
+
go after the Context Trail of the tab, and only while that trail records.
|
|
360
|
+
`useChatLaunchTarget` makes a custom chat a Launch Target over
|
|
361
|
+
`submitChatLaunch`. `<ChatLaunchButton turn>` is the "Ask AI" button of a
|
|
362
|
+
page: it launches its Prepared Turn with the launch options of `useLaunch`
|
|
363
|
+
(`target`, `agentId`, `conversation`, `prefill`, `trail`), and is disabled,
|
|
364
|
+
with its reason, while no Launch Target exists.
|
|
365
|
+
- `VisibilityGate` renders its children only when the `access` port answers
|
|
366
|
+
`allowed` for its `AccessTarget`; it is a display hint only.
|
|
367
|
+
- `IntentCard` shows one Intent card: working, the Intent Result, the
|
|
368
|
+
failure, or "Result no longer available".
|
|
369
|
+
- Without an `IntentsApi` the Intent controls render nothing. A Studio widget
|
|
370
|
+
gets the Studio `IntentsProvider`: the Studio ignores the `api`, `access`
|
|
371
|
+
and `caller` that a widget passes.
|
|
372
|
+
|
|
373
|
+
## Styling
|
|
374
|
+
|
|
375
|
+
The views style themselves with Tailwind classes and the shadcn tokens. The
|
|
376
|
+
host app owns the theme:
|
|
377
|
+
|
|
378
|
+
- Build the app's styles with Tailwind v4 as the ui-react README says
|
|
379
|
+
("Styling a host app"): import `tailwindcss`, then
|
|
380
|
+
`@collective-intelligence/ui-react/shadcn.css`, and add
|
|
381
|
+
`@source "../node_modules/@collective-intelligence/ai/dist";` and
|
|
382
|
+
`@source "../node_modules/streamdown/dist/*.js";` (paths relative to the
|
|
383
|
+
stylesheet).
|
|
384
|
+
- Set the shadcn tokens and `--brand`, `--brand-hover` and `--brand-fg` on
|
|
385
|
+
`:root`, and their dark values on `.dark`. Put the `dark` class on `<html>`
|
|
386
|
+
or on an ancestor of the chat.
|
|
387
|
+
- The views take no `theme` and no `colorScheme` prop. Each renders in a chat
|
|
388
|
+
root (`ChatRoot`: the `ci-root` class and the `data-ci-root` attribute)
|
|
389
|
+
that holds the portal container of its overlays and sets no token.
|
|
390
|
+
|
|
391
|
+
## Place
|
|
392
|
+
|
|
393
|
+
`Place` is `{ kind, id }` with `kind` one of `placeKinds`: `studio_app` (the
|
|
394
|
+
Studio app id), `external_app` (the External App's application id) or
|
|
395
|
+
`dashboard` (the Organization id; one Dashboard Place per Organization).
|
|
396
|
+
|
|
397
|
+
## Errors and values
|
|
398
|
+
|
|
399
|
+
An `AiError` is `{ code, message, retryable, reason? }`, with `code` one of the
|
|
400
|
+
eight `aiErrorCodes`. `AiResult<Value>` is `{ ok: true, value }` or
|
|
401
|
+
`{ ok: false, error }`. `AiFailureError` carries an `AiError` where no result
|
|
402
|
+
can carry it, such as inside a stream.
|
|
403
|
+
|
|
404
|
+
`RuntimeValue`, `asRuntimeValue`, `requireValue`, `isNullish` and the
|
|
405
|
+
`has*RuntimeKind` guards narrow values of an unknown kind.
|
|
406
|
+
|
|
407
|
+
## Migrating from ai-core and ai-react
|
|
408
|
+
|
|
409
|
+
This package replaces `@collective-intelligence/ai-core` and
|
|
410
|
+
`@collective-intelligence/ai-react`, whose last release is 0.5.0. It has no
|
|
411
|
+
compatibility layer: the chat runs on AI SDK UI message streams and the typed
|
|
412
|
+
`ChatSurfaceApi` client, not on the operation-keyed transport and the
|
|
413
|
+
presentation stream.
|
|
414
|
+
|
|
415
|
+
1. Remove `ai-core` and `ai-react`. Install this package, `ai`, `effect` and,
|
|
416
|
+
for the React layers, the optional peers listed in [Install](#install).
|
|
417
|
+
2. Replace `AiProvider` with `ChatSessionProvider` of `./headless`. Pass `api`
|
|
418
|
+
and `transport` of the same mount (an External App gets both from the
|
|
419
|
+
client SDK: `chatMountOf(org)` and `createChatTransport(org)`), the
|
|
420
|
+
`place`, and the same `host` ports. Replace `caller` with a `key` on the
|
|
421
|
+
provider.
|
|
422
|
+
3. Move `<Chat>` inside that provider and drop `theme` and `colorScheme`.
|
|
423
|
+
Replace `AiThemeScope` and the `ui-react/styles.css` import with the host
|
|
424
|
+
setup of [Styling](#styling).
|
|
425
|
+
4. Rename the imports with the table below.
|
|
426
|
+
|
|
427
|
+
In a Studio widget, `bindHostAi` is gone: the Studio replaces
|
|
428
|
+
`ChatSessionProvider`, `Chat`, `ChatDock` and `RunTrace` with versions bound
|
|
429
|
+
to its own Backend and Studio app, and ignores the `api`, `transport`, `host`
|
|
430
|
+
and `place` that a widget passes. Rebuild the widget with the CLI of the same
|
|
431
|
+
release.
|
|
432
|
+
|
|
433
|
+
| ai-core and ai-react | `@collective-intelligence/ai` |
|
|
434
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
435
|
+
| `Place`, `PlaceKind`, `AiResult`, `AiError`, `AiErrorCode`, `AiFailureError`, `aiErrorCodes`, the runtime value helpers (`ai-core`) | the same names in `./domain`; `PlaceKind` adds `dashboard` |
|
|
436
|
+
| `ChatTransport` and `call(operationId, { path, query, body })` (`ai-core/chat`) | `makeChatSurfaceClient` of `./api`: `client.<group>.<operation>({ params, query, payload })`; inside a provider, `useChatSession().call(operation)` |
|
|
437
|
+
| `chatOperationIds`, `ChatOperationId`, `ChatOperationInput`, `ChatOperationOutput` | the groups and operations of `ChatSurfaceApi` (`./api`) |
|
|
438
|
+
| `followPresentation`, `openPresentationStream`, `PresentationSnapshot` | a turn: the AI SDK chat transport `createChatTransport` (`./transport`); a run: `GET /runs/:runId/stream`, shown by `<RunTrace>` |
|
|
439
|
+
| `displayPartsFromResult`, `tableDisplay`, `evidenceDisplay`, `evidenceNavigationRequest` | `data-evidence` parts (`Evidence` of `./domain`), shown by `EvidencePart` of `./views`; navigation through `resolveEvidenceNavigation` |
|
|
440
|
+
| `AiProvider` (`transport`, `caller`, `host`) | `ChatSessionProvider` (`api`, `transport`, `place`, `host`) of `./headless`, with a `key` |
|
|
441
|
+
| `AiThemeScope`, `AiTheme`, `AiThemePalette`, `AiColorScheme` | gone: the host app sets the tokens and the `dark` class |
|
|
442
|
+
| `bindHostAi`, `HostAiBinding` | gone: the Studio binds the chat of a widget itself |
|
|
443
|
+
| `AiHostPorts`, `FilePort`, `SpeechInputPort`, `SessionStorePort`, `FeatureFlagPort`, `OpenTargetPort`, `chatFeatureFlags`, `createBrowserFilePort` | the same names in `./headless`; `AiHostPorts` adds `messages`, and the record of `SessionStorePort` is `ChatSessionRecord` (was `ChatSession`) |
|
|
444
|
+
| `Chat`, `chatLabels` and the chat types (`ChatProps`, `ChatSlots`, `ChatComponents`, `ChatPartProps`, ...) (`ai-react/chat`) | the same names in `./views`, rendered inside `ChatSessionProvider`; the default parts (`ConversationSidebar`, `ChatHeader`, ...) are exported too |
|
|
445
|
+
| `<Chat onSent>` | the `messages` host port: `sent({ conversation })` |
|
|
446
|
+
| `useChat({ place, historyScope })` | `useChatSession()` for the session state and actions, `useCiChat()` for the messages (the AI SDK `useChat`) |
|
|
447
|
+
| `chat.sendMessage.mutate({ text, attachments })`, `queueMessage`, `stopRun` | `session.submit({ text, files })`, `session.queue(text)`, `session.stop()` |
|
|
448
|
+
| `chat.transcript`, `chat.run` | `useCiChat().messages` and `status`, and `session.sendMode` |
|
|
449
|
+
| `useQueuedMessages` | `session.queuedMessages`, `updateQueuedMessage`, `removeQueuedMessage` |
|
|
450
|
+
| `usePlaceContext` | `session.placeContext` |
|
|
451
|
+
| `useChatAgents`, `useChatSkills`, `useChatTools`, `useChatAttachments`, `useSpeechAvailability` | `session.call` with `chatCatalog.listAgents`, `listSkills`, `listTools`, `getAttachmentCapabilities` and `chatSpeech.getSpeechAvailability` |
|
|
452
|
+
| `useInteractionResponse`, `useApprovalRequest`, `usePermissionDecision` | the tool part of the answer: `addToolApprovalResponse`, or `addToolOutput` for `ci_ask_user`, of `useCiChat()`; `ToolPart` and `QuestionPart` render them |
|
|
453
|
+
| `useAnswerFeedback` | `ChatAnswerFeedback` of `./views`, or `chatFeedback.putAnswerFeedback` and `clearAnswerFeedback` |
|
|
454
|
+
| `useEvidenceSource`, `useArtifactProgress`, `useAttachmentDownload` | `session.call` with `chat.resolveEvidenceNavigation`, `chat.getArtifactProgress` and `chatAttachments.getAttachmentDownloadUrl` |
|
|
455
|
+
| `useChatProjects` | the Projects of the default sidebar, or `session.call` with the `chatProjects` operations |
|
|
456
|
+
| `transcribeRecording` | `transcribeRecording` of `./views` |
|
|
457
|
+
| `AiProvider` `intents` and `host.access`; `ai-core/intents` and `ai-core/access` types | `IntentsProvider` (`api`, `access`, `caller`, `waits`) of `./headless`; the types in `./domain` and `./api`; `IntentTransport` is now `IntentsApi` |
|
|
458
|
+
| `IntentTrigger`, `IntentForm`, `useIntentDispatch`, `useIntents`, `useReturnedIntentHandle` (`ai-react/intents`) | the same names: the components in `./views`, the hooks in `./headless` |
|
|
459
|
+
| `AssistantSidebar`, `AssistantSidebarLayout`, `AssistantSidebarToggle`, `ChatLaunchButton` (`ai-react/chat`) | the same names in `./views`; pass the `sessions` port to `AssistantSidebarLayout`, and render the sidebar inside a `ChatSessionProvider` |
|
|
460
|
+
| `useChatLaunch().launch` (`ai-react/chat`) | `useLaunch()` of `./headless` |
|
|
461
|
+
|
|
462
|
+
A capability permission prompt is gone: a tool that needs the user's approval
|
|
463
|
+
asks for it in its tool part.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AccessCheckAnswer, AccessTarget, AiResult } from "../domain/index.js";
|
|
2
|
+
/** The answers in target order, with the Access Version they hold for. */
|
|
3
|
+
export interface AccessCheckResponse {
|
|
4
|
+
readonly accessVersion: number;
|
|
5
|
+
readonly answers: readonly AccessCheckAnswer[];
|
|
6
|
+
}
|
|
7
|
+
export interface AccessCheckOptions {
|
|
8
|
+
readonly signal?: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The one port through which the Visibility Gate reaches the Access Check.
|
|
12
|
+
* The Studio and the client SDK each fill it with an adapter. One `check`
|
|
13
|
+
* sends the targets of one render. The answers are a display hint only: the
|
|
14
|
+
* backend checks access on every call.
|
|
15
|
+
*/
|
|
16
|
+
export interface AccessCheckPort {
|
|
17
|
+
readonly check: (targets: readonly AccessTarget[], options?: AccessCheckOptions) => Promise<AiResult<AccessCheckResponse>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
/** The answer whose evidence a navigation names. */
|
|
3
|
+
export declare const EvidenceNavigationPath: Schema.Struct<{
|
|
4
|
+
readonly invocationId: Schema.brand<Schema.String, "@collective-intelligence/ai/InvocationId">;
|
|
5
|
+
}>;
|
|
6
|
+
/** One evidence item of the answer, by the opaque `evidenceId` of the source. */
|
|
7
|
+
export declare const EvidenceNavigationRequest: Schema.Struct<{
|
|
8
|
+
readonly evidenceId: Schema.NonEmptyString;
|
|
9
|
+
readonly navigation: Schema.Union<readonly [Schema.Struct<{
|
|
10
|
+
readonly entityId: Schema.String;
|
|
11
|
+
readonly kind: Schema.Literal<"entity">;
|
|
12
|
+
}>, Schema.Struct<{
|
|
13
|
+
readonly fileId: Schema.String;
|
|
14
|
+
readonly kind: Schema.Literal<"file">;
|
|
15
|
+
}>, Schema.Struct<{
|
|
16
|
+
readonly kind: Schema.Literal<"external_url">;
|
|
17
|
+
readonly url: Schema.String;
|
|
18
|
+
}>]>;
|
|
19
|
+
}>;
|
|
20
|
+
/** The target of the source while the caller can still read it; else null. */
|
|
21
|
+
export declare const EvidenceNavigationResponse: Schema.Struct<{
|
|
22
|
+
readonly target: Schema.NullOr<Schema.Union<readonly [Schema.Struct<{
|
|
23
|
+
readonly entityId: Schema.String;
|
|
24
|
+
readonly kind: Schema.Literal<"entity">;
|
|
25
|
+
}>, Schema.Struct<{
|
|
26
|
+
readonly fileId: Schema.String;
|
|
27
|
+
readonly kind: Schema.Literal<"file">;
|
|
28
|
+
readonly mediaUrl: Schema.optionalKey<Schema.String>;
|
|
29
|
+
}>, Schema.Struct<{
|
|
30
|
+
readonly kind: Schema.Literal<"external_url">;
|
|
31
|
+
readonly url: Schema.String;
|
|
32
|
+
}>]>>;
|
|
33
|
+
}>;
|
|
34
|
+
/** The progress of the artifacts of a Conversation, such as the images that a turn generates. */
|
|
35
|
+
export declare const ArtifactProgress: Schema.Struct<{
|
|
36
|
+
readonly currentArtifact: Schema.NullOr<Schema.Struct<{
|
|
37
|
+
readonly artifactId: Schema.String;
|
|
38
|
+
readonly contentType: Schema.NullOr<Schema.String>;
|
|
39
|
+
readonly filename: Schema.String;
|
|
40
|
+
readonly role: Schema.String;
|
|
41
|
+
readonly sourceKind: Schema.String;
|
|
42
|
+
}>>;
|
|
43
|
+
readonly failed: Schema.Int;
|
|
44
|
+
readonly leased: Schema.Int;
|
|
45
|
+
readonly pending: Schema.Int;
|
|
46
|
+
readonly processed: Schema.Int;
|
|
47
|
+
readonly skipped: Schema.Int;
|
|
48
|
+
}>;
|