@segmentstream/ontology 0.0.0-stage → 0.92.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 (483) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +2 -0
  3. package/README.md +1655 -2
  4. package/dist/action.d.ts +193 -0
  5. package/dist/action.js +41 -0
  6. package/dist/agent-chat.d.ts +44 -0
  7. package/dist/agent-chat.js +91 -0
  8. package/dist/agent-task-contract.d.ts +64 -0
  9. package/dist/agent-task-contract.js +15 -0
  10. package/dist/agent-task.d.ts +39 -0
  11. package/dist/agent-task.js +112 -0
  12. package/dist/analyze.d.ts +215 -0
  13. package/dist/analyze.js +2438 -0
  14. package/dist/app-feedback.d.ts +167 -0
  15. package/dist/app-feedback.js +176 -0
  16. package/dist/authoring-input.d.ts +3 -0
  17. package/dist/authoring-input.js +107 -0
  18. package/dist/authoring-names.d.ts +4 -0
  19. package/dist/authoring-names.js +13 -0
  20. package/dist/authoring-records.d.ts +35 -0
  21. package/dist/authoring-records.js +264 -0
  22. package/dist/authoring.d.ts +15 -0
  23. package/dist/authoring.js +331 -0
  24. package/dist/bin/check.d.ts +30 -0
  25. package/dist/bin/check.js +99 -0
  26. package/dist/bin/load.d.ts +48 -0
  27. package/dist/bin/load.js +139 -0
  28. package/dist/bin/main.d.ts +31 -0
  29. package/dist/bin/main.js +121 -0
  30. package/dist/bin/migrate.d.ts +57 -0
  31. package/dist/bin/migrate.js +170 -0
  32. package/dist/bin/output.d.ts +31 -0
  33. package/dist/bin/output.js +84 -0
  34. package/dist/bin.d.ts +2 -0
  35. package/dist/bin.js +31 -0
  36. package/dist/blob.d.ts +52 -0
  37. package/dist/blob.js +87 -0
  38. package/dist/channel-session.d.ts +16 -0
  39. package/dist/channel-session.js +16 -0
  40. package/dist/chat.d.ts +43 -0
  41. package/dist/chat.js +34 -0
  42. package/dist/confirmation.d.ts +46 -0
  43. package/dist/confirmation.js +41 -0
  44. package/dist/connection.d.ts +213 -0
  45. package/dist/connection.js +289 -0
  46. package/dist/deployment.d.ts +35 -0
  47. package/dist/deployment.js +76 -0
  48. package/dist/diagnostics.d.ts +27 -0
  49. package/dist/diagnostics.js +106 -0
  50. package/dist/emails.d.ts +70 -0
  51. package/dist/emails.js +221 -0
  52. package/dist/entity.d.ts +331 -0
  53. package/dist/entity.js +153 -0
  54. package/dist/errors.d.ts +154 -0
  55. package/dist/errors.js +109 -0
  56. package/dist/feedback-config.d.ts +24 -0
  57. package/dist/feedback-config.js +126 -0
  58. package/dist/files.d.ts +39 -0
  59. package/dist/files.js +4 -0
  60. package/dist/groups.d.ts +95 -0
  61. package/dist/groups.js +280 -0
  62. package/dist/index.d.ts +109 -0
  63. package/dist/index.js +70 -0
  64. package/dist/internal/diagnostics.js +594 -0
  65. package/dist/legacy.d.ts +160 -0
  66. package/dist/legacy.js +270 -0
  67. package/dist/manifest-compatibility.d.ts +8 -0
  68. package/dist/manifest-compatibility.js +87 -0
  69. package/dist/manifest.d.ts +3329 -0
  70. package/dist/manifest.js +757 -0
  71. package/dist/me.d.ts +46 -0
  72. package/dist/me.js +109 -0
  73. package/dist/metric-filters.d.ts +48 -0
  74. package/dist/metric-filters.js +252 -0
  75. package/dist/metric-routes.d.ts +132 -0
  76. package/dist/metric-routes.js +498 -0
  77. package/dist/metric.d.ts +172 -0
  78. package/dist/metric.js +132 -0
  79. package/dist/migrate/apply.d.ts +94 -0
  80. package/dist/migrate/apply.js +526 -0
  81. package/dist/migrate/errors.d.ts +46 -0
  82. package/dist/migrate/errors.js +38 -0
  83. package/dist/migrate/index.d.ts +10 -0
  84. package/dist/migrate/index.js +7 -0
  85. package/dist/migrate/model.d.ts +2311 -0
  86. package/dist/migrate/model.js +148 -0
  87. package/dist/migrate/plan.d.ts +51 -0
  88. package/dist/migrate/plan.js +1856 -0
  89. package/dist/migrate/preview.d.ts +13 -0
  90. package/dist/migrate/preview.js +65 -0
  91. package/dist/migrate/storage.d.ts +226 -0
  92. package/dist/migrate/storage.js +774 -0
  93. package/dist/model-metrics.d.ts +22 -0
  94. package/dist/model-metrics.js +545 -0
  95. package/dist/names.d.ts +49 -0
  96. package/dist/names.js +110 -0
  97. package/dist/navigation-artifact.d.ts +13 -0
  98. package/dist/navigation-artifact.js +11 -0
  99. package/dist/navigation-catalog.d.ts +55 -0
  100. package/dist/navigation-catalog.js +297 -0
  101. package/dist/nitro-navigation.d.ts +3 -0
  102. package/dist/nitro-navigation.js +64 -0
  103. package/dist/nitro-workflows.d.ts +108 -0
  104. package/dist/nitro-workflows.js +286 -0
  105. package/dist/nitro.d.ts +40 -0
  106. package/dist/nitro.js +50 -0
  107. package/dist/ontology.d.ts +41 -0
  108. package/dist/ontology.js +46 -0
  109. package/dist/permissions.d.ts +198 -0
  110. package/dist/permissions.js +272 -0
  111. package/dist/property.d.ts +188 -0
  112. package/dist/property.js +301 -0
  113. package/dist/query.d.ts +245 -0
  114. package/dist/query.js +615 -0
  115. package/dist/relationship.d.ts +99 -0
  116. package/dist/relationship.js +33 -0
  117. package/dist/render.d.ts +81 -0
  118. package/dist/render.js +512 -0
  119. package/dist/replication/baseline.d.ts +51 -0
  120. package/dist/replication/baseline.js +215 -0
  121. package/dist/replication/bigquery.d.ts +37 -0
  122. package/dist/replication/bigquery.js +211 -0
  123. package/dist/replication/coverage.d.ts +14 -0
  124. package/dist/replication/coverage.js +53 -0
  125. package/dist/replication/evolution.d.ts +25 -0
  126. package/dist/replication/evolution.js +184 -0
  127. package/dist/replication/identities.d.ts +6 -0
  128. package/dist/replication/identities.js +47 -0
  129. package/dist/replication/legacy-baseline.d.ts +27 -0
  130. package/dist/replication/legacy-baseline.js +109 -0
  131. package/dist/replication/legacy-store.d.ts +19 -0
  132. package/dist/replication/legacy-store.js +63 -0
  133. package/dist/replication/lineage.d.ts +36 -0
  134. package/dist/replication/lineage.js +72 -0
  135. package/dist/replication/migrate.d.ts +21 -0
  136. package/dist/replication/migrate.js +84 -0
  137. package/dist/replication/model.d.ts +52 -0
  138. package/dist/replication/model.js +99 -0
  139. package/dist/replication/scans.d.ts +34 -0
  140. package/dist/replication/scans.js +158 -0
  141. package/dist/replication/schema.d.ts +11 -0
  142. package/dist/replication/schema.js +226 -0
  143. package/dist/replication/shadow-schema.d.ts +4 -0
  144. package/dist/replication/shadow-schema.js +61 -0
  145. package/dist/replication/shadow.d.ts +127 -0
  146. package/dist/replication/shadow.js +614 -0
  147. package/dist/replication/source-replacement.d.ts +33 -0
  148. package/dist/replication/source-replacement.js +76 -0
  149. package/dist/replication/store.d.ts +36 -0
  150. package/dist/replication/store.js +382 -0
  151. package/dist/replication/transaction.d.ts +23 -0
  152. package/dist/replication/transaction.js +88 -0
  153. package/dist/role.d.ts +61 -0
  154. package/dist/role.js +76 -0
  155. package/dist/runtime/action-deadlocks.d.ts +21 -0
  156. package/dist/runtime/action-deadlocks.js +130 -0
  157. package/dist/runtime/action-transactions.d.ts +35 -0
  158. package/dist/runtime/action-transactions.js +54 -0
  159. package/dist/runtime/agent-counters.d.ts +26 -0
  160. package/dist/runtime/agent-counters.js +98 -0
  161. package/dist/runtime/agent-tasks.d.ts +63 -0
  162. package/dist/runtime/agent-tasks.js +120 -0
  163. package/dist/runtime/agents.d.ts +15 -0
  164. package/dist/runtime/agents.js +457 -0
  165. package/dist/runtime/batch-diagnostics.d.ts +22 -0
  166. package/dist/runtime/batch-diagnostics.js +89 -0
  167. package/dist/runtime/batch.d.ts +52 -0
  168. package/dist/runtime/batch.js +534 -0
  169. package/dist/runtime/channel-session-revocation.d.ts +3 -0
  170. package/dist/runtime/channel-session-revocation.js +5 -0
  171. package/dist/runtime/channel-sessions.d.ts +4 -0
  172. package/dist/runtime/channel-sessions.js +61 -0
  173. package/dist/runtime/confirmations.d.ts +29 -0
  174. package/dist/runtime/confirmations.js +57 -0
  175. package/dist/runtime/cursor.d.ts +23 -0
  176. package/dist/runtime/cursor.js +100 -0
  177. package/dist/runtime/deployment.d.ts +7 -0
  178. package/dist/runtime/deployment.js +4 -0
  179. package/dist/runtime/errors.d.ts +118 -0
  180. package/dist/runtime/errors.js +109 -0
  181. package/dist/runtime/federation-tables.d.ts +2 -0
  182. package/dist/runtime/federation-tables.js +20 -0
  183. package/dist/runtime/federation.d.ts +42 -0
  184. package/dist/runtime/federation.js +222 -0
  185. package/dist/runtime/files.d.ts +39 -0
  186. package/dist/runtime/files.js +44 -0
  187. package/dist/runtime/generated-actions.d.ts +37 -0
  188. package/dist/runtime/generated-actions.js +307 -0
  189. package/dist/runtime/history.d.ts +91 -0
  190. package/dist/runtime/history.js +77 -0
  191. package/dist/runtime/ids.d.ts +6 -0
  192. package/dist/runtime/ids.js +39 -0
  193. package/dist/runtime/member-tables.d.ts +8 -0
  194. package/dist/runtime/member-tables.js +33 -0
  195. package/dist/runtime/member-writes.d.ts +78 -0
  196. package/dist/runtime/member-writes.js +202 -0
  197. package/dist/runtime/metric-query.d.ts +19 -0
  198. package/dist/runtime/metric-query.js +411 -0
  199. package/dist/runtime/model.d.ts +67 -0
  200. package/dist/runtime/model.js +150 -0
  201. package/dist/runtime/new-user-hook.d.ts +6 -0
  202. package/dist/runtime/new-user-hook.js +37 -0
  203. package/dist/runtime/oauth.d.ts +9 -0
  204. package/dist/runtime/oauth.js +299 -0
  205. package/dist/runtime/pipeline.d.ts +155 -0
  206. package/dist/runtime/pipeline.js +597 -0
  207. package/dist/runtime/postgres-tls.d.ts +10 -0
  208. package/dist/runtime/postgres-tls.js +14 -0
  209. package/dist/runtime/principals.d.ts +302 -0
  210. package/dist/runtime/principals.js +1307 -0
  211. package/dist/runtime/reads.d.ts +55 -0
  212. package/dist/runtime/reads.js +313 -0
  213. package/dist/runtime/records.d.ts +42 -0
  214. package/dist/runtime/records.js +245 -0
  215. package/dist/runtime/resolve-agent-identity.d.ts +6 -0
  216. package/dist/runtime/resolve-agent-identity.js +181 -0
  217. package/dist/runtime/service-binding.d.ts +18 -0
  218. package/dist/runtime/service-binding.js +266 -0
  219. package/dist/runtime/sign-in-links.d.ts +68 -0
  220. package/dist/runtime/sign-in-links.js +147 -0
  221. package/dist/runtime/sql-runtime.d.ts +131 -0
  222. package/dist/runtime/sql-runtime.js +362 -0
  223. package/dist/runtime/statement.d.ts +18 -0
  224. package/dist/runtime/statement.js +31 -0
  225. package/dist/runtime/user-identities.d.ts +66 -0
  226. package/dist/runtime/user-identities.js +106 -0
  227. package/dist/runtime/user-identity-sql.d.ts +86 -0
  228. package/dist/runtime/user-identity-sql.js +297 -0
  229. package/dist/runtime/user-roles.d.ts +16 -0
  230. package/dist/runtime/user-roles.js +32 -0
  231. package/dist/runtime/validation.d.ts +16 -0
  232. package/dist/runtime/validation.js +26 -0
  233. package/dist/runtime/where.d.ts +57 -0
  234. package/dist/runtime/where.js +404 -0
  235. package/dist/runtime/workflow-admission.d.ts +49 -0
  236. package/dist/runtime/workflow-admission.js +92 -0
  237. package/dist/runtime/workflow-argument-codec.d.ts +10 -0
  238. package/dist/runtime/workflow-argument-codec.js +120 -0
  239. package/dist/runtime/workflow-arguments.d.ts +17 -0
  240. package/dist/runtime/workflow-arguments.js +99 -0
  241. package/dist/runtime/workflow-starts.d.ts +203 -0
  242. package/dist/runtime/workflow-starts.js +493 -0
  243. package/dist/runtime/workflow-users.d.ts +9 -0
  244. package/dist/runtime/workflow-users.js +17 -0
  245. package/dist/runtime/workload.d.ts +25 -0
  246. package/dist/runtime/workload.js +24 -0
  247. package/dist/runtime/writes.d.ts +108 -0
  248. package/dist/runtime/writes.js +491 -0
  249. package/dist/runtime-source.d.ts +22 -0
  250. package/dist/runtime-source.js +28 -0
  251. package/dist/runtime.d.ts +310 -0
  252. package/dist/runtime.js +31 -0
  253. package/dist/server.d.ts +23 -0
  254. package/dist/server.js +107 -0
  255. package/dist/service/agent/attachments.d.ts +33 -0
  256. package/dist/service/agent/attachments.js +228 -0
  257. package/dist/service/agent/authentication.d.ts +22 -0
  258. package/dist/service/agent/authentication.js +58 -0
  259. package/dist/service/agent/confirmations.d.ts +5 -0
  260. package/dist/service/agent/confirmations.js +73 -0
  261. package/dist/service/agent/conversation-routes.d.ts +14 -0
  262. package/dist/service/agent/conversation-routes.js +45 -0
  263. package/dist/service/agent/conversations.d.ts +40 -0
  264. package/dist/service/agent/conversations.js +69 -0
  265. package/dist/service/agent/files.d.ts +12 -0
  266. package/dist/service/agent/files.js +69 -0
  267. package/dist/service/agent/protocol.d.ts +90 -0
  268. package/dist/service/agent/protocol.js +114 -0
  269. package/dist/service/agent/server.d.ts +28 -0
  270. package/dist/service/agent/server.js +374 -0
  271. package/dist/service/agent/task-caller.d.ts +21 -0
  272. package/dist/service/agent/task-caller.js +35 -0
  273. package/dist/service/agent/task-start.d.ts +53 -0
  274. package/dist/service/agent/task-start.js +161 -0
  275. package/dist/service/agent/tasks.d.ts +40 -0
  276. package/dist/service/agent/tasks.js +155 -0
  277. package/dist/service/api.d.ts +50 -0
  278. package/dist/service/api.js +288 -0
  279. package/dist/service/authentication.d.ts +227 -0
  280. package/dist/service/authentication.js +767 -0
  281. package/dist/service/caller-context.d.ts +24 -0
  282. package/dist/service/caller-context.js +6 -0
  283. package/dist/service/catalog.d.ts +42 -0
  284. package/dist/service/catalog.js +66 -0
  285. package/dist/service/channel/provider.d.ts +10 -0
  286. package/dist/service/channel/provider.js +1 -0
  287. package/dist/service/channel/providers/telegram.d.ts +18 -0
  288. package/dist/service/channel/providers/telegram.js +108 -0
  289. package/dist/service/channel/sessions.d.ts +5 -0
  290. package/dist/service/channel/sessions.js +53 -0
  291. package/dist/service/channel/sign-in.d.ts +7 -0
  292. package/dist/service/channel/sign-in.js +78 -0
  293. package/dist/service/chat/archive.d.ts +64 -0
  294. package/dist/service/chat/archive.js +62 -0
  295. package/dist/service/chat/attribution.d.ts +26 -0
  296. package/dist/service/chat/attribution.js +28 -0
  297. package/dist/service/chat/delivery.d.ts +18 -0
  298. package/dist/service/chat/delivery.js +251 -0
  299. package/dist/service/chat/diagnostics.d.ts +2 -0
  300. package/dist/service/chat/diagnostics.js +35 -0
  301. package/dist/service/chat/envelope.d.ts +96 -0
  302. package/dist/service/chat/envelope.js +39 -0
  303. package/dist/service/chat/idempotency.d.ts +19 -0
  304. package/dist/service/chat/idempotency.js +37 -0
  305. package/dist/service/chat/providers/telegram.d.ts +36 -0
  306. package/dist/service/chat/providers/telegram.js +133 -0
  307. package/dist/service/chat/reads.d.ts +25 -0
  308. package/dist/service/chat/reads.js +75 -0
  309. package/dist/service/chat/resolve.d.ts +34 -0
  310. package/dist/service/chat/resolve.js +150 -0
  311. package/dist/service/chat/routes.d.ts +23 -0
  312. package/dist/service/chat/routes.js +75 -0
  313. package/dist/service/chat/schemas.d.ts +43 -0
  314. package/dist/service/chat/schemas.js +31 -0
  315. package/dist/service/config.d.ts +218 -0
  316. package/dist/service/config.js +265 -0
  317. package/dist/service/connection-stream.d.ts +10 -0
  318. package/dist/service/connection-stream.js +191 -0
  319. package/dist/service/connections.d.ts +60 -0
  320. package/dist/service/connections.js +271 -0
  321. package/dist/service/decisions.d.ts +35 -0
  322. package/dist/service/decisions.js +63 -0
  323. package/dist/service/descriptions.d.ts +8 -0
  324. package/dist/service/descriptions.js +20 -0
  325. package/dist/service/discovery-schemas.d.ts +92 -0
  326. package/dist/service/discovery-schemas.js +59 -0
  327. package/dist/service/discovery-search.d.ts +30 -0
  328. package/dist/service/discovery-search.js +95 -0
  329. package/dist/service/discovery.d.ts +37 -0
  330. package/dist/service/discovery.js +436 -0
  331. package/dist/service/docs.d.ts +9 -0
  332. package/dist/service/docs.js +197 -0
  333. package/dist/service/errors.d.ts +145 -0
  334. package/dist/service/errors.js +704 -0
  335. package/dist/service/federation-provider.d.ts +36 -0
  336. package/dist/service/federation-provider.js +110 -0
  337. package/dist/service/federation-server.d.ts +20 -0
  338. package/dist/service/federation-server.js +249 -0
  339. package/dist/service/federation-status.d.ts +40 -0
  340. package/dist/service/federation-status.js +151 -0
  341. package/dist/service/handlers.d.ts +18 -0
  342. package/dist/service/handlers.js +287 -0
  343. package/dist/service/mcp/confirmation.d.ts +68 -0
  344. package/dist/service/mcp/confirmation.js +178 -0
  345. package/dist/service/mcp/find-input.d.ts +12 -0
  346. package/dist/service/mcp/find-input.js +122 -0
  347. package/dist/service/mcp/input-schema.d.ts +6 -0
  348. package/dist/service/mcp/input-schema.js +126 -0
  349. package/dist/service/mcp/listing.d.ts +26 -0
  350. package/dist/service/mcp/listing.js +92 -0
  351. package/dist/service/mcp/metric-tools.d.ts +85 -0
  352. package/dist/service/mcp/metric-tools.js +258 -0
  353. package/dist/service/mcp/request-log.d.ts +5 -0
  354. package/dist/service/mcp/request-log.js +53 -0
  355. package/dist/service/mcp/runtime-policy.d.ts +27 -0
  356. package/dist/service/mcp/runtime-policy.js +62 -0
  357. package/dist/service/mcp/server.d.ts +52 -0
  358. package/dist/service/mcp/server.js +861 -0
  359. package/dist/service/mcp/tools.d.ts +99 -0
  360. package/dist/service/mcp/tools.js +938 -0
  361. package/dist/service/member-file-routes.d.ts +22 -0
  362. package/dist/service/member-file-routes.js +52 -0
  363. package/dist/service/member-files.d.ts +245 -0
  364. package/dist/service/member-files.js +258 -0
  365. package/dist/service/metric-query-platform.d.ts +77 -0
  366. package/dist/service/metric-query-platform.js +198 -0
  367. package/dist/service/metric-query-scopes.d.ts +43 -0
  368. package/dist/service/metric-query-scopes.js +147 -0
  369. package/dist/service/metric-query.d.ts +48 -0
  370. package/dist/service/metric-query.js +200 -0
  371. package/dist/service/name-suggestions.d.ts +3 -0
  372. package/dist/service/name-suggestions.js +38 -0
  373. package/dist/service/navigation-schemas.d.ts +80 -0
  374. package/dist/service/navigation-schemas.js +49 -0
  375. package/dist/service/navigation.d.ts +20 -0
  376. package/dist/service/navigation.js +165 -0
  377. package/dist/service/oauth/protocol.d.ts +70 -0
  378. package/dist/service/oauth/protocol.js +157 -0
  379. package/dist/service/oauth/refresh-replay.d.ts +2 -0
  380. package/dist/service/oauth/refresh-replay.js +20 -0
  381. package/dist/service/oauth/server.d.ts +28 -0
  382. package/dist/service/oauth/server.js +769 -0
  383. package/dist/service/operations.d.ts +170 -0
  384. package/dist/service/operations.js +392 -0
  385. package/dist/service/plan.d.ts +57 -0
  386. package/dist/service/plan.js +96 -0
  387. package/dist/service/rate-limit.d.ts +22 -0
  388. package/dist/service/rate-limit.js +52 -0
  389. package/dist/service/record-reads.d.ts +21 -0
  390. package/dist/service/record-reads.js +155 -0
  391. package/dist/service/replication.d.ts +5 -0
  392. package/dist/service/replication.js +39 -0
  393. package/dist/service/runtime-contract.d.ts +508 -0
  394. package/dist/service/runtime-contract.js +18 -0
  395. package/dist/service/runtime-identity.d.ts +71 -0
  396. package/dist/service/runtime-identity.js +122 -0
  397. package/dist/service/schemas.d.ts +961 -0
  398. package/dist/service/schemas.js +639 -0
  399. package/dist/service/service.d.ts +21 -0
  400. package/dist/service/service.js +526 -0
  401. package/dist/service/warehouse-platform.d.ts +17 -0
  402. package/dist/service/warehouse-platform.js +122 -0
  403. package/dist/service/warehouse-query.d.ts +24 -0
  404. package/dist/service/warehouse-query.js +280 -0
  405. package/dist/service/webhooks.d.ts +106 -0
  406. package/dist/service/webhooks.js +233 -0
  407. package/dist/service/workflow-admission-provider.d.ts +31 -0
  408. package/dist/service/workflow-admission-provider.js +205 -0
  409. package/dist/service/workflow-argument-serialization.d.ts +2 -0
  410. package/dist/service/workflow-argument-serialization.js +14 -0
  411. package/dist/service/workflow-callback.d.ts +22 -0
  412. package/dist/service/workflow-callback.js +75 -0
  413. package/dist/service/workflow-deployment.d.ts +8 -0
  414. package/dist/service/workflow-deployment.js +131 -0
  415. package/dist/service/workflow-diagnostics.d.ts +23 -0
  416. package/dist/service/workflow-diagnostics.js +263 -0
  417. package/dist/service/workflow-errors.d.ts +26 -0
  418. package/dist/service/workflow-errors.js +181 -0
  419. package/dist/service/workflow-logging.d.ts +2 -0
  420. package/dist/service/workflow-logging.js +50 -0
  421. package/dist/service/workflow-queue-fence.d.ts +6 -0
  422. package/dist/service/workflow-queue-fence.js +66 -0
  423. package/dist/service/workflows.d.ts +200 -0
  424. package/dist/service/workflows.js +1549 -0
  425. package/dist/sign-in.d.ts +58 -0
  426. package/dist/sign-in.js +57 -0
  427. package/dist/source.d.ts +30 -0
  428. package/dist/source.js +107 -0
  429. package/dist/start-recovery-contract.d.ts +49 -0
  430. package/dist/start-recovery-contract.js +26 -0
  431. package/dist/start-recovery.d.ts +27 -0
  432. package/dist/start-recovery.js +81 -0
  433. package/dist/storage/api.d.ts +4 -0
  434. package/dist/storage/api.js +40 -0
  435. package/dist/storage/attachments.d.ts +146 -0
  436. package/dist/storage/attachments.js +733 -0
  437. package/dist/storage/authorization.d.ts +38 -0
  438. package/dist/storage/authorization.js +83 -0
  439. package/dist/storage/file-access.d.ts +17 -0
  440. package/dist/storage/file-access.js +8 -0
  441. package/dist/storage/limits.d.ts +12 -0
  442. package/dist/storage/limits.js +17 -0
  443. package/dist/storage/maintenance-auth.d.ts +20 -0
  444. package/dist/storage/maintenance-auth.js +24 -0
  445. package/dist/storage/maintenance.d.ts +11 -0
  446. package/dist/storage/maintenance.js +67 -0
  447. package/dist/storage/neon.d.ts +4 -0
  448. package/dist/storage/neon.js +318 -0
  449. package/dist/storage/operator.d.ts +11 -0
  450. package/dist/storage/operator.js +30 -0
  451. package/dist/storage/provider.d.ts +93 -0
  452. package/dist/storage/provider.js +36 -0
  453. package/dist/storage/sessions.d.ts +184 -0
  454. package/dist/storage/sessions.js +688 -0
  455. package/dist/storage/tables.d.ts +54 -0
  456. package/dist/storage/tables.js +205 -0
  457. package/dist/storage/transfers.d.ts +16 -0
  458. package/dist/storage/transfers.js +153 -0
  459. package/dist/storage/writes.d.ts +7 -0
  460. package/dist/storage/writes.js +88 -0
  461. package/dist/telegram.d.ts +35 -0
  462. package/dist/telegram.js +173 -0
  463. package/dist/user-identity.d.ts +28 -0
  464. package/dist/user-identity.js +106 -0
  465. package/dist/user.d.ts +75 -0
  466. package/dist/user.js +111 -0
  467. package/dist/warehouse-backed.d.ts +6 -0
  468. package/dist/warehouse-backed.js +495 -0
  469. package/dist/webhook-token.d.ts +11 -0
  470. package/dist/webhook-token.js +18 -0
  471. package/dist/webhooks.d.ts +40 -0
  472. package/dist/webhooks.js +55 -0
  473. package/dist/wire.d.ts +10 -0
  474. package/dist/wire.js +35 -0
  475. package/dist/workflow-runtime.d.ts +116 -0
  476. package/dist/workflow-runtime.js +109 -0
  477. package/dist/workflow-topics.d.ts +28 -0
  478. package/dist/workflow-topics.js +28 -0
  479. package/dist/workflow.d.ts +284 -0
  480. package/dist/workflow.js +259 -0
  481. package/dist/workflows.d.ts +24 -0
  482. package/dist/workflows.js +18 -0
  483. package/package.json +127 -4
