@elie-laloum/outpost 6.0.1 → 7.0.0

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 (463) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +3 -3
  3. package/SECURITY.md +9 -1
  4. package/dist/adapters/agents/antigravity-adapter.js +4 -2
  5. package/dist/adapters/agents/antigravity-adapter.js.map +1 -1
  6. package/dist/adapters/agents/antigravity-diagnostics.js +1 -1
  7. package/dist/adapters/agents/antigravity-diagnostics.js.map +1 -1
  8. package/dist/adapters/agents/antigravity-events.js +19 -10
  9. package/dist/adapters/agents/antigravity-events.js.map +1 -1
  10. package/dist/adapters/agents/antigravity-request.js +9 -1
  11. package/dist/adapters/agents/antigravity-request.js.map +1 -1
  12. package/dist/adapters/agents/antigravity.constants.d.ts +3 -0
  13. package/dist/adapters/agents/antigravity.constants.js +4 -0
  14. package/dist/adapters/agents/antigravity.constants.js.map +1 -0
  15. package/dist/adapters/agents/claude-events.js +52 -9
  16. package/dist/adapters/agents/claude-events.js.map +1 -1
  17. package/dist/adapters/agents/claude-request.js +2 -0
  18. package/dist/adapters/agents/claude-request.js.map +1 -1
  19. package/dist/adapters/agents/cli-diagnostics.d.ts +1 -1
  20. package/dist/adapters/agents/cli-diagnostics.js +15 -8
  21. package/dist/adapters/agents/cli-diagnostics.js.map +1 -1
  22. package/dist/adapters/agents/codex-events.js +28 -2
  23. package/dist/adapters/agents/codex-events.js.map +1 -1
  24. package/dist/adapters/agents/copilot-adapter.js +8 -2
  25. package/dist/adapters/agents/copilot-adapter.js.map +1 -1
  26. package/dist/adapters/agents/copilot-authentication.js +2 -1
  27. package/dist/adapters/agents/copilot-authentication.js.map +1 -1
  28. package/dist/adapters/agents/copilot-diagnostics.js +1 -1
  29. package/dist/adapters/agents/copilot-diagnostics.js.map +1 -1
  30. package/dist/adapters/agents/copilot-events.js +16 -0
  31. package/dist/adapters/agents/copilot-events.js.map +1 -1
  32. package/dist/adapters/agents/copilot-request.js +6 -1
  33. package/dist/adapters/agents/copilot-request.js.map +1 -1
  34. package/dist/adapters/agents/copilot-usage.d.ts +3 -0
  35. package/dist/adapters/agents/copilot-usage.js +19 -0
  36. package/dist/adapters/agents/copilot-usage.js.map +1 -0
  37. package/dist/adapters/agents/kimi-adapter.js +19 -3
  38. package/dist/adapters/agents/kimi-adapter.js.map +1 -1
  39. package/dist/adapters/agents/kimi-authentication.d.ts +2 -1
  40. package/dist/adapters/agents/kimi-authentication.js +41 -26
  41. package/dist/adapters/agents/kimi-authentication.js.map +1 -1
  42. package/dist/adapters/agents/kimi-diagnostics.d.ts +2 -1
  43. package/dist/adapters/agents/kimi-diagnostics.js +9 -1
  44. package/dist/adapters/agents/kimi-diagnostics.js.map +1 -1
  45. package/dist/adapters/agents/kimi-events.js +4 -0
  46. package/dist/adapters/agents/kimi-events.js.map +1 -1
  47. package/dist/adapters/agents/kimi-fork.d.ts +2 -0
  48. package/dist/adapters/agents/kimi-fork.js +11 -0
  49. package/dist/adapters/agents/kimi-fork.js.map +1 -0
  50. package/dist/adapters/agents/kimi-request.js +6 -1
  51. package/dist/adapters/agents/kimi-request.js.map +1 -1
  52. package/dist/adapters/agents/kimi-usage.d.ts +2 -0
  53. package/dist/adapters/agents/kimi-usage.js +7 -0
  54. package/dist/adapters/agents/kimi-usage.js.map +1 -0
  55. package/dist/adapters/agents/kimi.constants.d.ts +13 -0
  56. package/dist/adapters/agents/kimi.constants.js +14 -0
  57. package/dist/adapters/agents/kimi.constants.js.map +1 -0
  58. package/dist/adapters/agents/kimi.types.d.ts +1 -0
  59. package/dist/adapters/agents/kimi.types.js.map +1 -1
  60. package/dist/adapters/agents/protocol-fixtures.constants.js +15 -19
  61. package/dist/adapters/agents/protocol-fixtures.constants.js.map +1 -1
  62. package/dist/adapters/agents/session-usage.constants.d.ts +10 -0
  63. package/dist/adapters/agents/session-usage.constants.js +110 -0
  64. package/dist/adapters/agents/session-usage.constants.js.map +1 -0
  65. package/dist/adapters/agents/session-usage.d.ts +5 -0
  66. package/dist/adapters/agents/session-usage.js +45 -0
  67. package/dist/adapters/agents/session-usage.js.map +1 -0
  68. package/dist/adapters/agents/settings.types.d.ts +1 -0
  69. package/dist/adapters/agents/settings.types.js.map +1 -1
  70. package/dist/adapters/agents/tool-result.d.ts +2 -0
  71. package/dist/adapters/agents/tool-result.js +17 -0
  72. package/dist/adapters/agents/tool-result.js.map +1 -0
  73. package/dist/adapters/models/anthropic-response.js +3 -0
  74. package/dist/adapters/models/anthropic-response.js.map +1 -1
  75. package/dist/adapters/models/http-provider.js +6 -1
  76. package/dist/adapters/models/http-provider.js.map +1 -1
  77. package/dist/adapters/models/openai-responses.js +10 -0
  78. package/dist/adapters/models/openai-responses.js.map +1 -1
  79. package/dist/adapters/models/retry-after.d.ts +1 -0
  80. package/dist/adapters/models/retry-after.js +16 -0
  81. package/dist/adapters/models/retry-after.js.map +1 -0
  82. package/dist/application/activity-watchdog.js +1 -2
  83. package/dist/application/activity-watchdog.js.map +1 -1
  84. package/dist/application/agent-bootstrap.constants.js +1 -3
  85. package/dist/application/agent-bootstrap.constants.js.map +1 -1
  86. package/dist/application/agent-bootstrap.js +9 -3
  87. package/dist/application/agent-bootstrap.js.map +1 -1
  88. package/dist/application/agent-bootstrap.types.d.ts +1 -2
  89. package/dist/application/agent-bootstrap.types.js.map +1 -1
  90. package/dist/application/agent-output.js +74 -8
  91. package/dist/application/agent-output.js.map +1 -1
  92. package/dist/application/agent-request.d.ts +3 -0
  93. package/dist/application/agent-request.js +11 -0
  94. package/dist/application/agent-request.js.map +1 -0
  95. package/dist/application/agent-turn.js +74 -6
  96. package/dist/application/agent-turn.js.map +1 -1
  97. package/dist/application/agent-usage.d.ts +6 -0
  98. package/dist/application/agent-usage.js +57 -0
  99. package/dist/application/agent-usage.js.map +1 -0
  100. package/dist/application/attach.js +2 -0
  101. package/dist/application/attach.js.map +1 -1
  102. package/dist/application/custom-turn.js +44 -49
  103. package/dist/application/custom-turn.js.map +1 -1
  104. package/dist/application/dispatch-observation.d.ts +1 -1
  105. package/dist/application/dispatch-observation.js +141 -21
  106. package/dist/application/dispatch-observation.js.map +1 -1
  107. package/dist/application/dispatch-observation.types.d.ts +2 -0
  108. package/dist/application/dispatch-observation.types.js.map +1 -1
  109. package/dist/application/dispatch-validation.js +2 -0
  110. package/dist/application/dispatch-validation.js.map +1 -1
  111. package/dist/application/dispatch.js +1 -1
  112. package/dist/application/dispatch.js.map +1 -1
  113. package/dist/application/doctor-agent.constants.js +3 -0
  114. package/dist/application/doctor-agent.constants.js.map +1 -1
  115. package/dist/application/doctor-agent.js +6 -2
  116. package/dist/application/doctor-agent.js.map +1 -1
  117. package/dist/application/doctor.js +26 -6
  118. package/dist/application/doctor.js.map +1 -1
  119. package/dist/application/doctor.types.d.ts +1 -0
  120. package/dist/application/doctor.types.js.map +1 -1
  121. package/dist/application/execution.constants.d.ts +2 -0
  122. package/dist/application/execution.constants.js +2 -0
  123. package/dist/application/execution.constants.js.map +1 -1
  124. package/dist/application/execution.types.d.ts +8 -0
  125. package/dist/application/execution.types.js.map +1 -1
  126. package/dist/application/harness-budget.d.ts +3 -0
  127. package/dist/application/harness-budget.js +42 -0
  128. package/dist/application/harness-budget.js.map +1 -0
  129. package/dist/application/harness-budget.types.d.ts +5 -0
  130. package/dist/application/harness-budget.types.js +2 -0
  131. package/dist/application/harness-budget.types.js.map +1 -0
  132. package/dist/application/harness-hooks.js +34 -3
  133. package/dist/application/harness-hooks.js.map +1 -1
  134. package/dist/application/harness-loop.js +52 -24
  135. package/dist/application/harness-loop.js.map +1 -1
  136. package/dist/application/harness-model-provider.d.ts +3 -0
  137. package/dist/application/harness-model-provider.js +49 -0
  138. package/dist/application/harness-model-provider.js.map +1 -0
  139. package/dist/application/harness-model-provider.types.d.ts +10 -0
  140. package/dist/application/harness-model-provider.types.js +2 -0
  141. package/dist/application/harness-model-provider.types.js.map +1 -0
  142. package/dist/application/harness-subagent.d.ts +4 -0
  143. package/dist/application/harness-subagent.js +110 -0
  144. package/dist/application/harness-subagent.js.map +1 -0
  145. package/dist/application/harness.types.d.ts +11 -0
  146. package/dist/application/harness.types.js.map +1 -1
  147. package/dist/application/lifecycle-hooks.d.ts +1 -1
  148. package/dist/application/lifecycle-hooks.js +5 -4
  149. package/dist/application/lifecycle-hooks.js.map +1 -1
  150. package/dist/application/observed-lease.d.ts +3 -0
  151. package/dist/application/observed-lease.js +26 -0
  152. package/dist/application/observed-lease.js.map +1 -0
  153. package/dist/application/outpost.types.d.ts +3 -0
  154. package/dist/application/outpost.types.js.map +1 -1
  155. package/dist/application/output-lines.d.ts +4 -0
  156. package/dist/application/output-lines.js +28 -0
  157. package/dist/application/output-lines.js.map +1 -0
  158. package/dist/application/queue-worker.js +1 -1
  159. package/dist/application/queue-worker.js.map +1 -1
  160. package/dist/application/queue-worker.types.d.ts +1 -0
  161. package/dist/application/queue-worker.types.js.map +1 -1
  162. package/dist/application/queued-task.js +24 -5
  163. package/dist/application/queued-task.js.map +1 -1
  164. package/dist/application/recovery-archive.d.ts +3 -2
  165. package/dist/application/recovery-archive.js +9 -2
  166. package/dist/application/recovery-archive.js.map +1 -1
  167. package/dist/application/recovery-restore.d.ts +3 -2
  168. package/dist/application/recovery-restore.js +9 -2
  169. package/dist/application/recovery-restore.js.map +1 -1
  170. package/dist/application/recovery-retention.d.ts +3 -2
  171. package/dist/application/recovery-retention.js +9 -2
  172. package/dist/application/recovery-retention.js.map +1 -1
  173. package/dist/application/remote-workspace.js +5 -4
  174. package/dist/application/remote-workspace.js.map +1 -1
  175. package/dist/application/remote-workspace.types.d.ts +1 -0
  176. package/dist/application/remote-workspace.types.js.map +1 -1
  177. package/dist/application/sandbox-agents.js +11 -12
  178. package/dist/application/sandbox-agents.js.map +1 -1
  179. package/dist/application/sandbox-attach.js +12 -3
  180. package/dist/application/sandbox-attach.js.map +1 -1
  181. package/dist/application/sandbox-dispatch.js +13 -25
  182. package/dist/application/sandbox-dispatch.js.map +1 -1
  183. package/dist/application/sandbox-provision.js +15 -9
  184. package/dist/application/sandbox-provision.js.map +1 -1
  185. package/dist/application/sandbox-session.types.d.ts +2 -2
  186. package/dist/application/sandbox-session.types.js.map +1 -1
  187. package/dist/application/sandbox.js +13 -6
  188. package/dist/application/sandbox.js.map +1 -1
  189. package/dist/application/speculation-checkpoint.d.ts +6 -0
  190. package/dist/application/speculation-checkpoint.js +206 -0
  191. package/dist/application/speculation-checkpoint.js.map +1 -0
  192. package/dist/application/speculation-checkpoint.types.d.ts +24 -0
  193. package/dist/application/speculation-checkpoint.types.js +2 -0
  194. package/dist/application/speculation-checkpoint.types.js.map +1 -0
  195. package/dist/application/speculation-integration.constants.d.ts +4 -0
  196. package/dist/application/speculation-integration.constants.js +5 -0
  197. package/dist/application/speculation-integration.constants.js.map +1 -0
  198. package/dist/application/speculation-integration.d.ts +2 -0
  199. package/dist/application/speculation-integration.js +67 -0
  200. package/dist/application/speculation-integration.js.map +1 -0
  201. package/dist/application/speculation-resume.d.ts +4 -0
  202. package/dist/application/speculation-resume.js +71 -0
  203. package/dist/application/speculation-resume.js.map +1 -0
  204. package/dist/application/speculation-run.d.ts +4 -0
  205. package/dist/application/speculation-run.js +320 -0
  206. package/dist/application/speculation-run.js.map +1 -0
  207. package/dist/application/speculation-timeout.d.ts +1 -0
  208. package/dist/application/speculation-timeout.js +15 -0
  209. package/dist/application/speculation-timeout.js.map +1 -0
  210. package/dist/application/speculation.constants.d.ts +1 -0
  211. package/dist/application/speculation.constants.js +5 -1
  212. package/dist/application/speculation.constants.js.map +1 -1
  213. package/dist/application/speculation.js +41 -149
  214. package/dist/application/speculation.js.map +1 -1
  215. package/dist/application/speculation.types.d.ts +23 -0
  216. package/dist/application/speculation.types.js.map +1 -1
  217. package/dist/application/startup-recovery.js +13 -0
  218. package/dist/application/startup-recovery.js.map +1 -1
  219. package/dist/application/startup-recovery.types.d.ts +1 -0
  220. package/dist/application/startup-recovery.types.js.map +1 -1
  221. package/dist/application/stop-reason.d.ts +2 -0
  222. package/dist/application/stop-reason.js +21 -0
  223. package/dist/application/stop-reason.js.map +1 -0
  224. package/dist/application/stop-reason.types.d.ts +4 -0
  225. package/dist/application/stop-reason.types.js +2 -0
  226. package/dist/application/stop-reason.types.js.map +1 -0
  227. package/dist/application/task-observation.d.ts +3 -0
  228. package/dist/application/task-observation.js +22 -0
  229. package/dist/application/task-observation.js.map +1 -0
  230. package/dist/application/task-usage.js +5 -12
  231. package/dist/application/task-usage.js.map +1 -1
  232. package/dist/application/tasks.js +41 -16
  233. package/dist/application/tasks.js.map +1 -1
  234. package/dist/application/tool-execution.js +42 -19
  235. package/dist/application/tool-execution.js.map +1 -1
  236. package/dist/application/workspace.js +6 -4
  237. package/dist/application/workspace.js.map +1 -1
  238. package/dist/cli/doctor-command.js +1 -1
  239. package/dist/cli/doctor-command.js.map +1 -1
  240. package/dist/cli/main.js +2 -1
  241. package/dist/cli/main.js.map +1 -1
  242. package/dist/cli/scaffold.constants.js +3 -2
  243. package/dist/cli/scaffold.constants.js.map +1 -1
  244. package/dist/domain/agent-observation.d.ts +4 -0
  245. package/dist/domain/agent-observation.js +27 -0
  246. package/dist/domain/agent-observation.js.map +1 -0
  247. package/dist/domain/agent.types.d.ts +75 -3
  248. package/dist/domain/agent.types.js.map +1 -1
  249. package/dist/domain/harness.js +6 -0
  250. package/dist/domain/harness.js.map +1 -1
  251. package/dist/domain/harness.types.d.ts +2 -1
  252. package/dist/domain/harness.types.js.map +1 -1
  253. package/dist/domain/model.types.d.ts +8 -0
  254. package/dist/domain/model.types.js.map +1 -1
  255. package/dist/domain/observation.constants.d.ts +8 -0
  256. package/dist/domain/observation.constants.js +9 -0
  257. package/dist/domain/observation.constants.js.map +1 -0
  258. package/dist/domain/observation.d.ts +2 -0
  259. package/dist/domain/observation.js +190 -0
  260. package/dist/domain/observation.js.map +1 -0
  261. package/dist/domain/observation.types.d.ts +84 -0
  262. package/dist/domain/observation.types.js +2 -0
  263. package/dist/domain/observation.types.js.map +1 -0
  264. package/dist/domain/observed-operation.d.ts +2 -0
  265. package/dist/domain/observed-operation.js +30 -0
  266. package/dist/domain/observed-operation.js.map +1 -0
  267. package/dist/domain/sandbox.types.d.ts +2 -0
  268. package/dist/domain/sandbox.types.js.map +1 -1
  269. package/dist/domain/subagent.constants.d.ts +13 -0
  270. package/dist/domain/subagent.constants.js +9 -0
  271. package/dist/domain/subagent.constants.js.map +1 -0
  272. package/dist/domain/subagent.d.ts +4 -0
  273. package/dist/domain/subagent.js +28 -0
  274. package/dist/domain/subagent.js.map +1 -0
  275. package/dist/domain/subagent.types.d.ts +13 -0
  276. package/dist/domain/subagent.types.js +2 -0
  277. package/dist/domain/subagent.types.js.map +1 -0
  278. package/dist/domain/transcript.types.d.ts +2 -0
  279. package/dist/domain/transcript.types.js.map +1 -1
  280. package/dist/domain/usage.d.ts +1 -0
  281. package/dist/domain/usage.js +16 -0
  282. package/dist/domain/usage.js.map +1 -1
  283. package/dist/domain/workflow/budget.d.ts +7 -3
  284. package/dist/domain/workflow/budget.js +26 -0
  285. package/dist/domain/workflow/budget.js.map +1 -1
  286. package/dist/domain/workflow/budget.types.d.ts +1 -1
  287. package/dist/domain/workflow/budget.types.js.map +1 -1
  288. package/dist/domain/workflow/checkpoint-validation.js +7 -1
  289. package/dist/domain/workflow/checkpoint-validation.js.map +1 -1
  290. package/dist/domain/workflow/checkpoint.js +3 -0
  291. package/dist/domain/workflow/checkpoint.js.map +1 -1
  292. package/dist/domain/workflow/gate-validation.js +14 -1
  293. package/dist/domain/workflow/gate-validation.js.map +1 -1
  294. package/dist/domain/workflow/gates.d.ts +1 -1
  295. package/dist/domain/workflow/gates.js +52 -4
  296. package/dist/domain/workflow/gates.js.map +1 -1
  297. package/dist/domain/workflow/gates.types.d.ts +15 -1
  298. package/dist/domain/workflow/gates.types.js.map +1 -1
  299. package/dist/domain/workflow/idempotency.d.ts +1 -0
  300. package/dist/domain/workflow/idempotency.js +7 -0
  301. package/dist/domain/workflow/idempotency.js.map +1 -0
  302. package/dist/domain/workflow/retry.constants.d.ts +2 -0
  303. package/dist/domain/workflow/retry.constants.js +3 -0
  304. package/dist/domain/workflow/retry.constants.js.map +1 -0
  305. package/dist/domain/workflow/retry.d.ts +4 -0
  306. package/dist/domain/workflow/retry.js +49 -0
  307. package/dist/domain/workflow/retry.js.map +1 -0
  308. package/dist/domain/workflow/task-runner.js +9 -5
  309. package/dist/domain/workflow/task-runner.js.map +1 -1
  310. package/dist/domain/workflow/task.js +6 -6
  311. package/dist/domain/workflow/task.js.map +1 -1
  312. package/dist/domain/workflow/workflow-scheduler.js +110 -72
  313. package/dist/domain/workflow/workflow-scheduler.js.map +1 -1
  314. package/dist/domain/workflow/workflow-state.js +28 -12
  315. package/dist/domain/workflow/workflow-state.js.map +1 -1
  316. package/dist/domain/workflow.d.ts +1 -1
  317. package/dist/domain/workflow.js +1 -1
  318. package/dist/domain/workflow.js.map +1 -1
  319. package/dist/domain/workflow.types.d.ts +13 -2
  320. package/dist/domain/workflow.types.js.map +1 -1
  321. package/dist/index.d.ts +12 -3
  322. package/dist/index.js +6 -1
  323. package/dist/index.js.map +1 -1
  324. package/dist/infrastructure/conversations/capture.js +10 -0
  325. package/dist/infrastructure/conversations/capture.js.map +1 -1
  326. package/dist/infrastructure/conversations/harness-transcript.js +6 -0
  327. package/dist/infrastructure/conversations/harness-transcript.js.map +1 -1
  328. package/dist/infrastructure/conversations/harness-transcript.types.d.ts +2 -0
  329. package/dist/infrastructure/conversations/harness-transcript.types.js.map +1 -1
  330. package/dist/infrastructure/conversations/layout.js +2 -0
  331. package/dist/infrastructure/conversations/layout.js.map +1 -1
  332. package/dist/infrastructure/conversations/locate.js +7 -1
  333. package/dist/infrastructure/conversations/locate.js.map +1 -1
  334. package/dist/infrastructure/conversations/native-store.js +8 -1
  335. package/dist/infrastructure/conversations/native-store.js.map +1 -1
  336. package/dist/infrastructure/conversations/paths.js +3 -0
  337. package/dist/infrastructure/conversations/paths.js.map +1 -1
  338. package/dist/infrastructure/conversations/restore.js +7 -0
  339. package/dist/infrastructure/conversations/restore.js.map +1 -1
  340. package/dist/infrastructure/conversations/session-bundle.constants.d.ts +5 -0
  341. package/dist/infrastructure/conversations/session-bundle.constants.js +173 -0
  342. package/dist/infrastructure/conversations/session-bundle.constants.js.map +1 -0
  343. package/dist/infrastructure/conversations/session-bundle.d.ts +6 -0
  344. package/dist/infrastructure/conversations/session-bundle.js +98 -0
  345. package/dist/infrastructure/conversations/session-bundle.js.map +1 -0
  346. package/dist/infrastructure/conversations/session-bundle.types.d.ts +1 -0
  347. package/dist/infrastructure/conversations/session-bundle.types.js +2 -0
  348. package/dist/infrastructure/conversations/session-bundle.types.js.map +1 -0
  349. package/dist/infrastructure/conversations.js +4 -2
  350. package/dist/infrastructure/conversations.js.map +1 -1
  351. package/dist/infrastructure/conversations.types.d.ts +1 -1
  352. package/dist/infrastructure/conversations.types.js.map +1 -1
  353. package/dist/infrastructure/custom-reporter.js +32 -24
  354. package/dist/infrastructure/custom-reporter.js.map +1 -1
  355. package/dist/infrastructure/custom-reporter.types.d.ts +2 -0
  356. package/dist/infrastructure/custom-reporter.types.js.map +1 -1
  357. package/dist/infrastructure/git/workspace-lease.js +4 -3
  358. package/dist/infrastructure/git/workspace-lease.js.map +1 -1
  359. package/dist/infrastructure/git/workspace.js +7 -6
  360. package/dist/infrastructure/git/workspace.js.map +1 -1
  361. package/dist/infrastructure/git/workspace.types.d.ts +1 -0
  362. package/dist/infrastructure/git/workspace.types.js.map +1 -1
  363. package/dist/infrastructure/journal.constants.js +10 -1
  364. package/dist/infrastructure/journal.constants.js.map +1 -1
  365. package/dist/infrastructure/journal.d.ts +1 -1
  366. package/dist/infrastructure/journal.js +2 -2
  367. package/dist/infrastructure/journal.js.map +1 -1
  368. package/dist/infrastructure/journal.types.d.ts +2 -2
  369. package/dist/infrastructure/journal.types.js.map +1 -1
  370. package/dist/infrastructure/opentelemetry-dispatch.d.ts +3 -3
  371. package/dist/infrastructure/opentelemetry-dispatch.js +5 -4
  372. package/dist/infrastructure/opentelemetry-dispatch.js.map +1 -1
  373. package/dist/infrastructure/opentelemetry-observation.d.ts +5 -0
  374. package/dist/infrastructure/opentelemetry-observation.js +59 -0
  375. package/dist/infrastructure/opentelemetry-observation.js.map +1 -0
  376. package/dist/infrastructure/opentelemetry.js +15 -1
  377. package/dist/infrastructure/opentelemetry.js.map +1 -1
  378. package/dist/infrastructure/opentelemetry.types.d.ts +9 -1
  379. package/dist/infrastructure/opentelemetry.types.js.map +1 -1
  380. package/dist/infrastructure/reporter.d.ts +2 -2
  381. package/dist/infrastructure/reporter.js +5 -1
  382. package/dist/infrastructure/reporter.js.map +1 -1
  383. package/dist/infrastructure/s3-transport.constants.d.ts +2 -0
  384. package/dist/infrastructure/s3-transport.constants.js +3 -0
  385. package/dist/infrastructure/s3-transport.constants.js.map +1 -0
  386. package/dist/infrastructure/s3-transport.js +57 -3
  387. package/dist/infrastructure/s3-transport.js.map +1 -1
  388. package/dist/infrastructure/s3-transport.types.d.ts +1 -0
  389. package/dist/infrastructure/s3-transport.types.js.map +1 -1
  390. package/dist/infrastructure/speculation-store.constants.d.ts +3 -0
  391. package/dist/infrastructure/speculation-store.constants.js +2 -0
  392. package/dist/infrastructure/speculation-store.constants.js.map +1 -0
  393. package/dist/infrastructure/speculation-store.d.ts +4 -0
  394. package/dist/infrastructure/speculation-store.js +73 -0
  395. package/dist/infrastructure/speculation-store.js.map +1 -0
  396. package/dist/infrastructure/speculation-store.types.d.ts +12 -0
  397. package/dist/infrastructure/speculation-store.types.js +2 -0
  398. package/dist/infrastructure/speculation-store.types.js.map +1 -0
  399. package/dist/infrastructure/task-queue-bullmq-resources.js +3 -0
  400. package/dist/infrastructure/task-queue-bullmq-resources.js.map +1 -1
  401. package/dist/infrastructure/task-queue-http.js +29 -4
  402. package/dist/infrastructure/task-queue-http.js.map +1 -1
  403. package/dist/infrastructure/task-queue-http.types.d.ts +2 -2
  404. package/dist/infrastructure/task-queue-http.types.js.map +1 -1
  405. package/dist/infrastructure/transport-conversations.js +2 -0
  406. package/dist/infrastructure/transport-conversations.js.map +1 -1
  407. package/dist/infrastructure/transport-journal.d.ts +1 -1
  408. package/dist/infrastructure/transport-journal.js +8 -2
  409. package/dist/infrastructure/transport-journal.js.map +1 -1
  410. package/dist/infrastructure/workflow-decision-signature.constants.d.ts +4 -0
  411. package/dist/infrastructure/workflow-decision-signature.constants.js +5 -0
  412. package/dist/infrastructure/workflow-decision-signature.constants.js.map +1 -0
  413. package/dist/infrastructure/workflow-decision-signature.d.ts +4 -0
  414. package/dist/infrastructure/workflow-decision-signature.js +83 -0
  415. package/dist/infrastructure/workflow-decision-signature.js.map +1 -0
  416. package/dist/infrastructure/workflow-decision-signature.types.d.ts +16 -0
  417. package/dist/infrastructure/workflow-decision-signature.types.js +2 -0
  418. package/dist/infrastructure/workflow-decision-signature.types.js.map +1 -0
  419. package/dist/providers/antigravity-install.constants.d.ts +2 -0
  420. package/dist/providers/antigravity-install.constants.js +28 -0
  421. package/dist/providers/antigravity-install.constants.js.map +1 -0
  422. package/dist/providers/antigravity-install.d.ts +2 -0
  423. package/dist/providers/antigravity-install.js +29 -0
  424. package/dist/providers/antigravity-install.js.map +1 -0
  425. package/dist/providers/antigravity-install.types.d.ts +4 -0
  426. package/dist/providers/antigravity-install.types.js +2 -0
  427. package/dist/providers/antigravity-install.types.js.map +1 -0
  428. package/dist/providers/container-recovery.d.ts +4 -0
  429. package/dist/providers/container-recovery.js +28 -0
  430. package/dist/providers/container-recovery.js.map +1 -0
  431. package/dist/providers/container.js +8 -0
  432. package/dist/providers/container.js.map +1 -1
  433. package/dist/providers/daytona-network.constants.d.ts +5 -0
  434. package/dist/providers/daytona-network.constants.js +8 -0
  435. package/dist/providers/daytona-network.constants.js.map +1 -0
  436. package/dist/providers/daytona-network.d.ts +4 -0
  437. package/dist/providers/daytona-network.js +33 -0
  438. package/dist/providers/daytona-network.js.map +1 -0
  439. package/dist/providers/daytona.d.ts +1 -0
  440. package/dist/providers/daytona.js +9 -3
  441. package/dist/providers/daytona.js.map +1 -1
  442. package/dist/providers/daytona.types.d.ts +2 -0
  443. package/dist/providers/daytona.types.js.map +1 -1
  444. package/dist/providers/firecracker-command.js +1 -1
  445. package/dist/providers/firecracker-command.js.map +1 -1
  446. package/dist/providers/firecracker-jailer.constants.d.ts +9 -0
  447. package/dist/providers/firecracker-jailer.constants.js +10 -0
  448. package/dist/providers/firecracker-jailer.constants.js.map +1 -0
  449. package/dist/providers/firecracker-jailer.d.ts +4 -0
  450. package/dist/providers/firecracker-jailer.js +171 -0
  451. package/dist/providers/firecracker-jailer.js.map +1 -0
  452. package/dist/providers/firecracker-machine.js +30 -8
  453. package/dist/providers/firecracker-machine.js.map +1 -1
  454. package/dist/providers/firecracker.types.d.ts +16 -0
  455. package/dist/providers/firecracker.types.js.map +1 -1
  456. package/dist/providers/vercel-network.js +1 -1
  457. package/dist/providers/vercel-network.js.map +1 -1
  458. package/dist/providers/vercel.js +6 -3
  459. package/dist/providers/vercel.js.map +1 -1
  460. package/dist/providers/versions.constants.d.ts +1 -1
  461. package/dist/providers/versions.constants.js +1 -1
  462. package/dist/providers/versions.constants.js.map +1 -1
  463. package/package.json +1 -1
