@practicalkit/plugin-sdk 0.0.2
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 +5 -0
- package/dist/src/PracticalKitSdk.d.ts +184 -0
- package/dist/src/PracticalKitSdk.d.ts.map +1 -0
- package/dist/src/PracticalKitSdk.js +230 -0
- package/dist/src/PracticalKitSdk.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/keyboard/KeyboardShortcutForwarder.d.ts +18 -0
- package/dist/src/keyboard/KeyboardShortcutForwarder.d.ts.map +1 -0
- package/dist/src/keyboard/KeyboardShortcutForwarder.js +36 -0
- package/dist/src/keyboard/KeyboardShortcutForwarder.js.map +1 -0
- package/dist/src/keyboard/index.d.ts +2 -0
- package/dist/src/keyboard/index.d.ts.map +1 -0
- package/dist/src/keyboard/index.js +2 -0
- package/dist/src/keyboard/index.js.map +1 -0
- package/dist/src/llm/ToolRegistry.d.ts +49 -0
- package/dist/src/llm/ToolRegistry.d.ts.map +1 -0
- package/dist/src/llm/ToolRegistry.js +126 -0
- package/dist/src/llm/ToolRegistry.js.map +1 -0
- package/dist/src/logs/channel/IFrameLogChannelAdapter.d.ts +8 -0
- package/dist/src/logs/channel/IFrameLogChannelAdapter.d.ts.map +1 -0
- package/dist/src/logs/channel/IFrameLogChannelAdapter.js +34 -0
- package/dist/src/logs/channel/IFrameLogChannelAdapter.js.map +1 -0
- package/dist/src/logs/channel/ILogChannelAdapter.d.ts +5 -0
- package/dist/src/logs/channel/ILogChannelAdapter.d.ts.map +1 -0
- package/dist/src/logs/channel/ILogChannelAdapter.js +2 -0
- package/dist/src/logs/channel/ILogChannelAdapter.js.map +1 -0
- package/dist/src/logs/channel/LogChannel.d.ts +21 -0
- package/dist/src/logs/channel/LogChannel.d.ts.map +1 -0
- package/dist/src/logs/channel/LogChannel.js +41 -0
- package/dist/src/logs/channel/LogChannel.js.map +1 -0
- package/dist/src/logs/outputs/types.d.ts +18 -0
- package/dist/src/logs/outputs/types.d.ts.map +1 -0
- package/dist/src/logs/outputs/types.js +2 -0
- package/dist/src/logs/outputs/types.js.map +1 -0
- package/dist/src/messages/IFrameClient.d.ts +33 -0
- package/dist/src/messages/IFrameClient.d.ts.map +1 -0
- package/dist/src/messages/IFrameClient.js +88 -0
- package/dist/src/messages/IFrameClient.js.map +1 -0
- package/dist/src/messages/IFrameMessageBus.d.ts +10 -0
- package/dist/src/messages/IFrameMessageBus.d.ts.map +1 -0
- package/dist/src/messages/IFrameMessageBus.js +24 -0
- package/dist/src/messages/IFrameMessageBus.js.map +1 -0
- package/dist/src/messages/base/index.d.ts +8 -0
- package/dist/src/messages/base/index.d.ts.map +1 -0
- package/dist/src/messages/base/index.js +9 -0
- package/dist/src/messages/base/index.js.map +1 -0
- package/dist/src/messages/document/index.d.ts +5 -0
- package/dist/src/messages/document/index.d.ts.map +1 -0
- package/dist/src/messages/document/index.js +5 -0
- package/dist/src/messages/document/index.js.map +1 -0
- package/dist/src/messages/document/requestContent/message.schemas.d.ts +34 -0
- package/dist/src/messages/document/requestContent/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/document/requestContent/message.schemas.js +21 -0
- package/dist/src/messages/document/requestContent/message.schemas.js.map +1 -0
- package/dist/src/messages/document/save/index.d.ts +2 -0
- package/dist/src/messages/document/save/index.d.ts.map +1 -0
- package/dist/src/messages/document/save/index.js +2 -0
- package/dist/src/messages/document/save/index.js.map +1 -0
- package/dist/src/messages/document/save/message.schemas.d.ts +34 -0
- package/dist/src/messages/document/save/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/document/save/message.schemas.js +21 -0
- package/dist/src/messages/document/save/message.schemas.js.map +1 -0
- package/dist/src/messages/document/saveRequested/message.schemas.d.ts +41 -0
- package/dist/src/messages/document/saveRequested/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/document/saveRequested/message.schemas.js +28 -0
- package/dist/src/messages/document/saveRequested/message.schemas.js.map +1 -0
- package/dist/src/messages/document/saved/message.schemas.d.ts +39 -0
- package/dist/src/messages/document/saved/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/document/saved/message.schemas.js +26 -0
- package/dist/src/messages/document/saved/message.schemas.js.map +1 -0
- package/dist/src/messages/editor/index.d.ts +2 -0
- package/dist/src/messages/editor/index.d.ts.map +1 -0
- package/dist/src/messages/editor/index.js +2 -0
- package/dist/src/messages/editor/index.js.map +1 -0
- package/dist/src/messages/editor/openFile/message.schemas.d.ts +30 -0
- package/dist/src/messages/editor/openFile/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/editor/openFile/message.schemas.js +17 -0
- package/dist/src/messages/editor/openFile/message.schemas.js.map +1 -0
- package/dist/src/messages/fs/fileChanged/message.schemas.d.ts +10 -0
- package/dist/src/messages/fs/fileChanged/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/fs/fileChanged/message.schemas.js +10 -0
- package/dist/src/messages/fs/fileChanged/message.schemas.js.map +1 -0
- package/dist/src/messages/fs/index.d.ts +3 -0
- package/dist/src/messages/fs/index.d.ts.map +1 -0
- package/dist/src/messages/fs/index.js +3 -0
- package/dist/src/messages/fs/index.js.map +1 -0
- package/dist/src/messages/fs/subscribe/message.schemas.d.ts +54 -0
- package/dist/src/messages/fs/subscribe/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/fs/subscribe/message.schemas.js +27 -0
- package/dist/src/messages/fs/subscribe/message.schemas.js.map +1 -0
- package/dist/src/messages/index.d.ts +15 -0
- package/dist/src/messages/index.d.ts.map +1 -0
- package/dist/src/messages/index.js +29 -0
- package/dist/src/messages/index.js.map +1 -0
- package/dist/src/messages/llm/index.d.ts +148 -0
- package/dist/src/messages/llm/index.d.ts.map +1 -0
- package/dist/src/messages/llm/index.js +124 -0
- package/dist/src/messages/llm/index.js.map +1 -0
- package/dist/src/messages/logs/index.d.ts +26 -0
- package/dist/src/messages/logs/index.d.ts.map +1 -0
- package/dist/src/messages/logs/index.js +24 -0
- package/dist/src/messages/logs/index.js.map +1 -0
- package/dist/src/messages/native/call/message.schemas.d.ts +34 -0
- package/dist/src/messages/native/call/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/native/call/message.schemas.js +22 -0
- package/dist/src/messages/native/call/message.schemas.js.map +1 -0
- package/dist/src/messages/native/index.d.ts +2 -0
- package/dist/src/messages/native/index.d.ts.map +1 -0
- package/dist/src/messages/native/index.js +2 -0
- package/dist/src/messages/native/index.js.map +1 -0
- package/dist/src/messages/plugin/index.d.ts +78 -0
- package/dist/src/messages/plugin/index.d.ts.map +1 -0
- package/dist/src/messages/plugin/index.js +72 -0
- package/dist/src/messages/plugin/index.js.map +1 -0
- package/dist/src/messages/storage/index.d.ts +126 -0
- package/dist/src/messages/storage/index.d.ts.map +1 -0
- package/dist/src/messages/storage/index.js +109 -0
- package/dist/src/messages/storage/index.js.map +1 -0
- package/dist/src/messages/ui/UiChannel.d.ts +68 -0
- package/dist/src/messages/ui/UiChannel.d.ts.map +1 -0
- package/dist/src/messages/ui/UiChannel.js +81 -0
- package/dist/src/messages/ui/UiChannel.js.map +1 -0
- package/dist/src/messages/ui/confirm/index.d.ts +2 -0
- package/dist/src/messages/ui/confirm/index.d.ts.map +1 -0
- package/dist/src/messages/ui/confirm/index.js +2 -0
- package/dist/src/messages/ui/confirm/index.js.map +1 -0
- package/dist/src/messages/ui/confirm/message.schemas.d.ts +39 -0
- package/dist/src/messages/ui/confirm/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/ui/confirm/message.schemas.js +25 -0
- package/dist/src/messages/ui/confirm/message.schemas.js.map +1 -0
- package/dist/src/messages/ui/getState/message.schemas.d.ts +38 -0
- package/dist/src/messages/ui/getState/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/ui/getState/message.schemas.js +21 -0
- package/dist/src/messages/ui/getState/message.schemas.js.map +1 -0
- package/dist/src/messages/ui/index.d.ts +8 -0
- package/dist/src/messages/ui/index.d.ts.map +1 -0
- package/dist/src/messages/ui/index.js +8 -0
- package/dist/src/messages/ui/index.js.map +1 -0
- package/dist/src/messages/ui/setCollapseState/message.schemas.d.ts +33 -0
- package/dist/src/messages/ui/setCollapseState/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/ui/setCollapseState/message.schemas.js +19 -0
- package/dist/src/messages/ui/setCollapseState/message.schemas.js.map +1 -0
- package/dist/src/messages/ui/showContextMenu/message.schemas.d.ts +61 -0
- package/dist/src/messages/ui/showContextMenu/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/ui/showContextMenu/message.schemas.js +37 -0
- package/dist/src/messages/ui/showContextMenu/message.schemas.js.map +1 -0
- package/dist/src/messages/ui/showNotification/message.schemas.d.ts +38 -0
- package/dist/src/messages/ui/showNotification/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/ui/showNotification/message.schemas.js +29 -0
- package/dist/src/messages/ui/showNotification/message.schemas.js.map +1 -0
- package/dist/src/messages/ui/tabsChanged/message.schemas.d.ts +24 -0
- package/dist/src/messages/ui/tabsChanged/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/ui/tabsChanged/message.schemas.js +15 -0
- package/dist/src/messages/ui/tabsChanged/message.schemas.js.map +1 -0
- package/dist/src/messages/vfs/createDir/message.schemas.d.ts +30 -0
- package/dist/src/messages/vfs/createDir/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/vfs/createDir/message.schemas.js +17 -0
- package/dist/src/messages/vfs/createDir/message.schemas.js.map +1 -0
- package/dist/src/messages/vfs/delete/message.schemas.d.ts +30 -0
- package/dist/src/messages/vfs/delete/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/vfs/delete/message.schemas.js +17 -0
- package/dist/src/messages/vfs/delete/message.schemas.js.map +1 -0
- package/dist/src/messages/vfs/exists/message.schemas.d.ts +34 -0
- package/dist/src/messages/vfs/exists/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/vfs/exists/message.schemas.js +21 -0
- package/dist/src/messages/vfs/exists/message.schemas.js.map +1 -0
- package/dist/src/messages/vfs/getAbsolutePath/message.schemas.d.ts +33 -0
- package/dist/src/messages/vfs/getAbsolutePath/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/vfs/getAbsolutePath/message.schemas.js +20 -0
- package/dist/src/messages/vfs/getAbsolutePath/message.schemas.js.map +1 -0
- package/dist/src/messages/vfs/index.d.ts +9 -0
- package/dist/src/messages/vfs/index.d.ts.map +1 -0
- package/dist/src/messages/vfs/index.js +9 -0
- package/dist/src/messages/vfs/index.js.map +1 -0
- package/dist/src/messages/vfs/readDir/message.schemas.d.ts +41 -0
- package/dist/src/messages/vfs/readDir/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/vfs/readDir/message.schemas.js +23 -0
- package/dist/src/messages/vfs/readDir/message.schemas.js.map +1 -0
- package/dist/src/messages/vfs/readFile/message.schemas.d.ts +31 -0
- package/dist/src/messages/vfs/readFile/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/vfs/readFile/message.schemas.js +18 -0
- package/dist/src/messages/vfs/readFile/message.schemas.js.map +1 -0
- package/dist/src/messages/vfs/rename/message.schemas.d.ts +31 -0
- package/dist/src/messages/vfs/rename/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/vfs/rename/message.schemas.js +18 -0
- package/dist/src/messages/vfs/rename/message.schemas.js.map +1 -0
- package/dist/src/messages/vfs/writeFile/message.schemas.d.ts +31 -0
- package/dist/src/messages/vfs/writeFile/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/vfs/writeFile/message.schemas.js +18 -0
- package/dist/src/messages/vfs/writeFile/message.schemas.js.map +1 -0
- package/dist/src/messages/workspace/changed/message.schemas.d.ts +9 -0
- package/dist/src/messages/workspace/changed/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/workspace/changed/message.schemas.js +9 -0
- package/dist/src/messages/workspace/changed/message.schemas.js.map +1 -0
- package/dist/src/messages/workspace/getDetails/message.schemas.d.ts +39 -0
- package/dist/src/messages/workspace/getDetails/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/workspace/getDetails/message.schemas.js +22 -0
- package/dist/src/messages/workspace/getDetails/message.schemas.js.map +1 -0
- package/dist/src/messages/workspace/index.d.ts +4 -0
- package/dist/src/messages/workspace/index.d.ts.map +1 -0
- package/dist/src/messages/workspace/index.js +4 -0
- package/dist/src/messages/workspace/index.js.map +1 -0
- package/dist/src/messages/workspace/open/message.schemas.d.ts +29 -0
- package/dist/src/messages/workspace/open/message.schemas.d.ts.map +1 -0
- package/dist/src/messages/workspace/open/message.schemas.js +16 -0
- package/dist/src/messages/workspace/open/message.schemas.js.map +1 -0
- package/dist/src/namespaces/DocumentNamespace.d.ts +56 -0
- package/dist/src/namespaces/DocumentNamespace.d.ts.map +1 -0
- package/dist/src/namespaces/DocumentNamespace.js +129 -0
- package/dist/src/namespaces/DocumentNamespace.js.map +1 -0
- package/dist/src/namespaces/EditorNamespace.d.ts +11 -0
- package/dist/src/namespaces/EditorNamespace.d.ts.map +1 -0
- package/dist/src/namespaces/EditorNamespace.js +18 -0
- package/dist/src/namespaces/EditorNamespace.js.map +1 -0
- package/dist/src/namespaces/FsNamespace.d.ts +27 -0
- package/dist/src/namespaces/FsNamespace.d.ts.map +1 -0
- package/dist/src/namespaces/FsNamespace.js +52 -0
- package/dist/src/namespaces/FsNamespace.js.map +1 -0
- package/dist/src/namespaces/NativeNamespace.d.ts +11 -0
- package/dist/src/namespaces/NativeNamespace.d.ts.map +1 -0
- package/dist/src/namespaces/NativeNamespace.js +19 -0
- package/dist/src/namespaces/NativeNamespace.js.map +1 -0
- package/dist/src/namespaces/PluginNamespace.d.ts +56 -0
- package/dist/src/namespaces/PluginNamespace.d.ts.map +1 -0
- package/dist/src/namespaces/PluginNamespace.js +116 -0
- package/dist/src/namespaces/PluginNamespace.js.map +1 -0
- package/dist/src/namespaces/StorageNamespace.d.ts +56 -0
- package/dist/src/namespaces/StorageNamespace.d.ts.map +1 -0
- package/dist/src/namespaces/StorageNamespace.js +127 -0
- package/dist/src/namespaces/StorageNamespace.js.map +1 -0
- package/dist/src/namespaces/VfsNamespace.d.ts +25 -0
- package/dist/src/namespaces/VfsNamespace.d.ts.map +1 -0
- package/dist/src/namespaces/VfsNamespace.js +64 -0
- package/dist/src/namespaces/VfsNamespace.js.map +1 -0
- package/dist/src/namespaces/WorkspaceNamespace.d.ts +18 -0
- package/dist/src/namespaces/WorkspaceNamespace.d.ts.map +1 -0
- package/dist/src/namespaces/WorkspaceNamespace.js +48 -0
- package/dist/src/namespaces/WorkspaceNamespace.js.map +1 -0
- package/dist/src/namespaces/index.d.ts +9 -0
- package/dist/src/namespaces/index.d.ts.map +1 -0
- package/dist/src/namespaces/index.js +9 -0
- package/dist/src/namespaces/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/eslint.config.js +25 -0
- package/package.json +28 -0
- package/src/PracticalKitSdk.ts +325 -0
- package/src/index.ts +10 -0
- package/src/keyboard/KeyboardShortcutForwarder.ts +35 -0
- package/src/keyboard/index.ts +1 -0
- package/src/llm/ToolRegistry.ts +186 -0
- package/src/logs/channel/IFrameLogChannelAdapter.ts +44 -0
- package/src/logs/channel/ILogChannelAdapter.ts +5 -0
- package/src/logs/channel/LogChannel.ts +49 -0
- package/src/logs/outputs/types.ts +21 -0
- package/src/messages/IFrameClient.ts +113 -0
- package/src/messages/IFrameMessageBus.ts +28 -0
- package/src/messages/base/index.ts +16 -0
- package/src/messages/document/index.ts +4 -0
- package/src/messages/document/requestContent/message.schemas.ts +28 -0
- package/src/messages/document/save/index.ts +1 -0
- package/src/messages/document/save/message.schemas.ts +24 -0
- package/src/messages/document/saveRequested/message.schemas.ts +35 -0
- package/src/messages/document/saved/message.schemas.ts +29 -0
- package/src/messages/editor/index.ts +1 -0
- package/src/messages/editor/openFile/message.schemas.ts +22 -0
- package/src/messages/fs/fileChanged/message.schemas.ts +12 -0
- package/src/messages/fs/index.ts +2 -0
- package/src/messages/fs/subscribe/message.schemas.ts +33 -0
- package/src/messages/index.ts +41 -0
- package/src/messages/llm/index.ts +158 -0
- package/src/messages/logs/index.ts +39 -0
- package/src/messages/native/call/message.schemas.ts +25 -0
- package/src/messages/native/index.ts +1 -0
- package/src/messages/plugin/index.ts +95 -0
- package/src/messages/storage/index.ts +140 -0
- package/src/messages/ui/UiChannel.ts +156 -0
- package/src/messages/ui/confirm/index.ts +1 -0
- package/src/messages/ui/confirm/message.schemas.ts +36 -0
- package/src/messages/ui/getState/message.schemas.ts +33 -0
- package/src/messages/ui/index.ts +7 -0
- package/src/messages/ui/setCollapseState/message.schemas.ts +34 -0
- package/src/messages/ui/showContextMenu/message.schemas.ts +64 -0
- package/src/messages/ui/showNotification/message.schemas.ts +41 -0
- package/src/messages/ui/tabsChanged/message.schemas.ts +25 -0
- package/src/messages/vfs/createDir/message.schemas.ts +20 -0
- package/src/messages/vfs/delete/message.schemas.ts +20 -0
- package/src/messages/vfs/exists/message.schemas.ts +32 -0
- package/src/messages/vfs/getAbsolutePath/message.schemas.ts +27 -0
- package/src/messages/vfs/index.ts +8 -0
- package/src/messages/vfs/readDir/message.schemas.ts +36 -0
- package/src/messages/vfs/readFile/message.schemas.ts +21 -0
- package/src/messages/vfs/rename/message.schemas.ts +21 -0
- package/src/messages/vfs/writeFile/message.schemas.ts +21 -0
- package/src/messages/workspace/changed/message.schemas.ts +18 -0
- package/src/messages/workspace/getDetails/message.schemas.ts +39 -0
- package/src/messages/workspace/index.ts +3 -0
- package/src/messages/workspace/open/message.schemas.ts +27 -0
- package/src/namespaces/DocumentNamespace.ts +164 -0
- package/src/namespaces/EditorNamespace.ts +27 -0
- package/src/namespaces/FsNamespace.ts +77 -0
- package/src/namespaces/NativeNamespace.ts +34 -0
- package/src/namespaces/PluginNamespace.ts +156 -0
- package/src/namespaces/StorageNamespace.ts +186 -0
- package/src/namespaces/VfsNamespace.ts +135 -0
- package/src/namespaces/WorkspaceNamespace.ts +80 -0
- package/src/namespaces/index.ts +8 -0
- package/tsconfig.json +41 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { safeParse } from "valibot";
|
|
2
|
+
import { FsSubscribe, FsUnsubscribe, FsFileChangedSchema, } from "../messages/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* File system namespace for file watching operations.
|
|
5
|
+
* This class is not part of the public SDK API.
|
|
6
|
+
*/
|
|
7
|
+
export class FsNamespace {
|
|
8
|
+
client;
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Subscribe to file system change events.
|
|
14
|
+
* Requires the "fs.watch" permission in the plugin manifest.
|
|
15
|
+
*/
|
|
16
|
+
async subscribe() {
|
|
17
|
+
const response = await this.client.sendAndWait("fs.subscribe", {}, FsSubscribe.Request, FsSubscribe.Response);
|
|
18
|
+
if (!response.success) {
|
|
19
|
+
throw new Error(response.error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Unsubscribe from file system change events.
|
|
24
|
+
*/
|
|
25
|
+
async unsubscribe() {
|
|
26
|
+
const response = await this.client.sendAndWait("fs.unsubscribe", {}, FsUnsubscribe.Request, FsUnsubscribe.Response);
|
|
27
|
+
if (!response.success) {
|
|
28
|
+
throw new Error(response.error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Listen for file change events.
|
|
33
|
+
* Must call fs.subscribe() first.
|
|
34
|
+
* @param callback Function called when a file changes
|
|
35
|
+
* @returns Unsubscribe function
|
|
36
|
+
*/
|
|
37
|
+
onFileChanged(callback) {
|
|
38
|
+
return this.client.subscribe((evt) => {
|
|
39
|
+
const { type } = evt.data || {};
|
|
40
|
+
if (type !== "fs.fileChanged") {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const result = safeParse(FsFileChangedSchema, evt.data);
|
|
44
|
+
if (!result.success) {
|
|
45
|
+
console.error("[SDK] Invalid fs.fileChanged payload:", result.issues);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
callback(result.output);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=FsNamespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsNamespace.js","sourceRoot":"","sources":["../../../src/namespaces/FsNamespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EACL,WAAW,EACX,aAAa,EACb,mBAAmB,GAEpB,MAAM,sBAAsB,CAAC;AAE9B;;;GAGG;AACH,MAAM,OAAO,WAAW;IACL,MAAM,CAAe;IAEtC,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5C,cAAc,EACd,EAAE,EACF,WAAW,CAAC,OAAO,EACnB,WAAW,CAAC,QAAQ,CACrB,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW;QACf,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5C,gBAAgB,EAChB,EAAE,EACF,aAAa,CAAC,OAAO,EACrB,aAAa,CAAC,QAAQ,CACvB,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,QAAwC;QACpD,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;YACnC,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;YAChC,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;gBAC9B,OAAO;YACT,CAAC;YAED,MAAM,MAAM,GAAG,SAAS,CAAC,mBAAmB,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;YAExD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBACtE,OAAO;YACT,CAAC;YAED,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IFrameClient } from "../messages/IFrameClient.js";
|
|
2
|
+
/**
|
|
3
|
+
* Native namespace for calling native plugin modules.
|
|
4
|
+
* This class is not part of the public SDK API.
|
|
5
|
+
*/
|
|
6
|
+
export declare class NativeNamespace {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(client: IFrameClient);
|
|
9
|
+
call(pluginId: string, moduleId: string, command: string, args: unknown): Promise<unknown>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=NativeNamespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeNamespace.d.ts","sourceRoot":"","sources":["../../../src/namespaces/NativeNamespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,YAAY;IAI1B,IAAI,CACR,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,OAAO,CAAC;CAcpB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NativeCall } from "../messages/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Native namespace for calling native plugin modules.
|
|
4
|
+
* This class is not part of the public SDK API.
|
|
5
|
+
*/
|
|
6
|
+
export class NativeNamespace {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
async call(pluginId, moduleId, command, args) {
|
|
12
|
+
const response = await this.client.sendAndWait("native.call", { pluginId, moduleId, command, args }, NativeCall.Request, NativeCall.Response);
|
|
13
|
+
if (!response.success) {
|
|
14
|
+
throw new Error(response.error);
|
|
15
|
+
}
|
|
16
|
+
return response.data;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=NativeNamespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeNamespace.js","sourceRoot":"","sources":["../../../src/namespaces/NativeNamespace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;GAGG;AACH,MAAM,OAAO,eAAe;IACT,MAAM,CAAe;IAEtC,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,IAAI,CACR,QAAgB,EAChB,QAAgB,EAChB,OAAe,EACf,IAAa;QAEb,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5C,aAAa,EACb,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,EACrC,UAAU,CAAC,OAAO,EAClB,UAAU,CAAC,QAAQ,CACpB,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { IFrameClient } from "../messages/IFrameClient.js";
|
|
2
|
+
import { PluginMessage } from "../messages/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Intra-plugin messaging namespace.
|
|
5
|
+
* This class is not part of the public SDK API.
|
|
6
|
+
*
|
|
7
|
+
* Allows modules within the same plugin to communicate with each other.
|
|
8
|
+
* Messages are routed through the host - modules cannot communicate directly.
|
|
9
|
+
*
|
|
10
|
+
* Use cases:
|
|
11
|
+
* - A panel module sending commands to a backgroundService module
|
|
12
|
+
* - A backgroundService module notifying UI modules of state changes
|
|
13
|
+
* - Coordinating work between multiple UI modules
|
|
14
|
+
*/
|
|
15
|
+
export declare class PluginNamespace {
|
|
16
|
+
private readonly client;
|
|
17
|
+
constructor(client: IFrameClient);
|
|
18
|
+
/**
|
|
19
|
+
* Send a message to a specific sibling module within the same plugin.
|
|
20
|
+
* Returns a promise that resolves with the response from the target module.
|
|
21
|
+
*
|
|
22
|
+
* @param targetModuleId - The module ID to send the message to
|
|
23
|
+
* @param message - The message payload (any serializable value)
|
|
24
|
+
* @returns Promise resolving to the response data from the target module
|
|
25
|
+
* @throws Error if the target module doesn't exist or fails to respond
|
|
26
|
+
*/
|
|
27
|
+
sendMessage<T = unknown>(targetModuleId: string, message: unknown): Promise<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Listen for incoming messages from sibling modules.
|
|
30
|
+
* The handler should return a response that will be sent back to the sender.
|
|
31
|
+
* Supports both sync and async handlers.
|
|
32
|
+
*
|
|
33
|
+
* @param handler - Function that handles incoming messages and returns a response (sync or async)
|
|
34
|
+
* @returns Unsubscribe function
|
|
35
|
+
*/
|
|
36
|
+
onMessage(handler: (payload: PluginMessage.HandlerPayload) => unknown | Promise<unknown>): () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Broadcast a message to all sibling modules within the same plugin.
|
|
39
|
+
* This is fire-and-forget - no response is expected.
|
|
40
|
+
*
|
|
41
|
+
* @param message - The message payload (any serializable value)
|
|
42
|
+
*/
|
|
43
|
+
sendBroadcast(message: unknown): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Listen for broadcast messages from sibling modules.
|
|
46
|
+
* Broadcasts are fire-and-forget - no response is expected.
|
|
47
|
+
*
|
|
48
|
+
* @param handler - Function that handles incoming broadcasts
|
|
49
|
+
* @returns Unsubscribe function
|
|
50
|
+
*/
|
|
51
|
+
onBroadcast(handler: (payload: {
|
|
52
|
+
fromModuleId: string;
|
|
53
|
+
message: unknown;
|
|
54
|
+
}) => void): () => void;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=PluginNamespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginNamespace.d.ts","sourceRoot":"","sources":["../../../src/namespaces/PluginNamespace.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAEL,aAAa,EAGd,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;;;;GAWG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,YAAY;IAIhC;;;;;;;;OAQG;IACG,WAAW,CAAC,CAAC,GAAG,OAAO,EAC3B,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,CAAC,CAAC;IAeb;;;;;;;OAOG;IACH,SAAS,CACP,OAAO,EAAE,CACP,OAAO,EAAE,aAAa,CAAC,cAAc,KAClC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAC9B,MAAM,IAAI;IA2Cb;;;;;OAKG;IACG,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAapD;;;;;;OAMG;IACH,WAAW,CACT,OAAO,EAAE,CAAC,OAAO,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GACrE,MAAM,IAAI;CAiBd"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { safeParse } from "valibot";
|
|
2
|
+
import { PluginSendMessage, PluginMessage, PluginSendBroadcast, PluginBroadcast, } from "../messages/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Intra-plugin messaging namespace.
|
|
5
|
+
* This class is not part of the public SDK API.
|
|
6
|
+
*
|
|
7
|
+
* Allows modules within the same plugin to communicate with each other.
|
|
8
|
+
* Messages are routed through the host - modules cannot communicate directly.
|
|
9
|
+
*
|
|
10
|
+
* Use cases:
|
|
11
|
+
* - A panel module sending commands to a backgroundService module
|
|
12
|
+
* - A backgroundService module notifying UI modules of state changes
|
|
13
|
+
* - Coordinating work between multiple UI modules
|
|
14
|
+
*/
|
|
15
|
+
export class PluginNamespace {
|
|
16
|
+
client;
|
|
17
|
+
constructor(client) {
|
|
18
|
+
this.client = client;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Send a message to a specific sibling module within the same plugin.
|
|
22
|
+
* Returns a promise that resolves with the response from the target module.
|
|
23
|
+
*
|
|
24
|
+
* @param targetModuleId - The module ID to send the message to
|
|
25
|
+
* @param message - The message payload (any serializable value)
|
|
26
|
+
* @returns Promise resolving to the response data from the target module
|
|
27
|
+
* @throws Error if the target module doesn't exist or fails to respond
|
|
28
|
+
*/
|
|
29
|
+
async sendMessage(targetModuleId, message) {
|
|
30
|
+
const response = await this.client.sendAndWait("plugin.sendMessage", { targetModuleId, message }, PluginSendMessage.Request, PluginSendMessage.Response);
|
|
31
|
+
if (!response.success) {
|
|
32
|
+
throw new Error(response.error || "Failed to send message");
|
|
33
|
+
}
|
|
34
|
+
return response.data;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Listen for incoming messages from sibling modules.
|
|
38
|
+
* The handler should return a response that will be sent back to the sender.
|
|
39
|
+
* Supports both sync and async handlers.
|
|
40
|
+
*
|
|
41
|
+
* @param handler - Function that handles incoming messages and returns a response (sync or async)
|
|
42
|
+
* @returns Unsubscribe function
|
|
43
|
+
*/
|
|
44
|
+
onMessage(handler) {
|
|
45
|
+
return this.client.subscribe((evt) => {
|
|
46
|
+
const { type } = evt.data || {};
|
|
47
|
+
if (type !== "plugin.message") {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const result = safeParse(PluginMessage.Request, evt.data);
|
|
51
|
+
if (!result.success) {
|
|
52
|
+
console.error("[SDK] Invalid plugin.message payload:", result.issues);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const requestId = result.output.payload.requestId;
|
|
56
|
+
// Wrap in Promise.resolve to handle both sync and async handlers
|
|
57
|
+
Promise.resolve()
|
|
58
|
+
.then(() => handler(result.output.payload))
|
|
59
|
+
.then((responseData) => {
|
|
60
|
+
this.client.send({
|
|
61
|
+
type: "plugin.message.response",
|
|
62
|
+
payload: {
|
|
63
|
+
requestId,
|
|
64
|
+
success: true,
|
|
65
|
+
data: responseData,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
})
|
|
69
|
+
.catch((error) => {
|
|
70
|
+
console.error("[SDK] Error in plugin.onMessage handler:", error);
|
|
71
|
+
this.client.send({
|
|
72
|
+
type: "plugin.message.response",
|
|
73
|
+
payload: {
|
|
74
|
+
requestId,
|
|
75
|
+
success: false,
|
|
76
|
+
error: error instanceof Error ? error.message : String(error),
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Broadcast a message to all sibling modules within the same plugin.
|
|
84
|
+
* This is fire-and-forget - no response is expected.
|
|
85
|
+
*
|
|
86
|
+
* @param message - The message payload (any serializable value)
|
|
87
|
+
*/
|
|
88
|
+
async sendBroadcast(message) {
|
|
89
|
+
const response = await this.client.sendAndWait("plugin.sendBroadcast", { message }, PluginSendBroadcast.Request, PluginSendBroadcast.Response);
|
|
90
|
+
if (!response.success) {
|
|
91
|
+
throw new Error(response.error || "Failed to send broadcast");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Listen for broadcast messages from sibling modules.
|
|
96
|
+
* Broadcasts are fire-and-forget - no response is expected.
|
|
97
|
+
*
|
|
98
|
+
* @param handler - Function that handles incoming broadcasts
|
|
99
|
+
* @returns Unsubscribe function
|
|
100
|
+
*/
|
|
101
|
+
onBroadcast(handler) {
|
|
102
|
+
return this.client.subscribe((evt) => {
|
|
103
|
+
const { type } = evt.data || {};
|
|
104
|
+
if (type !== "plugin.broadcast") {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const result = safeParse(PluginBroadcast.Event, evt.data);
|
|
108
|
+
if (!result.success) {
|
|
109
|
+
console.error("[SDK] Invalid plugin.broadcast payload:", result.issues);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
handler(result.output.payload);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=PluginNamespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginNamespace.js","sourceRoot":"","sources":["../../../src/namespaces/PluginNamespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,eAAe;IACT,MAAM,CAAe;IAEtC,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,WAAW,CACf,cAAsB,EACtB,OAAgB;QAEhB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5C,oBAAoB,EACpB,EAAE,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MAAM,CAAC,CAAC;gBACxE,OAAO;YACT,CAAC;YAED,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { IFrameClient } from "../messages/IFrameClient.js";
|
|
2
|
+
/**
|
|
3
|
+
* Storage namespace for plugin data and secrets.
|
|
4
|
+
*
|
|
5
|
+
* Provides two storage types:
|
|
6
|
+
* - `get`/`set`/`delete`: Non-secret storage for any binary data
|
|
7
|
+
* - `getSecret`/`setSecret`/`deleteSecret`: Encrypted storage for sensitive data
|
|
8
|
+
*
|
|
9
|
+
* Both use Uint8Array for values to support any binary data.
|
|
10
|
+
* Data is isolated per plugin (plugins cannot access each other's storage).
|
|
11
|
+
*/
|
|
12
|
+
export declare class StorageNamespace {
|
|
13
|
+
private readonly client;
|
|
14
|
+
constructor(client: IFrameClient);
|
|
15
|
+
/**
|
|
16
|
+
* Get a value from storage.
|
|
17
|
+
*
|
|
18
|
+
* @param key - The storage key
|
|
19
|
+
* @returns The value as Uint8Array, or null if not found
|
|
20
|
+
*/
|
|
21
|
+
get(key: string): Promise<Uint8Array | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Set a value in storage.
|
|
24
|
+
*
|
|
25
|
+
* @param key - The storage key
|
|
26
|
+
* @param value - The value to store as Uint8Array
|
|
27
|
+
*/
|
|
28
|
+
set(key: string, value: Uint8Array): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Delete a value from storage.
|
|
31
|
+
*
|
|
32
|
+
* @param key - The storage key to delete
|
|
33
|
+
*/
|
|
34
|
+
delete(key: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Get a secret value for this plugin.
|
|
37
|
+
*
|
|
38
|
+
* @param key - The secret key (e.g., "apiKey", "token")
|
|
39
|
+
* @returns The secret value as Uint8Array, or null if not found
|
|
40
|
+
*/
|
|
41
|
+
getSecret(key: string): Promise<Uint8Array | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Set a secret value for this plugin.
|
|
44
|
+
*
|
|
45
|
+
* @param key - The secret key (e.g., "apiKey", "token")
|
|
46
|
+
* @param value - The secret value to store as Uint8Array
|
|
47
|
+
*/
|
|
48
|
+
setSecret(key: string, value: Uint8Array): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Delete a secret value for this plugin.
|
|
51
|
+
*
|
|
52
|
+
* @param key - The secret key to delete
|
|
53
|
+
*/
|
|
54
|
+
deleteSecret(key: string): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=StorageNamespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageNamespace.d.ts","sourceRoot":"","sources":["../../../src/namespaces/StorageNamespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAmChE;;;;;;;;;GASG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,YAAY;IAQhC;;;;;OAKG;IACG,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAmBlD;;;;;OAKG;IACG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAcxD;;;;OAIG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBxC;;;;;OAKG;IACG,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAmBxD;;;;;OAKG;IACG,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAc9D;;;;OAIG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAY/C"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { StorageGet, StorageSet, StorageDelete, StorageGetSecret, StorageSetSecret, StorageDeleteSecret, } from "../messages/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Encode Uint8Array to base64 string.
|
|
4
|
+
*/
|
|
5
|
+
function encodeBase64(bytes) {
|
|
6
|
+
let binary = "";
|
|
7
|
+
const len = bytes.length;
|
|
8
|
+
for (let i = 0; i < len; i++) {
|
|
9
|
+
binary += String.fromCharCode(bytes[i]);
|
|
10
|
+
}
|
|
11
|
+
return btoa(binary);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Decode base64 string to Uint8Array.
|
|
15
|
+
*/
|
|
16
|
+
function decodeBase64(base64) {
|
|
17
|
+
const binary = atob(base64);
|
|
18
|
+
const len = binary.length;
|
|
19
|
+
const bytes = new Uint8Array(len);
|
|
20
|
+
for (let i = 0; i < len; i++) {
|
|
21
|
+
bytes[i] = binary.charCodeAt(i);
|
|
22
|
+
}
|
|
23
|
+
return bytes;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Storage namespace for plugin data and secrets.
|
|
27
|
+
*
|
|
28
|
+
* Provides two storage types:
|
|
29
|
+
* - `get`/`set`/`delete`: Non-secret storage for any binary data
|
|
30
|
+
* - `getSecret`/`setSecret`/`deleteSecret`: Encrypted storage for sensitive data
|
|
31
|
+
*
|
|
32
|
+
* Both use Uint8Array for values to support any binary data.
|
|
33
|
+
* Data is isolated per plugin (plugins cannot access each other's storage).
|
|
34
|
+
*/
|
|
35
|
+
export class StorageNamespace {
|
|
36
|
+
client;
|
|
37
|
+
constructor(client) {
|
|
38
|
+
this.client = client;
|
|
39
|
+
}
|
|
40
|
+
// ===========================================================================
|
|
41
|
+
// Non-secret storage (raw bytes, unencrypted)
|
|
42
|
+
// ===========================================================================
|
|
43
|
+
/**
|
|
44
|
+
* Get a value from storage.
|
|
45
|
+
*
|
|
46
|
+
* @param key - The storage key
|
|
47
|
+
* @returns The value as Uint8Array, or null if not found
|
|
48
|
+
*/
|
|
49
|
+
async get(key) {
|
|
50
|
+
const response = await this.client.sendAndWait("storage.get", { key }, StorageGet.Request, StorageGet.Response);
|
|
51
|
+
if (!response.success) {
|
|
52
|
+
throw new Error(response.error || "Failed to get value");
|
|
53
|
+
}
|
|
54
|
+
if (response.value === null) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return decodeBase64(response.value);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Set a value in storage.
|
|
61
|
+
*
|
|
62
|
+
* @param key - The storage key
|
|
63
|
+
* @param value - The value to store as Uint8Array
|
|
64
|
+
*/
|
|
65
|
+
async set(key, value) {
|
|
66
|
+
const base64 = encodeBase64(value);
|
|
67
|
+
const response = await this.client.sendAndWait("storage.set", { key, value: base64 }, StorageSet.Request, StorageSet.Response);
|
|
68
|
+
if (!response.success) {
|
|
69
|
+
throw new Error(response.error || "Failed to set value");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Delete a value from storage.
|
|
74
|
+
*
|
|
75
|
+
* @param key - The storage key to delete
|
|
76
|
+
*/
|
|
77
|
+
async delete(key) {
|
|
78
|
+
const response = await this.client.sendAndWait("storage.delete", { key }, StorageDelete.Request, StorageDelete.Response);
|
|
79
|
+
if (!response.success) {
|
|
80
|
+
throw new Error(response.error || "Failed to delete value");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// ===========================================================================
|
|
84
|
+
// Secret storage (encrypted at rest)
|
|
85
|
+
// ===========================================================================
|
|
86
|
+
/**
|
|
87
|
+
* Get a secret value for this plugin.
|
|
88
|
+
*
|
|
89
|
+
* @param key - The secret key (e.g., "apiKey", "token")
|
|
90
|
+
* @returns The secret value as Uint8Array, or null if not found
|
|
91
|
+
*/
|
|
92
|
+
async getSecret(key) {
|
|
93
|
+
const response = await this.client.sendAndWait("storage.getSecret", { key }, StorageGetSecret.Request, StorageGetSecret.Response);
|
|
94
|
+
if (!response.success) {
|
|
95
|
+
throw new Error(response.error || "Failed to get secret");
|
|
96
|
+
}
|
|
97
|
+
if (response.value === null) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
return decodeBase64(response.value);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Set a secret value for this plugin.
|
|
104
|
+
*
|
|
105
|
+
* @param key - The secret key (e.g., "apiKey", "token")
|
|
106
|
+
* @param value - The secret value to store as Uint8Array
|
|
107
|
+
*/
|
|
108
|
+
async setSecret(key, value) {
|
|
109
|
+
const base64 = encodeBase64(value);
|
|
110
|
+
const response = await this.client.sendAndWait("storage.setSecret", { key, value: base64 }, StorageSetSecret.Request, StorageSetSecret.Response);
|
|
111
|
+
if (!response.success) {
|
|
112
|
+
throw new Error(response.error || "Failed to set secret");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Delete a secret value for this plugin.
|
|
117
|
+
*
|
|
118
|
+
* @param key - The secret key to delete
|
|
119
|
+
*/
|
|
120
|
+
async deleteSecret(key) {
|
|
121
|
+
const response = await this.client.sendAndWait("storage.deleteSecret", { key }, StorageDeleteSecret.Request, StorageDeleteSecret.Response);
|
|
122
|
+
if (!response.success) {
|
|
123
|
+
throw new Error(response.error || "Failed to delete secret");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=StorageNamespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageNamespace.js","sourceRoot":"","sources":["../../../src/namespaces/StorageNamespace.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,SAAS,YAAY,CAAC,KAAiB;IACrC,IAA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
2
|
+
/**
|
|
3
|
+
* Virtual file system namespace for file operations.
|
|
4
|
+
* This class is not part of the public SDK API.
|
|
5
|
+
*/
|
|
6
|
+
export declare class VfsNamespace {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(client: IFrameClient);
|
|
9
|
+
exists(path: string): Promise<{
|
|
10
|
+
exists: boolean;
|
|
11
|
+
entryType: string | null;
|
|
12
|
+
}>;
|
|
13
|
+
readDir(path: string): Promise<{
|
|
14
|
+
name: string;
|
|
15
|
+
type: "file" | "directory";
|
|
16
|
+
size: number;
|
|
17
|
+
}[]>;
|
|
18
|
+
readFile(path: string): Promise<string>;
|
|
19
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
20
|
+
getAbsolutePath(path: string): Promise<string>;
|
|
21
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
22
|
+
delete(path: string): Promise<void>;
|
|
23
|
+
createDir(path: string): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=VfsNamespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VfsNamespace.d.ts","sourceRoot":"","sources":["../../../src/namespaces/VfsNamespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAYhE;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,YAAY;IAI1B,MAAM,CAAC,IAAI,EAAE,MAAM;;;;IAenB,OAAO,CAAC,IAAI,EAAE,MAAM;;;;;IAepB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAevC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAavD,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAe9C,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAavD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAanC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAY7C"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { VfsCreateDir, VfsDelete, VfsExists, VfsGetAbsolutePath, VfsReadDir, VfsReadFile, VfsRename, VfsWriteFile, } from "../messages/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Virtual file system namespace for file operations.
|
|
4
|
+
* This class is not part of the public SDK API.
|
|
5
|
+
*/
|
|
6
|
+
export class VfsNamespace {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
async exists(path) {
|
|
12
|
+
const response = await this.client.sendAndWait("vfs.exists", { path }, VfsExists.Request, VfsExists.Response);
|
|
13
|
+
if (!response.success) {
|
|
14
|
+
throw new Error(response.error);
|
|
15
|
+
}
|
|
16
|
+
return response.data;
|
|
17
|
+
}
|
|
18
|
+
async readDir(path) {
|
|
19
|
+
const response = await this.client.sendAndWait("vfs.readDir", { path }, VfsReadDir.Request, VfsReadDir.Response);
|
|
20
|
+
if (!response.success) {
|
|
21
|
+
throw new Error(response.error);
|
|
22
|
+
}
|
|
23
|
+
return response.data;
|
|
24
|
+
}
|
|
25
|
+
async readFile(path) {
|
|
26
|
+
const response = await this.client.sendAndWait("vfs.readFile", { path }, VfsReadFile.Request, VfsReadFile.Response);
|
|
27
|
+
if (!response.success) {
|
|
28
|
+
throw new Error(response.error);
|
|
29
|
+
}
|
|
30
|
+
return response.data;
|
|
31
|
+
}
|
|
32
|
+
async writeFile(path, content) {
|
|
33
|
+
const response = await this.client.sendAndWait("vfs.writeFile", { path, content }, VfsWriteFile.Request, VfsWriteFile.Response);
|
|
34
|
+
if (!response.success) {
|
|
35
|
+
throw new Error(response.error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async getAbsolutePath(path) {
|
|
39
|
+
const response = await this.client.sendAndWait("vfs.getAbsolutePath", { path }, VfsGetAbsolutePath.Request, VfsGetAbsolutePath.Response);
|
|
40
|
+
if (!response.success) {
|
|
41
|
+
throw new Error(response.error);
|
|
42
|
+
}
|
|
43
|
+
return response.data.absolutePath;
|
|
44
|
+
}
|
|
45
|
+
async rename(oldPath, newPath) {
|
|
46
|
+
const response = await this.client.sendAndWait("vfs.rename", { oldPath, newPath }, VfsRename.Request, VfsRename.Response);
|
|
47
|
+
if (!response.success) {
|
|
48
|
+
throw new Error(response.error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async delete(path) {
|
|
52
|
+
const response = await this.client.sendAndWait("vfs.delete", { path }, VfsDelete.Request, VfsDelete.Response);
|
|
53
|
+
if (!response.success) {
|
|
54
|
+
throw new Error(response.error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async createDir(path) {
|
|
58
|
+
const response = await this.client.sendAndWait("vfs.createDir", { path }, VfsCreateDir.Request, VfsCreateDir.Response);
|
|
59
|
+
if (!response.success) {
|
|
60
|
+
throw new Error(response.error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=VfsNamespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VfsNamespace.js","sourceRoot":"","sources":["../../../src/namespaces/VfsNamespace.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,SAAS,EACT,YAAY,GACb,MAAM,sBAAsB,CAAC;AAE9B;;;GAGG;AACH,MAAM,OAAO,YAAY;IACN,MAAM,CAAe;IAEtC,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;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,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAY;QAC1B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5C,eAAe,EACf,EAAE,IAAI,EAAE,EACR,YAAY,CAAC,OAAO,EACpB,YAAY,CAAC,QAAQ,CACtB,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IFrameClient } from "../messages/IFrameClient.js";
|
|
2
|
+
import { type WorkspaceChanged, type WorkspaceDetails } from "../messages/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Workspace namespace for workspace operations.
|
|
5
|
+
* This class is not part of the public SDK API.
|
|
6
|
+
*/
|
|
7
|
+
export declare class WorkspaceNamespace {
|
|
8
|
+
private readonly client;
|
|
9
|
+
constructor(client: IFrameClient);
|
|
10
|
+
getDetails(): Promise<WorkspaceDetails>;
|
|
11
|
+
onChanged(callback: (payload: WorkspaceChanged) => void): () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Open a folder picker dialog to select a workspace.
|
|
14
|
+
* @returns The selected workspace path, or null if cancelled
|
|
15
|
+
*/
|
|
16
|
+
open(): Promise<string | null>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=WorkspaceNamespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkspaceNamespace.d.ts","sourceRoot":"","sources":["../../../src/namespaces/WorkspaceNamespace.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAE9B;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,YAAY;IAI1B,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAe7C,SAAS,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI;IAyBpE;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAcrC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { safeParse } from "valibot";
|
|
2
|
+
import { WorkspaceGetDetails, WorkspaceOpen, WorkspaceChangedSchema, } from "../messages/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Workspace namespace for workspace operations.
|
|
5
|
+
* This class is not part of the public SDK API.
|
|
6
|
+
*/
|
|
7
|
+
export class WorkspaceNamespace {
|
|
8
|
+
client;
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
async getDetails() {
|
|
13
|
+
const response = await this.client.sendAndWait("workspace.getDetails", {}, WorkspaceGetDetails.Request, WorkspaceGetDetails.Response);
|
|
14
|
+
if (!response.success) {
|
|
15
|
+
throw new Error(response.error);
|
|
16
|
+
}
|
|
17
|
+
return response.data;
|
|
18
|
+
}
|
|
19
|
+
onChanged(callback) {
|
|
20
|
+
return this.client.subscribe((evt) => {
|
|
21
|
+
const { type, payload } = evt.data || {};
|
|
22
|
+
if (type !== "workspace.changed") {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const result = safeParse(WorkspaceChangedSchema, {
|
|
26
|
+
type,
|
|
27
|
+
...payload,
|
|
28
|
+
});
|
|
29
|
+
if (!result.success) {
|
|
30
|
+
console.error("[SDK] Invalid workspace.changed payload:", result.issues);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
callback(result.output);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Open a folder picker dialog to select a workspace.
|
|
38
|
+
* @returns The selected workspace path, or null if cancelled
|
|
39
|
+
*/
|
|
40
|
+
async open() {
|
|
41
|
+
const response = await this.client.sendAndWait("workspace.open", {}, WorkspaceOpen.Request, WorkspaceOpen.Response);
|
|
42
|
+
if (!response.success) {
|
|
43
|
+
throw new Error(response.error);
|
|
44
|
+
}
|
|
45
|
+
return response.path;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=WorkspaceNamespace.js.map
|