@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,207 @@
1
+ import type { FetchLike } from "../client.js";
2
+ import type { Chats } from "../chats.js";
3
+ import type { WorkspaceIdResolverOptions } from "../tenant-workspaces.js";
4
+ import type { CreateSessionRequest, AgentConfigRequest, HumanInputAnswer, LatencyMode, ReasoningEffort, SessionEvent, Session, SessionSkill, ToolRef } from "../types.js";
5
+ /** Which other sessions the agent may reach from this one. */
6
+ export type ChatAgentAccess = "session" | "user" | "workspace";
7
+ /**
8
+ * Compatibility option for personal or workspace Knowledge. `false` initializes
9
+ * Knowledge authoring to Off; authorized retrieval remains available. Omitted
10
+ * follows `chats`: private with a user, or legacy reach-based defaults without one.
11
+ * Task notes cover temporary session-tree data.
12
+ */
13
+ export type ChatMemory = "user" | "workspace" | false;
14
+ export type OpenGeniOptions = {
15
+ /** Organization API key. Keep it on the server. */
16
+ apiKey: string;
17
+ /**
18
+ * The organization (account) id that owns every workspace. Optional: when
19
+ * omitted it is read once from the API key.
20
+ */
21
+ organizationId?: string | undefined;
22
+ /** Defaults to `https://app.opengeni.ai`. */
23
+ baseUrl?: string | undefined;
24
+ /**
25
+ * The product identity used as the external-source label for tenant
26
+ * workspaces and end users. Defaults to `"app"`.
27
+ */
28
+ source?: string | undefined;
29
+ fetch?: FetchLike | undefined;
30
+ /** Display name for a tenant workspace created on first use. Defaults to the tenant id. */
31
+ workspaceName?: ((tenant: string) => string) | undefined;
32
+ /**
33
+ * Per-user workspaces only (`{ user }` alone, or `chats: "isolated"`):
34
+ * permissions for the one owner the SDK adds explicitly. Tenant workspaces
35
+ * rely on Opengeni, which adds a user on their first request. Both default
36
+ * to workspace read, session create/read/control (including sending
37
+ * messages), file upload/read, and per-session MCP attachment; no admin
38
+ * permissions. Never updates an existing membership: use
39
+ * `client.updateExternalWorkspaceMember` for that.
40
+ */
41
+ memberPermissions?: WorkspaceIdResolverOptions["memberPermissions"];
42
+ };
43
+ /**
44
+ * Which workspace, in your own ids: `tenant` (one workspace per tenant),
45
+ * neither (the `user`'s own workspace), or an explicit `workspaceId`.
46
+ */
47
+ export type ChatTarget = {
48
+ tenant: string;
49
+ workspaceId?: undefined;
50
+ } | {
51
+ workspaceId: string;
52
+ tenant?: undefined;
53
+ } | {
54
+ user: string;
55
+ tenant?: undefined;
56
+ workspaceId?: undefined;
57
+ };
58
+ /**
59
+ * A workspace in your own ids, for `og.workspaceId(...)`: `{ tenant }` (one
60
+ * workspace per tenant), `{ user }` (one workspace per user), or
61
+ * `{ workspaceId }`. Precedence: workspaceId, then tenant, then user.
62
+ */
63
+ export type WorkspaceTarget = {
64
+ tenant?: string | undefined;
65
+ user?: string | undefined;
66
+ workspaceId?: string | undefined;
67
+ };
68
+ export type ChatOptions = ChatTarget & {
69
+ /**
70
+ * Host-authenticated external user; resolved through server-side asUser().
71
+ * Without a tenant or workspaceId, the user gets one workspace of their own.
72
+ */
73
+ user?: string | undefined;
74
+ /** Stable conversation id; the session id is derived from it deterministically. */
75
+ conversation: string;
76
+ /** Prefer the actual OpenGeni session ID for shared or existing conversations.
77
+ * The acting user is independent of the conversation's identity. */
78
+ sessionId?: string | undefined;
79
+ /**
80
+ * Private (default with a user) uses personal Knowledge and session-only reach;
81
+ * shared uses workspace Knowledge/reach, isolated adds a workspace per tenant/user.
82
+ * Without a user, omission keeps workspace visibility, session reach and Knowledge off.
83
+ */
84
+ chats?: Chats | undefined;
85
+ /** Agent identity, capabilities and instructions; implicit markdown falls back on older servers. */
86
+ agent?: AgentConfigRequest | undefined;
87
+ /** Explicit agent reach overrides the `chats` default. */
88
+ agentAccess?: ChatAgentAccess | undefined;
89
+ memory?: ChatMemory | undefined;
90
+ model?: string | undefined;
91
+ instructions?: string | undefined;
92
+ skills?: SessionSkill[] | undefined;
93
+ tools?: ToolRef[] | undefined;
94
+ /**
95
+ * Raw create-request passthrough (for example `sandboxBackend: "none"` for a
96
+ * pure chat). Explicit values win over facade-derived ones; the message and
97
+ * identity/idempotency fields always come from the facade.
98
+ */
99
+ create?: Partial<CreateSessionRequest> | undefined;
100
+ };
101
+ /** A turn stopped to wait for a human decision. */
102
+ export type ChatPending = {
103
+ kind: "approval" | "human_input";
104
+ /** The id to pass back through `chat.respond`. */
105
+ requestId: string;
106
+ /** Tool name for an approval; null for structured human input. */
107
+ name: string | null;
108
+ /** The producer's exact payload (approval entry or human-input request). */
109
+ payload: unknown;
110
+ };
111
+ export type ChatReplyStatus = "completed" | "pending" | "cancelled";
112
+ export type ChatReply = {
113
+ text: string;
114
+ sessionId: string;
115
+ workspaceId: string;
116
+ turnId: string | null;
117
+ /** `pending` waits on `chat.respond`; `cancelled` carries the text produced before the cancel. */
118
+ status: ChatReplyStatus;
119
+ /** Set when the turn is waiting on `chat.respond` instead of finished. */
120
+ pending: ChatPending | null;
121
+ /** A non-destructive completion without a model-authored final answer. */
122
+ emptyFinalReply?: true;
123
+ /** Display this informational notice when emptyFinalReply is present. */
124
+ notice?: string;
125
+ /** Every event consumed while folding this turn. */
126
+ events: SessionEvent[];
127
+ toString(): string;
128
+ };
129
+ export type ChatToolStatus = "started" | "completed" | "failed";
130
+ export type ChatChunk = {
131
+ type: "text";
132
+ text: string;
133
+ } | {
134
+ type: "tool";
135
+ name: string;
136
+ status: ChatToolStatus;
137
+ callId?: string | undefined;
138
+ input?: unknown;
139
+ } | {
140
+ type: "pending";
141
+ pending: ChatPending;
142
+ } | {
143
+ type: "done";
144
+ reply: ChatReply;
145
+ };
146
+ export type ChatMessage = {
147
+ role: "user" | "assistant";
148
+ text: string;
149
+ sequence: number;
150
+ };
151
+ /** Durable text and unresolved decisions restored when a chat is reopened. */
152
+ export type ChatSnapshot = {
153
+ messages: ChatMessage[];
154
+ pending: ChatPending[];
155
+ status: Session["status"] | null;
156
+ };
157
+ export type ChatRespondInput = {
158
+ requestId: string;
159
+ decision: "approve" | "reject";
160
+ message?: string | undefined;
161
+ } | {
162
+ requestId: string;
163
+ answers: HumanInputAnswer[];
164
+ } | {
165
+ requestId: string;
166
+ skip: true;
167
+ };
168
+ /** One earlier message from the product's own history, imported as context on the first send. */
169
+ export type ChatImportedMessage = {
170
+ role: "user" | "assistant" | "system";
171
+ text: string;
172
+ };
173
+ export type ChatSendOptions = {
174
+ signal?: AbortSignal | undefined;
175
+ /** Supersede the current inference instead of queueing behind it. */
176
+ steer?: boolean | undefined;
177
+ /**
178
+ * Earlier messages the product already holds, oldest first. Used only when
179
+ * this send creates the session: they become the first message's
180
+ * `modelContext` (skipped when `create.modelContext` was supplied), trimmed
181
+ * from the oldest end to 30,000 characters. Never resent on later turns:
182
+ * after the first message OpenGeni owns the history.
183
+ */
184
+ importedHistory?: ChatImportedMessage[] | undefined;
185
+ /** Model for this message's turn; omitted keeps the session's current policy. */
186
+ model?: string | undefined;
187
+ reasoningEffort?: ReasoningEffort | undefined;
188
+ latencyMode?: LatencyMode | undefined;
189
+ /**
190
+ * Model-visible application context for this one message (for example the
191
+ * page or record the user is looking at). Not shown in the transcript and not
192
+ * secret. On the creating message it is combined with imported history.
193
+ */
194
+ modelContext?: string | undefined;
195
+ };
196
+ export type ChatSessionListOptions = ChatTarget & {
197
+ user?: string | undefined;
198
+ /** Match the chat's mode; isolated lists that user's separate workspace. */
199
+ chats?: Chats | undefined;
200
+ limit?: number | undefined;
201
+ };
202
+ /** A turn ended without a usable reply, or the facade was misused. */
203
+ export declare class OpenGeniChatError extends Error {
204
+ readonly code: string;
205
+ readonly event: SessionEvent | null;
206
+ constructor(code: string, message: string, event?: SessionEvent | null);
207
+ }
@@ -0,0 +1,49 @@
1
+ import { type ChatResolve } from "./http.js";
2
+ import type { OpenGeni } from "./opengeni.js";
3
+ import type { ChatChunk } from "./types.js";
4
+ /**
5
+ * Vercel AI SDK UI message stream (protocol v1, as consumed by `useChat` with
6
+ * the default transport in AI SDK 5, 6, and 7; approval requests need 6+).
7
+ * Parts are `data: <json>` SSE
8
+ * lines terminated by `data: [DONE]`, under the
9
+ * `x-vercel-ai-ui-message-stream: v1` header.
10
+ */
11
+ export declare const UI_MESSAGE_STREAM_HEADER = "x-vercel-ai-ui-message-stream";
12
+ export declare const UI_MESSAGE_STREAM_VERSION = "v1";
13
+ export type UIMessageStreamOptions = {
14
+ /** Assistant message id announced in the `start` part. Defaults to a random UUID. */
15
+ messageId?: string | undefined;
16
+ /**
17
+ * Emit OpenGeni's own tool activity as tool parts. Off by default: those
18
+ * tools are not in the app's typed tool set. When on, parts are marked
19
+ * `dynamic` and `providerExecuted`, so `useChat` renders them as
20
+ * `dynamic-tool` parts and never tries to execute them. Approval requests
21
+ * are always emitted (as dynamic tool parts) because answering them is part
22
+ * of the conversation.
23
+ */
24
+ toolParts?: boolean | undefined;
25
+ /**
26
+ * Emit the `start` / `start-step` / `finish-step` / `finish` framing. Set to
27
+ * false when writing into an existing AI SDK stream that owns its framing
28
+ * (for example `createUIMessageStream({ execute: ({ writer }) => ... })`).
29
+ * Defaults to true.
30
+ */
31
+ framing?: boolean | undefined;
32
+ };
33
+ /** Protocol parts for one reply, in order. */
34
+ export declare function uiMessageStreamParts(chunks: AsyncIterable<ChatChunk>, options?: UIMessageStreamOptions): AsyncGenerator<Record<string, unknown>, void, void>;
35
+ export declare function uiMessageStreamBlocks(chunks: AsyncIterable<ChatChunk>, options?: UIMessageStreamOptions): AsyncGenerator<string, void, void>;
36
+ export declare function chatChunksToUIMessageStream(chunks: AsyncIterable<ChatChunk>, options?: UIMessageStreamOptions & {
37
+ onCancel?: (() => void) | undefined;
38
+ }): ReadableStream<Uint8Array>;
39
+ export declare function uiMessageStreamResponse(chunks: AsyncIterable<ChatChunk>, options?: UIMessageStreamOptions): Response;
40
+ /** Text of the last user `UIMessage` (`parts` of type `text`, joined). */
41
+ export declare function lastUIMessageText(messages: unknown): string | null;
42
+ /**
43
+ * `useChat` request handler: body `{ id, messages, trigger, messageId }`.
44
+ * Conversation: the host's `resolve`, else the `x-opengeni-conversation`
45
+ * header, else the chat `id`. Only the last user message is sent; the
46
+ * messages before it are imported once as context when this request creates
47
+ * the session. `regenerate-message` steers instead of queueing.
48
+ */
49
+ export declare function handleVercelChatRequest(og: OpenGeni, request: Request, resolve: ChatResolve, options?: Pick<UIMessageStreamOptions, "toolParts">): Promise<Response>;
@@ -0,0 +1,8 @@
1
+ import type { CreateSessionRequest } from "./types.js";
2
+ /**
3
+ * Private chats use personal Knowledge and session-only agent reach; shared chats
4
+ * use workspace Knowledge and reach. Isolated adds a separate workspace per user.
5
+ */
6
+ export type Chats = "private" | "shared" | "isolated";
7
+ /** SDK defaults only: the API still authorizes visibility, agent reach and Knowledge separately. */
8
+ export declare function chatDefaults(chats: Chats): Required<Pick<CreateSessionRequest, "visibility" | "agentAccess" | "memoryScope">>;