@geminilight/mindos 1.1.26 → 1.1.28

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 (352) hide show
  1. package/dist/agent/bridges/index.d.ts +3 -0
  2. package/dist/agent/bridges/index.d.ts.map +1 -0
  3. package/dist/agent/bridges/index.js +3 -0
  4. package/dist/agent/bridges/index.js.map +1 -0
  5. package/dist/agent/bridges/runtime-permission-bridge.d.ts +34 -0
  6. package/dist/agent/bridges/runtime-permission-bridge.d.ts.map +1 -0
  7. package/dist/agent/bridges/runtime-permission-bridge.js +284 -0
  8. package/dist/agent/bridges/runtime-permission-bridge.js.map +1 -0
  9. package/dist/agent/bridges/user-question-bridge.d.ts +90 -0
  10. package/dist/agent/bridges/user-question-bridge.d.ts.map +1 -0
  11. package/dist/agent/bridges/user-question-bridge.js +260 -0
  12. package/dist/agent/bridges/user-question-bridge.js.map +1 -0
  13. package/dist/agent/index.d.ts +6 -7
  14. package/dist/agent/index.d.ts.map +1 -1
  15. package/dist/agent/index.js +6 -7
  16. package/dist/agent/index.js.map +1 -1
  17. package/dist/agent/ledger/index.d.ts +5 -0
  18. package/dist/agent/ledger/index.d.ts.map +1 -0
  19. package/dist/agent/ledger/index.js +5 -0
  20. package/dist/agent/ledger/index.js.map +1 -0
  21. package/dist/agent/ledger/run-cancellation.d.ts +13 -0
  22. package/dist/agent/ledger/run-cancellation.d.ts.map +1 -0
  23. package/dist/agent/ledger/run-cancellation.js +97 -0
  24. package/dist/agent/ledger/run-cancellation.js.map +1 -0
  25. package/dist/agent/ledger/run-ledger-types.d.ts +197 -0
  26. package/dist/agent/ledger/run-ledger-types.d.ts.map +1 -0
  27. package/dist/agent/ledger/run-ledger-types.js +9 -0
  28. package/dist/agent/ledger/run-ledger-types.js.map +1 -0
  29. package/dist/agent/ledger/run-ledger.d.ts +44 -0
  30. package/dist/agent/ledger/run-ledger.d.ts.map +1 -0
  31. package/dist/agent/ledger/run-ledger.js +814 -0
  32. package/dist/agent/ledger/run-ledger.js.map +1 -0
  33. package/dist/agent/ledger/run-timeline-events.d.ts +3 -0
  34. package/dist/agent/ledger/run-timeline-events.d.ts.map +1 -0
  35. package/dist/agent/ledger/run-timeline-events.js +239 -0
  36. package/dist/agent/ledger/run-timeline-events.js.map +1 -0
  37. package/dist/agent/mindos-pi/extension/extension-tools.d.ts +16 -0
  38. package/dist/agent/mindos-pi/extension/extension-tools.d.ts.map +1 -0
  39. package/dist/agent/mindos-pi/extension/extension-tools.js +115 -0
  40. package/dist/agent/mindos-pi/extension/extension-tools.js.map +1 -0
  41. package/dist/agent/mindos-pi/extension/index.d.ts +3 -0
  42. package/dist/agent/mindos-pi/extension/index.d.ts.map +1 -0
  43. package/dist/agent/mindos-pi/extension/index.js +3 -0
  44. package/dist/agent/mindos-pi/extension/index.js.map +1 -0
  45. package/dist/agent/mindos-pi/extension/kb-extension.d.ts +38 -0
  46. package/dist/agent/mindos-pi/extension/kb-extension.d.ts.map +1 -0
  47. package/dist/agent/mindos-pi/extension/kb-extension.js +140 -0
  48. package/dist/agent/mindos-pi/extension/kb-extension.js.map +1 -0
  49. package/dist/agent/mindos-pi/index.d.ts +5 -0
  50. package/dist/agent/mindos-pi/index.d.ts.map +1 -0
  51. package/dist/agent/mindos-pi/index.js +5 -0
  52. package/dist/agent/mindos-pi/index.js.map +1 -0
  53. package/dist/agent/mindos-pi/prompt.d.ts +3 -0
  54. package/dist/agent/mindos-pi/prompt.d.ts.map +1 -0
  55. package/dist/agent/mindos-pi/prompt.js +22 -0
  56. package/dist/agent/mindos-pi/prompt.js.map +1 -0
  57. package/dist/agent/mindos-pi/resource-types.d.ts +27 -0
  58. package/dist/agent/mindos-pi/resource-types.d.ts.map +1 -0
  59. package/dist/agent/mindos-pi/resource-types.js +2 -0
  60. package/dist/agent/mindos-pi/resource-types.js.map +1 -0
  61. package/dist/agent/mindos-pi/runtime.d.ts +10 -0
  62. package/dist/agent/mindos-pi/runtime.d.ts.map +1 -0
  63. package/dist/agent/mindos-pi/runtime.js +31 -0
  64. package/dist/agent/mindos-pi/runtime.js.map +1 -0
  65. package/dist/agent/pi/extension-tools.d.ts +2 -0
  66. package/dist/agent/pi/extension-tools.d.ts.map +1 -0
  67. package/dist/agent/pi/extension-tools.js +2 -0
  68. package/dist/agent/pi/extension-tools.js.map +1 -0
  69. package/dist/agent/pi/index.d.ts +2 -0
  70. package/dist/agent/pi/index.d.ts.map +1 -0
  71. package/dist/agent/pi/index.js +2 -0
  72. package/dist/agent/pi/index.js.map +1 -0
  73. package/dist/agent/pi/resource-types.d.ts +2 -0
  74. package/dist/agent/pi/resource-types.d.ts.map +1 -0
  75. package/dist/agent/pi/resource-types.js +2 -0
  76. package/dist/agent/pi/resource-types.js.map +1 -0
  77. package/dist/agent/pi/runtime.d.ts +2 -0
  78. package/dist/agent/pi/runtime.d.ts.map +1 -0
  79. package/dist/agent/pi/runtime.js +2 -0
  80. package/dist/agent/pi/runtime.js.map +1 -0
  81. package/dist/agent/prompt/context-prompt.d.ts +24 -0
  82. package/dist/agent/prompt/context-prompt.d.ts.map +1 -1
  83. package/dist/agent/prompt/context-prompt.js +15 -38
  84. package/dist/agent/prompt/context-prompt.js.map +1 -1
  85. package/dist/agent/prompt/index.d.ts +1 -1
  86. package/dist/agent/prompt/index.d.ts.map +1 -1
  87. package/dist/agent/prompt/index.js +1 -1
  88. package/dist/agent/prompt/index.js.map +1 -1
  89. package/dist/agent/result-reducer.d.ts +1 -1
  90. package/dist/agent/result-reducer.d.ts.map +1 -1
  91. package/dist/agent/run-cancellation.d.ts +1 -12
  92. package/dist/agent/run-cancellation.d.ts.map +1 -1
  93. package/dist/agent/run-cancellation.js +1 -96
  94. package/dist/agent/run-cancellation.js.map +1 -1
  95. package/dist/agent/run-ledger-types.d.ts +1 -196
  96. package/dist/agent/run-ledger-types.d.ts.map +1 -1
  97. package/dist/agent/run-ledger-types.js +1 -8
  98. package/dist/agent/run-ledger-types.js.map +1 -1
  99. package/dist/agent/run-ledger.d.ts +1 -43
  100. package/dist/agent/run-ledger.d.ts.map +1 -1
  101. package/dist/agent/run-ledger.js +1 -813
  102. package/dist/agent/run-ledger.js.map +1 -1
  103. package/dist/agent/run-timeline-events.d.ts +1 -2
  104. package/dist/agent/run-timeline-events.d.ts.map +1 -1
  105. package/dist/agent/run-timeline-events.js +1 -238
  106. package/dist/agent/run-timeline-events.js.map +1 -1
  107. package/dist/agent/runtime/adapters/index.d.ts +2 -0
  108. package/dist/agent/runtime/adapters/index.d.ts.map +1 -0
  109. package/dist/agent/runtime/adapters/index.js +2 -0
  110. package/dist/agent/runtime/adapters/index.js.map +1 -0
  111. package/dist/agent/runtime/adapters/mindos.d.ts +21 -0
  112. package/dist/agent/runtime/adapters/mindos.d.ts.map +1 -0
  113. package/dist/agent/runtime/adapters/mindos.js +14 -0
  114. package/dist/agent/runtime/adapters/mindos.js.map +1 -0
  115. package/dist/agent/runtime/attachments.d.ts +37 -0
  116. package/dist/agent/runtime/attachments.d.ts.map +1 -0
  117. package/dist/agent/runtime/attachments.js +187 -0
  118. package/dist/agent/runtime/attachments.js.map +1 -0
  119. package/dist/agent/runtime/capabilities.d.ts +10 -0
  120. package/dist/agent/runtime/capabilities.d.ts.map +1 -0
  121. package/dist/agent/runtime/capabilities.js +100 -0
  122. package/dist/agent/runtime/capabilities.js.map +1 -0
  123. package/dist/agent/runtime/child-process.d.ts +21 -0
  124. package/dist/agent/runtime/child-process.d.ts.map +1 -0
  125. package/dist/agent/runtime/child-process.js +29 -0
  126. package/dist/agent/runtime/child-process.js.map +1 -0
  127. package/dist/agent/runtime/claude-code-cli.d.ts +40 -0
  128. package/dist/agent/runtime/claude-code-cli.d.ts.map +1 -0
  129. package/dist/agent/runtime/claude-code-cli.js +288 -0
  130. package/dist/agent/runtime/claude-code-cli.js.map +1 -0
  131. package/dist/agent/runtime/claude-code-sdk.d.ts +62 -0
  132. package/dist/agent/runtime/claude-code-sdk.d.ts.map +1 -0
  133. package/dist/agent/runtime/claude-code-sdk.js +613 -0
  134. package/dist/agent/runtime/claude-code-sdk.js.map +1 -0
  135. package/dist/agent/runtime/codex-app-server.d.ts +172 -0
  136. package/dist/agent/runtime/codex-app-server.d.ts.map +1 -0
  137. package/dist/agent/runtime/codex-app-server.js +700 -0
  138. package/dist/agent/runtime/codex-app-server.js.map +1 -0
  139. package/dist/agent/runtime/codex-env.d.ts +42 -0
  140. package/dist/agent/runtime/codex-env.d.ts.map +1 -0
  141. package/dist/agent/runtime/codex-env.js +290 -0
  142. package/dist/agent/runtime/codex-env.js.map +1 -0
  143. package/dist/agent/runtime/descriptors.d.ts +19 -0
  144. package/dist/agent/runtime/descriptors.d.ts.map +1 -0
  145. package/dist/agent/runtime/descriptors.js +143 -0
  146. package/dist/agent/runtime/descriptors.js.map +1 -0
  147. package/dist/agent/runtime/detection.d.ts +15 -0
  148. package/dist/agent/runtime/detection.d.ts.map +1 -0
  149. package/dist/agent/runtime/detection.js +124 -0
  150. package/dist/agent/runtime/detection.js.map +1 -0
  151. package/dist/agent/runtime/index.d.ts +15 -0
  152. package/dist/agent/runtime/index.d.ts.map +1 -0
  153. package/dist/agent/runtime/index.js +15 -0
  154. package/dist/agent/runtime/index.js.map +1 -0
  155. package/dist/agent/runtime/registry.d.ts +152 -0
  156. package/dist/agent/runtime/registry.d.ts.map +1 -0
  157. package/dist/agent/runtime/registry.js +84 -0
  158. package/dist/agent/runtime/registry.js.map +1 -0
  159. package/dist/agent/runtime/run.d.ts +129 -0
  160. package/dist/agent/runtime/run.d.ts.map +1 -0
  161. package/dist/agent/runtime/run.js +739 -0
  162. package/dist/agent/runtime/run.js.map +1 -0
  163. package/dist/agent/runtime/runtime-env.d.ts +28 -0
  164. package/dist/agent/runtime/runtime-env.d.ts.map +1 -0
  165. package/dist/agent/runtime/runtime-env.js +66 -0
  166. package/dist/agent/runtime/runtime-env.js.map +1 -0
  167. package/dist/agent/runtime/runtime-errors.d.ts +20 -0
  168. package/dist/agent/runtime/runtime-errors.d.ts.map +1 -0
  169. package/dist/agent/runtime/runtime-errors.js +95 -0
  170. package/dist/agent/runtime/runtime-errors.js.map +1 -0
  171. package/dist/agent/runtime-permission-bridge.d.ts +1 -33
  172. package/dist/agent/runtime-permission-bridge.d.ts.map +1 -1
  173. package/dist/agent/runtime-permission-bridge.js +1 -283
  174. package/dist/agent/runtime-permission-bridge.js.map +1 -1
  175. package/dist/agent/selected-skills.d.ts +8 -0
  176. package/dist/agent/selected-skills.d.ts.map +1 -0
  177. package/dist/agent/selected-skills.js +27 -0
  178. package/dist/agent/selected-skills.js.map +1 -0
  179. package/dist/agent/session/index.d.ts +618 -0
  180. package/dist/agent/session/index.d.ts.map +1 -0
  181. package/dist/agent/session/index.js +1330 -0
  182. package/dist/agent/session/index.js.map +1 -0
  183. package/dist/agent/session/redaction.d.ts +3 -0
  184. package/dist/agent/session/redaction.d.ts.map +1 -0
  185. package/dist/agent/session/redaction.js +47 -0
  186. package/dist/agent/session/redaction.js.map +1 -0
  187. package/dist/agent/stream/index.d.ts +3 -0
  188. package/dist/agent/stream/index.d.ts.map +1 -0
  189. package/dist/agent/stream/index.js +3 -0
  190. package/dist/agent/stream/index.js.map +1 -0
  191. package/dist/agent/stream/stream-consumer.d.ts +65 -0
  192. package/dist/agent/stream/stream-consumer.d.ts.map +1 -0
  193. package/dist/agent/stream/stream-consumer.js +664 -0
  194. package/dist/agent/stream/stream-consumer.js.map +1 -0
  195. package/dist/agent/stream/stream-message-types.d.ts +128 -0
  196. package/dist/agent/stream/stream-message-types.d.ts.map +1 -0
  197. package/dist/agent/stream/stream-message-types.js +14 -0
  198. package/dist/agent/stream/stream-message-types.js.map +1 -0
  199. package/dist/agent/stream-consumer.d.ts +1 -64
  200. package/dist/agent/stream-consumer.d.ts.map +1 -1
  201. package/dist/agent/stream-consumer.js +1 -663
  202. package/dist/agent/stream-consumer.js.map +1 -1
  203. package/dist/agent/stream-message-types.d.ts +1 -137
  204. package/dist/agent/stream-message-types.d.ts.map +1 -1
  205. package/dist/agent/stream-message-types.js +1 -13
  206. package/dist/agent/stream-message-types.js.map +1 -1
  207. package/dist/agent/subagent/index.d.ts +3 -0
  208. package/dist/agent/subagent/index.d.ts.map +1 -0
  209. package/dist/agent/subagent/index.js +3 -0
  210. package/dist/agent/subagent/index.js.map +1 -0
  211. package/dist/agent/subagent/subagent-ledger-extension.d.ts +36 -0
  212. package/dist/agent/subagent/subagent-ledger-extension.d.ts.map +1 -0
  213. package/dist/agent/subagent/subagent-ledger-extension.js +572 -0
  214. package/dist/agent/subagent/subagent-ledger-extension.js.map +1 -0
  215. package/dist/agent/subagent/subagent-orchestrator.d.ts +62 -0
  216. package/dist/agent/subagent/subagent-orchestrator.d.ts.map +1 -0
  217. package/dist/agent/subagent/subagent-orchestrator.js +350 -0
  218. package/dist/agent/subagent/subagent-orchestrator.js.map +1 -0
  219. package/dist/agent/subagent-ledger-extension.d.ts +1 -35
  220. package/dist/agent/subagent-ledger-extension.d.ts.map +1 -1
  221. package/dist/agent/subagent-ledger-extension.js +1 -571
  222. package/dist/agent/subagent-ledger-extension.js.map +1 -1
  223. package/dist/agent/subagent-orchestrator.d.ts +1 -61
  224. package/dist/agent/subagent-orchestrator.d.ts.map +1 -1
  225. package/dist/agent/subagent-orchestrator.js +1 -349
  226. package/dist/agent/subagent-orchestrator.js.map +1 -1
  227. package/dist/agent/tool/executable-tool.d.ts +12 -0
  228. package/dist/agent/tool/executable-tool.d.ts.map +1 -0
  229. package/dist/agent/tool/executable-tool.js +2 -0
  230. package/dist/agent/tool/executable-tool.js.map +1 -0
  231. package/dist/agent/tool/index.d.ts +1 -1
  232. package/dist/agent/tool/index.d.ts.map +1 -1
  233. package/dist/agent/tool/index.js +1 -1
  234. package/dist/agent/tool/index.js.map +1 -1
  235. package/dist/agent/tool/kb-extension.d.ts +1 -37
  236. package/dist/agent/tool/kb-extension.d.ts.map +1 -1
  237. package/dist/agent/tool/kb-extension.js +1 -139
  238. package/dist/agent/tool/kb-extension.js.map +1 -1
  239. package/dist/agent/user-question-bridge.d.ts +1 -89
  240. package/dist/agent/user-question-bridge.d.ts.map +1 -1
  241. package/dist/agent/user-question-bridge.js +1 -259
  242. package/dist/agent/user-question-bridge.js.map +1 -1
  243. package/dist/agent-runtime/adapters/index.d.ts +2 -0
  244. package/dist/agent-runtime/adapters/index.d.ts.map +1 -0
  245. package/dist/agent-runtime/adapters/index.js +2 -0
  246. package/dist/agent-runtime/adapters/index.js.map +1 -0
  247. package/dist/agent-runtime/adapters/mindos.d.ts +2 -0
  248. package/dist/agent-runtime/adapters/mindos.d.ts.map +1 -0
  249. package/dist/agent-runtime/adapters/mindos.js +2 -0
  250. package/dist/agent-runtime/adapters/mindos.js.map +1 -0
  251. package/dist/agent-runtime/capabilities.d.ts +1 -9
  252. package/dist/agent-runtime/capabilities.d.ts.map +1 -1
  253. package/dist/agent-runtime/capabilities.js +1 -99
  254. package/dist/agent-runtime/capabilities.js.map +1 -1
  255. package/dist/agent-runtime/child-process.d.ts +1 -20
  256. package/dist/agent-runtime/child-process.d.ts.map +1 -1
  257. package/dist/agent-runtime/child-process.js +1 -28
  258. package/dist/agent-runtime/child-process.js.map +1 -1
  259. package/dist/agent-runtime/claude-code-cli.d.ts +1 -35
  260. package/dist/agent-runtime/claude-code-cli.d.ts.map +1 -1
  261. package/dist/agent-runtime/claude-code-cli.js +1 -287
  262. package/dist/agent-runtime/claude-code-cli.js.map +1 -1
  263. package/dist/agent-runtime/claude-code-sdk.d.ts +1 -40
  264. package/dist/agent-runtime/claude-code-sdk.d.ts.map +1 -1
  265. package/dist/agent-runtime/claude-code-sdk.js +1 -571
  266. package/dist/agent-runtime/claude-code-sdk.js.map +1 -1
  267. package/dist/agent-runtime/codex-app-server.d.ts +1 -157
  268. package/dist/agent-runtime/codex-app-server.d.ts.map +1 -1
  269. package/dist/agent-runtime/codex-app-server.js +1 -665
  270. package/dist/agent-runtime/codex-app-server.js.map +1 -1
  271. package/dist/agent-runtime/codex-env.d.ts +1 -41
  272. package/dist/agent-runtime/codex-env.d.ts.map +1 -1
  273. package/dist/agent-runtime/codex-env.js +1 -289
  274. package/dist/agent-runtime/codex-env.js.map +1 -1
  275. package/dist/agent-runtime/descriptors.d.ts +1 -18
  276. package/dist/agent-runtime/descriptors.d.ts.map +1 -1
  277. package/dist/agent-runtime/descriptors.js +1 -142
  278. package/dist/agent-runtime/descriptors.js.map +1 -1
  279. package/dist/agent-runtime/detection.d.ts +1 -14
  280. package/dist/agent-runtime/detection.d.ts.map +1 -1
  281. package/dist/agent-runtime/detection.js +1 -123
  282. package/dist/agent-runtime/detection.js.map +1 -1
  283. package/dist/agent-runtime/index.d.ts +1 -8
  284. package/dist/agent-runtime/index.d.ts.map +1 -1
  285. package/dist/agent-runtime/index.js +1 -8
  286. package/dist/agent-runtime/index.js.map +1 -1
  287. package/dist/agent-runtime/registry.d.ts +1 -151
  288. package/dist/agent-runtime/registry.d.ts.map +1 -1
  289. package/dist/agent-runtime/registry.js +1 -83
  290. package/dist/agent-runtime/registry.js.map +1 -1
  291. package/dist/agent-runtime/run.d.ts +1 -124
  292. package/dist/agent-runtime/run.d.ts.map +1 -1
  293. package/dist/agent-runtime/run.js +1 -720
  294. package/dist/agent-runtime/run.js.map +1 -1
  295. package/dist/agent-runtime/runtime-env.d.ts +1 -27
  296. package/dist/agent-runtime/runtime-env.d.ts.map +1 -1
  297. package/dist/agent-runtime/runtime-env.js +1 -65
  298. package/dist/agent-runtime/runtime-env.js.map +1 -1
  299. package/dist/agent-runtime/runtime-errors.d.ts +1 -19
  300. package/dist/agent-runtime/runtime-errors.d.ts.map +1 -1
  301. package/dist/agent-runtime/runtime-errors.js +1 -94
  302. package/dist/agent-runtime/runtime-errors.js.map +1 -1
  303. package/dist/agent-runtime.d.ts +1 -1
  304. package/dist/agent-runtime.js +1 -1
  305. package/dist/client.d.ts +8 -4
  306. package/dist/client.d.ts.map +1 -1
  307. package/dist/client.js.map +1 -1
  308. package/dist/foundation/config/schema.d.ts +1 -1
  309. package/dist/server/handlers/agent-runtime-codex.d.ts +1 -1
  310. package/dist/server/handlers/agent-runtime-codex.js +2 -2
  311. package/dist/server/handlers/agent-runtimes.d.ts +3 -3
  312. package/dist/server/handlers/agent-runtimes.js +5 -5
  313. package/dist/server/handlers/ask.d.ts +8 -4
  314. package/dist/server/handlers/ask.d.ts.map +1 -1
  315. package/dist/server/handlers/ask.js +7 -1
  316. package/dist/server/handlers/ask.js.map +1 -1
  317. package/dist/server/handlers/inbox-source.d.ts +1 -1
  318. package/dist/server/handlers/inbox-source.d.ts.map +1 -1
  319. package/dist/server/handlers/inbox-source.js +22 -0
  320. package/dist/server/handlers/inbox-source.js.map +1 -1
  321. package/dist/server/handlers/settings.d.ts +1 -1
  322. package/dist/server/handlers/settings.js +1 -1
  323. package/dist/server/handlers/setup.d.ts +2 -1
  324. package/dist/server/handlers/setup.d.ts.map +1 -1
  325. package/dist/server/handlers/setup.js +1 -0
  326. package/dist/server/handlers/setup.js.map +1 -1
  327. package/dist/server/index.d.ts +1 -1
  328. package/dist/server/index.d.ts.map +1 -1
  329. package/dist/server/index.js +1 -1
  330. package/dist/server/index.js.map +1 -1
  331. package/dist/server/runtime.d.ts +1 -1
  332. package/dist/session/index.d.ts +1 -650
  333. package/dist/session/index.d.ts.map +1 -1
  334. package/dist/session/index.js +1 -1455
  335. package/dist/session/index.js.map +1 -1
  336. package/dist/session/pi-coding-agent-runtime.d.ts +1 -9
  337. package/dist/session/pi-coding-agent-runtime.d.ts.map +1 -1
  338. package/dist/session/pi-coding-agent-runtime.js +1 -30
  339. package/dist/session/pi-coding-agent-runtime.js.map +1 -1
  340. package/dist/session/redaction.d.ts +1 -2
  341. package/dist/session/redaction.d.ts.map +1 -1
  342. package/dist/session/redaction.js +1 -46
  343. package/dist/session/redaction.js.map +1 -1
  344. package/dist/session.d.ts +1 -1
  345. package/dist/session.d.ts.map +1 -1
  346. package/dist/session.js +1 -1
  347. package/dist/session.js.map +1 -1
  348. package/dist/setup/index.d.ts +24 -3
  349. package/dist/setup/index.d.ts.map +1 -1
  350. package/dist/setup/index.js +102 -2
  351. package/dist/setup/index.js.map +1 -1
  352. package/package.json +97 -9
