@elizaos/shared 2.0.0-alpha.538 → 2.0.11-beta.7

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.
Files changed (729) hide show
  1. package/api/agent-api-types.d.ts +210 -0
  2. package/api/agent-api-types.d.ts.map +1 -0
  3. package/api/agent-api-types.js +11 -0
  4. package/api/agent-api-types.js.map +1 -0
  5. package/api/http-helpers.d.ts +3 -0
  6. package/api/http-helpers.d.ts.map +1 -0
  7. package/api/http-helpers.js +2 -0
  8. package/api/http-helpers.js.map +1 -0
  9. package/api/route-helpers.d.ts +2 -0
  10. package/api/route-helpers.d.ts.map +1 -0
  11. package/api/route-helpers.js +2 -0
  12. package/api/route-helpers.js.map +1 -0
  13. package/app-hero-art.d.ts.map +1 -1
  14. package/app-hero-art.js +5 -13
  15. package/app-hero-art.js.map +1 -1
  16. package/brand/index.d.ts +130 -0
  17. package/brand/index.d.ts.map +1 -0
  18. package/brand/index.js +126 -0
  19. package/brand/index.js.map +1 -0
  20. package/brand-classic/index.d.ts +158 -0
  21. package/brand-classic/index.d.ts.map +1 -0
  22. package/brand-classic/index.js +91 -0
  23. package/brand-classic/index.js.map +1 -0
  24. package/character-language.d.ts +16 -0
  25. package/character-language.d.ts.map +1 -0
  26. package/character-language.js +58 -0
  27. package/character-language.js.map +1 -0
  28. package/{onboarding-presets.characters.d.ts → character-presets.characters.d.ts} +2 -2
  29. package/character-presets.characters.d.ts.map +1 -0
  30. package/{onboarding-presets.characters.js → character-presets.characters.js} +1 -1
  31. package/character-presets.characters.js.map +1 -0
  32. package/{onboarding-presets.d.ts → character-presets.d.ts} +7 -5
  33. package/character-presets.d.ts.map +1 -0
  34. package/{onboarding-presets.js → character-presets.js} +53 -58
  35. package/character-presets.js.map +1 -0
  36. package/{onboarding-presets.shared.d.ts → character-presets.shared.d.ts} +1 -1
  37. package/character-presets.shared.d.ts.map +1 -0
  38. package/{onboarding-presets.shared.js → character-presets.shared.js} +1 -1
  39. package/character-presets.shared.js.map +1 -0
  40. package/checkout/index.d.ts +48 -0
  41. package/checkout/index.d.ts.map +1 -0
  42. package/checkout/index.js +59 -0
  43. package/checkout/index.js.map +1 -0
  44. package/cli/parse-duration.d.ts +5 -0
  45. package/cli/parse-duration.d.ts.map +1 -0
  46. package/cli/parse-duration.js +26 -0
  47. package/cli/parse-duration.js.map +1 -0
  48. package/config/allowed-hosts.d.ts +8 -0
  49. package/config/allowed-hosts.d.ts.map +1 -0
  50. package/config/allowed-hosts.js +44 -0
  51. package/config/allowed-hosts.js.map +1 -0
  52. package/config/api-key-prefix-hints.d.ts +24 -0
  53. package/config/api-key-prefix-hints.d.ts.map +1 -0
  54. package/config/api-key-prefix-hints.js +26 -0
  55. package/config/api-key-prefix-hints.js.map +1 -0
  56. package/config/app-config.d.ts +274 -0
  57. package/config/app-config.d.ts.map +1 -0
  58. package/config/app-config.js +64 -0
  59. package/config/app-config.js.map +1 -0
  60. package/config/app-manifest.d.ts +75 -0
  61. package/config/app-manifest.d.ts.map +1 -0
  62. package/config/app-manifest.js +115 -0
  63. package/config/app-manifest.js.map +1 -0
  64. package/config/boot-config-store.d.ts +74 -0
  65. package/config/boot-config-store.d.ts.map +1 -0
  66. package/config/boot-config-store.js +121 -0
  67. package/config/boot-config-store.js.map +1 -0
  68. package/config/boot-config.d.ts +6 -0
  69. package/config/boot-config.d.ts.map +1 -0
  70. package/config/boot-config.js +6 -0
  71. package/config/boot-config.js.map +1 -0
  72. package/config/branding.d.ts +53 -0
  73. package/config/branding.d.ts.map +1 -0
  74. package/config/branding.js +23 -0
  75. package/config/branding.js.map +1 -0
  76. package/config/cloud-only.d.ts +8 -0
  77. package/config/cloud-only.d.ts.map +1 -0
  78. package/config/cloud-only.js +26 -0
  79. package/config/cloud-only.js.map +1 -0
  80. package/config/config-catalog.d.ts +371 -0
  81. package/config/config-catalog.d.ts.map +1 -0
  82. package/config/config-catalog.js +719 -0
  83. package/config/config-catalog.js.map +1 -0
  84. package/config/config-paths.d.ts +11 -0
  85. package/config/config-paths.d.ts.map +1 -0
  86. package/config/config-paths.js +74 -0
  87. package/config/config-paths.js.map +1 -0
  88. package/config/config.d.ts +11 -0
  89. package/config/config.d.ts.map +1 -0
  90. package/config/config.js +23 -0
  91. package/config/config.js.map +1 -0
  92. package/config/distribution-profile.d.ts +16 -0
  93. package/config/distribution-profile.d.ts.map +1 -0
  94. package/config/distribution-profile.js +29 -0
  95. package/config/distribution-profile.js.map +1 -0
  96. package/config/env-vars.d.ts +2 -0
  97. package/config/env-vars.d.ts.map +1 -0
  98. package/config/env-vars.js +2 -0
  99. package/config/env-vars.js.map +1 -0
  100. package/config/index.d.ts +12 -0
  101. package/config/index.d.ts.map +1 -0
  102. package/config/index.js +15 -0
  103. package/config/index.js.map +1 -0
  104. package/config/plugin-auto-enable-engine.d.ts +4 -0
  105. package/config/plugin-auto-enable-engine.d.ts.map +1 -0
  106. package/config/plugin-auto-enable-engine.js +45 -0
  107. package/config/plugin-auto-enable-engine.js.map +1 -0
  108. package/config/plugin-auto-enable.d.ts +2 -0
  109. package/config/plugin-auto-enable.d.ts.map +1 -0
  110. package/config/plugin-auto-enable.js +8 -0
  111. package/config/plugin-auto-enable.js.map +1 -0
  112. package/config/plugin-manifest.d.ts +89 -0
  113. package/config/plugin-manifest.d.ts.map +1 -0
  114. package/config/plugin-manifest.js +281 -0
  115. package/config/plugin-manifest.js.map +1 -0
  116. package/config/plugin-ui-spec.d.ts +42 -0
  117. package/config/plugin-ui-spec.d.ts.map +1 -0
  118. package/config/plugin-ui-spec.js +257 -0
  119. package/config/plugin-ui-spec.js.map +1 -0
  120. package/config/runtime-mode.d.ts +54 -0
  121. package/config/runtime-mode.d.ts.map +1 -0
  122. package/config/runtime-mode.js +107 -0
  123. package/config/runtime-mode.js.map +1 -0
  124. package/config/runtime-overrides.d.ts +16 -0
  125. package/config/runtime-overrides.d.ts.map +1 -0
  126. package/config/runtime-overrides.js +49 -0
  127. package/config/runtime-overrides.js.map +1 -0
  128. package/config/schema.d.ts +7 -0
  129. package/config/schema.d.ts.map +1 -0
  130. package/config/schema.js +30 -0
  131. package/config/schema.js.map +1 -0
  132. package/config/types.agent-defaults.d.ts +6 -1
  133. package/config/types.agent-defaults.d.ts.map +1 -1
  134. package/config/types.agents.d.ts +9 -4
  135. package/config/types.agents.d.ts.map +1 -1
  136. package/config/types.eliza.d.ts +27 -49
  137. package/config/types.eliza.d.ts.map +1 -1
  138. package/config/types.messages.d.ts +2 -2
  139. package/config/types.messages.d.ts.map +1 -1
  140. package/config/types.tools.d.ts +2 -2
  141. package/config/types.tools.d.ts.map +1 -1
  142. package/config/ui-spec.d.ts +164 -0
  143. package/config/ui-spec.d.ts.map +1 -0
  144. package/config/ui-spec.js +14 -0
  145. package/config/ui-spec.js.map +1 -0
  146. package/config/wechat-config.d.ts +2 -0
  147. package/config/wechat-config.d.ts.map +1 -0
  148. package/config/wechat-config.js +2 -0
  149. package/config/wechat-config.js.map +1 -0
  150. package/config/zod-schema.agent-runtime.d.ts +1087 -0
  151. package/config/zod-schema.agent-runtime.d.ts.map +1 -0
  152. package/config/zod-schema.agent-runtime.js +764 -0
  153. package/config/zod-schema.agent-runtime.js.map +1 -0
  154. package/config/zod-schema.core.d.ts +1048 -0
  155. package/config/zod-schema.core.d.ts.map +1 -0
  156. package/config/zod-schema.core.js +707 -0
  157. package/config/zod-schema.core.js.map +1 -0
  158. package/connector-cred-types.d.ts +3 -3
  159. package/connector-cred-types.js +4 -4
  160. package/connectors.d.ts +0 -8
  161. package/connectors.d.ts.map +1 -1
  162. package/connectors.js +26 -50
  163. package/connectors.js.map +1 -1
  164. package/contracts/agent-routes.d.ts +63 -0
  165. package/contracts/agent-routes.d.ts.map +1 -0
  166. package/contracts/agent-routes.js +55 -0
  167. package/contracts/agent-routes.js.map +1 -0
  168. package/contracts/app-permissions-routes.d.ts +148 -0
  169. package/contracts/app-permissions-routes.d.ts.map +1 -0
  170. package/contracts/app-permissions-routes.js +96 -0
  171. package/contracts/app-permissions-routes.js.map +1 -0
  172. package/contracts/app-permissions.d.ts +122 -0
  173. package/contracts/app-permissions.d.ts.map +1 -0
  174. package/contracts/app-permissions.js +163 -0
  175. package/contracts/app-permissions.js.map +1 -0
  176. package/contracts/apps-favorites-routes.d.ts +44 -0
  177. package/contracts/apps-favorites-routes.d.ts.map +1 -0
  178. package/contracts/apps-favorites-routes.js +48 -0
  179. package/contracts/apps-favorites-routes.js.map +1 -0
  180. package/contracts/apps-lifecycle-routes.d.ts +185 -0
  181. package/contracts/apps-lifecycle-routes.d.ts.map +1 -0
  182. package/contracts/apps-lifecycle-routes.js +204 -0
  183. package/contracts/apps-lifecycle-routes.js.map +1 -0
  184. package/contracts/apps-loading-routes.d.ts +64 -0
  185. package/contracts/apps-loading-routes.d.ts.map +1 -0
  186. package/contracts/apps-loading-routes.js +65 -0
  187. package/contracts/apps-loading-routes.js.map +1 -0
  188. package/contracts/apps-runs-routes.d.ts +33 -0
  189. package/contracts/apps-runs-routes.d.ts.map +1 -0
  190. package/contracts/apps-runs-routes.js +38 -0
  191. package/contracts/apps-runs-routes.js.map +1 -0
  192. package/contracts/apps.d.ts +883 -3
  193. package/contracts/apps.d.ts.map +1 -1
  194. package/contracts/apps.js +278 -40
  195. package/contracts/apps.js.map +1 -1
  196. package/contracts/auth-routes.d.ts +23 -0
  197. package/contracts/auth-routes.d.ts.map +1 -0
  198. package/contracts/auth-routes.js +25 -0
  199. package/contracts/auth-routes.js.map +1 -0
  200. package/contracts/awareness.d.ts +1 -1
  201. package/contracts/calendar.d.ts +181 -0
  202. package/contracts/calendar.d.ts.map +1 -0
  203. package/contracts/calendar.js +19 -0
  204. package/contracts/calendar.js.map +1 -0
  205. package/contracts/character-routes.d.ts +70 -0
  206. package/contracts/character-routes.d.ts.map +1 -0
  207. package/contracts/character-routes.js +49 -0
  208. package/contracts/character-routes.js.map +1 -0
  209. package/contracts/cloud-coding-containers.d.ts +432 -0
  210. package/contracts/cloud-coding-containers.d.ts.map +1 -0
  211. package/contracts/cloud-coding-containers.js +135 -0
  212. package/contracts/cloud-coding-containers.js.map +1 -0
  213. package/contracts/cloud-topology.js +7 -7
  214. package/contracts/cloud-topology.js.map +1 -1
  215. package/contracts/config.d.ts +52 -4
  216. package/contracts/config.d.ts.map +1 -1
  217. package/contracts/connector-routes.d.ts +39 -0
  218. package/contracts/connector-routes.d.ts.map +1 -0
  219. package/contracts/connector-routes.js +50 -0
  220. package/contracts/connector-routes.js.map +1 -0
  221. package/contracts/content-pack.d.ts +2 -2
  222. package/contracts/content-pack.d.ts.map +1 -1
  223. package/contracts/content-pack.js +1 -1
  224. package/contracts/conversation-routes.d.ts +195 -0
  225. package/contracts/conversation-routes.d.ts.map +1 -0
  226. package/contracts/conversation-routes.js +107 -0
  227. package/contracts/conversation-routes.js.map +1 -0
  228. package/contracts/diagnostics-routes.d.ts +33 -0
  229. package/contracts/diagnostics-routes.d.ts.map +1 -0
  230. package/contracts/diagnostics-routes.js +26 -0
  231. package/contracts/diagnostics-routes.js.map +1 -0
  232. package/contracts/feature-result.d.ts +24 -0
  233. package/contracts/feature-result.d.ts.map +1 -0
  234. package/contracts/feature-result.js +7 -0
  235. package/contracts/feature-result.js.map +1 -0
  236. package/contracts/{onboarding.d.ts → first-run-options.d.ts} +172 -69
  237. package/contracts/first-run-options.d.ts.map +1 -0
  238. package/contracts/{onboarding.js → first-run-options.js} +222 -91
  239. package/contracts/first-run-options.js.map +1 -0
  240. package/contracts/first-run-routes.d.ts +167 -0
  241. package/contracts/first-run-routes.d.ts.map +1 -0
  242. package/contracts/first-run-routes.js +115 -0
  243. package/contracts/first-run-routes.js.map +1 -0
  244. package/contracts/health.d.ts +30 -0
  245. package/contracts/health.d.ts.map +1 -0
  246. package/contracts/health.js +29 -0
  247. package/contracts/health.js.map +1 -0
  248. package/contracts/inbox-routes.d.ts +37 -0
  249. package/contracts/inbox-routes.d.ts.map +1 -0
  250. package/contracts/inbox-routes.js +44 -0
  251. package/contracts/inbox-routes.js.map +1 -0
  252. package/contracts/index.d.ts +30 -3
  253. package/contracts/index.d.ts.map +1 -1
  254. package/contracts/index.js +30 -3
  255. package/contracts/index.js.map +1 -1
  256. package/contracts/memory-routes.d.ts +27 -0
  257. package/contracts/memory-routes.d.ts.map +1 -0
  258. package/contracts/memory-routes.js +23 -0
  259. package/contracts/memory-routes.js.map +1 -0
  260. package/contracts/misc-routes.d.ts +192 -0
  261. package/contracts/misc-routes.d.ts.map +1 -0
  262. package/contracts/misc-routes.js +155 -0
  263. package/contracts/misc-routes.js.map +1 -0
  264. package/contracts/permissions-routes.d.ts +31 -0
  265. package/contracts/permissions-routes.d.ts.map +1 -0
  266. package/contracts/permissions-routes.js +34 -0
  267. package/contracts/permissions-routes.js.map +1 -0
  268. package/contracts/permissions.d.ts +81 -11
  269. package/contracts/permissions.d.ts.map +1 -1
  270. package/contracts/permissions.js +37 -1
  271. package/contracts/permissions.js.map +1 -1
  272. package/contracts/{lifeops.d.ts → personal-assistant.d.ts} +368 -170
  273. package/contracts/personal-assistant.d.ts.map +1 -0
  274. package/contracts/{lifeops.js → personal-assistant.js} +39 -13
  275. package/contracts/personal-assistant.js.map +1 -0
  276. package/contracts/plugin-routes.d.ts +105 -0
  277. package/contracts/plugin-routes.d.ts.map +1 -0
  278. package/contracts/plugin-routes.js +81 -0
  279. package/contracts/plugin-routes.js.map +1 -0
  280. package/contracts/relationships-routes.d.ts +23 -0
  281. package/contracts/relationships-routes.d.ts.map +1 -0
  282. package/contracts/relationships-routes.js +22 -0
  283. package/contracts/relationships-routes.js.map +1 -0
  284. package/contracts/service-routing.d.ts +7 -121
  285. package/contracts/service-routing.d.ts.map +1 -1
  286. package/contracts/service-routing.js +19 -12
  287. package/contracts/service-routing.js.map +1 -1
  288. package/contracts/skills-routes.d.ts +116 -0
  289. package/contracts/skills-routes.d.ts.map +1 -0
  290. package/contracts/skills-routes.js +115 -0
  291. package/contracts/skills-routes.js.map +1 -0
  292. package/contracts/subscription-routes.d.ts +47 -0
  293. package/contracts/subscription-routes.d.ts.map +1 -0
  294. package/contracts/subscription-routes.js +50 -0
  295. package/contracts/subscription-routes.js.map +1 -0
  296. package/contracts/tail-routes.d.ts +78 -0
  297. package/contracts/tail-routes.d.ts.map +1 -0
  298. package/contracts/tail-routes.js +63 -0
  299. package/contracts/tail-routes.js.map +1 -0
  300. package/contracts/theme.d.ts +0 -2
  301. package/contracts/theme.d.ts.map +1 -1
  302. package/contracts/theme.js +0 -2
  303. package/contracts/theme.js.map +1 -1
  304. package/contracts/update-status.d.ts +100 -0
  305. package/contracts/update-status.d.ts.map +1 -0
  306. package/contracts/update-status.js +45 -0
  307. package/contracts/update-status.js.map +1 -0
  308. package/contracts/wallet-routes.d.ts +82 -0
  309. package/contracts/wallet-routes.d.ts.map +1 -0
  310. package/contracts/wallet-routes.js +49 -0
  311. package/contracts/wallet-routes.js.map +1 -0
  312. package/contracts/wallet.d.ts +12 -570
  313. package/contracts/wallet.d.ts.map +1 -1
  314. package/contracts/wallet.js +139 -0
  315. package/contracts/wallet.js.map +1 -1
  316. package/contracts/workbench-routes.d.ts +231 -0
  317. package/contracts/workbench-routes.d.ts.map +1 -0
  318. package/contracts/workbench-routes.js +183 -0
  319. package/contracts/workbench-routes.js.map +1 -0
  320. package/db/drizzle-database.d.ts +13 -0
  321. package/db/drizzle-database.d.ts.map +1 -0
  322. package/db/drizzle-database.js +2 -0
  323. package/db/drizzle-database.js.map +1 -0
  324. package/dev-settings-banner-style.d.ts +1 -1
  325. package/dev-settings-banner-style.js +2 -2
  326. package/dev-settings-banner-style.js.map +1 -1
  327. package/dev-settings-figlet-heading.d.ts.map +1 -1
  328. package/dev-settings-figlet-heading.js +1 -8
  329. package/dev-settings-figlet-heading.js.map +1 -1
  330. package/elizacloud/base-url.d.ts +6 -0
  331. package/elizacloud/base-url.d.ts.map +1 -0
  332. package/elizacloud/base-url.js +65 -0
  333. package/elizacloud/base-url.js.map +1 -0
  334. package/elizacloud/cloud-provisioning.d.ts +9 -0
  335. package/elizacloud/cloud-provisioning.d.ts.map +1 -0
  336. package/elizacloud/cloud-provisioning.js +25 -0
  337. package/elizacloud/cloud-provisioning.js.map +1 -0
  338. package/elizacloud/cloud-secrets.d.ts +23 -0
  339. package/elizacloud/cloud-secrets.d.ts.map +1 -0
  340. package/elizacloud/cloud-secrets.js +51 -0
  341. package/elizacloud/cloud-secrets.js.map +1 -0
  342. package/elizacloud/index.d.ts +6 -0
  343. package/elizacloud/index.d.ts.map +1 -0
  344. package/elizacloud/index.js +6 -0
  345. package/elizacloud/index.js.map +1 -0
  346. package/elizacloud/is-cloud-reachable.d.ts +19 -0
  347. package/elizacloud/is-cloud-reachable.d.ts.map +1 -0
  348. package/elizacloud/is-cloud-reachable.js +44 -0
  349. package/elizacloud/is-cloud-reachable.js.map +1 -0
  350. package/elizacloud/server-cloud-tts.d.ts +21 -0
  351. package/elizacloud/server-cloud-tts.d.ts.map +1 -0
  352. package/elizacloud/server-cloud-tts.js +293 -0
  353. package/elizacloud/server-cloud-tts.js.map +1 -0
  354. package/email-classification/email-classifier.d.ts +57 -0
  355. package/email-classification/email-classifier.d.ts.map +1 -0
  356. package/email-classification/email-classifier.js +348 -0
  357. package/email-classification/email-classifier.js.map +1 -0
  358. package/email-classification/index.d.ts +12 -0
  359. package/email-classification/index.d.ts.map +1 -0
  360. package/email-classification/index.js +12 -0
  361. package/email-classification/index.js.map +1 -0
  362. package/email-classification/wrap-untrusted-email-content.d.ts +15 -0
  363. package/email-classification/wrap-untrusted-email-content.d.ts.map +1 -0
  364. package/email-classification/wrap-untrusted-email-content.js +24 -0
  365. package/email-classification/wrap-untrusted-email-content.js.map +1 -0
  366. package/env-utils.d.ts +1 -4
  367. package/env-utils.d.ts.map +1 -1
  368. package/env-utils.js +9 -1
  369. package/env-utils.js.map +1 -1
  370. package/events/index.d.ts +68 -0
  371. package/events/index.d.ts.map +1 -0
  372. package/events/index.js +53 -0
  373. package/events/index.js.map +1 -0
  374. package/hardware-catalog/index.d.ts +204 -0
  375. package/hardware-catalog/index.d.ts.map +1 -0
  376. package/hardware-catalog/index.js +174 -0
  377. package/hardware-catalog/index.js.map +1 -0
  378. package/i18n/generated/validation-keyword-data.d.ts +2711 -748
  379. package/i18n/generated/validation-keyword-data.d.ts.map +1 -1
  380. package/i18n/generated/validation-keyword-data.js +2711 -748
  381. package/i18n/generated/validation-keyword-data.js.map +1 -1
  382. package/i18n/keyword-matching.d.ts.map +1 -1
  383. package/i18n/keyword-matching.js +4 -1
  384. package/i18n/keyword-matching.js.map +1 -1
  385. package/index.d.ts +82 -7
  386. package/index.d.ts.map +1 -1
  387. package/index.js +109 -13
  388. package/index.js.map +1 -1
  389. package/knowledge-graph/entity-types.d.ts +135 -0
  390. package/knowledge-graph/entity-types.d.ts.map +1 -0
  391. package/knowledge-graph/entity-types.js +75 -0
  392. package/knowledge-graph/entity-types.js.map +1 -0
  393. package/knowledge-graph/index.d.ts +13 -0
  394. package/knowledge-graph/index.d.ts.map +1 -0
  395. package/knowledge-graph/index.js +13 -0
  396. package/knowledge-graph/index.js.map +1 -0
  397. package/knowledge-graph/merge.d.ts +76 -0
  398. package/knowledge-graph/merge.d.ts.map +1 -0
  399. package/knowledge-graph/merge.js +175 -0
  400. package/knowledge-graph/merge.js.map +1 -0
  401. package/knowledge-graph/relationship-types.d.ts +105 -0
  402. package/knowledge-graph/relationship-types.d.ts.map +1 -0
  403. package/knowledge-graph/relationship-types.js +114 -0
  404. package/knowledge-graph/relationship-types.js.map +1 -0
  405. package/lifeops-constants/index.d.ts +9 -0
  406. package/lifeops-constants/index.d.ts.map +1 -0
  407. package/lifeops-constants/index.js +9 -0
  408. package/lifeops-constants/index.js.map +1 -0
  409. package/lifeops-constants/service-constants.d.ts +79 -0
  410. package/lifeops-constants/service-constants.d.ts.map +1 -0
  411. package/lifeops-constants/service-constants.js +123 -0
  412. package/lifeops-constants/service-constants.js.map +1 -0
  413. package/lifeops-normalize/index.d.ts +12 -0
  414. package/lifeops-normalize/index.d.ts.map +1 -0
  415. package/lifeops-normalize/index.js +12 -0
  416. package/lifeops-normalize/index.js.map +1 -0
  417. package/lifeops-normalize/service-error.d.ts +14 -0
  418. package/lifeops-normalize/service-error.d.ts.map +1 -0
  419. package/lifeops-normalize/service-error.js +19 -0
  420. package/lifeops-normalize/service-error.js.map +1 -0
  421. package/lifeops-normalize/service-normalize.d.ts +38 -0
  422. package/lifeops-normalize/service-normalize.d.ts.map +1 -0
  423. package/lifeops-normalize/service-normalize.js +205 -0
  424. package/lifeops-normalize/service-normalize.js.map +1 -0
  425. package/lifeops-normalize/time-zone.d.ts +12 -0
  426. package/lifeops-normalize/time-zone.d.ts.map +1 -0
  427. package/lifeops-normalize/time-zone.js +29 -0
  428. package/lifeops-normalize/time-zone.js.map +1 -0
  429. package/local-inference/catalog.d.ts +97 -0
  430. package/local-inference/catalog.d.ts.map +1 -0
  431. package/local-inference/catalog.js +547 -0
  432. package/local-inference/catalog.js.map +1 -0
  433. package/local-inference/gpu-profiles.d.ts +110 -0
  434. package/local-inference/gpu-profiles.d.ts.map +1 -0
  435. package/local-inference/gpu-profiles.js +214 -0
  436. package/local-inference/gpu-profiles.js.map +1 -0
  437. package/local-inference/index.d.ts +21 -0
  438. package/local-inference/index.d.ts.map +1 -0
  439. package/local-inference/index.js +18 -0
  440. package/local-inference/index.js.map +1 -0
  441. package/local-inference/manifest-signature.d.ts +61 -0
  442. package/local-inference/manifest-signature.d.ts.map +1 -0
  443. package/local-inference/manifest-signature.js +129 -0
  444. package/local-inference/manifest-signature.js.map +1 -0
  445. package/local-inference/network-policy.d.ts +115 -0
  446. package/local-inference/network-policy.d.ts.map +1 -0
  447. package/local-inference/network-policy.js +154 -0
  448. package/local-inference/network-policy.js.map +1 -0
  449. package/local-inference/paths.d.ts +24 -0
  450. package/local-inference/paths.d.ts.map +1 -0
  451. package/local-inference/paths.js +40 -0
  452. package/local-inference/paths.js.map +1 -0
  453. package/local-inference/providers-types.d.ts +56 -0
  454. package/local-inference/providers-types.d.ts.map +1 -0
  455. package/local-inference/providers-types.js +19 -0
  456. package/local-inference/providers-types.js.map +1 -0
  457. package/local-inference/routing-preferences.d.ts +31 -0
  458. package/local-inference/routing-preferences.d.ts.map +1 -0
  459. package/local-inference/routing-preferences.js +73 -0
  460. package/local-inference/routing-preferences.js.map +1 -0
  461. package/local-inference/throughput.d.ts +74 -0
  462. package/local-inference/throughput.d.ts.map +1 -0
  463. package/local-inference/throughput.js +84 -0
  464. package/local-inference/throughput.js.map +1 -0
  465. package/local-inference/types.d.ts +510 -0
  466. package/local-inference/types.d.ts.map +1 -0
  467. package/local-inference/types.js +22 -0
  468. package/local-inference/types.js.map +1 -0
  469. package/local-inference/verify.d.ts +39 -0
  470. package/local-inference/verify.d.ts.map +1 -0
  471. package/local-inference/verify.js +105 -0
  472. package/local-inference/verify.js.map +1 -0
  473. package/local-inference/voice-models.d.ts +156 -0
  474. package/local-inference/voice-models.d.ts.map +1 -0
  475. package/local-inference/voice-models.js +746 -0
  476. package/local-inference/voice-models.js.map +1 -0
  477. package/local-inference-gpu/gpu-overrides.d.ts +97 -0
  478. package/local-inference-gpu/gpu-overrides.d.ts.map +1 -0
  479. package/local-inference-gpu/gpu-overrides.js +76 -0
  480. package/local-inference-gpu/gpu-overrides.js.map +1 -0
  481. package/local-inference-gpu/gpu-profile-loader.d.ts +83 -0
  482. package/local-inference-gpu/gpu-profile-loader.d.ts.map +1 -0
  483. package/local-inference-gpu/gpu-profile-loader.js +196 -0
  484. package/local-inference-gpu/gpu-profile-loader.js.map +1 -0
  485. package/local-inference-gpu/gpu-profile-schema.d.ts +208 -0
  486. package/local-inference-gpu/gpu-profile-schema.d.ts.map +1 -0
  487. package/local-inference-gpu/gpu-profile-schema.js +123 -0
  488. package/local-inference-gpu/gpu-profile-schema.js.map +1 -0
  489. package/local-inference-gpu/gpu-tier-detect.d.ts +61 -0
  490. package/local-inference-gpu/gpu-tier-detect.d.ts.map +1 -0
  491. package/local-inference-gpu/gpu-tier-detect.js +93 -0
  492. package/local-inference-gpu/gpu-tier-detect.js.map +1 -0
  493. package/local-inference-gpu/gpu-tier-profiles.d.ts +110 -0
  494. package/local-inference-gpu/gpu-tier-profiles.d.ts.map +1 -0
  495. package/local-inference-gpu/gpu-tier-profiles.js +235 -0
  496. package/local-inference-gpu/gpu-tier-profiles.js.map +1 -0
  497. package/package.json +111 -160
  498. package/platform/is-native-server.d.ts +9 -0
  499. package/platform/is-native-server.d.ts.map +1 -0
  500. package/platform/is-native-server.js +12 -0
  501. package/platform/is-native-server.js.map +1 -0
  502. package/restart.d.ts +2 -1
  503. package/restart.d.ts.map +1 -1
  504. package/restart.js +3 -2
  505. package/restart.js.map +1 -1
  506. package/runtime-env.d.ts +2 -2
  507. package/runtime-env.d.ts.map +1 -1
  508. package/runtime-env.js +15 -7
  509. package/runtime-env.js.map +1 -1
  510. package/self-edit.d.ts +4 -4
  511. package/self-edit.d.ts.map +1 -1
  512. package/self-edit.js +5 -5
  513. package/self-edit.js.map +1 -1
  514. package/settings-debug.d.ts.map +1 -1
  515. package/settings-debug.js +45 -38
  516. package/settings-debug.js.map +1 -1
  517. package/spoken-text.d.ts.map +1 -1
  518. package/spoken-text.js +3 -2
  519. package/spoken-text.js.map +1 -1
  520. package/steward-session-client/index.d.ts +172 -0
  521. package/steward-session-client/index.d.ts.map +1 -0
  522. package/steward-session-client/index.js +248 -0
  523. package/steward-session-client/index.js.map +1 -0
  524. package/steward-session-client/steward-oauth-pkce.d.ts +24 -0
  525. package/steward-session-client/steward-oauth-pkce.d.ts.map +1 -0
  526. package/steward-session-client/steward-oauth-pkce.js +105 -0
  527. package/steward-session-client/steward-oauth-pkce.js.map +1 -0
  528. package/terminal/links.d.ts +9 -0
  529. package/terminal/links.d.ts.map +1 -0
  530. package/terminal/links.js +21 -0
  531. package/terminal/links.js.map +1 -0
  532. package/terminal/palette.d.ts +11 -0
  533. package/terminal/palette.d.ts.map +1 -0
  534. package/terminal/palette.js +13 -0
  535. package/terminal/palette.js.map +1 -0
  536. package/terminal/theme.d.ts +17 -0
  537. package/terminal/theme.d.ts.map +1 -0
  538. package/terminal/theme.js +25 -0
  539. package/terminal/theme.js.map +1 -0
  540. package/test-support/process-helpers.d.ts +13 -0
  541. package/test-support/process-helpers.d.ts.map +1 -0
  542. package/test-support/process-helpers.js +24 -0
  543. package/test-support/process-helpers.js.map +1 -0
  544. package/test-support/test-helpers.d.ts +79 -0
  545. package/test-support/test-helpers.d.ts.map +1 -0
  546. package/test-support/test-helpers.js +341 -0
  547. package/test-support/test-helpers.js.map +1 -0
  548. package/transcripts.d.ts +111 -0
  549. package/transcripts.d.ts.map +1 -0
  550. package/transcripts.js +106 -0
  551. package/transcripts.js.map +1 -0
  552. package/type-guards.d.ts +1 -23
  553. package/type-guards.d.ts.map +1 -1
  554. package/type-guards.js +6 -23
  555. package/type-guards.js.map +1 -1
  556. package/types/index.d.ts +654 -0
  557. package/types/index.d.ts.map +1 -0
  558. package/types/index.js +5 -0
  559. package/types/index.js.map +1 -0
  560. package/utils/asset-url.d.ts +24 -0
  561. package/utils/asset-url.d.ts.map +1 -0
  562. package/utils/asset-url.js +151 -0
  563. package/utils/asset-url.js.map +1 -0
  564. package/utils/assistant-text.d.ts +13 -0
  565. package/utils/assistant-text.d.ts.map +1 -0
  566. package/utils/assistant-text.js +292 -0
  567. package/utils/assistant-text.js.map +1 -0
  568. package/utils/browser-tab-kit-types.d.ts +81 -0
  569. package/utils/browser-tab-kit-types.d.ts.map +1 -0
  570. package/utils/browser-tab-kit-types.js +23 -0
  571. package/utils/browser-tab-kit-types.js.map +1 -0
  572. package/utils/browser-tabs-renderer-registry.d.ts +56 -0
  573. package/utils/browser-tabs-renderer-registry.d.ts.map +1 -0
  574. package/utils/browser-tabs-renderer-registry.js +1282 -0
  575. package/utils/browser-tabs-renderer-registry.js.map +1 -0
  576. package/utils/character-message-examples.d.ts +7 -0
  577. package/utils/character-message-examples.d.ts.map +1 -0
  578. package/utils/character-message-examples.js +123 -0
  579. package/utils/character-message-examples.js.map +1 -0
  580. package/utils/cloud-status.d.ts +3 -0
  581. package/utils/cloud-status.d.ts.map +1 -0
  582. package/utils/cloud-status.js +11 -0
  583. package/utils/cloud-status.js.map +1 -0
  584. package/utils/documents-upload-image.d.ts +27 -0
  585. package/utils/documents-upload-image.d.ts.map +1 -0
  586. package/utils/documents-upload-image.js +147 -0
  587. package/utils/documents-upload-image.js.map +1 -0
  588. package/utils/eliza-cloud-model-route.d.ts +3 -0
  589. package/utils/eliza-cloud-model-route.d.ts.map +1 -0
  590. package/utils/eliza-cloud-model-route.js +10 -0
  591. package/utils/eliza-cloud-model-route.js.map +1 -0
  592. package/utils/eliza-globals.d.ts +13 -0
  593. package/utils/eliza-globals.d.ts.map +1 -0
  594. package/utils/eliza-globals.js +49 -0
  595. package/utils/eliza-globals.js.map +1 -0
  596. package/utils/eliza-root.d.ts +9 -0
  597. package/utils/eliza-root.d.ts.map +1 -0
  598. package/utils/eliza-root.js +102 -0
  599. package/utils/eliza-root.js.map +1 -0
  600. package/utils/env.d.ts +34 -0
  601. package/utils/env.d.ts.map +1 -0
  602. package/utils/env.js +142 -0
  603. package/utils/env.js.map +1 -0
  604. package/utils/errors.d.ts +13 -0
  605. package/utils/errors.d.ts.map +1 -0
  606. package/utils/errors.js +26 -0
  607. package/utils/errors.js.map +1 -0
  608. package/utils/exec-safety.d.ts +2 -0
  609. package/utils/exec-safety.d.ts.map +1 -0
  610. package/utils/exec-safety.js +25 -0
  611. package/utils/exec-safety.js.map +1 -0
  612. package/utils/format.d.ts +85 -0
  613. package/utils/format.d.ts.map +1 -0
  614. package/utils/format.js +140 -0
  615. package/utils/format.js.map +1 -0
  616. package/utils/labels.d.ts +6 -0
  617. package/utils/labels.d.ts.map +1 -0
  618. package/utils/labels.js +42 -0
  619. package/utils/labels.js.map +1 -0
  620. package/utils/log-prefix.d.ts +2 -0
  621. package/utils/log-prefix.d.ts.map +1 -0
  622. package/utils/log-prefix.js +44 -0
  623. package/utils/log-prefix.js.map +1 -0
  624. package/utils/name-tokens.d.ts +24 -0
  625. package/utils/name-tokens.d.ts.map +1 -0
  626. package/utils/name-tokens.js +37 -0
  627. package/utils/name-tokens.js.map +1 -0
  628. package/utils/namespace-defaults.d.ts +10 -0
  629. package/utils/namespace-defaults.d.ts.map +1 -0
  630. package/utils/namespace-defaults.js +17 -0
  631. package/utils/namespace-defaults.js.map +1 -0
  632. package/utils/number-parsing.d.ts +26 -0
  633. package/utils/number-parsing.d.ts.map +1 -0
  634. package/utils/number-parsing.js +57 -0
  635. package/utils/number-parsing.js.map +1 -0
  636. package/utils/owner-name.d.ts +3 -0
  637. package/utils/owner-name.d.ts.map +1 -0
  638. package/utils/owner-name.js +8 -0
  639. package/utils/owner-name.js.map +1 -0
  640. package/utils/permission-deep-links.d.ts +35 -0
  641. package/utils/permission-deep-links.d.ts.map +1 -0
  642. package/utils/permission-deep-links.js +95 -0
  643. package/utils/permission-deep-links.js.map +1 -0
  644. package/utils/rate-limiter.d.ts +32 -0
  645. package/utils/rate-limiter.d.ts.map +1 -0
  646. package/utils/rate-limiter.js +53 -0
  647. package/utils/rate-limiter.js.map +1 -0
  648. package/utils/serialise.d.ts +12 -0
  649. package/utils/serialise.d.ts.map +1 -0
  650. package/utils/serialise.js +22 -0
  651. package/utils/serialise.js.map +1 -0
  652. package/utils/sql-compat.d.ts +10 -0
  653. package/utils/sql-compat.d.ts.map +1 -0
  654. package/utils/sql-compat.js +112 -0
  655. package/utils/sql-compat.js.map +1 -0
  656. package/utils/streaming-text.d.ts +9 -0
  657. package/utils/streaming-text.d.ts.map +1 -0
  658. package/utils/streaming-text.js +116 -0
  659. package/utils/streaming-text.js.map +1 -0
  660. package/utils/subscription-auth.d.ts +9 -0
  661. package/utils/subscription-auth.d.ts.map +1 -0
  662. package/utils/subscription-auth.js +49 -0
  663. package/utils/subscription-auth.js.map +1 -0
  664. package/utils/trajectory-format.d.ts +6 -0
  665. package/utils/trajectory-format.d.ts.map +1 -0
  666. package/utils/trajectory-format.js +44 -0
  667. package/utils/trajectory-format.js.map +1 -0
  668. package/utils/tts-debug.d.ts +10 -0
  669. package/utils/tts-debug.d.ts.map +1 -0
  670. package/utils/tts-debug.js +73 -0
  671. package/utils/tts-debug.js.map +1 -0
  672. package/view-hero-art.d.ts +75 -0
  673. package/view-hero-art.d.ts.map +1 -0
  674. package/view-hero-art.js +360 -0
  675. package/view-hero-art.js.map +1 -0
  676. package/voice/first-sentence-snip.d.ts +68 -0
  677. package/voice/first-sentence-snip.d.ts.map +1 -0
  678. package/voice/first-sentence-snip.js +284 -0
  679. package/voice/first-sentence-snip.js.map +1 -0
  680. package/voice/voice-cancellation-token.d.ts +127 -0
  681. package/voice/voice-cancellation-token.d.ts.map +1 -0
  682. package/voice/voice-cancellation-token.js +186 -0
  683. package/voice/voice-cancellation-token.js.map +1 -0
  684. package/voice-wer.d.ts +19 -0
  685. package/voice-wer.d.ts.map +1 -0
  686. package/voice-wer.js +42 -0
  687. package/voice-wer.js.map +1 -0
  688. package/voice.d.ts +55 -0
  689. package/voice.d.ts.map +1 -0
  690. package/voice.js +337 -0
  691. package/voice.js.map +1 -0
  692. package/contracts/lifeops-extensions.d.ts +0 -340
  693. package/contracts/lifeops-extensions.d.ts.map +0 -1
  694. package/contracts/lifeops-extensions.js +0 -37
  695. package/contracts/lifeops-extensions.js.map +0 -1
  696. package/contracts/lifeops.d.ts.map +0 -1
  697. package/contracts/lifeops.js.map +0 -1
  698. package/contracts/onboarding.d.ts.map +0 -1
  699. package/contracts/onboarding.js.map +0 -1
  700. package/contracts/scratchpad.d.ts +0 -136
  701. package/contracts/scratchpad.d.ts.map +0 -1
  702. package/contracts/scratchpad.js +0 -91
  703. package/contracts/scratchpad.js.map +0 -1
  704. package/eliza-core-roles.d.ts +0 -79
  705. package/eliza-core-roles.d.ts.map +0 -1
  706. package/eliza-core-roles.js +0 -600
  707. package/eliza-core-roles.js.map +0 -1
  708. package/env-utils.impl.d.ts +0 -2
  709. package/env-utils.impl.d.ts.map +0 -1
  710. package/env-utils.impl.js +0 -10
  711. package/env-utils.impl.js.map +0 -1
  712. package/onboarding-presets.characters.d.ts.map +0 -1
  713. package/onboarding-presets.characters.js.map +0 -1
  714. package/onboarding-presets.d.ts.map +0 -1
  715. package/onboarding-presets.js.map +0 -1
  716. package/onboarding-presets.shared.d.ts.map +0 -1
  717. package/onboarding-presets.shared.js.map +0 -1
  718. package/themes/index.d.ts +0 -7
  719. package/themes/index.d.ts.map +0 -1
  720. package/themes/index.js +0 -6
  721. package/themes/index.js.map +0 -1
  722. package/themes/presets.d.ts +0 -15
  723. package/themes/presets.d.ts.map +0 -1
  724. package/themes/presets.js +0 -789
  725. package/themes/presets.js.map +0 -1
  726. package/types.d.ts +0 -27
  727. package/types.d.ts.map +0 -1
  728. package/types.js +0 -2
  729. package/types.js.map +0 -1