@@ -0,0 +1,288 @@
1
+ import { Effect, Layer, Schema } from "effect";
2
+ import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi, } from "effect/unstable/httpapi";
3
+ import { EARLIER_QUERY_METRICS_ROUTE } from "../legacy.js";
4
+ import { QUERY_METRICS_ROUTE } from "../names.js";
5
+ import { storageGroup } from "../storage/api.js";
6
+ import { DownloadRequest, TransferGrant } from "../storage/sessions.js";
7
+ import { permissionOf, READ_VERB } from "../permissions.js";
8
+ import { generatedActions } from "../runtime/generated-actions.js";
9
+ import { Authentication } from "./authentication.js";
10
+ import { actionDescription, requires } from "./descriptions.js";
11
+ import { InvalidRequestBody, RequestId, failureResponse } from "./errors.js";
12
+ import { planApi, } from "./plan.js";
13
+ import { ActionResponse, MetricQueryBody, MetricQueryResult, EntityMetricQueryBody, AsParams, Catalog, ErrorSchemas, Graph, HistoryPage, HistoryParams, IdParam, WarehouseIdParam, Me, SignInCheckRequest, SignInCheckResult, Status, actionRequest, entitySchemas, } from "./schemas.js";
14
+ /** The path every ontology route lives under. */
15
+ export const BASE_PATH = "/api/ontology";
16
+ /** The group of the global routes. Entity names are snake_case, so it cannot clash with one. */
17
+ export const SERVICE_GROUP = "Ontology";
18
+ /**
19
+ * Maps every failure of a route, including input that fails its schema, to the service's error
20
+ * responses. It runs inside {@link Authentication}, so unauthenticated requests never reach it.
21
+ */
22
+ export class ErrorResponses extends HttpApiMiddleware.Service()("@segmentstream/ontology/ErrorResponses", {
23
+ error: [ErrorSchemas.invalidRequest, ErrorSchemas.internal],
24
+ }) {
25
+ }
26
+ export const ErrorResponsesLive = Layer.succeed(ErrorResponses)((httpEffect) => Effect.gen(function* () {
27
+ const requestId = yield* RequestId;
28
+ return yield* httpEffect.pipe(
29
+ // HttpApi answers a body it cannot decode with a plain-text 415.
30
+ Effect.flatMap((response) => response.status === 415
31
+ ? Effect.fail(new InvalidRequestBody({ reason: "unsupported_media_type", issues: [] }))
32
+ : Effect.succeed(response)), Effect.catchCause((cause) => failureResponse(cause, requestId)));
33
+ }));
34
+ function authenticated(endpoint) {
35
+ return endpoint.middleware(ErrorResponses).middleware(Authentication);
36
+ }
37
+ function documented(endpoint, summary, description) {
38
+ return endpoint.annotateMerge(OpenApi.annotations({ summary, ...(description !== undefined ? { description } : {}) }));
39
+ }
40
+ const serviceErrors = [ErrorSchemas.invalidRequest, ErrorSchemas.internal];
41
+ const readErrors = [
42
+ ErrorSchemas.invalidRequest,
43
+ ErrorSchemas.forbidden,
44
+ ErrorSchemas.internal,
45
+ ErrorSchemas.warehouseReadUnavailable,
46
+ ErrorSchemas.rateLimited,
47
+ ];
48
+ const recordErrors = [
49
+ ErrorSchemas.invalidRequest,
50
+ ErrorSchemas.forbidden,
51
+ ErrorSchemas.notFound,
52
+ ErrorSchemas.internal,
53
+ ErrorSchemas.warehouseReadUnavailable,
54
+ ErrorSchemas.rateLimited,
55
+ ];
56
+ const actionErrors = [
57
+ ErrorSchemas.invalidRequest,
58
+ ErrorSchemas.forbidden,
59
+ ErrorSchemas.notFound,
60
+ ErrorSchemas.conflict,
61
+ ErrorSchemas.unsupportedMediaType,
62
+ ErrorSchemas.unprocessable,
63
+ ErrorSchemas.internal,
64
+ ];
65
+ /**
66
+ * The facade's own refusals. SegmentStream's answers, success and errors alike, pass through as it
67
+ * sent them: its errors are `{ error, detail, requestId, retryable }`.
68
+ */
69
+ const metricQueryErrors = [
70
+ ErrorSchemas.invalidRequest,
71
+ ErrorSchemas.invalidMetricQuery,
72
+ ErrorSchemas.readForbidden,
73
+ ErrorSchemas.unsupportedMediaType,
74
+ ErrorSchemas.rateLimited,
75
+ ErrorSchemas.internal,
76
+ ErrorSchemas.metricQueryUpstreamUnavailable,
77
+ ErrorSchemas.metricQueriesUnavailable,
78
+ ];
79
+ /** An action that calls connections also answers for the connections it could not use. */
80
+ const connectionActionErrors = [
81
+ ...actionErrors,
82
+ ErrorSchemas.connectionRequired,
83
+ ErrorSchemas.connectionResponseInvalid,
84
+ ErrorSchemas.connectionUnavailable,
85
+ ];
86
+ function readPermission(entity) {
87
+ return permissionOf(entity, READ_VERB);
88
+ }
89
+ /** Whether an entity declares metrics, and so has `POST /api/ontology/<entity>/query_metrics`. */
90
+ export function hasMetrics(planned) {
91
+ return Object.keys(planned.resolved.entity.definition.metrics ?? {}).length > 0;
92
+ }
93
+ /** The name of the metric query endpoints at their current paths, in the service and entity groups. */
94
+ export const QUERY_METRICS_ENDPOINT = "queryMetrics";
95
+ /**
96
+ * A metric query route, `<base>/query_metrics`, and the same route at its earlier path,
97
+ * `<base>/aggregate`, which older app SDKs call: one request and answer, the earlier deprecated.
98
+ */
99
+ function metricQueryEndpoints(input) {
100
+ const { base, payload, summary, description } = input;
101
+ const endpoint = (name, route) => HttpApiEndpoint.post(name, `${base}/${route}`, {
102
+ payload,
103
+ success: MetricQueryResult,
104
+ error: metricQueryErrors,
105
+ });
106
+ return [
107
+ documented(endpoint(QUERY_METRICS_ENDPOINT, QUERY_METRICS_ROUTE), summary, description),
108
+ documented(
109
+ // @legacy ontology.metric-earlier-names
110
+ endpoint(EARLIER_QUERY_METRICS_ROUTE, EARLIER_QUERY_METRICS_ROUTE), summary, `The earlier path of ${base}/${QUERY_METRICS_ROUTE}, which it answers the same way.`).annotateMerge(OpenApi.annotations({ deprecated: true })),
111
+ ];
112
+ }
113
+ /** The per-entity shorthand, which runs as the caller like the model-level route. */
114
+ function entityMetricQueryEndpoints(planned) {
115
+ const { plural } = planned.resolved.entity.definition;
116
+ return metricQueryEndpoints({
117
+ base: `${BASE_PATH}/${planned.name}`,
118
+ payload: EntityMetricQueryBody,
119
+ summary: `Query ${plural.toLowerCase()} metrics`,
120
+ description: `The entity's metrics, with names relative to it: revenue, product.brand. dateRange bounds a ` +
121
+ "partitioned entity. Requires reading the entity and every entity along each path it " +
122
+ `groups, filters or orders by. Answered as POST ${BASE_PATH}/${QUERY_METRICS_ROUTE} is, ` +
123
+ "and counted against the same limit.",
124
+ });
125
+ }
126
+ function traversalEndpoint(planned, traversal, target, targetNames) {
127
+ const label = planned.resolved.entity.definition.label;
128
+ const reach = traversal.kind === "one" ? `one ${targetNames.label}` : `many ${targetNames.plural}`;
129
+ // A rel.one reaches one record; every to-many traversal is a paged query on the target.
130
+ const query = traversal.kind === "one" ? target.includeParams : target.queryParams;
131
+ const endpoint = HttpApiEndpoint.get(`related.${traversal.name}`, `${BASE_PATH}/${planned.name}/:id/${traversal.name}`, {
132
+ params: {
133
+ id: planned.resolved.entity.definition.source === undefined ? IdParam : WarehouseIdParam,
134
+ },
135
+ query,
136
+ success: target.findResult,
137
+ error: recordErrors,
138
+ });
139
+ const permissions = [...new Set([planned.name, traversal.target].map(readPermission))];
140
+ return documented(endpoint, `${label} ${traversal.phrase} ${reach} (${traversal.name})`, `${traversal.description}\n\n${requires(permissions)} Including a relationship requires ` +
141
+ "reading its entity too.");
142
+ }
143
+ function actionEndpoint(planned, plannedAction) {
144
+ const { name, action } = plannedAction;
145
+ const endpoint = HttpApiEndpoint.post(`actions.${name}`, `${BASE_PATH}/${planned.name}/actions/${name}`, {
146
+ payload: actionRequest(action.input),
147
+ success: ActionResponse,
148
+ error: action.connections.length > 0 ? connectionActionErrors : actionErrors,
149
+ });
150
+ return documented(endpoint, `${planned.name}.${name}`, actionDescription(plannedAction));
151
+ }
152
+ function entityGroup(planned, schemas, names) {
153
+ const own = schemas.get(planned.name);
154
+ const { definition } = planned.resolved.entity;
155
+ const base = `${BASE_PATH}/${planned.name}`;
156
+ const metricQueries = hasMetrics(planned)
157
+ ? entityMetricQueryEndpoints(planned).map(authenticated)
158
+ : [];
159
+ const plural = definition.plural.toLowerCase();
160
+ const read = requires([readPermission(planned.name)]);
161
+ const including = `${read} Including a relationship requires reading its entity too.`;
162
+ const endpoints = [
163
+ documented(HttpApiEndpoint.get("find", base, {
164
+ query: own.queryParams,
165
+ success: own.findResult,
166
+ error: readErrors,
167
+ }), `Find ${plural}`, `Filter, sort and page through records. The filter is JSON in the where parameter. ${including}`),
168
+ documented(HttpApiEndpoint.post("query", `${base}/query`, {
169
+ payload: own.query,
170
+ success: own.findResult,
171
+ error: readErrors,
172
+ }), `Query ${plural}`, `The same query as find, as a JSON body. ${including}`),
173
+ documented(HttpApiEndpoint.get("get", `${base}/:id`, {
174
+ params: { id: definition.source === undefined ? IdParam : WarehouseIdParam },
175
+ success: own.record,
176
+ error: recordErrors,
177
+ }), `Get a ${definition.label.toLowerCase()}`, read),
178
+ ...(definition.source === undefined
179
+ ? [
180
+ documented(HttpApiEndpoint.get("history", `${base}/:id/history`, {
181
+ params: { id: IdParam },
182
+ query: HistoryParams,
183
+ success: HistoryPage,
184
+ error: recordErrors,
185
+ }), `History of a ${definition.label.toLowerCase()}`, `What each action changed on the record, newest first. ${read}`),
186
+ ]
187
+ : []),
188
+ ...planned.traversals.map((traversal) => traversalEndpoint(planned, traversal, schemas.get(traversal.target), names.get(traversal.target) ?? { label: traversal.target, plural: traversal.target })),
189
+ ...planned.resolved.properties
190
+ .filter((property) => property.definition.type === "blob")
191
+ .map((property) => documented(HttpApiEndpoint.post(`blobs.${property.name}`, `${base}/:id/blobs/${property.name}/download`, {
192
+ params: { id: IdParam },
193
+ payload: DownloadRequest,
194
+ success: TransferGrant,
195
+ error: recordErrors,
196
+ }), `Download ${property.name}`, `Requires ${planned.name}:read. Historical revisions must belong to this record and field.`)),
197
+ ...planned.actions.map((action) => actionEndpoint(planned, action)),
198
+ ];
199
+ const [first, ...rest] = [...endpoints.map(authenticated), ...metricQueries];
200
+ return HttpApiGroup.make(planned.name)
201
+ .add(first, ...rest)
202
+ .annotateMerge(OpenApi.annotations({ title: definition.plural, description: definition.description }));
203
+ }
204
+ function serviceGroup() {
205
+ return HttpApiGroup.make(SERVICE_GROUP, { topLevel: true })
206
+ .add(authenticated(documented(HttpApiEndpoint.get("catalog", BASE_PATH, {
207
+ query: AsParams,
208
+ success: Catalog,
209
+ error: serviceErrors,
210
+ }), "The catalog", "The manifest: entities, properties, relationships, actions and roles with their " +
211
+ "permissions. With as=me, only the actions the caller's permissions may run.")), authenticated(documented(HttpApiEndpoint.get("graph", `${BASE_PATH}/graph`, {
212
+ success: Graph,
213
+ error: serviceErrors,
214
+ }), "Entities and their relationships, phrased in both directions")), authenticated(documented(HttpApiEndpoint.get("openapi", `${BASE_PATH}/openapi.json`, {
215
+ success: Schema.Record(Schema.String, Schema.Unknown),
216
+ error: serviceErrors,
217
+ }), "This OpenAPI document")), authenticated(documented(HttpApiEndpoint.get("me", `${BASE_PATH}/me`, {
218
+ success: Me,
219
+ error: serviceErrors,
220
+ }), "The caller", "The signed-in member, or the service an API key belongs to: the user, its roles and " +
221
+ "the permissions they grant. Needs only authentication; the app reads it once per " +
222
+ "session to show what the caller may do.")), authenticated(documented(HttpApiEndpoint.get("describe", `${BASE_PATH}/describe`, {
223
+ query: AsParams,
224
+ success: Schema.String.pipe(HttpApiSchema.asText()),
225
+ error: serviceErrors,
226
+ }), "The catalog as prose", "Written for agents and people. With as=me, only the actions the caller's " +
227
+ "permissions may run.")), documented(HttpApiEndpoint.get("status", `${BASE_PATH}/status`, {
228
+ success: Status,
229
+ error: serviceErrors,
230
+ }).middleware(ErrorResponses), "The served and the applied manifest hash", "Public: the deploy pipeline compares the hashes before it marks a deployment ready."), documented(HttpApiEndpoint.post("signInCheck", `${BASE_PATH}/sign-in/check`, {
231
+ payload: SignInCheckRequest,
232
+ success: SignInCheckResult,
233
+ error: [ErrorSchemas.invalidRequest, ErrorSchemas.rateLimited, ErrorSchemas.internal],
234
+ }).middleware(ErrorResponses), "Whether an address may sign in", "Public and rate limited per client address. The app asks before it emails a code or a " +
235
+ "sign-in link. Under the invited policy, an active member's address is allowed: with " +
236
+ "code once they have signed in with Neon Auth, with link before; any other address, " +
237
+ "deactivated members included, is not. Under open, every address is allowed with link."), ...metricQueryEndpoints({
238
+ base: BASE_PATH,
239
+ payload: MetricQueryBody,
240
+ summary: "Query metrics across the ontology",
241
+ description: "Numbers about the model: metrics from several entities, grouped and filtered by " +
242
+ "properties of related entities. Look at or change records through find and actions; " +
243
+ "count, sum or compare through query_metrics. Names are <entity>.<metric> and " +
244
+ "<entity>.<property>, or a route from a metric's entity: " +
245
+ "<entity>.<relationship>.<property>. Requires <entity>:read on every entity the " +
246
+ "request reads: each metric's entity, and every entity on a dimension's or a " +
247
+ "filter's route, and at most 30 metric queries a minute per caller, MCP included. The " +
248
+ "service then forwards the request to SegmentStream, which " +
249
+ "answers from the warehouse and the replica of stored records; its answer, errors " +
250
+ "included, is returned unchanged. Preview deployments answer aggregate_unavailable.",
251
+ }).map(authenticated))
252
+ .annotateMerge(OpenApi.annotations({ title: SERVICE_GROUP, description: "The ontology as a whole." }));
253
+ }
254
+ export function buildApi(plan) {
255
+ const schemas = entitySchemas(plan);
256
+ const names = new Map(plan.entities.map(({ name, resolved }) => [
257
+ name,
258
+ { label: resolved.entity.definition.label, plural: resolved.entity.definition.plural },
259
+ ]));
260
+ const groups = [
261
+ serviceGroup(),
262
+ ...(plan.ontology.manifest.entities.some((entity) => entity.properties.some((property) => property.type === "blob"))
263
+ ? [
264
+ storageGroup(authenticated, [...actionErrors, ErrorSchemas.storageUnavailable], (endpoint) => endpoint.middleware(ErrorResponses)),
265
+ ]
266
+ : []),
267
+ ...plan.entities.map((planned) => entityGroup(planned, schemas, names)),
268
+ ];
269
+ const api = HttpApi.make("ontology")
270
+ .add(...groups)
271
+ .annotateMerge(OpenApi.annotations({
272
+ title: "Ontology",
273
+ version: plan.ontology.manifest.hash,
274
+ description: "The workspace app's ontology: read records, run actions and read the catalog. " +
275
+ "Every change goes through an action.",
276
+ }));
277
+ return { plan, api, schemas };
278
+ }
279
+ const runtimeGeneratedActions = (entity, ontology) => generatedActions(ontology, entity.name);
280
+ /**
281
+ * The HttpApi of an ontology: per entity `find`, `query`, `get`, `history`, a traversal per
282
+ * relationship and inverse, and a route per generated and authored action; and the catalog, graph,
283
+ * OpenAPI, status, caller (`me`), sign-in check, prose and metric query routes. There is no PUT, PATCH
284
+ * or DELETE: every change is an action.
285
+ */
286
+ export function deriveApi(ontology, options = {}) {
287
+ return buildApi(planApi(ontology, options.generatedActions ?? runtimeGeneratedActions)).api;
288
+ }
@@ -0,0 +1,227 @@
1
+ import { Context, Effect, Layer, Redacted } from "effect";
2
+ import { HttpServerRequest, type HttpServerResponse } from "effect/unstable/http";
3
+ import { HttpApiMiddleware, HttpApiSecurity } from "effect/unstable/httpapi";
4
+ import { type JWTVerifyGetKey } from "jose";
5
+ import { type DeploymentObservation } from "../deployment.js";
6
+ import { type BrowserRevision } from "./federation-status.js";
7
+ import type { WorkloadExecution } from "../runtime/workload.js";
8
+ import type { Principal } from "../runtime.js";
9
+ import type { NeonAuthEnvironment } from "./config.js";
10
+ import { RequestId } from "./errors.js";
11
+ import { CurrentCaller, type VerifiedCaller } from "./caller-context.js";
12
+ import { OntologyBackend, type SignInIdentity } from "./runtime-contract.js";
13
+ import { type RuntimeCredential, type RuntimeTokenVerifier } from "./runtime-identity.js";
14
+ declare const CurrentPrincipal_base: Context.ServiceClass<CurrentPrincipal, "@segmentstream/ontology/CurrentPrincipal", Principal>;
15
+ /** The principal the request runs as, provided by {@link Authentication}. */
16
+ export declare class CurrentPrincipal extends CurrentPrincipal_base {
17
+ }
18
+ declare const Authentication_base: HttpApiMiddleware.ServiceClass<Authentication, "@segmentstream/ontology/Authentication", {
19
+ requires: RequestId;
20
+ provides: CurrentCaller | CurrentPrincipal;
21
+ error: readonly [import("effect/Schema").Top, import("effect/Schema").Top, import("effect/Schema").Top];
22
+ clientError: never;
23
+ requiredForClient: false;
24
+ security: {
25
+ readonly bearer: HttpApiSecurity.Http;
26
+ };
27
+ }, HttpApiMiddleware.HttpApiMiddlewareSecurity<{
28
+ readonly bearer: HttpApiSecurity.Http;
29
+ }, CurrentCaller | CurrentPrincipal, readonly [import("effect/Schema").Top, import("effect/Schema").Top, import("effect/Schema").Top], RequestId>>;
30
+ /**
31
+ * Authenticates every ontology route except `status`: a Neon Auth token, a SegmentStream app token,
32
+ * an API key or the deployment's runtime token acting as a member, all as `Authorization: Bearer …`;
33
+ * without one, the app's Neon Auth session cookie. Failures answer the request directly, before its
34
+ * input is decoded.
35
+ */
36
+ export declare class Authentication extends Authentication_base {
37
+ }
38
+ export interface TokenVerifierConfig {
39
+ readonly browserRevision?: BrowserRevision;
40
+ readonly browserMethods?: readonly string[];
41
+ readonly oidc?: {
42
+ issuer: string;
43
+ clientId: string;
44
+ environment?: string;
45
+ deploymentId?: string;
46
+ manifestDigest?: string;
47
+ };
48
+ readonly deployment?: DeploymentObservation;
49
+ /** Production workload activation and the deployment actually serving the request. */
50
+ readonly workloadTarget?: {
51
+ readonly deploymentId: string;
52
+ };
53
+ /** The control plane: the issuer of app tokens and the host of their JWKS. */
54
+ readonly segmentstreamUrl: string;
55
+ readonly applicationId: string;
56
+ readonly workspaceId: string;
57
+ readonly organizationId: string;
58
+ }
59
+ export type TokenVerification = {
60
+ readonly status: "workload";
61
+ readonly execution: WorkloadExecution;
62
+ } | {
63
+ readonly status: "valid";
64
+ readonly identity: SignInIdentity;
65
+ } | {
66
+ readonly status: "invalid";
67
+ } | {
68
+ readonly status: "unavailable";
69
+ };
70
+ export type TokenVerifier = ((token: string) => Promise<TokenVerification>) & {
71
+ readonly browserRevision?: BrowserRevision;
72
+ readonly browserMethods?: readonly string[];
73
+ readonly oidc?: {
74
+ issuer: string;
75
+ clientId: string;
76
+ environment?: string;
77
+ deploymentId?: string;
78
+ manifestDigest?: string;
79
+ };
80
+ readonly deployment?: DeploymentObservation;
81
+ };
82
+ /** The control plane's app-token key set: `GET /api/v1/app-sessions/jwks`. */
83
+ export declare function remoteKeySet(segmentstreamUrl: string): JWTVerifyGetKey;
84
+ /** The workspace's Neon Auth key set, at `NEON_AUTH_JWKS_URL`. */
85
+ export declare function neonAuthKeySet(jwksUrl: string): JWTVerifyGetKey;
86
+ /**
87
+ * Verifies app tokens as the app SDK does: ES256 against the control plane's JWKS, issued by
88
+ * `SEGMENTSTREAM_URL` for this application (`aud: app:<application id>`), organization and workspace.
89
+ */
90
+ export declare function makeTokenVerifier(config: TokenVerifierConfig, keySet: JWTVerifyGetKey): TokenVerifier;
91
+ export declare const WORKLOAD_TOKEN_TYPE = "segmentstream-ontology-workload+jwt";
92
+ /** The workspace's pipeline workers' workload subject: `pipeline-workers:<workspace id>`. */
93
+ export declare const PIPELINE_WORKERS_SUBJECT_PREFIX = "pipeline-workers:";
94
+ /**
95
+ * The platform's workload subject, `platform:<workspace id>`: backend-next acting for the console
96
+ * and the CLI. It is admitted only to the workflow routes and never resolves as a principal.
97
+ */
98
+ export declare const PLATFORM_SUBJECT_PREFIX = "platform:";
99
+ /**
100
+ * Who a workload token's subject names in this workspace: its pipeline workers or the platform.
101
+ * `undefined` for any other subject.
102
+ */
103
+ export declare function workloadKind(claims: {
104
+ readonly sub?: unknown;
105
+ }, workspaceId: string): "pipeline" | "platform" | undefined;
106
+ /** A separate verifier: a workload token can never resolve as a human or act as an agent. */
107
+ export declare function makeWorkloadTokenVerifier(config: TokenVerifierConfig, keySet: JWTVerifyGetKey): TokenVerifier;
108
+ /**
109
+ * Neon Auth's issuer is the origin of its Auth URL: `https://ep-….neon.tech/ontology/auth` issues
110
+ * tokens with `iss: https://ep-….neon.tech`.
111
+ */
112
+ export declare function neonAuthIssuer(baseUrl: string): string;
113
+ /**
114
+ * Verifies the workspace's Neon Auth tokens (Managed Better Auth): EdDSA against its JWKS, issued by
115
+ * the origin of `NEON_AUTH_BASE_URL`, with a subject. The tokens carry no roles and no custom claims;
116
+ * roles come from the ontology.
117
+ */
118
+ export declare function makeNeonAuthTokenVerifier(config: {
119
+ readonly baseUrl: string;
120
+ }, keySet: JWTVerifyGetKey): TokenVerifier;
121
+ /**
122
+ * Verifies a token with the verifier of the issuer it claims, by origin. The claim only picks the
123
+ * verifier, which checks the issuer again with the signature; a token from any other issuer is
124
+ * invalid without a key-set fetch.
125
+ */
126
+ export declare function verifyByIssuer(verifiers: ReadonlyMap<string, TokenVerifier>): TokenVerifier;
127
+ /**
128
+ * The service's token verification: SegmentStream app tokens, and the workspace's Neon Auth tokens
129
+ * once it has Neon Auth. Both are accepted while workspaces move to Neon Auth.
130
+ */
131
+ export declare function tokenVerifier(config: TokenVerifierConfig & {
132
+ readonly neonAuth?: NeonAuthEnvironment | undefined;
133
+ }): TokenVerifier;
134
+ /**
135
+ * The session cookie the app's Neon Auth sets on the app's domain. The ontology service shares the
136
+ * domain, so a signed-in browser sends it here too: the docs page relies on it.
137
+ */
138
+ export declare const NEON_AUTH_SESSION_COOKIE = "__Secure-neon-auth.session_token";
139
+ export type SessionExchangeResult = {
140
+ readonly status: "token";
141
+ readonly token: string;
142
+ } | {
143
+ readonly status: "invalid";
144
+ } | {
145
+ readonly status: "unavailable";
146
+ };
147
+ /** Turns a Neon Auth session cookie into the session's token; `origin` is the app's. */
148
+ export type SessionExchange = (session: Redacted.Redacted<string>, origin: string) => Promise<SessionExchangeResult>;
149
+ /**
150
+ * Exchanges a session cookie for its token at Neon Auth's `GET <base URL>/token`, as the app's
151
+ * `@neondatabase/auth` does, and reuses the token until shortly before it expires. The token is then
152
+ * verified like any bearer token, so the exchange never vouches for a session on its own.
153
+ */
154
+ export declare function neonAuthSessionExchange(config: {
155
+ readonly baseUrl: string;
156
+ }, options?: {
157
+ readonly fetch?: typeof fetch;
158
+ readonly now?: () => number;
159
+ }): SessionExchange;
160
+ /**
161
+ * A request the session cookie may authenticate: any read, and a change only when the browser says
162
+ * it comes from the app's own origin. Browsers send `Origin` with every cross-origin request and
163
+ * with same-origin `POST`s, so a change without one is refused too.
164
+ */
165
+ export declare function sessionMayAuthenticate(request: HttpServerRequest.HttpServerRequest): boolean;
166
+ type Authenticated = {
167
+ readonly status: "authenticated";
168
+ readonly principal: Principal;
169
+ readonly caller: VerifiedCaller;
170
+ } | {
171
+ readonly status: "missing";
172
+ } | {
173
+ readonly status: "rejected";
174
+ } | {
175
+ readonly status: "not_invited";
176
+ } | {
177
+ readonly status: "forbidden";
178
+ readonly detail: string;
179
+ } | {
180
+ readonly status: "unavailable";
181
+ };
182
+ /** Where a credential is presented. */
183
+ export interface CredentialOptions {
184
+ /**
185
+ * The exact resource an opaque access token must name: MCP's URL or the first-party app-session
186
+ * resource. Ordinary routes derive the app resource from their browser request context.
187
+ */
188
+ readonly oauthResource?: string;
189
+ /**
190
+ * The deployment's own runtime token may authenticate here, acting as the member it names. Without
191
+ * it a runtime token is just an invalid token.
192
+ */
193
+ readonly runtime?: RuntimeCredential;
194
+ /**
195
+ * This route accepts `X-SegmentStream-Agent-Task`: with the runtime token, a live task's secret
196
+ * authenticates as the task's workflow user in this workspace. Every other route refuses it.
197
+ */
198
+ readonly agentTasks?: {
199
+ readonly workspaceId: string;
200
+ };
201
+ }
202
+ /** Resolves a bearer credential to its current principal and verified credential provenance. */
203
+ export declare function authenticate(credential: Redacted.Redacted<string>, verifyToken: TokenVerifier, options?: CredentialOptions): Effect.Effect<Authenticated, never, OntologyBackend>;
204
+ /** A browser's request, which may authenticate with the app's Neon Auth session cookie. */
205
+ export interface BrowserSession {
206
+ readonly request: HttpServerRequest.HttpServerRequest;
207
+ readonly exchange: SessionExchange | undefined;
208
+ }
209
+ /**
210
+ * Runs `effect` as the principal a bearer credential names, or answers the request as every route
211
+ * does: 401 without a valid credential, 403 for a person nobody invited or a session cookie sent
212
+ * from another origin, 503 while sign-in cannot be verified, and a sanitized 500 when
213
+ * authentication itself fails.
214
+ */
215
+ export declare function withPrincipal<E, R>(credential: Redacted.Redacted<string>, verifyToken: TokenVerifier, backend: OntologyBackend["Service"], effect: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>, options?: CredentialOptions & {
216
+ /** The `WWW-Authenticate` challenge of a 401, by whether the credential was missing. */
217
+ readonly challenge?: (missing: boolean) => string;
218
+ /** Without a bearer token, the app's session cookie may authenticate this browser request. */
219
+ readonly session?: BrowserSession;
220
+ }): Effect.Effect<HttpServerResponse.HttpServerResponse, E, Exclude<R, CurrentPrincipal | CurrentCaller> | RequestId>;
221
+ /**
222
+ * The {@link Authentication} middleware, verifying tokens with `verifyToken`. With `exchangeSession`,
223
+ * a request without a bearer token may authenticate with the app's Neon Auth session cookie; with
224
+ * `verifyRuntime`, the deployment's own runtime token may act as the member it names.
225
+ */
226
+ export declare function authenticationLayer(verifyToken: TokenVerifier, exchangeSession?: SessionExchange, verifyRuntime?: RuntimeTokenVerifier): Layer.Layer<Authentication, never, OntologyBackend>;
227
+ export {};