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

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/dist/index.d.ts CHANGED
@@ -11,14 +11,31 @@ export declare interface AnswerQuestionInput {
11
11
  readonly text?: string;
12
12
  }
13
13
 
14
- export declare interface ArtifactChange {
15
- readonly changeKind: 'create' | 'modify';
16
- readonly artifact: ArtifactRef;
17
- readonly content: string;
18
- readonly before?: string;
19
- readonly validationMessages?: ReadonlyArray<string>;
14
+ export declare interface ApplyDraftInput {
15
+ readonly conversationId: string;
16
+ readonly draftId: string;
17
+ readonly reviewedGeneration: number;
18
+ readonly confirmedLive: ReadonlyArray<{
19
+ readonly artifactKey: string;
20
+ readonly liveFingerprint: string;
21
+ }>;
20
22
  }
21
23
 
24
+ export declare type ApplyDraftResult = {
25
+ readonly status: 'applied';
26
+ readonly applyId: string;
27
+ } | {
28
+ readonly status: 'changed_since_review';
29
+ readonly draft: Draft;
30
+ } | {
31
+ readonly status: 'blocked';
32
+ readonly reasons: ReadonlyArray<{
33
+ readonly artifactKey: string;
34
+ readonly reason: 'no_edit_permission' | 'location_deleted' | 'hub_rule' | 'limit';
35
+ readonly message: string;
36
+ }>;
37
+ };
38
+
22
39
  export declare interface ArtifactRef {
23
40
  readonly projectId: string;
24
41
  readonly artifactId: string;
@@ -28,120 +45,74 @@ export declare interface ArtifactRef {
28
45
 
29
46
  export declare type ArtifactType = 'bpmn' | 'dmn' | 'form';
30
47
 
48
+ export declare interface AssistantMessage {
49
+ readonly kind: 'assistant';
50
+ readonly messageId: string;
51
+ readonly turnId: string;
52
+ readonly content: string;
53
+ readonly steps: ReadonlyArray<MessageStep>;
54
+ readonly createdAt: string;
55
+ readonly state: MessageState;
56
+ readonly cancellationReason?: TurnCancellationReason;
57
+ readonly inputDelivery: 'sending' | 'confirmed' | 'unverified';
58
+ readonly remoteStop?: RemoteStopStatus;
59
+ readonly phase?: MessagePhase;
60
+ readonly error?: CopilotError;
61
+ readonly questions?: ReadonlyArray<ConversationQuestion>;
62
+ }
63
+
31
64
  export declare interface BpmnElementReference {
32
65
  readonly artifactId: string;
33
66
  readonly elementId: string;
34
67
  }
35
68
 
36
- export declare interface Candidate {
37
- readonly candidateId: string;
38
- readonly messageId: string;
39
- readonly state: CandidateState;
40
- readonly changes: ReadonlyArray<ArtifactChange>;
41
- readonly checkpointId?: string;
42
- }
43
-
44
- export declare const CandidateReview: ({ candidate, onReviewReady }: CandidateReviewProps) => JSX.Element;
69
+ export declare const closeSidecar: () => void;
45
70
 
46
- export declare interface CandidateReviewProps {
47
- readonly candidate: Candidate;
48
- readonly onReviewReady?: (ready: boolean) => void;
71
+ export declare interface ContextRef {
72
+ readonly type: 'project';
73
+ readonly id: string;
74
+ readonly availability: 'available' | 'deleted' | 'no_access';
49
75
  }
50
76
 
51
- export declare type CandidateState = 'proposed' | 'applied' | 'rejected' | 'cancelled' | 'stale';
52
-
53
- export declare const closeSidecar: () => void;
54
-
55
77
  export declare interface Conversation extends ConversationSummary {
78
+ readonly context: ReadonlyArray<ContextRef>;
56
79
  readonly messages: ReadonlyArray<ConversationMessage>;
80
+ readonly availability?: OrganizationAvailability;
57
81
  readonly verificationHealth?: VerificationHealth | null;
58
- readonly sourceChangedMessageId?: string | null;
82
+ readonly draft: Draft | null;
83
+ readonly lastApply?: {
84
+ readonly applyId: string;
85
+ readonly undoable: boolean;
86
+ readonly artifacts: ReadonlyArray<ArtifactRef>;
87
+ };
59
88
  }
60
89
 
61
90
  export declare const CONVERSATION_NAME_MAX_LENGTH = 100;
62
91
 
63
- export declare type ConversationEvent = {
64
- readonly revision?: number;
65
- } & ({
66
- readonly type: 'question_requested' | 'question_answered' | 'question_delivery_changed';
67
- readonly messageId: string;
68
- readonly question: ConversationQuestion;
69
- } | {
70
- readonly type: 'turn_started';
71
- readonly messageId: string;
72
- readonly userMessageId: string;
73
- readonly userContent: string;
74
- } | {
75
- readonly type: 'turn_finished';
76
- readonly messageId: string;
77
- readonly outcome: 'complete' | 'cancelled';
78
- } | {
79
- readonly type: 'candidate_proposed';
80
- readonly messageId: string;
81
- readonly candidateId: string;
82
- } | {
83
- readonly type: 'candidate_resolved';
84
- readonly messageId: string;
85
- readonly candidateId: string;
86
- readonly state: CandidateState;
87
- readonly checkpointId?: string;
88
- } | {
89
- readonly type: 'checkpoint_restored';
90
- readonly checkpointId: string;
91
- readonly contents: ReadonlyArray<{
92
- readonly name: string;
93
- readonly content: string | null;
94
- }>;
95
- } | {
96
- readonly type: 'failed';
97
- readonly messageId: string;
98
- readonly error: CopilotError;
99
- } | {
100
- readonly type: 'text';
101
- readonly messageId: string;
102
- readonly delta: string;
103
- } | {
104
- readonly type: 'activity';
105
- readonly messageId: string;
106
- readonly label: string;
107
- } | {
108
- readonly type: 'step_start';
109
- readonly messageId: string;
110
- readonly stepId: string;
111
- readonly kind: StepKind;
112
- readonly artifacts?: readonly ArtifactRef[];
113
- readonly name?: string;
114
- readonly label: string;
115
- readonly description?: string;
116
- readonly groupId?: string;
117
- readonly startedAt?: string;
118
- } | {
119
- readonly type: 'step_end';
120
- readonly messageId: string;
121
- readonly stepId: string;
122
- readonly status: 'complete' | 'error';
123
- readonly description?: string;
124
- } | {
125
- readonly type: 'step_removed';
126
- readonly messageId: string;
127
- readonly stepId: string;
128
- } | {
129
- readonly type: 'source_changed';
130
- readonly messageId: string;
131
- });
92
+ export declare type ConversationChanges = Omit<Conversation, 'messages' | 'draft'> & Partial<Pick<Conversation, 'draft'>> & {
93
+ readonly messages: readonly ConversationMessageRow[];
94
+ };
132
95
 
133
- export declare interface ConversationMessage {
134
- readonly messageId: string;
135
- readonly role: 'user' | 'assistant';
136
- readonly content: string;
137
- readonly steps: ReadonlyArray<MessageStep>;
138
- readonly createdAt?: string;
139
- readonly state?: MessageState;
140
- readonly candidate?: Candidate;
141
- readonly error?: CopilotError;
142
- readonly questions?: ReadonlyArray<ConversationQuestion>;
96
+ export declare type ConversationEvent = RevisionedConversationEvent | {
97
+ readonly type: 'availability_changed';
98
+ readonly conversationId: string;
99
+ readonly revision: number;
100
+ };
101
+
102
+ export declare type ConversationMessage = UserMessage | AssistantMessage | EventMessage;
103
+
104
+ export declare interface ConversationMessagePage {
105
+ readonly messages: readonly ConversationMessageRow[];
106
+ readonly olderCursor: string | null;
143
107
  }
144
108
 
109
+ export declare type ConversationMessageRow = ConversationMessage & {
110
+ readonly sequence: number;
111
+ readonly revision: number;
112
+ };
113
+
114
+ export declare type ConversationPage = Omit<Conversation, 'messages'> & ConversationMessagePage;
115
+
145
116
  export declare interface ConversationQuestion {
146
117
  readonly questionId: string;
147
118
  readonly messageId: string;
@@ -164,19 +135,33 @@ export declare interface ConversationQuestion {
164
135
  readonly createdAt: string;
165
136
  }
166
137
 
138
+ export declare interface ConversationRevisionNotice {
139
+ readonly chatId: string;
140
+ readonly revision: number;
141
+ readonly reset?: true;
142
+ }
143
+
167
144
  export declare type ConversationStatus = 'idle' | 'running';
168
145
 
169
146
  declare interface ConversationStoreState {
170
147
  readonly conversationId: string | null;
171
148
  readonly revision?: number;
172
149
  readonly snapshotRevision?: number;
150
+ readonly draftRevision?: number;
151
+ readonly rows?: readonly ConversationMessageRow[];
152
+ readonly olderCursor?: string | null;
153
+ readonly oldestLoadedSequence?: number;
173
154
  readonly status: ConversationStatus | null;
174
155
  readonly verificationHealth: VerificationHealth | null;
175
- readonly sourceChangedMessageId: string | null;
176
156
  readonly name: string | null;
177
- readonly originArtifact: ArtifactRef | null;
157
+ readonly entryPoint: ArtifactRef | null;
178
158
  readonly preview: string;
179
- readonly pendingCandidate: boolean;
159
+ readonly hasOpenDraft: boolean;
160
+ readonly pendingMessageCount: number;
161
+ readonly availability: OrganizationAvailability | null;
162
+ readonly context: Conversation['context'];
163
+ readonly draft: Draft | null;
164
+ readonly lastApply: Conversation['lastApply'] | null;
180
165
  readonly pendingQuestionId?: string;
181
166
  readonly messages: ReadonlyArray<MessageStoreState>;
182
167
  readonly messagesLoaded: boolean;
@@ -184,12 +169,13 @@ declare interface ConversationStoreState {
184
169
 
185
170
  export declare interface ConversationSummary {
186
171
  readonly conversationId: string;
187
- readonly revision?: number;
172
+ readonly revision: number;
188
173
  readonly status: ConversationStatus;
189
174
  readonly name?: string;
190
- readonly originArtifact?: ArtifactRef;
175
+ readonly entryPoint?: ArtifactRef;
191
176
  readonly preview: string;
192
- readonly pendingCandidate: boolean;
177
+ readonly hasOpenDraft: boolean;
178
+ readonly pendingMessageCount: number;
193
179
  readonly pendingQuestionId?: string;
194
180
  }
195
181
 
@@ -205,22 +191,41 @@ export declare interface CopilotBadgeProps {
205
191
  }
206
192
 
207
193
  export declare interface CopilotClient {
208
- answerQuestion?(input: AnswerQuestionInput): Promise<void>;
209
- postMessage(input: PostMessageInput): Promise<{
210
- conversationId: string;
211
- }>;
212
- observe(conversationId: string, onEvent: (event: ConversationEvent) => void, onConnected?: () => void, onError?: (error: Error) => void): () => void;
213
- getConversation(conversationId: string): Promise<Conversation>;
194
+ getAvailability(): Promise<OrganizationAvailability>;
195
+ answerQuestion(input: AnswerQuestionInput): Promise<ConversationQuestion>;
196
+ postMessage(input: PostMessageInput): Promise<PostMessageResult>;
197
+ observe(conversationId: string, onRevision: (notice: ConversationRevisionNotice) => void, onConnected?: () => void, onError?: (error: Error) => void): () => void;
198
+ getConversation(conversationId: string): Promise<ConversationPage>;
199
+ getOlderMessages(conversationId: string, cursor: string): Promise<ConversationMessagePage>;
200
+ getChanges(conversationId: string, since: number): Promise<ConversationChanges>;
214
201
  listConversations(): Promise<ReadonlyArray<ConversationSummary>>;
215
- observeConversationList?(onSummary: (summary: ConversationSummary) => void, onConnected?: () => void, onError?: (error: Error) => void): () => void;
216
- renameConversation?(conversationId: string, name: string): Promise<ConversationSummary>;
217
- approve(candidateId: string): Promise<void>;
218
- reject(candidateId: string): Promise<void>;
219
- restoreCheckpoint(checkpointId: string): Promise<void>;
220
- cancelTurn(conversationId: string): Promise<void>;
202
+ observeConversationList(onSummary: (summary: ConversationSummary) => void, onConnected?: () => void, onError?: (error: Error) => void): () => void;
203
+ renameConversation(conversationId: string, name: string): Promise<ConversationSummary>;
204
+ deleteConversation(conversationId: string): Promise<void>;
205
+ sendHeldMessages(conversationId: string): Promise<void>;
206
+ retryMessage(conversationId: string, messageId: string): Promise<void>;
207
+ cancelMessage(conversationId: string, messageId: string): Promise<void>;
208
+ resendTurnInput(conversationId: string, turnId: string): Promise<void>;
209
+ stopTurn(conversationId: string): Promise<void>;
210
+ applyDraft(input: ApplyDraftInput): Promise<ApplyDraftResult>;
211
+ discardDraft(input: {
212
+ readonly conversationId: string;
213
+ readonly draftId: string;
214
+ readonly artifactKeys?: ReadonlyArray<string>;
215
+ }): Promise<void>;
216
+ revertDraft(input: {
217
+ readonly conversationId: string;
218
+ readonly draftId: string;
219
+ readonly beforeTurnId: string;
220
+ }): Promise<void>;
221
+ updateDraftFromLive(input: {
222
+ readonly conversationId: string;
223
+ readonly submissionId: string;
224
+ }): Promise<PostMessageResult>;
225
+ undoApply(conversationId: string, applyId: string): Promise<void>;
221
226
  }
222
227
 
223
- export declare const CopilotConversationPanel: ({ client, conversationId, onConversationStarted, onSelectConversation, projectName, projectNameUnavailable, readOnlyReason, onOpenProject, onClose, renderReview, renderElementReference, artifacts, suggestions, selectionContext, }: CopilotConversationPanelProps) => JSX.Element;
228
+ export declare const CopilotConversationPanel: ({ client, conversationId, onConversationStarted, onSelectConversation, projectName, projectNameUnavailable, readOnlyReason, onOpenProject, onClose, openDraftReview, renderElementReference, artifacts, suggestions, selectionContext, }: CopilotConversationPanelProps) => JSX.Element;
224
229
 
225
230
  export declare interface CopilotConversationPanelProps {
226
231
  readonly client: CopilotClient;
@@ -232,10 +237,9 @@ export declare interface CopilotConversationPanelProps {
232
237
  readonly readOnlyReason?: string;
233
238
  readonly onOpenProject?: (projectId: string) => void;
234
239
  readonly onClose?: () => void;
235
- readonly renderReview?: (candidate: Candidate, actions: {
236
- approve: () => Promise<void>;
237
- reject: () => Promise<void>;
238
- }) => ReactNode;
240
+ readonly openDraftReview: (input: OpenDraftReviewInput) => void;
241
+ /** @deprecated Retained for host compatibility. Chat restore uses `undoApply`. */
242
+ readonly openVersionHistory?: (fileId: string) => void;
239
243
  readonly artifacts?: ReadonlyArray<ArtifactRef>;
240
244
  readonly suggestions?: ReadonlyArray<string>;
241
245
  readonly selectionContext?: {
@@ -251,7 +255,7 @@ export declare interface CopilotError {
251
255
  readonly traceRef?: string;
252
256
  }
253
257
 
254
- export declare type CopilotErrorCode = 'PROVIDER_ERROR' | 'CANCELLED' | 'VALIDATION_FAILED' | 'BUDGET_EXCEEDED' | 'STALE_SOURCE';
258
+ export declare type CopilotErrorCode = 'PROVIDER_ERROR' | 'CANCELLED' | 'VALIDATION_FAILED' | 'BUDGET_EXCEEDED' | 'STALE_SOURCE' | 'SUBMISSION_UNVERIFIED' | 'PERMISSION_POLICY_UNVERIFIED';
255
259
 
256
260
  export declare const CopilotSidecar: ({ children }: CopilotSidecarProps) => JSX.Element;
257
261
 
@@ -263,6 +267,41 @@ export declare const createFixtureClient: (options?: FixtureClientOptions) => Co
263
267
 
264
268
  export declare const createHttpClient: (options: HttpClientOptions) => CopilotClient;
265
269
 
270
+ export declare interface Draft {
271
+ readonly draftId: string;
272
+ readonly generation: number;
273
+ readonly writable: boolean;
274
+ readonly artifacts: ReadonlyArray<DraftArtifact>;
275
+ readonly steps: ReadonlyArray<DraftStep>;
276
+ }
277
+
278
+ export declare interface DraftArtifact {
279
+ readonly artifactKey: string;
280
+ readonly artifact: ArtifactRef;
281
+ readonly change: 'create' | 'modify' | 'delete' | 'rename' | 'move';
282
+ readonly fromIncompleteTurn: boolean;
283
+ readonly access: 'edit' | 'read' | 'none';
284
+ readonly divergence?: {
285
+ readonly kind: 'edited' | 'renamed' | 'moved' | 'deleted';
286
+ readonly liveFingerprint: string;
287
+ readonly by?: UserRef;
288
+ readonly at?: string;
289
+ };
290
+ readonly otherConversationIds: ReadonlyArray<string>;
291
+ readonly validationMessages?: ReadonlyArray<string>;
292
+ }
293
+
294
+ export declare type DraftArtifactView = 'draft' | 'diff' | 'live';
295
+
296
+ export declare interface DraftStep {
297
+ readonly stepId: string;
298
+ readonly kind: DraftStepKind;
299
+ readonly turnId?: string;
300
+ readonly reverted: boolean;
301
+ }
302
+
303
+ export declare type DraftStepKind = 'turn' | 'user_edits' | 'revert' | 'discard' | 'transfer';
304
+
266
305
  export declare type ElementReferenceRenderer = (reference: BpmnElementReference, context: {
267
306
  readonly label: string;
268
307
  readonly messageId: string;
@@ -271,6 +310,12 @@ export declare type ElementReferenceRenderer = (reference: BpmnElementReference,
271
310
 
272
311
  export declare const encodeBpmnElementReference: (reference: BpmnElementReference) => string;
273
312
 
313
+ export declare interface EventMessage {
314
+ readonly kind: 'event';
315
+ readonly messageId: string;
316
+ readonly event: TranscriptEvent;
317
+ }
318
+
274
319
  export declare interface EventSourceLike {
275
320
  onmessage: ((message: {
276
321
  data: string;
@@ -280,19 +325,30 @@ export declare interface EventSourceLike {
280
325
  close(): void;
281
326
  }
282
327
 
328
+ export declare interface FixtureArtifactChange {
329
+ readonly changeKind: 'create' | 'modify';
330
+ readonly artifact: ArtifactRef;
331
+ readonly content: string;
332
+ readonly before?: string;
333
+ readonly validationMessages?: ReadonlyArray<string>;
334
+ }
335
+
283
336
  export declare interface FixtureClientOptions {
284
337
  readonly resolveScript?: (input: PostMessageInput) => FixtureScript;
285
- readonly originArtifact?: ArtifactRef;
338
+ readonly entryPoint?: ArtifactRef;
286
339
  readonly timing?: FixtureTiming;
340
+ readonly onDraftApplied?: (changes: ReadonlyArray<FixtureArtifactChange>) => void;
341
+ readonly onApplyUndone?: (changes: ReadonlyArray<FixtureArtifactChange>) => void;
287
342
  }
288
343
 
289
344
  export declare interface FixtureScript {
290
345
  readonly outcome: 'answer' | 'propose' | 'failed' | 'run_forever';
291
346
  readonly answer?: string;
292
- readonly changes?: ReadonlyArray<ArtifactChange>;
347
+ readonly changes?: ReadonlyArray<FixtureArtifactChange>;
293
348
  readonly error?: CopilotError;
294
349
  readonly stepLabels?: ReadonlyArray<string>;
295
350
  readonly continuationStepLabels?: ReadonlyArray<string>;
351
+ readonly reconcileHistory?: boolean;
296
352
  readonly question?: Pick<ConversationQuestion, 'question' | 'mode' | 'options' | 'allowCustomAnswer'>;
297
353
  }
298
354
 
@@ -308,6 +364,8 @@ export declare interface HttpClientOptions {
308
364
  readonly eventSource?: new (url: string) => EventSourceLike;
309
365
  }
310
366
 
367
+ export declare type MessagePhase = 'reconciling_history';
368
+
311
369
  export declare type MessageState = 'streaming' | 'complete' | 'cancelled' | 'failed';
312
370
 
313
371
  export declare interface MessageStep {
@@ -322,21 +380,28 @@ export declare interface MessageStep {
322
380
  readonly startedAt?: string;
323
381
  }
324
382
 
325
- declare interface MessageStoreState {
326
- readonly messageId: string;
327
- readonly role: 'user' | 'assistant';
328
- readonly content: string;
329
- readonly steps: ReadonlyArray<MessageStep>;
330
- readonly createdAt: string | null;
383
+ declare type MessageStoreState = ConversationMessage & {
331
384
  readonly activity: string | null;
332
- readonly state: MessageState | null;
333
- readonly candidate: Candidate | null;
334
- readonly error: CopilotError | null;
335
- readonly questions?: ReadonlyArray<ConversationQuestion>;
385
+ };
386
+
387
+ export declare interface OpenDraftArtifactInput {
388
+ readonly conversationId: string;
389
+ readonly artifactKey: string;
390
+ readonly view: DraftArtifactView;
391
+ }
392
+
393
+ export declare interface OpenDraftReviewInput {
394
+ readonly conversationId: string;
395
+ readonly draftId: string;
336
396
  }
337
397
 
338
398
  export declare const openSidecar: () => void;
339
399
 
400
+ export declare interface OrganizationAvailability {
401
+ readonly state: 'enabled' | 'organization_disabled';
402
+ readonly policyVersion: string;
403
+ }
404
+
340
405
  export declare const parseBpmnElementReference: (destination: string) => {
341
406
  readonly kind: "ordinary";
342
407
  } | {
@@ -346,13 +411,123 @@ export declare const parseBpmnElementReference: (destination: string) => {
346
411
  readonly reference: BpmnElementReference;
347
412
  };
348
413
 
349
- export declare interface PostMessageInput {
414
+ declare interface PostMessageFields {
415
+ readonly submissionId: string;
350
416
  readonly prompt: string;
351
- readonly conversationId?: string;
352
- readonly context?: Record<string, unknown>;
353
- readonly reapplyCandidateId?: string;
417
+ readonly focus?: Record<string, unknown>;
418
+ readonly context?: ReadonlyArray<ContextRef>;
354
419
  }
355
420
 
421
+ export declare type PostMessageInput = PostMessageFields & ({
422
+ readonly conversationId: string;
423
+ readonly newConversationId?: never;
424
+ } | {
425
+ readonly conversationId?: never;
426
+ readonly newConversationId: string;
427
+ });
428
+
429
+ export declare interface PostMessageResult {
430
+ readonly conversationId: string;
431
+ readonly messageId: string;
432
+ readonly delivery: 'delivered' | 'pending' | 'answered_question';
433
+ }
434
+
435
+ export declare type RemoteStopStatus = 'not_sent' | 'pending' | 'confirmed' | 'unconfirmed';
436
+
437
+ declare type RevisionedConversationEvent = {
438
+ readonly revision: number;
439
+ } & ({
440
+ readonly type: 'question_requested' | 'question_answered' | 'question_delivery_changed';
441
+ readonly messageId: string;
442
+ readonly question: ConversationQuestion;
443
+ } | {
444
+ readonly type: 'turn_started';
445
+ readonly turnId: string;
446
+ readonly assistantMessageId: string;
447
+ readonly userMessageIds: ReadonlyArray<string>;
448
+ } | ({
449
+ readonly type: 'turn_finished';
450
+ readonly turnId: string;
451
+ readonly assistantMessageId: string;
452
+ readonly outcome: 'complete';
453
+ } & {
454
+ readonly cancellationReason?: never;
455
+ readonly error?: never;
456
+ }) | ({
457
+ readonly type: 'turn_finished';
458
+ readonly turnId: string;
459
+ readonly assistantMessageId: string;
460
+ readonly outcome: 'cancelled';
461
+ readonly cancellationReason?: TurnCancellationReason;
462
+ } & {
463
+ readonly error?: never;
464
+ }) | {
465
+ readonly type: 'turn_finished';
466
+ readonly turnId: string;
467
+ readonly assistantMessageId: string;
468
+ readonly outcome: 'failed';
469
+ readonly error: CopilotError;
470
+ readonly cancellationReason?: never;
471
+ } | {
472
+ readonly type: 'turn_input_delivery';
473
+ readonly turnId: string;
474
+ readonly inputDelivery: 'sending' | 'confirmed' | 'unverified';
475
+ } | {
476
+ readonly type: 'message_delivery';
477
+ readonly messageId: string;
478
+ readonly delivery: 'delivered' | 'pending' | 'held' | 'failed' | 'cancelled';
479
+ readonly deliveryError?: CopilotError;
480
+ } | {
481
+ readonly type: 'draft_changed';
482
+ readonly draftId: string;
483
+ readonly generation: number;
484
+ } | {
485
+ readonly type: 'draft_resolved';
486
+ readonly draftId: string;
487
+ readonly outcome: 'applied';
488
+ readonly applyId: string;
489
+ } | {
490
+ readonly type: 'draft_resolved';
491
+ readonly draftId: string;
492
+ readonly outcome: 'discarded' | 'transferred';
493
+ readonly applyId?: never;
494
+ } | {
495
+ readonly type: 'apply_undone';
496
+ readonly applyId: string;
497
+ readonly artifacts: ReadonlyArray<ArtifactRef>;
498
+ } | {
499
+ readonly type: 'text';
500
+ readonly messageId: string;
501
+ readonly delta: string;
502
+ } | {
503
+ readonly type: 'activity';
504
+ readonly messageId: string;
505
+ readonly label?: string;
506
+ readonly phase?: MessagePhase | null;
507
+ readonly remoteStop?: RemoteStopStatus;
508
+ } | {
509
+ readonly type: 'step_start';
510
+ readonly messageId: string;
511
+ readonly stepId: string;
512
+ readonly kind: StepKind;
513
+ readonly artifacts?: readonly ArtifactRef[];
514
+ readonly name?: string;
515
+ readonly label: string;
516
+ readonly description?: string;
517
+ readonly groupId?: string;
518
+ readonly startedAt?: string;
519
+ } | {
520
+ readonly type: 'step_end';
521
+ readonly messageId: string;
522
+ readonly stepId: string;
523
+ readonly status: 'complete' | 'error';
524
+ readonly description?: string;
525
+ } | {
526
+ readonly type: 'step_removed';
527
+ readonly messageId: string;
528
+ readonly stepId: string;
529
+ });
530
+
356
531
  export declare interface SidecarRenderProps {
357
532
  readonly onMinimize: () => void;
358
533
  readonly isOpen: boolean;
@@ -364,27 +539,76 @@ export declare type StepStatus = 'active' | 'complete' | 'error';
364
539
 
365
540
  export declare const toggleSidecar: () => void;
366
541
 
542
+ export declare type TranscriptEvent = {
543
+ readonly type: 'draft_applied';
544
+ readonly draftId: string;
545
+ readonly applyId: string;
546
+ readonly generation: number;
547
+ readonly artifacts: ReadonlyArray<ArtifactRef>;
548
+ } | {
549
+ readonly type: 'draft_discarded';
550
+ readonly draftId: string;
551
+ readonly generation: number;
552
+ readonly artifactKeys: ReadonlyArray<string>;
553
+ } | {
554
+ readonly type: 'draft_reverted';
555
+ readonly draftId: string;
556
+ readonly beforeTurnId: string;
557
+ readonly generation: number;
558
+ readonly stepId: string;
559
+ readonly revertedStepIds: ReadonlyArray<string>;
560
+ } | {
561
+ readonly type: 'apply_undone';
562
+ readonly applyId: string;
563
+ readonly artifacts: ReadonlyArray<ArtifactRef>;
564
+ } | {
565
+ readonly type: 'continued_from';
566
+ readonly conversationId: string;
567
+ readonly sourceConversationId: string;
568
+ readonly sourceDraftId?: string;
569
+ };
570
+
571
+ export declare type TurnCancellationReason = 'user_stop' | 'redirected' | 'chat_deleted' | 'organization_disabled';
572
+
367
573
  export declare const useCopilotConversation: ({ client, conversationId, }: UseCopilotConversationOptions) => {
368
- conversationId: string | null;
369
- status: ConversationStatus | null;
370
- originArtifact: ArtifactRef | null;
574
+ refreshAvailability: () => Promise<OrganizationAvailability>;
575
+ entryPoint: ArtifactRef | null;
371
576
  messages: readonly MessageStoreState[];
372
577
  messagesLoaded: boolean;
373
- pendingCandidate: boolean;
578
+ hasOlderMessages: boolean;
579
+ loadOlderMessages: () => Promise<void>;
580
+ hasOpenDraft: boolean;
581
+ pendingMessageCount: number;
582
+ draft: Draft | null;
583
+ lastApply: {
584
+ readonly applyId: string;
585
+ readonly undoable: boolean;
586
+ readonly artifacts: ReadonlyArray<ArtifactRef>;
587
+ } | null | undefined;
588
+ context: readonly ContextRef[];
374
589
  pendingQuestion: ConversationQuestion | undefined;
375
- supportsQuestions: boolean;
376
590
  answerQuestion: (input: AnswerQuestionInput) => Promise<void>;
377
591
  isRunning: boolean;
378
- sourceChangedMessageId: string | null;
379
592
  synchronizationError: Error | null;
380
593
  verificationWarning: boolean;
381
- postMessage: (prompt: string) => Promise<string>;
382
- reapply: (candidateId: string, prompt?: string) => Promise<void>;
594
+ postMessage: (prompt: string) => Promise<PostMessageResult>;
595
+ applyDraft: (input: Parameters<CopilotClient["applyDraft"]>[0]) => Promise<ApplyDraftResult>;
596
+ discardDraft: (input: Parameters<CopilotClient["discardDraft"]>[0]) => Promise<void>;
597
+ revertDraft: (input: Parameters<CopilotClient["revertDraft"]>[0]) => Promise<void>;
598
+ updateDraftFromLive: () => Promise<PostMessageResult>;
599
+ undoApply: (applyId: string) => Promise<void>;
600
+ sendHeldMessages: () => Promise<void>;
601
+ retryMessage: (messageId: string) => Promise<void>;
602
+ cancelMessage: (messageId: string) => Promise<void>;
603
+ resendTurnInput: (turnId: string) => Promise<void>;
604
+ stopTurn: () => Promise<void>;
383
605
  refresh: () => Promise<void>;
384
- approve: (candidateId: string) => Promise<void>;
385
- reject: (candidateId: string) => Promise<void>;
386
- restoreCheckpoint: (checkpointId: string) => Promise<void>;
387
- cancelTurn: () => Promise<void>;
606
+ availability: OrganizationAvailability | null;
607
+ availabilityLoading: boolean;
608
+ availabilityError: Error | null;
609
+ availabilityCheckSupported: boolean;
610
+ conversationId: string | null;
611
+ status: ConversationStatus | null;
388
612
  };
389
613
 
390
614
  export declare const useCopilotConversationList: ({ client }: UseCopilotConversationListOptions) => {
@@ -405,6 +629,21 @@ export declare interface UseCopilotConversationOptions {
405
629
  readonly conversationId: string | null;
406
630
  }
407
631
 
632
+ export declare interface UserMessage {
633
+ readonly kind: 'user';
634
+ readonly messageId: string;
635
+ readonly turnId?: string;
636
+ readonly content: string;
637
+ readonly createdAt: string;
638
+ readonly delivery?: 'pending' | 'held' | 'failed' | 'cancelled';
639
+ readonly deliveryError?: CopilotError;
640
+ }
641
+
642
+ export declare interface UserRef {
643
+ readonly id: string;
644
+ readonly name: string;
645
+ }
646
+
408
647
  export declare const useSidecarOpen: () => boolean;
409
648
 
410
649
  /** ISO 8601 provider-verification timestamps for one assistant message, not a terminal state. */