@opengeni/contracts 3.1.0-canary.2 → 3.1.2

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 (429) hide show
  1. package/dist/agent-authored-durable-text.d.ts +9 -9
  2. package/dist/agent-config.d.ts +971 -0
  3. package/dist/agent-instruction-changes.d.ts +0 -2
  4. package/dist/allowance-refusal.d.ts +9 -0
  5. package/dist/allowance-refusal.js +50 -0
  6. package/dist/allowance-refusal.js.map +1 -0
  7. package/dist/analytics-consent-report.d.ts +19 -0
  8. package/dist/analytics-consent-report.js +10 -0
  9. package/dist/analytics-consent-report.js.map +1 -0
  10. package/dist/api-key-presets.d.ts +19 -0
  11. package/dist/artifact-catalog.d.ts +188 -0
  12. package/dist/artifacts.d.ts +86 -0
  13. package/dist/atlassian-native-retirement.d.ts +16 -0
  14. package/dist/atlassian-native-retirement.js +30 -0
  15. package/dist/atlassian-native-retirement.js.map +1 -0
  16. package/dist/atlassian.d.ts +1 -0
  17. package/dist/atlassian.js +34 -19
  18. package/dist/browser-storage.d.ts +5 -0
  19. package/dist/browser-storage.js +9 -0
  20. package/dist/browser-storage.js.map +1 -0
  21. package/dist/bundled-skills.d.ts +24 -1
  22. package/dist/canonical-human-identities.js +2 -1
  23. package/dist/chunk-2ZIHHL72.js +153 -0
  24. package/dist/chunk-2ZIHHL72.js.map +1 -0
  25. package/dist/{chunk-5LYFSZ7O.js → chunk-352X6ENP.js} +31 -31
  26. package/dist/chunk-4JGHSSB7.js +11 -0
  27. package/dist/chunk-4JGHSSB7.js.map +1 -0
  28. package/dist/chunk-4QO6GJUX.js +85 -0
  29. package/dist/chunk-4QO6GJUX.js.map +1 -0
  30. package/dist/chunk-4VDMHLLL.js +49 -0
  31. package/dist/chunk-4VDMHLLL.js.map +1 -0
  32. package/dist/chunk-56SNIMDO.js +9 -0
  33. package/dist/chunk-56SNIMDO.js.map +1 -0
  34. package/dist/chunk-6C2HKFTU.js +207 -0
  35. package/dist/chunk-6C2HKFTU.js.map +1 -0
  36. package/dist/chunk-6IXO76Z6.js +72 -0
  37. package/dist/chunk-6IXO76Z6.js.map +1 -0
  38. package/dist/chunk-7272KVWZ.js +60 -0
  39. package/dist/chunk-7272KVWZ.js.map +1 -0
  40. package/dist/{chunk-7ABONTXE.js → chunk-E3GGUBHS.js} +49 -5
  41. package/dist/chunk-E3GGUBHS.js.map +1 -0
  42. package/dist/chunk-EFZYKUE2.js +767 -0
  43. package/dist/chunk-EFZYKUE2.js.map +1 -0
  44. package/dist/chunk-EKWNTOG3.js +154 -0
  45. package/dist/chunk-EKWNTOG3.js.map +1 -0
  46. package/dist/chunk-HABQ7ADB.js +234 -0
  47. package/dist/chunk-HABQ7ADB.js.map +1 -0
  48. package/dist/chunk-HRRU4QPI.js +91 -0
  49. package/dist/chunk-HRRU4QPI.js.map +1 -0
  50. package/dist/{chunk-3SIZGL3O.js → chunk-IK36LXKC.js} +18 -2
  51. package/dist/chunk-IK36LXKC.js.map +1 -0
  52. package/dist/{chunk-TXTQIYCV.js → chunk-ILJ72KPO.js} +56 -3
  53. package/dist/chunk-ILJ72KPO.js.map +1 -0
  54. package/dist/chunk-J4HQ3UKY.js +93 -0
  55. package/dist/chunk-J4HQ3UKY.js.map +1 -0
  56. package/dist/chunk-KHHZTBP7.js +11 -0
  57. package/dist/chunk-KHHZTBP7.js.map +1 -0
  58. package/dist/{chunk-WYBDERIY.js → chunk-LZ2LAHIX.js} +47 -41
  59. package/dist/chunk-LZ2LAHIX.js.map +1 -0
  60. package/dist/chunk-NDZHPTCL.js +400 -0
  61. package/dist/chunk-NDZHPTCL.js.map +1 -0
  62. package/dist/chunk-OF6OKOBF.js +54793 -0
  63. package/dist/chunk-OF6OKOBF.js.map +1 -0
  64. package/dist/chunk-OL23ARTF.js +94 -0
  65. package/dist/chunk-OL23ARTF.js.map +1 -0
  66. package/dist/chunk-PUIUXIOL.js +189 -0
  67. package/dist/chunk-PUIUXIOL.js.map +1 -0
  68. package/dist/{chunk-Y3KNXVTD.js → chunk-RMWXDZEO.js} +128 -21
  69. package/dist/chunk-RMWXDZEO.js.map +1 -0
  70. package/dist/{chunk-MRWYRAS5.js → chunk-SHO4YO4B.js} +27 -35
  71. package/dist/chunk-SHO4YO4B.js.map +1 -0
  72. package/dist/chunk-SWRN2DJ3.js +153 -0
  73. package/dist/chunk-SWRN2DJ3.js.map +1 -0
  74. package/dist/chunk-TCXCRBPF.js +267 -0
  75. package/dist/chunk-TCXCRBPF.js.map +1 -0
  76. package/dist/chunk-TLU3UEMD.js +324 -0
  77. package/dist/chunk-TLU3UEMD.js.map +1 -0
  78. package/dist/chunk-TSWWZMUS.js +186 -0
  79. package/dist/chunk-TSWWZMUS.js.map +1 -0
  80. package/dist/{chunk-PX3VCKAU.js → chunk-WVCFSOUZ.js} +1 -1
  81. package/dist/{chunk-PX3VCKAU.js.map → chunk-WVCFSOUZ.js.map} +1 -1
  82. package/dist/chunk-XDLAGX66.js +127 -0
  83. package/dist/chunk-XDLAGX66.js.map +1 -0
  84. package/dist/chunk-YKZ4WU4P.js +33 -0
  85. package/dist/chunk-YKZ4WU4P.js.map +1 -0
  86. package/dist/{chunk-O5LEQHDM.js → chunk-Z7WEVGCL.js} +3 -3
  87. package/dist/{chunk-YBW5JSA3.js → chunk-ZDCRWCGZ.js} +119 -101
  88. package/dist/chunk-ZDCRWCGZ.js.map +1 -0
  89. package/dist/claude-provider-account-authority.d.ts +18 -0
  90. package/dist/claude-subscription-oauth.d.ts +42 -0
  91. package/dist/claude-subscription-usage.d.ts +159 -0
  92. package/dist/client-error-report.d.ts +158 -0
  93. package/dist/client-error-report.js +164 -0
  94. package/dist/client-error-report.js.map +1 -0
  95. package/dist/code-search.d.ts +52 -0
  96. package/dist/code-search.js +40 -0
  97. package/dist/code-search.js.map +1 -0
  98. package/dist/codex-provider-account-authority.js +20 -12
  99. package/dist/codex-provider-account-authority.js.map +1 -1
  100. package/dist/company-profile.d.ts +144 -6
  101. package/dist/connect.d.ts +37 -0
  102. package/dist/connect.js +216 -159
  103. package/dist/connect.js.map +1 -1
  104. package/dist/connection-account-label.d.ts +2 -0
  105. package/dist/connection-account-label.js +35 -0
  106. package/dist/connection-account-label.js.map +1 -0
  107. package/dist/connection-authority.d.ts +9 -317
  108. package/dist/connection-authority.js +37 -42
  109. package/dist/connector-attachments.js +2 -1
  110. package/dist/connector-destinations.js +2 -1
  111. package/dist/connector-tool-permissions.d.ts +137 -0
  112. package/dist/cua-desktop-tools.d.ts +17 -0
  113. package/dist/define-schema.d.ts +8 -0
  114. package/dist/direct-model-provider.d.ts +36 -0
  115. package/dist/editable-artifact-codec-registry.js +5 -5
  116. package/dist/editable-artifact-committed-transaction.js +3 -2
  117. package/dist/editable-artifact-live.js +5 -5
  118. package/dist/editable-artifact-serialized-commit.js +6 -6
  119. package/dist/editable-artifact-versions.d.ts +7 -1
  120. package/dist/editable-artifact-versions.js +1 -1
  121. package/dist/editable-artifacts.js +62 -56
  122. package/dist/event-preview.d.ts +22 -0
  123. package/dist/external-identities.d.ts +138 -0
  124. package/dist/external-identities.js +9 -4
  125. package/dist/first-party-tool-authorization.d.ts +815 -0
  126. package/dist/github-repository-contracts.js +60 -43
  127. package/dist/github-repository-contracts.js.map +1 -1
  128. package/dist/google-drive.d.ts +2 -1
  129. package/dist/google-drive.js +305 -238
  130. package/dist/google-drive.js.map +1 -1
  131. package/dist/host-mcp-bindings.d.ts +5 -0
  132. package/dist/host-mcp-bindings.js +233 -170
  133. package/dist/host-mcp-bindings.js.map +1 -1
  134. package/dist/image-generation.d.ts +1 -0
  135. package/dist/index.d.ts +16761 -5946
  136. package/dist/index.js +1973 -260
  137. package/dist/insights-usage.d.ts +877 -0
  138. package/dist/insights-usage.js +559 -0
  139. package/dist/insights-usage.js.map +1 -0
  140. package/dist/interaction.d.ts +1176 -829
  141. package/dist/knowledge-entries.d.ts +81 -2
  142. package/dist/knowledge-preparation.d.ts +239 -0
  143. package/dist/managed-auth-session-sets.d.ts +7 -0
  144. package/dist/managed-auth-session-sets.js +198 -132
  145. package/dist/managed-auth-session-sets.js.map +1 -1
  146. package/dist/managed-sign-in-methods.d.ts +56 -0
  147. package/dist/managed-sign-in-methods.js +64 -0
  148. package/dist/managed-sign-in-methods.js.map +1 -0
  149. package/dist/mcp-catalog-limits.d.ts +2 -0
  150. package/dist/mcp-oauth.d.ts +2 -2
  151. package/dist/mcp-structured-content.d.ts +25 -0
  152. package/dist/modal-native-proof-v2.d.ts +587 -0
  153. package/dist/modal-native-proof-v2.js +38 -0
  154. package/dist/modal-native-proof-v2.js.map +1 -0
  155. package/dist/model-account-choice.d.ts +235 -0
  156. package/dist/model-account-settings.d.ts +422 -0
  157. package/dist/model-availability.d.ts +15 -0
  158. package/dist/model-connection-access.d.ts +13 -0
  159. package/dist/model-context-inspector.d.ts +98 -0
  160. package/dist/model-display.d.ts +43 -0
  161. package/dist/model-display.js +17 -0
  162. package/dist/model-display.js.map +1 -0
  163. package/dist/model-picker-order.d.ts +3 -1
  164. package/dist/model-picker-order.js +3 -0
  165. package/dist/model-picker-order.js.map +1 -1
  166. package/dist/organization-access.d.ts +412 -0
  167. package/dist/organization-access.js +39 -0
  168. package/dist/organization-access.js.map +1 -0
  169. package/dist/organization-integration-policy.d.ts +27 -0
  170. package/dist/organization-membership-lifecycle.d.ts +38 -0
  171. package/dist/organization-model-usage.d.ts +146 -0
  172. package/dist/organization-model-usage.js +78 -0
  173. package/dist/organization-model-usage.js.map +1 -0
  174. package/dist/organization-recovery.js +2 -1
  175. package/dist/organization-usage.d.ts +138 -0
  176. package/dist/permissions.d.ts +18 -0
  177. package/dist/personal-github.d.ts +1 -0
  178. package/dist/personal-github.js +199 -144
  179. package/dist/personal-github.js.map +1 -1
  180. package/dist/prepared-mcp-setup.d.ts +54 -0
  181. package/dist/prepared-mcp-setup.js +12 -0
  182. package/dist/prepared-mcp-setup.js.map +1 -0
  183. package/dist/product-analytics.d.ts +116 -0
  184. package/dist/product-lifecycle-facts.d.ts +73 -0
  185. package/dist/remember.d.ts +98 -6
  186. package/dist/retained-output.d.ts +8 -0
  187. package/dist/sandbox-file-artifacts.d.ts +1 -0
  188. package/dist/sandbox-provider-command.d.ts +91 -1
  189. package/dist/sandbox-recovery.d.ts +146 -0
  190. package/dist/secret-generator.d.ts +44 -0
  191. package/dist/secret-references.d.ts +90 -0
  192. package/dist/secret-resolution.d.ts +111 -0
  193. package/dist/secret-totp.d.ts +41 -0
  194. package/dist/session-final-reply.d.ts +6 -0
  195. package/dist/session-final-reply.js +9 -0
  196. package/dist/session-final-reply.js.map +1 -0
  197. package/dist/session-goal-reports.d.ts +21 -0
  198. package/dist/session-history-import.d.ts +1272 -0
  199. package/dist/session-list-entries.d.ts +4 -0
  200. package/dist/session-list-entries.js +56 -0
  201. package/dist/session-list-entries.js.map +1 -0
  202. package/dist/session-mcp-projections.d.ts +6 -0
  203. package/dist/session-mcp-tool-permissions.d.ts +62 -0
  204. package/dist/session-message-search.d.ts +68 -0
  205. package/dist/session-target.d.ts +18 -0
  206. package/dist/session-titles.d.ts +8 -0
  207. package/dist/session-titles.js +5 -1
  208. package/dist/session-usage-limit-refusal.d.ts +34 -0
  209. package/dist/session-usage-limit-refusal.js +15 -0
  210. package/dist/session-usage-limit-refusal.js.map +1 -0
  211. package/dist/session-usage-limits.d.ts +127 -0
  212. package/dist/session-usage-limits.js +41 -0
  213. package/dist/session-usage-limits.js.map +1 -0
  214. package/dist/signup-attribution.d.ts +39 -0
  215. package/dist/site-data.d.ts +286 -0
  216. package/dist/site-operations.d.ts +39 -0
  217. package/dist/site-publishing.d.ts +778 -0
  218. package/dist/site-session-http.d.ts +89 -4
  219. package/dist/site-session-http.js +25 -1
  220. package/dist/site-sql.d.ts +421 -0
  221. package/dist/skill-catalog-context.d.ts +7 -0
  222. package/dist/skill-files.d.ts +1 -1
  223. package/dist/skill-use.d.ts +61 -0
  224. package/dist/skills.d.ts +15 -0
  225. package/dist/slack-bot-scopes.d.ts +17 -12
  226. package/dist/slack-bot-scopes.js +10 -3
  227. package/dist/slack-rest-mcp.d.ts +36 -0
  228. package/dist/slack-rest-mcp.js +25 -0
  229. package/dist/slack-rest-mcp.js.map +1 -0
  230. package/dist/spreadsheet-artifact-commands.d.ts +14 -1
  231. package/dist/spreadsheet-artifact-commands.js +8 -2
  232. package/dist/spreadsheet-artifact-query.d.ts +13 -6
  233. package/dist/spreadsheet-artifact-query.js +3 -3
  234. package/dist/subscription-account-actions.d.ts +64 -0
  235. package/dist/subscription-account-pools.d.ts +292 -0
  236. package/dist/subscription-personal-authority-v2.d.ts +28 -0
  237. package/dist/subscription-personal-authority-v2.js +12 -0
  238. package/dist/subscription-personal-authority-v2.js.map +1 -0
  239. package/dist/tool-action-review.d.ts +132 -0
  240. package/dist/tool-catalog.d.ts +408 -0
  241. package/dist/tool-policy.d.ts +5 -0
  242. package/dist/tool-review-presentation.d.ts +12 -0
  243. package/dist/tool-review-presentation.js +17 -0
  244. package/dist/tool-review-presentation.js.map +1 -0
  245. package/dist/transcription-recordings.d.ts +21 -0
  246. package/dist/turn-serving-policy.d.ts +221 -0
  247. package/dist/usage-allowances.d.ts +314 -0
  248. package/dist/usage-allowances.js +52 -0
  249. package/dist/usage-allowances.js.map +1 -0
  250. package/dist/vaults.d.ts +1286 -0
  251. package/dist/video-generation.d.ts +3 -0
  252. package/dist/video-generation.js +2 -1
  253. package/dist/workspace-integration-wire.d.ts +36 -0
  254. package/dist/workspace-integration-wire.js +23 -0
  255. package/dist/workspace-integration-wire.js.map +1 -0
  256. package/dist/workspace-integrations.d.ts +1028 -0
  257. package/dist/xai-provider-account-authority.js +2 -1
  258. package/package.json +93 -5
  259. package/src/agent-authored-durable-text.ts +14 -11
  260. package/src/agent-config.ts +1698 -0
  261. package/src/agent-instruction-changes.ts +91 -74
  262. package/src/agent-learning.ts +94 -67
  263. package/src/agent-topology.ts +57 -52
  264. package/src/allowance-refusal.ts +81 -0
  265. package/src/analytics-consent-report.ts +20 -0
  266. package/src/api-key-presets.ts +28 -0
  267. package/src/artifact-catalog.ts +82 -0
  268. package/src/artifacts.ts +299 -227
  269. package/src/atlassian-native-retirement.ts +33 -0
  270. package/src/atlassian.ts +135 -108
  271. package/src/browser-storage.ts +10 -0
  272. package/src/bundled-skills.ts +60 -17
  273. package/src/canonical-human-identities.ts +60 -58
  274. package/src/claude-provider-account-authority.ts +12 -0
  275. package/src/claude-subscription-oauth.ts +73 -0
  276. package/src/claude-subscription-usage.ts +68 -0
  277. package/src/client-error-report.ts +343 -0
  278. package/src/code-search.ts +105 -0
  279. package/src/codex-provider-account-authority.ts +21 -16
  280. package/src/company-brain-governed-writes.ts +255 -233
  281. package/src/company-brain.ts +164 -153
  282. package/src/company-profile.ts +365 -292
  283. package/src/connect.ts +212 -173
  284. package/src/connection-account-label.ts +46 -0
  285. package/src/connection-authority.ts +183 -364
  286. package/src/connector-attachments.ts +137 -122
  287. package/src/connector-destinations.ts +46 -42
  288. package/src/connector-tool-permissions.ts +117 -0
  289. package/src/cua-desktop-tools.gen.json +6512 -0
  290. package/src/cua-desktop-tools.linux.gen.json +6600 -0
  291. package/src/cua-desktop-tools.ts +36 -0
  292. package/src/cua-desktop-tools.windows.gen.json +6353 -0
  293. package/src/define-schema.ts +10 -0
  294. package/src/direct-model-provider.ts +108 -0
  295. package/src/editable-artifact-committed-transaction.ts +17 -0
  296. package/src/editable-artifact-versions.ts +7 -1
  297. package/src/event-preview.ts +53 -3
  298. package/src/external-identities.ts +249 -176
  299. package/src/feedback.ts +43 -30
  300. package/src/first-party-tool-authorization.ts +356 -0
  301. package/src/github-repository-contracts.ts +78 -64
  302. package/src/google-drive.ts +285 -234
  303. package/src/governed-learning-activation.ts +152 -131
  304. package/src/governed-learning-evaluator.ts +140 -133
  305. package/src/host-mcp-bindings.ts +252 -198
  306. package/src/image-generation.ts +104 -95
  307. package/src/index.ts +13235 -8687
  308. package/src/insights-usage.ts +727 -0
  309. package/src/interaction.ts +3070 -2326
  310. package/src/knowledge-entries.ts +361 -276
  311. package/src/knowledge-preparation.ts +57 -0
  312. package/src/knowledge.ts +246 -213
  313. package/src/managed-auth-session-sets.ts +220 -144
  314. package/src/managed-sign-in-methods.ts +52 -0
  315. package/src/mcp-catalog-limits.ts +2 -0
  316. package/src/mcp-oauth.ts +43 -34
  317. package/src/mcp-receipts.ts +192 -192
  318. package/src/mcp-structured-content.ts +81 -0
  319. package/src/memory-slack-delivery.ts +171 -142
  320. package/src/modal-native-proof-v2.ts +429 -0
  321. package/src/model-account-choice.ts +177 -0
  322. package/src/model-account-settings.ts +210 -0
  323. package/src/model-availability.ts +22 -0
  324. package/src/model-connection-access.ts +61 -14
  325. package/src/model-context-inspector.ts +133 -99
  326. package/src/model-display.ts +221 -0
  327. package/src/model-picker-order.ts +12 -1
  328. package/src/organization-access.ts +217 -0
  329. package/src/organization-integration-policy.ts +63 -0
  330. package/src/organization-membership-lifecycle.ts +528 -382
  331. package/src/organization-model-usage.ts +81 -0
  332. package/src/organization-recovery.ts +147 -135
  333. package/src/organization-usage.ts +94 -0
  334. package/src/permissions.ts +88 -52
  335. package/src/personal-github.ts +210 -171
  336. package/src/preference-registry.ts +314 -258
  337. package/src/prepared-mcp-setup.ts +189 -0
  338. package/src/product-analytics.ts +261 -0
  339. package/src/product-lifecycle-facts.ts +122 -0
  340. package/src/remember.ts +181 -167
  341. package/src/retained-output.ts +194 -165
  342. package/src/sandbox-file-artifacts.ts +60 -47
  343. package/src/sandbox-provider-command.ts +88 -20
  344. package/src/sandbox-recovery.ts +129 -0
  345. package/src/scoped-knowledge.ts +61 -43
  346. package/src/secret-generator.ts +155 -0
  347. package/src/secret-references.ts +414 -0
  348. package/src/secret-resolution.ts +274 -0
  349. package/src/secret-totp.ts +188 -0
  350. package/src/session-final-reply.ts +16 -0
  351. package/src/session-goal-reports.ts +64 -0
  352. package/src/session-history-import.ts +177 -0
  353. package/src/session-list-entries.ts +96 -0
  354. package/src/session-mcp-projections.ts +11 -0
  355. package/src/session-mcp-tool-permissions.ts +108 -0
  356. package/src/session-message-search.ts +61 -0
  357. package/src/session-target.ts +57 -0
  358. package/src/session-titles.ts +80 -10
  359. package/src/session-topology-primitives.ts +19 -12
  360. package/src/session-usage-limit-refusal.ts +101 -0
  361. package/src/session-usage-limits.ts +171 -0
  362. package/src/signup-attribution.ts +86 -0
  363. package/src/site-data.ts +339 -0
  364. package/src/site-operations.ts +154 -0
  365. package/src/site-publishing.ts +876 -0
  366. package/src/site-session-http.ts +294 -16
  367. package/src/site-sql.ts +1123 -0
  368. package/src/skill-catalog-context.ts +50 -0
  369. package/src/skill-files.ts +3 -3
  370. package/src/skill-use.ts +80 -0
  371. package/src/skills.ts +82 -54
  372. package/src/slack-bot-scopes.ts +31 -39
  373. package/src/slack-rest-mcp.ts +222 -0
  374. package/src/slack-task-policy.ts +96 -73
  375. package/src/spreadsheet-artifact-commands.ts +73 -2
  376. package/src/spreadsheet-artifact-query.ts +187 -39
  377. package/src/subscription-account-actions.ts +84 -0
  378. package/src/subscription-account-pools.ts +53 -0
  379. package/src/subscription-personal-authority-v2.ts +66 -0
  380. package/src/task-notes.ts +55 -51
  381. package/src/tool-action-review.ts +258 -0
  382. package/src/tool-catalog.ts +609 -372
  383. package/src/tool-policy.ts +82 -0
  384. package/src/tool-result-spill.ts +12 -9
  385. package/src/tool-review-presentation.ts +385 -0
  386. package/src/transcription-recordings.ts +145 -131
  387. package/src/turn-serving-policy.ts +166 -0
  388. package/src/usage-allowances.ts +248 -0
  389. package/src/vaults.ts +850 -0
  390. package/src/video-generation.ts +385 -360
  391. package/src/work-claims.ts +173 -149
  392. package/src/workspace-instruction-policies.ts +349 -276
  393. package/src/workspace-integration-wire.ts +101 -0
  394. package/src/workspace-integrations.ts +724 -0
  395. package/src/workspace-learning-administration.ts +57 -44
  396. package/src/workspace-learning-policy.ts +127 -96
  397. package/src/workspace-state.ts +250 -220
  398. package/src/xai-provider-account-authority.ts +22 -17
  399. package/dist/chunk-2AC63F4S.js +0 -171
  400. package/dist/chunk-2AC63F4S.js.map +0 -1
  401. package/dist/chunk-3SIZGL3O.js.map +0 -1
  402. package/dist/chunk-7ABONTXE.js.map +0 -1
  403. package/dist/chunk-BCS7WHCK.js +0 -139
  404. package/dist/chunk-BCS7WHCK.js.map +0 -1
  405. package/dist/chunk-GRG7PHWQ.js +0 -25
  406. package/dist/chunk-GRG7PHWQ.js.map +0 -1
  407. package/dist/chunk-JUFK3T4Q.js +0 -80
  408. package/dist/chunk-JUFK3T4Q.js.map +0 -1
  409. package/dist/chunk-M5ZGRVIQ.js +0 -719
  410. package/dist/chunk-M5ZGRVIQ.js.map +0 -1
  411. package/dist/chunk-MRWYRAS5.js.map +0 -1
  412. package/dist/chunk-OVFORMPW.js +0 -348
  413. package/dist/chunk-OVFORMPW.js.map +0 -1
  414. package/dist/chunk-P3HLDT77.js +0 -59
  415. package/dist/chunk-P3HLDT77.js.map +0 -1
  416. package/dist/chunk-QQUJ6NPW.js +0 -23093
  417. package/dist/chunk-QQUJ6NPW.js.map +0 -1
  418. package/dist/chunk-TXTQIYCV.js.map +0 -1
  419. package/dist/chunk-WYBDERIY.js.map +0 -1
  420. package/dist/chunk-Y3KNXVTD.js.map +0 -1
  421. package/dist/chunk-YBW5JSA3.js.map +0 -1
  422. package/dist/chunk-YRXAWWCU.js +0 -45
  423. package/dist/chunk-YRXAWWCU.js.map +0 -1
  424. package/dist/host-mcp-resolvers.d.ts +0 -32
  425. package/dist/host-mcp-resolvers.js +0 -34
  426. package/dist/host-mcp-resolvers.js.map +0 -1
  427. package/src/host-mcp-resolvers.ts +0 -50
  428. /package/dist/{chunk-5LYFSZ7O.js.map → chunk-352X6ENP.js.map} +0 -0
  429. /package/dist/{chunk-O5LEQHDM.js.map → chunk-Z7WEVGCL.js.map} +0 -0
