@evermore.work/shared 2026.509.0-canary.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 (373) hide show
  1. package/dist/adapter-type.d.ts +4 -0
  2. package/dist/adapter-type.d.ts.map +1 -0
  3. package/dist/adapter-type.js +14 -0
  4. package/dist/adapter-type.js.map +1 -0
  5. package/dist/adapter-types.test.d.ts +2 -0
  6. package/dist/adapter-types.test.d.ts.map +1 -0
  7. package/dist/adapter-types.test.js +46 -0
  8. package/dist/adapter-types.test.js.map +1 -0
  9. package/dist/agent-url-key.d.ts +4 -0
  10. package/dist/agent-url-key.d.ts.map +1 -0
  11. package/dist/agent-url-key.js +22 -0
  12. package/dist/agent-url-key.js.map +1 -0
  13. package/dist/api.d.ts +23 -0
  14. package/dist/api.d.ts.map +1 -0
  15. package/dist/api.js +23 -0
  16. package/dist/api.js.map +1 -0
  17. package/dist/config-schema.d.ts +725 -0
  18. package/dist/config-schema.d.ts.map +1 -0
  19. package/dist/config-schema.js +160 -0
  20. package/dist/config-schema.js.map +1 -0
  21. package/dist/constants.d.ts +323 -0
  22. package/dist/constants.d.ts.map +1 -0
  23. package/dist/constants.js +761 -0
  24. package/dist/constants.js.map +1 -0
  25. package/dist/environment-support.d.ts +37 -0
  26. package/dist/environment-support.d.ts.map +1 -0
  27. package/dist/environment-support.js +92 -0
  28. package/dist/environment-support.js.map +1 -0
  29. package/dist/environment-support.test.d.ts +2 -0
  30. package/dist/environment-support.test.d.ts.map +1 -0
  31. package/dist/environment-support.test.js +11 -0
  32. package/dist/environment-support.test.js.map +1 -0
  33. package/dist/execution-workspace-guards.d.ts +6 -0
  34. package/dist/execution-workspace-guards.d.ts.map +1 -0
  35. package/dist/execution-workspace-guards.js +12 -0
  36. package/dist/execution-workspace-guards.js.map +1 -0
  37. package/dist/index.d.ts +23 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +21 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/issue-references.d.ts +16 -0
  42. package/dist/issue-references.d.ts.map +1 -0
  43. package/dist/issue-references.js +160 -0
  44. package/dist/issue-references.js.map +1 -0
  45. package/dist/issue-references.test.d.ts +2 -0
  46. package/dist/issue-references.test.d.ts.map +1 -0
  47. package/dist/issue-references.test.js +56 -0
  48. package/dist/issue-references.test.js.map +1 -0
  49. package/dist/issue-thread-interactions.test.d.ts +2 -0
  50. package/dist/issue-thread-interactions.test.d.ts.map +1 -0
  51. package/dist/issue-thread-interactions.test.js +118 -0
  52. package/dist/issue-thread-interactions.test.js.map +1 -0
  53. package/dist/network-bind.d.ts +27 -0
  54. package/dist/network-bind.d.ts.map +1 -0
  55. package/dist/network-bind.js +75 -0
  56. package/dist/network-bind.js.map +1 -0
  57. package/dist/project-mentions.d.ts +32 -0
  58. package/dist/project-mentions.d.ts.map +1 -0
  59. package/dist/project-mentions.js +210 -0
  60. package/dist/project-mentions.js.map +1 -0
  61. package/dist/project-mentions.test.d.ts +2 -0
  62. package/dist/project-mentions.test.d.ts.map +1 -0
  63. package/dist/project-mentions.test.js +36 -0
  64. package/dist/project-mentions.test.js.map +1 -0
  65. package/dist/project-url-key.d.ts +5 -0
  66. package/dist/project-url-key.d.ts.map +1 -0
  67. package/dist/project-url-key.js +39 -0
  68. package/dist/project-url-key.js.map +1 -0
  69. package/dist/routine-variables.d.ts +21 -0
  70. package/dist/routine-variables.d.ts.map +1 -0
  71. package/dist/routine-variables.js +91 -0
  72. package/dist/routine-variables.js.map +1 -0
  73. package/dist/routine-variables.test.d.ts +2 -0
  74. package/dist/routine-variables.test.d.ts.map +1 -0
  75. package/dist/routine-variables.test.js +58 -0
  76. package/dist/routine-variables.test.js.map +1 -0
  77. package/dist/telemetry/client.d.ts +18 -0
  78. package/dist/telemetry/client.d.ts.map +1 -0
  79. package/dist/telemetry/client.js +105 -0
  80. package/dist/telemetry/client.js.map +1 -0
  81. package/dist/telemetry/config.d.ts +5 -0
  82. package/dist/telemetry/config.d.ts.map +1 -0
  83. package/dist/telemetry/config.js +21 -0
  84. package/dist/telemetry/config.js.map +1 -0
  85. package/dist/telemetry/events.d.ts +41 -0
  86. package/dist/telemetry/events.d.ts.map +1 -0
  87. package/dist/telemetry/events.js +59 -0
  88. package/dist/telemetry/events.js.map +1 -0
  89. package/dist/telemetry/index.d.ts +6 -0
  90. package/dist/telemetry/index.d.ts.map +1 -0
  91. package/dist/telemetry/index.js +5 -0
  92. package/dist/telemetry/index.js.map +1 -0
  93. package/dist/telemetry/state.d.ts +3 -0
  94. package/dist/telemetry/state.d.ts.map +1 -0
  95. package/dist/telemetry/state.js +28 -0
  96. package/dist/telemetry/state.js.map +1 -0
  97. package/dist/telemetry/types.d.ts +28 -0
  98. package/dist/telemetry/types.d.ts.map +1 -0
  99. package/dist/telemetry/types.js +2 -0
  100. package/dist/telemetry/types.js.map +1 -0
  101. package/dist/types/access.d.ts +142 -0
  102. package/dist/types/access.d.ts.map +1 -0
  103. package/dist/types/access.js +2 -0
  104. package/dist/types/access.js.map +1 -0
  105. package/dist/types/activity.d.ts +14 -0
  106. package/dist/types/activity.d.ts.map +1 -0
  107. package/dist/types/activity.js +2 -0
  108. package/dist/types/activity.js.map +1 -0
  109. package/dist/types/adapter-skills.d.ts +31 -0
  110. package/dist/types/adapter-skills.d.ts.map +1 -0
  111. package/dist/types/adapter-skills.js +2 -0
  112. package/dist/types/adapter-skills.js.map +1 -0
  113. package/dist/types/agent.d.ts +117 -0
  114. package/dist/types/agent.d.ts.map +1 -0
  115. package/dist/types/agent.js +2 -0
  116. package/dist/types/agent.js.map +1 -0
  117. package/dist/types/approval.d.ts +26 -0
  118. package/dist/types/approval.d.ts.map +1 -0
  119. package/dist/types/approval.js +2 -0
  120. package/dist/types/approval.js.map +1 -0
  121. package/dist/types/asset.d.ts +16 -0
  122. package/dist/types/asset.d.ts.map +1 -0
  123. package/dist/types/asset.js +2 -0
  124. package/dist/types/asset.js.map +1 -0
  125. package/dist/types/budget.d.ts +86 -0
  126. package/dist/types/budget.d.ts.map +1 -0
  127. package/dist/types/budget.js +2 -0
  128. package/dist/types/budget.js.map +1 -0
  129. package/dist/types/company-portability.d.ts +298 -0
  130. package/dist/types/company-portability.d.ts.map +1 -0
  131. package/dist/types/company-portability.js +2 -0
  132. package/dist/types/company-portability.js.map +1 -0
  133. package/dist/types/company-skill.d.ts +140 -0
  134. package/dist/types/company-skill.d.ts.map +1 -0
  135. package/dist/types/company-skill.js +2 -0
  136. package/dist/types/company-skill.js.map +1 -0
  137. package/dist/types/company.d.ts +25 -0
  138. package/dist/types/company.d.ts.map +1 -0
  139. package/dist/types/company.js +2 -0
  140. package/dist/types/company.js.map +1 -0
  141. package/dist/types/cost.d.ts +120 -0
  142. package/dist/types/cost.d.ts.map +1 -0
  143. package/dist/types/cost.js +2 -0
  144. package/dist/types/cost.js.map +1 -0
  145. package/dist/types/dashboard.d.ts +36 -0
  146. package/dist/types/dashboard.d.ts.map +1 -0
  147. package/dist/types/dashboard.js +2 -0
  148. package/dist/types/dashboard.js.map +1 -0
  149. package/dist/types/environment.d.ts +73 -0
  150. package/dist/types/environment.d.ts.map +1 -0
  151. package/dist/types/environment.js +2 -0
  152. package/dist/types/environment.js.map +1 -0
  153. package/dist/types/feedback.d.ts +95 -0
  154. package/dist/types/feedback.d.ts.map +1 -0
  155. package/dist/types/feedback.js +7 -0
  156. package/dist/types/feedback.js.map +1 -0
  157. package/dist/types/finance.d.ts +57 -0
  158. package/dist/types/finance.d.ts.map +1 -0
  159. package/dist/types/finance.js +2 -0
  160. package/dist/types/finance.js.map +1 -0
  161. package/dist/types/goal.d.ts +14 -0
  162. package/dist/types/goal.d.ts.map +1 -0
  163. package/dist/types/goal.js +2 -0
  164. package/dist/types/goal.js.map +1 -0
  165. package/dist/types/heartbeat.d.ts +158 -0
  166. package/dist/types/heartbeat.d.ts.map +1 -0
  167. package/dist/types/heartbeat.js +2 -0
  168. package/dist/types/heartbeat.js.map +1 -0
  169. package/dist/types/inbox-dismissal.d.ts +10 -0
  170. package/dist/types/inbox-dismissal.d.ts.map +1 -0
  171. package/dist/types/inbox-dismissal.js +2 -0
  172. package/dist/types/inbox-dismissal.js.map +1 -0
  173. package/dist/types/index.d.ts +37 -0
  174. package/dist/types/index.d.ts.map +1 -0
  175. package/dist/types/index.js +3 -0
  176. package/dist/types/index.js.map +1 -0
  177. package/dist/types/instance.d.ts +63 -0
  178. package/dist/types/instance.d.ts.map +1 -0
  179. package/dist/types/instance.js +12 -0
  180. package/dist/types/instance.js.map +1 -0
  181. package/dist/types/issue-tree-control.d.ts +102 -0
  182. package/dist/types/issue-tree-control.d.ts.map +1 -0
  183. package/dist/types/issue-tree-control.js +2 -0
  184. package/dist/types/issue-tree-control.js.map +1 -0
  185. package/dist/types/issue.d.ts +527 -0
  186. package/dist/types/issue.d.ts.map +1 -0
  187. package/dist/types/issue.js +2 -0
  188. package/dist/types/issue.js.map +1 -0
  189. package/dist/types/live.d.ts +9 -0
  190. package/dist/types/live.d.ts.map +1 -0
  191. package/dist/types/live.js +2 -0
  192. package/dist/types/live.js.map +1 -0
  193. package/dist/types/plugin.d.ts +686 -0
  194. package/dist/types/plugin.d.ts.map +1 -0
  195. package/dist/types/plugin.js +2 -0
  196. package/dist/types/plugin.js.map +1 -0
  197. package/dist/types/project.d.ts +82 -0
  198. package/dist/types/project.d.ts.map +1 -0
  199. package/dist/types/project.js +2 -0
  200. package/dist/types/project.js.map +1 -0
  201. package/dist/types/quota.d.ts +26 -0
  202. package/dist/types/quota.d.ts.map +1 -0
  203. package/dist/types/quota.js +2 -0
  204. package/dist/types/quota.js.map +1 -0
  205. package/dist/types/routine.d.ts +185 -0
  206. package/dist/types/routine.d.ts.map +1 -0
  207. package/dist/types/routine.js +2 -0
  208. package/dist/types/routine.js.map +1 -0
  209. package/dist/types/search.d.ts +50 -0
  210. package/dist/types/search.d.ts.map +1 -0
  211. package/dist/types/search.js +2 -0
  212. package/dist/types/search.js.map +1 -0
  213. package/dist/types/secrets.d.ts +32 -0
  214. package/dist/types/secrets.d.ts.map +1 -0
  215. package/dist/types/secrets.js +2 -0
  216. package/dist/types/secrets.js.map +1 -0
  217. package/dist/types/sidebar-badges.d.ts +7 -0
  218. package/dist/types/sidebar-badges.d.ts.map +1 -0
  219. package/dist/types/sidebar-badges.js +2 -0
  220. package/dist/types/sidebar-badges.js.map +1 -0
  221. package/dist/types/sidebar-preferences.d.ts +5 -0
  222. package/dist/types/sidebar-preferences.d.ts.map +1 -0
  223. package/dist/types/sidebar-preferences.js +2 -0
  224. package/dist/types/sidebar-preferences.js.map +1 -0
  225. package/dist/types/user-profile.d.ts +81 -0
  226. package/dist/types/user-profile.d.ts.map +1 -0
  227. package/dist/types/user-profile.js +2 -0
  228. package/dist/types/user-profile.js.map +1 -0
  229. package/dist/types/work-product.d.ts +27 -0
  230. package/dist/types/work-product.d.ts.map +1 -0
  231. package/dist/types/work-product.js +2 -0
  232. package/dist/types/work-product.js.map +1 -0
  233. package/dist/types/workspace-operation.d.ts +26 -0
  234. package/dist/types/workspace-operation.d.ts.map +1 -0
  235. package/dist/types/workspace-operation.js +2 -0
  236. package/dist/types/workspace-operation.js.map +1 -0
  237. package/dist/types/workspace-runtime.d.ts +252 -0
  238. package/dist/types/workspace-runtime.d.ts.map +1 -0
  239. package/dist/types/workspace-runtime.js +2 -0
  240. package/dist/types/workspace-runtime.js.map +1 -0
  241. package/dist/validators/access.d.ts +333 -0
  242. package/dist/validators/access.d.ts.map +1 -0
  243. package/dist/validators/access.js +132 -0
  244. package/dist/validators/access.js.map +1 -0
  245. package/dist/validators/adapter-skills.d.ts +156 -0
  246. package/dist/validators/adapter-skills.d.ts.map +1 -0
  247. package/dist/validators/adapter-skills.js +48 -0
  248. package/dist/validators/adapter-skills.js.map +1 -0
  249. package/dist/validators/agent.d.ts +841 -0
  250. package/dist/validators/agent.d.ts.map +1 -0
  251. package/dist/validators/agent.js +115 -0
  252. package/dist/validators/agent.js.map +1 -0
  253. package/dist/validators/approval.d.ts +51 -0
  254. package/dist/validators/approval.d.ts.map +1 -0
  255. package/dist/validators/approval.js +22 -0
  256. package/dist/validators/approval.js.map +1 -0
  257. package/dist/validators/approval.test.d.ts +2 -0
  258. package/dist/validators/approval.test.d.ts.map +1 -0
  259. package/dist/validators/approval.test.js +25 -0
  260. package/dist/validators/approval.test.js.map +1 -0
  261. package/dist/validators/asset.d.ts +10 -0
  262. package/dist/validators/asset.d.ts.map +1 -0
  263. package/dist/validators/asset.js +11 -0
  264. package/dist/validators/asset.js.map +1 -0
  265. package/dist/validators/budget.d.ts +56 -0
  266. package/dist/validators/budget.d.ts.map +1 -0
  267. package/dist/validators/budget.js +27 -0
  268. package/dist/validators/budget.js.map +1 -0
  269. package/dist/validators/company-portability.d.ts +3453 -0
  270. package/dist/validators/company-portability.d.ts.map +1 -0
  271. package/dist/validators/company-portability.js +231 -0
  272. package/dist/validators/company-portability.js.map +1 -0
  273. package/dist/validators/company-skill.d.ts +797 -0
  274. package/dist/validators/company-skill.d.ts.map +1 -0
  275. package/dist/validators/company-skill.js +116 -0
  276. package/dist/validators/company-skill.js.map +1 -0
  277. package/dist/validators/company.d.ts +91 -0
  278. package/dist/validators/company.d.ts.map +1 -0
  279. package/dist/validators/company.js +43 -0
  280. package/dist/validators/company.js.map +1 -0
  281. package/dist/validators/cost.d.ts +92 -0
  282. package/dist/validators/cost.d.ts.map +1 -0
  283. package/dist/validators/cost.js +26 -0
  284. package/dist/validators/cost.js.map +1 -0
  285. package/dist/validators/environment.d.ts +72 -0
  286. package/dist/validators/environment.d.ts.map +1 -0
  287. package/dist/validators/environment.js +31 -0
  288. package/dist/validators/environment.js.map +1 -0
  289. package/dist/validators/execution-workspace.d.ts +586 -0
  290. package/dist/validators/execution-workspace.d.ts.map +1 -0
  291. package/dist/validators/execution-workspace.js +120 -0
  292. package/dist/validators/execution-workspace.js.map +1 -0
  293. package/dist/validators/feedback.d.ts +26 -0
  294. package/dist/validators/feedback.d.ts.map +1 -0
  295. package/dist/validators/feedback.js +14 -0
  296. package/dist/validators/feedback.js.map +1 -0
  297. package/dist/validators/finance.d.ts +129 -0
  298. package/dist/validators/finance.d.ts.map +1 -0
  299. package/dist/validators/finance.js +32 -0
  300. package/dist/validators/finance.js.map +1 -0
  301. package/dist/validators/goal.d.ts +48 -0
  302. package/dist/validators/goal.d.ts.map +1 -0
  303. package/dist/validators/goal.js +12 -0
  304. package/dist/validators/goal.js.map +1 -0
  305. package/dist/validators/index.d.ts +26 -0
  306. package/dist/validators/index.d.ts.map +1 -0
  307. package/dist/validators/index.js +26 -0
  308. package/dist/validators/index.js.map +1 -0
  309. package/dist/validators/instance.d.ts +137 -0
  310. package/dist/validators/instance.d.ts.map +1 -0
  311. package/dist/validators/instance.js +41 -0
  312. package/dist/validators/instance.js.map +1 -0
  313. package/dist/validators/issue-tree-control.d.ts +100 -0
  314. package/dist/validators/issue-tree-control.d.ts.map +1 -0
  315. package/dist/validators/issue-tree-control.js +31 -0
  316. package/dist/validators/issue-tree-control.js.map +1 -0
  317. package/dist/validators/issue.d.ts +4292 -0
  318. package/dist/validators/issue.d.ts.map +1 -0
  319. package/dist/validators/issue.js +506 -0
  320. package/dist/validators/issue.js.map +1 -0
  321. package/dist/validators/issue.test.d.ts +2 -0
  322. package/dist/validators/issue.test.d.ts.map +1 -0
  323. package/dist/validators/issue.test.js +203 -0
  324. package/dist/validators/issue.test.js.map +1 -0
  325. package/dist/validators/plugin.d.ts +2426 -0
  326. package/dist/validators/plugin.d.ts.map +1 -0
  327. package/dist/validators/plugin.js +837 -0
  328. package/dist/validators/plugin.js.map +1 -0
  329. package/dist/validators/plugin.test.d.ts +2 -0
  330. package/dist/validators/plugin.test.d.ts.map +1 -0
  331. package/dist/validators/plugin.test.js +64 -0
  332. package/dist/validators/plugin.test.js.map +1 -0
  333. package/dist/validators/project.d.ts +784 -0
  334. package/dist/validators/project.d.ts.map +1 -0
  335. package/dist/validators/project.js +102 -0
  336. package/dist/validators/project.js.map +1 -0
  337. package/dist/validators/routine.d.ts +920 -0
  338. package/dist/validators/routine.d.ts.map +1 -0
  339. package/dist/validators/routine.js +125 -0
  340. package/dist/validators/routine.js.map +1 -0
  341. package/dist/validators/routine.test.d.ts +2 -0
  342. package/dist/validators/routine.test.d.ts.map +1 -0
  343. package/dist/validators/routine.test.js +79 -0
  344. package/dist/validators/routine.test.js.map +1 -0
  345. package/dist/validators/search.d.ts +24 -0
  346. package/dist/validators/search.d.ts.map +1 -0
  347. package/dist/validators/search.js +33 -0
  348. package/dist/validators/search.js.map +1 -0
  349. package/dist/validators/secret.d.ts +114 -0
  350. package/dist/validators/secret.d.ts.map +1 -0
  351. package/dist/validators/secret.js +35 -0
  352. package/dist/validators/secret.js.map +1 -0
  353. package/dist/validators/sidebar-preferences.d.ts +20 -0
  354. package/dist/validators/sidebar-preferences.d.ts.map +1 -0
  355. package/dist/validators/sidebar-preferences.js +10 -0
  356. package/dist/validators/sidebar-preferences.js.map +1 -0
  357. package/dist/validators/text.d.ts +4 -0
  358. package/dist/validators/text.d.ts.map +1 -0
  359. package/dist/validators/text.js +9 -0
  360. package/dist/validators/text.js.map +1 -0
  361. package/dist/validators/work-product.d.ts +105 -0
  362. package/dist/validators/work-product.d.ts.map +1 -0
  363. package/dist/validators/work-product.js +46 -0
  364. package/dist/validators/work-product.js.map +1 -0
  365. package/dist/workspace-commands.d.ts +7 -0
  366. package/dist/workspace-commands.d.ts.map +1 -0
  367. package/dist/workspace-commands.js +150 -0
  368. package/dist/workspace-commands.js.map +1 -0
  369. package/dist/workspace-commands.test.d.ts +2 -0
  370. package/dist/workspace-commands.test.d.ts.map +1 -0
  371. package/dist/workspace-commands.test.js +65 -0
  372. package/dist/workspace-commands.test.js.map +1 -0
  373. package/package.json +47 -0
