@gadicc/loom 0.0.0-oidc-bootstrap.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 (342) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +6 -0
  3. package/README.md +448 -0
  4. package/THIRD_PARTY_NOTICES.md +25 -0
  5. package/db/drizzle-config.d.ts +20 -0
  6. package/db/drizzle-config.js +34 -0
  7. package/db/fixtures.d.ts +31 -0
  8. package/db/fixtures.js +52 -0
  9. package/db/neon.d.ts +3 -0
  10. package/db/neon.js +20 -0
  11. package/db/neonFull.d.ts +12 -0
  12. package/db/neonFull.js +33 -0
  13. package/db/package.json +3 -0
  14. package/db/testing.d.ts +26 -0
  15. package/db/testing.js +76 -0
  16. package/db/testing.test.ts +28 -0
  17. package/db/valibot.d.ts +23 -0
  18. package/db/valibot.js +8 -0
  19. package/esm/_dnt.polyfills.d.ts +149 -0
  20. package/esm/_dnt.polyfills.d.ts.map +1 -0
  21. package/esm/_dnt.polyfills.js +163 -0
  22. package/esm/_dnt.shims.d.ts +2 -0
  23. package/esm/_dnt.shims.d.ts.map +1 -0
  24. package/esm/_dnt.shims.js +57 -0
  25. package/esm/bin/loom.d.ts +2 -0
  26. package/esm/bin/loom.d.ts.map +1 -0
  27. package/esm/bin/loom.js +11 -0
  28. package/esm/mod.d.ts +9 -0
  29. package/esm/mod.d.ts.map +1 -0
  30. package/esm/mod.js +8 -0
  31. package/esm/package.json +3 -0
  32. package/esm/src/apiKeys/authorize.d.ts +4 -0
  33. package/esm/src/apiKeys/authorize.d.ts.map +1 -0
  34. package/esm/src/apiKeys/authorize.js +184 -0
  35. package/esm/src/apiKeys/country.d.ts +3 -0
  36. package/esm/src/apiKeys/country.d.ts.map +1 -0
  37. package/esm/src/apiKeys/country.js +7 -0
  38. package/esm/src/apiKeys/credentials.d.ts +4 -0
  39. package/esm/src/apiKeys/credentials.d.ts.map +1 -0
  40. package/esm/src/apiKeys/credentials.js +55 -0
  41. package/esm/src/apiKeys/fingerprint.d.ts +3 -0
  42. package/esm/src/apiKeys/fingerprint.d.ts.map +1 -0
  43. package/esm/src/apiKeys/fingerprint.js +5 -0
  44. package/esm/src/apiKeys/mod.d.ts +9 -0
  45. package/esm/src/apiKeys/mod.d.ts.map +1 -0
  46. package/esm/src/apiKeys/mod.js +8 -0
  47. package/esm/src/apiKeys/policy.d.ts +59 -0
  48. package/esm/src/apiKeys/policy.d.ts.map +1 -0
  49. package/esm/src/apiKeys/policy.js +88 -0
  50. package/esm/src/apiKeys/retention.d.ts +55 -0
  51. package/esm/src/apiKeys/retention.d.ts.map +1 -0
  52. package/esm/src/apiKeys/retention.js +65 -0
  53. package/esm/src/apiKeys/types.d.ts +175 -0
  54. package/esm/src/apiKeys/types.d.ts.map +1 -0
  55. package/esm/src/apiKeys/types.js +1 -0
  56. package/esm/src/cli/externalSkills.d.ts +39 -0
  57. package/esm/src/cli/externalSkills.d.ts.map +1 -0
  58. package/esm/src/cli/externalSkills.js +177 -0
  59. package/esm/src/cli/mod.d.ts +337 -0
  60. package/esm/src/cli/mod.d.ts.map +1 -0
  61. package/esm/src/cli/mod.js +9268 -0
  62. package/esm/src/cli/projectSkills.d.ts +102 -0
  63. package/esm/src/cli/projectSkills.d.ts.map +1 -0
  64. package/esm/src/cli/projectSkills.js +592 -0
  65. package/esm/src/files/client.d.ts +29 -0
  66. package/esm/src/files/client.d.ts.map +1 -0
  67. package/esm/src/files/client.js +41 -0
  68. package/esm/src/files/errors.d.ts +37 -0
  69. package/esm/src/files/errors.d.ts.map +1 -0
  70. package/esm/src/files/errors.js +66 -0
  71. package/esm/src/files/hash.d.ts +15 -0
  72. package/esm/src/files/hash.d.ts.map +1 -0
  73. package/esm/src/files/hash.js +82 -0
  74. package/esm/src/files/memory.d.ts +29 -0
  75. package/esm/src/files/memory.d.ts.map +1 -0
  76. package/esm/src/files/memory.js +109 -0
  77. package/esm/src/files/metadata.d.ts +10 -0
  78. package/esm/src/files/metadata.d.ts.map +1 -0
  79. package/esm/src/files/metadata.js +186 -0
  80. package/esm/src/files/mod.d.ts +10 -0
  81. package/esm/src/files/mod.d.ts.map +1 -0
  82. package/esm/src/files/mod.js +9 -0
  83. package/esm/src/files/s3.d.ts +29 -0
  84. package/esm/src/files/s3.d.ts.map +1 -0
  85. package/esm/src/files/s3.js +107 -0
  86. package/esm/src/files/service.d.ts +27 -0
  87. package/esm/src/files/service.d.ts.map +1 -0
  88. package/esm/src/files/service.js +136 -0
  89. package/esm/src/files/types.d.ts +134 -0
  90. package/esm/src/files/types.d.ts.map +1 -0
  91. package/esm/src/files/types.js +1 -0
  92. package/esm/src/jobs/catalog.d.ts +32 -0
  93. package/esm/src/jobs/catalog.d.ts.map +1 -0
  94. package/esm/src/jobs/catalog.js +208 -0
  95. package/esm/src/jobs/controller.d.ts +28 -0
  96. package/esm/src/jobs/controller.d.ts.map +1 -0
  97. package/esm/src/jobs/controller.js +95 -0
  98. package/esm/src/jobs/direct.d.ts +36 -0
  99. package/esm/src/jobs/direct.d.ts.map +1 -0
  100. package/esm/src/jobs/direct.js +122 -0
  101. package/esm/src/jobs/events.d.ts +15 -0
  102. package/esm/src/jobs/events.d.ts.map +1 -0
  103. package/esm/src/jobs/events.js +30 -0
  104. package/esm/src/jobs/format.d.ts +16 -0
  105. package/esm/src/jobs/format.d.ts.map +1 -0
  106. package/esm/src/jobs/format.js +183 -0
  107. package/esm/src/jobs/http.d.ts +22 -0
  108. package/esm/src/jobs/http.d.ts.map +1 -0
  109. package/esm/src/jobs/http.js +44 -0
  110. package/esm/src/jobs/log.d.ts +2 -0
  111. package/esm/src/jobs/log.d.ts.map +1 -0
  112. package/esm/src/jobs/log.js +10 -0
  113. package/esm/src/jobs/mod.d.ts +10 -0
  114. package/esm/src/jobs/mod.d.ts.map +1 -0
  115. package/esm/src/jobs/mod.js +9 -0
  116. package/esm/src/jobs/run.d.ts +20 -0
  117. package/esm/src/jobs/run.d.ts.map +1 -0
  118. package/esm/src/jobs/run.js +57 -0
  119. package/esm/src/jobs/types.d.ts +31 -0
  120. package/esm/src/jobs/types.d.ts.map +1 -0
  121. package/esm/src/jobs/types.js +1 -0
  122. package/esm/src/mui/apiKeys.d.ts +65 -0
  123. package/esm/src/mui/apiKeys.d.ts.map +1 -0
  124. package/esm/src/mui/apiKeys.js +301 -0
  125. package/esm/src/mui/apiKeysView.d.ts +48 -0
  126. package/esm/src/mui/apiKeysView.d.ts.map +1 -0
  127. package/esm/src/mui/apiKeysView.js +34 -0
  128. package/esm/src/mui/confirm.d.ts +12 -0
  129. package/esm/src/mui/confirm.d.ts.map +1 -0
  130. package/esm/src/mui/confirm.js +78 -0
  131. package/esm/src/mui/mod.d.ts +4 -0
  132. package/esm/src/mui/mod.d.ts.map +1 -0
  133. package/esm/src/mui/mod.js +2 -0
  134. package/esm/src/next/apiKeys/mod.d.ts +64 -0
  135. package/esm/src/next/apiKeys/mod.d.ts.map +1 -0
  136. package/esm/src/next/apiKeys/mod.js +217 -0
  137. package/esm/src/next/auth/config.d.ts +34 -0
  138. package/esm/src/next/auth/config.d.ts.map +1 -0
  139. package/esm/src/next/auth/config.js +103 -0
  140. package/esm/src/next/auth/mod.d.ts +3 -0
  141. package/esm/src/next/auth/mod.d.ts.map +1 -0
  142. package/esm/src/next/auth/mod.js +2 -0
  143. package/esm/src/next/auth/server.d.ts +28 -0
  144. package/esm/src/next/auth/server.d.ts.map +1 -0
  145. package/esm/src/next/auth/server.js +24 -0
  146. package/esm/src/next/files/mod.d.ts +3 -0
  147. package/esm/src/next/files/mod.d.ts.map +1 -0
  148. package/esm/src/next/files/mod.js +2 -0
  149. package/esm/src/next/files/route.d.ts +99 -0
  150. package/esm/src/next/files/route.d.ts.map +1 -0
  151. package/esm/src/next/files/route.js +349 -0
  152. package/esm/src/next/jobs/list.d.ts +25 -0
  153. package/esm/src/next/jobs/list.d.ts.map +1 -0
  154. package/esm/src/next/jobs/list.js +39 -0
  155. package/esm/src/next/jobs/mod.d.ts +6 -0
  156. package/esm/src/next/jobs/mod.d.ts.map +1 -0
  157. package/esm/src/next/jobs/mod.js +5 -0
  158. package/esm/src/next/jobs/paths.d.ts +14 -0
  159. package/esm/src/next/jobs/paths.d.ts.map +1 -0
  160. package/esm/src/next/jobs/paths.js +40 -0
  161. package/esm/src/next/jobs/route.d.ts +48 -0
  162. package/esm/src/next/jobs/route.d.ts.map +1 -0
  163. package/esm/src/next/jobs/route.js +101 -0
  164. package/esm/src/next/jobs/run.d.ts +51 -0
  165. package/esm/src/next/jobs/run.d.ts.map +1 -0
  166. package/esm/src/next/jobs/run.js +563 -0
  167. package/esm/src/next/jobs/stream.d.ts +3 -0
  168. package/esm/src/next/jobs/stream.d.ts.map +1 -0
  169. package/esm/src/next/jobs/stream.js +25 -0
  170. package/esm/src/next/pwa/mod.d.ts +104 -0
  171. package/esm/src/next/pwa/mod.d.ts.map +1 -0
  172. package/esm/src/next/pwa/mod.js +169 -0
  173. package/esm/src/next/pwa/worker.d.ts +27 -0
  174. package/esm/src/next/pwa/worker.d.ts.map +1 -0
  175. package/esm/src/next/pwa/worker.js +27 -0
  176. package/package.json +293 -0
  177. package/script/_dnt.polyfills.d.ts +149 -0
  178. package/script/_dnt.polyfills.d.ts.map +1 -0
  179. package/script/_dnt.polyfills.js +166 -0
  180. package/script/_dnt.shims.d.ts +2 -0
  181. package/script/_dnt.shims.d.ts.map +1 -0
  182. package/script/_dnt.shims.js +60 -0
  183. package/script/bin/loom.d.ts +2 -0
  184. package/script/bin/loom.d.ts.map +1 -0
  185. package/script/bin/loom.js +17 -0
  186. package/script/mod.d.ts +9 -0
  187. package/script/mod.d.ts.map +1 -0
  188. package/script/mod.js +24 -0
  189. package/script/package.json +3 -0
  190. package/script/src/apiKeys/authorize.d.ts +4 -0
  191. package/script/src/apiKeys/authorize.d.ts.map +1 -0
  192. package/script/src/apiKeys/authorize.js +187 -0
  193. package/script/src/apiKeys/country.d.ts +3 -0
  194. package/script/src/apiKeys/country.d.ts.map +1 -0
  195. package/script/src/apiKeys/country.js +10 -0
  196. package/script/src/apiKeys/credentials.d.ts +4 -0
  197. package/script/src/apiKeys/credentials.d.ts.map +1 -0
  198. package/script/src/apiKeys/credentials.js +58 -0
  199. package/script/src/apiKeys/fingerprint.d.ts +3 -0
  200. package/script/src/apiKeys/fingerprint.d.ts.map +1 -0
  201. package/script/src/apiKeys/fingerprint.js +8 -0
  202. package/script/src/apiKeys/mod.d.ts +9 -0
  203. package/script/src/apiKeys/mod.d.ts.map +1 -0
  204. package/script/src/apiKeys/mod.js +24 -0
  205. package/script/src/apiKeys/policy.d.ts +59 -0
  206. package/script/src/apiKeys/policy.d.ts.map +1 -0
  207. package/script/src/apiKeys/policy.js +92 -0
  208. package/script/src/apiKeys/retention.d.ts +55 -0
  209. package/script/src/apiKeys/retention.d.ts.map +1 -0
  210. package/script/src/apiKeys/retention.js +70 -0
  211. package/script/src/apiKeys/types.d.ts +175 -0
  212. package/script/src/apiKeys/types.d.ts.map +1 -0
  213. package/script/src/apiKeys/types.js +2 -0
  214. package/script/src/cli/externalSkills.d.ts +39 -0
  215. package/script/src/cli/externalSkills.d.ts.map +1 -0
  216. package/script/src/cli/externalSkills.js +181 -0
  217. package/script/src/cli/mod.d.ts +337 -0
  218. package/script/src/cli/mod.d.ts.map +1 -0
  219. package/script/src/cli/mod.js +9337 -0
  220. package/script/src/cli/projectSkills.d.ts +102 -0
  221. package/script/src/cli/projectSkills.d.ts.map +1 -0
  222. package/script/src/cli/projectSkills.js +606 -0
  223. package/script/src/files/client.d.ts +29 -0
  224. package/script/src/files/client.d.ts.map +1 -0
  225. package/script/src/files/client.js +45 -0
  226. package/script/src/files/errors.d.ts +37 -0
  227. package/script/src/files/errors.d.ts.map +1 -0
  228. package/script/src/files/errors.js +76 -0
  229. package/script/src/files/hash.d.ts +15 -0
  230. package/script/src/files/hash.d.ts.map +1 -0
  231. package/script/src/files/hash.js +89 -0
  232. package/script/src/files/memory.d.ts +29 -0
  233. package/script/src/files/memory.d.ts.map +1 -0
  234. package/script/src/files/memory.js +113 -0
  235. package/script/src/files/metadata.d.ts +10 -0
  236. package/script/src/files/metadata.d.ts.map +1 -0
  237. package/script/src/files/metadata.js +189 -0
  238. package/script/src/files/mod.d.ts +10 -0
  239. package/script/src/files/mod.d.ts.map +1 -0
  240. package/script/src/files/mod.js +25 -0
  241. package/script/src/files/s3.d.ts +29 -0
  242. package/script/src/files/s3.d.ts.map +1 -0
  243. package/script/src/files/s3.js +110 -0
  244. package/script/src/files/service.d.ts +27 -0
  245. package/script/src/files/service.d.ts.map +1 -0
  246. package/script/src/files/service.js +139 -0
  247. package/script/src/files/types.d.ts +134 -0
  248. package/script/src/files/types.d.ts.map +1 -0
  249. package/script/src/files/types.js +2 -0
  250. package/script/src/jobs/catalog.d.ts +32 -0
  251. package/script/src/jobs/catalog.d.ts.map +1 -0
  252. package/script/src/jobs/catalog.js +223 -0
  253. package/script/src/jobs/controller.d.ts +28 -0
  254. package/script/src/jobs/controller.d.ts.map +1 -0
  255. package/script/src/jobs/controller.js +100 -0
  256. package/script/src/jobs/direct.d.ts +36 -0
  257. package/script/src/jobs/direct.d.ts.map +1 -0
  258. package/script/src/jobs/direct.js +128 -0
  259. package/script/src/jobs/events.d.ts +15 -0
  260. package/script/src/jobs/events.d.ts.map +1 -0
  261. package/script/src/jobs/events.js +37 -0
  262. package/script/src/jobs/format.d.ts +16 -0
  263. package/script/src/jobs/format.d.ts.map +1 -0
  264. package/script/src/jobs/format.js +193 -0
  265. package/script/src/jobs/http.d.ts +22 -0
  266. package/script/src/jobs/http.d.ts.map +1 -0
  267. package/script/src/jobs/http.js +50 -0
  268. package/script/src/jobs/log.d.ts +2 -0
  269. package/script/src/jobs/log.d.ts.map +1 -0
  270. package/script/src/jobs/log.js +13 -0
  271. package/script/src/jobs/mod.d.ts +10 -0
  272. package/script/src/jobs/mod.d.ts.map +1 -0
  273. package/script/src/jobs/mod.js +25 -0
  274. package/script/src/jobs/run.d.ts +20 -0
  275. package/script/src/jobs/run.d.ts.map +1 -0
  276. package/script/src/jobs/run.js +61 -0
  277. package/script/src/jobs/types.d.ts +31 -0
  278. package/script/src/jobs/types.d.ts.map +1 -0
  279. package/script/src/jobs/types.js +2 -0
  280. package/script/src/mui/apiKeys.d.ts +65 -0
  281. package/script/src/mui/apiKeys.d.ts.map +1 -0
  282. package/script/src/mui/apiKeys.js +327 -0
  283. package/script/src/mui/apiKeysView.d.ts +48 -0
  284. package/script/src/mui/apiKeysView.d.ts.map +1 -0
  285. package/script/src/mui/apiKeysView.js +40 -0
  286. package/script/src/mui/confirm.d.ts +12 -0
  287. package/script/src/mui/confirm.d.ts.map +1 -0
  288. package/script/src/mui/confirm.js +85 -0
  289. package/script/src/mui/mod.d.ts +4 -0
  290. package/script/src/mui/mod.d.ts.map +1 -0
  291. package/script/src/mui/mod.js +19 -0
  292. package/script/src/next/apiKeys/mod.d.ts +64 -0
  293. package/script/src/next/apiKeys/mod.d.ts.map +1 -0
  294. package/script/src/next/apiKeys/mod.js +224 -0
  295. package/script/src/next/auth/config.d.ts +34 -0
  296. package/script/src/next/auth/config.d.ts.map +1 -0
  297. package/script/src/next/auth/config.js +142 -0
  298. package/script/src/next/auth/mod.d.ts +3 -0
  299. package/script/src/next/auth/mod.d.ts.map +1 -0
  300. package/script/src/next/auth/mod.js +18 -0
  301. package/script/src/next/auth/server.d.ts +28 -0
  302. package/script/src/next/auth/server.d.ts.map +1 -0
  303. package/script/src/next/auth/server.js +27 -0
  304. package/script/src/next/files/mod.d.ts +3 -0
  305. package/script/src/next/files/mod.d.ts.map +1 -0
  306. package/script/src/next/files/mod.js +18 -0
  307. package/script/src/next/files/route.d.ts +99 -0
  308. package/script/src/next/files/route.d.ts.map +1 -0
  309. package/script/src/next/files/route.js +353 -0
  310. package/script/src/next/jobs/list.d.ts +25 -0
  311. package/script/src/next/jobs/list.d.ts.map +1 -0
  312. package/script/src/next/jobs/list.js +48 -0
  313. package/script/src/next/jobs/mod.d.ts +6 -0
  314. package/script/src/next/jobs/mod.d.ts.map +1 -0
  315. package/script/src/next/jobs/mod.js +21 -0
  316. package/script/src/next/jobs/paths.d.ts +14 -0
  317. package/script/src/next/jobs/paths.d.ts.map +1 -0
  318. package/script/src/next/jobs/paths.js +47 -0
  319. package/script/src/next/jobs/route.d.ts +48 -0
  320. package/script/src/next/jobs/route.d.ts.map +1 -0
  321. package/script/src/next/jobs/route.js +105 -0
  322. package/script/src/next/jobs/run.d.ts +51 -0
  323. package/script/src/next/jobs/run.d.ts.map +1 -0
  324. package/script/src/next/jobs/run.js +570 -0
  325. package/script/src/next/jobs/stream.d.ts +3 -0
  326. package/script/src/next/jobs/stream.d.ts.map +1 -0
  327. package/script/src/next/jobs/stream.js +28 -0
  328. package/script/src/next/pwa/mod.d.ts +104 -0
  329. package/script/src/next/pwa/mod.d.ts.map +1 -0
  330. package/script/src/next/pwa/mod.js +192 -0
  331. package/script/src/next/pwa/worker.d.ts +27 -0
  332. package/script/src/next/pwa/worker.d.ts.map +1 -0
  333. package/script/src/next/pwa/worker.js +33 -0
  334. package/skills/loom/SKILL.md +200 -0
  335. package/skills/loom-api-keys/SKILL.md +123 -0
  336. package/skills/loom-auth/SKILL.md +70 -0
  337. package/skills/loom-db/SKILL.md +94 -0
  338. package/skills/loom-db/references/db-stack.md +39 -0
  339. package/skills/loom-files/SKILL.md +97 -0
  340. package/skills/loom-jobs/SKILL.md +148 -0
  341. package/skills/upgrade-deps/SKILL.md +165 -0
  342. package/skills/upgrade-deps/agents/openai.yaml +4 -0
