jupyter-chat-components 0.2.0 → 0.4.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/lib/factory.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { nullTranslator } from '@jupyterlab/translation';
2
2
  import { ReactWidget } from '@jupyterlab/ui-components';
3
3
  import * as React from 'react';
4
- import { InlineDiff, ToolCall } from './components';
4
+ import { GroupedToolCalls, InlineDiff, MessageQueue, ToolCall } from './components';
5
5
  import { ComponentRegistry } from './registry';
6
6
  /**
7
7
  * The default mime type for the extension.
@@ -26,6 +26,9 @@ export class ComponentsRenderer extends ReactWidget {
26
26
  this._trans = ((_a = options.translator) !== null && _a !== void 0 ? _a : nullTranslator).load('jupyterlab');
27
27
  this._mimeType = options.mimeType;
28
28
  this._toolCallApproval = options.toolCallApproval;
29
+ this._removeQueuedMessage = options.removeQueuedMessage;
30
+ this._toolCallPermissionDecision = options.toolCallPermissionDecision;
31
+ this._openToolCallPath = options.openToolCallPath;
29
32
  this._registry = options.registry;
30
33
  this.addClass(CLASS_NAME);
31
34
  }
@@ -53,6 +56,14 @@ export class ComponentsRenderer extends ReactWidget {
53
56
  if (this._data === 'tool-call') {
54
57
  componentsProps.toolCallApproval = this._toolCallApproval;
55
58
  }
59
+ if (this._data === 'message-queue') {
60
+ componentsProps.removeQueuedMessage = this._removeQueuedMessage;
61
+ }
62
+ if (this._data === 'grouped-tool-calls') {
63
+ componentsProps.toolCallPermissionDecision =
64
+ this._toolCallPermissionDecision;
65
+ componentsProps.openToolCallPath = this._openToolCallPath;
66
+ }
56
67
  return React.createElement(Component, { ...componentsProps, trans: this._trans });
57
68
  }
58
69
  }
@@ -65,15 +76,23 @@ export class RendererFactory {
65
76
  this.mimeTypes = [MIME_TYPE];
66
77
  this.defaultRank = 100;
67
78
  this.toolCallApproval = null;
79
+ this.removeQueuedMessage = null;
80
+ this.toolCallPermissionDecision = null;
81
+ this.openToolCallPath = null;
68
82
  this.createRenderer = (options) => {
69
83
  return new ComponentsRenderer({
70
84
  ...options,
71
85
  toolCallApproval: this.toolCallApproval,
86
+ removeQueuedMessage: this.removeQueuedMessage,
87
+ toolCallPermissionDecision: this.toolCallPermissionDecision,
88
+ openToolCallPath: this.openToolCallPath,
72
89
  registry: this.registry
73
90
  });
74
91
  };
75
92
  this.registry = new ComponentRegistry();
76
93
  this.registry.add('tool-call', ToolCall);
94
+ this.registry.add('grouped-tool-calls', GroupedToolCalls);
77
95
  this.registry.add('inline-diff', InlineDiff);
96
+ this.registry.add('message-queue', MessageQueue);
78
97
  }
79
98
  }
package/lib/token.d.ts CHANGED
@@ -10,6 +10,18 @@ export declare const IComponentsRendererFactory: Token<IComponentsRendererFactor
10
10
  * The callback to approve or reject a tool.
11
11
  */
12
12
  export type ToolCallApproval = ((targetId: string, approvalId: string, approve: boolean) => void) | null;
13
+ /**
14
+ * The callback to submit a tool-call permission decision.
15
+ */
16
+ export type ToolCallPermissionDecision = ((sessionId: string, toolCallId: string, optionId: string) => Promise<void> | void) | null;
17
+ /**
18
+ * The callback to remove a queued message.
19
+ */
20
+ export type RemoveQueuedMessage = ((targetId: string, messageId: string) => void) | null;
21
+ /**
22
+ * The callback to open a file or resource path referenced by a tool call.
23
+ */
24
+ export type OpenToolCallPath = ((path: string) => void) | null;
13
25
  /**
14
26
  * The interface for components renderer factory.
15
27
  */
@@ -22,6 +34,18 @@ export interface IComponentsRendererFactory extends IRenderMime.IRendererFactory
22
34
  * The callback to approve or reject a tool.
23
35
  */
24
36
  toolCallApproval: ToolCallApproval;
37
+ /**
38
+ * The callback to remove a queued message.
39
+ */
40
+ removeQueuedMessage: RemoveQueuedMessage;
41
+ /**
42
+ * The callback to submit a permission decision for grouped tool calls.
43
+ */
44
+ toolCallPermissionDecision: ToolCallPermissionDecision;
45
+ /**
46
+ * The callback to open a path referenced by grouped tool calls.
47
+ */
48
+ openToolCallPath: OpenToolCallPath;
25
49
  }
26
50
  /**
27
51
  * The interface for the component registry.
@@ -65,16 +89,180 @@ export interface IComponentProps {
65
89
  trans: TranslationBundle;
66
90
  }
67
91
  /**
68
- * A single file diff entry.
92
+ * A file diff entry for grouped tool calls.
69
93
  */
