@elizaos/agent 2.0.0-alpha.173 → 2.0.0-alpha.192
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/app-companion/src/actions/emote.d.ts.map +1 -1
- package/apps/app-companion/src/actions/emote.js +1 -0
- package/apps/app-elizamaker/src/drop-routes.d.ts +22 -0
- package/apps/app-elizamaker/src/drop-routes.d.ts.map +1 -0
- package/apps/app-elizamaker/src/drop-service.d.ts +26 -0
- package/apps/app-elizamaker/src/drop-service.d.ts.map +1 -0
- package/apps/app-elizamaker/src/index.d.ts +8 -0
- package/apps/app-elizamaker/src/index.d.ts.map +1 -0
- package/apps/app-elizamaker/src/index.js +5 -0
- package/apps/app-elizamaker/src/merkle-tree.d.ts.map +1 -0
- package/apps/app-elizamaker/src/og-tracker.d.ts.map +1 -0
- package/apps/app-elizamaker/src/og-tracker.js +60 -0
- package/apps/app-elizamaker/src/twitter-verify.d.ts +25 -0
- package/apps/app-elizamaker/src/twitter-verify.d.ts.map +1 -0
- package/apps/app-elizamaker/src/twitter-verify.js +168 -0
- package/apps/app-lifeops/src/actions/activity-report.d.ts +13 -0
- package/apps/app-lifeops/src/actions/activity-report.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/activity-report.js +287 -0
- package/apps/app-lifeops/src/actions/app-blocker.d.ts +5 -0
- package/apps/app-lifeops/src/actions/app-blocker.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/app-blocker.js +446 -0
- package/apps/app-lifeops/src/actions/autofill.d.ts +35 -0
- package/apps/app-lifeops/src/actions/autofill.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/autofill.js +340 -0
- package/apps/app-lifeops/src/actions/browser-extension.d.ts +19 -0
- package/apps/app-lifeops/src/actions/browser-extension.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/browser-extension.js +88 -0
- package/apps/app-lifeops/src/actions/calendar.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/calendar.js +405 -973
- package/apps/app-lifeops/src/actions/calendly.d.ts +3 -0
- package/apps/app-lifeops/src/actions/calendly.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/calendly.js +242 -0
- package/apps/app-lifeops/src/actions/checkin.d.ts +4 -0
- package/apps/app-lifeops/src/actions/checkin.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/checkin.js +72 -0
- package/apps/app-lifeops/src/actions/computer-use.d.ts +14 -0
- package/apps/app-lifeops/src/actions/computer-use.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/computer-use.js +149 -0
- package/apps/app-lifeops/src/actions/cross-channel-send.d.ts +22 -0
- package/apps/app-lifeops/src/actions/cross-channel-send.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/cross-channel-send.js +562 -0
- package/apps/app-lifeops/src/actions/device-bus.d.ts +19 -0
- package/apps/app-lifeops/src/actions/device-bus.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/device-bus.js +233 -0
- package/apps/app-lifeops/src/actions/dossier.d.ts +5 -0
- package/apps/app-lifeops/src/actions/dossier.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/dossier.js +195 -0
- package/apps/app-lifeops/src/actions/gmail.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/gmail.js +73 -37
- package/apps/app-lifeops/src/actions/health.d.ts +9 -0
- package/apps/app-lifeops/src/actions/health.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/health.js +357 -0
- package/apps/app-lifeops/src/actions/inbox.d.ts +3 -1
- package/apps/app-lifeops/src/actions/inbox.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/inbox.js +279 -152
- package/apps/app-lifeops/src/actions/intent-sync.d.ts +3 -0
- package/apps/app-lifeops/src/actions/intent-sync.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/intent-sync.js +258 -0
- package/apps/app-lifeops/src/actions/life.d.ts +0 -4
- package/apps/app-lifeops/src/actions/life.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/life.js +162 -249
- package/apps/app-lifeops/src/actions/lifeops-google-helpers.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/lifeops-google-helpers.js +11 -3
- package/apps/app-lifeops/src/actions/list-remote-sessions.d.ts +6 -0
- package/apps/app-lifeops/src/actions/list-remote-sessions.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/list-remote-sessions.js +45 -0
- package/apps/app-lifeops/src/actions/password-manager.d.ts +3 -0
- package/apps/app-lifeops/src/actions/password-manager.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/password-manager.js +182 -0
- package/apps/app-lifeops/src/actions/relationships.d.ts +9 -0
- package/apps/app-lifeops/src/actions/relationships.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/relationships.js +504 -0
- package/apps/app-lifeops/src/actions/remote-desktop.d.ts +3 -0
- package/apps/app-lifeops/src/actions/remote-desktop.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/remote-desktop.js +244 -0
- package/apps/app-lifeops/src/actions/revoke-remote-session.d.ts +6 -0
- package/apps/app-lifeops/src/actions/revoke-remote-session.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/revoke-remote-session.js +73 -0
- package/apps/app-lifeops/src/actions/scheduling.d.ts +55 -0
- package/apps/app-lifeops/src/actions/scheduling.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/scheduling.js +914 -0
- package/apps/app-lifeops/src/actions/screen-time.d.ts +8 -0
- package/apps/app-lifeops/src/actions/screen-time.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/screen-time.js +231 -0
- package/apps/app-lifeops/src/actions/search-across-channels.d.ts +13 -0
- package/apps/app-lifeops/src/actions/search-across-channels.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/search-across-channels.js +340 -0
- package/apps/app-lifeops/src/actions/start-remote-session.d.ts +14 -0
- package/apps/app-lifeops/src/actions/start-remote-session.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/start-remote-session.js +138 -0
- package/apps/app-lifeops/src/actions/twilio-call.d.ts +20 -0
- package/apps/app-lifeops/src/actions/twilio-call.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/twilio-call.js +510 -0
- package/apps/app-lifeops/src/actions/update-owner-profile.d.ts +3 -1
- package/apps/app-lifeops/src/actions/update-owner-profile.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/update-owner-profile.js +52 -31
- package/apps/app-lifeops/src/actions/website-blocker.d.ts +10 -0
- package/apps/app-lifeops/src/actions/website-blocker.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/website-blocker.js +539 -0
- package/apps/app-lifeops/src/actions/x-read.d.ts +3 -0
- package/apps/app-lifeops/src/actions/x-read.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/x-read.js +367 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-repo.d.ts +28 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-repo.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-repo.js +62 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-reporting.d.ts +45 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-reporting.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-reporting.js +112 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-service.d.ts +26 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-service.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-service.js +84 -0
- package/apps/app-lifeops/src/activity-profile/analyzer.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/analyzer.js +544 -0
- package/apps/app-lifeops/src/activity-profile/proactive-planner.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/proactive-planner.js +458 -0
- package/apps/app-lifeops/src/activity-profile/proactive-worker.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/proactive-worker.js +571 -0
- package/apps/app-lifeops/src/activity-profile/profile-metadata.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/redactor.d.ts +18 -0
- package/apps/app-lifeops/src/activity-profile/redactor.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/redactor.js +39 -0
- package/apps/app-lifeops/src/activity-profile/service.d.ts +11 -0
- package/apps/app-lifeops/src/activity-profile/service.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/service.js +229 -0
- package/apps/app-lifeops/src/activity-profile/types.d.ts.map +1 -0
- package/apps/app-lifeops/src/app-blocker/access.d.ts +8 -0
- package/apps/app-lifeops/src/app-blocker/access.d.ts.map +1 -0
- package/apps/app-lifeops/src/app-blocker/access.js +28 -0
- package/apps/app-lifeops/src/app-blocker/engine.d.ts +10 -0
- package/apps/app-lifeops/src/app-blocker/engine.d.ts.map +1 -0
- package/apps/app-lifeops/src/app-blocker/engine.js +43 -0
- package/apps/app-lifeops/src/dossier/action.d.ts +9 -0
- package/apps/app-lifeops/src/dossier/action.d.ts.map +1 -0
- package/apps/app-lifeops/src/dossier/action.js +87 -0
- package/apps/app-lifeops/src/dossier/service.d.ts +145 -0
- package/apps/app-lifeops/src/dossier/service.d.ts.map +1 -0
- package/apps/app-lifeops/src/dossier/service.js +346 -0
- package/apps/app-lifeops/src/followup/actions/listOverdueFollowups.d.ts +3 -0
- package/apps/app-lifeops/src/followup/actions/listOverdueFollowups.d.ts.map +1 -0
- package/apps/app-lifeops/src/followup/actions/listOverdueFollowups.js +47 -0
- package/apps/app-lifeops/src/followup/actions/markFollowupDone.d.ts +3 -0
- package/apps/app-lifeops/src/followup/actions/markFollowupDone.d.ts.map +1 -0
- package/apps/app-lifeops/src/followup/actions/markFollowupDone.js +172 -0
- package/apps/app-lifeops/src/followup/actions/setFollowupThreshold.d.ts +3 -0
- package/apps/app-lifeops/src/followup/actions/setFollowupThreshold.d.ts.map +1 -0
- package/apps/app-lifeops/src/followup/actions/setFollowupThreshold.js +171 -0
- package/apps/app-lifeops/src/followup/followup-tracker.d.ts +81 -0
- package/apps/app-lifeops/src/followup/followup-tracker.d.ts.map +1 -0
- package/apps/app-lifeops/src/followup/followup-tracker.js +251 -0
- package/apps/app-lifeops/src/followup/index.d.ts +5 -0
- package/apps/app-lifeops/src/followup/index.d.ts.map +1 -0
- package/apps/app-lifeops/src/followup/index.js +4 -0
- package/apps/app-lifeops/src/inbox/reflection.d.ts +0 -5
- package/apps/app-lifeops/src/inbox/reflection.d.ts.map +1 -1
- package/apps/app-lifeops/src/inbox/reflection.js +9 -51
- package/apps/app-lifeops/src/inbox/repository.d.ts +0 -1
- package/apps/app-lifeops/src/inbox/repository.d.ts.map +1 -1
- package/apps/app-lifeops/src/inbox/repository.js +18 -118
- package/apps/app-lifeops/src/inbox/triage-classifier.d.ts +4 -6
- package/apps/app-lifeops/src/inbox/triage-classifier.d.ts.map +1 -1
- package/apps/app-lifeops/src/inbox/triage-classifier.js +68 -101
- package/apps/app-lifeops/src/inbox/types.d.ts +4 -42
- package/apps/app-lifeops/src/inbox/types.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/approval-queue.types.d.ts +162 -0
- package/apps/app-lifeops/src/lifeops/approval-queue.types.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/approval-queue.types.js +41 -0
- package/apps/app-lifeops/src/lifeops/autofill-whitelist.d.ts +24 -0
- package/apps/app-lifeops/src/lifeops/autofill-whitelist.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/autofill-whitelist.js +125 -0
- package/apps/app-lifeops/src/lifeops/background-planner-dispatch.d.ts +59 -0
- package/apps/app-lifeops/src/lifeops/background-planner-dispatch.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/background-planner-dispatch.js +129 -0
- package/apps/app-lifeops/src/lifeops/background-planner.d.ts +141 -0
- package/apps/app-lifeops/src/lifeops/background-planner.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/background-planner.js +308 -0
- package/apps/app-lifeops/src/lifeops/browser-extension-store.d.ts +61 -0
- package/apps/app-lifeops/src/lifeops/browser-extension-store.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/browser-extension-store.js +181 -0
- package/apps/app-lifeops/src/lifeops/calendly-client.d.ts +61 -0
- package/apps/app-lifeops/src/lifeops/calendly-client.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/calendly-client.js +218 -0
- package/apps/app-lifeops/src/lifeops/checkin/checkin-service.d.ts +24 -0
- package/apps/app-lifeops/src/lifeops/checkin/checkin-service.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/checkin/checkin-service.js +216 -0
- package/apps/app-lifeops/src/lifeops/checkin/schedule-resolver.d.ts +14 -0
- package/apps/app-lifeops/src/lifeops/checkin/schedule-resolver.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/checkin/schedule-resolver.js +33 -0
- package/apps/app-lifeops/src/lifeops/checkin/types.d.ts +42 -0
- package/apps/app-lifeops/src/lifeops/checkin/types.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/checkin/types.js +7 -0
- package/apps/app-lifeops/src/lifeops/defaults.d.ts +1 -1
- package/apps/app-lifeops/src/lifeops/defaults.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/defaults.js +8 -1
- package/apps/app-lifeops/src/lifeops/discord-browser-scraper.d.ts +106 -0
- package/apps/app-lifeops/src/lifeops/discord-browser-scraper.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/discord-browser-scraper.js +488 -0
- package/apps/app-lifeops/src/lifeops/enforcement-windows.d.ts +34 -0
- package/apps/app-lifeops/src/lifeops/enforcement-windows.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/enforcement-windows.js +110 -0
- package/apps/app-lifeops/src/lifeops/google-connector-gateway.d.ts +13 -0
- package/apps/app-lifeops/src/lifeops/google-connector-gateway.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/google-connector-gateway.js +23 -0
- package/apps/app-lifeops/src/lifeops/google-drive.d.ts +103 -0
- package/apps/app-lifeops/src/lifeops/google-drive.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/google-drive.js +265 -0
- package/apps/app-lifeops/src/lifeops/google-fetch.d.ts +5 -0
- package/apps/app-lifeops/src/lifeops/google-fetch.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/google-fetch.js +12 -1
- package/apps/app-lifeops/src/lifeops/google-gmail.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/google-gmail.js +19 -34
- package/apps/app-lifeops/src/lifeops/google-managed-client.d.ts +12 -1
- package/apps/app-lifeops/src/lifeops/google-managed-client.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/google-managed-client.js +32 -12
- package/apps/app-lifeops/src/lifeops/google-oauth.d.ts +4 -0
- package/apps/app-lifeops/src/lifeops/google-oauth.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/google-oauth.js +99 -13
- package/apps/app-lifeops/src/lifeops/health-bridge.d.ts +57 -0
- package/apps/app-lifeops/src/lifeops/health-bridge.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/health-bridge.js +514 -0
- package/apps/app-lifeops/src/lifeops/imessage-bridge.d.ts +98 -0
- package/apps/app-lifeops/src/lifeops/imessage-bridge.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/imessage-bridge.js +537 -0
- package/apps/app-lifeops/src/lifeops/intent-sync.d.ts +56 -0
- package/apps/app-lifeops/src/lifeops/intent-sync.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/intent-sync.js +223 -0
- package/apps/app-lifeops/src/lifeops/notifications-push.d.ts +37 -0
- package/apps/app-lifeops/src/lifeops/notifications-push.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/notifications-push.js +90 -0
- package/apps/app-lifeops/src/lifeops/owner-profile.d.ts +29 -1
- package/apps/app-lifeops/src/lifeops/owner-profile.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/owner-profile.js +106 -0
- package/apps/app-lifeops/src/lifeops/password-manager-bridge.d.ts +49 -0
- package/apps/app-lifeops/src/lifeops/password-manager-bridge.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/password-manager-bridge.js +374 -0
- package/apps/app-lifeops/src/lifeops/remote-desktop.d.ts +37 -0
- package/apps/app-lifeops/src/lifeops/remote-desktop.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/remote-desktop.js +341 -0
- package/apps/app-lifeops/src/lifeops/repository.d.ts +69 -3
- package/apps/app-lifeops/src/lifeops/repository.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/repository.js +1368 -926
- package/apps/app-lifeops/src/lifeops/runtime.d.ts +1 -0
- package/apps/app-lifeops/src/lifeops/runtime.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/runtime.js +119 -9
- package/apps/app-lifeops/src/lifeops/schema.d.ts +5022 -0
- package/apps/app-lifeops/src/lifeops/schema.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/schema.js +207 -0
- package/apps/app-lifeops/src/lifeops/service-constants.d.ts +51 -0
- package/apps/app-lifeops/src/lifeops/service-constants.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-constants.js +111 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-browser.d.ts +40 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-browser.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-browser.js +288 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-misc.d.ts +68 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-misc.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-misc.js +493 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-occurrence.d.ts +17 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-occurrence.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-occurrence.js +214 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-reminder.d.ts +24 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-reminder.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-reminder.js +170 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-browser.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-browser.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-browser.js +769 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-calendar.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-calendar.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-calendar.js +513 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-core.d.ts +49 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-core.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-core.js +433 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-definitions.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-definitions.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-definitions.js +353 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-discord.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-discord.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-discord.js +603 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-dossier.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-dossier.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-dossier.js +262 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-drive.d.ts +12 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-drive.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-drive.js +230 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-gmail.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-gmail.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-gmail.js +1013 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-goals.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-goals.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-goals.js +714 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-google.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-google.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-google.js +793 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-health.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-health.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-health.js +55 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-imessage.d.ts +3 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-imessage.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-imessage.js +106 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-relationships.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-relationships.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-relationships.js +109 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-reminders.d.ts +37 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-reminders.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-reminders.js +2436 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-scheduling.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-scheduling.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-scheduling.js +149 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-screentime.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-screentime.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-screentime.js +97 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-signal.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-signal.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-signal.js +264 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-telegram.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-telegram.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-telegram.js +270 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-whatsapp.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-whatsapp.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-whatsapp.js +56 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-workflows.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-workflows.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-workflows.js +411 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-x-read.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-x-read.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-x-read.js +190 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-x.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-x.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-x.js +120 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-calendar.d.ts +42 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-calendar.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-calendar.js +294 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-connector.d.ts +18 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-connector.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-connector.js +317 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-gmail.d.ts +63 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-gmail.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-gmail.js +553 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-task.d.ts +8 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-task.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-task.js +333 -0
- package/apps/app-lifeops/src/lifeops/service-normalize.d.ts +27 -0
- package/apps/app-lifeops/src/lifeops/service-normalize.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-normalize.js +193 -0
- package/apps/app-lifeops/src/lifeops/service-types.d.ts +43 -0
- package/apps/app-lifeops/src/lifeops/service-types.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-types.js +8 -0
- package/apps/app-lifeops/src/lifeops/service.d.ts +1566 -272
- package/apps/app-lifeops/src/lifeops/service.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/service.js +38 -9256
- package/apps/app-lifeops/src/lifeops/signal-auth.d.ts +26 -0
- package/apps/app-lifeops/src/lifeops/signal-auth.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/signal-auth.js +300 -0
- package/apps/app-lifeops/src/lifeops/signal-runtime-config.d.ts +13 -0
- package/apps/app-lifeops/src/lifeops/signal-runtime-config.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/signal-runtime-config.js +42 -0
- package/apps/app-lifeops/src/lifeops/sql.d.ts +0 -5
- package/apps/app-lifeops/src/lifeops/sql.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/sql.js +5 -125
- package/apps/app-lifeops/src/lifeops/telegram-auth.d.ts +62 -0
- package/apps/app-lifeops/src/lifeops/telegram-auth.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/telegram-auth.js +496 -0
- package/apps/app-lifeops/src/lifeops/telegram-local-client.d.ts +118 -0
- package/apps/app-lifeops/src/lifeops/telegram-local-client.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/telegram-local-client.js +376 -0
- package/apps/app-lifeops/src/lifeops/twilio.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/twilio.js +2 -1
- package/apps/app-lifeops/src/lifeops/unified-search.d.ts +88 -0
- package/apps/app-lifeops/src/lifeops/unified-search.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/unified-search.js +431 -0
- package/apps/app-lifeops/src/lifeops/whatsapp-client.d.ts +47 -0
- package/apps/app-lifeops/src/lifeops/whatsapp-client.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/whatsapp-client.js +198 -0
- package/apps/app-lifeops/src/lifeops/x-poster.d.ts +22 -0
- package/apps/app-lifeops/src/lifeops/x-poster.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/x-poster.js +67 -3
- package/apps/app-lifeops/src/lifeops/x-reader.d.ts +70 -0
- package/apps/app-lifeops/src/lifeops/x-reader.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/x-reader.js +260 -0
- package/apps/app-lifeops/src/plugin.d.ts +12 -1
- package/apps/app-lifeops/src/plugin.d.ts.map +1 -1
- package/apps/app-lifeops/src/plugin.js +245 -26
- package/apps/app-lifeops/src/provider.d.ts.map +1 -1
- package/apps/app-lifeops/src/provider.js +1 -0
- package/apps/app-lifeops/src/providers/activity-profile.d.ts.map +1 -0
- package/apps/app-lifeops/src/providers/activity-profile.js +140 -0
- package/apps/app-lifeops/src/providers/app-blocker.d.ts +3 -0
- package/apps/app-lifeops/src/providers/app-blocker.d.ts.map +1 -0
- package/apps/app-lifeops/src/providers/app-blocker.js +86 -0
- package/apps/app-lifeops/src/providers/cross-channel-context.d.ts +29 -0
- package/apps/app-lifeops/src/providers/cross-channel-context.d.ts.map +1 -0
- package/apps/app-lifeops/src/providers/cross-channel-context.js +193 -0
- package/apps/app-lifeops/src/providers/inbox-triage.d.ts.map +1 -1
- package/apps/app-lifeops/src/providers/inbox-triage.js +1 -0
- package/apps/app-lifeops/src/providers/lifeops.d.ts +1 -1
- package/apps/app-lifeops/src/providers/lifeops.d.ts.map +1 -1
- package/apps/app-lifeops/src/providers/lifeops.js +39 -11
- package/apps/app-lifeops/src/providers/website-blocker.d.ts +4 -0
- package/apps/app-lifeops/src/providers/website-blocker.d.ts.map +1 -0
- package/apps/app-lifeops/src/providers/website-blocker.js +117 -0
- package/apps/app-lifeops/src/remote/pairing-code.d.ts +39 -0
- package/apps/app-lifeops/src/remote/pairing-code.d.ts.map +1 -0
- package/apps/app-lifeops/src/remote/pairing-code.js +76 -0
- package/apps/app-lifeops/src/remote/remote-session-service.d.ts +107 -0
- package/apps/app-lifeops/src/remote/remote-session-service.d.ts.map +1 -0
- package/apps/app-lifeops/src/remote/remote-session-service.js +253 -0
- package/apps/app-lifeops/src/routes/lifeops-browser-packaging.d.ts.map +1 -1
- package/apps/app-lifeops/src/routes/lifeops-browser-packaging.js +9 -3
- package/apps/app-lifeops/src/routes/lifeops-routes.d.ts +1 -1
- package/apps/app-lifeops/src/routes/lifeops-routes.d.ts.map +1 -1
- package/apps/app-lifeops/src/routes/lifeops-routes.js +276 -40
- package/apps/app-lifeops/src/routes/website-blocker-routes.d.ts.map +1 -1
- package/apps/app-lifeops/src/routes/website-blocker-routes.js +8 -13
- package/apps/app-lifeops/src/travel-time/action.d.ts +6 -0
- package/apps/app-lifeops/src/travel-time/action.d.ts.map +1 -0
- package/apps/app-lifeops/src/travel-time/action.js +81 -0
- package/apps/app-lifeops/src/travel-time/service.d.ts +61 -0
- package/apps/app-lifeops/src/travel-time/service.d.ts.map +1 -0
- package/apps/app-lifeops/src/travel-time/service.js +145 -0
- package/apps/app-lifeops/src/types/app-blocker-settings-card.d.ts +2 -0
- package/apps/app-lifeops/src/types/app-blocker-settings-card.d.ts.map +1 -0
- package/apps/app-lifeops/src/types/index.d.ts +3 -0
- package/apps/app-lifeops/src/types/index.d.ts.map +1 -0
- package/apps/app-lifeops/src/types/website-blocker-settings-card.d.ts +2 -0
- package/apps/app-lifeops/src/types/website-blocker-settings-card.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/access.d.ts +8 -0
- package/apps/app-lifeops/src/website-blocker/access.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/access.js +32 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/blockUntilTaskComplete.d.ts +3 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/blockUntilTaskComplete.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/blockUntilTaskComplete.js +212 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/listActiveBlocks.d.ts +3 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/listActiveBlocks.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/listActiveBlocks.js +57 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/releaseBlock.d.ts +3 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/releaseBlock.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/releaseBlock.js +98 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-reconciler.d.ts +7 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-reconciler.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-reconciler.js +111 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-schema.d.ts +39 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-schema.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-schema.js +123 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-service.d.ts +21 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-service.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-service.js +227 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/index.d.ts +8 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/index.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/index.js +6 -0
- package/apps/app-lifeops/src/website-blocker/engine.d.ts +116 -0
- package/apps/app-lifeops/src/website-blocker/engine.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/engine.js +934 -0
- package/apps/app-lifeops/src/website-blocker/permissions.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/permissions.js +1 -0
- package/apps/app-lifeops/src/website-blocker/public.d.ts +13 -0
- package/apps/app-lifeops/src/website-blocker/public.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/public.js +10 -0
- package/apps/app-lifeops/src/website-blocker/roles.d.ts +13 -0
- package/apps/app-lifeops/src/website-blocker/roles.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/roles.js +20 -0
- package/apps/app-lifeops/src/website-blocker/service.d.ts +21 -0
- package/apps/app-lifeops/src/website-blocker/service.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/service.js +268 -0
- package/apps/app-steward/src/api/tx-service.d.ts +47 -0
- package/apps/app-steward/src/api/tx-service.d.ts.map +1 -0
- package/apps/app-steward/src/api/tx-service.js +156 -0
- package/apps/app-steward/src/api/wallet-routes.d.ts +1 -9
- package/apps/app-steward/src/api/wallet-routes.d.ts.map +1 -1
- package/apps/app-steward/src/routes/wallet-export-guard.d.ts +2 -9
- package/apps/app-steward/src/routes/wallet-export-guard.d.ts.map +1 -1
- package/apps/app-steward/src/types/steward.d.ts +85 -0
- package/apps/app-steward/src/types/steward.d.ts.map +1 -0
- package/apps/app-steward/src/types/steward.js +9 -0
- package/apps/app-training/src/backends/atropos.d.ts +31 -0
- package/apps/app-training/src/backends/atropos.d.ts.map +1 -0
- package/apps/app-training/src/backends/atropos.js +63 -0
- package/apps/app-training/src/backends/native.d.ts +50 -0
- package/apps/app-training/src/backends/native.d.ts.map +1 -0
- package/apps/app-training/src/backends/native.js +128 -0
- package/apps/app-training/src/backends/tinker.d.ts +27 -0
- package/apps/app-training/src/backends/tinker.d.ts.map +1 -0
- package/apps/app-training/src/backends/tinker.js +56 -0
- package/apps/app-training/src/core/privacy-filter.d.ts +73 -0
- package/apps/app-training/src/core/privacy-filter.d.ts.map +1 -0
- package/apps/app-training/src/core/privacy-filter.js +169 -0
- package/apps/app-training/src/core/training-config.d.ts +52 -0
- package/apps/app-training/src/core/training-config.d.ts.map +1 -0
- package/apps/app-training/src/core/training-config.js +140 -0
- package/apps/app-training/src/core/training-orchestrator.d.ts +107 -0
- package/apps/app-training/src/core/training-orchestrator.d.ts.map +1 -0
- package/apps/app-training/src/core/training-orchestrator.js +409 -0
- package/apps/app-training/src/core/trajectory-task-datasets.d.ts +38 -0
- package/apps/app-training/src/core/trajectory-task-datasets.d.ts.map +1 -0
- package/apps/app-training/src/core/trajectory-task-datasets.js +281 -0
- package/apps/app-training/src/optimizers/bootstrap-fewshot.d.ts +42 -0
- package/apps/app-training/src/optimizers/bootstrap-fewshot.d.ts.map +1 -0
- package/apps/app-training/src/optimizers/bootstrap-fewshot.js +91 -0
- package/apps/app-training/src/optimizers/index.d.ts +6 -0
- package/apps/app-training/src/optimizers/index.d.ts.map +1 -0
- package/apps/app-training/src/optimizers/index.js +4 -0
- package/apps/app-training/src/optimizers/instruction-search.d.ts +39 -0
- package/apps/app-training/src/optimizers/instruction-search.d.ts.map +1 -0
- package/apps/app-training/src/optimizers/instruction-search.js +82 -0
- package/apps/app-training/src/optimizers/prompt-evolution.d.ts +39 -0
- package/apps/app-training/src/optimizers/prompt-evolution.d.ts.map +1 -0
- package/apps/app-training/src/optimizers/prompt-evolution.js +111 -0
- package/apps/app-training/src/optimizers/scoring.d.ts +63 -0
- package/apps/app-training/src/optimizers/scoring.d.ts.map +1 -0
- package/apps/app-training/src/optimizers/scoring.js +117 -0
- package/apps/app-training/src/optimizers/types.d.ts +105 -0
- package/apps/app-training/src/optimizers/types.d.ts.map +1 -0
- package/apps/app-training/src/optimizers/types.js +17 -0
- package/apps/app-training/src/services/index.d.ts +1 -0
- package/apps/app-training/src/services/index.d.ts.map +1 -1
- package/apps/app-training/src/services/index.js +1 -0
- package/apps/app-training/src/services/training-trigger.d.ts +166 -0
- package/apps/app-training/src/services/training-trigger.d.ts.map +1 -0
- package/apps/app-training/src/services/training-trigger.js +376 -0
- package/package.json +26 -21
- package/packages/agent/src/actions/app-control.js +1 -1
- package/packages/agent/src/actions/connector-resolver.d.ts.map +1 -1
- package/packages/agent/src/actions/connector-resolver.js +17 -7
- package/packages/agent/src/actions/context-signal-lexicon.d.ts +1 -1
- package/packages/agent/src/actions/context-signal-lexicon.d.ts.map +1 -1
- package/packages/agent/src/actions/context-signal-lexicon.js +7 -1
- package/packages/agent/src/actions/context-signal.d.ts +1 -1
- package/packages/agent/src/actions/context-signal.d.ts.map +1 -1
- package/packages/agent/src/actions/context-signal.js +1 -1
- package/packages/agent/src/actions/eject-plugin.d.ts.map +1 -1
- package/packages/agent/src/actions/eject-plugin.js +3 -1
- package/packages/agent/src/actions/entity-actions.d.ts +1 -0
- package/packages/agent/src/actions/entity-actions.d.ts.map +1 -1
- package/packages/agent/src/actions/entity-actions.js +233 -1
- package/packages/agent/src/actions/get-self-status.d.ts.map +1 -1
- package/packages/agent/src/actions/get-self-status.js +12 -1
- package/packages/agent/src/actions/grounded-action-reply.d.ts.map +1 -1
- package/packages/agent/src/actions/grounded-action-reply.js +1 -1
- package/packages/agent/src/actions/index.d.ts +0 -9
- package/packages/agent/src/actions/index.d.ts.map +1 -1
- package/packages/agent/src/actions/index.js +0 -9
- package/packages/agent/src/actions/install-plugin.d.ts.map +1 -1
- package/packages/agent/src/actions/install-plugin.js +3 -1
- package/packages/agent/src/actions/list-ejected.d.ts.map +1 -1
- package/packages/agent/src/actions/list-ejected.js +5 -3
- package/packages/agent/src/actions/reinject-plugin.d.ts.map +1 -1
- package/packages/agent/src/actions/reinject-plugin.js +3 -1
- package/packages/agent/src/actions/set-user-name.d.ts.map +1 -1
- package/packages/agent/src/actions/set-user-name.js +1 -1
- package/packages/agent/src/actions/sync-plugin.d.ts.map +1 -1
- package/packages/agent/src/actions/sync-plugin.js +5 -6
- package/packages/agent/src/api/agent-admin-routes.js +1 -1
- package/packages/agent/src/api/apps-routes.d.ts +2 -1
- package/packages/agent/src/api/apps-routes.d.ts.map +1 -1
- package/packages/agent/src/api/apps-routes.js +152 -2
- package/packages/agent/src/api/auth-routes.js +1 -1
- package/packages/agent/src/api/bsc-trade.d.ts +0 -4
- package/packages/agent/src/api/bsc-trade.d.ts.map +1 -1
- package/packages/agent/src/api/bsc-trade.js +0 -4
- package/packages/agent/src/api/character-routes.d.ts +2 -1
- package/packages/agent/src/api/character-routes.d.ts.map +1 -1
- package/packages/agent/src/api/chat-augmentation.js +1 -1
- package/packages/agent/src/api/chat-routes.d.ts.map +1 -1
- package/packages/agent/src/api/chat-routes.js +23 -108
- package/packages/agent/src/api/cloud-billing-routes.d.ts +1 -1
- package/packages/agent/src/api/cloud-billing-routes.d.ts.map +1 -1
- package/packages/agent/src/api/cloud-compat-routes.d.ts +1 -1
- package/packages/agent/src/api/cloud-compat-routes.d.ts.map +1 -1
- package/packages/agent/src/api/connector-health.d.ts +1 -1
- package/packages/agent/src/api/connector-health.d.ts.map +1 -1
- package/packages/agent/src/api/conversation-routes.d.ts +2 -2
- package/packages/agent/src/api/conversation-routes.d.ts.map +1 -1
- package/packages/agent/src/api/conversation-routes.js +1 -1
- package/packages/agent/src/api/curated-skills-routes.d.ts +22 -0
- package/packages/agent/src/api/curated-skills-routes.d.ts.map +1 -0
- package/packages/agent/src/api/curated-skills-routes.js +300 -0
- package/packages/agent/src/api/database.d.ts.map +1 -1
- package/packages/agent/src/api/database.js +11 -4
- package/packages/agent/src/api/discord-profiles.d.ts.map +1 -1
- package/packages/agent/src/api/discord-profiles.js +1 -4
- package/packages/agent/src/api/index.d.ts +0 -7
- package/packages/agent/src/api/index.d.ts.map +1 -1
- package/packages/agent/src/api/index.js +0 -7
- package/packages/agent/src/api/knowledge-routes.d.ts +22 -1
- package/packages/agent/src/api/knowledge-routes.d.ts.map +1 -1
- package/packages/agent/src/api/knowledge-routes.js +956 -2
- package/packages/agent/src/api/lifeops-browser-packaging.d.ts +1 -1
- package/packages/agent/src/api/lifeops-browser-packaging.d.ts.map +1 -1
- package/packages/agent/src/api/lifeops-browser-packaging.js +1 -1
- package/packages/agent/src/api/misc-routes.d.ts +2 -2
- package/packages/agent/src/api/misc-routes.d.ts.map +1 -1
- package/packages/agent/src/api/misc-routes.js +43 -6
- package/packages/agent/src/api/plugin-discovery-helpers.d.ts.map +1 -1
- package/packages/agent/src/api/plugin-discovery-helpers.js +2 -2
- package/packages/agent/src/api/plugin-routes.d.ts +1 -1
- package/packages/agent/src/api/plugin-routes.d.ts.map +1 -1
- package/packages/agent/src/api/plugin-routes.js +11 -2
- package/packages/agent/src/api/registry-service.d.ts +1 -1
- package/packages/agent/src/api/registry-service.d.ts.map +1 -1
- package/packages/agent/src/api/relationships-routes.d.ts.map +1 -1
- package/packages/agent/src/api/relationships-routes.js +70 -3
- package/packages/agent/src/api/server-auth.d.ts +2 -9
- package/packages/agent/src/api/server-auth.d.ts.map +1 -1
- package/packages/agent/src/api/server-auth.js +1 -1
- package/packages/agent/src/api/server-helpers-auth.d.ts +39 -0
- package/packages/agent/src/api/server-helpers-auth.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-auth.js +432 -0
- package/packages/agent/src/api/server-helpers-config.d.ts +37 -0
- package/packages/agent/src/api/server-helpers-config.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-config.js +295 -0
- package/packages/agent/src/api/server-helpers-mcp.d.ts +12 -0
- package/packages/agent/src/api/server-helpers-mcp.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-mcp.js +315 -0
- package/packages/agent/src/api/server-helpers-plugin.d.ts +13 -0
- package/packages/agent/src/api/server-helpers-plugin.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-plugin.js +158 -0
- package/packages/agent/src/api/server-helpers-swarm.d.ts +57 -0
- package/packages/agent/src/api/server-helpers-swarm.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-swarm.js +325 -0
- package/packages/agent/src/api/server-helpers-wallet.d.ts +18 -0
- package/packages/agent/src/api/server-helpers-wallet.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-wallet.js +178 -0
- package/packages/agent/src/api/server-helpers.d.ts.map +1 -1
- package/packages/agent/src/api/server-helpers.js +1 -1
- package/packages/agent/src/api/server-types.d.ts +42 -3
- package/packages/agent/src/api/server-types.d.ts.map +1 -1
- package/packages/agent/src/api/server.d.ts +10 -56
- package/packages/agent/src/api/server.d.ts.map +1 -1
- package/packages/agent/src/api/server.js +298 -1436
- package/packages/agent/src/api/signal-routes.d.ts +1 -1
- package/packages/agent/src/api/signal-routes.d.ts.map +1 -1
- package/packages/agent/src/api/signal-routes.js +1 -2
- package/packages/agent/src/api/skill-discovery-helpers.js +2 -0
- package/packages/agent/src/api/skills-routes.d.ts.map +1 -1
- package/packages/agent/src/api/skills-routes.js +69 -0
- package/packages/agent/src/api/static-file-server.js +1 -1
- package/packages/agent/src/api/stream-routes.d.ts +0 -19
- package/packages/agent/src/api/stream-routes.d.ts.map +1 -1
- package/packages/agent/src/api/trade-safety.d.ts +0 -4
- package/packages/agent/src/api/trade-safety.d.ts.map +1 -1
- package/packages/agent/src/api/trade-safety.js +0 -4
- package/packages/agent/src/api/trigger-routes.d.ts +37 -47
- package/packages/agent/src/api/trigger-routes.d.ts.map +1 -1
- package/packages/agent/src/api/trigger-routes.js +89 -18
- package/packages/agent/src/api/tts-routes.d.ts.map +1 -1
- package/packages/agent/src/api/tts-routes.js +1 -1
- package/packages/agent/src/api/tx-service.d.ts +0 -4
- package/packages/agent/src/api/tx-service.d.ts.map +1 -1
- package/packages/agent/src/api/tx-service.js +0 -4
- package/packages/agent/src/api/wallet-bsc-routes.d.ts +0 -4
- package/packages/agent/src/api/wallet-bsc-routes.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-bsc-routes.js +0 -4
- package/packages/agent/src/api/wallet-capability.d.ts +0 -5
- package/packages/agent/src/api/wallet-capability.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-capability.js +0 -5
- package/packages/agent/src/api/wallet-dex-prices.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-dex-prices.js +0 -4
- package/packages/agent/src/api/wallet-env-sync.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-env-sync.js +5 -1
- package/packages/agent/src/api/wallet-evm-balance.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-evm-balance.js +0 -4
- package/packages/agent/src/api/wallet-routes.d.ts +1 -14
- package/packages/agent/src/api/wallet-routes.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-routes.js +9 -15
- package/packages/agent/src/api/wallet-rpc.d.ts +0 -5
- package/packages/agent/src/api/wallet-rpc.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-rpc.js +0 -5
- package/packages/agent/src/api/wallet-trade-routes.d.ts +0 -5
- package/packages/agent/src/api/wallet-trade-routes.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-trade-routes.js +0 -5
- package/packages/agent/src/api/wallet-trading-profile.d.ts +2 -27
- package/packages/agent/src/api/wallet-trading-profile.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-trading-profile.js +0 -5
- package/packages/agent/src/api/wallet.d.ts.map +1 -1
- package/packages/agent/src/api/wallet.js +0 -4
- package/packages/agent/src/api/whatsapp-routes.d.ts +1 -1
- package/packages/agent/src/api/whatsapp-routes.d.ts.map +1 -1
- package/packages/agent/src/api/whatsapp-routes.js +1 -2
- package/packages/agent/src/api/workbench-helpers.d.ts.map +1 -1
- package/packages/agent/src/api/workbench-helpers.js +2 -1
- package/packages/agent/src/api/workbench-routes.d.ts.map +1 -1
- package/packages/agent/src/api/workbench-routes.js +1 -1
- package/packages/agent/src/auth/anthropic.d.ts +0 -5
- package/packages/agent/src/auth/anthropic.d.ts.map +1 -1
- package/packages/agent/src/auth/anthropic.js +0 -5
- package/packages/agent/src/auth/openai-codex.d.ts +0 -5
- package/packages/agent/src/auth/openai-codex.d.ts.map +1 -1
- package/packages/agent/src/auth/openai-codex.js +0 -5
- package/packages/agent/src/cloud/cloud-wallet.d.ts +0 -2
- package/packages/agent/src/cloud/cloud-wallet.d.ts.map +1 -1
- package/packages/agent/src/config/env-vars.d.ts.map +1 -1
- package/packages/agent/src/config/env-vars.js +2 -0
- package/packages/agent/src/config/includes.js +1 -1
- package/packages/agent/src/config/index.d.ts +1 -1
- package/packages/agent/src/config/index.d.ts.map +1 -1
- package/packages/agent/src/config/index.js +1 -1
- package/packages/agent/src/config/plugin-auto-enable.d.ts +8 -0
- package/packages/agent/src/config/plugin-auto-enable.d.ts.map +1 -1
- package/packages/agent/src/config/plugin-auto-enable.js +28 -0
- package/packages/agent/src/config/types.agent-defaults.d.ts +2 -1
- package/packages/agent/src/config/types.agent-defaults.d.ts.map +1 -1
- package/packages/agent/src/config/types.eliza.d.ts +34 -0
- package/packages/agent/src/config/types.eliza.d.ts.map +1 -1
- package/packages/agent/src/contracts/index.d.ts +8 -8
- package/packages/agent/src/contracts/index.d.ts.map +1 -1
- package/packages/agent/src/contracts/index.js +8 -8
- package/packages/agent/src/contracts/onboarding-provider-defaults.d.ts +165 -0
- package/packages/agent/src/contracts/onboarding-provider-defaults.d.ts.map +1 -0
- package/packages/agent/src/contracts/onboarding-provider-defaults.js +189 -0
- package/packages/agent/src/index.d.ts +8 -6
- package/packages/agent/src/index.d.ts.map +1 -1
- package/packages/agent/src/index.js +8 -6
- package/packages/agent/src/providers/conversation-utils.d.ts.map +1 -1
- package/packages/agent/src/providers/conversation-utils.js +2 -3
- package/packages/agent/src/providers/index.d.ts +0 -1
- package/packages/agent/src/providers/index.d.ts.map +1 -1
- package/packages/agent/src/providers/index.js +0 -1
- package/packages/agent/src/providers/user-name.d.ts.map +1 -1
- package/packages/agent/src/providers/user-name.js +1 -1
- package/packages/agent/src/providers/workspace-provider.d.ts +0 -8
- package/packages/agent/src/providers/workspace-provider.d.ts.map +1 -1
- package/packages/agent/src/runtime/custom-actions.js +1 -1
- package/packages/agent/src/runtime/eliza-plugin.d.ts.map +1 -1
- package/packages/agent/src/runtime/eliza-plugin.js +1 -47
- package/packages/agent/src/runtime/eliza.d.ts +1 -91
- package/packages/agent/src/runtime/eliza.d.ts.map +1 -1
- package/packages/agent/src/runtime/eliza.js +109 -12
- package/packages/agent/src/runtime/first-time-setup.d.ts +20 -0
- package/packages/agent/src/runtime/first-time-setup.d.ts.map +1 -1
- package/packages/agent/src/runtime/first-time-setup.js +20 -25
- package/packages/agent/src/runtime/index.d.ts +1 -1
- package/packages/agent/src/runtime/index.d.ts.map +1 -1
- package/packages/agent/src/runtime/index.js +1 -1
- package/packages/agent/src/runtime/plugin-collector.d.ts +0 -12
- package/packages/agent/src/runtime/plugin-collector.d.ts.map +1 -1
- package/packages/agent/src/runtime/plugin-lifecycle.d.ts.map +1 -1
- package/packages/agent/src/runtime/plugin-lifecycle.js +6 -2
- package/packages/agent/src/runtime/plugin-resolver.d.ts.map +1 -1
- package/packages/agent/src/runtime/plugin-resolver.js +6 -7
- package/packages/agent/src/runtime/plugin-types.d.ts +0 -6
- package/packages/agent/src/runtime/plugin-types.d.ts.map +1 -1
- package/packages/agent/src/runtime/roles/src/utils.d.ts +1 -1
- package/packages/agent/src/runtime/roles/src/utils.d.ts.map +1 -1
- package/packages/agent/src/runtime/roles/src/utils.js +1 -1
- package/packages/agent/src/runtime/subagent-output.d.ts +51 -0
- package/packages/agent/src/runtime/subagent-output.d.ts.map +1 -0
- package/packages/agent/src/runtime/subagent-output.js +173 -0
- package/packages/agent/src/runtime/task-heartbeat.d.ts +22 -0
- package/packages/agent/src/runtime/task-heartbeat.d.ts.map +1 -0
- package/packages/agent/src/runtime/task-heartbeat.js +84 -0
- package/packages/agent/src/runtime/trajectory-internals.d.ts +37 -30
- package/packages/agent/src/runtime/trajectory-internals.d.ts.map +1 -1
- package/packages/agent/src/runtime/trajectory-internals.js +73 -47
- package/packages/agent/src/runtime/trajectory-persistence.d.ts +1 -1
- package/packages/agent/src/runtime/trajectory-persistence.d.ts.map +1 -1
- package/packages/agent/src/runtime/trajectory-persistence.js +1 -1
- package/packages/agent/src/runtime/trajectory-storage.d.ts +27 -1
- package/packages/agent/src/runtime/trajectory-storage.d.ts.map +1 -1
- package/packages/agent/src/runtime/trajectory-storage.js +124 -1
- package/packages/agent/src/runtime/web-search-tools.d.ts.map +1 -1
- package/packages/agent/src/security/access.d.ts.map +1 -1
- package/packages/agent/src/security/access.js +6 -26
- package/packages/agent/src/security/audit-log.d.ts +0 -2
- package/packages/agent/src/security/audit-log.d.ts.map +1 -1
- package/packages/agent/src/security/index.d.ts +1 -0
- package/packages/agent/src/security/index.d.ts.map +1 -1
- package/packages/agent/src/security/index.js +1 -0
- package/packages/agent/src/services/app-manager.d.ts +53 -1
- package/packages/agent/src/services/app-manager.d.ts.map +1 -1
- package/packages/agent/src/services/app-manager.js +219 -15
- package/packages/agent/src/services/app-package-modules.d.ts +3 -12
- package/packages/agent/src/services/app-package-modules.d.ts.map +1 -1
- package/packages/agent/src/services/app-package-modules.js +78 -11
- package/packages/agent/src/services/browser-workspace-desktop.d.ts +22 -0
- package/packages/agent/src/services/browser-workspace-desktop.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-desktop.js +1379 -0
- package/packages/agent/src/services/browser-workspace-elements.d.ts +42 -0
- package/packages/agent/src/services/browser-workspace-elements.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-elements.js +508 -0
- package/packages/agent/src/services/browser-workspace-forms.d.ts +19 -0
- package/packages/agent/src/services/browser-workspace-forms.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-forms.js +244 -0
- package/packages/agent/src/services/browser-workspace-helpers.d.ts +20 -0
- package/packages/agent/src/services/browser-workspace-helpers.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-helpers.js +121 -0
- package/packages/agent/src/services/browser-workspace-jsdom.d.ts +16 -0
- package/packages/agent/src/services/browser-workspace-jsdom.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-jsdom.js +223 -0
- package/packages/agent/src/services/browser-workspace-network.d.ts +7 -0
- package/packages/agent/src/services/browser-workspace-network.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-network.js +137 -0
- package/packages/agent/src/services/browser-workspace-snapshots.d.ts +14 -0
- package/packages/agent/src/services/browser-workspace-snapshots.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-snapshots.js +144 -0
- package/packages/agent/src/services/browser-workspace-state.d.ts +22 -0
- package/packages/agent/src/services/browser-workspace-state.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-state.js +129 -0
- package/packages/agent/src/services/browser-workspace-types.d.ts +262 -0
- package/packages/agent/src/services/browser-workspace-types.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-types.js +1 -0
- package/packages/agent/src/services/browser-workspace-web.d.ts +8 -0
- package/packages/agent/src/services/browser-workspace-web.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-web.js +1141 -0
- package/packages/agent/src/services/browser-workspace.d.ts +22 -165
- package/packages/agent/src/services/browser-workspace.d.ts.map +1 -1
- package/packages/agent/src/services/browser-workspace.js +89 -4043
- package/packages/agent/src/services/built-in-app-routes/hyperscape.d.ts.map +1 -1
- package/packages/agent/src/services/built-in-app-routes/hyperscape.js +9 -6
- package/packages/agent/src/services/character-persistence.d.ts.map +1 -1
- package/packages/agent/src/services/character-persistence.js +1 -2
- package/packages/agent/src/services/client-chat-sender.d.ts.map +1 -1
- package/packages/agent/src/services/coding-task-executor.d.ts +2 -8
- package/packages/agent/src/services/coding-task-executor.d.ts.map +1 -1
- package/packages/agent/src/services/coding-task-executor.js +34 -66
- package/packages/agent/src/services/connector-setup-service.d.ts +4 -4
- package/packages/agent/src/services/connector-setup-service.d.ts.map +1 -1
- package/packages/agent/src/services/escalation.d.ts.map +1 -1
- package/packages/agent/src/services/escalation.js +1 -1
- package/packages/agent/src/services/plugin-manager-types.d.ts +1 -0
- package/packages/agent/src/services/plugin-manager-types.d.ts.map +1 -1
- package/packages/agent/src/services/privy-wallets.d.ts +0 -5
- package/packages/agent/src/services/privy-wallets.d.ts.map +1 -1
- package/packages/agent/src/services/privy-wallets.js +0 -5
- package/packages/agent/src/services/registry-client-app-meta.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-app-meta.js +1 -0
- package/packages/agent/src/services/registry-client-local.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-local.js +1 -0
- package/packages/agent/src/services/registry-client-network.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-network.js +1 -0
- package/packages/agent/src/services/registry-client-queries.d.ts +11 -0
- package/packages/agent/src/services/registry-client-queries.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-queries.js +23 -0
- package/packages/agent/src/services/registry-client-types.d.ts +8 -32
- package/packages/agent/src/services/registry-client-types.d.ts.map +1 -1
- package/packages/agent/src/services/relationships-graph.d.ts +62 -1
- package/packages/agent/src/services/relationships-graph.d.ts.map +1 -1
- package/packages/agent/src/services/relationships-graph.js +116 -6
- package/packages/agent/src/services/signal-pairing.d.ts.map +1 -1
- package/packages/agent/src/services/signal-pairing.js +15 -1
- package/packages/agent/src/services/steward-evm-account.d.ts +0 -4
- package/packages/agent/src/services/steward-evm-account.d.ts.map +1 -1
- package/packages/agent/src/services/steward-evm-account.js +0 -4
- package/packages/agent/src/services/steward-evm-bridge.d.ts +0 -4
- package/packages/agent/src/services/steward-evm-bridge.d.ts.map +1 -1
- package/packages/agent/src/services/steward-evm-bridge.js +0 -4
- package/packages/agent/src/services/steward-wallet.d.ts +1 -6
- package/packages/agent/src/services/steward-wallet.d.ts.map +1 -1
- package/packages/agent/src/services/steward-wallet.js +0 -5
- package/packages/agent/src/services/tts-stream-bridge.d.ts.map +1 -1
- package/packages/agent/src/services/tts-stream-bridge.js +1 -1
- package/packages/agent/src/test-support/route-test-helpers.d.ts +2 -2
- package/packages/agent/src/test-support/route-test-helpers.d.ts.map +1 -1
- package/packages/agent/src/test-support/test-helpers.d.ts +2 -2
- package/packages/agent/src/test-support/test-helpers.d.ts.map +1 -1
- package/packages/agent/src/triggers/runtime.d.ts +1 -0
- package/packages/agent/src/triggers/runtime.d.ts.map +1 -1
- package/packages/agent/src/triggers/runtime.js +67 -16
- package/packages/agent/src/triggers/scheduling.d.ts +6 -1
- package/packages/agent/src/triggers/scheduling.d.ts.map +1 -1
- package/packages/agent/src/triggers/scheduling.js +66 -20
- package/packages/agent/src/triggers/types.d.ts +14 -37
- package/packages/agent/src/triggers/types.d.ts.map +1 -1
- package/packages/agent/src/triggers/types.js +1 -1
- package/packages/agent/src/types/trajectory.d.ts +42 -1
- package/packages/agent/src/types/trajectory.d.ts.map +1 -1
- package/packages/agent/src/types/trajectory.js +2 -1
- package/packages/agent/src/utils/index.d.ts +1 -1
- package/packages/agent/src/utils/index.d.ts.map +1 -1
- package/packages/agent/src/utils/index.js +1 -1
- package/packages/app-core/src/api/client-types-cloud.d.ts +799 -0
- package/packages/app-core/src/api/client-types-cloud.d.ts.map +1 -0
- package/packages/app-core/src/api/client-types-cloud.js +57 -0
- package/packages/app-core/src/api/client-types-core.d.ts +334 -0
- package/packages/app-core/src/api/client-types-core.d.ts.map +1 -0
- package/packages/app-core/src/api/client-types-core.js +22 -0
- package/packages/app-core/src/api/compat-route-shared.d.ts +2 -2
- package/packages/app-core/src/api/compat-route-shared.d.ts.map +1 -1
- package/packages/app-core/src/api/server-cloud-tts.js +1 -1
- package/packages/app-core/src/bridge/native-plugins.d.ts +290 -0
- package/packages/app-core/src/bridge/native-plugins.d.ts.map +1 -0
- package/packages/app-core/src/bridge/native-plugins.js +55 -0
- package/packages/app-core/src/config/boot-config-store.d.ts +121 -2
- package/packages/app-core/src/config/boot-config-store.d.ts.map +1 -1
- package/packages/app-core/src/config/boot-config-store.js +16 -7
- package/packages/app-core/src/services/plugin-installer.d.ts +93 -0
- package/packages/app-core/src/services/plugin-installer.d.ts.map +1 -0
- package/packages/app-core/src/services/plugin-installer.js +611 -0
- package/packages/app-core/src/utils/env.d.ts.map +1 -1
- package/packages/app-core/src/utils/serialise.d.ts +12 -0
- package/packages/app-core/src/utils/serialise.d.ts.map +1 -0
- package/packages/app-core/src/utils/serialise.js +21 -0
- package/packages/native-plugins/activity-tracker/src/index.d.ts +35 -0
- package/packages/native-plugins/activity-tracker/src/index.d.ts.map +1 -0
- package/packages/native-plugins/activity-tracker/src/index.js +102 -0
- package/packages/shared/src/connectors.d.ts.map +1 -1
- package/packages/shared/src/connectors.js +8 -3
- package/packages/shared/src/contracts/apps.d.ts +53 -0
- package/packages/shared/src/contracts/apps.d.ts.map +1 -1
- package/packages/shared/src/contracts/cloud-topology.d.ts.map +1 -1
- package/packages/shared/src/contracts/cloud-topology.js +2 -4
- package/packages/shared/src/contracts/config.d.ts.map +1 -1
- package/packages/shared/src/contracts/index.d.ts +1 -1
- package/packages/shared/src/contracts/index.d.ts.map +1 -1
- package/packages/shared/src/contracts/index.js +1 -1
- package/packages/shared/src/contracts/lifeops-extensions.d.ts +181 -0
- package/packages/shared/src/contracts/lifeops-extensions.d.ts.map +1 -0
- package/packages/shared/src/contracts/lifeops-extensions.js +30 -0
- package/packages/shared/src/contracts/lifeops.d.ts +259 -0
- package/packages/shared/src/contracts/lifeops.d.ts.map +1 -1
- package/packages/shared/src/contracts/lifeops.js +62 -0
- package/packages/shared/src/contracts/onboarding.d.ts +5 -0
- package/packages/shared/src/contracts/onboarding.d.ts.map +1 -1
- package/packages/shared/src/contracts/onboarding.js +7 -6
- package/packages/shared/src/contracts/service-routing.d.ts.map +1 -1
- package/packages/shared/src/contracts/service-routing.js +1 -3
- package/packages/shared/src/contracts/wallet.d.ts +30 -103
- package/packages/shared/src/contracts/wallet.d.ts.map +1 -1
- package/packages/shared/src/env-utils.impl.d.ts.map +1 -1
- package/packages/shared/src/env-utils.impl.js +1 -8
- package/packages/shared/src/i18n/keyword-matching.d.ts.map +1 -1
- package/packages/shared/src/i18n/validation-keywords.d.ts +1 -1
- package/packages/shared/src/i18n/validation-keywords.d.ts.map +1 -1
- package/packages/shared/src/i18n/validation-keywords.js +1 -1
- package/packages/shared/src/index.d.ts +3 -3
- package/packages/shared/src/index.d.ts.map +1 -1
- package/packages/shared/src/index.js +3 -3
- package/packages/shared/src/onboarding-presets.characters.d.ts.map +1 -1
- package/packages/shared/src/onboarding-presets.characters.js +15 -5
- package/packages/shared/src/onboarding-presets.d.ts.map +1 -1
- package/packages/shared/src/onboarding-presets.js +5 -1
- package/packages/shared/src/runtime-env.d.ts.map +1 -1
- package/packages/shared/src/runtime-env.js +2 -7
- package/packages/shared/src/settings-debug.d.ts.map +1 -1
- package/packages/shared/src/settings-debug.js +1 -3
- package/packages/skills/src/formatter.d.ts +44 -0
- package/packages/skills/src/formatter.d.ts.map +1 -0
- package/packages/skills/src/formatter.js +181 -0
- package/packages/skills/src/frontmatter.d.ts +51 -0
- package/packages/skills/src/frontmatter.d.ts.map +1 -0
- package/packages/skills/src/frontmatter.js +155 -0
- package/packages/skills/src/index.d.ts +29 -0
- package/packages/skills/src/index.d.ts.map +1 -0
- package/packages/skills/src/index.js +31 -0
- package/packages/skills/src/loader.d.ts +33 -0
- package/packages/skills/src/loader.d.ts.map +1 -0
- package/packages/skills/src/loader.js +369 -0
- package/packages/skills/src/resolver.d.ts +35 -0
- package/packages/skills/src/resolver.d.ts.map +1 -0
- package/packages/skills/src/resolver.js +146 -0
- package/packages/skills/src/types.d.ts +238 -0
- package/packages/skills/src/types.d.ts.map +1 -0
- package/packages/skills/src/types.js +1 -0
- package/packages/typescript/src/action-docs.d.ts.map +1 -1
- package/packages/typescript/src/action-docs.js +2 -0
- package/packages/typescript/src/actions.d.ts.map +1 -1
- package/packages/typescript/src/actions.js +8 -3
- package/packages/typescript/src/database/inMemoryAdapter.js +1 -1
- package/packages/typescript/src/features/advanced-capabilities/evaluators/factRefinement.d.ts +20 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/factRefinement.d.ts.map +1 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/factRefinement.js +362 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/index.d.ts +3 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/index.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-capabilities/evaluators/index.js +3 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/reflection.js +1 -1
- package/packages/typescript/src/features/advanced-capabilities/evaluators/relationshipExtraction.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-capabilities/evaluators/relationshipExtraction.js +21 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/skillExtraction.d.ts +25 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/skillExtraction.d.ts.map +1 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/skillExtraction.js +367 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/skillRefinement.d.ts +21 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/skillRefinement.d.ts.map +1 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/skillRefinement.js +545 -0
- package/packages/typescript/src/features/advanced-capabilities/form/service.d.ts +1 -5
- package/packages/typescript/src/features/advanced-capabilities/form/service.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-capabilities/form/service.js +1 -13
- package/packages/typescript/src/features/advanced-capabilities/form/types.d.ts +3 -2
- package/packages/typescript/src/features/advanced-capabilities/form/types.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-capabilities/providers/facts.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-capabilities/providers/facts.js +68 -14
- package/packages/typescript/src/features/advanced-memory/services/memory-service.d.ts +1 -0
- package/packages/typescript/src/features/advanced-memory/services/memory-service.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-memory/services/memory-service.js +31 -11
- package/packages/typescript/src/features/autonomy/execution-facade.d.ts +1 -1
- package/packages/typescript/src/features/autonomy/execution-facade.d.ts.map +1 -1
- package/packages/typescript/src/features/autonomy/execution-facade.js +3 -3
- package/packages/typescript/src/features/basic-capabilities/actions/none.js +1 -1
- package/packages/typescript/src/features/basic-capabilities/index.d.ts.map +1 -1
- package/packages/typescript/src/features/basic-capabilities/index.js +9 -3
- package/packages/typescript/src/features/plugin-manager/coreExtensions.d.ts +4 -11
- package/packages/typescript/src/features/plugin-manager/coreExtensions.d.ts.map +1 -1
- package/packages/typescript/src/features/plugin-manager/coreExtensions.js +0 -23
- package/packages/typescript/src/features/plugin-manager/index.d.ts +1 -1
- package/packages/typescript/src/features/plugin-manager/index.d.ts.map +1 -1
- package/packages/typescript/src/features/plugin-manager/index.js +1 -1
- package/packages/typescript/src/features/plugin-manager/providers/relevance.d.ts.map +1 -1
- package/packages/typescript/src/features/plugin-manager/providers/relevance.js +1 -3
- package/packages/typescript/src/features/trajectories/TrajectoriesService.d.ts +13 -0
- package/packages/typescript/src/features/trajectories/TrajectoriesService.d.ts.map +1 -1
- package/packages/typescript/src/features/trajectories/TrajectoriesService.js +12 -9
- package/packages/typescript/src/features/trajectories/integration.d.ts +1 -1
- package/packages/typescript/src/features/trajectories/integration.d.ts.map +1 -1
- package/packages/typescript/src/features/trajectories/types.d.ts +19 -1
- package/packages/typescript/src/features/trajectories/types.d.ts.map +1 -1
- package/packages/typescript/src/features/trust/index.d.ts +3 -52
- package/packages/typescript/src/features/trust/index.d.ts.map +1 -1
- package/packages/typescript/src/features/trust/index.js +5 -122
- package/packages/typescript/src/features/trust/services/wrappers.d.ts +56 -0
- package/packages/typescript/src/features/trust/services/wrappers.d.ts.map +1 -0
- package/packages/typescript/src/features/trust/services/wrappers.js +124 -0
- package/packages/typescript/src/generated/action-docs.d.ts +207 -3
- package/packages/typescript/src/generated/action-docs.d.ts.map +1 -1
- package/packages/typescript/src/generated/action-docs.js +271 -2
- package/packages/typescript/src/index.node.d.ts +3 -0
- package/packages/typescript/src/index.node.d.ts.map +1 -1
- package/packages/typescript/src/index.node.js +6 -0
- package/packages/typescript/src/optimization/ab-analysis.d.ts +1 -1
- package/packages/typescript/src/optimization/ab-analysis.d.ts.map +1 -1
- package/packages/typescript/src/optimization/ab-analysis.js +1 -1
- package/packages/typescript/src/optimization-root-dir.d.ts +6 -1
- package/packages/typescript/src/optimization-root-dir.d.ts.map +1 -1
- package/packages/typescript/src/optimization-root-dir.js +6 -1
- package/packages/typescript/src/prompts.d.ts +2 -2
- package/packages/typescript/src/prompts.d.ts.map +1 -1
- package/packages/typescript/src/prompts.js +4 -1
- package/packages/typescript/src/runtime.d.ts +3 -0
- package/packages/typescript/src/runtime.d.ts.map +1 -1
- package/packages/typescript/src/runtime.js +20 -5
- package/packages/typescript/src/schemas/character.d.ts +1 -1
- package/packages/typescript/src/schemas/character.d.ts.map +1 -1
- package/packages/typescript/src/schemas/character.js +1 -1
- package/packages/typescript/src/schemas/entity-identity.d.ts +29 -0
- package/packages/typescript/src/schemas/entity-identity.d.ts.map +1 -0
- package/packages/typescript/src/schemas/entity-identity.js +334 -0
- package/packages/typescript/src/schemas/index.d.ts +3 -1
- package/packages/typescript/src/schemas/index.d.ts.map +1 -1
- package/packages/typescript/src/schemas/index.js +2 -1
- package/packages/typescript/src/search.d.ts +0 -22
- package/packages/typescript/src/search.d.ts.map +1 -1
- package/packages/typescript/src/services/message.d.ts +11 -0
- package/packages/typescript/src/services/message.d.ts.map +1 -1
- package/packages/typescript/src/services/message.js +63 -36
- package/packages/typescript/src/services/optimized-prompt-resolver.d.ts +23 -0
- package/packages/typescript/src/services/optimized-prompt-resolver.d.ts.map +1 -0
- package/packages/typescript/src/services/optimized-prompt-resolver.js +50 -0
- package/packages/typescript/src/services/optimized-prompt.d.ts +117 -0
- package/packages/typescript/src/services/optimized-prompt.d.ts.map +1 -0
- package/packages/typescript/src/services/optimized-prompt.js +262 -0
- package/packages/typescript/src/services/relationships.d.ts +225 -0
- package/packages/typescript/src/services/relationships.d.ts.map +1 -1
- package/packages/typescript/src/services/relationships.js +979 -3
- package/packages/typescript/src/services/trajectories.d.ts +9 -0
- package/packages/typescript/src/services/trajectories.d.ts.map +1 -1
- package/packages/typescript/src/trajectory-context.d.ts +7 -0
- package/packages/typescript/src/trajectory-context.d.ts.map +1 -1
- package/packages/typescript/src/trajectory-utils.d.ts +24 -0
- package/packages/typescript/src/trajectory-utils.d.ts.map +1 -1
- package/packages/typescript/src/trajectory-utils.js +19 -0
- package/packages/typescript/src/types/components.d.ts +6 -0
- package/packages/typescript/src/types/components.d.ts.map +1 -1
- package/packages/typescript/src/types/plugin.d.ts +11 -0
- package/packages/typescript/src/types/plugin.d.ts.map +1 -1
- package/packages/typescript/src/types/runtime.d.ts +12 -0
- package/packages/typescript/src/types/runtime.d.ts.map +1 -1
- package/packages/typescript/src/types/service.d.ts +2 -0
- package/packages/typescript/src/types/service.d.ts.map +1 -1
- package/packages/typescript/src/types/service.js +1 -0
- package/packages/typescript/src/types/trigger.d.ts +4 -0
- package/packages/typescript/src/types/trigger.d.ts.map +1 -1
- package/packages/typescript/src/utils/batch-queue/batch-processor.d.ts +2 -3
- package/packages/typescript/src/utils/batch-queue/batch-processor.d.ts.map +1 -1
- package/packages/typescript/src/utils/batch-queue/batch-processor.js +0 -3
- package/packages/typescript/src/utils/crypto-compat.js +1 -1
- package/packages/typescript/src/utils/union-find.d.ts +30 -0
- package/packages/typescript/src/utils/union-find.d.ts.map +1 -0
- package/packages/typescript/src/utils/union-find.js +81 -0
- package/packages/typescript/src/utils.d.ts +1 -0
- package/packages/typescript/src/utils.d.ts.map +1 -1
- package/packages/typescript/src/utils.js +5 -1
- package/apps/app-lifeops/src/actions/inbox-digest.d.ts +0 -2
- package/apps/app-lifeops/src/actions/inbox-digest.d.ts.map +0 -1
- package/apps/app-lifeops/src/actions/inbox-digest.js +0 -1
- package/apps/app-lifeops/src/actions/inbox-respond.d.ts +0 -2
- package/apps/app-lifeops/src/actions/inbox-respond.d.ts.map +0 -1
- package/apps/app-lifeops/src/actions/inbox-respond.js +0 -1
- package/apps/app-lifeops/src/actions/inbox-triage.d.ts +0 -2
- package/apps/app-lifeops/src/actions/inbox-triage.d.ts.map +0 -1
- package/apps/app-lifeops/src/actions/inbox-triage.js +0 -1
- package/apps/app-lifeops/src/lifeops/index.d.ts +0 -25
- package/apps/app-lifeops/src/lifeops/index.d.ts.map +0 -1
- package/apps/app-lifeops/src/lifeops/index.js +0 -24
- package/apps/app-lifeops/src/selfcontrol/access.d.ts +0 -8
- package/apps/app-lifeops/src/selfcontrol/access.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/access.js +0 -16
- package/apps/app-lifeops/src/selfcontrol/action.d.ts +0 -10
- package/apps/app-lifeops/src/selfcontrol/action.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/action.js +0 -506
- package/apps/app-lifeops/src/selfcontrol/index.d.ts +0 -13
- package/apps/app-lifeops/src/selfcontrol/index.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/index.js +0 -10
- package/apps/app-lifeops/src/selfcontrol/permissions.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/provider.d.ts +0 -4
- package/apps/app-lifeops/src/selfcontrol/provider.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/provider.js +0 -116
- package/apps/app-lifeops/src/selfcontrol/roles.d.ts +0 -19
- package/apps/app-lifeops/src/selfcontrol/roles.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/roles.js +0 -41
- package/apps/app-lifeops/src/selfcontrol/selfcontrol.d.ts +0 -97
- package/apps/app-lifeops/src/selfcontrol/selfcontrol.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/selfcontrol.js +0 -949
- package/apps/app-lifeops/src/selfcontrol/service.d.ts +0 -21
- package/apps/app-lifeops/src/selfcontrol/service.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/service.js +0 -268
- package/packages/agent/src/actions/calendar.d.ts +0 -2
- package/packages/agent/src/actions/calendar.d.ts.map +0 -1
- package/packages/agent/src/actions/calendar.js +0 -1
- package/packages/agent/src/actions/check-balance.d.ts +0 -17
- package/packages/agent/src/actions/check-balance.d.ts.map +0 -1
- package/packages/agent/src/actions/check-balance.js +0 -167
- package/packages/agent/src/actions/execute-trade.d.ts +0 -17
- package/packages/agent/src/actions/execute-trade.d.ts.map +0 -1
- package/packages/agent/src/actions/execute-trade.js +0 -299
- package/packages/agent/src/actions/gmail.d.ts +0 -2
- package/packages/agent/src/actions/gmail.d.ts.map +0 -1
- package/packages/agent/src/actions/gmail.js +0 -1
- package/packages/agent/src/actions/inbox-digest.d.ts +0 -2
- package/packages/agent/src/actions/inbox-digest.d.ts.map +0 -1
- package/packages/agent/src/actions/inbox-digest.js +0 -1
- package/packages/agent/src/actions/inbox-respond.d.ts +0 -2
- package/packages/agent/src/actions/inbox-respond.d.ts.map +0 -1
- package/packages/agent/src/actions/inbox-respond.js +0 -1
- package/packages/agent/src/actions/inbox-triage.d.ts +0 -2
- package/packages/agent/src/actions/inbox-triage.d.ts.map +0 -1
- package/packages/agent/src/actions/inbox-triage.js +0 -1
- package/packages/agent/src/actions/inbox.d.ts +0 -2
- package/packages/agent/src/actions/inbox.d.ts.map +0 -1
- package/packages/agent/src/actions/inbox.js +0 -1
- package/packages/agent/src/actions/life-goal-extractor.d.ts +0 -2
- package/packages/agent/src/actions/life-goal-extractor.d.ts.map +0 -1
- package/packages/agent/src/actions/life-goal-extractor.js +0 -1
- package/packages/agent/src/actions/life-param-extractor.d.ts +0 -2
- package/packages/agent/src/actions/life-param-extractor.d.ts.map +0 -1
- package/packages/agent/src/actions/life-param-extractor.js +0 -1
- package/packages/agent/src/actions/life-recent-context.d.ts +0 -2
- package/packages/agent/src/actions/life-recent-context.d.ts.map +0 -1
- package/packages/agent/src/actions/life-recent-context.js +0 -1
- package/packages/agent/src/actions/life-update-extractor.d.ts +0 -2
- package/packages/agent/src/actions/life-update-extractor.d.ts.map +0 -1
- package/packages/agent/src/actions/life-update-extractor.js +0 -1
- package/packages/agent/src/actions/life.d.ts +0 -2
- package/packages/agent/src/actions/life.d.ts.map +0 -1
- package/packages/agent/src/actions/life.extractor.d.ts +0 -2
- package/packages/agent/src/actions/life.extractor.d.ts.map +0 -1
- package/packages/agent/src/actions/life.extractor.js +0 -1
- package/packages/agent/src/actions/life.js +0 -1
- package/packages/agent/src/actions/lifeops-extraction-config.d.ts +0 -2
- package/packages/agent/src/actions/lifeops-extraction-config.d.ts.map +0 -1
- package/packages/agent/src/actions/lifeops-extraction-config.js +0 -1
- package/packages/agent/src/actions/lifeops-google-helpers.d.ts +0 -2
- package/packages/agent/src/actions/lifeops-google-helpers.d.ts.map +0 -1
- package/packages/agent/src/actions/lifeops-google-helpers.js +0 -1
- package/packages/agent/src/actions/timezone-normalization.d.ts +0 -2
- package/packages/agent/src/actions/timezone-normalization.d.ts.map +0 -1
- package/packages/agent/src/actions/timezone-normalization.js +0 -1
- package/packages/agent/src/actions/transfer-token.d.ts +0 -17
- package/packages/agent/src/actions/transfer-token.d.ts.map +0 -1
- package/packages/agent/src/actions/transfer-token.js +0 -470
- package/packages/agent/src/actions/update-owner-profile.d.ts +0 -2
- package/packages/agent/src/actions/update-owner-profile.d.ts.map +0 -1
- package/packages/agent/src/actions/update-owner-profile.js +0 -1
- package/packages/agent/src/actions/wallet-action-shared.d.ts +0 -15
- package/packages/agent/src/actions/wallet-action-shared.d.ts.map +0 -1
- package/packages/agent/src/actions/wallet-action-shared.js +0 -24
- package/packages/agent/src/activity-profile/analyzer.d.ts.map +0 -1
- package/packages/agent/src/activity-profile/analyzer.js +0 -531
- package/packages/agent/src/activity-profile/proactive-planner.d.ts.map +0 -1
- package/packages/agent/src/activity-profile/proactive-planner.js +0 -455
- package/packages/agent/src/activity-profile/proactive-worker.d.ts.map +0 -1
- package/packages/agent/src/activity-profile/proactive-worker.js +0 -523
- package/packages/agent/src/activity-profile/profile-metadata.d.ts.map +0 -1
- package/packages/agent/src/activity-profile/service.d.ts +0 -11
- package/packages/agent/src/activity-profile/service.d.ts.map +0 -1
- package/packages/agent/src/activity-profile/service.js +0 -226
- package/packages/agent/src/activity-profile/types.d.ts.map +0 -1
- package/packages/agent/src/api/coding-agents-auth-sanitize.d.ts +0 -2
- package/packages/agent/src/api/coding-agents-auth-sanitize.d.ts.map +0 -1
- package/packages/agent/src/api/coding-agents-auth-sanitize.js +0 -1
- package/packages/agent/src/api/coding-agents-preflight-normalize.d.ts +0 -2
- package/packages/agent/src/api/coding-agents-preflight-normalize.d.ts.map +0 -1
- package/packages/agent/src/api/coding-agents-preflight-normalize.js +0 -1
- package/packages/agent/src/api/coordinator-types.d.ts +0 -2
- package/packages/agent/src/api/coordinator-types.d.ts.map +0 -1
- package/packages/agent/src/api/coordinator-types.js +0 -1
- package/packages/agent/src/api/coordinator-wiring.d.ts +0 -2
- package/packages/agent/src/api/coordinator-wiring.d.ts.map +0 -1
- package/packages/agent/src/api/coordinator-wiring.js +0 -1
- package/packages/agent/src/api/drop-routes.d.ts +0 -22
- package/packages/agent/src/api/drop-routes.d.ts.map +0 -1
- package/packages/agent/src/api/drop-service.d.ts +0 -26
- package/packages/agent/src/api/drop-service.d.ts.map +0 -1
- package/packages/agent/src/api/lifeops-routes.d.ts +0 -2
- package/packages/agent/src/api/lifeops-routes.d.ts.map +0 -1
- package/packages/agent/src/api/lifeops-routes.js +0 -1
- package/packages/agent/src/api/merkle-tree.d.ts.map +0 -1
- package/packages/agent/src/api/nft-verify.d.ts +0 -16
- package/packages/agent/src/api/nft-verify.d.ts.map +0 -1
- package/packages/agent/src/api/nft-verify.js +0 -81
- package/packages/agent/src/api/og-tracker.d.ts.map +0 -1
- package/packages/agent/src/api/og-tracker.js +0 -60
- package/packages/agent/src/api/task-agent-message-routing.d.ts +0 -2
- package/packages/agent/src/api/task-agent-message-routing.d.ts.map +0 -1
- package/packages/agent/src/api/task-agent-message-routing.js +0 -1
- package/packages/agent/src/api/twitter-verify.d.ts +0 -25
- package/packages/agent/src/api/twitter-verify.d.ts.map +0 -1
- package/packages/agent/src/api/twitter-verify.js +0 -168
- package/packages/agent/src/api/website-blocker-routes.d.ts +0 -2
- package/packages/agent/src/api/website-blocker-routes.d.ts.map +0 -1
- package/packages/agent/src/api/website-blocker-routes.js +0 -1
- package/packages/agent/src/config/runtime-env.d.ts +0 -2
- package/packages/agent/src/config/runtime-env.d.ts.map +0 -1
- package/packages/agent/src/config/runtime-env.js +0 -1
- package/packages/agent/src/evals/coordinator-eval-client.d.ts +0 -2
- package/packages/agent/src/evals/coordinator-eval-client.d.ts.map +0 -1
- package/packages/agent/src/evals/coordinator-eval-client.js +0 -1
- package/packages/agent/src/evals/coordinator-live-runner.d.ts +0 -2
- package/packages/agent/src/evals/coordinator-live-runner.d.ts.map +0 -1
- package/packages/agent/src/evals/coordinator-live-runner.js +0 -1
- package/packages/agent/src/evals/coordinator-preflight.d.ts +0 -2
- package/packages/agent/src/evals/coordinator-preflight.d.ts.map +0 -1
- package/packages/agent/src/evals/coordinator-preflight.js +0 -1
- package/packages/agent/src/evals/coordinator-scenarios.d.ts +0 -2
- package/packages/agent/src/evals/coordinator-scenarios.d.ts.map +0 -1
- package/packages/agent/src/evals/coordinator-scenarios.js +0 -1
- package/packages/agent/src/lifeops/app-state.d.ts +0 -2
- package/packages/agent/src/lifeops/app-state.d.ts.map +0 -1
- package/packages/agent/src/lifeops/app-state.js +0 -1
- package/packages/agent/src/lifeops/apple-reminders.d.ts +0 -2
- package/packages/agent/src/lifeops/apple-reminders.d.ts.map +0 -1
- package/packages/agent/src/lifeops/apple-reminders.js +0 -1
- package/packages/agent/src/lifeops/defaults.d.ts +0 -2
- package/packages/agent/src/lifeops/defaults.d.ts.map +0 -1
- package/packages/agent/src/lifeops/defaults.js +0 -1
- package/packages/agent/src/lifeops/engine.d.ts +0 -2
- package/packages/agent/src/lifeops/engine.d.ts.map +0 -1
- package/packages/agent/src/lifeops/engine.js +0 -1
- package/packages/agent/src/lifeops/goal-grounding.d.ts +0 -2
- package/packages/agent/src/lifeops/goal-grounding.d.ts.map +0 -1
- package/packages/agent/src/lifeops/goal-grounding.js +0 -1
- package/packages/agent/src/lifeops/goal-semantic-evaluator.d.ts +0 -2
- package/packages/agent/src/lifeops/goal-semantic-evaluator.d.ts.map +0 -1
- package/packages/agent/src/lifeops/goal-semantic-evaluator.js +0 -1
- package/packages/agent/src/lifeops/google-api-error.d.ts +0 -2
- package/packages/agent/src/lifeops/google-api-error.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-api-error.js +0 -1
- package/packages/agent/src/lifeops/google-calendar.d.ts +0 -2
- package/packages/agent/src/lifeops/google-calendar.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-calendar.js +0 -1
- package/packages/agent/src/lifeops/google-connector-gateway.d.ts +0 -2
- package/packages/agent/src/lifeops/google-connector-gateway.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-connector-gateway.js +0 -1
- package/packages/agent/src/lifeops/google-fetch.d.ts +0 -2
- package/packages/agent/src/lifeops/google-fetch.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-fetch.js +0 -1
- package/packages/agent/src/lifeops/google-gmail.d.ts +0 -2
- package/packages/agent/src/lifeops/google-gmail.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-gmail.js +0 -1
- package/packages/agent/src/lifeops/google-managed-client.d.ts +0 -2
- package/packages/agent/src/lifeops/google-managed-client.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-managed-client.js +0 -1
- package/packages/agent/src/lifeops/google-oauth.d.ts +0 -2
- package/packages/agent/src/lifeops/google-oauth.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-oauth.js +0 -1
- package/packages/agent/src/lifeops/google-scopes.d.ts +0 -2
- package/packages/agent/src/lifeops/google-scopes.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-scopes.js +0 -1
- package/packages/agent/src/lifeops/index.d.ts +0 -2
- package/packages/agent/src/lifeops/index.d.ts.map +0 -1
- package/packages/agent/src/lifeops/index.js +0 -1
- package/packages/agent/src/lifeops/owner-profile.d.ts +0 -2
- package/packages/agent/src/lifeops/owner-profile.d.ts.map +0 -1
- package/packages/agent/src/lifeops/owner-profile.js +0 -1
- package/packages/agent/src/lifeops/repository.d.ts +0 -2
- package/packages/agent/src/lifeops/repository.d.ts.map +0 -1
- package/packages/agent/src/lifeops/repository.js +0 -1
- package/packages/agent/src/lifeops/runtime.d.ts +0 -2
- package/packages/agent/src/lifeops/runtime.d.ts.map +0 -1
- package/packages/agent/src/lifeops/runtime.js +0 -1
- package/packages/agent/src/lifeops/screen-context.d.ts +0 -2
- package/packages/agent/src/lifeops/screen-context.d.ts.map +0 -1
- package/packages/agent/src/lifeops/screen-context.js +0 -1
- package/packages/agent/src/lifeops/seed-routines.d.ts +0 -2
- package/packages/agent/src/lifeops/seed-routines.d.ts.map +0 -1
- package/packages/agent/src/lifeops/seed-routines.js +0 -1
- package/packages/agent/src/lifeops/service.d.ts +0 -2
- package/packages/agent/src/lifeops/service.d.ts.map +0 -1
- package/packages/agent/src/lifeops/service.js +0 -1
- package/packages/agent/src/lifeops/sql.d.ts +0 -2
- package/packages/agent/src/lifeops/sql.d.ts.map +0 -1
- package/packages/agent/src/lifeops/sql.js +0 -1
- package/packages/agent/src/lifeops/time.d.ts +0 -2
- package/packages/agent/src/lifeops/time.d.ts.map +0 -1
- package/packages/agent/src/lifeops/time.js +0 -1
- package/packages/agent/src/lifeops/twilio.d.ts +0 -2
- package/packages/agent/src/lifeops/twilio.d.ts.map +0 -1
- package/packages/agent/src/lifeops/twilio.js +0 -1
- package/packages/agent/src/lifeops/x-poster.d.ts +0 -2
- package/packages/agent/src/lifeops/x-poster.d.ts.map +0 -1
- package/packages/agent/src/lifeops/x-poster.js +0 -1
- package/packages/agent/src/providers/activity-profile.d.ts.map +0 -1
- package/packages/agent/src/providers/activity-profile.js +0 -140
- package/packages/agent/src/providers/inbox-triage.d.ts +0 -2
- package/packages/agent/src/providers/inbox-triage.d.ts.map +0 -1
- package/packages/agent/src/providers/inbox-triage.js +0 -1
- package/packages/agent/src/providers/lifeops.d.ts +0 -2
- package/packages/agent/src/providers/lifeops.d.ts.map +0 -1
- package/packages/agent/src/providers/lifeops.js +0 -1
- package/packages/agent/src/utils/spoken-text.d.ts +0 -2
- package/packages/agent/src/utils/spoken-text.d.ts.map +0 -1
- package/packages/agent/src/utils/spoken-text.js +0 -1
- package/packages/app-core/src/config/config.d.ts +0 -12
- package/packages/app-core/src/config/config.d.ts.map +0 -1
- package/packages/app-core/src/config/config.js +0 -23
- package/packages/app-core/src/types/index.d.ts +0 -649
- package/packages/app-core/src/types/index.d.ts.map +0 -1
- package/packages/app-core/src/types/lifeops-ui.d.ts +0 -10
- package/packages/app-core/src/types/lifeops-ui.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/append.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/append.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/append.js +0 -150
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/delete.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/delete.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/delete.js +0 -136
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/list.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/list.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/list.js +0 -84
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read-attachment.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read-attachment.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read-attachment.js +0 -107
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read-file.d.ts +0 -16
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read-file.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read-file.js +0 -187
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read.js +0 -138
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/remove-from-clipboard.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/remove-from-clipboard.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/remove-from-clipboard.js +0 -96
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/search.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/search.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/search.js +0 -139
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/write.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/write.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/write.js +0 -138
- package/packages/typescript/src/advanced-capabilities/clipboard/index.d.ts +0 -39
- package/packages/typescript/src/advanced-capabilities/clipboard/index.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/index.js +0 -78
- package/packages/typescript/src/advanced-capabilities/clipboard/providers/clipboard.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/providers/clipboard.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/providers/clipboard.js +0 -62
- package/packages/typescript/src/advanced-capabilities/clipboard/services/attachmentContext.d.ts +0 -16
- package/packages/typescript/src/advanced-capabilities/clipboard/services/attachmentContext.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/services/attachmentContext.js +0 -162
- package/packages/typescript/src/advanced-capabilities/clipboard/services/clipboardService.d.ts +0 -65
- package/packages/typescript/src/advanced-capabilities/clipboard/services/clipboardService.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/services/clipboardService.js +0 -352
- package/packages/typescript/src/advanced-capabilities/clipboard/services/taskClipboardPersistence.d.ts +0 -24
- package/packages/typescript/src/advanced-capabilities/clipboard/services/taskClipboardPersistence.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/services/taskClipboardPersistence.js +0 -63
- package/packages/typescript/src/advanced-capabilities/clipboard/services/taskClipboardService.d.ts +0 -29
- package/packages/typescript/src/advanced-capabilities/clipboard/services/taskClipboardService.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/services/taskClipboardService.js +0 -195
- package/packages/typescript/src/advanced-capabilities/clipboard/specs.d.ts +0 -15
- package/packages/typescript/src/advanced-capabilities/clipboard/specs.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/specs.js +0 -164
- package/packages/typescript/src/advanced-capabilities/clipboard/types.d.ts +0 -92
- package/packages/typescript/src/advanced-capabilities/clipboard/types.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/types.js +0 -4
- package/packages/typescript/src/index.d.ts +0 -12
- package/packages/typescript/src/index.d.ts.map +0 -1
- package/packages/typescript/src/index.js +0 -13
- /package/{packages/agent/src/api → apps/app-elizamaker/src}/drop-routes.js +0 -0
- /package/{packages/agent/src/api → apps/app-elizamaker/src}/drop-service.js +0 -0
- /package/{packages/agent/src/api → apps/app-elizamaker/src}/merkle-tree.d.ts +0 -0
- /package/{packages/agent/src/api → apps/app-elizamaker/src}/merkle-tree.js +0 -0
- /package/{packages/agent/src/api → apps/app-elizamaker/src}/og-tracker.d.ts +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/analyzer.d.ts +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/proactive-planner.d.ts +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/proactive-worker.d.ts +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/profile-metadata.d.ts +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/profile-metadata.js +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/types.d.ts +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/types.js +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/providers/activity-profile.d.ts +0 -0
- /package/apps/app-lifeops/src/{selfcontrol/permissions.js → types/app-blocker-settings-card.js} +0 -0
- /package/{packages/app-core → apps/app-lifeops}/src/types/index.js +0 -0
- /package/{packages/app-core/src/types/lifeops-ui.js → apps/app-lifeops/src/types/website-blocker-settings-card.js} +0 -0
- /package/apps/app-lifeops/src/{selfcontrol → website-blocker}/permissions.d.ts +0 -0
|
@@ -0,0 +1,2436 @@
|
|
|
1
|
+
// @ts-nocheck — mixin: type safety is enforced on the composed class
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
import { ModelType } from "@elizaos/core";
|
|
4
|
+
import { LIFEOPS_CHANNEL_TYPES, } from "@elizaos/shared/contracts/lifeops";
|
|
5
|
+
import { getSelfControlStatus, startSelfControlBlock, stopSelfControlBlock, } from "../website-blocker/engine.js";
|
|
6
|
+
import { readProfileFromMetadata } from "../activity-profile/service.js";
|
|
7
|
+
import { loadOwnerContactRoutingHints, loadOwnerContactsConfig, resolveOwnerContactWithFallback, } from "@elizaos/agent/config/owner-contacts";
|
|
8
|
+
import { registerEscalationChannel } from "@elizaos/agent/services/escalation";
|
|
9
|
+
import { buildNativeAppleReminderMetadata, createNativeAppleReminderLikeItem, deleteNativeAppleReminderLikeItem, readNativeAppleReminderMetadata, updateNativeAppleReminderLikeItem, } from "./apple-reminders.js";
|
|
10
|
+
import { computeAdaptiveWindowPolicy, windowPolicyMatchesDefaults, } from "./defaults.js";
|
|
11
|
+
import { materializeDefinitionOccurrences } from "./engine.js";
|
|
12
|
+
import { computeDefinitionPerformance } from "./service-helpers-occurrence.js";
|
|
13
|
+
import { createLifeOpsActivitySignal, createLifeOpsChannelPolicy, createLifeOpsReminderAttempt, createLifeOpsReminderPlan, createLifeOpsWebsiteAccessGrant, } from "./repository.js";
|
|
14
|
+
import { fail, lifeOpsErrorMessage, normalizeEnumValue, requireNonEmptyString, } from "./service-normalize.js";
|
|
15
|
+
import { addMinutes } from "./time.js";
|
|
16
|
+
import { readTwilioCredentialsFromEnv, sendTwilioSms, sendTwilioVoiceCall, } from "./twilio.js";
|
|
17
|
+
import { DEFAULT_MORNING_WINDOW, DEFAULT_NIGHT_WINDOW, getCurrentEnforcementWindow, minutesPastWindowStart, } from "./enforcement-windows.js";
|
|
18
|
+
/**
|
|
19
|
+
* Given a "normal" delay in minutes between reminder steps and the
|
|
20
|
+
* current enforcement state, return the effective delay. Inside an
|
|
21
|
+
* active enforcement window for a routine definition, once more than
|
|
22
|
+
* 10 minutes have elapsed past the window start, the gap is halved.
|
|
23
|
+
*/
|
|
24
|
+
export function applyEnforcementOverrides(normalDelayMinutes, state) {
|
|
25
|
+
if (!state || state.window.kind === "none" || !state.definitionIsRoutine) {
|
|
26
|
+
return { delayMinutes: normalDelayMinutes, forceVoice: false };
|
|
27
|
+
}
|
|
28
|
+
let delay = normalDelayMinutes;
|
|
29
|
+
if (state.minutesPastStart > 10) {
|
|
30
|
+
delay = Math.max(1, Math.floor(normalDelayMinutes / 2));
|
|
31
|
+
}
|
|
32
|
+
const forceVoice = state.twilioVoiceAvailable && state.minutesPastStart > 20;
|
|
33
|
+
return { delayMinutes: delay, forceVoice };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Determine whether a task/routine definition should trigger enforcement
|
|
37
|
+
* overrides inside a morning/night window.
|
|
38
|
+
*/
|
|
39
|
+
export function definitionTriggersEnforcement(definition) {
|
|
40
|
+
if (!definition)
|
|
41
|
+
return false;
|
|
42
|
+
if (definition.kind === "morning_routine" || definition.kind === "night_routine") {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
const metadata = definition.metadata;
|
|
46
|
+
if (metadata && metadata.enforceRoutineWindow === true)
|
|
47
|
+
return true;
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Build the enforcement state for a dispatch. Callers pass the relevant
|
|
52
|
+
* definition (may be null for calendar events) and the owner's timezone.
|
|
53
|
+
*/
|
|
54
|
+
export function buildReminderEnforcementState(now, timezone, definition, twilioVoiceAvailable, windows) {
|
|
55
|
+
const window = getCurrentEnforcementWindow(now, timezone, windows ?? [DEFAULT_MORNING_WINDOW, DEFAULT_NIGHT_WINDOW]);
|
|
56
|
+
const minutesPast = minutesPastWindowStart(now, timezone, window);
|
|
57
|
+
return {
|
|
58
|
+
window,
|
|
59
|
+
minutesPastStart: minutesPast,
|
|
60
|
+
definitionIsRoutine: definitionTriggersEnforcement(definition),
|
|
61
|
+
twilioVoiceAvailable,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// Local constants
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
const DEFAULT_REMINDER_PROCESS_LIMIT = 24;
|
|
68
|
+
const DEFAULT_WORKFLOW_PROCESS_LIMIT = 12;
|
|
69
|
+
const OVERVIEW_HORIZON_MINUTES = 18 * 60;
|
|
70
|
+
const DEFAULT_REMINDER_INTENSITY = "normal";
|
|
71
|
+
const GLOBAL_REMINDER_PREFERENCE_CHANNEL_REF = "lifeops://owner/reminder-preferences";
|
|
72
|
+
const REMINDER_INTENSITY_METADATA_KEY = "reminderIntensity";
|
|
73
|
+
const REMINDER_INTENSITY_UPDATED_AT_METADATA_KEY = "reminderIntensityUpdatedAt";
|
|
74
|
+
const REMINDER_INTENSITY_NOTE_METADATA_KEY = "reminderIntensityNote";
|
|
75
|
+
const REMINDER_PREFERENCE_SCOPE_METADATA_KEY = "reminderPreferenceScope";
|
|
76
|
+
const REMINDER_LIFECYCLE_METADATA_KEY = "lifecycle";
|
|
77
|
+
const REMINDER_ESCALATION_INDEX_METADATA_KEY = "escalationIndex";
|
|
78
|
+
const REMINDER_ESCALATION_REASON_METADATA_KEY = "escalationReason";
|
|
79
|
+
const REMINDER_ESCALATION_ACTIVITY_PLATFORM_METADATA_KEY = "activityPlatform";
|
|
80
|
+
const REMINDER_ESCALATION_ACTIVITY_ACTIVE_METADATA_KEY = "activityActive";
|
|
81
|
+
const REMINDER_ESCALATION_STARTED_AT_METADATA_KEY = "reminderEscalationStartedAt";
|
|
82
|
+
const REMINDER_ESCALATION_LAST_ATTEMPT_AT_METADATA_KEY = "reminderEscalationLastAttemptAt";
|
|
83
|
+
const REMINDER_ESCALATION_LAST_CHANNEL_METADATA_KEY = "reminderEscalationLastChannel";
|
|
84
|
+
const REMINDER_ESCALATION_LAST_OUTCOME_METADATA_KEY = "reminderEscalationLastOutcome";
|
|
85
|
+
const REMINDER_ESCALATION_CHANNELS_METADATA_KEY = "reminderEscalationChannels";
|
|
86
|
+
const REMINDER_ESCALATION_RESOLVED_AT_METADATA_KEY = "reminderEscalationResolvedAt";
|
|
87
|
+
const REMINDER_ESCALATION_RESOLUTION_METADATA_KEY = "reminderEscalationResolution";
|
|
88
|
+
const REMINDER_ESCALATION_RESOLUTION_NOTE_METADATA_KEY = "reminderEscalationResolutionNote";
|
|
89
|
+
const PROACTIVE_TASK_QUERY_TAGS = ["queue", "repeat", "proactive"];
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
// Local helpers (copied from service.ts)
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
function isRecord(value) {
|
|
94
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
95
|
+
}
|
|
96
|
+
function normalizeOptionalString(value) {
|
|
97
|
+
if (value === undefined || value === null)
|
|
98
|
+
return undefined;
|
|
99
|
+
if (typeof value !== "string")
|
|
100
|
+
return undefined;
|
|
101
|
+
const trimmed = value.trim();
|
|
102
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
103
|
+
}
|
|
104
|
+
function mergeMetadata(current, updates) {
|
|
105
|
+
const cloned = updates && typeof updates === "object" && !Array.isArray(updates)
|
|
106
|
+
? { ...updates }
|
|
107
|
+
: {};
|
|
108
|
+
return { ...current, ...cloned };
|
|
109
|
+
}
|
|
110
|
+
function requireRecord(value, field) {
|
|
111
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
112
|
+
fail(400, `${field} must be an object`);
|
|
113
|
+
}
|
|
114
|
+
return { ...value };
|
|
115
|
+
}
|
|
116
|
+
function normalizeOptionalBoolean(value, field) {
|
|
117
|
+
if (value === undefined || value === null)
|
|
118
|
+
return null;
|
|
119
|
+
if (typeof value === "boolean")
|
|
120
|
+
return value;
|
|
121
|
+
if (value === "true")
|
|
122
|
+
return true;
|
|
123
|
+
if (value === "false")
|
|
124
|
+
return false;
|
|
125
|
+
fail(400, `${field} must be a boolean`);
|
|
126
|
+
}
|
|
127
|
+
function normalizeIsoString(value, field) {
|
|
128
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
129
|
+
fail(400, `${field} must be an ISO 8601 string`);
|
|
130
|
+
}
|
|
131
|
+
const ms = Date.parse(value);
|
|
132
|
+
if (!Number.isFinite(ms)) {
|
|
133
|
+
fail(400, `${field} must be a valid ISO 8601 string`);
|
|
134
|
+
}
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
function normalizeOptionalIsoString(value, field) {
|
|
138
|
+
if (value === undefined || value === null)
|
|
139
|
+
return null;
|
|
140
|
+
return normalizeIsoString(value, field);
|
|
141
|
+
}
|
|
142
|
+
function normalizePositiveInteger(value, field) {
|
|
143
|
+
const num = typeof value === "string" ? Number(value) : value;
|
|
144
|
+
if (typeof num !== "number" || !Number.isInteger(num) || num < 1) {
|
|
145
|
+
fail(400, `${field} must be a positive integer`);
|
|
146
|
+
}
|
|
147
|
+
return num;
|
|
148
|
+
}
|
|
149
|
+
function normalizeOptionalNonNegativeInteger(value, field) {
|
|
150
|
+
if (value === undefined || value === null)
|
|
151
|
+
return null;
|
|
152
|
+
const num = typeof value === "string" ? Number(value) : value;
|
|
153
|
+
if (typeof num !== "number" || !Number.isInteger(num) || num < 0) {
|
|
154
|
+
fail(400, `${field} must be a non-negative integer`);
|
|
155
|
+
}
|
|
156
|
+
return num;
|
|
157
|
+
}
|
|
158
|
+
function normalizeOptionalRecord(value, field) {
|
|
159
|
+
if (value === undefined)
|
|
160
|
+
return undefined;
|
|
161
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
162
|
+
fail(400, `${field} must be an object`);
|
|
163
|
+
}
|
|
164
|
+
return { ...value };
|
|
165
|
+
}
|
|
166
|
+
function normalizePhoneNumber(value, field) {
|
|
167
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
168
|
+
fail(400, `${field} must be a non-empty phone number string`);
|
|
169
|
+
}
|
|
170
|
+
const cleaned = value.replace(/[\s\-().]/g, "");
|
|
171
|
+
if (!/^\+?\d{7,15}$/.test(cleaned)) {
|
|
172
|
+
fail(400, `${field} is not a valid phone number`);
|
|
173
|
+
}
|
|
174
|
+
return cleaned.startsWith("+") ? cleaned : `+${cleaned}`;
|
|
175
|
+
}
|
|
176
|
+
function normalizePrivacyClass(value, field, fallback) {
|
|
177
|
+
if (value === undefined || value === null) {
|
|
178
|
+
return typeof fallback === "string" ? fallback : "private";
|
|
179
|
+
}
|
|
180
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
181
|
+
if (typeof fallback === "string")
|
|
182
|
+
return fallback;
|
|
183
|
+
fail(400, `${field ?? "privacyClass"} must be a string`);
|
|
184
|
+
}
|
|
185
|
+
return value.trim();
|
|
186
|
+
}
|
|
187
|
+
const LIFEOPS_OWNER_CONTACTS_LOAD_CONTEXT = {
|
|
188
|
+
fallbackToEnv: true,
|
|
189
|
+
envPrefix: "LIFEOPS_OWNER_",
|
|
190
|
+
};
|
|
191
|
+
// Reminder-specific helpers
|
|
192
|
+
function normalizeReminderUrgency(value) {
|
|
193
|
+
if (typeof value !== "string")
|
|
194
|
+
return "medium";
|
|
195
|
+
const lower = value.toLowerCase().trim();
|
|
196
|
+
if (lower === "low" ||
|
|
197
|
+
lower === "medium" ||
|
|
198
|
+
lower === "high" ||
|
|
199
|
+
lower === "critical") {
|
|
200
|
+
return lower;
|
|
201
|
+
}
|
|
202
|
+
return "medium";
|
|
203
|
+
}
|
|
204
|
+
function priorityToUrgency(priority) {
|
|
205
|
+
if (priority >= 80)
|
|
206
|
+
return "critical";
|
|
207
|
+
if (priority >= 50)
|
|
208
|
+
return "high";
|
|
209
|
+
if (priority >= 20)
|
|
210
|
+
return "medium";
|
|
211
|
+
return "low";
|
|
212
|
+
}
|
|
213
|
+
const REMINDER_INTENSITY_CANONICAL_ALIASES = {
|
|
214
|
+
minimal: "minimal",
|
|
215
|
+
normal: "normal",
|
|
216
|
+
persistent: "persistent",
|
|
217
|
+
high_priority_only: "high_priority_only",
|
|
218
|
+
paused: "high_priority_only",
|
|
219
|
+
low: "minimal",
|
|
220
|
+
high: "persistent",
|
|
221
|
+
};
|
|
222
|
+
function normalizeReminderIntensityInput(value, field) {
|
|
223
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
224
|
+
fail(400, `${field} must be a non-empty string`);
|
|
225
|
+
}
|
|
226
|
+
const canonical = REMINDER_INTENSITY_CANONICAL_ALIASES[value.trim().toLowerCase()];
|
|
227
|
+
if (!canonical) {
|
|
228
|
+
fail(400, `${field} must be one of: ${Object.keys(REMINDER_INTENSITY_CANONICAL_ALIASES).join(", ")}`);
|
|
229
|
+
}
|
|
230
|
+
return canonical;
|
|
231
|
+
}
|
|
232
|
+
function isReminderChannel(value) {
|
|
233
|
+
return (typeof value === "string" &&
|
|
234
|
+
(value === "in_app" ||
|
|
235
|
+
value === "email" ||
|
|
236
|
+
value === "telegram" ||
|
|
237
|
+
value === "discord" ||
|
|
238
|
+
value === "sms" ||
|
|
239
|
+
value === "voice"));
|
|
240
|
+
}
|
|
241
|
+
function isReminderChannelAllowedForUrgency(channel, urgency) {
|
|
242
|
+
if (channel === "voice" && urgency !== "critical" && urgency !== "high") {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
function shouldDeliverReminderForIntensity(intensity, urgency) {
|
|
248
|
+
if (intensity === "high_priority_only") {
|
|
249
|
+
return urgency === "critical" || urgency === "high";
|
|
250
|
+
}
|
|
251
|
+
if (intensity === "minimal") {
|
|
252
|
+
return urgency === "critical";
|
|
253
|
+
}
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
function mapPlatformToReminderChannel(platform) {
|
|
257
|
+
if (!platform)
|
|
258
|
+
return null;
|
|
259
|
+
const lower = platform.toLowerCase();
|
|
260
|
+
if (lower === "telegram")
|
|
261
|
+
return "telegram";
|
|
262
|
+
if (lower === "discord")
|
|
263
|
+
return "discord";
|
|
264
|
+
if (lower === "email")
|
|
265
|
+
return "email";
|
|
266
|
+
if (lower === "sms")
|
|
267
|
+
return "sms";
|
|
268
|
+
if (lower === "voice")
|
|
269
|
+
return "voice";
|
|
270
|
+
if (lower === "in_app" || lower === "app" || lower === "client_chat")
|
|
271
|
+
return "in_app";
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
function readReminderAttemptLifecycle(attempt) {
|
|
275
|
+
const metadata = attempt.deliveryMetadata ?? {};
|
|
276
|
+
return metadata[REMINDER_LIFECYCLE_METADATA_KEY] === "escalation"
|
|
277
|
+
? "escalation"
|
|
278
|
+
: "plan";
|
|
279
|
+
}
|
|
280
|
+
function shouldEscalateImmediately(outcome) {
|
|
281
|
+
return (outcome === "blocked_connector" ||
|
|
282
|
+
outcome === "blocked_policy" ||
|
|
283
|
+
outcome === "blocked_quiet_hours");
|
|
284
|
+
}
|
|
285
|
+
const REMINDER_ESCALATION_DELAYS = {
|
|
286
|
+
low: { initialMinutes: null, repeatMinutes: null },
|
|
287
|
+
medium: { initialMinutes: 90, repeatMinutes: 180 },
|
|
288
|
+
high: { initialMinutes: 20, repeatMinutes: 45 },
|
|
289
|
+
critical: { initialMinutes: 5, repeatMinutes: 15 },
|
|
290
|
+
};
|
|
291
|
+
function resolveReminderEscalationDelayMinutes(urgency, previousOutcome, hasEscalated) {
|
|
292
|
+
const delays = REMINDER_ESCALATION_DELAYS[urgency];
|
|
293
|
+
if (!delays.initialMinutes)
|
|
294
|
+
return null;
|
|
295
|
+
if (shouldEscalateImmediately(previousOutcome))
|
|
296
|
+
return 0;
|
|
297
|
+
return hasEscalated ? delays.repeatMinutes : delays.initialMinutes;
|
|
298
|
+
}
|
|
299
|
+
function readReminderPreferenceSettingFromMetadata(metadata, source) {
|
|
300
|
+
if (!metadata)
|
|
301
|
+
return null;
|
|
302
|
+
const intensity = metadata[REMINDER_INTENSITY_METADATA_KEY];
|
|
303
|
+
if (typeof intensity !== "string")
|
|
304
|
+
return null;
|
|
305
|
+
const canonical = REMINDER_INTENSITY_CANONICAL_ALIASES[intensity];
|
|
306
|
+
if (!canonical)
|
|
307
|
+
return null;
|
|
308
|
+
return {
|
|
309
|
+
intensity: canonical,
|
|
310
|
+
source,
|
|
311
|
+
updatedAt: typeof metadata[REMINDER_INTENSITY_UPDATED_AT_METADATA_KEY] === "string"
|
|
312
|
+
? metadata[REMINDER_INTENSITY_UPDATED_AT_METADATA_KEY]
|
|
313
|
+
: null,
|
|
314
|
+
note: typeof metadata[REMINDER_INTENSITY_NOTE_METADATA_KEY] === "string"
|
|
315
|
+
? metadata[REMINDER_INTENSITY_NOTE_METADATA_KEY]
|
|
316
|
+
: null,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function withReminderPreferenceMetadata(metadata, intensity, updatedAt, note, _scope) {
|
|
320
|
+
return {
|
|
321
|
+
...metadata,
|
|
322
|
+
[REMINDER_INTENSITY_METADATA_KEY]: intensity,
|
|
323
|
+
[REMINDER_INTENSITY_UPDATED_AT_METADATA_KEY]: updatedAt,
|
|
324
|
+
[REMINDER_INTENSITY_NOTE_METADATA_KEY]: note,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function applyReminderIntensityToPlan(plan, intensity) {
|
|
328
|
+
if (intensity === "normal" || intensity === "persistent") {
|
|
329
|
+
return plan;
|
|
330
|
+
}
|
|
331
|
+
return plan;
|
|
332
|
+
}
|
|
333
|
+
function isWithinQuietHours(args) {
|
|
334
|
+
if (!args.quietHours ||
|
|
335
|
+
typeof args.quietHours !== "object" ||
|
|
336
|
+
!("startHour" in args.quietHours) ||
|
|
337
|
+
!("endHour" in args.quietHours)) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
const startHour = typeof args.quietHours.startHour === "number"
|
|
341
|
+
? args.quietHours.startHour
|
|
342
|
+
: null;
|
|
343
|
+
const endHour = typeof args.quietHours.endHour === "number"
|
|
344
|
+
? args.quietHours.endHour
|
|
345
|
+
: null;
|
|
346
|
+
if (startHour === null || endHour === null)
|
|
347
|
+
return false;
|
|
348
|
+
const hour = args.now.getHours();
|
|
349
|
+
if (startHour <= endHour) {
|
|
350
|
+
return hour >= startHour && hour < endHour;
|
|
351
|
+
}
|
|
352
|
+
return hour >= startHour || hour < endHour;
|
|
353
|
+
}
|
|
354
|
+
function buildReminderBody(args) {
|
|
355
|
+
const parts = [];
|
|
356
|
+
if (args.lifecycle === "escalation") {
|
|
357
|
+
parts.push(`Follow-up reminder: ${args.title}`);
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
parts.push(`Reminder: ${args.title}`);
|
|
361
|
+
}
|
|
362
|
+
if (args.dueAt) {
|
|
363
|
+
parts.push(`Due: ${new Date(args.dueAt).toLocaleString()}`);
|
|
364
|
+
}
|
|
365
|
+
return parts.join("\n");
|
|
366
|
+
}
|
|
367
|
+
function buildReminderVoiceContext(runtime) {
|
|
368
|
+
if (!runtime.character)
|
|
369
|
+
return "";
|
|
370
|
+
const parts = [];
|
|
371
|
+
if (runtime.character.name) {
|
|
372
|
+
parts.push(`Name: ${runtime.character.name}`);
|
|
373
|
+
}
|
|
374
|
+
const bio = runtime.character.bio;
|
|
375
|
+
if (typeof bio === "string" && bio.trim().length > 0) {
|
|
376
|
+
parts.push(`Bio: ${bio.trim()}`);
|
|
377
|
+
}
|
|
378
|
+
else if (Array.isArray(bio)) {
|
|
379
|
+
const bioText = bio
|
|
380
|
+
.filter((line) => typeof line === "string")
|
|
381
|
+
.map((line) => line.trim())
|
|
382
|
+
.filter(Boolean)
|
|
383
|
+
.join(" ");
|
|
384
|
+
if (bioText.length > 0) {
|
|
385
|
+
parts.push(`Bio: ${bioText}`);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return parts.join("\n");
|
|
389
|
+
}
|
|
390
|
+
function formatReminderConversationLine(args) {
|
|
391
|
+
const text = args.memory.content?.text;
|
|
392
|
+
if (!text || typeof text !== "string")
|
|
393
|
+
return null;
|
|
394
|
+
const isAgent = args.memory.entityId === args.agentId;
|
|
395
|
+
const prefix = isAgent ? args.agentName : "User";
|
|
396
|
+
return `${prefix}: ${text}`;
|
|
397
|
+
}
|
|
398
|
+
function normalizeGeneratedReminderBody(value) {
|
|
399
|
+
const cleaned = value.replace(/^["'`]+|["'`]+$/g, "").trim();
|
|
400
|
+
return cleaned.length > 0 ? cleaned : null;
|
|
401
|
+
}
|
|
402
|
+
function normalizeGeneratedWorkflowBody(value) {
|
|
403
|
+
const cleaned = value.replace(/^["'`]+|["'`]+$/g, "").trim();
|
|
404
|
+
return cleaned.length > 0 ? cleaned : null;
|
|
405
|
+
}
|
|
406
|
+
function formatNearbyReminderTitlesForPrompt(titles) {
|
|
407
|
+
if (titles.length === 0) {
|
|
408
|
+
return "None.";
|
|
409
|
+
}
|
|
410
|
+
return titles.map((title) => `- ${title}`).join("\n");
|
|
411
|
+
}
|
|
412
|
+
function collectNearbyReminderTitles(args) {
|
|
413
|
+
if (!args.currentAnchorAt)
|
|
414
|
+
return [];
|
|
415
|
+
const anchorMs = Date.parse(args.currentAnchorAt);
|
|
416
|
+
if (!Number.isFinite(anchorMs))
|
|
417
|
+
return [];
|
|
418
|
+
const windowMs = 2 * 60 * 60 * 1000; // 2 hours
|
|
419
|
+
const titles = [];
|
|
420
|
+
for (const occ of args.occurrences) {
|
|
421
|
+
if (occ.id === args.currentOwnerId)
|
|
422
|
+
continue;
|
|
423
|
+
const occMs = occ.dueAt ? Date.parse(occ.dueAt) : null;
|
|
424
|
+
if (occMs !== null && Math.abs(occMs - anchorMs) <= windowMs) {
|
|
425
|
+
titles.push(occ.title);
|
|
426
|
+
}
|
|
427
|
+
if (titles.length >= args.limit)
|
|
428
|
+
return titles;
|
|
429
|
+
}
|
|
430
|
+
for (const event of args.events) {
|
|
431
|
+
if (event.id === args.currentOwnerId)
|
|
432
|
+
continue;
|
|
433
|
+
const eventMs = Date.parse(event.startAt);
|
|
434
|
+
if (Math.abs(eventMs - anchorMs) <= windowMs) {
|
|
435
|
+
titles.push(event.title);
|
|
436
|
+
}
|
|
437
|
+
if (titles.length >= args.limit)
|
|
438
|
+
return titles;
|
|
439
|
+
}
|
|
440
|
+
return titles;
|
|
441
|
+
}
|
|
442
|
+
function buildActiveReminders(occurrences, plansByDefinitionId, now) {
|
|
443
|
+
const rows = [];
|
|
444
|
+
for (const occurrence of occurrences) {
|
|
445
|
+
const plan = plansByDefinitionId.get(occurrence.definitionId);
|
|
446
|
+
if (!plan)
|
|
447
|
+
continue;
|
|
448
|
+
const anchorIso = occurrence.snoozedUntil ?? occurrence.relevanceStartAt;
|
|
449
|
+
if (!anchorIso)
|
|
450
|
+
continue;
|
|
451
|
+
const anchorDate = new Date(anchorIso);
|
|
452
|
+
for (const [stepIndex, step] of plan.steps.entries()) {
|
|
453
|
+
const scheduledFor = addMinutes(anchorDate, step.offsetMinutes).toISOString();
|
|
454
|
+
if (Date.parse(scheduledFor) > now.getTime())
|
|
455
|
+
continue;
|
|
456
|
+
rows.push({
|
|
457
|
+
ownerType: "occurrence",
|
|
458
|
+
ownerId: occurrence.id,
|
|
459
|
+
occurrenceId: occurrence.id,
|
|
460
|
+
definitionId: occurrence.definitionId,
|
|
461
|
+
title: occurrence.title,
|
|
462
|
+
channel: step.channel,
|
|
463
|
+
stepIndex,
|
|
464
|
+
scheduledFor,
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return rows;
|
|
469
|
+
}
|
|
470
|
+
function buildActiveCalendarEventReminders(events, plansByEventId, ownerEntityId, now) {
|
|
471
|
+
const rows = [];
|
|
472
|
+
for (const event of events) {
|
|
473
|
+
const plan = plansByEventId.get(event.id);
|
|
474
|
+
if (!plan)
|
|
475
|
+
continue;
|
|
476
|
+
const eventStartAt = new Date(event.startAt);
|
|
477
|
+
for (const [stepIndex, step] of plan.steps.entries()) {
|
|
478
|
+
const scheduledFor = addMinutes(eventStartAt, -step.offsetMinutes).toISOString();
|
|
479
|
+
if (Date.parse(scheduledFor) > now.getTime())
|
|
480
|
+
continue;
|
|
481
|
+
rows.push({
|
|
482
|
+
ownerType: "calendar_event",
|
|
483
|
+
ownerId: event.id,
|
|
484
|
+
eventId: event.id,
|
|
485
|
+
subjectType: "owner",
|
|
486
|
+
title: event.title,
|
|
487
|
+
dueAt: event.startAt,
|
|
488
|
+
channel: step.channel,
|
|
489
|
+
stepIndex,
|
|
490
|
+
scheduledFor,
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return rows;
|
|
495
|
+
}
|
|
496
|
+
function normalizeHealthSignal(value, field) {
|
|
497
|
+
if (value === undefined || value === null)
|
|
498
|
+
return {};
|
|
499
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
500
|
+
fail(400, `${field} must be an object`);
|
|
501
|
+
}
|
|
502
|
+
return { ...value };
|
|
503
|
+
}
|
|
504
|
+
function normalizeActivitySignalSource(value, field) {
|
|
505
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
506
|
+
fail(400, `${field} must be a non-empty string`);
|
|
507
|
+
}
|
|
508
|
+
return value.trim();
|
|
509
|
+
}
|
|
510
|
+
function normalizeActivitySignalState(value, field) {
|
|
511
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
512
|
+
fail(400, `${field} must be a non-empty string`);
|
|
513
|
+
}
|
|
514
|
+
return value.trim();
|
|
515
|
+
}
|
|
516
|
+
function normalizeOptionalIdleState(value, field) {
|
|
517
|
+
if (value === undefined || value === null)
|
|
518
|
+
return null;
|
|
519
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
520
|
+
fail(400, `${field} must be a non-empty string`);
|
|
521
|
+
}
|
|
522
|
+
return value.trim();
|
|
523
|
+
}
|
|
524
|
+
function normalizeWebsiteListForComparison(websites) {
|
|
525
|
+
return [...new Set(websites.map((w) => w.toLowerCase().trim()).filter(Boolean))].sort();
|
|
526
|
+
}
|
|
527
|
+
function haveSameWebsiteSet(left, right) {
|
|
528
|
+
const leftSet = normalizeWebsiteListForComparison([...left]);
|
|
529
|
+
const rightSet = normalizeWebsiteListForComparison([...right]);
|
|
530
|
+
if (leftSet.length !== rightSet.length)
|
|
531
|
+
return false;
|
|
532
|
+
return leftSet.every((v, i) => v === rightSet[i]);
|
|
533
|
+
}
|
|
534
|
+
function isWebsiteAccessGrantActive(grant, now) {
|
|
535
|
+
if (grant.revokedAt)
|
|
536
|
+
return false;
|
|
537
|
+
if (grant.expiresAt) {
|
|
538
|
+
return Date.parse(grant.expiresAt) > now.getTime();
|
|
539
|
+
}
|
|
540
|
+
return true;
|
|
541
|
+
}
|
|
542
|
+
// ---------------------------------------------------------------------------
|
|
543
|
+
// Reminders mixin
|
|
544
|
+
// ---------------------------------------------------------------------------
|
|
545
|
+
/** @internal */
|
|
546
|
+
export function withReminders(Base) {
|
|
547
|
+
class LifeOpsRemindersServiceMixin extends Base {
|
|
548
|
+
emitInAppReminderNudge(args) {
|
|
549
|
+
this.emitAssistantEvent(args.text, "lifeops-reminder", {
|
|
550
|
+
ownerType: args.ownerType,
|
|
551
|
+
ownerId: args.ownerId,
|
|
552
|
+
subjectType: args.subjectType,
|
|
553
|
+
scheduledFor: args.scheduledFor,
|
|
554
|
+
dueAt: args.dueAt,
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
async readRecentReminderConversation(args) {
|
|
558
|
+
if (args.subjectType !== "owner" ||
|
|
559
|
+
typeof this.runtime.getRoomsForParticipants !== "function" ||
|
|
560
|
+
typeof this.runtime.getMemoriesByRoomIds !== "function") {
|
|
561
|
+
return [];
|
|
562
|
+
}
|
|
563
|
+
const ownerEntityId = (await this.ownerRoutingEntityId()) ?? this.ownerEntityId();
|
|
564
|
+
const agentId = this.agentId();
|
|
565
|
+
try {
|
|
566
|
+
const roomIds = await this.runtime.getRoomsForParticipants([
|
|
567
|
+
ownerEntityId,
|
|
568
|
+
agentId,
|
|
569
|
+
]);
|
|
570
|
+
if (!Array.isArray(roomIds) || roomIds.length === 0) {
|
|
571
|
+
return [];
|
|
572
|
+
}
|
|
573
|
+
const memories = await this.runtime.getMemoriesByRoomIds({
|
|
574
|
+
tableName: "messages",
|
|
575
|
+
roomIds,
|
|
576
|
+
limit: Math.max(6, (args.limit ?? 6) * 2),
|
|
577
|
+
});
|
|
578
|
+
if (!Array.isArray(memories) || memories.length === 0) {
|
|
579
|
+
return [];
|
|
580
|
+
}
|
|
581
|
+
const agentName = typeof this.runtime.character?.name === "string" &&
|
|
582
|
+
this.runtime.character.name.trim().length > 0
|
|
583
|
+
? this.runtime.character.name.trim()
|
|
584
|
+
: "Assistant";
|
|
585
|
+
return memories
|
|
586
|
+
.slice()
|
|
587
|
+
.sort((left, right) => Number(left.createdAt ?? 0) - Number(right.createdAt ?? 0))
|
|
588
|
+
.map((memory) => formatReminderConversationLine({
|
|
589
|
+
agentId,
|
|
590
|
+
agentName,
|
|
591
|
+
ownerEntityId,
|
|
592
|
+
memory,
|
|
593
|
+
}))
|
|
594
|
+
.filter((line) => typeof line === "string")
|
|
595
|
+
.slice(-(args.limit ?? 6));
|
|
596
|
+
}
|
|
597
|
+
catch {
|
|
598
|
+
return [];
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
async renderReminderBody(args) {
|
|
602
|
+
const fallback = buildReminderBody({
|
|
603
|
+
title: args.title,
|
|
604
|
+
scheduledFor: args.scheduledFor,
|
|
605
|
+
dueAt: args.dueAt,
|
|
606
|
+
channel: args.channel,
|
|
607
|
+
lifecycle: args.lifecycle,
|
|
608
|
+
nearbyReminderTitles: args.nearbyReminderTitles,
|
|
609
|
+
});
|
|
610
|
+
if (typeof this.runtime.useModel !== "function") {
|
|
611
|
+
return fallback;
|
|
612
|
+
}
|
|
613
|
+
const recentConversation = await this.readRecentReminderConversation({
|
|
614
|
+
subjectType: args.subjectType,
|
|
615
|
+
limit: 6,
|
|
616
|
+
});
|
|
617
|
+
const reminderAt = args.dueAt ?? args.scheduledFor;
|
|
618
|
+
const prompt = [
|
|
619
|
+
`Write a short reminder nudge in the voice of ${this.runtime.character?.name ?? "the assistant"}.`,
|
|
620
|
+
"This is a real follow-up or reminder delivery, not a system log.",
|
|
621
|
+
"",
|
|
622
|
+
"Character voice:",
|
|
623
|
+
buildReminderVoiceContext(this.runtime) || "No extra character context.",
|
|
624
|
+
"",
|
|
625
|
+
"Current reminder:",
|
|
626
|
+
`- title: ${args.title}`,
|
|
627
|
+
`- due: ${new Date(reminderAt).toLocaleString()}`,
|
|
628
|
+
`- channel: ${args.channel}`,
|
|
629
|
+
`- urgency: ${args.urgency}`,
|
|
630
|
+
`- lifecycle: ${args.lifecycle}`,
|
|
631
|
+
"",
|
|
632
|
+
"Recent conversation:",
|
|
633
|
+
recentConversation.length > 0
|
|
634
|
+
? recentConversation.join("\n")
|
|
635
|
+
: "No recent conversation available.",
|
|
636
|
+
"",
|
|
637
|
+
"Other reminders around this time:",
|
|
638
|
+
formatNearbyReminderTitlesForPrompt(args.nearbyReminderTitles ?? []),
|
|
639
|
+
"",
|
|
640
|
+
"Rules:",
|
|
641
|
+
"- Return only the reminder text.",
|
|
642
|
+
"- Sound natural and in character.",
|
|
643
|
+
"- Do not start with 'Reminder' or 'Follow-up reminder'.",
|
|
644
|
+
"- Do not use ISO timestamps.",
|
|
645
|
+
"- Keep it concise: one or two short sentences.",
|
|
646
|
+
"- You may mention nearby reminders briefly if it helps.",
|
|
647
|
+
"- For escalation, sound a little firmer but still human.",
|
|
648
|
+
"- No markdown, bullets, quotes, labels, or emoji.",
|
|
649
|
+
"",
|
|
650
|
+
"Reminder text:",
|
|
651
|
+
].join("\n");
|
|
652
|
+
try {
|
|
653
|
+
const response = await this.runtime.useModel(ModelType.TEXT_SMALL, {
|
|
654
|
+
prompt,
|
|
655
|
+
});
|
|
656
|
+
const text = typeof response === "string"
|
|
657
|
+
? normalizeGeneratedReminderBody(response)
|
|
658
|
+
: null;
|
|
659
|
+
return text ?? fallback;
|
|
660
|
+
}
|
|
661
|
+
catch {
|
|
662
|
+
return fallback;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
async renderWorkflowRunBody(args) {
|
|
666
|
+
const fallback = args.run.status === "success"
|
|
667
|
+
? `${args.workflow.title} just ran successfully.`
|
|
668
|
+
: `${args.workflow.title} ran but hit a problem.`;
|
|
669
|
+
if (args.workflow.subjectType !== "owner" ||
|
|
670
|
+
typeof this.runtime.useModel !== "function") {
|
|
671
|
+
return fallback;
|
|
672
|
+
}
|
|
673
|
+
const recentConversation = await this.readRecentReminderConversation({
|
|
674
|
+
subjectType: "owner",
|
|
675
|
+
limit: 6,
|
|
676
|
+
});
|
|
677
|
+
const prompt = [
|
|
678
|
+
`Write a short assistant update about the workflow "${args.workflow.title}".`,
|
|
679
|
+
"This is a user-facing status nudge, not a system log.",
|
|
680
|
+
"",
|
|
681
|
+
"Character voice:",
|
|
682
|
+
buildReminderVoiceContext(this.runtime) || "No extra character context.",
|
|
683
|
+
"",
|
|
684
|
+
"Workflow run:",
|
|
685
|
+
`- title: ${args.workflow.title}`,
|
|
686
|
+
`- status: ${args.run.status}`,
|
|
687
|
+
"",
|
|
688
|
+
"Recent conversation:",
|
|
689
|
+
recentConversation.length > 0
|
|
690
|
+
? recentConversation.join("\n")
|
|
691
|
+
: "No recent conversation available.",
|
|
692
|
+
"",
|
|
693
|
+
"Rules:",
|
|
694
|
+
"- Return only the message text.",
|
|
695
|
+
"- Sound natural and in character.",
|
|
696
|
+
"- Do not start with 'Workflow' or 'Scheduled workflow'.",
|
|
697
|
+
"- Keep it concise: one short sentence, or two at most.",
|
|
698
|
+
"- For failures, sound calm and direct rather than robotic.",
|
|
699
|
+
"- No markdown, bullets, quotes, labels, or emoji.",
|
|
700
|
+
"",
|
|
701
|
+
"Message text:",
|
|
702
|
+
].join("\n");
|
|
703
|
+
try {
|
|
704
|
+
const response = await this.runtime.useModel(ModelType.TEXT_SMALL, {
|
|
705
|
+
prompt,
|
|
706
|
+
});
|
|
707
|
+
const text = typeof response === "string"
|
|
708
|
+
? normalizeGeneratedWorkflowBody(response)
|
|
709
|
+
: null;
|
|
710
|
+
return text ?? fallback;
|
|
711
|
+
}
|
|
712
|
+
catch {
|
|
713
|
+
return fallback;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
async emitWorkflowRunNudge(workflow, run) {
|
|
717
|
+
if (workflow.subjectType !== "owner") {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
const message = await this.renderWorkflowRunBody({
|
|
721
|
+
workflow,
|
|
722
|
+
run,
|
|
723
|
+
});
|
|
724
|
+
this.emitAssistantEvent(message, "lifeops-workflow", {
|
|
725
|
+
workflowId: workflow.id,
|
|
726
|
+
workflowTitle: workflow.title,
|
|
727
|
+
workflowRunId: run.id,
|
|
728
|
+
status: run.status,
|
|
729
|
+
subjectType: workflow.subjectType,
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
withNativeAppleReminderId(definition, reminderId) {
|
|
733
|
+
const nativeMetadata = readNativeAppleReminderMetadata(definition.metadata);
|
|
734
|
+
if (!nativeMetadata) {
|
|
735
|
+
return definition;
|
|
736
|
+
}
|
|
737
|
+
return {
|
|
738
|
+
...definition,
|
|
739
|
+
metadata: mergeMetadata(definition.metadata, buildNativeAppleReminderMetadata({
|
|
740
|
+
kind: nativeMetadata.kind,
|
|
741
|
+
source: nativeMetadata.source,
|
|
742
|
+
reminderId,
|
|
743
|
+
})),
|
|
744
|
+
updatedAt: new Date().toISOString(),
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
async syncNativeAppleReminderForDefinition(args) {
|
|
748
|
+
const previousMetadata = args.previousDefinition
|
|
749
|
+
? readNativeAppleReminderMetadata(args.previousDefinition.metadata)
|
|
750
|
+
: null;
|
|
751
|
+
const nextMetadata = args.definition
|
|
752
|
+
? readNativeAppleReminderMetadata(args.definition.metadata)
|
|
753
|
+
: null;
|
|
754
|
+
const previousReminderId = previousMetadata?.reminderId ?? null;
|
|
755
|
+
if (args.definition === null ||
|
|
756
|
+
nextMetadata === null ||
|
|
757
|
+
args.definition.subjectType !== "owner" ||
|
|
758
|
+
args.definition.domain !== "user_lifeops" ||
|
|
759
|
+
args.definition.cadence.kind !== "once") {
|
|
760
|
+
if (previousReminderId) {
|
|
761
|
+
const deleteResult = await deleteNativeAppleReminderLikeItem(previousReminderId);
|
|
762
|
+
if (deleteResult.ok === false) {
|
|
763
|
+
this.logLifeOpsWarn("native_apple_reminder_sync", "[lifeops] Failed to delete a native Apple reminder.", {
|
|
764
|
+
definitionId: args.previousDefinition?.id ?? null,
|
|
765
|
+
reminderId: previousReminderId,
|
|
766
|
+
skippedReason: deleteResult.skippedReason,
|
|
767
|
+
error: deleteResult.error,
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
if (args.definition && nextMetadata?.reminderId) {
|
|
772
|
+
return this.withNativeAppleReminderId(args.definition, null);
|
|
773
|
+
}
|
|
774
|
+
return args.definition;
|
|
775
|
+
}
|
|
776
|
+
const definition = args.definition;
|
|
777
|
+
const nativeMetadata = nextMetadata;
|
|
778
|
+
const cadence = definition.cadence.kind === "once" ? definition.cadence : null;
|
|
779
|
+
if (!cadence) {
|
|
780
|
+
return definition;
|
|
781
|
+
}
|
|
782
|
+
const reminderId = nativeMetadata.reminderId ?? previousReminderId;
|
|
783
|
+
if (reminderId) {
|
|
784
|
+
const updateResult = await updateNativeAppleReminderLikeItem({
|
|
785
|
+
reminderId,
|
|
786
|
+
kind: nativeMetadata.kind,
|
|
787
|
+
title: definition.title,
|
|
788
|
+
dueAt: cadence.dueAt,
|
|
789
|
+
notes: definition.description,
|
|
790
|
+
originalIntent: definition.originalIntent,
|
|
791
|
+
});
|
|
792
|
+
if (updateResult.ok === true) {
|
|
793
|
+
return this.withNativeAppleReminderId(definition, updateResult.reminderId ?? reminderId);
|
|
794
|
+
}
|
|
795
|
+
this.logLifeOpsWarn("native_apple_reminder_sync", "[lifeops] Failed to update a native Apple reminder.", {
|
|
796
|
+
definitionId: definition.id,
|
|
797
|
+
kind: nativeMetadata.kind,
|
|
798
|
+
reminderId,
|
|
799
|
+
skippedReason: updateResult.skippedReason,
|
|
800
|
+
error: updateResult.error,
|
|
801
|
+
});
|
|
802
|
+
return this.withNativeAppleReminderId(definition, reminderId);
|
|
803
|
+
}
|
|
804
|
+
const createResult = await createNativeAppleReminderLikeItem({
|
|
805
|
+
kind: nativeMetadata.kind,
|
|
806
|
+
title: definition.title,
|
|
807
|
+
dueAt: cadence.dueAt,
|
|
808
|
+
notes: definition.description,
|
|
809
|
+
originalIntent: definition.originalIntent,
|
|
810
|
+
});
|
|
811
|
+
if (createResult.ok === false) {
|
|
812
|
+
this.logLifeOpsWarn("native_apple_reminder_sync", "[lifeops] Failed to sync a native Apple reminder.", {
|
|
813
|
+
definitionId: definition.id,
|
|
814
|
+
kind: nativeMetadata.kind,
|
|
815
|
+
skippedReason: createResult.skippedReason,
|
|
816
|
+
error: createResult.error,
|
|
817
|
+
});
|
|
818
|
+
return definition;
|
|
819
|
+
}
|
|
820
|
+
return this.withNativeAppleReminderId(definition, createResult.reminderId ?? null);
|
|
821
|
+
}
|
|
822
|
+
async getDefinitionRecord(definitionId, now = new Date()) {
|
|
823
|
+
const definition = await this.repository.getDefinition(this.agentId(), definitionId);
|
|
824
|
+
if (!definition) {
|
|
825
|
+
fail(404, "life-ops definition not found");
|
|
826
|
+
}
|
|
827
|
+
const reminderPlan = definition.reminderPlanId
|
|
828
|
+
? await this.repository.getReminderPlan(this.agentId(), definition.reminderPlanId)
|
|
829
|
+
: null;
|
|
830
|
+
const occurrences = await this.repository.listOccurrencesForDefinition(this.agentId(), definition.id);
|
|
831
|
+
return {
|
|
832
|
+
definition,
|
|
833
|
+
reminderPlan,
|
|
834
|
+
performance: computeDefinitionPerformance(definition, occurrences, now),
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
async getGoalRecord(goalId) {
|
|
838
|
+
const goal = await this.repository.getGoal(this.agentId(), goalId);
|
|
839
|
+
if (!goal) {
|
|
840
|
+
fail(404, "life-ops goal not found");
|
|
841
|
+
}
|
|
842
|
+
const links = await this.repository.listGoalLinksForGoal(this.agentId(), goalId);
|
|
843
|
+
return { goal, links };
|
|
844
|
+
}
|
|
845
|
+
async ensureGoalExists(goalId, ownership) {
|
|
846
|
+
if (!goalId)
|
|
847
|
+
return null;
|
|
848
|
+
const goal = await this.repository.getGoal(this.agentId(), goalId);
|
|
849
|
+
if (!goal) {
|
|
850
|
+
fail(404, `goal ${goalId} does not exist`);
|
|
851
|
+
}
|
|
852
|
+
if (ownership &&
|
|
853
|
+
(goal.domain !== ownership.domain ||
|
|
854
|
+
goal.subjectType !== ownership.subjectType ||
|
|
855
|
+
goal.subjectId !== ownership.subjectId)) {
|
|
856
|
+
fail(400, "goalId must reference a goal in the same owner or agent scope");
|
|
857
|
+
}
|
|
858
|
+
return goal.id;
|
|
859
|
+
}
|
|
860
|
+
async syncGoalLink(definition) {
|
|
861
|
+
await this.repository.deleteGoalLinksForLinked(definition.agentId, "definition", definition.id);
|
|
862
|
+
if (!definition.goalId)
|
|
863
|
+
return;
|
|
864
|
+
await this.repository.upsertGoalLink({
|
|
865
|
+
id: crypto.randomUUID(),
|
|
866
|
+
agentId: definition.agentId,
|
|
867
|
+
goalId: definition.goalId,
|
|
868
|
+
linkedType: "definition",
|
|
869
|
+
linkedId: definition.id,
|
|
870
|
+
createdAt: new Date().toISOString(),
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
async syncReminderPlan(definition, draft) {
|
|
874
|
+
if (draft === undefined) {
|
|
875
|
+
return definition.reminderPlanId
|
|
876
|
+
? await this.repository.getReminderPlan(definition.agentId, definition.reminderPlanId)
|
|
877
|
+
: null;
|
|
878
|
+
}
|
|
879
|
+
if (draft === null) {
|
|
880
|
+
if (definition.reminderPlanId) {
|
|
881
|
+
await this.repository.deleteReminderPlan(definition.agentId, definition.reminderPlanId);
|
|
882
|
+
}
|
|
883
|
+
definition.reminderPlanId = null;
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
const existingPlan = definition.reminderPlanId
|
|
887
|
+
? await this.repository.getReminderPlan(definition.agentId, definition.reminderPlanId)
|
|
888
|
+
: null;
|
|
889
|
+
if (existingPlan) {
|
|
890
|
+
const nextPlan = {
|
|
891
|
+
...existingPlan,
|
|
892
|
+
steps: draft.steps,
|
|
893
|
+
mutePolicy: draft.mutePolicy,
|
|
894
|
+
quietHours: draft.quietHours,
|
|
895
|
+
updatedAt: new Date().toISOString(),
|
|
896
|
+
};
|
|
897
|
+
await this.repository.updateReminderPlan(nextPlan);
|
|
898
|
+
definition.reminderPlanId = nextPlan.id;
|
|
899
|
+
return nextPlan;
|
|
900
|
+
}
|
|
901
|
+
const createdPlan = createLifeOpsReminderPlan({
|
|
902
|
+
agentId: definition.agentId,
|
|
903
|
+
ownerType: "definition",
|
|
904
|
+
ownerId: definition.id,
|
|
905
|
+
steps: draft.steps,
|
|
906
|
+
mutePolicy: draft.mutePolicy,
|
|
907
|
+
quietHours: draft.quietHours,
|
|
908
|
+
});
|
|
909
|
+
await this.repository.createReminderPlan(createdPlan);
|
|
910
|
+
definition.reminderPlanId = createdPlan.id;
|
|
911
|
+
return createdPlan;
|
|
912
|
+
}
|
|
913
|
+
/** Max age for the cached adaptive window policy (30 minutes). */
|
|
914
|
+
static ADAPTIVE_POLICY_TTL_MS = 30 * 60 * 1000;
|
|
915
|
+
/**
|
|
916
|
+
* Read the activity profile from the proactive task metadata and return
|
|
917
|
+
* an adaptive window policy. Result is cached for up to 30 minutes.
|
|
918
|
+
*/
|
|
919
|
+
async resolveAdaptiveWindowPolicy(timezone, now) {
|
|
920
|
+
const cached = this.adaptiveWindowPolicyCache;
|
|
921
|
+
if (cached &&
|
|
922
|
+
now.getTime() - cached.computedAt < this.constructor.ADAPTIVE_POLICY_TTL_MS) {
|
|
923
|
+
return cached.policy;
|
|
924
|
+
}
|
|
925
|
+
try {
|
|
926
|
+
const tasks = await this.runtime.getTasks({
|
|
927
|
+
agentIds: [this.runtime.agentId],
|
|
928
|
+
tags: [...PROACTIVE_TASK_QUERY_TAGS],
|
|
929
|
+
});
|
|
930
|
+
const proactiveTask = tasks.find((task) => {
|
|
931
|
+
const metadata = isRecord(task.metadata) ? task.metadata : null;
|
|
932
|
+
return (task.name === "PROACTIVE_AGENT" &&
|
|
933
|
+
isRecord(metadata?.proactiveAgent) &&
|
|
934
|
+
metadata.proactiveAgent.kind ===
|
|
935
|
+
"runtime_runner");
|
|
936
|
+
});
|
|
937
|
+
const profile = proactiveTask
|
|
938
|
+
? readProfileFromMetadata(isRecord(proactiveTask.metadata)
|
|
939
|
+
? proactiveTask.metadata
|
|
940
|
+
: null)
|
|
941
|
+
: null;
|
|
942
|
+
if (!profile) {
|
|
943
|
+
this.adaptiveWindowPolicyCache = null;
|
|
944
|
+
return null;
|
|
945
|
+
}
|
|
946
|
+
const policy = computeAdaptiveWindowPolicy(profile, timezone);
|
|
947
|
+
this.adaptiveWindowPolicyCache = { policy, computedAt: now.getTime() };
|
|
948
|
+
return policy;
|
|
949
|
+
}
|
|
950
|
+
catch (error) {
|
|
951
|
+
this.logLifeOpsWarn("adaptive_window_policy", "[lifeops] Failed to resolve adaptive window policy; using defaults.", { error: lifeOpsErrorMessage(error) });
|
|
952
|
+
this.adaptiveWindowPolicyCache = null;
|
|
953
|
+
return null;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
async refreshDefinitionOccurrences(definition, now = new Date()) {
|
|
957
|
+
const existingOccurrences = await this.repository.listOccurrencesForDefinition(definition.agentId, definition.id);
|
|
958
|
+
// If the definition still uses the default time windows, adapt them
|
|
959
|
+
// to the user's actual rhythm when an activity profile is available.
|
|
960
|
+
let effectiveDefinition = definition;
|
|
961
|
+
if (windowPolicyMatchesDefaults(definition.windowPolicy)) {
|
|
962
|
+
const adaptivePolicy = await this.resolveAdaptiveWindowPolicy(definition.timezone, now);
|
|
963
|
+
if (adaptivePolicy) {
|
|
964
|
+
effectiveDefinition = { ...definition, windowPolicy: adaptivePolicy };
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
const materialized = materializeDefinitionOccurrences(effectiveDefinition, existingOccurrences, { now });
|
|
968
|
+
for (const occurrence of materialized) {
|
|
969
|
+
await this.repository.upsertOccurrence(occurrence);
|
|
970
|
+
}
|
|
971
|
+
await this.repository.pruneNonTerminalOccurrences(definition.agentId, definition.id, materialized.map((occurrence) => occurrence.occurrenceKey));
|
|
972
|
+
return materialized;
|
|
973
|
+
}
|
|
974
|
+
async getFreshOccurrence(occurrenceId, now = new Date()) {
|
|
975
|
+
const occurrence = await this.repository.getOccurrence(this.agentId(), occurrenceId);
|
|
976
|
+
if (!occurrence) {
|
|
977
|
+
fail(404, "life-ops occurrence not found");
|
|
978
|
+
}
|
|
979
|
+
const definition = await this.repository.getDefinition(this.agentId(), occurrence.definitionId);
|
|
980
|
+
if (!definition) {
|
|
981
|
+
fail(404, "life-ops definition not found for occurrence");
|
|
982
|
+
}
|
|
983
|
+
if (definition.status === "active") {
|
|
984
|
+
await this.refreshDefinitionOccurrences(definition, now);
|
|
985
|
+
}
|
|
986
|
+
const freshOccurrence = await this.repository.getOccurrence(this.agentId(), occurrenceId);
|
|
987
|
+
if (!freshOccurrence) {
|
|
988
|
+
fail(404, "life-ops occurrence not found after refresh");
|
|
989
|
+
}
|
|
990
|
+
return {
|
|
991
|
+
definition,
|
|
992
|
+
occurrence: freshOccurrence,
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
async resolvePrimaryChannelPolicy(channelType) {
|
|
996
|
+
const policies = (await this.repository.listChannelPolicies(this.agentId())).filter((policy) => policy.channelType === channelType);
|
|
997
|
+
return (policies.find((policy) => policy.metadata.isPrimary === true) ??
|
|
998
|
+
policies[0] ??
|
|
999
|
+
null);
|
|
1000
|
+
}
|
|
1001
|
+
async resolveRuntimeReminderTarget(channel, policy, ownerContacts = loadOwnerContactsConfig(LIFEOPS_OWNER_CONTACTS_LOAD_CONTEXT), ownerContactHints) {
|
|
1002
|
+
const metadata = policy ? policy.metadata : null;
|
|
1003
|
+
const configuredSource = (metadata && normalizeOptionalString(metadata.source)) ??
|
|
1004
|
+
(metadata && normalizeOptionalString(metadata.platform)) ??
|
|
1005
|
+
channel;
|
|
1006
|
+
const hints = ownerContactHints ??
|
|
1007
|
+
(await loadOwnerContactRoutingHints(this.runtime, ownerContacts));
|
|
1008
|
+
const ownerEntityId = await this.ownerRoutingEntityId();
|
|
1009
|
+
const hint = hints[configuredSource] ??
|
|
1010
|
+
hints[channel] ??
|
|
1011
|
+
{
|
|
1012
|
+
source: configuredSource,
|
|
1013
|
+
entityId: null,
|
|
1014
|
+
channelId: null,
|
|
1015
|
+
roomId: null,
|
|
1016
|
+
preferredCommunicationChannel: null,
|
|
1017
|
+
platformIdentities: [],
|
|
1018
|
+
lastResponseAt: null,
|
|
1019
|
+
lastResponseChannel: null,
|
|
1020
|
+
resolvedFrom: "config",
|
|
1021
|
+
};
|
|
1022
|
+
const contactResolution = resolveOwnerContactWithFallback({
|
|
1023
|
+
ownerContacts,
|
|
1024
|
+
source: hint.source,
|
|
1025
|
+
ownerEntityId,
|
|
1026
|
+
}) ??
|
|
1027
|
+
resolveOwnerContactWithFallback({
|
|
1028
|
+
ownerContacts,
|
|
1029
|
+
source: channel,
|
|
1030
|
+
ownerEntityId,
|
|
1031
|
+
});
|
|
1032
|
+
const contact = contactResolution?.contact ??
|
|
1033
|
+
ownerContacts[hint.source] ??
|
|
1034
|
+
ownerContacts[channel];
|
|
1035
|
+
const entityId = (metadata && normalizeOptionalString(metadata.entityId)) ??
|
|
1036
|
+
normalizeOptionalString(hint.entityId) ??
|
|
1037
|
+
normalizeOptionalString(contact?.entityId) ??
|
|
1038
|
+
null;
|
|
1039
|
+
const channelId = (metadata && normalizeOptionalString(metadata.channelId)) ??
|
|
1040
|
+
normalizeOptionalString(hint.channelId) ??
|
|
1041
|
+
normalizeOptionalString(contact?.channelId) ??
|
|
1042
|
+
null;
|
|
1043
|
+
const roomId = (metadata && normalizeOptionalString(metadata.roomId)) ??
|
|
1044
|
+
normalizeOptionalString(hint.roomId) ??
|
|
1045
|
+
normalizeOptionalString(contact?.roomId) ??
|
|
1046
|
+
null;
|
|
1047
|
+
if (!entityId && !channelId && !roomId) {
|
|
1048
|
+
return null;
|
|
1049
|
+
}
|
|
1050
|
+
const targetRef = channelId ?? roomId ?? entityId ?? policy?.channelRef ?? null;
|
|
1051
|
+
return {
|
|
1052
|
+
source: contactResolution?.source ?? hint.source,
|
|
1053
|
+
connectorRef: `runtime:${contactResolution?.source ?? hint.source}:${targetRef}`,
|
|
1054
|
+
target: {
|
|
1055
|
+
source: contactResolution?.source ?? hint.source,
|
|
1056
|
+
entityId: entityId,
|
|
1057
|
+
channelId,
|
|
1058
|
+
roomId: roomId,
|
|
1059
|
+
},
|
|
1060
|
+
resolution: {
|
|
1061
|
+
sourceOfTruth: hint.resolvedFrom,
|
|
1062
|
+
preferredCommunicationChannel: hint.preferredCommunicationChannel,
|
|
1063
|
+
platformIdentities: hint.platformIdentities,
|
|
1064
|
+
lastResponseAt: hint.lastResponseAt,
|
|
1065
|
+
lastResponseChannel: hint.lastResponseChannel,
|
|
1066
|
+
},
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
async readReminderActivityProfileSnapshot() {
|
|
1070
|
+
try {
|
|
1071
|
+
const tasks = await this.runtime.getTasks({
|
|
1072
|
+
agentIds: [this.runtime.agentId],
|
|
1073
|
+
tags: [...PROACTIVE_TASK_QUERY_TAGS],
|
|
1074
|
+
});
|
|
1075
|
+
const proactiveTask = tasks.find((task) => {
|
|
1076
|
+
const metadata = isRecord(task.metadata) ? task.metadata : null;
|
|
1077
|
+
return (task.name === "PROACTIVE_AGENT" &&
|
|
1078
|
+
isRecord(metadata?.proactiveAgent) &&
|
|
1079
|
+
metadata.proactiveAgent.kind === "runtime_runner");
|
|
1080
|
+
});
|
|
1081
|
+
if (!proactiveTask || !isRecord(proactiveTask.metadata)) {
|
|
1082
|
+
return null;
|
|
1083
|
+
}
|
|
1084
|
+
const profile = proactiveTask.metadata.activityProfile;
|
|
1085
|
+
if (!isRecord(profile)) {
|
|
1086
|
+
return null;
|
|
1087
|
+
}
|
|
1088
|
+
return {
|
|
1089
|
+
primaryPlatform: normalizeOptionalString(profile.primaryPlatform) ?? null,
|
|
1090
|
+
secondaryPlatform: normalizeOptionalString(profile.secondaryPlatform) ?? null,
|
|
1091
|
+
lastSeenPlatform: normalizeOptionalString(profile.lastSeenPlatform) ?? null,
|
|
1092
|
+
isCurrentlyActive: profile.isCurrentlyActive === true,
|
|
1093
|
+
lastSeenAt: typeof profile.lastSeenAt === "number" ? profile.lastSeenAt : null,
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
catch (error) {
|
|
1097
|
+
this.logLifeOpsWarn("reminder_activity_profile", "[lifeops] Failed to read proactive activity profile; using connector order for reminder escalation.", {
|
|
1098
|
+
error: lifeOpsErrorMessage(error),
|
|
1099
|
+
});
|
|
1100
|
+
return null;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Scan recent "delivered" attempts and upgrade to "delivered_read" when the
|
|
1105
|
+
* owner was seen active after the reminder was sent. This gives escalation
|
|
1106
|
+
* better signal about whether the owner is reachable.
|
|
1107
|
+
*/
|
|
1108
|
+
async scanReadReceipts(attempts, activityProfile, now) {
|
|
1109
|
+
if (!activityProfile?.lastSeenAt) {
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
const RECEIPT_SCAN_WINDOW_MS = 4 * 60 * 60 * 1000; // 4 hours
|
|
1113
|
+
const cutoff = now.getTime() - RECEIPT_SCAN_WINDOW_MS;
|
|
1114
|
+
const candidates = attempts.filter((attempt) => {
|
|
1115
|
+
if (attempt.outcome !== "delivered") {
|
|
1116
|
+
return false;
|
|
1117
|
+
}
|
|
1118
|
+
const attemptedMs = attempt.attemptedAt
|
|
1119
|
+
? Date.parse(attempt.attemptedAt)
|
|
1120
|
+
: 0;
|
|
1121
|
+
return attemptedMs > cutoff;
|
|
1122
|
+
});
|
|
1123
|
+
for (const attempt of candidates) {
|
|
1124
|
+
const attemptedMs = attempt.attemptedAt
|
|
1125
|
+
? Date.parse(attempt.attemptedAt)
|
|
1126
|
+
: 0;
|
|
1127
|
+
if (activityProfile.lastSeenAt > attemptedMs) {
|
|
1128
|
+
try {
|
|
1129
|
+
await this.repository.updateReminderAttemptOutcome(attempt.id, "delivered_read", { readDetectedAt: now.toISOString() });
|
|
1130
|
+
attempt.outcome = "delivered_read";
|
|
1131
|
+
}
|
|
1132
|
+
catch (error) {
|
|
1133
|
+
this.logLifeOpsWarn("read_receipt_scan", `[lifeops] Failed to update read receipt for attempt ${attempt.id}`, { error: lifeOpsErrorMessage(error) });
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
buildReminderPlanSchedule(args) {
|
|
1139
|
+
const rows = [];
|
|
1140
|
+
if (args.ownerType === "occurrence") {
|
|
1141
|
+
const anchorIso = args.occurrence?.snoozedUntil ?? args.occurrence?.relevanceStartAt;
|
|
1142
|
+
if (!anchorIso) {
|
|
1143
|
+
return rows;
|
|
1144
|
+
}
|
|
1145
|
+
const anchorDate = new Date(anchorIso);
|
|
1146
|
+
for (const [stepIndex, step] of args.plan.steps.entries()) {
|
|
1147
|
+
rows.push({
|
|
1148
|
+
ownerType: args.ownerType,
|
|
1149
|
+
ownerId: args.ownerId,
|
|
1150
|
+
occurrenceId: args.occurrenceId,
|
|
1151
|
+
title: args.title,
|
|
1152
|
+
channel: step.channel,
|
|
1153
|
+
stepIndex,
|
|
1154
|
+
scheduledFor: addMinutes(anchorDate, step.offsetMinutes).toISOString(),
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
return rows;
|
|
1158
|
+
}
|
|
1159
|
+
if (!args.eventStartAt) {
|
|
1160
|
+
return rows;
|
|
1161
|
+
}
|
|
1162
|
+
const eventStartAt = new Date(args.eventStartAt);
|
|
1163
|
+
for (const [stepIndex, step] of args.plan.steps.entries()) {
|
|
1164
|
+
rows.push({
|
|
1165
|
+
ownerType: args.ownerType,
|
|
1166
|
+
ownerId: args.ownerId,
|
|
1167
|
+
occurrenceId: args.occurrenceId,
|
|
1168
|
+
title: args.title,
|
|
1169
|
+
channel: step.channel,
|
|
1170
|
+
stepIndex,
|
|
1171
|
+
scheduledFor: addMinutes(eventStartAt, -step.offsetMinutes).toISOString(),
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
return rows;
|
|
1175
|
+
}
|
|
1176
|
+
async resolveReminderEscalationChannels(args) {
|
|
1177
|
+
const ordered = [];
|
|
1178
|
+
const ownerContacts = loadOwnerContactsConfig(LIFEOPS_OWNER_CONTACTS_LOAD_CONTEXT);
|
|
1179
|
+
const ownerContactHints = await loadOwnerContactRoutingHints(this.runtime, ownerContacts);
|
|
1180
|
+
const preferredChannels = new Set();
|
|
1181
|
+
for (const hint of Object.values(ownerContactHints)) {
|
|
1182
|
+
const preferredChannel = mapPlatformToReminderChannel(hint.preferredCommunicationChannel);
|
|
1183
|
+
const recentChannel = mapPlatformToReminderChannel(hint.lastResponseChannel);
|
|
1184
|
+
if (preferredChannel) {
|
|
1185
|
+
preferredChannels.add(preferredChannel);
|
|
1186
|
+
}
|
|
1187
|
+
if (recentChannel) {
|
|
1188
|
+
preferredChannels.add(recentChannel);
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
const pushChannel = async (channel) => {
|
|
1192
|
+
if (!channel || ordered.includes(channel)) {
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
if (!isReminderChannelAllowedForUrgency(channel, args.urgency)) {
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
if (channel === "in_app") {
|
|
1199
|
+
ordered.push(channel);
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
const policy = await this.resolvePrimaryChannelPolicy(channel);
|
|
1203
|
+
if (policy) {
|
|
1204
|
+
if (!policy.allowReminders || !policy.allowEscalation) {
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
else if (channel === "sms" || channel === "voice") {
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
if (channel === "sms" || channel === "voice") {
|
|
1212
|
+
ordered.push(channel);
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
if (typeof this.runtime.sendMessageToTarget !== "function") {
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
const runtimeTarget = await this.resolveRuntimeReminderTarget(channel, policy, ownerContacts, ownerContactHints);
|
|
1219
|
+
if (runtimeTarget !== null) {
|
|
1220
|
+
ordered.push(channel);
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
await pushChannel(mapPlatformToReminderChannel(args.activityProfile?.isCurrentlyActive
|
|
1224
|
+
? args.activityProfile.lastSeenPlatform
|
|
1225
|
+
: null));
|
|
1226
|
+
await pushChannel(mapPlatformToReminderChannel(args.activityProfile?.primaryPlatform));
|
|
1227
|
+
await pushChannel(mapPlatformToReminderChannel(args.activityProfile?.secondaryPlatform));
|
|
1228
|
+
for (const preferredChannel of preferredChannels) {
|
|
1229
|
+
await pushChannel(preferredChannel);
|
|
1230
|
+
}
|
|
1231
|
+
for (const source of Object.keys(ownerContacts)) {
|
|
1232
|
+
const mappedChannel = mapPlatformToReminderChannel(source);
|
|
1233
|
+
if (mappedChannel === "in_app") {
|
|
1234
|
+
continue;
|
|
1235
|
+
}
|
|
1236
|
+
await pushChannel(mappedChannel);
|
|
1237
|
+
}
|
|
1238
|
+
for (const policy of args.policies) {
|
|
1239
|
+
await pushChannel(isReminderChannel(policy.channelType) ? policy.channelType : null);
|
|
1240
|
+
}
|
|
1241
|
+
return ordered;
|
|
1242
|
+
}
|
|
1243
|
+
async markReminderEscalationStarted(args) {
|
|
1244
|
+
if (args.ownerType === "occurrence") {
|
|
1245
|
+
const occurrence = await this.repository.getOccurrence(this.agentId(), args.ownerId);
|
|
1246
|
+
if (!occurrence) {
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1249
|
+
const channels = Array.isArray(occurrence.metadata[REMINDER_ESCALATION_CHANNELS_METADATA_KEY])
|
|
1250
|
+
? occurrence.metadata[REMINDER_ESCALATION_CHANNELS_METADATA_KEY].filter(isReminderChannel)
|
|
1251
|
+
: [];
|
|
1252
|
+
const nextChannels = [...new Set([...channels, args.channel])];
|
|
1253
|
+
await this.repository.updateOccurrence({
|
|
1254
|
+
...occurrence,
|
|
1255
|
+
metadata: {
|
|
1256
|
+
...occurrence.metadata,
|
|
1257
|
+
[REMINDER_ESCALATION_STARTED_AT_METADATA_KEY]: typeof occurrence.metadata[REMINDER_ESCALATION_STARTED_AT_METADATA_KEY] === "string"
|
|
1258
|
+
? occurrence.metadata[REMINDER_ESCALATION_STARTED_AT_METADATA_KEY]
|
|
1259
|
+
: args.attemptedAt,
|
|
1260
|
+
[REMINDER_ESCALATION_LAST_ATTEMPT_AT_METADATA_KEY]: args.attemptedAt,
|
|
1261
|
+
[REMINDER_ESCALATION_LAST_CHANNEL_METADATA_KEY]: args.channel,
|
|
1262
|
+
[REMINDER_ESCALATION_LAST_OUTCOME_METADATA_KEY]: args.outcome,
|
|
1263
|
+
[REMINDER_ESCALATION_CHANNELS_METADATA_KEY]: nextChannels,
|
|
1264
|
+
},
|
|
1265
|
+
updatedAt: new Date().toISOString(),
|
|
1266
|
+
});
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
const event = (await this.repository.listCalendarEvents(this.agentId(), "google")).find((candidate) => candidate.id === args.ownerId);
|
|
1270
|
+
if (!event) {
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
const channels = Array.isArray(event.metadata[REMINDER_ESCALATION_CHANNELS_METADATA_KEY])
|
|
1274
|
+
? event.metadata[REMINDER_ESCALATION_CHANNELS_METADATA_KEY].filter(isReminderChannel)
|
|
1275
|
+
: [];
|
|
1276
|
+
const nextChannels = [...new Set([...channels, args.channel])];
|
|
1277
|
+
await this.repository.upsertCalendarEvent({
|
|
1278
|
+
...event,
|
|
1279
|
+
metadata: {
|
|
1280
|
+
...event.metadata,
|
|
1281
|
+
[REMINDER_ESCALATION_STARTED_AT_METADATA_KEY]: typeof event.metadata[REMINDER_ESCALATION_STARTED_AT_METADATA_KEY] ===
|
|
1282
|
+
"string"
|
|
1283
|
+
? event.metadata[REMINDER_ESCALATION_STARTED_AT_METADATA_KEY]
|
|
1284
|
+
: args.attemptedAt,
|
|
1285
|
+
[REMINDER_ESCALATION_LAST_ATTEMPT_AT_METADATA_KEY]: args.attemptedAt,
|
|
1286
|
+
[REMINDER_ESCALATION_LAST_CHANNEL_METADATA_KEY]: args.channel,
|
|
1287
|
+
[REMINDER_ESCALATION_LAST_OUTCOME_METADATA_KEY]: args.outcome,
|
|
1288
|
+
[REMINDER_ESCALATION_CHANNELS_METADATA_KEY]: nextChannels,
|
|
1289
|
+
},
|
|
1290
|
+
updatedAt: new Date().toISOString(),
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
async resolveReminderEscalation(args) {
|
|
1294
|
+
const attempts = await this.repository.listReminderAttempts(this.agentId(), {
|
|
1295
|
+
ownerType: args.ownerType,
|
|
1296
|
+
ownerId: args.ownerId,
|
|
1297
|
+
});
|
|
1298
|
+
const escalationAttempts = attempts.filter((attempt) => readReminderAttemptLifecycle(attempt) === "escalation");
|
|
1299
|
+
const latestEscalation = escalationAttempts.at(-1) ?? null;
|
|
1300
|
+
if (!latestEscalation) {
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
const latestEscalationAt = Date.parse(latestEscalation.attemptedAt ?? latestEscalation.scheduledFor);
|
|
1304
|
+
if (args.ownerType === "occurrence") {
|
|
1305
|
+
const occurrence = await this.repository.getOccurrence(this.agentId(), args.ownerId);
|
|
1306
|
+
if (!occurrence) {
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
const resolvedAtValue = typeof occurrence.metadata[REMINDER_ESCALATION_RESOLVED_AT_METADATA_KEY] === "string"
|
|
1310
|
+
? occurrence.metadata[REMINDER_ESCALATION_RESOLVED_AT_METADATA_KEY]
|
|
1311
|
+
: null;
|
|
1312
|
+
if (resolvedAtValue &&
|
|
1313
|
+
Date.parse(resolvedAtValue) >= latestEscalationAt) {
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
await this.repository.updateOccurrence({
|
|
1317
|
+
...occurrence,
|
|
1318
|
+
metadata: {
|
|
1319
|
+
...occurrence.metadata,
|
|
1320
|
+
[REMINDER_ESCALATION_RESOLVED_AT_METADATA_KEY]: args.resolvedAt,
|
|
1321
|
+
[REMINDER_ESCALATION_RESOLUTION_METADATA_KEY]: args.resolution,
|
|
1322
|
+
[REMINDER_ESCALATION_RESOLUTION_NOTE_METADATA_KEY]: args.note ?? null,
|
|
1323
|
+
},
|
|
1324
|
+
updatedAt: new Date().toISOString(),
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
else {
|
|
1328
|
+
const event = (await this.repository.listCalendarEvents(this.agentId(), "google")).find((candidate) => candidate.id === args.ownerId);
|
|
1329
|
+
if (!event) {
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
const resolvedAtValue = typeof event.metadata[REMINDER_ESCALATION_RESOLVED_AT_METADATA_KEY] ===
|
|
1333
|
+
"string"
|
|
1334
|
+
? event.metadata[REMINDER_ESCALATION_RESOLVED_AT_METADATA_KEY]
|
|
1335
|
+
: null;
|
|
1336
|
+
if (resolvedAtValue &&
|
|
1337
|
+
Date.parse(resolvedAtValue) >= latestEscalationAt) {
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
await this.repository.upsertCalendarEvent({
|
|
1341
|
+
...event,
|
|
1342
|
+
metadata: {
|
|
1343
|
+
...event.metadata,
|
|
1344
|
+
[REMINDER_ESCALATION_RESOLVED_AT_METADATA_KEY]: args.resolvedAt,
|
|
1345
|
+
[REMINDER_ESCALATION_RESOLUTION_METADATA_KEY]: args.resolution,
|
|
1346
|
+
[REMINDER_ESCALATION_RESOLUTION_NOTE_METADATA_KEY]: args.note ?? null,
|
|
1347
|
+
},
|
|
1348
|
+
updatedAt: new Date().toISOString(),
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
await this.recordReminderAudit("reminder_escalation_resolved", args.ownerType, args.ownerId, "reminder escalation resolved", {
|
|
1352
|
+
resolution: args.resolution,
|
|
1353
|
+
note: args.note ?? null,
|
|
1354
|
+
}, {
|
|
1355
|
+
resolvedAt: args.resolvedAt,
|
|
1356
|
+
lastEscalationChannel: latestEscalation.channel,
|
|
1357
|
+
lastEscalationOutcome: latestEscalation.outcome,
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
async dispatchDueReminderEscalation(args) {
|
|
1361
|
+
if (!shouldDeliverReminderForIntensity(args.intensity, args.urgency)) {
|
|
1362
|
+
return null;
|
|
1363
|
+
}
|
|
1364
|
+
if (args.acknowledged || args.urgency === "low") {
|
|
1365
|
+
return null;
|
|
1366
|
+
}
|
|
1367
|
+
const ownerAttempts = args.attempts.filter((attempt) => attempt.ownerType === args.ownerType &&
|
|
1368
|
+
attempt.ownerId === args.ownerId);
|
|
1369
|
+
if (ownerAttempts.length === 0) {
|
|
1370
|
+
return null;
|
|
1371
|
+
}
|
|
1372
|
+
const escalationAttempts = ownerAttempts.filter((attempt) => readReminderAttemptLifecycle(attempt) === "escalation");
|
|
1373
|
+
const schedule = this.buildReminderPlanSchedule({
|
|
1374
|
+
ownerType: args.ownerType,
|
|
1375
|
+
ownerId: args.ownerId,
|
|
1376
|
+
occurrenceId: args.occurrenceId,
|
|
1377
|
+
title: args.title,
|
|
1378
|
+
plan: args.plan,
|
|
1379
|
+
occurrence: args.occurrence ?? null,
|
|
1380
|
+
eventStartAt: args.eventStartAt ?? null,
|
|
1381
|
+
});
|
|
1382
|
+
if (schedule.length === 0) {
|
|
1383
|
+
return null;
|
|
1384
|
+
}
|
|
1385
|
+
const lastNormalAttempt = ownerAttempts
|
|
1386
|
+
.filter((attempt) => readReminderAttemptLifecycle(attempt) === "plan")
|
|
1387
|
+
.at(-1);
|
|
1388
|
+
if (!lastNormalAttempt) {
|
|
1389
|
+
return null;
|
|
1390
|
+
}
|
|
1391
|
+
const lastScheduledPlanEntry = schedule[schedule.length - 1];
|
|
1392
|
+
const lastScheduledPlanTime = Date.parse(lastScheduledPlanEntry.scheduledFor);
|
|
1393
|
+
const nowMs = args.now.getTime();
|
|
1394
|
+
const planExhausted = nowMs >= lastScheduledPlanTime;
|
|
1395
|
+
if (!planExhausted &&
|
|
1396
|
+
!shouldEscalateImmediately(lastNormalAttempt.outcome)) {
|
|
1397
|
+
return null;
|
|
1398
|
+
}
|
|
1399
|
+
const lastScheduledPlanAttempt = ownerAttempts.find((attempt) => readReminderAttemptLifecycle(attempt) === "plan" &&
|
|
1400
|
+
attempt.stepIndex === lastScheduledPlanEntry.stepIndex &&
|
|
1401
|
+
attempt.scheduledFor === lastScheduledPlanEntry.scheduledFor);
|
|
1402
|
+
const gatingPlanAttempt = planExhausted
|
|
1403
|
+
? lastScheduledPlanAttempt
|
|
1404
|
+
: lastNormalAttempt;
|
|
1405
|
+
if (!gatingPlanAttempt && escalationAttempts.length === 0) {
|
|
1406
|
+
return null;
|
|
1407
|
+
}
|
|
1408
|
+
const candidateChannels = await this.resolveReminderEscalationChannels({
|
|
1409
|
+
activityProfile: args.activityProfile,
|
|
1410
|
+
policies: args.policies,
|
|
1411
|
+
urgency: args.urgency,
|
|
1412
|
+
});
|
|
1413
|
+
const attemptedChannels = new Set(ownerAttempts.map((attempt) => attempt.channel));
|
|
1414
|
+
const lastEscalationAttempt = escalationAttempts.at(-1) ?? null;
|
|
1415
|
+
let nextChannel = candidateChannels.find((channel) => !attemptedChannels.has(channel)) ??
|
|
1416
|
+
null;
|
|
1417
|
+
if (!nextChannel &&
|
|
1418
|
+
(lastEscalationAttempt?.outcome === "delivered" ||
|
|
1419
|
+
lastEscalationAttempt?.outcome === "delivered_read" ||
|
|
1420
|
+
lastEscalationAttempt?.outcome === "delivered_unread") &&
|
|
1421
|
+
candidateChannels.includes(lastEscalationAttempt.channel)) {
|
|
1422
|
+
nextChannel = lastEscalationAttempt.channel;
|
|
1423
|
+
}
|
|
1424
|
+
if (!nextChannel) {
|
|
1425
|
+
return null;
|
|
1426
|
+
}
|
|
1427
|
+
const previousAttempt = escalationAttempts.at(-1) ?? gatingPlanAttempt ?? lastNormalAttempt;
|
|
1428
|
+
if (!previousAttempt) {
|
|
1429
|
+
return null;
|
|
1430
|
+
}
|
|
1431
|
+
const delayMinutes = resolveReminderEscalationDelayMinutes(args.urgency, previousAttempt.outcome, escalationAttempts.length > 0);
|
|
1432
|
+
if (delayMinutes === null) {
|
|
1433
|
+
return null;
|
|
1434
|
+
}
|
|
1435
|
+
// TODO: wire enforcement overrides here — call
|
|
1436
|
+
// buildReminderEnforcementState(now, timezone, definition, twilioVoiceAvailable)
|
|
1437
|
+
// and applyEnforcementOverrides(delayMinutes, state) to shorten the gap
|
|
1438
|
+
// for morning/night routine occurrences, and force a voice channel
|
|
1439
|
+
// when state.forceVoice is true. Pipe the timezone + definition in via
|
|
1440
|
+
// dispatchReminderAttempt args before enabling this path.
|
|
1441
|
+
const scheduledFor = addMinutes(new Date(previousAttempt.attemptedAt ?? previousAttempt.scheduledFor), delayMinutes).toISOString();
|
|
1442
|
+
if (Date.parse(scheduledFor) > nowMs) {
|
|
1443
|
+
return null;
|
|
1444
|
+
}
|
|
1445
|
+
const attempt = await this.dispatchReminderAttempt({
|
|
1446
|
+
plan: args.plan,
|
|
1447
|
+
ownerType: args.ownerType,
|
|
1448
|
+
ownerId: args.ownerId,
|
|
1449
|
+
occurrenceId: args.occurrenceId,
|
|
1450
|
+
subjectType: args.subjectType,
|
|
1451
|
+
title: args.title,
|
|
1452
|
+
channel: nextChannel,
|
|
1453
|
+
stepIndex: args.plan.steps.length + escalationAttempts.length,
|
|
1454
|
+
scheduledFor,
|
|
1455
|
+
dueAt: args.dueAt,
|
|
1456
|
+
urgency: args.urgency,
|
|
1457
|
+
quietHours: args.quietHours,
|
|
1458
|
+
acknowledged: false,
|
|
1459
|
+
attemptedAt: args.attemptedAt,
|
|
1460
|
+
lifecycle: "escalation",
|
|
1461
|
+
escalationIndex: escalationAttempts.length,
|
|
1462
|
+
escalationReason: escalationAttempts.length > 0
|
|
1463
|
+
? "previous_escalation_unacknowledged"
|
|
1464
|
+
: "plan_exhausted_without_acknowledgement",
|
|
1465
|
+
activityProfile: args.activityProfile,
|
|
1466
|
+
nearbyReminderTitles: args.nearbyReminderTitles,
|
|
1467
|
+
});
|
|
1468
|
+
await this.markReminderEscalationStarted({
|
|
1469
|
+
ownerType: args.ownerType,
|
|
1470
|
+
ownerId: args.ownerId,
|
|
1471
|
+
attemptedAt: args.attemptedAt,
|
|
1472
|
+
channel: nextChannel,
|
|
1473
|
+
outcome: attempt.outcome,
|
|
1474
|
+
});
|
|
1475
|
+
if (escalationAttempts.length === 0) {
|
|
1476
|
+
await this.recordReminderAudit("reminder_escalation_started", args.ownerType, args.ownerId, "reminder escalation started", {
|
|
1477
|
+
channel: nextChannel,
|
|
1478
|
+
scheduledFor,
|
|
1479
|
+
}, {
|
|
1480
|
+
urgency: args.urgency,
|
|
1481
|
+
activityPlatform: args.activityProfile?.lastSeenPlatform ?? null,
|
|
1482
|
+
activityActive: args.activityProfile?.isCurrentlyActive ?? false,
|
|
1483
|
+
outcome: attempt.outcome,
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
return attempt;
|
|
1487
|
+
}
|
|
1488
|
+
async awardWebsiteAccessGrant(definition, occurrenceId, now = new Date()) {
|
|
1489
|
+
const policy = definition.websiteAccess;
|
|
1490
|
+
if (!policy) {
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
const unlockedAt = now.toISOString();
|
|
1494
|
+
await this.repository.revokeWebsiteAccessGrants(definition.agentId, {
|
|
1495
|
+
groupKey: policy.groupKey,
|
|
1496
|
+
revokedAt: unlockedAt,
|
|
1497
|
+
});
|
|
1498
|
+
const expiresAt = policy.unlockMode === "fixed_duration" &&
|
|
1499
|
+
typeof policy.unlockDurationMinutes === "number"
|
|
1500
|
+
? addMinutes(now, policy.unlockDurationMinutes).toISOString()
|
|
1501
|
+
: null;
|
|
1502
|
+
const grant = createLifeOpsWebsiteAccessGrant({
|
|
1503
|
+
agentId: definition.agentId,
|
|
1504
|
+
groupKey: policy.groupKey,
|
|
1505
|
+
definitionId: definition.id,
|
|
1506
|
+
occurrenceId,
|
|
1507
|
+
websites: [...policy.websites],
|
|
1508
|
+
unlockMode: policy.unlockMode,
|
|
1509
|
+
unlockDurationMinutes: policy.unlockMode === "fixed_duration"
|
|
1510
|
+
? (policy.unlockDurationMinutes ?? null)
|
|
1511
|
+
: null,
|
|
1512
|
+
callbackKey: policy.callbackKey ?? null,
|
|
1513
|
+
unlockedAt,
|
|
1514
|
+
expiresAt,
|
|
1515
|
+
revokedAt: null,
|
|
1516
|
+
metadata: {
|
|
1517
|
+
definitionTitle: definition.title,
|
|
1518
|
+
reason: policy.reason,
|
|
1519
|
+
},
|
|
1520
|
+
});
|
|
1521
|
+
await this.repository.upsertWebsiteAccessGrant(grant);
|
|
1522
|
+
}
|
|
1523
|
+
async syncWebsiteAccessState(now = new Date()) {
|
|
1524
|
+
const definitions = (await this.repository.listDefinitions(this.agentId())).filter((definition) => definition.status === "active" && definition.websiteAccess);
|
|
1525
|
+
const groups = new Map();
|
|
1526
|
+
for (const definition of definitions) {
|
|
1527
|
+
const policy = definition.websiteAccess;
|
|
1528
|
+
if (!policy) {
|
|
1529
|
+
continue;
|
|
1530
|
+
}
|
|
1531
|
+
const websites = groups.get(policy.groupKey) ?? new Set();
|
|
1532
|
+
for (const website of policy.websites) {
|
|
1533
|
+
websites.add(website.toLowerCase());
|
|
1534
|
+
}
|
|
1535
|
+
groups.set(policy.groupKey, websites);
|
|
1536
|
+
}
|
|
1537
|
+
const activeGrants = (await this.repository.listWebsiteAccessGrants(this.agentId())).filter((grant) => isWebsiteAccessGrantActive(grant, now));
|
|
1538
|
+
const unlockedGroups = new Set(activeGrants.map((grant) => grant.groupKey));
|
|
1539
|
+
const blockedGroups = [...groups.keys()].filter((groupKey) => !unlockedGroups.has(groupKey));
|
|
1540
|
+
const blockedWebsites = normalizeWebsiteListForComparison(blockedGroups.flatMap((groupKey) => [...(groups.get(groupKey) ?? [])]));
|
|
1541
|
+
let status;
|
|
1542
|
+
try {
|
|
1543
|
+
status = await getSelfControlStatus();
|
|
1544
|
+
}
|
|
1545
|
+
catch (error) {
|
|
1546
|
+
this.logLifeOpsError("website_access_status", error, {
|
|
1547
|
+
blockedGroups,
|
|
1548
|
+
});
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
const activeLifeOpsBlock = status.active && status.managedBy === "lifeops";
|
|
1552
|
+
if (status.active && !activeLifeOpsBlock) {
|
|
1553
|
+
if (blockedWebsites.length > 0) {
|
|
1554
|
+
this.logLifeOpsWarn("website_access_sync", "[lifeops] Website blocker is already active outside LifeOps; skipping blocker sync.", {
|
|
1555
|
+
managedBy: status.managedBy,
|
|
1556
|
+
currentWebsites: status.websites,
|
|
1557
|
+
blockedWebsites,
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
if (blockedWebsites.length === 0) {
|
|
1563
|
+
if (!activeLifeOpsBlock) {
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
const stopResult = await stopSelfControlBlock();
|
|
1567
|
+
if (stopResult.success === false) {
|
|
1568
|
+
this.logLifeOpsWarn("website_access_sync", "[lifeops] Failed to clear the LifeOps-managed website blocker state.", {
|
|
1569
|
+
error: stopResult.error,
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
return;
|
|
1573
|
+
}
|
|
1574
|
+
if (activeLifeOpsBlock &&
|
|
1575
|
+
haveSameWebsiteSet(status.websites, blockedWebsites)) {
|
|
1576
|
+
return;
|
|
1577
|
+
}
|
|
1578
|
+
if (activeLifeOpsBlock) {
|
|
1579
|
+
const stopResult = await stopSelfControlBlock();
|
|
1580
|
+
if (stopResult.success === false) {
|
|
1581
|
+
this.logLifeOpsWarn("website_access_sync", "[lifeops] Failed to update the existing LifeOps website block.", {
|
|
1582
|
+
error: stopResult.error,
|
|
1583
|
+
blockedWebsites,
|
|
1584
|
+
});
|
|
1585
|
+
return;
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
const startResult = await startSelfControlBlock({
|
|
1589
|
+
websites: blockedWebsites,
|
|
1590
|
+
durationMinutes: null,
|
|
1591
|
+
metadata: {
|
|
1592
|
+
managedBy: "lifeops",
|
|
1593
|
+
blockedGroups,
|
|
1594
|
+
reason: "lifeops_earned_access",
|
|
1595
|
+
},
|
|
1596
|
+
});
|
|
1597
|
+
if (startResult.success === false) {
|
|
1598
|
+
this.logLifeOpsWarn("website_access_sync", "[lifeops] Failed to apply the LifeOps website block.", {
|
|
1599
|
+
error: startResult.error,
|
|
1600
|
+
blockedWebsites,
|
|
1601
|
+
blockedGroups,
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
async dispatchReminderAttempt(args) {
|
|
1606
|
+
const attemptedAt = args.attemptedAt;
|
|
1607
|
+
const attemptedAtDate = new Date(attemptedAt);
|
|
1608
|
+
const lifecycle = args.lifecycle ?? "plan";
|
|
1609
|
+
const reminderBody = await this.renderReminderBody({
|
|
1610
|
+
title: args.title,
|
|
1611
|
+
scheduledFor: args.scheduledFor,
|
|
1612
|
+
dueAt: args.dueAt,
|
|
1613
|
+
channel: args.channel,
|
|
1614
|
+
lifecycle,
|
|
1615
|
+
urgency: args.urgency,
|
|
1616
|
+
subjectType: args.subjectType,
|
|
1617
|
+
nearbyReminderTitles: args.nearbyReminderTitles,
|
|
1618
|
+
});
|
|
1619
|
+
let outcome = "delivered";
|
|
1620
|
+
let connectorRef = null;
|
|
1621
|
+
const deliveryMetadata = {
|
|
1622
|
+
title: args.title,
|
|
1623
|
+
urgency: args.urgency,
|
|
1624
|
+
[REMINDER_LIFECYCLE_METADATA_KEY]: lifecycle,
|
|
1625
|
+
};
|
|
1626
|
+
if (lifecycle === "escalation") {
|
|
1627
|
+
deliveryMetadata[REMINDER_ESCALATION_INDEX_METADATA_KEY] =
|
|
1628
|
+
args.escalationIndex ?? 0;
|
|
1629
|
+
deliveryMetadata[REMINDER_ESCALATION_REASON_METADATA_KEY] =
|
|
1630
|
+
args.escalationReason ?? "escalation";
|
|
1631
|
+
deliveryMetadata[REMINDER_ESCALATION_ACTIVITY_PLATFORM_METADATA_KEY] =
|
|
1632
|
+
args.activityProfile?.lastSeenPlatform ??
|
|
1633
|
+
args.activityProfile?.primaryPlatform ??
|
|
1634
|
+
null;
|
|
1635
|
+
deliveryMetadata[REMINDER_ESCALATION_ACTIVITY_ACTIVE_METADATA_KEY] =
|
|
1636
|
+
args.activityProfile?.isCurrentlyActive ?? false;
|
|
1637
|
+
}
|
|
1638
|
+
await this.recordReminderAudit("reminder_due", args.ownerType, args.ownerId, "reminder step became due", {
|
|
1639
|
+
planId: args.plan.id,
|
|
1640
|
+
channel: args.channel,
|
|
1641
|
+
stepIndex: args.stepIndex,
|
|
1642
|
+
scheduledFor: args.scheduledFor,
|
|
1643
|
+
}, {
|
|
1644
|
+
ownerId: args.ownerId,
|
|
1645
|
+
});
|
|
1646
|
+
if (args.acknowledged) {
|
|
1647
|
+
outcome = "blocked_acknowledged";
|
|
1648
|
+
deliveryMetadata.reason = "owner_acknowledged";
|
|
1649
|
+
}
|
|
1650
|
+
else if (!isReminderChannelAllowedForUrgency(args.channel, args.urgency)) {
|
|
1651
|
+
outcome = "blocked_urgency";
|
|
1652
|
+
deliveryMetadata.reason = "urgency_gate";
|
|
1653
|
+
}
|
|
1654
|
+
else if (args.channel !== "in_app" &&
|
|
1655
|
+
isWithinQuietHours({
|
|
1656
|
+
now: attemptedAtDate,
|
|
1657
|
+
quietHours: args.quietHours,
|
|
1658
|
+
channel: args.channel,
|
|
1659
|
+
})) {
|
|
1660
|
+
outcome = "blocked_quiet_hours";
|
|
1661
|
+
deliveryMetadata.reason = "quiet_hours";
|
|
1662
|
+
}
|
|
1663
|
+
else if (args.channel === "in_app") {
|
|
1664
|
+
connectorRef = "system:in_app";
|
|
1665
|
+
deliveryMetadata.message = reminderBody;
|
|
1666
|
+
}
|
|
1667
|
+
else {
|
|
1668
|
+
const policy = await this.resolvePrimaryChannelPolicy(args.channel);
|
|
1669
|
+
const runtimeTarget = args.channel === "sms" || args.channel === "voice"
|
|
1670
|
+
? null
|
|
1671
|
+
: await this.resolveRuntimeReminderTarget(args.channel, policy);
|
|
1672
|
+
const requiresEscalationPermission = args.stepIndex > 0;
|
|
1673
|
+
if (policy && !policy.allowReminders) {
|
|
1674
|
+
outcome = "blocked_policy";
|
|
1675
|
+
deliveryMetadata.reason = "channel_policy";
|
|
1676
|
+
}
|
|
1677
|
+
else if ((lifecycle === "escalation" || requiresEscalationPermission) &&
|
|
1678
|
+
policy &&
|
|
1679
|
+
!policy.allowEscalation) {
|
|
1680
|
+
outcome = "blocked_policy";
|
|
1681
|
+
deliveryMetadata.reason = "channel_escalation_policy";
|
|
1682
|
+
}
|
|
1683
|
+
else if ((args.channel === "sms" || args.channel === "voice") &&
|
|
1684
|
+
!policy) {
|
|
1685
|
+
outcome = "blocked_policy";
|
|
1686
|
+
deliveryMetadata.reason = "channel_policy";
|
|
1687
|
+
}
|
|
1688
|
+
else if (args.channel === "sms" || args.channel === "voice") {
|
|
1689
|
+
const credentials = readTwilioCredentialsFromEnv();
|
|
1690
|
+
const twilioPolicy = policy;
|
|
1691
|
+
if (!credentials) {
|
|
1692
|
+
outcome = "blocked_connector";
|
|
1693
|
+
deliveryMetadata.reason = "twilio_missing";
|
|
1694
|
+
}
|
|
1695
|
+
else if (!twilioPolicy) {
|
|
1696
|
+
outcome = "blocked_policy";
|
|
1697
|
+
deliveryMetadata.reason = "channel_policy";
|
|
1698
|
+
}
|
|
1699
|
+
else if ((lifecycle === "escalation" || requiresEscalationPermission) &&
|
|
1700
|
+
!twilioPolicy.allowEscalation) {
|
|
1701
|
+
outcome = "blocked_policy";
|
|
1702
|
+
deliveryMetadata.reason = "channel_escalation_policy";
|
|
1703
|
+
}
|
|
1704
|
+
else {
|
|
1705
|
+
connectorRef = `twilio:${twilioPolicy.channelRef}`;
|
|
1706
|
+
if (args.channel === "sms") {
|
|
1707
|
+
const result = await sendTwilioSms({
|
|
1708
|
+
credentials,
|
|
1709
|
+
to: twilioPolicy.channelRef,
|
|
1710
|
+
body: reminderBody,
|
|
1711
|
+
});
|
|
1712
|
+
if (!result.ok) {
|
|
1713
|
+
outcome = "blocked_connector";
|
|
1714
|
+
deliveryMetadata.error = result.error ?? "sms delivery failed";
|
|
1715
|
+
deliveryMetadata.status = result.status;
|
|
1716
|
+
}
|
|
1717
|
+
else {
|
|
1718
|
+
deliveryMetadata.sid = result.sid ?? null;
|
|
1719
|
+
deliveryMetadata.status = result.status;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
else {
|
|
1723
|
+
const result = await sendTwilioVoiceCall({
|
|
1724
|
+
credentials,
|
|
1725
|
+
to: twilioPolicy.channelRef,
|
|
1726
|
+
message: reminderBody,
|
|
1727
|
+
});
|
|
1728
|
+
if (!result.ok) {
|
|
1729
|
+
outcome = "blocked_connector";
|
|
1730
|
+
deliveryMetadata.error = result.error ?? "voice delivery failed";
|
|
1731
|
+
deliveryMetadata.status = result.status;
|
|
1732
|
+
}
|
|
1733
|
+
else {
|
|
1734
|
+
deliveryMetadata.sid = result.sid ?? null;
|
|
1735
|
+
deliveryMetadata.status = result.status;
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
else if (runtimeTarget) {
|
|
1741
|
+
connectorRef = runtimeTarget.connectorRef;
|
|
1742
|
+
deliveryMetadata.routeSource = runtimeTarget.source;
|
|
1743
|
+
deliveryMetadata.routeResolution = runtimeTarget.resolution;
|
|
1744
|
+
deliveryMetadata.routeEndpoint =
|
|
1745
|
+
runtimeTarget.target.channelId ??
|
|
1746
|
+
runtimeTarget.target.roomId ??
|
|
1747
|
+
runtimeTarget.target.entityId ??
|
|
1748
|
+
null;
|
|
1749
|
+
const sendPayload = {
|
|
1750
|
+
text: reminderBody,
|
|
1751
|
+
source: runtimeTarget.source,
|
|
1752
|
+
metadata: {
|
|
1753
|
+
channelType: args.channel,
|
|
1754
|
+
lifeopsReminder: true,
|
|
1755
|
+
ownerType: args.ownerType,
|
|
1756
|
+
ownerId: args.ownerId,
|
|
1757
|
+
urgency: args.urgency,
|
|
1758
|
+
scheduledFor: args.scheduledFor,
|
|
1759
|
+
routeSource: runtimeTarget.source,
|
|
1760
|
+
routeEndpoint: runtimeTarget.target.channelId ??
|
|
1761
|
+
runtimeTarget.target.roomId ??
|
|
1762
|
+
runtimeTarget.target.entityId ??
|
|
1763
|
+
null,
|
|
1764
|
+
routeResolution: runtimeTarget.resolution,
|
|
1765
|
+
},
|
|
1766
|
+
};
|
|
1767
|
+
try {
|
|
1768
|
+
await this.runtime.sendMessageToTarget(runtimeTarget.target, sendPayload);
|
|
1769
|
+
}
|
|
1770
|
+
catch (firstError) {
|
|
1771
|
+
this.logLifeOpsWarn("reminder_dispatch", `[lifeops] Reminder delivery failed for ${args.channel}, retrying in 2s`, { error: lifeOpsErrorMessage(firstError) });
|
|
1772
|
+
await new Promise((r) => setTimeout(r, 2_000));
|
|
1773
|
+
try {
|
|
1774
|
+
await this.runtime.sendMessageToTarget(runtimeTarget.target, sendPayload);
|
|
1775
|
+
}
|
|
1776
|
+
catch (retryError) {
|
|
1777
|
+
outcome = "blocked_connector";
|
|
1778
|
+
deliveryMetadata.error = lifeOpsErrorMessage(retryError);
|
|
1779
|
+
deliveryMetadata.reason = "runtime_send_failed";
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
else {
|
|
1784
|
+
outcome = "blocked_connector";
|
|
1785
|
+
deliveryMetadata.reason = policy
|
|
1786
|
+
? "target_missing"
|
|
1787
|
+
: "unconfigured_channel";
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
const attempt = createLifeOpsReminderAttempt({
|
|
1791
|
+
agentId: this.agentId(),
|
|
1792
|
+
planId: args.plan.id,
|
|
1793
|
+
ownerType: args.ownerType,
|
|
1794
|
+
ownerId: args.ownerId,
|
|
1795
|
+
occurrenceId: args.occurrenceId,
|
|
1796
|
+
channel: args.channel,
|
|
1797
|
+
stepIndex: args.stepIndex,
|
|
1798
|
+
scheduledFor: args.scheduledFor,
|
|
1799
|
+
attemptedAt,
|
|
1800
|
+
outcome,
|
|
1801
|
+
connectorRef,
|
|
1802
|
+
deliveryMetadata,
|
|
1803
|
+
});
|
|
1804
|
+
await this.repository.createReminderAttempt(attempt);
|
|
1805
|
+
await this.recordReminderAudit(outcome === "delivered" ? "reminder_delivered" : "reminder_blocked", args.ownerType, args.ownerId, outcome === "delivered" ? "reminder delivered" : "reminder blocked", {
|
|
1806
|
+
planId: args.plan.id,
|
|
1807
|
+
channel: args.channel,
|
|
1808
|
+
stepIndex: args.stepIndex,
|
|
1809
|
+
scheduledFor: args.scheduledFor,
|
|
1810
|
+
}, {
|
|
1811
|
+
connectorRef,
|
|
1812
|
+
outcome,
|
|
1813
|
+
...deliveryMetadata,
|
|
1814
|
+
});
|
|
1815
|
+
if (outcome === "blocked_connector") {
|
|
1816
|
+
this.logLifeOpsWarn("reminder_dispatch", `[lifeops] Reminder delivery failed for ${args.channel}`, {
|
|
1817
|
+
ownerType: args.ownerType,
|
|
1818
|
+
ownerId: args.ownerId,
|
|
1819
|
+
occurrenceId: args.occurrenceId,
|
|
1820
|
+
channel: args.channel,
|
|
1821
|
+
connectorRef,
|
|
1822
|
+
scheduledFor: args.scheduledFor,
|
|
1823
|
+
stepIndex: args.stepIndex,
|
|
1824
|
+
reason: typeof deliveryMetadata.reason === "string"
|
|
1825
|
+
? deliveryMetadata.reason
|
|
1826
|
+
: null,
|
|
1827
|
+
status: typeof deliveryMetadata.status === "number"
|
|
1828
|
+
? deliveryMetadata.status
|
|
1829
|
+
: null,
|
|
1830
|
+
error: typeof deliveryMetadata.error === "string"
|
|
1831
|
+
? deliveryMetadata.error
|
|
1832
|
+
: null,
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
if (outcome === "delivered" && args.channel === "in_app") {
|
|
1836
|
+
this.emitInAppReminderNudge({
|
|
1837
|
+
text: reminderBody,
|
|
1838
|
+
ownerType: args.ownerType,
|
|
1839
|
+
ownerId: args.ownerId,
|
|
1840
|
+
subjectType: args.subjectType,
|
|
1841
|
+
scheduledFor: args.scheduledFor,
|
|
1842
|
+
dueAt: args.dueAt,
|
|
1843
|
+
});
|
|
1844
|
+
}
|
|
1845
|
+
return attempt;
|
|
1846
|
+
}
|
|
1847
|
+
resolveGlobalReminderPreferencePolicy(policies) {
|
|
1848
|
+
const candidates = policies.filter((policy) => policy.channelType === "in_app" &&
|
|
1849
|
+
(policy.channelRef === GLOBAL_REMINDER_PREFERENCE_CHANNEL_REF ||
|
|
1850
|
+
policy.metadata[REMINDER_PREFERENCE_SCOPE_METADATA_KEY] === "global"));
|
|
1851
|
+
return (candidates.find((policy) => policy.metadata.isPrimary === true) ??
|
|
1852
|
+
candidates[0] ??
|
|
1853
|
+
null);
|
|
1854
|
+
}
|
|
1855
|
+
buildReminderPreferenceResponse(definition, policies) {
|
|
1856
|
+
const globalPolicy = this.resolveGlobalReminderPreferencePolicy(policies);
|
|
1857
|
+
const globalSetting = readReminderPreferenceSettingFromMetadata(globalPolicy?.metadata, "global_policy") ?? {
|
|
1858
|
+
intensity: DEFAULT_REMINDER_INTENSITY,
|
|
1859
|
+
source: "default",
|
|
1860
|
+
updatedAt: null,
|
|
1861
|
+
note: null,
|
|
1862
|
+
};
|
|
1863
|
+
const definitionSetting = definition
|
|
1864
|
+
? readReminderPreferenceSettingFromMetadata(definition.metadata, "definition_metadata")
|
|
1865
|
+
: null;
|
|
1866
|
+
return {
|
|
1867
|
+
definitionId: definition?.id ?? null,
|
|
1868
|
+
definitionTitle: definition?.title ?? null,
|
|
1869
|
+
global: globalSetting,
|
|
1870
|
+
definition: definitionSetting,
|
|
1871
|
+
effective: definitionSetting ?? globalSetting,
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
resolveEffectiveReminderPlan(plan, preference) {
|
|
1875
|
+
if (!plan) {
|
|
1876
|
+
return null;
|
|
1877
|
+
}
|
|
1878
|
+
return applyReminderIntensityToPlan(plan, preference.effective.intensity);
|
|
1879
|
+
}
|
|
1880
|
+
async getReminderPreference(definitionId) {
|
|
1881
|
+
const definition = definitionId
|
|
1882
|
+
? await this.repository.getDefinition(this.agentId(), requireNonEmptyString(definitionId, "definitionId"))
|
|
1883
|
+
: null;
|
|
1884
|
+
if (definitionId && !definition) {
|
|
1885
|
+
fail(404, "life-ops definition not found");
|
|
1886
|
+
}
|
|
1887
|
+
const policies = await this.repository.listChannelPolicies(this.agentId());
|
|
1888
|
+
return this.buildReminderPreferenceResponse(definition, policies);
|
|
1889
|
+
}
|
|
1890
|
+
async setReminderPreference(request) {
|
|
1891
|
+
const intensity = normalizeReminderIntensityInput(request.intensity, "intensity");
|
|
1892
|
+
const note = normalizeOptionalString(request.note) ?? null;
|
|
1893
|
+
const updatedAt = new Date().toISOString();
|
|
1894
|
+
const definitionId = normalizeOptionalString(request.definitionId) ?? null;
|
|
1895
|
+
if (definitionId) {
|
|
1896
|
+
const definition = await this.repository.getDefinition(this.agentId(), definitionId);
|
|
1897
|
+
if (!definition) {
|
|
1898
|
+
fail(404, "life-ops definition not found");
|
|
1899
|
+
}
|
|
1900
|
+
const nextDefinition = {
|
|
1901
|
+
...definition,
|
|
1902
|
+
metadata: withReminderPreferenceMetadata(definition.metadata, intensity, updatedAt, note, "definition"),
|
|
1903
|
+
updatedAt,
|
|
1904
|
+
};
|
|
1905
|
+
await this.repository.updateDefinition(nextDefinition);
|
|
1906
|
+
await this.recordAudit("definition_updated", "definition", definition.id, "reminder preference updated", {
|
|
1907
|
+
request,
|
|
1908
|
+
}, {
|
|
1909
|
+
reminderIntensity: intensity,
|
|
1910
|
+
note,
|
|
1911
|
+
});
|
|
1912
|
+
const policies = await this.repository.listChannelPolicies(this.agentId());
|
|
1913
|
+
return this.buildReminderPreferenceResponse(nextDefinition, policies);
|
|
1914
|
+
}
|
|
1915
|
+
await this.upsertChannelPolicy({
|
|
1916
|
+
channelType: "in_app",
|
|
1917
|
+
channelRef: GLOBAL_REMINDER_PREFERENCE_CHANNEL_REF,
|
|
1918
|
+
privacyClass: "private",
|
|
1919
|
+
allowReminders: true,
|
|
1920
|
+
allowEscalation: false,
|
|
1921
|
+
allowPosts: false,
|
|
1922
|
+
requireConfirmationForActions: false,
|
|
1923
|
+
metadata: {
|
|
1924
|
+
isPrimary: true,
|
|
1925
|
+
[REMINDER_PREFERENCE_SCOPE_METADATA_KEY]: "global",
|
|
1926
|
+
[REMINDER_INTENSITY_METADATA_KEY]: intensity,
|
|
1927
|
+
[REMINDER_INTENSITY_UPDATED_AT_METADATA_KEY]: updatedAt,
|
|
1928
|
+
[REMINDER_INTENSITY_NOTE_METADATA_KEY]: note,
|
|
1929
|
+
},
|
|
1930
|
+
});
|
|
1931
|
+
return this.getReminderPreference();
|
|
1932
|
+
}
|
|
1933
|
+
async captureActivitySignal(request) {
|
|
1934
|
+
const health = normalizeHealthSignal(request.health, "health");
|
|
1935
|
+
const signal = createLifeOpsActivitySignal({
|
|
1936
|
+
agentId: this.agentId(),
|
|
1937
|
+
source: normalizeActivitySignalSource(request.source, "source"),
|
|
1938
|
+
platform: normalizeOptionalString(request.platform) ?? "client_chat",
|
|
1939
|
+
state: normalizeActivitySignalState(request.state, "state"),
|
|
1940
|
+
observedAt: normalizeOptionalIsoString(request.observedAt, "observedAt") ??
|
|
1941
|
+
new Date().toISOString(),
|
|
1942
|
+
idleState: normalizeOptionalIdleState(request.idleState, "idleState"),
|
|
1943
|
+
idleTimeSeconds: normalizeOptionalNonNegativeInteger(request.idleTimeSeconds, "idleTimeSeconds"),
|
|
1944
|
+
onBattery: normalizeOptionalBoolean(request.onBattery, "onBattery") ?? null,
|
|
1945
|
+
health,
|
|
1946
|
+
metadata: request.metadata !== undefined
|
|
1947
|
+
? requireRecord(request.metadata, "metadata")
|
|
1948
|
+
: {},
|
|
1949
|
+
});
|
|
1950
|
+
await this.repository.createActivitySignal(signal);
|
|
1951
|
+
return signal;
|
|
1952
|
+
}
|
|
1953
|
+
async listActivitySignals(args = {}) {
|
|
1954
|
+
return this.repository.listActivitySignals(this.agentId(), args);
|
|
1955
|
+
}
|
|
1956
|
+
async upsertChannelPolicy(request) {
|
|
1957
|
+
const channelType = normalizeEnumValue(request.channelType, "channelType", LIFEOPS_CHANNEL_TYPES);
|
|
1958
|
+
const channelRef = channelType === "sms" || channelType === "voice"
|
|
1959
|
+
? normalizePhoneNumber(request.channelRef, "channelRef")
|
|
1960
|
+
: requireNonEmptyString(request.channelRef, "channelRef");
|
|
1961
|
+
const existing = await this.repository.getChannelPolicy(this.agentId(), channelType, channelRef);
|
|
1962
|
+
const policy = existing
|
|
1963
|
+
? {
|
|
1964
|
+
...existing,
|
|
1965
|
+
privacyClass: normalizePrivacyClass(request.privacyClass, "privacyClass", existing.privacyClass),
|
|
1966
|
+
allowReminders: normalizeOptionalBoolean(request.allowReminders, "allowReminders") ?? existing.allowReminders,
|
|
1967
|
+
allowEscalation: normalizeOptionalBoolean(request.allowEscalation, "allowEscalation") ?? existing.allowEscalation,
|
|
1968
|
+
allowPosts: normalizeOptionalBoolean(request.allowPosts, "allowPosts") ??
|
|
1969
|
+
existing.allowPosts,
|
|
1970
|
+
requireConfirmationForActions: normalizeOptionalBoolean(request.requireConfirmationForActions, "requireConfirmationForActions") ?? existing.requireConfirmationForActions,
|
|
1971
|
+
metadata: request.metadata !== undefined
|
|
1972
|
+
? {
|
|
1973
|
+
...existing.metadata,
|
|
1974
|
+
...requireRecord(request.metadata, "metadata"),
|
|
1975
|
+
}
|
|
1976
|
+
: existing.metadata,
|
|
1977
|
+
updatedAt: new Date().toISOString(),
|
|
1978
|
+
}
|
|
1979
|
+
: createLifeOpsChannelPolicy({
|
|
1980
|
+
agentId: this.agentId(),
|
|
1981
|
+
channelType,
|
|
1982
|
+
channelRef,
|
|
1983
|
+
privacyClass: normalizePrivacyClass(request.privacyClass),
|
|
1984
|
+
allowReminders: normalizeOptionalBoolean(request.allowReminders, "allowReminders") ?? true,
|
|
1985
|
+
allowEscalation: normalizeOptionalBoolean(request.allowEscalation, "allowEscalation") ?? false,
|
|
1986
|
+
allowPosts: normalizeOptionalBoolean(request.allowPosts, "allowPosts") ?? false,
|
|
1987
|
+
requireConfirmationForActions: normalizeOptionalBoolean(request.requireConfirmationForActions, "requireConfirmationForActions") ?? true,
|
|
1988
|
+
metadata: normalizeOptionalRecord(request.metadata, "metadata") ?? {},
|
|
1989
|
+
});
|
|
1990
|
+
await this.repository.upsertChannelPolicy(policy);
|
|
1991
|
+
await this.recordChannelPolicyAudit(policy.id, "channel policy updated", { request }, {
|
|
1992
|
+
channelType: policy.channelType,
|
|
1993
|
+
channelRef: policy.channelRef,
|
|
1994
|
+
});
|
|
1995
|
+
return policy;
|
|
1996
|
+
}
|
|
1997
|
+
async capturePhoneConsent(request) {
|
|
1998
|
+
if (normalizeOptionalBoolean(request.consentGiven, "consentGiven") !== true) {
|
|
1999
|
+
fail(400, "Explicit consent is required before capturing a phone number.");
|
|
2000
|
+
}
|
|
2001
|
+
const phoneNumber = normalizePhoneNumber(request.phoneNumber, "phoneNumber");
|
|
2002
|
+
const privacyClass = normalizePrivacyClass(request.privacyClass);
|
|
2003
|
+
const baseMetadata = {
|
|
2004
|
+
...(normalizeOptionalRecord(request.metadata, "metadata") ?? {}),
|
|
2005
|
+
phoneNumber,
|
|
2006
|
+
consentCapturedAt: new Date().toISOString(),
|
|
2007
|
+
consentGiven: true,
|
|
2008
|
+
isPrimary: true,
|
|
2009
|
+
};
|
|
2010
|
+
const smsPolicy = await this.upsertChannelPolicy({
|
|
2011
|
+
channelType: "sms",
|
|
2012
|
+
channelRef: phoneNumber,
|
|
2013
|
+
privacyClass,
|
|
2014
|
+
allowReminders: normalizeOptionalBoolean(request.allowSms, "allowSms") ?? false,
|
|
2015
|
+
allowEscalation: normalizeOptionalBoolean(request.allowSms, "allowSms") ?? false,
|
|
2016
|
+
allowPosts: false,
|
|
2017
|
+
requireConfirmationForActions: true,
|
|
2018
|
+
metadata: {
|
|
2019
|
+
...baseMetadata,
|
|
2020
|
+
consentKind: "phone",
|
|
2021
|
+
smsAllowed: normalizeOptionalBoolean(request.allowSms, "allowSms") ?? false,
|
|
2022
|
+
voiceAllowed: normalizeOptionalBoolean(request.allowVoice, "allowVoice") ?? false,
|
|
2023
|
+
},
|
|
2024
|
+
});
|
|
2025
|
+
const voicePolicy = await this.upsertChannelPolicy({
|
|
2026
|
+
channelType: "voice",
|
|
2027
|
+
channelRef: phoneNumber,
|
|
2028
|
+
privacyClass,
|
|
2029
|
+
allowReminders: normalizeOptionalBoolean(request.allowVoice, "allowVoice") ?? false,
|
|
2030
|
+
allowEscalation: normalizeOptionalBoolean(request.allowVoice, "allowVoice") ?? false,
|
|
2031
|
+
allowPosts: false,
|
|
2032
|
+
requireConfirmationForActions: true,
|
|
2033
|
+
metadata: {
|
|
2034
|
+
...baseMetadata,
|
|
2035
|
+
consentKind: "phone",
|
|
2036
|
+
smsAllowed: normalizeOptionalBoolean(request.allowSms, "allowSms") ?? false,
|
|
2037
|
+
voiceAllowed: normalizeOptionalBoolean(request.allowVoice, "allowVoice") ?? false,
|
|
2038
|
+
},
|
|
2039
|
+
});
|
|
2040
|
+
// Register SMS/voice in the escalation channel list when the user
|
|
2041
|
+
// consents so the escalation service can reach them without manual
|
|
2042
|
+
// setup.
|
|
2043
|
+
const allowSms = normalizeOptionalBoolean(request.allowSms, "allowSms") ?? false;
|
|
2044
|
+
const allowVoice = normalizeOptionalBoolean(request.allowVoice, "allowVoice") ?? false;
|
|
2045
|
+
if (allowSms) {
|
|
2046
|
+
registerEscalationChannel("sms");
|
|
2047
|
+
}
|
|
2048
|
+
if (allowVoice) {
|
|
2049
|
+
registerEscalationChannel("voice");
|
|
2050
|
+
}
|
|
2051
|
+
return {
|
|
2052
|
+
phoneNumber,
|
|
2053
|
+
policies: [smsPolicy, voicePolicy],
|
|
2054
|
+
};
|
|
2055
|
+
}
|
|
2056
|
+
async processReminders(request = {}) {
|
|
2057
|
+
return this.withReminderProcessingLock(async () => {
|
|
2058
|
+
const now = request.now === undefined
|
|
2059
|
+
? new Date()
|
|
2060
|
+
: new Date(normalizeIsoString(request.now, "now"));
|
|
2061
|
+
const limit = request.limit === undefined
|
|
2062
|
+
? DEFAULT_REMINDER_PROCESS_LIMIT
|
|
2063
|
+
: normalizePositiveInteger(request.limit, "limit");
|
|
2064
|
+
const definitions = await this.repository.listActiveDefinitions(this.agentId());
|
|
2065
|
+
for (const definition of definitions) {
|
|
2066
|
+
await this.refreshDefinitionOccurrences(definition, now);
|
|
2067
|
+
}
|
|
2068
|
+
const definitionsById = new Map(definitions.map((definition) => [definition.id, definition]));
|
|
2069
|
+
const horizon = addMinutes(now, OVERVIEW_HORIZON_MINUTES).toISOString();
|
|
2070
|
+
const occurrenceViews = await this.repository.listOccurrenceViewsForOverview(this.agentId(), horizon);
|
|
2071
|
+
const occurrencePlans = await this.repository.listReminderPlansForOwners(this.agentId(), "definition", occurrenceViews.map((occurrence) => occurrence.definitionId));
|
|
2072
|
+
const policies = await this.repository.listChannelPolicies(this.agentId());
|
|
2073
|
+
const definitionPreferencesById = new Map();
|
|
2074
|
+
const plansByDefinitionId = new Map();
|
|
2075
|
+
for (const plan of occurrencePlans) {
|
|
2076
|
+
const definition = definitionsById.get(plan.ownerId) ?? null;
|
|
2077
|
+
const preference = this.buildReminderPreferenceResponse(definition, policies);
|
|
2078
|
+
definitionPreferencesById.set(plan.ownerId, preference);
|
|
2079
|
+
const effectivePlan = this.resolveEffectiveReminderPlan(plan, preference);
|
|
2080
|
+
if (effectivePlan) {
|
|
2081
|
+
plansByDefinitionId.set(plan.ownerId, effectivePlan);
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
const eventWindowEnd = addMinutes(now, OVERVIEW_HORIZON_MINUTES).toISOString();
|
|
2085
|
+
const calendarEvents = await this.repository.listCalendarEvents(this.agentId(), "google", now.toISOString(), eventWindowEnd);
|
|
2086
|
+
const eventPlans = await this.repository.listReminderPlansForOwners(this.agentId(), "calendar_event", calendarEvents.map((event) => event.id));
|
|
2087
|
+
const globalReminderPreference = this.buildReminderPreferenceResponse(null, policies);
|
|
2088
|
+
const occurrenceUrgencies = new Map();
|
|
2089
|
+
for (const occurrence of occurrenceViews) {
|
|
2090
|
+
occurrenceUrgencies.set(occurrence.id, typeof occurrence.metadata.urgency === "string"
|
|
2091
|
+
? normalizeReminderUrgency(occurrence.metadata.urgency)
|
|
2092
|
+
: priorityToUrgency(occurrence.priority));
|
|
2093
|
+
}
|
|
2094
|
+
const plansByEventId = new Map();
|
|
2095
|
+
for (const plan of eventPlans) {
|
|
2096
|
+
const effectivePlan = this.resolveEffectiveReminderPlan(plan, globalReminderPreference);
|
|
2097
|
+
if (effectivePlan) {
|
|
2098
|
+
plansByEventId.set(plan.ownerId, effectivePlan);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
const eventUrgencies = new Map();
|
|
2102
|
+
for (const event of calendarEvents) {
|
|
2103
|
+
eventUrgencies.set(event.id, typeof event.metadata.urgency === "string"
|
|
2104
|
+
? normalizeReminderUrgency(event.metadata.urgency)
|
|
2105
|
+
: "medium");
|
|
2106
|
+
}
|
|
2107
|
+
const existingAttempts = await this.repository.listReminderAttempts(this.agentId());
|
|
2108
|
+
const attemptKey = (planId, stepIndex, scheduledFor) => `${planId}:${stepIndex}:${scheduledFor}`;
|
|
2109
|
+
const deliveredAttempts = new Set(existingAttempts
|
|
2110
|
+
.filter((attempt) => attempt.outcome === "delivered" ||
|
|
2111
|
+
attempt.outcome === "delivered_read" ||
|
|
2112
|
+
attempt.outcome === "delivered_unread")
|
|
2113
|
+
.map((attempt) => attemptKey(attempt.planId, attempt.stepIndex, attempt.scheduledFor)));
|
|
2114
|
+
const blockedAckAttempts = new Set(existingAttempts
|
|
2115
|
+
.filter((attempt) => attempt.outcome === "blocked_acknowledged")
|
|
2116
|
+
.map((attempt) => attemptKey(attempt.planId, attempt.stepIndex, attempt.scheduledFor)));
|
|
2117
|
+
const dueAttempts = [];
|
|
2118
|
+
for (const reminder of buildActiveReminders(occurrenceViews, plansByDefinitionId, now)) {
|
|
2119
|
+
if (dueAttempts.length >= limit)
|
|
2120
|
+
break;
|
|
2121
|
+
const plan = reminder.definitionId
|
|
2122
|
+
? plansByDefinitionId.get(reminder.definitionId)
|
|
2123
|
+
: null;
|
|
2124
|
+
if (!plan)
|
|
2125
|
+
continue;
|
|
2126
|
+
const occurrence = occurrenceViews.find((candidate) => candidate.id === reminder.ownerId);
|
|
2127
|
+
if (!occurrence)
|
|
2128
|
+
continue;
|
|
2129
|
+
const preference = definitionPreferencesById.get(reminder.definitionId ?? "") ??
|
|
2130
|
+
globalReminderPreference;
|
|
2131
|
+
const urgency = occurrenceUrgencies.get(reminder.ownerId) ?? "medium";
|
|
2132
|
+
if (!shouldDeliverReminderForIntensity(preference.effective.intensity, urgency)) {
|
|
2133
|
+
continue;
|
|
2134
|
+
}
|
|
2135
|
+
const key = attemptKey(plan.id, reminder.stepIndex, reminder.scheduledFor);
|
|
2136
|
+
const acknowledged = Boolean(occurrence.metadata.reminderAcknowledgedAt ||
|
|
2137
|
+
occurrence.state === "completed");
|
|
2138
|
+
if (deliveredAttempts.has(key) ||
|
|
2139
|
+
(acknowledged && blockedAckAttempts.has(key))) {
|
|
2140
|
+
continue;
|
|
2141
|
+
}
|
|
2142
|
+
const attempt = await this.dispatchReminderAttempt({
|
|
2143
|
+
plan,
|
|
2144
|
+
ownerType: "occurrence",
|
|
2145
|
+
ownerId: reminder.ownerId,
|
|
2146
|
+
occurrenceId: reminder.occurrenceId,
|
|
2147
|
+
subjectType: occurrence.subjectType,
|
|
2148
|
+
title: reminder.title,
|
|
2149
|
+
channel: reminder.channel,
|
|
2150
|
+
stepIndex: reminder.stepIndex,
|
|
2151
|
+
scheduledFor: reminder.scheduledFor,
|
|
2152
|
+
dueAt: occurrence.dueAt,
|
|
2153
|
+
urgency: typeof occurrence.metadata.urgency === "string"
|
|
2154
|
+
? normalizeReminderUrgency(occurrence.metadata.urgency)
|
|
2155
|
+
: priorityToUrgency(occurrence.priority),
|
|
2156
|
+
quietHours: plan.quietHours,
|
|
2157
|
+
acknowledged,
|
|
2158
|
+
attemptedAt: now.toISOString(),
|
|
2159
|
+
nearbyReminderTitles: collectNearbyReminderTitles({
|
|
2160
|
+
currentOwnerId: reminder.ownerId,
|
|
2161
|
+
currentAnchorAt: occurrence.dueAt,
|
|
2162
|
+
occurrences: occurrenceViews,
|
|
2163
|
+
events: calendarEvents,
|
|
2164
|
+
limit: 3,
|
|
2165
|
+
}),
|
|
2166
|
+
});
|
|
2167
|
+
dueAttempts.push(attempt);
|
|
2168
|
+
if (attempt.outcome === "delivered") {
|
|
2169
|
+
deliveredAttempts.add(key);
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
for (const reminder of buildActiveCalendarEventReminders(calendarEvents, plansByEventId, this.ownerEntityId(), now)) {
|
|
2173
|
+
if (dueAttempts.length >= limit)
|
|
2174
|
+
break;
|
|
2175
|
+
const plan = reminder.eventId
|
|
2176
|
+
? plansByEventId.get(reminder.eventId)
|
|
2177
|
+
: null;
|
|
2178
|
+
if (!plan)
|
|
2179
|
+
continue;
|
|
2180
|
+
const event = calendarEvents.find((candidate) => candidate.id === reminder.ownerId);
|
|
2181
|
+
if (!event)
|
|
2182
|
+
continue;
|
|
2183
|
+
if (!shouldDeliverReminderForIntensity(globalReminderPreference.effective.intensity, eventUrgencies.get(reminder.ownerId) ?? "medium")) {
|
|
2184
|
+
continue;
|
|
2185
|
+
}
|
|
2186
|
+
const key = attemptKey(plan.id, reminder.stepIndex, reminder.scheduledFor);
|
|
2187
|
+
const acknowledged = Boolean(event.metadata.reminderAcknowledgedAt);
|
|
2188
|
+
if (deliveredAttempts.has(key) ||
|
|
2189
|
+
(acknowledged && blockedAckAttempts.has(key))) {
|
|
2190
|
+
continue;
|
|
2191
|
+
}
|
|
2192
|
+
const attempt = await this.dispatchReminderAttempt({
|
|
2193
|
+
plan,
|
|
2194
|
+
ownerType: "calendar_event",
|
|
2195
|
+
ownerId: reminder.ownerId,
|
|
2196
|
+
occurrenceId: null,
|
|
2197
|
+
subjectType: reminder.subjectType,
|
|
2198
|
+
title: reminder.title,
|
|
2199
|
+
channel: reminder.channel,
|
|
2200
|
+
stepIndex: reminder.stepIndex,
|
|
2201
|
+
scheduledFor: reminder.scheduledFor,
|
|
2202
|
+
dueAt: reminder.dueAt,
|
|
2203
|
+
urgency: typeof event.metadata.urgency === "string"
|
|
2204
|
+
? normalizeReminderUrgency(event.metadata.urgency)
|
|
2205
|
+
: "medium",
|
|
2206
|
+
quietHours: plan.quietHours,
|
|
2207
|
+
acknowledged,
|
|
2208
|
+
attemptedAt: now.toISOString(),
|
|
2209
|
+
nearbyReminderTitles: collectNearbyReminderTitles({
|
|
2210
|
+
currentOwnerId: reminder.ownerId,
|
|
2211
|
+
currentAnchorAt: reminder.dueAt,
|
|
2212
|
+
occurrences: occurrenceViews,
|
|
2213
|
+
events: calendarEvents,
|
|
2214
|
+
limit: 3,
|
|
2215
|
+
}),
|
|
2216
|
+
});
|
|
2217
|
+
dueAttempts.push(attempt);
|
|
2218
|
+
if (attempt.outcome === "delivered") {
|
|
2219
|
+
deliveredAttempts.add(key);
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
const reminderAttemptsForEscalation = [
|
|
2223
|
+
...existingAttempts,
|
|
2224
|
+
...dueAttempts,
|
|
2225
|
+
];
|
|
2226
|
+
const activityProfile = await this.readReminderActivityProfileSnapshot();
|
|
2227
|
+
// Scan recent "delivered" attempts and upgrade to "delivered_read" when
|
|
2228
|
+
// the owner was active after delivery. This improves escalation decisions.
|
|
2229
|
+
await this.scanReadReceipts(reminderAttemptsForEscalation, activityProfile, now);
|
|
2230
|
+
for (const occurrence of occurrenceViews) {
|
|
2231
|
+
if (dueAttempts.length >= limit)
|
|
2232
|
+
break;
|
|
2233
|
+
const plan = plansByDefinitionId.get(occurrence.definitionId) ?? null;
|
|
2234
|
+
if (!plan)
|
|
2235
|
+
continue;
|
|
2236
|
+
const acknowledged = Boolean(occurrence.metadata.reminderAcknowledgedAt ||
|
|
2237
|
+
occurrence.state === "completed");
|
|
2238
|
+
const attempt = await this.dispatchDueReminderEscalation({
|
|
2239
|
+
plan,
|
|
2240
|
+
ownerType: "occurrence",
|
|
2241
|
+
ownerId: occurrence.id,
|
|
2242
|
+
occurrenceId: occurrence.id,
|
|
2243
|
+
subjectType: occurrence.subjectType,
|
|
2244
|
+
title: occurrence.title,
|
|
2245
|
+
dueAt: occurrence.dueAt,
|
|
2246
|
+
urgency: typeof occurrence.metadata.urgency === "string"
|
|
2247
|
+
? normalizeReminderUrgency(occurrence.metadata.urgency)
|
|
2248
|
+
: priorityToUrgency(occurrence.priority),
|
|
2249
|
+
intensity: definitionPreferencesById.get(occurrence.definitionId)?.effective
|
|
2250
|
+
?.intensity ?? globalReminderPreference.effective.intensity,
|
|
2251
|
+
quietHours: plan.quietHours,
|
|
2252
|
+
attemptedAt: now.toISOString(),
|
|
2253
|
+
now,
|
|
2254
|
+
attempts: reminderAttemptsForEscalation,
|
|
2255
|
+
policies,
|
|
2256
|
+
activityProfile,
|
|
2257
|
+
occurrence,
|
|
2258
|
+
acknowledged,
|
|
2259
|
+
nearbyReminderTitles: collectNearbyReminderTitles({
|
|
2260
|
+
currentOwnerId: occurrence.id,
|
|
2261
|
+
currentAnchorAt: occurrence.dueAt,
|
|
2262
|
+
occurrences: occurrenceViews,
|
|
2263
|
+
events: calendarEvents,
|
|
2264
|
+
limit: 3,
|
|
2265
|
+
}),
|
|
2266
|
+
});
|
|
2267
|
+
if (!attempt)
|
|
2268
|
+
continue;
|
|
2269
|
+
dueAttempts.push(attempt);
|
|
2270
|
+
reminderAttemptsForEscalation.push(attempt);
|
|
2271
|
+
}
|
|
2272
|
+
for (const event of calendarEvents) {
|
|
2273
|
+
if (dueAttempts.length >= limit)
|
|
2274
|
+
break;
|
|
2275
|
+
const plan = plansByEventId.get(event.id) ?? null;
|
|
2276
|
+
if (!plan)
|
|
2277
|
+
continue;
|
|
2278
|
+
const attempt = await this.dispatchDueReminderEscalation({
|
|
2279
|
+
plan,
|
|
2280
|
+
ownerType: "calendar_event",
|
|
2281
|
+
ownerId: event.id,
|
|
2282
|
+
occurrenceId: null,
|
|
2283
|
+
subjectType: "owner",
|
|
2284
|
+
title: event.title,
|
|
2285
|
+
dueAt: event.startAt,
|
|
2286
|
+
urgency: typeof event.metadata.urgency === "string"
|
|
2287
|
+
? normalizeReminderUrgency(event.metadata.urgency)
|
|
2288
|
+
: "medium",
|
|
2289
|
+
intensity: globalReminderPreference.effective.intensity,
|
|
2290
|
+
quietHours: plan.quietHours,
|
|
2291
|
+
attemptedAt: now.toISOString(),
|
|
2292
|
+
now,
|
|
2293
|
+
attempts: reminderAttemptsForEscalation,
|
|
2294
|
+
policies,
|
|
2295
|
+
activityProfile,
|
|
2296
|
+
eventStartAt: event.startAt,
|
|
2297
|
+
acknowledged: Boolean(event.metadata.reminderAcknowledgedAt),
|
|
2298
|
+
nearbyReminderTitles: collectNearbyReminderTitles({
|
|
2299
|
+
currentOwnerId: event.id,
|
|
2300
|
+
currentAnchorAt: event.startAt,
|
|
2301
|
+
occurrences: occurrenceViews,
|
|
2302
|
+
events: calendarEvents,
|
|
2303
|
+
limit: 3,
|
|
2304
|
+
}),
|
|
2305
|
+
});
|
|
2306
|
+
if (!attempt)
|
|
2307
|
+
continue;
|
|
2308
|
+
dueAttempts.push(attempt);
|
|
2309
|
+
reminderAttemptsForEscalation.push(attempt);
|
|
2310
|
+
}
|
|
2311
|
+
return {
|
|
2312
|
+
now: now.toISOString(),
|
|
2313
|
+
attempts: dueAttempts,
|
|
2314
|
+
};
|
|
2315
|
+
});
|
|
2316
|
+
}
|
|
2317
|
+
async processScheduledWork(request = {}) {
|
|
2318
|
+
const now = request.now === undefined
|
|
2319
|
+
? new Date()
|
|
2320
|
+
: new Date(normalizeIsoString(request.now, "now"));
|
|
2321
|
+
const reminderLimit = request.reminderLimit === undefined
|
|
2322
|
+
? DEFAULT_REMINDER_PROCESS_LIMIT
|
|
2323
|
+
: normalizePositiveInteger(request.reminderLimit, "reminderLimit");
|
|
2324
|
+
const workflowLimit = request.workflowLimit === undefined
|
|
2325
|
+
? DEFAULT_WORKFLOW_PROCESS_LIMIT
|
|
2326
|
+
: normalizePositiveInteger(request.workflowLimit, "workflowLimit");
|
|
2327
|
+
await this.syncWebsiteAccessState(now);
|
|
2328
|
+
const reminderResult = await this.processReminders({
|
|
2329
|
+
now: now.toISOString(),
|
|
2330
|
+
limit: reminderLimit,
|
|
2331
|
+
});
|
|
2332
|
+
const workflowRuns = await this.runDueWorkflows({
|
|
2333
|
+
now: now.toISOString(),
|
|
2334
|
+
limit: workflowLimit,
|
|
2335
|
+
});
|
|
2336
|
+
return {
|
|
2337
|
+
now: now.toISOString(),
|
|
2338
|
+
reminderAttempts: reminderResult.attempts,
|
|
2339
|
+
workflowRuns,
|
|
2340
|
+
};
|
|
2341
|
+
}
|
|
2342
|
+
async relockWebsiteAccessGroup(groupKey, now = new Date()) {
|
|
2343
|
+
await this.repository.revokeWebsiteAccessGrants(this.agentId(), {
|
|
2344
|
+
groupKey: requireNonEmptyString(groupKey, "groupKey"),
|
|
2345
|
+
revokedAt: now.toISOString(),
|
|
2346
|
+
});
|
|
2347
|
+
await this.syncWebsiteAccessState(now);
|
|
2348
|
+
return { ok: true };
|
|
2349
|
+
}
|
|
2350
|
+
async resolveWebsiteAccessCallback(callbackKey, now = new Date()) {
|
|
2351
|
+
await this.repository.revokeWebsiteAccessGrants(this.agentId(), {
|
|
2352
|
+
callbackKey: requireNonEmptyString(callbackKey, "callbackKey"),
|
|
2353
|
+
revokedAt: now.toISOString(),
|
|
2354
|
+
});
|
|
2355
|
+
await this.syncWebsiteAccessState(now);
|
|
2356
|
+
return { ok: true };
|
|
2357
|
+
}
|
|
2358
|
+
async inspectReminder(ownerType, ownerId) {
|
|
2359
|
+
let plan = null;
|
|
2360
|
+
if (ownerType === "occurrence") {
|
|
2361
|
+
const occurrence = await this.repository.getOccurrence(this.agentId(), ownerId);
|
|
2362
|
+
if (!occurrence) {
|
|
2363
|
+
fail(404, "life-ops occurrence not found");
|
|
2364
|
+
}
|
|
2365
|
+
const definition = await this.repository.getDefinition(this.agentId(), occurrence.definitionId);
|
|
2366
|
+
if (definition?.reminderPlanId) {
|
|
2367
|
+
plan = await this.repository.getReminderPlan(this.agentId(), definition.reminderPlanId);
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
else {
|
|
2371
|
+
const plans = await this.repository.listReminderPlansForOwners(this.agentId(), "calendar_event", [ownerId]);
|
|
2372
|
+
plan = plans[0] ?? null;
|
|
2373
|
+
}
|
|
2374
|
+
return {
|
|
2375
|
+
ownerType,
|
|
2376
|
+
ownerId,
|
|
2377
|
+
reminderPlan: plan,
|
|
2378
|
+
attempts: await this.repository.listReminderAttempts(this.agentId(), {
|
|
2379
|
+
ownerType,
|
|
2380
|
+
ownerId,
|
|
2381
|
+
}),
|
|
2382
|
+
audits: await this.repository.listAuditEvents(this.agentId(), ownerType, ownerId),
|
|
2383
|
+
};
|
|
2384
|
+
}
|
|
2385
|
+
async acknowledgeReminder(request) {
|
|
2386
|
+
const ownerType = normalizeEnumValue(request.ownerType, "ownerType", [
|
|
2387
|
+
"occurrence",
|
|
2388
|
+
"calendar_event",
|
|
2389
|
+
]);
|
|
2390
|
+
const ownerId = requireNonEmptyString(request.ownerId, "ownerId");
|
|
2391
|
+
const acknowledgedAt = request.acknowledgedAt === undefined
|
|
2392
|
+
? new Date().toISOString()
|
|
2393
|
+
: normalizeIsoString(request.acknowledgedAt, "acknowledgedAt");
|
|
2394
|
+
const note = normalizeOptionalString(request.note) ?? null;
|
|
2395
|
+
if (ownerType === "occurrence") {
|
|
2396
|
+
const occurrence = await this.repository.getOccurrence(this.agentId(), ownerId);
|
|
2397
|
+
if (!occurrence) {
|
|
2398
|
+
fail(404, "life-ops occurrence not found");
|
|
2399
|
+
}
|
|
2400
|
+
await this.repository.updateOccurrence({
|
|
2401
|
+
...occurrence,
|
|
2402
|
+
metadata: {
|
|
2403
|
+
...occurrence.metadata,
|
|
2404
|
+
reminderAcknowledgedAt: acknowledgedAt,
|
|
2405
|
+
reminderAcknowledgedNote: note,
|
|
2406
|
+
},
|
|
2407
|
+
updatedAt: new Date().toISOString(),
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
else {
|
|
2411
|
+
const event = (await this.repository.listCalendarEvents(this.agentId(), "google")).find((candidate) => candidate.id === ownerId);
|
|
2412
|
+
if (!event) {
|
|
2413
|
+
fail(404, "life-ops calendar event not found");
|
|
2414
|
+
}
|
|
2415
|
+
await this.repository.upsertCalendarEvent({
|
|
2416
|
+
...event,
|
|
2417
|
+
metadata: {
|
|
2418
|
+
...event.metadata,
|
|
2419
|
+
reminderAcknowledgedAt: acknowledgedAt,
|
|
2420
|
+
reminderAcknowledgedNote: note,
|
|
2421
|
+
},
|
|
2422
|
+
updatedAt: new Date().toISOString(),
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
await this.resolveReminderEscalation({
|
|
2426
|
+
ownerType,
|
|
2427
|
+
ownerId,
|
|
2428
|
+
resolvedAt: acknowledgedAt,
|
|
2429
|
+
resolution: "acknowledged",
|
|
2430
|
+
note,
|
|
2431
|
+
});
|
|
2432
|
+
return { ok: true };
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
return LifeOpsRemindersServiceMixin;
|
|
2436
|
+
}
|