@mulmochat-plugin/form 0.1.1 → 0.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.
@@ -1,130 +0,0 @@
1
- /**
2
- * MulmoChat Plugin Common Types
3
- *
4
- * Core interfaces for building MulmoChat plugins.
5
- * These types are plugin-agnostic and can be used by any plugin implementation.
6
- */
7
- import type { Component } from "vue";
8
- /**
9
- * Context passed to plugin execute function
10
- */
11
- export interface ToolContext {
12
- currentResult?: ToolResult<unknown> | null;
13
- userPreferences?: Record<string, unknown>;
14
- getPluginConfig?: <T = unknown>(key: string) => T | undefined;
15
- /** Backend API functions provided by the host app */
16
- app?: Record<string, (...args: any[]) => any>;
17
- }
18
- /**
19
- * Result returned from plugin execution
20
- */
21
- export interface ToolResult<T = unknown, J = unknown> {
22
- toolName?: string;
23
- uuid?: string;
24
- message: string;
25
- title?: string;
26
- jsonData?: J;
27
- instructions?: string;
28
- instructionsRequired?: boolean;
29
- updating?: boolean;
30
- cancelled?: boolean;
31
- data?: T;
32
- viewState?: Record<string, unknown>;
33
- }
34
- /**
35
- * JSON Schema property definition for tool parameters
36
- */
37
- export interface JsonSchemaProperty {
38
- type?: string;
39
- description?: string;
40
- enum?: string[];
41
- items?: JsonSchemaProperty;
42
- minimum?: number;
43
- maximum?: number;
44
- minItems?: number;
45
- maxItems?: number;
46
- properties?: Record<string, JsonSchemaProperty>;
47
- required?: string[];
48
- additionalProperties?: boolean;
49
- oneOf?: JsonSchemaProperty[];
50
- [key: string]: unknown;
51
- }
52
- /**
53
- * API response from server start endpoint
54
- */
55
- export interface StartApiResponse {
56
- hasOpenAIApiKey?: boolean;
57
- hasAnthropicApiKey?: boolean;
58
- hasGoogleApiKey?: boolean;
59
- [key: string]: unknown;
60
- }
61
- /**
62
- * Tool definition for OpenAI-compatible function calling
63
- */
64
- export interface ToolDefinition {
65
- type: "function";
66
- name: string;
67
- description: string;
68
- parameters?: {
69
- type: "object";
70
- properties: Record<string, JsonSchemaProperty>;
71
- required: string[];
72
- additionalProperties?: boolean;
73
- };
74
- }
75
- /**
76
- * File upload configuration
77
- */
78
- export interface FileUploadConfig {
79
- acceptedTypes: string[];
80
- handleUpload: (fileData: string, fileName: string, ...args: unknown[]) => ToolResult<unknown, unknown>;
81
- }
82
- /**
83
- * Plugin configuration
84
- */
85
- export interface ToolPluginConfig {
86
- key: string;
87
- defaultValue: unknown;
88
- component: Component;
89
- }
90
- /**
91
- * Sample arguments for testing
92
- */
93
- export interface ToolSample {
94
- name: string;
95
- args: Record<string, unknown>;
96
- }
97
- /**
98
- * Main plugin interface
99
- * @template T - Type of data stored in result.data
100
- * @template J - Type of data stored in result.jsonData
101
- * @template A - Type of arguments passed to execute
102
- */
103
- export interface ToolPlugin<T = unknown, J = unknown, A extends object = object> {
104
- /** Tool definition for LLM function calling */
105
- toolDefinition: ToolDefinition;
106
- /** Execute the plugin with given context and arguments */
107
- execute: (context: ToolContext, args: A) => Promise<ToolResult<T, J>>;
108
- /** Message shown while generating */
109
- generatingMessage: string;
110
- /** Message shown while waiting for user action */
111
- waitingMessage?: string;
112
- /** Message shown during file upload */
113
- uploadMessage?: string;
114
- /** Check if plugin is enabled based on server capabilities */
115
- isEnabled: (startResponse?: StartApiResponse | null) => boolean;
116
- /** Delay in ms after execution before proceeding */
117
- delayAfterExecution?: number;
118
- /** Vue component for full view */
119
- viewComponent?: Component;
120
- /** Vue component for preview/thumbnail */
121
- previewComponent?: Component;
122
- /** System prompt additions for this plugin */
123
- systemPrompt?: string;
124
- /** Optional file upload configuration */
125
- fileUpload?: FileUploadConfig;
126
- /** Optional plugin-specific configuration */
127
- config?: ToolPluginConfig;
128
- /** Optional sample arguments for testing */
129
- samples?: ToolSample[];
130
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * MulmoChat Form Plugin
3
- *
4
- * A plugin for creating structured forms to collect user information.
5
- *
6
- * @example Basic usage
7
- * ```typescript
8
- * import { plugin } from "@mulmochat-plugin/form";
9
- * import "@mulmochat-plugin/form/style.css";
10
- * // Use plugin directly
11
- * ```
12
- */
13
- import type { ToolPlugin } from "../common";
14
- import { type FormData, type FormArgs } from "./types";
15
- /**
16
- * Form plugin instance
17
- */
18
- export declare const plugin: ToolPlugin<never, FormData, FormArgs>;
@@ -1,5 +0,0 @@
1
- /**
2
- * Form Sample Data
3
- */
4
- import type { ToolSample } from "../common";
5
- export declare const SAMPLES: ToolSample[];
@@ -1,207 +0,0 @@
1
- /**
2
- * Form Tool Definition and Types
3
- */
4
- /** Field type discriminator */
5
- export type FieldType = "text" | "textarea" | "radio" | "dropdown" | "checkbox" | "date" | "time" | "number";
6
- /** Base field interface */
7
- export interface BaseField {
8
- id: string;
9
- type: FieldType;
10
- label: string;
11
- description?: string;
12
- required?: boolean;
13
- maxLength?: number;
14
- }
15
- /** Text field */
16
- export interface TextField extends BaseField {
17
- type: "text";
18
- placeholder?: string;
19
- validation?: "email" | "url" | "phone" | string;
20
- defaultValue?: string;
21
- minLength?: number;
22
- maxLength?: number;
23
- }
24
- /** Textarea field */
25
- export interface TextareaField extends BaseField {
26
- type: "textarea";
27
- placeholder?: string;
28
- minLength?: number;
29
- maxLength?: number;
30
- rows?: number;
31
- defaultValue?: string;
32
- }
33
- /** Radio field */
34
- export interface RadioField extends BaseField {
35
- type: "radio";
36
- choices: string[];
37
- defaultValue?: string;
38
- }
39
- /** Dropdown field */
40
- export interface DropdownField extends BaseField {
41
- type: "dropdown";
42
- choices: string[];
43
- searchable?: boolean;
44
- defaultValue?: string;
45
- }
46
- /** Checkbox field */
47
- export interface CheckboxField extends BaseField {
48
- type: "checkbox";
49
- choices: string[];
50
- minSelections?: number;
51
- maxSelections?: number;
52
- defaultValue?: string[];
53
- }
54
- /** Date field */
55
- export interface DateField extends BaseField {
56
- type: "date";
57
- minDate?: string;
58
- maxDate?: string;
59
- format?: string;
60
- defaultValue?: string;
61
- }
62
- /** Time field */
63
- export interface TimeField extends BaseField {
64
- type: "time";
65
- format?: "12hr" | "24hr";
66
- defaultValue?: string;
67
- }
68
- /** Number field */
69
- export interface NumberField extends BaseField {
70
- type: "number";
71
- min?: number;
72
- max?: number;
73
- step?: number;
74
- defaultValue?: number;
75
- }
76
- /** Union type for all fields */
77
- export type FormField = TextField | TextareaField | RadioField | DropdownField | CheckboxField | DateField | TimeField | NumberField;
78
- /** Form data stored in result.jsonData */
79
- export interface FormData {
80
- title?: string;
81
- description?: string;
82
- fields: FormField[];
83
- }
84
- /** Arguments passed to the form tool */
85
- export interface FormArgs {
86
- title?: string;
87
- description?: string;
88
- fields: FormField[];
89
- }
90
- export declare const TOOL_NAME = "presentForm";
91
- export declare const TOOL_DEFINITION: {
92
- type: "function";
93
- name: string;
94
- description: string;
95
- parameters: {
96
- type: "object";
97
- properties: {
98
- title: {
99
- type: string;
100
- description: string;
101
- };
102
- description: {
103
- type: string;
104
- description: string;
105
- };
106
- fields: {
107
- type: string;
108
- description: string;
109
- items: {
110
- type: string;
111
- properties: {
112
- id: {
113
- type: string;
114
- description: string;
115
- };
116
- type: {
117
- type: string;
118
- enum: string[];
119
- description: string;
120
- };
121
- label: {
122
- type: string;
123
- description: string;
124
- };
125
- description: {
126
- type: string;
127
- description: string;
128
- };
129
- required: {
130
- type: string;
131
- description: string;
132
- };
133
- placeholder: {
134
- type: string;
135
- description: string;
136
- };
137
- validation: {
138
- type: string;
139
- description: string;
140
- };
141
- minLength: {
142
- type: string;
143
- description: string;
144
- };
145
- maxLength: {
146
- type: string;
147
- description: string;
148
- };
149
- rows: {
150
- type: string;
151
- description: string;
152
- };
153
- choices: {
154
- type: string;
155
- items: {
156
- type: string;
157
- };
158
- description: string;
159
- };
160
- searchable: {
161
- type: string;
162
- description: string;
163
- };
164
- minSelections: {
165
- type: string;
166
- description: string;
167
- };
168
- maxSelections: {
169
- type: string;
170
- description: string;
171
- };
172
- minDate: {
173
- type: string;
174
- description: string;
175
- };
176
- maxDate: {
177
- type: string;
178
- description: string;
179
- };
180
- format: {
181
- type: string;
182
- description: string;
183
- };
184
- min: {
185
- type: string;
186
- description: string;
187
- };
188
- max: {
189
- type: string;
190
- description: string;
191
- };
192
- step: {
193
- type: string;
194
- description: string;
195
- };
196
- defaultValue: {
197
- description: string;
198
- };
199
- };
200
- required: string[];
201
- };
202
- minItems: number;
203
- };
204
- };
205
- required: string[];
206
- };
207
- };