gui-chat-protocol 0.0.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/README.md ADDED
@@ -0,0 +1,390 @@
1
+ # GUI Chat Protocol
2
+
3
+ A TypeScript library that defines the standard protocol for building GUI chat plugins. This package provides framework-agnostic core types with adapters for Vue and React, enabling developers to create interactive tool plugins that work with any compatible chat application.
4
+
5
+ > For the full protocol specification, see [GUI_CHAT_PROTOCOL.md](https://github.com/receptron/MulmoChat/blob/main/GUI_CHAT_PROTOCOL.md)
6
+
7
+ ## What is GUI Chat Protocol?
8
+
9
+ GUI Chat Protocol extends standard LLM tool calling to enable **rich graphical interfaces** in chat applications. Instead of tool results being purely textual data displayed inline, they trigger the rendering of GUI components or multi-modal content in the chat interface.
10
+
11
+ ### Key Mechanism
12
+
13
+ Tools return two things:
14
+
15
+ 1. **Text response** - For the LLM to continue the conversation
16
+ 2. **Typed GUI data** - That triggers appropriate visual components (images, maps, forms, quizzes, documents)
17
+
18
+ This approach maintains backward compatibility—existing text-based tools work unchanged while new tools leverage GUI rendering.
19
+
20
+ ### Role-Based Architecture
21
+
22
+ A standout feature is the **"composable roles without code"** concept. Applications are defined by:
23
+
24
+ - **Available tools** (like `presentForm`, `generateImage`, `map`, `quiz`)
25
+ - **System prompt** describing behavior
26
+
27
+ This enables non-programmers to create specialized AI assistants by configuration alone. The same generic chat infrastructure powers vastly different applications—a recipe guide, tutor, trip planner, or game companion—simply by changing tool selection and system instructions.
28
+
29
+ ### LLM Agnostic
30
+
31
+ The protocol works with **any model supporting function calling**: Claude, GPT, Gemini, and open-weight models. No proprietary features required.
32
+
33
+ ### Use Cases
34
+
35
+ The protocol enables:
36
+ - **Creative tools** - Image generation, music, 3D content
37
+ - **Information discovery** - Web browsing, search, maps
38
+ - **Interactive learning** - Quizzes, tutorials, forms
39
+ - **Content creation** - Documents, presentations, spreadsheets
40
+ - **Productivity applications** - Todo lists, calendars, workflows
41
+
42
+ All with bidirectional interaction where GUIs both display information and collect structured user input.
43
+
44
+ ## This Package
45
+
46
+ This npm package (`gui-chat-protocol`) provides the TypeScript type definitions for implementing the GUI Chat Protocol:
47
+
48
+ - **Framework-agnostic core types** - For plugin logic without UI dependencies
49
+ - **Vue adapter** - Vue 3 component types
50
+ - **React adapter** - React 18/19 component types
51
+
52
+ By defining a standard protocol, plugins become portable across different chat applications, and applications can easily integrate plugins without framework-specific dependencies.
53
+
54
+ ## Architecture
55
+
56
+ ### Tool Plugin Architecture
57
+
58
+ ```
59
+ ┌─────────────────────────────────────────────────────────────┐
60
+ │ Chat Application │
61
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
62
+ │ │ LLM │ │ Plugin │ │ UI Layer │ │
63
+ │ │ Interface │◄─┤ Manager │◄─┤ (Vue/React/etc.) │ │
64
+ │ └─────────────┘ └──────┬──────┘ └─────────────────────┘ │
65
+ └──────────────────────────┼──────────────────────────────────┘
66
+
67
+ ┌─────────────────┼─────────────────┐
68
+ │ │ │
69
+ ▼ ▼ ▼
70
+ ┌───────────┐ ┌───────────┐ ┌───────────┐
71
+ │ Plugin A │ │ Plugin B │ │ Plugin C │
72
+ │ (Quiz) │ │ (Image) │ │ (Form) │
73
+ └───────────┘ └───────────┘ └───────────┘
74
+ ```
75
+
76
+ ### Key Types
77
+
78
+ | Type | Description |
79
+ |------|-------------|
80
+ | `ToolPluginCore` | Framework-agnostic plugin definition |
81
+ | `ToolPlugin` | Vue-specific plugin with Vue components |
82
+ | `ToolPluginReact` | React-specific plugin with React components |
83
+ | `ToolResult` | Standardized result from plugin execution |
84
+ | `ToolContext` | Context passed to plugin execute function |
85
+ | `ToolDefinition` | OpenAI-compatible function definition |
86
+
87
+ ## Installation
88
+
89
+ ```bash
90
+ npm install gui-chat-protocol
91
+ # or
92
+ yarn add gui-chat-protocol
93
+ ```
94
+
95
+ ## Package Exports
96
+
97
+ ```typescript
98
+ // Core types (framework-agnostic)
99
+ import { ToolPluginCore, ToolResult, ToolContext } from "gui-chat-protocol";
100
+
101
+ // Vue-specific types
102
+ import { ToolPlugin } from "gui-chat-protocol/vue";
103
+
104
+ // React-specific types
105
+ import { ToolPluginReact } from "gui-chat-protocol/react";
106
+ ```
107
+
108
+ ## API Reference
109
+
110
+ ### Core Types
111
+
112
+ #### ToolPluginCore
113
+
114
+ The base plugin interface (framework-agnostic):
115
+
116
+ ```typescript
117
+ interface ToolPluginCore<T, J, A, H, S> {
118
+ // Tool definition for LLM function calling
119
+ toolDefinition: ToolDefinition;
120
+
121
+ // Execute function called when LLM invokes the tool
122
+ execute: (context: ToolContext, args: A) => Promise<ToolResult<T, J>>;
123
+
124
+ // Message shown while generating
125
+ generatingMessage: string;
126
+
127
+ // Check if plugin is enabled based on server capabilities
128
+ isEnabled: (startResponse?: S | null) => boolean;
129
+
130
+ // Optional: Input handlers for files, clipboard, etc.
131
+ inputHandlers?: H[];
132
+
133
+ // Optional: System prompt additions
134
+ systemPrompt?: string;
135
+
136
+ // Optional: Sample arguments for testing
137
+ samples?: ToolSample[];
138
+
139
+ // Optional: Backend types this plugin requires
140
+ backends?: BackendType[];
141
+ }
142
+ ```
143
+
144
+ #### ToolResult
145
+
146
+ Result returned from plugin execution:
147
+
148
+ ```typescript
149
+ interface ToolResult<T, J> {
150
+ message: string; // Status message for the LLM
151
+ data?: T; // UI data (not visible to LLM)
152
+ jsonData?: J; // Data passed to the LLM
153
+ instructions?: string; // Follow-up instructions for LLM
154
+ title?: string; // Display title
155
+ updating?: boolean; // Update existing result vs create new
156
+ }
157
+ ```
158
+
159
+ #### ToolContext
160
+
161
+ Context passed to the execute function:
162
+
163
+ ```typescript
164
+ interface ToolContext {
165
+ currentResult?: ToolResult | null; // Current result being updated
166
+ app?: ToolContextApp; // App-provided functions
167
+ }
168
+
169
+ interface ToolContextApp {
170
+ getConfig: <T>(key: string) => T | undefined;
171
+ setConfig: (key: string, value: unknown) => void;
172
+ // App can add custom functions (e.g., generateImage, browse, etc.)
173
+ }
174
+ ```
175
+
176
+ ### Input Handlers
177
+
178
+ Plugins can accept various input types:
179
+
180
+ ```typescript
181
+ type InputHandler =
182
+ | FileInputHandler // File uploads
183
+ | ClipboardImageInputHandler // Paste from clipboard
184
+ | UrlInputHandler // URL processing
185
+ | TextInputHandler // Text patterns
186
+ | CameraInputHandler // Camera capture
187
+ | AudioInputHandler; // Audio recording
188
+ ```
189
+
190
+ ### Vue Types
191
+
192
+ ```typescript
193
+ import { ToolPlugin } from "gui-chat-protocol/vue";
194
+
195
+ interface ToolPlugin<T, J, A, H, S> extends ToolPluginCore<T, J, A, H, S> {
196
+ viewComponent?: Component; // Full view component
197
+ previewComponent?: Component; // Thumbnail/preview component
198
+ }
199
+ ```
200
+
201
+ ### React Types
202
+
203
+ ```typescript
204
+ import { ToolPluginReact, ViewComponentProps, PreviewComponentProps } from "gui-chat-protocol/react";
205
+
206
+ interface ToolPluginReact<T, J, A, H, S> extends ToolPluginCore<T, J, A, H, S> {
207
+ ViewComponent?: ComponentType<ViewComponentProps<T, J>>;
208
+ PreviewComponent?: ComponentType<PreviewComponentProps<T, J>>;
209
+ }
210
+ ```
211
+
212
+ ## Creating a Plugin
213
+
214
+ ### Step 1: Define Plugin-Specific Types
215
+
216
+ ```typescript
217
+ // src/core/types.ts
218
+ export interface MyPluginData {
219
+ // Data for UI (not sent to LLM)
220
+ }
221
+
222
+ export interface MyPluginArgs {
223
+ // Arguments from LLM function call
224
+ }
225
+ ```
226
+
227
+ ### Step 2: Create Core Plugin (Framework-Agnostic)
228
+
229
+ ```typescript
230
+ // src/core/plugin.ts
231
+ import type { ToolPluginCore, ToolContext, ToolResult } from "gui-chat-protocol";
232
+ import type { MyPluginData, MyPluginArgs } from "./types";
233
+
234
+ export const pluginCore: ToolPluginCore<MyPluginData, never, MyPluginArgs> = {
235
+ toolDefinition: {
236
+ type: "function",
237
+ name: "myPlugin",
238
+ description: "Description for the LLM",
239
+ parameters: {
240
+ type: "object",
241
+ properties: { /* ... */ },
242
+ required: [],
243
+ },
244
+ },
245
+ execute: async (context, args) => {
246
+ // Plugin logic here
247
+ return {
248
+ message: "Success",
249
+ data: { /* MyPluginData */ },
250
+ };
251
+ },
252
+ generatingMessage: "Processing...",
253
+ isEnabled: () => true,
254
+ };
255
+ ```
256
+
257
+ ### Step 3: Create Vue Plugin
258
+
259
+ ```typescript
260
+ // src/vue/index.ts
261
+ import type { ToolPlugin } from "gui-chat-protocol/vue";
262
+ import { pluginCore } from "../core/plugin";
263
+ import View from "./View.vue";
264
+ import Preview from "./Preview.vue";
265
+
266
+ export const plugin: ToolPlugin<MyPluginData, never, MyPluginArgs> = {
267
+ ...pluginCore,
268
+ viewComponent: View,
269
+ previewComponent: Preview,
270
+ };
271
+
272
+ export default { plugin };
273
+ ```
274
+
275
+ ### Step 4: Create React Plugin
276
+
277
+ ```typescript
278
+ // src/react/index.ts
279
+ import type { ToolPluginReact } from "gui-chat-protocol/react";
280
+ import { pluginCore } from "../core/plugin";
281
+ import { View } from "./View";
282
+ import { Preview } from "./Preview";
283
+
284
+ export const plugin: ToolPluginReact<MyPluginData, never, MyPluginArgs> = {
285
+ ...pluginCore,
286
+ ViewComponent: View,
287
+ PreviewComponent: Preview,
288
+ };
289
+
290
+ export default { plugin };
291
+ ```
292
+
293
+ ## Example Implementations
294
+
295
+ ### Quiz Plugin
296
+
297
+ An interactive quiz plugin that presents multiple-choice questions:
298
+
299
+ - **Repository**: [MulmoChatPluginQuiz](https://github.com/receptron/MulmoChatPluginQuiz)
300
+ - **Features**:
301
+ - Multiple questions with choices
302
+ - Answer tracking with viewState persistence
303
+ - Both Vue and React implementations
304
+
305
+ ```typescript
306
+ // Usage
307
+ import QuizPlugin from "@mulmochat-plugin/quiz/vue";
308
+ // or
309
+ import QuizPlugin from "@mulmochat-plugin/quiz/react";
310
+ ```
311
+
312
+ ### GenerateImage Plugin
313
+
314
+ An image generation plugin that creates images from text prompts:
315
+
316
+ - **Repository**: [MulmoChatPluginGenerateImage](https://github.com/receptron/MulmoChatPluginGenerateImage)
317
+ - **Features**:
318
+ - Text-to-image generation
319
+ - File upload and clipboard paste support
320
+ - Backend abstraction for different providers
321
+
322
+ ```typescript
323
+ // Usage
324
+ import GenerateImagePlugin from "@mulmochat-plugin/generate-image/vue";
325
+ ```
326
+
327
+ ## Compatible Applications
328
+
329
+ ### MulmoChat
330
+
331
+ A multi-modal voice chat application with comprehensive plugin support:
332
+
333
+ - **Repository**: [MulmoChat](https://github.com/receptron/MulmoChat)
334
+ - **Features**:
335
+ - OpenAI Realtime API integration
336
+ - Voice and text input
337
+ - Multiple backend providers
338
+ - Full plugin ecosystem
339
+
340
+ ### Building Your Own Application
341
+
342
+ Any application can implement the GUI Chat Protocol by:
343
+
344
+ 1. Loading plugins that export `{ plugin }` default export
345
+ 2. Passing tool definitions to the LLM
346
+ 3. Executing plugins via `plugin.execute(context, args)`
347
+ 4. Rendering plugin components (`viewComponent`/`previewComponent`)
348
+ 5. Handling `ToolResult` for UI updates and LLM responses
349
+
350
+ ```typescript
351
+ // Example: Loading a plugin
352
+ import Plugin from "@mulmochat-plugin/quiz/vue";
353
+
354
+ // Get tool definition for LLM
355
+ const tools = [Plugin.plugin.toolDefinition];
356
+
357
+ // Execute when LLM calls the tool
358
+ const result = await Plugin.plugin.execute(context, args);
359
+
360
+ // Render the view component
361
+ <component :is="Plugin.plugin.viewComponent" :selected-result="result" />
362
+ ```
363
+
364
+ ## Framework Support
365
+
366
+ | Framework | Import Path | Plugin Type |
367
+ |-----------|-------------|-------------|
368
+ | Core (no UI) | `gui-chat-protocol` | `ToolPluginCore` |
369
+ | Vue 3 | `gui-chat-protocol/vue` | `ToolPlugin` |
370
+ | React 18/19 | `gui-chat-protocol/react` | `ToolPluginReact` |
371
+
372
+ Both Vue and React are optional peer dependencies - only install what you need.
373
+
374
+ ## TypeScript Support
375
+
376
+ Full TypeScript support with generic type parameters:
377
+
378
+ ```typescript
379
+ // T = Tool data type (UI only)
380
+ // J = JSON data type (sent to LLM)
381
+ // A = Arguments type
382
+ // H = Input handler type (extensible)
383
+ // S = Start response type (app-specific)
384
+
385
+ type ToolPlugin<T, J, A, H, S>
386
+ ```
387
+
388
+ ## License
389
+
390
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,261 @@
1
+ /**
2
+ * Audio input handler
3
+ */
4
+ export declare interface AudioInputHandler {
5
+ type: "audio";
6
+ handleInput: (audioData: string, duration: number) => ToolResult;
7
+ }
8
+
9
+ export declare type BackendType = "textLLM" | "imageGen" | "audio" | "search" | "browse" | "map" | "mulmocast";
10
+
11
+ declare interface BaseFieldSchema {
12
+ label: string;
13
+ description?: string;
14
+ required?: boolean;
15
+ }
16
+
17
+ export declare interface BooleanFieldSchema extends BaseFieldSchema {
18
+ type: "boolean";
19
+ }
20
+
21
+ /**
22
+ * Camera capture input handler
23
+ */
24
+ export declare interface CameraInputHandler {
25
+ type: "camera";
26
+ mode: "photo" | "video";
27
+ handleInput: (data: string, metadata?: {
28
+ duration?: number;
29
+ }) => ToolResult;
30
+ }
31
+
32
+ /**
33
+ * Clipboard image input handler
34
+ */
35
+ export declare interface ClipboardImageInputHandler {
36
+ type: "clipboard-image";
37
+ handleInput: (imageData: string) => ToolResult;
38
+ }
39
+
40
+ export declare type ConfigFieldSchema = StringFieldSchema | NumberFieldSchema | BooleanFieldSchema | SelectFieldSchema | MultiSelectFieldSchema;
41
+
42
+ export declare type ConfigValue = string | number | boolean | string[];
43
+
44
+ /**
45
+ * Base interface for custom input handlers
46
+ * Apps can extend this to create their own handler types
47
+ */
48
+ export declare interface CustomInputHandler {
49
+ type: string;
50
+ handleInput: (...args: unknown[]) => ToolResult;
51
+ }
52
+
53
+ /**
54
+ * File input handler
55
+ */
56
+ export declare interface FileInputHandler {
57
+ type: "file";
58
+ acceptedTypes: string[];
59
+ handleInput: (fileData: string, fileName: string) => ToolResult;
60
+ }
61
+
62
+ /**
63
+ * Union of all input handler types
64
+ */
65
+ export declare type InputHandler = FileInputHandler | ClipboardImageInputHandler | UrlInputHandler | TextInputHandler | CameraInputHandler | AudioInputHandler;
66
+
67
+ /**
68
+ * Schema Types (Framework-agnostic)
69
+ *
70
+ * JSON Schema based types for tool definitions and plugin settings.
71
+ */
72
+ /**
73
+ * JSON Schema property definition
74
+ */
75
+ export declare interface JsonSchemaProperty {
76
+ type?: string;
77
+ description?: string;
78
+ enum?: string[];
79
+ items?: JsonSchemaProperty;
80
+ minimum?: number;
81
+ maximum?: number;
82
+ minItems?: number;
83
+ maxItems?: number;
84
+ properties?: Record<string, JsonSchemaProperty>;
85
+ required?: string[];
86
+ additionalProperties?: boolean;
87
+ oneOf?: JsonSchemaProperty[];
88
+ [key: string]: unknown;
89
+ }
90
+
91
+ export declare interface MultiSelectFieldSchema extends BaseFieldSchema {
92
+ type: "multiselect";
93
+ options: SelectOption[];
94
+ minItems?: number;
95
+ maxItems?: number;
96
+ }
97
+
98
+ export declare interface NumberFieldSchema extends BaseFieldSchema {
99
+ type: "number";
100
+ min?: number;
101
+ max?: number;
102
+ step?: number;
103
+ }
104
+
105
+ /**
106
+ * Plugin configuration schema (JSON Schema based)
107
+ */
108
+ export declare interface PluginConfigSchema {
109
+ key: string;
110
+ defaultValue: ConfigValue;
111
+ schema: ConfigFieldSchema;
112
+ }
113
+
114
+ /**
115
+ * Standard props for Preview components
116
+ */
117
+ export declare interface PreviewComponentProps<T = unknown, J = unknown> {
118
+ result: ToolResultComplete<T, J>;
119
+ isSelected?: boolean;
120
+ onSelect?: () => void;
121
+ }
122
+
123
+ export declare interface SelectFieldSchema extends BaseFieldSchema {
124
+ type: "select";
125
+ options: SelectOption[];
126
+ }
127
+
128
+ export declare interface SelectOption {
129
+ value: string;
130
+ label: string;
131
+ description?: string;
132
+ disabled?: boolean;
133
+ }
134
+
135
+ export declare interface StringFieldSchema extends BaseFieldSchema {
136
+ type: "string";
137
+ placeholder?: string;
138
+ minLength?: number;
139
+ maxLength?: number;
140
+ pattern?: string;
141
+ }
142
+
143
+ /**
144
+ * Text input handler
145
+ */
146
+ export declare interface TextInputHandler {
147
+ type: "text";
148
+ patterns?: string[];
149
+ handleInput: (text: string) => ToolResult;
150
+ }
151
+
152
+ /**
153
+ * Context passed to plugin execute function
154
+ */
155
+ export declare interface ToolContext {
156
+ currentResult?: ToolResult<unknown> | null;
157
+ app?: ToolContextApp;
158
+ }
159
+
160
+ /**
161
+ * App interface provided to plugins via context.app
162
+ * Contains backend functions and config accessors
163
+ */
164
+ export declare interface ToolContextApp extends Record<string, (...args: any[]) => any> {
165
+ getConfig: <T = unknown>(key: string) => T | undefined;
166
+ setConfig: (key: string, value: unknown) => void;
167
+ }
168
+
169
+ /**
170
+ * Tool definition for OpenAI-compatible function calling
171
+ */
172
+ export declare interface ToolDefinition {
173
+ type: "function";
174
+ name: string;
175
+ description: string;
176
+ parameters?: {
177
+ type: "object";
178
+ properties: Record<string, JsonSchemaProperty>;
179
+ required: string[];
180
+ additionalProperties?: boolean;
181
+ };
182
+ }
183
+
184
+ /**
185
+ * Core plugin interface - framework agnostic
186
+ * Does not include UI components
187
+ *
188
+ * @typeParam T - Tool-specific data type (for views)
189
+ * @typeParam J - JSON data type (passed to LLM)
190
+ * @typeParam A - Arguments type for execute function
191
+ * @typeParam H - Input handler type (allows custom handlers)
192
+ * @typeParam S - Start response type (app-specific server response)
193
+ */
194
+ export declare interface ToolPluginCore<T = unknown, J = unknown, A extends object = object, H = InputHandler, S = Record<string, unknown>> {
195
+ toolDefinition: ToolDefinition;
196
+ execute: (context: ToolContext, args: A) => Promise<ToolResult<T, J>>;
197
+ generatingMessage: string;
198
+ waitingMessage?: string;
199
+ uploadMessage?: string;
200
+ isEnabled: (startResponse?: S | null) => boolean;
201
+ delayAfterExecution?: number;
202
+ systemPrompt?: string;
203
+ inputHandlers?: H[];
204
+ configSchema?: PluginConfigSchema;
205
+ samples?: ToolSample[];
206
+ backends?: BackendType[];
207
+ }
208
+
209
+ /**
210
+ * Result returned from plugin execution
211
+ */
212
+ export declare interface ToolResult<T = unknown, J = unknown> {
213
+ toolName?: string;
214
+ uuid?: string;
215
+ message: string;
216
+ title?: string;
217
+ jsonData?: J;
218
+ instructions?: string;
219
+ instructionsRequired?: boolean;
220
+ updating?: boolean;
221
+ cancelled?: boolean;
222
+ data?: T;
223
+ viewState?: Record<string, unknown>;
224
+ }
225
+
226
+ /**
227
+ * Complete tool result with required fields
228
+ */
229
+ export declare interface ToolResultComplete<T = unknown, J = unknown> extends ToolResult<T, J> {
230
+ toolName: string;
231
+ uuid: string;
232
+ }
233
+
234
+ /**
235
+ * Sample arguments for testing
236
+ */
237
+ export declare interface ToolSample {
238
+ name: string;
239
+ args: Record<string, unknown>;
240
+ }
241
+
242
+ /**
243
+ * URL input handler
244
+ */
245
+ export declare interface UrlInputHandler {
246
+ type: "url";
247
+ patterns?: string[];
248
+ handleInput: (url: string) => ToolResult;
249
+ }
250
+
251
+ /**
252
+ * Standard props for View components
253
+ */
254
+ export declare interface ViewComponentProps<T = unknown, J = unknown> {
255
+ selectedResult: ToolResultComplete<T, J>;
256
+ sendTextMessage: (text?: string) => void;
257
+ onUpdateResult?: (result: Partial<ToolResult<T, J>>) => void;
258
+ pluginConfigs?: Record<string, unknown>;
259
+ }
260
+
261
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/react.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=react.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,277 @@
1
+ import { ComponentType } from 'react';
2
+
3
+ /**
4
+ * Audio input handler
5
+ */
6
+ export declare interface AudioInputHandler {
7
+ type: "audio";
8
+ handleInput: (audioData: string, duration: number) => ToolResult;
9
+ }
10
+
11
+ export declare type BackendType = "textLLM" | "imageGen" | "audio" | "search" | "browse" | "map" | "mulmocast";
12
+
13
+ declare interface BaseFieldSchema {
14
+ label: string;
15
+ description?: string;
16
+ required?: boolean;
17
+ }
18
+
19
+ export declare interface BooleanFieldSchema extends BaseFieldSchema {
20
+ type: "boolean";
21
+ }
22
+
23
+ /**
24
+ * Camera capture input handler
25
+ */
26
+ export declare interface CameraInputHandler {
27
+ type: "camera";
28
+ mode: "photo" | "video";
29
+ handleInput: (data: string, metadata?: {
30
+ duration?: number;
31
+ }) => ToolResult;
32
+ }
33
+
34
+ /**
35
+ * Clipboard image input handler
36
+ */
37
+ export declare interface ClipboardImageInputHandler {
38
+ type: "clipboard-image";
39
+ handleInput: (imageData: string) => ToolResult;
40
+ }
41
+
42
+ export declare type ConfigFieldSchema = StringFieldSchema | NumberFieldSchema | BooleanFieldSchema | SelectFieldSchema | MultiSelectFieldSchema;
43
+
44
+ export declare type ConfigValue = string | number | boolean | string[];
45
+
46
+ /**
47
+ * Base interface for custom input handlers
48
+ * Apps can extend this to create their own handler types
49
+ */
50
+ export declare interface CustomInputHandler {
51
+ type: string;
52
+ handleInput: (...args: unknown[]) => ToolResult;
53
+ }
54
+
55
+ /**
56
+ * File input handler
57
+ */
58
+ export declare interface FileInputHandler {
59
+ type: "file";
60
+ acceptedTypes: string[];
61
+ handleInput: (fileData: string, fileName: string) => ToolResult;
62
+ }
63
+
64
+ /**
65
+ * Union of all input handler types
66
+ */
67
+ export declare type InputHandler = FileInputHandler | ClipboardImageInputHandler | UrlInputHandler | TextInputHandler | CameraInputHandler | AudioInputHandler;
68
+
69
+ /**
70
+ * Schema Types (Framework-agnostic)
71
+ *
72
+ * JSON Schema based types for tool definitions and plugin settings.
73
+ */
74
+ /**
75
+ * JSON Schema property definition
76
+ */
77
+ export declare interface JsonSchemaProperty {
78
+ type?: string;
79
+ description?: string;
80
+ enum?: string[];
81
+ items?: JsonSchemaProperty;
82
+ minimum?: number;
83
+ maximum?: number;
84
+ minItems?: number;
85
+ maxItems?: number;
86
+ properties?: Record<string, JsonSchemaProperty>;
87
+ required?: string[];
88
+ additionalProperties?: boolean;
89
+ oneOf?: JsonSchemaProperty[];
90
+ [key: string]: unknown;
91
+ }
92
+
93
+ export declare interface MultiSelectFieldSchema extends BaseFieldSchema {
94
+ type: "multiselect";
95
+ options: SelectOption[];
96
+ minItems?: number;
97
+ maxItems?: number;
98
+ }
99
+
100
+ export declare interface NumberFieldSchema extends BaseFieldSchema {
101
+ type: "number";
102
+ min?: number;
103
+ max?: number;
104
+ step?: number;
105
+ }
106
+
107
+ /**
108
+ * Plugin configuration schema (JSON Schema based)
109
+ */
110
+ export declare interface PluginConfigSchema {
111
+ key: string;
112
+ defaultValue: ConfigValue;
113
+ schema: ConfigFieldSchema;
114
+ }
115
+
116
+ /**
117
+ * Standard props for Preview components
118
+ */
119
+ export declare interface PreviewComponentProps<T = unknown, J = unknown> {
120
+ result: ToolResultComplete<T, J>;
121
+ isSelected?: boolean;
122
+ onSelect?: () => void;
123
+ }
124
+
125
+ export declare interface SelectFieldSchema extends BaseFieldSchema {
126
+ type: "select";
127
+ options: SelectOption[];
128
+ }
129
+
130
+ export declare interface SelectOption {
131
+ value: string;
132
+ label: string;
133
+ description?: string;
134
+ disabled?: boolean;
135
+ }
136
+
137
+ export declare interface StringFieldSchema extends BaseFieldSchema {
138
+ type: "string";
139
+ placeholder?: string;
140
+ minLength?: number;
141
+ maxLength?: number;
142
+ pattern?: string;
143
+ }
144
+
145
+ /**
146
+ * Text input handler
147
+ */
148
+ export declare interface TextInputHandler {
149
+ type: "text";
150
+ patterns?: string[];
151
+ handleInput: (text: string) => ToolResult;
152
+ }
153
+
154
+ /**
155
+ * Context passed to plugin execute function
156
+ */
157
+ export declare interface ToolContext {
158
+ currentResult?: ToolResult<unknown> | null;
159
+ app?: ToolContextApp;
160
+ }
161
+
162
+ /**
163
+ * App interface provided to plugins via context.app
164
+ * Contains backend functions and config accessors
165
+ */
166
+ export declare interface ToolContextApp extends Record<string, (...args: any[]) => any> {
167
+ getConfig: <T = unknown>(key: string) => T | undefined;
168
+ setConfig: (key: string, value: unknown) => void;
169
+ }
170
+
171
+ /**
172
+ * Tool definition for OpenAI-compatible function calling
173
+ */
174
+ export declare interface ToolDefinition {
175
+ type: "function";
176
+ name: string;
177
+ description: string;
178
+ parameters?: {
179
+ type: "object";
180
+ properties: Record<string, JsonSchemaProperty>;
181
+ required: string[];
182
+ additionalProperties?: boolean;
183
+ };
184
+ }
185
+
186
+ /**
187
+ * Core plugin interface - framework agnostic
188
+ * Does not include UI components
189
+ *
190
+ * @typeParam T - Tool-specific data type (for views)
191
+ * @typeParam J - JSON data type (passed to LLM)
192
+ * @typeParam A - Arguments type for execute function
193
+ * @typeParam H - Input handler type (allows custom handlers)
194
+ * @typeParam S - Start response type (app-specific server response)
195
+ */
196
+ export declare interface ToolPluginCore<T = unknown, J = unknown, A extends object = object, H = InputHandler, S = Record<string, unknown>> {
197
+ toolDefinition: ToolDefinition;
198
+ execute: (context: ToolContext, args: A) => Promise<ToolResult<T, J>>;
199
+ generatingMessage: string;
200
+ waitingMessage?: string;
201
+ uploadMessage?: string;
202
+ isEnabled: (startResponse?: S | null) => boolean;
203
+ delayAfterExecution?: number;
204
+ systemPrompt?: string;
205
+ inputHandlers?: H[];
206
+ configSchema?: PluginConfigSchema;
207
+ samples?: ToolSample[];
208
+ backends?: BackendType[];
209
+ }
210
+
211
+ /**
212
+ * React plugin interface - extends core with React components
213
+ *
214
+ * @typeParam T - Tool-specific data type (for views)
215
+ * @typeParam J - JSON data type (passed to LLM)
216
+ * @typeParam A - Arguments type for execute function
217
+ * @typeParam H - Input handler type (allows custom handlers)
218
+ * @typeParam S - Start response type (app-specific server response)
219
+ */
220
+ export declare interface ToolPluginReact<T = unknown, J = unknown, A extends object = object, H = InputHandler, S = Record<string, unknown>> extends ToolPluginCore<T, J, A, H, S> {
221
+ ViewComponent?: ComponentType<ViewComponentProps<T, J>>;
222
+ PreviewComponent?: ComponentType<PreviewComponentProps<T, J>>;
223
+ }
224
+
225
+ /**
226
+ * Result returned from plugin execution
227
+ */
228
+ export declare interface ToolResult<T = unknown, J = unknown> {
229
+ toolName?: string;
230
+ uuid?: string;
231
+ message: string;
232
+ title?: string;
233
+ jsonData?: J;
234
+ instructions?: string;
235
+ instructionsRequired?: boolean;
236
+ updating?: boolean;
237
+ cancelled?: boolean;
238
+ data?: T;
239
+ viewState?: Record<string, unknown>;
240
+ }
241
+
242
+ /**
243
+ * Complete tool result with required fields
244
+ */
245
+ export declare interface ToolResultComplete<T = unknown, J = unknown> extends ToolResult<T, J> {
246
+ toolName: string;
247
+ uuid: string;
248
+ }
249
+
250
+ /**
251
+ * Sample arguments for testing
252
+ */
253
+ export declare interface ToolSample {
254
+ name: string;
255
+ args: Record<string, unknown>;
256
+ }
257
+
258
+ /**
259
+ * URL input handler
260
+ */
261
+ export declare interface UrlInputHandler {
262
+ type: "url";
263
+ patterns?: string[];
264
+ handleInput: (url: string) => ToolResult;
265
+ }
266
+
267
+ /**
268
+ * Standard props for View components
269
+ */
270
+ export declare interface ViewComponentProps<T = unknown, J = unknown> {
271
+ selectedResult: ToolResultComplete<T, J>;
272
+ sendTextMessage: (text?: string) => void;
273
+ onUpdateResult?: (result: Partial<ToolResult<T, J>>) => void;
274
+ pluginConfigs?: Record<string, unknown>;
275
+ }
276
+
277
+ export { }
package/dist/react.js ADDED
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/vue.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=vue.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vue.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/vue.d.ts ADDED
@@ -0,0 +1,297 @@
1
+ import { Component } from 'vue';
2
+
3
+ /**
4
+ * Audio input handler
5
+ */
6
+ export declare interface AudioInputHandler {
7
+ type: "audio";
8
+ handleInput: (audioData: string, duration: number) => ToolResult;
9
+ }
10
+
11
+ export declare type BackendType = "textLLM" | "imageGen" | "audio" | "search" | "browse" | "map" | "mulmocast";
12
+
13
+ declare interface BaseFieldSchema {
14
+ label: string;
15
+ description?: string;
16
+ required?: boolean;
17
+ }
18
+
19
+ export declare interface BooleanFieldSchema extends BaseFieldSchema {
20
+ type: "boolean";
21
+ }
22
+
23
+ /**
24
+ * Camera capture input handler
25
+ */
26
+ export declare interface CameraInputHandler {
27
+ type: "camera";
28
+ mode: "photo" | "video";
29
+ handleInput: (data: string, metadata?: {
30
+ duration?: number;
31
+ }) => ToolResult;
32
+ }
33
+
34
+ /**
35
+ * Clipboard image input handler
36
+ */
37
+ export declare interface ClipboardImageInputHandler {
38
+ type: "clipboard-image";
39
+ handleInput: (imageData: string) => ToolResult;
40
+ }
41
+
42
+ export declare type ConfigFieldSchema = StringFieldSchema | NumberFieldSchema | BooleanFieldSchema | SelectFieldSchema | MultiSelectFieldSchema;
43
+
44
+ export declare type ConfigValue = string | number | boolean | string[];
45
+
46
+ /**
47
+ * Base interface for custom input handlers
48
+ * Apps can extend this to create their own handler types
49
+ */
50
+ export declare interface CustomInputHandler {
51
+ type: string;
52
+ handleInput: (...args: unknown[]) => ToolResult;
53
+ }
54
+
55
+ /**
56
+ * File input handler
57
+ */
58
+ export declare interface FileInputHandler {
59
+ type: "file";
60
+ acceptedTypes: string[];
61
+ handleInput: (fileData: string, fileName: string) => ToolResult;
62
+ }
63
+
64
+ /**
65
+ * Union of all input handler types
66
+ */
67
+ export declare type InputHandler = FileInputHandler | ClipboardImageInputHandler | UrlInputHandler | TextInputHandler | CameraInputHandler | AudioInputHandler;
68
+
69
+ /**
70
+ * Schema Types (Framework-agnostic)
71
+ *
72
+ * JSON Schema based types for tool definitions and plugin settings.
73
+ */
74
+ /**
75
+ * JSON Schema property definition
76
+ */
77
+ export declare interface JsonSchemaProperty {
78
+ type?: string;
79
+ description?: string;
80
+ enum?: string[];
81
+ items?: JsonSchemaProperty;
82
+ minimum?: number;
83
+ maximum?: number;
84
+ minItems?: number;
85
+ maxItems?: number;
86
+ properties?: Record<string, JsonSchemaProperty>;
87
+ required?: string[];
88
+ additionalProperties?: boolean;
89
+ oneOf?: JsonSchemaProperty[];
90
+ [key: string]: unknown;
91
+ }
92
+
93
+ export declare interface MultiSelectFieldSchema extends BaseFieldSchema {
94
+ type: "multiselect";
95
+ options: SelectOption[];
96
+ minItems?: number;
97
+ maxItems?: number;
98
+ }
99
+
100
+ export declare interface NumberFieldSchema extends BaseFieldSchema {
101
+ type: "number";
102
+ min?: number;
103
+ max?: number;
104
+ step?: number;
105
+ }
106
+
107
+ /**
108
+ * Plugin configuration schema (JSON Schema based)
109
+ */
110
+ export declare interface PluginConfigSchema {
111
+ key: string;
112
+ defaultValue: ConfigValue;
113
+ schema: ConfigFieldSchema;
114
+ }
115
+
116
+ /**
117
+ * Standard props for Preview components
118
+ */
119
+ export declare interface PreviewComponentProps<T = unknown, J = unknown> {
120
+ result: ToolResultComplete<T, J>;
121
+ isSelected?: boolean;
122
+ onSelect?: () => void;
123
+ }
124
+
125
+ export declare interface SelectFieldSchema extends BaseFieldSchema {
126
+ type: "select";
127
+ options: SelectOption[];
128
+ }
129
+
130
+ export declare interface SelectOption {
131
+ value: string;
132
+ label: string;
133
+ description?: string;
134
+ disabled?: boolean;
135
+ }
136
+
137
+ export declare interface StringFieldSchema extends BaseFieldSchema {
138
+ type: "string";
139
+ placeholder?: string;
140
+ minLength?: number;
141
+ maxLength?: number;
142
+ pattern?: string;
143
+ }
144
+
145
+ /**
146
+ * Text input handler
147
+ */
148
+ export declare interface TextInputHandler {
149
+ type: "text";
150
+ patterns?: string[];
151
+ handleInput: (text: string) => ToolResult;
152
+ }
153
+
154
+ /**
155
+ * Context passed to plugin execute function
156
+ */
157
+ export declare interface ToolContext {
158
+ currentResult?: ToolResult<unknown> | null;
159
+ app?: ToolContextApp;
160
+ }
161
+
162
+ /**
163
+ * App interface provided to plugins via context.app
164
+ * Contains backend functions and config accessors
165
+ */
166
+ export declare interface ToolContextApp extends Record<string, (...args: any[]) => any> {
167
+ getConfig: <T = unknown>(key: string) => T | undefined;
168
+ setConfig: (key: string, value: unknown) => void;
169
+ }
170
+
171
+ /**
172
+ * Tool definition for OpenAI-compatible function calling
173
+ */
174
+ export declare interface ToolDefinition {
175
+ type: "function";
176
+ name: string;
177
+ description: string;
178
+ parameters?: {
179
+ type: "object";
180
+ properties: Record<string, JsonSchemaProperty>;
181
+ required: string[];
182
+ additionalProperties?: boolean;
183
+ };
184
+ }
185
+
186
+ /**
187
+ * Vue plugin interface - extends core with Vue components
188
+ *
189
+ * @typeParam T - Tool-specific data type (for views)
190
+ * @typeParam J - JSON data type (passed to LLM)
191
+ * @typeParam A - Arguments type for execute function
192
+ * @typeParam H - Input handler type (allows custom handlers)
193
+ * @typeParam S - Start response type (app-specific server response)
194
+ */
195
+ export declare interface ToolPlugin<T = unknown, J = unknown, A extends object = object, H = InputHandler, S = Record<string, unknown>> extends ToolPluginCore<T, J, A, H, S> {
196
+ viewComponent?: Component;
197
+ previewComponent?: Component;
198
+ /**
199
+ * Legacy Vue component-based config (for backward compatibility)
200
+ * @deprecated Use configSchema (PluginConfigSchema) instead
201
+ */
202
+ config?: ToolPluginConfig;
203
+ }
204
+
205
+ /**
206
+ * Legacy Vue component-based config
207
+ * @deprecated Use PluginConfigSchema instead
208
+ */
209
+ export declare interface ToolPluginConfig {
210
+ key: string;
211
+ defaultValue: unknown;
212
+ component: Component;
213
+ }
214
+
215
+ /**
216
+ * Core plugin interface - framework agnostic
217
+ * Does not include UI components
218
+ *
219
+ * @typeParam T - Tool-specific data type (for views)
220
+ * @typeParam J - JSON data type (passed to LLM)
221
+ * @typeParam A - Arguments type for execute function
222
+ * @typeParam H - Input handler type (allows custom handlers)
223
+ * @typeParam S - Start response type (app-specific server response)
224
+ */
225
+ export declare interface ToolPluginCore<T = unknown, J = unknown, A extends object = object, H = InputHandler, S = Record<string, unknown>> {
226
+ toolDefinition: ToolDefinition;
227
+ execute: (context: ToolContext, args: A) => Promise<ToolResult<T, J>>;
228
+ generatingMessage: string;
229
+ waitingMessage?: string;
230
+ uploadMessage?: string;
231
+ isEnabled: (startResponse?: S | null) => boolean;
232
+ delayAfterExecution?: number;
233
+ systemPrompt?: string;
234
+ inputHandlers?: H[];
235
+ configSchema?: PluginConfigSchema;
236
+ samples?: ToolSample[];
237
+ backends?: BackendType[];
238
+ }
239
+
240
+ /**
241
+ * Alias for ToolPlugin (Vue-specific)
242
+ */
243
+ export declare type ToolPluginVue<T = unknown, J = unknown, A extends object = object, H = InputHandler, S = Record<string, unknown>> = ToolPlugin<T, J, A, H, S>;
244
+
245
+ /**
246
+ * Result returned from plugin execution
247
+ */
248
+ export declare interface ToolResult<T = unknown, J = unknown> {
249
+ toolName?: string;
250
+ uuid?: string;
251
+ message: string;
252
+ title?: string;
253
+ jsonData?: J;
254
+ instructions?: string;
255
+ instructionsRequired?: boolean;
256
+ updating?: boolean;
257
+ cancelled?: boolean;
258
+ data?: T;
259
+ viewState?: Record<string, unknown>;
260
+ }
261
+
262
+ /**
263
+ * Complete tool result with required fields
264
+ */
265
+ export declare interface ToolResultComplete<T = unknown, J = unknown> extends ToolResult<T, J> {
266
+ toolName: string;
267
+ uuid: string;
268
+ }
269
+
270
+ /**
271
+ * Sample arguments for testing
272
+ */
273
+ export declare interface ToolSample {
274
+ name: string;
275
+ args: Record<string, unknown>;
276
+ }
277
+
278
+ /**
279
+ * URL input handler
280
+ */
281
+ export declare interface UrlInputHandler {
282
+ type: "url";
283
+ patterns?: string[];
284
+ handleInput: (url: string) => ToolResult;
285
+ }
286
+
287
+ /**
288
+ * Standard props for View components
289
+ */
290
+ export declare interface ViewComponentProps<T = unknown, J = unknown> {
291
+ selectedResult: ToolResultComplete<T, J>;
292
+ sendTextMessage: (text?: string) => void;
293
+ onUpdateResult?: (result: Partial<ToolResult<T, J>>) => void;
294
+ pluginConfigs?: Record<string, unknown>;
295
+ }
296
+
297
+ export { }
package/dist/vue.js ADDED
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vue.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "gui-chat-protocol",
3
+ "version": "0.0.1",
4
+ "description": "Protocol types for GUI chat plugins - framework-agnostic core with Vue and React adapters",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.cjs"
11
+ },
12
+ "./vue": {
13
+ "types": "./dist/vue.d.ts",
14
+ "import": "./dist/vue.js",
15
+ "require": "./dist/vue.cjs"
16
+ },
17
+ "./react": {
18
+ "types": "./dist/react.d.ts",
19
+ "import": "./dist/react.js",
20
+ "require": "./dist/react.cjs"
21
+ }
22
+ },
23
+ "main": "./dist/index.cjs",
24
+ "module": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "scripts": {
30
+ "build": "vite build",
31
+ "typecheck": "tsc --noEmit"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "^18.0.0 || ^19.0.0",
35
+ "vue": "^3.5.0"
36
+ },
37
+ "peerDependenciesMeta": {
38
+ "vue": {
39
+ "optional": true
40
+ },
41
+ "react": {
42
+ "optional": true
43
+ }
44
+ },
45
+ "devDependencies": {
46
+ "@types/react": "^19.0.0",
47
+ "react": "^19.0.0",
48
+ "typescript": "^5.9.3",
49
+ "vite": "^7.3.1",
50
+ "vite-plugin-dts": "^4.5.4",
51
+ "vue": "^3.5.26"
52
+ },
53
+ "keywords": [
54
+ "gui-chat",
55
+ "plugin",
56
+ "protocol",
57
+ "vue",
58
+ "react",
59
+ "typescript"
60
+ ],
61
+ "license": "MIT",
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "https://github.com/receptron/gui-chat-protocol.git"
65
+ }
66
+ }