xkzoom 1.5.4 → 1.5.6
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/README.md +65 -0
- package/dist/{chunk-YPKHMAO4.mjs → chunk-22VRM3T3.mjs} +1 -1
- package/dist/{chunk-XL3MUGFG.mjs → chunk-2B3A3C2V.mjs} +1 -1
- package/dist/{chunk-UQLGVSQH.mjs → chunk-2F65KBU2.mjs} +8 -9
- package/dist/chunk-2L4VMCM2.mjs +15 -0
- package/dist/{chunk-WQSQXDUL.mjs → chunk-2LN3ODBA.mjs} +1 -1
- package/dist/{chunk-OBYPZT2S.mjs → chunk-2YB6BHIB.mjs} +9 -9
- package/dist/chunk-35SKU3FL.mjs +279 -0
- package/dist/{chunk-PETWGCGB.mjs → chunk-3JHD7MGZ.mjs} +2 -2
- package/dist/{chunk-PW3ULDNL.mjs → chunk-3QE7GUJC.mjs} +1 -1
- package/dist/{chunk-JI67TW4E.mjs → chunk-4XJFA7V3.mjs} +1 -1
- package/dist/{chunk-CQUISJWG.mjs → chunk-5G3UUQ36.mjs} +2 -2
- package/dist/{chunk-HYSOWPIC.mjs → chunk-6KCPL45H.mjs} +5 -5
- package/dist/{chunk-2IQAT3PE.mjs → chunk-6OY3GOUH.mjs} +6 -6
- package/dist/{chunk-LBZCBBHU.mjs → chunk-72IPGTJZ.mjs} +1 -1
- package/dist/{chunk-TVH4LII3.mjs → chunk-74S3DUNZ.mjs} +1 -1
- package/dist/{chunk-MPGMU75K.mjs → chunk-7C7HREZO.mjs} +12 -12
- package/dist/{chunk-BFSOQ5IG.mjs → chunk-7HQEB7IJ.mjs} +3 -3
- package/dist/{chunk-3VA3YDYL.mjs → chunk-7TKZKTS5.mjs} +1 -1
- package/dist/{chunk-M3ISDSQP.mjs → chunk-A4BZZNPW.mjs} +5 -5
- package/dist/{chunk-BJ6YI2DJ.mjs → chunk-AEE3DM6S.mjs} +1 -1
- package/dist/{chunk-4JXTPCOE.mjs → chunk-ANGNUW6F.mjs} +5 -5
- package/dist/{chunk-GZZ7KO57.mjs → chunk-BJFTC4GW.mjs} +21 -1
- package/dist/{chunk-GYZ4IXUD.mjs → chunk-CLN4OVFM.mjs} +3 -6
- package/dist/{chunk-3KJHUTOO.mjs → chunk-CLVSQ3FG.mjs} +2 -2
- package/dist/{chunk-IKQ7CLX3.mjs → chunk-CSKP6E6Y.mjs} +2 -2
- package/dist/{chunk-LWCO2YNI.mjs → chunk-CVWDLRQI.mjs} +1 -1
- package/dist/{chunk-FG6QCRVN.mjs → chunk-D4TNMY2O.mjs} +2 -2
- package/dist/{chunk-FLVJABFP.mjs → chunk-DODTDJSF.mjs} +10 -8
- package/dist/{chunk-MWRQORKQ.mjs → chunk-E36MAP7Y.mjs} +1 -1
- package/dist/{chunk-CFZVBILR.mjs → chunk-EHL345OC.mjs} +4 -4
- package/dist/chunk-F3Y7WDC6.mjs +108 -0
- package/dist/{chunk-Q33JD64H.mjs → chunk-FCK6QFJB.mjs} +1 -1
- package/dist/{chunk-3ZH273T7.mjs → chunk-FEEEY457.mjs} +71 -55
- package/dist/{chunk-MDZUWIBH.mjs → chunk-G3E2E6DD.mjs} +38 -38
- package/dist/{chunk-WXELBVXY.mjs → chunk-GC2H3KNZ.mjs} +1 -1
- package/dist/{chunk-5SE4JOKE.mjs → chunk-GHWAAAG6.mjs} +309 -262
- package/dist/{chunk-5YEFG7BF.mjs → chunk-GNDVHDPO.mjs} +52 -52
- package/dist/chunk-H4NINXMV.mjs +95 -0
- package/dist/{chunk-TQBVFKCT.mjs → chunk-H6W42R46.mjs} +194 -154
- package/dist/chunk-H7ILBOZU.mjs +48 -0
- package/dist/{chunk-7LEEVP5O.mjs → chunk-H7QNACAJ.mjs} +12 -12
- package/dist/chunk-HCYIE2PR.mjs +130 -0
- package/dist/{chunk-E2TTUY6R.mjs → chunk-HHPHIVCC.mjs} +11 -11
- package/dist/{chunk-P262PAGZ.mjs → chunk-HLYVEYML.mjs} +15 -2
- package/dist/{chunk-GZJMFCRG.mjs → chunk-HNYI45WM.mjs} +23 -4
- package/dist/{chunk-JFFBD5TV.mjs → chunk-HOII5XBJ.mjs} +17 -17
- package/dist/{chunk-T23H5D4O.mjs → chunk-HPZG5VVI.mjs} +3 -9
- package/dist/chunk-HQHICFPO.mjs +58 -0
- package/dist/{chunk-DRY7AJMM.mjs → chunk-HQPA2MV5.mjs} +7 -7
- package/dist/{chunk-NJAPWQ4D.mjs → chunk-ICKBF7KF.mjs} +2 -60
- package/dist/{chunk-HAI7DJD2.mjs → chunk-IEF2AMNW.mjs} +7 -7
- package/dist/{chunk-VIZQURO5.mjs → chunk-IGJFAE72.mjs} +9 -9
- package/dist/{chunk-IT2GAHAL.mjs → chunk-IHMPR5HT.mjs} +1 -1
- package/dist/{chunk-PJKLQF3K.mjs → chunk-INFZEMQK.mjs} +1 -1
- package/dist/{chunk-MKYCBV3H.mjs → chunk-J4FQVXEA.mjs} +7 -7
- package/dist/{chunk-27BXVTXH.mjs → chunk-JN5EMEXS.mjs} +1 -1
- package/dist/{chunk-4WWT6OC2.mjs → chunk-JTKSYLZE.mjs} +26 -48
- package/dist/{chunk-ZTKJR7OC.mjs → chunk-K5IQLMJQ.mjs} +4 -4
- package/dist/{chunk-GIAML5K5.mjs → chunk-K5JMXCH5.mjs} +1 -1
- package/dist/{chunk-JJKRD5DL.mjs → chunk-KBEY4ZQV.mjs} +4 -4
- package/dist/{chunk-EL6TOIFZ.mjs → chunk-KHQPC6I7.mjs} +1 -16
- package/dist/{chunk-VNEPNUBZ.mjs → chunk-L3PV2ZNB.mjs} +15 -15
- package/dist/{chunk-MQKREMOB.mjs → chunk-L7N2B4LX.mjs} +8 -8
- package/dist/{chunk-PS6X3CND.mjs → chunk-LKSRZTSL.mjs} +1 -0
- package/dist/{chunk-DCSERRXG.mjs → chunk-LNPOTNGJ.mjs} +1 -1
- package/dist/chunk-LOMDPHVQ.mjs +42 -0
- package/dist/chunk-LQHI5VK2.mjs +26 -0
- package/dist/{chunk-J5AXFEDQ.mjs → chunk-LTTSUVF5.mjs} +52 -52
- package/dist/{chunk-LESS4N25.mjs → chunk-LV3CI5A4.mjs} +5 -5
- package/dist/{chunk-JG3K4N5B.mjs → chunk-M3E2R3PT.mjs} +1 -1
- package/dist/{chunk-WPMJCKI2.mjs → chunk-M7DB4RAC.mjs} +9 -9
- package/dist/{chunk-COYZO24J.mjs → chunk-MCD5TOFD.mjs} +1 -1
- package/dist/{chunk-AP4WVS6L.mjs → chunk-MCJPAZBQ.mjs} +1 -1
- package/dist/{chunk-T6XDJ2QQ.mjs → chunk-MGIGU4G6.mjs} +119 -18
- package/dist/{chunk-ZMQ3UOGP.mjs → chunk-MMWLRPKT.mjs} +13 -1
- package/dist/{chunk-NIU6GWKB.mjs → chunk-MNLMVNF5.mjs} +5 -5
- package/dist/{chunk-W75Z6CZR.mjs → chunk-MXKSS63B.mjs} +2 -2
- package/dist/{chunk-TADSGGK2.mjs → chunk-N4X2MAF2.mjs} +14 -28
- package/dist/{chunk-E7BFLHLM.mjs → chunk-NDPDPELV.mjs} +1 -16
- package/dist/{chunk-24GJWXMG.mjs → chunk-NI2PDCVA.mjs} +3 -3
- package/dist/{chunk-BSG6WLML.mjs → chunk-NI4N35JN.mjs} +1 -1
- package/dist/{chunk-Z2JNJLJM.mjs → chunk-NLUF66E7.mjs} +1 -1
- package/dist/{chunk-RKZ56GST.mjs → chunk-NRPE77A3.mjs} +2 -2
- package/dist/{chunk-76TKUYY3.mjs → chunk-NTVWS2MO.mjs} +6 -6
- package/dist/{chunk-YYDDQEY4.mjs → chunk-NV7SYEH7.mjs} +2 -2
- package/dist/{chunk-6W4W5JLG.mjs → chunk-NXVXMXL5.mjs} +3 -3
- package/dist/{chunk-PINXXWFJ.mjs → chunk-OGT25PYJ.mjs} +1 -1
- package/dist/{chunk-3STOFADV.mjs → chunk-OHCBAEML.mjs} +1 -0
- package/dist/{chunk-L252ASZW.mjs → chunk-OPTSEYTI.mjs} +1 -1
- package/dist/{chunk-B4YKXZ5W.mjs → chunk-OQMIECO2.mjs} +1 -1
- package/dist/{chunk-D3N7EHB2.mjs → chunk-PH5QACOX.mjs} +19 -19
- package/dist/{chunk-6MOIFLPP.mjs → chunk-PKJLFQRF.mjs} +1 -1
- package/dist/{chunk-M5IU6U3O.mjs → chunk-POOU2U4R.mjs} +2 -2
- package/dist/{chunk-IGDJGBAI.mjs → chunk-PPMT66BN.mjs} +3 -3
- package/dist/{chunk-RZOILUDC.mjs → chunk-PSZPHCUP.mjs} +1 -1
- package/dist/{chunk-MXXTDG5V.mjs → chunk-PVSCARHF.mjs} +1 -1
- package/dist/chunk-PW6NSDMI.mjs +117 -0
- package/dist/{chunk-NHICONJ3.mjs → chunk-PZAMMLMJ.mjs} +3 -3
- package/dist/{chunk-IDQ5B572.mjs → chunk-QDN74R5G.mjs} +5 -5
- package/dist/{chunk-VWAUDB4X.mjs → chunk-QHIZRYTO.mjs} +2 -2
- package/dist/{chunk-2DR5RT3I.mjs → chunk-QITZ7SAD.mjs} +499 -943
- package/dist/{chunk-N2CMVW47.mjs → chunk-QRHBGABQ.mjs} +7 -3
- package/dist/{chunk-F35EHL5U.mjs → chunk-RM6GZ2SF.mjs} +7 -7
- package/dist/{chunk-JXDHNASC.mjs → chunk-RUMRGCYN.mjs} +85 -42
- package/dist/{chunk-K7RZQIPZ.mjs → chunk-S54MBJWY.mjs} +6 -4
- package/dist/{chunk-MBOWNG3A.mjs → chunk-S573TMN6.mjs} +2 -2
- package/dist/{chunk-UFV3WER4.mjs → chunk-SJ5LNKAH.mjs} +1 -1
- package/dist/chunk-SJWQGIQU.mjs +99 -0
- package/dist/{chunk-KWQEFCOY.mjs → chunk-SMHFMHQ2.mjs} +1 -1
- package/dist/{chunk-LGNLS7ZN.mjs → chunk-SPUVJNKO.mjs} +2 -2
- package/dist/{chunk-JBKRS62W.mjs → chunk-T3EJW65E.mjs} +6 -6
- package/dist/{chunk-6ZVXCJTG.mjs → chunk-TBLUKDLO.mjs} +91 -1
- package/dist/{chunk-76MFE24I.mjs → chunk-TKZWE5DB.mjs} +1 -1
- package/dist/{chunk-3CPVI6Y2.mjs → chunk-TRSW7QJW.mjs} +1 -1
- package/dist/{chunk-UXEZFEB3.mjs → chunk-TSS3NVRA.mjs} +18 -17
- package/dist/{chunk-WRZWEAMN.mjs → chunk-TU75ILAE.mjs} +1 -1
- package/dist/{chunk-E5LABIPO.mjs → chunk-U2NKGGVL.mjs} +3 -2
- package/dist/{chunk-KLQSTA6K.mjs → chunk-U7TPS3MS.mjs} +1 -1
- package/dist/chunk-UOCUHKR5.mjs +21 -0
- package/dist/{chunk-VA7SUI2L.mjs → chunk-VD4DIRCW.mjs} +1 -1
- package/dist/chunk-VHQ5WHXF.mjs +17 -0
- package/dist/{chunk-MRTQWCNC.mjs → chunk-VMRVJ2VF.mjs} +9 -9
- package/dist/{chunk-MJDJIPB4.mjs → chunk-VRG32WNZ.mjs} +1 -1
- package/dist/chunk-W5XO4T4J.mjs +63 -0
- package/dist/{chunk-5ZMY6RTR.mjs → chunk-WASHQYUB.mjs} +2 -2
- package/dist/{chunk-XNQJRIGR.mjs → chunk-WHP2GNEC.mjs} +66 -15
- package/dist/chunk-WI7PS7YW.mjs +79 -0
- package/dist/{chunk-GIC2RBVM.mjs → chunk-WMLZDHER.mjs} +51 -33
- package/dist/{chunk-4POYX4AW.mjs → chunk-WVTJXJY4.mjs} +1 -1
- package/dist/{chunk-KPDVZFJY.mjs → chunk-WYCMXDZT.mjs} +1 -1
- package/dist/{chunk-LFZAVCVW.mjs → chunk-XD5XGGQA.mjs} +1 -1
- package/dist/{chunk-NEDXMES6.mjs → chunk-YAGU7I25.mjs} +2 -2
- package/dist/{chunk-TRMEHTAT.mjs → chunk-YSI3ZONB.mjs} +1 -1
- package/dist/chunk-YTBKWX7J.mjs +102 -0
- package/dist/chunk-YYUB3HQR.mjs +119 -0
- package/dist/{chunk-CTKIQWTE.mjs → chunk-ZOJEC5RT.mjs} +1 -1
- package/dist/{chunk-2VSERWT6.mjs → chunk-ZXJY3JIP.mjs} +2 -2
- package/dist/index.js +7773 -6876
- package/dist/index.mjs +271 -256
- package/dist/mobile/action-planner.js +492 -389
- package/dist/mobile/action-planner.mjs +155 -155
- package/dist/mobile/agent-capabilities.js +492 -389
- package/dist/mobile/agent-capabilities.mjs +155 -155
- package/dist/mobile/agent-shop/handlers.mjs +5 -5
- package/dist/mobile/agents-watch.js +346 -0
- package/dist/mobile/agents-watch.mjs +13 -0
- package/dist/mobile/anthropic-incremental-deliver.mjs +4 -4
- package/dist/mobile/anthropic-messages-turn-runner.js +1160 -887
- package/dist/mobile/anthropic-messages-turn-runner.mjs +172 -170
- package/dist/mobile/anthropic-owned-tool-executor.js +542 -435
- package/dist/mobile/anthropic-owned-tool-executor.mjs +169 -169
- package/dist/mobile/anthropic-provider-adapter.js +23 -18
- package/dist/mobile/anthropic-provider-adapter.mjs +3 -2
- package/dist/mobile/api.js +236 -147
- package/dist/mobile/api.mjs +84 -83
- package/dist/mobile/auth.mjs +1 -1
- package/dist/mobile/bucket-events/emit-bucket-frame.js +327 -0
- package/dist/mobile/bucket-events/emit-bucket-frame.mjs +8 -3
- package/dist/mobile/bucket-events/register-bucket-gateway-bridge.js +320 -3
- package/dist/mobile/bucket-events/register-bucket-gateway-bridge.mjs +9 -4
- package/dist/mobile/channel.mjs +2 -2
- package/dist/mobile/chinese-monologue-deliver-partition.js +21 -1
- package/dist/mobile/chinese-monologue-deliver-partition.mjs +1 -1
- package/dist/mobile/context-compact/compact-artifact-enrich.mjs +18 -18
- package/dist/mobile/context-compact/compact-artifact-writer.mjs +3 -3
- package/dist/mobile/context-compact/compact-engine-artifacts.mjs +5 -5
- package/dist/mobile/context-compact/compact-memory-distill-job.mjs +3 -3
- package/dist/mobile/context-compact/compact-message-collector.mjs +2 -2
- package/dist/mobile/context-compact/compact-orchestrator.js +8 -22
- package/dist/mobile/context-compact/compact-orchestrator.mjs +41 -41
- package/dist/mobile/context-compact/compact-resume-prefetch.mjs +3 -3
- package/dist/mobile/context-compact/compact-summarizer-engine-artifact.mjs +20 -20
- package/dist/mobile/context-compact/compact-summarizer-llm-request.js +2 -1
- package/dist/mobile/context-compact/compact-summarizer-llm-request.mjs +11 -11
- package/dist/mobile/context-compact/compact-summarizer-llm.js +5 -19
- package/dist/mobile/context-compact/compact-summarizer-llm.mjs +12 -12
- package/dist/mobile/context-compact/compact-summarizer.js +5 -19
- package/dist/mobile/context-compact/compact-summarizer.mjs +17 -17
- package/dist/mobile/context-compact/compact-visible-tool-chain.mjs +2 -2
- package/dist/mobile/context-compact/compact-write-verifier.mjs +2 -2
- package/dist/mobile/context-compact/context-budget-gate.js +111 -84
- package/dist/mobile/context-compact/context-budget-gate.mjs +5 -5
- package/dist/mobile/context-compact/native-transcript-budget.js +151 -79
- package/dist/mobile/context-compact/native-transcript-budget.mjs +7 -3
- package/dist/mobile/context-compact/runtime-compact-hook.js +592 -468
- package/dist/mobile/context-compact/runtime-compact-hook.mjs +158 -158
- package/dist/mobile/dispatch/compact-resume-contract.js +567 -0
- package/dist/mobile/dispatch/compact-resume-contract.mjs +39 -0
- package/dist/mobile/dispatch/dispatch-context-assembly.js +588 -0
- package/dist/mobile/dispatch/dispatch-context-assembly.mjs +20 -0
- package/dist/mobile/dispatch/dispatch-route.js +547 -0
- package/dist/mobile/dispatch/dispatch-route.mjs +23 -0
- package/dist/mobile/dispatch/dispatch-streaming.js +51 -0
- package/dist/mobile/dispatch/dispatch-streaming.mjs +9 -0
- package/dist/mobile/dispatch/finalize-contract.js +147 -0
- package/dist/mobile/dispatch/finalize-contract.mjs +38 -0
- package/dist/mobile/dispatch/inbound-prep.js +671 -0
- package/dist/mobile/dispatch/inbound-prep.mjs +31 -0
- package/dist/mobile/dispatch/interrupted-snapshot.js +190 -0
- package/dist/mobile/dispatch/interrupted-snapshot.mjs +11 -0
- package/dist/mobile/dispatch/mobile-dispatch-error.js +41 -0
- package/dist/mobile/dispatch/mobile-dispatch-error.mjs +7 -0
- package/dist/mobile/dispatch/native-turn-executor.js +42662 -0
- package/dist/mobile/dispatch/native-turn-executor.mjs +320 -0
- package/dist/mobile/dispatch/native-turn-route.js +1465 -0
- package/dist/mobile/dispatch/native-turn-route.mjs +34 -0
- package/dist/mobile/dispatch/native-turn-transcript.js +1134 -0
- package/dist/mobile/dispatch/native-turn-transcript.mjs +29 -0
- package/dist/mobile/group/conductor-llm.js +5 -19
- package/dist/mobile/group/conductor-llm.mjs +15 -15
- package/dist/mobile/group/conductor-plan-llm.js +5 -19
- package/dist/mobile/group/conductor-plan-llm.mjs +22 -22
- package/dist/mobile/group/delivery-verification.js +61 -13
- package/dist/mobile/group/delivery-verification.mjs +4 -4
- package/dist/mobile/group/direct-chat-group-context.mjs +6 -6
- package/dist/mobile/group/execution-plan.js +61 -13
- package/dist/mobile/group/execution-plan.mjs +5 -5
- package/dist/mobile/group/floor-scheduler.mjs +9 -9
- package/dist/mobile/group/floor-state-store.mjs +6 -6
- package/dist/mobile/group/group-api-handlers.js +3 -0
- package/dist/mobile/group/group-api-handlers.mjs +61 -60
- package/dist/mobile/group/group-peer-private-context.mjs +5 -5
- package/dist/mobile/group/group-session.mjs +25 -25
- package/dist/mobile/group/index.js +63 -17
- package/dist/mobile/group/index.mjs +51 -50
- package/dist/mobile/group/memory-supplement.mjs +9 -9
- package/dist/mobile/group/mention.mjs +3 -3
- package/dist/mobile/group/normal-group-router.mjs +2 -2
- package/dist/mobile/group/orchestrator.js +62 -17
- package/dist/mobile/group/orchestrator.mjs +44 -44
- package/dist/mobile/group/pipeline-ceo-dept-mention-parse.mjs +3 -3
- package/dist/mobile/group/pipeline-handoff-verification.js +4 -10
- package/dist/mobile/group/pipeline-handoff-verification.mjs +3 -3
- package/dist/mobile/group/pipeline-turn-outcome.js +5 -14
- package/dist/mobile/group/pipeline-turn-outcome.mjs +2 -2
- package/dist/mobile/group/plan-runtime.js +61 -13
- package/dist/mobile/group/plan-runtime.mjs +26 -26
- package/dist/mobile/group/relation-distill.mjs +10 -10
- package/dist/mobile/group/remarks.mjs +4 -4
- package/dist/mobile/group/runtime-integration.js +65 -17
- package/dist/mobile/group/runtime-integration.mjs +59 -58
- package/dist/mobile/group/team-memory-runtime.mjs +3 -3
- package/dist/mobile/group/transcript-projection.js +1 -0
- package/dist/mobile/group/transcript-projection.mjs +4 -3
- package/dist/mobile/index.js +8046 -7126
- package/dist/mobile/index.mjs +256 -241
- package/dist/mobile/memory-contract-r1-prefetch.mjs +10 -10
- package/dist/mobile/memory-contract-r1.js +1 -1
- package/dist/mobile/memory-contract-r1.mjs +1 -1
- package/dist/mobile/memory-contract-r5-empty-result.mjs +11 -11
- package/dist/mobile/memory-runtime-v2/checkpoint-policy.js +1 -61
- package/dist/mobile/memory-runtime-v2/checkpoint-policy.mjs +2 -2
- package/dist/mobile/memory-runtime-v2/context-pack.js +16 -2
- package/dist/mobile/memory-runtime-v2/context-pack.mjs +2 -2
- package/dist/mobile/memory-runtime-v2/eval-runner.js +231 -145
- package/dist/mobile/memory-runtime-v2/eval-runner.mjs +20 -14
- package/dist/mobile/memory-runtime-v2/evidence-plan.js +233 -147
- package/dist/mobile/memory-runtime-v2/evidence-plan.mjs +22 -16
- package/dist/mobile/memory-runtime-v2/index.js +242 -147
- package/dist/mobile/memory-runtime-v2/index.mjs +58 -46
- package/dist/mobile/memory-runtime-v2/local-source-import.mjs +3 -3
- package/dist/mobile/memory-runtime-v2/long-run-guard.js +1 -119
- package/dist/mobile/memory-runtime-v2/long-run-guard.mjs +3 -3
- package/dist/mobile/memory-runtime-v2/memory-control-plane.js +233 -147
- package/dist/mobile/memory-runtime-v2/memory-control-plane.mjs +22 -16
- package/dist/mobile/memory-runtime-v2/memory-evidence-graph.mjs +2 -2
- package/dist/mobile/memory-runtime-v2/memory-readiness.js +232 -146
- package/dist/mobile/memory-runtime-v2/memory-readiness.mjs +22 -16
- package/dist/mobile/memory-runtime-v2/orchestrator.js +17 -3
- package/dist/mobile/memory-runtime-v2/orchestrator.mjs +7 -7
- package/dist/mobile/memory-runtime-v2/project-tool-event.mjs +2 -2
- package/dist/mobile/memory-runtime-v2/public-api.js +233 -147
- package/dist/mobile/memory-runtime-v2/public-api.mjs +23 -17
- package/dist/mobile/memory-runtime-v2/retrieval.mjs +2 -2
- package/dist/mobile/memory-runtime-v2/run-ledger.js +29 -48
- package/dist/mobile/memory-runtime-v2/run-ledger.mjs +7 -1
- package/dist/mobile/minimax-m3.js +2 -20
- package/dist/mobile/minimax-m3.mjs +3 -9
- package/dist/mobile/model-context-window-budget.js +19 -4
- package/dist/mobile/model-context-window-budget.mjs +7 -3
- package/dist/mobile/model-turn-runner.js +61 -2
- package/dist/mobile/model-turn-runner.mjs +12 -6
- package/dist/mobile/native-anthropic-messages-stream.js +7 -22
- package/dist/mobile/native-anthropic-messages-stream.mjs +12 -12
- package/dist/mobile/native-openai-text-stream.js +1 -2
- package/dist/mobile/native-openai-text-stream.mjs +3 -3
- package/dist/mobile/native-provider-api-key.js +2 -2
- package/dist/mobile/native-provider-api-key.mjs +1 -1
- package/dist/mobile/native-reply-route.js +25 -4
- package/dist/mobile/native-reply-route.mjs +13 -11
- package/dist/mobile/native-reply-system-prompt-layers.js +497 -392
- package/dist/mobile/native-reply-system-prompt-layers.mjs +155 -155
- package/dist/mobile/native-reply-system-prompt.js +1 -0
- package/dist/mobile/native-reply-system-prompt.mjs +1 -1
- package/dist/mobile/native-reply-transcript.js +125 -0
- package/dist/mobile/native-reply-transcript.mjs +7 -2
- package/dist/mobile/native-request-diagnostics.js +4 -2
- package/dist/mobile/native-request-diagnostics.mjs +3 -1
- package/dist/mobile/native-stream-block-emit.mjs +3 -3
- package/dist/mobile/openai-completions-turn-runner.js +874 -608
- package/dist/mobile/openai-completions-turn-runner.mjs +172 -170
- package/dist/mobile/reply-dispatch-warmup.mjs +5 -5
- package/dist/mobile/runtime.js +8272 -7353
- package/dist/mobile/runtime.mjs +253 -238
- package/dist/mobile/session-dispatch/mobile-session-agent-event-bridge.mjs +1 -1
- package/dist/mobile/store.mjs +3 -3
- package/dist/mobile/stream-inbound/mobile-text-stream-pipeline.js +321 -9
- package/dist/mobile/stream-inbound/mobile-text-stream-pipeline.mjs +11 -4
- package/dist/mobile/system-prompt-snapshot.mjs +4 -4
- package/dist/mobile/tool-result-final-summary.js +145 -0
- package/dist/mobile/tool-result-final-summary.mjs +11 -0
- package/dist/mobile/tool-use-input-normalize.js +492 -389
- package/dist/mobile/tool-use-input-normalize.mjs +158 -158
- package/dist/mobile/tools/mobile-compact-tool-bridge.js +492 -389
- package/dist/mobile/tools/mobile-compact-tool-bridge.mjs +157 -157
- package/dist/mobile/types.js +1 -0
- package/dist/mobile/types.mjs +1 -1
- package/dist/mobile/websocket.js +327 -0
- package/dist/mobile/websocket.mjs +7 -2
- package/dist/mobile/workspace-startup-pointer.js +1 -1
- package/dist/mobile/workspace-startup-pointer.mjs +1 -1
- package/dist/org/dept-context.mjs +4 -4
- package/dist/org/index.mjs +8 -8
- package/dist/owned-tools/agent-tool-config.mjs +2 -2
- package/dist/owned-tools/agents-list.mjs +6 -6
- package/dist/owned-tools/ceo-confirm-requirements.mjs +15 -15
- package/dist/owned-tools/ceo-decision.js +72 -18
- package/dist/owned-tools/ceo-decision.mjs +22 -22
- package/dist/owned-tools/ceo-ops-brief.mjs +15 -15
- package/dist/owned-tools/ceo-redirect.js +3 -0
- package/dist/owned-tools/ceo-redirect.mjs +60 -59
- package/dist/owned-tools/commit-stack-lesson.mjs +16 -16
- package/dist/owned-tools/compact/execute.js +492 -389
- package/dist/owned-tools/compact/execute.mjs +155 -155
- package/dist/owned-tools/compact/gateway-tool-factory.js +492 -389
- package/dist/owned-tools/compact/gateway-tool-factory.mjs +156 -156
- package/dist/owned-tools/compact/registry.js +492 -389
- package/dist/owned-tools/compact/registry.mjs +154 -154
- package/dist/owned-tools/context-compact.js +8 -22
- package/dist/owned-tools/context-compact.mjs +69 -63
- package/dist/owned-tools/edit.mjs +2 -2
- package/dist/owned-tools/exec-primitives.mjs +2 -2
- package/dist/owned-tools/exec.js +112 -9
- package/dist/owned-tools/exec.mjs +12 -8
- package/dist/owned-tools/groups-history.mjs +10 -10
- package/dist/owned-tools/handoff.mjs +21 -21
- package/dist/owned-tools/internal-tool-names.js +40 -0
- package/dist/owned-tools/internal-tool-names.mjs +9 -0
- package/dist/owned-tools/media-asset-library.mjs +2 -2
- package/dist/owned-tools/memory-control.mjs +24 -18
- package/dist/owned-tools/memory-get.js +7 -3
- package/dist/owned-tools/memory-get.mjs +1 -1
- package/dist/owned-tools/memory-runtime-eval.js +232 -146
- package/dist/owned-tools/memory-runtime-eval.mjs +23 -17
- package/dist/owned-tools/message.mjs +7 -7
- package/dist/owned-tools/models-list.mjs +2 -2
- package/dist/owned-tools/owned-reply.mjs +6 -6
- package/dist/owned-tools/owned-tool-payload-failure.js +3 -6
- package/dist/owned-tools/owned-tool-payload-failure.mjs +1 -1
- package/dist/owned-tools/process-registry.mjs +2 -2
- package/dist/owned-tools/process.mjs +3 -3
- package/dist/owned-tools/providers/minimax-video-generate.mjs +2 -2
- package/dist/owned-tools/providers/minimax-voice.mjs +2 -2
- package/dist/owned-tools/read.mjs +2 -2
- package/dist/owned-tools/register-owned-providers.mjs +12 -12
- package/dist/owned-tools/registry.js +497 -389
- package/dist/owned-tools/registry.mjs +158 -153
- package/dist/owned-tools/router.js +554 -451
- package/dist/owned-tools/router.mjs +154 -154
- package/dist/owned-tools/runtime-bridge.js +554 -451
- package/dist/owned-tools/runtime-bridge.mjs +156 -156
- package/dist/owned-tools/runtime-data.mjs +5 -5
- package/dist/owned-tools/session-status.mjs +7 -7
- package/dist/owned-tools/sessions-history-resolver.mjs +9 -9
- package/dist/owned-tools/sessions-history.mjs +8 -8
- package/dist/owned-tools/sessions-list.mjs +6 -6
- package/dist/owned-tools/sessions-send.mjs +7 -7
- package/dist/owned-tools/skills-create.mjs +6 -6
- package/dist/owned-tools/subagents.mjs +7 -7
- package/dist/owned-tools/tool-contract-prompt.js +497 -392
- package/dist/owned-tools/tool-contract-prompt.mjs +154 -154
- package/dist/owned-tools/tool-result-envelope.js +526 -405
- package/dist/owned-tools/tool-result-envelope.mjs +159 -159
- package/dist/owned-tools/tool-usage-guide.js +492 -389
- package/dist/owned-tools/tool-usage-guide.mjs +153 -153
- package/dist/owned-tools/tool-validation.mjs +2 -2
- package/dist/owned-tools/tts.mjs +6 -6
- package/dist/owned-tools/web-smoke.mjs +9 -9
- package/dist/owned-tools/write.mjs +2 -2
- package/dist/project/file-tool-scope-default.mjs +6 -6
- package/dist/project/file-tool-scope.js +1 -1
- package/dist/project/file-tool-scope.mjs +1 -1
- package/dist/project-pipeline/handlers.js +3 -0
- package/dist/project-pipeline/handlers.mjs +60 -59
- package/dist/project-pipeline/index.js +3 -0
- package/dist/project-pipeline/index.mjs +62 -61
- package/dist/project-pipeline/pipeline-routing.mjs +2 -2
- package/dist/project-pipeline/post-close-skill-evolution.mjs +5 -5
- package/dist/project-pipeline/project-store.mjs +5 -5
- package/gateway-core/runtime/reply/chinese-monologue-deliver-partition.cjs +27 -6
- package/package.json +2 -2
- package/dist/chunk-4IWTTXQE.mjs +0 -113
- package/dist/chunk-ETD5LGJY.mjs +0 -25
- package/gateway-core/README.md +0 -6
- package/dist/{chunk-MGWYJD5Q.mjs → chunk-2YNBEBKQ.mjs} +14 -14
- package/dist/{chunk-QM7MTC5Q.mjs → chunk-522D52FC.mjs} +3 -3
- package/dist/{chunk-QADC4VKT.mjs → chunk-5MXGINNQ.mjs} +4 -4
- package/dist/{chunk-BRJJML7A.mjs → chunk-5NFOBSYF.mjs} +3 -3
- package/dist/{chunk-NRJWLPTI.mjs → chunk-6AY6OPO5.mjs} +3 -3
- package/dist/{chunk-JA65ZG3H.mjs → chunk-BYGWNFCJ.mjs} +4 -4
- package/dist/{chunk-I7O5UR24.mjs → chunk-JX3URYQG.mjs} +4 -4
- package/dist/{chunk-2QCX6RPN.mjs → chunk-KCZIK3TH.mjs} +3 -3
- package/dist/{chunk-WPLDZLAL.mjs → chunk-L7PMYQN5.mjs} +3 -3
- package/dist/{chunk-H2UCPL5O.mjs → chunk-LY7M7Z7M.mjs} +3 -3
- package/dist/{chunk-UNZ3D3B3.mjs → chunk-MK32KUVI.mjs} +6 -6
- package/dist/{chunk-5LUTMHVL.mjs → chunk-NXKHSX4M.mjs} +3 -3
- package/dist/{chunk-QVEQRCOD.mjs → chunk-PIDPHIN6.mjs} +4 -4
- package/dist/{chunk-UR6LPERL.mjs → chunk-Q7NYATKS.mjs} +3 -3
- package/dist/{chunk-TQOUQIVS.mjs → chunk-V3XUPTZQ.mjs} +3 -3
- package/dist/{chunk-HWGRW6YP.mjs → chunk-VS2URZFN.mjs} +3 -3
- package/dist/{chunk-CVXJ45WI.mjs → chunk-WTOP2LEF.mjs} +5 -5
- package/dist/{chunk-FY2QAWA6.mjs → chunk-YI7E3RUY.mjs} +5 -5
|
@@ -0,0 +1,1465 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// src/mobile/native-provider-api-key-gateway.ts
|
|
34
|
+
var native_provider_api_key_gateway_exports = {};
|
|
35
|
+
__export(native_provider_api_key_gateway_exports, {
|
|
36
|
+
resolveNativeProviderApiKeyViaGatewayAuth: () => resolveNativeProviderApiKeyViaGatewayAuth
|
|
37
|
+
});
|
|
38
|
+
function resolveGatewayAuthBridgePath() {
|
|
39
|
+
const candidates = [];
|
|
40
|
+
if (typeof __dirname === "string") {
|
|
41
|
+
candidates.push(
|
|
42
|
+
import_node_path6.default.resolve(
|
|
43
|
+
__dirname,
|
|
44
|
+
"..",
|
|
45
|
+
"..",
|
|
46
|
+
"gateway-core",
|
|
47
|
+
"runtime",
|
|
48
|
+
"mobile",
|
|
49
|
+
"native-provider-api-key-bridge.cjs"
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
candidates.push(
|
|
54
|
+
import_node_path6.default.resolve(process.cwd(), "gateway-core", "runtime", "mobile", "native-provider-api-key-bridge.cjs")
|
|
55
|
+
);
|
|
56
|
+
for (const candidate of candidates) {
|
|
57
|
+
if (import_node_fs6.default.existsSync(candidate)) {
|
|
58
|
+
return candidate;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
throw new Error(
|
|
62
|
+
`native-provider-api-key-gateway: bridge not found; tried:
|
|
63
|
+
${candidates.join("\n")}`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
function loadGatewayAuthBridge() {
|
|
67
|
+
if (!bridgeMemo) {
|
|
68
|
+
const bridgePath = resolveGatewayAuthBridgePath();
|
|
69
|
+
const req = (0, import_node_module.createRequire)(bridgePath);
|
|
70
|
+
bridgeMemo = req(bridgePath);
|
|
71
|
+
}
|
|
72
|
+
return bridgeMemo;
|
|
73
|
+
}
|
|
74
|
+
async function resolveNativeProviderApiKeyViaGatewayAuth(cfg, providerId, agentId) {
|
|
75
|
+
return loadGatewayAuthBridge().resolveNativeProviderApiKeyViaGatewayAuth({
|
|
76
|
+
cfg,
|
|
77
|
+
providerId,
|
|
78
|
+
agentId
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
var import_node_fs6, import_node_module, import_node_path6, bridgeMemo;
|
|
82
|
+
var init_native_provider_api_key_gateway = __esm({
|
|
83
|
+
"src/mobile/native-provider-api-key-gateway.ts"() {
|
|
84
|
+
"use strict";
|
|
85
|
+
import_node_fs6 = __toESM(require("fs"));
|
|
86
|
+
import_node_module = require("module");
|
|
87
|
+
import_node_path6 = __toESM(require("path"));
|
|
88
|
+
bridgeMemo = null;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// src/mobile/dispatch/native-turn-route.ts
|
|
93
|
+
var native_turn_route_exports = {};
|
|
94
|
+
__export(native_turn_route_exports, {
|
|
95
|
+
resolveNativeDispatchReplyRoute: () => resolveNativeDispatchReplyRoute
|
|
96
|
+
});
|
|
97
|
+
module.exports = __toCommonJS(native_turn_route_exports);
|
|
98
|
+
|
|
99
|
+
// src/mobile/native-gateway-config.ts
|
|
100
|
+
function isGatewayConfigRecord(value) {
|
|
101
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
102
|
+
}
|
|
103
|
+
function gatewayConfigStringProp(obj, key) {
|
|
104
|
+
if (!isGatewayConfigRecord(obj)) {
|
|
105
|
+
return "";
|
|
106
|
+
}
|
|
107
|
+
const v = obj[key];
|
|
108
|
+
return typeof v === "string" ? v.trim() : "";
|
|
109
|
+
}
|
|
110
|
+
function readPositiveConfigInt(value) {
|
|
111
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
112
|
+
return void 0;
|
|
113
|
+
}
|
|
114
|
+
return Math.trunc(value);
|
|
115
|
+
}
|
|
116
|
+
function resolveGatewayConfigString(raw, cfg) {
|
|
117
|
+
if (typeof raw !== "string") {
|
|
118
|
+
return "";
|
|
119
|
+
}
|
|
120
|
+
const s = raw.trim();
|
|
121
|
+
const m = /^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(s);
|
|
122
|
+
if (!m) {
|
|
123
|
+
return s;
|
|
124
|
+
}
|
|
125
|
+
const key = m[1];
|
|
126
|
+
const cfgEnv = isGatewayConfigRecord(cfg) && isGatewayConfigRecord(cfg.env) ? cfg.env : void 0;
|
|
127
|
+
const fromCfg = typeof cfgEnv?.[key] === "string" ? String(cfgEnv[key]).trim() : "";
|
|
128
|
+
return fromCfg || (typeof process.env[key] === "string" ? process.env[key].trim() : "");
|
|
129
|
+
}
|
|
130
|
+
function resolveModelPrimary(modelValue) {
|
|
131
|
+
if (typeof modelValue === "string") {
|
|
132
|
+
return modelValue.trim();
|
|
133
|
+
}
|
|
134
|
+
if (isGatewayConfigRecord(modelValue) && typeof modelValue.primary === "string") {
|
|
135
|
+
return modelValue.primary.trim();
|
|
136
|
+
}
|
|
137
|
+
return "";
|
|
138
|
+
}
|
|
139
|
+
function resolveSelectedModelKey(cfg, agentId) {
|
|
140
|
+
const agents = isGatewayConfigRecord(cfg) && isGatewayConfigRecord(cfg.agents) ? cfg.agents : void 0;
|
|
141
|
+
const defaults = agents && isGatewayConfigRecord(agents.defaults) ? agents.defaults : void 0;
|
|
142
|
+
const list = agents && Array.isArray(agents.list) ? agents.list : [];
|
|
143
|
+
const agent = agentId ? list.find((entry) => isGatewayConfigRecord(entry) && gatewayConfigStringProp(entry, "id") === agentId) : void 0;
|
|
144
|
+
const agentModel = isGatewayConfigRecord(agent) ? resolveModelPrimary(agent.model) : "";
|
|
145
|
+
return agentModel || resolveModelPrimary(defaults?.model);
|
|
146
|
+
}
|
|
147
|
+
function resolveModelRuntimeMetadataFromProvider(providerId, modelId, provider) {
|
|
148
|
+
const base = {
|
|
149
|
+
providerId,
|
|
150
|
+
modelId,
|
|
151
|
+
source: "missing"
|
|
152
|
+
};
|
|
153
|
+
if (!provider || !Array.isArray(provider.models)) {
|
|
154
|
+
return base;
|
|
155
|
+
}
|
|
156
|
+
const row = provider.models.find(
|
|
157
|
+
(item) => isGatewayConfigRecord(item) && gatewayConfigStringProp(item, "id") === modelId
|
|
158
|
+
);
|
|
159
|
+
if (!isGatewayConfigRecord(row)) {
|
|
160
|
+
return base;
|
|
161
|
+
}
|
|
162
|
+
const contextWindow = readPositiveConfigInt(row.contextWindow);
|
|
163
|
+
const maxTokens = readPositiveConfigInt(row.maxTokens);
|
|
164
|
+
return {
|
|
165
|
+
providerId,
|
|
166
|
+
modelId,
|
|
167
|
+
...contextWindow !== void 0 ? { contextWindow } : {},
|
|
168
|
+
...maxTokens !== void 0 ? { maxTokens } : {},
|
|
169
|
+
source: contextWindow !== void 0 || maxTokens !== void 0 ? "models.providers" : "missing"
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function resolveProviderSliceFromGatewayConfig(cfg, options) {
|
|
173
|
+
const modelKey = resolveSelectedModelKey(cfg, options?.agentId);
|
|
174
|
+
const slash = modelKey.indexOf("/");
|
|
175
|
+
if (slash <= 0 || slash >= modelKey.length - 1) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
const providerId = modelKey.slice(0, slash);
|
|
179
|
+
const model = modelKey.slice(slash + 1);
|
|
180
|
+
const providers = isGatewayConfigRecord(cfg) && isGatewayConfigRecord(cfg.models) && isGatewayConfigRecord(cfg.models.providers) ? cfg.models.providers : void 0;
|
|
181
|
+
const provider = providers?.[providerId];
|
|
182
|
+
if (!isGatewayConfigRecord(provider) || gatewayConfigStringProp(provider, "api") !== options?.api) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
providerId,
|
|
187
|
+
model,
|
|
188
|
+
provider,
|
|
189
|
+
metadata: resolveModelRuntimeMetadataFromProvider(providerId, model, provider)
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function resolveGatewayAgentToolsProfile(cfg, agentId) {
|
|
193
|
+
const globalTools = isGatewayConfigRecord(cfg) && isGatewayConfigRecord(cfg.tools) ? gatewayConfigStringProp(cfg.tools, "profile") : "";
|
|
194
|
+
const agents = isGatewayConfigRecord(cfg) && isGatewayConfigRecord(cfg.agents) ? cfg.agents : void 0;
|
|
195
|
+
const defaults = agents && isGatewayConfigRecord(agents.defaults) ? agents.defaults : void 0;
|
|
196
|
+
const list = agents && Array.isArray(agents.list) ? agents.list : [];
|
|
197
|
+
const agent = agentId ? list.find((entry) => isGatewayConfigRecord(entry) && gatewayConfigStringProp(entry, "id") === agentId) : void 0;
|
|
198
|
+
const agentTools = isGatewayConfigRecord(agent?.tools) ? gatewayConfigStringProp(agent.tools, "profile") : "";
|
|
199
|
+
const defaultTools = isGatewayConfigRecord(defaults?.tools) ? gatewayConfigStringProp(defaults.tools, "profile") : "";
|
|
200
|
+
return agentTools || defaultTools || globalTools || "";
|
|
201
|
+
}
|
|
202
|
+
function gatewayAgentWantsFullToolLoop(cfg, agentId) {
|
|
203
|
+
const profile = resolveGatewayAgentToolsProfile(cfg, agentId).trim().toLowerCase();
|
|
204
|
+
if (profile === "minimal" || profile === "none" || profile === "off" || profile === "messaging") {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// src/mobile/native-provider-api-key.ts
|
|
211
|
+
var import_node_fs4 = __toESM(require("fs"));
|
|
212
|
+
var import_node_path4 = __toESM(require("path"));
|
|
213
|
+
|
|
214
|
+
// src/mobile/agent-shop/runtime-agent-paths.ts
|
|
215
|
+
var import_node_fs3 = require("fs");
|
|
216
|
+
|
|
217
|
+
// src/agent/agent-folder-name.ts
|
|
218
|
+
var import_node_path2 = require("path");
|
|
219
|
+
|
|
220
|
+
// src/path/root.ts
|
|
221
|
+
var import_memoize = __toESM(require("lodash-es/memoize.js"));
|
|
222
|
+
var import_os2 = require("os");
|
|
223
|
+
var import_path3 = require("path");
|
|
224
|
+
|
|
225
|
+
// src/path/state-dir.ts
|
|
226
|
+
var import_node_fs = require("fs");
|
|
227
|
+
var import_node_os = require("os");
|
|
228
|
+
var import_node_path = require("path");
|
|
229
|
+
|
|
230
|
+
// src/utils/path.ts
|
|
231
|
+
var import_path = require("path");
|
|
232
|
+
var import_os = require("os");
|
|
233
|
+
function validateRootPath(raw, expandTilde = true) {
|
|
234
|
+
if (!raw || raw.trim().length === 0) {
|
|
235
|
+
return { valid: false, reason: "Path is empty" };
|
|
236
|
+
}
|
|
237
|
+
let candidate = raw.trim();
|
|
238
|
+
if (expandTilde && (candidate.startsWith("~/") || candidate.startsWith("~\\"))) {
|
|
239
|
+
const rest = candidate.slice(2);
|
|
240
|
+
const restNorm = (0, import_path.normalize)(rest || ".");
|
|
241
|
+
if (restNorm === "." || restNorm === "..") {
|
|
242
|
+
return { valid: false, reason: "Cannot expand to home or parent directory" };
|
|
243
|
+
}
|
|
244
|
+
candidate = (0, import_path.join)((0, import_os.homedir)(), rest);
|
|
245
|
+
}
|
|
246
|
+
const normalized = (0, import_path.normalize)(candidate).replace(/[/\\]+$/, "");
|
|
247
|
+
if (!(0, import_path.isAbsolute)(normalized)) {
|
|
248
|
+
return { valid: false, reason: "Path must be absolute" };
|
|
249
|
+
}
|
|
250
|
+
if (normalized.length < 3) {
|
|
251
|
+
return { valid: false, reason: "Path too short" };
|
|
252
|
+
}
|
|
253
|
+
if (/^[A-Za-z]:$/.test(normalized)) {
|
|
254
|
+
return { valid: false, reason: "Cannot use drive root directly" };
|
|
255
|
+
}
|
|
256
|
+
if (normalized.startsWith("\\\\") || normalized.startsWith("//")) {
|
|
257
|
+
return { valid: false, reason: "UNC network paths not supported" };
|
|
258
|
+
}
|
|
259
|
+
if (normalized.includes("\0")) {
|
|
260
|
+
return { valid: false, reason: "Path contains null byte" };
|
|
261
|
+
}
|
|
262
|
+
const normalizedWithSep = normalized + import_path.sep;
|
|
263
|
+
return { valid: true, normalizedPath: normalizedWithSep.normalize("NFC") };
|
|
264
|
+
}
|
|
265
|
+
function checkPortableMarker(dir) {
|
|
266
|
+
const fs4 = require("fs");
|
|
267
|
+
const path4 = require("path");
|
|
268
|
+
const markerPath = path4.join(dir, ".xkzoom_portable");
|
|
269
|
+
try {
|
|
270
|
+
return fs4.existsSync(markerPath) && fs4.statSync(markerPath).isFile();
|
|
271
|
+
} catch {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// src/path/state-dir.ts
|
|
277
|
+
var XKZOOM_STATE_ROOT_MARKER = "xkzoom-state-root.json";
|
|
278
|
+
var LEGACY_ENV_EXACT_KEYS = /* @__PURE__ */ new Set([
|
|
279
|
+
["OPEN", "CLAW"].join(""),
|
|
280
|
+
["XKZOOM", "ROOT"].join("_"),
|
|
281
|
+
["XK", "ZOOM", "ROOT"].join("_")
|
|
282
|
+
]);
|
|
283
|
+
var LEGACY_ENV_PREFIXES = [
|
|
284
|
+
["OPEN", "CLAW_"].join(""),
|
|
285
|
+
["XKZOOM_", "DO", "NOR_"].join("")
|
|
286
|
+
];
|
|
287
|
+
function isLegacyGatewayEnvKey(key) {
|
|
288
|
+
return LEGACY_ENV_EXACT_KEYS.has(key) || LEGACY_ENV_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
289
|
+
}
|
|
290
|
+
function findLegacyGatewayEnvKeys(env = process.env) {
|
|
291
|
+
return Object.keys(env).filter((key) => {
|
|
292
|
+
const value = env[key];
|
|
293
|
+
return value != null && String(value).trim() && isLegacyGatewayEnvKey(key);
|
|
294
|
+
}).sort();
|
|
295
|
+
}
|
|
296
|
+
function assertNoLegacyGatewayEnv(env = process.env) {
|
|
297
|
+
const hits = findLegacyGatewayEnvKeys(env);
|
|
298
|
+
if (hits.length > 0) {
|
|
299
|
+
throw new Error(
|
|
300
|
+
`[XKZOOM] retired gateway environment variables are no longer supported: ${hits.join(", ")}. Use XKZOOM_STATE_DIR for the state root and remove retired runtime fallback environment variables.`
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function normalizeTrailingSep(raw) {
|
|
305
|
+
const n = (0, import_node_path.normalize)(raw.trim()).replace(/[/\\]+$/, "");
|
|
306
|
+
return n.length ? n + import_node_path.sep : raw;
|
|
307
|
+
}
|
|
308
|
+
function isPlausibleDirectory(absPath) {
|
|
309
|
+
if (!absPath || absPath.length < 4) return false;
|
|
310
|
+
if (!(0, import_node_path.isAbsolute)(absPath)) return false;
|
|
311
|
+
if (/^[A-Za-z]:$/.test(absPath)) return false;
|
|
312
|
+
if (absPath.startsWith("\\\\") || absPath.startsWith("//")) return false;
|
|
313
|
+
if (absPath.includes("\0")) return false;
|
|
314
|
+
try {
|
|
315
|
+
if (!(0, import_node_fs.existsSync)(absPath)) return false;
|
|
316
|
+
return (0, import_node_fs.statSync)(absPath).isDirectory();
|
|
317
|
+
} catch {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function expandHomePath(raw, userHome) {
|
|
322
|
+
return raw.startsWith("~/") || raw.startsWith("~\\") ? (0, import_node_path.join)(userHome, raw.slice(2)) : raw;
|
|
323
|
+
}
|
|
324
|
+
function readRedirectFromHomeStub(userHome) {
|
|
325
|
+
const stub = (0, import_node_path.join)(userHome, ".xkzoom");
|
|
326
|
+
const marker = (0, import_node_path.join)(stub, XKZOOM_STATE_ROOT_MARKER);
|
|
327
|
+
if (!(0, import_node_fs.existsSync)(marker)) {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
try {
|
|
331
|
+
const parsed = JSON.parse((0, import_node_fs.readFileSync)(marker, "utf8"));
|
|
332
|
+
const target = typeof parsed.stateRoot === "string" ? parsed.stateRoot.trim() : "";
|
|
333
|
+
if (!target) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
const expanded = expandHomePath(target, userHome);
|
|
337
|
+
const v = validateRootPath(expanded, true);
|
|
338
|
+
if (!v.valid || !v.normalizedPath) {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
const dir = v.normalizedPath.replace(/[/\\]+$/, "");
|
|
342
|
+
return isPlausibleDirectory(dir) ? normalizeTrailingSep(dir) : null;
|
|
343
|
+
} catch {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
function resolveDefaultStateDirAfterEnv(userHome = (0, import_node_os.homedir)()) {
|
|
348
|
+
const redirected = readRedirectFromHomeStub(userHome);
|
|
349
|
+
if (redirected) {
|
|
350
|
+
const p = redirected.endsWith(import_node_path.sep) ? redirected : redirected + import_node_path.sep;
|
|
351
|
+
return { rootPath: p, source: "redirect" };
|
|
352
|
+
}
|
|
353
|
+
const fallback = (0, import_node_path.join)(userHome, ".xkzoom") + import_node_path.sep;
|
|
354
|
+
return { rootPath: fallback, source: "default" };
|
|
355
|
+
}
|
|
356
|
+
function resolveXkzoomStateDirForProcess(userHome = (0, import_node_os.homedir)()) {
|
|
357
|
+
assertNoLegacyGatewayEnv(process.env);
|
|
358
|
+
const explicit = process.env.XKZOOM_STATE_DIR?.trim();
|
|
359
|
+
if (explicit) {
|
|
360
|
+
const expanded = expandHomePath(explicit, userHome);
|
|
361
|
+
const v = validateRootPath(expanded, true);
|
|
362
|
+
if (v.valid && v.normalizedPath) {
|
|
363
|
+
return v.normalizedPath;
|
|
364
|
+
}
|
|
365
|
+
throw new Error(`Invalid XKZOOM_STATE_DIR: ${v.valid ? "unknown" : v.reason}`);
|
|
366
|
+
}
|
|
367
|
+
return resolveDefaultStateDirAfterEnv(userHome).rootPath;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// src/path/root.ts
|
|
371
|
+
function rootResolutionCacheKey() {
|
|
372
|
+
return [
|
|
373
|
+
process.env.XKZOOM_STATE_DIR?.trim() ?? "",
|
|
374
|
+
process.cwd()
|
|
375
|
+
].join("\0");
|
|
376
|
+
}
|
|
377
|
+
var getXkRootMemoized = (0, import_memoize.default)(() => {
|
|
378
|
+
assertNoLegacyGatewayEnv(process.env);
|
|
379
|
+
const envStateDir = process.env.XKZOOM_STATE_DIR?.trim();
|
|
380
|
+
if (envStateDir) {
|
|
381
|
+
return {
|
|
382
|
+
rootPath: resolveXkzoomStateDirForProcess((0, import_os2.homedir)()),
|
|
383
|
+
isPortable: false,
|
|
384
|
+
source: "env"
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
const cwd = process.cwd();
|
|
388
|
+
if (checkPortableMarker(cwd)) {
|
|
389
|
+
return {
|
|
390
|
+
rootPath: cwd.endsWith("/") || cwd.endsWith("\\") ? cwd : cwd + import_path3.sep,
|
|
391
|
+
isPortable: true,
|
|
392
|
+
source: "portable"
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
const meta = resolveDefaultStateDirAfterEnv((0, import_os2.homedir)());
|
|
396
|
+
return {
|
|
397
|
+
rootPath: meta.rootPath,
|
|
398
|
+
isPortable: false,
|
|
399
|
+
source: meta.source
|
|
400
|
+
};
|
|
401
|
+
}, rootResolutionCacheKey);
|
|
402
|
+
function getXkRoot() {
|
|
403
|
+
return getXkRootMemoized();
|
|
404
|
+
}
|
|
405
|
+
function getXkRootPath() {
|
|
406
|
+
return getXkRoot().rootPath;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// src/path/resolver.ts
|
|
410
|
+
var import_path5 = require("path");
|
|
411
|
+
function resolveXkPath(...segments) {
|
|
412
|
+
const root = getXkRootPath();
|
|
413
|
+
return (0, import_path5.normalize)((0, import_path5.join)(root, ...segments));
|
|
414
|
+
}
|
|
415
|
+
var SAFE_AGENT_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
416
|
+
function isSafeAgentId(raw) {
|
|
417
|
+
if (typeof raw !== "string") {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
if (raw === "." || raw === "..") {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
if (raw.startsWith(".") || raw.startsWith("-")) {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
return SAFE_AGENT_ID_RE.test(raw);
|
|
427
|
+
}
|
|
428
|
+
function assertSafeAgentId(raw) {
|
|
429
|
+
if (!isSafeAgentId(raw)) {
|
|
430
|
+
const preview = typeof raw === "string" ? JSON.stringify(raw).slice(0, 64) : String(raw);
|
|
431
|
+
throw new Error(`[XKZOOM] Invalid agentId for path resolution: ${preview}`);
|
|
432
|
+
}
|
|
433
|
+
return raw;
|
|
434
|
+
}
|
|
435
|
+
function resolveAgentDir(agentId) {
|
|
436
|
+
const safe = assertSafeAgentId(agentId);
|
|
437
|
+
return resolveXkPath("agents", safe);
|
|
438
|
+
}
|
|
439
|
+
function resolveAgentWorkspace(agentId) {
|
|
440
|
+
return resolveXkPath("agents", assertSafeAgentId(agentId), "workspace");
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// src/mobile/agent-shop/agent-job-lineup.ts
|
|
444
|
+
var OWNED_SOUL_SEED_REVISION_V2 = 2;
|
|
445
|
+
var AGENT_JOB_LINEUP_V1 = [
|
|
446
|
+
{
|
|
447
|
+
catalogId: "onboarding",
|
|
448
|
+
displayName: "Zoom",
|
|
449
|
+
roleTitle: "\u6B22\u8FCE\u5411\u5BFC",
|
|
450
|
+
jobCategory: "delivery",
|
|
451
|
+
legacyShopId: "z-infj",
|
|
452
|
+
pipelineParticipates: false,
|
|
453
|
+
deliverableHint: "\u573A\u666F\u5BFC\u8BFB\u3001\u5DE5\u79CD\u63A8\u8350",
|
|
454
|
+
tagline: "\u5148\u8BFB\u61C2\u4F60\u7684\u573A\u666F",
|
|
455
|
+
skills: ["\u6B22\u8FCE\u5411\u5BFC", "\u5DE5\u79CD\u63A8\u8350", "\u4E0A\u624B\u8DEF\u5F84"],
|
|
456
|
+
workspaceSeedDir: "onboarding",
|
|
457
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
catalogId: "research",
|
|
461
|
+
displayName: "\u8C03\u7814\u4E13\u5BB6",
|
|
462
|
+
roleTitle: "\u8C03\u7814",
|
|
463
|
+
jobCategory: "delivery",
|
|
464
|
+
legacyShopId: "z-intp",
|
|
465
|
+
pipelineParticipates: true,
|
|
466
|
+
deliverableHint: "\u8C03\u7814\u62A5\u544A\u3001\u53EF\u884C\u6027\u5206\u6790",
|
|
467
|
+
tagline: "\u628A\u95EE\u9898\u62C6\u6E05\u695A\u518D\u4E0B\u7ED3\u8BBA",
|
|
468
|
+
skills: ["\u7528\u6237\u8BBF\u8C08", "\u7ADE\u54C1\u626B\u63CF", "\u5047\u8BBE\u9A8C\u8BC1"],
|
|
469
|
+
workspaceSeedDir: "research",
|
|
470
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
catalogId: "product",
|
|
474
|
+
displayName: "\u4EA7\u54C1\u4E13\u5BB6",
|
|
475
|
+
roleTitle: "\u4EA7\u54C1",
|
|
476
|
+
jobCategory: "delivery",
|
|
477
|
+
legacyShopId: "z-entj",
|
|
478
|
+
pipelineParticipates: true,
|
|
479
|
+
deliverableHint: "PRD\u3001\u9A8C\u6536\u6807\u51C6",
|
|
480
|
+
tagline: "\u9700\u6C42\u5199\u6E05\u3001\u8FB9\u754C\u5212\u660E",
|
|
481
|
+
skills: ["PRD", "\u9A8C\u6536\u6807\u51C6", "\u4F18\u5148\u7EA7"],
|
|
482
|
+
workspaceSeedDir: "product",
|
|
483
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
catalogId: "dev",
|
|
487
|
+
displayName: "\u7814\u53D1\u4E13\u5BB6",
|
|
488
|
+
roleTitle: "\u7814\u53D1",
|
|
489
|
+
jobCategory: "delivery",
|
|
490
|
+
legacyShopId: "z-istp",
|
|
491
|
+
pipelineParticipates: true,
|
|
492
|
+
deliverableHint: "\u53EF\u8FD0\u884C\u4EE3\u7801\u3001\u6280\u672F\u8BF4\u660E",
|
|
493
|
+
tagline: "\u80FD\u8DD1\u8D77\u6765\u624D\u7B97\u4EA4\u4ED8",
|
|
494
|
+
skills: ["\u5B9E\u73B0", "\u8C03\u8BD5", "\u6280\u672F\u8BF4\u660E"],
|
|
495
|
+
workspaceSeedDir: "dev",
|
|
496
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
catalogId: "audit",
|
|
500
|
+
displayName: "\u5BA1\u8BA1\u4E13\u5BB6",
|
|
501
|
+
roleTitle: "\u5BA1\u8BA1",
|
|
502
|
+
jobCategory: "delivery",
|
|
503
|
+
legacyShopId: "z-istj",
|
|
504
|
+
pipelineParticipates: true,
|
|
505
|
+
deliverableHint: "\u5BA1\u8BA1\u62A5\u544A\u3001approve/reject",
|
|
506
|
+
tagline: "\u8BC1\u636E\u5230\u4F4D\u518D\u7B7E\u5B57",
|
|
507
|
+
skills: ["\u95E8\u7981\u5BA1\u67E5", "\u98CE\u9669\u6E05\u5355", "\u9A8C\u6536\u88C1\u51B3"],
|
|
508
|
+
workspaceSeedDir: "audit",
|
|
509
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
catalogId: "design",
|
|
513
|
+
displayName: "\u8BBE\u8BA1\u4E13\u5BB6",
|
|
514
|
+
roleTitle: "\u8BBE\u8BA1",
|
|
515
|
+
jobCategory: "delivery",
|
|
516
|
+
legacyShopId: "z-isfp",
|
|
517
|
+
pipelineParticipates: false,
|
|
518
|
+
deliverableHint: "\u8BBE\u8BA1\u89C4\u8303\u3001\u7EC4\u4EF6\u4E00\u81F4\u6027",
|
|
519
|
+
tagline: "\u754C\u9762\u53EF\u8BFB\u3001\u4EA4\u4E92\u53EF\u5B66",
|
|
520
|
+
skills: ["UI \u89C4\u8303", "\u7EC4\u4EF6\u5E93", "\u89C6\u89C9\u4E00\u81F4\u6027"],
|
|
521
|
+
workspaceSeedDir: "design",
|
|
522
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
catalogId: "architecture",
|
|
526
|
+
displayName: "\u67B6\u6784\u4E13\u5BB6",
|
|
527
|
+
roleTitle: "\u67B6\u6784",
|
|
528
|
+
jobCategory: "delivery",
|
|
529
|
+
legacyShopId: "z-intj",
|
|
530
|
+
pipelineParticipates: false,
|
|
531
|
+
deliverableHint: "ADR\u3001\u8FB9\u754C\u4E0E\u6743\u8861",
|
|
532
|
+
tagline: "\u8FB9\u754C\u6E05\u695A\u3001\u6F14\u8FDB\u53EF\u63A7",
|
|
533
|
+
skills: ["ADR", "\u6A21\u5757\u8FB9\u754C", "\u5BB9\u91CF\u89C4\u5212"],
|
|
534
|
+
workspaceSeedDir: "architecture",
|
|
535
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
catalogId: "qa",
|
|
539
|
+
displayName: "\u6D4B\u8BD5\u4E13\u5BB6",
|
|
540
|
+
roleTitle: "\u6D4B\u8BD5",
|
|
541
|
+
jobCategory: "delivery",
|
|
542
|
+
legacyShopId: "z-estj",
|
|
543
|
+
pipelineParticipates: false,
|
|
544
|
+
deliverableHint: "\u6D4B\u8BD5\u62A5\u544A\u3001\u7F3A\u9677\u8BC1\u636E",
|
|
545
|
+
tagline: "\u6B65\u9AA4\u53EF\u590D\u73B0\u3001\u7ED3\u8BBA\u53EF\u6838\u5BF9",
|
|
546
|
+
skills: ["\u7528\u4F8B\u8BBE\u8BA1", "\u56DE\u5F52\u6D4B\u8BD5", "\u7F3A\u9677\u8BC1\u636E"],
|
|
547
|
+
workspaceSeedDir: "qa",
|
|
548
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
catalogId: "data_analytics",
|
|
552
|
+
displayName: "\u6570\u636E\u5206\u6790\u4E13\u5BB6",
|
|
553
|
+
roleTitle: "\u6570\u636E\u5206\u6790",
|
|
554
|
+
jobCategory: "operations",
|
|
555
|
+
legacyShopId: "z-isfj",
|
|
556
|
+
pipelineParticipates: false,
|
|
557
|
+
deliverableHint: "\u6307\u6807\u5B57\u5178\u3001\u5206\u6790\u62A5\u544A",
|
|
558
|
+
tagline: "\u6307\u6807\u53E3\u5F84\u4E00\u81F4\u3001\u7ED3\u8BBA\u53EF\u8FFD\u6EAF",
|
|
559
|
+
skills: ["\u6307\u6807\u5B9A\u4E49", "SQL/\u62A5\u8868", "\u5F02\u52A8\u5F52\u56E0"],
|
|
560
|
+
workspaceSeedDir: "data_analytics",
|
|
561
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
catalogId: "strategy",
|
|
565
|
+
displayName: "\u6218\u7565\u4E13\u5BB6",
|
|
566
|
+
roleTitle: "\u6218\u7565",
|
|
567
|
+
jobCategory: "growth",
|
|
568
|
+
legacyShopId: "z-enfp",
|
|
569
|
+
pipelineParticipates: false,
|
|
570
|
+
deliverableHint: "\u6218\u7565\u5907\u5FD8\u3001\u9009\u9879\u6BD4\u8F83",
|
|
571
|
+
tagline: "\u9009\u9879\u5217\u5168\u3001\u53D6\u820D\u8BF4\u900F",
|
|
572
|
+
skills: ["\u6218\u7565\u5907\u5FD8", "\u7ADE\u4E89\u683C\u5C40", "\u8DEF\u7EBF\u6BD4\u8F83"],
|
|
573
|
+
workspaceSeedDir: "strategy",
|
|
574
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
catalogId: "pmo",
|
|
578
|
+
displayName: "\u9879\u76EE\u4E13\u5BB6",
|
|
579
|
+
roleTitle: "\u9879\u76EE\u7BA1\u7406",
|
|
580
|
+
jobCategory: "operations",
|
|
581
|
+
legacyShopId: "z-entp",
|
|
582
|
+
pipelineParticipates: false,
|
|
583
|
+
deliverableHint: "\u9879\u76EE\u8BA1\u5212\u3001RAID",
|
|
584
|
+
tagline: "\u8303\u56F4\u3001\u8282\u594F\u3001\u98CE\u9669\u540C\u5C4F",
|
|
585
|
+
skills: ["\u91CC\u7A0B\u7891", "RAID", "\u8D44\u6E90\u534F\u8C03"],
|
|
586
|
+
workspaceSeedDir: "pmo",
|
|
587
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
catalogId: "operations",
|
|
591
|
+
displayName: "\u8FD0\u8425\u4E13\u5BB6",
|
|
592
|
+
roleTitle: "\u8FD0\u8425",
|
|
593
|
+
jobCategory: "operations",
|
|
594
|
+
legacyShopId: "z-esfj",
|
|
595
|
+
pipelineParticipates: false,
|
|
596
|
+
deliverableHint: "\u8FD0\u8425 SOP\u3001\u6392\u671F",
|
|
597
|
+
tagline: "\u6D41\u7A0B\u8DD1\u987A\u3001\u8282\u70B9\u6709\u4EBA\u8DDF",
|
|
598
|
+
skills: ["SOP", "\u6D3B\u52A8\u6392\u671F", "\u8F6C\u5316\u590D\u76D8"],
|
|
599
|
+
workspaceSeedDir: "operations",
|
|
600
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
catalogId: "marketing",
|
|
604
|
+
displayName: "\u8425\u9500\u4E13\u5BB6",
|
|
605
|
+
roleTitle: "\u8425\u9500",
|
|
606
|
+
jobCategory: "growth",
|
|
607
|
+
legacyShopId: "z-esfp",
|
|
608
|
+
pipelineParticipates: false,
|
|
609
|
+
deliverableHint: "\u8425\u9500\u65B9\u6848\u3001\u6E20\u9053\u53E3\u5F84",
|
|
610
|
+
tagline: "\u6E20\u9053\u6E05\u695A\u3001\u53E3\u5F84\u7EDF\u4E00",
|
|
611
|
+
skills: ["\u6295\u653E\u65B9\u6848", "\u5185\u5BB9\u65E5\u5386", "\u54C1\u724C\u53E3\u5F84"],
|
|
612
|
+
workspaceSeedDir: "marketing",
|
|
613
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
catalogId: "sales",
|
|
617
|
+
displayName: "\u9500\u552E\u4E13\u5BB6",
|
|
618
|
+
roleTitle: "\u9500\u552E",
|
|
619
|
+
jobCategory: "growth",
|
|
620
|
+
legacyShopId: "z-estp",
|
|
621
|
+
pipelineParticipates: false,
|
|
622
|
+
deliverableHint: "\u5546\u673A\u65B9\u6848\u3001\u62A5\u4EF7\u8FB9\u754C",
|
|
623
|
+
tagline: "\u9700\u6C42\u5BF9\u9F50\u3001\u627F\u8BFA\u53EF\u5151\u73B0",
|
|
624
|
+
skills: ["\u5546\u673A\u68B3\u7406", "\u65B9\u6848\u62A5\u4EF7", "\u4EA4\u4ED8\u8FB9\u754C"],
|
|
625
|
+
workspaceSeedDir: "sales",
|
|
626
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
catalogId: "hr",
|
|
630
|
+
displayName: "\u4EBA\u529B\u7EC4\u7EC7\u4E13\u5BB6",
|
|
631
|
+
roleTitle: "\u4EBA\u529B\u7EC4\u7EC7",
|
|
632
|
+
jobCategory: "people_legal",
|
|
633
|
+
legacyShopId: "z-enfj",
|
|
634
|
+
pipelineParticipates: false,
|
|
635
|
+
deliverableHint: "\u5C97\u4F4D\u8BF4\u660E\u3001\u534F\u4F5C\u7EA6\u5B9A",
|
|
636
|
+
tagline: "\u89D2\u8272\u6E05\u6670\u3001\u534F\u4F5C\u6709\u7AE0",
|
|
637
|
+
skills: ["\u5C97\u4F4D JD", "\u534F\u4F5C\u7EA6\u5B9A", "\u5165\u804C\u6E05\u5355"],
|
|
638
|
+
workspaceSeedDir: "hr",
|
|
639
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
catalogId: "legal",
|
|
643
|
+
displayName: "\u6CD5\u52A1\u5408\u89C4\u4E13\u5BB6",
|
|
644
|
+
roleTitle: "\u6CD5\u52A1\u5408\u89C4",
|
|
645
|
+
jobCategory: "people_legal",
|
|
646
|
+
legacyShopId: "z-infp",
|
|
647
|
+
pipelineParticipates: false,
|
|
648
|
+
deliverableHint: "\u5408\u89C4\u6E05\u5355\u3001\u98CE\u9669\u63D0\u793A",
|
|
649
|
+
tagline: "\u7EA2\u7EBF\u5148\u8BF4\u3001\u98CE\u9669\u53EF\u7BA1",
|
|
650
|
+
skills: ["\u5408\u540C\u8981\u70B9", "\u5408\u89C4\u6E05\u5355", "\u9690\u79C1\u7EA2\u7EBF"],
|
|
651
|
+
workspaceSeedDir: "legal",
|
|
652
|
+
soulSeedRevision: OWNED_SOUL_SEED_REVISION_V2
|
|
653
|
+
}
|
|
654
|
+
];
|
|
655
|
+
var CATALOG_IDS_FROM_LINEUP = AGENT_JOB_LINEUP_V1.map((e) => e.catalogId);
|
|
656
|
+
|
|
657
|
+
// src/agent/agent-folder-name.ts
|
|
658
|
+
var SAFE_FOLDER_RE = /^[a-z0-9._-]{1,128}$/;
|
|
659
|
+
var WINDOWS_RESERVED_NAMES = /* @__PURE__ */ new Set([
|
|
660
|
+
"con",
|
|
661
|
+
"prn",
|
|
662
|
+
"aux",
|
|
663
|
+
"nul",
|
|
664
|
+
...Array.from({ length: 9 }, (_, i) => `com${i + 1}`),
|
|
665
|
+
...Array.from({ length: 9 }, (_, i) => `lpt${i + 1}`)
|
|
666
|
+
]);
|
|
667
|
+
function asRecord(value) {
|
|
668
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
669
|
+
}
|
|
670
|
+
function clean(value) {
|
|
671
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
672
|
+
}
|
|
673
|
+
function normalizeAgentFolderName(input) {
|
|
674
|
+
return input.trim().toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9._-]+/g, "_").replace(/_+/g, "_").replace(/^[._-]+|[._-]+$/g, "").slice(0, 128);
|
|
675
|
+
}
|
|
676
|
+
function assertSafeAgentFolderName(folderName) {
|
|
677
|
+
if (typeof folderName !== "string") {
|
|
678
|
+
throw new Error("[XKZOOM] Invalid agent folder name: not a string");
|
|
679
|
+
}
|
|
680
|
+
if (!folderName || folderName === "." || folderName === "..") {
|
|
681
|
+
throw new Error("[XKZOOM] Invalid agent folder name: empty or dot segment");
|
|
682
|
+
}
|
|
683
|
+
if (folderName.includes("/") || folderName.includes("\\") || folderName.includes("\0")) {
|
|
684
|
+
throw new Error("[XKZOOM] Invalid agent folder name: path separator or null byte");
|
|
685
|
+
}
|
|
686
|
+
if (/[\x00-\x1f\x7f]/.test(folderName)) {
|
|
687
|
+
throw new Error("[XKZOOM] Invalid agent folder name: control character");
|
|
688
|
+
}
|
|
689
|
+
if (!SAFE_FOLDER_RE.test(folderName)) {
|
|
690
|
+
throw new Error("[XKZOOM] Invalid agent folder name: allowed characters are [a-z0-9._-]");
|
|
691
|
+
}
|
|
692
|
+
const base = folderName.split(".")[0];
|
|
693
|
+
if (WINDOWS_RESERVED_NAMES.has(base)) {
|
|
694
|
+
throw new Error(`[XKZOOM] Invalid agent folder name: Windows reserved name "${folderName}"`);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
function resolveAgentRootByFolderName(folderName) {
|
|
698
|
+
assertSafeAgentFolderName(folderName);
|
|
699
|
+
return resolveXkPath("agents", folderName);
|
|
700
|
+
}
|
|
701
|
+
function resolveAgentWorkspaceByFolderName(folderName) {
|
|
702
|
+
return (0, import_node_path2.join)(resolveAgentRootByFolderName(folderName), "workspace");
|
|
703
|
+
}
|
|
704
|
+
function resolveAgentDirByFolderName(folderName) {
|
|
705
|
+
return (0, import_node_path2.join)(resolveAgentRootByFolderName(folderName), "agent");
|
|
706
|
+
}
|
|
707
|
+
function readPersistedAgentFolderName(entry) {
|
|
708
|
+
const params = asRecord(entry?.params);
|
|
709
|
+
const folder = asRecord(params.xkzoomFolder);
|
|
710
|
+
const folderName = clean(folder.folderName);
|
|
711
|
+
if (!folderName) {
|
|
712
|
+
return null;
|
|
713
|
+
}
|
|
714
|
+
const normalized = normalizeAgentFolderName(folderName);
|
|
715
|
+
assertSafeAgentFolderName(normalized);
|
|
716
|
+
return normalized;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// src/agent/workspace-policy.ts
|
|
720
|
+
var import_path7 = require("path");
|
|
721
|
+
var noopWarn = (msg) => {
|
|
722
|
+
console.warn(msg);
|
|
723
|
+
};
|
|
724
|
+
function resolveCanonicalAgentPaths(agentId, options = {}) {
|
|
725
|
+
assertSafeAgentId(agentId);
|
|
726
|
+
const onWarn = options.onWarn ?? noopWarn;
|
|
727
|
+
const requireUnderStateRoot = options.requireUnderStateRoot === true;
|
|
728
|
+
const fallback = resolveFallbackPaths(agentId, options.folderName);
|
|
729
|
+
const hint = normalizeJsonHint(options.jsonHint);
|
|
730
|
+
if (!hint) {
|
|
731
|
+
return fallback;
|
|
732
|
+
}
|
|
733
|
+
if (samePath(hint, fallback.workspaceDir)) {
|
|
734
|
+
return { ...fallback, workspaceDir: fallback.workspaceDir, source: "json-aligned" };
|
|
735
|
+
}
|
|
736
|
+
if (requireUnderStateRoot && !isUnderAgentsRoot(hint)) {
|
|
737
|
+
onWarn(
|
|
738
|
+
`[XKZOOM][workspace-policy] xkzoom.json agents.list[].workspace ("${hint}") falls outside STATE_ROOT/agents/ for agentId="${agentId}". Rejecting hint and falling back to canonical resolver path ("${fallback.workspaceDir}") (write-path safety; see AGENT_SHOP_V1_PLAN \xA716.2 + STATE_ROOT_MAINLAND_ALIGN \xA77).`
|
|
739
|
+
);
|
|
740
|
+
return { ...fallback, source: "json-rejected-out-of-state-root" };
|
|
741
|
+
}
|
|
742
|
+
onWarn(
|
|
743
|
+
`[XKZOOM][workspace-policy] xkzoom.json agents.list[].workspace ("${hint}") differs from STATE_ROOT-derived path ("${fallback.workspaceDir}") for agentId="${agentId}". Falling back to JSON value during migration window; align them ASAP (see STATE_ROOT_MAINLAND_ALIGN \xA77).`
|
|
744
|
+
);
|
|
745
|
+
const agentRootDir = (0, import_path7.dirname)(hint);
|
|
746
|
+
return {
|
|
747
|
+
agentRootDir,
|
|
748
|
+
workspaceDir: hint,
|
|
749
|
+
agentDir: (0, import_path7.join)(agentRootDir, "agent"),
|
|
750
|
+
source: "json-overrides-resolver"
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
function resolveFallbackPaths(agentId, folderNameRaw) {
|
|
754
|
+
if (typeof folderNameRaw === "string" && folderNameRaw.trim()) {
|
|
755
|
+
const folderName = folderNameRaw.trim().toLowerCase();
|
|
756
|
+
assertSafeAgentFolderName(folderName);
|
|
757
|
+
return {
|
|
758
|
+
agentRootDir: stripTrailingSep((0, import_path7.normalize)(resolveAgentRootByFolderName(folderName))),
|
|
759
|
+
workspaceDir: stripTrailingSep((0, import_path7.normalize)(resolveAgentWorkspaceByFolderName(folderName))),
|
|
760
|
+
agentDir: stripTrailingSep((0, import_path7.normalize)(resolveAgentDirByFolderName(folderName))),
|
|
761
|
+
source: "folder-name"
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
const agentRootDir = stripTrailingSep((0, import_path7.normalize)(resolveAgentDir(agentId)));
|
|
765
|
+
return {
|
|
766
|
+
agentRootDir,
|
|
767
|
+
workspaceDir: stripTrailingSep((0, import_path7.normalize)(resolveAgentWorkspace(agentId))),
|
|
768
|
+
agentDir: stripTrailingSep((0, import_path7.normalize)((0, import_path7.join)(agentRootDir, "agent"))),
|
|
769
|
+
source: "resolver"
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
function normalizeJsonHint(raw) {
|
|
773
|
+
if (typeof raw !== "string") {
|
|
774
|
+
return null;
|
|
775
|
+
}
|
|
776
|
+
const trimmed = raw.trim();
|
|
777
|
+
if (!trimmed) {
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
if (!(0, import_path7.isAbsolute)(trimmed)) {
|
|
781
|
+
return null;
|
|
782
|
+
}
|
|
783
|
+
if (trimmed.includes("\0")) {
|
|
784
|
+
return null;
|
|
785
|
+
}
|
|
786
|
+
return stripTrailingSep((0, import_path7.normalize)(trimmed));
|
|
787
|
+
}
|
|
788
|
+
function stripTrailingSep(p) {
|
|
789
|
+
return p.replace(/[\\/]+$/, "");
|
|
790
|
+
}
|
|
791
|
+
function samePath(a, b) {
|
|
792
|
+
const isWin = process.platform === "win32";
|
|
793
|
+
const na = isWin ? a.toLowerCase() : a;
|
|
794
|
+
const nb = isWin ? b.toLowerCase() : b;
|
|
795
|
+
return na === nb;
|
|
796
|
+
}
|
|
797
|
+
function isUnderAgentsRoot(candidate) {
|
|
798
|
+
const agentsRoot = stripTrailingSep((0, import_path7.normalize)(resolveXkPath("agents"))) + import_path7.sep;
|
|
799
|
+
const isWin = process.platform === "win32";
|
|
800
|
+
const c = isWin ? candidate.toLowerCase() : candidate;
|
|
801
|
+
const r = isWin ? agentsRoot.toLowerCase() : agentsRoot;
|
|
802
|
+
return c.startsWith(r);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// src/mobile/agent-shop/migrate-agent-ids-to-folder-names.ts
|
|
806
|
+
var import_node_fs2 = require("fs");
|
|
807
|
+
var import_node_path3 = require("path");
|
|
808
|
+
function asRecord2(value) {
|
|
809
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
810
|
+
}
|
|
811
|
+
function clean2(value) {
|
|
812
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
813
|
+
}
|
|
814
|
+
function readLegacyAgentId(entry) {
|
|
815
|
+
const params = asRecord2(entry.params);
|
|
816
|
+
return clean2(params.xkzoomLegacyId);
|
|
817
|
+
}
|
|
818
|
+
function readConfig(configPath) {
|
|
819
|
+
if (!(0, import_node_fs2.existsSync)(configPath)) {
|
|
820
|
+
return null;
|
|
821
|
+
}
|
|
822
|
+
try {
|
|
823
|
+
return asRecord2(JSON.parse((0, import_node_fs2.readFileSync)(configPath, "utf8")));
|
|
824
|
+
} catch {
|
|
825
|
+
return null;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
function findRuntimeAgentEntryByAnyId(agentId, list) {
|
|
829
|
+
const needle = clean2(agentId);
|
|
830
|
+
if (!needle) {
|
|
831
|
+
return null;
|
|
832
|
+
}
|
|
833
|
+
const byId = list.find((entry) => clean2(entry.id) === needle);
|
|
834
|
+
if (byId) {
|
|
835
|
+
return byId;
|
|
836
|
+
}
|
|
837
|
+
return list.find((entry) => readLegacyAgentId(entry) === needle) ?? list.find((entry) => readPersistedAgentFolderName(entry) === needle) ?? null;
|
|
838
|
+
}
|
|
839
|
+
function resolveCanonicalRuntimeAgentId(agentId) {
|
|
840
|
+
const configPath = resolveXkPath("xkzoom.json");
|
|
841
|
+
const config = readConfig(configPath);
|
|
842
|
+
const list = Array.isArray(config?.agents?.list) ? config.agents.list : [];
|
|
843
|
+
const entry = findRuntimeAgentEntryByAnyId(agentId, list);
|
|
844
|
+
const canonical = clean2(entry?.id);
|
|
845
|
+
if (canonical && isSafeAgentId(canonical)) {
|
|
846
|
+
assertSafeAgentId(canonical);
|
|
847
|
+
return canonical;
|
|
848
|
+
}
|
|
849
|
+
assertSafeAgentId(agentId);
|
|
850
|
+
return agentId;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
// src/mobile/agent-shop/runtime-agent-paths.ts
|
|
854
|
+
function clean3(value) {
|
|
855
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
856
|
+
}
|
|
857
|
+
function readRuntimeAgentEntry(agentId) {
|
|
858
|
+
const configPath = resolveXkPath("xkzoom.json");
|
|
859
|
+
if (!(0, import_node_fs3.existsSync)(configPath)) {
|
|
860
|
+
return null;
|
|
861
|
+
}
|
|
862
|
+
try {
|
|
863
|
+
const parsed = JSON.parse((0, import_node_fs3.readFileSync)(configPath, "utf8"));
|
|
864
|
+
const list = Array.isArray(parsed.agents?.list) ? parsed.agents.list : [];
|
|
865
|
+
return list.find((entry) => clean3(entry.id) === agentId) ?? null;
|
|
866
|
+
} catch {
|
|
867
|
+
return null;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
function readRuntimeAgentPathHints(agentId) {
|
|
871
|
+
const canonicalAgentId = resolveCanonicalRuntimeAgentId(agentId);
|
|
872
|
+
const entry = readRuntimeAgentEntry(canonicalAgentId);
|
|
873
|
+
if (!entry) {
|
|
874
|
+
return {};
|
|
875
|
+
}
|
|
876
|
+
let folderNameHint;
|
|
877
|
+
try {
|
|
878
|
+
folderNameHint = readPersistedAgentFolderName(entry) ?? void 0;
|
|
879
|
+
} catch {
|
|
880
|
+
folderNameHint = void 0;
|
|
881
|
+
}
|
|
882
|
+
return {
|
|
883
|
+
workspaceHint: clean3(entry.workspace),
|
|
884
|
+
folderNameHint,
|
|
885
|
+
agentDirHint: clean3(entry.agentDir)
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
function resolveRuntimeAgentPaths(agentId, options) {
|
|
889
|
+
const canonicalAgentId = resolveCanonicalRuntimeAgentId(agentId);
|
|
890
|
+
const hints = readRuntimeAgentPathHints(canonicalAgentId);
|
|
891
|
+
return resolveCanonicalAgentPaths(canonicalAgentId, {
|
|
892
|
+
jsonHint: hints.workspaceHint,
|
|
893
|
+
folderName: hints.folderNameHint,
|
|
894
|
+
requireUnderStateRoot: options?.requireUnderStateRoot
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// src/mobile/native-provider-api-key.ts
|
|
899
|
+
var PROVIDER_ENV_KEY_CANDIDATES = {
|
|
900
|
+
minimax: ["MINIMAX_API_KEY"],
|
|
901
|
+
"minimax-portal": ["MINIMAX_OAUTH_TOKEN", "MINIMAX_API_KEY"],
|
|
902
|
+
modelstudio: ["MODELSTUDIO_API_KEY", "DASHSCOPE_API_KEY"],
|
|
903
|
+
openai: ["OPENAI_API_KEY"],
|
|
904
|
+
anthropic: ["ANTHROPIC_API_KEY", "ANTHROPIC_OAUTH_TOKEN"],
|
|
905
|
+
xai: ["XAI_API_KEY"]
|
|
906
|
+
};
|
|
907
|
+
function resolveAgentAuthProfilesPath(agentId) {
|
|
908
|
+
const id = typeof agentId === "string" && agentId.trim() ? agentId.trim() : "zoom";
|
|
909
|
+
const { agentDir } = resolveRuntimeAgentPaths(id, { requireUnderStateRoot: true });
|
|
910
|
+
return import_node_path4.default.join(agentDir, "auth-profiles.json");
|
|
911
|
+
}
|
|
912
|
+
function readAuthProfileStore(agentId) {
|
|
913
|
+
const filePath = resolveAgentAuthProfilesPath(agentId);
|
|
914
|
+
try {
|
|
915
|
+
if (!import_node_fs4.default.existsSync(filePath)) {
|
|
916
|
+
return null;
|
|
917
|
+
}
|
|
918
|
+
const raw = JSON.parse(import_node_fs4.default.readFileSync(filePath, "utf8"));
|
|
919
|
+
return isGatewayConfigRecord(raw) ? raw : null;
|
|
920
|
+
} catch {
|
|
921
|
+
return null;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
function collectProfileIdCandidates(cfg, providerId, store) {
|
|
925
|
+
const out = [];
|
|
926
|
+
const seen = /* @__PURE__ */ new Set();
|
|
927
|
+
const push = (id) => {
|
|
928
|
+
const t = typeof id === "string" ? id.trim() : "";
|
|
929
|
+
if (!t || seen.has(t)) {
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
seen.add(t);
|
|
933
|
+
out.push(t);
|
|
934
|
+
};
|
|
935
|
+
const lastGood = store?.lastGood?.[providerId];
|
|
936
|
+
push(lastGood);
|
|
937
|
+
const authProfiles = isGatewayConfigRecord(cfg) && isGatewayConfigRecord(cfg.auth) && isGatewayConfigRecord(cfg.auth.profiles) ? cfg.auth.profiles : void 0;
|
|
938
|
+
if (authProfiles) {
|
|
939
|
+
for (const [profileId, meta] of Object.entries(authProfiles)) {
|
|
940
|
+
if (isGatewayConfigRecord(meta) && gatewayConfigStringProp(meta, "provider") === providerId) {
|
|
941
|
+
push(profileId);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
if (store?.profiles) {
|
|
946
|
+
for (const [profileId, meta] of Object.entries(store.profiles)) {
|
|
947
|
+
if (meta?.provider === providerId) {
|
|
948
|
+
push(profileId);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
return out;
|
|
953
|
+
}
|
|
954
|
+
function readApiKeyFromAuthProfileStore(cfg, providerId, agentId) {
|
|
955
|
+
const store = readAuthProfileStore(agentId);
|
|
956
|
+
if (!store?.profiles) {
|
|
957
|
+
return "";
|
|
958
|
+
}
|
|
959
|
+
for (const profileId of collectProfileIdCandidates(cfg, providerId, store)) {
|
|
960
|
+
const entry = store.profiles[profileId];
|
|
961
|
+
if (!entry || entry.type !== "api_key") {
|
|
962
|
+
continue;
|
|
963
|
+
}
|
|
964
|
+
const key = typeof entry.key === "string" ? entry.key.trim() : "";
|
|
965
|
+
if (key) {
|
|
966
|
+
return key;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
for (const profileId of collectProfileIdCandidates(cfg, providerId, store)) {
|
|
970
|
+
const entry = store.profiles[profileId];
|
|
971
|
+
if (!entry || entry.type !== "oauth") {
|
|
972
|
+
continue;
|
|
973
|
+
}
|
|
974
|
+
const access = typeof entry.access === "string" ? entry.access.trim() : "";
|
|
975
|
+
if (access) {
|
|
976
|
+
return access;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
return "";
|
|
980
|
+
}
|
|
981
|
+
function readApiKeyFromEnv(providerId) {
|
|
982
|
+
const candidates = PROVIDER_ENV_KEY_CANDIDATES[providerId] ?? [
|
|
983
|
+
`${providerId.toUpperCase().replace(/[^A-Z0-9]/g, "_")}_API_KEY`
|
|
984
|
+
];
|
|
985
|
+
for (const envKey of candidates) {
|
|
986
|
+
const v = process.env[envKey]?.trim();
|
|
987
|
+
if (v) {
|
|
988
|
+
return v;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
return "";
|
|
992
|
+
}
|
|
993
|
+
function resolveNativeProviderApiKeySync(cfg, providerId, agentId) {
|
|
994
|
+
return readApiKeyFromAuthProfileStore(cfg, providerId, agentId) || readApiKeyFromEnv(providerId);
|
|
995
|
+
}
|
|
996
|
+
function diagnoseNativeReplyRouteMiss(cfg, agentId, input) {
|
|
997
|
+
if (!input.streamingEnabled || (input.requestType ?? "text") !== "text" || typeof input.content === "string" && input.content.trim().startsWith("/") || input.hasInboundMedia || input.hasResolvedUpload) {
|
|
998
|
+
return { reason: "guards" };
|
|
999
|
+
}
|
|
1000
|
+
if (!input.allowNativeToolLoopOverride && gatewayAgentWantsFullToolLoop(cfg, agentId)) {
|
|
1001
|
+
return { reason: "gateway_tool_loop" };
|
|
1002
|
+
}
|
|
1003
|
+
const agents = isGatewayConfigRecord(cfg) && isGatewayConfigRecord(cfg.agents) ? cfg.agents : void 0;
|
|
1004
|
+
const defaults = agents && isGatewayConfigRecord(agents.defaults) ? agents.defaults : void 0;
|
|
1005
|
+
const list = agents && Array.isArray(agents.list) ? agents.list : [];
|
|
1006
|
+
const agent = agentId ? list.find((entry) => isGatewayConfigRecord(entry) && gatewayConfigStringProp(entry, "id") === agentId) : void 0;
|
|
1007
|
+
let modelKey = "";
|
|
1008
|
+
if (isGatewayConfigRecord(agent?.model) && typeof agent.model.primary === "string") {
|
|
1009
|
+
modelKey = agent.model.primary.trim();
|
|
1010
|
+
} else if (isGatewayConfigRecord(defaults?.model) && typeof defaults.model.primary === "string") {
|
|
1011
|
+
modelKey = defaults.model.primary.trim();
|
|
1012
|
+
} else if (typeof defaults?.model === "string") {
|
|
1013
|
+
modelKey = defaults.model.trim();
|
|
1014
|
+
}
|
|
1015
|
+
const slash = modelKey.indexOf("/");
|
|
1016
|
+
if (slash <= 0) {
|
|
1017
|
+
return { reason: "no_model" };
|
|
1018
|
+
}
|
|
1019
|
+
const providerId = modelKey.slice(0, slash);
|
|
1020
|
+
const model = modelKey.slice(slash + 1);
|
|
1021
|
+
const providers = isGatewayConfigRecord(cfg) && isGatewayConfigRecord(cfg.models) && isGatewayConfigRecord(cfg.models.providers) ? cfg.models.providers : void 0;
|
|
1022
|
+
const provider = providers?.[providerId];
|
|
1023
|
+
if (!isGatewayConfigRecord(provider)) {
|
|
1024
|
+
return { reason: "no_model", providerId, model };
|
|
1025
|
+
}
|
|
1026
|
+
const api = gatewayConfigStringProp(provider, "api");
|
|
1027
|
+
if (api !== "openai-completions" && api !== "anthropic-messages") {
|
|
1028
|
+
return { reason: "unsupported_api", providerId, api, model };
|
|
1029
|
+
}
|
|
1030
|
+
const baseUrl = gatewayConfigStringProp(provider, "baseUrl");
|
|
1031
|
+
if (!baseUrl) {
|
|
1032
|
+
return { reason: "missing_base_url", providerId, api, model };
|
|
1033
|
+
}
|
|
1034
|
+
const inlineKey = gatewayConfigStringProp(provider, "apiKey");
|
|
1035
|
+
const resolvedKey = inlineKey || resolveNativeProviderApiKeySync(cfg, providerId, agentId);
|
|
1036
|
+
if (!resolvedKey) {
|
|
1037
|
+
return { reason: "missing_api_key", providerId, api, model };
|
|
1038
|
+
}
|
|
1039
|
+
return { reason: "guards" };
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// src/mobile/memory-runtime-v2/provider-acceleration.ts
|
|
1043
|
+
var import_node_crypto = require("crypto");
|
|
1044
|
+
|
|
1045
|
+
// src/mobile/memory-runtime-v2/storage.ts
|
|
1046
|
+
var import_node_fs5 = require("fs");
|
|
1047
|
+
var import_node_path5 = __toESM(require("path"));
|
|
1048
|
+
|
|
1049
|
+
// src/mobile/openai-completions-provider-adapter.ts
|
|
1050
|
+
function defaultNormalizeToolsForBody(tools) {
|
|
1051
|
+
return tools;
|
|
1052
|
+
}
|
|
1053
|
+
function openAiToolChoiceForPolicy(policy) {
|
|
1054
|
+
switch (policy.kind) {
|
|
1055
|
+
case "auto":
|
|
1056
|
+
return void 0;
|
|
1057
|
+
case "none":
|
|
1058
|
+
return "none";
|
|
1059
|
+
case "required":
|
|
1060
|
+
return "required";
|
|
1061
|
+
case "tool":
|
|
1062
|
+
return {
|
|
1063
|
+
type: "function",
|
|
1064
|
+
function: { name: policy.name }
|
|
1065
|
+
};
|
|
1066
|
+
default:
|
|
1067
|
+
return void 0;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
function defaultForcedToolChoiceSupported() {
|
|
1071
|
+
return true;
|
|
1072
|
+
}
|
|
1073
|
+
function defaultResolveToolChoiceForBody(input) {
|
|
1074
|
+
if (input.policy.kind !== "auto" && !defaultForcedToolChoiceSupported()) {
|
|
1075
|
+
return void 0;
|
|
1076
|
+
}
|
|
1077
|
+
return openAiToolChoiceForPolicy(input.policy);
|
|
1078
|
+
}
|
|
1079
|
+
function resolveGenericOpenAiChatCompletionsUrl(baseUrl) {
|
|
1080
|
+
const raw = baseUrl.trim();
|
|
1081
|
+
const queryStart = raw.indexOf("?");
|
|
1082
|
+
const path4 = (queryStart >= 0 ? raw.slice(0, queryStart) : raw).replace(/\/+$/, "");
|
|
1083
|
+
const query = queryStart >= 0 ? raw.slice(queryStart) : "";
|
|
1084
|
+
const lowerPath = path4.toLowerCase();
|
|
1085
|
+
if (lowerPath.endsWith("/chat/completions")) {
|
|
1086
|
+
return `${path4}${query}`;
|
|
1087
|
+
}
|
|
1088
|
+
if (lowerPath.endsWith("/openai")) {
|
|
1089
|
+
return `${path4}/chat/completions${query}`;
|
|
1090
|
+
}
|
|
1091
|
+
if (lowerPath.endsWith("/v1")) {
|
|
1092
|
+
return `${path4}/chat/completions${query}`;
|
|
1093
|
+
}
|
|
1094
|
+
return `${path4}/v1/chat/completions${query}`;
|
|
1095
|
+
}
|
|
1096
|
+
function buildBearerOpenAiHeaders(cfg) {
|
|
1097
|
+
return {
|
|
1098
|
+
"Content-Type": "application/json",
|
|
1099
|
+
Authorization: `Bearer ${cfg.apiKey}`
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
function isOpenAiDashScopeStyleBaseUrl(baseUrl) {
|
|
1103
|
+
const u = baseUrl.trim().toLowerCase();
|
|
1104
|
+
return u.includes("dashscope.aliyuncs.com") || u.includes("dashscope-us.aliyuncs.com") || u.includes("dashscope-intl.aliyuncs.com") || u.includes(".maas.aliyuncs.com");
|
|
1105
|
+
}
|
|
1106
|
+
function isOpenAiGlmStyleProvider(cfg) {
|
|
1107
|
+
const pid = (cfg.providerId ?? "").trim().toLowerCase();
|
|
1108
|
+
const base = cfg.baseUrl.trim().toLowerCase();
|
|
1109
|
+
return pid.includes("glm") || pid.includes("bigmodel") || pid.includes("zhipu") || base.includes("open.bigmodel.cn");
|
|
1110
|
+
}
|
|
1111
|
+
function resolveDeepSeekChatCompletionsUrl(baseUrl) {
|
|
1112
|
+
const raw = baseUrl.trim();
|
|
1113
|
+
const queryStart = raw.indexOf("?");
|
|
1114
|
+
const path4 = (queryStart >= 0 ? raw.slice(0, queryStart) : raw).replace(/\/+$/, "");
|
|
1115
|
+
const query = queryStart >= 0 ? raw.slice(queryStart) : "";
|
|
1116
|
+
const lowerPath = path4.toLowerCase();
|
|
1117
|
+
if (lowerPath.endsWith("/chat/completions")) {
|
|
1118
|
+
return `${path4}${query}`;
|
|
1119
|
+
}
|
|
1120
|
+
if (lowerPath.endsWith("/beta")) {
|
|
1121
|
+
return `${path4}/chat/completions${query}`;
|
|
1122
|
+
}
|
|
1123
|
+
if (lowerPath.endsWith("/v1")) {
|
|
1124
|
+
return `${path4.slice(0, -3)}/chat/completions${query}`;
|
|
1125
|
+
}
|
|
1126
|
+
return `${path4}/chat/completions${query}`;
|
|
1127
|
+
}
|
|
1128
|
+
function resolveGlmChatCompletionsUrl(baseUrl) {
|
|
1129
|
+
const raw = baseUrl.trim();
|
|
1130
|
+
const queryStart = raw.indexOf("?");
|
|
1131
|
+
const path4 = (queryStart >= 0 ? raw.slice(0, queryStart) : raw).replace(/\/+$/, "");
|
|
1132
|
+
const query = queryStart >= 0 ? raw.slice(queryStart) : "";
|
|
1133
|
+
const lowerPath = path4.toLowerCase();
|
|
1134
|
+
if (lowerPath.endsWith("/chat/completions")) {
|
|
1135
|
+
return `${path4}${query}`;
|
|
1136
|
+
}
|
|
1137
|
+
return `${path4}/chat/completions${query}`;
|
|
1138
|
+
}
|
|
1139
|
+
function isOpenAiMinimaxStyleProvider(cfg) {
|
|
1140
|
+
const pid = (cfg.providerId ?? "").trim().toLowerCase();
|
|
1141
|
+
const base = cfg.baseUrl.trim().toLowerCase();
|
|
1142
|
+
return pid.includes("minimax") || base.includes("minimax");
|
|
1143
|
+
}
|
|
1144
|
+
function openAiCompletionsBodyExtrasForRun(cfg, reasoningMode) {
|
|
1145
|
+
const isGlm = isOpenAiGlmStyleProvider(cfg);
|
|
1146
|
+
const extras = cfg.openAiCompletionsBodyExtras !== void 0 ? { ...cfg.openAiCompletionsBodyExtras } : isGlm ? { tool_stream: true } : isOpenAiMinimaxStyleProvider(cfg) ? { reasoning_split: true } : isOpenAiDashScopeStyleBaseUrl(cfg.baseUrl) ? { enable_thinking: true } : {};
|
|
1147
|
+
if (isGlm) {
|
|
1148
|
+
if (!Object.prototype.hasOwnProperty.call(extras, "tool_stream")) {
|
|
1149
|
+
extras.tool_stream = true;
|
|
1150
|
+
}
|
|
1151
|
+
if (!Object.prototype.hasOwnProperty.call(extras, "thinking")) {
|
|
1152
|
+
extras.thinking = { type: reasoningMode === "on" ? "enabled" : "disabled" };
|
|
1153
|
+
}
|
|
1154
|
+
return extras;
|
|
1155
|
+
}
|
|
1156
|
+
if (reasoningMode !== "on") {
|
|
1157
|
+
return extras;
|
|
1158
|
+
}
|
|
1159
|
+
if (Object.prototype.hasOwnProperty.call(extras, "enable_thinking")) {
|
|
1160
|
+
return extras;
|
|
1161
|
+
}
|
|
1162
|
+
if (Object.prototype.hasOwnProperty.call(extras, "reasoning_split")) {
|
|
1163
|
+
return extras;
|
|
1164
|
+
}
|
|
1165
|
+
if (isOpenAiMinimaxStyleProvider(cfg)) {
|
|
1166
|
+
return { ...extras, reasoning_split: true };
|
|
1167
|
+
}
|
|
1168
|
+
if (isOpenAiDashScopeStyleBaseUrl(cfg.baseUrl)) {
|
|
1169
|
+
return { ...extras, enable_thinking: true };
|
|
1170
|
+
}
|
|
1171
|
+
return extras;
|
|
1172
|
+
}
|
|
1173
|
+
var genericOpenAiCompletionsAdapter = {
|
|
1174
|
+
id: "generic",
|
|
1175
|
+
resolveChatCompletionsUrl: resolveGenericOpenAiChatCompletionsUrl,
|
|
1176
|
+
buildHeaders: buildBearerOpenAiHeaders,
|
|
1177
|
+
bodyExtrasForRun: openAiCompletionsBodyExtrasForRun,
|
|
1178
|
+
forcedToolChoiceSupported: defaultForcedToolChoiceSupported,
|
|
1179
|
+
resolveToolChoiceForBody: defaultResolveToolChoiceForBody,
|
|
1180
|
+
normalizeToolsForBody: defaultNormalizeToolsForBody
|
|
1181
|
+
};
|
|
1182
|
+
var dashscopeOpenAiCompletionsAdapter = {
|
|
1183
|
+
...genericOpenAiCompletionsAdapter,
|
|
1184
|
+
id: "dashscope"
|
|
1185
|
+
};
|
|
1186
|
+
var deepSeekOpenAiCompletionsAdapter = {
|
|
1187
|
+
...genericOpenAiCompletionsAdapter,
|
|
1188
|
+
id: "deepseek",
|
|
1189
|
+
resolveChatCompletionsUrl: resolveDeepSeekChatCompletionsUrl
|
|
1190
|
+
};
|
|
1191
|
+
var geminiOpenAiCompletionsAdapter = {
|
|
1192
|
+
...genericOpenAiCompletionsAdapter,
|
|
1193
|
+
id: "gemini"
|
|
1194
|
+
};
|
|
1195
|
+
var glmOpenAiCompletionsAdapter = {
|
|
1196
|
+
...genericOpenAiCompletionsAdapter,
|
|
1197
|
+
id: "glm",
|
|
1198
|
+
resolveChatCompletionsUrl: resolveGlmChatCompletionsUrl,
|
|
1199
|
+
bodyExtrasForRun: openAiCompletionsBodyExtrasForRun,
|
|
1200
|
+
forcedToolChoiceSupported() {
|
|
1201
|
+
return false;
|
|
1202
|
+
},
|
|
1203
|
+
resolveToolChoiceForBody(input) {
|
|
1204
|
+
if (input.policy.kind === "auto") {
|
|
1205
|
+
return void 0;
|
|
1206
|
+
}
|
|
1207
|
+
return void 0;
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
var minimaxOpenAiCompletionsAdapter = {
|
|
1211
|
+
...genericOpenAiCompletionsAdapter,
|
|
1212
|
+
id: "minimax"
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1215
|
+
// src/mobile/native-request-diagnostics.ts
|
|
1216
|
+
var PROTOCOL_FALLBACK_MAX_TOKENS = 16384;
|
|
1217
|
+
var RETRYABLE_NATIVE_FETCH_RE = new RegExp(
|
|
1218
|
+
[
|
|
1219
|
+
"fetch failed",
|
|
1220
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
1221
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
1222
|
+
"UND_ERR_SOCKET",
|
|
1223
|
+
"ECONNRESET",
|
|
1224
|
+
"ETIMEDOUT",
|
|
1225
|
+
"ECONNREFUSED",
|
|
1226
|
+
"ENOTFOUND",
|
|
1227
|
+
"EAI_AGAIN",
|
|
1228
|
+
"socket hang up",
|
|
1229
|
+
"network connection lost",
|
|
1230
|
+
"network request failed"
|
|
1231
|
+
].join("|"),
|
|
1232
|
+
"i"
|
|
1233
|
+
);
|
|
1234
|
+
|
|
1235
|
+
// src/mobile/native-openai-text-stream.ts
|
|
1236
|
+
var isRecord = isGatewayConfigRecord;
|
|
1237
|
+
function resolveOpenAiCompletionsBodyExtras(provider, baseUrl) {
|
|
1238
|
+
if (provider && Object.prototype.hasOwnProperty.call(provider, "openAiCompletionsBodyExtras")) {
|
|
1239
|
+
const raw = provider.openAiCompletionsBodyExtras;
|
|
1240
|
+
if (raw === null) {
|
|
1241
|
+
return {};
|
|
1242
|
+
}
|
|
1243
|
+
return isRecord(raw) ? { ...raw } : {};
|
|
1244
|
+
}
|
|
1245
|
+
if (isNativeOpenAiDashScopeStyleBaseUrl(baseUrl)) {
|
|
1246
|
+
return { enable_thinking: true };
|
|
1247
|
+
}
|
|
1248
|
+
return {};
|
|
1249
|
+
}
|
|
1250
|
+
function resolveOpenAiCompletionsToolsFromProvider(provider) {
|
|
1251
|
+
if (!provider || !Object.prototype.hasOwnProperty.call(provider, "openAiCompletionsTools")) {
|
|
1252
|
+
return void 0;
|
|
1253
|
+
}
|
|
1254
|
+
const raw = provider.openAiCompletionsTools;
|
|
1255
|
+
if (raw === null || raw === void 0) {
|
|
1256
|
+
return void 0;
|
|
1257
|
+
}
|
|
1258
|
+
return Array.isArray(raw) && raw.length > 0 ? raw : void 0;
|
|
1259
|
+
}
|
|
1260
|
+
function resolveNativeOpenAiChatConfigFromGatewayConfig(cfg, options) {
|
|
1261
|
+
const slice = resolveProviderSliceFromGatewayConfig(cfg, {
|
|
1262
|
+
agentId: options?.agentId,
|
|
1263
|
+
api: "openai-completions"
|
|
1264
|
+
});
|
|
1265
|
+
if (!slice) {
|
|
1266
|
+
return null;
|
|
1267
|
+
}
|
|
1268
|
+
const baseUrl = resolveGatewayConfigString(slice.provider.baseUrl, cfg).replace(/\/+$/, "");
|
|
1269
|
+
const inlineApiKey = resolveGatewayConfigString(slice.provider.apiKey, cfg);
|
|
1270
|
+
const apiKey = inlineApiKey || (typeof options?.resolvedApiKey === "string" ? options.resolvedApiKey.trim() : "") || resolveNativeProviderApiKeySync(cfg, slice.providerId, options?.agentId);
|
|
1271
|
+
if (!baseUrl || !apiKey || !slice.model) {
|
|
1272
|
+
return null;
|
|
1273
|
+
}
|
|
1274
|
+
const openAiCompletionsBodyExtras = resolveOpenAiCompletionsBodyExtras(slice.provider, baseUrl);
|
|
1275
|
+
const openAiCompletionsTools = resolveOpenAiCompletionsToolsFromProvider(slice.provider);
|
|
1276
|
+
return {
|
|
1277
|
+
baseUrl,
|
|
1278
|
+
apiKey,
|
|
1279
|
+
model: slice.model,
|
|
1280
|
+
providerId: slice.providerId,
|
|
1281
|
+
...slice.metadata.contextWindow !== void 0 ? { contextWindow: slice.metadata.contextWindow } : {},
|
|
1282
|
+
...slice.metadata.maxTokens !== void 0 ? { maxTokens: slice.metadata.maxTokens } : {},
|
|
1283
|
+
openAiCompletionsBodyExtras,
|
|
1284
|
+
...openAiCompletionsTools ? { openAiCompletionsTools } : {}
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
function isNativeOpenAiDashScopeStyleBaseUrl(baseUrl) {
|
|
1288
|
+
return isOpenAiDashScopeStyleBaseUrl(baseUrl);
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
// src/mobile/native-stream-block-emit.ts
|
|
1292
|
+
var NATIVE_STREAM_BLOCK_MIN_CHARS_DEFAULT = 8;
|
|
1293
|
+
function readNativeStreamBlockMinChars(env = process.env) {
|
|
1294
|
+
const raw = (env.XKZOOM_NATIVE_STREAM_BLOCK_MIN_CHARS ?? "").trim();
|
|
1295
|
+
const n = Number.parseInt(raw, 10);
|
|
1296
|
+
if (Number.isFinite(n) && n >= 1) {
|
|
1297
|
+
return Math.min(n, 512);
|
|
1298
|
+
}
|
|
1299
|
+
return NATIVE_STREAM_BLOCK_MIN_CHARS_DEFAULT;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
// src/mobile/anthropic-incremental-deliver.ts
|
|
1303
|
+
var NATIVE_ANTHROPIC_STREAM_BLOCK_MIN_CHARS = readNativeStreamBlockMinChars();
|
|
1304
|
+
|
|
1305
|
+
// src/mobile/native-anthropic-messages-stream.ts
|
|
1306
|
+
function resolveAnthropicMessagesBodyExtras(provider) {
|
|
1307
|
+
if (provider && Object.prototype.hasOwnProperty.call(provider, "anthropicMessagesBodyExtras")) {
|
|
1308
|
+
const raw = provider.anthropicMessagesBodyExtras;
|
|
1309
|
+
if (raw === null) {
|
|
1310
|
+
return {};
|
|
1311
|
+
}
|
|
1312
|
+
return isGatewayConfigRecord(raw) ? { ...raw } : {};
|
|
1313
|
+
}
|
|
1314
|
+
return { max_tokens: PROTOCOL_FALLBACK_MAX_TOKENS };
|
|
1315
|
+
}
|
|
1316
|
+
function resolveNativeAnthropicMessagesConfigFromGatewayConfig(cfg, options) {
|
|
1317
|
+
const slice = resolveProviderSliceFromGatewayConfig(cfg, {
|
|
1318
|
+
agentId: options?.agentId,
|
|
1319
|
+
api: "anthropic-messages"
|
|
1320
|
+
});
|
|
1321
|
+
if (!slice) {
|
|
1322
|
+
return null;
|
|
1323
|
+
}
|
|
1324
|
+
const baseUrl = resolveGatewayConfigString(slice.provider.baseUrl, cfg).replace(/\/+$/, "");
|
|
1325
|
+
const inlineApiKey = resolveGatewayConfigString(slice.provider.apiKey, cfg);
|
|
1326
|
+
const apiKey = inlineApiKey || (typeof options?.resolvedApiKey === "string" ? options.resolvedApiKey.trim() : "") || resolveNativeProviderApiKeySync(cfg, slice.providerId, options?.agentId);
|
|
1327
|
+
if (!baseUrl || !apiKey || !slice.model) {
|
|
1328
|
+
return null;
|
|
1329
|
+
}
|
|
1330
|
+
const authHeader = slice.provider.authHeader === true;
|
|
1331
|
+
return {
|
|
1332
|
+
baseUrl,
|
|
1333
|
+
apiKey,
|
|
1334
|
+
model: slice.model,
|
|
1335
|
+
providerId: slice.providerId,
|
|
1336
|
+
...slice.metadata.contextWindow !== void 0 ? { contextWindow: slice.metadata.contextWindow } : {},
|
|
1337
|
+
...slice.metadata.maxTokens !== void 0 ? { maxTokens: slice.metadata.maxTokens } : {},
|
|
1338
|
+
...authHeader ? { authHeader: true } : {},
|
|
1339
|
+
anthropicMessagesBodyExtras: resolveAnthropicMessagesBodyExtras(slice.provider)
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
// src/mobile/native-reply-route.ts
|
|
1344
|
+
function envFlagOn(raw) {
|
|
1345
|
+
if (raw === void 0 || raw === null || String(raw).trim() === "") {
|
|
1346
|
+
return false;
|
|
1347
|
+
}
|
|
1348
|
+
const t = String(raw).trim().toLowerCase();
|
|
1349
|
+
return t === "1" || t === "true" || t === "yes" || t === "on";
|
|
1350
|
+
}
|
|
1351
|
+
function nativeReplyTransportForced(env = process.env) {
|
|
1352
|
+
return envFlagOn(env.XKZOOM_XRE_NATIVE_REPLY_ALWAYS);
|
|
1353
|
+
}
|
|
1354
|
+
function nativeAnthropicTurnLoopEnabled(env = process.env) {
|
|
1355
|
+
return envFlagOn(env.XKZOOM_NATIVE_ANTHROPIC_TURN);
|
|
1356
|
+
}
|
|
1357
|
+
function nativeOwnedTurnOverridesHostToolLoop(env = process.env) {
|
|
1358
|
+
return nativeReplyTransportForced(env) && nativeAnthropicTurnLoopEnabled(env);
|
|
1359
|
+
}
|
|
1360
|
+
function shouldResolveNativeReplyRouteAsync(cfg, agentId, hasSyncRoute) {
|
|
1361
|
+
if (hasSyncRoute) {
|
|
1362
|
+
return false;
|
|
1363
|
+
}
|
|
1364
|
+
if (!gatewayAgentWantsFullToolLoop(cfg, agentId)) {
|
|
1365
|
+
return true;
|
|
1366
|
+
}
|
|
1367
|
+
return nativeOwnedTurnOverridesHostToolLoop();
|
|
1368
|
+
}
|
|
1369
|
+
function sharedRouteGuards(input) {
|
|
1370
|
+
if (!input.streamingEnabled) {
|
|
1371
|
+
return false;
|
|
1372
|
+
}
|
|
1373
|
+
const t = input.requestType ?? "text";
|
|
1374
|
+
const mediaInbound = Boolean(input.hasInboundMedia || input.hasResolvedUpload);
|
|
1375
|
+
const typeOk = t === "text" || (t === "image" || t === "file") && mediaInbound;
|
|
1376
|
+
if (!typeOk) {
|
|
1377
|
+
return false;
|
|
1378
|
+
}
|
|
1379
|
+
if (typeof input.content === "string" && input.content.trim().startsWith("/")) {
|
|
1380
|
+
return false;
|
|
1381
|
+
}
|
|
1382
|
+
return true;
|
|
1383
|
+
}
|
|
1384
|
+
function resolveNativeReplyRoute(input) {
|
|
1385
|
+
if (!sharedRouteGuards(input)) {
|
|
1386
|
+
return null;
|
|
1387
|
+
}
|
|
1388
|
+
if (!nativeReplyTransportForced()) {
|
|
1389
|
+
return null;
|
|
1390
|
+
}
|
|
1391
|
+
const openAiChat = resolveNativeOpenAiChatConfigFromGatewayConfig(input.cfg, { agentId: input.agentId });
|
|
1392
|
+
if (openAiChat) {
|
|
1393
|
+
return { platform: "openai-completions", chat: openAiChat };
|
|
1394
|
+
}
|
|
1395
|
+
const anthropicChat = resolveNativeAnthropicMessagesConfigFromGatewayConfig(input.cfg, {
|
|
1396
|
+
agentId: input.agentId
|
|
1397
|
+
});
|
|
1398
|
+
if (anthropicChat) {
|
|
1399
|
+
return { platform: "anthropic-messages", chat: anthropicChat };
|
|
1400
|
+
}
|
|
1401
|
+
return null;
|
|
1402
|
+
}
|
|
1403
|
+
async function resolveNativeReplyRouteAsync(input) {
|
|
1404
|
+
const syncRoute = resolveNativeReplyRoute(input);
|
|
1405
|
+
if (syncRoute) {
|
|
1406
|
+
return syncRoute;
|
|
1407
|
+
}
|
|
1408
|
+
if (!sharedRouteGuards(input)) {
|
|
1409
|
+
return null;
|
|
1410
|
+
}
|
|
1411
|
+
if (!nativeReplyTransportForced()) {
|
|
1412
|
+
return null;
|
|
1413
|
+
}
|
|
1414
|
+
const miss = diagnoseNativeReplyRouteMiss(input.cfg, input.agentId, {
|
|
1415
|
+
streamingEnabled: input.streamingEnabled,
|
|
1416
|
+
requestType: input.requestType,
|
|
1417
|
+
content: input.content,
|
|
1418
|
+
hasInboundMedia: input.hasInboundMedia,
|
|
1419
|
+
hasResolvedUpload: input.hasResolvedUpload,
|
|
1420
|
+
allowNativeToolLoopOverride: nativeOwnedTurnOverridesHostToolLoop()
|
|
1421
|
+
});
|
|
1422
|
+
if (miss.reason !== "missing_api_key" || !miss.providerId || !miss.api) {
|
|
1423
|
+
return null;
|
|
1424
|
+
}
|
|
1425
|
+
const { resolveNativeProviderApiKeyViaGatewayAuth: resolveNativeProviderApiKeyViaGatewayAuth2 } = await Promise.resolve().then(() => (init_native_provider_api_key_gateway(), native_provider_api_key_gateway_exports));
|
|
1426
|
+
const hostAuth = await resolveNativeProviderApiKeyViaGatewayAuth2(
|
|
1427
|
+
input.cfg,
|
|
1428
|
+
miss.providerId,
|
|
1429
|
+
input.agentId
|
|
1430
|
+
);
|
|
1431
|
+
if (!hostAuth?.apiKey) {
|
|
1432
|
+
return null;
|
|
1433
|
+
}
|
|
1434
|
+
if (miss.api === "anthropic-messages") {
|
|
1435
|
+
const chat = resolveNativeAnthropicMessagesConfigFromGatewayConfig(input.cfg, {
|
|
1436
|
+
agentId: input.agentId,
|
|
1437
|
+
resolvedApiKey: hostAuth.apiKey
|
|
1438
|
+
});
|
|
1439
|
+
return chat ? { platform: "anthropic-messages", chat } : null;
|
|
1440
|
+
}
|
|
1441
|
+
if (miss.api === "openai-completions") {
|
|
1442
|
+
const chat = resolveNativeOpenAiChatConfigFromGatewayConfig(input.cfg, {
|
|
1443
|
+
agentId: input.agentId,
|
|
1444
|
+
resolvedApiKey: hostAuth.apiKey
|
|
1445
|
+
});
|
|
1446
|
+
return chat ? { platform: "openai-completions", chat } : null;
|
|
1447
|
+
}
|
|
1448
|
+
return null;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
// src/mobile/dispatch/native-turn-route.ts
|
|
1452
|
+
async function resolveNativeDispatchReplyRoute(input) {
|
|
1453
|
+
const syncRoute = resolveNativeReplyRoute(input);
|
|
1454
|
+
if (syncRoute) {
|
|
1455
|
+
return syncRoute;
|
|
1456
|
+
}
|
|
1457
|
+
if (!shouldResolveNativeReplyRouteAsync(input.cfg, input.agentId, false)) {
|
|
1458
|
+
return null;
|
|
1459
|
+
}
|
|
1460
|
+
return resolveNativeReplyRouteAsync(input);
|
|
1461
|
+
}
|
|
1462
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1463
|
+
0 && (module.exports = {
|
|
1464
|
+
resolveNativeDispatchReplyRoute
|
|
1465
|
+
});
|