@elizaos/ui 2.0.0-alpha.383 → 2.0.0-alpha.385

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 (777) hide show
  1. package/apps/app-companion/src/components/avatar/VrmViewer.d.ts.map +1 -1
  2. package/apps/app-companion/src/components/avatar/VrmViewer.js +2 -1
  3. package/apps/app-companion/src/components/companion/CompanionAppView.d.ts.map +1 -1
  4. package/apps/app-companion/src/components/companion/CompanionAppView.js +2 -1
  5. package/apps/app-companion/src/components/companion/CompanionView.d.ts.map +1 -1
  6. package/apps/app-companion/src/components/companion/CompanionView.js +2 -1
  7. package/apps/app-companion/src/components/companion/EmotePicker.d.ts.map +1 -1
  8. package/apps/app-companion/src/components/companion/EmotePicker.js +1 -1
  9. package/apps/app-companion/src/components/companion/scene-overlay-bridge.d.ts.map +1 -1
  10. package/apps/app-companion/src/components/companion/scene-overlay-bridge.js +2 -1
  11. package/apps/app-companion/src/index.d.ts +3 -3
  12. package/apps/app-companion/src/index.d.ts.map +1 -1
  13. package/apps/app-companion/src/index.js +3 -3
  14. package/apps/app-elizamaker/src/drop-service.d.ts +2 -2
  15. package/apps/app-elizamaker/src/drop-service.d.ts.map +1 -1
  16. package/apps/app-elizamaker/src/twitter-verify.d.ts +2 -2
  17. package/apps/app-elizamaker/src/twitter-verify.d.ts.map +1 -1
  18. package/apps/app-lifeops/src/api/client-lifeops.d.ts +1 -1
  19. package/apps/app-lifeops/src/api/client-lifeops.d.ts.map +1 -1
  20. package/apps/app-lifeops/src/contracts/index.d.ts +1 -1
  21. package/apps/app-lifeops/src/contracts/index.d.ts.map +1 -1
  22. package/apps/app-lifeops/src/contracts/index.js +1 -1
  23. package/apps/app-lifeops/src/inbox/message-fetcher.d.ts.map +1 -1
  24. package/apps/app-lifeops/src/inbox/message-fetcher.js +4 -2
  25. package/apps/app-lifeops/src/lifeops/google-managed-client.d.ts.map +1 -1
  26. package/apps/app-lifeops/src/lifeops/google-managed-client.js +4 -3
  27. package/apps/app-lifeops/src/lifeops/paypal-managed-client.d.ts.map +1 -1
  28. package/apps/app-lifeops/src/lifeops/paypal-managed-client.js +4 -3
  29. package/apps/app-lifeops/src/lifeops/plaid-managed-client.d.ts.map +1 -1
  30. package/apps/app-lifeops/src/lifeops/plaid-managed-client.js +4 -3
  31. package/apps/app-lifeops/src/lifeops/repository.d.ts +12 -1
  32. package/apps/app-lifeops/src/lifeops/repository.d.ts.map +1 -1
  33. package/apps/app-lifeops/src/lifeops/repository.js +135 -0
  34. package/apps/app-lifeops/src/lifeops/schedule-sync-client.js +1 -1
  35. package/apps/app-lifeops/src/lifeops/schema.d.ts +4587 -3791
  36. package/apps/app-lifeops/src/lifeops/schema.d.ts.map +1 -1
  37. package/apps/app-lifeops/src/lifeops/schema.js +30 -0
  38. package/apps/app-lifeops/src/lifeops/service-mixin-inbox.d.ts +2 -0
  39. package/apps/app-lifeops/src/lifeops/service-mixin-inbox.d.ts.map +1 -1
  40. package/apps/app-lifeops/src/lifeops/service-mixin-inbox.js +103 -13
  41. package/apps/app-lifeops/src/routes/cloud-features-routes.d.ts.map +1 -1
  42. package/apps/app-lifeops/src/routes/cloud-features-routes.js +2 -1
  43. package/apps/app-lifeops/src/routes/travel-provider-relay-routes.d.ts.map +1 -1
  44. package/apps/app-lifeops/src/routes/travel-provider-relay-routes.js +2 -1
  45. package/package.json +1 -1
  46. package/packages/agent/src/actions/grounded-action-reply.d.ts.map +1 -1
  47. package/packages/agent/src/actions/grounded-action-reply.js +1 -1
  48. package/packages/agent/src/actions/index.d.ts +1 -0
  49. package/packages/agent/src/actions/index.d.ts.map +1 -1
  50. package/packages/agent/src/actions/index.js +1 -0
  51. package/packages/agent/src/actions/scratchpad.d.ts +7 -0
  52. package/packages/agent/src/actions/scratchpad.d.ts.map +1 -0
  53. package/packages/agent/src/actions/scratchpad.js +394 -0
  54. package/packages/agent/src/actions/settings-actions.js +1 -1
  55. package/packages/agent/src/actions/terminal.d.ts.map +1 -1
  56. package/packages/agent/src/actions/terminal.js +10 -2
  57. package/packages/agent/src/api/apps-routes.d.ts.map +1 -1
  58. package/packages/agent/src/api/apps-routes.js +171 -0
  59. package/packages/agent/src/api/binance-skill-helpers.d.ts.map +1 -1
  60. package/packages/agent/src/api/chat-routes.d.ts +3 -0
  61. package/packages/agent/src/api/chat-routes.d.ts.map +1 -1
  62. package/packages/agent/src/api/chat-routes.js +32 -13
  63. package/packages/agent/src/api/conversation-routes.js +2 -2
  64. package/packages/agent/src/api/misc-routes.d.ts.map +1 -1
  65. package/packages/agent/src/api/misc-routes.js +2 -2
  66. package/packages/agent/src/api/permissions-routes.js +1 -1
  67. package/packages/agent/src/api/plugin-routes.d.ts.map +1 -1
  68. package/packages/agent/src/api/plugin-routes.js +7 -1
  69. package/packages/agent/src/api/provider-switch-config.js +1 -1
  70. package/packages/agent/src/api/registry-service.d.ts +1 -1
  71. package/packages/agent/src/api/registry-service.d.ts.map +1 -1
  72. package/packages/agent/src/api/server-auth.d.ts.map +1 -1
  73. package/packages/agent/src/api/server-auth.js +119 -1
  74. package/packages/agent/src/api/server-helpers-auth.d.ts.map +1 -1
  75. package/packages/agent/src/api/server-helpers-auth.js +119 -1
  76. package/packages/agent/src/api/server-helpers-swarm.d.ts +1 -1
  77. package/packages/agent/src/api/server-helpers-swarm.d.ts.map +1 -1
  78. package/packages/agent/src/api/server-helpers.js +1 -1
  79. package/packages/agent/src/api/server-types.d.ts +2 -2
  80. package/packages/agent/src/api/server-types.d.ts.map +1 -1
  81. package/packages/agent/src/api/server.d.ts.map +1 -1
  82. package/packages/agent/src/api/server.js +5 -4
  83. package/packages/agent/src/api/training-backend-check.d.ts +1 -1
  84. package/packages/agent/src/api/training-backend-check.d.ts.map +1 -1
  85. package/packages/agent/src/api/training-backend-check.js +1 -1
  86. package/packages/agent/src/api/training-routes.d.ts +1 -1
  87. package/packages/agent/src/api/training-routes.d.ts.map +1 -1
  88. package/packages/agent/src/api/training-routes.js +1 -1
  89. package/packages/agent/src/api/training-service-like.d.ts +1 -1
  90. package/packages/agent/src/api/training-service-like.d.ts.map +1 -1
  91. package/packages/agent/src/api/trajectory-routes.d.ts +1 -1
  92. package/packages/agent/src/api/trajectory-routes.d.ts.map +1 -1
  93. package/packages/agent/src/api/trajectory-routes.js +1 -1
  94. package/packages/agent/src/api/wallet-capability.js +1 -1
  95. package/packages/agent/src/api/wallet-evm-balance.js +1 -1
  96. package/packages/agent/src/api/wallet.d.ts +1 -1
  97. package/packages/agent/src/api/wallet.d.ts.map +1 -1
  98. package/packages/agent/src/api/wallet.js +2 -2
  99. package/packages/agent/src/awareness/index.d.ts +2 -0
  100. package/packages/agent/src/awareness/index.d.ts.map +1 -0
  101. package/packages/agent/src/awareness/index.js +1 -0
  102. package/packages/agent/src/config/config.d.ts.map +1 -1
  103. package/packages/agent/src/config/config.js +2 -0
  104. package/packages/agent/src/config/index.d.ts +1 -0
  105. package/packages/agent/src/config/index.d.ts.map +1 -1
  106. package/packages/agent/src/config/index.js +1 -0
  107. package/packages/agent/src/config/model-metadata.d.ts +20 -0
  108. package/packages/agent/src/config/model-metadata.d.ts.map +1 -0
  109. package/packages/agent/src/config/model-metadata.js +133 -0
  110. package/packages/agent/src/config/zod-schema.core.d.ts +28 -28
  111. package/packages/agent/src/config/zod-schema.core.d.ts.map +1 -1
  112. package/packages/agent/src/config/zod-schema.core.js +16 -9
  113. package/packages/agent/src/config/zod-schema.d.ts +10 -10
  114. package/packages/agent/src/index.d.ts +6 -11
  115. package/packages/agent/src/index.d.ts.map +1 -1
  116. package/packages/agent/src/index.js +8 -10
  117. package/packages/agent/src/providers/media-provider.js +1 -1
  118. package/packages/agent/src/runtime/custom-actions.d.ts.map +1 -1
  119. package/packages/agent/src/runtime/custom-actions.js +1 -1
  120. package/packages/agent/src/runtime/eliza-plugin.d.ts.map +1 -1
  121. package/packages/agent/src/runtime/eliza-plugin.js +6 -0
  122. package/packages/agent/src/runtime/eliza.d.ts.map +1 -1
  123. package/packages/agent/src/runtime/eliza.js +7 -7
  124. package/packages/agent/src/runtime/prompt-optimization.d.ts +24 -1
  125. package/packages/agent/src/runtime/prompt-optimization.d.ts.map +1 -1
  126. package/packages/agent/src/runtime/prompt-optimization.js +292 -27
  127. package/packages/agent/src/runtime/trajectory-internals.d.ts +1 -0
  128. package/packages/agent/src/runtime/trajectory-internals.d.ts.map +1 -1
  129. package/packages/agent/src/runtime/trajectory-storage.d.ts.map +1 -1
  130. package/packages/agent/src/runtime/trajectory-storage.js +3 -0
  131. package/packages/agent/src/services/index.d.ts +4 -4
  132. package/packages/agent/src/services/index.d.ts.map +1 -1
  133. package/packages/agent/src/services/index.js +2 -2
  134. package/packages/agent/src/services/registry-client-app-meta.d.ts.map +1 -1
  135. package/packages/agent/src/services/registry-client-app-meta.js +0 -61
  136. package/packages/agent/src/services/skill-marketplace.d.ts.map +1 -1
  137. package/packages/app-core/src/App.js +1 -1
  138. package/packages/app-core/src/api/auth.js +1 -1
  139. package/packages/app-core/src/api/client-agent.d.ts +1 -2
  140. package/packages/app-core/src/api/client-agent.d.ts.map +1 -1
  141. package/packages/app-core/src/api/client-chat.d.ts +10 -1
  142. package/packages/app-core/src/api/client-chat.d.ts.map +1 -1
  143. package/packages/app-core/src/api/client-chat.js +33 -0
  144. package/packages/app-core/src/api/client-skills.d.ts.map +1 -1
  145. package/packages/app-core/src/api/client-types-chat.d.ts +1 -0
  146. package/packages/app-core/src/api/client-types-chat.d.ts.map +1 -1
  147. package/packages/app-core/src/api/client-types-config.d.ts +2 -2
  148. package/packages/app-core/src/api/client-types-config.d.ts.map +1 -1
  149. package/packages/app-core/src/api/client-wallet.d.ts +2 -4
  150. package/packages/app-core/src/api/client-wallet.d.ts.map +1 -1
  151. package/packages/app-core/src/api/client.d.ts +3 -4
  152. package/packages/app-core/src/api/client.d.ts.map +1 -1
  153. package/packages/app-core/src/api/client.js +1 -1
  154. package/packages/app-core/src/api/compat-route-shared.d.ts +1 -1
  155. package/packages/app-core/src/api/compat-route-shared.d.ts.map +1 -1
  156. package/packages/app-core/src/api/compat-route-shared.js +117 -1
  157. package/packages/app-core/src/api/server-cloud-tts.js +1 -1
  158. package/packages/app-core/src/api/trusted-local-request.d.ts +4 -0
  159. package/packages/app-core/src/api/trusted-local-request.d.ts.map +1 -0
  160. package/packages/app-core/src/api/trusted-local-request.js +176 -0
  161. package/packages/app-core/src/autonomy/index.d.ts.map +1 -1
  162. package/packages/app-core/src/autonomy/index.js +3 -1
  163. package/packages/app-core/src/components/auth/LoginView.d.ts +3 -23
  164. package/packages/app-core/src/components/auth/LoginView.d.ts.map +1 -1
  165. package/packages/app-core/src/components/auth/LoginView.js +43 -33
  166. package/packages/app-core/src/components/chat/AppsSection.d.ts.map +1 -1
  167. package/packages/app-core/src/components/chat/AppsSection.js +61 -6
  168. package/packages/app-core/src/components/chat/MessageContent.d.ts.map +1 -1
  169. package/packages/app-core/src/components/chat/MessageContent.js +26 -3
  170. package/packages/app-core/src/components/chat/message-choice-parser.d.ts +20 -0
  171. package/packages/app-core/src/components/chat/message-choice-parser.d.ts.map +1 -0
  172. package/packages/app-core/src/components/chat/message-choice-parser.js +53 -0
  173. package/packages/app-core/src/components/chat/widgets/ChoiceWidget.d.ts +24 -0
  174. package/packages/app-core/src/components/chat/widgets/ChoiceWidget.d.ts.map +1 -0
  175. package/packages/app-core/src/components/chat/widgets/ChoiceWidget.js +38 -0
  176. package/packages/app-core/src/components/connectors/ConnectorSetupPanel.js +1 -1
  177. package/packages/app-core/src/components/custom-actions/CustomActionEditor.d.ts.map +1 -1
  178. package/packages/app-core/src/components/custom-actions/CustomActionsPanel.d.ts.map +1 -1
  179. package/packages/app-core/src/components/custom-actions/CustomActionsView.d.ts.map +1 -1
  180. package/packages/app-core/src/components/custom-actions/custom-action-form.d.ts.map +1 -1
  181. package/packages/app-core/src/components/pages/BrowserWorkspaceView.js +1 -1
  182. package/packages/app-core/src/components/pages/KnowledgeView.d.ts.map +1 -1
  183. package/packages/app-core/src/components/pages/KnowledgeView.js +11 -1
  184. package/packages/app-core/src/components/pages/PluginConfigForm.d.ts.map +1 -1
  185. package/packages/app-core/src/components/pages/PluginConfigForm.js +1 -1
  186. package/packages/app-core/src/components/pages/ScratchpadView.d.ts +2 -0
  187. package/packages/app-core/src/components/pages/ScratchpadView.d.ts.map +1 -0
  188. package/packages/app-core/src/components/pages/ScratchpadView.js +364 -0
  189. package/packages/app-core/src/components/pages/SettingsView.d.ts.map +1 -1
  190. package/packages/app-core/src/components/pages/SettingsView.js +29 -5
  191. package/packages/app-core/src/components/pages/VectorBrowserView.d.ts.map +1 -1
  192. package/packages/app-core/src/components/pages/VectorBrowserView.js +1 -1
  193. package/packages/app-core/src/components/pages/config-page-sections.d.ts +1 -1
  194. package/packages/app-core/src/components/pages/config-page-sections.d.ts.map +1 -1
  195. package/packages/app-core/src/components/pages/config-page-sections.js +1 -1
  196. package/packages/app-core/src/components/pages/plugin-list-utils.d.ts +1 -1
  197. package/packages/app-core/src/components/pages/plugin-list-utils.d.ts.map +1 -1
  198. package/packages/app-core/src/components/pages/useBrowserWorkspaceWalletBridge.d.ts +1 -1
  199. package/packages/app-core/src/components/pages/useBrowserWorkspaceWalletBridge.d.ts.map +1 -1
  200. package/packages/app-core/src/components/pages/useBrowserWorkspaceWalletBridge.js +1 -1
  201. package/packages/app-core/src/components/settings/ApiKeyConfig.js +1 -1
  202. package/packages/app-core/src/components/settings/AppearanceSettingsSection.d.ts.map +1 -1
  203. package/packages/app-core/src/components/settings/AppearanceSettingsSection.js +1 -1
  204. package/packages/app-core/src/components/settings/AppsManagementSection.d.ts +12 -0
  205. package/packages/app-core/src/components/settings/AppsManagementSection.d.ts.map +1 -0
  206. package/packages/app-core/src/components/settings/AppsManagementSection.js +285 -0
  207. package/packages/app-core/src/components/settings/PermissionsSection.js +1 -1
  208. package/packages/app-core/src/components/settings/ProviderSwitcher.d.ts.map +1 -1
  209. package/packages/app-core/src/components/settings/ProviderSwitcher.js +2 -2
  210. package/packages/app-core/src/components/settings/SecuritySettingsSection.d.ts.map +1 -1
  211. package/packages/app-core/src/components/settings/SecuritySettingsSection.js +150 -33
  212. package/packages/app-core/src/components/settings/cloud-model-schema.d.ts +1 -1
  213. package/packages/app-core/src/components/settings/cloud-model-schema.d.ts.map +1 -1
  214. package/packages/app-core/src/components/shell/Header.d.ts.map +1 -1
  215. package/packages/app-core/src/components/shell/Header.js +28 -1
  216. package/packages/app-core/src/components/steward/injected.d.ts.map +1 -1
  217. package/packages/app-core/src/components/steward/injected.js +1 -1
  218. package/packages/app-core/src/components/training/injected.d.ts.map +1 -1
  219. package/packages/app-core/src/components/training/injected.js +1 -1
  220. package/packages/app-core/src/config/boot-config-store.d.ts +1 -1
  221. package/packages/app-core/src/config/boot-config-store.d.ts.map +1 -1
  222. package/packages/app-core/src/content-packs/bundled-packs.d.ts.map +1 -1
  223. package/packages/app-core/src/hooks/index.d.ts +0 -2
  224. package/packages/app-core/src/hooks/index.d.ts.map +1 -1
  225. package/packages/app-core/src/hooks/index.js +0 -2
  226. package/packages/app-core/src/hooks/useAuthStatus.d.ts +5 -0
  227. package/packages/app-core/src/hooks/useAuthStatus.d.ts.map +1 -1
  228. package/packages/app-core/src/hooks/useAuthStatus.js +41 -18
  229. package/packages/app-core/src/hooks/useSignalPairing.d.ts +1 -1
  230. package/packages/app-core/src/hooks/useSignalPairing.d.ts.map +1 -1
  231. package/packages/app-core/src/hooks/useWhatsAppPairing.d.ts +1 -1
  232. package/packages/app-core/src/hooks/useWhatsAppPairing.d.ts.map +1 -1
  233. package/packages/app-core/src/i18n/locales/en.json +0 -1
  234. package/packages/app-core/src/i18n/locales/es.json +0 -1
  235. package/packages/app-core/src/i18n/locales/ko.json +0 -1
  236. package/packages/app-core/src/i18n/locales/pt.json +0 -1
  237. package/packages/app-core/src/i18n/locales/tl.json +0 -1
  238. package/packages/app-core/src/i18n/locales/vi.json +0 -1
  239. package/packages/app-core/src/i18n/locales/zh-CN.json +0 -1
  240. package/packages/app-core/src/index.d.ts +0 -1
  241. package/packages/app-core/src/index.d.ts.map +1 -1
  242. package/packages/app-core/src/index.js +0 -1
  243. package/packages/app-core/src/runtime/channel-plugin-map.d.ts.map +1 -1
  244. package/packages/app-core/src/runtime/channel-plugin-map.js +1 -1
  245. package/packages/app-core/src/runtime/plugin-manager-guard.d.ts.map +1 -1
  246. package/packages/app-core/src/runtime/plugin-manager-guard.js +1 -1
  247. package/packages/app-core/src/services/plugin-installer.d.ts.map +1 -1
  248. package/packages/app-core/src/services/plugin-installer.js +1 -8
  249. package/packages/app-core/src/state/index.d.ts +0 -1
  250. package/packages/app-core/src/state/index.d.ts.map +1 -1
  251. package/packages/app-core/src/state/index.js +0 -1
  252. package/packages/app-core/src/state/startup-phase-restore.d.ts.map +1 -1
  253. package/packages/app-core/src/state/startup-phase-restore.js +1 -1
  254. package/packages/app-core/src/state/useOnboardingState.js +2 -2
  255. package/packages/app-core/src/state/usePluginsSkillsState.d.ts +4 -4
  256. package/packages/app-core/src/types/index.d.ts +1 -1
  257. package/packages/app-core/src/types/index.d.ts.map +1 -1
  258. package/packages/shared/src/contracts/index.d.ts +1 -0
  259. package/packages/shared/src/contracts/index.d.ts.map +1 -1
  260. package/packages/shared/src/contracts/index.js +1 -0
  261. package/packages/shared/src/contracts/scratchpad.d.ts +136 -0
  262. package/packages/shared/src/contracts/scratchpad.d.ts.map +1 -0
  263. package/packages/shared/src/contracts/scratchpad.js +90 -0
  264. package/packages/shared/src/index.d.ts +13 -13
  265. package/packages/shared/src/index.d.ts.map +1 -1
  266. package/packages/shared/src/index.js +19 -19
  267. package/packages/shared/src/spoken-text.js +1 -1
  268. package/packages/typescript/src/features/advanced-capabilities/evaluators/factExtractor.d.ts.map +1 -1
  269. package/packages/typescript/src/features/advanced-capabilities/evaluators/factExtractor.js +12 -6
  270. package/packages/typescript/src/generated/action-docs.d.ts +25 -0
  271. package/packages/typescript/src/generated/action-docs.d.ts.map +1 -1
  272. package/packages/typescript/src/generated/action-docs.js +51 -0
  273. package/packages/typescript/src/services/message.d.ts.map +1 -1
  274. package/packages/typescript/src/services/message.js +1 -3
  275. package/packages/typescript/src/types/tools.d.ts.map +1 -1
  276. package/packages/typescript/src/types/tools.js +7 -3
  277. package/apps/app-lifeops/src/action.d.ts +0 -3
  278. package/apps/app-lifeops/src/action.d.ts.map +0 -1
  279. package/apps/app-lifeops/src/action.js +0 -351
  280. package/apps/app-lifeops/src/actions/activity-report.d.ts +0 -13
  281. package/apps/app-lifeops/src/actions/activity-report.d.ts.map +0 -1
  282. package/apps/app-lifeops/src/actions/activity-report.js +0 -313
  283. package/apps/app-lifeops/src/actions/app-blocker.d.ts +0 -7
  284. package/apps/app-lifeops/src/actions/app-blocker.d.ts.map +0 -1
  285. package/apps/app-lifeops/src/actions/app-blocker.js +0 -454
  286. package/apps/app-lifeops/src/actions/approval.d.ts +0 -21
  287. package/apps/app-lifeops/src/actions/approval.d.ts.map +0 -1
  288. package/apps/app-lifeops/src/actions/approval.js +0 -342
  289. package/apps/app-lifeops/src/actions/autofill.d.ts +0 -35
  290. package/apps/app-lifeops/src/actions/autofill.d.ts.map +0 -1
  291. package/apps/app-lifeops/src/actions/autofill.js +0 -475
  292. package/apps/app-lifeops/src/actions/book-travel-executor.d.ts +0 -9
  293. package/apps/app-lifeops/src/actions/book-travel-executor.d.ts.map +0 -1
  294. package/apps/app-lifeops/src/actions/book-travel-executor.js +0 -65
  295. package/apps/app-lifeops/src/actions/book-travel.d.ts +0 -5
  296. package/apps/app-lifeops/src/actions/book-travel.d.ts.map +0 -1
  297. package/apps/app-lifeops/src/actions/book-travel.js +0 -491
  298. package/apps/app-lifeops/src/actions/calendar.d.ts +0 -19
  299. package/apps/app-lifeops/src/actions/calendar.d.ts.map +0 -1
  300. package/apps/app-lifeops/src/actions/calendar.js +0 -3189
  301. package/apps/app-lifeops/src/actions/calendly.d.ts +0 -3
  302. package/apps/app-lifeops/src/actions/calendly.d.ts.map +0 -1
  303. package/apps/app-lifeops/src/actions/calendly.js +0 -285
  304. package/apps/app-lifeops/src/actions/chat-thread-control.d.ts +0 -3
  305. package/apps/app-lifeops/src/actions/chat-thread-control.d.ts.map +0 -1
  306. package/apps/app-lifeops/src/actions/chat-thread-control.js +0 -260
  307. package/apps/app-lifeops/src/actions/checkin.d.ts +0 -8
  308. package/apps/app-lifeops/src/actions/checkin.d.ts.map +0 -1
  309. package/apps/app-lifeops/src/actions/checkin.js +0 -230
  310. package/apps/app-lifeops/src/actions/computer-use.d.ts +0 -14
  311. package/apps/app-lifeops/src/actions/computer-use.d.ts.map +0 -1
  312. package/apps/app-lifeops/src/actions/computer-use.js +0 -365
  313. package/apps/app-lifeops/src/actions/cross-channel-send.d.ts +0 -34
  314. package/apps/app-lifeops/src/actions/cross-channel-send.d.ts.map +0 -1
  315. package/apps/app-lifeops/src/actions/cross-channel-send.js +0 -964
  316. package/apps/app-lifeops/src/actions/device-bus.d.ts +0 -19
  317. package/apps/app-lifeops/src/actions/device-bus.d.ts.map +0 -1
  318. package/apps/app-lifeops/src/actions/device-bus.js +0 -386
  319. package/apps/app-lifeops/src/actions/dossier.d.ts +0 -5
  320. package/apps/app-lifeops/src/actions/dossier.d.ts.map +0 -1
  321. package/apps/app-lifeops/src/actions/dossier.js +0 -227
  322. package/apps/app-lifeops/src/actions/email-unsubscribe.d.ts +0 -5
  323. package/apps/app-lifeops/src/actions/email-unsubscribe.d.ts.map +0 -1
  324. package/apps/app-lifeops/src/actions/email-unsubscribe.js +0 -172
  325. package/apps/app-lifeops/src/actions/gmail.d.ts +0 -57
  326. package/apps/app-lifeops/src/actions/gmail.d.ts.map +0 -1
  327. package/apps/app-lifeops/src/actions/gmail.js +0 -2540
  328. package/apps/app-lifeops/src/actions/health.d.ts +0 -9
  329. package/apps/app-lifeops/src/actions/health.d.ts.map +0 -1
  330. package/apps/app-lifeops/src/actions/health.js +0 -398
  331. package/apps/app-lifeops/src/actions/inbox.d.ts +0 -5
  332. package/apps/app-lifeops/src/actions/inbox.d.ts.map +0 -1
  333. package/apps/app-lifeops/src/actions/inbox.js +0 -1244
  334. package/apps/app-lifeops/src/actions/intent-sync.d.ts +0 -5
  335. package/apps/app-lifeops/src/actions/intent-sync.d.ts.map +0 -1
  336. package/apps/app-lifeops/src/actions/intent-sync.js +0 -326
  337. package/apps/app-lifeops/src/actions/life-goal-extractor.d.ts +0 -69
  338. package/apps/app-lifeops/src/actions/life-goal-extractor.d.ts.map +0 -1
  339. package/apps/app-lifeops/src/actions/life-goal-extractor.js +0 -420
  340. package/apps/app-lifeops/src/actions/life-param-extractor.d.ts +0 -78
  341. package/apps/app-lifeops/src/actions/life-param-extractor.d.ts.map +0 -1
  342. package/apps/app-lifeops/src/actions/life-param-extractor.js +0 -431
  343. package/apps/app-lifeops/src/actions/life-recent-context.d.ts +0 -9
  344. package/apps/app-lifeops/src/actions/life-recent-context.d.ts.map +0 -1
  345. package/apps/app-lifeops/src/actions/life-recent-context.js +0 -78
  346. package/apps/app-lifeops/src/actions/life-update-extractor.d.ts +0 -27
  347. package/apps/app-lifeops/src/actions/life-update-extractor.d.ts.map +0 -1
  348. package/apps/app-lifeops/src/actions/life-update-extractor.js +0 -195
  349. package/apps/app-lifeops/src/actions/life.d.ts +0 -5
  350. package/apps/app-lifeops/src/actions/life.d.ts.map +0 -1
  351. package/apps/app-lifeops/src/actions/life.extractor.d.ts +0 -18
  352. package/apps/app-lifeops/src/actions/life.extractor.d.ts.map +0 -1
  353. package/apps/app-lifeops/src/actions/life.extractor.js +0 -363
  354. package/apps/app-lifeops/src/actions/life.js +0 -3247
  355. package/apps/app-lifeops/src/actions/lifeops-connector.d.ts +0 -5
  356. package/apps/app-lifeops/src/actions/lifeops-connector.d.ts.map +0 -1
  357. package/apps/app-lifeops/src/actions/lifeops-connector.js +0 -683
  358. package/apps/app-lifeops/src/actions/lifeops-extraction-config.d.ts +0 -16
  359. package/apps/app-lifeops/src/actions/lifeops-extraction-config.d.ts.map +0 -1
  360. package/apps/app-lifeops/src/actions/lifeops-extraction-config.js +0 -25
  361. package/apps/app-lifeops/src/actions/lifeops-google-helpers.d.ts +0 -64
  362. package/apps/app-lifeops/src/actions/lifeops-google-helpers.d.ts.map +0 -1
  363. package/apps/app-lifeops/src/actions/lifeops-google-helpers.js +0 -671
  364. package/apps/app-lifeops/src/actions/lifeops-mutate.d.ts +0 -5
  365. package/apps/app-lifeops/src/actions/lifeops-mutate.d.ts.map +0 -1
  366. package/apps/app-lifeops/src/actions/lifeops-mutate.js +0 -769
  367. package/apps/app-lifeops/src/actions/list-remote-sessions.d.ts +0 -6
  368. package/apps/app-lifeops/src/actions/list-remote-sessions.d.ts.map +0 -1
  369. package/apps/app-lifeops/src/actions/list-remote-sessions.js +0 -45
  370. package/apps/app-lifeops/src/actions/non-actionable-request.d.ts +0 -17
  371. package/apps/app-lifeops/src/actions/non-actionable-request.d.ts.map +0 -1
  372. package/apps/app-lifeops/src/actions/non-actionable-request.js +0 -25
  373. package/apps/app-lifeops/src/actions/owner-app-block.d.ts +0 -12
  374. package/apps/app-lifeops/src/actions/owner-app-block.d.ts.map +0 -1
  375. package/apps/app-lifeops/src/actions/owner-app-block.js +0 -144
  376. package/apps/app-lifeops/src/actions/owner-calendar.d.ts +0 -15
  377. package/apps/app-lifeops/src/actions/owner-calendar.d.ts.map +0 -1
  378. package/apps/app-lifeops/src/actions/owner-calendar.js +0 -762
  379. package/apps/app-lifeops/src/actions/owner-inbox.d.ts +0 -5
  380. package/apps/app-lifeops/src/actions/owner-inbox.d.ts.map +0 -1
  381. package/apps/app-lifeops/src/actions/owner-inbox.js +0 -662
  382. package/apps/app-lifeops/src/actions/owner-remote-desktop.d.ts +0 -12
  383. package/apps/app-lifeops/src/actions/owner-remote-desktop.d.ts.map +0 -1
  384. package/apps/app-lifeops/src/actions/owner-remote-desktop.js +0 -173
  385. package/apps/app-lifeops/src/actions/owner-schedule.d.ts +0 -3
  386. package/apps/app-lifeops/src/actions/owner-schedule.d.ts.map +0 -1
  387. package/apps/app-lifeops/src/actions/owner-schedule.js +0 -174
  388. package/apps/app-lifeops/src/actions/owner-screen-time.d.ts +0 -10
  389. package/apps/app-lifeops/src/actions/owner-screen-time.d.ts.map +0 -1
  390. package/apps/app-lifeops/src/actions/owner-screen-time.js +0 -213
  391. package/apps/app-lifeops/src/actions/owner-website-block.d.ts +0 -12
  392. package/apps/app-lifeops/src/actions/owner-website-block.d.ts.map +0 -1
  393. package/apps/app-lifeops/src/actions/owner-website-block.js +0 -424
  394. package/apps/app-lifeops/src/actions/password-manager.d.ts +0 -5
  395. package/apps/app-lifeops/src/actions/password-manager.d.ts.map +0 -1
  396. package/apps/app-lifeops/src/actions/password-manager.js +0 -217
  397. package/apps/app-lifeops/src/actions/payments.d.ts +0 -5
  398. package/apps/app-lifeops/src/actions/payments.d.ts.map +0 -1
  399. package/apps/app-lifeops/src/actions/payments.js +0 -236
  400. package/apps/app-lifeops/src/actions/relationships.d.ts +0 -12
  401. package/apps/app-lifeops/src/actions/relationships.d.ts.map +0 -1
  402. package/apps/app-lifeops/src/actions/relationships.js +0 -880
  403. package/apps/app-lifeops/src/actions/remote-desktop.d.ts +0 -5
  404. package/apps/app-lifeops/src/actions/remote-desktop.d.ts.map +0 -1
  405. package/apps/app-lifeops/src/actions/remote-desktop.js +0 -248
  406. package/apps/app-lifeops/src/actions/revoke-remote-session.d.ts +0 -6
  407. package/apps/app-lifeops/src/actions/revoke-remote-session.d.ts.map +0 -1
  408. package/apps/app-lifeops/src/actions/revoke-remote-session.js +0 -73
  409. package/apps/app-lifeops/src/actions/schedule-x-dm-reply.d.ts +0 -3
  410. package/apps/app-lifeops/src/actions/schedule-x-dm-reply.d.ts.map +0 -1
  411. package/apps/app-lifeops/src/actions/schedule-x-dm-reply.js +0 -134
  412. package/apps/app-lifeops/src/actions/scheduled-trigger-task.d.ts +0 -19
  413. package/apps/app-lifeops/src/actions/scheduled-trigger-task.d.ts.map +0 -1
  414. package/apps/app-lifeops/src/actions/scheduled-trigger-task.js +0 -82
  415. package/apps/app-lifeops/src/actions/scheduling.d.ts +0 -70
  416. package/apps/app-lifeops/src/actions/scheduling.d.ts.map +0 -1
  417. package/apps/app-lifeops/src/actions/scheduling.js +0 -1078
  418. package/apps/app-lifeops/src/actions/screen-time.d.ts +0 -8
  419. package/apps/app-lifeops/src/actions/screen-time.d.ts.map +0 -1
  420. package/apps/app-lifeops/src/actions/screen-time.js +0 -249
  421. package/apps/app-lifeops/src/actions/search-across-channels.d.ts +0 -13
  422. package/apps/app-lifeops/src/actions/search-across-channels.d.ts.map +0 -1
  423. package/apps/app-lifeops/src/actions/search-across-channels.js +0 -338
  424. package/apps/app-lifeops/src/actions/start-remote-session.d.ts +0 -14
  425. package/apps/app-lifeops/src/actions/start-remote-session.d.ts.map +0 -1
  426. package/apps/app-lifeops/src/actions/start-remote-session.js +0 -139
  427. package/apps/app-lifeops/src/actions/subscriptions.d.ts +0 -5
  428. package/apps/app-lifeops/src/actions/subscriptions.d.ts.map +0 -1
  429. package/apps/app-lifeops/src/actions/subscriptions.js +0 -404
  430. package/apps/app-lifeops/src/actions/timezone-normalization.d.ts +0 -4
  431. package/apps/app-lifeops/src/actions/timezone-normalization.d.ts.map +0 -1
  432. package/apps/app-lifeops/src/actions/timezone-normalization.js +0 -159
  433. package/apps/app-lifeops/src/actions/twilio-call.d.ts +0 -20
  434. package/apps/app-lifeops/src/actions/twilio-call.d.ts.map +0 -1
  435. package/apps/app-lifeops/src/actions/twilio-call.js +0 -853
  436. package/apps/app-lifeops/src/actions/update-owner-profile.d.ts +0 -5
  437. package/apps/app-lifeops/src/actions/update-owner-profile.d.ts.map +0 -1
  438. package/apps/app-lifeops/src/actions/update-owner-profile.js +0 -181
  439. package/apps/app-lifeops/src/actions/x-read.d.ts +0 -5
  440. package/apps/app-lifeops/src/actions/x-read.d.ts.map +0 -1
  441. package/apps/app-lifeops/src/actions/x-read.js +0 -561
  442. package/apps/app-lifeops/src/activity-profile/activity-tracker-service.d.ts +0 -36
  443. package/apps/app-lifeops/src/activity-profile/activity-tracker-service.d.ts.map +0 -1
  444. package/apps/app-lifeops/src/activity-profile/activity-tracker-service.js +0 -160
  445. package/apps/app-lifeops/src/activity-profile/analyzer.d.ts +0 -23
  446. package/apps/app-lifeops/src/activity-profile/analyzer.d.ts.map +0 -1
  447. package/apps/app-lifeops/src/activity-profile/analyzer.js +0 -555
  448. package/apps/app-lifeops/src/activity-profile/presence-signal-bridge-service.d.ts +0 -14
  449. package/apps/app-lifeops/src/activity-profile/presence-signal-bridge-service.d.ts.map +0 -1
  450. package/apps/app-lifeops/src/activity-profile/presence-signal-bridge-service.js +0 -133
  451. package/apps/app-lifeops/src/activity-profile/proactive-planner.d.ts +0 -71
  452. package/apps/app-lifeops/src/activity-profile/proactive-planner.d.ts.map +0 -1
  453. package/apps/app-lifeops/src/activity-profile/proactive-planner.js +0 -567
  454. package/apps/app-lifeops/src/activity-profile/proactive-worker.d.ts +0 -32
  455. package/apps/app-lifeops/src/activity-profile/proactive-worker.d.ts.map +0 -1
  456. package/apps/app-lifeops/src/activity-profile/proactive-worker.js +0 -676
  457. package/apps/app-lifeops/src/activity-profile/service.d.ts +0 -11
  458. package/apps/app-lifeops/src/activity-profile/service.d.ts.map +0 -1
  459. package/apps/app-lifeops/src/activity-profile/service.js +0 -246
  460. package/apps/app-lifeops/src/app-blocker/access.d.ts +0 -8
  461. package/apps/app-lifeops/src/app-blocker/access.d.ts.map +0 -1
  462. package/apps/app-lifeops/src/app-blocker/access.js +0 -35
  463. package/apps/app-lifeops/src/app-blocker/engine.d.ts +0 -10
  464. package/apps/app-lifeops/src/app-blocker/engine.d.ts.map +0 -1
  465. package/apps/app-lifeops/src/app-blocker/engine.js +0 -43
  466. package/apps/app-lifeops/src/components/AppBlockerSettingsCard.d.ts +0 -3
  467. package/apps/app-lifeops/src/components/AppBlockerSettingsCard.d.ts.map +0 -1
  468. package/apps/app-lifeops/src/components/AppBlockerSettingsCard.js +0 -189
  469. package/apps/app-lifeops/src/components/BrowserBridgeSetupPanel.d.ts +0 -2
  470. package/apps/app-lifeops/src/components/BrowserBridgeSetupPanel.d.ts.map +0 -1
  471. package/apps/app-lifeops/src/components/BrowserBridgeSetupPanel.js +0 -1065
  472. package/apps/app-lifeops/src/components/BrowserBridgeStatusChip.d.ts +0 -7
  473. package/apps/app-lifeops/src/components/BrowserBridgeStatusChip.d.ts.map +0 -1
  474. package/apps/app-lifeops/src/components/BrowserBridgeStatusChip.js +0 -74
  475. package/apps/app-lifeops/src/components/DataSourcesStrip.d.ts +0 -14
  476. package/apps/app-lifeops/src/components/DataSourcesStrip.d.ts.map +0 -1
  477. package/apps/app-lifeops/src/components/DataSourcesStrip.js +0 -36
  478. package/apps/app-lifeops/src/components/EventEditorDrawer.d.ts +0 -23
  479. package/apps/app-lifeops/src/components/EventEditorDrawer.d.ts.map +0 -1
  480. package/apps/app-lifeops/src/components/EventEditorDrawer.js +0 -514
  481. package/apps/app-lifeops/src/components/LifeOpsActivitySignalsEffect.d.ts +0 -2
  482. package/apps/app-lifeops/src/components/LifeOpsActivitySignalsEffect.d.ts.map +0 -1
  483. package/apps/app-lifeops/src/components/LifeOpsActivitySignalsEffect.js +0 -10
  484. package/apps/app-lifeops/src/components/LifeOpsCalendarSection.d.ts +0 -15
  485. package/apps/app-lifeops/src/components/LifeOpsCalendarSection.d.ts.map +0 -1
  486. package/apps/app-lifeops/src/components/LifeOpsCalendarSection.js +0 -515
  487. package/apps/app-lifeops/src/components/LifeOpsChatAdapter.d.ts +0 -34
  488. package/apps/app-lifeops/src/components/LifeOpsChatAdapter.d.ts.map +0 -1
  489. package/apps/app-lifeops/src/components/LifeOpsChatAdapter.js +0 -175
  490. package/apps/app-lifeops/src/components/LifeOpsFeatureTogglesSection.d.ts +0 -2
  491. package/apps/app-lifeops/src/components/LifeOpsFeatureTogglesSection.d.ts.map +0 -1
  492. package/apps/app-lifeops/src/components/LifeOpsFeatureTogglesSection.js +0 -99
  493. package/apps/app-lifeops/src/components/LifeOpsHabitVisuals.d.ts +0 -37
  494. package/apps/app-lifeops/src/components/LifeOpsHabitVisuals.d.ts.map +0 -1
  495. package/apps/app-lifeops/src/components/LifeOpsHabitVisuals.js +0 -88
  496. package/apps/app-lifeops/src/components/LifeOpsInboxSection.d.ts +0 -13
  497. package/apps/app-lifeops/src/components/LifeOpsInboxSection.d.ts.map +0 -1
  498. package/apps/app-lifeops/src/components/LifeOpsInboxSection.js +0 -490
  499. package/apps/app-lifeops/src/components/LifeOpsLinkBankButton.d.ts +0 -12
  500. package/apps/app-lifeops/src/components/LifeOpsLinkBankButton.d.ts.map +0 -1
  501. package/apps/app-lifeops/src/components/LifeOpsLinkBankButton.js +0 -92
  502. package/apps/app-lifeops/src/components/LifeOpsLinkPaypalButton.d.ts +0 -12
  503. package/apps/app-lifeops/src/components/LifeOpsLinkPaypalButton.d.ts.map +0 -1
  504. package/apps/app-lifeops/src/components/LifeOpsLinkPaypalButton.js +0 -160
  505. package/apps/app-lifeops/src/components/LifeOpsMoneySection.d.ts +0 -3
  506. package/apps/app-lifeops/src/components/LifeOpsMoneySection.d.ts.map +0 -1
  507. package/apps/app-lifeops/src/components/LifeOpsMoneySection.js +0 -373
  508. package/apps/app-lifeops/src/components/LifeOpsNavRail.d.ts +0 -9
  509. package/apps/app-lifeops/src/components/LifeOpsNavRail.d.ts.map +0 -1
  510. package/apps/app-lifeops/src/components/LifeOpsNavRail.js +0 -93
  511. package/apps/app-lifeops/src/components/LifeOpsOperationalPanels.d.ts +0 -4
  512. package/apps/app-lifeops/src/components/LifeOpsOperationalPanels.d.ts.map +0 -1
  513. package/apps/app-lifeops/src/components/LifeOpsOperationalPanels.js +0 -274
  514. package/apps/app-lifeops/src/components/LifeOpsOverviewSection.d.ts +0 -7
  515. package/apps/app-lifeops/src/components/LifeOpsOverviewSection.d.ts.map +0 -1
  516. package/apps/app-lifeops/src/components/LifeOpsOverviewSection.js +0 -670
  517. package/apps/app-lifeops/src/components/LifeOpsPageSections.d.ts +0 -42
  518. package/apps/app-lifeops/src/components/LifeOpsPageSections.d.ts.map +0 -1
  519. package/apps/app-lifeops/src/components/LifeOpsPageSections.js +0 -166
  520. package/apps/app-lifeops/src/components/LifeOpsPageView.d.ts +0 -2
  521. package/apps/app-lifeops/src/components/LifeOpsPageView.d.ts.map +0 -1
  522. package/apps/app-lifeops/src/components/LifeOpsPageView.js +0 -565
  523. package/apps/app-lifeops/src/components/LifeOpsRemindersSection.d.ts +0 -2
  524. package/apps/app-lifeops/src/components/LifeOpsRemindersSection.d.ts.map +0 -1
  525. package/apps/app-lifeops/src/components/LifeOpsRemindersSection.js +0 -749
  526. package/apps/app-lifeops/src/components/LifeOpsResizableSidebar.d.ts +0 -27
  527. package/apps/app-lifeops/src/components/LifeOpsResizableSidebar.d.ts.map +0 -1
  528. package/apps/app-lifeops/src/components/LifeOpsResizableSidebar.js +0 -106
  529. package/apps/app-lifeops/src/components/LifeOpsScreenTimeSection.d.ts +0 -2
  530. package/apps/app-lifeops/src/components/LifeOpsScreenTimeSection.d.ts.map +0 -1
  531. package/apps/app-lifeops/src/components/LifeOpsScreenTimeSection.js +0 -373
  532. package/apps/app-lifeops/src/components/LifeOpsSectionContent.d.ts +0 -10
  533. package/apps/app-lifeops/src/components/LifeOpsSectionContent.d.ts.map +0 -1
  534. package/apps/app-lifeops/src/components/LifeOpsSectionContent.js +0 -30
  535. package/apps/app-lifeops/src/components/LifeOpsSelectionContext.d.ts +0 -21
  536. package/apps/app-lifeops/src/components/LifeOpsSelectionContext.d.ts.map +0 -1
  537. package/apps/app-lifeops/src/components/LifeOpsSelectionContext.js +0 -30
  538. package/apps/app-lifeops/src/components/LifeOpsSettingsSection.d.ts +0 -20
  539. package/apps/app-lifeops/src/components/LifeOpsSettingsSection.d.ts.map +0 -1
  540. package/apps/app-lifeops/src/components/LifeOpsSettingsSection.js +0 -597
  541. package/apps/app-lifeops/src/components/LifeOpsSetupGate.d.ts +0 -13
  542. package/apps/app-lifeops/src/components/LifeOpsSetupGate.d.ts.map +0 -1
  543. package/apps/app-lifeops/src/components/LifeOpsSetupGate.js +0 -134
  544. package/apps/app-lifeops/src/components/LifeOpsSleepSection.d.ts +0 -10
  545. package/apps/app-lifeops/src/components/LifeOpsSleepSection.d.ts.map +0 -1
  546. package/apps/app-lifeops/src/components/LifeOpsSleepSection.js +0 -425
  547. package/apps/app-lifeops/src/components/LifeOpsWorkspaceShell.d.ts +0 -11
  548. package/apps/app-lifeops/src/components/LifeOpsWorkspaceShell.d.ts.map +0 -1
  549. package/apps/app-lifeops/src/components/LifeOpsWorkspaceShell.js +0 -49
  550. package/apps/app-lifeops/src/components/LifeOpsWorkspaceView.d.ts +0 -2
  551. package/apps/app-lifeops/src/components/LifeOpsWorkspaceView.d.ts.map +0 -1
  552. package/apps/app-lifeops/src/components/LifeOpsWorkspaceView.js +0 -1041
  553. package/apps/app-lifeops/src/components/MessagingConnectorCards.d.ts +0 -7
  554. package/apps/app-lifeops/src/components/MessagingConnectorCards.d.ts.map +0 -1
  555. package/apps/app-lifeops/src/components/MessagingConnectorCards.js +0 -643
  556. package/apps/app-lifeops/src/components/MissingSourceCard.d.ts +0 -9
  557. package/apps/app-lifeops/src/components/MissingSourceCard.d.ts.map +0 -1
  558. package/apps/app-lifeops/src/components/MissingSourceCard.js +0 -5
  559. package/apps/app-lifeops/src/components/MobileSignalsSetupCard.d.ts +0 -2
  560. package/apps/app-lifeops/src/components/MobileSignalsSetupCard.d.ts.map +0 -1
  561. package/apps/app-lifeops/src/components/MobileSignalsSetupCard.js +0 -162
  562. package/apps/app-lifeops/src/components/SleepInspectionPanel.d.ts +0 -8
  563. package/apps/app-lifeops/src/components/SleepInspectionPanel.d.ts.map +0 -1
  564. package/apps/app-lifeops/src/components/SleepInspectionPanel.js +0 -59
  565. package/apps/app-lifeops/src/components/WebsiteBlockerSettingsCard.d.ts +0 -3
  566. package/apps/app-lifeops/src/components/WebsiteBlockerSettingsCard.d.ts.map +0 -1
  567. package/apps/app-lifeops/src/components/WebsiteBlockerSettingsCard.js +0 -75
  568. package/apps/app-lifeops/src/components/WhatsAppQrOverlay.d.ts +0 -8
  569. package/apps/app-lifeops/src/components/WhatsAppQrOverlay.d.ts.map +0 -1
  570. package/apps/app-lifeops/src/components/WhatsAppQrOverlay.js +0 -48
  571. package/apps/app-lifeops/src/components/lifeops-labels.d.ts +0 -2
  572. package/apps/app-lifeops/src/components/lifeops-labels.d.ts.map +0 -1
  573. package/apps/app-lifeops/src/components/lifeops-labels.js +0 -5
  574. package/apps/app-lifeops/src/events/index.d.ts +0 -34
  575. package/apps/app-lifeops/src/events/index.d.ts.map +0 -1
  576. package/apps/app-lifeops/src/events/index.js +0 -23
  577. package/apps/app-lifeops/src/followup/actions/listOverdueFollowups.d.ts +0 -3
  578. package/apps/app-lifeops/src/followup/actions/listOverdueFollowups.d.ts.map +0 -1
  579. package/apps/app-lifeops/src/followup/actions/listOverdueFollowups.js +0 -48
  580. package/apps/app-lifeops/src/followup/actions/markFollowupDone.d.ts +0 -3
  581. package/apps/app-lifeops/src/followup/actions/markFollowupDone.d.ts.map +0 -1
  582. package/apps/app-lifeops/src/followup/actions/markFollowupDone.js +0 -173
  583. package/apps/app-lifeops/src/followup/actions/setFollowupThreshold.d.ts +0 -3
  584. package/apps/app-lifeops/src/followup/actions/setFollowupThreshold.d.ts.map +0 -1
  585. package/apps/app-lifeops/src/followup/actions/setFollowupThreshold.js +0 -172
  586. package/apps/app-lifeops/src/followup/followup-tracker.d.ts +0 -82
  587. package/apps/app-lifeops/src/followup/followup-tracker.d.ts.map +0 -1
  588. package/apps/app-lifeops/src/followup/followup-tracker.js +0 -279
  589. package/apps/app-lifeops/src/followup/index.d.ts +0 -5
  590. package/apps/app-lifeops/src/followup/index.d.ts.map +0 -1
  591. package/apps/app-lifeops/src/followup/index.js +0 -4
  592. package/apps/app-lifeops/src/hooks/useCalendarWeek.d.ts +0 -28
  593. package/apps/app-lifeops/src/hooks/useCalendarWeek.d.ts.map +0 -1
  594. package/apps/app-lifeops/src/hooks/useCalendarWeek.js +0 -93
  595. package/apps/app-lifeops/src/hooks/useDiscordConnector.d.ts +0 -14
  596. package/apps/app-lifeops/src/hooks/useDiscordConnector.d.ts.map +0 -1
  597. package/apps/app-lifeops/src/hooks/useDiscordConnector.js +0 -126
  598. package/apps/app-lifeops/src/hooks/useGoogleLifeOpsConnector.d.ts +0 -29
  599. package/apps/app-lifeops/src/hooks/useGoogleLifeOpsConnector.d.ts.map +0 -1
  600. package/apps/app-lifeops/src/hooks/useGoogleLifeOpsConnector.js +0 -481
  601. package/apps/app-lifeops/src/hooks/useIMessageConnector.d.ts +0 -10
  602. package/apps/app-lifeops/src/hooks/useIMessageConnector.d.ts.map +0 -1
  603. package/apps/app-lifeops/src/hooks/useIMessageConnector.js +0 -50
  604. package/apps/app-lifeops/src/hooks/useInbox.d.ts +0 -34
  605. package/apps/app-lifeops/src/hooks/useInbox.d.ts.map +0 -1
  606. package/apps/app-lifeops/src/hooks/useInbox.js +0 -98
  607. package/apps/app-lifeops/src/hooks/useLifeOpsActivitySignals.d.ts +0 -2
  608. package/apps/app-lifeops/src/hooks/useLifeOpsActivitySignals.d.ts.map +0 -1
  609. package/apps/app-lifeops/src/hooks/useLifeOpsActivitySignals.js +0 -382
  610. package/apps/app-lifeops/src/hooks/useLifeOpsAppState.d.ts +0 -21
  611. package/apps/app-lifeops/src/hooks/useLifeOpsAppState.d.ts.map +0 -1
  612. package/apps/app-lifeops/src/hooks/useLifeOpsAppState.js +0 -83
  613. package/apps/app-lifeops/src/hooks/useLifeOpsCapabilitiesStatus.d.ts +0 -8
  614. package/apps/app-lifeops/src/hooks/useLifeOpsCapabilitiesStatus.d.ts.map +0 -1
  615. package/apps/app-lifeops/src/hooks/useLifeOpsCapabilitiesStatus.js +0 -60
  616. package/apps/app-lifeops/src/hooks/useLifeOpsScheduleInspection.d.ts +0 -18
  617. package/apps/app-lifeops/src/hooks/useLifeOpsScheduleInspection.d.ts.map +0 -1
  618. package/apps/app-lifeops/src/hooks/useLifeOpsScheduleInspection.js +0 -66
  619. package/apps/app-lifeops/src/hooks/useLifeOpsScheduleState.d.ts +0 -14
  620. package/apps/app-lifeops/src/hooks/useLifeOpsScheduleState.d.ts.map +0 -1
  621. package/apps/app-lifeops/src/hooks/useLifeOpsScheduleState.js +0 -79
  622. package/apps/app-lifeops/src/hooks/useLifeOpsSection.d.ts +0 -18
  623. package/apps/app-lifeops/src/hooks/useLifeOpsSection.d.ts.map +0 -1
  624. package/apps/app-lifeops/src/hooks/useLifeOpsSection.js +0 -78
  625. package/apps/app-lifeops/src/hooks/useLifeOpsXConnector.d.ts +0 -14
  626. package/apps/app-lifeops/src/hooks/useLifeOpsXConnector.d.ts.map +0 -1
  627. package/apps/app-lifeops/src/hooks/useLifeOpsXConnector.js +0 -160
  628. package/apps/app-lifeops/src/hooks/useSignalConnector.d.ts +0 -16
  629. package/apps/app-lifeops/src/hooks/useSignalConnector.d.ts.map +0 -1
  630. package/apps/app-lifeops/src/hooks/useSignalConnector.js +0 -198
  631. package/apps/app-lifeops/src/hooks/useTelegramConnector.d.ts +0 -21
  632. package/apps/app-lifeops/src/hooks/useTelegramConnector.d.ts.map +0 -1
  633. package/apps/app-lifeops/src/hooks/useTelegramConnector.js +0 -177
  634. package/apps/app-lifeops/src/hooks/useWhatsAppConnector.d.ts +0 -8
  635. package/apps/app-lifeops/src/hooks/useWhatsAppConnector.d.ts.map +0 -1
  636. package/apps/app-lifeops/src/hooks/useWhatsAppConnector.js +0 -58
  637. package/apps/app-lifeops/src/hooks/useWhatsAppPairing.d.ts +0 -12
  638. package/apps/app-lifeops/src/hooks/useWhatsAppPairing.d.ts.map +0 -1
  639. package/apps/app-lifeops/src/hooks/useWhatsAppPairing.js +0 -152
  640. package/apps/app-lifeops/src/inbox/config.d.ts +0 -7
  641. package/apps/app-lifeops/src/inbox/config.d.ts.map +0 -1
  642. package/apps/app-lifeops/src/inbox/config.js +0 -67
  643. package/apps/app-lifeops/src/inbox/reflection.d.ts +0 -40
  644. package/apps/app-lifeops/src/inbox/reflection.d.ts.map +0 -1
  645. package/apps/app-lifeops/src/inbox/reflection.js +0 -115
  646. package/apps/app-lifeops/src/inbox/repository.d.ts +0 -52
  647. package/apps/app-lifeops/src/inbox/repository.d.ts.map +0 -1
  648. package/apps/app-lifeops/src/inbox/repository.js +0 -262
  649. package/apps/app-lifeops/src/inbox/triage-classifier.d.ts +0 -15
  650. package/apps/app-lifeops/src/inbox/triage-classifier.d.ts.map +0 -1
  651. package/apps/app-lifeops/src/inbox/triage-classifier.js +0 -179
  652. package/apps/app-lifeops/src/index.d.ts +0 -20
  653. package/apps/app-lifeops/src/index.d.ts.map +0 -1
  654. package/apps/app-lifeops/src/index.js +0 -18
  655. package/apps/app-lifeops/src/lifeops/approval-queue.d.ts +0 -24
  656. package/apps/app-lifeops/src/lifeops/approval-queue.d.ts.map +0 -1
  657. package/apps/app-lifeops/src/lifeops/approval-queue.js +0 -500
  658. package/apps/app-lifeops/src/lifeops/approval-queue.types.d.ts +0 -166
  659. package/apps/app-lifeops/src/lifeops/approval-queue.types.d.ts.map +0 -1
  660. package/apps/app-lifeops/src/lifeops/approval-queue.types.js +0 -22
  661. package/apps/app-lifeops/src/lifeops/autofill-whitelist.d.ts +0 -15
  662. package/apps/app-lifeops/src/lifeops/autofill-whitelist.d.ts.map +0 -1
  663. package/apps/app-lifeops/src/lifeops/autofill-whitelist.js +0 -116
  664. package/apps/app-lifeops/src/lifeops/background-planner-dispatch.d.ts +0 -60
  665. package/apps/app-lifeops/src/lifeops/background-planner-dispatch.d.ts.map +0 -1
  666. package/apps/app-lifeops/src/lifeops/background-planner-dispatch.js +0 -134
  667. package/apps/app-lifeops/src/lifeops/background-planner.d.ts +0 -141
  668. package/apps/app-lifeops/src/lifeops/background-planner.d.ts.map +0 -1
  669. package/apps/app-lifeops/src/lifeops/background-planner.js +0 -377
  670. package/apps/app-lifeops/src/lifeops/calendly-client.d.ts +0 -61
  671. package/apps/app-lifeops/src/lifeops/calendly-client.d.ts.map +0 -1
  672. package/apps/app-lifeops/src/lifeops/calendly-client.js +0 -234
  673. package/apps/app-lifeops/src/lifeops/checkin/schedule-resolver.d.ts +0 -14
  674. package/apps/app-lifeops/src/lifeops/checkin/schedule-resolver.d.ts.map +0 -1
  675. package/apps/app-lifeops/src/lifeops/checkin/schedule-resolver.js +0 -27
  676. package/apps/app-lifeops/src/lifeops/cross-channel-search.d.ts +0 -88
  677. package/apps/app-lifeops/src/lifeops/cross-channel-search.d.ts.map +0 -1
  678. package/apps/app-lifeops/src/lifeops/cross-channel-search.js +0 -446
  679. package/apps/app-lifeops/src/lifeops/intent-sync.d.ts +0 -59
  680. package/apps/app-lifeops/src/lifeops/intent-sync.d.ts.map +0 -1
  681. package/apps/app-lifeops/src/lifeops/intent-sync.js +0 -305
  682. package/apps/app-lifeops/src/lifeops/notifications-push.d.ts +0 -37
  683. package/apps/app-lifeops/src/lifeops/notifications-push.d.ts.map +0 -1
  684. package/apps/app-lifeops/src/lifeops/notifications-push.js +0 -92
  685. package/apps/app-lifeops/src/lifeops/password-manager-bridge.d.ts +0 -50
  686. package/apps/app-lifeops/src/lifeops/password-manager-bridge.d.ts.map +0 -1
  687. package/apps/app-lifeops/src/lifeops/password-manager-bridge.js +0 -448
  688. package/apps/app-lifeops/src/lifeops/remote-desktop.d.ts +0 -38
  689. package/apps/app-lifeops/src/lifeops/remote-desktop.d.ts.map +0 -1
  690. package/apps/app-lifeops/src/lifeops/remote-desktop.js +0 -372
  691. package/apps/app-lifeops/src/lifeops/runtime.d.ts +0 -11
  692. package/apps/app-lifeops/src/lifeops/runtime.d.ts.map +0 -1
  693. package/apps/app-lifeops/src/lifeops/runtime.js +0 -57
  694. package/apps/app-lifeops/src/lifeops/screen-context.d.ts +0 -52
  695. package/apps/app-lifeops/src/lifeops/screen-context.d.ts.map +0 -1
  696. package/apps/app-lifeops/src/lifeops/screen-context.js +0 -349
  697. package/apps/app-lifeops/src/lifeops-route.d.ts +0 -74
  698. package/apps/app-lifeops/src/lifeops-route.d.ts.map +0 -1
  699. package/apps/app-lifeops/src/lifeops-route.js +0 -204
  700. package/apps/app-lifeops/src/platform/index.d.ts +0 -2
  701. package/apps/app-lifeops/src/platform/index.d.ts.map +0 -1
  702. package/apps/app-lifeops/src/platform/index.js +0 -1
  703. package/apps/app-lifeops/src/platform/lifeops-github.d.ts +0 -15
  704. package/apps/app-lifeops/src/platform/lifeops-github.d.ts.map +0 -1
  705. package/apps/app-lifeops/src/platform/lifeops-github.js +0 -135
  706. package/apps/app-lifeops/src/plugin.d.ts +0 -33
  707. package/apps/app-lifeops/src/plugin.d.ts.map +0 -1
  708. package/apps/app-lifeops/src/plugin.js +0 -316
  709. package/apps/app-lifeops/src/provider.d.ts +0 -4
  710. package/apps/app-lifeops/src/provider.d.ts.map +0 -1
  711. package/apps/app-lifeops/src/provider.js +0 -77
  712. package/apps/app-lifeops/src/providers/activity-profile.d.ts +0 -3
  713. package/apps/app-lifeops/src/providers/activity-profile.d.ts.map +0 -1
  714. package/apps/app-lifeops/src/providers/activity-profile.js +0 -140
  715. package/apps/app-lifeops/src/providers/app-blocker.d.ts +0 -3
  716. package/apps/app-lifeops/src/providers/app-blocker.d.ts.map +0 -1
  717. package/apps/app-lifeops/src/providers/app-blocker.js +0 -86
  718. package/apps/app-lifeops/src/providers/cross-channel-context.d.ts +0 -29
  719. package/apps/app-lifeops/src/providers/cross-channel-context.d.ts.map +0 -1
  720. package/apps/app-lifeops/src/providers/cross-channel-context.js +0 -182
  721. package/apps/app-lifeops/src/providers/inbox-triage.d.ts +0 -3
  722. package/apps/app-lifeops/src/providers/inbox-triage.d.ts.map +0 -1
  723. package/apps/app-lifeops/src/providers/inbox-triage.js +0 -90
  724. package/apps/app-lifeops/src/providers/lifeops.d.ts +0 -3
  725. package/apps/app-lifeops/src/providers/lifeops.d.ts.map +0 -1
  726. package/apps/app-lifeops/src/providers/lifeops.js +0 -197
  727. package/apps/app-lifeops/src/remote/pairing-code.d.ts +0 -39
  728. package/apps/app-lifeops/src/remote/pairing-code.d.ts.map +0 -1
  729. package/apps/app-lifeops/src/remote/pairing-code.js +0 -76
  730. package/apps/app-lifeops/src/remote/remote-session-service.d.ts +0 -107
  731. package/apps/app-lifeops/src/remote/remote-session-service.d.ts.map +0 -1
  732. package/apps/app-lifeops/src/remote/remote-session-service.js +0 -253
  733. package/apps/app-lifeops/src/service.d.ts +0 -32
  734. package/apps/app-lifeops/src/service.d.ts.map +0 -1
  735. package/apps/app-lifeops/src/service.js +0 -67
  736. package/apps/app-lifeops/src/travel-time/calendar-create.d.ts +0 -17
  737. package/apps/app-lifeops/src/travel-time/calendar-create.d.ts.map +0 -1
  738. package/apps/app-lifeops/src/travel-time/calendar-create.js +0 -21
  739. package/apps/app-lifeops/src/travel-time/service.d.ts +0 -60
  740. package/apps/app-lifeops/src/travel-time/service.d.ts.map +0 -1
  741. package/apps/app-lifeops/src/travel-time/service.js +0 -142
  742. package/apps/app-lifeops/src/utils/lifeops-url.d.ts +0 -5
  743. package/apps/app-lifeops/src/utils/lifeops-url.d.ts.map +0 -1
  744. package/apps/app-lifeops/src/utils/lifeops-url.js +0 -35
  745. package/apps/app-lifeops/src/website-blocker/chat-integration/actions/blockUntilTaskComplete.d.ts +0 -3
  746. package/apps/app-lifeops/src/website-blocker/chat-integration/actions/blockUntilTaskComplete.d.ts.map +0 -1
  747. package/apps/app-lifeops/src/website-blocker/chat-integration/actions/blockUntilTaskComplete.js +0 -246
  748. package/apps/app-lifeops/src/website-blocker/chat-integration/actions/listActiveBlocks.d.ts +0 -3
  749. package/apps/app-lifeops/src/website-blocker/chat-integration/actions/listActiveBlocks.d.ts.map +0 -1
  750. package/apps/app-lifeops/src/website-blocker/chat-integration/actions/listActiveBlocks.js +0 -83
  751. package/apps/app-lifeops/src/website-blocker/chat-integration/actions/releaseBlock.d.ts +0 -3
  752. package/apps/app-lifeops/src/website-blocker/chat-integration/actions/releaseBlock.d.ts.map +0 -1
  753. package/apps/app-lifeops/src/website-blocker/chat-integration/actions/releaseBlock.js +0 -98
  754. package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-reconciler.d.ts +0 -7
  755. package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-reconciler.d.ts.map +0 -1
  756. package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-reconciler.js +0 -111
  757. package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-schema.d.ts +0 -39
  758. package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-schema.d.ts.map +0 -1
  759. package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-schema.js +0 -123
  760. package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-service.d.ts +0 -21
  761. package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-service.d.ts.map +0 -1
  762. package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-service.js +0 -258
  763. package/apps/app-lifeops/src/website-blocker/chat-integration/index.d.ts +0 -8
  764. package/apps/app-lifeops/src/website-blocker/chat-integration/index.d.ts.map +0 -1
  765. package/apps/app-lifeops/src/website-blocker/chat-integration/index.js +0 -6
  766. package/packages/app-core/src/api/client-lifeops.d.ts +0 -35
  767. package/packages/app-core/src/api/client-lifeops.d.ts.map +0 -1
  768. package/packages/app-core/src/api/client-lifeops.js +0 -114
  769. package/packages/app-core/src/hooks/useGoogleLifeOpsConnector.d.ts +0 -20
  770. package/packages/app-core/src/hooks/useGoogleLifeOpsConnector.d.ts.map +0 -1
  771. package/packages/app-core/src/hooks/useGoogleLifeOpsConnector.js +0 -69
  772. package/packages/app-core/src/hooks/useLifeOpsAppState.d.ts +0 -21
  773. package/packages/app-core/src/hooks/useLifeOpsAppState.d.ts.map +0 -1
  774. package/packages/app-core/src/hooks/useLifeOpsAppState.js +0 -81
  775. package/packages/app-core/src/services/steward-sidecar.d.ts +0 -6
  776. package/packages/app-core/src/services/steward-sidecar.d.ts.map +0 -1
  777. package/packages/app-core/src/services/steward-sidecar.js +0 -5
