@neta-art/cohub-cli 10.23.0 → 10.25.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 (369) hide show
  1. package/README.md +18 -5
  2. package/bin/cohub.js +4 -1
  3. package/dist/board-gpu/page.js +1566 -71230
  4. package/dist/bootstrap.js +67 -27
  5. package/dist/build.json +1 -1
  6. package/dist/{board-kernel/FilterPipe.js → chunks/Geometry.js} +10447 -10469
  7. package/dist/chunks/about.js +102 -0
  8. package/dist/chunks/app-realtime.js +2216 -0
  9. package/dist/chunks/app-realtime2.js +2 -0
  10. package/dist/chunks/app-ref.js +88 -0
  11. package/dist/chunks/apps.js +1423 -0
  12. package/dist/chunks/auth.js +175 -0
  13. package/dist/chunks/avatar.js +146 -0
  14. package/dist/chunks/board-export-resources.js +232 -0
  15. package/dist/chunks/board-export.js +874 -0
  16. package/dist/chunks/board-export2.js +2 -0
  17. package/dist/{board-kernel.js → chunks/board-kernel.js} +18032 -28512
  18. package/dist/chunks/board-kernel2.js +4 -0
  19. package/dist/chunks/board-profile.js +69 -0
  20. package/dist/chunks/board-simulate.js +315 -0
  21. package/dist/chunks/board-time.js +34 -0
  22. package/dist/chunks/boards.js +1943 -0
  23. package/dist/{board-kernel → chunks}/browserAll.js +9 -8
  24. package/dist/chunks/channels.js +64 -0
  25. package/dist/chunks/client.js +12606 -0
  26. package/dist/chunks/command-input.js +17 -0
  27. package/dist/chunks/commander.js +2962 -0
  28. package/dist/chunks/cron-jobs.js +163 -0
  29. package/dist/chunks/daemon.js +545 -0
  30. package/dist/chunks/daemon2.js +2 -0
  31. package/dist/chunks/desktop.js +172 -0
  32. package/dist/chunks/endpoint-options.js +26 -0
  33. package/dist/chunks/env-proxy.js +35 -0
  34. package/dist/chunks/environment.js +154 -0
  35. package/dist/chunks/feedback.js +120 -0
  36. package/dist/chunks/generations.js +379 -0
  37. package/dist/chunks/host.js +9 -0
  38. package/dist/chunks/http-put.js +131 -0
  39. package/dist/chunks/id.js +2416 -0
  40. package/dist/{board-kernel → chunks}/init.js +1 -1
  41. package/dist/chunks/install.js +11959 -0
  42. package/dist/chunks/launch.js +374 -0
  43. package/dist/chunks/local-media.js +47 -0
  44. package/dist/chunks/me.js +134 -0
  45. package/dist/chunks/media.js +315 -0
  46. package/dist/chunks/models.js +242 -0
  47. package/dist/chunks/operands.js +46 -0
  48. package/dist/chunks/package-paths.js +13 -0
  49. package/dist/chunks/policy.js +221 -0
  50. package/dist/chunks/preferences.js +29 -0
  51. package/dist/chunks/profile.js +64 -0
  52. package/dist/chunks/prompts.js +41 -0
  53. package/dist/chunks/public.js +2 -0
  54. package/dist/chunks/public2.js +244 -0
  55. package/dist/chunks/references.js +197 -0
  56. package/dist/chunks/referrals.js +90 -0
  57. package/dist/chunks/rolldown-runtime.js +26 -0
  58. package/dist/chunks/rooms-connect.js +2 -0
  59. package/dist/chunks/rooms-connect2.js +151 -0
  60. package/dist/chunks/rooms-rtc.js +309 -0
  61. package/dist/chunks/rooms.js +211 -0
  62. package/dist/chunks/run.js +220 -0
  63. package/dist/chunks/runtime.js +638 -0
  64. package/dist/chunks/runtime2.js +286 -0
  65. package/dist/chunks/runtimes.js +48 -0
  66. package/dist/chunks/safe-remote-image.js +198 -0
  67. package/dist/chunks/schemas.js +6017 -0
  68. package/dist/chunks/search.js +113 -0
  69. package/dist/chunks/self-update.js +238 -0
  70. package/dist/chunks/serve.js +1246 -0
  71. package/dist/chunks/session-status.js +24 -0
  72. package/dist/chunks/skills.js +35 -0
  73. package/dist/chunks/spaces.js +5080 -0
  74. package/dist/chunks/src.js +405 -0
  75. package/dist/chunks/supervisor.js +2511 -0
  76. package/dist/chunks/supervisor2.js +2 -0
  77. package/dist/chunks/tasks.js +82 -0
  78. package/dist/chunks/themes.js +2898 -0
  79. package/dist/chunks/version.js +2 -0
  80. package/dist/chunks/version2.js +22 -0
  81. package/dist/chunks/version3.js +18 -0
  82. package/dist/chunks/web.js +7 -0
  83. package/dist/{board-kernel → chunks}/webworkerAll.js +1 -1
  84. package/dist/runtime/native/pi-extension.js +174 -166
  85. package/dist/runtime/worker.js +27 -16
  86. package/package.json +8 -9
  87. package/dist/about.d.ts +0 -2
  88. package/dist/about.js +0 -71
  89. package/dist/app-download.d.ts +0 -11
  90. package/dist/app-download.js +0 -252
  91. package/dist/app-ref.d.ts +0 -5
  92. package/dist/app-ref.js +0 -8
  93. package/dist/app-target.d.ts +0 -26
  94. package/dist/app-target.js +0 -55
  95. package/dist/auth.d.ts +0 -45
  96. package/dist/auth.js +0 -307
  97. package/dist/avatar.d.ts +0 -55
  98. package/dist/avatar.js +0 -104
  99. package/dist/board-command-support.d.ts +0 -6
  100. package/dist/board-command-support.js +0 -88
  101. package/dist/board-export-resources.d.ts +0 -12
  102. package/dist/board-export-resources.js +0 -51
  103. package/dist/board-export.d.ts +0 -110
  104. package/dist/board-export.js +0 -592
  105. package/dist/board-fonts.d.ts +0 -11
  106. package/dist/board-fonts.js +0 -10
  107. package/dist/board-gpu/daemon.d.ts +0 -11
  108. package/dist/board-gpu/daemon.js +0 -295
  109. package/dist/board-gpu/index.d.ts +0 -33
  110. package/dist/board-gpu/index.js +0 -189
  111. package/dist/board-gpu/protocol.d.ts +0 -77
  112. package/dist/board-gpu/protocol.js +0 -1
  113. package/dist/board-kernel.d.ts +0 -5
  114. package/dist/board-media-export.d.ts +0 -17
  115. package/dist/board-media-export.js +0 -164
  116. package/dist/board-media.d.ts +0 -5
  117. package/dist/board-media.js +0 -66
  118. package/dist/board-profile.d.ts +0 -21
  119. package/dist/board-profile.js +0 -67
  120. package/dist/board-simulate.d.ts +0 -67
  121. package/dist/board-simulate.js +0 -259
  122. package/dist/board-time.d.ts +0 -3
  123. package/dist/board-time.js +0 -34
  124. package/dist/bootstrap.d.ts +0 -2
  125. package/dist/client.d.ts +0 -5
  126. package/dist/client.js +0 -24
  127. package/dist/command-input.d.ts +0 -4
  128. package/dist/command-input.js +0 -16
  129. package/dist/commands/app-commerce.d.ts +0 -2
  130. package/dist/commands/app-commerce.js +0 -228
  131. package/dist/commands/app-domains.d.ts +0 -2
  132. package/dist/commands/app-domains.js +0 -133
  133. package/dist/commands/apps.d.ts +0 -4
  134. package/dist/commands/apps.js +0 -827
  135. package/dist/commands/auth.d.ts +0 -2
  136. package/dist/commands/auth.js +0 -186
  137. package/dist/commands/boards/authoring.d.ts +0 -2
  138. package/dist/commands/boards/authoring.js +0 -166
  139. package/dist/commands/boards/examples.d.ts +0 -10
  140. package/dist/commands/boards/examples.js +0 -118
  141. package/dist/commands/boards.d.ts +0 -13
  142. package/dist/commands/boards.js +0 -836
  143. package/dist/commands/channels.d.ts +0 -2
  144. package/dist/commands/channels.js +0 -74
  145. package/dist/commands/cron-jobs.d.ts +0 -2
  146. package/dist/commands/cron-jobs.js +0 -155
  147. package/dist/commands/decision.d.ts +0 -4
  148. package/dist/commands/decision.js +0 -113
  149. package/dist/commands/desktop.d.ts +0 -10
  150. package/dist/commands/desktop.js +0 -233
  151. package/dist/commands/feedback.d.ts +0 -2
  152. package/dist/commands/feedback.js +0 -131
  153. package/dist/commands/generations.d.ts +0 -2
  154. package/dist/commands/generations.js +0 -427
  155. package/dist/commands/host.d.ts +0 -2
  156. package/dist/commands/host.js +0 -11
  157. package/dist/commands/me.d.ts +0 -2
  158. package/dist/commands/me.js +0 -118
  159. package/dist/commands/models.d.ts +0 -28
  160. package/dist/commands/models.js +0 -271
  161. package/dist/commands/profile.d.ts +0 -2
  162. package/dist/commands/profile.js +0 -81
  163. package/dist/commands/prompts.d.ts +0 -2
  164. package/dist/commands/prompts.js +0 -37
  165. package/dist/commands/public.d.ts +0 -20
  166. package/dist/commands/public.js +0 -291
  167. package/dist/commands/references.d.ts +0 -2
  168. package/dist/commands/references.js +0 -193
  169. package/dist/commands/referrals.d.ts +0 -2
  170. package/dist/commands/referrals.js +0 -88
  171. package/dist/commands/rooms-connect.d.ts +0 -17
  172. package/dist/commands/rooms-connect.js +0 -140
  173. package/dist/commands/rooms-rtc-binary.d.ts +0 -2
  174. package/dist/commands/rooms-rtc-binary.js +0 -107
  175. package/dist/commands/rooms-rtc.d.ts +0 -21
  176. package/dist/commands/rooms-rtc.js +0 -171
  177. package/dist/commands/rooms.d.ts +0 -3
  178. package/dist/commands/rooms.js +0 -277
  179. package/dist/commands/run.d.ts +0 -13
  180. package/dist/commands/run.js +0 -246
  181. package/dist/commands/runtime.d.ts +0 -3
  182. package/dist/commands/runtime.js +0 -320
  183. package/dist/commands/sandboxd-binary.d.ts +0 -11
  184. package/dist/commands/sandboxd-binary.js +0 -238
  185. package/dist/commands/search.d.ts +0 -2
  186. package/dist/commands/search.js +0 -114
  187. package/dist/commands/session-access.d.ts +0 -2
  188. package/dist/commands/session-access.js +0 -70
  189. package/dist/commands/skills.d.ts +0 -2
  190. package/dist/commands/skills.js +0 -34
  191. package/dist/commands/space-activity.d.ts +0 -26
  192. package/dist/commands/space-activity.js +0 -147
  193. package/dist/commands/space-commerce.d.ts +0 -2
  194. package/dist/commands/space-commerce.js +0 -514
  195. package/dist/commands/space-displays.d.ts +0 -2
  196. package/dist/commands/space-displays.js +0 -620
  197. package/dist/commands/space-files.d.ts +0 -5
  198. package/dist/commands/space-files.js +0 -215
  199. package/dist/commands/space-invitations.d.ts +0 -29
  200. package/dist/commands/space-invitations.js +0 -189
  201. package/dist/commands/space-turns.d.ts +0 -49
  202. package/dist/commands/space-turns.js +0 -205
  203. package/dist/commands/space-wallet.d.ts +0 -2
  204. package/dist/commands/space-wallet.js +0 -64
  205. package/dist/commands/space-webhooks.d.ts +0 -7
  206. package/dist/commands/space-webhooks.js +0 -73
  207. package/dist/commands/spaces.d.ts +0 -25
  208. package/dist/commands/spaces.js +0 -2139
  209. package/dist/commands/tasks.d.ts +0 -8
  210. package/dist/commands/tasks.js +0 -80
  211. package/dist/commands/version.d.ts +0 -2
  212. package/dist/commands/version.js +0 -21
  213. package/dist/endpoint-options.d.ts +0 -4
  214. package/dist/endpoint-options.js +0 -26
  215. package/dist/env-proxy.d.ts +0 -5
  216. package/dist/env-proxy.js +0 -20
  217. package/dist/help-path.d.ts +0 -18
  218. package/dist/help-path.js +0 -223
  219. package/dist/host/auth.d.ts +0 -20
  220. package/dist/host/auth.js +0 -119
  221. package/dist/host/login-env.d.ts +0 -1
  222. package/dist/host/login-env.js +0 -31
  223. package/dist/host/runtime.d.ts +0 -35
  224. package/dist/host/runtime.js +0 -395
  225. package/dist/host/runtimes.d.ts +0 -9
  226. package/dist/host/runtimes.js +0 -42
  227. package/dist/host/serve.d.ts +0 -2
  228. package/dist/host/serve.js +0 -117
  229. package/dist/host/workspaces.d.ts +0 -2
  230. package/dist/host/workspaces.js +0 -18
  231. package/dist/http-put.d.ts +0 -25
  232. package/dist/http-put.js +0 -132
  233. package/dist/index.d.ts +0 -2
  234. package/dist/index.js +0 -129
  235. package/dist/launcher.d.ts +0 -4
  236. package/dist/launcher.js +0 -38
  237. package/dist/local-media.d.ts +0 -2
  238. package/dist/local-media.js +0 -30
  239. package/dist/network-error.d.ts +0 -3
  240. package/dist/network-error.js +0 -22
  241. package/dist/output.d.ts +0 -46
  242. package/dist/output.js +0 -244
  243. package/dist/runtime/archive-store.d.ts +0 -54
  244. package/dist/runtime/archive-store.js +0 -379
  245. package/dist/runtime/cli-path.d.ts +0 -5
  246. package/dist/runtime/cli-path.js +0 -27
  247. package/dist/runtime/codex-usage.d.ts +0 -7
  248. package/dist/runtime/codex-usage.js +0 -11
  249. package/dist/runtime/connection.d.ts +0 -42
  250. package/dist/runtime/connection.js +0 -789
  251. package/dist/runtime/diagnostics.d.ts +0 -107
  252. package/dist/runtime/diagnostics.js +0 -392
  253. package/dist/runtime/harnesses/chained-projection.d.ts +0 -40
  254. package/dist/runtime/harnesses/chained-projection.js +0 -95
  255. package/dist/runtime/harnesses/chained-transcript.d.ts +0 -24
  256. package/dist/runtime/harnesses/chained-transcript.js +0 -62
  257. package/dist/runtime/harnesses/claude-approval.d.ts +0 -34
  258. package/dist/runtime/harnesses/claude-approval.js +0 -124
  259. package/dist/runtime/harnesses/claude-transcript.d.ts +0 -8
  260. package/dist/runtime/harnesses/claude-transcript.js +0 -138
  261. package/dist/runtime/harnesses/claude.d.ts +0 -8
  262. package/dist/runtime/harnesses/claude.js +0 -225
  263. package/dist/runtime/harnesses/codex-approval.d.ts +0 -25
  264. package/dist/runtime/harnesses/codex-approval.js +0 -69
  265. package/dist/runtime/harnesses/codex.d.ts +0 -4
  266. package/dist/runtime/harnesses/codex.js +0 -269
  267. package/dist/runtime/harnesses/cursor-transcript.d.ts +0 -37
  268. package/dist/runtime/harnesses/cursor-transcript.js +0 -183
  269. package/dist/runtime/harnesses/cursor.d.ts +0 -24
  270. package/dist/runtime/harnesses/cursor.js +0 -620
  271. package/dist/runtime/harnesses/index.d.ts +0 -16
  272. package/dist/runtime/harnesses/index.js +0 -73
  273. package/dist/runtime/harnesses/pi.d.ts +0 -4
  274. package/dist/runtime/harnesses/pi.js +0 -247
  275. package/dist/runtime/harnesses/process.d.ts +0 -31
  276. package/dist/runtime/harnesses/process.js +0 -75
  277. package/dist/runtime/harnesses/stream-json.d.ts +0 -48
  278. package/dist/runtime/harnesses/stream-json.js +0 -336
  279. package/dist/runtime/harnesses/types.d.ts +0 -117
  280. package/dist/runtime/harnesses/types.js +0 -1
  281. package/dist/runtime/harnesses/workbuddy-transcript.d.ts +0 -8
  282. package/dist/runtime/harnesses/workbuddy-transcript.js +0 -127
  283. package/dist/runtime/harnesses/workbuddy.d.ts +0 -21
  284. package/dist/runtime/harnesses/workbuddy.js +0 -123
  285. package/dist/runtime/instance.d.ts +0 -20
  286. package/dist/runtime/instance.js +0 -247
  287. package/dist/runtime/json-rpc.d.ts +0 -53
  288. package/dist/runtime/json-rpc.js +0 -212
  289. package/dist/runtime/launch.d.ts +0 -25
  290. package/dist/runtime/launch.js +0 -247
  291. package/dist/runtime/local-workspace.d.ts +0 -15
  292. package/dist/runtime/local-workspace.js +0 -52
  293. package/dist/runtime/model-catalog.d.ts +0 -12
  294. package/dist/runtime/model-catalog.js +0 -84
  295. package/dist/runtime/native/adapters.d.ts +0 -15
  296. package/dist/runtime/native/adapters.js +0 -11
  297. package/dist/runtime/native/approvals.d.ts +0 -18
  298. package/dist/runtime/native/approvals.js +0 -54
  299. package/dist/runtime/native/archive.d.ts +0 -19
  300. package/dist/runtime/native/archive.js +0 -142
  301. package/dist/runtime/native/attach.d.ts +0 -36
  302. package/dist/runtime/native/attach.js +0 -128
  303. package/dist/runtime/native/codex-link.d.ts +0 -60
  304. package/dist/runtime/native/codex-link.js +0 -322
  305. package/dist/runtime/native/config.d.ts +0 -16
  306. package/dist/runtime/native/config.js +0 -24
  307. package/dist/runtime/native/daemon.d.ts +0 -92
  308. package/dist/runtime/native/daemon.js +0 -380
  309. package/dist/runtime/native/execution.d.ts +0 -26
  310. package/dist/runtime/native/execution.js +0 -34
  311. package/dist/runtime/native/identity.d.ts +0 -9
  312. package/dist/runtime/native/identity.js +0 -15
  313. package/dist/runtime/native/ingest.d.ts +0 -263
  314. package/dist/runtime/native/ingest.js +0 -884
  315. package/dist/runtime/native/install.d.ts +0 -9
  316. package/dist/runtime/native/install.js +0 -113
  317. package/dist/runtime/native/paths.d.ts +0 -2
  318. package/dist/runtime/native/paths.js +0 -7
  319. package/dist/runtime/native/pi-extension.d.ts +0 -36
  320. package/dist/runtime/native/pi-link.d.ts +0 -69
  321. package/dist/runtime/native/pi-link.js +0 -269
  322. package/dist/runtime/native/results.d.ts +0 -41
  323. package/dist/runtime/native/results.js +0 -128
  324. package/dist/runtime/native/sessions.d.ts +0 -45
  325. package/dist/runtime/native/sessions.js +0 -87
  326. package/dist/runtime/native/transcript.d.ts +0 -89
  327. package/dist/runtime/native/transcript.js +0 -656
  328. package/dist/runtime/native/translate.d.ts +0 -46
  329. package/dist/runtime/native/translate.js +0 -299
  330. package/dist/runtime/native/transport.d.ts +0 -7
  331. package/dist/runtime/native/transport.js +0 -16
  332. package/dist/runtime/native/version.d.ts +0 -5
  333. package/dist/runtime/native/version.js +0 -21
  334. package/dist/runtime/preferences.d.ts +0 -7
  335. package/dist/runtime/preferences.js +0 -22
  336. package/dist/runtime/presentation.d.ts +0 -32
  337. package/dist/runtime/presentation.js +0 -124
  338. package/dist/runtime/process-group.d.ts +0 -5
  339. package/dist/runtime/process-group.js +0 -161
  340. package/dist/runtime/projection-store.d.ts +0 -27
  341. package/dist/runtime/projection-store.js +0 -30
  342. package/dist/runtime/space-binding.d.ts +0 -48
  343. package/dist/runtime/space-binding.js +0 -342
  344. package/dist/runtime/supervisor.d.ts +0 -19
  345. package/dist/runtime/supervisor.js +0 -441
  346. package/dist/runtime/turn-projection.d.ts +0 -41
  347. package/dist/runtime/turn-projection.js +0 -120
  348. package/dist/runtime/worker.d.ts +0 -1
  349. package/dist/safe-remote-image.d.ts +0 -36
  350. package/dist/safe-remote-image.js +0 -191
  351. package/dist/self-update.d.ts +0 -7
  352. package/dist/self-update.js +0 -202
  353. package/dist/session-status.d.ts +0 -6
  354. package/dist/session-status.js +0 -16
  355. package/dist/space-files/limit.d.ts +0 -2
  356. package/dist/space-files/limit.js +0 -16
  357. package/dist/space-files/operands.d.ts +0 -17
  358. package/dist/space-files/operands.js +0 -33
  359. package/dist/space-files/transfer.d.ts +0 -53
  360. package/dist/space-files/transfer.js +0 -297
  361. package/dist/space-files/upload.d.ts +0 -17
  362. package/dist/space-files/upload.js +0 -76
  363. package/dist/space.d.ts +0 -44
  364. package/dist/space.js +0 -192
  365. package/dist/version.d.ts +0 -2
  366. package/dist/version.js +0 -17
  367. package/dist/web.d.ts +0 -1
  368. package/dist/web.js +0 -4
  369. /package/dist/{board-kernel → chunks}/lexer.js +0 -0
