@camunda/copilot-chat 0.8.1-alpha.2 → 0.8.1-alpha.3

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.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -63,6 +63,22 @@ close the sidecar and return focus to its opener.
63
63
 
64
64
  ## Conversation context
65
65
 
66
+ Conversation typography uses two scoped design-system scales: regular user and
67
+ assistant prose and composer use `--text-sm` (14px/20px by default); event labels,
68
+ active questions, answers, expanded details and actions use `--text-xs`
69
+ (12px/16px by default). Semantic
70
+ Markdown headings and code retain their own treatment. Scoped event paragraph
71
+ spacing and form typography prevent host resets or browser defaults from changing
72
+ that hierarchy.
73
+
74
+ Steps can include optional `artifacts: readonly ArtifactRef[]` in snapshots and
75
+ `step_start` events. These render identity-backed file chips using the complete
76
+ display name, without parsing paths or extensions. When present and nonempty,
77
+ they replace the legacy description in the row; chips remain read-only.
78
+ At the snapshot boundary, omitted message `steps` (as serialized for Hub user
79
+ messages) normalize to an empty timeline. Present non-array values remain
80
+ synchronization errors; they are not silently replaced.
81
+
66
82
  Pass `projectName` for the selected conversation's project to show its name in
67
83
  the header. The project chip explains Copilot's project access; pass
68
84
  `onOpenProject(projectId)` to show a "Go to project" action in its popup.
@@ -76,6 +92,24 @@ disabled and shows the reason, and stale proposals can no longer be reapplied;
76
92
  stopping a running turn and reviewing proposals
77
93
  stay available, as do the chat list and new chats.
78
94
 
95
+ ## Naming conversations
96
+
97
+ Each chat in the list is labelled with its `name`, falling back to the origin
98
+ artifact's name and then "Chat". When the `CopilotClient` implements the
99
+ optional `renameConversation(conversationId, name)`, every row gets an
100
+ "Actions for …" menu with a Rename item. It opens a "Rename chat" dialog, as
101
+ elsewhere in Hub: Rename stays disabled until the trimmed name is non-empty and
102
+ differs from the current one; Enter renames; Escape, Cancel, or the close
103
+ button leave the name unchanged; focus returns to the actions button. The new
104
+ name shows at once; if the request fails, the previous name returns and the row
105
+ shows an error. Without `renameConversation`, no actions menu is offered.
106
+
107
+ Adapters resolve with the conversation's updated summary. The server trims the
108
+ name and rejects it when blank or longer than `CONVERSATION_NAME_MAX_LENGTH`
109
+ (100) characters. The HTTP adapter sends `PATCH /conversations/{conversationId}`
110
+ with `{ "name": "…" }`; `useCopilotConversationList` exposes the same action as
111
+ `rename(conversationId, name)` together with `canRename`.
112
+
79
113
  ## Selection context
80
114
 
81
115
  Pass `selectionContext={{ projectId, count }}` to `CopilotConversationPanel`
@@ -88,6 +122,67 @@ to `projectId`. It remains hidden while that origin is loading or belongs to a
88
122
  different project. The host is responsible for supplying the selected elements
89
123
  as context when the message is sent.
90
124
 
