@pulse-editor/react-api 0.1.1-alpha.7 → 0.1.1-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Add or use agent tools in the editor.
3
+ * @param moduleName
4
+ * @returns
5
+ */
6
+ export default function useAgentTools(): {};
@@ -0,0 +1,5 @@
1
+ import { LLMConfig } from "@pulse-editor/shared-utils";
2
+ export default function useAgents(): {
3
+ runAgentMethod: (agentName: string, methodName: string, parameters: Record<string, any>, abortSignal?: AbortSignal, llmConfig?: LLMConfig) => Promise<any>;
4
+ isReady: boolean;
5
+ };
@@ -0,0 +1,6 @@
1
+ import { ViewModel } from "@pulse-editor/shared-utils";
2
+ export default function useFileView(): {
3
+ viewModel: ViewModel | undefined;
4
+ updateViewModel: (viewModel: ViewModel) => void;
5
+ setIsLoaded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
6
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Use the microphone to record audio. (WIP)
3
+ */
4
+ export default function useMic(): void;
@@ -0,0 +1 @@
1
+ export default function useToolbar(): {};
@@ -0,0 +1,9 @@
1
+ import { ExtensionCommandInfo } from "@pulse-editor/shared-utils";
2
+ /**
3
+ * Register an extension command to listen to IMC messages from the core,
4
+ * and pass to the extension to handle.
5
+ */
6
+ export default function useExtCommand(commandInfo: ExtensionCommandInfo, initialHandler?: (args: any) => Promise<string | void>): {
7
+ isReady: boolean;
8
+ updateHandler: (handler: (args: any) => Promise<string | void>) => void;
9
+ };
@@ -0,0 +1 @@
1
+ export default function useDiffusion(): {};
@@ -0,0 +1,5 @@
1
+ import { LLMConfig } from "@pulse-editor/shared-utils";
2
+ export default function useLLM(): {
3
+ runLLM: (prompt: string, llmConfig?: LLMConfig) => Promise<string>;
4
+ isReady: boolean;
5
+ };
@@ -0,0 +1,3 @@
1
+ export default function useOCR(): {
2
+ recognizeText: (image: string) => Promise<string>;
3
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Use speech-to-speech API to listen to user input and read the output
3
+ * provided by you.
4
+ */
5
+ export default function UseSpeech2Speech(): {
6
+ isReady: boolean;
7
+ userInput: string;
8
+ isUserStopped: boolean;
9
+ respondAndRead: (text: string) => Promise<void>;
10
+ };
@@ -0,0 +1,5 @@
1
+ import { STTConfig } from "@pulse-editor/shared-utils";
2
+ export default function useSTT(): {
3
+ runSTT: (audio: Uint8Array, sttConfig?: STTConfig) => Promise<string>;
4
+ isReady: boolean;
5
+ };
@@ -0,0 +1,5 @@
1
+ import { TTSConfig } from "@pulse-editor/shared-utils";
2
+ export default function useTTS(): {
3
+ runTTS: (text: string, ttsConfig?: TTSConfig) => Promise<Uint8Array>;
4
+ isReady: boolean;
5
+ };
package/dist/main.d.ts CHANGED
@@ -1,7 +1,14 @@
1
- import useFileView from "./hooks/use-file-view";
2
- import useTheme from "./hooks/use-theme";
3
- import useNotification from "./hooks/use-notification";
4
- import useAgents from "./hooks/use-agents";
5
- import useOCR from "./hooks/use-orc";
6
- import useTerminal from "./hooks/use-terminal";
7
- export { useFileView, useTheme, useNotification, useAgents, useOCR, useTerminal, };
1
+ import useAgentTools from "./hooks/agent/use-agent-tools";
2
+ import useAgents from "./hooks/agent/use-agents";
3
+ import useFetch from "./hooks/editor/use-fetch";
4
+ import useFileView from "./hooks/editor/use-file-view";
5
+ import useNotification from "./hooks/editor/use-notification";
6
+ import useTheme from "./hooks/editor/use-theme";
7
+ import useToolbar from "./hooks/editor/use-toolbar";
8
+ import useExtCommand from "./hooks/extension/use-ext-command";
9
+ import useDiffusion from "./hooks/modality/use-diffusion";
10
+ import useLLM from "./hooks/modality/use-llm";
11
+ import useOCR from "./hooks/modality/use-ocr";
12
+ import useSTT from "./hooks/modality/use-stt";
13
+ import useTTS from "./hooks/modality/use-tts";
14
+ export { useAgentTools, useAgents, useFetch, useFileView, useNotification, useTheme, useToolbar, useDiffusion, useLLM, useOCR, useSTT, useTTS, useExtCommand, };
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- import{InterModuleCommunication as e,IMCMessageTypeEnum as n}from"@pulse-editor/shared-utils";import{useState as t,useEffect as i}from"react";function o(o){const[s,r]=t(void 0),[a,d]=t(!1),[c,u]=t(!1),w=window.parent;return i((()=>(u(!0),()=>{s?.close()})),[]),i((()=>{if(!c)return;if(void 0!==s)return;const t=new e;t.initThisWindow(window),t.updateReceiverHandlerMap(o),t.initOtherWindow(w),r(t),t.sendMessage(n.Ready).then((()=>{d(!0)}))}),[c,s]),{imc:s,isReady:a}}function s(){const[e,s]=t(void 0),[r,a]=t(!1),d=new Map,{imc:c,isReady:u}=o(d);return i((()=>{u&&c?.sendMessage(n.RequestViewFile).then((e=>{s(e)}))}),[u]),i((()=>{r&&c?.sendMessage(n.Loaded)}),[r,c]),{viewFile:e,updateViewFile:function(e){c?.sendMessage(n.WriteViewFile,e)},setIsLoaded:a}}function r(){const[e,i]=t("light"),s=new Map;return s.set(n.ThemeChange,(async(e,n)=>{const t=n.payload;i((e=>t))})),o(s),{theme:e}}function a(){const e=new Map,{imc:t}=o(e);return{openNotification:function(e,i){if(!t)throw new Error("IMC is not initialized.");t.sendMessage(n.Notification,{text:e,type:i})}}}function d(){const e=new Map,{imc:t,isReady:i}=o(e);return{installAgent:async function(e){if(!t)throw new Error("IMC not initialized.");await t.sendMessage(n.InstallAgent,e).catch((e=>{throw new Error(e)}))},runAgentMethod:async function(e,i,o,s){if(!t)throw new Error("IMC not initialized.");return await t.sendMessage(n.RunAgentMethod,{agentName:e,methodName:i,parameters:o},s).then((e=>e))},isReady:i}}function c(){const e=new Map,{imc:t}=o(e);return{recognizeText:async function(e){if(!t)throw new Error("IMC is not initialized.");return(await t.sendMessage(n.OCR,{uri:e})).payload.text}}}function u(){const e=new Map,{imc:s,isReady:r}=o(e),[a,d]=t(void 0);return i((()=>{r&&s?.sendMessage(n.RequestTerminal).then((e=>{const{websocketUrl:t}=e;d(t),s.sendMessage(n.Loaded)}))}),[r]),{websocketUrl:a}}export{d as useAgents,s as useFileView,a as useNotification,c as useOCR,u as useTerminal,r as useTheme};
1
+ import{InterModuleCommunication as e,IMCMessageTypeEnum as n}from"@pulse-editor/shared-utils";import{useState as t,useEffect as i}from"react";function r(r){const[o,a]=t(void 0),[s,c]=t(!1),[d,u]=t(!1),f=window.parent;return i((()=>(u(!0),()=>{u(!1),o?.close(),a(void 0)})),[]),i((()=>{if(!d)return;if(void 0!==o)return;const t=new e;t.initThisWindow(window),t.updateReceiverHandlerMap(r),t.initOtherWindow(f),a(t),t.sendMessage(n.ExtReady).then((()=>{c(!0)}))}),[d,o]),{imc:o,isReady:s}}function o(){return r(new Map),{}}function a(){const e=new Map,{imc:t,isReady:i}=r(e);return{runAgentMethod:async function(e,i,r,o,a){if(!t)throw new Error("IMC not initialized.");return await t.sendMessage(n.RunAgentMethod,{agentName:e,methodName:i,parameters:r,llmConfig:a},o).then((e=>e))},isReady:i}}function s(){const e=new Map,{imc:t}=r(e);return{fetch:function(e,i){if(!t)throw new Error("IMC is not initialized.");return t.sendMessage(n.Fetch,JSON.stringify({uri:e,options:i}))}}}function c(){const[e,o]=t(void 0),[a,s]=t(!1),c=new Map,{imc:d,isReady:u}=r(c);return i((()=>{u&&d?.sendMessage(n.RequestViewFile).then((e=>{o(e)}))}),[u]),i((()=>{a&&d?.sendMessage(n.Loaded)}),[a,d]),{viewModel:e,updateViewModel:function(e){d?.sendMessage(n.WriteViewFile,e)},setIsLoaded:s}}function d(){const e=new Map,{imc:t}=r(e);return{openNotification:function(e,i){if(!t)throw new Error("IMC is not initialized.");t.sendMessage(n.Notification,{text:e,type:i})}}}function u(){const[e,i]=t("light"),o=new Map;return o.set(n.ThemeChange,(async(e,n)=>{const t=n.payload;i((e=>t))})),r(o),{theme:e}}function f(){return{}}function w(e,o){const{isReady:a,imc:s}=r(u()),[c,d]=t(o);function u(){return new Map([[n.RunExtCommand,async(n,t)=>{if(!e)throw new Error("Extension command is not available");const{name:i,args:r}=t.payload;if(i===e.name){const n=e.parameters;if(Object.keys(r).length!==Object.keys(n).length)throw new Error(`Invalid number of parameters: expected ${Object.keys(n).length}, got ${Object.keys(r).length}`);for(const[n,t]of Object.entries(r)){if(void 0===e.parameters[n])throw new Error(`Invalid parameter: ${n}`);if(typeof t!==e.parameters[n].type)throw new Error(`Invalid type for parameter ${n}: expected ${e.parameters[n].type}, got ${typeof t}. Value received: ${t}`)}if(c){const e=await c(r);if(e)return e}}}]])}return i((()=>{s?.updateReceiverHandlerMap(u())}),[c,s]),{isReady:a,updateHandler:function(e){d((()=>e))}}}function p(){return{}}function m(){const e=new Map,{imc:t,isReady:i}=r(e);return{runLLM:async function(e,i){if(!t)throw new Error("IMC not initialized.");return await t.sendMessage(n.UseLLM,{prompt:e,llmConfig:i}).then((e=>e))},isReady:i}}function M(){const e=new Map,{imc:t}=r(e);return{recognizeText:async function(e){if(!t)throw new Error("IMC is not initialized.");return(await t.sendMessage(n.UseOCR,{image:e})).payload.text}}}function l(){const e=new Map,{imc:t,isReady:i}=r(e);return{runSTT:async function(e,i){if(!t)throw new Error("IMC not initialized.");return await t.sendMessage(n.UseSTT,{audio:e,sttConfig:i}).then((e=>e))},isReady:i}}function y(){const e=new Map,{imc:t,isReady:i}=r(e);return{runTTS:async function(e,i){if(!t)throw new Error("IMC not initialized.");return await t.sendMessage(n.UseTTS,{text:e,ttsConfig:i}).then((e=>e))},isReady:i}}export{o as useAgentTools,a as useAgents,p as useDiffusion,w as useExtCommand,s as useFetch,c as useFileView,m as useLLM,d as useNotification,M as useOCR,l as useSTT,y as useTTS,u as useTheme,f as useToolbar};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pulse-editor/react-api",
3
- "version": "0.1.1-alpha.7",
3
+ "version": "0.1.1-alpha.8",
4
4
  "main": "dist/main.js",
5
5
  "files": [
6
6
  "dist"
@@ -38,7 +38,7 @@
38
38
  "typescript-eslint": "^8.30.1"
39
39
  },
40
40
  "peerDependencies": {
41
- "@pulse-editor/shared-utils": "0.1.1-alpha.7",
41
+ "@pulse-editor/shared-utils": "0.1.1-alpha.8",
42
42
  "react": "^19.0.0",
43
43
  "react-dom": "^19.0.0"
44
44
  }
@@ -1,9 +0,0 @@
1
- import { AgentTool } from "@pulse-editor/shared-utils";
2
- /**
3
- * Add or use agent tools in the editor.
4
- * @param moduleName
5
- * @returns
6
- */
7
- export default function useAgentTools(): {
8
- installAgentTool: (tool: AgentTool) => Promise<void>;
9
- };
@@ -1,6 +0,0 @@
1
- import { Agent } from "@pulse-editor/shared-utils";
2
- export default function useAgents(): {
3
- installAgent: (config: Agent) => Promise<void>;
4
- runAgentMethod: (agentName: string, methodName: string, parameters: Record<string, any>, abortSignal?: AbortSignal) => Promise<Record<string, any>>;
5
- isReady: boolean;
6
- };
@@ -1,6 +0,0 @@
1
- import { FileViewModel } from "@pulse-editor/shared-utils";
2
- export default function useFileView(): {
3
- viewFile: FileViewModel | undefined;
4
- updateViewFile: (file: FileViewModel) => void;
5
- setIsLoaded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
6
- };
@@ -1,3 +0,0 @@
1
- export default function useOCR(): {
2
- recognizeText: (uri: string) => Promise<string>;
3
- };
File without changes