cx-viewer 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -20
- package/build.js +15 -0
- package/cli.js +102 -18
- package/concepts/ar/BodyDiffJSON.md +1 -1
- package/concepts/ar/BodyFields.md +30 -33
- package/concepts/ar/GlobalSettings.md +165 -167
- package/concepts/ar/MainAgent.md +3 -4
- package/concepts/ar/ProxySwitch.md +3 -3
- package/concepts/ar/QRCode.md +1 -1
- package/concepts/ar/ResponseFields.md +29 -41
- package/concepts/ar/SubAgent-Search.md +12 -12
- package/concepts/ar/Teammate.md +16 -16
- package/concepts/ar/ToolsFirst.md +42 -48
- package/concepts/ar/TranslateContextPollution.md +9 -9
- package/concepts/ar/UltraPlan.md +38 -38
- package/concepts/da/BodyDiffJSON.md +2 -2
- package/concepts/da/BodyFields.md +30 -33
- package/concepts/da/GlobalSettings.md +165 -167
- package/concepts/da/MainAgent.md +3 -4
- package/concepts/da/ProxySwitch.md +3 -3
- package/concepts/da/QRCode.md +1 -1
- package/concepts/da/ResponseFields.md +29 -41
- package/concepts/da/SubAgent-Search.md +11 -11
- package/concepts/da/Teammate.md +16 -16
- package/concepts/da/ToolsFirst.md +42 -48
- package/concepts/da/TranslateContextPollution.md +9 -9
- package/concepts/da/UltraPlan.md +38 -38
- package/concepts/de/BodyDiffJSON.md +2 -2
- package/concepts/de/BodyFields.md +30 -33
- package/concepts/de/GlobalSettings.md +165 -167
- package/concepts/de/MainAgent.md +3 -4
- package/concepts/de/ProxySwitch.md +3 -3
- package/concepts/de/QRCode.md +1 -1
- package/concepts/de/ResponseFields.md +29 -41
- package/concepts/de/SubAgent-Search.md +11 -11
- package/concepts/de/Teammate.md +15 -15
- package/concepts/de/ToolsFirst.md +41 -47
- package/concepts/de/TranslateContextPollution.md +9 -9
- package/concepts/de/UltraPlan.md +38 -38
- package/concepts/en/BodyDiffJSON.md +5 -5
- package/concepts/en/BodyFields.md +17 -20
- package/concepts/en/GlobalSettings.md +49 -51
- package/concepts/en/MainAgent.md +8 -8
- package/concepts/en/ProxySwitch.md +3 -3
- package/concepts/en/QRCode.md +6 -6
- package/concepts/en/ResponseFields.md +7 -19
- package/concepts/en/SubAgent-Search.md +2 -2
- package/concepts/en/Teammate.md +4 -4
- package/concepts/en/Tool-apply_patch.md +11 -0
- package/concepts/en/Tool-create_goal.md +8 -0
- package/concepts/en/Tool-exec.md +88 -0
- package/concepts/en/Tool-followup_task.md +10 -0
- package/concepts/en/Tool-get_goal.md +5 -0
- package/concepts/en/Tool-image_generation.md +5 -0
- package/concepts/en/Tool-interrupt_agent.md +9 -0
- package/concepts/en/Tool-list_agents.md +9 -0
- package/concepts/en/Tool-list_mcp_resource_templates.md +8 -0
- package/concepts/en/Tool-list_mcp_resources.md +8 -0
- package/concepts/en/Tool-read_mcp_resource.md +10 -0
- package/concepts/en/Tool-request_user_input.md +9 -0
- package/concepts/en/Tool-send_message.md +10 -0
- package/concepts/en/Tool-shell_command.md +12 -0
- package/concepts/en/Tool-spawn_agent.md +11 -0
- package/concepts/en/Tool-tool_search.md +12 -0
- package/concepts/en/Tool-update_goal.md +9 -0
- package/concepts/en/Tool-update_plan.md +9 -0
- package/concepts/en/Tool-view_image.md +10 -0
- package/concepts/en/Tool-wait.md +12 -0
- package/concepts/en/Tool-wait_agent.md +9 -0
- package/concepts/en/Tool-web_search.md +11 -0
- package/concepts/en/Tools.md +29 -58
- package/concepts/en/ToolsFirst.md +24 -30
- package/concepts/en/TranslateContextPollution.md +10 -38
- package/concepts/en/UltraPlan.md +7 -7
- package/concepts/es/BodyDiffJSON.md +1 -1
- package/concepts/es/BodyFields.md +35 -38
- package/concepts/es/GlobalSettings.md +165 -167
- package/concepts/es/MainAgent.md +3 -4
- package/concepts/es/ProxySwitch.md +3 -3
- package/concepts/es/QRCode.md +1 -1
- package/concepts/es/ResponseFields.md +28 -40
- package/concepts/es/SubAgent-Search.md +12 -12
- package/concepts/es/Teammate.md +17 -17
- package/concepts/es/ToolsFirst.md +41 -47
- package/concepts/es/TranslateContextPollution.md +9 -9
- package/concepts/es/UltraPlan.md +38 -38
- package/concepts/fr/BodyDiffJSON.md +2 -2
- package/concepts/fr/BodyFields.md +35 -38
- package/concepts/fr/GlobalSettings.md +165 -167
- package/concepts/fr/MainAgent.md +3 -4
- package/concepts/fr/ProxySwitch.md +3 -3
- package/concepts/fr/QRCode.md +1 -1
- package/concepts/fr/ResponseFields.md +25 -37
- package/concepts/fr/SubAgent-Search.md +12 -12
- package/concepts/fr/Teammate.md +16 -16
- package/concepts/fr/ToolsFirst.md +40 -46
- package/concepts/fr/TranslateContextPollution.md +9 -9
- package/concepts/fr/UltraPlan.md +38 -38
- package/concepts/it/BodyDiffJSON.md +2 -2
- package/concepts/it/BodyFields.md +35 -38
- package/concepts/it/GlobalSettings.md +165 -167
- package/concepts/it/MainAgent.md +3 -4
- package/concepts/it/ProxySwitch.md +3 -3
- package/concepts/it/QRCode.md +1 -1
- package/concepts/it/ResponseFields.md +28 -40
- package/concepts/it/SubAgent-Search.md +12 -12
- package/concepts/it/Teammate.md +17 -17
- package/concepts/it/ToolsFirst.md +41 -47
- package/concepts/it/TranslateContextPollution.md +9 -9
- package/concepts/it/UltraPlan.md +38 -38
- package/concepts/ja/BodyDiffJSON.md +1 -1
- package/concepts/ja/BodyFields.md +30 -33
- package/concepts/ja/GlobalSettings.md +165 -167
- package/concepts/ja/MainAgent.md +3 -4
- package/concepts/ja/ProxySwitch.md +3 -3
- package/concepts/ja/QRCode.md +1 -1
- package/concepts/ja/ResponseFields.md +29 -41
- package/concepts/ja/SubAgent-Search.md +12 -12
- package/concepts/ja/Teammate.md +17 -17
- package/concepts/ja/ToolsFirst.md +41 -47
- package/concepts/ja/TranslateContextPollution.md +9 -9
- package/concepts/ja/UltraPlan.md +38 -38
- package/concepts/ko/BodyDiffJSON.md +1 -1
- package/concepts/ko/BodyFields.md +30 -33
- package/concepts/ko/GlobalSettings.md +165 -167
- package/concepts/ko/MainAgent.md +3 -4
- package/concepts/ko/ProxySwitch.md +3 -3
- package/concepts/ko/QRCode.md +1 -1
- package/concepts/ko/ResponseFields.md +29 -41
- package/concepts/ko/SubAgent-Search.md +12 -12
- package/concepts/ko/Teammate.md +17 -17
- package/concepts/ko/ToolsFirst.md +41 -47
- package/concepts/ko/TranslateContextPollution.md +9 -9
- package/concepts/ko/UltraPlan.md +38 -38
- package/concepts/no/BodyDiffJSON.md +2 -2
- package/concepts/no/BodyFields.md +30 -33
- package/concepts/no/GlobalSettings.md +165 -167
- package/concepts/no/MainAgent.md +3 -4
- package/concepts/no/ProxySwitch.md +3 -3
- package/concepts/no/QRCode.md +1 -1
- package/concepts/no/ResponseFields.md +29 -41
- package/concepts/no/SubAgent-Search.md +12 -12
- package/concepts/no/Teammate.md +17 -17
- package/concepts/no/ToolsFirst.md +42 -48
- package/concepts/no/TranslateContextPollution.md +9 -9
- package/concepts/no/UltraPlan.md +38 -38
- package/concepts/pl/BodyDiffJSON.md +2 -2
- package/concepts/pl/BodyFields.md +30 -33
- package/concepts/pl/GlobalSettings.md +165 -167
- package/concepts/pl/MainAgent.md +3 -4
- package/concepts/pl/ProxySwitch.md +3 -3
- package/concepts/pl/QRCode.md +1 -1
- package/concepts/pl/ResponseFields.md +29 -41
- package/concepts/pl/SubAgent-Search.md +12 -12
- package/concepts/pl/Teammate.md +17 -17
- package/concepts/pl/ToolsFirst.md +42 -48
- package/concepts/pl/TranslateContextPollution.md +9 -9
- package/concepts/pl/UltraPlan.md +38 -38
- package/concepts/pt-BR/BodyDiffJSON.md +2 -2
- package/concepts/pt-BR/BodyFields.md +30 -33
- package/concepts/pt-BR/GlobalSettings.md +165 -167
- package/concepts/pt-BR/MainAgent.md +3 -4
- package/concepts/pt-BR/ProxySwitch.md +3 -3
- package/concepts/pt-BR/QRCode.md +1 -1
- package/concepts/pt-BR/ResponseFields.md +29 -41
- package/concepts/pt-BR/SubAgent-Search.md +12 -12
- package/concepts/pt-BR/Teammate.md +17 -17
- package/concepts/pt-BR/ToolsFirst.md +41 -47
- package/concepts/pt-BR/TranslateContextPollution.md +9 -9
- package/concepts/pt-BR/UltraPlan.md +38 -38
- package/concepts/ru/BodyDiffJSON.md +1 -1
- package/concepts/ru/BodyFields.md +30 -33
- package/concepts/ru/GlobalSettings.md +165 -167
- package/concepts/ru/MainAgent.md +3 -4
- package/concepts/ru/ProxySwitch.md +3 -3
- package/concepts/ru/QRCode.md +1 -1
- package/concepts/ru/ResponseFields.md +29 -41
- package/concepts/ru/SubAgent-Search.md +12 -12
- package/concepts/ru/Teammate.md +17 -17
- package/concepts/ru/ToolsFirst.md +41 -47
- package/concepts/ru/TranslateContextPollution.md +9 -9
- package/concepts/ru/UltraPlan.md +38 -38
- package/concepts/th/BodyDiffJSON.md +1 -1
- package/concepts/th/BodyFields.md +30 -33
- package/concepts/th/GlobalSettings.md +165 -167
- package/concepts/th/MainAgent.md +3 -4
- package/concepts/th/ProxySwitch.md +3 -3
- package/concepts/th/QRCode.md +1 -1
- package/concepts/th/ResponseFields.md +29 -41
- package/concepts/th/SubAgent-Search.md +12 -12
- package/concepts/th/Teammate.md +17 -17
- package/concepts/th/ToolsFirst.md +42 -48
- package/concepts/th/TranslateContextPollution.md +9 -9
- package/concepts/th/UltraPlan.md +38 -38
- package/concepts/tr/BodyDiffJSON.md +1 -1
- package/concepts/tr/BodyFields.md +30 -33
- package/concepts/tr/GlobalSettings.md +165 -167
- package/concepts/tr/MainAgent.md +3 -4
- package/concepts/tr/ProxySwitch.md +3 -3
- package/concepts/tr/QRCode.md +1 -1
- package/concepts/tr/ResponseFields.md +29 -41
- package/concepts/tr/SubAgent-Search.md +12 -12
- package/concepts/tr/Teammate.md +16 -16
- package/concepts/tr/ToolsFirst.md +42 -48
- package/concepts/tr/TranslateContextPollution.md +9 -9
- package/concepts/tr/UltraPlan.md +38 -38
- package/concepts/uk/BodyDiffJSON.md +1 -1
- package/concepts/uk/BodyFields.md +30 -33
- package/concepts/uk/GlobalSettings.md +165 -167
- package/concepts/uk/MainAgent.md +3 -4
- package/concepts/uk/ProxySwitch.md +3 -3
- package/concepts/uk/QRCode.md +1 -1
- package/concepts/uk/ResponseFields.md +29 -41
- package/concepts/uk/SubAgent-Search.md +12 -12
- package/concepts/uk/Teammate.md +17 -17
- package/concepts/uk/ToolsFirst.md +42 -48
- package/concepts/uk/TranslateContextPollution.md +9 -9
- package/concepts/uk/UltraPlan.md +38 -38
- package/concepts/zh/BodyDiffJSON.md +4 -4
- package/concepts/zh/BodyFields.md +17 -20
- package/concepts/zh/GlobalSettings.md +26 -28
- package/concepts/zh/MainAgent.md +6 -6
- package/concepts/zh/ProxySwitch.md +1 -1
- package/concepts/zh/ResponseFields.md +7 -18
- package/concepts/zh/SubAgent-Search.md +2 -2
- package/concepts/zh/Teammate.md +4 -4
- package/concepts/zh/Tool-apply_patch.md +11 -0
- package/concepts/zh/Tool-create_goal.md +8 -0
- package/concepts/zh/Tool-exec.md +88 -0
- package/concepts/zh/Tool-followup_task.md +10 -0
- package/concepts/zh/Tool-get_goal.md +5 -0
- package/concepts/zh/Tool-image_generation.md +5 -0
- package/concepts/zh/Tool-interrupt_agent.md +9 -0
- package/concepts/zh/Tool-list_agents.md +9 -0
- package/concepts/zh/Tool-list_mcp_resource_templates.md +8 -0
- package/concepts/zh/Tool-list_mcp_resources.md +8 -0
- package/concepts/zh/Tool-read_mcp_resource.md +10 -0
- package/concepts/zh/Tool-request_user_input.md +9 -0
- package/concepts/zh/Tool-send_message.md +10 -0
- package/concepts/zh/Tool-shell_command.md +12 -0
- package/concepts/zh/Tool-spawn_agent.md +11 -0
- package/concepts/zh/Tool-tool_search.md +12 -0
- package/concepts/zh/Tool-update_goal.md +9 -0
- package/concepts/zh/Tool-update_plan.md +9 -0
- package/concepts/zh/Tool-view_image.md +10 -0
- package/concepts/zh/Tool-wait.md +12 -0
- package/concepts/zh/Tool-wait_agent.md +9 -0
- package/concepts/zh/Tool-web_search.md +11 -0
- package/concepts/zh/Tools.md +29 -58
- package/concepts/zh/ToolsFirst.md +21 -27
- package/concepts/zh/TranslateContextPollution.md +10 -38
- package/concepts/zh/UltraPlan.md +7 -7
- package/concepts/zh-TW/BodyFields.md +27 -30
- package/concepts/zh-TW/GlobalSettings.md +26 -28
- package/concepts/zh-TW/MainAgent.md +0 -1
- package/concepts/zh-TW/ProxySwitch.md +22 -22
- package/concepts/zh-TW/ResponseFields.md +29 -40
- package/concepts/zh-TW/SubAgent-Search.md +12 -12
- package/concepts/zh-TW/Teammate.md +16 -16
- package/concepts/zh-TW/ToolsFirst.md +41 -47
- package/concepts/zh-TW/UltraPlan.md +38 -38
- package/dist/assets/App-BZ9oclBj.js +2 -0
- package/dist/assets/App-rWON7PuS.css +1 -0
- package/dist/assets/MdxEditorPanel-B4lZ7Z_A.js +1 -0
- package/dist/assets/MdxEditorPanel-Da_ceLFo.css +1 -0
- package/dist/assets/Mobile-B5V_-6Hc.css +1 -0
- package/dist/assets/Mobile-C7Hy-TIM.js +1 -0
- package/dist/assets/abnfDiagram-VRR7QNED-DYYppIQV.js +1 -0
- package/dist/assets/apl-B8ZmNFqK.js +1 -0
- package/dist/assets/arc-BT3um7r4.js +1 -0
- package/dist/assets/architectureDiagram-ZJ3FMSHR-uweBqnh-.js +1 -0
- package/dist/assets/asciiarmor-CIte6N-S.js +1 -0
- package/dist/assets/asn1-Ax1-z1nk.js +1 -0
- package/dist/assets/asterisk-CLHf-iRz.js +1 -0
- package/dist/assets/blockDiagram-677ZJIJ3-DzeI4GyV.js +1 -0
- package/dist/assets/brainfuck-CdLnmYpe.js +1 -0
- package/dist/assets/c4Diagram-LMCZKHZV-DBI0K7wS.js +1 -0
- package/dist/assets/channel-BrN6yx0e.js +1 -0
- package/dist/assets/chunk-2Q5K7J3B-DK9JA8Ct.js +1 -0
- package/dist/assets/chunk-32BRIVSS-VNg3Ylzs.js +1 -0
- package/dist/assets/chunk-5VM5RSS4-DFhufY9o.js +1 -0
- package/dist/assets/chunk-EX3LRPZG-B93MHNBT.js +1 -0
- package/dist/assets/chunk-JWPE2WC7-C54OW1iN.js +1 -0
- package/dist/assets/chunk-MOJQB5TN-lKhWWIDe.js +1 -0
- package/dist/assets/chunk-RYQCIY6F-BK2jDXwB.js +1 -0
- package/dist/assets/chunk-V7JOEXUC-aLHBmfOc.js +1 -0
- package/dist/assets/chunk-VR4S4FIN-Bomuor1h.js +1 -0
- package/dist/assets/chunk-XXDRQBXY-BPj05P7g.js +1 -0
- package/dist/assets/classDiagram-OUVF2IWQ-COm0X4uJ.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-COm0X4uJ.js +1 -0
- package/dist/assets/clike-BDgEuk0n.js +1 -0
- package/dist/assets/clojure-CrPxgQZl.js +1 -0
- package/dist/assets/cmake-BknZiLBu.js +1 -0
- package/dist/assets/cobol-DN1mHbgw.js +1 -0
- package/dist/assets/coffeescript-DTAwRC7M.js +1 -0
- package/dist/assets/commonlisp-B4DJ--Bo.js +1 -0
- package/dist/assets/cose-bilkent-JH36ORCC-DU44QHSb.js +1 -0
- package/dist/assets/crystal-DoipYOOv.js +1 -0
- package/dist/assets/css-BeQRP3p5.js +1 -0
- package/dist/assets/cynefin-VYW2F7L2-C0dowxsF.js +15 -0
- package/dist/assets/cynefinDiagram-TSTJHNR4-C6vNWPUV.js +1 -0
- package/dist/assets/cypher-BzELKutH.js +1 -0
- package/dist/assets/cytoscape.esm-D0POlJZ1.js +9 -0
- package/dist/assets/d-Mh2Rawoc.js +1 -0
- package/dist/assets/dagre-VKFMJZFB-aLG4uEb-.js +1 -0
- package/dist/assets/defaultLocale-DZ7E7S9R.js +1 -0
- package/dist/assets/diagram-FQU43EPY-D5C8GfdU.js +1 -0
- package/dist/assets/diagram-G47NLZAW-C9tRw_xi.js +1 -0
- package/dist/assets/diagram-NH7WQ7WH-AYxTxwJ2.js +1 -0
- package/dist/assets/diagram-OA4YK3LP-BuBE5n9n.js +1 -0
- package/dist/assets/diagram-WEI45ONY-Cda7zYeO.js +1 -0
- package/dist/assets/diff-B1OtBbfz.js +1 -0
- package/dist/assets/dockerfile-Du7niAGi.js +1 -0
- package/dist/assets/dtd-So5hjSa8.js +1 -0
- package/dist/assets/dylan-Co15g-RX.js +1 -0
- package/dist/assets/ebnf-DWrAnno4.js +1 -0
- package/dist/assets/ebnfDiagram-CCIWWBDH-DC_OGyoh.js +1 -0
- package/dist/assets/ecl-8tbf0rUT.js +1 -0
- package/dist/assets/eiffel-BXtlUtEg.js +1 -0
- package/dist/assets/elm-BwiUluiH.js +1 -0
- package/dist/assets/erDiagram-Q63AITRT-D2G21PVY.js +1 -0
- package/dist/assets/erlang-CrHBLi-m.js +1 -0
- package/dist/assets/factor-C7nC06Ta.js +1 -0
- package/dist/assets/fcl-DKWfryFT.js +1 -0
- package/dist/assets/flowDiagram-23GEKE2U-CEQPYHrk.js +1 -0
- package/dist/assets/forth-Cg8ASoTj.js +1 -0
- package/dist/assets/fortran-BHf_qfFx.js +1 -0
- package/dist/assets/ganttDiagram-NO4QXBWP-JStxUtFR.js +1 -0
- package/dist/assets/gas-cj_2N_z1.js +1 -0
- package/dist/assets/gherkin-BiuTaH40.js +1 -0
- package/dist/assets/gitGraphDiagram-IHSO6WYX-BiojPH-V.js +1 -0
- package/dist/assets/graph-CnJdn47S.js +1 -0
- package/dist/assets/groovy-Bq8cXYUU.js +1 -0
- package/dist/assets/haskell-1ANuaeie.js +1 -0
- package/dist/assets/haxe-BUNSvWf_.js +1 -0
- package/dist/assets/html2canvas.esm-HFdlUwfn.js +20 -0
- package/dist/assets/http-DPC2IRQA.js +1 -0
- package/dist/assets/idl-DDbIciu_.js +1 -0
- package/dist/assets/index-BEyKG3O5.css +1 -0
- package/dist/assets/index-BduJoLQ5.js +1 -0
- package/dist/assets/index-BqwR8F0v.js +1 -0
- package/dist/assets/index-BsycQyrv.js +1 -0
- package/dist/assets/index-CFSDxZyA.js +1 -0
- package/dist/assets/index-CunNLTHc.js +1 -0
- package/dist/assets/index-OGkDFNTK.js +1 -0
- package/dist/assets/index-oxOyrL07.js +2 -0
- package/dist/assets/index-wvaycTGT.js +1 -0
- package/dist/assets/infoDiagram-FWYZ7A6U-Csl_aBIC.js +1 -0
- package/dist/assets/init-DMZMl1PR.js +1 -0
- package/dist/assets/ishikawaDiagram-FXEZZL3T-CjgGuMwr.js +1 -0
- package/dist/assets/javascript-Cet1BUca.js +1 -0
- package/dist/assets/journeyDiagram-5HDEW3XC-DUOy1PCq.js +1 -0
- package/dist/assets/jszip.min-BxIXdRg4.js +12 -0
- package/dist/assets/julia-CdxLCr68.js +1 -0
- package/dist/assets/kanban-definition-HUTT4EX6-Cx7GSrSj.js +1 -0
- package/dist/assets/katex-CfXf84Fz.js +1 -0
- package/dist/assets/layout-CCUE9ZRw.js +1 -0
- package/dist/assets/linear-GeBi6jJp.js +1 -0
- package/dist/assets/livescript-Bw1Vw7Ae.js +1 -0
- package/dist/assets/lua-DM1wbcnc.js +1 -0
- package/dist/assets/map-DQeg2hXV.js +1 -0
- package/dist/assets/mathematica-BXSv1_O1.js +1 -0
- package/dist/assets/mbox-CWY0keg3.js +1 -0
- package/dist/assets/mermaid.core-Cy9iVxov.js +7 -0
- package/dist/assets/mindmap-definition-LN4V7U3C-CUVxVkK5.js +1 -0
- package/dist/assets/mirc-CMLrLVMT.js +1 -0
- package/dist/assets/mllike-naqhAFf1.js +1 -0
- package/dist/assets/modelica-BvadsaHY.js +1 -0
- package/dist/assets/mscgen-DOr-Q10p.js +1 -0
- package/dist/assets/mumps-DKTl5Nyj.js +1 -0
- package/dist/assets/nginx-DWR90-d1.js +1 -0
- package/dist/assets/nsis-ooFGduGn.js +1 -0
- package/dist/assets/ntriples-q5jkU4X1.js +1 -0
- package/dist/assets/octave-Deu9Ci7_.js +1 -0
- package/dist/assets/orbiting-BCD4Vuij.svg +7 -0
- package/dist/assets/ordinal-DA-_8pMy.js +1 -0
- package/dist/assets/oz-cTQm1aoB.js +1 -0
- package/dist/assets/pascal-Oh3VmczP.js +1 -0
- package/dist/assets/pegDiagram-2B236MQR-BCF1byLY.js +1 -0
- package/dist/assets/perl-BddWF1HQ.js +1 -0
- package/dist/assets/pieDiagram-ENE6RG2P-D2cZTo8-.js +1 -0
- package/dist/assets/pig-g5ZQNIDr.js +1 -0
- package/dist/assets/powershell-CNmQNFVJ.js +1 -0
- package/dist/assets/properties-B41DXfv6.js +1 -0
- package/dist/assets/protobuf-eEBl31OJ.js +1 -0
- package/dist/assets/pug-DRSo4eCK.js +1 -0
- package/dist/assets/puppet-ClfRubAD.js +1 -0
- package/dist/assets/python-BSflc812.js +1 -0
- package/dist/assets/q-BBDx3N9Y.js +1 -0
- package/dist/assets/quadrantDiagram-ABIIQ3AL-Bwsn2--F.js +1 -0
- package/dist/assets/r-CByC1eO8.js +1 -0
- package/dist/assets/railroadDiagram-RFXS5EU6-CLGLpWHs.js +1 -0
- package/dist/assets/requirementDiagram-TGXJPOKE-BfmBYwZl.js +1 -0
- package/dist/assets/rpm-8t935XkD.js +1 -0
- package/dist/assets/ruby-CAgbkLZh.js +1 -0
- package/dist/assets/sankeyDiagram-HTMAVEWB-CqZhbyFn.js +1 -0
- package/dist/assets/sas-C-JWcRvo.js +1 -0
- package/dist/assets/scheme-D7o9RjUX.js +1 -0
- package/dist/assets/seqResourceLoaders-Bkh2Rb9i.js +2 -0
- package/dist/assets/seqResourceLoaders-Do7Kqg3B.css +41 -0
- package/dist/assets/sequenceDiagram-DBY2YBRQ-CcOdXkN2.js +1 -0
- package/dist/assets/shell-BXA79DV6.js +1 -0
- package/dist/assets/shimmer-BBDejmDf.svg +7 -0
- package/dist/assets/sieve-DNwyl0rd.js +1 -0
- package/dist/assets/simple-mode-CoQRusFX.js +1 -0
- package/dist/assets/sizeCapture-X5ZJPWSS-B4OVmPqu.js +1 -0
- package/dist/assets/smalltalk-DggktV6S.js +1 -0
- package/dist/assets/solr-D7NRuIPM.js +1 -0
- package/dist/assets/sparql-Cr71deJQ.js +1 -0
- package/dist/assets/spreadsheet-BMD3tYqw.js +1 -0
- package/dist/assets/sql-CbOjXfBR.js +1 -0
- package/dist/assets/stateDiagram-2N3HPSRC-Dysun0oO.js +1 -0
- package/dist/assets/stateDiagram-v2-6OUMAXLB-BFet8xAz.js +1 -0
- package/dist/assets/stex-iDPIkRmr.js +1 -0
- package/dist/assets/stylus-nWZizI-c.js +1 -0
- package/dist/assets/swift-DOhLK5SG.js +1 -0
- package/dist/assets/swimlanes-5IMT3BWC-_30OXwXy.js +2 -0
- package/dist/assets/swimlanesDiagram-G3AALYLV-C19viY0G.js +1 -0
- package/dist/assets/tcl-CQhJd1WY.js +1 -0
- package/dist/assets/textile-D9XqfVtL.js +1 -0
- package/dist/assets/tiddlywiki-DfOYgVky.js +1 -0
- package/dist/assets/tiki-a0_YLWvV.js +1 -0
- package/dist/assets/timeline-definition-FHXFAJF6-X1Xk3onD.js +1 -0
- package/dist/assets/toml-ekl3F1YB.js +1 -0
- package/dist/assets/troff-Bh_pcXF1.js +1 -0
- package/dist/assets/ttcn-M6363IRW.js +1 -0
- package/dist/assets/ttcn-cfg-7I2DgJEN.js +1 -0
- package/dist/assets/turtle-B5jdxH6D.js +1 -0
- package/dist/assets/vb-DM-xPmVv.js +1 -0
- package/dist/assets/vbscript-B0qu41Yc.js +1 -0
- package/dist/assets/velocity-FCgsuVHf.js +1 -0
- package/dist/assets/vendor-antd-Bzi1WuBb.js +17 -0
- package/dist/assets/vendor-codemirror-CKTrJd47.js +1 -0
- package/dist/assets/vendor-highlight-IFTJ9nxW.js +1 -0
- package/dist/assets/vendor-markdown-BN3QLsBu.js +3 -0
- package/dist/assets/vendor-mdxeditor-4PbKH6K7.js +2 -0
- package/dist/assets/vendor-qrcode-Bnjm0rcu.js +6 -0
- package/dist/assets/vendor-react-l0sNRNKZ.js +1 -0
- package/dist/assets/vendor-virtuoso-2P4SowHC.js +1 -0
- package/dist/assets/vendor-xterm-DckPrCx1.js +37 -0
- package/dist/assets/vennDiagram-L72KCM5P-D3fQnGq7.js +1 -0
- package/dist/assets/verilog-nrfFvR12.js +1 -0
- package/dist/assets/vhdl-WlDXtV-W.js +1 -0
- package/dist/assets/wardleyDiagram-EHGQE667-CRhqI6-g.js +1 -0
- package/dist/assets/webidl-RIQoSXDx.js +1 -0
- package/dist/assets/xquery-BN45G3lJ.js +1 -0
- package/dist/assets/xychartDiagram-FW5EYKEG-Cmtgmmtg.js +1 -0
- package/dist/assets/yacas-U6gaIVhD.js +1 -0
- package/dist/assets/z80-CFe5BHbK.js +1 -0
- package/dist/index.html +25 -6
- package/dist/voice-packs/default/A_choice_for_your_consideration_sir.MP3 +0 -0
- package/dist/voice-packs/default/It_is_done_sir.MP3 +0 -0
- package/dist/voice-packs/default/The_plan_awaits_your_approval_sir.MP3 +0 -0
- package/dist/voice-packs/default/pack.json +24 -0
- package/dist/voice-packs/sanguo/ask.MP3 +0 -0
- package/dist/voice-packs/sanguo/end.MP3 +0 -0
- package/dist/voice-packs/sanguo/pack.json +24 -0
- package/dist/voice-packs/sanguo/plan.MP3 +0 -0
- package/electron/diag.js +110 -0
- package/electron/main.js +1432 -0
- package/electron/menu-model.js +107 -0
- package/electron/tab-bar.html +575 -0
- package/electron/tab-content-preload.js +66 -0
- package/electron/tab-preload.js +24 -0
- package/electron/tab-worker.js +142 -0
- package/electron/window-state.js +60 -0
- package/electron/workspace-preload.js +19 -0
- package/findcx.js +4 -0
- package/i18n.js +3 -423
- package/index.html +30 -0
- package/interceptor.js +144 -70
- package/jsconfig.json +25 -0
- package/lib/approval-reviewer.js +23 -0
- package/lib/appserver-bridge.js +1753 -237
- package/lib/ask-bridge.js +5 -5
- package/lib/cli-args.js +1 -0
- package/lib/codex-config.js +157 -18
- package/lib/context-watcher.js +6 -65
- package/lib/delta-reconstructor.js +74 -52
- package/lib/ensure-hooks.js +37 -30
- package/lib/interceptor-core.js +490 -43
- package/lib/log-watcher.js +3 -8
- package/lib/main-agent-entry.js +68 -0
- package/lib/openai-body.js +95 -0
- package/lib/otel-adapter.js +3 -2
- package/lib/otel-receiver.js +1 -2
- package/lib/perm-bridge.js +84 -44
- package/lib/proxy-env.js +45 -1
- package/lib/sdk-adapter.js +241 -51
- package/lib/sdk-manager.js +523 -370
- package/lib/skills-api.js +364 -0
- package/lib/stats-worker.js +21 -21
- package/lib/token-usage.js +29 -0
- package/lib/updater.js +3 -7
- package/package.json +27 -6
- package/plugins/.gitkeep +0 -0
- package/plugins/README.md +8 -0
- package/proxy.js +187 -241
- package/pty-manager.js +17 -1
- package/public/favicon.ico +0 -0
- package/public/voice-packs/default/A_choice_for_your_consideration_sir.MP3 +0 -0
- package/public/voice-packs/default/It_is_done_sir.MP3 +0 -0
- package/public/voice-packs/default/The_plan_awaits_your_approval_sir.MP3 +0 -0
- package/public/voice-packs/default/pack.json +24 -0
- package/public/voice-packs/sanguo/ask.MP3 +0 -0
- package/public/voice-packs/sanguo/end.MP3 +0 -0
- package/public/voice-packs/sanguo/pack.json +24 -0
- package/public/voice-packs/sanguo/plan.MP3 +0 -0
- package/scripts/check-no-control-bytes.js +130 -0
- package/scripts/check-sign-config.sh +85 -0
- package/scripts/gen-default-voicepack.js +176 -0
- package/scripts/mac-sign.sh +47 -0
- package/scripts/npm-pack-dry-run.mjs +20 -0
- package/server/lib/approval-modal-prefs.js +72 -0
- package/server/lib/context-rules.js +70 -0
- package/server/lib/delta-reconstructor.js +403 -0
- package/server/lib/tools-xml-formatter.js +91 -0
- package/server/lib/voice-pack-events.js +79 -0
- package/server.js +420 -86
- package/src/App.jsx +638 -0
- package/src/App.module.css +1088 -0
- package/src/AppBase.jsx +2803 -0
- package/src/Mobile.jsx +1348 -0
- package/src/components/approval/ApprovalModal.jsx +319 -0
- package/src/components/approval/ApprovalModal.module.css +160 -0
- package/src/components/approval/ToolApprovalPanel.jsx +111 -0
- package/src/components/approval/ToolApprovalPanel.module.css +250 -0
- package/src/components/chat/ApprovalPortalContext.js +26 -0
- package/src/components/chat/AskQuestionForm.jsx +279 -0
- package/src/components/chat/AskTimeoutCountdown.jsx +113 -0
- package/src/components/chat/ChatInputBar.jsx +584 -0
- package/src/components/chat/ChatInputBar.module.css +656 -0
- package/src/components/chat/ChatMessage.jsx +1587 -0
- package/src/components/chat/ChatMessage.module.css +1560 -0
- package/src/components/chat/ChatView.jsx +3533 -0
- package/src/components/chat/ChatView.module.css +418 -0
- package/src/components/chat/DiffView.jsx +111 -0
- package/src/components/chat/DiffView.module.css +141 -0
- package/src/components/chat/RoleFilterBar.jsx +35 -0
- package/src/components/chat/RoleFilterBar.module.css +62 -0
- package/src/components/chat/controllers/askFlowController.js +789 -0
- package/src/components/chat/controllers/permissionController.js +84 -0
- package/src/components/chat/controllers/ptyPromptController.js +166 -0
- package/src/components/chat/controllers/scrollHighlightController.js +50 -0
- package/src/components/chat/controllers/splitDragController.js +135 -0
- package/src/components/chat/controllers/toolFileChangeController.js +216 -0
- package/src/components/chat/interactionOwnership.js +106 -0
- package/src/components/chat/uploadDeferLogic.js +46 -0
- package/src/components/common/ConceptHelp.jsx +97 -0
- package/src/components/common/ConceptHelp.module.css +151 -0
- package/src/components/common/ConfirmRemoveButton.jsx +78 -0
- package/src/components/common/CountryFlag.jsx +105 -0
- package/src/components/common/CountryFlag.module.css +36 -0
- package/src/components/common/DingTalkIcon.jsx +20 -0
- package/src/components/common/DiscordIcon.jsx +21 -0
- package/src/components/common/FeishuIcon.jsx +23 -0
- package/src/components/common/HoverPreviewTip.jsx +62 -0
- package/src/components/common/HoverPreviewTip.module.css +21 -0
- package/src/components/common/ImageLightbox.jsx +244 -0
- package/src/components/common/ImageLightbox.module.css +120 -0
- package/src/components/common/MemoryDetailModal.jsx +75 -0
- package/src/components/common/OpenFolderIcon.jsx +53 -0
- package/src/components/common/OpenFolderIcon.module.css +7 -0
- package/src/components/common/PanelResizer.jsx +48 -0
- package/src/components/common/PanelResizer.module.css +11 -0
- package/src/components/common/QuickAutoApproveRows.jsx +66 -0
- package/src/components/common/RefreshIcon.jsx +50 -0
- package/src/components/common/RefreshIcon.module.css +26 -0
- package/src/components/common/SnapLineOverlay.jsx +47 -0
- package/src/components/common/SnapLineOverlay.module.css +31 -0
- package/src/components/common/ToolsHelp.jsx +113 -0
- package/src/components/common/ToolsHelp.module.css +85 -0
- package/src/components/common/WeComIcon.jsx +22 -0
- package/src/components/common/quickMenuIcons.jsx +99 -0
- package/src/components/common/sharedChrome.module.css +274 -0
- package/src/components/dashboard/AppHeader.jsx +2085 -0
- package/src/components/dashboard/AppHeader.module.css +676 -0
- package/src/components/dashboard/CachePopoverContent.jsx +538 -0
- package/src/components/dashboard/CachePopoverContent.module.css +191 -0
- package/src/components/dashboard/ContextTab.jsx +769 -0
- package/src/components/dashboard/ContextTab.module.css +565 -0
- package/src/components/dashboard/DetailPanel.jsx +813 -0
- package/src/components/dashboard/DetailPanel.module.css +513 -0
- package/src/components/dashboard/LiveTagPopover.jsx +89 -0
- package/src/components/dashboard/LiveTagPopover.module.css +67 -0
- package/src/components/dashboard/RequestList.jsx +146 -0
- package/src/components/dashboard/RequestList.module.css +146 -0
- package/src/components/dashboard/TeamSessionPanel.jsx +584 -0
- package/src/components/dashboard/TeamSessionPanel.module.css +457 -0
- package/src/components/dashboard/UsageWindowPill.jsx +166 -0
- package/src/components/dashboard/UsageWindowPill.module.css +140 -0
- package/src/components/dashboard/WorkflowRunsPanel.jsx +108 -0
- package/src/components/dashboard/WorkflowRunsPanel.module.css +72 -0
- package/src/components/dashboard/WorkspaceList.jsx +410 -0
- package/src/components/dashboard/WorkspaceList.module.css +254 -0
- package/src/components/files/FileContentView.jsx +1013 -0
- package/src/components/files/FileContentView.module.css +418 -0
- package/src/components/files/FileExplorer.jsx +937 -0
- package/src/components/files/FileExplorer.module.css +173 -0
- package/src/components/files/MdxEditorPanel.base.css +9 -0
- package/src/components/files/MdxEditorPanel.jsx +181 -0
- package/src/components/files/MdxEditorPanel.module.css +917 -0
- package/src/components/git/DiffMiniMap.jsx +98 -0
- package/src/components/git/DiffMiniMap.module.css +17 -0
- package/src/components/git/FullFileDiffView.jsx +265 -0
- package/src/components/git/FullFileDiffView.module.css +176 -0
- package/src/components/git/GitChanges.jsx +461 -0
- package/src/components/git/GitChanges.module.css +337 -0
- package/src/components/git/GitDiffView.jsx +161 -0
- package/src/components/git/GitDiffView.module.css +205 -0
- package/src/components/mobile/MobileDrawerCloseButton.jsx +18 -0
- package/src/components/mobile/MobileFileExplorer.jsx +231 -0
- package/src/components/mobile/MobileFileExplorer.module.css +171 -0
- package/src/components/mobile/MobileGitDiff.jsx +293 -0
- package/src/components/mobile/MobileGitDiff.module.css +317 -0
- package/src/components/mobile/MobileStats.jsx +211 -0
- package/src/components/mobile/MobileStats.module.css +75 -0
- package/src/components/settings/ImAppendSystemModal.jsx +104 -0
- package/src/components/settings/ImConversationModal.jsx +328 -0
- package/src/components/settings/ImConversationModal.module.css +49 -0
- package/src/components/settings/ImPlatformSettings.jsx +453 -0
- package/src/components/settings/ImPlatformSettings.module.css +110 -0
- package/src/components/settings/ImSkillsModal.jsx +94 -0
- package/src/components/settings/ImStatusChip.jsx +80 -0
- package/src/components/settings/ImStatusChip.module.css +36 -0
- package/src/components/settings/MessagingModal.jsx +65 -0
- package/src/components/settings/MessagingModal.module.css +95 -0
- package/src/components/settings/ModelPromptTabs.jsx +118 -0
- package/src/components/settings/PluginModal.jsx +423 -0
- package/src/components/settings/PluginModal.module.css +136 -0
- package/src/components/settings/PreferencesForm.jsx +104 -0
- package/src/components/settings/PreferencesForm.module.css +27 -0
- package/src/components/settings/ProcessModal.jsx +175 -0
- package/src/components/settings/ProcessModal.module.css +21 -0
- package/src/components/settings/ProjectAliasEditor.jsx +138 -0
- package/src/components/settings/ProjectAliasEditor.module.css +87 -0
- package/src/components/settings/ProjectPrefsManagerModal.jsx +123 -0
- package/src/components/settings/ProjectPrefsManagerModal.module.css +52 -0
- package/src/components/settings/ProxyModal.jsx +286 -0
- package/src/components/settings/ProxyModal.module.css +141 -0
- package/src/components/settings/SkillsManagerModal.jsx +143 -0
- package/src/components/settings/SkillsManagerModal.module.css +143 -0
- package/src/components/settings/SystemTextModal.jsx +312 -0
- package/src/components/settings/SystemTextModal.module.css +331 -0
- package/src/components/settings/VoicePackSettings.jsx +319 -0
- package/src/components/settings/VoicePackSettings.module.css +151 -0
- package/src/components/settings/imPlatforms.js +177 -0
- package/src/components/terminal/CustomUltraplanEditModal.jsx +227 -0
- package/src/components/terminal/CustomUltraplanEditModal.module.css +189 -0
- package/src/components/terminal/PresetExpertPickerModal.jsx +116 -0
- package/src/components/terminal/PresetExpertPickerModal.module.css +90 -0
- package/src/components/terminal/PresetModal.jsx +118 -0
- package/src/components/terminal/ScratchTerminal.jsx +359 -0
- package/src/components/terminal/TerminalPanel.jsx +2021 -0
- package/src/components/terminal/TerminalPanel.module.css +872 -0
- package/src/components/terminal/TerminalWsContext.jsx +226 -0
- package/src/components/terminal/UltraPlanModal.jsx +328 -0
- package/src/components/terminal/UltraPlanModal.module.css +527 -0
- package/src/components/terminal/UltraplanExpertManagerModal.jsx +114 -0
- package/src/components/terminal/UltraplanExpertManagerModal.module.css +91 -0
- package/src/components/terminal/UltraplanPanel.jsx +307 -0
- package/src/components/terminal/UltraplanPanel.module.css +540 -0
- package/src/components/terminal/terminalThemes.js +33 -0
- package/src/components/viewers/ImageViewer.jsx +288 -0
- package/src/components/viewers/ImageViewer.module.css +203 -0
- package/src/components/viewers/JsonViewer.jsx +40 -0
- package/src/components/viewers/JsonViewer.module.css +9 -0
- package/src/components/viewers/LogTable.jsx +131 -0
- package/src/components/viewers/MarkdownBlock.jsx +112 -0
- package/src/components/viewers/MarkdownBlock.module.css +157 -0
- package/src/components/viewers/ToolResultView.jsx +389 -0
- package/src/components/viewers/ToolResultView.module.css +108 -0
- package/src/components/viewers/WebResultsView.jsx +74 -0
- package/src/components/viewers/WebResultsView.module.css +85 -0
- package/src/components/viewers/WorkflowLiveHud.jsx +153 -0
- package/src/components/viewers/WorkflowLiveHud.module.css +256 -0
- package/src/components/viewers/WorkflowPanel.jsx +243 -0
- package/src/components/viewers/WorkflowPanel.module.css +265 -0
- package/src/components/viewers/WorkflowTimeline.jsx +83 -0
- package/src/components/viewers/WorkflowTimeline.module.css +116 -0
- package/src/contexts/SettingsContext.jsx +140 -0
- package/src/env.js +54 -0
- package/src/global.css +607 -0
- package/src/hooks/useMarkdownExport.js +146 -0
- package/src/hooks/useMermaidRender.js +193 -0
- package/src/hooks/useProjectAlias.js +29 -0
- package/src/hooks/useSessionStoragePersistedSet.js +41 -0
- package/src/i18n/mdxTranslations.js +472 -0
- package/src/i18n.js +12409 -0
- package/src/img/ccv-logo.png +0 -0
- package/src/img/codex/entrance.svg +7 -0
- package/src/img/codex/exit.svg +7 -0
- package/src/img/codex/orbiting.svg +7 -0
- package/src/img/codex/shimmer.svg +7 -0
- package/src/img/codex/thinking.svg +7 -0
- package/src/img/codex/tickle.svg +7 -0
- package/src/img/codex/waiting.svg +7 -0
- package/src/img/codex/writing.svg +7 -0
- package/src/img/default-avatar.svg +1 -0
- package/src/img/default-model-avatar.svg +1 -0
- package/src/img/loading-pet.gif +0 -0
- package/src/img/model-codex.svg +2 -0
- package/src/img/model-deepseek.svg +2 -0
- package/src/img/model-gemini.svg +2 -0
- package/src/img/model-glm.svg +2 -0
- package/src/img/model-kimi.svg +2 -0
- package/src/img/model-minimax.svg +2 -0
- package/src/img/model-openai.svg +2 -0
- package/src/img/model-qwen.svg +2 -0
- package/src/img/teammates/DESIGN.md +165 -0
- package/src/img/teammates/analyst.svg +32 -0
- package/src/img/teammates/auditor.svg +28 -0
- package/src/img/teammates/builder.svg +33 -0
- package/src/img/teammates/default.svg +25 -0
- package/src/img/teammates/designer.svg +25 -0
- package/src/img/teammates/executor.svg +31 -0
- package/src/img/teammates/expert.svg +30 -0
- package/src/img/teammates/explorer.svg +30 -0
- package/src/img/teammates/implementer.svg +34 -0
- package/src/img/teammates/investigator.svg +29 -0
- package/src/img/teammates/marvel/analyst.svg +26 -0
- package/src/img/teammates/marvel/auditor.svg +28 -0
- package/src/img/teammates/marvel/builder.svg +15 -0
- package/src/img/teammates/marvel/default.svg +25 -0
- package/src/img/teammates/marvel/designer.svg +21 -0
- package/src/img/teammates/marvel/executor.svg +25 -0
- package/src/img/teammates/marvel/expert.svg +31 -0
- package/src/img/teammates/marvel/explorer.svg +22 -0
- package/src/img/teammates/marvel/implementer.svg +30 -0
- package/src/img/teammates/marvel/investigator.svg +21 -0
- package/src/img/teammates/marvel/researcher.svg +30 -0
- package/src/img/teammates/marvel/reviewer.svg +21 -0
- package/src/img/teammates/marvel/scanner.svg +23 -0
- package/src/img/teammates/marvel/security.svg +30 -0
- package/src/img/teammates/marvel/tracer.svg +19 -0
- package/src/img/teammates/marvel/translator.svg +24 -0
- package/src/img/teammates/marvel/worker.svg +16 -0
- package/src/img/teammates/researcher.svg +35 -0
- package/src/img/teammates/reviewer.svg +23 -0
- package/src/img/teammates/scanner.svg +31 -0
- package/src/img/teammates/security.svg +31 -0
- package/src/img/teammates/tracer.svg +30 -0
- package/src/img/teammates/translator.svg +32 -0
- package/src/img/teammates/worker.svg +29 -0
- package/src/main.jsx +30 -0
- package/src/tokenInterceptor.js +60 -0
- package/src/utils/apiUrl.js +26 -0
- package/src/utils/approvalReviewerOptions.js +27 -0
- package/src/utils/askFallback.js +21 -0
- package/src/utils/askOptionDesc.js +55 -0
- package/src/utils/askPortalMatcher.js +54 -0
- package/src/utils/autoApproveOptions.js +23 -0
- package/src/utils/avatarAnimationPostPass.js +46 -0
- package/src/utils/builtinPresets.js +18 -0
- package/src/utils/clearCheckpoint.js +154 -0
- package/src/utils/commandValidator.js +45 -0
- package/src/utils/contentFilter.js +675 -0
- package/src/utils/contextRaw.js +17 -0
- package/src/utils/contextSidebarNavigation.js +16 -0
- package/src/utils/conversationEntryNormalize.js +497 -0
- package/src/utils/displayScaleHelper.js +47 -0
- package/src/utils/entry-slim.js +594 -0
- package/src/utils/entryCache.js +179 -0
- package/src/utils/errorReport.js +40 -0
- package/src/utils/fileExpandedPathsStorage.js +70 -0
- package/src/utils/fileIcons.jsx +36 -0
- package/src/utils/fileOpen.js +37 -0
- package/src/utils/formatters.js +48 -0
- package/src/utils/gitApi.js +50 -0
- package/src/utils/gitTreeBuilder.js +19 -0
- package/src/utils/helpers.js +462 -0
- package/src/utils/identityHeal.js +83 -0
- package/src/utils/imOrigin.js +24 -0
- package/src/utils/imTr.js +7 -0
- package/src/utils/imageCompress.js +83 -0
- package/src/utils/imageDownscale.js +28 -0
- package/src/utils/imageResize.js +112 -0
- package/src/utils/ingestPipeline.js +47 -0
- package/src/utils/lazyWithReload.js +53 -0
- package/src/utils/markdown.js +30 -0
- package/src/utils/markdownIncremental.js +39 -0
- package/src/utils/markdownProfiler.js +113 -0
- package/src/utils/mdExtensionDetect.js +64 -0
- package/src/utils/memoryLinkParser.js +44 -0
- package/src/utils/modalMask.js +15 -0
- package/src/utils/monotime.js +6 -0
- package/src/utils/pinnedMenu.js +55 -0
- package/src/utils/presetShortcuts.js +14 -0
- package/src/utils/projectAlias.js +135 -0
- package/src/utils/promptClassifier.js +111 -0
- package/src/utils/promptDetect.js +196 -0
- package/src/utils/promptNav.js +60 -0
- package/src/utils/ptyChunkBuilder.js +251 -0
- package/src/utils/quickMenuHoverIntent.js +35 -0
- package/src/utils/rateLimitParser.js +249 -0
- package/src/utils/readResultPool.js +106 -0
- package/src/utils/refreshCachedItemProp.js +32 -0
- package/src/utils/requestTools.js +19 -0
- package/src/utils/requestType.js +284 -0
- package/src/utils/resizeCalc.js +21 -0
- package/src/utils/resolveLocalized.js +17 -0
- package/src/utils/seqResourceLoaders.js +79 -0
- package/src/utils/sessionManager.js +694 -0
- package/src/utils/sessionMerge.js +290 -0
- package/src/utils/skillModalController.js +111 -0
- package/src/utils/skillsParser.js +116 -0
- package/src/utils/slashCommandLabels.js +80 -0
- package/src/utils/splitDragCalc.js +73 -0
- package/src/utils/stickyBottomController.js +643 -0
- package/src/utils/svgSanitize.js +48 -0
- package/src/utils/systemTags.js +47 -0
- package/src/utils/tCodex.js +20 -0
- package/src/utils/teamModalBuilder.js +347 -0
- package/src/utils/teamSessionParser.js +186 -0
- package/src/utils/teammateAvatars.js +194 -0
- package/src/utils/teammateDetector.js +106 -0
- package/src/utils/termDiag.js +114 -0
- package/src/utils/terminalClipboard.js +117 -0
- package/src/utils/terminalWriteQueue.js +398 -0
- package/src/utils/thinkingMerge.js +49 -0
- package/src/utils/tokenUsage.js +1 -0
- package/src/utils/toolCatalog.js +31 -0
- package/src/utils/toolNameAliases.js +13 -0
- package/src/utils/toolResultBuilder.js +312 -0
- package/src/utils/toolResultClassifier.js +16 -0
- package/src/utils/toolResultCore.js +161 -0
- package/src/utils/toolsDiff.js +44 -0
- package/src/utils/toolsXmlFormatter.js +3 -0
- package/src/utils/ultraplanController.js +109 -0
- package/src/utils/ultraplanExperts.js +86 -0
- package/src/utils/ultraplanTemplates.js +152 -0
- package/src/utils/userImageRefs.js +49 -0
- package/src/utils/voicePackPlayer.js +233 -0
- package/src/utils/webResultGrouping.js +111 -0
- package/src/utils/workflowFormat.js +52 -0
- package/src/utils/workflowRuns.js +118 -0
- package/src/utils/workflowStore.js +94 -0
- package/vite.config.js +106 -0
- package/concepts/ar/CacheRebuild.md +0 -36
- package/concepts/ar/KVCacheContent.md +0 -49
- package/concepts/ar/Tool-Agent.md +0 -125
- package/concepts/ar/Tool-AskUserQuestion.md +0 -75
- package/concepts/ar/Tool-Bash.md +0 -167
- package/concepts/ar/Tool-Edit.md +0 -46
- package/concepts/ar/Tool-EnterPlanMode.md +0 -128
- package/concepts/ar/Tool-EnterWorktree.md +0 -56
- package/concepts/ar/Tool-ExitPlanMode.md +0 -62
- package/concepts/ar/Tool-Glob.md +0 -39
- package/concepts/ar/Tool-Grep.md +0 -57
- package/concepts/ar/Tool-NotebookEdit.md +0 -33
- package/concepts/ar/Tool-Read.md +0 -56
- package/concepts/ar/Tool-SendMessage.md +0 -41
- package/concepts/ar/Tool-Skill.md +0 -56
- package/concepts/ar/Tool-Task.md +0 -51
- package/concepts/ar/Tool-TaskCreate.md +0 -78
- package/concepts/ar/Tool-TaskGet.md +0 -56
- package/concepts/ar/Tool-TaskList.md +0 -56
- package/concepts/ar/Tool-TaskOutput.md +0 -40
- package/concepts/ar/Tool-TaskStop.md +0 -32
- package/concepts/ar/Tool-TaskUpdate.md +0 -123
- package/concepts/ar/Tool-TeamCreate.md +0 -38
- package/concepts/ar/Tool-TeamDelete.md +0 -30
- package/concepts/ar/Tool-WebFetch.md +0 -55
- package/concepts/ar/Tool-WebSearch.md +0 -58
- package/concepts/ar/Tool-Write.md +0 -39
- package/concepts/ar/Tool-executeCode.md +0 -41
- package/concepts/ar/Tool-getDiagnostics.md +0 -32
- package/concepts/ar/Tools.md +0 -67
- package/concepts/da/CacheRebuild.md +0 -36
- package/concepts/da/KVCacheContent.md +0 -49
- package/concepts/da/Tool-Agent.md +0 -125
- package/concepts/da/Tool-AskUserQuestion.md +0 -75
- package/concepts/da/Tool-Bash.md +0 -167
- package/concepts/da/Tool-Edit.md +0 -46
- package/concepts/da/Tool-EnterPlanMode.md +0 -128
- package/concepts/da/Tool-EnterWorktree.md +0 -56
- package/concepts/da/Tool-ExitPlanMode.md +0 -62
- package/concepts/da/Tool-Glob.md +0 -39
- package/concepts/da/Tool-Grep.md +0 -57
- package/concepts/da/Tool-NotebookEdit.md +0 -33
- package/concepts/da/Tool-Read.md +0 -56
- package/concepts/da/Tool-SendMessage.md +0 -41
- package/concepts/da/Tool-Skill.md +0 -56
- package/concepts/da/Tool-Task.md +0 -51
- package/concepts/da/Tool-TaskCreate.md +0 -78
- package/concepts/da/Tool-TaskGet.md +0 -56
- package/concepts/da/Tool-TaskList.md +0 -56
- package/concepts/da/Tool-TaskOutput.md +0 -40
- package/concepts/da/Tool-TaskStop.md +0 -32
- package/concepts/da/Tool-TaskUpdate.md +0 -123
- package/concepts/da/Tool-TeamCreate.md +0 -38
- package/concepts/da/Tool-TeamDelete.md +0 -30
- package/concepts/da/Tool-WebFetch.md +0 -55
- package/concepts/da/Tool-WebSearch.md +0 -58
- package/concepts/da/Tool-Write.md +0 -39
- package/concepts/da/Tool-executeCode.md +0 -41
- package/concepts/da/Tool-getDiagnostics.md +0 -32
- package/concepts/da/Tools.md +0 -67
- package/concepts/de/CacheRebuild.md +0 -36
- package/concepts/de/KVCacheContent.md +0 -49
- package/concepts/de/Tool-Agent.md +0 -125
- package/concepts/de/Tool-AskUserQuestion.md +0 -75
- package/concepts/de/Tool-Bash.md +0 -167
- package/concepts/de/Tool-Edit.md +0 -46
- package/concepts/de/Tool-EnterPlanMode.md +0 -128
- package/concepts/de/Tool-EnterWorktree.md +0 -56
- package/concepts/de/Tool-ExitPlanMode.md +0 -62
- package/concepts/de/Tool-Glob.md +0 -39
- package/concepts/de/Tool-Grep.md +0 -57
- package/concepts/de/Tool-NotebookEdit.md +0 -33
- package/concepts/de/Tool-Read.md +0 -56
- package/concepts/de/Tool-SendMessage.md +0 -41
- package/concepts/de/Tool-Skill.md +0 -56
- package/concepts/de/Tool-Task.md +0 -51
- package/concepts/de/Tool-TaskCreate.md +0 -78
- package/concepts/de/Tool-TaskGet.md +0 -56
- package/concepts/de/Tool-TaskList.md +0 -56
- package/concepts/de/Tool-TaskOutput.md +0 -40
- package/concepts/de/Tool-TaskStop.md +0 -32
- package/concepts/de/Tool-TaskUpdate.md +0 -123
- package/concepts/de/Tool-TeamCreate.md +0 -38
- package/concepts/de/Tool-TeamDelete.md +0 -30
- package/concepts/de/Tool-WebFetch.md +0 -55
- package/concepts/de/Tool-WebSearch.md +0 -58
- package/concepts/de/Tool-Write.md +0 -39
- package/concepts/de/Tool-executeCode.md +0 -41
- package/concepts/de/Tool-getDiagnostics.md +0 -32
- package/concepts/de/Tools.md +0 -67
- package/concepts/en/CacheRebuild.md +0 -36
- package/concepts/en/KVCacheContent.md +0 -49
- package/concepts/en/Tool-Agent.md +0 -125
- package/concepts/en/Tool-AskUserQuestion.md +0 -75
- package/concepts/en/Tool-Bash.md +0 -167
- package/concepts/en/Tool-Edit.md +0 -46
- package/concepts/en/Tool-EnterPlanMode.md +0 -128
- package/concepts/en/Tool-EnterWorktree.md +0 -56
- package/concepts/en/Tool-ExitPlanMode.md +0 -62
- package/concepts/en/Tool-Glob.md +0 -39
- package/concepts/en/Tool-Grep.md +0 -57
- package/concepts/en/Tool-NotebookEdit.md +0 -33
- package/concepts/en/Tool-Read.md +0 -56
- package/concepts/en/Tool-SendMessage.md +0 -41
- package/concepts/en/Tool-Skill.md +0 -56
- package/concepts/en/Tool-Task.md +0 -51
- package/concepts/en/Tool-TaskCreate.md +0 -78
- package/concepts/en/Tool-TaskGet.md +0 -56
- package/concepts/en/Tool-TaskList.md +0 -56
- package/concepts/en/Tool-TaskOutput.md +0 -40
- package/concepts/en/Tool-TaskStop.md +0 -32
- package/concepts/en/Tool-TaskUpdate.md +0 -123
- package/concepts/en/Tool-TeamCreate.md +0 -38
- package/concepts/en/Tool-TeamDelete.md +0 -30
- package/concepts/en/Tool-WebFetch.md +0 -55
- package/concepts/en/Tool-WebSearch.md +0 -58
- package/concepts/en/Tool-Write.md +0 -39
- package/concepts/en/Tool-executeCode.md +0 -41
- package/concepts/en/Tool-getDiagnostics.md +0 -32
- package/concepts/es/CacheRebuild.md +0 -36
- package/concepts/es/KVCacheContent.md +0 -49
- package/concepts/es/Tool-Agent.md +0 -125
- package/concepts/es/Tool-AskUserQuestion.md +0 -75
- package/concepts/es/Tool-Bash.md +0 -167
- package/concepts/es/Tool-Edit.md +0 -46
- package/concepts/es/Tool-EnterPlanMode.md +0 -128
- package/concepts/es/Tool-EnterWorktree.md +0 -56
- package/concepts/es/Tool-ExitPlanMode.md +0 -62
- package/concepts/es/Tool-Glob.md +0 -39
- package/concepts/es/Tool-Grep.md +0 -57
- package/concepts/es/Tool-NotebookEdit.md +0 -33
- package/concepts/es/Tool-Read.md +0 -56
- package/concepts/es/Tool-SendMessage.md +0 -41
- package/concepts/es/Tool-Skill.md +0 -56
- package/concepts/es/Tool-Task.md +0 -51
- package/concepts/es/Tool-TaskCreate.md +0 -78
- package/concepts/es/Tool-TaskGet.md +0 -56
- package/concepts/es/Tool-TaskList.md +0 -56
- package/concepts/es/Tool-TaskOutput.md +0 -40
- package/concepts/es/Tool-TaskStop.md +0 -32
- package/concepts/es/Tool-TaskUpdate.md +0 -123
- package/concepts/es/Tool-TeamCreate.md +0 -38
- package/concepts/es/Tool-TeamDelete.md +0 -30
- package/concepts/es/Tool-WebFetch.md +0 -55
- package/concepts/es/Tool-WebSearch.md +0 -58
- package/concepts/es/Tool-Write.md +0 -39
- package/concepts/es/Tool-executeCode.md +0 -41
- package/concepts/es/Tool-getDiagnostics.md +0 -32
- package/concepts/es/Tools.md +0 -67
- package/concepts/fr/CacheRebuild.md +0 -36
- package/concepts/fr/KVCacheContent.md +0 -49
- package/concepts/fr/Tool-Agent.md +0 -125
- package/concepts/fr/Tool-AskUserQuestion.md +0 -75
- package/concepts/fr/Tool-Bash.md +0 -167
- package/concepts/fr/Tool-Edit.md +0 -46
- package/concepts/fr/Tool-EnterPlanMode.md +0 -128
- package/concepts/fr/Tool-EnterWorktree.md +0 -56
- package/concepts/fr/Tool-ExitPlanMode.md +0 -62
- package/concepts/fr/Tool-Glob.md +0 -39
- package/concepts/fr/Tool-Grep.md +0 -57
- package/concepts/fr/Tool-NotebookEdit.md +0 -33
- package/concepts/fr/Tool-Read.md +0 -56
- package/concepts/fr/Tool-SendMessage.md +0 -41
- package/concepts/fr/Tool-Skill.md +0 -56
- package/concepts/fr/Tool-Task.md +0 -51
- package/concepts/fr/Tool-TaskCreate.md +0 -78
- package/concepts/fr/Tool-TaskGet.md +0 -56
- package/concepts/fr/Tool-TaskList.md +0 -56
- package/concepts/fr/Tool-TaskOutput.md +0 -40
- package/concepts/fr/Tool-TaskStop.md +0 -32
- package/concepts/fr/Tool-TaskUpdate.md +0 -123
- package/concepts/fr/Tool-TeamCreate.md +0 -38
- package/concepts/fr/Tool-TeamDelete.md +0 -30
- package/concepts/fr/Tool-WebFetch.md +0 -55
- package/concepts/fr/Tool-WebSearch.md +0 -58
- package/concepts/fr/Tool-Write.md +0 -39
- package/concepts/fr/Tool-executeCode.md +0 -41
- package/concepts/fr/Tool-getDiagnostics.md +0 -32
- package/concepts/fr/Tools.md +0 -67
- package/concepts/it/CacheRebuild.md +0 -36
- package/concepts/it/KVCacheContent.md +0 -49
- package/concepts/it/Tool-Agent.md +0 -125
- package/concepts/it/Tool-AskUserQuestion.md +0 -75
- package/concepts/it/Tool-Bash.md +0 -167
- package/concepts/it/Tool-Edit.md +0 -46
- package/concepts/it/Tool-EnterPlanMode.md +0 -128
- package/concepts/it/Tool-EnterWorktree.md +0 -56
- package/concepts/it/Tool-ExitPlanMode.md +0 -62
- package/concepts/it/Tool-Glob.md +0 -39
- package/concepts/it/Tool-Grep.md +0 -57
- package/concepts/it/Tool-NotebookEdit.md +0 -33
- package/concepts/it/Tool-Read.md +0 -56
- package/concepts/it/Tool-SendMessage.md +0 -41
- package/concepts/it/Tool-Skill.md +0 -56
- package/concepts/it/Tool-Task.md +0 -51
- package/concepts/it/Tool-TaskCreate.md +0 -78
- package/concepts/it/Tool-TaskGet.md +0 -56
- package/concepts/it/Tool-TaskList.md +0 -56
- package/concepts/it/Tool-TaskOutput.md +0 -40
- package/concepts/it/Tool-TaskStop.md +0 -32
- package/concepts/it/Tool-TaskUpdate.md +0 -123
- package/concepts/it/Tool-TeamCreate.md +0 -38
- package/concepts/it/Tool-TeamDelete.md +0 -30
- package/concepts/it/Tool-WebFetch.md +0 -55
- package/concepts/it/Tool-WebSearch.md +0 -58
- package/concepts/it/Tool-Write.md +0 -39
- package/concepts/it/Tool-executeCode.md +0 -41
- package/concepts/it/Tool-getDiagnostics.md +0 -32
- package/concepts/it/Tools.md +0 -67
- package/concepts/ja/CacheRebuild.md +0 -36
- package/concepts/ja/KVCacheContent.md +0 -49
- package/concepts/ja/Tool-Agent.md +0 -125
- package/concepts/ja/Tool-AskUserQuestion.md +0 -75
- package/concepts/ja/Tool-Bash.md +0 -167
- package/concepts/ja/Tool-Edit.md +0 -46
- package/concepts/ja/Tool-EnterPlanMode.md +0 -128
- package/concepts/ja/Tool-EnterWorktree.md +0 -56
- package/concepts/ja/Tool-ExitPlanMode.md +0 -62
- package/concepts/ja/Tool-Glob.md +0 -39
- package/concepts/ja/Tool-Grep.md +0 -57
- package/concepts/ja/Tool-NotebookEdit.md +0 -33
- package/concepts/ja/Tool-Read.md +0 -56
- package/concepts/ja/Tool-SendMessage.md +0 -41
- package/concepts/ja/Tool-Skill.md +0 -56
- package/concepts/ja/Tool-Task.md +0 -51
- package/concepts/ja/Tool-TaskCreate.md +0 -78
- package/concepts/ja/Tool-TaskGet.md +0 -56
- package/concepts/ja/Tool-TaskList.md +0 -56
- package/concepts/ja/Tool-TaskOutput.md +0 -40
- package/concepts/ja/Tool-TaskStop.md +0 -32
- package/concepts/ja/Tool-TaskUpdate.md +0 -123
- package/concepts/ja/Tool-TeamCreate.md +0 -38
- package/concepts/ja/Tool-TeamDelete.md +0 -30
- package/concepts/ja/Tool-WebFetch.md +0 -55
- package/concepts/ja/Tool-WebSearch.md +0 -58
- package/concepts/ja/Tool-Write.md +0 -39
- package/concepts/ja/Tool-executeCode.md +0 -41
- package/concepts/ja/Tool-getDiagnostics.md +0 -32
- package/concepts/ja/Tools.md +0 -67
- package/concepts/ko/CacheRebuild.md +0 -36
- package/concepts/ko/KVCacheContent.md +0 -49
- package/concepts/ko/Tool-Agent.md +0 -125
- package/concepts/ko/Tool-AskUserQuestion.md +0 -75
- package/concepts/ko/Tool-Bash.md +0 -167
- package/concepts/ko/Tool-Edit.md +0 -46
- package/concepts/ko/Tool-EnterPlanMode.md +0 -128
- package/concepts/ko/Tool-EnterWorktree.md +0 -56
- package/concepts/ko/Tool-ExitPlanMode.md +0 -62
- package/concepts/ko/Tool-Glob.md +0 -39
- package/concepts/ko/Tool-Grep.md +0 -57
- package/concepts/ko/Tool-NotebookEdit.md +0 -33
- package/concepts/ko/Tool-Read.md +0 -56
- package/concepts/ko/Tool-SendMessage.md +0 -41
- package/concepts/ko/Tool-Skill.md +0 -56
- package/concepts/ko/Tool-Task.md +0 -51
- package/concepts/ko/Tool-TaskCreate.md +0 -78
- package/concepts/ko/Tool-TaskGet.md +0 -56
- package/concepts/ko/Tool-TaskList.md +0 -56
- package/concepts/ko/Tool-TaskOutput.md +0 -40
- package/concepts/ko/Tool-TaskStop.md +0 -32
- package/concepts/ko/Tool-TaskUpdate.md +0 -123
- package/concepts/ko/Tool-TeamCreate.md +0 -38
- package/concepts/ko/Tool-TeamDelete.md +0 -30
- package/concepts/ko/Tool-WebFetch.md +0 -55
- package/concepts/ko/Tool-WebSearch.md +0 -58
- package/concepts/ko/Tool-Write.md +0 -39
- package/concepts/ko/Tool-executeCode.md +0 -41
- package/concepts/ko/Tool-getDiagnostics.md +0 -32
- package/concepts/ko/Tools.md +0 -67
- package/concepts/no/CacheRebuild.md +0 -36
- package/concepts/no/KVCacheContent.md +0 -49
- package/concepts/no/Tool-Agent.md +0 -125
- package/concepts/no/Tool-AskUserQuestion.md +0 -75
- package/concepts/no/Tool-Bash.md +0 -167
- package/concepts/no/Tool-Edit.md +0 -46
- package/concepts/no/Tool-EnterPlanMode.md +0 -128
- package/concepts/no/Tool-EnterWorktree.md +0 -56
- package/concepts/no/Tool-ExitPlanMode.md +0 -62
- package/concepts/no/Tool-Glob.md +0 -39
- package/concepts/no/Tool-Grep.md +0 -57
- package/concepts/no/Tool-NotebookEdit.md +0 -33
- package/concepts/no/Tool-Read.md +0 -56
- package/concepts/no/Tool-SendMessage.md +0 -41
- package/concepts/no/Tool-Skill.md +0 -56
- package/concepts/no/Tool-Task.md +0 -51
- package/concepts/no/Tool-TaskCreate.md +0 -78
- package/concepts/no/Tool-TaskGet.md +0 -56
- package/concepts/no/Tool-TaskList.md +0 -56
- package/concepts/no/Tool-TaskOutput.md +0 -40
- package/concepts/no/Tool-TaskStop.md +0 -32
- package/concepts/no/Tool-TaskUpdate.md +0 -123
- package/concepts/no/Tool-TeamCreate.md +0 -38
- package/concepts/no/Tool-TeamDelete.md +0 -30
- package/concepts/no/Tool-WebFetch.md +0 -55
- package/concepts/no/Tool-WebSearch.md +0 -58
- package/concepts/no/Tool-Write.md +0 -39
- package/concepts/no/Tool-executeCode.md +0 -41
- package/concepts/no/Tool-getDiagnostics.md +0 -32
- package/concepts/no/Tools.md +0 -67
- package/concepts/pl/CacheRebuild.md +0 -36
- package/concepts/pl/KVCacheContent.md +0 -49
- package/concepts/pl/Tool-Agent.md +0 -125
- package/concepts/pl/Tool-AskUserQuestion.md +0 -75
- package/concepts/pl/Tool-Bash.md +0 -167
- package/concepts/pl/Tool-Edit.md +0 -46
- package/concepts/pl/Tool-EnterPlanMode.md +0 -128
- package/concepts/pl/Tool-EnterWorktree.md +0 -56
- package/concepts/pl/Tool-ExitPlanMode.md +0 -62
- package/concepts/pl/Tool-Glob.md +0 -39
- package/concepts/pl/Tool-Grep.md +0 -57
- package/concepts/pl/Tool-NotebookEdit.md +0 -33
- package/concepts/pl/Tool-Read.md +0 -56
- package/concepts/pl/Tool-SendMessage.md +0 -41
- package/concepts/pl/Tool-Skill.md +0 -56
- package/concepts/pl/Tool-Task.md +0 -51
- package/concepts/pl/Tool-TaskCreate.md +0 -78
- package/concepts/pl/Tool-TaskGet.md +0 -56
- package/concepts/pl/Tool-TaskList.md +0 -56
- package/concepts/pl/Tool-TaskOutput.md +0 -40
- package/concepts/pl/Tool-TaskStop.md +0 -32
- package/concepts/pl/Tool-TaskUpdate.md +0 -123
- package/concepts/pl/Tool-TeamCreate.md +0 -38
- package/concepts/pl/Tool-TeamDelete.md +0 -30
- package/concepts/pl/Tool-WebFetch.md +0 -55
- package/concepts/pl/Tool-WebSearch.md +0 -58
- package/concepts/pl/Tool-Write.md +0 -39
- package/concepts/pl/Tool-executeCode.md +0 -41
- package/concepts/pl/Tool-getDiagnostics.md +0 -32
- package/concepts/pl/Tools.md +0 -67
- package/concepts/pt-BR/CacheRebuild.md +0 -36
- package/concepts/pt-BR/KVCacheContent.md +0 -49
- package/concepts/pt-BR/Tool-Agent.md +0 -125
- package/concepts/pt-BR/Tool-AskUserQuestion.md +0 -75
- package/concepts/pt-BR/Tool-Bash.md +0 -167
- package/concepts/pt-BR/Tool-Edit.md +0 -46
- package/concepts/pt-BR/Tool-EnterPlanMode.md +0 -128
- package/concepts/pt-BR/Tool-EnterWorktree.md +0 -56
- package/concepts/pt-BR/Tool-ExitPlanMode.md +0 -62
- package/concepts/pt-BR/Tool-Glob.md +0 -39
- package/concepts/pt-BR/Tool-Grep.md +0 -57
- package/concepts/pt-BR/Tool-NotebookEdit.md +0 -33
- package/concepts/pt-BR/Tool-Read.md +0 -56
- package/concepts/pt-BR/Tool-SendMessage.md +0 -41
- package/concepts/pt-BR/Tool-Skill.md +0 -56
- package/concepts/pt-BR/Tool-Task.md +0 -51
- package/concepts/pt-BR/Tool-TaskCreate.md +0 -78
- package/concepts/pt-BR/Tool-TaskGet.md +0 -56
- package/concepts/pt-BR/Tool-TaskList.md +0 -56
- package/concepts/pt-BR/Tool-TaskOutput.md +0 -40
- package/concepts/pt-BR/Tool-TaskStop.md +0 -32
- package/concepts/pt-BR/Tool-TaskUpdate.md +0 -123
- package/concepts/pt-BR/Tool-TeamCreate.md +0 -38
- package/concepts/pt-BR/Tool-TeamDelete.md +0 -30
- package/concepts/pt-BR/Tool-WebFetch.md +0 -55
- package/concepts/pt-BR/Tool-WebSearch.md +0 -58
- package/concepts/pt-BR/Tool-Write.md +0 -39
- package/concepts/pt-BR/Tool-executeCode.md +0 -41
- package/concepts/pt-BR/Tool-getDiagnostics.md +0 -32
- package/concepts/pt-BR/Tools.md +0 -67
- package/concepts/ru/CacheRebuild.md +0 -36
- package/concepts/ru/KVCacheContent.md +0 -49
- package/concepts/ru/Tool-Agent.md +0 -125
- package/concepts/ru/Tool-AskUserQuestion.md +0 -75
- package/concepts/ru/Tool-Bash.md +0 -167
- package/concepts/ru/Tool-Edit.md +0 -46
- package/concepts/ru/Tool-EnterPlanMode.md +0 -128
- package/concepts/ru/Tool-EnterWorktree.md +0 -56
- package/concepts/ru/Tool-ExitPlanMode.md +0 -62
- package/concepts/ru/Tool-Glob.md +0 -39
- package/concepts/ru/Tool-Grep.md +0 -57
- package/concepts/ru/Tool-NotebookEdit.md +0 -33
- package/concepts/ru/Tool-Read.md +0 -56
- package/concepts/ru/Tool-SendMessage.md +0 -41
- package/concepts/ru/Tool-Skill.md +0 -56
- package/concepts/ru/Tool-Task.md +0 -51
- package/concepts/ru/Tool-TaskCreate.md +0 -78
- package/concepts/ru/Tool-TaskGet.md +0 -56
- package/concepts/ru/Tool-TaskList.md +0 -56
- package/concepts/ru/Tool-TaskOutput.md +0 -40
- package/concepts/ru/Tool-TaskStop.md +0 -32
- package/concepts/ru/Tool-TaskUpdate.md +0 -123
- package/concepts/ru/Tool-TeamCreate.md +0 -38
- package/concepts/ru/Tool-TeamDelete.md +0 -30
- package/concepts/ru/Tool-WebFetch.md +0 -55
- package/concepts/ru/Tool-WebSearch.md +0 -58
- package/concepts/ru/Tool-Write.md +0 -39
- package/concepts/ru/Tool-executeCode.md +0 -41
- package/concepts/ru/Tool-getDiagnostics.md +0 -32
- package/concepts/ru/Tools.md +0 -67
- package/concepts/th/CacheRebuild.md +0 -36
- package/concepts/th/KVCacheContent.md +0 -49
- package/concepts/th/Tool-Agent.md +0 -125
- package/concepts/th/Tool-AskUserQuestion.md +0 -75
- package/concepts/th/Tool-Bash.md +0 -167
- package/concepts/th/Tool-Edit.md +0 -46
- package/concepts/th/Tool-EnterPlanMode.md +0 -128
- package/concepts/th/Tool-EnterWorktree.md +0 -56
- package/concepts/th/Tool-ExitPlanMode.md +0 -62
- package/concepts/th/Tool-Glob.md +0 -39
- package/concepts/th/Tool-Grep.md +0 -57
- package/concepts/th/Tool-NotebookEdit.md +0 -33
- package/concepts/th/Tool-Read.md +0 -56
- package/concepts/th/Tool-SendMessage.md +0 -41
- package/concepts/th/Tool-Skill.md +0 -56
- package/concepts/th/Tool-Task.md +0 -51
- package/concepts/th/Tool-TaskCreate.md +0 -78
- package/concepts/th/Tool-TaskGet.md +0 -56
- package/concepts/th/Tool-TaskList.md +0 -56
- package/concepts/th/Tool-TaskOutput.md +0 -40
- package/concepts/th/Tool-TaskStop.md +0 -32
- package/concepts/th/Tool-TaskUpdate.md +0 -123
- package/concepts/th/Tool-TeamCreate.md +0 -38
- package/concepts/th/Tool-TeamDelete.md +0 -30
- package/concepts/th/Tool-WebFetch.md +0 -55
- package/concepts/th/Tool-WebSearch.md +0 -58
- package/concepts/th/Tool-Write.md +0 -39
- package/concepts/th/Tool-executeCode.md +0 -41
- package/concepts/th/Tool-getDiagnostics.md +0 -32
- package/concepts/th/Tools.md +0 -67
- package/concepts/tr/CacheRebuild.md +0 -36
- package/concepts/tr/KVCacheContent.md +0 -49
- package/concepts/tr/Tool-Agent.md +0 -125
- package/concepts/tr/Tool-AskUserQuestion.md +0 -75
- package/concepts/tr/Tool-Bash.md +0 -167
- package/concepts/tr/Tool-Edit.md +0 -46
- package/concepts/tr/Tool-EnterPlanMode.md +0 -128
- package/concepts/tr/Tool-EnterWorktree.md +0 -56
- package/concepts/tr/Tool-ExitPlanMode.md +0 -62
- package/concepts/tr/Tool-Glob.md +0 -39
- package/concepts/tr/Tool-Grep.md +0 -57
- package/concepts/tr/Tool-NotebookEdit.md +0 -33
- package/concepts/tr/Tool-Read.md +0 -56
- package/concepts/tr/Tool-SendMessage.md +0 -41
- package/concepts/tr/Tool-Skill.md +0 -56
- package/concepts/tr/Tool-Task.md +0 -51
- package/concepts/tr/Tool-TaskCreate.md +0 -78
- package/concepts/tr/Tool-TaskGet.md +0 -56
- package/concepts/tr/Tool-TaskList.md +0 -56
- package/concepts/tr/Tool-TaskOutput.md +0 -40
- package/concepts/tr/Tool-TaskStop.md +0 -32
- package/concepts/tr/Tool-TaskUpdate.md +0 -123
- package/concepts/tr/Tool-TeamCreate.md +0 -38
- package/concepts/tr/Tool-TeamDelete.md +0 -30
- package/concepts/tr/Tool-WebFetch.md +0 -55
- package/concepts/tr/Tool-WebSearch.md +0 -58
- package/concepts/tr/Tool-Write.md +0 -39
- package/concepts/tr/Tool-executeCode.md +0 -41
- package/concepts/tr/Tool-getDiagnostics.md +0 -32
- package/concepts/tr/Tools.md +0 -67
- package/concepts/uk/CacheRebuild.md +0 -36
- package/concepts/uk/KVCacheContent.md +0 -49
- package/concepts/uk/Tool-Agent.md +0 -125
- package/concepts/uk/Tool-AskUserQuestion.md +0 -75
- package/concepts/uk/Tool-Bash.md +0 -167
- package/concepts/uk/Tool-Edit.md +0 -46
- package/concepts/uk/Tool-EnterPlanMode.md +0 -128
- package/concepts/uk/Tool-EnterWorktree.md +0 -56
- package/concepts/uk/Tool-ExitPlanMode.md +0 -62
- package/concepts/uk/Tool-Glob.md +0 -39
- package/concepts/uk/Tool-Grep.md +0 -57
- package/concepts/uk/Tool-NotebookEdit.md +0 -33
- package/concepts/uk/Tool-Read.md +0 -56
- package/concepts/uk/Tool-SendMessage.md +0 -41
- package/concepts/uk/Tool-Skill.md +0 -56
- package/concepts/uk/Tool-Task.md +0 -51
- package/concepts/uk/Tool-TaskCreate.md +0 -78
- package/concepts/uk/Tool-TaskGet.md +0 -56
- package/concepts/uk/Tool-TaskList.md +0 -56
- package/concepts/uk/Tool-TaskOutput.md +0 -40
- package/concepts/uk/Tool-TaskStop.md +0 -32
- package/concepts/uk/Tool-TaskUpdate.md +0 -123
- package/concepts/uk/Tool-TeamCreate.md +0 -38
- package/concepts/uk/Tool-TeamDelete.md +0 -30
- package/concepts/uk/Tool-WebFetch.md +0 -55
- package/concepts/uk/Tool-WebSearch.md +0 -58
- package/concepts/uk/Tool-Write.md +0 -39
- package/concepts/uk/Tool-executeCode.md +0 -41
- package/concepts/uk/Tool-getDiagnostics.md +0 -32
- package/concepts/uk/Tools.md +0 -67
- package/concepts/zh/CacheRebuild.md +0 -36
- package/concepts/zh/KVCacheContent.md +0 -49
- package/concepts/zh/Tool-Agent.md +0 -125
- package/concepts/zh/Tool-AskUserQuestion.md +0 -75
- package/concepts/zh/Tool-Bash.md +0 -167
- package/concepts/zh/Tool-Edit.md +0 -46
- package/concepts/zh/Tool-EnterPlanMode.md +0 -128
- package/concepts/zh/Tool-EnterWorktree.md +0 -56
- package/concepts/zh/Tool-ExitPlanMode.md +0 -62
- package/concepts/zh/Tool-Glob.md +0 -39
- package/concepts/zh/Tool-Grep.md +0 -57
- package/concepts/zh/Tool-NotebookEdit.md +0 -33
- package/concepts/zh/Tool-Read.md +0 -56
- package/concepts/zh/Tool-SendMessage.md +0 -41
- package/concepts/zh/Tool-Skill.md +0 -56
- package/concepts/zh/Tool-Task.md +0 -51
- package/concepts/zh/Tool-TaskCreate.md +0 -78
- package/concepts/zh/Tool-TaskGet.md +0 -56
- package/concepts/zh/Tool-TaskList.md +0 -56
- package/concepts/zh/Tool-TaskOutput.md +0 -40
- package/concepts/zh/Tool-TaskStop.md +0 -32
- package/concepts/zh/Tool-TaskUpdate.md +0 -123
- package/concepts/zh/Tool-TeamCreate.md +0 -38
- package/concepts/zh/Tool-TeamDelete.md +0 -30
- package/concepts/zh/Tool-WebFetch.md +0 -55
- package/concepts/zh/Tool-WebSearch.md +0 -58
- package/concepts/zh/Tool-Write.md +0 -39
- package/concepts/zh/Tool-executeCode.md +0 -41
- package/concepts/zh/Tool-getDiagnostics.md +0 -32
- package/concepts/zh-TW/CacheRebuild.md +0 -36
- package/concepts/zh-TW/KVCacheContent.md +0 -49
- package/concepts/zh-TW/Tool-Agent.md +0 -125
- package/concepts/zh-TW/Tool-AskUserQuestion.md +0 -75
- package/concepts/zh-TW/Tool-Bash.md +0 -167
- package/concepts/zh-TW/Tool-Edit.md +0 -46
- package/concepts/zh-TW/Tool-EnterPlanMode.md +0 -128
- package/concepts/zh-TW/Tool-EnterWorktree.md +0 -56
- package/concepts/zh-TW/Tool-ExitPlanMode.md +0 -62
- package/concepts/zh-TW/Tool-Glob.md +0 -39
- package/concepts/zh-TW/Tool-Grep.md +0 -57
- package/concepts/zh-TW/Tool-NotebookEdit.md +0 -33
- package/concepts/zh-TW/Tool-Read.md +0 -56
- package/concepts/zh-TW/Tool-SendMessage.md +0 -41
- package/concepts/zh-TW/Tool-Skill.md +0 -56
- package/concepts/zh-TW/Tool-Task.md +0 -51
- package/concepts/zh-TW/Tool-TaskCreate.md +0 -78
- package/concepts/zh-TW/Tool-TaskGet.md +0 -56
- package/concepts/zh-TW/Tool-TaskList.md +0 -56
- package/concepts/zh-TW/Tool-TaskOutput.md +0 -40
- package/concepts/zh-TW/Tool-TaskStop.md +0 -32
- package/concepts/zh-TW/Tool-TaskUpdate.md +0 -123
- package/concepts/zh-TW/Tool-TeamCreate.md +0 -38
- package/concepts/zh-TW/Tool-TeamDelete.md +0 -30
- package/concepts/zh-TW/Tool-WebFetch.md +0 -55
- package/concepts/zh-TW/Tool-WebSearch.md +0 -58
- package/concepts/zh-TW/Tool-Write.md +0 -39
- package/concepts/zh-TW/Tool-executeCode.md +0 -41
- package/concepts/zh-TW/Tool-getDiagnostics.md +0 -32
- package/concepts/zh-TW/Tools.md +0 -67
- package/dist/assets/App-BN2YmKSu.js +0 -41
- package/dist/assets/App-fG2r3jFq.css +0 -1
- package/dist/assets/AppHeader-BqUGBbBx.css +0 -41
- package/dist/assets/AppHeader.module-CvH9GQQ2.js +0 -1250
- package/dist/assets/Mobile-BnDkLcBv.css +0 -1
- package/dist/assets/Mobile-CbC8YD3O.js +0 -10
- package/dist/assets/_baseUniq-B2ddYY2A.js +0 -1
- package/dist/assets/arc-DFPOHgcd.js +0 -1
- package/dist/assets/architectureDiagram-Q4EWVU46-1tuXixQv.js +0 -36
- package/dist/assets/blockDiagram-DXYQGD6D-BfVKQPAV.js +0 -132
- package/dist/assets/c4Diagram-AHTNJAMY-Bua8O4-1.js +0 -10
- package/dist/assets/channel-Cf9uPxYW.js +0 -1
- package/dist/assets/chunk-4BX2VUAB-YOIkSNn_.js +0 -1
- package/dist/assets/chunk-4TB4RGXK-CjZt-To5.js +0 -206
- package/dist/assets/chunk-55IACEB6-BAEfMF5S.js +0 -1
- package/dist/assets/chunk-EDXVE4YY-BUYDmLXU.js +0 -1
- package/dist/assets/chunk-FMBD7UC4-Cw_LDap-.js +0 -15
- package/dist/assets/chunk-OYMX7WX6-PlfZFFxd.js +0 -231
- package/dist/assets/chunk-QZHKN3VN-C2ReFZl_.js +0 -1
- package/dist/assets/chunk-YZCP3GAM-B7IVGkPB.js +0 -1
- package/dist/assets/classDiagram-6PBFFD2Q-DdwVeNLZ.js +0 -1
- package/dist/assets/classDiagram-v2-HSJHXN6E-DdwVeNLZ.js +0 -1
- package/dist/assets/clone-C8Lz0121.js +0 -1
- package/dist/assets/cose-bilkent-S5V4N54A-M6rBKf0y.js +0 -1
- package/dist/assets/cytoscape.esm-DxGcaOPV.js +0 -331
- package/dist/assets/dagre-KV5264BT-UPacTWnL.js +0 -4
- package/dist/assets/defaultLocale-DX6XiGOO.js +0 -1
- package/dist/assets/diagram-5BDNPKRD-Cjjtnh0e.js +0 -10
- package/dist/assets/diagram-G4DWMVQ6-CjXILMP0.js +0 -24
- package/dist/assets/diagram-MMDJMWI5-C_-XZ9gc.js +0 -43
- package/dist/assets/diagram-TYMM5635-Dxe2GxUR.js +0 -24
- package/dist/assets/erDiagram-SMLLAGMA-1w-wtgMd.js +0 -85
- package/dist/assets/flowDiagram-DWJPFMVM-B9naMGCj.js +0 -162
- package/dist/assets/ganttDiagram-T4ZO3ILL-BPZBdhPv.js +0 -292
- package/dist/assets/gitGraphDiagram-UUTBAWPF-_P9PdiGG.js +0 -106
- package/dist/assets/graph-CjOY8lRz.js +0 -1
- package/dist/assets/html2canvas.esm-QH1iLAAe.js +0 -22
- package/dist/assets/index-BcCW9op4.js +0 -41
- package/dist/assets/index-DCtZ2KSX.css +0 -1
- package/dist/assets/infoDiagram-42DDH7IO-Ch8SOTtq.js +0 -2
- package/dist/assets/init-Gi6I4Gst.js +0 -1
- package/dist/assets/ishikawaDiagram-UXIWVN3A-XLscQrJT.js +0 -70
- package/dist/assets/journeyDiagram-VCZTEJTY-C3FQ_QPk.js +0 -139
- package/dist/assets/kanban-definition-6JOO6SKY-DIQDTOi3.js +0 -89
- package/dist/assets/katex-DkKDou_j.js +0 -257
- package/dist/assets/layout-DO9W0X_b.js +0 -1
- package/dist/assets/linear-ClCJqwn1.js +0 -1
- package/dist/assets/mermaid.core-BW02B1TS.js +0 -308
- package/dist/assets/min-BuzClhio.js +0 -1
- package/dist/assets/mindmap-definition-QFDTVHPH-DuCaTeZu.js +0 -96
- package/dist/assets/ordinal-Cboi1Yqb.js +0 -1
- package/dist/assets/pieDiagram-DEJITSTG-BZoZ6CI1.js +0 -30
- package/dist/assets/quadrantDiagram-34T5L4WZ-DFNwvtmc.js +0 -7
- package/dist/assets/requirementDiagram-MS252O5E-DPG-7raV.js +0 -84
- package/dist/assets/sankeyDiagram-XADWPNL6-Bp92e1ie.js +0 -10
- package/dist/assets/sequenceDiagram-FGHM5R23-C6ADwqJY.js +0 -157
- package/dist/assets/stateDiagram-FHFEXIEX-BfrwZGmF.js +0 -1
- package/dist/assets/stateDiagram-v2-QKLJ7IA2-4gBW7EPI.js +0 -1
- package/dist/assets/timeline-definition-GMOUNBTQ-Bb-TxYx2.js +0 -120
- package/dist/assets/vennDiagram-DHZGUBPP-DTRiNXJu.js +0 -34
- package/dist/assets/wardley-RL74JXVD-C8j_kjXS.js +0 -162
- package/dist/assets/wardleyDiagram-NUSXRM2D-CvICMc3N.js +0 -20
- package/dist/assets/xychartDiagram-5P7HB3ND-DI0bBGwq.js +0 -7
- package/lib/kv-cache-analyzer.js +0 -164
package/lib/appserver-bridge.js
CHANGED
|
@@ -21,16 +21,35 @@ import { appendFileSync } from 'node:fs';
|
|
|
21
21
|
import { basename } from 'node:path';
|
|
22
22
|
import { BINARY_NAME } from '../findcx.js';
|
|
23
23
|
import WebSocket, { WebSocketServer } from 'ws';
|
|
24
|
+
import { getOriginalCodexBaseUrl } from './codex-config.js';
|
|
25
|
+
import { DEFAULT_API_BASE } from './constants.js';
|
|
26
|
+
import { isSupportedApprovalsReviewer, normalizeApprovalsReviewer } from './approval-reviewer.js';
|
|
24
27
|
|
|
25
28
|
let _appServerProcess = null;
|
|
29
|
+
|
|
30
|
+
const CODEX_PLAN_TOOL_NAME = 'update_plan';
|
|
31
|
+
const CODEX_ASK_TOOL_NAME = 'request_user_input';
|
|
32
|
+
|
|
33
|
+
/** Build the real OpenAI API URL from configured base URL */
|
|
34
|
+
function buildApiUrl() {
|
|
35
|
+
const base = getOriginalCodexBaseUrl() || DEFAULT_API_BASE;
|
|
36
|
+
const cleanBase = base.replace(/\/+$/, '');
|
|
37
|
+
if (cleanBase.endsWith('/v1')) return `${cleanBase}/responses`;
|
|
38
|
+
return `${cleanBase}/v1/responses`;
|
|
39
|
+
}
|
|
26
40
|
let _proxyServer = null;
|
|
27
41
|
let _upstreamWs = null;
|
|
28
42
|
let _logFile = null;
|
|
29
43
|
let _currentModel = null;
|
|
30
44
|
let _currentProject = null;
|
|
31
|
-
let _messages = []; //
|
|
45
|
+
let _messages = []; // 累积会话项,用于生成 MainAgent 的 Responses input
|
|
32
46
|
let _pendingContent = []; // 当前 turn 的 assistant content blocks
|
|
33
47
|
let _turnStartTime = null;
|
|
48
|
+
let _mainThreadId = null;
|
|
49
|
+
const _threadStates = new Map();
|
|
50
|
+
const _threadMetaById = new Map();
|
|
51
|
+
const _subAgentThreads = new Map();
|
|
52
|
+
const _pendingServerRequests = new Map();
|
|
34
53
|
|
|
35
54
|
// 丰富的上下文信息
|
|
36
55
|
let _threadId = null;
|
|
@@ -47,6 +66,35 @@ let _rawSessionServerFrames = [];
|
|
|
47
66
|
let _rawTurnClientFrames = [];
|
|
48
67
|
let _rawTurnServerFrames = [];
|
|
49
68
|
let _turnActive = false;
|
|
69
|
+
let _approvalsReviewerOverride = null;
|
|
70
|
+
let _onApprovalsReviewerActive = null;
|
|
71
|
+
let _writeLogEntry = null;
|
|
72
|
+
|
|
73
|
+
const REVIEWER_LIFECYCLE_METHODS = new Set([
|
|
74
|
+
'thread/start',
|
|
75
|
+
'thread/resume',
|
|
76
|
+
'thread/fork',
|
|
77
|
+
'turn/start',
|
|
78
|
+
]);
|
|
79
|
+
|
|
80
|
+
function injectApprovalsReviewer(msg) {
|
|
81
|
+
if (!_approvalsReviewerOverride || !msg || !REVIEWER_LIFECYCLE_METHODS.has(msg.method)) return msg;
|
|
82
|
+
return {
|
|
83
|
+
...msg,
|
|
84
|
+
params: {
|
|
85
|
+
...(msg.params || {}),
|
|
86
|
+
approvalsReviewer: _approvalsReviewerOverride,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function setApprovalsReviewer(value) {
|
|
92
|
+
_approvalsReviewerOverride = normalizeApprovalsReviewer(value);
|
|
93
|
+
return {
|
|
94
|
+
approvalsReviewer: _approvalsReviewerOverride,
|
|
95
|
+
appliesOnNextTurn: true,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
50
98
|
|
|
51
99
|
function _pickSystemPrompt(...candidates) {
|
|
52
100
|
for (const value of candidates) {
|
|
@@ -64,6 +112,390 @@ function cloneJson(value) {
|
|
|
64
112
|
}
|
|
65
113
|
}
|
|
66
114
|
|
|
115
|
+
function stringifyValue(value) {
|
|
116
|
+
if (value == null) return '';
|
|
117
|
+
if (typeof value === 'string') return value;
|
|
118
|
+
try {
|
|
119
|
+
return JSON.stringify(value);
|
|
120
|
+
} catch {
|
|
121
|
+
return String(value);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function parseMaybeJson(value) {
|
|
126
|
+
if (typeof value !== 'string') return value;
|
|
127
|
+
try {
|
|
128
|
+
return JSON.parse(value);
|
|
129
|
+
} catch {
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function decodeBase64Text(value) {
|
|
135
|
+
if (typeof value !== 'string' || !value) return '';
|
|
136
|
+
try {
|
|
137
|
+
return Buffer.from(value, 'base64').toString('utf8');
|
|
138
|
+
} catch {
|
|
139
|
+
return '';
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function usageField(usage, camelName, snakeName) {
|
|
144
|
+
return usage?.[camelName] ?? usage?.[snakeName] ?? 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function normalizeTokenUsage(usage) {
|
|
148
|
+
if (!usage) return null;
|
|
149
|
+
const input = usageField(usage, 'inputTokens', 'input_tokens');
|
|
150
|
+
const output = usageField(usage, 'outputTokens', 'output_tokens');
|
|
151
|
+
const reasoning = usageField(usage, 'reasoningOutputTokens', 'reasoning_output_tokens');
|
|
152
|
+
const cached = usageField(usage, 'cachedInputTokens', 'cached_input_tokens');
|
|
153
|
+
const total = usageField(usage, 'totalTokens', 'total_tokens') || (input + output);
|
|
154
|
+
return {
|
|
155
|
+
input_tokens: input,
|
|
156
|
+
output_tokens: output,
|
|
157
|
+
reasoning_output_tokens: reasoning,
|
|
158
|
+
total_tokens: total,
|
|
159
|
+
input_tokens_details: { cached_tokens: cached, cache_write_tokens: 0 },
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function formatTurnPlan(planUpdate) {
|
|
164
|
+
if (!planUpdate) return '';
|
|
165
|
+
const lines = [];
|
|
166
|
+
if (planUpdate.explanation) lines.push(planUpdate.explanation);
|
|
167
|
+
for (const item of planUpdate.plan || []) {
|
|
168
|
+
if (!item?.step) continue;
|
|
169
|
+
const status = item.status ? `[${item.status}] ` : '';
|
|
170
|
+
lines.push(`- ${status}${item.step}`);
|
|
171
|
+
}
|
|
172
|
+
return lines.join('\n');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function textFromContent(content) {
|
|
176
|
+
if (content == null) return '';
|
|
177
|
+
if (typeof content === 'string') return content;
|
|
178
|
+
if (!Array.isArray(content)) {
|
|
179
|
+
if (typeof content.text === 'string') return content.text;
|
|
180
|
+
if (typeof content.input_text === 'string') return content.input_text;
|
|
181
|
+
if (typeof content.output_text === 'string') return content.output_text;
|
|
182
|
+
if (Array.isArray(content.content) || typeof content.content === 'string') {
|
|
183
|
+
return textFromContent(content.content);
|
|
184
|
+
}
|
|
185
|
+
return '';
|
|
186
|
+
}
|
|
187
|
+
return content.map(block => {
|
|
188
|
+
if (!block) return '';
|
|
189
|
+
if (typeof block === 'string') return block;
|
|
190
|
+
if (typeof block.text === 'string') return block.text;
|
|
191
|
+
if (typeof block.input_text === 'string') return block.input_text;
|
|
192
|
+
if (typeof block.output_text === 'string') return block.output_text;
|
|
193
|
+
if (typeof block.content === 'string' || Array.isArray(block.content)) return textFromContent(block.content);
|
|
194
|
+
return '';
|
|
195
|
+
}).filter(Boolean).join('\n');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function normalizeUserContent(content) {
|
|
199
|
+
if (typeof content === 'string') return content;
|
|
200
|
+
if (!Array.isArray(content)) return textFromContent(content);
|
|
201
|
+
const text = textFromContent(content);
|
|
202
|
+
const hasOnlyText = content.every(block => {
|
|
203
|
+
if (typeof block === 'string') return true;
|
|
204
|
+
return block && (block.type === 'text' || block.type === 'input_text');
|
|
205
|
+
});
|
|
206
|
+
return hasOnlyText ? text : cloneJson(content);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function sameUserContent(a, b) {
|
|
210
|
+
if (a === b) return true;
|
|
211
|
+
try {
|
|
212
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
213
|
+
} catch {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function createThreadState(threadId) {
|
|
219
|
+
return {
|
|
220
|
+
threadId: threadId || 'root',
|
|
221
|
+
messages: [],
|
|
222
|
+
pendingContent: [],
|
|
223
|
+
turnStartTime: null,
|
|
224
|
+
turnId: null,
|
|
225
|
+
cwd: _cwd,
|
|
226
|
+
model: _currentModel,
|
|
227
|
+
systemPrompt: null,
|
|
228
|
+
turnContext: {},
|
|
229
|
+
threadMeta: {},
|
|
230
|
+
lastTokenUsage: null,
|
|
231
|
+
turnStatus: null,
|
|
232
|
+
seenUserMessageIds: new Set(),
|
|
233
|
+
agentMessageDeltas: new Map(),
|
|
234
|
+
reasoningDeltas: new Map(),
|
|
235
|
+
planDeltas: new Map(),
|
|
236
|
+
commandOutputDeltas: new Map(),
|
|
237
|
+
commandExecOutputDeltas: new Map(),
|
|
238
|
+
terminalInteractions: new Map(),
|
|
239
|
+
fileChangeOutputDeltas: new Map(),
|
|
240
|
+
fileChangePatches: new Map(),
|
|
241
|
+
mcpProgressMessages: new Map(),
|
|
242
|
+
processOutputDeltas: new Map(),
|
|
243
|
+
itemSnapshots: new Map(),
|
|
244
|
+
itemOrder: [],
|
|
245
|
+
completedItemIds: new Set(),
|
|
246
|
+
emittedTurnIds: new Set(),
|
|
247
|
+
turnPlan: null,
|
|
248
|
+
turnPlanToolId: null,
|
|
249
|
+
turnDiff: null,
|
|
250
|
+
turnModerationMetadata: null,
|
|
251
|
+
modelReroutes: [],
|
|
252
|
+
modelVerifications: [],
|
|
253
|
+
safetyBuffering: null,
|
|
254
|
+
warnings: [],
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function getThreadState(threadId) {
|
|
259
|
+
const key = threadId || _threadId || _mainThreadId || 'root';
|
|
260
|
+
let state = _threadStates.get(key);
|
|
261
|
+
if (!state) {
|
|
262
|
+
state = createThreadState(key);
|
|
263
|
+
_threadStates.set(key, state);
|
|
264
|
+
}
|
|
265
|
+
return state;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function syncGlobalsFromState(state) {
|
|
269
|
+
if (!state) return;
|
|
270
|
+
_threadId = state.threadId;
|
|
271
|
+
_turnId = state.turnId;
|
|
272
|
+
_turnStartTime = state.turnStartTime;
|
|
273
|
+
_turnContext = state.turnContext || {};
|
|
274
|
+
_threadMeta = state.threadMeta || {};
|
|
275
|
+
_lastTokenUsage = state.lastTokenUsage || null;
|
|
276
|
+
_turnStatus = state.turnStatus || null;
|
|
277
|
+
_messages = state.messages;
|
|
278
|
+
_pendingContent = state.pendingContent;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function resetThreadRuntimeState() {
|
|
282
|
+
_threadStates.clear();
|
|
283
|
+
_threadMetaById.clear();
|
|
284
|
+
_subAgentThreads.clear();
|
|
285
|
+
_pendingServerRequests.clear();
|
|
286
|
+
_mainThreadId = null;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function getSubAgentSourceInfo(source) {
|
|
290
|
+
const subAgent = source?.subAgent;
|
|
291
|
+
if (!subAgent) return null;
|
|
292
|
+
if (typeof subAgent === 'string') {
|
|
293
|
+
return { kind: subAgent };
|
|
294
|
+
}
|
|
295
|
+
const spawn = subAgent.thread_spawn || subAgent.threadSpawn;
|
|
296
|
+
if (spawn) {
|
|
297
|
+
return {
|
|
298
|
+
kind: 'thread_spawn',
|
|
299
|
+
parentThreadId: spawn.parent_thread_id || spawn.parentThreadId,
|
|
300
|
+
agentPath: spawn.agent_path || spawn.agentPath,
|
|
301
|
+
agentNickname: spawn.agent_nickname || spawn.agentNickname,
|
|
302
|
+
agentRole: spawn.agent_role || spawn.agentRole || spawn.agent_type || spawn.agentType,
|
|
303
|
+
depth: spawn.depth,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
return { kind: stringifyValue(subAgent) };
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function rememberSubAgentThread(threadId, info = {}) {
|
|
310
|
+
if (!threadId) return;
|
|
311
|
+
const existing = _subAgentThreads.get(threadId) || {};
|
|
312
|
+
const next = { ...existing, ...info };
|
|
313
|
+
if (!next.parentThreadId && _mainThreadId && _mainThreadId !== threadId) {
|
|
314
|
+
next.parentThreadId = _mainThreadId;
|
|
315
|
+
}
|
|
316
|
+
_subAgentThreads.set(threadId, next);
|
|
317
|
+
getThreadState(threadId);
|
|
318
|
+
if (!_mainThreadId && next.parentThreadId && next.parentThreadId !== threadId) {
|
|
319
|
+
_mainThreadId = next.parentThreadId;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function isSubAgentThreadMeta(thread) {
|
|
324
|
+
if (!thread) return false;
|
|
325
|
+
if (thread.parentThreadId) return true;
|
|
326
|
+
if (thread.threadSource === 'subagent') return true;
|
|
327
|
+
return !!getSubAgentSourceInfo(thread.source);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function rememberThread(thread) {
|
|
331
|
+
if (!thread?.id) return getThreadState();
|
|
332
|
+
_threadMetaById.set(thread.id, thread);
|
|
333
|
+
const state = getThreadState(thread.id);
|
|
334
|
+
state.threadMeta = thread;
|
|
335
|
+
state.cwd = thread.cwd || state.cwd || _cwd;
|
|
336
|
+
const sourceInfo = getSubAgentSourceInfo(thread.source) || {};
|
|
337
|
+
const parentThreadId = thread.parentThreadId || sourceInfo.parentThreadId || null;
|
|
338
|
+
|
|
339
|
+
if (isSubAgentThreadMeta(thread)) {
|
|
340
|
+
rememberSubAgentThread(thread.id, {
|
|
341
|
+
parentThreadId,
|
|
342
|
+
agentPath: thread.agentPath || sourceInfo.agentPath,
|
|
343
|
+
agentNickname: thread.agentNickname || sourceInfo.agentNickname,
|
|
344
|
+
agentRole: thread.agentRole || sourceInfo.agentRole || sourceInfo.kind,
|
|
345
|
+
source: thread.source,
|
|
346
|
+
});
|
|
347
|
+
} else if (!_mainThreadId) {
|
|
348
|
+
_mainThreadId = thread.id;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
syncGlobalsFromState(state);
|
|
352
|
+
return state;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function rememberThreadResponse(result) {
|
|
356
|
+
const thread = result?.thread;
|
|
357
|
+
if (!thread?.id) return null;
|
|
358
|
+
const state = rememberThread(thread);
|
|
359
|
+
state.model = result.model || state.model || _currentModel;
|
|
360
|
+
state.cwd = result.cwd || thread.cwd || state.cwd || _cwd;
|
|
361
|
+
syncGlobalsFromState(state);
|
|
362
|
+
hydrateThreadTurnsFromResponse(thread, result);
|
|
363
|
+
return state;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function getAgentIdentity(threadId) {
|
|
367
|
+
const thread = _threadMetaById.get(threadId) || getThreadState(threadId).threadMeta || {};
|
|
368
|
+
const sourceInfo = getSubAgentSourceInfo(thread.source) || {};
|
|
369
|
+
const registered = _subAgentThreads.get(threadId);
|
|
370
|
+
if (registered || isSubAgentThreadMeta(thread)) {
|
|
371
|
+
const info = registered || {};
|
|
372
|
+
const label = info.agentNickname
|
|
373
|
+
|| thread.agentNickname
|
|
374
|
+
|| info.agentRole
|
|
375
|
+
|| thread.agentRole
|
|
376
|
+
|| info.agentPath
|
|
377
|
+
|| sourceInfo.agentNickname
|
|
378
|
+
|| sourceInfo.agentRole
|
|
379
|
+
|| sourceInfo.agentPath
|
|
380
|
+
|| sourceInfo.kind
|
|
381
|
+
|| 'subagent';
|
|
382
|
+
const parentThreadId = info.parentThreadId || thread.parentThreadId || sourceInfo.parentThreadId || _mainThreadId || null;
|
|
383
|
+
return {
|
|
384
|
+
mainAgent: false,
|
|
385
|
+
subAgent: true,
|
|
386
|
+
subAgentName: label,
|
|
387
|
+
teamName: parentThreadId || undefined,
|
|
388
|
+
_agentThreadId: threadId,
|
|
389
|
+
...(parentThreadId ? { _parentThreadId: parentThreadId } : {}),
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
return {
|
|
393
|
+
mainAgent: true,
|
|
394
|
+
subAgent: false,
|
|
395
|
+
_agentThreadId: threadId,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function pushContentBlock(blocks, block) {
|
|
400
|
+
if (!block) return;
|
|
401
|
+
if (block.type === 'text' && !block.text) return;
|
|
402
|
+
if (block.type === 'thinking' && !block.thinking) return;
|
|
403
|
+
const prev = blocks[blocks.length - 1];
|
|
404
|
+
if (prev && prev.type === 'text' && block.type === 'text') {
|
|
405
|
+
prev.text += block.text;
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
if (prev && prev.type === 'thinking' && block.type === 'thinking') {
|
|
409
|
+
prev.thinking += block.thinking;
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
blocks.push(block);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function flushAssistantContent(state) {
|
|
416
|
+
if (!state?.pendingContent?.length) return;
|
|
417
|
+
state.messages.push({ role: 'assistant', content: state.pendingContent });
|
|
418
|
+
state.pendingContent = [];
|
|
419
|
+
if (state.threadId === _threadId) _pendingContent = state.pendingContent;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function appendUserMessage(state, content, clientId, options = {}) {
|
|
423
|
+
if (!state) return;
|
|
424
|
+
if (clientId && state.seenUserMessageIds.has(clientId)) return;
|
|
425
|
+
const normalized = normalizeUserContent(content);
|
|
426
|
+
const hasContent = Array.isArray(normalized) ? normalized.length > 0 : !!normalized;
|
|
427
|
+
if (!hasContent) return;
|
|
428
|
+
if (options.dedupeLastUser) {
|
|
429
|
+
const last = state.messages[state.messages.length - 1];
|
|
430
|
+
if (last?.role === 'user' && sameUserContent(last.content, normalized)) {
|
|
431
|
+
if (clientId) state.seenUserMessageIds.add(clientId);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
state.messages.push({ role: 'user', content: normalized, ...(clientId ? { _clientId: clientId } : {}) });
|
|
436
|
+
if (clientId) state.seenUserMessageIds.add(clientId);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function appendToolResultMessage(state, id, output) {
|
|
440
|
+
state.messages.push({
|
|
441
|
+
role: 'user',
|
|
442
|
+
content: [{
|
|
443
|
+
type: 'tool_result',
|
|
444
|
+
tool_use_id: id,
|
|
445
|
+
content: stringifyValue(output),
|
|
446
|
+
}],
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function registerCollabAgentThreads(item, fallbackParentThreadId) {
|
|
451
|
+
if (!item || typeof item !== 'object') return;
|
|
452
|
+
const parentThreadId = item.senderThreadId || fallbackParentThreadId || _mainThreadId;
|
|
453
|
+
const receiverThreadIds = [
|
|
454
|
+
...(Array.isArray(item.receiverThreadIds) ? item.receiverThreadIds : []),
|
|
455
|
+
item.receiverThreadId,
|
|
456
|
+
item.newThreadId,
|
|
457
|
+
].filter(Boolean);
|
|
458
|
+
for (const threadId of receiverThreadIds) {
|
|
459
|
+
rememberSubAgentThread(threadId, {
|
|
460
|
+
parentThreadId,
|
|
461
|
+
agentNickname: item.agentNickname,
|
|
462
|
+
agentRole: item.agentRole || item.tool,
|
|
463
|
+
agentPath: item.agentPath,
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function itemKey(item) {
|
|
469
|
+
return item?.id || item?.call_id || item?.callId || item?.processId || item?.type || null;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function rememberItemSnapshot(state, item) {
|
|
473
|
+
const id = itemKey(item);
|
|
474
|
+
if (!state || !id || !item || typeof item !== 'object') return item;
|
|
475
|
+
if (!state.itemSnapshots.has(id)) state.itemOrder.push(id);
|
|
476
|
+
const previous = state.itemSnapshots.get(id) || {};
|
|
477
|
+
const next = { ...previous, ...item, id: item.id || previous.id || id };
|
|
478
|
+
state.itemSnapshots.set(id, next);
|
|
479
|
+
return next;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function isTerminalItem(item) {
|
|
483
|
+
return item?.status === 'completed' || item?.status === 'failed' || item?.status === 'cancelled';
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function canFlushSnapshotAtTurnEnd(item) {
|
|
487
|
+
if (!item || typeof item !== 'object') return false;
|
|
488
|
+
if (isTerminalItem(item)) return true;
|
|
489
|
+
return item.type === 'message'
|
|
490
|
+
|| item.type === 'agentMessage'
|
|
491
|
+
|| item.type === 'agent_message'
|
|
492
|
+
|| item.type === 'reasoning'
|
|
493
|
+
|| item.type === 'todoList'
|
|
494
|
+
|| item.type === 'todo_list'
|
|
495
|
+
|| item.type === 'error'
|
|
496
|
+
|| item.type === 'plan';
|
|
497
|
+
}
|
|
498
|
+
|
|
67
499
|
function resetRawSessionFrames() {
|
|
68
500
|
_rawSessionClientFrames = [];
|
|
69
501
|
_rawSessionServerFrames = [];
|
|
@@ -140,30 +572,37 @@ async function waitForReady(url, timeoutMs = 15000) {
|
|
|
140
572
|
function writeEntry(entry) {
|
|
141
573
|
if (!entry || !_logFile) return;
|
|
142
574
|
try {
|
|
143
|
-
|
|
575
|
+
if (_writeLogEntry) _writeLogEntry(entry);
|
|
576
|
+
else appendFileSync(_logFile, JSON.stringify(entry) + '\n---\n');
|
|
144
577
|
} catch {}
|
|
145
578
|
}
|
|
146
579
|
|
|
147
580
|
/**
|
|
148
|
-
* 构建完整的 request body(包含所有可用上下文)
|
|
581
|
+
* 构建完整的 Responses request body(包含所有可用上下文)
|
|
149
582
|
*/
|
|
150
|
-
function buildFullRequestBody() {
|
|
583
|
+
function buildFullRequestBody(state = getThreadState(), threadId = state.threadId) {
|
|
584
|
+
const identity = getAgentIdentity(threadId);
|
|
585
|
+
const systemPrompt = state.systemPrompt
|
|
586
|
+
|| (identity.subAgent
|
|
587
|
+
? `You are Codex subagent (${identity.subAgentName || 'subagent'}), a general-purpose agent.`
|
|
588
|
+
: (_systemPrompt || 'You are Codex'));
|
|
151
589
|
return {
|
|
152
|
-
model: _currentModel,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
tools: [{ name: '
|
|
590
|
+
model: state.model || _currentModel,
|
|
591
|
+
instructions: systemPrompt,
|
|
592
|
+
input: state.messages.map(m => cloneJson(m)),
|
|
593
|
+
tools: [{ name: 'shell_command' }, { name: 'apply_patch' }, { name: 'tool_search' }],
|
|
156
594
|
// turn/start 中的完整参数
|
|
157
|
-
...(
|
|
158
|
-
...(
|
|
159
|
-
...(
|
|
160
|
-
...(
|
|
595
|
+
...(state.turnContext?.approvalPolicy ? { approval_policy: state.turnContext.approvalPolicy } : {}),
|
|
596
|
+
...(state.turnContext?.effort ? { reasoning_effort: state.turnContext.effort } : {}),
|
|
597
|
+
...(state.turnContext?.summary ? { reasoning_summary: state.turnContext.summary } : {}),
|
|
598
|
+
...(state.turnContext?.sandboxPolicy ? { sandbox_policy: state.turnContext.sandboxPolicy } : {}),
|
|
161
599
|
// 线程和 turn 元数据
|
|
162
600
|
metadata: {
|
|
163
|
-
thread_id:
|
|
164
|
-
turn_id:
|
|
165
|
-
cwd: _cwd || _currentProject,
|
|
166
|
-
...
|
|
601
|
+
thread_id: threadId,
|
|
602
|
+
turn_id: state.turnId,
|
|
603
|
+
cwd: state.cwd || _cwd || _currentProject,
|
|
604
|
+
...identity,
|
|
605
|
+
...(state.threadMeta?.preview ? { thread_preview: state.threadMeta.preview } : {}),
|
|
167
606
|
...(_serverInfo ? { server: _serverInfo } : {}),
|
|
168
607
|
},
|
|
169
608
|
};
|
|
@@ -183,74 +622,829 @@ function buildRawCodexRequest() {
|
|
|
183
622
|
server: cloneJson(_rawTurnServerFrames),
|
|
184
623
|
};
|
|
185
624
|
}
|
|
186
|
-
return raw;
|
|
625
|
+
return raw;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* 构建完整的 response body
|
|
630
|
+
*/
|
|
631
|
+
function buildFullResponseBody(responseContent, turnMeta, state = getThreadState()) {
|
|
632
|
+
const usage = state.lastTokenUsage?.last;
|
|
633
|
+
const totalUsage = state.lastTokenUsage?.total;
|
|
634
|
+
return {
|
|
635
|
+
content: responseContent,
|
|
636
|
+
model: state.model || _currentModel,
|
|
637
|
+
stop_reason: state.turnStatus || 'end_turn',
|
|
638
|
+
...(usage ? {
|
|
639
|
+
usage: normalizeTokenUsage(usage),
|
|
640
|
+
} : {}),
|
|
641
|
+
...(totalUsage ? {
|
|
642
|
+
total_usage: normalizeTokenUsage(totalUsage),
|
|
643
|
+
} : {}),
|
|
644
|
+
...(state.lastTokenUsage?.modelContextWindow ? { context_window: state.lastTokenUsage.modelContextWindow } : {}),
|
|
645
|
+
...(state.turnPlan ? { turn_plan: cloneJson(state.turnPlan) } : {}),
|
|
646
|
+
...(state.turnDiff ? { turn_diff: state.turnDiff } : {}),
|
|
647
|
+
...(state.turnModerationMetadata ? { moderation_metadata: cloneJson(state.turnModerationMetadata) } : {}),
|
|
648
|
+
...(state.modelReroutes?.length ? { model_reroutes: cloneJson(state.modelReroutes) } : {}),
|
|
649
|
+
...(state.modelVerifications?.length ? { model_verifications: cloneJson(state.modelVerifications) } : {}),
|
|
650
|
+
...(state.safetyBuffering ? { safety_buffering: cloneJson(state.safetyBuffering) } : {}),
|
|
651
|
+
...(state.warnings?.length ? { warnings: cloneJson(state.warnings) } : {}),
|
|
652
|
+
...(turnMeta ? {
|
|
653
|
+
turn: {
|
|
654
|
+
id: turnMeta.id,
|
|
655
|
+
status: turnMeta.status,
|
|
656
|
+
started_at: turnMeta.startedAt,
|
|
657
|
+
completed_at: turnMeta.completedAt,
|
|
658
|
+
duration_ms: turnMeta.durationMs,
|
|
659
|
+
},
|
|
660
|
+
} : {}),
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* 发出累积式 MainAgent entry
|
|
666
|
+
*/
|
|
667
|
+
function emitMainAgentEntry(timestamp, responseContent, turnMeta, state = getThreadState(), options = {}) {
|
|
668
|
+
const identity = getAgentIdentity(state.threadId);
|
|
669
|
+
const entry = {
|
|
670
|
+
timestamp,
|
|
671
|
+
project: _currentProject || 'codex',
|
|
672
|
+
url: buildApiUrl(),
|
|
673
|
+
method: 'POST',
|
|
674
|
+
headers: {},
|
|
675
|
+
body: buildFullRequestBody(state, state.threadId),
|
|
676
|
+
response: {
|
|
677
|
+
status: 200,
|
|
678
|
+
statusText: 'OK',
|
|
679
|
+
headers: {},
|
|
680
|
+
body: buildFullResponseBody(responseContent, turnMeta, state),
|
|
681
|
+
},
|
|
682
|
+
duration: turnMeta?.durationMs || (state.turnStartTime ? Date.now() - state.turnStartTime : 0),
|
|
683
|
+
isStream: options.isStream ?? true,
|
|
684
|
+
...identity,
|
|
685
|
+
_appServerSource: true,
|
|
686
|
+
_codexRawRequest: buildRawCodexRequest(),
|
|
687
|
+
...(options.extra || {}),
|
|
688
|
+
};
|
|
689
|
+
writeEntry(entry);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function writeEventEntry(base, state, name, input = {}, options = {}) {
|
|
693
|
+
const identity = getAgentIdentity(state.threadId);
|
|
694
|
+
writeEntry({
|
|
695
|
+
...base,
|
|
696
|
+
url: options.url || `codex://event/${encodeURIComponent(name)}`,
|
|
697
|
+
method: options.method || 'EVENT',
|
|
698
|
+
body: {
|
|
699
|
+
event_name: name,
|
|
700
|
+
event_input: cloneJson(input),
|
|
701
|
+
_threadId: state.threadId,
|
|
702
|
+
_turnId: state.turnId,
|
|
703
|
+
},
|
|
704
|
+
response: {
|
|
705
|
+
status: options.status || 200,
|
|
706
|
+
statusText: options.statusText || 'OK',
|
|
707
|
+
headers: {},
|
|
708
|
+
body: Object.prototype.hasOwnProperty.call(options, 'output')
|
|
709
|
+
? cloneJson(options.output)
|
|
710
|
+
: cloneJson(input),
|
|
711
|
+
},
|
|
712
|
+
duration: 0,
|
|
713
|
+
mainAgent: false,
|
|
714
|
+
subAgent: identity.subAgent,
|
|
715
|
+
...(identity.subAgent ? {
|
|
716
|
+
subAgentName: identity.subAgentName,
|
|
717
|
+
teamName: identity.teamName,
|
|
718
|
+
} : {}),
|
|
719
|
+
_agentThreadId: state.threadId,
|
|
720
|
+
...(identity._parentThreadId ? { _parentThreadId: identity._parentThreadId } : {}),
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
function rememberProcessOutput(state, params) {
|
|
725
|
+
const processHandle = params.processHandle;
|
|
726
|
+
if (!processHandle) return;
|
|
727
|
+
const stream = params.stream === 'stderr' ? 'stderr' : 'stdout';
|
|
728
|
+
const current = state.processOutputDeltas.get(processHandle) || {
|
|
729
|
+
stdout: '',
|
|
730
|
+
stderr: '',
|
|
731
|
+
stdoutCapReached: false,
|
|
732
|
+
stderrCapReached: false,
|
|
733
|
+
};
|
|
734
|
+
current[stream] += decodeBase64Text(params.deltaBase64);
|
|
735
|
+
if (params.capReached) {
|
|
736
|
+
current[`${stream}CapReached`] = true;
|
|
737
|
+
}
|
|
738
|
+
state.processOutputDeltas.set(processHandle, current);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function writeToolEntry(base, state, item, options = {}) {
|
|
742
|
+
const identity = getAgentIdentity(state.threadId);
|
|
743
|
+
const name = options.name || item.tool || item.name || item.type || 'tool';
|
|
744
|
+
const input = options.input ?? item.arguments ?? item.input ?? item.action ?? {};
|
|
745
|
+
const hasOutput = Object.prototype.hasOwnProperty.call(options, 'output')
|
|
746
|
+
|| Object.prototype.hasOwnProperty.call(item, 'output')
|
|
747
|
+
|| Object.prototype.hasOwnProperty.call(item, 'result')
|
|
748
|
+
|| Object.prototype.hasOwnProperty.call(item, 'error')
|
|
749
|
+
|| Object.prototype.hasOwnProperty.call(item, 'aggregatedOutput')
|
|
750
|
+
|| Object.prototype.hasOwnProperty.call(item, 'status');
|
|
751
|
+
const output = Object.prototype.hasOwnProperty.call(options, 'output')
|
|
752
|
+
? options.output
|
|
753
|
+
: (item.output ?? item.result ?? item.error ?? item.aggregatedOutput ?? item.status);
|
|
754
|
+
writeEntry({
|
|
755
|
+
...base,
|
|
756
|
+
url: options.url || `codex://tool/${encodeURIComponent(name)}`,
|
|
757
|
+
method: options.method || 'TOOL',
|
|
758
|
+
body: {
|
|
759
|
+
tool_name: name,
|
|
760
|
+
tool_input: parseMaybeJson(input),
|
|
761
|
+
_callId: item.call_id || item.callId || item.id,
|
|
762
|
+
_threadId: state.threadId,
|
|
763
|
+
_turnId: state.turnId,
|
|
764
|
+
_itemType: item.type,
|
|
765
|
+
status: item.status,
|
|
766
|
+
raw_item: item,
|
|
767
|
+
},
|
|
768
|
+
response: hasOutput ? {
|
|
769
|
+
status: item.error || item.status === 'failed' ? 500 : 200,
|
|
770
|
+
statusText: item.error || item.status === 'failed' ? 'Error' : 'OK',
|
|
771
|
+
headers: {},
|
|
772
|
+
body: {
|
|
773
|
+
output,
|
|
774
|
+
status: item.status,
|
|
775
|
+
exit_code: item.exitCode,
|
|
776
|
+
duration_ms: item.durationMs,
|
|
777
|
+
},
|
|
778
|
+
} : null,
|
|
779
|
+
duration: item.durationMs || 0,
|
|
780
|
+
mainAgent: false,
|
|
781
|
+
subAgent: identity.subAgent,
|
|
782
|
+
...(identity.subAgent ? {
|
|
783
|
+
subAgentName: identity.subAgentName,
|
|
784
|
+
teamName: identity.teamName,
|
|
785
|
+
} : {}),
|
|
786
|
+
_agentThreadId: state.threadId,
|
|
787
|
+
...(identity._parentThreadId ? { _parentThreadId: identity._parentThreadId } : {}),
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
const APPROVAL_SERVER_REQUEST_METHODS = new Set([
|
|
792
|
+
'item/commandExecution/requestApproval',
|
|
793
|
+
'item/fileChange/requestApproval',
|
|
794
|
+
'item/permissions/requestApproval',
|
|
795
|
+
'applyPatchApproval',
|
|
796
|
+
'execCommandApproval',
|
|
797
|
+
]);
|
|
798
|
+
|
|
799
|
+
function describeServerRequest(method, params = {}) {
|
|
800
|
+
if (method === 'item/commandExecution/requestApproval') {
|
|
801
|
+
return {
|
|
802
|
+
kind: 'approval',
|
|
803
|
+
name: 'shell_command',
|
|
804
|
+
input: {
|
|
805
|
+
command: params.command,
|
|
806
|
+
cwd: params.cwd,
|
|
807
|
+
reason: params.reason,
|
|
808
|
+
environmentId: params.environmentId,
|
|
809
|
+
approvalId: params.approvalId,
|
|
810
|
+
commandActions: params.commandActions,
|
|
811
|
+
networkApprovalContext: params.networkApprovalContext,
|
|
812
|
+
proposedExecpolicyAmendment: params.proposedExecpolicyAmendment,
|
|
813
|
+
proposedNetworkPolicyAmendments: params.proposedNetworkPolicyAmendments,
|
|
814
|
+
},
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
if (method === 'execCommandApproval') {
|
|
818
|
+
return {
|
|
819
|
+
kind: 'approval',
|
|
820
|
+
name: 'shell_command',
|
|
821
|
+
input: {
|
|
822
|
+
command: Array.isArray(params.command) ? params.command.join(' ') : params.command,
|
|
823
|
+
cwd: params.cwd,
|
|
824
|
+
reason: params.reason,
|
|
825
|
+
approvalId: params.approvalId,
|
|
826
|
+
parsedCmd: params.parsedCmd,
|
|
827
|
+
},
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
if (method === 'item/fileChange/requestApproval') {
|
|
831
|
+
return {
|
|
832
|
+
kind: 'approval',
|
|
833
|
+
name: 'apply_patch',
|
|
834
|
+
input: {
|
|
835
|
+
reason: params.reason,
|
|
836
|
+
grantRoot: params.grantRoot,
|
|
837
|
+
},
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
if (method === 'applyPatchApproval') {
|
|
841
|
+
return {
|
|
842
|
+
kind: 'approval',
|
|
843
|
+
name: 'apply_patch',
|
|
844
|
+
input: {
|
|
845
|
+
fileChanges: params.fileChanges,
|
|
846
|
+
reason: params.reason,
|
|
847
|
+
grantRoot: params.grantRoot,
|
|
848
|
+
},
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
if (method === 'item/permissions/requestApproval') {
|
|
852
|
+
return {
|
|
853
|
+
kind: 'approval',
|
|
854
|
+
name: 'permissions',
|
|
855
|
+
input: {
|
|
856
|
+
cwd: params.cwd,
|
|
857
|
+
reason: params.reason,
|
|
858
|
+
permissions: params.permissions,
|
|
859
|
+
environmentId: params.environmentId,
|
|
860
|
+
},
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
if (method === 'mcpServer/elicitation/request') {
|
|
864
|
+
return {
|
|
865
|
+
kind: 'elicitation',
|
|
866
|
+
name: params.serverName ? `${params.serverName}.elicitation` : 'mcp.elicitation',
|
|
867
|
+
input: {
|
|
868
|
+
mode: params.mode,
|
|
869
|
+
message: params.message,
|
|
870
|
+
requestedSchema: params.requestedSchema,
|
|
871
|
+
url: params.url,
|
|
872
|
+
elicitationId: params.elicitationId,
|
|
873
|
+
_meta: params._meta,
|
|
874
|
+
},
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
if (method === 'item/tool/call') {
|
|
878
|
+
return {
|
|
879
|
+
kind: 'dynamicToolCall',
|
|
880
|
+
name: params.namespace ? `${params.namespace}.${params.tool || 'tool'}` : (params.tool || 'dynamic_tool'),
|
|
881
|
+
input: params.arguments ?? {},
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
function writeServerRequestEntry(base, state, requestId, method, params, descriptor) {
|
|
888
|
+
const identity = getAgentIdentity(state.threadId);
|
|
889
|
+
const kind = descriptor?.kind || 'serverRequest';
|
|
890
|
+
const name = descriptor?.name || method;
|
|
891
|
+
const input = descriptor?.input ?? params;
|
|
892
|
+
writeEntry({
|
|
893
|
+
...base,
|
|
894
|
+
url: `codex://server_request/${encodeURIComponent(method)}/${encodeURIComponent(String(requestId))}`,
|
|
895
|
+
method: APPROVAL_SERVER_REQUEST_METHODS.has(method) ? 'APPROVAL_REQUEST' : 'SERVER_REQUEST',
|
|
896
|
+
body: {
|
|
897
|
+
server_request_method: method,
|
|
898
|
+
server_request_id: requestId,
|
|
899
|
+
server_request_kind: kind,
|
|
900
|
+
tool_name: name,
|
|
901
|
+
tool_input: parseMaybeJson(input) || {},
|
|
902
|
+
_threadId: state.threadId,
|
|
903
|
+
_turnId: params.turnId || state.turnId,
|
|
904
|
+
_itemId: params.itemId || params.callId,
|
|
905
|
+
raw_params: cloneJson(params),
|
|
906
|
+
},
|
|
907
|
+
response: null,
|
|
908
|
+
duration: 0,
|
|
909
|
+
mainAgent: false,
|
|
910
|
+
subAgent: identity.subAgent,
|
|
911
|
+
...(identity.subAgent ? {
|
|
912
|
+
subAgentName: identity.subAgentName,
|
|
913
|
+
teamName: identity.teamName,
|
|
914
|
+
} : {}),
|
|
915
|
+
_agentThreadId: state.threadId,
|
|
916
|
+
...(identity._parentThreadId ? { _parentThreadId: identity._parentThreadId } : {}),
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
function writeServerRequestResolutionEntry(pending, msg) {
|
|
921
|
+
const state = getThreadState(pending.threadId);
|
|
922
|
+
const identity = getAgentIdentity(state.threadId);
|
|
923
|
+
const isError = !!msg.error;
|
|
924
|
+
writeEntry({
|
|
925
|
+
timestamp: new Date().toISOString(),
|
|
926
|
+
project: _currentProject || 'codex',
|
|
927
|
+
url: `codex://server_request_response/${encodeURIComponent(pending.method)}/${encodeURIComponent(String(pending.requestId))}`,
|
|
928
|
+
method: 'SERVER_RESPONSE',
|
|
929
|
+
headers: {},
|
|
930
|
+
body: {
|
|
931
|
+
server_request_method: pending.method,
|
|
932
|
+
server_request_id: pending.requestId,
|
|
933
|
+
server_request_kind: pending.kind,
|
|
934
|
+
tool_name: pending.name,
|
|
935
|
+
_threadId: state.threadId,
|
|
936
|
+
_turnId: pending.turnId || state.turnId,
|
|
937
|
+
_itemId: pending.itemId,
|
|
938
|
+
},
|
|
939
|
+
response: {
|
|
940
|
+
status: isError ? 500 : 200,
|
|
941
|
+
statusText: isError ? 'Error' : 'OK',
|
|
942
|
+
headers: {},
|
|
943
|
+
body: isError ? cloneJson(msg.error) : cloneJson(msg.result),
|
|
944
|
+
},
|
|
945
|
+
duration: 0,
|
|
946
|
+
mainAgent: false,
|
|
947
|
+
subAgent: identity.subAgent,
|
|
948
|
+
...(identity.subAgent ? {
|
|
949
|
+
subAgentName: identity.subAgentName,
|
|
950
|
+
teamName: identity.teamName,
|
|
951
|
+
} : {}),
|
|
952
|
+
_agentThreadId: state.threadId,
|
|
953
|
+
...(identity._parentThreadId ? { _parentThreadId: identity._parentThreadId } : {}),
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
function appendToolUse(state, id, name, input) {
|
|
958
|
+
pushContentBlock(state.pendingContent, {
|
|
959
|
+
type: 'tool_use',
|
|
960
|
+
id: id || name || 'tool',
|
|
961
|
+
name: name || 'tool',
|
|
962
|
+
input: parseMaybeJson(input) || {},
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
function upsertToolUse(state, id, name, input) {
|
|
967
|
+
if (!state || !id) return;
|
|
968
|
+
const existing = state.pendingContent.find(block => block?.type === 'tool_use' && block.id === id);
|
|
969
|
+
if (existing) {
|
|
970
|
+
existing.name = name || existing.name;
|
|
971
|
+
existing.input = parseMaybeJson(input) || {};
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
appendToolUse(state, id, name, input);
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
function normalizeRequestUserInputQuestions(questions = []) {
|
|
978
|
+
if (!Array.isArray(questions)) return [];
|
|
979
|
+
return questions
|
|
980
|
+
.filter(q => q && typeof q === 'object')
|
|
981
|
+
.map(q => ({
|
|
982
|
+
...(q.id ? { id: q.id } : {}),
|
|
983
|
+
header: q.header || '',
|
|
984
|
+
question: q.question || q.id || '',
|
|
985
|
+
...(q.isOther ? { isOther: true } : {}),
|
|
986
|
+
...(q.isSecret ? { isSecret: true } : {}),
|
|
987
|
+
options: Array.isArray(q.options)
|
|
988
|
+
? q.options.map(opt => ({
|
|
989
|
+
label: String(opt?.label ?? ''),
|
|
990
|
+
description: opt?.description || '',
|
|
991
|
+
}))
|
|
992
|
+
: [],
|
|
993
|
+
}));
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
function mcpElicitationOptions(schema = {}) {
|
|
997
|
+
if (Array.isArray(schema.oneOf)) {
|
|
998
|
+
return schema.oneOf.map(opt => ({
|
|
999
|
+
label: String(opt?.title ?? opt?.const ?? ''),
|
|
1000
|
+
description: opt?.title && opt?.const != null && opt.title !== opt.const ? String(opt.const) : '',
|
|
1001
|
+
value: opt?.const,
|
|
1002
|
+
}));
|
|
1003
|
+
}
|
|
1004
|
+
if (Array.isArray(schema.enum)) {
|
|
1005
|
+
return schema.enum.map((value, index) => ({
|
|
1006
|
+
label: String(schema.enumNames?.[index] ?? value),
|
|
1007
|
+
description: schema.enumNames?.[index] ? String(value) : '',
|
|
1008
|
+
value,
|
|
1009
|
+
}));
|
|
1010
|
+
}
|
|
1011
|
+
return [];
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
function mcpElicitationArrayOptions(schema = {}) {
|
|
1015
|
+
const items = schema.items || {};
|
|
1016
|
+
if (Array.isArray(items.anyOf)) {
|
|
1017
|
+
return items.anyOf.map(opt => ({
|
|
1018
|
+
label: String(opt?.title ?? opt?.const ?? ''),
|
|
1019
|
+
description: opt?.title && opt?.const != null && opt.title !== opt.const ? String(opt.const) : '',
|
|
1020
|
+
value: opt?.const,
|
|
1021
|
+
}));
|
|
1022
|
+
}
|
|
1023
|
+
if (Array.isArray(items.enum)) {
|
|
1024
|
+
return items.enum.map(value => ({ label: String(value), description: '', value }));
|
|
1025
|
+
}
|
|
1026
|
+
return [];
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
function questionTextFromMcpField(params, key, schema = {}) {
|
|
1030
|
+
const label = schema.title || key;
|
|
1031
|
+
const description = schema.description ? `\n${schema.description}` : '';
|
|
1032
|
+
return [params.message, `${label}${description}`].filter(Boolean).join('\n\n');
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
function normalizeMcpElicitationQuestions(params = {}) {
|
|
1036
|
+
const header = params.serverName ? `${params.serverName} MCP` : 'MCP elicitation';
|
|
1037
|
+
if (params.mode === 'form' && params.requestedSchema?.properties) {
|
|
1038
|
+
return Object.entries(params.requestedSchema.properties)
|
|
1039
|
+
.filter(([, schema]) => schema && typeof schema === 'object')
|
|
1040
|
+
.map(([key, schema]) => {
|
|
1041
|
+
const isMulti = schema.type === 'array';
|
|
1042
|
+
const options = isMulti ? mcpElicitationArrayOptions(schema) : mcpElicitationOptions(schema);
|
|
1043
|
+
const booleanOptions = schema.type === 'boolean'
|
|
1044
|
+
? [
|
|
1045
|
+
{ label: 'true', description: '' },
|
|
1046
|
+
{ label: 'false', description: '' },
|
|
1047
|
+
]
|
|
1048
|
+
: [];
|
|
1049
|
+
return {
|
|
1050
|
+
id: key,
|
|
1051
|
+
header,
|
|
1052
|
+
question: questionTextFromMcpField(params, key, schema),
|
|
1053
|
+
...(isMulti ? { multiSelect: true } : {}),
|
|
1054
|
+
options: options.length ? options : booleanOptions,
|
|
1055
|
+
mcpSchema: cloneJson(schema),
|
|
1056
|
+
};
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
return [{
|
|
1060
|
+
id: params.elicitationId || 'mcp-elicitation',
|
|
1061
|
+
header,
|
|
1062
|
+
question: [params.message, params.url].filter(Boolean).join('\n\n'),
|
|
1063
|
+
options: [],
|
|
1064
|
+
mcpMode: params.mode,
|
|
1065
|
+
requestedSchema: cloneJson(params.requestedSchema),
|
|
1066
|
+
}];
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
function answerTextValue(answer) {
|
|
1070
|
+
if (Array.isArray(answer?.answers)) return answer.answers.join(', ');
|
|
1071
|
+
if (Array.isArray(answer)) return answer.join(', ');
|
|
1072
|
+
if (typeof answer === 'string') return answer;
|
|
1073
|
+
if (answer && typeof answer === 'object' && typeof answer.answer === 'string') return answer.answer;
|
|
1074
|
+
return stringifyValue(answer);
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
function quoteAskField(value) {
|
|
1078
|
+
return String(value ?? '').replace(/"/g, "'");
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
function formatAskUserInputResult(pending, result = {}) {
|
|
1082
|
+
const answers = result.answers || {};
|
|
1083
|
+
const questionById = new Map((pending.questions || []).map(q => [q.id || q.question, q]));
|
|
1084
|
+
return Object.entries(answers).map(([id, answer]) => {
|
|
1085
|
+
const q = questionById.get(id) || {};
|
|
1086
|
+
const question = q.question || id;
|
|
1087
|
+
return `"${quoteAskField(question)}"="${quoteAskField(answerTextValue(answer))}"`;
|
|
1088
|
+
}).join('\n');
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
function answerLabelForQuestion(question, answer) {
|
|
1092
|
+
if (!question?.options?.length) return answerTextValue(answer);
|
|
1093
|
+
const values = Array.isArray(answer) ? answer : [answer];
|
|
1094
|
+
return values.map(value => {
|
|
1095
|
+
const match = question.options.find(opt => opt.value === value || opt.label === value);
|
|
1096
|
+
return match?.label || answerTextValue(value);
|
|
1097
|
+
}).join(', ');
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
function formatMcpElicitationResult(pending, result = {}) {
|
|
1101
|
+
const action = result.action || null;
|
|
1102
|
+
if (action && action !== 'accept') return `[mcp:${action}]`;
|
|
1103
|
+
const content = result.content && typeof result.content === 'object' ? result.content : {};
|
|
1104
|
+
const questionById = new Map((pending.questions || []).map(q => [q.id || q.question, q]));
|
|
1105
|
+
const lines = Object.entries(content).map(([id, answer]) => {
|
|
1106
|
+
const q = questionById.get(id) || {};
|
|
1107
|
+
const question = q.question || id;
|
|
1108
|
+
return `"${quoteAskField(question)}"="${quoteAskField(answerLabelForQuestion(q, answer))}"`;
|
|
1109
|
+
});
|
|
1110
|
+
if (lines.length > 0) return lines.join('\n');
|
|
1111
|
+
return action ? `action=${action}` : stringifyValue(result);
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
function buildCodexTurnPlanInput(planUpdate) {
|
|
1115
|
+
return {
|
|
1116
|
+
plan: formatTurnPlan(planUpdate),
|
|
1117
|
+
allowedPrompts: [],
|
|
1118
|
+
codexTurnPlan: true,
|
|
1119
|
+
nonInteractive: true,
|
|
1120
|
+
turnPlan: cloneJson(planUpdate),
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
function buildCodexPlanItemInput(item) {
|
|
1125
|
+
return {
|
|
1126
|
+
plan: item?.text || '',
|
|
1127
|
+
allowedPrompts: [],
|
|
1128
|
+
codexTurnPlan: true,
|
|
1129
|
+
nonInteractive: true,
|
|
1130
|
+
planItem: cloneJson(item),
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
function completeToolLikeItem(base, state, item, options = {}) {
|
|
1135
|
+
const id = item.call_id || item.callId || item.id || options.id || options.name || item.type;
|
|
1136
|
+
const name = options.name || item.tool || item.name || item.type || 'tool';
|
|
1137
|
+
const input = options.input ?? item.arguments ?? item.input ?? item.action ?? {};
|
|
1138
|
+
const output = Object.prototype.hasOwnProperty.call(options, 'output')
|
|
1139
|
+
? options.output
|
|
1140
|
+
: (item.output ?? item.result ?? item.error ?? item.aggregatedOutput ?? item.status ?? item);
|
|
1141
|
+
appendToolUse(state, id, name, input);
|
|
1142
|
+
writeToolEntry(base, state, item, { ...options, name, input, output });
|
|
1143
|
+
flushAssistantContent(state);
|
|
1144
|
+
appendToolResultMessage(state, id, output);
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
function handleCompletedItem(item, state, base) {
|
|
1148
|
+
if (!item || typeof item !== 'object') return;
|
|
1149
|
+
const type = item.type;
|
|
1150
|
+
const id = itemKey(item);
|
|
1151
|
+
if (id) state.completedItemIds.add(id);
|
|
1152
|
+
|
|
1153
|
+
if (type === 'userMessage') {
|
|
1154
|
+
appendUserMessage(state, item.content || [], item.clientId || item.id, { dedupeLastUser: true });
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
if (type === 'message' || type === 'agentMessage' || type === 'agent_message') {
|
|
1159
|
+
const text = item.text || textFromContent(item.content) || state.agentMessageDeltas.get(item.id) || '';
|
|
1160
|
+
pushContentBlock(state.pendingContent, { type: 'text', text });
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
if (type === 'plan') {
|
|
1165
|
+
const text = item.text || state.planDeltas.get(item.id) || '';
|
|
1166
|
+
upsertToolUse(state, item.id || `codex-plan:${state.turnId || state.threadId || 'turn'}`, CODEX_PLAN_TOOL_NAME, buildCodexPlanItemInput({ ...item, text }));
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
if (type === 'reasoning') {
|
|
1171
|
+
const fromItem = textFromContent(item.summary || []) || textFromContent(item.content || []);
|
|
1172
|
+
const thinking = fromItem || state.reasoningDeltas.get(item.id) || '';
|
|
1173
|
+
pushContentBlock(state.pendingContent, { type: 'thinking', thinking, summary: item.summary });
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
if (type === 'function_call' || type === 'custom_tool_call' || type === 'local_shell_call' || type === 'tool_search_call') {
|
|
1178
|
+
const input = item.arguments ?? item.input ?? item.action ?? {};
|
|
1179
|
+
const name = item.name || item.tool || (type === 'local_shell_call' ? 'local_shell' : type);
|
|
1180
|
+
appendToolUse(state, item.call_id || item.id, name, input);
|
|
1181
|
+
writeToolEntry(base, state, item, { name, input });
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
if (type === 'function_call_output' || type === 'custom_tool_call_output') {
|
|
1186
|
+
const id = item.call_id || item.callId || item.id;
|
|
1187
|
+
flushAssistantContent(state);
|
|
1188
|
+
appendToolResultMessage(state, id, item.output);
|
|
1189
|
+
writeToolEntry(base, state, item, {
|
|
1190
|
+
method: 'TOOL_RESULT',
|
|
1191
|
+
url: `codex://tool_result/${encodeURIComponent(id || '')}`,
|
|
1192
|
+
name: type,
|
|
1193
|
+
input: { _callId: id },
|
|
1194
|
+
output: item.output,
|
|
1195
|
+
});
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
if (type === 'commandExecution' || type === 'command_execution') {
|
|
1200
|
+
const output = item.aggregatedOutput
|
|
1201
|
+
?? item.aggregated_output
|
|
1202
|
+
?? state.commandOutputDeltas.get(item.id)
|
|
1203
|
+
?? (item.processId ? state.commandExecOutputDeltas.get(item.processId) : null)
|
|
1204
|
+
?? item.status;
|
|
1205
|
+
const terminalInteractions = state.terminalInteractions.get(item.id) || [];
|
|
1206
|
+
const exitCode = item.exitCode ?? item.exit_code;
|
|
1207
|
+
completeToolLikeItem(base, state, item, {
|
|
1208
|
+
name: 'shell_command',
|
|
1209
|
+
input: {
|
|
1210
|
+
command: item.command,
|
|
1211
|
+
cwd: item.cwd,
|
|
1212
|
+
source: item.source,
|
|
1213
|
+
commandActions: item.commandActions,
|
|
1214
|
+
},
|
|
1215
|
+
output: {
|
|
1216
|
+
output,
|
|
1217
|
+
status: item.status,
|
|
1218
|
+
exitCode,
|
|
1219
|
+
...(terminalInteractions.length ? { terminal_interactions: terminalInteractions } : {}),
|
|
1220
|
+
},
|
|
1221
|
+
});
|
|
1222
|
+
return;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
if (type === 'fileChange' || type === 'file_change') {
|
|
1226
|
+
const deltaOutput = state.fileChangeOutputDeltas.get(item.id);
|
|
1227
|
+
const changes = (Array.isArray(item.changes) && item.changes.length > 0)
|
|
1228
|
+
? item.changes
|
|
1229
|
+
: (state.fileChangePatches.get(item.id) || item.changes || []);
|
|
1230
|
+
completeToolLikeItem(base, state, item, {
|
|
1231
|
+
name: 'apply_patch',
|
|
1232
|
+
input: { changes },
|
|
1233
|
+
output: { status: item.status, changes, ...(deltaOutput ? { output: deltaOutput } : {}) },
|
|
1234
|
+
});
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
if (type === 'mcpToolCall' || type === 'mcp_tool_call') {
|
|
1239
|
+
const progress = state.mcpProgressMessages.get(item.id);
|
|
1240
|
+
const resultOutput = item.error || item.result || item.status;
|
|
1241
|
+
completeToolLikeItem(base, state, item, {
|
|
1242
|
+
name: item.server ? `${item.server}.${item.tool}` : item.tool,
|
|
1243
|
+
input: item.arguments,
|
|
1244
|
+
output: progress?.length ? {
|
|
1245
|
+
progress,
|
|
1246
|
+
result: item.result,
|
|
1247
|
+
error: item.error,
|
|
1248
|
+
status: item.status,
|
|
1249
|
+
} : resultOutput,
|
|
1250
|
+
url: `codex://mcp_tool/${encodeURIComponent(item.tool || item.id || '')}`,
|
|
1251
|
+
});
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
if (type === 'dynamicToolCall') {
|
|
1256
|
+
completeToolLikeItem(base, state, item, {
|
|
1257
|
+
name: item.namespace ? `${item.namespace}.${item.tool}` : item.tool,
|
|
1258
|
+
input: item.arguments,
|
|
1259
|
+
output: item.contentItems || item.success || item.status,
|
|
1260
|
+
url: `codex://dynamic_tool/${encodeURIComponent(item.tool || item.id || '')}`,
|
|
1261
|
+
});
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
if (type === 'webSearch' || type === 'web_search') {
|
|
1266
|
+
completeToolLikeItem(base, state, item, {
|
|
1267
|
+
name: 'web_search',
|
|
1268
|
+
input: { query: item.query, action: item.action },
|
|
1269
|
+
output: item.action || item.query,
|
|
1270
|
+
url: 'codex://tool/web_search',
|
|
1271
|
+
});
|
|
1272
|
+
return;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
if (type === 'todoList' || type === 'todo_list') {
|
|
1276
|
+
const text = (Array.isArray(item.items) ? item.items : [])
|
|
1277
|
+
.map(todo => `${todo.completed ? '[x]' : '[ ]'} ${todo.text || ''}`.trim())
|
|
1278
|
+
.filter(Boolean)
|
|
1279
|
+
.join('\n');
|
|
1280
|
+
pushContentBlock(state.pendingContent, { type: 'text', text });
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
if (type === 'error') {
|
|
1285
|
+
const text = item.message ? `Error: ${item.message}` : '';
|
|
1286
|
+
pushContentBlock(state.pendingContent, { type: 'text', text });
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
if (type === 'imageView') {
|
|
1291
|
+
completeToolLikeItem(base, state, item, {
|
|
1292
|
+
name: 'view_image',
|
|
1293
|
+
input: { path: item.path },
|
|
1294
|
+
output: item.path,
|
|
1295
|
+
url: 'codex://tool/view_image',
|
|
1296
|
+
});
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
if (type === 'collabAgentToolCall' || type === 'collabToolCall') {
|
|
1301
|
+
registerCollabAgentThreads(item, state.threadId);
|
|
1302
|
+
completeToolLikeItem(base, state, item, {
|
|
1303
|
+
name: item.tool || 'spawn_agent',
|
|
1304
|
+
input: {
|
|
1305
|
+
prompt: item.prompt,
|
|
1306
|
+
model: item.model,
|
|
1307
|
+
receiverThreadIds: item.receiverThreadIds,
|
|
1308
|
+
receiverThreadId: item.receiverThreadId,
|
|
1309
|
+
newThreadId: item.newThreadId,
|
|
1310
|
+
reasoningEffort: item.reasoningEffort,
|
|
1311
|
+
},
|
|
1312
|
+
output: {
|
|
1313
|
+
status: item.status,
|
|
1314
|
+
agentsStates: item.agentsStates,
|
|
1315
|
+
receiverThreadIds: item.receiverThreadIds,
|
|
1316
|
+
receiverThreadId: item.receiverThreadId,
|
|
1317
|
+
newThreadId: item.newThreadId,
|
|
1318
|
+
},
|
|
1319
|
+
url: `codex://collab/${encodeURIComponent(item.tool || 'agent')}`,
|
|
1320
|
+
});
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
if (type === 'subAgentActivity') {
|
|
1325
|
+
rememberSubAgentThread(item.agentThreadId, {
|
|
1326
|
+
parentThreadId: state.threadId,
|
|
1327
|
+
agentPath: item.agentPath,
|
|
1328
|
+
agentRole: item.kind,
|
|
1329
|
+
});
|
|
1330
|
+
writeToolEntry(base, state, item, {
|
|
1331
|
+
method: 'SUBAGENT',
|
|
1332
|
+
url: `codex://subagent/${encodeURIComponent(item.kind || 'activity')}`,
|
|
1333
|
+
name: item.kind || 'subAgentActivity',
|
|
1334
|
+
input: { agentThreadId: item.agentThreadId, agentPath: item.agentPath },
|
|
1335
|
+
output: item.kind,
|
|
1336
|
+
});
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
if (type === 'sleep' || type === 'imageGeneration' || type === 'contextCompaction' || type === 'compacted' || type === 'enteredReviewMode' || type === 'exitedReviewMode') {
|
|
1341
|
+
writeToolEntry(base, state, item, {
|
|
1342
|
+
method: 'EVENT',
|
|
1343
|
+
url: `codex://event/${encodeURIComponent(type)}`,
|
|
1344
|
+
name: type,
|
|
1345
|
+
input: item,
|
|
1346
|
+
output: item.status || item.review || item,
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
187
1349
|
}
|
|
188
1350
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
model: _currentModel,
|
|
198
|
-
stop_reason: _turnStatus || 'end_turn',
|
|
199
|
-
...(usage ? {
|
|
200
|
-
usage: {
|
|
201
|
-
input_tokens: usage.inputTokens || 0,
|
|
202
|
-
output_tokens: usage.outputTokens || 0,
|
|
203
|
-
cache_read_input_tokens: usage.cachedInputTokens || 0,
|
|
204
|
-
reasoning_output_tokens: usage.reasoningOutputTokens || 0,
|
|
205
|
-
total_tokens: usage.totalTokens || 0,
|
|
206
|
-
},
|
|
207
|
-
} : {}),
|
|
208
|
-
...(totalUsage ? {
|
|
209
|
-
total_usage: {
|
|
210
|
-
input_tokens: totalUsage.inputTokens || 0,
|
|
211
|
-
output_tokens: totalUsage.outputTokens || 0,
|
|
212
|
-
cache_read_input_tokens: totalUsage.cachedInputTokens || 0,
|
|
213
|
-
reasoning_output_tokens: totalUsage.reasoningOutputTokens || 0,
|
|
214
|
-
total_tokens: totalUsage.totalTokens || 0,
|
|
215
|
-
},
|
|
216
|
-
} : {}),
|
|
217
|
-
...(_lastTokenUsage?.modelContextWindow ? { context_window: _lastTokenUsage.modelContextWindow } : {}),
|
|
218
|
-
...(turnMeta ? {
|
|
219
|
-
turn: {
|
|
220
|
-
id: turnMeta.id,
|
|
221
|
-
status: turnMeta.status,
|
|
222
|
-
started_at: turnMeta.startedAt,
|
|
223
|
-
completed_at: turnMeta.completedAt,
|
|
224
|
-
duration_ms: turnMeta.durationMs,
|
|
225
|
-
},
|
|
226
|
-
} : {}),
|
|
227
|
-
};
|
|
1351
|
+
function flushSnapshotItemsAtTurnEnd(state, base) {
|
|
1352
|
+
if (!state?.itemOrder?.length) return;
|
|
1353
|
+
for (const id of state.itemOrder) {
|
|
1354
|
+
if (state.completedItemIds.has(id)) continue;
|
|
1355
|
+
const item = state.itemSnapshots.get(id);
|
|
1356
|
+
if (!canFlushSnapshotAtTurnEnd(item)) continue;
|
|
1357
|
+
handleCompletedItem(item, state, base);
|
|
1358
|
+
}
|
|
228
1359
|
}
|
|
229
1360
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
1361
|
+
function timestampFromTurn(turn) {
|
|
1362
|
+
const seconds = turn?.completedAt ?? turn?.startedAt;
|
|
1363
|
+
return typeof seconds === 'number' && Number.isFinite(seconds)
|
|
1364
|
+
? new Date(seconds * 1000).toISOString()
|
|
1365
|
+
: new Date().toISOString();
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
function resetTurnItemState(state) {
|
|
1369
|
+
state.pendingContent = [];
|
|
1370
|
+
state.itemSnapshots = new Map();
|
|
1371
|
+
state.itemOrder = [];
|
|
1372
|
+
state.completedItemIds = new Set();
|
|
1373
|
+
state.turnPlan = null;
|
|
1374
|
+
state.turnPlanToolId = null;
|
|
1375
|
+
state.turnDiff = null;
|
|
1376
|
+
state.turnModerationMetadata = null;
|
|
1377
|
+
state.modelReroutes = [];
|
|
1378
|
+
state.modelVerifications = [];
|
|
1379
|
+
state.safetyBuffering = null;
|
|
1380
|
+
state.warnings = [];
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
function hydrateHistoryTurn(thread, turn, responseResult = {}) {
|
|
1384
|
+
if (!thread?.id || !turn?.id || !Array.isArray(turn.items)) return;
|
|
1385
|
+
if (turn.status === 'inProgress') return;
|
|
1386
|
+
const state = getThreadState(thread.id);
|
|
1387
|
+
if (state.emittedTurnIds.has(turn.id)) return;
|
|
1388
|
+
|
|
1389
|
+
state.threadId = thread.id;
|
|
1390
|
+
state.threadMeta = thread;
|
|
1391
|
+
state.cwd = responseResult.cwd || thread.cwd || state.cwd || _cwd;
|
|
1392
|
+
state.model = responseResult.model || state.model || _currentModel;
|
|
1393
|
+
state.turnId = turn.id;
|
|
1394
|
+
state.turnStatus = turn.status;
|
|
1395
|
+
state.turnStartTime = typeof turn.startedAt === 'number' ? turn.startedAt * 1000 : null;
|
|
1396
|
+
resetTurnItemState(state);
|
|
1397
|
+
syncGlobalsFromState(state);
|
|
1398
|
+
|
|
1399
|
+
const base = {
|
|
1400
|
+
timestamp: timestampFromTurn(turn),
|
|
236
1401
|
project: _currentProject || 'codex',
|
|
237
|
-
url: `codex://api/${_currentModel || 'codex'}`,
|
|
238
|
-
method: 'POST',
|
|
239
1402
|
headers: {},
|
|
240
|
-
|
|
241
|
-
response: {
|
|
242
|
-
status: 200,
|
|
243
|
-
statusText: 'OK',
|
|
244
|
-
headers: {},
|
|
245
|
-
body: buildFullResponseBody(responseContent, turnMeta),
|
|
246
|
-
},
|
|
247
|
-
duration: turnMeta?.durationMs || (_turnStartTime ? Date.now() - _turnStartTime : 0),
|
|
248
|
-
isStream: true,
|
|
249
|
-
mainAgent: true,
|
|
1403
|
+
isStream: false,
|
|
250
1404
|
_appServerSource: true,
|
|
251
|
-
|
|
1405
|
+
_codexHistorySource: true,
|
|
252
1406
|
};
|
|
253
|
-
|
|
1407
|
+
|
|
1408
|
+
for (const item of turn.items) {
|
|
1409
|
+
handleCompletedItem(item, state, base);
|
|
1410
|
+
}
|
|
1411
|
+
flushSnapshotItemsAtTurnEnd(state, base);
|
|
1412
|
+
|
|
1413
|
+
if (state.pendingContent.length > 0 || state.turnPlan || state.turnDiff) {
|
|
1414
|
+
const responseContent = state.pendingContent.length > 0
|
|
1415
|
+
? state.pendingContent
|
|
1416
|
+
: (state.turnPlan ? [{ type: 'text', text: formatTurnPlan(state.turnPlan) }] : []);
|
|
1417
|
+
state.messages.push({ role: 'assistant', content: responseContent });
|
|
1418
|
+
emitMainAgentEntry(base.timestamp, responseContent, turn, state, {
|
|
1419
|
+
isStream: false,
|
|
1420
|
+
extra: { _codexHistorySource: true },
|
|
1421
|
+
});
|
|
1422
|
+
state.pendingContent = [];
|
|
1423
|
+
} else if (turn.status === 'failed' || turn.error) {
|
|
1424
|
+
writeEntry({
|
|
1425
|
+
...base,
|
|
1426
|
+
url: 'codex://error',
|
|
1427
|
+
method: 'POST',
|
|
1428
|
+
body: buildFullRequestBody(state, state.threadId),
|
|
1429
|
+
response: {
|
|
1430
|
+
status: 500, statusText: 'Error', headers: {},
|
|
1431
|
+
body: { error: turn.error || turn },
|
|
1432
|
+
},
|
|
1433
|
+
duration: turn.durationMs || 0,
|
|
1434
|
+
...getAgentIdentity(state.threadId),
|
|
1435
|
+
_codexRawRequest: buildRawCodexRequest(),
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
state.emittedTurnIds.add(turn.id);
|
|
1440
|
+
syncGlobalsFromState(state);
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
function hydrateThreadTurnsFromResponse(thread, responseResult = {}) {
|
|
1444
|
+
if (!Array.isArray(thread?.turns) || thread.turns.length === 0) return;
|
|
1445
|
+
for (const turn of thread.turns) {
|
|
1446
|
+
hydrateHistoryTurn(thread, turn, responseResult);
|
|
1447
|
+
}
|
|
254
1448
|
}
|
|
255
1449
|
|
|
256
1450
|
/**
|
|
@@ -272,11 +1466,32 @@ function parseServerMessage(msg) {
|
|
|
272
1466
|
}
|
|
273
1467
|
}
|
|
274
1468
|
|
|
1469
|
+
if (msg.id !== undefined && msg.result) {
|
|
1470
|
+
rememberThreadResponse(msg.result);
|
|
1471
|
+
}
|
|
1472
|
+
|
|
275
1473
|
if (!msg.method) return; // 只处理 notifications(有 method)
|
|
276
|
-
if (msg.id !== undefined && msg.id !== null) return; // 忽略 request responses
|
|
277
1474
|
|
|
278
1475
|
const params = msg.params || {};
|
|
279
1476
|
const ts = new Date().toISOString();
|
|
1477
|
+
const method = msg.method;
|
|
1478
|
+
|
|
1479
|
+
// thread/started — 捕获线程元数据;parentThreadId/source/threadSource 用于识别 subAgent
|
|
1480
|
+
if (method === 'thread/started') {
|
|
1481
|
+
rememberThread(params.thread || {});
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
const threadId = params.threadId
|
|
1486
|
+
|| params.conversationId
|
|
1487
|
+
|| params.thread?.id
|
|
1488
|
+
|| params.turn?.threadId
|
|
1489
|
+
|| params.item?.threadId
|
|
1490
|
+
|| _threadId
|
|
1491
|
+
|| _mainThreadId;
|
|
1492
|
+
const state = getThreadState(threadId);
|
|
1493
|
+
syncGlobalsFromState(state);
|
|
1494
|
+
|
|
280
1495
|
const base = {
|
|
281
1496
|
timestamp: ts,
|
|
282
1497
|
project: _currentProject || 'codex',
|
|
@@ -285,185 +1500,355 @@ function parseServerMessage(msg) {
|
|
|
285
1500
|
_appServerSource: true,
|
|
286
1501
|
};
|
|
287
1502
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
//
|
|
291
|
-
if (
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
1503
|
+
// Server requests with an id are part of the app-server protocol as well.
|
|
1504
|
+
// For transcript purposes, preserve the question-card input shape consumed
|
|
1505
|
+
// by ChatView, but keep the Codex-native tool name in new app-server logs.
|
|
1506
|
+
if (msg.id !== undefined && msg.id !== null) {
|
|
1507
|
+
if (method === 'item/tool/requestUserInput') {
|
|
1508
|
+
const questions = normalizeRequestUserInputQuestions(params.questions || []);
|
|
1509
|
+
const toolId = params.itemId || `request-user-input-${msg.id}`;
|
|
1510
|
+
upsertToolUse(state, toolId, CODEX_ASK_TOOL_NAME, {
|
|
1511
|
+
questions,
|
|
1512
|
+
autoResolutionMs: params.autoResolutionMs ?? null,
|
|
1513
|
+
codexRequestUserInput: true,
|
|
1514
|
+
});
|
|
1515
|
+
_pendingServerRequests.set(String(msg.id), {
|
|
1516
|
+
kind: 'requestUserInput',
|
|
1517
|
+
threadId: state.threadId,
|
|
1518
|
+
turnId: params.turnId || state.turnId,
|
|
1519
|
+
itemId: toolId,
|
|
1520
|
+
questions,
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
if (method === 'mcpServer/elicitation/request') {
|
|
1524
|
+
const questions = normalizeMcpElicitationQuestions(params);
|
|
1525
|
+
const toolId = params.elicitationId || `mcp-elicitation-${msg.id}`;
|
|
1526
|
+
upsertToolUse(state, toolId, CODEX_ASK_TOOL_NAME, {
|
|
1527
|
+
questions,
|
|
1528
|
+
codexMcpElicitation: true,
|
|
1529
|
+
mode: params.mode,
|
|
1530
|
+
serverName: params.serverName,
|
|
1531
|
+
requestedSchema: cloneJson(params.requestedSchema),
|
|
1532
|
+
url: params.url,
|
|
1533
|
+
elicitationId: params.elicitationId,
|
|
1534
|
+
});
|
|
1535
|
+
_pendingServerRequests.set(String(msg.id), {
|
|
1536
|
+
kind: 'mcpElicitation',
|
|
1537
|
+
threadId: state.threadId,
|
|
1538
|
+
turnId: params.turnId || state.turnId,
|
|
1539
|
+
itemId: toolId,
|
|
1540
|
+
questions,
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
const descriptor = describeServerRequest(method, params);
|
|
1544
|
+
if (descriptor) {
|
|
1545
|
+
writeServerRequestEntry(base, state, msg.id, method, params, descriptor);
|
|
1546
|
+
const previous = _pendingServerRequests.get(String(msg.id)) || {};
|
|
1547
|
+
_pendingServerRequests.set(String(msg.id), {
|
|
1548
|
+
...previous,
|
|
1549
|
+
kind: previous.kind || descriptor.kind,
|
|
1550
|
+
method,
|
|
1551
|
+
requestId: msg.id,
|
|
1552
|
+
threadId: previous.threadId || state.threadId,
|
|
1553
|
+
turnId: previous.turnId || params.turnId || state.turnId,
|
|
1554
|
+
itemId: previous.itemId || params.itemId || params.callId,
|
|
1555
|
+
name: descriptor.name,
|
|
1556
|
+
});
|
|
1557
|
+
}
|
|
295
1558
|
return;
|
|
296
1559
|
}
|
|
297
1560
|
|
|
298
1561
|
// turn/started — 捕获 turn 元数据
|
|
299
1562
|
if (method === 'turn/started') {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
1563
|
+
state.turnStartTime = Date.now();
|
|
1564
|
+
state.pendingContent = [];
|
|
1565
|
+
state.turnId = params.turn?.id || params.turnId || state.turnId;
|
|
1566
|
+
state.turnStatus = params.turn?.status || 'inProgress';
|
|
1567
|
+
state.turnPlan = null;
|
|
1568
|
+
state.turnPlanToolId = null;
|
|
1569
|
+
state.turnDiff = null;
|
|
1570
|
+
state.turnModerationMetadata = null;
|
|
1571
|
+
state.modelReroutes = [];
|
|
1572
|
+
state.modelVerifications = [];
|
|
1573
|
+
state.safetyBuffering = null;
|
|
1574
|
+
state.warnings = [];
|
|
1575
|
+
state.itemSnapshots = new Map();
|
|
1576
|
+
state.itemOrder = [];
|
|
1577
|
+
state.completedItemIds = new Set();
|
|
1578
|
+
if (params.threadId && params.threadId !== state.threadId) {
|
|
1579
|
+
state.threadId = params.threadId;
|
|
1580
|
+
}
|
|
1581
|
+
syncGlobalsFromState(state);
|
|
304
1582
|
return;
|
|
305
1583
|
}
|
|
306
1584
|
|
|
307
|
-
// turn/completed —
|
|
1585
|
+
// turn/completed — 发出根线程或 subAgent 的完整 turn entry
|
|
308
1586
|
if (method === 'turn/completed') {
|
|
309
1587
|
const turn = params.turn || {};
|
|
310
|
-
|
|
311
|
-
if (
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
1588
|
+
state.turnStatus = turn.status;
|
|
1589
|
+
if (turn.id && state.emittedTurnIds.has(turn.id)) {
|
|
1590
|
+
state.pendingContent = [];
|
|
1591
|
+
syncGlobalsFromState(state);
|
|
1592
|
+
resetRawTurnFrames();
|
|
1593
|
+
_turnActive = false;
|
|
1594
|
+
return;
|
|
1595
|
+
}
|
|
1596
|
+
flushSnapshotItemsAtTurnEnd(state, base);
|
|
1597
|
+
if (state.pendingContent.length > 0 || state.turnPlan || state.turnDiff) {
|
|
1598
|
+
const responseContent = state.pendingContent.length > 0
|
|
1599
|
+
? state.pendingContent
|
|
1600
|
+
: (state.turnPlan ? [{ type: 'text', text: formatTurnPlan(state.turnPlan) }] : []);
|
|
1601
|
+
state.messages.push({ role: 'assistant', content: responseContent });
|
|
1602
|
+
emitMainAgentEntry(ts, responseContent, turn, state);
|
|
1603
|
+
state.pendingContent = [];
|
|
1604
|
+
} else if (turn.status === 'failed' || turn.error) {
|
|
1605
|
+
writeEntry({
|
|
1606
|
+
...base,
|
|
1607
|
+
url: 'codex://error',
|
|
1608
|
+
method: 'POST',
|
|
1609
|
+
body: buildFullRequestBody(state, state.threadId),
|
|
1610
|
+
response: {
|
|
1611
|
+
status: 500, statusText: 'Error', headers: {},
|
|
1612
|
+
body: { error: turn.error || params.error || turn },
|
|
1613
|
+
},
|
|
1614
|
+
duration: turn.durationMs || (state.turnStartTime ? Date.now() - state.turnStartTime : 0),
|
|
1615
|
+
...getAgentIdentity(state.threadId),
|
|
1616
|
+
_appServerSource: true,
|
|
1617
|
+
_codexRawRequest: buildRawCodexRequest(),
|
|
1618
|
+
});
|
|
315
1619
|
}
|
|
1620
|
+
if (turn.id) state.emittedTurnIds.add(turn.id);
|
|
1621
|
+
syncGlobalsFromState(state);
|
|
316
1622
|
resetRawTurnFrames();
|
|
317
1623
|
_turnActive = false;
|
|
318
1624
|
return;
|
|
319
1625
|
}
|
|
320
1626
|
|
|
321
|
-
// thread/
|
|
322
|
-
if (method === 'thread/tokenUsageUpdated') {
|
|
323
|
-
|
|
1627
|
+
// thread/tokenUsage/updated — 缓存 token usage(供 emitMainAgentEntry 使用)
|
|
1628
|
+
if (method === 'thread/tokenUsage/updated' || method === 'thread/tokenUsageUpdated') {
|
|
1629
|
+
state.lastTokenUsage = params.tokenUsage || null;
|
|
1630
|
+
syncGlobalsFromState(state);
|
|
324
1631
|
return;
|
|
325
1632
|
}
|
|
326
1633
|
|
|
327
|
-
|
|
328
|
-
if (method === 'item/completed' || method === 'rawResponseItem/completed' || method === 'rawResponseItemCompleted') {
|
|
1634
|
+
if (method === 'item/started') {
|
|
329
1635
|
const item = params.item || {};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
if (type === 'userMessage') {
|
|
334
|
-
const content = item.content || [];
|
|
335
|
-
for (const block of content) {
|
|
336
|
-
if ((block.type === 'text' || block.type === 'input_text') && block.text) {
|
|
337
|
-
_messages.push({ role: 'user', content: block.text });
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
return;
|
|
1636
|
+
rememberItemSnapshot(state, item);
|
|
1637
|
+
if (item.type === 'collabAgentToolCall' || item.type === 'collabToolCall') {
|
|
1638
|
+
registerCollabAgentThreads(item, state.threadId);
|
|
341
1639
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
const content = item.content || [];
|
|
349
|
-
for (const block of content) {
|
|
350
|
-
if (typeof block === 'string' && block) {
|
|
351
|
-
_pendingContent.push({ type: 'text', text: block });
|
|
352
|
-
} else if (block.type === 'output_text' || block.type === 'text') {
|
|
353
|
-
_pendingContent.push({ type: 'text', text: block.text || '' });
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return;
|
|
1640
|
+
if (item.type === 'subAgentActivity') {
|
|
1641
|
+
rememberSubAgentThread(item.agentThreadId, {
|
|
1642
|
+
parentThreadId: state.threadId,
|
|
1643
|
+
agentPath: item.agentPath,
|
|
1644
|
+
agentRole: item.kind,
|
|
1645
|
+
});
|
|
357
1646
|
}
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
358
1649
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
1650
|
+
if (method === 'item/updated' || method === 'rawResponseItem/updated' || method === 'rawResponseItemUpdated' || method === 'itemUpdated') {
|
|
1651
|
+
rememberItemSnapshot(state, params.item || {});
|
|
1652
|
+
syncGlobalsFromState(state);
|
|
1653
|
+
return;
|
|
1654
|
+
}
|
|
367
1655
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
type: 'tool_use',
|
|
376
|
-
id: item.call_id || item.id,
|
|
377
|
-
name: item.name || 'unknown',
|
|
378
|
-
input: args || {},
|
|
379
|
-
});
|
|
380
|
-
writeEntry({
|
|
381
|
-
...base,
|
|
382
|
-
url: `codex://tool/${item.name || 'unknown'}`,
|
|
383
|
-
method: 'TOOL',
|
|
384
|
-
body: { tool_name: item.name, tool_input: args, _callId: item.call_id },
|
|
385
|
-
response: null,
|
|
386
|
-
duration: 0,
|
|
387
|
-
mainAgent: false,
|
|
388
|
-
});
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
1656
|
+
// item/completed — ResponseItem 完成(包含 message、function_call、function_call_output、reasoning 等)
|
|
1657
|
+
if (method === 'item/completed' || method === 'rawResponseItem/completed' || method === 'rawResponseItemCompleted') {
|
|
1658
|
+
const item = rememberItemSnapshot(state, params.item || {});
|
|
1659
|
+
handleCompletedItem(item, state, base);
|
|
1660
|
+
syncGlobalsFromState(state);
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
391
1663
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
1664
|
+
// item/* deltas — 用于 final item 缺失完整字段时兜底重建
|
|
1665
|
+
if (method === 'item/agentMessage/delta' || method === 'agentMessage/delta' || method === 'agentMessageDelta') {
|
|
1666
|
+
const itemId = params.itemId || params.item?.id || 'agentMessage';
|
|
1667
|
+
state.agentMessageDeltas.set(itemId, (state.agentMessageDeltas.get(itemId) || '') + (params.delta || ''));
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
if (method === 'item/plan/delta') {
|
|
1672
|
+
const itemId = params.itemId || 'plan';
|
|
1673
|
+
state.planDeltas.set(itemId, (state.planDeltas.get(itemId) || '') + (params.delta || ''));
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
if (method === 'item/reasoning/summaryTextDelta' || method === 'item/reasoning/textDelta') {
|
|
1678
|
+
const itemId = params.itemId || 'reasoning';
|
|
1679
|
+
state.reasoningDeltas.set(itemId, (state.reasoningDeltas.get(itemId) || '') + (params.delta || ''));
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
if (method === 'item/commandExecution/outputDelta') {
|
|
1684
|
+
const itemId = params.itemId || 'commandExecution';
|
|
1685
|
+
state.commandOutputDeltas.set(itemId, (state.commandOutputDeltas.get(itemId) || '') + (params.delta || ''));
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
if (method === 'item/commandExecution/terminalInteraction') {
|
|
1690
|
+
const itemId = params.itemId || 'commandExecution';
|
|
1691
|
+
const list = state.terminalInteractions.get(itemId) || [];
|
|
1692
|
+
list.push({
|
|
1693
|
+
processId: params.processId,
|
|
1694
|
+
stdin: params.stdin,
|
|
1695
|
+
});
|
|
1696
|
+
state.terminalInteractions.set(itemId, list);
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
if (method === 'command/exec/outputDelta') {
|
|
1701
|
+
const processId = params.processId;
|
|
1702
|
+
if (processId) {
|
|
1703
|
+
const delta = decodeBase64Text(params.deltaBase64);
|
|
1704
|
+
state.commandExecOutputDeltas.set(processId, (state.commandExecOutputDeltas.get(processId) || '') + delta);
|
|
420
1705
|
}
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
421
1708
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
1709
|
+
if (method === 'process/outputDelta') {
|
|
1710
|
+
rememberProcessOutput(state, params);
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
if (method === 'process/exited') {
|
|
1715
|
+
const processHandle = params.processHandle;
|
|
1716
|
+
const output = state.processOutputDeltas.get(processHandle) || {};
|
|
1717
|
+
const stdout = params.stdout || output.stdout || '';
|
|
1718
|
+
const stderr = params.stderr || output.stderr || '';
|
|
1719
|
+
writeEventEntry(base, state, 'process.exited', {
|
|
1720
|
+
processHandle,
|
|
1721
|
+
}, {
|
|
1722
|
+
method: 'PROCESS',
|
|
1723
|
+
url: `codex://process/${encodeURIComponent(processHandle || 'spawn')}`,
|
|
1724
|
+
output: {
|
|
1725
|
+
exitCode: params.exitCode,
|
|
1726
|
+
stdout,
|
|
1727
|
+
stderr,
|
|
1728
|
+
stdoutCapReached: !!(params.stdoutCapReached || output.stdoutCapReached),
|
|
1729
|
+
stderrCapReached: !!(params.stderrCapReached || output.stderrCapReached),
|
|
1730
|
+
},
|
|
1731
|
+
status: params.exitCode === 0 ? 200 : 500,
|
|
1732
|
+
statusText: params.exitCode === 0 ? 'OK' : 'Error',
|
|
1733
|
+
});
|
|
1734
|
+
if (processHandle) state.processOutputDeltas.delete(processHandle);
|
|
1735
|
+
return;
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
if (method === 'item/fileChange/outputDelta') {
|
|
1739
|
+
const itemId = params.itemId || 'fileChange';
|
|
1740
|
+
state.fileChangeOutputDeltas.set(itemId, (state.fileChangeOutputDeltas.get(itemId) || '') + (params.delta || ''));
|
|
1741
|
+
return;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
if (method === 'item/fileChange/patchUpdated') {
|
|
1745
|
+
const itemId = params.itemId || 'fileChange';
|
|
1746
|
+
state.fileChangePatches.set(itemId, cloneJson(params.changes || []));
|
|
1747
|
+
return;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
if (method === 'item/mcpToolCall/progress') {
|
|
1751
|
+
const itemId = params.itemId || 'mcpToolCall';
|
|
1752
|
+
const list = state.mcpProgressMessages.get(itemId) || [];
|
|
1753
|
+
if (params.message) list.push(params.message);
|
|
1754
|
+
state.mcpProgressMessages.set(itemId, list);
|
|
1755
|
+
return;
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
if (method === 'item/reasoning/summaryPartAdded') {
|
|
1759
|
+
return;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
if (method === 'turn/plan/updated') {
|
|
1763
|
+
state.turnPlan = {
|
|
1764
|
+
plan: cloneJson(params.plan || []),
|
|
1765
|
+
explanation: params.explanation || null,
|
|
1766
|
+
};
|
|
1767
|
+
state.turnPlanToolId = `codex-turn-plan:${params.turnId || state.turnId || state.threadId || 'turn'}`;
|
|
1768
|
+
upsertToolUse(state, state.turnPlanToolId, CODEX_PLAN_TOOL_NAME, buildCodexTurnPlanInput(state.turnPlan));
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
if (method === 'turn/diff/updated') {
|
|
1773
|
+
state.turnDiff = params.diff || '';
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
if (method === 'turn/moderationMetadata') {
|
|
1778
|
+
state.turnModerationMetadata = cloneJson(params.metadata);
|
|
1779
|
+
writeEventEntry(base, state, 'turn.moderationMetadata', params, {
|
|
1780
|
+
url: 'codex://turn/moderationMetadata',
|
|
1781
|
+
});
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
if (method === 'model/rerouted') {
|
|
1786
|
+
state.modelReroutes.push(cloneJson(params));
|
|
1787
|
+
if (params.toModel) {
|
|
1788
|
+
state.model = params.toModel;
|
|
1789
|
+
_currentModel = params.toModel;
|
|
440
1790
|
}
|
|
1791
|
+
writeEventEntry(base, state, 'model.rerouted', params, {
|
|
1792
|
+
url: 'codex://model/rerouted',
|
|
1793
|
+
});
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
441
1796
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
1797
|
+
if (method === 'model/verification') {
|
|
1798
|
+
state.modelVerifications.push(cloneJson(params));
|
|
1799
|
+
writeEventEntry(base, state, 'model.verification', params, {
|
|
1800
|
+
url: 'codex://model/verification',
|
|
1801
|
+
});
|
|
1802
|
+
return;
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
if (method === 'model/safetyBuffering/updated') {
|
|
1806
|
+
state.safetyBuffering = cloneJson(params);
|
|
1807
|
+
writeEventEntry(base, state, 'model.safetyBuffering.updated', params, {
|
|
1808
|
+
url: 'codex://model/safetyBuffering',
|
|
1809
|
+
});
|
|
1810
|
+
return;
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1813
|
+
if (method === 'warning' || method === 'guardianWarning' || method === 'configWarning'
|
|
1814
|
+
|| method === 'deprecationNotice' || method === 'windows/worldWritableWarning') {
|
|
1815
|
+
state.warnings.push({ method, ...cloneJson(params) });
|
|
1816
|
+
writeEventEntry(base, state, method.replace(/\//g, '.'), params, {
|
|
1817
|
+
url: `codex://warning/${encodeURIComponent(method)}`,
|
|
1818
|
+
status: 299,
|
|
1819
|
+
statusText: 'Warning',
|
|
1820
|
+
});
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
if (method === 'item/autoApprovalReview/started' || method === 'item/autoApprovalReview/completed') {
|
|
1825
|
+
writeEventEntry(base, state, method.replace(/\//g, '.'), params, {
|
|
1826
|
+
url: `codex://approval/${encodeURIComponent(params.reviewId || method)}`,
|
|
1827
|
+
});
|
|
1828
|
+
return;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
if (method === 'serverRequest/resolved') {
|
|
1832
|
+
const pending = _pendingServerRequests.get(String(params.requestId));
|
|
1833
|
+
writeEventEntry(base, state, 'serverRequest.resolved', {
|
|
1834
|
+
...params,
|
|
1835
|
+
...(pending ? {
|
|
1836
|
+
pendingMethod: pending.method,
|
|
1837
|
+
pendingKind: pending.kind,
|
|
1838
|
+
pendingName: pending.name,
|
|
1839
|
+
pendingItemId: pending.itemId,
|
|
1840
|
+
} : {}),
|
|
1841
|
+
}, {
|
|
1842
|
+
url: `codex://server_request_resolved/${encodeURIComponent(String(params.requestId || 'unknown'))}`,
|
|
1843
|
+
});
|
|
1844
|
+
if (pending?.responded) {
|
|
1845
|
+
_pendingServerRequests.delete(String(params.requestId));
|
|
462
1846
|
}
|
|
1847
|
+
return;
|
|
463
1848
|
}
|
|
464
1849
|
|
|
465
|
-
|
|
466
|
-
|
|
1850
|
+
if (method === 'hook/started' || method === 'hook/completed') {
|
|
1851
|
+
// Hook events are internal implementation details; suppressed from the log.
|
|
467
1852
|
return;
|
|
468
1853
|
}
|
|
469
1854
|
|
|
@@ -473,13 +1858,13 @@ function parseServerMessage(msg) {
|
|
|
473
1858
|
...base,
|
|
474
1859
|
url: 'codex://error',
|
|
475
1860
|
method: 'POST',
|
|
476
|
-
body: buildFullRequestBody(),
|
|
1861
|
+
body: buildFullRequestBody(state, state.threadId),
|
|
477
1862
|
response: {
|
|
478
1863
|
status: 500, statusText: 'Error', headers: {},
|
|
479
1864
|
body: { error: params.error || params },
|
|
480
1865
|
},
|
|
481
|
-
duration:
|
|
482
|
-
|
|
1866
|
+
duration: state.turnStartTime ? Date.now() - state.turnStartTime : 0,
|
|
1867
|
+
...getAgentIdentity(state.threadId),
|
|
483
1868
|
_appServerSource: true,
|
|
484
1869
|
_codexRawRequest: buildRawCodexRequest(),
|
|
485
1870
|
});
|
|
@@ -491,18 +1876,56 @@ function parseServerMessage(msg) {
|
|
|
491
1876
|
* 解析 client → server 的 JSON-RPC request(提取用户输入)
|
|
492
1877
|
*/
|
|
493
1878
|
function parseClientMessage(msg) {
|
|
494
|
-
if (!msg
|
|
1879
|
+
if (!msg) return;
|
|
1880
|
+
|
|
1881
|
+
if (!msg.method) {
|
|
1882
|
+
captureRawClientFrame(msg);
|
|
1883
|
+
if (msg.id !== undefined && msg.id !== null) {
|
|
1884
|
+
const pending = _pendingServerRequests.get(String(msg.id));
|
|
1885
|
+
if (pending?.kind === 'requestUserInput' || pending?.kind === 'mcpElicitation') {
|
|
1886
|
+
if (!pending.responded) {
|
|
1887
|
+
const state = getThreadState(pending.threadId);
|
|
1888
|
+
appendToolResultMessage(
|
|
1889
|
+
state,
|
|
1890
|
+
pending.itemId,
|
|
1891
|
+
msg.error
|
|
1892
|
+
? `[cx-viewer:cancel] ${msg.error.message || stringifyValue(msg.error)}`
|
|
1893
|
+
: (pending.kind === 'mcpElicitation'
|
|
1894
|
+
? formatMcpElicitationResult(pending, msg.result || {})
|
|
1895
|
+
: formatAskUserInputResult(pending, msg.result || {}))
|
|
1896
|
+
);
|
|
1897
|
+
if (pending.kind === 'mcpElicitation' && pending.method) {
|
|
1898
|
+
writeServerRequestResolutionEntry(pending, msg);
|
|
1899
|
+
}
|
|
1900
|
+
pending.responded = true;
|
|
1901
|
+
pending.response = msg.error || msg.result || null;
|
|
1902
|
+
syncGlobalsFromState(state);
|
|
1903
|
+
}
|
|
1904
|
+
} else if (pending) {
|
|
1905
|
+
if (!pending.responded) {
|
|
1906
|
+
writeServerRequestResolutionEntry(pending, msg);
|
|
1907
|
+
pending.responded = true;
|
|
1908
|
+
pending.response = msg.error || msg.result || null;
|
|
1909
|
+
syncGlobalsFromState(getThreadState(pending.threadId));
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
return;
|
|
1914
|
+
}
|
|
495
1915
|
|
|
496
1916
|
// turn/start — 用户发起新 turn(捕获完整上下文)
|
|
497
1917
|
if (msg.method === 'turn/start') {
|
|
498
1918
|
captureRawClientFrame(msg, { startNewTurn: true });
|
|
499
1919
|
const params = msg.params || {};
|
|
500
1920
|
_currentModel = params.model || _currentModel;
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
1921
|
+
const state = getThreadState(params.threadId || _threadId || _mainThreadId);
|
|
1922
|
+
state.model = params.model || state.model || _currentModel;
|
|
1923
|
+
state.turnStartTime = Date.now();
|
|
1924
|
+
state.pendingContent = [];
|
|
1925
|
+
state.threadId = params.threadId || state.threadId;
|
|
1926
|
+
state.cwd = params.cwd || state.cwd || _cwd;
|
|
504
1927
|
// 保存完整 turn 参数供 buildFullRequestBody 使用
|
|
505
|
-
|
|
1928
|
+
state.turnContext = {
|
|
506
1929
|
approvalPolicy: params.approvalPolicy,
|
|
507
1930
|
effort: params.effort,
|
|
508
1931
|
summary: params.summary,
|
|
@@ -510,8 +1933,28 @@ function parseClientMessage(msg) {
|
|
|
510
1933
|
cwd: params.cwd,
|
|
511
1934
|
model: params.model,
|
|
512
1935
|
outputSchema: params.outputSchema,
|
|
1936
|
+
serviceTier: params.serviceTier,
|
|
1937
|
+
personality: params.personality,
|
|
1938
|
+
approvalsReviewer: params.approvalsReviewer,
|
|
513
1939
|
};
|
|
1940
|
+
appendUserMessage(state, params.input || [], params.clientUserMessageId);
|
|
514
1941
|
if (params.cwd) _cwd = params.cwd;
|
|
1942
|
+
syncGlobalsFromState(state);
|
|
1943
|
+
return;
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
// turn/steer — 同一 active turn 内追加用户输入,不开启新 turn
|
|
1947
|
+
if (msg.method === 'turn/steer') {
|
|
1948
|
+
captureRawClientFrame(msg);
|
|
1949
|
+
const params = msg.params || {};
|
|
1950
|
+
const state = getThreadState(params.threadId || _threadId || _mainThreadId);
|
|
1951
|
+
if (params.expectedTurnId) state.turnId = params.expectedTurnId;
|
|
1952
|
+
if (params.threadId && params.threadId !== state.threadId) {
|
|
1953
|
+
state.threadId = params.threadId;
|
|
1954
|
+
}
|
|
1955
|
+
flushAssistantContent(state);
|
|
1956
|
+
appendUserMessage(state, params.input || [], params.clientUserMessageId);
|
|
1957
|
+
syncGlobalsFromState(state);
|
|
515
1958
|
return;
|
|
516
1959
|
}
|
|
517
1960
|
|
|
@@ -519,6 +1962,7 @@ function parseClientMessage(msg) {
|
|
|
519
1962
|
if (msg.method === 'thread/start') {
|
|
520
1963
|
captureRawClientFrame(msg, { startNewSession: true });
|
|
521
1964
|
const params = msg.params || {};
|
|
1965
|
+
resetThreadRuntimeState();
|
|
522
1966
|
_cwd = params.cwd || _cwd;
|
|
523
1967
|
_currentProject = params.cwd ? basename(params.cwd) : _currentProject;
|
|
524
1968
|
_systemPrompt = _pickSystemPrompt(
|
|
@@ -531,12 +1975,62 @@ function parseClientMessage(msg) {
|
|
|
531
1975
|
_pendingContent = [];
|
|
532
1976
|
_threadMeta = {};
|
|
533
1977
|
_turnContext = {};
|
|
1978
|
+
_threadId = null;
|
|
1979
|
+
_turnId = null;
|
|
534
1980
|
return;
|
|
535
1981
|
}
|
|
536
1982
|
|
|
537
1983
|
captureRawClientFrame(msg);
|
|
538
1984
|
}
|
|
539
1985
|
|
|
1986
|
+
export function _resetAppServerBridgeForTests({
|
|
1987
|
+
logFile = null,
|
|
1988
|
+
cwd = '/tmp/codex-project',
|
|
1989
|
+
project = 'codex-project',
|
|
1990
|
+
model = null,
|
|
1991
|
+
writeLogEntry = null,
|
|
1992
|
+
} = {}) {
|
|
1993
|
+
_logFile = logFile;
|
|
1994
|
+
_writeLogEntry = typeof writeLogEntry === 'function' ? writeLogEntry : null;
|
|
1995
|
+
_currentModel = model;
|
|
1996
|
+
_currentProject = project;
|
|
1997
|
+
_cwd = cwd;
|
|
1998
|
+
_messages = [];
|
|
1999
|
+
_pendingContent = [];
|
|
2000
|
+
_threadId = null;
|
|
2001
|
+
_turnId = null;
|
|
2002
|
+
_serverInfo = null;
|
|
2003
|
+
_turnContext = {};
|
|
2004
|
+
_threadMeta = {};
|
|
2005
|
+
_systemPrompt = null;
|
|
2006
|
+
_lastTokenUsage = null;
|
|
2007
|
+
_turnStatus = null;
|
|
2008
|
+
resetThreadRuntimeState();
|
|
2009
|
+
resetRawSessionFrames();
|
|
2010
|
+
resetRawTurnFrames();
|
|
2011
|
+
_turnActive = false;
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
export function _parseAppServerClientMessageForTests(msg) {
|
|
2015
|
+
parseClientMessage(msg);
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
export function _injectApprovalsReviewerForTests(msg, value) {
|
|
2019
|
+
const previous = _approvalsReviewerOverride;
|
|
2020
|
+
if (value !== undefined) setApprovalsReviewer(value);
|
|
2021
|
+
const injected = injectApprovalsReviewer(msg);
|
|
2022
|
+
_approvalsReviewerOverride = previous;
|
|
2023
|
+
return injected;
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
export function _parseAppServerServerMessageForTests(msg) {
|
|
2027
|
+
parseServerMessage(msg);
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
export function _writeAppServerEntryForTests(entry) {
|
|
2031
|
+
writeEntry(entry);
|
|
2032
|
+
}
|
|
2033
|
+
|
|
540
2034
|
/**
|
|
541
2035
|
* 启动 App-Server Bridge
|
|
542
2036
|
*
|
|
@@ -548,11 +2042,14 @@ function parseClientMessage(msg) {
|
|
|
548
2042
|
* @returns {Promise<{ proxyPort: number, appServerPort: number, stop: Function }>}
|
|
549
2043
|
*/
|
|
550
2044
|
export async function startAppServerBridge(options) {
|
|
551
|
-
const { cwd, codexPath, logFile, env = process.env } = options;
|
|
2045
|
+
const { cwd, codexPath, logFile, env = process.env, extraConfigArgs = [], onApprovalsReviewerActive = null, writeLogEntry = null } = options;
|
|
2046
|
+
_onApprovalsReviewerActive = typeof onApprovalsReviewerActive === 'function' ? onApprovalsReviewerActive : null;
|
|
2047
|
+
_writeLogEntry = typeof writeLogEntry === 'function' ? writeLogEntry : null;
|
|
552
2048
|
_logFile = logFile;
|
|
553
2049
|
_currentModel = null;
|
|
554
2050
|
_currentProject = cwd ? basename(cwd) : 'codex';
|
|
555
2051
|
_cwd = cwd;
|
|
2052
|
+
resetThreadRuntimeState();
|
|
556
2053
|
_messages = [];
|
|
557
2054
|
_pendingContent = [];
|
|
558
2055
|
_threadId = null;
|
|
@@ -571,8 +2068,14 @@ export async function startAppServerBridge(options) {
|
|
|
571
2068
|
const appServerPort = await findFreePort();
|
|
572
2069
|
const proxyPort = await findFreePort();
|
|
573
2070
|
|
|
574
|
-
// 2. 启动 codex app-server
|
|
2071
|
+
// 2. 启动 codex app-server
|
|
2072
|
+
// The HTTP proxy is started by cli.js before calling us; the -c
|
|
2073
|
+
// openai_base_url=... flag in extraConfigArgs routes the app-server's model
|
|
2074
|
+
// traffic through it. Clear any stale OPENAI_BASE_URL from the environment
|
|
2075
|
+
// so it does not conflict with the -c override.
|
|
575
2076
|
const appEnv = { ...env };
|
|
2077
|
+
delete appEnv.OPENAI_BASE_URL;
|
|
2078
|
+
delete appEnv.CXV_ORIGINAL_BASE_URL;
|
|
576
2079
|
if (!appEnv.HTTPS_PROXY && !appEnv.HTTP_PROXY && !appEnv.https_proxy && !appEnv.http_proxy) {
|
|
577
2080
|
try {
|
|
578
2081
|
const shell = process.env.SHELL || '/bin/zsh';
|
|
@@ -589,7 +2092,10 @@ export async function startAppServerBridge(options) {
|
|
|
589
2092
|
}
|
|
590
2093
|
|
|
591
2094
|
let command = codexPath;
|
|
592
|
-
|
|
2095
|
+
// extraConfigArgs (e.g. -c openai_base_url="...") redirect the app-server
|
|
2096
|
+
// child's model traffic through the cxv proxy. `-c` is a global Codex flag so
|
|
2097
|
+
// position relative to the `app-server` subcommand does not matter.
|
|
2098
|
+
let appServerArgs = [...extraConfigArgs, 'app-server', '--listen', `ws://127.0.0.1:${appServerPort}`];
|
|
593
2099
|
// npm 版 codex 是 .js 文件,需要 node 运行
|
|
594
2100
|
if (codexPath.endsWith('.js')) {
|
|
595
2101
|
command = process.execPath;
|
|
@@ -634,9 +2140,16 @@ export async function startAppServerBridge(options) {
|
|
|
634
2140
|
|
|
635
2141
|
// client → proxy → upstream
|
|
636
2142
|
clientWs.on('message', (data) => {
|
|
637
|
-
const
|
|
2143
|
+
const original = typeof data === 'string' ? data : data.toString();
|
|
2144
|
+
let str = original;
|
|
638
2145
|
try {
|
|
639
|
-
|
|
2146
|
+
const msg = injectApprovalsReviewer(JSON.parse(original));
|
|
2147
|
+
str = JSON.stringify(msg);
|
|
2148
|
+
parseClientMessage(msg);
|
|
2149
|
+
if (REVIEWER_LIFECYCLE_METHODS.has(msg.method)
|
|
2150
|
+
&& isSupportedApprovalsReviewer(msg.params?.approvalsReviewer)) {
|
|
2151
|
+
_onApprovalsReviewerActive?.(normalizeApprovalsReviewer(msg.params.approvalsReviewer));
|
|
2152
|
+
}
|
|
640
2153
|
} catch {}
|
|
641
2154
|
|
|
642
2155
|
if (upstreamReady) {
|
|
@@ -674,7 +2187,10 @@ export async function startAppServerBridge(options) {
|
|
|
674
2187
|
return {
|
|
675
2188
|
proxyPort,
|
|
676
2189
|
appServerPort,
|
|
2190
|
+
setApprovalsReviewer,
|
|
677
2191
|
stop() {
|
|
2192
|
+
_onApprovalsReviewerActive = null;
|
|
2193
|
+
_writeLogEntry = null;
|
|
678
2194
|
if (_proxyServer) { _proxyServer.close(); _proxyServer = null; }
|
|
679
2195
|
if (_upstreamWs) { _upstreamWs.close(); _upstreamWs = null; }
|
|
680
2196
|
if (_appServerProcess) { _appServerProcess.kill(); _appServerProcess = null; }
|