@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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -3
- package/dist/index.d.ts +62 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +29 -43
- 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 +29 -43
- package/dist/runtime.js.map +1 -1
- package/dist/{types-CvfONPis.d.cts → types.tools-BQrCW_wq.d.cts} +250 -217
- package/dist/{types-CvfONPis.d.ts → types.tools-BQrCW_wq.d.ts} +250 -217
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/runtime.ts +37 -49
- package/src/types.components.ts +21 -0
- package/src/types.context.ts +399 -0
- package/src/types.contributions.ts +404 -0
- package/src/types.localization.ts +39 -0
- package/src/types.manifest.ts +45 -0
- package/src/types.permissions.ts +48 -0
- package/src/types.provider.ts +111 -0
- package/src/types.tools.ts +70 -0
- package/src/types.ts +92 -1038
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Localization Types
|
|
3
|
+
*
|
|
4
|
+
* Types and utilities for localized strings in extensions.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A string that can be either a simple string or a map of language codes to localized strings.
|
|
8
|
+
* When a simple string is provided, it's used as the default/fallback value.
|
|
9
|
+
* When a map is provided, the appropriate language is selected at runtime.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Simple string (backwards compatible)
|
|
13
|
+
* name: "Get Weather"
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Localized strings
|
|
17
|
+
* name: { en: "Get Weather", sv: "Hämta väder", de: "Wetter abrufen" }
|
|
18
|
+
*/
|
|
19
|
+
type LocalizedString = string | Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves a LocalizedString to an actual string value.
|
|
22
|
+
* @param value The LocalizedString to resolve
|
|
23
|
+
* @param lang The preferred language code (e.g., "sv", "en")
|
|
24
|
+
* @param fallbackLang The fallback language code (defaults to "en")
|
|
25
|
+
* @returns The resolved string value
|
|
26
|
+
*/
|
|
27
|
+
declare function resolveLocalizedString(value: LocalizedString, lang: string, fallbackLang?: string): string;
|
|
28
|
+
|
|
1
29
|
/**
|
|
2
30
|
* Allowed CSS property names for extension component styling.
|
|
3
31
|
* Only safe properties that cannot be used for UI spoofing,
|
|
@@ -306,64 +334,33 @@ interface ModalProps extends ExtensionComponentData {
|
|
|
306
334
|
/** Action to call when the modal is closed. */
|
|
307
335
|
onCloseAction?: ExtensionActionRef;
|
|
308
336
|
}
|
|
309
|
-
|
|
310
337
|
/**
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
* When a map is provided, the appropriate language is selected at runtime.
|
|
314
|
-
*
|
|
315
|
-
* @example
|
|
316
|
-
* // Simple string (backwards compatible)
|
|
317
|
-
* name: "Get Weather"
|
|
318
|
-
*
|
|
319
|
-
* @example
|
|
320
|
-
* // Localized strings
|
|
321
|
-
* name: { en: "Get Weather", sv: "Hämta väder", de: "Wetter abrufen" }
|
|
338
|
+
* The extension API properties for the ConditionalGroup component.
|
|
339
|
+
* Renders children only when the condition evaluates to true.
|
|
322
340
|
*/
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
341
|
+
interface ConditionalGroupProps extends ExtensionComponentData {
|
|
342
|
+
component: 'ConditionalGroup';
|
|
343
|
+
/**
|
|
344
|
+
* Condition expression to evaluate.
|
|
345
|
+
* Supports:
|
|
346
|
+
* - Comparison: ==, !=
|
|
347
|
+
* - Logical: && (and), || (or)
|
|
348
|
+
* - Values: $references, 'strings', numbers, true, false, null
|
|
349
|
+
*
|
|
350
|
+
* @example "$form.provider == 'imap'"
|
|
351
|
+
* @example "$form.provider == 'gmail' || $form.provider == 'outlook'"
|
|
352
|
+
*/
|
|
353
|
+
condition: string;
|
|
354
|
+
/** Children to render when condition is true. */
|
|
355
|
+
children: ExtensionComponentChildren;
|
|
356
|
+
}
|
|
357
|
+
|
|
332
358
|
/**
|
|
333
|
-
*
|
|
359
|
+
* Contribution Types
|
|
360
|
+
*
|
|
361
|
+
* Types for extension contributions: settings, panels, providers, tools, commands, prompts.
|
|
334
362
|
*/
|
|
335
|
-
|
|
336
|
-
/** Unique identifier (e.g., "ollama-provider") */
|
|
337
|
-
id: string;
|
|
338
|
-
/** Human-readable name */
|
|
339
|
-
name: string;
|
|
340
|
-
/** Version string (semver) */
|
|
341
|
-
version: string;
|
|
342
|
-
/** Short description */
|
|
343
|
-
description: string;
|
|
344
|
-
/** Author information */
|
|
345
|
-
author: {
|
|
346
|
-
name: string;
|
|
347
|
-
url?: string;
|
|
348
|
-
};
|
|
349
|
-
/** Repository URL */
|
|
350
|
-
repository?: string;
|
|
351
|
-
/** License identifier */
|
|
352
|
-
license?: string;
|
|
353
|
-
/** Minimum Stina version required */
|
|
354
|
-
engines?: {
|
|
355
|
-
stina: string;
|
|
356
|
-
};
|
|
357
|
-
/** Supported platforms */
|
|
358
|
-
platforms?: Platform[];
|
|
359
|
-
/** Entry point file (relative to extension root) */
|
|
360
|
-
main: string;
|
|
361
|
-
/** Required permissions */
|
|
362
|
-
permissions: Permission[];
|
|
363
|
-
/** What the extension contributes */
|
|
364
|
-
contributes?: ExtensionContributions;
|
|
365
|
-
}
|
|
366
|
-
type Platform = 'web' | 'electron' | 'tui';
|
|
363
|
+
|
|
367
364
|
/**
|
|
368
365
|
* What an extension can contribute to Stina
|
|
369
366
|
*/
|
|
@@ -595,21 +592,6 @@ interface ProviderDefinition {
|
|
|
595
592
|
/** Schema for provider-specific configuration UI */
|
|
596
593
|
configSchema?: ProviderConfigSchema;
|
|
597
594
|
}
|
|
598
|
-
type PromptSection = 'system' | 'behavior' | 'tools';
|
|
599
|
-
interface PromptContribution {
|
|
600
|
-
/** Unique ID within the extension */
|
|
601
|
-
id: string;
|
|
602
|
-
/** Optional title for the prompt chunk */
|
|
603
|
-
title?: string;
|
|
604
|
-
/** Prompt section placement */
|
|
605
|
-
section?: PromptSection;
|
|
606
|
-
/** Plain text prompt content */
|
|
607
|
-
text?: string;
|
|
608
|
-
/** Optional localized prompt content (keyed by locale, e.g. "en", "sv") */
|
|
609
|
-
i18n?: Record<string, string>;
|
|
610
|
-
/** Optional ordering hint (lower comes first) */
|
|
611
|
-
order?: number;
|
|
612
|
-
}
|
|
613
595
|
/**
|
|
614
596
|
* Schema for provider-specific configuration.
|
|
615
597
|
* Used to generate UI forms for configuring provider settings.
|
|
@@ -704,17 +686,145 @@ interface CommandDefinition {
|
|
|
704
686
|
/** Description */
|
|
705
687
|
description: string;
|
|
706
688
|
}
|
|
707
|
-
type
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
689
|
+
type PromptSection = 'system' | 'behavior' | 'tools';
|
|
690
|
+
interface PromptContribution {
|
|
691
|
+
/** Unique ID within the extension */
|
|
692
|
+
id: string;
|
|
693
|
+
/** Optional title for the prompt chunk */
|
|
694
|
+
title?: string;
|
|
695
|
+
/** Prompt section placement */
|
|
696
|
+
section?: PromptSection;
|
|
697
|
+
/** Plain text prompt content */
|
|
698
|
+
text?: string;
|
|
699
|
+
/** Optional localized prompt content (keyed by locale, e.g. "en", "sv") */
|
|
700
|
+
i18n?: Record<string, string>;
|
|
701
|
+
/** Optional ordering hint (lower comes first) */
|
|
702
|
+
order?: number;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* AI Provider Types
|
|
707
|
+
*
|
|
708
|
+
* Types for AI providers, models, and chat interactions.
|
|
709
|
+
*/
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* AI provider implementation
|
|
713
|
+
*/
|
|
714
|
+
interface AIProvider {
|
|
715
|
+
/** Provider ID (must match manifest) */
|
|
716
|
+
id: string;
|
|
717
|
+
/** Display name */
|
|
718
|
+
name: string;
|
|
719
|
+
/**
|
|
720
|
+
* Get available models from this provider
|
|
721
|
+
* @param options Optional settings for the provider (e.g., URL)
|
|
722
|
+
*/
|
|
723
|
+
getModels(options?: GetModelsOptions): Promise<ModelInfo[]>;
|
|
724
|
+
/**
|
|
725
|
+
* Chat completion with streaming
|
|
726
|
+
*/
|
|
727
|
+
chat(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamEvent, void, unknown>;
|
|
728
|
+
/**
|
|
729
|
+
* Optional: Generate embeddings
|
|
730
|
+
*/
|
|
731
|
+
embed?(texts: string[]): Promise<number[][]>;
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Model information
|
|
735
|
+
*/
|
|
736
|
+
interface ModelInfo {
|
|
737
|
+
/** Model ID */
|
|
738
|
+
id: string;
|
|
739
|
+
/** Display name */
|
|
740
|
+
name: string;
|
|
741
|
+
/** Description */
|
|
742
|
+
description?: string;
|
|
743
|
+
/** Context window size */
|
|
744
|
+
contextLength?: number;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Chat message
|
|
748
|
+
*/
|
|
749
|
+
interface ChatMessage {
|
|
750
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
751
|
+
content: string;
|
|
752
|
+
/** For assistant messages: tool calls made by the model */
|
|
753
|
+
tool_calls?: ToolCall[];
|
|
754
|
+
/** For tool messages: the ID of the tool call this is a response to */
|
|
755
|
+
tool_call_id?: string;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* A tool call made by the model
|
|
759
|
+
*/
|
|
760
|
+
interface ToolCall {
|
|
761
|
+
/** Unique ID for this tool call */
|
|
762
|
+
id: string;
|
|
763
|
+
/** Tool name/ID to invoke */
|
|
764
|
+
name: string;
|
|
765
|
+
/** Arguments for the tool (as parsed object) */
|
|
766
|
+
arguments: Record<string, unknown>;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Options for chat completion
|
|
770
|
+
*/
|
|
771
|
+
interface ChatOptions {
|
|
772
|
+
/** Model to use */
|
|
773
|
+
model?: string;
|
|
774
|
+
/** Temperature (0-1) */
|
|
775
|
+
temperature?: number;
|
|
776
|
+
/** Maximum tokens to generate */
|
|
777
|
+
maxTokens?: number;
|
|
778
|
+
/** Abort signal for cancellation */
|
|
779
|
+
signal?: AbortSignal;
|
|
780
|
+
/** Provider-specific settings from model configuration */
|
|
781
|
+
settings?: Record<string, unknown>;
|
|
782
|
+
/** Available tools for this request */
|
|
783
|
+
tools?: ToolDefinition[];
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Options for getModels
|
|
787
|
+
*/
|
|
788
|
+
interface GetModelsOptions {
|
|
789
|
+
/** Provider-specific settings (e.g., URL for Ollama) */
|
|
790
|
+
settings?: Record<string, unknown>;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Streaming events from chat
|
|
794
|
+
*/
|
|
795
|
+
type StreamEvent = {
|
|
796
|
+
type: 'content';
|
|
797
|
+
text: string;
|
|
798
|
+
} | {
|
|
799
|
+
type: 'thinking';
|
|
800
|
+
text: string;
|
|
801
|
+
} | {
|
|
802
|
+
type: 'tool_start';
|
|
803
|
+
name: string;
|
|
804
|
+
input: unknown;
|
|
805
|
+
toolCallId: string;
|
|
806
|
+
} | {
|
|
807
|
+
type: 'tool_end';
|
|
808
|
+
name: string;
|
|
809
|
+
output: unknown;
|
|
810
|
+
toolCallId: string;
|
|
811
|
+
} | {
|
|
812
|
+
type: 'done';
|
|
813
|
+
usage?: {
|
|
814
|
+
inputTokens: number;
|
|
815
|
+
outputTokens: number;
|
|
816
|
+
};
|
|
817
|
+
} | {
|
|
818
|
+
type: 'error';
|
|
819
|
+
message: string;
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Extension Context Types
|
|
824
|
+
*
|
|
825
|
+
* Types for extension context and available APIs.
|
|
826
|
+
*/
|
|
827
|
+
|
|
718
828
|
/**
|
|
719
829
|
* Disposable resource that can be cleaned up
|
|
720
830
|
*/
|
|
@@ -722,17 +832,18 @@ interface Disposable {
|
|
|
722
832
|
dispose(): void;
|
|
723
833
|
}
|
|
724
834
|
/**
|
|
725
|
-
*
|
|
835
|
+
* Request-scoped execution context for tool, action, and scheduler operations.
|
|
726
836
|
*
|
|
727
|
-
*
|
|
837
|
+
* This context is passed to every tool and action execute() call, providing
|
|
838
|
+
* request-specific information without relying on global mutable state.
|
|
728
839
|
*
|
|
729
|
-
*
|
|
730
|
-
* - A tool is executed by a user
|
|
731
|
-
* - An action is executed by a user
|
|
732
|
-
* - A scheduled job fires (if the job was created with a userId)
|
|
840
|
+
* ## Why Request-Scoped Context?
|
|
733
841
|
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
842
|
+
* Using request-scoped context instead of global state:
|
|
843
|
+
* - Eliminates race conditions (no global userId that can change mid-execution)
|
|
844
|
+
* - Provides cleaner architecture with explicit data flow
|
|
845
|
+
* - Makes code easier to reason about and debug
|
|
846
|
+
* - Allows scheduler jobs to create context for the correct user
|
|
736
847
|
*
|
|
737
848
|
* @example
|
|
738
849
|
* ```typescript
|
|
@@ -742,9 +853,31 @@ interface Disposable {
|
|
|
742
853
|
* // User-specific logic
|
|
743
854
|
* const userData = await storage.getForUser(context.userId, 'preferences')
|
|
744
855
|
* }
|
|
856
|
+
* // Access extension metadata
|
|
857
|
+
* console.log(`Running in extension ${context.extension.id}`)
|
|
745
858
|
* }
|
|
746
859
|
* ```
|
|
747
860
|
*/
|
|
861
|
+
interface ExecutionContext {
|
|
862
|
+
/**
|
|
863
|
+
* User ID for the current request.
|
|
864
|
+
* Undefined only for system/global operations during extension activation.
|
|
865
|
+
* Always defined for tool executions, action executions, and scheduler callbacks.
|
|
866
|
+
*/
|
|
867
|
+
readonly userId?: string;
|
|
868
|
+
/** Extension metadata */
|
|
869
|
+
readonly extension: {
|
|
870
|
+
readonly id: string;
|
|
871
|
+
readonly version: string;
|
|
872
|
+
readonly storagePath: string;
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Context provided to extension's activate function.
|
|
877
|
+
*
|
|
878
|
+
* Note: This context is for extension activation only. For tool/action execution,
|
|
879
|
+
* use the ExecutionContext parameter passed to execute() methods.
|
|
880
|
+
*/
|
|
748
881
|
interface ExtensionContext {
|
|
749
882
|
/** Extension metadata */
|
|
750
883
|
readonly extension: {
|
|
@@ -752,11 +885,6 @@ interface ExtensionContext {
|
|
|
752
885
|
readonly version: string;
|
|
753
886
|
readonly storagePath: string;
|
|
754
887
|
};
|
|
755
|
-
/**
|
|
756
|
-
* Current user ID if in a user context, undefined for global/system operations.
|
|
757
|
-
* Set when tools or actions are executed by a user, or when a user-scoped job fires.
|
|
758
|
-
*/
|
|
759
|
-
readonly userId?: string;
|
|
760
888
|
/** Network access (if permitted) */
|
|
761
889
|
readonly network?: NetworkAPI;
|
|
762
890
|
/** Settings access (if permitted) */
|
|
@@ -891,11 +1019,11 @@ interface SchedulerJobRequest {
|
|
|
891
1019
|
payload?: Record<string, unknown>;
|
|
892
1020
|
misfire?: 'run_once' | 'skip';
|
|
893
1021
|
/**
|
|
894
|
-
*
|
|
895
|
-
*
|
|
896
|
-
* will be passed to the extension when the job fires.
|
|
1022
|
+
* User ID for the job owner.
|
|
1023
|
+
* All scheduled jobs must be associated with a user. The userId
|
|
1024
|
+
* will be passed to the extension when the job fires via ExecutionContext.
|
|
897
1025
|
*/
|
|
898
|
-
userId
|
|
1026
|
+
userId: string;
|
|
899
1027
|
}
|
|
900
1028
|
/**
|
|
901
1029
|
* Scheduler fire payload
|
|
@@ -906,8 +1034,8 @@ interface SchedulerFirePayload {
|
|
|
906
1034
|
scheduledFor: string;
|
|
907
1035
|
firedAt: string;
|
|
908
1036
|
delayMs: number;
|
|
909
|
-
/** User ID
|
|
910
|
-
userId
|
|
1037
|
+
/** User ID for the job owner */
|
|
1038
|
+
userId: string;
|
|
911
1039
|
}
|
|
912
1040
|
/**
|
|
913
1041
|
* Scheduler API for registering jobs
|
|
@@ -915,7 +1043,12 @@ interface SchedulerFirePayload {
|
|
|
915
1043
|
interface SchedulerAPI {
|
|
916
1044
|
schedule(job: SchedulerJobRequest): Promise<void>;
|
|
917
1045
|
cancel(jobId: string): Promise<void>;
|
|
918
|
-
|
|
1046
|
+
/**
|
|
1047
|
+
* Register a callback for when scheduled jobs fire.
|
|
1048
|
+
* The callback receives both the fire payload and an ExecutionContext
|
|
1049
|
+
* with userId if the job was created with a userId.
|
|
1050
|
+
*/
|
|
1051
|
+
onFire(callback: (payload: SchedulerFirePayload, context: ExecutionContext) => void | Promise<void>): Disposable;
|
|
919
1052
|
}
|
|
920
1053
|
/**
|
|
921
1054
|
* User profile data
|
|
@@ -1032,115 +1165,25 @@ interface LogAPI {
|
|
|
1032
1165
|
error(message: string, data?: Record<string, unknown>): void;
|
|
1033
1166
|
}
|
|
1034
1167
|
/**
|
|
1035
|
-
*
|
|
1168
|
+
* Extension entry point interface
|
|
1036
1169
|
*/
|
|
1037
|
-
interface
|
|
1038
|
-
/** Provider ID (must match manifest) */
|
|
1039
|
-
id: string;
|
|
1040
|
-
/** Display name */
|
|
1041
|
-
name: string;
|
|
1042
|
-
/**
|
|
1043
|
-
* Get available models from this provider
|
|
1044
|
-
* @param options Optional settings for the provider (e.g., URL)
|
|
1045
|
-
*/
|
|
1046
|
-
getModels(options?: GetModelsOptions): Promise<ModelInfo[]>;
|
|
1170
|
+
interface ExtensionModule {
|
|
1047
1171
|
/**
|
|
1048
|
-
*
|
|
1172
|
+
* Called when extension is activated
|
|
1049
1173
|
*/
|
|
1050
|
-
|
|
1174
|
+
activate(context: ExtensionContext): void | Disposable | Promise<void | Disposable>;
|
|
1051
1175
|
/**
|
|
1052
|
-
*
|
|
1176
|
+
* Called when extension is deactivated
|
|
1053
1177
|
*/
|
|
1054
|
-
|
|
1055
|
-
}
|
|
1056
|
-
/**
|
|
1057
|
-
* Model information
|
|
1058
|
-
*/
|
|
1059
|
-
interface ModelInfo {
|
|
1060
|
-
/** Model ID */
|
|
1061
|
-
id: string;
|
|
1062
|
-
/** Display name */
|
|
1063
|
-
name: string;
|
|
1064
|
-
/** Description */
|
|
1065
|
-
description?: string;
|
|
1066
|
-
/** Context window size */
|
|
1067
|
-
contextLength?: number;
|
|
1068
|
-
}
|
|
1069
|
-
/**
|
|
1070
|
-
* Chat message
|
|
1071
|
-
*/
|
|
1072
|
-
interface ChatMessage {
|
|
1073
|
-
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
1074
|
-
content: string;
|
|
1075
|
-
/** For assistant messages: tool calls made by the model */
|
|
1076
|
-
tool_calls?: ToolCall[];
|
|
1077
|
-
/** For tool messages: the ID of the tool call this is a response to */
|
|
1078
|
-
tool_call_id?: string;
|
|
1079
|
-
}
|
|
1080
|
-
/**
|
|
1081
|
-
* A tool call made by the model
|
|
1082
|
-
*/
|
|
1083
|
-
interface ToolCall {
|
|
1084
|
-
/** Unique ID for this tool call */
|
|
1085
|
-
id: string;
|
|
1086
|
-
/** Tool name/ID to invoke */
|
|
1087
|
-
name: string;
|
|
1088
|
-
/** Arguments for the tool (as parsed object) */
|
|
1089
|
-
arguments: Record<string, unknown>;
|
|
1090
|
-
}
|
|
1091
|
-
/**
|
|
1092
|
-
* Options for chat completion
|
|
1093
|
-
*/
|
|
1094
|
-
interface ChatOptions {
|
|
1095
|
-
/** Model to use */
|
|
1096
|
-
model?: string;
|
|
1097
|
-
/** Temperature (0-1) */
|
|
1098
|
-
temperature?: number;
|
|
1099
|
-
/** Maximum tokens to generate */
|
|
1100
|
-
maxTokens?: number;
|
|
1101
|
-
/** Abort signal for cancellation */
|
|
1102
|
-
signal?: AbortSignal;
|
|
1103
|
-
/** Provider-specific settings from model configuration */
|
|
1104
|
-
settings?: Record<string, unknown>;
|
|
1105
|
-
/** Available tools for this request */
|
|
1106
|
-
tools?: ToolDefinition[];
|
|
1107
|
-
}
|
|
1108
|
-
/**
|
|
1109
|
-
* Options for getModels
|
|
1110
|
-
*/
|
|
1111
|
-
interface GetModelsOptions {
|
|
1112
|
-
/** Provider-specific settings (e.g., URL for Ollama) */
|
|
1113
|
-
settings?: Record<string, unknown>;
|
|
1178
|
+
deactivate?(): void | Promise<void>;
|
|
1114
1179
|
}
|
|
1180
|
+
|
|
1115
1181
|
/**
|
|
1116
|
-
*
|
|
1182
|
+
* Tool and Action Types
|
|
1183
|
+
*
|
|
1184
|
+
* Types for tool and action implementations.
|
|
1117
1185
|
*/
|
|
1118
|
-
|
|
1119
|
-
type: 'content';
|
|
1120
|
-
text: string;
|
|
1121
|
-
} | {
|
|
1122
|
-
type: 'thinking';
|
|
1123
|
-
text: string;
|
|
1124
|
-
} | {
|
|
1125
|
-
type: 'tool_start';
|
|
1126
|
-
name: string;
|
|
1127
|
-
input: unknown;
|
|
1128
|
-
toolCallId: string;
|
|
1129
|
-
} | {
|
|
1130
|
-
type: 'tool_end';
|
|
1131
|
-
name: string;
|
|
1132
|
-
output: unknown;
|
|
1133
|
-
toolCallId: string;
|
|
1134
|
-
} | {
|
|
1135
|
-
type: 'done';
|
|
1136
|
-
usage?: {
|
|
1137
|
-
inputTokens: number;
|
|
1138
|
-
outputTokens: number;
|
|
1139
|
-
};
|
|
1140
|
-
} | {
|
|
1141
|
-
type: 'error';
|
|
1142
|
-
message: string;
|
|
1143
|
-
};
|
|
1186
|
+
|
|
1144
1187
|
/**
|
|
1145
1188
|
* Tool implementation
|
|
1146
1189
|
*/
|
|
@@ -1155,8 +1198,10 @@ interface Tool {
|
|
|
1155
1198
|
parameters?: Record<string, unknown>;
|
|
1156
1199
|
/**
|
|
1157
1200
|
* Execute the tool
|
|
1201
|
+
* @param params Tool parameters from the AI
|
|
1202
|
+
* @param context Request-scoped execution context with userId and extension metadata
|
|
1158
1203
|
*/
|
|
1159
|
-
execute(params: Record<string, unknown
|
|
1204
|
+
execute(params: Record<string, unknown>, context: ExecutionContext): Promise<ToolResult>;
|
|
1160
1205
|
}
|
|
1161
1206
|
/**
|
|
1162
1207
|
* Tool execution result
|
|
@@ -1181,8 +1226,9 @@ interface Action {
|
|
|
1181
1226
|
/**
|
|
1182
1227
|
* Execute the action
|
|
1183
1228
|
* @param params Parameters from the UI component (with $-values already resolved)
|
|
1229
|
+
* @param context Request-scoped execution context with userId and extension metadata
|
|
1184
1230
|
*/
|
|
1185
|
-
execute(params: Record<string, unknown
|
|
1231
|
+
execute(params: Record<string, unknown>, context: ExecutionContext): Promise<ActionResult>;
|
|
1186
1232
|
}
|
|
1187
1233
|
/**
|
|
1188
1234
|
* Action execution result
|
|
@@ -1195,18 +1241,5 @@ interface ActionResult {
|
|
|
1195
1241
|
/** Error message if failed */
|
|
1196
1242
|
error?: string;
|
|
1197
1243
|
}
|
|
1198
|
-
/**
|
|
1199
|
-
* Extension entry point interface
|
|
1200
|
-
*/
|
|
1201
|
-
interface ExtensionModule {
|
|
1202
|
-
/**
|
|
1203
|
-
* Called when extension is activated
|
|
1204
|
-
*/
|
|
1205
|
-
activate(context: ExtensionContext): void | Disposable | Promise<void | Disposable>;
|
|
1206
|
-
/**
|
|
1207
|
-
* Called when extension is deactivated
|
|
1208
|
-
*/
|
|
1209
|
-
deactivate?(): void | Promise<void>;
|
|
1210
|
-
}
|
|
1211
1244
|
|
|
1212
|
-
export { type
|
|
1245
|
+
export { type AIProvider as $, type ActionResult as A, type ExtensionContext as B, type ChatMessage as C, type Disposable as D, type ExtensionContributions as E, type SettingsAPI as F, type GetModelsOptions as G, type ProvidersAPI as H, type ToolsAPI as I, type ActionsAPI as J, type EventsAPI as K, type LocalizedString as L, type ModelInfo as M, type NetworkAPI as N, type SchedulerAPI as O, type PanelDefinition as P, type SchedulerJobRequest as Q, type SchedulerSchedule as R, type SchedulerFirePayload as S, type ToolResult as T, type UserAPI as U, type UserProfile as V, type ChatAPI as W, type ChatInstructionMessage as X, type DatabaseAPI as Y, type StorageAPI as Z, type LogAPI as _, type ChatOptions as a, type ToolCall as a0, type Tool as a1, type Action as a2, type ExtensionModule as a3, type AllowedCSSProperty as a4, type ExtensionComponentStyle as a5, type ExtensionComponentData as a6, type ExtensionComponentIterator as a7, type ExtensionComponentChildren as a8, type ExtensionActionCall as a9, type ConditionalGroupProps as aA, type ExecutionContext as aB, type ExtensionActionRef as aa, type ExtensionDataSource as ab, type ExtensionPanelDefinition as ac, type HeaderProps as ad, type LabelProps as ae, type ParagraphProps as af, type ButtonProps as ag, type TextInputProps as ah, type DateTimeInputProps as ai, type SelectProps as aj, type VerticalStackProps as ak, type HorizontalStackProps as al, type GridProps as am, type DividerProps as an, type IconProps as ao, type IconButtonType as ap, type IconButtonProps as aq, type PanelAction as ar, type PanelProps as as, type ToggleProps as at, type CollapsibleProps as au, type PillVariant as av, type PillProps as aw, type CheckboxProps as ax, type MarkdownProps as ay, type ModalProps 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 CommandDefinition as u, type ProviderConfigSchema as v, type ProviderConfigProperty as w, type ProviderConfigPropertyType as x, type ProviderConfigSelectOption as y, type ProviderConfigValidation as z };
|
package/package.json
CHANGED