@@ -0,0 +1,563 @@
1
+ "use client";
2
+ import React from "react";
3
+ import { collectJobMetas } from "../../jobs/catalog.js";
4
+ import { JobController } from "../../jobs/controller.js";
5
+ import { isJobLifecycleEvent, isJobLogEvent, } from "../../jobs/events.js";
6
+ import { formatJobLogTime } from "../../jobs/log.js";
7
+ import { createJobsAdminPaths, serializePageSearchParams, } from "./paths.js";
8
+ import { readNdJsonResponse } from "./stream.js";
9
+ const JOB_LOG_LEVEL_COLORS = [
10
+ "#b91c1c",
11
+ "#dc2626",
12
+ "#d97706",
13
+ "#2563eb",
14
+ "#111827",
15
+ "#0f766e",
16
+ "#6b7280",
17
+ ];
18
+ const JOB_LOG_TIME_COLUMN_WIDTH = "15ch";
19
+ const JOB_LOG_COLUMN_GAP = "0.75rem";
20
+ function getLogArgKey(arg) {
21
+ if (typeof arg === "string")
22
+ return `string:${arg}`;
23
+ if (typeof arg === "number")
24
+ return `number:${arg}`;
25
+ if (typeof arg === "boolean")
26
+ return `boolean:${arg}`;
27
+ if (arg === null)
28
+ return "null";
29
+ if (typeof arg === "undefined")
30
+ return "undefined";
31
+ try {
32
+ return `json:${JSON.stringify(arg)}`;
33
+ }
34
+ catch {
35
+ return `type:${typeof arg}`;
36
+ }
37
+ }
38
+ function safeJsonStringify(value, space) {
39
+ try {
40
+ return JSON.stringify(value, null, space);
41
+ }
42
+ catch {
43
+ return String(value);
44
+ }
45
+ }
46
+ function DefaultJobsRunButton(props) {
47
+ return (React.createElement("button", { disabled: props.disabled, onClick: props.onClick, type: "button" }, props.label));
48
+ }
49
+ function DefaultJobsRunTitle(props) {
50
+ return (React.createElement("h1", { style: {
51
+ alignItems: "center",
52
+ display: "flex",
53
+ fontSize: "1.5rem",
54
+ fontWeight: 600,
55
+ gap: "8px",
56
+ } },
57
+ React.createElement("span", null,
58
+ "Job: ",
59
+ props.id,
60
+ " (",
61
+ props.status,
62
+ ")"),
63
+ props.rerunButton));
64
+ }
65
+ function DefaultJobsRunPanel(props) {
66
+ return (React.createElement("div", { ref: props.panelRef, style: {
67
+ border: "1px solid #cbd5e1",
68
+ borderRadius: "0.75rem",
69
+ marginTop: "1rem",
70
+ maxHeight: "calc(100vh - 180px)",
71
+ overflow: "auto",
72
+ padding: "1rem",
73
+ } }, props.children));
74
+ }
75
+ function defaultRenderLogValue(value, key) {
76
+ if (typeof value === "object" && value) {
77
+ return (React.createElement("pre", { key: key, style: {
78
+ display: "inline-block",
79
+ margin: 0,
80
+ whiteSpace: "pre-wrap",
81
+ wordBreak: "break-word",
82
+ } }, safeJsonStringify(value, 2)));
83
+ }
84
+ return (React.createElement("span", { key: key, style: { verticalAlign: "top", whiteSpace: "pre" } }, String(value)));
85
+ }
86
+ function DefaultJobsRunPageLayout(props) {
87
+ return (React.createElement("main", { style: { margin: "2rem auto", maxWidth: "72rem", padding: "0 1rem" } },
88
+ props.title,
89
+ props.panel));
90
+ }
91
+ function JobsRunLogLine(props) {
92
+ const renderLogValue = props.renderLogValue ?? defaultRenderLogValue;
93
+ if (isJobLifecycleEvent(props.entry.event)) {
94
+ return (React.createElement("div", { style: {
95
+ color: JOB_LOG_LEVEL_COLORS[JobController._logLevelsInt.info],
96
+ columnGap: JOB_LOG_COLUMN_GAP,
97
+ display: "grid",
98
+ fontFamily: "monospace",
99
+ gridTemplateColumns: `${JOB_LOG_TIME_COLUMN_WIDTH} minmax(0, 1fr)`,
100
+ alignItems: "start",
101
+ } },
102
+ React.createElement("span", { style: {
103
+ whiteSpace: "nowrap",
104
+ } },
105
+ "[",
106
+ formatJobLogTime(props.entry.receivedAt),
107
+ "]"),
108
+ React.createElement("span", { style: { minWidth: 0 } },
109
+ "[JOB] ",
110
+ props.entry.event._job)));
111
+ }
112
+ if (!isJobLogEvent(props.entry.event)) {
113
+ return (React.createElement("div", { style: { fontFamily: "monospace" } }, safeJsonStringify(props.entry.event)));
114
+ }
115
+ const [timestamp, levelInt, ...args] = props.entry.event._log;
116
+ const argKeyCounts = new Map();
117
+ return (React.createElement("div", { style: {
118
+ color: JOB_LOG_LEVEL_COLORS[levelInt] ??
119
+ JOB_LOG_LEVEL_COLORS[JobController._logLevelsInt.log],
120
+ columnGap: JOB_LOG_COLUMN_GAP,
121
+ display: "grid",
122
+ fontFamily: "monospace",
123
+ gridTemplateColumns: `${JOB_LOG_TIME_COLUMN_WIDTH} minmax(0, 1fr)`,
124
+ alignItems: "start",
125
+ } },
126
+ React.createElement("span", { style: {
127
+ whiteSpace: "nowrap",
128
+ } },
129
+ "[",
130
+ formatJobLogTime(timestamp),
131
+ "]"),
132
+ React.createElement("span", { style: {
133
+ minWidth: 0,
134
+ whiteSpace: "pre-wrap",
135
+ wordBreak: "break-word",
136
+ } }, args.map((arg) => {
137
+ const keyBase = getLogArgKey(arg);
138
+ const keyCount = (argKeyCounts.get(keyBase) ?? 0) + 1;
139
+ argKeyCounts.set(keyBase, keyCount);
140
+ return (React.createElement(React.Fragment, { key: `${keyBase}:${keyCount}` },
141
+ renderLogValue(arg, `${keyBase}:${keyCount}`),
142
+ " "));
143
+ }))));
144
+ }
145
+ function toJobErrorEvent(message) {
146
+ return {
147
+ _log: [
148
+ Date.now(),
149
+ JobController._logLevelsInt.error,
150
+ message,
151
+ ],
152
+ };
153
+ }
154
+ export function JobsRunPanel(props) {
155
+ const [entries, setEntries] = React.useState([]);
156
+ const [status, setReactStatus] = React.useState(props.autoStart === true ? "starting" : "idle");
157
+ const statusRef = React.useRef(props.autoStart === true ? "starting" : "idle");
158
+ const nextEntryId = React.useRef(0);
159
+ const autoStartedKey = React.useRef(null);
160
+ const isRunning = React.useRef(false);
161
+ const panelRef = React.useRef(null);
162
+ const autoscroll = React.useRef(true);
163
+ const scrolling = React.useRef(false);
164
+ const scrollTimeout = React.useRef(null);
165
+ const lineHeight = React.useRef(12);
166
+ const activeMeta = React.useMemo(() => {
167
+ if (!props.metas)
168
+ return undefined;
169
+ const metas = collectJobMetas(props.metas);
170
+ return metas.find((m) => m.id === props.id);
171
+ }, [props.metas, props.id]);
172
+ const initialParams = React.useMemo(() => {
173
+ const p = new URLSearchParams(props.queryString || "");
174
+ return Object.fromEntries(p.entries());
175
+ }, [props.queryString]);
176
+ const [formValues, setFormValues] = React.useState({});
177
+ React.useEffect(() => {
178
+ const initial = {};
179
+ if (activeMeta?.params) {
180
+ for (const [key, def] of Object.entries(activeMeta.params)) {
181
+ const urlVal = initialParams[key];
182
+ if (urlVal !== undefined) {
183
+ initial[key] = urlVal;
184
+ }
185
+ else if (def.default !== undefined) {
186
+ initial[key] = String(def.default);
187
+ }
188
+ else if (def.type === "boolean") {
189
+ initial[key] = "false";
190
+ }
191
+ else {
192
+ initial[key] = "";
193
+ }
194
+ }
195
+ }
196
+ setFormValues(initial);
197
+ }, [initialParams, activeMeta]);
198
+ const setStatus = (value) => {
199
+ statusRef.current = value;
200
+ setReactStatus(value);
201
+ };
202
+ const appendEntry = (event) => {
203
+ setEntries((current) => [
204
+ ...current,
205
+ {
206
+ event,
207
+ id: nextEntryId.current++,
208
+ receivedAt: Date.now(),
209
+ },
210
+ ]);
211
+ };
212
+ React.useEffect(() => {
213
+ if (!panelRef.current) {
214
+ return;
215
+ }
216
+ lineHeight.current =
217
+ Number.parseFloat(getComputedStyle(panelRef.current).fontSize) || 12;
218
+ }, []);
219
+ React.useEffect(() => {
220
+ const element = panelRef.current;
221
+ if (!element) {
222
+ return;
223
+ }
224
+ const onScroll = () => {
225
+ scrolling.current = true;
226
+ autoscroll.current =
227
+ element.scrollHeight - element.clientHeight - element.scrollTop <
228
+ lineHeight.current * 2;
229
+ if (scrollTimeout.current !== null) {
230
+ globalThis.clearTimeout(scrollTimeout.current);
231
+ }
232
+ scrollTimeout.current = globalThis.setTimeout(() => {
233
+ scrolling.current = false;
234
+ }, 150);
235
+ };
236
+ element.addEventListener("scroll", onScroll, { passive: true });
237
+ return () => {
238
+ element.removeEventListener("scroll", onScroll);
239
+ if (scrollTimeout.current !== null) {
240
+ globalThis.clearTimeout(scrollTimeout.current);
241
+ }
242
+ };
243
+ }, []);
244
+ React.useEffect(() => {
245
+ if (panelRef.current && autoscroll.current && !scrolling.current) {
246
+ panelRef.current.scrollTo(0, panelRef.current.scrollHeight);
247
+ }
248
+ }, [entries]);
249
+ const runJob = React.useCallback(async () => {
250
+ if (isRunning.current) {
251
+ return;
252
+ }
253
+ isRunning.current = true;
254
+ const paths = createJobsAdminPaths(props.basePath);
255
+ const searchParams = new URLSearchParams();
256
+ if (activeMeta?.params) {
257
+ for (const [key, val] of Object.entries(formValues)) {
258
+ const def = activeMeta.params[key];
259
+ if (def?.type === "boolean") {
260
+ searchParams.set(key, val === "true" ? "true" : "false");
261
+ }
262
+ else if (val !== "") {
263
+ searchParams.set(key, val);
264
+ }
265
+ }
266
+ }
267
+ else {
268
+ const p = new URLSearchParams(props.queryString || "");
269
+ for (const [key, val] of p.entries()) {
270
+ searchParams.set(key, val);
271
+ }
272
+ }
273
+ const qString = searchParams.toString();
274
+ if (typeof globalThis.window !== "undefined") {
275
+ const newUrl = `${globalThis.location.pathname}${qString ? `?${qString}` : ""}`;
276
+ globalThis.history.pushState({ path: newUrl }, "", newUrl);
277
+ }
278
+ const requestPath = `${paths.job(props.id)}${qString ? `?${qString}` : ""}`;
279
+ setStatus("starting");
280
+ setEntries([]);
281
+ nextEntryId.current = 0;
282
+ try {
283
+ const response = await fetch(requestPath);
284
+ if (!response.ok) {
285
+ setStatus("error");
286
+ appendEntry(toJobErrorEvent((await response.text()) ||
287
+ `Request failed with status ${response.status}`));
288
+ return;
289
+ }
290
+ if (!response.body) {
291
+ setStatus("error");
292
+ appendEntry(toJobErrorEvent("No response body."));
293
+ return;
294
+ }
295
+ for await (const event of readNdJsonResponse(response.body)) {
296
+ appendEntry(event);
297
+ if (isJobLifecycleEvent(event)) {
298
+ if (event._job === "start") {
299
+ setStatus("running");
300
+ }
301
+ else if (event._job === "end") {
302
+ setStatus("done");
303
+ }
304
+ }
305
+ }
306
+ if (statusRef.current !== "done") {
307
+ setStatus("stopped");
308
+ }
309
+ }
310
+ catch (error) {
311
+ setStatus("error");
312
+ appendEntry(toJobErrorEvent(error instanceof Error
313
+ ? error.stack ?? error.message
314
+ : safeJsonStringify(error)));
315
+ }
316
+ finally {
317
+ isRunning.current = false;
318
+ }
319
+ }, [props.basePath, props.id, props.queryString, formValues, activeMeta]);
320
+ const runKey = React.useMemo(() => [props.basePath ?? "", props.id, props.queryString ?? ""].join("\0"), [props.basePath, props.id, props.queryString]);
321
+ React.useEffect(() => {
322
+ if (props.autoStart !== true) {
323
+ setStatus("idle");
324
+ setEntries([]);
325
+ nextEntryId.current = 0;
326
+ return;
327
+ }
328
+ if (autoStartedKey.current === runKey) {
329
+ return;
330
+ }
331
+ autoStartedKey.current = runKey;
332
+ void runJob();
333
+ }, [props.autoStart, runJob, runKey]);
334
+ const isRunDisabled = status === "starting" || status === "running";
335
+ const rerunButton = props.renderRerunButton?.({
336
+ disabled: isRunDisabled,
337
+ label: status === "idle" ? "Run" : "Rerun",
338
+ onClick: () => void runJob(),
339
+ status,
340
+ }) ?? (React.createElement(DefaultJobsRunButton, { disabled: isRunDisabled, label: status === "idle" ? "Run" : "Rerun", onClick: () => void runJob(), status: status }));
341
+ const title = props.renderTitle?.({
342
+ id: props.id,
343
+ rerunButton,
344
+ status,
345
+ }) ?? (React.createElement(DefaultJobsRunTitle, { id: props.id, rerunButton: rerunButton, status: status }));
346
+ const handleFormSubmit = (e) => {
347
+ e.preventDefault();
348
+ void runJob();
349
+ };
350
+ const parametersForm = React.useMemo(() => {
351
+ if (!activeMeta?.params || Object.keys(activeMeta.params).length === 0) {
352
+ return null;
353
+ }
354
+ return (React.createElement("form", { onSubmit: handleFormSubmit, style: {
355
+ background: "Canvas",
356
+ border: "1px solid color-mix(in oklab, CanvasText 15%, Canvas)",
357
+ borderRadius: "12px",
358
+ padding: "16px",
359
+ marginBottom: "20px",
360
+ boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05)",
361
+ } },
362
+ React.createElement("style", null, `
363
+ .loom-param-grid {
364
+ display: grid;
365
+ grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
366
+ gap: 16px;
367
+ margin-bottom: 16px;
368
+ }
369
+ .loom-param-field {
370
+ display: flex;
371
+ flex-direction: column;
372
+ align-items: flex-start;
373
+ }
374
+ .loom-param-field-bool {
375
+ display: flex;
376
+ flex-direction: row;
377
+ align-items: center;
378
+ gap: 8px;
379
+ padding-top: 24px;
380
+ }
381
+ .loom-param-label {
382
+ font-size: 0.875rem;
383
+ font-weight: 600;
384
+ color: CanvasText;
385
+ display: inline-flex;
386
+ align-items: center;
387
+ gap: 6px;
388
+ margin-bottom: 6px;
389
+ }
390
+ .loom-param-label-bool {
391
+ font-size: 0.875rem;
392
+ font-weight: 600;
393
+ color: CanvasText;
394
+ display: inline-flex;
395
+ align-items: center;
396
+ gap: 6px;
397
+ cursor: pointer;
398
+ }
399
+ .loom-param-input {
400
+ box-sizing: border-box;
401
+ width: 100%;
402
+ padding: 8px 12px;
403
+ border-radius: 6px;
404
+ border: 1px solid color-mix(in oklab, CanvasText 20%, Canvas);
405
+ background: Canvas;
406
+ color: CanvasText;
407
+ font-size: 0.875rem;
408
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
409
+ }
410
+ .loom-param-input:focus {
411
+ border-color: #6366f1;
412
+ outline: none;
413
+ box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
414
+ }
415
+ .loom-param-input-bool {
416
+ width: 18px;
417
+ height: 18px;
418
+ cursor: pointer;
419
+ accent-color: #6366f1;
420
+ }
421
+ .loom-tooltip-trigger {
422
+ display: inline-flex;
423
+ align-items: center;
424
+ justify-content: center;
425
+ width: 16px;
426
+ height: 16px;
427
+ border-radius: 50%;
428
+ background: color-mix(in oklab, CanvasText 8%, Canvas);
429
+ color: color-mix(in oklab, CanvasText 50%, Canvas);
430
+ font-size: 0.675rem;
431
+ font-weight: bold;
432
+ cursor: help;
433
+ position: relative;
434
+ }
435
+ .loom-tooltip-content {
436
+ position: absolute;
437
+ bottom: 130%;
438
+ left: 50%;
439
+ transform: translateX(-50%) translateY(4px);
440
+ background: #1e293b;
441
+ color: #f8fafc;
442
+ padding: 8px 12px;
443
+ border-radius: 6px;
444
+ font-size: 0.75rem;
445
+ font-family: system-ui, -apple-system, sans-serif;
446
+ line-height: 1.4;
447
+ width: 220px;
448
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.25);
449
+ opacity: 0;
450
+ pointer-events: none;
451
+ transition: opacity 0.15s ease, transform 0.15s ease;
452
+ z-index: 100;
453
+ text-align: left;
454
+ white-space: normal;
455
+ font-weight: normal;
456
+ }
457
+ .loom-tooltip-trigger:hover .loom-tooltip-content {
458
+ opacity: 1;
459
+ transform: translateX(-50%) translateY(0);
460
+ }
461
+ .loom-run-btn {
462
+ background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
463
+ color: #ffffff;
464
+ border: none;
465
+ padding: 10px 24px;
466
+ border-radius: 6px;
467
+ font-size: 0.875rem;
468
+ font-weight: 600;
469
+ cursor: pointer;
470
+ transition: transform 0.1s ease, box-shadow 0.15s ease;
471
+ box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.25);
472
+ }
473
+ .loom-run-btn:hover:not(:disabled) {
474
+ transform: translateY(-1px);
475
+ box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.35);
476
+ }
477
+ .loom-run-btn:active:not(:disabled) {
478
+ transform: translateY(1px);
479
+ }
480
+ .loom-run-btn:disabled {
481
+ opacity: 0.6;
482
+ cursor: not-allowed;
483
+ }
484
+ `),
485
+ React.createElement("div", { style: { fontSize: "1rem", fontWeight: 600, marginBottom: "12px" } }, "Job Parameters"),
486
+ React.createElement("div", { className: "loom-param-grid" }, Object.entries(activeMeta.params).map(([key, def]) => {
487
+ const isBool = def.type === "boolean";
488
+ const val = formValues[key] ?? "";
489
+ if (isBool) {
490
+ const isChecked = val === "true";
491
+ return (React.createElement("div", { key: key, className: "loom-param-field-bool" },
492
+ React.createElement("input", { type: "checkbox", id: `param-${key}`, className: "loom-param-input-bool", checked: isChecked, onChange: (e) => {
493
+ setFormValues((prev) => ({
494
+ ...prev,
495
+ [key]: e.target.checked ? "true" : "false",
496
+ }));
497
+ } }),
498
+ React.createElement("label", { htmlFor: `param-${key}`, className: "loom-param-label-bool" },
499
+ key,
500
+ def.required && (React.createElement("span", { style: { color: "#ef4444" } }, "*")),
501
+ React.createElement("span", { className: "loom-tooltip-trigger" },
502
+ "i",
503
+ React.createElement("span", { className: "loom-tooltip-content" },
504
+ React.createElement("strong", null, "Description:"),
505
+ " ",
506
+ def.desc,
507
+ def.default !== undefined && (React.createElement(React.Fragment, null,
508
+ React.createElement("br", null),
509
+ React.createElement("strong", null, "Default:"),
510
+ " ",
511
+ String(def.default))))))));
512
+ }
513
+ return (React.createElement("div", { key: key, className: "loom-param-field" },
514
+ React.createElement("label", { htmlFor: `param-${key}`, className: "loom-param-label" },
515
+ key,
516
+ def.required && React.createElement("span", { style: { color: "#ef4444" } }, "*"),
517
+ React.createElement("span", { className: "loom-tooltip-trigger" },
518
+ "i",
519
+ React.createElement("span", { className: "loom-tooltip-content" },
520
+ React.createElement("strong", null, "Description:"),
521
+ " ",
522
+ def.desc,
523
+ def.default !== undefined && (React.createElement(React.Fragment, null,
524
+ React.createElement("br", null),
525
+ React.createElement("strong", null, "Default:"),
526
+ " ",
527
+ String(def.default)))))),
528
+ React.createElement("input", { type: def.type === "number" ? "number" : "text", id: `param-${key}`, className: "loom-param-input", placeholder: def.default !== undefined
529
+ ? String(def.default)
530
+ : "", required: def.required, value: val, onChange: (e) => {
531
+ setFormValues((prev) => ({
532
+ ...prev,
533
+ [key]: e.target.value,
534
+ }));
535
+ } })));
536
+ })),
537
+ React.createElement("button", { type: "submit", className: "loom-run-btn", disabled: status === "starting" || status === "running" }, status === "idle" ? "Run Job" : "Rerun Job")));
538
+ }, [activeMeta, formValues, status]);
539
+ const panelChildren = (React.createElement(React.Fragment, null,
540
+ parametersForm,
541
+ entries.map((entry) => (React.createElement(JobsRunLogLine, { entry: entry, key: entry.id, renderLogValue: props.renderLogValue })))));
542
+ const panel = props.renderPanel?.({
543
+ children: panelChildren,
544
+ panelRef,
545
+ }) ?? (React.createElement(DefaultJobsRunPanel, { panelRef: panelRef }, panelChildren));
546
+ return (React.createElement(React.Fragment, null, props.renderPage?.({
547
+ id: props.id,
548
+ panel,
549
+ rerunButton,
550
+ status,
551
+ title,
552
+ }) ?? (React.createElement(DefaultJobsRunPageLayout, { id: props.id, panel: panel, rerunButton: rerunButton, status: status, title: title }))));
553
+ }
554
+ export function createJobsRunPage(options = {}) {
555
+ return function JobsRunPage(props) {
556
+ const { id } = React.use(props.params);
557
+ const searchParams = props.searchParams
558
+ ? React.use(props.searchParams)
559
+ : {};
560
+ const queryString = serializePageSearchParams(searchParams, options.reservedSearchParams ?? ["output"]);
561
+ return React.createElement(JobsRunPanel, { ...options, id: id, queryString: queryString });
562
+ };
563
+ }
@@ -0,0 +1,3 @@
1
+ import { type JobStreamEvent } from "../../jobs/events.js";
2
+ export declare function readNdJsonResponse(body: ReadableStream<Uint8Array>): AsyncGenerator<JobStreamEvent>;
3
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../src/src/next/jobs/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,sBAAsB,CAAC;AAE1E,wBAAuB,kBAAkB,CACvC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAC/B,cAAc,CAAC,cAAc,CAAC,CA4BhC"}
@@ -0,0 +1,25 @@
1
+ import { parseJobEvent } from "../../jobs/events.js";
2
+ export async function* readNdJsonResponse(body) {
3
+ const reader = body.getReader();
4
+ const decoder = new TextDecoder();
5
+ let buffer = "";
6
+ while (true) {
7
+ const { done, value } = await reader.read();
8
+ if (done) {
9
+ break;
10
+ }
11
+ buffer += decoder.decode(value, { stream: true });
12
+ const lines = buffer.split("\n");
13
+ buffer = lines.pop() ?? "";
14
+ for (const line of lines) {
15
+ if (!line.trim()) {
16
+ continue;
17
+ }
18
+ yield parseJobEvent(line);
19
+ }
20
+ }
21
+ buffer += decoder.decode();
22
+ if (buffer.trim()) {
23
+ yield parseJobEvent(buffer);
24
+ }
25
+ }