@eloxiv/contracts 0.0.0-stage → 0.1.1

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 (537) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +6 -2
  3. package/dist/Agent.d.ts +792 -0
  4. package/dist/Agent.d.ts.map +1 -0
  5. package/dist/Agent.js +610 -0
  6. package/dist/Agent.js.map +1 -0
  7. package/dist/Analytics.d.ts +46 -0
  8. package/dist/Analytics.d.ts.map +1 -0
  9. package/dist/Analytics.js +89 -0
  10. package/dist/Analytics.js.map +1 -0
  11. package/dist/Approval.d.ts +70 -0
  12. package/dist/Approval.d.ts.map +1 -0
  13. package/dist/Approval.js +127 -0
  14. package/dist/Approval.js.map +1 -0
  15. package/dist/Catalog.d.ts +238 -0
  16. package/dist/Catalog.d.ts.map +1 -0
  17. package/dist/Catalog.js +169 -0
  18. package/dist/Catalog.js.map +1 -0
  19. package/dist/Checklist.d.ts +99 -0
  20. package/dist/Checklist.d.ts.map +1 -0
  21. package/dist/Checklist.js +105 -0
  22. package/dist/Checklist.js.map +1 -0
  23. package/dist/Data.d.ts +107 -0
  24. package/dist/Data.d.ts.map +1 -0
  25. package/dist/Data.js +93 -0
  26. package/dist/Data.js.map +1 -0
  27. package/dist/Devices.d.ts +857 -0
  28. package/dist/Devices.d.ts.map +1 -0
  29. package/dist/Devices.js +590 -0
  30. package/dist/Devices.js.map +1 -0
  31. package/dist/Durable.d.ts +406 -0
  32. package/dist/Durable.d.ts.map +1 -0
  33. package/dist/Durable.js +203 -0
  34. package/dist/Durable.js.map +1 -0
  35. package/dist/Errors.d.ts +95 -0
  36. package/dist/Errors.d.ts.map +1 -0
  37. package/dist/Errors.js +72 -0
  38. package/dist/Errors.js.map +1 -0
  39. package/dist/JsonSchema.d.ts +355 -0
  40. package/dist/JsonSchema.d.ts.map +1 -0
  41. package/dist/JsonSchema.js +151 -0
  42. package/dist/JsonSchema.js.map +1 -0
  43. package/dist/Manifest.d.ts +353 -0
  44. package/dist/Manifest.d.ts.map +1 -0
  45. package/dist/Manifest.js +894 -0
  46. package/dist/Manifest.js.map +1 -0
  47. package/dist/Module.d.ts +447 -0
  48. package/dist/Module.d.ts.map +1 -0
  49. package/dist/Module.js +221 -0
  50. package/dist/Module.js.map +1 -0
  51. package/dist/Optimistic.d.ts +192 -0
  52. package/dist/Optimistic.d.ts.map +1 -0
  53. package/dist/Optimistic.js +319 -0
  54. package/dist/Optimistic.js.map +1 -0
  55. package/dist/Projection.d.ts +163 -0
  56. package/dist/Projection.d.ts.map +1 -0
  57. package/dist/Projection.js +158 -0
  58. package/dist/Projection.js.map +1 -0
  59. package/dist/Proposals.d.ts +103 -0
  60. package/dist/Proposals.d.ts.map +1 -0
  61. package/dist/Proposals.js +72 -0
  62. package/dist/Proposals.js.map +1 -0
  63. package/dist/Receipt.d.ts +243 -0
  64. package/dist/Receipt.d.ts.map +1 -0
  65. package/dist/Receipt.js +108 -0
  66. package/dist/Receipt.js.map +1 -0
  67. package/dist/Records.d.ts +297 -0
  68. package/dist/Records.d.ts.map +1 -0
  69. package/dist/Records.js +171 -0
  70. package/dist/Records.js.map +1 -0
  71. package/dist/Render.d.ts +207 -0
  72. package/dist/Render.d.ts.map +1 -0
  73. package/dist/Render.js +502 -0
  74. package/dist/Render.js.map +1 -0
  75. package/dist/Rpc.d.ts +115 -0
  76. package/dist/Rpc.d.ts.map +1 -0
  77. package/dist/Rpc.js +68 -0
  78. package/dist/Rpc.js.map +1 -0
  79. package/dist/SearchLanguages.d.ts +4 -0
  80. package/dist/SearchLanguages.d.ts.map +1 -0
  81. package/dist/SearchLanguages.js +33 -0
  82. package/dist/SearchLanguages.js.map +1 -0
  83. package/dist/Service.d.ts +59 -0
  84. package/dist/Service.d.ts.map +1 -0
  85. package/dist/Service.js +38 -0
  86. package/dist/Service.js.map +1 -0
  87. package/dist/Versions.d.ts +9 -0
  88. package/dist/Versions.d.ts.map +1 -0
  89. package/dist/Versions.js +78 -0
  90. package/dist/Versions.js.map +1 -0
  91. package/dist/contracts/ActionConsent.d.ts +189 -0
  92. package/dist/contracts/ActionConsent.d.ts.map +1 -0
  93. package/dist/contracts/ActionConsent.js +129 -0
  94. package/dist/contracts/ActionConsent.js.map +1 -0
  95. package/dist/contracts/ActionRegistry.d.ts +149 -0
  96. package/dist/contracts/ActionRegistry.d.ts.map +1 -0
  97. package/dist/contracts/ActionRegistry.js +37 -0
  98. package/dist/contracts/ActionRegistry.js.map +1 -0
  99. package/dist/contracts/Actor.d.ts +129 -0
  100. package/dist/contracts/Actor.d.ts.map +1 -0
  101. package/dist/contracts/Actor.js +47 -0
  102. package/dist/contracts/Actor.js.map +1 -0
  103. package/dist/contracts/AgentResources.d.ts +248 -0
  104. package/dist/contracts/AgentResources.d.ts.map +1 -0
  105. package/dist/contracts/AgentResources.js +158 -0
  106. package/dist/contracts/AgentResources.js.map +1 -0
  107. package/dist/contracts/AgentRuntime.d.ts +453 -0
  108. package/dist/contracts/AgentRuntime.d.ts.map +1 -0
  109. package/dist/contracts/AgentRuntime.js +117 -0
  110. package/dist/contracts/AgentRuntime.js.map +1 -0
  111. package/dist/contracts/Approvals.d.ts +303 -0
  112. package/dist/contracts/Approvals.d.ts.map +1 -0
  113. package/dist/contracts/Approvals.js +117 -0
  114. package/dist/contracts/Approvals.js.map +1 -0
  115. package/dist/contracts/Audit.d.ts +510 -0
  116. package/dist/contracts/Audit.d.ts.map +1 -0
  117. package/dist/contracts/Audit.js +139 -0
  118. package/dist/contracts/Audit.js.map +1 -0
  119. package/dist/contracts/CalendarProvider.d.ts +572 -0
  120. package/dist/contracts/CalendarProvider.d.ts.map +1 -0
  121. package/dist/contracts/CalendarProvider.js +203 -0
  122. package/dist/contracts/CalendarProvider.js.map +1 -0
  123. package/dist/contracts/Capability.d.ts +197 -0
  124. package/dist/contracts/Capability.d.ts.map +1 -0
  125. package/dist/contracts/Capability.js +189 -0
  126. package/dist/contracts/Capability.js.map +1 -0
  127. package/dist/contracts/ClientSDK.d.ts +250 -0
  128. package/dist/contracts/ClientSDK.d.ts.map +1 -0
  129. package/dist/contracts/ClientSDK.js +184 -0
  130. package/dist/contracts/ClientSDK.js.map +1 -0
  131. package/dist/contracts/CollabDocument.d.ts +781 -0
  132. package/dist/contracts/CollabDocument.d.ts.map +1 -0
  133. package/dist/contracts/CollabDocument.js +364 -0
  134. package/dist/contracts/CollabDocument.js.map +1 -0
  135. package/dist/contracts/Command.d.ts +183 -0
  136. package/dist/contracts/Command.d.ts.map +1 -0
  137. package/dist/contracts/Command.js +66 -0
  138. package/dist/contracts/Command.js.map +1 -0
  139. package/dist/contracts/Connections.d.ts +612 -0
  140. package/dist/contracts/Connections.d.ts.map +1 -0
  141. package/dist/contracts/Connections.js +323 -0
  142. package/dist/contracts/Connections.js.map +1 -0
  143. package/dist/contracts/ContextAccounting.d.ts +79 -0
  144. package/dist/contracts/ContextAccounting.d.ts.map +1 -0
  145. package/dist/contracts/ContextAccounting.js +32 -0
  146. package/dist/contracts/ContextAccounting.js.map +1 -0
  147. package/dist/contracts/Daemon.d.ts +486 -0
  148. package/dist/contracts/Daemon.d.ts.map +1 -0
  149. package/dist/contracts/Daemon.js +192 -0
  150. package/dist/contracts/Daemon.js.map +1 -0
  151. package/dist/contracts/DbTx.d.ts +149 -0
  152. package/dist/contracts/DbTx.d.ts.map +1 -0
  153. package/dist/contracts/DbTx.js +94 -0
  154. package/dist/contracts/DbTx.js.map +1 -0
  155. package/dist/contracts/Delegation.d.ts +121 -0
  156. package/dist/contracts/Delegation.d.ts.map +1 -0
  157. package/dist/contracts/Delegation.js +76 -0
  158. package/dist/contracts/Delegation.js.map +1 -0
  159. package/dist/contracts/DeviceControl.d.ts +293 -0
  160. package/dist/contracts/DeviceControl.d.ts.map +1 -0
  161. package/dist/contracts/DeviceControl.js +107 -0
  162. package/dist/contracts/DeviceControl.js.map +1 -0
  163. package/dist/contracts/Directory.d.ts +492 -0
  164. package/dist/contracts/Directory.d.ts.map +1 -0
  165. package/dist/contracts/Directory.js +225 -0
  166. package/dist/contracts/Directory.js.map +1 -0
  167. package/dist/contracts/DirectoryProvider.d.ts +214 -0
  168. package/dist/contracts/DirectoryProvider.d.ts.map +1 -0
  169. package/dist/contracts/DirectoryProvider.js +73 -0
  170. package/dist/contracts/DirectoryProvider.js.map +1 -0
  171. package/dist/contracts/DocumentSource.d.ts +190 -0
  172. package/dist/contracts/DocumentSource.d.ts.map +1 -0
  173. package/dist/contracts/DocumentSource.js +64 -0
  174. package/dist/contracts/DocumentSource.js.map +1 -0
  175. package/dist/contracts/Files.d.ts +762 -0
  176. package/dist/contracts/Files.d.ts.map +1 -0
  177. package/dist/contracts/Files.js +339 -0
  178. package/dist/contracts/Files.js.map +1 -0
  179. package/dist/contracts/Flags.d.ts +265 -0
  180. package/dist/contracts/Flags.d.ts.map +1 -0
  181. package/dist/contracts/Flags.js +197 -0
  182. package/dist/contracts/Flags.js.map +1 -0
  183. package/dist/contracts/Host.d.ts +320 -0
  184. package/dist/contracts/Host.d.ts.map +1 -0
  185. package/dist/contracts/Host.js +224 -0
  186. package/dist/contracts/Host.js.map +1 -0
  187. package/dist/contracts/HttpApi.d.ts +102 -0
  188. package/dist/contracts/HttpApi.d.ts.map +1 -0
  189. package/dist/contracts/HttpApi.js +89 -0
  190. package/dist/contracts/HttpApi.js.map +1 -0
  191. package/dist/contracts/Ingestion.d.ts +522 -0
  192. package/dist/contracts/Ingestion.d.ts.map +1 -0
  193. package/dist/contracts/Ingestion.js +275 -0
  194. package/dist/contracts/Ingestion.js.map +1 -0
  195. package/dist/contracts/Ingress.d.ts +132 -0
  196. package/dist/contracts/Ingress.d.ts.map +1 -0
  197. package/dist/contracts/Ingress.js +102 -0
  198. package/dist/contracts/Ingress.js.map +1 -0
  199. package/dist/contracts/Invocation.d.ts +361 -0
  200. package/dist/contracts/Invocation.d.ts.map +1 -0
  201. package/dist/contracts/Invocation.js +104 -0
  202. package/dist/contracts/Invocation.js.map +1 -0
  203. package/dist/contracts/LocalClient.d.ts +888 -0
  204. package/dist/contracts/LocalClient.d.ts.map +1 -0
  205. package/dist/contracts/LocalClient.js +429 -0
  206. package/dist/contracts/LocalClient.js.map +1 -0
  207. package/dist/contracts/Locale.d.ts +162 -0
  208. package/dist/contracts/Locale.d.ts.map +1 -0
  209. package/dist/contracts/Locale.js +123 -0
  210. package/dist/contracts/Locale.js.map +1 -0
  211. package/dist/contracts/MachineIdentity.d.ts +434 -0
  212. package/dist/contracts/MachineIdentity.d.ts.map +1 -0
  213. package/dist/contracts/MachineIdentity.js +223 -0
  214. package/dist/contracts/MachineIdentity.js.map +1 -0
  215. package/dist/contracts/MailProvider.d.ts +791 -0
  216. package/dist/contracts/MailProvider.d.ts.map +1 -0
  217. package/dist/contracts/MailProvider.js +237 -0
  218. package/dist/contracts/MailProvider.js.map +1 -0
  219. package/dist/contracts/Memory.d.ts +62 -0
  220. package/dist/contracts/Memory.d.ts.map +1 -0
  221. package/dist/contracts/Memory.js +43 -0
  222. package/dist/contracts/Memory.js.map +1 -0
  223. package/dist/contracts/Messaging.d.ts +154 -0
  224. package/dist/contracts/Messaging.d.ts.map +1 -0
  225. package/dist/contracts/Messaging.js +97 -0
  226. package/dist/contracts/Messaging.js.map +1 -0
  227. package/dist/contracts/Metering.d.ts +334 -0
  228. package/dist/contracts/Metering.d.ts.map +1 -0
  229. package/dist/contracts/Metering.js +202 -0
  230. package/dist/contracts/Metering.js.map +1 -0
  231. package/dist/contracts/ModelProvider.d.ts +142 -0
  232. package/dist/contracts/ModelProvider.d.ts.map +1 -0
  233. package/dist/contracts/ModelProvider.js +72 -0
  234. package/dist/contracts/ModelProvider.js.map +1 -0
  235. package/dist/contracts/ModuleManifest.d.ts +2519 -0
  236. package/dist/contracts/ModuleManifest.d.ts.map +1 -0
  237. package/dist/contracts/ModuleManifest.js +272 -0
  238. package/dist/contracts/ModuleManifest.js.map +1 -0
  239. package/dist/contracts/NotificationChannel.d.ts +378 -0
  240. package/dist/contracts/NotificationChannel.d.ts.map +1 -0
  241. package/dist/contracts/NotificationChannel.js +136 -0
  242. package/dist/contracts/NotificationChannel.js.map +1 -0
  243. package/dist/contracts/Notifications.d.ts +417 -0
  244. package/dist/contracts/Notifications.d.ts.map +1 -0
  245. package/dist/contracts/Notifications.js +267 -0
  246. package/dist/contracts/Notifications.js.map +1 -0
  247. package/dist/contracts/Outbox.d.ts +469 -0
  248. package/dist/contracts/Outbox.d.ts.map +1 -0
  249. package/dist/contracts/Outbox.js +215 -0
  250. package/dist/contracts/Outbox.js.map +1 -0
  251. package/dist/contracts/Privacy.d.ts +1029 -0
  252. package/dist/contracts/Privacy.d.ts.map +1 -0
  253. package/dist/contracts/Privacy.js +437 -0
  254. package/dist/contracts/Privacy.js.map +1 -0
  255. package/dist/contracts/Progress.d.ts +305 -0
  256. package/dist/contracts/Progress.d.ts.map +1 -0
  257. package/dist/contracts/Progress.js +174 -0
  258. package/dist/contracts/Progress.js.map +1 -0
  259. package/dist/contracts/QuerySurface.d.ts +231 -0
  260. package/dist/contracts/QuerySurface.d.ts.map +1 -0
  261. package/dist/contracts/QuerySurface.js +113 -0
  262. package/dist/contracts/QuerySurface.js.map +1 -0
  263. package/dist/contracts/Readiness.d.ts +105 -0
  264. package/dist/contracts/Readiness.d.ts.map +1 -0
  265. package/dist/contracts/Readiness.js +57 -0
  266. package/dist/contracts/Readiness.js.map +1 -0
  267. package/dist/contracts/Release.d.ts +295 -0
  268. package/dist/contracts/Release.d.ts.map +1 -0
  269. package/dist/contracts/Release.js +175 -0
  270. package/dist/contracts/Release.js.map +1 -0
  271. package/dist/contracts/ResultRendering.d.ts +533 -0
  272. package/dist/contracts/ResultRendering.d.ts.map +1 -0
  273. package/dist/contracts/ResultRendering.js +59 -0
  274. package/dist/contracts/ResultRendering.js.map +1 -0
  275. package/dist/contracts/Sandbox.d.ts +1164 -0
  276. package/dist/contracts/Sandbox.d.ts.map +1 -0
  277. package/dist/contracts/Sandbox.js +550 -0
  278. package/dist/contracts/Sandbox.js.map +1 -0
  279. package/dist/contracts/Scheduler.d.ts +814 -0
  280. package/dist/contracts/Scheduler.d.ts.map +1 -0
  281. package/dist/contracts/Scheduler.js +202 -0
  282. package/dist/contracts/Scheduler.js.map +1 -0
  283. package/dist/contracts/ScreenContext.d.ts +514 -0
  284. package/dist/contracts/ScreenContext.d.ts.map +1 -0
  285. package/dist/contracts/ScreenContext.js +272 -0
  286. package/dist/contracts/ScreenContext.js.map +1 -0
  287. package/dist/contracts/Search.d.ts +308 -0
  288. package/dist/contracts/Search.d.ts.map +1 -0
  289. package/dist/contracts/Search.js +107 -0
  290. package/dist/contracts/Search.js.map +1 -0
  291. package/dist/contracts/Secrets.d.ts +483 -0
  292. package/dist/contracts/Secrets.d.ts.map +1 -0
  293. package/dist/contracts/Secrets.js +136 -0
  294. package/dist/contracts/Secrets.js.map +1 -0
  295. package/dist/contracts/Settings.d.ts +221 -0
  296. package/dist/contracts/Settings.d.ts.map +1 -0
  297. package/dist/contracts/Settings.js +163 -0
  298. package/dist/contracts/Settings.js.map +1 -0
  299. package/dist/contracts/Sharing.d.ts +319 -0
  300. package/dist/contracts/Sharing.d.ts.map +1 -0
  301. package/dist/contracts/Sharing.js +172 -0
  302. package/dist/contracts/Sharing.js.map +1 -0
  303. package/dist/contracts/Slot.d.ts +162 -0
  304. package/dist/contracts/Slot.d.ts.map +1 -0
  305. package/dist/contracts/Slot.js +56 -0
  306. package/dist/contracts/Slot.js.map +1 -0
  307. package/dist/contracts/Space.d.ts +256 -0
  308. package/dist/contracts/Space.d.ts.map +1 -0
  309. package/dist/contracts/Space.js +133 -0
  310. package/dist/contracts/Space.js.map +1 -0
  311. package/dist/contracts/StorageAdapter.d.ts +124 -0
  312. package/dist/contracts/StorageAdapter.d.ts.map +1 -0
  313. package/dist/contracts/StorageAdapter.js +96 -0
  314. package/dist/contracts/StorageAdapter.js.map +1 -0
  315. package/dist/contracts/StorageBackend.d.ts +310 -0
  316. package/dist/contracts/StorageBackend.d.ts.map +1 -0
  317. package/dist/contracts/StorageBackend.js +196 -0
  318. package/dist/contracts/StorageBackend.js.map +1 -0
  319. package/dist/contracts/Sync.d.ts +286 -0
  320. package/dist/contracts/Sync.d.ts.map +1 -0
  321. package/dist/contracts/Sync.js +157 -0
  322. package/dist/contracts/Sync.js.map +1 -0
  323. package/dist/contracts/Telemetry.d.ts +183 -0
  324. package/dist/contracts/Telemetry.d.ts.map +1 -0
  325. package/dist/contracts/Telemetry.js +153 -0
  326. package/dist/contracts/Telemetry.js.map +1 -0
  327. package/dist/contracts/ThemeTokens.d.ts +212 -0
  328. package/dist/contracts/ThemeTokens.d.ts.map +1 -0
  329. package/dist/contracts/ThemeTokens.js +111 -0
  330. package/dist/contracts/ThemeTokens.js.map +1 -0
  331. package/dist/contracts/ToolSource.d.ts +135 -0
  332. package/dist/contracts/ToolSource.d.ts.map +1 -0
  333. package/dist/contracts/ToolSource.js +81 -0
  334. package/dist/contracts/ToolSource.js.map +1 -0
  335. package/dist/contracts/Versioning.d.ts +363 -0
  336. package/dist/contracts/Versioning.d.ts.map +1 -0
  337. package/dist/contracts/Versioning.js +201 -0
  338. package/dist/contracts/Versioning.js.map +1 -0
  339. package/dist/contracts/View.d.ts +232 -0
  340. package/dist/contracts/View.d.ts.map +1 -0
  341. package/dist/contracts/View.js +102 -0
  342. package/dist/contracts/View.js.map +1 -0
  343. package/dist/contracts/WorkItems.d.ts +242 -0
  344. package/dist/contracts/WorkItems.d.ts.map +1 -0
  345. package/dist/contracts/WorkItems.js +126 -0
  346. package/dist/contracts/WorkItems.js.map +1 -0
  347. package/dist/contracts/Workflow.d.ts +191 -0
  348. package/dist/contracts/Workflow.d.ts.map +1 -0
  349. package/dist/contracts/Workflow.js +63 -0
  350. package/dist/contracts/Workflow.js.map +1 -0
  351. package/dist/contracts/index.d.ts +75 -0
  352. package/dist/contracts/index.d.ts.map +1 -0
  353. package/dist/contracts/index.js +196 -0
  354. package/dist/contracts/index.js.map +1 -0
  355. package/dist/devices/module.d.ts +3777 -0
  356. package/dist/devices/module.d.ts.map +1 -0
  357. package/dist/devices/module.js +179 -0
  358. package/dist/devices/module.js.map +1 -0
  359. package/dist/drizzle/Entity.d.ts +148 -0
  360. package/dist/drizzle/Entity.d.ts.map +1 -0
  361. package/dist/drizzle/Entity.js +396 -0
  362. package/dist/drizzle/Entity.js.map +1 -0
  363. package/dist/index.d.ts +20 -0
  364. package/dist/index.d.ts.map +1 -0
  365. package/dist/index.js +20 -0
  366. package/dist/index.js.map +1 -0
  367. package/package.json +48 -3
  368. package/schema/Actor.json +46 -0
  369. package/schema/AuditRecord.json +403 -0
  370. package/schema/DaemonHealth.json +29 -0
  371. package/schema/InvocationError.json +257 -0
  372. package/schema/InvocationReceipt.json +253 -0
  373. package/schema/Lockfile.json +129 -0
  374. package/schema/OutboxEvent.json +36 -0
  375. package/schema/PairingConfirm.json +33 -0
  376. package/schema/PairingResult.json +18 -0
  377. package/schema/PairingStart.json +18 -0
  378. package/schema/ProvenanceEntry.json +110 -0
  379. package/schema/ReplayEnvelope.json +269 -0
  380. package/schema/Surface.json +17 -0
  381. package/schema/codegen/LocalClient.json +1298 -0
  382. package/schema/codegen/Sandbox.json +320 -0
  383. package/schema/contracts/ActionConsent.json +1930 -0
  384. package/schema/contracts/ActionRegistry.json +722 -0
  385. package/schema/contracts/Actor.json +451 -0
  386. package/schema/contracts/AgentResources.json +1400 -0
  387. package/schema/contracts/AgentRuntime.json +4017 -0
  388. package/schema/contracts/Approvals.json +2916 -0
  389. package/schema/contracts/Audit.json +3268 -0
  390. package/schema/contracts/CalendarProvider.json +5557 -0
  391. package/schema/contracts/ClientSDK.json +1400 -0
  392. package/schema/contracts/CollabDocument.json +4012 -0
  393. package/schema/contracts/Command.json +616 -0
  394. package/schema/contracts/Connections.json +6687 -0
  395. package/schema/contracts/ContextAccounting.json +685 -0
  396. package/schema/contracts/Daemon.json +4555 -0
  397. package/schema/contracts/DbTx.json +321 -0
  398. package/schema/contracts/Delegation.json +949 -0
  399. package/schema/contracts/DeviceControl.json +2626 -0
  400. package/schema/contracts/Directory.json +5168 -0
  401. package/schema/contracts/DirectoryProvider.json +2090 -0
  402. package/schema/contracts/DocumentSource.json +2044 -0
  403. package/schema/contracts/Files.json +4122 -0
  404. package/schema/contracts/Flags.json +1202 -0
  405. package/schema/contracts/Host.json +1769 -0
  406. package/schema/contracts/HttpApi.json +1615 -0
  407. package/schema/contracts/Ingestion.json +3211 -0
  408. package/schema/contracts/Ingress.json +819 -0
  409. package/schema/contracts/Invocation.json +2044 -0
  410. package/schema/contracts/LocalClient.json +6657 -0
  411. package/schema/contracts/Locale.json +654 -0
  412. package/schema/contracts/MachineIdentity.json +2303 -0
  413. package/schema/contracts/MailProvider.json +6663 -0
  414. package/schema/contracts/Memory.json +579 -0
  415. package/schema/contracts/Messaging.json +1764 -0
  416. package/schema/contracts/Metering.json +3060 -0
  417. package/schema/contracts/ModelProvider.json +1127 -0
  418. package/schema/contracts/ModuleManifest.json +9449 -0
  419. package/schema/contracts/NotificationChannel.json +986 -0
  420. package/schema/contracts/Notifications.json +4280 -0
  421. package/schema/contracts/Outbox.json +1451 -0
  422. package/schema/contracts/Privacy.json +4354 -0
  423. package/schema/contracts/Progress.json +1524 -0
  424. package/schema/contracts/QuerySurface.json +661 -0
  425. package/schema/contracts/Readiness.json +209 -0
  426. package/schema/contracts/Release.json +805 -0
  427. package/schema/contracts/ResultRendering.json +2859 -0
  428. package/schema/contracts/Sandbox.json +2286 -0
  429. package/schema/contracts/Scheduler.json +6138 -0
  430. package/schema/contracts/ScreenContext.json +1238 -0
  431. package/schema/contracts/Search.json +1058 -0
  432. package/schema/contracts/Secrets.json +2444 -0
  433. package/schema/contracts/Settings.json +654 -0
  434. package/schema/contracts/Sharing.json +2854 -0
  435. package/schema/contracts/Slot.json +537 -0
  436. package/schema/contracts/Space.json +892 -0
  437. package/schema/contracts/StorageAdapter.json +623 -0
  438. package/schema/contracts/StorageBackend.json +2421 -0
  439. package/schema/contracts/Sync.json +894 -0
  440. package/schema/contracts/Telemetry.json +696 -0
  441. package/schema/contracts/ThemeTokens.json +547 -0
  442. package/schema/contracts/ToolSource.json +1333 -0
  443. package/schema/contracts/Versioning.json +1481 -0
  444. package/schema/contracts/View.json +750 -0
  445. package/schema/contracts/WorkItems.json +1731 -0
  446. package/schema/contracts/Workflow.json +1242 -0
  447. package/src/Agent.ts +758 -0
  448. package/src/Analytics.ts +110 -0
  449. package/src/Approval.ts +131 -0
  450. package/src/Catalog.ts +192 -0
  451. package/src/Checklist.ts +162 -0
  452. package/src/Data.ts +109 -0
  453. package/src/Devices.ts +721 -0
  454. package/src/Durable.ts +240 -0
  455. package/src/Errors.ts +111 -0
  456. package/src/JsonSchema.ts +166 -0
  457. package/src/Manifest.ts +1147 -0
  458. package/src/Module.ts +640 -0
  459. package/src/Optimistic.ts +332 -0
  460. package/src/Projection.ts +207 -0
  461. package/src/Proposals.ts +89 -0
  462. package/src/Receipt.ts +125 -0
  463. package/src/Records.ts +197 -0
  464. package/src/Render.ts +515 -0
  465. package/src/Rpc.ts +113 -0
  466. package/src/SearchLanguages.ts +33 -0
  467. package/src/Service.ts +102 -0
  468. package/src/Versions.ts +69 -0
  469. package/src/contracts/ActionConsent.ts +150 -0
  470. package/src/contracts/ActionRegistry.ts +39 -0
  471. package/src/contracts/Actor.ts +53 -0
  472. package/src/contracts/AgentResources.ts +167 -0
  473. package/src/contracts/AgentRuntime.ts +154 -0
  474. package/src/contracts/Approvals.ts +133 -0
  475. package/src/contracts/Audit.ts +160 -0
  476. package/src/contracts/CalendarProvider.ts +241 -0
  477. package/src/contracts/Capability.ts +246 -0
  478. package/src/contracts/ClientSDK.ts +199 -0
  479. package/src/contracts/CollabDocument.ts +420 -0
  480. package/src/contracts/Command.ts +74 -0
  481. package/src/contracts/Connections.ts +360 -0
  482. package/src/contracts/ContextAccounting.ts +35 -0
  483. package/src/contracts/Daemon.ts +247 -0
  484. package/src/contracts/DbTx.ts +110 -0
  485. package/src/contracts/Delegation.ts +91 -0
  486. package/src/contracts/DeviceControl.ts +143 -0
  487. package/src/contracts/Directory.ts +384 -0
  488. package/src/contracts/DirectoryProvider.ts +82 -0
  489. package/src/contracts/DocumentSource.ts +71 -0
  490. package/src/contracts/Files.ts +395 -0
  491. package/src/contracts/Flags.ts +241 -0
  492. package/src/contracts/Host.ts +245 -0
  493. package/src/contracts/HttpApi.ts +100 -0
  494. package/src/contracts/Ingestion.ts +315 -0
  495. package/src/contracts/Ingress.ts +132 -0
  496. package/src/contracts/Invocation.ts +122 -0
  497. package/src/contracts/LocalClient.ts +620 -0
  498. package/src/contracts/Locale.ts +133 -0
  499. package/src/contracts/MachineIdentity.ts +305 -0
  500. package/src/contracts/MailProvider.ts +272 -0
  501. package/src/contracts/Memory.ts +47 -0
  502. package/src/contracts/Messaging.ts +108 -0
  503. package/src/contracts/Metering.ts +231 -0
  504. package/src/contracts/ModelProvider.ts +87 -0
  505. package/src/contracts/ModuleManifest.ts +310 -0
  506. package/src/contracts/NotificationChannel.ts +158 -0
  507. package/src/contracts/Notifications.ts +309 -0
  508. package/src/contracts/Outbox.ts +246 -0
  509. package/src/contracts/Privacy.ts +502 -0
  510. package/src/contracts/Progress.ts +196 -0
  511. package/src/contracts/QuerySurface.ts +134 -0
  512. package/src/contracts/Readiness.ts +67 -0
  513. package/src/contracts/Release.ts +199 -0
  514. package/src/contracts/ResultRendering.ts +65 -0
  515. package/src/contracts/Sandbox.ts +648 -0
  516. package/src/contracts/Scheduler.ts +237 -0
  517. package/src/contracts/ScreenContext.ts +316 -0
  518. package/src/contracts/Search.ts +126 -0
  519. package/src/contracts/Secrets.ts +162 -0
  520. package/src/contracts/Settings.ts +207 -0
  521. package/src/contracts/Sharing.ts +205 -0
  522. package/src/contracts/Slot.ts +61 -0
  523. package/src/contracts/Space.ts +157 -0
  524. package/src/contracts/StorageAdapter.ts +104 -0
  525. package/src/contracts/StorageBackend.ts +220 -0
  526. package/src/contracts/Sync.ts +180 -0
  527. package/src/contracts/Telemetry.ts +177 -0
  528. package/src/contracts/ThemeTokens.ts +136 -0
  529. package/src/contracts/ToolSource.ts +94 -0
  530. package/src/contracts/Versioning.ts +237 -0
  531. package/src/contracts/View.ts +116 -0
  532. package/src/contracts/WorkItems.ts +144 -0
  533. package/src/contracts/Workflow.ts +67 -0
  534. package/src/contracts/index.ts +205 -0
  535. package/src/devices/module.ts +201 -0
  536. package/src/drizzle/Entity.ts +524 -0
  537. package/src/index.ts +19 -0
