@opengeni/sdk 3.3.2 → 3.4.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 (299) hide show
  1. package/README.md +1007 -72
  2. package/dist/adapters/express.d.ts +31 -0
  3. package/dist/adapters/express.js +87 -0
  4. package/dist/adapters/express.js.map +1 -0
  5. package/dist/adapters/hono.d.ts +16 -0
  6. package/dist/adapters/hono.js +8 -0
  7. package/dist/adapters/hono.js.map +1 -0
  8. package/dist/adapters/next.d.ts +29 -0
  9. package/dist/adapters/next.js +22 -0
  10. package/dist/adapters/next.js.map +1 -0
  11. package/dist/allowance-refusal.d.ts +2 -0
  12. package/dist/allowance-refusal.js +50 -0
  13. package/dist/allowance-refusal.js.map +1 -0
  14. package/dist/app-links.d.ts +42 -0
  15. package/dist/app-links.js +66 -0
  16. package/dist/app-links.js.map +1 -0
  17. package/dist/artifact-catalog.d.ts +40 -0
  18. package/dist/artifact-client.d.ts +20 -8
  19. package/dist/artifacts.d.ts +1 -1
  20. package/dist/artifacts.js +8 -6
  21. package/dist/automations.js +8 -2
  22. package/dist/automations.js.map +1 -1
  23. package/dist/azure-live-transport.d.ts +32 -0
  24. package/dist/browser.d.ts +7 -2
  25. package/dist/browser.js +27 -5
  26. package/dist/chat/fold.d.ts +75 -0
  27. package/dist/chat/handler.d.ts +41 -0
  28. package/dist/chat/http.d.ts +67 -0
  29. package/dist/chat/ids.d.ts +34 -0
  30. package/dist/chat/index.d.ts +9 -0
  31. package/dist/chat/index.js +1369 -0
  32. package/dist/chat/index.js.map +1 -0
  33. package/dist/chat/openai.d.ts +30 -0
  34. package/dist/chat/opengeni.d.ts +129 -0
  35. package/dist/chat/types.d.ts +207 -0
  36. package/dist/chat/vercel.d.ts +49 -0
  37. package/dist/chats.d.ts +8 -0
  38. package/dist/chunk-4AHR4KGA.js +301 -0
  39. package/dist/chunk-4AHR4KGA.js.map +1 -0
  40. package/dist/chunk-6GYGMLX4.js +332 -0
  41. package/dist/chunk-6GYGMLX4.js.map +1 -0
  42. package/dist/chunk-7EWT3PV6.js +368 -0
  43. package/dist/chunk-7EWT3PV6.js.map +1 -0
  44. package/dist/chunk-FTWVVPR6.js +1665 -0
  45. package/dist/chunk-FTWVVPR6.js.map +1 -0
  46. package/dist/{chunk-VYCTL62C.js → chunk-GZQSWAKD.js} +1 -1
  47. package/dist/chunk-GZQSWAKD.js.map +1 -0
  48. package/dist/chunk-KGEABAID.js +71 -0
  49. package/dist/chunk-KGEABAID.js.map +1 -0
  50. package/dist/{chunk-YKZME56C.js → chunk-KWADQ227.js} +3 -3
  51. package/dist/{chunk-YKZME56C.js.map → chunk-KWADQ227.js.map} +1 -1
  52. package/dist/{chunk-JUS2UYRP.js → chunk-NCU5OAN7.js} +27 -2
  53. package/dist/chunk-NCU5OAN7.js.map +1 -0
  54. package/dist/{chunk-YXQX7RQT.js → chunk-OI5YLASH.js} +73 -2
  55. package/dist/chunk-OI5YLASH.js.map +1 -0
  56. package/dist/chunk-OV3POE62.js +359 -0
  57. package/dist/chunk-OV3POE62.js.map +1 -0
  58. package/dist/chunk-P7UWKORG.js +561 -0
  59. package/dist/chunk-P7UWKORG.js.map +1 -0
  60. package/dist/chunk-QGEIL4TR.js +195 -0
  61. package/dist/chunk-QGEIL4TR.js.map +1 -0
  62. package/dist/{chunk-TRNI7KEO.js → chunk-S2NLS3ES.js} +3669 -1281
  63. package/dist/chunk-S2NLS3ES.js.map +1 -0
  64. package/dist/chunk-UM4ZXXJR.js +9 -0
  65. package/dist/chunk-UM4ZXXJR.js.map +1 -0
  66. package/dist/{chunk-QT3KFVDP.js → chunk-UME3X7CP.js} +28 -32
  67. package/dist/chunk-UME3X7CP.js.map +1 -0
  68. package/dist/chunk-VT4YM4XQ.js +210 -0
  69. package/dist/chunk-VT4YM4XQ.js.map +1 -0
  70. package/dist/chunk-WSYYXONG.js +1602 -0
  71. package/dist/chunk-WSYYXONG.js.map +1 -0
  72. package/dist/{chunk-C2H7HBNP.js → chunk-WVCJRSGJ.js} +119 -14
  73. package/dist/chunk-WVCJRSGJ.js.map +1 -0
  74. package/dist/chunk-X5ITQVXE.js +15 -0
  75. package/dist/chunk-X5ITQVXE.js.map +1 -0
  76. package/dist/chunk-XA7HVIHI.js +126 -0
  77. package/dist/chunk-XA7HVIHI.js.map +1 -0
  78. package/dist/{chunk-KKRO2VCP.js → chunk-YJCHB7R3.js} +60 -12
  79. package/dist/chunk-YJCHB7R3.js.map +1 -0
  80. package/dist/chunk-YKIHNLWD.js +153 -0
  81. package/dist/chunk-YKIHNLWD.js.map +1 -0
  82. package/dist/chunk-ZDUBPV33.js +277 -0
  83. package/dist/chunk-ZDUBPV33.js.map +1 -0
  84. package/dist/client.d.ts +1068 -118
  85. package/dist/codex-realtime-controller.d.ts +13 -0
  86. package/dist/codex-realtime-controller.js +4 -2
  87. package/dist/codex-realtime-v3-wire.d.ts +3 -2
  88. package/dist/codex-realtime.d.ts +5 -1
  89. package/dist/company-brain.d.ts +1 -11
  90. package/dist/core.d.ts +7 -2
  91. package/dist/core.js +25 -6
  92. package/dist/deprecation.d.ts +47 -0
  93. package/dist/document-authority-client.d.ts +24 -2
  94. package/dist/document-authority.js +7 -5
  95. package/dist/editable-artifacts/index.d.ts +1 -1
  96. package/dist/editable-artifacts/types.d.ts +12 -2
  97. package/dist/editable-artifacts.js +19 -3
  98. package/dist/editable-artifacts.js.map +1 -1
  99. package/dist/embedding-client.d.ts +129 -0
  100. package/dist/errors.d.ts +76 -1
  101. package/dist/external-vault-receiver.d.ts +203 -0
  102. package/dist/external-vault-receiver.js +564 -0
  103. package/dist/external-vault-receiver.js.map +1 -0
  104. package/dist/feedback.d.ts +23 -0
  105. package/dist/gateway-realtime-transport.js +1 -1
  106. package/dist/github-repositories.d.ts +10 -0
  107. package/dist/github-repositories.js +36 -0
  108. package/dist/github-repositories.js.map +1 -0
  109. package/dist/index.d.ts +62 -11
  110. package/dist/index.js +557 -338
  111. package/dist/index.js.map +1 -1
  112. package/dist/insights-usage.d.ts +33 -0
  113. package/dist/insights-usage.js +7 -0
  114. package/dist/insights-usage.js.map +1 -0
  115. package/dist/interaction.d.ts +165 -71
  116. package/dist/interaction.js +2 -2
  117. package/dist/knowledge.d.ts +7 -0
  118. package/dist/knowledge.js +20 -0
  119. package/dist/knowledge.js.map +1 -0
  120. package/dist/known-tools.d.ts +4 -0
  121. package/dist/message-links.d.ts +68 -0
  122. package/dist/model-context.d.ts +68 -0
  123. package/dist/model-display.d.ts +2 -0
  124. package/dist/model-display.js +17 -0
  125. package/dist/model-display.js.map +1 -0
  126. package/dist/model-picker-order.d.ts +1 -0
  127. package/dist/model-picker-order.js +10 -0
  128. package/dist/model-picker-order.js.map +1 -0
  129. package/dist/organization-integration-policy.d.ts +26 -0
  130. package/dist/organization-integration-policy.js +26 -0
  131. package/dist/organization-integration-policy.js.map +1 -0
  132. package/dist/pr-review-client.d.ts +1 -1
  133. package/dist/pr-review.d.ts +1 -1
  134. package/dist/pr-review.js.map +1 -1
  135. package/dist/preference-registry.d.ts +1 -1
  136. package/dist/prepared-mcp-setup.d.ts +5 -0
  137. package/dist/proxy.d.ts +13 -11
  138. package/dist/realtime.d.ts +1 -1
  139. package/dist/realtime.js +253 -7
  140. package/dist/realtime.js.map +1 -1
  141. package/dist/session-history-import.d.ts +22 -0
  142. package/dist/session-history-import.js +36 -0
  143. package/dist/session-history-import.js.map +1 -0
  144. package/dist/session-list-entries.d.ts +1 -0
  145. package/dist/session-list-entries.js +7 -0
  146. package/dist/session-list-entries.js.map +1 -0
  147. package/dist/session-message-search.d.ts +53 -0
  148. package/dist/session-proxy-client.d.ts +28 -0
  149. package/dist/session-proxy.d.ts +334 -0
  150. package/dist/session-proxy.js +24 -0
  151. package/dist/session-proxy.js.map +1 -0
  152. package/dist/session-titles.d.ts +2 -28
  153. package/dist/session-usage-limits.d.ts +10 -0
  154. package/dist/session-usage-limits.js +43 -0
  155. package/dist/session-usage-limits.js.map +1 -0
  156. package/dist/shared-catalog-loader.d.ts +34 -0
  157. package/dist/site-ai.d.ts +35 -0
  158. package/dist/site-bridge-host.d.ts +112 -0
  159. package/dist/site-bridge-host.js +286 -0
  160. package/dist/site-bridge-host.js.map +1 -0
  161. package/dist/site-browser-entry.d.ts +1 -0
  162. package/dist/site-browser-runtime.gen.d.ts +1 -0
  163. package/dist/site-data.d.ts +178 -0
  164. package/dist/site-document.d.ts +5 -0
  165. package/dist/site-document.js +20 -0
  166. package/dist/site-document.js.map +1 -0
  167. package/dist/site-document.test.d.ts +1 -0
  168. package/dist/site-http.d.ts +17 -0
  169. package/dist/site-sql.d.ts +31 -0
  170. package/dist/site-tool-bridge.d.ts +57 -0
  171. package/dist/site.d.ts +186 -0
  172. package/dist/site.js +63 -0
  173. package/dist/site.js.map +1 -0
  174. package/dist/skills.d.ts +75 -0
  175. package/dist/sse.d.ts +1 -1
  176. package/dist/stream.d.ts +2 -0
  177. package/dist/tenant-workspaces.d.ts +47 -0
  178. package/dist/tenant-workspaces.js +8 -0
  179. package/dist/tenant-workspaces.js.map +1 -0
  180. package/dist/tool-auth.d.ts +87 -0
  181. package/dist/tool-auth.js +23 -0
  182. package/dist/tool-auth.js.map +1 -0
  183. package/dist/tool-display-metadata.d.ts +3 -0
  184. package/dist/tools-37DCTCNZ.js +12 -0
  185. package/dist/tools-37DCTCNZ.js.map +1 -0
  186. package/dist/tools.d.ts +81 -0
  187. package/dist/transcription.d.ts +1 -1
  188. package/dist/types.d.ts +2807 -583
  189. package/dist/usage-allowances.d.ts +36 -0
  190. package/dist/usage-allowances.js +80 -0
  191. package/dist/usage-allowances.js.map +1 -0
  192. package/dist/vault-types.d.ts +324 -0
  193. package/dist/vaults-api.d.ts +65 -0
  194. package/dist/workspace-artifacts.d.ts +47 -5
  195. package/dist/workspace-instruction-policies.d.ts +2 -2
  196. package/dist/workspace-integrations.d.ts +74 -0
  197. package/dist/workspace-integrations.js +67 -0
  198. package/dist/workspace-integrations.js.map +1 -0
  199. package/dist/workspace-state.d.ts +8 -71
  200. package/package.json +103 -5
  201. package/src/adapters/express.ts +136 -0
  202. package/src/adapters/hono.ts +18 -0
  203. package/src/adapters/next.ts +42 -0
  204. package/src/allowance-refusal.ts +5 -0
  205. package/src/app-links.ts +117 -0
  206. package/src/artifact-catalog.ts +51 -0
  207. package/src/artifact-client.ts +40 -49
  208. package/src/artifacts.ts +1 -0
  209. package/src/automations-client.ts +8 -2
  210. package/src/azure-live-transport.ts +286 -0
  211. package/src/browser.ts +37 -0
  212. package/src/chat/fold.ts +431 -0
  213. package/src/chat/handler.ts +240 -0
  214. package/src/chat/http.ts +257 -0
  215. package/src/chat/ids.ts +85 -0
  216. package/src/chat/index.ts +88 -0
  217. package/src/chat/openai.ts +439 -0
  218. package/src/chat/opengeni.ts +737 -0
  219. package/src/chat/types.ts +219 -0
  220. package/src/chat/vercel.ts +204 -0
  221. package/src/chats.ts +16 -0
  222. package/src/client.ts +5697 -1833
  223. package/src/codex-realtime-controller.ts +163 -8
  224. package/src/codex-realtime-v3-wire.ts +4 -3
  225. package/src/codex-realtime-v3.ts +12 -3
  226. package/src/codex-realtime.ts +11 -3
  227. package/src/company-brain.ts +0 -40
  228. package/src/core.ts +20 -0
  229. package/src/deprecation.ts +149 -0
  230. package/src/document-authority-client.ts +104 -1
  231. package/src/editable-artifacts/controller.ts +36 -2
  232. package/src/editable-artifacts/index.ts +1 -0
  233. package/src/editable-artifacts/types.ts +29 -16
  234. package/src/embedding-client.ts +519 -0
  235. package/src/errors.ts +303 -4
  236. package/src/external-vault-receiver.ts +914 -0
  237. package/src/feedback.ts +20 -0
  238. package/src/gateway-realtime-transport.ts +3 -3
  239. package/src/github-repositories.ts +60 -0
  240. package/src/index.ts +603 -65
  241. package/src/insights-usage.ts +64 -0
  242. package/src/interaction.ts +315 -93
  243. package/src/knowledge.ts +72 -0
  244. package/src/known-tools.ts +279 -0
  245. package/src/message-links.ts +178 -0
  246. package/src/model-context.ts +113 -0
  247. package/src/model-display.ts +11 -0
  248. package/src/model-picker-order.ts +6 -0
  249. package/src/organization-integration-policy.ts +54 -0
  250. package/src/pr-review-client.ts +1 -1
  251. package/src/pr-review.ts +1 -1
  252. package/src/preference-registry.ts +2 -0
  253. package/src/prepared-mcp-setup.ts +123 -0
  254. package/src/proxy.ts +23 -12
  255. package/src/realtime.ts +15 -6
  256. package/src/session-history-import.ts +84 -0
  257. package/src/session-list-entries.ts +1 -0
  258. package/src/session-message-search.ts +47 -0
  259. package/src/session-proxy-client.ts +68 -0
  260. package/src/session-proxy.ts +2098 -0
  261. package/src/session-titles.ts +8 -82
  262. package/src/session-usage-limits.ts +71 -0
  263. package/src/shared-catalog-loader.ts +169 -0
  264. package/src/site-ai.ts +284 -0
  265. package/src/site-bridge-host.ts +422 -0
  266. package/src/site-browser-entry.ts +6 -0
  267. package/src/site-browser-runtime.gen.ts +2 -0
  268. package/src/site-data.ts +372 -0
  269. package/src/site-document.test.ts +64 -0
  270. package/src/site-document.ts +18 -0
  271. package/src/site-http.ts +171 -0
  272. package/src/site-sql.ts +153 -0
  273. package/src/site-tool-bridge.ts +401 -0
  274. package/src/site.ts +878 -0
  275. package/src/skills.ts +69 -0
  276. package/src/sse.ts +9 -3
  277. package/src/stream.ts +33 -10
  278. package/src/tenant-workspaces.ts +148 -0
  279. package/src/tool-auth.ts +301 -0
  280. package/src/tool-display-metadata.ts +27 -0
  281. package/src/tools.ts +452 -0
  282. package/src/transcription.ts +3 -0
  283. package/src/types.ts +3170 -582
  284. package/src/usage-allowances.ts +189 -0
  285. package/src/vault-types.ts +379 -0
  286. package/src/vaults-api.ts +339 -0
  287. package/src/workspace-artifacts.ts +55 -6
  288. package/src/workspace-instruction-policies.ts +2 -1
  289. package/src/workspace-integrations.ts +402 -0
  290. package/src/workspace-state.ts +8 -82
  291. package/dist/chunk-C2H7HBNP.js.map +0 -1
  292. package/dist/chunk-C4DJPZRU.js +0 -119
  293. package/dist/chunk-C4DJPZRU.js.map +0 -1
  294. package/dist/chunk-JUS2UYRP.js.map +0 -1
  295. package/dist/chunk-KKRO2VCP.js.map +0 -1
  296. package/dist/chunk-QT3KFVDP.js.map +0 -1
  297. package/dist/chunk-TRNI7KEO.js.map +0 -1
  298. package/dist/chunk-VYCTL62C.js.map +0 -1
  299. package/dist/chunk-YXQX7RQT.js.map +0 -1
