@stina/extension-api 0.7.0 → 0.8.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/README.md +107 -0
- package/dist/{chunk-SS4D3JYX.js → chunk-IKJ37ZGB.js} +1 -1
- package/dist/chunk-IKJ37ZGB.js.map +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -6
- package/dist/index.d.ts +33 -6
- package/dist/index.js +1 -1
- package/dist/runtime.cjs +116 -0
- 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 +117 -1
- package/dist/runtime.js.map +1 -1
- package/dist/{types-Brv9O9NY.d.cts → types-Cr8eCJ0G.d.cts} +413 -2
- package/dist/{types-Brv9O9NY.d.ts → types-Cr8eCJ0G.d.ts} +413 -2
- package/package.json +1 -1
- package/src/index.ts +56 -0
- package/src/messages.ts +50 -1
- package/src/runtime.ts +146 -0
- package/src/types.components.ts +236 -0
- package/src/types.ts +234 -0
- package/dist/chunk-SS4D3JYX.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# @stina/extension-api
|
|
2
|
+
|
|
3
|
+
Type definitions and runtime helpers for building extensions for Stina (https://github.com/einord/stina).
|
|
4
|
+
Use this package to define your extension manifest, register tools/providers, and access the extension context.
|
|
5
|
+
|
|
6
|
+
## What this package is for
|
|
7
|
+
|
|
8
|
+
- Authoring Stina extensions (tools, providers, settings, commands, prompts).
|
|
9
|
+
- Typing `manifest.json` and runtime code with Stina's Extension API.
|
|
10
|
+
- Running extension code inside Stina's sandboxed worker via the runtime helper.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @stina/extension-api
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
(Use npm or yarn if you prefer.)
|
|
19
|
+
|
|
20
|
+
## Minimal extension example
|
|
21
|
+
|
|
22
|
+
### 1) `manifest.json`
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"id": "example.hello",
|
|
27
|
+
"name": "Hello Extension",
|
|
28
|
+
"version": "0.1.0",
|
|
29
|
+
"description": "Adds a hello tool",
|
|
30
|
+
"author": { "name": "Your Name" },
|
|
31
|
+
"main": "dist/index.js",
|
|
32
|
+
"permissions": ["tools.register"],
|
|
33
|
+
"contributes": {
|
|
34
|
+
"tools": [
|
|
35
|
+
{
|
|
36
|
+
"id": "example.hello",
|
|
37
|
+
"name": "Hello",
|
|
38
|
+
"description": "Returns a friendly greeting",
|
|
39
|
+
"parameters": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"name": { "type": "string" }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2) Extension entry point (`src/index.ts`)
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import type { ExtensionModule } from '@stina/extension-api'
|
|
55
|
+
import { initializeExtension } from '@stina/extension-api/runtime'
|
|
56
|
+
|
|
57
|
+
const extension: ExtensionModule = {
|
|
58
|
+
activate(context) {
|
|
59
|
+
context.log.info('Hello extension activated', { id: context.extension.id })
|
|
60
|
+
|
|
61
|
+
context.tools?.register({
|
|
62
|
+
id: 'example.hello',
|
|
63
|
+
name: 'Hello',
|
|
64
|
+
description: 'Returns a friendly greeting',
|
|
65
|
+
execute: async (params) => {
|
|
66
|
+
const name = typeof params?.name === 'string' ? params.name : 'there'
|
|
67
|
+
return { message: `Hello, ${name}!` }
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
initializeExtension(extension)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3) Build output
|
|
77
|
+
|
|
78
|
+
Bundle your extension so that `manifest.json` points at the built file (`main`).
|
|
79
|
+
For example, compile to `dist/index.js` and publish the zip/release with:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
manifest.json
|
|
83
|
+
src/
|
|
84
|
+
dist/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Common patterns
|
|
88
|
+
|
|
89
|
+
- Use `contributes` in `manifest.json` for UI definitions.
|
|
90
|
+
- Use `context.tools?.register(...)` or `context.providers?.register(...)` at runtime.
|
|
91
|
+
- Always include the permission that matches what you register (`tools.register`, `provider.register`, etc.).
|
|
92
|
+
- Keep runtime code platform-agnostic; it runs in a worker.
|
|
93
|
+
|
|
94
|
+
## Publish to Stina Extension Library
|
|
95
|
+
|
|
96
|
+
Extensions that should appear in the Stina Extension Library must be registered via a Pull Request to:
|
|
97
|
+
https://github.com/einord/stina-extensions-registry
|
|
98
|
+
|
|
99
|
+
## Real-world example
|
|
100
|
+
|
|
101
|
+
For a real, but still approachable example of a Stina extension in use, see:
|
|
102
|
+
https://github.com/einord/stina-ext-people
|
|
103
|
+
|
|
104
|
+
## Links
|
|
105
|
+
|
|
106
|
+
- Manifest types: `ExtensionManifest` in this package.
|
|
107
|
+
- Runtime helper: `@stina/extension-api/runtime`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/messages.ts"],"sourcesContent":["/**\n * Message protocol between Extension Host and Extension Workers\n */\n\nimport type {\n ChatMessage,\n ChatOptions,\n GetModelsOptions,\n StreamEvent,\n ToolResult,\n ActionResult,\n ModelInfo,\n SchedulerFirePayload,\n} from './types.js'\n\n// ============================================================================\n// Host → Worker Messages\n// ============================================================================\n\nexport type HostToWorkerMessage =\n | ActivateMessage\n | DeactivateMessage\n | SettingsChangedMessage\n | SchedulerFireMessage\n | ProviderChatRequestMessage\n | ProviderModelsRequestMessage\n | ToolExecuteRequestMessage\n | ActionExecuteRequestMessage\n | ResponseMessage\n\nexport interface ActivateMessage {\n type: 'activate'\n id: string\n payload: {\n extensionId: string\n extensionVersion: string\n storagePath: string\n permissions: string[]\n settings: Record<string, unknown>\n }\n}\n\nexport interface DeactivateMessage {\n type: 'deactivate'\n id: string\n}\n\nexport interface SettingsChangedMessage {\n type: 'settings-changed'\n id: string\n payload: {\n key: string\n value: unknown\n }\n}\n\nexport interface SchedulerFireMessage {\n type: 'scheduler-fire'\n id: string\n payload: SchedulerFirePayload\n}\n\nexport interface ProviderChatRequestMessage {\n type: 'provider-chat-request'\n id: string\n payload: {\n providerId: string\n messages: ChatMessage[]\n options: ChatOptions\n }\n}\n\nexport interface ProviderModelsRequestMessage {\n type: 'provider-models-request'\n id: string\n payload: {\n providerId: string\n options?: GetModelsOptions\n }\n}\n\nexport interface ToolExecuteRequestMessage {\n type: 'tool-execute-request'\n id: string\n payload: {\n toolId: string\n params: Record<string, unknown>\n }\n}\n\nexport interface ActionExecuteRequestMessage {\n type: 'action-execute-request'\n id: string\n payload: {\n actionId: string\n params: Record<string, unknown>\n }\n}\n\nexport interface ResponseMessage {\n type: 'response'\n id: string\n payload: {\n requestId: string\n success: boolean\n data?: unknown\n error?: string\n }\n}\n\n// ============================================================================\n// Worker → Host Messages\n// ============================================================================\n\nexport type WorkerToHostMessage =\n | ReadyMessage\n | RequestMessage\n | ProviderRegisteredMessage\n | ToolRegisteredMessage\n | ActionRegisteredMessage\n | StreamEventMessage\n | LogMessage\n | ProviderModelsResponseMessage\n | ToolExecuteResponseMessage\n | ActionExecuteResponseMessage\n\nexport interface ReadyMessage {\n type: 'ready'\n}\n\nexport interface RequestMessage {\n type: 'request'\n id: string\n method: RequestMethod\n payload: unknown\n}\n\nexport type RequestMethod =\n | 'network.fetch'\n | 'settings.getAll'\n | 'settings.get'\n | 'settings.set'\n | 'user.getProfile'\n | 'events.emit'\n | 'scheduler.schedule'\n | 'scheduler.cancel'\n | 'chat.appendInstruction'\n | 'database.execute'\n | 'storage.get'\n | 'storage.set'\n | 'storage.delete'\n | 'storage.keys'\n\nexport interface ProviderRegisteredMessage {\n type: 'provider-registered'\n payload: {\n id: string\n name: string\n }\n}\n\nexport interface ToolRegisteredMessage {\n type: 'tool-registered'\n payload: {\n id: string\n name: string\n description: string\n parameters?: Record<string, unknown>\n }\n}\n\nexport interface ActionRegisteredMessage {\n type: 'action-registered'\n payload: {\n id: string\n }\n}\n\nexport interface StreamEventMessage {\n type: 'stream-event'\n payload: {\n requestId: string\n event: StreamEvent\n }\n}\n\nexport interface ProviderModelsResponseMessage {\n type: 'provider-models-response'\n payload: {\n requestId: string\n models: ModelInfo[]\n error?: string\n }\n}\n\nexport interface ToolExecuteResponseMessage {\n type: 'tool-execute-response'\n payload: {\n requestId: string\n result: ToolResult\n error?: string\n }\n}\n\nexport interface ActionExecuteResponseMessage {\n type: 'action-execute-response'\n payload: {\n requestId: string\n result: ActionResult\n error?: string\n }\n}\n\nexport interface LogMessage {\n type: 'log'\n payload: {\n level: 'debug' | 'info' | 'warn' | 'error'\n message: string\n data?: Record<string, unknown>\n }\n}\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\nexport interface PendingRequest<T = unknown> {\n resolve: (value: T) => void\n reject: (error: Error) => void\n timeout: ReturnType<typeof setTimeout>\n}\n\n/**\n * Generate a unique message ID\n */\nexport function generateMessageId(): string {\n return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`\n}\n"],"mappings":";;;;;;;;AA2OO,SAAS,oBAA4B;AAC1C,SAAO,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACjE;","names":[]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/messages.ts"],"sourcesContent":["/**\n * @stina/extension-api\n *\n * Types and utilities for building Stina extensions.\n *\n * Extensions should import from this package for type definitions.\n * The runtime (worker-side code) should import from '@stina/extension-api/runtime'.\n */\n\n// Types\nexport type {\n // Manifest\n ExtensionManifest,\n Platform,\n ExtensionContributions,\n SettingDefinition,\n ToolSettingsViewDefinition,\n ToolSettingsView,\n ToolSettingsListView,\n ToolSettingsListMapping,\n ProviderDefinition,\n PromptContribution,\n PromptSection,\n ToolDefinition,\n CommandDefinition,\n\n // Provider Configuration Schema\n ProviderConfigSchema,\n ProviderConfigProperty,\n ProviderConfigPropertyType,\n ProviderConfigSelectOption,\n ProviderConfigValidation,\n\n // Permissions\n Permission,\n NetworkPermission,\n StoragePermission,\n UserDataPermission,\n CapabilityPermission,\n SystemPermission,\n\n // Context\n ExtensionContext,\n Disposable,\n NetworkAPI,\n SettingsAPI,\n ProvidersAPI,\n ToolsAPI,\n DatabaseAPI,\n StorageAPI,\n LogAPI,\n\n // AI Provider\n AIProvider,\n ModelInfo,\n ChatMessage,\n ChatOptions,\n GetModelsOptions,\n StreamEvent,\n ToolCall,\n\n // Tools\n Tool,\n ToolResult,\n\n // Entry point\n ExtensionModule,\n} from './types.js'\n\n// Messages (for host implementation)\nexport type {\n HostToWorkerMessage,\n WorkerToHostMessage,\n ActivateMessage,\n DeactivateMessage,\n SettingsChangedMessage,\n ProviderChatRequestMessage,\n ProviderModelsRequestMessage,\n ToolExecuteRequestMessage,\n ToolExecuteResponseMessage,\n ResponseMessage,\n ReadyMessage,\n RequestMessage,\n RequestMethod,\n ProviderRegisteredMessage,\n ToolRegisteredMessage,\n StreamEventMessage,\n LogMessage,\n PendingRequest,\n} from './messages.js'\n\nexport { generateMessageId } from './messages.js'\n","/**\n * Message protocol between Extension Host and Extension Workers\n */\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/messages.ts"],"sourcesContent":["/**\n * @stina/extension-api\n *\n * Types and utilities for building Stina extensions.\n *\n * Extensions should import from this package for type definitions.\n * The runtime (worker-side code) should import from '@stina/extension-api/runtime'.\n */\n\n// Types\nexport type {\n // Manifest\n ExtensionManifest,\n Platform,\n ExtensionContributions,\n SettingDefinition,\n SettingOptionsMapping,\n SettingCreateMapping,\n ToolSettingsViewDefinition,\n ToolSettingsView,\n ToolSettingsListView,\n ToolSettingsListMapping,\n PanelDefinition,\n PanelView,\n PanelComponentView,\n PanelActionDataSource,\n PanelUnknownView,\n ProviderDefinition,\n PromptContribution,\n PromptSection,\n ToolDefinition,\n CommandDefinition,\n\n // Provider Configuration Schema\n ProviderConfigSchema,\n ProviderConfigProperty,\n ProviderConfigPropertyType,\n ProviderConfigSelectOption,\n ProviderConfigValidation,\n\n // Permissions\n Permission,\n NetworkPermission,\n StoragePermission,\n UserDataPermission,\n CapabilityPermission,\n SystemPermission,\n\n // Context\n ExtensionContext,\n Disposable,\n NetworkAPI,\n SettingsAPI,\n ProvidersAPI,\n ToolsAPI,\n ActionsAPI,\n EventsAPI,\n SchedulerAPI,\n SchedulerJobRequest,\n SchedulerSchedule,\n SchedulerFirePayload,\n UserAPI,\n UserProfile,\n ChatAPI,\n ChatInstructionMessage,\n DatabaseAPI,\n StorageAPI,\n LogAPI,\n\n // AI Provider\n AIProvider,\n ModelInfo,\n ChatMessage,\n ChatOptions,\n GetModelsOptions,\n StreamEvent,\n ToolCall,\n\n // Tools\n Tool,\n ToolResult,\n\n // Actions\n Action,\n ActionResult,\n\n // Entry point\n ExtensionModule,\n} from './types.js'\n\n// Messages (for host implementation)\nexport type {\n HostToWorkerMessage,\n WorkerToHostMessage,\n ActivateMessage,\n DeactivateMessage,\n SettingsChangedMessage,\n ProviderChatRequestMessage,\n ProviderModelsRequestMessage,\n ToolExecuteRequestMessage,\n ToolExecuteResponseMessage,\n ActionExecuteRequestMessage,\n ActionExecuteResponseMessage,\n ResponseMessage,\n ReadyMessage,\n RequestMessage,\n RequestMethod,\n ProviderRegisteredMessage,\n ToolRegisteredMessage,\n ActionRegisteredMessage,\n StreamEventMessage,\n LogMessage,\n PendingRequest,\n} from './messages.js'\n\nexport { generateMessageId } from './messages.js'\n\n// Component types (for extension UI components)\nexport type {\n // Base types\n ExtensionComponentData,\n // Iteration & Children\n ExtensionComponentIterator,\n ExtensionComponentChildren,\n // Actions\n ExtensionActionCall,\n ExtensionActionRef,\n // Data Sources & Panel Definition\n ExtensionDataSource,\n ExtensionPanelDefinition,\n // Component Props\n HeaderProps,\n LabelProps,\n ParagraphProps,\n ButtonProps,\n TextInputProps,\n SelectProps,\n VerticalStackProps,\n HorizontalStackProps,\n GridProps,\n DividerProps,\n IconProps,\n IconButtonType,\n IconButtonProps,\n PanelAction,\n PanelProps,\n ToggleProps,\n} from './types.components.js'\n","/**\n * Message protocol between Extension Host and Extension Workers\n */\n\nimport type {\n ChatMessage,\n ChatOptions,\n GetModelsOptions,\n StreamEvent,\n ToolResult,\n ActionResult,\n ModelInfo,\n SchedulerFirePayload,\n} from './types.js'\n\n// ============================================================================\n// Host → Worker Messages\n// ============================================================================\n\nexport type HostToWorkerMessage =\n | ActivateMessage\n | DeactivateMessage\n | SettingsChangedMessage\n | SchedulerFireMessage\n | ProviderChatRequestMessage\n | ProviderModelsRequestMessage\n | ToolExecuteRequestMessage\n | ActionExecuteRequestMessage\n | ResponseMessage\n\nexport interface ActivateMessage {\n type: 'activate'\n id: string\n payload: {\n extensionId: string\n extensionVersion: string\n storagePath: string\n permissions: string[]\n settings: Record<string, unknown>\n }\n}\n\nexport interface DeactivateMessage {\n type: 'deactivate'\n id: string\n}\n\nexport interface SettingsChangedMessage {\n type: 'settings-changed'\n id: string\n payload: {\n key: string\n value: unknown\n }\n}\n\nexport interface SchedulerFireMessage {\n type: 'scheduler-fire'\n id: string\n payload: SchedulerFirePayload\n}\n\nexport interface ProviderChatRequestMessage {\n type: 'provider-chat-request'\n id: string\n payload: {\n providerId: string\n messages: ChatMessage[]\n options: ChatOptions\n }\n}\n\nexport interface ProviderModelsRequestMessage {\n type: 'provider-models-request'\n id: string\n payload: {\n providerId: string\n options?: GetModelsOptions\n }\n}\n\nexport interface ToolExecuteRequestMessage {\n type: 'tool-execute-request'\n id: string\n payload: {\n toolId: string\n params: Record<string, unknown>\n }\n}\n\nexport interface ActionExecuteRequestMessage {\n type: 'action-execute-request'\n id: string\n payload: {\n actionId: string\n params: Record<string, unknown>\n }\n}\n\nexport interface ResponseMessage {\n type: 'response'\n id: string\n payload: {\n requestId: string\n success: boolean\n data?: unknown\n error?: string\n }\n}\n\n// ============================================================================\n// Worker → Host Messages\n// ============================================================================\n\nexport type WorkerToHostMessage =\n | ReadyMessage\n | RequestMessage\n | ProviderRegisteredMessage\n | ToolRegisteredMessage\n | ActionRegisteredMessage\n | StreamEventMessage\n | LogMessage\n | ProviderModelsResponseMessage\n | ToolExecuteResponseMessage\n | ActionExecuteResponseMessage\n\nexport interface ReadyMessage {\n type: 'ready'\n}\n\nexport interface RequestMessage {\n type: 'request'\n id: string\n method: RequestMethod\n payload: unknown\n}\n\nexport type RequestMethod =\n | 'network.fetch'\n | 'settings.getAll'\n | 'settings.get'\n | 'settings.set'\n | 'user.getProfile'\n | 'events.emit'\n | 'scheduler.schedule'\n | 'scheduler.cancel'\n | 'chat.appendInstruction'\n | 'database.execute'\n | 'storage.get'\n | 'storage.set'\n | 'storage.delete'\n | 'storage.keys'\n\nexport interface ProviderRegisteredMessage {\n type: 'provider-registered'\n payload: {\n id: string\n name: string\n }\n}\n\nexport interface ToolRegisteredMessage {\n type: 'tool-registered'\n payload: {\n id: string\n name: string\n description: string\n parameters?: Record<string, unknown>\n }\n}\n\nexport interface ActionRegisteredMessage {\n type: 'action-registered'\n payload: {\n id: string\n }\n}\n\nexport interface StreamEventMessage {\n type: 'stream-event'\n payload: {\n requestId: string\n event: StreamEvent\n }\n}\n\nexport interface ProviderModelsResponseMessage {\n type: 'provider-models-response'\n payload: {\n requestId: string\n models: ModelInfo[]\n error?: string\n }\n}\n\nexport interface ToolExecuteResponseMessage {\n type: 'tool-execute-response'\n payload: {\n requestId: string\n result: ToolResult\n error?: string\n }\n}\n\nexport interface ActionExecuteResponseMessage {\n type: 'action-execute-response'\n payload: {\n requestId: string\n result: ActionResult\n error?: string\n }\n}\n\nexport interface LogMessage {\n type: 'log'\n payload: {\n level: 'debug' | 'info' | 'warn' | 'error'\n message: string\n data?: Record<string, unknown>\n }\n}\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\nexport interface PendingRequest<T = unknown> {\n resolve: (value: T) => void\n reject: (error: Error) => void\n timeout: ReturnType<typeof setTimeout>\n}\n\n/**\n * Generate a unique message ID\n */\nexport function generateMessageId(): string {\n return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC2OO,SAAS,oBAA4B;AAC1C,SAAO,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACjE;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as ChatMessage, a as ChatOptions, G as GetModelsOptions,
|
|
2
|
-
export {
|
|
1
|
+
import { S as SchedulerFirePayload, C as ChatMessage, a as ChatOptions, G as GetModelsOptions, b as StreamEvent, M as ModelInfo, T as ToolResult, A as ActionResult } from './types-Cr8eCJ0G.cjs';
|
|
2
|
+
export { a3 as AIProvider, a6 as Action, Q as ActionsAPI, ai as ButtonProps, D as CapabilityPermission, _ as ChatAPI, $ as ChatInstructionMessage, t as CommandDefinition, a0 as DatabaseAPI, I as Disposable, ao as DividerProps, R as EventsAPI, ab as ExtensionActionCall, ac as ExtensionActionRef, aa as ExtensionComponentChildren, a8 as ExtensionComponentData, a9 as ExtensionComponentIterator, H as ExtensionContext, c as ExtensionContributions, ad as ExtensionDataSource, E as ExtensionManifest, a7 as ExtensionModule, ae as ExtensionPanelDefinition, an as GridProps, af as HeaderProps, am as HorizontalStackProps, ar as IconButtonProps, aq as IconButtonType, ap as IconProps, ag as LabelProps, a2 as LogAPI, J as NetworkAPI, N as NetworkPermission, as as PanelAction, n as PanelActionDataSource, m as PanelComponentView, k as PanelDefinition, at as PanelProps, o as PanelUnknownView, l as PanelView, ah as ParagraphProps, z as Permission, P as Platform, q as PromptContribution, r as PromptSection, v as ProviderConfigProperty, w as ProviderConfigPropertyType, u as ProviderConfigSchema, x as ProviderConfigSelectOption, y as ProviderConfigValidation, p as ProviderDefinition, L as ProvidersAPI, V as SchedulerAPI, W as SchedulerJobRequest, X as SchedulerSchedule, ak as SelectProps, f as SettingCreateMapping, d as SettingDefinition, e as SettingOptionsMapping, K as SettingsAPI, a1 as StorageAPI, B as StoragePermission, F as SystemPermission, aj as TextInputProps, au as ToggleProps, a5 as Tool, a4 as ToolCall, s as ToolDefinition, j as ToolSettingsListMapping, i as ToolSettingsListView, h as ToolSettingsView, g as ToolSettingsViewDefinition, O as ToolsAPI, Y as UserAPI, U as UserDataPermission, Z as UserProfile, al as VerticalStackProps } from './types-Cr8eCJ0G.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Message protocol between Extension Host and Extension Workers
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
type HostToWorkerMessage = ActivateMessage | DeactivateMessage | SettingsChangedMessage | ProviderChatRequestMessage | ProviderModelsRequestMessage | ToolExecuteRequestMessage | ResponseMessage;
|
|
8
|
+
type HostToWorkerMessage = ActivateMessage | DeactivateMessage | SettingsChangedMessage | SchedulerFireMessage | ProviderChatRequestMessage | ProviderModelsRequestMessage | ToolExecuteRequestMessage | ActionExecuteRequestMessage | ResponseMessage;
|
|
9
9
|
interface ActivateMessage {
|
|
10
10
|
type: 'activate';
|
|
11
11
|
id: string;
|
|
@@ -29,6 +29,11 @@ interface SettingsChangedMessage {
|
|
|
29
29
|
value: unknown;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
interface SchedulerFireMessage {
|
|
33
|
+
type: 'scheduler-fire';
|
|
34
|
+
id: string;
|
|
35
|
+
payload: SchedulerFirePayload;
|
|
36
|
+
}
|
|
32
37
|
interface ProviderChatRequestMessage {
|
|
33
38
|
type: 'provider-chat-request';
|
|
34
39
|
id: string;
|
|
@@ -54,6 +59,14 @@ interface ToolExecuteRequestMessage {
|
|
|
54
59
|
params: Record<string, unknown>;
|
|
55
60
|
};
|
|
56
61
|
}
|
|
62
|
+
interface ActionExecuteRequestMessage {
|
|
63
|
+
type: 'action-execute-request';
|
|
64
|
+
id: string;
|
|
65
|
+
payload: {
|
|
66
|
+
actionId: string;
|
|
67
|
+
params: Record<string, unknown>;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
57
70
|
interface ResponseMessage {
|
|
58
71
|
type: 'response';
|
|
59
72
|
id: string;
|
|
@@ -64,7 +77,7 @@ interface ResponseMessage {
|
|
|
64
77
|
error?: string;
|
|
65
78
|
};
|
|
66
79
|
}
|
|
67
|
-
type WorkerToHostMessage = ReadyMessage | RequestMessage | ProviderRegisteredMessage | ToolRegisteredMessage | StreamEventMessage | LogMessage | ProviderModelsResponseMessage | ToolExecuteResponseMessage;
|
|
80
|
+
type WorkerToHostMessage = ReadyMessage | RequestMessage | ProviderRegisteredMessage | ToolRegisteredMessage | ActionRegisteredMessage | StreamEventMessage | LogMessage | ProviderModelsResponseMessage | ToolExecuteResponseMessage | ActionExecuteResponseMessage;
|
|
68
81
|
interface ReadyMessage {
|
|
69
82
|
type: 'ready';
|
|
70
83
|
}
|
|
@@ -74,7 +87,7 @@ interface RequestMessage {
|
|
|
74
87
|
method: RequestMethod;
|
|
75
88
|
payload: unknown;
|
|
76
89
|
}
|
|
77
|
-
type RequestMethod = 'network.fetch' | 'settings.getAll' | 'settings.get' | 'settings.set' | 'database.execute' | 'storage.get' | 'storage.set' | 'storage.delete' | 'storage.keys';
|
|
90
|
+
type RequestMethod = 'network.fetch' | 'settings.getAll' | 'settings.get' | 'settings.set' | 'user.getProfile' | 'events.emit' | 'scheduler.schedule' | 'scheduler.cancel' | 'chat.appendInstruction' | 'database.execute' | 'storage.get' | 'storage.set' | 'storage.delete' | 'storage.keys';
|
|
78
91
|
interface ProviderRegisteredMessage {
|
|
79
92
|
type: 'provider-registered';
|
|
80
93
|
payload: {
|
|
@@ -91,6 +104,12 @@ interface ToolRegisteredMessage {
|
|
|
91
104
|
parameters?: Record<string, unknown>;
|
|
92
105
|
};
|
|
93
106
|
}
|
|
107
|
+
interface ActionRegisteredMessage {
|
|
108
|
+
type: 'action-registered';
|
|
109
|
+
payload: {
|
|
110
|
+
id: string;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
94
113
|
interface StreamEventMessage {
|
|
95
114
|
type: 'stream-event';
|
|
96
115
|
payload: {
|
|
@@ -114,6 +133,14 @@ interface ToolExecuteResponseMessage {
|
|
|
114
133
|
error?: string;
|
|
115
134
|
};
|
|
116
135
|
}
|
|
136
|
+
interface ActionExecuteResponseMessage {
|
|
137
|
+
type: 'action-execute-response';
|
|
138
|
+
payload: {
|
|
139
|
+
requestId: string;
|
|
140
|
+
result: ActionResult;
|
|
141
|
+
error?: string;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
117
144
|
interface LogMessage {
|
|
118
145
|
type: 'log';
|
|
119
146
|
payload: {
|
|
@@ -132,4 +159,4 @@ interface PendingRequest<T = unknown> {
|
|
|
132
159
|
*/
|
|
133
160
|
declare function generateMessageId(): string;
|
|
134
161
|
|
|
135
|
-
export { type ActivateMessage, ChatMessage, ChatOptions, type DeactivateMessage, GetModelsOptions, type HostToWorkerMessage, type LogMessage, ModelInfo, type PendingRequest, type ProviderChatRequestMessage, type ProviderModelsRequestMessage, type ProviderRegisteredMessage, type ReadyMessage, type RequestMessage, type RequestMethod, type ResponseMessage, type SettingsChangedMessage, StreamEvent, type StreamEventMessage, type ToolExecuteRequestMessage, type ToolExecuteResponseMessage, type ToolRegisteredMessage, ToolResult, type WorkerToHostMessage, generateMessageId };
|
|
162
|
+
export { type ActionExecuteRequestMessage, type ActionExecuteResponseMessage, type ActionRegisteredMessage, ActionResult, type ActivateMessage, ChatMessage, ChatOptions, type DeactivateMessage, GetModelsOptions, type HostToWorkerMessage, type LogMessage, ModelInfo, type PendingRequest, type ProviderChatRequestMessage, type ProviderModelsRequestMessage, type ProviderRegisteredMessage, type ReadyMessage, type RequestMessage, type RequestMethod, type ResponseMessage, SchedulerFirePayload, type SettingsChangedMessage, StreamEvent, type StreamEventMessage, type ToolExecuteRequestMessage, type ToolExecuteResponseMessage, type ToolRegisteredMessage, ToolResult, type WorkerToHostMessage, generateMessageId };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as ChatMessage, a as ChatOptions, G as GetModelsOptions,
|
|
2
|
-
export {
|
|
1
|
+
import { S as SchedulerFirePayload, C as ChatMessage, a as ChatOptions, G as GetModelsOptions, b as StreamEvent, M as ModelInfo, T as ToolResult, A as ActionResult } from './types-Cr8eCJ0G.js';
|
|
2
|
+
export { a3 as AIProvider, a6 as Action, Q as ActionsAPI, ai as ButtonProps, D as CapabilityPermission, _ as ChatAPI, $ as ChatInstructionMessage, t as CommandDefinition, a0 as DatabaseAPI, I as Disposable, ao as DividerProps, R as EventsAPI, ab as ExtensionActionCall, ac as ExtensionActionRef, aa as ExtensionComponentChildren, a8 as ExtensionComponentData, a9 as ExtensionComponentIterator, H as ExtensionContext, c as ExtensionContributions, ad as ExtensionDataSource, E as ExtensionManifest, a7 as ExtensionModule, ae as ExtensionPanelDefinition, an as GridProps, af as HeaderProps, am as HorizontalStackProps, ar as IconButtonProps, aq as IconButtonType, ap as IconProps, ag as LabelProps, a2 as LogAPI, J as NetworkAPI, N as NetworkPermission, as as PanelAction, n as PanelActionDataSource, m as PanelComponentView, k as PanelDefinition, at as PanelProps, o as PanelUnknownView, l as PanelView, ah as ParagraphProps, z as Permission, P as Platform, q as PromptContribution, r as PromptSection, v as ProviderConfigProperty, w as ProviderConfigPropertyType, u as ProviderConfigSchema, x as ProviderConfigSelectOption, y as ProviderConfigValidation, p as ProviderDefinition, L as ProvidersAPI, V as SchedulerAPI, W as SchedulerJobRequest, X as SchedulerSchedule, ak as SelectProps, f as SettingCreateMapping, d as SettingDefinition, e as SettingOptionsMapping, K as SettingsAPI, a1 as StorageAPI, B as StoragePermission, F as SystemPermission, aj as TextInputProps, au as ToggleProps, a5 as Tool, a4 as ToolCall, s as ToolDefinition, j as ToolSettingsListMapping, i as ToolSettingsListView, h as ToolSettingsView, g as ToolSettingsViewDefinition, O as ToolsAPI, Y as UserAPI, U as UserDataPermission, Z as UserProfile, al as VerticalStackProps } from './types-Cr8eCJ0G.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Message protocol between Extension Host and Extension Workers
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
type HostToWorkerMessage = ActivateMessage | DeactivateMessage | SettingsChangedMessage | ProviderChatRequestMessage | ProviderModelsRequestMessage | ToolExecuteRequestMessage | ResponseMessage;
|
|
8
|
+
type HostToWorkerMessage = ActivateMessage | DeactivateMessage | SettingsChangedMessage | SchedulerFireMessage | ProviderChatRequestMessage | ProviderModelsRequestMessage | ToolExecuteRequestMessage | ActionExecuteRequestMessage | ResponseMessage;
|
|
9
9
|
interface ActivateMessage {
|
|
10
10
|
type: 'activate';
|
|
11
11
|
id: string;
|
|
@@ -29,6 +29,11 @@ interface SettingsChangedMessage {
|
|
|
29
29
|
value: unknown;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
interface SchedulerFireMessage {
|
|
33
|
+
type: 'scheduler-fire';
|
|
34
|
+
id: string;
|
|
35
|
+
payload: SchedulerFirePayload;
|
|
36
|
+
}
|
|
32
37
|
interface ProviderChatRequestMessage {
|
|
33
38
|
type: 'provider-chat-request';
|
|
34
39
|
id: string;
|
|
@@ -54,6 +59,14 @@ interface ToolExecuteRequestMessage {
|
|
|
54
59
|
params: Record<string, unknown>;
|
|
55
60
|
};
|
|
56
61
|
}
|
|
62
|
+
interface ActionExecuteRequestMessage {
|
|
63
|
+
type: 'action-execute-request';
|
|
64
|
+
id: string;
|
|
65
|
+
payload: {
|
|
66
|
+
actionId: string;
|
|
67
|
+
params: Record<string, unknown>;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
57
70
|
interface ResponseMessage {
|
|
58
71
|
type: 'response';
|
|
59
72
|
id: string;
|
|
@@ -64,7 +77,7 @@ interface ResponseMessage {
|
|
|
64
77
|
error?: string;
|
|
65
78
|
};
|
|
66
79
|
}
|
|
67
|
-
type WorkerToHostMessage = ReadyMessage | RequestMessage | ProviderRegisteredMessage | ToolRegisteredMessage | StreamEventMessage | LogMessage | ProviderModelsResponseMessage | ToolExecuteResponseMessage;
|
|
80
|
+
type WorkerToHostMessage = ReadyMessage | RequestMessage | ProviderRegisteredMessage | ToolRegisteredMessage | ActionRegisteredMessage | StreamEventMessage | LogMessage | ProviderModelsResponseMessage | ToolExecuteResponseMessage | ActionExecuteResponseMessage;
|
|
68
81
|
interface ReadyMessage {
|
|
69
82
|
type: 'ready';
|
|
70
83
|
}
|
|
@@ -74,7 +87,7 @@ interface RequestMessage {
|
|
|
74
87
|
method: RequestMethod;
|
|
75
88
|
payload: unknown;
|
|
76
89
|
}
|
|
77
|
-
type RequestMethod = 'network.fetch' | 'settings.getAll' | 'settings.get' | 'settings.set' | 'database.execute' | 'storage.get' | 'storage.set' | 'storage.delete' | 'storage.keys';
|
|
90
|
+
type RequestMethod = 'network.fetch' | 'settings.getAll' | 'settings.get' | 'settings.set' | 'user.getProfile' | 'events.emit' | 'scheduler.schedule' | 'scheduler.cancel' | 'chat.appendInstruction' | 'database.execute' | 'storage.get' | 'storage.set' | 'storage.delete' | 'storage.keys';
|
|
78
91
|
interface ProviderRegisteredMessage {
|
|
79
92
|
type: 'provider-registered';
|
|
80
93
|
payload: {
|
|
@@ -91,6 +104,12 @@ interface ToolRegisteredMessage {
|
|
|
91
104
|
parameters?: Record<string, unknown>;
|
|
92
105
|
};
|
|
93
106
|
}
|
|
107
|
+
interface ActionRegisteredMessage {
|
|
108
|
+
type: 'action-registered';
|
|
109
|
+
payload: {
|
|
110
|
+
id: string;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
94
113
|
interface StreamEventMessage {
|
|
95
114
|
type: 'stream-event';
|
|
96
115
|
payload: {
|
|
@@ -114,6 +133,14 @@ interface ToolExecuteResponseMessage {
|
|
|
114
133
|
error?: string;
|
|
115
134
|
};
|
|
116
135
|
}
|
|
136
|
+
interface ActionExecuteResponseMessage {
|
|
137
|
+
type: 'action-execute-response';
|
|
138
|
+
payload: {
|
|
139
|
+
requestId: string;
|
|
140
|
+
result: ActionResult;
|
|
141
|
+
error?: string;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
117
144
|
interface LogMessage {
|
|
118
145
|
type: 'log';
|
|
119
146
|
payload: {
|
|
@@ -132,4 +159,4 @@ interface PendingRequest<T = unknown> {
|
|
|
132
159
|
*/
|
|
133
160
|
declare function generateMessageId(): string;
|
|
134
161
|
|
|
135
|
-
export { type ActivateMessage, ChatMessage, ChatOptions, type DeactivateMessage, GetModelsOptions, type HostToWorkerMessage, type LogMessage, ModelInfo, type PendingRequest, type ProviderChatRequestMessage, type ProviderModelsRequestMessage, type ProviderRegisteredMessage, type ReadyMessage, type RequestMessage, type RequestMethod, type ResponseMessage, type SettingsChangedMessage, StreamEvent, type StreamEventMessage, type ToolExecuteRequestMessage, type ToolExecuteResponseMessage, type ToolRegisteredMessage, ToolResult, type WorkerToHostMessage, generateMessageId };
|
|
162
|
+
export { type ActionExecuteRequestMessage, type ActionExecuteResponseMessage, type ActionRegisteredMessage, ActionResult, type ActivateMessage, ChatMessage, ChatOptions, type DeactivateMessage, GetModelsOptions, type HostToWorkerMessage, type LogMessage, ModelInfo, type PendingRequest, type ProviderChatRequestMessage, type ProviderModelsRequestMessage, type ProviderRegisteredMessage, type ReadyMessage, type RequestMessage, type RequestMethod, type ResponseMessage, SchedulerFirePayload, type SettingsChangedMessage, StreamEvent, type StreamEventMessage, type ToolExecuteRequestMessage, type ToolExecuteResponseMessage, type ToolRegisteredMessage, ToolResult, type WorkerToHostMessage, generateMessageId };
|
package/dist/index.js
CHANGED
package/dist/runtime.cjs
CHANGED
|
@@ -54,7 +54,9 @@ var extensionContext = null;
|
|
|
54
54
|
var pendingRequests = /* @__PURE__ */ new Map();
|
|
55
55
|
var registeredProviders = /* @__PURE__ */ new Map();
|
|
56
56
|
var registeredTools = /* @__PURE__ */ new Map();
|
|
57
|
+
var registeredActions = /* @__PURE__ */ new Map();
|
|
57
58
|
var settingsCallbacks = [];
|
|
59
|
+
var schedulerCallbacks = [];
|
|
58
60
|
var REQUEST_TIMEOUT = 3e4;
|
|
59
61
|
function postMessage(message) {
|
|
60
62
|
messagePort.postMessage(message);
|
|
@@ -86,6 +88,9 @@ async function handleHostMessage(message) {
|
|
|
86
88
|
case "settings-changed":
|
|
87
89
|
handleSettingsChanged(message.payload.key, message.payload.value);
|
|
88
90
|
break;
|
|
91
|
+
case "scheduler-fire":
|
|
92
|
+
handleSchedulerFire(message.payload);
|
|
93
|
+
break;
|
|
89
94
|
case "provider-chat-request":
|
|
90
95
|
await handleProviderChatRequest(message.id, message.payload);
|
|
91
96
|
break;
|
|
@@ -95,6 +100,9 @@ async function handleHostMessage(message) {
|
|
|
95
100
|
case "tool-execute-request":
|
|
96
101
|
await handleToolExecuteRequest(message.id, message.payload);
|
|
97
102
|
break;
|
|
103
|
+
case "action-execute-request":
|
|
104
|
+
await handleActionExecuteRequest(message.id, message.payload);
|
|
105
|
+
break;
|
|
98
106
|
case "response":
|
|
99
107
|
handleResponse(message.payload);
|
|
100
108
|
break;
|
|
@@ -144,7 +152,9 @@ async function handleDeactivate() {
|
|
|
144
152
|
extensionContext = null;
|
|
145
153
|
registeredProviders.clear();
|
|
146
154
|
registeredTools.clear();
|
|
155
|
+
registeredActions.clear();
|
|
147
156
|
settingsCallbacks.length = 0;
|
|
157
|
+
schedulerCallbacks.length = 0;
|
|
148
158
|
}
|
|
149
159
|
}
|
|
150
160
|
function handleSettingsChanged(key, value) {
|
|
@@ -156,6 +166,15 @@ function handleSettingsChanged(key, value) {
|
|
|
156
166
|
}
|
|
157
167
|
}
|
|
158
168
|
}
|
|
169
|
+
function handleSchedulerFire(payload) {
|
|
170
|
+
for (const callback of schedulerCallbacks) {
|
|
171
|
+
try {
|
|
172
|
+
callback(payload);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.error("Error in scheduler callback:", error);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
159
178
|
async function handleProviderChatRequest(requestId, payload) {
|
|
160
179
|
const provider = registeredProviders.get(payload.providerId);
|
|
161
180
|
if (!provider) {
|
|
@@ -272,6 +291,40 @@ async function handleToolExecuteRequest(requestId, payload) {
|
|
|
272
291
|
});
|
|
273
292
|
}
|
|
274
293
|
}
|
|
294
|
+
async function handleActionExecuteRequest(requestId, payload) {
|
|
295
|
+
const action = registeredActions.get(payload.actionId);
|
|
296
|
+
if (!action) {
|
|
297
|
+
postMessage({
|
|
298
|
+
type: "action-execute-response",
|
|
299
|
+
payload: {
|
|
300
|
+
requestId,
|
|
301
|
+
result: { success: false, error: `Action ${payload.actionId} not found` },
|
|
302
|
+
error: `Action ${payload.actionId} not found`
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
try {
|
|
308
|
+
const result = await action.execute(payload.params);
|
|
309
|
+
postMessage({
|
|
310
|
+
type: "action-execute-response",
|
|
311
|
+
payload: {
|
|
312
|
+
requestId,
|
|
313
|
+
result
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
} catch (error) {
|
|
317
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
318
|
+
postMessage({
|
|
319
|
+
type: "action-execute-response",
|
|
320
|
+
payload: {
|
|
321
|
+
requestId,
|
|
322
|
+
result: { success: false, error: errorMessage },
|
|
323
|
+
error: errorMessage
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
275
328
|
function buildContext(extensionId, extensionVersion, storagePath, permissions) {
|
|
276
329
|
const hasPermission = (perm) => {
|
|
277
330
|
return permissions.some((p) => {
|
|
@@ -369,6 +422,69 @@ function buildContext(extensionId, extensionVersion, storagePath, permissions) {
|
|
|
369
422
|
};
|
|
370
423
|
context.tools = toolsApi;
|
|
371
424
|
}
|
|
425
|
+
if (hasPermission("actions.register")) {
|
|
426
|
+
const actionsApi = {
|
|
427
|
+
register(action) {
|
|
428
|
+
registeredActions.set(action.id, action);
|
|
429
|
+
postMessage({
|
|
430
|
+
type: "action-registered",
|
|
431
|
+
payload: {
|
|
432
|
+
id: action.id
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
return {
|
|
436
|
+
dispose: () => {
|
|
437
|
+
registeredActions.delete(action.id);
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
context.actions = actionsApi;
|
|
443
|
+
}
|
|
444
|
+
if (hasPermission("events.emit")) {
|
|
445
|
+
const eventsApi = {
|
|
446
|
+
async emit(name, payload) {
|
|
447
|
+
await sendRequest("events.emit", { name, payload });
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
context.events = eventsApi;
|
|
451
|
+
}
|
|
452
|
+
if (hasPermission("scheduler.register")) {
|
|
453
|
+
const schedulerApi = {
|
|
454
|
+
async schedule(job) {
|
|
455
|
+
await sendRequest("scheduler.schedule", { job });
|
|
456
|
+
},
|
|
457
|
+
async cancel(jobId) {
|
|
458
|
+
await sendRequest("scheduler.cancel", { jobId });
|
|
459
|
+
},
|
|
460
|
+
onFire(callback) {
|
|
461
|
+
schedulerCallbacks.push(callback);
|
|
462
|
+
return {
|
|
463
|
+
dispose: () => {
|
|
464
|
+
const index = schedulerCallbacks.indexOf(callback);
|
|
465
|
+
if (index >= 0) schedulerCallbacks.splice(index, 1);
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
context.scheduler = schedulerApi;
|
|
471
|
+
}
|
|
472
|
+
if (hasPermission("user.profile.read")) {
|
|
473
|
+
const userApi = {
|
|
474
|
+
async getProfile() {
|
|
475
|
+
return sendRequest("user.getProfile", {});
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
context.user = userApi;
|
|
479
|
+
}
|
|
480
|
+
if (hasPermission("chat.message.write")) {
|
|
481
|
+
const chatApi = {
|
|
482
|
+
async appendInstruction(message) {
|
|
483
|
+
await sendRequest("chat.appendInstruction", message);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
context.chat = chatApi;
|
|
487
|
+
}
|
|
372
488
|
if (hasPermission("database.own")) {
|
|
373
489
|
const databaseApi = {
|
|
374
490
|
async execute(sql, params) {
|