@stina/extension-api 0.31.1 → 0.32.0-alpha.25ba69d

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.
@@ -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
- /** Schema for provider-specific configuration UI */
276
- configSchema?: ProviderConfigSchema
277
- }
278
-
279
- /**
280
- * Schema for provider-specific configuration.
281
- * Used to generate UI forms for configuring provider settings.
282
- */
283
- export interface ProviderConfigSchema {
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
- * Validation rules for a property
224
+ * Component-tree-based configuration view for a provider.
336
225
  */
337
- export interface ProviderConfigValidation {
338
- /** Regex pattern the value must match */
339
- pattern?: string
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
  // ============================================================================
@@ -374,13 +255,20 @@ export interface ToolDefinition {
374
255
  /** Parameter schema (JSON Schema) */
375
256
  parameters?: Record<string, unknown>
376
257
  /**
377
- * Confirmation configuration. If set, user must confirm before tool runs.
378
- * If not set, tool runs without confirmation.
258
+ * Whether this tool requires user confirmation before execution.
259
+ * Defaults to true if not specified tools require confirmation unless explicitly opted out.
260
+ */
261
+ requiresConfirmation?: boolean
262
+ /**
263
+ * Optional custom confirmation prompt to show the user.
264
+ * Only used when confirmation is required.
265
+ * @example { en: "Allow sending email?", sv: "Tillåt att skicka e-post?" }
379
266
  */
380
- confirmation?: ToolConfirmationConfig
267
+ confirmationPrompt?: LocalizedString
381
268
  }
382
269
 
383
270
  /**
271
+ * @deprecated Use `requiresConfirmation` and `confirmationPrompt` directly on ToolDefinition instead.
384
272
  * Configuration for tool confirmation.
385
273
  */
386
274
  export interface ToolConfirmationConfig {
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
- ProviderConfigSchema,
45
- ProviderConfigPropertyType,
46
- ProviderConfigProperty,
47
- ProviderConfigSelectOption,
48
- ProviderConfigValidation,
40
+ ProviderConfigView,
49
41
  // Tools
50
42
  ToolDefinition,
51
43
  ToolConfirmationConfig,