@rimori/client 1.1.9 → 1.2.0
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 +128 -45
- package/dist/cli/scripts/init/dev-registration.d.ts +35 -0
- package/dist/cli/scripts/init/dev-registration.js +175 -0
- package/dist/cli/scripts/init/env-setup.d.ts +9 -0
- package/dist/cli/scripts/init/env-setup.js +43 -0
- package/dist/cli/scripts/init/file-operations.d.ts +4 -0
- package/dist/cli/scripts/init/file-operations.js +51 -0
- package/dist/cli/scripts/init/html-cleaner.d.ts +4 -0
- package/dist/cli/scripts/init/html-cleaner.js +38 -0
- package/dist/cli/scripts/init/main.d.ts +2 -0
- package/dist/cli/scripts/init/main.js +159 -0
- package/dist/cli/scripts/init/package-setup.d.ts +32 -0
- package/dist/cli/scripts/init/package-setup.js +75 -0
- package/dist/cli/scripts/init/router-transformer.d.ts +6 -0
- package/dist/cli/scripts/init/router-transformer.js +254 -0
- package/dist/cli/scripts/init/tailwind-config.d.ts +4 -0
- package/dist/cli/scripts/init/tailwind-config.js +56 -0
- package/dist/cli/scripts/init/vite-config.d.ts +20 -0
- package/dist/cli/scripts/init/vite-config.js +54 -0
- package/dist/cli/scripts/release/release-config-upload.d.ts +7 -0
- package/dist/cli/scripts/release/release-config-upload.js +116 -0
- package/dist/cli/scripts/release/release-db-update.d.ts +6 -0
- package/dist/cli/scripts/release/release-db-update.js +100 -0
- package/dist/cli/scripts/release/release-file-upload.d.ts +6 -0
- package/dist/cli/scripts/release/release-file-upload.js +136 -0
- package/dist/cli/scripts/release/release.d.ts +23 -0
- package/dist/cli/scripts/release/release.js +70 -0
- package/dist/cli/types/DatabaseTypes.d.ts +103 -0
- package/dist/cli/types/DatabaseTypes.js +2 -0
- package/dist/components/ai/Assistant.js +4 -4
- package/dist/components/ai/Avatar.d.ts +3 -2
- package/dist/components/ai/Avatar.js +10 -5
- package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +1 -1
- package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +1 -0
- package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +12 -6
- package/dist/components/ai/utils.js +0 -1
- package/dist/components/audio/Playbutton.js +3 -3
- package/dist/{core → components}/components/ContextMenu.js +2 -2
- package/dist/components.d.ts +5 -5
- package/dist/components.js +5 -5
- package/dist/core/controller/AIController.d.ts +15 -0
- package/dist/core/controller/AIController.js +120 -0
- package/dist/{controller → core/controller}/ObjectController.d.ts +8 -0
- package/dist/{controller → core/controller}/SettingsController.d.ts +12 -4
- package/dist/{controller → core/controller}/SettingsController.js +0 -25
- package/dist/{controller → core/controller}/SharedContentController.d.ts +10 -19
- package/dist/{controller → core/controller}/SharedContentController.js +11 -11
- package/dist/core/core.d.ts +13 -0
- package/dist/core/core.js +8 -0
- package/dist/{plugin/fromRimori → fromRimori}/EventBus.d.ts +3 -3
- package/dist/{plugin/fromRimori → fromRimori}/EventBus.js +25 -8
- package/dist/fromRimori/PluginTypes.d.ts +171 -0
- package/dist/hooks/UseChatHook.d.ts +2 -1
- package/dist/hooks/UseChatHook.js +3 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -3
- package/dist/plugin/AccomplishmentHandler.d.ts +1 -1
- package/dist/plugin/AccomplishmentHandler.js +1 -1
- package/dist/plugin/PluginController.d.ts +16 -3
- package/dist/plugin/PluginController.js +24 -18
- package/dist/plugin/RimoriClient.d.ts +22 -17
- package/dist/plugin/RimoriClient.js +35 -25
- package/dist/plugin/StandaloneClient.js +11 -8
- package/dist/plugin/ThemeSetter.d.ts +1 -0
- package/dist/plugin/ThemeSetter.js +9 -6
- package/dist/providers/PluginProvider.d.ts +3 -0
- package/dist/providers/PluginProvider.js +4 -4
- package/dist/utils/Language.d.ts +2 -1
- package/dist/utils/Language.js +4 -2
- package/dist/utils/difficultyConverter.js +1 -1
- package/dist/utils/endpoint.d.ts +2 -0
- package/dist/utils/endpoint.js +2 -0
- package/dist/worker/WorkerSetup.js +3 -1
- package/example/docs/devdocs.md +231 -0
- package/example/docs/overview.md +29 -0
- package/example/docs/userdocs.md +123 -0
- package/example/rimori.config.ts +89 -0
- package/example/worker/vite.config.ts +23 -0
- package/example/worker/worker.ts +11 -0
- package/package.json +15 -9
- package/src/cli/scripts/init/dev-registration.ts +193 -0
- package/src/cli/scripts/init/env-setup.ts +44 -0
- package/src/cli/scripts/init/file-operations.ts +58 -0
- package/src/cli/scripts/init/html-cleaner.ts +48 -0
- package/src/cli/scripts/init/main.ts +171 -0
- package/src/cli/scripts/init/package-setup.ts +117 -0
- package/src/cli/scripts/init/router-transformer.ts +329 -0
- package/src/cli/scripts/init/tailwind-config.ts +75 -0
- package/src/cli/scripts/init/vite-config.ts +73 -0
- package/src/cli/scripts/release/release-config-upload.ts +114 -0
- package/src/cli/scripts/release/release-db-update.ts +97 -0
- package/src/cli/scripts/release/release-file-upload.ts +138 -0
- package/src/cli/scripts/release/release.ts +69 -0
- package/src/cli/types/DatabaseTypes.ts +117 -0
- package/src/components/ai/Assistant.tsx +4 -4
- package/src/components/ai/Avatar.tsx +24 -7
- package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +1 -1
- package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +16 -8
- package/src/components/ai/utils.ts +0 -2
- package/src/components/audio/Playbutton.tsx +3 -3
- package/src/{core → components}/components/ContextMenu.tsx +3 -3
- package/src/components.ts +6 -6
- package/src/core/controller/AIController.ts +122 -0
- package/src/core/controller/ObjectController.ts +115 -0
- package/src/{controller → core/controller}/SettingsController.ts +13 -29
- package/src/{controller → core/controller}/SharedContentController.ts +18 -28
- package/src/core/core.ts +15 -0
- package/src/{plugin/fromRimori → fromRimori}/EventBus.ts +28 -10
- package/src/fromRimori/PluginTypes.ts +203 -0
- package/src/hooks/UseChatHook.ts +5 -4
- package/src/index.ts +5 -3
- package/src/plugin/AccomplishmentHandler.ts +1 -1
- package/src/plugin/PluginController.ts +35 -23
- package/src/plugin/RimoriClient.ts +48 -41
- package/src/plugin/StandaloneClient.ts +11 -8
- package/src/plugin/ThemeSetter.ts +12 -8
- package/src/providers/PluginProvider.tsx +7 -4
- package/src/utils/Language.ts +4 -2
- package/src/utils/difficultyConverter.ts +3 -3
- package/src/utils/endpoint.ts +2 -0
- package/src/worker/WorkerSetup.ts +4 -2
- package/dist/components/PluginController.d.ts +0 -21
- package/dist/components/PluginController.js +0 -116
- package/dist/controller/AIController.d.ts +0 -23
- package/dist/controller/AIController.js +0 -93
- package/dist/controller/SidePluginController.d.ts +0 -3
- package/dist/controller/SidePluginController.js +0 -31
- package/dist/core.d.ts +0 -7
- package/dist/core.js +0 -7
- package/dist/plugin/ContextMenu.d.ts +0 -17
- package/dist/plugin/ContextMenu.js +0 -45
- package/dist/plugin/fromRimori/PluginTypes.d.ts +0 -48
- package/dist/plugin/fromRimori/SupabaseHandler.d.ts +0 -13
- package/dist/plugin/fromRimori/SupabaseHandler.js +0 -55
- package/dist/providers/PluginController.d.ts +0 -21
- package/dist/providers/PluginController.js +0 -116
- package/dist/types/Actions.d.ts +0 -4
- package/dist/types/Actions.js +0 -1
- package/src/controller/AIController.ts +0 -112
- package/src/controller/ObjectController.ts +0 -107
- package/src/controller/SidePluginController.ts +0 -25
- package/src/core.ts +0 -8
- package/src/plugin/fromRimori/PluginTypes.ts +0 -64
- package/src/types/Actions.ts +0 -6
- /package/dist/{core → components}/components/ContextMenu.d.ts +0 -0
- /package/dist/{controller → core/controller}/ObjectController.js +0 -0
- /package/dist/{controller → core/controller}/VoiceController.d.ts +0 -0
- /package/dist/{controller → core/controller}/VoiceController.js +0 -0
- /package/dist/{plugin/fromRimori → fromRimori}/PluginTypes.js +0 -0
- /package/src/{controller → core/controller}/VoiceController.ts +0 -0
- /package/src/{plugin/fromRimori → fromRimori}/readme.md +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
export type Plugin = Omit<RimoriPluginConfig, '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 interface PluginPage {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
url: string;
|
|
12
|
+
show: boolean;
|
|
13
|
+
description: string;
|
|
14
|
+
root: "vocabulary" | "grammar" | "reading" | "listening" | "watching" | "writing" | "speaking" | "other" | "community";
|
|
15
|
+
action?: {
|
|
16
|
+
key: string;
|
|
17
|
+
parameters: ObjectTool;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface SidebarPage {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
url: string;
|
|
25
|
+
icon: string;
|
|
26
|
+
}
|
|
27
|
+
export interface MenuEntry {
|
|
28
|
+
plugin_id: string;
|
|
29
|
+
action_key: string;
|
|
30
|
+
text: string;
|
|
31
|
+
icon?: React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
export type MainPanelAction = {
|
|
34
|
+
plugin_id: string;
|
|
35
|
+
action_key: string;
|
|
36
|
+
} & Record<string, string>;
|
|
37
|
+
export interface ContextMenuAction {
|
|
38
|
+
text: string;
|
|
39
|
+
plugin_id: string;
|
|
40
|
+
action_key: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Rimori plugin structure representing the complete configuration
|
|
44
|
+
* of a Rimori plugin with all metadata and configuration options.
|
|
45
|
+
*/
|
|
46
|
+
export interface RimoriPluginConfig {
|
|
47
|
+
id: string;
|
|
48
|
+
/**
|
|
49
|
+
* Basic information about the plugin including branding and core details.
|
|
50
|
+
*/
|
|
51
|
+
info: {
|
|
52
|
+
/** The display name of the plugin shown to users */
|
|
53
|
+
title: string;
|
|
54
|
+
/** Detailed description introducing the plugin */
|
|
55
|
+
description: string;
|
|
56
|
+
/** relative or absolute URL or path to the plugin's logo/icon image */
|
|
57
|
+
logo: string;
|
|
58
|
+
/** Optional website URL for the plugin's homepage or link to plugins owner for contributions */
|
|
59
|
+
website?: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Configuration for different types of pages.
|
|
63
|
+
*/
|
|
64
|
+
pages: {
|
|
65
|
+
/** Optional external URL where the plugin is hosted instead of the default CDN */
|
|
66
|
+
external_hosted_url?: string;
|
|
67
|
+
/** Array of main plugin pages that appear in the application's main navigation (can be disabled using the 'show' flag) */
|
|
68
|
+
main: PluginPage[];
|
|
69
|
+
/** Array of sidebar pages that appear in the sidebar for quick access (can be disabled using the 'show' flag) */
|
|
70
|
+
sidebar: SidebarPage[];
|
|
71
|
+
/** Optional path to the plugin's settings/configuration page */
|
|
72
|
+
settings?: string;
|
|
73
|
+
/** Optional array of event topics the plugin pages can listen to for cross-plugin communication */
|
|
74
|
+
topics?: string[];
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Context menu actions that the plugin registers to appear in right-click menus throughout the application.
|
|
78
|
+
*/
|
|
79
|
+
context_menu_actions: Omit<MenuEntry, "plugin_id">[];
|
|
80
|
+
/**
|
|
81
|
+
* Documentation paths for different types of plugin documentation.
|
|
82
|
+
*/
|
|
83
|
+
documentation: {
|
|
84
|
+
/** Path to the general overview documentation. It's shown upon installation of the plugin. */
|
|
85
|
+
overview_path: string;
|
|
86
|
+
/** Path to user-facing documentation and guides */
|
|
87
|
+
user_path: string;
|
|
88
|
+
/** Path to developer documentation for plugin development */
|
|
89
|
+
developer_path: string;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Configuration for the plugin's web worker if it uses background processing or exposes actions to other plugins.
|
|
93
|
+
*/
|
|
94
|
+
worker?: {
|
|
95
|
+
/** Relative path to the web worker JavaScript file. Mostly it's 'web-worker.js' which is located in the public folder. */
|
|
96
|
+
url: string;
|
|
97
|
+
/** 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.*' */
|
|
98
|
+
topics?: string[];
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export interface Tool {
|
|
102
|
+
name: string;
|
|
103
|
+
description: string;
|
|
104
|
+
parameters: {
|
|
105
|
+
name: string;
|
|
106
|
+
description: string;
|
|
107
|
+
type: "string" | "number" | "boolean";
|
|
108
|
+
}[];
|
|
109
|
+
execute?: (args: Record<string, any>) => Promise<unknown> | unknown | void;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The tool definition structure is used for LLM function calling and plugin action parameters.
|
|
113
|
+
* It defines the schema for tools that can be used by Language Learning Models (LLMs)
|
|
114
|
+
* and plugin actions.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const flashcardTool: Tool = {
|
|
119
|
+
* total_amount: {
|
|
120
|
+
* type: 'string',
|
|
121
|
+
* enum: ['default', '10', '20', '50'],
|
|
122
|
+
* description: 'Number of flashcards to practice'
|
|
123
|
+
* },
|
|
124
|
+
* deck: {
|
|
125
|
+
* type: 'string',
|
|
126
|
+
* enum: ['latest', 'random', 'oldest', 'mix', 'best_known'],
|
|
127
|
+
* description: 'Type of deck to practice'
|
|
128
|
+
* }
|
|
129
|
+
* };
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
*/
|
|
133
|
+
export type ObjectTool = {
|
|
134
|
+
[key: string]: ToolParameter;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Parameter definition for LLM tools and plugin actions.
|
|
138
|
+
* Defines the structure, validation rules, and metadata for individual tool parameters.
|
|
139
|
+
* Used to create type-safe interfaces between LLMs, plugins, and the Rimori platform.
|
|
140
|
+
*/
|
|
141
|
+
interface ToolParameter {
|
|
142
|
+
/** The data type of the parameter - can be primitive, nested object, or array */
|
|
143
|
+
type: ToolParameterType;
|
|
144
|
+
/** Human-readable description of the parameter's purpose and usage */
|
|
145
|
+
description: string;
|
|
146
|
+
/** Optional array of allowed values for enumerated parameters */
|
|
147
|
+
enum?: string[];
|
|
148
|
+
/** Whether the parameter is optional */
|
|
149
|
+
optional?: boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Union type defining all possible parameter types for LLM tools.
|
|
153
|
+
* Supports primitive types, nested objects for complex data structures,
|
|
154
|
+
* and arrays of objects for collections. The tuple notation [{}] indicates
|
|
155
|
+
* arrays of objects with a specific structure.
|
|
156
|
+
*
|
|
157
|
+
* @example Primitive: 'string' | 'number' | 'boolean'
|
|
158
|
+
* @example Nested object: { name: { type: 'string' }, age: { type: 'number' } }
|
|
159
|
+
* @example Array of objects: [{ id: { type: 'string' }, value: { type: 'number' } }]
|
|
160
|
+
*/
|
|
161
|
+
type ToolParameterType = PrimitiveType | {
|
|
162
|
+
[key: string]: ToolParameter;
|
|
163
|
+
} | [{
|
|
164
|
+
[key: string]: ToolParameter;
|
|
165
|
+
}];
|
|
166
|
+
/**
|
|
167
|
+
* Primitive data types supported by the LLM tool system.
|
|
168
|
+
* These align with JSON schema primitive types and TypeScript basic types.
|
|
169
|
+
*/
|
|
170
|
+
type PrimitiveType = 'string' | 'number' | 'boolean';
|
|
171
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Tool } from "../fromRimori/PluginTypes";
|
|
3
|
+
import { Message } from "../core/controller/AIController";
|
|
3
4
|
export declare function useChat(tools?: Tool[]): {
|
|
4
5
|
messages: Message[];
|
|
5
6
|
append: (appendMessages: Message[]) => void;
|
|
@@ -3,9 +3,9 @@ import { usePlugin } from "../providers/PluginProvider";
|
|
|
3
3
|
export function useChat(tools) {
|
|
4
4
|
const [messages, setMessages] = React.useState([]);
|
|
5
5
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
6
|
-
const {
|
|
6
|
+
const { ai } = usePlugin();
|
|
7
7
|
const append = (appendMessages) => {
|
|
8
|
-
|
|
8
|
+
ai.getSteamedText([...messages, ...appendMessages], (id, message, finished, toolInvocations) => {
|
|
9
9
|
const lastMessage = messages[messages.length - 1];
|
|
10
10
|
setIsLoading(!finished);
|
|
11
11
|
if ((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.id) === id) {
|
|
@@ -13,7 +13,7 @@ export function useChat(tools) {
|
|
|
13
13
|
setMessages([...messages, lastMessage]);
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
|
-
setMessages([...messages, ...appendMessages, { id, role: 'assistant', content: message, toolInvocations }]);
|
|
16
|
+
setMessages([...messages, ...appendMessages, { id, role: 'assistant', content: message, toolCalls: toolInvocations }]);
|
|
17
17
|
}
|
|
18
18
|
}, tools);
|
|
19
19
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export * from './core';
|
|
2
1
|
export * from './components';
|
|
3
2
|
export * from "./hooks/UseChatHook";
|
|
4
|
-
export * from "./plugin/
|
|
3
|
+
export * from "./plugin/PluginController";
|
|
5
4
|
export * from "./providers/PluginProvider";
|
|
5
|
+
export * from "./cli/types/DatabaseTypes";
|
|
6
6
|
export * from "./utils/difficultyConverter";
|
|
7
7
|
export * from "./utils/PluginUtils";
|
|
8
|
-
export * from "./
|
|
8
|
+
export * from "./utils/Language";
|
|
9
|
+
export * from "./fromRimori/PluginTypes";
|
|
10
|
+
export { FirstMessages } from "./components/ai/utils";
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Re-export everything
|
|
2
|
-
export * from './core';
|
|
3
2
|
export * from './components';
|
|
4
3
|
export * from "./hooks/UseChatHook";
|
|
5
|
-
export * from "./plugin/
|
|
4
|
+
export * from "./plugin/PluginController";
|
|
6
5
|
export * from "./providers/PluginProvider";
|
|
6
|
+
export * from "./cli/types/DatabaseTypes";
|
|
7
7
|
export * from "./utils/difficultyConverter";
|
|
8
8
|
export * from "./utils/PluginUtils";
|
|
9
|
-
export * from "./
|
|
9
|
+
export * from "./utils/Language";
|
|
10
|
+
export * from "./fromRimori/PluginTypes";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventBusMessage } from "
|
|
1
|
+
import { EventBusMessage } from "../fromRimori/EventBus";
|
|
2
2
|
export type AccomplishmentMessage = EventBusMessage<MicroAccomplishmentPayload>;
|
|
3
3
|
export declare const skillCategories: readonly ["reading", "listening", "speaking", "writing", "learning", "community"];
|
|
4
4
|
interface BaseAccomplishmentPayload {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventBus } from "
|
|
1
|
+
import { EventBus } from "../fromRimori/EventBus";
|
|
2
2
|
export const skillCategories = ["reading", "listening", "speaking", "writing", "learning", "community"];
|
|
3
3
|
export class AccomplishmentHandler {
|
|
4
4
|
constructor(pluginId) {
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { UserInfo } from '../core/controller/SettingsController';
|
|
3
|
+
import { Plugin } from '../fromRimori/PluginTypes';
|
|
2
4
|
import { RimoriClient } from "./RimoriClient";
|
|
5
|
+
export interface RimoriInfo {
|
|
6
|
+
url: string;
|
|
7
|
+
key: string;
|
|
8
|
+
backendUrl: string;
|
|
9
|
+
token: string;
|
|
10
|
+
expiration: Date;
|
|
11
|
+
tablePrefix: string;
|
|
12
|
+
pluginId: string;
|
|
13
|
+
installedPlugins: Plugin[];
|
|
14
|
+
profile: UserInfo;
|
|
15
|
+
}
|
|
3
16
|
export declare class PluginController {
|
|
4
17
|
private static client;
|
|
5
18
|
private static instance;
|
|
6
19
|
private communicationSecret;
|
|
7
20
|
private supabase;
|
|
8
|
-
private
|
|
21
|
+
private rimoriInfo;
|
|
9
22
|
private pluginId;
|
|
10
23
|
private constructor();
|
|
11
24
|
static getInstance(pluginId: string, standalone?: boolean): Promise<RimoriClient>;
|
|
12
25
|
private getSecret;
|
|
13
26
|
getClient(): Promise<{
|
|
14
27
|
supabase: SupabaseClient;
|
|
15
|
-
|
|
16
|
-
pluginId: string;
|
|
28
|
+
info: RimoriInfo;
|
|
17
29
|
}>;
|
|
18
30
|
getToken(): Promise<string>;
|
|
19
31
|
getSupabaseUrl(): string;
|
|
32
|
+
getBackendUrl(): string;
|
|
20
33
|
getGlobalEventTopic(preliminaryTopic: string): string;
|
|
21
34
|
}
|
|
@@ -8,15 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { createClient } from '@supabase/supabase-js';
|
|
11
|
-
import { EventBus } from '
|
|
11
|
+
import { EventBus } from '../fromRimori/EventBus';
|
|
12
12
|
import { RimoriClient } from "./RimoriClient";
|
|
13
|
-
import { setTheme } from './ThemeSetter';
|
|
14
13
|
import { StandaloneClient } from './StandaloneClient';
|
|
14
|
+
import { setTheme } from './ThemeSetter';
|
|
15
15
|
export class PluginController {
|
|
16
16
|
constructor(pluginId, standalone) {
|
|
17
17
|
this.communicationSecret = null;
|
|
18
18
|
this.supabase = null;
|
|
19
|
-
this.
|
|
19
|
+
this.rimoriInfo = null;
|
|
20
20
|
this.pluginId = pluginId;
|
|
21
21
|
this.getClient = this.getClient.bind(this);
|
|
22
22
|
if (typeof WorkerGlobalScope === 'undefined') {
|
|
@@ -69,37 +69,43 @@ export class PluginController {
|
|
|
69
69
|
getClient() {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
71
|
if (this.supabase &&
|
|
72
|
-
this.
|
|
73
|
-
this.
|
|
74
|
-
return { supabase: this.supabase,
|
|
72
|
+
this.rimoriInfo &&
|
|
73
|
+
this.rimoriInfo.expiration > new Date()) {
|
|
74
|
+
return { supabase: this.supabase, info: this.rimoriInfo };
|
|
75
75
|
}
|
|
76
76
|
const { data } = yield EventBus.request(this.pluginId, "global.supabase.requestAccess");
|
|
77
|
-
this.
|
|
78
|
-
this.supabase = createClient(this.
|
|
77
|
+
this.rimoriInfo = data;
|
|
78
|
+
this.supabase = createClient(this.rimoriInfo.url, this.rimoriInfo.key, {
|
|
79
79
|
accessToken: () => Promise.resolve(this.getToken())
|
|
80
80
|
});
|
|
81
|
-
return { supabase: this.supabase,
|
|
81
|
+
return { supabase: this.supabase, info: this.rimoriInfo };
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
getToken() {
|
|
85
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
if (this.
|
|
87
|
-
return this.
|
|
86
|
+
if (this.rimoriInfo && this.rimoriInfo.expiration && this.rimoriInfo.expiration > new Date()) {
|
|
87
|
+
return this.rimoriInfo.token;
|
|
88
88
|
}
|
|
89
89
|
const { data } = yield EventBus.request(this.pluginId, "global.supabase.requestAccess");
|
|
90
|
-
if (!this.
|
|
90
|
+
if (!this.rimoriInfo) {
|
|
91
91
|
throw new Error("Supabase info not found");
|
|
92
92
|
}
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
95
|
-
return this.
|
|
93
|
+
this.rimoriInfo.token = data.token;
|
|
94
|
+
this.rimoriInfo.expiration = data.expiration;
|
|
95
|
+
return this.rimoriInfo.token;
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
getSupabaseUrl() {
|
|
99
|
-
if (!this.
|
|
99
|
+
if (!this.rimoriInfo) {
|
|
100
100
|
throw new Error("Supabase info not found");
|
|
101
101
|
}
|
|
102
|
-
return this.
|
|
102
|
+
return this.rimoriInfo.url;
|
|
103
|
+
}
|
|
104
|
+
getBackendUrl() {
|
|
105
|
+
if (!this.rimoriInfo) {
|
|
106
|
+
throw new Error("Rimori info not found");
|
|
107
|
+
}
|
|
108
|
+
return this.rimoriInfo.backendUrl;
|
|
103
109
|
}
|
|
104
110
|
getGlobalEventTopic(preliminaryTopic) {
|
|
105
111
|
var _a, _b;
|
|
@@ -119,7 +125,7 @@ export class PluginController {
|
|
|
119
125
|
else if (topicParts.length > 3) {
|
|
120
126
|
throw new Error(`The event topic must consist of 3 parts. <pluginId>.<topic area>.<action>. Received: ${preliminaryTopic}`);
|
|
121
127
|
}
|
|
122
|
-
const topicRoot = (_b = (_a = this.
|
|
128
|
+
const topicRoot = (_b = (_a = this.rimoriInfo) === null || _a === void 0 ? void 0 : _a.pluginId) !== null && _b !== void 0 ? _b : "global";
|
|
123
129
|
return `${topicRoot}.${preliminaryTopic}`;
|
|
124
130
|
}
|
|
125
131
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { PostgrestQueryBuilder } from "@supabase/postgrest-js";
|
|
2
2
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
3
3
|
import { GenericSchema } from "@supabase/supabase-js/dist/module/lib/types";
|
|
4
|
-
import { Message, OnLLMResponse
|
|
5
|
-
import { ObjectRequest } from "../controller/ObjectController";
|
|
6
|
-
import { UserInfo } from "../controller/SettingsController";
|
|
7
|
-
import {
|
|
4
|
+
import { Message, OnLLMResponse } from "../core/controller/AIController";
|
|
5
|
+
import { ObjectRequest } from "../core/controller/ObjectController";
|
|
6
|
+
import { UserInfo } from "../core/controller/SettingsController";
|
|
7
|
+
import { SharedContent, SharedContentFilter, SharedContentObjectRequest } from "../core/controller/SharedContentController";
|
|
8
|
+
import { EventBusMessage, EventHandler, EventPayload } from "../fromRimori/EventBus";
|
|
9
|
+
import { Plugin, Tool } from "../fromRimori/PluginTypes";
|
|
8
10
|
import { AccomplishmentPayload } from "./AccomplishmentHandler";
|
|
9
|
-
import { EventBusMessage, EventHandler, EventPayload } from "./fromRimori/EventBus";
|
|
10
|
-
import { Plugin } from "./fromRimori/PluginTypes";
|
|
11
11
|
import { PluginController } from "./PluginController";
|
|
12
12
|
interface Db {
|
|
13
13
|
from: {
|
|
@@ -52,8 +52,10 @@ export declare class RimoriClient {
|
|
|
52
52
|
private sharedContentController;
|
|
53
53
|
private accomplishmentHandler;
|
|
54
54
|
private supabaseUrl;
|
|
55
|
-
|
|
55
|
+
private installedPlugins;
|
|
56
|
+
private profile;
|
|
56
57
|
plugin: PluginInterface;
|
|
58
|
+
db: Db;
|
|
57
59
|
private constructor();
|
|
58
60
|
event: {
|
|
59
61
|
/**
|
|
@@ -78,9 +80,9 @@ export declare class RimoriClient {
|
|
|
78
80
|
* Subscribe to an event.
|
|
79
81
|
* @param topic The topic to subscribe to.
|
|
80
82
|
* @param callback The callback to call when the event is emitted.
|
|
81
|
-
* @returns
|
|
83
|
+
* @returns An EventListener object containing an off() method to unsubscribe the listeners.
|
|
82
84
|
*/
|
|
83
|
-
on: <T = EventPayload>(topic: string | string[], callback: EventHandler<T>) => import("
|
|
85
|
+
on: <T = EventPayload>(topic: string | string[], callback: EventHandler<T>) => import("../fromRimori/EventBus").EventListener;
|
|
84
86
|
/**
|
|
85
87
|
* Subscribe to an event once.
|
|
86
88
|
* @param topic The topic to subscribe to.
|
|
@@ -92,7 +94,7 @@ export declare class RimoriClient {
|
|
|
92
94
|
* @param topic The topic to respond to.
|
|
93
95
|
* @param data The data to respond with.
|
|
94
96
|
*/
|
|
95
|
-
respond: <T = EventPayload>(topic: string, data: EventPayload | ((data: EventBusMessage<T>) => EventPayload | Promise<EventPayload>)) => void;
|
|
97
|
+
respond: <T = EventPayload>(topic: string | string[], data: EventPayload | ((data: EventBusMessage<T>) => EventPayload | Promise<EventPayload>)) => void;
|
|
96
98
|
/**
|
|
97
99
|
* Emit an accomplishment.
|
|
98
100
|
* @param payload The payload to emit.
|
|
@@ -112,10 +114,13 @@ export declare class RimoriClient {
|
|
|
112
114
|
*/
|
|
113
115
|
emitSidebarAction: (pluginId: string, actionKey: string, text?: string) => void;
|
|
114
116
|
};
|
|
117
|
+
navigation: {
|
|
118
|
+
toDashboard: () => void;
|
|
119
|
+
};
|
|
115
120
|
static getInstance(pluginController: PluginController): Promise<RimoriClient>;
|
|
116
121
|
private from;
|
|
117
122
|
private getTableName;
|
|
118
|
-
|
|
123
|
+
ai: {
|
|
119
124
|
getText: (messages: Message[], tools?: Tool[]) => Promise<string>;
|
|
120
125
|
getSteamedText: (messages: Message[], onMessage: OnLLMResponse, tools?: Tool[]) => Promise<void>;
|
|
121
126
|
getVoice: (text: string, voice?: string, speed?: number, language?: string) => Promise<Blob>;
|
|
@@ -135,7 +140,7 @@ export declare class RimoriClient {
|
|
|
135
140
|
* @param id The id of the shared content item.
|
|
136
141
|
* @returns The shared content item.
|
|
137
142
|
*/
|
|
138
|
-
get: <T = any>(contentType: string, id: string) => Promise<
|
|
143
|
+
get: <T = any>(contentType: string, id: string) => Promise<SharedContent<T>>;
|
|
139
144
|
/**
|
|
140
145
|
* Get a list of shared content items.
|
|
141
146
|
* @param contentType The type of shared content to get. E.g. assignments, exercises, etc.
|
|
@@ -143,7 +148,7 @@ export declare class RimoriClient {
|
|
|
143
148
|
* @param limit The optional limit for the number of results.
|
|
144
149
|
* @returns The list of shared content items.
|
|
145
150
|
*/
|
|
146
|
-
getList: <T = any>(contentType: string, filter?: SharedContentFilter, limit?: number) => Promise<
|
|
151
|
+
getList: <T = any>(contentType: string, filter?: SharedContentFilter, limit?: number) => Promise<SharedContent<T>[]>;
|
|
147
152
|
/**
|
|
148
153
|
* Get new shared content.
|
|
149
154
|
* @param contentType The type of shared content to fetch. E.g. assignments, exercises, etc.
|
|
@@ -152,20 +157,20 @@ export declare class RimoriClient {
|
|
|
152
157
|
* @param privateTopic An optional flag to indicate if the topic should be private and only be visible to the user. This is useful if the topic is not meant to be shared with other users. Like for personal topics or if the content is based on the personal study goal.
|
|
153
158
|
* @returns The new shared content.
|
|
154
159
|
*/
|
|
155
|
-
getNew: <T = any>(contentType: string, generatorInstructions: SharedContentObjectRequest, filter?: SharedContentFilter, privateTopic?: boolean) => Promise<
|
|
160
|
+
getNew: <T = any>(contentType: string, generatorInstructions: SharedContentObjectRequest, filter?: SharedContentFilter, privateTopic?: boolean) => Promise<SharedContent<T>>;
|
|
156
161
|
/**
|
|
157
162
|
* Create a new shared content item.
|
|
158
163
|
* @param content The content to create.
|
|
159
164
|
* @returns The new shared content item.
|
|
160
165
|
*/
|
|
161
|
-
create: <T = any>(content: Omit<SharedContent<T>, "id">) => Promise<
|
|
166
|
+
create: <T = any>(content: Omit<SharedContent<T>, "id">) => Promise<SharedContent<T>>;
|
|
162
167
|
/**
|
|
163
168
|
* Update a shared content item.
|
|
164
169
|
* @param id The id of the shared content item to update.
|
|
165
170
|
* @param content The content to update.
|
|
166
171
|
* @returns The updated shared content item.
|
|
167
172
|
*/
|
|
168
|
-
update: <T = any>(id: string, content: Partial<SharedContent<T>>) => Promise<
|
|
173
|
+
update: <T = any>(id: string, content: Partial<SharedContent<T>>) => Promise<SharedContent<T>>;
|
|
169
174
|
/**
|
|
170
175
|
* Complete a shared content item.
|
|
171
176
|
* @param contentType The type of shared content to complete. E.g. assignments, exercises, etc.
|
|
@@ -177,7 +182,7 @@ export declare class RimoriClient {
|
|
|
177
182
|
* @param id The id of the shared content item to remove.
|
|
178
183
|
* @returns The removed shared content item.
|
|
179
184
|
*/
|
|
180
|
-
remove: (id: string) => Promise<
|
|
185
|
+
remove: (id: string) => Promise<SharedContent<any>>;
|
|
181
186
|
};
|
|
182
187
|
};
|
|
183
188
|
}
|
|
@@ -7,16 +7,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { generateText, streamChatGPT } from "../controller/AIController";
|
|
11
|
-
import { generateObject as generateObjectFunction } from "../controller/ObjectController";
|
|
12
|
-
import { SettingsController } from "../controller/SettingsController";
|
|
13
|
-
import { SharedContentController } from "../controller/SharedContentController";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
10
|
+
import { generateText, streamChatGPT } from "../core/controller/AIController";
|
|
11
|
+
import { generateObject as generateObjectFunction } from "../core/controller/ObjectController";
|
|
12
|
+
import { SettingsController } from "../core/controller/SettingsController";
|
|
13
|
+
import { SharedContentController } from "../core/controller/SharedContentController";
|
|
14
|
+
import { getSTTResponse, getTTSResponse } from "../core/controller/VoiceController";
|
|
15
|
+
import { EventBus } from "../fromRimori/EventBus";
|
|
16
16
|
import { AccomplishmentHandler } from "./AccomplishmentHandler";
|
|
17
|
-
import { EventBus } from "./fromRimori/EventBus";
|
|
18
17
|
export class RimoriClient {
|
|
19
|
-
constructor(
|
|
18
|
+
constructor(supabase, info, pluginController) {
|
|
20
19
|
this.event = {
|
|
21
20
|
/**
|
|
22
21
|
* Emit an event to Rimori or a plugin.
|
|
@@ -46,11 +45,11 @@ export class RimoriClient {
|
|
|
46
45
|
* Subscribe to an event.
|
|
47
46
|
* @param topic The topic to subscribe to.
|
|
48
47
|
* @param callback The callback to call when the event is emitted.
|
|
49
|
-
* @returns
|
|
48
|
+
* @returns An EventListener object containing an off() method to unsubscribe the listeners.
|
|
50
49
|
*/
|
|
51
50
|
on: (topic, callback) => {
|
|
52
51
|
const topics = Array.isArray(topic) ? topic : [topic];
|
|
53
|
-
return topics.map(
|
|
52
|
+
return EventBus.on(topics.map(t => this.pluginController.getGlobalEventTopic(t)), callback);
|
|
54
53
|
},
|
|
55
54
|
/**
|
|
56
55
|
* Subscribe to an event once.
|
|
@@ -66,7 +65,8 @@ export class RimoriClient {
|
|
|
66
65
|
* @param data The data to respond with.
|
|
67
66
|
*/
|
|
68
67
|
respond: (topic, data) => {
|
|
69
|
-
|
|
68
|
+
const topics = Array.isArray(topic) ? topic : [topic];
|
|
69
|
+
EventBus.respond(this.plugin.pluginId, topics.map(t => this.pluginController.getGlobalEventTopic(t)), data);
|
|
70
70
|
},
|
|
71
71
|
/**
|
|
72
72
|
* Emit an accomplishment.
|
|
@@ -90,17 +90,22 @@ export class RimoriClient {
|
|
|
90
90
|
* @param text Optional text to be used for the action like for example text that the translator would look up.
|
|
91
91
|
*/
|
|
92
92
|
emitSidebarAction: (pluginId, actionKey, text) => {
|
|
93
|
-
this.event.emit("global.sidebar.triggerAction", { pluginId, actionKey, text });
|
|
93
|
+
this.event.emit("global.sidebar.triggerAction", { plugin_id: pluginId, action_key: actionKey, text });
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
this.navigation = {
|
|
97
|
+
toDashboard: () => {
|
|
98
|
+
this.event.emit("global.navigation.triggerToDashboard");
|
|
94
99
|
}
|
|
95
100
|
};
|
|
96
|
-
this.
|
|
101
|
+
this.ai = {
|
|
97
102
|
getText: (messages, tools) => __awaiter(this, void 0, void 0, function* () {
|
|
98
103
|
const token = yield this.pluginController.getToken();
|
|
99
|
-
return generateText(this.
|
|
104
|
+
return generateText(this.pluginController.getBackendUrl(), messages, tools || [], token).then(({ messages }) => messages[0].content[0].text);
|
|
100
105
|
}),
|
|
101
106
|
getSteamedText: (messages, onMessage, tools) => __awaiter(this, void 0, void 0, function* () {
|
|
102
107
|
const token = yield this.pluginController.getToken();
|
|
103
|
-
streamChatGPT(this.
|
|
108
|
+
streamChatGPT(this.pluginController.getBackendUrl(), messages, tools || [], onMessage, token);
|
|
104
109
|
}),
|
|
105
110
|
getVoice: (text_1, ...args_1) => __awaiter(this, [text_1, ...args_1], void 0, function* (text, voice = "alloy", speed = 1, language) {
|
|
106
111
|
const token = yield this.pluginController.getToken();
|
|
@@ -187,22 +192,24 @@ export class RimoriClient {
|
|
|
187
192
|
})
|
|
188
193
|
}
|
|
189
194
|
};
|
|
190
|
-
this.superbase =
|
|
191
|
-
this.pluginController =
|
|
192
|
-
this.settingsController = new SettingsController(
|
|
195
|
+
this.superbase = supabase;
|
|
196
|
+
this.pluginController = pluginController;
|
|
197
|
+
this.settingsController = new SettingsController(supabase, info.pluginId);
|
|
193
198
|
this.sharedContentController = new SharedContentController(this.superbase, this);
|
|
194
199
|
this.supabaseUrl = this.pluginController.getSupabaseUrl();
|
|
195
|
-
this.accomplishmentHandler = new AccomplishmentHandler(
|
|
200
|
+
this.accomplishmentHandler = new AccomplishmentHandler(info.pluginId);
|
|
201
|
+
this.installedPlugins = info.installedPlugins;
|
|
202
|
+
this.profile = info.profile;
|
|
196
203
|
this.from = this.from.bind(this);
|
|
197
204
|
this.db = {
|
|
198
205
|
from: this.from,
|
|
199
206
|
storage: this.superbase.storage,
|
|
200
207
|
// functions: this.superbase.functions,
|
|
201
|
-
tablePrefix:
|
|
208
|
+
tablePrefix: info.tablePrefix,
|
|
202
209
|
getTableName: this.getTableName.bind(this),
|
|
203
210
|
};
|
|
204
211
|
this.plugin = {
|
|
205
|
-
pluginId:
|
|
212
|
+
pluginId: info.pluginId,
|
|
206
213
|
setSettings: (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
207
214
|
yield this.settingsController.setSettings(settings);
|
|
208
215
|
}),
|
|
@@ -210,18 +217,18 @@ export class RimoriClient {
|
|
|
210
217
|
return yield this.settingsController.getSettings(defaultSettings);
|
|
211
218
|
}),
|
|
212
219
|
getInstalled: () => __awaiter(this, void 0, void 0, function* () {
|
|
213
|
-
return
|
|
220
|
+
return this.installedPlugins;
|
|
214
221
|
}),
|
|
215
222
|
getUserInfo: () => __awaiter(this, void 0, void 0, function* () {
|
|
216
|
-
return this.
|
|
223
|
+
return this.profile;
|
|
217
224
|
})
|
|
218
225
|
};
|
|
219
226
|
}
|
|
220
227
|
static getInstance(pluginController) {
|
|
221
228
|
return __awaiter(this, void 0, void 0, function* () {
|
|
222
229
|
if (!RimoriClient.instance) {
|
|
223
|
-
const
|
|
224
|
-
RimoriClient.instance = new RimoriClient(
|
|
230
|
+
const client = yield pluginController.getClient();
|
|
231
|
+
RimoriClient.instance = new RimoriClient(client.supabase, client.info, pluginController);
|
|
225
232
|
}
|
|
226
233
|
return RimoriClient.instance;
|
|
227
234
|
});
|
|
@@ -230,6 +237,9 @@ export class RimoriClient {
|
|
|
230
237
|
return this.superbase.from(this.getTableName(relation));
|
|
231
238
|
}
|
|
232
239
|
getTableName(type) {
|
|
240
|
+
if (type.startsWith("global_")) {
|
|
241
|
+
return type.replace("global_", "");
|
|
242
|
+
}
|
|
233
243
|
return this.db.tablePrefix + "_" + type;
|
|
234
244
|
}
|
|
235
245
|
}
|