@camunda/copilot-chat 0.6.0 → 0.8.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.
package/README.md CHANGED
@@ -11,86 +11,131 @@ npm install @camunda/copilot-chat
11
11
  **Peer Dependencies:**
12
12
 
13
13
  ```bash
14
- npm install react react-dom @carbon/react @carbon/icons-react
14
+ npm install react react-dom
15
15
  ```
16
16
 
17
- ## Quick Start
17
+ ## Styling
18
+
19
+ The library ships precompiled CSS (including its own Tailwind v4 utilities,
20
+ scoped under `.copilot-chat-root` so they cannot leak into the host document):
18
21
 
19
22
  ```tsx
20
- import { CopilotChat, useChatStore } from '@camunda/copilot-chat';
21
23
  import '@camunda/copilot-chat/style.css';
22
-
23
- function App() {
24
- const handleSendMessage = async (message: string) => {
25
- const { addAssistantMessage, appendToMessage, updateMessageStatus } = useChatStore.getState();
26
- const messageId = `msg-${Date.now()}`;
27
- addAssistantMessage(messageId);
28
- appendToMessage(messageId, 'Hello!');
29
- updateMessageStatus(messageId, 'complete'); // 'pending' | 'streaming' | 'complete' | 'error'
30
- };
31
-
32
- return <CopilotChat onSendMessage={handleSendMessage} workareaSelector="body" />;
33
- }
34
24
  ```
35
25
 
36
- ## With Agent Adapter (Recommended)
26
+ Components are built on `@camunda/design-system` (a runtime dependency, kept
27
+ external to the bundle). Consumers must import the design-system stylesheet
28
+ themselves:
29
+
30
+ ```tsx
31
+ import '@camunda/design-system/styles.css';
32
+ ```
37
33
 
38
- For full agent orchestration with tool execution:
34
+ ## Quick Start
39
35
 
40
36
  ```tsx
41
- import { useMemo } from 'react';
42
- import { CopilotChat, useAgentAdapter } from '@camunda/copilot-chat';
37
+ import {
38
+ CopilotConversationPanel,
39
+ createFixtureClient,
40
+ } from '@camunda/copilot-chat';
43
41
  import '@camunda/copilot-chat/style.css';
42
+ import { useState } from 'react';
43
+
44
+ const client = createFixtureClient();
44
45
 
45
46
  function App() {
46
- const transport = useMemo(
47
- () => ({
48
- subscribe: (id, onEvent) => {
49
- /* Subscribe to events */
50
- },
51
- unsubscribe: (id) => {
52
- /* Cleanup */
53
- },
54
- sendMessage: async (payload) => {
55
- /* POST to backend */
56
- },
57
- sendToolResult: async (payload) => {
58
- /* POST tool result */
59
- },
60
- }),
61
- []
47
+ const [conversationId, setConversationId] = useState<string | null>(null);
48
+
49
+ return (
50
+ <CopilotConversationPanel
51
+ client={client}
52
+ conversationId={conversationId}
53
+ onConversationStarted={setConversationId}
54
+ onSelectConversation={setConversationId}
55
+ />
62
56
  );
63
-
64
- const { sendMessage, stopGeneration, resetConversation } = useAgentAdapter({
65
- transport,
66
- externalTools: [{ name: 'my_tool', description: '...', parametersSchema: '{}' }],
67
- onToolInvoke: async (toolName, args) => {
68
- /* Return result */
69
- },
70
- });
71
-
72
- return <CopilotChat onSendMessage={sendMessage} onStopGeneration={stopGeneration} onResetConversation={resetConversation} />;
73
57
  }
74
58
  ```
75
59
 
