@neta-art/cohub-cli 10.24.0 → 10.25.1

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/bin/cohub.js +4 -1
  2. package/dist/board-gpu/page.js +1566 -71230
  3. package/dist/bootstrap.js +67 -27
  4. package/dist/build.json +1 -1
  5. package/dist/{board-kernel/FilterPipe.js → chunks/Geometry.js} +10447 -10469
  6. package/dist/chunks/about.js +102 -0
  7. package/dist/chunks/app-realtime.js +2216 -0
  8. package/dist/chunks/app-realtime2.js +2 -0
  9. package/dist/chunks/app-ref.js +88 -0
  10. package/dist/chunks/apps.js +1423 -0
  11. package/dist/chunks/auth.js +175 -0
  12. package/dist/chunks/avatar.js +146 -0
  13. package/dist/chunks/binary-pins.js +5 -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 +311 -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 +2513 -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 -121
  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 -141
  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 -2170
  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 -10
  354. package/dist/session-status.js +0 -25
  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,46 +0,0 @@
1
- import type { ContentBlock, NativeTurnProgress, RuntimeExecutionEvent, RuntimeMessage } from "@neta-art/cohub";
2
- import { type JsonRecord } from "../json-rpc.js";
3
- export declare function piContent(value: unknown): ContentBlock[];
4
- export declare function codexItemContent(item: JsonRecord): ContentBlock[];
5
- /** Harness events mapped onto Cohub's streaming protocol. */
6
- export type Translator = {
7
- push(event: JsonRecord): boolean;
8
- last(): RuntimeMessage;
9
- };
10
- /** Pi emits the same event shapes to its extensions as over RPC. */
11
- export declare function piTranslator(emit: (event: RuntimeExecutionEvent) => void): Translator;
12
- /** Codex app-server notifications for one Turn of one thread. */
13
- export declare function codexTranslator(emit: (event: RuntimeExecutionEvent) => void, identity: {
14
- provider: string | null;
15
- model: string | null;
16
- }): Translator;
17
- type PreviewMessage = {
18
- content: ContentBlock[];
19
- provider: string | null;
20
- model: string | null;
21
- };
22
- /** Where progress goes; `null` while the Turn is not yet recorded, so nothing can be sent yet. */
23
- export type ProgressSink = (progress: NativeTurnProgress) => Promise<unknown> | null;
24
- /**
25
- * The live preview of a Turn a terminal user runs: harness events folded into messages and sent as
26
- * ephemeral progress, at most once per interval and only from the first message that changed.
27
- */
28
- export declare class LiveProgress {
29
- private readonly sink;
30
- private readonly intervalMs;
31
- private messages;
32
- private dirtyFrom;
33
- private synced;
34
- private timer;
35
- private inFlight;
36
- private disposed;
37
- constructor(sink: ProgressSink, intervalMs: number);
38
- apply(event: RuntimeExecutionEvent): void;
39
- replace(messages: PreviewMessage[]): void;
40
- dispose(): void;
41
- private touched;
42
- private schedule;
43
- private flush;
44
- private at;
45
- }
46
- export {};
@@ -1,299 +0,0 @@
1
- import { codexTokenTotals, codexUsage, subtractCodexTokens } from "../codex-usage.js";
2
- import { identifiable } from "../harnesses/process.js";
3
- import { record } from "../json-rpc.js";
4
- const text = (value) => typeof value === "string" ? value : "";
5
- const list = (value) => Array.isArray(value) ? value : [];
6
- const hasToolCall = (content, id) => content.some((block) => block.type === "tool_use" && block.id === id);
7
- export function piContent(value) {
8
- return list(value).flatMap((entry) => {
9
- const block = record(entry);
10
- if (block.type === "text")
11
- return [{ type: "text", text: text(block.text) }];
12
- if (block.type === "thinking")
13
- return [{ type: "thinking", thinking: text(block.thinking), ...(typeof (block.thinkingSignature ?? block.signature) === "string" ? { signature: String(block.thinkingSignature ?? block.signature) } : {}) }];
14
- if (block.type === "toolCall")
15
- return identifiable(block.id) && identifiable(block.name) ? [{ type: "tool_use", id: block.id, name: block.name, input: record(block.arguments) }] : [];
16
- if (block.type === "image")
17
- return [{ type: "image", source: { type: "base64", data: text(block.data), media_type: text(block.mimeType) } }];
18
- return [{ type: "text", text: JSON.stringify(block) }];
19
- });
20
- }
21
- export function codexItemContent(item) {
22
- if (item.type === "agentMessage" || item.type === "plan")
23
- return [{ type: "text", text: text(item.text) }];
24
- if (item.type === "reasoning")
25
- return [{ type: "thinking", thinking: [...list(item.summary), ...list(item.content)].map(text).join("\n") }];
26
- if (item.type === "userMessage")
27
- return [];
28
- if (item.type === "contextCompaction")
29
- return [{ type: "system_note", note_type: "compacted", text: "Context compacted" }];
30
- const id = item.id;
31
- if (!identifiable(id))
32
- return [];
33
- const name = item.type === "commandExecution" ? "bash" : item.type === "fileChange" ? "apply_patch" : text(item.tool) || text(item.type);
34
- const input = item.type === "commandExecution" ? { command: item.command, cwd: item.cwd } : item.type === "fileChange" ? { changes: item.changes } : record(item.arguments);
35
- return [
36
- { type: "tool_use", id, name, input },
37
- { type: "tool_result", tool_use_id: id, content: typeof item.aggregatedOutput === "string" ? item.aggregatedOutput : JSON.stringify(item.result ?? item.error ?? item.changes ?? item), is_error: item.status === "failed" || typeof item.exitCode === "number" && item.exitCode !== 0 },
38
- ];
39
- }
40
- /** Pi emits the same event shapes to its extensions as over RPC. */
41
- export function piTranslator(emit) {
42
- let ordinal = -1;
43
- let current = [];
44
- let last = { ordinal: 0, content: [] };
45
- return {
46
- last: () => last,
47
- push(event) {
48
- const type = text(event.type);
49
- const message = record(event.message);
50
- if (type === "message_start" && message.role === "assistant") {
51
- ordinal += 1;
52
- current = [];
53
- emit({ type: "message.start", ordinal });
54
- }
55
- if (type === "message_end" && message.role === "assistant") {
56
- current = piContent(message.content);
57
- emit({ type: "content.replace", ordinal, content: current });
58
- }
59
- const toolCallId = text(event.toolCallId);
60
- if (type === "tool_execution_start") {
61
- if (identifiable(toolCallId) && identifiable(event.toolName) && !hasToolCall(current, toolCallId)) {
62
- current.push({ type: "tool_use", id: toolCallId, name: event.toolName, input: record(event.args), _meta: { toolStatus: "running" } });
63
- emit({ type: "content.replace", ordinal, content: [...current] });
64
- }
65
- }
66
- if ((type === "tool_execution_update" || type === "tool_execution_end") && hasToolCall(current, toolCallId)) {
67
- const raw = type === "tool_execution_end" ? event.result : event.partialResult;
68
- const resultContent = typeof raw === "string" ? raw : piContent(record(raw).content);
69
- current = current.filter((block) => block.type !== "tool_result" || block.tool_use_id !== toolCallId);
70
- current.push({ type: "tool_result", tool_use_id: toolCallId, content: resultContent, is_error: Boolean(event.isError), _meta: { toolStatus: type === "tool_execution_end" ? "done" : "running" } });
71
- emit({ type: "content.replace", ordinal, content: [...current] });
72
- }
73
- if (type === "message_update") {
74
- const delta = record(event.assistantMessageEvent);
75
- if (delta.type === "text_delta" || delta.type === "thinking_delta")
76
- emit({ type: "text.delta", ordinal, index: Number(delta.contentIndex ?? 0), kind: delta.type === "text_delta" ? "text" : "thinking", delta: text(delta.delta) });
77
- }
78
- if (type === "turn_end") {
79
- const content = piContent(message.content);
80
- for (const value of list(event.toolResults)) {
81
- const result = record(value);
82
- const id = text(result.toolCallId);
83
- if (hasToolCall(content, id))
84
- content.push({ type: "tool_result", tool_use_id: id, content: typeof result.content === "string" ? result.content : piContent(result.content), is_error: Boolean(result.isError) });
85
- }
86
- const stopReason = text(message.stopReason);
87
- last = { ordinal: Math.max(0, ordinal), content, provider: text(message.provider) || null, model: text(message.model) || null, usage: message.usage, stopReason: stopReason === "toolUse" ? "tool_use" : stopReason || "stop", errorMessage: text(message.errorMessage) || null };
88
- emit({ type: "content.replace", ordinal: last.ordinal, content });
89
- if (last.stopReason === "tool_use")
90
- emit({ type: "message.commit", message: last });
91
- }
92
- // The run ends when Pi settles: an automatic retry or compaction continues after `agent_end`,
93
- // and extensions are not told whether one follows.
94
- return type === "agent_settled" || type === "agent_end" && event.willRetry === false;
95
- },
96
- };
97
- }
98
- /** Codex app-server notifications for one Turn of one thread. */
99
- export function codexTranslator(emit, identity) {
100
- let ordinal = -1;
101
- const items = new Map();
102
- const ordinals = new Map();
103
- const outputs = new Map();
104
- const completed = new Set();
105
- let pending = null;
106
- let final = { ordinal: 0, content: [] };
107
- let usage;
108
- let baseline;
109
- const { provider, model } = identity;
110
- const latest = () => {
111
- if (pending && pending.ordinal >= ordinal)
112
- return pending;
113
- const item = [...items.entries()].find(([id]) => ordinals.get(id) === ordinal)?.[1];
114
- return { ordinal: Math.max(0, ordinal), content: item ? codexItemContent(item) : [] };
115
- };
116
- return {
117
- last: () => usage ? { ...final, usage } : final,
118
- push(event) {
119
- const method = text(event.method);
120
- const params = record(event.params);
121
- if (method === "thread/tokenUsage/updated") {
122
- const tokenUsage = record(params.tokenUsage);
123
- const total = codexTokenTotals(tokenUsage.total);
124
- baseline ??= subtractCodexTokens(total, codexTokenTotals(tokenUsage.last));
125
- usage = codexUsage(subtractCodexTokens(total, baseline));
126
- }
127
- if (method === "item/started") {
128
- const item = record(params.item);
129
- if (item.type === "userMessage" || completed.has(text(item.id)))
130
- return false;
131
- const existing = ordinals.get(text(item.id));
132
- if (pending && (existing == null || existing > pending.ordinal)) {
133
- emit({ type: "message.commit", message: pending });
134
- pending = null;
135
- }
136
- if (existing != null) {
137
- items.set(text(item.id), item);
138
- if (item.type === "agentMessage" && text(item.text))
139
- emit({ type: "content.replace", ordinal: existing, content: codexItemContent(item) });
140
- return false;
141
- }
142
- ordinal += 1;
143
- ordinals.set(text(item.id), ordinal);
144
- items.set(text(item.id), item);
145
- emit({ type: "message.start", ordinal });
146
- if (!["agentMessage", "reasoning", "plan"].includes(text(item.type)))
147
- emit({ type: "content.replace", ordinal, content: codexItemContent(item).filter((block) => block.type !== "tool_result") });
148
- }
149
- if (method === "item/agentMessage/delta" || method === "item/reasoning/textDelta" || method === "item/reasoning/summaryTextDelta") {
150
- const id = text(params.itemId);
151
- if (completed.has(id))
152
- return false;
153
- const itemOrdinal = ordinals.get(id);
154
- const item = items.get(id);
155
- if (item) {
156
- if (method === "item/agentMessage/delta")
157
- item.text = text(item.text) + text(params.delta);
158
- else {
159
- const key = method.includes("summary") ? "summary" : "content";
160
- item[key] = [list(item[key]).map(text).join("\n") + text(params.delta)];
161
- }
162
- }
163
- if (itemOrdinal != null)
164
- emit({ type: "text.delta", ordinal: itemOrdinal, index: 0, kind: method === "item/agentMessage/delta" ? "text" : "thinking", delta: text(params.delta) });
165
- }
166
- if (method === "item/commandExecution/outputDelta") {
167
- const id = text(params.itemId);
168
- const item = items.get(id);
169
- const itemOrdinal = ordinals.get(id);
170
- if (item && itemOrdinal != null) {
171
- const output = (outputs.get(id) ?? "") + text(params.delta);
172
- outputs.set(id, output);
173
- item.aggregatedOutput = output;
174
- emit({ type: "content.replace", ordinal: itemOrdinal, content: codexItemContent(item) });
175
- }
176
- }
177
- if (method === "item/completed") {
178
- const item = record(params.item);
179
- if (item.type === "userMessage" || completed.has(text(item.id)))
180
- return false;
181
- completed.add(text(item.id));
182
- const itemOrdinal = ordinals.get(text(item.id)) ?? ++ordinal;
183
- if (!ordinals.has(text(item.id))) {
184
- ordinals.set(text(item.id), itemOrdinal);
185
- emit({ type: "message.start", ordinal: itemOrdinal });
186
- }
187
- items.set(text(item.id), item);
188
- const message = { ordinal: itemOrdinal, content: codexItemContent(item), provider, model, stopReason: "stop" };
189
- emit({ type: "content.replace", ordinal: itemOrdinal, content: message.content });
190
- if (pending && pending.ordinal > itemOrdinal)
191
- emit({ type: "message.commit", message });
192
- else {
193
- if (pending && pending.ordinal !== itemOrdinal)
194
- emit({ type: "message.commit", message: pending });
195
- pending = message;
196
- }
197
- }
198
- if (method === "turn/completed") {
199
- const turn = record(params.turn);
200
- final = { ...latest(), provider, model, stopReason: turn.status === "interrupted" ? "aborted" : turn.status === "failed" ? "error" : "stop", errorMessage: text(record(turn.error).message) || null };
201
- return true;
202
- }
203
- return false;
204
- },
205
- };
206
- }
207
- /**
208
- * Revisions only grow, across every preview of this process: the server keeps the highest one, so a
209
- * preview restarted within the same millisecond, or after the clock stepped back, still lands.
210
- */
211
- let lastRevision = 0;
212
- const nextRevision = () => (lastRevision = Math.max(Date.now(), lastRevision + 1));
213
- /**
214
- * The live preview of a Turn a terminal user runs: harness events folded into messages and sent as
215
- * ephemeral progress, at most once per interval and only from the first message that changed.
216
- */
217
- export class LiveProgress {
218
- sink;
219
- intervalMs;
220
- messages = [];
221
- dirtyFrom = Number.POSITIVE_INFINITY;
222
- synced = false;
223
- timer = null;
224
- inFlight = false;
225
- disposed = false;
226
- constructor(sink, intervalMs) {
227
- this.sink = sink;
228
- this.intervalMs = intervalMs;
229
- }
230
- apply(event) {
231
- const ordinal = event.type === "message.start" || event.type === "content.replace" || event.type === "text.delta" ? event.ordinal
232
- : event.type === "message.commit" || event.type === "turn.end" ? event.message.ordinal : null;
233
- if (ordinal === null)
234
- return;
235
- const target = this.at(ordinal);
236
- if (event.type === "content.replace")
237
- target.content = event.content;
238
- if (event.type === "message.commit" || event.type === "turn.end")
239
- Object.assign(target, { content: event.message.content, provider: event.message.provider ?? null, model: event.message.model ?? null });
240
- if (event.type === "text.delta") {
241
- const block = target.content[event.index];
242
- if (event.kind === "text")
243
- target.content[event.index] = block?.type === "text" ? { ...block, text: block.text + event.delta } : { type: "text", text: event.delta };
244
- else
245
- target.content[event.index] = block?.type === "thinking" ? { ...block, thinking: block.thinking + event.delta } : { type: "thinking", thinking: event.delta };
246
- }
247
- this.touched(ordinal);
248
- }
249
- replace(messages) {
250
- const first = messages.findIndex((message, index) => JSON.stringify(message) !== JSON.stringify(this.messages[index]));
251
- if (first < 0 && messages.length === this.messages.length)
252
- return;
253
- this.messages = messages.map((message) => ({ ...message, content: [...message.content] }));
254
- this.touched(first < 0 ? messages.length : first);
255
- }
256
- dispose() {
257
- this.disposed = true;
258
- if (this.timer)
259
- clearTimeout(this.timer);
260
- this.timer = null;
261
- }
262
- touched(ordinal) {
263
- this.dirtyFrom = Math.min(this.dirtyFrom, ordinal);
264
- this.schedule();
265
- }
266
- schedule() {
267
- if (this.disposed || this.inFlight)
268
- return;
269
- this.timer ??= setTimeout(() => { this.timer = null; this.flush(); }, this.intervalMs);
270
- this.timer.unref?.();
271
- }
272
- flush() {
273
- if (this.disposed || !Number.isFinite(this.dirtyFrom))
274
- return;
275
- const from = this.synced ? Math.min(this.dirtyFrom, this.messages.length) : 0;
276
- const sent = this.sink({ revision: nextRevision(), from, messages: this.messages.slice(from) });
277
- // Not yet recorded: stay dirty, the next event tries again.
278
- if (!sent)
279
- return;
280
- this.dirtyFrom = Number.POSITIVE_INFINITY;
281
- this.synced = true;
282
- this.inFlight = true;
283
- void sent.then((result) => {
284
- const outcome = result;
285
- if (outcome?.accepted === false || outcome?.resync)
286
- this.synced = false;
287
- }, () => { this.synced = false; }).finally(() => {
288
- this.inFlight = false;
289
- // Whatever changed meanwhile goes next; after a refusal, the next send is a full one.
290
- if (Number.isFinite(this.dirtyFrom))
291
- this.schedule();
292
- });
293
- }
294
- at(ordinal) {
295
- for (let index = this.messages.length; index <= ordinal; index += 1)
296
- this.messages[index] = { content: [], provider: null, model: null };
297
- return this.messages[ordinal];
298
- }
299
- }
@@ -1,7 +0,0 @@
1
- import type { NativeRuntimeEvent } from "@neta-art/cohub";
2
- import type { IngestTransport } from "./ingest.js";
3
- /**
4
- * Transcript ingest travels over the existing Runtime WebSocket: one connection, one credential, no
5
- * second channel and no local receipts.
6
- */
7
- export declare function nativeWebSocketTransport(send: (event: NativeRuntimeEvent) => Promise<unknown>): IngestTransport;
@@ -1,16 +0,0 @@
1
- /**
2
- * Transcript ingest travels over the existing Runtime WebSocket: one connection, one credential, no
3
- * second channel and no local receipts.
4
- */
5
- export function nativeWebSocketTransport(send) {
6
- const call = async (event, options) => {
7
- options?.signal?.throwIfAborted();
8
- return await send(event);
9
- };
10
- return {
11
- ingest: (event, options) => call(event, options),
12
- known: async (turnIds, options) => (await call({ type: "known", input: { turnIds } }, options)).turns,
13
- progress: (event, options) => call(event, options),
14
- status: (sessionId, turnId, controllable, options) => call({ type: "status", sessionId, turnId, ...(controllable === undefined ? {} : { controllable }) }, options),
15
- };
16
- }
@@ -1,5 +0,0 @@
1
- export type Version = readonly [number, number, number];
2
- /** A harness binary's own version, or `null` when it cannot say. */
3
- export declare function harnessVersion(binary: string): Promise<Version | null>;
4
- export declare function atLeast(version: Version | null, minimum: Version): boolean;
5
- export declare const formatVersion: (version: Version | null) => string;
@@ -1,21 +0,0 @@
1
- import { execFile } from "node:child_process";
2
- import { promisify } from "node:util";
3
- import { harnessCommand } from "../harnesses/process.js";
4
- /** A harness binary's own version, or `null` when it cannot say. */
5
- export async function harnessVersion(binary) {
6
- const { stdout } = await Promise.resolve()
7
- .then(() => promisify(execFile)(...harnessCommand(binary, ["--version"], process.cwd()), { encoding: "utf8", timeout: 15_000, windowsHide: true }))
8
- .catch(() => ({ stdout: "" }));
9
- const match = /(\d+)\.(\d+)\.(\d+)/.exec(stdout);
10
- return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
11
- }
12
- export function atLeast(version, minimum) {
13
- if (!version)
14
- return false;
15
- for (let index = 0; index < 3; index += 1) {
16
- if (version[index] !== minimum[index])
17
- return (version[index] ?? 0) > (minimum[index] ?? 0);
18
- }
19
- return true;
20
- }
21
- export const formatVersion = (version) => version?.join(".") ?? "(unknown version)";
@@ -1,7 +0,0 @@
1
- type RuntimePreferences = {
2
- keepAwake: boolean;
3
- };
4
- export declare const runtimePreferencesPath: () => string;
5
- export declare function readRuntimePreferences(path?: string): Promise<RuntimePreferences>;
6
- export declare function writeRuntimePreferences(preferences: RuntimePreferences, path?: string): Promise<void>;
7
- export {};
@@ -1,22 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
3
- import { homedir } from "node:os";
4
- import { dirname, join } from "node:path";
5
- const DEFAULTS = { keepAwake: true };
6
- export const runtimePreferencesPath = () => join(homedir(), ".config", "cohub", "runtime-preferences.json");
7
- export async function readRuntimePreferences(path = runtimePreferencesPath()) {
8
- const stored = await readFile(path, "utf8").then(JSON.parse).catch(() => null);
9
- const keepAwake = stored?.keepAwake;
10
- return { keepAwake: typeof keepAwake === "boolean" ? keepAwake : DEFAULTS.keepAwake };
11
- }
12
- export async function writeRuntimePreferences(preferences, path = runtimePreferencesPath()) {
13
- await mkdir(dirname(path), { recursive: true, mode: 0o700 });
14
- const temporary = `${path}.${randomUUID()}.tmp`;
15
- try {
16
- await writeFile(temporary, `${JSON.stringify(preferences, null, 2)}\n`, { mode: 0o600, flag: "wx" });
17
- await rename(temporary, path);
18
- }
19
- finally {
20
- await rm(temporary, { force: true });
21
- }
22
- }
@@ -1,32 +0,0 @@
1
- import type { NativeConfig } from "./native/config.js";
2
- import type { NativeStatus } from "./native/daemon.js";
3
- import type { RuntimeDiagnostic, RuntimeDiagnosticLevel } from "./diagnostics.js";
4
- export declare const diagnosticLevels: RuntimeDiagnosticLevel[];
5
- export declare const atLeastLevel: (level: RuntimeDiagnosticLevel, minimum: RuntimeDiagnosticLevel) => boolean;
6
- export declare const runtimeWebUrl: (spaceId: string) => string;
7
- export declare function formatDiagnostic(event: RuntimeDiagnostic, verbose?: boolean): string;
8
- /** File logs retain every event; repeated terminal warnings are coalesced. */
9
- export declare function createDiagnosticConsole(verbose?: boolean, write?: (line: string) => boolean): (event: RuntimeDiagnostic) => void;
10
- export type RuntimeSummary = {
11
- spaceId: string;
12
- runtimeId: string;
13
- root: string;
14
- harnesses: string[];
15
- pid: number;
16
- version?: string;
17
- state: "starting" | "ready" | "reconnecting" | "attention" | "stopping";
18
- harnessConnected: boolean;
19
- workspaceConnected: boolean;
20
- diagnosticsPath: string;
21
- background: boolean;
22
- display?: string;
23
- displayOnRequest?: boolean;
24
- displayNeeds?: string[];
25
- direct?: boolean;
26
- native?: NativeStatus;
27
- };
28
- export declare function printRuntimeSummary(summary: RuntimeSummary, json?: boolean, reused?: boolean): void;
29
- /** One line of import progress: files and bytes, with an estimate once enough is known. */
30
- export declare function formatImportProgress(job: NativeStatus["import"], now?: number): string;
31
- /** `runtime status` native block: what syncs, what can be driven, and backfill progress. */
32
- export declare function formatNativeSync(config: NativeConfig | null, native: NativeStatus | undefined, error?: string | null): string;
@@ -1,124 +0,0 @@
1
- import { LOCAL_HARNESS_SPECS } from "@neta-art/cohub";
2
- import { webUrl } from "../web.js";
3
- export const diagnosticLevels = ["debug", "info", "warn", "error"];
4
- export const atLeastLevel = (level, minimum) => diagnosticLevels.indexOf(level) >= diagnosticLevels.indexOf(minimum);
5
- export const runtimeWebUrl = (spaceId) => webUrl(`/spaces/${spaceId}`);
6
- const messages = {
7
- "runtime.ready": "Harness connected",
8
- "runtime.available": "Runtime ready",
9
- "runtime.websocket.closed": "Connection lost; reconnecting",
10
- "runtime.websocket.rejected": "Connection rejected; not reconnecting",
11
- "runtime.heartbeat_timeout": "Connection timed out; reconnecting",
12
- "runtime.auth_token_failed": "Cannot obtain credentials; retrying",
13
- "runtime.auth_required": "Sign in with cohub auth login",
14
- "runtime.stopped": "Runtime stopped",
15
- "runtime.failed": "Runtime needs attention",
16
- "runtime.turn_failed": "Turn failed; local files retained",
17
- "runtime.turn_cleanup_pending": "Turn result saved; tool cleanup still unconfirmed",
18
- "runtime.connection_failed": "Connection attempt failed; retrying",
19
- "runtime.execution_transport_detached": "Execution continues locally; result replays after reconnect",
20
- "runtime.execution_transport_invalidated": "Execution interrupted; outcome needs reconciliation",
21
- "archive.upload_pending": "Archive upload pending; local data retained",
22
- "native.sync_pending": "Native sync pending; the native file is the record and is retried",
23
- "native.stop_failed": "Could not stop the native Turn; stop it in the terminal",
24
- "native.import_failed": "Import did not start; run cohub runtime import",
25
- "archive.capture_pending": "Archive capture pending",
26
- "archive.capture_unavailable": "Archive unavailable; original receipt retained",
27
- "archive.restore_failed": "Native restore unavailable; using saved history",
28
- "sandboxd.process_exit": "File bridge stopped; restarting",
29
- "sandboxd.download": "Preparing file bridge",
30
- "sandboxd.connected": "File bridge connected",
31
- "sandboxd.disconnected": "File bridge disconnected; reconnecting",
32
- };
33
- export function formatDiagnostic(event, verbose = false) {
34
- const text = messages[event.event] ?? (typeof event.data?.message === "string" ? event.data.message : event.event);
35
- const detail = event.error?.message ? ` — ${event.error.message}` : "";
36
- const context = verbose ? ` ${JSON.stringify({ ...event.data, runtimeId: event.runtimeId, sessionId: event.sessionId, turnId: event.turnId })}` : "";
37
- return `${event.timestamp.slice(11, 19)} ${event.level.toUpperCase().padEnd(5)} ${text}${detail}${context}\n`;
38
- }
39
- /** File logs retain every event; repeated terminal warnings are coalesced. */
40
- export function createDiagnosticConsole(verbose = false, write = (line) => process.stderr.write(line)) {
41
- const last = new Map();
42
- return (event) => {
43
- if (!verbose && (event.level === "debug" || !atLeastLevel(event.level, "warn") && !messages[event.event]))
44
- return;
45
- const key = `${event.component}:${event.event}:${event.level}:${event.error?.message ?? event.data?.message ?? ""}`;
46
- const previous = last.get(key);
47
- const now = Date.now();
48
- if (!verbose && previous && now - previous.at < 30_000 && atLeastLevel(event.level, "warn")) {
49
- previous.suppressed++;
50
- return;
51
- }
52
- if (last.size >= 256)
53
- last.delete(last.keys().next().value ?? "");
54
- last.set(key, { at: now, suppressed: 0 });
55
- const repeated = previous?.suppressed ? ` (+${previous.suppressed} repeated)` : "";
56
- write(`${formatDiagnostic(event, verbose).trimEnd()}${repeated}\n`);
57
- };
58
- }
59
- export function printRuntimeSummary(summary, json = false, reused = false) {
60
- const value = { ...summary, url: runtimeWebUrl(summary.spaceId), reused };
61
- if (json) {
62
- process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
63
- return;
64
- }
65
- const label = summary.state === "ready" ? "Runtime ready" : `Runtime ${summary.state}`;
66
- process.stdout.write(`\n${label}${reused ? " · reused" : ""}\n\n`);
67
- const rows = [
68
- ["Space", summary.spaceId],
69
- ["URL", value.url],
70
- ["Directory", summary.root],
71
- ["Harness", summary.harnesses.join(" · ") || "Cohub"],
72
- ...(summary.version ? [["CLI", summary.version]] : []),
73
- ["Mode", summary.background ? "Background" : "Foreground"],
74
- ...(summary.display ? [["Screen", summary.display === "auto" ? "This computer" : summary.display]] : []),
75
- ...(summary.direct ? [["Direct", "Files and screens on this machine skip the network"]] : []),
76
- ["PID", String(summary.pid)],
77
- ["Logs", summary.diagnosticsPath],
78
- ];
79
- for (const [name, text] of rows)
80
- process.stdout.write(` ${name} ${text}\n`);
81
- process.stdout.write(`\n cohub runtime logs --space ${summary.spaceId} --follow\n cohub runtime down --space ${summary.spaceId}\n`);
82
- if (!summary.background && !reused)
83
- process.stdout.write(" Ctrl+C to stop\n");
84
- process.stdout.write("\n");
85
- }
86
- const plural = (count, word) => `${count.toLocaleString("en-US")} ${word}${count === 1 ? "" : "s"}`;
87
- const megabytes = (bytes) => `${(bytes / 1024 / 1024).toFixed(bytes < 10 * 1024 * 1024 ? 1 : 0)} MB`;
88
- /** One line of import progress: files and bytes, with an estimate once enough is known. */
89
- export function formatImportProgress(job, now = Date.now()) {
90
- const parts = [`${job.done.toLocaleString("en-US")}/${plural(job.files, "conversation")}`, plural(job.turns, "Turn"), `${megabytes(job.bytes)}/${megabytes(job.totalBytes)}`];
91
- const elapsed = job.startedAt ? now - Date.parse(job.startedAt) : 0;
92
- if (job.state === "running" && job.bytes > 0 && elapsed > 2_000 && job.totalBytes > job.bytes) {
93
- const seconds = Math.round((job.totalBytes - job.bytes) / (job.bytes / elapsed) / 1_000);
94
- parts.push(`about ${seconds < 90 ? `${seconds}s` : `${Math.round(seconds / 60)}m`} left`);
95
- }
96
- return parts.join(" · ");
97
- }
98
- /** `runtime status` native block: what syncs, what can be driven, and backfill progress. */
99
- export function formatNativeSync(config, native, error = null) {
100
- if (error)
101
- return `Native sync unknown — ${error} · fix or remove the config, then runtime up\n`;
102
- if (!config?.harnesses.length)
103
- return "Native sync off · run cohub runtime up to enable\n";
104
- const lines = [`Native sync ${config.harnesses.map((harness) => LOCAL_HARNESS_SPECS[harness].label).join(" · ")}`];
105
- if (!native)
106
- return `${lines[0]} · Runtime not running\n`;
107
- if (native.pi) {
108
- lines.push(native.pi.unavailable ? ` Pi read-only · ${native.pi.unavailable}`
109
- : native.pi.extension === "installed"
110
- ? ` Pi ${plural(native.pi.connected, "session")} connected`
111
- : " Pi read-only · install the extension with cohub runtime attach --harness pi, then /reload");
112
- }
113
- if (native.codex)
114
- lines.push(native.codex.control === "shared" ? " Codex shared app-server" : " Codex read-only in the terminal · Cohub Turns use a private app-server");
115
- lines.push(` Files ${plural(native.transcripts, "transcript")}${native.running ? ` · ${plural(native.running, "Turn")} running` : ""}`);
116
- const job = native.import;
117
- if (job.state === "running")
118
- lines.push(` Import ${formatImportProgress(job)}`);
119
- else if (job.state === "paused")
120
- lines.push(` Import paused at ${job.done}/${job.files} · run cohub runtime import to continue`);
121
- if (job.failed.length)
122
- lines.push(` ${plural(job.failed.length, "conversation")} failed to import · cohub runtime logs`);
123
- return `${lines.join("\n")}\n`;
124
- }
@@ -1,5 +0,0 @@
1
- export declare class ProcessCleanupUncertainError extends Error {
2
- }
3
- /** True only when the process group is gone or holds nothing that can execute. */
4
- export declare function confirmQuiescentProcessGroup(pid: number): Promise<boolean>;
5
- export declare function stopProcessGroup(pid: number): Promise<void>;