@botiverse/oar 0.121.0 → 0.122.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 (312) hide show
  1. package/README.md +8 -6
  2. package/dist/community/cybion/client.d.ts +24 -0
  3. package/dist/community/cybion/client.d.ts.map +1 -0
  4. package/dist/community/cybion/client.js +42 -0
  5. package/dist/community/cybion/client.js.map +1 -0
  6. package/dist/community/cybion/index.d.ts +14 -0
  7. package/dist/community/cybion/index.d.ts.map +1 -0
  8. package/dist/community/cybion/index.js +30 -0
  9. package/dist/community/cybion/index.js.map +1 -0
  10. package/dist/community/cybion/projection.d.ts +7 -0
  11. package/dist/community/cybion/projection.d.ts.map +1 -0
  12. package/dist/community/cybion/projection.js +100 -0
  13. package/dist/community/cybion/projection.js.map +1 -0
  14. package/dist/community/cybion/refusal.d.ts +19 -0
  15. package/dist/community/cybion/refusal.d.ts.map +1 -0
  16. package/dist/community/cybion/refusal.js +23 -0
  17. package/dist/community/cybion/refusal.js.map +1 -0
  18. package/dist/community/cybion/refused-options.d.ts +4 -0
  19. package/dist/community/cybion/refused-options.d.ts.map +1 -0
  20. package/dist/community/cybion/refused-options.js +17 -0
  21. package/dist/community/cybion/refused-options.js.map +1 -0
  22. package/dist/community/cybion/session.d.ts +8 -0
  23. package/dist/community/cybion/session.d.ts.map +1 -0
  24. package/dist/community/cybion/session.js +283 -0
  25. package/dist/community/cybion/session.js.map +1 -0
  26. package/dist/community/cybion/thread.d.ts +75 -0
  27. package/dist/community/cybion/thread.d.ts.map +1 -0
  28. package/dist/community/cybion/thread.js +192 -0
  29. package/dist/community/cybion/thread.js.map +1 -0
  30. package/dist/community/cybion/tracker-facts.d.ts +38 -0
  31. package/dist/community/cybion/tracker-facts.d.ts.map +1 -0
  32. package/dist/community/cybion/tracker-facts.js +44 -0
  33. package/dist/community/cybion/tracker-facts.js.map +1 -0
  34. package/dist/community/cybion/tracker.d.ts +76 -0
  35. package/dist/community/cybion/tracker.d.ts.map +1 -0
  36. package/dist/community/cybion/tracker.js +244 -0
  37. package/dist/community/cybion/tracker.js.map +1 -0
  38. package/dist/community/index.d.ts +1 -0
  39. package/dist/community/index.d.ts.map +1 -1
  40. package/dist/community/index.js +1 -0
  41. package/dist/community/index.js.map +1 -1
  42. package/dist/contracts/account-usage.d.ts +3 -1
  43. package/dist/contracts/account-usage.d.ts.map +1 -1
  44. package/dist/contracts/index.d.ts +3 -3
  45. package/dist/contracts/index.d.ts.map +1 -1
  46. package/dist/contracts/index.js +1 -1
  47. package/dist/contracts/index.js.map +1 -1
  48. package/dist/contracts/login.d.ts +6 -0
  49. package/dist/contracts/login.d.ts.map +1 -1
  50. package/dist/contracts/orientation.d.ts +5 -0
  51. package/dist/contracts/orientation.d.ts.map +1 -1
  52. package/dist/contracts/records.d.ts +1 -1
  53. package/dist/contracts/records.d.ts.map +1 -1
  54. package/dist/contracts/runtime.d.ts +70 -3
  55. package/dist/contracts/runtime.d.ts.map +1 -1
  56. package/dist/contracts/runtime.js +25 -0
  57. package/dist/contracts/runtime.js.map +1 -1
  58. package/dist/contracts/session-options.d.ts +10 -10
  59. package/dist/platforms.d.ts +25 -0
  60. package/dist/platforms.d.ts.map +1 -0
  61. package/dist/platforms.js +16 -0
  62. package/dist/platforms.js.map +1 -0
  63. package/dist/runtimes/antigravity/index.d.ts +4 -1
  64. package/dist/runtimes/antigravity/index.d.ts.map +1 -1
  65. package/dist/runtimes/antigravity/index.js +2 -1
  66. package/dist/runtimes/antigravity/index.js.map +1 -1
  67. package/dist/runtimes/antigravity/skill-files.d.ts.map +1 -1
  68. package/dist/runtimes/antigravity/skill-files.js +44 -18
  69. package/dist/runtimes/antigravity/skill-files.js.map +1 -1
  70. package/dist/runtimes/antigravity/skill-manifests.d.ts +2 -0
  71. package/dist/runtimes/antigravity/skill-manifests.d.ts.map +1 -1
  72. package/dist/runtimes/antigravity/skill-manifests.js +11 -16
  73. package/dist/runtimes/antigravity/skill-manifests.js.map +1 -1
  74. package/dist/runtimes/claude/account-usage.d.ts.map +1 -1
  75. package/dist/runtimes/claude/account-usage.js +9 -7
  76. package/dist/runtimes/claude/account-usage.js.map +1 -1
  77. package/dist/runtimes/claude/auth-status.d.ts.map +1 -1
  78. package/dist/runtimes/claude/auth-status.js +6 -1
  79. package/dist/runtimes/claude/auth-status.js.map +1 -1
  80. package/dist/runtimes/claude/fork-identity.d.ts +2 -2
  81. package/dist/runtimes/claude/fork-identity.d.ts.map +1 -1
  82. package/dist/runtimes/claude/fork-identity.js +21 -16
  83. package/dist/runtimes/claude/fork-identity.js.map +1 -1
  84. package/dist/runtimes/claude/global-config.d.ts +3 -0
  85. package/dist/runtimes/claude/global-config.d.ts.map +1 -0
  86. package/dist/runtimes/claude/global-config.js +36 -0
  87. package/dist/runtimes/claude/global-config.js.map +1 -0
  88. package/dist/runtimes/claude/index.d.ts +4 -1
  89. package/dist/runtimes/claude/index.d.ts.map +1 -1
  90. package/dist/runtimes/claude/index.js +2 -1
  91. package/dist/runtimes/claude/index.js.map +1 -1
  92. package/dist/runtimes/claude/last-account.d.ts +4 -0
  93. package/dist/runtimes/claude/last-account.d.ts.map +1 -0
  94. package/dist/runtimes/claude/last-account.js +15 -0
  95. package/dist/runtimes/claude/last-account.js.map +1 -0
  96. package/dist/runtimes/claude/launch.js +3 -3
  97. package/dist/runtimes/claude/launch.js.map +1 -1
  98. package/dist/runtimes/claude/limit-reset/driver.d.ts.map +1 -1
  99. package/dist/runtimes/claude/limit-reset/driver.js +6 -34
  100. package/dist/runtimes/claude/limit-reset/driver.js.map +1 -1
  101. package/dist/runtimes/claude/open-settings.d.ts +2 -2
  102. package/dist/runtimes/claude/open-settings.d.ts.map +1 -1
  103. package/dist/runtimes/claude/open-settings.js +13 -6
  104. package/dist/runtimes/claude/open-settings.js.map +1 -1
  105. package/dist/runtimes/claude/projection.d.ts.map +1 -1
  106. package/dist/runtimes/claude/projection.js +6 -1
  107. package/dist/runtimes/claude/projection.js.map +1 -1
  108. package/dist/runtimes/claude/session.d.ts.map +1 -1
  109. package/dist/runtimes/claude/session.js +4 -3
  110. package/dist/runtimes/claude/session.js.map +1 -1
  111. package/dist/runtimes/codebuddy/index.d.ts +4 -1
  112. package/dist/runtimes/codebuddy/index.d.ts.map +1 -1
  113. package/dist/runtimes/codebuddy/index.js +2 -1
  114. package/dist/runtimes/codebuddy/index.js.map +1 -1
  115. package/dist/runtimes/codex/index.d.ts +4 -1
  116. package/dist/runtimes/codex/index.d.ts.map +1 -1
  117. package/dist/runtimes/codex/index.js +2 -1
  118. package/dist/runtimes/codex/index.js.map +1 -1
  119. package/dist/runtimes/cursor/index.d.ts.map +1 -1
  120. package/dist/runtimes/cursor/index.js +0 -1
  121. package/dist/runtimes/cursor/index.js.map +1 -1
  122. package/dist/runtimes/devin/index.d.ts +3 -1
  123. package/dist/runtimes/devin/index.d.ts.map +1 -1
  124. package/dist/runtimes/dsh/bridge-controls.d.ts +3 -0
  125. package/dist/runtimes/dsh/bridge-controls.d.ts.map +1 -0
  126. package/dist/runtimes/dsh/bridge-controls.js +67 -0
  127. package/dist/runtimes/dsh/bridge-controls.js.map +1 -0
  128. package/dist/runtimes/dsh/bridge-input.d.ts +3 -0
  129. package/dist/runtimes/dsh/bridge-input.d.ts.map +1 -0
  130. package/dist/runtimes/dsh/bridge-input.js +51 -0
  131. package/dist/runtimes/dsh/bridge-input.js.map +1 -0
  132. package/dist/runtimes/dsh/bridge.d.ts.map +1 -1
  133. package/dist/runtimes/dsh/bridge.js +24 -52
  134. package/dist/runtimes/dsh/bridge.js.map +1 -1
  135. package/dist/runtimes/dsh/compaction.d.ts +5 -0
  136. package/dist/runtimes/dsh/compaction.d.ts.map +1 -0
  137. package/dist/runtimes/dsh/compaction.js +73 -0
  138. package/dist/runtimes/dsh/compaction.js.map +1 -0
  139. package/dist/runtimes/dsh/control.d.ts +1 -1
  140. package/dist/runtimes/dsh/control.d.ts.map +1 -1
  141. package/dist/runtimes/dsh/control.js +1 -1
  142. package/dist/runtimes/dsh/control.js.map +1 -1
  143. package/dist/runtimes/dsh/index.d.ts +39 -3
  144. package/dist/runtimes/dsh/index.d.ts.map +1 -1
  145. package/dist/runtimes/dsh/index.js +13 -2
  146. package/dist/runtimes/dsh/index.js.map +1 -1
  147. package/dist/runtimes/dsh/jobs.d.ts +3 -1
  148. package/dist/runtimes/dsh/jobs.d.ts.map +1 -1
  149. package/dist/runtimes/dsh/jobs.js +20 -1
  150. package/dist/runtimes/dsh/jobs.js.map +1 -1
  151. package/dist/runtimes/dsh/launch.d.ts +0 -2
  152. package/dist/runtimes/dsh/launch.d.ts.map +1 -1
  153. package/dist/runtimes/dsh/launch.js +1 -6
  154. package/dist/runtimes/dsh/launch.js.map +1 -1
  155. package/dist/runtimes/dsh/options.d.ts +2 -0
  156. package/dist/runtimes/dsh/options.d.ts.map +1 -1
  157. package/dist/runtimes/dsh/options.js +11 -1
  158. package/dist/runtimes/dsh/options.js.map +1 -1
  159. package/dist/runtimes/dsh/projection.d.ts.map +1 -1
  160. package/dist/runtimes/dsh/projection.js +6 -1
  161. package/dist/runtimes/dsh/projection.js.map +1 -1
  162. package/dist/runtimes/dsh/session.d.ts.map +1 -1
  163. package/dist/runtimes/dsh/session.js +37 -11
  164. package/dist/runtimes/dsh/session.js.map +1 -1
  165. package/dist/runtimes/dsh/version.d.ts +1 -2
  166. package/dist/runtimes/dsh/version.d.ts.map +1 -1
  167. package/dist/runtimes/dsh/version.js +3 -46
  168. package/dist/runtimes/dsh/version.js.map +1 -1
  169. package/dist/runtimes/factory/compaction.d.ts +1 -1
  170. package/dist/runtimes/factory/compaction.d.ts.map +1 -1
  171. package/dist/runtimes/factory/compaction.js +35 -51
  172. package/dist/runtimes/factory/compaction.js.map +1 -1
  173. package/dist/runtimes/factory/index.d.ts +4 -1
  174. package/dist/runtimes/factory/index.d.ts.map +1 -1
  175. package/dist/runtimes/factory/index.js +2 -1
  176. package/dist/runtimes/factory/index.js.map +1 -1
  177. package/dist/runtimes/factory/session.d.ts.map +1 -1
  178. package/dist/runtimes/factory/session.js +26 -20
  179. package/dist/runtimes/factory/session.js.map +1 -1
  180. package/dist/runtimes/grok/account-info.d.ts +11 -0
  181. package/dist/runtimes/grok/account-info.d.ts.map +1 -0
  182. package/dist/runtimes/grok/account-info.js +60 -0
  183. package/dist/runtimes/grok/account-info.js.map +1 -0
  184. package/dist/runtimes/grok/account-usage.d.ts +0 -2
  185. package/dist/runtimes/grok/account-usage.d.ts.map +1 -1
  186. package/dist/runtimes/grok/account-usage.js +30 -48
  187. package/dist/runtimes/grok/account-usage.js.map +1 -1
  188. package/dist/runtimes/grok/auth.d.ts.map +1 -1
  189. package/dist/runtimes/grok/auth.js +9 -2
  190. package/dist/runtimes/grok/auth.js.map +1 -1
  191. package/dist/runtimes/grok/index.d.ts +4 -1
  192. package/dist/runtimes/grok/index.d.ts.map +1 -1
  193. package/dist/runtimes/grok/index.js +2 -1
  194. package/dist/runtimes/grok/index.js.map +1 -1
  195. package/dist/runtimes/kimi/index.d.ts +4 -1
  196. package/dist/runtimes/kimi/index.d.ts.map +1 -1
  197. package/dist/runtimes/kimi/index.js +2 -1
  198. package/dist/runtimes/kimi/index.js.map +1 -1
  199. package/dist/runtimes/opencode/index.d.ts +7 -6
  200. package/dist/runtimes/opencode/index.d.ts.map +1 -1
  201. package/dist/runtimes/opencode/index.js +6 -5
  202. package/dist/runtimes/opencode/index.js.map +1 -1
  203. package/dist/runtimes/opencode/options.d.ts +5 -1
  204. package/dist/runtimes/opencode/options.d.ts.map +1 -1
  205. package/dist/runtimes/opencode/options.js +34 -1
  206. package/dist/runtimes/opencode/options.js.map +1 -1
  207. package/dist/runtimes/opencode/prompt-config-v2.d.ts +15 -0
  208. package/dist/runtimes/opencode/prompt-config-v2.d.ts.map +1 -0
  209. package/dist/runtimes/opencode/prompt-config-v2.js +75 -0
  210. package/dist/runtimes/opencode/prompt-config-v2.js.map +1 -0
  211. package/dist/runtimes/opencode/prompt-config.d.ts +12 -0
  212. package/dist/runtimes/opencode/prompt-config.d.ts.map +1 -1
  213. package/dist/runtimes/opencode/prompt-config.js +32 -19
  214. package/dist/runtimes/opencode/prompt-config.js.map +1 -1
  215. package/dist/runtimes/opencode/retry.d.ts +5 -0
  216. package/dist/runtimes/opencode/retry.d.ts.map +1 -0
  217. package/dist/runtimes/opencode/retry.js +20 -0
  218. package/dist/runtimes/opencode/retry.js.map +1 -0
  219. package/dist/runtimes/opencode/session.d.ts +1 -0
  220. package/dist/runtimes/opencode/session.d.ts.map +1 -1
  221. package/dist/runtimes/opencode/session.js +31 -8
  222. package/dist/runtimes/opencode/session.js.map +1 -1
  223. package/dist/runtimes/opencode/shared-session.d.ts.map +1 -1
  224. package/dist/runtimes/opencode/shared-session.js +7 -2
  225. package/dist/runtimes/opencode/shared-session.js.map +1 -1
  226. package/dist/runtimes/opencode/token-usage.d.ts +5 -0
  227. package/dist/runtimes/opencode/token-usage.d.ts.map +1 -0
  228. package/dist/runtimes/opencode/token-usage.js +31 -0
  229. package/dist/runtimes/opencode/token-usage.js.map +1 -0
  230. package/dist/runtimes/opencode/upgrade.d.ts +4 -0
  231. package/dist/runtimes/opencode/upgrade.d.ts.map +1 -0
  232. package/dist/runtimes/opencode/upgrade.js +21 -0
  233. package/dist/runtimes/opencode/upgrade.js.map +1 -0
  234. package/dist/runtimes/pi/index.d.ts.map +1 -1
  235. package/dist/runtimes/pi/index.js +2 -1
  236. package/dist/runtimes/pi/index.js.map +1 -1
  237. package/dist/runtimes/pi/inventory.d.ts.map +1 -1
  238. package/dist/runtimes/pi/inventory.js +5 -2
  239. package/dist/runtimes/pi/inventory.js.map +1 -1
  240. package/dist/runtimes/pi/rpc/open.d.ts.map +1 -1
  241. package/dist/runtimes/pi/rpc/open.js +1 -0
  242. package/dist/runtimes/pi/rpc/open.js.map +1 -1
  243. package/dist/runtimes/pi-durable/index.d.ts.map +1 -1
  244. package/dist/runtimes/pi-durable/index.js +2 -1
  245. package/dist/runtimes/pi-durable/index.js.map +1 -1
  246. package/dist/runtimes/qoder/index.d.ts +4 -1
  247. package/dist/runtimes/qoder/index.d.ts.map +1 -1
  248. package/dist/runtimes/qoder/index.js +2 -1
  249. package/dist/runtimes/qoder/index.js.map +1 -1
  250. package/dist/runtimes/qoder/launch.js +1 -1
  251. package/dist/runtimes/qoder/launch.js.map +1 -1
  252. package/dist/runtimes/qoder/projection.d.ts.map +1 -1
  253. package/dist/runtimes/qoder/projection.js +2 -1
  254. package/dist/runtimes/qoder/projection.js.map +1 -1
  255. package/dist/runtimes/qwen/index.d.ts +4 -1
  256. package/dist/runtimes/qwen/index.d.ts.map +1 -1
  257. package/dist/runtimes/qwen/index.js +2 -1
  258. package/dist/runtimes/qwen/index.js.map +1 -1
  259. package/dist/runtimes/qwen/launch.js +1 -1
  260. package/dist/runtimes/qwen/launch.js.map +1 -1
  261. package/dist/shared/acp/profile.d.ts +5 -3
  262. package/dist/shared/acp/profile.d.ts.map +1 -1
  263. package/dist/shared/acp/profile.js +34 -17
  264. package/dist/shared/acp/profile.js.map +1 -1
  265. package/dist/shared/acp/records.js +9 -9
  266. package/dist/shared/acp/records.js.map +1 -1
  267. package/dist/shared/acp/session.d.ts +3 -2
  268. package/dist/shared/acp/session.d.ts.map +1 -1
  269. package/dist/shared/acp/session.js +3 -3
  270. package/dist/shared/acp/session.js.map +1 -1
  271. package/dist/shared/acp/shared-session.d.ts.map +1 -1
  272. package/dist/shared/acp/shared-session.js +8 -2
  273. package/dist/shared/acp/shared-session.js.map +1 -1
  274. package/dist/shared/acp/token-usage.d.ts +1 -1
  275. package/dist/shared/acp/token-usage.d.ts.map +1 -1
  276. package/dist/shared/acp/token-usage.js +2 -2
  277. package/dist/shared/acp/token-usage.js.map +1 -1
  278. package/dist/shared/acp/turn-terminals.d.ts.map +1 -1
  279. package/dist/shared/acp/turn-terminals.js +59 -48
  280. package/dist/shared/acp/turn-terminals.js.map +1 -1
  281. package/dist/shared/orientation/index.d.ts.map +1 -1
  282. package/dist/shared/orientation/index.js +7 -2
  283. package/dist/shared/orientation/index.js.map +1 -1
  284. package/dist/shared/process-session.d.ts +2 -1
  285. package/dist/shared/process-session.d.ts.map +1 -1
  286. package/dist/shared/process-session.js +1 -2
  287. package/dist/shared/process-session.js.map +1 -1
  288. package/dist/shared/semver.d.ts +10 -0
  289. package/dist/shared/semver.d.ts.map +1 -0
  290. package/dist/shared/semver.js +46 -0
  291. package/dist/shared/semver.js.map +1 -0
  292. package/dist/shared/session-options.d.ts +6 -0
  293. package/dist/shared/session-options.d.ts.map +1 -1
  294. package/dist/shared/session-options.js +15 -0
  295. package/dist/shared/session-options.js.map +1 -1
  296. package/dist/shared/stream-json/profile.d.ts +2 -0
  297. package/dist/shared/stream-json/profile.d.ts.map +1 -1
  298. package/dist/shared/stream-json/projection.d.ts.map +1 -1
  299. package/dist/shared/stream-json/projection.js +30 -2
  300. package/dist/shared/stream-json/projection.js.map +1 -1
  301. package/dist/shared/stream-json/session.d.ts.map +1 -1
  302. package/dist/shared/stream-json/session.js +1 -0
  303. package/dist/shared/stream-json/session.js.map +1 -1
  304. package/dist/shared/stream-json/state.d.ts +2 -0
  305. package/dist/shared/stream-json/state.d.ts.map +1 -1
  306. package/dist/shared/stream-json/state.js +1 -0
  307. package/dist/shared/stream-json/state.js.map +1 -1
  308. package/dist/shared/update.d.ts +2 -0
  309. package/dist/shared/update.d.ts.map +1 -1
  310. package/dist/shared/update.js +6 -2
  311. package/dist/shared/update.js.map +1 -1
  312. package/package.json +1 -1
