@askexenow/exe-os 0.9.231 → 0.9.232
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{active-agent-GJDG4CAW.js → active-agent-QFQKXG3F.js} +4 -4
- package/dist/{active-agent-WOP3ZHLN.js → active-agent-Z5MLNWDB.js} +4 -4
- package/dist/{agentic-ontology-ASORFII6.js → agentic-ontology-GBRFTYFS.js} +1 -1
- package/dist/{backfill-metadata-7WHAJKVL.js → backfill-metadata-KT6XR5QQ.js} +6 -6
- package/dist/{background-jobs-VTOMOTNA.js → background-jobs-53U6HSUF.js} +2 -2
- package/dist/{behaviors-36T3O2DC.js → behaviors-KZZE732K.js} +4 -4
- package/dist/bin/age-ontology-load.js +2 -2
- package/dist/bin/agentic-ontology-backfill.js +8 -8
- package/dist/bin/agentic-reflection-backfill.js +9 -9
- package/dist/bin/agentic-semantic-label.js +8 -8
- package/dist/bin/backfill-conversations.js +8 -8
- package/dist/bin/backfill-responses.js +8 -8
- package/dist/bin/backfill-vectors.js +10 -10
- package/dist/bin/bulk-sync-postgres.js +9 -9
- package/dist/bin/cc-doctor.js +3 -3
- package/dist/bin/cleanup-stale-review-tasks.js +12 -12
- package/dist/bin/cli.js +23 -20
- package/dist/bin/exe-agent-config.js +4 -4
- package/dist/bin/exe-agent.js +5 -5
- package/dist/bin/exe-assign.js +10 -10
- package/dist/bin/exe-boot.js +20 -20
- package/dist/bin/exe-call.js +5 -5
- package/dist/bin/exe-cloud.js +8 -8
- package/dist/bin/exe-dispatch.js +12 -12
- package/dist/bin/exe-doctor.js +1 -1
- package/dist/bin/exe-export-behaviors.js +9 -9
- package/dist/bin/exe-forget.js +8 -8
- package/dist/bin/exe-gateway.js +8 -8
- package/dist/bin/exe-healthcheck.js +3 -3
- package/dist/bin/exe-heartbeat.js +12 -12
- package/dist/bin/exe-kill.js +16 -16
- package/dist/bin/exe-launch-agent.js +20 -20
- package/dist/bin/exe-new-employee.js +9 -9
- package/dist/bin/exe-pending-messages.js +13 -13
- package/dist/bin/exe-pending-notifications.js +12 -12
- package/dist/bin/exe-pending-reviews.js +12 -12
- package/dist/bin/exe-rename.js +5 -5
- package/dist/bin/exe-review.js +15 -15
- package/dist/bin/exe-search.js +7 -7
- package/dist/bin/exe-session-cleanup.js +18 -18
- package/dist/bin/exe-settings.js +7 -7
- package/dist/bin/exe-start-codex.js +13 -13
- package/dist/bin/exe-start-opencode.js +10 -10
- package/dist/bin/exe-status.js +13 -13
- package/dist/bin/exe-support.js +3 -3
- package/dist/bin/exe-team.js +4 -4
- package/dist/bin/git-sweep.js +12 -12
- package/dist/bin/graph-backfill.js +7 -7
- package/dist/bin/graph-export.js +7 -7
- package/dist/bin/import-history.js +9 -9
- package/dist/bin/install.js +34 -21
- package/dist/bin/intercom-check.js +4 -4
- package/dist/bin/mcp-sessions.js +2 -2
- package/dist/bin/orchestration-metrics.js +5 -5
- package/dist/bin/postgres-agentic-reflection-backfill.js +4 -4
- package/dist/bin/postgres-agentic-semantic-backfill.js +3 -3
- package/dist/bin/scan-tasks.js +12 -12
- package/dist/bin/setup.js +3 -3
- package/dist/bin/shard-migrate.js +7 -7
- package/dist/bin/stack-update.js +3 -3
- package/dist/bin/update.js +3 -12
- package/dist/bin/vps-health-gate.js +1 -1
- package/dist/{branding-I2TDZFUH.js → branding-CLWTOGDU.js} +1 -1
- package/dist/{capacity-monitor-PRUTCTKE.js → capacity-monitor-GGTPFYQG.js} +13 -13
- package/dist/{catchup-brief-E2UK24I7.js → catchup-brief-5HRROAN7.js} +15 -15
- package/dist/{chunk-L24HYX62.js → chunk-2L6GV2VS.js} +2 -2
- package/dist/{chunk-CTFKTUYN.js → chunk-2OFB7NQW.js} +1 -1
- package/dist/{chunk-X3AVWFWW.js → chunk-3KIULH4N.js} +1 -1
- package/dist/{chunk-2AWEIMVH.js → chunk-3LTFCIMU.js} +1 -1
- package/dist/{chunk-V3QAAU2U.js → chunk-4E2XAON5.js} +3 -3
- package/dist/{chunk-B5AEHLZQ.js → chunk-4GAN7BGG.js} +3 -3
- package/dist/{chunk-OHPRXEUA.js → chunk-4KYGTWQ2.js} +1 -1
- package/dist/{chunk-EOVABUV3.js → chunk-5B5DRXBQ.js} +2 -2
- package/dist/{chunk-Q5GUJUDW.js → chunk-63KZ3LV4.js} +1 -1
- package/dist/{chunk-2RS2DR47.js → chunk-6SKF42BO.js} +2 -2
- package/dist/{chunk-YADYM2DE.js → chunk-72GRCS2I.js} +1 -1
- package/dist/{chunk-F2UFRUVY.js → chunk-7GCZAO22.js} +3 -3
- package/dist/{chunk-R2E4TV5V.js → chunk-7ZOFRNMG.js} +1 -1
- package/dist/{chunk-UILBQ5PU.js → chunk-AKYXKCDN.js} +2 -2
- package/dist/{chunk-YZKJLGWL.js → chunk-ALSWBA34.js} +1 -1
- package/dist/{chunk-NXF7NZEA.js → chunk-AQSGZ3DL.js} +4 -4
- package/dist/{chunk-2V5UDX2O.js → chunk-ASWHNMK5.js} +3 -3
- package/dist/{chunk-XWOXF4NK.js → chunk-AWHANCZN.js} +1 -1
- package/dist/{chunk-CHT3THVG.js → chunk-BYBACXPV.js} +1 -1
- package/dist/{chunk-ADJXHBEU.js → chunk-CYWD6JN3.js} +1 -1
- package/dist/{chunk-ZVSG2KKG.js → chunk-D6MAKN4A.js} +1 -1
- package/dist/{chunk-LRRMS5OF.js → chunk-DHV2DGH2.js} +9 -9
- package/dist/{chunk-DLXTKVBO.js → chunk-DUBO7325.js} +2 -2
- package/dist/{chunk-GFCQJZTO.js → chunk-EDPL7RUE.js} +1 -1
- package/dist/{chunk-GVP5U4WL.js → chunk-EEAY2YNU.js} +1 -1
- package/dist/{chunk-UKCXMU5W.js → chunk-ERG2BYEY.js} +4 -4
- package/dist/{chunk-IQT43SDJ.js → chunk-ESQCAAOT.js} +2 -2
- package/dist/{chunk-FIPU4BDF.js → chunk-FZOXXQ34.js} +1 -1
- package/dist/{chunk-2VZ6SY2R.js → chunk-GBCZXOWU.js} +7 -3
- package/dist/{chunk-UJOSFVWG.js → chunk-IYHYMEEV.js} +8 -4
- package/dist/{chunk-ECQBG62Y.js → chunk-JO5H3IVP.js} +1 -1
- package/dist/{chunk-JBKA7F5V.js → chunk-JR6S6JD7.js} +470 -445
- package/dist/{chunk-J5VSABXD.js → chunk-K4KJEH4Y.js} +2 -2
- package/dist/{chunk-7NNXBDOO.js → chunk-KDJRFJDL.js} +26 -16
- package/dist/{chunk-GKM7RYN3.js → chunk-KHEX4NY3.js} +6 -5
- package/dist/{chunk-WUFPA6LR.js → chunk-KQBSNOJL.js} +2 -2
- package/dist/{chunk-VW6UDG7E.js → chunk-KXOX7SDE.js} +2 -2
- package/dist/{chunk-UV4ZHXUP.js → chunk-L55G65Q2.js} +1 -1
- package/dist/{chunk-HQMEOIUJ.js → chunk-LHY4ZRZV.js} +1 -1
- package/dist/{chunk-3EFVHTTG.js → chunk-LOLA7VLN.js} +1 -1
- package/dist/{chunk-WA67SFFZ.js → chunk-LZHNW2TW.js} +1 -1
- package/dist/{chunk-OE6SYHTC.js → chunk-M44DCO63.js} +1 -1
- package/dist/{chunk-J5WI42RB.js → chunk-M6W3HYEK.js} +15 -15
- package/dist/{chunk-3MK3R5E6.js → chunk-MJYZJP7O.js} +4 -4
- package/dist/{chunk-Z3TT2SVJ.js → chunk-NV3WPNBM.js} +1 -1
- package/dist/{chunk-SSMXRAE2.js → chunk-O7A2X7MH.js} +3 -3
- package/dist/{chunk-3CLQFRM6.js → chunk-OANEAQ7F.js} +26 -4
- package/dist/{chunk-OI6MVDSY.js → chunk-OE6XFO2J.js} +1 -1
- package/dist/{chunk-ETSREHYC.js → chunk-OVG7IQTZ.js} +2 -2
- package/dist/{chunk-D4IVTUNN.js → chunk-OZCZNEYI.js} +1 -1
- package/dist/{chunk-FF62UWIJ.js → chunk-P6Z6TTQZ.js} +1 -1
- package/dist/{chunk-26PUEPOY.js → chunk-PBFEGM26.js} +3 -3
- package/dist/{chunk-5HF7X4WH.js → chunk-PQV5FL3N.js} +18 -18
- package/dist/{chunk-QHIGMP2M.js → chunk-QDDPNZBG.js} +1 -1
- package/dist/{chunk-7DNX45WB.js → chunk-QHFTK5EF.js} +1 -1
- package/dist/{chunk-6MP5NOOR.js → chunk-QU3ULJBC.js} +1 -1
- package/dist/{chunk-G4LLKD4Z.js → chunk-QWRRM2BE.js} +1 -1
- package/dist/{chunk-SJI7LQUK.js → chunk-RMIJ5G7P.js} +2 -2
- package/dist/{chunk-Q7RGLXQO.js → chunk-RRSTE5AR.js} +1 -1
- package/dist/{chunk-N4C2RMEO.js → chunk-RZQ4QPV5.js} +2 -2
- package/dist/{chunk-EHKIJPVX.js → chunk-S5K7OGFP.js} +1 -1
- package/dist/{chunk-I2CDSGQW.js → chunk-SBUSQBPP.js} +1 -1
- package/dist/{chunk-QYUWMF3P.js → chunk-SOU6SIMY.js} +1 -1
- package/dist/{chunk-6YZ4MT2L.js → chunk-SU7NR5JA.js} +6 -6
- package/dist/{chunk-JGZS4U4X.js → chunk-TCUOOFBS.js} +1 -1
- package/dist/{chunk-I32QME33.js → chunk-TPG4TR43.js} +10 -10
- package/dist/{chunk-2EHYQKJR.js → chunk-UESS3A4X.js} +5 -5
- package/dist/{chunk-5X3ISBHJ.js → chunk-V5QHETEF.js} +9 -9
- package/dist/{chunk-GTTLP5WK.js → chunk-WCLWK2GI.js} +97 -91
- package/dist/{chunk-RMPAMMYW.js → chunk-WUHYKL36.js} +1 -1
- package/dist/{chunk-TNTFEWU5.js → chunk-XBXKLACW.js} +8 -1
- package/dist/{chunk-AZSCW64F.js → chunk-XIQZTFQQ.js} +1 -1
- package/dist/{chunk-HO5SBL4B.js → chunk-XM2B73ES.js} +2 -2
- package/dist/{chunk-DGOGCPYU.js → chunk-XQ6YKRLZ.js} +2 -2
- package/dist/{chunk-36DAY227.js → chunk-XUBNHBQE.js} +2 -2
- package/dist/{chunk-MKVFPQH2.js → chunk-XW57NQDY.js} +2 -2
- package/dist/{chunk-GGV3PFUW.js → chunk-YHPULREH.js} +1 -1
- package/dist/{chunk-WEMIJFOX.js → chunk-YKR4AM5K.js} +24 -10
- package/dist/{chunk-NRFVWJHP.js → chunk-ZDO2PPFL.js} +2 -2
- package/dist/{chunk-PW2YH2ZR.js → chunk-ZPTGXNUS.js} +1 -1
- package/dist/{co-activation-AJZTQHI3.js → co-activation-LHVIX5DN.js} +3 -3
- package/dist/{co-occurrence-FGEJIMMV.js → co-occurrence-34TI6766.js} +3 -3
- package/dist/{code-context-index-KHUYATRB.js → code-context-index-TPJZBS6M.js} +4 -4
- package/dist/{conversation-wiki-populator-GNFRTS7X.js → conversation-wiki-populator-7ZQUMJTL.js} +1 -1
- package/dist/{crdt-sync-K25AKQAD.js → crdt-sync-UDQLFKQ4.js} +1 -1
- package/dist/{crm-webhook-ZL2YFSFK.js → crm-webhook-ALFLLQQZ.js} +2 -2
- package/dist/{cto-delegation-gate-VRGO7IQ2.js → cto-delegation-gate-PDL77V7U.js} +11 -11
- package/dist/{daemon-auth-WFQMMNSD.js → daemon-auth-YJ7XBUR3.js} +2 -2
- package/dist/{daemon-orchestration-5TO3CHJQ.js → daemon-orchestration-3QCHGFYF.js} +14 -14
- package/dist/{db-backup-MSQKO6M5.js → db-backup-3ZQQPS5G.js} +2 -2
- package/dist/{dreaming-UL7T5ZXA.js → dreaming-MNQ3UIMT.js} +4 -4
- package/dist/{exe-drift-2KHRPBUK.js → exe-drift-GHZD7CP6.js} +4 -4
- package/dist/{exe-export-DC4MYDXH.js → exe-export-CEC3JASW.js} +7 -7
- package/dist/{exe-import-KTTZOAAA.js → exe-import-LJNVTJUJ.js} +7 -7
- package/dist/{exe-key-A6WNNU4Q.js → exe-key-4VYTLMXT.js} +4 -4
- package/dist/{exe-org-JRBBON5H.js → exe-org-2FN2JADE.js} +2 -2
- package/dist/{exe-snapshot-NJ6BFROA.js → exe-snapshot-MOU536LX.js} +8 -8
- package/dist/{fast-db-init-QYMFD4FX.js → fast-db-init-3ZWHPYUQ.js} +1 -1
- package/dist/{founder-context-3N6BMG7B.js → founder-context-ZNGQ5NGW.js} +2 -2
- package/dist/gateway/index.js +9 -9
- package/dist/{gateway-client-V7NH35Q2.js → gateway-client-TBA6RKLN.js} +1 -1
- package/dist/{git-staleness-JW57ZGEJ.js → git-staleness-3XLWI33K.js} +3 -3
- package/dist/{git-task-sweep-WJAABZK5.js → git-task-sweep-SNJG4T4E.js} +12 -12
- package/dist/{global-procedures-NY3W7L5Q.js → global-procedures-OC5C7BWJ.js} +4 -4
- package/dist/{graph-auto-extract-5GZ34NXS.js → graph-auto-extract-B4Z66POP.js} +3 -3
- package/dist/{hook-integrity-OKSYTGVP.js → hook-integrity-R7EIWBUF.js} +1 -1
- package/dist/hooks/bug-report-worker.js +13 -13
- package/dist/hooks/codex-stop-task-finalizer.js +13 -13
- package/dist/hooks/commit-complete.js +15 -15
- package/dist/hooks/error-recall.js +9 -9
- package/dist/hooks/exe-heartbeat-hook.js +5 -5
- package/dist/hooks/ingest-worker.js +5 -5
- package/dist/hooks/ingest.js +12 -12
- package/dist/hooks/instructions-loaded.js +6 -6
- package/dist/hooks/manifest.json +20 -20
- package/dist/hooks/notification.js +6 -6
- package/dist/hooks/post-compact.js +14 -14
- package/dist/hooks/post-tool-combined.js +6 -6
- package/dist/hooks/pre-compact.js +19 -19
- package/dist/hooks/pre-tool-use.js +18 -18
- package/dist/hooks/prompt-submit.js +26 -26
- package/dist/hooks/session-end.js +24 -24
- package/dist/hooks/session-start.js +13 -13
- package/dist/hooks/stop.js +21 -21
- package/dist/hooks/subagent-stop.js +14 -14
- package/dist/hooks/summary-worker.js +22 -22
- package/dist/index.js +20 -20
- package/dist/{installer-GMIVB2JS.js → installer-KAKAR5WI.js} +6 -6
- package/dist/{installer-OBYQ6O3C.js → installer-KK2CS2CK.js} +6 -6
- package/dist/{installer-UAMA6ZVH.js → installer-RV2QVZTK.js} +6 -6
- package/dist/{key-backup-status-TVFMMWTT.js → key-backup-status-DRZO77KR.js} +1 -1
- package/dist/lib/agent-config.js +2 -2
- package/dist/lib/cloud-sync.js +8 -6
- package/dist/lib/config.js +1 -1
- package/dist/lib/consolidation.js +7 -7
- package/dist/lib/database.js +3 -3
- package/dist/lib/db-daemon-client.js +3 -3
- package/dist/lib/db.js +3 -3
- package/dist/lib/device-registry.js +1 -1
- package/dist/lib/embedder.js +4 -4
- package/dist/lib/employee-templates.js +5 -5
- package/dist/lib/employees.js +3 -3
- package/dist/lib/exe-daemon-client.js +3 -3
- package/dist/lib/exe-daemon.js +43 -43
- package/dist/lib/hybrid-search.js +7 -7
- package/dist/lib/identity.js +3 -3
- package/dist/lib/keychain.js +1 -1
- package/dist/lib/license.js +2 -2
- package/dist/lib/messaging.js +12 -12
- package/dist/lib/reminders.js +4 -4
- package/dist/lib/schedules.js +7 -7
- package/dist/lib/session-registry.js +5 -5
- package/dist/lib/session-wrappers.js +1 -1
- package/dist/lib/skill-learning.js +5 -5
- package/dist/lib/store.js +6 -6
- package/dist/lib/task-router.js +4 -4
- package/dist/lib/tasks.js +12 -12
- package/dist/lib/tmux-routing.js +11 -11
- package/dist/lib/token-spend.js +4 -4
- package/dist/lib/ws-client.js +1 -1
- package/dist/{license-gate-7QVCYARF.js → license-gate-67W2K667.js} +3 -3
- package/dist/mcp/register-tools.js +64 -64
- package/dist/mcp/server.js +86 -65
- package/dist/mcp/tools/complete-reminder.js +5 -5
- package/dist/mcp/tools/create-reminder.js +5 -5
- package/dist/mcp/tools/create-task.js +14 -14
- package/dist/mcp/tools/deactivate-behavior.js +6 -6
- package/dist/mcp/tools/list-reminders.js +5 -5
- package/dist/mcp/tools/list-tasks.js +14 -14
- package/dist/mcp/tools/send-message.js +14 -14
- package/dist/mcp/tools/update-task.js +13 -13
- package/dist/{mcp-http-config-YPF4WGU5.js → mcp-http-config-ZKOV5TEB.js} +4 -4
- package/dist/{memory-cards-XHZEOX7Q.js → memory-cards-P4ELKIBQ.js} +3 -3
- package/dist/{memory-graph-extractor-J3K7B4GC.js → memory-graph-extractor-LTOZ7QRR.js} +4 -4
- package/dist/{memory-poisoning-defense-I76FGNHK.js → memory-poisoning-defense-RNLXBWNU.js} +3 -3
- package/dist/{memory-queue-WEVFXPZO.js → memory-queue-PQRE4A62.js} +2 -2
- package/dist/{memory-queue-client-5XBHYAQR.js → memory-queue-client-MGXFQ62G.js} +5 -5
- package/dist/{memory-reflection-YJGI6IDI.js → memory-reflection-RIGWBNZJ.js} +3 -3
- package/dist/{notifications-MEW6QY57.js → notifications-TNCGZ5W2.js} +11 -11
- package/dist/{orchestration-events-LXVPJL6S.js → orchestration-events-TMN37OEJ.js} +4 -4
- package/dist/{orchestration-phase-HXRKMZXM.js → orchestration-phase-7VYG3L7X.js} +2 -2
- package/dist/{orchestrator-HGTR4YIR.js → orchestrator-3I2ZWCBE.js} +13 -13
- package/dist/{pipeline-router-7VGJ7635.js → pipeline-router-IWKIZSDC.js} +4 -4
- package/dist/{plan-limits-NFQVRHS5.js → plan-limits-4EPTLSIU.js} +5 -5
- package/dist/{prediction-log-C2BD3AHR.js → prediction-log-2Z6XD4EZ.js} +1 -1
- package/dist/{project-boot-JIGOSGCN.js → project-boot-6KWZPQNQ.js} +1 -1
- package/dist/{projection-worker-JZQTL4NU.js → projection-worker-5CSBJILA.js} +3 -3
- package/dist/{push-notifications-3GNJ5SZS.js → push-notifications-WR6QLWR3.js} +2 -2
- package/dist/{reranker-67X4YJEW.js → reranker-2IHJEYIB.js} +2 -2
- package/dist/{review-polling-ILAI4FDS.js → review-polling-L5P2KMBI.js} +12 -12
- package/dist/runtime/index.js +14 -14
- package/dist/{session-events-Y2YPBY3Q.js → session-events-5FHQPX6H.js} +12 -12
- package/dist/{session-kill-telemetry-JHSI7D3F.js → session-kill-telemetry-GKNTJ6BY.js} +4 -4
- package/dist/{session-scope-CUDNSN62.js → session-scope-DWIP4IKM.js} +11 -11
- package/dist/{setup-wizard-RBUTEZB2.js → setup-wizard-UHXMO2FP.js} +3 -3
- package/dist/{shard-manager-ON2WWCRM.js → shard-manager-PWSOXHZ4.js} +2 -2
- package/dist/{skill-refinement-YCCQ5W7C.js → skill-refinement-X2MCBDTB.js} +3 -3
- package/dist/{stack-update-ZIMV4OEQ.js → stack-update-WFO774SS.js} +3 -3
- package/dist/{steward-gate-6IKH335D.js → steward-gate-PR2N5XHY.js} +4 -4
- package/dist/{task-enforcement-MGHY6IJV.js → task-enforcement-AATKSKSX.js} +11 -11
- package/dist/{task-scope-N6GNTTVY.js → task-scope-C24XH5SU.js} +11 -11
- package/dist/{tasks-crud-2FX6NTL2.js → tasks-crud-3FBWU6GS.js} +11 -11
- package/dist/{tasks-review-5NFMLQJG.js → tasks-review-PLWP7Y6K.js} +11 -11
- package/dist/{telemetry-upload-APVDPCEV.js → telemetry-upload-SQOU3PMH.js} +7 -7
- package/dist/{token-budget-6IQNYKLR.js → token-budget-GL3TMPSU.js} +3 -3
- package/dist/{tool-capability-index-UUNF7VPA.js → tool-capability-index-H3YVB4WH.js} +1 -1
- package/dist/{tool-telemetry-SJSIL5M5.js → tool-telemetry-25KPRGFS.js} +1 -1
- package/dist/tui/App.js +25 -25
- package/dist/{tui-data-DT4WV54Q.js → tui-data-Y4U6LD4V.js} +11 -11
- package/dist/{worker-gate-SN6WCY4Q.js → worker-gate-NFZWLPCT.js} +2 -2
- package/dist/{workflow-engine-2RQLJXDG.js → workflow-engine-BGLW3NCF.js} +2 -2
- package/dist/{worktree-BO7QQ32T.js → worktree-DJB52IZE.js} +5 -5
- package/package.json +2 -2
- /package/dist/{chunk-A2G6WCUO.js → chunk-5CDLCKFP.js} +0 -0
- /package/dist/{chunk-EGWPJQRQ.js → chunk-73AHWU3R.js} +0 -0
- /package/dist/{chunk-IW53DAYO.js → chunk-HBVVFXTS.js} +0 -0
- /package/dist/{chunk-JZ2JEXEM.js → chunk-OAOBUDO3.js} +0 -0
- /package/dist/{chunk-WWPX2LLP.js → chunk-P6346JIK.js} +0 -0
- /package/dist/{chunk-EEAKFEEA.js → chunk-TPOWVHXP.js} +0 -0
- /package/dist/{chunk-7EZCYO76.js → chunk-V32QD5JJ.js} +0 -0
- /package/dist/{chunk-3JP3FY33.js → chunk-VITYTNHD.js} +0 -0
- /package/dist/{core-memory-6JYJS3A3.js → core-memory-GS3UTWJA.js} +0 -0
- /package/dist/{entity-boost-7MB2IYAE.js → entity-boost-BQEHHM3I.js} +0 -0
- /package/dist/{message-queue-client-FUKX43JD.js → message-queue-client-NPOYVISO.js} +0 -0
- /package/dist/{oauth-server-CCZPDTZJ.js → oauth-server-TVI5S5GG.js} +0 -0
- /package/dist/{webhook-pipe-4WPFGGFD.js → webhook-pipe-GB7YZIKE.js} +0 -0
- /package/dist/{wiki-acl-XCT6QQGP.js → wiki-acl-WZ4YRL3B.js} +0 -0
- /package/dist/{wiki-client-KE622HKY.js → wiki-client-WRO5PRMD.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isCrdtSyncEnabled
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TPOWVHXP.js";
|
|
4
4
|
import {
|
|
5
5
|
decryptSyncBlob,
|
|
6
6
|
encryptSyncBlob,
|
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
loadEmployees,
|
|
13
13
|
registerBinSymlinks,
|
|
14
14
|
saveEmployees
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-IYHYMEEV.js";
|
|
16
16
|
import {
|
|
17
17
|
loadDeviceId
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-OZCZNEYI.js";
|
|
19
19
|
import {
|
|
20
20
|
EXE_AI_DIR
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-XBXKLACW.js";
|
|
22
22
|
import {
|
|
23
23
|
atomicWriteJsonSync,
|
|
24
24
|
atomicWriteSync,
|
|
@@ -48,6 +48,7 @@ function decompress(input) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// src/lib/cloud-sync.ts
|
|
51
|
+
var _cloudSyncInProgress = false;
|
|
51
52
|
function sqlSafe(v) {
|
|
52
53
|
return v === void 0 ? null : v;
|
|
53
54
|
}
|
|
@@ -155,6 +156,16 @@ function loadPgClient() {
|
|
|
155
156
|
}
|
|
156
157
|
return _pgPromise;
|
|
157
158
|
}
|
|
159
|
+
async function disposeCloudSync() {
|
|
160
|
+
if (_pgPromise) {
|
|
161
|
+
try {
|
|
162
|
+
const pg = await _pgPromise;
|
|
163
|
+
if (pg.$disconnect) await pg.$disconnect();
|
|
164
|
+
} catch {
|
|
165
|
+
}
|
|
166
|
+
_pgPromise = null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
158
169
|
async function pushToPostgres(records) {
|
|
159
170
|
const loader = loadPgClient();
|
|
160
171
|
if (!loader) return 0;
|
|
@@ -441,76 +452,82 @@ async function markCloudReuploadRequired(client = getClient()) {
|
|
|
441
452
|
await client.execute("INSERT INTO sync_meta (key, value) VALUES ('cloud_reupload_required', '1') ON CONFLICT(key) DO UPDATE SET value = excluded.value");
|
|
442
453
|
}
|
|
443
454
|
async function cloudSync(config) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
455
|
+
if (_cloudSyncInProgress) {
|
|
456
|
+
process.stderr.write("[cloud-sync] Sync already in progress \u2014 skipping concurrent call.\n");
|
|
457
|
+
return { pushed: 0, pulled: 0, totalMemories: 0, behaviors: { pushed: 0, pulled: 0 }, graphrag: { pushed: 0, pulled: 0 }, tasks: { pushed: 0, pulled: 0 }, conversations: { pushed: 0, pulled: 0 }, documents: { pushed: 0, pulled: 0 }, roster: { employees: 0, identities: 0 } };
|
|
458
|
+
}
|
|
459
|
+
_cloudSyncInProgress = true;
|
|
460
|
+
try {
|
|
461
|
+
config = { ...config, endpoint: migrateEndpoint(config.endpoint) };
|
|
462
|
+
if (!isSyncCryptoInitialized()) {
|
|
463
|
+
try {
|
|
464
|
+
const { getMasterKey } = await import("./lib/keychain.js");
|
|
465
|
+
const masterKey = await getMasterKey();
|
|
466
|
+
if (masterKey) {
|
|
467
|
+
initSyncCrypto(masterKey);
|
|
468
|
+
} else {
|
|
469
|
+
throw new Error("No master key found");
|
|
470
|
+
}
|
|
471
|
+
} catch (err) {
|
|
472
|
+
throw new Error(`[cloud-sync] Cannot initialize encryption: ${err instanceof Error ? err.message : String(err)}`);
|
|
453
473
|
}
|
|
474
|
+
}
|
|
475
|
+
let client;
|
|
476
|
+
try {
|
|
477
|
+
client = getClient();
|
|
478
|
+
} catch (e) {
|
|
479
|
+
process.stderr.write("[cloud-sync] getClient() failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
|
|
480
|
+
throw new Error("[cloud-sync] Database not initialized. Call initStore() before cloudSync().");
|
|
481
|
+
}
|
|
482
|
+
try {
|
|
483
|
+
if (await getCloudReuploadRequired(client)) throw new Error(CLOUD_REUPLOAD_REQUIRED_MESSAGE);
|
|
454
484
|
} catch (err) {
|
|
455
|
-
|
|
485
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
486
|
+
if (msg === CLOUD_REUPLOAD_REQUIRED_MESSAGE || msg.includes("key rotation")) throw err;
|
|
456
487
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
if (await getCloudReuploadRequired(client)) throw new Error(CLOUD_REUPLOAD_REQUIRED_MESSAGE);
|
|
467
|
-
} catch (err) {
|
|
468
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
469
|
-
if (msg === CLOUD_REUPLOAD_REQUIRED_MESSAGE || msg.includes("key rotation")) throw err;
|
|
470
|
-
}
|
|
471
|
-
try {
|
|
472
|
-
const { getRawClient } = await import("./lib/database.js");
|
|
473
|
-
await getRawClient().execute("PRAGMA wal_checkpoint(PASSIVE)");
|
|
474
|
-
} catch (e) {
|
|
475
|
-
process.stderr.write("[cloud-sync] WAL checkpoint failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
|
|
476
|
-
}
|
|
477
|
-
try {
|
|
478
|
-
await client.execute(
|
|
479
|
-
"CREATE TABLE IF NOT EXISTS sync_meta (key TEXT PRIMARY KEY, value TEXT NOT NULL)"
|
|
480
|
-
);
|
|
481
|
-
} catch (e) {
|
|
482
|
-
logError(`[cloud-sync] sync_meta CREATE failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
483
|
-
}
|
|
484
|
-
const pullMeta = await client.execute(
|
|
485
|
-
"SELECT value FROM sync_meta WHERE key = 'last_cloud_pull_version'"
|
|
486
|
-
);
|
|
487
|
-
const lastPullVersion = pullMeta.rows.length > 0 ? Number(pullMeta.rows[0].value) : 0;
|
|
488
|
-
const pullResult = await cloudPull(lastPullVersion, config);
|
|
489
|
-
let pulled = 0;
|
|
490
|
-
if (pullResult.records.length > 0) {
|
|
491
|
-
if (isCrdtSyncEnabled()) {
|
|
492
|
-
const { initCrdtDoc, importExistingMemories, readAllMemories } = await import("./crdt-sync-K25AKQAD.js");
|
|
493
|
-
initCrdtDoc();
|
|
494
|
-
importExistingMemories(
|
|
495
|
-
pullResult.records.map((rec) => ({
|
|
496
|
-
id: String(rec.id ?? ""),
|
|
497
|
-
agent_id: rec.agent_id,
|
|
498
|
-
agent_role: rec.agent_role,
|
|
499
|
-
session_id: rec.session_id,
|
|
500
|
-
timestamp: rec.timestamp,
|
|
501
|
-
tool_name: rec.tool_name,
|
|
502
|
-
project_name: rec.project_name,
|
|
503
|
-
has_error: rec.has_error ?? 0,
|
|
504
|
-
raw_text: rec.raw_text ?? "",
|
|
505
|
-
version: rec.version ?? 0,
|
|
506
|
-
author_device_id: rec.author_device_id,
|
|
507
|
-
scope: rec.scope ?? "business"
|
|
508
|
-
}))
|
|
488
|
+
try {
|
|
489
|
+
const { getRawClient } = await import("./lib/database.js");
|
|
490
|
+
await getRawClient().execute("PRAGMA wal_checkpoint(PASSIVE)");
|
|
491
|
+
} catch (e) {
|
|
492
|
+
process.stderr.write("[cloud-sync] WAL checkpoint failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
|
|
493
|
+
}
|
|
494
|
+
try {
|
|
495
|
+
await client.execute(
|
|
496
|
+
"CREATE TABLE IF NOT EXISTS sync_meta (key TEXT PRIMARY KEY, value TEXT NOT NULL)"
|
|
509
497
|
);
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
498
|
+
} catch (e) {
|
|
499
|
+
logError(`[cloud-sync] sync_meta CREATE failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
500
|
+
}
|
|
501
|
+
const pullMeta = await client.execute(
|
|
502
|
+
"SELECT value FROM sync_meta WHERE key = 'last_cloud_pull_version'"
|
|
503
|
+
);
|
|
504
|
+
const lastPullVersion = pullMeta.rows.length > 0 ? Number(pullMeta.rows[0].value) : 0;
|
|
505
|
+
const pullResult = await cloudPull(lastPullVersion, config);
|
|
506
|
+
let pulled = 0;
|
|
507
|
+
if (pullResult.records.length > 0) {
|
|
508
|
+
if (isCrdtSyncEnabled()) {
|
|
509
|
+
const { initCrdtDoc, importExistingMemories, readAllMemories } = await import("./crdt-sync-UDQLFKQ4.js");
|
|
510
|
+
initCrdtDoc();
|
|
511
|
+
importExistingMemories(
|
|
512
|
+
pullResult.records.map((rec) => ({
|
|
513
|
+
id: String(rec.id ?? ""),
|
|
514
|
+
agent_id: rec.agent_id,
|
|
515
|
+
agent_role: rec.agent_role,
|
|
516
|
+
session_id: rec.session_id,
|
|
517
|
+
timestamp: rec.timestamp,
|
|
518
|
+
tool_name: rec.tool_name,
|
|
519
|
+
project_name: rec.project_name,
|
|
520
|
+
has_error: rec.has_error ?? 0,
|
|
521
|
+
raw_text: rec.raw_text ?? "",
|
|
522
|
+
version: rec.version ?? 0,
|
|
523
|
+
author_device_id: rec.author_device_id,
|
|
524
|
+
scope: rec.scope ?? "business"
|
|
525
|
+
}))
|
|
526
|
+
);
|
|
527
|
+
const pulledIds = new Set(pullResult.records.map((r) => String(r.id ?? "")));
|
|
528
|
+
const merged = readAllMemories().filter((rec) => pulledIds.has(rec.id));
|
|
529
|
+
const stmts = merged.map((rec) => ({
|
|
530
|
+
sql: `INSERT INTO memories
|
|
514
531
|
(id, agent_id, agent_role, session_id, timestamp,
|
|
515
532
|
tool_name, project_name, has_error, raw_text, version,
|
|
516
533
|
author_device_id, scope, memory_type, session_scope)
|
|
@@ -534,74 +551,74 @@ async function cloudSync(config) {
|
|
|
534
551
|
confidence = COALESCE(memories.confidence, excluded.confidence),
|
|
535
552
|
tier = COALESCE(memories.tier, excluded.tier),
|
|
536
553
|
strength = COALESCE(memories.strength, excluded.strength)`,
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
554
|
+
args: [
|
|
555
|
+
sqlSafe(rec.id),
|
|
556
|
+
sqlSafe(rec.agent_id),
|
|
557
|
+
sqlSafe(rec.agent_role),
|
|
558
|
+
sqlSafe(rec.session_id),
|
|
559
|
+
sqlSafe(rec.timestamp),
|
|
560
|
+
sqlSafe(rec.tool_name),
|
|
561
|
+
sqlSafe(rec.project_name),
|
|
562
|
+
sqlSafe(rec.has_error ?? 0),
|
|
563
|
+
sqlSafe(rec.raw_text ?? ""),
|
|
564
|
+
sqlSafe(rec.version ?? 0),
|
|
565
|
+
sqlSafe(rec.author_device_id),
|
|
566
|
+
sqlSafe(rec.scope ?? "business"),
|
|
567
|
+
sqlSafe(rec.memory_type),
|
|
568
|
+
sqlSafe(rec.session_scope)
|
|
569
|
+
]
|
|
570
|
+
}));
|
|
571
|
+
if (stmts.length > 0) await client.batch(stmts, "write");
|
|
572
|
+
pulled = pullResult.records.length;
|
|
573
|
+
} else {
|
|
574
|
+
try {
|
|
575
|
+
const incomingIds = pullResult.records.map((r) => sqlSafe(r.id));
|
|
576
|
+
if (incomingIds.length > 0) {
|
|
577
|
+
const ph = incomingIds.map(() => "?").join(",");
|
|
578
|
+
const existing = await client.execute({
|
|
579
|
+
sql: `SELECT id, version, timestamp FROM memories WHERE id IN (${ph})`,
|
|
580
|
+
args: incomingIds
|
|
581
|
+
});
|
|
582
|
+
const localMap = new Map(existing.rows.map((r) => [String(r.id), r]));
|
|
583
|
+
for (const rec of pullResult.records) {
|
|
584
|
+
const local = localMap.get(String(rec.id));
|
|
585
|
+
if (local && Number(local.version) > 0 && Number(local.version) !== Number(rec.version ?? 0)) {
|
|
586
|
+
process.stderr.write(
|
|
587
|
+
`[cloud-sync] CONFLICT: memory ${String(rec.id).slice(0, 8)} \u2014 local v${local.version} vs remote v${rec.version ?? 0}. Remote wins (LWW).
|
|
571
588
|
`
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
589
|
+
);
|
|
590
|
+
client.execute({
|
|
591
|
+
sql: `INSERT OR IGNORE INTO sync_conflicts (id, memory_id, local_version, remote_version, local_timestamp, remote_timestamp, local_device_id, resolution, created_at)
|
|
575
592
|
VALUES (?, ?, ?, ?, ?, ?, ?, 'remote_wins', ?)`,
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
593
|
+
args: [
|
|
594
|
+
`conflict-${String(rec.id).slice(0, 8)}-${Date.now()}`,
|
|
595
|
+
String(rec.id),
|
|
596
|
+
Number(local.version),
|
|
597
|
+
Number(rec.version ?? 0),
|
|
598
|
+
String(local.timestamp ?? ""),
|
|
599
|
+
String(rec.timestamp ?? ""),
|
|
600
|
+
process.env.EXE_DEVICE_ID ?? "",
|
|
601
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
602
|
+
]
|
|
603
|
+
}).catch((err) => {
|
|
604
|
+
process.stderr.write(`[cloud-sync] conflict audit insert failed: ${err instanceof Error ? err.message : String(err)}
|
|
588
605
|
`);
|
|
589
|
-
|
|
606
|
+
});
|
|
607
|
+
}
|
|
590
608
|
}
|
|
591
609
|
}
|
|
610
|
+
} catch (e) {
|
|
611
|
+
process.stderr.write("[cloud-sync] conflict detection query failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
|
|
592
612
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
});
|
|
603
|
-
const stmts = deviceFilteredRecords.map((rec) => ({
|
|
604
|
-
sql: `INSERT INTO memories
|
|
613
|
+
const localDeviceId = loadDeviceId();
|
|
614
|
+
const deviceFilteredRecords = pullResult.records.filter((rec) => {
|
|
615
|
+
const authorDevice = rec.author_device_id;
|
|
616
|
+
if (!authorDevice) return true;
|
|
617
|
+
if (String(authorDevice) === localDeviceId) return true;
|
|
618
|
+
return true;
|
|
619
|
+
});
|
|
620
|
+
const stmts = deviceFilteredRecords.map((rec) => ({
|
|
621
|
+
sql: `INSERT INTO memories
|
|
605
622
|
(id, agent_id, agent_role, session_id, timestamp,
|
|
606
623
|
tool_name, project_name, has_error, raw_text, version,
|
|
607
624
|
author_device_id, scope, memory_type, session_scope)
|
|
@@ -625,79 +642,79 @@ async function cloudSync(config) {
|
|
|
625
642
|
confidence = COALESCE(memories.confidence, excluded.confidence),
|
|
626
643
|
tier = COALESCE(memories.tier, excluded.tier),
|
|
627
644
|
strength = COALESCE(memories.strength, excluded.strength)`,
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
645
|
+
args: [
|
|
646
|
+
sqlSafe(rec.id),
|
|
647
|
+
sqlSafeRequired(rec.agent_id, "unknown"),
|
|
648
|
+
sqlSafeRequired(rec.agent_role, "employee"),
|
|
649
|
+
sqlSafeRequired(rec.session_id, "cloud-sync"),
|
|
650
|
+
sqlSafeRequired(rec.timestamp, (/* @__PURE__ */ new Date()).toISOString()),
|
|
651
|
+
sqlSafeRequired(rec.tool_name, "cloud_sync"),
|
|
652
|
+
sqlSafeRequired(rec.project_name, "unknown"),
|
|
653
|
+
sqlSafe(rec.has_error ?? 0),
|
|
654
|
+
sqlSafe(rec.raw_text ?? ""),
|
|
655
|
+
sqlSafe(rec.version ?? 0),
|
|
656
|
+
sqlSafe(rec.author_device_id),
|
|
657
|
+
sqlSafe(rec.scope ?? "business"),
|
|
658
|
+
sqlSafe(rec.memory_type),
|
|
659
|
+
sqlSafe(rec.session_scope)
|
|
660
|
+
]
|
|
661
|
+
}));
|
|
662
|
+
let syncErrors = 0;
|
|
663
|
+
const BATCH_SIZE = 100;
|
|
664
|
+
for (let i = 0; i < stmts.length; i += BATCH_SIZE) {
|
|
665
|
+
const batch = stmts.slice(i, i + BATCH_SIZE);
|
|
666
|
+
try {
|
|
667
|
+
await client.batch(batch, "write");
|
|
668
|
+
} catch (batchErr) {
|
|
669
|
+
for (const stmt of batch) {
|
|
670
|
+
try {
|
|
671
|
+
await client.execute(stmt);
|
|
672
|
+
} catch (recErr) {
|
|
673
|
+
syncErrors++;
|
|
674
|
+
process.stderr.write(
|
|
675
|
+
`[cloud-sync] Skipped bad record (${recErr instanceof Error ? recErr.message : String(recErr)})
|
|
659
676
|
`
|
|
660
|
-
|
|
677
|
+
);
|
|
678
|
+
}
|
|
661
679
|
}
|
|
662
680
|
}
|
|
681
|
+
if (i + BATCH_SIZE < stmts.length) {
|
|
682
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
683
|
+
}
|
|
663
684
|
}
|
|
664
|
-
|
|
665
|
-
|
|
685
|
+
pulled = stmts.length - syncErrors;
|
|
686
|
+
if (syncErrors > 0) {
|
|
687
|
+
process.stderr.write(`[cloud-sync] Pull completed with ${syncErrors} skipped record(s)
|
|
688
|
+
`);
|
|
666
689
|
}
|
|
667
690
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
691
|
+
}
|
|
692
|
+
if (pulled > 0) {
|
|
693
|
+
try {
|
|
694
|
+
await pushToPostgres(pullResult.records);
|
|
695
|
+
} catch (e) {
|
|
696
|
+
process.stderr.write("[cloud-sync] Postgres push of pulled records failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
|
|
672
697
|
}
|
|
673
698
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
process.stderr.write("[cloud-sync] Postgres push of pulled records failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
|
|
699
|
+
if (pullResult.maxVersion > lastPullVersion) {
|
|
700
|
+
await client.execute({
|
|
701
|
+
sql: "INSERT INTO sync_meta (key, value) VALUES ('last_cloud_pull_version', ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",
|
|
702
|
+
args: [String(pullResult.maxVersion)]
|
|
703
|
+
});
|
|
680
704
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
const nowMs = Date.now();
|
|
695
|
-
const pushCooldownActive = lastPushVersion > 0 && lastPushVersion === _lastSyncPushVersion && nowMs - _lastSyncPushTimestamp < SYNC_COOLDOWN_MS;
|
|
696
|
-
if (pushCooldownActive) {
|
|
697
|
-
} else {
|
|
698
|
-
while (true) {
|
|
699
|
-
const recordsResult = await client.execute({
|
|
700
|
-
sql: `SELECT id, agent_id, agent_role, session_id, timestamp,
|
|
705
|
+
const pushMeta = await client.execute(
|
|
706
|
+
"SELECT value FROM sync_meta WHERE key = 'last_cloud_push_version'"
|
|
707
|
+
);
|
|
708
|
+
const lastPushVersion = pushMeta.rows.length > 0 ? Number(pushMeta.rows[0].value) : 0;
|
|
709
|
+
let pushed = 0;
|
|
710
|
+
let batchCursor = lastPushVersion;
|
|
711
|
+
const nowMs = Date.now();
|
|
712
|
+
const pushCooldownActive = lastPushVersion > 0 && lastPushVersion === _lastSyncPushVersion && nowMs - _lastSyncPushTimestamp < SYNC_COOLDOWN_MS;
|
|
713
|
+
if (pushCooldownActive) {
|
|
714
|
+
} else {
|
|
715
|
+
while (true) {
|
|
716
|
+
const recordsResult = await client.execute({
|
|
717
|
+
sql: `SELECT id, agent_id, agent_role, session_id, timestamp,
|
|
701
718
|
tool_name, project_name, has_error, raw_text, version,
|
|
702
719
|
author_device_id, scope, session_scope
|
|
703
720
|
FROM memories
|
|
@@ -705,266 +722,273 @@ async function cloudSync(config) {
|
|
|
705
722
|
AND (scope IS NULL OR scope != 'personal')
|
|
706
723
|
ORDER BY version ASC
|
|
707
724
|
LIMIT ?`,
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
725
|
+
args: [batchCursor, PUSH_BATCH_SIZE]
|
|
726
|
+
});
|
|
727
|
+
if (recordsResult.rows.length === 0) break;
|
|
728
|
+
const records = recordsResult.rows.map((row) => ({
|
|
729
|
+
id: row.id,
|
|
730
|
+
agent_id: row.agent_id,
|
|
731
|
+
agent_role: row.agent_role,
|
|
732
|
+
session_id: row.session_id,
|
|
733
|
+
timestamp: row.timestamp,
|
|
734
|
+
tool_name: row.tool_name,
|
|
735
|
+
project_name: row.project_name,
|
|
736
|
+
has_error: row.has_error,
|
|
737
|
+
raw_text: row.raw_text,
|
|
738
|
+
version: row.version,
|
|
739
|
+
author_device_id: row.author_device_id,
|
|
740
|
+
scope: row.scope,
|
|
741
|
+
session_scope: row.session_scope
|
|
742
|
+
}));
|
|
743
|
+
const maxVersion = Number(records[records.length - 1].version);
|
|
744
|
+
let pushOk = await cloudPush(records, maxVersion, config);
|
|
745
|
+
if (!pushOk) {
|
|
746
|
+
await cloudPull(lastPullVersion, config);
|
|
747
|
+
pushOk = await cloudPush(records, maxVersion, config);
|
|
748
|
+
if (!pushOk) break;
|
|
749
|
+
}
|
|
750
|
+
try {
|
|
751
|
+
await pushToPostgres(records);
|
|
752
|
+
} catch (e) {
|
|
753
|
+
process.stderr.write("[cloud-sync] Postgres push of local records failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
|
|
754
|
+
}
|
|
755
|
+
await client.execute({
|
|
756
|
+
sql: "INSERT INTO sync_meta (key, value) VALUES ('last_cloud_push_version', ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",
|
|
757
|
+
args: [String(maxVersion)]
|
|
758
|
+
});
|
|
759
|
+
pushed += records.length;
|
|
760
|
+
batchCursor = maxVersion;
|
|
761
|
+
_lastSyncPushVersion = maxVersion;
|
|
762
|
+
_lastSyncPushTimestamp = Date.now();
|
|
763
|
+
if (recordsResult.rows.length < PUSH_BATCH_SIZE) break;
|
|
764
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
try {
|
|
768
|
+
await cloudPushRoster(config);
|
|
769
|
+
} catch (err) {
|
|
770
|
+
logError(`[cloud-sync] Roster push: ${err instanceof Error ? err.message : String(err)}`);
|
|
771
|
+
}
|
|
772
|
+
try {
|
|
773
|
+
await cloudPullRoster(config);
|
|
774
|
+
} catch (err) {
|
|
775
|
+
logError(`[cloud-sync] Roster pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
776
|
+
}
|
|
777
|
+
try {
|
|
778
|
+
await cloudPushGlobalProcedures(config);
|
|
779
|
+
} catch (err) {
|
|
780
|
+
logError(`[cloud-sync] Company procedures push: ${err instanceof Error ? err.message : String(err)}`);
|
|
781
|
+
}
|
|
782
|
+
try {
|
|
783
|
+
await cloudPullGlobalProcedures(config);
|
|
784
|
+
} catch (err) {
|
|
785
|
+
logError(`[cloud-sync] Company procedures pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
786
|
+
}
|
|
787
|
+
const countRows = async (sql) => {
|
|
729
788
|
try {
|
|
730
|
-
await
|
|
789
|
+
return Number((await client.execute(sql)).rows[0]?.cnt ?? 0);
|
|
731
790
|
} catch (e) {
|
|
732
|
-
process.stderr.write("[cloud-sync]
|
|
791
|
+
process.stderr.write("[cloud-sync] countRows failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
|
|
792
|
+
return 0;
|
|
733
793
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
pushed
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
_lastSyncPushTimestamp = Date.now();
|
|
742
|
-
if (recordsResult.rows.length < PUSH_BATCH_SIZE) break;
|
|
743
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
794
|
+
};
|
|
795
|
+
const behaviorsResult = { pushed: 0, pulled: 0 };
|
|
796
|
+
try {
|
|
797
|
+
await cloudPushBehaviors(config);
|
|
798
|
+
behaviorsResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM behaviors WHERE active = 1");
|
|
799
|
+
} catch (err) {
|
|
800
|
+
logError(`[cloud-sync] Behaviors push: ${err instanceof Error ? err.message : String(err)}`);
|
|
744
801
|
}
|
|
745
|
-
}
|
|
746
|
-
try {
|
|
747
|
-
await cloudPushRoster(config);
|
|
748
|
-
} catch (err) {
|
|
749
|
-
logError(`[cloud-sync] Roster push: ${err instanceof Error ? err.message : String(err)}`);
|
|
750
|
-
}
|
|
751
|
-
try {
|
|
752
|
-
await cloudPullRoster(config);
|
|
753
|
-
} catch (err) {
|
|
754
|
-
logError(`[cloud-sync] Roster pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
755
|
-
}
|
|
756
|
-
try {
|
|
757
|
-
await cloudPushGlobalProcedures(config);
|
|
758
|
-
} catch (err) {
|
|
759
|
-
logError(`[cloud-sync] Company procedures push: ${err instanceof Error ? err.message : String(err)}`);
|
|
760
|
-
}
|
|
761
|
-
try {
|
|
762
|
-
await cloudPullGlobalProcedures(config);
|
|
763
|
-
} catch (err) {
|
|
764
|
-
logError(`[cloud-sync] Company procedures pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
765
|
-
}
|
|
766
|
-
const countRows = async (sql) => {
|
|
767
802
|
try {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
803
|
+
const pullResult2 = await cloudPullBehaviors(config);
|
|
804
|
+
behaviorsResult.pulled = pullResult2.pulled;
|
|
805
|
+
} catch (err) {
|
|
806
|
+
logError(`[cloud-sync] Behaviors pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
772
807
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
logError(`[cloud-sync] Behaviors push: ${err instanceof Error ? err.message : String(err)}`);
|
|
780
|
-
}
|
|
781
|
-
try {
|
|
782
|
-
const pullResult2 = await cloudPullBehaviors(config);
|
|
783
|
-
behaviorsResult.pulled = pullResult2.pulled;
|
|
784
|
-
} catch (err) {
|
|
785
|
-
logError(`[cloud-sync] Behaviors pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
786
|
-
}
|
|
787
|
-
const graphragResult = { pushed: 0, pulled: 0 };
|
|
788
|
-
try {
|
|
789
|
-
await cloudPushGraphRAG(config);
|
|
790
|
-
graphragResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM entities");
|
|
791
|
-
} catch (err) {
|
|
792
|
-
logError(`[cloud-sync] GraphRAG push: ${err instanceof Error ? err.message : String(err)}`);
|
|
793
|
-
}
|
|
794
|
-
try {
|
|
795
|
-
const pullResult2 = await cloudPullGraphRAG(config);
|
|
796
|
-
graphragResult.pulled = pullResult2.pulled;
|
|
797
|
-
} catch (err) {
|
|
798
|
-
logError(`[cloud-sync] GraphRAG pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
799
|
-
}
|
|
800
|
-
const tasksResult = { pushed: 0, pulled: 0 };
|
|
801
|
-
try {
|
|
802
|
-
await cloudPushTasks(config);
|
|
803
|
-
tasksResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM tasks");
|
|
804
|
-
} catch (err) {
|
|
805
|
-
logError(`[cloud-sync] Tasks push: ${err instanceof Error ? err.message : String(err)}`);
|
|
806
|
-
}
|
|
807
|
-
try {
|
|
808
|
-
const pullResult2 = await cloudPullTasks(config);
|
|
809
|
-
tasksResult.pulled = pullResult2.pulled;
|
|
810
|
-
} catch (err) {
|
|
811
|
-
logError(`[cloud-sync] Tasks pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
812
|
-
}
|
|
813
|
-
const conversationsResult = { pushed: 0, pulled: 0 };
|
|
814
|
-
try {
|
|
815
|
-
await cloudPushConversations(config);
|
|
816
|
-
conversationsResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM conversations");
|
|
817
|
-
} catch (err) {
|
|
818
|
-
logError(`[cloud-sync] Conversations push: ${err instanceof Error ? err.message : String(err)}`);
|
|
819
|
-
}
|
|
820
|
-
try {
|
|
821
|
-
const pullResult2 = await cloudPullConversations(config);
|
|
822
|
-
conversationsResult.pulled = pullResult2.pulled;
|
|
823
|
-
} catch (err) {
|
|
824
|
-
logError(`[cloud-sync] Conversations pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
825
|
-
}
|
|
826
|
-
const schedulesResult = { pushed: 0, pulled: 0 };
|
|
827
|
-
try {
|
|
828
|
-
await cloudPushSchedules(config);
|
|
829
|
-
schedulesResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM schedules");
|
|
830
|
-
} catch (err) {
|
|
831
|
-
logError(`[cloud-sync] Schedules push: ${err instanceof Error ? err.message : String(err)}`);
|
|
832
|
-
}
|
|
833
|
-
try {
|
|
834
|
-
const pullResult2 = await cloudPullSchedules(config);
|
|
835
|
-
schedulesResult.pulled = pullResult2.pulled;
|
|
836
|
-
} catch (err) {
|
|
837
|
-
logError(`[cloud-sync] Schedules pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
838
|
-
}
|
|
839
|
-
const trajectoriesResult = { pushed: 0, pulled: 0 };
|
|
840
|
-
try {
|
|
841
|
-
await cloudPushTrajectories(config);
|
|
842
|
-
trajectoriesResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM trajectories");
|
|
843
|
-
} catch (err) {
|
|
844
|
-
logError(`[cloud-sync] Trajectories push: ${err instanceof Error ? err.message : String(err)}`);
|
|
845
|
-
}
|
|
846
|
-
try {
|
|
847
|
-
const pullResult2 = await cloudPullTrajectories(config);
|
|
848
|
-
trajectoriesResult.pulled = pullResult2.pulled;
|
|
849
|
-
} catch (err) {
|
|
850
|
-
logError(`[cloud-sync] Trajectories pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
851
|
-
}
|
|
852
|
-
const consolidationsResult = { pushed: 0, pulled: 0 };
|
|
853
|
-
try {
|
|
854
|
-
await cloudPushConsolidations(config);
|
|
855
|
-
consolidationsResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM consolidations");
|
|
856
|
-
} catch (err) {
|
|
857
|
-
logError(`[cloud-sync] Consolidations push: ${err instanceof Error ? err.message : String(err)}`);
|
|
858
|
-
}
|
|
859
|
-
try {
|
|
860
|
-
const pullResult2 = await cloudPullConsolidations(config);
|
|
861
|
-
consolidationsResult.pulled = pullResult2.pulled;
|
|
862
|
-
} catch (err) {
|
|
863
|
-
logError(`[cloud-sync] Consolidations pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
864
|
-
}
|
|
865
|
-
const identityResult = { pushed: 0, pulled: 0 };
|
|
866
|
-
try {
|
|
867
|
-
await cloudPushIdentityMeta(config);
|
|
868
|
-
identityResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM identity");
|
|
869
|
-
} catch (err) {
|
|
870
|
-
logError(`[cloud-sync] Identity push: ${err instanceof Error ? err.message : String(err)}`);
|
|
871
|
-
}
|
|
872
|
-
try {
|
|
873
|
-
const pullResult2 = await cloudPullIdentityMeta(config);
|
|
874
|
-
identityResult.pulled = pullResult2.pulled;
|
|
875
|
-
} catch (err) {
|
|
876
|
-
logError(`[cloud-sync] Identity pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
877
|
-
}
|
|
878
|
-
const documentsResult = { pushed: 0, pulled: 0 };
|
|
879
|
-
try {
|
|
880
|
-
await cloudPushDocuments(config);
|
|
881
|
-
documentsResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM documents");
|
|
882
|
-
} catch (err) {
|
|
883
|
-
logError(`[cloud-sync] Documents push: ${err instanceof Error ? err.message : String(err)}`);
|
|
884
|
-
}
|
|
885
|
-
try {
|
|
886
|
-
const pullResult2 = await cloudPullDocuments(config);
|
|
887
|
-
documentsResult.pulled = pullResult2.pulled;
|
|
888
|
-
} catch (err) {
|
|
889
|
-
logError(`[cloud-sync] Documents pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
890
|
-
}
|
|
891
|
-
const coreMemoryResult = { pushed: 0, pulled: 0 };
|
|
892
|
-
try {
|
|
893
|
-
await cloudPushCoreMemory(config);
|
|
894
|
-
coreMemoryResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM core_memory");
|
|
895
|
-
} catch (err) {
|
|
896
|
-
logError(`[cloud-sync] Core memory push: ${err instanceof Error ? err.message : String(err)}`);
|
|
897
|
-
}
|
|
898
|
-
try {
|
|
899
|
-
const pullResult2 = await cloudPullCoreMemory(config);
|
|
900
|
-
coreMemoryResult.pulled = pullResult2.pulled;
|
|
901
|
-
} catch (err) {
|
|
902
|
-
logError(`[cloud-sync] Core memory pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
903
|
-
}
|
|
904
|
-
const rosterResult = { employees: 0, identities: 0 };
|
|
905
|
-
try {
|
|
906
|
-
const employees = await loadEmployees();
|
|
907
|
-
rosterResult.employees = employees.length;
|
|
908
|
-
const idDir = path.join(EXE_AI_DIR, "identity");
|
|
909
|
-
if (existsSync(idDir)) {
|
|
910
|
-
rosterResult.identities = readdirSync(idDir).filter((f) => f.endsWith(".md")).length;
|
|
808
|
+
const graphragResult = { pushed: 0, pulled: 0 };
|
|
809
|
+
try {
|
|
810
|
+
await cloudPushGraphRAG(config);
|
|
811
|
+
graphragResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM entities");
|
|
812
|
+
} catch (err) {
|
|
813
|
+
logError(`[cloud-sync] GraphRAG push: ${err instanceof Error ? err.message : String(err)}`);
|
|
911
814
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
const
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
815
|
+
try {
|
|
816
|
+
const pullResult2 = await cloudPullGraphRAG(config);
|
|
817
|
+
graphragResult.pulled = pullResult2.pulled;
|
|
818
|
+
} catch (err) {
|
|
819
|
+
logError(`[cloud-sync] GraphRAG pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
820
|
+
}
|
|
821
|
+
const tasksResult = { pushed: 0, pulled: 0 };
|
|
822
|
+
try {
|
|
823
|
+
await cloudPushTasks(config);
|
|
824
|
+
tasksResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM tasks");
|
|
825
|
+
} catch (err) {
|
|
826
|
+
logError(`[cloud-sync] Tasks push: ${err instanceof Error ? err.message : String(err)}`);
|
|
827
|
+
}
|
|
828
|
+
try {
|
|
829
|
+
const pullResult2 = await cloudPullTasks(config);
|
|
830
|
+
tasksResult.pulled = pullResult2.pulled;
|
|
831
|
+
} catch (err) {
|
|
832
|
+
logError(`[cloud-sync] Tasks pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
833
|
+
}
|
|
834
|
+
const conversationsResult = { pushed: 0, pulled: 0 };
|
|
835
|
+
try {
|
|
836
|
+
await cloudPushConversations(config);
|
|
837
|
+
conversationsResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM conversations");
|
|
838
|
+
} catch (err) {
|
|
839
|
+
logError(`[cloud-sync] Conversations push: ${err instanceof Error ? err.message : String(err)}`);
|
|
840
|
+
}
|
|
841
|
+
try {
|
|
842
|
+
const pullResult2 = await cloudPullConversations(config);
|
|
843
|
+
conversationsResult.pulled = pullResult2.pulled;
|
|
844
|
+
} catch (err) {
|
|
845
|
+
logError(`[cloud-sync] Conversations pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
846
|
+
}
|
|
847
|
+
const schedulesResult = { pushed: 0, pulled: 0 };
|
|
848
|
+
try {
|
|
849
|
+
await cloudPushSchedules(config);
|
|
850
|
+
schedulesResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM schedules");
|
|
851
|
+
} catch (err) {
|
|
852
|
+
logError(`[cloud-sync] Schedules push: ${err instanceof Error ? err.message : String(err)}`);
|
|
853
|
+
}
|
|
854
|
+
try {
|
|
855
|
+
const pullResult2 = await cloudPullSchedules(config);
|
|
856
|
+
schedulesResult.pulled = pullResult2.pulled;
|
|
857
|
+
} catch (err) {
|
|
858
|
+
logError(`[cloud-sync] Schedules pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
859
|
+
}
|
|
860
|
+
const trajectoriesResult = { pushed: 0, pulled: 0 };
|
|
861
|
+
try {
|
|
862
|
+
await cloudPushTrajectories(config);
|
|
863
|
+
trajectoriesResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM trajectories");
|
|
864
|
+
} catch (err) {
|
|
865
|
+
logError(`[cloud-sync] Trajectories push: ${err instanceof Error ? err.message : String(err)}`);
|
|
866
|
+
}
|
|
867
|
+
try {
|
|
868
|
+
const pullResult2 = await cloudPullTrajectories(config);
|
|
869
|
+
trajectoriesResult.pulled = pullResult2.pulled;
|
|
870
|
+
} catch (err) {
|
|
871
|
+
logError(`[cloud-sync] Trajectories pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
872
|
+
}
|
|
873
|
+
const consolidationsResult = { pushed: 0, pulled: 0 };
|
|
874
|
+
try {
|
|
875
|
+
await cloudPushConsolidations(config);
|
|
876
|
+
consolidationsResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM consolidations");
|
|
877
|
+
} catch (err) {
|
|
878
|
+
logError(`[cloud-sync] Consolidations push: ${err instanceof Error ? err.message : String(err)}`);
|
|
879
|
+
}
|
|
880
|
+
try {
|
|
881
|
+
const pullResult2 = await cloudPullConsolidations(config);
|
|
882
|
+
consolidationsResult.pulled = pullResult2.pulled;
|
|
883
|
+
} catch (err) {
|
|
884
|
+
logError(`[cloud-sync] Consolidations pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
885
|
+
}
|
|
886
|
+
const identityResult = { pushed: 0, pulled: 0 };
|
|
887
|
+
try {
|
|
888
|
+
await cloudPushIdentityMeta(config);
|
|
889
|
+
identityResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM identity");
|
|
890
|
+
} catch (err) {
|
|
891
|
+
logError(`[cloud-sync] Identity push: ${err instanceof Error ? err.message : String(err)}`);
|
|
892
|
+
}
|
|
893
|
+
try {
|
|
894
|
+
const pullResult2 = await cloudPullIdentityMeta(config);
|
|
895
|
+
identityResult.pulled = pullResult2.pulled;
|
|
896
|
+
} catch (err) {
|
|
897
|
+
logError(`[cloud-sync] Identity pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
898
|
+
}
|
|
899
|
+
const documentsResult = { pushed: 0, pulled: 0 };
|
|
900
|
+
try {
|
|
901
|
+
await cloudPushDocuments(config);
|
|
902
|
+
documentsResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM documents");
|
|
903
|
+
} catch (err) {
|
|
904
|
+
logError(`[cloud-sync] Documents push: ${err instanceof Error ? err.message : String(err)}`);
|
|
905
|
+
}
|
|
906
|
+
try {
|
|
907
|
+
const pullResult2 = await cloudPullDocuments(config);
|
|
908
|
+
documentsResult.pulled = pullResult2.pulled;
|
|
909
|
+
} catch (err) {
|
|
910
|
+
logError(`[cloud-sync] Documents pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
911
|
+
}
|
|
912
|
+
const coreMemoryResult = { pushed: 0, pulled: 0 };
|
|
913
|
+
try {
|
|
914
|
+
await cloudPushCoreMemory(config);
|
|
915
|
+
coreMemoryResult.pushed = await countRows("SELECT COUNT(*) as cnt FROM core_memory");
|
|
916
|
+
} catch (err) {
|
|
917
|
+
logError(`[cloud-sync] Core memory push: ${err instanceof Error ? err.message : String(err)}`);
|
|
918
|
+
}
|
|
919
|
+
try {
|
|
920
|
+
const pullResult2 = await cloudPullCoreMemory(config);
|
|
921
|
+
coreMemoryResult.pulled = pullResult2.pulled;
|
|
922
|
+
} catch (err) {
|
|
923
|
+
logError(`[cloud-sync] Core memory pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
924
|
+
}
|
|
925
|
+
const rosterResult = { employees: 0, identities: 0 };
|
|
926
|
+
try {
|
|
927
|
+
const employees = await loadEmployees();
|
|
928
|
+
rosterResult.employees = employees.length;
|
|
929
|
+
const idDir = path.join(EXE_AI_DIR, "identity");
|
|
930
|
+
if (existsSync(idDir)) {
|
|
931
|
+
rosterResult.identities = readdirSync(idDir).filter((f) => f.endsWith(".md")).length;
|
|
932
|
+
}
|
|
933
|
+
} catch (e) {
|
|
934
|
+
process.stderr.write("[cloud-sync] roster count failed: " + (e instanceof Error ? e.message : String(e)) + "\n");
|
|
935
|
+
}
|
|
936
|
+
const totalMemories = await countRows("SELECT COUNT(*) as cnt FROM memories WHERE status = 'active' OR status IS NULL");
|
|
937
|
+
try {
|
|
938
|
+
const { getLatestBackup } = await import("./db-backup-3ZQQPS5G.js");
|
|
939
|
+
const latestBackup = getLatestBackup();
|
|
940
|
+
if (latestBackup) {
|
|
941
|
+
const backupSize = statSync(latestBackup).size;
|
|
942
|
+
const MAX_CLOUD_BACKUP_BYTES = 50 * 1024 * 1024;
|
|
943
|
+
if (backupSize <= MAX_CLOUD_BACKUP_BYTES) {
|
|
944
|
+
const backupData = readFileSync(latestBackup);
|
|
945
|
+
const deviceId = loadDeviceId() ?? "unknown";
|
|
946
|
+
const encrypted = encryptSyncBlob(backupData);
|
|
947
|
+
const backupRes = await fetchWithRetry(`${config.endpoint}/sync/push-db-backup`, {
|
|
948
|
+
method: "POST",
|
|
949
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${config.apiKey}` },
|
|
950
|
+
body: JSON.stringify({
|
|
951
|
+
device_id: deviceId,
|
|
952
|
+
filename: path.basename(latestBackup),
|
|
953
|
+
blob: encrypted,
|
|
954
|
+
size: backupData.length
|
|
955
|
+
})
|
|
956
|
+
});
|
|
957
|
+
if (backupRes && !backupRes.ok) {
|
|
958
|
+
logError(`[cloud-sync] DB backup upload failed: ${backupRes.status}`);
|
|
959
|
+
}
|
|
938
960
|
}
|
|
939
961
|
}
|
|
962
|
+
} catch (err) {
|
|
963
|
+
logError(`[cloud-sync] DB backup upload error: ${err instanceof Error ? err.message : String(err)}`);
|
|
940
964
|
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
965
|
+
const codeContextResult = { pushed: 0, pulled: 0 };
|
|
966
|
+
try {
|
|
967
|
+
codeContextResult.pushed = await cloudPushCodeContext(config);
|
|
968
|
+
} catch (err) {
|
|
969
|
+
logError(`[cloud-sync] Code context push: ${err instanceof Error ? err.message : String(err)}`);
|
|
970
|
+
}
|
|
971
|
+
try {
|
|
972
|
+
codeContextResult.pulled = await cloudPullCodeContext(config);
|
|
973
|
+
} catch (err) {
|
|
974
|
+
logError(`[cloud-sync] Code context pull: ${err instanceof Error ? err.message : String(err)}`);
|
|
975
|
+
}
|
|
976
|
+
return {
|
|
977
|
+
pushed,
|
|
978
|
+
pulled,
|
|
979
|
+
totalMemories,
|
|
980
|
+
behaviors: behaviorsResult,
|
|
981
|
+
graphrag: graphragResult,
|
|
982
|
+
tasks: tasksResult,
|
|
983
|
+
conversations: conversationsResult,
|
|
984
|
+
documents: documentsResult,
|
|
985
|
+
coreMemory: coreMemoryResult,
|
|
986
|
+
roster: rosterResult,
|
|
987
|
+
codeContext: codeContextResult
|
|
988
|
+
};
|
|
989
|
+
} finally {
|
|
990
|
+
_cloudSyncInProgress = false;
|
|
954
991
|
}
|
|
955
|
-
return {
|
|
956
|
-
pushed,
|
|
957
|
-
pulled,
|
|
958
|
-
totalMemories,
|
|
959
|
-
behaviors: behaviorsResult,
|
|
960
|
-
graphrag: graphragResult,
|
|
961
|
-
tasks: tasksResult,
|
|
962
|
-
conversations: conversationsResult,
|
|
963
|
-
documents: documentsResult,
|
|
964
|
-
coreMemory: coreMemoryResult,
|
|
965
|
-
roster: rosterResult,
|
|
966
|
-
codeContext: codeContextResult
|
|
967
|
-
};
|
|
968
992
|
}
|
|
969
993
|
var ROSTER_DELETIONS_PATH = path.join(EXE_AI_DIR, "roster-deletions.json");
|
|
970
994
|
function recordRosterDeletion(name) {
|
|
@@ -1969,6 +1993,7 @@ async function cloudPullCoreMemory(config) {
|
|
|
1969
1993
|
}
|
|
1970
1994
|
|
|
1971
1995
|
export {
|
|
1996
|
+
disposeCloudSync,
|
|
1972
1997
|
pushToPostgres,
|
|
1973
1998
|
migrateEndpoint,
|
|
1974
1999
|
assertSecureEndpoint,
|