70
- export interface IInlineDiff {
94
+ export interface IToolCallDiff {
95
+ /**
96
+ * Path of the file being diffed.
97
+ */
71
98
  path: string;
99
+ /**
100
+ * Updated text content.
101
+ */
72
102
  newText: string;
103
+ /**
104
+ * Previous text content.
105
+ */
106
+ oldText?: string;
107
+ }
108
+ /**
109
+ * A permission option for grouped tool calls.
110
+ */
111
+ export interface IToolCallPermissionOption {
112
+ /**
113
+ * Stable permission option identifier.
114
+ */
115
+ optionId: string;
116
+ /**
117
+ * Human-readable button label.
118
+ */
119
+ name: string;
120
+ /**
121
+ * Optional semantic option kind, such as allow_once or reject_once.
122
+ */
123
+ kind?: string;
124
+ }
125
+ /**
126
+ * A single grouped tool call entry.
127
+ */
128
+ export interface IToolCallsEntry {
129
+ /**
130
+ * Unique tool call identifier.
131
+ */
132
+ toolCallId: string;
133
+ /**
134
+ * Human-readable title displayed in the UI.
135
+ */
136
+ title?: string;
137
+ /**
138
+ * Tool operation category.
139
+ */
140
+ kind?: string;
141
+ /**
142
+ * Current tool call status.
143
+ */
144
+ status?: string;
145
+ /**
146
+ * Tool input payload.
147
+ */
148
+ rawInput?: unknown;
149
+ /**
150
+ * Tool output payload.
151
+ */
152
+ rawOutput?: unknown;
153
+ /**
154
+ * File paths or resource locations referenced by the tool call.
155
+ */
156
+ locations?: string[];
157
+ /**
158
+ * Permission options presented to the user.
159
+ */
160
+ permissionOptions?: IToolCallPermissionOption[];
161
+ /**
162
+ * Permission request lifecycle state.
163
+ */
164
+ permissionStatus?: 'pending' | 'resolved';
165
+ /**
166
+ * Selected permission option identifier.
167
+ */
168
+ selectedOptionId?: string;
169
+ /**
170
+ * Session identifier used to route permission decisions.
171
+ */
172
+ sessionId?: string;
173
+ /**
174
+ * Optional inline file diffs associated with the tool call.
175
+ */
176
+ diffs?: IToolCallDiff[];
177
+ }
178
+ /**
179
+ * Metadata for rendering grouped tool calls.
180
+ */
181
+ export interface IToolCallsMetadata {
182
+ /**
183
+ * List of tool call entries.
184
+ */
185
+ toolCalls: IToolCallsEntry[];
186
+ }
187
+ /**
188
+ * A file diff target.
189
+ */
190
+ export interface IInlineDiffFileTarget {
191
+ /**
192
+ * Discriminator for a regular file diff target.
193
+ */
194
+ kind: 'file';
195
+ /**
196
+ * Path of the file being diffed.
197
+ */
198
+ path: string;
199
+ }
200
+ /**
201
+ * A notebook cell diff target.
202
+ */
203
+ export interface IInlineDiffNotebookCellTarget {
204
+ /**
205
+ * Discriminator for a notebook cell source diff target.
206
+ */
207
+ kind: 'cell';
208
+ /**
209
+ * Path of the notebook containing the cell.
210
+ */
211
+ notebookPath: string;
212
+ /**
213
+ * Stable cell identifier, when available from the producer.
214
+ */
215
+ cellId?: string;
216
+ /**
217
+ * Zero-based notebook cell index used for the default display label.
218
+ */
219
+ cellIndex?: number;
220
+ }
221
+ /**
222
+ * A supported inline diff target.
223
+ */
224
+ export type IInlineDiffTarget = IInlineDiffFileTarget | IInlineDiffNotebookCellTarget;
225
+ /**
226
+ * A single inline diff entry.
227
+ */
228
+ export interface IInlineDiff {
229
+ /**
230
+ * Structured target metadata.
231
+ */
232
+ target: IInlineDiffTarget;
233
+ /**
234
+ * Optional explicit label for the diff header.
235
+ */
236
+ label?: string;
237
+ /**
238
+ * Updated text content for the diff target.
239
+ */
240
+ newText: string;
241
+ /**
242
+ * Previous text content for the diff target.
243
+ */
73
244
  oldText?: string;
74
245
  }
75
246
  /**
76
247
  * Metadata for rendering inline diffs.
77
248
  */
78
249
  export interface IInlineDiffMetadata {
250
+ /**
251
+ * List of inline diff entries to render.
252
+ */
79
253
  diffs: IInlineDiff[];
80
254
  }
255
+ /**
256
+ * A single queued message entry.
257
+ */
258
+ export interface IQueuedMessage {
259
+ id: string;
260
+ body: string;
261
+ }
262
+ /**
263
+ * Metadata for the message queue component.
264
+ */
265
+ export interface IMessageQueueMetadata {
266
+ messages: IQueuedMessage[];
267
+ targetId?: string;
268
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jupyter-chat-components",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Components to displayed in jupyter chat",
5
5
  "keywords": [
6
6
  "jupyter",