@stina/extension-api 0.19.1 → 0.21.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.
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Tool and Action Types
3
+ *
4
+ * Types for tool and action implementations.
5
+ */
6
+
7
+ import type { ExecutionContext } from './types.context.js'
8
+
9
+ /**
10
+ * Tool implementation
11
+ */
12
+ export interface Tool {
13
+ /** Tool ID (must match manifest) */
14
+ id: string
15
+ /** Display name */
16
+ name: string
17
+ /** Description for Stina */
18
+ description: string
19
+ /** Parameter schema (JSON Schema) */
20
+ parameters?: Record<string, unknown>
21
+
22
+ /**
23
+ * Execute the tool
24
+ * @param params Tool parameters from the AI
25
+ * @param context Request-scoped execution context with userId and extension metadata
26
+ */
27
+ execute(params: Record<string, unknown>, context: ExecutionContext): Promise<ToolResult>
28
+ }
29
+
30
+ /**
31
+ * Tool execution result
32
+ */
33
+ export interface ToolResult {
34
+ /** Whether the tool succeeded */
35
+ success: boolean
36
+ /** Result data (for Stina to use) */
37
+ data?: unknown
38
+ /** Human-readable message */
39
+ message?: string
40
+ /** Error message if failed */
41
+ error?: string
42
+ }
43
+
44
+ /**
45
+ * Action implementation for UI interactions.
46
+ * Actions are invoked by UI components, not by Stina (AI).
47
+ */
48
+ export interface Action {
49
+ /** Action ID (unique within the extension) */
50
+ id: string
51
+
52
+ /**
53
+ * Execute the action
54
+ * @param params Parameters from the UI component (with $-values already resolved)
55
+ * @param context Request-scoped execution context with userId and extension metadata
56
+ */
57
+ execute(params: Record<string, unknown>, context: ExecutionContext): Promise<ActionResult>
58
+ }
59
+
60
+ /**
61
+ * Action execution result
62
+ */
63
+ export interface ActionResult {
64
+ /** Whether the action succeeded */
65
+ success: boolean
66
+ /** Result data (returned to UI) */
67
+ data?: unknown
68
+ /** Error message if failed */
69
+ error?: string
70
+ }