76
- ## Props
77
-
78
- | Prop | Type | Required | Description |
79
- | ----------------------- | ------------------------------------ | -------- | ---------------------------------------- |
80
- | `onSendMessage` | `(message: string) => Promise<void>` | Yes | Called when user sends a message |
81
- | `onStopGeneration` | `() => void` | No | Called when user clicks stop button |
82
- | `onResetConversation` | `() => void` | No | Called when user resets the conversation |
83
- | `workareaSelector` | `string` | No | CSS selector for the main content area |
84
- | `emptyStateTitle` | `string` | No | Title shown when chat is empty |
85
- | `emptyStateDescription` | `string` | No | Description shown when chat is empty |
60
+ Pass `onClose` when the panel is used in a sidecar. It adds a close button to
61
+ the header in both the chat list and an open chat; the host callback should
62
+ close the sidecar and return focus to its opener.
63
+
64
+ ## Conversation context
65
+
66
+ Pass `projectName` for the selected conversation's project to show its name in
67
+ the header. The project chip explains Copilot's project access; pass
68
+ `onOpenProject(projectId)` to show a "Go to project" action in its popup.
69
+ If the project name cannot be loaded, pass `projectNameUnavailable` rather
70
+ than displaying a project ID as its name. The host must still provide editor
71
+ context in `postMessage`; these props only describe the project.
72
+
73
+ ## Selection context
74
+
75
+ Pass `selectionContext={{ projectId, count }}` to `CopilotConversationPanel`
76
+ when a BPMN editor has selected elements. A positive count appears as a
77
+ read-only "1 element selected" or "N elements selected" pill in the
78
+ composer's prompt-input toolbar; omit the prop or
79
+ pass `count: 0` to hide it. For a pinned conversation,
80
+ the indicator appears only when the loaded conversation's origin artifact belongs
81
+ to `projectId`. It remains hidden while that origin is loading or belongs to a
82
+ different project. The host is responsible for supplying the selected elements
83
+ as context when the message is sent.
84
+
85
+ ## Reviewing proposed changes
86
+
87
+ `CopilotConversationPanel` accepts a `renderReview(candidate, { approve, reject })`
88
+ callback for host-owned review flows. When provided, its return value replaces
89
+ the inline approve/reject controls for pending candidates. Hosts should present
90
+ the candidate's changes (including their `before` and `content` snapshots)
91
+ before calling `approve`; the exported `CandidateReview` renders BPMN diagrams
92
+ and text diffs. Both actions return promises, so the host can display progress
93
+ and keep the review open if an action fails.
94
+ While a proposal awaits approval or rejection, the composer is disabled for
95
+ that conversation. Other conversations remain available. The backend also
96
+ rejects new turns until the proposal is resolved.
97
+
98
+ While a turn is running, the message input and suggestions are disabled and no
99
+ additional message can be submitted. Stop remains available; sending resumes after
100
+ the turn finishes or is stopped, provided no proposal awaits review. Rejected submissions show an inline
101
+ error and preserve the draft for retry. Messages are not queued or automatically
102
+ used to interrupt a running turn.
103
+
104
+ Applied changes offer a Restore action. It opens a confirmation dialog naming the
105
+ affected files before restoring their earlier state. Cancel or Escape leaves them
106
+ unchanged; restoring preserves chat history. Failed restores remain in the dialog
107
+ with an error and can be retried.
108
+
109
+ Async `CopilotClient` adapters should call the optional third `observe` argument
110
+ after each connection or reconnection. The panel refreshes its snapshot at that
111
+ point to recover events missed while connecting. The HTTP adapter does this on
112
+ SSE open; two-argument synchronous adapters remain supported.
113
+
114
+ `CandidateReview.onReviewReady` reports true only when every artifact is ready.
115
+ Fixture scripts must supply `before` for modifications to support restore;
116
+ otherwise approval has no checkpoint. Only created files restore to absence.
117
+
118
+ ## Conversation steps
119
+
120
+ Assistant messages can include `message` steps for intermediate agent progress.
121
+ Their `description` holds the message text. Intermediate messages remain visible
122
+ alongside tool steps in event order, including after completion or interruption.
123
+ If the turn ends with a message, only that last message is removed from the steps
124
+ and becomes the assistant reply in `content`. Optional `groupId` metadata in
125
+ older snapshots does not nest rows. Message rows show text directly beside a
126
+ neutral dot, without a generic "Progress" label.
127
+
128
+ Shell-tool lint steps, including combined layout/lint steps, use a neutral wrench
129
+ and their original activity label even when the check returns an error. They do
130
+ not show red failure styling, a "(failed)" suffix, or a warning badge. The stored
131
+ step status remains `error`; lint findings stay in the assistant's explanation.
132
+ Other failed operations retain their failure presentation. This presentation
133
+ rule applies both to live steps and to reopened conversation history.
86
134
 
87
135
  ## Documentation
88
136
 
89
- See the [docs folder](../../docs) for detailed documentation:
90
-
91
- - [Architecture Overview](../../docs/architecture.md)
92
- - [Integration Guide](../../docs/integration.md)
93
- - [Writing Adapters](../../docs/adapters.md)
137
+ - [Repository README](https://github.com/camunda/camunda-copilot-client#readme)
138
+ - [Development Guide](https://github.com/camunda/camunda-copilot-client/blob/main/docs/development.md)
94
139
 
95
140
  ## License
96
141
 
@@ -0,0 +1,19 @@
1
+ import { R as c, L as f, A as d } from "./index-D9bYzhnE.js";
2
+ import { useContext as p, useState as L, useEffect as N } from "react";
3
+ import { jsx as x } from "react/jsx-runtime";
4
+ var A = ({ code: s, language: e, raw: a, className: o, startLine: m, lineNumbers: u, ...g }) => {
5
+ let { shikiTheme: i } = p(c), t = f(), [n, r] = L(a);
6
+ return N(() => {
7
+ if (!t) {
8
+ r(a);
9
+ return;
10
+ }
11
+ let l = t.highlight({ code: s, language: e, themes: i }, (h) => {
12
+ r(h);
13
+ });
14
+ l && r(l);
15
+ }, [s, e, i, t, a]), x(d, { className: o, language: e, lineNumbers: u, result: n, startLine: m, ...g });
16
+ };
17
+ export {
18
+ A as HighlightedCodeBlockBody
19
+ };