@rimori/client 1.0.3 → 1.0.4
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 +51 -0
- package/dist/components/CRUDModal.js +0 -1
- package/dist/components/ai/Assistant.d.ts +9 -0
- package/dist/components/ai/Assistant.js +59 -0
- package/dist/components/ai/Avatar.d.ts +11 -0
- package/dist/components/ai/Avatar.js +39 -0
- package/dist/components/ai/EmbeddedAssistent/AudioInputField.d.ts +7 -0
- package/dist/components/ai/EmbeddedAssistent/AudioInputField.js +38 -0
- package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.d.ts +7 -0
- package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +59 -0
- package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.d.ts +19 -0
- package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.js +86 -0
- package/dist/components/ai/EmbeddedAssistent/TTS/Player.d.ts +25 -0
- package/dist/components/ai/EmbeddedAssistent/TTS/Player.js +180 -0
- package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +7 -0
- package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +45 -0
- package/dist/components/ai/utils.d.ts +6 -0
- package/dist/components/ai/utils.js +14 -0
- package/dist/components/audio/Playbutton.js +4 -5
- package/dist/components/avatar/Assistant.d.ts +9 -0
- package/dist/components/avatar/Assistant.js +59 -0
- package/dist/components/avatar/Avatar.d.ts +12 -0
- package/dist/components/avatar/Avatar.js +42 -0
- package/dist/components/avatar/EmbeddedAssistent/AudioInputField.d.ts +7 -0
- package/dist/components/avatar/EmbeddedAssistent/AudioInputField.js +38 -0
- package/dist/components/avatar/EmbeddedAssistent/CircleAudioAvatar.d.ts +7 -0
- package/dist/components/avatar/EmbeddedAssistent/CircleAudioAvatar.js +59 -0
- package/dist/components/avatar/EmbeddedAssistent/TTS/MessageSender.d.ts +19 -0
- package/dist/components/avatar/EmbeddedAssistent/TTS/MessageSender.js +84 -0
- package/dist/components/avatar/EmbeddedAssistent/TTS/Player.d.ts +25 -0
- package/dist/components/avatar/EmbeddedAssistent/TTS/Player.js +180 -0
- package/dist/components/avatar/EmbeddedAssistent/VoiceRecoder.d.ts +7 -0
- package/dist/components/avatar/EmbeddedAssistent/VoiceRecoder.js +45 -0
- package/dist/components/avatar/utils.d.ts +6 -0
- package/dist/components/avatar/utils.js +14 -0
- package/dist/components.d.ts +9 -0
- package/dist/components.js +10 -0
- package/dist/controller/AIController.d.ts +4 -3
- package/dist/controller/AIController.js +32 -8
- package/dist/controller/ObjectController.d.ts +2 -2
- package/dist/controller/ObjectController.js +4 -5
- package/dist/controller/SettingsController.d.ts +2 -1
- package/dist/controller/SettingsController.js +9 -0
- package/dist/controller/SharedContentController.js +6 -6
- package/dist/core.d.ts +9 -0
- package/dist/core.js +10 -0
- package/dist/hooks/UseChatHook.js +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -2
- package/dist/plugin/PluginController.d.ts +4 -12
- package/dist/plugin/PluginController.js +43 -70
- package/dist/plugin/RimoriClient.d.ts +85 -32
- package/dist/plugin/RimoriClient.js +98 -77
- package/dist/plugin/fromRimori/EventBus.d.ts +98 -0
- package/dist/plugin/fromRimori/EventBus.js +240 -0
- package/dist/providers/PluginProvider.d.ts +1 -0
- package/dist/providers/PluginProvider.js +10 -12
- package/dist/worker/WorkerSetup.d.ts +6 -0
- package/dist/worker/WorkerSetup.js +79 -0
- package/package.json +16 -3
- package/src/components/CRUDModal.tsx +1 -3
- package/src/components/ai/Assistant.tsx +96 -0
- package/src/components/ai/Avatar.tsx +61 -0
- package/src/components/ai/EmbeddedAssistent/AudioInputField.tsx +64 -0
- package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +75 -0
- package/src/components/ai/EmbeddedAssistent/TTS/MessageSender.ts +91 -0
- package/src/components/ai/EmbeddedAssistent/TTS/Player.ts +192 -0
- package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +56 -0
- package/src/components/ai/utils.ts +23 -0
- package/src/components/audio/Playbutton.tsx +4 -5
- package/src/components.ts +10 -0
- package/src/controller/AIController.ts +84 -60
- package/src/controller/ObjectController.ts +4 -6
- package/src/controller/SettingsController.ts +9 -1
- package/src/controller/SharedContentController.ts +6 -6
- package/src/core.ts +10 -0
- package/src/hooks/UseChatHook.ts +2 -2
- package/src/index.ts +4 -2
- package/src/plugin/PluginController.ts +46 -76
- package/src/plugin/RimoriClient.ts +147 -85
- package/src/plugin/fromRimori/EventBus.ts +301 -0
- package/src/plugin/fromRimori/readme.md +2 -0
- package/src/providers/PluginProvider.tsx +12 -14
- package/src/worker/WorkerSetup.ts +80 -0
- package/dist/CRUDModal.d.ts +0 -16
- package/dist/CRUDModal.js +0 -31
- package/dist/MarkdownEditor.d.ts +0 -8
- package/dist/MarkdownEditor.js +0 -46
- package/dist/audio/Playbutton.d.ts +0 -14
- package/dist/audio/Playbutton.js +0 -73
- package/dist/components/hooks/UseChatHook.d.ts +0 -15
- package/dist/components/hooks/UseChatHook.js +0 -21
- package/dist/controller/PluginController.d.ts +0 -14
- package/dist/controller/PluginController.js +0 -30
- package/dist/plugin/AIController copy.d.ts +0 -22
- package/dist/plugin/AIController copy.js +0 -68
- package/dist/plugin/AIController.d.ts +0 -22
- package/dist/plugin/AIController.js +0 -68
- package/dist/plugin/ObjectController.d.ts +0 -34
- package/dist/plugin/ObjectController.js +0 -77
- package/dist/plugin/SettingController.d.ts +0 -13
- package/dist/plugin/SettingController.js +0 -55
- package/dist/plugin/VoiceController.d.ts +0 -2
- package/dist/plugin/VoiceController.js +0 -27
- package/dist/providers/EventEmitter.d.ts +0 -11
- package/dist/providers/EventEmitter.js +0 -41
- package/dist/providers/EventEmitterContext.d.ts +0 -6
- package/dist/providers/EventEmitterContext.js +0 -19
- package/dist/utils/DifficultyConverter.d.ts +0 -3
- package/dist/utils/DifficultyConverter.js +0 -7
- package/dist/utils/constants.d.ts +0 -4
- package/dist/utils/constants.js +0 -12
- package/dist/utils/plugin/Client.d.ts +0 -72
- package/dist/utils/plugin/Client.js +0 -118
- package/dist/utils/plugin/PluginController.d.ts +0 -36
- package/dist/utils/plugin/PluginController.js +0 -119
- package/dist/utils/plugin/PluginUtils.d.ts +0 -2
- package/dist/utils/plugin/PluginUtils.js +0 -23
- package/dist/utils/plugin/RimoriClient.d.ts +0 -72
- package/dist/utils/plugin/RimoriClient.js +0 -118
- package/dist/utils/plugin/ThemeSetter.d.ts +0 -1
- package/dist/utils/plugin/ThemeSetter.js +0 -13
- package/dist/utils/plugin/WhereClauseBuilder.d.ts +0 -24
- package/dist/utils/plugin/WhereClauseBuilder.js +0 -79
- package/dist/utils/plugin/providers/EventEmitter.d.ts +0 -11
- package/dist/utils/plugin/providers/EventEmitter.js +0 -41
- package/dist/utils/plugin/providers/EventEmitterContext.d.ts +0 -6
- package/dist/utils/plugin/providers/EventEmitterContext.js +0 -19
- package/dist/utils/plugin/providers/PluginProvider.d.ts +0 -8
- package/dist/utils/plugin/providers/PluginProvider.js +0 -49
- package/src/providers/EventEmitter.ts +0 -48
- package/src/providers/EventEmitterContext.tsx +0 -27
- package/src/utils/constants.ts +0 -18
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export class RimoriClient {
|
|
11
|
-
constructor(pluginController, superbase) {
|
|
12
|
-
this.superbase = superbase;
|
|
13
|
-
this.plugin = pluginController;
|
|
14
|
-
this.functions = this.superbase.functions;
|
|
15
|
-
this.storage = this.superbase.storage;
|
|
16
|
-
}
|
|
17
|
-
static getInstance(pluginController) {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
if (!RimoriClient.instance) {
|
|
20
|
-
const superbase = yield pluginController.getClient();
|
|
21
|
-
RimoriClient.instance = new RimoriClient(pluginController, superbase);
|
|
22
|
-
}
|
|
23
|
-
return RimoriClient.instance;
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
from(relation) {
|
|
27
|
-
return this.superbase.from(relation);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Perform a function call.
|
|
31
|
-
*
|
|
32
|
-
* @param fn - The function name to call
|
|
33
|
-
* @param args - The arguments to pass to the function call
|
|
34
|
-
* @param options - Named parameters
|
|
35
|
-
* @param options.head - When set to `true`, `data` will not be returned.
|
|
36
|
-
* Useful if you only need the count.
|
|
37
|
-
* @param options.get - When set to `true`, the function will be called with
|
|
38
|
-
* read-only access mode.
|
|
39
|
-
* @param options.count - Count algorithm to use to count rows returned by the
|
|
40
|
-
* function. Only applicable for [set-returning
|
|
41
|
-
* functions](https://www.postgresql.org/docs/current/functions-srf.html).
|
|
42
|
-
*
|
|
43
|
-
* `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
|
|
44
|
-
* hood.
|
|
45
|
-
*
|
|
46
|
-
* `"planned"`: Approximated but fast count algorithm. Uses the Postgres
|
|
47
|
-
* statistics under the hood.
|
|
48
|
-
*
|
|
49
|
-
* `"estimated"`: Uses exact count for low numbers and planned count for high
|
|
50
|
-
* numbers.
|
|
51
|
-
*/
|
|
52
|
-
rpc(fn, args = {}, options = {}) {
|
|
53
|
-
return this.superbase.rpc(fn, args, options);
|
|
54
|
-
}
|
|
55
|
-
subscribe(eventName, callback) {
|
|
56
|
-
this.plugin.subscribe(eventName, callback);
|
|
57
|
-
}
|
|
58
|
-
request(eventName, data) {
|
|
59
|
-
return this.plugin.request(eventName, data);
|
|
60
|
-
}
|
|
61
|
-
emit(eventName, data) {
|
|
62
|
-
this.plugin.emit(eventName, data);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Get the settings for the plugin. T can be any type of settings, UserSettings or SystemSettings.
|
|
66
|
-
* @param defaultSettings The default settings to use if no settings are found.
|
|
67
|
-
* @param genericSettings The type of settings to get.
|
|
68
|
-
* @returns The settings for the plugin.
|
|
69
|
-
*/
|
|
70
|
-
getSettings(defaultSettings, genericSettings) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
const response = yield this.plugin.request("get_settings", { genericSettings });
|
|
73
|
-
if (response === null) {
|
|
74
|
-
this.setSettings(defaultSettings, genericSettings);
|
|
75
|
-
return defaultSettings;
|
|
76
|
-
//if the settings are not the same, merge the settings
|
|
77
|
-
}
|
|
78
|
-
else if (Object.keys(response).length !== Object.keys(defaultSettings).length) {
|
|
79
|
-
const existingKeys = Object.fromEntries(Object.entries(response).filter(([k]) => k in defaultSettings));
|
|
80
|
-
const mergedSettings = Object.assign(Object.assign({}, defaultSettings), existingKeys);
|
|
81
|
-
console.warn("Settings mismatch", { response, defaultSettings, mergedSettings });
|
|
82
|
-
this.setSettings(mergedSettings, genericSettings);
|
|
83
|
-
return mergedSettings;
|
|
84
|
-
}
|
|
85
|
-
return response;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
setSettings(settings, genericSettings) {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
yield this.plugin.request("set_settings", { settings, genericSettings });
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
getAIResponse(messages) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
return this.plugin.request("getAIResponse", messages);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
getAIResponseStream(messages, onMessage, tools) {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
throw new Error("Not implemented");
|
|
101
|
-
// let triggered = false;
|
|
102
|
-
// console.log("getAIResponseStream", messages);
|
|
103
|
-
// const id = Math.random();
|
|
104
|
-
// this.internalEmit("getAIResponseStream", id, { messages, tools: tools || [] });
|
|
105
|
-
// this.subscribe("getAIResponseStream", (_id: number, data: { id: string, response: string, finished: boolean, toolInvocations?: ToolInvocation[] }) => {
|
|
106
|
-
// if (triggered || (_id !== id && _id !== 0)) return;
|
|
107
|
-
// triggered = data.finished;
|
|
108
|
-
// onMessage(data.id, data.response, data.finished, data.toolInvocations);
|
|
109
|
-
// })
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
getVoiceResponse(text, voice = "alloy", speed = 1, language) {
|
|
113
|
-
return this.plugin.request("getVoiceResponse", { text, voice, speed, language });
|
|
114
|
-
}
|
|
115
|
-
getVoiceToTextResponse(file) {
|
|
116
|
-
return this.plugin.request("getSTTResponse", file);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
-
import { RimoriClient } from "./RimoriClient";
|
|
3
|
-
export interface Tool {
|
|
4
|
-
name: string;
|
|
5
|
-
description: string;
|
|
6
|
-
parameters: {
|
|
7
|
-
name: string;
|
|
8
|
-
type: "string" | "number" | "boolean";
|
|
9
|
-
description: string;
|
|
10
|
-
}[];
|
|
11
|
-
}
|
|
12
|
-
export interface ToolInvocation {
|
|
13
|
-
toolName: string;
|
|
14
|
-
args: Record<string, string>;
|
|
15
|
-
}
|
|
16
|
-
export declare class PluginController {
|
|
17
|
-
private static instance;
|
|
18
|
-
private static client;
|
|
19
|
-
private plugin;
|
|
20
|
-
private onceListeners;
|
|
21
|
-
private listeners;
|
|
22
|
-
private communicationSecret;
|
|
23
|
-
private initialized;
|
|
24
|
-
private supabase;
|
|
25
|
-
private accessTokenExpiration;
|
|
26
|
-
private constructor();
|
|
27
|
-
static getInstance(): Promise<RimoriClient>;
|
|
28
|
-
init(): Promise<void>;
|
|
29
|
-
private getSecret;
|
|
30
|
-
getClient(): Promise<SupabaseClient<any, "public", any>>;
|
|
31
|
-
emit(eventName: string, data?: any): void;
|
|
32
|
-
private internalEmit;
|
|
33
|
-
subscribe(eventName: string, callback: (_id: number, data: any) => void): void;
|
|
34
|
-
onOnce(eventName: string, callback: (data: any) => void): void;
|
|
35
|
-
request<T>(topic: string, data: any): Promise<T>;
|
|
36
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { Child } from "ibridge-flex";
|
|
11
|
-
import { createClient } from '@supabase/supabase-js';
|
|
12
|
-
import { RimoriClient } from "./RimoriClient";
|
|
13
|
-
export class PluginController {
|
|
14
|
-
constructor() {
|
|
15
|
-
// localStorage.debug = "*";
|
|
16
|
-
this.onceListeners = new Map();
|
|
17
|
-
this.listeners = new Map();
|
|
18
|
-
this.communicationSecret = null;
|
|
19
|
-
this.initialized = false;
|
|
20
|
-
this.supabase = null;
|
|
21
|
-
this.accessTokenExpiration = null;
|
|
22
|
-
this.plugin = new Child({
|
|
23
|
-
triggerChild: ({ topic, data, _id }) => {
|
|
24
|
-
var _a, _b;
|
|
25
|
-
// console.log("trigger child with topic:" + topic + " and data: ", data);
|
|
26
|
-
(_a = this.onceListeners.get(topic)) === null || _a === void 0 ? void 0 : _a.forEach((callback) => callback(_id, data));
|
|
27
|
-
this.onceListeners.set(topic, []);
|
|
28
|
-
(_b = this.listeners.get(topic)) === null || _b === void 0 ? void 0 : _b.forEach((callback) => callback(_id, data));
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
// this.init();
|
|
32
|
-
this.emit = this.emit.bind(this);
|
|
33
|
-
this.onOnce = this.onOnce.bind(this);
|
|
34
|
-
this.getClient = this.getClient.bind(this);
|
|
35
|
-
this.subscribe = this.subscribe.bind(this);
|
|
36
|
-
this.internalEmit = this.internalEmit.bind(this);
|
|
37
|
-
this.request = this.request.bind(this);
|
|
38
|
-
}
|
|
39
|
-
static getInstance() {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
if (!PluginController.instance) {
|
|
42
|
-
PluginController.instance = new PluginController();
|
|
43
|
-
yield PluginController.instance.init();
|
|
44
|
-
PluginController.client = yield RimoriClient.getInstance(PluginController.instance);
|
|
45
|
-
}
|
|
46
|
-
return PluginController.client;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
init() {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
if (this.initialized) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
// Wait for the plugin to be ready
|
|
55
|
-
yield this.plugin.handshake().then(() => this.initialized = true).catch((error) => {
|
|
56
|
-
console.error("Failed to initialize the plugin communication:", error);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
getSecret() {
|
|
61
|
-
if (!this.communicationSecret) {
|
|
62
|
-
const secret = new URLSearchParams(window.location.search).get("secret");
|
|
63
|
-
if (!secret) {
|
|
64
|
-
throw new Error("Communication secret not found in URL as query parameter");
|
|
65
|
-
}
|
|
66
|
-
this.communicationSecret = secret;
|
|
67
|
-
}
|
|
68
|
-
return this.communicationSecret;
|
|
69
|
-
}
|
|
70
|
-
getClient() {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
if (this.supabase && this.accessTokenExpiration && this.accessTokenExpiration > new Date()) {
|
|
73
|
-
return this.supabase;
|
|
74
|
-
}
|
|
75
|
-
const response = yield this.request("getSupabaseAccess", {});
|
|
76
|
-
this.accessTokenExpiration = response.expiration;
|
|
77
|
-
this.supabase = createClient(response.url, response.key, {
|
|
78
|
-
accessToken: () => Promise.resolve(response.token)
|
|
79
|
-
});
|
|
80
|
-
return this.supabase;
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
emit(eventName, data) {
|
|
84
|
-
this.internalEmit(eventName, 0, data);
|
|
85
|
-
}
|
|
86
|
-
// the communication needs to have an id to be able to distinguish between different responses
|
|
87
|
-
internalEmit(eventName, id, data) {
|
|
88
|
-
this.init().then(() => this.plugin.emitToParent(eventName, { data, _id: id, secret: this.getSecret() }));
|
|
89
|
-
}
|
|
90
|
-
subscribe(eventName, callback) {
|
|
91
|
-
var _a;
|
|
92
|
-
if (!this.listeners.has(eventName)) {
|
|
93
|
-
this.listeners.set(eventName, []);
|
|
94
|
-
}
|
|
95
|
-
(_a = this.listeners.get(eventName)) === null || _a === void 0 ? void 0 : _a.push(callback);
|
|
96
|
-
}
|
|
97
|
-
onOnce(eventName, callback) {
|
|
98
|
-
var _a;
|
|
99
|
-
if (!this.onceListeners.has(eventName)) {
|
|
100
|
-
this.onceListeners.set(eventName, []);
|
|
101
|
-
}
|
|
102
|
-
(_a = this.onceListeners.get(eventName)) === null || _a === void 0 ? void 0 : _a.push(callback);
|
|
103
|
-
}
|
|
104
|
-
request(topic, data) {
|
|
105
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
return yield new Promise((resolve) => {
|
|
107
|
-
let triggered = false;
|
|
108
|
-
const id = Math.random();
|
|
109
|
-
this.internalEmit(topic, id, data);
|
|
110
|
-
this.subscribe(topic, (_id, data) => {
|
|
111
|
-
if (triggered || (_id !== id && _id !== 0))
|
|
112
|
-
return;
|
|
113
|
-
triggered = true;
|
|
114
|
-
resolve(data);
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export function isFullscreen() {
|
|
2
|
-
return !!document.fullscreenElement;
|
|
3
|
-
}
|
|
4
|
-
export function triggerFullscreen(onStateChange, selector) {
|
|
5
|
-
document.addEventListener("fullscreenchange", () => {
|
|
6
|
-
onStateChange(isFullscreen());
|
|
7
|
-
});
|
|
8
|
-
try {
|
|
9
|
-
const ref = document.querySelector(selector || "#root");
|
|
10
|
-
if (!isFullscreen()) {
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
ref.requestFullscreen() || ref.webkitRequestFullscreen();
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
document.exitFullscreen() || document.webkitExitFullscreen();
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
console.error("Failed to enter fullscreen", error.message);
|
|
21
|
-
}
|
|
22
|
-
onStateChange(isFullscreen());
|
|
23
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import { GenericSchema } from "@supabase/supabase-js/dist/module/lib/types";
|
|
3
|
-
import { PostgrestQueryBuilder, PostgrestFilterBuilder } from "@supabase/postgrest-js";
|
|
4
|
-
import { PluginController, Tool, ToolInvocation } from "./PluginController";
|
|
5
|
-
import { LanguageLevel } from "../DifficultyConverter";
|
|
6
|
-
export declare class RimoriClient {
|
|
7
|
-
private static instance;
|
|
8
|
-
private superbase;
|
|
9
|
-
private plugin;
|
|
10
|
-
functions: SupabaseClient["functions"];
|
|
11
|
-
storage: SupabaseClient["storage"];
|
|
12
|
-
private constructor();
|
|
13
|
-
static getInstance(pluginController: PluginController): Promise<RimoriClient>;
|
|
14
|
-
from<TableName extends string & keyof GenericSchema['Tables'], Table extends GenericSchema['Tables'][TableName]>(relation: TableName): PostgrestQueryBuilder<GenericSchema, Table, GenericSchema, Table extends {
|
|
15
|
-
Relationships: infer R;
|
|
16
|
-
} ? R : unknown>;
|
|
17
|
-
/**
|
|
18
|
-
* Perform a function call.
|
|
19
|
-
*
|
|
20
|
-
* @param fn - The function name to call
|
|
21
|
-
* @param args - The arguments to pass to the function call
|
|
22
|
-
* @param options - Named parameters
|
|
23
|
-
* @param options.head - When set to `true`, `data` will not be returned.
|
|
24
|
-
* Useful if you only need the count.
|
|
25
|
-
* @param options.get - When set to `true`, the function will be called with
|
|
26
|
-
* read-only access mode.
|
|
27
|
-
* @param options.count - Count algorithm to use to count rows returned by the
|
|
28
|
-
* function. Only applicable for [set-returning
|
|
29
|
-
* functions](https://www.postgresql.org/docs/current/functions-srf.html).
|
|
30
|
-
*
|
|
31
|
-
* `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
|
|
32
|
-
* hood.
|
|
33
|
-
*
|
|
34
|
-
* `"planned"`: Approximated but fast count algorithm. Uses the Postgres
|
|
35
|
-
* statistics under the hood.
|
|
36
|
-
*
|
|
37
|
-
* `"estimated"`: Uses exact count for low numbers and planned count for high
|
|
38
|
-
* numbers.
|
|
39
|
-
*/
|
|
40
|
-
rpc<FnName extends string & keyof GenericSchema['Functions'], Fn extends GenericSchema['Functions'][FnName]>(fn: FnName, args?: Fn['Args'], options?: {
|
|
41
|
-
head?: boolean;
|
|
42
|
-
get?: boolean;
|
|
43
|
-
count?: 'exact' | 'planned' | 'estimated';
|
|
44
|
-
}): PostgrestFilterBuilder<GenericSchema, Fn['Returns'] extends any[] ? Fn['Returns'][number] extends Record<string, unknown> ? Fn['Returns'][number] : never : never, Fn['Returns'], FnName, null>;
|
|
45
|
-
subscribe(eventName: string, callback: (_id: number, data: any) => void): void;
|
|
46
|
-
request<T>(eventName: string, data: any): Promise<T>;
|
|
47
|
-
emit(eventName: string, data: any): void;
|
|
48
|
-
/**
|
|
49
|
-
* Get the settings for the plugin. T can be any type of settings, UserSettings or SystemSettings.
|
|
50
|
-
* @param defaultSettings The default settings to use if no settings are found.
|
|
51
|
-
* @param genericSettings The type of settings to get.
|
|
52
|
-
* @returns The settings for the plugin.
|
|
53
|
-
*/
|
|
54
|
-
getSettings<T>(defaultSettings: T, genericSettings?: "user" | "system"): Promise<T>;
|
|
55
|
-
setSettings(settings: any, genericSettings?: "user" | "system"): Promise<void>;
|
|
56
|
-
getAIResponse(messages: {
|
|
57
|
-
role: string;
|
|
58
|
-
content: string;
|
|
59
|
-
}[]): Promise<string>;
|
|
60
|
-
getAIResponseStream(messages: {
|
|
61
|
-
role: string;
|
|
62
|
-
content: string;
|
|
63
|
-
}[], onMessage: (id: string, message: string, finished: boolean, toolInvocations?: ToolInvocation[]) => void, tools?: Tool[]): Promise<void>;
|
|
64
|
-
getVoiceResponse(text: string, voice?: string, speed?: number, language?: string): Promise<Blob>;
|
|
65
|
-
getVoiceToTextResponse(file: Blob): Promise<string>;
|
|
66
|
-
}
|
|
67
|
-
export interface UserSettings {
|
|
68
|
-
motherTongue: string;
|
|
69
|
-
languageLevel: LanguageLevel;
|
|
70
|
-
}
|
|
71
|
-
export interface SystemSettings {
|
|
72
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export class RimoriClient {
|
|
11
|
-
constructor(pluginController, superbase) {
|
|
12
|
-
this.superbase = superbase;
|
|
13
|
-
this.plugin = pluginController;
|
|
14
|
-
this.functions = this.superbase.functions;
|
|
15
|
-
this.storage = this.superbase.storage;
|
|
16
|
-
}
|
|
17
|
-
static getInstance(pluginController) {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
if (!RimoriClient.instance) {
|
|
20
|
-
const superbase = yield pluginController.getClient();
|
|
21
|
-
RimoriClient.instance = new RimoriClient(pluginController, superbase);
|
|
22
|
-
}
|
|
23
|
-
return RimoriClient.instance;
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
from(relation) {
|
|
27
|
-
return this.superbase.from(relation);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Perform a function call.
|
|
31
|
-
*
|
|
32
|
-
* @param fn - The function name to call
|
|
33
|
-
* @param args - The arguments to pass to the function call
|
|
34
|
-
* @param options - Named parameters
|
|
35
|
-
* @param options.head - When set to `true`, `data` will not be returned.
|
|
36
|
-
* Useful if you only need the count.
|
|
37
|
-
* @param options.get - When set to `true`, the function will be called with
|
|
38
|
-
* read-only access mode.
|
|
39
|
-
* @param options.count - Count algorithm to use to count rows returned by the
|
|
40
|
-
* function. Only applicable for [set-returning
|
|
41
|
-
* functions](https://www.postgresql.org/docs/current/functions-srf.html).
|
|
42
|
-
*
|
|
43
|
-
* `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
|
|
44
|
-
* hood.
|
|
45
|
-
*
|
|
46
|
-
* `"planned"`: Approximated but fast count algorithm. Uses the Postgres
|
|
47
|
-
* statistics under the hood.
|
|
48
|
-
*
|
|
49
|
-
* `"estimated"`: Uses exact count for low numbers and planned count for high
|
|
50
|
-
* numbers.
|
|
51
|
-
*/
|
|
52
|
-
rpc(fn, args = {}, options = {}) {
|
|
53
|
-
return this.superbase.rpc(fn, args, options);
|
|
54
|
-
}
|
|
55
|
-
subscribe(eventName, callback) {
|
|
56
|
-
this.plugin.subscribe(eventName, callback);
|
|
57
|
-
}
|
|
58
|
-
request(eventName, data) {
|
|
59
|
-
return this.plugin.request(eventName, data);
|
|
60
|
-
}
|
|
61
|
-
emit(eventName, data) {
|
|
62
|
-
this.plugin.emit(eventName, data);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Get the settings for the plugin. T can be any type of settings, UserSettings or SystemSettings.
|
|
66
|
-
* @param defaultSettings The default settings to use if no settings are found.
|
|
67
|
-
* @param genericSettings The type of settings to get.
|
|
68
|
-
* @returns The settings for the plugin.
|
|
69
|
-
*/
|
|
70
|
-
getSettings(defaultSettings, genericSettings) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
const response = yield this.plugin.request("get_settings", { genericSettings });
|
|
73
|
-
if (response === null) {
|
|
74
|
-
this.setSettings(defaultSettings, genericSettings);
|
|
75
|
-
return defaultSettings;
|
|
76
|
-
//if the settings are not the same, merge the settings
|
|
77
|
-
}
|
|
78
|
-
else if (Object.keys(response).length !== Object.keys(defaultSettings).length) {
|
|
79
|
-
const existingKeys = Object.fromEntries(Object.entries(response).filter(([k]) => k in defaultSettings));
|
|
80
|
-
const mergedSettings = Object.assign(Object.assign({}, defaultSettings), existingKeys);
|
|
81
|
-
console.warn("Settings mismatch", { response, defaultSettings, mergedSettings });
|
|
82
|
-
this.setSettings(mergedSettings, genericSettings);
|
|
83
|
-
return mergedSettings;
|
|
84
|
-
}
|
|
85
|
-
return response;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
setSettings(settings, genericSettings) {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
yield this.plugin.request("set_settings", { settings, genericSettings });
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
getAIResponse(messages) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
return this.plugin.request("getAIResponse", messages);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
getAIResponseStream(messages, onMessage, tools) {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
throw new Error("Not implemented");
|
|
101
|
-
// let triggered = false;
|
|
102
|
-
// console.log("getAIResponseStream", messages);
|
|
103
|
-
// const id = Math.random();
|
|
104
|
-
// this.internalEmit("getAIResponseStream", id, { messages, tools: tools || [] });
|
|
105
|
-
// this.subscribe("getAIResponseStream", (_id: number, data: { id: string, response: string, finished: boolean, toolInvocations?: ToolInvocation[] }) => {
|
|
106
|
-
// if (triggered || (_id !== id && _id !== 0)) return;
|
|
107
|
-
// triggered = data.finished;
|
|
108
|
-
// onMessage(data.id, data.response, data.finished, data.toolInvocations);
|
|
109
|
-
// })
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
getVoiceResponse(text, voice = "alloy", speed = 1, language) {
|
|
113
|
-
return this.plugin.request("getVoiceResponse", { text, voice, speed, language });
|
|
114
|
-
}
|
|
115
|
-
getVoiceToTextResponse(file) {
|
|
116
|
-
return this.plugin.request("getSTTResponse", file);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function setTheme(): void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function setTheme() {
|
|
2
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
3
|
-
let theme = urlParams.get('theme');
|
|
4
|
-
const isSidebar = urlParams.get('applicationMode') === "sidebar";
|
|
5
|
-
if (!theme || theme === 'system') {
|
|
6
|
-
theme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
7
|
-
}
|
|
8
|
-
document.documentElement.classList.add("dark:text-gray-200", "bg-white");
|
|
9
|
-
if (theme === 'dark') {
|
|
10
|
-
document.documentElement.classList.add('dark', isSidebar ? "bg-gray-920" : "bg-gray-950");
|
|
11
|
-
document.documentElement.style.background = isSidebar ? "rgb(6, 12, 30)" : "rgb(3, 7, 18)";
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
type Condition = {
|
|
2
|
-
column?: string;
|
|
3
|
-
operator?: string;
|
|
4
|
-
value?: any;
|
|
5
|
-
AND?: Condition[];
|
|
6
|
-
OR?: Condition[];
|
|
7
|
-
};
|
|
8
|
-
export declare class WhereClauseBuilder {
|
|
9
|
-
conditions: Condition[];
|
|
10
|
-
constructor();
|
|
11
|
-
eq(column: string, value: any): WhereClauseBuilder;
|
|
12
|
-
neq(column: string, value: any): WhereClauseBuilder;
|
|
13
|
-
gt(column: string, value: any): WhereClauseBuilder;
|
|
14
|
-
lt(column: string, value: any): WhereClauseBuilder;
|
|
15
|
-
gte(column: string, value: any): WhereClauseBuilder;
|
|
16
|
-
lte(column: string, value: any): WhereClauseBuilder;
|
|
17
|
-
like(column: string, pattern: string): WhereClauseBuilder;
|
|
18
|
-
in(column: string, values: any[]): WhereClauseBuilder;
|
|
19
|
-
isNull(column: string): WhereClauseBuilder;
|
|
20
|
-
isNotNull(column: string): WhereClauseBuilder;
|
|
21
|
-
between(column: string, start: any, end: any): WhereClauseBuilder;
|
|
22
|
-
build(): Condition;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
export class WhereClauseBuilder {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.conditions = [];
|
|
4
|
-
}
|
|
5
|
-
// Add AND condition
|
|
6
|
-
// and(): WhereClauseBuilder {
|
|
7
|
-
// const builder = new WhereClauseBuilder();
|
|
8
|
-
// this.conditions.push({ AND: builder.conditions });
|
|
9
|
-
// return builder;
|
|
10
|
-
// }
|
|
11
|
-
// Add OR condition
|
|
12
|
-
// or(): WhereClauseBuilder {
|
|
13
|
-
// const builder = new WhereClauseBuilder();
|
|
14
|
-
// this.conditions.push({ OR: builder.conditions });
|
|
15
|
-
// return builder;
|
|
16
|
-
// }
|
|
17
|
-
// Equality check
|
|
18
|
-
eq(column, value) {
|
|
19
|
-
this.conditions.push({ column, operator: "eq", value });
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
// Not equal check
|
|
23
|
-
neq(column, value) {
|
|
24
|
-
this.conditions.push({ column, operator: "neq", value });
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
// Greater than
|
|
28
|
-
gt(column, value) {
|
|
29
|
-
this.conditions.push({ column, operator: "gt", value });
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
// Less than
|
|
33
|
-
lt(column, value) {
|
|
34
|
-
this.conditions.push({ column, operator: "lt", value });
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
// Greater than or equal to
|
|
38
|
-
gte(column, value) {
|
|
39
|
-
this.conditions.push({ column, operator: "gte", value });
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
// Less than or equal to
|
|
43
|
-
lte(column, value) {
|
|
44
|
-
this.conditions.push({ column, operator: "lte", value });
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
// LIKE (pattern match)
|
|
48
|
-
like(column, pattern) {
|
|
49
|
-
this.conditions.push({ column, operator: "like", value: pattern });
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
// IN (for multiple values)
|
|
53
|
-
in(column, values) {
|
|
54
|
-
this.conditions.push({ column, operator: "in", value: values });
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
// IS NULL
|
|
58
|
-
isNull(column) {
|
|
59
|
-
this.conditions.push({ column, operator: "is", value: null });
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
// IS NOT NULL
|
|
63
|
-
isNotNull(column) {
|
|
64
|
-
this.conditions.push({ column, operator: "is", value: { not: null } });
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
// BETWEEN (for range checking)
|
|
68
|
-
between(column, start, end) {
|
|
69
|
-
this.conditions.push({ column, operator: "between", value: [start, end] });
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
// Build and return the final condition object
|
|
73
|
-
build() {
|
|
74
|
-
// if (this.conditions.length === 1) {
|
|
75
|
-
// return this.conditions; // Direct return if only one condition
|
|
76
|
-
// }
|
|
77
|
-
return { AND: this.conditions }; // If multiple conditions, combine using AND
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
type Listener<T = any> = (event: T) => void;
|
|
2
|
-
export declare class EventEmitter {
|
|
3
|
-
private events;
|
|
4
|
-
constructor();
|
|
5
|
-
on<T = any>(eventName: string, listener: Listener<T>): void;
|
|
6
|
-
once<T = any>(eventName: string, listener: Listener<T>): void;
|
|
7
|
-
removeListener<T = any>(eventName: string, listener: Listener<T>): void;
|
|
8
|
-
emit<T = any>(eventName: string, data?: T): void;
|
|
9
|
-
}
|
|
10
|
-
export declare const EmitterSingleton: EventEmitter;
|
|
11
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export class EventEmitter {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.events = new Map();
|
|
4
|
-
this.on = this.on.bind(this);
|
|
5
|
-
this.once = this.once.bind(this);
|
|
6
|
-
this.emit = this.emit.bind(this);
|
|
7
|
-
this.removeListener = this.removeListener.bind(this);
|
|
8
|
-
}
|
|
9
|
-
// Subscribe to an event
|
|
10
|
-
on(eventName, listener) {
|
|
11
|
-
if (!this.events.has(eventName)) {
|
|
12
|
-
this.events.set(eventName, []);
|
|
13
|
-
}
|
|
14
|
-
this.events.get(eventName).push(listener);
|
|
15
|
-
}
|
|
16
|
-
// Subscribe to an event for a single invocation
|
|
17
|
-
once(eventName, listener) {
|
|
18
|
-
const onceWrapper = (event) => {
|
|
19
|
-
this.removeListener(eventName, onceWrapper);
|
|
20
|
-
listener(event);
|
|
21
|
-
};
|
|
22
|
-
this.on(eventName, onceWrapper);
|
|
23
|
-
}
|
|
24
|
-
// Remove a specific listener
|
|
25
|
-
removeListener(eventName, listener) {
|
|
26
|
-
const listeners = this.events.get(eventName);
|
|
27
|
-
if (!listeners)
|
|
28
|
-
return;
|
|
29
|
-
this.events.set(eventName, listeners.filter((l) => l !== listener));
|
|
30
|
-
}
|
|
31
|
-
// Emit an event
|
|
32
|
-
emit(eventName, data) {
|
|
33
|
-
const listeners = this.events.get(eventName);
|
|
34
|
-
console.log("emit", eventName, data, listeners);
|
|
35
|
-
if (!listeners)
|
|
36
|
-
return;
|
|
37
|
-
listeners.forEach((listener) => listener(data));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
const emitter = new EventEmitter();
|
|
41
|
-
export const EmitterSingleton = emitter;
|