@elizaos/plugin-form 2.0.0-alpha.1 → 2.0.0-alpha.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Odilitime
3
+ Copyright (c) 2026 Shaw Walters and elizaOS Contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/index.d.ts CHANGED
@@ -1,175 +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
- export { formNudgeWorker, processEntityNudges } from "./tasks/nudge";
155
- /**
156
- * Form Plugin
157
- *
158
- * Infrastructure plugin for collecting structured data through natural conversation.
159
- *
160
- * Architecture:
161
- * - Provider: Injects form state into agent context before response
162
- * - Evaluator: Extracts fields and handles intents after response
163
- * - Action: Fast-path restore for stashed forms
164
- * - Service: Manages form definitions, sessions, and submissions
165
- *
166
- * Usage:
167
- * 1. Register form definitions via FormService.registerForm()
168
- * 2. Start sessions via FormService.startSession()
169
- * 3. The evaluator automatically extracts field values from user messages
170
- * 4. The provider gives the agent context about what to ask next
171
- * 5. The agent (via REPLY) handles the conversation naturally
172
- */
173
- export declare const formPlugin: Plugin;
174
- export default formPlugin;
175
- //# sourceMappingURL=index.d.ts.map
1
+ export * from "./index";
2
+ export { default } from "./index";
package/package.json CHANGED
@@ -1,13 +1,25 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-form",
3
- "version": "2.0.0-alpha.1",
4
3
  "description": "Guardrails for agent-guided user journeys - forms as agent guidance rails for ElizaOS",
5
- "author": "Odilitime",
6
- "license": "MIT",
4
+ "version": "2.0.0-alpha.2",
7
5
  "type": "module",
8
6
  "main": "dist/index.js",
9
7
  "module": "dist/index.js",
10
8
  "types": "dist/index.d.ts",
9
+ "packageType": "plugin",
10
+ "platform": "node",
11
+ "license": "MIT",
12
+ "author": "Odilitime",
13
+ "keywords": [
14
+ "plugin",
15
+ "elizaos",
16
+ "form",
17
+ "conversational"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/elizaos/eliza"
22
+ },
11
23
  "exports": {
12
24
  "./package.json": "./package.json",
13
25
  ".": {
@@ -19,34 +31,29 @@
19
31
  },
20
32
  "files": [
21
33
  "dist",
22
- "package.json",
23
- "LICENSE"
34
+ "README.md",
35
+ "package.json"
24
36
  ],
25
- "dependencies": {
26
- "@elizaos/core": "2.0.0-alpha.1"
37
+ "peerDependencies": {
38
+ "@elizaos/core": "2.0.0-alpha.2"
27
39
  },
28
40
  "devDependencies": {
29
- "@types/node": "^22.15.3",
30
- "bun-types": "^1.2.21",
31
- "prettier": "3.5.3",
32
- "typescript": "5.8.2"
41
+ "@biomejs/biome": "^2.3.11",
42
+ "@types/node": "^25.0.3",
43
+ "typescript": "^5.9.3"
33
44
  },
34
45
  "scripts": {
46
+ "dev": "bun --hot build.ts",
47
+ "test": "vitest run || echo 'TypeScript tests skipped - no tests found'",
48
+ "lint": "bunx @biomejs/biome check --write --unsafe .",
49
+ "typecheck": "tsc --noEmit",
50
+ "clean": "rm -rf dist .turbo",
51
+ "lint:check": "bunx @biomejs/biome check .",
35
52
  "build": "bun run build.ts",
36
- "dev": "bun run build.ts --watch",
37
- "lint": "prettier --write ./src",
38
- "clean": "rm -rf dist .turbo node_modules .turbo-tsconfig.json tsconfig.tsbuildinfo",
39
- "format": "prettier --write ./src",
40
- "format:check": "prettier --check ./src",
41
- "test": "bun test",
42
- "test:watch": "bun test --watch",
43
- "test:coverage": "bun test --coverage"
44
- },
45
- "peerDependencies": {
46
- "whatwg-url": "7.1.0"
53
+ "build:ts": "bun run build.ts"
47
54
  },
48
55
  "publishConfig": {
49
56
  "access": "public"
50
57
  },
51
- "gitHead": "05d4ca11d769db8c7f54a722ee24b2ce2b951543"
58
+ "gitHead": "bc6cac8d36845d7cbde51a64307c6a57c16378ad"
52
59
  }