@stina/extension-api 0.28.1 → 0.29.0-alpha.d59ea54
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/{chunk-VSPMXOO7.js → chunk-RZGR2OKA.js} +1 -1
- package/dist/{chunk-VSPMXOO7.js.map → chunk-RZGR2OKA.js.map} +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/runtime.cjs +17 -1
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +18 -2
- package/dist/runtime.js.map +1 -1
- package/dist/schemas/index.cjs +34 -0
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +391 -5
- package/dist/schemas/index.d.ts +391 -5
- package/dist/schemas/index.js +30 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/{types.tools-ymsggUiN.d.cts → types.tools-CmclZz5I.d.cts} +62 -8
- package/dist/{types.tools-ymsggUiN.d.ts → types.tools-CmclZz5I.d.ts} +62 -8
- package/package.json +1 -1
- package/schema/extension-manifest.schema.json +2 -0
- package/src/index.ts +6 -0
- package/src/messages.ts +3 -0
- package/src/runtime.ts +20 -2
- package/src/schemas/components.schema.ts +41 -0
- package/src/schemas/index.ts +8 -0
- package/src/schemas/permissions.schema.ts +4 -0
- package/src/types.components.ts +48 -7
- package/src/types.context.ts +20 -1
- package/src/types.permissions.ts +2 -0
- package/src/types.provider.ts +2 -0
|
@@ -26,6 +26,8 @@ type LocalizedString = string | Record<string, string>;
|
|
|
26
26
|
*/
|
|
27
27
|
declare function resolveLocalizedString(value: LocalizedString, lang: string, fallbackLang?: string): string;
|
|
28
28
|
|
|
29
|
+
/** Semantic type alias for icon names (e.g. Hugeicons). Accepts any string. */
|
|
30
|
+
type HugeIconName = string;
|
|
29
31
|
/**
|
|
30
32
|
* Allowed CSS property names for extension component styling.
|
|
31
33
|
* Only safe properties that cannot be used for UI spoofing,
|
|
@@ -162,7 +164,7 @@ interface HeaderProps extends ExtensionComponentData {
|
|
|
162
164
|
level: number;
|
|
163
165
|
title: string;
|
|
164
166
|
description?: string | string[];
|
|
165
|
-
icon?:
|
|
167
|
+
icon?: HugeIconName;
|
|
166
168
|
}
|
|
167
169
|
/** The extension API properties for the Label component. */
|
|
168
170
|
interface LabelProps extends ExtensionComponentData {
|
|
@@ -239,7 +241,7 @@ interface DividerProps extends ExtensionComponentData {
|
|
|
239
241
|
/** The extension API properties for the Icon component. */
|
|
240
242
|
interface IconProps extends ExtensionComponentData {
|
|
241
243
|
component: 'Icon';
|
|
242
|
-
name:
|
|
244
|
+
name: HugeIconName;
|
|
243
245
|
title?: string;
|
|
244
246
|
}
|
|
245
247
|
/** Button type for IconButton. */
|
|
@@ -247,7 +249,7 @@ type IconButtonType = 'normal' | 'primary' | 'danger' | 'accent';
|
|
|
247
249
|
/** The extension API properties for the IconButton component. */
|
|
248
250
|
interface IconButtonProps extends ExtensionComponentData {
|
|
249
251
|
component: 'IconButton';
|
|
250
|
-
icon:
|
|
252
|
+
icon: HugeIconName;
|
|
251
253
|
tooltip: string;
|
|
252
254
|
active?: boolean;
|
|
253
255
|
disabled?: boolean;
|
|
@@ -256,7 +258,7 @@ interface IconButtonProps extends ExtensionComponentData {
|
|
|
256
258
|
}
|
|
257
259
|
/** Action button definition for Panel component. */
|
|
258
260
|
interface PanelAction {
|
|
259
|
-
icon:
|
|
261
|
+
icon: HugeIconName;
|
|
260
262
|
tooltip: string;
|
|
261
263
|
action: ExtensionActionRef;
|
|
262
264
|
type?: IconButtonType;
|
|
@@ -266,7 +268,7 @@ interface PanelProps extends ExtensionComponentData {
|
|
|
266
268
|
component: 'Panel';
|
|
267
269
|
title: string;
|
|
268
270
|
description?: string | string[];
|
|
269
|
-
icon?:
|
|
271
|
+
icon?: HugeIconName;
|
|
270
272
|
actions?: PanelAction[];
|
|
271
273
|
content?: ExtensionComponentData;
|
|
272
274
|
}
|
|
@@ -287,7 +289,7 @@ interface CollapsibleProps extends ExtensionComponentData {
|
|
|
287
289
|
/** Optional description rendered under the title. */
|
|
288
290
|
description?: string | string[];
|
|
289
291
|
/** Optional icon shown to the left of the title. */
|
|
290
|
-
icon?:
|
|
292
|
+
icon?: HugeIconName;
|
|
291
293
|
/** Whether the section is expanded by default. */
|
|
292
294
|
defaultExpanded?: boolean;
|
|
293
295
|
/** Child component to render when expanded. */
|
|
@@ -301,7 +303,7 @@ interface PillProps extends ExtensionComponentData {
|
|
|
301
303
|
/** Text to display in the pill. */
|
|
302
304
|
text: string;
|
|
303
305
|
/** Optional icon shown to the left of the text. */
|
|
304
|
-
icon?:
|
|
306
|
+
icon?: HugeIconName;
|
|
305
307
|
/** Color variant. Defaults to 'default'. */
|
|
306
308
|
variant?: PillVariant;
|
|
307
309
|
}
|
|
@@ -325,6 +327,14 @@ interface MarkdownProps extends ExtensionComponentData {
|
|
|
325
327
|
/** Markdown content to render. */
|
|
326
328
|
content: string;
|
|
327
329
|
}
|
|
330
|
+
/** The extension API properties for the TextPreview component. */
|
|
331
|
+
interface TextPreviewProps extends ExtensionComponentData {
|
|
332
|
+
component: 'TextPreview';
|
|
333
|
+
/** Markdown content to render. */
|
|
334
|
+
content: string;
|
|
335
|
+
/** Maximum number of visible lines before truncating. Defaults to 5. */
|
|
336
|
+
maxLines?: number;
|
|
337
|
+
}
|
|
328
338
|
/** The extension API properties for the Modal component. */
|
|
329
339
|
interface ModalProps extends ExtensionComponentData {
|
|
330
340
|
component: 'Modal';
|
|
@@ -361,6 +371,28 @@ interface ConditionalGroupProps extends ExtensionComponentData {
|
|
|
361
371
|
/** Children to render when condition is true. */
|
|
362
372
|
children: ExtensionComponentChildren;
|
|
363
373
|
}
|
|
374
|
+
/** Visual variant for the Frame component. */
|
|
375
|
+
type FrameVariant = 'border' | 'solid';
|
|
376
|
+
/** The extension API properties for the Frame component. */
|
|
377
|
+
interface FrameProps extends ExtensionComponentData {
|
|
378
|
+
component: 'Frame';
|
|
379
|
+
/** Optional title displayed in the header. Can be a plain string or extension components. */
|
|
380
|
+
title?: string | ExtensionComponentChildren;
|
|
381
|
+
/** Whether the content can be toggled (collapsed/expanded) by clicking the title. Requires title to be set. */
|
|
382
|
+
collapsible?: boolean;
|
|
383
|
+
/** Whether the frame content is expanded by default. Only used when collapsible is true. Defaults to true. */
|
|
384
|
+
defaultExpanded?: boolean;
|
|
385
|
+
/** Visual variant: 'border' shows a bordered container, 'solid' shows a solid background. Defaults to 'border'. */
|
|
386
|
+
variant?: FrameVariant;
|
|
387
|
+
/** Child components to render inside the frame. */
|
|
388
|
+
children: ExtensionComponentChildren;
|
|
389
|
+
}
|
|
390
|
+
/** The extension API properties for the List component. */
|
|
391
|
+
interface ListProps extends ExtensionComponentData {
|
|
392
|
+
component: 'List';
|
|
393
|
+
/** Child components to render as list items. Supports iteration. */
|
|
394
|
+
children: ExtensionComponentChildren;
|
|
395
|
+
}
|
|
364
396
|
|
|
365
397
|
/**
|
|
366
398
|
* Contribution Types
|
|
@@ -811,6 +843,11 @@ interface ChatOptions {
|
|
|
811
843
|
signal?: AbortSignal;
|
|
812
844
|
/** Provider-specific settings from model configuration */
|
|
813
845
|
settings?: Record<string, unknown>;
|
|
846
|
+
/** Request context (user info, session metadata — not provider config) */
|
|
847
|
+
context?: {
|
|
848
|
+
userId?: string;
|
|
849
|
+
[key: string]: unknown;
|
|
850
|
+
};
|
|
814
851
|
/** Available tools for this request */
|
|
815
852
|
tools?: ToolDefinition[];
|
|
816
853
|
}
|
|
@@ -1304,6 +1341,23 @@ interface ToolsAPI {
|
|
|
1304
1341
|
* Register a tool that Stina can use
|
|
1305
1342
|
*/
|
|
1306
1343
|
register(tool: Tool): Disposable;
|
|
1344
|
+
/**
|
|
1345
|
+
* List all registered tools from all extensions.
|
|
1346
|
+
* Requires the `tools.list` permission.
|
|
1347
|
+
*
|
|
1348
|
+
* @returns All tool definitions currently registered across all extensions.
|
|
1349
|
+
*/
|
|
1350
|
+
list(): Promise<ToolDefinition[]>;
|
|
1351
|
+
/**
|
|
1352
|
+
* Execute a tool registered by any extension.
|
|
1353
|
+
* Requires the `tools.execute` permission.
|
|
1354
|
+
*
|
|
1355
|
+
* @param toolId - The unique identifier of the tool to execute.
|
|
1356
|
+
* @param params - Parameters to pass to the tool.
|
|
1357
|
+
* @param userId - Optional user ID for user-scoped tool execution.
|
|
1358
|
+
* @returns The result produced by the tool.
|
|
1359
|
+
*/
|
|
1360
|
+
execute(toolId: string, params: Record<string, unknown>, userId?: string): Promise<ToolResult>;
|
|
1307
1361
|
}
|
|
1308
1362
|
/**
|
|
1309
1363
|
* Actions API for registering UI actions
|
|
@@ -1678,4 +1732,4 @@ interface ActionResult {
|
|
|
1678
1732
|
error?: string;
|
|
1679
1733
|
}
|
|
1680
1734
|
|
|
1681
|
-
export { type BackgroundTaskConfig as $, type ActionResult as A, type ProviderConfigValidation as B, type ChatMessage as C, type ExtensionContext as D, type ExtensionContributions as E, type Disposable as F, type GetModelsOptions as G, type SettingsAPI as H, type ProvidersAPI as I, type ToolsAPI as J, type ActionsAPI as K, type LocalizedString as L, type ModelInfo as M, type NetworkAPI as N, type EventsAPI as O, type PanelDefinition as P, type SchedulerAPI as Q, type SchedulerJobRequest as R, type SchedulerFirePayload as S, type ToolResult as T, type SchedulerSchedule as U, type UserAPI as V, type UserProfile as W, type ChatAPI as X, type ChatInstructionMessage as Y, type LogAPI as Z, type BackgroundWorkersAPI as _, type ChatOptions as a, type BackgroundTaskCallback as a0, type BackgroundTaskContext as a1, type BackgroundTaskHealth as a2, type BackgroundRestartPolicy as a3, type Query as a4, type QueryOptions as a5, type StorageAPI as a6, type SecretsAPI as a7, type StorageCollectionConfig as a8, type StorageContributions as a9, type
|
|
1735
|
+
export { type BackgroundTaskConfig as $, type ActionResult as A, type ProviderConfigValidation as B, type ChatMessage as C, type ExtensionContext as D, type ExtensionContributions as E, type Disposable as F, type GetModelsOptions as G, type SettingsAPI as H, type ProvidersAPI as I, type ToolsAPI as J, type ActionsAPI as K, type LocalizedString as L, type ModelInfo as M, type NetworkAPI as N, type EventsAPI as O, type PanelDefinition as P, type SchedulerAPI as Q, type SchedulerJobRequest as R, type SchedulerFirePayload as S, type ToolResult as T, type SchedulerSchedule as U, type UserAPI as V, type UserProfile as W, type ChatAPI as X, type ChatInstructionMessage as Y, type LogAPI as Z, type BackgroundWorkersAPI as _, type ChatOptions as a, type BackgroundTaskCallback as a0, type BackgroundTaskContext as a1, type BackgroundTaskHealth as a2, type BackgroundRestartPolicy as a3, type Query as a4, type QueryOptions as a5, type StorageAPI as a6, type SecretsAPI as a7, type StorageCollectionConfig as a8, type StorageContributions as a9, type DividerProps as aA, type IconProps as aB, type IconButtonType as aC, type IconButtonProps as aD, type PanelAction as aE, type PanelProps as aF, type ToggleProps as aG, type CollapsibleProps as aH, type FrameVariant as aI, type FrameProps as aJ, type ListProps as aK, type PillVariant as aL, type PillProps as aM, type CheckboxProps as aN, type MarkdownProps as aO, type TextPreviewProps as aP, type ModalProps as aQ, type ConditionalGroupProps as aR, type ExecutionContext as aS, type AIProvider as aa, type ToolCall as ab, type Tool as ac, type Action as ad, type ExtensionModule as ae, type HugeIconName as af, type AllowedCSSProperty as ag, type ExtensionComponentStyle as ah, type ExtensionComponentData as ai, type ExtensionComponentIterator as aj, type ExtensionComponentChildren as ak, type ExtensionActionCall as al, type ExtensionActionRef as am, type ExtensionDataSource as an, type ExtensionPanelDefinition as ao, type HeaderProps as ap, type LabelProps as aq, type ParagraphProps as ar, type ButtonProps as as, type TextInputProps as at, type DateTimeInputProps as au, type SelectProps as av, type IconPickerProps as aw, type VerticalStackProps as ax, type HorizontalStackProps as ay, type GridProps as az, type StreamEvent as b, type SettingDefinition as c, type SettingOptionsMapping as d, type SettingCreateMapping as e, type ToolSettingsViewDefinition as f, type ToolSettingsView as g, type ToolSettingsListView as h, type ToolSettingsListMapping as i, type ToolSettingsComponentView as j, type ToolSettingsActionDataSource as k, type PanelView as l, type PanelComponentView as m, type PanelActionDataSource as n, type PanelUnknownView as o, type ProviderDefinition as p, type PromptContribution as q, resolveLocalizedString as r, type PromptSection as s, type ToolDefinition as t, type ToolConfirmationConfig as u, type CommandDefinition as v, type ProviderConfigSchema as w, type ProviderConfigProperty as x, type ProviderConfigPropertyType as y, type ProviderConfigSelectOption as z };
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -144,6 +144,8 @@ export { generateMessageId } from './messages.js'
|
|
|
144
144
|
|
|
145
145
|
// Component types (for extension UI components)
|
|
146
146
|
export type {
|
|
147
|
+
// Icon Names
|
|
148
|
+
HugeIconName,
|
|
147
149
|
// Styling
|
|
148
150
|
AllowedCSSProperty,
|
|
149
151
|
ExtensionComponentStyle,
|
|
@@ -178,10 +180,14 @@ export type {
|
|
|
178
180
|
PanelProps,
|
|
179
181
|
ToggleProps,
|
|
180
182
|
CollapsibleProps,
|
|
183
|
+
FrameVariant,
|
|
184
|
+
FrameProps,
|
|
185
|
+
ListProps,
|
|
181
186
|
PillVariant,
|
|
182
187
|
PillProps,
|
|
183
188
|
CheckboxProps,
|
|
184
189
|
MarkdownProps,
|
|
190
|
+
TextPreviewProps,
|
|
185
191
|
ModalProps,
|
|
186
192
|
ConditionalGroupProps,
|
|
187
193
|
} from './types.components.js'
|
package/src/messages.ts
CHANGED
|
@@ -242,6 +242,9 @@ export type RequestMethod =
|
|
|
242
242
|
| 'secrets.getForUser'
|
|
243
243
|
| 'secrets.deleteForUser'
|
|
244
244
|
| 'secrets.listForUser'
|
|
245
|
+
// Tools cross-extension methods
|
|
246
|
+
| 'tools.list'
|
|
247
|
+
| 'tools.execute'
|
|
245
248
|
|
|
246
249
|
export interface ProviderRegisteredMessage {
|
|
247
250
|
type: 'provider-registered'
|
package/src/runtime.ts
CHANGED
|
@@ -28,6 +28,8 @@ import type {
|
|
|
28
28
|
LogAPI,
|
|
29
29
|
AIProvider,
|
|
30
30
|
Tool,
|
|
31
|
+
ToolDefinition,
|
|
32
|
+
ToolResult,
|
|
31
33
|
Action,
|
|
32
34
|
ChatMessage,
|
|
33
35
|
ChatOptions,
|
|
@@ -720,10 +722,14 @@ function buildContext(
|
|
|
720
722
|
;(context as { providers: ProvidersAPI }).providers = providersApi
|
|
721
723
|
}
|
|
722
724
|
|
|
723
|
-
// Add tools API if
|
|
724
|
-
|
|
725
|
+
// Add tools API if ANY tools permission is present
|
|
726
|
+
const hasAnyToolsPermission = hasPermission('tools.register') || hasPermission('tools.list') || hasPermission('tools.execute')
|
|
727
|
+
if (hasAnyToolsPermission) {
|
|
725
728
|
const toolsApi: ToolsAPI = {
|
|
726
729
|
register(tool: Tool): Disposable {
|
|
730
|
+
if (!hasPermission('tools.register')) {
|
|
731
|
+
throw new Error('tools.register permission required')
|
|
732
|
+
}
|
|
727
733
|
registeredTools.set(tool.id, tool)
|
|
728
734
|
postMessage({
|
|
729
735
|
type: 'tool-registered',
|
|
@@ -740,6 +746,18 @@ function buildContext(
|
|
|
740
746
|
},
|
|
741
747
|
}
|
|
742
748
|
},
|
|
749
|
+
async list(): Promise<ToolDefinition[]> {
|
|
750
|
+
if (!hasPermission('tools.list')) {
|
|
751
|
+
throw new Error('tools.list permission required')
|
|
752
|
+
}
|
|
753
|
+
return sendRequest<ToolDefinition[]>('tools.list', {})
|
|
754
|
+
},
|
|
755
|
+
async execute(toolId: string, params: Record<string, unknown>, userId?: string): Promise<ToolResult> {
|
|
756
|
+
if (!hasPermission('tools.execute')) {
|
|
757
|
+
throw new Error('tools.execute permission required')
|
|
758
|
+
}
|
|
759
|
+
return sendRequest<ToolResult>('tools.execute', { toolId, params, userId })
|
|
760
|
+
},
|
|
743
761
|
}
|
|
744
762
|
;(context as { tools: ToolsAPI }).tools = toolsApi
|
|
745
763
|
}
|
|
@@ -414,6 +414,16 @@ export const MarkdownPropsSchema = z
|
|
|
414
414
|
.passthrough()
|
|
415
415
|
.describe('Markdown component')
|
|
416
416
|
|
|
417
|
+
export const TextPreviewPropsSchema = z
|
|
418
|
+
.object({
|
|
419
|
+
component: z.literal('TextPreview'),
|
|
420
|
+
content: z.string().describe('Markdown content'),
|
|
421
|
+
maxLines: z.number().optional().describe('Max visible lines before truncating (default 5)'),
|
|
422
|
+
style: ExtensionComponentStyleSchema.optional(),
|
|
423
|
+
})
|
|
424
|
+
.passthrough()
|
|
425
|
+
.describe('TextPreview component')
|
|
426
|
+
|
|
417
427
|
export const ModalPropsSchema = z
|
|
418
428
|
.object({
|
|
419
429
|
component: z.literal('Modal'),
|
|
@@ -438,6 +448,33 @@ export const ConditionalGroupPropsSchema = z
|
|
|
438
448
|
.passthrough()
|
|
439
449
|
.describe('ConditionalGroup component')
|
|
440
450
|
|
|
451
|
+
export const FrameVariantSchema = z
|
|
452
|
+
.enum(['border', 'solid'])
|
|
453
|
+
.describe('Frame visual variant')
|
|
454
|
+
|
|
455
|
+
export const FramePropsSchema = z
|
|
456
|
+
.object({
|
|
457
|
+
component: z.literal('Frame'),
|
|
458
|
+
title: z.union([z.string(), ExtensionComponentChildrenSchema]).optional().describe('Optional title (string or components)'),
|
|
459
|
+
icon: z.string().optional().describe('Icon name'),
|
|
460
|
+
collapsible: z.boolean().optional().describe('Whether content can be toggled'),
|
|
461
|
+
defaultExpanded: z.boolean().optional().describe('Whether expanded by default'),
|
|
462
|
+
variant: FrameVariantSchema.optional().describe('Visual variant'),
|
|
463
|
+
children: ExtensionComponentChildrenSchema.describe('Child components'),
|
|
464
|
+
style: ExtensionComponentStyleSchema.optional(),
|
|
465
|
+
})
|
|
466
|
+
.passthrough()
|
|
467
|
+
.describe('Frame container component')
|
|
468
|
+
|
|
469
|
+
export const ListPropsSchema = z
|
|
470
|
+
.object({
|
|
471
|
+
component: z.literal('List'),
|
|
472
|
+
children: ExtensionComponentChildrenSchema.describe('Child components rendered as list items'),
|
|
473
|
+
style: ExtensionComponentStyleSchema.optional(),
|
|
474
|
+
})
|
|
475
|
+
.passthrough()
|
|
476
|
+
.describe('List component')
|
|
477
|
+
|
|
441
478
|
// =============================================================================
|
|
442
479
|
// Type Exports
|
|
443
480
|
// =============================================================================
|
|
@@ -473,5 +510,9 @@ export type CollapsibleProps = z.infer<typeof CollapsiblePropsSchema>
|
|
|
473
510
|
export type PillProps = z.infer<typeof PillPropsSchema>
|
|
474
511
|
export type CheckboxProps = z.infer<typeof CheckboxPropsSchema>
|
|
475
512
|
export type MarkdownProps = z.infer<typeof MarkdownPropsSchema>
|
|
513
|
+
export type TextPreviewProps = z.infer<typeof TextPreviewPropsSchema>
|
|
476
514
|
export type ModalProps = z.infer<typeof ModalPropsSchema>
|
|
477
515
|
export type ConditionalGroupProps = z.infer<typeof ConditionalGroupPropsSchema>
|
|
516
|
+
export type FrameVariant = z.infer<typeof FrameVariantSchema>
|
|
517
|
+
export type FrameProps = z.infer<typeof FramePropsSchema>
|
|
518
|
+
export type ListProps = z.infer<typeof ListPropsSchema>
|
package/src/schemas/index.ts
CHANGED
|
@@ -123,6 +123,10 @@ export {
|
|
|
123
123
|
PanelPropsSchema,
|
|
124
124
|
TogglePropsSchema,
|
|
125
125
|
CollapsiblePropsSchema,
|
|
126
|
+
FrameVariantSchema,
|
|
127
|
+
FramePropsSchema,
|
|
128
|
+
TextPreviewPropsSchema,
|
|
129
|
+
ListPropsSchema,
|
|
126
130
|
PillPropsSchema,
|
|
127
131
|
CheckboxPropsSchema,
|
|
128
132
|
MarkdownPropsSchema,
|
|
@@ -156,6 +160,10 @@ export {
|
|
|
156
160
|
type PanelProps,
|
|
157
161
|
type ToggleProps,
|
|
158
162
|
type CollapsibleProps,
|
|
163
|
+
type FrameVariant,
|
|
164
|
+
type FrameProps,
|
|
165
|
+
type TextPreviewProps,
|
|
166
|
+
type ListProps,
|
|
159
167
|
type PillProps,
|
|
160
168
|
type CheckboxProps,
|
|
161
169
|
type MarkdownProps,
|
|
@@ -22,6 +22,8 @@ export const VALID_PERMISSIONS = [
|
|
|
22
22
|
'chat.message.write',
|
|
23
23
|
'provider.register',
|
|
24
24
|
'tools.register',
|
|
25
|
+
'tools.list',
|
|
26
|
+
'tools.execute',
|
|
25
27
|
'actions.register',
|
|
26
28
|
'settings.register',
|
|
27
29
|
'commands.register',
|
|
@@ -81,6 +83,8 @@ const CapabilityPermissionSchema = z
|
|
|
81
83
|
.enum([
|
|
82
84
|
'provider.register',
|
|
83
85
|
'tools.register',
|
|
86
|
+
'tools.list',
|
|
87
|
+
'tools.execute',
|
|
84
88
|
'actions.register',
|
|
85
89
|
'settings.register',
|
|
86
90
|
'commands.register',
|
package/src/types.components.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Icon Names
|
|
3
|
+
// =============================================================================
|
|
4
|
+
|
|
5
|
+
/** Semantic type alias for icon names (e.g. Hugeicons). Accepts any string. */
|
|
6
|
+
export type HugeIconName = string
|
|
7
|
+
|
|
1
8
|
// =============================================================================
|
|
2
9
|
// Styling
|
|
3
10
|
// =============================================================================
|
|
@@ -235,7 +242,7 @@ export interface HeaderProps extends ExtensionComponentData {
|
|
|
235
242
|
level: number
|
|
236
243
|
title: string
|
|
237
244
|
description?: string | string[]
|
|
238
|
-
icon?:
|
|
245
|
+
icon?: HugeIconName
|
|
239
246
|
}
|
|
240
247
|
|
|
241
248
|
/** The extension API properties for the Label component. */
|
|
@@ -321,7 +328,7 @@ export interface DividerProps extends ExtensionComponentData {
|
|
|
321
328
|
/** The extension API properties for the Icon component. */
|
|
322
329
|
export interface IconProps extends ExtensionComponentData {
|
|
323
330
|
component: 'Icon'
|
|
324
|
-
name:
|
|
331
|
+
name: HugeIconName
|
|
325
332
|
title?: string
|
|
326
333
|
}
|
|
327
334
|
|
|
@@ -331,7 +338,7 @@ export type IconButtonType = 'normal' | 'primary' | 'danger' | 'accent'
|
|
|
331
338
|
/** The extension API properties for the IconButton component. */
|
|
332
339
|
export interface IconButtonProps extends ExtensionComponentData {
|
|
333
340
|
component: 'IconButton'
|
|
334
|
-
icon:
|
|
341
|
+
icon: HugeIconName
|
|
335
342
|
tooltip: string
|
|
336
343
|
active?: boolean
|
|
337
344
|
disabled?: boolean
|
|
@@ -341,7 +348,7 @@ export interface IconButtonProps extends ExtensionComponentData {
|
|
|
341
348
|
|
|
342
349
|
/** Action button definition for Panel component. */
|
|
343
350
|
export interface PanelAction {
|
|
344
|
-
icon:
|
|
351
|
+
icon: HugeIconName
|
|
345
352
|
tooltip: string
|
|
346
353
|
action: ExtensionActionRef
|
|
347
354
|
type?: IconButtonType
|
|
@@ -352,7 +359,7 @@ export interface PanelProps extends ExtensionComponentData {
|
|
|
352
359
|
component: 'Panel'
|
|
353
360
|
title: string
|
|
354
361
|
description?: string | string[]
|
|
355
|
-
icon?:
|
|
362
|
+
icon?: HugeIconName
|
|
356
363
|
actions?: PanelAction[]
|
|
357
364
|
content?: ExtensionComponentData
|
|
358
365
|
}
|
|
@@ -375,7 +382,7 @@ export interface CollapsibleProps extends ExtensionComponentData {
|
|
|
375
382
|
/** Optional description rendered under the title. */
|
|
376
383
|
description?: string | string[]
|
|
377
384
|
/** Optional icon shown to the left of the title. */
|
|
378
|
-
icon?:
|
|
385
|
+
icon?: HugeIconName
|
|
379
386
|
/** Whether the section is expanded by default. */
|
|
380
387
|
defaultExpanded?: boolean
|
|
381
388
|
/** Child component to render when expanded. */
|
|
@@ -391,7 +398,7 @@ export interface PillProps extends ExtensionComponentData {
|
|
|
391
398
|
/** Text to display in the pill. */
|
|
392
399
|
text: string
|
|
393
400
|
/** Optional icon shown to the left of the text. */
|
|
394
|
-
icon?:
|
|
401
|
+
icon?: HugeIconName
|
|
395
402
|
/** Color variant. Defaults to 'default'. */
|
|
396
403
|
variant?: PillVariant
|
|
397
404
|
}
|
|
@@ -418,6 +425,15 @@ export interface MarkdownProps extends ExtensionComponentData {
|
|
|
418
425
|
content: string
|
|
419
426
|
}
|
|
420
427
|
|
|
428
|
+
/** The extension API properties for the TextPreview component. */
|
|
429
|
+
export interface TextPreviewProps extends ExtensionComponentData {
|
|
430
|
+
component: 'TextPreview'
|
|
431
|
+
/** Markdown content to render. */
|
|
432
|
+
content: string
|
|
433
|
+
/** Maximum number of visible lines before truncating. Defaults to 5. */
|
|
434
|
+
maxLines?: number
|
|
435
|
+
}
|
|
436
|
+
|
|
421
437
|
/** The extension API properties for the Modal component. */
|
|
422
438
|
export interface ModalProps extends ExtensionComponentData {
|
|
423
439
|
component: 'Modal'
|
|
@@ -455,3 +471,28 @@ export interface ConditionalGroupProps extends ExtensionComponentData {
|
|
|
455
471
|
/** Children to render when condition is true. */
|
|
456
472
|
children: ExtensionComponentChildren
|
|
457
473
|
}
|
|
474
|
+
|
|
475
|
+
/** Visual variant for the Frame component. */
|
|
476
|
+
export type FrameVariant = 'border' | 'solid'
|
|
477
|
+
|
|
478
|
+
/** The extension API properties for the Frame component. */
|
|
479
|
+
export interface FrameProps extends ExtensionComponentData {
|
|
480
|
+
component: 'Frame'
|
|
481
|
+
/** Optional title displayed in the header. Can be a plain string or extension components. */
|
|
482
|
+
title?: string | ExtensionComponentChildren
|
|
483
|
+
/** Whether the content can be toggled (collapsed/expanded) by clicking the title. Requires title to be set. */
|
|
484
|
+
collapsible?: boolean
|
|
485
|
+
/** Whether the frame content is expanded by default. Only used when collapsible is true. Defaults to true. */
|
|
486
|
+
defaultExpanded?: boolean
|
|
487
|
+
/** Visual variant: 'border' shows a bordered container, 'solid' shows a solid background. Defaults to 'border'. */
|
|
488
|
+
variant?: FrameVariant
|
|
489
|
+
/** Child components to render inside the frame. */
|
|
490
|
+
children: ExtensionComponentChildren
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** The extension API properties for the List component. */
|
|
494
|
+
export interface ListProps extends ExtensionComponentData {
|
|
495
|
+
component: 'List'
|
|
496
|
+
/** Child components to render as list items. Supports iteration. */
|
|
497
|
+
children: ExtensionComponentChildren
|
|
498
|
+
}
|
package/src/types.context.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { AIProvider } from './types.provider.js'
|
|
8
|
-
import type { Tool, Action } from './types.tools.js'
|
|
8
|
+
import type { Tool, ToolResult, Action } from './types.tools.js'
|
|
9
|
+
import type { ToolDefinition } from './types.contributions.js'
|
|
9
10
|
import type { StorageAPI, SecretsAPI } from './types.storage.js'
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -212,6 +213,24 @@ export interface ToolsAPI {
|
|
|
212
213
|
* Register a tool that Stina can use
|
|
213
214
|
*/
|
|
214
215
|
register(tool: Tool): Disposable
|
|
216
|
+
/**
|
|
217
|
+
* List all registered tools from all extensions.
|
|
218
|
+
* Requires the `tools.list` permission.
|
|
219
|
+
*
|
|
220
|
+
* @returns All tool definitions currently registered across all extensions.
|
|
221
|
+
*/
|
|
222
|
+
list(): Promise<ToolDefinition[]>
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Execute a tool registered by any extension.
|
|
226
|
+
* Requires the `tools.execute` permission.
|
|
227
|
+
*
|
|
228
|
+
* @param toolId - The unique identifier of the tool to execute.
|
|
229
|
+
* @param params - Parameters to pass to the tool.
|
|
230
|
+
* @param userId - Optional user ID for user-scoped tool execution.
|
|
231
|
+
* @returns The result produced by the tool.
|
|
232
|
+
*/
|
|
233
|
+
execute(toolId: string, params: Record<string, unknown>, userId?: string): Promise<ToolResult>
|
|
215
234
|
}
|
|
216
235
|
|
|
217
236
|
/**
|
package/src/types.permissions.ts
CHANGED
package/src/types.provider.ts
CHANGED
|
@@ -87,6 +87,8 @@ export interface ChatOptions {
|
|
|
87
87
|
signal?: AbortSignal
|
|
88
88
|
/** Provider-specific settings from model configuration */
|
|
89
89
|
settings?: Record<string, unknown>
|
|
90
|
+
/** Request context (user info, session metadata — not provider config) */
|
|
91
|
+
context?: { userId?: string; [key: string]: unknown }
|
|
90
92
|
/** Available tools for this request */
|
|
91
93
|
tools?: ToolDefinition[]
|
|
92
94
|
}
|