@@ -1,721 +1,2 @@
1
- import { redactSensitiveText } from '../session/index.js';
2
- import { createClaudeCodeCliClient, createClaudeCodeCliStdioTransport, } from './claude-code-cli.js';
3
- import { createClaudeCodeSdkClient, isClaudeCodeSdkNativeBinaryError, loadClaudeCodeSdkModule, } from './claude-code-sdk.js';
4
- import { createCodexAppServerClient, createCodexAppServerStdioTransport, mapCodexAppServerNotificationToSseEvents, } from './codex-app-server.js';
5
- import { compactRuntimeFailureMessage } from './runtime-errors.js';
6
- function sendNativeRuntimeStatus(options, runtime, message) {
7
- options.send({ type: 'status', visible: true, runtime, message });
8
- }
9
- export async function runMindosAgentRuntimeAskSession(options) {
10
- const scoped = withNativeRuntimeTimeout(options);
11
- try {
12
- if (scoped.options.runtime.kind === 'claude') {
13
- return await runClaudeAskSession(scoped.options);
14
- }
15
- return await runCodexAskSession(scoped.options);
16
- }
17
- finally {
18
- scoped.cleanup();
19
- }
20
- }
21
- function createNativeRuntimeTimeoutError(timeoutMs) {
22
- const seconds = Math.max(1, Math.round(timeoutMs / 1000));
23
- const error = new Error(`Native runtime timed out after ${seconds}s.`);
24
- error.code = 'TIMEOUT';
25
- return error;
26
- }
27
- function isTimeoutError(value) {
28
- return value instanceof Error && value.code === 'TIMEOUT';
29
- }
30
- function errorFromRuntimeFailure(error, signal, runtime) {
31
- const reason = signal?.reason;
32
- if (signal?.aborted && isTimeoutError(reason))
33
- return reason;
34
- // Transport failures can echo stderr/env contents; redact before the
35
- // message reaches SSE events or persisted run ledgers.
36
- const rawMessage = redactSensitiveText(error instanceof Error ? error.message : String(error));
37
- const compactMessage = compactRuntimeFailureMessage(rawMessage, {
38
- runtime,
39
- fallback: `${runtime === 'claude' ? 'Claude Code' : 'Codex'} native runtime error.`,
40
- });
41
- const compactError = new Error(compactMessage);
42
- if (error instanceof Error)
43
- compactError.name = error.name;
44
- return compactError;
45
- }
46
- function throwIfNativeRuntimeTimedOut(signal) {
47
- if (signal?.aborted && isTimeoutError(signal.reason)) {
48
- throw signal.reason;
49
- }
50
- }
51
- function abortErrorFromSignal(signal) {
52
- const reason = signal.reason;
53
- if (reason instanceof Error)
54
- return reason;
55
- return new Error(reason ? String(reason) : 'Native runtime aborted.');
56
- }
57
- function throwIfNativeRuntimeAborted(signal) {
58
- if (signal?.aborted) {
59
- throw abortErrorFromSignal(signal);
60
- }
61
- }
62
- function settleIteratorReturn(iterator) {
63
- const result = iterator.return?.();
64
- if (result && typeof result.then === 'function') {
65
- void Promise.resolve(result).catch(() => { });
66
- }
67
- }
68
- async function nextWithNativeRuntimeAbort(iterator, signal) {
69
- throwIfNativeRuntimeAborted(signal);
70
- const nextPromise = Promise.resolve(iterator.next());
71
- nextPromise.catch(() => { });
72
- if (!signal)
73
- return nextPromise;
74
- let removeAbortListener = () => { };
75
- const abortPromise = new Promise((_resolve, reject) => {
76
- const abort = () => reject(abortErrorFromSignal(signal));
77
- removeAbortListener = () => signal.removeEventListener('abort', abort);
78
- signal.addEventListener('abort', abort, { once: true });
79
- });
80
- try {
81
- return await Promise.race([nextPromise, abortPromise]);
82
- }
83
- catch (error) {
84
- if (signal.aborted) {
85
- throw abortErrorFromSignal(signal);
86
- }
87
- throw error;
88
- }
89
- finally {
90
- removeAbortListener();
91
- }
92
- }
93
- async function* iterateWithNativeRuntimeAbort(iterable, signal) {
94
- const iterator = iterable[Symbol.asyncIterator]();
95
- let completed = false;
96
- try {
97
- while (true) {
98
- const next = await nextWithNativeRuntimeAbort(iterator, signal);
99
- if (next.done) {
100
- completed = true;
101
- return;
102
- }
103
- yield next.value;
104
- }
105
- }
106
- finally {
107
- if (!completed) {
108
- settleIteratorReturn(iterator);
109
- }
110
- }
111
- }
112
- function withNativeRuntimeTimeout(options) {
113
- const timeoutMs = options.timeoutMs;
114
- if (!timeoutMs || !Number.isFinite(timeoutMs) || timeoutMs <= 0) {
115
- return { options, cleanup: () => { } };
116
- }
117
- const controller = new AbortController();
118
- const abortFromParent = () => {
119
- if (!controller.signal.aborted) {
120
- controller.abort(options.signal?.reason ?? new Error('Native runtime aborted.'));
121
- }
122
- };
123
- if (options.signal?.aborted) {
124
- abortFromParent();
125
- }
126
- else {
127
- options.signal?.addEventListener('abort', abortFromParent, { once: true });
128
- }
129
- const timer = setTimeout(() => {
130
- if (!controller.signal.aborted) {
131
- controller.abort(createNativeRuntimeTimeoutError(timeoutMs));
132
- }
133
- }, timeoutMs);
134
- return {
135
- options: {
136
- ...options,
137
- signal: controller.signal,
138
- },
139
- cleanup: () => {
140
- clearTimeout(timer);
141
- options.signal?.removeEventListener('abort', abortFromParent);
142
- },
143
- };
144
- }
145
- async function runClaudeAskSession(options) {
146
- let client;
147
- let sessionId = options.runtime.externalSessionId;
148
- const turnState = { sessionId };
149
- try {
150
- sendNativeRuntimeStatus(options, 'claude', sessionId
151
- ? 'Resuming Claude Code locally.'
152
- : 'Starting Claude Code locally.');
153
- const resolvedClient = await resolveClaudeClient(options);
154
- client = resolvedClient.client;
155
- try {
156
- sessionId = await runClaudeTurnWithClient(options, resolvedClient, turnState);
157
- }
158
- catch (error) {
159
- sessionId = turnState.sessionId;
160
- const err = errorFromRuntimeFailure(error, options.signal, 'claude');
161
- if (resolvedClient.source !== 'sdk' || !shouldFallbackFromClaudeSdkTurnError(err, options.signal)) {
162
- throw error;
163
- }
164
- await client.close?.();
165
- sendNativeRuntimeStatus(options, 'claude', `Claude Agent SDK could not start its native runtime; using Claude Code CLI fallback. ${err.message}`);
166
- const cliClient = await resolveClaudeCliClient(options);
167
- client = cliClient;
168
- turnState.sessionId = sessionId;
169
- sessionId = await runClaudeTurnWithClient(options, {
170
- client: cliClient,
171
- usesCliPermissionPrompt: true,
172
- source: 'cli',
173
- }, turnState);
174
- }
175
- throwIfNativeRuntimeTimedOut(options.signal);
176
- return sessionId ? { externalSessionId: sessionId } : {};
177
- }
178
- catch (error) {
179
- const err = errorFromRuntimeFailure(error, options.signal, 'claude');
180
- if (sessionId) {
181
- options.send({
182
- type: 'runtime_binding',
183
- runtime: 'claude',
184
- externalSessionId: sessionId,
185
- cwd: options.cwd,
186
- status: 'failed',
187
- reason: err.message,
188
- });
189
- }
190
- options.send({ type: 'error', message: `Claude Code native runtime error: ${err.message}` });
191
- return { error: err, ...(sessionId ? { externalSessionId: sessionId } : {}) };
192
- }
193
- finally {
194
- await client?.close?.();
195
- }
196
- }
197
- async function runClaudeTurnWithClient(options, resolvedClient, state) {
198
- let sessionId = state.sessionId;
199
- const permissionPrompt = resolvedClient.usesCliPermissionPrompt
200
- ? await options.services?.createClaudePermissionPrompt?.({
201
- cwd: options.cwd,
202
- signal: options.signal,
203
- })
204
- : undefined;
205
- const turnEvents = resolvedClient.client.startTurn({
206
- prompt: options.prompt,
207
- cwd: options.cwd,
208
- ...(sessionId ? { sessionId } : {}),
209
- ...(options.modelOverride ? { model: options.modelOverride } : {}),
210
- ...(options.reasoningEffort ? { effort: options.reasoningEffort } : {}),
211
- permissionMode: claudeCliPermissionModeForMindosMode(options.permissionMode),
212
- ...(permissionPrompt ? { permissionPrompt } : {}),
213
- signal: options.signal,
214
- });
215
- for await (const event of iterateWithNativeRuntimeAbort(turnEvents, options.signal)) {
216
- if (event.type === 'session_id') {
217
- sessionId = event.sessionId;
218
- state.sessionId = event.sessionId;
219
- options.send({
220
- type: 'runtime_binding',
221
- runtime: 'claude',
222
- externalSessionId: event.sessionId,
223
- cwd: options.cwd,
224
- });
225
- sendNativeRuntimeStatus(options, 'claude', 'Claude Code is connected and working in this chat.');
226
- continue;
227
- }
228
- options.send(event);
229
- }
230
- return sessionId;
231
- }
232
- function shouldFallbackFromClaudeSdkTurnError(error, signal) {
233
- if (signal?.aborted)
234
- return false;
235
- return isClaudeCodeSdkNativeBinaryError(error);
236
- }
237
- function claudeCliPermissionModeForMindosMode(mode) {
238
- return mode === 'readonly' ? 'dontAsk' : 'default';
239
- }
240
- function codexPermissionOptionsForMindosMode(mode) {
241
- if (mode !== 'readonly')
242
- return {};
243
- return {
244
- approvalPolicy: 'never',
245
- sandbox: { mode: 'read-only' },
246
- };
247
- }
248
- async function runCodexAskSession(options) {
249
- let client;
250
- let threadId = options.runtime.externalSessionId;
251
- const pendingServerRequests = new Map();
252
- try {
253
- sendNativeRuntimeStatus(options, 'codex', threadId
254
- ? 'Resuming Codex locally.'
255
- : 'Starting Codex locally.');
256
- client = await resolveCodexClient(options, async (request) => {
257
- return handleCodexServerRequest(request, options, pendingServerRequests);
258
- });
259
- await client.initialize({ signal: options.signal });
260
- const thread = threadId
261
- ? await client.resumeThread({ threadId }, { signal: options.signal })
262
- : await client.startThread({
263
- cwd: options.cwd,
264
- ...(options.modelOverride ? { model: options.modelOverride } : {}),
265
- }, { signal: options.signal });
266
- threadId = thread.threadId;
267
- options.send({
268
- type: 'runtime_binding',
269
- runtime: 'codex',
270
- externalSessionId: threadId,
271
- cwd: options.cwd,
272
- });
273
- sendNativeRuntimeStatus(options, 'codex', 'Codex is connected and working in this chat.');
274
- const abortListener = () => {
275
- if (threadId)
276
- void client?.interruptTurn?.({ threadId }).catch(() => { });
277
- };
278
- options.signal?.addEventListener('abort', abortListener, { once: true });
279
- try {
280
- const turnNotifications = client.startTurn({
281
- threadId,
282
- cwd: options.cwd,
283
- input: [{ type: 'text', text: options.prompt }],
284
- ...(options.modelOverride ? { model: options.modelOverride } : {}),
285
- ...(options.reasoningEffort ? { effort: options.reasoningEffort } : {}),
286
- ...codexPermissionOptionsForMindosMode(options.permissionMode),
287
- signal: options.signal,
288
- });
289
- for await (const notification of iterateWithNativeRuntimeAbort(turnNotifications, options.signal)) {
290
- if (notification.method === 'serverRequest/resolved') {
291
- abortCodexPendingServerRequest(notification.params, pendingServerRequests);
292
- }
293
- for (const event of mapCodexAppServerNotificationToSseEvents(notification)) {
294
- options.send(event);
295
- }
296
- }
297
- }
298
- finally {
299
- options.signal?.removeEventListener('abort', abortListener);
300
- }
301
- throwIfNativeRuntimeTimedOut(options.signal);
302
- return { externalSessionId: threadId };
303
- }
304
- catch (error) {
305
- const err = errorFromRuntimeFailure(error, options.signal, 'codex');
306
- if (threadId) {
307
- options.send({
308
- type: 'runtime_binding',
309
- runtime: 'codex',
310
- externalSessionId: threadId,
311
- cwd: options.cwd,
312
- status: 'failed',
313
- reason: err.message,
314
- });
315
- }
316
- options.send({ type: 'error', message: `Codex native runtime error: ${err.message}` });
317
- return { error: err, ...(threadId ? { externalSessionId: threadId } : {}) };
318
- }
319
- finally {
320
- abortAllCodexPendingServerRequests(pendingServerRequests);
321
- await client?.close?.();
322
- }
323
- }
324
- async function resolveCodexClient(options, handleServerRequest) {
325
- if (options.services?.createCodexClient) {
326
- return options.services.createCodexClient({ cwd: options.cwd, signal: options.signal, handleServerRequest });
327
- }
328
- return createCodexAppServerClient(createCodexAppServerStdioTransport({
329
- cwd: options.cwd,
330
- ...(options.runtime.binaryPath ? { command: options.runtime.binaryPath } : {}),
331
- ...(options.runtimeEnv ? { env: options.runtimeEnv } : {}),
332
- }), { handleServerRequest });
333
- }
334
- async function resolveClaudeClient(options) {
335
- const command = requireClaudeLocalCliPath(options);
336
- if (options.services?.createClaudeClient) {
337
- return {
338
- client: await options.services.createClaudeClient({ cwd: options.cwd, signal: options.signal }),
339
- usesCliPermissionPrompt: true,
340
- source: 'override',
341
- };
342
- }
343
- try {
344
- return {
345
- client: await resolveClaudeSdkClient(options),
346
- usesCliPermissionPrompt: false,
347
- source: 'sdk',
348
- };
349
- }
350
- catch (error) {
351
- const err = error instanceof Error ? error : new Error(String(error));
352
- sendNativeRuntimeStatus(options, 'claude', `Claude Agent SDK is unavailable; using Claude Code CLI fallback. ${err.message}`);
353
- }
354
- return {
355
- client: await resolveClaudeCliClient(options, command),
356
- usesCliPermissionPrompt: true,
357
- source: 'cli',
358
- };
359
- }
360
- async function resolveClaudeSdkClient(options) {
361
- const command = requireClaudeLocalCliPath(options);
362
- if (options.services?.createClaudeSdkClient) {
363
- return options.services.createClaudeSdkClient({
364
- cwd: options.cwd,
365
- signal: options.signal,
366
- command,
367
- ...(options.runtimeEnv ? { env: options.runtimeEnv } : {}),
368
- });
369
- }
370
- const sdk = options.services?.loadClaudeSdk
371
- ? await options.services.loadClaudeSdk()
372
- : await loadClaudeCodeSdkModule();
373
- return createClaudeCodeSdkClient({
374
- sdk,
375
- pathToClaudeCodeExecutable: command,
376
- ...(options.runtimeEnv ? { env: options.runtimeEnv } : {}),
377
- requestRuntimePermission: options.services?.requestRuntimePermission,
378
- requestUserQuestion: options.services?.requestUserQuestion,
379
- });
380
- }
381
- async function resolveClaudeCliClient(options, command = requireClaudeLocalCliPath(options)) {
382
- if (options.services?.createClaudeCliClient) {
383
- return options.services.createClaudeCliClient({
384
- cwd: options.cwd,
385
- signal: options.signal,
386
- command,
387
- ...(options.runtimeEnv ? { env: options.runtimeEnv } : {}),
388
- });
389
- }
390
- return createClaudeCodeCliClient(createClaudeCodeCliStdioTransport({
391
- command,
392
- ...(options.runtimeEnv ? { env: options.runtimeEnv } : {}),
393
- }));
394
- }
395
- function isNativeCliBinaryPath(value) {
396
- return typeof value === 'string' && value.trim().length > 0 && !value.startsWith('sdk:');
397
- }
398
- function requireClaudeLocalCliPath(options) {
399
- if (isNativeCliBinaryPath(options.runtime.binaryPath))
400
- return options.runtime.binaryPath;
401
- throw new Error('Claude Code requires a local claude executable detected by MindOS. MindOS does not bundle the Claude Agent SDK native runtime.');
402
- }
403
- async function handleCodexServerRequest(request, options, pendingServerRequests) {
404
- if (isCodexUserInputRequest(request)) {
405
- return handleCodexUserInputRequest(request, options, pendingServerRequests);
406
- }
407
- if (!isCodexApprovalRequest(request)) {
408
- throw new Error(`Unhandled Codex app-server request: ${request.method}`);
409
- }
410
- const permissionRequest = buildCodexPermissionRequest(request);
411
- const result = await withCodexPendingServerRequest(request, {
412
- kind: 'permission',
413
- toolCallId: permissionRequest.toolCallId,
414
- signal: options.signal,
415
- pendingServerRequests,
416
- }, async (signal) => (options.services?.requestRuntimePermission
417
- ? await options.services.requestRuntimePermission(permissionRequest, { signal })
418
- : { decision: 'cancel', cancelled: true }));
419
- if (request.method === 'item/permissions/requestApproval') {
420
- return codexPermissionsApprovalResult(request, result);
421
- }
422
- return {
423
- decision: result.cancelled ? 'cancel' : normalizeCodexApprovalDecision(result.decision),
424
- };
425
- }
426
- async function handleCodexUserInputRequest(request, options, pendingServerRequests) {
427
- const questionRequest = buildCodexUserQuestionRequest(request);
428
- const result = await withCodexPendingServerRequest(request, {
429
- kind: 'question',
430
- toolCallId: questionRequest.toolCallId,
431
- signal: options.signal,
432
- pendingServerRequests,
433
- }, async (signal) => (options.services?.requestUserQuestion
434
- ? await options.services.requestUserQuestion(questionRequest, { signal })
435
- : { answers: [], cancelled: true, error: 'no_bridge' }));
436
- if (result.cancelled) {
437
- return { cancelled: true, answers: [], error: result.error ?? 'cancelled' };
438
- }
439
- return {
440
- answers: result.answers.map((answer) => ({
441
- questionIndex: answer.questionIndex,
442
- question: answer.question,
443
- answer: answer.answer,
444
- ...(answer.selected ? { selected: answer.selected } : {}),
445
- ...(answer.kind ? { kind: answer.kind } : {}),
446
- })),
447
- };
448
- }
449
- function isCodexUserInputRequest(request) {
450
- return request.method === 'item/tool/requestUserInput'
451
- || request.method === 'tool/requestUserInput';
452
- }
453
- function isCodexApprovalRequest(request) {
454
- return request.method === 'item/commandExecution/requestApproval'
455
- || request.method === 'item/fileChange/requestApproval'
456
- || request.method === 'item/permissions/requestApproval'
457
- || /approval|permission/i.test(request.method);
458
- }
459
- async function withCodexPendingServerRequest(request, input, callback) {
460
- if (!input.pendingServerRequests)
461
- return callback(input.signal);
462
- const abortController = new AbortController();
463
- const abortFromParent = () => abortController.abort();
464
- if (input.signal?.aborted) {
465
- abortController.abort();
466
- }
467
- else {
468
- input.signal?.addEventListener('abort', abortFromParent, { once: true });
469
- }
470
- const keys = codexServerRequestKeys(request);
471
- const pending = {
472
- requestId: request.id,
473
- toolCallId: input.toolCallId,
474
- kind: input.kind,
475
- abortController,
476
- cleanup: () => {
477
- input.signal?.removeEventListener('abort', abortFromParent);
478
- for (const key of keys) {
479
- if (input.pendingServerRequests?.get(key) === pending) {
480
- input.pendingServerRequests.delete(key);
481
- }
482
- }
483
- },
484
- };
485
- for (const key of keys)
486
- input.pendingServerRequests.set(key, pending);
487
- try {
488
- return await callback(abortController.signal);
489
- }
490
- finally {
491
- pending.cleanup();
492
- }
493
- }
494
- function abortCodexPendingServerRequest(params, pendingServerRequests) {
495
- const keys = codexServerRequestResolvedKeys(params);
496
- for (const key of keys) {
497
- const pending = pendingServerRequests.get(key);
498
- if (!pending)
499
- continue;
500
- pending.abortController.abort();
501
- pending.cleanup();
502
- return true;
503
- }
504
- return false;
505
- }
506
- function abortAllCodexPendingServerRequests(pendingServerRequests) {
507
- const pending = new Set(pendingServerRequests.values());
508
- pendingServerRequests.clear();
509
- for (const request of pending) {
510
- request.abortController.abort();
511
- request.cleanup();
512
- }
513
- }
514
- function codexServerRequestKeys(request) {
515
- const params = request.params ?? {};
516
- return uniqueStrings([
517
- String(request.id),
518
- getIdLike(params, 'requestId'),
519
- getIdLike(params, 'serverRequestId'),
520
- getIdLike(params, 'jsonrpcId'),
521
- getIdLike(params, 'itemId'),
522
- getIdLike(params, 'callId'),
523
- getIdLike(params, 'id'),
524
- ]);
525
- }
526
- function codexServerRequestResolvedKeys(params) {
527
- return uniqueStrings([
528
- getIdLike(params, 'requestId'),
529
- getIdLike(params, 'serverRequestId'),
530
- getIdLike(params, 'jsonrpcId'),
531
- getIdLike(params, 'itemId'),
532
- getIdLike(params, 'callId'),
533
- getIdLike(params, 'id'),
534
- ]);
535
- }
536
- function buildCodexPermissionRequest(request) {
537
- const params = request.params ?? {};
538
- const toolCallId = getString(params, 'itemId')
539
- ?? getString(params, 'requestId')
540
- ?? getString(params, 'callId')
541
- ?? getString(params, 'id')
542
- ?? `codex-approval-${request.id}`;
543
- const command = getString(params, 'command')
544
- ?? getString(params, 'cmd')
545
- ?? getString(params, 'shellCommand');
546
- const filePath = getString(params, 'path')
547
- ?? getString(params, 'filePath')
548
- ?? getString(params, 'targetPath');
549
- const toolName = request.method === 'item/fileChange/requestApproval'
550
- ? 'file_change_approval'
551
- : command
552
- ? 'Bash'
553
- : 'approval_request';
554
- const action = request.method === 'item/fileChange/requestApproval'
555
- ? 'file-change'
556
- : command
557
- ? 'command'
558
- : 'tool-call';
559
- return {
560
- runtime: 'codex',
561
- toolCallId,
562
- toolName,
563
- input: {
564
- method: request.method,
565
- ...params,
566
- },
567
- options: getCodexPermissionOptions(params, request.method),
568
- action,
569
- ...(command || filePath ? { resource: command ?? filePath } : {}),
570
- ...(getString(params, 'reason') ?? getString(params, 'message') ? {
571
- reason: getString(params, 'reason') ?? getString(params, 'message'),
572
- } : {}),
573
- };
574
- }
575
- function buildCodexUserQuestionRequest(request) {
576
- const params = request.params ?? {};
577
- const toolCallId = getString(params, 'itemId')
578
- ?? getString(params, 'requestId')
579
- ?? getString(params, 'callId')
580
- ?? getString(params, 'id')
581
- ?? `codex-question-${request.id}`;
582
- const questions = normalizeCodexUserQuestions(params);
583
- return {
584
- runtime: 'codex',
585
- toolCallId,
586
- questions: questions.length > 0 ? questions : [{
587
- question: getString(params, 'message') ?? getString(params, 'reason') ?? 'Codex needs your input to continue.',
588
- header: getString(params, 'title') ?? 'Codex input',
589
- options: [
590
- { label: 'Continue', description: 'Allow Codex to continue with this request.' },
591
- { label: 'Cancel', description: 'Cancel this request.' },
592
- ],
593
- }],
594
- };
595
- }
596
- function normalizeCodexUserQuestions(params) {
597
- const rawQuestions = Array.isArray(params.questions)
598
- ? params.questions
599
- : isRecord(params.input) && Array.isArray(params.input.questions)
600
- ? params.input.questions
601
- : [];
602
- return rawQuestions
603
- .filter(isRecord)
604
- .map((question, index) => ({
605
- question: getString(question, 'question') ?? getString(question, 'text') ?? getString(question, 'message') ?? `Question ${index + 1}`,
606
- header: getString(question, 'header') ?? getString(question, 'title') ?? `Question ${index + 1}`,
607
- multiSelect: question.multiSelect === true || question.multiselect === true,
608
- options: normalizeCodexUserQuestionOptions(question.options),
609
- }));
610
- }
611
- function normalizeCodexUserQuestionOptions(value) {
612
- if (!Array.isArray(value))
613
- return [];
614
- return value.flatMap((option) => {
615
- if (typeof option === 'string' && option.trim()) {
616
- return [{ label: option, description: option }];
617
- }
618
- if (!isRecord(option))
619
- return [];
620
- const label = getString(option, 'label')
621
- ?? getString(option, 'value')
622
- ?? getString(option, 'title')
623
- ?? (option.isOther === true ? 'Other' : undefined);
624
- if (!label)
625
- return [];
626
- return [{
627
- label,
628
- description: getString(option, 'description') ?? getString(option, 'hint') ?? label,
629
- ...(getString(option, 'preview') ? { preview: getString(option, 'preview') } : {}),
630
- }];
631
- });
632
- }
633
- function getCodexPermissionOptions(params, method) {
634
- const fromParams = [
635
- ...stringArray(params.availableDecisions),
636
- ...stringArray(params.decisions),
637
- ...stringArray(params.options),
638
- ].map(decisionOption);
639
- if (fromParams.length > 0)
640
- return dedupeOptions(fromParams);
641
- const defaults = method === 'item/permissions/requestApproval'
642
- ? ['accept', 'acceptForSession', 'decline']
643
- : ['accept', 'acceptForSession', 'decline'];
644
- return defaults.map(decisionOption);
645
- }
646
- function decisionOption(id) {
647
- const labels = {
648
- accept: 'Allow once',
649
- acceptForSession: 'Allow session',
650
- decline: 'Deny',
651
- cancel: 'Cancel',
652
- deny: 'Deny',
653
- };
654
- const descriptions = {
655
- accept: 'Run this action one time.',
656
- acceptForSession: 'Run this action and remember the same rule for this Codex session.',
657
- decline: 'Reject this action.',
658
- cancel: 'Cancel the pending action.',
659
- };
660
- return {
661
- id,
662
- label: labels[id] ?? id,
663
- ...(descriptions[id] ? { description: descriptions[id] } : {}),
664
- intent: id === 'accept' || id === 'acceptForSession' ? 'allow' : id === 'decline' || id === 'deny' ? 'deny' : 'cancel',
665
- ...(id === 'accept' ? { scope: 'once' } : {}),
666
- ...(id === 'acceptForSession' ? { scope: 'session' } : {}),
667
- };
668
- }
669
- function dedupeOptions(options) {
670
- const seen = new Set();
671
- return options.filter((option) => {
672
- if (!option.id || seen.has(option.id))
673
- return false;
674
- seen.add(option.id);
675
- return true;
676
- });
677
- }
678
- function normalizeCodexApprovalDecision(decision) {
679
- if (decision === 'accept' || decision === 'acceptForSession' || decision === 'decline' || decision === 'cancel') {
680
- return decision;
681
- }
682
- if (decision === 'deny' || decision === 'denied')
683
- return 'decline';
684
- return 'cancel';
685
- }
686
- function codexPermissionsApprovalResult(request, result) {
687
- const decision = result.cancelled ? 'cancel' : normalizeCodexApprovalDecision(result.decision);
688
- if (decision === 'decline' || decision === 'cancel')
689
- return { permissions: {} };
690
- const requestedPermissions = request.params?.permissions && typeof request.params.permissions === 'object'
691
- ? request.params.permissions
692
- : {};
693
- return {
694
- permissions: requestedPermissions,
695
- ...(decision === 'acceptForSession' ? { scope: 'session' } : {}),
696
- };
697
- }
698
- function stringArray(value) {
699
- if (!Array.isArray(value))
700
- return [];
701
- return value.filter((item) => typeof item === 'string' && item.trim().length > 0);
702
- }
703
- function uniqueStrings(values) {
704
- return Array.from(new Set(values.filter((value) => Boolean(value))));
705
- }
706
- function isRecord(value) {
707
- return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
708
- }
709
- function getIdLike(record, key) {
710
- const value = record?.[key];
711
- if (typeof value === 'string' && value.trim())
712
- return value;
713
- if (typeof value === 'number' && Number.isFinite(value))
714
- return String(value);
715
- return undefined;
716
- }
717
- function getString(record, key) {
718
- const value = record[key];
719
- return typeof value === 'string' && value.trim() ? value : undefined;
720
- }
1
+ export * from '../agent/runtime/run.js';
721
2
  //# sourceMappingURL=run.js.map