@qwen-code/qwen-code 0.26.2-preview.0 → 0.26.2-preview.1
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/chunks/{MaxSizedBox-K6YUM3DX.js → MaxSizedBox-EGHZ2BPF.js} +1 -1
- package/chunks/{StandaloneSessionPicker-75IC33SN.js → StandaloneSessionPicker-UVCW6YW3.js} +1 -1
- package/chunks/{acp-subagent-executor-3NHBJRPL.js → acp-subagent-executor-AQ7AWSD4.js} +1 -1
- package/chunks/{acpAgent-JT6KQPTH.js → acpAgent-IV7JAGD7.js} +3 -3
- package/chunks/{advisor-TI2UVEZK.js → advisor-UZ4TF65D.js} +1 -1
- package/chunks/{agent-SWIZZZMY.js → agent-CNLVAWDD.js} +1 -1
- package/chunks/{agent-headless-USWEJ4GW.js → agent-headless-ZJUJLUJS.js} +1 -1
- package/chunks/{agent-host-client-ZFIMQX33.js → agent-host-client-SN5V2KBH.js} +1 -1
- package/chunks/{agent-host-connections-LOFD7O7Q.js → agent-host-connections-VKMAJIIU.js} +1 -1
- package/chunks/{anthropicContentGenerator-HMLEI4FI.js → anthropicContentGenerator-QTJVPAMI.js} +1 -1
- package/chunks/{autofix-pr-NKR2VSLB.js → autofix-pr-U7GNSH27.js} +1 -1
- package/chunks/{batch-JQZ3TOHA.js → batch-MBEWETXN.js} +1 -1
- package/chunks/{bridge-EIWWT4P6.js → bridge-TEJLNYV3.js} +1 -1
- package/chunks/{channel-settings-store-FLRLUA67.js → channel-settings-store-QNCKWWBL.js} +1 -1
- package/chunks/{chunk-244YTFYD.js → chunk-23KDY7UW.js} +1 -1
- package/chunks/{chunk-7TDMQJTD.js → chunk-2DWWSMTV.js} +1 -1
- package/chunks/{chunk-UU2LTNSF.js → chunk-3IZMVLVZ.js} +1 -1
- package/chunks/{chunk-B6T4ESBM.js → chunk-3JI7IKJL.js} +1 -1
- package/chunks/{chunk-Y5TT2G3N.js → chunk-427MARCP.js} +1 -1
- package/chunks/{chunk-KX7JS2P7.js → chunk-4NNNGSQY.js} +3 -3
- package/chunks/{chunk-6TQS2WQO.js → chunk-4RM7KY3Z.js} +2 -2
- package/chunks/{chunk-YL3N2UGG.js → chunk-5X7S4AE6.js} +5 -5
- package/chunks/{chunk-K2HAY5PY.js → chunk-5XAECBED.js} +1 -1
- package/chunks/{chunk-VCHFBETO.js → chunk-66KKSLUO.js} +1 -1
- package/chunks/{chunk-BSJR2KEF.js → chunk-6CIIDUZW.js} +1 -1
- package/chunks/{chunk-22CLK7PK.js → chunk-7EBRMQYW.js} +1 -1
- package/chunks/{chunk-J4TFGZ4A.js → chunk-7FSC2NKA.js} +1 -1
- package/chunks/{chunk-6JFC5M6B.js → chunk-A5TAAMML.js} +1 -1
- package/chunks/{chunk-DHHACQVN.js → chunk-AOYSX44A.js} +1 -1
- package/chunks/{chunk-VFVZ2DY7.js → chunk-AZCMQ3DD.js} +2 -2
- package/chunks/{chunk-BQJXWIMR.js → chunk-B6F7CVBP.js} +1 -1
- package/chunks/{chunk-OVPEAKOQ.js → chunk-BDQOLT37.js} +1 -1
- package/chunks/{chunk-5SYUBQNO.js → chunk-BIWEUAKG.js} +1 -1
- package/chunks/{chunk-BZM66PQO.js → chunk-BJ5R7LOM.js} +1 -1
- package/chunks/{chunk-4R2OHBH3.js → chunk-BKUFRNME.js} +1 -1
- package/chunks/{chunk-NIYWNFVF.js → chunk-BNZSPX2I.js} +1 -1
- package/chunks/{chunk-FJV2ECNY.js → chunk-D2URRVOK.js} +1 -1
- package/chunks/{chunk-GT6CHVAI.js → chunk-DANP7CMW.js} +1 -1
- package/chunks/{chunk-FHFLD4DR.js → chunk-DBHLRZGI.js} +1 -1
- package/chunks/{chunk-Y2UXZJLM.js → chunk-DL7TKH2E.js} +2 -2
- package/chunks/{chunk-MCQE2U7N.js → chunk-DOWKH5OZ.js} +6 -6
- package/chunks/{chunk-UHRLBY3C.js → chunk-DPHQJPCU.js} +1 -1
- package/chunks/{chunk-PV2VT25U.js → chunk-DPNGBOI7.js} +1 -1
- package/chunks/{chunk-NCDNF7UJ.js → chunk-DXRXF4QD.js} +1 -1
- package/chunks/{chunk-OCVRMNEQ.js → chunk-DZ3GV34J.js} +1 -1
- package/chunks/{chunk-3QIAXWWW.js → chunk-EU2MKUK4.js} +1 -1
- package/chunks/{chunk-KMAVI6FB.js → chunk-EVBUXPGM.js} +1 -1
- package/chunks/{chunk-BVSTV4JM.js → chunk-F3ZRU2SA.js} +1 -1
- package/chunks/{chunk-TBZY477Y.js → chunk-FCZYH27X.js} +1 -1
- package/chunks/{chunk-JCOK67LT.js → chunk-FNDMWG43.js} +1 -1
- package/chunks/{chunk-5SF32OGU.js → chunk-GDXLJJSW.js} +1 -1
- package/chunks/{chunk-SO6FCPRI.js → chunk-GZYIXB7Y.js} +1 -1
- package/chunks/{chunk-WZPTWC7X.js → chunk-HHNAH4IH.js} +1 -1
- package/chunks/{chunk-7KCAOXNL.js → chunk-HOKROBQZ.js} +1 -1
- package/chunks/{chunk-34ZBUQJV.js → chunk-IGPAATQW.js} +1 -1
- package/chunks/{chunk-2ZTRKK2O.js → chunk-INFBJDWM.js} +1 -1
- package/chunks/{chunk-IEJ2CGRN.js → chunk-J3R7ZNSA.js} +1 -1
- package/chunks/{chunk-KT5MPRYB.js → chunk-JCRS367I.js} +1 -1
- package/chunks/{chunk-7JWJTRP6.js → chunk-JFVXZFMV.js} +1 -1
- package/chunks/{chunk-47LP4MBD.js → chunk-JKMGS2VD.js} +1 -1
- package/chunks/{chunk-WRJ3PMDZ.js → chunk-JUQ7T2MV.js} +1 -1
- package/chunks/{chunk-NZX3UWNF.js → chunk-KQ4TDFNE.js} +1 -1
- package/chunks/{chunk-X7D4VKMX.js → chunk-L6BKKN42.js} +1 -1
- package/chunks/{chunk-YG5HVFMY.js → chunk-L7Y6MOHS.js} +1 -1
- package/chunks/{chunk-UFTIUKD4.js → chunk-LGYXZJI3.js} +1 -1
- package/chunks/{chunk-JQGGILML.js → chunk-LPOEVTKD.js} +1 -1
- package/chunks/{chunk-5KI55A6S.js → chunk-LRXS7ZI2.js} +1 -1
- package/chunks/{chunk-CKVHEYXW.js → chunk-LYYVSCNL.js} +1 -1
- package/chunks/{chunk-LIIMQ4DI.js → chunk-LZNBHBAJ.js} +6 -6
- package/chunks/{chunk-H4GDEXMF.js → chunk-M3C6RDGC.js} +1 -1
- package/chunks/{chunk-KKKUB3RQ.js → chunk-MNVMHVQJ.js} +1 -1
- package/chunks/{chunk-2B3W7IQY.js → chunk-MVGQFFIK.js} +1 -1
- package/chunks/{chunk-Q35A2RGO.js → chunk-NC7BCZPQ.js} +1 -1
- package/chunks/{chunk-2ZOTG3NW.js → chunk-NE627MUW.js} +1 -1
- package/chunks/{chunk-W4P2EN3V.js → chunk-NZNRCPGE.js} +1 -1
- package/chunks/{chunk-YPDQJQ3S.js → chunk-P3M4WWRA.js} +1 -1
- package/chunks/{chunk-DVB36ASH.js → chunk-P534ONQN.js} +1 -1
- package/chunks/{chunk-EL5J4ESB.js → chunk-QF44NNSC.js} +1 -1
- package/chunks/{chunk-IQPJOBPI.js → chunk-QHGCDHNW.js} +1 -1
- package/chunks/{chunk-EVZC4KEQ.js → chunk-QWJX7NIP.js} +1 -1
- package/chunks/{chunk-J2TJL2F4.js → chunk-S53G54DW.js} +2 -2
- package/chunks/{chunk-3A6LFJJV.js → chunk-SMNFL3AD.js} +1 -1
- package/chunks/{chunk-WDO3K3P2.js → chunk-TOBNWST4.js} +1 -1
- package/chunks/{chunk-AVGJ4HE3.js → chunk-TQSBUHAM.js} +1 -1
- package/chunks/{chunk-ABUS7DNN.js → chunk-TW5QEP2J.js} +1 -1
- package/chunks/{chunk-WYM4Z4D5.js → chunk-UEB2F43V.js} +1 -1
- package/chunks/{chunk-FUUPMVD2.js → chunk-UPPE4I6H.js} +1 -1
- package/chunks/{chunk-UHBJVFZA.js → chunk-US42COBM.js} +1 -1
- package/chunks/{chunk-RMQNBSMK.js → chunk-UUY6XSQI.js} +1 -1
- package/chunks/{chunk-UVQUQNCA.js → chunk-UZI3IA27.js} +1 -1
- package/chunks/{chunk-SXJ2E33J.js → chunk-V6VMUJ47.js} +1 -1
- package/chunks/{chunk-5UFCNJGN.js → chunk-VG2ZINTO.js} +1 -1
- package/chunks/{chunk-JPPPJ2GN.js → chunk-VJI6MHWX.js} +1 -1
- package/chunks/{chunk-AUI7WVSU.js → chunk-VOBNHBCJ.js} +1 -1
- package/chunks/{chunk-3BNJDZHU.js → chunk-VUEZWMI4.js} +1 -1
- package/chunks/{chunk-LMNKCL55.js → chunk-W7ZX6WB3.js} +2 -2
- package/chunks/{chunk-HVS6V2UZ.js → chunk-WA2LKUVP.js} +1 -1
- package/chunks/{chunk-7APLU2XE.js → chunk-WFFCJ5PF.js} +1 -1
- package/chunks/{chunk-3TD4WAG5.js → chunk-WQY5GE65.js} +1 -1
- package/chunks/{chunk-3YWRMF6C.js → chunk-WSESLSKK.js} +1 -1
- package/chunks/{chunk-NILCQMZ7.js → chunk-XFJV5NYT.js} +1 -1
- package/chunks/{chunk-LGBGUITT.js → chunk-XIYLRIW4.js} +1 -1
- package/chunks/{chunk-KS74L67R.js → chunk-XQ2NYKJH.js} +1 -1
- package/chunks/{chunk-JB2NOB6W.js → chunk-Y3VRWG52.js} +1 -1
- package/chunks/{chunk-GVZ6D2NL.js → chunk-YBISME5B.js} +1 -1
- package/chunks/{chunk-2C2253QI.js → chunk-YJNWPSB3.js} +1 -1
- package/chunks/{chunk-O2T3GQ6F.js → chunk-YWVV5STA.js} +1 -1
- package/chunks/{chunk-MAQZSOHI.js → chunk-ZH4J3FL6.js} +1 -1
- package/chunks/{chunk-THNEKTPK.js → chunk-ZSKCF6DI.js} +1 -1
- package/chunks/{chunk-Z7BAHKO5.js → chunk-ZW6456SD.js} +1 -1
- package/chunks/{chunk-DMSZ2TB3.js → chunk-ZWM3LLT7.js} +1 -1
- package/chunks/{codex-subagent-executor-DQ5LQQWO.js → codex-subagent-executor-DWWT7246.js} +1 -1
- package/chunks/{config-utils-CY6HLKZ5.js → config-utils-NGZB522W.js} +1 -1
- package/chunks/{contextCommand-SGBWI7O6.js → contextCommand-7QCW2YNX.js} +1 -1
- package/chunks/{core-runtime-4DP27LCC.js → core-runtime-PSVNDJPD.js} +1 -1
- package/chunks/{create-sub-session-ECPDZMBX.js → create-sub-session-JTSEMEJE.js} +1 -1
- package/chunks/{cron-create-OO4OG3EI.js → cron-create-VGIDTUMX.js} +1 -1
- package/chunks/{daemon-git-worktree-guard-OYDNHT7P.js → daemon-git-worktree-guard-IQRGS7IH.js} +1 -1
- package/chunks/{daemon-status-provider-JGDLXPC6.js → daemon-status-provider-R4MYCYPG.js} +1 -1
- package/chunks/{daemon-trust-policy-5HRARS54.js → daemon-trust-policy-VAUKFZ2N.js} +1 -1
- package/chunks/{daemon-trust-policy-monitor-RM7FVIIC.js → daemon-trust-policy-monitor-E5HIO6RP.js} +1 -1
- package/chunks/{deferred-core-runtime-3CXBZIOG.js → deferred-core-runtime-FLOFQJPU.js} +1 -1
- package/chunks/{edit-DJPESAAY.js → edit-OOVQUGKV.js} +1 -1
- package/chunks/{enterPlanMode-IHBLRIF3.js → enterPlanMode-AUWVTQLT.js} +1 -1
- package/chunks/{environment-JN5SD347.js → environment-RM5OXYP4.js} +1 -1
- package/chunks/{errors-NUJCME3Y.js → errors-CLDJGHVD.js} +1 -1
- package/chunks/{execution-tool-I3SWG6I3.js → execution-tool-JFBVOKPW.js} +1 -1
- package/chunks/{execution-worker-62UZMAMJ.js → execution-worker-MNJZD72W.js} +1 -1
- package/chunks/{exitPlanMode-JIC4V3FE.js → exitPlanMode-PC6XG4TW.js} +1 -1
- package/chunks/{fast-path-NIOIL5YI.js → fast-path-V4DN3CRZ.js} +1 -1
- package/chunks/{glob-EQ4QNAHF.js → glob-DTZROBDS.js} +1 -1
- package/chunks/{goal-tools-DYTTSBQG.js → goal-tools-FUVGTY33.js} +1 -1
- package/chunks/{handleAutoUpdate-44BTG5L5.js → handleAutoUpdate-U4LVTHGU.js} +1 -1
- package/chunks/{i18n-FTHZAHCT.js → i18n-XOKNDFYP.js} +1 -1
- package/chunks/{initializer-MSGKXC75.js → initializer-XBR5J4CY.js} +1 -1
- package/chunks/{installationInfo-4XJMJJYU.js → installationInfo-4AOEOUI6.js} +1 -1
- package/chunks/{interactive-mod-session-DFLRYO2Q.js → interactive-mod-session-YGZK2JK2.js} +1 -1
- package/chunks/{list-ODZ7Z6VI.js → list-TCGKVPH4.js} +1 -1
- package/chunks/{llm-O64DHKP7.js → llm-SKFTN5UN.js} +4 -4
- package/chunks/{llm-content-generator-SK24I6QS.js → llm-content-generator-GWHXT3WS.js} +1 -1
- package/chunks/{loadedSettingsAdapter-6PEBUZT5.js → loadedSettingsAdapter-ZALZGZE7.js} +1 -1
- package/chunks/{local-ED3UEKWP.js → local-RWTWYS5Z.js} +1 -1
- package/chunks/{local-execution-environment-PUKES5LO.js → local-execution-environment-R6JWLD65.js} +1 -1
- package/chunks/{loggingContentGenerator-UHOJVSRR.js → loggingContentGenerator-UJV6QFOY.js} +1 -1
- package/chunks/{loop-wakeup-NSJQETPZ.js → loop-wakeup-BU2RRYHA.js} +1 -1
- package/chunks/{manage-memory-5RRB6FLH.js → manage-memory-XI57JN4T.js} +1 -1
- package/chunks/{managed-execution-engine-MZAP7SK6.js → managed-execution-engine-BA5PABMP.js} +1 -1
- package/chunks/{managed-local-serve-XMES3HXL.js → managed-local-serve-MFKN22K6.js} +1 -1
- package/chunks/{managed-npm-update-R5KGY7G2.js → managed-npm-update-ZGN43NUA.js} +1 -1
- package/chunks/{managed-runtime-attestation-worker-O2KNHHV6.js → managed-runtime-attestation-worker-YN2VBGYN.js} +1 -1
- package/chunks/{managed-runtime-bootstrap-HOTLM6DE.js → managed-runtime-bootstrap-SGQVMUJE.js} +1 -1
- package/chunks/{managed-runtime-session-worker-QZX44ZTD.js → managed-runtime-session-worker-4UMF3VBY.js} +1 -1
- package/chunks/{managed-runtime-ssh-worker-U425WQ65.js → managed-runtime-ssh-worker-7XA6KRBN.js} +1 -1
- package/chunks/{managed-session-authority-THHDHCBP.js → managed-session-authority-IJGYAOEL.js} +1 -1
- package/chunks/{mcp-AR7EK4WY.js → mcp-V3L7B5YK.js} +1 -1
- package/chunks/{memory-C2TSF6BK.js → memory-3T6FPNAK.js} +1 -1
- package/chunks/{model-call-collection-25WR55OH.js → model-call-collection-WTTITWWM.js} +1 -1
- package/chunks/{model-configuration-KC7DQGKV.js → model-configuration-T6SSGI4J.js} +1 -1
- package/chunks/{modelConfigUtils-QEHMVLSQ.js → modelConfigUtils-TQA25QJC.js} +1 -1
- package/chunks/{monitor-PDQUZD23.js → monitor-5ZAOJSEE.js} +1 -1
- package/chunks/{nonInteractiveCli-WY2YFONU.js → nonInteractiveCli-YFINLVA7.js} +1 -1
- package/chunks/{nonInteractiveToolExecutor-7RJZYPHJ.js → nonInteractiveToolExecutor-DE3WACL5.js} +1 -1
- package/chunks/{notebook-edit-P4ITXF5H.js → notebook-edit-UK6HBRO3.js} +1 -1
- package/chunks/{omni-AYUPB2QM.js → omni-65LF5QK4.js} +1 -1
- package/chunks/{openaiContentGenerator-V5IK4ITO.js → openaiContentGenerator-HX7NCSV5.js} +1 -1
- package/chunks/{openaiResponsesContentGenerator-DYDH6KWT.js → openaiResponsesContentGenerator-CFA6U6Y5.js} +1 -1
- package/chunks/{pidfile-INPBL2DK.js → pidfile-ZVKJUNTZ.js} +1 -1
- package/chunks/{processUtils-J4UDEDS4.js → processUtils-VS6CJT7E.js} +1 -1
- package/chunks/{prompt-terminal-ledger-QLOQWHYE.js → prompt-terminal-ledger-UF5RDB57.js} +1 -1
- package/chunks/{qwenContentGenerator-RU43XKKB.js → qwenContentGenerator-GM3ZSI7E.js} +1 -1
- package/chunks/{reactive-degrade-2Q3Z3KAR.js → reactive-degrade-TSAQWZ5F.js} +1 -1
- package/chunks/{read-file-472BQ25I.js → read-file-J267NT45.js} +1 -1
- package/chunks/{resumeHistoryUtils-7SUFKZDC.js → resumeHistoryUtils-IM46VFDV.js} +1 -1
- package/chunks/{review-WX52IWJR.js → review-4B64XTCL.js} +1 -1
- package/chunks/{ripGrep-4GPGLKAM.js → ripGrep-YLOSXO7P.js} +1 -1
- package/chunks/{run-qwen-serve-MXK4RBKL.js → run-qwen-serve-SAHEC44O.js} +1 -1
- package/chunks/{runtime-WHU3AGFT.js → runtime-SJDZHV6J.js} +1 -1
- package/chunks/{sandboxConfig-7DBXEQJH.js → sandboxConfig-47EXXMUA.js} +1 -1
- package/chunks/{scheduled-tasks-O5RV6G6U.js → scheduled-tasks-E6RCTUUS.js} +1 -1
- package/chunks/{scheduler-HLMS5LR5.js → scheduler-SE3IWIWA.js} +1 -1
- package/chunks/{search-memory-PYND7ZX3.js → search-memory-2W7VJC4Q.js} +1 -1
- package/chunks/{send-message-TMLYTQOI.js → send-message-63YGQP6G.js} +1 -1
- package/chunks/{serve-EBNBRAME.js → serve-F4ML2WNL.js} +1 -1
- package/chunks/{server-63BRDBL5.js → server-S56IB4TT.js} +3 -3
- package/chunks/{session-XB6J4CZD.js → session-2CUVLZ4H.js} +1 -1
- package/chunks/{session-attachments-root-PFK475N2.js → session-attachments-root-FINBX7K5.js} +1 -1
- package/chunks/{session-execution-engine-selector-P6TJTCKR.js → session-execution-engine-selector-UGC7DGUN.js} +1 -1
- package/chunks/{session-pr-refresh-PM7VAQTV.js → session-pr-refresh-KQLQ4MZY.js} +1 -1
- package/chunks/{sessionService-PO3LLZIZ.js → sessionService-Q6N7LF7Z.js} +1 -1
- package/chunks/{settings-JDQSRXP3.js → settings-23I6H76E.js} +1 -1
- package/chunks/{shell-JCEX3HKM.js → shell-IUECEVVY.js} +1 -1
- package/chunks/{skill-JSZBONIZ.js → skill-YKUETMPC.js} +1 -1
- package/chunks/{skill-settings-YGFG6GPN.js → skill-settings-ODYXOPCA.js} +1 -1
- package/chunks/{spawnChannel-VIIWSWTL.js → spawnChannel-7XU2SRWZ.js} +1 -1
- package/chunks/{standalone-update-2UU6FQZL.js → standalone-update-SWI2RL3L.js} +1 -1
- package/chunks/{start-opentui-ui-OSZZNSLY.js → start-opentui-ui-T53QJGCH.js} +1 -1
- package/chunks/{startInteractiveUI-FFH66MYH.js → startInteractiveUI-USTZGQOE.js} +1 -1
- package/chunks/{team-create-TKGDJ3NU.js → team-create-4A2XUE3D.js} +1 -1
- package/chunks/{team-plan-approval-3VJF4G6Z.js → team-plan-approval-4TS5CYN6.js} +1 -1
- package/chunks/{terminal-image-renderer-T3VJRZGP.js → terminal-image-renderer-C7553YV6.js} +1 -1
- package/chunks/{theme-manager-ZGUFLFUI.js → theme-manager-GTW75GOO.js} +1 -1
- package/chunks/{tool-call-3EQS5KSE.js → tool-call-YTUMWL3A.js} +1 -1
- package/chunks/{tool-result-media-7LFNVQ6E.js → tool-result-media-JYOYBX4J.js} +1 -1
- package/chunks/{tool-search-UDZ4S7T5.js → tool-search-Y4XTT2WF.js} +1 -1
- package/chunks/{total-session-admission-U4MII4RA.js → total-session-admission-EMJ5NRGL.js} +1 -1
- package/chunks/{trustedFolders-2NQJCIN3.js → trustedFolders-YG6WAVRE.js} +1 -1
- package/chunks/{update-relaunch-YKLWSCLC.js → update-relaunch-4QYQRCP4.js} +1 -1
- package/chunks/{updateCheck-YDLTQQRU.js → updateCheck-VRFPSX4G.js} +1 -1
- package/chunks/{upload-config-5QQKWF4O.js → upload-config-UCKGUYYQ.js} +1 -1
- package/chunks/{useAutoAcceptIndicator-AJS4WTU2.js → useAutoAcceptIndicator-2VGLKD7B.js} +1 -1
- package/chunks/{validateNonInterActiveAuth-AETOT7ZW.js → validateNonInterActiveAuth-GGMQXKKU.js} +1 -1
- package/chunks/{version-IB6DLRAG.js → version-Y46PG7II.js} +1 -1
- package/chunks/{web-fetch-LS3QARNR.js → web-fetch-7MPU555L.js} +1 -1
- package/chunks/{web-search-FGHRIVEB.js → web-search-HU2CL2X2.js} +1 -1
- package/chunks/{workflow-FX6XNETQ.js → workflow-U3D34QQX.js} +1 -1
- package/chunks/{workflow-ancestor-trust-5XXBGN6F.js → workflow-ancestor-trust-OWC4YTMR.js} +1 -1
- package/chunks/{workspace-agents-UJKLYPUK.js → workspace-agents-KHLAWSAR.js} +1 -1
- package/chunks/{workspace-providers-status-4JOHMTAW.js → workspace-providers-status-T57SE3YX.js} +1 -1
- package/chunks/{workspace-recovery-worker-XFEYQ4TP.js → workspace-recovery-worker-VYQ723ZE.js} +1 -1
- package/chunks/{workspace-registration-store-LWAPVNYC.js → workspace-registration-store-I7PR3A2Y.js} +1 -1
- package/chunks/{workspace-registry-M7OC376O.js → workspace-registry-YYUBXCLH.js} +1 -1
- package/chunks/{workspace-runtime-coordinator-CYHIL47L.js → workspace-runtime-coordinator-5ICAQO7W.js} +1 -1
- package/chunks/{workspace-service-43VZZ56B.js → workspace-service-YROWXOLQ.js} +1 -1
- package/chunks/{workspace-skills-status-V2TT6UJQ.js → workspace-skills-status-DKKQDTZJ.js} +1 -1
- package/chunks/{workspace-trust-reconciler-YZ4AG5ZW.js → workspace-trust-reconciler-3FPMUZDO.js} +1 -1
- package/chunks/{write-file-TGEH5MEZ.js → write-file-7QQVYFDT.js} +1 -1
- package/chunks/{zoom-image-TT6R7H2H.js → zoom-image-WL5EB6Q7.js} +1 -1
- package/cli.js +2 -2
- package/execution-worker.js +1 -1
- package/export-transcript-document.js +1 -1
- package/package.json +3 -3
- package/web-shell/assets/{PierreFilePreview-OsApm5-S.js → PierreFilePreview-BZ17f56_.js} +1 -1
- package/web-shell/assets/{SpreadsheetPreview-I1v1EzV7.js → SpreadsheetPreview-Bvkvr_5u.js} +1 -1
- package/web-shell/assets/{WorkspaceFileBrowser-BO6aug7i.js → WorkspaceFileBrowser-BJ_I4Uoz.js} +1 -1
- package/web-shell/assets/{abnfDiagram-VCTEODGH-DxuLMyN0.js → abnfDiagram-VCTEODGH-iuaBM15V.js} +1 -1
- package/web-shell/assets/{agents-route-CSJf6QPO.js → agents-route-CycwfNSC.js} +1 -1
- package/web-shell/assets/{arc-3--LekYQ.js → arc-C0lt8n55.js} +1 -1
- package/web-shell/assets/{architectureDiagram-5GKGNRK7-Dihq4uto.js → architectureDiagram-5GKGNRK7-Bw326d-A.js} +1 -1
- package/web-shell/assets/{blockDiagram-NRAW4CY4-BnaRPM2o.js → blockDiagram-NRAW4CY4-CHtFgBjV.js} +1 -1
- package/web-shell/assets/{c4Diagram-UCG6FXSJ-BtC94eMa.js → c4Diagram-UCG6FXSJ-Bx66oJT9.js} +1 -1
- package/web-shell/assets/channel-CRJuO00u.js +1 -0
- package/web-shell/assets/{chunk-2Q5K7J3B-2ZTXWP6M.js → chunk-2Q5K7J3B-BIshvfa_.js} +1 -1
- package/web-shell/assets/{chunk-5VM5RSS4-DBh7DP1F.js → chunk-5VM5RSS4-BZeRS6uD.js} +1 -1
- package/web-shell/assets/{chunk-F27PBJKO-xzqbWXBw.js → chunk-F27PBJKO-El-CGY2R.js} +1 -1
- package/web-shell/assets/{chunk-G27WJ6UU-DxnCrpxK.js → chunk-G27WJ6UU-DO8ZfQL_.js} +1 -1
- package/web-shell/assets/{chunk-JWPE2WC7-BPjRsozm.js → chunk-JWPE2WC7-yYFrrKAj.js} +1 -1
- package/web-shell/assets/{chunk-LCL6LL3I-Q2HgB3lf.js → chunk-LCL6LL3I-BFGuOKN0.js} +1 -1
- package/web-shell/assets/{chunk-POPQ4Y6H-9tlPaKu-.js → chunk-POPQ4Y6H-GRHK6sdV.js} +1 -1
- package/web-shell/assets/{chunk-SVP7TREG-DkNdOHCU.js → chunk-SVP7TREG-DwDu6GqZ.js} +1 -1
- package/web-shell/assets/{chunk-XXDRQBXY-D0G-Dhfi.js → chunk-XXDRQBXY-RoNDjkIy.js} +1 -1
- package/web-shell/assets/classDiagram-DTDB5LWJ-pPPByLA7.js +1 -0
- package/web-shell/assets/classDiagram-v2-JRS7N3AN-pPPByLA7.js +1 -0
- package/web-shell/assets/{cose-bilkent-JH36ORCC-Ck0tHxul.js → cose-bilkent-JH36ORCC-CYNiiONE.js} +1 -1
- package/web-shell/assets/{cynefin-OW5HDTMX-a4-NTMHi.js → cynefin-OW5HDTMX-DC1_lDIG.js} +1 -1
- package/web-shell/assets/{cynefinDiagram-5FMLGOSQ-Pg41Zbf2.js → cynefinDiagram-5FMLGOSQ-D2VxKm2n.js} +1 -1
- package/web-shell/assets/{dagre-3AP2YEHR-DT_ZmqkF.js → dagre-3AP2YEHR-C4_BHzpM.js} +1 -1
- package/web-shell/assets/{diagram-S7CK7UJ4-hapdMOl1.js → diagram-S7CK7UJ4-BpAO4-Gv.js} +1 -1
- package/web-shell/assets/{diagram-UQ7AKVKN-YZ0nbk56.js → diagram-UQ7AKVKN-DqUsFdsX.js} +1 -1
- package/web-shell/assets/{diagram-VSXAHHWV-DA_yNbWy.js → diagram-VSXAHHWV-DcMXIYMy.js} +1 -1
- package/web-shell/assets/{diagram-VX7I27RA-DoULuCLT.js → diagram-VX7I27RA-I3nr09ex.js} +1 -1
- package/web-shell/assets/{diagram-Z3DM3KII-B5c9o9zL.js → diagram-Z3DM3KII-CN-gvsTo.js} +1 -1
- package/web-shell/assets/{docx-preview-BulxdBjs.js → docx-preview-31J6RsS0.js} +1 -1
- package/web-shell/assets/{ebnfDiagram-PWID7BFC-B5hgIg3m.js → ebnfDiagram-PWID7BFC-DOQvLWlM.js} +1 -1
- package/web-shell/assets/{erDiagram-SSCWMZ5O-BEfEPozi.js → erDiagram-SSCWMZ5O-Cb5ijFZh.js} +1 -1
- package/web-shell/assets/{flowDiagram-A5DVABFB-CQHNk92v.js → flowDiagram-A5DVABFB-BecqqjnZ.js} +1 -1
- package/web-shell/assets/{ganttDiagram-EL5Y4UJY-BabdVgIM.js → ganttDiagram-EL5Y4UJY-DWY5vzQl.js} +1 -1
- package/web-shell/assets/{gitGraphDiagram-WWUBYQGX-ujRZBFUo.js → gitGraphDiagram-WWUBYQGX-DqBnsZmZ.js} +1 -1
- package/web-shell/assets/{index-B9uXebIR.js → index-DDmiUW3b.js} +6 -6
- package/web-shell/assets/{index-DSZXdZnu.js → index-DabH7kHA.js} +1 -1
- package/web-shell/assets/{infoDiagram-RXCK75RN-CUHj9jJC.js → infoDiagram-RXCK75RN-MlotyOdT.js} +1 -1
- package/web-shell/assets/{ishikawaDiagram-5VMMS53U-CulW_q81.js → ishikawaDiagram-5VMMS53U-Daq_85C7.js} +1 -1
- package/web-shell/assets/{journeyDiagram-EYS64GPL-BR46CvRQ.js → journeyDiagram-EYS64GPL-OipivCxL.js} +1 -1
- package/web-shell/assets/{kanban-definition-3QL26DDD-HAoUqzFy.js → kanban-definition-3QL26DDD-zqaz7dLu.js} +1 -1
- package/web-shell/assets/{layout-DYLl7fyA.js → layout-Bi3msQMQ.js} +1 -1
- package/web-shell/assets/{linear-DPXABjDZ.js → linear-D4gPORvD.js} +1 -1
- package/web-shell/assets/{mermaid.core-Bi30Gi0n.js → mermaid.core-BUnytF7a.js} +6 -6
- package/web-shell/assets/{mindmap-definition-FBJOCRG2-B1_lUq4o.js → mindmap-definition-FBJOCRG2-B_X4iChu.js} +1 -1
- package/web-shell/assets/{pegDiagram-XKGWAZYB-Cy8tjJJC.js → pegDiagram-XKGWAZYB-z4wYBoBW.js} +1 -1
- package/web-shell/assets/{pieDiagram-E7YTZNPT-D6waLVVi.js → pieDiagram-E7YTZNPT-Dvyg6FYo.js} +1 -1
- package/web-shell/assets/{quadrantDiagram-AXDQQJYC--6ehi_FI.js → quadrantDiagram-AXDQQJYC-CJBWU2Dk.js} +1 -1
- package/web-shell/assets/{railroadDiagram-O6MQD6OU-BhLy40X4.js → railroadDiagram-O6MQD6OU-Dl_An1O0.js} +1 -1
- package/web-shell/assets/{requirementDiagram-EFPCY7ZU-BVNXTgNP.js → requirementDiagram-EFPCY7ZU-Tw8FwaYU.js} +1 -1
- package/web-shell/assets/{sankeyDiagram-P5KCCOFB-BHgTytxV.js → sankeyDiagram-P5KCCOFB-BCPCkbR0.js} +1 -1
- package/web-shell/assets/{sequenceDiagram-WJ2MYXX4-CgOsTvhu.js → sequenceDiagram-WJ2MYXX4-DDj7uFTG.js} +1 -1
- package/web-shell/assets/{sizeCapture-X5ZJPWSS-vCQBQ5FI.js → sizeCapture-X5ZJPWSS-B9eVSpKb.js} +1 -1
- package/web-shell/assets/{stateDiagram-HBIQ2CUA-DytMYRWJ.js → stateDiagram-HBIQ2CUA-Bf4BZP_V.js} +1 -1
- package/web-shell/assets/stateDiagram-v2-4QOOHH4V-BPJi6Gre.js +1 -0
- package/web-shell/assets/{swimlanes-XN3QIQJK-CTGnifOP.js → swimlanes-XN3QIQJK-dyTWsZFj.js} +1 -1
- package/web-shell/assets/swimlanesDiagram-VK2B7HYN-Bw4NRtJQ.js +8 -0
- package/web-shell/assets/{timeline-definition-24CTP7MA-DEJ1cbn2.js → timeline-definition-24CTP7MA-DVl1A4uL.js} +1 -1
- package/web-shell/assets/{vennDiagram-4TSXK5OY-K1e4SjS0.js → vennDiagram-4TSXK5OY-Boosxy9D.js} +1 -1
- package/web-shell/assets/{wardleyDiagram-VM6X3IG4-DEX-GkRp.js → wardleyDiagram-VM6X3IG4-C6wlY8jy.js} +1 -1
- package/web-shell/assets/{xychartDiagram-S5SC5T6Z-B6wYXreH.js → xychartDiagram-S5SC5T6Z-CkzZe3ro.js} +1 -1
- package/web-shell/index.html +1 -1
- package/web-shell/sw.js +1 -1
- package/web-shell/assets/channel-CLVrtVFX.js +0 -1
- package/web-shell/assets/classDiagram-DTDB5LWJ-Df2T70oB.js +0 -1
- package/web-shell/assets/classDiagram-v2-JRS7N3AN-Df2T70oB.js +0 -1
- package/web-shell/assets/stateDiagram-v2-4QOOHH4V-CcjUJGng.js +0 -1
- package/web-shell/assets/swimlanesDiagram-VK2B7HYN-Dt8NvQfX.js +0 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{GATE_OUTPUT_BUDGET_BYTES,HOSTNAME_RE,currentUser,ensureAuthenticated,gh,ghWithInput,isOwnerRepo,jsonBytes,normalizeGhHostForUrl,resolveGhHost,setGhHost}from"./chunk-TYFJZYVN.js";import{GIT_TIMEOUT_MS,git,gitOpt,gitProbe,gitRaw,redirectedAncestor,refExists,releaseWorktree,repoRoot,sanitizedGitEnv}from"./chunk-
|
|
3
|
+
import{GATE_OUTPUT_BUDGET_BYTES,HOSTNAME_RE,currentUser,ensureAuthenticated,gh,ghWithInput,isOwnerRepo,jsonBytes,normalizeGhHostForUrl,resolveGhHost,setGhHost}from"./chunk-TYFJZYVN.js";import{GIT_TIMEOUT_MS,git,gitOpt,gitProbe,gitRaw,redirectedAncestor,refExists,releaseWorktree,repoRoot,sanitizedGitEnv}from"./chunk-INFBJDWM.js";import{matchRemotes,normalizeSegment}from"./chunk-FF2IRBNF.js";import{isWithinRoot}from"./chunk-IDXJIDME.js";import"./chunk-A5TAAMML.js";import"./chunk-QS2ZMQIS.js";import"./chunk-S7IKHQ6I.js";import"./chunk-PAD5GPDY.js";import"./chunk-MD3ZEOBX.js";import"./chunk-X5QSFJVS.js";import"./chunk-2Q7T5CR2.js";import"./chunk-46VUDNCL.js";import"./chunk-MKH3EH7O.js";import"./chunk-JFVXZFMV.js";import"./chunk-BNYJY4OL.js";import"./chunk-JKV4ODXE.js";import"./chunk-YBISME5B.js";import"./chunk-ZHHFNZ5J.js";import"./chunk-M3C6RDGC.js";import"./chunk-AKWYMQKU.js";import"./chunk-MZUOREFD.js";import"./chunk-IGPAATQW.js";import"./chunk-XZACON5H.js";import"./chunk-7EBRMQYW.js";import"./chunk-ZZJXFLVM.js";import"./chunk-RKDS7A4H.js";import"./chunk-V6VMUJ47.js";import"./chunk-IV3HAIUN.js";import"./chunk-UYYQB2TU.js";import"./chunk-VET7MLTV.js";import"./chunk-HN5UYLPU.js";import"./chunk-DECUAM3U.js";import"./chunk-PGRN3GZY.js";import"./chunk-YFTVFH2A.js";import"./chunk-ZBHL2CXR.js";import"./chunk-NIOS3B3V.js";import"./chunk-LZNBHBAJ.js";import"./chunk-R2EHHA2C.js";import"./chunk-ZLZF2ZDD.js";import"./chunk-YK7NDQKM.js";import"./chunk-TLROJH6O.js";import"./chunk-PHIPLV2I.js";import"./chunk-2EUNU5M5.js";import"./chunk-7DCW657A.js";import"./chunk-FIXDX63I.js";import"./chunk-T7CHK6C2.js";import"./chunk-PT7NZBDY.js";import"./chunk-TWP72VRH.js";import"./chunk-UYEWRLGD.js";import"./chunk-2MB4ZSKF.js";import"./chunk-WK2IBT6D.js";import"./chunk-ILECDNJX.js";import"./chunk-QXQGUM3Y.js";import"./chunk-TRA6EVDT.js";import"./chunk-DBA3F3D7.js";import"./chunk-QVPT37XZ.js";import"./chunk-T6W33SET.js";import"./chunk-4WFGJVTF.js";import"./chunk-BYU42MLK.js";import"./chunk-JWQXU3SR.js";import"./chunk-5LZ2DPLH.js";import"./chunk-XQJOZDV7.js";import"./chunk-CV2UAEZA.js";import"./chunk-LO76B6GW.js";import"./chunk-CMLAE3UB.js";import"./chunk-KLC3OD2M.js";import"./chunk-QZV4PFQK.js";import"./chunk-VXRLLVOP.js";import"./chunk-G5PYYZMM.js";import"./chunk-BG67XABA.js";import"./chunk-BEKROCWN.js";import"./chunk-OBOU4ZZM.js";import"./chunk-D7XCQWP2.js";import"./chunk-AE5OMKRY.js";import"./chunk-QF44NNSC.js";import"./chunk-QX4PIAJI.js";import"./chunk-7DQ2T3TA.js";import"./chunk-TDHEAGDX.js";import"./chunk-JZK2WGXA.js";import"./chunk-MPHSE7M4.js";import"./chunk-S2ZKZXHX.js";import"./chunk-4GP3PH7Z.js";import"./chunk-4QQKOW5M.js";import"./chunk-OV3EBH6J.js";import"./chunk-EBMCWXGZ.js";import"./chunk-DPNGBOI7.js";import"./chunk-7UK4WJWS.js";import"./chunk-HMIP4IK2.js";import"./chunk-SG3M7EYB.js";import"./chunk-YIW3H46P.js";import"./chunk-E6MI76C2.js";import"./chunk-NTNKD4KR.js";import"./chunk-4ZRCV3JY.js";import"./chunk-K7TPIVP4.js";import"./chunk-CQCSNHPU.js";import"./chunk-YGLM5XPP.js";import"./chunk-WGNF7FPC.js";import"./chunk-4NPYOXJO.js";import"./chunk-MWGB5RCF.js";import"./chunk-SCD5TUBG.js";import"./chunk-NTRFETZB.js";import"./chunk-TL3SF2GA.js";import"./chunk-GRW3GBXN.js";import"./chunk-4JNHUZ7M.js";import"./chunk-SW54YEPK.js";import"./chunk-FNDMWG43.js";import"./chunk-AGQBNWGY.js";import"./chunk-AGEDDL7Z.js";import"./chunk-2NJJHZ52.js";import"./chunk-BN4FIQ77.js";import"./chunk-IKDZVJH2.js";import"./chunk-3YWXKSOI.js";import"./chunk-OZGM5CCE.js";import"./chunk-S4KYECMU.js";import"./chunk-VFB6Q74I.js";import"./chunk-A6LT3FIJ.js";import"./chunk-S6RXVOY6.js";import"./chunk-X64RXJQQ.js";import"./chunk-HETUGUHE.js";import"./chunk-BDQOLT37.js";import"./chunk-NCVLAQE5.js";import"./chunk-476F6QIM.js";import"./chunk-4R67LXKL.js";import"./chunk-VTDSLBET.js";import"./chunk-TNCN2JX2.js";import"./chunk-UQFTXKEB.js";import"./chunk-HDGTWJ24.js";import"./chunk-W5NWIGKO.js";import"./chunk-KVA6DHHF.js";import"./chunk-PWOQASXT.js";import"./chunk-K7JCVESI.js";import"./chunk-Y6HHV4LC.js";import"./chunk-RP57XAJ2.js";import"./chunk-Z6AR5XE5.js";import"./chunk-77V43YOE.js";import"./chunk-7U7CWMP7.js";import"./chunk-SLD7H2FA.js";import"./chunk-7DOOXUDG.js";import"./chunk-4DIWAQ5G.js";import"./chunk-Q6UAOTP3.js";import"./chunk-DZ3GV34J.js";import"./chunk-HEDN54OB.js";import"./chunk-4ZBZL23U.js";import"./chunk-ZZZAYAJW.js";import"./chunk-XMANRGPK.js";import"./chunk-XHV5HLJS.js";import"./chunk-KQX4H2D3.js";import"./chunk-URNNJMIC.js";import"./chunk-HTW7PYHK.js";import"./chunk-AMGUAA4G.js";import{atomicWriteFileSync}from"./chunk-BMHYEQTI.js";import"./chunk-GU22I6TY.js";import"./chunk-YEYW7PPR.js";import{writeStdoutLine}from"./chunk-SLPJ4OII.js";import"./chunk-4YLXNRRH.js";import"./chunk-B3ZFUGTC.js";import"./chunk-IRINPFG7.js";import"./chunk-6GTPLW7K.js";import"./chunk-NGVRCUYD.js";import"./chunk-5DTFN37U.js";import"./chunk-2YUBAWQ6.js";import"./chunk-O5EKX7LG.js";import"./chunk-TM6ZCBR7.js";import"./chunk-SVAPAMMG.js";import"./chunk-3KUHQGOS.js";import"./chunk-I6S7NGX3.js";import"./chunk-SBZFGYYS.js";import"./chunk-JAUJI56S.js";import"./chunk-I4H7NUVP.js";import"./chunk-EPODBRBP.js";import{realpathNearestExisting}from"./chunk-OKN3Z5C5.js";import"./chunk-XYB7GC5U.js";import"./chunk-2UOMCYQG.js";import"./chunk-I7L2TX4M.js";import"./chunk-MK3OONRA.js";import"./chunk-COGTQ5KZ.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name}from"./chunk-KBWJGX7I.js";init_esbuild_shims();init_esbuild_shims();import{existsSync as existsSync2,mkdirSync}from"node:fs";import{dirname as dirname4}from"node:path";init_esbuild_shims();import{randomUUID}from"node:crypto";import{linkSync,lstatSync,readFileSync,readlinkSync,renameSync,rmSync,statSync,unlinkSync,writeFileSync}from"node:fs";import{basename,dirname,join}from"node:path";var REPLY_MARKER="<!-- qwen-autofix-pr:v1 -->";var WATCH_INTERVALS=[1,2,5,10,15,30,60];var MAX_NEEDS_HUMAN=20;var MAX_INSTRUCTIONS_CHARS=2e3;function rerunFloors(state){return[...state.rerunChecks??[],...(state.heldChecks??[]).map(entry=>entry.replace(/^\d+:/,""))]}__name(rerunFloors,"rerunFloors");var MAX_PUSHES=10;function checkAttemptKey(check,headSha,attempt){return`${check}@${headSha}@${attempt}`}__name(checkAttemptKey,"checkAttemptKey");function assertPositiveInteger(value,what){if(!Number.isInteger(value)||value<1){throw new TypeError(`${what} must be a positive integer, got ${value}`)}}__name(assertPositiveInteger,"assertPositiveInteger");function autofixPrPaths(root,prNumber){assertPositiveInteger(prNumber,"PR number");const tmp=join(root,".qwen","tmp");return{worktreePath:join(tmp,`autofix-pr-${prNumber}`),statePath:join(tmp,`autofix-pr-${prNumber}-state.json`),gatePath:join(tmp,`autofix-pr-${prNumber}-gate.json`),checkedPath:join(tmp,`autofix-pr-${prNumber}-gate.checked`),snapshotPath:join(tmp,`autofix-pr-${prNumber}-snapshot.json`),repliesPath:join(tmp,`autofix-pr-${prNumber}-replies.json`),lockPath:join(tmp,`autofix-pr-${prNumber}.lock`),instructionsPath:join(tmp,`autofix-pr-${prNumber}-instructions.txt`),fixPath:join(tmp,`autofix-pr-${prNumber}-fix.json`),branch:`qwen-autofix/pr-${prNumber}`}}__name(autofixPrPaths,"autofixPrPaths");function isRegularFile(path){return lstatSync(path,{throwIfNoEntry:false})?.isFile()===true}__name(isRegularFile,"isRegularFile");function readGateCursor(gatePath){if(lstatSync(gatePath,{throwIfNoEntry:false})===void 0){return null}if(!isRegularFile(gatePath)){throw new Error(`${gatePath} is not a regular file`)}const parsed=JSON.parse(readFileSync(gatePath,"utf8"));if(parsed.version!==1){throw new Error(`unsupported autofix-pr gate cursor version in ${gatePath}: ${String(parsed.version)}`)}return{...parsed,reportedTruncated:parsed.reportedTruncated??[]}}__name(readGateCursor,"readGateCursor");function writeGateCursor(gatePath,cursor){atomicWriteFileSync(gatePath,`${JSON.stringify(cursor,null,2)}
|
|
4
4
|
`,{noFollow:true})}__name(writeGateCursor,"writeGateCursor");function sameRepository(a,b){return normalizeGhHostForUrl(a.host)===normalizeGhHostForUrl(b.host)&&normalizeSegment(a.owner)===normalizeSegment(b.owner)&&normalizeSegment(a.repo)===normalizeSegment(b.repo)}__name(sameRepository,"sameRepository");var SHA_RE=/^[0-9a-f]{40,64}$/;function isBranchName(name){return!(name===""||name==="@"||name.startsWith("-")||name.endsWith("/")||name.endsWith(".")||[...name].some(char=>char.charCodeAt(0)<=32||char==="\x7F")||/[~^:?*[\\]/.test(name)||name.includes("..")||name.includes("@{")||name.includes("//")||name.split("/").some(part=>part.startsWith(".")||part.endsWith(".lock")))}__name(isBranchName,"isBranchName");var SHELL_SPECIAL=/[;&|$`<>()'"{}!#]/;function isCommandSafeName(name){return!SHELL_SPECIAL.test(name)}__name(isCommandSafeName,"isCommandSafeName");function stringList(value){return Array.isArray(value)?value.filter(item=>typeof item==="string"):[]}__name(stringList,"stringList");var isStringList=__name(value=>Array.isArray(value)&&value.every(item=>typeof item==="string"),"isStringList");var isRunList=__name(value=>Array.isArray(value)&&value.every(item=>Number.isInteger(item)),"isRunList");function isPendingPost(value){const post=value;return typeof post==="object"&&post!==null&&(post.where==="summary"||Number.isInteger(post.where))&&isStringList(post.handled)&&typeof post.bodyHash==="string"&&typeof post.sha==="string"}__name(isPendingPost,"isPendingPost");function stateDefect(state){const word=__name(value=>typeof value==="string"&&value!==""&&!value.startsWith("-"),"word");if(!word(state.remote)||!isBranchName(state.remote)||!isCommandSafeName(state.remote)){return"remote"}if(!word(state.pushTarget))return"pushTarget";if(!word(state.headRefName)||!isBranchName(state.headRefName)){return"headRefName"}if(!word(state.baseRefName)||!isBranchName(state.baseRefName)||!isCommandSafeName(state.baseRefName)){return"baseRefName"}if(!isOwnerRepo(`${state.owner}/${state.repo}`))return"owner/repo";if(typeof state.host!=="string"||!HOSTNAME_RE.test(state.host)){return"host"}if(!Number.isInteger(state.prNumber)||state.prNumber<1){return"prNumber"}if(typeof state.lastKnownHeadSha!=="string"||!SHA_RE.test(state.lastKnownHeadSha)){return"lastKnownHeadSha"}if(!Array.isArray(state.pushedShas)||!state.pushedShas.every(sha=>typeof sha==="string"&&SHA_RE.test(sha))){return"pushedShas"}if(!isStringList(state.handledCommentIds))return"handledCommentIds";if(!isStringList(state.postedCommentIds))return"postedCommentIds";if(state.handledChecks!==void 0&&!isStringList(state.handledChecks)){return"handledChecks"}if(state.rerunChecks!==void 0&&!isStringList(state.rerunChecks)){return"rerunChecks"}if(state.deferredRuns!==void 0&&!isRunList(state.deferredRuns)){return"deferredRuns"}if(state.heldChecks!==void 0&&!isStringList(state.heldChecks)){return"heldChecks"}if(state.pendingPosts!==void 0&&!(Array.isArray(state.pendingPosts)&&state.pendingPosts.every(isPendingPost))){return"pendingPosts"}if(state.pushCount!==void 0&&!(Number.isInteger(state.pushCount)&&state.pushCount>=0)){return"pushCount"}if(state.watch!==void 0&&!isWatchOptions(state.watch)){return"watch"}if(state.needsHuman!==void 0&&!(Array.isArray(state.needsHuman)&&state.needsHuman.every(isNeedsHumanItem))){return"needsHuman"}if(state.preparedAt!==void 0&&typeof state.preparedAt!=="string"){return"preparedAt"}if(state.ended!==void 0&&!(typeof state.ended==="object"&&state.ended!==null&&typeof state.ended.at==="string"&&typeof state.ended.reason==="string")){return"ended"}return null}__name(stateDefect,"stateDefect");function isWatchOptions(value){const watch=value;return typeof watch==="object"&&watch!==null&&WATCH_INTERVALS.includes(watch.every)&&typeof watch.reply==="boolean"&&typeof watch.instructions==="string"&&watch.instructions.length<=MAX_INSTRUCTIONS_CHARS&&!/[\p{Cc}\p{Cf}\u2028\u2029]/u.test(watch.instructions)&&(watch.task===void 0||/^[0-9a-f]{12}$/.test(watch.task))}__name(isWatchOptions,"isWatchOptions");function isNeedsHumanItem(value){const item=value;return typeof item==="object"&&item!==null&&typeof item.sha==="string"&&typeof item.at==="string"&&typeof item.text==="string"}__name(isNeedsHumanItem,"isNeedsHumanItem");function readState(statePath){const entry=lstatSync(statePath,{throwIfNoEntry:false});if(entry===void 0)return null;if(!entry.isFile()){throw new Error(`${statePath} is not a regular file; \`qwen autofix-pr cleanup <pr> --force\` discards it.`)}const parsed=JSON.parse(readFileSync(statePath,"utf8"));if(parsed.version!==1){throw new Error(`unsupported autofix-pr state version in ${statePath}: ${String(parsed.version)}`)}const defect=stateDefect(parsed);if(defect){throw new Error(`${statePath} has an invalid ${defect}; run \`qwen autofix-pr cleanup ${String(parsed.prNumber)} --force\` and prepare the watch again.`)}const{watch,ended,needsHuman}=parsed;return{...parsed,...watch?{watch:{every:watch.every,reply:watch.reply,instructions:watch.instructions,...watch.task!==void 0?{task:watch.task}:{}}}:{},...ended?{ended:{at:ended.at,reason:ended.reason}}:{},...needsHuman?{needsHuman:needsHuman.map(({sha,at,text})=>({sha,at,text}))}:{}}}__name(readState,"readState");var NO_FOLLOW={noFollow:true};function writeState(statePath,state){atomicWriteFileSync(statePath,`${JSON.stringify(state,null,2)}
|
|
5
5
|
`,NO_FOLLOW)}__name(writeState,"writeState");function historyPath(paths,repository){const slug=[normalizeGhHostForUrl(repository.host).replace(/:/g,"@"),normalizeSegment(repository.owner),normalizeSegment(repository.repo)].join("+").replace(/[^a-z0-9._@+-]/g,"_");return join(dirname(paths.statePath),`${historyPrefix(paths)}${slug}.history.json`)}__name(historyPath,"historyPath");function historyPrefix(paths){return basename(paths.statePath).replace(/-state\.json$/,"-history-")}__name(historyPrefix,"historyPrefix");function readHistory(path){if(lstatSync(path,{throwIfNoEntry:false})===void 0)return null;if(!isRegularFile(path))throw new Error(`${path} is not a regular file`);const parsed=JSON.parse(readFileSync(path,"utf8"));if(parsed.version!==1){throw new Error(`unsupported autofix-pr history version in ${path}: ${String(parsed.version)}`)}return{...parsed,handledCommentIds:stringList(parsed.handledCommentIds),postedCommentIds:stringList(parsed.postedCommentIds),handledChecks:stringList(parsed.handledChecks),rerunChecks:stringList(parsed.rerunChecks),handledConflictSha:typeof parsed.handledConflictSha==="string"&&SHA_RE.test(parsed.handledConflictSha)?parsed.handledConflictSha:null,pendingPosts:Array.isArray(parsed.pendingPosts)?parsed.pendingPosts.filter(isPendingPost):[],deferredRuns:Array.isArray(parsed.deferredRuns)?parsed.deferredRuns.filter(run=>Number.isInteger(run)):[],heldChecks:stringList(parsed.heldChecks)}}__name(readHistory,"readHistory");function keepHistory(paths,state){const path=historyPath(paths,state);let earlier=null;try{earlier=readHistory(path)}catch{}if(earlier&&!sameRepository(earlier,state))earlier=null;const union=__name((a,b)=>[...new Set([...stringList(a),...stringList(b)])],"union");const history={version:1,host:state.host,owner:state.owner,repo:state.repo,prNumber:state.prNumber,handledCommentIds:union(earlier?.handledCommentIds,state.handledCommentIds),postedCommentIds:union(earlier?.postedCommentIds,state.postedCommentIds),handledChecks:union(earlier?.handledChecks,state.handledChecks),rerunChecks:union(earlier?.rerunChecks,state.rerunChecks),handledConflictSha:state.handledConflictSha??earlier?.handledConflictSha??null,pendingPosts:state.pendingPosts??earlier?.pendingPosts??[],deferredRuns:state.deferredRuns??earlier?.deferredRuns??[],heldChecks:state.heldChecks??earlier?.heldChecks??[]};const entry=lstatSync(path,{throwIfNoEntry:false});if(entry&&!entry.isFile()&&!entry.isSymbolicLink()){rmSync(path,{recursive:true,force:true})}atomicWriteFileSync(path,`${JSON.stringify(history,null,2)}
|
|
6
6
|
`,NO_FOLLOW);return path}__name(keepHistory,"keepHistory");var LOCK_STALE_MS=15*6e4;function pidNamespace(){try{return readlinkSync("/proc/self/ns/pid")}catch{return null}}__name(pidNamespace,"pidNamespace");function lockIsStale(raw,mtimeMs){let token=null;try{token=JSON.parse(raw)}catch{}const at=typeof token?.at==="number"?token.at:mtimeMs;if(Date.now()-at>LOCK_STALE_MS)return true;if(!token||token.ns!==pidNamespace())return false;return!processAlive(token.pid)}__name(lockIsStale,"lockIsStale");function withWatchLock(paths,prNumber,fn){const lockPath=paths.lockPath;const token=JSON.stringify({pid:process.pid,ns:pidNamespace(),at:Date.now(),id:randomUUID()});const pending=`${lockPath}.${randomUUID()}`;writeFileSync(pending,token,{flag:"wx"});try{for(let attempt=0;;attempt+=1){if(takeLock(pending,lockPath,token))break;if(attempt>=4){throw new Error(`could not take the lock ${lockPath}`)}let stat;try{stat=lstatSync(lockPath)}catch{continue}if(stat.isSymbolicLink()){rmSync(lockPath,{force:true});continue}if(!stat.isFile()){throw new Error(`${lockPath} is not a lock file; remove it, or run \`qwen autofix-pr cleanup ${prNumber} --force\`.`)}let held;try{held=readFileSync(lockPath,"utf8")}catch{continue}if(attempt===0&&lockIsStale(held,stat.mtimeMs)){if(breakStaleLock(lockPath,held,pending))break;continue}throw new Error(`another autofix-pr helper is working on PR #${prNumber}; run one at a time (a lock left by a helper that was killed expires after ${LOCK_STALE_MS/6e4} minutes, or \`qwen autofix-pr cleanup ${prNumber} --force\` removes it).`)}}finally{rmSync(pending,{force:true})}try{return fn()}finally{try{if(readFileSync(lockPath,"utf8")===token)unlinkSync(lockPath)}catch{}}}__name(withWatchLock,"withWatchLock");function breakStaleLock(lockPath,stale,pending){const breaker=`${lockPath}.break`;if(!takeBreaker(breaker))return false;try{let current;try{current=readFileSync(lockPath,"utf8")}catch{return false}if(current!==stale)return false;renameSync(pending,lockPath);return true}finally{rmSync(breaker,{force:true})}}__name(breakStaleLock,"breakStaleLock");function takeBreaker(breaker){for(let attempt=0;attempt<2;attempt+=1){try{writeFileSync(breaker,String(process.pid),{flag:"wx"});return true}catch{try{if(Math.abs(Date.now()-statSync(breaker).mtimeMs)<=6e4){return false}rmSync(breaker,{force:true})}catch{}}}return false}__name(takeBreaker,"takeBreaker");function takeLock(pending,lockPath,token){try{linkSync(pending,lockPath);return true}catch(err){if(err.code==="EEXIST")return false}try{writeFileSync(lockPath,token,{flag:"wx"});return true}catch(err){if(err.code==="EEXIST")return false;throw err}}__name(takeLock,"takeLock");function processAlive(pid){if(!Number.isInteger(pid)||pid<1)return false;try{process.kill(pid,0);return true}catch(err){return err.code==="EPERM"}}__name(processAlive,"processAlive");function currentSessionId(){return process.env["QWEN_CODE_SESSION_ID"]?.trim()??""}__name(currentSessionId,"currentSessionId");function requireState(statePath,prNumber){const state=readState(statePath);if(!state){throw new Error(`PR #${prNumber} is not prepared here; run \`qwen autofix-pr prepare ${prNumber} --repo <owner>/<repo>\` first.`)}return state}__name(requireState,"requireState");var TASK_OPTION={type:"string",describe:"The scheduled task that woke the round (its prompt's --task): refused unless it still drives the watch"};function taskArg(argv){return argv["task"]===void 0?void 0:String(argv["task"])}__name(taskArg,"taskArg");function assertWatching(state,task){if(state.ended){throw new Error(`PR #${state.prNumber}'s watch was stopped (${state.ended.reason}); its worktree was kept. Start it again with /autofix-pr ${state.prNumber}.`)}assertOwnedBySession(state);if(task!==void 0&&state.watch?.task!==task){throw new Error(`task ${task} no longer drives PR #${state.prNumber}'s watch; delete the task whose gate has --task ${task}`+(state.watch?.task?`, not the one with --task ${state.watch.task}, which drives it.`:"."))}}__name(assertWatching,"assertWatching");function ghNotFound(err){const stderr=err.stderr;return/\(HTTP 404\)/.test(typeof stderr==="string"?stderr:"")}__name(ghNotFound,"ghNotFound");function assertOwnedBySession(state){const sessionId=currentSessionId();if(state.sessionId!==sessionId){throw new Error(`PR #${state.prNumber} is watched by another session (${state.sessionId||"no session"}). Take it over with `+(state.watch?`\`/autofix-pr resume ${state.prNumber}\``:`\`/autofix-pr ${state.prNumber}\``)+`, end it keeping its work with \`qwen autofix-pr cleanup ${state.prNumber} --take-over\` (what \`/autofix-pr stop ${state.prNumber}\` runs), or discard it with \`cleanup ${state.prNumber} --force\`.`)}}__name(assertOwnedBySession,"assertOwnedBySession");init_esbuild_shims();import{lstatSync as lstatSync2,readFileSync as readFileSync2,renameSync as renameSync2,rmSync as rmSync2}from"node:fs";import{dirname as dirname2,join as join2}from"node:path";var FIX_FRESH_MS=9e4;var FIX_MAX_AGE_MS=45*6e4;var CLOCK_SKEW_MS=6e4;var FIX_SNAPSHOT_MAX_AGE_MS=30*6e4;var ATTEMPT_RE=/^[0-9a-f]{12}$/;function assertAttemptId(attempt){if(!ATTEMPT_RE.test(attempt)){throw new TypeError(`--attempt must be the id the session opened the attempt with, got ${JSON.stringify(attempt)}`)}}__name(assertAttemptId,"assertAttemptId");function isFixAttempt(value){const v=value;return typeof v==="object"&&v!==null&&v.version===1&&typeof v.attempt==="string"&&ATTEMPT_RE.test(v.attempt)&&typeof v.task==="string"&&typeof v.head==="string"&&typeof v.startedAt==="string"&&Number.isFinite(Date.parse(v.startedAt))}__name(isFixAttempt,"isFixAttempt");function readFixMarker(paths){const stat=lstatSync2(paths.fixPath,{throwIfNoEntry:false});if(!stat)return null;if(!stat.isFile())return{attempt:null,mtimeMs:stat.mtimeMs};let parsed;try{parsed=JSON.parse(readFileSync2(paths.fixPath,"utf8"))}catch{parsed=null}return{attempt:isFixAttempt(parsed)?parsed:null,mtimeMs:stat.mtimeMs}}__name(readFixMarker,"readFixMarker");function fixInFlight(paths,now=Date.now()){return freshAttempt(readFixMarker(paths),now)}__name(fixInFlight,"fixInFlight");function freshAttempt(marker,now=Date.now()){if(!marker?.attempt)return null;const started=Date.parse(marker.attempt.startedAt);const fresh=marker.mtimeMs<=now+CLOCK_SKEW_MS&&now-marker.mtimeMs<=FIX_FRESH_MS&&started<=now+CLOCK_SKEW_MS&&now-started<FIX_MAX_AGE_MS;return fresh?marker.attempt:null}__name(freshAttempt,"freshAttempt");function assertNoFixInFlight(paths,prNumber,now=Date.now()){const attempt=fixInFlight(paths,now);if(!attempt)return;throw new Error(`a fix agent is working in PR #${prNumber}'s worktree (attempt ${attempt.attempt}, started ${attempt.startedAt}); its round goes on when it ends. In the session that runs it, /autofix-pr stop ${prNumber} stops it; it ends by itself within 45 minutes, and one its session gave up on within 90 seconds.`)}__name(assertNoFixInFlight,"assertNoFixInFlight");function clearAbandonedFix(paths,now=Date.now()){const marker=readFixMarker(paths);if(!marker||fixInFlight(paths,now))return null;rmSync2(paths.fixPath,{force:true,recursive:true});if(isRegularFile(paths.snapshotPath))rmSync2(paths.snapshotPath);return{startedAt:marker.attempt?.startedAt??null}}__name(clearAbandonedFix,"clearAbandonedFix");function briefPath(paths,prNumber){return join2(dirname2(paths.statePath),`autofix-pr-${prNumber}-brief.md`)}__name(briefPath,"briefPath");function fixSnapshotPath(paths,prNumber){return join2(dirname2(paths.statePath),`autofix-pr-${prNumber}-fix-snapshot.json`)}__name(fixSnapshotPath,"fixSnapshotPath");function assertRoundToFix(paths,prNumber,head,task){const stat=lstatSync2(paths.snapshotPath,{throwIfNoEntry:false});let snapshot=null;if(stat?.isFile()){try{snapshot=JSON.parse(readFileSync2(paths.snapshotPath,"utf8"))}catch{snapshot=null}}if(!stat||snapshot?.action!=="fix"||snapshot.headSha!==head||snapshot.task!==task||Date.now()-stat.mtimeMs>FIX_SNAPSHOT_MAX_AGE_MS){throw new Error(`no round of PR #${prNumber} has a fix to start: a fix runs in the background only after the snapshot of a round of the watch's task (action "fix" at the watch's head, within ${FIX_SNAPSHOT_MAX_AGE_MS/6e4} minutes).`)}let reportedAt=Number.NaN;try{reportedAt=Date.parse(readGateCursor(paths.gatePath)?.reportedAt??"")}catch{reportedAt=Number.NaN}const readAt=typeof snapshot.readAt==="string"?Date.parse(snapshot.readAt):NaN;if(!(reportedAt<=readAt)&&Number.isFinite(reportedAt)){throw new Error(`no round of PR #${prNumber} has a fix to start: the gate reported more since the round's snapshot; the fix runs in the foreground.`)}}__name(assertRoundToFix,"assertRoundToFix");function runFixStart(args){assertAttemptId(args.attempt);const paths=autofixPrPaths(repoRoot(),args.pr);return withWatchLock(paths,args.pr,()=>{const state=requireState(paths.statePath,args.pr);assertWatching(state);const task=state.watch?.task;if(!task){throw new Error(`PR #${args.pr} has no scheduled task: a fix runs in the background only in a watch.`)}const running=fixInFlight(paths);if(running){throw new Error(`attempt ${running.attempt} of PR #${args.pr}'s fix is still in flight (started ${running.startedAt}).`)}if(readFixMarker(paths)){throw new Error(`an earlier attempt of PR #${args.pr}'s fix was left behind; the round's sync removes it first.`)}assertRoundToFix(paths,args.pr,state.lastKnownHeadSha,task);const attempt={version:1,attempt:args.attempt,task,head:state.lastKnownHeadSha,startedAt:new Date().toISOString()};atomicWriteFileSync(paths.fixPath,`${JSON.stringify(attempt,null,2)}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{batchCommand,listWorkflowCommand,prepareEndpoint,resolveEndpoint}from"./chunk-
|
|
3
|
+
import{batchCommand,listWorkflowCommand,prepareEndpoint,resolveEndpoint}from"./chunk-ZSKCF6DI.js";import"./chunk-GGM3I5AO.js";import"./chunk-XKSB7VTV.js";import"./chunk-MVGQFFIK.js";import"./chunk-UPPE4I6H.js";import"./chunk-UWCF7JIF.js";import"./chunk-LMUSSYJH.js";import"./chunk-EZMTX4EU.js";import"./chunk-MWABT6CH.js";import"./chunk-TW5QEP2J.js";import"./chunk-PKK2D2W4.js";import"./chunk-HZ4Y7DH5.js";import"./chunk-E5T4R2PM.js";import"./chunk-VOBNHBCJ.js";import"./chunk-GT4TCQ3R.js";import"./chunk-XIYLRIW4.js";import"./chunk-EIPLDYEY.js";import"./chunk-IDXJIDME.js";import"./chunk-A5TAAMML.js";import"./chunk-QS2ZMQIS.js";import"./chunk-S7IKHQ6I.js";import"./chunk-DOLUT3XC.js";import"./chunk-PTHIQ7ZN.js";import"./chunk-PAD5GPDY.js";import"./chunk-MD3ZEOBX.js";import"./chunk-X5QSFJVS.js";import"./chunk-2Q7T5CR2.js";import"./chunk-46VUDNCL.js";import"./chunk-MKH3EH7O.js";import"./chunk-JFVXZFMV.js";import"./chunk-BNYJY4OL.js";import"./chunk-JKV4ODXE.js";import"./chunk-YBISME5B.js";import"./chunk-ZHHFNZ5J.js";import"./chunk-M3C6RDGC.js";import"./chunk-AKWYMQKU.js";import"./chunk-MZUOREFD.js";import"./chunk-IGPAATQW.js";import"./chunk-XZACON5H.js";import"./chunk-7EBRMQYW.js";import"./chunk-ZZJXFLVM.js";import"./chunk-RKDS7A4H.js";import"./chunk-V6VMUJ47.js";import"./chunk-IV3HAIUN.js";import"./chunk-UYYQB2TU.js";import"./chunk-VET7MLTV.js";import"./chunk-HN5UYLPU.js";import"./chunk-DECUAM3U.js";import"./chunk-PGRN3GZY.js";import"./chunk-YFTVFH2A.js";import"./chunk-ZBHL2CXR.js";import"./chunk-NIOS3B3V.js";import"./chunk-LZNBHBAJ.js";import"./chunk-R2EHHA2C.js";import"./chunk-ZLZF2ZDD.js";import"./chunk-YK7NDQKM.js";import"./chunk-TLROJH6O.js";import"./chunk-PHIPLV2I.js";import"./chunk-2EUNU5M5.js";import"./chunk-7DCW657A.js";import"./chunk-FIXDX63I.js";import"./chunk-T7CHK6C2.js";import"./chunk-PT7NZBDY.js";import"./chunk-TWP72VRH.js";import"./chunk-UYEWRLGD.js";import"./chunk-2MB4ZSKF.js";import"./chunk-WK2IBT6D.js";import"./chunk-ILECDNJX.js";import"./chunk-QXQGUM3Y.js";import"./chunk-TRA6EVDT.js";import"./chunk-DBA3F3D7.js";import"./chunk-QVPT37XZ.js";import"./chunk-T6W33SET.js";import"./chunk-4WFGJVTF.js";import"./chunk-BYU42MLK.js";import"./chunk-JWQXU3SR.js";import"./chunk-5LZ2DPLH.js";import"./chunk-XQJOZDV7.js";import"./chunk-CV2UAEZA.js";import"./chunk-LO76B6GW.js";import"./chunk-CMLAE3UB.js";import"./chunk-KLC3OD2M.js";import"./chunk-QZV4PFQK.js";import"./chunk-VXRLLVOP.js";import"./chunk-G5PYYZMM.js";import"./chunk-BG67XABA.js";import"./chunk-BEKROCWN.js";import"./chunk-OBOU4ZZM.js";import"./chunk-D7XCQWP2.js";import"./chunk-AE5OMKRY.js";import"./chunk-QF44NNSC.js";import"./chunk-QX4PIAJI.js";import"./chunk-7DQ2T3TA.js";import"./chunk-TDHEAGDX.js";import"./chunk-JZK2WGXA.js";import"./chunk-MPHSE7M4.js";import"./chunk-S2ZKZXHX.js";import"./chunk-4GP3PH7Z.js";import"./chunk-4QQKOW5M.js";import"./chunk-OV3EBH6J.js";import"./chunk-EBMCWXGZ.js";import"./chunk-DPNGBOI7.js";import"./chunk-7UK4WJWS.js";import"./chunk-HMIP4IK2.js";import"./chunk-SG3M7EYB.js";import"./chunk-YIW3H46P.js";import"./chunk-E6MI76C2.js";import"./chunk-NTNKD4KR.js";import"./chunk-4ZRCV3JY.js";import"./chunk-K7TPIVP4.js";import"./chunk-CQCSNHPU.js";import"./chunk-YGLM5XPP.js";import"./chunk-WGNF7FPC.js";import"./chunk-4NPYOXJO.js";import"./chunk-MWGB5RCF.js";import"./chunk-SCD5TUBG.js";import"./chunk-NTRFETZB.js";import"./chunk-TL3SF2GA.js";import"./chunk-GRW3GBXN.js";import"./chunk-4JNHUZ7M.js";import"./chunk-SW54YEPK.js";import"./chunk-FNDMWG43.js";import"./chunk-AGQBNWGY.js";import"./chunk-AGEDDL7Z.js";import"./chunk-2NJJHZ52.js";import"./chunk-BN4FIQ77.js";import"./chunk-IKDZVJH2.js";import"./chunk-3YWXKSOI.js";import"./chunk-OZGM5CCE.js";import"./chunk-S4KYECMU.js";import"./chunk-VFB6Q74I.js";import"./chunk-A6LT3FIJ.js";import"./chunk-S6RXVOY6.js";import"./chunk-X64RXJQQ.js";import"./chunk-HETUGUHE.js";import"./chunk-BDQOLT37.js";import"./chunk-NCVLAQE5.js";import"./chunk-476F6QIM.js";import"./chunk-4R67LXKL.js";import"./chunk-VTDSLBET.js";import"./chunk-TNCN2JX2.js";import"./chunk-UQFTXKEB.js";import"./chunk-HDGTWJ24.js";import"./chunk-W5NWIGKO.js";import"./chunk-KVA6DHHF.js";import"./chunk-PWOQASXT.js";import"./chunk-K7JCVESI.js";import"./chunk-Y6HHV4LC.js";import"./chunk-RP57XAJ2.js";import"./chunk-Z6AR5XE5.js";import"./chunk-77V43YOE.js";import"./chunk-7U7CWMP7.js";import"./chunk-SLD7H2FA.js";import"./chunk-7DOOXUDG.js";import"./chunk-4DIWAQ5G.js";import"./chunk-Q6UAOTP3.js";import"./chunk-DZ3GV34J.js";import"./chunk-HEDN54OB.js";import"./chunk-4ZBZL23U.js";import"./chunk-ZZZAYAJW.js";import"./chunk-XMANRGPK.js";import"./chunk-XHV5HLJS.js";import"./chunk-KQX4H2D3.js";import"./chunk-URNNJMIC.js";import"./chunk-HTW7PYHK.js";import"./chunk-AMGUAA4G.js";import"./chunk-BMHYEQTI.js";import"./chunk-GU22I6TY.js";import"./chunk-YEYW7PPR.js";import"./chunk-SLPJ4OII.js";import"./chunk-4YLXNRRH.js";import"./chunk-B3ZFUGTC.js";import"./chunk-IRINPFG7.js";import"./chunk-6GTPLW7K.js";import"./chunk-NGVRCUYD.js";import"./chunk-5DTFN37U.js";import"./chunk-2YUBAWQ6.js";import"./chunk-O5EKX7LG.js";import"./chunk-TM6ZCBR7.js";import"./chunk-SVAPAMMG.js";import"./chunk-3KUHQGOS.js";import"./chunk-I6S7NGX3.js";import"./chunk-SBZFGYYS.js";import"./chunk-JAUJI56S.js";import"./chunk-I4H7NUVP.js";import"./chunk-EPODBRBP.js";import"./chunk-OKN3Z5C5.js";import"./chunk-XYB7GC5U.js";import"./chunk-2UOMCYQG.js";import"./chunk-I7L2TX4M.js";import"./chunk-MK3OONRA.js";import"./chunk-COGTQ5KZ.js";import"./chunk-VKDAXTCZ.js";import"./chunk-KBWJGX7I.js";export{batchCommand,listWorkflowCommand,prepareEndpoint,resolveEndpoint};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{classifyTurnErrorKind,createAcpSessionBridge,createHttpAcpBridge,extractErrorCode,extractErrorMessage}from"./chunk-
|
|
3
|
+
import{classifyTurnErrorKind,createAcpSessionBridge,createHttpAcpBridge,extractErrorCode,extractErrorMessage}from"./chunk-FCZYH27X.js";import"./chunk-BWQ5AIEA.js";import"./chunk-WDR5XP3Y.js";import"./chunk-IFPLGH5C.js";import"./chunk-OBGX5CDE.js";import"./chunk-2QYDBHYZ.js";import"./chunk-LUDNUVSA.js";import"./chunk-WBDNGVHU.js";import"./chunk-VTZZXEWA.js";import"./chunk-L5UULTGF.js";import"./chunk-3KZHPZVZ.js";import"./chunk-NIEO2TBE.js";import"./chunk-CFTFKWPW.js";import"./chunk-WSOEJTOC.js";import"./chunk-A5TAAMML.js";import"./chunk-QS2ZMQIS.js";import"./chunk-S7IKHQ6I.js";import"./chunk-PAD5GPDY.js";import"./chunk-MD3ZEOBX.js";import"./chunk-X5QSFJVS.js";import"./chunk-2Q7T5CR2.js";import"./chunk-46VUDNCL.js";import"./chunk-MKH3EH7O.js";import"./chunk-JFVXZFMV.js";import"./chunk-BNYJY4OL.js";import"./chunk-JKV4ODXE.js";import"./chunk-YBISME5B.js";import"./chunk-ZHHFNZ5J.js";import"./chunk-M3C6RDGC.js";import"./chunk-AKWYMQKU.js";import"./chunk-MZUOREFD.js";import"./chunk-IGPAATQW.js";import"./chunk-XZACON5H.js";import"./chunk-7EBRMQYW.js";import"./chunk-ZZJXFLVM.js";import"./chunk-RKDS7A4H.js";import"./chunk-V6VMUJ47.js";import"./chunk-IV3HAIUN.js";import"./chunk-UYYQB2TU.js";import"./chunk-VET7MLTV.js";import"./chunk-HN5UYLPU.js";import"./chunk-DECUAM3U.js";import"./chunk-PGRN3GZY.js";import"./chunk-YFTVFH2A.js";import"./chunk-ZBHL2CXR.js";import"./chunk-NIOS3B3V.js";import"./chunk-LZNBHBAJ.js";import"./chunk-R2EHHA2C.js";import"./chunk-ZLZF2ZDD.js";import"./chunk-YK7NDQKM.js";import"./chunk-TLROJH6O.js";import"./chunk-PHIPLV2I.js";import"./chunk-2EUNU5M5.js";import"./chunk-7DCW657A.js";import"./chunk-FIXDX63I.js";import"./chunk-T7CHK6C2.js";import"./chunk-PT7NZBDY.js";import"./chunk-TWP72VRH.js";import"./chunk-UYEWRLGD.js";import"./chunk-2MB4ZSKF.js";import"./chunk-WK2IBT6D.js";import"./chunk-ILECDNJX.js";import"./chunk-QXQGUM3Y.js";import"./chunk-TRA6EVDT.js";import"./chunk-DBA3F3D7.js";import"./chunk-QVPT37XZ.js";import"./chunk-T6W33SET.js";import"./chunk-4WFGJVTF.js";import"./chunk-BYU42MLK.js";import"./chunk-JWQXU3SR.js";import"./chunk-5LZ2DPLH.js";import"./chunk-XQJOZDV7.js";import"./chunk-CV2UAEZA.js";import"./chunk-LO76B6GW.js";import"./chunk-CMLAE3UB.js";import"./chunk-KLC3OD2M.js";import"./chunk-QZV4PFQK.js";import"./chunk-VXRLLVOP.js";import"./chunk-G5PYYZMM.js";import"./chunk-BG67XABA.js";import"./chunk-BEKROCWN.js";import"./chunk-OBOU4ZZM.js";import"./chunk-D7XCQWP2.js";import"./chunk-AE5OMKRY.js";import"./chunk-QF44NNSC.js";import"./chunk-QX4PIAJI.js";import"./chunk-7DQ2T3TA.js";import"./chunk-TDHEAGDX.js";import"./chunk-JZK2WGXA.js";import"./chunk-MPHSE7M4.js";import"./chunk-S2ZKZXHX.js";import"./chunk-4GP3PH7Z.js";import"./chunk-4QQKOW5M.js";import"./chunk-OV3EBH6J.js";import"./chunk-EBMCWXGZ.js";import"./chunk-DPNGBOI7.js";import"./chunk-7UK4WJWS.js";import"./chunk-HMIP4IK2.js";import"./chunk-SG3M7EYB.js";import"./chunk-YIW3H46P.js";import"./chunk-E6MI76C2.js";import"./chunk-NTNKD4KR.js";import"./chunk-4ZRCV3JY.js";import"./chunk-K7TPIVP4.js";import"./chunk-CQCSNHPU.js";import"./chunk-YGLM5XPP.js";import"./chunk-WGNF7FPC.js";import"./chunk-4NPYOXJO.js";import"./chunk-MWGB5RCF.js";import"./chunk-SCD5TUBG.js";import"./chunk-NTRFETZB.js";import"./chunk-TL3SF2GA.js";import"./chunk-GRW3GBXN.js";import"./chunk-4JNHUZ7M.js";import"./chunk-SW54YEPK.js";import"./chunk-FNDMWG43.js";import"./chunk-AGQBNWGY.js";import"./chunk-AGEDDL7Z.js";import"./chunk-2NJJHZ52.js";import"./chunk-BN4FIQ77.js";import"./chunk-IKDZVJH2.js";import"./chunk-3YWXKSOI.js";import"./chunk-OZGM5CCE.js";import"./chunk-S4KYECMU.js";import"./chunk-VFB6Q74I.js";import"./chunk-A6LT3FIJ.js";import"./chunk-S6RXVOY6.js";import"./chunk-X64RXJQQ.js";import"./chunk-HETUGUHE.js";import"./chunk-BDQOLT37.js";import"./chunk-NCVLAQE5.js";import"./chunk-476F6QIM.js";import"./chunk-4R67LXKL.js";import"./chunk-VTDSLBET.js";import"./chunk-TNCN2JX2.js";import"./chunk-UQFTXKEB.js";import"./chunk-HDGTWJ24.js";import"./chunk-W5NWIGKO.js";import"./chunk-KVA6DHHF.js";import"./chunk-PWOQASXT.js";import"./chunk-K7JCVESI.js";import"./chunk-Y6HHV4LC.js";import"./chunk-RP57XAJ2.js";import"./chunk-Z6AR5XE5.js";import"./chunk-77V43YOE.js";import"./chunk-7U7CWMP7.js";import"./chunk-SLD7H2FA.js";import"./chunk-7DOOXUDG.js";import"./chunk-4DIWAQ5G.js";import"./chunk-Q6UAOTP3.js";import"./chunk-DZ3GV34J.js";import"./chunk-HEDN54OB.js";import"./chunk-4ZBZL23U.js";import"./chunk-ZZZAYAJW.js";import"./chunk-XMANRGPK.js";import"./chunk-XHV5HLJS.js";import"./chunk-KQX4H2D3.js";import"./chunk-URNNJMIC.js";import"./chunk-HTW7PYHK.js";import"./chunk-AMGUAA4G.js";import"./chunk-BMHYEQTI.js";import"./chunk-GU22I6TY.js";import"./chunk-YEYW7PPR.js";import"./chunk-4YLXNRRH.js";import"./chunk-B3ZFUGTC.js";import"./chunk-IRINPFG7.js";import"./chunk-6GTPLW7K.js";import"./chunk-NGVRCUYD.js";import"./chunk-5DTFN37U.js";import"./chunk-2YUBAWQ6.js";import"./chunk-O5EKX7LG.js";import"./chunk-TM6ZCBR7.js";import"./chunk-SVAPAMMG.js";import"./chunk-3KUHQGOS.js";import"./chunk-I6S7NGX3.js";import"./chunk-SBZFGYYS.js";import"./chunk-JAUJI56S.js";import"./chunk-I4H7NUVP.js";import"./chunk-EPODBRBP.js";import"./chunk-OKN3Z5C5.js";import"./chunk-XYB7GC5U.js";import"./chunk-2UOMCYQG.js";import"./chunk-I7L2TX4M.js";import"./chunk-MK3OONRA.js";import"./chunk-COGTQ5KZ.js";import"./chunk-VKDAXTCZ.js";import"./chunk-KBWJGX7I.js";export{classifyTurnErrorKind,createAcpSessionBridge,createHttpAcpBridge,extractErrorCode,extractErrorMessage};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{ChannelSettingsError,WorkspaceChannelSettingsStore,assertValidChannelSecretUpdates}from"./chunk-
|
|
3
|
+
import{ChannelSettingsError,WorkspaceChannelSettingsStore,assertValidChannelSecretUpdates}from"./chunk-US42COBM.js";import"./chunk-FJUXMWZW.js";import"./chunk-MHZY2JYX.js";import"./chunk-JBJA2Y7T.js";import"./chunk-W7V6J2VV.js";import"./chunk-44WSAMWG.js";import"./chunk-WSOEJTOC.js";import"./chunk-MVGQFFIK.js";import"./chunk-UPPE4I6H.js";import"./chunk-UWCF7JIF.js";import"./chunk-LMUSSYJH.js";import"./chunk-EZMTX4EU.js";import"./chunk-MWABT6CH.js";import"./chunk-TW5QEP2J.js";import"./chunk-PKK2D2W4.js";import"./chunk-HZ4Y7DH5.js";import"./chunk-E5T4R2PM.js";import"./chunk-XIYLRIW4.js";import"./chunk-EIPLDYEY.js";import"./chunk-IDXJIDME.js";import"./chunk-A5TAAMML.js";import"./chunk-QS2ZMQIS.js";import"./chunk-S7IKHQ6I.js";import"./chunk-DOLUT3XC.js";import"./chunk-PTHIQ7ZN.js";import"./chunk-PAD5GPDY.js";import"./chunk-MD3ZEOBX.js";import"./chunk-X5QSFJVS.js";import"./chunk-2Q7T5CR2.js";import"./chunk-46VUDNCL.js";import"./chunk-MKH3EH7O.js";import"./chunk-JFVXZFMV.js";import"./chunk-BNYJY4OL.js";import"./chunk-JKV4ODXE.js";import"./chunk-YBISME5B.js";import"./chunk-ZHHFNZ5J.js";import"./chunk-M3C6RDGC.js";import"./chunk-AKWYMQKU.js";import"./chunk-MZUOREFD.js";import"./chunk-IGPAATQW.js";import"./chunk-XZACON5H.js";import"./chunk-7EBRMQYW.js";import"./chunk-ZZJXFLVM.js";import"./chunk-RKDS7A4H.js";import"./chunk-V6VMUJ47.js";import"./chunk-IV3HAIUN.js";import"./chunk-UYYQB2TU.js";import"./chunk-VET7MLTV.js";import"./chunk-HN5UYLPU.js";import"./chunk-DECUAM3U.js";import"./chunk-PGRN3GZY.js";import"./chunk-YFTVFH2A.js";import"./chunk-ZBHL2CXR.js";import"./chunk-NIOS3B3V.js";import"./chunk-LZNBHBAJ.js";import"./chunk-R2EHHA2C.js";import"./chunk-ZLZF2ZDD.js";import"./chunk-YK7NDQKM.js";import"./chunk-TLROJH6O.js";import"./chunk-PHIPLV2I.js";import"./chunk-2EUNU5M5.js";import"./chunk-7DCW657A.js";import"./chunk-FIXDX63I.js";import"./chunk-T7CHK6C2.js";import"./chunk-PT7NZBDY.js";import"./chunk-TWP72VRH.js";import"./chunk-UYEWRLGD.js";import"./chunk-2MB4ZSKF.js";import"./chunk-WK2IBT6D.js";import"./chunk-ILECDNJX.js";import"./chunk-QXQGUM3Y.js";import"./chunk-TRA6EVDT.js";import"./chunk-DBA3F3D7.js";import"./chunk-QVPT37XZ.js";import"./chunk-T6W33SET.js";import"./chunk-4WFGJVTF.js";import"./chunk-BYU42MLK.js";import"./chunk-JWQXU3SR.js";import"./chunk-5LZ2DPLH.js";import"./chunk-XQJOZDV7.js";import"./chunk-CV2UAEZA.js";import"./chunk-LO76B6GW.js";import"./chunk-CMLAE3UB.js";import"./chunk-KLC3OD2M.js";import"./chunk-QZV4PFQK.js";import"./chunk-VXRLLVOP.js";import"./chunk-G5PYYZMM.js";import"./chunk-BG67XABA.js";import"./chunk-BEKROCWN.js";import"./chunk-OBOU4ZZM.js";import"./chunk-D7XCQWP2.js";import"./chunk-AE5OMKRY.js";import"./chunk-QF44NNSC.js";import"./chunk-QX4PIAJI.js";import"./chunk-7DQ2T3TA.js";import"./chunk-TDHEAGDX.js";import"./chunk-JZK2WGXA.js";import"./chunk-MPHSE7M4.js";import"./chunk-S2ZKZXHX.js";import"./chunk-4GP3PH7Z.js";import"./chunk-4QQKOW5M.js";import"./chunk-OV3EBH6J.js";import"./chunk-EBMCWXGZ.js";import"./chunk-DPNGBOI7.js";import"./chunk-7UK4WJWS.js";import"./chunk-HMIP4IK2.js";import"./chunk-SG3M7EYB.js";import"./chunk-YIW3H46P.js";import"./chunk-E6MI76C2.js";import"./chunk-NTNKD4KR.js";import"./chunk-4ZRCV3JY.js";import"./chunk-K7TPIVP4.js";import"./chunk-CQCSNHPU.js";import"./chunk-YGLM5XPP.js";import"./chunk-WGNF7FPC.js";import"./chunk-4NPYOXJO.js";import"./chunk-MWGB5RCF.js";import"./chunk-SCD5TUBG.js";import"./chunk-NTRFETZB.js";import"./chunk-TL3SF2GA.js";import"./chunk-GRW3GBXN.js";import"./chunk-4JNHUZ7M.js";import"./chunk-SW54YEPK.js";import"./chunk-FNDMWG43.js";import"./chunk-AGQBNWGY.js";import"./chunk-AGEDDL7Z.js";import"./chunk-2NJJHZ52.js";import"./chunk-BN4FIQ77.js";import"./chunk-IKDZVJH2.js";import"./chunk-3YWXKSOI.js";import"./chunk-OZGM5CCE.js";import"./chunk-S4KYECMU.js";import"./chunk-VFB6Q74I.js";import"./chunk-A6LT3FIJ.js";import"./chunk-S6RXVOY6.js";import"./chunk-X64RXJQQ.js";import"./chunk-HETUGUHE.js";import"./chunk-BDQOLT37.js";import"./chunk-NCVLAQE5.js";import"./chunk-476F6QIM.js";import"./chunk-4R67LXKL.js";import"./chunk-VTDSLBET.js";import"./chunk-TNCN2JX2.js";import"./chunk-UQFTXKEB.js";import"./chunk-HDGTWJ24.js";import"./chunk-W5NWIGKO.js";import"./chunk-KVA6DHHF.js";import"./chunk-PWOQASXT.js";import"./chunk-K7JCVESI.js";import"./chunk-Y6HHV4LC.js";import"./chunk-RP57XAJ2.js";import"./chunk-Z6AR5XE5.js";import"./chunk-77V43YOE.js";import"./chunk-7U7CWMP7.js";import"./chunk-SLD7H2FA.js";import"./chunk-7DOOXUDG.js";import"./chunk-4DIWAQ5G.js";import"./chunk-Q6UAOTP3.js";import"./chunk-DZ3GV34J.js";import"./chunk-HEDN54OB.js";import"./chunk-4ZBZL23U.js";import"./chunk-ZZZAYAJW.js";import"./chunk-XMANRGPK.js";import"./chunk-XHV5HLJS.js";import"./chunk-KQX4H2D3.js";import"./chunk-URNNJMIC.js";import"./chunk-HTW7PYHK.js";import"./chunk-AMGUAA4G.js";import"./chunk-BMHYEQTI.js";import"./chunk-GU22I6TY.js";import"./chunk-YEYW7PPR.js";import"./chunk-SLPJ4OII.js";import"./chunk-4YLXNRRH.js";import"./chunk-B3ZFUGTC.js";import"./chunk-IRINPFG7.js";import"./chunk-6GTPLW7K.js";import"./chunk-NGVRCUYD.js";import"./chunk-5DTFN37U.js";import"./chunk-2YUBAWQ6.js";import"./chunk-O5EKX7LG.js";import"./chunk-TM6ZCBR7.js";import"./chunk-SVAPAMMG.js";import"./chunk-3KUHQGOS.js";import"./chunk-I6S7NGX3.js";import"./chunk-SBZFGYYS.js";import"./chunk-JAUJI56S.js";import"./chunk-I4H7NUVP.js";import"./chunk-EPODBRBP.js";import"./chunk-OKN3Z5C5.js";import"./chunk-XYB7GC5U.js";import"./chunk-2UOMCYQG.js";import"./chunk-I7L2TX4M.js";import"./chunk-MK3OONRA.js";import"./chunk-COGTQ5KZ.js";import"./chunk-VKDAXTCZ.js";import"./chunk-KBWJGX7I.js";export{ChannelSettingsError,WorkspaceChannelSettingsStore,assertValidChannelSecretUpdates};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";init_esbuild_shims();var GIT_COMMIT_INFO="
|
|
3
|
+
import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";init_esbuild_shims();var GIT_COMMIT_INFO="47262f97d8";var CLI_VERSION="0.26.2-preview.1";export{GIT_COMMIT_INFO,CLI_VERSION};
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2026 Google LLC
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{MAX_WORKSPACE_PATH_LENGTH,canonicalizeWorkspace}from"./chunk-L5UULTGF.js";import{isWithinRoot}from"./chunk-IDXJIDME.js";import{getGlobalQwenDirLite}from"./chunk-PTHIQ7ZN.js";import{isUnverifiableIdentityError,openNoFollow}from"./chunk-QXQGUM3Y.js";import{require_proper_lockfile}from"./chunk-YIW3H46P.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name,__toESM}from"./chunk-KBWJGX7I.js";init_esbuild_shims();var import_proper_lockfile=__toESM(require_proper_lockfile(),1);import{createHash}from"node:crypto";import*as fs from"node:fs/promises";import*as os from"node:os";import*as path from"node:path";init_esbuild_shims();var MAX_REGISTERED_WORKSPACES=256;var MAX_CONFIGURED_REGISTERED_WORKSPACES=256;var QWEN_SERVE_MAX_WORKSPACES_ENV="QWEN_SERVE_MAX_WORKSPACES";function resolveMaxRegisteredWorkspaces(configured,env){const raw=env[QWEN_SERVE_MAX_WORKSPACES_ENV];const value=configured??(raw===void 0?MAX_REGISTERED_WORKSPACES:/^\d+$/.test(raw.trim())?Number(raw.trim()):Number.NaN);if(!Number.isSafeInteger(value)||value<1||value>MAX_CONFIGURED_REGISTERED_WORKSPACES){const source=configured===void 0?`${QWEN_SERVE_MAX_WORKSPACES_ENV}=${JSON.stringify(raw)}`:`maxRegisteredWorkspaces option ${String(configured)}`;throw new TypeError(`Invalid ${source}: must be an integer from 1 to ${MAX_CONFIGURED_REGISTERED_WORKSPACES}.`)}return value}__name(resolveMaxRegisteredWorkspaces,"resolveMaxRegisteredWorkspaces");var DuplicateWorkspaceInputError=class extends Error{static{__name(this,"DuplicateWorkspaceInputError")}constructor(workspace){super(`Duplicate --workspace value resolves to ${JSON.stringify(workspace)}. Pass distinct --workspace values.`);this.name="DuplicateWorkspaceInputError"}};var NestedWorkspaceInputError=class extends Error{static{__name(this,"NestedWorkspaceInputError")}constructor(parent,child){super(`Nested --workspace values are not supported yet: ${JSON.stringify(child)} is inside ${JSON.stringify(parent)}. Pass non-nested --workspace values.`);this.name="NestedWorkspaceInputError"}};var MissingWorkspaceInputError=class extends Error{static{__name(this,"MissingWorkspaceInputError")}constructor(){super("--workspace requires a value.");this.name="MissingWorkspaceInputError"}};function normalizeWorkspaceInputs(workspace){if(Array.isArray(workspace)){if(workspace.length===0){throw new MissingWorkspaceInputError}return workspace.map(value=>String(value))}if(workspace===void 0)return[process.cwd()];return[String(workspace)]}__name(normalizeWorkspaceInputs,"normalizeWorkspaceInputs");function isNestedWorkspace(parent,child){return parent!==child&&isWithinRoot(child,parent)}__name(isNestedWorkspace,"isNestedWorkspace");function rejectDuplicateOrNestedWorkspaceInputs(workspaces){if(workspaces.length<=1)return;let canonicalWorkspaces;try{canonicalWorkspaces=workspaces.map(workspace=>canonicalizeWorkspace(workspace))}catch{return}const seen=new Set;for(const workspace of canonicalWorkspaces){if(seen.has(workspace)){throw new DuplicateWorkspaceInputError(workspace)}seen.add(workspace)}for(let i=0;i<canonicalWorkspaces.length;i++){for(let j=i+1;j<canonicalWorkspaces.length;j++){const first=canonicalWorkspaces[i];const second=canonicalWorkspaces[j];if(isNestedWorkspace(first,second)){throw new NestedWorkspaceInputError(first,second)}if(isNestedWorkspace(second,first)){throw new NestedWorkspaceInputError(second,first)}}}}__name(rejectDuplicateOrNestedWorkspaceInputs,"rejectDuplicateOrNestedWorkspaceInputs");function resolveWorkspaceInputs(workspace){const workspaces=normalizeWorkspaceInputs(workspace);rejectDuplicateOrNestedWorkspaceInputs(workspaces);return workspaces}__name(resolveWorkspaceInputs,"resolveWorkspaceInputs");var SCHEMA_VERSION=1;var MAX_SECONDARY_WORKSPACES=MAX_CONFIGURED_REGISTERED_WORKSPACES-1;var MAX_STORE_BYTES=8*1024*1024;var MAX_WORKSPACE_DISPLAY_NAME_LENGTH=256;var LOCK_OPTIONS={realpath:false,stale:1e4,update:2e3,retries:{retries:120,minTimeout:10,maxTimeout:100,factor:1.2,randomize:true}};var WorkspaceDisplayNameValidationError=class extends Error{static{__name(this,"WorkspaceDisplayNameValidationError")}constructor(message){super(message);this.name="WorkspaceDisplayNameValidationError"}};function containsDisplayNameControlCharacter(value){for(const character of value){const codePoint=character.codePointAt(0);if(codePoint<=31||codePoint===127)return true}return false}__name(containsDisplayNameControlCharacter,"containsDisplayNameControlCharacter");function normalizeWorkspaceDisplayName(value){if(typeof value!=="string"){throw new WorkspaceDisplayNameValidationError("Workspace display name must be a string")}const trimmed=value.trim();if(trimmed.length>MAX_WORKSPACE_DISPLAY_NAME_LENGTH){throw new WorkspaceDisplayNameValidationError(`Workspace display name exceeds ${MAX_WORKSPACE_DISPLAY_NAME_LENGTH} characters`)}if(containsDisplayNameControlCharacter(trimmed)){throw new WorkspaceDisplayNameValidationError("Workspace display name contains control characters")}return trimmed.length===0?void 0:trimmed}__name(normalizeWorkspaceDisplayName,"normalizeWorkspaceDisplayName");var WorkspaceRegistrationStoreError=class extends Error{static{__name(this,"WorkspaceRegistrationStoreError")}constructor(message){super(message);this.name="WorkspaceRegistrationStoreError"}};var WorkspaceRegistrationStoreLimitError=class extends WorkspaceRegistrationStoreError{static{__name(this,"WorkspaceRegistrationStoreLimitError")}};var WorkspaceRegistrationStoreTooLargeError=class extends WorkspaceRegistrationStoreError{static{__name(this,"WorkspaceRegistrationStoreTooLargeError")}};var WorkspaceRegistrationStoreCommittedError=class extends WorkspaceRegistrationStoreError{static{__name(this,"WorkspaceRegistrationStoreCommittedError")}};function normalizedScopePath(primaryWorkspace){return os.platform()==="win32"?primaryWorkspace.toLowerCase():primaryWorkspace}__name(normalizedScopePath,"normalizedScopePath");function workspaceRegistrationScopeHash(primaryWorkspace){return createHash("sha256").update(normalizedScopePath(primaryWorkspace)).digest("hex")}__name(workspaceRegistrationScopeHash,"workspaceRegistrationScopeHash");function workspaceRegistrationId(workspace){return createHash("sha256").update(workspace).digest("hex").slice(0,16)}__name(workspaceRegistrationId,"workspaceRegistrationId");function getWorkspaceRegistrationStorePath(primaryWorkspace,qwenHome=getGlobalQwenDirLite()){return path.join(qwenHome,"daemon","workspaces",`${workspaceRegistrationScopeHash(primaryWorkspace)}.json`)}__name(getWorkspaceRegistrationStorePath,"getWorkspaceRegistrationStorePath");function emptySnapshot(primaryWorkspace){return{schemaVersion:SCHEMA_VERSION,primaryWorkspace,workspaces:[]}}__name(emptySnapshot,"emptySnapshot");function validateWorkspacePath(value,label){if(typeof value!=="string"||!path.isAbsolute(value)){throw new WorkspaceRegistrationStoreError(`${label} must be an absolute path`)}if(value.includes("\0")||value.length>MAX_WORKSPACE_PATH_LENGTH){throw new WorkspaceRegistrationStoreError(`${label} is invalid`)}return value}__name(validateWorkspacePath,"validateWorkspacePath");function validateStoredDisplayName(value,label){let displayName;try{displayName=normalizeWorkspaceDisplayName(value)}catch(err){throw new WorkspaceRegistrationStoreError(`${label} is invalid: ${err instanceof Error?err.message:String(err)}`)}if(displayName===void 0){throw new WorkspaceRegistrationStoreError(`${label} must not be empty`)}return displayName}__name(validateStoredDisplayName,"validateStoredDisplayName");function setSnapshotDisplayName(snapshot,registrationId,displayName){if(displayName===void 0){if(!snapshot.displayNames||!Object.hasOwn(snapshot.displayNames,registrationId)){return false}delete snapshot.displayNames[registrationId];if(Object.keys(snapshot.displayNames).length===0){delete snapshot.displayNames}return true}if(snapshot.displayNames?.[registrationId]===displayName)return false;snapshot.displayNames??={};snapshot.displayNames[registrationId]=displayName;return true}__name(setSnapshotDisplayName,"setSnapshotDisplayName");function parseSnapshot(raw,primaryWorkspace){let value;try{value=JSON.parse(raw)}catch{throw new WorkspaceRegistrationStoreError("Workspace registration store contains malformed JSON")}if(typeof value!=="object"||value===null||Array.isArray(value)){throw new WorkspaceRegistrationStoreError("Workspace registration store root must be an object")}const record=value;if(record["schemaVersion"]!==SCHEMA_VERSION){throw new WorkspaceRegistrationStoreError(`Unsupported workspace registration schema ${String(record["schemaVersion"])}`)}const storedPrimary=validateWorkspacePath(record["primaryWorkspace"],"primaryWorkspace");if(normalizedScopePath(storedPrimary)!==normalizedScopePath(primaryWorkspace)){throw new WorkspaceRegistrationStoreError("Workspace registration store primary does not match this daemon")}if(!Array.isArray(record["workspaces"])){throw new WorkspaceRegistrationStoreError("Workspace registration store workspaces must be an array")}if(record["workspaces"].length>MAX_SECONDARY_WORKSPACES){throw new WorkspaceRegistrationStoreError(`Workspace registration store exceeds ${MAX_SECONDARY_WORKSPACES} entries`)}const seen=new Set;const workspaces=record["workspaces"].map((entry,index)=>{const workspace=validateWorkspacePath(entry,`workspaces[${index}]`);const normalizedWorkspace=normalizedScopePath(workspace);if(normalizedWorkspace===normalizedScopePath(primaryWorkspace)){throw new WorkspaceRegistrationStoreError("Primary workspace cannot be stored as a secondary registration")}if(seen.has(normalizedWorkspace)){throw new WorkspaceRegistrationStoreError("Workspace registration store contains duplicate paths")}seen.add(normalizedWorkspace);return workspace});const rawDisplayNames=record["displayNames"];let displayNames;if(rawDisplayNames!==void 0){if(typeof rawDisplayNames!=="object"||rawDisplayNames===null||Array.isArray(rawDisplayNames)){throw new WorkspaceRegistrationStoreError("Workspace registration store displayNames must be an object")}const registrationIds=new Set(workspaces.map(workspaceRegistrationId));for(const[registrationId,value2]of Object.entries(rawDisplayNames)){if(!registrationIds.has(registrationId)){throw new WorkspaceRegistrationStoreError(`Workspace registration store displayNames contains unknown registration id ${JSON.stringify(registrationId)}`)}displayNames??={};displayNames[registrationId]=validateStoredDisplayName(value2,`displayNames[${JSON.stringify(registrationId)}]`)}}return{schemaVersion:SCHEMA_VERSION,primaryWorkspace,workspaces,...displayNames?{displayNames}:{}}}__name(parseSnapshot,"parseSnapshot");var updateChains=new Map;async function withInProcessLock(filePath,work){const previous=updateChains.get(filePath)??Promise.resolve();const next=previous.then(work,work);const settled=next.catch(()=>void 0).finally(()=>{if(updateChains.get(filePath)===settled)updateChains.delete(filePath)});updateChains.set(filePath,settled);return next}__name(withInProcessLock,"withInProcessLock");function compromisedLockError(){return new WorkspaceRegistrationStoreError("Workspace registration store lock was compromised")}__name(compromisedLockError,"compromisedLockError");async function acquireFileLock(filePath){await fs.mkdir(path.dirname(filePath),{recursive:true,mode:448});let compromised=false;const release=await import_proper_lockfile.default.lock(filePath,{...LOCK_OPTIONS,onCompromised:__name(()=>{compromised=true},"onCompromised")});return{assertOwned:__name(()=>{if(compromised)throw compromisedLockError()},"assertOwned"),release:__name(async()=>{try{await release()}catch(err){if(!compromised)throw err}if(compromised)throw compromisedLockError()},"release")}}__name(acquireFileLock,"acquireFileLock");var WorkspaceRegistrationStore=class{constructor(primaryWorkspace,qwenHome){this.primaryWorkspace=primaryWorkspace;validateWorkspacePath(primaryWorkspace,"primaryWorkspace");this.filePath=getWorkspaceRegistrationStorePath(primaryWorkspace,qwenHome)}static{__name(this,"WorkspaceRegistrationStore")}filePath;async read(){try{const entry=await fs.lstat(this.filePath);if(entry.isSymbolicLink()||!entry.isFile()){throw new WorkspaceRegistrationStoreError("Workspace registration store must be a regular file")}}catch(err){if(err.code==="ENOENT"){return emptySnapshot(this.primaryWorkspace)}throw err}let file;try{file=await openNoFollow(this.filePath)}catch(err){if(err.code==="ENOENT"){return emptySnapshot(this.primaryWorkspace)}if(isUnverifiableIdentityError(err)){throw new WorkspaceRegistrationStoreError("Workspace registration store identity could not be verified")}if(err.code==="ELOOP"){throw new WorkspaceRegistrationStoreError("Workspace registration store must be a regular file")}throw err}try{const stat=await file.stat();if(!stat.isFile()){throw new WorkspaceRegistrationStoreError("Workspace registration store must be a regular file")}if(stat.size>MAX_STORE_BYTES){throw new WorkspaceRegistrationStoreTooLargeError(`Workspace registration store exceeds ${MAX_STORE_BYTES} bytes`)}let buffer=Buffer.alloc(Math.max(1,Math.min(stat.size+1,MAX_STORE_BYTES+1)));let totalBytesRead=0;for(;;){if(totalBytesRead===buffer.length){if(totalBytesRead>MAX_STORE_BYTES)break;const grown=Buffer.alloc(Math.min(MAX_STORE_BYTES+1,Math.max(buffer.length*2,totalBytesRead+1)));buffer.copy(grown,0,0,totalBytesRead);buffer=grown}const{bytesRead}=await file.read(buffer,totalBytesRead,buffer.length-totalBytesRead,totalBytesRead);if(bytesRead===0)break;totalBytesRead+=bytesRead}if(totalBytesRead>MAX_STORE_BYTES){throw new WorkspaceRegistrationStoreTooLargeError(`Workspace registration store exceeds ${MAX_STORE_BYTES} bytes`)}return parseSnapshot(buffer.toString("utf8",0,totalBytesRead),this.primaryWorkspace)}finally{await file.close()}}async add(workspace,displayName,maxRegisteredWorkspaces=MAX_REGISTERED_WORKSPACES){const maxSecondaries=resolveMaxRegisteredWorkspaces(maxRegisteredWorkspaces,{})-1;validateWorkspacePath(workspace,"workspace");const normalizedDisplayName=displayName===void 0?void 0:normalizeWorkspaceDisplayName(displayName);if(normalizedScopePath(workspace)===normalizedScopePath(this.primaryWorkspace)){throw new WorkspaceRegistrationStoreError("Primary workspace cannot be stored as a secondary registration")}return this.update(snapshot=>{const normalizedWorkspace=normalizedScopePath(workspace);if(snapshot.workspaces.some(stored=>normalizedScopePath(stored)===normalizedWorkspace)){return false}if(snapshot.workspaces.length>=maxSecondaries){throw new WorkspaceRegistrationStoreLimitError(`Workspace registration store limit of ${maxSecondaries} reached`)}snapshot.workspaces.push(workspace);if(normalizedDisplayName!==void 0){snapshot.displayNames??={};snapshot.displayNames[workspaceRegistrationId(workspace)]=normalizedDisplayName}return true})}async removeById(id){return await this.removeByIds([id])>0}async setDisplayNameByIds(ids,displayName){const normalizedDisplayName=displayName===void 0?void 0:normalizeWorkspaceDisplayName(displayName);const requested=new Set(ids);if(requested.size===0)return 0;let matched=0;await this.update(snapshot=>{let changed=false;for(const workspace of snapshot.workspaces){const registrationId=workspaceRegistrationId(workspace);if(!requested.has(registrationId))continue;matched++;changed=setSnapshotDisplayName(snapshot,registrationId,normalizedDisplayName)||changed}return changed});return matched}async removeByIds(ids){const requested=new Set(ids);if(requested.size===0)return 0;let removed=0;await this.update(snapshot=>{const removedIds=new Set;const retained=snapshot.workspaces.filter(workspace=>{const registrationId=workspaceRegistrationId(workspace);if(!requested.has(registrationId))return true;removed++;removedIds.add(registrationId);return false});if(removed===0)return false;snapshot.workspaces.splice(0,snapshot.workspaces.length,...retained);for(const registrationId of removedIds){setSnapshotDisplayName(snapshot,registrationId,void 0)}return true});return removed}async update(mutate){const{atomicWriteFile}=await import("./deferred-core-runtime-3CXBZIOG.js");return withInProcessLock(this.filePath,async()=>{const lock=await acquireFileLock(this.filePath);let committed=false;let changed=false;let workError;try{const snapshot=await this.read();lock.assertOwned();changed=mutate(snapshot);if(changed){const serialized=`${JSON.stringify(snapshot,null,2)}
|
|
3
|
+
import{MAX_WORKSPACE_PATH_LENGTH,canonicalizeWorkspace}from"./chunk-L5UULTGF.js";import{isWithinRoot}from"./chunk-IDXJIDME.js";import{getGlobalQwenDirLite}from"./chunk-PTHIQ7ZN.js";import{isUnverifiableIdentityError,openNoFollow}from"./chunk-QXQGUM3Y.js";import{require_proper_lockfile}from"./chunk-YIW3H46P.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name,__toESM}from"./chunk-KBWJGX7I.js";init_esbuild_shims();var import_proper_lockfile=__toESM(require_proper_lockfile(),1);import{createHash}from"node:crypto";import*as fs from"node:fs/promises";import*as os from"node:os";import*as path from"node:path";init_esbuild_shims();var MAX_REGISTERED_WORKSPACES=256;var MAX_CONFIGURED_REGISTERED_WORKSPACES=256;var QWEN_SERVE_MAX_WORKSPACES_ENV="QWEN_SERVE_MAX_WORKSPACES";function resolveMaxRegisteredWorkspaces(configured,env){const raw=env[QWEN_SERVE_MAX_WORKSPACES_ENV];const value=configured??(raw===void 0?MAX_REGISTERED_WORKSPACES:/^\d+$/.test(raw.trim())?Number(raw.trim()):Number.NaN);if(!Number.isSafeInteger(value)||value<1||value>MAX_CONFIGURED_REGISTERED_WORKSPACES){const source=configured===void 0?`${QWEN_SERVE_MAX_WORKSPACES_ENV}=${JSON.stringify(raw)}`:`maxRegisteredWorkspaces option ${String(configured)}`;throw new TypeError(`Invalid ${source}: must be an integer from 1 to ${MAX_CONFIGURED_REGISTERED_WORKSPACES}.`)}return value}__name(resolveMaxRegisteredWorkspaces,"resolveMaxRegisteredWorkspaces");var DuplicateWorkspaceInputError=class extends Error{static{__name(this,"DuplicateWorkspaceInputError")}constructor(workspace){super(`Duplicate --workspace value resolves to ${JSON.stringify(workspace)}. Pass distinct --workspace values.`);this.name="DuplicateWorkspaceInputError"}};var NestedWorkspaceInputError=class extends Error{static{__name(this,"NestedWorkspaceInputError")}constructor(parent,child){super(`Nested --workspace values are not supported yet: ${JSON.stringify(child)} is inside ${JSON.stringify(parent)}. Pass non-nested --workspace values.`);this.name="NestedWorkspaceInputError"}};var MissingWorkspaceInputError=class extends Error{static{__name(this,"MissingWorkspaceInputError")}constructor(){super("--workspace requires a value.");this.name="MissingWorkspaceInputError"}};function normalizeWorkspaceInputs(workspace){if(Array.isArray(workspace)){if(workspace.length===0){throw new MissingWorkspaceInputError}return workspace.map(value=>String(value))}if(workspace===void 0)return[process.cwd()];return[String(workspace)]}__name(normalizeWorkspaceInputs,"normalizeWorkspaceInputs");function isNestedWorkspace(parent,child){return parent!==child&&isWithinRoot(child,parent)}__name(isNestedWorkspace,"isNestedWorkspace");function rejectDuplicateOrNestedWorkspaceInputs(workspaces){if(workspaces.length<=1)return;let canonicalWorkspaces;try{canonicalWorkspaces=workspaces.map(workspace=>canonicalizeWorkspace(workspace))}catch{return}const seen=new Set;for(const workspace of canonicalWorkspaces){if(seen.has(workspace)){throw new DuplicateWorkspaceInputError(workspace)}seen.add(workspace)}for(let i=0;i<canonicalWorkspaces.length;i++){for(let j=i+1;j<canonicalWorkspaces.length;j++){const first=canonicalWorkspaces[i];const second=canonicalWorkspaces[j];if(isNestedWorkspace(first,second)){throw new NestedWorkspaceInputError(first,second)}if(isNestedWorkspace(second,first)){throw new NestedWorkspaceInputError(second,first)}}}}__name(rejectDuplicateOrNestedWorkspaceInputs,"rejectDuplicateOrNestedWorkspaceInputs");function resolveWorkspaceInputs(workspace){const workspaces=normalizeWorkspaceInputs(workspace);rejectDuplicateOrNestedWorkspaceInputs(workspaces);return workspaces}__name(resolveWorkspaceInputs,"resolveWorkspaceInputs");var SCHEMA_VERSION=1;var MAX_SECONDARY_WORKSPACES=MAX_CONFIGURED_REGISTERED_WORKSPACES-1;var MAX_STORE_BYTES=8*1024*1024;var MAX_WORKSPACE_DISPLAY_NAME_LENGTH=256;var LOCK_OPTIONS={realpath:false,stale:1e4,update:2e3,retries:{retries:120,minTimeout:10,maxTimeout:100,factor:1.2,randomize:true}};var WorkspaceDisplayNameValidationError=class extends Error{static{__name(this,"WorkspaceDisplayNameValidationError")}constructor(message){super(message);this.name="WorkspaceDisplayNameValidationError"}};function containsDisplayNameControlCharacter(value){for(const character of value){const codePoint=character.codePointAt(0);if(codePoint<=31||codePoint===127)return true}return false}__name(containsDisplayNameControlCharacter,"containsDisplayNameControlCharacter");function normalizeWorkspaceDisplayName(value){if(typeof value!=="string"){throw new WorkspaceDisplayNameValidationError("Workspace display name must be a string")}const trimmed=value.trim();if(trimmed.length>MAX_WORKSPACE_DISPLAY_NAME_LENGTH){throw new WorkspaceDisplayNameValidationError(`Workspace display name exceeds ${MAX_WORKSPACE_DISPLAY_NAME_LENGTH} characters`)}if(containsDisplayNameControlCharacter(trimmed)){throw new WorkspaceDisplayNameValidationError("Workspace display name contains control characters")}return trimmed.length===0?void 0:trimmed}__name(normalizeWorkspaceDisplayName,"normalizeWorkspaceDisplayName");var WorkspaceRegistrationStoreError=class extends Error{static{__name(this,"WorkspaceRegistrationStoreError")}constructor(message){super(message);this.name="WorkspaceRegistrationStoreError"}};var WorkspaceRegistrationStoreLimitError=class extends WorkspaceRegistrationStoreError{static{__name(this,"WorkspaceRegistrationStoreLimitError")}};var WorkspaceRegistrationStoreTooLargeError=class extends WorkspaceRegistrationStoreError{static{__name(this,"WorkspaceRegistrationStoreTooLargeError")}};var WorkspaceRegistrationStoreCommittedError=class extends WorkspaceRegistrationStoreError{static{__name(this,"WorkspaceRegistrationStoreCommittedError")}};function normalizedScopePath(primaryWorkspace){return os.platform()==="win32"?primaryWorkspace.toLowerCase():primaryWorkspace}__name(normalizedScopePath,"normalizedScopePath");function workspaceRegistrationScopeHash(primaryWorkspace){return createHash("sha256").update(normalizedScopePath(primaryWorkspace)).digest("hex")}__name(workspaceRegistrationScopeHash,"workspaceRegistrationScopeHash");function workspaceRegistrationId(workspace){return createHash("sha256").update(workspace).digest("hex").slice(0,16)}__name(workspaceRegistrationId,"workspaceRegistrationId");function getWorkspaceRegistrationStorePath(primaryWorkspace,qwenHome=getGlobalQwenDirLite()){return path.join(qwenHome,"daemon","workspaces",`${workspaceRegistrationScopeHash(primaryWorkspace)}.json`)}__name(getWorkspaceRegistrationStorePath,"getWorkspaceRegistrationStorePath");function emptySnapshot(primaryWorkspace){return{schemaVersion:SCHEMA_VERSION,primaryWorkspace,workspaces:[]}}__name(emptySnapshot,"emptySnapshot");function validateWorkspacePath(value,label){if(typeof value!=="string"||!path.isAbsolute(value)){throw new WorkspaceRegistrationStoreError(`${label} must be an absolute path`)}if(value.includes("\0")||value.length>MAX_WORKSPACE_PATH_LENGTH){throw new WorkspaceRegistrationStoreError(`${label} is invalid`)}return value}__name(validateWorkspacePath,"validateWorkspacePath");function validateStoredDisplayName(value,label){let displayName;try{displayName=normalizeWorkspaceDisplayName(value)}catch(err){throw new WorkspaceRegistrationStoreError(`${label} is invalid: ${err instanceof Error?err.message:String(err)}`)}if(displayName===void 0){throw new WorkspaceRegistrationStoreError(`${label} must not be empty`)}return displayName}__name(validateStoredDisplayName,"validateStoredDisplayName");function setSnapshotDisplayName(snapshot,registrationId,displayName){if(displayName===void 0){if(!snapshot.displayNames||!Object.hasOwn(snapshot.displayNames,registrationId)){return false}delete snapshot.displayNames[registrationId];if(Object.keys(snapshot.displayNames).length===0){delete snapshot.displayNames}return true}if(snapshot.displayNames?.[registrationId]===displayName)return false;snapshot.displayNames??={};snapshot.displayNames[registrationId]=displayName;return true}__name(setSnapshotDisplayName,"setSnapshotDisplayName");function parseSnapshot(raw,primaryWorkspace){let value;try{value=JSON.parse(raw)}catch{throw new WorkspaceRegistrationStoreError("Workspace registration store contains malformed JSON")}if(typeof value!=="object"||value===null||Array.isArray(value)){throw new WorkspaceRegistrationStoreError("Workspace registration store root must be an object")}const record=value;if(record["schemaVersion"]!==SCHEMA_VERSION){throw new WorkspaceRegistrationStoreError(`Unsupported workspace registration schema ${String(record["schemaVersion"])}`)}const storedPrimary=validateWorkspacePath(record["primaryWorkspace"],"primaryWorkspace");if(normalizedScopePath(storedPrimary)!==normalizedScopePath(primaryWorkspace)){throw new WorkspaceRegistrationStoreError("Workspace registration store primary does not match this daemon")}if(!Array.isArray(record["workspaces"])){throw new WorkspaceRegistrationStoreError("Workspace registration store workspaces must be an array")}if(record["workspaces"].length>MAX_SECONDARY_WORKSPACES){throw new WorkspaceRegistrationStoreError(`Workspace registration store exceeds ${MAX_SECONDARY_WORKSPACES} entries`)}const seen=new Set;const workspaces=record["workspaces"].map((entry,index)=>{const workspace=validateWorkspacePath(entry,`workspaces[${index}]`);const normalizedWorkspace=normalizedScopePath(workspace);if(normalizedWorkspace===normalizedScopePath(primaryWorkspace)){throw new WorkspaceRegistrationStoreError("Primary workspace cannot be stored as a secondary registration")}if(seen.has(normalizedWorkspace)){throw new WorkspaceRegistrationStoreError("Workspace registration store contains duplicate paths")}seen.add(normalizedWorkspace);return workspace});const rawDisplayNames=record["displayNames"];let displayNames;if(rawDisplayNames!==void 0){if(typeof rawDisplayNames!=="object"||rawDisplayNames===null||Array.isArray(rawDisplayNames)){throw new WorkspaceRegistrationStoreError("Workspace registration store displayNames must be an object")}const registrationIds=new Set(workspaces.map(workspaceRegistrationId));for(const[registrationId,value2]of Object.entries(rawDisplayNames)){if(!registrationIds.has(registrationId)){throw new WorkspaceRegistrationStoreError(`Workspace registration store displayNames contains unknown registration id ${JSON.stringify(registrationId)}`)}displayNames??={};displayNames[registrationId]=validateStoredDisplayName(value2,`displayNames[${JSON.stringify(registrationId)}]`)}}return{schemaVersion:SCHEMA_VERSION,primaryWorkspace,workspaces,...displayNames?{displayNames}:{}}}__name(parseSnapshot,"parseSnapshot");var updateChains=new Map;async function withInProcessLock(filePath,work){const previous=updateChains.get(filePath)??Promise.resolve();const next=previous.then(work,work);const settled=next.catch(()=>void 0).finally(()=>{if(updateChains.get(filePath)===settled)updateChains.delete(filePath)});updateChains.set(filePath,settled);return next}__name(withInProcessLock,"withInProcessLock");function compromisedLockError(){return new WorkspaceRegistrationStoreError("Workspace registration store lock was compromised")}__name(compromisedLockError,"compromisedLockError");async function acquireFileLock(filePath){await fs.mkdir(path.dirname(filePath),{recursive:true,mode:448});let compromised=false;const release=await import_proper_lockfile.default.lock(filePath,{...LOCK_OPTIONS,onCompromised:__name(()=>{compromised=true},"onCompromised")});return{assertOwned:__name(()=>{if(compromised)throw compromisedLockError()},"assertOwned"),release:__name(async()=>{try{await release()}catch(err){if(!compromised)throw err}if(compromised)throw compromisedLockError()},"release")}}__name(acquireFileLock,"acquireFileLock");var WorkspaceRegistrationStore=class{constructor(primaryWorkspace,qwenHome){this.primaryWorkspace=primaryWorkspace;validateWorkspacePath(primaryWorkspace,"primaryWorkspace");this.filePath=getWorkspaceRegistrationStorePath(primaryWorkspace,qwenHome)}static{__name(this,"WorkspaceRegistrationStore")}filePath;async read(){try{const entry=await fs.lstat(this.filePath);if(entry.isSymbolicLink()||!entry.isFile()){throw new WorkspaceRegistrationStoreError("Workspace registration store must be a regular file")}}catch(err){if(err.code==="ENOENT"){return emptySnapshot(this.primaryWorkspace)}throw err}let file;try{file=await openNoFollow(this.filePath)}catch(err){if(err.code==="ENOENT"){return emptySnapshot(this.primaryWorkspace)}if(isUnverifiableIdentityError(err)){throw new WorkspaceRegistrationStoreError("Workspace registration store identity could not be verified")}if(err.code==="ELOOP"){throw new WorkspaceRegistrationStoreError("Workspace registration store must be a regular file")}throw err}try{const stat=await file.stat();if(!stat.isFile()){throw new WorkspaceRegistrationStoreError("Workspace registration store must be a regular file")}if(stat.size>MAX_STORE_BYTES){throw new WorkspaceRegistrationStoreTooLargeError(`Workspace registration store exceeds ${MAX_STORE_BYTES} bytes`)}let buffer=Buffer.alloc(Math.max(1,Math.min(stat.size+1,MAX_STORE_BYTES+1)));let totalBytesRead=0;for(;;){if(totalBytesRead===buffer.length){if(totalBytesRead>MAX_STORE_BYTES)break;const grown=Buffer.alloc(Math.min(MAX_STORE_BYTES+1,Math.max(buffer.length*2,totalBytesRead+1)));buffer.copy(grown,0,0,totalBytesRead);buffer=grown}const{bytesRead}=await file.read(buffer,totalBytesRead,buffer.length-totalBytesRead,totalBytesRead);if(bytesRead===0)break;totalBytesRead+=bytesRead}if(totalBytesRead>MAX_STORE_BYTES){throw new WorkspaceRegistrationStoreTooLargeError(`Workspace registration store exceeds ${MAX_STORE_BYTES} bytes`)}return parseSnapshot(buffer.toString("utf8",0,totalBytesRead),this.primaryWorkspace)}finally{await file.close()}}async add(workspace,displayName,maxRegisteredWorkspaces=MAX_REGISTERED_WORKSPACES){const maxSecondaries=resolveMaxRegisteredWorkspaces(maxRegisteredWorkspaces,{})-1;validateWorkspacePath(workspace,"workspace");const normalizedDisplayName=displayName===void 0?void 0:normalizeWorkspaceDisplayName(displayName);if(normalizedScopePath(workspace)===normalizedScopePath(this.primaryWorkspace)){throw new WorkspaceRegistrationStoreError("Primary workspace cannot be stored as a secondary registration")}return this.update(snapshot=>{const normalizedWorkspace=normalizedScopePath(workspace);if(snapshot.workspaces.some(stored=>normalizedScopePath(stored)===normalizedWorkspace)){return false}if(snapshot.workspaces.length>=maxSecondaries){throw new WorkspaceRegistrationStoreLimitError(`Workspace registration store limit of ${maxSecondaries} reached`)}snapshot.workspaces.push(workspace);if(normalizedDisplayName!==void 0){snapshot.displayNames??={};snapshot.displayNames[workspaceRegistrationId(workspace)]=normalizedDisplayName}return true})}async removeById(id){return await this.removeByIds([id])>0}async setDisplayNameByIds(ids,displayName){const normalizedDisplayName=displayName===void 0?void 0:normalizeWorkspaceDisplayName(displayName);const requested=new Set(ids);if(requested.size===0)return 0;let matched=0;await this.update(snapshot=>{let changed=false;for(const workspace of snapshot.workspaces){const registrationId=workspaceRegistrationId(workspace);if(!requested.has(registrationId))continue;matched++;changed=setSnapshotDisplayName(snapshot,registrationId,normalizedDisplayName)||changed}return changed});return matched}async removeByIds(ids){const requested=new Set(ids);if(requested.size===0)return 0;let removed=0;await this.update(snapshot=>{const removedIds=new Set;const retained=snapshot.workspaces.filter(workspace=>{const registrationId=workspaceRegistrationId(workspace);if(!requested.has(registrationId))return true;removed++;removedIds.add(registrationId);return false});if(removed===0)return false;snapshot.workspaces.splice(0,snapshot.workspaces.length,...retained);for(const registrationId of removedIds){setSnapshotDisplayName(snapshot,registrationId,void 0)}return true});return removed}async update(mutate){const{atomicWriteFile}=await import("./deferred-core-runtime-FLOFQJPU.js");return withInProcessLock(this.filePath,async()=>{const lock=await acquireFileLock(this.filePath);let committed=false;let changed=false;let workError;try{const snapshot=await this.read();lock.assertOwned();changed=mutate(snapshot);if(changed){const serialized=`${JSON.stringify(snapshot,null,2)}
|
|
4
4
|
`;if(Buffer.byteLength(serialized,"utf8")>MAX_STORE_BYTES){throw new WorkspaceRegistrationStoreTooLargeError(`Workspace registration store exceeds ${MAX_STORE_BYTES} bytes`)}lock.assertOwned();await atomicWriteFile(this.filePath,serialized,{mode:384,forceMode:true,noFollow:true});committed=true}}catch(err){workError=err}let releaseError;try{await lock.release()}catch(err){releaseError=committed?new WorkspaceRegistrationStoreCommittedError(`Workspace registration update committed but lock release failed: ${err instanceof Error?err.message:String(err)}`):err}if(workError instanceof Error&&releaseError!==void 0&&workError.cause===void 0){workError.cause=releaseError}if(workError!==void 0)throw workError;if(releaseError!==void 0)throw releaseError;return changed})}};export{MAX_REGISTERED_WORKSPACES,resolveMaxRegisteredWorkspaces,resolveWorkspaceInputs,MAX_WORKSPACE_DISPLAY_NAME_LENGTH,WorkspaceDisplayNameValidationError,normalizeWorkspaceDisplayName,WorkspaceRegistrationStoreError,WorkspaceRegistrationStoreLimitError,WorkspaceRegistrationStoreTooLargeError,WorkspaceRegistrationStoreCommittedError,workspaceRegistrationScopeHash,workspaceRegistrationId,getWorkspaceRegistrationStorePath,WorkspaceRegistrationStore};
|
|
5
5
|
/**
|
|
6
6
|
* @license
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{redactMcpServersSetting,restoreRedactedMcpServersSetting}from"./chunk-44U2VNWI.js";import{safeLogValue}from"./chunk-K246IFIW.js";import{requireTrustedWorkspaceRuntime,resolveWorkspaceRuntimeFromParam,sendGenerationClosedError}from"./chunk-BQJXWIMR.js";import{isServeDebugMode}from"./chunk-CUNEBE5E.js";import{STATUS_SCHEMA_VERSION}from"./chunk-LUDNUVSA.js";import{loadSettings}from"./chunk-2B3W7IQY.js";import{BuiltinAgentRegistry,SubagentManager}from"./chunk-LIIMQ4DI.js";import{APPROVAL_MODES}from"./chunk-JZK2WGXA.js";import{writeStderrLine}from"./chunk-SLPJ4OII.js";import{SubagentError,SubagentErrorCode}from"./chunk-B3ZFUGTC.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name}from"./chunk-KBWJGX7I.js";init_esbuild_shims();import{promises as fs}from"node:fs";import{isDeepStrictEqual}from"node:util";var AGENT_TYPE_PATTERN=/^[\p{L}\p{N}_-]+$/u;var AGENT_TYPE_MAX_LENGTH=64;var AGENT_TYPE_MIN_LENGTH=2;var MAX_DESCRIPTION_BYTES=256*1024;var MAX_SYSTEM_PROMPT_BYTES=256*1024;var MAX_TOOLS_ENTRIES=256;var MAX_TOOL_ID_LENGTH=256;var MAX_RECORD_ENTRIES=128;var SUBAGENT_APPROVAL_MODES=[...APPROVAL_MODES,"bubble"];var SUBAGENT_PERMISSION_MODES=["acceptEdits","auto","bypassPermissions","default","dontAsk","plan"];var SUBAGENT_COLORS=["auto","red","blue","green","yellow","purple","orange","pink","cyan"];function captureTrustedGeneration(deps,res){const assertGenerationOpen=deps.captureGenerationAssertion?.()??(()=>{});try{assertGenerationOpen()}catch{res.set("Retry-After","1");res.status(503).json({error:"Workspace runtime is not active.",code:"workspace_runtime_unavailable"});return null}if(deps.isWorkspaceTrusted?.()===false){res.status(403).json({error:"Workspace is not trusted.",code:"untrusted_workspace"});return null}return assertGenerationOpen}__name(captureTrustedGeneration,"captureTrustedGeneration");function mountWorkspaceAgentsRoutes(app,deps){const manager=createDaemonSubagentManager(deps.boundWorkspace);app.get("/workspace/agents",async(_req,res)=>{const assertGenerationOpen=captureTrustedGeneration(deps,res);if(!assertGenerationOpen)return;try{const agents=await manager.listSubagents({force:true});assertGenerationOpen();const status={v:STATUS_SCHEMA_VERSION,workspaceCwd:deps.boundWorkspace,agents:agents.map(toSummary)};res.status(200).json(status)}catch(err){if(sendGenerationClosedError(res,err))return;writeStderrLine(`qwen serve: GET /workspace/agents failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to list workspace agents",code:"agent_list_failed"})}});app.post("/workspace/agents",deps.mutate({strict:true}),async(req,res)=>{const assertGenerationOpen=captureTrustedGeneration(deps,res);if(!assertGenerationOpen)return;const body=deps.safeBody(req);const clientIdResult=resolveOriginatorClientId(deps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const scope=body["scope"];if(scope!=="workspace"&&scope!=="global"){res.status(400).json({error:'`scope` must be "workspace" or "global"',code:"invalid_scope"});return}const level=scope==="workspace"?"project":"user";const config=parseAgentConfig(restoreAgentMcpServerSecrets(body,deps.boundWorkspace,level),level,res);if(!config)return;const collision=await manager.loadSubagent(config.name,level);if(collision){res.status(409).json({error:`Subagent "${config.name}" already exists at ${level} level`,code:"agent_already_exists",name:config.name,level});return}try{assertGenerationOpen();await manager.createSubagent(config,{level,assertCanCommit:assertGenerationOpen});assertGenerationOpen()}catch(err){if(sendGenerationClosedError(res,err))return;if(err instanceof SubagentError){if(err.code===SubagentErrorCode.ALREADY_EXISTS){res.status(409).json({error:err.message,code:"agent_already_exists",name:err.subagentName??config.name});return}if(err.code===SubagentErrorCode.VALIDATION_ERROR||err.code===SubagentErrorCode.INVALID_CONFIG||err.code===SubagentErrorCode.INVALID_NAME||err.code===SubagentErrorCode.TOOL_NOT_FOUND){res.status(422).json({error:err.message,code:"invalid_config",name:err.subagentName??config.name});return}if(err.code===SubagentErrorCode.FILE_ERROR){const debug=isServeDebugMode();res.status(500).json({error:debug?err.message:"Failed to write workspace agent file",code:"file_error",name:err.subagentName??config.name});return}}writeStderrLine(`qwen serve: POST /workspace/agents failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to create workspace agent",code:"agent_create_failed"});return}const created=await manager.loadSubagent(config.name,level);try{assertGenerationOpen()}catch(err){sendGenerationClosedError(res,err);return}if(!created){writeStderrLine(`qwen serve: agent_create_reload_failed (name=${safeLogValue(config.name)} level=${level}) \u2014 file likely persisted on disk; check \`GET /workspace/agents\` for a phantom entry`);res.status(500).json({error:"Agent creation succeeded but reload failed",code:"agent_create_reload_failed",name:config.name,level});return}deps.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"created",name:config.name,level},...originatorClientId?{originatorClientId}:{}});res.status(201).json({ok:true,agent:toDetail(created)})});app.post("/workspace/agents/generate",deps.mutate({strict:true}),async(req,res)=>{const assertGenerationOpen=captureTrustedGeneration(deps,res);if(!assertGenerationOpen)return;const body=deps.safeBody(req);const clientIdResult=resolveOriginatorClientId(deps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const description=body["description"];if(typeof description!=="string"||description.trim().length===0){res.status(400).json({error:"`description` must be a non-empty string",code:"invalid_description"});return}if(Buffer.byteLength(description,"utf8")>4096){res.status(400).json({error:"`description` exceeds the 4096-byte limit",code:"invalid_description"});return}try{const generated=await deps.bridge.generateWorkspaceAgent(description.trim(),originatorClientId);assertGenerationOpen();res.status(200).json(generated)}catch(err){if(sendGenerationClosedError(res,err))return;writeStderrLine(`qwen serve: POST /workspace/agents/generate failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to generate workspace agent",code:"agent_generate_failed"})}});app.get("/workspace/agents/:agentType",async(req,res)=>{const assertGenerationOpen=captureTrustedGeneration(deps,res);if(!assertGenerationOpen)return;const agentType=validateAgentType(req,res);if(agentType===null)return;try{const scopedLevel=parseScopeQuery(req,res);if(scopedLevel===null)return;const config=await manager.loadSubagent(agentType,scopedLevel);assertGenerationOpen();if(!config){res.status(404).json({error:`Subagent "${agentType}" not found`,code:"agent_not_found",name:agentType});return}res.status(200).json(toDetail(config))}catch(err){if(sendGenerationClosedError(res,err))return;writeStderrLine(`qwen serve: GET /workspace/agents/${safeLogValue(agentType)} failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to read workspace agent",code:"agent_read_failed"})}});app.post("/workspace/agents/:agentType",deps.mutate({strict:true}),async(req,res)=>{const assertGenerationOpen=captureTrustedGeneration(deps,res);if(!assertGenerationOpen)return;const agentType=validateAgentType(req,res);if(agentType===null)return;const clientIdResult=resolveOriginatorClientId(deps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const preferredLevel=parseScopeQuery(req,res);if(preferredLevel===null)return;const existing=await manager.loadSubagent(agentType,preferredLevel);if(!existing){res.status(404).json({error:`Subagent "${agentType}" not found`,code:"agent_not_found",name:agentType});return}if(assertMutableLevel(existing,agentType,res)){return}const body=restoreAgentMcpServerSecrets(deps.safeBody(req),deps.boundWorkspace,existing.level,existing.mcpServers);const updates=parseAgentUpdates(body,res);if(!updates)return;if(Object.keys(updates).length===0){res.status(400).json({error:"`POST /workspace/agents/:agentType` requires at least one updatable field in the body",code:"invalid_config",name:agentType});return}if(isNoOpUpdate(existing,updates)){res.status(200).json({ok:true,agent:toDetail(existing),changed:false});return}try{assertGenerationOpen();await manager.updateSubagent(agentType,updates,existing.level,{assertCanCommit:assertGenerationOpen});assertGenerationOpen()}catch(err){if(sendGenerationClosedError(res,err))return;if(err instanceof SubagentError){if(err.code===SubagentErrorCode.NOT_FOUND){res.status(404).json({error:err.message,code:"agent_not_found",name:err.subagentName??agentType});return}if(err.code===SubagentErrorCode.INVALID_CONFIG){res.status(403).json({error:err.message,code:"agent_readonly",name:err.subagentName??agentType});return}if(err.code===SubagentErrorCode.VALIDATION_ERROR||err.code===SubagentErrorCode.INVALID_NAME||err.code===SubagentErrorCode.TOOL_NOT_FOUND){res.status(422).json({error:err.message,code:"invalid_config",name:err.subagentName??agentType});return}if(err.code===SubagentErrorCode.FILE_ERROR){const debug=isServeDebugMode();res.status(500).json({error:debug?err.message:"Failed to write workspace agent file",code:"file_error",name:err.subagentName??agentType});return}}writeStderrLine(`qwen serve: POST /workspace/agents/${safeLogValue(agentType)} failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to update workspace agent",code:"agent_update_failed"});return}const updated=await manager.loadSubagent(agentType,existing.level);try{assertGenerationOpen()}catch(err){sendGenerationClosedError(res,err);return}if(!updated){writeStderrLine(`qwen serve: agent_update_reload_failed (name=${safeLogValue(agentType)} level=${existing.level}) \u2014 disk write completed; check \`GET /workspace/agents/${safeLogValue(agentType)}\` for the new state`);res.status(500).json({error:"Agent update succeeded but reload failed",code:"agent_update_reload_failed",name:agentType,level:existing.level});return}const eventLevel=existing.level==="project"?"project":"user";deps.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"updated",name:existing.name,level:eventLevel},...originatorClientId?{originatorClientId}:{}});res.status(200).json({ok:true,agent:toDetail(updated),changed:true})});app.delete("/workspace/agents/:agentType",deps.mutate({strict:true}),async(req,res)=>{const assertGenerationOpen=captureTrustedGeneration(deps,res);if(!assertGenerationOpen)return;const agentType=validateAgentType(req,res);if(agentType===null)return;const clientIdResult=resolveOriginatorClientId(deps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const scopedLevel=parseScopeQuery(req,res);if(scopedLevel===null)return;const levelsToCheck=scopedLevel?[scopedLevel]:["project","user"];const existingAtLevels=[];for(const lvl of levelsToCheck){const found=await manager.loadSubagent(agentType,lvl);if(found)existingAtLevels.push(found)}for(const found of existingAtLevels){if(assertMutableLevel(found,agentType,res))return}try{assertGenerationOpen();await manager.deleteSubagent(agentType,scopedLevel,void 0,{assertCanCommit:assertGenerationOpen});assertGenerationOpen()}catch(err){if(sendGenerationClosedError(res,err))return;if(err instanceof SubagentError){if(err.code===SubagentErrorCode.NOT_FOUND){res.status(404).json({error:err.message,code:"agent_not_found",name:err.subagentName??agentType});return}if(err.code===SubagentErrorCode.INVALID_CONFIG){res.status(403).json({error:err.message,code:"agent_readonly",name:err.subagentName??agentType});return}}writeStderrLine(`qwen serve: DELETE /workspace/agents/${safeLogValue(agentType)} failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to delete workspace agent",code:"agent_delete_failed"});return}const removed=[];const remaining=[];for(const found of existingAtLevels){if(!found.filePath){removed.push(found);continue}try{await fs.access(found.filePath);remaining.push(found)}catch{removed.push(found)}}try{assertGenerationOpen()}catch(err){sendGenerationClosedError(res,err);return}if(remaining.length>0){writeStderrLine(`qwen serve: DELETE /workspace/agents/${safeLogValue(agentType)} partial \u2014 removed=${removed.map(r=>r.level).join(",")||"none"} remaining=${remaining.map(r=>`${r.level}:${r.filePath}`).join(",")}`);for(const found of removed){const evtLevel=found.level==="project"?"project":"user";deps.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"deleted",name:found.name,level:evtLevel},...originatorClientId?{originatorClientId}:{}})}res.status(500).json({error:`Failed to delete every level of subagent "${agentType}" \u2014 ${remaining.length} level(s) still have their file on disk`,code:"agent_delete_partial",name:agentType,removedLevels:removed.map(r=>r.level),remainingLevels:remaining.map(r=>r.level)});return}if(existingAtLevels.length===0){const fallbackLevel=scopedLevel==="user"?"user":"project";deps.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"deleted",name:agentType,level:fallbackLevel},...originatorClientId?{originatorClientId}:{}})}else{for(const found of removed){const evtLevel=found.level==="project"?"project":"user";deps.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"deleted",name:found.name,level:evtLevel},...originatorClientId?{originatorClientId}:{}})}}res.status(204).end()})}__name(mountWorkspaceAgentsRoutes,"mountWorkspaceAgentsRoutes");function mountWorkspaceQualifiedAgentsRoutes(app,deps){app.get("/workspaces/:workspace/agents",async(req,res)=>{const runtime=resolveTrustedWorkspaceAgentRuntime(deps,req,res);if(!runtime)return;const scopedLevel=parseWorkspaceOnlyAgentScopeQuery(req,res);if(scopedLevel===null)return;const manager=createDaemonSubagentManager(runtime.workspaceCwd);try{const agents=await manager.listSubagents({force:true});runtime.generationGuard?.assertOpen();const status={v:STATUS_SCHEMA_VERSION,workspaceCwd:runtime.workspaceCwd,agents:agents.filter(agent=>agent.level==="project").map(toSummary)};res.status(200).json(status)}catch(err){if(sendGenerationClosedError(res,err))return;writeStderrLine(`qwen serve: GET /workspaces/:workspace/agents failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to list workspace agents",code:"agent_list_failed"})}});app.post("/workspaces/:workspace/agents",deps.mutate({strict:true}),async(req,res)=>{const runtime=resolveTrustedWorkspaceAgentRuntime(deps,req,res);if(!runtime)return;const routeDeps=workspaceAgentDepsForRuntime(runtime,deps);const body=deps.safeBody(req);const clientIdResult=resolveOriginatorClientId(routeDeps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const level=parseWorkspaceOnlyAgentBodyScope(body,res);if(level===null)return;const manager=createDaemonSubagentManager(runtime.workspaceCwd);const config=parseAgentConfig(restoreAgentMcpServerSecrets(body,runtime.workspaceCwd,level),level,res);if(!config)return;const collision=await manager.loadSubagent(config.name,level);if(collision){res.status(409).json({error:`Subagent "${config.name}" already exists at ${level} level`,code:"agent_already_exists",name:config.name,level});return}try{runtime.generationGuard?.assertOpen();await manager.createSubagent(config,{level,assertCanCommit:__name(()=>runtime.generationGuard?.assertOpen(),"assertCanCommit")});runtime.generationGuard?.assertOpen()}catch(err){if(sendGenerationClosedError(res,err))return;if(sendCreateAgentError(res,err,config.name))return;writeStderrLine(`qwen serve: POST /workspaces/:workspace/agents failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to create workspace agent",code:"agent_create_failed"});return}const created=await manager.loadSubagent(config.name,level);try{runtime.generationGuard?.assertOpen()}catch(err){sendGenerationClosedError(res,err);return}if(!created){writeStderrLine(`qwen serve: agent_create_reload_failed (name=${safeLogValue(config.name)} level=${level}) \u2014 file likely persisted on disk; check \`GET /workspaces/:workspace/agents\` for a phantom entry`);res.status(500).json({error:"Agent creation succeeded but reload failed",code:"agent_create_reload_failed",name:config.name,level});return}runtime.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"created",name:config.name,level:"project"},...originatorClientId?{originatorClientId}:{}});res.status(201).json({ok:true,agent:toDetail(created)})});app.get("/workspaces/:workspace/agents/:agentType",async(req,res)=>{const runtime=resolveTrustedWorkspaceAgentRuntime(deps,req,res);if(!runtime)return;const agentType=validateAgentType(req,res);if(agentType===null)return;const scopedLevel=parseWorkspaceOnlyAgentScopeQuery(req,res);if(scopedLevel===null)return;const manager=createDaemonSubagentManager(runtime.workspaceCwd);try{const config=await manager.loadSubagent(agentType,scopedLevel);runtime.generationGuard?.assertOpen();if(!config){res.status(404).json({error:`Subagent "${agentType}" not found`,code:"agent_not_found",name:agentType});return}res.status(200).json(toDetail(config))}catch(err){if(sendGenerationClosedError(res,err))return;writeStderrLine(`qwen serve: GET /workspaces/:workspace/agents/${safeLogValue(agentType)} failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to read workspace agent",code:"agent_read_failed"})}});app.post("/workspaces/:workspace/agents/:agentType",deps.mutate({strict:true}),async(req,res)=>{const runtime=resolveTrustedWorkspaceAgentRuntime(deps,req,res);if(!runtime)return;const agentType=validateAgentType(req,res);if(agentType===null)return;const scopedLevel=parseWorkspaceOnlyAgentScopeQuery(req,res);if(scopedLevel===null)return;const routeDeps=workspaceAgentDepsForRuntime(runtime,deps);const clientIdResult=resolveOriginatorClientId(routeDeps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const manager=createDaemonSubagentManager(runtime.workspaceCwd);const existing=await manager.loadSubagent(agentType,scopedLevel);if(!existing){res.status(404).json({error:`Subagent "${agentType}" not found`,code:"agent_not_found",name:agentType});return}if(assertMutableLevel(existing,agentType,res))return;const body=restoreAgentMcpServerSecrets(deps.safeBody(req),runtime.workspaceCwd,existing.level,existing.mcpServers);const updates=parseAgentUpdates(body,res);if(!updates)return;if(Object.keys(updates).length===0){res.status(400).json({error:"`POST /workspaces/:workspace/agents/:agentType` requires at least one updatable field in the body",code:"invalid_config",name:agentType});return}if(isNoOpUpdate(existing,updates)){res.status(200).json({ok:true,agent:toDetail(existing),changed:false});return}try{runtime.generationGuard?.assertOpen();await manager.updateSubagent(agentType,updates,existing.level,{assertCanCommit:__name(()=>runtime.generationGuard?.assertOpen(),"assertCanCommit")});runtime.generationGuard?.assertOpen()}catch(err){if(sendGenerationClosedError(res,err))return;if(sendUpdateAgentError(res,err,agentType))return;writeStderrLine(`qwen serve: POST /workspaces/:workspace/agents/${safeLogValue(agentType)} failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to update workspace agent",code:"agent_update_failed"});return}const updated=await manager.loadSubagent(agentType,existing.level);try{runtime.generationGuard?.assertOpen()}catch(err){sendGenerationClosedError(res,err);return}if(!updated){writeStderrLine(`qwen serve: agent_update_reload_failed (name=${safeLogValue(agentType)} level=${existing.level}) \u2014 disk write completed; check \`GET /workspaces/:workspace/agents/${safeLogValue(agentType)}\` for the new state`);res.status(500).json({error:"Agent update succeeded but reload failed",code:"agent_update_reload_failed",name:agentType,level:existing.level});return}runtime.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"updated",name:existing.name,level:"project"},...originatorClientId?{originatorClientId}:{}});res.status(200).json({ok:true,agent:toDetail(updated),changed:true})});app.delete("/workspaces/:workspace/agents/:agentType",deps.mutate({strict:true}),async(req,res)=>{const runtime=resolveTrustedWorkspaceAgentRuntime(deps,req,res);if(!runtime)return;const agentType=validateAgentType(req,res);if(agentType===null)return;const scopedLevel=parseWorkspaceOnlyAgentScopeQuery(req,res);if(scopedLevel===null)return;const routeDeps=workspaceAgentDepsForRuntime(runtime,deps);const clientIdResult=resolveOriginatorClientId(routeDeps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const manager=createDaemonSubagentManager(runtime.workspaceCwd);const existing=await manager.loadSubagent(agentType,scopedLevel);if(existing&&assertMutableLevel(existing,agentType,res))return;try{runtime.generationGuard?.assertOpen();await manager.deleteSubagent(agentType,scopedLevel,void 0,{assertCanCommit:__name(()=>runtime.generationGuard?.assertOpen(),"assertCanCommit")});runtime.generationGuard?.assertOpen()}catch(err){if(sendGenerationClosedError(res,err))return;if(err instanceof SubagentError){if(err.code===SubagentErrorCode.NOT_FOUND){res.status(404).json({error:err.message,code:"agent_not_found",name:err.subagentName??agentType});return}if(err.code===SubagentErrorCode.INVALID_CONFIG){res.status(403).json({error:err.message,code:"agent_readonly",name:err.subagentName??agentType});return}}writeStderrLine(`qwen serve: DELETE /workspaces/:workspace/agents/${safeLogValue(agentType)} failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to delete workspace agent",code:"agent_delete_failed"});return}if(existing?.filePath){try{await fs.access(existing.filePath);writeStderrLine(`qwen serve: DELETE /workspaces/:workspace/agents/${safeLogValue(agentType)} partial \u2014 remaining=${existing.level}:${existing.filePath}`);res.status(500).json({error:`Failed to delete subagent "${agentType}" \u2014 ${existing.level} level still has its file on disk`,code:"agent_delete_partial",name:agentType,removedLevels:[],remainingLevels:[existing.level]});return}catch{}}try{runtime.generationGuard?.assertOpen()}catch(err){sendGenerationClosedError(res,err);return}runtime.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"deleted",name:existing?.name??agentType,level:"project"},...originatorClientId?{originatorClientId}:{}});res.status(204).end()})}__name(mountWorkspaceQualifiedAgentsRoutes,"mountWorkspaceQualifiedAgentsRoutes");function validateAgentType(req,res){const raw=req.params["agentType"];if(!raw||raw.length===0){res.status(400).json({error:"`agentType` path parameter is required",code:"invalid_agent_type"});return null}if(raw.length>AGENT_TYPE_MAX_LENGTH||!AGENT_TYPE_PATTERN.test(raw)){res.status(400).json({error:"`agentType` must contain only letters, numbers, hyphens, or underscores (max 64 chars)",code:"invalid_agent_type",agentType:raw});return null}return raw}__name(validateAgentType,"validateAgentType");function parseScopeQuery(req,res){const raw=req.query["scope"];if(raw===void 0)return void 0;if(typeof raw!=="string"){res.status(400).json({error:'`scope` query must be a single "workspace" or "global" value',code:"invalid_scope"});return null}if(raw!=="workspace"&&raw!=="global"){res.status(400).json({error:'`scope` query must be "workspace" or "global"',code:"invalid_scope"});return null}return raw==="workspace"?"project":"user"}__name(parseScopeQuery,"parseScopeQuery");function assertMutableLevel(found,agentType,res){if(found.isBuiltin||found.level==="builtin"||found.level==="extension"||found.level==="session"){res.status(403).json({error:`Cannot modify ${found.level}-level subagent "${agentType}"`,code:"agent_readonly",name:found.name,level:found.level});return true}return false}__name(assertMutableLevel,"assertMutableLevel");function resolveOriginatorClientId(deps,req,res){const clientId=deps.parseClientId(req,res);if(clientId===null)return null;if(clientId===void 0)return void 0;if(!deps.bridge.knownClientIds().has(clientId)){res.status(400).json({error:`Client id "${clientId}" is not registered for this workspace`,code:"invalid_client_id",clientId});return null}return clientId}__name(resolveOriginatorClientId,"resolveOriginatorClientId");function resolveTrustedWorkspaceAgentRuntime(deps,req,res){const runtime=resolveWorkspaceRuntimeFromParam(deps.workspaceRegistry,req,res);if(!runtime)return void 0;if(!requireTrustedWorkspaceRuntime(runtime,res))return void 0;return runtime}__name(resolveTrustedWorkspaceAgentRuntime,"resolveTrustedWorkspaceAgentRuntime");function workspaceAgentDepsForRuntime(runtime,deps){return{bridge:runtime.bridge,boundWorkspace:runtime.workspaceCwd,mutate:deps.mutate,parseClientId:deps.parseClientId,safeBody:deps.safeBody}}__name(workspaceAgentDepsForRuntime,"workspaceAgentDepsForRuntime");function parseWorkspaceOnlyAgentBodyScope(body,res){const scope=body["scope"];if(scope===void 0||scope==="workspace"||scope==="project"){return"project"}return rejectWorkspaceQualifiedAgentScope(scope,res)}__name(parseWorkspaceOnlyAgentBodyScope,"parseWorkspaceOnlyAgentBodyScope");function parseWorkspaceOnlyAgentScopeQuery(req,res){const raw=req.query["scope"];if(raw===void 0||raw==="workspace"||raw==="project"){return"project"}if(typeof raw!=="string"){res.status(400).json({error:"`scope` query must be a single workspace/project value",code:"invalid_scope"});return null}return rejectWorkspaceQualifiedAgentScope(raw,res)}__name(parseWorkspaceOnlyAgentScopeQuery,"parseWorkspaceOnlyAgentScopeQuery");function rejectWorkspaceQualifiedAgentScope(scope,res){if(scope==="global"||scope==="user"){res.status(400).json({error:"Workspace-qualified agents routes only support workspace/project scope",code:"global_scope_not_supported_for_workspace_route"});return null}res.status(400).json({error:'`scope` must be "workspace" or "project"',code:"invalid_scope"});return null}__name(rejectWorkspaceQualifiedAgentScope,"rejectWorkspaceQualifiedAgentScope");function restoreAgentMcpServerSecrets(body,workspace,level,currentAgentServers){const incoming=body["mcpServers"];if(typeof incoming!=="object"||incoming===null||Array.isArray(incoming)){return body}const settings=loadSettings(workspace);const configuredServers=level==="user"?settings.user.settings.mcpServers??{}:settings.merged.mcpServers??{};return{...body,mcpServers:restoreRedactedMcpServersSetting(incoming,{...configuredServers,...currentAgentServers})}}__name(restoreAgentMcpServerSecrets,"restoreAgentMcpServerSecrets");function sendCreateAgentError(res,err,name){if(!(err instanceof SubagentError))return false;if(err.code===SubagentErrorCode.ALREADY_EXISTS){res.status(409).json({error:err.message,code:"agent_already_exists",name:err.subagentName??name});return true}if(err.code===SubagentErrorCode.VALIDATION_ERROR||err.code===SubagentErrorCode.INVALID_CONFIG||err.code===SubagentErrorCode.INVALID_NAME||err.code===SubagentErrorCode.TOOL_NOT_FOUND){res.status(422).json({error:err.message,code:"invalid_config",name:err.subagentName??name});return true}if(err.code===SubagentErrorCode.FILE_ERROR){const debug=isServeDebugMode();res.status(500).json({error:debug?err.message:"Failed to write workspace agent file",code:"file_error",name:err.subagentName??name});return true}return false}__name(sendCreateAgentError,"sendCreateAgentError");function sendUpdateAgentError(res,err,agentType){if(!(err instanceof SubagentError))return false;if(err.code===SubagentErrorCode.NOT_FOUND){res.status(404).json({error:err.message,code:"agent_not_found",name:err.subagentName??agentType});return true}if(err.code===SubagentErrorCode.INVALID_CONFIG){res.status(403).json({error:err.message,code:"agent_readonly",name:err.subagentName??agentType});return true}if(err.code===SubagentErrorCode.VALIDATION_ERROR||err.code===SubagentErrorCode.INVALID_NAME||err.code===SubagentErrorCode.TOOL_NOT_FOUND){res.status(422).json({error:err.message,code:"invalid_config",name:err.subagentName??agentType});return true}if(err.code===SubagentErrorCode.FILE_ERROR){const debug=isServeDebugMode();res.status(500).json({error:debug?err.message:"Failed to write workspace agent file",code:"file_error",name:err.subagentName??agentType});return true}return false}__name(sendUpdateAgentError,"sendUpdateAgentError");function parseAgentConfig(body,level,res){if("executionBackend"in body){return sendInvalidConfig(res,"Daemon agents do not support executionBackend.")}const rawName=body["name"];if(typeof rawName!=="string"||rawName.trim().length===0){res.status(422).json({error:"`name` is required and must be a non-empty string",code:"invalid_config"});return void 0}const name=rawName.trim();if(name.length<AGENT_TYPE_MIN_LENGTH||name.length>AGENT_TYPE_MAX_LENGTH||!AGENT_TYPE_PATTERN.test(name)){res.status(422).json({error:`\`name\` must be ${AGENT_TYPE_MIN_LENGTH}-${AGENT_TYPE_MAX_LENGTH} characters of letters, numbers, hyphens, or underscores`,code:"invalid_config",name});return void 0}if(BuiltinAgentRegistry.isBuiltinAgent(name)){res.status(422).json({error:`"${name}" shadows a built-in subagent and cannot be used as a project- or user-level agent name. Choose a different name.`,code:"invalid_config",name});return void 0}const description=body["description"];if(typeof description!=="string"||description.trim().length===0){res.status(422).json({error:"`description` is required and must be a non-empty string",code:"invalid_config"});return void 0}if(Buffer.byteLength(description,"utf8")>MAX_DESCRIPTION_BYTES){res.status(422).json({error:`\`description\` exceeds the ${MAX_DESCRIPTION_BYTES}-byte limit`,code:"invalid_config"});return void 0}const systemPrompt=body["systemPrompt"];if(typeof systemPrompt!=="string"||systemPrompt.trim().length===0){res.status(422).json({error:"`systemPrompt` is required and must be a non-empty string (whitespace only is rejected)",code:"invalid_config"});return void 0}if(Buffer.byteLength(systemPrompt,"utf8")>MAX_SYSTEM_PROMPT_BYTES){res.status(422).json({error:`\`systemPrompt\` exceeds the ${MAX_SYSTEM_PROMPT_BYTES}-byte limit`,code:"invalid_config"});return void 0}const tools=parseStringArray(body["tools"],"tools",res);if(tools===null)return void 0;const disallowedTools=parseStringArray(body["disallowedTools"],"disallowedTools",res);if(disallowedTools===null)return void 0;const config={name,description,systemPrompt,level};if(tools!==void 0)config.tools=tools;if(disallowedTools!==void 0)config.disallowedTools=disallowedTools;if(rejectIfPresentWrongType(body,"model","string",res))return void 0;if(typeof body["model"]==="string"){if(!body["model"].trim()){return sendInvalidConfig(res,"`model` must not be empty when provided")}config.model=body["model"].trim()}if(rejectIfPresentWrongType(body,"color","string",res))return void 0;if(typeof body["color"]==="string"){if(!SUBAGENT_COLORS.includes(body["color"])){return sendInvalidConfig(res,`\`color\` must be one of ${JSON.stringify(SUBAGENT_COLORS)}`)}config.color=body["color"]}if(rejectIfPresentWrongType(body,"approvalMode","string",res)){return void 0}if(typeof body["approvalMode"]==="string"){if(!SUBAGENT_APPROVAL_MODES.includes(body["approvalMode"])){return sendInvalidConfig(res,`\`approvalMode\` must be one of ${JSON.stringify(SUBAGENT_APPROVAL_MODES)}`)}config.approvalMode=body["approvalMode"]}if(rejectIfPresentWrongType(body,"permissionMode","string",res)){return void 0}if(typeof body["permissionMode"]==="string"){if(!SUBAGENT_PERMISSION_MODES.includes(body["permissionMode"])){return sendInvalidConfig(res,`\`permissionMode\` must be one of ${JSON.stringify(SUBAGENT_PERMISSION_MODES)}`)}config.permissionMode=body["permissionMode"]}if("maxTurns"in body){const maxTurns=parseMaxTurns(body["maxTurns"],res);if(maxTurns===null)return void 0;config.maxTurns=maxTurns}if("mcpServers"in body){const mcpServers=parseRecordField(body["mcpServers"],"mcpServers",value=>typeof value==="object"&&value!==null&&!Array.isArray(value),"an object of server names to server configuration objects",res);if(mcpServers===null)return void 0;if(Object.keys(mcpServers).length>0)config.mcpServers=mcpServers}if("hooks"in body){const hooks=parseRecordField(body["hooks"],"hooks",Array.isArray,"an object of hook event names to matcher arrays",res);if(hooks===null)return void 0;if(Object.keys(hooks).length>0)config.hooks=hooks}if(rejectIfPresentWrongType(body,"background","boolean",res)){return void 0}if(typeof body["background"]==="boolean"){config.background=body["background"]}const runConfig=body["runConfig"];if(runConfig!==void 0){const sanitized=sanitizeRunConfig(runConfig,res);if(sanitized===null)return void 0;config.runConfig=sanitized}return config}__name(parseAgentConfig,"parseAgentConfig");function parseAgentUpdates(body,res){if("executionBackend"in body){return sendInvalidConfig(res,"Daemon agents do not support executionBackend.")}const updates={};if("description"in body){const value=body["description"];if(typeof value!=="string"||value.trim().length===0){res.status(422).json({error:"`description` must be a non-empty string (whitespace only is rejected) when provided",code:"invalid_config"});return void 0}if(Buffer.byteLength(value,"utf8")>MAX_DESCRIPTION_BYTES){res.status(422).json({error:`\`description\` exceeds the ${MAX_DESCRIPTION_BYTES}-byte limit`,code:"invalid_config"});return void 0}updates.description=value}if("systemPrompt"in body){const value=body["systemPrompt"];if(typeof value!=="string"||value.trim().length===0){res.status(422).json({error:"`systemPrompt` must be a non-empty string (whitespace only is rejected) when provided",code:"invalid_config"});return void 0}if(Buffer.byteLength(value,"utf8")>MAX_SYSTEM_PROMPT_BYTES){res.status(422).json({error:`\`systemPrompt\` exceeds the ${MAX_SYSTEM_PROMPT_BYTES}-byte limit`,code:"invalid_config"});return void 0}updates.systemPrompt=value}if("tools"in body){const tools=parseStringArray(body["tools"],"tools",res);if(tools===null)return void 0;if(tools!==void 0)updates.tools=tools}if("disallowedTools"in body){const disallowedTools=parseStringArray(body["disallowedTools"],"disallowedTools",res);if(disallowedTools===null)return void 0;if(disallowedTools!==void 0){updates.disallowedTools=disallowedTools}}if(body["model"]===null){updates.model=void 0}else if(rejectIfPresentWrongType(body,"model","string",res)){return void 0}else if(typeof body["model"]==="string"){if(!body["model"].trim()){return sendInvalidConfig(res,"`model` must not be empty when provided")}updates.model=body["model"].trim()}if(body["color"]===null){updates.color=void 0}else if(rejectIfPresentWrongType(body,"color","string",res)){return void 0}else if(typeof body["color"]==="string"){if(!SUBAGENT_COLORS.includes(body["color"])){return sendInvalidConfig(res,`\`color\` must be one of ${JSON.stringify(SUBAGENT_COLORS)}`)}updates.color=body["color"]}if(body["approvalMode"]===null){updates.approvalMode=void 0}else if(rejectIfPresentWrongType(body,"approvalMode","string",res)){return void 0}else if(typeof body["approvalMode"]==="string"){if(!SUBAGENT_APPROVAL_MODES.includes(body["approvalMode"])){return sendInvalidConfig(res,`\`approvalMode\` must be one of ${JSON.stringify(SUBAGENT_APPROVAL_MODES)}`)}updates.approvalMode=body["approvalMode"]}if(body["permissionMode"]===null){updates.permissionMode=void 0}else if(rejectIfPresentWrongType(body,"permissionMode","string",res)){return void 0}else if(typeof body["permissionMode"]==="string"){if(!SUBAGENT_PERMISSION_MODES.includes(body["permissionMode"])){return sendInvalidConfig(res,`\`permissionMode\` must be one of ${JSON.stringify(SUBAGENT_PERMISSION_MODES)}`)}updates.permissionMode=body["permissionMode"]}if("maxTurns"in body){if(body["maxTurns"]===null){updates.maxTurns=void 0}else{const maxTurns=parseMaxTurns(body["maxTurns"],res);if(maxTurns===null)return void 0;updates.maxTurns=maxTurns}}if("mcpServers"in body){const mcpServers=parseRecordField(body["mcpServers"],"mcpServers",value=>typeof value==="object"&&value!==null&&!Array.isArray(value),"an object of server names to server configuration objects",res);if(mcpServers===null)return void 0;updates.mcpServers=mcpServers}if("hooks"in body){const hooks=parseRecordField(body["hooks"],"hooks",Array.isArray,"an object of hook event names to matcher arrays",res);if(hooks===null)return void 0;updates.hooks=hooks}if(rejectIfPresentWrongType(body,"background","boolean",res)){return void 0}if(typeof body["background"]==="boolean"){updates.background=body["background"]}if("runConfig"in body){const sanitized=sanitizeRunConfig(body["runConfig"],res);if(sanitized===null)return void 0;updates.runConfig=sanitized}return updates}__name(parseAgentUpdates,"parseAgentUpdates");function parseStringArray(value,field,res){if(value===void 0)return void 0;if(!Array.isArray(value)||value.some(v=>typeof v!=="string")){res.status(422).json({error:`\`${field}\` must be an array of strings when provided`,code:"invalid_config"});return null}if(value.length>MAX_TOOLS_ENTRIES){res.status(422).json({error:`\`${field}\` exceeds the ${MAX_TOOLS_ENTRIES}-entry limit`,code:"invalid_config"});return null}if(value.some(v=>v.length>MAX_TOOL_ID_LENGTH)){res.status(422).json({error:`\`${field}\` entries must be at most ${MAX_TOOL_ID_LENGTH} characters`,code:"invalid_config"});return null}return value}__name(parseStringArray,"parseStringArray");function sendInvalidConfig(res,error){res.status(422).json({error,code:"invalid_config"});return void 0}__name(sendInvalidConfig,"sendInvalidConfig");function parseMaxTurns(value,res){if(typeof value!=="number"||!Number.isFinite(value)||!Number.isInteger(value)||value<=0){sendInvalidConfig(res,"`maxTurns` must be a positive integer");return null}return value}__name(parseMaxTurns,"parseMaxTurns");function parseRecordField(value,field,isValidEntry,expected,res){if(typeof value!=="object"||value===null||Array.isArray(value)){sendInvalidConfig(res,`\`${field}\` must be ${expected}`);return null}const entries=Object.entries(value);if(entries.length>MAX_RECORD_ENTRIES){sendInvalidConfig(res,`\`${field}\` exceeds the ${MAX_RECORD_ENTRIES}-entry limit`);return null}const output={};for(const[key,entry]of entries){if(!key||key.length>MAX_TOOL_ID_LENGTH||key==="__proto__"||key==="constructor"||key==="prototype"||!isValidEntry(entry)){sendInvalidConfig(res,`\`${field}\` must be ${expected}`);return null}output[key]=entry}return output}__name(parseRecordField,"parseRecordField");function rejectIfPresentWrongType(body,key,expected,res){if(!(key in body))return false;if(typeof body[key]===expected)return false;res.status(422).json({error:`\`${key}\` must be a ${expected} when provided`,code:"invalid_config"});return true}__name(rejectIfPresentWrongType,"rejectIfPresentWrongType");function isNoOpUpdate(existing,updates){if(updates.description!==void 0&&updates.description!==existing.description){return false}if(updates.systemPrompt!==void 0&&updates.systemPrompt!==existing.systemPrompt){return false}if(updates.tools!==void 0&&!shallowArrayEqual(updates.tools,existing.tools)){return false}if(updates.disallowedTools!==void 0&&!shallowArrayEqual(updates.disallowedTools,existing.disallowedTools)){return false}if("model"in updates&&updates.model!==existing.model){return false}if("color"in updates&&updates.color!==existing.color){return false}if("approvalMode"in updates&&updates.approvalMode!==existing.approvalMode){return false}if("permissionMode"in updates&&updates.permissionMode!==existing.permissionMode){return false}if("maxTurns"in updates&&updates.maxTurns!==existing.maxTurns){return false}if(updates.mcpServers!==void 0&&!isDeepStrictEqual(normalizedRecord(updates.mcpServers),normalizedRecord(existing.mcpServers))){return false}if(updates.hooks!==void 0&&!isDeepStrictEqual(normalizedRecord(updates.hooks),normalizedRecord(existing.hooks))){return false}if(updates.background!==void 0&&updates.background!==existing.background){return false}if(updates.runConfig!==void 0){const e=existing.runConfig??{};const u=updates.runConfig;if("max_time_minutes"in u){if(u["max_time_minutes"]!==e["max_time_minutes"])return false}if("max_turns"in u){if(u["max_turns"]!==e["max_turns"])return false}}return true}__name(isNoOpUpdate,"isNoOpUpdate");function normalizedRecord(value){if(!value||Object.keys(value).length===0)return void 0;return normalizeRecordValue(value)}__name(normalizedRecord,"normalizedRecord");function normalizeRecordValue(value){if(Array.isArray(value))return value.map(normalizeRecordValue);if(typeof value!=="object"||value===null)return value;return Object.fromEntries(Object.entries(value).filter(([,entry])=>entry!==void 0).map(([key,entry])=>[key,normalizeRecordValue(entry)]))}__name(normalizeRecordValue,"normalizeRecordValue");function shallowArrayEqual(a,b){if(a===b)return true;if(!a||!b)return false;if(a.length!==b.length)return false;for(let i=0;i<a.length;i++)if(a[i]!==b[i])return false;return true}__name(shallowArrayEqual,"shallowArrayEqual");function sanitizeRunConfig(raw,res){if(typeof raw!=="object"||raw===null||Array.isArray(raw)){res.status(422).json({error:"`runConfig` must be an object when provided",code:"invalid_config"});return null}const input=raw;const out={};if("max_time_minutes"in input){const v=input["max_time_minutes"];if(typeof v!=="number"||!Number.isFinite(v)||v<=0){res.status(422).json({error:"`runConfig.max_time_minutes` must be a positive finite number when provided",code:"invalid_config"});return null}out["max_time_minutes"]=v}if("max_turns"in input){const v=input["max_turns"];if(typeof v!=="number"||!Number.isFinite(v)||v<=0||!Number.isInteger(v)){res.status(422).json({error:"`runConfig.max_turns` must be a positive integer when provided",code:"invalid_config"});return null}out["max_turns"]=v}return out}__name(sanitizeRunConfig,"sanitizeRunConfig");function toSummary(config){const summary={kind:"agent",name:config.name,description:config.description,level:config.level,isBuiltin:config.isBuiltin===true||config.level==="builtin",hasTools:Array.isArray(config.tools)&&config.tools.length>0};if(config.tools)summary.tools=[...config.tools];if(config.disallowedTools){summary.disallowedTools=[...config.disallowedTools]}if(config.model)summary.model=config.model;if(config.color)summary.color=config.color;if(config.background!==void 0)summary.background=config.background;if(config.approvalMode)summary.approvalMode=config.approvalMode;if(config.permissionMode)summary.permissionMode=config.permissionMode;if(config.maxTurns!==void 0)summary.maxTurns=config.maxTurns;if(config.mcpServers){summary.mcpServerNames=Object.keys(config.mcpServers)}if(config.hooks)summary.hookEvents=Object.keys(config.hooks);if(config.runConfig){const runConfig={};if(typeof config.runConfig.max_time_minutes==="number"){runConfig.max_time_minutes=config.runConfig.max_time_minutes}if(typeof config.runConfig.max_turns==="number"){runConfig.max_turns=config.runConfig.max_turns}summary.runConfig=runConfig}if(config.extensionName)summary.extensionName=config.extensionName;if(config.filePath)summary.filePath=config.filePath;return summary}__name(toSummary,"toSummary");function toDetail(config){const detail={...toSummary(config),systemPrompt:config.systemPrompt};if(config.mcpServers){detail.mcpServers=redactMcpServersSetting(config.mcpServers)}if(config.hooks)detail.hooks=config.hooks;return detail}__name(toDetail,"toDetail");function createDaemonSubagentManager(boundWorkspace,safeMode=false){const stub={getSdkMode:__name(()=>false,"getSdkMode"),getProjectRoot:__name(()=>boundWorkspace,"getProjectRoot"),getActiveExtensions:__name(()=>[],"getActiveExtensions"),isSafeMode:__name(()=>safeMode,"isSafeMode"),getAgentsSettings:__name(()=>({}),"getAgentsSettings")};const guarded=new Proxy(stub,{get(target,prop){if(prop in target){return target[prop]}if(prop==="then")return void 0;throw new Error(`qwen serve workspace agents: SubagentManager touched Config.${String(prop)} which the daemon stub does not implement. Add it to createDaemonSubagentManager and audit safety.`)},has(target,prop){if(prop in target)return true;if(prop==="then")return false;throw new Error(`qwen serve workspace agents: SubagentManager probed Config.${String(prop)} via 'in' check; the daemon stub does not implement it. Add it to createDaemonSubagentManager and audit safety.`)}});return new SubagentManager(guarded)}__name(createDaemonSubagentManager,"createDaemonSubagentManager");export{mountWorkspaceAgentsRoutes,mountWorkspaceQualifiedAgentsRoutes,toSummary,toDetail,createDaemonSubagentManager};
|
|
3
|
+
import{redactMcpServersSetting,restoreRedactedMcpServersSetting}from"./chunk-44U2VNWI.js";import{safeLogValue}from"./chunk-K246IFIW.js";import{requireTrustedWorkspaceRuntime,resolveWorkspaceRuntimeFromParam,sendGenerationClosedError}from"./chunk-B6F7CVBP.js";import{isServeDebugMode}from"./chunk-CUNEBE5E.js";import{STATUS_SCHEMA_VERSION}from"./chunk-LUDNUVSA.js";import{loadSettings}from"./chunk-MVGQFFIK.js";import{BuiltinAgentRegistry,SubagentManager}from"./chunk-LZNBHBAJ.js";import{APPROVAL_MODES}from"./chunk-JZK2WGXA.js";import{writeStderrLine}from"./chunk-SLPJ4OII.js";import{SubagentError,SubagentErrorCode}from"./chunk-B3ZFUGTC.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name}from"./chunk-KBWJGX7I.js";init_esbuild_shims();import{promises as fs}from"node:fs";import{isDeepStrictEqual}from"node:util";var AGENT_TYPE_PATTERN=/^[\p{L}\p{N}_-]+$/u;var AGENT_TYPE_MAX_LENGTH=64;var AGENT_TYPE_MIN_LENGTH=2;var MAX_DESCRIPTION_BYTES=256*1024;var MAX_SYSTEM_PROMPT_BYTES=256*1024;var MAX_TOOLS_ENTRIES=256;var MAX_TOOL_ID_LENGTH=256;var MAX_RECORD_ENTRIES=128;var SUBAGENT_APPROVAL_MODES=[...APPROVAL_MODES,"bubble"];var SUBAGENT_PERMISSION_MODES=["acceptEdits","auto","bypassPermissions","default","dontAsk","plan"];var SUBAGENT_COLORS=["auto","red","blue","green","yellow","purple","orange","pink","cyan"];function captureTrustedGeneration(deps,res){const assertGenerationOpen=deps.captureGenerationAssertion?.()??(()=>{});try{assertGenerationOpen()}catch{res.set("Retry-After","1");res.status(503).json({error:"Workspace runtime is not active.",code:"workspace_runtime_unavailable"});return null}if(deps.isWorkspaceTrusted?.()===false){res.status(403).json({error:"Workspace is not trusted.",code:"untrusted_workspace"});return null}return assertGenerationOpen}__name(captureTrustedGeneration,"captureTrustedGeneration");function mountWorkspaceAgentsRoutes(app,deps){const manager=createDaemonSubagentManager(deps.boundWorkspace);app.get("/workspace/agents",async(_req,res)=>{const assertGenerationOpen=captureTrustedGeneration(deps,res);if(!assertGenerationOpen)return;try{const agents=await manager.listSubagents({force:true});assertGenerationOpen();const status={v:STATUS_SCHEMA_VERSION,workspaceCwd:deps.boundWorkspace,agents:agents.map(toSummary)};res.status(200).json(status)}catch(err){if(sendGenerationClosedError(res,err))return;writeStderrLine(`qwen serve: GET /workspace/agents failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to list workspace agents",code:"agent_list_failed"})}});app.post("/workspace/agents",deps.mutate({strict:true}),async(req,res)=>{const assertGenerationOpen=captureTrustedGeneration(deps,res);if(!assertGenerationOpen)return;const body=deps.safeBody(req);const clientIdResult=resolveOriginatorClientId(deps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const scope=body["scope"];if(scope!=="workspace"&&scope!=="global"){res.status(400).json({error:'`scope` must be "workspace" or "global"',code:"invalid_scope"});return}const level=scope==="workspace"?"project":"user";const config=parseAgentConfig(restoreAgentMcpServerSecrets(body,deps.boundWorkspace,level),level,res);if(!config)return;const collision=await manager.loadSubagent(config.name,level);if(collision){res.status(409).json({error:`Subagent "${config.name}" already exists at ${level} level`,code:"agent_already_exists",name:config.name,level});return}try{assertGenerationOpen();await manager.createSubagent(config,{level,assertCanCommit:assertGenerationOpen});assertGenerationOpen()}catch(err){if(sendGenerationClosedError(res,err))return;if(err instanceof SubagentError){if(err.code===SubagentErrorCode.ALREADY_EXISTS){res.status(409).json({error:err.message,code:"agent_already_exists",name:err.subagentName??config.name});return}if(err.code===SubagentErrorCode.VALIDATION_ERROR||err.code===SubagentErrorCode.INVALID_CONFIG||err.code===SubagentErrorCode.INVALID_NAME||err.code===SubagentErrorCode.TOOL_NOT_FOUND){res.status(422).json({error:err.message,code:"invalid_config",name:err.subagentName??config.name});return}if(err.code===SubagentErrorCode.FILE_ERROR){const debug=isServeDebugMode();res.status(500).json({error:debug?err.message:"Failed to write workspace agent file",code:"file_error",name:err.subagentName??config.name});return}}writeStderrLine(`qwen serve: POST /workspace/agents failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to create workspace agent",code:"agent_create_failed"});return}const created=await manager.loadSubagent(config.name,level);try{assertGenerationOpen()}catch(err){sendGenerationClosedError(res,err);return}if(!created){writeStderrLine(`qwen serve: agent_create_reload_failed (name=${safeLogValue(config.name)} level=${level}) \u2014 file likely persisted on disk; check \`GET /workspace/agents\` for a phantom entry`);res.status(500).json({error:"Agent creation succeeded but reload failed",code:"agent_create_reload_failed",name:config.name,level});return}deps.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"created",name:config.name,level},...originatorClientId?{originatorClientId}:{}});res.status(201).json({ok:true,agent:toDetail(created)})});app.post("/workspace/agents/generate",deps.mutate({strict:true}),async(req,res)=>{const assertGenerationOpen=captureTrustedGeneration(deps,res);if(!assertGenerationOpen)return;const body=deps.safeBody(req);const clientIdResult=resolveOriginatorClientId(deps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const description=body["description"];if(typeof description!=="string"||description.trim().length===0){res.status(400).json({error:"`description` must be a non-empty string",code:"invalid_description"});return}if(Buffer.byteLength(description,"utf8")>4096){res.status(400).json({error:"`description` exceeds the 4096-byte limit",code:"invalid_description"});return}try{const generated=await deps.bridge.generateWorkspaceAgent(description.trim(),originatorClientId);assertGenerationOpen();res.status(200).json(generated)}catch(err){if(sendGenerationClosedError(res,err))return;writeStderrLine(`qwen serve: POST /workspace/agents/generate failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to generate workspace agent",code:"agent_generate_failed"})}});app.get("/workspace/agents/:agentType",async(req,res)=>{const assertGenerationOpen=captureTrustedGeneration(deps,res);if(!assertGenerationOpen)return;const agentType=validateAgentType(req,res);if(agentType===null)return;try{const scopedLevel=parseScopeQuery(req,res);if(scopedLevel===null)return;const config=await manager.loadSubagent(agentType,scopedLevel);assertGenerationOpen();if(!config){res.status(404).json({error:`Subagent "${agentType}" not found`,code:"agent_not_found",name:agentType});return}res.status(200).json(toDetail(config))}catch(err){if(sendGenerationClosedError(res,err))return;writeStderrLine(`qwen serve: GET /workspace/agents/${safeLogValue(agentType)} failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to read workspace agent",code:"agent_read_failed"})}});app.post("/workspace/agents/:agentType",deps.mutate({strict:true}),async(req,res)=>{const assertGenerationOpen=captureTrustedGeneration(deps,res);if(!assertGenerationOpen)return;const agentType=validateAgentType(req,res);if(agentType===null)return;const clientIdResult=resolveOriginatorClientId(deps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const preferredLevel=parseScopeQuery(req,res);if(preferredLevel===null)return;const existing=await manager.loadSubagent(agentType,preferredLevel);if(!existing){res.status(404).json({error:`Subagent "${agentType}" not found`,code:"agent_not_found",name:agentType});return}if(assertMutableLevel(existing,agentType,res)){return}const body=restoreAgentMcpServerSecrets(deps.safeBody(req),deps.boundWorkspace,existing.level,existing.mcpServers);const updates=parseAgentUpdates(body,res);if(!updates)return;if(Object.keys(updates).length===0){res.status(400).json({error:"`POST /workspace/agents/:agentType` requires at least one updatable field in the body",code:"invalid_config",name:agentType});return}if(isNoOpUpdate(existing,updates)){res.status(200).json({ok:true,agent:toDetail(existing),changed:false});return}try{assertGenerationOpen();await manager.updateSubagent(agentType,updates,existing.level,{assertCanCommit:assertGenerationOpen});assertGenerationOpen()}catch(err){if(sendGenerationClosedError(res,err))return;if(err instanceof SubagentError){if(err.code===SubagentErrorCode.NOT_FOUND){res.status(404).json({error:err.message,code:"agent_not_found",name:err.subagentName??agentType});return}if(err.code===SubagentErrorCode.INVALID_CONFIG){res.status(403).json({error:err.message,code:"agent_readonly",name:err.subagentName??agentType});return}if(err.code===SubagentErrorCode.VALIDATION_ERROR||err.code===SubagentErrorCode.INVALID_NAME||err.code===SubagentErrorCode.TOOL_NOT_FOUND){res.status(422).json({error:err.message,code:"invalid_config",name:err.subagentName??agentType});return}if(err.code===SubagentErrorCode.FILE_ERROR){const debug=isServeDebugMode();res.status(500).json({error:debug?err.message:"Failed to write workspace agent file",code:"file_error",name:err.subagentName??agentType});return}}writeStderrLine(`qwen serve: POST /workspace/agents/${safeLogValue(agentType)} failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to update workspace agent",code:"agent_update_failed"});return}const updated=await manager.loadSubagent(agentType,existing.level);try{assertGenerationOpen()}catch(err){sendGenerationClosedError(res,err);return}if(!updated){writeStderrLine(`qwen serve: agent_update_reload_failed (name=${safeLogValue(agentType)} level=${existing.level}) \u2014 disk write completed; check \`GET /workspace/agents/${safeLogValue(agentType)}\` for the new state`);res.status(500).json({error:"Agent update succeeded but reload failed",code:"agent_update_reload_failed",name:agentType,level:existing.level});return}const eventLevel=existing.level==="project"?"project":"user";deps.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"updated",name:existing.name,level:eventLevel},...originatorClientId?{originatorClientId}:{}});res.status(200).json({ok:true,agent:toDetail(updated),changed:true})});app.delete("/workspace/agents/:agentType",deps.mutate({strict:true}),async(req,res)=>{const assertGenerationOpen=captureTrustedGeneration(deps,res);if(!assertGenerationOpen)return;const agentType=validateAgentType(req,res);if(agentType===null)return;const clientIdResult=resolveOriginatorClientId(deps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const scopedLevel=parseScopeQuery(req,res);if(scopedLevel===null)return;const levelsToCheck=scopedLevel?[scopedLevel]:["project","user"];const existingAtLevels=[];for(const lvl of levelsToCheck){const found=await manager.loadSubagent(agentType,lvl);if(found)existingAtLevels.push(found)}for(const found of existingAtLevels){if(assertMutableLevel(found,agentType,res))return}try{assertGenerationOpen();await manager.deleteSubagent(agentType,scopedLevel,void 0,{assertCanCommit:assertGenerationOpen});assertGenerationOpen()}catch(err){if(sendGenerationClosedError(res,err))return;if(err instanceof SubagentError){if(err.code===SubagentErrorCode.NOT_FOUND){res.status(404).json({error:err.message,code:"agent_not_found",name:err.subagentName??agentType});return}if(err.code===SubagentErrorCode.INVALID_CONFIG){res.status(403).json({error:err.message,code:"agent_readonly",name:err.subagentName??agentType});return}}writeStderrLine(`qwen serve: DELETE /workspace/agents/${safeLogValue(agentType)} failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to delete workspace agent",code:"agent_delete_failed"});return}const removed=[];const remaining=[];for(const found of existingAtLevels){if(!found.filePath){removed.push(found);continue}try{await fs.access(found.filePath);remaining.push(found)}catch{removed.push(found)}}try{assertGenerationOpen()}catch(err){sendGenerationClosedError(res,err);return}if(remaining.length>0){writeStderrLine(`qwen serve: DELETE /workspace/agents/${safeLogValue(agentType)} partial \u2014 removed=${removed.map(r=>r.level).join(",")||"none"} remaining=${remaining.map(r=>`${r.level}:${r.filePath}`).join(",")}`);for(const found of removed){const evtLevel=found.level==="project"?"project":"user";deps.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"deleted",name:found.name,level:evtLevel},...originatorClientId?{originatorClientId}:{}})}res.status(500).json({error:`Failed to delete every level of subagent "${agentType}" \u2014 ${remaining.length} level(s) still have their file on disk`,code:"agent_delete_partial",name:agentType,removedLevels:removed.map(r=>r.level),remainingLevels:remaining.map(r=>r.level)});return}if(existingAtLevels.length===0){const fallbackLevel=scopedLevel==="user"?"user":"project";deps.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"deleted",name:agentType,level:fallbackLevel},...originatorClientId?{originatorClientId}:{}})}else{for(const found of removed){const evtLevel=found.level==="project"?"project":"user";deps.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"deleted",name:found.name,level:evtLevel},...originatorClientId?{originatorClientId}:{}})}}res.status(204).end()})}__name(mountWorkspaceAgentsRoutes,"mountWorkspaceAgentsRoutes");function mountWorkspaceQualifiedAgentsRoutes(app,deps){app.get("/workspaces/:workspace/agents",async(req,res)=>{const runtime=resolveTrustedWorkspaceAgentRuntime(deps,req,res);if(!runtime)return;const scopedLevel=parseWorkspaceOnlyAgentScopeQuery(req,res);if(scopedLevel===null)return;const manager=createDaemonSubagentManager(runtime.workspaceCwd);try{const agents=await manager.listSubagents({force:true});runtime.generationGuard?.assertOpen();const status={v:STATUS_SCHEMA_VERSION,workspaceCwd:runtime.workspaceCwd,agents:agents.filter(agent=>agent.level==="project").map(toSummary)};res.status(200).json(status)}catch(err){if(sendGenerationClosedError(res,err))return;writeStderrLine(`qwen serve: GET /workspaces/:workspace/agents failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to list workspace agents",code:"agent_list_failed"})}});app.post("/workspaces/:workspace/agents",deps.mutate({strict:true}),async(req,res)=>{const runtime=resolveTrustedWorkspaceAgentRuntime(deps,req,res);if(!runtime)return;const routeDeps=workspaceAgentDepsForRuntime(runtime,deps);const body=deps.safeBody(req);const clientIdResult=resolveOriginatorClientId(routeDeps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const level=parseWorkspaceOnlyAgentBodyScope(body,res);if(level===null)return;const manager=createDaemonSubagentManager(runtime.workspaceCwd);const config=parseAgentConfig(restoreAgentMcpServerSecrets(body,runtime.workspaceCwd,level),level,res);if(!config)return;const collision=await manager.loadSubagent(config.name,level);if(collision){res.status(409).json({error:`Subagent "${config.name}" already exists at ${level} level`,code:"agent_already_exists",name:config.name,level});return}try{runtime.generationGuard?.assertOpen();await manager.createSubagent(config,{level,assertCanCommit:__name(()=>runtime.generationGuard?.assertOpen(),"assertCanCommit")});runtime.generationGuard?.assertOpen()}catch(err){if(sendGenerationClosedError(res,err))return;if(sendCreateAgentError(res,err,config.name))return;writeStderrLine(`qwen serve: POST /workspaces/:workspace/agents failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to create workspace agent",code:"agent_create_failed"});return}const created=await manager.loadSubagent(config.name,level);try{runtime.generationGuard?.assertOpen()}catch(err){sendGenerationClosedError(res,err);return}if(!created){writeStderrLine(`qwen serve: agent_create_reload_failed (name=${safeLogValue(config.name)} level=${level}) \u2014 file likely persisted on disk; check \`GET /workspaces/:workspace/agents\` for a phantom entry`);res.status(500).json({error:"Agent creation succeeded but reload failed",code:"agent_create_reload_failed",name:config.name,level});return}runtime.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"created",name:config.name,level:"project"},...originatorClientId?{originatorClientId}:{}});res.status(201).json({ok:true,agent:toDetail(created)})});app.get("/workspaces/:workspace/agents/:agentType",async(req,res)=>{const runtime=resolveTrustedWorkspaceAgentRuntime(deps,req,res);if(!runtime)return;const agentType=validateAgentType(req,res);if(agentType===null)return;const scopedLevel=parseWorkspaceOnlyAgentScopeQuery(req,res);if(scopedLevel===null)return;const manager=createDaemonSubagentManager(runtime.workspaceCwd);try{const config=await manager.loadSubagent(agentType,scopedLevel);runtime.generationGuard?.assertOpen();if(!config){res.status(404).json({error:`Subagent "${agentType}" not found`,code:"agent_not_found",name:agentType});return}res.status(200).json(toDetail(config))}catch(err){if(sendGenerationClosedError(res,err))return;writeStderrLine(`qwen serve: GET /workspaces/:workspace/agents/${safeLogValue(agentType)} failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to read workspace agent",code:"agent_read_failed"})}});app.post("/workspaces/:workspace/agents/:agentType",deps.mutate({strict:true}),async(req,res)=>{const runtime=resolveTrustedWorkspaceAgentRuntime(deps,req,res);if(!runtime)return;const agentType=validateAgentType(req,res);if(agentType===null)return;const scopedLevel=parseWorkspaceOnlyAgentScopeQuery(req,res);if(scopedLevel===null)return;const routeDeps=workspaceAgentDepsForRuntime(runtime,deps);const clientIdResult=resolveOriginatorClientId(routeDeps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const manager=createDaemonSubagentManager(runtime.workspaceCwd);const existing=await manager.loadSubagent(agentType,scopedLevel);if(!existing){res.status(404).json({error:`Subagent "${agentType}" not found`,code:"agent_not_found",name:agentType});return}if(assertMutableLevel(existing,agentType,res))return;const body=restoreAgentMcpServerSecrets(deps.safeBody(req),runtime.workspaceCwd,existing.level,existing.mcpServers);const updates=parseAgentUpdates(body,res);if(!updates)return;if(Object.keys(updates).length===0){res.status(400).json({error:"`POST /workspaces/:workspace/agents/:agentType` requires at least one updatable field in the body",code:"invalid_config",name:agentType});return}if(isNoOpUpdate(existing,updates)){res.status(200).json({ok:true,agent:toDetail(existing),changed:false});return}try{runtime.generationGuard?.assertOpen();await manager.updateSubagent(agentType,updates,existing.level,{assertCanCommit:__name(()=>runtime.generationGuard?.assertOpen(),"assertCanCommit")});runtime.generationGuard?.assertOpen()}catch(err){if(sendGenerationClosedError(res,err))return;if(sendUpdateAgentError(res,err,agentType))return;writeStderrLine(`qwen serve: POST /workspaces/:workspace/agents/${safeLogValue(agentType)} failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to update workspace agent",code:"agent_update_failed"});return}const updated=await manager.loadSubagent(agentType,existing.level);try{runtime.generationGuard?.assertOpen()}catch(err){sendGenerationClosedError(res,err);return}if(!updated){writeStderrLine(`qwen serve: agent_update_reload_failed (name=${safeLogValue(agentType)} level=${existing.level}) \u2014 disk write completed; check \`GET /workspaces/:workspace/agents/${safeLogValue(agentType)}\` for the new state`);res.status(500).json({error:"Agent update succeeded but reload failed",code:"agent_update_reload_failed",name:agentType,level:existing.level});return}runtime.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"updated",name:existing.name,level:"project"},...originatorClientId?{originatorClientId}:{}});res.status(200).json({ok:true,agent:toDetail(updated),changed:true})});app.delete("/workspaces/:workspace/agents/:agentType",deps.mutate({strict:true}),async(req,res)=>{const runtime=resolveTrustedWorkspaceAgentRuntime(deps,req,res);if(!runtime)return;const agentType=validateAgentType(req,res);if(agentType===null)return;const scopedLevel=parseWorkspaceOnlyAgentScopeQuery(req,res);if(scopedLevel===null)return;const routeDeps=workspaceAgentDepsForRuntime(runtime,deps);const clientIdResult=resolveOriginatorClientId(routeDeps,req,res);if(clientIdResult===null)return;const originatorClientId=clientIdResult;const manager=createDaemonSubagentManager(runtime.workspaceCwd);const existing=await manager.loadSubagent(agentType,scopedLevel);if(existing&&assertMutableLevel(existing,agentType,res))return;try{runtime.generationGuard?.assertOpen();await manager.deleteSubagent(agentType,scopedLevel,void 0,{assertCanCommit:__name(()=>runtime.generationGuard?.assertOpen(),"assertCanCommit")});runtime.generationGuard?.assertOpen()}catch(err){if(sendGenerationClosedError(res,err))return;if(err instanceof SubagentError){if(err.code===SubagentErrorCode.NOT_FOUND){res.status(404).json({error:err.message,code:"agent_not_found",name:err.subagentName??agentType});return}if(err.code===SubagentErrorCode.INVALID_CONFIG){res.status(403).json({error:err.message,code:"agent_readonly",name:err.subagentName??agentType});return}}writeStderrLine(`qwen serve: DELETE /workspaces/:workspace/agents/${safeLogValue(agentType)} failed: ${err instanceof Error?err.stack??err.message:String(err)}`);res.status(500).json({error:"Failed to delete workspace agent",code:"agent_delete_failed"});return}if(existing?.filePath){try{await fs.access(existing.filePath);writeStderrLine(`qwen serve: DELETE /workspaces/:workspace/agents/${safeLogValue(agentType)} partial \u2014 remaining=${existing.level}:${existing.filePath}`);res.status(500).json({error:`Failed to delete subagent "${agentType}" \u2014 ${existing.level} level still has its file on disk`,code:"agent_delete_partial",name:agentType,removedLevels:[],remainingLevels:[existing.level]});return}catch{}}try{runtime.generationGuard?.assertOpen()}catch(err){sendGenerationClosedError(res,err);return}runtime.bridge.publishWorkspaceEvent({type:"agent_changed",data:{change:"deleted",name:existing?.name??agentType,level:"project"},...originatorClientId?{originatorClientId}:{}});res.status(204).end()})}__name(mountWorkspaceQualifiedAgentsRoutes,"mountWorkspaceQualifiedAgentsRoutes");function validateAgentType(req,res){const raw=req.params["agentType"];if(!raw||raw.length===0){res.status(400).json({error:"`agentType` path parameter is required",code:"invalid_agent_type"});return null}if(raw.length>AGENT_TYPE_MAX_LENGTH||!AGENT_TYPE_PATTERN.test(raw)){res.status(400).json({error:"`agentType` must contain only letters, numbers, hyphens, or underscores (max 64 chars)",code:"invalid_agent_type",agentType:raw});return null}return raw}__name(validateAgentType,"validateAgentType");function parseScopeQuery(req,res){const raw=req.query["scope"];if(raw===void 0)return void 0;if(typeof raw!=="string"){res.status(400).json({error:'`scope` query must be a single "workspace" or "global" value',code:"invalid_scope"});return null}if(raw!=="workspace"&&raw!=="global"){res.status(400).json({error:'`scope` query must be "workspace" or "global"',code:"invalid_scope"});return null}return raw==="workspace"?"project":"user"}__name(parseScopeQuery,"parseScopeQuery");function assertMutableLevel(found,agentType,res){if(found.isBuiltin||found.level==="builtin"||found.level==="extension"||found.level==="session"){res.status(403).json({error:`Cannot modify ${found.level}-level subagent "${agentType}"`,code:"agent_readonly",name:found.name,level:found.level});return true}return false}__name(assertMutableLevel,"assertMutableLevel");function resolveOriginatorClientId(deps,req,res){const clientId=deps.parseClientId(req,res);if(clientId===null)return null;if(clientId===void 0)return void 0;if(!deps.bridge.knownClientIds().has(clientId)){res.status(400).json({error:`Client id "${clientId}" is not registered for this workspace`,code:"invalid_client_id",clientId});return null}return clientId}__name(resolveOriginatorClientId,"resolveOriginatorClientId");function resolveTrustedWorkspaceAgentRuntime(deps,req,res){const runtime=resolveWorkspaceRuntimeFromParam(deps.workspaceRegistry,req,res);if(!runtime)return void 0;if(!requireTrustedWorkspaceRuntime(runtime,res))return void 0;return runtime}__name(resolveTrustedWorkspaceAgentRuntime,"resolveTrustedWorkspaceAgentRuntime");function workspaceAgentDepsForRuntime(runtime,deps){return{bridge:runtime.bridge,boundWorkspace:runtime.workspaceCwd,mutate:deps.mutate,parseClientId:deps.parseClientId,safeBody:deps.safeBody}}__name(workspaceAgentDepsForRuntime,"workspaceAgentDepsForRuntime");function parseWorkspaceOnlyAgentBodyScope(body,res){const scope=body["scope"];if(scope===void 0||scope==="workspace"||scope==="project"){return"project"}return rejectWorkspaceQualifiedAgentScope(scope,res)}__name(parseWorkspaceOnlyAgentBodyScope,"parseWorkspaceOnlyAgentBodyScope");function parseWorkspaceOnlyAgentScopeQuery(req,res){const raw=req.query["scope"];if(raw===void 0||raw==="workspace"||raw==="project"){return"project"}if(typeof raw!=="string"){res.status(400).json({error:"`scope` query must be a single workspace/project value",code:"invalid_scope"});return null}return rejectWorkspaceQualifiedAgentScope(raw,res)}__name(parseWorkspaceOnlyAgentScopeQuery,"parseWorkspaceOnlyAgentScopeQuery");function rejectWorkspaceQualifiedAgentScope(scope,res){if(scope==="global"||scope==="user"){res.status(400).json({error:"Workspace-qualified agents routes only support workspace/project scope",code:"global_scope_not_supported_for_workspace_route"});return null}res.status(400).json({error:'`scope` must be "workspace" or "project"',code:"invalid_scope"});return null}__name(rejectWorkspaceQualifiedAgentScope,"rejectWorkspaceQualifiedAgentScope");function restoreAgentMcpServerSecrets(body,workspace,level,currentAgentServers){const incoming=body["mcpServers"];if(typeof incoming!=="object"||incoming===null||Array.isArray(incoming)){return body}const settings=loadSettings(workspace);const configuredServers=level==="user"?settings.user.settings.mcpServers??{}:settings.merged.mcpServers??{};return{...body,mcpServers:restoreRedactedMcpServersSetting(incoming,{...configuredServers,...currentAgentServers})}}__name(restoreAgentMcpServerSecrets,"restoreAgentMcpServerSecrets");function sendCreateAgentError(res,err,name){if(!(err instanceof SubagentError))return false;if(err.code===SubagentErrorCode.ALREADY_EXISTS){res.status(409).json({error:err.message,code:"agent_already_exists",name:err.subagentName??name});return true}if(err.code===SubagentErrorCode.VALIDATION_ERROR||err.code===SubagentErrorCode.INVALID_CONFIG||err.code===SubagentErrorCode.INVALID_NAME||err.code===SubagentErrorCode.TOOL_NOT_FOUND){res.status(422).json({error:err.message,code:"invalid_config",name:err.subagentName??name});return true}if(err.code===SubagentErrorCode.FILE_ERROR){const debug=isServeDebugMode();res.status(500).json({error:debug?err.message:"Failed to write workspace agent file",code:"file_error",name:err.subagentName??name});return true}return false}__name(sendCreateAgentError,"sendCreateAgentError");function sendUpdateAgentError(res,err,agentType){if(!(err instanceof SubagentError))return false;if(err.code===SubagentErrorCode.NOT_FOUND){res.status(404).json({error:err.message,code:"agent_not_found",name:err.subagentName??agentType});return true}if(err.code===SubagentErrorCode.INVALID_CONFIG){res.status(403).json({error:err.message,code:"agent_readonly",name:err.subagentName??agentType});return true}if(err.code===SubagentErrorCode.VALIDATION_ERROR||err.code===SubagentErrorCode.INVALID_NAME||err.code===SubagentErrorCode.TOOL_NOT_FOUND){res.status(422).json({error:err.message,code:"invalid_config",name:err.subagentName??agentType});return true}if(err.code===SubagentErrorCode.FILE_ERROR){const debug=isServeDebugMode();res.status(500).json({error:debug?err.message:"Failed to write workspace agent file",code:"file_error",name:err.subagentName??agentType});return true}return false}__name(sendUpdateAgentError,"sendUpdateAgentError");function parseAgentConfig(body,level,res){if("executionBackend"in body){return sendInvalidConfig(res,"Daemon agents do not support executionBackend.")}const rawName=body["name"];if(typeof rawName!=="string"||rawName.trim().length===0){res.status(422).json({error:"`name` is required and must be a non-empty string",code:"invalid_config"});return void 0}const name=rawName.trim();if(name.length<AGENT_TYPE_MIN_LENGTH||name.length>AGENT_TYPE_MAX_LENGTH||!AGENT_TYPE_PATTERN.test(name)){res.status(422).json({error:`\`name\` must be ${AGENT_TYPE_MIN_LENGTH}-${AGENT_TYPE_MAX_LENGTH} characters of letters, numbers, hyphens, or underscores`,code:"invalid_config",name});return void 0}if(BuiltinAgentRegistry.isBuiltinAgent(name)){res.status(422).json({error:`"${name}" shadows a built-in subagent and cannot be used as a project- or user-level agent name. Choose a different name.`,code:"invalid_config",name});return void 0}const description=body["description"];if(typeof description!=="string"||description.trim().length===0){res.status(422).json({error:"`description` is required and must be a non-empty string",code:"invalid_config"});return void 0}if(Buffer.byteLength(description,"utf8")>MAX_DESCRIPTION_BYTES){res.status(422).json({error:`\`description\` exceeds the ${MAX_DESCRIPTION_BYTES}-byte limit`,code:"invalid_config"});return void 0}const systemPrompt=body["systemPrompt"];if(typeof systemPrompt!=="string"||systemPrompt.trim().length===0){res.status(422).json({error:"`systemPrompt` is required and must be a non-empty string (whitespace only is rejected)",code:"invalid_config"});return void 0}if(Buffer.byteLength(systemPrompt,"utf8")>MAX_SYSTEM_PROMPT_BYTES){res.status(422).json({error:`\`systemPrompt\` exceeds the ${MAX_SYSTEM_PROMPT_BYTES}-byte limit`,code:"invalid_config"});return void 0}const tools=parseStringArray(body["tools"],"tools",res);if(tools===null)return void 0;const disallowedTools=parseStringArray(body["disallowedTools"],"disallowedTools",res);if(disallowedTools===null)return void 0;const config={name,description,systemPrompt,level};if(tools!==void 0)config.tools=tools;if(disallowedTools!==void 0)config.disallowedTools=disallowedTools;if(rejectIfPresentWrongType(body,"model","string",res))return void 0;if(typeof body["model"]==="string"){if(!body["model"].trim()){return sendInvalidConfig(res,"`model` must not be empty when provided")}config.model=body["model"].trim()}if(rejectIfPresentWrongType(body,"color","string",res))return void 0;if(typeof body["color"]==="string"){if(!SUBAGENT_COLORS.includes(body["color"])){return sendInvalidConfig(res,`\`color\` must be one of ${JSON.stringify(SUBAGENT_COLORS)}`)}config.color=body["color"]}if(rejectIfPresentWrongType(body,"approvalMode","string",res)){return void 0}if(typeof body["approvalMode"]==="string"){if(!SUBAGENT_APPROVAL_MODES.includes(body["approvalMode"])){return sendInvalidConfig(res,`\`approvalMode\` must be one of ${JSON.stringify(SUBAGENT_APPROVAL_MODES)}`)}config.approvalMode=body["approvalMode"]}if(rejectIfPresentWrongType(body,"permissionMode","string",res)){return void 0}if(typeof body["permissionMode"]==="string"){if(!SUBAGENT_PERMISSION_MODES.includes(body["permissionMode"])){return sendInvalidConfig(res,`\`permissionMode\` must be one of ${JSON.stringify(SUBAGENT_PERMISSION_MODES)}`)}config.permissionMode=body["permissionMode"]}if("maxTurns"in body){const maxTurns=parseMaxTurns(body["maxTurns"],res);if(maxTurns===null)return void 0;config.maxTurns=maxTurns}if("mcpServers"in body){const mcpServers=parseRecordField(body["mcpServers"],"mcpServers",value=>typeof value==="object"&&value!==null&&!Array.isArray(value),"an object of server names to server configuration objects",res);if(mcpServers===null)return void 0;if(Object.keys(mcpServers).length>0)config.mcpServers=mcpServers}if("hooks"in body){const hooks=parseRecordField(body["hooks"],"hooks",Array.isArray,"an object of hook event names to matcher arrays",res);if(hooks===null)return void 0;if(Object.keys(hooks).length>0)config.hooks=hooks}if(rejectIfPresentWrongType(body,"background","boolean",res)){return void 0}if(typeof body["background"]==="boolean"){config.background=body["background"]}const runConfig=body["runConfig"];if(runConfig!==void 0){const sanitized=sanitizeRunConfig(runConfig,res);if(sanitized===null)return void 0;config.runConfig=sanitized}return config}__name(parseAgentConfig,"parseAgentConfig");function parseAgentUpdates(body,res){if("executionBackend"in body){return sendInvalidConfig(res,"Daemon agents do not support executionBackend.")}const updates={};if("description"in body){const value=body["description"];if(typeof value!=="string"||value.trim().length===0){res.status(422).json({error:"`description` must be a non-empty string (whitespace only is rejected) when provided",code:"invalid_config"});return void 0}if(Buffer.byteLength(value,"utf8")>MAX_DESCRIPTION_BYTES){res.status(422).json({error:`\`description\` exceeds the ${MAX_DESCRIPTION_BYTES}-byte limit`,code:"invalid_config"});return void 0}updates.description=value}if("systemPrompt"in body){const value=body["systemPrompt"];if(typeof value!=="string"||value.trim().length===0){res.status(422).json({error:"`systemPrompt` must be a non-empty string (whitespace only is rejected) when provided",code:"invalid_config"});return void 0}if(Buffer.byteLength(value,"utf8")>MAX_SYSTEM_PROMPT_BYTES){res.status(422).json({error:`\`systemPrompt\` exceeds the ${MAX_SYSTEM_PROMPT_BYTES}-byte limit`,code:"invalid_config"});return void 0}updates.systemPrompt=value}if("tools"in body){const tools=parseStringArray(body["tools"],"tools",res);if(tools===null)return void 0;if(tools!==void 0)updates.tools=tools}if("disallowedTools"in body){const disallowedTools=parseStringArray(body["disallowedTools"],"disallowedTools",res);if(disallowedTools===null)return void 0;if(disallowedTools!==void 0){updates.disallowedTools=disallowedTools}}if(body["model"]===null){updates.model=void 0}else if(rejectIfPresentWrongType(body,"model","string",res)){return void 0}else if(typeof body["model"]==="string"){if(!body["model"].trim()){return sendInvalidConfig(res,"`model` must not be empty when provided")}updates.model=body["model"].trim()}if(body["color"]===null){updates.color=void 0}else if(rejectIfPresentWrongType(body,"color","string",res)){return void 0}else if(typeof body["color"]==="string"){if(!SUBAGENT_COLORS.includes(body["color"])){return sendInvalidConfig(res,`\`color\` must be one of ${JSON.stringify(SUBAGENT_COLORS)}`)}updates.color=body["color"]}if(body["approvalMode"]===null){updates.approvalMode=void 0}else if(rejectIfPresentWrongType(body,"approvalMode","string",res)){return void 0}else if(typeof body["approvalMode"]==="string"){if(!SUBAGENT_APPROVAL_MODES.includes(body["approvalMode"])){return sendInvalidConfig(res,`\`approvalMode\` must be one of ${JSON.stringify(SUBAGENT_APPROVAL_MODES)}`)}updates.approvalMode=body["approvalMode"]}if(body["permissionMode"]===null){updates.permissionMode=void 0}else if(rejectIfPresentWrongType(body,"permissionMode","string",res)){return void 0}else if(typeof body["permissionMode"]==="string"){if(!SUBAGENT_PERMISSION_MODES.includes(body["permissionMode"])){return sendInvalidConfig(res,`\`permissionMode\` must be one of ${JSON.stringify(SUBAGENT_PERMISSION_MODES)}`)}updates.permissionMode=body["permissionMode"]}if("maxTurns"in body){if(body["maxTurns"]===null){updates.maxTurns=void 0}else{const maxTurns=parseMaxTurns(body["maxTurns"],res);if(maxTurns===null)return void 0;updates.maxTurns=maxTurns}}if("mcpServers"in body){const mcpServers=parseRecordField(body["mcpServers"],"mcpServers",value=>typeof value==="object"&&value!==null&&!Array.isArray(value),"an object of server names to server configuration objects",res);if(mcpServers===null)return void 0;updates.mcpServers=mcpServers}if("hooks"in body){const hooks=parseRecordField(body["hooks"],"hooks",Array.isArray,"an object of hook event names to matcher arrays",res);if(hooks===null)return void 0;updates.hooks=hooks}if(rejectIfPresentWrongType(body,"background","boolean",res)){return void 0}if(typeof body["background"]==="boolean"){updates.background=body["background"]}if("runConfig"in body){const sanitized=sanitizeRunConfig(body["runConfig"],res);if(sanitized===null)return void 0;updates.runConfig=sanitized}return updates}__name(parseAgentUpdates,"parseAgentUpdates");function parseStringArray(value,field,res){if(value===void 0)return void 0;if(!Array.isArray(value)||value.some(v=>typeof v!=="string")){res.status(422).json({error:`\`${field}\` must be an array of strings when provided`,code:"invalid_config"});return null}if(value.length>MAX_TOOLS_ENTRIES){res.status(422).json({error:`\`${field}\` exceeds the ${MAX_TOOLS_ENTRIES}-entry limit`,code:"invalid_config"});return null}if(value.some(v=>v.length>MAX_TOOL_ID_LENGTH)){res.status(422).json({error:`\`${field}\` entries must be at most ${MAX_TOOL_ID_LENGTH} characters`,code:"invalid_config"});return null}return value}__name(parseStringArray,"parseStringArray");function sendInvalidConfig(res,error){res.status(422).json({error,code:"invalid_config"});return void 0}__name(sendInvalidConfig,"sendInvalidConfig");function parseMaxTurns(value,res){if(typeof value!=="number"||!Number.isFinite(value)||!Number.isInteger(value)||value<=0){sendInvalidConfig(res,"`maxTurns` must be a positive integer");return null}return value}__name(parseMaxTurns,"parseMaxTurns");function parseRecordField(value,field,isValidEntry,expected,res){if(typeof value!=="object"||value===null||Array.isArray(value)){sendInvalidConfig(res,`\`${field}\` must be ${expected}`);return null}const entries=Object.entries(value);if(entries.length>MAX_RECORD_ENTRIES){sendInvalidConfig(res,`\`${field}\` exceeds the ${MAX_RECORD_ENTRIES}-entry limit`);return null}const output={};for(const[key,entry]of entries){if(!key||key.length>MAX_TOOL_ID_LENGTH||key==="__proto__"||key==="constructor"||key==="prototype"||!isValidEntry(entry)){sendInvalidConfig(res,`\`${field}\` must be ${expected}`);return null}output[key]=entry}return output}__name(parseRecordField,"parseRecordField");function rejectIfPresentWrongType(body,key,expected,res){if(!(key in body))return false;if(typeof body[key]===expected)return false;res.status(422).json({error:`\`${key}\` must be a ${expected} when provided`,code:"invalid_config"});return true}__name(rejectIfPresentWrongType,"rejectIfPresentWrongType");function isNoOpUpdate(existing,updates){if(updates.description!==void 0&&updates.description!==existing.description){return false}if(updates.systemPrompt!==void 0&&updates.systemPrompt!==existing.systemPrompt){return false}if(updates.tools!==void 0&&!shallowArrayEqual(updates.tools,existing.tools)){return false}if(updates.disallowedTools!==void 0&&!shallowArrayEqual(updates.disallowedTools,existing.disallowedTools)){return false}if("model"in updates&&updates.model!==existing.model){return false}if("color"in updates&&updates.color!==existing.color){return false}if("approvalMode"in updates&&updates.approvalMode!==existing.approvalMode){return false}if("permissionMode"in updates&&updates.permissionMode!==existing.permissionMode){return false}if("maxTurns"in updates&&updates.maxTurns!==existing.maxTurns){return false}if(updates.mcpServers!==void 0&&!isDeepStrictEqual(normalizedRecord(updates.mcpServers),normalizedRecord(existing.mcpServers))){return false}if(updates.hooks!==void 0&&!isDeepStrictEqual(normalizedRecord(updates.hooks),normalizedRecord(existing.hooks))){return false}if(updates.background!==void 0&&updates.background!==existing.background){return false}if(updates.runConfig!==void 0){const e=existing.runConfig??{};const u=updates.runConfig;if("max_time_minutes"in u){if(u["max_time_minutes"]!==e["max_time_minutes"])return false}if("max_turns"in u){if(u["max_turns"]!==e["max_turns"])return false}}return true}__name(isNoOpUpdate,"isNoOpUpdate");function normalizedRecord(value){if(!value||Object.keys(value).length===0)return void 0;return normalizeRecordValue(value)}__name(normalizedRecord,"normalizedRecord");function normalizeRecordValue(value){if(Array.isArray(value))return value.map(normalizeRecordValue);if(typeof value!=="object"||value===null)return value;return Object.fromEntries(Object.entries(value).filter(([,entry])=>entry!==void 0).map(([key,entry])=>[key,normalizeRecordValue(entry)]))}__name(normalizeRecordValue,"normalizeRecordValue");function shallowArrayEqual(a,b){if(a===b)return true;if(!a||!b)return false;if(a.length!==b.length)return false;for(let i=0;i<a.length;i++)if(a[i]!==b[i])return false;return true}__name(shallowArrayEqual,"shallowArrayEqual");function sanitizeRunConfig(raw,res){if(typeof raw!=="object"||raw===null||Array.isArray(raw)){res.status(422).json({error:"`runConfig` must be an object when provided",code:"invalid_config"});return null}const input=raw;const out={};if("max_time_minutes"in input){const v=input["max_time_minutes"];if(typeof v!=="number"||!Number.isFinite(v)||v<=0){res.status(422).json({error:"`runConfig.max_time_minutes` must be a positive finite number when provided",code:"invalid_config"});return null}out["max_time_minutes"]=v}if("max_turns"in input){const v=input["max_turns"];if(typeof v!=="number"||!Number.isFinite(v)||v<=0||!Number.isInteger(v)){res.status(422).json({error:"`runConfig.max_turns` must be a positive integer when provided",code:"invalid_config"});return null}out["max_turns"]=v}return out}__name(sanitizeRunConfig,"sanitizeRunConfig");function toSummary(config){const summary={kind:"agent",name:config.name,description:config.description,level:config.level,isBuiltin:config.isBuiltin===true||config.level==="builtin",hasTools:Array.isArray(config.tools)&&config.tools.length>0};if(config.tools)summary.tools=[...config.tools];if(config.disallowedTools){summary.disallowedTools=[...config.disallowedTools]}if(config.model)summary.model=config.model;if(config.color)summary.color=config.color;if(config.background!==void 0)summary.background=config.background;if(config.approvalMode)summary.approvalMode=config.approvalMode;if(config.permissionMode)summary.permissionMode=config.permissionMode;if(config.maxTurns!==void 0)summary.maxTurns=config.maxTurns;if(config.mcpServers){summary.mcpServerNames=Object.keys(config.mcpServers)}if(config.hooks)summary.hookEvents=Object.keys(config.hooks);if(config.runConfig){const runConfig={};if(typeof config.runConfig.max_time_minutes==="number"){runConfig.max_time_minutes=config.runConfig.max_time_minutes}if(typeof config.runConfig.max_turns==="number"){runConfig.max_turns=config.runConfig.max_turns}summary.runConfig=runConfig}if(config.extensionName)summary.extensionName=config.extensionName;if(config.filePath)summary.filePath=config.filePath;return summary}__name(toSummary,"toSummary");function toDetail(config){const detail={...toSummary(config),systemPrompt:config.systemPrompt};if(config.mcpServers){detail.mcpServers=redactMcpServersSetting(config.mcpServers)}if(config.hooks)detail.hooks=config.hooks;return detail}__name(toDetail,"toDetail");function createDaemonSubagentManager(boundWorkspace,safeMode=false){const stub={getSdkMode:__name(()=>false,"getSdkMode"),getProjectRoot:__name(()=>boundWorkspace,"getProjectRoot"),getActiveExtensions:__name(()=>[],"getActiveExtensions"),isSafeMode:__name(()=>safeMode,"isSafeMode"),getAgentsSettings:__name(()=>({}),"getAgentsSettings")};const guarded=new Proxy(stub,{get(target,prop){if(prop in target){return target[prop]}if(prop==="then")return void 0;throw new Error(`qwen serve workspace agents: SubagentManager touched Config.${String(prop)} which the daemon stub does not implement. Add it to createDaemonSubagentManager and audit safety.`)},has(target,prop){if(prop in target)return true;if(prop==="then")return false;throw new Error(`qwen serve workspace agents: SubagentManager probed Config.${String(prop)} via 'in' check; the daemon stub does not implement it. Add it to createDaemonSubagentManager and audit safety.`)}});return new SubagentManager(guarded)}__name(createDaemonSubagentManager,"createDaemonSubagentManager");export{mountWorkspaceAgentsRoutes,mountWorkspaceQualifiedAgentsRoutes,toSummary,toDetail,createDaemonSubagentManager};
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2025 Qwen Team
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{extensionToOutputString,getExtensionManager}from"./chunk-
|
|
3
|
+
import{extensionToOutputString,getExtensionManager}from"./chunk-NZNRCPGE.js";import{loadSettings}from"./chunk-MVGQFFIK.js";import{initializeI18n,resolveLanguageSetting,t}from"./chunk-EZMTX4EU.js";import{getErrorMessage}from"./chunk-LPOEVTKD.js";import{writeStderrLine,writeStdoutLine}from"./chunk-SLPJ4OII.js";import{init_esbuild_shims}from"./chunk-VKDAXTCZ.js";import{__name}from"./chunk-KBWJGX7I.js";init_esbuild_shims();async function handleList(){try{const settings=loadSettings();await initializeI18n(resolveLanguageSetting(settings.merged.general?.language));const extensionManager=await getExtensionManager();const extensions=extensionManager.getLoadedExtensions();if(!extensions||extensions.length===0){writeStdoutLine(t("No extensions installed."));return}writeStdoutLine(extensions.map((extension,_)=>extensionToOutputString(extension,extensionManager,process.cwd())).join("\n\n"))}catch(error){writeStderrLine(getErrorMessage(error));process.exit(1)}}__name(handleList,"handleList");var listCommand={command:"list",describe:t("Lists installed extensions."),builder:__name(yargs=>yargs,"builder"),handler:__name(async()=>{await handleList()},"handler")};export{handleList,listCommand};
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2025 Google LLC
|