@@ -0,0 +1,837 @@
1
+ import { z } from "zod";
2
+ import { PLUGIN_STATUSES, PLUGIN_CATEGORIES, PLUGIN_CAPABILITIES, PLUGIN_UI_SLOT_TYPES, PLUGIN_UI_SLOT_ENTITY_TYPES, PLUGIN_RESERVED_COMPANY_ROUTE_SEGMENTS, PLUGIN_LAUNCHER_PLACEMENT_ZONES, PLUGIN_LAUNCHER_ACTIONS, PLUGIN_LAUNCHER_BOUNDS, PLUGIN_LAUNCHER_RENDER_ENVIRONMENTS, PLUGIN_STATE_SCOPE_KINDS, PLUGIN_DATABASE_CORE_READ_TABLES, PLUGIN_API_ROUTE_AUTH_MODES, PLUGIN_API_ROUTE_CHECKOUT_POLICIES, PLUGIN_API_ROUTE_METHODS, ISSUE_PRIORITIES, ROUTINE_CATCH_UP_POLICIES, ROUTINE_CONCURRENCY_POLICIES, ROUTINE_STATUSES, ROUTINE_TRIGGER_KINDS, ROUTINE_TRIGGER_SIGNING_MODES, ISSUE_SURFACE_VISIBILITIES, } from "../constants.js";
3
+ import { routineVariableSchema } from "./routine.js";
4
+ // ---------------------------------------------------------------------------
5
+ // JSON Schema placeholder – a permissive validator for JSON Schema objects
6
+ // ---------------------------------------------------------------------------
7
+ /**
8
+ * Permissive validator for JSON Schema objects. Accepts any `Record<string, unknown>`
9
+ * that contains at least a `type`, `$ref`, or composition keyword (`oneOf`/`anyOf`/`allOf`).
10
+ * Empty objects are also accepted.
11
+ *
12
+ * Used to validate `instanceConfigSchema` and `parametersSchema` fields in the
13
+ * plugin manifest without fully parsing JSON Schema.
14
+ *
15
+ * @see PLUGIN_SPEC.md §10.1 — Manifest shape
16
+ */
17
+ export const jsonSchemaSchema = z.record(z.unknown()).refine((val) => {
18
+ // Must have a "type" field if non-empty, or be a valid JSON Schema object
19
+ if (Object.keys(val).length === 0)
20
+ return true;
21
+ return typeof val.type === "string" || val.$ref !== undefined || val.oneOf !== undefined || val.anyOf !== undefined || val.allOf !== undefined;
22
+ }, { message: "Must be a valid JSON Schema object (requires at least a 'type', '$ref', or composition keyword)" });
23
+ // ---------------------------------------------------------------------------
24
+ // Manifest sub-type schemas
25
+ // ---------------------------------------------------------------------------
26
+ /**
27
+ * Validates a {@link PluginJobDeclaration} — a scheduled job declared in the
28
+ * plugin manifest. Requires `jobKey` and `displayName`; `description` and
29
+ * `schedule` (cron expression) are optional.
30
+ *
31
+ * @see PLUGIN_SPEC.md §17 — Scheduled Jobs
32
+ */
33
+ /**
34
+ * Validates a cron expression has exactly 5 whitespace-separated fields,
35
+ * each containing only valid cron characters (digits, *, /, -, ,).
36
+ *
37
+ * Valid tokens per field: *, N, N-M, N/S, * /S, N-M/S, and comma-separated lists.
38
+ */
39
+ const CRON_FIELD_PATTERN = /^(\*(?:\/[0-9]+)?|[0-9]+(?:-[0-9]+)?(?:\/[0-9]+)?)(?:,(\*(?:\/[0-9]+)?|[0-9]+(?:-[0-9]+)?(?:\/[0-9]+)?))*$/;
40
+ function isValidCronExpression(expression) {
41
+ const trimmed = expression.trim();
42
+ if (!trimmed)
43
+ return false;
44
+ const fields = trimmed.split(/\s+/);
45
+ if (fields.length !== 5)
46
+ return false;
47
+ return fields.every((f) => CRON_FIELD_PATTERN.test(f));
48
+ }
49
+ export const pluginJobDeclarationSchema = z.object({
50
+ jobKey: z.string().min(1),
51
+ displayName: z.string().min(1),
52
+ description: z.string().optional(),
53
+ schedule: z.string().refine((val) => isValidCronExpression(val), { message: "schedule must be a valid 5-field cron expression (e.g. '*/15 * * * *')" }).optional(),
54
+ });
55
+ /**
56
+ * Validates a {@link PluginWebhookDeclaration} — a webhook endpoint declared
57
+ * in the plugin manifest. Requires `endpointKey` and `displayName`.
58
+ *
59
+ * @see PLUGIN_SPEC.md §18 — Webhooks
60
+ */
61
+ export const pluginWebhookDeclarationSchema = z.object({
62
+ endpointKey: z.string().min(1),
63
+ displayName: z.string().min(1),
64
+ description: z.string().optional(),
65
+ });
66
+ /**
67
+ * Validates a {@link PluginToolDeclaration} — an agent tool contributed by the
68
+ * plugin. Requires `name`, `displayName`, `description`, and a valid
69
+ * `parametersSchema`. Requires the `agent.tools.register` capability.
70
+ *
71
+ * @see PLUGIN_SPEC.md §11 — Agent Tools
72
+ */
73
+ export const pluginToolDeclarationSchema = z.object({
74
+ name: z.string().min(1),
75
+ displayName: z.string().min(1),
76
+ description: z.string().min(1),
77
+ parametersSchema: jsonSchemaSchema,
78
+ });
79
+ export const pluginEnvironmentDriverDeclarationSchema = z.object({
80
+ driverKey: z.string().min(1).regex(/^[a-z0-9][a-z0-9._-]*$/, "Environment driver key must start with a lowercase alphanumeric and contain only lowercase letters, digits, dots, hyphens, or underscores"),
81
+ kind: z.enum(["environment_driver", "sandbox_provider"]).optional(),
82
+ displayName: z.string().min(1).max(100),
83
+ description: z.string().max(500).optional(),
84
+ configSchema: jsonSchemaSchema,
85
+ });
86
+ export const pluginManagedAgentDeclarationSchema = z.object({
87
+ agentKey: z.string().min(1).max(100).regex(/^[a-z0-9][a-z0-9._:-]*$/, {
88
+ message: "agentKey must start with a lowercase alphanumeric and contain only lowercase letters, digits, dots, colons, underscores, or hyphens",
89
+ }),
90
+ displayName: z.string().min(1).max(100),
91
+ role: z.string().min(1).max(100).optional(),
92
+ title: z.string().max(200).nullable().optional(),
93
+ icon: z.string().max(100).nullable().optional(),
94
+ capabilities: z.string().max(2000).nullable().optional(),
95
+ adapterType: z.string().min(1).max(100).optional(),
96
+ adapterPreference: z.array(z.string().min(1).max(100)).max(10).optional(),
97
+ adapterConfig: z.record(z.unknown()).optional(),
98
+ runtimeConfig: z.record(z.unknown()).optional(),
99
+ permissions: z.record(z.unknown()).optional(),
100
+ status: z.enum(["idle", "paused"]).optional(),
101
+ budgetMonthlyCents: z.number().int().min(0).optional(),
102
+ instructions: z.object({
103
+ entryFile: z.string().min(1).max(200).optional(),
104
+ content: z.string().max(200_000).optional(),
105
+ assetPath: z.string().min(1).max(500).optional(),
106
+ }).optional(),
107
+ });
108
+ export const pluginManagedProjectDeclarationSchema = z.object({
109
+ projectKey: z.string().min(1).max(100).regex(/^[a-z0-9][a-z0-9._:-]*$/, {
110
+ message: "projectKey must start with a lowercase alphanumeric and contain only lowercase letters, digits, dots, colons, underscores, or hyphens",
111
+ }),
112
+ displayName: z.string().min(1).max(120),
113
+ description: z.string().max(2000).nullable().optional(),
114
+ status: z.enum(["backlog", "planned", "in_progress", "completed", "cancelled"]).optional(),
115
+ color: z.string().max(32).nullable().optional(),
116
+ settings: z.record(z.unknown()).optional(),
117
+ });
118
+ const pluginManagedResourceRefSchema = z.object({
119
+ pluginKey: z.string().min(1).max(100).optional(),
120
+ resourceKind: z.enum(["agent", "project", "routine"]),
121
+ resourceKey: z.string().min(1).max(100).regex(/^[a-z0-9][a-z0-9._:-]*$/, {
122
+ message: "resourceKey must start with a lowercase alphanumeric and contain only lowercase letters, digits, dots, colons, underscores, or hyphens",
123
+ }),
124
+ });
125
+ export const pluginManagedRoutineDeclarationSchema = z.object({
126
+ routineKey: z.string().min(1).max(100).regex(/^[a-z0-9][a-z0-9._:-]*$/, {
127
+ message: "routineKey must start with a lowercase alphanumeric and contain only lowercase letters, digits, dots, colons, underscores, or hyphens",
128
+ }),
129
+ title: z.string().trim().min(1).max(200),
130
+ description: z.string().max(10_000).nullable().optional(),
131
+ assigneeRef: pluginManagedResourceRefSchema.extend({ resourceKind: z.literal("agent") }).nullable().optional(),
132
+ projectRef: pluginManagedResourceRefSchema.extend({ resourceKind: z.literal("project") }).nullable().optional(),
133
+ goalId: z.string().uuid().nullable().optional(),
134
+ status: z.enum(ROUTINE_STATUSES).optional(),
135
+ priority: z.enum(ISSUE_PRIORITIES).optional(),
136
+ concurrencyPolicy: z.enum(ROUTINE_CONCURRENCY_POLICIES).optional(),
137
+ catchUpPolicy: z.enum(ROUTINE_CATCH_UP_POLICIES).optional(),
138
+ variables: z.array(routineVariableSchema).optional(),
139
+ triggers: z.array(z.object({
140
+ kind: z.enum(ROUTINE_TRIGGER_KINDS),
141
+ label: z.string().trim().max(120).nullable().optional(),
142
+ enabled: z.boolean().optional(),
143
+ cronExpression: z.string().trim().min(1).optional().nullable(),
144
+ timezone: z.string().trim().min(1).optional().nullable(),
145
+ signingMode: z.enum(ROUTINE_TRIGGER_SIGNING_MODES).optional().nullable(),
146
+ replayWindowSec: z.number().int().min(30).max(86_400).optional().nullable(),
147
+ })).max(20).optional(),
148
+ issueTemplate: z.object({
149
+ surfaceVisibility: z.enum(ISSUE_SURFACE_VISIBILITIES).optional(),
150
+ originId: z.string().trim().max(255).nullable().optional(),
151
+ billingCode: z.string().trim().max(200).nullable().optional(),
152
+ }).optional(),
153
+ });
154
+ const pluginLocalFolderRelativePathSchema = z.string().min(1).max(500).refine((value) => !value.startsWith("/") &&
155
+ !value.includes("..") &&
156
+ !value.includes("\\") &&
157
+ !value.split("/").some((segment) => segment === "" || segment === "."), { message: "local folder paths must be relative paths without traversal, empty segments, or backslashes" });
158
+ export const pluginLocalFolderDeclarationSchema = z.object({
159
+ folderKey: z.string().min(1).max(100).regex(/^[a-z0-9][a-z0-9._:-]*$/, {
160
+ message: "folderKey must start with a lowercase alphanumeric and contain only lowercase letters, digits, dots, colons, underscores, or hyphens",
161
+ }),
162
+ displayName: z.string().min(1).max(100),
163
+ description: z.string().max(500).optional(),
164
+ access: z.enum(["read", "readWrite"]).optional(),
165
+ requiredDirectories: z.array(pluginLocalFolderRelativePathSchema).optional(),
166
+ requiredFiles: z.array(pluginLocalFolderRelativePathSchema).optional(),
167
+ });
168
+ /**
169
+ * Validates a {@link PluginUiSlotDeclaration} — a UI extension slot the plugin
170
+ * fills with a React component. Includes `superRefine` checks for slot-specific
171
+ * requirements such as `entityTypes` for context-sensitive slots.
172
+ *
173
+ * @see PLUGIN_SPEC.md §19 — UI Extension Model
174
+ */
175
+ export const pluginUiSlotDeclarationSchema = z.object({
176
+ type: z.enum(PLUGIN_UI_SLOT_TYPES),
177
+ id: z.string().min(1),
178
+ displayName: z.string().min(1),
179
+ exportName: z.string().min(1),
180
+ entityTypes: z.array(z.enum(PLUGIN_UI_SLOT_ENTITY_TYPES)).optional(),
181
+ routePath: z.string().regex(/^[a-z0-9][a-z0-9-]*$/, {
182
+ message: "routePath must be a lowercase single-segment slug (letters, numbers, hyphens)",
183
+ }).optional(),
184
+ order: z.number().int().optional(),
185
+ }).superRefine((value, ctx) => {
186
+ // context-sensitive slots require explicit entity targeting.
187
+ const entityScopedTypes = ["detailTab", "taskDetailView", "contextMenuItem", "commentAnnotation", "commentContextMenuItem", "projectSidebarItem"];
188
+ if (entityScopedTypes.includes(value.type)
189
+ && (!value.entityTypes || value.entityTypes.length === 0)) {
190
+ ctx.addIssue({
191
+ code: z.ZodIssueCode.custom,
192
+ message: `${value.type} slots require at least one entityType`,
193
+ path: ["entityTypes"],
194
+ });
195
+ }
196
+ // projectSidebarItem only makes sense for entityType "project".
197
+ if (value.type === "projectSidebarItem" && value.entityTypes && !value.entityTypes.includes("project")) {
198
+ ctx.addIssue({
199
+ code: z.ZodIssueCode.custom,
200
+ message: "projectSidebarItem slots require entityTypes to include \"project\"",
201
+ path: ["entityTypes"],
202
+ });
203
+ }
204
+ // commentAnnotation only makes sense for entityType "comment".
205
+ if (value.type === "commentAnnotation" && value.entityTypes && !value.entityTypes.includes("comment")) {
206
+ ctx.addIssue({
207
+ code: z.ZodIssueCode.custom,
208
+ message: "commentAnnotation slots require entityTypes to include \"comment\"",
209
+ path: ["entityTypes"],
210
+ });
211
+ }
212
+ // commentContextMenuItem only makes sense for entityType "comment".
213
+ if (value.type === "commentContextMenuItem" && value.entityTypes && !value.entityTypes.includes("comment")) {
214
+ ctx.addIssue({
215
+ code: z.ZodIssueCode.custom,
216
+ message: "commentContextMenuItem slots require entityTypes to include \"comment\"",
217
+ path: ["entityTypes"],
218
+ });
219
+ }
220
+ if (value.routePath && value.type !== "page" && value.type !== "routeSidebar") {
221
+ ctx.addIssue({
222
+ code: z.ZodIssueCode.custom,
223
+ message: "routePath is only supported for page and routeSidebar slots",
224
+ path: ["routePath"],
225
+ });
226
+ }
227
+ if (value.type === "routeSidebar" && !value.routePath) {
228
+ ctx.addIssue({
229
+ code: z.ZodIssueCode.custom,
230
+ message: "routeSidebar slots require routePath",
231
+ path: ["routePath"],
232
+ });
233
+ }
234
+ if (value.routePath && PLUGIN_RESERVED_COMPANY_ROUTE_SEGMENTS.includes(value.routePath)) {
235
+ ctx.addIssue({
236
+ code: z.ZodIssueCode.custom,
237
+ message: `routePath "${value.routePath}" is reserved by the host`,
238
+ path: ["routePath"],
239
+ });
240
+ }
241
+ });
242
+ const entityScopedLauncherPlacementZones = [
243
+ "detailTab",
244
+ "taskDetailView",
245
+ "contextMenuItem",
246
+ "commentAnnotation",
247
+ "commentContextMenuItem",
248
+ "projectSidebarItem",
249
+ ];
250
+ const launcherBoundsByEnvironment = {
251
+ hostInline: ["inline", "compact", "default"],
252
+ hostOverlay: ["compact", "default", "wide", "full"],
253
+ hostRoute: ["default", "wide", "full"],
254
+ external: [],
255
+ iframe: ["compact", "default", "wide", "full"],
256
+ };
257
+ /**
258
+ * Validates the action payload for a declarative plugin launcher.
259
+ */
260
+ export const pluginLauncherActionDeclarationSchema = z.object({
261
+ type: z.enum(PLUGIN_LAUNCHER_ACTIONS),
262
+ target: z.string().min(1),
263
+ params: z.record(z.unknown()).optional(),
264
+ }).superRefine((value, ctx) => {
265
+ if (value.type === "performAction" && value.target.includes("/")) {
266
+ ctx.addIssue({
267
+ code: z.ZodIssueCode.custom,
268
+ message: "performAction launchers must target an action key, not a route or URL",
269
+ path: ["target"],
270
+ });
271
+ }
272
+ if (value.type === "navigate" && /^https?:\/\//.test(value.target)) {
273
+ ctx.addIssue({
274
+ code: z.ZodIssueCode.custom,
275
+ message: "navigate launchers must target a host route, not an absolute URL",
276
+ path: ["target"],
277
+ });
278
+ }
279
+ });
280
+ /**
281
+ * Validates optional render hints for a plugin launcher destination.
282
+ */
283
+ export const pluginLauncherRenderDeclarationSchema = z.object({
284
+ environment: z.enum(PLUGIN_LAUNCHER_RENDER_ENVIRONMENTS),
285
+ bounds: z.enum(PLUGIN_LAUNCHER_BOUNDS).optional(),
286
+ }).superRefine((value, ctx) => {
287
+ if (!value.bounds) {
288
+ return;
289
+ }
290
+ const supportedBounds = launcherBoundsByEnvironment[value.environment];
291
+ if (!supportedBounds.includes(value.bounds)) {
292
+ ctx.addIssue({
293
+ code: z.ZodIssueCode.custom,
294
+ message: `bounds "${value.bounds}" is not supported for render environment "${value.environment}"`,
295
+ path: ["bounds"],
296
+ });
297
+ }
298
+ });
299
+ /**
300
+ * Validates declarative launcher metadata in a plugin manifest.
301
+ */
302
+ export const pluginLauncherDeclarationSchema = z.object({
303
+ id: z.string().min(1),
304
+ displayName: z.string().min(1),
305
+ description: z.string().optional(),
306
+ placementZone: z.enum(PLUGIN_LAUNCHER_PLACEMENT_ZONES),
307
+ exportName: z.string().min(1).optional(),
308
+ entityTypes: z.array(z.enum(PLUGIN_UI_SLOT_ENTITY_TYPES)).optional(),
309
+ order: z.number().int().optional(),
310
+ action: pluginLauncherActionDeclarationSchema,
311
+ render: pluginLauncherRenderDeclarationSchema.optional(),
312
+ }).superRefine((value, ctx) => {
313
+ if (entityScopedLauncherPlacementZones.some((zone) => zone === value.placementZone)
314
+ && (!value.entityTypes || value.entityTypes.length === 0)) {
315
+ ctx.addIssue({
316
+ code: z.ZodIssueCode.custom,
317
+ message: `${value.placementZone} launchers require at least one entityType`,
318
+ path: ["entityTypes"],
319
+ });
320
+ }
321
+ if (value.placementZone === "projectSidebarItem"
322
+ && value.entityTypes
323
+ && !value.entityTypes.includes("project")) {
324
+ ctx.addIssue({
325
+ code: z.ZodIssueCode.custom,
326
+ message: "projectSidebarItem launchers require entityTypes to include \"project\"",
327
+ path: ["entityTypes"],
328
+ });
329
+ }
330
+ if (value.action.type === "performAction" && value.render) {
331
+ ctx.addIssue({
332
+ code: z.ZodIssueCode.custom,
333
+ message: "performAction launchers cannot declare render hints",
334
+ path: ["render"],
335
+ });
336
+ }
337
+ if (["openModal", "openDrawer", "openPopover"].includes(value.action.type)
338
+ && !value.render) {
339
+ ctx.addIssue({
340
+ code: z.ZodIssueCode.custom,
341
+ message: `${value.action.type} launchers require render metadata`,
342
+ path: ["render"],
343
+ });
344
+ }
345
+ if (value.action.type === "openModal" && value.render?.environment === "hostInline") {
346
+ ctx.addIssue({
347
+ code: z.ZodIssueCode.custom,
348
+ message: "openModal launchers cannot use the hostInline render environment",
349
+ path: ["render", "environment"],
350
+ });
351
+ }
352
+ if (value.action.type === "openDrawer"
353
+ && value.render
354
+ && !["hostOverlay", "iframe"].includes(value.render.environment)) {
355
+ ctx.addIssue({
356
+ code: z.ZodIssueCode.custom,
357
+ message: "openDrawer launchers must use hostOverlay or iframe render environments",
358
+ path: ["render", "environment"],
359
+ });
360
+ }
361
+ if (value.action.type === "openPopover" && value.render?.environment === "hostRoute") {
362
+ ctx.addIssue({
363
+ code: z.ZodIssueCode.custom,
364
+ message: "openPopover launchers cannot use the hostRoute render environment",
365
+ path: ["render", "environment"],
366
+ });
367
+ }
368
+ });
369
+ export const pluginDatabaseDeclarationSchema = z.object({
370
+ namespaceSlug: z.string().regex(/^[a-z0-9][a-z0-9_]*$/, {
371
+ message: "namespaceSlug must be lowercase letters, digits, or underscores and start with a letter or digit",
372
+ }).max(40).optional(),
373
+ migrationsDir: z.string().min(1).refine((value) => !value.startsWith("/") && !value.includes("..") && !/[\\]/.test(value), { message: "migrationsDir must be a relative package path without '..' or backslashes" }),
374
+ coreReadTables: z.array(z.enum(PLUGIN_DATABASE_CORE_READ_TABLES)).optional(),
375
+ });
376
+ export const pluginApiRouteDeclarationSchema = z.object({
377
+ routeKey: z.string().min(1).max(100).regex(/^[a-z0-9][a-z0-9._:-]*$/, {
378
+ message: "routeKey must be lowercase letters, digits, dots, colons, underscores, or hyphens",
379
+ }),
380
+ method: z.enum(PLUGIN_API_ROUTE_METHODS),
381
+ path: z.string().min(1).regex(/^\/[a-zA-Z0-9:_./-]*$/, {
382
+ message: "path must start with / and contain only path-safe literal or :param segments",
383
+ }).refine((value) => !value.includes("..") &&
384
+ !value.includes("//") &&
385
+ value !== "/api" &&
386
+ !value.startsWith("/api/") &&
387
+ value !== "/plugins" &&
388
+ !value.startsWith("/plugins/"), { message: "path must stay inside the plugin api namespace" }),
389
+ auth: z.enum(PLUGIN_API_ROUTE_AUTH_MODES),
390
+ capability: z.literal("api.routes.register"),
391
+ checkoutPolicy: z.enum(PLUGIN_API_ROUTE_CHECKOUT_POLICIES).optional(),
392
+ companyResolution: z.discriminatedUnion("from", [
393
+ z.object({ from: z.literal("body"), key: z.string().min(1) }),
394
+ z.object({ from: z.literal("query"), key: z.string().min(1) }),
395
+ z.object({ from: z.literal("issue"), param: z.string().min(1) }),
396
+ ]).optional(),
397
+ });
398
+ // ---------------------------------------------------------------------------
399
+ // Plugin Manifest V1 schema
400
+ // ---------------------------------------------------------------------------
401
+ /**
402
+ * Zod schema for {@link EvermorePluginManifestV1} — the complete runtime
403
+ * validator for plugin manifests read at install time.
404
+ *
405
+ * Field-level constraints (see PLUGIN_SPEC.md §10.1 for the normative rules):
406
+ *
407
+ * | Field | Type | Constraints |
408
+ * |--------------------------|------------|----------------------------------------------|
409
+ * | `id` | string | `^[a-z0-9][a-z0-9._-]*$` |
410
+ * | `apiVersion` | literal 1 | must equal `PLUGIN_API_VERSION` |
411
+ * | `version` | string | semver (`\d+\.\d+\.\d+`) |
412
+ * | `displayName` | string | 1–100 chars |
413
+ * | `description` | string | 1–500 chars |
414
+ * | `author` | string | 1–200 chars |
415
+ * | `categories` | enum[] | at least one; values from PLUGIN_CATEGORIES |
416
+ * | `minimumHostVersion` | string? | semver lower bound if present, no leading `v`|
417
+ * | `minimumEvermoreVersion`| string? | legacy alias of `minimumHostVersion` |
418
+ * | `capabilities` | enum[] | at least one; values from PLUGIN_CAPABILITIES|
419
+ * | `entrypoints.worker` | string | min 1 char |
420
+ * | `entrypoints.ui` | string? | required when `ui.slots` is declared |
421
+ *
422
+ * Cross-field rules enforced via `superRefine`:
423
+ * - `entrypoints.ui` required when `ui.slots` declared
424
+ * - `agent.tools.register` capability required when `tools` declared
425
+ * - `environment.drivers.register` capability required when `environmentDrivers` declared
426
+ * - `jobs.schedule` capability required when `jobs` declared
427
+ * - `webhooks.receive` capability required when `webhooks` declared
428
+ * - duplicate `jobs[].jobKey` values are rejected
429
+ * - duplicate `webhooks[].endpointKey` values are rejected
430
+ * - duplicate `tools[].name` values are rejected
431
+ * - duplicate `environmentDrivers[].driverKey` values are rejected
432
+ * - duplicate `ui.slots[].id` values are rejected
433
+ *
434
+ * @see PLUGIN_SPEC.md §10.1 — Manifest shape
435
+ * @see {@link EvermorePluginManifestV1} — the inferred TypeScript type
436
+ */
437
+ export const pluginManifestV1Schema = z.object({
438
+ id: z.string().min(1).regex(/^[a-z0-9][a-z0-9._-]*$/, "Plugin id must start with a lowercase alphanumeric and contain only lowercase letters, digits, dots, hyphens, or underscores"),
439
+ apiVersion: z.literal(1),
440
+ version: z.string().min(1).regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/, "Version must follow semver (e.g. 1.0.0 or 1.0.0-beta.1)"),
441
+ displayName: z.string().min(1).max(100),
442
+ description: z.string().min(1).max(500),
443
+ author: z.string().min(1).max(200),
444
+ categories: z.array(z.enum(PLUGIN_CATEGORIES)).min(1),
445
+ minimumHostVersion: z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/, "minimumHostVersion must follow semver (e.g. 1.0.0)").optional(),
446
+ minimumEvermoreVersion: z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/, "minimumEvermoreVersion must follow semver (e.g. 1.0.0)").optional(),
447
+ capabilities: z.array(z.enum(PLUGIN_CAPABILITIES)).min(1),
448
+ entrypoints: z.object({
449
+ worker: z.string().min(1),
450
+ ui: z.string().min(1).optional(),
451
+ }),
452
+ instanceConfigSchema: jsonSchemaSchema.optional(),
453
+ jobs: z.array(pluginJobDeclarationSchema).optional(),
454
+ webhooks: z.array(pluginWebhookDeclarationSchema).optional(),
455
+ tools: z.array(pluginToolDeclarationSchema).optional(),
456
+ database: pluginDatabaseDeclarationSchema.optional(),
457
+ apiRoutes: z.array(pluginApiRouteDeclarationSchema).optional(),
458
+ environmentDrivers: z.array(pluginEnvironmentDriverDeclarationSchema).optional(),
459
+ agents: z.array(pluginManagedAgentDeclarationSchema).optional(),
460
+ projects: z.array(pluginManagedProjectDeclarationSchema).optional(),
461
+ routines: z.array(pluginManagedRoutineDeclarationSchema).optional(),
462
+ localFolders: z.array(pluginLocalFolderDeclarationSchema).optional(),
463
+ launchers: z.array(pluginLauncherDeclarationSchema).optional(),
464
+ ui: z.object({
465
+ slots: z.array(pluginUiSlotDeclarationSchema).min(1).optional(),
466
+ launchers: z.array(pluginLauncherDeclarationSchema).optional(),
467
+ }).optional(),
468
+ }).superRefine((manifest, ctx) => {
469
+ // ── Entrypoint ↔ UI slot consistency ──────────────────────────────────
470
+ // Plugins that declare UI slots must also declare a UI entrypoint so the
471
+ // host knows where to load the bundle from (PLUGIN_SPEC.md §10.1).
472
+ const hasUiSlots = (manifest.ui?.slots?.length ?? 0) > 0;
473
+ const hasUiLaunchers = (manifest.ui?.launchers?.length ?? 0) > 0;
474
+ if ((hasUiSlots || hasUiLaunchers) && !manifest.entrypoints.ui) {
475
+ ctx.addIssue({
476
+ code: z.ZodIssueCode.custom,
477
+ message: "entrypoints.ui is required when ui.slots or ui.launchers are declared",
478
+ path: ["entrypoints", "ui"],
479
+ });
480
+ }
481
+ if (manifest.minimumHostVersion
482
+ && manifest.minimumEvermoreVersion
483
+ && manifest.minimumHostVersion !== manifest.minimumEvermoreVersion) {
484
+ ctx.addIssue({
485
+ code: z.ZodIssueCode.custom,
486
+ message: "minimumHostVersion and minimumEvermoreVersion must match when both are declared",
487
+ path: ["minimumHostVersion"],
488
+ });
489
+ }
490
+ // ── Capability ↔ feature declaration consistency ───────────────────────
491
+ // The host enforces capabilities at install and runtime. A plugin must
492
+ // declare every capability it needs up-front; silently having more features
493
+ // than capabilities would cause runtime rejections.
494
+ // tools require agent.tools.register (PLUGIN_SPEC.md §11)
495
+ if (manifest.tools && manifest.tools.length > 0) {
496
+ if (!manifest.capabilities.includes("agent.tools.register")) {
497
+ ctx.addIssue({
498
+ code: z.ZodIssueCode.custom,
499
+ message: "Capability 'agent.tools.register' is required when tools are declared",
500
+ path: ["capabilities"],
501
+ });
502
+ }
503
+ }
504
+ // environment drivers require environment.drivers.register
505
+ if (manifest.environmentDrivers && manifest.environmentDrivers.length > 0) {
506
+ if (!manifest.capabilities.includes("environment.drivers.register")) {
507
+ ctx.addIssue({
508
+ code: z.ZodIssueCode.custom,
509
+ message: "Capability 'environment.drivers.register' is required when environmentDrivers are declared",
510
+ path: ["capabilities"],
511
+ });
512
+ }
513
+ }
514
+ if (manifest.agents && manifest.agents.length > 0) {
515
+ if (!manifest.capabilities.includes("agents.managed")) {
516
+ ctx.addIssue({
517
+ code: z.ZodIssueCode.custom,
518
+ message: "Capability 'agents.managed' is required when managed agents are declared",
519
+ path: ["capabilities"],
520
+ });
521
+ }
522
+ }
523
+ if (manifest.projects && manifest.projects.length > 0) {
524
+ if (!manifest.capabilities.includes("projects.managed")) {
525
+ ctx.addIssue({
526
+ code: z.ZodIssueCode.custom,
527
+ message: "Capability 'projects.managed' is required when managed projects are declared",
528
+ path: ["capabilities"],
529
+ });
530
+ }
531
+ }
532
+ if (manifest.routines && manifest.routines.length > 0) {
533
+ if (!manifest.capabilities.includes("routines.managed")) {
534
+ ctx.addIssue({
535
+ code: z.ZodIssueCode.custom,
536
+ message: "Capability 'routines.managed' is required when managed routines are declared",
537
+ path: ["capabilities"],
538
+ });
539
+ }
540
+ }
541
+ if (manifest.localFolders && manifest.localFolders.length > 0) {
542
+ if (!manifest.capabilities.includes("local.folders")) {
543
+ ctx.addIssue({
544
+ code: z.ZodIssueCode.custom,
545
+ message: "Capability 'local.folders' is required when local folders are declared",
546
+ path: ["capabilities"],
547
+ });
548
+ }
549
+ }
550
+ // jobs require jobs.schedule (PLUGIN_SPEC.md §17)
551
+ if (manifest.jobs && manifest.jobs.length > 0) {
552
+ if (!manifest.capabilities.includes("jobs.schedule")) {
553
+ ctx.addIssue({
554
+ code: z.ZodIssueCode.custom,
555
+ message: "Capability 'jobs.schedule' is required when jobs are declared",
556
+ path: ["capabilities"],
557
+ });
558
+ }
559
+ }
560
+ // webhooks require webhooks.receive (PLUGIN_SPEC.md §18)
561
+ if (manifest.webhooks && manifest.webhooks.length > 0) {
562
+ if (!manifest.capabilities.includes("webhooks.receive")) {
563
+ ctx.addIssue({
564
+ code: z.ZodIssueCode.custom,
565
+ message: "Capability 'webhooks.receive' is required when webhooks are declared",
566
+ path: ["capabilities"],
567
+ });
568
+ }
569
+ }
570
+ if (manifest.apiRoutes && manifest.apiRoutes.length > 0) {
571
+ if (!manifest.capabilities.includes("api.routes.register")) {
572
+ ctx.addIssue({
573
+ code: z.ZodIssueCode.custom,
574
+ message: "Capability 'api.routes.register' is required when apiRoutes are declared",
575
+ path: ["capabilities"],
576
+ });
577
+ }
578
+ }
579
+ if (manifest.database) {
580
+ const requiredCapabilities = [
581
+ "database.namespace.migrate",
582
+ "database.namespace.read",
583
+ ];
584
+ for (const capability of requiredCapabilities) {
585
+ if (!manifest.capabilities.includes(capability)) {
586
+ ctx.addIssue({
587
+ code: z.ZodIssueCode.custom,
588
+ message: `Capability '${capability}' is required when database migrations are declared`,
589
+ path: ["capabilities"],
590
+ });
591
+ }
592
+ }
593
+ const coreReadTables = manifest.database.coreReadTables ?? [];
594
+ const duplicates = coreReadTables.filter((table, i) => coreReadTables.indexOf(table) !== i);
595
+ if (duplicates.length > 0) {
596
+ ctx.addIssue({
597
+ code: z.ZodIssueCode.custom,
598
+ message: `Duplicate database coreReadTables: ${[...new Set(duplicates)].join(", ")}`,
599
+ path: ["database", "coreReadTables"],
600
+ });
601
+ }
602
+ }
603
+ // ── Uniqueness checks ──────────────────────────────────────────────────
604
+ // Duplicate keys within a plugin's own manifest are always a bug. The host
605
+ // would not know which declaration takes precedence, so we reject early.
606
+ // job keys must be unique within the plugin (used as identifiers in the DB)
607
+ if (manifest.jobs) {
608
+ const jobKeys = manifest.jobs.map((j) => j.jobKey);
609
+ const duplicates = jobKeys.filter((key, i) => jobKeys.indexOf(key) !== i);
610
+ if (duplicates.length > 0) {
611
+ ctx.addIssue({
612
+ code: z.ZodIssueCode.custom,
613
+ message: `Duplicate job keys: ${[...new Set(duplicates)].join(", ")}`,
614
+ path: ["jobs"],
615
+ });
616
+ }
617
+ }
618
+ // webhook endpoint keys must be unique within the plugin (used in routes)
619
+ if (manifest.webhooks) {
620
+ const endpointKeys = manifest.webhooks.map((w) => w.endpointKey);
621
+ const duplicates = endpointKeys.filter((key, i) => endpointKeys.indexOf(key) !== i);
622
+ if (duplicates.length > 0) {
623
+ ctx.addIssue({
624
+ code: z.ZodIssueCode.custom,
625
+ message: `Duplicate webhook endpoint keys: ${[...new Set(duplicates)].join(", ")}`,
626
+ path: ["webhooks"],
627
+ });
628
+ }
629
+ }
630
+ if (manifest.apiRoutes) {
631
+ const routeKeys = manifest.apiRoutes.map((route) => route.routeKey);
632
+ const duplicateKeys = routeKeys.filter((key, i) => routeKeys.indexOf(key) !== i);
633
+ if (duplicateKeys.length > 0) {
634
+ ctx.addIssue({
635
+ code: z.ZodIssueCode.custom,
636
+ message: `Duplicate api route keys: ${[...new Set(duplicateKeys)].join(", ")}`,
637
+ path: ["apiRoutes"],
638
+ });
639
+ }
640
+ const routeSignatures = manifest.apiRoutes.map((route) => `${route.method} ${route.path}`);
641
+ const duplicateRoutes = routeSignatures.filter((sig, i) => routeSignatures.indexOf(sig) !== i);
642
+ if (duplicateRoutes.length > 0) {
643
+ ctx.addIssue({
644
+ code: z.ZodIssueCode.custom,
645
+ message: `Duplicate api routes: ${[...new Set(duplicateRoutes)].join(", ")}`,
646
+ path: ["apiRoutes"],
647
+ });
648
+ }
649
+ }
650
+ // tool names must be unique within the plugin (namespaced at runtime)
651
+ if (manifest.tools) {
652
+ const toolNames = manifest.tools.map((t) => t.name);
653
+ const duplicates = toolNames.filter((name, i) => toolNames.indexOf(name) !== i);
654
+ if (duplicates.length > 0) {
655
+ ctx.addIssue({
656
+ code: z.ZodIssueCode.custom,
657
+ message: `Duplicate tool names: ${[...new Set(duplicates)].join(", ")}`,
658
+ path: ["tools"],
659
+ });
660
+ }
661
+ }
662
+ // environment driver keys must be unique within the plugin
663
+ if (manifest.environmentDrivers) {
664
+ const driverKeys = manifest.environmentDrivers.map((d) => d.driverKey);
665
+ const duplicates = driverKeys.filter((key, i) => driverKeys.indexOf(key) !== i);
666
+ if (duplicates.length > 0) {
667
+ ctx.addIssue({
668
+ code: z.ZodIssueCode.custom,
669
+ message: `Duplicate environment driver keys: ${[...new Set(duplicates)].join(", ")}`,
670
+ path: ["environmentDrivers"],
671
+ });
672
+ }
673
+ }
674
+ if (manifest.localFolders) {
675
+ const folderKeys = manifest.localFolders.map((folder) => folder.folderKey);
676
+ const duplicates = folderKeys.filter((key, i) => folderKeys.indexOf(key) !== i);
677
+ if (duplicates.length > 0) {
678
+ ctx.addIssue({
679
+ code: z.ZodIssueCode.custom,
680
+ message: `Duplicate local folder keys: ${[...new Set(duplicates)].join(", ")}`,
681
+ path: ["localFolders"],
682
+ });
683
+ }
684
+ }
685
+ if (manifest.agents) {
686
+ const agentKeys = manifest.agents.map((agent) => agent.agentKey);
687
+ const duplicates = agentKeys.filter((key, i) => agentKeys.indexOf(key) !== i);
688
+ if (duplicates.length > 0) {
689
+ ctx.addIssue({
690
+ code: z.ZodIssueCode.custom,
691
+ message: `Duplicate managed agent keys: ${[...new Set(duplicates)].join(", ")}`,
692
+ path: ["agents"],
693
+ });
694
+ }
695
+ }
696
+ if (manifest.projects) {
697
+ const projectKeys = manifest.projects.map((project) => project.projectKey);
698
+ const duplicates = projectKeys.filter((key, i) => projectKeys.indexOf(key) !== i);
699
+ if (duplicates.length > 0) {
700
+ ctx.addIssue({
701
+ code: z.ZodIssueCode.custom,
702
+ message: `Duplicate managed project keys: ${[...new Set(duplicates)].join(", ")}`,
703
+ path: ["projects"],
704
+ });
705
+ }
706
+ }
707
+ if (manifest.routines) {
708
+ const routineKeys = manifest.routines.map((routine) => routine.routineKey);
709
+ const duplicates = routineKeys.filter((key, i) => routineKeys.indexOf(key) !== i);
710
+ if (duplicates.length > 0) {
711
+ ctx.addIssue({
712
+ code: z.ZodIssueCode.custom,
713
+ message: `Duplicate managed routine keys: ${[...new Set(duplicates)].join(", ")}`,
714
+ path: ["routines"],
715
+ });
716
+ }
717
+ }
718
+ // UI slot ids must be unique within the plugin (namespaced at runtime)
719
+ if (manifest.ui) {
720
+ if (manifest.ui.slots) {
721
+ const slotIds = manifest.ui.slots.map((s) => s.id);
722
+ const duplicates = slotIds.filter((id, i) => slotIds.indexOf(id) !== i);
723
+ if (duplicates.length > 0) {
724
+ ctx.addIssue({
725
+ code: z.ZodIssueCode.custom,
726
+ message: `Duplicate UI slot ids: ${[...new Set(duplicates)].join(", ")}`,
727
+ path: ["ui", "slots"],
728
+ });
729
+ }
730
+ }
731
+ }
732
+ // launcher ids must be unique within the plugin
733
+ const allLaunchers = [
734
+ ...(manifest.launchers ?? []),
735
+ ...(manifest.ui?.launchers ?? []),
736
+ ];
737
+ if (allLaunchers.length > 0) {
738
+ const launcherIds = allLaunchers.map((launcher) => launcher.id);
739
+ const duplicates = launcherIds.filter((id, i) => launcherIds.indexOf(id) !== i);
740
+ if (duplicates.length > 0) {
741
+ ctx.addIssue({
742
+ code: z.ZodIssueCode.custom,
743
+ message: `Duplicate launcher ids: ${[...new Set(duplicates)].join(", ")}`,
744
+ path: manifest.ui?.launchers ? ["ui", "launchers"] : ["launchers"],
745
+ });
746
+ }
747
+ }
748
+ });
749
+ // ---------------------------------------------------------------------------
750
+ // Plugin installation / registration request
751
+ // ---------------------------------------------------------------------------
752
+ /**
753
+ * Schema for installing (registering) a plugin.
754
+ * The server receives the packageName and resolves the manifest from the
755
+ * installed package.
756
+ */
757
+ export const installPluginSchema = z.object({
758
+ packageName: z.string().min(1),
759
+ version: z.string().min(1).optional(),
760
+ /** Set by loader for local-path installs so the worker can be resolved. */
761
+ packagePath: z.string().min(1).optional(),
762
+ });
763
+ // ---------------------------------------------------------------------------
764
+ // Plugin config (instance configuration) schemas
765
+ // ---------------------------------------------------------------------------
766
+ /**
767
+ * Schema for creating or updating a plugin's instance configuration.
768
+ * configJson is validated permissively here; runtime validation against
769
+ * the plugin's instanceConfigSchema is done at the service layer.
770
+ */
771
+ export const upsertPluginConfigSchema = z.object({
772
+ configJson: z.record(z.unknown()),
773
+ });
774
+ /**
775
+ * Schema for partially updating a plugin's instance configuration.
776
+ * Allows a partial merge of config values.
777
+ */
778
+ export const patchPluginConfigSchema = z.object({
779
+ configJson: z.record(z.unknown()),
780
+ });
781
+ // ---------------------------------------------------------------------------
782
+ // Plugin status update
783
+ // ---------------------------------------------------------------------------
784
+ /**
785
+ * Schema for updating a plugin's lifecycle status. Used by the lifecycle
786
+ * manager to persist state transitions.
787
+ *
788
+ * @see {@link PLUGIN_STATUSES} for the valid status values
789
+ */
790
+ export const updatePluginStatusSchema = z.object({
791
+ status: z.enum(PLUGIN_STATUSES),
792
+ lastError: z.string().nullable().optional(),
793
+ });
794
+ // ---------------------------------------------------------------------------
795
+ // Plugin uninstall
796
+ // ---------------------------------------------------------------------------
797
+ /** Schema for the uninstall request. `removeData` controls hard vs soft delete. */
798
+ export const uninstallPluginSchema = z.object({
799
+ removeData: z.boolean().optional().default(false),
800
+ });
801
+ // ---------------------------------------------------------------------------
802
+ // Plugin state (key-value storage) schemas
803
+ // ---------------------------------------------------------------------------
804
+ /**
805
+ * Schema for a plugin state scope key — identifies the exact location where
806
+ * state is stored. Used by the `ctx.state.get()`, `ctx.state.set()`, and
807
+ * `ctx.state.delete()` SDK methods.
808
+ *
809
+ * @see PLUGIN_SPEC.md §21.3 `plugin_state`
810
+ */
811
+ export const pluginStateScopeKeySchema = z.object({
812
+ scopeKind: z.enum(PLUGIN_STATE_SCOPE_KINDS),
813
+ scopeId: z.string().min(1).optional(),
814
+ namespace: z.string().min(1).optional(),
815
+ stateKey: z.string().min(1),
816
+ });
817
+ /**
818
+ * Schema for setting a plugin state value.
819
+ */
820
+ export const setPluginStateSchema = z.object({
821
+ scopeKind: z.enum(PLUGIN_STATE_SCOPE_KINDS),
822
+ scopeId: z.string().min(1).optional(),
823
+ namespace: z.string().min(1).optional(),
824
+ stateKey: z.string().min(1),
825
+ /** JSON-serializable value to store. */
826
+ value: z.unknown(),
827
+ });
828
+ /**
829
+ * Schema for querying plugin state entries. All fields are optional to allow
830
+ * flexible list queries (e.g. all state for a plugin within a scope).
831
+ */
832
+ export const listPluginStateSchema = z.object({
833
+ scopeKind: z.enum(PLUGIN_STATE_SCOPE_KINDS).optional(),
834
+ scopeId: z.string().min(1).optional(),
835
+ namespace: z.string().min(1).optional(),
836
+ });
837
+ //# sourceMappingURL=plugin.js.map