@raybase/core 0.0.2 → 0.3.3

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 (435) hide show
  1. package/LICENSE +21 -0
  2. package/dist/.admin-build/AdminApp.css +2 -0
  3. package/dist/.admin-build/AdminApp.js +77 -0
  4. package/dist/.admin-docs-build/AdminDocsApp.css +2 -0
  5. package/dist/.admin-docs-build/AdminDocsApp.js +45 -0
  6. package/dist/actions.d.ts +347 -0
  7. package/dist/actions.d.ts.map +1 -0
  8. package/dist/actions.js +661 -0
  9. package/dist/actions.js.map +1 -0
  10. package/dist/admin-assets/admin.7738f50720a8ed7b.css +2 -0
  11. package/dist/admin-assets/admin.8678cb61db34dc81.js +77 -0
  12. package/dist/admin-boot.d.ts +94 -0
  13. package/dist/admin-boot.d.ts.map +1 -0
  14. package/dist/admin-boot.js +139 -0
  15. package/dist/admin-boot.js.map +1 -0
  16. package/dist/admin-docs-content.d.ts +95 -0
  17. package/dist/admin-docs-content.d.ts.map +1 -0
  18. package/dist/admin-docs-content.js +463 -0
  19. package/dist/admin-docs-content.js.map +1 -0
  20. package/dist/admin-docs-ui.d.ts +11 -0
  21. package/dist/admin-docs-ui.d.ts.map +1 -0
  22. package/dist/admin-docs-ui.js +23 -0
  23. package/dist/admin-docs-ui.js.map +1 -0
  24. package/dist/admin-kit.d.ts +29 -0
  25. package/dist/admin-kit.js +1557 -0
  26. package/dist/admin-role.d.ts +8 -0
  27. package/dist/admin-role.d.ts.map +1 -0
  28. package/dist/admin-role.js +22 -0
  29. package/dist/admin-role.js.map +1 -0
  30. package/dist/admin-ui.d.ts +3 -0
  31. package/dist/admin-ui.d.ts.map +1 -0
  32. package/dist/admin-ui.js +16 -0
  33. package/dist/admin-ui.js.map +1 -0
  34. package/dist/agent-ai-chat.d.ts +127 -0
  35. package/dist/agent-ai-chat.d.ts.map +1 -0
  36. package/dist/agent-ai-chat.js +5975 -0
  37. package/dist/agent-ai-chat.js.map +1 -0
  38. package/dist/agent-chapter-archive.d.ts +214 -0
  39. package/dist/agent-chapter-archive.d.ts.map +1 -0
  40. package/dist/agent-chapter-archive.js +696 -0
  41. package/dist/agent-chapter-archive.js.map +1 -0
  42. package/dist/agent-chapter-search.d.ts +116 -0
  43. package/dist/agent-chapter-search.d.ts.map +1 -0
  44. package/dist/agent-chapter-search.js +605 -0
  45. package/dist/agent-chapter-search.js.map +1 -0
  46. package/dist/agent-chapter-tools.d.ts +45 -0
  47. package/dist/agent-chapter-tools.d.ts.map +1 -0
  48. package/dist/agent-chapter-tools.js +344 -0
  49. package/dist/agent-chapter-tools.js.map +1 -0
  50. package/dist/agent-chapters.d.ts +228 -0
  51. package/dist/agent-chapters.d.ts.map +1 -0
  52. package/dist/agent-chapters.js +737 -0
  53. package/dist/agent-chapters.js.map +1 -0
  54. package/dist/agent-data-parts.d.ts +167 -0
  55. package/dist/agent-data-parts.d.ts.map +1 -0
  56. package/dist/agent-data-parts.js +68 -0
  57. package/dist/agent-data-parts.js.map +1 -0
  58. package/dist/agent-errors.d.ts +41 -0
  59. package/dist/agent-errors.d.ts.map +1 -0
  60. package/dist/agent-errors.js +191 -0
  61. package/dist/agent-errors.js.map +1 -0
  62. package/dist/agent-follow-up-store.d.ts +273 -0
  63. package/dist/agent-follow-up-store.d.ts.map +1 -0
  64. package/dist/agent-follow-up-store.js +703 -0
  65. package/dist/agent-follow-up-store.js.map +1 -0
  66. package/dist/agent-follow-ups.d.ts +314 -0
  67. package/dist/agent-follow-ups.d.ts.map +1 -0
  68. package/dist/agent-follow-ups.js +840 -0
  69. package/dist/agent-follow-ups.js.map +1 -0
  70. package/dist/agent-memory.d.ts +323 -0
  71. package/dist/agent-memory.d.ts.map +1 -0
  72. package/dist/agent-memory.js +1270 -0
  73. package/dist/agent-memory.js.map +1 -0
  74. package/dist/agent-message-parts.d.ts +58 -0
  75. package/dist/agent-message-parts.d.ts.map +1 -0
  76. package/dist/agent-message-parts.js +163 -0
  77. package/dist/agent-message-parts.js.map +1 -0
  78. package/dist/agent-remote-mcp-credentials.d.ts +154 -0
  79. package/dist/agent-remote-mcp-credentials.d.ts.map +1 -0
  80. package/dist/agent-remote-mcp-credentials.js +287 -0
  81. package/dist/agent-remote-mcp-credentials.js.map +1 -0
  82. package/dist/agent-remote-mcp-crypto.d.ts +32 -0
  83. package/dist/agent-remote-mcp-crypto.d.ts.map +1 -0
  84. package/dist/agent-remote-mcp-crypto.js +101 -0
  85. package/dist/agent-remote-mcp-crypto.js.map +1 -0
  86. package/dist/agent-remote-mcp-install.d.ts +299 -0
  87. package/dist/agent-remote-mcp-install.d.ts.map +1 -0
  88. package/dist/agent-remote-mcp-install.js +785 -0
  89. package/dist/agent-remote-mcp-install.js.map +1 -0
  90. package/dist/agent-remote-mcp-oauth.d.ts +73 -0
  91. package/dist/agent-remote-mcp-oauth.d.ts.map +1 -0
  92. package/dist/agent-remote-mcp-oauth.js +344 -0
  93. package/dist/agent-remote-mcp-oauth.js.map +1 -0
  94. package/dist/agent-remote-mcp-transport.d.ts +46 -0
  95. package/dist/agent-remote-mcp-transport.d.ts.map +1 -0
  96. package/dist/agent-remote-mcp-transport.js +225 -0
  97. package/dist/agent-remote-mcp-transport.js.map +1 -0
  98. package/dist/agent-remote-mcp.d.ts +147 -0
  99. package/dist/agent-remote-mcp.d.ts.map +1 -0
  100. package/dist/agent-remote-mcp.js +681 -0
  101. package/dist/agent-remote-mcp.js.map +1 -0
  102. package/dist/agent-room-redaction.d.ts +66 -0
  103. package/dist/agent-room-redaction.d.ts.map +1 -0
  104. package/dist/agent-room-redaction.js +264 -0
  105. package/dist/agent-room-redaction.js.map +1 -0
  106. package/dist/agent-rooms.d.ts +209 -0
  107. package/dist/agent-rooms.d.ts.map +1 -0
  108. package/dist/agent-rooms.js +244 -0
  109. package/dist/agent-rooms.js.map +1 -0
  110. package/dist/agent-runtime.d.ts +541 -0
  111. package/dist/agent-runtime.d.ts.map +1 -0
  112. package/dist/agent-runtime.js +4260 -0
  113. package/dist/agent-runtime.js.map +1 -0
  114. package/dist/agent-skill-archive.d.ts +20 -0
  115. package/dist/agent-skill-archive.d.ts.map +1 -0
  116. package/dist/agent-skill-archive.js +316 -0
  117. package/dist/agent-skill-archive.js.map +1 -0
  118. package/dist/agent-skill-discovery.d.ts +96 -0
  119. package/dist/agent-skill-discovery.d.ts.map +1 -0
  120. package/dist/agent-skill-discovery.js +464 -0
  121. package/dist/agent-skill-discovery.js.map +1 -0
  122. package/dist/agent-skill-format.d.ts +57 -0
  123. package/dist/agent-skill-format.d.ts.map +1 -0
  124. package/dist/agent-skill-format.js +238 -0
  125. package/dist/agent-skill-format.js.map +1 -0
  126. package/dist/agent-skill-import.d.ts +64 -0
  127. package/dist/agent-skill-import.d.ts.map +1 -0
  128. package/dist/agent-skill-import.js +295 -0
  129. package/dist/agent-skill-import.js.map +1 -0
  130. package/dist/agent-skill-publish.d.ts +51 -0
  131. package/dist/agent-skill-publish.d.ts.map +1 -0
  132. package/dist/agent-skill-publish.js +136 -0
  133. package/dist/agent-skill-publish.js.map +1 -0
  134. package/dist/agent-skill-store.d.ts +252 -0
  135. package/dist/agent-skill-store.d.ts.map +1 -0
  136. package/dist/agent-skill-store.js +514 -0
  137. package/dist/agent-skill-store.js.map +1 -0
  138. package/dist/agent-skills.d.ts +85 -0
  139. package/dist/agent-skills.d.ts.map +1 -0
  140. package/dist/agent-skills.js +291 -0
  141. package/dist/agent-skills.js.map +1 -0
  142. package/dist/agent-transcript-pager.d.ts +77 -0
  143. package/dist/agent-transcript-pager.d.ts.map +1 -0
  144. package/dist/agent-transcript-pager.js +210 -0
  145. package/dist/agent-transcript-pager.js.map +1 -0
  146. package/dist/agent-user-data-parts.d.ts +20 -0
  147. package/dist/agent-user-data-parts.d.ts.map +1 -0
  148. package/dist/agent-user-data-parts.js +161 -0
  149. package/dist/agent-user-data-parts.js.map +1 -0
  150. package/dist/agent-user-transcript.d.ts +46 -0
  151. package/dist/agent-user-transcript.d.ts.map +1 -0
  152. package/dist/agent-user-transcript.js +106 -0
  153. package/dist/agent-user-transcript.js.map +1 -0
  154. package/dist/agent-voice-notes.d.ts +15 -0
  155. package/dist/agent-voice-notes.d.ts.map +1 -0
  156. package/dist/agent-voice-notes.js +17 -0
  157. package/dist/agent-voice-notes.js.map +1 -0
  158. package/dist/agent-wakes.d.ts +213 -0
  159. package/dist/agent-wakes.d.ts.map +1 -0
  160. package/dist/agent-wakes.js +534 -0
  161. package/dist/agent-wakes.js.map +1 -0
  162. package/dist/agent.d.ts +1780 -0
  163. package/dist/agent.d.ts.map +1 -0
  164. package/dist/agent.js +3123 -0
  165. package/dist/agent.js.map +1 -0
  166. package/dist/ai.d.ts +583 -0
  167. package/dist/ai.d.ts.map +1 -0
  168. package/dist/ai.js +1858 -0
  169. package/dist/ai.js.map +1 -0
  170. package/dist/app-manifest.d.ts +255 -0
  171. package/dist/app-manifest.d.ts.map +1 -0
  172. package/dist/app-manifest.js +372 -0
  173. package/dist/app-manifest.js.map +1 -0
  174. package/dist/app-users.d.ts +30 -0
  175. package/dist/app-users.d.ts.map +1 -0
  176. package/dist/app-users.js +91 -0
  177. package/dist/app-users.js.map +1 -0
  178. package/dist/audit-archive.d.ts +85 -0
  179. package/dist/audit-archive.d.ts.map +1 -0
  180. package/dist/audit-archive.js +178 -0
  181. package/dist/audit-archive.js.map +1 -0
  182. package/dist/audit.d.ts +54 -0
  183. package/dist/audit.d.ts.map +1 -0
  184. package/dist/audit.js +95 -0
  185. package/dist/audit.js.map +1 -0
  186. package/dist/auth-logger.d.ts +28 -0
  187. package/dist/auth-logger.d.ts.map +1 -0
  188. package/dist/auth-logger.js +53 -0
  189. package/dist/auth-logger.js.map +1 -0
  190. package/dist/auth-password-secret.d.ts +59 -0
  191. package/dist/auth-password-secret.d.ts.map +1 -0
  192. package/dist/auth-password-secret.js +409 -0
  193. package/dist/auth-password-secret.js.map +1 -0
  194. package/dist/auth-schema.d.ts +120 -0
  195. package/dist/auth-schema.d.ts.map +1 -0
  196. package/dist/auth-schema.js +285 -0
  197. package/dist/auth-schema.js.map +1 -0
  198. package/dist/auth.d.ts +321 -0
  199. package/dist/auth.d.ts.map +1 -0
  200. package/dist/auth.js +1562 -0
  201. package/dist/auth.js.map +1 -0
  202. package/dist/backup-archive.d.ts +257 -0
  203. package/dist/backup-archive.d.ts.map +1 -0
  204. package/dist/backup-archive.js +2068 -0
  205. package/dist/backup-archive.js.map +1 -0
  206. package/dist/backup-crypto.d.ts +313 -0
  207. package/dist/backup-crypto.d.ts.map +1 -0
  208. package/dist/backup-crypto.js +693 -0
  209. package/dist/backup-crypto.js.map +1 -0
  210. package/dist/backup-format.d.ts +200 -0
  211. package/dist/backup-format.d.ts.map +1 -0
  212. package/dist/backup-format.js +1247 -0
  213. package/dist/backup-format.js.map +1 -0
  214. package/dist/cli.d.ts +9 -0
  215. package/dist/cli.d.ts.map +1 -0
  216. package/dist/cli.js +15 -0
  217. package/dist/cli.js.map +1 -0
  218. package/dist/clock.d.ts +35 -0
  219. package/dist/clock.d.ts.map +1 -0
  220. package/dist/clock.js +83 -0
  221. package/dist/clock.js.map +1 -0
  222. package/dist/data-client.d.ts +187 -0
  223. package/dist/data-client.d.ts.map +1 -0
  224. package/dist/data-client.js +590 -0
  225. package/dist/data-client.js.map +1 -0
  226. package/dist/data-secrets.d.ts +164 -0
  227. package/dist/data-secrets.d.ts.map +1 -0
  228. package/dist/data-secrets.js +383 -0
  229. package/dist/data-secrets.js.map +1 -0
  230. package/dist/db.d.ts +453 -0
  231. package/dist/db.d.ts.map +1 -0
  232. package/dist/db.js +324 -0
  233. package/dist/db.js.map +1 -0
  234. package/dist/dev-activity.d.ts +48 -0
  235. package/dist/dev-activity.d.ts.map +1 -0
  236. package/dist/dev-activity.js +50 -0
  237. package/dist/dev-activity.js.map +1 -0
  238. package/dist/do.d.ts +429 -0
  239. package/dist/do.d.ts.map +1 -0
  240. package/dist/do.js +4526 -0
  241. package/dist/do.js.map +1 -0
  242. package/dist/email.d.ts +137 -0
  243. package/dist/email.d.ts.map +1 -0
  244. package/dist/email.js +527 -0
  245. package/dist/email.js.map +1 -0
  246. package/dist/generated/admin-assets.d.ts +16 -0
  247. package/dist/generated/admin-assets.d.ts.map +1 -0
  248. package/dist/generated/admin-assets.js +16 -0
  249. package/dist/generated/admin-assets.js.map +1 -0
  250. package/dist/generated/admin-docs-assets.d.ts +3 -0
  251. package/dist/generated/admin-docs-assets.d.ts.map +1 -0
  252. package/dist/generated/admin-docs-assets.js +3 -0
  253. package/dist/generated/admin-docs-assets.js.map +1 -0
  254. package/dist/handoff-consumer.d.ts +79 -0
  255. package/dist/handoff-consumer.d.ts.map +1 -0
  256. package/dist/handoff-consumer.js +300 -0
  257. package/dist/handoff-consumer.js.map +1 -0
  258. package/dist/handoff.d.ts +70 -0
  259. package/dist/handoff.d.ts.map +1 -0
  260. package/dist/handoff.js +228 -0
  261. package/dist/handoff.js.map +1 -0
  262. package/dist/host-auth.d.ts +47 -0
  263. package/dist/host-auth.d.ts.map +1 -0
  264. package/dist/host-auth.js +59 -0
  265. package/dist/host-auth.js.map +1 -0
  266. package/dist/host-user.d.ts +15 -0
  267. package/dist/host-user.d.ts.map +1 -0
  268. package/dist/host-user.js +23 -0
  269. package/dist/host-user.js.map +1 -0
  270. package/dist/html.d.ts +35 -0
  271. package/dist/html.d.ts.map +1 -0
  272. package/dist/html.js +634 -0
  273. package/dist/html.js.map +1 -0
  274. package/dist/http-error.d.ts +13 -0
  275. package/dist/http-error.d.ts.map +1 -0
  276. package/dist/http-error.js +15 -0
  277. package/dist/http-error.js.map +1 -0
  278. package/dist/imports.d.ts +219 -0
  279. package/dist/imports.d.ts.map +1 -0
  280. package/dist/imports.js +571 -0
  281. package/dist/imports.js.map +1 -0
  282. package/dist/index.d.ts +78 -0
  283. package/dist/index.d.ts.map +1 -0
  284. package/dist/index.js +76 -0
  285. package/dist/index.js.map +1 -0
  286. package/dist/inference-tape.d.ts +64 -0
  287. package/dist/inference-tape.d.ts.map +1 -0
  288. package/dist/inference-tape.js +278 -0
  289. package/dist/inference-tape.js.map +1 -0
  290. package/dist/internal.d.ts +15 -0
  291. package/dist/internal.d.ts.map +1 -0
  292. package/dist/internal.js +48 -0
  293. package/dist/internal.js.map +1 -0
  294. package/dist/jobs.d.ts +796 -0
  295. package/dist/jobs.d.ts.map +1 -0
  296. package/dist/jobs.js +538 -0
  297. package/dist/jobs.js.map +1 -0
  298. package/dist/json-schema.d.ts +91 -0
  299. package/dist/json-schema.d.ts.map +1 -0
  300. package/dist/json-schema.js +884 -0
  301. package/dist/json-schema.js.map +1 -0
  302. package/dist/knowledge.d.ts +33 -0
  303. package/dist/knowledge.d.ts.map +1 -0
  304. package/dist/knowledge.js +348 -0
  305. package/dist/knowledge.js.map +1 -0
  306. package/dist/local-dev-chrome.d.ts +29 -0
  307. package/dist/local-dev-chrome.d.ts.map +1 -0
  308. package/dist/local-dev-chrome.js +514 -0
  309. package/dist/local-dev-chrome.js.map +1 -0
  310. package/dist/local-dev-personas.d.ts +15 -0
  311. package/dist/local-dev-personas.d.ts.map +1 -0
  312. package/dist/local-dev-personas.js +46 -0
  313. package/dist/local-dev-personas.js.map +1 -0
  314. package/dist/mcp.d.ts +567 -0
  315. package/dist/mcp.d.ts.map +1 -0
  316. package/dist/mcp.js +2480 -0
  317. package/dist/mcp.js.map +1 -0
  318. package/dist/modules.d.ts +145 -0
  319. package/dist/modules.d.ts.map +1 -0
  320. package/dist/modules.js +164 -0
  321. package/dist/modules.js.map +1 -0
  322. package/dist/notification-client.d.ts +94 -0
  323. package/dist/notification-client.d.ts.map +1 -0
  324. package/dist/notification-client.js +127 -0
  325. package/dist/notification-client.js.map +1 -0
  326. package/dist/notifications.d.ts +447 -0
  327. package/dist/notifications.d.ts.map +1 -0
  328. package/dist/notifications.js +1625 -0
  329. package/dist/notifications.js.map +1 -0
  330. package/dist/operator-data-query.d.ts +117 -0
  331. package/dist/operator-data-query.d.ts.map +1 -0
  332. package/dist/operator-data-query.js +431 -0
  333. package/dist/operator-data-query.js.map +1 -0
  334. package/dist/operator-mcp.d.ts +63 -0
  335. package/dist/operator-mcp.d.ts.map +1 -0
  336. package/dist/operator-mcp.js +2828 -0
  337. package/dist/operator-mcp.js.map +1 -0
  338. package/dist/outbound-https.d.ts +24 -0
  339. package/dist/outbound-https.d.ts.map +1 -0
  340. package/dist/outbound-https.js +172 -0
  341. package/dist/outbound-https.js.map +1 -0
  342. package/dist/pitr.d.ts +60 -0
  343. package/dist/pitr.d.ts.map +1 -0
  344. package/dist/pitr.js +94 -0
  345. package/dist/pitr.js.map +1 -0
  346. package/dist/platform.d.ts +199 -0
  347. package/dist/platform.d.ts.map +1 -0
  348. package/dist/platform.js +196 -0
  349. package/dist/platform.js.map +1 -0
  350. package/dist/policies.d.ts +115 -0
  351. package/dist/policies.d.ts.map +1 -0
  352. package/dist/policies.js +158 -0
  353. package/dist/policies.js.map +1 -0
  354. package/dist/principal.d.ts +143 -0
  355. package/dist/principal.d.ts.map +1 -0
  356. package/dist/principal.js +174 -0
  357. package/dist/principal.js.map +1 -0
  358. package/dist/realtime.d.ts +280 -0
  359. package/dist/realtime.d.ts.map +1 -0
  360. package/dist/realtime.js +578 -0
  361. package/dist/realtime.js.map +1 -0
  362. package/dist/retrieval.d.ts +263 -0
  363. package/dist/retrieval.d.ts.map +1 -0
  364. package/dist/retrieval.js +602 -0
  365. package/dist/retrieval.js.map +1 -0
  366. package/dist/runtime-error-client.d.ts +10 -0
  367. package/dist/runtime-error-client.d.ts.map +1 -0
  368. package/dist/runtime-error-client.js +70 -0
  369. package/dist/runtime-error-client.js.map +1 -0
  370. package/dist/runtime-errors.d.ts +180 -0
  371. package/dist/runtime-errors.d.ts.map +1 -0
  372. package/dist/runtime-errors.js +572 -0
  373. package/dist/runtime-errors.js.map +1 -0
  374. package/dist/schema.d.ts +434 -0
  375. package/dist/schema.d.ts.map +1 -0
  376. package/dist/schema.js +232 -0
  377. package/dist/schema.js.map +1 -0
  378. package/dist/search.d.ts +216 -0
  379. package/dist/search.d.ts.map +1 -0
  380. package/dist/search.js +785 -0
  381. package/dist/search.js.map +1 -0
  382. package/dist/settings.d.ts +191 -0
  383. package/dist/settings.d.ts.map +1 -0
  384. package/dist/settings.js +478 -0
  385. package/dist/settings.js.map +1 -0
  386. package/dist/sql.d.ts +7 -0
  387. package/dist/sql.d.ts.map +1 -0
  388. package/dist/sql.js +30 -0
  389. package/dist/sql.js.map +1 -0
  390. package/dist/storage-client.d.ts +69 -0
  391. package/dist/storage-client.d.ts.map +1 -0
  392. package/dist/storage-client.js +469 -0
  393. package/dist/storage-client.js.map +1 -0
  394. package/dist/storage.d.ts +21 -0
  395. package/dist/storage.d.ts.map +1 -0
  396. package/dist/storage.js +82 -0
  397. package/dist/storage.js.map +1 -0
  398. package/dist/subject-domains.d.ts +15 -0
  399. package/dist/subject-domains.d.ts.map +1 -0
  400. package/dist/subject-domains.js +38 -0
  401. package/dist/subject-domains.js.map +1 -0
  402. package/dist/support.d.ts +132 -0
  403. package/dist/support.d.ts.map +1 -0
  404. package/dist/support.js +483 -0
  405. package/dist/support.js.map +1 -0
  406. package/dist/system-tables.d.ts +12 -0
  407. package/dist/system-tables.d.ts.map +1 -0
  408. package/dist/system-tables.js +225 -0
  409. package/dist/system-tables.js.map +1 -0
  410. package/dist/test.d.ts +57 -0
  411. package/dist/test.d.ts.map +1 -0
  412. package/dist/test.js +454 -0
  413. package/dist/test.js.map +1 -0
  414. package/dist/vite.d.ts +82 -0
  415. package/dist/vite.d.ts.map +1 -0
  416. package/dist/vite.js +82 -0
  417. package/dist/vite.js.map +1 -0
  418. package/dist/webpush-crypto.d.ts +39 -0
  419. package/dist/webpush-crypto.d.ts.map +1 -0
  420. package/dist/webpush-crypto.js +213 -0
  421. package/dist/webpush-crypto.js.map +1 -0
  422. package/dist/webpush-private.d.ts +11 -0
  423. package/dist/webpush-private.d.ts.map +1 -0
  424. package/dist/webpush-private.js +11 -0
  425. package/dist/webpush-private.js.map +1 -0
  426. package/dist/webpush.d.ts +86 -0
  427. package/dist/webpush.d.ts.map +1 -0
  428. package/dist/webpush.js +375 -0
  429. package/dist/webpush.js.map +1 -0
  430. package/dist/worker.d.ts +185 -0
  431. package/dist/worker.d.ts.map +1 -0
  432. package/dist/worker.js +13021 -0
  433. package/dist/worker.js.map +1 -0
  434. package/package.json +161 -8
  435. package/README.md +0 -3