@@ -1,336 +0,0 @@
1
- import { execFile } from "node:child_process";
2
- import { randomUUID } from "node:crypto";
3
- import { createReadStream } from "node:fs";
4
- import { access, readdir } from "node:fs/promises";
5
- import { join } from "node:path";
6
- import { promisify } from "node:util";
7
- import { isModelThinkingLevel, thinkingLevelMapFor } from "@neta-art/cohub";
8
- import { JsonRpcProcess, record } from "../json-rpc.js";
9
- import { describeError } from "../../network-error.js";
10
- import { array, closeHost, harnessCommand, identifiable, inlineImage, missing, text, turnEnvironment, watchHost } from "./process.js";
11
- /** A stop request that the harness does not honour within this long ends its process. */
12
- const ABORT_ESCALATION_MS = 5_000;
13
- /** After input closes, the CLI flushes its transcript; it is reaped when it does not exit by then. */
14
- const FLUSH_TIMEOUT_MS = 10_000;
15
- /**
16
- * Plan mode still honours the user's allow rules, so a read-only Turn also gets only these
17
- * built-in tools and no configured MCP servers.
18
- */
19
- export const READ_ONLY_ARGS = ["--permission-mode", "plan", "--tools", "Read,Glob,Grep", "--strict-mcp-config"];
20
- /** Flags every Turn relies on; an executable whose help lacks one is an older or unrelated CLI. */
21
- const REQUIRED_FLAGS = ["--input-format", "--output-format", "--include-partial-messages", "--session-id", "--resume", "--permission-mode", "--tools", "--strict-mcp-config", "--model", "--effort"];
22
- /** Runs without `--model`, so the CLI's own configuration and account default apply. */
23
- export const DEFAULT_MODEL = "default";
24
- /** The CLI's help, after checking it offers every flag a Turn uses. */
25
- export async function streamJsonHelp(profile, executable, cwd) {
26
- const { stdout } = await promisify(execFile)(...harnessCommand(executable, ["--help"], cwd), { cwd, encoding: "utf8", timeout: 30_000, maxBuffer: 4 * 1024 * 1024, windowsHide: true });
27
- const missingFlags = REQUIRED_FLAGS.filter((flag) => !new RegExp(`(^|[\\s,])${flag}(?=[\\s,=<]|$)`, "m").test(stdout));
28
- if (missingFlags.length)
29
- throw new Error(`${executable} is not a supported ${profile.label} CLI (missing ${missingFlags.join(", ")}); update ${profile.label}`);
30
- return stdout;
31
- }
32
- export function streamJsonModel(profile, id, name, options) {
33
- const effortLevels = options.effortLevels ?? profile.effortLevels;
34
- return {
35
- harness: profile.harness, provider: options.provider ?? profile.provider, id, name,
36
- ...(options.isDefault ? { isDefault: true } : {}),
37
- // An explicit `reasoning: false` lets Cohub fit any requested level to `off`, so no `--effort` is sent.
38
- ...(options.reasoning ? { reasoning: true, thinkingLevelMap: thinkingLevelMapFor((level) => effortLevels.includes(level) ? level : null) } : { reasoning: false }),
39
- };
40
- }
41
- /** A session's file is found by id; the project directory naming is only the fast path. */
42
- async function findSession(profile, nativeSessionId, cwd) {
43
- const name = `${nativeSessionId}.jsonl`;
44
- const exists = (path) => access(path).then(() => true, () => false);
45
- const preferred = (() => { try {
46
- return join(profile.projectDirectory(cwd), name);
47
- }
48
- catch {
49
- return null;
50
- } })();
51
- if (preferred && await exists(preferred))
52
- return preferred;
53
- const projects = join(profile.dataRoot(), "projects");
54
- const entries = await readdir(projects, { withFileTypes: true }).catch((error) => { if (missing(error))
55
- return []; throw error; });
56
- for (const entry of entries) {
57
- const candidate = join(projects, entry.name, name);
58
- if (entry.isDirectory() && await exists(candidate))
59
- return candidate;
60
- }
61
- return null;
62
- }
63
- export function streamContent(value) {
64
- return array(value).flatMap((entry) => {
65
- const block = record(entry);
66
- if (block.type === "text")
67
- return [{ type: "text", text: text(block.text) }];
68
- if (block.type === "thinking")
69
- return [{ type: "thinking", thinking: text(block.thinking), ...(text(block.signature) ? { signature: text(block.signature) } : {}) }];
70
- if (block.type === "tool_use")
71
- return identifiable(block.id) && identifiable(block.name) ? [{ type: "tool_use", id: block.id, name: block.name, input: record(block.input) }] : [];
72
- const source = record(block.source);
73
- if (block.type === "image" && source.type === "base64")
74
- return [{ type: "image", source: { type: "base64", data: text(source.data), media_type: text(source.media_type) } }];
75
- return [];
76
- });
77
- }
78
- export function streamUsage(value, cost) {
79
- const usage = record(value);
80
- const count = (key) => typeof usage[key] === "number" ? usage[key] : 0;
81
- const input = count("input_tokens"), output = count("output_tokens"), cacheRead = count("cache_read_input_tokens"), cacheWrite = count("cache_creation_input_tokens");
82
- if (!input && !output && !cacheRead && !cacheWrite)
83
- return undefined;
84
- return { input, output, cacheRead, cacheWrite, totalTokens: input + output + cacheRead + cacheWrite, ...(typeof cost === "number" && cost > 0 ? { cost: { total: cost } } : {}) };
85
- }
86
- async function prompt(profile, input) {
87
- const content = await Promise.all(input.messages.flatMap((message) => message.content).map(async (block) => {
88
- if (block.type !== "image")
89
- return { type: "text", text: block.type === "text" ? block.text : JSON.stringify(block) };
90
- const image = await inlineImage(block);
91
- return { type: "image", source: { type: "base64", media_type: image.mimeType, data: image.data } };
92
- }));
93
- return { type: "user", ...(profile.promptUuid ? { uuid: input.turnId } : {}), message: { role: "user", content } };
94
- }
95
- /** Whether a session file already records this Turn's prompt (the CLI silently drops a repeated `uuid`). */
96
- async function holdsPrompt(path, turnId, signal) {
97
- const token = Buffer.from(`"uuid":"${turnId}"`);
98
- let tail = Buffer.alloc(0);
99
- try {
100
- for await (const chunk of createReadStream(path, { signal })) {
101
- const bytes = Buffer.concat([tail, chunk]);
102
- if (bytes.includes(token))
103
- return true;
104
- tail = bytes.subarray(Math.max(0, bytes.length - token.length + 1));
105
- }
106
- }
107
- catch (error) {
108
- if (!missing(error))
109
- throw error;
110
- }
111
- return false;
112
- }
113
- /** Maps stream-json output onto Cohub's streaming protocol; sub-agent traffic stays in the native transcript. */
114
- function streamJsonTranslator(emit, identity) {
115
- const messages = new Map();
116
- const owners = new Map();
117
- let current = null;
118
- let streaming = null;
119
- let model = identity.model;
120
- let final = null;
121
- const snapshot = (message) => ({
122
- ordinal: message.ordinal, content: [...message.content, ...message.partial.values()], provider: identity.provider, model: message.model ?? model,
123
- stopReason: message.content.some((block) => block.type === "tool_use") ? "tool_use" : "stop",
124
- });
125
- const begin = (id, messageModel) => {
126
- const existing = messages.get(id);
127
- if (existing)
128
- return existing;
129
- if (current)
130
- emit({ type: "message.commit", message: snapshot(current) });
131
- const message = { ordinal: messages.size, content: [], partial: new Map(), model: messageModel };
132
- messages.set(id, message);
133
- current = message;
134
- emit({ type: "message.start", ordinal: message.ordinal });
135
- return message;
136
- };
137
- const last = () => current ? snapshot(current) : { ordinal: 0, content: [], provider: identity.provider, model };
138
- return {
139
- /** The final `result`, or `null` while the Turn runs. */
140
- result: () => final,
141
- last,
142
- push(event) {
143
- if (event.parent_tool_use_id)
144
- return false;
145
- if (event.type === "system" && event.subtype === "init") {
146
- model = text(event.model) || model;
147
- return false;
148
- }
149
- if (event.type === "stream_event") {
150
- const stream = record(event.event);
151
- if (stream.type === "message_start")
152
- streaming = begin(text(record(stream.message).id) || randomUUID(), text(record(stream.message).model) || null);
153
- const delta = record(stream.delta);
154
- if (streaming && stream.type === "content_block_delta" && (delta.type === "text_delta" || delta.type === "thinking_delta")) {
155
- const index = Number(stream.index ?? 0), chunk = text(delta.text ?? delta.thinking);
156
- const previous = streaming.partial.get(index);
157
- streaming.partial.set(index, delta.type === "text_delta"
158
- ? { type: "text", text: (previous?.type === "text" ? previous.text : "") + chunk }
159
- : { type: "thinking", thinking: (previous?.type === "thinking" ? previous.thinking : "") + chunk });
160
- emit({ type: "text.delta", ordinal: streaming.ordinal, index, kind: delta.type === "text_delta" ? "text" : "thinking", delta: chunk });
161
- }
162
- return false;
163
- }
164
- if (event.type === "assistant") {
165
- const native = record(event.message);
166
- const message = begin(text(native.id) || randomUUID(), text(native.model) || null);
167
- // Complete blocks supersede what streamed so far.
168
- message.partial.clear();
169
- for (const block of streamContent(native.content)) {
170
- const index = block.type === "tool_use" ? message.content.findIndex((existing) => existing.type === "tool_use" && existing.id === block.id) : -1;
171
- if (index >= 0)
172
- message.content[index] = block;
173
- else
174
- message.content.push(block);
175
- if (block.type === "tool_use")
176
- owners.set(block.id, message);
177
- }
178
- emit({ type: "content.replace", ordinal: message.ordinal, content: [...message.content] });
179
- return false;
180
- }
181
- if (event.type === "user") {
182
- for (const entry of array(record(event.message).content)) {
183
- const block = record(entry);
184
- const id = text(block.tool_use_id);
185
- const owner = block.type === "tool_result" ? owners.get(id) : undefined;
186
- if (!owner)
187
- continue;
188
- owner.content = owner.content.filter((existing) => existing.type !== "tool_result" || existing.tool_use_id !== id);
189
- owner.content.push({ type: "tool_result", tool_use_id: id, content: typeof block.content === "string" ? block.content : streamContent(block.content), is_error: Boolean(block.is_error) });
190
- emit({ type: "content.replace", ordinal: owner.ordinal, content: [...owner.content] });
191
- }
192
- return false;
193
- }
194
- if (event.type !== "result")
195
- return false;
196
- const failed = event.is_error === true || event.subtype !== "success";
197
- final = {
198
- ...last(),
199
- stopReason: failed ? "error" : "stop",
200
- errorMessage: failed ? text(event.result) || array(event.errors).map(text).join("\n") || text(event.subtype) || "Turn failed" : null,
201
- usage: streamUsage(event.usage, event.total_cost_usd),
202
- };
203
- return true;
204
- },
205
- };
206
- }
207
- /**
208
- * One Turn per process. Cohub grants a permission prompt only through the profile's approvals;
209
- * otherwise workspace edits follow `acceptEdits` and every other tool the user's own rules.
210
- */
211
- export async function runStreamJson(profile, executor, turn) {
212
- const { input, signal, context } = turn;
213
- const prepare = (resumable) => executor.sessions.prepare({
214
- sessionId: input.sessionId, turnId: input.turnId, harness: profile.harness, cwd: executor.cwd,
215
- provider: input.provider, context: input.context, signal, resumable,
216
- });
217
- // Without a control plane, a terminal conversation is read-only: Cohub continues only files it wrote.
218
- let prepared = await prepare((transcript) => transcript.path !== turn.diverged && transcript.origin === "cohub");
219
- // A retried Turn whose prompt is already in the file would be dropped, so it continues from history.
220
- if (profile.promptUuid && prepared.resume === "native" && await holdsPrompt(prepared.session.path, input.turnId, signal))
221
- prepared = await prepare(() => false);
222
- let session = prepared.session;
223
- const approvals = await profile.approvals?.(executor, input) ?? null;
224
- // Cohub has already fitted the level to the levels the model declares; these CLIs have no `off` effort.
225
- const effort = isModelThinkingLevel(input.thinkingLevel) && input.thinkingLevel !== "off" ? input.thinkingLevel : null;
226
- const args = [
227
- "-p", "--input-format", "stream-json", "--output-format", "stream-json", "--verbose", "--include-partial-messages",
228
- ...(prepared.resume === "new" ? ["--session-id", session.nativeSessionId] : ["--resume", session.nativeSessionId]),
229
- ...(input.accessMode === "read_only" ? READ_ONLY_ARGS : approvals?.args ?? ["--permission-mode", "acceptEdits"]),
230
- ...(input.model && input.model !== DEFAULT_MODEL ? ["--model", input.model] : []),
231
- ...(effort ? ["--effort", effort] : []),
232
- ];
233
- const content = await prompt(profile, input);
234
- signal.throwIfAborted();
235
- const host = new JsonRpcProcess(...harnessCommand(executor.executables[profile.harness] || profile.binary, args, executor.cwd), executor.cwd, "stream", turnEnvironment(input));
236
- watchHost(host, executor.diagnostics, context);
237
- const translator = streamJsonTranslator(turn.emit, { provider: input.provider || profile.provider, model: input.model && input.model !== DEFAULT_MODEL ? input.model : null });
238
- let message = { ordinal: 0, content: [] };
239
- let begun = false;
240
- // Open approvals close with the process, not only when the Turn is stopped.
241
- const approvalScope = new AbortController();
242
- try {
243
- await turn.started(session);
244
- begun = true;
245
- await new Promise((resolve, reject) => {
246
- let escalation;
247
- let done = false;
248
- const finish = (error) => {
249
- if (done)
250
- return;
251
- done = true;
252
- off();
253
- offFailure();
254
- signal.removeEventListener("abort", abort);
255
- clearTimeout(escalation);
256
- approvalScope.abort();
257
- if (error)
258
- reject(error);
259
- else
260
- resolve();
261
- };
262
- const offFailure = host.onFailure((error) => finish(error));
263
- const off = host.onEvent((event) => {
264
- if (event.type === "control_request") {
265
- const respond = (response) => host.write({ type: "control_response", response: { subtype: "success", request_id: event.request_id, response } });
266
- const request = record(event.request);
267
- if (approvals?.answer && request.subtype === "can_use_tool" && input.accessMode !== "read_only") {
268
- void approvals.answer(request, AbortSignal.any([signal, approvalScope.signal]))
269
- .catch(() => ({ behavior: "deny", message: "Approval failed" }))
270
- .then((response) => {
271
- if (done)
272
- return;
273
- try {
274
- respond(response);
275
- }
276
- catch (error) {
277
- finish(error);
278
- }
279
- });
280
- return;
281
- }
282
- try {
283
- respond({ behavior: "deny", message: "Approval requires an interactive local client" });
284
- }
285
- catch (error) {
286
- finish(error);
287
- }
288
- return;
289
- }
290
- try {
291
- if (translator.push(event))
292
- finish();
293
- }
294
- catch (error) {
295
- finish(error);
296
- }
297
- });
298
- const abort = () => {
299
- try {
300
- host.write({ type: "control_request", request_id: randomUUID(), request: { subtype: "interrupt" } });
301
- }
302
- catch { /* Escalation closes the process. */ }
303
- escalation = setTimeout(() => void host.close().catch(() => undefined), ABORT_ESCALATION_MS);
304
- };
305
- signal.addEventListener("abort", abort, { once: true });
306
- try {
307
- host.write(content);
308
- }
309
- catch (error) {
310
- finish(error);
311
- }
312
- if (signal.aborted)
313
- abort();
314
- });
315
- message = translator.result() ?? translator.last();
316
- // A stopped Turn ends with an error result; the stop is not a failure to report.
317
- if (signal.aborted)
318
- message = { ...message, stopReason: "aborted", errorMessage: null };
319
- }
320
- catch (error) {
321
- if (!begun) {
322
- await closeHost(host, null).catch(() => undefined);
323
- throw error;
324
- }
325
- message = { ...translator.last(), stopReason: signal.aborted ? "aborted" : "error", errorMessage: signal.aborted ? null : describeError(error) };
326
- }
327
- // Closing input lets the CLI flush its transcript before the executor reaps the process.
328
- host.endInput();
329
- await host.exited(FLUSH_TIMEOUT_MS);
330
- const path = await findSession(profile, session.nativeSessionId, executor.cwd);
331
- if (path && (path !== session.path || prepared.resume === "new")) {
332
- session = { ...session, path };
333
- executor.ingest.adopt(session, input.sessionId);
334
- }
335
- return { session, resume: prepared.resume, message, host };
336
- }
@@ -1,117 +0,0 @@
1
- import type { ApprovalMode, LocalHarness, NativeProjection, ProjectionInput, ProjectionRecord, RuntimeCapabilities, RuntimeExecutionEvent, RuntimeMessage, RuntimeTurnInput } from "@neta-art/cohub";
2
- import type { JsonRpcProcess } from "../json-rpc.js";
3
- import type { RuntimeDiagnosticContext } from "../diagnostics.js";
4
- import type { Executor } from "../native/execution.js";
5
- import type { NativeSession, ResumeKind } from "../native/sessions.js";
6
- import type { NativeTranscript, NativeTranscriptTurn } from "../native/transcript.js";
7
- export type HarnessExecutables = Partial<Record<LocalHarness, string>>;
8
- export type HarnessModel = RuntimeCapabilities["models"][number];
9
- export type HarnessResult = {
10
- session: NativeSession;
11
- event: Extract<RuntimeExecutionEvent, {
12
- type: "turn.end";
13
- }>;
14
- uncertainCleanup?: {
15
- processGroupId: number;
16
- error: string;
17
- };
18
- };
19
- /** One Cohub Turn handed to an adapter. `started` must be awaited right before the prompt is sent. */
20
- export type HarnessTurn = {
21
- input: RuntimeTurnInput;
22
- emit: (event: RuntimeExecutionEvent) => void;
23
- signal: AbortSignal;
24
- /** A native file the server resolved as stopped; it is never continued. */
25
- diverged: string | null;
26
- started: (session: NativeSession) => Promise<void>;
27
- context?: RuntimeDiagnosticContext;
28
- };
29
- /** `host` is a process Cohub started for this Turn; the executor closes it. */
30
- export type HarnessRun = {
31
- session: NativeSession;
32
- resume: ResumeKind;
33
- message: RuntimeMessage;
34
- host: JsonRpcProcess | null;
35
- };
36
- export type ThreadKind = "user" | "internal" | "spawned";
37
- export type SessionHeader = {
38
- harness: LocalHarness;
39
- nativeSessionId: string;
40
- cwd: string;
41
- thread: ThreadKind;
42
- };
43
- /** Native session files: where they live, how Cohub history is written into them, and how archives restore. */
44
- export type NativeSessionFormat = {
45
- /** File for a new native session of `cwd`. */
46
- path(nativeSessionId: string, cwd: string): string;
47
- /** An empty session is created by the harness itself instead of a projected file. */
48
- startsWithoutFile: boolean;
49
- project(input: ProjectionInput): NativeProjection;
50
- /** Rewrite the session identity of a full projection. */
51
- rebind(records: ProjectionRecord[], nativeSessionId: string): ProjectionRecord[];
52
- /** Absent when the native state is not one file Cohub can carry; history is then projected again. */
53
- archive?: {
54
- /** Working-copy path of a restored archive; `id` is fresh, `nativeSessionId` the archived one. */
55
- target(input: {
56
- id: string;
57
- nativeSessionId: string;
58
- cwd: string;
59
- }): string;
60
- /** Copy raw archive bytes to `target`, adjusting only the header; returns the copy's session id. */
61
- import(input: NativeArchiveImport): Promise<{
62
- checksum: string;
63
- nativeSessionId: string;
64
- }>;
65
- };
66
- };
67
- export type NativeArchiveImport = {
68
- source: string;
69
- target: string;
70
- nativeSessionId: string;
71
- id: string;
72
- cwd: string;
73
- signal?: AbortSignal;
74
- };
75
- /** Reading a harness's own transcripts: native sync, import and receipt-less recovery. */
76
- export type NativeTranscriptFormat = {
77
- roots(): string[];
78
- /** Whether a directory found under a root can hold transcripts of `cwd`. */
79
- acceptsDirectory(path: string, root: string, cwd: string): boolean;
80
- /** Name-only check: can this path hold a transcript of `cwd`? */
81
- acceptsTranscript(path: string, cwd: string): boolean;
82
- header(path: string, signal?: AbortSignal): Promise<SessionHeader | null>;
83
- /** Parse into Turns. Without `turnEndRecorded`, the tail is parsed as settled and withdrawn by the caller while in flight. */
84
- read(path: string, signal?: AbortSignal): Promise<NativeTranscript>;
85
- /** Record substrings that begin or end a Turn; new bytes without one need no parse. */
86
- boundaries: string[];
87
- /** The file records each Turn's end, so a Turn without a result is still running. */
88
- turnEndRecorded: boolean;
89
- /** Otherwise: whether the tail's last reply ended (a quiet period then settles it). */
90
- replyEnded?(turn: NativeTranscriptTurn): boolean;
91
- /** The prompt is recorded in steps and marked final (`userFinal`); a Turn is sent only once it is. */
92
- userFinalMarked: boolean;
93
- /** Turn keys are unique across sessions (forks share their history's Turns). */
94
- globalTurnKeys: boolean;
95
- /**
96
- * A Turn Cohub runs carries its Cohub Turn id in the file (`cloudTurnId`). Otherwise the ledger
97
- * records which Turn Cohub is running, and a Cohub file's Turns up to its end are taken as the server's.
98
- */
99
- marksCohubTurns: boolean;
100
- /** Plain JSONL bytes for archival when the file itself is stored differently. */
101
- archiveSource?(path: string, cacheDirectory: string): Promise<string>;
102
- };
103
- export type LocalHarnessAdapter = {
104
- id: LocalHarness;
105
- /** Executable looked up on PATH unless overridden. */
106
- binary: string;
107
- /** Fails when the harness cannot run; with `strict`, also instead of falling back to a reduced catalog. */
108
- models(executable: string, cwd: string, options?: {
109
- strict?: boolean;
110
- }): Promise<HarnessModel[]>;
111
- /** Approval modes this installation enforces; absent or empty hides the choice. */
112
- approvalModes?(executable: string, cwd: string): Promise<ApprovalMode[]>;
113
- run(executor: Executor, turn: HarnessTurn): Promise<HarnessRun>;
114
- session: NativeSessionFormat;
115
- /** Every harness reads its own transcripts, so terminal conversations sync to the Space. */
116
- transcript: NativeTranscriptFormat;
117
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import { type NativeTranscript } from "../native/transcript.js";
2
- export declare const WORKBUDDY_REPLY_ENDED: string[];
3
- /**
4
- * CodeBuddy stores Responses-style items linked by `parentId`: a user message starts a Turn, and each
5
- * model step (`providerData.messageId`) is one message. Interactive sessions record each end
6
- * (`turn-metrics`, outside the chain); `-p` sessions do not.
7
- */
8
- export declare function readWorkbuddyTranscript(path: string, nativeSessionId: string, signal?: AbortSignal): Promise<NativeTranscript>;
@@ -1,127 +0,0 @@
1
- import { record } from "../json-rpc.js";
2
- import { iso } from "../native/transcript.js";
3
- import { chainBranch, extendTurn, readChainedLines, startTurn } from "./chained-transcript.js";
4
- import { array, identifiable, text } from "./process.js";
5
- import { streamUsage } from "./stream-json.js";
6
- export const WORKBUDDY_REPLY_ENDED = ["stop", "aborted", "error"];
7
- const INTERRUPTED = "Interrupted by user";
8
- function items(value) {
9
- return array(value).flatMap((entry) => {
10
- const block = record(entry);
11
- if (["input_text", "output_text", "text"].includes(text(block.type)))
12
- return text(block.text) ? [{ type: "text", text: text(block.text) }] : [];
13
- if (block.type === "reasoning_text")
14
- return text(block.text) ? [{ type: "thinking", thinking: text(block.text) }] : [];
15
- const image = text(block.image) || text(block.image_url);
16
- if (block.type === "input_image" && image) {
17
- const data = /^data:([^;]+);base64,(.*)$/s.exec(image);
18
- return [{ type: "image", source: data ? { type: "base64", media_type: data[1] ?? "image/png", data: data[2] ?? "" } : { type: "url", url: image } }];
19
- }
20
- return [];
21
- });
22
- }
23
- function toolOutput(value) {
24
- if (typeof value === "string")
25
- return value;
26
- const output = record(value);
27
- if (output.type === "text")
28
- return text(output.text);
29
- return Array.isArray(value) ? items(value) : JSON.stringify(value ?? null);
30
- }
31
- /**
32
- * CodeBuddy stores Responses-style items linked by `parentId`: a user message starts a Turn, and each
33
- * model step (`providerData.messageId`) is one message. Interactive sessions record each end
34
- * (`turn-metrics`, outside the chain); `-p` sessions do not.
35
- */
36
- export async function readWorkbuddyTranscript(path, nativeSessionId, signal) {
37
- const read = await readChainedLines(path, signal);
38
- const linked = (value) => value.type === "message" || "parentId" in value;
39
- const branch = chainBranch(read.lines, (value) => linked(value) ? text(value.id) : "", (value) => text(value.parentId));
40
- const metricsAt = read.lines.reduce((latest, line) => line.value.type === "turn-metrics" ? line.startBytes : latest, -1);
41
- const turns = [];
42
- const owners = new Map();
43
- const steps = new Map();
44
- let cwd = "", cloudSessionId = "", completedAt = "";
45
- let current = null;
46
- const finish = () => {
47
- if (!current)
48
- return;
49
- const last = current.messages.at(-1);
50
- const status = !last || last.stopReason === "aborted" || last.stopReason === "tool_use" ? "interrupted" : last.stopReason === "error" ? "failed" : "completed";
51
- current.result = { messages: current.messages, completedAt: completedAt || current.startedAt, status };
52
- turns.push(current);
53
- current = null;
54
- };
55
- for (const line of branch) {
56
- const value = line.value;
57
- cwd ||= text(value.cwd);
58
- if (value.type === "message" && value.role === "user") {
59
- finish();
60
- const cohub = record(value.cohub);
61
- cloudSessionId ||= text(cohub.sessionId);
62
- current = startTurn(line, text(value.id), turns.at(-1)?.key ?? null, items(value.content), text(cohub.turnId));
63
- completedAt = current.startedAt;
64
- owners.clear();
65
- steps.clear();
66
- continue;
67
- }
68
- if (!current)
69
- continue;
70
- const provider = record(value.providerData);
71
- const step = text(provider.messageId);
72
- const message = () => {
73
- let target = step ? steps.get(step) : undefined;
74
- if (!target) {
75
- target = { content: [], provider: null, model: text(provider.model) || null, stopReason: null, errorMessage: null };
76
- current?.messages.push(target);
77
- if (step)
78
- steps.set(step, target);
79
- }
80
- return target;
81
- };
82
- if (value.type === "message" && value.role === "assistant") {
83
- const target = message();
84
- target.content.push(...items(value.content));
85
- const usage = streamUsage(record(value.message).usage, undefined);
86
- if (usage)
87
- target.usage = usage;
88
- const error = text(record(provider.error).message);
89
- target.stopReason = value.status === "incomplete" ? error === INTERRUPTED ? "aborted" : "error" : "stop";
90
- if (target.stopReason === "error")
91
- target.errorMessage = error || "Turn failed";
92
- if (target.stopReason === "aborted")
93
- current.ended = true;
94
- }
95
- else if (value.type === "reasoning") {
96
- message().content.push(...items(value.rawContent), ...items(value.content).filter((block) => block.type === "thinking"));
97
- }
98
- else if (value.type === "function_call" && identifiable(value.callId) && identifiable(value.name)) {
99
- let input;
100
- try {
101
- input = record(JSON.parse(text(value.arguments)));
102
- }
103
- catch {
104
- input = { raw: value.arguments };
105
- }
106
- const target = message();
107
- target.content.push({ type: "tool_use", id: value.callId, name: value.name, input });
108
- target.stopReason = "tool_use";
109
- const usage = streamUsage(record(value.message).usage, undefined);
110
- if (usage)
111
- target.usage = usage;
112
- owners.set(value.callId, target);
113
- }
114
- else if (value.type === "function_call_result") {
115
- const id = text(value.callId);
116
- owners.get(id)?.content.push({ type: "tool_result", tool_use_id: id, content: toolOutput(value.output) });
117
- }
118
- if (typeof value.timestamp === "number" || typeof value.timestamp === "string")
119
- completedAt = iso(value.timestamp);
120
- extendTurn(current, line, true);
121
- }
122
- const tail = current;
123
- if (tail && metricsAt >= tail.contentEndBytes)
124
- tail.ended = true;
125
- finish();
126
- return { nativeSessionId, cwd, ...(cloudSessionId ? { cloudSessionId } : {}), turns, prefixes: read.prefixes };
127
- }
@@ -1,21 +0,0 @@
1
- import type { LocalHarnessAdapter } from "./types.js";
2
- /** Mirrors CodeBuddy's project naming, including its truncation hash for long paths. */
3
- export declare function workbuddyProjectName(cwd: string): string;
4
- /** The CLI lists selectable models (built-in and `models.json`) in its `--model` help. */
5
- export declare function workbuddyModels(help: string): {
6
- harness: "claude" | "codex" | "cursor" | "pi" | "workbuddy";
7
- provider: string;
8
- id: string;
9
- name: string;
10
- isDefault?: boolean | undefined;
11
- reasoning?: boolean | undefined;
12
- defaultThinkingLevel?: "high" | "low" | "max" | "medium" | "minimal" | "off" | "ultra" | "xhigh" | undefined;
13
- thinkingLevelMap?: Partial<Record<"high" | "low" | "max" | "medium" | "minimal" | "off" | "ultra" | "xhigh", string | null>> | undefined;
14
- serviceTiers?: {
15
- id: string;
16
- name: string;
17
- description?: string | undefined;
18
- }[] | undefined;
19
- defaultServiceTier?: string | undefined;
20
- }[];
21
- export declare const workbuddyHarness: LocalHarnessAdapter;