@kvman/kvcoder 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 (409) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/dist/api.d.ts +386 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +2 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/artifacts/artifact-format.d.ts +9 -0
  8. package/dist/artifacts/artifact-format.d.ts.map +1 -0
  9. package/dist/artifacts/artifact-format.js +32 -0
  10. package/dist/artifacts/artifact-format.js.map +1 -0
  11. package/dist/artifacts/artifact-records.d.ts +12 -0
  12. package/dist/artifacts/artifact-records.d.ts.map +1 -0
  13. package/dist/artifacts/artifact-records.js +17 -0
  14. package/dist/artifacts/artifact-records.js.map +1 -0
  15. package/dist/artifacts/register-artifacts.d.ts +3 -0
  16. package/dist/artifacts/register-artifacts.d.ts.map +1 -0
  17. package/dist/artifacts/register-artifacts.js +37 -0
  18. package/dist/artifacts/register-artifacts.js.map +1 -0
  19. package/dist/calls/binary-checks.d.ts +8 -0
  20. package/dist/calls/binary-checks.d.ts.map +1 -0
  21. package/dist/calls/binary-checks.js +12 -0
  22. package/dist/calls/binary-checks.js.map +1 -0
  23. package/dist/calls/connector-help.d.ts +3 -0
  24. package/dist/calls/connector-help.d.ts.map +1 -0
  25. package/dist/calls/connector-help.js +73 -0
  26. package/dist/calls/connector-help.js.map +1 -0
  27. package/dist/calls/help-text.d.ts +19 -0
  28. package/dist/calls/help-text.d.ts.map +1 -0
  29. package/dist/calls/help-text.js +22 -0
  30. package/dist/calls/help-text.js.map +1 -0
  31. package/dist/calls/line-run.d.ts +33 -0
  32. package/dist/calls/line-run.d.ts.map +1 -0
  33. package/dist/calls/line-run.js +56 -0
  34. package/dist/calls/line-run.js.map +1 -0
  35. package/dist/calls/run-shell.d.ts +12 -0
  36. package/dist/calls/run-shell.d.ts.map +1 -0
  37. package/dist/calls/run-shell.js +88 -0
  38. package/dist/calls/run-shell.js.map +1 -0
  39. package/dist/calls/run-tool.d.ts +49 -0
  40. package/dist/calls/run-tool.d.ts.map +1 -0
  41. package/dist/calls/run-tool.js +66 -0
  42. package/dist/calls/run-tool.js.map +1 -0
  43. package/dist/calls/shell-command.d.ts +25 -0
  44. package/dist/calls/shell-command.d.ts.map +1 -0
  45. package/dist/calls/shell-command.js +31 -0
  46. package/dist/calls/shell-command.js.map +1 -0
  47. package/dist/calls/shell-program.d.ts +5 -0
  48. package/dist/calls/shell-program.d.ts.map +1 -0
  49. package/dist/calls/shell-program.js +8 -0
  50. package/dist/calls/shell-program.js.map +1 -0
  51. package/dist/connector-call.d.ts +66 -0
  52. package/dist/connector-call.d.ts.map +1 -0
  53. package/dist/connector-call.js +133 -0
  54. package/dist/connector-call.js.map +1 -0
  55. package/dist/connectors/artifact.d.ts +51 -0
  56. package/dist/connectors/artifact.d.ts.map +1 -0
  57. package/dist/connectors/artifact.js +101 -0
  58. package/dist/connectors/artifact.js.map +1 -0
  59. package/dist/connectors/ask.d.ts +58 -0
  60. package/dist/connectors/ask.d.ts.map +1 -0
  61. package/dist/connectors/ask.js +85 -0
  62. package/dist/connectors/ask.js.map +1 -0
  63. package/dist/connectors/background.d.ts +29 -0
  64. package/dist/connectors/background.d.ts.map +1 -0
  65. package/dist/connectors/background.js +56 -0
  66. package/dist/connectors/background.js.map +1 -0
  67. package/dist/connectors/binary.d.ts +5 -0
  68. package/dist/connectors/binary.d.ts.map +1 -0
  69. package/dist/connectors/binary.js +27 -0
  70. package/dist/connectors/binary.js.map +1 -0
  71. package/dist/connectors/builtin-connectors.d.ts +217 -0
  72. package/dist/connectors/builtin-connectors.d.ts.map +1 -0
  73. package/dist/connectors/builtin-connectors.js +49 -0
  74. package/dist/connectors/builtin-connectors.js.map +1 -0
  75. package/dist/connectors/connector-command.d.ts +26 -0
  76. package/dist/connectors/connector-command.d.ts.map +1 -0
  77. package/dist/connectors/connector-command.js +17 -0
  78. package/dist/connectors/connector-command.js.map +1 -0
  79. package/dist/connectors/delegate.d.ts +32 -0
  80. package/dist/connectors/delegate.d.ts.map +1 -0
  81. package/dist/connectors/delegate.js +82 -0
  82. package/dist/connectors/delegate.js.map +1 -0
  83. package/dist/connectors/fs.d.ts +60 -0
  84. package/dist/connectors/fs.d.ts.map +1 -0
  85. package/dist/connectors/fs.js +132 -0
  86. package/dist/connectors/fs.js.map +1 -0
  87. package/dist/connectors/mcp.d.ts +37 -0
  88. package/dist/connectors/mcp.d.ts.map +1 -0
  89. package/dist/connectors/mcp.js +69 -0
  90. package/dist/connectors/mcp.js.map +1 -0
  91. package/dist/connectors/payload-fields.d.ts +9 -0
  92. package/dist/connectors/payload-fields.d.ts.map +1 -0
  93. package/dist/connectors/payload-fields.js +13 -0
  94. package/dist/connectors/payload-fields.js.map +1 -0
  95. package/dist/connectors/shell.d.ts +19 -0
  96. package/dist/connectors/shell.d.ts.map +1 -0
  97. package/dist/connectors/shell.js +22 -0
  98. package/dist/connectors/shell.js.map +1 -0
  99. package/dist/delay.d.ts +3 -0
  100. package/dist/delay.d.ts.map +1 -0
  101. package/dist/delay.js +11 -0
  102. package/dist/delay.js.map +1 -0
  103. package/dist/delegate/approved-run.d.ts +13 -0
  104. package/dist/delegate/approved-run.d.ts.map +1 -0
  105. package/dist/delegate/approved-run.js +54 -0
  106. package/dist/delegate/approved-run.js.map +1 -0
  107. package/dist/delegate/programs.d.ts +32 -0
  108. package/dist/delegate/programs.d.ts.map +1 -0
  109. package/dist/delegate/programs.js +67 -0
  110. package/dist/delegate/programs.js.map +1 -0
  111. package/dist/delegate/register-worker-run.d.ts +9 -0
  112. package/dist/delegate/register-worker-run.d.ts.map +1 -0
  113. package/dist/delegate/register-worker-run.js +70 -0
  114. package/dist/delegate/register-worker-run.js.map +1 -0
  115. package/dist/delegate/run-program.d.ts +9 -0
  116. package/dist/delegate/run-program.d.ts.map +1 -0
  117. package/dist/delegate/run-program.js +59 -0
  118. package/dist/delegate/run-program.js.map +1 -0
  119. package/dist/delegate/runs.d.ts +27 -0
  120. package/dist/delegate/runs.d.ts.map +1 -0
  121. package/dist/delegate/runs.js +68 -0
  122. package/dist/delegate/runs.js.map +1 -0
  123. package/dist/delegate/workers.d.ts +266 -0
  124. package/dist/delegate/workers.d.ts.map +1 -0
  125. package/dist/delegate/workers.js +80 -0
  126. package/dist/delegate/workers.js.map +1 -0
  127. package/dist/docs.d.ts +14 -0
  128. package/dist/docs.d.ts.map +1 -0
  129. package/dist/docs.js +59 -0
  130. package/dist/docs.js.map +1 -0
  131. package/dist/files/edit-text.d.ts +13 -0
  132. package/dist/files/edit-text.d.ts.map +1 -0
  133. package/dist/files/edit-text.js +46 -0
  134. package/dist/files/edit-text.js.map +1 -0
  135. package/dist/files/file-queue.d.ts +3 -0
  136. package/dist/files/file-queue.d.ts.map +1 -0
  137. package/dist/files/file-queue.js +17 -0
  138. package/dist/files/file-queue.js.map +1 -0
  139. package/dist/files/list-entries.d.ts +14 -0
  140. package/dist/files/list-entries.d.ts.map +1 -0
  141. package/dist/files/list-entries.js +40 -0
  142. package/dist/files/list-entries.js.map +1 -0
  143. package/dist/files/read-file.d.ts +17 -0
  144. package/dist/files/read-file.d.ts.map +1 -0
  145. package/dist/files/read-file.js +53 -0
  146. package/dist/files/read-file.js.map +1 -0
  147. package/dist/files/search-text.d.ts +14 -0
  148. package/dist/files/search-text.d.ts.map +1 -0
  149. package/dist/files/search-text.js +62 -0
  150. package/dist/files/search-text.js.map +1 -0
  151. package/dist/files/workspace-path.d.ts +5 -0
  152. package/dist/files/workspace-path.d.ts.map +1 -0
  153. package/dist/files/workspace-path.js +37 -0
  154. package/dist/files/workspace-path.js.map +1 -0
  155. package/dist/index.d.ts +6 -0
  156. package/dist/index.d.ts.map +1 -0
  157. package/dist/index.js +68 -0
  158. package/dist/index.js.map +1 -0
  159. package/dist/jobs/job-rows.d.ts +24 -0
  160. package/dist/jobs/job-rows.d.ts.map +1 -0
  161. package/dist/jobs/job-rows.js +74 -0
  162. package/dist/jobs/job-rows.js.map +1 -0
  163. package/dist/jobs/process-handlers.d.ts +8 -0
  164. package/dist/jobs/process-handlers.d.ts.map +1 -0
  165. package/dist/jobs/process-handlers.js +43 -0
  166. package/dist/jobs/process-handlers.js.map +1 -0
  167. package/dist/jobs/process-records.d.ts +15 -0
  168. package/dist/jobs/process-records.d.ts.map +1 -0
  169. package/dist/jobs/process-records.js +30 -0
  170. package/dist/jobs/process-records.js.map +1 -0
  171. package/dist/jobs/process-report.d.ts +8 -0
  172. package/dist/jobs/process-report.d.ts.map +1 -0
  173. package/dist/jobs/process-report.js +44 -0
  174. package/dist/jobs/process-report.js.map +1 -0
  175. package/dist/jobs/process-run.d.ts +26 -0
  176. package/dist/jobs/process-run.d.ts.map +1 -0
  177. package/dist/jobs/process-run.js +70 -0
  178. package/dist/jobs/process-run.js.map +1 -0
  179. package/dist/jobs/process-text.d.ts +5 -0
  180. package/dist/jobs/process-text.d.ts.map +1 -0
  181. package/dist/jobs/process-text.js +11 -0
  182. package/dist/jobs/process-text.js.map +1 -0
  183. package/dist/jobs/register-jobs.d.ts +3 -0
  184. package/dist/jobs/register-jobs.d.ts.map +1 -0
  185. package/dist/jobs/register-jobs.js +61 -0
  186. package/dist/jobs/register-jobs.js.map +1 -0
  187. package/dist/mcp/command-transport.d.ts +17 -0
  188. package/dist/mcp/command-transport.d.ts.map +1 -0
  189. package/dist/mcp/command-transport.js +60 -0
  190. package/dist/mcp/command-transport.js.map +1 -0
  191. package/dist/mcp/connect.d.ts +12 -0
  192. package/dist/mcp/connect.d.ts.map +1 -0
  193. package/dist/mcp/connect.js +54 -0
  194. package/dist/mcp/connect.js.map +1 -0
  195. package/dist/mcp/oauth-provider.d.ts +25 -0
  196. package/dist/mcp/oauth-provider.d.ts.map +1 -0
  197. package/dist/mcp/oauth-provider.js +59 -0
  198. package/dist/mcp/oauth-provider.js.map +1 -0
  199. package/dist/mcp/register-mcp.d.ts +3 -0
  200. package/dist/mcp/register-mcp.d.ts.map +1 -0
  201. package/dist/mcp/register-mcp.js +61 -0
  202. package/dist/mcp/register-mcp.js.map +1 -0
  203. package/dist/mcp/secrets.d.ts +7 -0
  204. package/dist/mcp/secrets.d.ts.map +1 -0
  205. package/dist/mcp/secrets.js +20 -0
  206. package/dist/mcp/secrets.js.map +1 -0
  207. package/dist/mcp/servers.d.ts +33 -0
  208. package/dist/mcp/servers.d.ts.map +1 -0
  209. package/dist/mcp/servers.js +31 -0
  210. package/dist/mcp/servers.js.map +1 -0
  211. package/dist/mcp/sign-in-record.d.ts +10 -0
  212. package/dist/mcp/sign-in-record.d.ts.map +1 -0
  213. package/dist/mcp/sign-in-record.js +4 -0
  214. package/dist/mcp/sign-in-record.js.map +1 -0
  215. package/dist/mcp/sign-in.d.ts +12 -0
  216. package/dist/mcp/sign-in.d.ts.map +1 -0
  217. package/dist/mcp/sign-in.js +75 -0
  218. package/dist/mcp/sign-in.js.map +1 -0
  219. package/dist/mcp/tools.d.ts +19 -0
  220. package/dist/mcp/tools.d.ts.map +1 -0
  221. package/dist/mcp/tools.js +31 -0
  222. package/dist/mcp/tools.js.map +1 -0
  223. package/dist/messages/attachments.d.ts +8 -0
  224. package/dist/messages/attachments.d.ts.map +1 -0
  225. package/dist/messages/attachments.js +48 -0
  226. package/dist/messages/attachments.js.map +1 -0
  227. package/dist/messages/receive-message.d.ts +15 -0
  228. package/dist/messages/receive-message.d.ts.map +1 -0
  229. package/dist/messages/receive-message.js +60 -0
  230. package/dist/messages/receive-message.js.map +1 -0
  231. package/dist/messages/register-messages.d.ts +3 -0
  232. package/dist/messages/register-messages.d.ts.map +1 -0
  233. package/dist/messages/register-messages.js +63 -0
  234. package/dist/messages/register-messages.js.map +1 -0
  235. package/dist/problems.d.ts +8 -0
  236. package/dist/problems.d.ts.map +1 -0
  237. package/dist/problems.js +14 -0
  238. package/dist/problems.js.map +1 -0
  239. package/dist/prompt/build-prompt.d.ts +29 -0
  240. package/dist/prompt/build-prompt.d.ts.map +1 -0
  241. package/dist/prompt/build-prompt.js +60 -0
  242. package/dist/prompt/build-prompt.js.map +1 -0
  243. package/dist/prompt/register-prompt.d.ts +3 -0
  244. package/dist/prompt/register-prompt.d.ts.map +1 -0
  245. package/dist/prompt/register-prompt.js +29 -0
  246. package/dist/prompt/register-prompt.js.map +1 -0
  247. package/dist/prompt/session-prompt.d.ts +24 -0
  248. package/dist/prompt/session-prompt.d.ts.map +1 -0
  249. package/dist/prompt/session-prompt.js +50 -0
  250. package/dist/prompt/session-prompt.js.map +1 -0
  251. package/dist/prompt/working-method.d.ts +7 -0
  252. package/dist/prompt/working-method.d.ts.map +1 -0
  253. package/dist/prompt/working-method.js +51 -0
  254. package/dist/prompt/working-method.js.map +1 -0
  255. package/dist/register-settings.d.ts +142 -0
  256. package/dist/register-settings.d.ts.map +1 -0
  257. package/dist/register-settings.js +51 -0
  258. package/dist/register-settings.js.map +1 -0
  259. package/dist/registry/loaded.d.ts +32 -0
  260. package/dist/registry/loaded.d.ts.map +1 -0
  261. package/dist/registry/loaded.js +41 -0
  262. package/dist/registry/loaded.js.map +1 -0
  263. package/dist/registry/register-connectors.d.ts +32 -0
  264. package/dist/registry/register-connectors.d.ts.map +1 -0
  265. package/dist/registry/register-connectors.js +126 -0
  266. package/dist/registry/register-connectors.js.map +1 -0
  267. package/dist/registry/register-sections.d.ts +18 -0
  268. package/dist/registry/register-sections.d.ts.map +1 -0
  269. package/dist/registry/register-sections.js +99 -0
  270. package/dist/registry/register-sections.js.map +1 -0
  271. package/dist/registry/session-points.d.ts +11 -0
  272. package/dist/registry/session-points.d.ts.map +1 -0
  273. package/dist/registry/session-points.js +89 -0
  274. package/dist/registry/session-points.js.map +1 -0
  275. package/dist/result-text.d.ts +11 -0
  276. package/dist/result-text.d.ts.map +1 -0
  277. package/dist/result-text.js +21 -0
  278. package/dist/result-text.js.map +1 -0
  279. package/dist/schemas/records.d.ts +357 -0
  280. package/dist/schemas/records.d.ts.map +1 -0
  281. package/dist/schemas/records.js +159 -0
  282. package/dist/schemas/records.js.map +1 -0
  283. package/dist/schemas/registry.d.ts +160 -0
  284. package/dist/schemas/registry.d.ts.map +1 -0
  285. package/dist/schemas/registry.js +37 -0
  286. package/dist/schemas/registry.js.map +1 -0
  287. package/dist/sessions/new-session.d.ts +6 -0
  288. package/dist/sessions/new-session.d.ts.map +1 -0
  289. package/dist/sessions/new-session.js +52 -0
  290. package/dist/sessions/new-session.js.map +1 -0
  291. package/dist/sessions/register-fork-export.d.ts +5 -0
  292. package/dist/sessions/register-fork-export.d.ts.map +1 -0
  293. package/dist/sessions/register-fork-export.js +62 -0
  294. package/dist/sessions/register-fork-export.js.map +1 -0
  295. package/dist/sessions/register-lifecycle.d.ts +3 -0
  296. package/dist/sessions/register-lifecycle.d.ts.map +1 -0
  297. package/dist/sessions/register-lifecycle.js +59 -0
  298. package/dist/sessions/register-lifecycle.js.map +1 -0
  299. package/dist/sessions/register-sessions.d.ts +3 -0
  300. package/dist/sessions/register-sessions.d.ts.map +1 -0
  301. package/dist/sessions/register-sessions.js +93 -0
  302. package/dist/sessions/register-sessions.js.map +1 -0
  303. package/dist/sessions/session-lookup.d.ts +10 -0
  304. package/dist/sessions/session-lookup.d.ts.map +1 -0
  305. package/dist/sessions/session-lookup.js +25 -0
  306. package/dist/sessions/session-lookup.js.map +1 -0
  307. package/dist/sessions/session-view.d.ts +118 -0
  308. package/dist/sessions/session-view.d.ts.map +1 -0
  309. package/dist/sessions/session-view.js +105 -0
  310. package/dist/sessions/session-view.js.map +1 -0
  311. package/dist/store/collections.d.ts +471 -0
  312. package/dist/store/collections.d.ts.map +1 -0
  313. package/dist/store/collections.js +46 -0
  314. package/dist/store/collections.js.map +1 -0
  315. package/dist/turns/background.d.ts +6 -0
  316. package/dist/turns/background.d.ts.map +1 -0
  317. package/dist/turns/background.js +27 -0
  318. package/dist/turns/background.js.map +1 -0
  319. package/dist/turns/cancel-turn.d.ts +3 -0
  320. package/dist/turns/cancel-turn.d.ts.map +1 -0
  321. package/dist/turns/cancel-turn.js +31 -0
  322. package/dist/turns/cancel-turn.js.map +1 -0
  323. package/dist/turns/compaction.d.ts +12 -0
  324. package/dist/turns/compaction.d.ts.map +1 -0
  325. package/dist/turns/compaction.js +55 -0
  326. package/dist/turns/compaction.js.map +1 -0
  327. package/dist/turns/end-turn.d.ts +15 -0
  328. package/dist/turns/end-turn.d.ts.map +1 -0
  329. package/dist/turns/end-turn.js +67 -0
  330. package/dist/turns/end-turn.js.map +1 -0
  331. package/dist/turns/history.d.ts +28 -0
  332. package/dist/turns/history.d.ts.map +1 -0
  333. package/dist/turns/history.js +47 -0
  334. package/dist/turns/history.js.map +1 -0
  335. package/dist/turns/lost-reply.d.ts +31 -0
  336. package/dist/turns/lost-reply.d.ts.map +1 -0
  337. package/dist/turns/lost-reply.js +43 -0
  338. package/dist/turns/lost-reply.js.map +1 -0
  339. package/dist/turns/message-blocks.d.ts +9 -0
  340. package/dist/turns/message-blocks.d.ts.map +1 -0
  341. package/dist/turns/message-blocks.js +25 -0
  342. package/dist/turns/message-blocks.js.map +1 -0
  343. package/dist/turns/model-context.d.ts +81 -0
  344. package/dist/turns/model-context.d.ts.map +1 -0
  345. package/dist/turns/model-context.js +46 -0
  346. package/dist/turns/model-context.js.map +1 -0
  347. package/dist/turns/model-info.d.ts +7 -0
  348. package/dist/turns/model-info.d.ts.map +1 -0
  349. package/dist/turns/model-info.js +10 -0
  350. package/dist/turns/model-info.js.map +1 -0
  351. package/dist/turns/model-retry.d.ts +3 -0
  352. package/dist/turns/model-retry.d.ts.map +1 -0
  353. package/dist/turns/model-retry.js +23 -0
  354. package/dist/turns/model-retry.js.map +1 -0
  355. package/dist/turns/register-interruptions.d.ts +3 -0
  356. package/dist/turns/register-interruptions.d.ts.map +1 -0
  357. package/dist/turns/register-interruptions.js +31 -0
  358. package/dist/turns/register-interruptions.js.map +1 -0
  359. package/dist/turns/register-turns.d.ts +3 -0
  360. package/dist/turns/register-turns.d.ts.map +1 -0
  361. package/dist/turns/register-turns.js +66 -0
  362. package/dist/turns/register-turns.js.map +1 -0
  363. package/dist/turns/resolve.d.ts +7 -0
  364. package/dist/turns/resolve.d.ts.map +1 -0
  365. package/dist/turns/resolve.js +29 -0
  366. package/dist/turns/resolve.js.map +1 -0
  367. package/dist/turns/run-calls.d.ts +34 -0
  368. package/dist/turns/run-calls.d.ts.map +1 -0
  369. package/dist/turns/run-calls.js +99 -0
  370. package/dist/turns/run-calls.js.map +1 -0
  371. package/dist/turns/run-command.d.ts +26 -0
  372. package/dist/turns/run-command.d.ts.map +1 -0
  373. package/dist/turns/run-command.js +118 -0
  374. package/dist/turns/run-command.js.map +1 -0
  375. package/dist/turns/settle-calls.d.ts +17 -0
  376. package/dist/turns/settle-calls.d.ts.map +1 -0
  377. package/dist/turns/settle-calls.js +98 -0
  378. package/dist/turns/settle-calls.js.map +1 -0
  379. package/dist/turns/start-turn.d.ts +87 -0
  380. package/dist/turns/start-turn.d.ts.map +1 -0
  381. package/dist/turns/start-turn.js +40 -0
  382. package/dist/turns/start-turn.js.map +1 -0
  383. package/dist/turns/step.d.ts +8 -0
  384. package/dist/turns/step.d.ts.map +1 -0
  385. package/dist/turns/step.js +168 -0
  386. package/dist/turns/step.js.map +1 -0
  387. package/dist/ui/register-ui.d.ts +3 -0
  388. package/dist/ui/register-ui.d.ts.map +1 -0
  389. package/dist/ui/register-ui.js +75 -0
  390. package/dist/ui/register-ui.js.map +1 -0
  391. package/dist/web/components/call.css +2 -0
  392. package/dist/web/components/call.js +386 -0
  393. package/dist/web/components/connectors.css +2 -0
  394. package/dist/web/components/connectors.js +2403 -0
  395. package/dist/web/components/conversation.css +2 -0
  396. package/dist/web/components/conversation.js +4319 -0
  397. package/dist/web/components/mcp-sign-in.css +2 -0
  398. package/dist/web/components/mcp-sign-in.js +265 -0
  399. package/dist/web/components/model.css +2 -0
  400. package/dist/web/components/model.js +545 -0
  401. package/dist/web/components/question.css +2 -0
  402. package/dist/web/components/question.js +321 -0
  403. package/dist/web/components/sessions.css +2 -0
  404. package/dist/web/components/sessions.js +264 -0
  405. package/docs/connectors.md +86 -0
  406. package/docs/sections.md +27 -0
  407. package/locales/ar.json +418 -0
  408. package/locales/en.json +418 -0
  409. package/package.json +70 -0