@@ -1,3 +1,5 @@
1
+ import { copilotUsage } from "./copilot-usage.js";
2
+ import { sessionUsageCommand, sessionUsageResult } from "./session-usage.js";
1
3
  import { credentialPlanner } from "./authentication.js";
2
4
  import { copilotCredentials } from "./copilot-authentication.js";
3
5
  import { copilotEvents } from "./copilot-events.js";
@@ -11,8 +13,9 @@ function bindCopilot(settings) {
11
13
  name: "copilot",
12
14
  ...(credentials ? { credentials } : {}),
13
15
  bootstrap: "copilot",
14
- resumable: false,
15
- capture: false,
16
+ resumable: true,
17
+ forkable: false,
18
+ conversations: "copilot",
16
19
  requiresFinishedEvent: true,
17
20
  variables: Object.freeze({
18
21
  COPILOT_AUTO_UPDATE: "false",
@@ -20,6 +23,9 @@ function bindCopilot(settings) {
20
23
  }),
21
24
  request: (input) => copilotRequest(settings, input),
22
25
  events: copilotEvents,
26
+ usage: "session",
27
+ usageCommand: (conversation) => sessionUsageCommand("copilot", conversation),
28
+ usageResult: (text) => sessionUsageResult(text, copilotUsage),
23
29
  });
