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