@leanmcp/elicitation 0.1.4-alpha.1.2daa577 → 0.1.4-alpha.3.0eaae8f
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 +76 -70
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,32 +52,32 @@ npm install @leanmcp/elicitation @leanmcp/core
|
|
|
52
52
|
### Simple Form Elicitation
|
|
53
53
|
|
|
54
54
|
```typescript
|
|
55
|
-
import { Tool } from
|
|
56
|
-
import { Elicitation } from
|
|
55
|
+
import { Tool } from '@leanmcp/core';
|
|
56
|
+
import { Elicitation } from '@leanmcp/elicitation';
|
|
57
57
|
|
|
58
58
|
class SlackService {
|
|
59
|
-
@Tool({ description:
|
|
59
|
+
@Tool({ description: 'Create a new Slack channel' })
|
|
60
60
|
@Elicitation({
|
|
61
|
-
title:
|
|
62
|
-
description:
|
|
61
|
+
title: 'Create Channel',
|
|
62
|
+
description: 'Please provide channel details',
|
|
63
63
|
fields: [
|
|
64
64
|
{
|
|
65
|
-
name:
|
|
66
|
-
label:
|
|
67
|
-
type:
|
|
65
|
+
name: 'channelName',
|
|
66
|
+
label: 'Channel Name',
|
|
67
|
+
type: 'text',
|
|
68
68
|
required: true,
|
|
69
69
|
validation: {
|
|
70
|
-
pattern:
|
|
71
|
-
errorMessage:
|
|
72
|
-
}
|
|
70
|
+
pattern: '^[a-z0-9-]+$',
|
|
71
|
+
errorMessage: 'Must be lowercase alphanumeric with hyphens',
|
|
72
|
+
},
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
|
-
name:
|
|
76
|
-
label:
|
|
77
|
-
type:
|
|
78
|
-
defaultValue: false
|
|
79
|
-
}
|
|
80
|
-
]
|
|
75
|
+
name: 'isPrivate',
|
|
76
|
+
label: 'Private Channel',
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
defaultValue: false,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
81
|
})
|
|
82
82
|
async createChannel(args: { channelName: string; isPrivate: boolean }) {
|
|
83
83
|
return { success: true, channelName: args.channelName };
|
|
@@ -101,29 +101,26 @@ class SlackService {
|
|
|
101
101
|
For more complex forms, use `ElicitationFormBuilder`:
|
|
102
102
|
|
|
103
103
|
```typescript
|
|
104
|
-
import { Tool } from
|
|
105
|
-
import { Elicitation, ElicitationFormBuilder, validation } from
|
|
104
|
+
import { Tool } from '@leanmcp/core';
|
|
105
|
+
import { Elicitation, ElicitationFormBuilder, validation } from '@leanmcp/elicitation';
|
|
106
106
|
|
|
107
107
|
class UserService {
|
|
108
|
-
@Tool({ description:
|
|
108
|
+
@Tool({ description: 'Create user account' })
|
|
109
109
|
@Elicitation({
|
|
110
|
-
builder: () =>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
.minLength(3)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{ label: "User", value: "user" }
|
|
125
|
-
])
|
|
126
|
-
.build()
|
|
110
|
+
builder: () =>
|
|
111
|
+
new ElicitationFormBuilder()
|
|
112
|
+
.title('User Registration')
|
|
113
|
+
.description('Create a new user account')
|
|
114
|
+
.addEmailField('email', 'Email Address', { required: true })
|
|
115
|
+
.addTextField('username', 'Username', {
|
|
116
|
+
required: true,
|
|
117
|
+
validation: validation().minLength(3).maxLength(20).pattern('^[a-zA-Z0-9_]+$').build(),
|
|
118
|
+
})
|
|
119
|
+
.addSelectField('role', 'Role', [
|
|
120
|
+
{ label: 'Admin', value: 'admin' },
|
|
121
|
+
{ label: 'User', value: 'user' },
|
|
122
|
+
])
|
|
123
|
+
.build(),
|
|
127
124
|
})
|
|
128
125
|
async createUser(args: any) {
|
|
129
126
|
return { success: true, email: args.email };
|
|
@@ -133,22 +130,22 @@ class UserService {
|
|
|
133
130
|
|
|
134
131
|
### Builder Methods
|
|
135
132
|
|
|
136
|
-
| Method
|
|
137
|
-
|
|
138
|
-
| `title(string)`
|
|
139
|
-
| `description(string)`
|
|
140
|
-
| `condition(fn)`
|
|
141
|
-
| `addTextField(name, label, opts?)`
|
|
142
|
-
| `addTextAreaField(name, label, opts?)`
|
|
143
|
-
| `addNumberField(name, label, opts?)`
|
|
144
|
-
| `addBooleanField(name, label, opts?)`
|
|
145
|
-
| `addSelectField(name, label, options, opts?)`
|
|
146
|
-
| `addMultiSelectField(name, label, options, opts?)` | Add multi-select
|
|
147
|
-
| `addEmailField(name, label, opts?)`
|
|
148
|
-
| `addUrlField(name, label, opts?)`
|
|
149
|
-
| `addDateField(name, label, opts?)`
|
|
150
|
-
| `addCustomField(field)`
|
|
151
|
-
| `build()`
|
|
133
|
+
| Method | Description |
|
|
134
|
+
| -------------------------------------------------- | ----------------------------- |
|
|
135
|
+
| `title(string)` | Set form title |
|
|
136
|
+
| `description(string)` | Set form description |
|
|
137
|
+
| `condition(fn)` | Set condition for elicitation |
|
|
138
|
+
| `addTextField(name, label, opts?)` | Add text input |
|
|
139
|
+
| `addTextAreaField(name, label, opts?)` | Add textarea |
|
|
140
|
+
| `addNumberField(name, label, opts?)` | Add number input |
|
|
141
|
+
| `addBooleanField(name, label, opts?)` | Add checkbox |
|
|
142
|
+
| `addSelectField(name, label, options, opts?)` | Add dropdown |
|
|
143
|
+
| `addMultiSelectField(name, label, options, opts?)` | Add multi-select |
|
|
144
|
+
| `addEmailField(name, label, opts?)` | Add email input |
|
|
145
|
+
| `addUrlField(name, label, opts?)` | Add URL input |
|
|
146
|
+
| `addDateField(name, label, opts?)` | Add date picker |
|
|
147
|
+
| `addCustomField(field)` | Add custom field |
|
|
148
|
+
| `build()` | Build final config |
|
|
152
149
|
|
|
153
150
|
---
|
|
154
151
|
|
|
@@ -228,17 +225,17 @@ async deployApp(args: any) {
|
|
|
228
225
|
|
|
229
226
|
## Field Types
|
|
230
227
|
|
|
231
|
-
| Type
|
|
232
|
-
|
|
233
|
-
| `text`
|
|
234
|
-
| `textarea`
|
|
235
|
-
| `number`
|
|
236
|
-
| `boolean`
|
|
237
|
-
| `select`
|
|
238
|
-
| `multiselect` | Multi-select
|
|
239
|
-
| `email`
|
|
240
|
-
| `url`
|
|
241
|
-
| `date`
|
|
228
|
+
| Type | Description |
|
|
229
|
+
| ------------- | ------------------------ |
|
|
230
|
+
| `text` | Single-line text input |
|
|
231
|
+
| `textarea` | Multi-line text area |
|
|
232
|
+
| `number` | Numeric input |
|
|
233
|
+
| `boolean` | Checkbox |
|
|
234
|
+
| `select` | Dropdown (single choice) |
|
|
235
|
+
| `multiselect` | Multi-select |
|
|
236
|
+
| `email` | Email input |
|
|
237
|
+
| `url` | URL input |
|
|
238
|
+
| `date` | Date picker |
|
|
242
239
|
|
|
243
240
|
---
|
|
244
241
|
|
|
@@ -263,15 +260,15 @@ async deployApp(args: any) {
|
|
|
263
260
|
### Using ValidationBuilder
|
|
264
261
|
|
|
265
262
|
```typescript
|
|
266
|
-
import { validation } from
|
|
263
|
+
import { validation } from '@leanmcp/elicitation';
|
|
267
264
|
|
|
268
265
|
validation()
|
|
269
266
|
.minLength(8)
|
|
270
267
|
.maxLength(100)
|
|
271
|
-
.pattern(
|
|
272
|
-
.customValidator((value) => value !==
|
|
273
|
-
.errorMessage(
|
|
274
|
-
.build()
|
|
268
|
+
.pattern('^[a-zA-Z0-9]+$')
|
|
269
|
+
.customValidator((value) => value !== 'admin')
|
|
270
|
+
.errorMessage('Invalid input')
|
|
271
|
+
.build();
|
|
275
272
|
```
|
|
276
273
|
|
|
277
274
|
---
|
|
@@ -297,7 +294,16 @@ interface ElicitationConfig {
|
|
|
297
294
|
interface ElicitationField {
|
|
298
295
|
name: string;
|
|
299
296
|
label: string;
|
|
300
|
-
type:
|
|
297
|
+
type:
|
|
298
|
+
| 'text'
|
|
299
|
+
| 'number'
|
|
300
|
+
| 'boolean'
|
|
301
|
+
| 'select'
|
|
302
|
+
| 'multiselect'
|
|
303
|
+
| 'date'
|
|
304
|
+
| 'email'
|
|
305
|
+
| 'url'
|
|
306
|
+
| 'textarea';
|
|
301
307
|
description?: string;
|
|
302
308
|
required?: boolean;
|
|
303
309
|
defaultValue?: any;
|
package/package.json
CHANGED