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

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
@@ -151,7 +151,6 @@ export { FormService } from "./service";
151
151
  export { formContextProvider } from "./providers/context";
152
152
  export { formEvaluator } from "./evaluators/extractor";
153
153
  export { formRestoreAction } from "./actions/restore";
154
- export { formNudgeWorker, processEntityNudges } from "./tasks/nudge";
155
154
  /**
156
155
  * Form Plugin
157
156
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAO3D,cAAc,SAAS,CAAC;AAOxB,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,aAAa,GACd,MAAM,YAAY,CAAC;AAOpB,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAOlB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAOnB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,GAC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,GAClB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAOlB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAOnB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,YAAY,EACZ,WAAW,EACX,cAAc,EACd,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,GACb,MAAM,OAAO,CAAC;AAOf,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAO/E,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAOjE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAQxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAUtD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,EAAE,MAoFxB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -629,7 +629,7 @@ function hasDataToExtract(intent) {
629
629
  return intent === "fill_form" || intent === "other";
630
630
  }
631
631
 
632
- // ../../node_modules/uuid/dist-node/stringify.js
632
+ // ../../../../node_modules/uuid/dist/esm/stringify.js
633
633
  function unsafeStringify(arr, offset = 0) {
634
634
  return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
635
635
  }
@@ -641,8 +641,8 @@ var init_stringify = __esm(() => {
641
641
  }
642
642
  });
643
643
 
644
- // ../../node_modules/uuid/dist-node/rng.js
645
- import { randomFillSync } from "node:crypto";
644
+ // ../../../../node_modules/uuid/dist/esm/rng.js
645
+ import { randomFillSync } from "crypto";
646
646
  function rng() {
647
647
  if (poolPtr > rnds8Pool.length - 16) {
648
648
  randomFillSync(rnds8Pool);
@@ -656,15 +656,18 @@ var init_rng = __esm(() => {
656
656
  poolPtr = rnds8Pool.length;
657
657
  });
658
658
 
659
- // ../../node_modules/uuid/dist-node/native.js
660
- import { randomUUID } from "node:crypto";
659
+ // ../../../../node_modules/uuid/dist/esm/native.js
660
+ import { randomUUID } from "crypto";
661
661
  var native_default;
662
662
  var init_native = __esm(() => {
663
663
  native_default = { randomUUID };
664
664
  });
665
665
 
666
- // ../../node_modules/uuid/dist-node/v4.js
667
- function _v4(options, buf, offset) {
666
+ // ../../../../node_modules/uuid/dist/esm/v4.js
667
+ function v4(options, buf, offset) {
668
+ if (native_default.randomUUID && !buf && !options) {
669
+ return native_default.randomUUID();
670
+ }
668
671
  options = options || {};
669
672
  const rnds = options.random ?? options.rng?.() ?? rng();
670
673
  if (rnds.length < 16) {
@@ -684,12 +687,6 @@ function _v4(options, buf, offset) {
684
687
  }
685
688
  return unsafeStringify(rnds);
686
689
  }
687
- function v4(options, buf, offset) {
688
- if (native_default.randomUUID && !buf && !options) {
689
- return native_default.randomUUID();
690
- }
691
- return _v4(options, buf, offset);
692
- }
693
690
  var v4_default;
694
691
  var init_v4 = __esm(() => {
695
692
  init_native();
@@ -698,8 +695,8 @@ var init_v4 = __esm(() => {
698
695
  v4_default = v4;
699
696
  });
700
697
 
701
- // ../../node_modules/uuid/dist-node/index.js
702
- var init_dist_node = __esm(() => {
698
+ // ../../../../node_modules/uuid/dist/esm/index.js
699
+ var init_esm = __esm(() => {
703
700
  init_v4();
704
701
  });
705
702
 
@@ -871,7 +868,7 @@ var isRecord = (value) => typeof value === "object" && value !== null && !Array.
871
868
  return typeof data.formId === "string" && typeof data.updatedAt === "number" && typeof data.values === "object";
872
869
  };
873
870
  var init_storage = __esm(() => {
874
- init_dist_node();
871
+ init_esm();
875
872
  init_types();
876
873
  });
877
874
 
@@ -1209,7 +1206,7 @@ function prettify3(key) {
1209
1206
  }
1210
1207
  var FormService;
1211
1208
  var init_service = __esm(() => {
1212
- init_dist_node();
1209
+ init_esm();
1213
1210
  init_types();
1214
1211
  init_storage();
1215
1212
  init_validation();
@@ -1254,13 +1251,6 @@ var init_service = __esm(() => {
1254
1251
  listForms() {
1255
1252
  return Array.from(this.forms.values());
1256
1253
  }
1257
- registerType(type, handler) {
1258
- registerTypeHandler(type, handler);
1259
- logger.debug(`[FormService] Registered type handler: ${type}`);
1260
- }
1261
- getTypeHandler(type) {
1262
- return getTypeHandler(type);
1263
- }
1264
1254
  registerControlType(type, options) {
1265
1255
  const existing = this.controlTypes.get(type.id);
1266
1256
  if (existing) {
@@ -3085,97 +3075,6 @@ init_service();
3085
3075
  init_context();
3086
3076
  init_extractor();
3087
3077
  init_restore();
3088
-
3089
- // src/tasks/nudge.ts
3090
- import { logger as logger5 } from "@elizaos/core";
3091
- var formNudgeWorker = {
3092
- name: "form_nudge_check",
3093
- validate: async (_runtime, _message, _state) => {
3094
- return true;
3095
- },
3096
- execute: async (runtime, _options, _task) => {
3097
- try {
3098
- const formService = runtime.getService("FORM");
3099
- if (!formService) {
3100
- logger5.debug("[FormNudge] Form service not available");
3101
- return;
3102
- }
3103
- logger5.debug("[FormNudge] Nudge check cycle completed");
3104
- } catch (error) {
3105
- logger5.error("[FormNudge] Error during nudge check:", String(error));
3106
- }
3107
- }
3108
- };
3109
- async function processEntityNudges(runtime, entityId) {
3110
- const formService = runtime.getService("FORM");
3111
- if (!formService)
3112
- return;
3113
- const activeSessions = await formService.getAllActiveSessions(entityId);
3114
- const stashedSessions = await formService.getStashedSessions(entityId);
3115
- const allSessions = [...activeSessions, ...stashedSessions];
3116
- const now = Date.now();
3117
- const expirationWarningMs = 24 * 60 * 60 * 1000;
3118
- for (const session of allSessions) {
3119
- const form = formService.getForm(session.formId);
3120
- if (session.expiresAt < now) {
3121
- session.status = "expired";
3122
- await formService.saveSession(session);
3123
- if (form?.hooks?.onExpire) {
3124
- const worker = runtime.getTaskWorker(form.hooks.onExpire);
3125
- if (worker) {
3126
- try {
3127
- await worker.execute(runtime, { session, form }, {});
3128
- } catch (error) {
3129
- logger5.error("[FormNudge] onExpire hook failed:", String(error));
3130
- }
3131
- }
3132
- }
3133
- logger5.debug(`[FormNudge] Session ${session.id} expired`);
3134
- continue;
3135
- }
3136
- if (isExpiringSoon(session, expirationWarningMs) && !session.expirationWarned) {
3137
- await sendExpirationWarning(runtime, session, form);
3138
- session.expirationWarned = true;
3139
- await formService.saveSession(session);
3140
- continue;
3141
- }
3142
- if (session.status === "stashed" && shouldNudge(session, form)) {
3143
- await sendNudge(runtime, session, form);
3144
- session.nudgeCount = (session.nudgeCount || 0) + 1;
3145
- session.lastNudgeAt = now;
3146
- await formService.saveSession(session);
3147
- }
3148
- }
3149
- }
3150
- async function sendNudge(runtime, session, form) {
3151
- const message = form?.nudge?.message || `You have an unfinished "${form?.name || "form"}". Would you like to continue?`;
3152
- try {
3153
- if (typeof runtime.sendMessageToRoom === "function") {
3154
- await runtime.sendMessageToRoom(session.roomId, {
3155
- text: message
3156
- });
3157
- logger5.debug(`[FormNudge] Sent nudge for session in room ${session.roomId}`);
3158
- }
3159
- } catch (error) {
3160
- logger5.error("[FormNudge] Failed to send nudge:", String(error));
3161
- }
3162
- }
3163
- async function sendExpirationWarning(runtime, session, form) {
3164
- const remaining = formatTimeRemaining(session);
3165
- const message = `Your "${form?.name || "form"}" form will expire in ${remaining}. Say "resume" to keep working on it.`;
3166
- try {
3167
- if (typeof runtime.sendMessageToRoom === "function") {
3168
- await runtime.sendMessageToRoom(session.roomId, {
3169
- text: message
3170
- });
3171
- logger5.debug(`[FormNudge] Sent expiration warning for session in room ${session.roomId}`);
3172
- }
3173
- } catch (error) {
3174
- logger5.error("[FormNudge] Failed to send expiration warning:", String(error));
3175
- }
3176
- }
3177
-
3178
- // src/index.ts
3179
3078
  var formPlugin = {
3180
3079
  name: "form",
3181
3080
  description: "Agent-native conversational forms for data collection",
@@ -3255,7 +3154,6 @@ export {
3255
3154
  registerTypeHandler,
3256
3155
  registerBuiltinTypes,
3257
3156
  quickIntentDetect,
3258
- processEntityNudges,
3259
3157
  prettify,
3260
3158
  parseValue,
3261
3159
  matchesMimeType,
@@ -3278,7 +3176,6 @@ export {
3278
3176
  formatEffort,
3279
3177
  formRestoreAction,
3280
3178
  formPlugin,
3281
- formNudgeWorker,
3282
3179
  formEvaluator,
3283
3180
  formContextProvider,
3284
3181
  extractSingleField,
@@ -3303,4 +3200,4 @@ export {
3303
3200
  BUILTIN_TYPES
3304
3201
  };
3305
3202
 
3306
- //# debugId=11830BB10982F7F464756E2164756E21
3203
+ //# debugId=6EC545854C3E8D8A64756E2164756E21