@@ -1,2540 +0,0 @@
1
- import { extractActionResultsFromState, extractRecentMessageEntriesFromState, extractStateDataRecords, hasContextSignalForKey, renderGroundedActionReply, summarizeActiveTrajectory, summarizeRecentActionHistory, } from "@elizaos/agent";
2
- import { ModelType, parseJSONObjectFromText, parseKeyValueXml, } from "@elizaos/core";
3
- import { resolveDefaultTimeZone } from "../lifeops/defaults.js";
4
- import { LifeOpsService, LifeOpsServiceError } from "../lifeops/service.js";
5
- import { recentConversationTexts as collectRecentConversationTexts } from "./life-recent-context.js";
6
- import { detailArray, detailBoolean, detailNumber, detailString, formatEmailNeedsResponse, formatEmailRead, formatEmailSearch, formatEmailTriage, formatGmailBatchReplyDrafts, formatGmailRecommendations, formatGmailReplyDraft, getGoogleCapabilityStatus, gmailReadUnavailableMessage, gmailSendUnavailableMessage, hasLifeOpsAccess, INTERNAL_URL, messageText, toActionData, } from "./lifeops-google-helpers.js";
7
- const GMAIL_CONTEXT_WINDOW = 12;
8
- const ACTION_NAME = "GMAIL_ACTION";
9
- const GMAIL_DETAIL_ALIASES = {
10
- forceSync: ["forcesync", "force_sync"],
11
- maxResults: ["maxresults", "max_results"],
12
- includeSpamTrash: ["includespamtrash", "include_spam_trash"],
13
- olderThanDays: ["olderthandays", "older_than_days"],
14
- replyNeededOnly: ["replyneededonly", "reply_needed_only"],
15
- messageIds: ["messageids", "message_ids"],
16
- labelIds: ["labelids", "label_ids"],
17
- confirmDestructive: ["confirmdestructive", "confirm_destructive"],
18
- };
19
- async function collectGmailConversationContext(args) {
20
- const recentConversation = await collectRecentConversationTexts({
21
- runtime: args.runtime,
22
- message: args.message,
23
- state: args.state,
24
- limit: GMAIL_CONTEXT_WINDOW,
25
- });
26
- const currentMessage = messageText(args.message).trim();
27
- const combined = [...recentConversation];
28
- if (currentMessage.length > 0) {
29
- combined.push(currentMessage);
30
- }
31
- return combined.slice(-GMAIL_CONTEXT_WINDOW);
32
- }
33
- async function buildGmailDraftGenerationContext(args) {
34
- const [conversationContext, trajectorySummary] = await Promise.all([
35
- collectGmailConversationContext(args),
36
- summarizeActiveTrajectory(args.runtime),
37
- ]);
38
- return {
39
- conversationContext,
40
- actionHistory: summarizeRecentActionHistory(args.state, 4),
41
- trajectorySummary,
42
- };
43
- }
44
- function getPendingGmailReplyCacheKey(roomId) {
45
- return `lifeops:gmail:pending-reply:${roomId}`;
46
- }
47
- async function readPendingGmailReplyApproval(runtime, roomId) {
48
- return ((await runtime.getCache(getPendingGmailReplyCacheKey(roomId))) ?? null);
49
- }
50
- async function writePendingGmailReplyApproval(runtime, roomId, approval) {
51
- await runtime.setCache(getPendingGmailReplyCacheKey(roomId), approval);
52
- }
53
- async function clearPendingGmailReplyApproval(runtime, roomId) {
54
- await runtime.deleteCache(getPendingGmailReplyCacheKey(roomId));
55
- }
56
- async function enqueueGmailReplyApprovalRequest(args) {
57
- return await args.runtime.createTask({
58
- name: `GMAIL_REPLY_APPROVAL_${Date.now()}`,
59
- description: `Approve sending the Gmail reply${args.draft.subject ? ` (${args.draft.subject})` : ""}: ${args.draft.bodyText}`,
60
- roomId: args.message.roomId,
61
- entityId: args.message.entityId,
62
- tags: ["AWAITING_CHOICE", "APPROVAL", ACTION_NAME],
63
- metadata: {
64
- options: [
65
- { name: "confirm", description: "Send the drafted Gmail reply" },
66
- { name: "cancel", description: "Keep the draft unsent" },
67
- ],
68
- approvalRequest: {
69
- timeoutMs: 24 * 60 * 60 * 1000,
70
- timeoutDefault: "cancel",
71
- createdAt: Date.now(),
72
- isAsync: true,
73
- },
74
- actionName: ACTION_NAME,
75
- channel: "gmail",
76
- payload: {
77
- messageId: args.draft.messageId,
78
- bodyText: args.draft.bodyText,
79
- subject: args.draft.subject ?? null,
80
- to: args.draft.to ?? [],
81
- cc: args.draft.cc ?? [],
82
- },
83
- },
84
- });
85
- }
86
- function normalizeGmailSubaction(value) {
87
- if (typeof value !== "string") {
88
- return null;
89
- }
90
- const normalized = value.trim().toLowerCase();
91
- switch (normalized) {
92
- case "triage":
93
- case "needs_response":
94
- case "recommend":
95
- case "unresponded":
96
- case "search":
97
- case "read":
98
- case "draft_reply":
99
- case "draft_batch_replies":
100
- case "manage":
101
- case "send_reply":
102
- case "send_batch_replies":
103
- case "send_message":
104
- return normalized;
105
- default:
106
- return null;
107
- }
108
- }
109
- function normalizeShouldAct(value) {
110
- if (typeof value === "boolean") {
111
- return value;
112
- }
113
- if (typeof value === "string") {
114
- const normalized = value.trim().toLowerCase();
115
- if (normalized === "true") {
116
- return true;
117
- }
118
- if (normalized === "false") {
119
- return false;
120
- }
121
- }
122
- return null;
123
- }
124
- function normalizePlannerResponse(value) {
125
- if (typeof value !== "string") {
126
- return undefined;
127
- }
128
- const trimmed = value.trim();
129
- return trimmed.length > 0 ? trimmed : undefined;
130
- }
131
- function normalizePlannerString(value) {
132
- if (typeof value !== "string") {
133
- return undefined;
134
- }
135
- const trimmed = value.trim();
136
- return trimmed.length > 0 ? trimmed : undefined;
137
- }
138
- function splitLooseListString(value) {
139
- const parts = [];
140
- let current = "";
141
- let inQuotes = false;
142
- let angleDepth = 0;
143
- for (let index = 0; index < value.length; index += 1) {
144
- const char = value[index];
145
- const next = value[index + 1];
146
- if (char === '"') {
147
- inQuotes = !inQuotes;
148
- current += char;
149
- continue;
150
- }
151
- if (!inQuotes && char === "<") {
152
- angleDepth += 1;
153
- current += char;
154
- continue;
155
- }
156
- if (!inQuotes && char === ">") {
157
- angleDepth = Math.max(0, angleDepth - 1);
158
- current += char;
159
- continue;
160
- }
161
- if (!inQuotes && angleDepth === 0 && char === "|" && next === "|") {
162
- const trimmed = current.trim();
163
- if (trimmed.length > 0) {
164
- parts.push(trimmed);
165
- }
166
- current = "";
167
- index += 1;
168
- continue;
169
- }
170
- if (!inQuotes &&
171
- angleDepth === 0 &&
172
- (char === "," || char === ";" || char === "\n")) {
173
- const trimmed = current.trim();
174
- if (trimmed.length > 0) {
175
- parts.push(trimmed);
176
- }
177
- current = "";
178
- continue;
179
- }
180
- current += char;
181
- }
182
- const trimmed = current.trim();
183
- if (trimmed.length > 0) {
184
- parts.push(trimmed);
185
- }
186
- return parts;
187
- }
188
- function normalizePlannerStringArray(value) {
189
- if (Array.isArray(value)) {
190
- return dedupeQueries(value.flatMap((item) => typeof item === "string" ? splitLooseListString(item) : []));
191
- }
192
- if (typeof value === "string") {
193
- return dedupeQueries(splitLooseListString(value));
194
- }
195
- return undefined;
196
- }
197
- function normalizeQueryStringArray(value) {
198
- if (Array.isArray(value)) {
199
- return dedupeQueries(value.map((item) => (typeof item === "string" ? item.trim() : "")));
200
- }
201
- if (typeof value === "string") {
202
- return dedupeQueries(value.slice(0, 10_000).split(/\s{0,256}\|\|\s{0,256}/).map((item) => item.trim()));
203
- }
204
- return undefined;
205
- }
206
- function buildGmailReplyOnlyFallback(subaction) {
207
- switch (subaction) {
208
- case "search":
209
- return "What email do you want me to search for?";
210
- case "read":
211
- return "Which email do you want me to read?";
212
- case "draft_reply":
213
- case "draft_batch_replies":
214
- return "Which email do you want me to draft a reply for?";
215
- case "send_reply":
216
- case "send_batch_replies":
217
- case "send_message":
218
- return "What exactly do you want me to send in Gmail?";
219
- case "needs_response":
220
- return "Do you want emails that need a reply, or something else in Gmail?";
221
- case "recommend":
222
- return "Do you want Gmail action recommendations for the current inbox or a specific search?";
223
- case "unresponded":
224
- return "How far back should I look for sent Gmail threads without replies?";
225
- case "manage":
226
- return "Which Gmail messages should I update, and should I archive, mark read, label, trash, or report spam?";
227
- default:
228
- return "What do you want to do in Gmail — check inbox, search, manage, read, or draft a reply?";
229
- }
230
- }
231
- function buildGmailServiceErrorFallback(error) {
232
- const normalized = normalizeText(error.message);
233
- if (error.status === 429 || normalized.includes("rate limit")) {
234
- return "Gmail is rate-limited right now. Try again in a bit.";
235
- }
236
- if (normalized.includes("multiple gmail messages matched") ||
237
- (error.status === 409 &&
238
- normalized.includes("narrow the query") &&
239
- normalized.includes("message"))) {
240
- return "I found more than one matching email. Tell me the sender, subject, or message id.";
241
- }
242
- if (normalized.includes("not found")) {
243
- return "I couldn't find that email. Tell me who it was from or what the subject looked like.";
244
- }
245
- if (normalized.includes("missing") &&
246
- (normalized.includes("message") || normalized.includes("body"))) {
247
- return "I still need the exact message or the reply text to finish that Gmail action.";
248
- }
249
- return "I couldn't finish that Gmail action yet. Tell me what message you want and what you want me to do with it.";
250
- }
251
- function buildGmailTargetDisambiguationFallback(feed) {
252
- return `${formatEmailSearch(feed)}\nTell me which email you mean by sender, subject, or message id.`;
253
- }
254
- function shouldUseCanonicalGmailReplyFallback(scenario) {
255
- return (scenario === "access_denied" ||
256
- scenario === "gmail_read_unavailable" ||
257
- scenario === "gmail_send_unavailable");
258
- }
259
- async function renderGmailActionReply(args) {
260
- const { runtime, message, state, intent, scenario, fallback, context } = args;
261
- if (shouldUseCanonicalGmailReplyFallback(scenario)) {
262
- return fallback;
263
- }
264
- return renderGroundedActionReply({
265
- runtime,
266
- message,
267
- state,
268
- intent,
269
- domain: "gmail",
270
- scenario,
271
- fallback,
272
- context,
273
- preferCharacterVoice: true,
274
- additionalRules: [
275
- "Mirror the user's wording for time windows, urgency, and reply intent when possible.",
276
- "Preserve all concrete email facts from the context and canonical fallback.",
277
- "If this is reply-only or a clarification, do not pretend you already searched, drafted, or sent something.",
278
- ],
279
- });
280
- }
281
- function normalizeText(value) {
282
- return value.trim().toLowerCase().replace(/\s+/g, " ");
283
- }
284
- function normalizeLookupKey(value) {
285
- return value.toLowerCase().replace(/[^a-z0-9]/g, "");
286
- }
287
- function dedupeQueries(values) {
288
- const queries = [];
289
- const seen = new Set();
290
- for (const value of values) {
291
- const query = typeof value === "string" ? value.trim().replace(/\s+/g, " ") : "";
292
- if (!query) {
293
- continue;
294
- }
295
- const key = query.toLowerCase();
296
- if (seen.has(key)) {
297
- continue;
298
- }
299
- seen.add(key);
300
- queries.push(query);
301
- }
302
- return queries;
303
- }
304
- function normalizeGmailDetails(details) {
305
- if (!details) {
306
- return undefined;
307
- }
308
- const normalized = { ...details };
309
- const aliasMap = new Map();
310
- for (const [canonical, aliases] of Object.entries(GMAIL_DETAIL_ALIASES)) {
311
- aliasMap.set(normalizeLookupKey(canonical), canonical);
312
- for (const alias of aliases) {
313
- aliasMap.set(normalizeLookupKey(alias), canonical);
314
- }
315
- }
316
- for (const [key, value] of Object.entries(details)) {
317
- const canonical = aliasMap.get(normalizeLookupKey(key));
318
- if (!canonical) {
319
- continue;
320
- }
321
- if (normalized[canonical] === undefined) {
322
- normalized[canonical] = value;
323
- }
324
- }
325
- return normalized;
326
- }
327
- function normalizeStringArray(value) {
328
- const normalized = Array.isArray(value)
329
- ? value.flatMap((item) => typeof item === "string" ? splitLooseListString(item) : [])
330
- : typeof value === "string"
331
- ? splitLooseListString(value)
332
- : [];
333
- return normalized.length > 0 ? normalized : undefined;
334
- }
335
- function normalizeOptionalBoolean(value) {
336
- return typeof value === "boolean" ? value : undefined;
337
- }
338
- function normalizePlannerGmailOperation(value) {
339
- if (typeof value !== "string") {
340
- return undefined;
341
- }
342
- const normalized = value.trim().toLowerCase();
343
- switch (normalized) {
344
- case "archive":
345
- case "trash":
346
- case "delete":
347
- case "report_spam":
348
- case "mark_read":
349
- case "mark_unread":
350
- case "apply_label":
351
- case "remove_label":
352
- return normalized;
353
- case "spam":
354
- return "report_spam";
355
- default:
356
- return undefined;
357
- }
358
- }
359
- function normalizeGmailPlanStepKind(value, subaction) {
360
- if (typeof value === "string") {
361
- const normalized = value.trim().toLowerCase();
362
- switch (normalized) {
363
- case "gmail_subaction":
364
- case "classify":
365
- case "propose_action":
366
- case "request_approval":
367
- case "audit":
368
- return normalized;
369
- default:
370
- break;
371
- }
372
- }
373
- return subaction ? "gmail_subaction" : "propose_action";
374
- }
375
- function normalizeGmailPlanStepStatus(value) {
376
- if (typeof value !== "string") {
377
- return undefined;
378
- }
379
- const normalized = value.trim().toLowerCase();
380
- switch (normalized) {
381
- case "pending":
382
- case "ready":
383
- case "blocked":
384
- case "completed":
385
- return normalized;
386
- case "complete":
387
- case "done":
388
- return "completed";
389
- case "waiting":
390
- case "waiting_approval":
391
- return "blocked";
392
- default:
393
- return undefined;
394
- }
395
- }
396
- function normalizeGmailPlanStep(value, index) {
397
- if (!value || typeof value !== "object" || Array.isArray(value)) {
398
- return null;
399
- }
400
- const record = value;
401
- const subaction = normalizeGmailSubaction(record.subaction);
402
- const payload = normalizeGmailPayloadPlan(record);
403
- const id = normalizePlannerString(record.id ?? record.stepId) ?? `step_${index + 1}`;
404
- return {
405
- id,
406
- kind: normalizeGmailPlanStepKind(record.kind ?? record.type, subaction),
407
- subaction: subaction ?? undefined,
408
- goal: normalizePlannerString(record.goal ?? record.description ?? record.purpose),
409
- dependsOn: normalizePlannerStringArray(record.dependsOn),
410
- requiresApproval: normalizeOptionalBoolean(record.requiresApproval),
411
- status: normalizeGmailPlanStepStatus(record.status),
412
- ...payload,
413
- };
414
- }
415
- function normalizeGmailPlanSteps(value) {
416
- if (!Array.isArray(value)) {
417
- return undefined;
418
- }
419
- const steps = value
420
- .map((step, index) => normalizeGmailPlanStep(step, index))
421
- .filter((step) => step !== null);
422
- return steps.length > 0 ? steps : undefined;
423
- }
424
- function isExecutableGmailPlanStep(step) {
425
- return Boolean(step.subaction &&
426
- step.kind === "gmail_subaction" &&
427
- step.status !== "blocked" &&
428
- step.status !== "completed");
429
- }
430
- function selectGmailPlanStep(args) {
431
- if (!args.steps || args.steps.length === 0) {
432
- return undefined;
433
- }
434
- const currentStep = args.currentStepId
435
- ? args.steps.find((step) => step.id === args.currentStepId)
436
- : undefined;
437
- if (currentStep && isExecutableGmailPlanStep(currentStep)) {
438
- return currentStep;
439
- }
440
- return args.steps.find(isExecutableGmailPlanStep);
441
- }
442
- function mergeGmailPayloadPlans(primary, fallback) {
443
- return {
444
- queries: dedupeQueries([...primary.queries, ...fallback.queries]),
445
- messageId: primary.messageId ?? fallback.messageId,
446
- messageIds: mergePlannerArray(primary.messageIds, fallback.messageIds),
447
- replyNeededOnly: primary.replyNeededOnly ?? fallback.replyNeededOnly,
448
- confirmed: primary.confirmed ?? fallback.confirmed,
449
- holdForApproval: primary.holdForApproval ?? fallback.holdForApproval,
450
- operation: primary.operation ?? fallback.operation,
451
- labelIds: mergePlannerArray(primary.labelIds, fallback.labelIds),
452
- confirmDestructive: primary.confirmDestructive ?? fallback.confirmDestructive,
453
- olderThanDays: primary.olderThanDays ?? fallback.olderThanDays,
454
- to: mergePlannerArray(primary.to, fallback.to),
455
- cc: mergePlannerArray(primary.cc, fallback.cc),
456
- bcc: mergePlannerArray(primary.bcc, fallback.bcc),
457
- subject: primary.subject ?? fallback.subject,
458
- bodyText: primary.bodyText ?? fallback.bodyText,
459
- };
460
- }
461
- function buildGmailWorkflowPlanSnapshot(args) {
462
- if (!args.plan.steps || args.plan.steps.length === 0) {
463
- return undefined;
464
- }
465
- const currentStep = selectGmailPlanStep({
466
- steps: args.plan.steps,
467
- currentStepId: args.plan.currentStepId,
468
- }) ??
469
- args.plan.steps.find((step) => step.subaction === args.executedSubaction &&
470
- step.status !== "completed");
471
- const executedStepId = currentStep?.id;
472
- const steps = args.plan.steps.map((step) => args.success && step.id === executedStepId
473
- ? { ...step, status: "completed" }
474
- : step);
475
- const executedIndex = executedStepId
476
- ? steps.findIndex((step) => step.id === executedStepId)
477
- : -1;
478
- // One handler invocation owns one Gmail service call; later workflow steps
479
- // are persisted for the next planner turn instead of being executed here.
480
- const nextSteps = executedIndex >= 0
481
- ? steps.slice(executedIndex + 1)
482
- : steps.filter((step) => step.status !== "completed");
483
- const nextStepIds = nextSteps
484
- .filter((step) => step.status !== "completed")
485
- .map((step) => step.id);
486
- return {
487
- summary: args.plan.planSummary,
488
- currentStepId: nextStepIds[0],
489
- lastExecutedStepId: args.success ? executedStepId : undefined,
490
- nextStepIds,
491
- steps,
492
- };
493
- }
494
- function attachGmailWorkflowPlanData(args) {
495
- const gmailPlan = buildGmailWorkflowPlanSnapshot({
496
- plan: args.plan,
497
- executedSubaction: args.executedSubaction,
498
- success: args.success,
499
- });
500
- if (!gmailPlan) {
501
- return args.data;
502
- }
503
- const dataRecord = args.data && typeof args.data === "object"
504
- ? args.data
505
- : {};
506
- return toActionData({
507
- ...dataRecord,
508
- gmailPlan,
509
- });
510
- }
511
- function coerceGmailComposeDraft(value) {
512
- if (!value || typeof value !== "object" || Array.isArray(value)) {
513
- return null;
514
- }
515
- const record = value;
516
- if (record.subaction !== "send_message") {
517
- return null;
518
- }
519
- const status = record.status === "sent" || record.status === "pending_clarification"
520
- ? record.status
521
- : null;
522
- if (!status) {
523
- return null;
524
- }
525
- return {
526
- subaction: "send_message",
527
- status,
528
- intent: normalizePlannerString(record.intent),
529
- to: normalizePlannerStringArray(record.to),
530
- cc: normalizePlannerStringArray(record.cc),
531
- bcc: normalizePlannerStringArray(record.bcc),
532
- subject: normalizePlannerString(record.subject),
533
- bodyText: normalizePlannerString(record.bodyText),
534
- updatedAt: normalizePlannerString(record.updatedAt),
535
- };
536
- }
537
- function buildGmailComposeDraft(args) {
538
- return {
539
- subaction: "send_message",
540
- status: args.status,
541
- intent: args.intent,
542
- to: args.to,
543
- cc: args.cc,
544
- bcc: args.bcc,
545
- subject: args.subject,
546
- bodyText: args.bodyText,
547
- updatedAt: new Date().toISOString(),
548
- };
549
- }
550
- function composeDraftFromActionResult(result) {
551
- if (!result?.data || typeof result.data !== "object") {
552
- return null;
553
- }
554
- return coerceGmailComposeDraft(result.data.gmailDraft);
555
- }
556
- function coerceGmailReplyDraftContext(value) {
557
- if (!value || typeof value !== "object" || Array.isArray(value)) {
558
- return null;
559
- }
560
- const record = value;
561
- const messageId = normalizePlannerString(record.messageId);
562
- const bodyText = normalizePlannerString(record.bodyText ?? record.body);
563
- if (!messageId || !bodyText) {
564
- return null;
565
- }
566
- return {
567
- messageId,
568
- bodyText,
569
- subject: normalizePlannerString(record.subject),
570
- to: normalizePlannerStringArray(record.to),
571
- cc: normalizePlannerStringArray(record.cc),
572
- };
573
- }
574
- function coerceGmailMessageTargetContext(value) {
575
- if (!value || typeof value !== "object" || Array.isArray(value)) {
576
- return null;
577
- }
578
- const record = value;
579
- const messageId = normalizePlannerString(record.id ?? record.messageId);
580
- if (!messageId) {
581
- return null;
582
- }
583
- return {
584
- messageId,
585
- subject: normalizePlannerString(record.subject),
586
- from: normalizePlannerString(record.from),
587
- query: normalizePlannerString(record.query),
588
- };
589
- }
590
- function gmailStateDataRecords(state) {
591
- return extractStateDataRecords(state);
592
- }
593
- function latestGmailReplyDraftContext(state) {
594
- const records = gmailStateDataRecords(state);
595
- for (const record of records.reverse()) {
596
- const directDraft = coerceGmailReplyDraftContext(record.gmailDraft) ??
597
- coerceGmailReplyDraftContext(record.draft) ??
598
- coerceGmailReplyDraftContext(record);
599
- if (directDraft) {
600
- return directDraft;
601
- }
602
- if (Array.isArray(record.drafts)) {
603
- for (const candidate of [...record.drafts].reverse()) {
604
- const draft = coerceGmailReplyDraftContext(candidate);
605
- if (draft) {
606
- return draft;
607
- }
608
- }
609
- }
610
- }
611
- return null;
612
- }
613
- function latestGmailBatchReplyDraftItems(state) {
614
- const records = gmailStateDataRecords(state);
615
- for (const record of records.reverse()) {
616
- const drafts = Array.isArray(record.drafts)
617
- ? record.drafts
618
- .map((draft) => coerceGmailReplyDraftContext(draft))
619
- .filter((draft) => draft !== null)
620
- : [];
621
- if (drafts.length === 0) {
622
- continue;
623
- }
624
- return drafts.map((draft) => ({
625
- messageId: draft.messageId,
626
- bodyText: draft.bodyText,
627
- subject: draft.subject,
628
- to: draft.to,
629
- cc: draft.cc,
630
- }));
631
- }
632
- return undefined;
633
- }
634
- function latestGmailMessageTargetContext(state) {
635
- const records = gmailStateDataRecords(state);
636
- for (const record of records.reverse()) {
637
- const directTarget = coerceGmailMessageTargetContext(record.message) ??
638
- coerceGmailMessageTargetContext(record.gmailMessage) ??
639
- coerceGmailMessageTargetContext(record);
640
- if (directTarget) {
641
- return directTarget;
642
- }
643
- if (Array.isArray(record.messages)) {
644
- for (const candidate of record.messages) {
645
- const message = coerceGmailMessageTargetContext(candidate);
646
- if (message) {
647
- return {
648
- ...message,
649
- query: message.query ?? normalizePlannerString(record.query),
650
- };
651
- }
652
- }
653
- }
654
- }
655
- return null;
656
- }
657
- function coerceGmailWorkflowPlan(value) {
658
- if (!value || typeof value !== "object" || Array.isArray(value)) {
659
- return null;
660
- }
661
- const record = value;
662
- const steps = normalizeGmailPlanSteps(record.steps);
663
- if (!steps) {
664
- return null;
665
- }
666
- return {
667
- summary: normalizePlannerString(record.summary ?? record.planSummary),
668
- currentStepId: normalizePlannerString(record.currentStepId),
669
- lastExecutedStepId: normalizePlannerString(record.lastExecutedStepId),
670
- nextStepIds: normalizePlannerStringArray(record.nextStepIds),
671
- steps,
672
- };
673
- }
674
- function latestGmailWorkflowPlan(state) {
675
- const records = gmailStateDataRecords(state);
676
- for (const record of records.reverse()) {
677
- const plan = coerceGmailWorkflowPlan(record.gmailPlan) ??
678
- coerceGmailWorkflowPlan(record.plan);
679
- if (plan) {
680
- return plan;
681
- }
682
- }
683
- return null;
684
- }
685
- function gmailComposeDraftFromMessageEntry(entry) {
686
- const content = entry.content && typeof entry.content === "object"
687
- ? entry.content
688
- : null;
689
- if (!content) {
690
- return null;
691
- }
692
- return (coerceGmailComposeDraft(content.gmailDraft) ??
693
- coerceGmailComposeDraft(content.data && typeof content.data === "object"
694
- ? content.data.gmailDraft
695
- : undefined));
696
- }
697
- function latestGmailComposeDraft(state, statuses) {
698
- const drafts = [];
699
- for (const result of extractActionResultsFromState(state)) {
700
- const draft = composeDraftFromActionResult(result);
701
- if (draft) {
702
- drafts.push(draft);
703
- }
704
- }
705
- for (const entry of extractRecentMessageEntriesFromState(state)) {
706
- const draft = gmailComposeDraftFromMessageEntry(entry);
707
- if (draft) {
708
- drafts.push(draft);
709
- }
710
- }
711
- const allowed = new Set(statuses);
712
- for (const draft of drafts.reverse()) {
713
- if (allowed.has(draft.status)) {
714
- return draft;
715
- }
716
- }
717
- return null;
718
- }
719
- function mergePlannerArray(primary, fallback) {
720
- if (primary && primary.length > 0) {
721
- return primary;
722
- }
723
- return fallback && fallback.length > 0 ? fallback : undefined;
724
- }
725
- function mergeComposeDrafts(...drafts) {
726
- let to;
727
- let cc;
728
- let bcc;
729
- let subject;
730
- let bodyText;
731
- let intent;
732
- let status = "pending_clarification";
733
- for (const draft of drafts) {
734
- if (!draft) {
735
- continue;
736
- }
737
- to = mergePlannerArray(draft.to, to);
738
- cc = mergePlannerArray(draft.cc, cc);
739
- bcc = mergePlannerArray(draft.bcc, bcc);
740
- subject =
741
- normalizePlannerString(draft.subject) ?? normalizePlannerString(subject);
742
- bodyText =
743
- normalizePlannerString(draft.bodyText) ??
744
- normalizePlannerString(bodyText);
745
- if ("intent" in draft) {
746
- intent =
747
- normalizePlannerString(draft.intent) ??
748
- intent;
749
- }
750
- if ("status" in draft) {
751
- const candidate = draft.status;
752
- if (candidate === "pending_clarification" || candidate === "sent") {
753
- status = candidate;
754
- }
755
- }
756
- }
757
- return buildGmailComposeDraft({
758
- status,
759
- intent,
760
- to,
761
- cc,
762
- bcc,
763
- subject,
764
- bodyText,
765
- });
766
- }
767
- async function buildGmailPlanningContext(args) {
768
- const recentConversation = (await collectGmailConversationContext(args)).join("\n");
769
- const currentMessage = messageText(args.message).trim();
770
- const timeZone = resolveDefaultTimeZone();
771
- const now = new Date();
772
- const nowIso = now.toISOString();
773
- const localNow = new Intl.DateTimeFormat(undefined, {
774
- timeZone,
775
- year: "numeric",
776
- month: "2-digit",
777
- day: "2-digit",
778
- hour: "2-digit",
779
- minute: "2-digit",
780
- second: "2-digit",
781
- hour12: false,
782
- }).format(now);
783
- return {
784
- recentConversation,
785
- latestReplyDraft: latestGmailReplyDraftContext(args.state),
786
- latestMessageTarget: latestGmailMessageTargetContext(args.state),
787
- activeWorkflowPlan: latestGmailWorkflowPlan(args.state),
788
- currentMessage,
789
- timeZone,
790
- nowIso,
791
- localNow,
792
- };
793
- }
794
- function parseGmailPlannerRecord(rawResponse) {
795
- return (parseKeyValueXml(rawResponse) ??
796
- parseJSONObjectFromText(rawResponse));
797
- }
798
- function extractPlannerQueries(parsed) {
799
- const rawQueries = [];
800
- if (typeof parsed.queries === "string" && parsed.queries.trim().length > 0) {
801
- for (const query of parsed.queries.split(/\s*\|\|\s*/)) {
802
- if (query.trim().length > 0) {
803
- rawQueries.push(query.trim());
804
- }
805
- }
806
- }
807
- else if (Array.isArray(parsed.queries)) {
808
- for (const value of parsed.queries) {
809
- if (typeof value === "string") {
810
- rawQueries.push(value);
811
- }
812
- }
813
- }
814
- if (typeof parsed.query === "string")
815
- rawQueries.push(parsed.query);
816
- if (typeof parsed.query1 === "string")
817
- rawQueries.push(parsed.query1);
818
- if (typeof parsed.query2 === "string")
819
- rawQueries.push(parsed.query2);
820
- if (typeof parsed.query3 === "string")
821
- rawQueries.push(parsed.query3);
822
- return rawQueries;
823
- }
824
- function normalizeGmailIntentPlan(parsed) {
825
- if (!parsed) {
826
- return { subaction: null, queries: [], shouldAct: null };
827
- }
828
- const steps = normalizeGmailPlanSteps(parsed.steps);
829
- const currentStepId = normalizePlannerString(parsed.currentStepId ?? parsed.current_step_id);
830
- const selectedStep = selectGmailPlanStep({ steps, currentStepId });
831
- return {
832
- subaction: normalizeGmailSubaction(parsed.subaction) ??
833
- selectedStep?.subaction ??
834
- null,
835
- queries: dedupeQueries(extractPlannerQueries(parsed)),
836
- shouldAct: normalizeShouldAct(parsed.shouldAct),
837
- confirmed: normalizeOptionalBoolean(parsed.confirmed),
838
- holdForApproval: normalizeOptionalBoolean(parsed.holdForApproval),
839
- messageId: typeof parsed.messageId === "string" && parsed.messageId.trim().length > 0
840
- ? parsed.messageId.trim()
841
- : undefined,
842
- messageIds: normalizePlannerStringArray(parsed.messageIds),
843
- replyNeededOnly: normalizeOptionalBoolean(parsed.replyNeededOnly),
844
- operation: normalizePlannerGmailOperation(parsed.operation),
845
- labelIds: normalizePlannerStringArray(parsed.labelIds),
846
- confirmDestructive: normalizeOptionalBoolean(parsed.confirmDestructive),
847
- olderThanDays: typeof parsed.olderThanDays === "number"
848
- ? parsed.olderThanDays
849
- : undefined,
850
- to: normalizePlannerStringArray(parsed.to ?? parsed.recipients),
851
- cc: normalizePlannerStringArray(parsed.cc),
852
- bcc: normalizePlannerStringArray(parsed.bcc),
853
- subject: normalizePlannerString(parsed.subject),
854
- bodyText: normalizePlannerString(parsed.bodyText ?? parsed.body),
855
- steps,
856
- currentStepId: currentStepId ?? selectedStep?.id,
857
- planSummary: normalizePlannerString(parsed.planSummary ?? parsed.summary ?? parsed.plan),
858
- };
859
- }
860
- function normalizeGmailPayloadPlan(parsed) {
861
- if (!parsed) {
862
- return { queries: [] };
863
- }
864
- return {
865
- queries: dedupeQueries(extractPlannerQueries(parsed)),
866
- messageId: normalizePlannerString(parsed.messageId),
867
- messageIds: normalizePlannerStringArray(parsed.messageIds),
868
- replyNeededOnly: normalizeOptionalBoolean(parsed.replyNeededOnly),
869
- confirmed: normalizeOptionalBoolean(parsed.confirmed),
870
- holdForApproval: normalizeOptionalBoolean(parsed.holdForApproval),
871
- operation: normalizePlannerGmailOperation(parsed.operation),
872
- labelIds: normalizePlannerStringArray(parsed.labelIds),
873
- confirmDestructive: normalizeOptionalBoolean(parsed.confirmDestructive),
874
- olderThanDays: typeof parsed.olderThanDays === "number"
875
- ? parsed.olderThanDays
876
- : undefined,
877
- to: normalizePlannerStringArray(parsed.to ?? parsed.recipients),
878
- cc: normalizePlannerStringArray(parsed.cc),
879
- bcc: normalizePlannerStringArray(parsed.bcc),
880
- subject: normalizePlannerString(parsed.subject),
881
- bodyText: normalizePlannerString(parsed.bodyText ?? parsed.body),
882
- };
883
- }
884
- function payloadFromGmailPlanFields(fields) {
885
- return {
886
- queries: fields.queries ?? [],
887
- messageId: fields.messageId,
888
- messageIds: fields.messageIds,
889
- replyNeededOnly: fields.replyNeededOnly,
890
- confirmed: fields.confirmed,
891
- holdForApproval: fields.holdForApproval,
892
- operation: fields.operation,
893
- labelIds: fields.labelIds,
894
- confirmDestructive: fields.confirmDestructive,
895
- olderThanDays: fields.olderThanDays,
896
- to: fields.to,
897
- cc: fields.cc,
898
- bcc: fields.bcc,
899
- subject: fields.subject,
900
- bodyText: fields.bodyText,
901
- };
902
- }
903
- function shouldExtractGmailPayload(subaction) {
904
- return subaction !== "triage" && subaction !== "send_batch_replies";
905
- }
906
- async function runGmailPlanningModel(args) {
907
- if (typeof args.runtime.useModel !== "function") {
908
- return null;
909
- }
910
- try {
911
- const runModel = args.runtime.useModel.bind(args.runtime);
912
- const result = await runModel(args.modelType, {
913
- prompt: args.prompt,
914
- });
915
- const rawResponse = typeof result === "string" ? result : "";
916
- return parseGmailPlannerRecord(rawResponse);
917
- }
918
- catch (error) {
919
- args.runtime.logger?.warn?.({
920
- src: "action:gmail",
921
- error: error instanceof Error ? error.message : String(error),
922
- }, args.failureMessage);
923
- return null;
924
- }
925
- }
926
- async function resolveGmailIntentPlanWithLlm(args) {
927
- const { context } = args;
928
- const prompt = [
929
- "Create the Gmail execution plan for this request.",
930
- "The user may speak in any language.",
931
- "This action can execute only one Gmail subaction in this invocation, but it must still plan the full user-visible workflow.",
932
- "Set top-level subaction to the first Gmail subaction that should execute now.",
933
- "Use steps to represent dependent work such as search, read, classify, propose_action, request_approval, execute, and audit.",
934
- "For multi-step requests, do not collapse directly to a later write/send step before required search/read/classification/approval steps have happened.",
935
- "Mailbox ownership (OWNER vs AGENT) is selected outside this planner.",
936
- "If the current request is vague or a follow-up, use recent conversation and any active Gmail workflow plan to recover the target or next step.",
937
- "When shouldAct=false, provide a short natural-language response that asks only for what is missing.",
938
- "When shouldAct=false, write that response in the user's language unless they clearly asked to switch languages.",
939
- "",
940
- "Return ONLY valid JSON with exactly these fields:",
941
- '{"subaction":"triage"|"needs_response"|"recommend"|"unresponded"|"search"|"read"|"draft_reply"|"draft_batch_replies"|"manage"|"send_reply"|"send_batch_replies"|"send_message"|null,"shouldAct":true|false,"response":"string|null","planSummary":"string|null","currentStepId":"string|null","steps":[]}',
942
- "Each step must be an object with id, kind, subaction, goal, status, dependsOn, requiresApproval, and any known Gmail fields.",
943
- 'Allowed step kind values: "gmail_subaction", "classify", "propose_action", "request_approval", "audit".',
944
- "Only gmail_subaction steps may set subaction. Use null subaction for classify/propose_action/request_approval/audit steps.",
945
- 'Allowed step status values: "pending", "ready", "blocked", "completed". Use ready for the step to execute now.',
946
- "Gmail fields on steps may include queries, messageId, messageIds, replyNeededOnly, operation, labelIds, confirmDestructive, olderThanDays, to, cc, bcc, subject, bodyText, confirmed, and holdForApproval.",
947
- "",
948
- "Subactions and when to use each:",
949
- " triage — broad inbox overview only",
950
- " needs_response — specifically about emails that need a reply",
951
- " recommend — read-only recommended Gmail actions for the current inbox or a search",
952
- " unresponded — sent threads where the user is waiting on someone else",
953
- " search — search by sender, subject, keyword, label, or time window",
954
- " read — read a specific email body",
955
- " draft_reply — draft a reply to one email thread",
956
- " draft_batch_replies — draft replies to multiple emails",
957
- " manage — archive, trash, mark read/unread, spam, or label existing emails",
958
- " send_reply — send a confirmed reply to one email thread",
959
- " send_batch_replies — send confirmed replies to multiple emails",
960
- " send_message — compose or send a brand-new outbound email",
961
- "Use triage only for broad inbox overviews.",
962
- "Use search as the first step when the request includes a specific sender, subject, keyword, label, or time filter and later work depends on seeing the matching thread.",
963
- "Use needs_response only when the user is specifically asking about emails that need a reply.",
964
- "Use recommend when the user asks what to archive, mark read, label, spam-review, or otherwise clean up without explicitly executing the write.",
965
- "Use unresponded when the user asks what sent emails are waiting for a reply.",
966
- "Use manage for inbox-zero operations such as archive, delete, spam, label, or mark read.",
967
- "Use send_message only for brand-new outbound email, not for replies to an existing thread.",
968
- "If there is an active compose draft and the user is filling in fields or confirming the send, choose send_message.",
969
- "",
970
- "Examples:",
971
- ' "check my inbox" -> {"subaction":"triage","shouldAct":true,"response":null,"planSummary":"Triage Gmail inbox","currentStepId":"triage","steps":[{"id":"triage","kind":"gmail_subaction","subaction":"triage","goal":"Summarize the inbox","status":"ready","dependsOn":[],"requiresApproval":false}]}',
972
- ' "did Sarah email me this week" -> {"subaction":"search","shouldAct":true,"response":null,"planSummary":"Search Gmail for Sarah this week","currentStepId":"search_sarah","steps":[{"id":"search_sarah","kind":"gmail_subaction","subaction":"search","goal":"Find matching email threads","status":"ready","queries":["from:sarah newer_than:7d"],"dependsOn":[],"requiresApproval":false}]}',
973
- ' "search for Sarah, read the thread, tell me if I should reply, draft it for approval, then send if I approve" -> {"subaction":"search","shouldAct":true,"response":null,"planSummary":"Find, read, classify, draft, approve, and send a Sarah reply","currentStepId":"search_sarah","steps":[{"id":"search_sarah","kind":"gmail_subaction","subaction":"search","goal":"Find the Sarah thread","status":"ready","queries":["from:sarah"],"dependsOn":[],"requiresApproval":false},{"id":"read_thread","kind":"gmail_subaction","subaction":"read","goal":"Read the selected thread","status":"pending","dependsOn":["search_sarah"],"requiresApproval":false},{"id":"classify_need","kind":"classify","subaction":null,"goal":"Decide whether the thread needs action","status":"pending","dependsOn":["read_thread"],"requiresApproval":false},{"id":"propose_reply","kind":"propose_action","subaction":null,"goal":"Propose the reply strategy","status":"pending","dependsOn":["classify_need"],"requiresApproval":false},{"id":"draft_reply","kind":"gmail_subaction","subaction":"draft_reply","goal":"Draft the reply","status":"pending","dependsOn":["propose_reply"],"requiresApproval":false},{"id":"approve_send","kind":"request_approval","subaction":null,"goal":"Ask before sending","status":"pending","dependsOn":["draft_reply"],"requiresApproval":true},{"id":"send_reply","kind":"gmail_subaction","subaction":"send_reply","goal":"Send the approved reply","status":"pending","dependsOn":["approve_send"],"requiresApproval":true},{"id":"audit","kind":"audit","subaction":null,"goal":"Report what happened","status":"pending","dependsOn":["send_reply"],"requiresApproval":false}]}',
974
- ' "send that reply now" with recent draft context -> {"subaction":"send_reply","shouldAct":true,"response":null,"planSummary":"Send the existing Gmail reply draft","currentStepId":"send_reply","steps":[{"id":"send_reply","kind":"gmail_subaction","subaction":"send_reply","goal":"Send the confirmed reply draft","status":"ready","dependsOn":[],"requiresApproval":true,"confirmed":true}]}',
975
- ' "can you help me with my email?" -> {"subaction":null,"shouldAct":false,"response":"What do you want to do in Gmail — check inbox, search, read, or draft a reply?","planSummary":null,"currentStepId":null,"steps":[]}',
976
- ...(args.activeComposeDraft
977
- ? [
978
- "",
979
- "Active compose draft:",
980
- ` ${JSON.stringify({
981
- to: args.activeComposeDraft.to,
982
- cc: args.activeComposeDraft.cc,
983
- bcc: args.activeComposeDraft.bcc,
984
- subject: args.activeComposeDraft.subject,
985
- bodyText: args.activeComposeDraft.bodyText,
986
- })}`,
987
- ]
988
- : []),
989
- ...(context.latestReplyDraft || context.latestMessageTarget
990
- ? [
991
- "",
992
- "Recent reply context:",
993
- ` ${JSON.stringify({
994
- latestReplyDraft: context.latestReplyDraft,
995
- latestMessageTarget: context.latestMessageTarget,
996
- })}`,
997
- ]
998
- : []),
999
- ...(context.activeWorkflowPlan
1000
- ? [
1001
- "",
1002
- "Active Gmail workflow plan from recent action results:",
1003
- ` ${JSON.stringify(context.activeWorkflowPlan)}`,
1004
- ]
1005
- : []),
1006
- "",
1007
- `Current timezone: ${context.timeZone}`,
1008
- `Current local datetime: ${context.localNow}`,
1009
- `Current ISO datetime: ${context.nowIso}`,
1010
- `Current request: ${JSON.stringify(context.currentMessage)}`,
1011
- `Resolved intent: ${JSON.stringify(args.intent)}`,
1012
- `Recent conversation: ${JSON.stringify(context.recentConversation)}`,
1013
- ].join("\n");
1014
- const parsed = await runGmailPlanningModel({
1015
- runtime: args.runtime,
1016
- prompt,
1017
- modelType: ModelType.TEXT_LARGE,
1018
- failureMessage: "Gmail intent planning model call failed",
1019
- });
1020
- return normalizeGmailIntentPlan(parsed);
1021
- }
1022
- async function extractGmailPayloadWithLlm(args) {
1023
- const { context, subaction, currentStep } = args;
1024
- const searchLikeSubaction = subaction === "needs_response" ||
1025
- subaction === "recommend" ||
1026
- subaction === "unresponded" ||
1027
- subaction === "search" ||
1028
- subaction === "read" ||
1029
- subaction === "draft_reply" ||
1030
- subaction === "draft_batch_replies" ||
1031
- subaction === "manage" ||
1032
- subaction === "send_reply";
1033
- const prompt = [
1034
- `Extract Gmail parameters for the current executable step ${currentStep?.id ?? subaction} (${subaction}).`,
1035
- "The user may speak in any language.",
1036
- "Do not skip ahead to a later workflow step. Only extract the supporting fields for the current executable step.",
1037
- "The larger stepwise plan is provided for dependency context; preserve it conceptually while returning only current-step fields.",
1038
- "",
1039
- "Return ONLY valid JSON with exactly these fields:",
1040
- '{"queries":[],"messageId":null,"messageIds":[],"replyNeededOnly":null,"operation":null,"labelIds":[],"confirmDestructive":null,"olderThanDays":null,"to":[],"cc":[],"bcc":[],"subject":null,"bodyText":null}',
1041
- "",
1042
- searchLikeSubaction
1043
- ? "For this subaction, use queries for sender, subject, keyword, label, and time filters. Use Gmail search syntax even when the user speaks another language."
1044
- : "For this subaction, leave queries, messageId, and replyNeededOnly empty unless the user explicitly provides them.",
1045
- subaction === "search"
1046
- ? "When the user asks who emailed them or whether anyone emailed within a time window, emit at least a time-window Gmail query like newer_than:1d instead of leaving queries empty."
1047
- : "Do not invent sender or time filters that are not supported by the request or recent context.",
1048
- searchLikeSubaction
1049
- ? "If the request already relies on recent context like 'that email' or 'send that reply', leave messageId and queries empty rather than inventing them."
1050
- : "Preserve existing compose-draft fields unless the current user message clearly overrides them.",
1051
- subaction === "needs_response" || subaction === "draft_batch_replies"
1052
- ? "Set replyNeededOnly=true only when the request is specifically about emails that need a reply."
1053
- : "Set replyNeededOnly only when it is genuinely required by the fixed subaction.",
1054
- subaction === "send_message"
1055
- ? "Extract to, cc, bcc, subject, and bodyText for a brand-new outbound email."
1056
- : "Leave to, cc, bcc, subject, and bodyText empty unless they are explicitly part of this fixed subaction.",
1057
- subaction === "manage"
1058
- ? "For operation, use one of archive, trash, delete, report_spam, mark_read, mark_unread, apply_label, remove_label. Set confirmDestructive=true only when the user explicitly confirms trash, spam, or delete right now."
1059
- : "Leave operation, labelIds, and confirmDestructive empty unless the fixed subaction is manage.",
1060
- subaction === "unresponded"
1061
- ? "Extract olderThanDays when the user gives a waiting-age threshold."
1062
- : "Leave olderThanDays empty unless the fixed subaction is unresponded.",
1063
- "",
1064
- "Examples:",
1065
- ...(searchLikeSubaction
1066
- ? [
1067
- ' fixed subaction search, request "who emailed me today" -> {"queries":["newer_than:1d"],"messageId":null,"messageIds":[],"replyNeededOnly":null,"operation":null,"labelIds":[],"confirmDestructive":null,"olderThanDays":null,"to":[],"cc":[],"bcc":[],"subject":null,"bodyText":null}',
1068
- ' fixed subaction search, request "did Sarah email me this week" -> {"queries":["from:sarah newer_than:7d"],"messageId":null,"messageIds":[],"replyNeededOnly":null,"operation":null,"labelIds":[],"confirmDestructive":null,"olderThanDays":null,"to":[],"cc":[],"bcc":[],"subject":null,"bodyText":null}',
1069
- ' fixed subaction needs_response, request "which emails need a reply about venue" -> {"queries":["venue"],"messageId":null,"messageIds":[],"replyNeededOnly":true,"operation":null,"labelIds":[],"confirmDestructive":null,"olderThanDays":null,"to":[],"cc":[],"bcc":[],"subject":null,"bodyText":null}',
1070
- ' fixed subaction read, request "read the latest email from finance" -> {"queries":["from:finance"],"messageId":null,"messageIds":[],"replyNeededOnly":null,"operation":null,"labelIds":[],"confirmDestructive":null,"olderThanDays":null,"to":[],"cc":[],"bcc":[],"subject":null,"bodyText":null}',
1071
- ' fixed subaction manage, request "archive that email" with recent target context -> {"queries":[],"messageId":null,"messageIds":[],"replyNeededOnly":null,"operation":"archive","labelIds":[],"confirmDestructive":null,"olderThanDays":null,"to":[],"cc":[],"bcc":[],"subject":null,"bodyText":null}',
1072
- ' fixed subaction send_reply, request "send that reply now" with recent draft context -> {"queries":[],"messageId":null,"messageIds":[],"replyNeededOnly":null,"operation":null,"labelIds":[],"confirmDestructive":null,"olderThanDays":null,"to":[],"cc":[],"bcc":[],"subject":null,"bodyText":null}',
1073
- ]
1074
- : [
1075
- ' fixed subaction send_message, request "send an email to zo@iqlabs.dev, subject hello, body test" -> {"queries":[],"messageId":null,"messageIds":[],"replyNeededOnly":null,"operation":null,"labelIds":[],"confirmDestructive":null,"olderThanDays":null,"to":["zo@iqlabs.dev"],"cc":[],"bcc":[],"subject":"hello","bodyText":"test"}',
1076
- ' fixed subaction send_message, active draft to=["shaw@gmail.com"], request "send an email like \\"test\\"" -> {"queries":[],"messageId":null,"messageIds":[],"replyNeededOnly":null,"operation":null,"labelIds":[],"confirmDestructive":null,"olderThanDays":null,"to":["shaw@gmail.com"],"cc":[],"bcc":[],"subject":"test","bodyText":"test"}',
1077
- ]),
1078
- ...(args.activeComposeDraft && subaction === "send_message"
1079
- ? [
1080
- "",
1081
- "Active compose draft:",
1082
- ` ${JSON.stringify({
1083
- to: args.activeComposeDraft.to,
1084
- cc: args.activeComposeDraft.cc,
1085
- bcc: args.activeComposeDraft.bcc,
1086
- subject: args.activeComposeDraft.subject,
1087
- bodyText: args.activeComposeDraft.bodyText,
1088
- })}`,
1089
- ]
1090
- : []),
1091
- ...(args.steps && args.steps.length > 0
1092
- ? [
1093
- "",
1094
- "Stepwise Gmail workflow plan:",
1095
- ` ${JSON.stringify(args.steps)}`,
1096
- `Current executable step: ${JSON.stringify(currentStep ?? null)}`,
1097
- ]
1098
- : []),
1099
- ...(context.latestReplyDraft || context.latestMessageTarget
1100
- ? [
1101
- "",
1102
- "Recent reply context:",
1103
- ` ${JSON.stringify({
1104
- latestReplyDraft: context.latestReplyDraft,
1105
- latestMessageTarget: context.latestMessageTarget,
1106
- })}`,
1107
- ]
1108
- : []),
1109
- "",
1110
- `Current timezone: ${context.timeZone}`,
1111
- `Current local datetime: ${context.localNow}`,
1112
- `Current ISO datetime: ${context.nowIso}`,
1113
- `Current request: ${JSON.stringify(context.currentMessage)}`,
1114
- `Resolved intent: ${JSON.stringify(args.intent)}`,
1115
- `Recent conversation: ${JSON.stringify(context.recentConversation)}`,
1116
- ].join("\n");
1117
- const parsed = await runGmailPlanningModel({
1118
- runtime: args.runtime,
1119
- prompt,
1120
- modelType: ModelType.TEXT_LARGE,
1121
- failureMessage: "Gmail parameter extraction model call failed",
1122
- });
1123
- const payload = normalizeGmailPayloadPlan(parsed);
1124
- if (subaction === "needs_response" && payload.replyNeededOnly === undefined) {
1125
- return { ...payload, replyNeededOnly: true };
1126
- }
1127
- return payload;
1128
- }
1129
- export async function extractGmailPlanWithLlm(runtime, message, state, intent, activeComposeDraft) {
1130
- const context = await buildGmailPlanningContext({
1131
- runtime,
1132
- message,
1133
- state,
1134
- });
1135
- const intentPlan = await resolveGmailIntentPlanWithLlm({
1136
- runtime,
1137
- intent,
1138
- context,
1139
- activeComposeDraft,
1140
- });
1141
- const currentStep = selectGmailPlanStep({
1142
- steps: intentPlan.steps,
1143
- currentStepId: intentPlan.currentStepId,
1144
- });
1145
- const subaction = currentStep?.subaction ?? intentPlan.subaction;
1146
- const intentPayload = payloadFromGmailPlanFields(intentPlan);
1147
- const stepPayload = currentStep
1148
- ? payloadFromGmailPlanFields(currentStep)
1149
- : { queries: [] };
1150
- const plannedPayload = mergeGmailPayloadPlans(intentPayload, stepPayload);
1151
- if (!subaction || intentPlan.shouldAct === false) {
1152
- return {
1153
- subaction,
1154
- queries: [],
1155
- response: intentPlan.response,
1156
- shouldAct: intentPlan.shouldAct,
1157
- steps: intentPlan.steps,
1158
- currentStepId: intentPlan.currentStepId,
1159
- planSummary: intentPlan.planSummary,
1160
- };
1161
- }
1162
- if (!shouldExtractGmailPayload(subaction)) {
1163
- return {
1164
- subaction,
1165
- response: intentPlan.response,
1166
- shouldAct: intentPlan.shouldAct,
1167
- ...plannedPayload,
1168
- steps: intentPlan.steps,
1169
- currentStepId: intentPlan.currentStepId ?? currentStep?.id,
1170
- planSummary: intentPlan.planSummary,
1171
- replyNeededOnly: plannedPayload.replyNeededOnly ??
1172
- (subaction === "needs_response" ? true : undefined),
1173
- };
1174
- }
1175
- const payloadPlan = await extractGmailPayloadWithLlm({
1176
- runtime,
1177
- intent,
1178
- subaction,
1179
- currentStep,
1180
- steps: intentPlan.steps,
1181
- context,
1182
- activeComposeDraft,
1183
- });
1184
- const mergedPayload = mergeGmailPayloadPlans(payloadPlan, plannedPayload);
1185
- return {
1186
- subaction,
1187
- shouldAct: intentPlan.shouldAct,
1188
- response: intentPlan.response,
1189
- ...mergedPayload,
1190
- steps: intentPlan.steps,
1191
- currentStepId: intentPlan.currentStepId ?? currentStep?.id,
1192
- planSummary: intentPlan.planSummary,
1193
- };
1194
- }
1195
- async function recoverSendMessagePlanWithLlm(args) {
1196
- const { runtime, message, state, intent, currentPlan, activeDraft, previousSentDraft, } = args;
1197
- if (typeof runtime.useModel !== "function") {
1198
- return null;
1199
- }
1200
- const recentConversation = (await collectGmailConversationContext({ runtime, message, state })).join("\n");
1201
- const currentMessage = messageText(message).trim();
1202
- const prompt = [
1203
- "Extract or recover the Gmail compose draft for this conversation.",
1204
- "The user may speak in any language.",
1205
- "This is only for brand-new outbound emails, not replies to an existing thread.",
1206
- "There may be no existing compose draft yet. Start a new draft from the current user message whenever they are trying to send a brand-new email.",
1207
- "Use the current user message as the source of truth for any new or overridden compose fields.",
1208
- "Preserve already-established compose fields unless the current user message clearly overrides them.",
1209
- "If the current user only gives part of the email, keep any extracted fields and leave the rest empty.",
1210
- "Return shouldResume=true whenever the conversation is still actively composing a brand-new outbound email, even if recipient, subject, or body is still missing.",
1211
- "When there is an active pending compose draft, keep its recipient, cc, bcc, subject, and body unless the user changes them.",
1212
- "When the user says something like 'same as the last email', reuse subject/body/cc/bcc from the most recent completed outbound email, but keep the active draft recipient unless the user changes it.",
1213
- "When a recipient is already known and the user gives a single short payload like send an email like 'test', treat that payload as the body text and, if subject is still missing, use the same short payload as the minimal subject.",
1214
- "Keep the subject and body in the user's language unless the user explicitly asks to translate or switch languages.",
1215
- "If the user is only pausing, thinking, or not ready yet, set shouldResume=false and do not invent missing fields.",
1216
- "If the user cancels the email, set cancelled=true and shouldResume=false.",
1217
- "",
1218
- "Return ONLY XML with exactly these tags and nothing else.",
1219
- "Use || between multiple addresses inside to, cc, or bcc.",
1220
- "<shouldResume>true|false</shouldResume>",
1221
- "<cancelled>true|false</cancelled>",
1222
- "<response></response>",
1223
- "<to></to>",
1224
- "<cc></cc>",
1225
- "<bcc></bcc>",
1226
- "<subject></subject>",
1227
- "<bodyText></bodyText>",
1228
- "",
1229
- "Examples:",
1230
- ' current message: "send an email to zo@iqlabs.dev the subject should say hello anon and the body should say how are you doing today?"',
1231
- " <shouldResume>true</shouldResume><cancelled>false</cancelled><to>zo@iqlabs.dev</to><subject>hello anon</subject><bodyText>how are you doing today?</bodyText>",
1232
- ' current message: "send it to shawmakesmagic@gmail.com this time"',
1233
- " <shouldResume>true</shouldResume><cancelled>false</cancelled><to>shawmakesmagic@gmail.com</to>",
1234
- ' active draft recipient: ["shawmakesmagic@gmail.com"], current message: "send an email like \\"test\\""',
1235
- " <shouldResume>true</shouldResume><cancelled>false</cancelled><to>shawmakesmagic@gmail.com</to><subject>test</subject><bodyText>test</bodyText>",
1236
- ' active draft recipient: ["shawmakesmagic@gmail.com"], previous sent subject/body: "Quick test" / "test", current message: "same as the last email"',
1237
- " <shouldResume>true</shouldResume><cancelled>false</cancelled><to>shawmakesmagic@gmail.com</to><subject>Quick test</subject><bodyText>test</bodyText>",
1238
- ' current message: "enviale un correo a maria@example.com con asunto hola y cuerpo nos vemos manana"',
1239
- " <shouldResume>true</shouldResume><cancelled>false</cancelled><to>maria@example.com</to><subject>hola</subject><bodyText>nos vemos manana</bodyText>",
1240
- `Current user message: ${JSON.stringify(currentMessage)}`,
1241
- `Resolved intent: ${JSON.stringify(intent)}`,
1242
- `Current Gmail planner draft: ${JSON.stringify({
1243
- to: currentPlan.to,
1244
- cc: currentPlan.cc,
1245
- bcc: currentPlan.bcc,
1246
- subject: currentPlan.subject,
1247
- bodyText: currentPlan.bodyText,
1248
- response: currentPlan.response,
1249
- shouldAct: currentPlan.shouldAct,
1250
- subaction: currentPlan.subaction,
1251
- })}`,
1252
- `Active pending compose draft: ${JSON.stringify(activeDraft ?? null)}`,
1253
- `Most recent completed outbound email draft: ${JSON.stringify(previousSentDraft ?? null)}`,
1254
- `Recent conversation: ${JSON.stringify(recentConversation)}`,
1255
- ].join("\n");
1256
- let rawResponse = "";
1257
- try {
1258
- const runModel = runtime.useModel.bind(runtime);
1259
- const result = await runModel(ModelType.TEXT_LARGE, { prompt });
1260
- rawResponse = typeof result === "string" ? result : "";
1261
- }
1262
- catch (error) {
1263
- runtime.logger?.warn?.({
1264
- src: "action:gmail",
1265
- error: error instanceof Error ? error.message : String(error),
1266
- }, "Gmail compose recovery model call failed");
1267
- return null;
1268
- }
1269
- const parsed = parseKeyValueXml(rawResponse) ??
1270
- parseJSONObjectFromText(rawResponse);
1271
- if (!parsed) {
1272
- return null;
1273
- }
1274
- return {
1275
- shouldResume: normalizeOptionalBoolean(parsed.shouldResume),
1276
- cancelled: normalizeOptionalBoolean(parsed.cancelled),
1277
- response: normalizePlannerResponse(parsed.response),
1278
- to: normalizePlannerStringArray(parsed.to ?? parsed.recipients),
1279
- cc: normalizePlannerStringArray(parsed.cc),
1280
- bcc: normalizePlannerStringArray(parsed.bcc),
1281
- subject: normalizePlannerString(parsed.subject),
1282
- bodyText: normalizePlannerString(parsed.bodyText ?? parsed.body),
1283
- };
1284
- }
1285
- function resolveGmailSearchQueries(explicitQueries, llmPlan) {
1286
- return dedupeQueries([...explicitQueries, ...(llmPlan?.queries ?? [])]);
1287
- }
1288
- function buildGmailSearchPlan(args) {
1289
- const queries = dedupeQueries(args.queries);
1290
- if (queries.length === 0) {
1291
- return null;
1292
- }
1293
- const displayQuery = queries[0];
1294
- if (!displayQuery) {
1295
- return null;
1296
- }
1297
- return {
1298
- queries,
1299
- displayQuery,
1300
- };
1301
- }
1302
- async function resolveGmailTargetMessage(args) {
1303
- const resolvedQueries = resolveGmailSearchQueries([
1304
- ...args.explicitQueryArray,
1305
- args.paramsQuery,
1306
- detailString(args.details, "query"),
1307
- ], args.llmPlan);
1308
- const searchPlan = buildGmailSearchPlan({
1309
- queries: resolvedQueries,
1310
- });
1311
- if (!searchPlan) {
1312
- return { kind: "missing" };
1313
- }
1314
- const requestBase = {
1315
- mode: detailString(args.details, "mode"),
1316
- side: detailString(args.details, "side"),
1317
- grantId: detailString(args.details, "grantId"),
1318
- forceSync: detailBoolean(args.details, "forceSync"),
1319
- maxResults: detailNumber(args.details, "maxResults") ?? 10,
1320
- replyNeededOnly: detailBoolean(args.details, "replyNeededOnly") ??
1321
- args.llmPlan.replyNeededOnly ??
1322
- false,
1323
- };
1324
- for (const query of searchPlan.queries) {
1325
- const feed = await args.service.getGmailSearch(INTERNAL_URL, {
1326
- ...requestBase,
1327
- query,
1328
- });
1329
- if (feed.messages.length === 0) {
1330
- continue;
1331
- }
1332
- const displayFeed = feed.query === searchPlan.displayQuery
1333
- ? feed
1334
- : {
1335
- ...feed,
1336
- query: searchPlan.displayQuery,
1337
- };
1338
- if (feed.messages.length > 1) {
1339
- return {
1340
- kind: "ambiguous",
1341
- feed: displayFeed,
1342
- displayQuery: searchPlan.displayQuery,
1343
- };
1344
- }
1345
- const message = feed.messages[0];
1346
- return message
1347
- ? {
1348
- kind: "resolved",
1349
- target: {
1350
- messageId: message.id,
1351
- subject: message.subject,
1352
- from: message.from,
1353
- query: searchPlan.displayQuery,
1354
- },
1355
- }
1356
- : { kind: "missing" };
1357
- }
1358
- return { kind: "missing" };
1359
- }
1360
- function normalizeBatchSendItems(details) {
1361
- const items = detailArray(details, "items");
1362
- if (!items) {
1363
- return undefined;
1364
- }
1365
- const normalized = items
1366
- .map((item) => {
1367
- if (!item || typeof item !== "object" || Array.isArray(item)) {
1368
- return null;
1369
- }
1370
- const record = item;
1371
- const messageId = typeof record.messageId === "string" &&
1372
- record.messageId.trim().length > 0
1373
- ? record.messageId.trim()
1374
- : null;
1375
- const bodyText = typeof record.bodyText === "string" && record.bodyText.trim().length > 0
1376
- ? record.bodyText.trim()
1377
- : null;
1378
- if (!messageId || !bodyText) {
1379
- return null;
1380
- }
1381
- const normalized = {
1382
- messageId,
1383
- bodyText,
1384
- subject: typeof record.subject === "string" && record.subject.trim().length > 0
1385
- ? record.subject.trim()
1386
- : undefined,
1387
- to: normalizeStringArray(record.to),
1388
- cc: normalizeStringArray(record.cc),
1389
- };
1390
- return normalized;
1391
- })
1392
- .filter((item) => item !== null);
1393
- return normalized.length > 0 ? normalized : undefined;
1394
- }
1395
- export const gmailAction = {
1396
- name: ACTION_NAME,
1397
- similes: [
1398
- "GMAIL",
1399
- "CHECK_EMAIL",
1400
- "EMAIL_TRIAGE",
1401
- "UNREAD_EMAILS",
1402
- "EMAIL_UNREAD",
1403
- "SEARCH_EMAIL",
1404
- "DRAFT_EMAIL_REPLY",
1405
- "SEND_EMAIL_REPLY",
1406
- ],
1407
- description: "Gmail-only execution layer through LifeOps. This action touches Gmail and nothing else. " +
1408
- "USE this action ONLY when the request explicitly names Gmail or email " +
1409
- "(e.g. 'triage my Gmail', 'summarize my unread emails', 'search for emails from Sarah', " +
1410
- "'draft a reply to the latest email from finance', 'send the email'). " +
1411
- "Subactions: Gmail-specific triage, recommended actions, true unresponded threads, search by sender/subject/keyword/date/label, " +
1412
- "read message bodies by Gmail ID, draft reply, send reply, and Gmail management. " +
1413
- "DO NOT use for a cross-channel inbox digest / inbox-only daily digest / triage across " +
1414
- "Slack / Discord / SMS / Telegram — route owner inbox work to OWNER_INBOX and the agent's " +
1415
- "own mailbox to AGENT_INBOX. If the user says 'my inbox' without specifying Gmail (e.g. " +
1416
- "'give me my inbox digest', 'triage my inbox'), do not route straight to " +
1417
- "GMAIL_ACTION. GMAIL_ACTION is only correct once the mailbox surface is already narrowed to Gmail under OWNER_INBOX, " +
1418
- "or when the request is about a specific email by sender/subject/body. " +
1419
- "Do NOT use for morning briefs, night briefs, or broad day-start/day-end reviews that happen to mention email. " +
1420
- "DO NOT use for venting ('I hate email') unless the user asks for a concrete Gmail operation. " +
1421
- "DO NOT use for calendar, meetings, scheduling, habits, goals, routines, or reminders. " +
1422
- "Provides the final grounded reply; do not pair with a speculative REPLY.",
1423
- descriptionCompressed: "Gmail execution layer under OWNER_INBOX or AGENT_INBOX: triage, recommendations, unresponded threads, search, read, manage, and draft/send replies.",
1424
- suppressPostActionContinuation: true,
1425
- validate: async (runtime, message, state) => {
1426
- if (!(await hasLifeOpsAccess(runtime, message)))
1427
- return false;
1428
- return hasContextSignalForKey(runtime, message, state, "gmail", {
1429
- contextLimit: GMAIL_CONTEXT_WINDOW,
1430
- });
1431
- },
1432
- handler: async (runtime, message, state, options, callback) => {
1433
- if (!(await hasLifeOpsAccess(runtime, message))) {
1434
- const fallback = "Gmail actions are restricted to the owner, explicitly granted users, and the agent.";
1435
- return {
1436
- success: false,
1437
- text: await renderGmailActionReply({
1438
- runtime,
1439
- message,
1440
- state,
1441
- intent: messageText(message).trim(),
1442
- scenario: "access_denied",
1443
- fallback,
1444
- }),
1445
- };
1446
- }
1447
- const rawParams = options?.parameters;
1448
- const params = rawParams ?? {};
1449
- const details = normalizeGmailDetails(params.details);
1450
- const explicitSubaction = normalizeGmailSubaction(params.subaction);
1451
- const intent = normalizePlannerString(params.intent) ?? messageText(message).trim();
1452
- const activeComposeDraft = latestGmailComposeDraft(state, [
1453
- "pending_clarification",
1454
- ]);
1455
- const previousSentComposeDraft = latestGmailComposeDraft(state, ["sent"]);
1456
- const llmPlan = await extractGmailPlanWithLlm(runtime, message, state, intent, activeComposeDraft);
1457
- const pendingReplyApproval = await readPendingGmailReplyApproval(runtime, message.roomId);
1458
- const latestReplyDraft = latestGmailReplyDraftContext(state);
1459
- const latestMessageTarget = latestGmailMessageTargetContext(state);
1460
- const latestBatchReplyDraftItems = latestGmailBatchReplyDraftItems(state);
1461
- const sendConfirmed = normalizeOptionalBoolean(params.confirmed) ??
1462
- detailBoolean(details, "confirmSend") ??
1463
- llmPlan.confirmed ??
1464
- false;
1465
- const holdReplyForApproval = detailBoolean(details, "holdForApproval") ??
1466
- (detailBoolean(details, "confirmSend") === false ? true : undefined) ??
1467
- llmPlan.holdForApproval ??
1468
- false;
1469
- const hasStructuredComposeSignal = Boolean(params.bodyText ||
1470
- detailString(details, "bodyText") ||
1471
- detailString(details, "subject") ||
1472
- (normalizeStringArray(details?.to)?.length ?? 0) > 0 ||
1473
- (normalizeStringArray(details?.cc)?.length ?? 0) > 0 ||
1474
- (normalizeStringArray(details?.bcc)?.length ?? 0) > 0 ||
1475
- (llmPlan.to?.length ?? 0) > 0 ||
1476
- (llmPlan.cc?.length ?? 0) > 0 ||
1477
- (llmPlan.bcc?.length ?? 0) > 0 ||
1478
- Boolean(llmPlan.subject) ||
1479
- Boolean(llmPlan.bodyText));
1480
- const hasReplyOrBatchTarget = Boolean(params.messageId ||
1481
- detailString(details, "messageId") ||
1482
- detailArray(details, "items") ||
1483
- (normalizeStringArray(details?.messageIds)?.length ?? 0) > 0);
1484
- const shouldAttemptComposeRecovery = !hasReplyOrBatchTarget &&
1485
- (Boolean(activeComposeDraft || previousSentComposeDraft) ||
1486
- llmPlan.subaction === "send_message" ||
1487
- llmPlan.subaction === null ||
1488
- explicitSubaction === "send_message" ||
1489
- hasStructuredComposeSignal);
1490
- const composeRecoveryPlan = shouldAttemptComposeRecovery
1491
- ? await recoverSendMessagePlanWithLlm({
1492
- runtime,
1493
- message,
1494
- state,
1495
- intent,
1496
- currentPlan: llmPlan,
1497
- activeDraft: activeComposeDraft,
1498
- previousSentDraft: previousSentComposeDraft,
1499
- })
1500
- : null;
1501
- const composeRecoveryActivated = composeRecoveryPlan?.shouldResume === true;
1502
- const resolvedComposeDraft = mergeComposeDrafts(previousSentComposeDraft ?? undefined, activeComposeDraft ?? undefined, {
1503
- subaction: "send_message",
1504
- status: "pending_clarification",
1505
- intent,
1506
- to: llmPlan.to,
1507
- cc: llmPlan.cc,
1508
- bcc: llmPlan.bcc,
1509
- subject: llmPlan.subject,
1510
- bodyText: llmPlan.bodyText,
1511
- }, composeRecoveryPlan ?? undefined);
1512
- const explicitQueryArray = [
1513
- ...(params.queries ?? []),
1514
- ...(normalizeQueryStringArray(details?.queries) ?? []),
1515
- ];
1516
- const hasExplicitGmailExecutionInput = Boolean(explicitSubaction ||
1517
- params.query ||
1518
- explicitQueryArray.length > 0 ||
1519
- params.messageId ||
1520
- (params.messageIds?.length ?? 0) > 0 ||
1521
- params.operation ||
1522
- detailString(details, "messageId") ||
1523
- detailString(details, "operation") ||
1524
- (normalizeStringArray(details?.messageIds)?.length ?? 0) > 0 ||
1525
- params.bodyText ||
1526
- detailString(details, "bodyText") ||
1527
- (normalizeStringArray(details?.to)?.length ?? 0) > 0 ||
1528
- (normalizeStringArray(details?.cc)?.length ?? 0) > 0 ||
1529
- (normalizeStringArray(details?.bcc)?.length ?? 0) > 0 ||
1530
- detailString(details, "subject"));
1531
- let subaction = explicitSubaction ?? llmPlan.subaction;
1532
- const composeRecipients = normalizeStringArray(details?.to) ??
1533
- resolvedComposeDraft.to ??
1534
- llmPlan.to ??
1535
- [];
1536
- const hasComposeRecipients = composeRecipients.length > 0;
1537
- const hasComposeContent = Boolean(params.bodyText ||
1538
- detailString(details, "bodyText") ||
1539
- resolvedComposeDraft.bodyText ||
1540
- llmPlan.bodyText ||
1541
- detailString(details, "subject") ||
1542
- resolvedComposeDraft.subject ||
1543
- llmPlan.subject);
1544
- if (!explicitSubaction && composeRecoveryActivated) {
1545
- subaction = "send_message";
1546
- }
1547
- if (!subaction &&
1548
- !params.messageId &&
1549
- !detailString(details, "messageId") &&
1550
- !detailArray(details, "items") &&
1551
- (hasComposeRecipients || hasStructuredComposeSignal) &&
1552
- hasComposeContent) {
1553
- subaction = "send_message";
1554
- }
1555
- runtime.logger?.debug?.({
1556
- src: "action:gmail",
1557
- subaction,
1558
- rawMessage: messageText(message).slice(0, 200),
1559
- resolvedIntent: intent.slice(0, 200),
1560
- params: {
1561
- subaction: params.subaction,
1562
- query: params.query,
1563
- messageId: params.messageId,
1564
- bodyText: params.bodyText?.slice(0, 100),
1565
- },
1566
- detailKeys: details ? Object.keys(details) : [],
1567
- detailToType: typeof details?.to,
1568
- detailSubject: typeof details?.subject === "string" ? details.subject : undefined,
1569
- sendConfirmed,
1570
- holdReplyForApproval,
1571
- }, "gmail action dispatch");
1572
- const service = new LifeOpsService(runtime);
1573
- const respond = async (payload) => {
1574
- const data = attachGmailWorkflowPlanData({
1575
- data: payload.data,
1576
- plan: llmPlan,
1577
- executedSubaction: subaction,
1578
- success: payload.success,
1579
- });
1580
- await callback?.({
1581
- text: payload.text,
1582
- source: "action",
1583
- action: ACTION_NAME,
1584
- });
1585
- return {
1586
- ...payload,
1587
- ...(data ? { data } : {}),
1588
- };
1589
- };
1590
- const renderReply = (scenario, fallback, context) => renderGmailActionReply({
1591
- runtime,
1592
- message,
1593
- state,
1594
- intent,
1595
- scenario,
1596
- fallback,
1597
- context,
1598
- });
1599
- if (composeRecoveryPlan?.cancelled) {
1600
- return respond({
1601
- success: true,
1602
- text: await renderReply("cancel_send_message", composeRecoveryPlan.response ?? "Okay, I won't send that email.", {
1603
- composeRecoveryPlan,
1604
- activeComposeDraft,
1605
- }),
1606
- data: {
1607
- noop: true,
1608
- },
1609
- });
1610
- }
1611
- if (!subaction &&
1612
- !composeRecoveryActivated &&
1613
- !hasExplicitGmailExecutionInput) {
1614
- const fallback = composeRecoveryPlan?.response ??
1615
- llmPlan.response ??
1616
- buildGmailReplyOnlyFallback(llmPlan.subaction);
1617
- return respond({
1618
- success: true,
1619
- text: await renderReply("reply_only", fallback, {
1620
- llmPlan,
1621
- composeRecoveryPlan,
1622
- suggestedSubaction: llmPlan.subaction,
1623
- }),
1624
- data: {
1625
- noop: true,
1626
- ...(llmPlan.subaction
1627
- ? { suggestedSubaction: llmPlan.subaction }
1628
- : {}),
1629
- },
1630
- });
1631
- }
1632
- if (!subaction) {
1633
- const fallback = llmPlan.response ??
1634
- composeRecoveryPlan?.response ??
1635
- buildGmailReplyOnlyFallback(llmPlan.subaction);
1636
- return respond({
1637
- success: false,
1638
- text: await renderReply("clarify_gmail_request", fallback, {
1639
- llmPlan,
1640
- composeRecoveryPlan,
1641
- }),
1642
- data: {
1643
- noop: true,
1644
- },
1645
- });
1646
- }
1647
- try {
1648
- const google = await getGoogleCapabilityStatus(service);
1649
- if (subaction === "send_reply" ||
1650
- subaction === "send_batch_replies" ||
1651
- subaction === "send_message") {
1652
- if (!google.hasGmailSend) {
1653
- return respond({
1654
- success: false,
1655
- text: await renderReply("gmail_send_unavailable", gmailSendUnavailableMessage(google), {
1656
- subaction,
1657
- google,
1658
- }),
1659
- });
1660
- }
1661
- }
1662
- else if (subaction === "manage") {
1663
- if (!google.hasGmailManage) {
1664
- return respond({
1665
- success: false,
1666
- text: await renderReply("gmail_manage_unavailable", "Gmail manage access is not connected. Reconnect Google in LifeOps settings and grant Gmail manage access.", {
1667
- subaction,
1668
- google,
1669
- }),
1670
- });
1671
- }
1672
- }
1673
- else if (!google.hasGmailTriage) {
1674
- return respond({
1675
- success: false,
1676
- text: await renderReply("gmail_read_unavailable", gmailReadUnavailableMessage(google), {
1677
- subaction,
1678
- google,
1679
- }),
1680
- });
1681
- }
1682
- if (subaction === "triage") {
1683
- const feed = await service.getGmailTriage(INTERNAL_URL, {
1684
- mode: detailString(details, "mode"),
1685
- side: detailString(details, "side"),
1686
- grantId: detailString(details, "grantId"),
1687
- forceSync: detailBoolean(details, "forceSync"),
1688
- maxResults: detailNumber(details, "maxResults") ?? 10,
1689
- });
1690
- const fallback = formatEmailTriage(feed);
1691
- return respond({
1692
- success: true,
1693
- text: await renderReply("triage_results", fallback, {
1694
- summary: feed.summary,
1695
- messages: feed.messages,
1696
- }),
1697
- data: toActionData(feed),
1698
- });
1699
- }
1700
- if (subaction === "needs_response") {
1701
- const feed = await service.getGmailNeedsResponse(INTERNAL_URL, {
1702
- mode: detailString(details, "mode"),
1703
- side: detailString(details, "side"),
1704
- grantId: detailString(details, "grantId"),
1705
- forceSync: detailBoolean(details, "forceSync"),
1706
- maxResults: detailNumber(details, "maxResults") ?? 10,
1707
- });
1708
- const fallback = formatEmailNeedsResponse(feed);
1709
- return respond({
1710
- success: true,
1711
- text: await renderReply("needs_response_results", fallback, {
1712
- summary: feed.summary,
1713
- messages: feed.messages,
1714
- }),
1715
- data: toActionData(feed),
1716
- });
1717
- }
1718
- if (subaction === "recommend") {
1719
- const resolvedQueries = resolveGmailSearchQueries([...explicitQueryArray, params.query, detailString(details, "query")], llmPlan);
1720
- const feed = await service.getGmailRecommendations(INTERNAL_URL, {
1721
- mode: detailString(details, "mode"),
1722
- side: detailString(details, "side"),
1723
- grantId: detailString(details, "grantId"),
1724
- forceSync: detailBoolean(details, "forceSync"),
1725
- maxResults: detailNumber(details, "maxResults") ?? 20,
1726
- query: resolvedQueries[0],
1727
- replyNeededOnly: detailBoolean(details, "replyNeededOnly") ??
1728
- llmPlan.replyNeededOnly,
1729
- includeSpamTrash: detailBoolean(details, "includeSpamTrash"),
1730
- });
1731
- const fallback = formatGmailRecommendations(feed);
1732
- return respond({
1733
- success: true,
1734
- text: await renderReply("recommendations_results", fallback, {
1735
- summary: feed.summary,
1736
- recommendations: feed.recommendations,
1737
- }),
1738
- data: toActionData(feed),
1739
- });
1740
- }
1741
- if (subaction === "unresponded") {
1742
- const feed = await service.getGmailUnresponded(INTERNAL_URL, {
1743
- mode: detailString(details, "mode"),
1744
- side: detailString(details, "side"),
1745
- grantId: detailString(details, "grantId"),
1746
- maxResults: detailNumber(details, "maxResults") ?? 10,
1747
- olderThanDays: detailNumber(details, "olderThanDays") ?? llmPlan.olderThanDays,
1748
- });
1749
- const fallback = feed.threads.length === 0
1750
- ? "No unresponded Gmail threads matched that window."
1751
- : feed.threads
1752
- .slice(0, 5)
1753
- .map((thread, index) => `${index + 1}. ${thread.subject} (${thread.daysWaiting}d waiting)`)
1754
- .join("\n");
1755
- return respond({
1756
- success: true,
1757
- text: await renderReply("unresponded_results", fallback, {
1758
- summary: feed.summary,
1759
- threads: feed.threads,
1760
- }),
1761
- data: toActionData(feed),
1762
- });
1763
- }
1764
- if (subaction === "search") {
1765
- const resolvedQueries = resolveGmailSearchQueries([...explicitQueryArray, params.query, detailString(details, "query")], llmPlan);
1766
- const searchPlan = buildGmailSearchPlan({
1767
- queries: resolvedQueries,
1768
- });
1769
- if (!searchPlan) {
1770
- return respond({
1771
- success: false,
1772
- text: await renderReply("clarify_search_target", "I need a sender, subject, keyword, or email search target to run that Gmail search.", {
1773
- missing: ["search target"],
1774
- }),
1775
- });
1776
- }
1777
- const requestBase = {
1778
- mode: detailString(details, "mode"),
1779
- side: detailString(details, "side"),
1780
- grantId: detailString(details, "grantId"),
1781
- forceSync: detailBoolean(details, "forceSync"),
1782
- maxResults: detailNumber(details, "maxResults") ?? 10,
1783
- replyNeededOnly: detailBoolean(details, "replyNeededOnly") ??
1784
- llmPlan.replyNeededOnly ??
1785
- false,
1786
- };
1787
- let feed = await service.getGmailSearch(INTERNAL_URL, {
1788
- ...requestBase,
1789
- query: searchPlan.queries[0] ?? searchPlan.displayQuery,
1790
- });
1791
- for (const query of searchPlan.queries.slice(1)) {
1792
- if (feed.messages.length > 0) {
1793
- break;
1794
- }
1795
- feed = await service.getGmailSearch(INTERNAL_URL, {
1796
- ...requestBase,
1797
- query,
1798
- });
1799
- }
1800
- const displayFeed = feed.query === searchPlan.displayQuery
1801
- ? feed
1802
- : {
1803
- ...feed,
1804
- query: searchPlan.displayQuery,
1805
- };
1806
- const fallback = formatEmailSearch(displayFeed);
1807
- return respond({
1808
- success: true,
1809
- text: await renderReply("search_results", fallback, {
1810
- query: displayFeed.query,
1811
- messages: displayFeed.messages,
1812
- }),
1813
- data: toActionData(displayFeed),
1814
- });
1815
- }
1816
- if (subaction === "read") {
1817
- const messageId = params.messageId ??
1818
- detailString(details, "messageId") ??
1819
- llmPlan.messageId ??
1820
- latestMessageTarget?.messageId ??
1821
- latestReplyDraft?.messageId;
1822
- if (messageId) {
1823
- const result = await service.readGmailMessage(INTERNAL_URL, {
1824
- mode: detailString(details, "mode"),
1825
- side: detailString(details, "side"),
1826
- grantId: detailString(details, "grantId"),
1827
- forceSync: detailBoolean(details, "forceSync"),
1828
- messageId,
1829
- });
1830
- const fallback = formatEmailRead(result);
1831
- return respond({
1832
- success: true,
1833
- text: await renderReply("read_result", fallback, {
1834
- message: result,
1835
- }),
1836
- data: toActionData(result),
1837
- });
1838
- }
1839
- const resolvedTarget = await resolveGmailTargetMessage({
1840
- service,
1841
- details,
1842
- explicitQueryArray,
1843
- paramsQuery: params.query,
1844
- llmPlan,
1845
- });
1846
- if (resolvedTarget.kind === "missing") {
1847
- return respond({
1848
- success: false,
1849
- text: await renderReply("clarify_read_target", "I need to know which email to read. Give me a sender, subject, keyword, or specific message id.", {
1850
- missing: ["message target"],
1851
- }),
1852
- });
1853
- }
1854
- if (resolvedTarget.kind === "ambiguous") {
1855
- const fallback = buildGmailTargetDisambiguationFallback(resolvedTarget.feed);
1856
- return respond({
1857
- success: false,
1858
- text: await renderReply("clarify_read_target", fallback, {
1859
- query: resolvedTarget.displayQuery,
1860
- messages: resolvedTarget.feed.messages,
1861
- }),
1862
- });
1863
- }
1864
- const result = await service.readGmailMessage(INTERNAL_URL, {
1865
- mode: detailString(details, "mode"),
1866
- side: detailString(details, "side"),
1867
- grantId: detailString(details, "grantId"),
1868
- forceSync: detailBoolean(details, "forceSync"),
1869
- messageId: resolvedTarget.target.messageId,
1870
- });
1871
- const displayResult = {
1872
- ...result,
1873
- query: resolvedTarget.target.query ?? result.query,
1874
- };
1875
- const fallback = formatEmailRead(displayResult);
1876
- return respond({
1877
- success: true,
1878
- text: await renderReply("read_result", fallback, {
1879
- message: displayResult,
1880
- }),
1881
- data: toActionData(displayResult),
1882
- });
1883
- }
1884
- if (subaction === "draft_reply") {
1885
- let messageId = params.messageId ??
1886
- detailString(details, "messageId") ??
1887
- llmPlan.messageId ??
1888
- latestMessageTarget?.messageId ??
1889
- latestReplyDraft?.messageId;
1890
- if (!messageId) {
1891
- const resolvedTarget = await resolveGmailTargetMessage({
1892
- service,
1893
- details,
1894
- explicitQueryArray,
1895
- paramsQuery: params.query,
1896
- llmPlan,
1897
- });
1898
- if (resolvedTarget.kind === "ambiguous") {
1899
- const fallback = buildGmailTargetDisambiguationFallback(resolvedTarget.feed);
1900
- return respond({
1901
- success: false,
1902
- text: await renderReply("clarify_draft_reply_target", fallback, {
1903
- query: resolvedTarget.displayQuery,
1904
- messages: resolvedTarget.feed.messages,
1905
- }),
1906
- });
1907
- }
1908
- messageId =
1909
- resolvedTarget.kind === "resolved"
1910
- ? resolvedTarget.target.messageId
1911
- : undefined;
1912
- if (!messageId) {
1913
- return respond({
1914
- success: false,
1915
- text: await renderReply("clarify_draft_reply_target", "Which email do you want me to draft a reply for?", {
1916
- missing: ["message target"],
1917
- latestMessageTarget,
1918
- latestReplyDraft,
1919
- }),
1920
- });
1921
- }
1922
- }
1923
- const draftGenerationContext = await buildGmailDraftGenerationContext({
1924
- runtime,
1925
- message,
1926
- state,
1927
- });
1928
- const draft = await service.createGmailReplyDraft(INTERNAL_URL, {
1929
- mode: detailString(details, "mode"),
1930
- side: detailString(details, "side"),
1931
- grantId: detailString(details, "grantId"),
1932
- messageId,
1933
- tone: detailString(details, "tone"),
1934
- intent: detailString(details, "draftIntent") ??
1935
- detailString(details, "intent") ??
1936
- intent,
1937
- includeQuotedOriginal: detailBoolean(details, "includeQuotedOriginal"),
1938
- ...draftGenerationContext,
1939
- });
1940
- const fallback = formatGmailReplyDraft(draft);
1941
- if (holdReplyForApproval) {
1942
- if (pendingReplyApproval?.approvalTaskId) {
1943
- await runtime.deleteTask(pendingReplyApproval.approvalTaskId);
1944
- }
1945
- const approvalTaskId = await enqueueGmailReplyApprovalRequest({
1946
- runtime,
1947
- message,
1948
- draft,
1949
- });
1950
- await writePendingGmailReplyApproval(runtime, message.roomId, {
1951
- messageId: draft.messageId,
1952
- bodyText: draft.bodyText,
1953
- subject: draft.subject,
1954
- to: draft.to,
1955
- cc: draft.cc,
1956
- approvalTaskId,
1957
- createdAt: new Date().toISOString(),
1958
- });
1959
- return respond({
1960
- success: true,
1961
- text: await renderReply("draft_reply", `${fallback}\n\nI'll hold this Gmail reply until you approve sending it.`, {
1962
- draft,
1963
- approvalRequired: true,
1964
- }),
1965
- data: toActionData({
1966
- ...draft,
1967
- gmailDraft: draft,
1968
- pendingApproval: true,
1969
- }),
1970
- });
1971
- }
1972
- if (pendingReplyApproval?.approvalTaskId) {
1973
- await runtime.deleteTask(pendingReplyApproval.approvalTaskId);
1974
- await clearPendingGmailReplyApproval(runtime, message.roomId);
1975
- }
1976
- return respond({
1977
- success: true,
1978
- text: await renderReply("draft_reply", fallback, {
1979
- draft,
1980
- }),
1981
- data: toActionData({
1982
- ...draft,
1983
- gmailDraft: draft,
1984
- gmailMessage: {
1985
- messageId: draft.messageId,
1986
- subject: draft.subject,
1987
- query: latestMessageTarget?.query,
1988
- },
1989
- }),
1990
- });
1991
- }
1992
- if (subaction === "draft_batch_replies") {
1993
- const batchSearchQueries = (normalizeStringArray(details?.messageIds)?.length ?? 0)
1994
- ? []
1995
- : resolveGmailSearchQueries([
1996
- ...explicitQueryArray,
1997
- params.query,
1998
- detailString(details, "query"),
1999
- ], llmPlan);
2000
- const draftGenerationContext = await buildGmailDraftGenerationContext({
2001
- runtime,
2002
- message,
2003
- state,
2004
- });
2005
- const request = {
2006
- mode: detailString(details, "mode"),
2007
- side: detailString(details, "side"),
2008
- grantId: detailString(details, "grantId"),
2009
- forceSync: detailBoolean(details, "forceSync"),
2010
- maxResults: detailNumber(details, "maxResults") ?? 10,
2011
- query: batchSearchQueries[0],
2012
- messageIds: normalizeStringArray(details?.messageIds),
2013
- tone: detailString(details, "tone"),
2014
- intent: detailString(details, "draftIntent") ??
2015
- detailString(details, "intent") ??
2016
- intent,
2017
- includeQuotedOriginal: detailBoolean(details, "includeQuotedOriginal"),
2018
- replyNeededOnly: detailBoolean(details, "replyNeededOnly") ??
2019
- llmPlan.replyNeededOnly ??
2020
- false,
2021
- ...draftGenerationContext,
2022
- };
2023
- const batch = await service.createGmailBatchReplyDrafts(INTERNAL_URL, request);
2024
- const fallback = formatGmailBatchReplyDrafts(batch);
2025
- return respond({
2026
- success: true,
2027
- text: await renderReply("draft_batch_replies", fallback, {
2028
- batch,
2029
- }),
2030
- data: toActionData(batch),
2031
- });
2032
- }
2033
- if (subaction === "manage") {
2034
- const operation = params.operation ??
2035
- normalizePlannerGmailOperation(detailString(details, "operation")) ??
2036
- llmPlan.operation;
2037
- const messageIds = params.messageIds ??
2038
- normalizeStringArray(details?.messageIds) ??
2039
- llmPlan.messageIds ??
2040
- [
2041
- detailString(details, "messageId") ??
2042
- llmPlan.messageId ??
2043
- latestMessageTarget?.messageId,
2044
- ].filter((value) => Boolean(value));
2045
- const query = detailString(details, "query") ??
2046
- params.query ??
2047
- llmPlan.queries[0] ??
2048
- latestMessageTarget?.query;
2049
- if (!operation) {
2050
- return respond({
2051
- success: false,
2052
- text: await renderReply("clarify_manage_operation", "Which Gmail operation should I run: archive, trash, spam, mark read, mark unread, apply label, or remove label?", {
2053
- missing: ["operation"],
2054
- }),
2055
- });
2056
- }
2057
- if (messageIds.length === 0 && !query) {
2058
- return respond({
2059
- success: false,
2060
- text: await renderReply("clarify_manage_target", "Which Gmail messages should I update?", {
2061
- missing: ["message target"],
2062
- latestMessageTarget,
2063
- }),
2064
- });
2065
- }
2066
- const destructive = operation === "trash" ||
2067
- operation === "delete" ||
2068
- operation === "report_spam";
2069
- const confirmDestructive = detailBoolean(details, "confirmDestructive") ??
2070
- llmPlan.confirmDestructive ??
2071
- false;
2072
- if (destructive && !confirmDestructive) {
2073
- return respond({
2074
- success: false,
2075
- text: await renderReply("confirm_manage_destructive", `Confirm before I ${operation.replace("_", " ")} Gmail messages.`, {
2076
- operation,
2077
- messageIds,
2078
- query,
2079
- }),
2080
- data: {
2081
- gmailManageRequest: {
2082
- operation,
2083
- messageIds,
2084
- query,
2085
- confirmDestructive: false,
2086
- },
2087
- noop: true,
2088
- },
2089
- });
2090
- }
2091
- const result = await service.manageGmailMessages(INTERNAL_URL, {
2092
- mode: detailString(details, "mode"),
2093
- side: detailString(details, "side"),
2094
- grantId: detailString(details, "grantId"),
2095
- operation,
2096
- messageIds: messageIds.length > 0 ? messageIds : undefined,
2097
- query: messageIds.length === 0 ? query : undefined,
2098
- maxResults: detailNumber(details, "maxResults") ?? 10,
2099
- labelIds: normalizeStringArray(details?.labelIds) ?? llmPlan.labelIds,
2100
- confirmDestructive,
2101
- });
2102
- const fallback = `Updated ${result.affectedCount} Gmail message${result.affectedCount === 1 ? "" : "s"}.`;
2103
- return respond({
2104
- success: true,
2105
- text: await renderReply("managed_messages", fallback, {
2106
- result,
2107
- }),
2108
- data: toActionData(result),
2109
- });
2110
- }
2111
- if (subaction === "send_reply") {
2112
- let messageId = params.messageId ??
2113
- detailString(details, "messageId") ??
2114
- llmPlan.messageId ??
2115
- pendingReplyApproval?.messageId ??
2116
- latestReplyDraft?.messageId ??
2117
- latestMessageTarget?.messageId;
2118
- if (!messageId) {
2119
- const resolvedTarget = await resolveGmailTargetMessage({
2120
- service,
2121
- details,
2122
- explicitQueryArray,
2123
- paramsQuery: params.query,
2124
- llmPlan,
2125
- });
2126
- if (resolvedTarget.kind === "ambiguous") {
2127
- const fallback = buildGmailTargetDisambiguationFallback(resolvedTarget.feed);
2128
- return respond({
2129
- success: false,
2130
- text: await renderReply("clarify_send_reply", fallback, {
2131
- query: resolvedTarget.displayQuery,
2132
- messages: resolvedTarget.feed.messages,
2133
- }),
2134
- });
2135
- }
2136
- messageId =
2137
- resolvedTarget.kind === "resolved"
2138
- ? resolvedTarget.target.messageId
2139
- : undefined;
2140
- }
2141
- const bodyText = params.bodyText ??
2142
- detailString(details, "bodyText") ??
2143
- pendingReplyApproval?.bodyText ??
2144
- latestReplyDraft?.bodyText;
2145
- if (pendingReplyApproval && !sendConfirmed) {
2146
- return respond({
2147
- success: true,
2148
- text: await renderReply("clarify_send_reply", "The Gmail reply draft is ready. Confirm when you want me to send it.", {
2149
- latestReplyDraft: pendingReplyApproval,
2150
- }),
2151
- data: toActionData({
2152
- gmailDraft: {
2153
- messageId: pendingReplyApproval.messageId,
2154
- bodyText: pendingReplyApproval.bodyText,
2155
- subject: pendingReplyApproval.subject,
2156
- to: pendingReplyApproval.to,
2157
- cc: pendingReplyApproval.cc,
2158
- },
2159
- pendingApproval: true,
2160
- }),
2161
- });
2162
- }
2163
- if (!messageId || !bodyText) {
2164
- return respond({
2165
- success: false,
2166
- text: await renderReply("clarify_send_reply", "I need both the email you're replying to and the reply text before I can send it.", {
2167
- missing: [
2168
- ...(!messageId ? ["messageId"] : []),
2169
- ...(!bodyText ? ["bodyText"] : []),
2170
- ],
2171
- latestReplyDraft,
2172
- latestMessageTarget,
2173
- }),
2174
- });
2175
- }
2176
- if (!sendConfirmed) {
2177
- return respond({
2178
- success: false,
2179
- text: await renderReply("confirm_send_reply", "Confirm before I send this Gmail reply.", {
2180
- messageId,
2181
- bodyText,
2182
- latestReplyDraft,
2183
- latestMessageTarget,
2184
- }),
2185
- data: {
2186
- gmailDraft: {
2187
- messageId,
2188
- bodyText,
2189
- subject: detailString(details, "subject") ?? latestReplyDraft?.subject,
2190
- to: normalizeStringArray(details?.to) ?? latestReplyDraft?.to,
2191
- cc: normalizeStringArray(details?.cc) ?? latestReplyDraft?.cc,
2192
- },
2193
- requiresConfirmation: true,
2194
- noop: true,
2195
- },
2196
- });
2197
- }
2198
- const result = await service.sendGmailReply(INTERNAL_URL, {
2199
- mode: detailString(details, "mode"),
2200
- side: detailString(details, "side"),
2201
- grantId: detailString(details, "grantId"),
2202
- messageId,
2203
- bodyText,
2204
- subject: detailString(details, "subject") ??
2205
- pendingReplyApproval?.subject ??
2206
- latestReplyDraft?.subject,
2207
- to: normalizeStringArray(details?.to) ??
2208
- pendingReplyApproval?.to ??
2209
- latestReplyDraft?.to,
2210
- cc: normalizeStringArray(details?.cc) ??
2211
- pendingReplyApproval?.cc ??
2212
- latestReplyDraft?.cc,
2213
- confirmSend: sendConfirmed,
2214
- });
2215
- if (pendingReplyApproval?.approvalTaskId) {
2216
- await runtime.deleteTask(pendingReplyApproval.approvalTaskId);
2217
- }
2218
- await clearPendingGmailReplyApproval(runtime, message.roomId);
2219
- const fallback = "Gmail reply sent.";
2220
- return respond({
2221
- success: true,
2222
- text: await renderReply("sent_reply", fallback, {
2223
- result,
2224
- messageId,
2225
- }),
2226
- data: toActionData(result),
2227
- });
2228
- }
2229
- if (subaction === "send_message") {
2230
- const to = normalizeStringArray(details?.to) ??
2231
- resolvedComposeDraft.to ??
2232
- llmPlan.to ??
2233
- [];
2234
- const cc = normalizeStringArray(details?.cc) ?? resolvedComposeDraft.cc;
2235
- const bcc = normalizeStringArray(details?.bcc) ?? resolvedComposeDraft.bcc;
2236
- const subject = detailString(details, "subject") ?? resolvedComposeDraft.subject;
2237
- const bodyText = params.bodyText ??
2238
- detailString(details, "bodyText") ??
2239
- resolvedComposeDraft.bodyText;
2240
- const composeDraft = buildGmailComposeDraft({
2241
- status: "pending_clarification",
2242
- intent,
2243
- to,
2244
- cc,
2245
- bcc,
2246
- subject,
2247
- bodyText,
2248
- });
2249
- if (to.length === 0 || !subject || !bodyText) {
2250
- const missing = [];
2251
- if (to.length === 0)
2252
- missing.push("recipient address");
2253
- if (!subject)
2254
- missing.push("subject");
2255
- if (!bodyText)
2256
- missing.push("body text");
2257
- const fallback = `I need ${missing.join(", ")} to compose that email.`;
2258
- return respond({
2259
- success: false,
2260
- text: await renderReply("clarify_send_message", fallback, {
2261
- composeDraft,
2262
- missing,
2263
- }),
2264
- data: {
2265
- gmailDraft: composeDraft,
2266
- missing,
2267
- noop: true,
2268
- },
2269
- });
2270
- }
2271
- if (!sendConfirmed) {
2272
- return respond({
2273
- success: false,
2274
- text: await renderReply("confirm_send_message", `Draft ready for ${to.join(", ")}. Confirm before I send it.`, {
2275
- to,
2276
- cc,
2277
- bcc,
2278
- subject,
2279
- bodyText,
2280
- }),
2281
- data: {
2282
- gmailDraft: composeDraft,
2283
- requiresConfirmation: true,
2284
- noop: true,
2285
- },
2286
- });
2287
- }
2288
- const result = await service.sendGmailMessage(INTERNAL_URL, {
2289
- mode: detailString(details, "mode"),
2290
- side: detailString(details, "side"),
2291
- grantId: detailString(details, "grantId"),
2292
- to,
2293
- cc,
2294
- bcc,
2295
- subject,
2296
- bodyText,
2297
- confirmSend: sendConfirmed,
2298
- });
2299
- const fallback = `sent to ${to.join(", ")}.`;
2300
- return respond({
2301
- success: true,
2302
- text: await renderReply("sent_message", fallback, {
2303
- result,
2304
- to,
2305
- subject,
2306
- }),
2307
- data: toActionData({
2308
- ...result,
2309
- gmailDraft: buildGmailComposeDraft({
2310
- status: "sent",
2311
- intent,
2312
- to,
2313
- cc,
2314
- bcc,
2315
- subject,
2316
- bodyText,
2317
- }),
2318
- }),
2319
- });
2320
- }
2321
- const items = normalizeBatchSendItems(details) ?? latestBatchReplyDraftItems;
2322
- if (!items) {
2323
- return respond({
2324
- success: false,
2325
- text: await renderReply("clarify_send_batch_replies", "I need the list of replies to send, with each email and its reply text.", {
2326
- missing: ["items"],
2327
- latestBatchReplyDraftItems,
2328
- }),
2329
- });
2330
- }
2331
- if (!sendConfirmed) {
2332
- return respond({
2333
- success: false,
2334
- text: await renderReply("confirm_send_batch_replies", `Confirm before I send ${items.length} Gmail repl${items.length === 1 ? "y" : "ies"}.`, {
2335
- items,
2336
- }),
2337
- data: {
2338
- items,
2339
- requiresConfirmation: true,
2340
- noop: true,
2341
- },
2342
- });
2343
- }
2344
- const result = await service.sendGmailReplies(INTERNAL_URL, {
2345
- mode: detailString(details, "mode"),
2346
- side: detailString(details, "side"),
2347
- grantId: detailString(details, "grantId"),
2348
- confirmSend: sendConfirmed,
2349
- items,
2350
- });
2351
- const fallback = `Sent ${result.sentCount} Gmail repl${result.sentCount === 1 ? "y" : "ies"}.`;
2352
- return respond({
2353
- success: true,
2354
- text: await renderReply("sent_batch_replies", fallback, {
2355
- result,
2356
- }),
2357
- data: toActionData(result),
2358
- });
2359
- }
2360
- catch (error) {
2361
- if (error instanceof LifeOpsServiceError) {
2362
- const fallback = buildGmailServiceErrorFallback(error);
2363
- return respond({
2364
- success: false,
2365
- text: await renderReply("service_error", fallback, {
2366
- status: error.status,
2367
- subaction,
2368
- }),
2369
- });
2370
- }
2371
- throw error;
2372
- }
2373
- },
2374
- parameters: [
2375
- {
2376
- name: "subaction",
2377
- description: "Gmail operation to run. Use triage, needs_response, recommend, search, read, draft_reply, draft_batch_replies, manage, send_reply, send_batch_replies, or send_message (compose a brand-new outbound email).",
2378
- required: false,
2379
- schema: {
2380
- type: "string",
2381
- enum: [
2382
- "triage",
2383
- "needs_response",
2384
- "recommend",
2385
- "unresponded",
2386
- "search",
2387
- "read",
2388
- "draft_reply",
2389
- "draft_batch_replies",
2390
- "manage",
2391
- "send_reply",
2392
- "send_batch_replies",
2393
- "send_message",
2394
- ],
2395
- },
2396
- },
2397
- {
2398
- name: "intent",
2399
- description: 'Natural language Gmail request. Examples: "what emails need a reply", "search email for investor", "read the latest email from suran", "draft a reply to message 123".',
2400
- required: false,
2401
- schema: { type: "string" },
2402
- },
2403
- {
2404
- name: "query",
2405
- description: "Search query for Gmail search or batch draft selection. Use Gmail-style query fragments when helpful, such as from:suran, is:unread, newer_than:21d, subject:venue.",
2406
- required: false,
2407
- schema: { type: "string" },
2408
- },
2409
- {
2410
- name: "queries",
2411
- description: "Optional array of Gmail search queries to try in order when the planner has multiple good variants.",
2412
- required: false,
2413
- schema: { type: "array", items: { type: "string" } },
2414
- },
2415
- {
2416
- name: "messageId",
2417
- description: "Single Gmail message id for read, draft_reply, or send_reply operations.",
2418
- required: false,
2419
- schema: { type: "string" },
2420
- },
2421
- {
2422
- name: "bodyText",
2423
- description: "Reply body for send_reply.",
2424
- required: false,
2425
- schema: { type: "string" },
2426
- },
2427
- {
2428
- name: "confirmed",
2429
- description: "Set true only when the owner is explicitly approving a pending Gmail send right now.",
2430
- required: false,
2431
- schema: { type: "boolean" },
2432
- },
2433
- {
2434
- name: "details",
2435
- description: "Structured Gmail arguments. Supported keys include mode, side, grantId, forceSync, maxResults, query, queries, replyNeededOnly, olderThanDays, operation, labelIds, confirmDestructive, tone, includeQuotedOriginal, messageId, messageIds, draftIntent, subject, to, cc, bodyText, confirmSend, holdForApproval, and items for batch send.",
2436
- required: false,
2437
- schema: { type: "object" },
2438
- },
2439
- ],
2440
- examples: [
2441
- [
2442
- {
2443
- name: "{{name1}}",
2444
- content: { text: "Triage my Gmail inbox." },
2445
- },
2446
- {
2447
- name: "{{agentName}}",
2448
- content: {
2449
- text: "Inbox triage: 6 unread, 2 important, 3 likely needing a reply.",
2450
- },
2451
- },
2452
- ],
2453
- [
2454
- {
2455
- name: "{{name1}}",
2456
- content: { text: "Summarize my unread emails." },
2457
- },
2458
- {
2459
- name: "{{agentName}}",
2460
- content: {
2461
- text: "Unread emails: 6. Top items: investor follow-up from Jane Doe, contract update from Legal.",
2462
- },
2463
- },
2464
- ],
2465
- [
2466
- {
2467
- name: "{{name1}}",
2468
- content: { text: "Do I have any emails I need to reply to?" },
2469
- },
2470
- {
2471
- name: "{{agentName}}",
2472
- content: {
2473
- text: "Emails that likely need a reply: 3.\n- **Investor follow-up** from Jane Doe · 2h ago",
2474
- },
2475
- },
2476
- ],
2477
- [
2478
- {
2479
- name: "{{name1}}",
2480
- content: { text: "Search my email for OneBlade receipts." },
2481
- },
2482
- {
2483
- name: "{{agentName}}",
2484
- content: { text: 'Found 2 emails for "OneBlade receipts".' },
2485
- },
2486
- ],
2487
- [
2488
- {
2489
- name: "{{name1}}",
2490
- content: { text: "Read the latest email from Suran." },
2491
- },
2492
- {
2493
- name: "{{agentName}}",
2494
- content: {
2495
- text: "**Suran follow-up** from Suran Lee · 2d ago\n\nWanted to follow up on the last few weeks.",
2496
- },
2497
- },
2498
- ],
2499
- [
2500
- {
2501
- name: "{{name1}}",
2502
- content: {
2503
- text: "Draft a reply to the latest email from Sarah saying I'll review it tomorrow.",
2504
- },
2505
- },
2506
- {
2507
- name: "{{agentName}}",
2508
- content: {
2509
- text: "Drafted reply to Sarah saying you will review it tomorrow.",
2510
- },
2511
- },
2512
- ],
2513
- [
2514
- {
2515
- name: "{{name1}}",
2516
- content: {
2517
- text: "Draft a reply to message abc123 thanking them and saying next week works.",
2518
- },
2519
- },
2520
- {
2521
- name: "{{agentName}}",
2522
- content: { text: "Drafted reply for **Re: Scheduling**." },
2523
- },
2524
- ],
2525
- [
2526
- {
2527
- name: "{{name1}}",
2528
- content: {
2529
- text: "Send a reply to the last email from finance confirming receipt.",
2530
- },
2531
- },
2532
- {
2533
- name: "{{agentName}}",
2534
- content: {
2535
- text: "Sent the confirmed reply to the latest email from finance.",
2536
- },
2537
- },
2538
- ],
2539
- ],
2540
- };