package/src/Module.ts ADDED
@@ -0,0 +1,640 @@
1
+ /**
2
+ * The declarative half of a module manifest: entities, actions and events as
3
+ * language-neutral contracts (Effect Schema sources that emit JSON Schema),
4
+ * plus the declarations in `Manifest.ts` (permission vocabulary, settings,
5
+ * skills, views, slots, commands, work-item sources, entity resolvers and
6
+ * published query views). Handlers, migrations and policy text live in the
7
+ * server half (`@eloxiv/kernel`).
8
+ */
9
+ import { Schema } from "effect"
10
+ import type { RenderDeclaration } from "./Render.ts"
11
+ import type { JobContract } from "./Durable.ts"
12
+ import type { ManifestDeclarations } from "./Manifest.ts"
13
+ import type { CapabilityName } from "./contracts/Capability.ts"
14
+ import type { OptimisticEffect } from "./Optimistic.ts"
15
+ import type { Surface } from "./Records.ts"
16
+
17
+ /** Cedar primitive types a column can hold. */
18
+ export type CedarScalarType = "String" | "Long" | "Boolean"
19
+
20
+ /**
21
+ * How a Cedar attribute on an entity maps onto storage, for the policy compiler
22
+ * and the generated Cedar schema. Types are explicit so a comparison between
23
+ * different types compiles to Cedar's answer (false), never to a column match.
24
+ */
25
+ export type PolicyAttribute =
26
+ /** A column holding a Cedar primitive. */
27
+ | { readonly kind: "column"; readonly field: string; readonly type: CedarScalarType }
28
+ /** A column holding the id of an entity of `entityType`, e.g. `Eloxiv::User`. */
29
+ | { readonly kind: "column"; readonly field: string; readonly type: "Entity"; readonly entityType: string }
30
+ /** A `Set<Eloxiv::User>` of principals granted `permission` per record through the kernel Sharing contract. */
31
+ | { readonly kind: "sharing"; readonly permission: string }
32
+
33
+ /**
34
+ * How a field travels in sync and in the published row schema: Zero's four column types (a timestamp is epoch
35
+ * milliseconds, an array is JSON), or `null` for a column sync cannot represent exactly (such an entity cannot
36
+ * be synced).
37
+ */
38
+ export type FieldType = "string" | "number" | "boolean" | "json"
39
+
40
+ /** One field of an entity, derived from its Drizzle column (decision 9: the table is the only declaration). */
41
+ export interface EntityField {
42
+ /** The database column. */
43
+ readonly column: string
44
+ readonly type: FieldType | null
45
+ /** The column admits NULL (Drizzle's `notNull` is absent). A primary key never does. */
46
+ readonly nullable: boolean
47
+ /** The values a string column is limited to (Drizzle's `enum`), if any. */
48
+ readonly enum?: ReadonlyArray<string> | undefined
49
+ /**
50
+ * The column's Postgres type as Drizzle declares it (`text`, `timestamp with time zone`, `integer[]`, a Postgres
51
+ * enum's name, ...). Setup checks the database's column has exactly this type.
52
+ */
53
+ readonly sqlType: string
54
+ /**
55
+ * The range a synced column of this type is held to, because sync carries the type exactly only inside it
56
+ * (`@eloxiv/contracts/drizzle`'s `SyncGuard`): setup installs it as a CHECK constraint.
57
+ */
58
+ readonly guard?:
59
+ | "safe-integer"
60
+ | "finite-double"
61
+ | "instant"
62
+ | "instant-ms"
63
+ | "date"
64
+ | "json-doubles"
65
+ | "plain-array"
66
+ | undefined
67
+ /** A generated column (`GENERATED ALWAYS AS ... STORED`): Postgres does not publish it, so it never syncs. */
68
+ readonly generated?: true | undefined
69
+ }
70
+
71
+ /**
72
+ * A Drizzle relation of an entity's table (decision 9), for `related()` and `whereExists()`: `one` names the
73
+ * fields that hold the referenced record's key (`references`); `many` is the other side of a `one` relation of
74
+ * the referenced entity's table (`table`) back to this one.
75
+ */
76
+ export type EntityRelationship =
77
+ | {
78
+ readonly name: string
79
+ readonly cardinality: "one"
80
+ readonly table: string
81
+ readonly fields: ReadonlyArray<string>
82
+ readonly references: ReadonlyArray<string>
83
+ /** Pairs it with the `many` of the same name on the other table, when two relations join the same tables. */
84
+ readonly relationName?: string
85
+ }
86
+ | { readonly name: string; readonly cardinality: "many"; readonly table: string; readonly relationName?: string }
87
+
88
+ /**
89
+ * What of an entity syncs to replicas: the Zero table's client name and the fields it carries (the primary key
90
+ * always among them). `false`: the entity is not synced, and the kernel refuses a sync table over it.
91
+ */
92
+ export type EntitySync = false | { readonly name: string; readonly fields: ReadonlyArray<string> }
93
+
94
+ /**
95
+ * An entity: the record a module stores, as the kernel and the published manifest see it. Everything about its
96
+ * fields (names, columns, types, nullability, the row schema) is derived from the module's Drizzle table by
97
+ * `defineEntity` in `@eloxiv/contracts/drizzle`; this interface is the language-neutral result.
98
+ */
99
+ export interface EntityContract<
100
+ Name extends string = string,
101
+ Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
102
+ > {
103
+ readonly name: Name
104
+ /** Cedar entity type, e.g. `Hello::Greeting`. */
105
+ readonly cedarType: string
106
+ /** Postgres location; the schema is owned by the module's role. */
107
+ readonly table: { readonly schema: string; readonly name: string }
108
+ readonly primaryKey: keyof Fields & string
109
+ /** Row shape, camelCase (what sync delivers: timestamps as epoch milliseconds). */
110
+ readonly row: Schema.Struct<Fields>
111
+ /** Field name to database column. */
112
+ readonly columns: { readonly [K in keyof Fields]: string }
113
+ /** Each field's column, transport type and nullability. */
114
+ readonly storage: { readonly [K in keyof Fields]: EntityField }
115
+ /** Cedar attribute name to storage, used to compile policy into SQL and sync filters. */
116
+ readonly policyAttributes: Readonly<Record<string, PolicyAttribute>>
117
+ /**
118
+ * Keep an append-only history of every change actions make to this entity's records (the Versioning
119
+ * contract), readable through the record's own read policy and restorable through a module action.
120
+ */
121
+ readonly history?: boolean | undefined
122
+ /** What syncs: the generated Zero table's name and fields. */
123
+ readonly sync: EntitySync
124
+ /** The table's unique keys besides the primary key (field names), from its Drizzle declaration. */
125
+ readonly uniqueKeys: ReadonlyArray<ReadonlyArray<string>>
126
+ /** The Drizzle relations the entity names. */
127
+ readonly relationships: ReadonlyArray<EntityRelationship>
128
+ /** Full-text search over the entity's records (the Search contract). */
129
+ readonly search?: EntitySearch | undefined
130
+ /** Files attached to the entity's records (the Files contract); without it, none can be. */
131
+ readonly files?: EntityFiles | undefined
132
+ /** Each record has a collaborative (Yjs) document (the CollabDocument contract); without it, none. */
133
+ readonly collab?: EntityCollab | undefined
134
+ }
135
+ export type AnyEntity = EntityContract<string, any>
136
+
137
+ /**
138
+ * An entity's records are searchable (the Search contract): the kernel indexes these string fields, with their
139
+ * weights (A ranks highest), in the same transaction as every write, and filters every hit by the entity's read
140
+ * policy. `title` is the field a hit shows as its title (default: the first field weighted A); `language` the
141
+ * PostgreSQL text search configuration (default `simple`, which does not stem).
142
+ */
143
+ export interface EntitySearch {
144
+ readonly fields: Readonly<Record<string, "A" | "B" | "C" | "D">>
145
+ readonly title?: string | undefined
146
+ readonly language?: string | undefined
147
+ }
148
+
149
+ /**
150
+ * The entity's records accept files (the Files contract). Who may attach, replace and delete them is the
151
+ * entity's Cedar policy for the kernel's action `attach`; who may read them, its `read` policy.
152
+ */
153
+ export interface EntityFiles {
154
+ /** The largest file, in bytes (never above the deployment's limit, which is the default). */
155
+ readonly maxBytes?: number | undefined
156
+ /** Accepted media types, exact (`application/pdf`) or by type (`image/*`). Default: any but executables. */
157
+ readonly types?: ReadonlyArray<string> | undefined
158
+ /** Ingest attached files into search (the Ingestion contract) once they are available. */
159
+ readonly ingest?: boolean | undefined
160
+ }
161
+
162
+ /**
163
+ * Each record of the entity has one collaborative document (the CollabDocument contract): a Yjs document the
164
+ * kernel stores, merges and serves. Who may read it is the entity's `read` policy; who may change it (updates,
165
+ * agent edits, restores) is its Cedar policy for the kernel's action `collaborate`. Without a `collaborate`
166
+ * policy the document is read-only. The limits fail closed: an update that would pass them is refused.
167
+ */
168
+ export interface EntityCollab {
169
+ /** The largest the merged document may grow, in bytes (default 2 MiB, at most 16 MiB). */
170
+ readonly maxBytes?: number | undefined
171
+ /** The largest single update, in bytes (default 256 KiB, at most `maxBytes`). */
172
+ readonly maxUpdateBytes?: number | undefined
173
+ /** Updates one person may apply to one document per minute (default 1200). */
174
+ readonly updatesPerMinute?: number | undefined
175
+ /** The Y.Text an agent reads and edits when it names none (default `content`). */
176
+ readonly text?: string | undefined
177
+ }
178
+
179
+ export interface ActionContract<
180
+ Name extends string = string,
181
+ Input extends Schema.Top = Schema.Top,
182
+ Output extends Schema.Top = Schema.Top,
183
+ > {
184
+ readonly _tag: "ActionContract"
185
+ readonly name: Name
186
+ /** Local action id inside the module's Cedar namespace, e.g. `greet` for `Hello::Action::"greet"`. */
187
+ readonly cedarAction: string
188
+ /**
189
+ * What people see the action called (a consent or approval prompt, a notification, a tool call in a chat): a short
190
+ * verb phrase such as "Send an email". `defineAction` falls back to `readableActionName(name)` when none is given.
191
+ */
192
+ readonly title: string
193
+ readonly description: string
194
+ readonly input: Input
195
+ readonly output: Output
196
+ /**
197
+ * The entity this action writes. The kernel authorises the written row against
198
+ * the action's compiled policy filter inside the transaction (like RLS `WITH CHECK`).
199
+ * The output must then carry the written row's primary key as `id`.
200
+ */
201
+ readonly writes?: string | undefined
202
+ /**
203
+ * The existing record the action acts on: `input[field]` is the primary key of
204
+ * an `entity` row. The kernel authorises that row against the action's policy
205
+ * before the handler runs.
206
+ */
207
+ readonly target?: { readonly entity: string; readonly field: string } | undefined
208
+ /**
209
+ * Further entities the action inserts or updates besides `writes` and `target` (for example a child
210
+ * record it creates with its parent). The action's policy grants access only to the tables of the entities
211
+ * it declares (`writes`, `target` and these): on every other table it grants nothing, whatever the policy
212
+ * says, so an action declaring no entity can read only what the read policy allows.
213
+ */
214
+ readonly actsOn: ReadonlyArray<string>
215
+ /**
216
+ * `true`: the action may act on any record of its declared entities in the acting organisation, so its
217
+ * policy may leave the resource unconstrained; the kernel confines it to records whose organisation is the
218
+ * acting organisation. `false` (the default): startup refuses a policy that would let the action reach
219
+ * records not tied to the actor (by organisation, by a user field, or by a sharing grant).
220
+ */
221
+ readonly organisationWide: boolean
222
+ /**
223
+ * The default (`false`): an action with a target must affect exactly its declared
224
+ * target(s), or it fails as Forbidden and rolls back. `true`: targets it may not
225
+ * change are skipped; the output then carries `BestEffortFields` (affected,
226
+ * requested, completion), set by the kernel, and so does the audit record.
227
+ */
228
+ readonly bestEffort: boolean
229
+ readonly hints: {
230
+ readonly readOnly: boolean
231
+ readonly destructive: boolean
232
+ readonly idempotent: boolean
233
+ }
234
+ /**
235
+ * Whether an agent acting for a person needs that person's consent for each call (the ActionConsent
236
+ * contract): an agent-originated call is held, bound to its exact prepared input, until the person approves
237
+ * it or a permission they remembered covers it. Calls a person makes themselves are not held. Defaults to
238
+ * `hints.destructive`.
239
+ */
240
+ readonly consent: boolean
241
+ /**
242
+ * With `consent`: every agent call needs the person's approval of that exact call; a permission they remembered
243
+ * ("always", or for the session) never covers it. For actions whose calls differ in kind, not only in input:
244
+ * each message sent is a new message.
245
+ */
246
+ readonly consentEachCall: boolean
247
+ /**
248
+ * The capability operations the handler may call through `ctx.connections`, by capability (`{ mail:
249
+ * ["getMessage"] }`); the kernel refuses every other. An `external` operation may only be scheduled
250
+ * (`ctx.connections.schedule`, after commit), and only by an action that needs consent.
251
+ */
252
+ readonly connections: Readonly<Record<string, ReadonlyArray<string>>>
253
+ /**
254
+ * The change the action predicts on a client's replica (`optimistic.insert`, `update`, `delete` or `custom`,
255
+ * from `Optimistic.ts`), from which `eloxiv generate` writes its mutator (for `custom`, wiring in the module's own
256
+ * prediction from its `predictions.ts`): a client applies it at once and the server's result replaces it. Only
257
+ * actions that declare one are reachable through sync's push (`/zero/mutate`). The prediction never runs on the
258
+ * server.
259
+ */
260
+ readonly optimistic: OptimisticEffect | undefined
261
+ /** How the output is shown to people and agents (the ResultRendering contract); checked against `output`. */
262
+ readonly render?: RenderDeclaration | undefined
263
+ /**
264
+ * Which surfaces offer the action, each on its own (all by default): `agent`, the app's own agent (its tools);
265
+ * `mcp`, external agents over MCP; `api`, the typed client, HTTP, the CLI and sync's push. A surface that does
266
+ * not offer it neither lists it nor runs a call to it (`Forbidden`, audited). Exposure is discovery, not
267
+ * authorisation: the policy, consent and approvals decide as on every surface, and trusted in-process callers
268
+ * (workflows, schedules, inbound webhooks) reach it whatever it says.
269
+ */
270
+ readonly exposure: ActionExposure
271
+ /**
272
+ * An untargeted writing action (`writes`, no `target`) whose output carries `WrittenFields`: the kernel sets
273
+ * `written` to what the call inserted and updated (its receipt always has it). Rows row-level security kept it
274
+ * from are never counted: the caller learns what happened, never what it could not see.
275
+ */
276
+ readonly reportsWritten: boolean
277
+ }
278
+ export type AnyAction = ActionContract
279
+
280
+ /** Which surfaces offer an action (`ActionContract.exposure`). */
281
+ export interface ActionExposure {
282
+ readonly agent: boolean
283
+ readonly mcp: boolean
284
+ readonly api: boolean
285
+ }
286
+ export const ALL_SURFACES_EXPOSURE: ActionExposure = { agent: true, mcp: true, api: true }
287
+
288
+ /**
289
+ * Does `surface` offer `action` (`ActionContract.exposure`)? The trusted in-process surfaces (workflow steps,
290
+ * scheduled runs, inbound webhooks' executions, kernel-internal calls) always do.
291
+ */
292
+ export const exposedOn = (action: AnyAction, surface: Surface): boolean => {
293
+ switch (surface) {
294
+ case "agent":
295
+ return action.exposure.agent
296
+ case "mcp":
297
+ return action.exposure.mcp
298
+ case "rpc":
299
+ case "http":
300
+ case "cli":
301
+ case "sync":
302
+ return action.exposure.api
303
+ default:
304
+ return true
305
+ }
306
+ }
307
+
308
+ /**
309
+ * Output fields every best-effort action returns: how many of its declared
310
+ * targets it affected and whether that was all of them. The kernel sets them.
311
+ */
312
+ /**
313
+ * The output field an untargeted writing action that `reportsWritten` returns: what the call wrote (`WrittenCounts`),
314
+ * set by the kernel, never the handler.
315
+ */
316
+ export const WrittenFields = {
317
+ written: Schema.Struct({ inserted: Schema.Number, updated: Schema.Number }),
318
+ } as const
319
+
320
+ export const BestEffortFields = {
321
+ affected: Schema.Number,
322
+ requested: Schema.Number,
323
+ completion: Schema.Literals(["complete", "partial"]),
324
+ } as const
325
+
326
+ export interface EventContract<Type extends string = string, Payload extends Schema.Top = Schema.Top> {
327
+ readonly _tag: "EventContract"
328
+ readonly type: Type
329
+ readonly payload: Payload
330
+ /**
331
+ * The record the event is about: one of the module's entities (by name) and the payload field holding its id.
332
+ * Only an event that names its record can start members' event automations (the Scheduler contract), and each
333
+ * automation sees it only while its owner may read that record.
334
+ */
335
+ readonly record?: EventRecord | undefined
336
+ }
337
+
338
+ /** The record an event is about (`defineEvent(type, payload, { record })`). */
339
+ export interface EventRecord {
340
+ readonly entity: string
341
+ readonly id: string
342
+ }
343
+ export type AnyEvent = EventContract
344
+
345
+ export interface ModuleContract<
346
+ Name extends string = string,
347
+ Actions extends Readonly<Record<string, AnyAction>> = Readonly<Record<string, AnyAction>>,
348
+ Events extends Readonly<Record<string, AnyEvent>> = Readonly<Record<string, AnyEvent>>,
349
+ Entities extends Readonly<Record<string, AnyEntity>> = Readonly<Record<string, AnyEntity>>,
350
+ > extends ManifestDeclarations {
351
+ readonly _tag: "ModuleContract"
352
+ readonly name: Name
353
+ readonly version: string
354
+ /** Cedar namespace for this module's entity types and actions, e.g. `Hello`. */
355
+ readonly cedarNamespace: string
356
+ readonly actions: Actions
357
+ readonly events: Events
358
+ readonly entities: Entities
359
+ /** Scheduled jobs (the Scheduler contract), by job id. */
360
+ readonly jobs: Readonly<Record<string, JobContract>>
361
+ /**
362
+ * The kernel versions this module works with (the Versioning contract), a range such as `>=0.1.0 <2.0.0` or
363
+ * `^1.2.0`. Setup refuses the module on a kernel outside it. Omitted: any.
364
+ */
365
+ readonly kernel?: string | undefined
366
+ }
367
+ export type AnyModuleContract = ModuleContract<string, any, any, any>
368
+
369
+ /**
370
+ * A readable form of an action's name, for an action that gives no `title` (and for requests recorded before titles
371
+ * were): the local part split into words, sentence-cased, with the module in parentheses (`mail.send` is
372
+ * "Send (mail)", `agent.moveResources` "Move resources (agent)"). Never the raw id. The kernel's migrations backfill
373
+ * consent and approval requests with the same words (`0003_title.sql`), and the Rune host repeats it for rows of an
374
+ * older kernel.
375
+ */
376
+ export const readableActionName = (name: string): string => {
377
+ const dot = name.indexOf(".")
378
+ const module = dot < 0 ? "" : name.slice(0, dot)
379
+ const words = readableWords(dot < 0 ? name : name.slice(dot + 1))
380
+ const phrase = words === "" ? name : words
381
+ return module === "" ? phrase : `${phrase} (${module})`
382
+ }
383
+
384
+ /** An action's local name as sentence-cased words (`moveResources` is "Move resources"), or "" when it has none. */
385
+ const readableWords = (local: string): string => {
386
+ const words = local
387
+ .replace(/([a-z0-9])([A-Z])/gu, "$1 $2")
388
+ .replace(/[._-]+/gu, " ")
389
+ .trim()
390
+ .toLowerCase()
391
+ return words === "" ? "" : words.charAt(0).toUpperCase() + words.slice(1)
392
+ }
393
+
394
+ /** The most characters an action's title may have: one short line, what a prompt, a subject or a push shows. */
395
+ export const ACTION_TITLE_MAX = 80
396
+
397
+ const LINE_BREAKS_AND_CONTROLS = /[\p{Cc}\u2028\u2029]/u
398
+
399
+ /**
400
+ * Why `title` cannot be an action's title (more than one line, a control character, longer than
401
+ * `ACTION_TITLE_MAX`), or undefined when it can. `defineAction` and MAKE manifest validation refuse such a title.
402
+ */
403
+ export const actionTitleProblem = (title: string): string | undefined =>
404
+ LINE_BREAKS_AND_CONTROLS.test(title)
405
+ ? "a title is one line, without line breaks or control characters"
406
+ : Array.from(title).length > ACTION_TITLE_MAX
407
+ ? `a title has at most ${ACTION_TITLE_MAX} characters`
408
+ : undefined
409
+
410
+ /**
411
+ * A title as one bounded line: line breaks and control characters become spaces, runs of spaces one, and a title
412
+ * longer than `ACTION_TITLE_MAX` is cut with an ellipsis. For titles recorded before the limit (a MAKE module version
413
+ * installed earlier, a request held then), wherever a generated subject or prompt uses one.
414
+ */
415
+ export const boundTitle = (title: string): string => {
416
+ const line = title.replace(new RegExp(LINE_BREAKS_AND_CONTROLS.source, "gu"), " ").replace(/\s+/gu, " ").trim()
417
+ const chars = Array.from(line)
418
+ return chars.length <= ACTION_TITLE_MAX
419
+ ? line
420
+ : `${chars
421
+ .slice(0, ACTION_TITLE_MAX - 1)
422
+ .join("")
423
+ .trimEnd()}…`
424
+ }
425
+
426
+ /** What people see an action called: its recorded title when there is one, otherwise its readable name; one line. */
427
+ export const actionLabel = (action: string, title?: string | null): string =>
428
+ boundTitle(title !== undefined && title !== null && title.trim() !== "" ? title : readableActionName(action))
429
+
430
+ /**
431
+ * What a person deciding on a call of `action` sees it called: `actionLabel`, except for a MAKE module's action
432
+ * (`mk_…`), whose authored title is the untrusted module's own words: there it is always `makeDecisionLabel` of the
433
+ * id (the module first, never cut). Clients rendering stored requests and events use it too, so a title recorded
434
+ * before is ignored for a MAKE action. Consent and approval records, their push, email and work items use it, so an installed module cannot
435
+ * describe a consequential call as a harmless one.
436
+ */
437
+ export const decisionLabel = (action: string, title?: string | null): string =>
438
+ action.startsWith("mk_") ? makeDecisionLabel(action) : actionLabel(action, title)
439
+
440
+ /**
441
+ * A MAKE module's action as a person deciding on it sees it called: the module's immutable id first, never cut, then
442
+ * the action's readable words (`mk_todos.urgent` is "mk_todos: Urgent"), only the words cut with an ellipsis so the
443
+ * label fits `ACTION_TITLE_MAX`. Computed from the id alone: a stored title (the module's own words, or a label
444
+ * recorded before this form) is never shown for one.
445
+ */
446
+ export const makeDecisionLabel = (action: string): string => {
447
+ const dot = action.indexOf(".")
448
+ const module = dot < 0 ? action : action.slice(0, dot)
449
+ const words = dot < 0 ? "" : readableWords(action.slice(dot + 1))
450
+ const room = ACTION_TITLE_MAX - Array.from(module).length - 2
451
+ if (words === "" || room < 2) return module
452
+ const chars = Array.from(words)
453
+ const fitted =
454
+ chars.length <= room
455
+ ? words
456
+ : `${chars
457
+ .slice(0, room - 1)
458
+ .join("")
459
+ .trimEnd()}…`
460
+ return `${module}: ${fitted}`
461
+ }
462
+
463
+ export const defineAction = <const Name extends string, Input extends Schema.Top, Output extends Schema.Top>(action: {
464
+ readonly name: Name
465
+ /** What people see the action called (see `ActionContract.title`); omitted: `readableActionName(name)`. */
466
+ readonly title?: string
467
+ readonly description: string
468
+ readonly input: Input
469
+ readonly output: Output
470
+ readonly writes?: string
471
+ readonly target?: { readonly entity: string; readonly field: string }
472
+ readonly actsOn?: ReadonlyArray<string>
473
+ readonly organisationWide?: boolean
474
+ readonly bestEffort?: boolean
475
+ readonly hints?: Partial<ActionContract["hints"]>
476
+ /** `true`, or `"each-call"`: remembered permissions never cover a call (see `consentEachCall`). */
477
+ readonly consent?: boolean | "each-call"
478
+ /** The capability operations the handler may call (see `ActionContract.connections`). */
479
+ readonly connections?: Readonly<Partial<Record<CapabilityName, ReadonlyArray<string>>>>
480
+ readonly optimistic?: OptimisticEffect
481
+ readonly render?: RenderDeclaration
482
+ /** Surfaces that do not offer the action (see `ActionContract.exposure`); omitted ones do. */
483
+ readonly exposure?: Partial<ActionExposure>
484
+ /** See `ActionContract.reportsWritten`. */
485
+ readonly reportsWritten?: boolean
486
+ }): ActionContract<Name, Input, Output> => {
487
+ const problem = action.title === undefined ? undefined : actionTitleProblem(action.title)
488
+ if (problem !== undefined) throw new Error(`Action ${action.name}'s title is not valid: ${problem}`)
489
+ return {
490
+ _tag: "ActionContract",
491
+ name: action.name,
492
+ cedarAction: action.name.slice(action.name.indexOf(".") + 1),
493
+ title: actionLabel(action.name, action.title),
494
+ description: action.description,
495
+ input: action.input,
496
+ output: action.output,
497
+ writes: action.writes,
498
+ target: action.target,
499
+ actsOn: action.actsOn ?? [],
500
+ organisationWide: action.organisationWide ?? false,
501
+ bestEffort: action.bestEffort ?? false,
502
+ hints: { readOnly: false, destructive: false, idempotent: false, ...action.hints },
503
+ consent: action.consent === "each-call" ? true : (action.consent ?? action.hints?.destructive ?? false),
504
+ consentEachCall: action.consent === "each-call",
505
+ connections: Object.fromEntries(
506
+ Object.entries(action.connections ?? {}).map(([capability, operations]) => [capability, [...(operations ?? [])]]),
507
+ ),
508
+ optimistic: action.optimistic,
509
+ ...(action.render === undefined ? {} : { render: action.render }),
510
+ exposure: { ...ALL_SURFACES_EXPOSURE, ...action.exposure },
511
+ reportsWritten: action.reportsWritten ?? false,
512
+ }
513
+ }
514
+
515
+ export const defineEvent = <const Type extends string, Payload extends Schema.Top>(
516
+ type: Type,
517
+ payload: Payload,
518
+ options: { readonly record?: EventRecord | undefined } = {},
519
+ ): EventContract<Type, Payload> => ({
520
+ _tag: "EventContract",
521
+ type,
522
+ payload,
523
+ ...(options.record === undefined ? {} : { record: options.record }),
524
+ })
525
+
526
+ export const defineModuleContract = <
527
+ const Name extends string,
528
+ const Actions extends Readonly<Record<string, AnyAction>>,
529
+ const Events extends Readonly<Record<string, AnyEvent>>,
530
+ const Entities extends Readonly<Record<string, AnyEntity>>,
531
+ >(
532
+ module: {
533
+ readonly name: Name
534
+ readonly version: string
535
+ readonly cedarNamespace: string
536
+ readonly actions: Actions
537
+ readonly events: Events
538
+ readonly entities: Entities
539
+ readonly jobs?: Readonly<Record<string, JobContract>>
540
+ readonly kernel?: string | undefined
541
+ } & Partial<ManifestDeclarations>,
542
+ ): ModuleContract<Name, Actions, Events, Entities> => {
543
+ for (const action of Object.values(module.actions)) {
544
+ if (!action.name.startsWith(`${module.name}.`)) {
545
+ throw new Error(`Action ${action.name} must be namespaced by its module (${module.name}.*)`)
546
+ }
547
+ }
548
+ return moduleContract(module)
549
+ }
550
+
551
+ /** The namespace of the kernel's own actions (`eloxiv.query`); no installable module may take it. */
552
+ export const KERNEL_NAMESPACE = "eloxiv"
553
+
554
+ /**
555
+ * The kernel's own modules only: like `defineModuleContract`, but its actions are namespaced `eloxiv.*`, the
556
+ * kernel's (the query surface's `eloxiv.query`). The module itself has an ordinary name, schema and roles.
557
+ */
558
+ export const defineKernelModuleContract = <
559
+ const Name extends string,
560
+ const Actions extends Readonly<Record<string, AnyAction>>,
561
+ const Events extends Readonly<Record<string, AnyEvent>>,
562
+ const Entities extends Readonly<Record<string, AnyEntity>>,
563
+ >(
564
+ module: {
565
+ readonly name: Name
566
+ readonly version: string
567
+ readonly cedarNamespace: string
568
+ readonly actions: Actions
569
+ readonly events: Events
570
+ readonly entities: Entities
571
+ } & Partial<ManifestDeclarations>,
572
+ ): ModuleContract<Name, Actions, Events, Entities> => {
573
+ for (const action of Object.values(module.actions)) {
574
+ if (!action.name.startsWith(`${KERNEL_NAMESPACE}.`)) {
575
+ throw new Error(`Kernel action ${action.name} must be namespaced ${KERNEL_NAMESPACE}.*`)
576
+ }
577
+ }
578
+ return moduleContract(module)
579
+ }
580
+
581
+ const moduleContract = <
582
+ const Name extends string,
583
+ const Actions extends Readonly<Record<string, AnyAction>>,
584
+ const Events extends Readonly<Record<string, AnyEvent>>,
585
+ const Entities extends Readonly<Record<string, AnyEntity>>,
586
+ >(
587
+ module: {
588
+ readonly name: Name
589
+ readonly version: string
590
+ readonly cedarNamespace: string
591
+ readonly actions: Actions
592
+ readonly events: Events
593
+ readonly entities: Entities
594
+ readonly jobs?: Readonly<Record<string, JobContract>>
595
+ readonly kernel?: string | undefined
596
+ } & Partial<ManifestDeclarations>,
597
+ ): ModuleContract<Name, Actions, Events, Entities> => {
598
+ // The declarations (and jobs) are checked together, across every installed module, when the kernel builds
599
+ // its registry (`manifestProblems`), so one report lists every problem of an app.
600
+ return {
601
+ permissions: {},
602
+ settings: {},
603
+ flags: {},
604
+ skills: {},
605
+ views: {},
606
+ slots: {},
607
+ contributions: {},
608
+ commands: {},
609
+ workItemSources: {},
610
+ entityResolvers: {},
611
+ queryViews: {},
612
+ approvalRules: {},
613
+ toolGroups: {},
614
+ dataSubjects: {},
615
+ analyticsEvents: {},
616
+ ...module,
617
+ jobs: module.jobs ?? {},
618
+ _tag: "ModuleContract",
619
+ }
620
+ }
621
+
622
+ /** The union of action contracts across a list of module contracts. */
623
+ export type ActionsOf<Modules extends ReadonlyArray<AnyModuleContract>> = {
624
+ [I in keyof Modules]: Modules[I]["actions"][keyof Modules[I]["actions"]]
625
+ }[number]
626
+
627
+ /** All action contracts of the given modules, keyed by action name. */
628
+ export const actionRegistry = (modules: ReadonlyArray<AnyModuleContract>): ReadonlyMap<string, AnyAction> => {
629
+ const registry = new Map<string, AnyAction>()
630
+ for (const module of modules) {
631
+ for (const action of Object.values(module.actions) as ReadonlyArray<AnyAction>) {
632
+ if (registry.has(action.name)) throw new Error(`Duplicate action ${action.name}`)
633
+ registry.set(action.name, action)
634
+ }
635
+ }
636
+ return registry
637
+ }
638
+
639
+ /** Tool-safe name for MCP and agent tools (`hello.greet` -> `hello_greet`). */
640
+ export const toolName = (actionName: string): string => actionName.replaceAll(".", "_")