@askexenow/exe-os 0.9.292 → 0.9.293
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/deploy/compose/generate-env.ts +27 -1
- package/dist/active-agent-OEJKODGY.js +27 -0
- package/dist/active-agent-PFZAEMJA.js +28 -0
- package/dist/active-agent-USK4RVP5.js +28 -0
- package/dist/active-agent-XEZTZEV7.js +27 -0
- package/dist/agentic-ontology-46PBPTLE.js +25 -0
- package/dist/agentic-ontology-WTXI6RLB.js +25 -0
- package/dist/assets/com.askexe.exed.plist +70 -0
- package/dist/backfill-metadata-IYP2QGGD.js +600 -0
- package/dist/backfill-metadata-S523IKKJ.js +600 -0
- package/dist/behaviors-GPCWN3RL.js +46 -0
- package/dist/behaviors-UYEYYVIH.js +46 -0
- package/dist/bin/agentic-ontology-backfill.js +5 -5
- package/dist/bin/agentic-reflection-backfill.js +6 -6
- package/dist/bin/agentic-semantic-label.js +5 -5
- package/dist/bin/backfill-conversations.js +6 -6
- package/dist/bin/backfill-responses.js +6 -6
- package/dist/bin/backfill-vectors.js +8 -8
- package/dist/bin/bulk-sync-postgres.js +7 -6
- package/dist/bin/cc-doctor.js +4 -4
- package/dist/bin/cleanup-stale-review-tasks.js +11 -11
- package/dist/bin/cli.js +16 -16
- package/dist/bin/deferred-daemon-restart.js +1 -1
- package/dist/bin/exe-agent-config.js +2 -2
- package/dist/bin/exe-agent.js +4 -4
- package/dist/bin/exe-assign.js +8 -8
- package/dist/bin/exe-boot.js +38 -18
- package/dist/bin/exe-call.js +4 -4
- package/dist/bin/exe-cloud.js +11 -4
- package/dist/bin/exe-dispatch.js +11 -11
- package/dist/bin/exe-doctor.js +2 -2
- package/dist/bin/exe-export-behaviors.js +7 -7
- package/dist/bin/exe-forget.js +6 -6
- package/dist/bin/exe-gateway.js +7 -7
- package/dist/bin/exe-healthcheck.js +4 -4
- package/dist/bin/exe-heartbeat.js +11 -11
- package/dist/bin/exe-kill.js +14 -14
- package/dist/bin/exe-launch-agent.js +36 -18
- package/dist/bin/exe-new-employee.js +6 -6
- package/dist/bin/exe-pending-messages.js +12 -12
- package/dist/bin/exe-pending-notifications.js +11 -11
- package/dist/bin/exe-pending-reviews.js +11 -11
- package/dist/bin/exe-rename.js +4 -4
- package/dist/bin/exe-review.js +13 -13
- package/dist/bin/exe-search.js +5 -5
- package/dist/bin/exe-session-cleanup.js +16 -16
- package/dist/bin/exe-settings.js +12 -4
- package/dist/bin/exe-start-codex.js +11 -11
- package/dist/bin/exe-start-opencode.js +8 -8
- package/dist/bin/exe-status.js +12 -12
- package/dist/bin/exe-team.js +3 -3
- package/dist/bin/git-sweep.js +12 -12
- package/dist/bin/graph-backfill.js +4 -4
- package/dist/bin/graph-export.js +5 -5
- package/dist/bin/import-history.js +7 -7
- package/dist/bin/install-launchd.js +46 -10
- package/dist/bin/install.js +8 -8
- package/dist/bin/intercom-check.js +4 -4
- package/dist/bin/mcp-sessions.js +2 -2
- package/dist/bin/orchestration-metrics.js +4 -4
- package/dist/bin/postgres-agentic-reflection-backfill.js +2 -2
- package/dist/bin/postgres-agentic-semantic-backfill.js +1 -1
- package/dist/bin/scan-tasks.js +11 -11
- package/dist/bin/setup.js +1 -1
- package/dist/bin/shard-migrate.js +4 -4
- package/dist/capability-cards-7XF2UW3Z.js +89 -0
- package/dist/capability-cards-DME6OMOK.js +89 -0
- package/dist/capacity-monitor-7SKMXRIK.js +51 -0
- package/dist/capacity-monitor-MNEA6FMY.js +51 -0
- package/dist/catchup-brief-46O3RLWO.js +175 -0
- package/dist/catchup-brief-EPEKZKRA.js +175 -0
- package/dist/chunk-2EMOVUJR.js +128 -0
- package/dist/chunk-2JE7LJCZ.js +240 -0
- package/dist/chunk-2LHQ5MGP.js +377 -0
- package/dist/chunk-2ZXMXFGH.js +4380 -0
- package/dist/chunk-3KIMGEFL.js +54 -0
- package/dist/chunk-3PY5PK75.js +14533 -0
- package/dist/chunk-3SDAK22H.js +538 -0
- package/dist/chunk-4CEGPB6F.js +240 -0
- package/dist/chunk-4HDMB2M5.js +574 -0
- package/dist/chunk-4KCLWBF6.js +197 -0
- package/dist/chunk-4WZ55DSC.js +381 -0
- package/dist/chunk-5QX4LHOF.js +668 -0
- package/dist/chunk-5RSGWGYP.js +1119 -0
- package/dist/chunk-5SWY4J5G.js +284 -0
- package/dist/chunk-5ZHIAIDE.js +424 -0
- package/dist/chunk-5ZKD5ZVT.js +33 -0
- package/dist/chunk-67X246EI.js +424 -0
- package/dist/chunk-6A56VNVX.js +448 -0
- package/dist/chunk-6EEBG6WU.js +345 -0
- package/dist/chunk-6EI5U2KJ.js +171 -0
- package/dist/chunk-6G4JWZPF.js +128 -0
- package/dist/chunk-6GTLJHAG.js +150 -0
- package/dist/chunk-6LDZPC2H.js +1079 -0
- package/dist/chunk-6PNCZTKV.js +1119 -0
- package/dist/chunk-6QPDD4BI.js +123 -0
- package/dist/chunk-6ZMLJ6ZQ.js +2129 -0
- package/dist/chunk-72O5EJ52.js +204 -0
- package/dist/chunk-737NSJT4.js +553 -0
- package/dist/chunk-7P5TUGTL.js +456 -0
- package/dist/chunk-7XDF7BZQ.js +192 -0
- package/dist/chunk-ALYNEMIH.js +150 -0
- package/dist/chunk-B4PYJHIV.js +402 -0
- package/dist/chunk-B5ZCGIYB.js +630 -0
- package/dist/chunk-BE3T47CS.js +97 -0
- package/dist/chunk-BNJ3YCPD.js +192 -0
- package/dist/chunk-BUBYDG7Q.js +1079 -0
- package/dist/chunk-CSCRGRZT.js +345 -0
- package/dist/chunk-CY4S3HMG.js +30 -0
- package/dist/chunk-D2WYUJHM.js +50 -0
- package/dist/chunk-D3X64YSB.js +377 -0
- package/dist/chunk-D6TPR4BN.js +204 -0
- package/dist/chunk-DDI57ILJ.js +38 -0
- package/dist/chunk-DQBHY3Q4.js +210 -0
- package/dist/chunk-DVFHAY2J.js +630 -0
- package/dist/chunk-DWCR5GGG.js +128 -0
- package/dist/chunk-DZJPVLVR.js +2078 -0
- package/dist/chunk-E45SQG7C.js +280 -0
- package/dist/chunk-EJ7CWALW.js +244 -0
- package/dist/chunk-EM5WXY6H.js +836 -0
- package/dist/chunk-EOVVOUXC.js +381 -0
- package/dist/chunk-EVV55PHP.js +331 -0
- package/dist/chunk-F4FMIWEL.js +214 -0
- package/dist/chunk-F5GLICUP.js +85 -0
- package/dist/chunk-F5WN7EQ2.js +333 -0
- package/dist/chunk-FVXYTNSI.js +123 -0
- package/dist/chunk-FXD5LXRD.js +8 -0
- package/dist/chunk-G53LIPLG.js +76 -0
- package/dist/chunk-GEJAUWIZ.js +1350 -0
- package/dist/chunk-GJDYAXUL.js +227 -0
- package/dist/chunk-GJS7CJRC.js +129 -0
- package/dist/chunk-GTVP4QTZ.js +362 -0
- package/dist/chunk-HG7Z7JHX.js +85 -0
- package/dist/chunk-HH3MBGMJ.js +70 -0
- package/dist/chunk-HJBKBEC4.js +58 -0
- package/dist/chunk-HKSTWZ22.js +456 -0
- package/dist/chunk-HMP5VT6A.js +118 -0
- package/dist/chunk-HN2PWLQI.js +167 -0
- package/dist/chunk-HN3HGFBL.js +20 -0
- package/dist/chunk-HREBA7BJ.js +290 -0
- package/dist/chunk-HV7F5CXJ.js +553 -0
- package/dist/chunk-HWXIMSB7.js +30 -0
- package/dist/chunk-HWY5ROLO.js +129 -0
- package/dist/chunk-IDJCLLJF.js +3298 -0
- package/dist/chunk-IPMGAQGC.js +290 -0
- package/dist/chunk-IRT55NLF.js +382 -0
- package/dist/chunk-IXZ7OTB3.js +159 -0
- package/dist/chunk-J7JVMFKR.js +262 -0
- package/dist/chunk-JABYHL7R.js +171 -0
- package/dist/chunk-JE2ICRS5.js +197 -0
- package/dist/chunk-JLH273CW.js +70 -0
- package/dist/chunk-JPTT22PI.js +54 -0
- package/dist/chunk-JVT6ONVZ.js +731 -0
- package/dist/chunk-KJEG2OQN.js +1350 -0
- package/dist/chunk-LSASGUNP.js +85 -0
- package/dist/chunk-LSTM35QE.js +1186 -0
- package/dist/chunk-LZEWGBU2.js +97 -0
- package/dist/chunk-M2IOPGVR.js +731 -0
- package/dist/chunk-MBININJN.js +2078 -0
- package/dist/chunk-MJ2MCLZH.js +402 -0
- package/dist/chunk-MX63V4YD.js +38 -0
- package/dist/chunk-N7TWCWY5.js +128 -0
- package/dist/chunk-NAKIQODV.js +331 -0
- package/dist/chunk-NMJSZ5FC.js +185 -0
- package/dist/chunk-NXCJWGAF.js +836 -0
- package/dist/chunk-OLJTE7LW.js +157 -0
- package/dist/chunk-OPDX7KTW.js +167 -0
- package/dist/chunk-OXM62MI7.js +221 -0
- package/dist/chunk-PC53GP5N.js +55 -0
- package/dist/chunk-PMMQFOER.js +81 -0
- package/dist/chunk-PVVG22J4.js +735 -0
- package/dist/chunk-Q326CKO3.js +377 -0
- package/dist/chunk-QAK47LG3.js +81 -0
- package/dist/chunk-QAWSQ5LG.js +157 -0
- package/dist/chunk-QLPHEY7D.js +668 -0
- package/dist/chunk-QV4CHWME.js +97 -0
- package/dist/chunk-QY46R3SB.js +348 -0
- package/dist/chunk-RAERYWCL.js +299 -0
- package/dist/chunk-RT5NXMH2.js +284 -0
- package/dist/chunk-RUUIZJSU.js +127 -0
- package/dist/chunk-S3PNZLTN.js +50 -0
- package/dist/chunk-S6WSWJBL.js +362 -0
- package/dist/chunk-STOZKLK6.js +1352 -0
- package/dist/chunk-SZCJI4TR.js +735 -0
- package/dist/chunk-T3FMPQOR.js +85 -0
- package/dist/chunk-T6EKR34W.js +58 -0
- package/dist/chunk-TKIOFYNW.js +1186 -0
- package/dist/chunk-TM2GZWIT.js +3313 -0
- package/dist/chunk-TWFTSIAI.js +4380 -0
- package/dist/chunk-U7BFATN7.js +538 -0
- package/dist/chunk-UAQZT24C.js +181 -0
- package/dist/chunk-UFHBNXGV.js +333 -0
- package/dist/chunk-UVN3LWCL.js +214 -0
- package/dist/chunk-UVRS32RJ.js +97 -0
- package/dist/chunk-V6R43RSE.js +227 -0
- package/dist/chunk-VHMVQUCR.js +448 -0
- package/dist/chunk-VK7NRMIW.js +2133 -0
- package/dist/chunk-VRFO3H3R.js +76 -0
- package/dist/chunk-VRZS4KWF.js +122 -0
- package/dist/chunk-WOXY76VV.js +33 -0
- package/dist/chunk-X6VOKECC.js +348 -0
- package/dist/chunk-XADXYWPE.js +280 -0
- package/dist/chunk-XCP56OMR.js +1352 -0
- package/dist/chunk-XDH5XB72.js +262 -0
- package/dist/chunk-XFPSFPVD.js +1094 -0
- package/dist/chunk-XOT6CVJA.js +244 -0
- package/dist/chunk-XWRIBBYP.js +210 -0
- package/dist/chunk-XWVCURC2.js +181 -0
- package/dist/chunk-YA6SJFNN.js +221 -0
- package/dist/chunk-YDMUHYCP.js +127 -0
- package/dist/chunk-YKQQ4UTG.js +382 -0
- package/dist/chunk-YNORJIBH.js +208 -0
- package/dist/chunk-YQ2R4BLZ.js +14533 -0
- package/dist/chunk-YUIT7Z7I.js +299 -0
- package/dist/chunk-ZD6EJ7LY.js +604 -0
- package/dist/chunk-ZHHBVPOX.js +1094 -0
- package/dist/chunk-ZNY54QWW.js +377 -0
- package/dist/chunk-ZVABYVSP.js +122 -0
- package/dist/chunk-ZVDYPSJH.js +94 -0
- package/dist/chunk-ZXNQ7GRU.js +185 -0
- package/dist/co-activation-ACVH2TL4.js +74 -0
- package/dist/co-activation-EJ63SDWZ.js +74 -0
- package/dist/co-occurrence-VKJWYROE.js +95 -0
- package/dist/co-occurrence-X2M3ASN4.js +95 -0
- package/dist/code-context-index-5EFZGRML.js +30 -0
- package/dist/core-memory-G3AEM4FY.js +110 -0
- package/dist/core-memory-GOI4WKP5.js +110 -0
- package/dist/crdt-sync-QXBHJ5GL.js +33 -0
- package/dist/crdt-sync-WX6YMYZS.js +33 -0
- package/dist/crm-webhook-EEL2F5TM.js +10 -0
- package/dist/crm-webhook-OYNQH4RZ.js +10 -0
- package/dist/cto-delegation-gate-RP4XBAZZ.js +280 -0
- package/dist/cto-delegation-gate-XOD3NAJS.js +280 -0
- package/dist/daemon-orchestration-33R5DNF2.js +139 -0
- package/dist/daemon-orchestration-EEPWOFMX.js +139 -0
- package/dist/db-backup-T4OALIZH.js +41 -0
- package/dist/db-backup-U5TNET7Z.js +41 -0
- package/dist/dispatch-ack-4S44HBWB.js +15 -0
- package/dist/doc-graph-extractor-O5EADZ3H.js +133 -0
- package/dist/doc-graph-extractor-SFMDR2SB.js +133 -0
- package/dist/dreaming-IXYC3FUN.js +34 -0
- package/dist/dreaming-ODYGZEIV.js +34 -0
- package/dist/entity-boost-XBGZKDJZ.js +375 -0
- package/dist/exe-drift-BKAGZUO2.js +70 -0
- package/dist/exe-drift-N7QYRQX7.js +70 -0
- package/dist/exe-export-AQZ3ZPSJ.js +77 -0
- package/dist/exe-export-QQGWWVZC.js +77 -0
- package/dist/exe-import-EVEGB2O4.js +80 -0
- package/dist/exe-import-RPL3RSZ2.js +80 -0
- package/dist/exe-key-5FYKRZOH.js +673 -0
- package/dist/exe-key-Y256JM3G.js +673 -0
- package/dist/exe-snapshot-AUJQ53Z7.js +338 -0
- package/dist/exe-snapshot-CSJDVWXM.js +338 -0
- package/dist/fast-db-init-57YCVJQP.js +7 -0
- package/dist/fast-db-init-VU4FDPGX.js +7 -0
- package/dist/gateway/index.js +8 -8
- package/dist/git-staleness-CR46BFAY.js +112 -0
- package/dist/git-staleness-H4NWNDJ5.js +112 -0
- package/dist/git-task-sweep-F7ASO7CZ.js +42 -0
- package/dist/git-task-sweep-XSPCOBUY.js +42 -0
- package/dist/global-procedures-7FDCJNWI.js +22 -0
- package/dist/global-procedures-GX7V5L76.js +22 -0
- package/dist/graph-auto-extract-JI3VW5KY.js +183 -0
- package/dist/graph-auto-extract-KFNHAHBK.js +183 -0
- 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 +13 -13
- package/dist/hooks/error-recall.js +6 -6
- package/dist/hooks/exe-heartbeat-hook.js +3 -3
- package/dist/hooks/ingest-worker.js +3 -3
- package/dist/hooks/ingest.js +6 -6
- package/dist/hooks/instructions-loaded.js +4 -4
- package/dist/hooks/manifest.json +20 -20
- package/dist/hooks/notification.js +4 -4
- package/dist/hooks/post-compact.js +12 -12
- package/dist/hooks/post-tool-combined.js +6 -6
- package/dist/hooks/pre-compact.js +16 -16
- package/dist/hooks/pre-tool-use.js +17 -17
- package/dist/hooks/prompt-submit.js +25 -25
- package/dist/hooks/session-end.js +23 -21
- package/dist/hooks/session-start.js +12 -12
- package/dist/hooks/stop.js +19 -19
- package/dist/hooks/subagent-stop.js +43 -13
- package/dist/hooks/summary-worker.js +19 -19
- package/dist/index.js +19 -19
- package/dist/installer-6PMCIZQZ.js +298 -0
- package/dist/installer-7ET5M2DD.js +344 -0
- package/dist/installer-K7BYY3XC.js +344 -0
- package/dist/installer-U6W7TQZU.js +40 -0
- package/dist/installer-UL4HFVPT.js +298 -0
- package/dist/installer-XMQRESAT.js +40 -0
- package/dist/lib/cloud-sync.js +12 -4
- package/dist/lib/consolidation.js +5 -5
- package/dist/lib/database.js +2 -2
- package/dist/lib/db-daemon-client.js +2 -2
- package/dist/lib/db.js +2 -2
- package/dist/lib/embedder.js +3 -3
- package/dist/lib/employee-templates.js +4 -4
- package/dist/lib/employees.js +2 -2
- package/dist/lib/exe-daemon-client.js +2 -2
- package/dist/lib/exe-daemon.js +50 -39
- package/dist/lib/hybrid-search.js +5 -5
- package/dist/lib/identity.js +2 -2
- package/dist/lib/messaging.js +11 -11
- package/dist/lib/reminders.js +3 -3
- package/dist/lib/schedules.js +5 -5
- package/dist/lib/session-registry.js +4 -4
- package/dist/lib/skill-learning.js +6 -6
- package/dist/lib/store.js +4 -4
- package/dist/lib/task-router.js +3 -3
- package/dist/lib/tasks.js +12 -12
- package/dist/lib/tmux-routing.js +10 -10
- package/dist/lib/tmux-transport.js +2 -1
- package/dist/lib/token-spend.js +3 -3
- package/dist/lib/transport.js +3 -2
- package/dist/mcp/register-tools.js +62 -62
- package/dist/mcp/server.js +63 -63
- package/dist/mcp/tools/complete-reminder.js +4 -4
- package/dist/mcp/tools/create-reminder.js +4 -4
- package/dist/mcp/tools/create-task.js +15 -15
- package/dist/mcp/tools/deactivate-behavior.js +7 -7
- package/dist/mcp/tools/list-reminders.js +4 -4
- package/dist/mcp/tools/list-tasks.js +14 -14
- package/dist/mcp/tools/send-message.js +13 -13
- package/dist/mcp/tools/update-task.js +13 -13
- package/dist/mcp-http-config-JZPO4B6K.js +29 -0
- package/dist/mcp-http-config-L6TEBZOW.js +29 -0
- package/dist/memory-cards-EIA3YLFA.js +180 -0
- package/dist/memory-cards-MDZGVJWJ.js +180 -0
- package/dist/memory-graph-extractor-BMZBK2LX.js +22 -0
- package/dist/memory-graph-extractor-U2Q7MTBZ.js +22 -0
- package/dist/memory-poisoning-defense-ORWGA4KK.js +224 -0
- package/dist/memory-poisoning-defense-ZY5P2OOG.js +224 -0
- package/dist/memory-queue-client-A2PMQVEU.js +16 -0
- package/dist/memory-reflection-35NUYL3Z.js +244 -0
- package/dist/memory-reflection-NHOC2FGF.js +244 -0
- package/dist/message-queue-client-L5VZ44IN.js +92 -0
- package/dist/notifications-7GGXNR42.js +47 -0
- package/dist/notifications-B2YCZD3T.js +47 -0
- package/dist/orchestration-events-7EQJF377.js +27 -0
- package/dist/orchestration-events-VJTAOA2R.js +27 -0
- package/dist/orchestrator-IAU2Y3K3.js +35 -0
- package/dist/orchestrator-YOM5D5EJ.js +35 -0
- package/dist/pipeline-router-ITQDOV2B.js +15 -0
- package/dist/pipeline-router-VYFAS3ZX.js +15 -0
- package/dist/plan-limits-OJQINDD3.js +28 -0
- package/dist/plan-limits-UWVCNA67.js +28 -0
- package/dist/project-boot-GSLIQJVS.js +299 -0
- package/dist/project-boot-NRU7RRED.js +299 -0
- package/dist/projection-worker-SKLKJJFA.js +1084 -0
- package/dist/projection-worker-XVOLBYQC.js +1084 -0
- package/dist/prospective-memory-JOKZL7QJ.js +232 -0
- package/dist/prospective-memory-WQSB2IPD.js +232 -0
- package/dist/reranker-5HJXM4K5.js +19 -0
- package/dist/reranker-Q7KD2VDL.js +19 -0
- package/dist/retrieval-health-BAKZOWX7.js +11 -0
- package/dist/retrieval-health-LXDMWIAZ.js +11 -0
- package/dist/review-polling-GBRSJ7X5.js +126 -0
- package/dist/review-polling-YDS35QTO.js +126 -0
- package/dist/runtime/index.js +13 -13
- package/dist/session-events-EJID2CZE.js +38 -0
- package/dist/session-events-UPXPYEA3.js +38 -0
- package/dist/session-kill-telemetry-7FP74BIM.js +31 -0
- package/dist/session-kill-telemetry-XLMNOBBQ.js +31 -0
- package/dist/session-scope-QCN23H6B.js +88 -0
- package/dist/session-scope-ZR2W2EDF.js +88 -0
- package/dist/setup-wizard-7H4CE5UL.js +12 -0
- package/dist/setup-wizard-MR3XA4BC.js +12 -0
- package/dist/skill-refinement-6UK4P4UQ.js +159 -0
- package/dist/skill-refinement-RYBLDKDP.js +159 -0
- package/dist/steward-gate-PSF4JQUC.js +15 -0
- package/dist/steward-gate-U2HQZ4LX.js +15 -0
- package/dist/task-enforcement-NL6WPS3T.js +506 -0
- package/dist/task-enforcement-RYWTWHQJ.js +506 -0
- package/dist/task-scope-43TBGXSP.js +37 -0
- package/dist/task-scope-BR4ZJLQT.js +37 -0
- package/dist/tasks-crud-AQLUDVES.js +79 -0
- package/dist/tasks-crud-LWTHIDHF.js +79 -0
- package/dist/tasks-notify-PZQMVQHI.js +40 -0
- package/dist/tasks-notify-U4QZ2FGV.js +40 -0
- package/dist/tasks-review-E3LQRBNB.js +49 -0
- package/dist/tasks-review-NIGU6K3L.js +49 -0
- package/dist/telemetry-upload-PQLC5A4D.js +741 -0
- package/dist/telemetry-upload-QOYSUDDH.js +741 -0
- package/dist/token-budget-OJGWYISJ.js +86 -0
- package/dist/token-budget-VMQLMHSU.js +86 -0
- package/dist/tool-capability-index-4M3BFQTU.js +10 -0
- package/dist/tool-telemetry-4YD2E6UU.js +17 -0
- package/dist/tool-telemetry-662N3S5Q.js +17 -0
- package/dist/tui/App.js +18 -18
- package/dist/tui-data-IIGF5XRY.js +260 -0
- package/dist/tui-data-W4INCXEA.js +260 -0
- package/dist/wiki-acl-KXXMRMIM.js +111 -0
- package/dist/wiki-acl-XSRBJSBD.js +111 -0
- package/dist/worker-gate-7GMM23JY.js +21 -0
- package/dist/worker-gate-F6LY67TM.js +21 -0
- package/dist/workflow-engine-G4JTWI5N.js +28 -0
- package/dist/workflow-engine-UHOVTA5Q.js +28 -0
- package/dist/worktree-OJMZ4RG4.js +28 -0
- package/dist/worktree-ZLF4MX6T.js +28 -0
- package/dist/worktree-sweep-5Z6V7MNJ.js +21 -0
- package/dist/worktree-sweep-M64OW2MU.js +21 -0
- package/package.json +2 -2
- package/release-notes.json +14 -14
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import {
|
|
2
|
+
initStore
|
|
3
|
+
} from "./chunk-NXCJWGAF.js";
|
|
4
|
+
import {
|
|
5
|
+
getClient,
|
|
6
|
+
isInitialized
|
|
7
|
+
} from "./chunk-IDJCLLJF.js";
|
|
8
|
+
|
|
9
|
+
// src/lib/schedules.ts
|
|
10
|
+
import crypto from "crypto";
|
|
11
|
+
import { execSync } from "child_process";
|
|
12
|
+
var CRON_FIELD = /^[\d*/,\-]+$/;
|
|
13
|
+
function isValidCron(cron) {
|
|
14
|
+
const fields = cron.trim().split(/\s+/);
|
|
15
|
+
if (fields.length !== 5) return false;
|
|
16
|
+
return fields.every((f) => CRON_FIELD.test(f));
|
|
17
|
+
}
|
|
18
|
+
var SAFE_ID = /^[a-zA-Z0-9_\-]+$/;
|
|
19
|
+
function isValidScheduleId(id) {
|
|
20
|
+
return SAFE_ID.test(id) && id.length <= 128;
|
|
21
|
+
}
|
|
22
|
+
async function ensureDb() {
|
|
23
|
+
if (!isInitialized()) {
|
|
24
|
+
await initStore();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function parseHumanCron(input) {
|
|
28
|
+
const s = input.toLowerCase().trim();
|
|
29
|
+
if (/^[\d*\/,-]+\s+[\d*\/,-]+\s+[\d*\/,-]+\s+[\d*\/,-]+\s+[\d*\/,-]+$/.test(s)) {
|
|
30
|
+
return s;
|
|
31
|
+
}
|
|
32
|
+
const dayMap = {
|
|
33
|
+
sunday: "0",
|
|
34
|
+
sun: "0",
|
|
35
|
+
monday: "1",
|
|
36
|
+
mon: "1",
|
|
37
|
+
tuesday: "2",
|
|
38
|
+
tue: "2",
|
|
39
|
+
wednesday: "3",
|
|
40
|
+
wed: "3",
|
|
41
|
+
thursday: "4",
|
|
42
|
+
thu: "4",
|
|
43
|
+
friday: "5",
|
|
44
|
+
fri: "5",
|
|
45
|
+
saturday: "6",
|
|
46
|
+
sat: "6"
|
|
47
|
+
};
|
|
48
|
+
const everyMatch = s.match(/every\s+(\d+)\s*([mh])/);
|
|
49
|
+
if (everyMatch) {
|
|
50
|
+
const n = everyMatch[1];
|
|
51
|
+
const unit = everyMatch[2];
|
|
52
|
+
if (unit === "m") return `*/${n} * * * *`;
|
|
53
|
+
if (unit === "h") return `0 */${n} * * *`;
|
|
54
|
+
}
|
|
55
|
+
let hour = -1;
|
|
56
|
+
let minute = 0;
|
|
57
|
+
if (/midnight/.test(s)) {
|
|
58
|
+
hour = 0;
|
|
59
|
+
} else if (/noon/.test(s)) {
|
|
60
|
+
hour = 12;
|
|
61
|
+
} else {
|
|
62
|
+
const timeMatch = s.match(/(\d{1,2})(?::(\d{2}))?\s*(am|pm)?/);
|
|
63
|
+
if (timeMatch) {
|
|
64
|
+
hour = parseInt(timeMatch[1], 10);
|
|
65
|
+
minute = timeMatch[2] ? parseInt(timeMatch[2], 10) : 0;
|
|
66
|
+
if (timeMatch[3] === "pm" && hour < 12) hour += 12;
|
|
67
|
+
if (timeMatch[3] === "am" && hour === 12) hour = 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (hour === -1) hour = 0;
|
|
71
|
+
let dow = "*";
|
|
72
|
+
if (/weekday|weekdays/.test(s)) {
|
|
73
|
+
dow = "1-5";
|
|
74
|
+
} else if (/weekend|weekends/.test(s)) {
|
|
75
|
+
dow = "0,6";
|
|
76
|
+
} else {
|
|
77
|
+
for (const [name, val] of Object.entries(dayMap)) {
|
|
78
|
+
if (s.includes(name)) {
|
|
79
|
+
dow = val;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return `${minute} ${hour} * * ${dow}`;
|
|
85
|
+
}
|
|
86
|
+
async function createSchedule(input) {
|
|
87
|
+
if (!isValidCron(input.cron)) {
|
|
88
|
+
throw new Error(`Invalid cron expression: ${input.cron}. Must be 5 fields with only digits, *, /, -, comma.`);
|
|
89
|
+
}
|
|
90
|
+
await ensureDb();
|
|
91
|
+
const client = getClient();
|
|
92
|
+
const id = crypto.randomUUID().slice(0, 8);
|
|
93
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
94
|
+
const prompt = input.prompt ?? input.description;
|
|
95
|
+
await client.execute({
|
|
96
|
+
sql: `INSERT INTO schedules (id, cron, description, job_type, prompt, assigned_to, project_name, active, use_crontab, created_at)
|
|
97
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, 1, ?, ?)`,
|
|
98
|
+
args: [
|
|
99
|
+
id,
|
|
100
|
+
input.cron,
|
|
101
|
+
input.description,
|
|
102
|
+
input.jobType ?? "report",
|
|
103
|
+
prompt,
|
|
104
|
+
input.assignedTo ?? null,
|
|
105
|
+
input.projectName ?? null,
|
|
106
|
+
input.useCrontab ? 1 : 0,
|
|
107
|
+
now
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
if (input.useCrontab) {
|
|
111
|
+
addToCrontab(id, input.cron, prompt, input.projectName);
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
id,
|
|
115
|
+
cron: input.cron,
|
|
116
|
+
description: input.description,
|
|
117
|
+
jobType: input.jobType ?? "report",
|
|
118
|
+
prompt,
|
|
119
|
+
assignedTo: input.assignedTo,
|
|
120
|
+
projectName: input.projectName,
|
|
121
|
+
active: true,
|
|
122
|
+
useCrontab: input.useCrontab ?? false,
|
|
123
|
+
createdAt: now
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async function listSchedules(activeOnly = true) {
|
|
127
|
+
await ensureDb();
|
|
128
|
+
const client = getClient();
|
|
129
|
+
const sql = activeOnly ? "SELECT * FROM schedules WHERE active = 1 ORDER BY created_at ASC" : "SELECT * FROM schedules ORDER BY created_at ASC";
|
|
130
|
+
const result = await client.execute({ sql, args: [] });
|
|
131
|
+
return result.rows.map((row) => ({
|
|
132
|
+
id: String(row.id),
|
|
133
|
+
cron: String(row.cron),
|
|
134
|
+
description: String(row.description),
|
|
135
|
+
jobType: String(row.job_type),
|
|
136
|
+
prompt: row.prompt ? String(row.prompt) : void 0,
|
|
137
|
+
assignedTo: row.assigned_to ? String(row.assigned_to) : void 0,
|
|
138
|
+
projectName: row.project_name ? String(row.project_name) : void 0,
|
|
139
|
+
active: Number(row.active) === 1,
|
|
140
|
+
useCrontab: Number(row.use_crontab) === 1,
|
|
141
|
+
createdAt: String(row.created_at)
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
async function deleteSchedule(id) {
|
|
145
|
+
await ensureDb();
|
|
146
|
+
const client = getClient();
|
|
147
|
+
const existing = await client.execute({
|
|
148
|
+
sql: "SELECT use_crontab FROM schedules WHERE id = ?",
|
|
149
|
+
args: [id]
|
|
150
|
+
});
|
|
151
|
+
if (existing.rows.length === 0) return false;
|
|
152
|
+
const usesCrontab = Number(existing.rows[0].use_crontab) === 1;
|
|
153
|
+
await client.execute({
|
|
154
|
+
sql: "DELETE FROM schedules WHERE id = ?",
|
|
155
|
+
args: [id]
|
|
156
|
+
});
|
|
157
|
+
if (usesCrontab) {
|
|
158
|
+
removeFromCrontab(id);
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
function addToCrontab(id, cron, prompt, projectDir) {
|
|
163
|
+
if (!isValidCron(cron)) {
|
|
164
|
+
throw new Error(`Invalid cron expression: ${cron}`);
|
|
165
|
+
}
|
|
166
|
+
if (!isValidScheduleId(id)) {
|
|
167
|
+
throw new Error(`Invalid schedule ID: ${id}`);
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
const cwd = projectDir ? `cd ${JSON.stringify(projectDir)} && ` : "";
|
|
171
|
+
const escapedPrompt = prompt.replace(/"/g, '\\"');
|
|
172
|
+
const entry = `${cron} ${cwd}claude -p --dangerously-skip-permissions "${escapedPrompt}" # exe-schedule:${id}`;
|
|
173
|
+
execSync(
|
|
174
|
+
`(crontab -l 2>/dev/null; echo ${JSON.stringify(entry)}) | crontab -`,
|
|
175
|
+
{ timeout: 5e3, stdio: "ignore" }
|
|
176
|
+
);
|
|
177
|
+
} catch (err) {
|
|
178
|
+
if (err instanceof Error && err.message.startsWith("Invalid")) throw err;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function removeFromCrontab(id) {
|
|
182
|
+
if (!isValidScheduleId(id)) return;
|
|
183
|
+
try {
|
|
184
|
+
execSync(
|
|
185
|
+
`crontab -l 2>/dev/null | grep -v "exe-schedule:${id}" | crontab -`,
|
|
186
|
+
{ timeout: 5e3, stdio: "ignore" }
|
|
187
|
+
);
|
|
188
|
+
} catch {
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export {
|
|
193
|
+
parseHumanCron,
|
|
194
|
+
createSchedule,
|
|
195
|
+
listSchedules,
|
|
196
|
+
deleteSchedule
|
|
197
|
+
};
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PLATFORM_PROCEDURE_TITLES
|
|
3
|
+
} from "./chunk-VUH67PT4.js";
|
|
4
|
+
import {
|
|
5
|
+
isGhostBehaviorRow
|
|
6
|
+
} from "./chunk-NAKIQODV.js";
|
|
7
|
+
import {
|
|
8
|
+
getClient,
|
|
9
|
+
getIdentity,
|
|
10
|
+
listIdentities,
|
|
11
|
+
updateIdentity
|
|
12
|
+
} from "./chunk-IDJCLLJF.js";
|
|
13
|
+
import {
|
|
14
|
+
atomicWriteJsonSync
|
|
15
|
+
} from "./chunk-LYH5HE24.js";
|
|
16
|
+
|
|
17
|
+
// src/lib/orchestration-package.ts
|
|
18
|
+
import { randomUUID } from "crypto";
|
|
19
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync } from "fs";
|
|
20
|
+
import os from "os";
|
|
21
|
+
import path from "path";
|
|
22
|
+
var PACKAGE_VERSION = "1.0";
|
|
23
|
+
var ROSTER_FILENAME = "exe-employees.json";
|
|
24
|
+
var ROSTER_BACKUP_FILENAME = "exe-employees.json.bak";
|
|
25
|
+
var EXE_OS_DIRNAME = ".exe-os";
|
|
26
|
+
var DEFAULT_BEHAVIOR_PRIORITY = "p1";
|
|
27
|
+
var DEFAULT_PROCEDURE_PRIORITY = "p0";
|
|
28
|
+
var DEFAULT_IDENTITY_UPDATED_BY = "orchestration-import";
|
|
29
|
+
function ensureObject(value, label) {
|
|
30
|
+
if (value == null || Array.isArray(value) || typeof value !== "object") {
|
|
31
|
+
throw new Error(`${label} must be an object`);
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
function ensureString(value, label) {
|
|
36
|
+
if (typeof value !== "string") {
|
|
37
|
+
throw new Error(`${label} must be a string`);
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
function ensureOptionalString(value, label) {
|
|
42
|
+
if (value == null) return void 0;
|
|
43
|
+
return ensureString(value, label);
|
|
44
|
+
}
|
|
45
|
+
function ensureNullableString(value, label) {
|
|
46
|
+
if (value == null) return null;
|
|
47
|
+
return ensureString(value, label);
|
|
48
|
+
}
|
|
49
|
+
function ensurePriority(value, label, fallback) {
|
|
50
|
+
if (value == null) return fallback;
|
|
51
|
+
if (value === "p0" || value === "p1" || value === "p2") {
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
throw new Error(`${label} must be one of: p0, p1, p2`);
|
|
55
|
+
}
|
|
56
|
+
function validateRosterEntry(value, index) {
|
|
57
|
+
const record = ensureObject(value, `roster[${index}]`);
|
|
58
|
+
return {
|
|
59
|
+
name: ensureString(record.name, `roster[${index}].name`),
|
|
60
|
+
role: ensureString(record.role, `roster[${index}].role`),
|
|
61
|
+
systemPrompt: ensureString(record.systemPrompt, `roster[${index}].systemPrompt`),
|
|
62
|
+
createdAt: typeof record.createdAt === "string" ? record.createdAt : "",
|
|
63
|
+
templateName: ensureOptionalString(record.templateName, `roster[${index}].templateName`),
|
|
64
|
+
templateVersion: typeof record.templateVersion === "number" ? record.templateVersion : void 0
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function validateBehaviorEntry(value, index) {
|
|
68
|
+
const record = ensureObject(value, `behaviors[${index}]`);
|
|
69
|
+
return {
|
|
70
|
+
agent_id: ensureString(record.agent_id, `behaviors[${index}].agent_id`),
|
|
71
|
+
project_name: ensureNullableString(record.project_name, `behaviors[${index}].project_name`),
|
|
72
|
+
domain: ensureNullableString(record.domain, `behaviors[${index}].domain`),
|
|
73
|
+
content: ensureString(record.content, `behaviors[${index}].content`),
|
|
74
|
+
priority: ensurePriority(record.priority, `behaviors[${index}].priority`, DEFAULT_BEHAVIOR_PRIORITY)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function validateProcedureEntry(value, index) {
|
|
78
|
+
const record = ensureObject(value, `procedures[${index}]`);
|
|
79
|
+
return {
|
|
80
|
+
title: ensureString(record.title, `procedures[${index}].title`),
|
|
81
|
+
content: ensureString(record.content, `procedures[${index}].content`),
|
|
82
|
+
priority: ensurePriority(record.priority, `procedures[${index}].priority`, DEFAULT_PROCEDURE_PRIORITY),
|
|
83
|
+
domain: ensureNullableString(record.domain, `procedures[${index}].domain`)
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function getRosterPath() {
|
|
87
|
+
return path.join(os.homedir(), EXE_OS_DIRNAME, ROSTER_FILENAME);
|
|
88
|
+
}
|
|
89
|
+
function getBackupPath() {
|
|
90
|
+
return path.join(os.homedir(), EXE_OS_DIRNAME, ROSTER_BACKUP_FILENAME);
|
|
91
|
+
}
|
|
92
|
+
function readRosterFile() {
|
|
93
|
+
const rosterPath = getRosterPath();
|
|
94
|
+
if (!existsSync(rosterPath)) return [];
|
|
95
|
+
const raw = readFileSync(rosterPath, "utf-8");
|
|
96
|
+
const parsed = JSON.parse(raw);
|
|
97
|
+
if (!Array.isArray(parsed)) {
|
|
98
|
+
throw new Error("Roster file must contain a JSON array");
|
|
99
|
+
}
|
|
100
|
+
return parsed.map((entry, index) => validateRosterEntry(entry, index));
|
|
101
|
+
}
|
|
102
|
+
function writeRosterFile(roster) {
|
|
103
|
+
if (roster.length === 0) {
|
|
104
|
+
throw new Error("Refusing to write empty roster \u2014 this would delete all employees");
|
|
105
|
+
}
|
|
106
|
+
const rosterPath = getRosterPath();
|
|
107
|
+
mkdirSync(path.dirname(rosterPath), { recursive: true });
|
|
108
|
+
if (existsSync(rosterPath)) {
|
|
109
|
+
const currentRoster = readRosterFile();
|
|
110
|
+
if (roster.length < currentRoster.length) {
|
|
111
|
+
throw new Error(
|
|
112
|
+
`Refusing to write roster with ${roster.length} entries \u2014 current roster has ${currentRoster.length}. Import would delete ${currentRoster.length - roster.length} employee(s). Use merge strategy instead, or add the missing entries to the package.`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
copyFileSync(rosterPath, getBackupPath());
|
|
116
|
+
}
|
|
117
|
+
atomicWriteJsonSync(rosterPath, roster);
|
|
118
|
+
}
|
|
119
|
+
function buildImportedRosterEntries(roster, timestamp) {
|
|
120
|
+
return roster.map((entry) => ({
|
|
121
|
+
name: entry.name,
|
|
122
|
+
role: entry.role,
|
|
123
|
+
systemPrompt: entry.systemPrompt,
|
|
124
|
+
createdAt: timestamp,
|
|
125
|
+
...entry.templateName != null ? { templateName: entry.templateName } : {},
|
|
126
|
+
...entry.templateVersion != null ? { templateVersion: entry.templateVersion } : {}
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
async function insertBehaviors(behaviors, timestamp) {
|
|
130
|
+
const client = getClient();
|
|
131
|
+
let inserted = 0;
|
|
132
|
+
for (const behavior of behaviors) {
|
|
133
|
+
if (isGhostBehaviorRow({ id: "import", content: behavior.content, agent_id: behavior.agent_id })) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
await client.execute({
|
|
137
|
+
sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, priority, content, active, created_at, updated_at)
|
|
138
|
+
VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?)`,
|
|
139
|
+
args: [
|
|
140
|
+
randomUUID(),
|
|
141
|
+
behavior.agent_id,
|
|
142
|
+
behavior.project_name,
|
|
143
|
+
behavior.domain,
|
|
144
|
+
behavior.priority,
|
|
145
|
+
behavior.content,
|
|
146
|
+
timestamp,
|
|
147
|
+
timestamp
|
|
148
|
+
]
|
|
149
|
+
});
|
|
150
|
+
inserted++;
|
|
151
|
+
}
|
|
152
|
+
return inserted;
|
|
153
|
+
}
|
|
154
|
+
async function insertProcedures(procedures, timestamp, options) {
|
|
155
|
+
const client = getClient();
|
|
156
|
+
const skipTitles = options?.skipTitles ?? /* @__PURE__ */ new Set();
|
|
157
|
+
let inserted = 0;
|
|
158
|
+
try {
|
|
159
|
+
const existing = await client.execute("SELECT title FROM company_procedures WHERE active = 1");
|
|
160
|
+
for (const r of existing.rows) {
|
|
161
|
+
if (r.title) skipTitles.add(r.title);
|
|
162
|
+
}
|
|
163
|
+
} catch {
|
|
164
|
+
}
|
|
165
|
+
for (const procedure of procedures) {
|
|
166
|
+
if (!procedure.title?.trim() || !procedure.content?.trim()) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (skipTitles.has(procedure.title) || PLATFORM_PROCEDURE_TITLES.has(procedure.title)) {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
await client.execute({
|
|
173
|
+
sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
|
|
174
|
+
VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
|
|
175
|
+
args: [
|
|
176
|
+
randomUUID(),
|
|
177
|
+
procedure.title,
|
|
178
|
+
procedure.content,
|
|
179
|
+
procedure.priority,
|
|
180
|
+
procedure.domain,
|
|
181
|
+
timestamp,
|
|
182
|
+
timestamp
|
|
183
|
+
]
|
|
184
|
+
});
|
|
185
|
+
skipTitles.add(procedure.title);
|
|
186
|
+
inserted += 1;
|
|
187
|
+
}
|
|
188
|
+
return inserted;
|
|
189
|
+
}
|
|
190
|
+
async function replaceBehaviorsAndProcedures(behaviors, procedures, timestamp) {
|
|
191
|
+
const client = getClient();
|
|
192
|
+
const existingBehaviors = await client.execute({
|
|
193
|
+
sql: "SELECT agent_id, content FROM behaviors WHERE active = 1",
|
|
194
|
+
args: []
|
|
195
|
+
});
|
|
196
|
+
const existingBehaviorKeys = new Set(
|
|
197
|
+
existingBehaviors.rows.map((row) => `${String(row.agent_id)}::${String(row.content)}`)
|
|
198
|
+
);
|
|
199
|
+
const newBehaviors = behaviors.filter(
|
|
200
|
+
(b) => !existingBehaviorKeys.has(`${b.agent_id}::${b.content}`)
|
|
201
|
+
);
|
|
202
|
+
const existingProcedureTitles = await getActiveProcedureTitles();
|
|
203
|
+
return {
|
|
204
|
+
behaviors: await insertBehaviors(newBehaviors, timestamp),
|
|
205
|
+
procedures: await insertProcedures(procedures, timestamp, { skipTitles: existingProcedureTitles })
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
async function mergeRosterEntries(importedRoster, timestamp) {
|
|
209
|
+
const currentRoster = readRosterFile();
|
|
210
|
+
const existingNames = new Set(currentRoster.map((entry) => entry.name.toLowerCase()));
|
|
211
|
+
const additions = buildImportedRosterEntries(
|
|
212
|
+
importedRoster.filter((entry) => !existingNames.has(entry.name.toLowerCase())),
|
|
213
|
+
timestamp
|
|
214
|
+
);
|
|
215
|
+
if (additions.length > 0) {
|
|
216
|
+
writeRosterFile([...currentRoster, ...additions]);
|
|
217
|
+
}
|
|
218
|
+
return additions.length;
|
|
219
|
+
}
|
|
220
|
+
async function replaceRosterEntries(importedRoster, timestamp) {
|
|
221
|
+
const currentRoster = readRosterFile();
|
|
222
|
+
const importedByName = new Map(
|
|
223
|
+
buildImportedRosterEntries(importedRoster, timestamp).map((entry) => [entry.name.toLowerCase(), entry])
|
|
224
|
+
);
|
|
225
|
+
const merged = currentRoster.map((existing) => {
|
|
226
|
+
const imported = importedByName.get(existing.name.toLowerCase());
|
|
227
|
+
if (imported) {
|
|
228
|
+
importedByName.delete(existing.name.toLowerCase());
|
|
229
|
+
return imported;
|
|
230
|
+
}
|
|
231
|
+
return existing;
|
|
232
|
+
});
|
|
233
|
+
for (const newEntry of importedByName.values()) {
|
|
234
|
+
merged.push(newEntry);
|
|
235
|
+
}
|
|
236
|
+
writeRosterFile(merged);
|
|
237
|
+
return importedRoster.length;
|
|
238
|
+
}
|
|
239
|
+
async function importIdentities(identities, updatedBy) {
|
|
240
|
+
const entries = Object.entries(identities);
|
|
241
|
+
let imported = 0;
|
|
242
|
+
for (const [agentId, content] of entries) {
|
|
243
|
+
const existing = getIdentity(agentId);
|
|
244
|
+
if (existing?.raw) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
await updateIdentity(agentId, content, updatedBy);
|
|
248
|
+
imported += 1;
|
|
249
|
+
}
|
|
250
|
+
return imported;
|
|
251
|
+
}
|
|
252
|
+
async function getActiveProcedureTitles() {
|
|
253
|
+
const client = getClient();
|
|
254
|
+
const result = await client.execute({
|
|
255
|
+
sql: "SELECT title FROM company_procedures WHERE active = 1",
|
|
256
|
+
args: []
|
|
257
|
+
});
|
|
258
|
+
return new Set(result.rows.map((row) => String(row.title)));
|
|
259
|
+
}
|
|
260
|
+
async function exportOrchestration(createdBy) {
|
|
261
|
+
const client = getClient();
|
|
262
|
+
const roster = readRosterFile().map((entry) => ({
|
|
263
|
+
...entry,
|
|
264
|
+
createdAt: ""
|
|
265
|
+
}));
|
|
266
|
+
const identities = {};
|
|
267
|
+
for (const identitySummary of listIdentities()) {
|
|
268
|
+
const identity = getIdentity(identitySummary.agentId);
|
|
269
|
+
if (identity?.raw) {
|
|
270
|
+
identities[identitySummary.agentId] = identity.raw;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const behaviorResult = await client.execute({
|
|
274
|
+
sql: "SELECT agent_id, project_name, domain, content, priority FROM behaviors WHERE active = 1",
|
|
275
|
+
args: []
|
|
276
|
+
});
|
|
277
|
+
const procedureResult = await client.execute({
|
|
278
|
+
sql: "SELECT title, content, priority, domain FROM company_procedures WHERE active = 1",
|
|
279
|
+
args: []
|
|
280
|
+
});
|
|
281
|
+
const behaviors = behaviorResult.rows.map((row) => ({
|
|
282
|
+
agent_id: String(row.agent_id),
|
|
283
|
+
project_name: row.project_name == null ? null : String(row.project_name),
|
|
284
|
+
domain: row.domain == null ? null : String(row.domain),
|
|
285
|
+
content: String(row.content),
|
|
286
|
+
priority: ensurePriority(row.priority, "behaviors.priority", DEFAULT_BEHAVIOR_PRIORITY)
|
|
287
|
+
}));
|
|
288
|
+
const procedures = procedureResult.rows.map((row) => ({
|
|
289
|
+
title: String(row.title),
|
|
290
|
+
content: String(row.content),
|
|
291
|
+
priority: ensurePriority(row.priority, "procedures.priority", DEFAULT_PROCEDURE_PRIORITY),
|
|
292
|
+
domain: row.domain == null ? null : String(row.domain)
|
|
293
|
+
})).filter((procedure) => !PLATFORM_PROCEDURE_TITLES.has(procedure.title));
|
|
294
|
+
return {
|
|
295
|
+
version: PACKAGE_VERSION,
|
|
296
|
+
created_by: createdBy,
|
|
297
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
298
|
+
roster,
|
|
299
|
+
identities,
|
|
300
|
+
behaviors,
|
|
301
|
+
procedures
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
async function importOrchestration(pkg, strategy) {
|
|
305
|
+
const validated = validatePackage(pkg);
|
|
306
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
307
|
+
const updatedBy = validated.created_by || DEFAULT_IDENTITY_UPDATED_BY;
|
|
308
|
+
const rosterCount = strategy === "replace" ? await replaceRosterEntries(validated.roster, timestamp) : await mergeRosterEntries(validated.roster, timestamp);
|
|
309
|
+
const identityCount = await importIdentities(validated.identities, updatedBy);
|
|
310
|
+
if (strategy === "replace") {
|
|
311
|
+
const replaced = await replaceBehaviorsAndProcedures(
|
|
312
|
+
validated.behaviors,
|
|
313
|
+
validated.procedures,
|
|
314
|
+
timestamp
|
|
315
|
+
);
|
|
316
|
+
return {
|
|
317
|
+
imported: {
|
|
318
|
+
roster: rosterCount,
|
|
319
|
+
identities: identityCount,
|
|
320
|
+
behaviors: replaced.behaviors,
|
|
321
|
+
procedures: replaced.procedures
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
const existingProcedureTitles = await getActiveProcedureTitles();
|
|
326
|
+
const behaviorCount = await insertBehaviors(validated.behaviors, timestamp);
|
|
327
|
+
const procedureCount = await insertProcedures(
|
|
328
|
+
validated.procedures,
|
|
329
|
+
timestamp,
|
|
330
|
+
{ skipTitles: existingProcedureTitles }
|
|
331
|
+
);
|
|
332
|
+
return {
|
|
333
|
+
imported: {
|
|
334
|
+
roster: rosterCount,
|
|
335
|
+
identities: identityCount,
|
|
336
|
+
behaviors: behaviorCount,
|
|
337
|
+
procedures: procedureCount
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
function validatePackage(data) {
|
|
342
|
+
const record = ensureObject(data, "package");
|
|
343
|
+
const version = ensureString(record.version, "version");
|
|
344
|
+
if (version !== PACKAGE_VERSION) {
|
|
345
|
+
throw new Error(`Unsupported orchestration package version: ${version}`);
|
|
346
|
+
}
|
|
347
|
+
if (!Array.isArray(record.roster)) {
|
|
348
|
+
throw new Error("roster is required and must be an array");
|
|
349
|
+
}
|
|
350
|
+
if (record.identities == null || Array.isArray(record.identities) || typeof record.identities !== "object") {
|
|
351
|
+
throw new Error("identities is required and must be an object");
|
|
352
|
+
}
|
|
353
|
+
if (!Array.isArray(record.behaviors)) {
|
|
354
|
+
throw new Error("behaviors is required and must be an array");
|
|
355
|
+
}
|
|
356
|
+
if (!Array.isArray(record.procedures)) {
|
|
357
|
+
throw new Error("procedures is required and must be an array");
|
|
358
|
+
}
|
|
359
|
+
const identities = Object.entries(record.identities).reduce(
|
|
360
|
+
(acc, [agentId, content]) => {
|
|
361
|
+
acc[agentId] = ensureString(content, `identities.${agentId}`);
|
|
362
|
+
return acc;
|
|
363
|
+
},
|
|
364
|
+
{}
|
|
365
|
+
);
|
|
366
|
+
return {
|
|
367
|
+
version: PACKAGE_VERSION,
|
|
368
|
+
created_by: ensureString(record.created_by, "created_by"),
|
|
369
|
+
created_at: ensureString(record.created_at, "created_at"),
|
|
370
|
+
roster: record.roster.map((entry, index) => validateRosterEntry(entry, index)),
|
|
371
|
+
identities,
|
|
372
|
+
behaviors: record.behaviors.map((entry, index) => validateBehaviorEntry(entry, index)),
|
|
373
|
+
procedures: record.procedures.map((entry, index) => validateProcedureEntry(entry, index))
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export {
|
|
378
|
+
exportOrchestration,
|
|
379
|
+
importOrchestration,
|
|
380
|
+
validatePackage
|
|
381
|
+
};
|