@kruntime/komputer 0.1.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 (353) hide show
  1. package/README.md +368 -0
  2. package/dist/agent/approvals.d.ts +28 -0
  3. package/dist/agent/approvals.js +109 -0
  4. package/dist/agent/approvals.js.map +1 -0
  5. package/dist/agent/messages.d.ts +67 -0
  6. package/dist/agent/messages.js +213 -0
  7. package/dist/agent/messages.js.map +1 -0
  8. package/dist/agent/recovery.d.ts +13 -0
  9. package/dist/agent/recovery.js +112 -0
  10. package/dist/agent/recovery.js.map +1 -0
  11. package/dist/agent/session-utils.d.ts +17 -0
  12. package/dist/agent/session-utils.js +77 -0
  13. package/dist/agent/session-utils.js.map +1 -0
  14. package/dist/agent-session.d.ts +303 -0
  15. package/dist/agent-session.js +3031 -0
  16. package/dist/agent-session.js.map +1 -0
  17. package/dist/authority.d.ts +34 -0
  18. package/dist/authority.js +105 -0
  19. package/dist/authority.js.map +1 -0
  20. package/dist/content.d.ts +17 -0
  21. package/dist/content.js +69 -0
  22. package/dist/content.js.map +1 -0
  23. package/dist/cron.d.ts +20 -0
  24. package/dist/cron.js +25 -0
  25. package/dist/cron.js.map +1 -0
  26. package/dist/drive.d.ts +198 -0
  27. package/dist/drive.js +656 -0
  28. package/dist/drive.js.map +1 -0
  29. package/dist/events.d.ts +20 -0
  30. package/dist/events.js +149 -0
  31. package/dist/events.js.map +1 -0
  32. package/dist/fs-mode.d.ts +9 -0
  33. package/dist/fs-mode.js +98 -0
  34. package/dist/fs-mode.js.map +1 -0
  35. package/dist/index.d.ts +26 -0
  36. package/dist/index.js +15 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/komputer.d.ts +123 -0
  39. package/dist/komputer.js +733 -0
  40. package/dist/komputer.js.map +1 -0
  41. package/dist/kstate.d.ts +107 -0
  42. package/dist/kstate.js +529 -0
  43. package/dist/kstate.js.map +1 -0
  44. package/dist/model.d.ts +81 -0
  45. package/dist/model.js +824 -0
  46. package/dist/model.js.map +1 -0
  47. package/dist/node.d.ts +2 -0
  48. package/dist/node.js +3 -0
  49. package/dist/node.js.map +1 -0
  50. package/dist/path.d.ts +4 -0
  51. package/dist/path.js +38 -0
  52. package/dist/path.js.map +1 -0
  53. package/dist/pool.d.ts +56 -0
  54. package/dist/pool.js +172 -0
  55. package/dist/pool.js.map +1 -0
  56. package/dist/receipts.d.ts +44 -0
  57. package/dist/receipts.js +35 -0
  58. package/dist/receipts.js.map +1 -0
  59. package/dist/remote-node.d.ts +2 -0
  60. package/dist/remote-node.js +122 -0
  61. package/dist/remote-node.js.map +1 -0
  62. package/dist/remote.d.ts +84 -0
  63. package/dist/remote.js +11 -0
  64. package/dist/remote.js.map +1 -0
  65. package/dist/sandbox.d.ts +4 -0
  66. package/dist/sandbox.js +70 -0
  67. package/dist/sandbox.js.map +1 -0
  68. package/dist/shell/builtins/catalog.d.ts +6 -0
  69. package/dist/shell/builtins/catalog.js +12 -0
  70. package/dist/shell/builtins/catalog.js.map +1 -0
  71. package/dist/shell/builtins/commands/filesystem/basename.d.ts +2 -0
  72. package/dist/shell/builtins/commands/filesystem/basename.js +23 -0
  73. package/dist/shell/builtins/commands/filesystem/basename.js.map +1 -0
  74. package/dist/shell/builtins/commands/filesystem/cat.d.ts +2 -0
  75. package/dist/shell/builtins/commands/filesystem/cat.js +85 -0
  76. package/dist/shell/builtins/commands/filesystem/cat.js.map +1 -0
  77. package/dist/shell/builtins/commands/filesystem/cd.d.ts +2 -0
  78. package/dist/shell/builtins/commands/filesystem/cd.js +14 -0
  79. package/dist/shell/builtins/commands/filesystem/cd.js.map +1 -0
  80. package/dist/shell/builtins/commands/filesystem/chmod.d.ts +2 -0
  81. package/dist/shell/builtins/commands/filesystem/chmod.js +46 -0
  82. package/dist/shell/builtins/commands/filesystem/chmod.js.map +1 -0
  83. package/dist/shell/builtins/commands/filesystem/copy-directory.d.ts +4 -0
  84. package/dist/shell/builtins/commands/filesystem/copy-directory.js +48 -0
  85. package/dist/shell/builtins/commands/filesystem/copy-directory.js.map +1 -0
  86. package/dist/shell/builtins/commands/filesystem/cp.d.ts +2 -0
  87. package/dist/shell/builtins/commands/filesystem/cp.js +92 -0
  88. package/dist/shell/builtins/commands/filesystem/cp.js.map +1 -0
  89. package/dist/shell/builtins/commands/filesystem/dirname.d.ts +2 -0
  90. package/dist/shell/builtins/commands/filesystem/dirname.js +23 -0
  91. package/dist/shell/builtins/commands/filesystem/dirname.js.map +1 -0
  92. package/dist/shell/builtins/commands/filesystem/du.d.ts +2 -0
  93. package/dist/shell/builtins/commands/filesystem/du.js +93 -0
  94. package/dist/shell/builtins/commands/filesystem/du.js.map +1 -0
  95. package/dist/shell/builtins/commands/filesystem/find.d.ts +2 -0
  96. package/dist/shell/builtins/commands/filesystem/find.js +111 -0
  97. package/dist/shell/builtins/commands/filesystem/find.js.map +1 -0
  98. package/dist/shell/builtins/commands/filesystem/install.d.ts +2 -0
  99. package/dist/shell/builtins/commands/filesystem/install.js +89 -0
  100. package/dist/shell/builtins/commands/filesystem/install.js.map +1 -0
  101. package/dist/shell/builtins/commands/filesystem/ln.d.ts +2 -0
  102. package/dist/shell/builtins/commands/filesystem/ln.js +57 -0
  103. package/dist/shell/builtins/commands/filesystem/ln.js.map +1 -0
  104. package/dist/shell/builtins/commands/filesystem/ls.d.ts +2 -0
  105. package/dist/shell/builtins/commands/filesystem/ls.js +153 -0
  106. package/dist/shell/builtins/commands/filesystem/ls.js.map +1 -0
  107. package/dist/shell/builtins/commands/filesystem/mkdir.d.ts +2 -0
  108. package/dist/shell/builtins/commands/filesystem/mkdir.js +41 -0
  109. package/dist/shell/builtins/commands/filesystem/mkdir.js.map +1 -0
  110. package/dist/shell/builtins/commands/filesystem/mktemp.d.ts +2 -0
  111. package/dist/shell/builtins/commands/filesystem/mktemp.js +94 -0
  112. package/dist/shell/builtins/commands/filesystem/mktemp.js.map +1 -0
  113. package/dist/shell/builtins/commands/filesystem/mv.d.ts +2 -0
  114. package/dist/shell/builtins/commands/filesystem/mv.js +41 -0
  115. package/dist/shell/builtins/commands/filesystem/mv.js.map +1 -0
  116. package/dist/shell/builtins/commands/filesystem/pwd.d.ts +2 -0
  117. package/dist/shell/builtins/commands/filesystem/pwd.js +2 -0
  118. package/dist/shell/builtins/commands/filesystem/pwd.js.map +1 -0
  119. package/dist/shell/builtins/commands/filesystem/realpath.d.ts +3 -0
  120. package/dist/shell/builtins/commands/filesystem/realpath.js +61 -0
  121. package/dist/shell/builtins/commands/filesystem/realpath.js.map +1 -0
  122. package/dist/shell/builtins/commands/filesystem/rm.d.ts +2 -0
  123. package/dist/shell/builtins/commands/filesystem/rm.js +38 -0
  124. package/dist/shell/builtins/commands/filesystem/rm.js.map +1 -0
  125. package/dist/shell/builtins/commands/filesystem/stat.d.ts +2 -0
  126. package/dist/shell/builtins/commands/filesystem/stat.js +141 -0
  127. package/dist/shell/builtins/commands/filesystem/stat.js.map +1 -0
  128. package/dist/shell/builtins/commands/filesystem/touch.d.ts +2 -0
  129. package/dist/shell/builtins/commands/filesystem/touch.js +143 -0
  130. package/dist/shell/builtins/commands/filesystem/touch.js.map +1 -0
  131. package/dist/shell/builtins/commands/filesystem.d.ts +2 -0
  132. package/dist/shell/builtins/commands/filesystem.js +44 -0
  133. package/dist/shell/builtins/commands/filesystem.js.map +1 -0
  134. package/dist/shell/builtins/commands/network/curl.d.ts +2 -0
  135. package/dist/shell/builtins/commands/network/curl.js +25 -0
  136. package/dist/shell/builtins/commands/network/curl.js.map +1 -0
  137. package/dist/shell/builtins/commands/network/http.d.ts +27 -0
  138. package/dist/shell/builtins/commands/network/http.js +226 -0
  139. package/dist/shell/builtins/commands/network/http.js.map +1 -0
  140. package/dist/shell/builtins/commands/network/wget.d.ts +2 -0
  141. package/dist/shell/builtins/commands/network/wget.js +32 -0
  142. package/dist/shell/builtins/commands/network/wget.js.map +1 -0
  143. package/dist/shell/builtins/commands/network.d.ts +2 -0
  144. package/dist/shell/builtins/commands/network.js +9 -0
  145. package/dist/shell/builtins/commands/network.js.map +1 -0
  146. package/dist/shell/builtins/commands/process/bg.d.ts +2 -0
  147. package/dist/shell/builtins/commands/process/bg.js +10 -0
  148. package/dist/shell/builtins/commands/process/bg.js.map +1 -0
  149. package/dist/shell/builtins/commands/process/fg.d.ts +2 -0
  150. package/dist/shell/builtins/commands/process/fg.js +14 -0
  151. package/dist/shell/builtins/commands/process/fg.js.map +1 -0
  152. package/dist/shell/builtins/commands/process/jobs.d.ts +2 -0
  153. package/dist/shell/builtins/commands/process/jobs.js +8 -0
  154. package/dist/shell/builtins/commands/process/jobs.js.map +1 -0
  155. package/dist/shell/builtins/commands/process/jobspec.d.ts +4 -0
  156. package/dist/shell/builtins/commands/process/jobspec.js +20 -0
  157. package/dist/shell/builtins/commands/process/jobspec.js.map +1 -0
  158. package/dist/shell/builtins/commands/process/kill.d.ts +2 -0
  159. package/dist/shell/builtins/commands/process/kill.js +35 -0
  160. package/dist/shell/builtins/commands/process/kill.js.map +1 -0
  161. package/dist/shell/builtins/commands/process/ps.d.ts +2 -0
  162. package/dist/shell/builtins/commands/process/ps.js +6 -0
  163. package/dist/shell/builtins/commands/process/ps.js.map +1 -0
  164. package/dist/shell/builtins/commands/process/sleep.d.ts +2 -0
  165. package/dist/shell/builtins/commands/process/sleep.js +6 -0
  166. package/dist/shell/builtins/commands/process/sleep.js.map +1 -0
  167. package/dist/shell/builtins/commands/process/wait.d.ts +2 -0
  168. package/dist/shell/builtins/commands/process/wait.js +21 -0
  169. package/dist/shell/builtins/commands/process/wait.js.map +1 -0
  170. package/dist/shell/builtins/commands/process.d.ts +2 -0
  171. package/dist/shell/builtins/commands/process.js +19 -0
  172. package/dist/shell/builtins/commands/process.js.map +1 -0
  173. package/dist/shell/builtins/commands/system/command.d.ts +2 -0
  174. package/dist/shell/builtins/commands/system/command.js +42 -0
  175. package/dist/shell/builtins/commands/system/command.js.map +1 -0
  176. package/dist/shell/builtins/commands/system/date.d.ts +2 -0
  177. package/dist/shell/builtins/commands/system/date.js +121 -0
  178. package/dist/shell/builtins/commands/system/date.js.map +1 -0
  179. package/dist/shell/builtins/commands/system/env.d.ts +2 -0
  180. package/dist/shell/builtins/commands/system/env.js +84 -0
  181. package/dist/shell/builtins/commands/system/env.js.map +1 -0
  182. package/dist/shell/builtins/commands/system/export.d.ts +2 -0
  183. package/dist/shell/builtins/commands/system/export.js +18 -0
  184. package/dist/shell/builtins/commands/system/export.js.map +1 -0
  185. package/dist/shell/builtins/commands/system/false.d.ts +2 -0
  186. package/dist/shell/builtins/commands/system/false.js +4 -0
  187. package/dist/shell/builtins/commands/system/false.js.map +1 -0
  188. package/dist/shell/builtins/commands/system/help.d.ts +2 -0
  189. package/dist/shell/builtins/commands/system/help.js +38 -0
  190. package/dist/shell/builtins/commands/system/help.js.map +1 -0
  191. package/dist/shell/builtins/commands/system/hostname.d.ts +2 -0
  192. package/dist/shell/builtins/commands/system/hostname.js +6 -0
  193. package/dist/shell/builtins/commands/system/hostname.js.map +1 -0
  194. package/dist/shell/builtins/commands/system/id.d.ts +2 -0
  195. package/dist/shell/builtins/commands/system/id.js +55 -0
  196. package/dist/shell/builtins/commands/system/id.js.map +1 -0
  197. package/dist/shell/builtins/commands/system/printenv.d.ts +2 -0
  198. package/dist/shell/builtins/commands/system/printenv.js +22 -0
  199. package/dist/shell/builtins/commands/system/printenv.js.map +1 -0
  200. package/dist/shell/builtins/commands/system/read.d.ts +2 -0
  201. package/dist/shell/builtins/commands/system/read.js +75 -0
  202. package/dist/shell/builtins/commands/system/read.js.map +1 -0
  203. package/dist/shell/builtins/commands/system/resolve-command.d.ts +3 -0
  204. package/dist/shell/builtins/commands/system/resolve-command.js +34 -0
  205. package/dist/shell/builtins/commands/system/resolve-command.js.map +1 -0
  206. package/dist/shell/builtins/commands/system/set.d.ts +2 -0
  207. package/dist/shell/builtins/commands/system/set.js +49 -0
  208. package/dist/shell/builtins/commands/system/set.js.map +1 -0
  209. package/dist/shell/builtins/commands/system/sh.d.ts +2 -0
  210. package/dist/shell/builtins/commands/system/sh.js +55 -0
  211. package/dist/shell/builtins/commands/system/sh.js.map +1 -0
  212. package/dist/shell/builtins/commands/system/source.d.ts +2 -0
  213. package/dist/shell/builtins/commands/system/source.js +42 -0
  214. package/dist/shell/builtins/commands/system/source.js.map +1 -0
  215. package/dist/shell/builtins/commands/system/test-expression.d.ts +2 -0
  216. package/dist/shell/builtins/commands/system/test-expression.js +93 -0
  217. package/dist/shell/builtins/commands/system/test-expression.js.map +1 -0
  218. package/dist/shell/builtins/commands/system/test.d.ts +4 -0
  219. package/dist/shell/builtins/commands/system/test.js +19 -0
  220. package/dist/shell/builtins/commands/system/test.js.map +1 -0
  221. package/dist/shell/builtins/commands/system/true.d.ts +2 -0
  222. package/dist/shell/builtins/commands/system/true.js +2 -0
  223. package/dist/shell/builtins/commands/system/true.js.map +1 -0
  224. package/dist/shell/builtins/commands/system/type.d.ts +2 -0
  225. package/dist/shell/builtins/commands/system/type.js +77 -0
  226. package/dist/shell/builtins/commands/system/type.js.map +1 -0
  227. package/dist/shell/builtins/commands/system/uname.d.ts +2 -0
  228. package/dist/shell/builtins/commands/system/uname.js +39 -0
  229. package/dist/shell/builtins/commands/system/uname.js.map +1 -0
  230. package/dist/shell/builtins/commands/system/unset.d.ts +2 -0
  231. package/dist/shell/builtins/commands/system/unset.js +9 -0
  232. package/dist/shell/builtins/commands/system/unset.js.map +1 -0
  233. package/dist/shell/builtins/commands/system/which.d.ts +2 -0
  234. package/dist/shell/builtins/commands/system/which.js +38 -0
  235. package/dist/shell/builtins/commands/system/which.js.map +1 -0
  236. package/dist/shell/builtins/commands/system/whoami.d.ts +2 -0
  237. package/dist/shell/builtins/commands/system/whoami.js +6 -0
  238. package/dist/shell/builtins/commands/system/whoami.js.map +1 -0
  239. package/dist/shell/builtins/commands/system.d.ts +2 -0
  240. package/dist/shell/builtins/commands/system.js +49 -0
  241. package/dist/shell/builtins/commands/system.js.map +1 -0
  242. package/dist/shell/builtins/commands/text/awk.d.ts +2 -0
  243. package/dist/shell/builtins/commands/text/awk.js +8 -0
  244. package/dist/shell/builtins/commands/text/awk.js.map +1 -0
  245. package/dist/shell/builtins/commands/text/base64.d.ts +2 -0
  246. package/dist/shell/builtins/commands/text/base64.js +69 -0
  247. package/dist/shell/builtins/commands/text/base64.js.map +1 -0
  248. package/dist/shell/builtins/commands/text/cut.d.ts +2 -0
  249. package/dist/shell/builtins/commands/text/cut.js +35 -0
  250. package/dist/shell/builtins/commands/text/cut.js.map +1 -0
  251. package/dist/shell/builtins/commands/text/diff.d.ts +2 -0
  252. package/dist/shell/builtins/commands/text/diff.js +83 -0
  253. package/dist/shell/builtins/commands/text/diff.js.map +1 -0
  254. package/dist/shell/builtins/commands/text/echo.d.ts +2 -0
  255. package/dist/shell/builtins/commands/text/echo.js +6 -0
  256. package/dist/shell/builtins/commands/text/echo.js.map +1 -0
  257. package/dist/shell/builtins/commands/text/grep.d.ts +2 -0
  258. package/dist/shell/builtins/commands/text/grep.js +123 -0
  259. package/dist/shell/builtins/commands/text/grep.js.map +1 -0
  260. package/dist/shell/builtins/commands/text/head.d.ts +2 -0
  261. package/dist/shell/builtins/commands/text/head.js +8 -0
  262. package/dist/shell/builtins/commands/text/head.js.map +1 -0
  263. package/dist/shell/builtins/commands/text/jq.d.ts +2 -0
  264. package/dist/shell/builtins/commands/text/jq.js +239 -0
  265. package/dist/shell/builtins/commands/text/jq.js.map +1 -0
  266. package/dist/shell/builtins/commands/text/printf.d.ts +2 -0
  267. package/dist/shell/builtins/commands/text/printf.js +3 -0
  268. package/dist/shell/builtins/commands/text/printf.js.map +1 -0
  269. package/dist/shell/builtins/commands/text/sed.d.ts +2 -0
  270. package/dist/shell/builtins/commands/text/sed.js +21 -0
  271. package/dist/shell/builtins/commands/text/sed.js.map +1 -0
  272. package/dist/shell/builtins/commands/text/sha256sum.d.ts +2 -0
  273. package/dist/shell/builtins/commands/text/sha256sum.js +63 -0
  274. package/dist/shell/builtins/commands/text/sha256sum.js.map +1 -0
  275. package/dist/shell/builtins/commands/text/sort.d.ts +2 -0
  276. package/dist/shell/builtins/commands/text/sort.js +134 -0
  277. package/dist/shell/builtins/commands/text/sort.js.map +1 -0
  278. package/dist/shell/builtins/commands/text/tail.d.ts +2 -0
  279. package/dist/shell/builtins/commands/text/tail.js +10 -0
  280. package/dist/shell/builtins/commands/text/tail.js.map +1 -0
  281. package/dist/shell/builtins/commands/text/tee.d.ts +2 -0
  282. package/dist/shell/builtins/commands/text/tee.js +29 -0
  283. package/dist/shell/builtins/commands/text/tee.js.map +1 -0
  284. package/dist/shell/builtins/commands/text/tr.d.ts +2 -0
  285. package/dist/shell/builtins/commands/text/tr.js +3 -0
  286. package/dist/shell/builtins/commands/text/tr.js.map +1 -0
  287. package/dist/shell/builtins/commands/text/uniq.d.ts +2 -0
  288. package/dist/shell/builtins/commands/text/uniq.js +8 -0
  289. package/dist/shell/builtins/commands/text/uniq.js.map +1 -0
  290. package/dist/shell/builtins/commands/text/wc.d.ts +2 -0
  291. package/dist/shell/builtins/commands/text/wc.js +30 -0
  292. package/dist/shell/builtins/commands/text/wc.js.map +1 -0
  293. package/dist/shell/builtins/commands/text/xargs.d.ts +2 -0
  294. package/dist/shell/builtins/commands/text/xargs.js +138 -0
  295. package/dist/shell/builtins/commands/text/xargs.js.map +1 -0
  296. package/dist/shell/builtins/commands/text.d.ts +2 -0
  297. package/dist/shell/builtins/commands/text.js +41 -0
  298. package/dist/shell/builtins/commands/text.js.map +1 -0
  299. package/dist/shell/builtins/help-text.d.ts +69 -0
  300. package/dist/shell/builtins/help-text.js +381 -0
  301. package/dist/shell/builtins/help-text.js.map +1 -0
  302. package/dist/shell/builtins/path.d.ts +28 -0
  303. package/dist/shell/builtins/path.js +184 -0
  304. package/dist/shell/builtins/path.js.map +1 -0
  305. package/dist/shell/builtins/registry.d.ts +3 -0
  306. package/dist/shell/builtins/registry.js +75 -0
  307. package/dist/shell/builtins/registry.js.map +1 -0
  308. package/dist/shell/builtins/run.d.ts +4 -0
  309. package/dist/shell/builtins/run.js +29 -0
  310. package/dist/shell/builtins/run.js.map +1 -0
  311. package/dist/shell/builtins/runtime.d.ts +83 -0
  312. package/dist/shell/builtins/runtime.js +46 -0
  313. package/dist/shell/builtins/runtime.js.map +1 -0
  314. package/dist/shell/builtins/text.d.ts +90 -0
  315. package/dist/shell/builtins/text.js +970 -0
  316. package/dist/shell/builtins/text.js.map +1 -0
  317. package/dist/shell/control.d.ts +31 -0
  318. package/dist/shell/control.js +232 -0
  319. package/dist/shell/control.js.map +1 -0
  320. package/dist/shell/expansion.d.ts +30 -0
  321. package/dist/shell/expansion.js +514 -0
  322. package/dist/shell/expansion.js.map +1 -0
  323. package/dist/shell/functions.d.ts +10 -0
  324. package/dist/shell/functions.js +108 -0
  325. package/dist/shell/functions.js.map +1 -0
  326. package/dist/shell/runtime.d.ts +44 -0
  327. package/dist/shell/runtime.js +276 -0
  328. package/dist/shell/runtime.js.map +1 -0
  329. package/dist/shell/time.d.ts +1 -0
  330. package/dist/shell/time.js +68 -0
  331. package/dist/shell/time.js.map +1 -0
  332. package/dist/state-backend.d.ts +61 -0
  333. package/dist/state-backend.js +275 -0
  334. package/dist/state-backend.js.map +1 -0
  335. package/dist/state-node.d.ts +2 -0
  336. package/dist/state-node.js +266 -0
  337. package/dist/state-node.js.map +1 -0
  338. package/dist/types.d.ts +462 -0
  339. package/dist/types.js +2 -0
  340. package/dist/types.js.map +1 -0
  341. package/dist/utils.d.ts +5 -0
  342. package/dist/utils.js +117 -0
  343. package/dist/utils.js.map +1 -0
  344. package/dist/vbash.d.ts +40 -0
  345. package/dist/vbash.js +389 -0
  346. package/dist/vbash.js.map +1 -0
  347. package/dist/vfs.d.ts +64 -0
  348. package/dist/vfs.js +248 -0
  349. package/dist/vfs.js.map +1 -0
  350. package/dist/vprocess.d.ts +139 -0
  351. package/dist/vprocess.js +756 -0
  352. package/dist/vprocess.js.map +1 -0
  353. package/package.json +28 -0
