@rimori/client 1.1.10 → 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 +1 -1
- package/dist/{controller → core/controller}/SharedContentController.js +4 -4
- 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 +16 -11
- 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 +5 -5
- 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 +42 -35
- 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
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
type PrimitiveType = 'string' | 'number' | 'boolean';
|
|
2
|
-
|
|
3
|
-
// This is the type that can appear in the `type` property
|
|
4
|
-
type ObjectToolParameterType =
|
|
5
|
-
| PrimitiveType
|
|
6
|
-
| { [key: string]: ObjectToolParameter } // for nested objects
|
|
7
|
-
| [{ [key: string]: ObjectToolParameter }]; // for arrays of objects (notice the tuple type)
|
|
8
|
-
|
|
9
|
-
interface ObjectToolParameter {
|
|
10
|
-
type: ObjectToolParameterType;
|
|
11
|
-
description?: string;
|
|
12
|
-
enum?: string[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type ObjectTool = {
|
|
16
|
-
[key: string]: ObjectToolParameter;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export interface ObjectRequest {
|
|
20
|
-
/**
|
|
21
|
-
* The tools that the AI can use.
|
|
22
|
-
*/
|
|
23
|
-
tool: ObjectTool;
|
|
24
|
-
/**
|
|
25
|
-
* High level instructions for the AI to follow. Behaviour, tone, restrictions, etc.
|
|
26
|
-
* Example: "Act like a recipe writer."
|
|
27
|
-
*/
|
|
28
|
-
behaviour?: string;
|
|
29
|
-
/**
|
|
30
|
-
* The specific instruction for the AI to follow.
|
|
31
|
-
* Example: "Generate a recipe using chicken, rice and vegetables."
|
|
32
|
-
*/
|
|
33
|
-
instructions: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export async function generateObject(supabaseUrl: string, request: ObjectRequest, token: string) {
|
|
37
|
-
return await fetch(`${supabaseUrl}/functions/v1/llm-object`, {
|
|
38
|
-
method: 'POST',
|
|
39
|
-
body: JSON.stringify({
|
|
40
|
-
stream: false,
|
|
41
|
-
tool: request.tool,
|
|
42
|
-
behaviour: request.behaviour,
|
|
43
|
-
instructions: request.instructions,
|
|
44
|
-
}),
|
|
45
|
-
headers: { 'Authorization': `Bearer ${token}` }
|
|
46
|
-
}).then(response => response.json());
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// TODO adjust stream to work with object
|
|
50
|
-
export type OnLLMResponse = (id: string, response: string, finished: boolean, toolInvocations?: any[]) => void;
|
|
51
|
-
|
|
52
|
-
export async function streamObject(supabaseUrl: string, request: ObjectRequest, onResponse: OnLLMResponse, token: string) {
|
|
53
|
-
const messageId = Math.random().toString(36).substring(3);
|
|
54
|
-
const response = await fetch(`${supabaseUrl}/functions/v1/llm-object`, {
|
|
55
|
-
method: 'POST',
|
|
56
|
-
body: JSON.stringify({
|
|
57
|
-
stream: true,
|
|
58
|
-
tools: request.tool,
|
|
59
|
-
systemInstructions: request.behaviour,
|
|
60
|
-
secondaryInstructions: request.instructions,
|
|
61
|
-
}),
|
|
62
|
-
headers: { 'Authorization': `Bearer ${token}` }
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
if (!response.body) {
|
|
66
|
-
console.error('No response body.');
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const reader = response.body.getReader();
|
|
71
|
-
const decoder = new TextDecoder('utf-8');
|
|
72
|
-
|
|
73
|
-
let content = "";
|
|
74
|
-
let done = false;
|
|
75
|
-
let toolInvocations: any[] = [];
|
|
76
|
-
while (!done) {
|
|
77
|
-
const { value } = await reader.read();
|
|
78
|
-
|
|
79
|
-
if (value) {
|
|
80
|
-
const chunk = decoder.decode(value, { stream: true });
|
|
81
|
-
const lines = chunk.split('\n').filter(line => line.trim() !== '');
|
|
82
|
-
|
|
83
|
-
for (const line of lines) {
|
|
84
|
-
const data = line.substring(3, line.length - 1);
|
|
85
|
-
const command = line.substring(0, 1);
|
|
86
|
-
// console.log("data: ", { line, data, command });
|
|
87
|
-
|
|
88
|
-
if (command === '0') {
|
|
89
|
-
content += data;
|
|
90
|
-
// console.log("AI response:", content);
|
|
91
|
-
|
|
92
|
-
//content \n\n should be real line break when message is displayed
|
|
93
|
-
onResponse(messageId, content.replace(/\\n/g, '\n'), false);
|
|
94
|
-
} else if (command === 'd') {
|
|
95
|
-
// console.log("AI usage:", JSON.parse(line.substring(2)));
|
|
96
|
-
done = true;
|
|
97
|
-
break;
|
|
98
|
-
} else if (command === '9') {
|
|
99
|
-
// console.log("tool call:", JSON.parse(line.substring(2)));
|
|
100
|
-
// console.log("tools", tools);
|
|
101
|
-
toolInvocations.push(JSON.parse(line.substring(2)));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
onResponse(messageId, content.replace(/\\n/g, '\n'), true, toolInvocations);
|
|
107
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
-
import { Plugin } from '../plugin/fromRimori/PluginTypes';
|
|
3
|
-
|
|
4
|
-
export async function getPlugins(supabase: SupabaseClient): Promise<Plugin[]> {
|
|
5
|
-
let { data, error } = await supabase.from('plugins').select('*');
|
|
6
|
-
|
|
7
|
-
if (error) {
|
|
8
|
-
console.error(error);
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return (data || []).map((plugin: any) => ({
|
|
13
|
-
id: plugin.id,
|
|
14
|
-
title: plugin.title,
|
|
15
|
-
description: plugin.description,
|
|
16
|
-
icon_url: plugin.icon_url,
|
|
17
|
-
endpoint: plugin.endpoint,
|
|
18
|
-
context_menu_actions: plugin.context_menu_actions,
|
|
19
|
-
plugin_pages: plugin.plugin_pages,
|
|
20
|
-
sidebar_pages: plugin.sidebar_pages,
|
|
21
|
-
settings_page: plugin.settings_page,
|
|
22
|
-
version: plugin.version,
|
|
23
|
-
external_hosted_url: plugin.external_hosted_url,
|
|
24
|
-
}));
|
|
25
|
-
}
|
package/src/core.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Core functionality exports
|
|
2
|
-
export * from "./plugin/RimoriClient";
|
|
3
|
-
export * from "./plugin/PluginController";
|
|
4
|
-
export * from "./utils/difficultyConverter";
|
|
5
|
-
export * from "./utils/PluginUtils";
|
|
6
|
-
export * from "./worker/WorkerSetup";
|
|
7
|
-
export * from "./utils/Language";
|
|
8
|
-
export { SharedContent } from "./controller/SharedContentController";
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// whole configuration of a plugin (from the database)
|
|
4
|
-
export interface Plugin {
|
|
5
|
-
id: string;
|
|
6
|
-
title: string;
|
|
7
|
-
description: string;
|
|
8
|
-
icon_url: string;
|
|
9
|
-
version: string;
|
|
10
|
-
endpoint: string;
|
|
11
|
-
context_menu_actions: MenuEntry[];
|
|
12
|
-
plugin_pages: PluginPage[];
|
|
13
|
-
sidebar_pages: SidebarPage[];
|
|
14
|
-
settings_page: string;
|
|
15
|
-
worker?: {
|
|
16
|
-
url: string;
|
|
17
|
-
topics?: string[];
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// browsable page of a plugin
|
|
22
|
-
export interface PluginPage {
|
|
23
|
-
name: string;
|
|
24
|
-
url: string;
|
|
25
|
-
// Whether the page should be shown in the navbar
|
|
26
|
-
show: boolean;
|
|
27
|
-
description: string;
|
|
28
|
-
root: string;
|
|
29
|
-
// The actions that can be triggered in the plugin
|
|
30
|
-
// The key is the action key. The other entries are additional properties needed when triggering the action
|
|
31
|
-
action?: (Record<string, string> & {
|
|
32
|
-
key: string;
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// a sidebar page of a plugin
|
|
37
|
-
export interface SidebarPage {
|
|
38
|
-
name: string;
|
|
39
|
-
url: string;
|
|
40
|
-
iconUrl: string;
|
|
41
|
-
description: string;
|
|
42
|
-
actionKey: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// context menu entry being configured in the plugin configuration
|
|
46
|
-
export interface MenuEntry {
|
|
47
|
-
text: string;
|
|
48
|
-
pluginId: string;
|
|
49
|
-
actionKey: string;
|
|
50
|
-
icon?: React.ReactNode;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// an action from the main panel that can be triggered and performs an action in the main panel
|
|
54
|
-
export type MainPanelAction = {
|
|
55
|
-
pluginId: string;
|
|
56
|
-
actionKey: string;
|
|
57
|
-
} & Record<string, string>;
|
|
58
|
-
|
|
59
|
-
// an action from the context menu that can be triggered and performs an action in the sidebar plugin
|
|
60
|
-
export interface ContextMenuAction {
|
|
61
|
-
text: string;
|
|
62
|
-
pluginId: string;
|
|
63
|
-
actionKey: string
|
|
64
|
-
}
|
package/src/types/Actions.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|