24
30
  }
25
31
  export function copilotHarness(settings = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"copilot-adapter.js","sourceRoot":"","sources":["../../../src/adapters/agents/copilot-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGnE,SAAS,WAAW,CAAC,QAAgC;IACnD,YAAY,CAAC,mBAAmB,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,WAAW,GAAG,iBAAiB,CACnC,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,CAAC,cAAc,EACvB,QAAQ,CAAC,KAAK,CACf,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,SAAS;QACf,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvC,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE,KAAK;QACd,qBAAqB,EAAE,IAAI;QAC3B,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;YACvB,mBAAmB,EAAE,OAAO;YAC5B,GAAG,QAAQ,CAAC,SAAS;SACtB,CAAC;QACF,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC;QACnD,MAAM,EAAE,aAAa;KACC,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,WAA4B,EAAE;IAC3D,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC1B,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;QAC/B,GAAG,QAAQ;QACX,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;KACpD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,CAAC,KAAkB,EAAE,EAAE,CAC3B,WAAW,CAAC;YACV,GAAG,UAAU;YACb,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;SAC1C,CAAC;KACL,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { AgentAdapter, CliHarness } from \"../../domain/agent.types.ts\";\nimport type { AgentModel } from \"../../domain/model.types.ts\";\nimport { credentialPlanner } from \"./authentication.ts\";\nimport { copilotCredentials } from \"./copilot-authentication.ts\";\nimport { copilotEvents } from \"./copilot-events.ts\";\nimport { copilotRequest } from \"./copilot-request.ts\";\nimport type { CopilotSettings } from \"./copilot.types.ts\";\nimport { copilotModelSupport } from \"./model-support.constants.ts\";\nimport { harnessSettings, supportModel } from \"./model-support.ts\";\nimport type { Bound } from \"./settings.types.ts\";\n\nfunction bindCopilot(settings: Bound<CopilotSettings>): AgentAdapter {\n supportModel(copilotModelSupport, settings.model);\n const credentials = credentialPlanner(\n \"GitHub Copilot CLI\",\n copilotCredentials,\n settings.authentication,\n settings.model,\n );\n return Object.freeze({\n name: \"copilot\",\n ...(credentials ? { credentials } : {}),\n bootstrap: \"copilot\",\n resumable: false,\n capture: false,\n requiresFinishedEvent: true,\n variables: Object.freeze({\n COPILOT_AUTO_UPDATE: \"false\",\n ...settings.variables,\n }),\n request: (input) => copilotRequest(settings, input),\n events: copilotEvents,\n } satisfies AgentAdapter);\n}\n\nexport function copilotHarness(settings: CopilotSettings = {}): CliHarness {\n harnessSettings(settings);\n const configured = Object.freeze({\n ...settings,\n variables: Object.freeze({ ...settings.variables }),\n });\n return Object.freeze({\n kind: \"cli\",\n bind: (model?: AgentModel) =>\n bindCopilot({\n ...configured,\n ...(model === undefined ? {} : { model }),\n }),\n });\n}\n"]}
