@rimori/client 1.1.10 → 1.3.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.
Files changed (171) hide show
  1. package/README.md +189 -63
  2. package/dist/cli/scripts/init/dev-registration.d.ts +35 -0
  3. package/dist/cli/scripts/init/dev-registration.js +174 -0
  4. package/dist/cli/scripts/init/env-setup.d.ts +9 -0
  5. package/dist/cli/scripts/init/env-setup.js +43 -0
  6. package/dist/cli/scripts/init/file-operations.d.ts +4 -0
  7. package/dist/cli/scripts/init/file-operations.js +51 -0
  8. package/dist/cli/scripts/init/html-cleaner.d.ts +4 -0
  9. package/dist/cli/scripts/init/html-cleaner.js +38 -0
  10. package/dist/cli/scripts/init/main.d.ts +2 -0
  11. package/dist/cli/scripts/init/main.js +160 -0
  12. package/dist/cli/scripts/init/package-setup.d.ts +32 -0
  13. package/dist/cli/scripts/init/package-setup.js +75 -0
  14. package/dist/cli/scripts/init/router-transformer.d.ts +6 -0
  15. package/dist/cli/scripts/init/router-transformer.js +254 -0
  16. package/dist/cli/scripts/init/tailwind-config.d.ts +4 -0
  17. package/dist/cli/scripts/init/tailwind-config.js +56 -0
  18. package/dist/cli/scripts/init/vite-config.d.ts +20 -0
  19. package/dist/cli/scripts/init/vite-config.js +54 -0
  20. package/dist/cli/scripts/release/release-config-upload.d.ts +7 -0
  21. package/dist/cli/scripts/release/release-config-upload.js +116 -0
  22. package/dist/cli/scripts/release/release-db-update.d.ts +6 -0
  23. package/dist/cli/scripts/release/release-db-update.js +100 -0
  24. package/dist/cli/scripts/release/release-file-upload.d.ts +6 -0
  25. package/dist/cli/scripts/release/release-file-upload.js +136 -0
  26. package/dist/cli/scripts/release/release.d.ts +23 -0
  27. package/dist/cli/scripts/release/release.js +70 -0
  28. package/dist/cli/types/DatabaseTypes.d.ts +103 -0
  29. package/dist/cli/types/DatabaseTypes.js +2 -0
  30. package/dist/components/LoggerExample.d.ts +6 -0
  31. package/dist/components/LoggerExample.js +79 -0
  32. package/dist/components/ai/Assistant.js +5 -5
  33. package/dist/components/ai/Avatar.d.ts +3 -2
  34. package/dist/components/ai/Avatar.js +11 -6
  35. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +1 -1
  36. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +1 -0
  37. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +48 -33
  38. package/dist/components/ai/utils.js +0 -1
  39. package/dist/components/audio/Playbutton.js +4 -4
  40. package/dist/{core → components}/components/ContextMenu.js +50 -11
  41. package/dist/components.d.ts +5 -5
  42. package/dist/components.js +5 -5
  43. package/dist/core/controller/AIController.d.ts +15 -0
  44. package/dist/core/controller/AIController.js +253 -0
  45. package/dist/core/controller/AudioController.d.ts +0 -0
  46. package/dist/core/controller/AudioController.js +1 -0
  47. package/dist/{controller → core/controller}/ObjectController.d.ts +10 -2
  48. package/dist/{controller → core/controller}/ObjectController.js +8 -8
  49. package/dist/{controller → core/controller}/SettingsController.d.ts +28 -4
  50. package/dist/{controller → core/controller}/SettingsController.js +0 -25
  51. package/dist/{controller → core/controller}/SharedContentController.d.ts +31 -3
  52. package/dist/{controller → core/controller}/SharedContentController.js +77 -26
  53. package/dist/core/controller/VoiceController.d.ts +9 -0
  54. package/dist/{controller → core/controller}/VoiceController.js +11 -4
  55. package/dist/core/core.d.ts +14 -0
  56. package/dist/core/core.js +8 -0
  57. package/dist/{plugin/fromRimori → fromRimori}/EventBus.d.ts +3 -3
  58. package/dist/{plugin/fromRimori → fromRimori}/EventBus.js +26 -9
  59. package/dist/fromRimori/PluginTypes.d.ts +174 -0
  60. package/dist/hooks/UseChatHook.d.ts +2 -1
  61. package/dist/hooks/UseChatHook.js +6 -4
  62. package/dist/hooks/UseLogger.d.ts +30 -0
  63. package/dist/hooks/UseLogger.js +122 -0
  64. package/dist/index.d.ts +6 -3
  65. package/dist/index.js +5 -3
  66. package/dist/plugin/AccomplishmentHandler.d.ts +1 -1
  67. package/dist/plugin/AccomplishmentHandler.js +1 -1
  68. package/dist/plugin/AudioController.d.ts +37 -0
  69. package/dist/plugin/AudioController.js +68 -0
  70. package/dist/plugin/Logger.d.ts +68 -0
  71. package/dist/plugin/Logger.js +256 -0
  72. package/dist/plugin/LoggerExample.d.ts +16 -0
  73. package/dist/plugin/LoggerExample.js +140 -0
  74. package/dist/plugin/PluginController.d.ts +30 -5
  75. package/dist/plugin/PluginController.js +182 -53
  76. package/dist/plugin/RimoriClient.d.ts +68 -21
  77. package/dist/plugin/RimoriClient.js +88 -41
  78. package/dist/plugin/StandaloneClient.d.ts +1 -0
  79. package/dist/plugin/StandaloneClient.js +24 -10
  80. package/dist/plugin/ThemeSetter.d.ts +2 -1
  81. package/dist/plugin/ThemeSetter.js +13 -7
  82. package/dist/providers/PluginProvider.d.ts +4 -1
  83. package/dist/providers/PluginProvider.js +39 -13
  84. package/dist/utils/Language.d.ts +2 -1
  85. package/dist/utils/Language.js +4 -2
  86. package/dist/utils/audioFormats.d.ts +26 -0
  87. package/dist/utils/audioFormats.js +67 -0
  88. package/dist/utils/difficultyConverter.js +1 -1
  89. package/dist/utils/endpoint.d.ts +2 -0
  90. package/dist/utils/endpoint.js +2 -0
  91. package/dist/worker/WorkerSetup.d.ts +3 -2
  92. package/dist/worker/WorkerSetup.js +22 -65
  93. package/example/docs/devdocs.md +231 -0
  94. package/example/docs/overview.md +29 -0
  95. package/example/docs/userdocs.md +123 -0
  96. package/example/rimori.config.ts +89 -0
  97. package/example/worker/vite.config.ts +23 -0
  98. package/example/worker/worker.ts +11 -0
  99. package/package.json +16 -9
  100. package/src/cli/scripts/init/dev-registration.ts +192 -0
  101. package/src/cli/scripts/init/env-setup.ts +44 -0
  102. package/src/cli/scripts/init/file-operations.ts +58 -0
  103. package/src/cli/scripts/init/html-cleaner.ts +48 -0
  104. package/src/cli/scripts/init/main.ts +172 -0
  105. package/src/cli/scripts/init/package-setup.ts +117 -0
  106. package/src/cli/scripts/init/router-transformer.ts +329 -0
  107. package/src/cli/scripts/init/tailwind-config.ts +75 -0
  108. package/src/cli/scripts/init/vite-config.ts +73 -0
  109. package/src/cli/scripts/release/release-config-upload.ts +114 -0
  110. package/src/cli/scripts/release/release-db-update.ts +97 -0
  111. package/src/cli/scripts/release/release-file-upload.ts +138 -0
  112. package/src/cli/scripts/release/release.ts +69 -0
  113. package/src/cli/types/DatabaseTypes.ts +117 -0
  114. package/src/components/ai/Assistant.tsx +5 -5
  115. package/src/components/ai/Avatar.tsx +25 -8
  116. package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +1 -1
  117. package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +50 -35
  118. package/src/components/ai/utils.ts +0 -2
  119. package/src/components/audio/Playbutton.tsx +4 -4
  120. package/src/{core → components}/components/ContextMenu.tsx +56 -12
  121. package/src/components.ts +6 -6
  122. package/src/core/controller/AIController.ts +283 -0
  123. package/src/core/controller/ObjectController.ts +115 -0
  124. package/src/{controller → core/controller}/SettingsController.ts +29 -29
  125. package/src/{controller → core/controller}/SharedContentController.ts +91 -29
  126. package/src/core/controller/VoiceController.ts +31 -0
  127. package/src/core/core.ts +16 -0
  128. package/src/{plugin/fromRimori → fromRimori}/EventBus.ts +29 -11
  129. package/src/fromRimori/PluginTypes.ts +205 -0
  130. package/src/hooks/UseChatHook.ts +8 -5
  131. package/src/index.ts +6 -3
  132. package/src/plugin/AccomplishmentHandler.ts +1 -1
  133. package/src/plugin/AudioController.ts +58 -0
  134. package/src/plugin/Logger.ts +324 -0
  135. package/src/plugin/PluginController.ts +203 -63
  136. package/src/plugin/RimoriClient.ts +127 -55
  137. package/src/plugin/StandaloneClient.ts +30 -11
  138. package/src/plugin/ThemeSetter.ts +16 -9
  139. package/src/providers/PluginProvider.tsx +46 -13
  140. package/src/utils/Language.ts +4 -2
  141. package/src/utils/difficultyConverter.ts +3 -3
  142. package/src/utils/endpoint.ts +2 -0
  143. package/src/worker/WorkerSetup.ts +13 -60
  144. package/dist/components/PluginController.d.ts +0 -21
  145. package/dist/components/PluginController.js +0 -116
  146. package/dist/controller/AIController.d.ts +0 -23
  147. package/dist/controller/AIController.js +0 -93
  148. package/dist/controller/SidePluginController.d.ts +0 -3
  149. package/dist/controller/SidePluginController.js +0 -31
  150. package/dist/controller/VoiceController.d.ts +0 -10
  151. package/dist/core.d.ts +0 -7
  152. package/dist/core.js +0 -7
  153. package/dist/plugin/ContextMenu.d.ts +0 -17
  154. package/dist/plugin/ContextMenu.js +0 -45
  155. package/dist/plugin/fromRimori/PluginTypes.d.ts +0 -48
  156. package/dist/plugin/fromRimori/SupabaseHandler.d.ts +0 -13
  157. package/dist/plugin/fromRimori/SupabaseHandler.js +0 -55
  158. package/dist/providers/PluginController.d.ts +0 -21
  159. package/dist/providers/PluginController.js +0 -116
  160. package/dist/types/Actions.d.ts +0 -4
  161. package/dist/types/Actions.js +0 -1
  162. package/src/controller/AIController.ts +0 -112
  163. package/src/controller/ObjectController.ts +0 -107
  164. package/src/controller/SidePluginController.ts +0 -25
  165. package/src/controller/VoiceController.ts +0 -26
  166. package/src/core.ts +0 -8
  167. package/src/plugin/fromRimori/PluginTypes.ts +0 -64
  168. package/src/types/Actions.ts +0 -6
  169. /package/dist/{core → components}/components/ContextMenu.d.ts +0 -0
  170. /package/dist/{plugin/fromRimori → fromRimori}/PluginTypes.js +0 -0
  171. /package/src/{plugin/fromRimori → fromRimori}/readme.md +0 -0
