@codex-app-sdk/backend 0.17.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/dist/chunks/{codex-DzX6RrF2.js → codex-CmHW3ikB.js} +14 -17
  2. package/dist/chunks/codex-CmHW3ikB.js.map +1 -0
  3. package/dist/codex/client.d.ts.map +1 -1
  4. package/dist/codex/generated/ClientRequest.d.ts +81 -5
  5. package/dist/codex/generated/ClientRequest.d.ts.map +1 -1
  6. package/dist/codex/generated/ContentItem.d.ts +6 -1
  7. package/dist/codex/generated/ContentItem.d.ts.map +1 -1
  8. package/dist/codex/generated/FunctionCallOutputContentItem.d.ts +4 -1
  9. package/dist/codex/generated/FunctionCallOutputContentItem.d.ts.map +1 -1
  10. package/dist/codex/generated/ImageGenerationInputImage.d.ts +12 -0
  11. package/dist/codex/generated/ImageGenerationInputImage.d.ts.map +1 -0
  12. package/dist/codex/generated/ImageGenerationItem.d.ts +10 -2
  13. package/dist/codex/generated/ImageGenerationItem.d.ts.map +1 -1
  14. package/dist/codex/generated/InitializeCapabilities.d.ts +5 -0
  15. package/dist/codex/generated/InitializeCapabilities.d.ts.map +1 -1
  16. package/dist/codex/generated/MessagePhase.d.ts +2 -2
  17. package/dist/codex/generated/MessagePhase.d.ts.map +1 -1
  18. package/dist/codex/generated/Personality.d.ts +3 -0
  19. package/dist/codex/generated/Personality.d.ts.map +1 -1
  20. package/dist/codex/generated/PlanType.d.ts +1 -1
  21. package/dist/codex/generated/PlanType.d.ts.map +1 -1
  22. package/dist/codex/generated/RealtimeVoice.d.ts +1 -1
  23. package/dist/codex/generated/RealtimeVoice.d.ts.map +1 -1
  24. package/dist/codex/generated/RealtimeVoicesList.d.ts +1 -0
  25. package/dist/codex/generated/RealtimeVoicesList.d.ts.map +1 -1
  26. package/dist/codex/generated/ResponseItem.d.ts +14 -0
  27. package/dist/codex/generated/ResponseItem.d.ts.map +1 -1
  28. package/dist/codex/generated/ServerNotification.d.ts +16 -0
  29. package/dist/codex/generated/ServerNotification.d.ts.map +1 -1
  30. package/dist/codex/generated/ServerNotificationEnvelope.d.ts +16 -0
  31. package/dist/codex/generated/ServerNotificationEnvelope.d.ts.map +1 -1
  32. package/dist/codex/generated/ToolExposureSurface.d.ts +5 -0
  33. package/dist/codex/generated/ToolExposureSurface.d.ts.map +1 -0
  34. package/dist/codex/generated/index.d.ts +2 -0
  35. package/dist/codex/generated/index.d.ts.map +1 -1
  36. package/dist/codex/generated/v2/AccountRoutingOverride.d.ts +5 -0
  37. package/dist/codex/generated/v2/AccountRoutingOverride.d.ts.map +1 -0
  38. package/dist/codex/generated/v2/ApplicationRequirements.d.ts +2 -0
  39. package/dist/codex/generated/v2/ApplicationRequirements.d.ts.map +1 -1
  40. package/dist/codex/generated/v2/ApplicationStorageRequirements.d.ts +9 -0
  41. package/dist/codex/generated/v2/ApplicationStorageRequirements.d.ts.map +1 -0
  42. package/dist/codex/generated/v2/AppsConfig.d.ts +5 -0
  43. package/dist/codex/generated/v2/AppsConfig.d.ts.map +1 -1
  44. package/dist/codex/generated/v2/BedrockCheckGovCloudRequirementsParams.d.ts +2 -0
  45. package/dist/codex/generated/v2/BedrockCheckGovCloudRequirementsParams.d.ts.map +1 -0
  46. package/dist/codex/generated/v2/BedrockCheckGovCloudRequirementsResponse.d.ts +15 -0
  47. package/dist/codex/generated/v2/BedrockCheckGovCloudRequirementsResponse.d.ts.map +1 -0
  48. package/dist/codex/generated/v2/BrowserUseExtensionRequirements.d.ts +5 -0
  49. package/dist/codex/generated/v2/BrowserUseExtensionRequirements.d.ts.map +1 -0
  50. package/dist/codex/generated/v2/BrowserUseRequirements.d.ts +2 -0
  51. package/dist/codex/generated/v2/BrowserUseRequirements.d.ts.map +1 -1
  52. package/dist/codex/generated/v2/CodexErrorInfo.d.ts +4 -2
  53. package/dist/codex/generated/v2/CodexErrorInfo.d.ts.map +1 -1
  54. package/dist/codex/generated/v2/ConfigBatchWriteParams.d.ts +2 -2
  55. package/dist/codex/generated/v2/ConfigRequirements.d.ts +19 -3
  56. package/dist/codex/generated/v2/ConfigRequirements.d.ts.map +1 -1
  57. package/dist/codex/generated/v2/ConfigRequirementsReadResponse.d.ts +5 -0
  58. package/dist/codex/generated/v2/ConfigRequirementsReadResponse.d.ts.map +1 -1
  59. package/dist/codex/generated/v2/CyberAccessProgram.d.ts +1 -1
  60. package/dist/codex/generated/v2/EnvironmentAddParams.d.ts +15 -0
  61. package/dist/codex/generated/v2/EnvironmentAddParams.d.ts.map +1 -1
  62. package/dist/codex/generated/v2/EnvironmentSkillsParams.d.ts +7 -0
  63. package/dist/codex/generated/v2/EnvironmentSkillsParams.d.ts.map +1 -0
  64. package/dist/codex/generated/v2/FeedbackSaveParams.d.ts +17 -0
  65. package/dist/codex/generated/v2/FeedbackSaveParams.d.ts.map +1 -0
  66. package/dist/codex/generated/v2/FeedbackSaveResponse.d.ts +10 -0
  67. package/dist/codex/generated/v2/FeedbackSaveResponse.d.ts.map +1 -0
  68. package/dist/codex/generated/v2/FeedbackUploadResponse.d.ts +6 -0
  69. package/dist/codex/generated/v2/FeedbackUploadResponse.d.ts.map +1 -1
  70. package/dist/codex/generated/v2/GatewayOAuthCancelResponse.d.ts +2 -0
  71. package/dist/codex/generated/v2/GatewayOAuthCancelResponse.d.ts.map +1 -0
  72. package/dist/codex/generated/v2/GatewayOAuthChangedNotification.d.ts +11 -0
  73. package/dist/codex/generated/v2/GatewayOAuthChangedNotification.d.ts.map +1 -0
  74. package/dist/codex/generated/v2/GatewayOAuthLoginResponse.d.ts +2 -0
  75. package/dist/codex/generated/v2/GatewayOAuthLoginResponse.d.ts.map +1 -0
  76. package/dist/codex/generated/v2/GatewayOAuthReadResponse.d.ts +18 -0
  77. package/dist/codex/generated/v2/GatewayOAuthReadResponse.d.ts.map +1 -0
  78. package/dist/codex/generated/v2/GatewayOAuthStatus.d.ts +2 -0
  79. package/dist/codex/generated/v2/GatewayOAuthStatus.d.ts.map +1 -0
  80. package/dist/codex/generated/v2/GetAccountResponse.d.ts +2 -0
  81. package/dist/codex/generated/v2/GetAccountResponse.d.ts.map +1 -1
  82. package/dist/codex/generated/v2/HookEventName.d.ts +1 -1
  83. package/dist/codex/generated/v2/HookEventName.d.ts.map +1 -1
  84. package/dist/codex/generated/v2/ListMcpServerStatusParams.d.ts +4 -0
  85. package/dist/codex/generated/v2/ListMcpServerStatusParams.d.ts.map +1 -1
  86. package/dist/codex/generated/v2/ManagedHooksRequirements.d.ts +2 -0
  87. package/dist/codex/generated/v2/ManagedHooksRequirements.d.ts.map +1 -1
  88. package/dist/codex/generated/v2/McpAppDisplayMode.d.ts +2 -0
  89. package/dist/codex/generated/v2/McpAppDisplayMode.d.ts.map +1 -0
  90. package/dist/codex/generated/v2/McpAppUi.d.ts +9 -0
  91. package/dist/codex/generated/v2/McpAppUi.d.ts.map +1 -0
  92. package/dist/codex/generated/v2/McpResourceReadParams.d.ts +5 -0
  93. package/dist/codex/generated/v2/McpResourceReadParams.d.ts.map +1 -1
  94. package/dist/codex/generated/v2/McpResourceReadTarget.d.ts +8 -0
  95. package/dist/codex/generated/v2/McpResourceReadTarget.d.ts.map +1 -0
  96. package/dist/codex/generated/v2/McpServerElicitationRequestParams.d.ts +1 -0
  97. package/dist/codex/generated/v2/McpServerElicitationRequestParams.d.ts.map +1 -1
  98. package/dist/codex/generated/v2/McpServerOauthLoginCompletedNotification.d.ts +4 -0
  99. package/dist/codex/generated/v2/McpServerOauthLoginCompletedNotification.d.ts.map +1 -1
  100. package/dist/codex/generated/v2/McpServerOauthLoginResponse.d.ts +5 -0
  101. package/dist/codex/generated/v2/McpServerOauthLoginResponse.d.ts.map +1 -1
  102. package/dist/codex/generated/v2/McpServerStatus.d.ts +14 -0
  103. package/dist/codex/generated/v2/McpServerStatus.d.ts.map +1 -1
  104. package/dist/codex/generated/v2/MemoryStatusParams.d.ts +7 -0
  105. package/dist/codex/generated/v2/MemoryStatusParams.d.ts.map +1 -0
  106. package/dist/codex/generated/v2/MemoryStatusResponse.d.ts +5 -0
  107. package/dist/codex/generated/v2/MemoryStatusResponse.d.ts.map +1 -0
  108. package/dist/codex/generated/v2/MisalignmentErrorDetails.d.ts +4 -0
  109. package/dist/codex/generated/v2/MisalignmentErrorDetails.d.ts.map +1 -1
  110. package/dist/codex/generated/v2/Model.d.ts +8 -0
  111. package/dist/codex/generated/v2/Model.d.ts.map +1 -1
  112. package/dist/codex/generated/v2/ModelAccessPrograms.d.ts +11 -0
  113. package/dist/codex/generated/v2/ModelAccessPrograms.d.ts.map +1 -0
  114. package/dist/codex/generated/v2/ModelProviderCapabilitiesReadResponse.d.ts +0 -1
  115. package/dist/codex/generated/v2/ModelProviderCapabilitiesReadResponse.d.ts.map +1 -1
  116. package/dist/codex/generated/v2/PluginDetail.d.ts +4 -0
  117. package/dist/codex/generated/v2/PluginDetail.d.ts.map +1 -1
  118. package/dist/codex/generated/v2/RequestHeader.d.ts +5 -0
  119. package/dist/codex/generated/v2/RequestHeader.d.ts.map +1 -0
  120. package/dist/codex/generated/v2/RolloutCompressResponse.d.ts +6 -0
  121. package/dist/codex/generated/v2/RolloutCompressResponse.d.ts.map +1 -0
  122. package/dist/codex/generated/v2/SkillMetadata.d.ts +2 -2
  123. package/dist/codex/generated/v2/SkillMetadata.d.ts.map +1 -1
  124. package/dist/codex/generated/v2/SkillSummary.d.ts +2 -2
  125. package/dist/codex/generated/v2/SkillSummary.d.ts.map +1 -1
  126. package/dist/codex/generated/v2/Thread.d.ts +1 -1
  127. package/dist/codex/generated/v2/ThreadAttachment.d.ts +12 -0
  128. package/dist/codex/generated/v2/ThreadAttachment.d.ts.map +1 -0
  129. package/dist/codex/generated/v2/ThreadAttachmentAddOutcome.d.ts +5 -0
  130. package/dist/codex/generated/v2/ThreadAttachmentAddOutcome.d.ts.map +1 -0
  131. package/dist/codex/generated/v2/ThreadAttachmentAddParams.d.ts +11 -0
  132. package/dist/codex/generated/v2/ThreadAttachmentAddParams.d.ts.map +1 -0
  133. package/dist/codex/generated/v2/ThreadAttachmentAddResponse.d.ts +10 -0
  134. package/dist/codex/generated/v2/ThreadAttachmentAddResponse.d.ts.map +1 -0
  135. package/dist/codex/generated/v2/ThreadAttachmentListParams.d.ts +9 -0
  136. package/dist/codex/generated/v2/ThreadAttachmentListParams.d.ts.map +1 -0
  137. package/dist/codex/generated/v2/ThreadAttachmentListResponse.d.ts +9 -0
  138. package/dist/codex/generated/v2/ThreadAttachmentListResponse.d.ts.map +1 -0
  139. package/dist/codex/generated/v2/ThreadAttachmentOperation.d.ts +5 -0
  140. package/dist/codex/generated/v2/ThreadAttachmentOperation.d.ts.map +1 -0
  141. package/dist/codex/generated/v2/ThreadAttachmentOwner.d.ts +11 -0
  142. package/dist/codex/generated/v2/ThreadAttachmentOwner.d.ts.map +1 -0
  143. package/dist/codex/generated/v2/ThreadAttachmentOwnerListParams.d.ts +14 -0
  144. package/dist/codex/generated/v2/ThreadAttachmentOwnerListParams.d.ts.map +1 -0
  145. package/dist/codex/generated/v2/ThreadAttachmentOwnerListResponse.d.ts +9 -0
  146. package/dist/codex/generated/v2/ThreadAttachmentOwnerListResponse.d.ts.map +1 -0
  147. package/dist/codex/generated/v2/ThreadAttachmentRemoveParams.d.ts +9 -0
  148. package/dist/codex/generated/v2/ThreadAttachmentRemoveParams.d.ts.map +1 -0
  149. package/dist/codex/generated/v2/ThreadAttachmentRemoveResponse.d.ts +5 -0
  150. package/dist/codex/generated/v2/ThreadAttachmentRemoveResponse.d.ts.map +1 -0
  151. package/dist/codex/generated/v2/ThreadAttachmentUpdatedNotification.d.ts +12 -0
  152. package/dist/codex/generated/v2/ThreadAttachmentUpdatedNotification.d.ts.map +1 -0
  153. package/dist/codex/generated/v2/ThreadForkParams.d.ts +13 -0
  154. package/dist/codex/generated/v2/ThreadForkParams.d.ts.map +1 -1
  155. package/dist/codex/generated/v2/ThreadForkResponse.d.ts +4 -0
  156. package/dist/codex/generated/v2/ThreadForkResponse.d.ts.map +1 -1
  157. package/dist/codex/generated/v2/ThreadGoalClearParams.d.ts +5 -0
  158. package/dist/codex/generated/v2/ThreadGoalClearParams.d.ts.map +1 -1
  159. package/dist/codex/generated/v2/ThreadGoalMutationOrigin.d.ts +5 -0
  160. package/dist/codex/generated/v2/ThreadGoalMutationOrigin.d.ts.map +1 -0
  161. package/dist/codex/generated/v2/ThreadGoalSetParams.d.ts +5 -0
  162. package/dist/codex/generated/v2/ThreadGoalSetParams.d.ts.map +1 -1
  163. package/dist/codex/generated/v2/ThreadItem.d.ts +14 -1
  164. package/dist/codex/generated/v2/ThreadItem.d.ts.map +1 -1
  165. package/dist/codex/generated/v2/ThreadItemEntry.d.ts +8 -0
  166. package/dist/codex/generated/v2/ThreadItemEntry.d.ts.map +1 -1
  167. package/dist/codex/generated/v2/ThreadItemsListAnchor.d.ts +8 -0
  168. package/dist/codex/generated/v2/ThreadItemsListAnchor.d.ts.map +1 -0
  169. package/dist/codex/generated/v2/ThreadItemsListCursor.d.ts +6 -0
  170. package/dist/codex/generated/v2/ThreadItemsListCursor.d.ts.map +1 -0
  171. package/dist/codex/generated/v2/ThreadItemsListParams.d.ts +5 -2
  172. package/dist/codex/generated/v2/ThreadItemsListParams.d.ts.map +1 -1
  173. package/dist/codex/generated/v2/ThreadItemsReadParams.d.ts +12 -0
  174. package/dist/codex/generated/v2/ThreadItemsReadParams.d.ts.map +1 -0
  175. package/dist/codex/generated/v2/ThreadItemsReadResponse.d.ts +8 -0
  176. package/dist/codex/generated/v2/ThreadItemsReadResponse.d.ts.map +1 -0
  177. package/dist/codex/generated/v2/ThreadListParams.d.ts +6 -0
  178. package/dist/codex/generated/v2/ThreadListParams.d.ts.map +1 -1
  179. package/dist/codex/generated/v2/ThreadListResponse.d.ts +8 -0
  180. package/dist/codex/generated/v2/ThreadListResponse.d.ts.map +1 -1
  181. package/dist/codex/generated/v2/ThreadPredictionRequestParams.d.ts +5 -0
  182. package/dist/codex/generated/v2/ThreadPredictionRequestParams.d.ts.map +1 -0
  183. package/dist/codex/generated/v2/ThreadPredictionRequestResponse.d.ts +2 -0
  184. package/dist/codex/generated/v2/ThreadPredictionRequestResponse.d.ts.map +1 -0
  185. package/dist/codex/generated/v2/ThreadPredictionResult.d.ts +7 -0
  186. package/dist/codex/generated/v2/ThreadPredictionResult.d.ts.map +1 -0
  187. package/dist/codex/generated/v2/ThreadPredictionUpdatedNotification.d.ts +7 -0
  188. package/dist/codex/generated/v2/ThreadPredictionUpdatedNotification.d.ts.map +1 -0
  189. package/dist/codex/generated/v2/ThreadReadResponse.d.ts +5 -0
  190. package/dist/codex/generated/v2/ThreadReadResponse.d.ts.map +1 -1
  191. package/dist/codex/generated/v2/ThreadReadState.d.ts +10 -0
  192. package/dist/codex/generated/v2/ThreadReadState.d.ts.map +1 -0
  193. package/dist/codex/generated/v2/ThreadReadStateChangedNotification.d.ts +6 -0
  194. package/dist/codex/generated/v2/ThreadReadStateChangedNotification.d.ts.map +1 -0
  195. package/dist/codex/generated/v2/ThreadReadStateOperation.d.ts +6 -0
  196. package/dist/codex/generated/v2/ThreadReadStateOperation.d.ts.map +1 -0
  197. package/dist/codex/generated/v2/ThreadReadStateUpdateParams.d.ts +10 -0
  198. package/dist/codex/generated/v2/ThreadReadStateUpdateParams.d.ts.map +1 -0
  199. package/dist/codex/generated/v2/ThreadReadStateUpdateResponse.d.ts +5 -0
  200. package/dist/codex/generated/v2/ThreadReadStateUpdateResponse.d.ts.map +1 -0
  201. package/dist/codex/generated/v2/ThreadRealtimeStartParams.d.ts +9 -0
  202. package/dist/codex/generated/v2/ThreadRealtimeStartParams.d.ts.map +1 -1
  203. package/dist/codex/generated/v2/ThreadResumeParams.d.ts +4 -0
  204. package/dist/codex/generated/v2/ThreadResumeParams.d.ts.map +1 -1
  205. package/dist/codex/generated/v2/ThreadResumeResponse.d.ts +9 -0
  206. package/dist/codex/generated/v2/ThreadResumeResponse.d.ts.map +1 -1
  207. package/dist/codex/generated/v2/ThreadSampleCancelParams.d.ts +5 -0
  208. package/dist/codex/generated/v2/ThreadSampleCancelParams.d.ts.map +1 -0
  209. package/dist/codex/generated/v2/ThreadSampleCancelResponse.d.ts +2 -0
  210. package/dist/codex/generated/v2/ThreadSampleCancelResponse.d.ts.map +1 -0
  211. package/dist/codex/generated/v2/ThreadSampleParams.d.ts +26 -0
  212. package/dist/codex/generated/v2/ThreadSampleParams.d.ts.map +1 -0
  213. package/dist/codex/generated/v2/ThreadSampleResponse.d.ts +12 -0
  214. package/dist/codex/generated/v2/ThreadSampleResponse.d.ts.map +1 -0
  215. package/dist/codex/generated/v2/ThreadSearchOccurrencesParams.d.ts +2 -2
  216. package/dist/codex/generated/v2/ThreadSettings.d.ts +7 -0
  217. package/dist/codex/generated/v2/ThreadSettings.d.ts.map +1 -1
  218. package/dist/codex/generated/v2/ThreadSettingsUpdateParams.d.ts +7 -1
  219. package/dist/codex/generated/v2/ThreadSettingsUpdateParams.d.ts.map +1 -1
  220. package/dist/codex/generated/v2/ThreadStartParams.d.ts +9 -0
  221. package/dist/codex/generated/v2/ThreadStartParams.d.ts.map +1 -1
  222. package/dist/codex/generated/v2/ThreadStartResponse.d.ts +4 -0
  223. package/dist/codex/generated/v2/ThreadStartResponse.d.ts.map +1 -1
  224. package/dist/codex/generated/v2/ThreadUnreadPosition.d.ts +7 -0
  225. package/dist/codex/generated/v2/ThreadUnreadPosition.d.ts.map +1 -0
  226. package/dist/codex/generated/v2/Turn.d.ts +7 -1
  227. package/dist/codex/generated/v2/Turn.d.ts.map +1 -1
  228. package/dist/codex/generated/v2/TurnStartParams.d.ts +33 -2
  229. package/dist/codex/generated/v2/TurnStartParams.d.ts.map +1 -1
  230. package/dist/codex/generated/v2/TurnSteerParams.d.ts +8 -0
  231. package/dist/codex/generated/v2/TurnSteerParams.d.ts.map +1 -1
  232. package/dist/codex/generated/v2/TurnToolOutput.d.ts +4 -0
  233. package/dist/codex/generated/v2/TurnToolOutput.d.ts.map +1 -1
  234. package/dist/codex/generated/v2/UserInput.d.ts +3 -0
  235. package/dist/codex/generated/v2/UserInput.d.ts.map +1 -1
  236. package/dist/codex/generated/v2/UserVerificationCancelParams.d.ts +9 -0
  237. package/dist/codex/generated/v2/UserVerificationCancelParams.d.ts.map +1 -0
  238. package/dist/codex/generated/v2/UserVerificationCancelResponse.d.ts +6 -0
  239. package/dist/codex/generated/v2/UserVerificationCancelResponse.d.ts.map +1 -0
  240. package/dist/codex/generated/v2/UserVerificationEnrollResponse.d.ts +10 -0
  241. package/dist/codex/generated/v2/UserVerificationEnrollResponse.d.ts.map +1 -1
  242. package/dist/codex/generated/v2/WindowsSandboxImplementation.d.ts +2 -0
  243. package/dist/codex/generated/v2/WindowsSandboxImplementation.d.ts.map +1 -0
  244. package/dist/codex/generated/v2/WorkspaceRouting.d.ts +7 -0
  245. package/dist/codex/generated/v2/WorkspaceRouting.d.ts.map +1 -0
  246. package/dist/codex/generated/v2/index.d.ts +57 -2
  247. package/dist/codex/generated/v2/index.d.ts.map +1 -1
  248. package/dist/codex/method-map.d.ts +98 -6
  249. package/dist/codex/method-map.d.ts.map +1 -1
  250. package/dist/codex/schema-version.d.ts +1 -1
  251. package/dist/index.js +463 -472
  252. package/dist/index.js.map +1 -1
  253. package/dist/node/codex-conversation-history.d.ts.map +1 -1
  254. package/dist/node/codex-surface-items-controller.d.ts.map +1 -1
  255. package/dist/node/codex-surface-turn-actions-controller.d.ts.map +1 -1
  256. package/dist/protocol.js +1 -1
  257. package/package.json +2 -2
  258. package/dist/chunks/codex-DzX6RrF2.js.map +0 -1
  259. package/dist/codex/generated/v2/ThreadRollbackParams.d.ts +0 -14
  260. package/dist/codex/generated/v2/ThreadRollbackParams.d.ts.map +0 -1
  261. package/dist/codex/generated/v2/ThreadRollbackResponse.d.ts +0 -12
  262. package/dist/codex/generated/v2/ThreadRollbackResponse.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as e, n as t, r as n, s as r } from "./chunks/codex-DzX6RrF2.js";
1
+ import { i as e, n as t, r as n, s as r } from "./chunks/codex-CmHW3ikB.js";
2
2
  import { execFile as i, execFileSync as a, spawn as o } from "node:child_process";
3
3
  import { constants as s } from "node:buffer";
