@elizaos/plugin-form 2.0.0-alpha.3 → 2.0.0-alpha.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/dist/index.d.ts CHANGED
@@ -1,174 +1,2 @@
1
- /**
2
- * @module @elizaos/plugin-form
3
- * @description Guardrails for agent-guided user journeys
4
- *
5
- * @author Odilitime
6
- * @copyright 2025 Odilitime
7
- * @license MIT
8
- *
9
- * ## The Core Insight
10
- *
11
- * Forms aren't just about data collection - they're **guardrails for agents**.
12
- *
13
- * Without structure, agents wander. They forget context, miss required
14
- * information, and can't reliably guide users to outcomes. This plugin
15
- * gives agents the tools to follow conventions and shepherd users through
16
- * structured journeys - registrations, orders, applications, onboarding flows.
17
- *
18
- * **Forms define the path. Agents follow it. Users reach outcomes.**
19
- *
20
- * ## Key Features
21
- *
22
- * - **Natural Language Extraction**: "I'm John, 25, john@example.com"
23
- * - **Two-Tier Intent Detection**: Fast English keywords + LLM fallback
24
- * - **UX Magic**: Undo, skip, explain, example, progress, autofill
25
- * - **Smart TTL**: Retention scales with user effort
26
- * - **Fluent Builder API**: Type-safe form definitions
27
- * - **Extensible Types**: Register custom field types
28
- *
29
- * ## Architecture
30
- *
31
- * ```
32
- * ┌─────────────────────────────────────────────────────────────┐
33
- * │ Form Plugin │
34
- * ├─────────────────────────────────────────────────────────────┤
35
- * │ │
36
- * │ Provider (FORM_CONTEXT) │
37
- * │ - Runs BEFORE agent responds │
38
- * │ - Injects form state into context │
39
- * │ - Tells agent what to ask next │
40
- * │ │
41
- * │ Evaluator (form_evaluator) │
42
- * │ - Runs AFTER each user message │
43
- * │ - Detects intent (submit, cancel, undo, etc.) │
44
- * │ - Extracts field values from natural language │
45
- * │ - Updates session state │
46
- * │ │
47
- * │ Action (FORM_RESTORE) │
48
- * │ - Preempts REPLY for restore intent │
49
- * │ - Immediately restores stashed forms │
50
- * │ │
51
- * │ Service (FormService) │
52
- * │ - Manages form definitions │
53
- * │ - Manages sessions, submissions, autofill │
54
- * │ - Executes lifecycle hooks │
55
- * │ │
56
- * └─────────────────────────────────────────────────────────────┘
57
- * ```
58
- *
59
- * ## Quick Start
60
- *
61
- * ### 1. Add plugin to your agent
62
- *
63
- * ```typescript
64
- * import { formPlugin } from '@elizaos/plugin-form';
65
- *
66
- * const agent = {
67
- * plugins: [formPlugin, ...otherPlugins],
68
- * };
69
- * ```
70
- *
71
- * ### 2. Define a form
72
- *
73
- * ```typescript
74
- * import { Form, C } from '@elizaos/plugin-form';
75
- *
76
- * const registrationForm = Form.create('registration')
77
- * .name('User Registration')
78
- * .control(C.email('email').required().ask('What email should we use?'))
79
- * .control(C.text('name').required().ask("What's your name?"))
80
- * .control(C.number('age').min(13))
81
- * .onSubmit('handle_registration')
82
- * .build();
83
- * ```
84
- *
85
- * ### 3. Register and start
86
- *
87
- * ```typescript
88
- * // In your plugin init:
89
- * const formService = runtime.getService('FORM') as FormService;
90
- * formService.registerForm(registrationForm);
91
- *
92
- * // When you need to collect data:
93
- * await formService.startSession('registration', entityId, roomId);
94
- * ```
95
- *
96
- * ### 4. Handle submissions
97
- *
98
- * ```typescript
99
- * runtime.registerTaskWorker({
100
- * name: 'handle_registration',
101
- * execute: async (runtime, options) => {
102
- * const { submission } = options;
103
- * const { email, name, age } = submission.values;
104
- * // Create user account, etc.
105
- * }
106
- * });
107
- * ```
108
- *
109
- * ## User Experience
110
- *
111
- * The form plugin handles these user interactions:
112
- *
113
- * | User Says | Intent | Result |
114
- * |-----------|--------|--------|
115
- * | "I'm John, 25 years old" | fill_form | Extract name=John, age=25 |
116
- * | "done" / "submit" | submit | Submit the form |
117
- * | "save for later" | stash | Save and switch contexts |
118
- * | "resume my form" | restore | Restore stashed form |
119
- * | "cancel" / "nevermind" | cancel | Abandon form |
120
- * | "undo" / "go back" | undo | Revert last change |
121
- * | "skip" | skip | Skip optional field |
122
- * | "why?" | explain | Explain current field |
123
- * | "example?" | example | Show example value |
124
- * | "how far?" | progress | Show completion status |
125
- * | "same as last time" | autofill | Use saved values |
126
- *
127
- * ## Module Exports
128
- *
129
- * - **Types**: FormControl, FormDefinition, FormSession, etc.
130
- * - **Builder**: Form, C (ControlBuilder)
131
- * - **Service**: FormService
132
- * - **Utilities**: validateField, parseValue, formatValue
133
- * - **Plugin**: formPlugin (default export)
134
- *
135
- * @see {@link FormService} for form management API
136
- * @see {@link FormBuilder} for fluent form definition
137
- * @see {@link ControlBuilder} for field definition
138
- */
139
- import type { Plugin } from "@elizaos/core";
140
- export * from "./types";
141
- export { BUILTIN_TYPES, BUILTIN_TYPE_MAP, registerBuiltinTypes, getBuiltinType, isBuiltinType, } from "./builtins";
142
- export { validateField, formatValue, parseValue, matchesMimeType, } from "./validation";
143
- export { registerTypeHandler, getTypeHandler, clearTypeHandlers, } from "./validation";
144
- export { quickIntentDetect, isLifecycleIntent, isUXIntent, hasDataToExtract, } from "./intent";
145
- export { getActiveSession, getAllActiveSessions, getStashedSessions, saveSession, deleteSession, saveSubmission, getSubmissions, getAutofillData, saveAutofillData, } from "./storage";
146
- export { llmIntentAndExtract, extractSingleField, detectCorrection, } from "./extraction";
147
- export { calculateTTL, shouldNudge, isExpiringSoon, isExpired, shouldConfirmCancel, formatTimeRemaining, formatEffort, } from "./ttl";
148
- export { applyControlDefaults, applyFormDefaults, prettify } from "./defaults";
149
- export { FormBuilder, ControlBuilder, Form, C } from "./builder";
150
- export { FormService } from "./service";
151
- export { formContextProvider } from "./providers/context";
152
- export { formEvaluator } from "./evaluators/extractor";
153
- export { formRestoreAction } from "./actions/restore";
154
- /**
155
- * Form Plugin
156
- *
157
- * Infrastructure plugin for collecting structured data through natural conversation.
158
- *
159
- * Architecture:
160
- * - Provider: Injects form state into agent context before response
161
- * - Evaluator: Extracts fields and handles intents after response
162
- * - Action: Fast-path restore for stashed forms
163
- * - Service: Manages form definitions, sessions, and submissions
164
- *
165
- * Usage:
166
- * 1. Register form definitions via FormService.registerForm()
167
- * 2. Start sessions via FormService.startSession()
168
- * 3. The evaluator automatically extracts field values from user messages
169
- * 4. The provider gives the agent context about what to ask next
170
- * 5. The agent (via REPLY) handles the conversation naturally
171
- */
172
- export declare const formPlugin: Plugin;
173
- export default formPlugin;
174
- //# sourceMappingURL=index.d.ts.map
1
+ export * from "./index";
2
+ export { default } from "./index";