package/README.md ADDED
@@ -0,0 +1,368 @@
1
+ # @kruntime/komputer
2
+
3
+ Runtime SDK and kernel surface for K.
4
+
5
+ This package owns the durable runtime truth:
6
+
7
+ - `Komputer`
8
+ - `AgentSession`
9
+ - `.kstate`
10
+ - VFS
11
+ - Runtime Authority
12
+ - events
13
+ - messages
14
+ - receipts
15
+ - vProcess recovery
16
+
17
+ It intentionally does not scan image source trees. Source layout and active files belong to `@kruntime/kimage`.
18
+
19
+ ## Agent Computer Surface
20
+
21
+ `agent.exec(...)` always enters K's local shell layer first. If a command cannot
22
+ run inside the virtual computer, K may delegate it to a configured remote shell.
23
+ The following work without any remote shell:
24
+
25
+ ```text
26
+ pwd cd ls cat chmod install stat du base64 echo printf grep wc head jq tail sort uniq sed sha256sum awk tr cut diff tee xargs
27
+ find basename dirname realpath readlink mkdir mktemp touch rm cp mv ln
28
+ command type which help env printenv read source . set sh bash export unset id whoami hostname uname date true false test [ [[
29
+ sleep curl wget jobs ps kill fg bg wait
30
+ registered image commands
31
+ ```
32
+
33
+ Output from K-local commands and remote commands is projected through the same
34
+ `process` event family. Streaming stdout/stderr uses
35
+ `{ type: 'process', status: 'output' }`.
36
+
37
+ K-local builtins support `ls -la`/`ls -F`, quote-aware variables, `$?`,
38
+ `${VAR:-fallback}`-style parameter defaults, `${#VAR}` length probes,
39
+ `${path##*/}`/`${path%/*}` trimming, `$((...))`, KFS glob expansion,
40
+ unquoted field splitting, bounded brace expansion, stdin/stdout/stderr
41
+ redirection, heredoc stdin, `$()` and backtick command substitution, pipes, top-level
42
+ `if` branches, top-level `for ... in` loops, and bounded `while`/`until` loops
43
+ through the VFS, so no-shell remote runtimes can still run familiar shell-shaped work
44
+ without a remote shell. `chmod` stores real mode bits in Drive/KState metadata;
45
+ `stat -c %a/%A`, `ls -l`, `test -x`, and PATH executable lookup all read those
46
+ same bits.
47
+ such as `echo note > ~/work/note.txt`, `grep alpha < notes.txt`,
48
+ `cat > file <<'EOF'`, `if test -f notes.txt; then grep alpha notes.txt; fi`,
49
+ `mkdir -p app/{src,test}`, `for file in *.ts; do basename "$file"; done`, and
50
+ `i=0; while test "$i" -lt 3; do echo "$i"; i=$((i + 1)); done`.
51
+ `printf "%s\n" one two` repeats the format for remaining args, with basic
52
+ `%s`/`%d`, width, left alignment, zero padding, and `%%` support.
53
+ `find ... -maxdepth 2 -print0 | xargs -0 -n1 ...` works inside the K shell, so
54
+ common Agent scripts can compose file discovery and text tools without a remote
55
+ shell. `find ... -exec ... {} \;` is also supported for familiar
56
+ one-file-at-a-time workflows.
57
+ `mkdir` follows normal Unix shell semantics: without `-p`, the parent must
58
+ already exist and the target must not; `mkdir -p` is the recursive, idempotent
59
+ form.
60
+ `touch -c`/`touch --no-create` follows Unix no-create behavior for existence
61
+ probes.
62
+ `rm -f` is safe as a cleanup no-op when no paths are passed, and `--` separates
63
+ options from paths that begin with `-`.
64
+ `cp --` and `mv --` follow the same path separator rule, while `cp -r` keeps
65
+ directory copies inside KFS.
66
+ `sed -n '1,20p' file`, `sed -n '$p' file`, and `sed -n '/pattern/p' file`
67
+ cover the common file-slice and match-print probes Agents use before editing.
68
+ `awk -F, '{print $1,$2,$NF,NF}'` covers the usual field-splitting and simple
69
+ projection probes without a remote shell.
70
+ `tail -n +2 file` follows Unix start-at-line semantics for header-skipping
71
+ pipelines. `head -c` and `tail -c` select UTF-8 bytes for common file sniffing
72
+ and log-tail probes.
73
+ `find -type l`, `test -L`, and `ls -F` also understand K symbolic links.
74
+ `grep -R -n pattern ~/work` searches recursively through KFS directories;
75
+ `grep -F`, `grep -E`, and repeated `grep -e` patterns cover the usual fixed
76
+ string, regex, and multiple-pattern probes.
77
+ `ln -s`, `readlink`, `realpath`, and `readlink -f` are KState-backed, so
78
+ symbolic links work on no-shell remote runtimes and survive recovery.
79
+ `curl ... | jq -r .field` also works for common API JSON responses.
80
+ `read` supports common stdin parsing patterns, including `read NAME`,
81
+ `read FIRST REST`, and `read -r RAW`.
82
+ `source file` and `. file` execute KFS shell files in the current shell state,
83
+ so profile-style files can export variables, change cwd, or adjust shell
84
+ options for later commands.
85
+ `sh file` / `bash file` and `bash -c '...'` run through the same K shell in a
86
+ child shell disk: positional parameters work, but cwd, exported variables, and
87
+ shell options do not leak back to the Agent's parent shell.
88
+ `env NAME=value cmd` runs a command with scoped temporary environment entries,
89
+ `env -u NAME cmd` temporarily removes a variable, and `env -i NAME=value cmd`
90
+ starts that command from an empty environment. These child environments do not
91
+ pollute the Agent's persistent shell state.
92
+
93
+ Network follows the same Unix-shaped rule. Runtime code can bind virtual hosts:
94
+
95
+ ```ts
96
+ const computer = await Komputer.boot(image, {
97
+ hosts: {
98
+ api: {
99
+ '/hello': 'hello\n',
100
+ '/data.json': { ok: true },
101
+ },
102
+ },
103
+ })
104
+ ```
105
+
106
+ The Agent sees those names in `/sys/hosts.md` and can use normal shell commands:
107
+
108
+ ```sh
109
+ curl http://api/hello
110
+ curl -I http://api/data.json
111
+ curl -i http://api/data.json
112
+ curl -fsSL -D ~/work/headers.txt http://api/data.json
113
+ curl -O http://api/data.json
114
+ wget -qO- http://api/data.json
115
+ ```
116
+
117
+ If a host is not bound and the current runtime profile has real `fetch`, K can use the
118
+ real network. If neither exists, the command fails clearly. K-local `curl`
119
+ supports common script options including compact flags like `-fsSL`, header
120
+ dumps with `-D`, stdout output with `-o -`, and remote-name downloads with
121
+ `-O`; `wget` follows redirects and supports Agent-friendly `-qO-` downloads.
122
+
123
+ Background remote commands are recorded as virtual processes. Agents can inspect
124
+ them with `jobs` and `ps`, move live handles with `fg`/`bg`, wait on them with
125
+ `wait`, and signal them with `kill` when the active remote implements process
126
+ signaling.
127
+
128
+ The VFS intentionally keeps a Node-like shape:
129
+
130
+ ```ts
131
+ await agent.fs.readFile('~/work/plan.md')
132
+ await agent.fs.writeFile('~/work/report.md', '...')
133
+ await agent.fs.mkdir('~/work/archive')
134
+ await agent.fs.rename('~/work/a.md', '~/work/archive/a.md')
135
+ await agent.fs.rm('~/work/archive', { recursive: true })
136
+
137
+ const tree = await agent.fs.walk('~/work')
138
+ ```
139
+
140
+ Mounted Drives are the only bridge between K paths and backing resources.
141
+ Custom Drives may implement lifecycle hooks:
142
+
143
+ ```ts
144
+ const drive = {
145
+ kind: 'drive',
146
+ name: 'crm-docs',
147
+ async mount(ctx) {
148
+ // connect, validate credentials, warm indexes
149
+ },
150
+ async unmount() {
151
+ // release backend handles
152
+ },
153
+ // readText/writeText/readdir/stat...
154
+ }
155
+ ```
156
+
157
+ When K delegates a script to a remote shell, it rewrites K paths only through the
158
+ mounted Drive's `realPath(...)`. If a Drive has no real backing path, that script
159
+ is rejected instead of pretending the remote can see the virtual resource. K-local
160
+ builtins and image commands can still work with that Drive through the VFS.
161
+
162
+ Command handlers receive submitted input as `ctx.args`/`ctx.input`, and can run
163
+ shell work through `ctx.exec(...)`, which follows the same K shell authority and
164
+ path rules as `agent.exec(...)`.
165
+
166
+ `agent.events()` follows the ordered event log until the caller aborts or the
167
+ local session handle closes. `agent.close()` explicitly ends the durable
168
+ session, emits a `session.closed` signal, and lets event tails finish after
169
+ draining already-written events. `agent.detach()` only releases the current
170
+ worker lease and preserves the durable session for another worker.
171
+
172
+ Forked sessions inherit image hooks by default:
173
+
174
+ ```ts
175
+ const reviewer = await agent.fork({ mode: 'readonly' })
176
+ const maintenance = await agent.fork({ mode: 'limited', hooks: false })
177
+ ```
178
+
179
+ `hooks: false` is for deliberate internal maintenance sessions created from a
180
+ hook. Normal application forks should keep hooks enabled.
181
+
182
+ `disk: 'overlay'` gives the fork an isolated upper layer for K-owned disk:
183
+
184
+ ```ts
185
+ const experiment = await agent.fork({ disk: 'overlay' })
186
+ ```
187
+
188
+ Writes to KState-backed paths stay in the fork overlay. External custom drives
189
+ are readonly in overlay forks so experiments cannot accidentally write through
190
+ to real services.
191
+
192
+ `fork({ mode: 'limited', scope })` carries the scope into the child session.
193
+ Forked sessions are registered with the parent `Komputer`, so `computer.close()`
194
+ releases their leases together with normal logged-in sessions.
195
+
196
+ Each active session holds a durable worker lease in `.kstate`. A second worker
197
+ cannot drive the same session until the lease is released or expires. Long
198
+ running sessions renew the lease with a heartbeat. `computer.close()` detaches
199
+ local workers by default, while `computer.close({ endSessions: true })` ends
200
+ them. `computer.recoverSessions()` can take over detached or expired sessions
201
+ after process shutdown or crash.
202
+
203
+ Long-running workers can call `computer.detachIdleSessions({ idleForMs })` to
204
+ release idle AgentSession handles without ending durable sessions. Running
205
+ background jobs are skipped by default. A later `login(agent, { id })` restores
206
+ the same Agent from KState.
207
+
208
+ For fleets, use `KomputerPool` as a thin lifecycle cache around the same boot
209
+ and login primitives:
210
+
211
+ ```ts
212
+ import { Komputer, KomputerPool } from '@kruntime/komputer'
213
+
214
+ const pool = new KomputerPool({
215
+ maxWarm: 100,
216
+ idleForMs: 60_000,
217
+ boot: key => Komputer.boot(image, {
218
+ disk: stateFor(key),
219
+ remote,
220
+ models,
221
+ }),
222
+ })
223
+
224
+ const agent = await pool.login('tenant:alice:assistant', 'assistant', {
225
+ id: 'chat:inbox',
226
+ })
227
+
228
+ await pool.withLogin('tenant:alice:assistant', { id: 'chat:inbox' }, async agent => {
229
+ await agent.exec('cat ~/task.md')
230
+ })
231
+
232
+ await pool.sweep()
233
+ console.log(pool.stats())
234
+ ```
235
+
236
+ The pool is not a task system and not another storage abstraction. A key maps
237
+ to one durable Computer. `KomputerPool` only coalesces concurrent boots, keeps a
238
+ bounded set of warm JavaScript handles, detaches idle sessions, and closes idle
239
+ Computers. Use `withLogin(...)` with `maxWarm: 0` for browser, extension,
240
+ embedded, or serverless profiles that should keep no warm Computers between
241
+ requests. Plain `get(...)` and `login(...)` keep a warm handle until
242
+ `sweep(...)` or `release(...)`.
243
+
244
+ For operations dashboards and leak checks, use `pool.stats()`,
245
+ `computer.stats()`, and `agent.stats()`. These are local-worker counters for
246
+ warm Computers, booting entries, local session handles, active virtual
247
+ processes, commands, hooks, crons, mounts, hosts, handlers, and shell
248
+ functions. They do not scan durable JSONL history and do not hold extra
249
+ references.
250
+
251
+ `computer.close()` releases local active process handles as well as session
252
+ handlers. Durable background process rows stay in KState for recovery instead
253
+ of keeping worker timers or remote stream readers alive after shutdown.
254
+
255
+ Custom disk and remote adapters can expose `close()`. `computer.close()`
256
+ releases them after sessions and mounts are settled, which keeps browser,
257
+ plugin, cloud, and DB-backed runtimes from leaking bridge handles or caches.
258
+
259
+ On recovery, K seals unfinished tool calls with an uncertain tool result and
260
+ seals any running turn with a terminal `turn` event. That keeps the provider
261
+ message stream, event stream, and input queue from containing dangling state
262
+ after a worker takeover.
263
+
264
+ K also separates provider-message sealing from event-stream sealing. If a
265
+ durable assistant message contains `tool_use`, recovery appends an uncertain
266
+ `tool_result` message. If only a streamed public `tool` event was durable before
267
+ the crash, recovery emits a sealed/uncertain `tool` event without inventing a
268
+ provider message.
269
+
270
+ Background process receipts are also sealed append-only. Starting a background
271
+ remote or K-local process writes an `uncertain` receipt; normal completion appends
272
+ the same receipt id again as `committed` or `failed`. If a worker dies before
273
+ that final row exists, the receipt remains `uncertain` for reconciliation.
274
+ VFS effects also write receipts for `vfs.write`, `vfs.append`, `vfs.mkdir`,
275
+ `vfs.rm`, `vfs.rename`, `vfs.symlink`, `vfs.chmod`, and `vfs.utime`. Those
276
+ receipts carry caller provenance through `by` and record operation metadata such
277
+ as path and byte count, not file contents.
278
+ Deterministic K-owned virtual processes can do better when their state is fully
279
+ recoverable: for example, a crashed `sleep 10 &` is resumed from its durable
280
+ start time or completed immediately if its deadline already passed. Remote
281
+ processes and non-replayable K scripts stay conservative and reconcile through
282
+ `uncertain`.
283
+
284
+ Approvals use one simple public pair: hooks call `ctx.ask(...)`, and external
285
+ code calls `agent.decide(id, 'allow' | 'reject')`. K stores the paused action in
286
+ `.kstate`; allowing it resumes the same shell, command, filesystem, model, or
287
+ turn action, including after a worker detach and later login recovery.
288
+
289
+ Restricted modes do not trust arbitrary remote shell execution. A remote must
290
+ declare hard shell sandbox support before `readonly`, `plan`, or `limited` can
291
+ delegate external shell commands to it. K hardens every remote sandbox request
292
+ with mandatory `denyWrite` entries for sensitive startup/config paths such as
293
+ shell rc files, `.mcp.json`, editor config directories, `.git/config`,
294
+ `.git/hooks`, and `_shared`, then validates paths and host allow-lists before a
295
+ Remote adapter sees the request.
296
+
297
+ `limited` is an explicit allow-list mode. It applies to filesystem writes,
298
+ remote shell commands, K shell commands, and direct `agent.command(...)` calls.
299
+ Filesystem scope entries may use `~/...`; K normalizes them against the Agent's
300
+ home directory when the session or fork is created.
301
+
302
+ Markdown commands can request invocation-local mode changes, such as
303
+ `readonly: true`; K applies that only for the command turn and restores the
304
+ AgentSession mode afterward.
305
+
306
+ ## Model Providers
307
+
308
+ K models are LLM adapters with one stable surface:
309
+
310
+ ```ts
311
+ model.complete({ messages })
312
+ ```
313
+
314
+ The package includes cross-platform fetch-based adapters for the primary LLM
315
+ protocol families:
316
+
317
+ ```ts
318
+ import {
319
+ anthropicMessagesModel,
320
+ deepseekMessagesModel,
321
+ deepseekOpenAIModel,
322
+ minimaxOpenAIModel,
323
+ openaiChatCompletionsModel,
324
+ openaiResponsesModel,
325
+ } from '@kruntime/komputer'
326
+ ```
327
+
328
+ Provider-specific continuation data is stored as adapter-owned sidecar state on
329
+ the message. K core only sees the standard `content` blocks and an optional
330
+ generic `provider.anchor` bit that asks the message window to retain a cache
331
+ anchor. OpenAI Responses encrypted reasoning, DeepSeek `reasoning_content`,
332
+ Anthropic signatures, and MiniMax `reasoning_details` are interpreted only by
333
+ their own adapters.
334
+
335
+ Other services should be exposed as commands, mounts, MCP tools, or application
336
+ APIs unless they are actually LLM-like.
337
+
338
+ ## Secrets
339
+
340
+ Secrets are bound at runtime, not baked into images. Agents can inspect
341
+ `/sys/secrets.md` to know which handles exist, but the raw values are only
342
+ available to trusted command/hook/cron code through:
343
+
344
+ ```ts
345
+ ctx.secret('github')
346
+ ```
347
+
348
+ ## Entrypoints
349
+
350
+ ```ts
351
+ import { boot, memoryDisk, noShellRemote } from '@kruntime/komputer'
352
+ ```
353
+
354
+ The root entrypoint is cross-platform and must be importable anywhere
355
+ JavaScript can run.
356
+
357
+ ```ts
358
+ import { Komputer } from '@kruntime/komputer'
359
+ import { localDisk, localRemote } from '@kruntime/komputer/node'
360
+
361
+ const computer = await Komputer.boot(image, {
362
+ disk: localDisk('.kstate'),
363
+ remotes: { local: localRemote() },
364
+ })
365
+ ```
366
+
367
+ Node-only helpers live in the `/node` subpath so browser, mini program,
368
+ extension, and embedded bundles do not inherit Node filesystem/process modules.
@@ -0,0 +1,28 @@
1
+ import type { KState } from '../kstate.js';
2
+ export interface ApprovalRecord extends Record<string, unknown> {
3
+ id: string;
4
+ status?: string;
5
+ hook?: string;
6
+ actionKey?: string;
7
+ request?: Record<string, unknown>;
8
+ current?: Record<string, unknown>;
9
+ createdAt?: string;
10
+ decidedAt?: string;
11
+ consumedAt?: string;
12
+ decision?: unknown;
13
+ by?: string;
14
+ result?: unknown;
15
+ }
16
+ export declare class SessionApprovals {
17
+ private readonly kstate;
18
+ private readonly sessionId;
19
+ constructor(kstate: KState, sessionId: string);
20
+ create(hook: string, current: Record<string, unknown>, request: Record<string, unknown>): Promise<ApprovalRecord>;
21
+ byId(approvalId: string): Promise<ApprovalRecord | undefined>;
22
+ forAction(hook: string, current: Record<string, unknown>): Promise<ApprovalRecord | undefined>;
23
+ append(row: Record<string, unknown>): Promise<void>;
24
+ consume(approval: ApprovalRecord): Promise<Record<string, unknown>>;
25
+ resumed(approvalId: string, result: unknown): Promise<void>;
26
+ }
27
+ export declare function normalizeApprovalDecision(decision: unknown): 'allowed' | 'rejected';
28
+ export declare function resultSummary(value: unknown): Record<string, unknown>;
@@ -0,0 +1,109 @@
1
+ import { id, now, sha256 } from "../utils.js";
2
+ export class SessionApprovals {
3
+ kstate;
4
+ sessionId;
5
+ constructor(kstate, sessionId) {
6
+ this.kstate = kstate;
7
+ this.sessionId = sessionId;
8
+ }
9
+ async create(hook, current, request) {
10
+ const approval = {
11
+ id: id('approval'),
12
+ status: 'pending',
13
+ hook,
14
+ actionKey: approvalActionKey(hook, current),
15
+ request,
16
+ current,
17
+ createdAt: now(),
18
+ };
19
+ await this.kstate.appendSessionJsonl(this.sessionId, 'approvals.jsonl', approval);
20
+ return approval;
21
+ }
22
+ async byId(approvalId) {
23
+ const rows = await this.kstate.readSessionJsonl(this.sessionId, 'approvals.jsonl');
24
+ const related = rows.filter((row) => row.id === approvalId);
25
+ if (!related.length)
26
+ return undefined;
27
+ return Object.assign({}, ...related);
28
+ }
29
+ async forAction(hook, current) {
30
+ const actionKey = approvalActionKey(hook, current);
31
+ const rows = await this.kstate.readSessionJsonl(this.sessionId, 'approvals.jsonl');
32
+ const grouped = new Map();
33
+ for (const row of rows) {
34
+ if (row.actionKey !== actionKey && !grouped.has(row.id))
35
+ continue;
36
+ const previous = grouped.get(row.id) || {};
37
+ const next = { ...previous, ...row };
38
+ if (next.actionKey === actionKey)
39
+ grouped.set(row.id, next);
40
+ }
41
+ const candidates = [...grouped.values()]
42
+ .filter((row) => row.hook === hook && (row.status === 'pending' || row.status === 'allowed'))
43
+ .sort((a, b) => String(b.createdAt || b.decidedAt || '').localeCompare(String(a.createdAt || a.decidedAt || '')));
44
+ return candidates[0];
45
+ }
46
+ async append(row) {
47
+ await this.kstate.appendSessionJsonl(this.sessionId, 'approvals.jsonl', row);
48
+ }
49
+ async consume(approval) {
50
+ const row = {
51
+ id: approval.id,
52
+ status: 'consumed',
53
+ consumedAt: now(),
54
+ };
55
+ await this.append(row);
56
+ return row;
57
+ }
58
+ async resumed(approvalId, result) {
59
+ await this.append({
60
+ id: approvalId,
61
+ status: 'resumed',
62
+ resumedAt: now(),
63
+ result: resultSummary(result),
64
+ });
65
+ }
66
+ }
67
+ export function normalizeApprovalDecision(decision) {
68
+ if (decision === true)
69
+ return 'allowed';
70
+ if (decision === false)
71
+ return 'rejected';
72
+ if (typeof decision === 'string') {
73
+ const clean = decision.toLowerCase();
74
+ if (clean === 'allow' || clean === 'allowed' || clean === 'yes' || clean === 'approve' || clean === 'approved')
75
+ return 'allowed';
76
+ if (clean === 'reject' || clean === 'rejected' || clean === 'no' || clean === 'deny' || clean === 'denied')
77
+ return 'rejected';
78
+ }
79
+ if (decision && typeof decision === 'object') {
80
+ const record = decision;
81
+ return normalizeApprovalDecision(record.decision ?? record.status ?? record.action);
82
+ }
83
+ throw new Error(`approval decision must be "allow" or "reject"`);
84
+ }
85
+ export function resultSummary(value) {
86
+ if (value && typeof value === 'object') {
87
+ const record = value;
88
+ return {
89
+ status: record.status,
90
+ code: record.code,
91
+ inputId: record.inputId,
92
+ turnId: record.turnId,
93
+ type: record.type,
94
+ };
95
+ }
96
+ return { type: typeof value };
97
+ }
98
+ function approvalActionKey(hook, current) {
99
+ return sha256(stableJson({ hook, current }));
100
+ }
101
+ function stableJson(value) {
102
+ if (value === null || typeof value !== 'object')
103
+ return JSON.stringify(value);
104
+ if (Array.isArray(value))
105
+ return `[${value.map(stableJson).join(',')}]`;
106
+ const record = value;
107
+ return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${stableJson(record[key])}`).join(',')}}`;
108
+ }
109
+ //# sourceMappingURL=approvals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approvals.js","sourceRoot":"","sources":["../../../../../packages/komputer/src/agent/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAkB7C,MAAM,OAAO,gBAAgB;IACV,MAAM,CAAQ;IACd,SAAS,CAAQ;IAElC,YAAY,MAAc,EAAE,SAAiB;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,OAAgC,EAAE,OAAgC;QAC3F,MAAM,QAAQ,GAAG;YACf,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC;YAClB,MAAM,EAAE,SAAS;YACjB,IAAI;YACJ,SAAS,EAAE,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC;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IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAA;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,OAAO,KAAK,EAAE,CAAA;AAC/B,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY,EAAE,OAAgC;IACvE,OAAO,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;AAC9C,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC7E,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA;IACvE,MAAM,MAAM,GAAG,KAAgC,CAAA;IAC/C,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA;AACtH,CAAC"}
@@ -0,0 +1,67 @@
1
+ import type { KState } from '../kstate.js';
2
+ import type { KMessage } from '../types.js';
3
+ export interface MessagePageOptions {
4
+ view?: 'full' | 'current';
5
+ since?: number;
6
+ before?: number;
7
+ limit?: number;
8
+ }
9
+ export interface MessageTailOptions {
10
+ view?: 'full' | 'current';
11
+ since?: number;
12
+ signal?: AbortSignal;
13
+ }
14
+ export interface SessionMessagesInit {
15
+ kstate: KState;
16
+ sessionId: string;
17
+ isClosed: () => boolean;
18
+ system: () => string;
19
+ }
20
+ export declare class SessionMessages {
21
+ private readonly kstate;
22
+ private readonly sessionId;
23
+ private readonly isClosed;
24
+ private readonly system;
25
+ private readonly waiters;
26
+ constructor({ kstate, sessionId, isClosed, system }: SessionMessagesInit);
27
+ append(message: Omit<KMessage, 'seq' | 'at'>): Promise<KMessage>;
28
+ appendMany(messages: Array<Omit<KMessage, 'seq' | 'at'>>): Promise<KMessage[]>;
29
+ appendCurrent(message: KMessage): Promise<void>;
30
+ forModel(): Promise<KMessage[]>;
31
+ view(): {
32
+ get: (options?: {}) => Promise<{
33
+ messages: KMessage[];
34
+ cursor: number;
35
+ hasMore: boolean;
36
+ }>;
37
+ current: (options?: {}) => Promise<{
38
+ messages: KMessage[];
39
+ cursor: number;
40
+ hasMore: boolean;
41
+ }>;
42
+ full: (options?: {}) => Promise<{
43
+ messages: KMessage[];
44
+ cursor: number;
45
+ hasMore: boolean;
46
+ }>;
47
+ tail: (options?: {}) => AsyncIterable<{
48
+ cursor: number;
49
+ message: KMessage;
50
+ }>;
51
+ };
52
+ get({ view, since, before, limit }?: MessagePageOptions): Promise<{
53
+ messages: KMessage[];
54
+ cursor: number;
55
+ hasMore: boolean;
56
+ }>;
57
+ tail({ view, since, signal }?: MessageTailOptions): AsyncIterable<{
58
+ cursor: number;
59
+ message: KMessage;
60
+ }>;
61
+ private readFullRange;
62
+ private indexFullMessage;
63
+ private offsetForCursor;
64
+ wake(): void;
65
+ clear(): void;
66
+ private waitForMessageOrPoll;
67
+ }