@@ -0,0 +1,284 @@
1
+ /**
2
+ * First-sentence snip helper for the TTS first-line cache.
3
+ *
4
+ * Pure, deterministic, no I/O. Both the local runtime and the Eliza Cloud
5
+ * `/api/v1/voice/tts` route call into this module so that byte-equal sentence
6
+ * text on either side maps to byte-equal cache keys.
7
+ *
8
+ * Algorithm summary (see R4 §2 in `.swarm/research/R4-tts-cache.md`):
9
+ * 1. Trim leading whitespace.
10
+ * 2. Walk char-by-char, tracking quote depth (skip terminators inside
11
+ * `"..."`/`'...'`/`“...”`), decimal context (digit-`.`-digit isn't a
12
+ * boundary), and abbreviation context (e.g. `Mr.`, `e.g.`, `U.S.`).
13
+ * 3. First surviving terminator (`.`/`!`/`?`/`…`/`。`/`!`/`?`) or `\n`
14
+ * ends the sentence. Consume any contiguous run of terminators that
15
+ * follow (so `"Wait..."` stays intact).
16
+ * 4. If no terminator and no newline → null (don't cache unterminated text).
17
+ * 5. Apply ≤10-word filter on the normalised form. If wordCount > 10,
18
+ * return null (don't cache).
19
+ *
20
+ * `FIRST_SENTENCE_SNIP_VERSION` is part of the cache key — bumping it
21
+ * invalidates every existing cached entry.
22
+ */
23
+ /**
24
+ * Cache-key algorithm version. Bump when the snip/normalise logic changes
25
+ * in a way that would produce different keys for the same input. Local and
26
+ * cloud caches re-key off this constant, so a bump rolls the entire cache.
27
+ */
28
+ export const FIRST_SENTENCE_SNIP_VERSION = "1";
29
+ /**
30
+ * Maximum word count (Unicode-aware) for a cacheable first-sentence snip.
31
+ * Beyond this the bytes won't repeat often enough to amortise the cache.
32
+ */
33
+ export const FIRST_SENTENCE_MAX_WORDS = 10;
34
+ const ABBREVIATIONS = new Set([
35
+ "mr",
36
+ "mrs",
37
+ "ms",
38
+ "mx",
39
+ "dr",
40
+ "st",
41
+ "jr",
42
+ "sr",
43
+ "prof",
44
+ "vs",
45
+ "etc",
46
+ "eg",
47
+ "ie",
48
+ "fig",
49
+ "no",
50
+ "vol",
51
+ "ch",
52
+ "pt",
53
+ "co",
54
+ "inc",
55
+ "ltd",
56
+ "us",
57
+ "uk",
58
+ "usa",
59
+ ]);
60
+ /**
61
+ * Terminator chars that end a sentence. Includes CJK `。!?` so multilingual
62
+ * inputs aren't refused.
63
+ */
64
+ const TERMINATOR_REGEX = /[.!?…。!?]/u;
65
+ const QUOTE_PAIRS = new Map([
66
+ ['"', '"'],
67
+ ["'", "'"],
68
+ ["“", "”"],
69
+ ["‘", "’"],
70
+ ["«", "»"],
71
+ ["「", "」"],
72
+ ["『", "』"],
73
+ ]);
74
+ const CLOSE_QUOTES = new Set(QUOTE_PAIRS.values());
75
+ function isDigit(ch) {
76
+ return ch >= "0" && ch <= "9";
77
+ }
78
+ function isAlpha(ch) {
79
+ if (!ch)
80
+ return false;
81
+ const code = ch.charCodeAt(0);
82
+ return ((code >= 65 && code <= 90) || // A-Z
83
+ (code >= 97 && code <= 122) // a-z
84
+ );
85
+ }
86
+ /**
87
+ * Lower-case + strip dots from a token to compare against `ABBREVIATIONS`.
88
+ * Used to detect things like `Mr.` / `U.S.` / `e.g.` where the dot is part of
89
+ * an abbreviation rather than a sentence terminator.
90
+ */
91
+ function isAbbrevToken(token) {
92
+ if (token.length === 0 || token.length > 6)
93
+ return false;
94
+ const lower = token.toLowerCase().replace(/\./g, "");
95
+ if (!lower)
96
+ return false;
97
+ return ABBREVIATIONS.has(lower);
98
+ }
99
+ /**
100
+ * Walk the input forwards looking for the first sentence-terminating position.
101
+ * Returns the *inclusive* end index of the terminator run (so the snip is
102
+ * `text.slice(start, endInclusive + 1)`), or -1 if no terminator was found.
103
+ *
104
+ * `start` is the position after any leading whitespace.
105
+ */
106
+ function findTerminatorEnd(text, start) {
107
+ let i = start;
108
+ const quoteStack = [];
109
+ while (i < text.length) {
110
+ const ch = text[i] ?? "";
111
+ // Newline acts as a soft terminator (e.g. message body broken into lines).
112
+ if (ch === "\n") {
113
+ // Strip trailing whitespace from the run by returning index of \n.
114
+ return i;
115
+ }
116
+ // Open / close quotes for skipping terminators inside.
117
+ const closer = QUOTE_PAIRS.get(ch);
118
+ if (closer && closer !== ch) {
119
+ // Asymmetric pair → push the expected closer.
120
+ quoteStack.push(closer);
121
+ i++;
122
+ continue;
123
+ }
124
+ if (quoteStack.length > 0 && ch === quoteStack[quoteStack.length - 1]) {
125
+ quoteStack.pop();
126
+ i++;
127
+ continue;
128
+ }
129
+ // Symmetric ASCII quotes: toggle stack only when not already inside an
130
+ // asymmetric quote.
131
+ //
132
+ // Apostrophes (`'`) are NEVER treated as quote delimiters when they sit
133
+ // between two letters (contractions like `it's`, possessives like
134
+ // `Eliza's`) — otherwise a stray apostrophe would swallow the rest of
135
+ // the input and we'd never find a terminator.
136
+ if (ch === "'" && quoteStack.length === 0) {
137
+ const prev = i > 0 ? text[i - 1] : "";
138
+ const next = i + 1 < text.length ? text[i + 1] : "";
139
+ if (!(isAlpha(prev) && isAlpha(next))) {
140
+ quoteStack.push(ch);
141
+ }
142
+ i++;
143
+ continue;
144
+ }
145
+ if (ch === '"' && quoteStack.length === 0) {
146
+ quoteStack.push(ch);
147
+ i++;
148
+ continue;
149
+ }
150
+ if (quoteStack.length > 0 &&
151
+ CLOSE_QUOTES.has(quoteStack[quoteStack.length - 1] ?? "") &&
152
+ ch === quoteStack[quoteStack.length - 1]) {
153
+ quoteStack.pop();
154
+ i++;
155
+ continue;
156
+ }
157
+ // Skip everything inside quotes.
158
+ if (quoteStack.length > 0) {
159
+ i++;
160
+ continue;
161
+ }
162
+ if (!TERMINATOR_REGEX.test(ch)) {
163
+ i++;
164
+ continue;
165
+ }
166
+ // Candidate terminator. Apply guards.
167
+ if (ch === ".") {
168
+ // Decimal context: digit . digit
169
+ const prev = i > 0 ? text[i - 1] : "";
170
+ const next = i + 1 < text.length ? text[i + 1] : "";
171
+ if (isDigit(prev) && isDigit(next)) {
172
+ i++;
173
+ continue;
174
+ }
175
+ // Abbreviation context: look backwards for an alpha run, possibly
176
+ // with internal dots (e.g. `U.S.`). Bound the look-back to 6 chars.
177
+ let j = i - 1;
178
+ let token = "";
179
+ while (j >= 0 && j >= i - 6) {
180
+ const tj = text[j] ?? "";
181
+ if (isAlpha(tj) || tj === ".") {
182
+ token = tj + token;
183
+ j--;
184
+ continue;
185
+ }
186
+ break;
187
+ }
188
+ if (token && isAbbrevToken(token)) {
189
+ i++;
190
+ continue;
191
+ }
192
+ // Also: avoid treating mid-word dot as terminator if followed
193
+ // immediately by alpha and no whitespace (e.g. "foo.bar"
194
+ // shouldn't terminate). Cache hit rate is more important than
195
+ // being clever here — conservative: skip.
196
+ if (isAlpha(next)) {
197
+ i++;
198
+ continue;
199
+ }
200
+ }
201
+ // Valid terminator. Consume any contiguous run of terminator chars so
202
+ // `Wait...` stays intact, then return the inclusive end.
203
+ let end = i;
204
+ while (end + 1 < text.length) {
205
+ const nxt = text[end + 1] ?? "";
206
+ if (TERMINATOR_REGEX.test(nxt)) {
207
+ end++;
208
+ continue;
209
+ }
210
+ break;
211
+ }
212
+ return end;
213
+ }
214
+ return -1;
215
+ }
216
+ /**
217
+ * Unicode-aware word count. Hyphenated words and apostrophe-internal words
218
+ * count as one (e.g. "twenty-three" → 1, "it's" → 1). Dotted acronyms with
219
+ * single-letter segments (e.g. "U.S.", "U.S.A.") count as one word. Decimal
220
+ * numbers like "3.14" count as one word.
221
+ */
222
+ export function wordCount(s) {
223
+ if (!s)
224
+ return 0;
225
+ const matches = s.match(
226
+ // In priority order:
227
+ // - decimal number (digits . digits, possibly multi-segment)
228
+ // - dotted acronym (≥2 single-letter dot pairs)
229
+ // - regular word with optional hyphen/apostrophe internal joiners
230
+ /\p{N}+(?:\.\p{N}+)+|(?:\p{L}\.){2,}|[\p{L}\p{N}]+(?:[’'-][\p{L}\p{N}]+)*/gu);
231
+ return matches ? matches.length : 0;
232
+ }
233
+ /**
234
+ * Normalise a snip for cache-key purposes. NFC + lower-case + collapse
235
+ * whitespace + strip trailing terminators/whitespace. Apostrophes preserved.
236
+ */
237
+ export function normalizeForKey(snip) {
238
+ let s = snip.normalize("NFC");
239
+ // Trim leading whitespace including zero-width space (U+200B).
240
+ s = s.replace(/^[\s​]+/u, "").replace(/[\s​]+$/u, "");
241
+ s = s.toLowerCase();
242
+ s = s.replace(/\s+/gu, " ");
243
+ // Strip trailing terminator/whitespace run. CJK terminators included.
244
+ s = s.replace(/[\s​.!?…。!?]+$/gu, "");
245
+ return s;
246
+ }
247
+ /**
248
+ * Attempt to snip the first sentence from `text`. Returns `null` if:
249
+ * - input is empty / whitespace only
250
+ * - no sentence-terminator found
251
+ * - normalised snip has > 10 words
252
+ * - normalised snip is empty after stripping terminators
253
+ *
254
+ * Otherwise returns a `FirstSentenceSnipResult` carrying the raw and
255
+ * normalised forms plus the word count.
256
+ */
257
+ export function firstSentenceSnip(text) {
258
+ if (typeof text !== "string" || text.length === 0)
259
+ return null;
260
+ // Find start after leading whitespace (incl. zero-width space).
261
+ const trimMatch = /^[\s​]+/u.exec(text);
262
+ const start = trimMatch ? trimMatch[0].length : 0;
263
+ if (start >= text.length)
264
+ return null;
265
+ const end = findTerminatorEnd(text, start);
266
+ if (end < 0)
267
+ return null;
268
+ const raw = text.slice(start, end + 1);
269
+ const normalized = normalizeForKey(raw);
270
+ if (!normalized)
271
+ return null;
272
+ const wc = wordCount(normalized);
273
+ if (wc === 0)
274
+ return null;
275
+ if (wc > FIRST_SENTENCE_MAX_WORDS)
276
+ return null;
277
+ return {
278
+ raw,
279
+ normalized,
280
+ wordCount: wc,
281
+ endOffset: end + 1,
282
+ };
283
+ }
284
+ //# sourceMappingURL=first-sentence-snip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"first-sentence-snip.js","sourceRoot":"","sources":["../../src/voice/first-sentence-snip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAY,CAAC;AAGxD;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAW,CAAC;AAEpD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAS;IACpC,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,KAAK;CACN,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAEtC,MAAM,WAAW,GAAgC,IAAI,GAAG,CAAC;IACvD,CAAC,GAAG,EAAE,GAAG,CAAC;IACV,CAAC,GAAG,EAAE,GAAG,CAAC;IACV,CAAC,GAAG,EAAE,GAAG,CAAC;IACV,CAAC,GAAG,EAAE,GAAG,CAAC;IACV,CAAC,GAAG,EAAE,GAAG,CAAC;IACV,CAAC,GAAG,EAAE,GAAG,CAAC;IACV,CAAC,GAAG,EAAE,GAAG,CAAC;CACX,CAAC,CAAC;AAEH,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,WAAW,CAAC,MAAM,EAA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,CAAC,UAAU,CAAC,CAAC;IACjC,IAAI,EAAE,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1B,IAAI,EAAE,GAAG,wBAAwB;QAAE,OAAO,IAAI,CAAC;IAE/C,OAAO;QACL,GAAG;QACH,UAAU;QACV,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,GAAG,GAAG,CAAC;KACnB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Canonical voice cancellation token.
3
+ *
4
+ * Wave 3 W3-9 — one token per voice turn, fanned out to every layer that can
5
+ * cancel: VAD start-of-speech (barge-in), turn-detector EOT revocation,
6
+ * planner-loop / message-handler yield points, MtpLlamaServer slot abort,
7
+ * TTS playback. Built on top of `AbortController` so any consumer that
8
+ * already understands `AbortSignal` (fetch / FFI / model calls) gets cancel
9
+ * for free.
10
+ *
11
+ * Invariants:
12
+ * - One token per `runId` (one utterance).
13
+ * - `abort()` is idempotent. The first reason wins; subsequent calls are
14
+ * ignored and leave the recorded reason unchanged.
15
+ * - `signal.aborted === true` after the first `abort()`.
16
+ * - Token is forward-compatible with the legacy `BargeInCancelToken`
17
+ * shape (`cancelled`, `reason`, `signal`) so existing voice pipeline
18
+ * consumers can adopt the canonical type without a wider refactor.
19
+ *
20
+ * This file deliberately has no runtime imports (no `@elizaos/core`, no
21
+ * voice-engine imports). It is the bottom of the cancellation stack — every
22
+ * layer above (runtime, plugin, app) imports this type, never the reverse.
23
+ */
24
+ /** Why a voice turn was cancelled. Stable enum — telemetry depends on it. */
25
+ export type VoiceCancellationReason = "barge-in" | "eot-revoked" | "user-cancel" | "timeout" | "external";
26
+ /**
27
+ * Listener fired exactly once when the token transitions from active →
28
+ * aborted. Listeners added after abort fire synchronously with the recorded
29
+ * reason.
30
+ */
31
+ export type VoiceCancellationListener = (reason: VoiceCancellationReason) => void;
32
+ /**
33
+ * Per-turn cancellation handle. Carries a stable `runId`, the optional slot
34
+ * id the LM is running against (for slot-abort), and a standard `AbortSignal`
35
+ * for fetch / model layers.
36
+ */
37
+ export interface VoiceCancellationToken {
38
+ /** Stable per-utterance id. Mirrors the voice state machine's turn id. */
39
+ readonly runId: string;
40
+ /**
41
+ * The MtpLlamaServer slot the optimistic LM is running on, when known.
42
+ * `abort()` fans this out to the slot-abort path on the inference server.
43
+ */
44
+ readonly slot?: number;
45
+ /** True once `abort()` has fired. Cheap polling field. */
46
+ readonly aborted: boolean;
47
+ /** Set when `abort()` fires; null while active. */
48
+ readonly reason: VoiceCancellationReason | null;
49
+ /** Standard `AbortSignal` for fetch / model / FFI consumers. */
50
+ readonly signal: AbortSignal;
51
+ /**
52
+ * Trip the token. Idempotent. First call wins; subsequent calls are
53
+ * ignored. Fires every registered `onAbort` listener synchronously.
54
+ */
55
+ abort(reason: VoiceCancellationReason): void;
56
+ /**
57
+ * Subscribe to abort. Returns an unsubscribe function. Listeners
58
+ * registered after the token has aborted fire synchronously with the
59
+ * recorded reason.
60
+ */
61
+ onAbort(listener: VoiceCancellationListener): () => void;
62
+ }
63
+ export interface CreateVoiceCancellationTokenOptions {
64
+ runId: string;
65
+ slot?: number;
66
+ /**
67
+ * Optional pre-existing `AbortSignal` to also honor. When this signal
68
+ * aborts (e.g. the runtime's per-turn signal from
69
+ * `TurnControllerRegistry`), the voice token aborts with reason
70
+ * `"external"` so the voice loop sees the runtime abort.
71
+ */
72
+ linkSignal?: AbortSignal;
73
+ }
74
+ /**
75
+ * Construct a fresh voice cancellation token.
76
+ *
77
+ * Implementation note: a single `AbortController` backs the public `signal`.
78
+ * Listener bookkeeping lives next to the controller (rather than via the
79
+ * `AbortSignal`'s native `addEventListener`) because we want to:
80
+ * 1. Guarantee listeners fire even when the abort was triggered by a
81
+ * linked signal (the native `addEventListener` path also works, but
82
+ * this is cheaper and gives us synchronous semantics for
83
+ * after-abort `onAbort` registrations).
84
+ * 2. Surface the `reason` enum, not a raw `DOMException` from the
85
+ * AbortSignal.
86
+ */
87
+ export declare function createVoiceCancellationToken(opts: CreateVoiceCancellationTokenOptions): VoiceCancellationToken;
88
+ /**
89
+ * Already-aborted token. Useful as a zero-cost default for code paths that
90
+ * have no live voice session but still want to type-thread a token through.
91
+ * The `runId` is the empty string — callers that depend on a stable id must
92
+ * pass their own.
93
+ */
94
+ export declare function createAbortedVoiceCancellationToken(reason?: VoiceCancellationReason): VoiceCancellationToken;
95
+ /**
96
+ * Per-room registry. Keeps the active voice token for each `roomId` so
97
+ * unrelated layers (the message handler, an HTTP route, the audio sink)
98
+ * can fetch the live token without holding a reference. Mirrors the shape
99
+ * of `TurnControllerRegistry` in `@elizaos/core/runtime/turn-controller`.
100
+ */
101
+ export declare class VoiceCancellationRegistry {
102
+ private readonly byRoom;
103
+ /**
104
+ * Replace the active token for `roomId`. The previous token (if any) is
105
+ * aborted with `"external"` so any orphaned background work cleans up.
106
+ * Returns the new token.
107
+ */
108
+ arm(roomId: string, opts: CreateVoiceCancellationTokenOptions): VoiceCancellationToken;
109
+ /** Fetch the active token for `roomId`, or null. */
110
+ current(roomId: string): VoiceCancellationToken | null;
111
+ /**
112
+ * Abort the active token for `roomId`. Returns true if a live token was
113
+ * aborted. Returns false when there is no active token or it's already aborted.
114
+ */
115
+ abort(roomId: string, reason: VoiceCancellationReason): boolean;
116
+ /**
117
+ * Abort every active token. Used by lifecycle shutdown (the runtime's
118
+ * `abortInflightInference` hook fires this so the voice loop drops in
119
+ * sync with the runtime).
120
+ */
121
+ abortAll(reason: VoiceCancellationReason): string[];
122
+ /** Snapshot of live room ids. Diagnostic. */
123
+ activeRoomIds(): string[];
124
+ /** Test seam: drop everything. */
125
+ clear(): void;
126
+ }
127
+ //# sourceMappingURL=voice-cancellation-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voice-cancellation-token.d.ts","sourceRoot":"","sources":["../../src/voice/voice-cancellation-token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,6EAA6E;AAC7E,MAAM,MAAM,uBAAuB,GAC/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AG,IAAI;IAItD;;;OAGG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB,GAAG,OAAO;IAO/D;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,EAAE;IAWnD,6CAA6C;IAC7C,aAAa,IAAI,MAAM,EAAE;IAOzB,kCAAkC;IAClC,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Canonical voice cancellation token.
3
+ *
4
+ * Wave 3 W3-9 — one token per voice turn, fanned out to every layer that can
5
+ * cancel: VAD start-of-speech (barge-in), turn-detector EOT revocation,
6
+ * planner-loop / message-handler yield points, MtpLlamaServer slot abort,
7
+ * TTS playback. Built on top of `AbortController` so any consumer that
8
+ * already understands `AbortSignal` (fetch / FFI / model calls) gets cancel
9
+ * for free.
10
+ *
11
+ * Invariants:
12
+ * - One token per `runId` (one utterance).
13
+ * - `abort()` is idempotent. The first reason wins; subsequent calls are
14
+ * ignored and leave the recorded reason unchanged.
15
+ * - `signal.aborted === true` after the first `abort()`.
16
+ * - Token is forward-compatible with the legacy `BargeInCancelToken`
17
+ * shape (`cancelled`, `reason`, `signal`) so existing voice pipeline
18
+ * consumers can adopt the canonical type without a wider refactor.
19
+ *
20
+ * This file deliberately has no runtime imports (no `@elizaos/core`, no
21
+ * voice-engine imports). It is the bottom of the cancellation stack — every
22
+ * layer above (runtime, plugin, app) imports this type, never the reverse.
23
+ */
24
+ /**
25
+ * Construct a fresh voice cancellation token.
26
+ *
27
+ * Implementation note: a single `AbortController` backs the public `signal`.
28
+ * Listener bookkeeping lives next to the controller (rather than via the
29
+ * `AbortSignal`'s native `addEventListener`) because we want to:
30
+ * 1. Guarantee listeners fire even when the abort was triggered by a
31
+ * linked signal (the native `addEventListener` path also works, but
32
+ * this is cheaper and gives us synchronous semantics for
33
+ * after-abort `onAbort` registrations).
34
+ * 2. Surface the `reason` enum, not a raw `DOMException` from the
35
+ * AbortSignal.
36
+ */
37
+ export function createVoiceCancellationToken(opts) {
38
+ const controller = new AbortController();
39
+ const listeners = new Set();
40
+ const state = { aborted: false, reason: null };
41
+ const trip = (reason) => {
42
+ if (state.aborted)
43
+ return;
44
+ state.aborted = true;
45
+ state.reason = reason;
46
+ // Call listeners BEFORE aborting the controller so a listener that
47
+ // itself awaits the signal sees the same reason this token recorded
48
+ // (otherwise listeners that observe `signal.aborted` could race).
49
+ for (const listener of Array.from(listeners)) {
50
+ try {
51
+ listener(reason);
52
+ }
53
+ catch {
54
+ // Listener errors are swallowed; telemetry should not affect
55
+ // cancellation propagation.
56
+ }
57
+ }
58
+ controller.abort();
59
+ };
60
+ if (opts.linkSignal) {
61
+ if (opts.linkSignal.aborted) {
62
+ trip("external");
63
+ }
64
+ else {
65
+ const onLinkAbort = () => trip("external");
66
+ opts.linkSignal.addEventListener("abort", onLinkAbort, { once: true });
67
+ }
68
+ }
69
+ const token = {
70
+ runId: opts.runId,
71
+ ...(opts.slot !== undefined ? { slot: opts.slot } : {}),
72
+ get aborted() {
73
+ return state.aborted;
74
+ },
75
+ get reason() {
76
+ return state.reason;
77
+ },
78
+ signal: controller.signal,
79
+ abort(reason) {
80
+ trip(reason);
81
+ },
82
+ onAbort(listener) {
83
+ if (state.aborted) {
84
+ // Synchronous after-abort fan-out. Caller may still want the
85
+ // hook even though the token already aborted — fire once.
86
+ const reason = state.reason ?? "external";
87
+ try {
88
+ listener(reason);
89
+ }
90
+ catch {
91
+ // see above
92
+ }
93
+ return () => undefined;
94
+ }
95
+ listeners.add(listener);
96
+ return () => {
97
+ listeners.delete(listener);
98
+ };
99
+ },
100
+ };
101
+ return token;
102
+ }
103
+ /**
104
+ * Already-aborted token. Useful as a zero-cost default for code paths that
105
+ * have no live voice session but still want to type-thread a token through.
106
+ * The `runId` is the empty string — callers that depend on a stable id must
107
+ * pass their own.
108
+ */
109
+ export function createAbortedVoiceCancellationToken(reason = "external") {
110
+ const t = createVoiceCancellationToken({ runId: "" });
111
+ t.abort(reason);
112
+ return t;
113
+ }
114
+ /**
115
+ * Per-room registry. Keeps the active voice token for each `roomId` so
116
+ * unrelated layers (the message handler, an HTTP route, the audio sink)
117
+ * can fetch the live token without holding a reference. Mirrors the shape
118
+ * of `TurnControllerRegistry` in `@elizaos/core/runtime/turn-controller`.
119
+ */
120
+ export class VoiceCancellationRegistry {
121
+ byRoom = new Map();
122
+ /**
123
+ * Replace the active token for `roomId`. The previous token (if any) is
124
+ * aborted with `"external"` so any orphaned background work cleans up.
125
+ * Returns the new token.
126
+ */
127
+ arm(roomId, opts) {
128
+ const previous = this.byRoom.get(roomId);
129
+ if (previous && !previous.aborted) {
130
+ previous.abort("external");
131
+ }
132
+ const token = createVoiceCancellationToken(opts);
133
+ this.byRoom.set(roomId, token);
134
+ // Self-clean: when the token aborts, drop it from the map IF it is
135
+ // still the active one. (Tokens that have been replaced via a later
136
+ // `arm()` will already be evicted.)
137
+ token.onAbort(() => {
138
+ if (this.byRoom.get(roomId) === token) {
139
+ this.byRoom.delete(roomId);
140
+ }
141
+ });
142
+ return token;
143
+ }
144
+ /** Fetch the active token for `roomId`, or null. */
145
+ current(roomId) {
146
+ return this.byRoom.get(roomId) ?? null;
147
+ }
148
+ /**
149
+ * Abort the active token for `roomId`. Returns true if a live token was
150
+ * aborted. Returns false when there is no active token or it's already aborted.
151
+ */
152
+ abort(roomId, reason) {
153
+ const token = this.byRoom.get(roomId);
154
+ if (!token || token.aborted)
155
+ return false;
156
+ token.abort(reason);
157
+ return true;
158
+ }
159
+ /**
160
+ * Abort every active token. Used by lifecycle shutdown (the runtime's
161
+ * `abortInflightInference` hook fires this so the voice loop drops in
162
+ * sync with the runtime).
163
+ */
164
+ abortAll(reason) {
165
+ const aborted = [];
166
+ for (const [roomId, token] of Array.from(this.byRoom.entries())) {
167
+ if (!token.aborted) {
168
+ token.abort(reason);
169
+ aborted.push(roomId);
170
+ }
171
+ }
172
+ return aborted;
173
+ }
174
+ /** Snapshot of live room ids. Diagnostic. */
175
+ activeRoomIds() {
176
+ return Array.from(this.byRoom.keys()).filter((roomId) => {
177
+ const token = this.byRoom.get(roomId);
178
+ return token !== undefined && !token.aborted;
179
+ });
180
+ }
181
+ /** Test seam: drop everything. */
182
+ clear() {
183
+ this.byRoom.clear();
184
+ }
185
+ }
186
+ //# sourceMappingURL=voice-cancellation-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voice-cancellation-token.js","sourceRoot":"","sources":["../../src/voice/voice-cancellation-token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAoEH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,4BAA4B,CAC1C,IAAyC;IAEzC,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA6B,CAAC;IACvD,MAAM,KAAK,GAAkB,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAE9D,MAAM,IAAI,GAAG,CAAC,MAA+B,EAAQ,EAAE;QACrD,IAAI,KAAK,CAAC,OAAO;YAAE,OAAO;QAC1B,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACrB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;QACtB,mEAAmE;QACnE,oEAAoE;QACpE,kEAAkE;QAClE,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7C,IAAI,CAAC;gBACH,QAAQ,CAAC,MAAM,CAAC,CAAC;YACnB,CAAC;YAAC,MAAM,CAAC;gBACP,6DAA6D;gBAC7D,4BAA4B;YAC9B,CAAC;QACH,CAAC;QACD,UAAU,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC,CAAC;IAEF,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YAC5B,IAAI,CAAC,UAAU,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,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAC1C,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,MAA+B;QACtC,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;YAChE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;gBACnB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBACpB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,6CAA6C;IAC7C,aAAa;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YACtD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACtC,OAAO,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,kCAAkC;IAClC,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF"}
package/voice-wer.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Word-error-rate scoring — the single source of truth (#8785).
3
+ *
4
+ * Both the headless metric library (plugin-local-inference `e2e-harness.ts`) and
5
+ * the headful self-test (ui `voice-selftest-harness.ts`) need WER; this used to
6
+ * be implemented twice with subtly different normalization. It lives in
7
+ * `@elizaos/shared` (which both already depend on) so there is exactly one
8
+ * definition. Pure + browser-safe (no Node deps), so it ships in the UI bundle
9
+ * via the `@elizaos/shared/voice-wer` subpath without pulling the whole barrel.
10
+ */
11
+ /** Lowercase, strip punctuation (keep letters/numbers/apostrophes), collapse WS. */
12
+ export declare function normalizeWerText(text: string): string;
13
+ /**
14
+ * Levenshtein word-error-rate of `hypothesis` against `reference`
15
+ * (substitutions + insertions + deletions, divided by reference word count).
16
+ * An empty reference scores 0 against an empty hypothesis, else 1.
17
+ */
18
+ export declare function wordErrorRate(reference: string, hypothesis: string): number;
19
+ //# sourceMappingURL=voice-wer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voice-wer.d.ts","sourceRoot":"","sources":["../src/voice-wer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMrD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAgB3E"}