1
+ {"version":3,"file":"copilot-adapter.js","sourceRoot":"","sources":["../../../src/adapters/agents/copilot-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGnE,SAAS,WAAW,CAAC,QAAgC;IACnD,YAAY,CAAC,mBAAmB,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,WAAW,GAAG,iBAAiB,CACnC,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,CAAC,cAAc,EACvB,QAAQ,CAAC,KAAK,CACf,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,SAAS;QACf,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvC,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,KAAK;QACf,aAAa,EAAE,SAAS;QACxB,qBAAqB,EAAE,IAAI;QAC3B,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;YACvB,mBAAmB,EAAE,OAAO;YAC5B,GAAG,QAAQ,CAAC,SAAS;SACtB,CAAC;QACF,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC;QACnD,MAAM,EAAE,aAAa;QACrB,KAAK,EAAE,SAAS;QAChB,YAAY,EAAE,CAAC,YAAY,EAAE,EAAE,CAC7B,mBAAmB,CAAC,SAAS,EAAE,YAAY,CAAC;QAC9C,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,YAAY,CAAC;KACvC,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,WAA4B,EAAE;IAC3D,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC1B,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;QAC/B,GAAG,QAAQ;QACX,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;KACpD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,CAAC,KAAkB,EAAE,EAAE,CAC3B,WAAW,CAAC;YACV,GAAG,UAAU;YACb,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;SAC1C,CAAC;KACL,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { copilotUsage } from \"./copilot-usage.ts\";\nimport { sessionUsageCommand, sessionUsageResult } from \"./session-usage.ts\";\nimport type { AgentAdapter, CliHarness } from \"../../domain/agent.types.ts\";\nimport type { AgentModel } from \"../../domain/model.types.ts\";\nimport { credentialPlanner } from \"./authentication.ts\";\nimport { copilotCredentials } from \"./copilot-authentication.ts\";\nimport { copilotEvents } from \"./copilot-events.ts\";\nimport { copilotRequest } from \"./copilot-request.ts\";\nimport type { CopilotSettings } from \"./copilot.types.ts\";\nimport { copilotModelSupport } from \"./model-support.constants.ts\";\nimport { harnessSettings, supportModel } from \"./model-support.ts\";\nimport type { Bound } from \"./settings.types.ts\";\n\nfunction bindCopilot(settings: Bound<CopilotSettings>): AgentAdapter {\n supportModel(copilotModelSupport, settings.model);\n const credentials = credentialPlanner(\n \"GitHub Copilot CLI\",\n copilotCredentials,\n settings.authentication,\n settings.model,\n );\n return Object.freeze({\n name: \"copilot\",\n ...(credentials ? { credentials } : {}),\n bootstrap: \"copilot\",\n resumable: true,\n forkable: false,\n conversations: \"copilot\",\n requiresFinishedEvent: true,\n variables: Object.freeze({\n COPILOT_AUTO_UPDATE: \"false\",\n ...settings.variables,\n }),\n request: (input) => copilotRequest(settings, input),\n events: copilotEvents,\n usage: \"session\",\n usageCommand: (conversation) =>\n sessionUsageCommand(\"copilot\", conversation),\n usageResult: (text) => sessionUsageResult(text, copilotUsage),\n } satisfies AgentAdapter);\n}\n\nexport function copilotHarness(settings: CopilotSettings = {}): CliHarness {\n harnessSettings(settings);\n const configured = Object.freeze({\n ...settings,\n variables: Object.freeze({ ...settings.variables }),\n });\n return Object.freeze({\n kind: \"cli\",\n bind: (model?: AgentModel) =>\n bindCopilot({\n ...configured,\n ...(model === undefined ? {} : { model }),\n }),\n });\n}\n"]}
@@ -18,9 +18,10 @@ function parseConfiguration(content) {
18
18
  function storedToken(content) {
19
19
  const configuration = parseConfiguration(content);
20
20
  const user = asRecord(configuration.lastLoggedInUser);
21
- const token = typeof user.host === "string" && typeof user.login === "string"
21
+ const stored = typeof user.host === "string" && typeof user.login === "string"
22
22
  ? asRecord(configuration.authTokens)[`${user.host}:${user.login}`]
23
23
  : undefined;
24
+ const token = typeof stored === "string" ? stored : asRecord(stored).token;
24
25
  invariant(typeof token === "string" && token !== "", `Copilot config.json stores no token for the last logged-in user. Copilot keeps tokens in the system keychain by default, which Outpost never reads: pass { account: { variable: "${variable}" } } instead.`);
25
26
  acceptToken(token);
26
27
  return token;
@@ -1 +1 @@
1
- {"version":3,"file":"copilot-authentication.js","sourceRoot":"","sources":["../../../src/adapters/agents/copilot-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC;AAErD,SAAS,WAAW,CAAC,KAAa;IAChC,SAAS,CACP,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EACzB,mJAAmJ,CACpJ,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAe;IACzC,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,YAAY,CACpB,eAAe,EACf,gDAAgD,CACjD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,OAAe;IAClC,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACtD,MAAM,KAAK,GACT,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;QAC7D,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAClE,CAAC,CAAC,SAAS,CAAC;IAChB,SAAS,CACP,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,EACzC,oLAAoL,QAAQ,gBAAgB,CAC7M,CAAC;IACF,WAAW,CAAC,KAAK,CAAC,CAAC;IACnB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,IAAI,GAAG,QAAQ,CAAC;IACpB,MAAM,EAAE;QACN,IAAI,EAAE,wBAAwB;QAC9B,IAAI,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE;KACxD;IACD,WAAW,EAAE,EAAE,QAAQ,EAAE;IACzB,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,2BAA2B,QAAQ,OAAO;IACvD,MAAM,EAAE,WAAW;CACpB,CAAC,CAAC;AAEH,MAAM,KAAK,GAAG,kBAAkB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;AAEpE,MAAM,CAAC,MAAM,kBAAkB,GAAuB,MAAM,CAAC,MAAM,CAAC;IAClE,OAAO,EAAE,IAAI,CAAC,MAAM;IACpB,cAAc,EAAE,IAAI,CAAC,IAAI;IACzB,aAAa,EAAE,KAAK,CAAC,GAAG;IACxB,kBAAkB,EAAE,KAAK,CAAC,QAAQ;CACnC,CAAC,CAAC","sourcesContent":["import { invariant, OutpostError } from \"../../domain/errors.ts\";\nimport { parseJsonc } from \"../../infrastructure/host-credentials.ts\";\nimport { credentialVariables } from \"./authentication.constants.ts\";\nimport { hostFile, variableCredential } from \"./authentication.ts\";\nimport type { CredentialStrategy } from \"./authentication.types.ts\";\nimport { asRecord } from \"./protocol.ts\";\n\nconst variable = credentialVariables.copilot.account;\n\nfunction acceptToken(token: string): void {\n invariant(\n !token.startsWith(\"ghp_\"),\n \"GitHub Copilot CLI rejects classic personal access tokens (ghp_). Use copilot login or a fine-grained token with the Copilot Requests permission.\",\n );\n}\n\nfunction parseConfiguration(content: string): Record<string, unknown> {\n try {\n return asRecord(parseJsonc(content));\n } catch {\n throw new OutpostError(\n \"configuration\",\n \"The Copilot config.json file is not valid JSON\",\n );\n }\n}\n\nfunction storedToken(content: string): string {\n const configuration = parseConfiguration(content);\n const user = asRecord(configuration.lastLoggedInUser);\n const token =\n typeof user.host === \"string\" && typeof user.login === \"string\"\n ? asRecord(configuration.authTokens)[`${user.host}:${user.login}`]\n : undefined;\n invariant(\n typeof token === \"string\" && token !== \"\",\n `Copilot config.json stores no token for the last logged-in user. Copilot keeps tokens in the system keychain by default, which Outpost never reads: pass { account: { variable: \"${variable}\" } } instead.`,\n );\n acceptToken(token);\n return token;\n}\n\nconst file = hostFile({\n source: {\n path: \"~/.copilot/config.json\",\n home: { variable: \"COPILOT_HOME\", path: \"config.json\" },\n },\n destination: { variable },\n login: \"copilot login\",\n alternative: `{ account: { variable: \"${variable}\" } }`,\n select: storedToken,\n});\n\nconst token = variableCredential({ variable, accept: acceptToken });\n\nexport const copilotCredentials: CredentialStrategy = Object.freeze({\n account: file.preset,\n \"account.file\": file.file,\n \"account.key\": token.key,\n \"account.variable\": token.variable,\n});\n"]}
1
+ {"version":3,"file":"copilot-authentication.js","sourceRoot":"","sources":["../../../src/adapters/agents/copilot-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC;AAErD,SAAS,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WAAW,EAAE,EAAE,QAAQ,EAAE;IACzB,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,2BAA2B,QAAQ,OAAO;IACvD,MAAM,EAAE,WAAW;CACpB,CAAC,CAAC;AAEH,MAAM,KAAK,GAAG,kBAAkB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;AAEpE,MAAM,CAAC,MAAM,kBAAkB,GAAuB,MAAM,CAAC,MAAM,CAAC;IAClE,OAAO,EAAE,IAAI,CAAC,MAAM;IACpB,cAAc,EAAE,IAAI,CAAC,IAAI;IACzB,aAAa,EAAE,KAAK,CAAC,GAAG;IACxB,kBAAkB,EAAE,KAAK,CAAC,QAAQ;CACnC,CAAC,CAAC","sourcesContent":["import { invariant, OutpostError } from \"../../domain/errors.ts\";\nimport { parseJsonc } from \"../../infrastructure/host-credentials.ts\";\nimport { credentialVariables } from \"./authentication.constants.ts\";\nimport { hostFile, variableCredential } from \"./authentication.ts\";\nimport type { CredentialStrategy } from \"./authentication.types.ts\";\nimport { asRecord } from \"./protocol.ts\";\n\nconst variable = credentialVariables.copilot.account;\n\nfunction acceptToken(token: string): void {\n invariant(\n !token.startsWith(\"ghp_\"),\n \"GitHub Copilot CLI rejects classic personal access tokens (ghp_). Use copilot login or a fine-grained token with the Copilot Requests permission.\",\n );\n}\n\nfunction parseConfiguration(content: string): Record<string, unknown> {\n try {\n return asRecord(parseJsonc(content));\n } catch {\n throw new OutpostError(\n \"configuration\",\n \"The Copilot config.json file is not valid JSON\",\n );\n }\n}\n\nfunction storedToken(content: string): string {\n const configuration = parseConfiguration(content);\n const user = asRecord(configuration.lastLoggedInUser);\n const stored =\n typeof user.host === \"string\" && typeof user.login === \"string\"\n ? asRecord(configuration.authTokens)[`${user.host}:${user.login}`]\n : undefined;\n const token = typeof stored === \"string\" ? stored : asRecord(stored).token;\n invariant(\n typeof token === \"string\" && token !== \"\",\n `Copilot config.json stores no token for the last logged-in user. Copilot keeps tokens in the system keychain by default, which Outpost never reads: pass { account: { variable: \"${variable}\" } } instead.`,\n );\n acceptToken(token);\n return token;\n}\n\nconst file = hostFile({\n source: {\n path: \"~/.copilot/config.json\",\n home: { variable: \"COPILOT_HOME\", path: \"config.json\" },\n },\n destination: { variable },\n login: \"copilot login\",\n alternative: `{ account: { variable: \"${variable}\" } }`,\n select: storedToken,\n});\n\nconst token = variableCredential({ variable, accept: acceptToken });\n\nexport const copilotCredentials: CredentialStrategy = Object.freeze({\n account: file.preset,\n \"account.file\": file.file,\n \"account.key\": token.key,\n \"account.variable\": token.variable,\n});\n"]}
@@ -1,6 +1,6 @@
1
1
  import { helpDiagnostics } from "./cli-diagnostics.js";
2
2
  import { copilotRequest } from "./copilot-request.js";
3
3
  export function copilotDiagnostics() {
4
- return helpDiagnostics((input) => copilotRequest({}, input), "Usage: copilot [");
4
+ return helpDiagnostics((input) => copilotRequest({}, input), "Usage: copilot [", true);
5
5
  }
6
6
  //# sourceMappingURL=copilot-diagnostics.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"copilot-diagnostics.js","sourceRoot":"","sources":["../../../src/adapters/agents/copilot-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,UAAU,kBAAkB;IAChC,OAAO,eAAe,CACpB,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,EACpC,kBAAkB,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import { helpDiagnostics } from \"./cli-diagnostics.ts\";\nimport { copilotRequest } from \"./copilot-request.ts\";\n\nexport function copilotDiagnostics() {\n return helpDiagnostics(\n (input) => copilotRequest({}, input),\n \"Usage: copilot [\",\n );\n}\n"]}
1
+ {"version":3,"file":"copilot-diagnostics.js","sourceRoot":"","sources":["../../../src/adapters/agents/copilot-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,UAAU,kBAAkB;IAChC,OAAO,eAAe,CACpB,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,EACpC,kBAAkB,EAClB,IAAI,CACL,CAAC;AACJ,CAAC","sourcesContent":["import { helpDiagnostics } from \"./cli-diagnostics.ts\";\nimport { copilotRequest } from \"./copilot-request.ts\";\n\nexport function copilotDiagnostics() {\n return helpDiagnostics(\n (input) => copilotRequest({}, input),\n \"Usage: copilot [\",\n true,\n );\n}\n"]}
@@ -1,3 +1,5 @@
1
+ import { copilotShutdown, copilotUsage } from "./copilot-usage.js";
2
+ import { toolResult } from "./tool-result.js";
1
3
  import { decodeLine } from "./event-decoder.js";
2
4
  import { asRecord } from "./protocol.js";
3
5
  function message(event) {
@@ -38,6 +40,20 @@ function result(event) {
38
40
  export function copilotEvents(line) {
39
41
  return decodeLine(line, {
40
42
  "assistant.message": message,
43
+ "assistant.usage": (event) => [
44
+ { kind: "usage", tokens: copilotUsage(event.data) },
45
+ ],
46
+ "session.shutdown": copilotShutdown,
47
+ "assistant.reasoning": (event) => {
48
+ const data = asRecord(event.data);
49
+ return typeof data.content === "string"
50
+ ? [{ kind: "reasoning", text: data.content }]
51
+ : [];
52
+ },
53
+ "tool.execution_complete": (event) => {
54
+ const data = asRecord(event.data);
55
+ return toolResult(data.toolCallId, undefined, data.result ?? data.error, data.success === false);
56
+ },
41
57
  "session.error": (event) => {
42
58
  const data = asRecord(event.data);
43
59
  return typeof data.message === "string"
@@ -1 +1 @@
1
- {"version":3,"file":"copilot-events.js","sourceRoot":"","sources":["../../../src/adapters/agents/copilot-events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,C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S;QACrD,OAAO,CAAC,GAAG,YAAY,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IACjD,OAAO;QACL,GAAG,YAAY;QACf;YACE,IAAI,EAAE,SAAS;YACf,OAAO,EACL,KAAK,CAAC,OAAO,KAAK,SAAS;gBACzB,CAAC,CAAC,6DAA6D;gBAC/D,CAAC,CAAC,2CAA2C,MAAM,CAAC,KAAK,CAAC,QAAQ,IAAI,SAAS,CAAC,EAAE;SACvF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,UAAU,CAAC,IAAI,EAAE;QACtB,mBAAmB,EAAE,OAAO;QAC5B,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE;YACzB,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAClC,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ;gBACrC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC9C,CAAC,CAAC,EAAE,CAAC;QACT,CAAC;QACD,MAAM;KACP,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { AgentEvent } from \"../../domain/agent.types.ts\";\nimport { decodeLine } from \"./event-decoder.ts\";\nimport { asRecord } from \"./protocol.ts\";\nimport type { ProtocolRecord } from \"./protocol.types.ts\";\n\nfunction message(event: ProtocolRecord): AgentEvent[] {\n const data = asRecord(event.data);\n const requests = Array.isArray(data.toolRequests) ? data.toolRequests : [];\n const tools = requests.map(asRecord).flatMap((request): AgentEvent[] =>\n typeof request.name === \"string\"\n ? [\n {\n kind: \"tool\",\n name: request.name,\n input: request.arguments,\n ...(typeof request.toolCallId === \"string\"\n ? { callId: request.toolCallId }\n : {}),\n },\n ]\n : [],\n );\n return typeof data.content === \"string\" && data.content\n ? [{ kind: \"text\", text: data.content }, ...tools]\n : tools;\n}\n\nfunction result(event: ProtocolRecord): AgentEvent[] {\n const conversation: AgentEvent[] =\n typeof event.sessionId === \"string\"\n ? [{ kind: \"conversation\", id: event.sessionId }]\n : [];\n if (event.exitCode === 0 && event.outcome !== \"blocked\")\n return [...conversation, { kind: \"finished\" }];\n return [\n ...conversation,\n {\n kind: \"failure\",\n message:\n event.outcome === \"blocked\"\n ? \"GitHub Copilot CLI was blocked before completing the prompt\"\n : `GitHub Copilot CLI ended with exit code ${String(event.exitCode ?? \"unknown\")}`,\n },\n ];\n}\n\nexport function copilotEvents(line: string): AgentEvent[] {\n return decodeLine(line, {\n \"assistant.message\": message,\n \"session.error\": (event) => {\n const data = asRecord(event.data);\n return typeof data.message === \"string\"\n ? [{ kind: \"warning\", message: data.message }]\n : [];\n },\n result,\n });\n}\n"]}
1
+ {"version":3,"file":"copilot-events.js","sourceRoot":"","sources":["../../../src/adapters/agents/copilot-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,SAAS,OAAO,CAAC,KAAqB;IACpC,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3E,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAgB,EAAE,CACrE,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ;QAC9B,CAAC,CAAC;YACE;gBACE,IAAI,EAAE,MAAM;gBACZ,I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AK,EAAE,EAAE,CAAC;YAC5B,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;SACpD;QACD,kBAAkB,EAAE,eAAe;QACnC,qBAAqB,EAAE,CAAC,KAAK,EAAE,EAAE;YAC/B,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAClC,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ;gBACrC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC7C,CAAC,CAAC,EAAE,CAAC;QACT,CAAC;QACD,yBAAyB,EAAE,CAAC,KAAK,EAAE,EAAE;YACnC,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAClC,OAAO,UAAU,CACf,IAAI,CAAC,UAAU,EACf,SAAS,EACT,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,EACzB,IAAI,CAAC,OAAO,KAAK,KAAK,CACvB,CAAC;QACJ,CAAC;QACD,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE;YACzB,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAClC,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ;gBACrC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC9C,CAAC,CAAC,EAAE,CAAC;QACT,CAAC;QACD,MAAM;KACP,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { copilotShutdown, copilotUsage } from \"./copilot-usage.ts\";\nimport { toolResult } from \"./tool-result.ts\";\nimport type { AgentEvent } from \"../../domain/agent.types.ts\";\nimport { decodeLine } from \"./event-decoder.ts\";\nimport { asRecord } from \"./protocol.ts\";\nimport type { ProtocolRecord } from \"./protocol.types.ts\";\n\nfunction message(event: ProtocolRecord): AgentEvent[] {\n const data = asRecord(event.data);\n const requests = Array.isArray(data.toolRequests) ? data.toolRequests : [];\n const tools = requests.map(asRecord).flatMap((request): AgentEvent[] =>\n typeof request.name === \"string\"\n ? [\n {\n kind: \"tool\",\n name: request.name,\n input: request.arguments,\n ...(typeof request.toolCallId === \"string\"\n ? { callId: request.toolCallId }\n : {}),\n },\n ]\n : [],\n );\n return typeof data.content === \"string\" && data.content\n ? [{ kind: \"text\", text: data.content }, ...tools]\n : tools;\n}\n\nfunction result(event: ProtocolRecord): AgentEvent[] {\n const conversation: AgentEvent[] =\n typeof event.sessionId === \"string\"\n ? [{ kind: \"conversation\", id: event.sessionId }]\n : [];\n if (event.exitCode === 0 && event.outcome !== \"blocked\")\n return [...conversation, { kind: \"finished\" }];\n return [\n ...conversation,\n {\n kind: \"failure\",\n message:\n event.outcome === \"blocked\"\n ? \"GitHub Copilot CLI was blocked before completing the prompt\"\n : `GitHub Copilot CLI ended with exit code ${String(event.exitCode ?? \"unknown\")}`,\n },\n ];\n}\n\nexport function copilotEvents(line: string): AgentEvent[] {\n return decodeLine(line, {\n \"assistant.message\": message,\n \"assistant.usage\": (event) => [\n { kind: \"usage\", tokens: copilotUsage(event.data) },\n ],\n \"session.shutdown\": copilotShutdown,\n \"assistant.reasoning\": (event) => {\n const data = asRecord(event.data);\n return typeof data.content === \"string\"\n ? [{ kind: \"reasoning\", text: data.content }]\n : [];\n },\n \"tool.execution_complete\": (event) => {\n const data = asRecord(event.data);\n return toolResult(\n data.toolCallId,\n undefined,\n data.result ?? data.error,\n data.success === false,\n );\n },\n \"session.error\": (event) => {\n const data = asRecord(event.data);\n return typeof data.message === \"string\"\n ? [{ kind: \"warning\", message: data.message }]\n : [];\n },\n result,\n });\n}\n"]}
@@ -1,7 +1,12 @@
1
+ import { validId } from "../../infrastructure/conversations/identity.js";
1
2
  import { invariant } from "../../domain/errors.js";
2
3
  export function copilotRequest(settings, input) {
3
- invariant(!input.continuation, "GitHub Copilot CLI does not support continuation or fork in Outpost");
4
+ invariant(!input.continuation?.fork, "GitHub Copilot CLI does not support automated fork in Outpost");
4
5
  const args = [];
6
+ if (input.continuation) {
7
+ validId(input.continuation.id);
8
+ args.push("--resume", input.continuation.id);
9
+ }
5
10
  if (settings.model)
6
11
  args.push("--model", settings.model.name);
7
12
  if (input.interactive)
@@ -1 +1 @@
1
- {"version":3,"file":"copilot-request.js","sourceRoot":"","sources":["../../../src/adapters/agents/copilot-request.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInD,MAAM,UAAU,cAAc,CAC5B,QAAgC,EAChC,KAAiB;IAEjB,SAAS,CACP,CAAC,KAAK,CAAC,YAAY,EACnB,qEAAqE,CACtE,CAAC;IACF,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,QAAQ,CAAC,KAAK;QAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9D,IAAI,KAAK,CAAC,WAAW;QACnB,OAAO;YACL,UAAU,EAAE,SAAS;YACrB,SAAS,EAAE;gBACT,GAAG,IAAI;gBACP,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;aACnE;YACD,WAAW,EAAE,IAAI;SAClB,CAAC;IACJ,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;IACrE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;AAC7E,CAAC","sourcesContent":["import type { AgentInput } from \"../../domain/agent.types.ts\";\nimport type { Command } from \"../../domain/command.types.ts\";\nimport { invariant } from \"../../domain/errors.ts\";\nimport type { CopilotSettings } from \"./copilot.types.ts\";\nimport type { Bound } from \"./settings.types.ts\";\n\nexport function copilotRequest(\n settings: Bound<CopilotSettings>,\n input: AgentInput,\n): Command {\n invariant(\n !input.continuation,\n \"GitHub Copilot CLI does not support continuation or fork in Outpost\",\n );\n const args: string[] = [];\n if (settings.model) args.push(\"--model\", settings.model.name);\n if (input.interactive)\n return {\n executable: \"copilot\",\n arguments: [\n ...args,\n ...(input.text === undefined ? [] : [\"--interactive\", input.text]),\n ],\n interactive: true,\n };\n args.push(\"--output-format\", \"json\", \"--allow-all\", \"--no-ask-user\");\n return { executable: \"copilot\", arguments: args, stdin: input.text ?? \"\" };\n}\n"]}
1
+ {"version":3,"file":"copilot-request.js","sourceRoot":"","sources":["../../../src/adapters/agents/copilot-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gDAAgD,CAAC;AAGzE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInD,MAAM,UAAU,cAAc,CAC5B,QAAgC,EAChC,KAAiB;IAEjB,SAAS,CACP,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,EACzB,+DAA+D,CAChE,CAAC;IACF,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,QAAQ,CAAC,KAAK;QAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9D,IAAI,KAAK,CAAC,WAAW;QACnB,OAAO;YACL,UAAU,EAAE,SAAS;YACrB,SAAS,EAAE;gBACT,GAAG,IAAI;gBACP,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;aACnE;YACD,WAAW,EAAE,IAAI;SAClB,CAAC;IACJ,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;IACrE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;AAC7E,CAAC","sourcesContent":["import { validId } from \"../../infrastructure/conversations/identity.ts\";\nimport type { AgentInput } from \"../../domain/agent.types.ts\";\nimport type { Command } from \"../../domain/command.types.ts\";\nimport { invariant } from \"../../domain/errors.ts\";\nimport type { CopilotSettings } from \"./copilot.types.ts\";\nimport type { Bound } from \"./settings.types.ts\";\n\nexport function copilotRequest(\n settings: Bound<CopilotSettings>,\n input: AgentInput,\n): Command {\n invariant(\n !input.continuation?.fork,\n \"GitHub Copilot CLI does not support automated fork in Outpost\",\n );\n const args: string[] = [];\n if (input.continuation) {\n validId(input.continuation.id);\n args.push(\"--resume\", input.continuation.id);\n }\n if (settings.model) args.push(\"--model\", settings.model.name);\n if (input.interactive)\n return {\n executable: \"copilot\",\n arguments: [\n ...args,\n ...(input.text === undefined ? [] : [\"--interactive\", input.text]),\n ],\n interactive: true,\n };\n args.push(\"--output-format\", \"json\", \"--allow-all\", \"--no-ask-user\");\n return { executable: \"copilot\", arguments: args, stdin: input.text ?? \"\" };\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { AgentEvent, Usage } from "../../domain/agent.types.ts";
2
+ export declare function copilotUsage(value: unknown): Usage;
3
+ export declare function copilotShutdown(event: Record<string, unknown>): AgentEvent[];
@@ -0,0 +1,19 @@
1
+ import { addUsage } from "../../domain/usage.js";
2
+ import { asRecord } from "./protocol.js";
3
+ import { usageCounts } from "./session-usage.js";
4
+ export function copilotUsage(value) {
5
+ const usage = asRecord(value);
6
+ return usageCounts(usage.inputTokens, usage.outputTokens, usage.cacheReadTokens, usage.cacheWriteTokens);
7
+ }
8
+ export function copilotShutdown(event) {
9
+ const metrics = asRecord(asRecord(event.data).modelMetrics);
10
+ const values = Object.values(metrics);
11
+ const tokens = values.reduce((total, metric) => addUsage(total, copilotUsage(asRecord(metric).usage)), {
12
+ input: 0,
13
+ cached: 0,
14
+ output: 0,
15
+ ...(values.length ? {} : { complete: false }),
16
+ });
17
+ return [{ kind: "usage", tokens, cumulative: true }];
18
+ }
19
+ //# sourceMappingURL=copilot-usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot-usage.js","sourceRoot":"","sources":["../../../src/adapters/agents/copilot-usage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,WAAW,CAChB,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,eAAe,EACrB,KAAK,CAAC,gBAAgB,CACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAA8B;IAC5D,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAC1B,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EACxE;QACE,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,MAAM,EAAE,CAAC;QACT,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;KAC9C,CACF,CAAC;IACF,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import type { AgentEvent, Usage } from \"../../domain/agent.types.ts\";\nimport { addUsage } from \"../../domain/usage.ts\";\nimport { asRecord } from \"./protocol.ts\";\nimport { usageCounts } from \"./session-usage.ts\";\n\nexport function copilotUsage(value: unknown): Usage {\n const usage = asRecord(value);\n return usageCounts(\n usage.inputTokens,\n usage.outputTokens,\n usage.cacheReadTokens,\n usage.cacheWriteTokens,\n );\n}\n\nexport function copilotShutdown(event: Record<string, unknown>): AgentEvent[] {\n const metrics = asRecord(asRecord(event.data).modelMetrics);\n const values = Object.values(metrics);\n const tokens = values.reduce<Usage>(\n (total, metric) => addUsage(total, copilotUsage(asRecord(metric).usage)),\n {\n input: 0,\n cached: 0,\n output: 0,\n ...(values.length ? {} : { complete: false }),\n },\n );\n return [{ kind: \"usage\", tokens, cumulative: true }];\n}\n"]}
@@ -1,3 +1,9 @@
1
+ import { kimiUsage } from "./kimi-usage.js";
2
+ import { sessionUsageCommand, sessionUsageResult } from "./session-usage.js";
3
+ import { forkKimi } from "./kimi-fork.js";
4
+ import { invariant } from "../../domain/errors.js";
5
+ import { authenticationForm } from "../../domain/authentication.js";
6
+ import { kimiRegions } from "./kimi.constants.js";
1
7
  import { credentialPlanner } from "./authentication.js";
2
8
  import { kimiCredentials } from "./kimi-authentication.js";
3
9
  import { kimiEvents } from "./kimi-events.js";
@@ -6,23 +12,33 @@ import { kimiModelSupport } from "./model-support.constants.js";
6
12
  import { harnessSettings, supportModel } from "./model-support.js";
7
13
  function bindKimi(settings) {
8
14
  supportModel(kimiModelSupport, settings.model);
9
- const credentials = credentialPlanner("Kimi Code", kimiCredentials, settings.authentication, settings.model);
15
+ const credentials = credentialPlanner("Kimi Code", kimiCredentials(settings.region), settings.authentication, settings.model);
10
16
  return Object.freeze({
11
17
  name: "kimi",
12
18
  ...(credentials ? { credentials } : {}),
13
19
  bootstrap: "kimi",
14
- resumable: false,
15
- capture: false,
20
+ resumable: true,
21
+ forkable: true,
22
+ fork: forkKimi,
23
+ conversations: "kimi",
16
24
  variables: Object.freeze({
17
25
  KIMI_CODE_NO_AUTO_UPDATE: "1",
18
26
  ...settings.variables,
19
27
  }),
20
28
  request: (input) => kimiRequest(settings, input),
21
29
  events: kimiEvents,
30
+ usage: "session",
31
+ usageCommand: (conversation) => sessionUsageCommand("kimi", conversation),
32
+ usageResult: (text) => sessionUsageResult(text, kimiUsage),
22
33
  });
23
34
  }
24
35
  export function kimiHarness(settings = {}) {
25
36
  harnessSettings(settings);
37
+ invariant(settings.region === undefined ||
38
+ Object.hasOwn(kimiRegions, settings.region), 'Kimi region must be "mainland-cn" or "global"');
39
+ invariant(settings.region === undefined ||
40
+ settings.authentication === undefined ||
41
+ !authenticationForm(settings.authentication).form.startsWith("usage"), "Kimi region selects account authentication; configure the API endpoint through variables for usage authentication");
26
42
  const configured = Object.freeze({
27
43
  ...settings,
28
44
  variables: Object.freeze({ ...settings.variables }),
@@ -1 +1 @@
1
- {"version":3,"file":"kimi-adapter.js","sourceRoot":"","sources":["../../../src/adapters/agents/kimi-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAA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K,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KACzE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { AgentAdapter, CliHarness } from \"../../domain/agent.types.ts\";\nimport type { AgentModel } from \"../../domain/model.types.ts\";\nimport { credentialPlanner } from \"./authentication.ts\";\nimport { kimiCredentials } from \"./kimi-authentication.ts\";\nimport { kimiEvents } from \"./kimi-events.ts\";\nimport { kimiRequest } from \"./kimi-request.ts\";\nimport type { KimiSettings } from \"./kimi.types.ts\";\nimport { kimiModelSupport } from \"./model-support.constants.ts\";\nimport { harnessSettings, supportModel } from \"./model-support.ts\";\nimport type { Bound } from \"./settings.types.ts\";\n\nfunction bindKimi(settings: Bound<KimiSettings>): AgentAdapter {\n supportModel(kimiModelSupport, settings.model);\n const credentials = credentialPlanner(\n \"Kimi Code\",\n kimiCredentials,\n settings.authentication,\n settings.model,\n );\n return Object.freeze({\n name: \"kimi\",\n ...(credentials ? { credentials } : {}),\n bootstrap: \"kimi\",\n resumable: false,\n capture: false,\n variables: Object.freeze({\n KIMI_CODE_NO_AUTO_UPDATE: \"1\",\n ...settings.variables,\n }),\n request: (input) => kimiRequest(settings, input),\n events: kimiEvents,\n } satisfies AgentAdapter);\n}\n\nexport function kimiHarness(settings: KimiSettings = {}): CliHarness {\n harnessSettings(settings);\n const configured = Object.freeze({\n ...settings,\n variables: Object.freeze({ ...settings.variables }),\n });\n return Object.freeze({\n kind: \"cli\",\n bind: (model?: AgentModel) =>\n bindKimi({ ...configured, ...(model === undefined ? {} : { model }) }),\n });\n}\n"]}
1
+ {"version":3,"file":"kimi-adapter.js","sourceRoot":"","sources":["../../../src/adapters/agents/kimi-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,E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AChD,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,SAAS;QAChB,YAAY,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC;QACzE,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC;KACpC,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,WAAyB,EAAE;IACrD,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC1B,SAAS,CACP,QAAQ,CAAC,MAAM,KAAK,SAAS;QAC3B,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,EAC7C,+CAA+C,CAChD,CAAC;IACF,SAAS,CACP,QAAQ,CAAC,MAAM,KAAK,SAAS;QAC3B,QAAQ,CAAC,cAAc,KAAK,SAAS;QACrC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EACvE,mHAAmH,CACpH,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;QAC/B,GAAG,QAAQ;QACX,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;KACpD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,CAAC,KAAkB,EAAE,EAAE,CAC3B,QAAQ,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KACzE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { kimiUsage } from \"./kimi-usage.ts\";\nimport { sessionUsageCommand, sessionUsageResult } from \"./session-usage.ts\";\nimport { forkKimi } from \"./kimi-fork.ts\";\nimport type { AgentAdapter, CliHarness } from \"../../domain/agent.types.ts\";\nimport { invariant } from \"../../domain/errors.ts\";\nimport { authenticationForm } from \"../../domain/authentication.ts\";\nimport { kimiRegions } from \"./kimi.constants.ts\";\nimport type { AgentModel } from \"../../domain/model.types.ts\";\nimport { credentialPlanner } from \"./authentication.ts\";\nimport { kimiCredentials } from \"./kimi-authentication.ts\";\nimport { kimiEvents } from \"./kimi-events.ts\";\nimport { kimiRequest } from \"./kimi-request.ts\";\nimport type { KimiSettings } from \"./kimi.types.ts\";\nimport { kimiModelSupport } from \"./model-support.constants.ts\";\nimport { harnessSettings, supportModel } from \"./model-support.ts\";\nimport type { Bound } from \"./settings.types.ts\";\n\nfunction bindKimi(settings: Bound<KimiSettings>): AgentAdapter {\n supportModel(kimiModelSupport, settings.model);\n const credentials = credentialPlanner(\n \"Kimi Code\",\n kimiCredentials(settings.region),\n settings.authentication,\n settings.model,\n );\n return Object.freeze({\n name: \"kimi\",\n ...(credentials ? { credentials } : {}),\n bootstrap: \"kimi\",\n resumable: true,\n forkable: true,\n fork: forkKimi,\n conversations: \"kimi\",\n variables: Object.freeze({\n KIMI_CODE_NO_AUTO_UPDATE: \"1\",\n ...settings.variables,\n }),\n request: (input) => kimiRequest(settings, input),\n events: kimiEvents,\n usage: \"session\",\n usageCommand: (conversation) => sessionUsageCommand(\"kimi\", conversation),\n usageResult: (text) => sessionUsageResult(text, kimiUsage),\n } satisfies AgentAdapter);\n}\n\nexport function kimiHarness(settings: KimiSettings = {}): CliHarness {\n harnessSettings(settings);\n invariant(\n settings.region === undefined ||\n Object.hasOwn(kimiRegions, settings.region),\n 'Kimi region must be \"mainland-cn\" or \"global\"',\n );\n invariant(\n settings.region === undefined ||\n settings.authentication === undefined ||\n !authenticationForm(settings.authentication).form.startsWith(\"usage\"),\n \"Kimi region selects account authentication; configure the API endpoint through variables for usage authentication\",\n );\n const configured = Object.freeze({\n ...settings,\n variables: Object.freeze({ ...settings.variables }),\n });\n return Object.freeze({\n kind: \"cli\",\n bind: (model?: AgentModel) =>\n bindKimi({ ...configured, ...(model === undefined ? {} : { model }) }),\n });\n}\n"]}
@@ -1,2 +1,3 @@
1
+ import type { KimiSettings } from "./kimi.types.ts";
1
2
  import type { CredentialStrategy } from "./authentication.types.ts";
2
- export declare const kimiCredentials: CredentialStrategy;
3
+ export declare function kimiCredentials(region?: NonNullable<KimiSettings["region"]>): CredentialStrategy;
@@ -1,23 +1,36 @@
1
1
  import { join, posix } from "node:path";
2
+ import { DEFAULT_KIMI_REGION, kimiRegions } from "./kimi.constants.js";
2
3
  import { invariant } from "../../domain/errors.js";
3
4
  import { KIMI_LOGIN_DEADLINE_MS, credentialVariables, } from "./authentication.constants.js";
4
5
  import { credentialPlan, toolCommand, variableCredential, } from "./authentication.js";
5
- const profileFiles = [
6
- ["credentials", "kimi-code.json"],
7
- ["device_id"],
8
- ];
9
- function profile(root) {
10
- return () => credentialPlan({
11
- host: profileFiles.map((parts) => ({
12
- source: root(join(...parts)),
13
- destination: { file: posix.join(".kimi-code", ...parts) },
14
- login: "kimi login",
15
- alternative: `"usage" with ${credentialVariables.kimi.usage} and a model`,
16
- })),
17
- commands: [
18
- toolCommand("kimi", ["login"], { deadlineMs: KIMI_LOGIN_DEADLINE_MS }),
19
- ],
20
- });
6
+ function profile(root, region) {
7
+ const selected = kimiRegions[region];
8
+ const profileFiles = [["credentials", selected.credential], ["device_id"]];
9
+ return (variables) => {
10
+ for (const [name, expected] of [
11
+ ["KIMI_CODE_OAUTH_HOST", selected.oauthHost],
12
+ ["KIMI_OAUTH_HOST", selected.oauthHost],
13
+ ["KIMI_CODE_BASE_URL", selected.baseUrl],
14
+ ])
15
+ invariant(!variables[name] || variables[name]?.replace(/\/+$/, "") === expected, `Kimi ${name} conflicts with account region "${region}"`);
16
+ return credentialPlan({
17
+ variables: {
18
+ KIMI_CODE_OAUTH_HOST: selected.oauthHost,
19
+ KIMI_CODE_BASE_URL: selected.baseUrl,
20
+ },
21
+ host: profileFiles.map((parts) => ({
22
+ source: root(join(...parts)),
23
+ destination: { file: posix.join(".kimi-code", ...parts) },
24
+ login: `kimi login --region ${region}`,
25
+ alternative: `"usage" with ${credentialVariables.kimi.usage} and a model`,
26
+ })),
27
+ commands: [
28
+ toolCommand("kimi", ["login", "--region", region], {
29
+ deadlineMs: KIMI_LOGIN_DEADLINE_MS,
30
+ }),
31
+ ],
32
+ });
33
+ };
21
34
  }
22
35
  function modelName(input) {
23
36
  const name = input.model?.name;
@@ -35,14 +48,16 @@ const key = variableCredential({
35
48
  },
36
49
  }),
37
50
  });
38
- export const kimiCredentials = Object.freeze({
39
- account: () => profile((path) => ({
40
- path: join("~/.kimi-code", path),
41
- home: { variable: "KIMI_CODE_HOME", path },
42
- })),
43
- "account.file": (input) => profile((path) => ({ path: join(input.value, path) })),
44
- usage: key.preset,
45
- "usage.key": key.key,
46
- "usage.variable": key.variable,
47
- });
51
+ export function kimiCredentials(region = DEFAULT_KIMI_REGION) {
52
+ return Object.freeze({
53
+ account: () => profile((path) => ({
54
+ path: join("~/.kimi-code", path),
55
+ home: { variable: "KIMI_CODE_HOME", path },
56
+ }), region),
57
+ "account.file": (input) => profile((path) => ({ path: join(input.value, path) }), region),
58
+ usage: key.preset,
59
+ "usage.key": key.key,
60
+ "usage.variable": key.variable,
61
+ });
62
+ }
48
63
  //# sourceMappingURL=kimi-authentication.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"kimi-authentication.js","sourceRoot":"","sources":["../../../src/adapters/agents/kimi-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,cAAc,EACd,WAAW,EACX,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAO7B,MAAM,Y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AAG,EAAE,CACZ,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACjB,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC;QAChC,IAAI,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE;KAC3C,CAAC,CAAC;IACL,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE,CACxB,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACxD,KAAK,EAAE,GAAG,CAAC,MAAM;IACjB,WAAW,EAAE,GAAG,CAAC,GAAG;IACpB,gBAAgB,EAAE,GAAG,CAAC,QAAQ;CAC/B,CAAC,CAAC","sourcesContent":["import { join, posix } from \"node:path\";\nimport type { HostCredentialPath } from \"../../domain/agent.types.ts\";\nimport { invariant } from \"../../domain/errors.ts\";\nimport {\n KIMI_LOGIN_DEADLINE_MS,\n credentialVariables,\n} from \"./authentication.constants.ts\";\nimport {\n credentialPlan,\n toolCommand,\n variableCredential,\n} from \"./authentication.ts\";\nimport type {\n CredentialInput,\n CredentialPlanner,\n CredentialStrategy,\n} from \"./authentication.types.ts\";\n\nconst profileFiles = [\n [\"credentials\", \"kimi-code.json\"],\n [\"device_id\"],\n] as const;\n\nfunction profile(\n root: (path: string) => HostCredentialPath,\n): CredentialPlanner {\n return () =>\n credentialPlan({\n host: profileFiles.map((parts) => ({\n source: root(join(...parts)),\n destination: { file: posix.join(\".kimi-code\", ...parts) },\n login: \"kimi login\",\n alternative: `\"usage\" with ${credentialVariables.kimi.usage} and a model`,\n })),\n commands: [\n toolCommand(\"kimi\", [\"login\"], { deadlineMs: KIMI_LOGIN_DEADLINE_MS }),\n ],\n });\n}\n\nfunction modelName(input: CredentialInput): string {\n const name = input.model?.name;\n invariant(\n name,\n \"Kimi Code usage authentication requires a model name on agent()\",\n );\n return name;\n}\n\nconst key = variableCredential({\n variable: credentialVariables.kimi.usage,\n bind: modelName,\n expose: (secret, input) => ({\n variables: {\n KIMI_MODEL_API_KEY: secret,\n KIMI_MODEL_PROVIDER_TYPE: \"kimi\",\n KIMI_MODEL_NAME: modelName(input),\n },\n }),\n});\n\nexport const kimiCredentials: CredentialStrategy = Object.freeze({\n account: () =>\n profile((path) => ({\n path: join(\"~/.kimi-code\", path),\n home: { variable: \"KIMI_CODE_HOME\", path },\n })),\n \"account.file\": (input) =>\n profile((path) => ({ path: join(input.value, path) })),\n usage: key.preset,\n \"usage.key\": key.key,\n \"usage.variable\": key.variable,\n});\n"]}
1
+ {"version":3,"file":"kimi-authentication.js","sourceRoot":"","sources":["../../../src/adapters/agents/kimi-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,cAAc,EACd,WAAW,EACX,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAO7B,SAAS,OAAO,CACd,IAA0C,EAC1C,MAA2C;IAE3C,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,YAAY,GAAG,CAAC,CAAC,aAAa,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,SAAS,EAAE,EAAE;QACnB,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI;YAC7B,CAAC,sBAAsB,EAAE,QAAQ,CAAC,SAAS,CAAC;YAC5C,CAAC,iBAAiB,EAAE,QAAQ,CAAC,SAAS,CAAC;YACvC,CAAC,oBAAoB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AK,EAAE,EAAE,CAAC,CAAC;QAC1B,SAAS,EAAE;YACT,kBAAkB,EAAE,MAAM;YAC1B,wBAAwB,EAAE,MAAM;YAChC,eAAe,EAAE,SAAS,CAAC,KAAK,CAAC;SAClC;KACF,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,UAAU,eAAe,CAC7B,SAA8C,mBAAmB;IAEjE,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,OAAO,EAAE,GAAG,EAAE,CACZ,OAAO,CACL,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACT,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC;YAChC,IAAI,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE;SAC3C,CAAC,EACF,MAAM,CACP;QACH,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE,CACxB,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAChE,KAAK,EAAE,GAAG,CAAC,MAAM;QACjB,WAAW,EAAE,GAAG,CAAC,GAAG;QACpB,gBAAgB,EAAE,GAAG,CAAC,QAAQ;KAC/B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { join, posix } from \"node:path\";\nimport { DEFAULT_KIMI_REGION, kimiRegions } from \"./kimi.constants.ts\";\nimport type { KimiSettings } from \"./kimi.types.ts\";\nimport type { HostCredentialPath } from \"../../domain/agent.types.ts\";\nimport { invariant } from \"../../domain/errors.ts\";\nimport {\n KIMI_LOGIN_DEADLINE_MS,\n credentialVariables,\n} from \"./authentication.constants.ts\";\nimport {\n credentialPlan,\n toolCommand,\n variableCredential,\n} from \"./authentication.ts\";\nimport type {\n CredentialInput,\n CredentialPlanner,\n CredentialStrategy,\n} from \"./authentication.types.ts\";\n\nfunction profile(\n root: (path: string) => HostCredentialPath,\n region: NonNullable<KimiSettings[\"region\"]>,\n): CredentialPlanner {\n const selected = kimiRegions[region];\n const profileFiles = [[\"credentials\", selected.credential], [\"device_id\"]];\n return (variables) => {\n for (const [name, expected] of [\n [\"KIMI_CODE_OAUTH_HOST\", selected.oauthHost],\n [\"KIMI_OAUTH_HOST\", selected.oauthHost],\n [\"KIMI_CODE_BASE_URL\", selected.baseUrl],\n ] as const)\n invariant(\n !variables[name] || variables[name]?.replace(/\\/+$/, \"\") === expected,\n `Kimi ${name} conflicts with account region \"${region}\"`,\n );\n return credentialPlan({\n variables: {\n KIMI_CODE_OAUTH_HOST: selected.oauthHost,\n KIMI_CODE_BASE_URL: selected.baseUrl,\n },\n host: profileFiles.map((parts) => ({\n source: root(join(...parts)),\n destination: { file: posix.join(\".kimi-code\", ...parts) },\n login: `kimi login --region ${region}`,\n alternative: `\"usage\" with ${credentialVariables.kimi.usage} and a model`,\n })),\n commands: [\n toolCommand(\"kimi\", [\"login\", \"--region\", region], {\n deadlineMs: KIMI_LOGIN_DEADLINE_MS,\n }),\n ],\n });\n };\n}\n\nfunction modelName(input: CredentialInput): string {\n const name = input.model?.name;\n invariant(\n name,\n \"Kimi Code usage authentication requires a model name on agent()\",\n );\n return name;\n}\n\nconst key = variableCredential({\n variable: credentialVariables.kimi.usage,\n bind: modelName,\n expose: (secret, input) => ({\n variables: {\n KIMI_MODEL_API_KEY: secret,\n KIMI_MODEL_PROVIDER_TYPE: \"kimi\",\n KIMI_MODEL_NAME: modelName(input),\n },\n }),\n});\n\nexport function kimiCredentials(\n region: NonNullable<KimiSettings[\"region\"]> = DEFAULT_KIMI_REGION,\n): CredentialStrategy {\n return Object.freeze({\n account: () =>\n profile(\n (path) => ({\n path: join(\"~/.kimi-code\", path),\n home: { variable: \"KIMI_CODE_HOME\", path },\n }),\n region,\n ),\n \"account.file\": (input) =>\n profile((path) => ({ path: join(input.value, path) }), region),\n usage: key.preset,\n \"usage.key\": key.key,\n \"usage.variable\": key.variable,\n });\n}\n"]}
@@ -1 +1,2 @@
1
- export declare function kimiDiagnostics(): readonly import("./cli-diagnostics.types.ts").AgentCliDiagnostic[];
1
+ import type { AgentCliDiagnostic } from "./cli-diagnostics.types.ts";
2
+ export declare function kimiDiagnostics(): readonly AgentCliDiagnostic[];
@@ -1,6 +1,14 @@
1
1
  import { helpDiagnostics } from "./cli-diagnostics.js";
2
2
  import { kimiRequest } from "./kimi-request.js";
3
3
  export function kimiDiagnostics() {
4
- return helpDiagnostics((input) => kimiRequest({}, input), "Usage: kimi [");
4
+ return [
5
+ ...helpDiagnostics((input) => kimiRequest({}, input), "Usage: kimi [", true),
6
+ {
7
+ mode: "fork",
8
+ usage: "Usage: kimi fork [",
9
+ options: ["--yes"],
10
+ command: { executable: "kimi", arguments: ["fork", "--help"] },
11
+ },
12
+ ];
5
13
  }
6
14
  //# sourceMappingURL=kimi-diagnostics.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"kimi-diagnostics.js","sourceRoot":"","sources":["../../../src/adapters/agents/kimi-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,eAAe;IAC7B,OAAO,eAAe,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,eAAe,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import { helpDiagnostics } from \"./cli-diagnostics.ts\";\nimport { kimiRequest } from \"./kimi-request.ts\";\n\nexport function kimiDiagnostics() {\n return helpDiagnostics((input) => kimiRequest({}, input), \"Usage: kimi [\");\n}\n"]}
1
+ {"version":3,"file":"kimi-diagnostics.js","sourceRoot":"","sources":["../../../src/adapters/agents/kimi-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,UAAU,eAAe;IAC7B,OAAO;QACL,GAAG,eAAe,CAChB,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,EACjC,eAAe,EACf,IAAI,CACL;QACD;YACE,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,oBAAoB;YAC3B,OAAO,EAAE,CAAC,OAAO,CAAC;YAClB,OAAO,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE;SAC/D;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { helpDiagnostics } from \"./cli-diagnostics.ts\";\nimport { kimiRequest } from \"./kimi-request.ts\";\nimport type { AgentCliDiagnostic } from \"./cli-diagnostics.types.ts\";\n\nexport function kimiDiagnostics(): readonly AgentCliDiagnostic[] {\n return [\n ...helpDiagnostics(\n (input) => kimiRequest({}, input),\n \"Usage: kimi [\",\n true,\n ),\n {\n mode: \"fork\",\n usage: \"Usage: kimi fork [\",\n options: [\"--yes\"],\n command: { executable: \"kimi\", arguments: [\"fork\", \"--help\"] },\n },\n ];\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { toolResult } from "./tool-result.js";
1
2
  import { decodeLine } from "./event-decoder.js";
2
3
  import { asRecord } from "./protocol.js";
3
4
  function toolInput(value) {
@@ -25,6 +26,8 @@ function assistant(event) {
25
26
  ]
26
27
  : [];
27
28
  });
29
+ if (typeof event.reasoning_content === "string" && event.reasoning_content)
30
+ tools.push({ kind: "reasoning", text: event.reasoning_content });
28
31
  return typeof event.content === "string" && event.content
29
32
  ? [{ kind: "text", text: event.content }, ...tools]
30
33
  : tools;
@@ -40,6 +43,7 @@ const meta = {
40
43
  export function kimiEvents(line) {
41
44
  return decodeLine(line, {
42
45
  assistant,
46
+ tool: (event) => toolResult(event.tool_call_id, event.name, event.content, event.is_error === true),
43
47
  meta: (event) => {
44
48
  const decode = typeof event.type === "string" && Object.hasOwn(meta, event.type)
45
49
  ? meta[event.type]
@@ -1 +1 @@
1
- {"version":3,"file":"kimi-events.js","sourceRoot":"","sources":["../../../src/adapters/agents/kimi-events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAqB;IACtC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAgB,EAAE;QAC/D,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3C,OAAO,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ;YACxC,CAAC,CAAC;gBACE;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,UAAU,CAAC,IAAI;oBACrB,KAAK,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC;oBACtC,GAAG,CAAC,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC5D;aACF;YACH,CAAC,CAAC,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO;QACvD,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC;QACnD,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC;AAED,MAAM,IAAI,GAAkB;IAC1B,qBAAqB,EAAE,CAAC,KAAK,EAAE,EAAE,CAC/B,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ;QAClC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC;QAClD,CAAC,CAAC,EAAE;IACR,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE,CAC9B,OAAO,KAAK,CAAC,aAAa,KAAK,QAAQ;QACrC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,aAAa,EAAE,CAAC;QACrD,CAAC,CAAC,EAAE;CACT,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,UAAU,CACf,IAAI,EACJ;QACE,SAAS;QACT,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;YACd,MAAM,MAAM,GACV,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;gBAC/D,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBAClB,CAAC,CAAC,SAAS,CAAC;YAChB,OAAO,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;KACF,EACD,MAAM,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentEvent } from \"../../domain/agent.types.ts\";\nimport { decodeLine } from \"./event-decoder.ts\";\nimport { asRecord } from \"./protocol.ts\";\nimport type { EventDecoders, ProtocolRecord } from \"./protocol.types.ts\";\n\nfunction toolInput(value: unknown): unknown {\n if (typeof value !== \"string\") return value;\n try {\n return JSON.parse(value);\n } catch {\n return value;\n }\n}\n\nfunction assistant(event: ProtocolRecord): AgentEvent[] {\n const calls = Array.isArray(event.tool_calls) ? event.tool_calls : [];\n const tools = calls.map(asRecord).flatMap((call): AgentEvent[] => {\n const invocation = asRecord(call.function);\n return typeof invocation.name === \"string\"\n ? [\n {\n kind: \"tool\",\n name: invocation.name,\n input: toolInput(invocation.arguments),\n ...(typeof call.id === \"string\" ? { callId: call.id } : {}),\n },\n ]\n : [];\n });\n return typeof event.content === \"string\" && event.content\n ? [{ kind: \"text\", text: event.content }, ...tools]\n : tools;\n}\n\nconst meta: EventDecoders = {\n \"session.resume_hint\": (event) =>\n typeof event.session_id === \"string\"\n ? [{ kind: \"conversation\", id: event.session_id }]\n : [],\n \"turn.step.retrying\": (event) =>\n typeof event.error_message === \"string\"\n ? [{ kind: \"warning\", message: event.error_message }]\n : [],\n};\n\nexport function kimiEvents(line: string): AgentEvent[] {\n return decodeLine(\n line,\n {\n assistant,\n meta: (event) => {\n const decode =\n typeof event.type === \"string\" && Object.hasOwn(meta, event.type)\n ? meta[event.type]\n : undefined;\n return decode?.(event) ?? [];\n },\n },\n \"role\",\n );\n}\n"]}
1
+ {"version":3,"file":"kimi-events.js","sourceRoot":"","sources":["../../../src/adapters/agents/kimi-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAAC,MAA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,GAAkB;IAC1B,qBAAqB,EAAE,CAAC,KAAK,EAAE,EAAE,CAC/B,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ;QAClC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC;QAClD,CAAC,CAAC,EAAE;IACR,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE,CAC9B,OAAO,KAAK,CAAC,aAAa,KAAK,QAAQ;QACrC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,aAAa,EAAE,CAAC;QACrD,CAAC,CAAC,EAAE;CACT,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,UAAU,CACf,IAAI,EACJ;QACE,SAAS;QACT,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACd,UAAU,CACR,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,QAAQ,KAAK,IAAI,CACxB;QACH,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;YACd,MAAM,MAAM,GACV,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;gBAC/D,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBAClB,CAAC,CAAC,SAAS,CAAC;YAChB,OAAO,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;KACF,EACD,MAAM,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { toolResult } from \"./tool-result.ts\";\nimport type { AgentEvent } from \"../../domain/agent.types.ts\";\nimport { decodeLine } from \"./event-decoder.ts\";\nimport { asRecord } from \"./protocol.ts\";\nimport type { EventDecoders, ProtocolRecord } from \"./protocol.types.ts\";\n\nfunction toolInput(value: unknown): unknown {\n if (typeof value !== \"string\") return value;\n try {\n return JSON.parse(value);\n } catch {\n return value;\n }\n}\n\nfunction assistant(event: ProtocolRecord): AgentEvent[] {\n const calls = Array.isArray(event.tool_calls) ? event.tool_calls : [];\n const tools = calls.map(asRecord).flatMap((call): AgentEvent[] => {\n const invocation = asRecord(call.function);\n return typeof invocation.name === \"string\"\n ? [\n {\n kind: \"tool\",\n name: invocation.name,\n input: toolInput(invocation.arguments),\n ...(typeof call.id === \"string\" ? { callId: call.id } : {}),\n },\n ]\n : [];\n });\n if (typeof event.reasoning_content === \"string\" && event.reasoning_content)\n tools.push({ kind: \"reasoning\", text: event.reasoning_content });\n return typeof event.content === \"string\" && event.content\n ? [{ kind: \"text\", text: event.content }, ...tools]\n : tools;\n}\n\nconst meta: EventDecoders = {\n \"session.resume_hint\": (event) =>\n typeof event.session_id === \"string\"\n ? [{ kind: \"conversation\", id: event.session_id }]\n : [],\n \"turn.step.retrying\": (event) =>\n typeof event.error_message === \"string\"\n ? [{ kind: \"warning\", message: event.error_message }]\n : [],\n};\n\nexport function kimiEvents(line: string): AgentEvent[] {\n return decodeLine(\n line,\n {\n assistant,\n tool: (event) =>\n toolResult(\n event.tool_call_id,\n event.name,\n event.content,\n event.is_error === true,\n ),\n meta: (event) => {\n const decode =\n typeof event.type === \"string\" && Object.hasOwn(meta, event.type)\n ? meta[event.type]\n : undefined;\n return decode?.(event) ?? [];\n },\n },\n \"role\",\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type { AgentAdapter } from "../../domain/agent.types.ts";
2
+ export declare const forkKimi: NonNullable<AgentAdapter["fork"]>;
@@ -0,0 +1,11 @@
1
+ import { invariant } from "../../domain/errors.js";
2
+ import { validId } from "../../infrastructure/conversations/identity.js";
3
+ import { requireSuccess } from "../../infrastructure/process.js";
4
+ export const forkKimi = async (id, invoke) => {
5
+ validId(id);
6
+ const result = await requireSuccess({ executable: "kimi", arguments: ["fork", id, "--yes"] }, invoke);
7
+ const child = /^Forked to ([A-Za-z0-9_-]+)(?: |$)/m.exec(result.stdout)?.[1];
8
+ invariant(child && child !== id, "Kimi fork did not return a distinct conversation identifier");
9
+ return child;
10
+ };
11
+ //# sourceMappingURL=kimi-fork.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kimi-fork.js","sourceRoot":"","sources":["../../../src/adapters/agents/kimi-fork.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,gDAAgD,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,MAAM,CAAC,MAAM,QAAQ,GAAsC,KAAK,EAC9D,EAAE,EACF,MAAM,EACN,EAAE;IACF,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EACxD,MAAM,CACP,CAAC;IACF,MAAM,KAAK,GAAG,qCAAqC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7E,SAAS,CACP,KAAK,IAAI,KAAK,KAAK,EAAE,EACrB,6DAA6D,CAC9D,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import type { AgentAdapter } from \"../../domain/agent.types.ts\";\nimport { invariant } from \"../../domain/errors.ts\";\nimport { validId } from \"../../infrastructure/conversations/identity.ts\";\nimport { requireSuccess } from \"../../infrastructure/process.ts\";\n\nexport const forkKimi: NonNullable<AgentAdapter[\"fork\"]> = async (\n id,\n invoke,\n) => {\n validId(id);\n const result = await requireSuccess(\n { executable: \"kimi\", arguments: [\"fork\", id, \"--yes\"] },\n invoke,\n );\n const child = /^Forked to ([A-Za-z0-9_-]+)(?: |$)/m.exec(result.stdout)?.[1];\n invariant(\n child && child !== id,\n \"Kimi fork did not return a distinct conversation identifier\",\n );\n return child;\n};\n"]}
@@ -1,3 +1,4 @@
1
+ import { validId } from "../../infrastructure/conversations/identity.js";
1
2
  import { authenticationForm } from "../../domain/authentication.js";
2
3
  import { invariant } from "../../domain/errors.js";
3
4
  function modelOption(settings) {
@@ -8,8 +9,12 @@ function modelOption(settings) {
8
9
  return usage ? [] : ["--model", settings.model.name];
9
10
  }
10
11
  export function kimiRequest(settings, input) {
11
- invariant(!input.continuation, "Kimi Code does not support continuation or fork in Outpost");
12
+ invariant(!input.continuation?.fork, "Kimi Code requires native fork preparation in Outpost");
12
13
  const args = [...modelOption(settings)];
14
+ if (input.continuation) {
15
+ validId(input.continuation.id);
16
+ args.push("--session", input.continuation.id);
17
+ }
13
18
  if (input.interactive) {
14
19
  invariant(input.text === undefined, "Kimi Code starts interactive sessions without an initial prompt");
15
20
  return { executable: "kimi", arguments: args, interactive: true };
@@ -1 +1 @@
1
- {"version":3,"file":"kimi-request.js","sourceRoot":"","sources":["../../../src/adapters/agents/kimi-request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInD,SAAS,WAAW,CAAC,QAA6B;IAChD,IAAI,CAAC,QAAQ,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAC/B,MAAM,KAAK,GACT,QAAQ,CAAC,cAAc,KAAK,SAAS;QACrC,kBAAkB,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACvE,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,QAA6B,EAC7B,KAAiB;IAEjB,SAAS,CACP,CAAC,KAAK,CAAC,YAAY,EACnB,4DAA4D,CAC7D,CAAC;IACF,MAAM,IAAI,GAAG,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QACtB,SAAS,CACP,KAAK,CAAC,IAAI,KAAK,SAAS,EACxB,iEAAiE,CAClE,CAAC;QACF,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IACpE,CAAC;IACD,OAAO;QACL,UAAU,EAAE,MAAM;QAClB,SAAS,EAAE;YACT,GAAG,IAAI;YACP,UAAU;YACV,KAAK,CAAC,IAAI,IAAI,EAAE;YAChB,iBAAiB;YACjB,aAAa;SACd;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentInput } from \"../../domain/agent.types.ts\";\nimport { authenticationForm } from \"../../domain/authentication.ts\";\nimport type { Command } from \"../../domain/command.types.ts\";\nimport { invariant } from \"../../domain/errors.ts\";\nimport type { KimiSettings } from \"./kimi.types.ts\";\nimport type { Bound } from \"./settings.types.ts\";\n\nfunction modelOption(settings: Bound<KimiSettings>): readonly string[] {\n if (!settings.model) return [];\n const usage =\n settings.authentication !== undefined &&\n authenticationForm(settings.authentication).form.startsWith(\"usage\");\n return usage ? [] : [\"--model\", settings.model.name];\n}\n\nexport function kimiRequest(\n settings: Bound<KimiSettings>,\n input: AgentInput,\n): Command {\n invariant(\n !input.continuation,\n \"Kimi Code does not support continuation or fork in Outpost\",\n );\n const args = [...modelOption(settings)];\n if (input.interactive) {\n invariant(\n input.text === undefined,\n \"Kimi Code starts interactive sessions without an initial prompt\",\n );\n return { executable: \"kimi\", arguments: args, interactive: true };\n }\n return {\n executable: \"kimi\",\n arguments: [\n ...args,\n \"--prompt\",\n input.text ?? \"\",\n \"--output-format\",\n \"stream-json\",\n ],\n };\n}\n"]}
1
+ {"version":3,"file":"kimi-request.js","sourceRoot":"","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M;QAClB,SAAS,EAAE;YACT,GAAG,IAAI;YACP,UAAU;YACV,KAAK,CAAC,IAAI,IAAI,EAAE;YAChB,iBAAiB;YACjB,aAAa;SACd;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { validId } from \"../../infrastructure/conversations/identity.ts\";\nimport type { AgentInput } from \"../../domain/agent.types.ts\";\nimport { authenticationForm } from \"../../domain/authentication.ts\";\nimport type { Command } from \"../../domain/command.types.ts\";\nimport { invariant } from \"../../domain/errors.ts\";\nimport type { KimiSettings } from \"./kimi.types.ts\";\nimport type { Bound } from \"./settings.types.ts\";\n\nfunction modelOption(settings: Bound<KimiSettings>): readonly string[] {\n if (!settings.model) return [];\n const usage =\n settings.authentication !== undefined &&\n authenticationForm(settings.authentication).form.startsWith(\"usage\");\n return usage ? [] : [\"--model\", settings.model.name];\n}\n\nexport function kimiRequest(\n settings: Bound<KimiSettings>,\n input: AgentInput,\n): Command {\n invariant(\n !input.continuation?.fork,\n \"Kimi Code requires native fork preparation in Outpost\",\n );\n const args = [...modelOption(settings)];\n if (input.continuation) {\n validId(input.continuation.id);\n args.push(\"--session\", input.continuation.id);\n }\n if (input.interactive) {\n invariant(\n input.text === undefined,\n \"Kimi Code starts interactive sessions without an initial prompt\",\n );\n return { executable: \"kimi\", arguments: args, interactive: true };\n }\n return {\n executable: \"kimi\",\n arguments: [\n ...args,\n \"--prompt\",\n input.text ?? \"\",\n \"--output-format\",\n \"stream-json\",\n ],\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type { Usage } from "../../domain/agent.types.ts";
2
+ export declare function kimiUsage(value: unknown): Usage;
@@ -0,0 +1,7 @@
1
+ import { asRecord } from "./protocol.js";
2
+ import { usageCounts } from "./session-usage.js";
3
+ export function kimiUsage(value) {
4
+ const usage = asRecord(value);
5
+ return usageCounts(usage.inputOther, usage.output, usage.inputCacheRead, usage.inputCacheCreation);
6
+ }
7
+ //# sourceMappingURL=kimi-usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kimi-usage.js","sourceRoot":"","sources":["../../../src/adapters/agents/kimi-usage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,WAAW,CAChB,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,cAAc,EACpB,KAAK,CAAC,kBAAkB,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import type { Usage } from \"../../domain/agent.types.ts\";\nimport { asRecord } from \"./protocol.ts\";\nimport { usageCounts } from \"./session-usage.ts\";\n\nexport function kimiUsage(value: unknown): Usage {\n const usage = asRecord(value);\n return usageCounts(\n usage.inputOther,\n usage.output,\n usage.inputCacheRead,\n usage.inputCacheCreation,\n );\n}\n"]}
@@ -0,0 +1,13 @@
1
+ export declare const DEFAULT_KIMI_REGION = "global";
2
+ export declare const kimiRegions: Readonly<{
3
+ readonly "mainland-cn": {
4
+ readonly credential: "kimi-code.json";
5
+ readonly oauthHost: "https://auth.kimi.com";
6
+ readonly baseUrl: "https://api.kimi.com/coding/v1";
7
+ };
8
+ readonly global: {
9
+ readonly credential: "kimi-code-env-0e4f99c69cc27850.json";
10
+ readonly oauthHost: "https://auth.kimi.ai";
11
+ readonly baseUrl: "https://api.kimi.ai/coding/v1";
12
+ };
13
+ }>;
@@ -0,0 +1,14 @@
1
+ export const DEFAULT_KIMI_REGION = "global";
2
+ export const kimiRegions = Object.freeze({
3
+ "mainland-cn": {
4
+ credential: "kimi-code.json",
5
+ oauthHost: "https://auth.kimi.com",
6
+ baseUrl: "https://api.kimi.com/coding/v1",
7
+ },
8
+ global: {
9
+ credential: "kimi-code-env-0e4f99c69cc27850.json",
10
+ oauthHost: "https://auth.kimi.ai",
11
+ baseUrl: "https://api.kimi.ai/coding/v1",
12
+ },
13
+ });
14
+ //# sourceMappingURL=kimi.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kimi.constants.js","sourceRoot":"","sources":["../../../src/adapters/agents/kimi.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AAE5C,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,aAAa,EAAE;QACb,UAAU,EAAE,gBAAgB;QAC5B,SAAS,EAAE,uBAAuB;QAClC,OAAO,EAAE,gCAAgC;KAC1C;IACD,MAAM,EAAE;QACN,UAAU,EAAE,qCAAqC;QACjD,SAAS,EAAE,sBAAsB;QACjC,OAAO,EAAE,+BAA+B;KACzC;CACO,CAAC,CAAC","sourcesContent":["export const DEFAULT_KIMI_REGION = \"global\";\n\nexport const kimiRegions = Object.freeze({\n \"mainland-cn\": {\n credential: \"kimi-code.json\",\n oauthHost: \"https://auth.kimi.com\",\n baseUrl: \"https://api.kimi.com/coding/v1\",\n },\n global: {\n credential: \"kimi-code-env-0e4f99c69cc27850.json\",\n oauthHost: \"https://auth.kimi.ai\",\n baseUrl: \"https://api.kimi.ai/coding/v1\",\n },\n} as const);\n"]}