@jingyi0605/codingns4dsh 0.2.1-beta.9 → 0.2.1-rc.3

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 (938) hide show
  1. package/README.en.md +10 -6
  2. package/README.md +12 -9
  3. package/assets/provider-icons/magpie.png +0 -0
  4. package/data/build/dist/bootstrap/dsh-connection-adapter.d.ts +1 -1
  5. package/data/build/dist/bootstrap/dsh-connection-adapter.d.ts.map +1 -1
  6. package/data/build/dist/bootstrap/index.d.ts +1 -1
  7. package/data/build/dist/bootstrap/index.d.ts.map +1 -1
  8. package/data/build/dist/client/account-bar.d.ts.map +1 -1
  9. package/data/build/dist/client/account-bar.js +24 -70
  10. package/data/build/dist/client/account-bar.js.map +1 -1
  11. package/data/build/dist/client/adapter-catalog-watch.d.ts +10 -2
  12. package/data/build/dist/client/adapter-catalog-watch.d.ts.map +1 -1
  13. package/data/build/dist/client/adapter-catalog-watch.js +16 -4
  14. package/data/build/dist/client/adapter-catalog-watch.js.map +1 -1
  15. package/data/build/dist/client/bundle.js +55627 -31591
  16. package/data/build/dist/client/bundle.js.map +1 -1
  17. package/data/build/dist/client/cli-management-dialog.d.ts +21 -0
  18. package/data/build/dist/client/cli-management-dialog.d.ts.map +1 -0
  19. package/data/build/dist/client/cli-management-dialog.js +215 -0
  20. package/data/build/dist/client/cli-management-dialog.js.map +1 -0
  21. package/data/build/dist/client/cli-management-terminal.d.ts +9 -0
  22. package/data/build/dist/client/cli-management-terminal.d.ts.map +1 -0
  23. package/data/build/dist/client/cli-management-terminal.js +30 -0
  24. package/data/build/dist/client/cli-management-terminal.js.map +1 -0
  25. package/data/build/dist/client/cli-settings-dialog.d.ts +9 -0
  26. package/data/build/dist/client/cli-settings-dialog.d.ts.map +1 -0
  27. package/data/build/dist/client/cli-settings-dialog.js +45 -0
  28. package/data/build/dist/client/cli-settings-dialog.js.map +1 -0
  29. package/data/build/dist/client/cli-settings-rpc.js +1 -1
  30. package/data/build/dist/client/cli-settings-rpc.js.map +1 -1
  31. package/data/build/dist/client/cli-slots.d.ts +17 -3
  32. package/data/build/dist/client/cli-slots.d.ts.map +1 -1
  33. package/data/build/dist/client/cli-slots.js +300 -41
  34. package/data/build/dist/client/cli-slots.js.map +1 -1
  35. package/data/build/dist/client/client.assistant-configuration-view.js +4 -3
  36. package/data/build/dist/client/client.assistant-configuration-view.js.map +1 -1
  37. package/data/build/dist/client/client.delegate-command.js +44 -26
  38. package/data/build/dist/client/client.delegate-command.js.map +1 -1
  39. package/data/build/dist/client/client.editor-engine.js +4 -1
  40. package/data/build/dist/client/client.editor-engine.js.map +1 -1
  41. package/data/build/dist/client/{client.model-catalog-cache.js → client.magpie-model-tag.js} +393 -14
  42. package/data/build/dist/client/client.magpie-model-tag.js.map +1 -0
  43. package/data/build/dist/client/client.moss-voice-output.js +415 -0
  44. package/data/build/dist/client/client.moss-voice-output.js.map +1 -0
  45. package/data/build/dist/client/client.native-workspace-store.js +91 -15
  46. package/data/build/dist/client/client.native-workspace-store.js.map +1 -1
  47. package/data/build/dist/client/client.primitives-adapter.js +128 -0
  48. package/data/build/dist/client/client.primitives-adapter.js.map +1 -1
  49. package/data/build/dist/client/client.react-dom.js +0 -404
  50. package/data/build/dist/client/client.react-dom.js.map +1 -1
  51. package/data/build/dist/client/client.session-translation.js +121 -2
  52. package/data/build/dist/client/client.session-translation.js.map +1 -1
  53. package/data/build/dist/client/client.transport.js +1415 -57
  54. package/data/build/dist/client/client.transport.js.map +1 -1
  55. package/data/build/dist/client/conversation-translation-settings.d.ts +11 -0
  56. package/data/build/dist/client/conversation-translation-settings.d.ts.map +1 -0
  57. package/data/build/dist/client/conversation-translation-settings.js +54 -0
  58. package/data/build/dist/client/conversation-translation-settings.js.map +1 -0
  59. package/data/build/dist/client/delegate-command.d.ts.map +1 -1
  60. package/data/build/dist/client/delegate-command.js +36 -7
  61. package/data/build/dist/client/delegate-command.js.map +1 -1
  62. package/data/build/dist/client/desktop-assistant.js +1948 -494
  63. package/data/build/dist/client/editor-engine.d.ts +1 -1
  64. package/data/build/dist/client/editor-engine.d.ts.map +1 -1
  65. package/data/build/dist/client/editor-engine.js +4 -1
  66. package/data/build/dist/client/editor-engine.js.map +1 -1
  67. package/data/build/dist/client/feature-requirement.d.ts +43 -0
  68. package/data/build/dist/client/feature-requirement.d.ts.map +1 -0
  69. package/data/build/dist/client/feature-requirement.js +105 -0
  70. package/data/build/dist/client/feature-requirement.js.map +1 -0
  71. package/data/build/dist/client/features/cli-adapters.d.ts +3 -1
  72. package/data/build/dist/client/features/cli-adapters.d.ts.map +1 -1
  73. package/data/build/dist/client/features/cli-adapters.js +207 -112
  74. package/data/build/dist/client/features/cli-adapters.js.map +1 -1
  75. package/data/build/dist/client/features/file-management.d.ts.map +1 -1
  76. package/data/build/dist/client/features/file-management.js +18 -0
  77. package/data/build/dist/client/features/file-management.js.map +1 -1
  78. package/data/build/dist/client/features/index.d.ts +1 -0
  79. package/data/build/dist/client/features/index.d.ts.map +1 -1
  80. package/data/build/dist/client/features/index.js +5 -0
  81. package/data/build/dist/client/features/index.js.map +1 -1
  82. package/data/build/dist/client/features/lan-access-panel.d.ts.map +1 -1
  83. package/data/build/dist/client/features/lan-access-panel.js +1 -0
  84. package/data/build/dist/client/features/lan-access-panel.js.map +1 -1
  85. package/data/build/dist/client/features/magpie-management-controls.d.ts +46 -0
  86. package/data/build/dist/client/features/magpie-management-controls.d.ts.map +1 -0
  87. package/data/build/dist/client/features/magpie-management-controls.js +759 -0
  88. package/data/build/dist/client/features/magpie-management-controls.js.map +1 -0
  89. package/data/build/dist/client/features/magpie-management-page.d.ts +124 -0
  90. package/data/build/dist/client/features/magpie-management-page.d.ts.map +1 -0
  91. package/data/build/dist/client/features/magpie-management-page.js +1256 -0
  92. package/data/build/dist/client/features/magpie-management-page.js.map +1 -0
  93. package/data/build/dist/client/features/magpie-management.d.ts +7 -0
  94. package/data/build/dist/client/features/magpie-management.d.ts.map +1 -0
  95. package/data/build/dist/client/features/magpie-management.js +154 -0
  96. package/data/build/dist/client/features/magpie-management.js.map +1 -0
  97. package/data/build/dist/client/features/magpie-mark.d.ts +10 -0
  98. package/data/build/dist/client/features/magpie-mark.d.ts.map +1 -0
  99. package/data/build/dist/client/features/magpie-mark.js +21 -0
  100. package/data/build/dist/client/features/magpie-mark.js.map +1 -0
  101. package/data/build/dist/client/features/magpie-provider-logo.d.ts +11 -0
  102. package/data/build/dist/client/features/magpie-provider-logo.d.ts.map +1 -0
  103. package/data/build/dist/client/features/magpie-provider-logo.js +35 -0
  104. package/data/build/dist/client/features/magpie-provider-logo.js.map +1 -0
  105. package/data/build/dist/client/features/mobile-access.d.ts.map +1 -1
  106. package/data/build/dist/client/features/mobile-access.js +7 -0
  107. package/data/build/dist/client/features/mobile-access.js.map +1 -1
  108. package/data/build/dist/client/features/peer-host.d.ts.map +1 -1
  109. package/data/build/dist/client/features/peer-host.js +6 -0
  110. package/data/build/dist/client/features/peer-host.js.map +1 -1
  111. package/data/build/dist/client/features/quick-apps.d.ts +3 -0
  112. package/data/build/dist/client/features/quick-apps.d.ts.map +1 -0
  113. package/data/build/dist/client/features/quick-apps.js +14 -0
  114. package/data/build/dist/client/features/quick-apps.js.map +1 -0
  115. package/data/build/dist/client/features/session-translation.d.ts.map +1 -1
  116. package/data/build/dist/client/features/session-translation.js +50 -49
  117. package/data/build/dist/client/features/session-translation.js.map +1 -1
  118. package/data/build/dist/client/features/subscription-quota-groups.d.ts +193 -0
  119. package/data/build/dist/client/features/subscription-quota-groups.d.ts.map +1 -0
  120. package/data/build/dist/client/features/subscription-quota-groups.js +548 -0
  121. package/data/build/dist/client/features/subscription-quota-groups.js.map +1 -0
  122. package/data/build/dist/client/features/workspace-session-enhancement.d.ts.map +1 -1
  123. package/data/build/dist/client/features/workspace-session-enhancement.js +6 -0
  124. package/data/build/dist/client/features/workspace-session-enhancement.js.map +1 -1
  125. package/data/build/dist/client/file-management-dom.d.ts +20 -1
  126. package/data/build/dist/client/file-management-dom.d.ts.map +1 -1
  127. package/data/build/dist/client/file-management-dom.js +94 -18
  128. package/data/build/dist/client/file-management-dom.js.map +1 -1
  129. package/data/build/dist/client/file-viewer-copy-path-menu.d.ts +27 -0
  130. package/data/build/dist/client/file-viewer-copy-path-menu.d.ts.map +1 -0
  131. package/data/build/dist/client/file-viewer-copy-path-menu.js +101 -0
  132. package/data/build/dist/client/file-viewer-copy-path-menu.js.map +1 -0
  133. package/data/build/dist/client/git-management-settings.d.ts +4 -0
  134. package/data/build/dist/client/git-management-settings.d.ts.map +1 -0
  135. package/data/build/dist/client/git-management-settings.js +73 -0
  136. package/data/build/dist/client/git-management-settings.js.map +1 -0
  137. package/data/build/dist/client/git-management.d.ts +2 -1
  138. package/data/build/dist/client/git-management.d.ts.map +1 -1
  139. package/data/build/dist/client/git-management.js +64 -41
  140. package/data/build/dist/client/git-management.js.map +1 -1
  141. package/data/build/dist/client/git-panel-styles.d.ts +4 -0
  142. package/data/build/dist/client/git-panel-styles.d.ts.map +1 -1
  143. package/data/build/dist/client/git-panel-styles.js +15 -0
  144. package/data/build/dist/client/git-panel-styles.js.map +1 -1
  145. package/data/build/dist/client/html-workspace-files.d.ts +4 -0
  146. package/data/build/dist/client/html-workspace-files.d.ts.map +1 -0
  147. package/data/build/dist/client/html-workspace-files.js +114 -0
  148. package/data/build/dist/client/html-workspace-files.js.map +1 -0
  149. package/data/build/dist/client/index.d.ts +1 -1
  150. package/data/build/dist/client/index.d.ts.map +1 -1
  151. package/data/build/dist/client/index.js +1 -1
  152. package/data/build/dist/client/index.js.map +1 -1
  153. package/data/build/dist/client/locale.d.ts.map +1 -1
  154. package/data/build/dist/client/locale.js +29 -2
  155. package/data/build/dist/client/locale.js.map +1 -1
  156. package/data/build/dist/client/locales/cliManagement.d.ts +3 -0
  157. package/data/build/dist/client/locales/cliManagement.d.ts.map +1 -0
  158. package/data/build/dist/client/locales/cliManagement.js +155 -0
  159. package/data/build/dist/client/locales/cliManagement.js.map +1 -0
  160. package/data/build/dist/client/locales/fileWorkspace.d.ts.map +1 -1
  161. package/data/build/dist/client/locales/fileWorkspace.js +8 -0
  162. package/data/build/dist/client/locales/fileWorkspace.js.map +1 -1
  163. package/data/build/dist/client/locales/git.d.ts.map +1 -1
  164. package/data/build/dist/client/locales/git.js +30 -2
  165. package/data/build/dist/client/locales/git.js.map +1 -1
  166. package/data/build/dist/client/locales/magpie.d.ts +4 -0
  167. package/data/build/dist/client/locales/magpie.d.ts.map +1 -0
  168. package/data/build/dist/client/locales/magpie.js +622 -0
  169. package/data/build/dist/client/locales/magpie.js.map +1 -0
  170. package/data/build/dist/client/locales/panels.d.ts.map +1 -1
  171. package/data/build/dist/client/locales/panels.js +103 -11
  172. package/data/build/dist/client/locales/panels.js.map +1 -1
  173. package/data/build/dist/client/locales/peerHost.d.ts.map +1 -1
  174. package/data/build/dist/client/locales/peerHost.js +2 -0
  175. package/data/build/dist/client/locales/peerHost.js.map +1 -1
  176. package/data/build/dist/client/locales/quickApps.d.ts +136 -0
  177. package/data/build/dist/client/locales/quickApps.d.ts.map +1 -0
  178. package/data/build/dist/client/locales/quickApps.js +162 -0
  179. package/data/build/dist/client/locales/quickApps.js.map +1 -0
  180. package/data/build/dist/client/locales/usage.d.ts.map +1 -1
  181. package/data/build/dist/client/locales/usage.js +150 -0
  182. package/data/build/dist/client/locales/usage.js.map +1 -1
  183. package/data/build/dist/client/magpie-model-tag.d.ts +16 -0
  184. package/data/build/dist/client/magpie-model-tag.d.ts.map +1 -0
  185. package/data/build/dist/client/magpie-model-tag.js +62 -0
  186. package/data/build/dist/client/magpie-model-tag.js.map +1 -0
  187. package/data/build/dist/client/mobile-team-panel-dom.d.ts +14 -0
  188. package/data/build/dist/client/mobile-team-panel-dom.d.ts.map +1 -0
  189. package/data/build/dist/client/mobile-team-panel-dom.js +164 -0
  190. package/data/build/dist/client/mobile-team-panel-dom.js.map +1 -0
  191. package/data/build/dist/client/model-catalog-cache.d.ts.map +1 -1
  192. package/data/build/dist/client/model-catalog-cache.js +66 -12
  193. package/data/build/dist/client/model-catalog-cache.js.map +1 -1
  194. package/data/build/dist/client/model-priority-pool.d.ts +23 -0
  195. package/data/build/dist/client/model-priority-pool.d.ts.map +1 -0
  196. package/data/build/dist/client/model-priority-pool.js +245 -0
  197. package/data/build/dist/client/model-priority-pool.js.map +1 -0
  198. package/data/build/dist/client/native-model-translation-menu.d.ts +13 -0
  199. package/data/build/dist/client/native-model-translation-menu.d.ts.map +1 -0
  200. package/data/build/dist/client/native-model-translation-menu.js +159 -0
  201. package/data/build/dist/client/native-model-translation-menu.js.map +1 -0
  202. package/data/build/dist/client/native-translation-default.d.ts +6 -0
  203. package/data/build/dist/client/native-translation-default.d.ts.map +1 -0
  204. package/data/build/dist/client/native-translation-default.js +30 -0
  205. package/data/build/dist/client/native-translation-default.js.map +1 -0
  206. package/data/build/dist/client/provider-icons.d.ts +8 -0
  207. package/data/build/dist/client/provider-icons.d.ts.map +1 -1
  208. package/data/build/dist/client/provider-icons.js +125 -3
  209. package/data/build/dist/client/provider-icons.js.map +1 -1
  210. package/data/build/dist/client/quick-apps/browser-storage.d.ts +24 -0
  211. package/data/build/dist/client/quick-apps/browser-storage.d.ts.map +1 -0
  212. package/data/build/dist/client/quick-apps/browser-storage.js +114 -0
  213. package/data/build/dist/client/quick-apps/browser-storage.js.map +1 -0
  214. package/data/build/dist/client/quick-apps/client.d.ts +31 -0
  215. package/data/build/dist/client/quick-apps/client.d.ts.map +1 -0
  216. package/data/build/dist/client/quick-apps/client.js +68 -0
  217. package/data/build/dist/client/quick-apps/client.js.map +1 -0
  218. package/data/build/dist/client/quick-apps/document.d.ts +26 -0
  219. package/data/build/dist/client/quick-apps/document.d.ts.map +1 -0
  220. package/data/build/dist/client/quick-apps/document.js +110 -0
  221. package/data/build/dist/client/quick-apps/document.js.map +1 -0
  222. package/data/build/dist/client/quick-apps/file-picker.d.ts +14 -0
  223. package/data/build/dist/client/quick-apps/file-picker.d.ts.map +1 -0
  224. package/data/build/dist/client/quick-apps/file-picker.js +51 -0
  225. package/data/build/dist/client/quick-apps/file-picker.js.map +1 -0
  226. package/data/build/dist/client/quick-apps/launcher.d.ts +7 -0
  227. package/data/build/dist/client/quick-apps/launcher.d.ts.map +1 -0
  228. package/data/build/dist/client/quick-apps/launcher.js +267 -0
  229. package/data/build/dist/client/quick-apps/launcher.js.map +1 -0
  230. package/data/build/dist/client/quick-apps/presentation.d.ts +16 -0
  231. package/data/build/dist/client/quick-apps/presentation.d.ts.map +1 -0
  232. package/data/build/dist/client/quick-apps/presentation.js +47 -0
  233. package/data/build/dist/client/quick-apps/presentation.js.map +1 -0
  234. package/data/build/dist/client/quick-apps/rail-preference.d.ts +5 -0
  235. package/data/build/dist/client/quick-apps/rail-preference.d.ts.map +1 -0
  236. package/data/build/dist/client/quick-apps/rail-preference.js +19 -0
  237. package/data/build/dist/client/quick-apps/rail-preference.js.map +1 -0
  238. package/data/build/dist/client/quick-apps/reorder-animation.d.ts +6 -0
  239. package/data/build/dist/client/quick-apps/reorder-animation.d.ts.map +1 -0
  240. package/data/build/dist/client/quick-apps/reorder-animation.js +50 -0
  241. package/data/build/dist/client/quick-apps/reorder-animation.js.map +1 -0
  242. package/data/build/dist/client/quick-apps/reorder.d.ts +26 -0
  243. package/data/build/dist/client/quick-apps/reorder.d.ts.map +1 -0
  244. package/data/build/dist/client/quick-apps/reorder.js +128 -0
  245. package/data/build/dist/client/quick-apps/reorder.js.map +1 -0
  246. package/data/build/dist/client/quick-apps/styles.d.ts +3 -0
  247. package/data/build/dist/client/quick-apps/styles.d.ts.map +1 -0
  248. package/data/build/dist/client/quick-apps/styles.js +153 -0
  249. package/data/build/dist/client/quick-apps/styles.js.map +1 -0
  250. package/data/build/dist/client/quick-apps/ui.d.ts +20 -0
  251. package/data/build/dist/client/quick-apps/ui.d.ts.map +1 -0
  252. package/data/build/dist/client/quick-apps/ui.js +21 -0
  253. package/data/build/dist/client/quick-apps/ui.js.map +1 -0
  254. package/data/build/dist/client/quick-apps/viewer.d.ts +16 -0
  255. package/data/build/dist/client/quick-apps/viewer.d.ts.map +1 -0
  256. package/data/build/dist/client/quick-apps/viewer.js +165 -0
  257. package/data/build/dist/client/quick-apps/viewer.js.map +1 -0
  258. package/data/build/dist/client/quick-apps/workspace-picker.d.ts +19 -0
  259. package/data/build/dist/client/quick-apps/workspace-picker.d.ts.map +1 -0
  260. package/data/build/dist/client/quick-apps/workspace-picker.js +30 -0
  261. package/data/build/dist/client/quick-apps/workspace-picker.js.map +1 -0
  262. package/data/build/dist/client/session-translation-chat.d.ts +68 -2
  263. package/data/build/dist/client/session-translation-chat.d.ts.map +1 -1
  264. package/data/build/dist/client/session-translation-chat.js +297 -109
  265. package/data/build/dist/client/session-translation-chat.js.map +1 -1
  266. package/data/build/dist/client/session-translation-interactions.d.ts +31 -0
  267. package/data/build/dist/client/session-translation-interactions.d.ts.map +1 -0
  268. package/data/build/dist/client/session-translation-interactions.js +158 -0
  269. package/data/build/dist/client/session-translation-interactions.js.map +1 -0
  270. package/data/build/dist/client/session-translation-pending-dom.d.ts +8 -0
  271. package/data/build/dist/client/session-translation-pending-dom.d.ts.map +1 -0
  272. package/data/build/dist/client/session-translation-pending-dom.js +58 -0
  273. package/data/build/dist/client/session-translation-pending-dom.js.map +1 -0
  274. package/data/build/dist/client/session-translation-retry.d.ts +16 -0
  275. package/data/build/dist/client/session-translation-retry.d.ts.map +1 -0
  276. package/data/build/dist/client/session-translation-retry.js +66 -0
  277. package/data/build/dist/client/session-translation-retry.js.map +1 -0
  278. package/data/build/dist/client/session-translation-rules.d.ts +13 -0
  279. package/data/build/dist/client/session-translation-rules.d.ts.map +1 -0
  280. package/data/build/dist/client/session-translation-rules.js +58 -0
  281. package/data/build/dist/client/session-translation-rules.js.map +1 -0
  282. package/data/build/dist/client/settings-bridge.d.ts +1 -0
  283. package/data/build/dist/client/settings-bridge.d.ts.map +1 -1
  284. package/data/build/dist/client/settings-bridge.js +29 -10
  285. package/data/build/dist/client/settings-bridge.js.map +1 -1
  286. package/data/build/dist/client/settings-section.d.ts.map +1 -1
  287. package/data/build/dist/client/settings-section.js +21 -3
  288. package/data/build/dist/client/settings-section.js.map +1 -1
  289. package/data/build/dist/client/sidebar-footer-style.d.ts +13 -0
  290. package/data/build/dist/client/sidebar-footer-style.d.ts.map +1 -0
  291. package/data/build/dist/client/sidebar-footer-style.js +54 -0
  292. package/data/build/dist/client/sidebar-footer-style.js.map +1 -0
  293. package/data/build/dist/client/style.css +279 -276
  294. package/data/build/dist/client/subscription-slot.d.ts +26 -2
  295. package/data/build/dist/client/subscription-slot.d.ts.map +1 -1
  296. package/data/build/dist/client/subscription-slot.js +679 -24
  297. package/data/build/dist/client/subscription-slot.js.map +1 -1
  298. package/data/build/dist/client/terminal/model.d.ts.map +1 -1
  299. package/data/build/dist/client/terminal/model.js +2 -1
  300. package/data/build/dist/client/terminal/model.js.map +1 -1
  301. package/data/build/dist/client/workspace-session-archive-dom.d.ts +1 -0
  302. package/data/build/dist/client/workspace-session-archive-dom.d.ts.map +1 -1
  303. package/data/build/dist/client/workspace-session-archive-dom.js +68 -8
  304. package/data/build/dist/client/workspace-session-archive-dom.js.map +1 -1
  305. package/data/build/dist/client/workspace-session-rightbar-dom.d.ts.map +1 -1
  306. package/data/build/dist/client/workspace-session-rightbar-dom.js +12 -21
  307. package/data/build/dist/client/workspace-session-rightbar-dom.js.map +1 -1
  308. package/data/build/dist/client/workspace-session-visibility-dom.d.ts +3 -0
  309. package/data/build/dist/client/workspace-session-visibility-dom.d.ts.map +1 -1
  310. package/data/build/dist/client/workspace-session-visibility-dom.js +43 -10
  311. package/data/build/dist/client/workspace-session-visibility-dom.js.map +1 -1
  312. package/data/build/dist/dsh-capabilities/client/composer-presentation-adapter.d.ts +8 -0
  313. package/data/build/dist/dsh-capabilities/client/composer-presentation-adapter.d.ts.map +1 -0
  314. package/data/build/dist/dsh-capabilities/client/composer-presentation-adapter.js +71 -0
  315. package/data/build/dist/dsh-capabilities/client/composer-presentation-adapter.js.map +1 -0
  316. package/data/build/dist/dsh-capabilities/client/composer-slot-selectors.d.ts +4 -0
  317. package/data/build/dist/dsh-capabilities/client/composer-slot-selectors.d.ts.map +1 -0
  318. package/data/build/dist/dsh-capabilities/client/composer-slot-selectors.js +8 -0
  319. package/data/build/dist/dsh-capabilities/client/composer-slot-selectors.js.map +1 -0
  320. package/data/build/dist/dsh-capabilities/client/global-panel-adapter.d.ts +27 -0
  321. package/data/build/dist/dsh-capabilities/client/global-panel-adapter.d.ts.map +1 -0
  322. package/data/build/dist/dsh-capabilities/client/global-panel-adapter.js +109 -0
  323. package/data/build/dist/dsh-capabilities/client/global-panel-adapter.js.map +1 -0
  324. package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.d.ts +30 -0
  325. package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.d.ts.map +1 -0
  326. package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.js +93 -0
  327. package/data/build/dist/dsh-capabilities/client/interaction-presentation-adapter.js.map +1 -0
  328. package/data/build/dist/dsh-capabilities/client/interaction-text-dom.d.ts +12 -0
  329. package/data/build/dist/dsh-capabilities/client/interaction-text-dom.d.ts.map +1 -0
  330. package/data/build/dist/dsh-capabilities/client/interaction-text-dom.js +181 -0
  331. package/data/build/dist/dsh-capabilities/client/interaction-text-dom.js.map +1 -0
  332. package/data/build/dist/dsh-capabilities/client/message-presentation-adapter.d.ts +19 -0
  333. package/data/build/dist/dsh-capabilities/client/message-presentation-adapter.d.ts.map +1 -0
  334. package/data/build/dist/dsh-capabilities/client/message-presentation-adapter.js +39 -0
  335. package/data/build/dist/dsh-capabilities/client/message-presentation-adapter.js.map +1 -0
  336. package/data/build/dist/dsh-capabilities/client/peer-host-attachment-adapter.d.ts +3 -0
  337. package/data/build/dist/dsh-capabilities/client/peer-host-attachment-adapter.d.ts.map +1 -0
  338. package/data/build/dist/dsh-capabilities/client/peer-host-attachment-adapter.js +27 -0
  339. package/data/build/dist/dsh-capabilities/client/peer-host-attachment-adapter.js.map +1 -0
  340. package/data/build/dist/dsh-capabilities/client/primitives-adapter.d.ts +36 -0
  341. package/data/build/dist/dsh-capabilities/client/primitives-adapter.d.ts.map +1 -1
  342. package/data/build/dist/dsh-capabilities/client/primitives-adapter.js +88 -0
  343. package/data/build/dist/dsh-capabilities/client/primitives-adapter.js.map +1 -1
  344. package/data/build/dist/dsh-capabilities/client/question-history-adapter.d.ts +20 -0
  345. package/data/build/dist/dsh-capabilities/client/question-history-adapter.d.ts.map +1 -0
  346. package/data/build/dist/dsh-capabilities/client/question-history-adapter.js +65 -0
  347. package/data/build/dist/dsh-capabilities/client/question-history-adapter.js.map +1 -0
  348. package/data/build/dist/dsh-capabilities/client/quick-app-footer-adapter.d.ts +18 -0
  349. package/data/build/dist/dsh-capabilities/client/quick-app-footer-adapter.d.ts.map +1 -0
  350. package/data/build/dist/dsh-capabilities/client/quick-app-footer-adapter.js +11 -0
  351. package/data/build/dist/dsh-capabilities/client/quick-app-footer-adapter.js.map +1 -0
  352. package/data/build/dist/dsh-capabilities/client/session-performance-adapter.d.ts +9 -0
  353. package/data/build/dist/dsh-capabilities/client/session-performance-adapter.d.ts.map +1 -0
  354. package/data/build/dist/dsh-capabilities/client/session-performance-adapter.js +75 -0
  355. package/data/build/dist/dsh-capabilities/client/session-performance-adapter.js.map +1 -0
  356. package/data/build/dist/dsh-capabilities/client/sidebar-footer-icon-adapter.d.ts +3 -0
  357. package/data/build/dist/dsh-capabilities/client/sidebar-footer-icon-adapter.d.ts.map +1 -0
  358. package/data/build/dist/dsh-capabilities/client/sidebar-footer-icon-adapter.js +22 -0
  359. package/data/build/dist/dsh-capabilities/client/sidebar-footer-icon-adapter.js.map +1 -0
  360. package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.d.ts +32 -0
  361. package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.d.ts.map +1 -0
  362. package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.js +90 -0
  363. package/data/build/dist/dsh-capabilities/client/slot-presentation-mirror.js.map +1 -0
  364. package/data/build/dist/dsh-capabilities/host/agent-team-adapter.d.ts +52 -0
  365. package/data/build/dist/dsh-capabilities/host/agent-team-adapter.d.ts.map +1 -0
  366. package/data/build/dist/dsh-capabilities/host/agent-team-adapter.js +109 -0
  367. package/data/build/dist/dsh-capabilities/host/agent-team-adapter.js.map +1 -0
  368. package/data/build/dist/dsh-capabilities/host/connection-peer-adapter.d.ts +10 -0
  369. package/data/build/dist/dsh-capabilities/host/connection-peer-adapter.d.ts.map +1 -0
  370. package/data/build/dist/dsh-capabilities/host/connection-peer-adapter.js +34 -0
  371. package/data/build/dist/dsh-capabilities/host/connection-peer-adapter.js.map +1 -0
  372. package/data/build/dist/dsh-capabilities/host/native-dispatch-adapter.d.ts +21 -0
  373. package/data/build/dist/dsh-capabilities/host/native-dispatch-adapter.d.ts.map +1 -0
  374. package/data/build/dist/dsh-capabilities/host/native-dispatch-adapter.js +11 -0
  375. package/data/build/dist/dsh-capabilities/host/native-dispatch-adapter.js.map +1 -0
  376. package/data/build/dist/dsh-capabilities/host/quick-app-credentials.d.ts +11 -0
  377. package/data/build/dist/dsh-capabilities/host/quick-app-credentials.d.ts.map +1 -0
  378. package/data/build/dist/dsh-capabilities/host/quick-app-credentials.js +97 -0
  379. package/data/build/dist/dsh-capabilities/host/quick-app-credentials.js.map +1 -0
  380. package/data/build/dist/dsh-capabilities/host/quick-app-https-provider.d.ts +36 -0
  381. package/data/build/dist/dsh-capabilities/host/quick-app-https-provider.d.ts.map +1 -0
  382. package/data/build/dist/dsh-capabilities/host/quick-app-https-provider.js +164 -0
  383. package/data/build/dist/dsh-capabilities/host/quick-app-https-provider.js.map +1 -0
  384. package/data/build/dist/dsh-capabilities/host/quick-app-lan-ports.d.ts +44 -0
  385. package/data/build/dist/dsh-capabilities/host/quick-app-lan-ports.d.ts.map +1 -0
  386. package/data/build/dist/dsh-capabilities/host/quick-app-lan-ports.js +240 -0
  387. package/data/build/dist/dsh-capabilities/host/quick-app-lan-ports.js.map +1 -0
  388. package/data/build/dist/dsh-capabilities/host/quick-app-origin-adapter.d.ts +37 -0
  389. package/data/build/dist/dsh-capabilities/host/quick-app-origin-adapter.d.ts.map +1 -0
  390. package/data/build/dist/dsh-capabilities/host/quick-app-origin-adapter.js +35 -0
  391. package/data/build/dist/dsh-capabilities/host/quick-app-origin-adapter.js.map +1 -0
  392. package/data/build/dist/dsh-capabilities/host/quick-app-proxy-adapter.d.ts +13 -0
  393. package/data/build/dist/dsh-capabilities/host/quick-app-proxy-adapter.d.ts.map +1 -0
  394. package/data/build/dist/dsh-capabilities/host/quick-app-proxy-adapter.js +30 -0
  395. package/data/build/dist/dsh-capabilities/host/quick-app-proxy-adapter.js.map +1 -0
  396. package/data/build/dist/dsh-capabilities/host/quick-app-proxy-provider.d.ts +21 -0
  397. package/data/build/dist/dsh-capabilities/host/quick-app-proxy-provider.d.ts.map +1 -0
  398. package/data/build/dist/dsh-capabilities/host/quick-app-proxy-provider.js +132 -0
  399. package/data/build/dist/dsh-capabilities/host/quick-app-proxy-provider.js.map +1 -0
  400. package/data/build/dist/dsh-capabilities/host/quick-app-transport.d.ts +10 -0
  401. package/data/build/dist/dsh-capabilities/host/quick-app-transport.d.ts.map +1 -0
  402. package/data/build/dist/dsh-capabilities/host/quick-app-transport.js +33 -0
  403. package/data/build/dist/dsh-capabilities/host/quick-app-transport.js.map +1 -0
  404. package/data/build/dist/dsh-capabilities/host/session-activation-adapter.d.ts +17 -0
  405. package/data/build/dist/dsh-capabilities/host/session-activation-adapter.d.ts.map +1 -0
  406. package/data/build/dist/dsh-capabilities/host/session-activation-adapter.js +37 -0
  407. package/data/build/dist/dsh-capabilities/host/session-activation-adapter.js.map +1 -0
  408. package/data/build/dist/dsh-capabilities/host/session-model-selection-adapter.d.ts +17 -0
  409. package/data/build/dist/dsh-capabilities/host/session-model-selection-adapter.d.ts.map +1 -0
  410. package/data/build/dist/dsh-capabilities/host/session-model-selection-adapter.js +45 -0
  411. package/data/build/dist/dsh-capabilities/host/session-model-selection-adapter.js.map +1 -0
  412. package/data/build/dist/dsh-capabilities/host/session-performance-adapter.d.ts +7 -0
  413. package/data/build/dist/dsh-capabilities/host/session-performance-adapter.d.ts.map +1 -0
  414. package/data/build/dist/dsh-capabilities/host/session-performance-adapter.js +18 -0
  415. package/data/build/dist/dsh-capabilities/host/session-performance-adapter.js.map +1 -0
  416. package/data/build/dist/dsh-capabilities/host/session-prompt-adapter.d.ts +28 -0
  417. package/data/build/dist/dsh-capabilities/host/session-prompt-adapter.d.ts.map +1 -0
  418. package/data/build/dist/dsh-capabilities/host/session-prompt-adapter.js +31 -0
  419. package/data/build/dist/dsh-capabilities/host/session-prompt-adapter.js.map +1 -0
  420. package/data/build/dist/dsh-capabilities/host/session-title-adapter.d.ts +2 -1
  421. package/data/build/dist/dsh-capabilities/host/session-title-adapter.d.ts.map +1 -1
  422. package/data/build/dist/dsh-capabilities/host/session-title-adapter.js +32 -2
  423. package/data/build/dist/dsh-capabilities/host/session-title-adapter.js.map +1 -1
  424. package/data/build/dist/dsh-capabilities/host/workspace-directory-adapter.d.ts +13 -0
  425. package/data/build/dist/dsh-capabilities/host/workspace-directory-adapter.d.ts.map +1 -0
  426. package/data/build/dist/dsh-capabilities/host/workspace-directory-adapter.js +24 -0
  427. package/data/build/dist/dsh-capabilities/host/workspace-directory-adapter.js.map +1 -0
  428. package/data/build/dist/dsh-capabilities/matrix.d.ts.map +1 -1
  429. package/data/build/dist/dsh-capabilities/matrix.js +23 -5
  430. package/data/build/dist/dsh-capabilities/matrix.js.map +1 -1
  431. package/data/build/dist/dsh-capabilities/routes.d.ts +1 -0
  432. package/data/build/dist/dsh-capabilities/routes.d.ts.map +1 -1
  433. package/data/build/dist/dsh-capabilities/routes.js +50 -3
  434. package/data/build/dist/dsh-capabilities/routes.js.map +1 -1
  435. package/data/build/dist/dsh-capabilities/types.d.ts +1 -1
  436. package/data/build/dist/dsh-capabilities/types.d.ts.map +1 -1
  437. package/data/build/dist/dsh-capabilities/types.js.map +1 -1
  438. package/data/build/dist/host/cli-adapters/acp-cli-driver.d.ts +27 -0
  439. package/data/build/dist/host/cli-adapters/acp-cli-driver.d.ts.map +1 -1
  440. package/data/build/dist/host/cli-adapters/acp-cli-driver.js +94 -16
  441. package/data/build/dist/host/cli-adapters/acp-cli-driver.js.map +1 -1
  442. package/data/build/dist/host/cli-adapters/antigravity-driver.js +1 -1
  443. package/data/build/dist/host/cli-adapters/antigravity-driver.js.map +1 -1
  444. package/data/build/dist/host/cli-adapters/attachment-utils.d.ts +4 -3
  445. package/data/build/dist/host/cli-adapters/attachment-utils.d.ts.map +1 -1
  446. package/data/build/dist/host/cli-adapters/attachment-utils.js +9 -8
  447. package/data/build/dist/host/cli-adapters/attachment-utils.js.map +1 -1
  448. package/data/build/dist/host/cli-adapters/binary-detection.d.ts.map +1 -1
  449. package/data/build/dist/host/cli-adapters/binary-detection.js +7 -3
  450. package/data/build/dist/host/cli-adapters/binary-detection.js.map +1 -1
  451. package/data/build/dist/host/cli-adapters/claude-driver.d.ts +1 -0
  452. package/data/build/dist/host/cli-adapters/claude-driver.d.ts.map +1 -1
  453. package/data/build/dist/host/cli-adapters/claude-driver.js +184 -21
  454. package/data/build/dist/host/cli-adapters/claude-driver.js.map +1 -1
  455. package/data/build/dist/host/cli-adapters/codex-driver.d.ts +28 -0
  456. package/data/build/dist/host/cli-adapters/codex-driver.d.ts.map +1 -1
  457. package/data/build/dist/host/cli-adapters/codex-driver.js +158 -22
  458. package/data/build/dist/host/cli-adapters/codex-driver.js.map +1 -1
  459. package/data/build/dist/host/cli-adapters/codex-performance-projection.d.ts +91 -0
  460. package/data/build/dist/host/cli-adapters/codex-performance-projection.d.ts.map +1 -0
  461. package/data/build/dist/host/cli-adapters/codex-performance-projection.js +8 -0
  462. package/data/build/dist/host/cli-adapters/codex-performance-projection.js.map +1 -0
  463. package/data/build/dist/host/cli-adapters/codex-performance.d.ts +16 -0
  464. package/data/build/dist/host/cli-adapters/codex-performance.d.ts.map +1 -0
  465. package/data/build/dist/host/cli-adapters/codex-performance.js +81 -0
  466. package/data/build/dist/host/cli-adapters/codex-performance.js.map +1 -0
  467. package/data/build/dist/host/cli-adapters/command-code-acp-loader.d.ts +6 -2
  468. package/data/build/dist/host/cli-adapters/command-code-acp-loader.d.ts.map +1 -1
  469. package/data/build/dist/host/cli-adapters/command-code-acp-loader.js +198 -26
  470. package/data/build/dist/host/cli-adapters/command-code-acp-loader.js.map +1 -1
  471. package/data/build/dist/host/cli-adapters/command-code-driver.d.ts.map +1 -1
  472. package/data/build/dist/host/cli-adapters/command-code-driver.js +33 -5
  473. package/data/build/dist/host/cli-adapters/command-code-driver.js.map +1 -1
  474. package/data/build/dist/host/cli-adapters/desktop-app-runtime.d.ts +3 -1
  475. package/data/build/dist/host/cli-adapters/desktop-app-runtime.d.ts.map +1 -1
  476. package/data/build/dist/host/cli-adapters/desktop-app-runtime.js +41 -4
  477. package/data/build/dist/host/cli-adapters/desktop-app-runtime.js.map +1 -1
  478. package/data/build/dist/host/cli-adapters/driver.d.ts +2 -0
  479. package/data/build/dist/host/cli-adapters/driver.d.ts.map +1 -1
  480. package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts +5 -1
  481. package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts.map +1 -1
  482. package/data/build/dist/host/cli-adapters/dsh-message-projector.js +65 -17
  483. package/data/build/dist/host/cli-adapters/dsh-message-projector.js.map +1 -1
  484. package/data/build/dist/host/cli-adapters/dsh-tool-history.js +3 -2
  485. package/data/build/dist/host/cli-adapters/dsh-tool-history.js.map +1 -1
  486. package/data/build/dist/host/cli-adapters/dsh-virtual-providers.d.ts.map +1 -1
  487. package/data/build/dist/host/cli-adapters/dsh-virtual-providers.js +3 -2
  488. package/data/build/dist/host/cli-adapters/dsh-virtual-providers.js.map +1 -1
  489. package/data/build/dist/host/cli-adapters/feature.d.ts +17 -0
  490. package/data/build/dist/host/cli-adapters/feature.d.ts.map +1 -1
  491. package/data/build/dist/host/cli-adapters/feature.js +972 -102
  492. package/data/build/dist/host/cli-adapters/feature.js.map +1 -1
  493. package/data/build/dist/host/cli-adapters/gemini-driver.d.ts.map +1 -1
  494. package/data/build/dist/host/cli-adapters/gemini-driver.js +5 -3
  495. package/data/build/dist/host/cli-adapters/gemini-driver.js.map +1 -1
  496. package/data/build/dist/host/cli-adapters/grok-driver.d.ts +7 -0
  497. package/data/build/dist/host/cli-adapters/grok-driver.d.ts.map +1 -1
  498. package/data/build/dist/host/cli-adapters/grok-driver.js +463 -59
  499. package/data/build/dist/host/cli-adapters/grok-driver.js.map +1 -1
  500. package/data/build/dist/host/cli-adapters/grok-performance-projection.d.ts +123 -0
  501. package/data/build/dist/host/cli-adapters/grok-performance-projection.d.ts.map +1 -0
  502. package/data/build/dist/host/cli-adapters/grok-performance-projection.js +48 -0
  503. package/data/build/dist/host/cli-adapters/grok-performance-projection.js.map +1 -0
  504. package/data/build/dist/host/cli-adapters/grok-usage.d.ts +45 -0
  505. package/data/build/dist/host/cli-adapters/grok-usage.d.ts.map +1 -0
  506. package/data/build/dist/host/cli-adapters/grok-usage.js +197 -0
  507. package/data/build/dist/host/cli-adapters/grok-usage.js.map +1 -0
  508. package/data/build/dist/host/cli-adapters/kimi-driver.js +2 -2
  509. package/data/build/dist/host/cli-adapters/kimi-driver.js.map +1 -1
  510. package/data/build/dist/host/cli-adapters/legacy-session-adapter.d.ts.map +1 -1
  511. package/data/build/dist/host/cli-adapters/legacy-session-adapter.js +20 -3
  512. package/data/build/dist/host/cli-adapters/legacy-session-adapter.js.map +1 -1
  513. package/data/build/dist/host/cli-adapters/magpie-detection.d.ts +72 -0
  514. package/data/build/dist/host/cli-adapters/magpie-detection.d.ts.map +1 -0
  515. package/data/build/dist/host/cli-adapters/magpie-detection.js +298 -0
  516. package/data/build/dist/host/cli-adapters/magpie-detection.js.map +1 -0
  517. package/data/build/dist/host/cli-adapters/magpie-management.d.ts +50 -0
  518. package/data/build/dist/host/cli-adapters/magpie-management.d.ts.map +1 -0
  519. package/data/build/dist/host/cli-adapters/magpie-management.js +1268 -0
  520. package/data/build/dist/host/cli-adapters/magpie-management.js.map +1 -0
  521. package/data/build/dist/host/cli-adapters/magpie-session-routing.d.ts +9 -0
  522. package/data/build/dist/host/cli-adapters/magpie-session-routing.d.ts.map +1 -0
  523. package/data/build/dist/host/cli-adapters/magpie-session-routing.js +90 -0
  524. package/data/build/dist/host/cli-adapters/magpie-session-routing.js.map +1 -0
  525. package/data/build/dist/host/cli-adapters/magpie-update.d.ts +59 -0
  526. package/data/build/dist/host/cli-adapters/magpie-update.d.ts.map +1 -0
  527. package/data/build/dist/host/cli-adapters/magpie-update.js +249 -0
  528. package/data/build/dist/host/cli-adapters/magpie-update.js.map +1 -0
  529. package/data/build/dist/host/cli-adapters/magpie-usage.d.ts +148 -0
  530. package/data/build/dist/host/cli-adapters/magpie-usage.d.ts.map +1 -0
  531. package/data/build/dist/host/cli-adapters/magpie-usage.js +1710 -0
  532. package/data/build/dist/host/cli-adapters/magpie-usage.js.map +1 -0
  533. package/data/build/dist/host/cli-adapters/magpie-web.d.ts +54 -0
  534. package/data/build/dist/host/cli-adapters/magpie-web.d.ts.map +1 -0
  535. package/data/build/dist/host/cli-adapters/magpie-web.js +407 -0
  536. package/data/build/dist/host/cli-adapters/magpie-web.js.map +1 -0
  537. package/data/build/dist/host/cli-adapters/management-installation.d.ts +5 -0
  538. package/data/build/dist/host/cli-adapters/management-installation.d.ts.map +1 -0
  539. package/data/build/dist/host/cli-adapters/management-installation.js +131 -0
  540. package/data/build/dist/host/cli-adapters/management-installation.js.map +1 -0
  541. package/data/build/dist/host/cli-adapters/management-methods.d.ts +37 -0
  542. package/data/build/dist/host/cli-adapters/management-methods.d.ts.map +1 -0
  543. package/data/build/dist/host/cli-adapters/management-methods.js +144 -0
  544. package/data/build/dist/host/cli-adapters/management-methods.js.map +1 -0
  545. package/data/build/dist/host/cli-adapters/management-process.d.ts +7 -0
  546. package/data/build/dist/host/cli-adapters/management-process.d.ts.map +1 -0
  547. package/data/build/dist/host/cli-adapters/management-process.js +62 -0
  548. package/data/build/dist/host/cli-adapters/management-process.js.map +1 -0
  549. package/data/build/dist/host/cli-adapters/management.d.ts +32 -0
  550. package/data/build/dist/host/cli-adapters/management.d.ts.map +1 -0
  551. package/data/build/dist/host/cli-adapters/management.js +177 -0
  552. package/data/build/dist/host/cli-adapters/management.js.map +1 -0
  553. package/data/build/dist/host/cli-adapters/mcode-driver.d.ts.map +1 -1
  554. package/data/build/dist/host/cli-adapters/mcode-driver.js +12 -5
  555. package/data/build/dist/host/cli-adapters/mcode-driver.js.map +1 -1
  556. package/data/build/dist/host/cli-adapters/model-catalog.d.ts +1 -0
  557. package/data/build/dist/host/cli-adapters/model-catalog.d.ts.map +1 -1
  558. package/data/build/dist/host/cli-adapters/model-catalog.js +70 -7
  559. package/data/build/dist/host/cli-adapters/model-catalog.js.map +1 -1
  560. package/data/build/dist/host/cli-adapters/native-subagent-dispatch.d.ts +1 -1
  561. package/data/build/dist/host/cli-adapters/native-subagent-dispatch.d.ts.map +1 -1
  562. package/data/build/dist/host/cli-adapters/native-subagent-dispatch.js +13 -5
  563. package/data/build/dist/host/cli-adapters/native-subagent-dispatch.js.map +1 -1
  564. package/data/build/dist/host/cli-adapters/native-team-subagent.d.ts +7 -1
  565. package/data/build/dist/host/cli-adapters/native-team-subagent.d.ts.map +1 -1
  566. package/data/build/dist/host/cli-adapters/native-team-subagent.js +6 -3
  567. package/data/build/dist/host/cli-adapters/native-team-subagent.js.map +1 -1
  568. package/data/build/dist/host/cli-adapters/opencode-driver.d.ts +22 -0
  569. package/data/build/dist/host/cli-adapters/opencode-driver.d.ts.map +1 -1
  570. package/data/build/dist/host/cli-adapters/opencode-driver.js +105 -17
  571. package/data/build/dist/host/cli-adapters/opencode-driver.js.map +1 -1
  572. package/data/build/dist/host/cli-adapters/opencode-v2-protocol.js +4 -1
  573. package/data/build/dist/host/cli-adapters/opencode-v2-protocol.js.map +1 -1
  574. package/data/build/dist/host/cli-adapters/pi-driver.d.ts.map +1 -1
  575. package/data/build/dist/host/cli-adapters/pi-driver.js +45 -11
  576. package/data/build/dist/host/cli-adapters/pi-driver.js.map +1 -1
  577. package/data/build/dist/host/cli-adapters/process-utils.d.ts +4 -0
  578. package/data/build/dist/host/cli-adapters/process-utils.d.ts.map +1 -1
  579. package/data/build/dist/host/cli-adapters/process-utils.js +20 -11
  580. package/data/build/dist/host/cli-adapters/process-utils.js.map +1 -1
  581. package/data/build/dist/host/cli-adapters/registry.d.ts +7 -1
  582. package/data/build/dist/host/cli-adapters/registry.d.ts.map +1 -1
  583. package/data/build/dist/host/cli-adapters/registry.js +141 -51
  584. package/data/build/dist/host/cli-adapters/registry.js.map +1 -1
  585. package/data/build/dist/host/cli-adapters/session-performance-projection.d.ts +74 -0
  586. package/data/build/dist/host/cli-adapters/session-performance-projection.d.ts.map +1 -0
  587. package/data/build/dist/host/cli-adapters/session-performance-projection.js +83 -0
  588. package/data/build/dist/host/cli-adapters/session-performance-projection.js.map +1 -0
  589. package/data/build/dist/host/cli-adapters/standard-stream-driver.d.ts.map +1 -1
  590. package/data/build/dist/host/cli-adapters/standard-stream-driver.js +4 -0
  591. package/data/build/dist/host/cli-adapters/standard-stream-driver.js.map +1 -1
  592. package/data/build/dist/host/cli-adapters/stream-normalizer.d.ts +3 -1
  593. package/data/build/dist/host/cli-adapters/stream-normalizer.d.ts.map +1 -1
  594. package/data/build/dist/host/cli-adapters/stream-normalizer.js +2 -0
  595. package/data/build/dist/host/cli-adapters/stream-normalizer.js.map +1 -1
  596. package/data/build/dist/host/cli-adapters/subagent-tool-descriptions.d.ts +26 -0
  597. package/data/build/dist/host/cli-adapters/subagent-tool-descriptions.d.ts.map +1 -0
  598. package/data/build/dist/host/cli-adapters/subagent-tool-descriptions.js +30 -0
  599. package/data/build/dist/host/cli-adapters/subagent-tool-descriptions.js.map +1 -0
  600. package/data/build/dist/host/cli-adapters/subagent-tool.d.ts.map +1 -1
  601. package/data/build/dist/host/cli-adapters/subagent-tool.js +7 -6
  602. package/data/build/dist/host/cli-adapters/subagent-tool.js.map +1 -1
  603. package/data/build/dist/host/cli-adapters/team-input.d.ts +17 -0
  604. package/data/build/dist/host/cli-adapters/team-input.d.ts.map +1 -0
  605. package/data/build/dist/host/cli-adapters/team-input.js +67 -0
  606. package/data/build/dist/host/cli-adapters/team-input.js.map +1 -0
  607. package/data/build/dist/host/cli-adapters/update-check.d.ts +34 -0
  608. package/data/build/dist/host/cli-adapters/update-check.d.ts.map +1 -0
  609. package/data/build/dist/host/cli-adapters/update-check.js +263 -0
  610. package/data/build/dist/host/cli-adapters/update-check.js.map +1 -0
  611. package/data/build/dist/host/cli-adapters/zcode-driver.d.ts.map +1 -1
  612. package/data/build/dist/host/cli-adapters/zcode-driver.js +7 -2
  613. package/data/build/dist/host/cli-adapters/zcode-driver.js.map +1 -1
  614. package/data/build/dist/host/cli-adapters/zcode-update.d.ts +8 -0
  615. package/data/build/dist/host/cli-adapters/zcode-update.d.ts.map +1 -0
  616. package/data/build/dist/host/cli-adapters/zcode-update.js +149 -0
  617. package/data/build/dist/host/cli-adapters/zcode-update.js.map +1 -0
  618. package/data/build/dist/host/cli-bridge/bridge-holder.d.ts +14 -0
  619. package/data/build/dist/host/cli-bridge/bridge-holder.d.ts.map +1 -1
  620. package/data/build/dist/host/cli-bridge/bridge-holder.js +53 -6
  621. package/data/build/dist/host/cli-bridge/bridge-holder.js.map +1 -1
  622. package/data/build/dist/host/cli-bridge/bridge-server.d.ts +8 -0
  623. package/data/build/dist/host/cli-bridge/bridge-server.d.ts.map +1 -1
  624. package/data/build/dist/host/cli-bridge/bridge-server.js +63 -6
  625. package/data/build/dist/host/cli-bridge/bridge-server.js.map +1 -1
  626. package/data/build/dist/host/cli-bridge/command-code-mod.d.ts.map +1 -1
  627. package/data/build/dist/host/cli-bridge/command-code-mod.js +128 -0
  628. package/data/build/dist/host/cli-bridge/command-code-mod.js.map +1 -1
  629. package/data/build/dist/host/cli-bridge/dispatch.js +1 -1
  630. package/data/build/dist/host/cli-bridge/dispatch.js.map +1 -1
  631. package/data/build/dist/host/cli-bridge/fetch-dispatch.d.ts +23 -0
  632. package/data/build/dist/host/cli-bridge/fetch-dispatch.d.ts.map +1 -0
  633. package/data/build/dist/host/cli-bridge/fetch-dispatch.js +73 -0
  634. package/data/build/dist/host/cli-bridge/fetch-dispatch.js.map +1 -0
  635. package/data/build/dist/host/cli-bridge/injections.d.ts +14 -0
  636. package/data/build/dist/host/cli-bridge/injections.d.ts.map +1 -1
  637. package/data/build/dist/host/cli-bridge/injections.js +69 -7
  638. package/data/build/dist/host/cli-bridge/injections.js.map +1 -1
  639. package/data/build/dist/host/cli-bridge/mcp-stdio-entry.d.ts +1 -1
  640. package/data/build/dist/host/cli-bridge/mcp-stdio-entry.js +102 -7
  641. package/data/build/dist/host/cli-bridge/mcp-stdio-entry.js.map +1 -1
  642. package/data/build/dist/host/cli-bridge/pi-extension-entry.d.ts +3 -0
  643. package/data/build/dist/host/cli-bridge/pi-extension-entry.d.ts.map +1 -0
  644. package/data/build/dist/host/cli-bridge/pi-extension-entry.js +9 -0
  645. package/data/build/dist/host/cli-bridge/pi-extension-entry.js.map +1 -0
  646. package/data/build/dist/host/cli-bridge/pi-extension.d.ts +52 -0
  647. package/data/build/dist/host/cli-bridge/pi-extension.d.ts.map +1 -0
  648. package/data/build/dist/host/cli-bridge/pi-extension.js +311 -0
  649. package/data/build/dist/host/cli-bridge/pi-extension.js.map +1 -0
  650. package/data/build/dist/host/cli-bridge/search-dispatch.d.ts +20 -0
  651. package/data/build/dist/host/cli-bridge/search-dispatch.d.ts.map +1 -0
  652. package/data/build/dist/host/cli-bridge/search-dispatch.js +61 -0
  653. package/data/build/dist/host/cli-bridge/search-dispatch.js.map +1 -0
  654. package/data/build/dist/host/cli-bridge/team-adapters.d.ts +11 -0
  655. package/data/build/dist/host/cli-bridge/team-adapters.d.ts.map +1 -0
  656. package/data/build/dist/host/cli-bridge/team-adapters.js +23 -0
  657. package/data/build/dist/host/cli-bridge/team-adapters.js.map +1 -0
  658. package/data/build/dist/host/cli-bridge/team-dispatch.d.ts +28 -0
  659. package/data/build/dist/host/cli-bridge/team-dispatch.d.ts.map +1 -0
  660. package/data/build/dist/host/cli-bridge/team-dispatch.js +208 -0
  661. package/data/build/dist/host/cli-bridge/team-dispatch.js.map +1 -0
  662. package/data/build/dist/host/cli-bridge/team-tool.d.ts +3 -0
  663. package/data/build/dist/host/cli-bridge/team-tool.d.ts.map +1 -0
  664. package/data/build/dist/host/cli-bridge/team-tool.js +18 -0
  665. package/data/build/dist/host/cli-bridge/team-tool.js.map +1 -0
  666. package/data/build/dist/host/dsh-gateway-feature.d.ts.map +1 -1
  667. package/data/build/dist/host/dsh-gateway-feature.js +26 -3
  668. package/data/build/dist/host/dsh-gateway-feature.js.map +1 -1
  669. package/data/build/dist/host/features/file-management.d.ts.map +1 -1
  670. package/data/build/dist/host/features/file-management.js +10 -1
  671. package/data/build/dist/host/features/file-management.js.map +1 -1
  672. package/data/build/dist/host/features/git-commit-message.d.ts +5 -0
  673. package/data/build/dist/host/features/git-commit-message.d.ts.map +1 -0
  674. package/data/build/dist/host/features/git-commit-message.js +66 -0
  675. package/data/build/dist/host/features/git-commit-message.js.map +1 -0
  676. package/data/build/dist/host/features/git-management.d.ts +11 -2
  677. package/data/build/dist/host/features/git-management.d.ts.map +1 -1
  678. package/data/build/dist/host/features/git-management.js +61 -7
  679. package/data/build/dist/host/features/git-management.js.map +1 -1
  680. package/data/build/dist/host/features/global-voice-rpc.d.ts.map +1 -1
  681. package/data/build/dist/host/features/global-voice-rpc.js +2 -3
  682. package/data/build/dist/host/features/global-voice-rpc.js.map +1 -1
  683. package/data/build/dist/host/features/host-status.d.ts +25 -0
  684. package/data/build/dist/host/features/host-status.d.ts.map +1 -1
  685. package/data/build/dist/host/features/host-status.js +60 -6
  686. package/data/build/dist/host/features/host-status.js.map +1 -1
  687. package/data/build/dist/host/features/index.d.ts.map +1 -1
  688. package/data/build/dist/host/features/index.js +2 -0
  689. package/data/build/dist/host/features/index.js.map +1 -1
  690. package/data/build/dist/host/features/interaction-translation.d.ts +10 -0
  691. package/data/build/dist/host/features/interaction-translation.d.ts.map +1 -0
  692. package/data/build/dist/host/features/interaction-translation.js +219 -0
  693. package/data/build/dist/host/features/interaction-translation.js.map +1 -0
  694. package/data/build/dist/host/features/lan-access-dsh.d.ts.map +1 -1
  695. package/data/build/dist/host/features/lan-access-dsh.js +64 -13
  696. package/data/build/dist/host/features/lan-access-dsh.js.map +1 -1
  697. package/data/build/dist/host/features/peer-host.d.ts.map +1 -1
  698. package/data/build/dist/host/features/peer-host.js +13 -6
  699. package/data/build/dist/host/features/peer-host.js.map +1 -1
  700. package/data/build/dist/host/features/quick-apps.d.ts +4 -0
  701. package/data/build/dist/host/features/quick-apps.d.ts.map +1 -0
  702. package/data/build/dist/host/features/quick-apps.js +158 -0
  703. package/data/build/dist/host/features/quick-apps.js.map +1 -0
  704. package/data/build/dist/host/features/session-prompt-translation.d.ts +10 -0
  705. package/data/build/dist/host/features/session-prompt-translation.d.ts.map +1 -0
  706. package/data/build/dist/host/features/session-prompt-translation.js +227 -0
  707. package/data/build/dist/host/features/session-prompt-translation.js.map +1 -0
  708. package/data/build/dist/host/features/session-translation-protection.d.ts +22 -0
  709. package/data/build/dist/host/features/session-translation-protection.d.ts.map +1 -0
  710. package/data/build/dist/host/features/session-translation-protection.js +205 -0
  711. package/data/build/dist/host/features/session-translation-protection.js.map +1 -0
  712. package/data/build/dist/host/features/session-translation-recovery.d.ts +21 -0
  713. package/data/build/dist/host/features/session-translation-recovery.d.ts.map +1 -0
  714. package/data/build/dist/host/features/session-translation-recovery.js +125 -0
  715. package/data/build/dist/host/features/session-translation-recovery.js.map +1 -0
  716. package/data/build/dist/host/features/session-translation-runtime.d.ts +16 -0
  717. package/data/build/dist/host/features/session-translation-runtime.d.ts.map +1 -0
  718. package/data/build/dist/host/features/session-translation-runtime.js +85 -0
  719. package/data/build/dist/host/features/session-translation-runtime.js.map +1 -0
  720. package/data/build/dist/host/features/session-translation-service.d.ts +19 -4
  721. package/data/build/dist/host/features/session-translation-service.d.ts.map +1 -1
  722. package/data/build/dist/host/features/session-translation-service.js +249 -210
  723. package/data/build/dist/host/features/session-translation-service.js.map +1 -1
  724. package/data/build/dist/host/features/session-translation.d.ts.map +1 -1
  725. package/data/build/dist/host/features/session-translation.js +6 -3
  726. package/data/build/dist/host/features/session-translation.js.map +1 -1
  727. package/data/build/dist/host/features/types.d.ts +10 -0
  728. package/data/build/dist/host/features/types.d.ts.map +1 -1
  729. package/data/build/dist/host/html-workspace-files.d.ts +3 -0
  730. package/data/build/dist/host/html-workspace-files.d.ts.map +1 -0
  731. package/data/build/dist/host/html-workspace-files.js +135 -0
  732. package/data/build/dist/host/html-workspace-files.js.map +1 -0
  733. package/data/build/dist/host/index.d.ts.map +1 -1
  734. package/data/build/dist/host/index.js +32 -39
  735. package/data/build/dist/host/index.js.map +1 -1
  736. package/data/build/dist/host/lan-access-dsh.d.ts +14 -2
  737. package/data/build/dist/host/lan-access-dsh.d.ts.map +1 -1
  738. package/data/build/dist/host/lan-access-dsh.js +87 -15
  739. package/data/build/dist/host/lan-access-dsh.js.map +1 -1
  740. package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.d.ts +2 -2
  741. package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.d.ts.map +1 -1
  742. package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.js +10 -9
  743. package/data/build/dist/host/modules/peer-host/peer-host-native-dispatch.js.map +1 -1
  744. package/data/build/dist/host/modules/peer-host/peer-host-native-streams.d.ts +3 -3
  745. package/data/build/dist/host/modules/peer-host/peer-host-native-streams.d.ts.map +1 -1
  746. package/data/build/dist/host/modules/peer-host/peer-host-native-streams.js +26 -14
  747. package/data/build/dist/host/modules/peer-host/peer-host-native-streams.js.map +1 -1
  748. package/data/build/dist/host/modules/peer-host/quick-app-gateway.d.ts +5 -0
  749. package/data/build/dist/host/modules/peer-host/quick-app-gateway.d.ts.map +1 -0
  750. package/data/build/dist/host/modules/peer-host/quick-app-gateway.js +27 -0
  751. package/data/build/dist/host/modules/peer-host/quick-app-gateway.js.map +1 -0
  752. package/data/build/dist/host/modules/pwa/pwa-session-notifications.js +2 -1
  753. package/data/build/dist/host/modules/pwa/pwa-session-notifications.js.map +1 -1
  754. package/data/build/dist/host/modules/quick-apps/browse.d.ts +5 -0
  755. package/data/build/dist/host/modules/quick-apps/browse.d.ts.map +1 -0
  756. package/data/build/dist/host/modules/quick-apps/browse.js +37 -0
  757. package/data/build/dist/host/modules/quick-apps/browse.js.map +1 -0
  758. package/data/build/dist/host/modules/quick-apps/code-revision.d.ts +4 -0
  759. package/data/build/dist/host/modules/quick-apps/code-revision.d.ts.map +1 -0
  760. package/data/build/dist/host/modules/quick-apps/code-revision.js +39 -0
  761. package/data/build/dist/host/modules/quick-apps/code-revision.js.map +1 -0
  762. package/data/build/dist/host/modules/quick-apps/documents.d.ts +14 -0
  763. package/data/build/dist/host/modules/quick-apps/documents.d.ts.map +1 -0
  764. package/data/build/dist/host/modules/quick-apps/documents.js +87 -0
  765. package/data/build/dist/host/modules/quick-apps/documents.js.map +1 -0
  766. package/data/build/dist/host/modules/quick-apps/egress.d.ts +35 -0
  767. package/data/build/dist/host/modules/quick-apps/egress.d.ts.map +1 -0
  768. package/data/build/dist/host/modules/quick-apps/egress.js +244 -0
  769. package/data/build/dist/host/modules/quick-apps/egress.js.map +1 -0
  770. package/data/build/dist/host/modules/quick-apps/errors.d.ts +8 -0
  771. package/data/build/dist/host/modules/quick-apps/errors.d.ts.map +1 -0
  772. package/data/build/dist/host/modules/quick-apps/errors.js +15 -0
  773. package/data/build/dist/host/modules/quick-apps/errors.js.map +1 -0
  774. package/data/build/dist/host/modules/quick-apps/file-api.d.ts +30 -0
  775. package/data/build/dist/host/modules/quick-apps/file-api.d.ts.map +1 -0
  776. package/data/build/dist/host/modules/quick-apps/file-api.js +149 -0
  777. package/data/build/dist/host/modules/quick-apps/file-api.js.map +1 -0
  778. package/data/build/dist/host/modules/quick-apps/launches.d.ts +35 -0
  779. package/data/build/dist/host/modules/quick-apps/launches.d.ts.map +1 -0
  780. package/data/build/dist/host/modules/quick-apps/launches.js +80 -0
  781. package/data/build/dist/host/modules/quick-apps/launches.js.map +1 -0
  782. package/data/build/dist/host/modules/quick-apps/paths.d.ts +14 -0
  783. package/data/build/dist/host/modules/quick-apps/paths.d.ts.map +1 -0
  784. package/data/build/dist/host/modules/quick-apps/paths.js +72 -0
  785. package/data/build/dist/host/modules/quick-apps/paths.js.map +1 -0
  786. package/data/build/dist/host/modules/quick-apps/registry.d.ts +30 -0
  787. package/data/build/dist/host/modules/quick-apps/registry.d.ts.map +1 -0
  788. package/data/build/dist/host/modules/quick-apps/registry.js +195 -0
  789. package/data/build/dist/host/modules/quick-apps/registry.js.map +1 -0
  790. package/data/build/dist/host/modules/quick-apps/remote.d.ts +38 -0
  791. package/data/build/dist/host/modules/quick-apps/remote.d.ts.map +1 -0
  792. package/data/build/dist/host/modules/quick-apps/remote.js +238 -0
  793. package/data/build/dist/host/modules/quick-apps/remote.js.map +1 -0
  794. package/data/build/dist/host/modules/quick-apps/service.d.ts +27 -0
  795. package/data/build/dist/host/modules/quick-apps/service.d.ts.map +1 -0
  796. package/data/build/dist/host/modules/quick-apps/service.js +174 -0
  797. package/data/build/dist/host/modules/quick-apps/service.js.map +1 -0
  798. package/data/build/dist/host/modules/quick-apps/static-handler.d.ts +8 -0
  799. package/data/build/dist/host/modules/quick-apps/static-handler.d.ts.map +1 -0
  800. package/data/build/dist/host/modules/quick-apps/static-handler.js +213 -0
  801. package/data/build/dist/host/modules/quick-apps/static-handler.js.map +1 -0
  802. package/data/build/dist/host/native-session-bridge.d.ts +7 -1
  803. package/data/build/dist/host/native-session-bridge.d.ts.map +1 -1
  804. package/data/build/dist/host/native-session-bridge.js +10 -15
  805. package/data/build/dist/host/native-session-bridge.js.map +1 -1
  806. package/data/build/dist/host/rpc.d.ts +15 -2
  807. package/data/build/dist/host/rpc.d.ts.map +1 -1
  808. package/data/build/dist/host/rpc.js +67 -15
  809. package/data/build/dist/host/rpc.js.map +1 -1
  810. package/data/build/dist/host/session-changes.d.ts.map +1 -1
  811. package/data/build/dist/host/session-changes.js +6 -2
  812. package/data/build/dist/host/session-changes.js.map +1 -1
  813. package/data/build/dist/host/session-migration-repair.js +48 -35
  814. package/data/build/dist/host/session-migration-repair.js.map +1 -1
  815. package/data/build/dist/host/settings.d.ts.map +1 -1
  816. package/data/build/dist/host/settings.js +36 -2
  817. package/data/build/dist/host/settings.js.map +1 -1
  818. package/data/build/dist/host/workspace-file-mutations.d.ts +2 -0
  819. package/data/build/dist/host/workspace-file-mutations.d.ts.map +1 -0
  820. package/data/build/dist/host/workspace-file-mutations.js +15 -0
  821. package/data/build/dist/host/workspace-file-mutations.js.map +1 -0
  822. package/data/build/dist/host/workspace-root.d.ts +14 -0
  823. package/data/build/dist/host/workspace-root.d.ts.map +1 -0
  824. package/data/build/dist/host/workspace-root.js +99 -0
  825. package/data/build/dist/host/workspace-root.js.map +1 -0
  826. package/data/build/dist/shared/attachment-prompts.d.ts +11 -0
  827. package/data/build/dist/shared/attachment-prompts.d.ts.map +1 -0
  828. package/data/build/dist/shared/attachment-prompts.js +17 -0
  829. package/data/build/dist/shared/attachment-prompts.js.map +1 -0
  830. package/data/build/dist/shared/cli-provider-route.d.ts +7 -0
  831. package/data/build/dist/shared/cli-provider-route.d.ts.map +1 -0
  832. package/data/build/dist/shared/cli-provider-route.js +13 -0
  833. package/data/build/dist/shared/cli-provider-route.js.map +1 -0
  834. package/data/build/dist/shared/codex-performance.d.ts +3 -0
  835. package/data/build/dist/shared/codex-performance.d.ts.map +1 -0
  836. package/data/build/dist/shared/codex-performance.js +2 -0
  837. package/data/build/dist/shared/codex-performance.js.map +1 -0
  838. package/data/build/dist/shared/contracts/agent-team.d.ts +14 -0
  839. package/data/build/dist/shared/contracts/agent-team.d.ts.map +1 -0
  840. package/data/build/dist/shared/contracts/agent-team.js +48 -0
  841. package/data/build/dist/shared/contracts/agent-team.js.map +1 -0
  842. package/data/build/dist/shared/contracts/cli-adapter.d.ts +62 -1
  843. package/data/build/dist/shared/contracts/cli-adapter.d.ts.map +1 -1
  844. package/data/build/dist/shared/contracts/cli-management.d.ts +29 -0
  845. package/data/build/dist/shared/contracts/cli-management.d.ts.map +1 -0
  846. package/data/build/dist/shared/contracts/cli-management.js +2 -0
  847. package/data/build/dist/shared/contracts/cli-management.js.map +1 -0
  848. package/data/build/dist/shared/contracts/config.d.ts +25 -1
  849. package/data/build/dist/shared/contracts/config.d.ts.map +1 -1
  850. package/data/build/dist/shared/contracts/config.js +11 -0
  851. package/data/build/dist/shared/contracts/config.js.map +1 -1
  852. package/data/build/dist/shared/contracts/errors.d.ts +2 -2
  853. package/data/build/dist/shared/contracts/errors.d.ts.map +1 -1
  854. package/data/build/dist/shared/contracts/feature.d.ts +7 -0
  855. package/data/build/dist/shared/contracts/feature.d.ts.map +1 -1
  856. package/data/build/dist/shared/contracts/git.d.ts +17 -0
  857. package/data/build/dist/shared/contracts/git.d.ts.map +1 -1
  858. package/data/build/dist/shared/contracts/git.js +27 -1
  859. package/data/build/dist/shared/contracts/git.js.map +1 -1
  860. package/data/build/dist/shared/contracts/interaction-presentation.d.ts +32 -0
  861. package/data/build/dist/shared/contracts/interaction-presentation.d.ts.map +1 -0
  862. package/data/build/dist/shared/contracts/interaction-presentation.js +2 -0
  863. package/data/build/dist/shared/contracts/interaction-presentation.js.map +1 -0
  864. package/data/build/dist/shared/contracts/interaction-translation.d.ts +53 -0
  865. package/data/build/dist/shared/contracts/interaction-translation.d.ts.map +1 -0
  866. package/data/build/dist/shared/contracts/interaction-translation.js +44 -0
  867. package/data/build/dist/shared/contracts/interaction-translation.js.map +1 -0
  868. package/data/build/dist/shared/contracts/magpie-management.d.ts +395 -0
  869. package/data/build/dist/shared/contracts/magpie-management.d.ts.map +1 -0
  870. package/data/build/dist/shared/contracts/magpie-management.js +2 -0
  871. package/data/build/dist/shared/contracts/magpie-management.js.map +1 -0
  872. package/data/build/dist/shared/contracts/quick-apps.d.ts +70 -0
  873. package/data/build/dist/shared/contracts/quick-apps.d.ts.map +1 -0
  874. package/data/build/dist/shared/contracts/quick-apps.js +4 -0
  875. package/data/build/dist/shared/contracts/quick-apps.js.map +1 -0
  876. package/data/build/dist/shared/contracts/session-translation.d.ts +82 -9
  877. package/data/build/dist/shared/contracts/session-translation.d.ts.map +1 -1
  878. package/data/build/dist/shared/contracts/session-translation.js +146 -2
  879. package/data/build/dist/shared/contracts/session-translation.js.map +1 -1
  880. package/data/build/dist/shared/contracts/subscription.d.ts +161 -0
  881. package/data/build/dist/shared/contracts/subscription.d.ts.map +1 -1
  882. package/data/build/dist/shared/contracts/subscription.js.map +1 -1
  883. package/data/build/dist/shared/contracts/version.d.ts +9 -15
  884. package/data/build/dist/shared/contracts/version.d.ts.map +1 -1
  885. package/data/build/dist/shared/contracts/version.js +8 -14
  886. package/data/build/dist/shared/contracts/version.js.map +1 -1
  887. package/data/build/dist/shared/index.d.ts +4 -2
  888. package/data/build/dist/shared/index.d.ts.map +1 -1
  889. package/data/build/dist/shared/index.js +3 -2
  890. package/data/build/dist/shared/index.js.map +1 -1
  891. package/data/build/dist/shared/peer-host-http-routes.d.ts +4 -0
  892. package/data/build/dist/shared/peer-host-http-routes.d.ts.map +1 -1
  893. package/data/build/dist/shared/peer-host-http-routes.js +4 -0
  894. package/data/build/dist/shared/peer-host-http-routes.js.map +1 -1
  895. package/data/build/dist/shared/provider-icon-resources.d.ts.map +1 -1
  896. package/data/build/dist/shared/provider-icon-resources.js +1 -0
  897. package/data/build/dist/shared/provider-icon-resources.js.map +1 -1
  898. package/data/build/dist/shared/quick-app-browser-storage.d.ts +33 -0
  899. package/data/build/dist/shared/quick-app-browser-storage.d.ts.map +1 -0
  900. package/data/build/dist/shared/quick-app-browser-storage.js +33 -0
  901. package/data/build/dist/shared/quick-app-browser-storage.js.map +1 -0
  902. package/data/build/dist/shared/quick-app-network-allow.d.ts +8 -0
  903. package/data/build/dist/shared/quick-app-network-allow.d.ts.map +1 -0
  904. package/data/build/dist/shared/quick-app-network-allow.js +192 -0
  905. package/data/build/dist/shared/quick-app-network-allow.js.map +1 -0
  906. package/data/build/dist/shared/quick-app-network-bootstrap.d.ts +9 -0
  907. package/data/build/dist/shared/quick-app-network-bootstrap.d.ts.map +1 -0
  908. package/data/build/dist/shared/quick-app-network-bootstrap.js +134 -0
  909. package/data/build/dist/shared/quick-app-network-bootstrap.js.map +1 -0
  910. package/data/build/dist/shared/quick-app-proxy-path.d.ts +6 -0
  911. package/data/build/dist/shared/quick-app-proxy-path.d.ts.map +1 -0
  912. package/data/build/dist/shared/quick-app-proxy-path.js +18 -0
  913. package/data/build/dist/shared/quick-app-proxy-path.js.map +1 -0
  914. package/data/build/dist/shared/quick-app-storage-bootstrap.d.ts +9 -0
  915. package/data/build/dist/shared/quick-app-storage-bootstrap.d.ts.map +1 -0
  916. package/data/build/dist/shared/quick-app-storage-bootstrap.js +189 -0
  917. package/data/build/dist/shared/quick-app-storage-bootstrap.js.map +1 -0
  918. package/data/build/dist/shared/quick-apps-bootstrap-locale.d.ts +7 -0
  919. package/data/build/dist/shared/quick-apps-bootstrap-locale.d.ts.map +1 -0
  920. package/data/build/dist/shared/quick-apps-bootstrap-locale.js +10 -0
  921. package/data/build/dist/shared/quick-apps-bootstrap-locale.js.map +1 -0
  922. package/data/build/dist/shared/request-performance.d.ts +15 -0
  923. package/data/build/dist/shared/request-performance.d.ts.map +1 -0
  924. package/data/build/dist/shared/request-performance.js +3 -0
  925. package/data/build/dist/shared/request-performance.js.map +1 -0
  926. package/data/build/dist/shared/session-title.d.ts.map +1 -1
  927. package/data/build/dist/shared/session-title.js +10 -4
  928. package/data/build/dist/shared/session-title.js.map +1 -1
  929. package/data/build/dist/shared/translation-indicator.d.ts +26 -0
  930. package/data/build/dist/shared/translation-indicator.d.ts.map +1 -0
  931. package/data/build/dist/shared/translation-indicator.js +29 -0
  932. package/data/build/dist/shared/translation-indicator.js.map +1 -0
  933. package/package.json +35 -34
  934. package/profile/README.md +2 -2
  935. package/profile/package.json +3 -3
  936. package/profile/version.json +3 -3
  937. package/version.json +3 -3
  938. package/data/build/dist/client/client.model-catalog-cache.js.map +0 -1
