@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,193 @@
1
+ import type { ActionConfirmation, ConfirmContext } from "./confirmation.js";
2
+ import type { ActionRuntime } from "./runtime-source.js";
3
+ import type { Files, FileTarget } from "./files.js";
4
+ import { Effect, Schema } from "effect";
5
+ import type { AnyConnectionHandle, Connection, ConnectionError, ConnectionsOf } from "./connection.js";
6
+ import type { AnyEntity } from "./entity.js";
7
+ import type { ActionError } from "./errors.js";
8
+ import type { OntologyReads, OntologyRuntime, Principal } from "./runtime.js";
9
+ export declare const ActionTypeId: unique symbol;
10
+ /** What `prepare` runs with. */
11
+ export interface PrepareContext<Input> {
12
+ /** The input, already decoded with the action's input schema. */
13
+ readonly input: Input;
14
+ readonly principal: Principal;
15
+ /** Verified runtime provenance, absent for ordinary member, OAuth and API-key callers. */
16
+ readonly runtime?: ActionRuntime;
17
+ /** The id of the request, for logs. Never derive a provider idempotency key from it. */
18
+ readonly requestId: string;
19
+ }
20
+ /** A live channel account of the member invoking the action. */
21
+ export declare const ActionIdentity: Schema.Struct<{
22
+ readonly provider: Schema.String;
23
+ readonly subject: Schema.String;
24
+ readonly username: Schema.optionalKey<Schema.String>;
25
+ readonly verified: Schema.Literal<true>;
26
+ }>;
27
+ export type ActionIdentity = typeof ActionIdentity.Type;
28
+ export interface ActionContext<Input, Prepared = undefined> extends PrepareContext<Input> {
29
+ /** Current live channel identities, loaded for the handler without changing Principal. */
30
+ readonly principal: Principal & {
31
+ readonly identities: ReadonlyArray<ActionIdentity>;
32
+ readonly createdVia: string;
33
+ readonly authenticatedVia: string;
34
+ };
35
+ /** What `prepare` returned; `undefined` for an action without `prepare`. */
36
+ readonly prepared: Prepared;
37
+ }
38
+ /** What `prepare` may fail with: the action errors, and connection calls that failed. */
39
+ export type PrepareError = ActionError | ConnectionError;
40
+ /**
41
+ * How an action behaves. Agents confirm destructive, irreversible or external actions before
42
+ * preparation. Actions with connections are external even when both safety hints are false,
43
+ * except for enforced read-only prepare actions declared with `readOnly: true`.
44
+ * Permitted, routine reversible actions can run without confirmation.
45
+ * Custom actions without safety labels require confirmation for backwards compatibility.
46
+ * Idempotence does not decide whether confirmation is needed.
47
+ */
48
+ export interface ActionHints {
49
+ /**
50
+ * A prepare-only action that reads without changing records or providers. Requires `prepare`
51
+ * without a handler. Its connection clients enforce GET/HEAD/OPTIONS without method overrides.
52
+ */
53
+ readonly readOnly?: boolean;
54
+ /** Enforce GET/HEAD/OPTIONS for every preparation connection, while allowing local handler writes. */
55
+ readonly connectionsReadOnly?: boolean;
56
+ /** Whether the action destroys records or established decisions. Unlabelled actions default true. */
57
+ readonly destructive?: boolean;
58
+ /** Whether the effect cannot be fully undone, such as sending a notification. Default false. */
59
+ readonly irreversible?: boolean;
60
+ /** Whether running it again with the same input changes nothing more. Default false. */
61
+ readonly idempotent?: boolean;
62
+ }
63
+ /** A described, typed, permissioned Effect function: the only way to change records. */
64
+ export interface Action<Input extends Schema.Top = Schema.Top, Result = unknown> {
65
+ readonly [ActionTypeId]: typeof ActionTypeId;
66
+ readonly description: string;
67
+ readonly input: Input;
68
+ /**
69
+ * The permission a principal needs to run the action, as `action({ permission })` set it. When it
70
+ * is not set, the action requires `<entity>:<action name>`, for example `lead:changeStatus`.
71
+ */
72
+ readonly permission: string | undefined;
73
+ /** How the action behaves, as `action({ hints })` set it; see {@link ActionHints}. */
74
+ readonly hints: ActionHints | undefined;
75
+ /** See `action({ retryOnDeadlock })`. Absent or false means the handler runs at most once. */
76
+ readonly retryOnDeadlock?: boolean;
77
+ /** See `action({ writes })`. Absent means the handler may write any entity. */
78
+ readonly writes?: ReadonlyArray<ActionWriteTarget>;
79
+ /** The connections `prepare` may call; empty for an action without `prepare`. */
80
+ readonly connections: ReadonlyArray<AnyConnectionHandle>;
81
+ /** File targets preparation may stage, declared with uploads.target. Absent on older actions. */
82
+ readonly files?: ReadonlyArray<FileTarget>;
83
+ /** Describes what a person confirms before an agent runs the action; see `action({ confirm })`. */
84
+ confirm?(context: ConfirmContext<Input["Type"]>): Effect.Effect<ActionConfirmation, ActionError, OntologyReads>;
85
+ /**
86
+ * Runs before the transaction, with reads, declared connections and file access; see
87
+ * {@link ActionConfigWithConnections}.
88
+ */
89
+ prepare?(context: PrepareContext<Input["Type"]>): Effect.Effect<unknown, PrepareError, OntologyReads | Connection<string> | Files>;
90
+ /**
91
+ * Runs in the transaction. An action declared with `prepare` and no handler gets one that returns
92
+ * what `prepare` returned, and `transactional: false`.
93
+ */
94
+ handler(context: ActionContext<Input["Type"], unknown>): Effect.Effect<Result, ActionError, OntologyRuntime>;
95
+ /** Whether the runtime opens a transaction for the handler; false for a `prepare`-only action. */
96
+ readonly transactional: boolean;
97
+ }
98
+ /** Any action, whatever its input and result. */
99
+ export type AnyAction = Action<any, any>;
100
+ /** An entity's authored actions by name, as `.actions(…)` returns them. */
101
+ export type Actions = {
102
+ readonly [name: string]: AnyAction;
103
+ };
104
+ /** The input of an action as its handler receives it: the decoded form of its input schema. */
105
+ export type ActionInput<A> = A extends Action<infer Input extends Schema.Top, unknown> ? Input["Type"] : never;
106
+ /** The input of an action as a caller sends it: the encoded form of its input schema. */
107
+ export type ActionEncodedInput<A> = A extends Action<infer Input extends Schema.Top, unknown> ? Input["Encoded"] : never;
108
+ /** What an action's handler succeeds with: the `result` of an action response. */
109
+ export type ActionResult<A> = A extends Action<Schema.Top, infer Result> ? Result : never;
110
+ interface ActionOptions<Input extends Schema.Top> {
111
+ readonly description: string;
112
+ /** Usually a `Schema.Struct` of property schemas, entity references and other schemas. */
113
+ readonly input: Input;
114
+ /**
115
+ * The permission a principal needs to run the action. It defaults to `<entity>:<action name>`;
116
+ * set it only to share one permission between actions, for example two actions behind `lead:edit`.
117
+ * Roles grant it in their `permissions`.
118
+ */
119
+ readonly permission?: string;
120
+ /**
121
+ * How the action behaves, for the agents that run it over MCP. Set `destructive: false` for an
122
+ * routine reversible action, `irreversible: true` for an effect without a complete undo, and
123
+ * `idempotent: true` for one
124
+ * that a repeated call leaves as it was.
125
+ */
126
+ readonly hints?: ActionHints;
127
+ /**
128
+ * Opt in to at most two retries after a PostgreSQL deadlock and completed rollback. The handler,
129
+ * including its wrappers, must have only transactional database effects, keep input and prepared
130
+ * values immutable, and recreate all attempt-local state on each call. Trigger functions must
131
+ * also be pure. Preparation runs once; its result is reused. After-commit effects run once.
132
+ * This is independent of `hints.idempotent`. Defaults to false.
133
+ */
134
+ readonly retryOnDeadlock?: boolean;
135
+ /**
136
+ * The entities the handler writes, such as `[self, Note]`; a thunk (`() => Note`) names an entity
137
+ * a circular import has not defined yet. The runtime refuses any other write of the handler, the
138
+ * manifest lists them, and agents read them in the action's description, so "what changes what"
139
+ * is declared. `[]` declares an action that writes nothing. Absent, the handler may write any
140
+ * entity, as before.
141
+ */
142
+ readonly writes?: ReadonlyArray<ActionWriteTarget>;
143
+ /**
144
+ * What a person confirms before an agent runs the action for them: the card the agent shows,
145
+ * with its title, the facts to check and secondary detail, in `locale`, the chat's language.
146
+ * It runs after the permission check, with reads only, and writes nothing. Fail with
147
+ * `ActionRejected` when the action would refuse this input: the agent then tells the person why
148
+ * instead of asking. Without it, agents show the action's fields.
149
+ */
150
+ readonly confirm?: (context: ConfirmContext<Input["Type"]>) => Effect.Effect<ActionConfirmation, ActionError, OntologyReads>;
151
+ }
152
+ /** An entity an action writes: its handle, or a thunk for a circular import. */
153
+ export type ActionWriteTarget = AnyEntity | (() => AnyEntity);
154
+ export interface ActionConfig<Input extends Schema.Top, Result> extends ActionOptions<Input> {
155
+ /**
156
+ * Runs inside the action's transaction. It reads and writes through entity handles (`Lead.get`,
157
+ * `Lead.update`, …), which require {@link OntologyRuntime}, and fails only with the action errors.
158
+ */
159
+ readonly handler: (context: ActionContext<Input["Type"]>) => Effect.Effect<Result, ActionError, OntologyRuntime>;
160
+ /** Set only with `prepare`; see {@link ActionConfigWithConnections}. */
161
+ readonly connections?: undefined;
162
+ readonly prepare?: undefined;
163
+ readonly files?: undefined;
164
+ }
165
+ /**
166
+ * An action that calls connections. `prepare` runs after the permission check and before the
167
+ * transaction, with reads and the declared connections but no writes, so a provider's latency never
168
+ * holds a database connection or a lock. `handler` then runs in the transaction with what `prepare`
169
+ * returned, and cannot call connections.
170
+ *
171
+ * `prepare` sees committed data without locks: a handler whose write depends on what `prepare` read
172
+ * re-reads it with `forUpdate` and checks it again. A provider write in `prepare` happens even when
173
+ * the transaction later fails, so derive its idempotency key from the record, never from the request.
174
+ */
175
+ export interface ActionConfigWithConnections<Input extends Schema.Top, C extends ReadonlyArray<AnyConnectionHandle>, Prepared, Result> extends ActionOptions<Input> {
176
+ /** The connection handles `prepare` calls; each is listed in `defineOntology({ connections })`. */
177
+ readonly connections: C;
178
+ readonly files?: ReadonlyArray<FileTarget>;
179
+ readonly prepare: (context: PrepareContext<Input["Type"]>) => Effect.Effect<Prepared, PrepareError, OntologyReads | ConnectionsOf<C> | Files>;
180
+ /**
181
+ * Runs in the transaction with `prepared`, as an action without connections does. Omit it when
182
+ * the action writes nothing: its result is then what `prepare` returned, and no transaction opens.
183
+ */
184
+ readonly handler?: (context: ActionContext<Input["Type"], Prepared>) => Effect.Effect<Result, ActionError, OntologyRuntime>;
185
+ }
186
+ export declare function action<Input extends Schema.Top, Result>(config: ActionConfig<Input, Result>): Action<Input, Result>;
187
+ export declare function action<Input extends Schema.Top, const C extends ReadonlyArray<AnyConnectionHandle>, Prepared>(config: ActionConfigWithConnections<Input, C, Prepared, never> & {
188
+ readonly handler?: undefined;
189
+ }): Action<Input, Prepared>;
190
+ export declare function action<Input extends Schema.Top, const C extends ReadonlyArray<AnyConnectionHandle>, Prepared, Result>(config: ActionConfigWithConnections<Input, C, Prepared, Result>): Action<Input, Result>;
191
+ /** Whether a value was declared with `action(…)`; an entity handle's callable actions are too. */
192
+ export declare function isAction(value: unknown): value is Action;
193
+ export {};
package/dist/action.js ADDED
@@ -0,0 +1,41 @@
1
+ import { Effect, Schema } from "effect";
2
+ export const ActionTypeId = Symbol.for("@segmentstream/ontology/Action");
3
+ /** A live channel account of the member invoking the action. */
4
+ export const ActionIdentity = Schema.Struct({
5
+ provider: Schema.String,
6
+ subject: Schema.String,
7
+ username: Schema.optionalKey(Schema.String),
8
+ verified: Schema.Literal(true),
9
+ });
10
+ // @legacy ontology.removed-allow-option
11
+ /** Options removed from earlier releases, kept on the action so that `check` can explain them. */
12
+ function removedOptions(config) {
13
+ return "allow" in config ? { allow: config.allow } : {};
14
+ }
15
+ export function action(config) {
16
+ return {
17
+ ...removedOptions(config),
18
+ [ActionTypeId]: ActionTypeId,
19
+ description: config.description,
20
+ input: config.input,
21
+ permission: config.permission,
22
+ hints: config.hints,
23
+ ...(config.retryOnDeadlock === undefined ? {} : { retryOnDeadlock: config.retryOnDeadlock }),
24
+ ...(config.writes === undefined ? {} : { writes: config.writes }),
25
+ ...(config.confirm === undefined ? {} : { confirm: config.confirm }),
26
+ connections: config.connections ?? [],
27
+ ...(config.files === undefined ? {} : { files: config.files }),
28
+ ...(config.prepare === undefined ? {} : { prepare: config.prepare }),
29
+ // A prepare-only action answers with what prepare returned; it writes nothing.
30
+ handler: config.handler === undefined && config.prepare !== undefined
31
+ ? ({ prepared }) => Effect.succeed(prepared)
32
+ : config.handler,
33
+ transactional: config.handler !== undefined || config.prepare === undefined,
34
+ };
35
+ }
36
+ /** Whether a value was declared with `action(…)`; an entity handle's callable actions are too. */
37
+ export function isAction(value) {
38
+ return ((typeof value === "object" || typeof value === "function") &&
39
+ value !== null &&
40
+ ActionTypeId in value);
41
+ }
@@ -0,0 +1,44 @@
1
+ export declare const TELEGRAM = "telegram";
2
+ /** Existing chat registry and membership storage; delivery lives in the ontology service. */
3
+ export declare const AgentChat: import("./entity.js").Entity<"agent_chat", {
4
+ readonly provider: import("./property.js").Property<string, false, false>;
5
+ readonly externalId: import("./property.js").Property<string, false, false>;
6
+ readonly title: import("./property.js").Property<string, false, false>;
7
+ readonly lastMessageAt: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
8
+ readonly purpose: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
9
+ readonly whenToUse: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
10
+ }, {
11
+ readonly members: import("./relationship.js").ManyRelationship;
12
+ }, import("./entity.js").InvocableActions<{
13
+ readonly previewMessage: import("./action.js").Action<import("effect/Schema").Struct<{
14
+ readonly chat: import("effect/Schema").String;
15
+ readonly text: import("effect/Schema").String;
16
+ readonly replyTo: import("effect/Schema").optionalKey<import("effect/Schema").String>;
17
+ readonly idempotencyKey: import("effect/Schema").String;
18
+ }>, import("./chat.js").ChatPreview>;
19
+ readonly postMessage: import("./action.js").Action<import("effect/Schema").Struct<{
20
+ readonly chat: import("effect/Schema").String;
21
+ readonly text: import("effect/Schema").String;
22
+ readonly replyTo: import("effect/Schema").optionalKey<import("effect/Schema").String>;
23
+ readonly idempotencyKey: import("effect/Schema").String;
24
+ }>, {
25
+ readonly status: "sent" | "uncertain";
26
+ readonly message_id: string | null;
27
+ readonly url: string | null;
28
+ readonly duplicate: boolean;
29
+ readonly history_recorded: boolean;
30
+ }>;
31
+ }, "agent_chat", {
32
+ readonly id: string;
33
+ readonly createdAt: string;
34
+ readonly updatedAt: string;
35
+ readonly createdBy: string | null;
36
+ readonly updatedBy: string | null;
37
+ readonly provider: string;
38
+ readonly externalId: string;
39
+ readonly title: string;
40
+ readonly lastMessageAt: string | null;
41
+ readonly purpose: string | null;
42
+ readonly whenToUse: string | null;
43
+ }>, Readonly<Record<never, never>>, "generated">;
44
+ export type AgentChat = typeof AgentChat.Type;
@@ -0,0 +1,91 @@
1
+ import { Effect, Option } from "effect";
2
+ import { action } from "./action.js";
3
+ import { entity } from "./entity.js";
4
+ import { ActionRejected } from "./errors.js";
5
+ import { ChatDelivery, ChatPostInput } from "./chat.js";
6
+ import { p } from "./property.js";
7
+ import { rel } from "./relationship.js";
8
+ export const TELEGRAM = "telegram";
9
+ /** Existing chat registry and membership storage; delivery lives in the ontology service. */
10
+ export const AgentChat = entity("agent_chat", {
11
+ id: "ent_agent_chat",
12
+ label: "Agent chat",
13
+ plural: "Agent chats",
14
+ title: "title",
15
+ description: "A group chat the workspace's agent is in. The agent records each chat it sees; " +
16
+ "members say what the chat is for, so that agents know where to write.",
17
+ properties: {
18
+ provider: p.text({ managed: true, description: "The channel, for example telegram." }),
19
+ externalId: p.text({ managed: true, description: "The chat's id at the provider." }),
20
+ title: p.text({
21
+ managed: true,
22
+ description: "The chat's name at the provider, kept current by the agent.",
23
+ }),
24
+ lastMessageAt: p.timestamp({
25
+ optional: true,
26
+ managed: true,
27
+ label: "Last message",
28
+ description: "When the agent last saw a message in the chat, recorded at most every 15 minutes.",
29
+ }),
30
+ purpose: p.text({
31
+ optional: true,
32
+ maxLength: 64,
33
+ description: "A short key that code and agents look the chat up by, such as accounting.",
34
+ }),
35
+ whenToUse: p.text({
36
+ optional: true,
37
+ maxLength: 1000,
38
+ display: "multiline",
39
+ label: "When to use",
40
+ description: "For agents: what the chat is for and when to write there, such as " +
41
+ '"Invoices and payments; Yulia answers on weekdays."',
42
+ }),
43
+ },
44
+ relationships: {
45
+ // By name, so that an ontology rebuilt with the deployed `user` still resolves it.
46
+ members: rel.many("user", {
47
+ inverse: "agentChats",
48
+ phrase: ["includes", "is in"],
49
+ description: "Workspace members the agent has seen writing in the chat.",
50
+ }),
51
+ },
52
+ indexes: [{ properties: ["provider", "externalId"], unique: true }],
53
+ }).actions(() => ({
54
+ previewMessage: action({
55
+ description: "Render an exact chat message with its verified destination and sender attribution, without reserving a key, " +
56
+ "writing history or sending. Requires the same explicit post permission as delivery. " +
57
+ "A preview is not authorization to send.",
58
+ permission: "agent_chat:post_message",
59
+ input: ChatPostInput,
60
+ connections: [],
61
+ hints: { readOnly: true, destructive: false, irreversible: false, idempotent: true },
62
+ prepare: ({ input }) => Effect.gen(function* () {
63
+ const delivery = yield* Effect.serviceOption(ChatDelivery);
64
+ if (Option.isNone(delivery)) {
65
+ return yield* new ActionRejected({
66
+ message: "Chat preview requires the authenticated ontology service.",
67
+ });
68
+ }
69
+ return yield* delivery.value.preview(input);
70
+ }),
71
+ }),
72
+ postMessage: action({
73
+ description: "Post to an eligible chat ID or exact title. text is Markdown (bold, italic, code, lists, " +
74
+ "[text](url)); each channel renders it natively and degrades constructs it can't show. " +
75
+ "The exact Markdown source is posted; the platform adds the sender attribution. " +
76
+ "Ambiguous titles require an explicit ID. Confirm the full final text, attribution and destination " +
77
+ "before calling. Reuse the same idempotency key on replay; an uncertain operation is never resent.",
78
+ input: ChatPostInput,
79
+ hints: { destructive: false, irreversible: true, idempotent: true },
80
+ connections: [],
81
+ prepare: ({ input }) => Effect.gen(function* () {
82
+ const delivery = yield* Effect.serviceOption(ChatDelivery);
83
+ if (Option.isNone(delivery)) {
84
+ return yield* new ActionRejected({
85
+ message: "Chat delivery requires the authenticated ontology service.",
86
+ });
87
+ }
88
+ return yield* delivery.value.post(input);
89
+ }),
90
+ }),
91
+ }));
@@ -0,0 +1,64 @@
1
+ /**
2
+ * What `agentTask` and the ontology service share: its limits and the values its steps exchange.
3
+ * This module holds no workflow or step function, so the package's root entry, which the platform's
4
+ * backend bundles with another Workflow SDK major, may import it without bundling a step.
5
+ */
6
+ /** The most tasks a workspace has live at once; one more is refused as `busy`. */
7
+ export declare const MAX_LIVE_AGENT_TASKS = 10;
8
+ /** The longest prompt, in characters. */
9
+ export declare const MAX_AGENT_TASK_PROMPT_LENGTH = 32768;
10
+ /** The longest text the agent reports; it cuts longer text and sets `truncated`. */
11
+ export declare const MAX_AGENT_TASK_TEXT_LENGTH = 65536;
12
+ /** How long a task may run, by default and at most: 15 minutes, 1 minute and 1 hour. */
13
+ export declare const DEFAULT_AGENT_TASK_TIMEOUT_MS = 900000;
14
+ export declare const MIN_AGENT_TASK_TIMEOUT_MS = 60000;
15
+ export declare const MAX_AGENT_TASK_TIMEOUT_MS = 3600000;
16
+ export interface AgentTaskOptions {
17
+ /** 1 to 32,768 characters, all of it the workspace's. */
18
+ readonly prompt: string;
19
+ /** Default 900,000 (15 minutes); at least 60,000 and at most 3,600,000. */
20
+ readonly timeoutMs?: number;
21
+ }
22
+ export type AgentTaskFailure =
23
+ /** The deployment has no agent, its agent predates tasks, or the call ran outside production. */
24
+ "agent_unavailable"
25
+ /** The workspace already has 10 live tasks; the agent was not called. */
26
+ | "busy"
27
+ /** The agent accepted the task and its turn failed, including its per-session cost cap. */
28
+ | "agent_failed";
29
+ export type AgentTaskResult = {
30
+ readonly status: "completed";
31
+ readonly text: string;
32
+ readonly truncated: boolean;
33
+ }
34
+ /** The agent asked a person something; `text` is its question. */
35
+ | {
36
+ readonly status: "needs_input";
37
+ readonly text: string;
38
+ readonly truncated: boolean;
39
+ } | {
40
+ readonly status: "failed";
41
+ readonly reason: AgentTaskFailure;
42
+ } | {
43
+ readonly status: "timed_out";
44
+ };
45
+ /** What the start step hands the service: the hook to resume, the prompt and the timeout. */
46
+ export interface AgentTaskStart {
47
+ readonly hookToken: string;
48
+ readonly prompt: string;
49
+ readonly timeoutMs: number;
50
+ }
51
+ /**
52
+ * What the start step answers: the task the workflow now waits for, or the outcome it already has
53
+ * (the agent was not called, refused, or the task ended before a retried step found it).
54
+ */
55
+ export type AgentTaskStarted =
56
+ /** `remainingMs` runs to the task's deadline, which its row fixed when the start created it. */
57
+ {
58
+ readonly status: "waiting";
59
+ readonly taskId: string;
60
+ readonly remainingMs: number;
61
+ } | {
62
+ readonly status: "decided";
63
+ readonly result: AgentTaskResult;
64
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * What `agentTask` and the ontology service share: its limits and the values its steps exchange.
3
+ * This module holds no workflow or step function, so the package's root entry, which the platform's
4
+ * backend bundles with another Workflow SDK major, may import it without bundling a step.
5
+ */
6
+ /** The most tasks a workspace has live at once; one more is refused as `busy`. */
7
+ export const MAX_LIVE_AGENT_TASKS = 10;
8
+ /** The longest prompt, in characters. */
9
+ export const MAX_AGENT_TASK_PROMPT_LENGTH = 32_768;
10
+ /** The longest text the agent reports; it cuts longer text and sets `truncated`. */
11
+ export const MAX_AGENT_TASK_TEXT_LENGTH = 65_536;
12
+ /** How long a task may run, by default and at most: 15 minutes, 1 minute and 1 hour. */
13
+ export const DEFAULT_AGENT_TASK_TIMEOUT_MS = 900_000;
14
+ export const MIN_AGENT_TASK_TIMEOUT_MS = 60_000;
15
+ export const MAX_AGENT_TASK_TIMEOUT_MS = 3_600_000;
@@ -0,0 +1,39 @@
1
+ import { type AgentTaskOptions, type AgentTaskResult } from "./agent-task-contract.js";
2
+ export { DEFAULT_AGENT_TASK_TIMEOUT_MS, MAX_AGENT_TASK_PROMPT_LENGTH, MAX_AGENT_TASK_TEXT_LENGTH, MAX_AGENT_TASK_TIMEOUT_MS, MAX_LIVE_AGENT_TASKS, MIN_AGENT_TASK_TIMEOUT_MS, } from "./agent-task-contract.js";
3
+ export type { AgentTaskFailure, AgentTaskOptions, AgentTaskResult, AgentTaskStart, AgentTaskStarted, } from "./agent-task-contract.js";
4
+ /**
5
+ * `agentTask`: a workflow hands the workspace's agent a prompt and waits, durably, for its answer.
6
+ * The agent acts as the workflow's own user. This module is part of the `workflows` entry, which the
7
+ * Workflow SDK bundles for a runtime without Node built-ins: it imports none, and none of the SDK.
8
+ * Its two steps only call the ontology service through the process's workflow binding, so the
9
+ * Workflow SDK compiles them into the workspace's bundle without the service's code. Only the
10
+ * `workflows` entry may import this module: the service imports `agent-task-contract.ts`.
11
+ */
12
+ /** `agentTask`'s options are invalid. Marked fatal, so that the Workflow SDK does not retry it. */
13
+ export declare class AgentTaskOptionsInvalid extends Error {
14
+ readonly fatal = true;
15
+ constructor(option: string, problem: string);
16
+ }
17
+ /** `agentTask` was called outside a `"use workflow"` body. Marked fatal, as above. */
18
+ export declare class AgentTaskWorkflowRequired extends Error {
19
+ readonly fatal = true;
20
+ constructor();
21
+ }
22
+ /** The options with the default timeout filled in; throws {@link AgentTaskOptionsInvalid}. */
23
+ export declare function agentTaskOptions(options: AgentTaskOptions): Required<AgentTaskOptions>;
24
+ /**
25
+ * Hands the workspace's agent a prompt, in a `"use workflow"` body, and waits for its final answer
26
+ * without holding compute. The agent runs as in chats, with the same instructions, models, tools and
27
+ * sandbox, acting as this workflow's user: it sees and does exactly what the workflow's role allows,
28
+ * and ontology actions run without confirmation. It resolves with:
29
+ *
30
+ * - `completed` and the agent's final text;
31
+ * - `needs_input` and its question, when it would need a person;
32
+ * - `failed` with `agent_unavailable` (no agent, an agent without tasks, or outside production),
33
+ * `busy` (10 tasks are live) or `agent_failed` (its turn failed);
34
+ * - `timed_out` when `timeoutMs`, counted from the call, passes first.
35
+ *
36
+ * Invalid options, and a call outside a workflow body, fail the workflow. A retried start may hand
37
+ * the agent the same prompt again, so prompts and later steps tolerate a repeat.
38
+ */
39
+ export declare function agentTask(options: AgentTaskOptions): Promise<AgentTaskResult>;
@@ -0,0 +1,112 @@
1
+ import { DEFAULT_AGENT_TASK_TIMEOUT_MS, MAX_AGENT_TASK_PROMPT_LENGTH, MAX_AGENT_TASK_TIMEOUT_MS, MIN_AGENT_TASK_TIMEOUT_MS, } from "./agent-task-contract.js";
2
+ import { boundStep } from "./workflow-runtime.js";
3
+ export { DEFAULT_AGENT_TASK_TIMEOUT_MS, MAX_AGENT_TASK_PROMPT_LENGTH, MAX_AGENT_TASK_TEXT_LENGTH, MAX_AGENT_TASK_TIMEOUT_MS, MAX_LIVE_AGENT_TASKS, MIN_AGENT_TASK_TIMEOUT_MS, } from "./agent-task-contract.js";
4
+ /**
5
+ * `agentTask`: a workflow hands the workspace's agent a prompt and waits, durably, for its answer.
6
+ * The agent acts as the workflow's own user. This module is part of the `workflows` entry, which the
7
+ * Workflow SDK bundles for a runtime without Node built-ins: it imports none, and none of the SDK.
8
+ * Its two steps only call the ontology service through the process's workflow binding, so the
9
+ * Workflow SDK compiles them into the workspace's bundle without the service's code. Only the
10
+ * `workflows` entry may import this module: the service imports `agent-task-contract.ts`.
11
+ */
12
+ /** `agentTask`'s options are invalid. Marked fatal, so that the Workflow SDK does not retry it. */
13
+ export class AgentTaskOptionsInvalid extends Error {
14
+ fatal = true;
15
+ constructor(option, problem) {
16
+ super(`agentTask: ${option} ${problem}`);
17
+ this.name = "AgentTaskOptionsInvalid";
18
+ }
19
+ }
20
+ /** `agentTask` was called outside a `"use workflow"` body. Marked fatal, as above. */
21
+ export class AgentTaskWorkflowRequired extends Error {
22
+ fatal = true;
23
+ constructor() {
24
+ super('agentTask runs only in the "use workflow" body of a declared workflow: not inside a ' +
25
+ '"use step" function, and not outside a workflow.');
26
+ this.name = "AgentTaskWorkflowRequired";
27
+ }
28
+ }
29
+ /** The options with the default timeout filled in; throws {@link AgentTaskOptionsInvalid}. */
30
+ export function agentTaskOptions(options) {
31
+ if (options === null || typeof options !== "object") {
32
+ throw new AgentTaskOptionsInvalid("options", "must be an object with a prompt.");
33
+ }
34
+ const { prompt, timeoutMs = DEFAULT_AGENT_TASK_TIMEOUT_MS } = options;
35
+ if (typeof prompt !== "string") {
36
+ throw new AgentTaskOptionsInvalid("prompt", "must be a string.");
37
+ }
38
+ if (prompt.length < 1 || prompt.length > MAX_AGENT_TASK_PROMPT_LENGTH) {
39
+ throw new AgentTaskOptionsInvalid("prompt", `must be 1 to ${MAX_AGENT_TASK_PROMPT_LENGTH} characters; it has ${prompt.length}.`);
40
+ }
41
+ if (typeof timeoutMs !== "number" ||
42
+ !Number.isInteger(timeoutMs) ||
43
+ timeoutMs < MIN_AGENT_TASK_TIMEOUT_MS ||
44
+ timeoutMs > MAX_AGENT_TASK_TIMEOUT_MS) {
45
+ throw new AgentTaskOptionsInvalid("timeoutMs", `must be a whole number of milliseconds from ${MIN_AGENT_TASK_TIMEOUT_MS} to ` +
46
+ `${MAX_AGENT_TASK_TIMEOUT_MS}; it is ${String(timeoutMs)}.`);
47
+ }
48
+ return { prompt, timeoutMs };
49
+ }
50
+ /**
51
+ * The Workflow SDK's `createHook` and `sleep` inside a `"use workflow"` body. The SDK's own
52
+ * exports read the same functions from these `globalThis` symbols, which its workflow sandbox sets
53
+ * and nothing else does; reading them here keeps the SDK out of this entry, which customer workflow
54
+ * files import at their top level. `undefined` in a step and outside a workflow.
55
+ */
56
+ function workflowPrimitives() {
57
+ const globals = globalThis;
58
+ const createHook = globals[Symbol.for("WORKFLOW_CREATE_HOOK")];
59
+ const sleep = globals[Symbol.for("WORKFLOW_SLEEP")];
60
+ return typeof createHook === "function" && typeof sleep === "function"
61
+ ? { createHook: createHook, sleep: sleep }
62
+ : undefined;
63
+ }
64
+ /**
65
+ * Refuses when 10 tasks are live, records the task under the hook's token, and hands it to the
66
+ * agent. The task's secret never leaves the service: the step returns the task id only.
67
+ */
68
+ async function startAgentTask(input) {
69
+ "use step";
70
+ const { binding, step } = boundStep();
71
+ return binding.startAgentTask(step, input);
72
+ }
73
+ /** The sleep won: the task times out unless it already ended, and its terminal outcome is returned. */
74
+ async function expireAgentTask(taskId) {
75
+ "use step";
76
+ const { binding, step } = boundStep();
77
+ return binding.expireAgentTask(step, taskId);
78
+ }
79
+ /**
80
+ * Hands the workspace's agent a prompt, in a `"use workflow"` body, and waits for its final answer
81
+ * without holding compute. The agent runs as in chats, with the same instructions, models, tools and
82
+ * sandbox, acting as this workflow's user: it sees and does exactly what the workflow's role allows,
83
+ * and ontology actions run without confirmation. It resolves with:
84
+ *
85
+ * - `completed` and the agent's final text;
86
+ * - `needs_input` and its question, when it would need a person;
87
+ * - `failed` with `agent_unavailable` (no agent, an agent without tasks, or outside production),
88
+ * `busy` (10 tasks are live) or `agent_failed` (its turn failed);
89
+ * - `timed_out` when `timeoutMs`, counted from the call, passes first.
90
+ *
91
+ * Invalid options, and a call outside a workflow body, fail the workflow. A retried start may hand
92
+ * the agent the same prompt again, so prompts and later steps tolerate a repeat.
93
+ */
94
+ export async function agentTask(options) {
95
+ const { prompt, timeoutMs } = agentTaskOptions(options);
96
+ const primitives = workflowPrimitives();
97
+ if (primitives === undefined) {
98
+ throw new AgentTaskWorkflowRequired();
99
+ }
100
+ const hook = primitives.createHook();
101
+ const started = await startAgentTask({ hookToken: hook.token, prompt, timeoutMs });
102
+ if (started.status === "decided") {
103
+ return started.result;
104
+ }
105
+ // Sleep until the row's deadline, not `timeoutMs` from now: a report the ontology accepted
106
+ // before the deadline then always wins, and start-step retries count against the timeout.
107
+ const reported = await Promise.race([
108
+ hook,
109
+ primitives.sleep(Math.max(started.remainingMs, 1)).then(() => undefined),
110
+ ]);
111
+ return reported ?? (await expireAgentTask(started.taskId));
112
+ }