@eloxiv/contracts 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +878 -0
  204. package/dist/contracts/LocalClient.d.ts.map +1 -0
  205. package/dist/contracts/LocalClient.js +423 -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 +1295 -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 +6642 -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 +614 -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
@@ -0,0 +1,648 @@
1
+ /**
2
+ * Sandbox: running untrusted code (MAKE modules' handlers, subscribers and views) with no ambient authority, under
3
+ * memory, stack, time, step and output limits. The only things such code can do are the host functions the
4
+ * caller grants it, each of which the caller checks against the code's capability profile.
5
+ *
6
+ * Also the MAKE module source (the language-neutral manifest of a module made by a person or the agent, with its
7
+ * capability profile, migrations, code and optional view) and the view runtime's message protocol: a MAKE view
8
+ * renders only in a sandboxed iframe, and talks to its shell host only through these messages.
9
+ *
10
+ * Documented in docs/contracts/sandbox.md; conformance kit `@eloxiv/testing/conformance/Sandbox`.
11
+ */
12
+ import { Effect, Schema } from "effect"
13
+ import { defineServiceContract } from "../Service.ts"
14
+ import { Forbidden, InvalidInput, Unauthenticated } from "../Errors.ts"
15
+ import { ProgramRun, RunProgram } from "../Data.ts"
16
+ import { DataSubjectDeclarationDocument } from "./ModuleManifest.ts"
17
+ import { COLOR_TOKENS } from "./ThemeTokens.ts"
18
+
19
+ // ---------------------------------------------------------------------------------------------------------
20
+ // Running code
21
+
22
+ /**
23
+ * What one run may use. Each is a ceiling the run is stopped at, never a target. `steps` counts the
24
+ * interpreter's interrupt checks (QuickJS polls its interrupt handler every few thousand bytecode operations), so
25
+ * it bounds computation independently of wall time; `timeMs` bounds the whole run, host calls included.
26
+ */
27
+ export const SandboxLimits = Schema.Struct({
28
+ /** Wall-clock time for the whole run, host calls included (ms). */
29
+ timeMs: Schema.Int.check(Schema.isGreaterThan(0)),
30
+ /** The interpreter's heap (bytes). */
31
+ memoryBytes: Schema.Int.check(Schema.isGreaterThan(0)),
32
+ /** The interpreter's stack (bytes). */
33
+ stackBytes: Schema.Int.check(Schema.isGreaterThan(0)),
34
+ /** Interrupt checks (about one per few thousand bytecode operations). */
35
+ steps: Schema.Int.check(Schema.isGreaterThan(0)),
36
+ /** Host function calls. */
37
+ hostCalls: Schema.Int.check(Schema.isGreaterThan(0)),
38
+ /** The JSON of the result, and of each host call's arguments (bytes). */
39
+ outputBytes: Schema.Int.check(Schema.isGreaterThan(0)),
40
+ })
41
+ export type SandboxLimits = typeof SandboxLimits.Type
42
+
43
+ /** The defaults, and the ceilings no capability profile may raise a limit above. */
44
+ export const SANDBOX_DEFAULT_LIMITS: SandboxLimits = {
45
+ timeMs: 2_000,
46
+ memoryBytes: 16 * 1024 * 1024,
47
+ stackBytes: 256 * 1024,
48
+ steps: 20_000,
49
+ hostCalls: 200,
50
+ outputBytes: 1024 * 1024,
51
+ }
52
+ export const SANDBOX_MAX_LIMITS: SandboxLimits = {
53
+ timeMs: 10_000,
54
+ memoryBytes: 64 * 1024 * 1024,
55
+ // A deeper interpreter stack can overflow the host's own stack first (Node's, under WebAssembly).
56
+ stackBytes: 256 * 1024,
57
+ steps: 200_000,
58
+ hostCalls: 1_000,
59
+ outputBytes: 4 * 1024 * 1024,
60
+ }
61
+
62
+ /** What a run used. */
63
+ export const SandboxUsage = Schema.Struct({
64
+ wallMs: Schema.Number,
65
+ steps: Schema.Int,
66
+ hostCalls: Schema.Int,
67
+ })
68
+ export type SandboxUsage = typeof SandboxUsage.Type
69
+
70
+ export const SandboxRun = Schema.Struct({
71
+ /** An ES module. It can import nothing; its exports are what the run may call. */
72
+ code: Schema.String,
73
+ /** The function to call: an export, or a dotted path into one (`actions.add`). */
74
+ entry: Schema.String,
75
+ /** Its arguments, as JSON. Host functions are reached through the global `eloxiv` object, never an argument. */
76
+ args: Schema.Array(Schema.Json),
77
+ /** The host functions the code may call (`eloxiv.<name>(...)`); the caller implements and checks each. */
78
+ capabilities: Schema.Array(Schema.String),
79
+ limits: Schema.optionalKey(SandboxLimits),
80
+ })
81
+ export type SandboxRun = typeof SandboxRun.Type
82
+
83
+ export const SandboxResult = Schema.Struct({
84
+ /** What the entry returned (or resolved to), as JSON; `null` for `undefined`. */
85
+ value: Schema.Json,
86
+ usage: SandboxUsage,
87
+ })
88
+ export type SandboxResult = typeof SandboxResult.Type
89
+
90
+ /** The run was stopped at a limit; nothing it was doing continued. */
91
+ export class SandboxLimitExceeded extends Schema.TaggedError<SandboxLimitExceeded>()("SandboxLimitExceeded", {
92
+ limit: Schema.Literals(["time", "memory", "stack", "steps", "hostCalls", "output"]),
93
+ message: Schema.String,
94
+ }) {}
95
+
96
+ /** The code did not compile, threw, rejected, has no such entry, or never settled. */
97
+ export class SandboxCodeFailed extends Schema.TaggedError<SandboxCodeFailed>()("SandboxCodeFailed", {
98
+ message: Schema.String,
99
+ }) {}
100
+
101
+ /**
102
+ * The code asked for something its capability profile does not grant (a host function it was not given, a table,
103
+ * an event, an action or a setting outside its profile, or a statement the SQL host refuses). The run fails even
104
+ * if the code caught the refusal: nothing outside the profile ever runs, and the attempt is reported.
105
+ */
106
+ export class SandboxCapabilityRefused extends Schema.TaggedError<SandboxCapabilityRefused>()(
107
+ "SandboxCapabilityRefused",
108
+ { capability: Schema.String, message: Schema.String },
109
+ ) {}
110
+
111
+ /**
112
+ * Every interpreter was busy for as long as the run could wait (or, for a run that may not wait, at once): nothing
113
+ * ran. Try again later.
114
+ */
115
+ export class SandboxBusy extends Schema.TaggedError<SandboxBusy>()("SandboxBusy", {
116
+ message: Schema.String,
117
+ }) {}
118
+
119
+ export const SandboxError = Schema.Union([
120
+ SandboxLimitExceeded,
121
+ SandboxCodeFailed,
122
+ SandboxCapabilityRefused,
123
+ SandboxBusy,
124
+ ])
125
+ export type SandboxError = typeof SandboxError.Type
126
+
127
+ export const SandboxCheck = Schema.Struct({ code: Schema.String })
128
+ export const SandboxCheckResult = Schema.Struct({
129
+ /** The module's exports: its own names and, for exported objects, their function members (`actions.add`). */
130
+ exports: Schema.Array(Schema.String),
131
+ })
132
+
133
+ // ---------------------------------------------------------------------------------------------------------
134
+ // The capability profile and the MAKE module source
135
+
136
+ /** A list of names a source may leave out, when it has none (decoded as the empty list: nothing allowed). */
137
+ const Names = Schema.Array(Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed([])))
138
+
139
+ /**
140
+ * Everything a MAKE module's code may do, declared in its manifest. The kernel refuses at install a module whose
141
+ * code, migrations or manifest reach beyond it, and at run time every host call outside it.
142
+ */
143
+ export const CapabilityProfile = Schema.Struct({
144
+ sql: Schema.Struct({
145
+ /** The module's own entities its statements may read. */
146
+ read: Schema.Array(Schema.String),
147
+ /** The module's own entities its statements may insert, update or delete (each also readable). */
148
+ write: Schema.Array(Schema.String),
149
+ }),
150
+ /** The module's own event types its code may emit (none when left out, as for `call`, `settings` and `view`). */
151
+ emit: Names,
152
+ /** Actions of other modules its code may call through the invocation path, as the caller. */
153
+ call: Names,
154
+ /** Settings its code may read (keyed reads, for the caller). */
155
+ settings: Names,
156
+ /** The module's own actions its view may ask the shell to call. */
157
+ view: Names,
158
+ /**
159
+ * Other modules' events its subscribers may handle (app or MAKE modules of its organisation, never a kernel
160
+ * module's): each is delivered with its payload, so the approver sees what the module will read. Its own events
161
+ * need no listing.
162
+ */
163
+ subscribe: Schema.optionalKey(Schema.Array(Schema.String)),
164
+ /** Limits below the kernel's ceilings (`SANDBOX_MAX_LIMITS`); unset ones take the defaults. */
165
+ limits: Schema.optionalKey(
166
+ Schema.Struct({
167
+ timeMs: Schema.optionalKey(Schema.Int),
168
+ memoryBytes: Schema.optionalKey(Schema.Int),
169
+ steps: Schema.optionalKey(Schema.Int),
170
+ }),
171
+ ),
172
+ })
173
+ export type CapabilityProfile = typeof CapabilityProfile.Type
174
+
175
+ const JsonSchemaDocument = Schema.Record(Schema.String, Schema.Json)
176
+
177
+ /** One entity of a MAKE manifest, in the JSON manifest form (`moduleToJson`). */
178
+ export const MakeEntity = Schema.Struct({
179
+ cedarType: Schema.String,
180
+ /** `<module schema>.<table>`: the module's schema is its name. */
181
+ table: Schema.String,
182
+ primaryKey: Schema.String,
183
+ /** Field (camelCase) to column. */
184
+ columns: Schema.Record(Schema.String, Schema.String),
185
+ policyAttributes: Schema.Record(Schema.String, Schema.Json),
186
+ /** The row's JSON Schema (an object with a property per field). */
187
+ row: JsonSchemaDocument,
188
+ /**
189
+ * Each field's column declaration, as the JSON manifest form publishes an entity's (`storage`): its Postgres
190
+ * type as the migrations declare it, whether it admits NULL, and its transport type. Optional: a field left out
191
+ * is `text`, `boolean`, `bigint` (an integer), `double precision` (a number) or `jsonb` (an object or array) by
192
+ * its row schema's type, nullable unless the row requires it. Setup holds the database to it, as it holds a
193
+ * built-in module to its Drizzle tables. A MAKE entity is never synced.
194
+ */
195
+ storage: Schema.optionalKey(
196
+ Schema.Record(
197
+ Schema.String,
198
+ Schema.Struct({
199
+ column: Schema.String,
200
+ type: Schema.NullOr(Schema.Literals(["string", "number", "boolean", "json"])),
201
+ nullable: Schema.Boolean,
202
+ sqlType: Schema.String,
203
+ enum: Schema.optionalKey(Schema.Array(Schema.String)),
204
+ }),
205
+ ),
206
+ ),
207
+ })
208
+ export type MakeEntity = typeof MakeEntity.Type
209
+
210
+ /** One action of a MAKE manifest, in the JSON manifest form. */
211
+ export const MakeAction = Schema.Struct({
212
+ /**
213
+ * What people see the action called (ModuleManifest 1.6.0): one line, at most 80 characters (checked at draft);
214
+ * omitted: its readable name. The module's own, untrusted words: never what a person decides a held call on.
215
+ */
216
+ title: Schema.optionalKey(Schema.String),
217
+ description: Schema.String,
218
+ writes: Schema.optionalKey(Schema.NullOr(Schema.String)),
219
+ target: Schema.optionalKey(Schema.NullOr(Schema.Struct({ entity: Schema.String, field: Schema.String }))),
220
+ actsOn: Schema.optionalKey(Schema.Array(Schema.String)),
221
+ organisationWide: Schema.optionalKey(Schema.Boolean),
222
+ bestEffort: Schema.optionalKey(Schema.Boolean),
223
+ hints: Schema.optionalKey(
224
+ Schema.Struct({
225
+ readOnly: Schema.optionalKey(Schema.Boolean),
226
+ destructive: Schema.optionalKey(Schema.Boolean),
227
+ idempotent: Schema.optionalKey(Schema.Boolean),
228
+ }),
229
+ ),
230
+ consent: Schema.optionalKey(Schema.Boolean),
231
+ input: JsonSchemaDocument,
232
+ output: JsonSchemaDocument,
233
+ })
234
+ export type MakeAction = typeof MakeAction.Type
235
+
236
+ /** The module manifest of a MAKE module: the same JSON form built-in modules publish, plus nothing else. */
237
+ /**
238
+ * A MAKE entity's entry in `dataSubjects`: a built-in module's (`{ fields, erase, export? }` or `{ none }`), with
239
+ * `notPersonal`: the fields that could hold an identifier (strings, JSON) but do not name a person. With the
240
+ * privacy module installed, every such field of a MAKE entity is classified, in `fields` or in `notPersonal`.
241
+ */
242
+ export const MakeDataSubject = Schema.Union([
243
+ Schema.Struct({
244
+ ...DataSubjectDeclarationDocument.fields,
245
+ notPersonal: Schema.optionalKey(Schema.Array(Schema.String)),
246
+ }),
247
+ Schema.Struct({ none: Schema.String, notPersonal: Schema.optionalKey(Schema.Array(Schema.String)) }),
248
+ ])
249
+ export type MakeDataSubject = typeof MakeDataSubject.Type
250
+
251
+ export const MakeManifest = Schema.Struct({
252
+ /** `mk_<name>`: the module, its schema and its roles. Unique in the app. */
253
+ name: Schema.String,
254
+ /** Semantic version; each installed version is greater than the one before. */
255
+ version: Schema.String,
256
+ cedarNamespace: Schema.String,
257
+ description: Schema.optionalKey(Schema.String),
258
+ entities: Schema.Record(Schema.String, MakeEntity),
259
+ /** By action name (`<module>.<action>`). */
260
+ actions: Schema.Record(Schema.String, MakeAction),
261
+ /** By event type (`<module>.<event>`); none when left out. */
262
+ events: Schema.Record(Schema.String, Schema.Struct({ payload: JsonSchemaDocument })).pipe(
263
+ Schema.withDecodingDefaultKey(Effect.succeed({})),
264
+ ),
265
+ /**
266
+ * Which entities hold records about a person, by entity name, and what an erasure does to them (the Privacy
267
+ * contract), in the JSON manifest form: `{ fields, erase: { kind: "delete" } | { kind: "anonymise", set } |
268
+ * { kind: "retain", reason }, export? }`, or `{ none: reason }` for an entity about nobody. Checked as a built-in
269
+ * module's (and a field named for a person is in `fields` or `notPersonal`); with the privacy module installed
270
+ * every entity must be declared, and data-subject requests export and erase these records as the module's
271
+ * runtime role.
272
+ */
273
+ dataSubjects: Schema.optionalKey(Schema.Record(Schema.String, MakeDataSubject)),
274
+ })
275
+ export type MakeManifest = typeof MakeManifest.Type
276
+
277
+ /** One migration: SQL statements separated by `--> statement-breakpoint`, run in order, recorded by name. */
278
+ export const MakeMigration = Schema.Struct({ name: Schema.String, sql: Schema.String })
279
+ export type MakeMigration = typeof MakeMigration.Type
280
+
281
+ /**
282
+ * A subscriber: the module's code reacting to an event, through the outbox, exactly once per event (its writes and
283
+ * the record of its delivery commit together), retried under the default delivery policy, in the sandbox under the
284
+ * module's limits. It handles one of the module's own events, or another module's its profile lists in
285
+ * `capabilities.subscribe`, of its own organisation only. It acts as the system in the event's organisation (row-level
286
+ * security's subscriber branch), with `eloxiv.sql` only (its profile's tables): it emits nothing, calls nothing and
287
+ * reads no setting, so it starts no further work of its own.
288
+ */
289
+ export const MakeSubscriber = Schema.Struct({
290
+ /** Unique in the app: `<module>.<id>`. */
291
+ id: Schema.String,
292
+ /** The event type it handles (any installed module's). */
293
+ event: Schema.String,
294
+ /**
295
+ * The export that handles it (`subscribers.onGreeted`): called with the event's payload and
296
+ * `{ eventId, event, module, orgId, invocationId, attempt, origin: "system" }` (`attempt` counts its earlier failed
297
+ * attempts at this event).
298
+ */
299
+ entry: Schema.String,
300
+ })
301
+ export type MakeSubscriber = typeof MakeSubscriber.Type
302
+
303
+ /** A slot of the app's (declared by an installed module, accepting views) the view is shown in, in order. */
304
+ export const MakeSlotContribution = Schema.Struct({ slot: Schema.String, order: Schema.optionalKey(Schema.Number) })
305
+ export type MakeSlotContribution = typeof MakeSlotContribution.Type
306
+
307
+ /**
308
+ * A MAKE module's view: code, never markup. `code` is an ES module that runs in the sandbox (no DOM, no network, no
309
+ * host functions) and exports `render(state)`, which returns the view tree (`MakeViewNode`) the shell draws, and
310
+ * optionally `init()` and `update(state, message)` (`MakeViewMessage`), which return `{ state?, calls? }`: the view's
311
+ * next state, and the calls (`MakeViewCall`) of its module's own actions it asks the shell to make (only those
312
+ * `capabilities.view` lists are made). The shell draws the tree from a fixed set of elements in a frame where nothing
313
+ * runs and nothing loads (`MAKE_VIEW_SANDBOX`, `MAKE_VIEW_CSP`).
314
+ */
315
+ export const MakeCodeView = Schema.Struct({
316
+ title: Schema.String,
317
+ /** The view's ES module (`export function render(state) { ... }`, with `init` and `update`). */
318
+ code: Schema.String,
319
+ /**
320
+ * The app's view slots the view is contributed to (`slots` an installed module declares with `accepts: "view"`),
321
+ * each once: the shell shows it there for the organisation that installed it.
322
+ */
323
+ slots: Schema.optionalKey(Schema.Array(MakeSlotContribution)),
324
+ })
325
+ export type MakeCodeView = typeof MakeCodeView.Type
326
+
327
+ /**
328
+ * A view written before views were code (an HTML document with inline script). Kept so the modules installed with
329
+ * one still load; it is no longer accepted in a draft, and it no longer renders (`make.view` answers no view for it).
330
+ */
331
+ export const MakeHtmlView = Schema.Struct({
332
+ title: Schema.String,
333
+ html: Schema.String,
334
+ slots: Schema.optionalKey(Schema.Array(MakeSlotContribution)),
335
+ })
336
+ export type MakeHtmlView = typeof MakeHtmlView.Type
337
+
338
+ export const MakeView = Schema.Union([MakeCodeView, MakeHtmlView])
339
+ export type MakeView = typeof MakeView.Type
340
+
341
+ /** Whether a view is code (the only kind that renders). */
342
+ export const isCodeView = (view: MakeView): view is MakeCodeView => "code" in view
343
+
344
+ /** Everything a draft holds: what the agent (or a person) writes, and what preview, approval and install act on. */
345
+ export const MakeModuleSource = Schema.Struct({
346
+ manifest: MakeManifest,
347
+ /** The module's Cedar policy (its own namespace only). */
348
+ policy: Schema.String,
349
+ capabilities: CapabilityProfile,
350
+ /**
351
+ * The module's migrations, in order. Versions are additive: a version's list starts with the previous
352
+ * version's migrations, unchanged, and its own may only create tables and indexes and add columns that are
353
+ * nullable or have a default (so the previous version's code keeps working over the new schema).
354
+ */
355
+ migrations: Schema.Array(MakeMigration),
356
+ /** The ES module with the handlers (`export const actions = { async add(input, eloxiv) {...} }`). */
357
+ code: Schema.String,
358
+ subscribers: Schema.optionalKey(Schema.Array(MakeSubscriber)),
359
+ view: Schema.optionalKey(MakeView),
360
+ /** Preview data: rows per entity (encoded, by field), inserted into the preview schema before its calls run. */
361
+ sample: Schema.optionalKey(Schema.Record(Schema.String, Schema.Array(Schema.Record(Schema.String, Schema.Json)))),
362
+ })
363
+ export type MakeModuleSource = typeof MakeModuleSource.Type
364
+
365
+ // ---------------------------------------------------------------------------------------------------------
366
+ // The view runtime: views are code that runs in the sandbox and returns a tree the shell draws.
367
+
368
+ export const MAKE_MODULE_PREFIX = "mk_"
369
+
370
+ /** Where an installed MAKE module's actions are served over HTTP: `POST /make/actions/<module>.<action>`. */
371
+ export const MAKE_ACTIONS_PATH = "/make/actions"
372
+
373
+ // The view tree: what a view's `render` returns, and the only thing the shell draws.
374
+
375
+ /**
376
+ * The elements a view tree may use. The shell draws each as plain DOM in the view's frame: `button` and `link` as
377
+ * links to a fragment of the frame's own document that the host routes to the view's `update` (never a URL of the
378
+ * view's), `form` as a group of fields (nothing is ever submitted), `input`, `textarea` and `select` as fields whose
379
+ * values the host reads when something is activated. Anything else is not drawn.
380
+ */
381
+ export const MAKE_VIEW_TAGS = [
382
+ "div",
383
+ "span",
384
+ "p",
385
+ "h1",
386
+ "h2",
387
+ "h3",
388
+ "h4",
389
+ "ul",
390
+ "ol",
391
+ "li",
392
+ "strong",
393
+ "em",
394
+ "small",
395
+ "code",
396
+ "pre",
397
+ "br",
398
+ "hr",
399
+ "table",
400
+ "thead",
401
+ "tbody",
402
+ "tr",
403
+ "th",
404
+ "td",
405
+ "section",
406
+ "header",
407
+ "footer",
408
+ "label",
409
+ "form",
410
+ "button",
411
+ "link",
412
+ "input",
413
+ "textarea",
414
+ "select",
415
+ "option",
416
+ ] as const
417
+ export type MakeViewTag = (typeof MAKE_VIEW_TAGS)[number]
418
+
419
+ /** The properties an element may have; none names a URL. `style` is held to a small set of CSS properties. */
420
+ export const MAKE_VIEW_PROPS = [
421
+ "class",
422
+ "title",
423
+ "style",
424
+ "placeholder",
425
+ "value",
426
+ "checked",
427
+ "selected",
428
+ "disabled",
429
+ "name",
430
+ "type",
431
+ "min",
432
+ "max",
433
+ "step",
434
+ "rows",
435
+ "colspan",
436
+ "rowspan",
437
+ "ariaLabel",
438
+ ] as const
439
+
440
+ /** The input types a view may use (never `file`, `image`, `submit` or `reset`). */
441
+ export const MAKE_VIEW_INPUT_TYPES = [
442
+ "text",
443
+ "number",
444
+ "email",
445
+ "date",
446
+ "time",
447
+ "datetime-local",
448
+ "search",
449
+ "tel",
450
+ "checkbox",
451
+ "radio",
452
+ "range",
453
+ "color",
454
+ "hidden",
455
+ ] as const
456
+
457
+ /** The most nodes, and the deepest nesting, a view tree may have. */
458
+ export const MAKE_VIEW_MAX_NODES = 5_000
459
+ export const MAKE_VIEW_MAX_DEPTH = 64
460
+
461
+ /**
462
+ * One node of a view tree: text (a string or a number), nothing (`null`, `false`: for conditional rendering), or
463
+ * an element: `{ tag, props?, children?, on?, data? }`. `on` names the view's event: activating a `button` or
464
+ * `link`, or changing a field, sends `update` `{ type: "event", name: on, data, value?, fields }`.
465
+ */
466
+ export interface MakeViewElement {
467
+ readonly tag: MakeViewTag
468
+ readonly props?: { readonly [key: string]: string | number | boolean }
469
+ readonly children?: ReadonlyArray<MakeViewNode>
470
+ readonly on?: string
471
+ readonly data?: Schema.Json
472
+ }
473
+ export type MakeViewNode = string | number | boolean | null | MakeViewElement
474
+
475
+ /** A prop's value. Named (`identifier`) so a native generator gives the tree's types their own names. */
476
+ export const MakeViewPropValue = Schema.Union([Schema.String, Schema.Number, Schema.Boolean]).annotate({
477
+ identifier: "MakeViewPropValue",
478
+ })
479
+ /** Any of `MAKE_VIEW_PROPS`; decoded with excess properties refused (`MAKE_VIEW_DECODE`), so no other is accepted. */
480
+ export const MakeViewProps = Schema.Struct(
481
+ Object.fromEntries(MAKE_VIEW_PROPS.map((key) => [key, Schema.optionalKey(MakeViewPropValue)])) as {
482
+ readonly [K in (typeof MAKE_VIEW_PROPS)[number]]: Schema.optionalKey<typeof MakeViewPropValue>
483
+ },
484
+ ).annotate({ identifier: "MakeViewProps" })
485
+
486
+ /** An element of a view tree: `{ tag, props?, children?, on?, data? }`. */
487
+ export const MakeViewElement: Schema.Codec<MakeViewElement> = Schema.Struct({
488
+ tag: Schema.Literals(MAKE_VIEW_TAGS),
489
+ props: Schema.optionalKey(MakeViewProps),
490
+ children: Schema.optionalKey(Schema.Array(Schema.suspend((): Schema.Codec<MakeViewNode> => MakeViewNode))),
491
+ on: Schema.optionalKey(Schema.String),
492
+ data: Schema.optionalKey(Schema.Json),
493
+ }).annotate({ identifier: "MakeViewElement" })
494
+
495
+ export const MakeViewNode: Schema.Codec<MakeViewNode> = Schema.Union([
496
+ Schema.String,
497
+ Schema.Number,
498
+ Schema.Boolean,
499
+ Schema.Null,
500
+ MakeViewElement,
501
+ ]).annotate({ identifier: "MakeViewNode" })
502
+
503
+ /** What a view tree holds: its node count and depth (held to `MAKE_VIEW_MAX_NODES` and `MAKE_VIEW_MAX_DEPTH`). */
504
+ export const viewTreeSize = (node: MakeViewNode): { readonly nodes: number; readonly depth: number } => {
505
+ let nodes = 0
506
+ let depth = 0
507
+ const walk = (n: MakeViewNode, level: number) => {
508
+ nodes++
509
+ if (level > depth) depth = level
510
+ if (n !== null && typeof n === "object") for (const child of n.children ?? []) walk(child, level + 1)
511
+ }
512
+ walk(node, 1)
513
+ return { nodes, depth }
514
+ }
515
+
516
+ /** A call a view asks the shell to make: one of its module's own actions its capability profile lists. */
517
+ export const MakeViewCall = Schema.Struct({
518
+ /** The view's own name for the call: its result comes back to `update` with it. */
519
+ id: Schema.String,
520
+ action: Schema.String,
521
+ input: Schema.Json,
522
+ /**
523
+ * The call's idempotency key (1 to 128 characters of `MAKE_VIEW_KEY`), the same on every retry of one request, so a
524
+ * retry after a lost answer is answered with the first call's result. The host namespaces it by its mount of the
525
+ * view. A call without one gets a key of the host's, new for each call.
526
+ */
527
+ key: Schema.optionalKey(Schema.String),
528
+ }).annotate({ identifier: "MakeViewCall" })
529
+ export type MakeViewCall = typeof MakeViewCall.Type
530
+
531
+ /** What a view's `update` is told: an event of its tree, or a call's result (the action's envelope) or error. */
532
+ export const MakeViewMessage = Schema.Union([
533
+ Schema.Struct({
534
+ type: Schema.Literal("event"),
535
+ /** The element's `on`. */
536
+ name: Schema.String,
537
+ /** The element's `data`. */
538
+ data: Schema.optionalKey(Schema.Json),
539
+ /** A changed field's value (a string, or a boolean for a checkbox). */
540
+ value: Schema.optionalKey(Schema.Union([Schema.String, Schema.Boolean])),
541
+ /** The values of the fields (by `name`) of the element's form, or of the whole view outside one. */
542
+ fields: Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Boolean])),
543
+ }),
544
+ Schema.Struct({ type: Schema.Literal("result"), id: Schema.String, ok: Schema.Literal(true), result: Schema.Json }),
545
+ Schema.Struct({
546
+ type: Schema.Literal("result"),
547
+ id: Schema.String,
548
+ ok: Schema.Literal(false),
549
+ error: Schema.Struct({ _tag: Schema.String, message: Schema.String }),
550
+ }),
551
+ ]).annotate({ identifier: "MakeViewMessage" })
552
+ export type MakeViewMessage = typeof MakeViewMessage.Type
553
+
554
+ /** How a view's answer is decoded: a property or key the contract does not name is refused, never dropped. */
555
+ export const MAKE_VIEW_DECODE = { onExcessProperty: "error" } as const
556
+
557
+ /** One step of a view (`make.renderView`): its next state, the calls it asks for, and the tree to draw. */
558
+ export const MakeViewStep = Schema.Struct({
559
+ state: Schema.Json,
560
+ calls: Schema.Array(MakeViewCall),
561
+ tree: MakeViewNode,
562
+ }).annotate({ identifier: "MakeViewStep" })
563
+ export type MakeViewStep = typeof MakeViewStep.Type
564
+
565
+ /**
566
+ * The Content Security Policy of the frame a view is drawn in (as a `<meta>` of its document and as the iframe's
567
+ * `csp` attribute): nothing runs and nothing loads. No script, no image, media, font, frame or object, no
568
+ * connection, no form submission, no base URL; inline style only (the shell's own sheet and `style` properties).
569
+ */
570
+ export const MAKE_VIEW_CSP =
571
+ "default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src 'none'; media-src 'none'; " +
572
+ "font-src 'none'; connect-src 'none'; form-action 'none'; frame-src 'none'; child-src 'none'; " +
573
+ "object-src 'none'; worker-src 'none'; manifest-src 'none'; base-uri 'none'"
574
+
575
+ /**
576
+ * The frame's sandbox flags: no scripts, no forms, no popups, no navigation of the shell. `allow-same-origin` lets
577
+ * the host (never the frame, where no script runs) draw the tree into the frame's document and read its fields.
578
+ */
579
+ export const MAKE_VIEW_SANDBOX = "allow-same-origin"
580
+
581
+ /** What a view's idempotency key may be: 1 to 128 URL-safe characters. */
582
+ export const MAKE_VIEW_KEY = /^[A-Za-z0-9_-]{1,128}$/u
583
+
584
+ /**
585
+ * The custom properties a view's `style` may name (`var(--primary)`): the app's theme (the ThemeTokens contract's
586
+ * colours, radius, spacing and fonts), which the shell sets on the frame's root; no other variable.
587
+ */
588
+ export const MAKE_VIEW_THEME_VARIABLES: ReadonlyArray<string> = [
589
+ ...COLOR_TOKENS.map((token) => `--${token}`),
590
+ "--radius",
591
+ "--spacing",
592
+ "--font-sans",
593
+ "--font-mono",
594
+ ]
595
+
596
+ export const SandboxContract = defineServiceContract({
597
+ name: "Sandbox",
598
+ kind: "kernel",
599
+ version: "2.3.0",
600
+ description:
601
+ "Runs untrusted code (MAKE modules' handlers, subscribers and views) with no ambient authority: no network, " +
602
+ "file system, process, timers, modules or kernel services, only the host functions the caller grants, each " +
603
+ "checked against the code's capability profile; stopped at memory, stack, time, step, host-call and output " +
604
+ "limits. Also publishes the MAKE module source (manifest, capability profile, migrations, code, view) and the " +
605
+ "view runtime: the view tree a view's code returns, its messages, and the frame's sandbox flags and CSP.",
606
+ operations: {
607
+ run: {
608
+ description:
609
+ "Evaluate an ES module in a fresh interpreter and call one of its exports with JSON arguments, giving it " +
610
+ "only the granted host functions (as `eloxiv.<name>`). Fails at the first limit reached, when the code fails, " +
611
+ "or when it asked for anything its capabilities do not grant (even if it caught the refusal).",
612
+ input: SandboxRun,
613
+ output: SandboxResult,
614
+ errors: SandboxError,
615
+ },
616
+ check: {
617
+ description: "Compile and evaluate an ES module (granting nothing) and list its exports, or report why it fails.",
618
+ input: SandboxCheck,
619
+ output: SandboxCheckResult,
620
+ errors: SandboxError,
621
+ },
622
+ runProgram: {
623
+ description:
624
+ "data.run: run a person's read program in the sandbox with only the read-only module actions and the person's " +
625
+ "Connections it is granted (`eloxiv.read`, `eloxiv.fetch`) and their staged datasets (`eloxiv.stage`, " +
626
+ "`eloxiv.staged`, `eloxiv.query`), in the call or in the background; recorded, and held to a quota of runs an " +
627
+ "hour and in the background.",
628
+ input: RunProgram,
629
+ output: ProgramRun,
630
+ errors: Schema.Union([Unauthenticated, Forbidden, InvalidInput]),
631
+ },
632
+ programStatus: {
633
+ description: "data.status: how one of the caller's read programs stands (running, succeeded, failed, lost).",
634
+ input: Schema.Struct({ runId: Schema.String }),
635
+ output: ProgramRun,
636
+ errors: Schema.Union([Unauthenticated, InvalidInput]),
637
+ },
638
+ },
639
+ types: {
640
+ SandboxLimits,
641
+ SandboxUsage,
642
+ CapabilityProfile,
643
+ MakeManifest,
644
+ MakeModuleSource,
645
+ MakeViewStep,
646
+ MakeViewMessage,
647
+ },
648
+ })