@opengeni/sdk 0.52.1 → 1.0.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 (300) hide show
  1. package/README.md +1078 -33
  2. package/dist/accounts.d.ts +153 -0
  3. package/dist/accounts.js +307 -0
  4. package/dist/accounts.js.map +1 -0
  5. package/dist/adapters/express.d.ts +31 -0
  6. package/dist/adapters/express.js +87 -0
  7. package/dist/adapters/express.js.map +1 -0
  8. package/dist/adapters/hono.d.ts +16 -0
  9. package/dist/adapters/hono.js +8 -0
  10. package/dist/adapters/hono.js.map +1 -0
  11. package/dist/adapters/next.d.ts +29 -0
  12. package/dist/adapters/next.js +22 -0
  13. package/dist/adapters/next.js.map +1 -0
  14. package/dist/allowance-refusal.d.ts +2 -0
  15. package/dist/allowance-refusal.js +50 -0
  16. package/dist/allowance-refusal.js.map +1 -0
  17. package/dist/artifact-catalog.d.ts +31 -0
  18. package/dist/artifact-client.d.ts +23 -11
  19. package/dist/artifacts.d.ts +1 -1
  20. package/dist/artifacts.js +7 -5
  21. package/dist/automations-client.d.ts +17 -0
  22. package/dist/automations.d.ts +3 -0
  23. package/dist/automations.js +84 -0
  24. package/dist/automations.js.map +1 -0
  25. package/dist/browser.d.ts +11 -0
  26. package/dist/browser.js +47 -0
  27. package/dist/browser.js.map +1 -0
  28. package/dist/chat/fold.d.ts +75 -0
  29. package/dist/chat/handler.d.ts +41 -0
  30. package/dist/chat/http.d.ts +67 -0
  31. package/dist/chat/ids.d.ts +34 -0
  32. package/dist/chat/index.d.ts +9 -0
  33. package/dist/chat/index.js +1694 -0
  34. package/dist/chat/index.js.map +1 -0
  35. package/dist/chat/openai.d.ts +30 -0
  36. package/dist/chat/opengeni.d.ts +128 -0
  37. package/dist/chat/types.d.ts +207 -0
  38. package/dist/chat/vercel.d.ts +49 -0
  39. package/dist/chats.d.ts +8 -0
  40. package/dist/{chunk-KIHGPM7H.js → chunk-2UXZUCEZ.js} +309 -46
  41. package/dist/chunk-2UXZUCEZ.js.map +1 -0
  42. package/dist/chunk-4SMEOV3P.js +246 -0
  43. package/dist/chunk-4SMEOV3P.js.map +1 -0
  44. package/dist/{chunk-FHI4DFIG.js → chunk-AH5D5Q5V.js} +31 -35
  45. package/dist/chunk-AH5D5Q5V.js.map +1 -0
  46. package/dist/chunk-APXVSSSY.js +301 -0
  47. package/dist/chunk-APXVSSSY.js.map +1 -0
  48. package/dist/chunk-DUVIYER4.js +639 -0
  49. package/dist/chunk-DUVIYER4.js.map +1 -0
  50. package/dist/{chunk-ILQZR5N6.js → chunk-FG3OO5LM.js} +3484 -750
  51. package/dist/chunk-FG3OO5LM.js.map +1 -0
  52. package/dist/chunk-GZYZT22T.js +260 -0
  53. package/dist/chunk-GZYZT22T.js.map +1 -0
  54. package/dist/chunk-HMGADJGZ.js +150 -0
  55. package/dist/chunk-HMGADJGZ.js.map +1 -0
  56. package/dist/{chunk-DXDL7EEW.js → chunk-KWADQ227.js} +198 -114
  57. package/dist/chunk-KWADQ227.js.map +1 -0
  58. package/dist/chunk-LY2K6ELJ.js +126 -0
  59. package/dist/chunk-LY2K6ELJ.js.map +1 -0
  60. package/dist/chunk-MOTJYIYL.js +340 -0
  61. package/dist/chunk-MOTJYIYL.js.map +1 -0
  62. package/dist/{chunk-MZWTWOX6.js → chunk-NC57YMUO.js} +447 -3
  63. package/dist/chunk-NC57YMUO.js.map +1 -0
  64. package/dist/chunk-RWKB6YZG.js +1270 -0
  65. package/dist/chunk-RWKB6YZG.js.map +1 -0
  66. package/dist/chunk-U6CV2SXO.js +195 -0
  67. package/dist/chunk-U6CV2SXO.js.map +1 -0
  68. package/dist/chunk-UM4ZXXJR.js +9 -0
  69. package/dist/chunk-UM4ZXXJR.js.map +1 -0
  70. package/dist/chunk-V6GIY62B.js +229 -0
  71. package/dist/chunk-V6GIY62B.js.map +1 -0
  72. package/dist/chunk-WU6GQG25.js +268 -0
  73. package/dist/chunk-WU6GQG25.js.map +1 -0
  74. package/dist/{chunk-VWE2QIVO.js → chunk-XNG7YGR3.js} +23 -6
  75. package/dist/chunk-XNG7YGR3.js.map +1 -0
  76. package/dist/{chunk-FRJFNDIR.js → chunk-YIKA2QT4.js} +37 -2
  77. package/dist/chunk-YIKA2QT4.js.map +1 -0
  78. package/dist/chunk-ZKPY6YAJ.js +135 -0
  79. package/dist/chunk-ZKPY6YAJ.js.map +1 -0
  80. package/dist/client.d.ts +843 -107
  81. package/dist/codex-realtime-controller.d.ts +6 -0
  82. package/dist/codex-realtime-controller.js +2 -2
  83. package/dist/codex-realtime-v3.d.ts +13 -2
  84. package/dist/company-brain.d.ts +22 -0
  85. package/dist/company-profile.d.ts +14 -1
  86. package/dist/core.d.ts +9 -3
  87. package/dist/core.js +28 -9
  88. package/dist/deprecation.d.ts +47 -0
  89. package/dist/desktop.d.ts +8 -0
  90. package/dist/document-authority-client.d.ts +51 -0
  91. package/dist/document-authority.d.ts +2 -0
  92. package/dist/document-authority.js +12 -0
  93. package/dist/document-authority.js.map +1 -0
  94. package/dist/editable-artifacts/browser-session.d.ts +7 -3
  95. package/dist/editable-artifacts/controller.d.ts +4 -1
  96. package/dist/editable-artifacts/errors.d.ts +1 -1
  97. package/dist/editable-artifacts/http-live-transport.d.ts +6 -2
  98. package/dist/editable-artifacts/index.d.ts +2 -0
  99. package/dist/editable-artifacts/open-failure.d.ts +9 -0
  100. package/dist/editable-artifacts/types.d.ts +6 -3
  101. package/dist/editable-artifacts/worker/kernel-adapter.d.ts +1 -1
  102. package/dist/editable-artifacts-worker.js +44 -17
  103. package/dist/editable-artifacts-worker.js.map +1 -1
  104. package/dist/editable-artifacts.js +243 -124
  105. package/dist/editable-artifacts.js.map +1 -1
  106. package/dist/embedding-client.d.ts +129 -0
  107. package/dist/errors.d.ts +36 -1
  108. package/dist/feedback.d.ts +23 -0
  109. package/dist/gateway-realtime-transport.d.ts +1 -0
  110. package/dist/gateway-realtime-transport.js +5 -3
  111. package/dist/github-repositories.d.ts +10 -0
  112. package/dist/github-repositories.js +36 -0
  113. package/dist/github-repositories.js.map +1 -0
  114. package/dist/index.d.ts +61 -12
  115. package/dist/index.js +277 -126
  116. package/dist/index.js.map +1 -1
  117. package/dist/interaction-revision-stream.d.ts +11 -0
  118. package/dist/interaction.d.ts +687 -5
  119. package/dist/interaction.js +32 -1
  120. package/dist/knowledge.d.ts +7 -0
  121. package/dist/knowledge.js +20 -0
  122. package/dist/knowledge.js.map +1 -0
  123. package/dist/message-links.d.ts +68 -0
  124. package/dist/model-context.d.ts +68 -0
  125. package/dist/model-display.d.ts +2 -0
  126. package/dist/model-display.js +15 -0
  127. package/dist/model-display.js.map +1 -0
  128. package/dist/model-picker-order.d.ts +1 -0
  129. package/dist/model-picker-order.js +10 -0
  130. package/dist/model-picker-order.js.map +1 -0
  131. package/dist/organization-integration-policy.d.ts +26 -0
  132. package/dist/organization-integration-policy.js +26 -0
  133. package/dist/organization-integration-policy.js.map +1 -0
  134. package/dist/organization-private-session-settings.d.ts +6 -0
  135. package/dist/organization-private-session-settings.js +22 -0
  136. package/dist/organization-private-session-settings.js.map +1 -0
  137. package/dist/organization-user-setup.d.ts +8 -0
  138. package/dist/organization-user-setup.js +16 -0
  139. package/dist/organization-user-setup.js.map +1 -0
  140. package/dist/pr-review-client.d.ts +16 -0
  141. package/dist/pr-review.d.ts +4 -0
  142. package/dist/pr-review.js +62 -0
  143. package/dist/pr-review.js.map +1 -0
  144. package/dist/preference-registry.d.ts +9 -1
  145. package/dist/proxy.d.ts +7 -5
  146. package/dist/realtime.d.ts +6 -4
  147. package/dist/realtime.js +10 -6
  148. package/dist/realtime.js.map +1 -1
  149. package/dist/retained-artifacts.d.ts +5 -1
  150. package/dist/session-history-import.d.ts +22 -0
  151. package/dist/session-history-import.js +36 -0
  152. package/dist/session-history-import.js.map +1 -0
  153. package/dist/session-list-entries.d.ts +1 -0
  154. package/dist/session-list-entries.js +7 -0
  155. package/dist/session-list-entries.js.map +1 -0
  156. package/dist/session-message-search.d.ts +53 -0
  157. package/dist/session-proxy-client.d.ts +24 -0
  158. package/dist/session-proxy.d.ts +245 -0
  159. package/dist/session-proxy.js +24 -0
  160. package/dist/session-proxy.js.map +1 -0
  161. package/dist/session-titles.d.ts +2 -0
  162. package/dist/site-browser-entry.d.ts +1 -0
  163. package/dist/site-browser-runtime.gen.d.ts +1 -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 +16 -0
  169. package/dist/site-tool-bridge.d.ts +44 -0
  170. package/dist/site.d.ts +101 -0
  171. package/dist/site.js +49 -0
  172. package/dist/site.js.map +1 -0
  173. package/dist/skills.d.ts +75 -0
  174. package/dist/stream.d.ts +2 -0
  175. package/dist/tenant-workspaces.d.ts +47 -0
  176. package/dist/tenant-workspaces.js +8 -0
  177. package/dist/tenant-workspaces.js.map +1 -0
  178. package/dist/tool-auth.d.ts +87 -0
  179. package/dist/tool-auth.js +23 -0
  180. package/dist/tool-auth.js.map +1 -0
  181. package/dist/tool-display-metadata.d.ts +3 -0
  182. package/dist/tools-FXBLUWAE.js +12 -0
  183. package/dist/tools-FXBLUWAE.js.map +1 -0
  184. package/dist/tools.d.ts +61 -0
  185. package/dist/types.d.ts +3048 -406
  186. package/dist/usage-allowances.d.ts +36 -0
  187. package/dist/usage-allowances.js +80 -0
  188. package/dist/usage-allowances.js.map +1 -0
  189. package/dist/workspace-artifacts.d.ts +33 -5
  190. package/dist/workspace-instruction-policies.d.ts +24 -2
  191. package/dist/workspace-integrations.d.ts +74 -0
  192. package/dist/workspace-integrations.js +65 -0
  193. package/dist/workspace-integrations.js.map +1 -0
  194. package/dist/workspace-learning.d.ts +124 -0
  195. package/dist/workspace-live-stream.d.ts +14 -0
  196. package/dist/workspace-state.d.ts +8 -71
  197. package/package.json +108 -3
  198. package/src/accounts.ts +443 -0
  199. package/src/adapters/express.ts +136 -0
  200. package/src/adapters/hono.ts +18 -0
  201. package/src/adapters/next.ts +42 -0
  202. package/src/allowance-refusal.ts +5 -0
  203. package/src/artifact-catalog.ts +41 -0
  204. package/src/artifact-client.ts +43 -52
  205. package/src/artifacts.ts +7 -1
  206. package/src/automations-client.ts +124 -0
  207. package/src/automations.ts +15 -0
  208. package/src/browser.ts +54 -0
  209. package/src/chat/fold.ts +431 -0
  210. package/src/chat/handler.ts +240 -0
  211. package/src/chat/http.ts +257 -0
  212. package/src/chat/ids.ts +85 -0
  213. package/src/chat/index.ts +87 -0
  214. package/src/chat/openai.ts +439 -0
  215. package/src/chat/opengeni.ts +722 -0
  216. package/src/chat/types.ts +219 -0
  217. package/src/chat/vercel.ts +204 -0
  218. package/src/chats.ts +16 -0
  219. package/src/client.ts +5162 -792
  220. package/src/codex-realtime-controller.ts +260 -12
  221. package/src/codex-realtime-lifecycle.ts +1 -0
  222. package/src/codex-realtime-v3.ts +162 -31
  223. package/src/codex-realtime.ts +1 -1
  224. package/src/company-brain.ts +59 -0
  225. package/src/company-profile.ts +17 -1
  226. package/src/core.ts +23 -1
  227. package/src/deprecation.ts +149 -0
  228. package/src/desktop.ts +11 -1
  229. package/src/document-authority-client.ts +219 -0
  230. package/src/document-authority.ts +17 -0
  231. package/src/editable-artifacts/browser-session.ts +36 -22
  232. package/src/editable-artifacts/controller.ts +102 -47
  233. package/src/editable-artifacts/errors.ts +2 -0
  234. package/src/editable-artifacts/http-live-transport.ts +62 -37
  235. package/src/editable-artifacts/index.ts +6 -0
  236. package/src/editable-artifacts/open-failure.ts +79 -0
  237. package/src/editable-artifacts/storage.ts +31 -40
  238. package/src/editable-artifacts/types.ts +6 -3
  239. package/src/editable-artifacts/worker/kernel-adapter.ts +23 -7
  240. package/src/editable-artifacts/worker/runtime.ts +26 -13
  241. package/src/editable-artifacts/worker/wire-codec.ts +23 -5
  242. package/src/embedding-client.ts +519 -0
  243. package/src/errors.ts +185 -4
  244. package/src/feedback.ts +20 -0
  245. package/src/gateway-realtime-transport.ts +253 -110
  246. package/src/github-repositories.ts +60 -0
  247. package/src/index.ts +603 -54
  248. package/src/interaction-revision-stream.ts +117 -0
  249. package/src/interaction.ts +1367 -51
  250. package/src/knowledge.ts +72 -0
  251. package/src/message-links.ts +178 -0
  252. package/src/model-context.ts +112 -0
  253. package/src/model-display.ts +10 -0
  254. package/src/model-picker-order.ts +6 -0
  255. package/src/organization-integration-policy.ts +54 -0
  256. package/src/organization-private-session-settings.ts +33 -0
  257. package/src/organization-user-setup.ts +31 -0
  258. package/src/pr-review-client.ts +92 -0
  259. package/src/pr-review.ts +17 -0
  260. package/src/preference-registry.ts +11 -0
  261. package/src/proxy.ts +17 -6
  262. package/src/realtime.ts +15 -4
  263. package/src/retained-artifacts.ts +101 -0
  264. package/src/session-history-import.ts +84 -0
  265. package/src/session-list-entries.ts +1 -0
  266. package/src/session-message-search.ts +47 -0
  267. package/src/session-proxy-client.ts +64 -0
  268. package/src/session-proxy.ts +1473 -0
  269. package/src/session-titles.ts +10 -0
  270. package/src/site-browser-entry.ts +6 -0
  271. package/src/site-browser-runtime.gen.ts +2 -0
  272. package/src/site-document.test.ts +64 -0
  273. package/src/site-document.ts +18 -0
  274. package/src/site-http.ts +162 -0
  275. package/src/site-tool-bridge.ts +146 -0
  276. package/src/site.ts +585 -0
  277. package/src/skills.ts +69 -0
  278. package/src/sse.ts +8 -2
  279. package/src/stream.ts +38 -4
  280. package/src/tenant-workspaces.ts +148 -0
  281. package/src/tool-auth.ts +301 -0
  282. package/src/tool-display-metadata.ts +19 -0
  283. package/src/tools.ts +396 -0
  284. package/src/types.ts +3607 -493
  285. package/src/usage-allowances.ts +189 -0
  286. package/src/workspace-artifacts.ts +40 -6
  287. package/src/workspace-instruction-policies.ts +26 -1
  288. package/src/workspace-integrations.ts +402 -0
  289. package/src/workspace-learning.ts +138 -0
  290. package/src/workspace-live-stream.ts +137 -0
  291. package/src/workspace-state.ts +8 -82
  292. package/dist/chunk-DXDL7EEW.js.map +0 -1
  293. package/dist/chunk-FHI4DFIG.js.map +0 -1
  294. package/dist/chunk-FRJFNDIR.js.map +0 -1
  295. package/dist/chunk-ILQZR5N6.js.map +0 -1
  296. package/dist/chunk-KIHGPM7H.js.map +0 -1
  297. package/dist/chunk-MZWTWOX6.js.map +0 -1
  298. package/dist/chunk-V5F253OG.js +0 -116
  299. package/dist/chunk-V5F253OG.js.map +0 -1
  300. package/dist/chunk-VWE2QIVO.js.map +0 -1