@@ -0,0 +1,514 @@
1
+ import { RaybaseActionError } from "./actions.js";
2
+ import { agentSkillRegistrations } from "./agent-skills.js";
3
+ import { recordAudit } from "./audit.js";
4
+ import { normalizeSkillPath, validateOpenAgentSkillName } from "./agent-skill-format.js";
5
+ import { sha256Hex, stableJson } from "./internal.js";
6
+ import { id, integer, longText, raybaseSystemTable, text } from "./schema.js";
7
+ import { nowIso, q, randomId } from "./sql.js";
8
+ import { validateOutboundHttpsUrl, validateOutboundOrigin } from "./outbound-https.js";
9
+ export const raybaseAgentSkillStoreLimits = {
10
+ maxSkills: 200,
11
+ maxSkillsCap: 1000,
12
+ maxGuidanceBytes: 64_000,
13
+ maxGuidanceBytesCap: 256_000,
14
+ uploadBytes: 10 * 1024 * 1024,
15
+ uploadInlineBytes: 1024 * 1024,
16
+ uploadTtlMs: 15 * 60 * 1000,
17
+ revisionsPerSkill: 3
18
+ };
19
+ export const raybaseAgentSkillToolNames = [
20
+ "skill_list", "skill_read", "skill_write", "skill_edit", "skill_delete", "skill_set_enabled",
21
+ "skill_import_discover", "skill_import_apply"
22
+ ];
23
+ export const raybaseAgentSkillSystemTables = [
24
+ raybaseSystemTable("_agent_skills", {
25
+ id: id(), agentName: text({ required: true }), normalizedName: text({ required: true }), name: text({ required: true }), title: text(),
26
+ description: text({ required: true }), guidance: longText({ required: true }), mode: text({ required: true }), ephemeral: integer({ required: true }), contentDigest: text({ required: true }),
27
+ lastImportedContentDigest: text(), license: text(), compatibility: text(), metadataJson: longText({ required: true }), enabled: integer({ required: true }),
28
+ revision: integer({ required: true }), source: text({ required: true }), ownerKind: text({ required: true }), ownerAgentName: text(), createdBy: text({ required: true }),
29
+ originKind: text({ required: true }), originUrl: text(), originRef: text(), originRefKind: text(), originCommit: text(), originRepo: text(),
30
+ originManifestPath: text(), originSkillPath: text(), originDigest: text(), importedAt: text(), sourceId: text(), remoteSha256: text(), syncedAt: text(),
31
+ syncStatus: text(), syncError: longText(), createdAt: text({ required: true }), updatedAt: text({ required: true })
32
+ }, { indexes: [{ columns: ["agentName", "normalizedName"], unique: true }, ["agentName", "enabled"], ["sourceId"], ["updatedAt"]] }),
33
+ raybaseSystemTable("_agent_skill_files", {
34
+ id: id(), skillId: text({ required: true }), path: text({ required: true }), normalizedPath: text({ required: true }), kind: text({ required: true }),
35
+ encoding: text({ required: true }), content: longText({ required: true }), bytes: integer({ required: true }), sha256: text({ required: true }), createdAt: text({ required: true })
36
+ }, { indexes: [{ columns: ["skillId", "normalizedPath"], unique: true }, ["skillId"]] }),
37
+ raybaseSystemTable("_agent_skill_sources", {
38
+ id: id(), agentName: text({ required: true }), sourceType: text({ required: true }), url: text({ required: true }), registeredBy: text({ required: true }),
39
+ enabled: integer({ required: true }), revision: integer({ required: true }), syncEveryMs: integer({ required: true }), authSecretName: text(), allowedArtifactOriginsJson: longText({ required: true }),
40
+ artifactAuthJson: longText({ required: true }), selectionMode: text({ required: true }), selectedNamesJson: longText({ required: true }), etag: text(),
41
+ lastSyncAt: text(), lastSyncStatus: text(), lastSyncError: longText(), lastSyncSummaryJson: longText(), repo: text(), manifestPath: text(), requestedRef: text(),
42
+ refKind: text(), defaultBranch: text(), resolvedCommit: text(), createdAt: text({ required: true }), updatedAt: text({ required: true })
43
+ }, { indexes: [{ columns: ["agentName", "url"], unique: true }, ["enabled", "lastSyncAt"], ["agentName"]] }),
44
+ raybaseSystemTable("_agent_skill_revisions", {
45
+ id: id(), skillId: text({ required: true }), revision: integer({ required: true }), title: text(), description: text({ required: true }),
46
+ guidance: longText({ required: true }), mode: text({ required: true }), ephemeral: integer({ required: true }), enabled: integer({ required: true }), contentDigest: text({ required: true }),
47
+ reason: text({ required: true }), actorKind: text({ required: true }), actor: text(), createdAt: text({ required: true })
48
+ }, { indexes: [["skillId", "revision"], ["createdAt"]] }),
49
+ raybaseSystemTable("_agent_skill_uploads", {
50
+ id: id(), agentName: text({ required: true }), filename: text({ required: true }), contentBase64: longText({ required: true }), bytes: integer({ required: true }),
51
+ sha256: text({ required: true }), createdByUserId: text(), createdAt: text({ required: true }), expiresAt: text({ required: true })
52
+ }, { indexes: [["agentName", "createdAt"], ["expiresAt"]] }),
53
+ raybaseSystemTable("_agent_skill_loads", {
54
+ id: id(), conversationId: text({ required: true }), chapterId: text({ required: true }), skillName: text({ required: true }), loadedAt: text({ required: true })
55
+ }, { indexes: [{ columns: ["conversationId", "chapterId", "skillName"], unique: true }, ["conversationId", "chapterId"]] })
56
+ ];
57
+ export function validateAgentSkillStoreForAgent(agent) {
58
+ const store = agent.skillStore;
59
+ if (store === undefined)
60
+ return;
61
+ if (!store || typeof store !== "object" || store.enabled !== true && store.enabled !== false)
62
+ throw new Error(`Raybase agent ${agent.name} skillStore.enabled must be boolean`);
63
+ if (!store.enabled)
64
+ return;
65
+ if (store.policy !== undefined && typeof store.policy !== "function")
66
+ throw new Error(`Raybase agent ${agent.name} skillStore.policy must be a function`);
67
+ boundedConfigLimit(agent.name, "maxSkills", store.limits?.maxSkills, raybaseAgentSkillStoreLimits.maxSkillsCap);
68
+ boundedConfigLimit(agent.name, "maxGuidanceBytes", store.limits?.maxGuidanceBytes, raybaseAgentSkillStoreLimits.maxGuidanceBytesCap);
69
+ const imports = store.agentAccess?.importSources ?? [];
70
+ if (!Array.isArray(imports) || imports.some((kind) => kind !== "direct-url" && kind !== "github"))
71
+ throw new Error(`Raybase agent ${agent.name} skillStore.agentAccess.importSources contains an unsupported source kind`);
72
+ for (const source of store.sources ?? []) {
73
+ if (!source || typeof source.url !== "string" || !source.url.trim())
74
+ throw new Error(`Raybase agent ${agent.name} skillStore source URL is required`);
75
+ validateOutboundHttpsUrl(source.url);
76
+ if (source.syncEveryMs !== undefined && source.syncEveryMs < 15 * 60 * 1000)
77
+ throw new Error(`Raybase agent ${agent.name} skillStore source syncEveryMs must be at least 15 minutes`);
78
+ if ((source.allowedArtifactOrigins?.length ?? 0) > 8)
79
+ throw new Error(`Raybase agent ${agent.name} skillStore source allows at most 8 artifact origins`);
80
+ for (const origin of source.allowedArtifactOrigins ?? [])
81
+ validateOutboundOrigin(origin);
82
+ if (source.authSecretName && !/^[A-Z][A-Z0-9_]*$/.test(source.authSecretName))
83
+ throw new Error(`Raybase agent ${agent.name} skillStore source authSecretName must be an uppercase environment binding name`);
84
+ for (const mapping of source.artifactAuth ?? []) {
85
+ validateOutboundOrigin(mapping.origin);
86
+ if (!source.allowedArtifactOrigins?.includes(mapping.origin))
87
+ throw new Error(`Raybase agent ${agent.name} skillStore artifact auth origin ${mapping.origin} must also be allowed`);
88
+ if (!/^[A-Z][A-Z0-9_]*$/.test(mapping.secretName))
89
+ throw new Error(`Raybase agent ${agent.name} skillStore artifact secretName must be an uppercase environment binding name`);
90
+ }
91
+ }
92
+ }
93
+ export function agentSkillStoreEnabled(agent) { return agent.skillStore?.enabled === true; }
94
+ export async function listAgentSkills(control, agentName) {
95
+ return control.all(`SELECT * FROM ${q("_agent_skills")}${agentName ? ` WHERE "agentName" = ?` : ""} ORDER BY "agentName", "name"`, agentName ? [agentName] : []);
96
+ }
97
+ export async function findAgentSkill(control, agentName, name) {
98
+ return control.first(`SELECT * FROM ${q("_agent_skills")} WHERE "agentName" = ? AND "normalizedName" = ? LIMIT 1`, [agentName, normalizeSkillName(name)]);
99
+ }
100
+ export async function listAgentSkillFiles(control, skillId) {
101
+ return control.all(`SELECT "path", "kind", "encoding", "content", "bytes", "sha256" FROM ${q("_agent_skill_files")} WHERE "skillId" = ? ORDER BY "path"`, [skillId]);
102
+ }
103
+ export async function readAgentSkillFile(control, skillId, pathValue) {
104
+ const path = normalizeSkillPath(pathValue);
105
+ return control.first(`SELECT "path", "kind", "encoding", "content", "bytes", "sha256" FROM ${q("_agent_skill_files")} WHERE "skillId" = ? AND "normalizedPath" = ? LIMIT 1`, [skillId, normalizeSkillName(path)]);
106
+ }
107
+ export async function currentAgentSkillChapterId(control, conversationId) {
108
+ const last = await control.first(`SELECT "id" FROM ${q("_agent_chapters")} WHERE "conversationId" = ? ORDER BY "ordinal" DESC LIMIT 1`, [conversationId]);
109
+ return last?.id ?? "chapter:0";
110
+ }
111
+ export async function listLoadedAgentSkillNames(control, conversationId, chapterId) {
112
+ const effectiveChapterId = chapterId ?? await currentAgentSkillChapterId(control, conversationId);
113
+ const rows = await control.all(`SELECT "skillName" FROM ${q("_agent_skill_loads")} WHERE "conversationId" = ? AND "chapterId" = ? ORDER BY "skillName"`, [conversationId, effectiveChapterId]);
114
+ return rows.map((row) => row.skillName);
115
+ }
116
+ export async function loadAgentSkillForChapter(control, conversationId, skillName) {
117
+ const chapterId = await currentAgentSkillChapterId(control, conversationId);
118
+ const existing = await control.first(`SELECT "id" FROM ${q("_agent_skill_loads")} WHERE "conversationId" = ? AND "chapterId" = ? AND "skillName" = ? LIMIT 1`, [conversationId, chapterId, skillName]);
119
+ if (existing)
120
+ return { chapterId, alreadyLoaded: true };
121
+ await control.run(`INSERT OR IGNORE INTO ${q("_agent_skill_loads")} ("id","conversationId","chapterId","skillName","loadedAt") VALUES (?,?,?,?,?)`, [randomId("skill_load"), conversationId, chapterId, skillName, nowIso()]);
122
+ return { chapterId, alreadyLoaded: false };
123
+ }
124
+ export async function installAgentSkillPackage(control, input) {
125
+ const existing = await findAgentSkill(control, input.agentName, input.package.name);
126
+ const mode = input.mode ?? existing?.mode ?? (input.package.ephemeral ? "include" : "available");
127
+ assertSkillDurability(input.package.ephemeral, mode);
128
+ if (existing && !input.replace)
129
+ throw skillError("skill_conflict", `Skill ${input.package.name} already exists`, { source: existing.source, revision: existing.revision });
130
+ if (existing) {
131
+ if (input.expectedRevision !== existing.revision)
132
+ throw staleRevision(existing);
133
+ if (existing.source === "code")
134
+ throw skillError("ownership", `Code skill ${existing.name} can only change through code reconcile`);
135
+ const revision = existing.revision + 1;
136
+ const now = nowIso();
137
+ await mutateSkillWithCas(control, existing, input.reason ?? "replace", input.actorKind ?? input.ownerKind, input.actor ?? input.createdBy, [
138
+ { sql: `UPDATE ${q("_agent_skills")} SET "title"=?, "description"=?, "guidance"=?, "mode"=?, "ephemeral"=?, "contentDigest"=?, "lastImportedContentDigest"=?, "license"=?, "compatibility"=?, "metadataJson"=?, "enabled"=?, "revision"=?, "updatedAt"=? WHERE "id"=? AND "revision"=?`, params: [
139
+ input.package.title ?? null, input.package.description, input.package.guidance, mode, input.package.ephemeral ? 1 : 0, input.package.contentDigest,
140
+ input.source === "local" ? input.package.contentDigest : null, input.package.license ?? null, input.package.compatibility ?? null, input.package.metadataJson,
141
+ input.enabled === undefined ? existing.enabled : input.enabled ? 1 : 0, revision, now, existing.id, existing.revision
142
+ ] },
143
+ ...replaceSkillFileStatements(existing.id, input.package.files, now)
144
+ ]);
145
+ return (await findAgentSkill(control, input.agentName, input.package.name));
146
+ }
147
+ const idValue = randomId("skill");
148
+ const now = nowIso();
149
+ await control.run(`INSERT INTO ${q("_agent_skills")} (
150
+ "id","agentName","normalizedName","name","title","description","guidance","mode","ephemeral","contentDigest","lastImportedContentDigest","license","compatibility","metadataJson","enabled","revision","source","ownerKind","ownerAgentName","createdBy","originKind","originUrl","originRef","originRefKind","originCommit","originRepo","originManifestPath","originSkillPath","originDigest","importedAt","sourceId","remoteSha256","syncedAt","syncStatus","syncError","createdAt","updatedAt"
151
+ ) VALUES (${Array.from({ length: 37 }, () => "?").join(",")})`, [
152
+ idValue, input.agentName, normalizeSkillName(input.package.name), input.package.name, input.package.title ?? null, input.package.description,
153
+ input.package.guidance, mode, input.package.ephemeral ? 1 : 0, input.package.contentDigest, input.source === "local" ? input.package.contentDigest : null,
154
+ input.package.license ?? null, input.package.compatibility ?? null, input.package.metadataJson, input.enabled === false ? 0 : 1, 1, input.source,
155
+ input.ownerKind, input.ownerAgentName ?? null, input.createdBy, input.originKind, input.originUrl ?? null, input.originRef ?? null,
156
+ input.originRefKind ?? null, input.originCommit ?? null, input.originRepo ?? null, input.originManifestPath ?? null, input.originSkillPath ?? null,
157
+ input.originDigest ?? null, input.source === "code" ? null : now, input.sourceId ?? null, input.remoteSha256 ?? null,
158
+ input.source === "managed" ? now : null, input.source === "managed" ? "ok" : null, null, now, now
159
+ ]);
160
+ await replaceSkillFiles(control, idValue, input.package.files);
161
+ return (await findAgentSkill(control, input.agentName, input.package.name));
162
+ }
163
+ export function resolveAgentSkillCreationMode(mode, ephemeral) {
164
+ const resolved = mode === "include" ? "include" : mode === "available" ? "available" : ephemeral ? "include" : "available";
165
+ assertSkillDurability(ephemeral, resolved);
166
+ return resolved;
167
+ }
168
+ export async function editAgentSkill(control, input) {
169
+ const row = await requiredSkill(control, input.agentName, input.name);
170
+ assertEditable(row, input.actorKind, input.agentName);
171
+ assertRevision(row, input.expectedRevision);
172
+ let guidance = row.guidance;
173
+ if (input.replaceGuidance !== undefined)
174
+ guidance = input.replaceGuidance;
175
+ else if (input.findText !== undefined)
176
+ guidance = replaceExactlyOnce(guidance, input.findText, input.replaceWith ?? "");
177
+ assertGuidanceBytes(guidance, input.maxGuidanceBytes ?? raybaseAgentSkillStoreLimits.maxGuidanceBytesCap);
178
+ const description = input.description ?? row.description;
179
+ if (!description.trim())
180
+ throw skillError("validation", "Skill description cannot be empty");
181
+ const mode = input.mode ?? row.mode;
182
+ const ephemeral = input.ephemeral === undefined ? row.ephemeral === 1 : input.ephemeral;
183
+ assertSkillDurability(ephemeral, mode);
184
+ const contentDigest = await computeEditedDigest(row, { title: input.title === undefined ? row.title : input.title, description, guidance, mode, ephemeral });
185
+ await mutateSkillWithCas(control, row, "edit", input.actorKind, input.actor, [{ sql: `UPDATE ${q("_agent_skills")} SET "title"=?,"description"=?,"guidance"=?,"mode"=?,"ephemeral"=?,"contentDigest"=?,"revision"=?,"updatedAt"=? WHERE "id"=? AND "revision"=?`, params: [
186
+ input.title === undefined ? row.title : input.title, description, guidance, mode, ephemeral ? 1 : 0, contentDigest, row.revision + 1, nowIso(), row.id, row.revision
187
+ ] }]);
188
+ return (await findAgentSkill(control, input.agentName, input.name));
189
+ }
190
+ export async function setAgentSkillEnabled(control, input) {
191
+ const row = await requiredSkill(control, input.agentName, input.name);
192
+ assertRevision(row, input.expectedRevision);
193
+ await mutateSkillWithCas(control, row, input.enabled ? "enable" : "disable", input.actorKind, input.actor, [{ sql: `UPDATE ${q("_agent_skills")} SET "enabled"=?,"revision"=?,"updatedAt"=? WHERE "id"=? AND "revision"=?`, params: [input.enabled ? 1 : 0, row.revision + 1, nowIso(), row.id, row.revision] }]);
194
+ return (await findAgentSkill(control, input.agentName, input.name));
195
+ }
196
+ export async function deleteAgentSkill(control, input) {
197
+ const row = await requiredSkill(control, input.agentName, input.name);
198
+ assertEditable(row, input.actorKind, input.agentName);
199
+ assertRevision(row, input.expectedRevision);
200
+ await mutateSkillWithCas(control, row, "delete", input.actorKind, input.actor, [
201
+ { sql: `DELETE FROM ${q("_agent_skill_files")} WHERE "skillId"=?`, params: [row.id] },
202
+ { sql: `DELETE FROM ${q("_agent_skills")} WHERE "id"=? AND "revision"=?`, params: [row.id, row.revision] }
203
+ ]);
204
+ }
205
+ /**
206
+ * Delete the source before its dependents, with a transaction-local guard
207
+ * that aborts (rather than merely no-ops) when the source CAS has lost.
208
+ */
209
+ export async function removeManagedAgentSkillSource(control, input) {
210
+ const source = await control.first(`SELECT * FROM ${q("_agent_skill_sources")} WHERE "id"=?${input.agentName ? ' AND "agentName"=?' : ""} AND "registeredBy"='operator'`, input.agentName ? [input.sourceId, input.agentName] : [input.sourceId]);
211
+ if (!source)
212
+ throw new Error("Operator-owned managed source not found");
213
+ if (source.revision !== input.expectedRevision)
214
+ throw new Error("Managed source revision changed; refresh and retry");
215
+ if (!control.runTransaction)
216
+ throw new Error("Managed source removal requires transaction support");
217
+ const guardId = randomId("skill_source_cas_guard");
218
+ const now = nowIso();
219
+ const statements = [
220
+ // `id()` is not necessarily a NOT NULL SQLite primary key. Put the
221
+ // conditional value in a known-required column so a lost CAS aborts this
222
+ // transaction instead of merely producing a zero-row guard marker.
223
+ { sql: `INSERT INTO ${q("_agent_skill_revisions")} ("id","skillId","revision","title","description","guidance","mode","ephemeral","enabled","contentDigest","reason","actorKind","actor","createdAt") SELECT ?,?,?,?,CASE WHEN EXISTS (SELECT 1 FROM ${q("_agent_skill_sources")} WHERE "id"=? AND "revision"=? AND "registeredBy"='operator') THEN ? ELSE NULL END,?,?,?,?,?,?,?,?,?`, params: [guardId, input.sourceId, 0, null, input.sourceId, input.expectedRevision, "", "", "available", 0, 0, "", "source_cas_guard", "system", null, now] },
224
+ { sql: `DELETE FROM ${q("_agent_skill_sources")} WHERE "id"=? AND "revision"=? AND "registeredBy"='operator'`, params: [input.sourceId, input.expectedRevision] }
225
+ ];
226
+ if (input.deleteSkills) {
227
+ statements.push({ sql: `DELETE FROM ${q("_agent_skill_files")} WHERE "skillId" IN (SELECT "id" FROM ${q("_agent_skills")} WHERE "sourceId"=?)`, params: [input.sourceId] }, { sql: `DELETE FROM ${q("_agent_skills")} WHERE "sourceId"=?`, params: [input.sourceId] });
228
+ }
229
+ else {
230
+ statements.push({ sql: `UPDATE ${q("_agent_skills")} SET "enabled"=0,"syncStatus"='orphaned',"sourceId"=NULL,"revision"="revision"+1,"updatedAt"=? WHERE "sourceId"=?`, params: [now, input.sourceId] });
231
+ }
232
+ statements.push({ sql: `DELETE FROM ${q("_agent_skill_revisions")} WHERE "id"=?`, params: [guardId] });
233
+ try {
234
+ await control.runTransaction(statements);
235
+ }
236
+ catch (error) {
237
+ const current = await control.first(`SELECT * FROM ${q("_agent_skill_sources")} WHERE "id"=? AND "registeredBy"='operator'`, [input.sourceId]);
238
+ if (!current || current.revision !== input.expectedRevision)
239
+ throw new Error("Managed source revision changed; refresh and retry");
240
+ throw error;
241
+ }
242
+ }
243
+ export async function createAgentSkillUpload(control, input) {
244
+ if (input.bytes.byteLength > raybaseAgentSkillStoreLimits.uploadBytes)
245
+ throw skillError("upload_too_large", "Upload exceeds the 10 MiB limit");
246
+ const uploadId = randomId("skill_upload");
247
+ const sha256 = await sha256Hex(input.bytes);
248
+ const now = new Date();
249
+ const expiresAt = new Date(now.getTime() + raybaseAgentSkillStoreLimits.uploadTtlMs).toISOString();
250
+ await control.run(`INSERT INTO ${q("_agent_skill_uploads")} ("id","agentName","filename","contentBase64","bytes","sha256","createdByUserId","createdAt","expiresAt") VALUES (?,?,?,?,?,?,?,?,?)`, [
251
+ uploadId, input.agentName, input.filename, bytesToBase64(input.bytes), input.bytes.byteLength, sha256, input.createdByUserId ?? null, now.toISOString(), expiresAt
252
+ ]);
253
+ return { uploadId, sha256, bytes: input.bytes.byteLength, filename: input.filename, expiresAt };
254
+ }
255
+ export async function getAgentSkillUpload(control, agentName, uploadId) {
256
+ return control.first(`SELECT "id","filename","contentBase64","bytes","sha256","expiresAt" FROM ${q("_agent_skill_uploads")} WHERE "id"=? AND "agentName"=? LIMIT 1`, [uploadId, agentName]);
257
+ }
258
+ export async function sweepExpiredAgentSkillUploads(control, at = nowIso()) { await control.run(`DELETE FROM ${q("_agent_skill_uploads")} WHERE "expiresAt" <= ?`, [at]); }
259
+ export async function databaseAgentSkills(control, agentName) {
260
+ const rows = (await listAgentSkills(control, agentName)).filter((row) => row.enabled === 1);
261
+ const output = [];
262
+ for (const row of rows) {
263
+ const files = await listAgentSkillFiles(control, row.id);
264
+ output.push({
265
+ skill: { name: row.name, namespace: row.name, ...(row.title ? { title: row.title } : {}), description: row.description, guidance: row.guidance, ...(row.ephemeral === 1 ? { ephemeral: true } : {}), actions: [], files: files.map((file) => ({ path: file.path, content: file.content })) },
266
+ result: row.mode,
267
+ row
268
+ });
269
+ }
270
+ return output;
271
+ }
272
+ export async function reconcileAgentSkillStore(control, agent) {
273
+ if (!agentSkillStoreEnabled(agent))
274
+ return { managedSourceSyncNeeded: false };
275
+ let managedSourceSyncNeeded = false;
276
+ const registrations = agentSkillRegistrations(agent.skills, agent.name);
277
+ const declaredNames = new Set(registrations.map(({ skill }) => normalizeSkillName(skill.name)));
278
+ for (const { skill, mode: registrationMode } of registrations) {
279
+ const mode = registrationMode === "include" || registrationMode === "available"
280
+ ? registrationMode
281
+ : skill.ephemeral ? "include" : "available";
282
+ const contentDigest = await sha256Hex(stableJson({
283
+ name: skill.name,
284
+ title: skill.title ?? null,
285
+ description: skill.description ?? "",
286
+ guidance: skill.guidance ?? "",
287
+ mode,
288
+ ephemeral: skill.ephemeral === true,
289
+ maxChars: skill.maxChars ?? null,
290
+ onOverflow: skill.onOverflow ?? "truncate",
291
+ files: await Promise.all((skill.files ?? []).map(async (file) => ({ path: file.path, sha256: await sha256Hex(file.content) }))),
292
+ actions: skill.actions.map((action) => action.name).sort(),
293
+ limits: skill.limits ?? null
294
+ }));
295
+ const existing = await findAgentSkill(control, agent.name, skill.name);
296
+ if (existing?.source !== undefined && existing.source !== "code") {
297
+ console.warn(`Raybase agent ${agent.name} code skill ${skill.name} collides with a ${existing.source} database skill; the code registration wins and the database row is ignored`);
298
+ continue;
299
+ }
300
+ if (existing?.contentDigest === contentDigest && existing.syncStatus !== "orphaned")
301
+ continue;
302
+ const pkg = {
303
+ name: skill.name,
304
+ ...(skill.title ? { title: skill.title } : {}),
305
+ description: skill.description ?? "",
306
+ guidance: skill.guidance ?? "",
307
+ ephemeral: skill.ephemeral === true,
308
+ metadataJson: stableJson({ actions: skill.actions.map((action) => action.name), limits: skill.limits ?? null }),
309
+ files: await Promise.all((skill.files ?? []).map(async (file) => {
310
+ const bytes = new TextEncoder().encode(file.content);
311
+ return { path: file.path, kind: codeSkillFileKind(file.path), encoding: "utf8", content: file.content, bytes: bytes.byteLength, sha256: await sha256Hex(bytes) };
312
+ })),
313
+ contentDigest
314
+ };
315
+ if (existing) {
316
+ await captureSkillRevision(control, existing, "reconcile", "code", "defineAgent");
317
+ await control.run(`UPDATE ${q("_agent_skills")} SET "title"=?,"description"=?,"guidance"=?,"mode"=?,"ephemeral"=?,"contentDigest"=?,"metadataJson"=?,"syncStatus"=NULL,"syncError"=NULL,"revision"=?,"updatedAt"=? WHERE "id"=?`, [pkg.title ?? null, pkg.description, pkg.guidance, mode, pkg.ephemeral ? 1 : 0, pkg.contentDigest, pkg.metadataJson, existing.revision + 1, nowIso(), existing.id]);
318
+ await replaceSkillFiles(control, existing.id, pkg.files);
319
+ }
320
+ else {
321
+ await installAgentSkillPackage(control, { agentName: agent.name, package: pkg, source: "code", ownerKind: "code", createdBy: "defineAgent", originKind: "code", mode });
322
+ }
323
+ }
324
+ for (const row of await listAgentSkills(control, agent.name)) {
325
+ if (row.source === "code" && !declaredNames.has(row.normalizedName) && (row.enabled !== 0 || row.syncStatus !== "orphaned")) {
326
+ await captureSkillRevision(control, row, "reconcile", "code", "defineAgent");
327
+ await control.run(`UPDATE ${q("_agent_skills")} SET "enabled"=0,"syncStatus"='orphaned',"revision"=?,"updatedAt"=? WHERE "id"=?`, [row.revision + 1, nowIso(), row.id]);
328
+ }
329
+ }
330
+ const declaredSourceUrls = new Set();
331
+ for (const definition of agent.skillStore?.sources ?? []) {
332
+ declaredSourceUrls.add(definition.url);
333
+ const existing = await control.first(`SELECT * FROM ${q("_agent_skill_sources")} WHERE "agentName"=? AND "url"=? LIMIT 1`, [agent.name, definition.url]);
334
+ const syncEveryMs = definition.syncEveryMs ?? 6 * 60 * 60 * 1000;
335
+ const authSecretName = definition.authSecretName ?? null;
336
+ const allowedArtifactOriginsJson = stableJson(definition.allowedArtifactOrigins ?? []);
337
+ const artifactAuthJson = stableJson(definition.artifactAuth ?? []);
338
+ const selectionMode = definition.selection === "all" || definition.selection === undefined ? "all" : "named";
339
+ const selectedNamesJson = stableJson(Array.isArray(definition.selection) ? definition.selection : []);
340
+ if (existing) {
341
+ if (existing.registeredBy !== "code") {
342
+ console.warn(`Raybase agent ${agent.name} code-defined skill source ${definition.url} collides with an operator-owned source; the operator source remains authoritative`);
343
+ continue;
344
+ }
345
+ if (existing.enabled === 1
346
+ && existing.syncEveryMs === syncEveryMs
347
+ && existing.authSecretName === authSecretName
348
+ && existing.allowedArtifactOriginsJson === allowedArtifactOriginsJson
349
+ && existing.artifactAuthJson === artifactAuthJson
350
+ && existing.selectionMode === selectionMode
351
+ && existing.selectedNamesJson === selectedNamesJson) {
352
+ if (!existing.lastSyncAt)
353
+ managedSourceSyncNeeded = true;
354
+ continue;
355
+ }
356
+ await control.run(`UPDATE ${q("_agent_skill_sources")} SET "enabled"=1,"revision"="revision"+1,"syncEveryMs"=?,"authSecretName"=?,"allowedArtifactOriginsJson"=?,"artifactAuthJson"=?,"selectionMode"=?,"selectedNamesJson"=?,"updatedAt"=? WHERE "id"=? AND "revision"=? AND "registeredBy"='code'`, [syncEveryMs, authSecretName, allowedArtifactOriginsJson, artifactAuthJson, selectionMode, selectedNamesJson, nowIso(), existing.id, existing.revision]);
357
+ managedSourceSyncNeeded = true;
358
+ continue;
359
+ }
360
+ const now = nowIso();
361
+ await control.run(`INSERT INTO ${q("_agent_skill_sources")} ("id","agentName","sourceType","url","registeredBy","enabled","revision","syncEveryMs","authSecretName","allowedArtifactOriginsJson","artifactAuthJson","selectionMode","selectedNamesJson","createdAt","updatedAt") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, [randomId("skill_source"), agent.name, "http-index", definition.url, "code", 1, 1, syncEveryMs, authSecretName, allowedArtifactOriginsJson, artifactAuthJson, selectionMode, selectedNamesJson, now, now]);
362
+ managedSourceSyncNeeded = true;
363
+ }
364
+ for (const source of await control.all(`SELECT * FROM ${q("_agent_skill_sources")} WHERE "agentName"=? AND "registeredBy"='code'`, [agent.name])) {
365
+ if (declaredSourceUrls.has(source.url) || source.enabled === 0)
366
+ continue;
367
+ const now = nowIso();
368
+ if (!control.runTransaction)
369
+ throw new Error("Code-defined Agent Skill source removal requires transaction support");
370
+ await control.runTransaction([
371
+ { sql: `UPDATE ${q("_agent_skill_sources")} SET "enabled"=0,"revision"="revision"+1,"updatedAt"=? WHERE "id"=? AND "revision"=? AND "registeredBy"='code'`, params: [now, source.id, source.revision] },
372
+ { sql: `UPDATE ${q("_agent_skills")} SET "enabled"=0,"syncStatus"='orphaned',"revision"="revision"+1,"updatedAt"=? WHERE "sourceId"=? AND "source"='managed' AND EXISTS (SELECT 1 FROM ${q("_agent_skill_sources")} WHERE "id"=? AND "revision"=? AND "enabled"=0 AND "registeredBy"='code')`, params: [now, source.id, source.id, source.revision + 1] }
373
+ ]);
374
+ }
375
+ return { managedSourceSyncNeeded };
376
+ }
377
+ export function agentSkillStoreRuntimeTools(input) {
378
+ if (!agentSkillStoreEnabled(input.agent))
379
+ return [];
380
+ const signedIn = input.principal.kind !== "public";
381
+ const access = input.agent.skillStore?.agentAccess ?? {};
382
+ const excluded = new Set((input.resolvedTurn?.skills ?? []).filter(({ verdict }) => verdict === "excluded").map(({ skill }) => normalizeSkillName(skill.name)));
383
+ const visibleRows = async () => (await listAgentSkills(input.control, input.agent.name)).filter((row) => !excluded.has(row.normalizedName));
384
+ const visibleSkill = async (name) => {
385
+ const row = await requiredSkill(input.control, input.agent.name, name);
386
+ if (excluded.has(row.normalizedName))
387
+ throw skillError("not_found", `Skill ${name} was not found`);
388
+ return row;
389
+ };
390
+ const tools = [
391
+ tool("skill_list", "List installed skills", "List installed database-backed skills and their revisions.", {}, async () => (await visibleRows()).map(publicSkill)),
392
+ tool("skill_read", "Read skill metadata", "Read metadata, digest, and the supporting-file manifest for one installed skill. Use load_agent_skill for guidance and read_skill for files.", { name: { type: "string" } }, async (args) => {
393
+ const row = await visibleSkill(argString(args, "name"));
394
+ return { ...publicSkill(row), files: (await listAgentSkillFiles(input.control, row.id)).map(({ path, kind, bytes, sha256 }) => ({ path, kind, bytes, sha256 })), guidanceAccess: "Use load_agent_skill to load guidance and read_skill to read supporting files." };
395
+ })
396
+ ];
397
+ if (!signedIn)
398
+ return tools;
399
+ if (access.create)
400
+ tools.push(tool("skill_write", "Write skill", "Create an agent-owned local skill.", { name: { type: "string" }, description: { type: "string" }, guidance: { type: "string" }, title: { type: "string" }, mode: { type: "string", enum: ["include", "available"] }, ephemeral: { type: "boolean" } }, async (args) => {
401
+ const record = argRecord(args);
402
+ const name = validateOpenAgentSkillName(record.name);
403
+ const guidance = argString(args, "guidance");
404
+ const description = argString(args, "description");
405
+ const maxSkills = input.agent.skillStore?.limits?.maxSkills ?? raybaseAgentSkillStoreLimits.maxSkills;
406
+ const maxGuidanceBytes = input.agent.skillStore?.limits?.maxGuidanceBytes ?? raybaseAgentSkillStoreLimits.maxGuidanceBytes;
407
+ assertGuidanceBytes(guidance, maxGuidanceBytes);
408
+ if ((await listAgentSkills(input.control, input.agent.name)).length >= maxSkills)
409
+ throw skillError("skill_limit", `Agent skill limit of ${maxSkills} would be exceeded`);
410
+ const ephemeral = record.ephemeral === true;
411
+ const pkg = await inlinePackage(name, typeof record.title === "string" ? record.title : undefined, description, guidance, ephemeral);
412
+ const actor = principalActor(input.principal);
413
+ const mode = resolveAgentSkillCreationMode(record.mode, ephemeral);
414
+ const row = await installAgentSkillPackage(input.control, { agentName: input.agent.name, package: pkg, source: "local", ownerKind: "agent", ownerAgentName: input.agent.name, createdBy: actor, originKind: "inline", mode });
415
+ await auditSkill(input, "agent.skills.apply", row, { originKind: "inline" });
416
+ return publicSkill(row);
417
+ }, true));
418
+ if (access.edit)
419
+ tools.push(tool("skill_edit", "Edit skill", "CAS-edit one owned local skill.", { name: { type: "string" }, expectedRevision: { type: "integer" }, replaceGuidance: { type: "string" }, findText: { type: "string" }, replaceWith: { type: "string" }, title: { type: "string" }, description: { type: "string" }, mode: { type: "string", enum: ["include", "available"] }, ephemeral: { type: "boolean" } }, async (args) => {
420
+ const record = argRecord(args);
421
+ const row = await editAgentSkill(input.control, { agentName: input.agent.name, name: argString(args, "name"), expectedRevision: argRevision(args), actorKind: "agent", actor: principalActor(input.principal), title: typeof record.title === "string" ? record.title : undefined, description: typeof record.description === "string" ? record.description : undefined, mode: record.mode === "include" ? "include" : record.mode === "available" ? "available" : undefined, ephemeral: typeof record.ephemeral === "boolean" ? record.ephemeral : undefined, replaceGuidance: typeof record.replaceGuidance === "string" ? record.replaceGuidance : undefined, findText: typeof record.findText === "string" ? record.findText : undefined, replaceWith: typeof record.replaceWith === "string" ? record.replaceWith : undefined, maxGuidanceBytes: input.agent.skillStore?.limits?.maxGuidanceBytes ?? raybaseAgentSkillStoreLimits.maxGuidanceBytes });
422
+ await auditSkill(input, "agent.skills.edit", row, {});
423
+ return publicSkill(row);
424
+ }, true));
425
+ if (access.delete)
426
+ tools.push(tool("skill_delete", "Delete skill", "CAS-delete one owned local skill.", { name: { type: "string" }, expectedRevision: { type: "integer" } }, async (args) => { const name = argString(args, "name"); const revision = argRevision(args); const row = await requiredSkill(input.control, input.agent.name, name); await deleteAgentSkill(input.control, { agentName: input.agent.name, name, expectedRevision: revision, actorKind: "agent", actor: principalActor(input.principal) }); await auditSkill(input, "agent.skills.delete", row, {}); return { ok: true, name }; }, true));
427
+ if (access.setEnabled)
428
+ tools.push(tool("skill_set_enabled", "Set skill enabled", "CAS-toggle one installed skill from any source.", { name: { type: "string" }, enabled: { type: "boolean" }, expectedRevision: { type: "integer" } }, async (args) => { const record = argRecord(args); const row = await setAgentSkillEnabled(input.control, { agentName: input.agent.name, name: argString(args, "name"), enabled: record.enabled === true, expectedRevision: argRevision(args), actorKind: "agent", actor: principalActor(input.principal) }); await auditSkill(input, row.enabled ? "agent.skills.enable" : "agent.skills.disable", row, {}); return publicSkill(row); }, true));
429
+ return tools;
430
+ }
431
+ function replaceSkillFileStatements(skillId, files, createdAt = nowIso()) {
432
+ const statements = [{ sql: `DELETE FROM ${q("_agent_skill_files")} WHERE "skillId"=?`, params: [skillId] }];
433
+ for (const file of files)
434
+ statements.push({ sql: `INSERT INTO ${q("_agent_skill_files")} ("id","skillId","path","normalizedPath","kind","encoding","content","bytes","sha256","createdAt") VALUES (?,?,?,?,?,?,?,?,?,?)`, params: [randomId("skill_file"), skillId, file.path, normalizeSkillName(file.path), file.kind, file.encoding, file.content, file.bytes, file.sha256, createdAt] });
435
+ return statements;
436
+ }
437
+ async function replaceSkillFiles(control, skillId, files) {
438
+ const statements = replaceSkillFileStatements(skillId, files);
439
+ if (control.runTransaction)
440
+ await control.runTransaction(statements);
441
+ else
442
+ for (const statement of statements)
443
+ await control.run(statement.sql, statement.params);
444
+ }
445
+ async function captureSkillRevision(control, row, reason, actorKind, actor) {
446
+ await control.run(`INSERT INTO ${q("_agent_skill_revisions")} ("id","skillId","revision","title","description","guidance","mode","ephemeral","enabled","contentDigest","reason","actorKind","actor","createdAt") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, [randomId("skill_rev"), row.id, row.revision, row.title, row.description, row.guidance, row.mode, row.ephemeral, row.enabled, row.contentDigest, reason, actorKind, actor, nowIso()]);
447
+ await control.run(`DELETE FROM ${q("_agent_skill_revisions")} WHERE "skillId"=? AND "id" NOT IN (SELECT "id" FROM ${q("_agent_skill_revisions")} WHERE "skillId"=? ORDER BY "createdAt" DESC LIMIT ?)`, [row.id, row.id, raybaseAgentSkillStoreLimits.revisionsPerSkill]);
448
+ }
449
+ /** A conditional snapshot is the CAS success marker and captures only the state actually replaced. */
450
+ async function mutateSkillWithCas(control, row, reason, actorKind, actor, mutation) {
451
+ if (!control.runTransaction)
452
+ throw new Error("Agent Skill mutation requires transaction support");
453
+ const revisionId = randomId("skill_rev");
454
+ const guardId = randomId("skill_cas_guard");
455
+ try {
456
+ await control.runTransaction([
457
+ { sql: `DELETE FROM ${q("_agent_skill_revisions")} WHERE "skillId"=? AND "id" NOT IN (SELECT "id" FROM ${q("_agent_skill_revisions")} WHERE "skillId"=? ORDER BY "createdAt" DESC LIMIT ?)`, params: [row.id, row.id, raybaseAgentSkillStoreLimits.revisionsPerSkill - 1] },
458
+ // Use a scalar EXISTS rather than SELECTing from the row: the latter
459
+ // silently writes zero rows when stale. `description` is required, so
460
+ // the NULL branch forces SQLite to roll back the whole transaction.
461
+ { sql: `INSERT INTO ${q("_agent_skill_revisions")} ("id","skillId","revision","title","description","guidance","mode","ephemeral","enabled","contentDigest","reason","actorKind","actor","createdAt") SELECT ?,?,?,?,CASE WHEN EXISTS (SELECT 1 FROM ${q("_agent_skills")} WHERE "id"=? AND "revision"=?) THEN ? ELSE NULL END,?,?,?,?,?,?,?,?,?`, params: [guardId, row.id, 0, null, row.id, row.revision, "", "", "available", 0, 0, "", "cas_guard", "system", null, nowIso()] },
462
+ { sql: `INSERT INTO ${q("_agent_skill_revisions")} ("id","skillId","revision","title","description","guidance","mode","ephemeral","enabled","contentDigest","reason","actorKind","actor","createdAt") SELECT ?,"id","revision","title","description","guidance","mode","ephemeral","enabled","contentDigest",?,?,?,? FROM ${q("_agent_skills")} WHERE "id"=? AND "revision"=?`, params: [revisionId, reason, actorKind, actor, nowIso(), row.id, row.revision] },
463
+ ...mutation,
464
+ { sql: `DELETE FROM ${q("_agent_skill_revisions")} WHERE "id"=?`, params: [guardId] }
465
+ ]);
466
+ }
467
+ catch (error) {
468
+ const current = await findAgentSkill(control, row.agentName, row.name);
469
+ if (!current || current.revision !== row.revision)
470
+ throw staleRevision(current ?? row);
471
+ throw error;
472
+ }
473
+ const marker = await control.first(`SELECT "id" FROM ${q("_agent_skill_revisions")} WHERE "id"=?`, [revisionId]);
474
+ if (!marker) {
475
+ const current = await findAgentSkill(control, row.agentName, row.name);
476
+ throw staleRevision(current ?? row);
477
+ }
478
+ }
479
+ function assertRevision(row, expected) { if (!Number.isInteger(expected) || expected !== row.revision)
480
+ throw staleRevision(row); }
481
+ function staleRevision(row) { return skillError("stale_revision", `Skill ${row.name} changed since it was read`, { currentRevision: row.revision, updatedAt: row.updatedAt }); }
482
+ function assertEditable(row, actorKind, agentName) { if (row.source !== "local")
483
+ throw skillError("ownership", `${row.source} skill ${row.name} cannot be edited directly`); if (actorKind === "agent")
484
+ assertAgentOwned(row, agentName); }
485
+ function assertAgentOwned(row, agentName) { if (row.ownerKind !== "agent" || row.ownerAgentName !== agentName || row.source !== "local")
486
+ throw skillError("ownership", `Skill ${row.name} is not owned by agent ${agentName}`); }
487
+ async function requiredSkill(control, agentName, name) { const row = await findAgentSkill(control, agentName, name); if (!row)
488
+ throw skillError("not_found", `Skill ${name} was not found`); return row; }
489
+ function replaceExactlyOnce(body, find, replacement) { const first = body.indexOf(find); if (first < 0)
490
+ throw skillError("not_found", "Skill edit text was not found"); if (body.indexOf(find, first + Math.max(1, find.length)) >= 0)
491
+ throw skillError("ambiguous_edit", "Skill edit text occurs more than once"); return body.slice(0, first) + replacement + body.slice(first + find.length); }
492
+ async function computeEditedDigest(row, value) { return sha256Hex(stableJson({ name: row.name, ...value, metadataJson: row.metadataJson })); }
493
+ function normalizeSkillName(value) { return value.normalize("NFC").toLocaleLowerCase("en-US"); }
494
+ function boundedConfigLimit(agentName, field, value, cap) { if (value !== undefined && (!Number.isInteger(value) || value < 1 || value > cap))
495
+ throw new Error(`Raybase agent ${agentName} skillStore.limits.${field} must be an integer between 1 and ${cap}`); }
496
+ function assertGuidanceBytes(guidance, maxBytes) { const bytes = new TextEncoder().encode(guidance).byteLength; if (bytes > maxBytes)
497
+ throw skillError("guidance_too_large", `Skill guidance exceeds ${maxBytes} bytes`, { bytes, maxBytes }); }
498
+ function assertSkillDurability(ephemeral, mode) { if (ephemeral && mode === "available")
499
+ throw skillError("invalid_durability", "Ephemeral Agent Skills must use include mode"); }
500
+ function codeSkillFileKind(path) { const head = path.split("/", 1)[0]; return head === "references" ? "reference" : head === "assets" ? "asset" : head === "scripts" ? "script" : "other"; }
501
+ function skillError(code, message, details) { return new RaybaseActionError(message, { code, retryable: code === "stale_revision" || code === "ambiguous_edit" || code === "not_found", ...details }); }
502
+ function publicSkill(row) { return { name: row.name, title: row.title, description: row.description, source: row.source, mode: row.mode, ephemeral: row.ephemeral === 1, enabled: row.enabled === 1, revision: row.revision, contentDigest: row.contentDigest, ownerKind: row.ownerKind, syncStatus: row.syncStatus, updatedAt: row.updatedAt }; }
503
+ function argRecord(value) { return value && typeof value === "object" && !Array.isArray(value) ? value : {}; }
504
+ function argString(value, key) { const item = argRecord(value)[key]; if (typeof item !== "string" || !item.trim())
505
+ throw skillError("validation", `${key} is required`); return item.trim(); }
506
+ function argRevision(value) { const item = argRecord(value).expectedRevision; if (!Number.isInteger(item))
507
+ throw skillError("validation", "expectedRevision must be an integer"); return item; }
508
+ function principalActor(principal) { return principal.kind === "public" ? `public:${principal.id}` : principal.user.id; }
509
+ function tool(name, displayName, description, properties, run, dataChange = false) { return { name, displayName, description, parameters: { type: "object", properties, additionalProperties: false }, dataChange: dataChange ? { actionName: name, effects: ["agent-skills"] } : null, run }; }
510
+ async function inlinePackage(name, title, description, guidance, ephemeral = false) { const metadataJson = "{}"; const contentDigest = await sha256Hex(stableJson({ name, title, description, guidance, ephemeral, metadataJson })); return { name, ...(title ? { title } : {}), description, guidance, ephemeral, metadataJson, files: [], contentDigest }; }
511
+ async function auditSkill(input, action, row, metadata) { await recordAudit(input.control, { actor: input.principal, action, target: { type: "_agent_skills", id: row.id }, metadata: { agentName: input.agent.name, name: row.name, revision: row.revision, contentDigest: row.contentDigest, conversationId: input.conversationId, runId: input.runId, ...metadata } }); }
512
+ function bytesToBase64(bytes) { let binary = ""; for (let offset = 0; offset < bytes.length; offset += 0x8000)
513
+ binary += String.fromCharCode(...bytes.subarray(offset, offset + 0x8000)); return btoa(binary); }
514
+ //# sourceMappingURL=agent-skill-store.js.map