@@ -0,0 +1,70 @@
1
+ import { z } from '@kvman/sdk';
2
+ import { records } from "../store/collections.js";
3
+ import { endTurn } from "../turns/end-turn.js";
4
+ import { checkCommand, runResult } from "./programs.js";
5
+ import { programFound, runProgram } from "./run-program.js";
6
+ import { finishRun } from "./runs.js";
7
+ import { isProgram, listedWorker, listedWorkers, workerCheckName } from "./workers.js";
8
+ // The job that runs a program worker, and the check of its program (plan 08 §8.5, ADR 0021, 11, 35, and 37). The job
9
+ // is queued by a step or by an answer, never by a handler, so when the program exits it may hold the result and queue
10
+ // the next step, as a subagent's last step does for its parent.
11
+ /** The run's job may last for the longest time limit, with room to report it. */
12
+ const runOptions = { retries: 0, timeoutMs: 7_260_000 };
13
+ // A run whose job failed (ADR 0021, 35): the turn that waits on it ends as a failed step does, and a background run
14
+ // tells the chat. Nothing is queued from here, since a handler's jobs carry the `fromHandler` mark.
15
+ export async function runLost(ctx, jobId, code) {
16
+ const store = records(ctx.store);
17
+ const [run] = await store.runs.find({ jobId }, { limit: 1 });
18
+ if (run === undefined || run.status !== 'running')
19
+ return;
20
+ const interrupted = code === 'INTERRUPTED';
21
+ const status = interrupted ? 'interrupted' : 'failed';
22
+ const text = interrupted ? `${run.worker} was interrupted because kvman stopped.` : `${run.worker} failed: ${code}`;
23
+ if (run.toolCallId === null) {
24
+ await finishRun(ctx, run.id, { status, exitCode: null, text, isError: true }, false);
25
+ return;
26
+ }
27
+ await store.runs.update(run.id, { status, endedAt: new Date().toISOString(), output: text });
28
+ const session = await store.sessions.get(run.sessionId);
29
+ if (session === undefined || session.turnId === null)
30
+ return;
31
+ await endTurn(ctx, session.id, session.turnId, status, 'handler', { code: interrupted ? 'INTERRUPTED' : 'STEP_FAILED', params: { code } });
32
+ }
33
+ /** The checks of the workspace's program workers, as a session keeps them (ADR 0021, 37). */
34
+ export async function workerChecks(ctx) {
35
+ const programs = (await listedWorkers(ctx)).filter(isProgram);
36
+ return Promise.all(programs.map(async (worker) => ({ name: workerCheckName(worker.name), passed: await programFound(checkCommand(worker.kind), ctx.job.workspace.path, ctx.job.signal) })));
37
+ }
38
+ export function registerWorkerRun(ctx) {
39
+ ctx.registerCommand('kvcoder.delegate.worker.run', {
40
+ description: "Runs a program worker's program on its task, and gives the chat its answer.",
41
+ input: z.strictObject({ runId: z.string() }),
42
+ output: z.object({}),
43
+ ...runOptions,
44
+ handle: async ({ runId }) => {
45
+ const run = await records(ctx.store).runs.get(runId);
46
+ if (run === undefined || run.status !== 'running')
47
+ return {};
48
+ const end = await runProgram({ command: run.command, args: run.args }, ctx.job.workspace.path, run.timeoutMs, ctx.job.signal);
49
+ // A cancelled or interrupted job leaves the run to whoever stopped it, or to `kernel.job.failed`.
50
+ ctx.job.signal.throwIfAborted();
51
+ const result = runResult({ name: run.worker, kind: run.kind, timeoutMs: run.timeoutMs }, end);
52
+ await finishRun(ctx, runId, { status: result.isError ? 'failed' : 'succeeded', exitCode: end.timedOut ? null : end.exitCode, ...result }, true);
53
+ return {};
54
+ },
55
+ });
56
+ ctx.registerCommand('kvcoder.delegate.worker.check', {
57
+ description: "Checks that a worker's program is installed; a subagent is always ready.",
58
+ input: z.strictObject({ name: z.string() }),
59
+ output: z.object({ status: z.enum(['ready', 'notFound']) }),
60
+ public: true,
61
+ retries: 0,
62
+ handle: async ({ name }) => {
63
+ const worker = await listedWorker(ctx, name);
64
+ const found = !isProgram(worker) || (await programFound(checkCommand(worker.kind), ctx.job.workspace.path, ctx.job.signal));
65
+ const status = found ? 'ready' : 'notFound';
66
+ return { status };
67
+ },
68
+ });
69
+ }
70
+ //# sourceMappingURL=register-worker-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-worker-run.js","sourceRoot":"","sources":["../../src/delegate/register-worker-run.ts"],"names":[],"mappings":"AAAA,OAA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CommandLine, ProgramEnd } from './programs.ts';
4
+ /** How the program is started on each OS: Windows has no process group, and its tree is killed by `taskkill`. */
5
+ export declare function programSpawn(platform: Platform, cwd: string, env: NodeJS.ProcessEnv): SpawnOptions;
6
+ /** Whether a program is installed: started as a run starts it, it exits 0 within 5 s (ADR 0021, 37). */
7
+ export declare function programFound(line: CommandLine, cwd: string, signal: AbortSignal): Promise<boolean>;
8
+ export declare function runProgram(line: CommandLine, cwd: string, timeoutMs: number, signal: AbortSignal): Promise<ProgramEnd>;
9
+ //# sourceMappingURL=run-program.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-program.d.ts","sourceRoot":"","sources":["../../src/delegate/run-program.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAM7D,iHAAiH;AACjH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,YAAY,CAElG;AAmBD,wGAAwG;AACxG,wBAAsB,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAGxG;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA0BtH"}
@@ -0,0 +1,59 @@
1
+ import spawn from 'cross-spawn';
2
+ import { killTree } from "../calls/run-shell.js";
3
+ import { outputLimit } from "../result-text.js";
4
+ // One run of a program worker (plan 08 §8.5, ADR 0021, 11 and 26): in the workspace folder, with kvman's environment
5
+ // and an empty standard input, in its own process group on Linux and macOS so its whole tree can be killed, which
6
+ // happens at its time limit and on cancel. It is a process of the run's own job (plan 02 §2.6).
7
+ /** How the program is started on each OS: Windows has no process group, and its tree is killed by `taskkill`. */
8
+ export function programSpawn(platform, cwd, env) {
9
+ return { cwd, env, stdio: ['ignore', 'pipe', 'pipe'], detached: platform !== 'win32', windowsHide: true };
10
+ }
11
+ /** The most of each stream that is kept: enough for an answer, which is then cut for the model. */
12
+ const keptBytes = 4 * outputLimit;
13
+ // Keeps the end of a stream: an answer comes last.
14
+ function tail() {
15
+ let kept = Buffer.alloc(0);
16
+ return {
17
+ add: (chunk) => {
18
+ kept = Buffer.concat([kept, chunk]);
19
+ if (kept.length > keptBytes)
20
+ kept = kept.subarray(kept.length - keptBytes);
21
+ },
22
+ text: () => kept.toString('utf8'),
23
+ };
24
+ }
25
+ const checkTimeoutMs = 5_000;
26
+ /** Whether a program is installed: started as a run starts it, it exits 0 within 5 s (ADR 0021, 37). */
27
+ export async function programFound(line, cwd, signal) {
28
+ const end = await runProgram(line, cwd, checkTimeoutMs, signal);
29
+ return end.startError === null && !end.timedOut && end.exitCode === 0;
30
+ }
31
+ export function runProgram(line, cwd, timeoutMs, signal) {
32
+ return new Promise((resolve) => {
33
+ const child = spawn(line.command, line.args, programSpawn(process.platform, cwd, process.env));
34
+ const stdout = tail();
35
+ const stderr = tail();
36
+ let timedOut = false;
37
+ child.stdout?.on('data', stdout.add);
38
+ child.stderr?.on('data', stderr.add);
39
+ const timer = setTimeout(() => {
40
+ timedOut = true;
41
+ killTree(child.pid);
42
+ }, timeoutMs);
43
+ const abort = () => killTree(child.pid);
44
+ signal.addEventListener('abort', abort, { once: true });
45
+ let settled = false;
46
+ // A program that can't start reports an error and may then close as well.
47
+ const settle = (end) => {
48
+ if (settled)
49
+ return;
50
+ settled = true;
51
+ clearTimeout(timer);
52
+ signal.removeEventListener('abort', abort);
53
+ resolve({ stdout: stdout.text(), stderr: stderr.text(), timedOut, ...end });
54
+ };
55
+ child.once('error', (error) => settle({ exitCode: null, startError: error.message }));
56
+ child.once('close', (code) => settle({ exitCode: code, startError: null }));
57
+ });
58
+ }
59
+ //# sourceMappingURL=run-program.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-program.js","sourceRoot":"","sources":["../../src/delegate/run-program.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,qHAAqH;AACrH,kHAAkH;AAClH,gGAAgG;AAEhG,iHAAiH;AACjH,MAAM,UAAU,YAAY,CAAC,QAAkB,EAAE,GAAW,EAAE,GAAsB;IAClF,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,KAAK,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAC5G,CAAC;AAED,mGAAmG;AACnG,MAAM,SAAS,GAAG,CAAC,GAAG,WAAW,CAAC;AAElC,mDAAmD;AACnD,SAAS,IAAI;IACX,IAAI,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,OAAO;QACL,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;YACb,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YACpC,IAAI,IAAI,CAAC,MAAM,GAAG,SAAS;gBAAE,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;QAC7E,CAAC;QACD,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;KAClC,CAAC;AACJ,CAAC;AAED,MAAM,cAAc,GAAG,KAAK,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,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,0EAA0E;QAC1E,MAAM,MAAM,GAAG,CAAC,GAAgD,EAAQ,EAAE;YACxE,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC3C,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;QAC9E,CAAC,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACtF,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Ctx, Stored } from '@kvman/sdk';
2
+ import type { HeldResult, RunDoc } from '../schemas/records.ts';
3
+ import type { ProgramWorker } from './workers.ts';
4
+ export type RunEnd = {
5
+ status: Exclude<RunDoc['status'], 'running'>;
6
+ exitCode: number | null;
7
+ text: string;
8
+ isError: boolean;
9
+ };
10
+ /** Records a run of `worker` on `task`; `toolCallId` is the call that waits on it, or `null` for a background run. */
11
+ export declare function createRun(ctx: Ctx, sessionId: string, worker: ProgramWorker, call: {
12
+ description: string;
13
+ task: string;
14
+ }, toolCallId: string | null): Promise<Stored<RunDoc>>;
15
+ /** Queues the job that runs a recorded run. */
16
+ export declare function launchRun(ctx: Ctx, runId: string): Promise<void>;
17
+ /** Ends a run and gives its result to the call that waits on it, or to the chat as a background message, which may start a turn. */
18
+ export declare function finishRun(ctx: Ctx, runId: string, end: RunEnd, startTurn: boolean): Promise<boolean>;
19
+ /** Stops a run for the agent or the person: its result is that it was stopped (ADR 0021, 34). `false` for one that had ended. */
20
+ export declare function stopRun(ctx: Ctx, run: Stored<RunDoc>): Promise<boolean>;
21
+ /** Stops a run whose turn or chat is going away: nothing is told to anyone. */
22
+ export declare function dropRun(ctx: Ctx, run: Stored<RunDoc>): Promise<void>;
23
+ /** Stops every run a session still has going, and forgets all of them (the chat is deleted). */
24
+ export declare function dropRuns(ctx: Ctx, sessionId: string): Promise<void>;
25
+ /** A result that says why a run never started. */
26
+ export declare const refusedRun: (toolCallId: string, text: string) => HeldResult;
27
+ //# sourceMappingURL=runs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/delegate/runs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAMhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAMlD,MAAM,MAAM,MAAM,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAE/H,sHAAsH;AACtH,wBAAsB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAGnL;AAED,+CAA+C;AAC/C,wBAAsB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGtE;AAiBD,oIAAoI;AACpI,wBAAsB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAM1G;AAOD,iIAAiI;AACjI,wBAAsB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAI7E;AAED,+EAA+E;AAC/E,wBAAsB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1E;AAED,gGAAgG;AAChG,wBAAsB,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzE;AAED,kDAAkD;AAClD,eAAO,MAAM,UAAU,GAAI,YAAY,MAAM,EAAE,MAAM,MAAM,KAAG,UAA8C,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { now } from "../sessions/session-lookup.js";
2
+ import { records, txRecords } from "../store/collections.js";
3
+ import { appendBackground, backgroundText } from "../turns/background.js";
4
+ import { heldText, resolvePending } from "../turns/resolve.js";
5
+ import { commandLine } from "./programs.js";
6
+ /** Records a run of `worker` on `task`; `toolCallId` is the call that waits on it, or `null` for a background run. */
7
+ export async function createRun(ctx, sessionId, worker, call, toolCallId) {
8
+ const line = commandLine(worker, call.task);
9
+ return records(ctx.store).runs.insert({ sessionId, toolCallId, worker: worker.name, kind: worker.kind, call: call.description, command: line.command, args: line.args, timeoutMs: worker.timeoutMs, jobId: null, status: 'running', startedAt: now(), endedAt: null, exitCode: null, output: null });
10
+ }
11
+ /** Queues the job that runs a recorded run. */
12
+ export async function launchRun(ctx, runId) {
13
+ const jobId = await ctx.execAsync('kvcoder.delegate.worker.run', { runId });
14
+ await records(ctx.store).runs.update(runId, { jobId });
15
+ }
16
+ // Records how a run ended, once: `undefined` when something else ended it first.
17
+ async function markEnded(ctx, runId, end) {
18
+ return ctx.store.transaction((tx) => {
19
+ const { runs } = txRecords(tx);
20
+ const run = runs.get(runId);
21
+ if (run === undefined || run.status !== 'running')
22
+ return undefined;
23
+ return runs.update(runId, { status: end.status, endedAt: now(), exitCode: end.exitCode, output: end.text });
24
+ });
25
+ }
26
+ function heldRun(run, toolCallId, end) {
27
+ const durationMs = Math.max(Date.now() - Date.parse(run.startedAt), 0);
28
+ return { toolCallId, text: end.text, isError: end.isError, run: null, details: { description: run.call, connector: 'delegate', command: 'run', output: end.text, durationMs } };
29
+ }
30
+ /** Ends a run and gives its result to the call that waits on it, or to the chat as a background message, which may start a turn. */
31
+ export async function finishRun(ctx, runId, end, startTurn) {
32
+ const run = await markEnded(ctx, runId, end);
33
+ if (run === undefined)
34
+ return false;
35
+ if (run.toolCallId !== null)
36
+ await resolvePending(ctx, run.sessionId, run.toolCallId, heldRun(run, run.toolCallId, end), false);
37
+ else
38
+ await appendBackground(ctx, run.sessionId, { kind: 'job', jobId: run.id }, backgroundText(run.call, run.id, end.text), startTurn);
39
+ return true;
40
+ }
41
+ async function cancelJobOf(ctx, run) {
42
+ const jobId = run.jobId ?? (await records(ctx.store).runs.get(run.id))?.jobId ?? null;
43
+ if (jobId !== null)
44
+ await ctx.cancel(jobId);
45
+ }
46
+ /** Stops a run for the agent or the person: its result is that it was stopped (ADR 0021, 34). `false` for one that had ended. */
47
+ export async function stopRun(ctx, run) {
48
+ const stopped = await finishRun(ctx, run.id, { status: 'cancelled', exitCode: null, text: `${run.worker} was stopped`, isError: true }, false);
49
+ if (stopped)
50
+ await cancelJobOf(ctx, run);
51
+ return stopped;
52
+ }
53
+ /** Stops a run whose turn or chat is going away: nothing is told to anyone. */
54
+ export async function dropRun(ctx, run) {
55
+ if ((await markEnded(ctx, run.id, { status: 'cancelled', exitCode: null, text: `${run.worker} was stopped`, isError: true })) !== undefined)
56
+ await cancelJobOf(ctx, run);
57
+ }
58
+ /** Stops every run a session still has going, and forgets all of them (the chat is deleted). */
59
+ export async function dropRuns(ctx, sessionId) {
60
+ const store = records(ctx.store);
61
+ for (const run of await store.runs.find({ sessionId }, { limit: 1000 })) {
62
+ await dropRun(ctx, run);
63
+ await store.runs.delete(run.id);
64
+ }
65
+ }
66
+ /** A result that says why a run never started. */
67
+ export const refusedRun = (toolCallId, text) => heldText(toolCallId, text, true);
68
+ //# sourceMappingURL=runs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runs.js","sourceRoot":"","sources":["../../src/delegate/runs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAS5C,sHAAsH;AACtH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAQ,EAAE,SAAiB,EAAE,MAAqB,EAAE,IAA2C,EAAE,UAAyB;IACxJ,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,UAAU,EA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M,CAAC,KAAK,UAAU,QAAQ,CAAC,GAAQ,EAAE,SAAiB;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACjC,KAAK,MAAM,GAAG,IAAI,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QACxE,MAAM,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACxB,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,kDAAkD;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAkB,EAAE,IAAY,EAAc,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC"}
@@ -0,0 +1,266 @@
1
+ import { z, type Ctx } from '@kvman/sdk';
2
+ /** A worker that runs a subagent: a child session with its own connectors, model, and thinking. */
3
+ export declare const subagentWorkerSchema: z.ZodObject<{
4
+ kind: z.ZodLiteral<"subagent">;
5
+ connectors: z.ZodNullable<z.ZodArray<z.ZodString>>;
6
+ model: z.ZodNullable<z.ZodString>;
7
+ thinking: z.ZodNullable<z.ZodEnum<{
8
+ off: "off";
9
+ minimal: "minimal";
10
+ low: "low";
11
+ medium: "medium";
12
+ high: "high";
13
+ }>>;
14
+ name: z.ZodString;
15
+ description: z.ZodString;
16
+ enabled: z.ZodBoolean;
17
+ instructions: z.ZodString;
18
+ }, z.core.$strict>;
19
+ /** The permission modes in which Claude Code acts without asking anyone. */
20
+ export declare const unaskedModes: readonly string[];
21
+ export declare const opencodeWorkerSchema: z.ZodObject<{
22
+ kind: z.ZodLiteral<"opencode">;
23
+ model: z.ZodNullable<z.ZodString>;
24
+ agent: z.ZodNullable<z.ZodString>;
25
+ autoApprove: z.ZodBoolean;
26
+ approval: z.ZodEnum<{
27
+ ask: "ask";
28
+ auto: "auto";
29
+ }>;
30
+ timeoutMs: z.ZodNumber;
31
+ name: z.ZodString;
32
+ description: z.ZodString;
33
+ enabled: z.ZodBoolean;
34
+ instructions: z.ZodString;
35
+ }, z.core.$strict>;
36
+ export declare const piWorkerSchema: z.ZodObject<{
37
+ kind: z.ZodLiteral<"pi">;
38
+ model: z.ZodNullable<z.ZodString>;
39
+ thinking: z.ZodNullable<z.ZodEnum<{
40
+ off: "off";
41
+ minimal: "minimal";
42
+ low: "low";
43
+ medium: "medium";
44
+ high: "high";
45
+ xhigh: "xhigh";
46
+ max: "max";
47
+ }>>;
48
+ tools: z.ZodNullable<z.ZodArray<z.ZodString>>;
49
+ approval: z.ZodEnum<{
50
+ ask: "ask";
51
+ auto: "auto";
52
+ }>;
53
+ timeoutMs: z.ZodNumber;
54
+ name: z.ZodString;
55
+ description: z.ZodString;
56
+ enabled: z.ZodBoolean;
57
+ instructions: z.ZodString;
58
+ }, z.core.$strict>;
59
+ export declare const claudeWorkerSchema: z.ZodObject<{
60
+ kind: z.ZodLiteral<"claude">;
61
+ model: z.ZodNullable<z.ZodString>;
62
+ effort: z.ZodNullable<z.ZodEnum<{
63
+ low: "low";
64
+ medium: "medium";
65
+ high: "high";
66
+ xhigh: "xhigh";
67
+ max: "max";
68
+ }>>;
69
+ permissionMode: z.ZodEnum<{
70
+ auto: "auto";
71
+ bypassPermissions: "bypassPermissions";
72
+ dontAsk: "dontAsk";
73
+ acceptEdits: "acceptEdits";
74
+ plan: "plan";
75
+ }>;
76
+ approval: z.ZodEnum<{
77
+ ask: "ask";
78
+ auto: "auto";
79
+ }>;
80
+ timeoutMs: z.ZodNumber;
81
+ name: z.ZodString;
82
+ description: z.ZodString;
83
+ enabled: z.ZodBoolean;
84
+ instructions: z.ZodString;
85
+ }, z.core.$strict>;
86
+ /** One worker: a subagent, or a program of one of the kinds kvcoder knows (ADR 0021, 3). */
87
+ export declare const workerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
88
+ kind: z.ZodLiteral<"subagent">;
89
+ connectors: z.ZodNullable<z.ZodArray<z.ZodString>>;
90
+ model: z.ZodNullable<z.ZodString>;
91
+ thinking: z.ZodNullable<z.ZodEnum<{
92
+ off: "off";
93
+ minimal: "minimal";
94
+ low: "low";
95
+ medium: "medium";
96
+ high: "high";
97
+ }>>;
98
+ name: z.ZodString;
99
+ description: z.ZodString;
100
+ enabled: z.ZodBoolean;
101
+ instructions: z.ZodString;
102
+ }, z.core.$strict>, z.ZodObject<{
103
+ kind: z.ZodLiteral<"opencode">;
104
+ model: z.ZodNullable<z.ZodString>;
105
+ agent: z.ZodNullable<z.ZodString>;
106
+ autoApprove: z.ZodBoolean;
107
+ approval: z.ZodEnum<{
108
+ ask: "ask";
109
+ auto: "auto";
110
+ }>;
111
+ timeoutMs: z.ZodNumber;
112
+ name: z.ZodString;
113
+ description: z.ZodString;
114
+ enabled: z.ZodBoolean;
115
+ instructions: z.ZodString;
116
+ }, z.core.$strict>, z.ZodObject<{
117
+ kind: z.ZodLiteral<"pi">;
118
+ model: z.ZodNullable<z.ZodString>;
119
+ thinking: z.ZodNullable<z.ZodEnum<{
120
+ off: "off";
121
+ minimal: "minimal";
122
+ low: "low";
123
+ medium: "medium";
124
+ high: "high";
125
+ xhigh: "xhigh";
126
+ max: "max";
127
+ }>>;
128
+ tools: z.ZodNullable<z.ZodArray<z.ZodString>>;
129
+ approval: z.ZodEnum<{
130
+ ask: "ask";
131
+ auto: "auto";
132
+ }>;
133
+ timeoutMs: z.ZodNumber;
134
+ name: z.ZodString;
135
+ description: z.ZodString;
136
+ enabled: z.ZodBoolean;
137
+ instructions: z.ZodString;
138
+ }, z.core.$strict>, z.ZodObject<{
139
+ kind: z.ZodLiteral<"claude">;
140
+ model: z.ZodNullable<z.ZodString>;
141
+ effort: z.ZodNullable<z.ZodEnum<{
142
+ low: "low";
143
+ medium: "medium";
144
+ high: "high";
145
+ xhigh: "xhigh";
146
+ max: "max";
147
+ }>>;
148
+ permissionMode: z.ZodEnum<{
149
+ auto: "auto";
150
+ bypassPermissions: "bypassPermissions";
151
+ dontAsk: "dontAsk";
152
+ acceptEdits: "acceptEdits";
153
+ plan: "plan";
154
+ }>;
155
+ approval: z.ZodEnum<{
156
+ ask: "ask";
157
+ auto: "auto";
158
+ }>;
159
+ timeoutMs: z.ZodNumber;
160
+ name: z.ZodString;
161
+ description: z.ZodString;
162
+ enabled: z.ZodBoolean;
163
+ instructions: z.ZodString;
164
+ }, z.core.$strict>], "kind">;
165
+ /** The `kvcoder.delegate.workers` setting: each worker has its own name. */
166
+ export declare const workersSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
167
+ kind: z.ZodLiteral<"subagent">;
168
+ connectors: z.ZodNullable<z.ZodArray<z.ZodString>>;
169
+ model: z.ZodNullable<z.ZodString>;
170
+ thinking: z.ZodNullable<z.ZodEnum<{
171
+ off: "off";
172
+ minimal: "minimal";
173
+ low: "low";
174
+ medium: "medium";
175
+ high: "high";
176
+ }>>;
177
+ name: z.ZodString;
178
+ description: z.ZodString;
179
+ enabled: z.ZodBoolean;
180
+ instructions: z.ZodString;
181
+ }, z.core.$strict>, z.ZodObject<{
182
+ kind: z.ZodLiteral<"opencode">;
183
+ model: z.ZodNullable<z.ZodString>;
184
+ agent: z.ZodNullable<z.ZodString>;
185
+ autoApprove: z.ZodBoolean;
186
+ approval: z.ZodEnum<{
187
+ ask: "ask";
188
+ auto: "auto";
189
+ }>;
190
+ timeoutMs: z.ZodNumber;
191
+ name: z.ZodString;
192
+ description: z.ZodString;
193
+ enabled: z.ZodBoolean;
194
+ instructions: z.ZodString;
195
+ }, z.core.$strict>, z.ZodObject<{
196
+ kind: z.ZodLiteral<"pi">;
197
+ model: z.ZodNullable<z.ZodString>;
198
+ thinking: z.ZodNullable<z.ZodEnum<{
199
+ off: "off";
200
+ minimal: "minimal";
201
+ low: "low";
202
+ medium: "medium";
203
+ high: "high";
204
+ xhigh: "xhigh";
205
+ max: "max";
206
+ }>>;
207
+ tools: z.ZodNullable<z.ZodArray<z.ZodString>>;
208
+ approval: z.ZodEnum<{
209
+ ask: "ask";
210
+ auto: "auto";
211
+ }>;
212
+ timeoutMs: z.ZodNumber;
213
+ name: z.ZodString;
214
+ description: z.ZodString;
215
+ enabled: z.ZodBoolean;
216
+ instructions: z.ZodString;
217
+ }, z.core.$strict>, z.ZodObject<{
218
+ kind: z.ZodLiteral<"claude">;
219
+ model: z.ZodNullable<z.ZodString>;
220
+ effort: z.ZodNullable<z.ZodEnum<{
221
+ low: "low";
222
+ medium: "medium";
223
+ high: "high";
224
+ xhigh: "xhigh";
225
+ max: "max";
226
+ }>>;
227
+ permissionMode: z.ZodEnum<{
228
+ auto: "auto";
229
+ bypassPermissions: "bypassPermissions";
230
+ dontAsk: "dontAsk";
231
+ acceptEdits: "acceptEdits";
232
+ plan: "plan";
233
+ }>;
234
+ approval: z.ZodEnum<{
235
+ ask: "ask";
236
+ auto: "auto";
237
+ }>;
238
+ timeoutMs: z.ZodNumber;
239
+ name: z.ZodString;
240
+ description: z.ZodString;
241
+ enabled: z.ZodBoolean;
242
+ instructions: z.ZodString;
243
+ }, z.core.$strict>], "kind">>;
244
+ export type Worker = z.output<typeof workerSchema>;
245
+ export type SubagentWorker = z.output<typeof subagentWorkerSchema>;
246
+ export type ProgramWorker = Exclude<Worker, SubagentWorker>;
247
+ /** Whether a worker runs a program, not a subagent. */
248
+ export declare const isProgram: (worker: Worker) => worker is ProgramWorker;
249
+ /** The name a program worker's check has among a session's checks (ADR 0021, 37). */
250
+ export declare const workerCheckName: (name: string) => string;
251
+ /** The workers kvcoder ships with: they differ by their instructions only (ADR 0021, 5). */
252
+ export declare const shippedWorkers: SubagentWorker[];
253
+ /** The workers of the job's workspace, in the setting's order. */
254
+ export declare function listedWorkers(ctx: Ctx): Promise<Worker[]>;
255
+ type Checks = readonly {
256
+ name: string;
257
+ passed: boolean;
258
+ }[] | null;
259
+ /** The workers a session can use: turned on, and for a program, one whose check passed (ADR 0021, 17). */
260
+ export declare function availableWorkers(ctx: Ctx, checks: Checks): Promise<Worker[]>;
261
+ /** One available worker by name, or `kvcoder/WORKER_NOT_FOUND` naming the ones there are. */
262
+ export declare function availableWorker(ctx: Ctx, checks: Checks, name: string): Promise<Worker>;
263
+ /** One worker of the list by name, turned on or not. */
264
+ export declare function listedWorker(ctx: Ctx, name: string): Promise<Worker>;
265
+ export {};
266
+ //# sourceMappingURL=workers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../src/delegate/workers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,CAAC,EAAE,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAkBvD,mGAAmG;AACnG,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;kBAAmL,CAAC;AAWrN,4EAA4E;AAC5E,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAA6C,CAAC;AAExF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;kBAAmM,CAAC;AACrO,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;kBAA6M,CAAC;AACzO,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;kBAM8E,CAAC;AAE9G,4FAA4F;AAC5F,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAAiH,CAAC;AAE3I,4EAA4E;AAC5E,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAAsJ,CAAC;AAEjL,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACnE,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAE5D,uDAAuD;AACvD,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,KAAG,MAAM,IAAI,aAA2C,CAAC;AAEjG,qFAAqF;AACrF,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAA0B,CAAC;AAI1E,4FAA4F;AAC5F,eAAO,MAAM,cAAc,EAAE,cAAc,EAsB1C,CAAC;AAEF,kEAAkE;AAClE,wBAAsB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAE/D;AAED,KAAK,MAAM,GAAG,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,EAAE,GAAG,IAAI,CAAC;AAElE,0GAA0G;AAC1G,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAGlF;AAMD,6FAA6F;AAC7F,wBAAsB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK7F;AAED,wDAAwD;AACxD,wBAAsB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK1E"}
@@ -0,0 +1,80 @@
1
+ import { ProblemError, z } from '@kvman/sdk';
2
+ import { thinkingSchema } from "../schemas/records.js";
3
+ import { wordSchema } from "../schemas/registry.js";
4
+ // The workers the `delegate` connector hands tasks to (plan 08 §8.5, ADR 0021, 4, 5, 7, and 20): the setting
5
+ // `kvcoder.delegate.workers`. A worker runs a subagent with its own instructions, connectors, model, and thinking, or
6
+ // a program on this computer, and is available while it is turned on.
7
+ /** The most a worker's instructions hold, a section's cap. */
8
+ const instructionsLimit = 16 * 1024;
9
+ const common = {
10
+ name: wordSchema,
11
+ description: z.string().min(1),
12
+ enabled: z.boolean(),
13
+ instructions: z.string().refine((text) => Buffer.byteLength(text, 'utf8') <= instructionsLimit, 'Instructions hold at most 16 KB.'),
14
+ };
15
+ /** A worker that runs a subagent: a child session with its own connectors, model, and thinking. */
16
+ export const subagentWorkerSchema = z.strictObject({ ...common, kind: z.literal('subagent'), connectors: z.array(z.string()).nullable(), model: z.string().min(1).nullable(), thinking: thinkingSchema.nullable() });
17
+ // A worker that runs a program on this computer (ADR 0021, 12, 13, and 31): whether a run asks first, how long it may
18
+ // take, and the flags that matter, each `null` to leave its flag out.
19
+ const program = { ...common, approval: z.enum(['ask', 'auto']), timeoutMs: z.number().int().min(60_000).max(7_200_000) };
20
+ const flag = z.string().min(1).nullable();
21
+ // A run nobody is asked about must not also approve its own actions (ADR 0021, 39): the task comes from the model,
22
+ // which may have been steered by what it read.
23
+ const unattended = 'A worker that starts at once must not approve its own actions: set it to ask before a run, or choose a stricter mode.';
24
+ /** The permission modes in which Claude Code acts without asking anyone. */
25
+ export const unaskedModes = ['bypassPermissions', 'auto', 'dontAsk'];
26
+ export const opencodeWorkerSchema = z.strictObject({ ...program, kind: z.literal('opencode'), model: flag, agent: flag, autoApprove: z.boolean() }).refine((worker) => worker.approval === 'ask' || !worker.autoApprove, unattended);
27
+ export const piWorkerSchema = z.strictObject({ ...program, kind: z.literal('pi'), model: flag, thinking: z.enum(['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']).nullable(), tools: z.array(z.string().min(1)).nullable() });
28
+ export const claudeWorkerSchema = z.strictObject({
29
+ ...program,
30
+ kind: z.literal('claude'),
31
+ model: flag,
32
+ effort: z.enum(['low', 'medium', 'high', 'xhigh', 'max']).nullable(),
33
+ permissionMode: z.enum(['acceptEdits', 'auto', 'bypassPermissions', 'dontAsk', 'plan']),
34
+ }).refine((worker) => worker.approval === 'ask' || !unaskedModes.includes(worker.permissionMode), unattended);
35
+ /** One worker: a subagent, or a program of one of the kinds kvcoder knows (ADR 0021, 3). */
36
+ export const workerSchema = z.discriminatedUnion('kind', [subagentWorkerSchema, opencodeWorkerSchema, piWorkerSchema, claudeWorkerSchema]);
37
+ /** The `kvcoder.delegate.workers` setting: each worker has its own name. */
38
+ export const workersSchema = z.array(workerSchema).refine((workers) => new Set(workers.map((worker) => worker.name)).size === workers.length, 'Each worker needs its own name.');
39
+ /** Whether a worker runs a program, not a subagent. */
40
+ export const isProgram = (worker) => worker.kind !== 'subagent';
41
+ /** The name a program worker's check has among a session's checks (ADR 0021, 37). */
42
+ export const workerCheckName = (name) => `worker:${name}`;
43
+ const shipped = (name, description, instructions) => ({ name, description, enabled: true, kind: 'subagent', instructions, connectors: null, model: null, thinking: null });
44
+ /** The workers kvcoder ships with: they differ by their instructions only (ADR 0021, 5). */
45
+ export const shippedWorkers = [
46
+ shipped('general', 'Any separate, self-contained task', ''),
47
+ shipped('ui-ux', 'Designs screens and flows', "You are a UI/UX designer. Design the screens and flows the task asks for, from the person's experience: what they see, what they do next, and every empty, loading, and error state. Follow the project's existing components, styles, and wording. Show the design in an artifact, as a page when layout matters. Don't change the project's files unless the task asks you to build the design."),
48
+ shipped('architect', 'Studies the code and proposes a design', "You are a software architect. Read the code the task touches before you propose anything. Return a design: the parts, their responsibilities, the shapes that pass between them, the trade-offs you weighed, and the risks. Prefer the simplest design that fits the project's conventions. Don't edit the project's files."),
49
+ shipped('tester', 'Writes and runs tests', "You are a test engineer. Write the tests the task asks for in the project's own test setup, each checking one behavior with real values, and run them. Report each failure with its cause. Don't change production code to make a test pass; report the defect."),
50
+ shipped('reviewer', 'Reviews changes with a fresh look', "You are a code reviewer. Read the changes the task names, and the code around them. Report defects by severity, each with its file and line, what is wrong, and what you expect instead: correctness first, then security, then the project's conventions. Say so when you find nothing. Don't edit the project's files."),
51
+ ];
52
+ /** The workers of the job's workspace, in the setting's order. */
53
+ export async function listedWorkers(ctx) {
54
+ return workersSchema.parse(await ctx.settings.get('kvcoder.delegate.workers'));
55
+ }
56
+ /** The workers a session can use: turned on, and for a program, one whose check passed (ADR 0021, 17). */
57
+ export async function availableWorkers(ctx, checks) {
58
+ const passed = new Set((checks ?? []).filter((check) => check.passed).map((check) => check.name));
59
+ return (await listedWorkers(ctx)).filter((worker) => worker.enabled && (!isProgram(worker) || passed.has(workerCheckName(worker.name))));
60
+ }
61
+ function notFound(name, names) {
62
+ return new ProblemError({ code: 'kvcoder/WORKER_NOT_FOUND', message: `There is no worker ${name}. ${names.length === 0 ? 'No worker is available.' : `The workers are: ${names.join(', ')}.`}`, params: { worker: name } });
63
+ }
64
+ /** One available worker by name, or `kvcoder/WORKER_NOT_FOUND` naming the ones there are. */
65
+ export async function availableWorker(ctx, checks, name) {
66
+ const workers = await availableWorkers(ctx, checks);
67
+ const found = workers.find((worker) => worker.name === name);
68
+ if (found === undefined)
69
+ throw notFound(name, workers.map((worker) => worker.name));
70
+ return found;
71
+ }
72
+ /** One worker of the list by name, turned on or not. */
73
+ export async function listedWorker(ctx, name) {
74
+ const workers = await listedWorkers(ctx);
75
+ const found = workers.find((worker) => worker.name === name);
76
+ if (found === undefined)
77
+ throw notFound(name, workers.map((worker) => worker.name));
78
+ return found;
79
+ }
80
+ //# sourceMappingURL=workers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workers.js","sourceRoot":"","sources":["../../src/delegate/workers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,CAAC,EAAY,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,6GAA6G;AAC7G,sHAAsH;AACtH,sEAAsE;AAEtE,8DAA8D;AAC9D,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEpC,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,CAA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