@@ -1,112 +0,0 @@
1
- export interface ToolInvocation {
2
- toolName: string;
3
- args: Record<string, string>;
4
- }
5
-
6
- export interface Tool {
7
- name: string;
8
- description: string;
9
- parameters: {
10
- name: string;
11
- description: string;
12
- type: "string" | "number" | "boolean";
13
- }[];
14
- execute?: <T = Record<string, string | boolean | number>>(args: T) => Promise<any> | void;
15
- }
16
-
17
- export interface Message {
18
- id: string;
19
- role: string;
20
- content: string;
21
- toolInvocations?: ToolInvocation[];
22
- }
23
-
24
- export async function generateText(supabaseUrl: string, messages: Message[], tools: Tool[], token: string) {
25
- const response = await fetch(`${supabaseUrl}/functions/v1/llm`, {
26
- method: 'POST',
27
- body: JSON.stringify({ messages, tools }),
28
- headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }
29
- });
30
-
31
- return await response.json();
32
- }
33
-
34
- export type OnLLMResponse = (id: string, response: string, finished: boolean, toolInvocations?: ToolInvocation[]) => void;
35
-
36
- export async function streamChatGPT(supabaseUrl: string, messages: Message[], tools: Tool[], onResponse: OnLLMResponse, token: string) {
37
- const messageId = Math.random().toString(36).substring(3);
38
- const response = await fetch(`${supabaseUrl}/functions/v1/llm`, {
39
- method: 'POST',
40
- body: JSON.stringify({ messages, tools, stream: true }),
41
- headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }
42
- });
43
-
44
- if (!response.body) {
45
- console.error('No response body.');
46
- return;
47
- }
48
-
49
- const reader = response.body.getReader();
50
- const decoder = new TextDecoder('utf-8');
51
-
52
- let content = "";
53
- let done = false;
54
- let toolInvocations: ToolInvocation[] = [];
55
- while (!done) {
56
- const { value } = await reader.read();
57
-
58
- if (value) {
59
- const chunk = decoder.decode(value, { stream: true });
60
- const lines = chunk.split('\n').filter(line => line.trim() !== '');
61
-
62
- for (const line of lines) {
63
- const data = line.substring(3, line.length - 1);
64
- const command = line.substring(0, 1);
65
- // console.log("data: ", { line, data, command });
66
-
67
- if (command === '0') {
68
- content += data;
69
- // console.log("AI response:", content);
70
-
71
- //content \n\n should be real line break when message is displayed
72
- //content \"\" should be real double quote when message is displayed
73
- onResponse(messageId, content.replace(/\\n/g, '\n').replace(/\\+"|"\\+/g, '"'), false);
74
- } else if (command === 'd') {
75
- // console.log("AI usage:", JSON.parse(line.substring(2)));
76
- done = true;
77
- break;
78
- } else if (command === '9') {
79
- // console.log("tool call:", JSON.parse(line.substring(2)));
80
- // console.log("tools", tools);
81
- const toolInvocation = JSON.parse(line.substring(2));
82
- toolInvocations.push(toolInvocation);
83
-
84
- // Find the tool and execute it if it has an execute function
85
- const tool = tools.find(t => t.name === toolInvocation.toolName);
86
- // console.log("tool", tool);
87
- if (tool && tool.execute) {
88
- try {
89
- const result = await tool.execute(toolInvocation.args);
90
- const toolResult = { success: true, result: result }
91
- // Add the tool result as a message
92
- messages.push({
93
- id: Math.random().toString(36).substring(3),
94
- role: "function",
95
- content: JSON.stringify(toolResult),
96
- toolInvocations: [{
97
- args: toolInvocation.args,
98
- toolName: toolInvocation.toolName,
99
- }]
100
- });
101
- } catch (error) {
102
- console.error(`Error executing tool ${toolInvocation.toolName}:`, error);
103
- }
104
- }
105
- }
106
- }
107
- }
108
- // Wait for 5ms to avoid blocking the main thread
109
- await new Promise(resolve => setTimeout(resolve, 5));
110
- }
111
- onResponse(messageId, content.replace(/\\n/g, '\n'), true, toolInvocations);
112
- }
@@ -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
- }
@@ -1,26 +0,0 @@
1
- import { SupabaseClient } from "@supabase/supabase-js";
2
-
3
- export async function getSTTResponse(supabase: SupabaseClient, audio: Blob) {
4
- const formData = new FormData();
5
- formData.append('file', audio);
6
-
7
- return await supabase.functions.invoke('speech', { method: 'POST', body: formData }).then(({ data }) => data.text);
8
- }
9
-
10
- export async function getTTSResponse(supabaseUrl: string, request: TTSRequest, token: string) {
11
- return await fetch(`${supabaseUrl}/functions/v1/speech`, {
12
- method: 'POST',
13
- headers: {
14
- 'Content-Type': 'application/json',
15
- 'Authorization': `Bearer ${token}`
16
- },
17
- body: JSON.stringify(request),
18
- }).then(r => r.blob());
19
- }
20
-
21
- interface TTSRequest {
22
- input: string;
23
- voice: string;
24
- speed: number;
25
- language?: string;
26
- }
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
- }
@@ -1,6 +0,0 @@
1
- // the received action when the plugin pages action is triggered
2
- // This is based upon plugin_pages configuration of the plugin
3
- export type MainPanelAction = {
4
- pluginId: string;
5
- actionKey: string;
6
- } & Record<string, string>;
File without changes