@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
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Host (a shell contract, decision 7): what the shell needs from wherever it runs (a browser tab, the Tauri
3
+ * desktop host, later a mobile host): deep links, push, secure storage, updates and file access. The kernel
4
+ * defines the contract; a host implements it, and says per capability whether it supports it, so the shell
5
+ * asks rather than guesses. A host that lacks a capability reports `unsupported` and every operation of it
6
+ * fails with `HostUnsupported`; it never pretends.
7
+ *
8
+ * - **Deep links:** the URL the app was opened with, and URLs it is asked to open while running, only on the
9
+ * app's own origin or custom scheme (the View contract parses them; a link only navigates).
10
+ * - **Secure storage:** small secrets (a session token) kept where the platform keeps secrets (the OS keychain;
11
+ * on the web, values encrypted with a non-extractable key). Keys are namespaced per app.
12
+ * - **Push:** a subscription a NotificationChannel can deliver to (Web Push, APNs or FCM), after the person's
13
+ * permission. A native host also gives its native device token (`pushToken`), which the app registers as an
14
+ * installation (`notifications.registerInstallation`), and tells the app of notification responses
15
+ * (`onNotificationResponse`: a tap, or a decision button, decided only for the person and installation the
16
+ * notification was sent to: with its token on iOS, through the person's session on Android, which gets none).
17
+ * - **Updates:** whether a newer build of the app is available, and applying it (on the web: reloading onto the
18
+ * deployed build; on desktop and mobile: the platform's updater).
19
+ * - **Files:** opening files the person picks and saving bytes to a file they choose.
20
+ *
21
+ * Documented in docs/contracts/host.md; conformance kit `@eloxiv/testing/conformance/Host`; implemented by
22
+ * `@eloxiv/shell-core/web` (`webHost`) and the registry's desktop template (`desktop/host.ts`).
23
+ */
24
+ import { Schema } from "effect"
25
+ import { defineServiceContract } from "../Service.ts"
26
+ import { DecisionVerdict } from "./NotificationChannel.ts"
27
+ import { PushProvider } from "./Notifications.ts"
28
+ import { DeepLink } from "./View.ts"
29
+
30
+ export const CapabilitySupport = Schema.Literals(["supported", "unsupported"])
31
+ export type CapabilitySupport = typeof CapabilitySupport.Type
32
+
33
+ export const HostCapabilities = Schema.Struct({
34
+ /** The host's kind: `web`, `tauri`, `expo`, or another host's name. */
35
+ host: Schema.String,
36
+ deepLinks: CapabilitySupport,
37
+ push: CapabilitySupport,
38
+ secureStorage: CapabilitySupport,
39
+ updates: CapabilitySupport,
40
+ files: CapabilitySupport,
41
+ })
42
+ export type HostCapabilities = typeof HostCapabilities.Type
43
+
44
+ /** A secure-storage key: short, namespaced by the caller (`session`, `device.credential`). */
45
+ export const SecretKey = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9._-]{0,127}$/))
46
+
47
+ export const PushPermission = Schema.Literals(["granted", "denied", "prompt"])
48
+ export type PushPermission = typeof PushPermission.Type
49
+
50
+ /** Where pushes for this installation go: a Web Push endpoint with its keys, or an APNs or FCM device token. */
51
+ export const PushSubscriptionInfo = Schema.Union([
52
+ Schema.Struct({
53
+ kind: Schema.Literal("web-push"),
54
+ endpoint: Schema.String,
55
+ keys: Schema.Struct({ p256dh: Schema.String, auth: Schema.String }),
56
+ }),
57
+ Schema.Struct({ kind: Schema.Literals(["apns", "fcm"]), token: Schema.String }),
58
+ ])
59
+ export type PushSubscriptionInfo = typeof PushSubscriptionInfo.Type
60
+
61
+ /**
62
+ * A native host's push token: what the app registers with `notifications.registerInstallation` (with its own
63
+ * installation id). `appId` is the APNs topic (bundle id) or the Android package; `environment` is APNs only.
64
+ */
65
+ export const PushToken = Schema.Struct({
66
+ provider: PushProvider,
67
+ token: Schema.String,
68
+ appId: Schema.String,
69
+ environment: Schema.optionalKey(Schema.Literals(["production", "sandbox"])),
70
+ })
71
+ export type PushToken = typeof PushToken.Type
72
+
73
+ /**
74
+ * The person responded to a push notification: a tap (no `action`: open `link`) or a decision button (`action`). A
75
+ * button is decided once the app shows its request to the person the notification was sent to, on the installation it
76
+ * was sent to: with the payload's decision token on iOS, through the person's own session on Android (FCM payloads
77
+ * carry no token). From the payload's `eloxiv` key.
78
+ */
79
+ export const NotificationResponse = Schema.Struct({
80
+ notificationId: Schema.String,
81
+ link: Schema.NullOr(DeepLink),
82
+ action: Schema.optionalKey(DecisionVerdict),
83
+ })
84
+ export type NotificationResponse = typeof NotificationResponse.Type
85
+
86
+ export const UpdateStatus = Schema.Struct({
87
+ current: Schema.String,
88
+ /** The newer build's version, or `null` when this one is current. */
89
+ available: Schema.NullOr(Schema.String),
90
+ })
91
+ export type UpdateStatus = typeof UpdateStatus.Type
92
+
93
+ /** A file the person picked. */
94
+ export const PickedFile = Schema.Struct({
95
+ name: Schema.String,
96
+ mediaType: Schema.String,
97
+ size: Schema.Number,
98
+ bytes: Schema.Uint8Array,
99
+ })
100
+ export type PickedFile = typeof PickedFile.Type
101
+
102
+ export class HostUnsupported extends Schema.TaggedError<HostUnsupported>()("HostUnsupported", {
103
+ message: Schema.String,
104
+ capability: Schema.Literals(["deepLinks", "push", "secureStorage", "updates", "files"]),
105
+ }) {}
106
+
107
+ export class HostPermissionDenied extends Schema.TaggedError<HostPermissionDenied>()("HostPermissionDenied", {
108
+ message: Schema.String,
109
+ }) {}
110
+
111
+ /** The person dismissed a picker or prompt. */
112
+ export class HostCancelled extends Schema.TaggedError<HostCancelled>()("HostCancelled", {
113
+ message: Schema.String,
114
+ }) {}
115
+
116
+ export class HostFailure extends Schema.TaggedError<HostFailure>()("HostFailure", {
117
+ message: Schema.String,
118
+ }) {}
119
+
120
+ export const HostContract = defineServiceContract({
121
+ name: "Host",
122
+ kind: "shell",
123
+ version: "1.1.0",
124
+ description:
125
+ "What the shell needs from where it runs (decision 7): deep links (only on the app's own origin or scheme), " +
126
+ "secure storage of small secrets where the platform keeps them, push subscriptions after the person's " +
127
+ "permission (and, on native hosts, the device token to register and notification responses), updates, and " +
128
+ "file access. Each capability is reported supported or unsupported; an unsupported one fails with " +
129
+ "HostUnsupported, never silently.",
130
+ operations: {
131
+ capabilities: {
132
+ description: "Which capabilities this host supports.",
133
+ input: Schema.Struct({}),
134
+ output: HostCapabilities,
135
+ errors: Schema.Never,
136
+ },
137
+ initialLink: {
138
+ description: "The deep link the app was opened with, or `null` (only links on the app's own origin or scheme).",
139
+ input: Schema.Struct({}),
140
+ output: Schema.NullOr(Schema.String),
141
+ errors: HostUnsupported,
142
+ },
143
+ onLink: {
144
+ description:
145
+ "Be told of each deep link the app is asked to open while running (only links on the app's own origin or " +
146
+ "scheme); returns a function that stops listening.",
147
+ input: Schema.Struct({}),
148
+ output: Schema.Struct({}),
149
+ errors: HostUnsupported,
150
+ },
151
+ secretGet: {
152
+ description: "A stored secret, or `null` when none is stored under the key.",
153
+ input: Schema.Struct({ key: SecretKey }),
154
+ output: Schema.NullOr(Schema.String),
155
+ errors: Schema.Union([HostUnsupported, HostFailure]),
156
+ },
157
+ secretSet: {
158
+ description: "Store a secret under a key (replacing any), kept across restarts and never in plain storage.",
159
+ input: Schema.Struct({ key: SecretKey, value: Schema.String.check(Schema.isMaxLength(16_384)) }),
160
+ output: Schema.Struct({}),
161
+ errors: Schema.Union([HostUnsupported, HostFailure]),
162
+ },
163
+ secretDelete: {
164
+ description: "Delete the secret under a key (nothing if none).",
165
+ input: Schema.Struct({ key: SecretKey }),
166
+ output: Schema.Struct({}),
167
+ errors: Schema.Union([HostUnsupported, HostFailure]),
168
+ },
169
+ pushPermission: {
170
+ description: "Whether the person allowed notifications, denied them, or has not been asked.",
171
+ input: Schema.Struct({}),
172
+ output: PushPermission,
173
+ errors: HostUnsupported,
174
+ },
175
+ pushSubscribe: {
176
+ description: "Ask the person's permission if needed, and subscribe this installation for push.",
177
+ input: Schema.Struct({ applicationServerKey: Schema.optionalKey(Schema.String) }),
178
+ output: PushSubscriptionInfo,
179
+ errors: Schema.Union([HostUnsupported, HostPermissionDenied, HostFailure]),
180
+ },
181
+ pushUnsubscribe: {
182
+ description: "Remove this installation's push subscription (nothing if none).",
183
+ input: Schema.Struct({}),
184
+ output: Schema.Struct({}),
185
+ errors: Schema.Union([HostUnsupported, HostFailure]),
186
+ },
187
+ pushToken: {
188
+ description:
189
+ "Native hosts: ask the person's permission if needed and give this installation's APNs or FCM device token " +
190
+ "(never a relay service's token), with the app id it is for, to register as an installation.",
191
+ input: Schema.Struct({}),
192
+ output: PushToken,
193
+ errors: Schema.Union([HostUnsupported, HostPermissionDenied, HostFailure]),
194
+ },
195
+ onNotificationResponse: {
196
+ description:
197
+ "Native hosts: be told of each response to a push notification, including the one that launched the app: a " +
198
+ "tap (open its link once signed in, in its organisation) or a decision button (decided once its request is " +
199
+ "shown to the person and installation the notification was sent to: with its token on iOS, through the " +
200
+ "person's session on Android; a tap never decides). Returns a function that stops listening.",
201
+ input: Schema.Struct({}),
202
+ output: NotificationResponse,
203
+ errors: HostUnsupported,
204
+ },
205
+ checkUpdate: {
206
+ description: "Whether a newer build of the app is available.",
207
+ input: Schema.Struct({}),
208
+ output: UpdateStatus,
209
+ errors: Schema.Union([HostUnsupported, HostFailure]),
210
+ },
211
+ applyUpdate: {
212
+ description: "Move onto the newer build (reload or install and restart).",
213
+ input: Schema.Struct({}),
214
+ output: Schema.Struct({}),
215
+ errors: Schema.Union([HostUnsupported, HostFailure]),
216
+ },
217
+ openFiles: {
218
+ description: "Let the person pick files to open; their names, media types and bytes.",
219
+ input: Schema.Struct({
220
+ accept: Schema.optionalKey(Schema.Array(Schema.String)),
221
+ multiple: Schema.optionalKey(Schema.Boolean),
222
+ }),
223
+ output: Schema.Array(PickedFile),
224
+ errors: Schema.Union([HostUnsupported, HostCancelled, HostFailure]),
225
+ },
226
+ saveFile: {
227
+ description: "Save bytes to a file the person chooses (or the platform's downloads).",
228
+ input: Schema.Struct({ name: Schema.String, mediaType: Schema.String, bytes: Schema.Uint8Array }),
229
+ output: Schema.Struct({}),
230
+ errors: Schema.Union([HostUnsupported, HostCancelled, HostFailure]),
231
+ },
232
+ },
233
+ types: {
234
+ HostCapabilities,
235
+ PushSubscriptionInfo,
236
+ PushToken,
237
+ NotificationResponse,
238
+ UpdateStatus,
239
+ PickedFile,
240
+ HostUnsupported,
241
+ HostPermissionDenied,
242
+ HostCancelled,
243
+ HostFailure,
244
+ },
245
+ })
@@ -0,0 +1,100 @@
1
+ /**
2
+ * HttpApi: any HTTP API (described by an OpenAPI document or not) over a kernel Connection whose endpoint is the
3
+ * API's base URL, through the registry's `http-openapi` connector. The kernel carries the credential (none, a secret
4
+ * it holds and sends only to the Connection's origin, or an OAuth grant) and checks every destination; requests stay
5
+ * under the base URL, answers are bounded, and writes are told apart from reads. See docs/contracts/http-api.md.
6
+ */
7
+ import { Schema } from "effect"
8
+ import { defineOperation, defineServiceContract } from "../Service.ts"
9
+ import { CapabilityError } from "./Capability.ts"
10
+
11
+ /** One operation of the API's OpenAPI document. `readOnly`: a GET or HEAD, or a POST the Connection names as reading. */
12
+ export const ApiOperation = Schema.Struct({
13
+ id: Schema.String,
14
+ method: Schema.String,
15
+ path: Schema.String,
16
+ summary: Schema.NullOr(Schema.String),
17
+ readOnly: Schema.Boolean,
18
+ })
19
+ export type ApiOperation = typeof ApiOperation.Type
20
+
21
+ /** What one request answered. `body` is the parsed JSON, the text, or null; `truncated` when it was cut at the bound. */
22
+ export const ApiResponse = Schema.Struct({
23
+ status: Schema.Int,
24
+ contentType: Schema.NullOr(Schema.String),
25
+ body: Schema.Unknown,
26
+ truncated: Schema.Boolean,
27
+ })
28
+ export type ApiResponse = typeof ApiResponse.Type
29
+
30
+ const RequestFields = {
31
+ /** A path under the Connection's base URL (`/repos/x/issues`, or relative to it); never another origin. */
32
+ path: Schema.String,
33
+ query: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
34
+ /** Extra request headers; credentials, cookies and hop-by-hop headers are refused. */
35
+ headers: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
36
+ /** A JSON body. */
37
+ json: Schema.optionalKey(Schema.Unknown),
38
+ }
39
+
40
+ export const HttpApiFlags = Schema.Struct({
41
+ /** The Connection names an OpenAPI document, so `catalog` and `describe` answer from it. */
42
+ openapi: Schema.Boolean,
43
+ })
44
+ export type HttpApiFlags = typeof HttpApiFlags.Type
45
+
46
+ export const HttpApiContract = defineServiceContract({
47
+ name: "HttpApi",
48
+ kind: "capability",
49
+ version: "1.0.0",
50
+ description:
51
+ "Any HTTP API over a kernel Connection whose endpoint is its base URL: its OpenAPI catalogue and an operation's description, reads (GET, HEAD, and POSTs the Connection names as reading) with bounded answers and pagination by Link headers on the same origin, and writes, which have effects others may see and are never sent twice. Requests stay under the base URL; the credential is the kernel's. Reads need api.read, writes api.write; operations fail only with the standard capability errors.",
52
+ operations: {
53
+ catalog: defineOperation({
54
+ description:
55
+ "The operations of the API's OpenAPI document (at most 500, `truncated` beyond), with which of them only read. Empty when the Connection names no document.",
56
+ input: Schema.Struct({}),
57
+ output: Schema.Struct({
58
+ title: Schema.NullOr(Schema.String),
59
+ operations: Schema.Array(ApiOperation),
60
+ truncated: Schema.Boolean,
61
+ }),
62
+ errors: CapabilityError,
63
+ scopes: ["api.read"],
64
+ }),
65
+ describe: defineOperation({
66
+ description:
67
+ "One operation of the OpenAPI document by its id: its parameters and request body as the document gives them (bounded).",
68
+ input: Schema.Struct({ operationId: Schema.String }),
69
+ output: Schema.Struct({
70
+ operation: ApiOperation,
71
+ description: Schema.NullOr(Schema.String),
72
+ parameters: Schema.Array(Schema.Unknown),
73
+ requestBody: Schema.NullOr(Schema.Unknown),
74
+ }),
75
+ errors: CapabilityError,
76
+ scopes: ["api.read"],
77
+ }),
78
+ read: defineOperation({
79
+ description:
80
+ 'A request that only reads: GET, HEAD, or a POST to a path the Connection names as reading. With `maxPages` above 1, follows the answer\'s `Link: <...>; rel="next"` on the same origin and under the base URL, up to that many pages (at most 10).',
81
+ input: Schema.Struct({
82
+ method: Schema.Literals(["GET", "HEAD", "POST"]),
83
+ ...RequestFields,
84
+ maxPages: Schema.optionalKey(Schema.Int),
85
+ }),
86
+ output: Schema.Struct({ pages: Schema.Array(ApiResponse) }),
87
+ errors: CapabilityError,
88
+ scopes: ["api.read"],
89
+ }),
90
+ write: defineOperation({
91
+ description: "A request that may change something: POST, PUT, PATCH or DELETE. Never retried after a 5xx.",
92
+ input: Schema.Struct({ method: Schema.Literals(["POST", "PUT", "PATCH", "DELETE"]), ...RequestFields }),
93
+ output: ApiResponse,
94
+ errors: CapabilityError,
95
+ scopes: ["api.write"],
96
+ effect: "external",
97
+ }),
98
+ },
99
+ types: { ApiOperation, ApiResponse, HttpApiFlags },
100
+ })
@@ -0,0 +1,315 @@
1
+ /**
2
+ * Ingestion: pipelines that turn inbound content into extracted text and searchable chunks
3
+ * (docs/contracts/ingestion.md): files attached to records, documents from a DocumentSource connector over a
4
+ * Connection, emails and other text a module receives. Each source item belongs to a record (whose read policy
5
+ * governs who finds its chunks through Search), runs as a durable workflow (fetch, extract, chunk, index), is
6
+ * idempotent per source item and version, and reports its progress.
7
+ */
8
+ import { Schema } from "effect"
9
+ import { Forbidden, InvalidInput, Unauthenticated } from "../Errors.ts"
10
+ import { defineOperation, defineServiceContract } from "../Service.ts"
11
+ import { RecordRef } from "./Files.ts"
12
+ import { CollectionStatus, CollectSpec, DatasetInfo, DatasetRows, QueryDataset, StageDataset } from "../Data.ts"
13
+
14
+ /** The kernel's ingestion actions. */
15
+ export const INGESTION_ACTIONS = { status: "ingestion.status" } as const
16
+
17
+ /** Media types the kernel extracts text from itself (a deployment adds more with an `Extractor`). */
18
+ export const BUILTIN_EXTRACTABLE = [
19
+ "text/plain",
20
+ "text/markdown",
21
+ "text/csv",
22
+ "text/tab-separated-values",
23
+ "text/html",
24
+ "application/xhtml+xml",
25
+ "application/json",
26
+ "application/xml",
27
+ "text/xml",
28
+ "application/pdf",
29
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
30
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
31
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation",
32
+ ] as const
33
+
34
+ /** What to ingest, and where it comes from. */
35
+ export const IngestionSource = Schema.Union([
36
+ /** A file attached to the record (the Files contract), once it is available. */
37
+ Schema.Struct({ kind: Schema.Literal("file"), fileId: Schema.String }),
38
+ /** Text the module already holds (a message, a note). `key` identifies it within the record. */
39
+ Schema.Struct({
40
+ kind: Schema.Literal("text"),
41
+ key: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(200)),
42
+ title: Schema.optionalKey(Schema.NullOr(Schema.String)),
43
+ mediaType: Schema.optionalKey(Schema.String),
44
+ text: Schema.String,
45
+ }),
46
+ /** An email: its subject and its body, plain text or HTML (the HTML is reduced to its text). */
47
+ Schema.Struct({
48
+ kind: Schema.Literal("email"),
49
+ /** The message id. */
50
+ key: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(500)),
51
+ subject: Schema.NullOr(Schema.String),
52
+ from: Schema.optionalKey(Schema.NullOr(Schema.String)),
53
+ text: Schema.optionalKey(Schema.NullOr(Schema.String)),
54
+ html: Schema.optionalKey(Schema.NullOr(Schema.String)),
55
+ }),
56
+ /**
57
+ * A document at a provider (the DocumentSource contract), fetched over the Connection with `getContent`.
58
+ * `version` (the item's `modifiedAt`, or the provider's version) makes a changed document a new version.
59
+ */
60
+ Schema.Struct({
61
+ kind: Schema.Literal("document"),
62
+ connectionId: Schema.String,
63
+ itemId: Schema.String,
64
+ version: Schema.String,
65
+ name: Schema.optionalKey(Schema.NullOr(Schema.String)),
66
+ }),
67
+ ])
68
+ export type IngestionSource = typeof IngestionSource.Type
69
+
70
+ export const SubmitIngestion = Schema.Struct({
71
+ /** The record the content belongs to, of the submitting module's own entities. */
72
+ record: RecordRef,
73
+ source: IngestionSource,
74
+ })
75
+ export type SubmitIngestion = typeof SubmitIngestion.Type
76
+
77
+ /**
78
+ * `queued` → `fetching` → `extracting` → `indexing` → `done`; `failed` (with `error`, resubmit to retry);
79
+ * `superseded` (a newer version of the same source item replaced it, or its record was deleted).
80
+ */
81
+ export const IngestionState = Schema.Literals([
82
+ "queued",
83
+ "fetching",
84
+ "extracting",
85
+ "indexing",
86
+ "done",
87
+ "failed",
88
+ "superseded",
89
+ ])
90
+ export type IngestionState = typeof IngestionState.Type
91
+
92
+ export const IngestionItem = Schema.Struct({
93
+ id: Schema.String,
94
+ orgId: Schema.String,
95
+ record: RecordRef,
96
+ /** `file`, `text`, `email` or `document`. */
97
+ sourceKind: Schema.String,
98
+ /** The source item's identity within the record: `file:<id>`, `text:<key>`, `email:<key>`, `document:<connection>:<item>`. */
99
+ sourceKey: Schema.String,
100
+ version: Schema.String,
101
+ title: Schema.NullOr(Schema.String),
102
+ mediaType: Schema.NullOr(Schema.String),
103
+ state: IngestionState,
104
+ /** 0 to 1, across the pipeline's stages. */
105
+ progress: Schema.Number,
106
+ chunks: Schema.Number,
107
+ characters: Schema.Number,
108
+ /** The extracted text was cut at the deployment's limit. */
109
+ truncated: Schema.Boolean,
110
+ error: Schema.NullOr(Schema.String),
111
+ /** ISO 8601, UTC. */
112
+ createdAt: Schema.String,
113
+ updatedAt: Schema.String,
114
+ completedAt: Schema.NullOr(Schema.String),
115
+ })
116
+ export type IngestionItem = typeof IngestionItem.Type
117
+
118
+ export const SubmitResult = Schema.Struct({
119
+ itemId: Schema.String,
120
+ state: IngestionState,
121
+ /** False when this source item and version were already submitted: nothing new runs. */
122
+ created: Schema.Boolean,
123
+ })
124
+ export type SubmitResult = typeof SubmitResult.Type
125
+
126
+ /** An extractor's answer (the in-process `Extractor` hook). */
127
+ export const Extracted = Schema.Struct({ text: Schema.String, title: Schema.NullOr(Schema.String) })
128
+
129
+ // --- Bulk runs: leases, budgets, inventory ------------------------------------------------------------------
130
+
131
+ /** An item key of a bulk run (a provider's id for it): at most 500 characters. */
132
+ const RunKey = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(500))
133
+
134
+ /** `ctx.ingestion.runs.open`: a run over an inventory of item keys, with an optional budget of cost units. */
135
+ export const OpenRun = Schema.Struct({
136
+ /** What the run processes (`mail.backfill`, `drive:<connection>`): for its owner to tell runs apart. */
137
+ source: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200)),
138
+ /** Every item the provider listed: the run is complete only when each is done or reported. */
139
+ items: Schema.Array(RunKey).check(Schema.isMaxLength(100_000)),
140
+ /** Stop the run once this many cost units are spent (each item's `cost`, default 1). */
141
+ budget: Schema.optionalKey(Schema.Number.check(Schema.isGreaterThan(0))),
142
+ })
143
+ export type OpenRun = typeof OpenRun.Type
144
+
145
+ export const RunItemState = Schema.Literals(["pending", "leased", "done", "reported"])
146
+ export type RunItemState = typeof RunItemState.Type
147
+
148
+ /** A claimed item: its key and which attempt this is (2 or more: an earlier worker's lease ran out). */
149
+ export const ClaimedItem = Schema.Struct({ key: Schema.String, attempt: Schema.Number })
150
+ export type ClaimedItem = typeof ClaimedItem.Type
151
+
152
+ export const BulkRunStatus = Schema.Literals(["running", "completed", "stopped"])
153
+ export type BulkRunStatus = typeof BulkRunStatus.Type
154
+
155
+ /** A run's inventory: every item's state, and whether each listed item was processed or reported. */
156
+ export const RunInventory = Schema.Struct({
157
+ runId: Schema.String,
158
+ source: Schema.String,
159
+ status: BulkRunStatus,
160
+ stopReason: Schema.NullOr(Schema.Literals(["budget"])),
161
+ budget: Schema.NullOr(Schema.Number),
162
+ spent: Schema.Number,
163
+ /** True when every item is done or reported. */
164
+ complete: Schema.Boolean,
165
+ counts: Schema.Struct({
166
+ pending: Schema.Number,
167
+ leased: Schema.Number,
168
+ done: Schema.Number,
169
+ reported: Schema.Number,
170
+ }),
171
+ items: Schema.Array(
172
+ Schema.Struct({
173
+ key: Schema.String,
174
+ state: RunItemState,
175
+ attempts: Schema.Number,
176
+ reason: Schema.NullOr(Schema.String),
177
+ }),
178
+ ),
179
+ })
180
+ export type RunInventory = typeof RunInventory.Type
181
+
182
+ export const IngestionContract = defineServiceContract({
183
+ name: "Ingestion",
184
+ kind: "kernel",
185
+ version: "1.2.0",
186
+ description:
187
+ "Turns inbound content (files attached to records, DocumentSource documents over a Connection, emails and text a module receives) into extracted text and bounded, overlapping chunks that Search indexes under the record they belong to, so they are found exactly by those who may read the record. Each source item runs as a durable workflow (fetch, extract, chunk, index) that survives restarts without indexing anything twice, is idempotent per source item and version (resubmitting changes nothing; a new version supersedes the old one's chunks; a failed item resubmitted runs again), and reports its state and progress.",
188
+ operations: {
189
+ stageDataset: defineOperation({
190
+ description:
191
+ "data.stage, ctx.ingestion.datasets.stage: stage rows as a dataset of the caller (a person) or the calling module, replacing it (or one page of it); bounded per dataset and per owner, expiring.",
192
+ input: StageDataset,
193
+ output: DatasetInfo,
194
+ errors: Schema.Union([Unauthenticated, Forbidden, InvalidInput]),
195
+ }),
196
+ queryDataset: defineOperation({
197
+ description:
198
+ "data.query, ctx.ingestion.datasets.query: one read-only SELECT over the relation dataset, of the owner's dataset, in a transaction that always rolls back.",
199
+ input: QueryDataset,
200
+ output: DatasetRows,
201
+ errors: Schema.Union([Unauthenticated, Forbidden, InvalidInput]),
202
+ }),
203
+ listDatasets: defineOperation({
204
+ description: "data.datasets, ctx.ingestion.datasets.list: the owner's datasets that have not expired.",
205
+ input: Schema.Struct({}),
206
+ output: Schema.Struct({ datasets: Schema.Array(DatasetInfo) }),
207
+ errors: Schema.Union([Unauthenticated, Forbidden]),
208
+ }),
209
+ dropDataset: defineOperation({
210
+ description: "data.drop, ctx.ingestion.datasets.drop: delete one of the owner's datasets.",
211
+ input: Schema.Struct({ name: Schema.String }),
212
+ output: Schema.Struct({ dropped: Schema.Boolean }),
213
+ errors: Schema.Union([Unauthenticated, Forbidden]),
214
+ }),
215
+ collect: defineOperation({
216
+ description:
217
+ "data.collect, ctx.ingestion.collect: a durable, checkpointed collection of a provider's paginated listing over the caller's Connection into a dataset of the caller or the calling module, under the call's authority; at most three at once per owner.",
218
+ input: CollectSpec,
219
+ output: Schema.Struct({ collectionId: Schema.String }),
220
+ errors: Schema.Union([Unauthenticated, Forbidden, InvalidInput]),
221
+ }),
222
+ collection: defineOperation({
223
+ description: "data.collection, ctx.ingestion.collection: how one of the owner's collections stands.",
224
+ input: Schema.Struct({ collectionId: Schema.String }),
225
+ output: CollectionStatus,
226
+ errors: Schema.Union([Unauthenticated, InvalidInput]),
227
+ }),
228
+ submit: defineOperation({
229
+ description:
230
+ "In process (a handler's `ctx.ingestion.submit`, for the module's own records, in its transaction): queue a source item for a record. Idempotent per (record, source item, version).",
231
+ input: SubmitIngestion,
232
+ output: SubmitResult,
233
+ errors: Schema.Union([Forbidden, InvalidInput]),
234
+ }),
235
+ status: defineOperation({
236
+ description:
237
+ "The ingestion items of a record the caller may read, with their state and progress (action ingestion.status).",
238
+ input: RecordRef,
239
+ output: Schema.Struct({ items: Schema.Array(IngestionItem) }),
240
+ errors: Schema.Union([Unauthenticated, Forbidden, InvalidInput]),
241
+ }),
242
+ openRun: defineOperation({
243
+ description:
244
+ "ctx.ingestion.runs.open: a bulk run of the calling module in the acting organisation over an inventory of item keys, with an optional budget of cost units; its id.",
245
+ input: OpenRun,
246
+ output: Schema.Struct({ runId: Schema.String }),
247
+ errors: InvalidInput,
248
+ }),
249
+ claim: defineOperation({
250
+ description:
251
+ "ctx.ingestion.runs.claim: lease up to `max` items for `leaseMs` to a worker: pending items, and items whose lease ran out (a crashed worker's, resumed with their next attempt). None once the run is stopped or completed.",
252
+ input: Schema.Struct({ runId: Schema.String, worker: Schema.String, max: Schema.Number, leaseMs: Schema.Number }),
253
+ output: Schema.Array(ClaimedItem),
254
+ errors: InvalidInput,
255
+ }),
256
+ completeItem: defineOperation({
257
+ description:
258
+ "ctx.ingestion.runs.complete: an item the worker holds under the attempt `claim` gave it, done, with its cost (default 1); refused when that lease ran out or the item was leased again (by another worker, or the same one). Spending the budget stops the run: no item is leased after.",
259
+ input: Schema.Struct({
260
+ runId: Schema.String,
261
+ worker: Schema.String,
262
+ key: Schema.String,
263
+ attempt: Schema.Number,
264
+ cost: Schema.optionalKey(Schema.Number),
265
+ }),
266
+ output: Schema.Struct({ status: BulkRunStatus }),
267
+ errors: InvalidInput,
268
+ }),
269
+ reportItem: defineOperation({
270
+ description:
271
+ "ctx.ingestion.runs.report: an item the worker holds, not processed, with the reason (gone at the provider, refused): it counts towards completeness.",
272
+ input: Schema.Struct({
273
+ runId: Schema.String,
274
+ worker: Schema.String,
275
+ key: Schema.String,
276
+ attempt: Schema.Number,
277
+ reason: Schema.String,
278
+ }),
279
+ output: Schema.Struct({ status: BulkRunStatus }),
280
+ errors: InvalidInput,
281
+ }),
282
+ inventory: defineOperation({
283
+ description:
284
+ "ctx.ingestion.runs.inventory: the run's inventory (the calling module's, in the acting organisation).",
285
+ input: Schema.Struct({ runId: Schema.String }),
286
+ output: RunInventory,
287
+ errors: InvalidInput,
288
+ }),
289
+ finishRun: defineOperation({
290
+ description:
291
+ "ctx.ingestion.runs.finish: complete the run, refused (naming the items) while any item is neither done nor reported; a stopped run stays stopped.",
292
+ input: Schema.Struct({ runId: Schema.String }),
293
+ output: RunInventory,
294
+ errors: InvalidInput,
295
+ }),
296
+ extract: defineOperation({
297
+ description:
298
+ "The extractor hook (in process, `Extractor`): text and an optional title from a media type the kernel does not extract itself.",
299
+ input: Schema.Struct({ mediaType: Schema.String, name: Schema.NullOr(Schema.String), bodyBase64: Schema.String }),
300
+ output: Extracted,
301
+ errors: Schema.Never,
302
+ }),
303
+ },
304
+ types: {
305
+ IngestionSource,
306
+ SubmitIngestion,
307
+ IngestionState,
308
+ IngestionItem,
309
+ SubmitResult,
310
+ Extracted,
311
+ OpenRun,
312
+ ClaimedItem,
313
+ RunInventory,
314
+ },
315
+ })