@@ -0,0 +1,16 @@
1
+ /** Any web-standard handler: `createSessionProxyHandler`, `createChatHandler`, or your own. */
2
+ export type WebHandler = (request: Request) => Promise<Response>;
3
+ /** The part of Hono's context this adapter uses (no Hono dependency). */
4
+ export type HonoContextLike = {
5
+ req: {
6
+ raw: Request;
7
+ };
8
+ };
9
+ /**
10
+ * Expose a web-standard handler as a Hono handler:
11
+ *
12
+ * ```ts
13
+ * app.all("/api/opengeni/*", toHonoHandler(handler));
14
+ * ```
15
+ */
16
+ export declare function toHonoHandler(handler: WebHandler): (context: HonoContextLike) => Promise<Response>;
@@ -0,0 +1,8 @@
1
+ // src/adapters/hono.ts
2
+ function toHonoHandler(handler) {
3
+ return async (context) => await handler(context.req.raw);
4
+ }
5
+ export {
6
+ toHonoHandler
7
+ };
8
+ //# sourceMappingURL=hono.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/hono.ts"],"sourcesContent":["/** Any web-standard handler: `createSessionProxyHandler`, `createChatHandler`, or your own. */\nexport type WebHandler = (request: Request) => Promise<Response>;\n\n/** The part of Hono's context this adapter uses (no Hono dependency). */\nexport type HonoContextLike = { req: { raw: Request } };\n\n/**\n * Expose a web-standard handler as a Hono handler:\n *\n * ```ts\n * app.all(\"/api/opengeni/*\", toHonoHandler(handler));\n * ```\n */\nexport function toHonoHandler(\n handler: WebHandler,\n): (context: HonoContextLike) => Promise<Response> {\n return async (context) => await handler(context.req.raw);\n}\n"],"mappings":";AAaO,SAAS,cACd,SACiD;AACjD,SAAO,OAAO,YAAY,MAAM,QAAQ,QAAQ,IAAI,GAAG;AACzD;","names":[]}
@@ -0,0 +1,29 @@
1
+ import { createSessionProxyHandler, type SessionProxyHandlerOptions } from "../session-proxy.js";
2
+ /** Any web-standard handler: `createSessionProxyHandler`, `createChatHandler`, or your own. */
3
+ export type WebHandler = (request: Request) => Promise<Response>;
4
+ /** Route handlers for a Next.js App Router catch-all route. */
5
+ export type NextRouteHandlers = {
6
+ GET: WebHandler;
7
+ POST: WebHandler;
8
+ PUT: WebHandler;
9
+ PATCH: WebHandler;
10
+ DELETE: WebHandler;
11
+ };
12
+ /**
13
+ * Expose a web-standard handler as Next.js App Router route handlers.
14
+ *
15
+ * ```ts
16
+ * // app/api/opengeni/[...path]/route.ts
17
+ * export const dynamic = "force-dynamic";
18
+ * export const { GET, POST, PUT, PATCH, DELETE } = toNextRouteHandlers(handler);
19
+ * ```
20
+ *
21
+ * Next passes the full request URL (including any `basePath`), so the proxy's
22
+ * own `/v1/` detection routes it; responses, including SSE, stream as-is.
23
+ */
24
+ export declare function toNextRouteHandlers(handler: WebHandler): NextRouteHandlers;
25
+ /**
26
+ * `createSessionProxyHandler` as Next.js App Router route handlers, for
27
+ * `app/<mount>/[...path]/route.ts`.
28
+ */
29
+ export declare function createSessionProxyRoute(target: Parameters<typeof createSessionProxyHandler>[0], options: SessionProxyHandlerOptions): NextRouteHandlers;
@@ -0,0 +1,22 @@
1
+ import {
2
+ createSessionProxyHandler
3
+ } from "../chunk-RWKB6YZG.js";
4
+ import "../chunk-UM4ZXXJR.js";
5
+ import "../chunk-U6CV2SXO.js";
6
+ import "../chunk-APXVSSSY.js";
7
+ import "../chunk-YIKA2QT4.js";
8
+ import "../chunk-V6GIY62B.js";
9
+
10
+ // src/adapters/next.ts
11
+ function toNextRouteHandlers(handler) {
12
+ const route = async (request) => await handler(request);
13
+ return { GET: route, POST: route, PUT: route, PATCH: route, DELETE: route };
14
+ }
15
+ function createSessionProxyRoute(target, options) {
16
+ return toNextRouteHandlers(createSessionProxyHandler(target, options));
17
+ }
18
+ export {
19
+ createSessionProxyRoute,
20
+ toNextRouteHandlers
21
+ };
22
+ //# sourceMappingURL=next.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/next.ts"],"sourcesContent":["import { createSessionProxyHandler, type SessionProxyHandlerOptions } from \"../session-proxy\";\n\n/** Any web-standard handler: `createSessionProxyHandler`, `createChatHandler`, or your own. */\nexport type WebHandler = (request: Request) => Promise<Response>;\n\n/** Route handlers for a Next.js App Router catch-all route. */\nexport type NextRouteHandlers = {\n GET: WebHandler;\n POST: WebHandler;\n PUT: WebHandler;\n PATCH: WebHandler;\n DELETE: WebHandler;\n};\n\n/**\n * Expose a web-standard handler as Next.js App Router route handlers.\n *\n * ```ts\n * // app/api/opengeni/[...path]/route.ts\n * export const dynamic = \"force-dynamic\";\n * export const { GET, POST, PUT, PATCH, DELETE } = toNextRouteHandlers(handler);\n * ```\n *\n * Next passes the full request URL (including any `basePath`), so the proxy's\n * own `/v1/` detection routes it; responses, including SSE, stream as-is.\n */\nexport function toNextRouteHandlers(handler: WebHandler): NextRouteHandlers {\n // Next calls route handlers with (request, context); only the request matters.\n const route: WebHandler = async (request) => await handler(request);\n return { GET: route, POST: route, PUT: route, PATCH: route, DELETE: route };\n}\n\n/**\n * `createSessionProxyHandler` as Next.js App Router route handlers, for\n * `app/<mount>/[...path]/route.ts`.\n */\nexport function createSessionProxyRoute(\n target: Parameters<typeof createSessionProxyHandler>[0],\n options: SessionProxyHandlerOptions,\n): NextRouteHandlers {\n return toNextRouteHandlers(createSessionProxyHandler(target, options));\n}\n"],"mappings":";;;;;;;;;;AA0BO,SAAS,oBAAoB,SAAwC;AAE1E,QAAM,QAAoB,OAAO,YAAY,MAAM,QAAQ,OAAO;AAClE,SAAO,EAAE,KAAK,OAAO,MAAM,OAAO,KAAK,OAAO,OAAO,OAAO,QAAQ,MAAM;AAC5E;AAMO,SAAS,wBACd,QACA,SACmB;AACnB,SAAO,oBAAoB,0BAA0B,QAAQ,OAAO,CAAC;AACvE;","names":[]}
@@ -0,0 +1,2 @@
1
+ /** Browser-safe allowance presentation without exposing the server core. */
2
+ export { allowanceExhaustedMessage, parseAllowanceExhaustedRefusal, } from "@opengeni/contracts/allowance-refusal";
@@ -0,0 +1,50 @@
1
+ // ../contracts/src/allowance-refusal.ts
2
+ var MESSAGE_MAX_UTF8_BYTES = 1024;
3
+ function record(value) {
4
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
5
+ }
6
+ function resetTimestamp(value) {
7
+ if (value === null) return true;
8
+ if (typeof value !== "string" || value.length > 64) return false;
9
+ const parts = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])T(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/.exec(
10
+ value
11
+ );
12
+ if (!parts || !Number.isFinite(Date.parse(value))) return false;
13
+ const year = Number(parts[1]);
14
+ const month = Number(parts[2]);
15
+ const day = Number(parts[3]);
16
+ const leapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
17
+ const days = [31, leapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
18
+ return day <= days[month - 1];
19
+ }
20
+ function parseAllowanceExhaustedRefusal(value) {
21
+ const source = record(value);
22
+ if (source?.code !== "allowance_exhausted") return null;
23
+ const fields = record(source.details) ?? source;
24
+ const scope = fields.scope;
25
+ const subjectId = scope === "member" ? fields.subjectId : void 0;
26
+ if (typeof source.message !== "string" || scope !== "workspace" && scope !== "member" || !resetTimestamp(fields.resetsAt) || subjectId !== void 0 && (typeof subjectId !== "string" || subjectId.length === 0 || subjectId.length > 1024 || subjectId.includes("\0"))) {
27
+ return null;
28
+ }
29
+ const normalized = source.message.slice(0, MESSAGE_MAX_UTF8_BYTES * 2).replace(/[\u0000-\u001f\u007f]+/g, " ").trim();
30
+ const bytes = new TextEncoder().encode(normalized.slice(0, MESSAGE_MAX_UTF8_BYTES * 2));
31
+ let end = Math.min(bytes.length, MESSAGE_MAX_UTF8_BYTES);
32
+ while (end > 0 && end < bytes.length && (bytes[end] & 192) === 128) end -= 1;
33
+ return {
34
+ code: "allowance_exhausted",
35
+ scope,
36
+ resetsAt: fields.resetsAt,
37
+ ...typeof subjectId === "string" ? { subjectId } : {},
38
+ message: new TextDecoder().decode(bytes.slice(0, end)).trim()
39
+ };
40
+ }
41
+ function allowanceExhaustedMessage(refusal) {
42
+ const remedy = refusal.scope === "workspace" ? "The workspace usage allowance is exhausted. An organization administrator or a full-access organization API key can raise the workspace ceiling or add an allowance grant." : "The member usage allowance is exhausted. A workspace administrator or a full-access organization API key can adjust the member ceiling.";
43
+ const reset = refusal.resetsAt === null ? "This allowance has no automatic reset." : `It resets at ${new Date(refusal.resetsAt).toISOString().slice(0, 16).replace("T", " ")} UTC.`;
44
+ return `${remedy} ${reset}`;
45
+ }
46
+ export {
47
+ allowanceExhaustedMessage,
48
+ parseAllowanceExhaustedRefusal
49
+ };
50
+ //# sourceMappingURL=allowance-refusal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../contracts/src/allowance-refusal.ts"],"sourcesContent":["import type { AllowanceExhaustedRefusal } from \"./usage-allowances\";\n\nconst MESSAGE_MAX_UTF8_BYTES = 1_024;\n\nfunction record(value: unknown): Record<string, unknown> | null {\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : null;\n}\n\n/** Mirror the canonical offset datetime's calendar/time bounds without loading\n * the schema runtime into synchronous browser/React Native session projection.\n * Contract-parity tests guard this deliberately small, bounded wire leaf.\n */\nfunction resetTimestamp(value: unknown): value is string | null {\n if (value === null) return true;\n if (typeof value !== \"string\" || value.length > 64) return false;\n const parts =\n /^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])T(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|[+-](?:[01]\\d|2[0-3]):[0-5]\\d)$/.exec(\n value,\n );\n if (!parts || !Number.isFinite(Date.parse(value))) return false;\n const year = Number(parts[1]);\n const month = Number(parts[2]);\n const day = Number(parts[3]);\n const leapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n const days = [31, leapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n return day <= days[month - 1]!;\n}\n\n/** Select only public refusal fields, including from an API error's details.\n * LimitDecision's allowed:false and transport/SQL diagnostics never cross out.\n */\nexport function parseAllowanceExhaustedRefusal(value: unknown): AllowanceExhaustedRefusal | null {\n const source = record(value);\n if (source?.code !== \"allowance_exhausted\") return null;\n const fields = record(source.details) ?? source;\n const scope = fields.scope;\n const subjectId = scope === \"member\" ? fields.subjectId : undefined;\n if (\n typeof source.message !== \"string\" ||\n (scope !== \"workspace\" && scope !== \"member\") ||\n !resetTimestamp(fields.resetsAt) ||\n (subjectId !== undefined &&\n (typeof subjectId !== \"string\" ||\n subjectId.length === 0 ||\n subjectId.length > 1_024 ||\n subjectId.includes(\"\\0\")))\n ) {\n return null;\n }\n const normalized = source.message\n .slice(0, MESSAGE_MAX_UTF8_BYTES * 2)\n .replace(/[\\u0000-\\u001f\\u007f]+/g, \" \")\n .trim();\n const bytes = new TextEncoder().encode(normalized.slice(0, MESSAGE_MAX_UTF8_BYTES * 2));\n let end = Math.min(bytes.length, MESSAGE_MAX_UTF8_BYTES);\n while (end > 0 && end < bytes.length && (bytes[end]! & 0xc0) === 0x80) end -= 1;\n return {\n code: \"allowance_exhausted\",\n scope,\n resetsAt: fields.resetsAt,\n ...(typeof subjectId === \"string\" ? { subjectId } : {}),\n message: new TextDecoder().decode(bytes.slice(0, end)).trim(),\n };\n}\n\n/** Bounded, fixed remedies: a ceiling is not an exhausted billing source.\n * Never interpolate arbitrary exception prose or a member identifier.\n */\nexport function allowanceExhaustedMessage(refusal: AllowanceExhaustedRefusal): string {\n const remedy =\n refusal.scope === \"workspace\"\n ? \"The workspace usage allowance is exhausted. An organization administrator or a full-access organization API key can raise the workspace ceiling or add an allowance grant.\"\n : \"The member usage allowance is exhausted. A workspace administrator or a full-access organization API key can adjust the member ceiling.\";\n const reset =\n refusal.resetsAt === null\n ? \"This allowance has no automatic reset.\"\n : `It resets at ${new Date(refusal.resetsAt).toISOString().slice(0, 16).replace(\"T\", \" \")} UTC.`;\n return `${remedy} ${reset}`;\n}\n"],"mappings":";AAEA,IAAM,yBAAyB;AAE/B,SAAS,OAAO,OAAgD;AAC9D,SAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IACrE,QACD;AACN;AAMA,SAAS,eAAe,OAAwC;AAC9D,MAAI,UAAU,KAAM,QAAO;AAC3B,MAAI,OAAO,UAAU,YAAY,MAAM,SAAS,GAAI,QAAO;AAC3D,QAAM,QACJ,sIAAsI;AAAA,IACpI;AAAA,EACF;AACF,MAAI,CAAC,SAAS,CAAC,OAAO,SAAS,KAAK,MAAM,KAAK,CAAC,EAAG,QAAO;AAC1D,QAAM,OAAO,OAAO,MAAM,CAAC,CAAC;AAC5B,QAAM,QAAQ,OAAO,MAAM,CAAC,CAAC;AAC7B,QAAM,MAAM,OAAO,MAAM,CAAC,CAAC;AAC3B,QAAM,WAAW,OAAO,MAAM,MAAM,OAAO,QAAQ,KAAK,OAAO,QAAQ;AACvE,QAAM,OAAO,CAAC,IAAI,WAAW,KAAK,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;AAC5E,SAAO,OAAO,KAAK,QAAQ,CAAC;AAC9B;AAKO,SAAS,+BAA+B,OAAkD;AAC/F,QAAM,SAAS,OAAO,KAAK;AAC3B,MAAI,QAAQ,SAAS,sBAAuB,QAAO;AACnD,QAAM,SAAS,OAAO,OAAO,OAAO,KAAK;AACzC,QAAM,QAAQ,OAAO;AACrB,QAAM,YAAY,UAAU,WAAW,OAAO,YAAY;AAC1D,MACE,OAAO,OAAO,YAAY,YACzB,UAAU,eAAe,UAAU,YACpC,CAAC,eAAe,OAAO,QAAQ,KAC9B,cAAc,WACZ,OAAO,cAAc,YACpB,UAAU,WAAW,KACrB,UAAU,SAAS,QACnB,UAAU,SAAS,IAAI,IAC3B;AACA,WAAO;AAAA,EACT;AACA,QAAM,aAAa,OAAO,QACvB,MAAM,GAAG,yBAAyB,CAAC,EACnC,QAAQ,2BAA2B,GAAG,EACtC,KAAK;AACR,QAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,WAAW,MAAM,GAAG,yBAAyB,CAAC,CAAC;AACtF,MAAI,MAAM,KAAK,IAAI,MAAM,QAAQ,sBAAsB;AACvD,SAAO,MAAM,KAAK,MAAM,MAAM,WAAW,MAAM,GAAG,IAAK,SAAU,IAAM,QAAO;AAC9E,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,UAAU,OAAO;AAAA,IACjB,GAAI,OAAO,cAAc,WAAW,EAAE,UAAU,IAAI,CAAC;AAAA,IACrD,SAAS,IAAI,YAAY,EAAE,OAAO,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,KAAK;AAAA,EAC9D;AACF;AAKO,SAAS,0BAA0B,SAA4C;AACpF,QAAM,SACJ,QAAQ,UAAU,cACd,+KACA;AACN,QAAM,QACJ,QAAQ,aAAa,OACjB,2CACA,gBAAgB,IAAI,KAAK,QAAQ,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,KAAK,GAAG,CAAC;AAC7F,SAAO,GAAG,MAAM,IAAI,KAAK;AAC3B;","names":[]}
@@ -0,0 +1,31 @@
1
+ import type { RetainedArtifactReference } from "./types.js";
2
+ export type ArtifactCatalogKind = "site" | "document" | "spreadsheet" | "presentation" | "image" | "file";
3
+ /** Native IDs are unique within a kind; use `${kind}:${id}` as a UI key. */
4
+ export type ArtifactCatalogItem = {
5
+ id: string;
6
+ kind: ArtifactCatalogKind;
7
+ title: string;
8
+ createdAt: string;
9
+ updatedAt: string;
10
+ status: "active" | "archived";
11
+ /** Present only when the viewer can read this session. */
12
+ sourceSessionId?: string;
13
+ versionId?: string;
14
+ file?: RetainedArtifactReference;
15
+ filename?: string;
16
+ contentType?: string;
17
+ sizeBytes?: number;
18
+ };
19
+ export type ArtifactCatalogListOptions = {
20
+ sourceSessionId?: string;
21
+ q?: string;
22
+ kind?: ArtifactCatalogKind;
23
+ sort?: "updated" | "newest" | "title";
24
+ status?: "active" | "archived";
25
+ limit?: number;
26
+ cursor?: string;
27
+ };
28
+ export type ArtifactCatalogListResponse = {
29
+ items: ArtifactCatalogItem[];
30
+ nextCursor: string | null;
31
+ };
@@ -1,8 +1,11 @@
1
- import { OpenGeniClient as OpenGeniCoreClient } from "./client.js";
1
+ import { OpenGeniDocumentAuthorityClient } from "./document-authority-client.js";
2
+ import type { FetchResponse } from "./client.js";
3
+ import type { SiteToolCallRequest } from "./site-tool-bridge.js";
4
+ import type { ToolGatewayCallResponse } from "./types.js";
5
+ import type { CreateWorkspaceArtifactRequest, PublishWorkspaceArtifactVersionRequest, WorkspaceArtifactContentResponse, WorkspaceArtifactMutationResponse } from "./workspace-artifacts.js";
2
6
  import type { CreateEditableArtifactMaterializationRequest, CreateEditableArtifactResourceRequest, EditableArtifactListResource, EditableArtifactMaterializationJobResource, EditableArtifactPinnedVersionResource, EditableArtifactResource, ImportEditableArtifactResourceRequest, ListSessionEditableArtifactResourcesOptions, PinEditableArtifactVersionRequest, ReadEditableArtifactMaterializationOptions, ReadEditableArtifactResourceOptions } from "./editable-artifact-resources.js";
3
- import type { CreateWorkspaceArtifactRequest, PublishWorkspaceArtifactVersionRequest, RollbackWorkspaceArtifactRequest, WorkspaceArtifactContentResponse, WorkspaceArtifactDetailResponse, WorkspaceArtifactListOptions, WorkspaceArtifactListResponse, WorkspaceArtifactMutationResponse } from "./workspace-artifacts.js";
4
- /** Public SDK client. Artifact operations stay out of the console's eager core graph. */
5
- export declare class OpenGeniClient extends OpenGeniCoreClient {
7
+ /** Public SDK client. Optional operator and artifact operations stay out of the console core. */
8
+ export declare class OpenGeniClient extends OpenGeniDocumentAuthorityClient {
6
9
  createEditableArtifact(workspaceId: string, request: CreateEditableArtifactResourceRequest, options?: Readonly<{
7
10
  signal?: AbortSignal | undefined;
8
11
  }>): Promise<EditableArtifactResource>;
@@ -19,11 +22,20 @@ export declare class OpenGeniClient extends OpenGeniCoreClient {
19
22
  }>): Promise<EditableArtifactMaterializationJobResource>;
20
23
  getEditableArtifactMaterialization(workspaceId: string, artifactId: string, jobId: string, options: ReadEditableArtifactMaterializationOptions): Promise<EditableArtifactMaterializationJobResource>;
21
24
  /** The caller owns the returned bounded response stream. */
22
- downloadEditableArtifactMaterialization(workspaceId: string, artifactId: string, jobId: string, options: ReadEditableArtifactMaterializationOptions): Promise<Response>;
23
- listWorkspaceArtifacts(workspaceId: string, options?: WorkspaceArtifactListOptions): Promise<WorkspaceArtifactListResponse>;
24
- getWorkspaceArtifact(workspaceId: string, artifactId: string): Promise<WorkspaceArtifactDetailResponse>;
25
- getWorkspaceArtifactContent(workspaceId: string, artifactId: string, versionId?: string): Promise<WorkspaceArtifactContentResponse>;
26
- createWorkspaceArtifact(workspaceId: string, request: CreateWorkspaceArtifactRequest): Promise<WorkspaceArtifactMutationResponse>;
27
- publishWorkspaceArtifactVersion(workspaceId: string, artifactId: string, request: PublishWorkspaceArtifactVersionRequest): Promise<WorkspaceArtifactMutationResponse>;
28
- rollbackWorkspaceArtifact(workspaceId: string, artifactId: string, request: RollbackWorkspaceArtifactRequest): Promise<WorkspaceArtifactMutationResponse>;
25
+ downloadEditableArtifactMaterialization(workspaceId: string, artifactId: string, jobId: string, options: ReadEditableArtifactMaterializationOptions): Promise<FetchResponse>;
26
+ /** Exact Site-version gateway call. Keep this client on the authenticated host;
27
+ * the API enforces live viewer access and the version's declared tool allowlist. */
28
+ callWorkspaceSiteTool(workspaceId: string, request: SiteToolCallRequest, options?: {
29
+ signal?: AbortSignal;
30
+ }): Promise<ToolGatewayCallResponse>;
31
+ getWorkspaceArtifactContent(workspaceId: string, artifactId: string, versionOrOptions?: string | {
32
+ versionId?: string;
33
+ signal?: AbortSignal;
34
+ }): Promise<WorkspaceArtifactContentResponse>;
35
+ createWorkspaceArtifact(workspaceId: string, request: CreateWorkspaceArtifactRequest, options?: {
36
+ signal?: AbortSignal;
37
+ }): Promise<WorkspaceArtifactMutationResponse>;
38
+ publishWorkspaceArtifactVersion(workspaceId: string, artifactId: string, request: PublishWorkspaceArtifactVersionRequest, options?: {
39
+ signal?: AbortSignal;
40
+ }): Promise<WorkspaceArtifactMutationResponse>;
29
41
  }
@@ -1,4 +1,4 @@
1
1
  /** Artifact-only API client entry; keeps unrelated SDK surfaces out of editor bundles. */
2
2
  export { OpenGeniClient } from "./artifact-client.js";
3
3
  export type { CreateEditableArtifactMaterializationRequest, CreateEditableArtifactResourceRequest, EditableArtifactListResource, EditableArtifactMaterializationFormat, EditableArtifactMaterializationJobResource, EditableArtifactMaterializationResultResource, EditableArtifactPinnedVersionResource, EditableArtifactResource, ListSessionEditableArtifactResourcesOptions, PinEditableArtifactVersionRequest, ReadEditableArtifactMaterializationOptions, ReadEditableArtifactResourceOptions, } from "./editable-artifact-resources.js";
4
- export type { FetchLike, OpenGeniClientOptions, OpenGeniRequestOptions } from "./client.js";
4
+ export type { FetchLike, FetchResponse, GetSessionOptions, OpenGeniClientOptions, OpenGeniRequestOptions, } from "./client.js";
package/dist/artifacts.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  OpenGeniClient
3
- } from "./chunk-FHI4DFIG.js";
4
- import "./chunk-ILQZR5N6.js";
5
- import "./chunk-V5F253OG.js";
6
- import "./chunk-MZWTWOX6.js";
7
- import "./chunk-FRJFNDIR.js";
3
+ } from "./chunk-AH5D5Q5V.js";
4
+ import "./chunk-HMGADJGZ.js";
5
+ import "./chunk-FG3OO5LM.js";
6
+ import "./chunk-APXVSSSY.js";
7
+ import "./chunk-YIKA2QT4.js";
8
+ import "./chunk-NC57YMUO.js";
9
+ import "./chunk-V6GIY62B.js";
8
10
  export {
9
11
  OpenGeniClient
10
12
  };
