@rimori/react-client 0.1.0 → 0.1.1
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/dist/{react-client/src/components → components}/ContextMenu.js +1 -2
- package/dist/components/ai/Assistant.js +1 -1
- package/dist/components/ai/Avatar.d.ts +1 -1
- package/dist/components/ai/Avatar.js +1 -1
- package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +1 -1
- package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +2 -2
- package/dist/components/audio/Playbutton.js +10 -8
- package/dist/hooks/I18nHooks.d.ts +1 -1
- package/dist/hooks/UseChatHook.d.ts +2 -2
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/providers/PluginProvider.d.ts +2 -1
- package/dist/providers/PluginProvider.js +9 -8
- package/dist/{react-client/src/utils → utils}/FullscreenUtils.js +2 -2
- package/package.json +1 -1
- package/src/components/ContextMenu.tsx +2 -2
- package/src/index.ts +11 -0
- package/src/plugin/ThemeSetter.ts +1 -1
- package/src/providers/PluginProvider.tsx +10 -9
- package/src/utils/FullscreenUtils.ts +5 -5
- package/tsconfig.json +6 -12
- package/dist/components/components/ContextMenu.d.ts +0 -10
- package/dist/components/components/ContextMenu.js +0 -135
- package/dist/react-client/src/components/MarkdownEditor.d.ts +0 -8
- package/dist/react-client/src/components/MarkdownEditor.js +0 -48
- package/dist/react-client/src/components/Spinner.d.ts +0 -8
- package/dist/react-client/src/components/Spinner.js +0 -4
- package/dist/react-client/src/components/ai/Assistant.d.ts +0 -9
- package/dist/react-client/src/components/ai/Assistant.js +0 -58
- package/dist/react-client/src/components/ai/Avatar.d.ts +0 -14
- package/dist/react-client/src/components/ai/Avatar.js +0 -59
- package/dist/react-client/src/components/ai/EmbeddedAssistent/AudioInputField.d.ts +0 -7
- package/dist/react-client/src/components/ai/EmbeddedAssistent/AudioInputField.js +0 -37
- package/dist/react-client/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.d.ts +0 -8
- package/dist/react-client/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +0 -79
- package/dist/react-client/src/components/ai/EmbeddedAssistent/TTS/MessageSender.d.ts +0 -19
- package/dist/react-client/src/components/ai/EmbeddedAssistent/TTS/MessageSender.js +0 -91
- package/dist/react-client/src/components/ai/EmbeddedAssistent/TTS/Player.d.ts +0 -27
- package/dist/react-client/src/components/ai/EmbeddedAssistent/TTS/Player.js +0 -185
- package/dist/react-client/src/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +0 -11
- package/dist/react-client/src/components/ai/EmbeddedAssistent/VoiceRecoder.js +0 -95
- package/dist/react-client/src/components/ai/utils.d.ts +0 -6
- package/dist/react-client/src/components/ai/utils.js +0 -13
- package/dist/react-client/src/components/audio/Playbutton.d.ts +0 -15
- package/dist/react-client/src/components/audio/Playbutton.js +0 -82
- package/dist/react-client/src/components/components/ContextMenu.d.ts +0 -10
- package/dist/react-client/src/components/components/ContextMenu.js +0 -135
- package/dist/react-client/src/hooks/I18nHooks.d.ts +0 -11
- package/dist/react-client/src/hooks/I18nHooks.js +0 -25
- package/dist/react-client/src/hooks/UseChatHook.d.ts +0 -10
- package/dist/react-client/src/hooks/UseChatHook.js +0 -29
- package/dist/react-client/src/plugin/ThemeSetter.d.ts +0 -2
- package/dist/react-client/src/plugin/ThemeSetter.js +0 -19
- package/dist/react-client/src/providers/PluginProvider.d.ts +0 -12
- package/dist/react-client/src/providers/PluginProvider.js +0 -142
- package/dist/react-client/src/utils/PluginUtils.d.ts +0 -2
- package/dist/react-client/src/utils/PluginUtils.js +0 -23
- package/dist/rimori-client/src/cli/types/DatabaseTypes.d.ts +0 -103
- package/dist/rimori-client/src/cli/types/DatabaseTypes.js +0 -2
- package/dist/rimori-client/src/controller/AIController.d.ts +0 -15
- package/dist/rimori-client/src/controller/AIController.js +0 -255
- package/dist/rimori-client/src/controller/AccomplishmentController.d.ts +0 -38
- package/dist/rimori-client/src/controller/AccomplishmentController.js +0 -112
- package/dist/rimori-client/src/controller/AudioController.d.ts +0 -37
- package/dist/rimori-client/src/controller/AudioController.js +0 -68
- package/dist/rimori-client/src/controller/ExerciseController.d.ts +0 -54
- package/dist/rimori-client/src/controller/ExerciseController.js +0 -74
- package/dist/rimori-client/src/controller/ObjectController.d.ts +0 -42
- package/dist/rimori-client/src/controller/ObjectController.js +0 -76
- package/dist/rimori-client/src/controller/SettingsController.d.ts +0 -79
- package/dist/rimori-client/src/controller/SettingsController.js +0 -118
- package/dist/rimori-client/src/controller/SharedContentController.d.ts +0 -106
- package/dist/rimori-client/src/controller/SharedContentController.js +0 -285
- package/dist/rimori-client/src/controller/TranslationController.d.ts +0 -38
- package/dist/rimori-client/src/controller/TranslationController.js +0 -106
- package/dist/rimori-client/src/controller/VoiceController.d.ts +0 -9
- package/dist/rimori-client/src/controller/VoiceController.js +0 -37
- package/dist/rimori-client/src/fromRimori/EventBus.d.ts +0 -101
- package/dist/rimori-client/src/fromRimori/EventBus.js +0 -263
- package/dist/rimori-client/src/fromRimori/PluginTypes.d.ts +0 -174
- package/dist/rimori-client/src/fromRimori/PluginTypes.js +0 -1
- package/dist/rimori-client/src/index.d.ts +0 -11
- package/dist/rimori-client/src/index.js +0 -10
- package/dist/rimori-client/src/plugin/CommunicationHandler.d.ts +0 -48
- package/dist/rimori-client/src/plugin/CommunicationHandler.js +0 -234
- package/dist/rimori-client/src/plugin/Logger.d.ts +0 -73
- package/dist/rimori-client/src/plugin/Logger.js +0 -308
- package/dist/rimori-client/src/plugin/RimoriClient.d.ts +0 -258
- package/dist/rimori-client/src/plugin/RimoriClient.js +0 -375
- package/dist/rimori-client/src/plugin/StandaloneClient.d.ts +0 -17
- package/dist/rimori-client/src/plugin/StandaloneClient.js +0 -115
- package/dist/rimori-client/src/utils/difficultyConverter.d.ts +0 -4
- package/dist/rimori-client/src/utils/difficultyConverter.js +0 -10
- package/dist/rimori-client/src/utils/endpoint.d.ts +0 -2
- package/dist/rimori-client/src/utils/endpoint.js +0 -2
- package/dist/utils/PluginUtils.d.ts +0 -2
- package/dist/utils/PluginUtils.js +0 -23
- package/index.ts +0 -6
- /package/dist/{react-client/src/components → components}/ContextMenu.d.ts +0 -0
- /package/dist/{react-client/plugin → plugin}/ThemeSetter.d.ts +0 -0
- /package/dist/{react-client/plugin → plugin}/ThemeSetter.js +0 -0
- /package/dist/{react-client/src/utils → utils}/FullscreenUtils.d.ts +0 -0
|
@@ -1,263 +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 EventBusHandler {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.listeners = new Map();
|
|
13
|
-
this.responseResolvers = new Map();
|
|
14
|
-
this.debugEnabled = false;
|
|
15
|
-
this.evName = "";
|
|
16
|
-
//private constructor
|
|
17
|
-
}
|
|
18
|
-
static getInstance(name) {
|
|
19
|
-
if (!EventBusHandler.instance) {
|
|
20
|
-
EventBusHandler.instance = new EventBusHandler();
|
|
21
|
-
EventBusHandler.instance.on("global.system.requestDebug", () => {
|
|
22
|
-
EventBusHandler.instance.debugEnabled = true;
|
|
23
|
-
console.log(`[${EventBusHandler.instance.evName}] Debug mode enabled. Make sure debugging messages are enabled in the browser console.`);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
if (name && EventBusHandler.instance.evName === "") {
|
|
27
|
-
EventBusHandler.instance.evName = name;
|
|
28
|
-
}
|
|
29
|
-
return EventBusHandler.instance;
|
|
30
|
-
}
|
|
31
|
-
createEvent(sender, topic, data, eventId) {
|
|
32
|
-
const generatedEventId = eventId || Math.floor(Math.random() * 10000000000);
|
|
33
|
-
return {
|
|
34
|
-
eventId: generatedEventId,
|
|
35
|
-
timestamp: new Date().toISOString(),
|
|
36
|
-
sender,
|
|
37
|
-
topic,
|
|
38
|
-
data,
|
|
39
|
-
debug: this.debugEnabled,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Emits an event to the event bus. Can be a new event or a response to a request.
|
|
44
|
-
* @param sender - The sender of the event.
|
|
45
|
-
* @param topic - The topic of the event.
|
|
46
|
-
* @param data - The data of the event.
|
|
47
|
-
* @param eventId - The event id of the event.
|
|
48
|
-
*
|
|
49
|
-
* The topic format is: **pluginId.area.action**
|
|
50
|
-
*
|
|
51
|
-
* Example topics:
|
|
52
|
-
* - pl1234.card.requestHard
|
|
53
|
-
* - pl1234.card.requestNew
|
|
54
|
-
* - pl1234.card.requestAll
|
|
55
|
-
* - pl1234.card.create
|
|
56
|
-
* - pl1234.card.update
|
|
57
|
-
* - pl1234.card.delete
|
|
58
|
-
* - pl1234.card.triggerBackup
|
|
59
|
-
*/
|
|
60
|
-
emit(sender, topic, data, eventId) {
|
|
61
|
-
this.emitInternal(sender, topic, data || {}, eventId);
|
|
62
|
-
}
|
|
63
|
-
emitInternal(sender, topic, data, eventId, skipResponseTrigger = false) {
|
|
64
|
-
if (!this.validateTopic(topic)) {
|
|
65
|
-
this.logAndThrowError(false, `Invalid topic: ` + topic);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const event = this.createEvent(sender, topic, data, eventId);
|
|
69
|
-
const handlers = this.getMatchingHandlers(event.topic);
|
|
70
|
-
handlers.forEach(handler => {
|
|
71
|
-
if (handler.ignoreSender && handler.ignoreSender.includes(sender)) {
|
|
72
|
-
// console.log("ignore event as its in the ignoreSender list", { event, ignoreList: handler.ignoreSender });
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
handler.handler(event);
|
|
76
|
-
});
|
|
77
|
-
this.logIfDebug(`Emitting event to ` + topic, event);
|
|
78
|
-
if (handlers.size === 0) {
|
|
79
|
-
this.logAndThrowError(false, `No handlers found for topic: ` + topic);
|
|
80
|
-
}
|
|
81
|
-
// If it's a response to a request
|
|
82
|
-
if (eventId && this.responseResolvers.has(eventId) && !skipResponseTrigger) {
|
|
83
|
-
// console.log("[Rimori] Resolving response to request: " + eventId, event.data);
|
|
84
|
-
this.responseResolvers.get(eventId)(event);
|
|
85
|
-
this.responseResolvers.delete(eventId);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Subscribes to an event on the event bus.
|
|
90
|
-
* @param topics - The topic of the event.
|
|
91
|
-
* @param handler - The handler to be called when the event is emitted.
|
|
92
|
-
* @param ignoreSender - The senders to ignore.
|
|
93
|
-
* @returns An EventListener object containing an off() method to unsubscribe the listeners.
|
|
94
|
-
*/
|
|
95
|
-
on(topics, handler, ignoreSender = []) {
|
|
96
|
-
const ids = this.toArray(topics).map(topic => {
|
|
97
|
-
this.logIfDebug(`Subscribing to ` + topic, { ignoreSender });
|
|
98
|
-
if (!this.validateTopic(topic)) {
|
|
99
|
-
this.logAndThrowError(true, `Invalid topic: ` + topic);
|
|
100
|
-
}
|
|
101
|
-
if (!this.listeners.has(topic)) {
|
|
102
|
-
this.listeners.set(topic, new Set());
|
|
103
|
-
}
|
|
104
|
-
const id = Math.floor(Math.random() * 10000000000);
|
|
105
|
-
// Type assertion to handle the generic type mismatch
|
|
106
|
-
const eventHandler = handler;
|
|
107
|
-
this.listeners.get(topic).add({ id, handler: eventHandler, ignoreSender });
|
|
108
|
-
this.logIfDebug(`Subscribed to ` + topic, { listenerId: id, ignoreSender });
|
|
109
|
-
return btoa(JSON.stringify({ topic, id }));
|
|
110
|
-
});
|
|
111
|
-
return {
|
|
112
|
-
off: () => this.off(ids)
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Subscribes to an event, processes the data and emits a response on the event bus.
|
|
117
|
-
* @param sender - The sender of the event.
|
|
118
|
-
* @param topic - The topic of the event.
|
|
119
|
-
* @param handler - The handler to be called when the event is received. The handler returns the data to be emitted. Can be a static object or a function.
|
|
120
|
-
* @returns An EventListener object containing an off() method to unsubscribe the listeners.
|
|
121
|
-
*/
|
|
122
|
-
respond(sender, topic, handler) {
|
|
123
|
-
const topics = Array.isArray(topic) ? topic : [topic];
|
|
124
|
-
const listeners = topics.map(topic => {
|
|
125
|
-
const blackListedEventIds = [];
|
|
126
|
-
//To allow event communication inside the same plugin the sender needs to be ignored but the events still need to be checked for the same event just reaching the subscriber to prevent infinite loops
|
|
127
|
-
const finalIgnoreSender = !topic.startsWith("self.") ? [sender] : [];
|
|
128
|
-
const listener = this.on(topic, (data) => __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
if (blackListedEventIds.includes(data.eventId)) {
|
|
130
|
-
// console.log("BLACKLISTED EVENT ID", data.eventId);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
blackListedEventIds.push(data.eventId);
|
|
134
|
-
if (blackListedEventIds.length > 20) {
|
|
135
|
-
blackListedEventIds.shift();
|
|
136
|
-
}
|
|
137
|
-
const response = typeof handler === "function" ? yield handler(data) : handler;
|
|
138
|
-
this.emit(sender, topic, response, data.eventId);
|
|
139
|
-
}), finalIgnoreSender);
|
|
140
|
-
this.logIfDebug(`Added respond listener ` + sender + " to topic " + topic, { listener, sender });
|
|
141
|
-
return {
|
|
142
|
-
off: () => listener.off()
|
|
143
|
-
};
|
|
144
|
-
});
|
|
145
|
-
return {
|
|
146
|
-
off: () => listeners.forEach(listener => listener.off())
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Subscribes to an event on the event bus. The handler will be called once and then removed.
|
|
151
|
-
* @param topic - The topic of the event.
|
|
152
|
-
* @param handler - The handler to be called when the event is emitted.
|
|
153
|
-
*/
|
|
154
|
-
once(topic, handler) {
|
|
155
|
-
if (!this.validateTopic(topic)) {
|
|
156
|
-
this.logAndThrowError(false, `Invalid topic: ` + topic);
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
let listener;
|
|
160
|
-
const wrapper = (event) => {
|
|
161
|
-
handler(event);
|
|
162
|
-
listener === null || listener === void 0 ? void 0 : listener.off();
|
|
163
|
-
};
|
|
164
|
-
listener = this.on(topic, wrapper);
|
|
165
|
-
this.logIfDebug(`Added once listener ` + topic, { listener, topic });
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Unsubscribes from an event on the event bus.
|
|
169
|
-
* @param listenerIds - The ids of the listeners to unsubscribe from.
|
|
170
|
-
*/
|
|
171
|
-
off(listenerIds) {
|
|
172
|
-
this.toArray(listenerIds).forEach(fullId => {
|
|
173
|
-
const { topic, id } = JSON.parse(atob(fullId));
|
|
174
|
-
const listeners = this.listeners.get(topic) || new Set();
|
|
175
|
-
listeners.forEach(listener => {
|
|
176
|
-
if (listener.id === Number(id)) {
|
|
177
|
-
listeners.delete(listener);
|
|
178
|
-
this.logIfDebug(`Removed listener ` + fullId, { topic, listenerId: id });
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
toArray(item) {
|
|
184
|
-
return Array.isArray(item) ? item : [item];
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Requests data from the event bus.
|
|
188
|
-
* @param sender - The sender of the event.
|
|
189
|
-
* @param topic - The topic of the event.
|
|
190
|
-
* @param data - The data of the event.
|
|
191
|
-
* @returns A promise that resolves to the event.
|
|
192
|
-
*/
|
|
193
|
-
request(sender, topic, data) {
|
|
194
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
if (!this.validateTopic(topic)) {
|
|
196
|
-
this.logAndThrowError(true, `Invalid topic: ` + topic);
|
|
197
|
-
}
|
|
198
|
-
const event = this.createEvent(sender, topic, data || {});
|
|
199
|
-
this.logIfDebug(`Requesting data from ` + topic, { event });
|
|
200
|
-
return new Promise(resolve => {
|
|
201
|
-
this.responseResolvers.set(event.eventId, (value) => resolve(value));
|
|
202
|
-
this.emitInternal(sender, topic, data || {}, event.eventId, true);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Gets the matching handlers for an event.
|
|
208
|
-
* @param topic - The topic of the event.
|
|
209
|
-
* @returns A set of handlers that match the event type.
|
|
210
|
-
*/
|
|
211
|
-
getMatchingHandlers(topic) {
|
|
212
|
-
const exact = this.listeners.get(topic) || new Set();
|
|
213
|
-
// Find wildcard matches
|
|
214
|
-
const wildcard = [...this.listeners.entries()]
|
|
215
|
-
.filter(([key]) => key.endsWith("*") && topic.startsWith(key.slice(0, -1)))
|
|
216
|
-
.flatMap(([_, handlers]) => [...handlers]);
|
|
217
|
-
return new Set([...exact, ...wildcard]);
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Validates the topic of an event.
|
|
221
|
-
* @param topic - The topic of the event.
|
|
222
|
-
* @returns True if the topic is valid, false otherwise.
|
|
223
|
-
*/
|
|
224
|
-
validateTopic(topic) {
|
|
225
|
-
// Split event type into parts
|
|
226
|
-
const parts = topic.split(".");
|
|
227
|
-
const [plugin, area, action] = parts;
|
|
228
|
-
if (parts.length !== 3) {
|
|
229
|
-
if (parts.length === 1 && plugin === "*") {
|
|
230
|
-
return true;
|
|
231
|
-
}
|
|
232
|
-
if (parts.length === 2 && plugin !== "*" && area === "*") {
|
|
233
|
-
return true;
|
|
234
|
-
}
|
|
235
|
-
this.logAndThrowError(false, `Event type must have 3 parts separated by dots. Received: ` + topic);
|
|
236
|
-
return false;
|
|
237
|
-
}
|
|
238
|
-
if (action === "*") {
|
|
239
|
-
return true;
|
|
240
|
-
}
|
|
241
|
-
// Validate action part
|
|
242
|
-
const validActions = ["request", "create", "update", "delete", "trigger"];
|
|
243
|
-
if (validActions.some(a => action.startsWith(a))) {
|
|
244
|
-
return true;
|
|
245
|
-
}
|
|
246
|
-
this.logAndThrowError(false, `Invalid event topic name. The action: ` + action + ". Must be or start with one of: " + validActions.join(", "));
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
logIfDebug(...args) {
|
|
250
|
-
if (this.debugEnabled) {
|
|
251
|
-
console.debug(`[${this.evName}] ` + args[0], ...args.slice(1));
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
logAndThrowError(throwError, ...args) {
|
|
255
|
-
const message = `[${this.evName}] ` + args[0];
|
|
256
|
-
console.error(message, ...args.slice(1));
|
|
257
|
-
if (throwError) {
|
|
258
|
-
throw new Error(message);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
EventBusHandler.instance = null;
|
|
263
|
-
export const EventBus = EventBusHandler.getInstance();
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
export type Plugin<T extends {} = {}> = Omit<RimoriPluginConfig<T>, 'context_menu_actions'> & {
|
|
2
|
-
version: string;
|
|
3
|
-
endpoint: string;
|
|
4
|
-
assetEndpoint: string;
|
|
5
|
-
context_menu_actions: MenuEntry[];
|
|
6
|
-
release_channel: "alpha" | "beta" | "stable";
|
|
7
|
-
};
|
|
8
|
-
export type ActivePlugin = Plugin<{
|
|
9
|
-
active?: boolean;
|
|
10
|
-
}>;
|
|
11
|
-
export interface PluginPage {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
url: string;
|
|
15
|
-
show: boolean;
|
|
16
|
-
description: string;
|
|
17
|
-
root: "vocabulary" | "grammar" | "reading" | "listening" | "watching" | "writing" | "speaking" | "other" | "community";
|
|
18
|
-
action?: {
|
|
19
|
-
key: string;
|
|
20
|
-
parameters: ObjectTool;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export interface SidebarPage {
|
|
24
|
-
id: string;
|
|
25
|
-
name: string;
|
|
26
|
-
description: string;
|
|
27
|
-
url: string;
|
|
28
|
-
icon: string;
|
|
29
|
-
}
|
|
30
|
-
export interface MenuEntry {
|
|
31
|
-
plugin_id: string;
|
|
32
|
-
action_key: string;
|
|
33
|
-
text: string;
|
|
34
|
-
icon?: React.ReactNode;
|
|
35
|
-
}
|
|
36
|
-
export type MainPanelAction = {
|
|
37
|
-
plugin_id: string;
|
|
38
|
-
action_key: string;
|
|
39
|
-
} & Record<string, string>;
|
|
40
|
-
export interface ContextMenuAction {
|
|
41
|
-
text: string;
|
|
42
|
-
plugin_id: string;
|
|
43
|
-
action_key: string;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Rimori plugin structure representing the complete configuration
|
|
47
|
-
* of a Rimori plugin with all metadata and configuration options.
|
|
48
|
-
*/
|
|
49
|
-
export interface RimoriPluginConfig<T extends {} = {}> {
|
|
50
|
-
id: string;
|
|
51
|
-
/**
|
|
52
|
-
* Basic information about the plugin including branding and core details.
|
|
53
|
-
*/
|
|
54
|
-
info: {
|
|
55
|
-
/** The display name of the plugin shown to users */
|
|
56
|
-
title: string;
|
|
57
|
-
/** Detailed description introducing the plugin */
|
|
58
|
-
description: string;
|
|
59
|
-
/** relative or absolute URL or path to the plugin's logo/icon image */
|
|
60
|
-
logo: string;
|
|
61
|
-
/** Optional website URL for the plugin's homepage or link to plugins owner for contributions */
|
|
62
|
-
website?: string;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Configuration for different types of pages.
|
|
66
|
-
*/
|
|
67
|
-
pages: {
|
|
68
|
-
/** Optional external URL where the plugin is hosted instead of the default CDN */
|
|
69
|
-
external_hosted_url?: string;
|
|
70
|
-
/** Array of main plugin pages that appear in the application's main navigation (can be disabled using the 'show' flag) */
|
|
71
|
-
main: (PluginPage & T)[];
|
|
72
|
-
/** Array of sidebar pages that appear in the sidebar for quick access (can be disabled using the 'show' flag) */
|
|
73
|
-
sidebar: (SidebarPage & T)[];
|
|
74
|
-
/** Optional path to the plugin's settings/configuration page */
|
|
75
|
-
settings?: string;
|
|
76
|
-
/** Optional array of event topics the plugin pages can listen to for cross-plugin communication */
|
|
77
|
-
topics?: string[];
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Context menu actions that the plugin registers to appear in right-click menus throughout the application.
|
|
81
|
-
*/
|
|
82
|
-
context_menu_actions: Omit<MenuEntry, "plugin_id">[];
|
|
83
|
-
/**
|
|
84
|
-
* Documentation paths for different types of plugin documentation.
|
|
85
|
-
*/
|
|
86
|
-
documentation: {
|
|
87
|
-
/** Path to the general overview documentation. It's shown upon installation of the plugin. */
|
|
88
|
-
overview_path: string;
|
|
89
|
-
/** Path to user-facing documentation and guides */
|
|
90
|
-
user_path: string;
|
|
91
|
-
/** Path to developer documentation for plugin development */
|
|
92
|
-
developer_path: string;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Configuration for the plugin's web worker if it uses background processing or exposes actions to other plugins.
|
|
96
|
-
*/
|
|
97
|
-
worker?: {
|
|
98
|
-
/** Relative path to the web worker JavaScript file. Mostly it's 'web-worker.js' which is located in the public folder. */
|
|
99
|
-
url: string;
|
|
100
|
-
/** Optional array of event topics the worker should listen to in addition to events having the pluginId in the topic. Can be a wildcard. Example: 'global.topic.*' or 'pluginId.*' */
|
|
101
|
-
topics?: string[];
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
export interface Tool {
|
|
105
|
-
name: string;
|
|
106
|
-
description: string;
|
|
107
|
-
parameters: {
|
|
108
|
-
name: string;
|
|
109
|
-
description: string;
|
|
110
|
-
type: "string" | "number" | "boolean";
|
|
111
|
-
}[];
|
|
112
|
-
execute?: (args: Record<string, any>) => Promise<unknown> | unknown | void;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* The tool definition structure is used for LLM function calling and plugin action parameters.
|
|
116
|
-
* It defines the schema for tools that can be used by Language Learning Models (LLMs)
|
|
117
|
-
* and plugin actions.
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* ```typescript
|
|
121
|
-
* const flashcardTool: Tool = {
|
|
122
|
-
* total_amount: {
|
|
123
|
-
* type: 'string',
|
|
124
|
-
* enum: ['default', '10', '20', '50'],
|
|
125
|
-
* description: 'Number of flashcards to practice'
|
|
126
|
-
* },
|
|
127
|
-
* deck: {
|
|
128
|
-
* type: 'string',
|
|
129
|
-
* enum: ['latest', 'random', 'oldest', 'mix', 'best_known'],
|
|
130
|
-
* description: 'Type of deck to practice'
|
|
131
|
-
* }
|
|
132
|
-
* };
|
|
133
|
-
* ```
|
|
134
|
-
*
|
|
135
|
-
*/
|
|
136
|
-
export type ObjectTool = {
|
|
137
|
-
[key: string]: ToolParameter;
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Parameter definition for LLM tools and plugin actions.
|
|
141
|
-
* Defines the structure, validation rules, and metadata for individual tool parameters.
|
|
142
|
-
* Used to create type-safe interfaces between LLMs, plugins, and the Rimori platform.
|
|
143
|
-
*/
|
|
144
|
-
interface ToolParameter {
|
|
145
|
-
/** The data type of the parameter - can be primitive, nested object, or array */
|
|
146
|
-
type: ToolParameterType;
|
|
147
|
-
/** Human-readable description of the parameter's purpose and usage */
|
|
148
|
-
description: string;
|
|
149
|
-
/** Optional array of allowed values for enumerated parameters */
|
|
150
|
-
enum?: string[];
|
|
151
|
-
/** Whether the parameter is optional */
|
|
152
|
-
optional?: boolean;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Union type defining all possible parameter types for LLM tools.
|
|
156
|
-
* Supports primitive types, nested objects for complex data structures,
|
|
157
|
-
* and arrays of objects for collections. The tuple notation [{}] indicates
|
|
158
|
-
* arrays of objects with a specific structure.
|
|
159
|
-
*
|
|
160
|
-
* @example Primitive: 'string' | 'number' | 'boolean'
|
|
161
|
-
* @example Nested object: { name: { type: 'string' }, age: { type: 'number' } }
|
|
162
|
-
* @example Array of objects: [{ id: { type: 'string' }, value: { type: 'number' } }]
|
|
163
|
-
*/
|
|
164
|
-
type ToolParameterType = PrimitiveType | {
|
|
165
|
-
[key: string]: ToolParameter;
|
|
166
|
-
} | [{
|
|
167
|
-
[key: string]: ToolParameter;
|
|
168
|
-
}];
|
|
169
|
-
/**
|
|
170
|
-
* Primitive data types supported by the LLM tool system.
|
|
171
|
-
* These align with JSON schema primitive types and TypeScript basic types.
|
|
172
|
-
*/
|
|
173
|
-
type PrimitiveType = 'string' | 'number' | 'boolean';
|
|
174
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from './plugin/CommunicationHandler';
|
|
2
|
-
export * from './cli/types/DatabaseTypes';
|
|
3
|
-
export * from './utils/difficultyConverter';
|
|
4
|
-
export * from './fromRimori/PluginTypes';
|
|
5
|
-
export * from './fromRimori/EventBus';
|
|
6
|
-
export * from './plugin/RimoriClient';
|
|
7
|
-
export * from './plugin/StandaloneClient';
|
|
8
|
-
export { AudioController } from './controller/AudioController';
|
|
9
|
-
export { Translator } from './controller/TranslationController';
|
|
10
|
-
export type { Message, ToolInvocation } from './controller/AIController';
|
|
11
|
-
export type { TOptions } from 'i18next';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Re-export everything
|
|
2
|
-
export * from './plugin/CommunicationHandler';
|
|
3
|
-
export * from './cli/types/DatabaseTypes';
|
|
4
|
-
export * from './utils/difficultyConverter';
|
|
5
|
-
export * from './fromRimori/PluginTypes';
|
|
6
|
-
export * from './fromRimori/EventBus';
|
|
7
|
-
export * from './plugin/RimoriClient';
|
|
8
|
-
export * from './plugin/StandaloneClient';
|
|
9
|
-
export { AudioController } from './controller/AudioController';
|
|
10
|
-
export { Translator } from './controller/TranslationController';
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
-
import { UserInfo } from '../controller/SettingsController';
|
|
3
|
-
import { ActivePlugin, Plugin } from '../fromRimori/PluginTypes';
|
|
4
|
-
export interface Guild {
|
|
5
|
-
id: string;
|
|
6
|
-
longTermGoalOverride: string;
|
|
7
|
-
allowUserPluginSettings: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface RimoriInfo {
|
|
10
|
-
url: string;
|
|
11
|
-
key: string;
|
|
12
|
-
backendUrl: string;
|
|
13
|
-
token: string;
|
|
14
|
-
expiration: Date;
|
|
15
|
-
tablePrefix: string;
|
|
16
|
-
pluginId: string;
|
|
17
|
-
guild: Guild;
|
|
18
|
-
installedPlugins: Plugin[];
|
|
19
|
-
profile: UserInfo;
|
|
20
|
-
mainPanelPlugin?: ActivePlugin;
|
|
21
|
-
sidePanelPlugin?: ActivePlugin;
|
|
22
|
-
}
|
|
23
|
-
export declare class RimoriCommunicationHandler {
|
|
24
|
-
private port;
|
|
25
|
-
private queryParams;
|
|
26
|
-
private supabase;
|
|
27
|
-
private rimoriInfo;
|
|
28
|
-
private pluginId;
|
|
29
|
-
private isMessageChannelReady;
|
|
30
|
-
private pendingRequests;
|
|
31
|
-
constructor(pluginId: string, standalone: boolean);
|
|
32
|
-
private initMessageChannel;
|
|
33
|
-
private sendHello;
|
|
34
|
-
getQueryParam(key: string): string | null;
|
|
35
|
-
getClient(): Promise<{
|
|
36
|
-
supabase: SupabaseClient;
|
|
37
|
-
info: RimoriInfo;
|
|
38
|
-
}>;
|
|
39
|
-
getToken(): Promise<string>;
|
|
40
|
-
/**
|
|
41
|
-
* Gets the Supabase URL.
|
|
42
|
-
* @returns The Supabase URL.
|
|
43
|
-
* @deprecated All endpoints should use the backend URL instead.
|
|
44
|
-
*/
|
|
45
|
-
getSupabaseUrl(): string;
|
|
46
|
-
getBackendUrl(): string;
|
|
47
|
-
getGlobalEventTopic(preliminaryTopic: string): string;
|
|
48
|
-
}
|