4
4
  import { existsSync as c, promises as l, readFileSync as u, readdirSync as d } from "node:fs";
@@ -1584,10 +1584,10 @@ var vn = "Result returned in structuredContent.", yn = 32 * 1024;
1584
1584
  function bn(e, t) {
1585
1585
  let n = e.status;
1586
1586
  if (e.kind === "command") {
1587
- let r = H(e.input) ? e.input : {}, i = typeof r.cwd == "string" ? r.cwd : t ?? void 0;
1587
+ let r = V(e.input) ? e.input : {}, i = typeof r.cwd == "string" ? r.cwd : t ?? void 0;
1588
1588
  return kn(r.commandActions).flatMap((e) => {
1589
1589
  if (e.type !== "read") return [];
1590
- let t = Vn(e.path ?? e.name, i);
1590
+ let t = Hn(e.path ?? e.name, i);
1591
1591
  return t ? [{
1592
1592
  action: "read",
1593
1593
  path: t,
@@ -1596,12 +1596,12 @@ function bn(e, t) {
1596
1596
  });
1597
1597
  }
1598
1598
  if (e.kind !== "fileChange") return [];
1599
- let r = H(e.input) ? e.input : {}, i = e.metadata ?? {};
1599
+ let r = V(e.input) ? e.input : {}, i = e.metadata ?? {};
1600
1600
  return (Array.isArray(i.changes) ? i.changes : Array.isArray(r.changes) ? r.changes : []).flatMap((e) => {
1601
- if (!H(e) || typeof e.path != "string") return [];
1602
- let r = V(e.kind);
1601
+ if (!V(e) || typeof e.path != "string") return [];
1602
+ let r = Vn(e.kind);
1603
1603
  if (r === "delete") return [];
1604
- let i = Vn(e.path, t ?? void 0);
1604
+ let i = Hn(e.path, t ?? void 0);
1605
1605
  return i ? [{
1606
1606
  action: r === "add" ? "create" : "edit",
1607
1607
  path: i,
@@ -1610,7 +1610,7 @@ function bn(e, t) {
1610
1610
  });
1611
1611
  }
1612
1612
  function R(e, t = {}) {
1613
- if (!H(e) || typeof e.id != "string") return null;
1613
+ if (!V(e) || typeof e.id != "string") return null;
1614
1614
  if (e.type === "commandExecution") {
1615
1615
  let n = typeof e.command == "string" ? e.command : "command", r = z(e.status), i = En(r, e.commandActions, n), a = t.includeCommandOutput && typeof e.aggregatedOutput == "string" ? e.aggregatedOutput : void 0;
1616
1616
  return {
@@ -1637,14 +1637,14 @@ function R(e, t = {}) {
1637
1637
  };
1638
1638
  }
1639
1639
  if (e.type === "mcpToolCall") {
1640
- let t = typeof e.server == "string" ? e.server : "mcp", n = typeof e.tool == "string" ? e.tool : "tool", r = Yn(Wn(e.error)), i = U(e.arguments), a = U(e.result);
1640
+ let t = typeof e.server == "string" ? e.server : "mcp", n = typeof e.tool == "string" ? e.tool : "tool", r = Xn(Gn(e.error)), i = H(e.arguments), a = H(e.result);
1641
1641
  return {
1642
1642
  type: "tool",
1643
1643
  id: e.id,
1644
1644
  kind: "mcp",
1645
1645
  title: `${t}.${n}`,
1646
1646
  status: z(e.status),
1647
- body: r ?? Yn(Gn(a)),
1647
+ body: r ?? Xn(Kn(a)),
1648
1648
  ...i === void 0 ? {} : { input: i },
1649
1649
  ...a === void 0 ? {} : { output: a },
1650
1650
  metadata: {
@@ -1657,14 +1657,14 @@ function R(e, t = {}) {
1657
1657
  };
1658
1658
  }
1659
1659
  if (e.type === "dynamicToolCall") {
1660
- let t = typeof e.tool == "string" ? e.tool : "tool", n = typeof e.namespace == "string" ? e.namespace : null, r = U(e.arguments), i = U(e.contentItems);
1660
+ let t = typeof e.tool == "string" ? e.tool : "tool", n = typeof e.namespace == "string" ? e.namespace : null, r = H(e.arguments), i = H(e.contentItems);
1661
1661
  return {
1662
1662
  type: "tool",
1663
1663
  id: e.id,
1664
1664
  kind: "dynamic",
1665
1665
  title: n ? `${n}.${t}` : t,
1666
1666
  status: z(e.status),
1667
- body: Yn(qn(i)),
1667
+ body: Xn(Jn(i)),
1668
1668
  ...r === void 0 ? {} : { input: r },
1669
1669
  ...i === void 0 ? {} : { output: i },
1670
1670
  metadata: {
@@ -1684,7 +1684,7 @@ function R(e, t = {}) {
1684
1684
  title: n.length === 1 ? "1 file change" : `${n.length} file changes`,
1685
1685
  status: r,
1686
1686
  ...i ? { statusText: i } : {},
1687
- body: Jn(n),
1687
+ body: Yn(n),
1688
1688
  input: { changes: n },
1689
1689
  metadata: {
1690
1690
  changes: n,
@@ -1721,7 +1721,7 @@ function R(e, t = {}) {
1721
1721
  } : null;
1722
1722
  }
1723
1723
  function xn(e) {
1724
- if (!H(e) || e.type !== "commandExecution" || typeof e.command != "string") return !1;
1724
+ if (!V(e) || e.type !== "commandExecution" || typeof e.command != "string") return !1;
1725
1725
  let t = e.command;
1726
1726
  return An(t) || jn(t) || Mn(t);
1727
1727
  }
@@ -1742,7 +1742,7 @@ function Cn(e, t) {
1742
1742
  let n = In("running", t);
1743
1743
  return {
1744
1744
  itemId: e,
1745
- body: Jn(t),
1745
+ body: Yn(t),
1746
1746
  ...n ? { statusText: n } : {},
1747
1747
  input: { changes: t },
1748
1748
  metadata: { changes: t },
@@ -1753,7 +1753,7 @@ function Cn(e, t) {
1753
1753
  title: t.length === 1 ? "1 file change" : `${t.length} file changes`,
1754
1754
  status: "running",
1755
1755
  ...n ? { statusText: n } : {},
1756
- body: Jn(t),
1756
+ body: Yn(t),
1757
1757
  input: { changes: t },
1758
1758
  metadata: { changes: t }
1759
1759
  }
@@ -1773,7 +1773,7 @@ function wn(e, t) {
1773
1773
  };
1774
1774
  }
1775
1775
  function Tn(e, t, n, r = "completed") {
1776
- let i = U(t), a = Yn(L(i));
1776
+ let i = H(t), a = Xn(L(i));
1777
1777
  return {
1778
1778
  itemId: e,
1779
1779
  title: n && n.trim() ? n : void 0,
@@ -1856,7 +1856,7 @@ function On(e) {
1856
1856
  return e.path ?? e.name ?? e.query ?? e.command;
1857
1857
  }
1858
1858
  function kn(e) {
1859
- return Array.isArray(e) ? e.flatMap((e) => !H(e) || e.type !== "read" && e.type !== "listFiles" && e.type !== "search" ? [] : [{
1859
+ return Array.isArray(e) ? e.flatMap((e) => !V(e) || e.type !== "read" && e.type !== "listFiles" && e.type !== "search" ? [] : [{
1860
1860
  command: typeof e.command == "string" ? e.command : void 0,
1861
1861
  name: typeof e.name == "string" ? e.name : void 0,
1862
1862
  path: typeof e.path == "string" ? e.path : void 0,
@@ -1883,7 +1883,7 @@ function Pn(e, t) {
1883
1883
  return Fn(e, t);
1884
1884
  }
1885
1885
  function Fn(e, t) {
1886
- return Nn(B(e.map(Un)), t);
1886
+ return Nn(B(e.map(Wn)), t);
1887
1887
  }
1888
1888
  function In(e, t) {
1889
1889
  let n = Ln(e, t);
@@ -1891,8 +1891,8 @@ function In(e, t) {
1891
1891
  }
1892
1892
  function Ln(e, t) {
1893
1893
  let n = t.flatMap((e) => {
1894
- if (!H(e)) return [];
1895
- let t = typeof e.path == "string" ? e.path : void 0, n = V(e.kind), r = zn(e);
1894
+ if (!V(e)) return [];
1895
+ let t = typeof e.path == "string" ? e.path : void 0, n = Vn(e.kind), r = zn(e);
1896
1896
  return [{
1897
1897
  addedLines: r.addedLines,
1898
1898
  kind: n,
@@ -1918,13 +1918,13 @@ function Rn(e) {
1918
1918
  return e.every((e) => e === "add") ? "create" : e.every((e) => e === "delete") ? "delete" : "edit";
1919
1919
  }
1920
1920
  function zn(e) {
1921
- let t = typeof e.diff == "string" ? e.diff : void 0, n = V(e.kind);
1921
+ let t = typeof e.diff == "string" ? e.diff : void 0, n = Vn(e.kind);
1922
1922
  return n === "add" ? {
1923
- addedLines: Hn(t),
1923
+ addedLines: Un(t),
1924
1924
  removedLines: 0
1925
1925
  } : n === "delete" ? {
1926
1926
  addedLines: 0,
1927
- removedLines: Hn(t)
1927
+ removedLines: Un(t)
1928
1928
  } : Bn(t);
1929
1929
  }
1930
1930
  function Bn(e) {
@@ -1939,54 +1939,54 @@ function Bn(e) {
1939
1939
  removedLines: n
1940
1940
  };
1941
1941
  }
1942
- function V(e) {
1942
+ function Vn(e) {
1943
1943
  if (e === "add" || e === "delete") return e;
1944
- if (H(e) && typeof e.type == "string") return V(e.type);
1944
+ if (V(e) && typeof e.type == "string") return Vn(e.type);
1945
1945
  }
1946
- function Vn(e, t) {
1946
+ function Hn(e, t) {
1947
1947
  let n = e?.trim();
1948
1948
  if (n) {
1949
1949
  if (v(n)) return n;
1950
1950
  if (!(!t || !v(t))) return x(t, n);
1951
1951
  }
1952
1952
  }
1953
- function Hn(e) {
1953
+ function Un(e) {
1954
1954
  if (!e) return 0;
1955
1955
  let t = e.split(/\r\n|\r|\n/);
1956
1956
  for (; t.at(-1) === "";) t.pop();
1957
1957
  return t.length;
1958
1958
  }
1959
- function Un(e) {
1960
- return e.split(/[\\/]/).filter(Boolean).at(-1) ?? e;
1961
- }
1962
1959
  function Wn(e) {
1963
- if (H(e)) return typeof e.message == "string" ? e.message : void 0;
1960
+ return e.split(/[\\/]/).filter(Boolean).at(-1) ?? e;
1964
1961
  }
1965
1962
  function Gn(e) {
1966
- if (!H(e)) return;
1967
- let t = Kn(e.content), n = "structuredContent" in e ? L(e.structuredContent) : void 0;
1968
- return n ? !t || t.trim() === vn ? n : `${t}\n\n${n}` : t;
1963
+ if (V(e)) return typeof e.message == "string" ? e.message : void 0;
1969
1964
  }
1970
1965
  function Kn(e) {
1971
- if (Array.isArray(e)) return e.map((e) => H(e) ? typeof e.text == "string" ? e.text : JSON.stringify(e) : "").filter(Boolean).join("\n\n") || void 0;
1966
+ if (!V(e)) return;
1967
+ let t = qn(e.content), n = "structuredContent" in e ? L(e.structuredContent) : void 0;
1968
+ return n ? !t || t.trim() === vn ? n : `${t}\n\n${n}` : t;
1972
1969
  }
1973
1970
  function qn(e) {
1974
- if (Array.isArray(e)) return e.map((e) => H(e) && typeof e.text == "string" ? e.text : JSON.stringify(e)).filter(Boolean).join("\n\n") || void 0;
1971
+ if (Array.isArray(e)) return e.map((e) => V(e) ? typeof e.text == "string" ? e.text : JSON.stringify(e) : "").filter(Boolean).join("\n\n") || void 0;
1975
1972
  }
1976
1973
  function Jn(e) {
1977
- return e.map((e) => H(e) ? `${V(e.kind) ?? "update"} ${typeof e.path == "string" ? e.path : "unknown"}` : JSON.stringify(e)).join("\n") || void 0;
1974
+ if (Array.isArray(e)) return e.map((e) => V(e) && typeof e.text == "string" ? e.text : JSON.stringify(e)).filter(Boolean).join("\n\n") || void 0;
1978
1975
  }
1979
- function H(e) {
1976
+ function Yn(e) {
1977
+ return e.map((e) => V(e) ? `${Vn(e.kind) ?? "update"} ${typeof e.path == "string" ? e.path : "unknown"}` : JSON.stringify(e)).join("\n") || void 0;
1978
+ }
1979
+ function V(e) {
1980
1980
  return !!(e && typeof e == "object" && !Array.isArray(e));
1981
1981
  }
1982
- function Yn(e) {
1982
+ function Xn(e) {
1983
1983
  return e !== void 0 && Buffer.byteLength(e) <= yn ? e : void 0;
1984
1984
  }
1985
- function U(e) {
1986
- if (!(e === void 0 || !Xn(e, yn))) return e;
1985
+ function H(e) {
1986
+ if (!(e === void 0 || !Zn(e, yn))) return e;
1987
1987
  }
1988
- function Xn(e, t) {
1989
- if (Zn(e, t, /* @__PURE__ */ new Set())) return !1;
1988
+ function Zn(e, t) {
1989
+ if (Qn(e, t, /* @__PURE__ */ new Set())) return !1;
1990
1990
  try {
1991
1991
  let n = JSON.stringify(e);
1992
1992
  return n !== void 0 && Buffer.byteLength(n) <= t;
@@ -1994,28 +1994,28 @@ function Xn(e, t) {
1994
1994
  return !1;
1995
1995
  }
1996
1996
  }
1997
- function Zn(e, t, n) {
1997
+ function Qn(e, t, n) {
1998
1998
  if (typeof e == "string") return Buffer.byteLength(e) > t;
1999
1999
  if (typeof e != "object" || !e) return !1;
2000
2000
  if (n.has(e)) return !0;
2001
2001
  n.add(e);
2002
- let r = (Array.isArray(e) ? e : Object.values(e)).some((e) => Zn(e, t, n));
2002
+ let r = (Array.isArray(e) ? e : Object.values(e)).some((e) => Qn(e, t, n));
2003
2003
  return n.delete(e), r;
2004
2004
  }
2005
2005
  //#endregion
2006
2006
  //#region src/node/codex-surface-message-state.ts
2007
- function Qn(e) {
2007
+ function $n(e) {
2008
2008
  for (let t = e.length - 1; t >= 0; --t) {
2009
2009
  let n = e[t];
2010
2010
  if (n?.status === "inProgress") return n.id;
2011
2011
  }
2012
2012
  return null;
2013
2013
  }
2014
- function W(e, t, n, r = {}) {
2015
- let i = [...e], a = q(i, (e) => e.metadata?.turnId === n), o = a >= 0 ? i[a] : void 0;
2014
+ function U(e, t, n, r = {}) {
2015
+ let i = [...e], a = K(i, (e) => e.metadata?.turnId === n), o = a >= 0 ? i[a] : void 0;
2016
2016
  if (o?.role === "assistant" && o.kind === void 0 && o.status === "streaming") return i;
2017
2017
  if (r.forceSegment) {
2018
- let e = q(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), t = e >= 0 ? i[e] : void 0;
2018
+ let e = K(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), t = e >= 0 ? i[e] : void 0;
2019
2019
  t?.parts.length === 0 ? i.splice(e, 1) : t && i.splice(e, 1, {
2020
2020
  ...t,
2021
2021
  status: "complete"
@@ -2035,9 +2035,9 @@ function W(e, t, n, r = {}) {
2035
2035
  }
2036
2036
  }), i;
2037
2037
  }
2038
- function $n(e, t, n, r, i, a) {
2038
+ function er(e, t, n, r, i, a) {
2039
2039
  if (!i) return [...e];
2040
- let o = W(e, t, n), s = q(o, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), c = s >= 0 ? o[s] : void 0;
2040
+ let o = U(e, t, n), s = K(o, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), c = s >= 0 ? o[s] : void 0;
2041
2041
  if (!c) return o;
2042
2042
  let l = [...c.parts], u = l.at(-1);
2043
2043
  return u?.type === "text" && u.itemId === r ? l.splice(l.length - 1, 1, {
@@ -2053,9 +2053,9 @@ function $n(e, t, n, r, i, a) {
2053
2053
  ...c,
2054
2054
  status: "streaming",
2055
2055
  parts: l
2056
- }), K(o, t);
2056
+ }), G(o, t);
2057
2057
  }
2058
- function er(e, t, n, r, i) {
2058
+ function tr(e, t, n, r, i) {
2059
2059
  let a = i.map((e, t) => {
2060
2060
  let n = e.trim();
2061
2061
  return n ? {
@@ -2065,17 +2065,22 @@ function er(e, t, n, r, i) {
2065
2065
  summaryIndex: t
2066
2066
  } : null;
2067
2067
  }).filter((e) => e !== null);
2068
- if (a.length === 0) return [...e];
2069
- let o = W(e, t, n), s = q(o, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), c = s >= 0 ? o[s] : void 0;
2068
+ a.length === 0 && a.push({
2069
+ type: "reasoning",
2070
+ summary: "",
2071
+ itemId: r,
2072
+ summaryIndex: 0
2073
+ });
2074
+ let o = U(e, t, n), s = K(o, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), c = s >= 0 ? o[s] : void 0;
2070
2075
  if (!c) return o;
2071
2076
  let l = c.parts.findIndex((e) => e.type === "reasoning" && e.itemId === r), u = c.parts.filter((e) => e.type !== "reasoning" || e.itemId !== r);
2072
2077
  return u.splice(l >= 0 ? l : u.length, 0, ...a), o.splice(s, 1, {
2073
2078
  ...c,
2074
2079
  status: "streaming",
2075
2080
  parts: u
2076
- }), K(o, t);
2081
+ }), G(o, t);
2077
2082
  }
2078
- function tr(e, t, n, r, i, a) {
2083
+ function nr(e, t, n, r, i, a) {
2079
2084
  let o = [...e];
2080
2085
  for (let e = o.length - 1; e >= 0; --e) {
2081
2086
  let s = o[e];
@@ -2091,9 +2096,9 @@ function tr(e, t, n, r, i, a) {
2091
2096
  }), o.splice(e, 1, {
2092
2097
  ...s,
2093
2098
  parts: l
2094
- }), K(o, t);
2099
+ }), G(o, t);
2095
2100
  }
2096
- let s = W(o, t, n), c = q(s, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), l = c >= 0 ? s[c] : void 0;
2101
+ let s = U(o, t, n), c = K(s, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), l = c >= 0 ? s[c] : void 0;
2097
2102
  if (!l) return s;
2098
2103
  let u = {
2099
2104
  type: "text",
@@ -2104,10 +2109,10 @@ function tr(e, t, n, r, i, a) {
2104
2109
  return s.splice(c, 1, {
2105
2110
  ...l,
2106
2111
  parts: [...l.parts, u]
2107
- }), K(s, t);
2112
+ }), G(s, t);
2108
2113
  }
2109
- function nr(e, t, n, r) {
2110
- return K(e.map((e) => {
2114
+ function rr(e, t, n, r) {
2115
+ return G(e.map((e) => {
2111
2116
  if (e.role !== "assistant" || e.metadata?.turnId !== n) return e;
2112
2117
  let t = e.parts.filter((e) => e.type !== "text" || e.itemId !== r);
2113
2118
  return t.length === e.parts.length ? e : {
@@ -2116,16 +2121,16 @@ function nr(e, t, n, r) {
2116
2121
  };
2117
2122
  }), t);
2118
2123
  }
2119
- function rr(e) {
2124
+ function ir(e) {
2120
2125
  let t = /<proposed_plan>([\s\S]*?)<\/proposed_plan>/iu.exec(e), n = t?.[1]?.trim() ?? "";
2121
2126
  return !t || !n ? null : {
2122
2127
  markdown: n,
2123
2128
  visibleText: `${e.slice(0, t.index)}${e.slice(t.index + t[0].length)}`.trim()
2124
2129
  };
2125
2130
  }
2126
- function G(e, t, n, r) {
2131
+ function W(e, t, n, r) {
2127
2132
  let i = [...e], a = i.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "tool" && e.id === r.id));
2128
- a < 0 && (i = W(i, t, n), a = q(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
2133
+ a < 0 && (i = U(i, t, n), a = K(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
2129
2134
  let o = a >= 0 ? i[a] : void 0;
2130
2135
  if (!o) return i;
2131
2136
  let s = [...o.parts], c = s.findIndex((e) => e.type === "tool" && e.id === r.id);
@@ -2137,7 +2142,7 @@ function G(e, t, n, r) {
2137
2142
  body: r.body ?? e.body,
2138
2143
  input: r.input ?? e.input,
2139
2144
  output: r.output ?? e.output,
2140
- statusText: r.statusText ?? ur(e.statusText, r.status),
2145
+ statusText: r.statusText ?? dr(e.statusText, r.status),
2141
2146
  metadata: {
2142
2147
  ...e.metadata ?? {},
2143
2148
  ...r.metadata ?? {}
@@ -2147,11 +2152,11 @@ function G(e, t, n, r) {
2147
2152
  return i.splice(a, 1, {
2148
2153
  ...o,
2149
2154
  parts: s
2150
- }), K(i, t);
2155
+ }), G(i, t);
2151
2156
  }
2152
- function ir(e, t, n, r, i = r.itemId) {
2157
+ function ar(e, t, n, r, i = r.itemId) {
2153
2158
  let a = [...e], o = a.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "media" && e.itemId === r.itemId));
2154
- o < 0 && r.itemId && (o = a.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "tool" && e.id === i))), o < 0 && (a = W(a, t, n), o = q(a, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
2159
+ o < 0 && r.itemId && (o = a.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "tool" && e.id === i))), o < 0 && (a = U(a, t, n), o = K(a, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
2155
2160
  let s = o >= 0 ? a[o] : void 0;
2156
2161
  if (!s) return a;
2157
2162
  let c = [...s.parts], l = c.findIndex((e) => e.type === "media" && e.itemId === r.itemId);
@@ -2159,25 +2164,25 @@ function ir(e, t, n, r, i = r.itemId) {
2159
2164
  ...s,
2160
2165
  status: "streaming",
2161
2166
  parts: c
2162
- }), K(a, t);
2167
+ }), G(a, t);
2163
2168
  }
2164
- function ar(e, t, n, r) {
2169
+ function or(e, t, n, r) {
2165
2170
  let i = [...e], a = i.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "question" && e.request.id === r.request.id));
2166
- a < 0 && (i = W(i, t, n), a = q(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
2171
+ a < 0 && (i = U(i, t, n), a = K(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
2167
2172
  let o = a >= 0 ? i[a] : void 0;
2168
2173
  if (!o) return i;
2169
2174
  let s = [...o.parts], c = s.findIndex((e) => e.type === "question" && e.request.id === r.request.id);
2170
2175
  return c >= 0 ? s.splice(c, 1, r) : s.push(r), i.splice(a, 1, {
2171
2176
  ...o,
2172
2177
  parts: s
2173
- }), K(i, t);
2178
+ }), G(i, t);
2174
2179
  }
2175
- function or(e, t) {
2180
+ function sr(e, t) {
2176
2181
  return e.itemId === t.itemId && e.media.url === t.media.url && e.media.alt === t.media.alt && e.media.mimeType === t.media.mimeType && e.media.prompt === t.media.prompt && e.media.title === t.media.title;
2177
2182
  }
2178
- function sr(e, t, n, r) {
2183
+ function cr(e, t, n, r) {
2179
2184
  let i = [...e], a = i.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "tool" && e.id === r.itemId));
2180
- if (a < 0) return r.fallbackToolPart ? sr(G(i, t, n, r.fallbackToolPart), t, n, {
2185
+ if (a < 0) return r.fallbackToolPart ? cr(W(i, t, n, r.fallbackToolPart), t, n, {
2181
2186
  ...r,
2182
2187
  fallbackToolPart: void 0
2183
2188
  }) : i;
@@ -2203,12 +2208,12 @@ function sr(e, t, n, r) {
2203
2208
  parts: s
2204
2209
  }), i) : i;
2205
2210
  }
2206
- function cr(e, t, n, r = "streaming") {
2211
+ function lr(e, t, n, r = "streaming") {
2207
2212
  if (e.some((e) => e.kind === "compaction" && e.metadata?.turnId === n)) return e.map((e) => r === "complete" && e.kind === "compaction" && e.metadata?.turnId === n ? {
2208
2213
  ...e,
2209
2214
  status: r
2210
2215
  } : e);
2211
- let i = [...e], a = q(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), o = a >= 0 ? i[a] : void 0;
2216
+ let i = [...e], a = K(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), o = a >= 0 ? i[a] : void 0;
2212
2217
  return o?.parts.length === 0 ? i.splice(a, 1) : o && i.splice(a, 1, {
2213
2218
  ...o,
2214
2219
  status: "complete"
@@ -2224,16 +2229,16 @@ function cr(e, t, n, r = "streaming") {
2224
2229
  conversationId: t,
2225
2230
  turnId: n
2226
2231
  }
2227
- }), K(i, t);
2232
+ }), G(i, t);
2228
2233
  }
2229
- function lr(e, t, n) {
2234
+ function ur(e, t, n) {
2230
2235
  let r = n === "completed" ? "completed" : "failed";
2231
2236
  return e.map((e) => {
2232
2237
  if (e.metadata?.turnId !== t) return e;
2233
2238
  let n = !1, i = e.parts.map((e) => e.type !== "tool" || e.status !== "running" ? e : (n = !0, {
2234
2239
  ...e,
2235
2240
  status: r,
2236
- statusText: ur(e.statusText, r)
2241
+ statusText: dr(e.statusText, r)
2237
2242
  }));
2238
2243
  return n ? {
2239
2244
  ...e,
@@ -2241,7 +2246,7 @@ function lr(e, t, n) {
2241
2246
  } : e;
2242
2247
  });
2243
2248
  }
2244
- function ur(e, t) {
2249
+ function dr(e, t) {
2245
2250
  if (t === "running" || !e) return e;
2246
2251
  try {
2247
2252
  let n = JSON.parse(e);
@@ -2253,27 +2258,27 @@ function ur(e, t) {
2253
2258
  return e;
2254
2259
  }
2255
2260
  }
2256
- function K(e, t) {
2261
+ function G(e, t) {
2257
2262
  let n = e.map((e, t) => ({
2258
2263
  message: e,
2259
2264
  index: t
2260
2265
  })).filter(({ message: e }) => e.metadata?.conversationId === t).at(-1)?.index ?? -1;
2261
2266
  return e.filter((e, r) => e.metadata?.conversationId !== t || r === n || e.role !== "assistant" || e.kind !== void 0 || e.parts.length > 0);
2262
2267
  }
2263
- function q(e, t) {
2268
+ function K(e, t) {
2264
2269
  for (let n = e.length - 1; n >= 0; --n) {
2265
2270
  let r = e[n];
2266
2271
  if (r !== void 0 && t(r)) return n;
2267
2272
  }
2268
2273
  return -1;
2269
2274
  }
2270
- function dr(e, t) {
2275
+ function fr(e, t) {
2271
2276
  return e.includes(t) ? [...e] : [...e, t];
2272
2277
  }
2273
- function fr(e, t) {
2278
+ function pr(e, t) {
2274
2279
  return [e?.trim() ?? "", ...t.map((e) => `${e.status === "completed" ? "- [x]" : "- [ ]"} ${e.step}`)].filter(Boolean).join("\n");
2275
2280
  }
2276
- function pr(e, t, n) {
2281
+ function mr(e, t, n) {
2277
2282
  return {
2278
2283
  type: "tool",
2279
2284
  id: `plan-progress-${e}`,
@@ -2296,19 +2301,19 @@ function pr(e, t, n) {
2296
2301
  }
2297
2302
  //#endregion
2298
2303
  //#region src/node/codex-conversation-history.ts
2299
- var mr = 16 * 1024 * 1024, hr = /* @__PURE__ */ new Set([
2304
+ var hr = 16 * 1024 * 1024, gr = /* @__PURE__ */ new Set([
2300
2305
  "image/avif",
2301
2306
  "image/gif",
2302
2307
  "image/jpeg",
2303
2308
  "image/png",
2304
2309
  "image/webp"
2305
2310
  ]);
2306
- function gr(e) {
2307
- return (Array.isArray(e.turns) ? e.turns : []).flatMap((t) => yr(e.id, t));
2311
+ function _r(e) {
2312
+ return (Array.isArray(e.turns) ? e.turns : []).flatMap((t) => br(e.id, t));
2308
2313
  }
2309
- function _r(e, t) {
2314
+ function vr(e, t) {
2310
2315
  let n = /* @__PURE__ */ new Map();
2311
- for (let t of e) for (let e of t.parts) e.type !== "attachment" || e.attachment.kind !== "image" || !e.attachment.path || Nr(e.attachment.url) && n.set(e.attachment.path, e.attachment.url);
2316
+ for (let t of e) for (let e of t.parts) e.type !== "attachment" || e.attachment.kind !== "image" || !e.attachment.path || Pr(e.attachment.url) && n.set(e.attachment.path, e.attachment.url);
2312
2317
  return n.size === 0 ? [...t] : t.map((e) => {
2313
2318
  let t = !1, r = e.parts.map((e) => {
2314
2319
  if (e.type !== "attachment" || e.attachment.kind !== "image" || !e.attachment.path) return e;
@@ -2327,9 +2332,9 @@ function _r(e, t) {
2327
2332
  } : e;
2328
2333
  });
2329
2334
  }
2330
- function vr(e, t) {
2335
+ function yr(e, t) {
2331
2336
  let n = new Map(e.filter((e) => e.role === "user" && e.metadata?.promptContent).map((e) => [e.id, e.metadata.promptContent]));
2332
- return _r(e, t).map((e) => {
2337
+ return vr(e, t).map((e) => {
2333
2338
  let t = n.get(e.id);
2334
2339
  if (!t || e.role !== "user") return e;
2335
2340
  let r = ne(t);
@@ -2346,14 +2351,14 @@ function vr(e, t) {
2346
2351
  };
2347
2352
  });
2348
2353
  }
2349
- function yr(e, t) {
2350
- let n = [], r = [], i = Lr(t.startedAt ?? t.completedAt), a = 0, o = !1, s = /* @__PURE__ */ new Set(), c = () => {
2354
+ function br(e, t) {
2355
+ let n = [], r = [], i = Rr(t.startedAt ?? t.completedAt), a = 0, o = !1, s = !1, c = /* @__PURE__ */ new Set(), l = () => {
2351
2356
  if (r.length === 0) return;
2352
2357
  let o = a === 0 ? "" : `-segment-${a}`;
2353
2358
  n.push({
2354
2359
  id: `assistant-${t.id}${o}`,
2355
2360
  role: "assistant",
2356
- status: Ir(t.status),
2361
+ status: Lr(t.status),
2357
2362
  turnId: t.id,
2358
2363
  parts: [...r],
2359
2364
  createdAt: i,
@@ -2365,11 +2370,11 @@ function yr(e, t) {
2365
2370
  };
2366
2371
  for (let a of Array.isArray(t.items) ? t.items : []) {
2367
2372
  if (a.type === "userMessage") {
2368
- let r = wr(a), l = Er(a);
2373
+ let r = Tr(a), s = Dr(a);
2369
2374
  if (r.length > 0) {
2370
2375
  let u = o, d = u ? null : JSON.stringify(r);
2371
- if (d && s.has(d)) continue;
2372
- d && s.add(d), c(), n.push({
2376
+ if (d && c.has(d)) continue;
2377
+ d && c.add(d), l(), n.push({
2373
2378
  id: a.clientId ?? `user-${e}-${t.id}-${a.id ?? n.length}`,
2374
2379
  ...u ? { kind: "steer" } : {},
2375
2380
  role: "user",
@@ -2380,9 +2385,9 @@ function yr(e, t) {
2380
2385
  metadata: {
2381
2386
  conversationId: e,
2382
2387
  turnId: t.id,
2383
- ...l.length > 0 ? {
2384
- asyncQuestionRequestIds: l,
2385
- asyncQuestionAnswers: Dr(a)
2388
+ ...s.length > 0 ? {
2389
+ asyncQuestionRequestIds: s,
2390
+ asyncQuestionAnswers: Or(a)
2386
2391
  } : {}
2387
2392
  }
2388
2393
  });
@@ -2390,7 +2395,7 @@ function yr(e, t) {
2390
2395
  continue;
2391
2396
  }
2392
2397
  if (a.type === "contextCompaction") {
2393
- o = !0, c();
2398
+ o = !0, l();
2394
2399
  let r = `compaction-${t.id}`;
2395
2400
  n.some((e) => e.id === r) || n.push({
2396
2401
  id: r,
@@ -2408,10 +2413,12 @@ function yr(e, t) {
2408
2413
  continue;
2409
2414
  }
2410
2415
  if (a.type === "agentMessage") {
2411
- let n = typeof a.text == "string" ? a.text : "", i = xr(e, t.id, a, !0), s = a.phase === "final_answer" ? rr(n) : null;
2412
- s && !i ? s.visibleText && (o = !0, r.push({
2416
+ let n = typeof a.text == "string" ? a.text : "";
2417
+ a.phase === "final_answer" && n.trim() && (s = !0);
2418
+ let i = Sr(e, t.id, a, !0), c = a.phase === "final_answer" ? ir(n) : null;
2419
+ c && !i ? c.visibleText && (o = !0, r.push({
2413
2420
  type: "text",
2414
- text: s.visibleText,
2421
+ text: c.visibleText,
2415
2422
  itemId: a.id,
2416
2423
  ...a.phase ? { phase: a.phase } : {}
2417
2424
  })) : n && !i && (o = !0, r.push({
@@ -2427,7 +2434,10 @@ function yr(e, t) {
2427
2434
  summary: e.trim(),
2428
2435
  summaryIndex: t
2429
2436
  })).filter(({ summary: e }) => e.length > 0);
2430
- e.length > 0 && (o = !0, r.push(...e.map(({ summary: e, summaryIndex: t }) => ({
2437
+ e.length === 0 && s && e.push({
2438
+ summary: "",
2439
+ summaryIndex: 0
2440
+ }), e.length > 0 && (o = !0, r.push(...e.map(({ summary: e, summaryIndex: t }) => ({
2431
2441
  type: "reasoning",
2432
2442
  summary: e,
2433
2443
  itemId: a.id,
@@ -2444,17 +2454,17 @@ function yr(e, t) {
2444
2454
  }));
2445
2455
  continue;
2446
2456
  }
2447
- let l = R(a);
2448
- l && (o = !0, r.push(l));
2449
- let u = Cr(a);
2450
- u.length && (o = !0, r.push(...u));
2457
+ let u = R(a);
2458
+ u && (o = !0, r.push(u));
2459
+ let d = wr(a);
2460
+ d.length && (o = !0, r.push(...d));
2451
2461
  }
2452
- return c(), t.status === "inProgress" ? n : lr(n, t.id, t.status);
2462
+ return l(), t.status === "inProgress" ? n : ur(n, t.id, t.status);
2453
2463
  }
2454
- function br(e, t, n) {
2455
- let r = Lr(t.startedAt);
2464
+ function xr(e, t, n) {
2465
+ let r = Rr(t.startedAt);
2456
2466
  if (n.type === "userMessage") {
2457
- let i = wr(n), a = Er(n);
2467
+ let i = Tr(n), a = Dr(n);
2458
2468
  return i.length > 0 ? {
2459
2469
  id: n.clientId ?? `user-${e}-${t.id}-${n.id}`,
2460
2470
  role: "user",
@@ -2468,13 +2478,13 @@ function br(e, t, n) {
2468
2478
  itemId: n.id,
2469
2479
  ...a.length > 0 ? {
2470
2480
  asyncQuestionRequestIds: a,
2471
- asyncQuestionAnswers: Dr(n)
2481
+ asyncQuestionAnswers: Or(n)
2472
2482
  } : {}
2473
2483
  }
2474
2484
  } : null;
2475
2485
  }
2476
2486
  if (n.type === "agentMessage" || n.type === "exitedReviewMode") {
2477
- let i = n.type === "agentMessage" ? n.text : n.review, a = n.type === "agentMessage" && n.phase === "final_answer" ? rr(i) : null, o = n.type === "agentMessage" ? xr(e, t.id, n, !0) : null, s = [...!o && (a?.visibleText || !a && i) ? [{
2487
+ let i = n.type === "agentMessage" ? n.text : n.review, a = n.type === "agentMessage" && n.phase === "final_answer" ? ir(i) : null, o = n.type === "agentMessage" ? Sr(e, t.id, n, !0) : null, s = [...!o && (a?.visibleText || !a && i) ? [{
2478
2488
  type: "text",
2479
2489
  text: a?.visibleText ?? i,
2480
2490
  itemId: n.id,
@@ -2483,7 +2493,7 @@ function br(e, t, n) {
2483
2493
  return s.length > 0 ? {
2484
2494
  id: `assistant-${n.id}`,
2485
2495
  role: "assistant",
2486
- status: Ir(t.status),
2496
+ status: Lr(t.status),
2487
2497
  turnId: t.id,
2488
2498
  parts: s,
2489
2499
  createdAt: r,
@@ -2507,7 +2517,7 @@ function br(e, t, n) {
2507
2517
  return i.length > 0 ? {
2508
2518
  id: `assistant-${n.id}`,
2509
2519
  role: "assistant",
2510
- status: Ir(t.status),
2520
+ status: Lr(t.status),
2511
2521
  turnId: t.id,
2512
2522
  parts: i,
2513
2523
  createdAt: r,
@@ -2519,11 +2529,11 @@ function br(e, t, n) {
2519
2529
  } : null;
2520
2530
  }
2521
2531
  let i = [], a = R(n);
2522
- a && i.push(a), i.push(...Cr(n));
2532
+ a && i.push(a), i.push(...wr(n));
2523
2533
  let o = i.length > 0 ? {
2524
2534
  id: `assistant-${n.id}`,
2525
2535
  role: "assistant",
2526
- status: Ir(t.status),
2536
+ status: Lr(t.status),
2527
2537
  turnId: t.id,
2528
2538
  parts: i,
2529
2539
  createdAt: r,
@@ -2533,9 +2543,9 @@ function br(e, t, n) {
2533
2543
  itemId: n.id
2534
2544
  }
2535
2545
  } : null;
2536
- return !o || t.status === "inProgress" ? o : lr([o], t.id, t.status)[0] ?? null;
2546
+ return !o || t.status === "inProgress" ? o : ur([o], t.id, t.status)[0] ?? null;
2537
2547
  }
2538
- function xr(e, t, n, r = !1) {
2548
+ function Sr(e, t, n, r = !1) {
2539
2549
  if (n.delivery !== "async") return null;
2540
2550
  let i = n.questions ?? [], a = i.length > 0 ? i.map((e, t) => ({
2541
2551
  id: JSON.stringify([
@@ -2577,9 +2587,9 @@ function xr(e, t, n, r = !1) {
2577
2587
  ...r ? { historical: !0 } : {}
2578
2588
  };
2579
2589
  }
2580
- function Sr(e) {
2590
+ function Cr(e) {
2581
2591
  if (e.type !== "imageGeneration" || R(e)?.status !== "completed") return null;
2582
- let t = typeof e.savedPath == "string" && v(e.savedPath) ? e.savedPath : null, n = t ? jr(t) : void 0, r = n && hr.has(n) ? t : null, i = Mr(typeof e.result == "string" ? e.result.trim() : ""), a = i?.url ?? (r ? oe(r).href : void 0);
2592
+ let t = typeof e.savedPath == "string" && v(e.savedPath) ? e.savedPath : null, n = t ? Mr(t) : void 0, r = n && gr.has(n) ? t : null, i = Nr("result" in e && typeof e.result == "string" ? e.result.trim() : ""), a = i?.url ?? (r ? oe(r).href : void 0);
2583
2593
  if (!a) return null;
2584
2594
  let o = typeof e.revisedPrompt == "string" ? e.revisedPrompt.trim() : "";
2585
2595
  return {
@@ -2594,8 +2604,8 @@ function Sr(e) {
2594
2604
  }
2595
2605
  };
2596
2606
  }
2597
- function Cr(e) {
2598
- let t = Sr(e);
2607
+ function wr(e) {
2608
+ let t = Cr(e);
2599
2609
  if (t) return [t];
2600
2610
  let n = e.type === "mcpToolCall" && e.status === "completed" ? e.result?.content : e.type === "dynamicToolCall" && e.status === "completed" ? e.contentItems : void 0;
2601
2611
  if (!Array.isArray(n)) return [];
@@ -2604,7 +2614,7 @@ function Cr(e) {
2604
2614
  if (!t || typeof t != "object" || Array.isArray(t) || r.length >= 8) continue;
2605
2615
  let n = t, a = n.type === "image" && typeof n.data == "string" ? n.data : n.type === "inputImage" && typeof n.imageUrl == "string" ? n.imageUrl : "";
2606
2616
  if (a.length > i) continue;
2607
- let o = Mr(a);
2617
+ let o = Nr(a);
2608
2618
  o && (i -= o.url.length, r.push({
2609
2619
  type: "media",
2610
2620
  itemId: r.length ? `${e.id}:image:${r.length}` : e.id,
@@ -2618,21 +2628,21 @@ function Cr(e) {
2618
2628
  }
2619
2629
  return r;
2620
2630
  }
2621
- function wr(e) {
2622
- let t = Array.isArray(e.content) ? e.content : [], n = t.some((e) => J(e) && e.type === "text" && typeof e.text == "string" && e.text.length > 0), r = [], i = [], a = /* @__PURE__ */ new Set(), o = () => {
2631
+ function Tr(e) {
2632
+ let t = Array.isArray(e.content) ? e.content : [], n = t.some((e) => q(e) && e.type === "text" && typeof e.text == "string" && e.text.length > 0), r = [], i = [], a = /* @__PURE__ */ new Set(), o = () => {
2623
2633
  i.length > 0 && r.push({
2624
2634
  type: "text",
2625
2635
  text: i.join("\n")
2626
2636
  }), i = [];
2627
2637
  };
2628
2638
  for (let e of t) {
2629
- if (J(e) && e.type === "skill" && typeof e.name == "string") {
2639
+ if (q(e) && e.type === "skill" && typeof e.name == "string") {
2630
2640
  if (n) continue;
2631
2641
  let t = e.name.toLowerCase();
2632
2642
  if (a.has(t)) continue;
2633
2643
  a.add(t);
2634
2644
  }
2635
- let t = Tr(e), s = Nt(t);
2645
+ let t = Er(e), s = Nt(t);
2636
2646
  if (s) {
2637
2647
  o(), r.push({
2638
2648
  type: "attachment",
@@ -2647,7 +2657,7 @@ function wr(e) {
2647
2657
  i.push(t);
2648
2658
  continue;
2649
2659
  }
2650
- let c = kr(e);
2660
+ let c = Ar(e);
2651
2661
  c && (o(), r.push({
2652
2662
  type: "attachment",
2653
2663
  attachment: c
@@ -2655,26 +2665,26 @@ function wr(e) {
2655
2665
  }
2656
2666
  return o(), r;
2657
2667
  }
2658
- function Tr(e) {
2659
- return !J(e) || typeof e.type != "string" ? "" : e.type === "text" && typeof e.text == "string" ? Or(e.text)?.displayText ?? e.text : e.type === "skill" && typeof e.name == "string" ? `$${e.name}` : "";
2660
- }
2661
2668
  function Er(e) {
2669
+ return !q(e) || typeof e.type != "string" ? "" : e.type === "text" && typeof e.text == "string" ? kr(e.text)?.displayText ?? e.text : e.type === "skill" && typeof e.name == "string" ? `$${e.name}` : "";
2670
+ }
2671
+ function Dr(e) {
2662
2672
  let t = /* @__PURE__ */ new Set();
2663
- for (let n of Array.isArray(e.content) ? e.content : []) if (!(!J(n) || n.type !== "text" || typeof n.text != "string")) for (let e of Or(n.text)?.requestIds ?? []) t.add(e);
2673
+ for (let n of Array.isArray(e.content) ? e.content : []) if (!(!q(n) || n.type !== "text" || typeof n.text != "string")) for (let e of kr(n.text)?.requestIds ?? []) t.add(e);
2664
2674
  return [...t];
2665
2675
  }
2666
- function Dr(e) {
2676
+ function Or(e) {
2667
2677
  let t = {};
2668
- for (let n of Array.isArray(e.content) ? e.content : []) !J(n) || n.type !== "text" || typeof n.text != "string" || Object.assign(t, Or(n.text)?.answers);
2678
+ for (let n of Array.isArray(e.content) ? e.content : []) !q(n) || n.type !== "text" || typeof n.text != "string" || Object.assign(t, kr(n.text)?.answers);
2669
2679
  return t;
2670
2680
  }
2671
- function Or(e) {
2681
+ function kr(e) {
2672
2682
  let t = e.match(/^<send_user_message_question_reply>\s*([\s\S]*?)\s*<\/send_user_message_question_reply>$/);
2673
2683
  if (!t?.[1]) return null;
2674
2684
  try {
2675
2685
  let e = JSON.parse(t[1]);
2676
2686
  if (!Array.isArray(e)) return null;
2677
- let n = e.filter((e) => J(e) && typeof e.questionItemId == "string" && typeof e.question == "string" && typeof e.answer == "string");
2687
+ let n = e.filter((e) => q(e) && typeof e.questionItemId == "string" && typeof e.question == "string" && typeof e.answer == "string");
2678
2688
  if (n.length === 0) return null;
2679
2689
  let r = n.flatMap((e) => {
2680
2690
  try {
@@ -2692,10 +2702,10 @@ function Or(e) {
2692
2702
  return null;
2693
2703
  }
2694
2704
  }
2695
- function kr(e) {
2696
- if (!J(e) || typeof e.type != "string") return null;
2697
- if (e.type === "mention" && typeof e.path == "string") {
2698
- let t = typeof e.name == "string" && e.name.trim() ? e.name.trim() : Ar(e.path, "File"), n = jr(e.path);
2705
+ function Ar(e) {
2706
+ if (!q(e) || typeof e.type != "string") return null;
2707
+ if (e.type === "mention" && typeof e.path == "string" && !e.path.startsWith("plugin://")) {
2708
+ let t = typeof e.name == "string" && e.name.trim() ? e.name.trim() : jr(e.path, "File"), n = Mr(e.path);
2699
2709
  return {
2700
2710
  kind: "file",
2701
2711
  name: t,
@@ -2704,26 +2714,26 @@ function kr(e) {
2704
2714
  };
2705
2715
  }
2706
2716
  if (e.type === "image" && typeof e.url == "string") {
2707
- let t = jr(e.url);
2717
+ let t = Mr(e.url);
2708
2718
  return {
2709
2719
  kind: "image",
2710
- name: Ar(e.url, "Image"),
2720
+ name: jr(e.url, "Image"),
2711
2721
  url: e.url,
2712
2722
  ...t ? { mimeType: t } : {}
2713
2723
  };
2714
2724
  }
2715
2725
  if (e.type === "localImage" && typeof e.path == "string") {
2716
- let t = jr(e.path);
2726
+ let t = Mr(e.path);
2717
2727
  return {
2718
2728
  kind: "image",
2719
- name: Ar(e.path, "Image"),
2729
+ name: jr(e.path, "Image"),
2720
2730
  path: e.path,
2721
2731
  ...t ? { mimeType: t } : {}
2722
2732
  };
2723
2733
  }
2724
2734
  return null;
2725
2735
  }
2726
- function Ar(e, t) {
2736
+ function jr(e, t) {
2727
2737
  try {
2728
2738
  let n = /^[a-z][a-z\d+.-]*:/i.test(e) ? new URL(e).pathname : e;
2729
2739
  return g(decodeURIComponent(n)).trim() || t;
@@ -2731,7 +2741,7 @@ function Ar(e, t) {
2731
2741
  return g(e).trim() || t;
2732
2742
  }
2733
2743
  }
2734
- function jr(e) {
2744
+ function Mr(e) {
2735
2745
  let t = /^data:([^;,]+)/i.exec(e)?.[1]?.toLowerCase();
2736
2746
  if (t) return t;
2737
2747
  let n = "";
@@ -2753,23 +2763,23 @@ function jr(e) {
2753
2763
  webp: "image/webp"
2754
2764
  }[n];
2755
2765
  }
2756
- function Mr(e) {
2766
+ function Nr(e) {
2757
2767
  if (!e) return null;
2758
- let t = (/^data:image\/[a-z0-9.+-]+;base64,([a-z0-9+/=\s]+)$/i.exec(e)?.[1] ?? e).replace(/\s+/g, ""), n = Math.ceil(mr / 3) * 4 + 4;
2768
+ let t = (/^data:image\/[a-z0-9.+-]+;base64,([a-z0-9+/=\s]+)$/i.exec(e)?.[1] ?? e).replace(/\s+/g, ""), n = Math.ceil(hr / 3) * 4 + 4;
2759
2769
  if (!t || t.length > n || t.length % 4 != 0 || !/^[a-z0-9+/]+={0,2}$/i.test(t)) return null;
2760
2770
  let r = Buffer.from(t, "base64");
2761
- if (r.byteLength === 0 || r.byteLength > mr) return null;
2762
- let i = Pr(r);
2771
+ if (r.byteLength === 0 || r.byteLength > hr) return null;
2772
+ let i = Fr(r);
2763
2773
  return i ? {
2764
2774
  url: `data:${i};base64,${t}`,
2765
2775
  mimeType: i
2766
2776
  } : null;
2767
2777
  }
2768
- function Nr(e) {
2778
+ function Pr(e) {
2769
2779
  return !!(e && e.length <= 16 * 1024 * 1024 && /^data:image\/(?:avif|bmp|gif|heic|heif|jpe?g|png|webp);base64,[a-z\d+/]+={0,2}$/i.test(e));
2770
2780
  }
2771
- function Pr(e) {
2772
- if (Fr(e, [
2781
+ function Fr(e) {
2782
+ if (Ir(e, [
2773
2783
  137,
2774
2784
  80,
2775
2785
  78,
@@ -2779,7 +2789,7 @@ function Pr(e) {
2779
2789
  26,
2780
2790
  10
2781
2791
  ])) return "image/png";
2782
- if (Fr(e, [
2792
+ if (Ir(e, [
2783
2793
  255,
2784
2794
  216,
2785
2795
  255
@@ -2787,50 +2797,50 @@ function Pr(e) {
2787
2797
  let t = Buffer.from(e.subarray(0, 12)).toString("ascii");
2788
2798
  return t.startsWith("GIF87a") || t.startsWith("GIF89a") ? "image/gif" : t.startsWith("RIFF") && t.slice(8, 12) === "WEBP" ? "image/webp" : e.byteLength >= 12 && t.slice(4, 12) === "ftypavif" ? "image/avif" : null;
2789
2799
  }
2790
- function Fr(e, t) {
2800
+ function Ir(e, t) {
2791
2801
  return t.every((t, n) => e[n] === t);
2792
2802
  }
2793
- function Ir(e) {
2803
+ function Lr(e) {
2794
2804
  return e === "inProgress" ? "streaming" : e === "failed" ? "error" : "complete";
2795
2805
  }
2796
- function Lr(e) {
2806
+ function Rr(e) {
2797
2807
  return typeof e != "number" || !Number.isFinite(e) ? (/* @__PURE__ */ new Date(0)).toISOString() : (/* @__PURE__ */ new Date(e * 1e3)).toISOString();
2798
2808
  }
2799
- function J(e) {
2809
+ function q(e) {
2800
2810
  return !!(e && typeof e == "object" && !Array.isArray(e));
2801
2811
  }
2802
2812
  //#endregion
2803
2813
  //#region src/node/codex-raw-response-item-adapter.ts
2804
- function Rr(e) {
2805
- if (!qr(e) || typeof e.type != "string") return null;
2814
+ function zr(e) {
2815
+ if (!Jr(e) || typeof e.type != "string") return null;
2806
2816
  if (e.type === "local_shell_call") {
2807
- let t = R(zr(e));
2817
+ let t = R(Br(e));
2808
2818
  return {
2809
- type: Ur(e.status) ? "item.completed" : "item.started",
2819
+ type: Wr(e.status) ? "item.completed" : "item.started",
2810
2820
  payload: { toolPart: t }
2811
2821
  };
2812
2822
  }
2813
2823
  return e.type === "function_call" ? {
2814
2824
  type: "item.started",
2815
- payload: { toolPart: R(Br(e)) }
2816
- } : e.type === "function_call_output" ? Vr(e.call_id, e.output) : e.type === "custom_tool_call" ? {
2825
+ payload: { toolPart: R(Vr(e)) }
2826
+ } : e.type === "function_call_output" ? Hr(e.call_id, e.output) : e.type === "custom_tool_call" ? {
2817
2827
  type: "item.started",
2818
2828
  payload: { toolPart: R({
2819
2829
  type: "dynamicToolCall",
2820
- id: X(e.call_id) ?? Y(e),
2830
+ id: Y(e.call_id) ?? J(e),
2821
2831
  namespace: null,
2822
- tool: X(e.name) ?? "custom_tool",
2832
+ tool: Y(e.name) ?? "custom_tool",
2823
2833
  status: e.status,
2824
- arguments: X(e.input) ?? "",
2834
+ arguments: Y(e.input) ?? "",
2825
2835
  contentItems: null,
2826
2836
  success: null,
2827
2837
  durationMs: null
2828
2838
  }) }
2829
- } : e.type === "custom_tool_call_output" ? Vr(e.call_id, e.output, X(e.name) ?? void 0) : e.type === "tool_search_call" ? {
2839
+ } : e.type === "custom_tool_call_output" ? Hr(e.call_id, e.output, Y(e.name) ?? void 0) : e.type === "tool_search_call" ? {
2830
2840
  type: "item.started",
2831
2841
  payload: { toolPart: R({
2832
2842
  type: "dynamicToolCall",
2833
- id: X(e.call_id) ?? Y(e),
2843
+ id: Y(e.call_id) ?? J(e),
2834
2844
  namespace: "codex",
2835
2845
  tool: "tool_search",
2836
2846
  status: e.status,
@@ -2842,20 +2852,20 @@ function Rr(e) {
2842
2852
  }) }
2843
2853
  } : e.type === "tool_search_output" ? {
2844
2854
  type: "item.updated",
2845
- payload: Tn(X(e.call_id) ?? Y(e), e.tools, "tool_search", e.status)
2855
+ payload: Tn(Y(e.call_id) ?? J(e), e.tools, "tool_search", e.status)
2846
2856
  } : e.type === "web_search_call" ? {
2847
2857
  type: "item.completed",
2848
2858
  payload: { toolPart: R({
2849
2859
  type: "webSearch",
2850
- id: Y(e),
2851
- query: Gr(e.action),
2860
+ id: J(e),
2861
+ query: Kr(e.action),
2852
2862
  action: e.action
2853
2863
  }) }
2854
2864
  } : e.type === "image_generation_call" ? {
2855
2865
  type: "item.completed",
2856
2866
  payload: { toolPart: R({
2857
2867
  type: "dynamicToolCall",
2858
- id: X(e.id) ?? Y(e),
2868
+ id: Y(e.id) ?? J(e),
2859
2869
  namespace: null,
2860
2870
  tool: "image_generation",
2861
2871
  status: e.status,
@@ -2866,29 +2876,29 @@ function Rr(e) {
2866
2876
  }) }
2867
2877
  } : null;
2868
2878
  }
2869
- function zr(e) {
2870
- let t = qr(e.action) ? e.action : {}, n = Array.isArray(t.command) ? Kr(t.command) : X(t.command) ?? "local shell";
2879
+ function Br(e) {
2880
+ let t = Jr(e.action) ? e.action : {}, n = Array.isArray(t.command) ? qr(t.command) : Y(t.command) ?? "local shell";
2871
2881
  return {
2872
2882
  type: "commandExecution",
2873
- id: X(e.call_id) ?? Y(e),
2883
+ id: Y(e.call_id) ?? J(e),
2874
2884
  command: n,
2875
- cwd: X(t.working_directory) ?? "",
2885
+ cwd: Y(t.working_directory) ?? "",
2876
2886
  processId: null,
2877
2887
  source: "agent",
2878
- status: Hr(e.status),
2888
+ status: Ur(e.status),
2879
2889
  commandActions: [],
2880
2890
  aggregatedOutput: null,
2881
2891
  exitCode: null,
2882
2892
  durationMs: null
2883
2893
  };
2884
2894
  }
2885
- function Br(e) {
2886
- let t = X(e.name) ?? "function_call", n = Wr(e.arguments), r = X(e.call_id) ?? Y(e);
2887
- return t === "shell_command" && qr(n) ? {
2895
+ function Vr(e) {
2896
+ let t = Y(e.name) ?? "function_call", n = Gr(e.arguments), r = Y(e.call_id) ?? J(e);
2897
+ return t === "shell_command" && Jr(n) ? {
2888
2898
  type: "commandExecution",
2889
2899
  id: r,
2890
- command: X(n.command) ?? t,
2891
- cwd: X(n.workdir) ?? X(n.cwd) ?? "",
2900
+ command: Y(n.command) ?? t,
2901
+ cwd: Y(n.workdir) ?? Y(n.cwd) ?? "",
2892
2902
  processId: null,
2893
2903
  source: "agent",
2894
2904
  status: "inProgress",
@@ -2899,7 +2909,7 @@ function Br(e) {
2899
2909
  } : {
2900
2910
  type: "dynamicToolCall",
2901
2911
  id: r,
2902
- namespace: X(e.namespace),
2912
+ namespace: Y(e.namespace),
2903
2913
  tool: t,
2904
2914
  status: "inProgress",
2905
2915
  arguments: n,
@@ -2908,19 +2918,19 @@ function Br(e) {
2908
2918
  durationMs: null
2909
2919
  };
2910
2920
  }
2911
- function Vr(e, t, n) {
2921
+ function Hr(e, t, n) {
2912
2922
  return {
2913
2923
  type: "item.updated",
2914
- payload: Tn(X(e) ?? "raw-response-output", t, n)
2924
+ payload: Tn(Y(e) ?? "raw-response-output", t, n)
2915
2925
  };
2916
2926
  }
2917
- function Hr(e) {
2927
+ function Ur(e) {
2918
2928
  return e === "completed" ? "completed" : e === "incomplete" || e === "failed" || e === "error" ? "failed" : "inProgress";
2919
2929
  }
2920
- function Ur(e) {
2930
+ function Wr(e) {
2921
2931
  return e === "completed" || e === "failed" || e === "error" || e === "incomplete";
2922
2932
  }
2923
- function Wr(e) {
2933
+ function Gr(e) {
2924
2934
  if (typeof e != "string") return e;
2925
2935
  try {
2926
2936
  return JSON.parse(e);
@@ -2928,54 +2938,54 @@ function Wr(e) {
2928
2938
  return e;
2929
2939
  }
2930
2940
  }
2931
- function Gr(e) {
2932
- return qr(e) ? X(e.query) ?? X(e.searchTerm) ?? "web search" : "web search";
2933
- }
2934
2941
  function Kr(e) {
2942
+ return Jr(e) ? Y(e.query) ?? Y(e.searchTerm) ?? "web search" : "web search";
2943
+ }
2944
+ function qr(e) {
2935
2945
  return e.map((e) => {
2936
2946
  let t = String(e);
2937
2947
  return /\s/.test(t) ? JSON.stringify(t) : t;
2938
2948
  }).join(" ");
2939
2949
  }
2940
- function Y(e) {
2941
- return (X(e.call_id) ?? X(e.id)) || `raw-${e.type}`;
2950
+ function J(e) {
2951
+ return (Y(e.call_id) ?? Y(e.id)) || `raw-${e.type}`;
2942
2952
  }
2943
- function X(e) {
2953
+ function Y(e) {
2944
2954
  return typeof e == "string" && e.length > 0 ? e : null;
2945
2955
  }
2946
- function qr(e) {
2956
+ function Jr(e) {
2947
2957
  return !!(e && typeof e == "object" && !Array.isArray(e));
2948
2958
  }
2949
2959
  //#endregion
2950
2960
  //#region src/node/codex-surface-events.ts
2951
- function Jr(e, t) {
2961
+ function Yr(e, t) {
2952
2962
  return `${e}\u0000${t}`;
2953
2963
  }
2954
- function Yr(e) {
2964
+ function Xr(e) {
2955
2965
  return typeof e == "number" && Number.isFinite(e) ? (/* @__PURE__ */ new Date(e * 1e3)).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
2956
2966
  }
2957
- function Xr(e) {
2967
+ function Zr(e) {
2958
2968
  return typeof e == "number" && Number.isFinite(e) ? (/* @__PURE__ */ new Date(e * 1e3)).toISOString() : null;
2959
2969
  }
2960
- function Zr(e) {
2970
+ function Qr(e) {
2961
2971
  return e ? {
2962
2972
  message: e.message,
2963
2973
  additionalDetails: e.additionalDetails,
2964
2974
  codexErrorInfo: e.codexErrorInfo
2965
2975
  } : null;
2966
2976
  }
2967
- function Z(e, t = !1) {
2977
+ function X(e, t = !1) {
2968
2978
  return {
2969
2979
  id: e.id,
2970
2980
  status: e.status,
2971
- error: Zr(e.error),
2981
+ error: Qr(e.error),
2972
2982
  willRetry: t,
2973
- startedAt: Xr(e.startedAt),
2974
- completedAt: Xr(e.completedAt),
2983
+ startedAt: Zr(e.startedAt),
2984
+ completedAt: Zr(e.completedAt),
2975
2985
  durationMs: e.durationMs ?? null
2976
2986
  };
2977
2987
  }
2978
- function Q(e, t) {
2988
+ function Z(e, t) {
2979
2989
  let n = e.findIndex((e) => e.id === t.id);
2980
2990
  if (n < 0) return [...e, t];
2981
2991
  let r = [...e];
@@ -2984,18 +2994,18 @@ function Q(e, t) {
2984
2994
  startedAt: t.startedAt ?? e[n].startedAt
2985
2995
  }), r;
2986
2996
  }
2987
- function Qr(e, t) {
2997
+ function $r(e, t) {
2988
2998
  return JSON.stringify(e) === JSON.stringify(t);
2989
2999
  }
2990
- function $r() {
3000
+ function ei() {
2991
3001
  return `user-${globalThis.crypto.randomUUID()}`;
2992
3002
  }
2993
- function ei() {
3003
+ function ti() {
2994
3004
  return `queued-prompt-${globalThis.crypto.randomUUID()}`;
2995
3005
  }
2996
3006
  //#endregion
2997
3007
  //#region src/node/codex-surface-subagents.ts
2998
- function ti(e) {
3008
+ function ni(e) {
2999
3009
  let t = {};
3000
3010
  for (let [n, r] of Object.entries(e.agentsStates)) r && (t[n] = {
3001
3011
  status: r.status,
@@ -3015,7 +3025,7 @@ function ti(e) {
3015
3025
  }
3016
3026
  //#endregion
3017
3027
  //#region src/node/codex-surface-items-controller.ts
3018
- var ni = class {
3028
+ var ri = class {
3019
3029
  host;
3020
3030
  commandOutputForwardItemIds = /* @__PURE__ */ new Set();
3021
3031
  fileActivityKeys = /* @__PURE__ */ new Set();
@@ -3033,13 +3043,13 @@ var ni = class {
3033
3043
  for (let e of this.reviewOutputByTurn.keys()) e.startsWith(t) && this.reviewOutputByTurn.delete(e);
3034
3044
  }
3035
3045
  isForwardingCommandOutput(e, t) {
3036
- return this.commandOutputForwardItemIds.has(Jr(e, t));
3046
+ return this.commandOutputForwardItemIds.has(Yr(e, t));
3037
3047
  }
3038
3048
  applyAgentDelta(e) {
3039
3049
  let t = this.host.requireRuntime(e.threadId);
3040
3050
  this.host.markRuntimeTurnActive(t, e.turnId);
3041
3051
  let n = t.messages.flatMap((e) => e.parts).find((t) => t.type === "text" && t.itemId === e.itemId)?.phase;
3042
- this.host.patchRuntime(e.threadId, { messages: $n(t.messages, e.threadId, e.turnId, e.itemId, e.delta, n) });
3052
+ this.host.patchRuntime(e.threadId, { messages: er(t.messages, e.threadId, e.turnId, e.itemId, e.delta, n) });
3043
3053
  let r = this.host.assistantMessageForTurn(e.threadId, e.turnId);
3044
3054
  r && this.host.emitEvent("notification", {
3045
3055
  type: "message.delta",
@@ -3057,7 +3067,7 @@ var ni = class {
3057
3067
  let t = this.host.requireRuntime(e.threadId);
3058
3068
  this.host.markRuntimeTurnActive(t, e.turnId);
3059
3069
  let n = `${t.planMarkdownByTurn.get(e.turnId) ?? ""}${e.delta}`;
3060
- t.planMarkdownByTurn.set(e.turnId, n), this.host.patchRuntime(e.threadId, { messages: G(t.messages, e.threadId, e.turnId, pr(e.turnId, n, "running")) }), this.host.emitEvent("notification", {
3070
+ t.planMarkdownByTurn.set(e.turnId, n), this.host.patchRuntime(e.threadId, { messages: W(t.messages, e.threadId, e.turnId, mr(e.turnId, n, "running")) }), this.host.emitEvent("notification", {
3061
3071
  type: "plan.delta",
3062
3072
  conversationId: e.threadId,
3063
3073
  turnId: e.turnId,
@@ -3071,7 +3081,7 @@ var ni = class {
3071
3081
  applyPlanUpdated(e) {
3072
3082
  let t = this.host.requireRuntime(e.threadId);
3073
3083
  this.host.markRuntimeTurnActive(t, e.turnId);
3074
- let n = fr(e.explanation, e.plan), r = (/* @__PURE__ */ new Date()).toISOString();
3084
+ let n = pr(e.explanation, e.plan), r = (/* @__PURE__ */ new Date()).toISOString();
3075
3085
  t.planMarkdownByTurn.set(e.turnId, n), this.host.patchRuntime(e.threadId, {
3076
3086
  executionPlan: {
3077
3087
  turnId: e.turnId,
@@ -3080,7 +3090,7 @@ var ni = class {
3080
3090
  markdown: n,
3081
3091
  updatedAt: r
3082
3092
  },
3083
- messages: G(t.messages, e.threadId, e.turnId, pr(e.turnId, n, "completed"))
3093
+ messages: W(t.messages, e.threadId, e.turnId, mr(e.turnId, n, "completed"))
3084
3094
  }), this.host.emitEvent("notification", {
3085
3095
  type: "plan.updated",
3086
3096
  conversationId: e.threadId,
@@ -3096,13 +3106,13 @@ var ni = class {
3096
3106
  applyRawResponseItem(e) {
3097
3107
  let t = this.host.requireRuntime(e.threadId);
3098
3108
  this.host.markRuntimeTurnActive(t, e.turnId);
3099
- let n = Rr(e.item);
3109
+ let n = zr(e.item);
3100
3110
  if (!n) return;
3101
3111
  if (n.type === "item.updated") {
3102
3112
  this.applyToolUpdate(e.threadId, e.turnId, n.payload);
3103
3113
  return;
3104
3114
  }
3105
- this.host.patchRuntime(e.threadId, { messages: G(t.messages, e.threadId, e.turnId, n.payload.toolPart) });
3115
+ this.host.patchRuntime(e.threadId, { messages: W(t.messages, e.threadId, e.turnId, n.payload.toolPart) });
3106
3116
  let r = this.host.messageContainingTool(e.threadId, e.turnId, n.payload.toolPart.id);
3107
3117
  r && (this.host.emitEvent("notification", {
3108
3118
  type: n.type === "item.completed" ? "tool.completed" : "tool.started",
@@ -3123,7 +3133,7 @@ var ni = class {
3123
3133
  startedAt: ("startedAtMs" in e ? e.startedAtMs : e.completedAtMs) / 1e3
3124
3134
  };
3125
3135
  if (e.item.type === "userMessage") {
3126
- let t = br(e.threadId, i, e.item);
3136
+ let t = xr(e.threadId, i, e.item);
3127
3137
  if (!t || n.messages.some((e) => e.id === t.id)) return;
3128
3138
  let a = n.messages.some((t) => t.role === "assistant" && t.metadata?.turnId === e.turnId && t.parts.length > 0), o = !a && r ? n.messages.map((e) => e.role === "user" && e.kind !== "steer" && !e.turnId && JSON.stringify(e.parts) === JSON.stringify(t.parts)).lastIndexOf(!0) : -1;
3129
3139
  if (o >= 0) {
@@ -3149,7 +3159,7 @@ var ni = class {
3149
3159
  ...t,
3150
3160
  kind: "steer"
3151
3161
  } : t, c = [...n.messages, s];
3152
- this.host.patchRuntime(e.threadId, { messages: a ? W(c, e.threadId, e.turnId, { forceSegment: !0 }) : c }), this.host.emitEvent("notification", {
3162
+ this.host.patchRuntime(e.threadId, { messages: a ? U(c, e.threadId, e.turnId, { forceSegment: !0 }) : c }), this.host.emitEvent("notification", {
3153
3163
  type: "message.appended",
3154
3164
  conversationId: e.threadId,
3155
3165
  turnId: e.turnId,
@@ -3158,9 +3168,8 @@ var ni = class {
3158
3168
  return;
3159
3169
  }
3160
3170
  if (e.item.type === "reasoning") {
3161
- if (e.item.summary.filter((e) => e.trim().length > 0).length === 0) return;
3162
3171
  let t = this.host.assistantMessageForTurn(e.threadId, e.turnId), r = t ? JSON.stringify(t.parts) : null;
3163
- this.host.patchRuntime(e.threadId, { messages: er(n.messages, e.threadId, e.turnId, e.item.id, e.item.summary) });
3172
+ this.host.patchRuntime(e.threadId, { messages: tr(n.messages, e.threadId, e.turnId, e.item.id, e.item.summary) });
3164
3173
  let i = this.host.assistantMessageForTurn(e.threadId, e.turnId);
3165
3174
  if (!i || JSON.stringify(i.parts) === r) return;
3166
3175
  this.host.emitEvent("notification", {
@@ -3172,10 +3181,10 @@ var ni = class {
3172
3181
  return;
3173
3182
  }
3174
3183
  if (e.item.type === "agentMessage" && t && n.planMode && e.item.phase === "final_answer") {
3175
- let t = rr(e.item.text);
3184
+ let t = ir(e.item.text);
3176
3185
  if (t) {
3177
- let r = this.host.assistantMessageForTurn(e.threadId, e.turnId), i = nr(n.messages, e.threadId, e.turnId, e.item.id);
3178
- t.visibleText && (i = tr(i, e.threadId, e.turnId, e.item.id, t.visibleText, e.item.phase)), i = G(i, e.threadId, e.turnId, pr(e.turnId, t.markdown, "completed")), n.planMarkdownByTurn.set(e.turnId, t.markdown), this.host.patchRuntime(e.threadId, { messages: i });
3186
+ let r = this.host.assistantMessageForTurn(e.threadId, e.turnId), i = rr(n.messages, e.threadId, e.turnId, e.item.id);
3187
+ t.visibleText && (i = nr(i, e.threadId, e.turnId, e.item.id, t.visibleText, e.item.phase)), i = W(i, e.threadId, e.turnId, mr(e.turnId, t.markdown, "completed")), n.planMarkdownByTurn.set(e.turnId, t.markdown), this.host.patchRuntime(e.threadId, { messages: i });
3179
3188
  let a = this.host.assistantMessageForTurn(e.threadId, e.turnId);
3180
3189
  a && this.host.emitEvent("notification", {
3181
3190
  type: r ? "message.updated" : "message.appended",
@@ -3197,11 +3206,11 @@ var ni = class {
3197
3206
  if (e.item.type === "agentMessage" || e.item.type === "exitedReviewMode") {
3198
3207
  let t = e.item.type === "agentMessage" ? e.item.text : e.item.review, r = e.item.type === "agentMessage" ? e.item.phase ?? void 0 : void 0;
3199
3208
  if (!t && e.item.type !== "agentMessage") return;
3200
- let i = Jr(e.threadId, e.turnId);
3209
+ let i = Yr(e.threadId, e.turnId);
3201
3210
  if (e.item.type === "agentMessage" && this.reviewOutputByTurn.get(i) === t) return;
3202
3211
  e.item.type === "exitedReviewMode" && this.reviewOutputByTurn.set(i, t);
3203
- let a = new Set(n.messages.map((e) => e.id)), o = this.host.assistantMessageForTurn(e.threadId, e.turnId), s = o ? JSON.stringify(o.parts) : null, c = new Set(o?.parts.flatMap((e) => e.type === "question" ? [e.request.id] : []) ?? []), l = n.messages.flatMap((e) => e.parts).find((t) => t.type === "text" && t.itemId === e.item.id)?.text ?? "", u = e.item.type === "agentMessage" ? xr(e.threadId, e.turnId, e.item) : null, d = u ? "" : t, f = u ? nr(n.messages, e.threadId, e.turnId, e.item.id) : tr(n.messages, e.threadId, e.turnId, e.item.id, t, r);
3204
- if (u && (f = ar(f, e.threadId, e.turnId, u)), this.host.patchRuntime(e.threadId, { messages: f }), !d && !u) return;
3212
+ let a = new Set(n.messages.map((e) => e.id)), o = this.host.assistantMessageForTurn(e.threadId, e.turnId), s = o ? JSON.stringify(o.parts) : null, c = new Set(o?.parts.flatMap((e) => e.type === "question" ? [e.request.id] : []) ?? []), l = n.messages.flatMap((e) => e.parts).find((t) => t.type === "text" && t.itemId === e.item.id)?.text ?? "", u = e.item.type === "agentMessage" ? Sr(e.threadId, e.turnId, e.item) : null, d = u ? "" : t, f = u ? rr(n.messages, e.threadId, e.turnId, e.item.id) : nr(n.messages, e.threadId, e.turnId, e.item.id, t, r);
3213
+ if (u && (f = or(f, e.threadId, e.turnId, u)), this.host.patchRuntime(e.threadId, { messages: f }), !d && !u && !r) return;
3205
3214
  let p = this.host.assistantMessageForTurn(e.threadId, e.turnId);
3206
3215
  if (p && !a.has(p.id)) this.host.emitEvent("notification", {
3207
3216
  type: "message.appended",
@@ -3209,7 +3218,7 @@ var ni = class {
3209
3218
  turnId: e.turnId,
3210
3219
  payload: { message: structuredClone(p) }
3211
3220
  });
3212
- else if (p && u && JSON.stringify(p.parts) !== s) this.host.emitEvent("notification", {
3221
+ else if (p && JSON.stringify(p.parts) !== s && (u || d === l)) this.host.emitEvent("notification", {
3213
3222
  type: "message.updated",
3214
3223
  conversationId: e.threadId,
3215
3224
  turnId: e.turnId,
@@ -3245,7 +3254,7 @@ var ni = class {
3245
3254
  if (e.item.type === "plan") {
3246
3255
  if (!t) return;
3247
3256
  let r = e.item.text.trim() || n.planMarkdownByTurn.get(e.turnId) || "";
3248
- n.planMarkdownByTurn.set(e.turnId, r), this.host.patchRuntime(e.threadId, { messages: G(n.messages, e.threadId, e.turnId, pr(e.turnId, r, "completed")) }), this.host.emitEvent("notification", {
3257
+ n.planMarkdownByTurn.set(e.turnId, r), this.host.patchRuntime(e.threadId, { messages: W(n.messages, e.threadId, e.turnId, mr(e.turnId, r, "completed")) }), this.host.emitEvent("notification", {
3249
3258
  type: "plan.completed",
3250
3259
  conversationId: e.threadId,
3251
3260
  turnId: e.turnId,
@@ -3257,7 +3266,7 @@ var ni = class {
3257
3266
  return;
3258
3267
  }
3259
3268
  if (e.item.type === "contextCompaction") {
3260
- if (this.host.patchRuntime(e.threadId, { messages: cr(n.messages, e.threadId, e.turnId, t ? "complete" : "streaming") }), t) {
3269
+ if (this.host.patchRuntime(e.threadId, { messages: lr(n.messages, e.threadId, e.turnId, t ? "complete" : "streaming") }), t) {
3261
3270
  let t = this.host.requireRuntime(e.threadId).messages.find((t) => t.kind === "compaction" && t.metadata?.turnId === e.turnId);
3262
3271
  t && this.host.emitEvent("notification", {
3263
3272
  type: "context.compactionCompleted",
@@ -3283,7 +3292,7 @@ var ni = class {
3283
3292
  turnId: e.turnId,
3284
3293
  payload: {
3285
3294
  lifecycle: t ? "completed" : "started",
3286
- toolCall: ti(e.item)
3295
+ toolCall: ni(e.item)
3287
3296
  }
3288
3297
  });
3289
3298
  return;
@@ -3308,10 +3317,10 @@ var ni = class {
3308
3317
  let a = this.shouldForwardCommandOutput(e.threadId, t, e.item), o = R(e.item, {
3309
3318
  includeCommandOutput: a,
3310
3319
  cwd: n.cwd
3311
- }), s = Cr(e.item);
3320
+ }), s = wr(e.item);
3312
3321
  if (!o && !s.length) return;
3313
- let c = s.some((e) => !n.messages.some((t) => t.parts.some((t) => t.type === "media" && or(t, e)))), l = o ? G(n.messages, e.threadId, e.turnId, o) : [...n.messages];
3314
- for (let t of s) l = ir(l, e.threadId, e.turnId, t, e.item.id);
3322
+ let c = s.some((e) => !n.messages.some((t) => t.parts.some((t) => t.type === "media" && sr(t, e)))), l = o ? W(n.messages, e.threadId, e.turnId, o) : [...n.messages];
3323
+ for (let t of s) l = ar(l, e.threadId, e.turnId, t, e.item.id);
3315
3324
  this.host.patchRuntime(e.threadId, { messages: l });
3316
3325
  let u = o ? this.host.messageContainingTool(e.threadId, e.turnId, o.id) : this.host.assistantMessageForTurn(e.threadId, e.turnId);
3317
3326
  u && o && this.host.emitEvent("notification", {
@@ -3332,7 +3341,7 @@ var ni = class {
3332
3341
  shouldForwardCommandOutput(e, t, n) {
3333
3342
  let r = "id" in n && typeof n.id == "string" ? n.id : null;
3334
3343
  if (!r) return !1;
3335
- let i = Jr(e, r);
3344
+ let i = Yr(e, r);
3336
3345
  if (!t) {
3337
3346
  let e = xn(n);
3338
3347
  return e ? this.commandOutputForwardItemIds.add(i) : this.commandOutputForwardItemIds.delete(i), e;
@@ -3343,14 +3352,14 @@ var ni = class {
3343
3352
  applyToolUpdate(e, t, n) {
3344
3353
  let r = this.host.requireRuntime(e);
3345
3354
  this.host.markRuntimeTurnActive(r, t);
3346
- let i = r.cwd && ri(n) ? {
3355
+ let i = r.cwd && ii(n) ? {
3347
3356
  ...n,
3348
3357
  metadata: {
3349
3358
  ...n.metadata,
3350
3359
  cwd: r.cwd
3351
3360
  }
3352
3361
  } : n;
3353
- this.host.patchRuntime(e, { messages: sr(r.messages, e, t, i) });
3362
+ this.host.patchRuntime(e, { messages: cr(r.messages, e, t, i) });
3354
3363
  let a = this.host.messageContainingTool(e, t, n.itemId);
3355
3364
  a && this.host.emitEvent("notification", {
3356
3365
  type: "tool.updated",
@@ -3386,7 +3395,7 @@ var ni = class {
3386
3395
  t.turnIds.includes(e.turn.id) || t.turnIds.push(e.turn.id);
3387
3396
  let n = t.activeTurnId !== e.turn.id && t.turnStartPending;
3388
3397
  t.activeTurnId === e.turn.id && (t.activeTurnId = null);
3389
- let r = n || t.activeTurnId !== null, i = e.turn.status === "failed" ? "error" : "complete", a = lr(t.messages, e.turn.id, e.turn.status).map((t) => t.metadata?.turnId === e.turn.id ? {
3398
+ let r = n || t.activeTurnId !== null, i = e.turn.status === "failed" ? "error" : "complete", a = ur(t.messages, e.turn.id, e.turn.status).map((t) => t.metadata?.turnId === e.turn.id ? {
3390
3399
  ...t,
3391
3400
  status: i
3392
3401
  } : t).filter((t) => !(t.role === "assistant" && t.metadata?.turnId === e.turn.id && t.kind === void 0 && t.parts.length === 0));
@@ -3398,7 +3407,7 @@ var ni = class {
3398
3407
  },
3399
3408
  turnStartPending: n,
3400
3409
  messages: a,
3401
- turns: Q(t.turns, Z(e.turn))
3410
+ turns: Z(t.turns, X(e.turn))
3402
3411
  }), this.host.patch({ conversations: this.host.getState().conversations.map((n) => n.id === e.threadId ? {
3403
3412
  ...n,
3404
3413
  status: r ? "active" : e.turn.status === "failed" ? "error" : "idle",
@@ -3412,26 +3421,26 @@ var ni = class {
3412
3421
  turnId: e.turn.id,
3413
3422
  payload: {
3414
3423
  status: e.turn.status,
3415
- error: Zr(e.turn.error),
3424
+ error: Qr(e.turn.error),
3416
3425
  willRetry: !1,
3417
- startedAt: Xr(e.turn.startedAt),
3418
- completedAt: Xr(e.turn.completedAt),
3426
+ startedAt: Zr(e.turn.startedAt),
3427
+ completedAt: Zr(e.turn.completedAt),
3419
3428
  durationMs: e.turn.durationMs ?? null
3420
3429
  }
3421
3430
  }), this.host.emitConversationActivity(e.threadId, "notification"), t.planMarkdownByTurn.delete(e.turn.id), this.host.sendNextQueuedPrompt(e.threadId);
3422
3431
  }
3423
3432
  };
3424
- function ri(e) {
3433
+ function ii(e) {
3425
3434
  if (e.fallbackToolPart?.kind === "fileChange") return !0;
3426
3435
  let t = e.input, n = e.metadata;
3427
- return ii(t) && Array.isArray(t.changes) || ii(n) && Array.isArray(n.changes);
3436
+ return ai(t) && Array.isArray(t.changes) || ai(n) && Array.isArray(n.changes);
3428
3437
  }
3429
- function ii(e) {
3438
+ function ai(e) {
3430
3439
  return typeof e == "object" && !!e;
3431
3440
  }
3432
3441
  //#endregion
3433
3442
  //#region src/node/codex-surface-client-requests-controller.ts
3434
- var ai = class {
3443
+ var oi = class {
3435
3444
  host;
3436
3445
  pending = /* @__PURE__ */ new Map();
3437
3446
  constructor(e) {
@@ -3480,12 +3489,12 @@ var ai = class {
3480
3489
  "deny"
3481
3490
  ].includes(r)) throw Error(`Invalid tool confirmation decision '${String(r)}'`);
3482
3491
  this.pending.delete(t.id);
3483
- let i = this.host.requireRuntime(n.threadId), a = dr(i.answeredClientRequestIds, t.id);
3492
+ let i = this.host.requireRuntime(n.threadId), a = fr(i.answeredClientRequestIds, t.id);
3484
3493
  if (n.kind === "ask_user") {
3485
3494
  let e = t.payload?.answers ?? {};
3486
3495
  n.responder.resolve({ answers: e }), this.host.patchRuntime(n.threadId, {
3487
3496
  answeredClientRequestIds: a,
3488
- messages: sr(i.messages, n.threadId, n.turnId, {
3497
+ messages: cr(i.messages, n.threadId, n.turnId, {
3489
3498
  itemId: n.itemId,
3490
3499
  output: { answers: e }
3491
3500
  })
@@ -3494,7 +3503,7 @@ var ai = class {
3494
3503
  let e = r;
3495
3504
  n.responder.resolve(et(e)), this.host.patchRuntime(n.threadId, {
3496
3505
  answeredClientRequestIds: a,
3497
- messages: sr(i.messages, n.threadId, n.displayTurnId, {
3506
+ messages: cr(i.messages, n.threadId, n.displayTurnId, {
3498
3507
  itemId: n.itemId,
3499
3508
  output: { decision: e }
3500
3509
  })
@@ -3533,7 +3542,7 @@ var ai = class {
3533
3542
  ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ? s[0].answer : s.map((e) => `${e.question}: ${e.answer}`).join("\n");
3534
3543
  await this.host.answerAsyncQuestion(a.runtime.threadId, e, t);
3535
3544
  }
3536
- this.host.patchRuntime(a.runtime.threadId, { answeredClientRequestIds: dr(a.runtime.answeredClientRequestIds, t.id) }), this.host.emitEvent("action", {
3545
+ this.host.patchRuntime(a.runtime.threadId, { answeredClientRequestIds: fr(a.runtime.answeredClientRequestIds, t.id) }), this.host.emitEvent("action", {
3537
3546
  type: "clientRequest.resolved",
3538
3547
  conversationId: a.runtime.threadId,
3539
3548
  ...a.request.turnId ? { turnId: a.request.turnId } : {},
@@ -3548,7 +3557,7 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
3548
3557
  let n = this.pending.get(e);
3549
3558
  if (this.pending.delete(e), n) {
3550
3559
  let t = this.host.requireRuntime(n.threadId);
3551
- this.host.patchRuntime(n.threadId, { answeredClientRequestIds: dr(t.answeredClientRequestIds, e) });
3560
+ this.host.patchRuntime(n.threadId, { answeredClientRequestIds: fr(t.answeredClientRequestIds, e) });
3552
3561
  }
3553
3562
  this.maybeClearWaitingBusy(t), n && this.host.emitEvent("notification", {
3554
3563
  type: "clientRequest.resolved",
@@ -3596,7 +3605,7 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
3596
3605
  responder: t
3597
3606
  }), this.host.patchRuntime(n, {
3598
3607
  busy: !0,
3599
- messages: G(o.messages, n, r, {
3608
+ messages: W(o.messages, n, r, {
3600
3609
  type: "tool",
3601
3610
  id: i,
3602
3611
  kind: "generic",
@@ -3695,7 +3704,7 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
3695
3704
  };
3696
3705
  this.host.patchRuntime(n.threadId, {
3697
3706
  busy: !0,
3698
- messages: G(o.messages, n.threadId, s, f)
3707
+ messages: W(o.messages, n.threadId, s, f)
3699
3708
  });
3700
3709
  let p = this.host.messageContainingTool(n.threadId, s, l);
3701
3710
  return p && this.host.emitEvent("notification", {
@@ -3713,8 +3722,8 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
3713
3722
  payload: { request: structuredClone(d) }
3714
3723
  }), this.host.emitConversationActivity(n.threadId, "notification"), !0;
3715
3724
  }
3716
- }, oi = 256 * 1024;
3717
- function si(e) {
3725
+ }, si = 256 * 1024;
3726
+ function ci(e) {
3718
3727
  return {
3719
3728
  id: e.id,
3720
3729
  model: e.model,
@@ -3739,11 +3748,11 @@ function si(e) {
3739
3748
  }
3740
3749
  };
3741
3750
  }
3742
- async function ci(e, t) {
3743
- return Promise.all(e.filter((e) => e.enabled).map((e) => li(e, t)));
3744
- }
3745
3751
  async function li(e, t) {
3746
- let n = $(e.interface?.brandColor), r = hi(e.interface?.defaultPrompt), [i, a] = await Promise.all([e.interface?.iconSmall ? t(e.interface.iconSmall) : void 0, e.interface?.iconLarge ? t(e.interface.iconLarge) : void 0]);
3752
+ return Promise.all(e.filter((e) => e.enabled).map((e) => ui(e, t)));
3753
+ }
3754
+ async function ui(e, t) {
3755
+ let n = Q(e.interface?.brandColor), r = gi(e.interface?.defaultPrompt), [i, a] = await Promise.all([e.interface?.iconSmall ? t(e.interface.iconSmall) : void 0, e.interface?.iconLarge ? t(e.interface.iconLarge) : void 0]);
3747
3756
  return {
3748
3757
  name: e.name,
3749
3758
  description: e.description,
@@ -3758,8 +3767,8 @@ async function li(e, t) {
3758
3767
  enabled: e.enabled
3759
3768
  };
3760
3769
  }
3761
- async function ui(e, t) {
3762
- let n = e.interface, r = fi(n?.composerIconUrl), i = fi(n?.logoUrl), a = fi(n?.logoUrlDark), o = $(n?.displayName) ?? e.name, s = $(n?.shortDescription), c = $(n?.longDescription), l = $(n?.brandColor), u = r ?? i ?? await di([n?.composerIcon, n?.logo], t), d = r ?? a ?? i ?? await di([
3770
+ async function di(e, t) {
3771
+ let n = e.interface, r = pi(n?.composerIconUrl), i = pi(n?.logoUrl), a = pi(n?.logoUrlDark), o = Q(n?.displayName) ?? e.name, s = Q(n?.shortDescription), c = Q(n?.longDescription), l = Q(n?.brandColor), u = r ?? i ?? await fi([n?.composerIcon, n?.logo], t), d = r ?? a ?? i ?? await fi([
3763
3772
  n?.composerIcon,
3764
3773
  n?.logoDark,
3765
3774
  n?.logo
@@ -3776,20 +3785,20 @@ async function ui(e, t) {
3776
3785
  enabled: e.enabled
3777
3786
  };
3778
3787
  }
3779
- async function di(e, t) {
3788
+ async function fi(e, t) {
3780
3789
  for (let n of e) {
3781
3790
  if (!n) continue;
3782
3791
  let e = await t(n);
3783
3792
  if (e) return e;
3784
3793
  }
3785
3794
  }
3786
- function fi(e) {
3787
- let t = $(e);
3795
+ function pi(e) {
3796
+ let t = Q(e);
3788
3797
  try {
3789
3798
  return new URL(t).protocol === "https:" ? t : void 0;
3790
3799
  } catch {}
3791
3800
  }
3792
- function pi(e) {
3801
+ function mi(e) {
3793
3802
  switch (_(e).toLowerCase()) {
3794
3803
  case ".avif": return "image/avif";
3795
3804
  case ".bmp": return "image/bmp";
@@ -3802,23 +3811,23 @@ function pi(e) {
3802
3811
  case ".webp": return "image/webp";
3803
3812
  }
3804
3813
  }
3805
- function mi(e, t) {
3814
+ function hi(e, t) {
3806
3815
  let n = t.trim();
3807
3816
  if (!/^[a-z\d+/]+={0,2}$/i.test(n)) return;
3808
3817
  let r = n.replace(/=+$/, "");
3809
3818
  if (r.length % 4 == 1) return;
3810
3819
  let i = n.length - r.length, a = (4 - r.length % 4) % 4;
3811
- if (!(i !== 0 && i !== a) && !(Math.floor(r.length * 3 / 4) > oi)) return `data:${e};base64,${`${r}${"=".repeat((4 - r.length % 4) % 4)}`}`;
3820
+ if (!(i !== 0 && i !== a) && !(Math.floor(r.length * 3 / 4) > si)) return `data:${e};base64,${`${r}${"=".repeat((4 - r.length % 4) % 4)}`}`;
3812
3821
  }
3813
- function $(e) {
3822
+ function Q(e) {
3814
3823
  return (typeof e == "string" ? e.trim() : void 0) || void 0;
3815
3824
  }
3816
- function hi(e) {
3825
+ function gi(e) {
3817
3826
  return typeof e == "string" ? e : void 0;
3818
3827
  }
3819
3828
  //#endregion
3820
3829
  //#region src/node/codex-surface-catalog-controller.ts
3821
- var gi = class {
3830
+ var _i = class {
3822
3831
  client;
3823
3832
  cwd;
3824
3833
  host;
@@ -3853,7 +3862,7 @@ var gi = class {
3853
3862
  async loadSkills(e = !1, t = "action") {
3854
3863
  e && this.iconDataUrls.clear(), this.host.patch({ skillCatalogStatus: "loading" }), this.emitSkills(this.cwd ?? null, [], "loading", t);
3855
3864
  try {
3856
- let n = await ci((await this.client.request("skills/list", {
3865
+ let n = await li((await this.client.request("skills/list", {
3857
3866
  ...this.cwd ? { cwds: [this.cwd] } : {},
3858
3867
  forceReload: e
3859
3868
  })).data.flatMap((e) => e.skills), (e) => this.iconDataUrl(e));
@@ -3870,7 +3879,7 @@ var gi = class {
3870
3879
  }
3871
3880
  async listSkills(e = {}) {
3872
3881
  await this.host.ensureConnected(), e.forceReload && this.iconDataUrls.clear();
3873
- let t = await ci((await this.client.request("skills/list", {
3882
+ let t = await li((await this.client.request("skills/list", {
3874
3883
  ...e.cwd ? { cwds: [e.cwd] } : {},
3875
3884
  forceReload: e.forceReload ?? !1
3876
3885
  })).data.flatMap((e) => e.skills), (e) => this.iconDataUrl(e));
@@ -3924,7 +3933,7 @@ var gi = class {
3924
3933
  }), (async () => ({
3925
3934
  profiles: await this.requestPermissionProfiles(e),
3926
3935
  requirements: (await this.client.request("configRequirements/read", void 0)).requirements
3927
- }))()]), a = r.status === "fulfilled" ? await ci(r.value.data.flatMap((e) => e.skills), (e) => this.iconDataUrl(e)) : [], o = i.status === "fulfilled" ? i.value.profiles : [];
3936
+ }))()]), a = r.status === "fulfilled" ? await li(r.value.data.flatMap((e) => e.skills), (e) => this.iconDataUrl(e)) : [], o = i.status === "fulfilled" ? i.value.profiles : [];
3928
3937
  return {
3929
3938
  skills: a,
3930
3939
  skillCatalogStatus: r.status === "fulfilled" ? "loaded" : "error",
@@ -3956,7 +3965,7 @@ var gi = class {
3956
3965
  cursor: n,
3957
3966
  includeHidden: e
3958
3967
  });
3959
- t.push(...r.data.map(si)), n = r.nextCursor;
3968
+ t.push(...r.data.map(ci)), n = r.nextCursor;
3960
3969
  } while (n);
3961
3970
  return t;
3962
3971
  }
@@ -4026,7 +4035,7 @@ var gi = class {
4026
4035
  try {
4027
4036
  let t = await this.client.request("plugin/installed", { ...e.length > 0 ? { cwds: [...e] } : {} }), n = /* @__PURE__ */ new Map();
4028
4037
  for (let e of t.marketplaces) for (let t of e.plugins) n.has(t.id) || n.set(t.id, t);
4029
- let r = Kt(this.host.getState().plugins, await Promise.all([...n.values()].map((e) => ui(e, (e) => this.iconDataUrl(e)))));
4038
+ let r = Kt(this.host.getState().plugins, await Promise.all([...n.values()].map((e) => di(e, (e) => this.iconDataUrl(e)))));
4030
4039
  if (this.host.isClosed() || this.host.authenticationBlocksBootstrap()) return;
4031
4040
  this.host.patch({
4032
4041
  plugins: r,
@@ -4057,9 +4066,9 @@ var gi = class {
4057
4066
  }
4058
4067
  async readIconDataUrl(e) {
4059
4068
  if (!v(e)) return;
4060
- let t = pi(e);
4069
+ let t = mi(e);
4061
4070
  if (t) try {
4062
- return mi(t, (await this.client.request("fs/readFile", { path: e })).dataBase64);
4071
+ return hi(t, (await this.client.request("fs/readFile", { path: e })).dataBase64);
4063
4072
  } catch {
4064
4073
  return;
4065
4074
  }
@@ -4067,18 +4076,18 @@ var gi = class {
4067
4076
  };
4068
4077
  //#endregion
4069
4078
  //#region src/node/codex-approvals.ts
4070
- function _i(e, t) {
4079
+ function vi(e, t) {
4071
4080
  let n = [
4072
4081
  e.onServerRequest("item/commandExecution/requestApproval", (e, n) => (t({
4073
- approval: vi(e.id, e.params),
4074
- resolve: (t, r) => n.resolve({ decision: xi(e.params, t, r) })
4082
+ approval: yi(e.id, e.params),
4083
+ resolve: (t, r) => n.resolve({ decision: Si(e.params, t, r) })
4075
4084
  }), !0)),
4076
4085
  e.onServerRequest("item/fileChange/requestApproval", (e, n) => (t({
4077
- approval: yi(e.id, e.params),
4086
+ approval: bi(e.id, e.params),
4078
4087
  resolve: (e, t) => n.resolve({ decision: e === "deny" ? "decline" : t === "session" ? "acceptForSession" : "accept" })
4079
4088
  }), !0)),
4080
4089
  e.onServerRequest("item/permissions/requestApproval", (e, n) => (t({
4081
- approval: bi(e.id, e.params),
4090
+ approval: xi(e.id, e.params),
4082
4091
  resolve: (t, r) => n.resolve({
4083
4092
  permissions: t === "deny" ? {} : {
4084
4093
  ...e.params.permissions.fileSystem ? { fileSystem: e.params.permissions.fileSystem } : {},
@@ -4116,8 +4125,8 @@ function _i(e, t) {
4116
4125
  for (let e of n) e();
4117
4126
  };
4118
4127
  }
4119
- function vi(e, t) {
4120
- let n = t.availableDecisions, r = Si(t.additionalPermissions), i = [...t.networkApprovalContext ? [{
4128
+ function yi(e, t) {
4129
+ let n = t.availableDecisions, r = Ci(t.additionalPermissions), i = [...t.networkApprovalContext ? [{
4121
4130
  kind: "network",
4122
4131
  enabled: !0,
4123
4132
  host: t.networkApprovalContext.host,
@@ -4140,7 +4149,7 @@ function vi(e, t) {
4140
4149
  } : {}
4141
4150
  };
4142
4151
  }
4143
- function yi(e, t) {
4152
+ function bi(e, t) {
4144
4153
  return {
4145
4154
  id: String(e),
4146
4155
  kind: "file-change",
@@ -4151,8 +4160,8 @@ function yi(e, t) {
4151
4160
  ...t.reason || t.grantRoot ? { description: t.reason ?? `Write under ${t.grantRoot}` } : {}
4152
4161
  };
4153
4162
  }
4154
- function bi(e, t) {
4155
- let n = Si(t.permissions);
4163
+ function xi(e, t) {
4164
+ let n = Ci(t.permissions);
4156
4165
  return {
4157
4166
  id: String(e),
4158
4167
  kind: "permissions",
@@ -4165,13 +4174,13 @@ function bi(e, t) {
4165
4174
  ...n.length ? { requestedPermissions: n } : {}
4166
4175
  };
4167
4176
  }
4168
- function xi(e, t, n) {
4177
+ function Si(e, t, n) {
4169
4178
  let r = e.availableDecisions, i = t === "deny" ? "decline" : n === "session" ? "acceptForSession" : "accept";
4170
4179
  if (!r || r.includes(i)) return i;
4171
4180
  if (t === "deny" && r.includes("cancel")) return "cancel";
4172
4181
  throw Error(`Approval decision '${t}:${n}' is not available for this command`);
4173
4182
  }
4174
- function Si(e) {
4183
+ function Ci(e) {
4175
4184
  if (!e) return [];
4176
4185
  let t = [];
4177
4186
  if (e.network && t.push({
@@ -4191,12 +4200,12 @@ function Si(e) {
4191
4200
  for (let n of e.fileSystem.entries ?? []) t.push({
4192
4201
  kind: "filesystem",
4193
4202
  access: n.access,
4194
- path: Ci(n.path)
4203
+ path: wi(n.path)
4195
4204
  });
4196
4205
  }
4197
4206
  return t;
4198
4207
  }
4199
- function Ci(e) {
4208
+ function wi(e) {
4200
4209
  if (e.type === "path") return e.path;
4201
4210
  if (e.type === "glob_pattern") return e.pattern;
4202
4211
  let t = e.value;
@@ -4211,12 +4220,12 @@ function Ci(e) {
4211
4220
  }
4212
4221
  //#endregion
4213
4222
  //#region src/node/codex-surface-approvals-controller.ts
4214
- var wi = class {
4223
+ var Ti = class {
4215
4224
  host;
4216
4225
  pending = /* @__PURE__ */ new Map();
4217
4226
  unsubscribeHandler;
4218
4227
  constructor(e, t) {
4219
- this.host = t, this.unsubscribeHandler = _i(e, (e) => this.add(e));
4228
+ this.host = t, this.unsubscribeHandler = vi(e, (e) => this.add(e));
4220
4229
  }
4221
4230
  close() {
4222
4231
  this.unsubscribeHandler(), this.pending.clear();
@@ -4297,7 +4306,7 @@ var wi = class {
4297
4306
  };
4298
4307
  //#endregion
4299
4308
  //#region src/node/codex-surface-mcp.ts
4300
- function Ti(e) {
4309
+ function Ei(e) {
4301
4310
  if (!Array.isArray(e)) throw TypeError("Codex MCP servers must be an array");
4302
4311
  let t = /* @__PURE__ */ new Set();
4303
4312
  return e.map((e, n) => {
@@ -4306,10 +4315,10 @@ function Ti(e) {
4306
4315
  if (!r || !/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(r)) throw TypeError(`Codex MCP server ${n + 1} name must match ^[A-Za-z0-9][A-Za-z0-9_-]*$`);
4307
4316
  if (t.has(r)) throw Error(`Duplicate Codex MCP server '${r}'`);
4308
4317
  t.add(r);
4309
- let i = Ei(e.transport, r), a = e.toolApprovalMode;
4318
+ let i = Di(e.transport, r), a = e.toolApprovalMode;
4310
4319
  if (a !== void 0 && a !== "auto" && a !== "prompt" && a !== "writes" && a !== "approve") throw TypeError(`Codex MCP server '${r}' tool approval mode is invalid`);
4311
4320
  if (e.required !== void 0 && typeof e.required != "boolean") throw TypeError(`Codex MCP server '${r}' required flag must be a boolean`);
4312
- let o = e.enabledTools === void 0 ? void 0 : Di(e.enabledTools, `Codex MCP server '${r}' enabled tool`), s = ki(e.startupTimeoutMs, `Codex MCP server '${r}' startup timeout`), c = ki(e.toolTimeoutMs, `Codex MCP server '${r}' tool timeout`);
4321
+ let o = e.enabledTools === void 0 ? void 0 : Oi(e.enabledTools, `Codex MCP server '${r}' enabled tool`), s = Ai(e.startupTimeoutMs, `Codex MCP server '${r}' startup timeout`), c = Ai(e.toolTimeoutMs, `Codex MCP server '${r}' tool timeout`);
4313
4322
  return {
4314
4323
  name: r,
4315
4324
  transport: i,
@@ -4321,7 +4330,7 @@ function Ti(e) {
4321
4330
  };
4322
4331
  });
4323
4332
  }
4324
- function Ei(e, t) {
4333
+ function Di(e, t) {
4325
4334
  if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError(`Codex MCP server '${t}' transport must be an object`);
4326
4335
  if (e.type === "http") {
4327
4336
  let n = e.url?.trim(), r;
@@ -4339,7 +4348,7 @@ function Ei(e, t) {
4339
4348
  if (e.type !== "stdio") throw TypeError(`Codex MCP server '${t}' transport type is invalid`);
4340
4349
  let n = e.command?.trim();
4341
4350
  if (!n) throw TypeError(`Codex MCP server '${t}' command cannot be empty`);
4342
- let r = e.args === void 0 ? void 0 : Di(e.args, `Codex MCP server '${t}' argument`), i = e.cwd?.trim();
4351
+ let r = e.args === void 0 ? void 0 : Oi(e.args, `Codex MCP server '${t}' argument`), i = e.cwd?.trim();
4343
4352
  if (i !== void 0 && (!i || !v(i))) throw TypeError(`Codex MCP server '${t}' cwd must be an absolute path`);
4344
4353
  let a;
4345
4354
  if (e.env !== void 0) {
@@ -4350,7 +4359,7 @@ function Ei(e, t) {
4350
4359
  a[n] = r;
4351
4360
  }
4352
4361
  }
4353
- let o = e.envVars === void 0 ? void 0 : Oi(e.envVars, t);
4362
+ let o = e.envVars === void 0 ? void 0 : ki(e.envVars, t);
4354
4363
  return {
4355
4364
  type: "stdio",
4356
4365
  command: n,
@@ -4360,7 +4369,7 @@ function Ei(e, t) {
4360
4369
  ...o === void 0 ? {} : { envVars: o }
4361
4370
  };
4362
4371
  }
4363
- function Di(e, t) {
4372
+ function Oi(e, t) {
4364
4373
  if (!Array.isArray(e)) throw TypeError(`${t}s must be an array`);
4365
4374
  let n = e.map((e) => {
4366
4375
  if (typeof e != "string" || !e.trim()) throw TypeError(`${t} cannot be empty`);
@@ -4368,18 +4377,18 @@ function Di(e, t) {
4368
4377
  });
4369
4378
  return [...new Set(n)];
4370
4379
  }
4371
- function Oi(e, t) {
4372
- let n = Di(e, `Codex MCP server '${t}' environment variable`);
4380
+ function ki(e, t) {
4381
+ let n = Oi(e, `Codex MCP server '${t}' environment variable`);
4373
4382
  for (let e of n) if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)) throw TypeError(`Codex MCP server '${t}' environment variable '${e}' is invalid`);
4374
4383
  return n;
4375
4384
  }
4376
- function ki(e, t) {
4385
+ function Ai(e, t) {
4377
4386
  if (e !== void 0) {
4378
4387
  if (!Number.isFinite(e) || e <= 0) throw TypeError(`${t} must be a positive finite number`);
4379
4388
  return e;
4380
4389
  }
4381
4390
  }
4382
- function Ai(e) {
4391
+ function ji(e) {
4383
4392
  let t = {};
4384
4393
  for (let n of e) {
4385
4394
  let e = n.transport.type === "http" ? { url: n.transport.url } : {
@@ -4393,7 +4402,7 @@ function Ai(e) {
4393
4402
  }
4394
4403
  return t;
4395
4404
  }
4396
- function ji(e, t) {
4405
+ function Mi(e, t) {
4397
4406
  if (t.length !== 0) for (let n of Object.keys(e)) {
4398
4407
  if (n === "mcp_servers") throw Error("Raw mcp_servers config cannot be combined with typed Codex MCP servers");
4399
4408
  for (let e of t) {
@@ -4404,13 +4413,13 @@ function ji(e, t) {
4404
4413
  }
4405
4414
  //#endregion
4406
4415
  //#region src/node/codex-surface-extensions-controller.ts
4407
- var Mi = class {
4416
+ var Ni = class {
4408
4417
  extensions;
4409
4418
  hostOptionsForThread;
4410
4419
  dynamicTools = /* @__PURE__ */ new Map();
4411
4420
  defaultMcpServers;
4412
4421
  constructor(e, t, n) {
4413
- this.extensions = e, this.hostOptionsForThread = n, this.defaultMcpServers = Ti(t);
4422
+ this.extensions = e, this.hostOptionsForThread = n, this.defaultMcpServers = Ei(t);
4414
4423
  for (let t of e) for (let e of t.dynamicTools ?? []) {
4415
4424
  let t = e.name.trim();
4416
4425
  if (!t) throw Error("Dynamic tool names cannot be empty");
@@ -4434,13 +4443,13 @@ var Mi = class {
4434
4443
  }));
4435
4444
  }
4436
4445
  async conversationExtension(e, t = {}, n = this.defaultMcpServers) {
4437
- let r = Ai(n), i = [], a;
4446
+ let r = ji(n), i = [], a;
4438
4447
  for (let t of this.extensions) {
4439
4448
  if (!t.configureConversation) continue;
4440
4449
  let o = await t.configureConversation(e);
4441
- o.config && (ji(o.config, n), Object.assign(r, o.config)), o.baseInstructions !== void 0 && (a = o.baseInstructions), o.developerInstructions?.trim() && i.push(o.developerInstructions.trim());
4450
+ o.config && (Mi(o.config, n), Object.assign(r, o.config)), o.baseInstructions !== void 0 && (a = o.baseInstructions), o.developerInstructions?.trim() && i.push(o.developerInstructions.trim());
4442
4451
  }
4443
- return t.config && (ji(t.config, n), Object.assign(r, t.config)), t.baseInstructions !== void 0 && (a = t.baseInstructions), t.developerInstructions?.trim() && i.push(t.developerInstructions.trim()), {
4452
+ return t.config && (Mi(t.config, n), Object.assign(r, t.config)), t.baseInstructions !== void 0 && (a = t.baseInstructions), t.developerInstructions?.trim() && i.push(t.developerInstructions.trim()), {
4444
4453
  ...a === void 0 ? {} : { baseInstructions: a },
4445
4454
  ...Object.keys(r).length === 0 ? {} : { config: r },
4446
4455
  ...i.length === 0 ? {} : { developerInstructions: i.join("\n\n") }
@@ -4499,7 +4508,7 @@ var Mi = class {
4499
4508
  });
4500
4509
  }
4501
4510
  }
4502
- }, Ni = 50, Pi = 25, Fi = 25, Ii = class {
4511
+ }, Pi = 50, Fi = 25, Ii = 25, Li = class {
4503
4512
  client;
4504
4513
  conversationLimit;
4505
4514
  host;
@@ -4568,7 +4577,7 @@ var Mi = class {
4568
4577
  let t = await this.client.request("thread/turns/list", {
4569
4578
  threadId: e,
4570
4579
  cursor: null,
4571
- limit: Ni,
4580
+ limit: Pi,
4572
4581
  sortDirection: "desc",
4573
4582
  itemsView: "full"
4574
4583
  });
@@ -4616,7 +4625,7 @@ var Mi = class {
4616
4625
  let i = new Set(this.host.requireRuntime(e).turnIds), a = await this.client.request("thread/turns/list", {
4617
4626
  threadId: e,
4618
4627
  cursor: t,
4619
- limit: Pi,
4628
+ limit: Fi,
4620
4629
  sortDirection: "desc",
4621
4630
  itemsView: "full"
4622
4631
  }), o = [...a.data].reverse(), s = new Set(o.map((e) => e.id).filter((e) => !i.has(e)));
@@ -4647,8 +4656,8 @@ var Mi = class {
4647
4656
  }
4648
4657
  async emitHistoryChunks(e, t) {
4649
4658
  for (let n = t.length; n > 0;) {
4650
- let r = Math.max(0, n - Fi);
4651
- this.host.emitHistoryPrepended(e, t.slice(r, n), "lifecycle"), await Li(), n = r;
4659
+ let r = Math.max(0, n - Ii);
4660
+ this.host.emitHistoryPrepended(e, t.slice(r, n), "lifecycle"), await Ri(), n = r;
4652
4661
  }
4653
4662
  }
4654
4663
  async refreshCompleteHistory(e) {
@@ -4684,10 +4693,10 @@ var Mi = class {
4684
4693
  let i = /* @__PURE__ */ new Set();
4685
4694
  r.activeTurnId && i.add(r.activeTurnId);
4686
4695
  for (let e of t) e.status === "inProgress" && r.turnIds.includes(e.id) && i.add(e.id);
4687
- let a = new Set(t.filter((e) => !i.has(e.id)).map((e) => e.id)), o = t.filter((e) => a.has(e.id)), s = r.turnIds.filter((e) => !a.has(e)), c = r.turns.filter((e) => !a.has(e.id)), l = r.messages.filter((e) => e.turnId === void 0 || !a.has(e.turnId)), u = vr(r.messages, o.flatMap((t) => yr(e, t)));
4696
+ let a = new Set(t.filter((e) => !i.has(e.id)).map((e) => e.id)), o = t.filter((e) => a.has(e.id)), s = r.turnIds.filter((e) => !a.has(e)), c = r.turns.filter((e) => !a.has(e.id)), l = r.messages.filter((e) => e.turnId === void 0 || !a.has(e.turnId)), u = yr(r.messages, o.flatMap((t) => br(e, t)));
4688
4697
  this.host.patchRuntime(e, {
4689
4698
  turnIds: [...o.map((e) => e.id), ...s],
4690
- turns: [...o.map((e) => Z(e)), ...c],
4699
+ turns: [...o.map((e) => X(e)), ...c],
4691
4700
  messages: [...u, ...l]
4692
4701
  });
4693
4702
  let d = this.host.requireRuntime(e).turnIds.length, f = this.host.getState();
@@ -4711,12 +4720,12 @@ var Mi = class {
4711
4720
  } : t;
4712
4721
  }
4713
4722
  };
4714
- function Li() {
4723
+ function Ri() {
4715
4724
  return new Promise((e) => setTimeout(e, 0));
4716
4725
  }
4717
4726
  //#endregion
4718
4727
  //#region src/node/codex-surface-conversation-settings-controller.ts
4719
- var Ri = class {
4728
+ var zi = class {
4720
4729
  client;
4721
4730
  defaults;
4722
4731
  host;
@@ -4789,7 +4798,7 @@ var Ri = class {
4789
4798
  ...n === void 0 ? {} : { tokenBudget: n }
4790
4799
  });
4791
4800
  if (a.goal.threadId !== e) throw Error(`Codex thread/goal/set returned a goal for '${a.goal.threadId}' instead of '${e}'`);
4792
- let o = !Qr(r.goal, a.goal);
4801
+ let o = !$r(r.goal, a.goal);
4793
4802
  this.host.patchRuntime(e, { goal: { ...a.goal } }), o && this.host.emitEvent("action", {
4794
4803
  type: "conversation.goalChanged",
4795
4804
  conversationId: e,
@@ -4811,7 +4820,7 @@ var Ri = class {
4811
4820
  payload: { goal: null }
4812
4821
  });
4813
4822
  }
4814
- }, zi = "Review the current code changes (staged, unstaged, and untracked files) and provide prioritized findings.", Bi = class {
4823
+ }, Bi = "Review the current code changes (staged, unstaged, and untracked files) and provide prioritized findings.", Vi = class {
4815
4824
  client;
4816
4825
  host;
4817
4826
  constructor(e, t) {
@@ -4848,22 +4857,22 @@ var Ri = class {
4848
4857
  if (i.reviewThreadId !== e) throw Error(`Codex review/start returned unexpected review thread '${i.reviewThreadId}' for inline review on thread '${e}'`);
4849
4858
  let a = n.turnIds.includes(i.turn.id);
4850
4859
  n.activeTurnId = i.turn.status === "inProgress" ? i.turn.id : null, n.turnIds.includes(i.turn.id) || n.turnIds.push(i.turn.id), this.host.patchConversationTurnCount(e, n.turnIds.length, "action");
4851
- let o = yr(e, i.turn).filter((e) => !n.messages.some((t) => t.id === e.id)).map((e) => e.role === "user" ? {
4860
+ let o = br(e, i.turn).filter((e) => !n.messages.some((t) => t.id === e.id)).map((e) => e.role === "user" ? {
4852
4861
  ...e,
4853
4862
  parts: r.type === "uncommittedChanges" ? e.parts.map((e) => e.type === "text" && e.text === "current changes" ? {
4854
4863
  ...e,
4855
- text: zi
4864
+ text: Bi
4856
4865
  } : e) : e.parts,
4857
4866
  metadata: {
4858
4867
  ...e.metadata,
4859
4868
  reviewPrompt: !0
4860
4869
  }
4861
- } : e), s = Vi(n.messages, i.turn.id, o);
4870
+ } : e), s = Hi(n.messages, i.turn.id, o);
4862
4871
  this.host.patchRuntime(e, {
4863
4872
  busy: n.activeTurnId !== null,
4864
4873
  turnStartPending: !1,
4865
- turns: Q(n.turns, Z(i.turn)),
4866
- messages: n.activeTurnId ? W(s, e, i.turn.id) : s
4874
+ turns: Z(n.turns, X(i.turn)),
4875
+ messages: n.activeTurnId ? U(s, e, i.turn.id) : s
4867
4876
  });
4868
4877
  for (let t of o) this.host.emitEvent("action", {
4869
4878
  type: "message.appended",
@@ -4875,7 +4884,7 @@ var Ri = class {
4875
4884
  type: "turn.started",
4876
4885
  conversationId: e,
4877
4886
  turnId: i.turn.id,
4878
- payload: { startedAt: Yr(i.turn.startedAt) }
4887
+ payload: { startedAt: Xr(i.turn.startedAt) }
4879
4888
  }), this.host.emitConversationActivity(e, "action");
4880
4889
  } catch (t) {
4881
4890
  throw this.host.patchRuntime(e, {
@@ -4936,28 +4945,10 @@ var Ri = class {
4936
4945
  async rollbackToTurn(e, t) {
4937
4946
  let n = await this.host.ensureThreadReady(e);
4938
4947
  if (n.busy) throw Error("Cannot roll back while Codex is responding");
4948
+ if (n.historyMode !== "paginated") throw Error("Legacy conversation history does not support deleting, editing, or retrying turns with app-server 0.164.0. Start a new conversation to use these actions.");
4939
4949
  let r = n.turnIds.indexOf(t);
4940
4950
  if (r < 0 && (await this.host.hydrateCompleteHistory(e), r = n.turnIds.indexOf(t)), r < 0) throw Error(`Cannot roll back to unknown Codex turn '${t}'`);
4941
- if (n.historyMode === "paginated") {
4942
- await this.revertPaginatedThread(e, t, r, n);
4943
- return;
4944
- }
4945
- let i = await this.client.request("thread/rollback", {
4946
- threadId: e,
4947
- numTurns: n.turnIds.length - r
4948
- });
4949
- if (i.thread.id !== e) throw Error(`Codex thread/rollback returned '${i.thread.id}' for requested thread '${e}'`);
4950
- n.turnIds = i.thread.turns.map((e) => e.id), n.turns = i.thread.turns.map((e) => Z(e)), n.activeTurnId = null;
4951
- let a = P(i.thread);
4952
- this.host.patch({ conversations: F(this.host.getState().conversations, a) }), this.host.patchRuntime(e, {
4953
- messages: vr(n.messages, gr(i.thread)),
4954
- answeredClientRequestIds: [],
4955
- busy: !1,
4956
- turnStartPending: !1,
4957
- error: null,
4958
- contextUsage: null,
4959
- turnGitDiff: null
4960
- }), this.host.emitSummaryUpserted(a, "updated", "action"), this.host.emitHistoryReplaced(e, "rollback", "action"), this.host.emitConversationActivity(e, "action");
4951
+ await this.revertPaginatedThread(e, t, r, n);
4961
4952
  }
4962
4953
  async revertPaginatedThread(e, t, n, r) {
4963
4954
  let i = await this.client.request("thread/revert", {
@@ -4993,7 +4984,7 @@ var Ri = class {
4993
4984
  return e;
4994
4985
  }
4995
4986
  };
4996
- function Vi(e, t, n) {
4987
+ function Hi(e, t, n) {
4997
4988
  let r = e.findIndex((e) => e.turnId === t);
4998
4989
  return r < 0 ? [...e, ...n] : [
4999
4990
  ...e.slice(0, r),
@@ -5003,7 +4994,7 @@ function Vi(e, t, n) {
5003
4994
  }
5004
4995
  //#endregion
5005
4996
  //#region src/node/codex-surface-messages-controller.ts
5006
- var Hi = class {
4997
+ var Ui = class {
5007
4998
  client;
5008
4999
  host;
5009
5000
  constructor(e, t) {
@@ -5090,13 +5081,13 @@ var Hi = class {
5090
5081
  this.host.patchRuntime(e, {
5091
5082
  busy: i,
5092
5083
  turnStartPending: !1,
5093
- turns: Q(t.turns, Z(n.turn)),
5094
- messages: i ? W(t.messages, e, n.turn.id) : t.messages
5084
+ turns: Z(t.turns, X(n.turn)),
5085
+ messages: i ? U(t.messages, e, n.turn.id) : t.messages
5095
5086
  }), this.host.patchConversationStatus(e, i ? "active" : "idle", "action"), i && !r && this.host.emitEvent("action", {
5096
5087
  type: "turn.started",
5097
5088
  conversationId: e,
5098
5089
  turnId: n.turn.id,
5099
- payload: { startedAt: Yr(n.turn.startedAt) }
5090
+ payload: { startedAt: Xr(n.turn.startedAt) }
5100
5091
  }), this.host.emitConversationActivity(e, "action");
5101
5092
  } catch (t) {
5102
5093
  throw this.host.patchRuntime(e, {
@@ -5112,13 +5103,13 @@ var Hi = class {
5112
5103
  let s = o ? ie(o) : r?.trim() || t, c = ct(E(ot(o), i.skills), E(a.skills ?? [], i.skills)), l = Jt(a.attachments ?? []);
5113
5104
  if (i.busy) {
5114
5105
  this.host.patchRuntime(e, { queuedPrompts: [...i.queuedPrompts, {
5115
- id: ei(),
5106
+ id: ti(),
5116
5107
  text: s,
5117
5108
  ...Object.keys(a).length > 0 ? { options: a } : {}
5118
5109
  }] }), this.emitQueuedPrompts(e);
5119
5110
  return;
5120
5111
  }
5121
- let u = $r(), d = {
5112
+ let u = ei(), d = {
5122
5113
  id: u,
5123
5114
  role: "user",
5124
5115
  status: "complete",
@@ -5176,8 +5167,8 @@ var Hi = class {
5176
5167
  this.host.patchRuntime(e, {
5177
5168
  busy: s,
5178
5169
  turnStartPending: !1,
5179
- turns: Q(i.turns, Z(n.turn)),
5180
- messages: s ? W(d, e, n.turn.id) : d
5170
+ turns: Z(i.turns, X(n.turn)),
5171
+ messages: s ? U(d, e, n.turn.id) : d
5181
5172
  }), this.host.patchConversationStatus(e, s ? "active" : "idle", "action");
5182
5173
  let f = d.find((e) => e.id === u);
5183
5174
  f && this.host.emitEvent("action", {
@@ -5189,7 +5180,7 @@ var Hi = class {
5189
5180
  type: "turn.started",
5190
5181
  conversationId: e,
5191
5182
  turnId: n.turn.id,
5192
- payload: { startedAt: Yr(n.turn.startedAt) }
5183
+ payload: { startedAt: Xr(n.turn.startedAt) }
5193
5184
  }), this.host.emitConversationActivity(e, "action");
5194
5185
  } catch (t) {
5195
5186
  throw this.host.patchRuntime(e, {
@@ -5207,7 +5198,7 @@ var Hi = class {
5207
5198
  let i = await this.host.ensureThreadReady(e), a = t.trim(), o = at(n.content), s = ct(E(ot(o), i.skills), E(n.skills ?? [], i.skills)), c = o ? ie(o) : r?.trim() || a;
5208
5199
  if (!a) throw Error("Cannot steer with an empty message");
5209
5200
  if (!i.activeTurnId) throw Error("There is no active turn to steer");
5210
- let l = Jt(n.attachments ?? []), u = $r(), d = {
5201
+ let l = Jt(n.attachments ?? []), u = ei(), d = {
5211
5202
  id: u,
5212
5203
  kind: "steer",
5213
5204
  role: "user",
@@ -5227,7 +5218,7 @@ var Hi = class {
5227
5218
  };
5228
5219
  this.host.patchRuntime(e, {
5229
5220
  error: null,
5230
- messages: W([...i.messages, d], e, i.activeTurnId, { forceSegment: !0 })
5221
+ messages: U([...i.messages, d], e, i.activeTurnId, { forceSegment: !0 })
5231
5222
  }), this.host.emitEvent("action", {
5232
5223
  type: "message.appended",
5233
5224
  conversationId: e,
@@ -5254,7 +5245,7 @@ var Hi = class {
5254
5245
  }))
5255
5246
  ]
5256
5247
  }), n = i.turnIds.includes(t.turnId);
5257
- i.activeTurnId = t.turnId, i.turnIds.includes(t.turnId) || i.turnIds.push(t.turnId), i.turns = Q(i.turns, {
5248
+ i.activeTurnId = t.turnId, i.turnIds.includes(t.turnId) || i.turnIds.push(t.turnId), i.turns = Z(i.turns, {
5258
5249
  id: t.turnId,
5259
5250
  status: "inProgress",
5260
5251
  error: null,
@@ -5271,7 +5262,7 @@ var Hi = class {
5271
5262
  turnId: t.turnId
5272
5263
  }
5273
5264
  } : e);
5274
- this.host.patchRuntime(e, { messages: K(W(r, e, t.turnId), e) }), n || this.host.emitEvent("action", {
5265
+ this.host.patchRuntime(e, { messages: G(U(r, e, t.turnId), e) }), n || this.host.emitEvent("action", {
5275
5266
  type: "turn.started",
5276
5267
  conversationId: e,
5277
5268
  turnId: t.turnId,
@@ -5364,7 +5355,7 @@ var Hi = class {
5364
5355
  if (!e) throw Error("There is no active conversation");
5365
5356
  return e;
5366
5357
  }
5367
- }, Ui = 5, Wi = class {
5358
+ }, Wi = 5, Gi = class {
5368
5359
  client;
5369
5360
  options;
5370
5361
  catalog;
@@ -5404,7 +5395,7 @@ var Hi = class {
5404
5395
  ...a ? { approvalPreset: a } : {}
5405
5396
  }, r.approvalPresets), s = A(i.models, i.selectedModelId), c = e.model ? Pt(i.models, e.model) : s, l = c?.model, u = e.reasoningEffort ?? (c?.id === s?.id ? i.selectedReasoningEffort : c ? j(c) : null) ?? void 0, d = e.serviceTier === void 0 ? c?.id === s?.id ? i.selectedServiceTier ?? null : c?.defaultServiceTier ?? null : e.serviceTier;
5406
5397
  Ft(c, u), M(c, d);
5407
- let f = t.mcpServers === void 0 ? this.extensions.defaultMcpServers : Ti(t.mcpServers), p = await this.extensions.conversationExtension({
5398
+ let f = t.mcpServers === void 0 ? this.extensions.defaultMcpServers : Ei(t.mcpServers), p = await this.extensions.conversationExtension({
5408
5399
  operation: "start",
5409
5400
  conversationId: null,
5410
5401
  cwd: n,
@@ -5521,7 +5512,7 @@ var Hi = class {
5521
5512
  ...n
5522
5513
  }, a = {
5523
5514
  ...i,
5524
- mcpServers: i.mcpServers === void 0 ? this.extensions.defaultMcpServers : Ti(i.mcpServers)
5515
+ mcpServers: i.mcpServers === void 0 ? this.extensions.defaultMcpServers : Ei(i.mcpServers)
5525
5516
  };
5526
5517
  this.hostOptionsByThread.set(e, a);
5527
5518
  let o = await this.extensions.conversationExtension({
@@ -5539,7 +5530,7 @@ var Hi = class {
5539
5530
  threadId: e,
5540
5531
  excludeTurns: !0,
5541
5532
  initialTurnsPage: {
5542
- limit: Ui,
5533
+ limit: Wi,
5543
5534
  sortDirection: "desc",
5544
5535
  itemsView: "full"
5545
5536
  },
@@ -5552,20 +5543,20 @@ var Hi = class {
5552
5543
  let i = t.initialTurnsPage ?? await this.client.request("thread/turns/list", {
5553
5544
  threadId: t.thread.id,
5554
5545
  cursor: null,
5555
- limit: Ui,
5546
+ limit: Wi,
5556
5547
  sortDirection: "desc",
5557
5548
  itemsView: "full"
5558
5549
  }), d = [...i.data].reverse(), f = t.cwd ?? t.thread.cwd ?? a.cwd, p = await this.catalog.loadConversationCatalogs(f), m = s.turns.filter((e) => c.get(e.id) !== e), h = s.threadStatus !== u && s.threadStatus ? s.threadStatus : I(t.thread.status), g = d.map((e) => h.type === "idle" && e.status === "inProgress" ? {
5559
5550
  ...e,
5560
5551
  status: "interrupted"
5561
- } : e), _ = new Map(g.map((e) => [e.id, Z(e)]));
5552
+ } : e), _ = new Map(g.map((e) => [e.id, X(e)]));
5562
5553
  for (let e of m) _.set(e.id, e);
5563
- let v = m.length > 0 ? s.activeTurnId : h.type === "active" ? Qn(d) : null, y = vr(s.messages, gr({
5554
+ let v = m.length > 0 ? s.activeTurnId : h.type === "active" ? $n(d) : null, y = yr(s.messages, _r({
5564
5555
  ...t.thread,
5565
5556
  turns: g
5566
5557
  })), b = new Map(y.map((e) => [e.id, e]));
5567
5558
  for (let e of s.messages) l.get(e.id) !== e && b.set(e.id, e);
5568
- let x = v ? W([...b.values()], t.thread.id, v) : [...b.values()], S = this.host.createRuntime(t.thread.id, {
5559
+ let x = v ? U([...b.values()], t.thread.id, v) : [...b.values()], S = this.host.createRuntime(t.thread.id, {
5569
5560
  hydrated: !0,
5570
5561
  historyMode: t.thread.historyMode ?? "legacy",
5571
5562
  loadingStrategy: a.loadingStrategy ?? this.options.loadingStrategy ?? "lazy",
@@ -5612,7 +5603,7 @@ var Hi = class {
5612
5603
  threadStatus: structuredClone(t.threadStatus)
5613
5604
  };
5614
5605
  }
5615
- }, Gi = class {
5606
+ }, Ki = class {
5616
5607
  authentication;
5617
5608
  approvals;
5618
5609
  catalog;
@@ -5694,7 +5685,7 @@ var Hi = class {
5694
5685
  return;
5695
5686
  }
5696
5687
  case "thread/goal/updated":
5697
- if (Qr(this.host.requireRuntime(e.params.threadId).goal, e.params.goal)) return;
5688
+ if ($r(this.host.requireRuntime(e.params.threadId).goal, e.params.goal)) return;
5698
5689
  this.host.patchRuntime(e.params.threadId, { goal: { ...e.params.goal } }), this.host.emitEvent("notification", {
5699
5690
  type: "conversation.goalChanged",
5700
5691
  conversationId: e.params.threadId,
@@ -5750,13 +5741,13 @@ var Hi = class {
5750
5741
  turnStartPending: !1,
5751
5742
  error: null,
5752
5743
  turnGitDiff: null,
5753
- turns: Q(t.turns, Z(e.params.turn)),
5754
- messages: W(t.messages, e.params.threadId, e.params.turn.id, { createdAt: Yr(e.params.turn.startedAt) })
5744
+ turns: Z(t.turns, X(e.params.turn)),
5745
+ messages: U(t.messages, e.params.threadId, e.params.turn.id, { createdAt: Xr(e.params.turn.startedAt) })
5755
5746
  }), this.host.patchConversationStatus(e.params.threadId, "active"), n || this.host.emitEvent("notification", {
5756
5747
  type: "turn.started",
5757
5748
  conversationId: e.params.threadId,
5758
5749
  turnId: e.params.turn.id,
5759
- payload: { startedAt: Yr(e.params.turn.startedAt) }
5750
+ payload: { startedAt: Xr(e.params.turn.startedAt) }
5760
5751
  }), this.host.emitConversationActivity(e.params.threadId, "notification");
5761
5752
  return;
5762
5753
  }
@@ -5808,7 +5799,7 @@ var Hi = class {
5808
5799
  }
5809
5800
  case "thread/compacted": {
5810
5801
  let t = this.host.requireRuntime(e.params.threadId);
5811
- this.host.patchRuntime(e.params.threadId, { messages: cr(t.messages, e.params.threadId, e.params.turnId, "complete") });
5802
+ this.host.patchRuntime(e.params.threadId, { messages: lr(t.messages, e.params.threadId, e.params.turnId, "complete") });
5812
5803
  let n = this.host.requireRuntime(e.params.threadId).messages.find((t) => t.kind === "compaction" && t.metadata?.turnId === e.params.turnId);
5813
5804
  this.host.emitEvent("notification", {
5814
5805
  type: "context.compactionCompleted",
@@ -5828,7 +5819,7 @@ var Hi = class {
5828
5819
  let t = this.host.requireRuntime(e.params.threadId), n = !e.params.willRetry && t.activeTurnId === e.params.turnId;
5829
5820
  n && (t.activeTurnId = null), this.host.patchRuntime(e.params.threadId, {
5830
5821
  error: e.params.error.message,
5831
- turns: Q(t.turns, {
5822
+ turns: Z(t.turns, {
5832
5823
  ...t.turns.find((t) => t.id === e.params.turnId) ?? {
5833
5824
  id: e.params.turnId,
5834
5825
  status: "inProgress",
@@ -5837,7 +5828,7 @@ var Hi = class {
5837
5828
  durationMs: null
5838
5829
  },
5839
5830
  status: e.params.willRetry ? "inProgress" : "failed",
5840
- error: Zr(e.params.error),
5831
+ error: Qr(e.params.error),
5841
5832
  willRetry: e.params.willRetry
5842
5833
  }),
5843
5834
  ...n ? {
@@ -5849,7 +5840,7 @@ var Hi = class {
5849
5840
  conversationId: e.params.threadId,
5850
5841
  turnId: e.params.turnId,
5851
5842
  payload: {
5852
- error: Zr(e.params.error),
5843
+ error: Qr(e.params.error),
5853
5844
  willRetry: e.params.willRetry
5854
5845
  }
5855
5846
  }), this.host.emitConversationActivity(e.params.threadId, "notification");
@@ -5995,7 +5986,7 @@ var Hi = class {
5995
5986
  default: return this.host.unknownNotification(e);
5996
5987
  }
5997
5988
  }
5998
- }, Ki = class {
5989
+ }, qi = class {
5999
5990
  approvals;
6000
5991
  clientRequests;
6001
5992
  host;
@@ -6056,7 +6047,7 @@ var Hi = class {
6056
6047
  conversationId: e,
6057
6048
  payload: {
6058
6049
  historyLoading: n.historyLoading,
6059
- historyState: Yi(n),
6050
+ historyState: Xi(n),
6060
6051
  error: n.error
6061
6052
  }
6062
6053
  });
@@ -6150,7 +6141,7 @@ var Hi = class {
6150
6141
  reason: t,
6151
6142
  messages: structuredClone(r.messages),
6152
6143
  threadStatus: structuredClone(r.threadStatus),
6153
- state: qi(r)
6144
+ state: Ji(r)
6154
6145
  }
6155
6146
  });
6156
6147
  }
@@ -6162,7 +6153,7 @@ var Hi = class {
6162
6153
  conversationId: e,
6163
6154
  payload: {
6164
6155
  messages: structuredClone(t.map((e) => r.get(e.id) ?? e)),
6165
- state: Ji(this.require(e))
6156
+ state: Yi(this.require(e))
6166
6157
  }
6167
6158
  });
6168
6159
  }
@@ -6173,7 +6164,7 @@ var Hi = class {
6173
6164
  return [...this.require(e).messages].reverse().find((e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === t) ?? null;
6174
6165
  }
6175
6166
  markTurnActive(e, t) {
6176
- e.activeTurnId = t, e.busy = !0, e.turnStartPending = !1, e.turnIds.includes(t) || e.turnIds.push(t), e.turns = Q(e.turns, {
6167
+ e.activeTurnId = t, e.busy = !0, e.turnStartPending = !1, e.turnIds.includes(t) || e.turnIds.push(t), e.turns = Z(e.turns, {
6177
6168
  id: t,
6178
6169
  status: "inProgress",
6179
6170
  error: null,
@@ -6204,7 +6195,7 @@ var Hi = class {
6204
6195
  i && this.emitSummaryUpserted(i, "updated", n);
6205
6196
  }
6206
6197
  };
6207
- function qi(e) {
6198
+ function Ji(e) {
6208
6199
  return structuredClone({
6209
6200
  activeTurnId: e.activeTurnId,
6210
6201
  answeredClientRequestIds: e.answeredClientRequestIds,
@@ -6213,21 +6204,21 @@ function qi(e) {
6213
6204
  error: e.error,
6214
6205
  executionPlan: e.executionPlan,
6215
6206
  historyLoading: e.historyLoading,
6216
- historyState: Yi(e),
6207
+ historyState: Xi(e),
6217
6208
  turnGitDiff: e.turnGitDiff,
6218
6209
  turnIds: e.turnIds,
6219
6210
  turns: e.turns
6220
6211
  });
6221
6212
  }
6222
- function Ji(e) {
6213
+ function Yi(e) {
6223
6214
  return structuredClone({
6224
6215
  historyLoading: e.historyLoading,
6225
- historyState: Yi(e),
6216
+ historyState: Xi(e),
6226
6217
  turnIds: e.turnIds,
6227
6218
  turns: e.turns
6228
6219
  });
6229
6220
  }
6230
- function Yi(e) {
6221
+ function Xi(e) {
6231
6222
  return {
6232
6223
  loadingStrategy: e.loadingStrategy,
6233
6224
  hasOlder: e.historyHasOlder,
@@ -6237,7 +6228,7 @@ function Yi(e) {
6237
6228
  }
6238
6229
  //#endregion
6239
6230
  //#region src/node/codex-surface-connection-controller.ts
6240
- var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_request_user_input"]), Zi = class {
6231
+ var Zi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_request_user_input"]), Qi = class {
6241
6232
  client;
6242
6233
  options;
6243
6234
  authentication;
@@ -6300,7 +6291,7 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
6300
6291
  limit: 100,
6301
6292
  threadId: null
6302
6293
  });
6303
- for (let e of n.data) Xi.has(e.name) && !e.enabled && (t[e.name] = !0);
6294
+ for (let e of n.data) Zi.has(e.name) && !e.enabled && (t[e.name] = !0);
6304
6295
  e = n.nextCursor;
6305
6296
  } while (e);
6306
6297
  Object.keys(t).length > 0 && await this.client.request("experimentalFeature/enablement/set", { enablement: t });
@@ -6434,7 +6425,7 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
6434
6425
  error: null
6435
6426
  });
6436
6427
  }
6437
- }, Qi = 5, $i = class {
6428
+ }, $i = 5, ea = class {
6438
6429
  client;
6439
6430
  loadingStrategy;
6440
6431
  catalog;
@@ -6448,7 +6439,7 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
6448
6439
  if ((i.busy || i.activeTurnId) && !r.beforeTurnId && (!r.lastTurnId || r.lastTurnId === i.activeTurnId)) throw Error("Cannot fork a conversation while its current turn is still active");
6449
6440
  let a = t.cwd ?? i.cwd ?? n.cwd, o = await this.catalog.loadConversationCatalogs(a ?? void 0), s = this.host.getState(), c = t.model ? Pt(s.models, t.model) : A(s.models, i.selectedModelId);
6450
6441
  Ft(c, t.reasoningEffort), M(c, t.serviceTier);
6451
- let l = n.mcpServers === void 0 ? this.extensions.defaultMcpServers : Ti(n.mcpServers), u = await this.extensions.conversationExtension({
6442
+ let l = n.mcpServers === void 0 ? this.extensions.defaultMcpServers : Ei(n.mcpServers), u = await this.extensions.conversationExtension({
6452
6443
  operation: "start",
6453
6444
  conversationId: null,
6454
6445
  cwd: a ?? void 0,
@@ -6466,7 +6457,7 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
6466
6457
  ...u.baseInstructions === void 0 ? {} : { baseInstructions: u.baseInstructions },
6467
6458
  ...u.developerInstructions === void 0 ? {} : { developerInstructions: u.developerInstructions },
6468
6459
  ...u.config === void 0 ? {} : { config: u.config },
6469
- ...ea(t, o.approvalPresets)
6460
+ ...ta(t, o.approvalPresets)
6470
6461
  });
6471
6462
  if (!d.thread.id || d.thread.id === e) throw Error(`Codex thread/fork returned an invalid new thread id '${d.thread.id}'`);
6472
6463
  t.reasoningEffort && await this.client.request("thread/settings/update", {
@@ -6477,13 +6468,13 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
6477
6468
  let [f, p] = await Promise.all([this.client.request("thread/turns/list", {
6478
6469
  threadId: d.thread.id,
6479
6470
  cursor: null,
6480
- limit: Qi,
6471
+ limit: $i,
6481
6472
  sortDirection: "desc",
6482
6473
  itemsView: "full"
6483
- }), this.client.request("thread/goal/get", { threadId: d.thread.id }).then((e) => e.goal).catch(() => null)]), m = [...f.data].reverse(), h = Qn(m), g = gr({
6474
+ }), this.client.request("thread/goal/get", { threadId: d.thread.id }).then((e) => e.goal).catch(() => null)]), m = [...f.data].reverse(), h = $n(m), g = _r({
6484
6475
  ...d.thread,
6485
6476
  turns: m
6486
- }), _ = h ? W(g, d.thread.id, h) : g, v = n.loadingStrategy ?? this.loadingStrategy ?? "lazy", y = this.host.createRuntime(d.thread.id, {
6477
+ }), _ = h ? U(g, d.thread.id, h) : g, v = n.loadingStrategy ?? this.loadingStrategy ?? "lazy", y = this.host.createRuntime(d.thread.id, {
6487
6478
  hydrated: !0,
6488
6479
  historyMode: d.thread.historyMode ?? "legacy",
6489
6480
  loadingStrategy: v,
@@ -6493,7 +6484,7 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
6493
6484
  fullHistoryHydrated: f.nextCursor === null,
6494
6485
  cwd: d.cwd ?? d.thread.cwd ?? a ?? null,
6495
6486
  activeTurnId: h,
6496
- turns: m.map((e) => Z(e)),
6487
+ turns: m.map((e) => X(e)),
6497
6488
  turnIds: m.map((e) => e.id),
6498
6489
  messages: _,
6499
6490
  busy: !!h,
@@ -6519,7 +6510,7 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
6519
6510
  return this.fork(e, n, r, { lastTurnId: t });
6520
6511
  }
6521
6512
  };
6522
- function ea(e, t) {
6513
+ function ta(e, t) {
6523
6514
  if (e.approvalPreset) {
6524
6515
  if (!t.includes(e.approvalPreset)) throw Error(`Approval preset '${e.approvalPreset}' is not available`);
6525
6516
  return Rt(e.approvalPreset);
@@ -6531,27 +6522,27 @@ function ea(e, t) {
6531
6522
  }
6532
6523
  //#endregion
6533
6524
  //#region src/node/codex-markdown-images.ts
6534
- var ta = /(?<!\[)!\[([^\]]*)\]\(([^)\s]+)(?:\s+["']([^"']*)["'])?\)/g, na = /* @__PURE__ */ new Set([
6525
+ var na = /(?<!\[)!\[([^\]]*)\]\(([^)\s]+)(?:\s+["']([^"']*)["'])?\)/g, ra = /* @__PURE__ */ new Set([
6535
6526
  ".avif",
6536
6527
  ".gif",
6537
6528
  ".jpeg",
6538
6529
  ".jpg",
6539
6530
  ".png",
6540
6531
  ".webp"
6541
- ]), ra = class {
6532
+ ]), ia = class {
6542
6533
  client;
6543
6534
  constructor(e) {
6544
6535
  this.client = e;
6545
6536
  }
6546
6537
  async hydrate(e, t) {
6547
- let n = oa(e);
6548
- return aa(e, (await Promise.all(Array.from(e.matchAll(ta), async (e) => {
6538
+ let n = sa(e);
6539
+ return oa(e, (await Promise.all(Array.from(e.matchAll(na), async (e) => {
6549
6540
  let r = e.index ?? 0;
6550
- if (sa(r, n)) return null;
6551
- let i = e[2], a = ia(i, t);
6541
+ if (ca(r, n)) return null;
6542
+ let i = e[2], a = aa(i, t);
6552
6543
  if (!a) return null;
6553
6544
  try {
6554
- let t = Mr((await this.client.request("fs/readFile", { path: a })).dataBase64);
6545
+ let t = Nr((await this.client.request("fs/readFile", { path: a })).dataBase64);
6555
6546
  if (!t) return null;
6556
6547
  let n = e[0].indexOf("](") + 2;
6557
6548
  return {
@@ -6565,7 +6556,7 @@ var ta = /(?<!\[)!\[([^\]]*)\]\(([^)\s]+)(?:\s+["']([^"']*)["'])?\)/g, na = /* @
6565
6556
  }))).filter((e) => e !== null));
6566
6557
  }
6567
6558
  };
6568
- function ia(e, t) {
6559
+ function aa(e, t) {
6569
6560
  let n = e.trim();
6570
6561
  if (!n || /[\u0000-\u001f\u007f]/.test(n)) return null;
6571
6562
  let r;
@@ -6580,18 +6571,18 @@ function ia(e, t) {
6580
6571
  } catch {
6581
6572
  return null;
6582
6573
  }
6583
- if (!na.has(_(r).toLowerCase())) return null;
6574
+ if (!ra.has(_(r).toLowerCase())) return null;
6584
6575
  if (v(r)) return r;
6585
6576
  if (!t || !v(t)) return null;
6586
6577
  let i = x(t, r), a = b(t, i);
6587
6578
  return a === ".." || a.startsWith(`..${S}`) || v(a) ? null : i;
6588
6579
  }
6589
- function aa(e, t) {
6580
+ function oa(e, t) {
6590
6581
  let n = e;
6591
6582
  for (let e of t.sort((e, t) => t.start - e.start)) n = `${n.slice(0, e.start)}${e.value}${n.slice(e.end)}`;
6592
6583
  return n;
6593
6584
  }
6594
- function oa(e) {
6585
+ function sa(e) {
6595
6586
  let t = [], n = /(^|\n)(```|~~~)/g, r;
6596
6587
  for (; (r = n.exec(e)) !== null;) {
6597
6588
  let i = r[2], a = r[1], o = r.index + a.length, s = RegExp(`(^|\\n)${i}`, "g");
@@ -6612,15 +6603,15 @@ function oa(e) {
6612
6603
  }
6613
6604
  return t;
6614
6605
  }
6615
- function sa(e, t) {
6606
+ function ca(e, t) {
6616
6607
  return t.some((t) => e >= t.start && e <= t.end);
6617
6608
  }
6618
- var ca = /<context>[\s\S]*?<\/context>\s*/g, la = /<in-app-browser-context(?:\s[^>]*)?>[\s\S]*?<\/in-app-browser-context>\s*/g, ua = /^[ \t]*## My request for Codex:[ \t]*$/m;
6619
- async function da(e, t) {
6609
+ var la = /<context>[\s\S]*?<\/context>\s*/g, ua = /<in-app-browser-context(?:\s[^>]*)?>[\s\S]*?<\/in-app-browser-context>\s*/g, da = /^[ \t]*## My request for Codex:[ \t]*$/m;
6610
+ async function fa(e, t) {
6620
6611
  let n = O(t);
6621
6612
  return {
6622
6613
  conversationId: n,
6623
- prompts: fa((await e.request("thread/turns/list", {
6614
+ prompts: pa((await e.request("thread/turns/list", {
6624
6615
  threadId: n,
6625
6616
  cursor: null,
6626
6617
  limit: 100,
@@ -6629,20 +6620,20 @@ async function da(e, t) {
6629
6620
  })).data)
6630
6621
  };
6631
6622
  }
6632
- function fa(e) {
6623
+ function pa(e) {
6633
6624
  return [...e].reverse().flatMap((e) => e.items.flatMap((e) => {
6634
6625
  if (e.type !== "userMessage") return [];
6635
- let t = pa(e.content.flatMap((e) => e.type === "text" ? [e.text] : []).join(""));
6626
+ let t = ma(e.content.flatMap((e) => e.type === "text" ? [e.text] : []).join(""));
6636
6627
  return t && t !== "(no user instructions)" ? [t] : [];
6637
6628
  }));
6638
6629
  }
6639
- function pa(e) {
6640
- let t = e.replace(ca, ""), n = t.replace(la, "");
6641
- return (n === t ? n : n.replace(ua, "")).trim();
6630
+ function ma(e) {
6631
+ let t = e.replace(la, ""), n = t.replace(ua, "");
6632
+ return (n === t ? n : n.replace(da, "")).trim();
6642
6633
  }
6643
6634
  //#endregion
6644
6635
  //#region src/node/codex-surface-text-generation-controller.ts
6645
- var ma = 12e4, ha = class {
6636
+ var ha = 12e4, ga = class {
6646
6637
  client;
6647
6638
  defaultCwd;
6648
6639
  host;
@@ -6653,7 +6644,7 @@ var ma = 12e4, ha = class {
6653
6644
  }
6654
6645
  handleNotification(e) {
6655
6646
  e.method === "thread/started" && e.params.thread.ephemeral && this.hiddenThreadIds.add(e.params.thread.id);
6656
- let t = ya(e);
6647
+ let t = ba(e);
6657
6648
  if (!t || !this.hiddenThreadIds.has(t)) return !1;
6658
6649
  let n = this.pendingByThread.get(t);
6659
6650
  return n && this.consumeNotification(n, e), (e.method === "thread/closed" || e.method === "thread/deleted") && this.hiddenThreadIds.delete(t), !0;
@@ -6661,7 +6652,7 @@ var ma = 12e4, ha = class {
6661
6652
  async generate(e, t = {}) {
6662
6653
  let n = e.trim();
6663
6654
  if (!n) throw Error("Generation prompt cannot be empty");
6664
- if (t.signal?.aborted) throw ba();
6655
+ if (t.signal?.aborted) throw xa();
6665
6656
  await this.host.ensureConnected();
6666
6657
  let r = this.host.getSnapshot(), i = A(r.models, r.selectedModelId), a = t.model ? Pt(r.models, t.model) : i, o = a?.model, s = t.reasoningEffort ?? (a?.id === i?.id ? r.selectedReasoningEffort : a ? j(a) : null) ?? void 0, c = t.serviceTier === void 0 ? a?.id === i?.id ? r.selectedServiceTier : a?.defaultServiceTier ?? null : t.serviceTier;
6667
6658
  Ft(a, s), M(a, c);
@@ -6680,15 +6671,15 @@ var ma = 12e4, ha = class {
6680
6671
  serviceName: "codex_app_sdk",
6681
6672
  threadSource: "sdk_ephemeral_generation"
6682
6673
  }), u = l.thread.id;
6683
- if (!l.thread.ephemeral) throw await ga(() => this.client.request("thread/delete", { threadId: u })), Error("Codex app-server did not create an ephemeral generation thread");
6684
- if (this.hiddenThreadIds.add(u), t.signal?.aborted) throw await ga(() => this.client.request("thread/unsubscribe", { threadId: u })), this.hiddenThreadIds.delete(u), ba();
6685
- let d = _a();
6674
+ if (!l.thread.ephemeral) throw await _a(() => this.client.request("thread/delete", { threadId: u })), Error("Codex app-server did not create an ephemeral generation thread");
6675
+ if (this.hiddenThreadIds.add(u), t.signal?.aborted) throw await _a(() => this.client.request("thread/unsubscribe", { threadId: u })), this.hiddenThreadIds.delete(u), xa();
6676
+ let d = va();
6686
6677
  this.pendingByThread.set(u, d);
6687
- let f = null, p = !1, m = () => d.reject(ba());
6678
+ let f = null, p = !1, m = () => d.reject(xa());
6688
6679
  t.signal?.addEventListener("abort", m);
6689
6680
  let h = setTimeout(() => {
6690
6681
  d.reject(/* @__PURE__ */ Error("Codex ephemeral generation timed out"));
6691
- }, t.timeoutMs ?? ma);
6682
+ }, t.timeoutMs ?? ha);
6692
6683
  try {
6693
6684
  let e = await this.client.request("turn/start", {
6694
6685
  threadId: u,
@@ -6704,18 +6695,18 @@ var ma = 12e4, ha = class {
6704
6695
  serviceTier: c,
6705
6696
  ...t.outputSchema === void 0 ? {} : { outputSchema: t.outputSchema }
6706
6697
  });
6707
- f = e.turn.id, d.turnId = f, va(d, e.turn);
6698
+ f = e.turn.id, d.turnId = f, ya(d, e.turn);
6708
6699
  let r = await d.promise;
6709
6700
  return p = !0, r;
6710
6701
  } finally {
6711
6702
  if (clearTimeout(h), t.signal?.removeEventListener("abort", m), this.pendingByThread.delete(u), !p && f) {
6712
6703
  let e = f;
6713
- await ga(() => this.client.request("turn/interrupt", {
6704
+ await _a(() => this.client.request("turn/interrupt", {
6714
6705
  threadId: u,
6715
6706
  turnId: e
6716
6707
  }));
6717
6708
  }
6718
- await ga(() => this.client.request("thread/unsubscribe", { threadId: u })), this.hiddenThreadIds.delete(u);
6709
+ await _a(() => this.client.request("thread/unsubscribe", { threadId: u })), this.hiddenThreadIds.delete(u);
6719
6710
  }
6720
6711
  }
6721
6712
  close(e = /* @__PURE__ */ Error("Codex surface closed")) {
@@ -6738,16 +6729,16 @@ var ma = 12e4, ha = class {
6738
6729
  }
6739
6730
  if (t.method === "turn/completed") {
6740
6731
  if (e.turnId && t.params.turn.id !== e.turnId) return;
6741
- va(e, t.params.turn);
6732
+ ya(e, t.params.turn);
6742
6733
  }
6743
6734
  }
6744
6735
  };
6745
- async function ga(e) {
6736
+ async function _a(e) {
6746
6737
  try {
6747
6738
  await e();
6748
6739
  } catch {}
6749
6740
  }
6750
- function _a() {
6741
+ function va() {
6751
6742
  let e, t, n = {
6752
6743
  promise: new Promise((n, r) => {
6753
6744
  e = n, t = r;
@@ -6763,7 +6754,7 @@ function _a() {
6763
6754
  };
6764
6755
  return n.promise.catch(() => void 0), n;
6765
6756
  }
6766
- function va(e, t) {
6757
+ function ya(e, t) {
6767
6758
  for (let n of t.items) {
6768
6759
  if (n.type !== "agentMessage") continue;
6769
6760
  let t = n.text.trim();
@@ -6785,17 +6776,17 @@ function va(e, t) {
6785
6776
  }
6786
6777
  e.resolve({ text: n });
6787
6778
  }
6788
- function ya(e) {
6779
+ function ba(e) {
6789
6780
  if (e.method === "thread/started") return e.params.thread.id;
6790
6781
  let t = e.params;
6791
6782
  return typeof t.threadId == "string" ? t.threadId : null;
6792
6783
  }
6793
- function ba() {
6784
+ function xa() {
6794
6785
  return /* @__PURE__ */ Error("Codex ephemeral generation was aborted");
6795
6786
  }
6796
6787
  //#endregion
6797
6788
  //#region src/node/codex-surface-usage-controller.ts
6798
- var xa = {
6789
+ var Sa = {
6799
6790
  status: "unavailable",
6800
6791
  reason: "public-runtime-request-evidence-unavailable",
6801
6792
  unavailableFields: [
@@ -6813,7 +6804,7 @@ var xa = {
6813
6804
  "finality"
6814
6805
  ],
6815
6806
  requests: null
6816
- }, Sa = class {
6807
+ }, Ca = class {
6817
6808
  threads = /* @__PURE__ */ new Map();
6818
6809
  clear() {
6819
6810
  this.threads.clear();
@@ -6855,16 +6846,16 @@ var xa = {
6855
6846
  let e = r.executions.get(r.activeTurnId);
6856
6847
  e && (e.baseline = null), i && (i.baseline = null);
6857
6848
  }
6858
- i && (!wa(a.total) || i.latest && !Ta(i.latest.total, a.total)) && (i.baseline = null);
6849
+ i && (!$(a.total) || i.latest && !Ta(i.latest.total, a.total)) && (i.baseline = null);
6859
6850
  let s = i?.baseline ? Ea(i.baseline, a.total) : null;
6860
6851
  i && s === null && (i.baseline = null);
6861
6852
  let c = {
6862
6853
  ...a,
6863
6854
  execution: s,
6864
6855
  observedStart: !!i,
6865
- requestUsage: structuredClone(xa)
6856
+ requestUsage: structuredClone(Sa)
6866
6857
  };
6867
- return i && (i.latest = structuredClone(c)), r.total = !o && wa(a.total) ? structuredClone(a.total) : null, r.lastUsageTurnId = t.turnId, {
6858
+ return i && (i.latest = structuredClone(c)), r.total = !o && $(a.total) ? structuredClone(a.total) : null, r.lastUsageTurnId = t.turnId, {
6868
6859
  ...t,
6869
6860
  payload: { usage: c }
6870
6861
  };
@@ -6878,21 +6869,21 @@ var xa = {
6878
6869
  executions: /* @__PURE__ */ new Map()
6879
6870
  }, this.threads.set(e, t)), t;
6880
6871
  }
6881
- }, Ca = [
6872
+ }, wa = [
6882
6873
  "totalTokens",
6883
6874
  "inputTokens",
6884
6875
  "cachedInputTokens",
6885
6876
  "outputTokens",
6886
6877
  "reasoningOutputTokens"
6887
6878
  ];
6888
- function wa(e) {
6889
- return Ca.every((t) => Number.isSafeInteger(e[t]) && e[t] >= 0) && (e.cacheWriteInputTokens === null || Number.isSafeInteger(e.cacheWriteInputTokens) && e.cacheWriteInputTokens >= 0) && e.totalTokens === e.inputTokens + e.outputTokens && e.cachedInputTokens <= e.inputTokens && e.reasoningOutputTokens <= e.outputTokens;
6879
+ function $(e) {
6880
+ return wa.every((t) => Number.isSafeInteger(e[t]) && e[t] >= 0) && (e.cacheWriteInputTokens === null || Number.isSafeInteger(e.cacheWriteInputTokens) && e.cacheWriteInputTokens >= 0) && e.totalTokens === e.inputTokens + e.outputTokens && e.cachedInputTokens <= e.inputTokens && e.reasoningOutputTokens <= e.outputTokens;
6890
6881
  }
6891
6882
  function Ta(e, t) {
6892
- return Ca.every((n) => t[n] >= e[n]) && (e.cacheWriteInputTokens === null || t.cacheWriteInputTokens === null || t.cacheWriteInputTokens >= e.cacheWriteInputTokens);
6883
+ return wa.every((n) => t[n] >= e[n]) && (e.cacheWriteInputTokens === null || t.cacheWriteInputTokens === null || t.cacheWriteInputTokens >= e.cacheWriteInputTokens);
6893
6884
  }
6894
6885
  function Ea(e, t) {
6895
- if (!wa(e) || !wa(t) || !Ta(e, t)) return null;
6886
+ if (!$(e) || !$(t) || !Ta(e, t)) return null;
6896
6887
  let n = {
6897
6888
  totalTokens: t.totalTokens - e.totalTokens,
6898
6889
  inputTokens: t.inputTokens - e.inputTokens,
@@ -6901,7 +6892,7 @@ function Ea(e, t) {
6901
6892
  outputTokens: t.outputTokens - e.outputTokens,
6902
6893
  reasoningOutputTokens: t.reasoningOutputTokens - e.reasoningOutputTokens
6903
6894
  };
6904
- return wa(n) ? n : null;
6895
+ return $(n) ? n : null;
6905
6896
  }
6906
6897
  //#endregion
6907
6898
  //#region src/node/codex-surface.ts
@@ -6936,21 +6927,21 @@ var Da = class {
6936
6927
  unsubscribeToolInputRequests;
6937
6928
  unsubscribeMcpElicitationRequests;
6938
6929
  eventSequence = 0;
6939
- usage = new Sa();
6930
+ usage = new Ca();
6940
6931
  accountGeneration = 0;
6941
6932
  pendingMarkdownImageHydrations = /* @__PURE__ */ new Set();
6942
6933
  closed = !1;
6943
6934
  state = xt(wt());
6944
6935
  constructor(e = {}) {
6945
- this.options = e, this.extensions = new Mi(e.extensions ?? [], e.mcpServers ?? [], (e) => this.lifecycle.hostOptions(e));
6936
+ this.options = e, this.extensions = new Ni(e.extensions ?? [], e.mcpServers ?? [], (e) => this.lifecycle.hostOptions(e));
6946
6937
  let n = dn(e);
6947
- this.client = e.client ?? new t(un(n) ? new Ye(n) : new We(n), e.onListenerError ? { onListenerError: e.onListenerError } : {}), this.markdownImages = new ra(this.client), this.authentication = new pn(this.client, {
6938
+ this.client = e.client ?? new t(un(n) ? new Ye(n) : new We(n), e.onListenerError ? { onListenerError: e.onListenerError } : {}), this.markdownImages = new ia(this.client), this.authentication = new pn(this.client, {
6948
6939
  bootstrapSurfaceData: (e) => this.connection.bootstrapSurfaceData(e),
6949
6940
  clearAuthenticatedSurfaceData: () => this.connection.clearAuthenticatedSurfaceData(),
6950
6941
  getSnapshot: () => this.getSnapshot(),
6951
6942
  patchAuthentication: (e, t) => this.connection.patchAuthentication(e, t),
6952
6943
  reportError: (e) => this.patch({ error: k(e) })
6953
- }), this.items = new ni({
6944
+ }), this.items = new ri({
6954
6945
  assistantMessageForTurn: (e, t) => this.assistantMessageForTurn(e, t),
6955
6946
  emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
6956
6947
  emitEvent: (e, t) => this.emitEvent(e, t),
@@ -6964,7 +6955,7 @@ var Da = class {
6964
6955
  sendNextQueuedPrompt: (e) => {
6965
6956
  this.messagesController.sendNextQueuedPrompt(e);
6966
6957
  }
6967
- }), this.approvals = new wi(this.client, {
6958
+ }), this.approvals = new Ti(this.client, {
6968
6959
  activeConversationId: () => this.state.activeConversationId,
6969
6960
  createRuntime: (e, t) => this.createRuntime(e, t),
6970
6961
  emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
@@ -6974,7 +6965,7 @@ var Da = class {
6974
6965
  patch: (e) => this.patch(e),
6975
6966
  patchConversationStatus: (e, t) => this.patchConversationStatus(e, t),
6976
6967
  patchRuntime: (e, t) => this.patchRuntime(e, t)
6977
- }), this.clientRequests = new ai({
6968
+ }), this.clientRequests = new oi({
6978
6969
  activeConversationId: () => this.state.activeConversationId,
6979
6970
  answerAsyncQuestion: (e, t, n) => this.messagesController.answerAsyncQuestion(e, t, n),
6980
6971
  emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
@@ -6984,13 +6975,13 @@ var Da = class {
6984
6975
  messageContainingTool: (e, t, n) => this.messageContainingTool(e, t, n),
6985
6976
  patchRuntime: (e, t) => this.patchRuntime(e, t),
6986
6977
  requireRuntime: (e) => this.requireRuntime(e)
6987
- }), this.runtimeState = new Ki(this.approvals, this.clientRequests, {
6978
+ }), this.runtimeState = new qi(this.approvals, this.clientRequests, {
6988
6979
  emitEvent: (e, t) => this.emitEvent(e, t),
6989
6980
  getState: () => this.state,
6990
6981
  notifyConversationListeners: (e) => this.notifyConversationListeners(e),
6991
6982
  patch: (e, t) => this.patch(e, t),
6992
6983
  schedulePluginRefresh: () => this.catalog.schedulePluginRefresh()
6993
- }), this.conversationSettings = new Ri(this.client, {
6984
+ }), this.conversationSettings = new zi(this.client, {
6994
6985
  approvalMode: e.approvalMode,
6995
6986
  approvalPreset: e.approvalPreset,
6996
6987
  permissionMode: e.permissionMode
@@ -7008,7 +6999,7 @@ var Da = class {
7008
6999
  patch: (e) => this.patch(e),
7009
7000
  patchRuntime: (e, t) => this.patchRuntime(e, t),
7010
7001
  snapshotForRuntime: (e) => this.snapshotForRuntime(e)
7011
- }), this.turnActions = new Bi(this.client, {
7002
+ }), this.turnActions = new Vi(this.client, {
7012
7003
  createConversation: async () => {
7013
7004
  await this.createConversation();
7014
7005
  },
@@ -7025,7 +7016,7 @@ var Da = class {
7025
7016
  patchConversationTurnCount: (e, t, n) => this.patchConversationTurnCount(e, t, n),
7026
7017
  patchRuntime: (e, t) => this.patchRuntime(e, t),
7027
7018
  sendMessageToThread: (e, t, n) => this.messagesController.sendToThread(e, t, n)
7028
- }), this.messagesController = new Hi(this.client, {
7019
+ }), this.messagesController = new Ui(this.client, {
7029
7020
  clearGoalForThread: (e) => this.conversationSettings.clearGoalForThread(e),
7030
7021
  compactForThread: (e) => this.turnActions.compactForThread(e),
7031
7022
  createConversation: async () => {
@@ -7048,7 +7039,7 @@ var Da = class {
7048
7039
  startReviewForThread: (e, t) => this.turnActions.startReviewForThread(e, t),
7049
7040
  updateSettings: (e) => this.conversationSettings.update(e),
7050
7041
  updateSettingsForThread: (e, t) => this.conversationSettings.updateForThread(e, t)
7051
- }), this.catalog = new gi(this.client, e.cwd, {
7042
+ }), this.catalog = new _i(this.client, e.cwd, {
7052
7043
  authenticationBlocksBootstrap: () => this.authentication.blocksBootstrap(),
7053
7044
  emitConversationSkills: (e, t) => this.emitConversationSkills(e, t),
7054
7045
  emitEvent: (e, t) => this.emitEvent(e, t),
@@ -7059,7 +7050,7 @@ var Da = class {
7059
7050
  patchRuntime: (e, t) => this.patchRuntime(e, t),
7060
7051
  preferredApprovalPreset: () => this.conversationSettings.preferredApprovalPreset(),
7061
7052
  runtimes: () => this.runtimeState.values()
7062
- }), this.conversations = new Ii(this.client, e.conversationLimit, {
7053
+ }), this.conversations = new Li(this.client, e.conversationLimit, {
7063
7054
  emitHistoryPrepended: (e, t, n) => this.emitHistoryPrepended(e, t, n),
7064
7055
  emitSummaryUpserted: (e, t, n) => this.emitSummaryUpserted(e, t, n),
7065
7056
  ensureConnected: () => this.ensureConnected(),
@@ -7071,7 +7062,7 @@ var Da = class {
7071
7062
  requireRuntime: (e) => this.requireRuntime(e),
7072
7063
  runtime: (e) => this.runtimeState.get(e),
7073
7064
  schedulePluginRefresh: (e) => this.catalog.schedulePluginRefresh(e)
7074
- }), this.lifecycle = new Wi(this.client, e, this.catalog, this.extensions, this.conversationSettings, this.conversations, {
7065
+ }), this.lifecycle = new Gi(this.client, e, this.catalog, this.extensions, this.conversationSettings, this.conversations, {
7075
7066
  activateRuntime: (e) => this.activateRuntime(e),
7076
7067
  createRuntime: (e, t) => this.createRuntime(e, t),
7077
7068
  emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
@@ -7094,7 +7085,7 @@ var Da = class {
7094
7085
  runtime: (e) => this.runtimeState.get(e),
7095
7086
  runtimeProjection: (e) => this.runtimeProjection(e),
7096
7087
  snapshotForRuntime: (e) => this.snapshotForRuntime(e)
7097
- }), this.forks = new $i(this.client, e.loadingStrategy, this.catalog, this.extensions, {
7088
+ }), this.forks = new ea(this.client, e.loadingStrategy, this.catalog, this.extensions, {
7098
7089
  createRuntime: (e, t) => this.createRuntime(e, t),
7099
7090
  emitConversationActivity: (e) => this.emitConversationActivity(e, "action"),
7100
7091
  emitConversationPermissions: (e) => this.emitConversationPermissions(e, "action"),
@@ -7108,7 +7099,7 @@ var Da = class {
7108
7099
  rememberHostOptions: (e, t) => this.lifecycle.rememberHostOptions(e, t),
7109
7100
  requireRuntime: (e) => this.requireRuntime(e),
7110
7101
  snapshotForRuntime: (e) => this.snapshotForRuntime(e)
7111
- }), this.connection = new Zi(this.client, e, this.authentication, this.approvals, this.catalog, this.clientRequests, this.conversations, this.items, this.lifecycle, this.runtimeState, {
7102
+ }), this.connection = new Qi(this.client, e, this.authentication, this.approvals, this.catalog, this.clientRequests, this.conversations, this.items, this.lifecycle, this.runtimeState, {
7112
7103
  clearConversationHandles: () => this.conversationHandles.clear(),
7113
7104
  clearPendingForThread: (e, t, n) => this.clearPendingForThread(e, t, n),
7114
7105
  closed: () => this.closed,
@@ -7120,7 +7111,7 @@ var Da = class {
7120
7111
  getSnapshot: () => this.getSnapshot(),
7121
7112
  getState: () => this.state,
7122
7113
  patch: (e) => this.patch(e)
7123
- }), this.notifications = new Gi(this.authentication, this.approvals, this.catalog, this.clientRequests, this.conversations, this.items, {
7114
+ }), this.notifications = new Ki(this.authentication, this.approvals, this.catalog, this.clientRequests, this.conversations, this.items, {
7124
7115
  clearPendingForThread: (e, t, n) => this.clearPendingForThread(e, t, n),
7125
7116
  createRuntime: (e, t) => this.createRuntime(e, t),
7126
7117
  emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
@@ -7144,7 +7135,7 @@ var Da = class {
7144
7135
  },
7145
7136
  snapshotForRuntime: (e) => this.snapshotForRuntime(e),
7146
7137
  unknownNotification: (e) => this.handleUnknownNotification(e)
7147
- }), this.textGeneration = new ha(this.client, e.cwd, {
7138
+ }), this.textGeneration = new ga(this.client, e.cwd, {
7148
7139
  ensureConnected: () => this.ensureConnected(),
7149
7140
  getSnapshot: () => this.getSnapshot()
7150
7141
  }), this.unsubscribeNotification = this.client.onNotification((e) => {
@@ -7317,7 +7308,7 @@ var Da = class {
7317
7308
  return this.lifecycle.readHistory(e);
7318
7309
  }
7319
7310
  async readConversationPromptHistory(e = this.state.activeConversationId ?? "") {
7320
- return await this.ensureConnected(), da(this.client, e);
7311
+ return await this.ensureConnected(), fa(this.client, e);
7321
7312
  }
7322
7313
  async loadOlderConversationHistory(e = this.state.activeConversationId ?? "") {
7323
7314
  return this.conversations.loadOlderHistory(O(e));
@@ -8069,6 +8060,6 @@ async function za(e, t, n = {}) {
8069
8060
  };
8070
8061
  }
8071
8062
  //#endregion
8072
- export { ja as CodexAppBackend, Aa as CodexAppBackendTtlCache, We as CodexAppServerStdioTransport, Ye as CodexAppServerUnixSocketTransport, Da as CodexSurface, Sr as codexItemToMediaPart, br as codexItemToSurfaceMessage, R as codexItemToToolPart, _e as codexRuntimePathEntries, gr as codexThreadToSurfaceMessages, yr as codexTurnToSurfaceMessages, Ma as createCodexAppBackend, Oa as createCodexSurface, ge as discoverCodexExecutable, _r as preserveHistoricalAttachmentPreviews, Pa as resolveAppleSpeechAnalyzerPath, ye as resolveCodexRuntime, za as startAppleSpeechSession, Na as transcribeWithAppleSpeechAnalyzer, ve as withCodexRuntimePath };
8063
+ export { ja as CodexAppBackend, Aa as CodexAppBackendTtlCache, We as CodexAppServerStdioTransport, Ye as CodexAppServerUnixSocketTransport, Da as CodexSurface, Cr as codexItemToMediaPart, xr as codexItemToSurfaceMessage, R as codexItemToToolPart, _e as codexRuntimePathEntries, _r as codexThreadToSurfaceMessages, br as codexTurnToSurfaceMessages, Ma as createCodexAppBackend, Oa as createCodexSurface, ge as discoverCodexExecutable, vr as preserveHistoricalAttachmentPreviews, Pa as resolveAppleSpeechAnalyzerPath, ye as resolveCodexRuntime, za as startAppleSpeechSession, Na as transcribeWithAppleSpeechAnalyzer, ve as withCodexRuntimePath };
8073
8064
 
8074
8065
  //# sourceMappingURL=index.js.map