@stina/extension-api 0.32.0 → 0.33.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/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/schemas/index.cjs +48 -110
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +2587 -3083
- package/dist/schemas/index.d.ts +2587 -3083
- package/dist/schemas/index.js +47 -101
- package/dist/schemas/index.js.map +1 -1
- package/dist/{types.tools-XIdePk7Z.d.cts → types.tools-CLp-Zw8L.d.cts} +67 -141
- package/dist/{types.tools-XIdePk7Z.d.ts → types.tools-CLp-Zw8L.d.ts} +67 -141
- package/package.json +1 -1
- package/schema/extension-manifest.schema.json +118 -341
- package/src/index.ts +4 -10
- package/src/schemas/components.schema.ts +52 -6
- package/src/schemas/contributions.schema.ts +12 -178
- package/src/schemas/index.ts +2 -18
- package/src/types.components.ts +46 -6
- package/src/types.contributions.ts +23 -142
- package/src/types.ts +1 -9
|
@@ -18,121 +18,6 @@ export const LocalizedStringSchema = z
|
|
|
18
18
|
.union([z.string(), z.record(z.string())])
|
|
19
19
|
.describe('String or localized string map')
|
|
20
20
|
|
|
21
|
-
// =============================================================================
|
|
22
|
-
// Settings
|
|
23
|
-
// =============================================================================
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Options mapping for select field options from tool response
|
|
27
|
-
*/
|
|
28
|
-
export const SettingOptionsMappingSchema = z
|
|
29
|
-
.object({
|
|
30
|
-
itemsKey: z.string().describe('Key for items array in tool result data'),
|
|
31
|
-
valueKey: z.string().describe('Key for option value'),
|
|
32
|
-
labelKey: z.string().describe('Key for option label'),
|
|
33
|
-
descriptionKey: z.string().optional().describe('Optional key for description'),
|
|
34
|
-
})
|
|
35
|
-
.describe('Mapping for select field options')
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Create mapping for create tool response
|
|
39
|
-
*/
|
|
40
|
-
export const SettingCreateMappingSchema = z
|
|
41
|
-
.object({
|
|
42
|
-
resultKey: z.string().optional().describe('Key for result data object'),
|
|
43
|
-
valueKey: z.string().describe('Key for option value (defaults to "id")'),
|
|
44
|
-
})
|
|
45
|
-
.describe('Mapping for create tool response')
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Validation rules for settings
|
|
49
|
-
*/
|
|
50
|
-
export const SettingValidationSchema = z
|
|
51
|
-
.object({
|
|
52
|
-
required: z.boolean().optional().describe('Whether the field is required'),
|
|
53
|
-
min: z.number().optional().describe('Minimum value (number) or length (string)'),
|
|
54
|
-
max: z.number().optional().describe('Maximum value (number) or length (string)'),
|
|
55
|
-
pattern: z.string().optional().describe('Regex pattern for validation'),
|
|
56
|
-
})
|
|
57
|
-
.describe('Validation rules')
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Setting definition type interface for recursive typing
|
|
61
|
-
*/
|
|
62
|
-
export interface SettingDefinitionType {
|
|
63
|
-
id: string
|
|
64
|
-
title: string
|
|
65
|
-
description?: string
|
|
66
|
-
type: 'string' | 'number' | 'boolean' | 'select'
|
|
67
|
-
default?: unknown
|
|
68
|
-
options?: { value: string; label: string }[]
|
|
69
|
-
optionsToolId?: string
|
|
70
|
-
optionsParams?: Record<string, unknown>
|
|
71
|
-
optionsMapping?: z.infer<typeof SettingOptionsMappingSchema>
|
|
72
|
-
createToolId?: string
|
|
73
|
-
createLabel?: string
|
|
74
|
-
createFields?: SettingDefinitionType[]
|
|
75
|
-
createParams?: Record<string, unknown>
|
|
76
|
-
createMapping?: z.infer<typeof SettingCreateMappingSchema>
|
|
77
|
-
validation?: z.infer<typeof SettingValidationSchema>
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export const SettingDefinitionSchema: z.ZodType<SettingDefinitionType> = z.lazy(() =>
|
|
81
|
-
z
|
|
82
|
-
.object({
|
|
83
|
-
id: z.string().describe('Setting ID (namespaced automatically)'),
|
|
84
|
-
title: z.string().describe('Display title'),
|
|
85
|
-
description: z.string().optional().describe('Help text'),
|
|
86
|
-
type: z.enum(['string', 'number', 'boolean', 'select']).describe('Setting type'),
|
|
87
|
-
default: z.unknown().optional().describe('Default value'),
|
|
88
|
-
options: z
|
|
89
|
-
.array(z.object({ value: z.string(), label: z.string() }))
|
|
90
|
-
.optional()
|
|
91
|
-
.describe('For select type: available options'),
|
|
92
|
-
optionsToolId: z.string().optional().describe('For select type: load options from tool'),
|
|
93
|
-
optionsParams: z.record(z.unknown()).optional().describe('Params for options tool'),
|
|
94
|
-
optionsMapping: SettingOptionsMappingSchema.optional().describe('Mapping for options tool response'),
|
|
95
|
-
createToolId: z.string().optional().describe('Tool ID for creating a new option'),
|
|
96
|
-
createLabel: z.string().optional().describe('Label for create action'),
|
|
97
|
-
createFields: z.array(SettingDefinitionSchema).optional().describe('Fields for create form'),
|
|
98
|
-
createParams: z.record(z.unknown()).optional().describe('Static params for create tool'),
|
|
99
|
-
createMapping: SettingCreateMappingSchema.optional().describe('Mapping for create tool response'),
|
|
100
|
-
validation: SettingValidationSchema.optional().describe('Validation rules'),
|
|
101
|
-
})
|
|
102
|
-
.superRefine((data, ctx) => {
|
|
103
|
-
// Validate that create* fields are only used with type: 'select'
|
|
104
|
-
const hasCreateFields =
|
|
105
|
-
data.createToolId !== undefined ||
|
|
106
|
-
data.createLabel !== undefined ||
|
|
107
|
-
data.createFields !== undefined ||
|
|
108
|
-
data.createParams !== undefined ||
|
|
109
|
-
data.createMapping !== undefined
|
|
110
|
-
|
|
111
|
-
if (hasCreateFields && data.type !== 'select') {
|
|
112
|
-
ctx.addIssue({
|
|
113
|
-
code: z.ZodIssueCode.custom,
|
|
114
|
-
message: 'create* fields (createToolId, createLabel, createFields, createParams, createMapping) are only valid for type "select"',
|
|
115
|
-
path: ['type'],
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Validate that select type has options or optionsToolId
|
|
120
|
-
if (data.type === 'select') {
|
|
121
|
-
const hasOptions = data.options && data.options.length > 0
|
|
122
|
-
const hasOptionsToolId = data.optionsToolId !== undefined
|
|
123
|
-
|
|
124
|
-
if (!hasOptions && !hasOptionsToolId) {
|
|
125
|
-
ctx.addIssue({
|
|
126
|
-
code: z.ZodIssueCode.custom,
|
|
127
|
-
message: 'Setting of type "select" must have "options" or "optionsToolId"',
|
|
128
|
-
path: ['type'],
|
|
129
|
-
})
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
})
|
|
133
|
-
.describe('Setting definition')
|
|
134
|
-
)
|
|
135
|
-
|
|
136
21
|
// =============================================================================
|
|
137
22
|
// Tool Settings Views
|
|
138
23
|
// =============================================================================
|
|
@@ -177,6 +62,12 @@ export const ToolSettingsListViewSchema = z
|
|
|
177
62
|
limitParam: z.string().optional().describe('Param name for limit'),
|
|
178
63
|
idParam: z.string().optional().describe('Param name for get/delete ID'),
|
|
179
64
|
listParams: z.record(z.unknown()).optional().describe('Static params for list tool'),
|
|
65
|
+
editView: z
|
|
66
|
+
.object({
|
|
67
|
+
content: ExtensionComponentDataSchema.describe('Root component for the create/edit modal'),
|
|
68
|
+
})
|
|
69
|
+
.optional()
|
|
70
|
+
.describe('Component-tree create/edit form bound to $item.<key>'),
|
|
180
71
|
})
|
|
181
72
|
.describe('List view backed by tools')
|
|
182
73
|
|
|
@@ -207,7 +98,6 @@ export const ToolSettingsViewDefinitionSchema = z
|
|
|
207
98
|
title: z.string().describe('Display title'),
|
|
208
99
|
description: z.string().optional().describe('Help text'),
|
|
209
100
|
view: ToolSettingsViewSchema.describe('View configuration'),
|
|
210
|
-
fields: z.array(SettingDefinitionSchema).optional().describe('Fields for create/edit forms'),
|
|
211
101
|
})
|
|
212
102
|
.describe('Tool settings view definition')
|
|
213
103
|
|
|
@@ -271,60 +161,13 @@ export const PanelDefinitionSchema = z
|
|
|
271
161
|
// =============================================================================
|
|
272
162
|
|
|
273
163
|
/**
|
|
274
|
-
*
|
|
275
|
-
*/
|
|
276
|
-
export const ProviderConfigPropertyTypeSchema = z
|
|
277
|
-
.enum(['string', 'number', 'boolean', 'select', 'password', 'url'])
|
|
278
|
-
.describe('Property type')
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Provider config select option
|
|
164
|
+
* Component-tree-based provider config view.
|
|
282
165
|
*/
|
|
283
|
-
export const
|
|
166
|
+
export const ProviderConfigViewSchema = z
|
|
284
167
|
.object({
|
|
285
|
-
|
|
286
|
-
label: z.string().describe('Display label'),
|
|
287
|
-
})
|
|
288
|
-
.describe('Select option')
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Provider config validation
|
|
292
|
-
*/
|
|
293
|
-
export const ProviderConfigValidationSchema = z
|
|
294
|
-
.object({
|
|
295
|
-
pattern: z.string().optional().describe('Regex pattern the value must match'),
|
|
296
|
-
minLength: z.number().optional().describe('Minimum string length'),
|
|
297
|
-
maxLength: z.number().optional().describe('Maximum string length'),
|
|
298
|
-
min: z.number().optional().describe('Minimum number value'),
|
|
299
|
-
max: z.number().optional().describe('Maximum number value'),
|
|
300
|
-
})
|
|
301
|
-
.describe('Validation rules')
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Provider config property
|
|
305
|
-
*/
|
|
306
|
-
export const ProviderConfigPropertySchema = z
|
|
307
|
-
.object({
|
|
308
|
-
type: ProviderConfigPropertyTypeSchema.describe('Property type'),
|
|
309
|
-
title: z.string().describe('Display label'),
|
|
310
|
-
description: z.string().optional().describe('Help text'),
|
|
311
|
-
default: z.unknown().optional().describe('Default value'),
|
|
312
|
-
required: z.boolean().optional().describe('Whether the field is required'),
|
|
313
|
-
placeholder: z.string().optional().describe('Placeholder text'),
|
|
314
|
-
options: z.array(ProviderConfigSelectOptionSchema).optional().describe('For select type'),
|
|
315
|
-
validation: ProviderConfigValidationSchema.optional().describe('Validation rules'),
|
|
316
|
-
})
|
|
317
|
-
.describe('Provider config property')
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Provider config schema
|
|
321
|
-
*/
|
|
322
|
-
export const ProviderConfigSchemaSchema = z
|
|
323
|
-
.object({
|
|
324
|
-
properties: z.record(ProviderConfigPropertySchema).describe('Property definitions'),
|
|
325
|
-
order: z.array(z.string()).optional().describe('Display order of properties'),
|
|
168
|
+
content: ExtensionComponentDataSchema.describe('Root component to render'),
|
|
326
169
|
})
|
|
327
|
-
.describe('Provider configuration
|
|
170
|
+
.describe('Provider configuration view (component tree)')
|
|
328
171
|
|
|
329
172
|
/**
|
|
330
173
|
* Provider definition
|
|
@@ -336,7 +179,7 @@ export const ProviderDefinitionSchema = z
|
|
|
336
179
|
description: z.string().optional().describe('Description'),
|
|
337
180
|
suggestedDefaultModel: z.string().optional().describe('Suggested default model'),
|
|
338
181
|
defaultSettings: z.record(z.unknown()).optional().describe('Default settings'),
|
|
339
|
-
|
|
182
|
+
configView: ProviderConfigViewSchema.optional().describe('Component-tree configuration view'),
|
|
340
183
|
})
|
|
341
184
|
.describe('Provider definition')
|
|
342
185
|
|
|
@@ -429,7 +272,6 @@ export const StorageContributionsSchema = z
|
|
|
429
272
|
*/
|
|
430
273
|
export const ExtensionContributionsSchema = z
|
|
431
274
|
.object({
|
|
432
|
-
settings: z.array(SettingDefinitionSchema).optional().describe('User-configurable settings'),
|
|
433
275
|
toolSettings: z.array(ToolSettingsViewDefinitionSchema).optional().describe('Tool settings views'),
|
|
434
276
|
panels: z.array(PanelDefinitionSchema).optional().describe('Right panel contributions'),
|
|
435
277
|
providers: z.array(ProviderDefinitionSchema).optional().describe('AI providers'),
|
|
@@ -445,10 +287,6 @@ export const ExtensionContributionsSchema = z
|
|
|
445
287
|
// =============================================================================
|
|
446
288
|
|
|
447
289
|
export type LocalizedString = z.infer<typeof LocalizedStringSchema>
|
|
448
|
-
export type SettingOptionsMapping = z.infer<typeof SettingOptionsMappingSchema>
|
|
449
|
-
export type SettingCreateMapping = z.infer<typeof SettingCreateMappingSchema>
|
|
450
|
-
export type SettingValidation = z.infer<typeof SettingValidationSchema>
|
|
451
|
-
export type SettingDefinition = z.infer<typeof SettingDefinitionSchema>
|
|
452
290
|
export type ToolSettingsListMapping = z.infer<typeof ToolSettingsListMappingSchema>
|
|
453
291
|
export type ToolSettingsActionDataSource = z.infer<typeof ToolSettingsActionDataSourceSchema>
|
|
454
292
|
export type ToolSettingsListView = z.infer<typeof ToolSettingsListViewSchema>
|
|
@@ -460,11 +298,7 @@ export type PanelComponentView = z.infer<typeof PanelComponentViewSchema>
|
|
|
460
298
|
export type PanelUnknownView = z.infer<typeof PanelUnknownViewSchema>
|
|
461
299
|
export type PanelView = z.infer<typeof PanelViewSchema>
|
|
462
300
|
export type PanelDefinition = z.infer<typeof PanelDefinitionSchema>
|
|
463
|
-
export type
|
|
464
|
-
export type ProviderConfigSelectOption = z.infer<typeof ProviderConfigSelectOptionSchema>
|
|
465
|
-
export type ProviderConfigValidation = z.infer<typeof ProviderConfigValidationSchema>
|
|
466
|
-
export type ProviderConfigProperty = z.infer<typeof ProviderConfigPropertySchema>
|
|
467
|
-
export type ProviderConfigSchema = z.infer<typeof ProviderConfigSchemaSchema>
|
|
301
|
+
export type ProviderConfigView = z.infer<typeof ProviderConfigViewSchema>
|
|
468
302
|
export type ProviderDefinition = z.infer<typeof ProviderDefinitionSchema>
|
|
469
303
|
export type ToolDefinition = z.infer<typeof ToolDefinitionSchema>
|
|
470
304
|
export type CommandDefinition = z.infer<typeof CommandDefinitionSchema>
|
package/src/schemas/index.ts
CHANGED
|
@@ -39,10 +39,6 @@ export {
|
|
|
39
39
|
export {
|
|
40
40
|
ExtensionContributionsSchema,
|
|
41
41
|
LocalizedStringSchema,
|
|
42
|
-
SettingDefinitionSchema,
|
|
43
|
-
SettingOptionsMappingSchema,
|
|
44
|
-
SettingCreateMappingSchema,
|
|
45
|
-
SettingValidationSchema,
|
|
46
42
|
ToolSettingsViewDefinitionSchema,
|
|
47
43
|
ToolSettingsViewSchema,
|
|
48
44
|
ToolSettingsListViewSchema,
|
|
@@ -55,21 +51,13 @@ export {
|
|
|
55
51
|
PanelUnknownViewSchema,
|
|
56
52
|
PanelActionDataSourceSchema,
|
|
57
53
|
ProviderDefinitionSchema,
|
|
58
|
-
|
|
59
|
-
ProviderConfigPropertySchema,
|
|
60
|
-
ProviderConfigPropertyTypeSchema,
|
|
61
|
-
ProviderConfigSelectOptionSchema,
|
|
62
|
-
ProviderConfigValidationSchema,
|
|
54
|
+
ProviderConfigViewSchema,
|
|
63
55
|
ToolDefinitionSchema,
|
|
64
56
|
CommandDefinitionSchema,
|
|
65
57
|
PromptContributionSchema,
|
|
66
58
|
PromptSectionSchema,
|
|
67
59
|
type ExtensionContributions,
|
|
68
60
|
type LocalizedString,
|
|
69
|
-
type SettingDefinition,
|
|
70
|
-
type SettingOptionsMapping,
|
|
71
|
-
type SettingCreateMapping,
|
|
72
|
-
type SettingValidation,
|
|
73
61
|
type ToolSettingsViewDefinition,
|
|
74
62
|
type ToolSettingsView,
|
|
75
63
|
type ToolSettingsListView,
|
|
@@ -82,11 +70,7 @@ export {
|
|
|
82
70
|
type PanelUnknownView,
|
|
83
71
|
type PanelActionDataSource,
|
|
84
72
|
type ProviderDefinition,
|
|
85
|
-
type
|
|
86
|
-
type ProviderConfigProperty,
|
|
87
|
-
type ProviderConfigPropertyType,
|
|
88
|
-
type ProviderConfigSelectOption,
|
|
89
|
-
type ProviderConfigValidation,
|
|
73
|
+
type ProviderConfigView,
|
|
90
74
|
type ToolDefinition,
|
|
91
75
|
type CommandDefinition,
|
|
92
76
|
type PromptContribution,
|
package/src/types.components.ts
CHANGED
|
@@ -261,6 +261,11 @@ export interface ParagraphProps extends ExtensionComponentData {
|
|
|
261
261
|
export interface ButtonProps extends ExtensionComponentData {
|
|
262
262
|
component: 'Button'
|
|
263
263
|
text: string
|
|
264
|
+
/** Visual style. Defaults to "normal". */
|
|
265
|
+
type?: 'normal' | 'primary' | 'danger' | 'accent'
|
|
266
|
+
/** Optional tooltip shown on hover. */
|
|
267
|
+
title?: string
|
|
268
|
+
disabled?: boolean
|
|
264
269
|
onClickAction: ExtensionActionRef
|
|
265
270
|
}
|
|
266
271
|
|
|
@@ -270,7 +275,42 @@ export interface TextInputProps extends ExtensionComponentData {
|
|
|
270
275
|
label: string
|
|
271
276
|
placeholder?: string
|
|
272
277
|
value?: string
|
|
273
|
-
onChangeAction
|
|
278
|
+
onChangeAction?: ExtensionActionRef
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** The extension API properties for the PasswordInput component. */
|
|
282
|
+
export interface PasswordInputProps extends ExtensionComponentData {
|
|
283
|
+
component: 'PasswordInput'
|
|
284
|
+
label: string
|
|
285
|
+
placeholder?: string
|
|
286
|
+
value?: string
|
|
287
|
+
onChangeAction?: ExtensionActionRef
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** The extension API properties for the NumberInput component. */
|
|
291
|
+
export interface NumberInputProps extends ExtensionComponentData {
|
|
292
|
+
component: 'NumberInput'
|
|
293
|
+
label: string
|
|
294
|
+
placeholder?: string
|
|
295
|
+
value?: string | number
|
|
296
|
+
/** Optional minimum value. */
|
|
297
|
+
min?: number
|
|
298
|
+
/** Optional maximum value. */
|
|
299
|
+
max?: number
|
|
300
|
+
/** Optional step. */
|
|
301
|
+
step?: number
|
|
302
|
+
onChangeAction?: ExtensionActionRef
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** The extension API properties for the TextArea component. */
|
|
306
|
+
export interface TextAreaProps extends ExtensionComponentData {
|
|
307
|
+
component: 'TextArea'
|
|
308
|
+
label: string
|
|
309
|
+
placeholder?: string
|
|
310
|
+
value?: string
|
|
311
|
+
/** Number of visible text rows. Defaults to 4. */
|
|
312
|
+
rows?: number
|
|
313
|
+
onChangeAction?: ExtensionActionRef
|
|
274
314
|
}
|
|
275
315
|
|
|
276
316
|
/** The extension API properties for the DateTimeInput component. */
|
|
@@ -278,7 +318,7 @@ export interface DateTimeInputProps extends ExtensionComponentData {
|
|
|
278
318
|
component: 'DateTimeInput'
|
|
279
319
|
label: string
|
|
280
320
|
value?: string
|
|
281
|
-
onChangeAction
|
|
321
|
+
onChangeAction?: ExtensionActionRef
|
|
282
322
|
}
|
|
283
323
|
|
|
284
324
|
/** The extension API properties for the Select component. */
|
|
@@ -287,7 +327,7 @@ export interface SelectProps extends ExtensionComponentData {
|
|
|
287
327
|
label: string
|
|
288
328
|
options: Array<{ label: string; value: string }>
|
|
289
329
|
selectedValue?: string
|
|
290
|
-
onChangeAction
|
|
330
|
+
onChangeAction?: ExtensionActionRef
|
|
291
331
|
}
|
|
292
332
|
|
|
293
333
|
/** The extension API properties for the IconPicker component. */
|
|
@@ -295,7 +335,7 @@ export interface IconPickerProps extends ExtensionComponentData {
|
|
|
295
335
|
component: 'IconPicker'
|
|
296
336
|
label?: string
|
|
297
337
|
value?: string
|
|
298
|
-
onChangeAction
|
|
338
|
+
onChangeAction?: ExtensionActionRef
|
|
299
339
|
}
|
|
300
340
|
|
|
301
341
|
/** The extension API properties for the VerticalStack component. */
|
|
@@ -371,7 +411,7 @@ export interface ToggleProps extends ExtensionComponentData {
|
|
|
371
411
|
description?: string
|
|
372
412
|
checked?: boolean
|
|
373
413
|
disabled?: boolean
|
|
374
|
-
onChangeAction
|
|
414
|
+
onChangeAction?: ExtensionActionRef
|
|
375
415
|
}
|
|
376
416
|
|
|
377
417
|
/** The extension API properties for the Collapsible component. */
|
|
@@ -415,7 +455,7 @@ export interface CheckboxProps extends ExtensionComponentData {
|
|
|
415
455
|
/** Whether to strike through the label when checked. Defaults to true. */
|
|
416
456
|
strikethrough?: boolean
|
|
417
457
|
/** Action to call when the checkbox state changes. */
|
|
418
|
-
onChangeAction
|
|
458
|
+
onChangeAction?: ExtensionActionRef
|
|
419
459
|
}
|
|
420
460
|
|
|
421
461
|
/** The extension API properties for the Markdown component. */
|
|
@@ -11,8 +11,6 @@ import type { ExtensionComponentData } from './types.components.js'
|
|
|
11
11
|
* What an extension can contribute to Stina
|
|
12
12
|
*/
|
|
13
13
|
export interface ExtensionContributions {
|
|
14
|
-
/** User-configurable settings */
|
|
15
|
-
settings?: SettingDefinition[]
|
|
16
14
|
/** Tool settings views for UI */
|
|
17
15
|
toolSettings?: ToolSettingsViewDefinition[]
|
|
18
16
|
/** Right panel contributions */
|
|
@@ -36,75 +34,6 @@ export interface ExtensionContributions {
|
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
// ============================================================================
|
|
40
|
-
// Settings
|
|
41
|
-
// ============================================================================
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Setting definition for the UI
|
|
45
|
-
*/
|
|
46
|
-
export interface SettingDefinition {
|
|
47
|
-
/** Setting ID (namespaced automatically) */
|
|
48
|
-
id: string
|
|
49
|
-
/** Display title */
|
|
50
|
-
title: string
|
|
51
|
-
/** Help text */
|
|
52
|
-
description?: string
|
|
53
|
-
/** Setting type */
|
|
54
|
-
type: 'string' | 'number' | 'boolean' | 'select'
|
|
55
|
-
/** Default value */
|
|
56
|
-
default?: unknown
|
|
57
|
-
/** For select type: available options */
|
|
58
|
-
options?: { value: string; label: string }[]
|
|
59
|
-
/** For select type: load options from tool */
|
|
60
|
-
optionsToolId?: string
|
|
61
|
-
/** Params for options tool */
|
|
62
|
-
optionsParams?: Record<string, unknown>
|
|
63
|
-
/** Mapping for options tool response */
|
|
64
|
-
optionsMapping?: SettingOptionsMapping
|
|
65
|
-
/** Tool ID for creating a new option */
|
|
66
|
-
createToolId?: string
|
|
67
|
-
/** Label for create action */
|
|
68
|
-
createLabel?: string
|
|
69
|
-
/** Fields for create form */
|
|
70
|
-
createFields?: SettingDefinition[]
|
|
71
|
-
/** Static params always sent to create tool */
|
|
72
|
-
createParams?: Record<string, unknown>
|
|
73
|
-
/** Mapping for create tool response */
|
|
74
|
-
createMapping?: SettingCreateMapping
|
|
75
|
-
/** Validation rules */
|
|
76
|
-
validation?: {
|
|
77
|
-
required?: boolean
|
|
78
|
-
min?: number
|
|
79
|
-
max?: number
|
|
80
|
-
pattern?: string
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Mapping for select field options from tool response
|
|
86
|
-
*/
|
|
87
|
-
export interface SettingOptionsMapping {
|
|
88
|
-
/** Key for items array in tool result data */
|
|
89
|
-
itemsKey: string
|
|
90
|
-
/** Key for option value */
|
|
91
|
-
valueKey: string
|
|
92
|
-
/** Key for option label */
|
|
93
|
-
labelKey: string
|
|
94
|
-
/** Optional key for description */
|
|
95
|
-
descriptionKey?: string
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Mapping for create tool response
|
|
100
|
-
*/
|
|
101
|
-
export interface SettingCreateMapping {
|
|
102
|
-
/** Key for result data object */
|
|
103
|
-
resultKey?: string
|
|
104
|
-
/** Key for option value (defaults to "id") */
|
|
105
|
-
valueKey: string
|
|
106
|
-
}
|
|
107
|
-
|
|
108
37
|
// ============================================================================
|
|
109
38
|
// Tool Settings Views
|
|
110
39
|
// ============================================================================
|
|
@@ -121,8 +50,6 @@ export interface ToolSettingsViewDefinition {
|
|
|
121
50
|
description?: string
|
|
122
51
|
/** View configuration */
|
|
123
52
|
view: ToolSettingsView
|
|
124
|
-
/** Fields for create/edit forms (uses SettingDefinition) */
|
|
125
|
-
fields?: SettingDefinition[]
|
|
126
53
|
}
|
|
127
54
|
|
|
128
55
|
/**
|
|
@@ -154,6 +81,16 @@ export interface ToolSettingsListView {
|
|
|
154
81
|
idParam?: string
|
|
155
82
|
/** Static params always sent to list tool */
|
|
156
83
|
listParams?: Record<string, unknown>
|
|
84
|
+
/**
|
|
85
|
+
* Component-tree-based create/edit form. Fields bind to the current
|
|
86
|
+
* item via `value: "$item.<key>"` (or `selectedValue` / `checked`),
|
|
87
|
+
* and the host saves the resulting object via `upsertToolId` when
|
|
88
|
+
* the user clicks "Save".
|
|
89
|
+
*/
|
|
90
|
+
editView?: {
|
|
91
|
+
/** Root component to render in the create/edit modal. */
|
|
92
|
+
content: ExtensionComponentData
|
|
93
|
+
}
|
|
157
94
|
}
|
|
158
95
|
|
|
159
96
|
/**
|
|
@@ -272,79 +209,23 @@ export interface ProviderDefinition {
|
|
|
272
209
|
suggestedDefaultModel?: string
|
|
273
210
|
/** Default settings for this provider (e.g., { url: "http://localhost:11434" }) */
|
|
274
211
|
defaultSettings?: Record<string, unknown>
|
|
275
|
-
/**
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
/** Property definitions */
|
|
285
|
-
properties: Record<string, ProviderConfigProperty>
|
|
286
|
-
/** Display order of properties in UI (optional, defaults to object key order) */
|
|
287
|
-
order?: string[]
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Property types for provider configuration
|
|
292
|
-
*/
|
|
293
|
-
export type ProviderConfigPropertyType =
|
|
294
|
-
| 'string'
|
|
295
|
-
| 'number'
|
|
296
|
-
| 'boolean'
|
|
297
|
-
| 'select'
|
|
298
|
-
| 'password'
|
|
299
|
-
| 'url'
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Single property in a provider configuration schema.
|
|
303
|
-
* Defines how a setting should be rendered and validated in the UI.
|
|
304
|
-
*/
|
|
305
|
-
export interface ProviderConfigProperty {
|
|
306
|
-
/** Property type - determines UI control */
|
|
307
|
-
type: ProviderConfigPropertyType
|
|
308
|
-
/** Display label */
|
|
309
|
-
title: string
|
|
310
|
-
/** Help text shown below the input */
|
|
311
|
-
description?: string
|
|
312
|
-
/** Default value */
|
|
313
|
-
default?: unknown
|
|
314
|
-
/** Whether the field is required */
|
|
315
|
-
required?: boolean
|
|
316
|
-
/** Placeholder text for input fields */
|
|
317
|
-
placeholder?: string
|
|
318
|
-
/** For 'select' type: static options */
|
|
319
|
-
options?: ProviderConfigSelectOption[]
|
|
320
|
-
/** Validation rules */
|
|
321
|
-
validation?: ProviderConfigValidation
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Option for select-type properties
|
|
326
|
-
*/
|
|
327
|
-
export interface ProviderConfigSelectOption {
|
|
328
|
-
/** Value stored in settings */
|
|
329
|
-
value: string
|
|
330
|
-
/** Display label */
|
|
331
|
-
label: string
|
|
212
|
+
/**
|
|
213
|
+
* Declarative configuration view rendered with the extensionComponent
|
|
214
|
+
* system. The host owns the settings state — bind fields with
|
|
215
|
+
* `value: "$settings.<key>"` and the host updates the model's
|
|
216
|
+
* settingsOverride when the user edits. `onChangeAction` is optional
|
|
217
|
+
* for input fields in this view; buttons can still use `onClickAction`
|
|
218
|
+
* to call extension actions (e.g. OAuth, "Test connection").
|
|
219
|
+
*/
|
|
220
|
+
configView?: ProviderConfigView
|
|
332
221
|
}
|
|
333
222
|
|
|
334
223
|
/**
|
|
335
|
-
*
|
|
224
|
+
* Component-tree-based configuration view for a provider.
|
|
336
225
|
*/
|
|
337
|
-
export interface
|
|
338
|
-
/**
|
|
339
|
-
|
|
340
|
-
/** Minimum string length */
|
|
341
|
-
minLength?: number
|
|
342
|
-
/** Maximum string length */
|
|
343
|
-
maxLength?: number
|
|
344
|
-
/** Minimum number value */
|
|
345
|
-
min?: number
|
|
346
|
-
/** Maximum number value */
|
|
347
|
-
max?: number
|
|
226
|
+
export interface ProviderConfigView {
|
|
227
|
+
/** Component tree describing the form. */
|
|
228
|
+
content: import('./types.components.js').ExtensionComponentData
|
|
348
229
|
}
|
|
349
230
|
|
|
350
231
|
// ============================================================================
|
package/src/types.ts
CHANGED
|
@@ -22,10 +22,6 @@ export type {
|
|
|
22
22
|
// Contributions
|
|
23
23
|
export type {
|
|
24
24
|
ExtensionContributions,
|
|
25
|
-
// Settings
|
|
26
|
-
SettingDefinition,
|
|
27
|
-
SettingOptionsMapping,
|
|
28
|
-
SettingCreateMapping,
|
|
29
25
|
// Tool Settings Views
|
|
30
26
|
ToolSettingsViewDefinition,
|
|
31
27
|
ToolSettingsView,
|
|
@@ -41,11 +37,7 @@ export type {
|
|
|
41
37
|
PanelComponentView,
|
|
42
38
|
// Providers
|
|
43
39
|
ProviderDefinition,
|
|
44
|
-
|
|
45
|
-
ProviderConfigPropertyType,
|
|
46
|
-
ProviderConfigProperty,
|
|
47
|
-
ProviderConfigSelectOption,
|
|
48
|
-
ProviderConfigValidation,
|
|
40
|
+
ProviderConfigView,
|
|
49
41
|
// Tools
|
|
50
42
|
ToolDefinition,
|
|
51
43
|
ToolConfirmationConfig,
|