@theia/ai-tool-sketchpad 1.74.0-next.53
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 +44 -0
- package/lib/browser/frontend-module.d.ts +5 -0
- package/lib/browser/frontend-module.d.ts.map +1 -0
- package/lib/browser/frontend-module.js +41 -0
- package/lib/browser/frontend-module.js.map +1 -0
- package/lib/browser/index.d.ts +4 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +22 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/sketched-tool-contribution.d.ts +7 -0
- package/lib/browser/sketched-tool-contribution.d.ts.map +1 -0
- package/lib/browser/sketched-tool-contribution.js +42 -0
- package/lib/browser/sketched-tool-contribution.js.map +1 -0
- package/lib/browser/sketched-tool-service.d.ts +37 -0
- package/lib/browser/sketched-tool-service.d.ts.map +1 -0
- package/lib/browser/sketched-tool-service.js +266 -0
- package/lib/browser/sketched-tool-service.js.map +1 -0
- package/lib/browser/sketched-tool-widget.d.ts +23 -0
- package/lib/browser/sketched-tool-widget.d.ts.map +1 -0
- package/lib/browser/sketched-tool-widget.js +455 -0
- package/lib/browser/sketched-tool-widget.js.map +1 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +20 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/sketched-tool.d.ts +51 -0
- package/lib/common/sketched-tool.d.ts.map +1 -0
- package/lib/common/sketched-tool.js +85 -0
- package/lib/common/sketched-tool.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +24 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +52 -0
- package/src/browser/frontend-module.ts +43 -0
- package/src/browser/index.ts +19 -0
- package/src/browser/sketched-tool-contribution.ts +37 -0
- package/src/browser/sketched-tool-service.ts +282 -0
- package/src/browser/sketched-tool-widget.tsx +707 -0
- package/src/browser/style/index.css +387 -0
- package/src/common/index.ts +17 -0
- package/src/common/sketched-tool.ts +118 -0
- package/src/package.spec.ts +25 -0
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (C) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
/* ===== Main Layout ===== */
|
|
18
|
+
.ai-sketchpad-widget {
|
|
19
|
+
height: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.ai-sketchpad-container {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: row;
|
|
25
|
+
height: 100%;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* ===== List Panel ===== */
|
|
30
|
+
.ai-sketchpad-list {
|
|
31
|
+
width: 240px;
|
|
32
|
+
min-width: 180px;
|
|
33
|
+
max-width: 320px;
|
|
34
|
+
border-right: var(--theia-border-width) solid var(--theia-widget-border);
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ai-sketchpad-list ul {
|
|
41
|
+
list-style: none;
|
|
42
|
+
padding: 0;
|
|
43
|
+
margin: 0;
|
|
44
|
+
flex: 1;
|
|
45
|
+
overflow-y: auto;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.ai-sketchpad-list-empty {
|
|
49
|
+
flex: 1;
|
|
50
|
+
padding: var(--theia-ui-padding);
|
|
51
|
+
color: var(--theia-descriptionForeground);
|
|
52
|
+
font-style: italic;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.ai-sketchpad-list .theia-TreeNode {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
gap: calc(var(--theia-ui-padding) * 0.75);
|
|
59
|
+
padding: calc(var(--theia-ui-padding) * 0.75) var(--theia-ui-padding);
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
user-select: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.ai-sketchpad-list .theia-TreeNode:hover {
|
|
65
|
+
background-color: var(--theia-list-hoverBackground);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ai-sketchpad-list .theia-TreeNode.theia-mod-selected {
|
|
69
|
+
background-color: var(--theia-list-activeSelectionBackground);
|
|
70
|
+
color: var(--theia-list-activeSelectionForeground);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.ai-sketchpad-list-item-icon {
|
|
74
|
+
flex: 0 0 auto;
|
|
75
|
+
color: var(--theia-icon-foreground);
|
|
76
|
+
opacity: 0.8;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.ai-sketchpad-list-item-text {
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
flex: 1;
|
|
83
|
+
min-width: 0;
|
|
84
|
+
line-height: 1.3;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.ai-sketchpad-list-item-label {
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
text-overflow: ellipsis;
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.ai-sketchpad-list-item-meta {
|
|
94
|
+
font-size: var(--theia-ui-font-size0);
|
|
95
|
+
color: var(--theia-descriptionForeground);
|
|
96
|
+
overflow: hidden;
|
|
97
|
+
text-overflow: ellipsis;
|
|
98
|
+
white-space: nowrap;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Keep icon and meta legible against the selection highlight. */
|
|
102
|
+
.ai-sketchpad-list .theia-TreeNode.theia-mod-selected .ai-sketchpad-list-item-icon,
|
|
103
|
+
.ai-sketchpad-list .theia-TreeNode.theia-mod-selected .ai-sketchpad-list-item-meta {
|
|
104
|
+
color: inherit;
|
|
105
|
+
opacity: 0.75;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.ai-sketchpad-delete-icon {
|
|
109
|
+
opacity: 0;
|
|
110
|
+
cursor: pointer;
|
|
111
|
+
color: var(--theia-icon-foreground);
|
|
112
|
+
padding: calc(var(--theia-ui-padding) / 3);
|
|
113
|
+
border-radius: calc(var(--theia-ui-padding) / 2);
|
|
114
|
+
transition: opacity 0.15s, background-color 0.15s;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.ai-sketchpad-list .theia-TreeNode:hover .ai-sketchpad-delete-icon {
|
|
118
|
+
opacity: 0.6;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.ai-sketchpad-list .theia-TreeNode:hover .ai-sketchpad-delete-icon:hover {
|
|
122
|
+
opacity: 1;
|
|
123
|
+
background-color: var(--theia-list-hoverBackground);
|
|
124
|
+
color: var(--theia-errorForeground);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.ai-sketchpad-add-button {
|
|
128
|
+
padding: var(--theia-ui-padding);
|
|
129
|
+
border-top: var(--theia-border-width) solid var(--theia-widget-border);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.ai-sketchpad-add-button button {
|
|
133
|
+
width: 100%;
|
|
134
|
+
margin-left: 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* ===== Detail Panel ===== */
|
|
138
|
+
.ai-sketchpad-detail {
|
|
139
|
+
flex: 1;
|
|
140
|
+
overflow-y: auto;
|
|
141
|
+
padding: calc(var(--theia-ui-padding) * 2);
|
|
142
|
+
min-width: 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.ai-sketchpad-empty-state {
|
|
146
|
+
display: flex;
|
|
147
|
+
flex-direction: column;
|
|
148
|
+
align-items: center;
|
|
149
|
+
justify-content: center;
|
|
150
|
+
gap: var(--theia-ui-padding);
|
|
151
|
+
height: 100%;
|
|
152
|
+
text-align: center;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.ai-sketchpad-empty-icon {
|
|
156
|
+
font-size: 32px;
|
|
157
|
+
color: var(--theia-descriptionForeground);
|
|
158
|
+
opacity: 0.5;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.ai-sketchpad-empty-message {
|
|
162
|
+
max-width: 260px;
|
|
163
|
+
color: var(--theia-descriptionForeground);
|
|
164
|
+
font-style: italic;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* ===== Form ===== */
|
|
168
|
+
.ai-sketchpad-form {
|
|
169
|
+
max-width: 700px;
|
|
170
|
+
display: flex;
|
|
171
|
+
flex-direction: column;
|
|
172
|
+
gap: calc(var(--theia-ui-padding) * 2);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* ===== Detail header (live tool signature) ===== */
|
|
176
|
+
.ai-sketchpad-tool-header {
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
gap: calc(var(--theia-ui-padding) * 0.75);
|
|
180
|
+
padding-bottom: calc(var(--theia-ui-padding) * 1.5);
|
|
181
|
+
border-bottom: var(--theia-border-width) solid var(--theia-widget-border);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.ai-sketchpad-tool-title {
|
|
185
|
+
display: flex;
|
|
186
|
+
align-items: center;
|
|
187
|
+
gap: calc(var(--theia-ui-padding) * 0.75);
|
|
188
|
+
min-width: 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.ai-sketchpad-tool-title-icon {
|
|
192
|
+
flex: 0 0 auto;
|
|
193
|
+
font-size: var(--theia-ui-font-size3);
|
|
194
|
+
color: var(--theia-icon-foreground);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.ai-sketchpad-tool-title-name {
|
|
198
|
+
overflow: hidden;
|
|
199
|
+
text-overflow: ellipsis;
|
|
200
|
+
white-space: nowrap;
|
|
201
|
+
font-size: var(--theia-ui-font-size3);
|
|
202
|
+
font-weight: 600;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.ai-sketchpad-mode-badge {
|
|
206
|
+
flex: 0 0 auto;
|
|
207
|
+
margin-left: auto;
|
|
208
|
+
padding: 1px calc(var(--theia-ui-padding) * 0.75);
|
|
209
|
+
border-radius: 999px;
|
|
210
|
+
font-size: var(--theia-ui-font-size0);
|
|
211
|
+
white-space: nowrap;
|
|
212
|
+
background-color: var(--theia-badge-background);
|
|
213
|
+
color: var(--theia-badge-foreground);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.ai-sketchpad-tool-signature {
|
|
217
|
+
overflow-x: auto;
|
|
218
|
+
white-space: pre;
|
|
219
|
+
padding: calc(var(--theia-ui-padding) * 0.5) calc(var(--theia-ui-padding) * 0.75);
|
|
220
|
+
border-left: 2px solid var(--theia-focusBorder);
|
|
221
|
+
border-radius: calc(var(--theia-ui-padding) / 2);
|
|
222
|
+
font-family: var(--theia-code-font-family);
|
|
223
|
+
font-size: var(--theia-code-font-size);
|
|
224
|
+
color: var(--theia-descriptionForeground);
|
|
225
|
+
background-color: var(--theia-textCodeBlock-background);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.ai-sketchpad-form-field {
|
|
229
|
+
display: flex;
|
|
230
|
+
flex-direction: column;
|
|
231
|
+
gap: calc(var(--theia-ui-padding) * 0.5);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.ai-sketchpad-form-field > label {
|
|
235
|
+
font-weight: 600;
|
|
236
|
+
font-size: var(--theia-ui-font-size2);
|
|
237
|
+
color: var(--theia-foreground);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.ai-sketchpad-textarea {
|
|
241
|
+
resize: vertical;
|
|
242
|
+
min-height: 60px;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.ai-sketchpad-textarea-code {
|
|
246
|
+
font-family: var(--theia-code-font-family);
|
|
247
|
+
font-size: var(--theia-code-font-size);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.ai-sketchpad-hint {
|
|
251
|
+
font-size: var(--theia-ui-font-size0);
|
|
252
|
+
color: var(--theia-descriptionForeground);
|
|
253
|
+
font-style: italic;
|
|
254
|
+
margin-top: calc(var(--theia-ui-padding) * 0.25);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/* ===== Parameters ===== */
|
|
258
|
+
.ai-sketchpad-no-params {
|
|
259
|
+
color: var(--theia-descriptionForeground);
|
|
260
|
+
font-style: italic;
|
|
261
|
+
padding: calc(var(--theia-ui-padding) * 0.5) 0;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.ai-sketchpad-param-list {
|
|
265
|
+
display: flex;
|
|
266
|
+
flex-direction: column;
|
|
267
|
+
gap: calc(var(--theia-ui-padding) * 0.5);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.ai-sketchpad-param-item {
|
|
271
|
+
border: var(--theia-border-width) solid var(--theia-widget-border);
|
|
272
|
+
border-radius: calc(var(--theia-ui-padding) * 2 / 3);
|
|
273
|
+
padding: calc(var(--theia-ui-padding) * 0.75);
|
|
274
|
+
background-color: var(--theia-editor-background);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.ai-sketchpad-param-row {
|
|
278
|
+
display: flex;
|
|
279
|
+
align-items: center;
|
|
280
|
+
gap: calc(var(--theia-ui-padding) * 0.5);
|
|
281
|
+
flex-wrap: wrap;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.ai-sketchpad-param-name {
|
|
285
|
+
flex: 1;
|
|
286
|
+
min-width: 100px;
|
|
287
|
+
max-width: 160px;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.ai-sketchpad-param-desc {
|
|
291
|
+
flex: 2;
|
|
292
|
+
min-width: 120px;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.ai-sketchpad-param-type {
|
|
296
|
+
width: 100px;
|
|
297
|
+
height: stretch;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.ai-sketchpad-param-required {
|
|
301
|
+
display: inline-flex;
|
|
302
|
+
align-items: center;
|
|
303
|
+
gap: calc(var(--theia-ui-padding) * 2 / 3);
|
|
304
|
+
padding-left: var(--theia-ui-padding);
|
|
305
|
+
cursor: pointer;
|
|
306
|
+
user-select: none;
|
|
307
|
+
font-size: var(--theia-ui-font-size0);
|
|
308
|
+
color: var(--theia-descriptionForeground);
|
|
309
|
+
white-space: nowrap;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.ai-sketchpad-param-required input[type="checkbox"] {
|
|
313
|
+
margin: 0;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.ai-sketchpad-param-delete {
|
|
317
|
+
cursor: pointer;
|
|
318
|
+
color: var(--theia-icon-foreground);
|
|
319
|
+
padding: calc(var(--theia-ui-padding) / 3);
|
|
320
|
+
border-radius: calc(var(--theia-ui-padding) / 2);
|
|
321
|
+
transition: background-color 0.15s;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.ai-sketchpad-param-delete:hover {
|
|
325
|
+
background-color: var(--theia-list-hoverBackground);
|
|
326
|
+
color: var(--theia-errorForeground);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/* ===== Nested Parameters ===== */
|
|
330
|
+
.ai-sketchpad-param-nested {
|
|
331
|
+
margin-top: calc(var(--theia-ui-padding) * 0.5);
|
|
332
|
+
padding-left: calc(var(--theia-ui-padding) * 1.5);
|
|
333
|
+
border-left: calc(var(--theia-border-width) * 2) solid var(--theia-widget-border);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.ai-sketchpad-param-depth-1 {
|
|
337
|
+
margin-left: calc(var(--theia-ui-padding) * 3);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.ai-sketchpad-param-depth-2 {
|
|
341
|
+
margin-left: calc(var(--theia-ui-padding) * 6);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.ai-sketchpad-add-nested-btn {
|
|
345
|
+
margin-top: calc(var(--theia-ui-padding) * 0.5);
|
|
346
|
+
align-self: flex-start;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.ai-sketchpad-add-param-btn {
|
|
350
|
+
margin-top: calc(var(--theia-ui-padding) * 0.5);
|
|
351
|
+
align-self: flex-start;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/* ===== Array Item Type ===== */
|
|
355
|
+
.ai-sketchpad-param-array-type {
|
|
356
|
+
display: flex;
|
|
357
|
+
align-items: center;
|
|
358
|
+
gap: calc(var(--theia-ui-padding) * 0.5);
|
|
359
|
+
margin-top: calc(var(--theia-ui-padding) * 0.5);
|
|
360
|
+
padding-left: calc(var(--theia-ui-padding) * 1.5);
|
|
361
|
+
font-size: var(--theia-ui-font-size0);
|
|
362
|
+
color: var(--theia-descriptionForeground);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.ai-sketchpad-param-array-type select {
|
|
366
|
+
width: 100px;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/* ===== Validation ===== */
|
|
370
|
+
.ai-sketchpad-input-error {
|
|
371
|
+
border-color: var(--theia-inputValidation-errorBorder) !important;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.ai-sketchpad-error {
|
|
375
|
+
margin-top: calc(var(--theia-ui-padding) * 0.5);
|
|
376
|
+
font-size: var(--theia-ui-font-size0);
|
|
377
|
+
color: var(--theia-errorForeground);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/* ===== Actions ===== */
|
|
381
|
+
.ai-sketchpad-actions {
|
|
382
|
+
display: flex;
|
|
383
|
+
justify-content: flex-end;
|
|
384
|
+
gap: var(--theia-ui-padding);
|
|
385
|
+
padding-top: var(--theia-ui-padding);
|
|
386
|
+
border-top: var(--theia-border-width) solid var(--theia-widget-border);
|
|
387
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 EclipseSource and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
export * from './sketched-tool';
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 EclipseSource and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { Event, nls } from '@theia/core';
|
|
18
|
+
|
|
19
|
+
export type SketchedToolParameterType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array';
|
|
20
|
+
|
|
21
|
+
export type SketchedToolReturnMode = 'static' | 'askAtRuntime';
|
|
22
|
+
|
|
23
|
+
export interface SketchedToolParameterDefinition {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
type: SketchedToolParameterType;
|
|
27
|
+
required?: boolean;
|
|
28
|
+
/** For type 'object': nested properties (max 2 levels) */
|
|
29
|
+
properties?: SketchedToolParameterDefinition[];
|
|
30
|
+
/** For type 'array': item type */
|
|
31
|
+
itemType?: 'string' | 'number' | 'integer' | 'boolean' | 'object';
|
|
32
|
+
/** For type 'array' with itemType 'object': properties of the item object */
|
|
33
|
+
itemProperties?: SketchedToolParameterDefinition[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface SketchedToolDefinition {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
parameters: SketchedToolParameterDefinition[];
|
|
41
|
+
returnMode: SketchedToolReturnMode;
|
|
42
|
+
staticReturn: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export namespace SketchedToolDefinition {
|
|
46
|
+
export function is(obj: unknown): obj is SketchedToolDefinition {
|
|
47
|
+
// eslint-disable-next-line no-null/no-null
|
|
48
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const candidate = obj as Record<string, unknown>;
|
|
52
|
+
if (typeof candidate.id !== 'string' || typeof candidate.name !== 'string') {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (typeof candidate.description !== 'string') {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
if (!Array.isArray(candidate.parameters)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
if (candidate.returnMode !== undefined && candidate.returnMode !== 'static' && candidate.returnMode !== 'askAtRuntime') {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
// returnMode and staticReturn are optional here; normalize() fills in defaults.
|
|
65
|
+
if (candidate.staticReturn !== undefined && typeof candidate.staticReturn !== 'string') {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function normalize(obj: SketchedToolDefinition): SketchedToolDefinition {
|
|
72
|
+
return {
|
|
73
|
+
...obj,
|
|
74
|
+
returnMode: obj.returnMode ?? 'static',
|
|
75
|
+
staticReturn: obj.staticReturn ?? ''
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Pattern accepted as a tool name by most LLM providers (e.g. OpenAI, Anthropic).
|
|
81
|
+
* The name is also used as the id under which the tool is registered, so it must be unique.
|
|
82
|
+
*/
|
|
83
|
+
export const NAME_PATTERN = /^[a-zA-Z0-9_-]{1,128}$/;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Validates a tool name for use as a registered tool id.
|
|
87
|
+
*
|
|
88
|
+
* @param name the name to validate
|
|
89
|
+
* @param existingTools the currently defined tools, used to check for name collisions
|
|
90
|
+
* @param selfId the id of the tool being edited, so it is not compared against itself
|
|
91
|
+
* @returns a localized error message if the name is invalid, otherwise `undefined`
|
|
92
|
+
*/
|
|
93
|
+
export function validateName(name: string, existingTools: SketchedToolDefinition[], selfId?: string): string | undefined {
|
|
94
|
+
const trimmed = name.trim();
|
|
95
|
+
if (!trimmed) {
|
|
96
|
+
return nls.localize('theia/ai-tool-sketchpad/nameEmpty', 'Tool name must not be empty.');
|
|
97
|
+
}
|
|
98
|
+
if (!NAME_PATTERN.test(trimmed)) {
|
|
99
|
+
return nls.localize('theia/ai-tool-sketchpad/nameInvalid',
|
|
100
|
+
'Tool name may only contain letters, digits, underscores and hyphens (1-128 characters).');
|
|
101
|
+
}
|
|
102
|
+
if (existingTools.some(tool => tool.id !== selfId && tool.name.trim() === trimmed)) {
|
|
103
|
+
return nls.localize('theia/ai-tool-sketchpad/nameDuplicate', 'A tool with this name already exists.');
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const SKETCHED_TOOLS_PROVIDER_NAME = 'ai-tool-sketchpad';
|
|
110
|
+
|
|
111
|
+
export const SketchedToolService = Symbol('SketchedToolService');
|
|
112
|
+
export interface SketchedToolService {
|
|
113
|
+
getSketchedTools(): SketchedToolDefinition[];
|
|
114
|
+
addSketchedTool(tool: SketchedToolDefinition): Promise<void>;
|
|
115
|
+
updateSketchedTool(tool: SketchedToolDefinition): Promise<void>;
|
|
116
|
+
removeSketchedTool(toolId: string): Promise<void>;
|
|
117
|
+
onDidChangeSketchedTools: Event<void>;
|
|
118
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 EclipseSource and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* This is a placeholder for tests that the extension package should implement
|
|
19
|
+
* but as yet does not.
|
|
20
|
+
* Please delete this file when a real test is implemented.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
describe('ai-tool-sketchpad package', () => {
|
|
24
|
+
it('placeholder to enable mocha', () => true);
|
|
25
|
+
});
|