@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,380 +0,0 @@
1
- import { serializeDiagnosticError } from "../diagnostics.js";
2
- import { record } from "../json-rpc.js";
3
- import { readTranscript } from "./adapters.js";
4
- import { ApprovalBroker } from "./approvals.js";
5
- import { CodexShared } from "./codex-link.js";
6
- import { readNativeConfig } from "./config.js";
7
- import { DEFAULT_IMPORT_CONCURRENCY, NativeIngest } from "./ingest.js";
8
- import { piExtensionSource, piExtensionState } from "./install.js";
9
- import { controlSocketPath } from "./pi-extension.js";
10
- import { PI_MIN_VERSION, PiLink } from "./pi-link.js";
11
- import { atLeast, formatVersion, harnessVersion } from "./version.js";
12
- import { ExecutionResults } from "./results.js";
13
- import { NativeSessions } from "./sessions.js";
14
- import { codexTranslator, LiveProgress, piTranslator } from "./translate.js";
15
- import { nativeWebSocketTransport } from "./transport.js";
16
- import { readRuntimeSpaceBindings } from "../space-binding.js";
17
- const text = (value) => typeof value === "string" ? value : "";
18
- /** Streamed previews reach the web at most this often. */
19
- const STREAM_INTERVAL_MS = 250;
20
- /** A client Cohub cannot stream is previewed from its file, at most this often. */
21
- const FILE_PREVIEW_INTERVAL_MS = 2_000;
22
- /** A file preview waits at least this many times as long as its last read took. */
23
- const FILE_PREVIEW_COST_FACTOR = 20;
24
- /**
25
- * Everything the Runtime does with native sessions: the ingest engine (data plane), the Pi and
26
- * Codex links (control plane), and the executor that runs Cohub Turns through them.
27
- */
28
- export class NativeRuntime {
29
- options;
30
- ingest;
31
- executor;
32
- pi;
33
- codex;
34
- streams = new Map();
35
- filePreviews = new Map();
36
- watched = new Map();
37
- active = new Set();
38
- send = null;
39
- approvals = new ApprovalBroker();
40
- extension = "missing";
41
- constructor(options) {
42
- this.options = options;
43
- this.pi = new PiLink({
44
- socketPath: controlSocketPath(options.root), owns: (cwd) => this.ingest.owns(cwd),
45
- onEvent: (link, event) => this.onPiEvent(link, event),
46
- onConnect: (link) => this.ingest.controlChanged("pi", link.sessionId),
47
- onDisconnect: (link) => {
48
- this.endStream(`pi:${link.sessionId}`);
49
- this.ingest.controlChanged("pi", link.sessionId);
50
- if (link.sessionFile)
51
- this.ingest.touch(link.sessionFile);
52
- },
53
- onDroppedLine: (nativeSessionId, bytes) => options.diagnostics.log("warn", "native.pi_line_dropped", { nativeSessionId, bytes }, { component: "native", harness: "pi" }),
54
- });
55
- this.codex = new CodexShared(options.executables.codex || "codex", options.root, Boolean(options.config?.codexShared) && options.harnesses.includes("codex"));
56
- this.codex.onConnect((channel) => this.observeCodex(channel));
57
- // Its next Turn is found again through the server's status broadcast.
58
- this.codex.onRelease((threadId) => {
59
- this.watched.delete(threadId);
60
- this.endStream(`codex:${threadId}`);
61
- });
62
- this.ingest = new NativeIngest({
63
- spaceId: options.spaceId,
64
- cwd: options.root,
65
- harnesses: this.synced,
66
- enabledAt: options.config?.enabledAt ?? new Date().toISOString(),
67
- root: options.stateRoot,
68
- archives: options.archives,
69
- hooks: {
70
- settled: (state, mtimeMs) => {
71
- const link = state.harness === "pi" ? this.pi.find(state.nativeSessionId) : null;
72
- if (!link)
73
- return null;
74
- if (!link.idle)
75
- return false;
76
- // Idle and nothing written since it settled: done. A newer write lets the file decide.
77
- return link.settledAt >= mtimeMs ? true : null;
78
- },
79
- // Only Pi (extension) and Codex (shared app-server) have a control plane; other synced clients are read-only.
80
- controllable: (state) => state.harness === "pi"
81
- ? this.pi.find(state.nativeSessionId) !== null
82
- : state.harness === "codex" && this.codex.enabled && (this.active.has(state.nativeSessionId) || this.watched.has(state.nativeSessionId) || this.codex.driving.has(state.nativeSessionId)),
83
- abortTurn: (state) => {
84
- const stop = state.harness === "pi"
85
- ? this.pi.abort(state.nativeSessionId)
86
- : state.harness === "codex" && state.runningTurnKey ? this.codex.interrupt(state.nativeSessionId, state.runningTurnKey) : Promise.resolve(false);
87
- void stop.catch((error) => options.diagnostics.log("warn", "native.stop_failed", { error: serializeDiagnosticError(error) }, { harness: state.harness, sessionId: state.sessionId ?? undefined }));
88
- },
89
- onGrowth: (state) => this.onGrowth(state),
90
- onRunning: (state, turnId) => this.onRunning(state, turnId),
91
- onError: (error, context) => options.diagnostics.log("warn", "native.sync_pending", { path: context.path, error: serializeDiagnosticError(error) }, { component: "native", harness: context.harness }),
92
- },
93
- });
94
- const results = new ExecutionResults(options.stateRoot);
95
- this.executor = {
96
- cwd: options.root,
97
- executables: options.executables,
98
- sessions: new NativeSessions({
99
- root: options.stateRoot, spaceId: options.spaceId, projectionSource: options.projectionSource, archives: options.archives, ingest: this.ingest,
100
- onRestoreFailed: (error, context) => options.diagnostics.log("warn", "native.restore_failed", { error: serializeDiagnosticError(error), unrestorable: context.unrestorable }, { component: "archive", harness: context.harness, sessionId: context.sessionId }),
101
- }),
102
- results,
103
- ingest: this.ingest,
104
- archives: options.archives,
105
- pi: this.pi,
106
- codex: this.codex,
107
- approvals: this.approvals,
108
- piExtension: piExtensionSource(),
109
- diagnostics: options.diagnostics,
110
- };
111
- }
112
- get synced() {
113
- const { config, root, harnesses } = this.options;
114
- return config?.root === root ? config.harnesses.filter((harness) => harnesses.includes(harness)) : [];
115
- }
116
- async start(signal) {
117
- const degraded = (event) => (error) => this.options.diagnostics.log("warn", event, { error: serializeDiagnosticError(error) }, { component: "native" });
118
- await this.ingest.load().catch(degraded("native.ledger_unreadable"));
119
- await this.refreshScope();
120
- if (this.options.harnesses.includes("pi")) {
121
- const version = await harnessVersion(this.options.executables.pi || "pi");
122
- if (!atLeast(version, PI_MIN_VERSION))
123
- this.pi.unavailable = `Pi ${formatVersion(version)} predates the Cohub extension (${PI_MIN_VERSION.join(".")}+); upgrade Pi, then restart the Runtime`;
124
- else
125
- await this.pi.listen(signal).catch((error) => {
126
- this.pi.unavailable = `Pi control socket unavailable (${serializeDiagnosticError(error).message}); restart the Runtime`;
127
- degraded("native.pi_socket_unavailable")(error);
128
- });
129
- this.extension = await piExtensionState().catch(() => "missing");
130
- }
131
- await this.ingest.watch(signal).catch(degraded("native.watch_unavailable"));
132
- // Connecting early lets a terminal Codex find the server before the first Cohub Turn needs it.
133
- if (this.codex.enabled)
134
- void this.codex.get();
135
- }
136
- /** `approvals`: the Gateway relays approval decisions back. */
137
- connect(send, features = {}) {
138
- this.send = send;
139
- this.ingest.connect(send ? nativeWebSocketTransport(send) : null);
140
- this.approvals.connect(send && features.approvals ? send : null);
141
- }
142
- stop(sessionId, turnId) {
143
- return this.ingest.stop(sessionId, turnId);
144
- }
145
- status() {
146
- const ingest = this.ingest.status();
147
- return {
148
- synced: this.synced,
149
- transcripts: ingest.transcripts,
150
- running: ingest.running,
151
- pi: this.options.harnesses.includes("pi") ? { extension: this.extension, connected: this.pi.list().length, unavailable: this.pi.unavailable } : null,
152
- codex: this.options.harnesses.includes("codex") ? { control: this.codex.enabled ? "shared" : "private", watching: this.watched.size } : null,
153
- import: ingest.import,
154
- };
155
- }
156
- async control(action, message) {
157
- if (action === "reload")
158
- return await this.reload();
159
- if (action !== "import")
160
- throw new Error("Unknown Runtime control request");
161
- if (!this.synced.length)
162
- throw new Error("Native sync is not enabled for this directory; run cohub runtime up");
163
- const filter = {
164
- ...(Array.isArray(message.harnesses) && message.harnesses.length ? { harnesses: message.harnesses } : {}),
165
- ...(typeof message.nativeSessionId === "string" && message.nativeSessionId ? { nativeSessionId: message.nativeSessionId } : {}),
166
- };
167
- if (message.command === "pause")
168
- return this.ingest.pauseImport();
169
- if (message.command === "start")
170
- return await this.ingest.startImport(filter, typeof message.concurrency === "number" ? message.concurrency : DEFAULT_IMPORT_CONCURRENCY);
171
- const plan = await this.ingest.plan(filter);
172
- return {
173
- files: plan.length,
174
- bytes: plan.reduce((sum, candidate) => sum + candidate.size, 0),
175
- // Enough to show what an import would bring in; the full list stays in the Runtime.
176
- sample: plan.slice(0, 20).map(({ harness, path, nativeSessionId, mtimeMs, size }) => ({ harness, path, nativeSessionId, mtimeMs, size })),
177
- };
178
- }
179
- async reload() {
180
- await this.refreshScope();
181
- this.options.config = await readNativeConfig(this.options.stateRoot, this.options.identity);
182
- this.ingest.configure(this.synced, this.options.config?.enabledAt ?? new Date().toISOString());
183
- this.codex.enabled = Boolean(this.options.config?.codexShared) && this.options.harnesses.includes("codex");
184
- if (this.codex.enabled)
185
- void this.codex.get();
186
- if (this.options.harnesses.includes("pi"))
187
- this.extension = await piExtensionState().catch(() => "missing");
188
- return this.status();
189
- }
190
- async refreshScope() {
191
- const { bindings } = await readRuntimeSpaceBindings().catch(() => ({ bindings: [] }));
192
- this.ingest.exclude(bindings.filter((binding) => binding.key === this.options.identity && binding.spaceId !== this.options.spaceId).map((binding) => binding.root));
193
- }
194
- async close(signal) {
195
- for (const stream of this.streams.values())
196
- stream.progress.dispose();
197
- for (const preview of this.filePreviews.values()) {
198
- preview.progress.dispose();
199
- if (preview.timer)
200
- clearTimeout(preview.timer);
201
- }
202
- await Promise.allSettled([this.pi.close(), this.codex.close(), this.ingest.close(signal)]);
203
- }
204
- sink(harness, nativeSessionId) {
205
- return (progress) => {
206
- const running = this.ingest.running(harness, nativeSessionId);
207
- if (!running?.sessionId || !running.runningTurnId || !this.send)
208
- return null;
209
- return this.send({ type: "progress", sessionId: running.sessionId, turnId: running.runningTurnId, progress }).catch(() => ({ accepted: false }));
210
- };
211
- }
212
- /**
213
- * A connected Pi. A user prompt starting and the agent settling are the two moments its file has
214
- * something to persist; everything between streams as a preview of a Turn someone runs there.
215
- */
216
- onPiEvent(link, event) {
217
- const key = `pi:${link.sessionId}`;
218
- const type = text(event.type);
219
- const userPrompt = type === "message_end" && record(event.message).role === "user";
220
- if (userPrompt || type === "agent_settled") {
221
- if (link.sessionFile)
222
- this.ingest.touch(link.sessionFile);
223
- }
224
- if (type === "agent_start")
225
- this.endStream(key);
226
- // An automatic retry follows `agent_end` within the same Turn; only settling ends it.
227
- if (type === "agent_settled") {
228
- this.endStream(key);
229
- return;
230
- }
231
- this.ingest.alive("pi", link.sessionId);
232
- // A Turn Cohub runs streams through its own execution; this is only a terminal user's Turn.
233
- if (!this.ingest.running("pi", link.sessionId) && !userPrompt && !this.streams.has(key))
234
- return;
235
- this.stream(key, "pi", link.sessionId).translator.push(event);
236
- }
237
- stream(key, harness, nativeSessionId) {
238
- let stream = this.streams.get(key);
239
- if (!stream) {
240
- const progress = new LiveProgress(this.sink(harness, nativeSessionId), STREAM_INTERVAL_MS);
241
- const emit = (update) => progress.apply(update);
242
- stream = { progress, translator: harness === "pi" ? piTranslator(emit) : codexTranslator(emit, { provider: null, model: null }) };
243
- this.streams.set(key, stream);
244
- }
245
- return stream;
246
- }
247
- endStream(key) {
248
- this.streams.get(key)?.progress.dispose();
249
- this.streams.delete(key);
250
- }
251
- endFilePreview(path) {
252
- const preview = this.filePreviews.get(path);
253
- if (!preview)
254
- return;
255
- preview.progress.dispose();
256
- if (preview.timer)
257
- clearTimeout(preview.timer);
258
- this.filePreviews.delete(path);
259
- }
260
- observeCodex(channel) {
261
- const offEvent = channel.onEvent((event) => this.onCodexEvent(event));
262
- const offClose = channel.onClose(() => {
263
- offEvent();
264
- offClose();
265
- // Subscriptions die with the connection; the next activity in a rollout reconnects.
266
- const lost = new Set([...this.watched.keys(), ...this.active]);
267
- this.watched.clear();
268
- this.active.clear();
269
- for (const key of [...this.streams.keys()])
270
- if (key.startsWith("codex:"))
271
- this.endStream(key);
272
- for (const threadId of lost)
273
- this.ingest.controlChanged("codex", threadId);
274
- });
275
- void channel.request("thread/loaded/list", {}).then((result) => {
276
- for (const threadId of Array.isArray(result.data) ? result.data : [])
277
- if (typeof threadId === "string")
278
- void this.watchCodexThread(channel, threadId, false);
279
- }).catch(() => undefined);
280
- }
281
- async watchCodexThread(channel, threadId, busy) {
282
- if (this.watched.has(threadId))
283
- return;
284
- const read = await channel.request("thread/read", { threadId }).catch(() => null);
285
- const thread = record(read?.thread);
286
- if (!busy && record(thread.status).type !== "active")
287
- return;
288
- // Only this project's conversations; sub-agents and ephemeral threads are not chats.
289
- if (!this.ingest.owns(text(thread.cwd)) || thread.parentThreadId || thread.ephemeral === true)
290
- return;
291
- this.active.add(threadId);
292
- if (this.codex.driving.has(threadId))
293
- return;
294
- this.watched.set(threadId, { path: text(thread.path) || null });
295
- this.ingest.controlChanged("codex", threadId);
296
- await this.codex.join(threadId).catch((error) => {
297
- this.watched.delete(threadId);
298
- this.options.diagnostics.log("debug", "native.codex_join_failed", { error: serializeDiagnosticError(error) }, { harness: "codex" });
299
- });
300
- }
301
- onCodexEvent(event) {
302
- // Approvals of other clients' Turns are theirs to answer.
303
- if (event.id != null)
304
- return;
305
- const threadId = text(event.params.threadId);
306
- if (!threadId)
307
- return;
308
- if (event.method === "thread/status/changed") {
309
- if (record(event.params.status).type === "active")
310
- void this.codex.get().then((channel) => channel && this.watchCodexThread(channel, threadId, true));
311
- return;
312
- }
313
- const watched = this.watched.get(threadId);
314
- // A Turn Cohub runs streams through its own execution.
315
- if (!watched || this.codex.driving.has(threadId))
316
- return;
317
- this.ingest.alive("codex", threadId);
318
- const key = `codex:${threadId}`;
319
- if (event.method === "turn/started")
320
- this.endStream(key);
321
- if (event.method === "turn/completed") {
322
- this.endStream(key);
323
- if (watched.path)
324
- this.ingest.touch(watched.path);
325
- void this.codex.release(threadId);
326
- return;
327
- }
328
- this.stream(key, "codex", threadId).translator.push(event);
329
- }
330
- /**
331
- * A terminal Pi runs many Turns in one process; once the ledger knows which one is running, its
332
- * tools are told, so a `cohub` call from a tool names the right Space, Session and Turn.
333
- */
334
- onRunning(state, turnId) {
335
- if (!turnId)
336
- this.endFilePreview(state.path);
337
- if (state.harness !== "pi" || !state.sessionId || !this.pi.find(state.nativeSessionId))
338
- return;
339
- void this.pi.context(state.nativeSessionId, { COHUB_SPACE_ID: this.options.spaceId, COHUB_SESSION_ID: state.sessionId, COHUB_TURN_ID: turnId }).catch(() => undefined);
340
- }
341
- /**
342
- * A running Turn's file grew. A connected client streams it already; otherwise the preview is
343
- * read from the file, at a pace set by a timer, not by every write.
344
- */
345
- onGrowth(state) {
346
- this.ingest.alive(state.harness, state.nativeSessionId);
347
- if (state.harness === "codex" && this.codex.enabled && !this.watched.has(state.nativeSessionId))
348
- void this.codex.get();
349
- const streamed = state.harness === "pi" ? this.pi.find(state.nativeSessionId) !== null : this.watched.has(state.nativeSessionId);
350
- if (streamed)
351
- return;
352
- let preview = this.filePreviews.get(state.path);
353
- if (!preview) {
354
- preview = { progress: new LiveProgress(this.sink(state.harness, state.nativeSessionId), 0), timer: null, readMs: 0 };
355
- this.filePreviews.set(state.path, preview);
356
- }
357
- const entry = preview;
358
- // A preview re-reads the file; a long transcript is previewed less often, so it costs a bounded share of time.
359
- entry.timer ??= setTimeout(() => {
360
- if (!state.runningTurnId) {
361
- this.endFilePreview(state.path);
362
- return;
363
- }
364
- const startedAt = performance.now();
365
- void readTranscript(state.path, state.harness).then((transcript) => {
366
- if (!state.runningTurnId) {
367
- this.endFilePreview(state.path);
368
- return;
369
- }
370
- const tail = transcript.turns.at(-1);
371
- entry.progress.replace((tail?.messages ?? []).map((message) => ({ content: message.content, provider: message.provider ?? null, model: message.model ?? null })));
372
- }).catch(() => undefined).finally(() => {
373
- entry.readMs = performance.now() - startedAt;
374
- // Growth during the read schedules the next one only now: reads never overlap.
375
- entry.timer = null;
376
- });
377
- }, Math.max(FILE_PREVIEW_INTERVAL_MS, FILE_PREVIEW_COST_FACTOR * entry.readMs));
378
- entry.timer.unref?.();
379
- }
380
- }
@@ -1,26 +0,0 @@
1
- import { type RuntimeTurnInput } from "@neta-art/cohub";
2
- import type { RuntimeArchiveStore } from "../archive-store.js";
3
- import { type RuntimeDiagnosticContext, type RuntimeDiagnostics } from "../diagnostics.js";
4
- import type { HarnessExecutables, HarnessResult, HarnessTurn } from "../harnesses/types.js";
5
- import type { ApprovalBroker } from "./approvals.js";
6
- import type { CodexShared } from "./codex-link.js";
7
- import type { NativeIngest } from "./ingest.js";
8
- import type { PiLink } from "./pi-link.js";
9
- import type { ExecutionResults } from "./results.js";
10
- import type { NativeSessions } from "./sessions.js";
11
- export type { HarnessResult } from "../harnesses/types.js";
12
- export type Executor = {
13
- cwd: string;
14
- executables: HarnessExecutables;
15
- sessions: NativeSessions;
16
- results: ExecutionResults;
17
- ingest: NativeIngest;
18
- archives: RuntimeArchiveStore;
19
- pi: PiLink;
20
- codex: CodexShared;
21
- approvals: ApprovalBroker;
22
- piExtension: string;
23
- diagnostics?: RuntimeDiagnostics;
24
- };
25
- /** Run one Cohub Turn in a local harness through its adapter. */
26
- export declare function executeTurn(executor: Executor, input: RuntimeTurnInput, emit: HarnessTurn["emit"], signal: AbortSignal, requestId: string | null, context?: RuntimeDiagnosticContext): Promise<HarnessResult>;
@@ -1,34 +0,0 @@
1
- import { assertHarnessAccess } from "@neta-art/cohub";
2
- import { serializeDiagnosticError } from "../diagnostics.js";
3
- import { harnessAdapter } from "../harnesses/index.js";
4
- import { closeHost } from "../harnesses/process.js";
5
- /** Run one Cohub Turn in a local harness through its adapter. */
6
- export async function executeTurn(executor, input, emit, signal, requestId, context) {
7
- signal.throwIfAborted();
8
- assertHarnessAccess(input.harness, input.accessMode);
9
- const diverged = await executor.results.admit(input);
10
- const started = async (session) => {
11
- await executor.results.start(session, input, requestId);
12
- executor.ingest.begin(session, input.sessionId, input.turnId);
13
- };
14
- const turn = { input, emit, signal, diverged, started, context };
15
- let run;
16
- try {
17
- run = await harnessAdapter(input.harness).run(executor, turn);
18
- }
19
- catch (error) {
20
- executor.ingest.end(input.turnId);
21
- throw error;
22
- }
23
- let uncertainCleanup;
24
- if (run.host)
25
- uncertainCleanup = await closeHost(run.host, run.message.errorMessage);
26
- const message = signal.aborted ? { ...run.message, stopReason: "aborted" } : run.message;
27
- const archive = !harnessAdapter(input.harness).session.archive ? null : await executor.archives.stage({ sessionId: input.sessionId, harness: input.harness, nativeSessionId: run.session.nativeSessionId, path: run.session.path }, input.turnId).catch((error) => {
28
- // A missing archive only costs cross-machine native resume; the file itself is intact.
29
- executor.diagnostics?.log("warn", "archive.capture_failed", { error: serializeDiagnosticError(error) }, { ...context, component: "archive" });
30
- return null;
31
- });
32
- executor.ingest.advance(run.session.path, input.turnId);
33
- return { session: run.session, event: { type: "turn.end", message, resume: run.resume, archive }, ...(uncertainCleanup ? { uncertainCleanup } : {}) };
34
- }
@@ -1,9 +0,0 @@
1
- import type { LocalHarness } from "@neta-art/cohub";
2
- /** Deterministic UUID-shaped id. A native Turn always names the same cloud Turn. */
3
- export declare function nativeStableId(value: string): string;
4
- /**
5
- * Cloud Turn id of a native Turn. A transcript can reach more than one Space (a directory rebound
6
- * to another Space, or another account), so the Space is part of the identity; within it, globally
7
- * unique Turn keys (Codex: a fork shares its history's Turns) stand alone and others are per session.
8
- */
9
- export declare function nativeTurnId(spaceId: string, harness: LocalHarness, nativeSessionId: string, turnKey: string): string;
@@ -1,15 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { transcriptFormat } from "../harnesses/index.js";
3
- /** Deterministic UUID-shaped id. A native Turn always names the same cloud Turn. */
4
- export function nativeStableId(value) {
5
- const hex = createHash("sha256").update(value).digest("hex");
6
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-5${hex.slice(13, 16)}-a${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
7
- }
8
- /**
9
- * Cloud Turn id of a native Turn. A transcript can reach more than one Space (a directory rebound
10
- * to another Space, or another account), so the Space is part of the identity; within it, globally
11
- * unique Turn keys (Codex: a fork shares its history's Turns) stand alone and others are per session.
12
- */
13
- export function nativeTurnId(spaceId, harness, nativeSessionId, turnKey) {
14
- return nativeStableId(JSON.stringify(transcriptFormat(harness).globalTurnKeys ? ["native", spaceId, harness, turnKey] : ["native", spaceId, harness, nativeSessionId, turnKey]));
15
- }