@@ -0,0 +1,283 @@
1
+ import { withdrawControl } from "../../shared/held-input.js";
2
+ import { inputImagesRefusal, withInputImages } from "../../shared/input-images.js";
3
+ import { sealSession } from "../../shared/seal-session.js";
4
+ import { createSessionKernel } from "../../shared/session-kernel.js";
5
+ import { refuseSessionOptions } from "../../shared/session-options.js";
6
+ import { cybionRefusedSessionOptions } from "./refused-options.js";
7
+ import { acceptedRecordOf, answeredStatusOf, cancelThread, lastRecordOf, openThread, refusalOf, submitInput } from "./thread.js";
8
+ import { createThreadTracker } from "./tracker.js";
9
+ /*
10
+ * One OAR session is one Cybion Thread, driven through the Agent API
11
+ * (`/v1/threads`; docs/runtimes/cybion.md):
12
+ *
13
+ * - open: `POST /v1/threads` creates an empty Thread (resume: `GET
14
+ * /v1/threads/{id}`), so Session.id is the Thread id and a session opened
15
+ * later with `resume` is the same conversation.
16
+ * - prompt: `POST /v1/threads/{id}/inputs`, then tracker.ts follows the turn.
17
+ * - steer: the same route while the turn runs. Cybion cancels what is in flight
18
+ * (a tool call, an inference request) and keeps the Thread `running` with the
19
+ * input appended to the same turn, so that turn still ends once — no
20
+ * `follow()` here, or the turn would be replaced instead of continued.
21
+ * - queue: held here with `queued: "adapter"`; at dispatch it records a prompt
22
+ * request carrying the held input's identity, as the record-stream spec
23
+ * requires, so a held input starts a turn like any other and no prompt
24
+ * overtakes it (`docs/spec/record-stream.md`, adapter-held queue records).
25
+ * - abort: `POST /api/threads/{id}/cancel`, the route Cybion's own UI uses: an
26
+ * API key authenticates on that router too, and Cybion answers the stopped
27
+ * Thread. The turn then ends through the Thread's `stopped` status, and an
28
+ * answer that is not `stopped` is read as a turn that had already ended.
29
+ * - dispose: the Thread outlives the session by design (it is resumable), so
30
+ * releasing it records the release and stops nothing on Cybion's side.
31
+ */
32
+ /** How long dispose waits for the running turn to end by itself. */
33
+ const DISPOSE_SETTLE_MS = 3000;
34
+ /**
35
+ * A session over `client`. The transport is injected so a test drives a
36
+ * scripted deployment without a network.
37
+ */
38
+ export function cybionSessionWith(client) {
39
+ return async (installation, options) => {
40
+ if (installation.via !== "bundled") {
41
+ throw new Error("The cybion session adapter needs its own bundled installation");
42
+ }
43
+ refuseSessionOptions(cybionRefusedSessionOptions, options);
44
+ const thread = await openThread(client, options);
45
+ const kernel = createSessionKernel(thread.id);
46
+ // The Thread's own report, read at open rather than echoed from the request.
47
+ const opening = [
48
+ ...(thread.model === null ? [] : [{ kind: "model", model: thread.model }]),
49
+ ...(thread.effort === null ? [] : [{ kind: "effort", effort: thread.effort }]),
50
+ ];
51
+ kernel.frame({ type: "thread/opened", native: thread.native, events: opening });
52
+ const held = [];
53
+ let disposed = false;
54
+ let draining = false;
55
+ const capabilities = { queue: { durable: false }, attribution: "none", images: true };
56
+ /** Whether the Thread has work of this session's: a running turn, or input waiting to be sent. */
57
+ const occupied = () => tracker.busy() || held.length > 0;
58
+ /**
59
+ * Hand one input to the Thread. A prompt starts the turn this session
60
+ * follows; a steer must leave the following alone, because Cybion appends
61
+ * its input to the running turn and that turn has to end once (`steer`).
62
+ */
63
+ const send = async (input, images, startsTurn) => {
64
+ const refused = inputImagesRefusal(capabilities, images);
65
+ if (refused !== null) {
66
+ return refused;
67
+ }
68
+ const outcome = await withInputImages(capabilities, images, async (loaded) => {
69
+ try {
70
+ const answer = await submitInput(client, thread.id, input, loaded.map((image) => `data:${image.mediaType};base64,${image.data}`));
71
+ if (startsTurn) {
72
+ tracker.follow(acceptedRecordOf(answer));
73
+ }
74
+ return { kind: "accepted", native: answer };
75
+ }
76
+ catch (error) {
77
+ return refusalOf(error);
78
+ }
79
+ });
80
+ return outcome;
81
+ };
82
+ /**
83
+ * Send one held input and record its dispatch as a prompt, so the turn it
84
+ * starts is in the stream like any other. A refusal the Thread reports
85
+ * hands the input back to the caller as `input_dropped`.
86
+ */
87
+ const dispatch = async (entry) => {
88
+ const result = await kernel.control(
89
+ // The dispatch prompt is its own control identity; the held input it
90
+ // sends is named by `carries` alone (a prompt whose own inputId is the
91
+ // carried one is not a dispatch).
92
+ { kind: "prompt", input: entry.input, carries: [entry.inputId], ...(entry.images === undefined ? {} : { images: entry.images }) }, async (request) => {
93
+ const outcome = await send(entry.input, entry.images, true);
94
+ // Only an answer from Cybion hands a held input back: a write that never
95
+ // reached it, or an image refused before sending, is not the runtime
96
+ // dropping an input it accepted.
97
+ if (outcome.kind === "rejected" && outcome.native !== undefined) {
98
+ const dropped = {
99
+ kind: "input_dropped",
100
+ reason: "runtime_refused",
101
+ message: outcome.reason,
102
+ requestId: request.id,
103
+ ...(outcome.failure === undefined ? {} : { failure: outcome.failure }),
104
+ };
105
+ kernel.frame({ type: "cybion/send_rejected", native: outcome.native ?? null, events: [dropped] });
106
+ }
107
+ return outcome;
108
+ });
109
+ return result;
110
+ };
111
+ /**
112
+ * Record the turn a steer started when it missed the turn it aimed at. Cybion
113
+ * already holds the input, so nothing is sent: what the stream needs is the
114
+ * request record of the turn it started, the way an adapter-held input is
115
+ * dispatched (`dispatch` above), so that turn has its own `turn_started`.
116
+ *
117
+ * This runs a `prompt` control from inside the `steer` control's handler: the
118
+ * kernel allows a control to open another one, and this relies on it. A kernel
119
+ * that serialised controls would deadlock here, so keep the two in one step
120
+ * (or record the prompt before the write) if that ever changes.
121
+ */
122
+ const adoptSteer = async (input, images, recordIdx) => {
123
+ await kernel.control({ kind: "prompt", input, ...(images === undefined ? {} : { images }) }, () => {
124
+ tracker.follow(recordIdx);
125
+ return { kind: "accepted" };
126
+ });
127
+ };
128
+ const drain = async () => {
129
+ if (disposed || draining) {
130
+ return;
131
+ }
132
+ const next = held[0];
133
+ if (next === undefined || tracker.busy()) {
134
+ return;
135
+ }
136
+ draining = true;
137
+ held.shift();
138
+ try {
139
+ const result = await dispatch(next);
140
+ if (result.response.body.kind !== "accepted") {
141
+ // The send failed: the next held input still gets its own turn.
142
+ queueMicrotask(() => {
143
+ void drain();
144
+ });
145
+ }
146
+ }
147
+ finally {
148
+ draining = false;
149
+ }
150
+ };
151
+ const tracker = createThreadTracker({
152
+ client,
153
+ kernel,
154
+ thread,
155
+ // The stream is what this process observes: the Thread's earlier records
156
+ // are not replayed, so a resumed session starts at its own next turn.
157
+ seen: await lastRecordOf(client, thread.id),
158
+ onIdle: () => {
159
+ void drain();
160
+ },
161
+ onGivenUp: () => {
162
+ // No poll follows a given-up turn, so a held input would wait behind a
163
+ // turn that ended: hand each one back to the host instead.
164
+ for (const entry of held.splice(0)) {
165
+ kernel.frame({ type: "cybion/held_dropped", native: null, events: [{ kind: "input_dropped", reason: "turn_interrupted", inputId: entry.inputId }] });
166
+ }
167
+ },
168
+ });
169
+ const session = sealSession({
170
+ id: kernel.sessionId,
171
+ capabilities,
172
+ prompt: async (input, inputOptions) => {
173
+ // Busy is read before the request is recorded, and every source of work
174
+ // counts: the status fold (a prompt already accepted), a turn the tracker
175
+ // follows, input held for a later turn, and a dispatch whose POST is in
176
+ // flight. The tracker alone is not enough — it only knows a turn after
177
+ // `/inputs` answers — so two prompts in one tick would both be accepted.
178
+ const busy = session.status().value.kind === "running" || occupied() || draining;
179
+ const result = await kernel.control({ kind: "prompt", input, ...inputOptions }, async () => {
180
+ if (busy) {
181
+ return { kind: "rejected", code: "busy", reason: "busy" };
182
+ }
183
+ const outcome = await send(input, inputOptions?.images, true);
184
+ return outcome;
185
+ });
186
+ return result;
187
+ },
188
+ steer: async (input, inputOptions) => {
189
+ const result = await kernel.control({ kind: "steer", input, ...inputOptions }, async () => {
190
+ // A steer continues the turn that runs. With no turn followed there is
191
+ // nothing to continue, and writing would start a turn this session is not
192
+ // following — so the caller keeps the input.
193
+ if (!tracker.busy()) {
194
+ return { kind: "rejected", code: "no_active_turn", reason: "not_steerable: no active turn" };
195
+ }
196
+ const outcome = await send(input, inputOptions?.images, false);
197
+ if (outcome.kind === "accepted") {
198
+ const recordIdx = acceptedRecordOf(outcome.native);
199
+ if (tracker.busy()) {
200
+ // Cybion takes the input into the running turn: the request in flight
201
+ // is cancelled, the Thread stays `running`, and the turn keeps going
202
+ // and ends once, after this input.
203
+ tracker.steer(recordIdx);
204
+ }
205
+ else if (!draining) {
206
+ // The turn ended while the write was in flight, so Cybion started one
207
+ // for this input alone: it is a turn of its own, and nothing else is
208
+ // following it. (A dispatch in flight will follow a turn that already
209
+ // holds this input, so it needs nothing here.)
210
+ await adoptSteer(input, inputOptions?.images, recordIdx);
211
+ }
212
+ }
213
+ return outcome;
214
+ });
215
+ return result;
216
+ },
217
+ queue: async (input, inputOptions) => {
218
+ // The queue record must name the input it holds: the dispatch prompt that
219
+ // later carries it is checked against this request's `inputId`, so one is
220
+ // made when the caller gave none.
221
+ const inputId = inputOptions?.inputId ?? globalThis.crypto.randomUUID();
222
+ const result = await kernel.control({ kind: "queue", input, ...inputOptions, inputId }, () => {
223
+ const refused = inputImagesRefusal(capabilities, inputOptions?.images);
224
+ if (refused !== null) {
225
+ return refused;
226
+ }
227
+ held.push({ input, inputId, images: inputOptions?.images });
228
+ return { kind: "accepted", queued: "adapter" };
229
+ });
230
+ void drain();
231
+ return result;
232
+ },
233
+ withdraw: withdrawControl(kernel, held),
234
+ abort: async () => {
235
+ // `POST /api/threads/{id}/cancel` stops the turn; an API key reaches it,
236
+ // because that router authenticates the same bearer credential. The turn
237
+ // then ends through the Thread's own `stopped` status, not here.
238
+ const result = await kernel.control({ kind: "abort" }, async () => {
239
+ const aborted = tracker.turnId();
240
+ if (aborted === null) {
241
+ return { kind: "rejected", code: "no_active_turn", reason: "no active turn" };
242
+ }
243
+ const stopped = await cancelThread(client, thread.id);
244
+ if (stopped.kind !== "accepted") {
245
+ return stopped;
246
+ }
247
+ // The cancel route takes no turn id, so its answer is read rather than
248
+ // trusted: Cybion answers `stopped` only for a Thread it actually stopped,
249
+ // and answers an idle Thread unchanged when the turn had already ended.
250
+ // A turn that came and went while the cancel travelled is not this call's.
251
+ if (answeredStatusOf(stopped.native) !== "stopped" || tracker.turnId() !== aborted) {
252
+ return { kind: "rejected", code: "no_active_turn", reason: "no active turn", native: stopped.native };
253
+ }
254
+ // The Thread carries `stopped` from here on; only this turn may read it
255
+ // as its own end, or the next turn would abort on the same word.
256
+ tracker.stoppedByUs(aborted);
257
+ return stopped;
258
+ });
259
+ return result;
260
+ },
261
+ rawEvents: (observer, cursor) => kernel.rawEvents(observer, cursor),
262
+ records: () => kernel.records(),
263
+ graph: () => kernel.graph(),
264
+ dispose: async () => {
265
+ if (disposed) {
266
+ return;
267
+ }
268
+ disposed = true;
269
+ const gone = kernel.unreachable() !== null;
270
+ const request = kernel.request("toRuntime", { kind: "dispose" });
271
+ held.length = 0;
272
+ if (!gone && tracker.busy()) {
273
+ // The turn still runs in the Thread; its own status ends it in the stream if it comes in time.
274
+ await tracker.settle(DISPOSE_SETTLE_MS);
275
+ }
276
+ tracker.close();
277
+ kernel.respond(request.id, { kind: "accepted" });
278
+ },
279
+ });
280
+ return session;
281
+ };
282
+ }
283
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sources":["../../../src/community/cybion/session.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACjI,OAAO,EAAE,mBAAmB,EAAsB,MAAM,cAAc,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,oEAAoE;AACpE,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAQ/B;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAwC;IACxE,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE;QACrC,IAAI,YAAY,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;QACnF,CAAC;QACD,oBAAoB,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC;QAC3D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,OAAO,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/json.js";
3
+ import { type CybionClient } from "./client.js";
4
+ /** The parts of a Cybion Thread (`ThreadView`) this adapter reads. */
5
+ export interface CybionThread {
6
+ /** The `ThreadView` as Cybion sent it, kept verbatim for the frame that carries it. */
7
+ readonly native: unknown;
8
+ readonly id: string;
9
+ /** `running` while a turn runs; `idle` or `failed` otherwise. */
10
+ readonly status: string;
11
+ /** The refined idle meaning: `ready`, `completed`, `stopped`, `blocked` or `compacting`. */
12
+ readonly displayStatus: string;
13
+ readonly title: string | null;
14
+ readonly model: string | null;
15
+ readonly effort: string | null;
16
+ /** Input tokens of the most recent inference, Cybion's own context fullness figure. */
17
+ readonly contextTokens: number | null;
18
+ readonly usage: CybionUsage;
19
+ }
20
+ /** A Thread's settled token totals, counted by Cybion since it was created. */
21
+ export interface CybionUsage {
22
+ readonly input: number;
23
+ readonly output: number;
24
+ readonly cacheRead: number;
25
+ }
26
+ /** One record of a Thread's append-only history (`GET /v1/threads/{id}/history`). */
27
+ export interface CybionHistoryRecord {
28
+ /** The record as Cybion sent it, kept verbatim for the frame that carries it. */
29
+ readonly native: unknown;
30
+ readonly id: number;
31
+ readonly kind: string;
32
+ readonly payload: JsonRecord;
33
+ }
34
+ /** A `ThreadView` read into the facts this adapter uses; a body without an id is not a Thread. */
35
+ export declare function threadOf(value: unknown): CybionThread;
36
+ /** A Thread's history in record order, read into the fields this adapter maps. */
37
+ export declare function historyOf(value: unknown): CybionHistoryRecord[];
38
+ /** Read one Thread, or fail with what Cybion answered. */
39
+ export declare function readThread(client: CybionClient, threadId: string): Promise<CybionThread>;
40
+ /** The Thread's whole history, oldest first. */
41
+ export declare function readHistory(client: CybionClient, threadId: string): Promise<CybionHistoryRecord[]>;
42
+ /** The last history record a Thread holds, so a session's stream starts at its own first turn. */
43
+ export declare function lastRecordOf(client: CybionClient, threadId: string): Promise<number>;
44
+ /**
45
+ * The Thread this session runs in: the one to resume, checked to exist, or a
46
+ * new empty one (`POST /v1/threads`). A resumed Thread keeps the model and
47
+ * effort Cybion stored, and the Agent API has no route that changes them, so a
48
+ * differing value is refused rather than silently ignored.
49
+ */
50
+ export declare function openThread(client: CybionClient, options: SessionOptions): Promise<CybionThread>;
51
+ /**
52
+ * Hand one input to the Thread. Cybion refuses with a 4xx the adapter records
53
+ * as a refusal, never as a delivered input: an empty or over-long input, more
54
+ * images than it takes, or an image that is not a png/jpeg/webp/gif data URL.
55
+ */
56
+ export declare function submitInput(client: CybionClient, threadId: string, input: string, images: readonly string[]): Promise<unknown>;
57
+ /**
58
+ * Stop the Thread's turn. Cybion answers the Thread it stopped (`status: idle`,
59
+ * `display_status: stopped`), or a refusal/404 the caller reads as one.
60
+ */
61
+ export declare function cancelThread(client: CybionClient, threadId: string): Promise<ResponseBody>;
62
+ /** The `display_status` a cancel answered, when the answer named one. */
63
+ export declare function answeredStatusOf(answer: unknown): string | null;
64
+ /** The record Cybion says an accepted input occupies; null when it named none. */
65
+ export declare function acceptedRecordOf(answer: unknown): number | null;
66
+ /**
67
+ * What one failed delivery attempt means to the caller, read from the status
68
+ * Cybion answered: a rejected credential is an `auth` failure, a throttle a
69
+ * `rate_limited` one, a 5xx a provider-side `error`. A transport failure keeps
70
+ * the exception's own words and no class, because nothing answered.
71
+ */
72
+ export declare function refusalOf(error: unknown): ResponseBody;
73
+ /** Every `output_text` of one `response_output` message, in the item's own order. */
74
+ export declare function outputTextOf(payload: JsonRecord): string;
75
+ //# sourceMappingURL=thread.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread.d.ts","sources":["../../../src/community/cybion/thread.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAoC,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3D,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,uFAAuF;IACvF,QAAQ,CAAC,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,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAExG;AAED,kGAAkG;AAClG,wBAAsB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG1F;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAqCrG;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CASpI;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAShG;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAG/D;AAED,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAG/D;AAaD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAmBtD;AAED,qFAAqF;AACrF,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAIxD"}
@@ -0,0 +1,192 @@
1
+ import { UnsupportedOptionError } from "../../contracts/errors.js";
2
+ import { SessionNotFoundError } from "../../contracts/session-not-found-error.js";
3
+ import { asNumber, asRecord, asRecordList } from "../../shared/json.js";
4
+ import { errorText } from "./client.js";
5
+ import { CybionRefusalError, replyMessage } from "./refusal.js";
6
+ function text(value) {
7
+ return typeof value === "string" && value !== "" ? value : null;
8
+ }
9
+ function usageOf(value) {
10
+ const usage = asRecord(value);
11
+ return {
12
+ input: asNumber(usage?.input_tokens) ?? 0,
13
+ output: asNumber(usage?.output_tokens) ?? 0,
14
+ cacheRead: asNumber(usage?.cached_tokens) ?? 0,
15
+ };
16
+ }
17
+ /** A `ThreadView` read into the facts this adapter uses; a body without an id is not a Thread. */
18
+ export function threadOf(value) {
19
+ const thread = asRecord(value);
20
+ const id = text(thread?.id);
21
+ if (thread === null || id === null) {
22
+ throw new Error("Cybion answered without a Thread id");
23
+ }
24
+ return {
25
+ native: value,
26
+ id,
27
+ status: text(thread.status) ?? "idle",
28
+ displayStatus: text(thread.display_status) ?? "ready",
29
+ title: text(thread.title),
30
+ model: text(thread.model),
31
+ effort: text(thread.reasoning_effort),
32
+ contextTokens: asNumber(thread.context_tokens),
33
+ usage: usageOf(thread.usage),
34
+ };
35
+ }
36
+ /** A Thread's history in record order, read into the fields this adapter maps. */
37
+ export function historyOf(value) {
38
+ if (!Array.isArray(value)) {
39
+ return [];
40
+ }
41
+ const entries = value;
42
+ const records = [];
43
+ for (const entry of entries) {
44
+ const record = asRecord(entry);
45
+ const id = asNumber(record?.id);
46
+ const kind = text(record?.kind);
47
+ if (record === null || id === null || kind === null) {
48
+ continue;
49
+ }
50
+ records.push({ native: entry, id, kind, payload: asRecord(record.payload) ?? {} });
51
+ }
52
+ return records;
53
+ }
54
+ /** Read one Thread, or fail with what Cybion answered. */
55
+ export async function readThread(client, threadId) {
56
+ return threadOf(await client.expect("GET", `/v1/threads/${encodeURIComponent(threadId)}`));
57
+ }
58
+ /** The Thread's whole history, oldest first. */
59
+ export async function readHistory(client, threadId) {
60
+ return historyOf(await client.expect("GET", `/v1/threads/${encodeURIComponent(threadId)}/history`));
61
+ }
62
+ /** The last history record a Thread holds, so a session's stream starts at its own first turn. */
63
+ export async function lastRecordOf(client, threadId) {
64
+ const history = await readHistory(client, threadId);
65
+ return history.reduce((highest, record) => Math.max(highest, record.id), 0);
66
+ }
67
+ /**
68
+ * The Thread this session runs in: the one to resume, checked to exist, or a
69
+ * new empty one (`POST /v1/threads`). A resumed Thread keeps the model and
70
+ * effort Cybion stored, and the Agent API has no route that changes them, so a
71
+ * differing value is refused rather than silently ignored.
72
+ */
73
+ export async function openThread(client, options) {
74
+ if (options.resume !== undefined) {
75
+ const reply = await client.call("GET", `/v1/threads/${encodeURIComponent(options.resume)}`);
76
+ if (reply.status === 404) {
77
+ throw new SessionNotFoundError(options.resume, `Cybion has no Thread ${options.resume} to resume`, { method: "GET /v1/threads/{id}", native: { error: errorText(reply.body) } });
78
+ }
79
+ if (reply.status < 200 || reply.status >= 300) {
80
+ throw new Error(`cybion GET /v1/threads/${options.resume} answered ${String(reply.status)}: ${replyMessage(reply)}`);
81
+ }
82
+ const resumed = threadOf(reply.body);
83
+ if (options.model !== undefined && resumed.model !== null && options.model !== resumed.model) {
84
+ throw new UnsupportedOptionError("model", `Cybion's Agent API has no route that changes a Thread's model, and Thread ${resumed.id} runs ${resumed.model}`);
85
+ }
86
+ if (options.effort !== undefined && resumed.effort !== null && options.effort !== resumed.effort) {
87
+ throw new UnsupportedOptionError("effort", `Cybion's Agent API has no route that changes a Thread's reasoning effort, and Thread ${resumed.id} runs at ${resumed.effort}`);
88
+ }
89
+ return resumed;
90
+ }
91
+ const created = await client.call("POST", "/v1/threads", {
92
+ ...(options.name === undefined ? {} : { title: options.name }),
93
+ ...(options.model === undefined ? {} : { model: options.model }),
94
+ ...(options.effort === undefined ? {} : { reasoning_effort: options.effort }),
95
+ });
96
+ if (created.status < 200 || created.status >= 300) {
97
+ const detail = errorText(created.body);
98
+ throw new Error(`cybion POST /v1/threads answered ${String(created.status)}: ${detail ?? "no detail"}`);
99
+ }
100
+ const thread = threadOf(created.body);
101
+ // A requested model is never silently substituted: the Thread reports the one
102
+ // it runs, so a substitution fails the open instead of the first turn.
103
+ if (options.model !== undefined && thread.model !== null && thread.model !== options.model) {
104
+ throw new Error(`Cybion created Thread ${thread.id} with model ${thread.model}, not the requested ${options.model}`);
105
+ }
106
+ if (options.effort !== undefined && thread.effort !== null && thread.effort !== options.effort) {
107
+ throw new Error(`Cybion created Thread ${thread.id} at reasoning effort ${thread.effort}, not the requested ${options.effort}`);
108
+ }
109
+ return thread;
110
+ }
111
+ /**
112
+ * Hand one input to the Thread. Cybion refuses with a 4xx the adapter records
113
+ * as a refusal, never as a delivered input: an empty or over-long input, more
114
+ * images than it takes, or an image that is not a png/jpeg/webp/gif data URL.
115
+ */
116
+ export async function submitInput(client, threadId, input, images) {
117
+ const reply = await client.call("POST", `/v1/threads/${encodeURIComponent(threadId)}/inputs`, {
118
+ input,
119
+ ...(images.length === 0 ? {} : { images: [...images] }),
120
+ });
121
+ if (reply.status < 200 || reply.status >= 300) {
122
+ throw new CybionRefusalError(reply);
123
+ }
124
+ return reply.body;
125
+ }
126
+ /**
127
+ * Stop the Thread's turn. Cybion answers the Thread it stopped (`status: idle`,
128
+ * `display_status: stopped`), or a refusal/404 the caller reads as one.
129
+ */
130
+ export async function cancelThread(client, threadId) {
131
+ const reply = await client.call("POST", `/api/threads/${encodeURIComponent(threadId)}/cancel`, {});
132
+ if (reply.status >= 200 && reply.status < 300) {
133
+ return { kind: "accepted", native: reply.body };
134
+ }
135
+ if (reply.status === 404) {
136
+ return { kind: "rejected", code: "session_not_found", reason: replyMessage(reply), native: reply.body };
137
+ }
138
+ return { kind: "rejected", code: reply.status < 500 && reply.status >= 400 ? "runtime_refused" : "error", reason: replyMessage(reply), native: reply.body };
139
+ }
140
+ /** The `display_status` a cancel answered, when the answer named one. */
141
+ export function answeredStatusOf(answer) {
142
+ const status = asRecord(answer)?.display_status;
143
+ return typeof status === "string" ? status : null;
144
+ }
145
+ /** The record Cybion says an accepted input occupies; null when it named none. */
146
+ export function acceptedRecordOf(answer) {
147
+ const index = asRecord(answer)?.record_idx;
148
+ return asNumber(index);
149
+ }
150
+ /** The failure class a status names, for the ones Cybion makes plain. */
151
+ function failureOf(status) {
152
+ if (status === 401 || status === 403) {
153
+ return "auth";
154
+ }
155
+ if (status === 429) {
156
+ return "rate_limited";
157
+ }
158
+ return undefined;
159
+ }
160
+ /**
161
+ * What one failed delivery attempt means to the caller, read from the status
162
+ * Cybion answered: a rejected credential is an `auth` failure, a throttle a
163
+ * `rate_limited` one, a 5xx a provider-side `error`. A transport failure keeps
164
+ * the exception's own words and no class, because nothing answered.
165
+ */
166
+ export function refusalOf(error) {
167
+ if (!(error instanceof CybionRefusalError)) {
168
+ return { kind: "rejected", code: "error", reason: String(error) };
169
+ }
170
+ if (error.status >= 500) {
171
+ return { kind: "rejected", code: "error", reason: error.message, failure: "provider", native: error.native };
172
+ }
173
+ if (error.status === 404) {
174
+ // The Thread the session was opened on is gone: no later control can succeed.
175
+ return { kind: "rejected", code: "session_not_found", reason: error.message, native: error.native };
176
+ }
177
+ const failure = failureOf(error.status);
178
+ return {
179
+ kind: "rejected",
180
+ code: error.refused ? "runtime_refused" : "error",
181
+ reason: error.message,
182
+ ...(failure === undefined ? {} : { failure }),
183
+ native: error.native,
184
+ };
185
+ }
186
+ /** Every `output_text` of one `response_output` message, in the item's own order. */
187
+ export function outputTextOf(payload) {
188
+ return asRecordList(payload.content)
189
+ .map((part) => (part.type === "output_text" ? text(part.text) ?? "" : ""))
190
+ .join("");
191
+ }
192
+ //# sourceMappingURL=thread.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread.js","sources":["../../../src/community/cybion/thread.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAElF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAmB,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,SAAS,EAAqB,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAmChE,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,OAAO,KAAK,KAAK,QA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,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO;QACjD,MAAM,EAAE,KAAK,CAAC,OAAO;QACrB,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;QAC7C,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC;AACJ,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,YAAY,CAAC,OAAmB;IAC9C,OAAO,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC;SACjC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SACzE,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { TurnOutcome } from "../../contracts/records.js";
2
+ import type { CybionThread, CybionUsage } from "./thread.js";
3
+ /** The Thread's totals less the ones it already carried when this session opened. */
4
+ export declare function totalsSince(now: CybionUsage, opened: CybionUsage): CybionUsage;
5
+ export declare function sameUsage(left: CybionUsage, right: CybionUsage): boolean;
6
+ /** How a Thread that stopped running ended, from Cybion's own status words. */
7
+ export declare function outcomeOf(thread: CybionThread): TurnOutcome;
8
+ export interface Turn {
9
+ /** Stable within one followed turn: an abort compares it to the turn it stopped. */
10
+ readonly id: number;
11
+ readonly ended: PromiseWithResolvers<void>;
12
+ /**
13
+ * Records with an id past this one prove the Thread did work for this turn.
14
+ * An input's own record sits AT it: recording the input is not the Thread
15
+ * running, so it never counts as work. A steer moves it forward — the input
16
+ * it wrote belongs to this turn, so the records it draws belong here too.
17
+ */
18
+ after: number;
19
+ /** The Thread was observed running, or wrote a record after the input. */
20
+ worked: boolean;
21
+ quiet: number;
22
+ startPolls: number;
23
+ /**
24
+ * This session asked Cybion to stop this very turn, and Cybion answered that
25
+ * it did. A `stopped` status from any other source (an earlier turn's stop the
26
+ * Thread still reports, its owner's UI) is not this turn's end.
27
+ */
28
+ stoppedByUs: boolean;
29
+ /**
30
+ * The record of the newest steer whose input the Thread has not been seen
31
+ * taking in yet, or null. Cybion accepts a steer into the running turn, so the
32
+ * turn is that input's too: it cannot end until the Thread ran (`running`) or
33
+ * wrote something past this record, whatever the status says meanwhile.
34
+ */
35
+ steerRecord: number | null;
36
+ }
37
+ export declare function observe(current: Turn, now: CybionThread): void;
38
+ //# sourceMappingURL=tracker-facts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracker-facts.d.ts","sources":["../../../src/community/cybion/tracker-facts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAQ7D,qFAAqF;AACrF,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,WAAW,CAM9E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAExE;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAW3D;AAED,MAAM,WAAW,IAAI;IACnB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC3C;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,WAAW,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,GAAG,IAAI,CAa9D"}