@@ -0,0 +1,17 @@
1
+ import type { AutomationRun, AutomationSource, AutomationTrigger, AutomationWebhookResult, CreateAutomationSourceRequest, CreateAutomationTriggerRequest, TriggerAutomationManuallyRequest, UpdateAutomationSourceRequest, UpdateAutomationTriggerRequest } from "@opengeni/contracts";
2
+ import type { OpenGeniClient as OpenGeniCoreClient } from "./client.js";
3
+ export type OpenGeniAutomationsTransport = Pick<OpenGeniCoreClient, "requestJson">;
4
+ export declare class OpenGeniAutomationsClient {
5
+ private readonly client;
6
+ constructor(client: OpenGeniAutomationsTransport);
7
+ listSources(workspaceId: string): Promise<AutomationSource[]>;
8
+ createSource(workspaceId: string, request: CreateAutomationSourceRequest): Promise<AutomationSource>;
9
+ updateSource(workspaceId: string, sourceId: string, request: UpdateAutomationSourceRequest): Promise<AutomationSource>;
10
+ disableSource(workspaceId: string, sourceId: string): Promise<void>;
11
+ listTriggers(workspaceId: string): Promise<AutomationTrigger[]>;
12
+ createTrigger(workspaceId: string, request: CreateAutomationTriggerRequest): Promise<AutomationTrigger>;
13
+ updateTrigger(workspaceId: string, triggerId: string, request: UpdateAutomationTriggerRequest): Promise<AutomationTrigger>;
14
+ disableTrigger(workspaceId: string, triggerId: string, expectedRevision: number): Promise<void>;
15
+ listRuns(workspaceId: string): Promise<AutomationRun[]>;
16
+ triggerManually(workspaceId: string, sourceId: string, request: TriggerAutomationManuallyRequest): Promise<AutomationWebhookResult>;
17
+ }
@@ -0,0 +1,3 @@
1
+ export { OpenGeniAutomationsClient } from "./automations-client.js";
2
+ export type { OpenGeniAutomationsTransport } from "./automations-client.js";
3
+ export type { AutomationAcceptedExecution, AutomationNormalizedEvent, AutomationRun, AutomationSource, AutomationTrigger, AutomationWebhookResult, CreateAutomationSourceRequest, CreateAutomationTriggerRequest, TriggerAutomationManuallyRequest, UpdateAutomationSourceRequest, UpdateAutomationTriggerRequest, } from "@opengeni/contracts";
@@ -0,0 +1,84 @@
1
+ // src/automations-client.ts
2
+ var OpenGeniAutomationsClient = class {
3
+ constructor(client) {
4
+ this.client = client;
5
+ }
6
+ async listSources(workspaceId) {
7
+ const result = await this.client.requestJson(
8
+ "GET",
9
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources`
10
+ );
11
+ return result.sources;
12
+ }
13
+ async createSource(workspaceId, request) {
14
+ return await this.client.requestJson(
15
+ "POST",
16
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources`,
17
+ request
18
+ );
19
+ }
20
+ async updateSource(workspaceId, sourceId, request) {
21
+ return await this.client.requestJson(
22
+ "PATCH",
23
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}`,
24
+ request
25
+ );
26
+ }
27
+ async disableSource(workspaceId, sourceId) {
28
+ await this.client.requestJson(
29
+ "DELETE",
30
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}`,
31
+ void 0,
32
+ {},
33
+ { responseType: "void" }
34
+ );
35
+ }
36
+ async listTriggers(workspaceId) {
37
+ const result = await this.client.requestJson(
38
+ "GET",
39
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers`
40
+ );
41
+ return result.triggers;
42
+ }
43
+ async createTrigger(workspaceId, request) {
44
+ return await this.client.requestJson(
45
+ "POST",
46
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers`,
47
+ request
48
+ );
49
+ }
50
+ async updateTrigger(workspaceId, triggerId, request) {
51
+ return await this.client.requestJson(
52
+ "PATCH",
53
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers/${encodeURIComponent(triggerId)}`,
54
+ request
55
+ );
56
+ }
57
+ async disableTrigger(workspaceId, triggerId, expectedRevision) {
58
+ await this.client.requestJson(
59
+ "DELETE",
60
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers/${encodeURIComponent(triggerId)}?expectedRevision=${expectedRevision}`,
61
+ void 0,
62
+ {},
63
+ { responseType: "void" }
64
+ );
65
+ }
66
+ async listRuns(workspaceId) {
67
+ const result = await this.client.requestJson(
68
+ "GET",
69
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/runs`
70
+ );
71
+ return result.runs;
72
+ }
73
+ async triggerManually(workspaceId, sourceId, request) {
74
+ return await this.client.requestJson(
75
+ "POST",
76
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}/events`,
77
+ request
78
+ );
79
+ }
80
+ };
81
+ export {
82
+ OpenGeniAutomationsClient
83
+ };
84
+ //# sourceMappingURL=automations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/automations-client.ts"],"sourcesContent":["import type {\n AutomationRun,\n AutomationSource,\n AutomationTrigger,\n AutomationWebhookResult,\n CreateAutomationSourceRequest,\n CreateAutomationTriggerRequest,\n TriggerAutomationManuallyRequest,\n UpdateAutomationSourceRequest,\n UpdateAutomationTriggerRequest,\n} from \"@opengeni/contracts\";\nimport type { OpenGeniClient as OpenGeniCoreClient } from \"./client\";\n\nexport type OpenGeniAutomationsTransport = Pick<OpenGeniCoreClient, \"requestJson\">;\n\nexport class OpenGeniAutomationsClient {\n constructor(private readonly client: OpenGeniAutomationsTransport) {}\n\n async listSources(workspaceId: string): Promise<AutomationSource[]> {\n const result = await this.client.requestJson<{ sources: AutomationSource[] }>(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources`,\n );\n return result.sources;\n }\n\n async createSource(\n workspaceId: string,\n request: CreateAutomationSourceRequest,\n ): Promise<AutomationSource> {\n return await this.client.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources`,\n request,\n );\n }\n\n async updateSource(\n workspaceId: string,\n sourceId: string,\n request: UpdateAutomationSourceRequest,\n ): Promise<AutomationSource> {\n return await this.client.requestJson(\n \"PATCH\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}`,\n request,\n );\n }\n\n async disableSource(workspaceId: string, sourceId: string): Promise<void> {\n await this.client.requestJson<void>(\n \"DELETE\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}`,\n undefined,\n {},\n { responseType: \"void\" },\n );\n }\n\n async listTriggers(workspaceId: string): Promise<AutomationTrigger[]> {\n const result = await this.client.requestJson<{ triggers: AutomationTrigger[] }>(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers`,\n );\n return result.triggers;\n }\n\n async createTrigger(\n workspaceId: string,\n request: CreateAutomationTriggerRequest,\n ): Promise<AutomationTrigger> {\n return await this.client.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers`,\n request,\n );\n }\n\n async updateTrigger(\n workspaceId: string,\n triggerId: string,\n request: UpdateAutomationTriggerRequest,\n ): Promise<AutomationTrigger> {\n return await this.client.requestJson(\n \"PATCH\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers/${encodeURIComponent(triggerId)}`,\n request,\n );\n }\n\n async disableTrigger(\n workspaceId: string,\n triggerId: string,\n expectedRevision: number,\n ): Promise<void> {\n await this.client.requestJson<void>(\n \"DELETE\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers/${encodeURIComponent(triggerId)}?expectedRevision=${expectedRevision}`,\n undefined,\n {},\n { responseType: \"void\" },\n );\n }\n\n async listRuns(workspaceId: string): Promise<AutomationRun[]> {\n const result = await this.client.requestJson<{ runs: AutomationRun[] }>(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/runs`,\n );\n return result.runs;\n }\n\n async triggerManually(\n workspaceId: string,\n sourceId: string,\n request: TriggerAutomationManuallyRequest,\n ): Promise<AutomationWebhookResult> {\n return await this.client.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}/events`,\n request,\n );\n }\n}\n"],"mappings":";AAeO,IAAM,4BAAN,MAAgC;AAAA,EACrC,YAA6B,QAAsC;AAAtC;AAAA,EAAuC;AAAA,EAEpE,MAAM,YAAY,aAAkD;AAClE,UAAM,SAAS,MAAM,KAAK,OAAO;AAAA,MAC/B;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,IACnD;AACA,WAAO,OAAO;AAAA,EAChB;AAAA,EAEA,MAAM,aACJ,aACA,SAC2B;AAC3B,WAAO,MAAM,KAAK,OAAO;AAAA,MACvB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,aACJ,aACA,UACA,SAC2B;AAC3B,WAAO,MAAM,KAAK,OAAO;AAAA,MACvB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC,wBAAwB,mBAAmB,QAAQ,CAAC;AAAA,MACrG;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,cAAc,aAAqB,UAAiC;AACxE,UAAM,KAAK,OAAO;AAAA,MAChB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC,wBAAwB,mBAAmB,QAAQ,CAAC;AAAA,MACrG;AAAA,MACA,CAAC;AAAA,MACD,EAAE,cAAc,OAAO;AAAA,IACzB;AAAA,EACF;AAAA,EAEA,MAAM,aAAa,aAAmD;AACpE,UAAM,SAAS,MAAM,KAAK,OAAO;AAAA,MAC/B;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,IACnD;AACA,WAAO,OAAO;AAAA,EAChB;AAAA,EAEA,MAAM,cACJ,aACA,SAC4B;AAC5B,WAAO,MAAM,KAAK,OAAO;AAAA,MACvB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,cACJ,aACA,WACA,SAC4B;AAC5B,WAAO,MAAM,KAAK,OAAO;AAAA,MACvB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC,yBAAyB,mBAAmB,SAAS,CAAC;AAAA,MACvG;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,eACJ,aACA,WACA,kBACe;AACf,UAAM,KAAK,OAAO;AAAA,MAChB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC,yBAAyB,mBAAmB,SAAS,CAAC,qBAAqB,gBAAgB;AAAA,MAC5I;AAAA,MACA,CAAC;AAAA,MACD,EAAE,cAAc,OAAO;AAAA,IACzB;AAAA,EACF;AAAA,EAEA,MAAM,SAAS,aAA+C;AAC5D,UAAM,SAAS,MAAM,KAAK,OAAO;AAAA,MAC/B;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,IACnD;AACA,WAAO,OAAO;AAAA,EAChB;AAAA,EAEA,MAAM,gBACJ,aACA,UACA,SACkC;AAClC,WAAO,MAAM,KAAK,OAAO;AAAA,MACvB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC,wBAAwB,mBAAmB,QAAQ,CAAC;AAAA,MACrG;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,11 @@
1
+ /** Browser-console client. Optional SDK surfaces must not enter this eager graph. */
2
+ export { OpenGeniClient as OpenGeniBrowserClient } from "./client.js";
3
+ export type { SessionMessageSearchRequest, SessionMessageSearchMatch, SessionMessageSearchResponse, SessionMessagePreview, SessionMessagePreviewReference, } from "./session-message-search.js";
4
+ export { OpenGeniToolCallError, OpenGeniToolReapprovalRequiredError, OpenGeniToolsClient, } from "./tools.js";
5
+ export type { OpenGeniGeneratedTools, OpenGeniDynamicToolNode, OpenGeniToolCallOptions, OpenGeniToolFunction, OpenGeniToolsFacade, OpenGeniWorkspaceTools, } from "./tools.js";
6
+ export type { FetchLike, FetchResponse, GetSessionOptions, OpenGeniClientOptions, OpenGeniRequestOptions, SendMessageInput, SteerMessageResult, TranscribeAudioInput, WorkspaceControlEventPage, } from "./client.js";
7
+ export { OpenGeniApiContractMismatchError, OpenGeniApiError, OpenGeniSetupError, OpenGeniAllowanceExhaustedError, OpenGeniSecureContextRequiredError, OpenGeniSessionListCursorError, OpenGeniStreamError, formatErrorMessage, isRetryableStreamError, } from "./errors.js";
8
+ export type { OpenGeniSecureContextRequiredReason } from "./errors.js";
9
+ export { resolveWorkspaceVoiceInputEnabled } from "./transcription.js";
10
+ export { OPENGENI_API_CONTRACT_HEADER, OPENGENI_API_CONTRACT_REVISION } from "./types.js";
11
+ export type { ConnectorToolPermission, ConnectorToolPermissionEntry, ConnectorToolPermissionsResponse, UpdateConnectorToolPermissionsRequest, } from "./types.js";
@@ -0,0 +1,47 @@
1
+ import {
2
+ resolveWorkspaceVoiceInputEnabled
3
+ } from "./chunk-VYCTL62C.js";
4
+ import {
5
+ OpenGeniToolCallError,
6
+ OpenGeniToolReapprovalRequiredError,
7
+ OpenGeniToolsClient
8
+ } from "./chunk-4SMEOV3P.js";
9
+ import {
10
+ OpenGeniClient
11
+ } from "./chunk-FG3OO5LM.js";
12
+ import "./chunk-APXVSSSY.js";
13
+ import {
14
+ OPENGENI_API_CONTRACT_HEADER,
15
+ OPENGENI_API_CONTRACT_REVISION
16
+ } from "./chunk-YIKA2QT4.js";
17
+ import "./chunk-NC57YMUO.js";
18
+ import {
19
+ OpenGeniAllowanceExhaustedError,
20
+ OpenGeniApiContractMismatchError,
21
+ OpenGeniApiError,
22
+ OpenGeniSecureContextRequiredError,
23
+ OpenGeniSessionListCursorError,
24
+ OpenGeniSetupError,
25
+ OpenGeniStreamError,
26
+ formatErrorMessage,
27
+ isRetryableStreamError
28
+ } from "./chunk-V6GIY62B.js";
29
+ export {
30
+ OPENGENI_API_CONTRACT_HEADER,
31
+ OPENGENI_API_CONTRACT_REVISION,
32
+ OpenGeniAllowanceExhaustedError,
33
+ OpenGeniApiContractMismatchError,
34
+ OpenGeniApiError,
35
+ OpenGeniClient as OpenGeniBrowserClient,
36
+ OpenGeniSecureContextRequiredError,
37
+ OpenGeniSessionListCursorError,
38
+ OpenGeniSetupError,
39
+ OpenGeniStreamError,
40
+ OpenGeniToolCallError,
41
+ OpenGeniToolReapprovalRequiredError,
42
+ OpenGeniToolsClient,
43
+ formatErrorMessage,
44
+ isRetryableStreamError,
45
+ resolveWorkspaceVoiceInputEnabled
46
+ };
47
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,75 @@
1
+ import type { SessionEvent } from "../types.js";
2
+ import { OpenGeniChatError, type ChatChunk, type ChatPending, type ChatReply } from "./types.js";
3
+ /**
4
+ * Event folding shared by `send`, `stream`, and every protocol adapter.
5
+ *
6
+ * One fold covers one logical turn: text deltas accumulate into message
7
+ * segments (a tool call closes the current segment, the completed event
8
+ * reconciles it), tool call/output pairs become tool chunks, and the turn
9
+ * settles on a terminal event or a human wait. Events that carry a different
10
+ * turn id than the expected one are ignored so a queued follow-up never ends
11
+ * early on the previous turn's settlement.
12
+ *
13
+ * A segment belongs to one provider message when events carry `messageId`: a
14
+ * delta for another message starts a new segment, and a completion reconciles
15
+ * only the segment of its own message. Completions may arrive after later
16
+ * messages already streamed, so matching by position would let one message's
17
+ * completion close another's segment and repeat its text.
18
+ *
19
+ * Commentary (`phase: "commentary"`) narrates the work, like a tool chunk, so
20
+ * it is held back from the reply text. Only a turn that settles without any
21
+ * answer text falls back to its latest commentary, emitted at settlement.
22
+ */
23
+ export type ChatTurnTerminal = "completed" | "failed" | "cancelled" | "pending";
24
+ export type ChatFoldStep = {
25
+ chunks: ChatChunk[];
26
+ terminal: ChatTurnTerminal | null;
27
+ };
28
+ /** Incremental replay of unresolved requests, without retaining the event log. */
29
+ export declare class ChatPendingFold {
30
+ private readonly requests;
31
+ push(event: SessionEvent): void;
32
+ pending(now?: number): ChatPending[];
33
+ private put;
34
+ }
35
+ export declare class ChatTurnFold {
36
+ private readonly workspaceId;
37
+ private readonly sessionId;
38
+ readonly events: SessionEvent[];
39
+ turnId: string | null;
40
+ pending: ChatPending | null;
41
+ failure: SessionEvent | null;
42
+ private emptyFinalReply;
43
+ private readonly segments;
44
+ private readonly openTools;
45
+ constructor(workspaceId: string, sessionId: string, expectedTurnId: string | null);
46
+ get text(): string;
47
+ push(event: SessionEvent): ChatFoldStep;
48
+ reply(terminal: ChatTurnTerminal): ChatReply;
49
+ /** The error to throw for a `turn.failed` settlement. */
50
+ failureError(): OpenGeniChatError;
51
+ private messageDelta;
52
+ private messageCompleted;
53
+ private segmentOf;
54
+ /** Deltas that carried no identity, still streaming the text this completion names. */
55
+ private unidentifiedStreamingSegment;
56
+ private latestAnswer;
57
+ private findLastSegment;
58
+ /**
59
+ * Complete an answer segment. Only the newest answer can grow: a remainder
60
+ * for an earlier one would land after later text for append-only consumers.
61
+ */
62
+ private extendAnswer;
63
+ private closeSegments;
64
+ /**
65
+ * Close the turn's text. A turn that produced commentary but no answer text
66
+ * (for example one that ends waiting for a worker) replies with its latest
67
+ * commentary rather than nothing.
68
+ */
69
+ private settleSegments;
70
+ private startSegment;
71
+ }
72
+ export declare function approvalPending(payload: Record<string, unknown>): ChatPending | null;
73
+ export declare function humanInputPending(payload: Record<string, unknown>): ChatPending | null;
74
+ export declare function asRecord(value: unknown): Record<string, unknown>;
75
+ export declare function stringValue(value: unknown): string | undefined;
@@ -0,0 +1,41 @@
1
+ import { type ChatResolve } from "./http.js";
2
+ import type { OpenGeni } from "./opengeni.js";
3
+ import { type ChatChunk, type ChatRespondInput } from "./types.js";
4
+ export { CHAT_CONVERSATION_HEADER, type ChatResolution, type ChatResolve } from "./http.js";
5
+ export type ChatHandlerFormat = "native" | "vercel" | "openai-chat" | "openai-responses";
6
+ export type ChatHandlerOptions = {
7
+ /** Mandatory host auth hook; see {@link ChatResolve}. */
8
+ resolve: ChatResolve;
9
+ /** Default wire format; a request may override it with the format header. */
10
+ format?: ChatHandlerFormat | undefined;
11
+ /** Vercel format only: also emit OpenGeni's own tool activity (see `UIMessageStreamOptions.toolParts`). */
12
+ toolParts?: boolean | undefined;
13
+ };
14
+ /** Per-request wire-format override header. */
15
+ export declare const CHAT_FORMAT_HEADER = "x-opengeni-chat-format";
16
+ /**
17
+ * One request handler for a product's chat endpoint. `POST` with `{ message }`
18
+ * streams the reply in the selected format; `POST .../respond` answers a
19
+ * pending approval or human-input request and streams the continuation;
20
+ * `GET` returns the conversation's history as JSON. Every other method is a
21
+ * 405. The conversation is the host's resolution, else the
22
+ * `x-opengeni-conversation` header, else the wire format's own field.
23
+ */
24
+ export declare function createChatHandler(og: OpenGeni, options: ChatHandlerOptions): (request: Request) => Promise<Response>;
25
+ /** `POST { message }` -> native SSE of {@link ChatChunk} (`event: chunk`). */
26
+ export declare function handleNativeChatRequest(og: OpenGeni, request: Request, resolve: ChatResolve): Promise<Response>;
27
+ /**
28
+ * `GET` -> `{ conversation, sessionId, created, messages, pending, status }`: the user and
29
+ * assistant text of the conversation so a client can restore it on reload
30
+ * (`messages` is empty and `created` false before the first message).
31
+ */
32
+ export declare function handleNativeHistoryRequest(og: OpenGeni, request: Request, resolve: ChatResolve): Promise<Response>;
33
+ /** `POST .../respond { requestId, decision | answers | skip }` -> native SSE of the continuation. */
34
+ export declare function handleNativeRespondRequest(og: OpenGeni, request: Request, resolve: ChatResolve): Promise<Response>;
35
+ export declare function respondInputFromBody(body: Record<string, unknown> | null): ChatRespondInput | null;
36
+ /** Native wire format: `event: chunk` per {@link ChatChunk}, `event: error` on failure. */
37
+ export declare function chatChunksToSseBlocks(chunks: AsyncIterable<ChatChunk>): AsyncGenerator<string, void, void>;
38
+ export declare function chatChunksToSseStream(chunks: AsyncIterable<ChatChunk>, onCancel?: () => void): ReadableStream<Uint8Array>;
39
+ export declare function chatChunksToSseResponse(chunks: AsyncIterable<ChatChunk>): Response;
40
+ /** Browser-side reader for the native wire format. Throws {@link OpenGeniChatError} on `event: error`. */
41
+ export declare function parseChatChunkStream(stream: ReadableStream<Uint8Array>): AsyncGenerator<ChatChunk, void, void>;