@elizaos/plugin-form 2.0.0-alpha.7 → 2.0.0-alpha.8
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.js +120 -19
- package/dist/index.js.map +7 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2005,7 +2005,8 @@ var init_service = __esm(() => {
|
|
|
2005
2005
|
id: session.id,
|
|
2006
2006
|
name: workerName,
|
|
2007
2007
|
roomId: session.roomId,
|
|
2008
|
-
entityId: session.entityId
|
|
2008
|
+
entityId: session.entityId,
|
|
2009
|
+
tags: ["form-hook", hookName]
|
|
2009
2010
|
};
|
|
2010
2011
|
await worker.execute(this.runtime, {
|
|
2011
2012
|
session,
|
|
@@ -2045,24 +2046,45 @@ var init_restore = __esm(() => {
|
|
|
2045
2046
|
name: "FORM_RESTORE",
|
|
2046
2047
|
similes: ["RESUME_FORM", "CONTINUE_FORM"],
|
|
2047
2048
|
description: "Restore a previously stashed form session",
|
|
2048
|
-
validate: async (runtime, message,
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2049
|
+
validate: async (runtime, message, state, options) => {
|
|
2050
|
+
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
2051
|
+
const __avText = __avTextRaw.toLowerCase();
|
|
2052
|
+
const __avKeywords = ["form", "restore"];
|
|
2053
|
+
const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
2054
|
+
const __avRegex = /\b(?:form|restore)\b/i;
|
|
2055
|
+
const __avRegexOk = __avRegex.test(__avText);
|
|
2056
|
+
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
2057
|
+
const __avExpectedSource = "";
|
|
2058
|
+
const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
2059
|
+
const __avOptions = options && typeof options === "object" ? options : {};
|
|
2060
|
+
const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
|
|
2061
|
+
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
2062
|
+
return false;
|
|
2063
|
+
}
|
|
2064
|
+
const __avLegacyValidate = async (runtime2, message2, _state) => {
|
|
2065
|
+
try {
|
|
2066
|
+
const text = message2.content?.text || "";
|
|
2067
|
+
const intent = quickIntentDetect(text);
|
|
2068
|
+
if (intent !== "restore") {
|
|
2069
|
+
return false;
|
|
2070
|
+
}
|
|
2071
|
+
const formService = runtime2.getService("FORM");
|
|
2072
|
+
if (!formService) {
|
|
2073
|
+
return false;
|
|
2074
|
+
}
|
|
2075
|
+
const entityId = message2.entityId;
|
|
2076
|
+
if (!entityId)
|
|
2077
|
+
return false;
|
|
2078
|
+
const stashed = await formService.getStashedSessions(entityId);
|
|
2079
|
+
return stashed.length > 0;
|
|
2080
|
+
} catch (error) {
|
|
2081
|
+
logger2.error("[FormRestoreAction] Validation error:", String(error));
|
|
2057
2082
|
return false;
|
|
2058
2083
|
}
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
return stashed.length > 0;
|
|
2064
|
-
} catch (error) {
|
|
2065
|
-
logger2.error("[FormRestoreAction] Validation error:", String(error));
|
|
2084
|
+
};
|
|
2085
|
+
try {
|
|
2086
|
+
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
2087
|
+
} catch {
|
|
2066
2088
|
return false;
|
|
2067
2089
|
}
|
|
2068
2090
|
},
|
|
@@ -2407,14 +2429,53 @@ __export(exports_context, {
|
|
|
2407
2429
|
formContextProvider: () => formContextProvider,
|
|
2408
2430
|
default: () => context_default
|
|
2409
2431
|
});
|
|
2410
|
-
import { logger as logger4 } from "@elizaos/core";
|
|
2432
|
+
import { logger as logger4, validateActionKeywords, validateActionRegex } from "@elizaos/core";
|
|
2411
2433
|
var formContextProvider, context_default;
|
|
2412
2434
|
var init_context = __esm(() => {
|
|
2413
2435
|
init_template();
|
|
2414
2436
|
formContextProvider = {
|
|
2415
2437
|
name: "FORM_CONTEXT",
|
|
2416
2438
|
description: "Provides context about active form sessions",
|
|
2439
|
+
dynamic: true,
|
|
2440
|
+
relevanceKeywords: [
|
|
2441
|
+
"form",
|
|
2442
|
+
"context",
|
|
2443
|
+
"formcontextprovider",
|
|
2444
|
+
"plugin",
|
|
2445
|
+
"status",
|
|
2446
|
+
"state",
|
|
2447
|
+
"info",
|
|
2448
|
+
"details",
|
|
2449
|
+
"chat",
|
|
2450
|
+
"conversation",
|
|
2451
|
+
"agent",
|
|
2452
|
+
"room",
|
|
2453
|
+
"channel",
|
|
2454
|
+
"user"
|
|
2455
|
+
],
|
|
2417
2456
|
get: async (runtime, message, _state) => {
|
|
2457
|
+
const __providerKeywords = [
|
|
2458
|
+
"form",
|
|
2459
|
+
"context",
|
|
2460
|
+
"formcontextprovider",
|
|
2461
|
+
"plugin",
|
|
2462
|
+
"status",
|
|
2463
|
+
"state",
|
|
2464
|
+
"info",
|
|
2465
|
+
"details",
|
|
2466
|
+
"chat",
|
|
2467
|
+
"conversation",
|
|
2468
|
+
"agent",
|
|
2469
|
+
"room",
|
|
2470
|
+
"channel",
|
|
2471
|
+
"user"
|
|
2472
|
+
];
|
|
2473
|
+
const __providerRegex = new RegExp(`\\b(${__providerKeywords.join("|")})\\b`, "i");
|
|
2474
|
+
const __recentMessages = Array.isArray(_state?.recentMessagesData) ? _state.recentMessagesData : [];
|
|
2475
|
+
const __isRelevant = validateActionKeywords(message, __recentMessages, __providerKeywords) || validateActionRegex(message, __recentMessages, __providerRegex);
|
|
2476
|
+
if (!__isRelevant) {
|
|
2477
|
+
return { text: "" };
|
|
2478
|
+
}
|
|
2418
2479
|
try {
|
|
2419
2480
|
const formService = runtime.getService("FORM");
|
|
2420
2481
|
if (!formService) {
|
|
@@ -2621,6 +2682,7 @@ init_validation();
|
|
|
2621
2682
|
init_storage();
|
|
2622
2683
|
init_extraction();
|
|
2623
2684
|
init_types();
|
|
2685
|
+
import { validateActionKeywords as validateActionKeywords2, validateActionRegex as validateActionRegex2 } from "@elizaos/core";
|
|
2624
2686
|
|
|
2625
2687
|
// src/ttl.ts
|
|
2626
2688
|
init_types();
|
|
@@ -3171,7 +3233,46 @@ var formPlugin = {
|
|
|
3171
3233
|
{
|
|
3172
3234
|
name: "FORM_CONTEXT",
|
|
3173
3235
|
description: "Provides context about active form sessions",
|
|
3236
|
+
dynamic: true,
|
|
3237
|
+
relevanceKeywords: [
|
|
3238
|
+
"form",
|
|
3239
|
+
"context",
|
|
3240
|
+
"inlineprovider1",
|
|
3241
|
+
"plugin",
|
|
3242
|
+
"status",
|
|
3243
|
+
"state",
|
|
3244
|
+
"info",
|
|
3245
|
+
"details",
|
|
3246
|
+
"chat",
|
|
3247
|
+
"conversation",
|
|
3248
|
+
"agent",
|
|
3249
|
+
"room",
|
|
3250
|
+
"channel",
|
|
3251
|
+
"user"
|
|
3252
|
+
],
|
|
3174
3253
|
get: async (runtime, message, state) => {
|
|
3254
|
+
const __providerKeywords = [
|
|
3255
|
+
"form",
|
|
3256
|
+
"context",
|
|
3257
|
+
"inlineprovider1",
|
|
3258
|
+
"plugin",
|
|
3259
|
+
"status",
|
|
3260
|
+
"state",
|
|
3261
|
+
"info",
|
|
3262
|
+
"details",
|
|
3263
|
+
"chat",
|
|
3264
|
+
"conversation",
|
|
3265
|
+
"agent",
|
|
3266
|
+
"room",
|
|
3267
|
+
"channel",
|
|
3268
|
+
"user"
|
|
3269
|
+
];
|
|
3270
|
+
const __providerRegex = new RegExp(`\\b(${__providerKeywords.join("|")})\\b`, "i");
|
|
3271
|
+
const __recentMessages = Array.isArray(state?.recentMessagesData) ? state.recentMessagesData : [];
|
|
3272
|
+
const __isRelevant = validateActionKeywords2(message, __recentMessages, __providerKeywords) || validateActionRegex2(message, __recentMessages, __providerRegex);
|
|
3273
|
+
if (!__isRelevant) {
|
|
3274
|
+
return { text: "" };
|
|
3275
|
+
}
|
|
3175
3276
|
const { formContextProvider: formContextProvider2 } = await Promise.resolve().then(() => (init_context(), exports_context));
|
|
3176
3277
|
return formContextProvider2.get(runtime, message, state);
|
|
3177
3278
|
}
|
|
@@ -3282,4 +3383,4 @@ export {
|
|
|
3282
3383
|
BUILTIN_TYPES
|
|
3283
3384
|
};
|
|
3284
3385
|
|
|
3285
|
-
//# debugId=
|
|
3386
|
+
//# debugId=B1811CEC0857E66F64756E2164756E21
|