Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions desktop/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ async function handleListPathContent(event, uri, options) {
return await listPathContent(uri, options);
}

async function handleHasFile(event, path) {
async function handleHasPath(event, path) {
return fs.existsSync(path);
}

Expand Down Expand Up @@ -278,7 +278,7 @@ app.whenReady().then(() => {
ipcMain.handle("rename", handleRename);
ipcMain.handle("delete", handleDelete);

ipcMain.handle("has-file", handleHasFile);
ipcMain.handle("has-path", handleHasPath);
ipcMain.handle("read-file", handleReadFile);
ipcMain.handle("write-file", handleWriteFile);

Expand Down
2 changes: 1 addition & 1 deletion desktop/preload.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contextBridge.exposeInMainWorld("electronAPI", {
rename: (oldUri, newUri) => ipcRenderer.invoke("rename", oldUri, newUri),
delete: (uri) => ipcRenderer.invoke("delete", uri),

hasFile: (path) => ipcRenderer.invoke("has-file", path),
hasPath: (path) => ipcRenderer.invoke("has-path", path),
readFile: (path) => ipcRenderer.invoke("read-file", path),
writeFile: (data, path) => ipcRenderer.invoke("write-file", data, path),

Expand Down
4 changes: 2 additions & 2 deletions npm-packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion npm-packages/cli/source/components/commands/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default function Create({cli}: {cli: Result<Flags>}) {
</Box>,
);
try {
await $`git clone --depth 1 https://github.com/ClayPulse/pulse-editor-extension-template.git ${name}`;
await $`git clone --depth 1 https://github.com/ClayPulse/pulse-app-template.git ${name}`;
} catch (error) {
setCreateMessage(
<Text color="redBright">
Expand Down
2 changes: 1 addition & 1 deletion npm-packages/react-api/src/hooks/agent/use-agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function useAgents() {

const result = await imc
.sendMessage(
IMCMessageTypeEnum.RunAgentMethod,
IMCMessageTypeEnum.EditorRunAgentMethod,
{
agentName,
methodName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function useImageGen() {
}

const result = await imc
.sendMessage(IMCMessageTypeEnum.UseImageGen, {
.sendMessage(IMCMessageTypeEnum.ModalityImageGen, {
textPrompt,
imagePrompt,
imageModelConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function useLLM() {
}

const result = await imc
.sendMessage(IMCMessageTypeEnum.UseLLM, {
.sendMessage(IMCMessageTypeEnum.ModalityLLM, {
prompt,
llmConfig,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function useOCR() {
}

// Send the message to the extension
const result = await imc.sendMessage(IMCMessageTypeEnum.UseOCR, { image });
const result = await imc.sendMessage(IMCMessageTypeEnum.ModalityOCR, { image });

return result.payload.text;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useState } from "react";
* Use speech-to-speech API to listen to user input and read the output
* provided by you.
*/
export default function UseSpeech2Speech() {
export default function useSpeech2Speech() {
const receiverHandlerMap = new Map<
IMCMessageTypeEnum,
(senderWindow: Window, message: IMCMessage) => Promise<void>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function useSTT() {
}

const result = await imc
.sendMessage(IMCMessageTypeEnum.UseSTT, {
.sendMessage(IMCMessageTypeEnum.ModalitySTT, {
audio,
sttConfig,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function useTTS() {
}

const result = await imc
.sendMessage(IMCMessageTypeEnum.UseTTS, {
.sendMessage(IMCMessageTypeEnum.ModalityTTS, {
text,
ttsConfig,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function useVideoGen() {
}

const result = await imc
.sendMessage(IMCMessageTypeEnum.UseVideoGen, {
.sendMessage(IMCMessageTypeEnum.ModalityVideoGen, {
duration,
textPrompt,
imagePrompt,
Expand Down
25 changes: 0 additions & 25 deletions npm-packages/react-api/src/hooks/editor/use-fetch.ts

This file was deleted.

5 changes: 2 additions & 3 deletions npm-packages/react-api/src/hooks/editor/use-file-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ export default function useFileView() {

useEffect(() => {
if (isReady) {
imc?.sendMessage(IMCMessageTypeEnum.RequestViewFile).then((model) => {
imc?.sendMessage(IMCMessageTypeEnum.PlatformReadFile).then((model) => {
setViewModel(model);
});
}
}, [isReady]);

function updateViewModel(viewModel: ViewModel) {
// sender.sendMessage(ViewBoxMessageTypeEnum.ViewFile, JSON.stringify(file));
imc?.sendMessage(IMCMessageTypeEnum.WriteViewFile, viewModel);
imc?.sendMessage(IMCMessageTypeEnum.PlatformWriteFile, viewModel);
}

return {
Expand Down
2 changes: 1 addition & 1 deletion npm-packages/react-api/src/hooks/editor/use-loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function useLoading() {

useEffect(() => {
if (isReady) {
imc?.sendMessage(IMCMessageTypeEnum.UseLoading, {
imc?.sendMessage(IMCMessageTypeEnum.EditorLoadingExt, {
isLoading,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function useNotification() {
if (!imc) {
throw new Error("IMC is not initialized.");
}
imc.sendMessage(IMCMessageTypeEnum.Notification, {
imc.sendMessage(IMCMessageTypeEnum.EditorShowNotification, {
text,
type,
});
Expand Down
2 changes: 1 addition & 1 deletion npm-packages/react-api/src/hooks/editor/use-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function useTheme() {
>();

receiverHandlerMap.set(
IMCMessageTypeEnum.ThemeChange,
IMCMessageTypeEnum.EditorThemeUpdate,
async (senderWindow: Window, message: IMCMessage) => {
const theme = message.payload;
setTheme((prev) => theme);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function useExtCommand(
function getReceiverHandlerMap() {
const receiverHandlerMap = new Map<IMCMessageTypeEnum, ReceiverHandler>([
[
IMCMessageTypeEnum.RunExtCommand,
IMCMessageTypeEnum.EditorRunExtCommand,
async (senderWindow: Window, message: IMCMessage) => {
if (!commandInfo) {
throw new Error("Extension command is not available");
Expand Down
2 changes: 1 addition & 1 deletion npm-packages/react-api/src/hooks/terminal/use-terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function useTerminal() {

useEffect(() => {
if (isReady) {
imc?.sendMessage(IMCMessageTypeEnum.RequestTerminal).then((response) => {
imc?.sendMessage(IMCMessageTypeEnum.PlatformCreateTerminal).then((response) => {
const {
websocketUrl,
projectHomePath,
Expand Down
26 changes: 12 additions & 14 deletions npm-packages/react-api/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
import useAgentTools from "./hooks/agent/use-agent-tools";
import useAgents from "./hooks/agent/use-agents";
import useFetch from "./hooks/editor/use-fetch";
import useFileView from "./hooks/editor/use-file-view";
import useLoading from "./hooks/editor/use-loading";
import useNotification from "./hooks/editor/use-notification";
import useTheme from "./hooks/editor/use-theme";
import useToolbar from "./hooks/editor/use-toolbar";
import useExtCommand from "./hooks/extension/use-ext-command";

import useImageGen from "./hooks/modality/use-image-gen";
import useLLM from "./hooks/modality/use-llm";
import useOCR from "./hooks/modality/use-ocr";
import useSTT from "./hooks/modality/use-stt";
import useTTS from "./hooks/modality/use-tts";
import useVideoGen from "./hooks/modality/use-video-gen";
import useImageGen from "./hooks/ai-modality/use-image-gen";
import useLLM from "./hooks/ai-modality/use-llm";
import useOCR from "./hooks/ai-modality/use-ocr";
import useSTT from "./hooks/ai-modality/use-stt";
import useTTS from "./hooks/ai-modality/use-tts";
import useVideoGen from "./hooks/ai-modality/use-video-gen";
import useTerminal from "./hooks/terminal/use-terminal";

export {
useAgentTools,
useAgents,
useFetch,
useFileView,
useNotification,
useTheme,
useToolbar,
useImageGen,
useVideoGen,
useLLM,
useOCR,
useSTT,
useTTS,
useImageGen as ModalityImageGen,
useVideoGen as ModalityVideoGen,
useLLM as ModalityLLM,
useOCR as ModalityOCR,
useSTT as ModalitySTT,
useTTS as ModalityTTS,
useExtCommand,
useTerminal,
useLoading,
Expand Down
10 changes: 5 additions & 5 deletions npm-packages/shared-utils/src/imc/inter-module-communication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class InterModuleCommunication {

if (
this.messageRecords?.has(messageId) &&
type !== IMCMessageTypeEnum.GetWindowId
type !== IMCMessageTypeEnum.SignalGetWindowId
) {
console.warn(
`Duplicate message received with ID: ${messageId}. Ignoring this message. Message: ${JSON.stringify(
Expand Down Expand Up @@ -131,7 +131,7 @@ export class InterModuleCommunication {
this.otherWindow = window;
this.otherWindow.postMessage(
{
type: IMCMessageTypeEnum.GetWindowId,
type: IMCMessageTypeEnum.SignalGetWindowId,
from: this.thisWindowId,
},
"*"
Expand Down Expand Up @@ -193,7 +193,7 @@ export class InterModuleCommunication {
// window has received the message and finished processing it.
// The current window must be initialized first. i.e. call initThisWindow() before initOtherWindow().
this.receiverHandlerMap?.set(
IMCMessageTypeEnum.Acknowledge,
IMCMessageTypeEnum.SignalAcknowledge,
async (senderWindow: Window, message: IMCMessage) => {
const pendingMessage = this.sender?.getPendingMessage(message.id);
if (pendingMessage) {
Expand All @@ -205,7 +205,7 @@ export class InterModuleCommunication {

// Set get window ID handler in the receiver handler map.
this.receiverHandlerMap?.set(
IMCMessageTypeEnum.GetWindowId,
IMCMessageTypeEnum.SignalGetWindowId,
async (senderWindow: Window, message: IMCMessage) => {
console.log(
"Received window ID request. Sending window ID to other window: "
Expand All @@ -216,7 +216,7 @@ export class InterModuleCommunication {
}
const msg: IMCMessage = {
id: message.id,
type: IMCMessageTypeEnum.ReturnWindowId,
type: IMCMessageTypeEnum.SignalReturnWindowId,
payload: {
windowId: id,
},
Expand Down
8 changes: 4 additions & 4 deletions npm-packages/shared-utils/src/imc/message-receiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class MessageReceiver {
if (this.windowId === message.from) return;

// Abort the task if the message type is Abort
if (message.type === IMCMessageTypeEnum.Abort) {
if (message.type === IMCMessageTypeEnum.SignalAbort) {
const id = message.id;
const pendingTask = this.pendingTasks.get(id);

Expand Down Expand Up @@ -55,15 +55,15 @@ export class MessageReceiver {
if (signal.aborted) return;

// Acknowledge the sender with the result if the message type is not Acknowledge
if (message.type !== IMCMessageTypeEnum.Acknowledge) {
if (message.type !== IMCMessageTypeEnum.SignalAcknowledge) {
this.acknowledgeSender(senderWindow, message.id, result);
}
})
.catch((error) => {
// Send the error message to the sender
const errMsg: IMCMessage = {
id: message.id,
type: IMCMessageTypeEnum.Error,
type: IMCMessageTypeEnum.SignalError,
payload: error.message,
from: this.windowId,
};
Expand All @@ -83,7 +83,7 @@ export class MessageReceiver {
): void {
const message: IMCMessage = {
id,
type: IMCMessageTypeEnum.Acknowledge,
type: IMCMessageTypeEnum.SignalAcknowledge,
payload: payload,
from: this.windowId,
};
Expand Down
2 changes: 1 addition & 1 deletion npm-packages/shared-utils/src/imc/message-sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class MessageSender {
this.targetWindow.postMessage(
{
id,
type: IMCMessageTypeEnum.Abort,
type: IMCMessageTypeEnum.SignalAbort,
payload: JSON.stringify({
status: "Task aborted",
data: null,
Expand Down
Loading
Loading