@@ -0,0 +1,61 @@
1
+ import { defineSchema } from "./define-schema";
2
+ import { z } from "zod";
3
+
4
+ /** Literal Unicode case-insensitive search, without trimming or normalization. */
5
+ export const SessionMessageSearchRequest = /* @__PURE__ */ defineSchema(() =>
6
+ z
7
+ .object({
8
+ query: z.string().min(1).max(200),
9
+ sessionId: z.string().uuid().optional(),
10
+ groupBy: z.literal("session").optional(),
11
+ archiveStatus: z.enum(["active", "archived", "all"]).optional(),
12
+ limit: z.number().int().min(1).max(50).optional(),
13
+ cursor: z.string().min(1).max(4096).optional(),
14
+ })
15
+ .strict()
16
+ .refine((request) => !request.groupBy || !request.sessionId, {
17
+ message: "groupBy=session is only supported for workspace search without sessionId",
18
+ path: ["groupBy"],
19
+ }),
20
+ );
21
+ export type SessionMessageSearchRequest = z.infer<typeof SessionMessageSearchRequest>;
22
+
23
+ export const SessionMessageSearchMatch = /* @__PURE__ */ defineSchema(() =>
24
+ z.object({
25
+ sessionId: z.string().uuid(),
26
+ sessionTitle: z.string().nullable(),
27
+ eventId: z.string().uuid(),
28
+ sequence: z.number().int().positive(),
29
+ turnId: z.string().uuid().nullable(),
30
+ role: z.enum(["user", "assistant"]),
31
+ messageId: z.string().nullable(),
32
+ /** All offsets are zero-based UTF-16 code units; ends are exclusive. */
33
+ messageMatchOffset: z.number().int().nonnegative(),
34
+ snippet: z.object({
35
+ text: z.string(),
36
+ matchStart: z.number().int().nonnegative(),
37
+ matchEnd: z.number().int().nonnegative(),
38
+ }),
39
+ }),
40
+ );
41
+ export type SessionMessageSearchMatch = z.infer<typeof SessionMessageSearchMatch>;
42
+
43
+ /** A bounded scan page, not necessarily a full page of matches. Continue even
44
+ * after an empty page while hasMore is true. Counts describe this live traversal,
45
+ * not a frozen snapshot; restart to reflect concurrent changes. All non-overlapping
46
+ * literal occurrences in user messages and completed assistant messages.
47
+ * With groupBy=session, matches and both matched counts describe one first-hit
48
+ * representative per matching session, not full message/occurrence totals.
49
+ */
50
+ export const SessionMessageSearchResponse = /* @__PURE__ */ defineSchema(() =>
51
+ z.object({
52
+ matches: z.array(SessionMessageSearchMatch).max(50),
53
+ nextCursor: z.string().nullable(),
54
+ hasMore: z.boolean(),
55
+ scannedMessages: z.number().int().nonnegative(),
56
+ matchedMessageCount: z.number().int().nonnegative(),
57
+ matchedOccurrenceCount: z.number().int().nonnegative(),
58
+ countIsExact: z.boolean(),
59
+ }),
60
+ );
61
+ export type SessionMessageSearchResponse = z.infer<typeof SessionMessageSearchResponse>;
@@ -0,0 +1,57 @@
1
+ import { defineSchema } from "./define-schema";
2
+ import { z } from "zod";
3
+
4
+ /** Conversational context only. Never an authority or an implicit dispatch destination. */
5
+ export const SessionTargetContext = /* @__PURE__ */ defineSchema(() =>
6
+ z
7
+ .object({
8
+ version: z.number().int().nonnegative(),
9
+ sessionId: z.string().uuid().nullable(),
10
+ operationId: z.string().uuid().nullable(),
11
+ })
12
+ .strict(),
13
+ );
14
+ export type SessionTargetContext = z.infer<typeof SessionTargetContext>;
15
+
16
+ export const SetSessionTargetRequest = /* @__PURE__ */ defineSchema(() =>
17
+ z
18
+ .object({
19
+ sessionId: z.string().uuid().nullable(),
20
+ expectedVersion: z.number().int().nonnegative(),
21
+ operationId: z.string().uuid(),
22
+ })
23
+ .strict(),
24
+ );
25
+ export type SetSessionTargetRequest = z.infer<typeof SetSessionTargetRequest>;
26
+
27
+ export const SESSION_TARGET_CONTEXT_KEY = "conversationTargetV1";
28
+
29
+ export function sessionTargetContext(metadata: Record<string, unknown>): SessionTargetContext {
30
+ return SessionTargetContext.parse(
31
+ metadata[SESSION_TARGET_CONTEXT_KEY] ?? {
32
+ version: 0,
33
+ sessionId: null,
34
+ operationId: null,
35
+ },
36
+ );
37
+ }
38
+
39
+ /** CAS plus exact retry replay; an old retry cannot restore a subsequently cleared target. */
40
+ export function nextSessionTargetContext(
41
+ current: SessionTargetContext,
42
+ request: SetSessionTargetRequest,
43
+ ): SessionTargetContext {
44
+ SetSessionTargetRequest.parse(request);
45
+ if (current.operationId === request.operationId) {
46
+ if (current.sessionId !== request.sessionId || current.version !== request.expectedVersion + 1)
47
+ throw new Error("Session target operation was reused with different input");
48
+ return current;
49
+ }
50
+ if (current.version !== request.expectedVersion)
51
+ throw new Error("Session target changed; read it again");
52
+ return {
53
+ version: current.version + 1,
54
+ sessionId: request.sessionId,
55
+ operationId: request.operationId,
56
+ };
57
+ }
@@ -18,7 +18,7 @@ export const AUTOMATIC_SESSION_TITLE_FALLBACK = "New conversation";
18
18
  // Session creation accepts a body far larger than a navigation label. Bound