@@ -0,0 +1,1710 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { commandEnvironment, resolveCommandPath, runAsyncCommand, WINDOWS, withCommandSignal } from './process-utils.js';
3
+ const MAGPIE_CATALOG_TTL_MS = 60_000;
4
+ const MAGPIE_MODEL_METADATA_TTL_MS = 60_000;
5
+ const MAGPIE_FAILURE_CACHE_TTL_MS = 5_000;
6
+ const MAX_MAGPIE_MODEL_METADATA_CACHE_ENTRIES = 4;
7
+ const MAGPIE_MINIMUM_CLI_VERSION = [0, 1, 1295];
8
+ const MAGPIE_CLI_TIMEOUT_MS = 10_000;
9
+ const MAGPIE_HTTP_TIMEOUT_MS = 3_000;
10
+ const MAGPIE_DASHBOARD_CACHE_TTL_MS = 15_000;
11
+ const MAX_MAGPIE_CLI_OUTPUT_BYTES = 512 * 1024;
12
+ const MAX_MAGPIE_RESPONSE_BYTES = 2 * 1024 * 1024;
13
+ const MAX_MAGPIE_ICON_FETCHES = 64;
14
+ const MAX_MAGPIE_MODELS = 10_000;
15
+ const MAX_MODEL_TOKEN_LIMIT = 1_000_000_000;
16
+ const MAGPIE_MODEL_ID_PATTERN = '[A-Za-z0-9][A-Za-z0-9._-]*(?:/[A-Za-z0-9][A-Za-z0-9._:/-]*)+';
17
+ const MAGPIE_AGENT_BY_ADAPTER = {
18
+ 'claude-code': 'claude',
19
+ codex: 'codex',
20
+ 'command-code': 'commandcode',
21
+ kimi: 'kimi',
22
+ gemini: 'gemini',
23
+ pi: 'pi',
24
+ opencode: 'opencode',
25
+ grok: 'grok',
26
+ mcode: 'minimax-code',
27
+ zcode: 'zcode',
28
+ codebuddy: 'codebuddy',
29
+ workbuddy: 'workbuddy',
30
+ 'cursor-cli': 'cursor',
31
+ qoder: 'qoder',
32
+ 'qoder-cn': 'qoder-cn',
33
+ antigravity: 'agy',
34
+ dsh: 'dsh',
35
+ };
36
+ // The DSH catalog uses `dsh`, while its gateway requests are recorded under
37
+ // the public client identity `codingns4dsh` in Magpie usage and trace data.
38
+ const MAGPIE_USAGE_AGENT_ALIASES = {
39
+ dsh: ['dsh', 'codingns4dsh'],
40
+ // Command Code ACP identifies its client as `codingns4dsh` in Magpie's
41
+ // usage ledger, while its verified model catalog uses `commandcode`.
42
+ commandcode: ['commandcode', 'codingns4dsh'],
43
+ };
44
+ /** Reads usage from the authenticated local Magpie Web API and exact-matches session identity. */
45
+ export class MagpieUsageService {
46
+ readModels;
47
+ readVersion;
48
+ request;
49
+ now;
50
+ timeoutMs;
51
+ lifetimeSignal;
52
+ webApi;
53
+ onDashboardTiming;
54
+ /** Agent CLI verification remains isolated; model metadata below is Gateway-wide and shared. */
55
+ catalogs = new Map();
56
+ catalogLoads = new Map();
57
+ /** `/v1/models` is Gateway-wide, so adapters with the same model set share one normalized response. */
58
+ modelMetadata = new Map();
59
+ modelMetadataLoads = new Map();
60
+ versionCheck;
61
+ versionLoad;
62
+ dashboardCache = new Map();
63
+ dashboardRefreshes = new Map();
64
+ quotaLogoCache = new Map();
65
+ constructor(options = {}) {
66
+ this.readModels = options.readModels ?? readMagpieModels;
67
+ // An injected catalog reader represents the whole fake CLI boundary in
68
+ // unit tests; tests that exercise version handling inject readVersion too.
69
+ this.readVersion = options.readVersion ?? (options.readModels === undefined
70
+ ? readMagpieVersion
71
+ : async () => 'magpie 0.1.1295');
72
+ this.request = options.fetch ?? fetch;
73
+ this.now = options.now ?? Date.now;
74
+ this.timeoutMs = options.timeoutMs ?? MAGPIE_HTTP_TIMEOUT_MS;
75
+ this.lifetimeSignal = options.lifetimeSignal;
76
+ this.webApi = options.webApi;
77
+ this.onDashboardTiming = options.onDashboardTiming;
78
+ }
79
+ async read(session, signal, includeRoute = false, dshSessionId) {
80
+ signal?.throwIfAborted();
81
+ const agent = magpieAgentForAdapter(session.adapterId);
82
+ const requestedModelId = cleanText(session.modelId);
83
+ if (agent === null || requestedModelId === null)
84
+ return null;
85
+ const providerSessionId = cleanText(session.providerSessionId);
86
+ const nativeSessionId = cleanText(dshSessionId);
87
+ // Native DSH requests use the DSH session ID as their Magpie session
88
+ // identity. Other drivers must never treat that fallback as a provider ID.
89
+ const sessionId = providerSessionId !== null && providerSessionId !== nativeSessionId
90
+ ? providerSessionId
91
+ : agent === 'dsh' ? nativeSessionId : null;
92
+ // Command Code's ACP child tags loopback Magpie requests with the DSH
93
+ // session ID injected by the Host, so the ledger key differs from the ACP
94
+ // session ID shown in the panel. Older Hosts without that ID keep the
95
+ // provider ID so the panel still reports the same "no usage" state.
96
+ const magpieSessionId = agent === 'commandcode' ? nativeSessionId ?? sessionId : sessionId;
97
+ // During a rolling update the ACP child may still tag requests with its ACP
98
+ // session ID; fall back to it when the DSH-ID ledger row is absent.
99
+ const fallbackSessionId = agent === 'commandcode' && nativeSessionId !== null && sessionId !== null && nativeSessionId !== sessionId
100
+ ? sessionId
101
+ : null;
102
+ if (magpieSessionId === null)
103
+ return null;
104
+ return this.readFromWeb(agent, requestedModelId, sessionId, magpieSessionId, fallbackSessionId, signal, includeRoute);
105
+ }
106
+ /**
107
+ * Mark Magpie models and enrich their public metadata. The marker is
108
+ * transient catalog data used by model-list UIs, not session provenance.
109
+ */
110
+ async enrichModelCatalog(adapterId, catalog, signal) {
111
+ const agent = magpieAgentForAdapter(adapterId);
112
+ const [resolvedCatalog, agentCatalog] = await Promise.all([
113
+ Promise.resolve(catalog),
114
+ agent === null ? Promise.resolve(null) : this.loadCatalog(agent, signal),
115
+ ]);
116
+ if (agent === null || agentCatalog === null)
117
+ return resolvedCatalog;
118
+ const hasMatch = resolvedCatalog.groups.some((group) => group.models.some((model) => resolveCatalogModelId(agent, model.id, agentCatalog, model.name) !== null));
119
+ const exposeMissingCodexModels = adapterId === 'codex';
120
+ if (!hasMatch && !exposeMissingCodexModels)
121
+ return resolvedCatalog;
122
+ const metadata = await this.loadModelMetadata(agentCatalog, signal);
123
+ let changed = false;
124
+ let groups = resolvedCatalog.groups.map((group) => {
125
+ let groupChanged = false;
126
+ const models = group.models.map((model) => {
127
+ const id = resolveCatalogModelId(agent, model.id, agentCatalog, model.name);
128
+ if (id === null)
129
+ return model;
130
+ const record = metadata?.get(id);
131
+ const enriched = record === undefined
132
+ ? model.source === 'magpie' ? model : { ...model, source: 'magpie' }
133
+ : mergeMagpieModelMetadata(model, record);
134
+ if (enriched === model)
135
+ return model;
136
+ groupChanged = true;
137
+ return enriched;
138
+ });
139
+ if (!groupChanged)
140
+ return group;
141
+ changed = true;
142
+ return { ...group, models };
143
+ });
144
+ if (exposeMissingCodexModels) {
145
+ const existingModelIds = new Set(groups.flatMap((group) => group.models.map((model) => model.id)));
146
+ const missingModels = [...agentCatalog.models]
147
+ .filter((id) => !existingModelIds.has(id))
148
+ .map((id) => {
149
+ const record = metadata?.get(id);
150
+ const model = {
151
+ id,
152
+ name: record?.name ?? agentCatalog.displayNames.get(id) ?? id,
153
+ efforts: record?.efforts ?? [],
154
+ source: 'magpie',
155
+ };
156
+ return record === undefined ? model : mergeMagpieModelMetadata(model, record);
157
+ });
158
+ if (missingModels.length > 0) {
159
+ const codexGroupIndex = groups.findIndex((group) => group.id === 'codex');
160
+ const targetIndex = codexGroupIndex >= 0 ? codexGroupIndex : groups.length > 0 ? 0 : -1;
161
+ if (targetIndex >= 0) {
162
+ groups = groups.map((group, index) => index === targetIndex
163
+ ? { ...group, models: [...group.models, ...missingModels] }
164
+ : group);
165
+ }
166
+ else {
167
+ groups = [{ id: 'codex', name: 'Codex', models: missingModels }];
168
+ }
169
+ changed = true;
170
+ }
171
+ }
172
+ return changed ? { ...resolvedCatalog, groups } : resolvedCatalog;
173
+ }
174
+ /** Return an exact, CLI-confirmed Magpie model record for trusted Host use. */
175
+ async readModelMetadata(adapterId, modelId, signal) {
176
+ signal?.throwIfAborted();
177
+ const agent = magpieAgentForAdapter(adapterId);
178
+ const requestedModelId = cleanText(modelId);
179
+ if (agent === null || requestedModelId === null)
180
+ return null;
181
+ const catalog = await this.loadCatalog(agent, signal);
182
+ if (catalog === null)
183
+ return null;
184
+ const id = resolveCatalogModelId(agent, requestedModelId, catalog, requestedModelId);
185
+ if (id === null)
186
+ return null;
187
+ const metadata = await this.loadModelMetadata(catalog, signal);
188
+ return metadata?.get(id) ?? null;
189
+ }
190
+ /** Read bounded, graph-ready usage and quota data through authenticated Magpie Web. */
191
+ async readDashboard(period, signal) {
192
+ signal?.throwIfAborted();
193
+ const cached = this.dashboardCache.get(period);
194
+ if (cached !== undefined) {
195
+ if (this.now() - cached.loadedAt >= MAGPIE_DASHBOARD_CACHE_TTL_MS) {
196
+ void this.refreshDashboard(period).catch(() => undefined);
197
+ }
198
+ return cached.dashboard;
199
+ }
200
+ return this.refreshDashboard(period, signal);
201
+ }
202
+ /** Stream cumulative dashboard snapshots as each independent Web API part is ready. */
203
+ async *readDashboardStream(period, signal, force = false) {
204
+ signal?.throwIfAborted();
205
+ const cached = this.dashboardCache.get(period);
206
+ if (!force && cached !== undefined) {
207
+ const stale = this.now() - cached.loadedAt >= MAGPIE_DASHBOARD_CACHE_TTL_MS;
208
+ yield { part: 'cache', dashboard: cached.dashboard, stale };
209
+ if (!stale)
210
+ return;
211
+ }
212
+ let latest;
213
+ for await (const chunk of this.readDashboardNetwork(period, signal)) {
214
+ latest = chunk.dashboard;
215
+ yield chunk;
216
+ }
217
+ if (latest !== undefined)
218
+ this.dashboardCache.set(period, { dashboard: latest, loadedAt: this.now() });
219
+ }
220
+ async refreshDashboard(period, signal) {
221
+ const pending = this.dashboardRefreshes.get(period);
222
+ if (pending !== undefined)
223
+ return awaitWithSignal(pending, signal);
224
+ const request = (async () => {
225
+ let latest;
226
+ for await (const chunk of this.readDashboardNetwork(period, signal))
227
+ latest = chunk.dashboard;
228
+ if (latest === undefined)
229
+ throw new Error('Magpie dashboard returned no snapshot');
230
+ this.dashboardCache.set(period, { dashboard: latest, loadedAt: this.now() });
231
+ return latest;
232
+ })().finally(() => {
233
+ if (this.dashboardRefreshes.get(period) === request)
234
+ this.dashboardRefreshes.delete(period);
235
+ });
236
+ this.dashboardRefreshes.set(period, request);
237
+ return awaitWithSignal(request, signal);
238
+ }
239
+ async *readDashboardNetwork(period, signal) {
240
+ const capturedAt = new Date(this.now()).toISOString();
241
+ let dashboard = emptyMagpieDashboard(period, capturedAt);
242
+ let quotas = null;
243
+ let logoLoad;
244
+ const results = new Map([
245
+ ['usage', this.timedDashboardRead('usage', () => this.readWebJson(`/api/usage?period=${magpieWebPeriod(period)}`, signal))],
246
+ ['quotas', this.timedDashboardRead('quotas', () => this.readWebJson('/api/usage/quotas', signal))],
247
+ ['history', this.timedDashboardRead('history', () => this.readWebJson('/api/usage/quotas/history?days=30', signal))],
248
+ ]);
249
+ const completed = new Map();
250
+ while (results.size > 0) {
251
+ const result = await Promise.race(results.values());
252
+ results.delete(result.part);
253
+ const response = asRecord(result.value);
254
+ const partOk = result.ok && response?.ok === true;
255
+ const partValue = partOk ? response.value : undefined;
256
+ completed.set(result.part, partOk);
257
+ if (result.part === 'usage') {
258
+ const parsed = partOk ? parseMagpieDashboardUsage(partValue) : null;
259
+ dashboard = {
260
+ ...dashboard,
261
+ usageStatus: parsed === null ? 'unavailable' : 'available',
262
+ aggregate: parsed?.aggregate ?? null,
263
+ series: parsed?.series ?? [],
264
+ agents: parsed?.agents ?? [],
265
+ providers: parsed?.providers ?? [],
266
+ models: parsed?.models ?? [],
267
+ accounts: parsed?.accounts ?? [],
268
+ sessions: parsed?.sessions ?? [],
269
+ sessionCount: parsed?.sessionCount ?? null,
270
+ };
271
+ }
272
+ else if (result.part === 'quotas') {
273
+ quotas = partOk ? parseMagpieQuotaCards(partValue) : null;
274
+ dashboard = { ...dashboard, quotaStatus: quotas === null ? 'unavailable' : 'available', quotas: quotas ?? [] };
275
+ if (quotas !== null)
276
+ logoLoad = this.timedDashboardRead('quota-logos', () => this.attachQuotaLogos(quotas, signal)).then((result) => result.value);
277
+ }
278
+ else {
279
+ const parsed = partOk ? parseMagpieQuotaHistory(partValue) : null;
280
+ dashboard = { ...dashboard, quotaHistoryStatus: parsed === null ? 'unavailable' : 'available', quotaHistory: parsed ?? [] };
281
+ }
282
+ yield { part: result.part, dashboard, stale: false };
283
+ }
284
+ dashboard = { ...dashboard, availabilityIssue: [...completed.values()].every((ok) => !ok) ? 'web-api-unavailable' : null };
285
+ yield { part: 'complete', dashboard, stale: false };
286
+ if (logoLoad !== undefined) {
287
+ dashboard = { ...dashboard, quotas: await logoLoad };
288
+ yield { part: 'logos', dashboard, stale: false };
289
+ }
290
+ }
291
+ async timedDashboardRead(part, read) {
292
+ const started = this.now();
293
+ try {
294
+ return { part: part === 'quota-logos' ? 'logos' : part, value: await read(), ok: true };
295
+ }
296
+ finally {
297
+ this.onDashboardTiming?.({ part, elapsedMs: Math.max(0, this.now() - started) });
298
+ }
299
+ }
300
+ /** Read one bounded Web API ledger page and exact-match session identities on Host. */
301
+ async readRequestPage(options, signal) {
302
+ signal?.throwIfAborted();
303
+ if (!isMagpieDashboardPeriod(options.period)
304
+ || !Number.isSafeInteger(options.offset) || options.offset < 0 || options.offset > 1_000_000
305
+ || !Number.isSafeInteger(options.limit) || options.limit < 1 || options.limit > 100)
306
+ return null;
307
+ const sessionId = options.sessionId === undefined ? null : cleanText(options.sessionId);
308
+ const sessionAgent = options.sessionAgent === undefined ? null : cleanText(options.sessionAgent);
309
+ if ((options.sessionId !== undefined && sessionId === null)
310
+ || (options.sessionAgent !== undefined && (sessionAgent === null || !isMagpieAgentId(sessionAgent)))
311
+ || ((sessionId === null) !== (sessionAgent === null)))
312
+ return null;
313
+ const query = new URLSearchParams({ period: magpieWebPeriod(options.period), limit: String(options.limit), offset: String(options.offset) });
314
+ if (sessionId !== null)
315
+ query.set('q', sessionId);
316
+ const response = await this.readWebJson(`/api/usage/requests?${query.toString()}`, signal);
317
+ if (!response.ok)
318
+ return null;
319
+ const root = asRecord(response.value);
320
+ const rawRows = root?.rows;
321
+ if (!Array.isArray(rawRows) || rawRows.length > 500)
322
+ return null;
323
+ const candidates = rawRows.flatMap((row) => {
324
+ const record = asRecord(row);
325
+ if (record === null)
326
+ return [];
327
+ const candidateSession = cleanText(record.session);
328
+ const nativeSession = cleanText(record.native_session);
329
+ const agent = cleanText(record.agent);
330
+ const acceptedAgents = sessionAgent === null ? [] : MAGPIE_USAGE_AGENT_ALIASES[sessionAgent] ?? [sessionAgent];
331
+ if (sessionId !== null
332
+ && (candidateSession !== sessionId && nativeSession !== sessionId || agent === null || !acceptedAgents.includes(agent)))
333
+ return [];
334
+ const item = parseMagpieRequest(record);
335
+ return item === null ? [] : [sessionId === null ? item : { ...item, sessionId }];
336
+ });
337
+ const total = sessionId === null ? safeCount(root?.total) : null;
338
+ return {
339
+ period: options.period,
340
+ offset: options.offset,
341
+ limit: options.limit,
342
+ total,
343
+ hasMore: total === null ? rawRows.length >= options.limit : options.offset + rawRows.length < total,
344
+ sessionId,
345
+ sessionAgent,
346
+ items: candidates.slice(0, options.limit),
347
+ };
348
+ }
349
+ async readFromWeb(agent, modelId, sessionId, magpieSessionId, fallbackSessionId, signal, includeRoute) {
350
+ const capturedAt = new Date(this.now()).toISOString();
351
+ const [usageResult, quotaResult] = await Promise.all([
352
+ this.readWebJson('/api/usage?period=today', signal),
353
+ this.readWebJson('/api/usage/quotas', signal),
354
+ ]);
355
+ const aggregate = usageResult.ok ? readTotals(usageResult.value) : null;
356
+ const primarySession = usageResult.ok && magpieSessionId !== null
357
+ ? readSession(usageResult.value, agent, magpieSessionId)
358
+ : null;
359
+ const fallbackSession = primarySession === null && usageResult.ok && fallbackSessionId !== null
360
+ ? readSession(usageResult.value, agent, fallbackSessionId)
361
+ : null;
362
+ const sessionUsage = primarySession ?? fallbackSession;
363
+ const resolvedSessionId = primarySession !== null ? magpieSessionId : fallbackSession !== null ? fallbackSessionId : magpieSessionId;
364
+ if (sessionUsage === null)
365
+ return null;
366
+ const canReadRoute = includeRoute && resolvedSessionId !== null && resolvedSessionId.length <= 128;
367
+ const routeHistoryResult = canReadRoute
368
+ ? await this.readWebJson(`/api/usage/requests?period=today&offset=0&limit=100&q=${encodeURIComponent(resolvedSessionId)}`, signal)
369
+ : { ok: false };
370
+ const routeRows = routeHistoryResult.ok ? asRecord(routeHistoryResult.value)?.rows : null;
371
+ const routeHistoryValid = Array.isArray(routeRows) && routeRows.length <= 500;
372
+ const routeHistory = routeHistoryResult.ok && routeHistoryValid && resolvedSessionId !== null
373
+ ? readSessionRouteHistory(routeHistoryResult.value, agent, resolvedSessionId)
374
+ : [];
375
+ const route = routeHistory[0]?.route ?? null;
376
+ const routeStatus = route !== null
377
+ ? 'available'
378
+ : resolvedSessionId === null
379
+ ? 'session-unavailable'
380
+ : !includeRoute
381
+ ? 'not-requested'
382
+ : !canReadRoute || !routeHistoryValid
383
+ ? 'unavailable'
384
+ : 'no-route';
385
+ const allQuotas = quotaResult.ok ? parseMagpieQuotas(quotaResult.value) : null;
386
+ const routeProviders = [...new Set([
387
+ providerFromRoute(route),
388
+ ...routeHistory.map((record) => record.provider),
389
+ ].filter((provider) => provider !== null))];
390
+ const upstreamProviders = routeProviders.length > 0
391
+ ? routeProviders
392
+ : [providerFromModelId(modelId, agent)].filter((provider) => provider !== null);
393
+ const upstreamProvider = upstreamProviders[0] ?? null;
394
+ const sessionQuotas = allQuotas === null
395
+ ? []
396
+ : filterSessionQuotas(allQuotas, upstreamProviders, routeHistory);
397
+ const matchingQuotas = markSessionAccounts(sessionQuotas, routeHistory, route);
398
+ const quotas = allQuotas === null ? [] : await this.attachQuotaLogos(matchingQuotas, signal);
399
+ // 同厂商的其它账号单独下发:客户端分组展示,但绝不参与本会话余量。
400
+ const siblingQuotas = allQuotas === null
401
+ ? []
402
+ : await this.attachQuotaLogos(otherProviderAccounts(allQuotas, upstreamProviders, sessionQuotas), signal);
403
+ return {
404
+ agent,
405
+ modelId,
406
+ capturedAt,
407
+ usageStatus: aggregate === null ? 'unavailable' : 'available',
408
+ aggregate,
409
+ sessionId,
410
+ session: sessionUsage,
411
+ routeStatus,
412
+ route,
413
+ upstreamProvider,
414
+ upstreamProviders,
415
+ quotaStatus: allQuotas === null ? 'unavailable' : upstreamProviders.length === 0 ? 'provider-unavailable' : 'available',
416
+ quotas,
417
+ ...(siblingQuotas.length === 0 ? {} : { providerAccounts: siblingQuotas }),
418
+ };
419
+ }
420
+ async attachQuotaLogos(quotas, signal) {
421
+ const requestAssetDataUrl = this.webApi?.requestAssetDataUrl;
422
+ if (typeof requestAssetDataUrl !== 'function')
423
+ return quotas;
424
+ const icons = [...new Set(quotas
425
+ .map((quota) => quota.icon)
426
+ .filter((icon) => icon !== undefined))].slice(0, MAX_MAGPIE_ICON_FETCHES);
427
+ if (icons.length === 0)
428
+ return quotas;
429
+ const logos = new Map();
430
+ await Promise.all(icons.map(async (icon) => {
431
+ const cached = this.quotaLogoCache.get(icon);
432
+ const logo = cached === undefined ? await this.readMagpieLogoDataUrl(icon, signal) : cached;
433
+ if (cached === undefined)
434
+ this.quotaLogoCache.set(icon, logo);
435
+ logos.set(icon, logo);
436
+ }));
437
+ return quotas.map((quota) => {
438
+ const logoDataUrl = quota.icon === undefined ? null : logos.get(quota.icon) ?? null;
439
+ return logoDataUrl === null ? quota : { ...quota, logoDataUrl };
440
+ });
441
+ }
442
+ async readMagpieLogoDataUrl(icon, signal) {
443
+ const requestAssetDataUrl = this.webApi?.requestAssetDataUrl;
444
+ if (typeof requestAssetDataUrl !== 'function')
445
+ return null;
446
+ for (const path of magpieIconAssetPaths(icon)) {
447
+ try {
448
+ const value = await requestAssetDataUrl.call(this.webApi, path, signal === undefined ? {} : { signal });
449
+ if (value !== null && value !== '')
450
+ return value;
451
+ }
452
+ catch {
453
+ signal?.throwIfAborted();
454
+ }
455
+ }
456
+ return null;
457
+ }
458
+ async loadCatalog(agent, signal) {
459
+ const cached = this.catalogs.get(agent);
460
+ const cacheTtl = cached?.catalog === null ? MAGPIE_FAILURE_CACHE_TTL_MS : MAGPIE_CATALOG_TTL_MS;
461
+ if (cached !== undefined && this.now() - cached.loadedAt < cacheTtl) {
462
+ return awaitWithSignal(Promise.resolve(cached.catalog), signal);
463
+ }
464
+ const pending = this.catalogLoads.get(agent);
465
+ if (pending !== undefined)
466
+ return awaitWithSignal(pending, signal);
467
+ const request = Promise.resolve().then(async () => {
468
+ // These checks are independent. Do not make every cold model-catalog
469
+ // request wait for the version subprocess before starting Magpie's
470
+ // model-list subprocess.
471
+ const supportedRequest = this.supportedCli(this.lifetimeSignal);
472
+ const catalogRequest = this.hasFreshUnsupportedVersion()
473
+ ? Promise.resolve(null)
474
+ : Promise.resolve().then(() => this.readModels(agent, this.lifetimeSignal))
475
+ .then((output) => output === null ? null : parseMagpieModelOutput(output, agent))
476
+ .catch(() => null);
477
+ const [supported, catalog] = await Promise.all([supportedRequest, catalogRequest]);
478
+ const result = supported ? catalog : null;
479
+ const unavailableIssue = result !== null
480
+ ? null
481
+ : !supported
482
+ ? this.versionCheck?.executableAvailable === true ? 'cli-version-unsupported' : 'cli-unavailable'
483
+ : 'model-catalog-unavailable';
484
+ this.catalogs.set(agent, { catalog: result, unavailableIssue, loadedAt: this.now() });
485
+ return result;
486
+ })
487
+ .catch(() => null)
488
+ .finally(() => { if (this.catalogLoads.get(agent) === request)
489
+ this.catalogLoads.delete(agent); });
490
+ this.catalogLoads.set(agent, request);
491
+ return awaitWithSignal(request, signal);
492
+ }
493
+ async loadModelMetadata(catalog, signal) {
494
+ signal?.throwIfAborted();
495
+ if (catalog.gatewayOrigin === null)
496
+ return null;
497
+ const catalogFingerprint = [...catalog.models].sort().join('\u0000');
498
+ const loadKey = `${catalog.gatewayOrigin}\u0000${catalogFingerprint}`;
499
+ const cached = this.modelMetadata.get(loadKey);
500
+ if (cached !== undefined
501
+ && cached.origin === catalog.gatewayOrigin
502
+ && cached.catalogFingerprint === catalogFingerprint
503
+ && this.now() - cached.loadedAt < (cached.models === null ? MAGPIE_FAILURE_CACHE_TTL_MS : MAGPIE_MODEL_METADATA_TTL_MS)) {
504
+ return awaitWithSignal(Promise.resolve(cached.models), signal);
505
+ }
506
+ const pending = this.modelMetadataLoads.get(loadKey);
507
+ if (pending !== undefined)
508
+ return awaitWithSignal(pending, signal);
509
+ const request = this.readGatewayJson(catalog.gatewayOrigin, '/v1/models', this.lifetimeSignal)
510
+ .then((response) => response.ok ? parseMagpieModelMetadata(response.value) : null)
511
+ .then((models) => {
512
+ this.modelMetadata.delete(loadKey);
513
+ this.modelMetadata.set(loadKey, {
514
+ origin: catalog.gatewayOrigin,
515
+ catalogFingerprint,
516
+ models,
517
+ loadedAt: this.now(),
518
+ });
519
+ while (this.modelMetadata.size > MAX_MAGPIE_MODEL_METADATA_CACHE_ENTRIES) {
520
+ const oldest = this.modelMetadata.keys().next().value;
521
+ if (oldest === undefined)
522
+ break;
523
+ this.modelMetadata.delete(oldest);
524
+ }
525
+ return models;
526
+ })
527
+ .catch(() => null)
528
+ .finally(() => { if (this.modelMetadataLoads.get(loadKey) === request)
529
+ this.modelMetadataLoads.delete(loadKey); });
530
+ this.modelMetadataLoads.set(loadKey, request);
531
+ return awaitWithSignal(request, signal);
532
+ }
533
+ async supportedCli(signal) {
534
+ if (this.versionCheck !== undefined && this.now() - this.versionCheck.checkedAt < MAGPIE_CATALOG_TTL_MS) {
535
+ return awaitWithSignal(Promise.resolve(this.versionCheck.supported), signal);
536
+ }
537
+ if (this.versionLoad !== undefined)
538
+ return awaitWithSignal(this.versionLoad, signal);
539
+ const load = this.readVersion(this.lifetimeSignal)
540
+ .then((value) => {
541
+ const supported = parseMagpieCliVersion(value);
542
+ this.versionCheck = { supported, executableAvailable: value !== null, checkedAt: this.now() };
543
+ return supported;
544
+ })
545
+ .catch(() => {
546
+ this.versionCheck = { supported: false, executableAvailable: false, checkedAt: this.now() };
547
+ return false;
548
+ })
549
+ .finally(() => { if (this.versionLoad === load)
550
+ this.versionLoad = undefined; });
551
+ this.versionLoad = load;
552
+ return awaitWithSignal(load, signal);
553
+ }
554
+ hasFreshUnsupportedVersion() {
555
+ return this.versionCheck !== undefined
556
+ && !this.versionCheck.supported
557
+ && this.now() - this.versionCheck.checkedAt < MAGPIE_CATALOG_TTL_MS;
558
+ }
559
+ async readGatewayJson(origin, path, signal) {
560
+ const abort = AbortSignal.timeout(this.timeoutMs);
561
+ const requestSignal = signal === undefined ? abort : AbortSignal.any([signal, abort]);
562
+ try {
563
+ const response = await this.request(new URL(path, origin), {
564
+ method: 'GET',
565
+ headers: { Accept: 'application/json', Authorization: 'Bearer magpie' },
566
+ redirect: 'error',
567
+ cache: 'no-store',
568
+ signal: requestSignal,
569
+ });
570
+ if (!response.ok) {
571
+ await response.body?.cancel().catch(() => undefined);
572
+ return { ok: false };
573
+ }
574
+ const value = await readBoundedJson(response);
575
+ if (value === null)
576
+ await response.body?.cancel().catch(() => undefined);
577
+ return value === null ? { ok: false } : { ok: true, value };
578
+ }
579
+ catch {
580
+ return { ok: false };
581
+ }
582
+ }
583
+ async readWebJson(path, signal) {
584
+ if (this.webApi === undefined)
585
+ return { ok: false };
586
+ try {
587
+ return { ok: true, value: await this.webApi.requestJson(path, signal === undefined ? {} : { signal }) };
588
+ }
589
+ catch {
590
+ signal?.throwIfAborted();
591
+ return { ok: false };
592
+ }
593
+ }
594
+ }
595
+ function awaitWithSignal(task, signal) {
596
+ if (signal === undefined)
597
+ return task;
598
+ if (signal.aborted)
599
+ return Promise.reject(signal.reason ?? new DOMException('The operation was aborted', 'AbortError'));
600
+ return new Promise((resolve, reject) => {
601
+ const cleanup = () => signal.removeEventListener('abort', onAbort);
602
+ const onAbort = () => {
603
+ cleanup();
604
+ reject(signal.reason ?? new DOMException('The operation was aborted', 'AbortError'));
605
+ };
606
+ signal.addEventListener('abort', onAbort, { once: true });
607
+ task.then((value) => { cleanup(); resolve(value); }, (error) => { cleanup(); reject(error); });
608
+ });
609
+ }
610
+ /** Strict parser for the human-readable Magpie catalog; unknown formats fail closed. */
611
+ export function parseMagpieModelOutput(output, agent) {
612
+ if (!isMagpieAgentId(agent) || Buffer.byteLength(output, 'utf8') > MAX_MAGPIE_CLI_OUTPUT_BYTES)
613
+ return null;
614
+ const models = new Set();
615
+ const displayNames = new Map();
616
+ const nameCandidates = new Map();
617
+ const gatewayUrls = [];
618
+ const lines = output.split(/\r?\n/u);
619
+ const expectedFooter = `${agent} is shown every provider's models`;
620
+ const hasExpectedAgentFooter = lines.some((line) => {
621
+ const footer = line.trim();
622
+ return footer === expectedFooter || footer.startsWith(`${expectedFooter} ·`);
623
+ });
624
+ for (const line of lines) {
625
+ const text = line.trim();
626
+ const columns = text.split(/\s{2,}/u);
627
+ const model = columns[0];
628
+ const label = columns[1]?.trim();
629
+ if (model !== undefined
630
+ && new RegExp(`^${MAGPIE_MODEL_ID_PATTERN}$`, 'u').test(model)
631
+ && model.length <= 512 && models.size < 10_000) {
632
+ models.add(model);
633
+ const displayName = label === undefined || !safeMetadataText(label, 200)
634
+ ? null
635
+ : label.trim().replace(/\s+/gu, ' ');
636
+ if (displayName !== null && !displayNames.has(model))
637
+ displayNames.set(model, displayName);
638
+ const name = displayName === null ? null : normalizeMagpieModelName(displayName);
639
+ if (name !== null) {
640
+ const candidates = nameCandidates.get(name) ?? [];
641
+ if (!candidates.includes(model))
642
+ candidates.push(model);
643
+ nameCandidates.set(name, candidates);
644
+ }
645
+ }
646
+ const url = text.match(/https?:\/\/[^\s]+/u)?.[0]?.replace(/[),.;]+$/u, '');
647
+ if (url !== undefined && gatewayUrls.length < 4)
648
+ gatewayUrls.push(url);
649
+ }
650
+ if (!hasExpectedAgentFooter || models.size === 0 || gatewayUrls.length !== 1)
651
+ return null;
652
+ const origins = [...new Set(gatewayUrls.map(normalizeLoopbackGatewayOrigin).filter((origin) => origin !== null))];
653
+ if (origins.length !== 1)
654
+ return null;
655
+ const names = new Map();
656
+ for (const [name, candidates] of nameCandidates) {
657
+ if (candidates.length === 1)
658
+ names.set(name, candidates[0]);
659
+ }
660
+ return { models, displayNames, names, gatewayOrigin: origins[0] };
661
+ }
662
+ /** Parse a bounded OpenAI-compatible `/v1/models` response into a safe allowlist. */
663
+ export function parseMagpieModelMetadata(value) {
664
+ const root = asRecord(value);
665
+ const rows = Array.isArray(value) ? value : Array.isArray(root?.data) ? root.data : null;
666
+ if (rows === null || rows.length === 0 || rows.length > MAX_MAGPIE_MODELS)
667
+ return null;
668
+ const models = new Map();
669
+ for (const row of rows) {
670
+ const record = asRecord(row);
671
+ const id = cleanModelId(record?.id);
672
+ if (record === null || id === null || models.has(id))
673
+ return null;
674
+ const modalities = asRecord(record.modalities);
675
+ const reasoningLevels = readReasoningLevels(record);
676
+ const serviceTiers = readMagpieServiceTiers(record.service_tiers);
677
+ const capabilities = readStringList(record.capabilities, 64, 128);
678
+ const metadata = {
679
+ id,
680
+ ...optionalText(record.display_name ?? record.magpie_label ?? record.name, 200, 'name'),
681
+ ...optionalText(record.description, 2_000, 'description'),
682
+ ...optionalPositiveLimit(record.context_window ?? record.context_length, 'contextWindow'),
683
+ ...optionalPositiveLimit(record.max_input_tokens, 'maxInputTokens'),
684
+ ...optionalPositiveLimit(record.max_output_tokens ?? record.max_completion_tokens, 'maxOutputTokens'),
685
+ ...optionalStringList(modalities?.input ?? record.input_modalities, 16, 64, 'inputModalities'),
686
+ ...optionalStringList(modalities?.output ?? record.output_modalities, 16, 64, 'outputModalities'),
687
+ ...(typeof record.reasoning === 'boolean' ? { reasoningSupported: record.reasoning } : {}),
688
+ ...(reasoningLevels === undefined ? {} : { efforts: reasoningLevels }),
689
+ ...(serviceTiers === undefined ? {} : { serviceTiers }),
690
+ ...(capabilities === undefined ? {} : { capabilities }),
691
+ ...optionalText(record.owned_by, 200, 'ownedBy'),
692
+ };
693
+ if (metadata.reasoningSupported === false && metadata.efforts === undefined) {
694
+ models.set(id, { ...metadata, efforts: [] });
695
+ }
696
+ else {
697
+ models.set(id, metadata);
698
+ }
699
+ }
700
+ return models;
701
+ }
702
+ function mergeMagpieModelMetadata(model, metadata) {
703
+ return {
704
+ ...model,
705
+ source: 'magpie',
706
+ ...(metadata.name === undefined ? {} : { name: metadata.name }),
707
+ ...(metadata.description === undefined ? {} : { description: metadata.description }),
708
+ ...(metadata.contextWindow === undefined ? {} : { contextWindow: metadata.contextWindow }),
709
+ ...(metadata.maxInputTokens === undefined ? {} : { maxInputTokens: metadata.maxInputTokens }),
710
+ ...(metadata.maxOutputTokens === undefined ? {} : { maxOutputTokens: metadata.maxOutputTokens }),
711
+ ...(metadata.inputModalities === undefined ? {} : { inputModalities: metadata.inputModalities }),
712
+ ...(metadata.outputModalities === undefined ? {} : { outputModalities: metadata.outputModalities }),
713
+ ...(metadata.reasoningSupported === undefined ? {} : { reasoningSupported: metadata.reasoningSupported }),
714
+ ...(metadata.reasoningSupported === false ? { efforts: [] } : metadata.efforts === undefined ? {} : { efforts: metadata.efforts }),
715
+ ...(metadata.serviceTiers === undefined ? {} : { serviceTiers: metadata.serviceTiers }),
716
+ ...(metadata.capabilities === undefined ? {} : { capabilities: metadata.capabilities }),
717
+ ...(metadata.ownedBy === undefined ? {} : { ownedBy: metadata.ownedBy }),
718
+ };
719
+ }
720
+ function readReasoningLevels(record) {
721
+ for (const key of ['reasoning_levels', 'supported_reasoning_levels']) {
722
+ if (!(key in record))
723
+ continue;
724
+ const value = record[key];
725
+ if (!Array.isArray(value))
726
+ return undefined;
727
+ const levels = value.flatMap((item) => {
728
+ const level = typeof item === 'string'
729
+ ? item
730
+ : asRecord(item)?.effort ?? asRecord(item)?.reasoning_effort ?? asRecord(item)?.id;
731
+ return typeof level === 'string' && isSafeModelToken(level, 64) ? [level.trim()] : [];
732
+ });
733
+ return [...new Set(levels)];
734
+ }
735
+ return undefined;
736
+ }
737
+ function readMagpieServiceTiers(value) {
738
+ if (value === undefined)
739
+ return undefined;
740
+ if (!Array.isArray(value) || value.length > 32)
741
+ return undefined;
742
+ const tiers = value.flatMap((item) => {
743
+ const record = asRecord(item);
744
+ if (record === null)
745
+ return [];
746
+ const id = typeof record.id === 'string' && isSafeModelToken(record.id, 64) ? record.id.trim() : '';
747
+ if (id === '')
748
+ return [];
749
+ const name = typeof record.name === 'string' && safeMetadataText(record.name, 128) ? record.name.trim() : id;
750
+ const description = typeof record.description === 'string' && safeMetadataText(record.description, 512) ? record.description.trim() : undefined;
751
+ return [{ id, name, ...(description === undefined ? {} : { description }) }];
752
+ });
753
+ return tiers;
754
+ }
755
+ function optionalText(value, maxLength, key) {
756
+ return typeof value === 'string' && safeMetadataText(value, maxLength) ? { [key]: value.trim() } : {};
757
+ }
758
+ function optionalPositiveLimit(value, key) {
759
+ const parsed = positiveModelTokenLimit(value);
760
+ return parsed === undefined ? {} : { [key]: parsed };
761
+ }
762
+ function optionalStringList(value, maxItems, maxLength, key) {
763
+ const parsed = readStringList(value, maxItems, maxLength);
764
+ return parsed === undefined ? {} : { [key]: parsed };
765
+ }
766
+ function readStringList(value, maxItems, maxLength) {
767
+ if (!Array.isArray(value) || value.length > maxItems)
768
+ return undefined;
769
+ const items = value.flatMap((item) => typeof item === 'string' && isSafeModelToken(item, maxLength) ? [item.trim()] : []);
770
+ return [...new Set(items)];
771
+ }
772
+ function cleanModelId(value) {
773
+ if (typeof value !== 'string')
774
+ return null;
775
+ const id = value.trim();
776
+ return id.length <= 512 && new RegExp(`^${MAGPIE_MODEL_ID_PATTERN}$`, 'u').test(id) ? id : null;
777
+ }
778
+ function positiveModelTokenLimit(value) {
779
+ return typeof value === 'number'
780
+ && Number.isSafeInteger(value)
781
+ && value > 0
782
+ && value <= MAX_MODEL_TOKEN_LIMIT
783
+ ? value
784
+ : undefined;
785
+ }
786
+ function safeMetadataText(value, maxLength) {
787
+ const text = value.trim();
788
+ return text !== '' && text.length <= maxLength && !/[\u0000-\u001f\u007f]/u.test(text);
789
+ }
790
+ function isSafeModelToken(value, maxLength) {
791
+ const text = value.trim();
792
+ return text !== '' && text.length <= maxLength && /^[A-Za-z0-9][A-Za-z0-9._:-]*$/u.test(text);
793
+ }
794
+ /** Fail closed until the human-readable catalog format is known to match. */
795
+ export function parseMagpieCliVersion(output) {
796
+ if (output === null || Buffer.byteLength(output, 'utf8') > 256)
797
+ return false;
798
+ const match = output.trim().match(/^magpie\s+(\d+)\.(\d+)\.(\d+)$/u);
799
+ if (match === null)
800
+ return false;
801
+ const version = match.slice(1).map(Number);
802
+ for (let index = 0; index < MAGPIE_MINIMUM_CLI_VERSION.length; index += 1) {
803
+ if (version[index] !== MAGPIE_MINIMUM_CLI_VERSION[index]) {
804
+ return version[index] > MAGPIE_MINIMUM_CLI_VERSION[index];
805
+ }
806
+ }
807
+ return true;
808
+ }
809
+ async function readMagpieModels(agent, signal) {
810
+ const result = await runMagpieCommand(['models', agent], signal);
811
+ return result?.status === 0 ? result.stdout : null;
812
+ }
813
+ async function readMagpieVersion(signal) {
814
+ const result = await runMagpieCommand(['--version'], signal);
815
+ return result?.status === 0 ? result.stdout : null;
816
+ }
817
+ async function runMagpieCommand(args, signal) {
818
+ const command = await resolveCommandPath('magpie');
819
+ if (command === null)
820
+ return null;
821
+ const environment = commandEnvironment(command);
822
+ // An inherited flag must not silently hide account-backed catalog entries;
823
+ // this integration reads the complete Magpie catalog but never writes it.
824
+ delete environment.MAGPIE_NO_ACCOUNTS;
825
+ const run = () => runAsyncCommand(spawnSync, command, args, {
826
+ timeout: MAGPIE_CLI_TIMEOUT_MS,
827
+ maxBuffer: MAX_MAGPIE_CLI_OUTPUT_BYTES,
828
+ shell: WINDOWS && /\.(?:cmd|bat)$/iu.test(command),
829
+ env: {
830
+ ...environment,
831
+ // Account-backed providers are part of Magpie's model catalog. Filtering
832
+ // them out makes the CLI catalog disagree with /v1/models and hides valid
833
+ // models such as the WorkBuddy-backed Auto entries.
834
+ NO_COLOR: '1',
835
+ FORCE_COLOR: '0',
836
+ },
837
+ }).then((result) => ({
838
+ status: result.status,
839
+ stdout: Buffer.byteLength(result.stdout, 'utf8') <= MAX_MAGPIE_CLI_OUTPUT_BYTES ? result.stdout : '',
840
+ }));
841
+ try {
842
+ return signal === undefined ? await run() : await withCommandSignal(signal, run);
843
+ }
844
+ catch {
845
+ return null;
846
+ }
847
+ }
848
+ /**
849
+ * Magpie IDs normally match adapter IDs. Keep naming differences explicit;
850
+ * it is used for exact Agent identity matching in Magpie usage records.
851
+ */
852
+ export function magpieAgentForAdapter(adapterId) {
853
+ const agent = MAGPIE_AGENT_BY_ADAPTER[adapterId];
854
+ return agent !== undefined && isMagpieAgentId(agent) ? agent : null;
855
+ }
856
+ /** Return the exact Magpie Agent identities accepted for one adapter. */
857
+ export function magpieUsageAgentAliases(adapterId) {
858
+ const agent = magpieAgentForAdapter(adapterId);
859
+ return agent === null ? [] : MAGPIE_USAGE_AGENT_ALIASES[agent] ?? [agent];
860
+ }
861
+ /**
862
+ * Enrich dashboard session rows only after an exact `(Agent, session ID)` match.
863
+ * Provider session IDs and DSH IDs are both candidates because Command Code and
864
+ * native DSH use different identities across Magpie versions.
865
+ */
866
+ export function attachMagpieSessionNames(dashboard, bindings) {
867
+ if (!Array.isArray(dashboard.sessions) || bindings.length === 0)
868
+ return dashboard;
869
+ const names = new Map();
870
+ const ambiguous = new Set();
871
+ for (const binding of bindings) {
872
+ const name = cleanSessionName(binding.name);
873
+ const dshSessionId = cleanText(binding.dshSessionId);
874
+ if (name === null || dshSessionId === null)
875
+ continue;
876
+ // Match the identity strategy used by compact usage: native DSH uses its
877
+ // DSH ID, Command Code may use either injected DSH or ACP ID, and other
878
+ // adapters use only their Provider session ID.
879
+ const providerSessionId = cleanText(binding.providerSessionId);
880
+ const ids = new Set((binding.adapterId === 'dsh'
881
+ ? [dshSessionId]
882
+ : binding.adapterId === 'command-code'
883
+ ? [dshSessionId, providerSessionId]
884
+ : [providerSessionId]).filter((value) => value !== null));
885
+ for (const agent of magpieUsageAgentAliases(binding.adapterId)) {
886
+ for (const id of ids) {
887
+ const key = `${agent}\u0000${id}`;
888
+ if (ambiguous.has(key))
889
+ continue;
890
+ const previous = names.get(key);
891
+ if (previous !== undefined && previous !== name) {
892
+ names.delete(key);
893
+ ambiguous.add(key);
894
+ }
895
+ else {
896
+ names.set(key, name);
897
+ }
898
+ }
899
+ }
900
+ }
901
+ if (names.size === 0)
902
+ return dashboard;
903
+ let changed = false;
904
+ const sessions = dashboard.sessions.map((session) => {
905
+ if (session.dshSessionName !== undefined)
906
+ return session;
907
+ const name = names.get(`${session.agent}\u0000${session.id}`);
908
+ if (name === undefined)
909
+ return session;
910
+ changed = true;
911
+ return { ...session, dshSessionName: name };
912
+ });
913
+ return changed ? { ...dashboard, sessions } : dashboard;
914
+ }
915
+ function isMagpieAgentId(value) {
916
+ return value.length <= 64 && /^[a-z0-9][a-z0-9-]*$/u.test(value);
917
+ }
918
+ function normalizeLoopbackGatewayOrigin(value) {
919
+ try {
920
+ const url = new URL(value);
921
+ const hostname = url.hostname.toLowerCase();
922
+ if (url.protocol !== 'http:'
923
+ || (hostname !== '127.0.0.1' && hostname !== 'localhost' && hostname !== '[::1]' && hostname !== '::1')
924
+ || url.username !== '' || url.password !== '' || url.search !== '' || url.hash !== ''
925
+ || url.pathname.replace(/\/$/u, '') !== '/v1')
926
+ return null;
927
+ return url.origin;
928
+ }
929
+ catch {
930
+ return null;
931
+ }
932
+ }
933
+ async function readBoundedJson(response) {
934
+ const contentLength = Number(response.headers.get('content-length'));
935
+ if (Number.isFinite(contentLength) && contentLength > MAX_MAGPIE_RESPONSE_BYTES)
936
+ return null;
937
+ const reader = response.body?.getReader();
938
+ if (reader === undefined)
939
+ return null;
940
+ const chunks = [];
941
+ let total = 0;
942
+ try {
943
+ while (true) {
944
+ const { done, value } = await reader.read();
945
+ if (done)
946
+ break;
947
+ total += value.byteLength;
948
+ if (total > MAX_MAGPIE_RESPONSE_BYTES) {
949
+ await reader.cancel();
950
+ return null;
951
+ }
952
+ chunks.push(value);
953
+ }
954
+ }
955
+ finally {
956
+ reader.releaseLock();
957
+ }
958
+ try {
959
+ const bytes = new Uint8Array(total);
960
+ let offset = 0;
961
+ for (const chunk of chunks) {
962
+ bytes.set(chunk, offset);
963
+ offset += chunk.byteLength;
964
+ }
965
+ return JSON.parse(new TextDecoder().decode(bytes));
966
+ }
967
+ catch {
968
+ return null;
969
+ }
970
+ }
971
+ function readTotals(value) {
972
+ const record = asRecord(value);
973
+ if (record === null)
974
+ return null;
975
+ const calls = safeCount(record.calls);
976
+ const errors = safeCount(record.errors);
977
+ const inputTokens = safeCount(record.input);
978
+ const outputTokens = safeCount(record.output);
979
+ const cacheReadTokens = safeCount(record.cache_read);
980
+ const cacheWriteTokens = safeCount(record.cache_write);
981
+ const costUsd = safeCost(record.cost);
982
+ if ([calls, errors, inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens, costUsd].every((item) => item === null))
983
+ return null;
984
+ return { calls, errors, inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens, costUsd };
985
+ }
986
+ function readSession(value, agent, sessionId) {
987
+ const sessions = asRecord(value)?.sessions;
988
+ if (!Array.isArray(sessions))
989
+ return null;
990
+ const usageAgents = MAGPIE_USAGE_AGENT_ALIASES[agent] ?? [agent];
991
+ const row = sessions.find((item) => {
992
+ const record = asRecord(item);
993
+ const usageAgent = cleanText(record?.agent);
994
+ return cleanText(record?.id) === sessionId && usageAgent !== null && usageAgents.includes(usageAgent);
995
+ });
996
+ const record = asRecord(row);
997
+ const totals = readTotals(record);
998
+ const usageAgent = cleanText(record?.agent);
999
+ return record !== null && usageAgent !== null && totals !== null ? { id: sessionId, agent: usageAgent, ...totals } : null;
1000
+ }
1001
+ /** Read the durable request ledger when Magpie's short in-memory trace has expired. */
1002
+ function readSessionRouteHistory(value, agent, sessionId) {
1003
+ const rows = asRecord(value)?.rows;
1004
+ if (!Array.isArray(rows) || rows.length > 500)
1005
+ return [];
1006
+ const usageAgents = MAGPIE_USAGE_AGENT_ALIASES[agent] ?? [agent];
1007
+ return rows.slice(0, 100).flatMap((item) => {
1008
+ const record = asRecord(item);
1009
+ const rowAgent = cleanText(record?.agent);
1010
+ const session = cleanText(record?.session);
1011
+ const nativeSession = cleanText(record?.native_session);
1012
+ const provider = routeText(record?.provider);
1013
+ if (record === null || rowAgent === null || !usageAgents.includes(rowAgent)
1014
+ || (session !== sessionId && nativeSession !== sessionId) || provider === null)
1015
+ return [];
1016
+ const requested = routeText(record.req);
1017
+ const model = routeText(record.model);
1018
+ const served = routeText(record.served);
1019
+ const status = routeStatusText(record.status);
1020
+ const rowModel = model === null
1021
+ ? null
1022
+ : model.startsWith(`${provider}/`) ? model : `${provider}/${model}`;
1023
+ const group = routeText(record.group) ?? (requested?.startsWith('group/') ? requested.slice('group/'.length) : null);
1024
+ const route = {
1025
+ asked: requested,
1026
+ group,
1027
+ rule: readRule(record.rule),
1028
+ model: rowModel,
1029
+ effort: routeText(record.effort),
1030
+ tries: [],
1031
+ done: true,
1032
+ status,
1033
+ served,
1034
+ routeId: safeRouteId(record.route_id),
1035
+ time: routeText(record.t),
1036
+ providerAccount: routeText(record.providerAccount),
1037
+ };
1038
+ return [{ route, provider, account: routeText(record.providerAccount) }];
1039
+ }).sort((left, right) => routeTime(right.route.time) - routeTime(left.route.time));
1040
+ }
1041
+ function routeTime(value) {
1042
+ if (value === null || value === undefined)
1043
+ return 0;
1044
+ const time = Date.parse(value);
1045
+ return Number.isFinite(time) ? time : 0;
1046
+ }
1047
+ /**
1048
+ * 选出本会话确实使用过的上游账号配额。
1049
+ *
1050
+ * 归属必须严格:请求历史里没有出现的账号不能算作本会话的配额。
1051
+ *
1052
+ * - 账号维度能对上:只留命中的账号。
1053
+ * - 上游不提供账号名(Codex 这类量贩账号没有 `user`),无从按账号筛选:保留该厂商
1054
+ * 全部候选。过去这里返回空数组,`quotaStatus` 仍是 `available`,界面就只剩下
1055
+ * "上游没有报告配额窗口"的空态 —— 明明识别出了 `glorinfo-api-platform`,却看不到
1056
+ * 它的额度。
1057
+ * - 有账号记录但一条都不匹配:返回空,宁可显示"没有可用配额"也不能把别的账号的额度
1058
+ * 说成本会话的。
1059
+ */
1060
+ function filterSessionQuotas(quotas, providers, history) {
1061
+ return providers.flatMap((provider) => {
1062
+ const candidates = quotas.filter((quota) => quota.provider === provider);
1063
+ const accounts = new Set(history
1064
+ .filter((record) => record.provider === provider && record.account !== null)
1065
+ .map((record) => record.account));
1066
+ if (accounts.size === 0)
1067
+ return candidates;
1068
+ const matched = candidates.filter((quota) => quota.user !== null && accounts.has(quota.user));
1069
+ return matched.length > 0 ? matched : candidates.filter((quota) => quota.user === null);
1070
+ });
1071
+ }
1072
+ /**
1073
+ * 与本会话同一厂商、但本会话没用过的其它账号。
1074
+ *
1075
+ * 单独返回而不是并进 `quotas`:客户端用它们做"同厂商账号分组"的补充展示,
1076
+ * 但这些账号的额度绝不参与本会话余量判断。顺序沿用上游。
1077
+ */
1078
+ function otherProviderAccounts(quotas, providers, sessionQuotas) {
1079
+ const claimed = new Set(sessionQuotas.map((quota) => `${quota.provider}\u0000${quota.user ?? ''}`));
1080
+ return providers.flatMap((provider) => quotas
1081
+ .filter((quota) => quota.provider === provider)
1082
+ .filter((quota) => quota.user !== null && !claimed.has(`${quota.provider}\u0000${quota.user}`)));
1083
+ }
1084
+ /**
1085
+ * 标记本会话实际使用过的账号。
1086
+ *
1087
+ * 只有能追溯到会话请求记录的账号才标 `active`;route 的账号字段优先于请求历史,
1088
+ * 因为它来自 Magpie 对这一次请求的精确归属。
1089
+ *
1090
+ * 账号名比对必须同时限定厂商:不同厂商的账号名会重名(WorkBuddy 与 WorkBuddy AI 都有
1091
+ * `zj59122704501@gmail.com`),只比名字会把别的厂商的账号标成本会话正在使用。
1092
+ * 无法确认时保持未标记,客户端据此显示"未知活动账号",而不是随便挑一个账号当"正在使用"。
1093
+ */
1094
+ function markSessionAccounts(quotas, history, route) {
1095
+ const used = new Set(history
1096
+ .filter((record) => record.account !== null)
1097
+ .map((record) => `${record.provider}\u0000${record.account}`));
1098
+ const routedProvider = providerFromRoute(route);
1099
+ const routedAccount = route?.providerAccount ?? null;
1100
+ const routedKey = routedAccount === null || routedProvider === null ? null : `${routedProvider}\u0000${routedAccount}`;
1101
+ if (used.size === 0 && routedKey === null)
1102
+ return quotas;
1103
+ // 每个厂商只承认一个活动账号:精确路由优先,其次是首个命中的历史账号。
1104
+ const claimed = new Set();
1105
+ return quotas.map((quota) => {
1106
+ if (quota.user === null)
1107
+ return quota;
1108
+ const key = `${quota.provider}\u0000${quota.user}`;
1109
+ if (claimed.has(key))
1110
+ return quota;
1111
+ if (key !== routedKey && !used.has(key))
1112
+ return quota;
1113
+ claimed.add(key);
1114
+ return { ...quota, active: true };
1115
+ });
1116
+ }
1117
+ function safeRouteId(value) {
1118
+ return typeof value === 'number' && Number.isSafeInteger(value) && value > 0 ? value : null;
1119
+ }
1120
+ /** Parse the bounded `/v1/magpie/quotas` envelope without exposing raw provider records. */
1121
+ export function parseMagpieQuotas(value) {
1122
+ const root = asRecord(value);
1123
+ const rows = Array.isArray(value) ? value : Array.isArray(root?.data) ? root.data : null;
1124
+ if (rows === null || rows.length > 512)
1125
+ return null;
1126
+ const quotas = [];
1127
+ for (const row of rows) {
1128
+ const record = asRecord(row);
1129
+ const provider = routeText(record?.provider);
1130
+ const name = routeText(record?.name);
1131
+ if (record === null || provider === null || name === null)
1132
+ return null;
1133
+ const windowsValue = record.windows;
1134
+ if (!Array.isArray(windowsValue) || windowsValue.length > 64)
1135
+ return null;
1136
+ const windows = windowsValue.flatMap((item) => {
1137
+ const window = asRecord(item);
1138
+ const windowName = routeText(window?.name);
1139
+ return window === null || windowName === null ? [] : [readQuotaWindow(window, windowName)];
1140
+ });
1141
+ if (windows.length !== windowsValue.length)
1142
+ return null;
1143
+ quotas.push({
1144
+ provider,
1145
+ name,
1146
+ ...optionalQuotaIcon(record.icon),
1147
+ kind: routeText(record.kind),
1148
+ user: routeText(record.user),
1149
+ plan: routeText(record.plan),
1150
+ alias: routeText(record.alias),
1151
+ balance: routeText(record.balance),
1152
+ readAt: routeText(record.readAt),
1153
+ windows,
1154
+ ...sessionQuotaDaily(record),
1155
+ ...readQuotaAccountMeta(record),
1156
+ });
1157
+ }
1158
+ return quotas;
1159
+ }
1160
+ /** Normalize the live aggregate and per-dimension usage response. */
1161
+ export function parseMagpieDashboardUsage(value) {
1162
+ const root = asRecord(value);
1163
+ if (root === null)
1164
+ return null;
1165
+ const hasMetrics = ['calls', 'errors', 'input', 'output', 'cache_read', 'cache_write', 'cost'].some((key) => key in root);
1166
+ if (!hasMetrics && !Array.isArray(root.series) && !Array.isArray(root.sessions))
1167
+ return null;
1168
+ const series = readMagpieSeries(root.series);
1169
+ const agents = readMagpieUsageGroups(root.agents, 'agent');
1170
+ const providers = readMagpieUsageGroups(root.providerKeys ?? root.providers, 'provider');
1171
+ const models = readMagpieUsageGroups(root.models, 'model');
1172
+ const accounts = readMagpieUsageGroups(root.accounts, 'account');
1173
+ const sessions = readMagpieUsageSessions(root.sessions);
1174
+ if (series === null || agents === null || providers === null || models === null || accounts === null || sessions === null)
1175
+ return null;
1176
+ return {
1177
+ aggregate: readMagpieUsageMetrics(root),
1178
+ series,
1179
+ agents,
1180
+ providers,
1181
+ models,
1182
+ accounts,
1183
+ sessions,
1184
+ sessionCount: safeCount(root.sessionCount),
1185
+ };
1186
+ }
1187
+ /** Normalize quota cards while preserving nullable values and bounded history. */
1188
+ export function parseMagpieQuotaCards(value) {
1189
+ const root = asRecord(value);
1190
+ const rows = Array.isArray(value) ? value : Array.isArray(root?.data) ? root.data : null;
1191
+ if (rows === null || rows.length > 512)
1192
+ return null;
1193
+ const quotas = [];
1194
+ for (const row of rows) {
1195
+ const record = asRecord(row);
1196
+ const provider = routeText(record?.provider);
1197
+ const name = routeText(record?.name);
1198
+ if (record === null || provider === null || name === null
1199
+ || !Array.isArray(record.windows) || record.windows.length > 64)
1200
+ return null;
1201
+ const windows = record.windows.flatMap((item) => {
1202
+ const window = asRecord(item);
1203
+ const windowName = routeText(window?.name);
1204
+ if (window === null || windowName === null)
1205
+ return [];
1206
+ return [{
1207
+ name: windowName,
1208
+ usedPercent: quotaUsedPercent(window),
1209
+ remainingPercent: quotaRemainingPercent(window),
1210
+ resetsAt: routeText(window.resetsAt),
1211
+ display: routeText(window.display),
1212
+ amount: safeDecimal(window.amount),
1213
+ limit: safeDecimal(window.limit),
1214
+ unit: routeText(window.unit),
1215
+ holdsWhy: routeText(window.holdsWhy),
1216
+ runsOutAt: routeText(window.runsOutAt),
1217
+ runsOut: safeDecimal(window.runsOut),
1218
+ }];
1219
+ });
1220
+ if (windows.length !== record.windows.length)
1221
+ return null;
1222
+ const dailyRecord = record.daily === undefined ? null : asRecord(record.daily);
1223
+ const dailyPoints = dailyRecord === null ? [] : dailyRecord.days;
1224
+ if (dailyRecord !== null && (!Array.isArray(dailyPoints) || dailyPoints.length > 366))
1225
+ return null;
1226
+ const days = (Array.isArray(dailyPoints) ? dailyPoints : []).flatMap((item) => {
1227
+ const point = asRecord(item);
1228
+ const day = routeText(point?.day);
1229
+ if (point === null || day === null)
1230
+ return [];
1231
+ const used = safeDecimal(point.used);
1232
+ return [{ day, used }];
1233
+ });
1234
+ if (days.length !== (Array.isArray(dailyPoints) ? dailyPoints.length : 0))
1235
+ return null;
1236
+ quotas.push({
1237
+ provider,
1238
+ name,
1239
+ ...optionalQuotaIcon(record.icon),
1240
+ kind: routeText(record.kind),
1241
+ user: routeText(record.user),
1242
+ plan: routeText(record.plan),
1243
+ alias: routeText(record.alias),
1244
+ balance: routeText(record.balance),
1245
+ readAt: routeText(record.readAt),
1246
+ windows,
1247
+ daily: { since: routeText(dailyRecord?.since), days },
1248
+ ...readQuotaAccountMeta(record),
1249
+ });
1250
+ }
1251
+ return quotas;
1252
+ }
1253
+ export function parseMagpieQuotaHistory(value) {
1254
+ const root = asRecord(value);
1255
+ const rows = Array.isArray(value) ? value : Array.isArray(root?.data) ? root.data : null;
1256
+ if (rows === null || rows.length > 512)
1257
+ return null;
1258
+ const history = [];
1259
+ for (const row of rows) {
1260
+ const record = asRecord(row);
1261
+ const provider = routeText(record?.provider);
1262
+ if (record === null || provider === null || !Array.isArray(record.lines) || record.lines.length > 64)
1263
+ return null;
1264
+ const lines = record.lines.flatMap((item) => {
1265
+ const line = asRecord(item);
1266
+ const name = routeText(line?.name);
1267
+ if (line === null || name === null || !Array.isArray(line.points) || line.points.length > 2_000)
1268
+ return [];
1269
+ const points = line.points.flatMap((pointValue) => {
1270
+ const point = asRecord(pointValue);
1271
+ const at = routeText(point?.at);
1272
+ return point === null || at === null ? [] : [{
1273
+ at,
1274
+ left: safeDecimal(point.left),
1275
+ start: routeText(point.start),
1276
+ resetsAt: routeText(point.resetsAt),
1277
+ }];
1278
+ });
1279
+ if (points.length !== line.points.length)
1280
+ return [];
1281
+ return [{ name, points }];
1282
+ });
1283
+ if (lines.length !== record.lines.length)
1284
+ return null;
1285
+ history.push({ provider, user: routeText(record.user), lines });
1286
+ }
1287
+ return history;
1288
+ }
1289
+ function readMagpieUsageMetrics(record) {
1290
+ return {
1291
+ calls: safeCount(record.calls),
1292
+ errors: safeCount(record.errors),
1293
+ retried: safeCount(record.retried),
1294
+ inputTokens: safeCount(record.input),
1295
+ outputTokens: safeCount(record.output),
1296
+ cacheReadTokens: safeCount(record.cache_read),
1297
+ cacheWriteTokens: safeCount(record.cache_write),
1298
+ reasoningTokens: safeCount(record.reasoning),
1299
+ cost: safeDecimal(record.cost),
1300
+ unpriced: safeDecimal(record.unpriced),
1301
+ credits: safeDecimal(record.credits),
1302
+ credited: safeDecimal(record.credited),
1303
+ timed: safeCount(record.timed),
1304
+ ttftMs: safeDecimal(record.ttft_ms),
1305
+ decodeMs: safeDecimal(record.decode_ms),
1306
+ decodeTokens: safeCount(record.decode_out),
1307
+ decodeCount: safeCount(record.decode_n),
1308
+ };
1309
+ }
1310
+ function readMagpieSeries(value) {
1311
+ if (value === undefined)
1312
+ return [];
1313
+ if (!Array.isArray(value) || value.length > 2_000)
1314
+ return null;
1315
+ return value.flatMap((item) => {
1316
+ const record = asRecord(item);
1317
+ return record === null ? [] : [{
1318
+ time: routeText(record.time),
1319
+ label: routeText(record.label),
1320
+ ...readMagpieUsageMetrics(record),
1321
+ }];
1322
+ });
1323
+ }
1324
+ function readMagpieUsageGroups(value, dimension) {
1325
+ if (value === undefined)
1326
+ return [];
1327
+ if (!Array.isArray(value) || value.length > 2_000)
1328
+ return null;
1329
+ const idKeys = {
1330
+ agent: ['id', 'agent'],
1331
+ provider: ['provider', 'id'],
1332
+ model: ['model', 'id'],
1333
+ account: ['account', 'id'],
1334
+ };
1335
+ const groups = value.flatMap((item) => {
1336
+ const record = asRecord(item);
1337
+ if (record === null)
1338
+ return [];
1339
+ const id = firstRouteText(record, idKeys[dimension]);
1340
+ if (id === null)
1341
+ return [];
1342
+ return [{
1343
+ id,
1344
+ name: routeText(record.name),
1345
+ provider: routeText(record.provider),
1346
+ model: routeText(record.model),
1347
+ account: routeText(record.account),
1348
+ agent: routeText(record.agent ?? record.id),
1349
+ ...readMagpieUsageMetrics(record),
1350
+ }];
1351
+ });
1352
+ if (dimension !== 'provider')
1353
+ return groups;
1354
+ const byProvider = new Map();
1355
+ for (const group of groups) {
1356
+ const current = byProvider.get(group.id);
1357
+ if (current === undefined) {
1358
+ byProvider.set(group.id, group);
1359
+ continue;
1360
+ }
1361
+ byProvider.set(group.id, {
1362
+ ...current,
1363
+ calls: sumNullable(current.calls, group.calls),
1364
+ errors: sumNullable(current.errors, group.errors),
1365
+ retried: sumNullable(current.retried, group.retried),
1366
+ inputTokens: sumNullable(current.inputTokens, group.inputTokens),
1367
+ outputTokens: sumNullable(current.outputTokens, group.outputTokens),
1368
+ cacheReadTokens: sumNullable(current.cacheReadTokens, group.cacheReadTokens),
1369
+ cacheWriteTokens: sumNullable(current.cacheWriteTokens, group.cacheWriteTokens),
1370
+ reasoningTokens: sumNullable(current.reasoningTokens, group.reasoningTokens),
1371
+ cost: sumNullable(current.cost, group.cost),
1372
+ unpriced: sumNullable(current.unpriced, group.unpriced),
1373
+ credits: sumNullable(current.credits, group.credits),
1374
+ credited: sumNullable(current.credited, group.credited),
1375
+ timed: sumNullable(current.timed, group.timed),
1376
+ ttftMs: null,
1377
+ decodeMs: null,
1378
+ decodeTokens: sumNullable(current.decodeTokens, group.decodeTokens),
1379
+ decodeCount: sumNullable(current.decodeCount, group.decodeCount),
1380
+ });
1381
+ }
1382
+ return [...byProvider.values()];
1383
+ }
1384
+ function readMagpieUsageSessions(value) {
1385
+ if (value === undefined)
1386
+ return [];
1387
+ if (!Array.isArray(value) || value.length > 2_000)
1388
+ return null;
1389
+ return value.flatMap((item) => {
1390
+ const record = asRecord(item);
1391
+ const id = cleanText(record?.id);
1392
+ const agent = cleanText(record?.agent);
1393
+ return record === null || id === null || agent === null ? [] : [{ id, agent, ...readMagpieUsageMetrics(record) }];
1394
+ });
1395
+ }
1396
+ function parseMagpieRequest(record) {
1397
+ const agent = routeText(record.agent);
1398
+ const provider = routeText(record.provider);
1399
+ const requestedModel = routeText(record.req);
1400
+ const servedModel = routeText(record.served);
1401
+ const group = requestedModel?.startsWith('group/') === true ? requestedModel.slice('group/'.length) : null;
1402
+ return {
1403
+ routeId: safeRouteId(record.route_id),
1404
+ time: routeText(record.t),
1405
+ agent,
1406
+ provider,
1407
+ account: routeText(record.providerAccount),
1408
+ requestedModel,
1409
+ servedModel,
1410
+ group,
1411
+ effort: routeText(record.effort),
1412
+ inputTokens: safeCount(record.in),
1413
+ outputTokens: safeCount(record.out),
1414
+ cacheReadTokens: safeCount(record.cache_read),
1415
+ cacheWriteTokens: safeCount(record.cache_write),
1416
+ reasoningTokens: safeCount(record.reasoning),
1417
+ cost: safeDecimal(record.cost),
1418
+ priced: typeof record.priced === 'boolean' ? record.priced : null,
1419
+ status: routeStatusText(record.status),
1420
+ durationMs: safeDecimal(record.ms),
1421
+ ttftMs: safeDecimal(record.ttft_ms),
1422
+ firstTextMs: safeDecimal(record.first_text_ms),
1423
+ firstReasoningMs: safeDecimal(record.first_reasoning_ms),
1424
+ flowMs: safeDecimal(record.flow_ms),
1425
+ sessionId: cleanText(record.session) ?? cleanText(record.native_session),
1426
+ };
1427
+ }
1428
+ function firstRouteText(record, keys) {
1429
+ for (const key of keys) {
1430
+ const value = routeText(record[key]);
1431
+ if (value !== null)
1432
+ return value;
1433
+ }
1434
+ return null;
1435
+ }
1436
+ function sumNullable(left, right) {
1437
+ return left === null && right === null ? null : (left ?? 0) + (right ?? 0);
1438
+ }
1439
+ function isMagpieDashboardPeriod(value) {
1440
+ return value === 'today' || value === 'week' || value === 'month' || value === 'all';
1441
+ }
1442
+ function magpieWebPeriod(period) {
1443
+ switch (period) {
1444
+ case 'today': return 'today';
1445
+ case 'week': return '7d';
1446
+ case 'month': return '30d';
1447
+ case 'all': return 'all';
1448
+ }
1449
+ }
1450
+ function emptyMagpieDashboard(period, capturedAt) {
1451
+ return {
1452
+ period,
1453
+ capturedAt,
1454
+ availabilityIssue: null,
1455
+ usageStatus: 'unavailable',
1456
+ aggregate: null,
1457
+ series: [],
1458
+ agents: [],
1459
+ providers: [],
1460
+ models: [],
1461
+ accounts: [],
1462
+ sessions: [],
1463
+ sessionCount: null,
1464
+ quotaStatus: 'unavailable',
1465
+ quotas: [],
1466
+ quotaHistoryStatus: 'unavailable',
1467
+ quotaHistory: [],
1468
+ };
1469
+ }
1470
+ /**
1471
+ * 窗口使用的百分比。
1472
+ *
1473
+ * Magpie 的 `used` 始终是 0–100 的百分比(见其 `auth.usage` 契约),但 `remaining`
1474
+ * 不一定:同一份数据里既有 `remaining: 96` 这种百分比,也有 `remaining: 86.57`
1475
+ * 配 `amount: 322.25 / limit: 2400` 这种"剩余量"。凡是带 `limit`(或 `amount`)的窗口,
1476
+ * `remaining` 一律按数量解释,不能直接当成 0–100 的百分比,否则 WorkBuddy 的
1477
+ * `322 / 2400` 会被读成"剩余 86.57%",和 `display` 里的数量对不上。
1478
+ */
1479
+ function quotaUsedPercent(record) {
1480
+ return safePercent(record.used);
1481
+ }
1482
+ function quotaRemainingPercent(record) {
1483
+ const counted = safeDecimal(record.limit) !== null || safeDecimal(record.amount) !== null;
1484
+ if (counted) {
1485
+ const used = quotaUsedPercent(record);
1486
+ return used === null ? null : 100 - used;
1487
+ }
1488
+ return safePercent(record.remaining);
1489
+ }
1490
+ function readQuotaWindow(record, name) {
1491
+ return {
1492
+ name,
1493
+ usedPercent: quotaUsedPercent(record),
1494
+ remainingPercent: quotaRemainingPercent(record),
1495
+ resetsAt: routeText(record.resetsAt),
1496
+ display: routeText(record.display),
1497
+ amount: safeDecimal(record.amount),
1498
+ limit: safeDecimal(record.limit),
1499
+ unit: routeText(record.unit),
1500
+ holdsWhy: routeText(record.holdsWhy),
1501
+ startsAt: routeText(record.startsAt),
1502
+ runsOut: safeDecimal(record.runsOut),
1503
+ runsOutAt: routeText(record.runsOutAt),
1504
+ };
1505
+ }
1506
+ /**
1507
+ * Read the daily check-in result of providers that have one (WorkBuddy, Trae, MiniMax).
1508
+ *
1509
+ * `outcome` stays an upstream string: the client only localizes the outcomes it knows, so a
1510
+ * new vendor state never gets presented as a successful check-in.
1511
+ */
1512
+ function readQuotaCheckin(value) {
1513
+ const record = asRecord(value);
1514
+ if (record === null)
1515
+ return null;
1516
+ const checkin = {
1517
+ day: routeText(record.day),
1518
+ at: routeText(record.at),
1519
+ outcome: routeText(record.outcome),
1520
+ credit: safeDecimal(record.credit),
1521
+ streak: safeCount(record.streak),
1522
+ };
1523
+ return Object.values(checkin).every((item) => item === null) ? null : checkin;
1524
+ }
1525
+ function readQuotaDaily(value) {
1526
+ const record = asRecord(value);
1527
+ if (record === null)
1528
+ return undefined;
1529
+ const points = record.days;
1530
+ if (!Array.isArray(points) || points.length > 366)
1531
+ return undefined;
1532
+ const days = points.flatMap((item) => {
1533
+ const point = asRecord(item);
1534
+ const day = routeText(point?.day);
1535
+ return point === null || day === null ? [] : [{ day, used: safeDecimal(point.used) }];
1536
+ });
1537
+ if (days.length !== points.length)
1538
+ return undefined;
1539
+ return { since: routeText(record.since), days };
1540
+ }
1541
+ /**
1542
+ * Read a provider's remaining reset cards without exposing the vendor's raw record.
1543
+ *
1544
+ * `count` 缺失与 0 不同:上游在 0 张时会省略整个对象,因此这里只在对象存在时才返回,
1545
+ * 客户端把缺失显示为"未知"而不是"没有可用重置卡"。
1546
+ */
1547
+ function readQuotaResets(value) {
1548
+ const record = asRecord(value);
1549
+ if (record === null)
1550
+ return null;
1551
+ const eachPoints = record.each;
1552
+ const each = Array.isArray(eachPoints)
1553
+ ? eachPoints.flatMap((item) => {
1554
+ const point = asRecord(item);
1555
+ if (point === null)
1556
+ return [];
1557
+ return [{ window: routeText(point.window), until: routeText(point.until) }];
1558
+ }).slice(0, 64)
1559
+ : [];
1560
+ return {
1561
+ count: safeCount(record.count),
1562
+ until: routeText(record.until),
1563
+ each,
1564
+ byWindow: record.byWindow === true,
1565
+ fiveHour: safeCount(record.fiveHour),
1566
+ weekly: safeCount(record.weekly),
1567
+ };
1568
+ }
1569
+ /** 会话级配额卡只带上 `daily`;上游缺字段时整个属性不出现。 */
1570
+ function sessionQuotaDaily(record) {
1571
+ const daily = readQuotaDaily(record.daily);
1572
+ return daily === undefined ? {} : { daily };
1573
+ }
1574
+ /**
1575
+ * Read the account-level fields shared by both quota parsers.
1576
+ *
1577
+ * `/api/usage/quotas` (session popover) and the dashboard read the same rows; keeping these
1578
+ * fields in one place stops the two views drifting apart. Absent values stay `undefined` so
1579
+ * older Magpie builds keep working.
1580
+ */
1581
+ function readQuotaAccountMeta(record) {
1582
+ const checkin = readQuotaCheckin(record.checkin);
1583
+ const resets = readQuotaResets(record.resets);
1584
+ return {
1585
+ ...(typeof record.active === 'boolean' ? { active: record.active } : {}),
1586
+ ...(checkin === null ? {} : { checkin }),
1587
+ ...(record.checkins === true ? { checkins: true } : {}),
1588
+ error: routeText(record.error),
1589
+ until: routeText(record.until),
1590
+ renew: routeText(record.renew),
1591
+ ...(resets === null ? {} : { resets }),
1592
+ credits: routeText(record.credits),
1593
+ };
1594
+ }
1595
+ function optionalQuotaIcon(value) {
1596
+ const icon = routeText(value);
1597
+ if (icon === null)
1598
+ return {};
1599
+ if (/^file:[A-Za-z0-9][A-Za-z0-9._~-]{0,255}$/u.test(icon))
1600
+ return { icon };
1601
+ return /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u.test(icon) ? { icon } : {};
1602
+ }
1603
+ function magpieIconAssetPaths(icon) {
1604
+ if (/^file:[A-Za-z0-9][A-Za-z0-9._~-]{0,255}$/u.test(icon)) {
1605
+ return [`/api/icons/${encodeURIComponent(icon.slice('file:'.length))}`];
1606
+ }
1607
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u.test(icon))
1608
+ return [];
1609
+ return [`/icons/${icon}.svg`, `/icons/${icon}.png`];
1610
+ }
1611
+ function providerFromRoute(route) {
1612
+ if (route === null)
1613
+ return null;
1614
+ const models = [route.model, route.served, ...route.tries.map((attempt) => attempt.model)];
1615
+ for (const model of models) {
1616
+ const provider = providerFromModel(model);
1617
+ if (provider !== null)
1618
+ return provider;
1619
+ }
1620
+ return null;
1621
+ }
1622
+ function providerFromModelId(modelId, agent) {
1623
+ const normalized = stripMagpieProviderPrefix(agent, modelId);
1624
+ return providerFromModel(normalized);
1625
+ }
1626
+ function providerFromModel(value) {
1627
+ if (value === null)
1628
+ return null;
1629
+ const slash = value.indexOf('/');
1630
+ if (slash <= 0)
1631
+ return null;
1632
+ const provider = value.slice(0, slash);
1633
+ return provider === 'group' || provider === 'auto'
1634
+ ? null
1635
+ : /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u.test(provider) ? provider : null;
1636
+ }
1637
+ function readRule(value) {
1638
+ const text = routeText(value);
1639
+ if (text !== null)
1640
+ return text;
1641
+ const record = asRecord(value);
1642
+ return routeText(record?.name) ?? routeText(record?.id);
1643
+ }
1644
+ function routeStatusText(value) {
1645
+ if (typeof value === 'number' && Number.isInteger(value) && value >= 100 && value <= 599)
1646
+ return String(value);
1647
+ const text = routeText(value);
1648
+ return text !== null && /^[A-Za-z0-9_-]{1,32}$/u.test(text) ? text : null;
1649
+ }
1650
+ function routeText(value) {
1651
+ if (typeof value !== 'string')
1652
+ return null;
1653
+ const text = value.trim().replace(/[\u0000-\u001f\u007f]/gu, '').slice(0, 240);
1654
+ return text === '' ? null : text;
1655
+ }
1656
+ function safePercent(value) {
1657
+ return typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 100 ? value : null;
1658
+ }
1659
+ function safeDecimal(value) {
1660
+ return typeof value === 'number' && Number.isFinite(value) && Math.abs(value) <= Number.MAX_SAFE_INTEGER ? value : null;
1661
+ }
1662
+ function cleanText(value) {
1663
+ if (typeof value !== 'string')
1664
+ return null;
1665
+ const text = value.trim();
1666
+ return text === '' || text.length > 512 || /[\u0000-\u001f\u007f]/u.test(text) ? null : text;
1667
+ }
1668
+ function cleanSessionName(value) {
1669
+ if (typeof value !== 'string')
1670
+ return null;
1671
+ const text = value.trim().replace(/[\u0000-\u001f\u007f]/gu, '').slice(0, 240);
1672
+ return text === '' ? null : text;
1673
+ }
1674
+ /** Pi and Command Code store Magpie selections with a local `magpie/` provider prefix. */
1675
+ function resolveCatalogModelId(agent, requestedModelId, catalog, modelName) {
1676
+ if (catalog === null)
1677
+ return null;
1678
+ const catalogModelId = catalogModelIdForRequested(agent, requestedModelId);
1679
+ if (catalogModelId !== null && catalog.models.has(catalogModelId))
1680
+ return catalogModelId;
1681
+ const normalizedName = normalizeMagpieModelName(modelName);
1682
+ return normalizedName === null ? null : catalog.names.get(normalizedName) ?? null;
1683
+ }
1684
+ function catalogModelIdForRequested(agent, requestedModelId) {
1685
+ const normalized = stripMagpieProviderPrefix(agent, requestedModelId);
1686
+ // Claude appends this context-window marker to model IDs returned by its
1687
+ // initialize protocol; Magpie's verified catalog keeps the canonical ID.
1688
+ return agent === 'claude' ? normalized.replace(/\[1m\]$/u, '') : normalized;
1689
+ }
1690
+ function stripMagpieProviderPrefix(agent, modelId) {
1691
+ return (agent === 'commandcode' || agent === 'pi') && modelId.startsWith('magpie/')
1692
+ ? modelId.slice('magpie/'.length)
1693
+ : modelId;
1694
+ }
1695
+ function normalizeMagpieModelName(value) {
1696
+ if (typeof value !== 'string')
1697
+ return null;
1698
+ const name = value.trim().replace(/\s+/gu, ' ').toLocaleLowerCase('en-US');
1699
+ return name === '' || name.length > 200 ? null : name;
1700
+ }
1701
+ function safeCount(value) {
1702
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : null;
1703
+ }
1704
+ function safeCost(value) {
1705
+ return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : null;
1706
+ }
1707
+ function asRecord(value) {
1708
+ return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null;
1709
+ }
1710
+ //# sourceMappingURL=magpie-usage.js.map