@@ -0,0 +1,36 @@
1
+ // src/session-history-import.ts
2
+ function importArchivedSession(client, workspaceId, request) {
3
+ return client.requestJson(
4
+ "POST",
5
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/session-imports`,
6
+ request
7
+ );
8
+ }
9
+ function appendArchivedSessionEvents(client, workspaceId, importId, request) {
10
+ return client.requestJson(
11
+ "POST",
12
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/session-imports/${encodeURIComponent(importId)}/events`,
13
+ request
14
+ );
15
+ }
16
+ function importExternalWorkspaceArchivedSession(client, source, externalId, request) {
17
+ return client.requestJson(
18
+ "POST",
19
+ `/v1/workspaces/external/${encodeURIComponent(source)}/${encodeURIComponent(externalId)}/session-imports`,
20
+ request
21
+ );
22
+ }
23
+ function appendExternalWorkspaceArchivedSessionEvents(client, source, externalId, importId, request) {
24
+ return client.requestJson(
25
+ "POST",
26
+ `/v1/workspaces/external/${encodeURIComponent(source)}/${encodeURIComponent(externalId)}/session-imports/${encodeURIComponent(importId)}/events`,
27
+ request
28
+ );
29
+ }
30
+ export {
31
+ appendArchivedSessionEvents,
32
+ appendExternalWorkspaceArchivedSessionEvents,
33
+ importArchivedSession,
34
+ importExternalWorkspaceArchivedSession
35
+ };
36
+ //# sourceMappingURL=session-history-import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/session-history-import.ts"],"sourcesContent":["import type { OpenGeniClient } from \"./client\";\nimport type {\n AppendArchivedSessionEventsRequest,\n AppendArchivedSessionEventsResponse,\n ImportArchivedSessionRequest,\n ImportArchivedSessionResponse,\n} from \"@opengeni/contracts\";\n\nexport type {\n ArchivedSessionImportEvent,\n AppendArchivedSessionEventsRequest,\n AppendArchivedSessionEventsResponse,\n ImportArchivedSessionRequest,\n ImportArchivedSessionResponse,\n SessionImportedArchive,\n} from \"@opengeni/contracts\";\n\ntype SessionHistoryImportClient = Pick<OpenGeniClient, \"requestJson\">;\n\n/**\n * Server-only migration of a read-only archive, not model-facing conversation\n * history. Use an asUser client to preserve the verified creator/owner. Persist\n * importId and retry the exact request after an uncertain outcome.\n * Requires sessions:create in the authenticated actor's permissions.\n */\nexport function importArchivedSession(\n client: SessionHistoryImportClient,\n workspaceId: string,\n request: ImportArchivedSessionRequest,\n): Promise<ImportArchivedSessionResponse> {\n return client.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/session-imports`,\n request,\n );\n}\n\n/**\n * Append historical events at the acknowledged nextOffset. Retrying the exact\n * batchId, offset and events replays its receipt; conflicting reuse returns 409.\n * Each request accepts at most 100 events / 1 MiB, with 256 KiB per event.\n * Requires sessions:control and the same authenticated importer.\n */\nexport function appendArchivedSessionEvents(\n client: SessionHistoryImportClient,\n workspaceId: string,\n importId: string,\n request: AppendArchivedSessionEventsRequest,\n): Promise<AppendArchivedSessionEventsResponse> {\n return client.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/session-imports/${encodeURIComponent(importId)}/events`,\n request,\n );\n}\n\n/** Import through an existing external tenant mapping; this does not onboard it. */\nexport function importExternalWorkspaceArchivedSession(\n client: SessionHistoryImportClient,\n source: string,\n externalId: string,\n request: ImportArchivedSessionRequest,\n): Promise<ImportArchivedSessionResponse> {\n return client.requestJson(\n \"POST\",\n `/v1/workspaces/external/${encodeURIComponent(source)}/${encodeURIComponent(externalId)}/session-imports`,\n request,\n );\n}\n\n/** Append to an archive through the same external tenant mapping and actor. */\nexport function appendExternalWorkspaceArchivedSessionEvents(\n client: SessionHistoryImportClient,\n source: string,\n externalId: string,\n importId: string,\n request: AppendArchivedSessionEventsRequest,\n): Promise<AppendArchivedSessionEventsResponse> {\n return client.requestJson(\n \"POST\",\n `/v1/workspaces/external/${encodeURIComponent(source)}/${encodeURIComponent(externalId)}/session-imports/${encodeURIComponent(importId)}/events`,\n request,\n );\n}\n"],"mappings":";AAyBO,SAAS,sBACd,QACA,aACA,SACwC;AACxC,SAAO,OAAO;AAAA,IACZ;AAAA,IACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,IACjD;AAAA,EACF;AACF;AAQO,SAAS,4BACd,QACA,aACA,UACA,SAC8C;AAC9C,SAAO,OAAO;AAAA,IACZ;AAAA,IACA,kBAAkB,mBAAmB,WAAW,CAAC,oBAAoB,mBAAmB,QAAQ,CAAC;AAAA,IACjG;AAAA,EACF;AACF;AAGO,SAAS,uCACd,QACA,QACA,YACA,SACwC;AACxC,SAAO,OAAO;AAAA,IACZ;AAAA,IACA,2BAA2B,mBAAmB,MAAM,CAAC,IAAI,mBAAmB,UAAU,CAAC;AAAA,IACvF;AAAA,EACF;AACF;AAGO,SAAS,6CACd,QACA,QACA,YACA,UACA,SAC8C;AAC9C,SAAO,OAAO;AAAA,IACZ;AAAA,IACA,2BAA2B,mBAAmB,MAAM,CAAC,IAAI,mBAAmB,UAAU,CAAC,oBAAoB,mBAAmB,QAAQ,CAAC;AAAA,IACvI;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1 @@
1
+ export { sessionListEntry } from "@opengeni/contracts/session-list-entries";
@@ -0,0 +1,7 @@
1
+ import {
2
+ sessionListEntry
3
+ } from "./chunk-ZDUBPV33.js";
4
+ export {
5
+ sessionListEntry
6
+ };
7
+ //# sourceMappingURL=session-list-entries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,53 @@
1
+ /** Literal Unicode case-insensitive substring. Whitespace is significant. */
2
+ export type SessionMessageSearchRequest = {
3
+ query: string;
4
+ sessionId?: string | undefined;
5
+ /** Workspace-only first hit per session; cannot combine with sessionId. */
6
+ groupBy?: "session" | undefined;
7
+ archiveStatus?: "active" | "archived" | "all" | undefined;
8
+ limit?: number | undefined;
9
+ cursor?: string | undefined;
10
+ };
11
+ export type SessionMessageSearchMatch = {
12
+ sessionId: string;
13
+ sessionTitle: string | null;
14
+ eventId: string;
15
+ sequence: number;
16
+ turnId: string | null;
17
+ role: "user" | "assistant";
18
+ messageId: string | null;
19
+ /** Zero-based UTF-16 offset in the complete visible message. */
20
+ messageMatchOffset: number;
21
+ /** Zero-based UTF-16 offsets in text; matchEnd is exclusive. */
22
+ snippet: {
23
+ text: string;
24
+ matchStart: number;
25
+ matchEnd: number;
26
+ };
27
+ };
28
+ export type SessionMessageSearchResponse = {
29
+ matches: SessionMessageSearchMatch[];
30
+ nextCursor: string | null;
31
+ /** Empty advancing pages are valid. Continue until false. */
32
+ hasMore: boolean;
33
+ /** Cumulative distinct messages visited in this live traversal. */
34
+ scannedMessages: number;
35
+ /** Cumulative matching messages, or session representatives with groupBy=session. */
36
+ matchedMessageCount: number;
37
+ /** Cumulative occurrences, or session representatives with groupBy=session. */
38
+ matchedOccurrenceCount: number;
39
+ /** True only on exhaustion. Concurrent mutations require a fresh traversal. */
40
+ countIsExact: boolean;
41
+ };
42
+ /** Exact selected event reference from a search match; no payload fields are read. */
43
+ export type SessionMessagePreviewReference = {
44
+ eventId: string;
45
+ sequence: number;
46
+ };
47
+ /** A complete visible message, or an explicit over-12,000-UTF-16-unit result. */
48
+ export type SessionMessagePreview = {
49
+ status: "available";
50
+ text: string;
51
+ } | {
52
+ status: "unavailable";
53
+ };
@@ -0,0 +1,28 @@
1
+ import type { OpenGeniEmbeddingClient } from "./embedding-client.js";
2
+ import type { OpenGeniRequestOptions, FetchResponse } from "./client.js";
3
+ import type { AccessGrant } from "./types.js";
4
+ /** Maximum actual UTF-8 bytes forwarded for one embedded Site HTML response. */
5
+ export declare const SESSION_PROXY_SITE_HTML_MAX_BYTES: number;
6
+ /** A streaming Site download exceeded the host proxy's actual-byte ceiling. */
7
+ export declare class SessionProxySiteHtmlTooLargeError extends Error {
8
+ readonly code = "site_html_too_large";
9
+ readonly limitBytes: number;
10
+ constructor();
11
+ }
12
+ /** Server-only effective grant read; never derive external authority from access/me snapshots. */
13
+ export declare function getSessionProxyWorkspaceGrant(client: Pick<OpenGeniEmbeddingClient, "requestJson">, workspaceId: string, options?: OpenGeniRequestOptions): Promise<AccessGrant>;
14
+ /**
15
+ * Exact association read. The API reauthorizes the source session on every
16
+ * call. `retained` proves a generated image or video, or a published sandbox
17
+ * file, originated in that session.
18
+ */
19
+ export declare function getSessionProxyArtifactAssociation(client: Pick<OpenGeniEmbeddingClient, "requestJson">, workspaceId: string, sessionId: string, kind: "editable" | "site" | "retained", artifactId: string, options?: OpenGeniRequestOptions): Promise<{
20
+ sessionId: string;
21
+ artifactId: string;
22
+ kind: "editable" | "site" | "retained";
23
+ }>;
24
+ /** Authenticated response stream for the server proxy; does not buffer Site HTML. */
25
+ export declare function downloadSessionProxySiteHtml(client: Pick<OpenGeniEmbeddingClient, "requestJsonResponse">, workspaceId: string, artifactId: string, options: {
26
+ versionId: string;
27
+ signal?: AbortSignal;
28
+ }): Promise<FetchResponse>;
@@ -0,0 +1,334 @@
1
+ import type { OpenGeniEmbeddingClient } from "./embedding-client.js";
2
+ import { type Chats } from "./chats.js";
3
+ import type { WorkspaceIdOptions, WorkspaceIdTarget } from "./tenant-workspaces.js";
4
+ import type { CreateSessionRequest, FileResourceRef, LatencyMode, ReasoningEffort, SessionMcpCredentialUpdateInput } from "./types.js";
5
+ export { downloadSessionProxySiteHtml, getSessionProxyArtifactAssociation, getSessionProxyWorkspaceGrant, SESSION_PROXY_SITE_HTML_MAX_BYTES, SessionProxySiteHtmlTooLargeError, } from "./session-proxy-client.js";
6
+ /**
7
+ * Packaged same-origin backend for the React conversation surfaces.
8
+ *
9
+ * Mount the handler at a catch-all route (for example `/api/opengeni/*`) and
10
+ * point an unmodified browser `OpenGeniClient({ baseUrl: "/api/opengeni" })`
11
+ * at it. Every request is authenticated by the host's `resolve` hook, pinned
12
+ * to the resolved workspace, executed as the resolved external user through
13
+ * `asUser` (never the organization key's own service authority), and limited
14
+ * to the exact native routes `SessionConversation` and its hooks use. It is
15
+ * an explicit dispatcher, not an arbitrary upstream proxy.
16
+ */
17
+ type ProxyClient = OpenGeniEmbeddingClient;
18
+ /** The `@opengeni/sdk/chat` `Opengeni` facade, structurally. */
19
+ type ProxyFacade = {
20
+ readonly client: ProxyClient;
21
+ readonly source: string;
22
+ workspaceId(target: {
23
+ tenant: string;
24
+ }): Promise<string>;
25
+ workspaceIdFor?(target: WorkspaceIdTarget, options: WorkspaceIdOptions): Promise<string>;
26
+ };
27
+ /**
28
+ * Who the authenticated request acts as, in your own ids. Never derive any of
29
+ * it from the request body or path. `{ user, tenant }`: one workspace per
30
+ * tenant. `{ user }`: one workspace per user. `{ user, workspaceId }`: your
31
+ * own workspace. Tenant and per-user mapping require the `Opengeni` facade
32
+ * from `@opengeni/sdk/chat`; workspaces are created on first use and Opengeni
33
+ * adds the user on their first request.
34
+ */
35
+ export type SessionProxyResolution = ({
36
+ workspaceId: string;
37
+ tenant?: undefined;
38
+ } | {
39
+ tenant: string;
40
+ workspaceId?: undefined;
41
+ } | {
42
+ tenant?: undefined;
43
+ workspaceId?: undefined;
44
+ }) & {
45
+ /** Host-authenticated external user id; every call runs through `asUser(user)`. */
46
+ user: string;
47
+ /** External identity source. Defaults to the facade's `source`, else `"default"`. */
48
+ source?: string | undefined;
49
+ /**
50
+ * The user is an anonymous visitor your product has not signed in, for
51
+ * example a website visitor keyed by a cookie. Visitors cannot upload
52
+ * composer file attachments unless the handler sets `visitorUploads: true`;
53
+ * everything else is unchanged.
54
+ */
55
+ visitor?: boolean | undefined;
56
+ };
57
+ /** Host auth hook: return the resolution, or a `Response` (for example 401) to reject. */
58
+ export type SessionProxyResolve = (request: Request) => Promise<SessionProxyResolution | Response> | SessionProxyResolution | Response;
59
+ export type SessionProxyContext = {
60
+ request: Request;
61
+ workspaceId: string;
62
+ user: string;
63
+ source: string;
64
+ /** The `asUser` client the proxy uses for this request. */
65
+ client: ProxyClient;
66
+ };
67
+ /**
68
+ * The only fields a browser may send when creating a session through the proxy.
69
+ * After the `createSession` hook returns, the proxy adds the attached files to
70
+ * the created request (deduplicated by file id) and, when `modelSelection` is
71
+ * not `false`, applies the browser's explicit model choices over the hook's,
72
+ * exactly as follow-up messages carry them. Return a `Response` from the hook
73
+ * to refuse an input.
74
+ */
75
+ export type SessionProxyCreateInput = {
76
+ /** Empty for a voice-first session; no initial user message is fabricated. */
77
+ initialMessage: string;
78
+ /** Available only while the proxy permits realtime voice. */
79
+ startMode?: "realtime" | undefined;
80
+ /** Browser retry key; replay is scoped to the acting user by the API. */
81
+ idempotencyKey?: string | undefined;
82
+ /** Files attached to the first message (uploaded through this proxy). */
83
+ resources?: FileResourceRef[] | undefined;
84
+ /** The user's model choice; only when `modelSelection` is not `false`. */
85
+ model?: string | undefined;
86
+ /** The user's reasoning choice; only when `modelSelection` is not `false`. */
87
+ reasoningEffort?: ReasoningEffort | undefined;
88
+ /** The user's latency choice; only when `modelSelection` is not `false`. */
89
+ latencyMode?: LatencyMode | undefined;
90
+ };
91
+ /** Which browser action is about to forward a user message or response. */
92
+ export type SessionProxyMessageInput = {
93
+ /** Absent for `create`. */
94
+ sessionId?: string | undefined;
95
+ /** An empty voice-first session shell, not an initial model-producing turn. */
96
+ startMode?: "realtime" | undefined;
97
+ /**
98
+ * `realtime` is live voice: once when a call starts (refuse it, or rotate
99
+ * MCP credentials), and before each batch of finalized transcripts and spoken
100
+ * requests is saved (refuse it, or add `modelContext`).
101
+ */
102
+ delivery: "create" | "send" | "steer" | "submit" | "realtime";
103
+ };
104
+ /** Server-side additions the host attaches to one forwarded user message or response. */
105
+ export type SessionProxyMessageExtras = {
106
+ /**
107
+ * Model-visible context for this message (current page, time zone, today's
108
+ * date). Placed before any context the browser sent. Not secret. Ignored for
109
+ * approval decisions and human-input responses, which are not new messages,
110
+ * and when a live voice call starts. Keep it stable for the same message:
111
+ * a retried voice entry must carry the same context to be accepted.
112
+ */
113
+ modelContext?: string | undefined;
114
+ /**
115
+ * Header-only credential rotation for MCP servers already attached to the
116
+ * session (for example a fresh short-lived per-user bearer), applied
117
+ * atomically as the message or response is accepted. Ignored for `create`,
118
+ * where the `createSession` hook sets the initial headers.
119
+ */
120
+ mcpCredentialUpdates?: SessionMcpCredentialUpdateInput[] | undefined;
121
+ };
122
+ /**
123
+ * Your product's own MCP tool server, attached to every session this proxy
124
+ * creates with a per-user bearer token. Verify it on every MCP request with
125
+ * `verifyToolRequest` from `@opengeni/sdk/tool-auth`. Tools always act as the
126
+ * chat's creator: in a shared chat, other members' messages do not change it.
127
+ */
128
+ export type SessionProxyToolServer = {
129
+ /**
130
+ * Public HTTPS URL of your MCP endpoint, e.g. `https://app.example.com/api/mcp`.
131
+ * Defaults to `OPENGENI_TOOL_SERVER_URL`, which `verifyToolRequest` also reads.
132
+ */
133
+ url?: string | undefined;
134
+ /** Session MCP server id (model-facing tool prefix). Defaults to `"app"`. */
135
+ id?: string | undefined;
136
+ /** Display name. */
137
+ name?: string | undefined;
138
+ /**
139
+ * Tools the user must approve before each call: list your write tools here
140
+ * (unprefixed MCP tool names), or `true` for every tool. Others run directly.
141
+ */
142
+ approvals?: {
143
+ ask: string[] | true;
144
+ } | undefined;
145
+ /** Token signing secret. Defaults to `OPENGENI_API_KEY`; `verifyToolRequest` must use the same. */
146
+ secret?: string | undefined;
147
+ /** Token lifetime in seconds. Defaults to 24 hours; refreshed on every message, approval, and answer. */
148
+ ttlSeconds?: number | undefined;
149
+ };
150
+ export type SessionProxyHandlerOptions = {
151
+ /**
152
+ * Private (default) uses personal Knowledge and session-only reach; shared uses
153
+ * workspace Knowledge and reach. Isolated also gives each user their own tenant workspace.
154
+ */
155
+ chats?: Chats | undefined;
156
+ /** Mandatory host auth hook, called on every request. */
157
+ resolve: SessionProxyResolve;
158
+ /**
159
+ * Host CSRF/session policy for non-GET requests. Without it the proxy only
160
+ * rejects `Sec-Fetch-Site: cross-site` mutations and requires JSON bodies;
161
+ * cookie-authenticated hosts should supply their existing CSRF check.
162
+ */
163
+ authorizeMutation?: ((request: Request) => boolean | Promise<boolean>) | undefined;
164
+ /**
165
+ * Optional product-level session check (for example "this ticket's session
166
+ * belongs to this user"). Opengeni still enforces membership and private
167
+ * visibility on every call.
168
+ */
169
+ authorizeSession?: ((sessionId: string, context: SessionProxyContext) => boolean | Promise<boolean>) | undefined;
170
+ /**
171
+ * Server-controlled session creation. The browser supplies only
172
+ * {@link SessionProxyCreateInput}; this hook returns the complete create
173
+ * request (agent, tools, MCP servers, Skills, instructions, model policy). Omit it
174
+ * to disable browser-initiated creation entirely.
175
+ */
176
+ createSession?: ((input: SessionProxyCreateInput, context: SessionProxyContext) => CreateSessionRequest | Response | Promise<CreateSessionRequest | Response>) | undefined;
177
+ /**
178
+ * Called before every forwarded user message (send, steer, composer submit,
179
+ * and browser-started create), approval decision, human-input response, and
180
+ * live voice start and transcript save (`delivery: "realtime"`).
181
+ * Return server-owned `modelContext` (messages and voice transcripts only)
182
+ * and MCP credential rotations, or a `Response` to reject the action.
183
+ */
184
+ beforeForwardMessage?: ((input: SessionProxyMessageInput, context: SessionProxyContext) => SessionProxyMessageExtras | Response | undefined | Promise<SessionProxyMessageExtras | Response | undefined>) | undefined;
185
+ /**
186
+ * Attach your product's MCP tool server to every session the `createSession`
187
+ * hook creates, authenticated as the resolved user. The proxy mints the
188
+ * token, adds the `mcpServers` entry (plus an eager ref when the hook lists
189
+ * explicit `tools`), and rotates the token on every send, steer, submit,
190
+ * approval decision, and human-input answer.
191
+ */
192
+ toolServer?: SessionProxyToolServer | undefined;
193
+ /** Mount prefix, e.g. `/api/opengeni`. Defaults to everything before the first `/v1/`. */
194
+ basePath?: string | undefined;
195
+ /** Maximum JSON request body. Defaults to 1 MiB. */
196
+ maxBodyBytes?: number | undefined;
197
+ /**
198
+ * Expose composer file attachments (upload begin/complete, download URL) and
199
+ * the media agents produce in a session: generated images, browser and
200
+ * computer screenshots, published sandbox files, and generated video
201
+ * playback. Workspace-level artifact reads must name their session in the
202
+ * `x-opengeni-session-id` header (`SessionConversation` does this); the proxy
203
+ * runs `authorizeSession` and only forwards an artifact Opengeni proves that
204
+ * session produced. Defaults to true.
205
+ */
206
+ files?: boolean | undefined;
207
+ /**
208
+ * Let anonymous visitors (`resolve` returned `visitor: true`) upload composer
209
+ * file attachments. Defaults to false: for a visitor the client config reports
210
+ * file uploads off, so stock UIs hide the attach button, and the upload routes
211
+ * are refused. Agent-produced media stays readable under `files`. Signed-in
212
+ * users follow `files` alone.
213
+ */
214
+ visitorUploads?: boolean | undefined;
215
+ /**
216
+ * Forward composer voice input (`POST .../transcriptions`, one recording per
217
+ * request) as the resolved user; Opengeni still requires that user's
218
+ * `sessions:create` permission and the workspace's voice-input setting.
219
+ * `false` reports voice input unavailable in the client config so stock UIs
220
+ * hide the microphone. Defaults to true.
221
+ */
222
+ voiceInput?: boolean | undefined;
223
+ /**
224
+ * Forward live speech-to-speech voice for existing chats as the resolved
225
+ * user: the voice model catalog and the call lifecycle routes under
226
+ * `.../sessions/{id}/realtime`. Opengeni still requires that user's
227
+ * `sessions:control` permission, binds the call to that user and browser,
228
+ * runs spoken requests as ordinary steers of the chat, and meters
229
+ * deployment-funded voice against the organization's credits. Defaults to
230
+ * true. The stock conversation's voice button is opt-in: explicit `true`
231
+ * reports `realtimeVoice: true` in the client config so `SessionConversation`
232
+ * and `OpenGeniChat` show it (when a voice model is available), as does their
233
+ * own `realtimeVoice` prop. `false` reports `realtimeVoice: false` so stock
234
+ * UIs hide it, and refuses the routes.
235
+ */
236
+ realtimeVoice?: boolean | undefined;
237
+ /**
238
+ * Let the browser read a file from the session's sandbox (`POST .../fs/read`)
239
+ * so `sandbox:` links in agent replies can be downloaded. Only `path`,
240
+ * `encoding`, and `maxBytes` are forwarded; Opengeni still requires the
241
+ * user's `files:read` permission on that session. Explicit opt-in, default
242
+ * false. Reads are confined to its working directory, including on Connected
243
+ * Machines; symlinked paths are refused.
244
+ */
245
+ sandboxFiles?: boolean | undefined;
246
+ /**
247
+ * Serve the embedded artifact viewer and inline Site previews: reads of the
248
+ * editable artifacts and Sites a session produced, and live-ticket minting
249
+ * for the editor. Explicit opt-in, default false.
250
+ *
251
+ * Every request must name its session in the `x-opengeni-session-id` header
252
+ * (`SessionArtifactViewer` and `SessionConversation` do this). The proxy
253
+ * runs `authorizeSession`, then only forwards an artifact Opengeni associates with
254
+ * that session, so the browser cannot open other workspace artifacts through
255
+ * it. Editing still requires the user's own `artifacts:publish` grant. Site
256
+ * tool calls are not proxied.
257
+ *
258
+ * The editor's live socket is ticket-authenticated and connects to Opengeni
259
+ * directly; the ticket binds the source session and the API revalidates its
260
+ * authority while connected. `editableLiveUrl` overrides the derived URL.
261
+ * Site HTML streams with backpressure and cancellation, with a 25 MiB
262
+ * actual-byte ceiling (`SESSION_PROXY_SITE_HTML_MAX_BYTES`). Oversize streams
263
+ * fail with `SessionProxySiteHtmlTooLargeError` / `site_html_too_large`;
264
+ * headers cannot be replaced once streaming has begun.
265
+ */
266
+ artifacts?: boolean | {
267
+ editableLiveUrl?: string | undefined;
268
+ } | undefined;
269
+ /**
270
+ * Read the workspace's Sites without naming a session: list, detail,
271
+ * content and HTML of published artifacts the signed-in user may read, for
272
+ * pages that belong to the workspace rather than to one chat (for example a
273
+ * page several sessions keep up to date, shown with `SiteDetail`). Read-only:
274
+ * publishing, rollback and status changes stay closed. Requests that send
275
+ * `x-opengeni-session-id` keep the session-scoped `artifacts` checks.
276
+ * Explicit opt-in, default false.
277
+ */
278
+ sites?: boolean | undefined;
279
+ /**
280
+ * Chat list for `SessionList` / `OpenGeniChat` (`listSessionPage` only).
281
+ * `"mine"` (default) lists sessions the resolved user created; `"visible"`
282
+ * lists every session Opengeni lets that user read in the workspace (shared
283
+ * chats included); `false` disables listing.
284
+ */
285
+ sessionList?: "mine" | "visible" | false | undefined;
286
+ /** Let the user archive or restore their own chats. Defaults to true. */
287
+ archive?: boolean | undefined;
288
+ /**
289
+ * Let the browser choose model, reasoning effort, and latency per message,
290
+ * draft, or new chat (still limited by the workspace model catalog). When
291
+ * false those choices are removed from messages and draft saves, and refused
292
+ * on create. Saves use the actor's
293
+ * server-owned draft policy (initially the session defaults). Submit must repeat
294
+ * the saved policy unchanged as an integrity fence, not a new selection: the
295
+ * API atomically checks the saved revision/content or replays the original
296
+ * receipt. Hide the composer's model picker to match. Defaults to true.
297
+ * Pass `true` explicitly to also show end users the stock model picker
298
+ * (`SessionConversation`/`OpenGeniChat` hide it unless asked). The picker
299
+ * lists the workspace's model catalog, so the workspace's allowed-model
300
+ * settings decide which models end users see.
301
+ */
302
+ modelSelection?: boolean | undefined;
303
+ /**
304
+ * SSE heartbeat interval. Defaults to 5 seconds, under Bun.serve's default
305
+ * 10-second `idleTimeout`, which otherwise closes a quiet event stream.
306
+ */
307
+ heartbeatMs?: number | undefined;
308
+ };
309
+ /**
310
+ * Create the packaged session proxy. Returns a web-standard
311
+ * `(Request) => Promise<Response>` for Next.js route handlers, Hono, Bun.serve,
312
+ * Cloudflare Workers, and similar hosts.
313
+ */
314
+ export declare function createSessionProxyHandler(target: ProxyClient | ProxyFacade, options: SessionProxyHandlerOptions): (request: Request) => Promise<Response>;
315
+ /**
316
+ * The client-config `artifacts` capability a custom host proxy reports so
317
+ * `SessionArtifactViewer` can open editable artifacts: the live socket URL
318
+ * (ticket-authenticated, reached directly) and the proxied user's browser cache
319
+ * partition. `client` acts as that user (for example `asUser(...)`).
320
+ */
321
+ export declare function artifactViewerCapability(input: {
322
+ client: Pick<ProxyClient, "getAccessContext" | "apiUrl"> & Partial<Pick<ProxyClient, "requestJson">>;
323
+ workspaceId: string;
324
+ /** Stable namespace of the host's user identities, mixed into the partition. */
325
+ source?: string | undefined;
326
+ editableLiveUrl?: string | undefined;
327
+ }): Promise<{
328
+ editableLiveUrl: string;
329
+ cachePartition: {
330
+ accountId: string;
331
+ principalId: string;
332
+ authorizationEpoch: string;
333
+ };
334
+ }>;
@@ -0,0 +1,24 @@
1
+ import {
2
+ SESSION_PROXY_SITE_HTML_MAX_BYTES,
3
+ SessionProxySiteHtmlTooLargeError,
4
+ artifactViewerCapability,
5
+ createSessionProxyHandler,
6
+ downloadSessionProxySiteHtml,
7
+ getSessionProxyArtifactAssociation,
8
+ getSessionProxyWorkspaceGrant
9
+ } from "./chunk-FTWVVPR6.js";
10
+ import "./chunk-UM4ZXXJR.js";
11
+ import "./chunk-QGEIL4TR.js";
12
+ import "./chunk-4AHR4KGA.js";
13
+ import "./chunk-NCU5OAN7.js";
14
+ import "./chunk-7EWT3PV6.js";
15
+ export {
16
+ SESSION_PROXY_SITE_HTML_MAX_BYTES,
17
+ SessionProxySiteHtmlTooLargeError,
18
+ artifactViewerCapability,
19
+ createSessionProxyHandler,
20
+ downloadSessionProxySiteHtml,
21
+ getSessionProxyArtifactAssociation,
22
+ getSessionProxyWorkspaceGrant
23
+ };
24
+ //# sourceMappingURL=session-proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,28 +1,2 @@
1
- import { AUTOMATIC_SESSION_TITLE_FALLBACK } from "@opengeni/contracts/session-titles";
2
- import type { Session } from "./types.js";
3
- export { AUTOMATIC_SESSION_TITLE_FALLBACK };
4
- export type SessionDisplayTitleInput = {
5
- title?: Session["title"] | undefined;
6
- titleSource?: Session["titleSource"] | undefined;
7
- initialMessage?: Session["initialMessage"] | null | undefined;
8
- metadata?: Readonly<Record<string, unknown>> | undefined;
9
- };
10
- export type SessionDisplayTitleOptions = {
11
- /** Optional metadata fields to try before the opening-prompt preview. */
12
- metadataKeys?: readonly string[] | undefined;
13
- };
14
- /**
15
- * Whether the durable title still represents the automatic-title pending state.
16
- * A user-authored title always wins, even when its literal value is the fallback.
17
- */
18
- export declare function sessionTitleIsPending(input: SessionDisplayTitleInput): boolean;
19
- /**
20
- * Derive the title a client should display for a session.
21
- *
22
- * A semantic agent title or human rename wins. While automatic naming is still
23
- * pending, clients show a short, sensitive-safe preview of the opening prompt;
24
- * the preview is never persisted as title metadata and is replaced naturally
25
- * when `session.title_set` arrives. Obvious credential-, URL-, or identifier-
26
- * shaped prompt prefixes retain the generic fallback.
27
- */
28
- export declare function deriveSessionDisplayTitle(input: SessionDisplayTitleInput, options?: SessionDisplayTitleOptions): string;
1
+ export { AUTOMATIC_SESSION_TITLE_FALLBACK, deriveAutomaticSessionTitlePreview, deriveSessionDisplayTitle, sessionTitleIsPending, } from "@opengeni/contracts/session-titles";
2
+ export type { SessionDisplayTitleInput, SessionDisplayTitleOptions, } from "@opengeni/contracts/session-titles";
@@ -0,0 +1,10 @@
1
+ import type { OpenGeniClient, OpenGeniRequestOptions } from "./client.js";
2
+ import type { SessionUsageLimit, SetSessionUsageLimitRequest } from "@opengeni/contracts/session-usage-limits";
3
+ export type { SessionUsageLimit, SessionUsageLimitHistory, SessionUsageLimitReachedRefusal, SessionUsageLimitStatus, SetSessionUsageLimitRequest, } from "@opengeni/contracts/session-usage-limits";
4
+ export { formatSessionUsageMicros, parseSessionUsageLimitReachedRefusal, SESSION_USAGE_LIMIT_GOAL_PAUSED_REASON, SESSION_USAGE_LIMIT_SEGMENT, sessionUsageLimitReachedMessage, } from "@opengeni/contracts/session-usage-limit-refusal";
5
+ export type { ParsedSessionUsageLimitReachedRefusal } from "@opengeni/contracts/session-usage-limit-refusal";
6
+ type RequestJsonClient = Pick<OpenGeniClient, "requestJson">;
7
+ /** Read a task's usage limit state (a child returns its root's, `inherited: true`). */
8
+ export declare function getSessionUsageLimit(client: RequestJsonClient, workspaceId: string, sessionId: string, options?: OpenGeniRequestOptions): Promise<SessionUsageLimit>;
9
+ /** Compare-and-set a root task's limit; `limitMicros: null` clears it. Never resumes work. */
10
+ export declare function setSessionUsageLimit(client: RequestJsonClient, workspaceId: string, sessionId: string, request: SetSessionUsageLimitRequest): Promise<SessionUsageLimit>;
@@ -0,0 +1,43 @@
1
+ import {
2
+ SESSION_USAGE_LIMIT_GOAL_PAUSED_REASON,
3
+ SESSION_USAGE_LIMIT_SEGMENT,
4
+ formatSessionUsageMicros,
5
+ parseSessionUsageLimitReachedRefusal,
6
+ sessionUsageLimitNotConfirmed,
7
+ sessionUsageLimitReachedMessage
8
+ } from "./chunk-7EWT3PV6.js";
9
+
10
+ // src/session-usage-limits.ts
11
+ function usageLimitPath(workspaceId, sessionId) {
12
+ return `/v1/workspaces/${encodeURIComponent(workspaceId)}/sessions/${encodeURIComponent(sessionId)}/usage-limit`;
13
+ }
14
+ async function getSessionUsageLimit(client, workspaceId, sessionId, options = {}) {
15
+ return await client.requestJson(
16
+ "GET",
17
+ usageLimitPath(workspaceId, sessionId),
18
+ void 0,
19
+ {},
20
+ options
21
+ );
22
+ }
23
+ async function setSessionUsageLimit(client, workspaceId, sessionId, request) {
24
+ const committed = await client.requestJson(
25
+ "PUT",
26
+ usageLimitPath(workspaceId, sessionId),
27
+ request
28
+ );
29
+ if (committed.limitMicros !== request.limitMicros) {
30
+ throw sessionUsageLimitNotConfirmed(sessionId);
31
+ }
32
+ return committed;
33
+ }
34
+ export {
35
+ SESSION_USAGE_LIMIT_GOAL_PAUSED_REASON,
36
+ SESSION_USAGE_LIMIT_SEGMENT,
37
+ formatSessionUsageMicros,
38
+ getSessionUsageLimit,
39
+ parseSessionUsageLimitReachedRefusal,
40
+ sessionUsageLimitReachedMessage,
41
+ setSessionUsageLimit
42
+ };
43
+ //# sourceMappingURL=session-usage-limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/session-usage-limits.ts"],"sourcesContent":["// @opengeni/sdk/session-usage-limits — per-task usage limit helpers that are\n// safe in browsers and React Native. Reads and writes use the root client's\n// `getSessionUsageLimit` / `setSessionUsageLimit`, or these free functions over\n// any client's `requestJson`.\n//\n// Amounts are integer USD micros of API-equivalent model usage (the\n// pre-margin provider list-price estimate), not your bill. The limit is\n// checked before each new model request: requests already running can take\n// recorded usage above it. See docs/session-usage-limits.md.\nimport type { OpenGeniClient, OpenGeniRequestOptions } from \"./client\";\nimport { sessionUsageLimitNotConfirmed } from \"./errors\";\nimport type {\n SessionUsageLimit,\n SetSessionUsageLimitRequest,\n} from \"@opengeni/contracts/session-usage-limits\";\n\nexport type {\n SessionUsageLimit,\n SessionUsageLimitHistory,\n SessionUsageLimitReachedRefusal,\n SessionUsageLimitStatus,\n SetSessionUsageLimitRequest,\n} from \"@opengeni/contracts/session-usage-limits\";\nexport {\n formatSessionUsageMicros,\n parseSessionUsageLimitReachedRefusal,\n SESSION_USAGE_LIMIT_GOAL_PAUSED_REASON,\n SESSION_USAGE_LIMIT_SEGMENT,\n sessionUsageLimitReachedMessage,\n} from \"@opengeni/contracts/session-usage-limit-refusal\";\nexport type { ParsedSessionUsageLimitReachedRefusal } from \"@opengeni/contracts/session-usage-limit-refusal\";\n\ntype RequestJsonClient = Pick<OpenGeniClient, \"requestJson\">;\n\nfunction usageLimitPath(workspaceId: string, sessionId: string): string {\n return `/v1/workspaces/${encodeURIComponent(workspaceId)}/sessions/${encodeURIComponent(sessionId)}/usage-limit`;\n}\n\n/** Read a task's usage limit state (a child returns its root's, `inherited: true`). */\nexport async function getSessionUsageLimit(\n client: RequestJsonClient,\n workspaceId: string,\n sessionId: string,\n options: OpenGeniRequestOptions = {},\n): Promise<SessionUsageLimit> {\n return await client.requestJson<SessionUsageLimit>(\n \"GET\",\n usageLimitPath(workspaceId, sessionId),\n undefined,\n {},\n options,\n );\n}\n\n/** Compare-and-set a root task's limit; `limitMicros: null` clears it. Never resumes work. */\nexport async function setSessionUsageLimit(\n client: RequestJsonClient,\n workspaceId: string,\n sessionId: string,\n request: SetSessionUsageLimitRequest,\n): Promise<SessionUsageLimit> {\n const committed = await client.requestJson<SessionUsageLimit>(\n \"PUT\",\n usageLimitPath(workspaceId, sessionId),\n request,\n );\n if (committed.limitMicros !== request.limitMicros) {\n throw sessionUsageLimitNotConfirmed(sessionId);\n }\n return committed;\n}\n"],"mappings":";;;;;;;;;;AAkCA,SAAS,eAAe,aAAqB,WAA2B;AACtE,SAAO,kBAAkB,mBAAmB,WAAW,CAAC,aAAa,mBAAmB,SAAS,CAAC;AACpG;AAGA,eAAsB,qBACpB,QACA,aACA,WACA,UAAkC,CAAC,GACP;AAC5B,SAAO,MAAM,OAAO;AAAA,IAClB;AAAA,IACA,eAAe,aAAa,SAAS;AAAA,IACrC;AAAA,IACA,CAAC;AAAA,IACD;AAAA,EACF;AACF;AAGA,eAAsB,qBACpB,QACA,aACA,WACA,SAC4B;AAC5B,QAAM,YAAY,MAAM,OAAO;AAAA,IAC7B;AAAA,IACA,eAAe,aAAa,SAAS;AAAA,IACrC;AAAA,EACF;AACA,MAAI,UAAU,gBAAgB,QAAQ,aAAa;AACjD,UAAM,8BAA8B,SAAS;AAAA,EAC/C;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Single-flight loader for one digest-pinned tool catalog.
3
+ *
4
+ * - Concurrent cold callers share one request instead of each fetching.
5
+ * - A waiter's AbortSignal cancels only its own wait. The shared request is
6
+ * cancelled once every waiter has aborted, and the next caller then starts
7
+ * a new request. A waiter without a signal keeps the shared request alive
8
+ * for every joiner until it settles (bounded by transport/server timeouts).
9
+ * - A failed load is never cached; the next caller starts a new request.
10
+ * - An explicit refresh, or a stale rejection, always obtains a catalog from a
11
+ * request started after that refresh/rejection. Callers rejected on the same
12
+ * stale digest share one post-rejection request while it is still current.
13
+ * - A load started before an invalidation never overwrites the newer state.
14
+ */
15
+ export type SharedCatalogLoader<T extends {
16
+ digest: string;
17
+ }> = {
18
+ load(options?: {
19
+ refresh?: boolean;
20
+ signal?: AbortSignal;
21
+ }): Promise<T>;
22
+ /** Reload after the server rejected `staleDigest` as a stale catalog. */
23
+ reloadAfterStale(staleDigest: string, signal?: AbortSignal): Promise<T>;
24
+ /** Drop the cached catalog when it is `digest`, without fetching. */
25
+ invalidate(digest: string): void;
26
+ };
27
+ export declare function createSharedCatalogLoader<T extends {
28
+ digest: string;
29
+ }>(
30
+ /**
31
+ * `refresh` is true when this load follows an invalidation or explicit
32
+ * refresh. `signal` aborts only when every waiter has abandoned the load.
33
+ */
34
+ fetchCatalog: (refresh: boolean, signal: AbortSignal) => Promise<T>): SharedCatalogLoader<T>;