19
19
  // the source before any replace/split/normalization so a persisted large prompt
20
20
  // cannot amplify memory or CPU on every client render.
21
- const PROMPT_PREVIEW_SCAN_MAX_CODE_UNITS = 4_096;
21
+ export const PROMPT_PREVIEW_SCAN_MAX_CODE_UNITS = 4_096;
22
22
 
23
23
  const SESSION_ID_PATTERN =
24
24
  /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
@@ -254,6 +254,45 @@ function stripAutomaticTitleBoilerplate(value: string): string {
254
254
  return title;
255
255
  }
256
256
 
257
+ const AUTOMATIC_TITLE_TRAILING_PUNCTUATION = /[\s.!?,;:\-–—]+$/u;
258
+
259
+ // Closing quote and markdown marks, mapped to the distinct opening mark that
260
+ // would pair with them inside the title.
261
+ const TRAILING_WRAPPER_MARKS = new Map<string, string | null>([
262
+ ['"', null],
263
+ ["'", null],
264
+ ["`", null],
265
+ ["*", null],
266
+ ["”", "“"],
267
+ ["’", "‘"],
268
+ ["»", "«"],
269
+ ]);
270
+
271
+ /**
272
+ * Remove trailing punctuation and a closing quote or markdown mark whose
273
+ * opening counterpart was already stripped as a leading wrapper, so
274
+ * `"Pod Crash Debugging"` and `**Pod Crash Debugging**` do not keep a dangling
275
+ * closing mark. A mark that still pairs with one inside the title stays.
276
+ */
277
+ function trimAutomaticTitleEnd(value: string): string {
278
+ let title = value;
279
+ for (let pass = 0; pass < 4; pass += 1) {
280
+ const before = title;
281
+ title = title.replace(AUTOMATIC_TITLE_TRAILING_PUNCTUATION, "");
282
+ const last = title.at(-1);
283
+ const opening = last === undefined ? undefined : TRAILING_WRAPPER_MARKS.get(last);
284
+ if (last !== undefined && opening !== undefined) {
285
+ let rest = title;
286
+ while (rest.endsWith(last)) rest = rest.slice(0, -last.length);
287
+ if (!rest.includes(last) && (opening === null || !rest.includes(opening))) {
288
+ title = rest;
289
+ }
290
+ }
291
+ if (title === before) break;
292
+ }
293
+ return title.trim();
294
+ }
295
+
257
296
  function automaticTitleGraphemes(value: string): string[] {
258
297
  if (titleSegmenter === undefined) {
259
298
  titleSegmenter =
@@ -285,6 +324,39 @@ function automaticTitleGraphemes(value: string): string[] {
285
324
  return graphemes;
286
325
  }
287
326
 
327
+ /**
328
+ * Model control tokens such as `<|fim_suffix|>`, `<|im_end|>` or `<|end▁of▁sentence|>`
329
+ * sometimes leak into generated text. They are never title content: each one
330
+ * becomes a line break, so a title keeps only its first real segment.
331
+ */
332
+ const MODEL_CONTROL_TOKEN = /<[||][^<>||\s]{1,64}[||]>/gu;
333
+
334
+ function withoutModelControlTokens(value: string): string {
335
+ return value.replace(MODEL_CONTROL_TOKEN, "\n");
336
+ }
337
+
338
+ /**
339
+ * Read-side cleanup for a durable title. Automatic titles written before
340
+ * control-token stripping can still hold a token ("Release plan<|fim_suffix|>");
341
+ * those keep only their first real segment, and a token-only title reads as no
342
+ * title. Human renames and titles without a token are returned unchanged.
343
+ */
344
+ export function cleanStoredSessionTitle(
345
+ title: string | null | undefined,
346
+ titleSource: string | null | undefined,
347
+ ): string | null {
348
+ if (title === null || title === undefined) return null;
349
+ if (titleSource === "user") return title;
350
+ const stripped = withoutModelControlTokens(title);
351
+ if (stripped === title) return title;
352
+ return (
353
+ stripped
354
+ .split("\n")
355
+ .map((part) => part.trim())
356
+ .find(Boolean) ?? null
357
+ );
358
+ }
359
+
288
360
  /** Bound an already-normalized automatic-title candidate without splitting graphemes. */
289
361
  export function boundAutomaticSessionTitle(value: string): string {
290
362
  const words = value.split(/\s+/u);
@@ -306,7 +378,7 @@ export function boundAutomaticSessionTitle(value: string): string {
306
378
  * title (normally {@link AUTOMATIC_SESSION_TITLE_FALLBACK}) in that case.
307
379
  */
308
380
  export function normalizeAutomaticSessionTitle(value: string): string | null {
309
- const firstLine = value
381
+ const firstLine = withoutModelControlTokens(value)
310
382
  .replace(/[\u0000-\u001f\u007f-\u009f]+/gu, "\n")
311
383
  .split(/\n+/u)
312
384
  .map((line) => line.trim())
@@ -319,10 +391,9 @@ export function normalizeAutomaticSessionTitle(value: string): string | null {
319
391
  return null;
320
392
  }
321
393
 
322
- let title = stripAutomaticTitleBoilerplate(firstLine)
323
- .replace(/\s+/gu, " ")
324
- .replace(/[\s.!?,;:\-–—]+$/u, "")
325
- .trim();
394
+ let title = trimAutomaticTitleEnd(
395
+ stripAutomaticTitleBoilerplate(firstLine).replace(/\s+/gu, " "),
396
+ );
326
397
  if (
327
398
  !title ||
328
399
  !hasVisibleAutomaticTitleContent(title) ||
@@ -331,9 +402,7 @@ export function normalizeAutomaticSessionTitle(value: string): string | null {
331
402
  return null;
332
403
  }
333
404
 
334
- title = boundAutomaticSessionTitle(title)
335
- .replace(/[\s.!?,;:\-–—]+$/u, "")
336
- .trim();
405
+ title = trimAutomaticTitleEnd(boundAutomaticSessionTitle(title));
337
406
  if (!title || !hasVisibleAutomaticTitleContent(title)) return null;
338
407
  return title;
339
408
  }
@@ -414,7 +483,8 @@ export function deriveSessionDisplayTitle(
414
483
  return title || automaticSessionReferenceTitle(input.id);
415
484
  }
416
485
  if (title && !sessionTitleIsPending(input)) {
417
- return title;
486
+ const clean = cleanStoredSessionTitle(title, input.titleSource)?.trim();
487
+ if (clean) return clean;
418
488
  }
419
489
 
420
490
  for (const key of options.metadataKeys ?? []) {
@@ -1,21 +1,28 @@
1
+ import { defineSchema } from "./define-schema";
1
2
  import { z } from "zod";
2
3
 
3
- export const SessionStatus = z.enum([
4
- "queued",
5
- "running",
6
- "idle",
7
- "requires_action",
8
- "recovering",
9
- "waiting_capacity",
10
- "failed",
11
- "cancelled",
12
- ]);
4
+ export const SessionStatus = /* @__PURE__ */ defineSchema(() =>
5
+ z.enum([
6
+ "queued",
7
+ "running",
8
+ "idle",
9
+ "requires_action",
10
+ "recovering",
11
+ "waiting_capacity",
12
+ "failed",
13
+ "cancelled",
14
+ ]),
15
+ );
13
16
  export type SessionStatus = z.infer<typeof SessionStatus>;
14
17
 
15
- export const SessionGoalStatus = z.enum(["active", "paused", "completed"]);
18
+ export const SessionGoalStatus = /* @__PURE__ */ defineSchema(() =>
19
+ z.enum(["active", "paused", "completed"]),
20
+ );
16
21
  export type SessionGoalStatus = z.infer<typeof SessionGoalStatus>;
17
22
 
18
23
  /** Physical ceiling of the PostgreSQL integer columns that persist depth policy. */
19
24
  export const MAX_NESTED_AGENT_DEPTH = 2_147_483_647;
20
- export const NestedAgentDepthValue = z.number().int().nonnegative().max(MAX_NESTED_AGENT_DEPTH);
25
+ export const NestedAgentDepthValue = /* @__PURE__ */ defineSchema(() =>
26
+ z.number().int().nonnegative().max(MAX_NESTED_AGENT_DEPTH),
27
+ );
21
28
  export type NestedAgentDepthValue = z.infer<typeof NestedAgentDepthValue>;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Browser/React Native-safe session usage limit helpers. Deliberately free of
3
+ * the zod runtime so synchronous timeline projection can use it; contract
4
+ * parity tests keep it aligned with `session-usage-limits.ts`.
5
+ */
6
+
7
+ /** `turn.completed.segmentLimit` for a stop caused by a task usage limit. */
8
+ export const SESSION_USAGE_LIMIT_SEGMENT = "session_usage_limit" as const;
9
+ /** `SessionGoal.pausedReason` for a goal paused by a task usage limit. */
10
+ export const SESSION_USAGE_LIMIT_GOAL_PAUSED_REASON = "session_usage_limit" as const;
11
+
12
+ const BASIS = "model_api_equivalent_v1";
13
+ const MAX_LIMIT_MICROS = 10_000_000 * 1_000_000;
14
+ const MESSAGE_MAX_UTF8_BYTES = 1_024;
15
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
16
+
17
+ export type ParsedSessionUsageLimitReachedRefusal = {
18
+ code: "session_usage_limit_reached";
19
+ basis: "model_api_equivalent_v1";
20
+ rootSessionId: string;
21
+ limitMicros: number;
22
+ usedMicros: number;
23
+ message: string;
24
+ };
25
+
26
+ function record(value: unknown): Record<string, unknown> | null {
27
+ return value !== null && typeof value === "object" && !Array.isArray(value)
28
+ ? (value as Record<string, unknown>)
29
+ : null;
30
+ }
31
+
32
+ function micros(value: unknown, max = Number.MAX_SAFE_INTEGER): value is number {
33
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= max;
34
+ }
35
+
36
+ function boundedMessage(value: string): string {
37
+ const normalized = value
38
+ .slice(0, MESSAGE_MAX_UTF8_BYTES * 2)
39
+ .replace(/[\u0000-\u001f\u007f]+/g, " ")
40
+ .trim();
41
+ const bytes = new TextEncoder().encode(normalized);
42
+ let end = Math.min(bytes.length, MESSAGE_MAX_UTF8_BYTES);
43
+ while (end > 0 && end < bytes.length && (bytes[end]! & 0xc0) === 0x80) end -= 1;
44
+ return new TextDecoder().decode(bytes.slice(0, end)).trim();
45
+ }
46
+
47
+ /**
48
+ * Select only the public refusal fields from an API error body (fields may sit
49
+ * in `details`), a `turn.completed` payload's `sessionUsageLimit` record, or a
50
+ * refusal object. Anything malformed returns null instead of a guessed amount.
51
+ */
52
+ export function parseSessionUsageLimitReachedRefusal(
53
+ value: unknown,
54
+ ): ParsedSessionUsageLimitReachedRefusal | null {
55
+ const outer = record(value);
56
+ if (!outer) return null;
57
+ const source = record(outer.sessionUsageLimit) ?? outer;
58
+ if (source.code !== "session_usage_limit_reached") return null;
59
+ const fields = record(source.details) ?? source;
60
+ if (
61
+ fields.basis !== BASIS ||
62
+ typeof fields.rootSessionId !== "string" ||
63
+ !UUID.test(fields.rootSessionId) ||
64
+ !micros(fields.limitMicros, MAX_LIMIT_MICROS) ||
65
+ !micros(fields.usedMicros)
66
+ ) {
67
+ return null;
68
+ }
69
+ const refusal = {
70
+ code: "session_usage_limit_reached" as const,
71
+ basis: BASIS as "model_api_equivalent_v1",
72
+ rootSessionId: fields.rootSessionId.toLowerCase(),
73
+ limitMicros: fields.limitMicros,
74
+ usedMicros: fields.usedMicros,
75
+ message: "",
76
+ };
77
+ const message = typeof source.message === "string" ? boundedMessage(source.message) : "";
78
+ return { ...refusal, message: message || sessionUsageLimitReachedMessage(refusal) };
79
+ }
80
+
81
+ /**
82
+ * "$12.34" for known amounts, "<$0.01" for a positive amount under a cent.
83
+ * Callers must not pass unknown usage: render "Preparing usage" or
84
+ * "Usage unavailable" instead of a dollar figure.
85
+ */
86
+ export function formatSessionUsageMicros(value: number): string {
87
+ if (value > 0 && value < 10_000) return "<$0.01";
88
+ const dollars = value / 1_000_000;
89
+ return `$${dollars.toLocaleString("en-US", {
90
+ minimumFractionDigits: 2,
91
+ maximumFractionDigits: 2,
92
+ })}`;
93
+ }
94
+
95
+ /** Fixed, bounded wording: no reset date, purchase remedy or invoice claim. */
96
+ export function sessionUsageLimitReachedMessage(refusal: {
97
+ limitMicros: number;
98
+ usedMicros: number;
99
+ }): string {
100
+ return `This task's usage limit is reached (${formatSessionUsageMicros(refusal.usedMicros)} of ${formatSessionUsageMicros(refusal.limitMicros)} API-equivalent model usage). A person can raise or remove the limit to continue.`;
101
+ }
@@ -0,0 +1,171 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * Per-task (root session) usage limits.
5
+ *
6
+ * One optional limit belongs to a root session and is shared by every
7
+ * descendant. It is measured in integer USD micros ($1 = 1,000,000) of the
8
+ * canonical pre-margin API-equivalent model cost (`estimatedProviderCostMicros`)
9
+ * recorded when a model response settles, whatever funds the call (Opengeni
10
+ * credits, a connected subscription or a workspace-owned key).
11
+ *
12
+ * The limit is checked before each new model request; it is not a reservation.
13
+ * Requests already admitted may finish and take recorded usage above the
14
+ * limit, and concurrently admitted requests may overshoot together. Usage
15
+ * without a known price is excluded from the total and disclosed as partial
16
+ * coverage instead of being valued at zero. It is not an invoice cap.
17
+ */
18
+
19
+ /** Versioned measurement basis, exposed so a future basis cannot be confused with this one. */
20
+ export const SESSION_USAGE_LIMIT_BASIS = "model_api_equivalent_v1" as const;
21
+ export const SessionUsageLimitBasis = z.literal(SESSION_USAGE_LIMIT_BASIS);
22
+ export type SessionUsageLimitBasis = z.infer<typeof SessionUsageLimitBasis>;
23
+
24
+ export const SESSION_USAGE_LIMIT_MICROS_PER_DOLLAR = 1_000_000;
25
+ /** $10M: the largest configurable limit, far inside safe integers. Usage itself is never clamped. */
26
+ export const SESSION_USAGE_LIMIT_MAX_MICROS = 10_000_000 * SESSION_USAGE_LIMIT_MICROS_PER_DOLLAR;
27
+
28
+ /** A configured limit. Zero is a valid immediate stop; `null` (not this schema) means no limit. */
29
+ export const SessionUsageLimitMicros = z
30
+ .number()
31
+ .int()
32
+ .nonnegative()
33
+ .safe()
34
+ .max(SESSION_USAGE_LIMIT_MAX_MICROS);
35
+ export type SessionUsageLimitMicros = z.infer<typeof SessionUsageLimitMicros>;
36
+
37
+ /** Recorded usage is a non-negative safe integer and may exceed the configured maximum. */
38
+ const UsageMicros = z.number().int().nonnegative().safe();
39
+ const Count = z.number().int().nonnegative().safe();
40
+ const Version = z.number().int().nonnegative().safe();
41
+
42
+ const OperationId = z
43
+ .string()
44
+ .min(1)
45
+ .max(256)
46
+ .refine(
47
+ (value) =>
48
+ value.trim().length > 0 &&
49
+ !value.includes("\0") &&
50
+ !/[\uD800-\uDFFF]/u.test(value) &&
51
+ new TextEncoder().encode(value).byteLength <= 256,
52
+ );
53
+
54
+ /**
55
+ * - `unlimited`: no limit is configured; usage is still recorded.
56
+ * - `within`: a limit is configured and recorded usage is below it.
57
+ * - `reached`: recorded usage is at or above the limit; new model requests are refused.
58
+ * - `preparing`: historical usage for a task created before this feature is
59
+ * still being imported; the total is not yet meaningful and a new limit
60
+ * cannot be set until it finishes.
61
+ * - `unavailable`: the usage state could not be read. Never treat it as zero or unlimited.
62
+ */
63
+ export const SessionUsageLimitStatus = z.enum([
64
+ "unlimited",
65
+ "within",
66
+ "reached",
67
+ "preparing",
68
+ "unavailable",
69
+ ]);
70
+ export type SessionUsageLimitStatus = z.infer<typeof SessionUsageLimitStatus>;
71
+
72
+ /**
73
+ * `complete`: every recorded model response of this task was metered live.
74
+ * `legacy_partial`: the task predates usage limits; available historical cost
75
+ * snapshots were imported, but older usage may be missing. This never upgrades
76
+ * to complete, because a missing old record is not proof of no usage.
77
+ * `preparing`: the historical import has not finished.
78
+ */
79
+ export const SessionUsageLimitHistory = z.enum(["complete", "legacy_partial", "preparing"]);
80
+ export type SessionUsageLimitHistory = z.infer<typeof SessionUsageLimitHistory>;
81
+
82
+ export const SessionUsageLimit = z
83
+ .object({
84
+ basis: SessionUsageLimitBasis,
85
+ /** The task root whose limit applies. Equal to the session id for a root. */
86
+ rootSessionId: z.string().uuid(),
87
+ /** True when this projection was read through a descendant: edit the root's limit instead. */
88
+ inherited: z.boolean(),
89
+ status: SessionUsageLimitStatus,
90
+ /** Configured limit; null means no limit. Meaningless while `status` is `unavailable`. */
91
+ limitMicros: SessionUsageLimitMicros.nullable(),
92
+ /**
93
+ * Recorded known (priced or known-free) usage of the whole task tree, in USD
94
+ * micros. Null while `preparing` or `unavailable`: never render it as $0.
95
+ * May exceed `limitMicros`.
96
+ */
97
+ usedMicros: UsageMicros.nullable(),
98
+ /** Configuration version for compare-and-set writes. Survives clearing. */
99
+ version: Version,
100
+ /** Monotonic usage revision; increases whenever a usage receipt changes the total or coverage. */
101
+ usageRevision: Version,
102
+ history: SessionUsageLimitHistory,
103
+ /** `partial` when any usage has unknown cost or history is legacy/preparing: show "at least". */
104
+ coverage: z.enum(["complete", "partial"]),
105
+ pricedCalls: Count,
106
+ /** Responses with a known price of zero; they count as zero, unlike unpriced usage. */
107
+ freeCalls: Count,
108
+ /** Responses whose cost is unknown; they are excluded from `usedMicros`. */
109
+ unpricedCalls: Count,
110
+ updatedAt: z.string().datetime({ offset: true }).nullable(),
111
+ })
112
+ .strict();
113
+ export type SessionUsageLimit = z.infer<typeof SessionUsageLimit>;
114
+
115
+ /**
116
+ * Compare-and-set write of a root task's limit. `expectedVersion` is the
117
+ * `version` the caller last read; a stale version returns 409. A replay of the
118
+ * same `operationId` with the same request returns the committed result.
119
+ */
120
+ export const SetSessionUsageLimitRequest = z
121
+ .object({
122
+ limitMicros: SessionUsageLimitMicros.nullable(),
123
+ expectedVersion: Version,
124
+ operationId: OperationId,
125
+ })
126
+ .strict();
127
+ export type SetSessionUsageLimitRequest = z.infer<typeof SetSessionUsageLimitRequest>;
128
+
129
+ /** Typed refusal for a fresh model request, message or goal resume after the limit is reached. */
130
+ export const SessionUsageLimitReachedRefusal = z
131
+ .object({
132
+ code: z.literal("session_usage_limit_reached"),
133
+ basis: SessionUsageLimitBasis,
134
+ rootSessionId: z.string().uuid(),
135
+ limitMicros: SessionUsageLimitMicros,
136
+ usedMicros: UsageMicros,
137
+ message: z.string().max(1_024),
138
+ })
139
+ .strict();
140
+ export type SessionUsageLimitReachedRefusal = z.infer<typeof SessionUsageLimitReachedRefusal>;
141
+
142
+ /** Typed error codes for the usage-limit routes. */
143
+ export const SessionUsageLimitErrorCode = z.enum([
144
+ "session_usage_limit_reached",
145
+ "session_usage_limit_conflict",
146
+ "session_usage_limit_not_root",
147
+ "session_usage_limit_preparing",
148
+ "session_usage_limit_unavailable",
149
+ "session_usage_limit_disabled",
150
+ "session_usage_limit_forbidden",
151
+ ]);
152
+ export type SessionUsageLimitErrorCode = z.infer<typeof SessionUsageLimitErrorCode>;
153
+
154
+ /** The durable event appended to a root's stream when an authorized person changes its limit. */
155
+ export const SessionUsageLimitUpdatedPayload = z
156
+ .object({
157
+ basis: SessionUsageLimitBasis,
158
+ limitMicros: SessionUsageLimitMicros.nullable(),
159
+ previousLimitMicros: SessionUsageLimitMicros.nullable(),
160
+ version: Version,
161
+ })
162
+ .strict();
163
+ export type SessionUsageLimitUpdatedPayload = z.infer<typeof SessionUsageLimitUpdatedPayload>;
164
+
165
+ export {
166
+ formatSessionUsageMicros,
167
+ parseSessionUsageLimitReachedRefusal,
168
+ SESSION_USAGE_LIMIT_SEGMENT,
169
+ SESSION_USAGE_LIMIT_GOAL_PAUSED_REASON,
170
+ sessionUsageLimitReachedMessage,
171
+ } from "./session-usage-limit-refusal";
@@ -0,0 +1,86 @@
1
+ import { defineSchema } from "./define-schema";
2
+ import { z } from "zod";
3
+
4
+ /**
5
+ * First-touch marketing parameters accepted on the web app landing URL. The
6
+ * browser keeps them in memory only and forwards them with a sign-up request,
7
+ * so nothing is written to the device before analytics consent.
8
+ */
9
+ export const SIGNUP_ATTRIBUTION_URL_PARAMETERS = {
10
+ utmSource: "utm_source",
11
+ utmMedium: "utm_medium",
12
+ utmCampaign: "utm_campaign",
13
+ utmContent: "utm_content",
14
+ ref: "ref",
15
+ } as const;
16
+
17
+ /** Maximum retained length of one attribution value. */
18
+ export const SIGNUP_ATTRIBUTION_VALUE_MAX_LENGTH = 100;
19
+
20
+ /**
21
+ * Campaign labels are marketer-chosen slug tokens such as `hero-cta` or
22
+ * `opengeni.ai`. The closed character set has no space, `@`, `:`, `/`, `?`,
23
+ * `=`, or `%`, so free text, email addresses, and URL payloads are rejected
24
+ * before they reach any sink. The web boot capture and the session-set social
25
+ * start request mirror this rule; tests pin each copy to it.
26
+ */
27
+ export const SIGNUP_ATTRIBUTION_VALUE_PATTERN = /^[A-Za-z0-9._~+-]+$/;
28
+
29
+ const SignupAttributionValue = /* @__PURE__ */ defineSchema(() =>
30
+ z
31
+ .string()
32
+ .trim()
33
+ .min(1)
34
+ .max(SIGNUP_ATTRIBUTION_VALUE_MAX_LENGTH)
35
+ .regex(SIGNUP_ATTRIBUTION_VALUE_PATTERN),
36
+ );
37
+
38
+ export const SignupAttribution = /* @__PURE__ */ defineSchema(() =>
39
+ z
40
+ .object({
41
+ utmSource: SignupAttributionValue.optional(),
42
+ utmMedium: SignupAttributionValue.optional(),
43
+ utmCampaign: SignupAttributionValue.optional(),
44
+ utmContent: SignupAttributionValue.optional(),
45
+ ref: SignupAttributionValue.optional(),
46
+ })
47
+ .strict(),
48
+ );
49
+ export type SignupAttribution = z.infer<typeof SignupAttribution>;
50
+
51
+ /** Closed acquisition channels reported by server-side sign-up metrics. */
52
+ export const SIGNUP_ACQUISITION_SOURCES = ["producthunt", "website", "direct", "other"] as const;
53
+ export type SignupAcquisitionSource = (typeof SIGNUP_ACQUISITION_SOURCES)[number];
54
+
55
+ /**
56
+ * Normalize untrusted first-touch attribution to a closed channel. Missing
57
+ * attribution is `direct`; malformed or unrecognized attribution is `other`.
58
+ */
59
+ export function signupAcquisitionSource(input: unknown): SignupAcquisitionSource {
60
+ if (input === undefined || input === null) return "direct";
61
+ const parsed = SignupAttribution.safeParse(input);
62
+ if (!parsed.success) return "other";
63
+ const attribution = parsed.data;
64
+ const values = Object.values(attribution).filter((value) => value !== undefined);
65
+ if (values.length === 0) return "direct";
66
+ const source = attribution.utmSource?.toLowerCase();
67
+ const medium = attribution.utmMedium?.toLowerCase();
68
+ const ref = attribution.ref?.toLowerCase();
69
+ if ([source, ref].some((value) => value !== undefined && isProductHunt(value))) {
70
+ return "producthunt";
71
+ }
72
+ if (
73
+ source === "opengeni.ai" ||
74
+ source?.endsWith(".opengeni.ai") ||
75
+ source === "opengeni" ||
76
+ medium === "website"
77
+ ) {
78
+ return "website";
79
+ }
80
+ return "other";
81
+ }
82
+
83
+ function isProductHunt(value: string): boolean {
84
+ const compact = value.replace(/[\s._-]/g, "");
85
+ return compact === "ph" || compact.includes("producthunt");
86
+ }