125
+ ## BPMN element references
126
+
127
+ Assistant Markdown can refer to an exact current BPMN element:
128
+
129
+ ```markdown
130
+ Check [Verify customer](#camunda-element-v1?artifactId=file-1&elementId=Task_Verify).
131
+ ```
132
+
133
+ Use the exported `encodeBpmnElementReference({ artifactId, elementId })` to build
134
+ destinations. `parseBpmnElementReference(destination)` returns a discriminated
135
+ `kind: 'ordinary' | 'invalid' | 'reference'`; the reference case contains the
136
+ decoded `{ artifactId, elementId }`. Both IDs must be nonempty, not whitespace-only,
137
+ and contain no control characters or unpaired surrogates. Decoded UTF-16 length
138
+ limits are 255 and 1024 respectively; no BPMN ID grammar is imposed. Exactly the
139
+ two named query parameters must occur once each. Invalid escapes, duplicate or
140
+ extra parameters, raw whitespace, `+` and `#` in values are rejected. The encoder
141
+ uses percent encoding, additionally escaping parentheses for Markdown safety.
142
+ Contract vectors ship at `@camunda/copilot-chat/fixtures/bpmn-element-references.json`.
143
+
144
+ Pass an optional `renderElementReference` to the panel:
145
+
146
+ ```tsx
147
+ <CopilotConversationPanel
148
+ client={client}
149
+ conversationId={conversationId}
150
+ renderElementReference={(reference, { label, messageId, blockId }) => (
151
+ <HostElementReference
152
+ reference={reference}
153
+ label={label}
154
+ messageId={messageId}
155
+ blockId={blockId}
156
+ />
157
+ )}
158
+ />
159
+ ```
160
+
161
+ The host renderer receives validated references only after the containing text
162
+ block completes. `blockId` is the message-step ID or `content` for top-level text;
163
+ `label` is the plain historical link text. Streaming references stay inert, and
164
+ terminal truncated links are not repaired into actionable references. Both
165
+ timeline message text and final assistant content use this path; user messages,
166
+ reasoning and raw tool descriptions do not. Renderer/context changes update
167
+ unchanged Markdown, so the host can reflect current resolution state.
168
+
169
+ Without a renderer, valid references are readable inert labels. Invalid reserved
170
+ destinations, including unknown versions, display inert “Reference unavailable”
171
+ text and never fall through to ordinary URL navigation. Ordinary Markdown retains
172
+ Streamdown's sanitization, external-link safety and image behavior.
173
+
174
+ The host owns authorized project/file resolution, accessibility, current-target
175
+ availability, preview cleanup and explicit navigation. The fragment never supplies
176
+ a project or authorizes access, model edits, proposal approval or a new turn.
177
+ Preserve the historical label and explain unavailable targets explicitly rather
178
+ than resolving a different element by name.
179
+
180
+ In the offline demo, send `references` for a deterministic streaming transcript
181
+ with duplicate labels, overlapping file identities, connection/subprocess examples
182
+ and unavailable targets. Its explicitly mocked controls exercise rendering and
183
+ keyboard behavior only, not BPMN navigation. Add `?hostless` to exercise inert
184
+ fallback without a renderer.
185
+
91
186
  ## Reviewing proposed changes
92
187
 
93
188
  `CopilotConversationPanel` accepts a `renderReview(candidate, { approve, reject })`
@@ -107,6 +202,11 @@ the turn finishes or is stopped, provided no proposal awaits review. Rejected su
107
202
  error and preserve the draft for retry. Messages are not queued or automatically
108
203
  used to interrupt a running turn.
109
204
 
205
+ Failed chat-list reads (including initial load, reconnect, visibility resume and
206
+ Back navigation) retain cached rows and display a retryable error in the Chats
207
+ view rather than an empty success state. A successful reload clears that error;
208
+ list failures do not replace the composer's independent send-error message.
209
+
110
210
  Applied changes offer a Restore action. It opens a confirmation dialog naming the
111
211
  affected files before restoring their earlier state. Cancel or Escape leaves them
112
212
  unchanged; restoring preserves chat history. Failed restores remain in the dialog
@@ -147,6 +247,68 @@ stops observation, timers, and browser listeners; it never cancels a turn.
147
247
  Fixture scripts must supply `before` for modifications to support restore;
148
248
  otherwise approval has no checkpoint. Only created files restore to absence.
149
249
 
