agentroam-runtime-darwin-arm64 0.2.0-preview.37 → 0.2.0-preview.39

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.
Files changed (203) hide show
  1. package/manifest.json +2 -2
  2. package/package.json +1 -1
  3. package/runtime/.next/BUILD_ID +1 -1
  4. package/runtime/.next/app-build-manifest.json +14 -14
  5. package/runtime/.next/app-path-routes-manifest.json +1 -1
  6. package/runtime/.next/build-manifest.json +6 -6
  7. package/runtime/.next/prerender-manifest.json +1 -1
  8. package/runtime/.next/react-loadable-manifest.json +12 -4
  9. package/runtime/.next/required-server-files.json +1 -1
  10. package/runtime/.next/routes-manifest.json +1 -1
  11. package/runtime/.next/server/app/_not-found/page.js +1 -1
  12. package/runtime/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/runtime/.next/server/app/_not-found.html +1 -1
  14. package/runtime/.next/server/app/_not-found.rsc +1 -1
  15. package/runtime/.next/server/app/api/agent/abort/route.js +1 -1
  16. package/runtime/.next/server/app/api/agent/answer/route.js +1 -1
  17. package/runtime/.next/server/app/api/agent/harness/status/route.js +1 -1
  18. package/runtime/.next/server/app/api/agent/model/route.js +1 -1
  19. package/runtime/.next/server/app/api/agent/models/route.js +1 -1
  20. package/runtime/.next/server/app/api/agent/run/route.js +3 -3
  21. package/runtime/.next/server/app/api/agent/runtime-health/route.js +1 -1
  22. package/runtime/.next/server/app/api/agent/steer/route.js +1 -1
  23. package/runtime/.next/server/app/api/agent/stream/route.js +3 -3
  24. package/runtime/.next/server/app/api/agent-workspaces/[workspaceId]/sessions/route.js +1 -1
  25. package/runtime/.next/server/app/api/agent-workspaces/route.js +1 -1
  26. package/runtime/.next/server/app/api/auth/verify/route.js +1 -1
  27. package/runtime/.next/server/app/api/business/route.js +1 -1
  28. package/runtime/.next/server/app/api/client-logs/route.js +1 -1
  29. package/runtime/.next/server/app/api/flow/v1/catalog/route.js +1 -1
  30. package/runtime/.next/server/app/api/flow/v1/runs/[runId]/cancel/route.js +1 -1
  31. package/runtime/.next/server/app/api/flow/v1/runs/[runId]/events/route.js +2 -2
  32. package/runtime/.next/server/app/api/flow/v1/runs/route.js +1 -1
  33. package/runtime/.next/server/app/api/flow-studio/config/route.js +1 -1
  34. package/runtime/.next/server/app/api/mcp/connect/route.js +1 -1
  35. package/runtime/.next/server/app/api/mcp/disconnect/route.js +1 -1
  36. package/runtime/.next/server/app/api/mcp/servers/route.js +1 -1
  37. package/runtime/.next/server/app/api/memory/[key]/route.js +1 -1
  38. package/runtime/.next/server/app/api/memory/route.js +1 -1
  39. package/runtime/.next/server/app/api/plugins/load/route.js +1 -1
  40. package/runtime/.next/server/app/api/projects/[id]/route.js +1 -1
  41. package/runtime/.next/server/app/api/projects/check/route.js +1 -1
  42. package/runtime/.next/server/app/api/projects/directories/route.js +1 -1
  43. package/runtime/.next/server/app/api/projects/roots/route.js +1 -1
  44. package/runtime/.next/server/app/api/projects/route.js +1 -1
  45. package/runtime/.next/server/app/api/push/subscribe/route.js +2 -2
  46. package/runtime/.next/server/app/api/push/unsubscribe/route.js +2 -2
  47. package/runtime/.next/server/app/api/push/vapid/route.js +2 -2
  48. package/runtime/.next/server/app/api/push/vapid.body +1 -1
  49. package/runtime/.next/server/app/api/remote-tools/register/route.js +1 -1
  50. package/runtime/.next/server/app/api/sessions/[id]/changes/route.js +2 -2
  51. package/runtime/.next/server/app/api/sessions/[id]/fork/route.js +1 -1
  52. package/runtime/.next/server/app/api/sessions/[id]/fork/route.js.nft.json +1 -1
  53. package/runtime/.next/server/app/api/sessions/[id]/fork-at/route.js +1 -0
  54. package/runtime/.next/server/app/api/sessions/[id]/fork-at/route.js.nft.json +1 -0
  55. package/runtime/.next/server/app/api/sessions/[id]/goals/route.js +1 -1
  56. package/runtime/.next/server/app/api/sessions/[id]/handoff/route.js +1 -1
  57. package/runtime/.next/server/app/api/sessions/[id]/query-index/route.js +1 -1
  58. package/runtime/.next/server/app/api/sessions/[id]/release/route.js +1 -1
  59. package/runtime/.next/server/app/api/sessions/[id]/route.js +1 -1
  60. package/runtime/.next/server/app/api/sessions/[id]/thread-goal/route.js +1 -1
  61. package/runtime/.next/server/app/api/sessions/[id]/tool-result/route.js +1 -1
  62. package/runtime/.next/server/app/api/sessions/route.js +1 -1
  63. package/runtime/.next/server/app/api/settings/route.js +1 -1
  64. package/runtime/.next/server/app/api/skills/route.js +1 -1
  65. package/runtime/.next/server/app/api/tool-policies/[policyId]/route.js +1 -1
  66. package/runtime/.next/server/app/api/tool-policies/route.js +1 -1
  67. package/runtime/.next/server/app/api/tools/route.js +1 -1
  68. package/runtime/.next/server/app/api/update/check/route.js +1 -1
  69. package/runtime/.next/server/app/api/update/install/route.js +1 -1
  70. package/runtime/.next/server/app/api/update/status/route.js +1 -1
  71. package/runtime/.next/server/app/api/web-auth/login/route.js +1 -1
  72. package/runtime/.next/server/app/api/web-auth/logout/route.js +1 -1
  73. package/runtime/.next/server/app/api/web-auth/revoke-all/route.js +1 -1
  74. package/runtime/.next/server/app/api/web-auth/setup/route.js +1 -1
  75. package/runtime/.next/server/app/api/web-auth/status/route.js +1 -1
  76. package/runtime/.next/server/app/api/web-console/bootstrap/route.js +1 -1
  77. package/runtime/.next/server/app/api/web-console/device-state/route.js +1 -1
  78. package/runtime/.next/server/app/api/web-console/history/route.js +1 -1
  79. package/runtime/.next/server/app/api/web-console/preferences/route.js +1 -1
  80. package/runtime/.next/server/app/web/page.js +2 -2
  81. package/runtime/.next/server/app/web/page_client-reference-manifest.js +1 -1
  82. package/runtime/.next/server/app-paths-manifest.json +20 -19
  83. package/runtime/.next/server/chunks/1322.js +72 -69
  84. package/runtime/.next/server/chunks/1773.js +38 -38
  85. package/runtime/.next/server/chunks/2293.js +1 -1
  86. package/runtime/.next/server/chunks/366.js +1 -0
  87. package/runtime/.next/server/chunks/5303.js +1 -1
  88. package/runtime/.next/server/chunks/8532.js +1 -1
  89. package/runtime/.next/server/middleware-build-manifest.js +1 -1
  90. package/runtime/.next/server/middleware-react-loadable-manifest.js +1 -1
  91. package/runtime/.next/server/pages/404.html +1 -1
  92. package/runtime/.next/server/pages/500.html +1 -1
  93. package/runtime/.next/server/server-reference-manifest.json +1 -1
  94. package/runtime/.next/static/chunks/326.567dcaf52a3fbf80.js +1 -0
  95. package/runtime/.next/static/chunks/693-41d7c8e27a8513d1.js +1 -0
  96. package/runtime/.next/static/chunks/784.1394d774230a5516.js +1 -0
  97. package/runtime/.next/static/chunks/834.801325c7f934eee6.js +1 -0
  98. package/runtime/.next/static/chunks/940.56137a61c838fa42.js +1 -0
  99. package/runtime/.next/static/chunks/95.ff2ef92ac2b1c909.js +1 -0
  100. package/runtime/.next/static/chunks/app/web/{error-7bdc841dab0f7345.js → error-f69dbd3718cb2107.js} +1 -1
  101. package/runtime/.next/static/chunks/app/web/layout-e0dd41d18df8ee9e.js +1 -0
  102. package/runtime/.next/static/chunks/app/web/page-f9926cbf4c1badd4.js +1 -0
  103. package/runtime/.next/static/chunks/{main-app-851d67ddcf02e2c2.js → main-app-d527fa0b25a0c755.js} +1 -1
  104. package/runtime/.next/static/chunks/webpack-d4e32619d2ce6d30.js +1 -0
  105. package/runtime/.next/static/css/e87416656ec8a57e.css +1 -0
  106. package/runtime/lib/remote-control/helper-manager.mjs +4 -1
  107. package/runtime/lib/remote-control/remote-authorization.mjs +21 -7
  108. package/runtime/native/AgentRoam Remote Desktop.app/Contents/MacOS/agentroam-remote-desktop +0 -0
  109. package/runtime/node_modules/.package-lock.json +11 -11
  110. package/runtime/node_modules/@agent/core/dist/index.js +123 -9
  111. package/runtime/node_modules/@agent/native-runtime/dist/index.js +141 -35
  112. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/bridge.mjs +77 -76
  113. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/browser-sdk.js +48 -48
  114. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-2haqfy07.mjs +33 -0
  115. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-a92dt75k.mjs +40 -0
  116. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core.mjs +17 -17
  117. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.json +19 -25
  118. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.zst.json +23 -29
  119. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/package.json +12 -12
  120. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs +53 -53
  121. package/runtime/package-lock.json +35 -35
  122. package/runtime/server.js +1 -1
  123. package/runtime/webapp/dist/assets/App-COIcZZvf.js +487 -0
  124. package/runtime/webapp/dist/assets/{App-CMOzoP5A.css → App-iUeP1CBo.css} +1 -1
  125. package/runtime/webapp/dist/assets/{abnfDiagram-VCTEODGH-CEAlrV9-.js → abnfDiagram-VCTEODGH-d4urtMQU.js} +1 -1
  126. package/runtime/webapp/dist/assets/{arc-CGetF_lO.js → arc-DiQEpEJQ.js} +1 -1
  127. package/runtime/webapp/dist/assets/{architectureDiagram-5GKGNRK7-BVksDtm9.js → architectureDiagram-5GKGNRK7-CWYKGqND.js} +1 -1
  128. package/runtime/webapp/dist/assets/{blockDiagram-I7D4REHJ-BvCo3epW.js → blockDiagram-I7D4REHJ-J2I0b5Zn.js} +1 -1
  129. package/runtime/webapp/dist/assets/{c4Diagram-7LVT6UL2-DwUEj82r.js → c4Diagram-7LVT6UL2-C-0xWeN3.js} +1 -1
  130. package/runtime/webapp/dist/assets/channel-B6S3kcST.js +1 -0
  131. package/runtime/webapp/dist/assets/{chunk-2Q5K7J3B-BQmtZUl-.js → chunk-2Q5K7J3B-CqodmK6L.js} +1 -1
  132. package/runtime/webapp/dist/assets/{chunk-5VM5RSS4-BXDY0cCC.js → chunk-5VM5RSS4-DClUnQcr.js} +1 -1
  133. package/runtime/webapp/dist/assets/{chunk-F27PBJKO-BPhfHsOp.js → chunk-F27PBJKO-CpaDg7Bg.js} +1 -1
  134. package/runtime/webapp/dist/assets/{chunk-IMKFNOWR-Dw-LyvaC.js → chunk-IMKFNOWR-CTIf9EjK.js} +1 -1
  135. package/runtime/webapp/dist/assets/{chunk-JWPE2WC7-Cdi61XTf.js → chunk-JWPE2WC7-DKalSWMm.js} +1 -1
  136. package/runtime/webapp/dist/assets/{chunk-POPQ4Y6H-eqgC5BfH.js → chunk-POPQ4Y6H-69MmeyRW.js} +1 -1
  137. package/runtime/webapp/dist/assets/{chunk-SVP7TREG-Dyzqf0xA.js → chunk-SVP7TREG-DCXWXzhU.js} +1 -1
  138. package/runtime/webapp/dist/assets/{chunk-TICWLB2K-DMy_FAyQ.js → chunk-TICWLB2K-B5nbTEng.js} +1 -1
  139. package/runtime/webapp/dist/assets/{chunk-XXDRQBXY-Dc3ya8KM.js → chunk-XXDRQBXY-DsJvkUuN.js} +1 -1
  140. package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-CyUA2YaV.js +1 -0
  141. package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-CyUA2YaV.js +1 -0
  142. package/runtime/webapp/dist/assets/codeSyntax-DJH88FPL.js +5 -0
  143. package/runtime/webapp/dist/assets/{cose-bilkent-JH36ORCC-8SpbJGQ_.js → cose-bilkent-JH36ORCC-BamzQ_e_.js} +1 -1
  144. package/runtime/webapp/dist/assets/{cynefin-OW5HDTMX-DZ8NcP4L.js → cynefin-OW5HDTMX-BI_j1tbW.js} +1 -1
  145. package/runtime/webapp/dist/assets/{cynefinDiagram-5FMLGOSQ-C-g805uS.js → cynefinDiagram-5FMLGOSQ-DuxMrVM2.js} +1 -1
  146. package/runtime/webapp/dist/assets/{dagre-GXQ25YYZ-Cr8OiP_4.js → dagre-GXQ25YYZ-Y9_ne36w.js} +1 -1
  147. package/runtime/webapp/dist/assets/{diagram-S7CK7UJ4-Be71Foqh.js → diagram-S7CK7UJ4-DIIjO29m.js} +1 -1
  148. package/runtime/webapp/dist/assets/{diagram-UQ7AKVKN-CeDsu1RS.js → diagram-UQ7AKVKN-C4m2VMIy.js} +1 -1
  149. package/runtime/webapp/dist/assets/{diagram-VSXAHHWV-CObfkAwP.js → diagram-VSXAHHWV-Cw5aPZ0o.js} +1 -1
  150. package/runtime/webapp/dist/assets/{diagram-VX7I27RA-B6lAuke7.js → diagram-VX7I27RA-W8nmVcOl.js} +1 -1
  151. package/runtime/webapp/dist/assets/{diagram-Z3DM3KII-8oGhKMeq.js → diagram-Z3DM3KII-TksnHlQo.js} +1 -1
  152. package/runtime/webapp/dist/assets/{ebnfDiagram-PWID7BFC-DmiqrULj.js → ebnfDiagram-PWID7BFC-B3WM1b4a.js} +1 -1
  153. package/runtime/webapp/dist/assets/{erDiagram-RLTQ6QDP-BB_7Zdd4.js → erDiagram-RLTQ6QDP-BWctPuya.js} +1 -1
  154. package/runtime/webapp/dist/assets/{flowDiagram-HODETNUW-DbuKFxoO.js → flowDiagram-HODETNUW-BG5RMrLN.js} +1 -1
  155. package/runtime/webapp/dist/assets/{ganttDiagram-EL5Y4UJY-DAM3Gwd_.js → ganttDiagram-EL5Y4UJY-CPcR7Kn_.js} +1 -1
  156. package/runtime/webapp/dist/assets/{gitGraphDiagram-WWUBYQGX-Ci91dL5m.js → gitGraphDiagram-WWUBYQGX-Sg6KChEd.js} +1 -1
  157. package/runtime/webapp/dist/assets/{index-NmsboYZi.css → index-CtJgsVah.css} +1 -1
  158. package/runtime/webapp/dist/assets/{index-ZpxfzUdy.js → index-tQnPGo1_.js} +4 -4
  159. package/runtime/webapp/dist/assets/{infoDiagram-27XIBGKW-D717Ys7n.js → infoDiagram-27XIBGKW-BvrtvnrY.js} +1 -1
  160. package/runtime/webapp/dist/assets/{ishikawaDiagram-5VMMS53U-BF6gmyPX.js → ishikawaDiagram-5VMMS53U-Bz-dZQLJ.js} +1 -1
  161. package/runtime/webapp/dist/assets/{journeyDiagram-3NMN7TZE-B6ZY-IXx.js → journeyDiagram-3NMN7TZE-Cb4s9jRE.js} +1 -1
  162. package/runtime/webapp/dist/assets/{kanban-definition-UXKFOSKX-DH3FR2sI.js → kanban-definition-UXKFOSKX-IjMPUHg9.js} +1 -1
  163. package/runtime/webapp/dist/assets/{layout-BOnxGXiM.js → layout-DHjqr0PJ.js} +1 -1
  164. package/runtime/webapp/dist/assets/{linear-M6pkDoQ3.js → linear-COctZkFy.js} +1 -1
  165. package/runtime/webapp/dist/assets/{mermaid.core-DxK9Epxh.js → mermaid.core-BnonXfHT.js} +5 -5
  166. package/runtime/webapp/dist/assets/{mindmap-definition-YA3MSWOX-DpZ-X_Vf.js → mindmap-definition-YA3MSWOX-hxBlXJJE.js} +1 -1
  167. package/runtime/webapp/dist/assets/{pegDiagram-XKGWAZYB-ZxLpbtO1.js → pegDiagram-XKGWAZYB-D6KJ8Ftm.js} +1 -1
  168. package/runtime/webapp/dist/assets/{pieDiagram-E7YTZNPT-B26_pDmg.js → pieDiagram-E7YTZNPT-BzKWZmHN.js} +1 -1
  169. package/runtime/webapp/dist/assets/{quadrantDiagram-AXDQQJYC-C-qB9cbX.js → quadrantDiagram-AXDQQJYC-ZhiPKt96.js} +1 -1
  170. package/runtime/webapp/dist/assets/{railroadDiagram-O6MQD6OU-C54V-8Ku.js → railroadDiagram-O6MQD6OU-BtKhiOPG.js} +1 -1
  171. package/runtime/webapp/dist/assets/{requirementDiagram-BXWQKSXE-CaMYVKMk.js → requirementDiagram-BXWQKSXE-OFr_TA8V.js} +1 -1
  172. package/runtime/webapp/dist/assets/{sankeyDiagram-P5KCCOFB-DsrVKW_h.js → sankeyDiagram-P5KCCOFB-qNTDFxAX.js} +1 -1
  173. package/runtime/webapp/dist/assets/{sequenceDiagram-WJ2MYXX4-C5ImABz1.js → sequenceDiagram-WJ2MYXX4-B7s5-R4s.js} +1 -1
  174. package/runtime/webapp/dist/assets/{sizeCapture-INFHLROL-wM9HJhkr.js → sizeCapture-INFHLROL-DdFabbN6.js} +1 -1
  175. package/runtime/webapp/dist/assets/{stateDiagram-D77RDMKH-BY8hQ5ro.js → stateDiagram-D77RDMKH-CmAN4pX7.js} +1 -1
  176. package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-DsxpCqde.js +1 -0
  177. package/runtime/webapp/dist/assets/{swimlanes-42K2YHIH-OsTKRKJW.js → swimlanes-42K2YHIH-BQlIJAhf.js} +1 -1
  178. package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-tji3GZVz.js +8 -0
  179. package/runtime/webapp/dist/assets/{timeline-definition-24CTP7MA-DqyQVkVW.js → timeline-definition-24CTP7MA--Y1zJ9mc.js} +1 -1
  180. package/runtime/webapp/dist/assets/{vennDiagram-4TSXK5OY-Di3KXYdD.js → vennDiagram-4TSXK5OY-CUn6FScx.js} +1 -1
  181. package/runtime/webapp/dist/assets/{wardleyDiagram-VM6X3IG4-CnJpZdMd.js → wardleyDiagram-VM6X3IG4-Bbz-WBd5.js} +1 -1
  182. package/runtime/webapp/dist/assets/{web-BMb61xwV.js → web-DzBEnE5q.js} +1 -1
  183. package/runtime/webapp/dist/assets/{web-eq1eso0Y.js → web-harvpkJj.js} +1 -1
  184. package/runtime/webapp/dist/assets/{xychartDiagram-S5SC5T6Z-frC_Dy5B.js → xychartDiagram-S5SC5T6Z-RA9edGdQ.js} +1 -1
  185. package/runtime/webapp/dist/index.html +2 -2
  186. package/runtime/ws-server.mjs +5 -5
  187. package/runtime/.next/static/chunks/221.80fc551c3d6118e2.js +0 -1
  188. package/runtime/.next/static/chunks/326.c10c95f947d32ecb.js +0 -1
  189. package/runtime/.next/static/chunks/750-1766abd7e24fd1d6.js +0 -1
  190. package/runtime/.next/static/chunks/942.1dec0ce762e131a5.js +0 -1
  191. package/runtime/.next/static/chunks/app/web/layout-e5b1780d2961e7c0.js +0 -1
  192. package/runtime/.next/static/chunks/app/web/page-f5171cee114f2892.js +0 -1
  193. package/runtime/.next/static/chunks/webpack-3ff471b94db6b1b2.js +0 -1
  194. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-reghh1vn.mjs +0 -33
  195. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-tm6xdb2r.mjs +0 -40
  196. package/runtime/webapp/dist/assets/App-DQ5fJODJ.js +0 -476
  197. package/runtime/webapp/dist/assets/channel-BjAaNinW.js +0 -1
  198. package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-BA6foNu5.js +0 -1
  199. package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-BA6foNu5.js +0 -1
  200. package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-D7wp4Sey.js +0 -1
  201. package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-Dq79H5La.js +0 -8
  202. /package/runtime/.next/static/{ENg3PaHjA_727MHwcEIkE → BmUH3xLHQfGkG3yzEK37i}/_buildManifest.js +0 -0
  203. /package/runtime/.next/static/{ENg3PaHjA_727MHwcEIkE → BmUH3xLHQfGkG3yzEK37i}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=3610,e.ids=[3610],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},8451:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>m,patchFetch:()=>f,requestAsyncStorage:()=>d,routeModule:()=>c,serverHooks:()=>h,staticGenerationAsyncStorage:()=>p});var s={};r.r(s),r.d(s,{POST:()=>l});var i=r(7786),n=r(5042),a=r(2184),o=r(1890),u=r(1614);async function l(e,{params:t}){if(!(0,u.V_)(t.id)||!t.id.startsWith("runtime:codex:"))return o.NextResponse.json({error:"Only Codex sessions can be released"},{status:405});try{return await (0,u.NL)().release(t.id),o.NextResponse.json({status:"released"})}catch(e){return o.NextResponse.json({error:e instanceof Error?e.message:"Codex release failed"},{status:(0,u.WW)(e)})}}let c=new i.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/sessions/[id]/release/route",pathname:"/api/sessions/[id]/release",filename:"route",bundlePath:"app/api/sessions/[id]/release/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/sessions/[id]/release/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:d,staticGenerationAsyncStorage:p,serverHooks:h}=c,m="/api/sessions/[id]/release/route";function f(){return(0,a.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:p})}},535:(e,t,r)=>{r.d(t,{L:()=>a});var s=r(1322),i=r(785);let n=!1;function a(){let e=(0,s.Qfc)();if(e)return e;let t=(0,s.qZ_)({dir:(0,i.ME)(),source:"server",minLevel:"info",handlers:{exitOnUncaughtException:!1}});return n||(n=!0,t.info("server logger attached",{dir:t.dir,pid:process.pid})),t}},1614:(e,t,r)=>{r.d(t,{NL:()=>O,V_:()=>P,WW:()=>_});var s=r(7561),i=r(612),n=r(9411),a=r(7718),o=r(1322);function u(e){if(!e.trim())return!1;try{return(0,s.accessSync)(e,s.constants.X_OK),!0}catch{return!1}}function l(e){try{return(0,o.wyD)((0,a.execFileSync)(e,["--version"],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","pipe"]}))}catch{return}}function c(e){let t=[],r=process.env[e.environmentVariable]?.trim();if(r){let s=u(r);t.push({source:"pin",path:r,executable:s,version:s?l(r):void 0,error:s?void 0:`${e.environmentVariable} "${r}" is not executable`})}let s=function(e){for(let t of(process.env.PATH??"").split(n.delimiter).filter(Boolean)){let r=(0,n.resolve)(t,e);if(u(r))return r}}(e.name);return s&&s!==r&&t.push({source:"path",path:s,executable:!0,version:l(s)}),(0,o.neJ)(t,{name:e.name,minimumVersion:e.minimumVersion})}var d=r(535),p=r(6279),h=r(785);let m=globalThis;class f{constructor(e,t=async()=>[],r=process.platform){this.runtime=e,this.listProjects=t,this.platform=r,this.pendingCreations=new Map}health(){return this.runtime.health()}listModels(e){return this.runtime.listModels(e)}listWorkspaces(e,t){return this.runtime.listWorkspaces(e,t)}importWorkspace(e,t,r){if(!this.runtime.importWorkspace)throw new p.no("Native workspace import is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.importWorkspace(e,t,r)}async listWorkspaceSessions(e,t,r){let s=await this.runtime.listWorkspaceSessions(e,t,r);if(r?.cursor)return s;let i=new Set(s.data.map(e=>e.id)),n=s.data.map(e=>{let t=this.pendingCreations.get(e.id);return t?(this.pendingCreations.delete(e.id),w(e,t)):e});for(let r of this.pendingCreations.values())r.agentType!==e||r.projectId!==t||i.has(r.id)||n.unshift(r);return{...s,data:n}}async list(e){let[t,r]=await Promise.all([this.runtime.list(),this.listProjects()]);return E(this.withPendingCreations(t).map(e=>v(e,r,this.platform)),e)}async refresh(e){let[t,r]=await Promise.all([this.runtime.refresh(),this.listProjects()]);return E(this.withPendingCreations(t).map(e=>v(e,r,this.platform)),e)}async create(e){let t=v(await this.runtime.create(e),await this.listProjects(),this.platform),r=e.projectId?{...t,projectId:e.projectId}:t;return this.pendingCreations.set(r.id,r),r}async fork(e){if(!P(e))throw new p.no("Customer Agent sessions do not support native forks","OPERATION_NOT_SUPPORTED");let t=v(await this.runtime.fork(e),await this.listProjects(),this.platform);return this.pendingCreations.set(t.id,t),t}async delete(e){await this.runtime.delete(e),this.pendingCreations.delete(e)}async get(e,t){let r;try{r=await this.runtime.get(e,t)}catch(s){let r=this.pendingCreations.get(e);if(!r)throw s;return t?{...r,messages:[],events:[],history:{nextCursor:null,hasMore:!1,pageSize:0,totalItems:0}}:{...r,messages:[],events:[]}}return v(r,await this.listProjects(),this.platform)}async getQueryIndex(e){if(this.runtime.getQueryIndex)return this.runtime.getQueryIndex(e);let t=await this.runtime.get(e),{buildSessionQueryIndex:s}=await Promise.resolve().then(r.bind(r,1322));return s(e,t.messages)}getSessionToolResult(e,t){return this.runtime.getSessionToolResult(e,t)}getSessionWatchPath(e){return this.runtime.getSessionWatchPath(e)}run(e,t,r,s,i){return this.runtime.run(e,t,r,s,i)}steer(e,t){return this.runtime.steer(e,t)}abort(e){return this.runtime.abort(e)}async release(e){if(!this.runtime.release)throw new p.no("Native runtime release is unavailable","RUNTIME_UNAVAILABLE");await this.runtime.release(e)}answerQuestion(e,t){return this.runtime.answerQuestion(e,t)}async startRun(e,t,r,s="web",i){if(!this.runtime.startRun)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.startRun(e,t,r,s,i)}async subscribe(e,t,r){if(!this.runtime.subscribe)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.subscribe(e,t,r)}async snapshot(e,t=0){if(!this.runtime.snapshot)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.snapshot(e,t)}async setPermissionMode(e,t){if(!this.runtime.setPermissionMode)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.setPermissionMode(e,t)}async handoff(e,t){if(!this.runtime.handoff)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.handoff(e,t)}async getGoals(e,t="web"){if(!this.runtime.getGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.getGoals(e,t)}async enqueueGoal(e,t,r,s="web"){if(!this.runtime.enqueueGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueGoal(e,t,r,s)}async reorderGoals(e,t){if(!this.runtime.reorderGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderGoals(e,t)}async cancelGoal(e,t){if(!this.runtime.cancelGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelGoal(e,t,"web")}async enqueueMessage(e,t,r="web"){if(!this.runtime.enqueueMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueMessage(e,t,r)}async reorderMessages(e,t){if(!this.runtime.reorderMessages)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderMessages(e,t)}async updateMessage(e,t,r,s){if(!this.runtime.updateMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.updateMessage(e,t,r,s)}async cancelMessage(e,t){if(!this.runtime.cancelMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelMessage(e,t)}async steerMessage(e,t){if(!this.runtime.steerMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.steerMessage(e,t)}withPendingCreations(e){let t=new Set,r=e.map(e=>{t.add(e.id);let r=this.pendingCreations.get(e.id);return this.pendingCreations.delete(e.id),r?w(e,r):e});return[...[...this.pendingCreations.values()].filter(e=>!t.has(e.id)).sort((e,t)=>t.updated.localeCompare(e.updated)),...r]}}function w(e,t){return{...e,cwd:e.cwd||t.cwd,projectId:e.projectId??t.projectId}}function g(e,t){t.executable?delete process.env[e]:process.env[e]=t.detail}function O(){if(!m.__nativeRuntimeService){!function(){let e=[(0,n.join)((0,i.homedir)(),".local","bin"),"/opt/homebrew/bin","/usr/local/bin"],t=(process.env.PATH??"").split(n.delimiter),r=e.filter(e=>(0,s.existsSync)(e)&&!t.includes(e));r.length>0&&(process.env.PATH=[...t,...r].join(n.delimiter))}();let e=new o.XWE((0,h.kO)());m.__nativeRuntimeService=new f((0,p.v6)({runtimeFactory:e=>{let t=c({name:"codex",environmentVariable:"AGENT_CODEX_BIN",minimumVersion:o.hix}),r=c({name:"opencode",environmentVariable:"AGENT_OPENCODE_BIN"});return process.pid,g("AGENT_CODEX_RUNTIME_ERROR",t),g("AGENT_OPENCODE_RUNTIME_ERROR",r),(0,d.L)().info("native runtime host elected",{pid:process.pid,codex:t.executable??null,codexSource:t.source??null,codexDetail:t.detail,opencode:r.executable??null,opencodeDetail:r.detail}),(0,p.WH)(t.executable??"codex",e,r.executable??"opencode")}}),()=>e.list())}return m.__nativeRuntimeService}function v(e,t,r=process.platform){let{projectId:s,...i}=e;if(!e.cwd)return i;let a=N(e.cwd,r),o="win32"===r?n.win32.sep:n.sep,u=t.filter(e=>e.description).map(e=>({project:e,path:N(e.description,r)})).filter(({path:e})=>a===e||a.startsWith(`${e}${o}`)).sort((e,t)=>t.path.length-e.path.length)[0];return u?{...i,projectId:u.project.id}:i}function N(e,t=process.platform){if("win32"!==t)return(0,n.resolve)(e);let r=n.win32.resolve(e),s=n.win32.parse(r).root;return(r.length>s.length?r.replace(/[\\/]+$/,""):r).toLowerCase()}function E(e,t){return void 0===t?e:e.filter(e=>e.projectId===t)}function P(e){try{return"customer-agent"!==(0,p.Vu)(e).agentType}catch{return!1}}function _(e){if(e instanceof p.no)switch(e.code){case"SESSION_NOT_FOUND":return 404;case"SESSION_OCCUPIED":case"SESSION_ALREADY_RUNNING":case"APPROVAL_EXPIRED":case"CODEX_SESSION_VERSION_INCOMPATIBLE":case"STALE_SESSION_ANCHOR":return 409;case"RUNTIME_UNAVAILABLE":return 503;case"OPERATION_NOT_SUPPORTED":return 405;default:return 400}return 500}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6703,6244,1322,1773],()=>r(8451));module.exports=s})();
1
+ "use strict";(()=>{var e={};e.id=3610,e.ids=[3610],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},2131:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>m,patchFetch:()=>f,requestAsyncStorage:()=>d,routeModule:()=>c,serverHooks:()=>h,staticGenerationAsyncStorage:()=>p});var s={};r.r(s),r.d(s,{POST:()=>l});var i=r(7786),n=r(5042),a=r(2184),o=r(1890),u=r(1614);async function l(e,{params:t}){if(!(0,u.V_)(t.id)||!t.id.startsWith("runtime:codex:"))return o.NextResponse.json({error:"Only Codex sessions can be released"},{status:405});try{return await (0,u.NL)().release(t.id),o.NextResponse.json({status:"released"})}catch(e){return o.NextResponse.json({error:e instanceof Error?e.message:"Codex release failed"},{status:(0,u.WW)(e)})}}let c=new i.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/sessions/[id]/release/route",pathname:"/api/sessions/[id]/release",filename:"route",bundlePath:"app/api/sessions/[id]/release/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/sessions/[id]/release/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:d,staticGenerationAsyncStorage:p,serverHooks:h}=c,m="/api/sessions/[id]/release/route";function f(){return(0,a.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:p})}},535:(e,t,r)=>{r.d(t,{L:()=>a});var s=r(1322),i=r(785);let n=!1;function a(){let e=(0,s.Qfc)();if(e)return e;let t=(0,s.qZ_)({dir:(0,i.ME)(),source:"server",minLevel:"info",handlers:{exitOnUncaughtException:!1}});return n||(n=!0,t.info("server logger attached",{dir:t.dir,pid:process.pid})),t}},1614:(e,t,r)=>{r.d(t,{NL:()=>O,V_:()=>P,WW:()=>_});var s=r(7561),i=r(612),n=r(9411),a=r(7718),o=r(1322);function u(e){if(!e.trim())return!1;try{return(0,s.accessSync)(e,s.constants.X_OK),!0}catch{return!1}}function l(e){try{return(0,o.wyD)((0,a.execFileSync)(e,["--version"],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","pipe"]}))}catch{return}}function c(e){let t=[],r=process.env[e.environmentVariable]?.trim();if(r){let s=u(r);t.push({source:"pin",path:r,executable:s,version:s?l(r):void 0,error:s?void 0:`${e.environmentVariable} "${r}" is not executable`})}let s=function(e){for(let t of(process.env.PATH??"").split(n.delimiter).filter(Boolean)){let r=(0,n.resolve)(t,e);if(u(r))return r}}(e.name);return s&&s!==r&&t.push({source:"path",path:s,executable:!0,version:l(s)}),(0,o.neJ)(t,{name:e.name,minimumVersion:e.minimumVersion})}var d=r(535),p=r(6279),h=r(785);let m=globalThis;class f{constructor(e,t=async()=>[],r=process.platform){this.runtime=e,this.listProjects=t,this.platform=r,this.pendingCreations=new Map}health(){return this.runtime.health()}listModels(e){return this.runtime.listModels(e)}listWorkspaces(e,t){return this.runtime.listWorkspaces(e,t)}importWorkspace(e,t,r){if(!this.runtime.importWorkspace)throw new p.no("Native workspace import is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.importWorkspace(e,t,r)}async listWorkspaceSessions(e,t,r){let s=await this.runtime.listWorkspaceSessions(e,t,r);if(r?.cursor)return s;let i=new Set(s.data.map(e=>e.id)),n=s.data.map(e=>{let t=this.pendingCreations.get(e.id);return t?(this.pendingCreations.delete(e.id),w(e,t)):e});for(let r of this.pendingCreations.values())r.agentType!==e||r.projectId!==t||i.has(r.id)||n.unshift(r);return{...s,data:n}}async list(e){let[t,r]=await Promise.all([this.runtime.list(),this.listProjects()]);return E(this.withPendingCreations(t).map(e=>v(e,r,this.platform)),e)}async refresh(e){let[t,r]=await Promise.all([this.runtime.refresh(),this.listProjects()]);return E(this.withPendingCreations(t).map(e=>v(e,r,this.platform)),e)}async create(e){let t=v(await this.runtime.create(e),await this.listProjects(),this.platform),r=e.projectId?{...t,projectId:e.projectId}:t;return this.pendingCreations.set(r.id,r),r}async fork(e,t){if(!P(e))throw new p.no("Customer Agent sessions do not support native forks","OPERATION_NOT_SUPPORTED");let r=v(t?await this.runtime.fork(e,t):await this.runtime.fork(e),await this.listProjects(),this.platform);return this.pendingCreations.set(r.id,r),r}async delete(e){await this.runtime.delete(e),this.pendingCreations.delete(e)}async get(e,t){let r;try{r=await this.runtime.get(e,t)}catch(s){let r=this.pendingCreations.get(e);if(!r)throw s;return t?{...r,messages:[],events:[],history:{nextCursor:null,hasMore:!1,pageSize:0,totalItems:0}}:{...r,messages:[],events:[]}}return v(r,await this.listProjects(),this.platform)}async getQueryIndex(e){if(this.runtime.getQueryIndex)return this.runtime.getQueryIndex(e);let t=await this.runtime.get(e),{buildSessionQueryIndex:s}=await Promise.resolve().then(r.bind(r,1322));return s(e,t.messages)}getSessionToolResult(e,t){return this.runtime.getSessionToolResult(e,t)}getSessionWatchPath(e){return this.runtime.getSessionWatchPath(e)}run(e,t,r,s,i){return this.runtime.run(e,t,r,s,i)}steer(e,t){return this.runtime.steer(e,t)}abort(e){return this.runtime.abort(e)}async release(e){if(!this.runtime.release)throw new p.no("Native runtime release is unavailable","RUNTIME_UNAVAILABLE");await this.runtime.release(e)}answerQuestion(e,t){return this.runtime.answerQuestion(e,t)}async startRun(e,t,r,s="web",i){if(!this.runtime.startRun)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.startRun(e,t,r,s,i)}async subscribe(e,t,r){if(!this.runtime.subscribe)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.subscribe(e,t,r)}async snapshot(e,t=0){if(!this.runtime.snapshot)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.snapshot(e,t)}async setPermissionMode(e,t){if(!this.runtime.setPermissionMode)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.setPermissionMode(e,t)}async handoff(e,t){if(!this.runtime.handoff)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.handoff(e,t)}async getGoals(e,t="web"){if(!this.runtime.getGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.getGoals(e,t)}async enqueueGoal(e,t,r,s="web"){if(!this.runtime.enqueueGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueGoal(e,t,r,s)}async reorderGoals(e,t){if(!this.runtime.reorderGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderGoals(e,t)}async cancelGoal(e,t){if(!this.runtime.cancelGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelGoal(e,t,"web")}async enqueueMessage(e,t,r="web"){if(!this.runtime.enqueueMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueMessage(e,t,r)}async reorderMessages(e,t){if(!this.runtime.reorderMessages)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderMessages(e,t)}async updateMessage(e,t,r,s){if(!this.runtime.updateMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.updateMessage(e,t,r,s)}async cancelMessage(e,t){if(!this.runtime.cancelMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelMessage(e,t)}async steerMessage(e,t){if(!this.runtime.steerMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.steerMessage(e,t)}withPendingCreations(e){let t=new Set,r=e.map(e=>{t.add(e.id);let r=this.pendingCreations.get(e.id);return this.pendingCreations.delete(e.id),r?w(e,r):e});return[...[...this.pendingCreations.values()].filter(e=>!t.has(e.id)).sort((e,t)=>t.updated.localeCompare(e.updated)),...r]}}function w(e,t){return{...e,cwd:e.cwd||t.cwd,projectId:e.projectId??t.projectId}}function g(e,t){t.executable?delete process.env[e]:process.env[e]=t.detail}function O(){if(!m.__nativeRuntimeService){!function(){let e=[(0,n.join)((0,i.homedir)(),".local","bin"),"/opt/homebrew/bin","/usr/local/bin"],t=(process.env.PATH??"").split(n.delimiter),r=e.filter(e=>(0,s.existsSync)(e)&&!t.includes(e));r.length>0&&(process.env.PATH=[...t,...r].join(n.delimiter))}();let e=new o.XWE((0,h.kO)());m.__nativeRuntimeService=new f((0,p.v6)({runtimeFactory:e=>{let t=c({name:"codex",environmentVariable:"AGENT_CODEX_BIN",minimumVersion:o.hix}),r=c({name:"opencode",environmentVariable:"AGENT_OPENCODE_BIN"});return process.pid,g("AGENT_CODEX_RUNTIME_ERROR",t),g("AGENT_OPENCODE_RUNTIME_ERROR",r),(0,d.L)().info("native runtime host elected",{pid:process.pid,codex:t.executable??null,codexSource:t.source??null,codexDetail:t.detail,opencode:r.executable??null,opencodeDetail:r.detail}),(0,p.WH)(t.executable??"codex",e,r.executable??"opencode")}}),()=>e.list())}return m.__nativeRuntimeService}function v(e,t,r=process.platform){let{projectId:s,...i}=e;if(!e.cwd)return i;let a=N(e.cwd,r),o="win32"===r?n.win32.sep:n.sep,u=t.filter(e=>e.description).map(e=>({project:e,path:N(e.description,r)})).filter(({path:e})=>a===e||a.startsWith(`${e}${o}`)).sort((e,t)=>t.path.length-e.path.length)[0];return u?{...i,projectId:u.project.id}:i}function N(e,t=process.platform){if("win32"!==t)return(0,n.resolve)(e);let r=n.win32.resolve(e),s=n.win32.parse(r).root;return(r.length>s.length?r.replace(/[\\/]+$/,""):r).toLowerCase()}function E(e,t){return void 0===t?e:e.filter(e=>e.projectId===t)}function P(e){try{return"customer-agent"!==(0,p.Vu)(e).agentType}catch{return!1}}function _(e){if(e instanceof p.no)switch(e.code){case"SESSION_NOT_FOUND":return 404;case"SESSION_OCCUPIED":case"SESSION_ALREADY_RUNNING":case"APPROVAL_EXPIRED":case"CODEX_SESSION_VERSION_INCOMPATIBLE":case"STALE_SESSION_ANCHOR":return 409;case"RUNTIME_UNAVAILABLE":return 503;case"OPERATION_NOT_SUPPORTED":return 405;default:return 400}return 500}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6703,6244,1322,1773],()=>r(2131));module.exports=s})();
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=5241,e.ids=[5241],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},9496:(e,r,s)=>{s.r(r),s.d(r,{originalPathname:()=>N,patchFetch:()=>R,requestAsyncStorage:()=>h,routeModule:()=>v,serverHooks:()=>q,staticGenerationAsyncStorage:()=>f});var t={};s.r(t),s.d(t,{DELETE:()=>x,GET:()=>m,PATCH:()=>g});var o=s(7786),n=s(5042),i=s(2184),a=s(1890),u=s(1322),d=s(7519),p=s(1614),c=s(6279),l=s(8274);async function m(e,{params:r}){let s=new URL(e.url),t=s.searchParams.get("before"),o=s.searchParams.get("after"),n=s.searchParams.get("anchor"),i=s.searchParams.get("limit"),m=s.searchParams.get("view"),g=s.searchParams.get("revision"),x=s.searchParams.get("turnId"),v="core"===m||"trace"===m?m:void 0,h=null!==t||null!==o||null!==n||null!==i||v||g||x?{before:t||void 0,after:o||void 0,anchor:n||void 0,limit:function(e){if(null===e)return;let r=Number(e);return Number.isFinite(r)?r:void 0}(i),view:v,revision:g||void 0,turnId:x||void 0}:void 0;if((0,p.V_)(r.id))try{let e=await (0,p.NL)().get(r.id,h);return a.NextResponse.json(e)}catch(e){return a.NextResponse.json({error:e instanceof Error?e.message:"Internal error",...e instanceof c.no?{code:e.code}:{}},{status:(0,p.WW)(e)})}let f=await d.agentHost.getSessionStore().get(r.id);if(!f)return a.NextResponse.json({error:"Session not found"},{status:404});let q=d.agentHost.getRecoverableRun(f),N=[...(!f.messages?.length&&!q&&Array.isArray(f.events)&&f.events.length>0?l.Q(f.events):f.messages)?.filter(e=>!u.lWN(e))??[]??[],...q?(0,l.Q)(f.events.slice(q.eventStart),{runId:q.runId,isStreaming:q.running}):[]],R=q?q.running?"active":"failed":f.status,j=q?{runId:q.runId,eventId:q.eventId,running:q.running}:void 0;try{let e=h?{...f,agentType:"customer-agent",status:R,permissionMode:(0,u.NyU)(f.metadata.permissionMode),...j?{activeRun:j}:{},...(0,u.MOJ)(N??[],f.events??[],h)}:{...f,agentType:"customer-agent",status:R,messages:N,permissionMode:(0,u.NyU)(f.metadata.permissionMode),...j?{activeRun:j}:{}};return a.NextResponse.json({...e,messageQueueVersion:1,goalState:(0,u.E0T)(f.metadata)})}catch(e){if(e instanceof u.ujo)return a.NextResponse.json({error:e.message,code:e.code},{status:409});throw e}}async function g(e,{params:r}){let s=await e.json();if(!(0,u.ueU)(s.permissionMode))return a.NextResponse.json({error:"Invalid permission mode"},{status:400});if((0,p.V_)(r.id))try{let e=await (0,p.NL)().setPermissionMode(r.id,s.permissionMode);return a.NextResponse.json(e)}catch(e){return a.NextResponse.json({error:e instanceof Error?e.message:"Unable to update permission mode"},{status:(0,p.WW)(e)})}try{let e=await d.agentHost.setSessionPermissionMode(r.id,s.permissionMode);return a.NextResponse.json({...e,permissionMode:(0,u.NyU)(e.metadata.permissionMode)})}catch(s){let e=s instanceof Error?s.message:"Unable to update permission mode",r=e.startsWith("Session not found")?404:500;return a.NextResponse.json({error:e},{status:r})}}async function x(e,{params:r}){if((0,p.V_)(r.id))try{return await (0,p.NL)().delete(r.id),a.NextResponse.json({status:"deleted"})}catch(e){return a.NextResponse.json({error:e instanceof Error?e.message:"Unable to delete session"},{status:(0,p.WW)(e)})}return d.agentHost.isSessionRunning(r.id)?a.NextResponse.json({error:"Session is currently running"},{status:409}):(await d.agentHost.getSessionStore().delete(r.id),a.NextResponse.json({status:"deleted"}))}let v=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/sessions/[id]/route",pathname:"/api/sessions/[id]",filename:"route",bundlePath:"app/api/sessions/[id]/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/sessions/[id]/route.ts",nextConfigOutput:"standalone",userland:t}),{requestAsyncStorage:h,staticGenerationAsyncStorage:f,serverHooks:q}=v,N="/api/sessions/[id]/route";function R(){return(0,i.patchFetch)({serverHooks:q,staticGenerationAsyncStorage:f})}}};var r=require("../../../../webpack-runtime.js");r.C(e);var s=e=>r(r.s=e),t=r.X(0,[8375,6703,6244,1322,1773,4621,7519,8532],()=>s(9496));module.exports=t})();
1
+ "use strict";(()=>{var e={};e.id=5241,e.ids=[5241],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},3975:(e,r,s)=>{s.r(r),s.d(r,{originalPathname:()=>N,patchFetch:()=>R,requestAsyncStorage:()=>h,routeModule:()=>v,serverHooks:()=>q,staticGenerationAsyncStorage:()=>f});var t={};s.r(t),s.d(t,{DELETE:()=>x,GET:()=>m,PATCH:()=>g});var o=s(7786),n=s(5042),i=s(2184),a=s(1890),u=s(1322),d=s(7519),p=s(1614),c=s(6279),l=s(8274);async function m(e,{params:r}){let s=new URL(e.url),t=s.searchParams.get("before"),o=s.searchParams.get("after"),n=s.searchParams.get("anchor"),i=s.searchParams.get("limit"),m=s.searchParams.get("view"),g=s.searchParams.get("revision"),x=s.searchParams.get("turnId"),v="core"===m||"trace"===m?m:void 0,h=null!==t||null!==o||null!==n||null!==i||v||g||x?{before:t||void 0,after:o||void 0,anchor:n||void 0,limit:function(e){if(null===e)return;let r=Number(e);return Number.isFinite(r)?r:void 0}(i),view:v,revision:g||void 0,turnId:x||void 0}:void 0;if((0,p.V_)(r.id))try{let e=await (0,p.NL)().get(r.id,h);return a.NextResponse.json(e)}catch(e){return a.NextResponse.json({error:e instanceof Error?e.message:"Internal error",...e instanceof c.no?{code:e.code}:{}},{status:(0,p.WW)(e)})}let f=await d.agentHost.getSessionStore().get(r.id);if(!f)return a.NextResponse.json({error:"Session not found"},{status:404});let q=d.agentHost.getRecoverableRun(f),N=[...(!f.messages?.length&&!q&&Array.isArray(f.events)&&f.events.length>0?l.Q(f.events):f.messages)?.filter(e=>!u.lWN(e))??[]??[],...q?(0,l.Q)(f.events.slice(q.eventStart),{runId:q.runId,isStreaming:q.running}):[]],R=q?q.running?"active":"failed":f.status,j=q?{runId:q.runId,eventId:q.eventId,running:q.running}:void 0;try{let e=h?{...f,agentType:"customer-agent",status:R,permissionMode:(0,u.NyU)(f.metadata.permissionMode),...j?{activeRun:j}:{},...(0,u.MOJ)(N??[],f.events??[],h)}:{...f,agentType:"customer-agent",status:R,messages:N,permissionMode:(0,u.NyU)(f.metadata.permissionMode),...j?{activeRun:j}:{}};return a.NextResponse.json({...e,messageQueueVersion:1,goalState:(0,u.E0T)(f.metadata)})}catch(e){if(e instanceof u.ujo)return a.NextResponse.json({error:e.message,code:e.code},{status:409});throw e}}async function g(e,{params:r}){let s=await e.json();if(!(0,u.ueU)(s.permissionMode))return a.NextResponse.json({error:"Invalid permission mode"},{status:400});if((0,p.V_)(r.id))try{let e=await (0,p.NL)().setPermissionMode(r.id,s.permissionMode);return a.NextResponse.json(e)}catch(e){return a.NextResponse.json({error:e instanceof Error?e.message:"Unable to update permission mode"},{status:(0,p.WW)(e)})}try{let e=await d.agentHost.setSessionPermissionMode(r.id,s.permissionMode);return a.NextResponse.json({...e,permissionMode:(0,u.NyU)(e.metadata.permissionMode)})}catch(s){let e=s instanceof Error?s.message:"Unable to update permission mode",r=e.startsWith("Session not found")?404:500;return a.NextResponse.json({error:e},{status:r})}}async function x(e,{params:r}){if((0,p.V_)(r.id))try{return await (0,p.NL)().delete(r.id),a.NextResponse.json({status:"deleted"})}catch(e){return a.NextResponse.json({error:e instanceof Error?e.message:"Unable to delete session"},{status:(0,p.WW)(e)})}return d.agentHost.isSessionRunning(r.id)?a.NextResponse.json({error:"Session is currently running"},{status:409}):(await d.agentHost.getSessionStore().delete(r.id),a.NextResponse.json({status:"deleted"}))}let v=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/sessions/[id]/route",pathname:"/api/sessions/[id]",filename:"route",bundlePath:"app/api/sessions/[id]/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/sessions/[id]/route.ts",nextConfigOutput:"standalone",userland:t}),{requestAsyncStorage:h,staticGenerationAsyncStorage:f,serverHooks:q}=v,N="/api/sessions/[id]/route";function R(){return(0,i.patchFetch)({serverHooks:q,staticGenerationAsyncStorage:f})}}};var r=require("../../../../webpack-runtime.js");r.C(e);var s=e=>r(r.s=e),t=r.X(0,[8375,6703,6244,1322,1773,4621,7519,8532],()=>s(3975));module.exports=t})();
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=6248,e.ids=[6248],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},4961:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>N,patchFetch:()=>_,requestAsyncStorage:()=>f,routeModule:()=>g,serverHooks:()=>v,staticGenerationAsyncStorage:()=>w});var s={};r.r(s),r.d(s,{DELETE:()=>h,GET:()=>c,PATCH:()=>p,PUT:()=>d});var n=r(7786),i=r(5042),o=r(2184),a=r(1890),u=r(1366),l=r(1614);async function c(e,{params:t}){if((0,l.V_)(t.id))return a.NextResponse.json({error:"Thread goal is only available on customer-agent sessions"},{status:400});let r=await (0,u.C)().getGoal(t.id);return a.NextResponse.json({goal:r})}async function d(e,{params:t}){if((0,l.V_)(t.id))return a.NextResponse.json({error:"Thread goal is only available on customer-agent sessions"},{status:400});try{let r=await e.json();if("string"!=typeof r.objective||!r.objective.trim())return a.NextResponse.json({error:"objective is required"},{status:400});let s=null===r.tokenBudget||void 0===r.tokenBudget?void 0:Number(r.tokenBudget);if(void 0!==s&&(!Number.isFinite(s)||s<=0))return a.NextResponse.json({error:"tokenBudget must be a positive number or null"},{status:400});let n=await (0,u.C)().setGoal(t.id,r.objective,{tokenBudget:s??null});return a.NextResponse.json({goal:n})}catch(e){return a.NextResponse.json({error:e instanceof Error?e.message:"Failed to set thread goal"},{status:m(e)})}}async function p(e,{params:t}){if((0,l.V_)(t.id))return a.NextResponse.json({error:"Thread goal is only available on customer-agent sessions"},{status:400});try{let r=await e.json(),s=(0,u.C)();if("pause"===r.action)return a.NextResponse.json({goal:await s.pauseGoal(t.id)});if("resume"===r.action)return a.NextResponse.json({goal:await s.resumeGoal(t.id)});return a.NextResponse.json({error:"action must be 'pause' or 'resume'"},{status:400})}catch(e){return a.NextResponse.json({error:e instanceof Error?e.message:"Failed to update thread goal"},{status:m(e)})}}async function h(e,{params:t}){if((0,l.V_)(t.id))return a.NextResponse.json({error:"Thread goal is only available on customer-agent sessions"},{status:400});let r=await (0,u.C)().clearGoal(t.id);return a.NextResponse.json({cleared:r})}function m(e){let t=e instanceof Error?e.message:"";return/no thread goal|Cannot transition/.test(t)?409:(/required|must be|at most/i.test(t),400)}let g=new n.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/sessions/[id]/thread-goal/route",pathname:"/api/sessions/[id]/thread-goal",filename:"route",bundlePath:"app/api/sessions/[id]/thread-goal/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/sessions/[id]/thread-goal/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:f,staticGenerationAsyncStorage:w,serverHooks:v}=g,N="/api/sessions/[id]/thread-goal/route";function _(){return(0,o.patchFetch)({serverHooks:v,staticGenerationAsyncStorage:w})}},1614:(e,t,r)=>{r.d(t,{NL:()=>v,V_:()=>E,WW:()=>R});var s=r(7561),n=r(612),i=r(9411),o=r(7718),a=r(1322);function u(e){if(!e.trim())return!1;try{return(0,s.accessSync)(e,s.constants.X_OK),!0}catch{return!1}}function l(e){try{return(0,a.wyD)((0,o.execFileSync)(e,["--version"],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","pipe"]}))}catch{return}}function c(e){let t=[],r=process.env[e.environmentVariable]?.trim();if(r){let s=u(r);t.push({source:"pin",path:r,executable:s,version:s?l(r):void 0,error:s?void 0:`${e.environmentVariable} "${r}" is not executable`})}let s=function(e){for(let t of(process.env.PATH??"").split(i.delimiter).filter(Boolean)){let r=(0,i.resolve)(t,e);if(u(r))return r}}(e.name);return s&&s!==r&&t.push({source:"path",path:s,executable:!0,version:l(s)}),(0,a.neJ)(t,{name:e.name,minimumVersion:e.minimumVersion})}var d=r(535),p=r(6279),h=r(785);let m=globalThis;class g{constructor(e,t=async()=>[],r=process.platform){this.runtime=e,this.listProjects=t,this.platform=r,this.pendingCreations=new Map}health(){return this.runtime.health()}listModels(e){return this.runtime.listModels(e)}listWorkspaces(e,t){return this.runtime.listWorkspaces(e,t)}importWorkspace(e,t,r){if(!this.runtime.importWorkspace)throw new p.no("Native workspace import is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.importWorkspace(e,t,r)}async listWorkspaceSessions(e,t,r){let s=await this.runtime.listWorkspaceSessions(e,t,r);if(r?.cursor)return s;let n=new Set(s.data.map(e=>e.id)),i=s.data.map(e=>{let t=this.pendingCreations.get(e.id);return t?(this.pendingCreations.delete(e.id),f(e,t)):e});for(let r of this.pendingCreations.values())r.agentType!==e||r.projectId!==t||n.has(r.id)||i.unshift(r);return{...s,data:i}}async list(e){let[t,r]=await Promise.all([this.runtime.list(),this.listProjects()]);return b(this.withPendingCreations(t).map(e=>N(e,r,this.platform)),e)}async refresh(e){let[t,r]=await Promise.all([this.runtime.refresh(),this.listProjects()]);return b(this.withPendingCreations(t).map(e=>N(e,r,this.platform)),e)}async create(e){let t=N(await this.runtime.create(e),await this.listProjects(),this.platform),r=e.projectId?{...t,projectId:e.projectId}:t;return this.pendingCreations.set(r.id,r),r}async fork(e){if(!E(e))throw new p.no("Customer Agent sessions do not support native forks","OPERATION_NOT_SUPPORTED");let t=N(await this.runtime.fork(e),await this.listProjects(),this.platform);return this.pendingCreations.set(t.id,t),t}async delete(e){await this.runtime.delete(e),this.pendingCreations.delete(e)}async get(e,t){let r;try{r=await this.runtime.get(e,t)}catch(s){let r=this.pendingCreations.get(e);if(!r)throw s;return t?{...r,messages:[],events:[],history:{nextCursor:null,hasMore:!1,pageSize:0,totalItems:0}}:{...r,messages:[],events:[]}}return N(r,await this.listProjects(),this.platform)}async getQueryIndex(e){if(this.runtime.getQueryIndex)return this.runtime.getQueryIndex(e);let t=await this.runtime.get(e),{buildSessionQueryIndex:s}=await Promise.resolve().then(r.bind(r,1322));return s(e,t.messages)}getSessionToolResult(e,t){return this.runtime.getSessionToolResult(e,t)}getSessionWatchPath(e){return this.runtime.getSessionWatchPath(e)}run(e,t,r,s,n){return this.runtime.run(e,t,r,s,n)}steer(e,t){return this.runtime.steer(e,t)}abort(e){return this.runtime.abort(e)}async release(e){if(!this.runtime.release)throw new p.no("Native runtime release is unavailable","RUNTIME_UNAVAILABLE");await this.runtime.release(e)}answerQuestion(e,t){return this.runtime.answerQuestion(e,t)}async startRun(e,t,r,s="web",n){if(!this.runtime.startRun)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.startRun(e,t,r,s,n)}async subscribe(e,t,r){if(!this.runtime.subscribe)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.subscribe(e,t,r)}async snapshot(e,t=0){if(!this.runtime.snapshot)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.snapshot(e,t)}async setPermissionMode(e,t){if(!this.runtime.setPermissionMode)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.setPermissionMode(e,t)}async handoff(e,t){if(!this.runtime.handoff)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.handoff(e,t)}async getGoals(e,t="web"){if(!this.runtime.getGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.getGoals(e,t)}async enqueueGoal(e,t,r,s="web"){if(!this.runtime.enqueueGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueGoal(e,t,r,s)}async reorderGoals(e,t){if(!this.runtime.reorderGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderGoals(e,t)}async cancelGoal(e,t){if(!this.runtime.cancelGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelGoal(e,t,"web")}async enqueueMessage(e,t,r="web"){if(!this.runtime.enqueueMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueMessage(e,t,r)}async reorderMessages(e,t){if(!this.runtime.reorderMessages)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderMessages(e,t)}async updateMessage(e,t,r,s){if(!this.runtime.updateMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.updateMessage(e,t,r,s)}async cancelMessage(e,t){if(!this.runtime.cancelMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelMessage(e,t)}async steerMessage(e,t){if(!this.runtime.steerMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.steerMessage(e,t)}withPendingCreations(e){let t=new Set,r=e.map(e=>{t.add(e.id);let r=this.pendingCreations.get(e.id);return this.pendingCreations.delete(e.id),r?f(e,r):e});return[...[...this.pendingCreations.values()].filter(e=>!t.has(e.id)).sort((e,t)=>t.updated.localeCompare(e.updated)),...r]}}function f(e,t){return{...e,cwd:e.cwd||t.cwd,projectId:e.projectId??t.projectId}}function w(e,t){t.executable?delete process.env[e]:process.env[e]=t.detail}function v(){if(!m.__nativeRuntimeService){!function(){let e=[(0,i.join)((0,n.homedir)(),".local","bin"),"/opt/homebrew/bin","/usr/local/bin"],t=(process.env.PATH??"").split(i.delimiter),r=e.filter(e=>(0,s.existsSync)(e)&&!t.includes(e));r.length>0&&(process.env.PATH=[...t,...r].join(i.delimiter))}();let e=new a.XWE((0,h.kO)());m.__nativeRuntimeService=new g((0,p.v6)({runtimeFactory:e=>{let t=c({name:"codex",environmentVariable:"AGENT_CODEX_BIN",minimumVersion:a.hix}),r=c({name:"opencode",environmentVariable:"AGENT_OPENCODE_BIN"});return process.pid,w("AGENT_CODEX_RUNTIME_ERROR",t),w("AGENT_OPENCODE_RUNTIME_ERROR",r),(0,d.L)().info("native runtime host elected",{pid:process.pid,codex:t.executable??null,codexSource:t.source??null,codexDetail:t.detail,opencode:r.executable??null,opencodeDetail:r.detail}),(0,p.WH)(t.executable??"codex",e,r.executable??"opencode")}}),()=>e.list())}return m.__nativeRuntimeService}function N(e,t,r=process.platform){let{projectId:s,...n}=e;if(!e.cwd)return n;let o=_(e.cwd,r),a="win32"===r?i.win32.sep:i.sep,u=t.filter(e=>e.description).map(e=>({project:e,path:_(e.description,r)})).filter(({path:e})=>o===e||o.startsWith(`${e}${a}`)).sort((e,t)=>t.path.length-e.path.length)[0];return u?{...n,projectId:u.project.id}:n}function _(e,t=process.platform){if("win32"!==t)return(0,i.resolve)(e);let r=i.win32.resolve(e),s=i.win32.parse(r).root;return(r.length>s.length?r.replace(/[\\/]+$/,""):r).toLowerCase()}function b(e,t){return void 0===t?e:e.filter(e=>e.projectId===t)}function E(e){try{return"customer-agent"!==(0,p.Vu)(e).agentType}catch{return!1}}function R(e){if(e instanceof p.no)switch(e.code){case"SESSION_NOT_FOUND":return 404;case"SESSION_OCCUPIED":case"SESSION_ALREADY_RUNNING":case"APPROVAL_EXPIRED":case"CODEX_SESSION_VERSION_INCOMPATIBLE":case"STALE_SESSION_ANCHOR":return 409;case"RUNTIME_UNAVAILABLE":return 503;case"OPERATION_NOT_SUPPORTED":return 405;default:return 400}return 500}},1489:(e,t,r)=>{r.d(t,{N:()=>u});var s=r(1322),n=r(6279),i=r(785);class o{constructor(){this.tasks=new s.vo4((0,i.kO)()),this.scheduler=new n.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await r.e(7519).then(r.bind(r,7519)),{getCustomerGoalCoordinator:s}=await Promise.all([r.e(7519),r.e(732)]).then(r.bind(r,732)),n=e.sessionId;n&&await t.getSessionStore().get(n)||(n=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:n})),await s().enqueue(n,e.prompt)}call(e,t){let r=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(r);case"cronResume":return this.tasks.resume(r);case"cronDelete":return this.tasks.delete(r);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function u(){return a.__sharedCronService??=new o}},1366:(e,t,r)=>{r.d(t,{C:()=>a,a:()=>u});var s=r(1322),n=r(7519),i=r(785);let o=globalThis;function a(){if(o.__threadGoalService)return o.__threadGoalService;let e=new s.rA9(new s.ZIW((0,i.kO)()),{isSessionRunning:e=>n.agentHost.isSessionRunning(e),startTurn:async(e,t)=>{if(n.agentHost.isSessionRunning(e))return!1;try{return n.agentHost.startRun(t,e,void 0,{source:"goal"}).completion.catch(()=>{}),!0}catch(e){if(e instanceof n.A)return!1;throw e}},steerHidden:(e,t)=>n.agentHost.steer(t,e,"__goal__"),sessionExists:async e=>!!await n.agentHost.getSessionStore().get(e)},{onUpdated:(e,t)=>n.agentHost.publishExternal(e,{type:"goal_updated",goal:t}),onCleared:e=>n.agentHost.publishExternal(e,{type:"goal_cleared",sessionId:e})});return n.agentHost.onRunSettled=t=>{e.onRunSettled({sessionId:t.sessionId,failed:t.failed,usageLimited:t.usageLimited,tokens:t.newTokens,seconds:t.durationMs/1e3}).catch(()=>{})},n.agentHost.threadGoalToolsProvider=t=>(0,s.DAt)(e,t),o.__threadGoalService=e,e}function u(){a().resumeInterrupted().catch(()=>{})}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6703,6244,1322,1773,4621,7519],()=>r(4961));module.exports=s})();
1
+ "use strict";(()=>{var e={};e.id=6248,e.ids=[6248],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},3945:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>N,patchFetch:()=>_,requestAsyncStorage:()=>f,routeModule:()=>g,serverHooks:()=>v,staticGenerationAsyncStorage:()=>w});var s={};r.r(s),r.d(s,{DELETE:()=>h,GET:()=>c,PATCH:()=>p,PUT:()=>d});var n=r(7786),i=r(5042),o=r(2184),a=r(1890),u=r(1366),l=r(1614);async function c(e,{params:t}){if((0,l.V_)(t.id))return a.NextResponse.json({error:"Thread goal is only available on customer-agent sessions"},{status:400});let r=await (0,u.C)().getGoal(t.id);return a.NextResponse.json({goal:r})}async function d(e,{params:t}){if((0,l.V_)(t.id))return a.NextResponse.json({error:"Thread goal is only available on customer-agent sessions"},{status:400});try{let r=await e.json();if("string"!=typeof r.objective||!r.objective.trim())return a.NextResponse.json({error:"objective is required"},{status:400});let s=null===r.tokenBudget||void 0===r.tokenBudget?void 0:Number(r.tokenBudget);if(void 0!==s&&(!Number.isFinite(s)||s<=0))return a.NextResponse.json({error:"tokenBudget must be a positive number or null"},{status:400});let n=await (0,u.C)().setGoal(t.id,r.objective,{tokenBudget:s??null});return a.NextResponse.json({goal:n})}catch(e){return a.NextResponse.json({error:e instanceof Error?e.message:"Failed to set thread goal"},{status:m(e)})}}async function p(e,{params:t}){if((0,l.V_)(t.id))return a.NextResponse.json({error:"Thread goal is only available on customer-agent sessions"},{status:400});try{let r=await e.json(),s=(0,u.C)();if("pause"===r.action)return a.NextResponse.json({goal:await s.pauseGoal(t.id)});if("resume"===r.action)return a.NextResponse.json({goal:await s.resumeGoal(t.id)});return a.NextResponse.json({error:"action must be 'pause' or 'resume'"},{status:400})}catch(e){return a.NextResponse.json({error:e instanceof Error?e.message:"Failed to update thread goal"},{status:m(e)})}}async function h(e,{params:t}){if((0,l.V_)(t.id))return a.NextResponse.json({error:"Thread goal is only available on customer-agent sessions"},{status:400});let r=await (0,u.C)().clearGoal(t.id);return a.NextResponse.json({cleared:r})}function m(e){let t=e instanceof Error?e.message:"";return/no thread goal|Cannot transition/.test(t)?409:(/required|must be|at most/i.test(t),400)}let g=new n.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/sessions/[id]/thread-goal/route",pathname:"/api/sessions/[id]/thread-goal",filename:"route",bundlePath:"app/api/sessions/[id]/thread-goal/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/sessions/[id]/thread-goal/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:f,staticGenerationAsyncStorage:w,serverHooks:v}=g,N="/api/sessions/[id]/thread-goal/route";function _(){return(0,o.patchFetch)({serverHooks:v,staticGenerationAsyncStorage:w})}},1614:(e,t,r)=>{r.d(t,{NL:()=>v,V_:()=>E,WW:()=>R});var s=r(7561),n=r(612),i=r(9411),o=r(7718),a=r(1322);function u(e){if(!e.trim())return!1;try{return(0,s.accessSync)(e,s.constants.X_OK),!0}catch{return!1}}function l(e){try{return(0,a.wyD)((0,o.execFileSync)(e,["--version"],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","pipe"]}))}catch{return}}function c(e){let t=[],r=process.env[e.environmentVariable]?.trim();if(r){let s=u(r);t.push({source:"pin",path:r,executable:s,version:s?l(r):void 0,error:s?void 0:`${e.environmentVariable} "${r}" is not executable`})}let s=function(e){for(let t of(process.env.PATH??"").split(i.delimiter).filter(Boolean)){let r=(0,i.resolve)(t,e);if(u(r))return r}}(e.name);return s&&s!==r&&t.push({source:"path",path:s,executable:!0,version:l(s)}),(0,a.neJ)(t,{name:e.name,minimumVersion:e.minimumVersion})}var d=r(535),p=r(6279),h=r(785);let m=globalThis;class g{constructor(e,t=async()=>[],r=process.platform){this.runtime=e,this.listProjects=t,this.platform=r,this.pendingCreations=new Map}health(){return this.runtime.health()}listModels(e){return this.runtime.listModels(e)}listWorkspaces(e,t){return this.runtime.listWorkspaces(e,t)}importWorkspace(e,t,r){if(!this.runtime.importWorkspace)throw new p.no("Native workspace import is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.importWorkspace(e,t,r)}async listWorkspaceSessions(e,t,r){let s=await this.runtime.listWorkspaceSessions(e,t,r);if(r?.cursor)return s;let n=new Set(s.data.map(e=>e.id)),i=s.data.map(e=>{let t=this.pendingCreations.get(e.id);return t?(this.pendingCreations.delete(e.id),f(e,t)):e});for(let r of this.pendingCreations.values())r.agentType!==e||r.projectId!==t||n.has(r.id)||i.unshift(r);return{...s,data:i}}async list(e){let[t,r]=await Promise.all([this.runtime.list(),this.listProjects()]);return b(this.withPendingCreations(t).map(e=>N(e,r,this.platform)),e)}async refresh(e){let[t,r]=await Promise.all([this.runtime.refresh(),this.listProjects()]);return b(this.withPendingCreations(t).map(e=>N(e,r,this.platform)),e)}async create(e){let t=N(await this.runtime.create(e),await this.listProjects(),this.platform),r=e.projectId?{...t,projectId:e.projectId}:t;return this.pendingCreations.set(r.id,r),r}async fork(e,t){if(!E(e))throw new p.no("Customer Agent sessions do not support native forks","OPERATION_NOT_SUPPORTED");let r=N(t?await this.runtime.fork(e,t):await this.runtime.fork(e),await this.listProjects(),this.platform);return this.pendingCreations.set(r.id,r),r}async delete(e){await this.runtime.delete(e),this.pendingCreations.delete(e)}async get(e,t){let r;try{r=await this.runtime.get(e,t)}catch(s){let r=this.pendingCreations.get(e);if(!r)throw s;return t?{...r,messages:[],events:[],history:{nextCursor:null,hasMore:!1,pageSize:0,totalItems:0}}:{...r,messages:[],events:[]}}return N(r,await this.listProjects(),this.platform)}async getQueryIndex(e){if(this.runtime.getQueryIndex)return this.runtime.getQueryIndex(e);let t=await this.runtime.get(e),{buildSessionQueryIndex:s}=await Promise.resolve().then(r.bind(r,1322));return s(e,t.messages)}getSessionToolResult(e,t){return this.runtime.getSessionToolResult(e,t)}getSessionWatchPath(e){return this.runtime.getSessionWatchPath(e)}run(e,t,r,s,n){return this.runtime.run(e,t,r,s,n)}steer(e,t){return this.runtime.steer(e,t)}abort(e){return this.runtime.abort(e)}async release(e){if(!this.runtime.release)throw new p.no("Native runtime release is unavailable","RUNTIME_UNAVAILABLE");await this.runtime.release(e)}answerQuestion(e,t){return this.runtime.answerQuestion(e,t)}async startRun(e,t,r,s="web",n){if(!this.runtime.startRun)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.startRun(e,t,r,s,n)}async subscribe(e,t,r){if(!this.runtime.subscribe)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.subscribe(e,t,r)}async snapshot(e,t=0){if(!this.runtime.snapshot)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.snapshot(e,t)}async setPermissionMode(e,t){if(!this.runtime.setPermissionMode)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.setPermissionMode(e,t)}async handoff(e,t){if(!this.runtime.handoff)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.handoff(e,t)}async getGoals(e,t="web"){if(!this.runtime.getGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.getGoals(e,t)}async enqueueGoal(e,t,r,s="web"){if(!this.runtime.enqueueGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueGoal(e,t,r,s)}async reorderGoals(e,t){if(!this.runtime.reorderGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderGoals(e,t)}async cancelGoal(e,t){if(!this.runtime.cancelGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelGoal(e,t,"web")}async enqueueMessage(e,t,r="web"){if(!this.runtime.enqueueMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueMessage(e,t,r)}async reorderMessages(e,t){if(!this.runtime.reorderMessages)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderMessages(e,t)}async updateMessage(e,t,r,s){if(!this.runtime.updateMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.updateMessage(e,t,r,s)}async cancelMessage(e,t){if(!this.runtime.cancelMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelMessage(e,t)}async steerMessage(e,t){if(!this.runtime.steerMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.steerMessage(e,t)}withPendingCreations(e){let t=new Set,r=e.map(e=>{t.add(e.id);let r=this.pendingCreations.get(e.id);return this.pendingCreations.delete(e.id),r?f(e,r):e});return[...[...this.pendingCreations.values()].filter(e=>!t.has(e.id)).sort((e,t)=>t.updated.localeCompare(e.updated)),...r]}}function f(e,t){return{...e,cwd:e.cwd||t.cwd,projectId:e.projectId??t.projectId}}function w(e,t){t.executable?delete process.env[e]:process.env[e]=t.detail}function v(){if(!m.__nativeRuntimeService){!function(){let e=[(0,i.join)((0,n.homedir)(),".local","bin"),"/opt/homebrew/bin","/usr/local/bin"],t=(process.env.PATH??"").split(i.delimiter),r=e.filter(e=>(0,s.existsSync)(e)&&!t.includes(e));r.length>0&&(process.env.PATH=[...t,...r].join(i.delimiter))}();let e=new a.XWE((0,h.kO)());m.__nativeRuntimeService=new g((0,p.v6)({runtimeFactory:e=>{let t=c({name:"codex",environmentVariable:"AGENT_CODEX_BIN",minimumVersion:a.hix}),r=c({name:"opencode",environmentVariable:"AGENT_OPENCODE_BIN"});return process.pid,w("AGENT_CODEX_RUNTIME_ERROR",t),w("AGENT_OPENCODE_RUNTIME_ERROR",r),(0,d.L)().info("native runtime host elected",{pid:process.pid,codex:t.executable??null,codexSource:t.source??null,codexDetail:t.detail,opencode:r.executable??null,opencodeDetail:r.detail}),(0,p.WH)(t.executable??"codex",e,r.executable??"opencode")}}),()=>e.list())}return m.__nativeRuntimeService}function N(e,t,r=process.platform){let{projectId:s,...n}=e;if(!e.cwd)return n;let o=_(e.cwd,r),a="win32"===r?i.win32.sep:i.sep,u=t.filter(e=>e.description).map(e=>({project:e,path:_(e.description,r)})).filter(({path:e})=>o===e||o.startsWith(`${e}${a}`)).sort((e,t)=>t.path.length-e.path.length)[0];return u?{...n,projectId:u.project.id}:n}function _(e,t=process.platform){if("win32"!==t)return(0,i.resolve)(e);let r=i.win32.resolve(e),s=i.win32.parse(r).root;return(r.length>s.length?r.replace(/[\\/]+$/,""):r).toLowerCase()}function b(e,t){return void 0===t?e:e.filter(e=>e.projectId===t)}function E(e){try{return"customer-agent"!==(0,p.Vu)(e).agentType}catch{return!1}}function R(e){if(e instanceof p.no)switch(e.code){case"SESSION_NOT_FOUND":return 404;case"SESSION_OCCUPIED":case"SESSION_ALREADY_RUNNING":case"APPROVAL_EXPIRED":case"CODEX_SESSION_VERSION_INCOMPATIBLE":case"STALE_SESSION_ANCHOR":return 409;case"RUNTIME_UNAVAILABLE":return 503;case"OPERATION_NOT_SUPPORTED":return 405;default:return 400}return 500}},1489:(e,t,r)=>{r.d(t,{N:()=>u});var s=r(1322),n=r(6279),i=r(785);class o{constructor(){this.tasks=new s.vo4((0,i.kO)()),this.scheduler=new n.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await r.e(7519).then(r.bind(r,7519)),{getCustomerGoalCoordinator:s}=await Promise.all([r.e(7519),r.e(732)]).then(r.bind(r,732)),n=e.sessionId;n&&await t.getSessionStore().get(n)||(n=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:n})),await s().enqueue(n,e.prompt)}call(e,t){let r=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(r);case"cronResume":return this.tasks.resume(r);case"cronDelete":return this.tasks.delete(r);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function u(){return a.__sharedCronService??=new o}},1366:(e,t,r)=>{r.d(t,{C:()=>a,a:()=>u});var s=r(1322),n=r(7519),i=r(785);let o=globalThis;function a(){if(o.__threadGoalService)return o.__threadGoalService;let e=new s.rA9(new s.ZIW((0,i.kO)()),{isSessionRunning:e=>n.agentHost.isSessionRunning(e),startTurn:async(e,t)=>{if(n.agentHost.isSessionRunning(e))return!1;try{return n.agentHost.startRun(t,e,void 0,{source:"goal"}).completion.catch(()=>{}),!0}catch(e){if(e instanceof n.A)return!1;throw e}},steerHidden:(e,t)=>n.agentHost.steer(t,e,"__goal__"),sessionExists:async e=>!!await n.agentHost.getSessionStore().get(e)},{onUpdated:(e,t)=>n.agentHost.publishExternal(e,{type:"goal_updated",goal:t}),onCleared:e=>n.agentHost.publishExternal(e,{type:"goal_cleared",sessionId:e})});return n.agentHost.onRunSettled=t=>{e.onRunSettled({sessionId:t.sessionId,failed:t.failed,usageLimited:t.usageLimited,tokens:t.newTokens,seconds:t.durationMs/1e3}).catch(()=>{})},n.agentHost.threadGoalToolsProvider=t=>(0,s.DAt)(e,t),o.__threadGoalService=e,e}function u(){a().resumeInterrupted().catch(()=>{})}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6703,6244,1322,1773,4621,7519],()=>r(3945));module.exports=s})();
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=6787,e.ids=[6787],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},106:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>m,patchFetch:()=>f,requestAsyncStorage:()=>d,routeModule:()=>c,serverHooks:()=>h,staticGenerationAsyncStorage:()=>p});var s={};r.r(s),r.d(s,{GET:()=>l});var i=r(7786),n=r(5042),o=r(2184),a=r(1890),u=r(1614);async function l(e,{params:t}){if(!(0,u.V_)(t.id))return a.NextResponse.json({error:"Session tool results are available only for native sessions",code:"OPERATION_NOT_SUPPORTED"},{status:405});let r=new URL(e.url),s=r.searchParams.get("turnId")?.trim(),i=r.searchParams.get("itemId")?.trim(),n=r.searchParams.get("revision")?.trim();if(!s||!i||!n)return a.NextResponse.json({error:"turnId, itemId, and revision are required",code:"INVALID_SESSION_ID"},{status:400});try{let e=await (0,u.NL)().getSessionToolResult(t.id,{turnId:s,itemId:i,revision:n});return a.NextResponse.json(e)}catch(r){let e="object"==typeof r&&null!==r&&"string"==typeof r.code?r.code:void 0,t=(0,u.WW)(r);return a.NextResponse.json({error:r instanceof Error?r.message:"Unable to load tool result",...e?{code:e}:{}},{status:t})}}let c=new i.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/sessions/[id]/tool-result/route",pathname:"/api/sessions/[id]/tool-result",filename:"route",bundlePath:"app/api/sessions/[id]/tool-result/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/sessions/[id]/tool-result/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:d,staticGenerationAsyncStorage:p,serverHooks:h}=c,m="/api/sessions/[id]/tool-result/route";function f(){return(0,o.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:p})}},535:(e,t,r)=>{r.d(t,{L:()=>o});var s=r(1322),i=r(785);let n=!1;function o(){let e=(0,s.Qfc)();if(e)return e;let t=(0,s.qZ_)({dir:(0,i.ME)(),source:"server",minLevel:"info",handlers:{exitOnUncaughtException:!1}});return n||(n=!0,t.info("server logger attached",{dir:t.dir,pid:process.pid})),t}},1614:(e,t,r)=>{r.d(t,{NL:()=>v,V_:()=>E,WW:()=>_});var s=r(7561),i=r(612),n=r(9411),o=r(7718),a=r(1322);function u(e){if(!e.trim())return!1;try{return(0,s.accessSync)(e,s.constants.X_OK),!0}catch{return!1}}function l(e){try{return(0,a.wyD)((0,o.execFileSync)(e,["--version"],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","pipe"]}))}catch{return}}function c(e){let t=[],r=process.env[e.environmentVariable]?.trim();if(r){let s=u(r);t.push({source:"pin",path:r,executable:s,version:s?l(r):void 0,error:s?void 0:`${e.environmentVariable} "${r}" is not executable`})}let s=function(e){for(let t of(process.env.PATH??"").split(n.delimiter).filter(Boolean)){let r=(0,n.resolve)(t,e);if(u(r))return r}}(e.name);return s&&s!==r&&t.push({source:"path",path:s,executable:!0,version:l(s)}),(0,a.neJ)(t,{name:e.name,minimumVersion:e.minimumVersion})}var d=r(535),p=r(6279),h=r(785);let m=globalThis;class f{constructor(e,t=async()=>[],r=process.platform){this.runtime=e,this.listProjects=t,this.platform=r,this.pendingCreations=new Map}health(){return this.runtime.health()}listModels(e){return this.runtime.listModels(e)}listWorkspaces(e,t){return this.runtime.listWorkspaces(e,t)}importWorkspace(e,t,r){if(!this.runtime.importWorkspace)throw new p.no("Native workspace import is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.importWorkspace(e,t,r)}async listWorkspaceSessions(e,t,r){let s=await this.runtime.listWorkspaceSessions(e,t,r);if(r?.cursor)return s;let i=new Set(s.data.map(e=>e.id)),n=s.data.map(e=>{let t=this.pendingCreations.get(e.id);return t?(this.pendingCreations.delete(e.id),g(e,t)):e});for(let r of this.pendingCreations.values())r.agentType!==e||r.projectId!==t||i.has(r.id)||n.unshift(r);return{...s,data:n}}async list(e){let[t,r]=await Promise.all([this.runtime.list(),this.listProjects()]);return P(this.withPendingCreations(t).map(e=>O(e,r,this.platform)),e)}async refresh(e){let[t,r]=await Promise.all([this.runtime.refresh(),this.listProjects()]);return P(this.withPendingCreations(t).map(e=>O(e,r,this.platform)),e)}async create(e){let t=O(await this.runtime.create(e),await this.listProjects(),this.platform),r=e.projectId?{...t,projectId:e.projectId}:t;return this.pendingCreations.set(r.id,r),r}async fork(e){if(!E(e))throw new p.no("Customer Agent sessions do not support native forks","OPERATION_NOT_SUPPORTED");let t=O(await this.runtime.fork(e),await this.listProjects(),this.platform);return this.pendingCreations.set(t.id,t),t}async delete(e){await this.runtime.delete(e),this.pendingCreations.delete(e)}async get(e,t){let r;try{r=await this.runtime.get(e,t)}catch(s){let r=this.pendingCreations.get(e);if(!r)throw s;return t?{...r,messages:[],events:[],history:{nextCursor:null,hasMore:!1,pageSize:0,totalItems:0}}:{...r,messages:[],events:[]}}return O(r,await this.listProjects(),this.platform)}async getQueryIndex(e){if(this.runtime.getQueryIndex)return this.runtime.getQueryIndex(e);let t=await this.runtime.get(e),{buildSessionQueryIndex:s}=await Promise.resolve().then(r.bind(r,1322));return s(e,t.messages)}getSessionToolResult(e,t){return this.runtime.getSessionToolResult(e,t)}getSessionWatchPath(e){return this.runtime.getSessionWatchPath(e)}run(e,t,r,s,i){return this.runtime.run(e,t,r,s,i)}steer(e,t){return this.runtime.steer(e,t)}abort(e){return this.runtime.abort(e)}async release(e){if(!this.runtime.release)throw new p.no("Native runtime release is unavailable","RUNTIME_UNAVAILABLE");await this.runtime.release(e)}answerQuestion(e,t){return this.runtime.answerQuestion(e,t)}async startRun(e,t,r,s="web",i){if(!this.runtime.startRun)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.startRun(e,t,r,s,i)}async subscribe(e,t,r){if(!this.runtime.subscribe)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.subscribe(e,t,r)}async snapshot(e,t=0){if(!this.runtime.snapshot)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.snapshot(e,t)}async setPermissionMode(e,t){if(!this.runtime.setPermissionMode)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.setPermissionMode(e,t)}async handoff(e,t){if(!this.runtime.handoff)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.handoff(e,t)}async getGoals(e,t="web"){if(!this.runtime.getGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.getGoals(e,t)}async enqueueGoal(e,t,r,s="web"){if(!this.runtime.enqueueGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueGoal(e,t,r,s)}async reorderGoals(e,t){if(!this.runtime.reorderGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderGoals(e,t)}async cancelGoal(e,t){if(!this.runtime.cancelGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelGoal(e,t,"web")}async enqueueMessage(e,t,r="web"){if(!this.runtime.enqueueMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueMessage(e,t,r)}async reorderMessages(e,t){if(!this.runtime.reorderMessages)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderMessages(e,t)}async updateMessage(e,t,r,s){if(!this.runtime.updateMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.updateMessage(e,t,r,s)}async cancelMessage(e,t){if(!this.runtime.cancelMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelMessage(e,t)}async steerMessage(e,t){if(!this.runtime.steerMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.steerMessage(e,t)}withPendingCreations(e){let t=new Set,r=e.map(e=>{t.add(e.id);let r=this.pendingCreations.get(e.id);return this.pendingCreations.delete(e.id),r?g(e,r):e});return[...[...this.pendingCreations.values()].filter(e=>!t.has(e.id)).sort((e,t)=>t.updated.localeCompare(e.updated)),...r]}}function g(e,t){return{...e,cwd:e.cwd||t.cwd,projectId:e.projectId??t.projectId}}function w(e,t){t.executable?delete process.env[e]:process.env[e]=t.detail}function v(){if(!m.__nativeRuntimeService){!function(){let e=[(0,n.join)((0,i.homedir)(),".local","bin"),"/opt/homebrew/bin","/usr/local/bin"],t=(process.env.PATH??"").split(n.delimiter),r=e.filter(e=>(0,s.existsSync)(e)&&!t.includes(e));r.length>0&&(process.env.PATH=[...t,...r].join(n.delimiter))}();let e=new a.XWE((0,h.kO)());m.__nativeRuntimeService=new f((0,p.v6)({runtimeFactory:e=>{let t=c({name:"codex",environmentVariable:"AGENT_CODEX_BIN",minimumVersion:a.hix}),r=c({name:"opencode",environmentVariable:"AGENT_OPENCODE_BIN"});return process.pid,w("AGENT_CODEX_RUNTIME_ERROR",t),w("AGENT_OPENCODE_RUNTIME_ERROR",r),(0,d.L)().info("native runtime host elected",{pid:process.pid,codex:t.executable??null,codexSource:t.source??null,codexDetail:t.detail,opencode:r.executable??null,opencodeDetail:r.detail}),(0,p.WH)(t.executable??"codex",e,r.executable??"opencode")}}),()=>e.list())}return m.__nativeRuntimeService}function O(e,t,r=process.platform){let{projectId:s,...i}=e;if(!e.cwd)return i;let o=N(e.cwd,r),a="win32"===r?n.win32.sep:n.sep,u=t.filter(e=>e.description).map(e=>({project:e,path:N(e.description,r)})).filter(({path:e})=>o===e||o.startsWith(`${e}${a}`)).sort((e,t)=>t.path.length-e.path.length)[0];return u?{...i,projectId:u.project.id}:i}function N(e,t=process.platform){if("win32"!==t)return(0,n.resolve)(e);let r=n.win32.resolve(e),s=n.win32.parse(r).root;return(r.length>s.length?r.replace(/[\\/]+$/,""):r).toLowerCase()}function P(e,t){return void 0===t?e:e.filter(e=>e.projectId===t)}function E(e){try{return"customer-agent"!==(0,p.Vu)(e).agentType}catch{return!1}}function _(e){if(e instanceof p.no)switch(e.code){case"SESSION_NOT_FOUND":return 404;case"SESSION_OCCUPIED":case"SESSION_ALREADY_RUNNING":case"APPROVAL_EXPIRED":case"CODEX_SESSION_VERSION_INCOMPATIBLE":case"STALE_SESSION_ANCHOR":return 409;case"RUNTIME_UNAVAILABLE":return 503;case"OPERATION_NOT_SUPPORTED":return 405;default:return 400}return 500}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6703,6244,1322,1773],()=>r(106));module.exports=s})();
1
+ "use strict";(()=>{var e={};e.id=6787,e.ids=[6787],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},1:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>m,patchFetch:()=>f,requestAsyncStorage:()=>d,routeModule:()=>c,serverHooks:()=>h,staticGenerationAsyncStorage:()=>p});var s={};r.r(s),r.d(s,{GET:()=>l});var i=r(7786),n=r(5042),o=r(2184),a=r(1890),u=r(1614);async function l(e,{params:t}){if(!(0,u.V_)(t.id))return a.NextResponse.json({error:"Session tool results are available only for native sessions",code:"OPERATION_NOT_SUPPORTED"},{status:405});let r=new URL(e.url),s=r.searchParams.get("turnId")?.trim(),i=r.searchParams.get("itemId")?.trim(),n=r.searchParams.get("revision")?.trim();if(!s||!i||!n)return a.NextResponse.json({error:"turnId, itemId, and revision are required",code:"INVALID_SESSION_ID"},{status:400});try{let e=await (0,u.NL)().getSessionToolResult(t.id,{turnId:s,itemId:i,revision:n});return a.NextResponse.json(e)}catch(r){let e="object"==typeof r&&null!==r&&"string"==typeof r.code?r.code:void 0,t=(0,u.WW)(r);return a.NextResponse.json({error:r instanceof Error?r.message:"Unable to load tool result",...e?{code:e}:{}},{status:t})}}let c=new i.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/sessions/[id]/tool-result/route",pathname:"/api/sessions/[id]/tool-result",filename:"route",bundlePath:"app/api/sessions/[id]/tool-result/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/sessions/[id]/tool-result/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:d,staticGenerationAsyncStorage:p,serverHooks:h}=c,m="/api/sessions/[id]/tool-result/route";function f(){return(0,o.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:p})}},535:(e,t,r)=>{r.d(t,{L:()=>o});var s=r(1322),i=r(785);let n=!1;function o(){let e=(0,s.Qfc)();if(e)return e;let t=(0,s.qZ_)({dir:(0,i.ME)(),source:"server",minLevel:"info",handlers:{exitOnUncaughtException:!1}});return n||(n=!0,t.info("server logger attached",{dir:t.dir,pid:process.pid})),t}},1614:(e,t,r)=>{r.d(t,{NL:()=>v,V_:()=>E,WW:()=>_});var s=r(7561),i=r(612),n=r(9411),o=r(7718),a=r(1322);function u(e){if(!e.trim())return!1;try{return(0,s.accessSync)(e,s.constants.X_OK),!0}catch{return!1}}function l(e){try{return(0,a.wyD)((0,o.execFileSync)(e,["--version"],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","pipe"]}))}catch{return}}function c(e){let t=[],r=process.env[e.environmentVariable]?.trim();if(r){let s=u(r);t.push({source:"pin",path:r,executable:s,version:s?l(r):void 0,error:s?void 0:`${e.environmentVariable} "${r}" is not executable`})}let s=function(e){for(let t of(process.env.PATH??"").split(n.delimiter).filter(Boolean)){let r=(0,n.resolve)(t,e);if(u(r))return r}}(e.name);return s&&s!==r&&t.push({source:"path",path:s,executable:!0,version:l(s)}),(0,a.neJ)(t,{name:e.name,minimumVersion:e.minimumVersion})}var d=r(535),p=r(6279),h=r(785);let m=globalThis;class f{constructor(e,t=async()=>[],r=process.platform){this.runtime=e,this.listProjects=t,this.platform=r,this.pendingCreations=new Map}health(){return this.runtime.health()}listModels(e){return this.runtime.listModels(e)}listWorkspaces(e,t){return this.runtime.listWorkspaces(e,t)}importWorkspace(e,t,r){if(!this.runtime.importWorkspace)throw new p.no("Native workspace import is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.importWorkspace(e,t,r)}async listWorkspaceSessions(e,t,r){let s=await this.runtime.listWorkspaceSessions(e,t,r);if(r?.cursor)return s;let i=new Set(s.data.map(e=>e.id)),n=s.data.map(e=>{let t=this.pendingCreations.get(e.id);return t?(this.pendingCreations.delete(e.id),g(e,t)):e});for(let r of this.pendingCreations.values())r.agentType!==e||r.projectId!==t||i.has(r.id)||n.unshift(r);return{...s,data:n}}async list(e){let[t,r]=await Promise.all([this.runtime.list(),this.listProjects()]);return P(this.withPendingCreations(t).map(e=>O(e,r,this.platform)),e)}async refresh(e){let[t,r]=await Promise.all([this.runtime.refresh(),this.listProjects()]);return P(this.withPendingCreations(t).map(e=>O(e,r,this.platform)),e)}async create(e){let t=O(await this.runtime.create(e),await this.listProjects(),this.platform),r=e.projectId?{...t,projectId:e.projectId}:t;return this.pendingCreations.set(r.id,r),r}async fork(e,t){if(!E(e))throw new p.no("Customer Agent sessions do not support native forks","OPERATION_NOT_SUPPORTED");let r=O(t?await this.runtime.fork(e,t):await this.runtime.fork(e),await this.listProjects(),this.platform);return this.pendingCreations.set(r.id,r),r}async delete(e){await this.runtime.delete(e),this.pendingCreations.delete(e)}async get(e,t){let r;try{r=await this.runtime.get(e,t)}catch(s){let r=this.pendingCreations.get(e);if(!r)throw s;return t?{...r,messages:[],events:[],history:{nextCursor:null,hasMore:!1,pageSize:0,totalItems:0}}:{...r,messages:[],events:[]}}return O(r,await this.listProjects(),this.platform)}async getQueryIndex(e){if(this.runtime.getQueryIndex)return this.runtime.getQueryIndex(e);let t=await this.runtime.get(e),{buildSessionQueryIndex:s}=await Promise.resolve().then(r.bind(r,1322));return s(e,t.messages)}getSessionToolResult(e,t){return this.runtime.getSessionToolResult(e,t)}getSessionWatchPath(e){return this.runtime.getSessionWatchPath(e)}run(e,t,r,s,i){return this.runtime.run(e,t,r,s,i)}steer(e,t){return this.runtime.steer(e,t)}abort(e){return this.runtime.abort(e)}async release(e){if(!this.runtime.release)throw new p.no("Native runtime release is unavailable","RUNTIME_UNAVAILABLE");await this.runtime.release(e)}answerQuestion(e,t){return this.runtime.answerQuestion(e,t)}async startRun(e,t,r,s="web",i){if(!this.runtime.startRun)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.startRun(e,t,r,s,i)}async subscribe(e,t,r){if(!this.runtime.subscribe)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.subscribe(e,t,r)}async snapshot(e,t=0){if(!this.runtime.snapshot)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.snapshot(e,t)}async setPermissionMode(e,t){if(!this.runtime.setPermissionMode)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.setPermissionMode(e,t)}async handoff(e,t){if(!this.runtime.handoff)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.handoff(e,t)}async getGoals(e,t="web"){if(!this.runtime.getGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.getGoals(e,t)}async enqueueGoal(e,t,r,s="web"){if(!this.runtime.enqueueGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueGoal(e,t,r,s)}async reorderGoals(e,t){if(!this.runtime.reorderGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderGoals(e,t)}async cancelGoal(e,t){if(!this.runtime.cancelGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelGoal(e,t,"web")}async enqueueMessage(e,t,r="web"){if(!this.runtime.enqueueMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueMessage(e,t,r)}async reorderMessages(e,t){if(!this.runtime.reorderMessages)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderMessages(e,t)}async updateMessage(e,t,r,s){if(!this.runtime.updateMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.updateMessage(e,t,r,s)}async cancelMessage(e,t){if(!this.runtime.cancelMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelMessage(e,t)}async steerMessage(e,t){if(!this.runtime.steerMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.steerMessage(e,t)}withPendingCreations(e){let t=new Set,r=e.map(e=>{t.add(e.id);let r=this.pendingCreations.get(e.id);return this.pendingCreations.delete(e.id),r?g(e,r):e});return[...[...this.pendingCreations.values()].filter(e=>!t.has(e.id)).sort((e,t)=>t.updated.localeCompare(e.updated)),...r]}}function g(e,t){return{...e,cwd:e.cwd||t.cwd,projectId:e.projectId??t.projectId}}function w(e,t){t.executable?delete process.env[e]:process.env[e]=t.detail}function v(){if(!m.__nativeRuntimeService){!function(){let e=[(0,n.join)((0,i.homedir)(),".local","bin"),"/opt/homebrew/bin","/usr/local/bin"],t=(process.env.PATH??"").split(n.delimiter),r=e.filter(e=>(0,s.existsSync)(e)&&!t.includes(e));r.length>0&&(process.env.PATH=[...t,...r].join(n.delimiter))}();let e=new a.XWE((0,h.kO)());m.__nativeRuntimeService=new f((0,p.v6)({runtimeFactory:e=>{let t=c({name:"codex",environmentVariable:"AGENT_CODEX_BIN",minimumVersion:a.hix}),r=c({name:"opencode",environmentVariable:"AGENT_OPENCODE_BIN"});return process.pid,w("AGENT_CODEX_RUNTIME_ERROR",t),w("AGENT_OPENCODE_RUNTIME_ERROR",r),(0,d.L)().info("native runtime host elected",{pid:process.pid,codex:t.executable??null,codexSource:t.source??null,codexDetail:t.detail,opencode:r.executable??null,opencodeDetail:r.detail}),(0,p.WH)(t.executable??"codex",e,r.executable??"opencode")}}),()=>e.list())}return m.__nativeRuntimeService}function O(e,t,r=process.platform){let{projectId:s,...i}=e;if(!e.cwd)return i;let o=N(e.cwd,r),a="win32"===r?n.win32.sep:n.sep,u=t.filter(e=>e.description).map(e=>({project:e,path:N(e.description,r)})).filter(({path:e})=>o===e||o.startsWith(`${e}${a}`)).sort((e,t)=>t.path.length-e.path.length)[0];return u?{...i,projectId:u.project.id}:i}function N(e,t=process.platform){if("win32"!==t)return(0,n.resolve)(e);let r=n.win32.resolve(e),s=n.win32.parse(r).root;return(r.length>s.length?r.replace(/[\\/]+$/,""):r).toLowerCase()}function P(e,t){return void 0===t?e:e.filter(e=>e.projectId===t)}function E(e){try{return"customer-agent"!==(0,p.Vu)(e).agentType}catch{return!1}}function _(e){if(e instanceof p.no)switch(e.code){case"SESSION_NOT_FOUND":return 404;case"SESSION_OCCUPIED":case"SESSION_ALREADY_RUNNING":case"APPROVAL_EXPIRED":case"CODEX_SESSION_VERSION_INCOMPATIBLE":case"STALE_SESSION_ANCHOR":return 409;case"RUNTIME_UNAVAILABLE":return 503;case"OPERATION_NOT_SUPPORTED":return 405;default:return 400}return 500}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6703,6244,1322,1773],()=>r(1));module.exports=s})();
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=1772,e.ids=[1772],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},4127:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>f,patchFetch:()=>N,requestAsyncStorage:()=>m,routeModule:()=>h,serverHooks:()=>w,staticGenerationAsyncStorage:()=>g});var s={};r.r(s),r.d(s,{GET:()=>p,POST:()=>d});var n=r(7786),i=r(5042),a=r(2184),o=r(1890),u=r(1322),l=r(7519),c=r(1614);async function p(e){let t=new URL(e.url),r=t.searchParams.get("projectId")||void 0,s="1"===t.searchParams.get("refresh"),n=await l.agentHost.getSessionStore().list(r),i=(0,c.NL)(),a=n.map(({messages:e,events:t,...r})=>({...r,agentType:"customer-agent",messageQueueVersion:1,canDelete:!l.agentHost.isSessionRunning(r.id),permissionMode:(0,u.NyU)(r.metadata.permissionMode)}));try{let e=s?await i.refresh(r):await i.list(r);return o.NextResponse.json([...a,...e])}catch(e){return console.error("Native session discovery failed:",e),o.NextResponse.json(a)}}async function d(e){let t=await e.json(),r=t.agentType??"customer-agent";if("customer-agent"!==r)try{if(!t.projectId&&!t.cwd?.trim())throw new l.B("请选择宿主机项目","PROJECT_PATH_REQUIRED",400);let e=t.cwd?.trim()||(t.projectId?await l.agentHost.resolveProjectWorkingDirectory(t.projectId,!0):""),s=await (0,c.NL)().create({agentType:r,title:t.title??"新会话",cwd:e,...t.projectId?{projectId:t.projectId}:{}});return o.NextResponse.json(s,{status:201})}catch(e){if(e instanceof l.B)return o.NextResponse.json({error:{code:e.code,message:e.message}},{status:e.status});return o.NextResponse.json({error:e instanceof Error?e.message:"Internal error"},{status:(0,c.WW)(e)})}let s=await l.agentHost.createSession(t.title??"Untitled",t.projectId??"");return o.NextResponse.json({...s,agentType:"customer-agent",messageQueueVersion:1},{status:201})}let h=new n.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/sessions/route",pathname:"/api/sessions",filename:"route",bundlePath:"app/api/sessions/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/sessions/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:m,staticGenerationAsyncStorage:g,serverHooks:w}=h,f="/api/sessions/route";function N(){return(0,a.patchFetch)({serverHooks:w,staticGenerationAsyncStorage:g})}},1614:(e,t,r)=>{r.d(t,{NL:()=>N,V_:()=>E,WW:()=>T});var s=r(7561),n=r(612),i=r(9411),a=r(7718),o=r(1322);function u(e){if(!e.trim())return!1;try{return(0,s.accessSync)(e,s.constants.X_OK),!0}catch{return!1}}function l(e){try{return(0,o.wyD)((0,a.execFileSync)(e,["--version"],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","pipe"]}))}catch{return}}function c(e){let t=[],r=process.env[e.environmentVariable]?.trim();if(r){let s=u(r);t.push({source:"pin",path:r,executable:s,version:s?l(r):void 0,error:s?void 0:`${e.environmentVariable} "${r}" is not executable`})}let s=function(e){for(let t of(process.env.PATH??"").split(i.delimiter).filter(Boolean)){let r=(0,i.resolve)(t,e);if(u(r))return r}}(e.name);return s&&s!==r&&t.push({source:"path",path:s,executable:!0,version:l(s)}),(0,o.neJ)(t,{name:e.name,minimumVersion:e.minimumVersion})}var p=r(535),d=r(6279),h=r(785);let m=globalThis;class g{constructor(e,t=async()=>[],r=process.platform){this.runtime=e,this.listProjects=t,this.platform=r,this.pendingCreations=new Map}health(){return this.runtime.health()}listModels(e){return this.runtime.listModels(e)}listWorkspaces(e,t){return this.runtime.listWorkspaces(e,t)}importWorkspace(e,t,r){if(!this.runtime.importWorkspace)throw new d.no("Native workspace import is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.importWorkspace(e,t,r)}async listWorkspaceSessions(e,t,r){let s=await this.runtime.listWorkspaceSessions(e,t,r);if(r?.cursor)return s;let n=new Set(s.data.map(e=>e.id)),i=s.data.map(e=>{let t=this.pendingCreations.get(e.id);return t?(this.pendingCreations.delete(e.id),w(e,t)):e});for(let r of this.pendingCreations.values())r.agentType!==e||r.projectId!==t||n.has(r.id)||i.unshift(r);return{...s,data:i}}async list(e){let[t,r]=await Promise.all([this.runtime.list(),this.listProjects()]);return O(this.withPendingCreations(t).map(e=>v(e,r,this.platform)),e)}async refresh(e){let[t,r]=await Promise.all([this.runtime.refresh(),this.listProjects()]);return O(this.withPendingCreations(t).map(e=>v(e,r,this.platform)),e)}async create(e){let t=v(await this.runtime.create(e),await this.listProjects(),this.platform),r=e.projectId?{...t,projectId:e.projectId}:t;return this.pendingCreations.set(r.id,r),r}async fork(e){if(!E(e))throw new d.no("Customer Agent sessions do not support native forks","OPERATION_NOT_SUPPORTED");let t=v(await this.runtime.fork(e),await this.listProjects(),this.platform);return this.pendingCreations.set(t.id,t),t}async delete(e){await this.runtime.delete(e),this.pendingCreations.delete(e)}async get(e,t){let r;try{r=await this.runtime.get(e,t)}catch(s){let r=this.pendingCreations.get(e);if(!r)throw s;return t?{...r,messages:[],events:[],history:{nextCursor:null,hasMore:!1,pageSize:0,totalItems:0}}:{...r,messages:[],events:[]}}return v(r,await this.listProjects(),this.platform)}async getQueryIndex(e){if(this.runtime.getQueryIndex)return this.runtime.getQueryIndex(e);let t=await this.runtime.get(e),{buildSessionQueryIndex:s}=await Promise.resolve().then(r.bind(r,1322));return s(e,t.messages)}getSessionToolResult(e,t){return this.runtime.getSessionToolResult(e,t)}getSessionWatchPath(e){return this.runtime.getSessionWatchPath(e)}run(e,t,r,s,n){return this.runtime.run(e,t,r,s,n)}steer(e,t){return this.runtime.steer(e,t)}abort(e){return this.runtime.abort(e)}async release(e){if(!this.runtime.release)throw new d.no("Native runtime release is unavailable","RUNTIME_UNAVAILABLE");await this.runtime.release(e)}answerQuestion(e,t){return this.runtime.answerQuestion(e,t)}async startRun(e,t,r,s="web",n){if(!this.runtime.startRun)throw new d.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.startRun(e,t,r,s,n)}async subscribe(e,t,r){if(!this.runtime.subscribe)throw new d.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.subscribe(e,t,r)}async snapshot(e,t=0){if(!this.runtime.snapshot)throw new d.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.snapshot(e,t)}async setPermissionMode(e,t){if(!this.runtime.setPermissionMode)throw new d.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.setPermissionMode(e,t)}async handoff(e,t){if(!this.runtime.handoff)throw new d.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.handoff(e,t)}async getGoals(e,t="web"){if(!this.runtime.getGoals)throw new d.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.getGoals(e,t)}async enqueueGoal(e,t,r,s="web"){if(!this.runtime.enqueueGoal)throw new d.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueGoal(e,t,r,s)}async reorderGoals(e,t){if(!this.runtime.reorderGoals)throw new d.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderGoals(e,t)}async cancelGoal(e,t){if(!this.runtime.cancelGoal)throw new d.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelGoal(e,t,"web")}async enqueueMessage(e,t,r="web"){if(!this.runtime.enqueueMessage)throw new d.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueMessage(e,t,r)}async reorderMessages(e,t){if(!this.runtime.reorderMessages)throw new d.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderMessages(e,t)}async updateMessage(e,t,r,s){if(!this.runtime.updateMessage)throw new d.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.updateMessage(e,t,r,s)}async cancelMessage(e,t){if(!this.runtime.cancelMessage)throw new d.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelMessage(e,t)}async steerMessage(e,t){if(!this.runtime.steerMessage)throw new d.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.steerMessage(e,t)}withPendingCreations(e){let t=new Set,r=e.map(e=>{t.add(e.id);let r=this.pendingCreations.get(e.id);return this.pendingCreations.delete(e.id),r?w(e,r):e});return[...[...this.pendingCreations.values()].filter(e=>!t.has(e.id)).sort((e,t)=>t.updated.localeCompare(e.updated)),...r]}}function w(e,t){return{...e,cwd:e.cwd||t.cwd,projectId:e.projectId??t.projectId}}function f(e,t){t.executable?delete process.env[e]:process.env[e]=t.detail}function N(){if(!m.__nativeRuntimeService){!function(){let e=[(0,i.join)((0,n.homedir)(),".local","bin"),"/opt/homebrew/bin","/usr/local/bin"],t=(process.env.PATH??"").split(i.delimiter),r=e.filter(e=>(0,s.existsSync)(e)&&!t.includes(e));r.length>0&&(process.env.PATH=[...t,...r].join(i.delimiter))}();let e=new o.XWE((0,h.kO)());m.__nativeRuntimeService=new g((0,d.v6)({runtimeFactory:e=>{let t=c({name:"codex",environmentVariable:"AGENT_CODEX_BIN",minimumVersion:o.hix}),r=c({name:"opencode",environmentVariable:"AGENT_OPENCODE_BIN"});return process.pid,f("AGENT_CODEX_RUNTIME_ERROR",t),f("AGENT_OPENCODE_RUNTIME_ERROR",r),(0,p.L)().info("native runtime host elected",{pid:process.pid,codex:t.executable??null,codexSource:t.source??null,codexDetail:t.detail,opencode:r.executable??null,opencodeDetail:r.detail}),(0,d.WH)(t.executable??"codex",e,r.executable??"opencode")}}),()=>e.list())}return m.__nativeRuntimeService}function v(e,t,r=process.platform){let{projectId:s,...n}=e;if(!e.cwd)return n;let a=P(e.cwd,r),o="win32"===r?i.win32.sep:i.sep,u=t.filter(e=>e.description).map(e=>({project:e,path:P(e.description,r)})).filter(({path:e})=>a===e||a.startsWith(`${e}${o}`)).sort((e,t)=>t.path.length-e.path.length)[0];return u?{...n,projectId:u.project.id}:n}function P(e,t=process.platform){if("win32"!==t)return(0,i.resolve)(e);let r=i.win32.resolve(e),s=i.win32.parse(r).root;return(r.length>s.length?r.replace(/[\\/]+$/,""):r).toLowerCase()}function O(e,t){return void 0===t?e:e.filter(e=>e.projectId===t)}function E(e){try{return"customer-agent"!==(0,d.Vu)(e).agentType}catch{return!1}}function T(e){if(e instanceof d.no)switch(e.code){case"SESSION_NOT_FOUND":return 404;case"SESSION_OCCUPIED":case"SESSION_ALREADY_RUNNING":case"APPROVAL_EXPIRED":case"CODEX_SESSION_VERSION_INCOMPATIBLE":case"STALE_SESSION_ANCHOR":return 409;case"RUNTIME_UNAVAILABLE":return 503;case"OPERATION_NOT_SUPPORTED":return 405;default:return 400}return 500}},1489:(e,t,r)=>{r.d(t,{N:()=>u});var s=r(1322),n=r(6279),i=r(785);class a{constructor(){this.tasks=new s.vo4((0,i.kO)()),this.scheduler=new n.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await r.e(7519).then(r.bind(r,7519)),{getCustomerGoalCoordinator:s}=await Promise.all([r.e(7519),r.e(732)]).then(r.bind(r,732)),n=e.sessionId;n&&await t.getSessionStore().get(n)||(n=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:n})),await s().enqueue(n,e.prompt)}call(e,t){let r=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(r);case"cronResume":return this.tasks.resume(r);case"cronDelete":return this.tasks.delete(r);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let o=globalThis;function u(){return o.__sharedCronService??=new a}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6703,6244,1322,1773,4621,7519],()=>r(4127));module.exports=s})();
1
+ "use strict";(()=>{var e={};e.id=1772,e.ids=[1772],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},4766:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>f,patchFetch:()=>N,requestAsyncStorage:()=>m,routeModule:()=>h,serverHooks:()=>w,staticGenerationAsyncStorage:()=>g});var s={};r.r(s),r.d(s,{GET:()=>p,POST:()=>d});var n=r(7786),i=r(5042),a=r(2184),o=r(1890),u=r(1322),l=r(7519),c=r(1614);async function p(e){let t=new URL(e.url),r=t.searchParams.get("projectId")||void 0,s="1"===t.searchParams.get("refresh"),n=await l.agentHost.getSessionStore().list(r),i=(0,c.NL)(),a=n.map(({messages:e,events:t,...r})=>({...r,agentType:"customer-agent",messageQueueVersion:1,canDelete:!l.agentHost.isSessionRunning(r.id),permissionMode:(0,u.NyU)(r.metadata.permissionMode)}));try{let e=s?await i.refresh(r):await i.list(r);return o.NextResponse.json([...a,...e])}catch(e){return console.error("Native session discovery failed:",e),o.NextResponse.json(a)}}async function d(e){let t=await e.json(),r=t.agentType??"customer-agent";if("customer-agent"!==r)try{if(!t.projectId&&!t.cwd?.trim())throw new l.B("请选择宿主机项目","PROJECT_PATH_REQUIRED",400);let e=t.cwd?.trim()||(t.projectId?await l.agentHost.resolveProjectWorkingDirectory(t.projectId,!0):""),s=await (0,c.NL)().create({agentType:r,title:t.title??"新会话",cwd:e,...t.projectId?{projectId:t.projectId}:{}});return o.NextResponse.json(s,{status:201})}catch(e){if(e instanceof l.B)return o.NextResponse.json({error:{code:e.code,message:e.message}},{status:e.status});return o.NextResponse.json({error:e instanceof Error?e.message:"Internal error"},{status:(0,c.WW)(e)})}let s=await l.agentHost.createSession(t.title??"Untitled",t.projectId??"");return o.NextResponse.json({...s,agentType:"customer-agent",messageQueueVersion:1},{status:201})}let h=new n.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/sessions/route",pathname:"/api/sessions",filename:"route",bundlePath:"app/api/sessions/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/sessions/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:m,staticGenerationAsyncStorage:g,serverHooks:w}=h,f="/api/sessions/route";function N(){return(0,a.patchFetch)({serverHooks:w,staticGenerationAsyncStorage:g})}},1614:(e,t,r)=>{r.d(t,{NL:()=>N,V_:()=>E,WW:()=>T});var s=r(7561),n=r(612),i=r(9411),a=r(7718),o=r(1322);function u(e){if(!e.trim())return!1;try{return(0,s.accessSync)(e,s.constants.X_OK),!0}catch{return!1}}function l(e){try{return(0,o.wyD)((0,a.execFileSync)(e,["--version"],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","pipe"]}))}catch{return}}function c(e){let t=[],r=process.env[e.environmentVariable]?.trim();if(r){let s=u(r);t.push({source:"pin",path:r,executable:s,version:s?l(r):void 0,error:s?void 0:`${e.environmentVariable} "${r}" is not executable`})}let s=function(e){for(let t of(process.env.PATH??"").split(i.delimiter).filter(Boolean)){let r=(0,i.resolve)(t,e);if(u(r))return r}}(e.name);return s&&s!==r&&t.push({source:"path",path:s,executable:!0,version:l(s)}),(0,o.neJ)(t,{name:e.name,minimumVersion:e.minimumVersion})}var p=r(535),d=r(6279),h=r(785);let m=globalThis;class g{constructor(e,t=async()=>[],r=process.platform){this.runtime=e,this.listProjects=t,this.platform=r,this.pendingCreations=new Map}health(){return this.runtime.health()}listModels(e){return this.runtime.listModels(e)}listWorkspaces(e,t){return this.runtime.listWorkspaces(e,t)}importWorkspace(e,t,r){if(!this.runtime.importWorkspace)throw new d.no("Native workspace import is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.importWorkspace(e,t,r)}async listWorkspaceSessions(e,t,r){let s=await this.runtime.listWorkspaceSessions(e,t,r);if(r?.cursor)return s;let n=new Set(s.data.map(e=>e.id)),i=s.data.map(e=>{let t=this.pendingCreations.get(e.id);return t?(this.pendingCreations.delete(e.id),w(e,t)):e});for(let r of this.pendingCreations.values())r.agentType!==e||r.projectId!==t||n.has(r.id)||i.unshift(r);return{...s,data:i}}async list(e){let[t,r]=await Promise.all([this.runtime.list(),this.listProjects()]);return O(this.withPendingCreations(t).map(e=>v(e,r,this.platform)),e)}async refresh(e){let[t,r]=await Promise.all([this.runtime.refresh(),this.listProjects()]);return O(this.withPendingCreations(t).map(e=>v(e,r,this.platform)),e)}async create(e){let t=v(await this.runtime.create(e),await this.listProjects(),this.platform),r=e.projectId?{...t,projectId:e.projectId}:t;return this.pendingCreations.set(r.id,r),r}async fork(e,t){if(!E(e))throw new d.no("Customer Agent sessions do not support native forks","OPERATION_NOT_SUPPORTED");let r=v(t?await this.runtime.fork(e,t):await this.runtime.fork(e),await this.listProjects(),this.platform);return this.pendingCreations.set(r.id,r),r}async delete(e){await this.runtime.delete(e),this.pendingCreations.delete(e)}async get(e,t){let r;try{r=await this.runtime.get(e,t)}catch(s){let r=this.pendingCreations.get(e);if(!r)throw s;return t?{...r,messages:[],events:[],history:{nextCursor:null,hasMore:!1,pageSize:0,totalItems:0}}:{...r,messages:[],events:[]}}return v(r,await this.listProjects(),this.platform)}async getQueryIndex(e){if(this.runtime.getQueryIndex)return this.runtime.getQueryIndex(e);let t=await this.runtime.get(e),{buildSessionQueryIndex:s}=await Promise.resolve().then(r.bind(r,1322));return s(e,t.messages)}getSessionToolResult(e,t){return this.runtime.getSessionToolResult(e,t)}getSessionWatchPath(e){return this.runtime.getSessionWatchPath(e)}run(e,t,r,s,n){return this.runtime.run(e,t,r,s,n)}steer(e,t){return this.runtime.steer(e,t)}abort(e){return this.runtime.abort(e)}async release(e){if(!this.runtime.release)throw new d.no("Native runtime release is unavailable","RUNTIME_UNAVAILABLE");await this.runtime.release(e)}answerQuestion(e,t){return this.runtime.answerQuestion(e,t)}async startRun(e,t,r,s="web",n){if(!this.runtime.startRun)throw new d.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.startRun(e,t,r,s,n)}async subscribe(e,t,r){if(!this.runtime.subscribe)throw new d.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.subscribe(e,t,r)}async snapshot(e,t=0){if(!this.runtime.snapshot)throw new d.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.snapshot(e,t)}async setPermissionMode(e,t){if(!this.runtime.setPermissionMode)throw new d.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.setPermissionMode(e,t)}async handoff(e,t){if(!this.runtime.handoff)throw new d.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.handoff(e,t)}async getGoals(e,t="web"){if(!this.runtime.getGoals)throw new d.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.getGoals(e,t)}async enqueueGoal(e,t,r,s="web"){if(!this.runtime.enqueueGoal)throw new d.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueGoal(e,t,r,s)}async reorderGoals(e,t){if(!this.runtime.reorderGoals)throw new d.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderGoals(e,t)}async cancelGoal(e,t){if(!this.runtime.cancelGoal)throw new d.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelGoal(e,t,"web")}async enqueueMessage(e,t,r="web"){if(!this.runtime.enqueueMessage)throw new d.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueMessage(e,t,r)}async reorderMessages(e,t){if(!this.runtime.reorderMessages)throw new d.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderMessages(e,t)}async updateMessage(e,t,r,s){if(!this.runtime.updateMessage)throw new d.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.updateMessage(e,t,r,s)}async cancelMessage(e,t){if(!this.runtime.cancelMessage)throw new d.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelMessage(e,t)}async steerMessage(e,t){if(!this.runtime.steerMessage)throw new d.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.steerMessage(e,t)}withPendingCreations(e){let t=new Set,r=e.map(e=>{t.add(e.id);let r=this.pendingCreations.get(e.id);return this.pendingCreations.delete(e.id),r?w(e,r):e});return[...[...this.pendingCreations.values()].filter(e=>!t.has(e.id)).sort((e,t)=>t.updated.localeCompare(e.updated)),...r]}}function w(e,t){return{...e,cwd:e.cwd||t.cwd,projectId:e.projectId??t.projectId}}function f(e,t){t.executable?delete process.env[e]:process.env[e]=t.detail}function N(){if(!m.__nativeRuntimeService){!function(){let e=[(0,i.join)((0,n.homedir)(),".local","bin"),"/opt/homebrew/bin","/usr/local/bin"],t=(process.env.PATH??"").split(i.delimiter),r=e.filter(e=>(0,s.existsSync)(e)&&!t.includes(e));r.length>0&&(process.env.PATH=[...t,...r].join(i.delimiter))}();let e=new o.XWE((0,h.kO)());m.__nativeRuntimeService=new g((0,d.v6)({runtimeFactory:e=>{let t=c({name:"codex",environmentVariable:"AGENT_CODEX_BIN",minimumVersion:o.hix}),r=c({name:"opencode",environmentVariable:"AGENT_OPENCODE_BIN"});return process.pid,f("AGENT_CODEX_RUNTIME_ERROR",t),f("AGENT_OPENCODE_RUNTIME_ERROR",r),(0,p.L)().info("native runtime host elected",{pid:process.pid,codex:t.executable??null,codexSource:t.source??null,codexDetail:t.detail,opencode:r.executable??null,opencodeDetail:r.detail}),(0,d.WH)(t.executable??"codex",e,r.executable??"opencode")}}),()=>e.list())}return m.__nativeRuntimeService}function v(e,t,r=process.platform){let{projectId:s,...n}=e;if(!e.cwd)return n;let a=P(e.cwd,r),o="win32"===r?i.win32.sep:i.sep,u=t.filter(e=>e.description).map(e=>({project:e,path:P(e.description,r)})).filter(({path:e})=>a===e||a.startsWith(`${e}${o}`)).sort((e,t)=>t.path.length-e.path.length)[0];return u?{...n,projectId:u.project.id}:n}function P(e,t=process.platform){if("win32"!==t)return(0,i.resolve)(e);let r=i.win32.resolve(e),s=i.win32.parse(r).root;return(r.length>s.length?r.replace(/[\\/]+$/,""):r).toLowerCase()}function O(e,t){return void 0===t?e:e.filter(e=>e.projectId===t)}function E(e){try{return"customer-agent"!==(0,d.Vu)(e).agentType}catch{return!1}}function T(e){if(e instanceof d.no)switch(e.code){case"SESSION_NOT_FOUND":return 404;case"SESSION_OCCUPIED":case"SESSION_ALREADY_RUNNING":case"APPROVAL_EXPIRED":case"CODEX_SESSION_VERSION_INCOMPATIBLE":case"STALE_SESSION_ANCHOR":return 409;case"RUNTIME_UNAVAILABLE":return 503;case"OPERATION_NOT_SUPPORTED":return 405;default:return 400}return 500}},1489:(e,t,r)=>{r.d(t,{N:()=>u});var s=r(1322),n=r(6279),i=r(785);class a{constructor(){this.tasks=new s.vo4((0,i.kO)()),this.scheduler=new n.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await r.e(7519).then(r.bind(r,7519)),{getCustomerGoalCoordinator:s}=await Promise.all([r.e(7519),r.e(732)]).then(r.bind(r,732)),n=e.sessionId;n&&await t.getSessionStore().get(n)||(n=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:n})),await s().enqueue(n,e.prompt)}call(e,t){let r=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(r);case"cronResume":return this.tasks.resume(r);case"cronDelete":return this.tasks.delete(r);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let o=globalThis;function u(){return o.__sharedCronService??=new a}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6703,6244,1322,1773,4621,7519],()=>r(4766));module.exports=s})();
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=6668,e.ids=[6668],e.modules={5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},9801:e=>{e.exports=require("os")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},1041:e=>{e.exports=require("node:url")},6145:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>v,patchFetch:()=>g,requestAsyncStorage:()=>f,routeModule:()=>c,serverHooks:()=>m,staticGenerationAsyncStorage:()=>h});var o={};r.r(o),r.d(o,{GET:()=>u,POST:()=>l,dynamic:()=>p});var i=r(7786),s=r(5042),n=r(2184),a=r(1982),d=r(9001);let p="force-dynamic";async function u(){return Response.json((0,a.dp)().publicView(),{headers:{"cache-control":"no-store"}})}async function l(e){let t=(0,d.o)(e);if(t)return t;try{let t=await e.json();if(!t||"object"!=typeof t||Array.isArray(t))throw new a.kg("设置必须是对象");return Response.json((0,a.dp)().save(t),{headers:{"cache-control":"no-store"}})}catch(e){return Response.json({error:e instanceof Error?e.message:"保存失败"},{status:e instanceof a.kg?e.status:400})}}let c=new i.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/settings/route",pathname:"/api/settings",filename:"route",bundlePath:"app/api/settings/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/settings/route.ts",nextConfigOutput:"standalone",userland:o}),{requestAsyncStorage:f,staticGenerationAsyncStorage:h,serverHooks:m}=c,v="/api/settings/route";function g(){return(0,n.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:h})}},7786:(e,t,r)=>{e.exports=r(517)},785:(e,t,r)=>{r.d(t,{ME:()=>a,kO:()=>n,sr:()=>d});var o=r(9411);let i=function(){let e=process.argv[1];if(e){let t=(0,o.dirname)((0,o.resolve)(e)),r=`${o.sep}node_modules${o.sep}.bin`;return t.endsWith(r)?(0,o.resolve)(t,"..",".."):t}return(0,o.resolve)(process.cwd())}();function s(e=process.env,t=i){return(0,o.resolve)(e.AGENT_DATA_DIR?.trim()||t)}function n(){return s()}function a(e=process.env,t=s(e)){let r=e.AGENT_LOG_DIR?.trim();if(r)return(0,o.resolve)(r);let i=e.AGENTROAM_DATA_DIR?.trim();return i?(0,o.resolve)(i,"logs"):(0,o.join)(t,".agent-data","logs")}function d(){return function(e=process.env,t=i){return(0,o.resolve)(e.AGENT_WORKING_DIRECTORY?.trim()||t)}(process.env,n())}},1982:(e,t,r)=>{let o;r.d(t,{dp:()=>l,kg:()=>d});var i=r(1322),s=r(785),n=r(6005);let a="__agentroam_stored_secret__";class d extends Error{constructor(e,t=400){super(e),this.status=t}}class p{constructor(e,t=process.env){this.baseDir=e,this.store=new i.nAl(e),null===this.store.get("sharedSettingsInitialized")&&(0,i.N8n)(e).db.transaction(()=>{if(!this.store.get("profiles")&&!this.store.get("apiKey")&&t.AGENT_API_KEY){let e={id:"server-default",name:"服务端默认",provider:t.AGENT_MODEL_PROVIDER||"openai",modelId:t.AGENT_MODEL_ID||"gpt-4o",apiKey:t.AGENT_API_KEY,baseUrl:t.AGENT_BASE_URL||""};this.store.saveAll({...this.store.getAll(),profiles:[e],activeProfileId:e.id,modelProvider:e.provider,modelId:e.modelId,apiKey:e.apiKey,baseUrl:e.baseUrl,isConfigured:!0})}this.store.set("sharedSettingsInitialized","1")})()}read(){let e=[];try{e=JSON.parse(this.store.get("activeAgentIds")||"[]")}catch{}return{...this.store.getAll(),activeAgentIds:e,revision:Number(this.store.get("sharedSettingsRevision")||0)}}publicView(){let e=this.read();return{...e,settingsSpaceId:(0,n.createHash)("sha256").update(this.baseDir).digest("hex").slice(0,24),apiKey:e.apiKey?a:"",profiles:e.profiles.map(e=>({...e,apiKey:e.apiKey?a:""}))}}save(e){return(0,i.N8n)(this.baseDir).db.transaction(()=>{let t=this.read();if(void 0!==e.revision&&e.revision!==t.revision)throw new d("设置已被另一端修改,请重新加载后保存",409);let r={...t};for(let t of["modelProvider","modelId","baseUrl","workingDirectory","activeProfileId"])if(void 0!==e[t]){if("string"!=typeof e[t])throw new d(`${t} 必须是字符串`);r[t]=e[t]}if(void 0!==e.maxIterations){if("number"!=typeof e.maxIterations||!Number.isSafeInteger(e.maxIterations)||e.maxIterations<0)throw new d("maxIterations 必须是非负整数");r.maxIterations=e.maxIterations}if(void 0!==e.contextWindow){if("number"!=typeof e.contextWindow||!Number.isFinite(e.contextWindow)||e.contextWindow<8||e.contextWindow>2e3)throw new d("contextWindow 超出范围");r.contextWindow=e.contextWindow}if(void 0!==e.reasoningEffort){if(!["off","low","medium","high"].includes(String(e.reasoningEffort)))throw new d("reasoningEffort 无效");r.reasoningEffort=e.reasoningEffort}if(void 0!==e.taskNotifications){if(!e.taskNotifications||"object"!=typeof e.taskNotifications||Array.isArray(e.taskNotifications))throw new d("taskNotifications 必须是对象");let t=e.taskNotifications;for(let e of["completionEnabled","soundEnabled","notifyWhileForeground"])if(void 0!==t[e]&&"boolean"!=typeof t[e])throw new d(`taskNotifications.${e} 必须是布尔值`);r.taskNotifications=(0,i.mDL)({...r.taskNotifications,...t})}if(void 0!==e.apiKey&&(r.apiKey=u(e.apiKey,t.apiKey)),void 0!==e.profiles){if(!Array.isArray(e.profiles)||e.profiles.length>100)throw new d("profiles 必须是数组");let o=new Set;r.profiles=e.profiles.map(e=>{if(!e||"object"!=typeof e)throw new d("profile 无效");for(let t of["id","name","provider","modelId","baseUrl"])if("string"!=typeof e[t])throw new d(`profile.${t} 无效`);if(!e.id||o.has(e.id))throw new d("profile.id 重复或为空");if(o.add(e.id),!["openai","anthropic","deepseek","aihub"].includes(e.provider))throw new d("不支持的模型提供方");if(void 0!==e.maxOutputTokens&&("number"!=typeof e.maxOutputTokens||!Number.isInteger(e.maxOutputTokens)||e.maxOutputTokens<256||e.maxOutputTokens>131072))throw new d("profile.maxOutputTokens 超出范围");if(void 0!==e.requestTimeoutSeconds&&("number"!=typeof e.requestTimeoutSeconds||!Number.isInteger(e.requestTimeoutSeconds)||e.requestTimeoutSeconds<30||e.requestTimeoutSeconds>1800))throw new d("profile.requestTimeoutSeconds 超出范围");return{id:e.id,name:e.name,provider:e.provider,modelId:e.modelId,baseUrl:e.baseUrl,apiKey:u(e.apiKey,t.profiles.find(t=>t.id===e.id)?.apiKey||""),...void 0===e.maxOutputTokens?{}:{maxOutputTokens:e.maxOutputTokens},...void 0===e.requestTimeoutSeconds?{}:{requestTimeoutSeconds:e.requestTimeoutSeconds}}})}let o=r.profiles.find(e=>e.id===r.activeProfileId);if(r.activeProfileId&&!o)throw new d("找不到当前配置档案");if(o&&Object.assign(r,{modelProvider:o.provider,modelId:o.modelId,apiKey:o.apiKey,baseUrl:o.baseUrl}),void 0!==e.activeAgentIds){if(!Array.isArray(e.activeAgentIds)||!e.activeAgentIds.every(e=>"string"==typeof e))throw new d("activeAgentIds 无效");r.activeAgentIds=[...new Set(e.activeAgentIds)]}return r.isConfigured="aihub"===r.modelProvider?!!r.modelId:!!(r.apiKey&&r.modelId),this.store.saveAll(r),this.store.set("activeAgentIds",JSON.stringify(r.activeAgentIds)),this.store.set("sharedSettingsRevision",String(t.revision+1)),this.publicView()})()}}function u(e,t){if(void 0===e||""===e||e===a)return t;if("string"!=typeof e||e.length>16384)throw new d("apiKey 无效");return e}function l(){return o??=new p((0,s.kO)())}},9001:(e,t,r)=>{r.d(t,{o:()=>i});let o=new Set(["capacitor://localhost","ionic://localhost"]);function i(e){if(!e.headers.get("content-type")?.toLowerCase().startsWith("application/json"))return Response.json({error:"JSON required"},{status:415});let t=e.headers.get("origin");if(!t||o.has(t))return null;let r=new URL(e.url),i="1"===process.env.AGENT_TRUST_TUNNEL_PROXY,s=i?e.headers.get("x-forwarded-host")?.split(",")[0].trim()||e.headers.get("host")||r.host:e.headers.get("host")||r.host,n=i&&e.headers.get("x-forwarded-proto")?.split(",")[0].trim()||r.protocol.slice(0,-1);return t!==`${n}://${s}`?Response.json({error:"Cross-origin write denied"},{status:403}):null}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),o=t.X(0,[8375,1322],()=>r(6145));module.exports=o})();
1
+ "use strict";(()=>{var e={};e.id=6668,e.ids=[6668],e.modules={5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},9801:e=>{e.exports=require("os")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},1041:e=>{e.exports=require("node:url")},4773:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>v,patchFetch:()=>g,requestAsyncStorage:()=>f,routeModule:()=>c,serverHooks:()=>m,staticGenerationAsyncStorage:()=>h});var o={};r.r(o),r.d(o,{GET:()=>u,POST:()=>l,dynamic:()=>p});var i=r(7786),s=r(5042),n=r(2184),a=r(1982),d=r(9001);let p="force-dynamic";async function u(){return Response.json((0,a.dp)().publicView(),{headers:{"cache-control":"no-store"}})}async function l(e){let t=(0,d.o)(e);if(t)return t;try{let t=await e.json();if(!t||"object"!=typeof t||Array.isArray(t))throw new a.kg("设置必须是对象");return Response.json((0,a.dp)().save(t),{headers:{"cache-control":"no-store"}})}catch(e){return Response.json({error:e instanceof Error?e.message:"保存失败"},{status:e instanceof a.kg?e.status:400})}}let c=new i.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/settings/route",pathname:"/api/settings",filename:"route",bundlePath:"app/api/settings/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/settings/route.ts",nextConfigOutput:"standalone",userland:o}),{requestAsyncStorage:f,staticGenerationAsyncStorage:h,serverHooks:m}=c,v="/api/settings/route";function g(){return(0,n.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:h})}},7786:(e,t,r)=>{e.exports=r(517)},785:(e,t,r)=>{r.d(t,{ME:()=>a,kO:()=>n,sr:()=>d});var o=r(9411);let i=function(){let e=process.argv[1];if(e){let t=(0,o.dirname)((0,o.resolve)(e)),r=`${o.sep}node_modules${o.sep}.bin`;return t.endsWith(r)?(0,o.resolve)(t,"..",".."):t}return(0,o.resolve)(process.cwd())}();function s(e=process.env,t=i){return(0,o.resolve)(e.AGENT_DATA_DIR?.trim()||t)}function n(){return s()}function a(e=process.env,t=s(e)){let r=e.AGENT_LOG_DIR?.trim();if(r)return(0,o.resolve)(r);let i=e.AGENTROAM_DATA_DIR?.trim();return i?(0,o.resolve)(i,"logs"):(0,o.join)(t,".agent-data","logs")}function d(){return function(e=process.env,t=i){return(0,o.resolve)(e.AGENT_WORKING_DIRECTORY?.trim()||t)}(process.env,n())}},1982:(e,t,r)=>{let o;r.d(t,{dp:()=>l,kg:()=>d});var i=r(1322),s=r(785),n=r(6005);let a="__agentroam_stored_secret__";class d extends Error{constructor(e,t=400){super(e),this.status=t}}class p{constructor(e,t=process.env){this.baseDir=e,this.store=new i.nAl(e),null===this.store.get("sharedSettingsInitialized")&&(0,i.N8n)(e).db.transaction(()=>{if(!this.store.get("profiles")&&!this.store.get("apiKey")&&t.AGENT_API_KEY){let e={id:"server-default",name:"服务端默认",provider:t.AGENT_MODEL_PROVIDER||"openai",modelId:t.AGENT_MODEL_ID||"gpt-4o",apiKey:t.AGENT_API_KEY,baseUrl:t.AGENT_BASE_URL||""};this.store.saveAll({...this.store.getAll(),profiles:[e],activeProfileId:e.id,modelProvider:e.provider,modelId:e.modelId,apiKey:e.apiKey,baseUrl:e.baseUrl,isConfigured:!0})}this.store.set("sharedSettingsInitialized","1")})()}read(){let e=[];try{e=JSON.parse(this.store.get("activeAgentIds")||"[]")}catch{}return{...this.store.getAll(),activeAgentIds:e,revision:Number(this.store.get("sharedSettingsRevision")||0)}}publicView(){let e=this.read();return{...e,settingsSpaceId:(0,n.createHash)("sha256").update(this.baseDir).digest("hex").slice(0,24),apiKey:e.apiKey?a:"",profiles:e.profiles.map(e=>({...e,apiKey:e.apiKey?a:""}))}}save(e){return(0,i.N8n)(this.baseDir).db.transaction(()=>{let t=this.read();if(void 0!==e.revision&&e.revision!==t.revision)throw new d("设置已被另一端修改,请重新加载后保存",409);let r={...t};for(let t of["modelProvider","modelId","baseUrl","workingDirectory","activeProfileId"])if(void 0!==e[t]){if("string"!=typeof e[t])throw new d(`${t} 必须是字符串`);r[t]=e[t]}if(void 0!==e.maxIterations){if("number"!=typeof e.maxIterations||!Number.isSafeInteger(e.maxIterations)||e.maxIterations<0)throw new d("maxIterations 必须是非负整数");r.maxIterations=e.maxIterations}if(void 0!==e.contextWindow){if("number"!=typeof e.contextWindow||!Number.isFinite(e.contextWindow)||e.contextWindow<8||e.contextWindow>2e3)throw new d("contextWindow 超出范围");r.contextWindow=e.contextWindow}if(void 0!==e.reasoningEffort){if(!["off","low","medium","high"].includes(String(e.reasoningEffort)))throw new d("reasoningEffort 无效");r.reasoningEffort=e.reasoningEffort}if(void 0!==e.taskNotifications){if(!e.taskNotifications||"object"!=typeof e.taskNotifications||Array.isArray(e.taskNotifications))throw new d("taskNotifications 必须是对象");let t=e.taskNotifications;for(let e of["completionEnabled","soundEnabled","notifyWhileForeground"])if(void 0!==t[e]&&"boolean"!=typeof t[e])throw new d(`taskNotifications.${e} 必须是布尔值`);r.taskNotifications=(0,i.mDL)({...r.taskNotifications,...t})}if(void 0!==e.apiKey&&(r.apiKey=u(e.apiKey,t.apiKey)),void 0!==e.profiles){if(!Array.isArray(e.profiles)||e.profiles.length>100)throw new d("profiles 必须是数组");let o=new Set;r.profiles=e.profiles.map(e=>{if(!e||"object"!=typeof e)throw new d("profile 无效");for(let t of["id","name","provider","modelId","baseUrl"])if("string"!=typeof e[t])throw new d(`profile.${t} 无效`);if(!e.id||o.has(e.id))throw new d("profile.id 重复或为空");if(o.add(e.id),!["openai","anthropic","deepseek","aihub"].includes(e.provider))throw new d("不支持的模型提供方");if(void 0!==e.maxOutputTokens&&("number"!=typeof e.maxOutputTokens||!Number.isInteger(e.maxOutputTokens)||e.maxOutputTokens<256||e.maxOutputTokens>131072))throw new d("profile.maxOutputTokens 超出范围");if(void 0!==e.requestTimeoutSeconds&&("number"!=typeof e.requestTimeoutSeconds||!Number.isInteger(e.requestTimeoutSeconds)||e.requestTimeoutSeconds<30||e.requestTimeoutSeconds>1800))throw new d("profile.requestTimeoutSeconds 超出范围");return{id:e.id,name:e.name,provider:e.provider,modelId:e.modelId,baseUrl:e.baseUrl,apiKey:u(e.apiKey,t.profiles.find(t=>t.id===e.id)?.apiKey||""),...void 0===e.maxOutputTokens?{}:{maxOutputTokens:e.maxOutputTokens},...void 0===e.requestTimeoutSeconds?{}:{requestTimeoutSeconds:e.requestTimeoutSeconds}}})}let o=r.profiles.find(e=>e.id===r.activeProfileId);if(r.activeProfileId&&!o)throw new d("找不到当前配置档案");if(o&&Object.assign(r,{modelProvider:o.provider,modelId:o.modelId,apiKey:o.apiKey,baseUrl:o.baseUrl}),void 0!==e.activeAgentIds){if(!Array.isArray(e.activeAgentIds)||!e.activeAgentIds.every(e=>"string"==typeof e))throw new d("activeAgentIds 无效");r.activeAgentIds=[...new Set(e.activeAgentIds)]}return r.isConfigured="aihub"===r.modelProvider?!!r.modelId:!!(r.apiKey&&r.modelId),this.store.saveAll(r),this.store.set("activeAgentIds",JSON.stringify(r.activeAgentIds)),this.store.set("sharedSettingsRevision",String(t.revision+1)),this.publicView()})()}}function u(e,t){if(void 0===e||""===e||e===a)return t;if("string"!=typeof e||e.length>16384)throw new d("apiKey 无效");return e}function l(){return o??=new p((0,s.kO)())}},9001:(e,t,r)=>{r.d(t,{o:()=>i});let o=new Set(["capacitor://localhost","ionic://localhost"]);function i(e){if(!e.headers.get("content-type")?.toLowerCase().startsWith("application/json"))return Response.json({error:"JSON required"},{status:415});let t=e.headers.get("origin");if(!t||o.has(t))return null;let r=new URL(e.url),i="1"===process.env.AGENT_TRUST_TUNNEL_PROXY,s=i?e.headers.get("x-forwarded-host")?.split(",")[0].trim()||e.headers.get("host")||r.host:e.headers.get("host")||r.host,n=i&&e.headers.get("x-forwarded-proto")?.split(",")[0].trim()||r.protocol.slice(0,-1);return t!==`${n}://${s}`?Response.json({error:"Cross-origin write denied"},{status:403}):null}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),o=t.X(0,[8375,1322],()=>r(4773));module.exports=o})();
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=1731,e.ids=[1731],e.modules={5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},9801:e=>{e.exports=require("os")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},1041:e=>{e.exports=require("node:url")},2772:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>v,patchFetch:()=>h,requestAsyncStorage:()=>m,routeModule:()=>c,serverHooks:()=>f,staticGenerationAsyncStorage:()=>x});var s={};t.r(s),t.d(s,{GET:()=>l,POST:()=>d});var o=t(7786),i=t(5042),n=t(2184),a=t(1890),p=t(1322),u=t(4621);async function l(){let e=await (0,u.i)().call("listSkills",[]);return a.NextResponse.json(e.map(e=>({name:e.name,description:e.description,triggers:e.triggers,filePath:e.filePath})))}async function d(e){try{let r=await e.json(),t=new p.N78,s=(0,u.i)().skills,o=[];if(r.filePath){let e=await t.loadFromFile(r.filePath);await s.save(e),o.push({name:e.name,description:e.description})}else if(!r.dirPath)return a.NextResponse.json({error:"filePath or dirPath is required"},{status:400});else for(let e of(await t.loadFromDirectory(r.dirPath)))await s.save(await t.loadFromFile(e.filePath)),o.push({name:e.name,description:e.description});return a.NextResponse.json({status:"imported",count:o.length,skills:o})}catch(e){return a.NextResponse.json({error:e instanceof Error?e.message:"Skill import failed"},{status:500})}}let c=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/skills/route",pathname:"/api/skills",filename:"route",bundlePath:"app/api/skills/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/skills/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:m,staticGenerationAsyncStorage:x,serverHooks:f}=c,v="/api/skills/route";function h(){return(0,n.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:x})}},785:(e,r,t)=>{t.d(r,{ME:()=>a,kO:()=>n,sr:()=>p});var s=t(9411);let o=function(){let e=process.argv[1];if(e){let r=(0,s.dirname)((0,s.resolve)(e)),t=`${s.sep}node_modules${s.sep}.bin`;return r.endsWith(t)?(0,s.resolve)(r,"..",".."):r}return(0,s.resolve)(process.cwd())}();function i(e=process.env,r=o){return(0,s.resolve)(e.AGENT_DATA_DIR?.trim()||r)}function n(){return i()}function a(e=process.env,r=i(e)){let t=e.AGENT_LOG_DIR?.trim();if(t)return(0,s.resolve)(t);let o=e.AGENTROAM_DATA_DIR?.trim();return o?(0,s.resolve)(o,"logs"):(0,s.join)(r,".agent-data","logs")}function p(){return function(e=process.env,r=o){return(0,s.resolve)(e.AGENT_WORKING_DIRECTORY?.trim()||r)}(process.env,n())}}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8375,6703,1322,4621],()=>t(2772));module.exports=s})();
1
+ "use strict";(()=>{var e={};e.id=1731,e.ids=[1731],e.modules={5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},9801:e=>{e.exports=require("os")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},1041:e=>{e.exports=require("node:url")},186:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>v,patchFetch:()=>h,requestAsyncStorage:()=>m,routeModule:()=>c,serverHooks:()=>f,staticGenerationAsyncStorage:()=>x});var s={};t.r(s),t.d(s,{GET:()=>l,POST:()=>d});var o=t(7786),i=t(5042),n=t(2184),a=t(1890),p=t(1322),u=t(4621);async function l(){let e=await (0,u.i)().call("listSkills",[]);return a.NextResponse.json(e.map(e=>({name:e.name,description:e.description,triggers:e.triggers,filePath:e.filePath})))}async function d(e){try{let r=await e.json(),t=new p.N78,s=(0,u.i)().skills,o=[];if(r.filePath){let e=await t.loadFromFile(r.filePath);await s.save(e),o.push({name:e.name,description:e.description})}else if(!r.dirPath)return a.NextResponse.json({error:"filePath or dirPath is required"},{status:400});else for(let e of(await t.loadFromDirectory(r.dirPath)))await s.save(await t.loadFromFile(e.filePath)),o.push({name:e.name,description:e.description});return a.NextResponse.json({status:"imported",count:o.length,skills:o})}catch(e){return a.NextResponse.json({error:e instanceof Error?e.message:"Skill import failed"},{status:500})}}let c=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/skills/route",pathname:"/api/skills",filename:"route",bundlePath:"app/api/skills/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/skills/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:m,staticGenerationAsyncStorage:x,serverHooks:f}=c,v="/api/skills/route";function h(){return(0,n.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:x})}},785:(e,r,t)=>{t.d(r,{ME:()=>a,kO:()=>n,sr:()=>p});var s=t(9411);let o=function(){let e=process.argv[1];if(e){let r=(0,s.dirname)((0,s.resolve)(e)),t=`${s.sep}node_modules${s.sep}.bin`;return r.endsWith(t)?(0,s.resolve)(r,"..",".."):r}return(0,s.resolve)(process.cwd())}();function i(e=process.env,r=o){return(0,s.resolve)(e.AGENT_DATA_DIR?.trim()||r)}function n(){return i()}function a(e=process.env,r=i(e)){let t=e.AGENT_LOG_DIR?.trim();if(t)return(0,s.resolve)(t);let o=e.AGENTROAM_DATA_DIR?.trim();return o?(0,s.resolve)(o,"logs"):(0,s.join)(r,".agent-data","logs")}function p(){return function(e=process.env,r=o){return(0,s.resolve)(e.AGENT_WORKING_DIRECTORY?.trim()||r)}(process.env,n())}}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8375,6703,1322,4621],()=>t(186));module.exports=s})();
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=2489,e.ids=[2489],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},3233:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>f,patchFetch:()=>m,requestAsyncStorage:()=>p,routeModule:()=>d,serverHooks:()=>g,staticGenerationAsyncStorage:()=>h});var s={};t.r(s),t.d(s,{DELETE:()=>c,PUT:()=>u});var o=t(7786),n=t(5042),i=t(2184),a=t(9001),l=t(8615);async function u(e,{params:r}){let t=(0,a.o)(e);if(t)return t;try{if(!await (0,l.cm)().get(r.policyId))return Response.json({error:"Tool policy not found",code:"TOOL_POLICY_NOT_FOUND"},{status:404});let t=await e.json();if(!t||"object"!=typeof t||Array.isArray(t))return Response.json({error:"Tool policy must be an object",code:"INVALID_TOOL_POLICY"},{status:422});if("id"in t&&t.id!==r.policyId)return Response.json({error:"Tool policy ID cannot be changed",code:"INVALID_TOOL_POLICY"},{status:422});return Response.json(await (0,l.cm)().save({...t,id:r.policyId},(0,l.jw)()))}catch(e){return(0,l.H5)(e)}}async function c(e,{params:r}){return(0,a.o)(e)||(await (0,l.cm)().delete(r.policyId)?Response.json({deleted:!0,policyId:r.policyId}):Response.json({error:"Tool policy not found",code:"TOOL_POLICY_NOT_FOUND"},{status:404}))}let d=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/tool-policies/[policyId]/route",pathname:"/api/tool-policies/[policyId]",filename:"route",bundlePath:"app/api/tool-policies/[policyId]/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/tool-policies/[policyId]/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:p,staticGenerationAsyncStorage:h,serverHooks:g}=d,f="/api/tool-policies/[policyId]/route";function m(){return(0,i.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:h})}},7786:(e,r,t)=>{e.exports=t(517)},6361:(e,r,t)=>{t.d(r,{Q:()=>i,e:()=>n});var s=t(1322),o=t(7519);function n(){let e=new s.S3T;(0,s._5y)(e);let r=new s.OqQ;for(let t of(e.register(new s.Q8u(r,null)),e.register(new s.URd(r,null)),o.agentHost.getBuilder().getToolRegistry().getAll()))e.register(t);return e.register(new s.gBG(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e.register(new s.sBJ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; spawning runs inside a dynamic Customer Agent session"}))),e.register(new s.HbQ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e}function i(){return n().getAll().map(e=>e.name).sort()}},1489:(e,r,t)=>{t.d(r,{N:()=>l});var s=t(1322),o=t(6279),n=t(785);class i{constructor(){this.tasks=new s.vo4((0,n.kO)()),this.scheduler=new o.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:r}=await t.e(7519).then(t.bind(t,7519)),{getCustomerGoalCoordinator:s}=await Promise.all([t.e(7519),t.e(732)]).then(t.bind(t,732)),o=e.sessionId;o&&await r.getSessionStore().get(o)||(o=(await r.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:o})),await s().enqueue(o,e.prompt)}call(e,r){let t=String(r[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof r[0]||"string"!=typeof r[1]||!r[1].trim())throw Error("cron and prompt required");let e=r[2]&&"object"==typeof r[2]?r[2]:{};return this.tasks.create({cron:r[0],prompt:r[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(t);case"cronResume":return this.tasks.resume(t);case"cronDelete":return this.tasks.delete(t);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function l(){return a.__sharedCronService??=new i}},9001:(e,r,t)=>{t.d(r,{o:()=>o});let s=new Set(["capacitor://localhost","ionic://localhost"]);function o(e){if(!e.headers.get("content-type")?.toLowerCase().startsWith("application/json"))return Response.json({error:"JSON required"},{status:415});let r=e.headers.get("origin");if(!r||s.has(r))return null;let t=new URL(e.url),o="1"===process.env.AGENT_TRUST_TUNNEL_PROXY,n=o?e.headers.get("x-forwarded-host")?.split(",")[0].trim()||e.headers.get("host")||t.host:e.headers.get("host")||t.host,i=o&&e.headers.get("x-forwarded-proto")?.split(",")[0].trim()||t.protocol.slice(0,-1);return r!==`${i}://${n}`?Response.json({error:"Cross-origin write denied"},{status:403}):null}},8615:(e,r,t)=>{let s;t.d(r,{H5:()=>c,cm:()=>l,jw:()=>u});var o=t(1322),n=t(785),i=t(6361);class a{constructor(e=(0,n.kO)()){this.store=new o.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(o._0R)}save(e,r){let t=(0,o.IJh)(e,{knownTools:r,requireExecutables:!0});return this.store.save(t)}delete(e){return this.store.delete(e)}}function l(){return s??=new a}function u(){return(0,i.Q)()}function c(e){let r=e instanceof o.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof o.DlR?e.code:"INVALID_TOOL_POLICY"},{status:r})}}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8375,6244,1322,1773,4621,7519],()=>t(3233));module.exports=s})();
1
+ "use strict";(()=>{var e={};e.id=2489,e.ids=[2489],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},7160:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>f,patchFetch:()=>m,requestAsyncStorage:()=>p,routeModule:()=>d,serverHooks:()=>g,staticGenerationAsyncStorage:()=>h});var s={};t.r(s),t.d(s,{DELETE:()=>c,PUT:()=>u});var o=t(7786),n=t(5042),i=t(2184),a=t(9001),l=t(8615);async function u(e,{params:r}){let t=(0,a.o)(e);if(t)return t;try{if(!await (0,l.cm)().get(r.policyId))return Response.json({error:"Tool policy not found",code:"TOOL_POLICY_NOT_FOUND"},{status:404});let t=await e.json();if(!t||"object"!=typeof t||Array.isArray(t))return Response.json({error:"Tool policy must be an object",code:"INVALID_TOOL_POLICY"},{status:422});if("id"in t&&t.id!==r.policyId)return Response.json({error:"Tool policy ID cannot be changed",code:"INVALID_TOOL_POLICY"},{status:422});return Response.json(await (0,l.cm)().save({...t,id:r.policyId},(0,l.jw)()))}catch(e){return(0,l.H5)(e)}}async function c(e,{params:r}){return(0,a.o)(e)||(await (0,l.cm)().delete(r.policyId)?Response.json({deleted:!0,policyId:r.policyId}):Response.json({error:"Tool policy not found",code:"TOOL_POLICY_NOT_FOUND"},{status:404}))}let d=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/tool-policies/[policyId]/route",pathname:"/api/tool-policies/[policyId]",filename:"route",bundlePath:"app/api/tool-policies/[policyId]/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/tool-policies/[policyId]/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:p,staticGenerationAsyncStorage:h,serverHooks:g}=d,f="/api/tool-policies/[policyId]/route";function m(){return(0,i.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:h})}},7786:(e,r,t)=>{e.exports=t(517)},6361:(e,r,t)=>{t.d(r,{Q:()=>i,e:()=>n});var s=t(1322),o=t(7519);function n(){let e=new s.S3T;(0,s._5y)(e);let r=new s.OqQ;for(let t of(e.register(new s.Q8u(r,null)),e.register(new s.URd(r,null)),o.agentHost.getBuilder().getToolRegistry().getAll()))e.register(t);return e.register(new s.gBG(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e.register(new s.sBJ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; spawning runs inside a dynamic Customer Agent session"}))),e.register(new s.HbQ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e}function i(){return n().getAll().map(e=>e.name).sort()}},1489:(e,r,t)=>{t.d(r,{N:()=>l});var s=t(1322),o=t(6279),n=t(785);class i{constructor(){this.tasks=new s.vo4((0,n.kO)()),this.scheduler=new o.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:r}=await t.e(7519).then(t.bind(t,7519)),{getCustomerGoalCoordinator:s}=await Promise.all([t.e(7519),t.e(732)]).then(t.bind(t,732)),o=e.sessionId;o&&await r.getSessionStore().get(o)||(o=(await r.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:o})),await s().enqueue(o,e.prompt)}call(e,r){let t=String(r[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof r[0]||"string"!=typeof r[1]||!r[1].trim())throw Error("cron and prompt required");let e=r[2]&&"object"==typeof r[2]?r[2]:{};return this.tasks.create({cron:r[0],prompt:r[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(t);case"cronResume":return this.tasks.resume(t);case"cronDelete":return this.tasks.delete(t);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function l(){return a.__sharedCronService??=new i}},9001:(e,r,t)=>{t.d(r,{o:()=>o});let s=new Set(["capacitor://localhost","ionic://localhost"]);function o(e){if(!e.headers.get("content-type")?.toLowerCase().startsWith("application/json"))return Response.json({error:"JSON required"},{status:415});let r=e.headers.get("origin");if(!r||s.has(r))return null;let t=new URL(e.url),o="1"===process.env.AGENT_TRUST_TUNNEL_PROXY,n=o?e.headers.get("x-forwarded-host")?.split(",")[0].trim()||e.headers.get("host")||t.host:e.headers.get("host")||t.host,i=o&&e.headers.get("x-forwarded-proto")?.split(",")[0].trim()||t.protocol.slice(0,-1);return r!==`${i}://${n}`?Response.json({error:"Cross-origin write denied"},{status:403}):null}},8615:(e,r,t)=>{let s;t.d(r,{H5:()=>c,cm:()=>l,jw:()=>u});var o=t(1322),n=t(785),i=t(6361);class a{constructor(e=(0,n.kO)()){this.store=new o.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(o._0R)}save(e,r){let t=(0,o.IJh)(e,{knownTools:r,requireExecutables:!0});return this.store.save(t)}delete(e){return this.store.delete(e)}}function l(){return s??=new a}function u(){return(0,i.Q)()}function c(e){let r=e instanceof o.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof o.DlR?e.code:"INVALID_TOOL_POLICY"},{status:r})}}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8375,6244,1322,1773,4621,7519],()=>t(7160));module.exports=s})();
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=5913,e.ids=[5913],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},8978:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>m,patchFetch:()=>w,requestAsyncStorage:()=>h,routeModule:()=>p,serverHooks:()=>f,staticGenerationAsyncStorage:()=>g});var s={};t.r(s),t.d(s,{GET:()=>c,POST:()=>d,dynamic:()=>l});var o=t(7786),n=t(5042),i=t(2184),a=t(9001),u=t(8615);let l="force-dynamic";async function c(){return Response.json({policies:await (0,u.cm)().list(),tools:(0,u.jw)()},{headers:{"cache-control":"no-store"}})}async function d(e){let r=(0,a.o)(e);if(r)return r;try{let r=await e.json();if(r&&"object"==typeof r&&!Array.isArray(r)&&"string"==typeof r.id&&await (0,u.cm)().get(r.id.trim()))return Response.json({error:"Tool policy already exists",code:"TOOL_POLICY_EXISTS"},{status:409});return Response.json(await (0,u.cm)().save(r,(0,u.jw)()),{status:201})}catch(e){return(0,u.H5)(e)}}let p=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/tool-policies/route",pathname:"/api/tool-policies",filename:"route",bundlePath:"app/api/tool-policies/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/tool-policies/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:h,staticGenerationAsyncStorage:g,serverHooks:f}=p,m="/api/tool-policies/route";function w(){return(0,i.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:g})}},7786:(e,r,t)=>{e.exports=t(517)},6361:(e,r,t)=>{t.d(r,{Q:()=>i,e:()=>n});var s=t(1322),o=t(7519);function n(){let e=new s.S3T;(0,s._5y)(e);let r=new s.OqQ;for(let t of(e.register(new s.Q8u(r,null)),e.register(new s.URd(r,null)),o.agentHost.getBuilder().getToolRegistry().getAll()))e.register(t);return e.register(new s.gBG(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e.register(new s.sBJ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; spawning runs inside a dynamic Customer Agent session"}))),e.register(new s.HbQ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e}function i(){return n().getAll().map(e=>e.name).sort()}},1489:(e,r,t)=>{t.d(r,{N:()=>u});var s=t(1322),o=t(6279),n=t(785);class i{constructor(){this.tasks=new s.vo4((0,n.kO)()),this.scheduler=new o.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:r}=await t.e(7519).then(t.bind(t,7519)),{getCustomerGoalCoordinator:s}=await Promise.all([t.e(7519),t.e(732)]).then(t.bind(t,732)),o=e.sessionId;o&&await r.getSessionStore().get(o)||(o=(await r.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:o})),await s().enqueue(o,e.prompt)}call(e,r){let t=String(r[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof r[0]||"string"!=typeof r[1]||!r[1].trim())throw Error("cron and prompt required");let e=r[2]&&"object"==typeof r[2]?r[2]:{};return this.tasks.create({cron:r[0],prompt:r[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(t);case"cronResume":return this.tasks.resume(t);case"cronDelete":return this.tasks.delete(t);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function u(){return a.__sharedCronService??=new i}},9001:(e,r,t)=>{t.d(r,{o:()=>o});let s=new Set(["capacitor://localhost","ionic://localhost"]);function o(e){if(!e.headers.get("content-type")?.toLowerCase().startsWith("application/json"))return Response.json({error:"JSON required"},{status:415});let r=e.headers.get("origin");if(!r||s.has(r))return null;let t=new URL(e.url),o="1"===process.env.AGENT_TRUST_TUNNEL_PROXY,n=o?e.headers.get("x-forwarded-host")?.split(",")[0].trim()||e.headers.get("host")||t.host:e.headers.get("host")||t.host,i=o&&e.headers.get("x-forwarded-proto")?.split(",")[0].trim()||t.protocol.slice(0,-1);return r!==`${i}://${n}`?Response.json({error:"Cross-origin write denied"},{status:403}):null}},8615:(e,r,t)=>{let s;t.d(r,{H5:()=>c,cm:()=>u,jw:()=>l});var o=t(1322),n=t(785),i=t(6361);class a{constructor(e=(0,n.kO)()){this.store=new o.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(o._0R)}save(e,r){let t=(0,o.IJh)(e,{knownTools:r,requireExecutables:!0});return this.store.save(t)}delete(e){return this.store.delete(e)}}function u(){return s??=new a}function l(){return(0,i.Q)()}function c(e){let r=e instanceof o.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof o.DlR?e.code:"INVALID_TOOL_POLICY"},{status:r})}}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8375,6244,1322,1773,4621,7519],()=>t(8978));module.exports=s})();
1
+ "use strict";(()=>{var e={};e.id=5913,e.ids=[5913],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},3318:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>m,patchFetch:()=>w,requestAsyncStorage:()=>h,routeModule:()=>p,serverHooks:()=>f,staticGenerationAsyncStorage:()=>g});var s={};t.r(s),t.d(s,{GET:()=>c,POST:()=>d,dynamic:()=>l});var o=t(7786),n=t(5042),i=t(2184),a=t(9001),u=t(8615);let l="force-dynamic";async function c(){return Response.json({policies:await (0,u.cm)().list(),tools:(0,u.jw)()},{headers:{"cache-control":"no-store"}})}async function d(e){let r=(0,a.o)(e);if(r)return r;try{let r=await e.json();if(r&&"object"==typeof r&&!Array.isArray(r)&&"string"==typeof r.id&&await (0,u.cm)().get(r.id.trim()))return Response.json({error:"Tool policy already exists",code:"TOOL_POLICY_EXISTS"},{status:409});return Response.json(await (0,u.cm)().save(r,(0,u.jw)()),{status:201})}catch(e){return(0,u.H5)(e)}}let p=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/tool-policies/route",pathname:"/api/tool-policies",filename:"route",bundlePath:"app/api/tool-policies/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/tool-policies/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:h,staticGenerationAsyncStorage:g,serverHooks:f}=p,m="/api/tool-policies/route";function w(){return(0,i.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:g})}},7786:(e,r,t)=>{e.exports=t(517)},6361:(e,r,t)=>{t.d(r,{Q:()=>i,e:()=>n});var s=t(1322),o=t(7519);function n(){let e=new s.S3T;(0,s._5y)(e);let r=new s.OqQ;for(let t of(e.register(new s.Q8u(r,null)),e.register(new s.URd(r,null)),o.agentHost.getBuilder().getToolRegistry().getAll()))e.register(t);return e.register(new s.gBG(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e.register(new s.sBJ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; spawning runs inside a dynamic Customer Agent session"}))),e.register(new s.HbQ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e}function i(){return n().getAll().map(e=>e.name).sort()}},1489:(e,r,t)=>{t.d(r,{N:()=>u});var s=t(1322),o=t(6279),n=t(785);class i{constructor(){this.tasks=new s.vo4((0,n.kO)()),this.scheduler=new o.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:r}=await t.e(7519).then(t.bind(t,7519)),{getCustomerGoalCoordinator:s}=await Promise.all([t.e(7519),t.e(732)]).then(t.bind(t,732)),o=e.sessionId;o&&await r.getSessionStore().get(o)||(o=(await r.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:o})),await s().enqueue(o,e.prompt)}call(e,r){let t=String(r[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof r[0]||"string"!=typeof r[1]||!r[1].trim())throw Error("cron and prompt required");let e=r[2]&&"object"==typeof r[2]?r[2]:{};return this.tasks.create({cron:r[0],prompt:r[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(t);case"cronResume":return this.tasks.resume(t);case"cronDelete":return this.tasks.delete(t);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function u(){return a.__sharedCronService??=new i}},9001:(e,r,t)=>{t.d(r,{o:()=>o});let s=new Set(["capacitor://localhost","ionic://localhost"]);function o(e){if(!e.headers.get("content-type")?.toLowerCase().startsWith("application/json"))return Response.json({error:"JSON required"},{status:415});let r=e.headers.get("origin");if(!r||s.has(r))return null;let t=new URL(e.url),o="1"===process.env.AGENT_TRUST_TUNNEL_PROXY,n=o?e.headers.get("x-forwarded-host")?.split(",")[0].trim()||e.headers.get("host")||t.host:e.headers.get("host")||t.host,i=o&&e.headers.get("x-forwarded-proto")?.split(",")[0].trim()||t.protocol.slice(0,-1);return r!==`${i}://${n}`?Response.json({error:"Cross-origin write denied"},{status:403}):null}},8615:(e,r,t)=>{let s;t.d(r,{H5:()=>c,cm:()=>u,jw:()=>l});var o=t(1322),n=t(785),i=t(6361);class a{constructor(e=(0,n.kO)()){this.store=new o.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(o._0R)}save(e,r){let t=(0,o.IJh)(e,{knownTools:r,requireExecutables:!0});return this.store.save(t)}delete(e){return this.store.delete(e)}}function u(){return s??=new a}function l(){return(0,i.Q)()}function c(e){let r=e instanceof o.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof o.DlR?e.code:"INVALID_TOOL_POLICY"},{status:r})}}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8375,6244,1322,1773,4621,7519],()=>t(3318));module.exports=s})();
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=443,e.ids=[443],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},5061:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>x,patchFetch:()=>q,requestAsyncStorage:()=>l,routeModule:()=>d,serverHooks:()=>h,staticGenerationAsyncStorage:()=>c});var s={};t.r(s),t.d(s,{GET:()=>p});var o=t(7786),i=t(5042),n=t(2184),a=t(1890),u=t(7519);async function p(){let e=u.agentHost.getBuilder().getToolRegistry().getAll();return a.NextResponse.json(e.map(e=>({name:e.name,description:e.description,parameters:e.parameters})))}let d=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/tools/route",pathname:"/api/tools",filename:"route",bundlePath:"app/api/tools/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/tools/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:l,staticGenerationAsyncStorage:c,serverHooks:h}=d,x="/api/tools/route";function q(){return(0,n.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:c})}},1489:(e,r,t)=>{t.d(r,{N:()=>u});var s=t(1322),o=t(6279),i=t(785);class n{constructor(){this.tasks=new s.vo4((0,i.kO)()),this.scheduler=new o.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:r}=await t.e(7519).then(t.bind(t,7519)),{getCustomerGoalCoordinator:s}=await Promise.all([t.e(7519),t.e(732)]).then(t.bind(t,732)),o=e.sessionId;o&&await r.getSessionStore().get(o)||(o=(await r.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:o})),await s().enqueue(o,e.prompt)}call(e,r){let t=String(r[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof r[0]||"string"!=typeof r[1]||!r[1].trim())throw Error("cron and prompt required");let e=r[2]&&"object"==typeof r[2]?r[2]:{};return this.tasks.create({cron:r[0],prompt:r[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(t);case"cronResume":return this.tasks.resume(t);case"cronDelete":return this.tasks.delete(t);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function u(){return a.__sharedCronService??=new n}}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8375,6703,6244,1322,1773,4621,7519],()=>t(5061));module.exports=s})();
1
+ "use strict";(()=>{var e={};e.id=443,e.ids=[443],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},5881:e=>{e.exports=require("node:util")},2926:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>x,patchFetch:()=>q,requestAsyncStorage:()=>l,routeModule:()=>d,serverHooks:()=>h,staticGenerationAsyncStorage:()=>c});var s={};t.r(s),t.d(s,{GET:()=>p});var o=t(7786),i=t(5042),n=t(2184),a=t(1890),u=t(7519);async function p(){let e=u.agentHost.getBuilder().getToolRegistry().getAll();return a.NextResponse.json(e.map(e=>({name:e.name,description:e.description,parameters:e.parameters})))}let d=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/tools/route",pathname:"/api/tools",filename:"route",bundlePath:"app/api/tools/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/tools/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:l,staticGenerationAsyncStorage:c,serverHooks:h}=d,x="/api/tools/route";function q(){return(0,n.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:c})}},1489:(e,r,t)=>{t.d(r,{N:()=>u});var s=t(1322),o=t(6279),i=t(785);class n{constructor(){this.tasks=new s.vo4((0,i.kO)()),this.scheduler=new o.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:r}=await t.e(7519).then(t.bind(t,7519)),{getCustomerGoalCoordinator:s}=await Promise.all([t.e(7519),t.e(732)]).then(t.bind(t,732)),o=e.sessionId;o&&await r.getSessionStore().get(o)||(o=(await r.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:o})),await s().enqueue(o,e.prompt)}call(e,r){let t=String(r[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof r[0]||"string"!=typeof r[1]||!r[1].trim())throw Error("cron and prompt required");let e=r[2]&&"object"==typeof r[2]?r[2]:{};return this.tasks.create({cron:r[0],prompt:r[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(t);case"cronResume":return this.tasks.resume(t);case"cronDelete":return this.tasks.delete(t);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function u(){return a.__sharedCronService??=new n}}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8375,6703,6244,1322,1773,4621,7519],()=>t(2926));module.exports=s})();
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=907,e.ids=[907],e.modules={5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},9801:e=>{e.exports=require("os")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},1041:e=>{e.exports=require("node:url")},6666:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>w,patchFetch:()=>x,requestAsyncStorage:()=>h,routeModule:()=>d,serverHooks:()=>g,staticGenerationAsyncStorage:()=>m});var s={};t.r(s),t.d(s,{POST:()=>u,dynamic:()=>p});var o=t(7786),i=t(5042),a=t(2184),n=t(1890),c=t(9605);let p="force-dynamic";async function u(e){return!function(e){let r=e.headers.get("origin");return!(r&&l.has(r))&&("cross-site"===e.headers.get("sec-fetch-site")||!!(r&&r!==new URL(e.url).origin))}(e)?n.NextResponse.json((0,c.X)().requestCheck(),{status:202,headers:{"cache-control":"no-store"}}):n.NextResponse.json({error:"cross-site update request rejected"},{status:403})}let l=new Set(["capacitor://localhost","ionic://localhost"]),d=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/update/check/route",pathname:"/api/update/check",filename:"route",bundlePath:"app/api/update/check/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/update/check/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:h,staticGenerationAsyncStorage:m,serverHooks:g}=d,w="/api/update/check/route";function x(){return(0,a.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:m})}},9605:(e,r,t)=>{let s;t.d(r,{X:()=>p});var o=t(7718),i=t(3977),a=t(9411),n=t(1322);class c{constructor(e){this.options=e,this.worker=null,this.spawnImpl=e.spawn??o.spawn,this.checker=e.platform?e.checker??new n.UuU({currentVersion:e.currentVersion,client:"cli",platform:e.platform}):null,this.checker?.schedule()}async status(){return await this.readDurableStatus()??this.checker?.getStatus()??{phase:"unavailable",currentVersion:this.options.currentVersion}}requestCheck(){return this.checker?(this.checker.refresh().catch(()=>void 0),this.checker.getStatus()):{phase:"unavailable",currentVersion:this.options.currentVersion}}async installAvailable(){if(!this.options.cliPath||!this.options.dataDir||!this.options.platform)throw Object.assign(Error("updates require a packaged AgentRoam service"),{status:409});let e=this.checker?.getStatus();if(!e||"available"!==e.phase||!e.targetVersion)throw Object.assign(Error("no validated update is available"),{status:409});return this.worker&&null===this.worker.exitCode?this.status():(this.worker=this.spawnImpl(process.execPath,[this.options.cliPath,"update",e.targetVersion,"--data-dir",this.options.dataDir],{detached:!0,stdio:"ignore",windowsHide:!0}),this.worker.unref(),{...e,phase:"downloading"})}async readDurableStatus(){if(!this.options.dataDir)return null;try{let e=JSON.parse(await (0,i.readFile)((0,a.resolve)(this.options.dataDir,"updates","state.json"),"utf8"));if(1!==e.schemaVersion||"string"!=typeof e.phase||"string"!=typeof e.targetVersion||!["downloading","installing","reconnecting","complete","failed"].includes(e.phase)||"complete"===e.phase&&0>=(0,n.V4k)(e.targetVersion,this.options.currentVersion))return null;return{phase:e.phase,currentVersion:this.options.currentVersion,targetVersion:e.targetVersion,message:"string"==typeof e.message?e.message:void 0}}catch{return null}}}function p(){let e=process.env.AGENTROAM_VERSION?.trim();return s??=new c({currentVersion:e||"0.0.0",platform:e?"darwin"===process.platform&&"arm64"===process.arch?"darwin-arm64":"win32"===process.platform&&"x64"===process.arch?"windows-amd64":null:null,dataDir:process.env.AGENTROAM_DATA_DIR?.trim(),cliPath:process.env.AGENTROAM_CLI_PATH?.trim()})}}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8375,6703,1322],()=>t(6666));module.exports=s})();
1
+ "use strict";(()=>{var e={};e.id=907,e.ids=[907],e.modules={5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},9801:e=>{e.exports=require("os")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},1041:e=>{e.exports=require("node:url")},9203:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>w,patchFetch:()=>x,requestAsyncStorage:()=>h,routeModule:()=>d,serverHooks:()=>g,staticGenerationAsyncStorage:()=>m});var s={};t.r(s),t.d(s,{POST:()=>u,dynamic:()=>p});var o=t(7786),i=t(5042),a=t(2184),n=t(1890),c=t(9605);let p="force-dynamic";async function u(e){return!function(e){let r=e.headers.get("origin");return!(r&&l.has(r))&&("cross-site"===e.headers.get("sec-fetch-site")||!!(r&&r!==new URL(e.url).origin))}(e)?n.NextResponse.json((0,c.X)().requestCheck(),{status:202,headers:{"cache-control":"no-store"}}):n.NextResponse.json({error:"cross-site update request rejected"},{status:403})}let l=new Set(["capacitor://localhost","ionic://localhost"]),d=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/update/check/route",pathname:"/api/update/check",filename:"route",bundlePath:"app/api/update/check/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/update/check/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:h,staticGenerationAsyncStorage:m,serverHooks:g}=d,w="/api/update/check/route";function x(){return(0,a.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:m})}},9605:(e,r,t)=>{let s;t.d(r,{X:()=>p});var o=t(7718),i=t(3977),a=t(9411),n=t(1322);class c{constructor(e){this.options=e,this.worker=null,this.spawnImpl=e.spawn??o.spawn,this.checker=e.platform?e.checker??new n.UuU({currentVersion:e.currentVersion,client:"cli",platform:e.platform}):null,this.checker?.schedule()}async status(){return await this.readDurableStatus()??this.checker?.getStatus()??{phase:"unavailable",currentVersion:this.options.currentVersion}}requestCheck(){return this.checker?(this.checker.refresh().catch(()=>void 0),this.checker.getStatus()):{phase:"unavailable",currentVersion:this.options.currentVersion}}async installAvailable(){if(!this.options.cliPath||!this.options.dataDir||!this.options.platform)throw Object.assign(Error("updates require a packaged AgentRoam service"),{status:409});let e=this.checker?.getStatus();if(!e||"available"!==e.phase||!e.targetVersion)throw Object.assign(Error("no validated update is available"),{status:409});return this.worker&&null===this.worker.exitCode?this.status():(this.worker=this.spawnImpl(process.execPath,[this.options.cliPath,"update",e.targetVersion,"--data-dir",this.options.dataDir],{detached:!0,stdio:"ignore",windowsHide:!0}),this.worker.unref(),{...e,phase:"downloading"})}async readDurableStatus(){if(!this.options.dataDir)return null;try{let e=JSON.parse(await (0,i.readFile)((0,a.resolve)(this.options.dataDir,"updates","state.json"),"utf8"));if(1!==e.schemaVersion||"string"!=typeof e.phase||"string"!=typeof e.targetVersion||!["downloading","installing","reconnecting","complete","failed"].includes(e.phase)||"complete"===e.phase&&0>=(0,n.V4k)(e.targetVersion,this.options.currentVersion))return null;return{phase:e.phase,currentVersion:this.options.currentVersion,targetVersion:e.targetVersion,message:"string"==typeof e.message?e.message:void 0}}catch{return null}}}function p(){let e=process.env.AGENTROAM_VERSION?.trim();return s??=new c({currentVersion:e||"0.0.0",platform:e?"darwin"===process.platform&&"arm64"===process.arch?"darwin-arm64":"win32"===process.platform&&"x64"===process.arch?"windows-amd64":null:null,dataDir:process.env.AGENTROAM_DATA_DIR?.trim(),cliPath:process.env.AGENTROAM_CLI_PATH?.trim()})}}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8375,6703,1322],()=>t(9203));module.exports=s})();
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=6936,e.ids=[6936],e.modules={5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},9801:e=>{e.exports=require("os")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},1041:e=>{e.exports=require("node:url")},9670:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>x,patchFetch:()=>f,requestAsyncStorage:()=>h,routeModule:()=>d,serverHooks:()=>g,staticGenerationAsyncStorage:()=>m});var s={};r.r(s),r.d(s,{POST:()=>c,dynamic:()=>u});var a=r(7786),i=r(5042),o=r(2184),n=r(1890),p=r(9605);let u="force-dynamic";async function c(e){try{if(function(e){let t=e.headers.get("origin");return!(t&&l.has(t))&&("cross-site"===e.headers.get("sec-fetch-site")||!!(t&&t!==new URL(e.url).origin))}(e))return n.NextResponse.json({error:"cross-site update request rejected"},{status:403});let t=await e.text();if(t&&"{}"!==t)return n.NextResponse.json({error:"update install does not accept parameters"},{status:400});return n.NextResponse.json(await (0,p.X)().installAvailable(),{status:202})}catch(t){let e=Number(t.status)||500;return n.NextResponse.json({error:t instanceof Error?t.message:"unable to start update"},{status:e})}}let l=new Set(["capacitor://localhost","ionic://localhost"]),d=new a.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/update/install/route",pathname:"/api/update/install",filename:"route",bundlePath:"app/api/update/install/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/update/install/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:h,staticGenerationAsyncStorage:m,serverHooks:g}=d,x="/api/update/install/route";function f(){return(0,o.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:m})}},9605:(e,t,r)=>{let s;r.d(t,{X:()=>u});var a=r(7718),i=r(3977),o=r(9411),n=r(1322);class p{constructor(e){this.options=e,this.worker=null,this.spawnImpl=e.spawn??a.spawn,this.checker=e.platform?e.checker??new n.UuU({currentVersion:e.currentVersion,client:"cli",platform:e.platform}):null,this.checker?.schedule()}async status(){return await this.readDurableStatus()??this.checker?.getStatus()??{phase:"unavailable",currentVersion:this.options.currentVersion}}requestCheck(){return this.checker?(this.checker.refresh().catch(()=>void 0),this.checker.getStatus()):{phase:"unavailable",currentVersion:this.options.currentVersion}}async installAvailable(){if(!this.options.cliPath||!this.options.dataDir||!this.options.platform)throw Object.assign(Error("updates require a packaged AgentRoam service"),{status:409});let e=this.checker?.getStatus();if(!e||"available"!==e.phase||!e.targetVersion)throw Object.assign(Error("no validated update is available"),{status:409});return this.worker&&null===this.worker.exitCode?this.status():(this.worker=this.spawnImpl(process.execPath,[this.options.cliPath,"update",e.targetVersion,"--data-dir",this.options.dataDir],{detached:!0,stdio:"ignore",windowsHide:!0}),this.worker.unref(),{...e,phase:"downloading"})}async readDurableStatus(){if(!this.options.dataDir)return null;try{let e=JSON.parse(await (0,i.readFile)((0,o.resolve)(this.options.dataDir,"updates","state.json"),"utf8"));if(1!==e.schemaVersion||"string"!=typeof e.phase||"string"!=typeof e.targetVersion||!["downloading","installing","reconnecting","complete","failed"].includes(e.phase)||"complete"===e.phase&&0>=(0,n.V4k)(e.targetVersion,this.options.currentVersion))return null;return{phase:e.phase,currentVersion:this.options.currentVersion,targetVersion:e.targetVersion,message:"string"==typeof e.message?e.message:void 0}}catch{return null}}}function u(){let e=process.env.AGENTROAM_VERSION?.trim();return s??=new p({currentVersion:e||"0.0.0",platform:e?"darwin"===process.platform&&"arm64"===process.arch?"darwin-arm64":"win32"===process.platform&&"x64"===process.arch?"windows-amd64":null:null,dataDir:process.env.AGENTROAM_DATA_DIR?.trim(),cliPath:process.env.AGENTROAM_CLI_PATH?.trim()})}}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6703,1322],()=>r(9670));module.exports=s})();
1
+ "use strict";(()=>{var e={};e.id=6936,e.ids=[6936],e.modules={5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},9801:e=>{e.exports=require("os")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},1041:e=>{e.exports=require("node:url")},3595:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>x,patchFetch:()=>f,requestAsyncStorage:()=>h,routeModule:()=>d,serverHooks:()=>g,staticGenerationAsyncStorage:()=>m});var s={};r.r(s),r.d(s,{POST:()=>c,dynamic:()=>u});var a=r(7786),i=r(5042),o=r(2184),n=r(1890),p=r(9605);let u="force-dynamic";async function c(e){try{if(function(e){let t=e.headers.get("origin");return!(t&&l.has(t))&&("cross-site"===e.headers.get("sec-fetch-site")||!!(t&&t!==new URL(e.url).origin))}(e))return n.NextResponse.json({error:"cross-site update request rejected"},{status:403});let t=await e.text();if(t&&"{}"!==t)return n.NextResponse.json({error:"update install does not accept parameters"},{status:400});return n.NextResponse.json(await (0,p.X)().installAvailable(),{status:202})}catch(t){let e=Number(t.status)||500;return n.NextResponse.json({error:t instanceof Error?t.message:"unable to start update"},{status:e})}}let l=new Set(["capacitor://localhost","ionic://localhost"]),d=new a.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/update/install/route",pathname:"/api/update/install",filename:"route",bundlePath:"app/api/update/install/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/update/install/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:h,staticGenerationAsyncStorage:m,serverHooks:g}=d,x="/api/update/install/route";function f(){return(0,o.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:m})}},9605:(e,t,r)=>{let s;r.d(t,{X:()=>u});var a=r(7718),i=r(3977),o=r(9411),n=r(1322);class p{constructor(e){this.options=e,this.worker=null,this.spawnImpl=e.spawn??a.spawn,this.checker=e.platform?e.checker??new n.UuU({currentVersion:e.currentVersion,client:"cli",platform:e.platform}):null,this.checker?.schedule()}async status(){return await this.readDurableStatus()??this.checker?.getStatus()??{phase:"unavailable",currentVersion:this.options.currentVersion}}requestCheck(){return this.checker?(this.checker.refresh().catch(()=>void 0),this.checker.getStatus()):{phase:"unavailable",currentVersion:this.options.currentVersion}}async installAvailable(){if(!this.options.cliPath||!this.options.dataDir||!this.options.platform)throw Object.assign(Error("updates require a packaged AgentRoam service"),{status:409});let e=this.checker?.getStatus();if(!e||"available"!==e.phase||!e.targetVersion)throw Object.assign(Error("no validated update is available"),{status:409});return this.worker&&null===this.worker.exitCode?this.status():(this.worker=this.spawnImpl(process.execPath,[this.options.cliPath,"update",e.targetVersion,"--data-dir",this.options.dataDir],{detached:!0,stdio:"ignore",windowsHide:!0}),this.worker.unref(),{...e,phase:"downloading"})}async readDurableStatus(){if(!this.options.dataDir)return null;try{let e=JSON.parse(await (0,i.readFile)((0,o.resolve)(this.options.dataDir,"updates","state.json"),"utf8"));if(1!==e.schemaVersion||"string"!=typeof e.phase||"string"!=typeof e.targetVersion||!["downloading","installing","reconnecting","complete","failed"].includes(e.phase)||"complete"===e.phase&&0>=(0,n.V4k)(e.targetVersion,this.options.currentVersion))return null;return{phase:e.phase,currentVersion:this.options.currentVersion,targetVersion:e.targetVersion,message:"string"==typeof e.message?e.message:void 0}}catch{return null}}}function u(){let e=process.env.AGENTROAM_VERSION?.trim();return s??=new p({currentVersion:e||"0.0.0",platform:e?"darwin"===process.platform&&"arm64"===process.arch?"darwin-arm64":"win32"===process.platform&&"x64"===process.arch?"windows-amd64":null:null,dataDir:process.env.AGENTROAM_DATA_DIR?.trim(),cliPath:process.env.AGENTROAM_CLI_PATH?.trim()})}}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6703,1322],()=>r(3595));module.exports=s})();
@@ -1 +1 @@
1
- "use strict";(()=>{var e={};e.id=4362,e.ids=[4362],e.modules={5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},9801:e=>{e.exports=require("os")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},1041:e=>{e.exports=require("node:url")},9734:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>g,patchFetch:()=>w,requestAsyncStorage:()=>l,routeModule:()=>d,serverHooks:()=>m,staticGenerationAsyncStorage:()=>h});var s={};r.r(s),r.d(s,{GET:()=>c,dynamic:()=>u});var a=r(7786),o=r(5042),i=r(2184),n=r(1890),p=r(9605);let u="force-dynamic";async function c(){return n.NextResponse.json(await (0,p.X)().status(),{headers:{"cache-control":"no-store"}})}let d=new a.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/update/status/route",pathname:"/api/update/status",filename:"route",bundlePath:"app/api/update/status/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-37/customer-agent/packages/server/app/api/update/status/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:l,staticGenerationAsyncStorage:h,serverHooks:m}=d,g="/api/update/status/route";function w(){return(0,i.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:h})}},9605:(e,t,r)=>{let s;r.d(t,{X:()=>u});var a=r(7718),o=r(3977),i=r(9411),n=r(1322);class p{constructor(e){this.options=e,this.worker=null,this.spawnImpl=e.spawn??a.spawn,this.checker=e.platform?e.checker??new n.UuU({currentVersion:e.currentVersion,client:"cli",platform:e.platform}):null,this.checker?.schedule()}async status(){return await this.readDurableStatus()??this.checker?.getStatus()??{phase:"unavailable",currentVersion:this.options.currentVersion}}requestCheck(){return this.checker?(this.checker.refresh().catch(()=>void 0),this.checker.getStatus()):{phase:"unavailable",currentVersion:this.options.currentVersion}}async installAvailable(){if(!this.options.cliPath||!this.options.dataDir||!this.options.platform)throw Object.assign(Error("updates require a packaged AgentRoam service"),{status:409});let e=this.checker?.getStatus();if(!e||"available"!==e.phase||!e.targetVersion)throw Object.assign(Error("no validated update is available"),{status:409});return this.worker&&null===this.worker.exitCode?this.status():(this.worker=this.spawnImpl(process.execPath,[this.options.cliPath,"update",e.targetVersion,"--data-dir",this.options.dataDir],{detached:!0,stdio:"ignore",windowsHide:!0}),this.worker.unref(),{...e,phase:"downloading"})}async readDurableStatus(){if(!this.options.dataDir)return null;try{let e=JSON.parse(await (0,o.readFile)((0,i.resolve)(this.options.dataDir,"updates","state.json"),"utf8"));if(1!==e.schemaVersion||"string"!=typeof e.phase||"string"!=typeof e.targetVersion||!["downloading","installing","reconnecting","complete","failed"].includes(e.phase)||"complete"===e.phase&&0>=(0,n.V4k)(e.targetVersion,this.options.currentVersion))return null;return{phase:e.phase,currentVersion:this.options.currentVersion,targetVersion:e.targetVersion,message:"string"==typeof e.message?e.message:void 0}}catch{return null}}}function u(){let e=process.env.AGENTROAM_VERSION?.trim();return s??=new p({currentVersion:e||"0.0.0",platform:e?"darwin"===process.platform&&"arm64"===process.arch?"darwin-arm64":"win32"===process.platform&&"x64"===process.arch?"windows-amd64":null:null,dataDir:process.env.AGENTROAM_DATA_DIR?.trim(),cliPath:process.env.AGENTROAM_CLI_PATH?.trim()})}}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6703,1322],()=>r(9734));module.exports=s})();
1
+ "use strict";(()=>{var e={};e.id=4362,e.ids=[4362],e.modules={5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},9801:e=>{e.exports=require("os")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},1041:e=>{e.exports=require("node:url")},7524:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>g,patchFetch:()=>w,requestAsyncStorage:()=>l,routeModule:()=>d,serverHooks:()=>m,staticGenerationAsyncStorage:()=>h});var s={};r.r(s),r.d(s,{GET:()=>c,dynamic:()=>u});var a=r(7786),o=r(5042),i=r(2184),n=r(1890),p=r(9605);let u="force-dynamic";async function c(){return n.NextResponse.json(await (0,p.X)().status(),{headers:{"cache-control":"no-store"}})}let d=new a.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/update/status/route",pathname:"/api/update/status",filename:"route",bundlePath:"app/api/update/status/route"},resolvedPagePath:"/Users/caoqu/.codex/worktrees/npm-preview-39/customer-agent/packages/server/app/api/update/status/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:l,staticGenerationAsyncStorage:h,serverHooks:m}=d,g="/api/update/status/route";function w(){return(0,i.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:h})}},9605:(e,t,r)=>{let s;r.d(t,{X:()=>u});var a=r(7718),o=r(3977),i=r(9411),n=r(1322);class p{constructor(e){this.options=e,this.worker=null,this.spawnImpl=e.spawn??a.spawn,this.checker=e.platform?e.checker??new n.UuU({currentVersion:e.currentVersion,client:"cli",platform:e.platform}):null,this.checker?.schedule()}async status(){return await this.readDurableStatus()??this.checker?.getStatus()??{phase:"unavailable",currentVersion:this.options.currentVersion}}requestCheck(){return this.checker?(this.checker.refresh().catch(()=>void 0),this.checker.getStatus()):{phase:"unavailable",currentVersion:this.options.currentVersion}}async installAvailable(){if(!this.options.cliPath||!this.options.dataDir||!this.options.platform)throw Object.assign(Error("updates require a packaged AgentRoam service"),{status:409});let e=this.checker?.getStatus();if(!e||"available"!==e.phase||!e.targetVersion)throw Object.assign(Error("no validated update is available"),{status:409});return this.worker&&null===this.worker.exitCode?this.status():(this.worker=this.spawnImpl(process.execPath,[this.options.cliPath,"update",e.targetVersion,"--data-dir",this.options.dataDir],{detached:!0,stdio:"ignore",windowsHide:!0}),this.worker.unref(),{...e,phase:"downloading"})}async readDurableStatus(){if(!this.options.dataDir)return null;try{let e=JSON.parse(await (0,o.readFile)((0,i.resolve)(this.options.dataDir,"updates","state.json"),"utf8"));if(1!==e.schemaVersion||"string"!=typeof e.phase||"string"!=typeof e.targetVersion||!["downloading","installing","reconnecting","complete","failed"].includes(e.phase)||"complete"===e.phase&&0>=(0,n.V4k)(e.targetVersion,this.options.currentVersion))return null;return{phase:e.phase,currentVersion:this.options.currentVersion,targetVersion:e.targetVersion,message:"string"==typeof e.message?e.message:void 0}}catch{return null}}}function u(){let e=process.env.AGENTROAM_VERSION?.trim();return s??=new p({currentVersion:e||"0.0.0",platform:e?"darwin"===process.platform&&"arm64"===process.arch?"darwin-arm64":"win32"===process.platform&&"x64"===process.arch?"windows-amd64":null:null,dataDir:process.env.AGENTROAM_DATA_DIR?.trim(),cliPath:process.env.AGENTROAM_CLI_PATH?.trim()})}}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6703,1322],()=>r(7524));module.exports=s})();