250
+ ## Questions from Copilot
251
+
252
+ Copilot can pause an active turn to ask a question in a nonmodal card above
253
+ the composer. The card uses the adapted AI Elements Question composition
254
+ and supports single choice, multiple choices and free text. A single choice
255
+ means at most one selected option; custom text may supplement a selection.
256
+ The card has the same 12px outer gutter as the transcript/composer and 12px
257
+ vertical separation. Long question content scrolls independently of its actions;
258
+ exceptionally short panels can scroll as a whole to keep every control reachable.
259
+ Continue submits the answer; Skip records an explicit skip and lets the same
260
+ turn continue. Stop remains a separate turn-cancellation action.
261
+
262
+ Adapters provide `ConversationMessage.questions` and the optional
263
+ `ConversationSummary.pendingQuestionId`. `ConversationQuestion` includes its
264
+ stable ID/version, owning assistant message ID, options, immutable answer and
265
+ delivery status. One question may be actionable per conversation. Keep the
266
+ conversation `running` and its assistant message `streaming` while awaiting
267
+ input; provider "requires action" is not turn completion.
268
+
269
+ Implement optional `CopilotClient.answerQuestion(AnswerQuestionInput)` to enable
270
+ answers. Existing adapters without Q&A remain supported; a pending question
271
+ from an adapter without that action displays an explicit unsupported message.
272
+ The HTTP client posts the answer fields (excluding the two path identities) to
273
+ `/conversations/{conversationId}/questions/{questionId}/answer` relative to
274
+ `baseUrl`. Hosts with other routes map this action in their adapter.
275
+
276
+ Question lifecycle events are `question_requested`, `question_answered` and
277
+ `question_delivery_changed`, each carrying `messageId`, the full `question`,
278
+ and optional conversation `revision`. Persist question/answer state before
279
+ broadcasting. Snapshots remain authoritative, including after reload or a
280
+ missed event; lifecycle events trigger refresh. Answered, skipped and cancelled
281
+ questions remain on the same assistant message as compact "Asked user" / "Answer"
282
+ timeline events, with a disclosure for full details instead of an actionable card.
283
+ The persisted question creation time places them among dated work steps before
284
+ subsequent activity and the final reply. Existing step order is preserved;
285
+ legacy undated steps stay before question events. Timestamps from different
286
+ clocks are a deterministic presentation aid, not a strict causal-order guarantee.
287
+
288
+ A successful answer request means the response intent was saved, not that
289
+ the provider received it. `delivery: 'unverified'` displays that uncertainty
290
+ without resending. The browser retains the original submission ID and draft
291
+ across refreshes/remounts in the current page. After a failed request, explicit
292
+ "Check status and retry" refreshes first and, only if still pending, resends the
293
+ same ID and canonical answer. Hosts must make this idempotent and reject a
294
+ conflicting answer; they must not automatically repeat ambiguous provider sends.
295
+ Accepted writes stay disabled even when the follow-up snapshot fails.
296
+ Unsubmitted drafts are not persisted across browser reload.
297
+
298
+ The fixture demo supports prompts `question single`, `question multiple`, and
299
+ `question text`. These exercise browser behavior without a provider and do not
300
+ prove live custom-tool registration/delivery. The Java demo server does not
301
+ register this tool; a real host must connect the existing Java custom-tool API.
302
+
303
+ For local consumer integration, use the existing `npm run dev:link` / yalc
304
+ workflow documented in the root development guide. Keep the consumer's normal
305
+ package range and lockfile as the final source-controlled dependency; remove
306
+ temporary `.yalc`/`file:` wiring after local verification. Do not publish a
307
+ release or commit machine-specific dependencies just to validate the feature.
308
+
309
+ The adapted Question source attribution and Apache-2.0 license ship in
310
+ `THIRD_PARTY_NOTICES.md` and `LICENSES`.
311
+
150
312
  ## Conversation steps
151
313
 
152
314
  Assistant messages can include `message` steps for intermediate agent progress.
@@ -0,0 +1,25 @@
1
+ # Third-party notices
2
+
3
+ ## AI Elements Question
4
+
5
+ `src/components/ai-elements/question.tsx` is adapted from
6
+ <https://github.com/vercel/ai-elements/blob/ca8be600bfd01b3131f9bf6134b51602a71f4374/packages/elements/src/question.tsx>.
7
+
8
+ Copyright 2023 Vercel, Inc.
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>.
13
+
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ See the License for the specific language governing permissions and
18
+ limitations under the License.
19
+
20
+ The license text is included in `LICENSES/Apache-2.0.txt`.
21
+
22
+ Modifications: Camunda design-system Button/Textarea/cn imports, CSS Modules,
23
+ reduced internal API, readonly draft types, and radio arrow-key navigation.
24
+ The source requires React and those UI primitives; no new runtime dependency
25
+ is needed by this adaptation.
@@ -1,4 +1,4 @@
1
- import { R as c, L as f, A as d } from "./index-WwYib96f.js";
1
+ import { R as c, L as f, A as d } from "./index-DevZv06y.js";
2
2
  import { useContext as p, useState as L, useEffect as N } from "react";
3
3
  import { jsx as x } from "react/jsx-runtime";
4
4
  var A = ({ code: s, language: e, raw: a, className: o, startLine: m, lineNumbers: u, ...g }) => {