@opengeni/sdk 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/README.md +1037 -71
  2. package/dist/accounts.d.ts +5 -1
  3. package/dist/accounts.js +13 -1
  4. package/dist/accounts.js.map +1 -1
  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/app-links.d.ts +42 -0
  18. package/dist/app-links.js +66 -0
  19. package/dist/app-links.js.map +1 -0
  20. package/dist/artifact-catalog.d.ts +40 -0
  21. package/dist/artifact-client.d.ts +20 -8
  22. package/dist/artifacts.d.ts +1 -1
  23. package/dist/artifacts.js +8 -6
  24. package/dist/automations.js +8 -2
  25. package/dist/automations.js.map +1 -1
  26. package/dist/azure-live-transport.d.ts +32 -0
  27. package/dist/browser.d.ts +7 -2
  28. package/dist/browser.js +27 -5
  29. package/dist/chat/fold.d.ts +75 -0
  30. package/dist/chat/handler.d.ts +41 -0
  31. package/dist/chat/http.d.ts +67 -0
  32. package/dist/chat/ids.d.ts +34 -0
  33. package/dist/chat/index.d.ts +9 -0
  34. package/dist/chat/index.js +1703 -0
  35. package/dist/chat/index.js.map +1 -0
  36. package/dist/chat/openai.d.ts +30 -0
  37. package/dist/chat/opengeni.d.ts +129 -0
  38. package/dist/chat/types.d.ts +207 -0
  39. package/dist/chat/vercel.d.ts +49 -0
  40. package/dist/chats.d.ts +8 -0
  41. package/dist/chunk-4AHR4KGA.js +301 -0
  42. package/dist/chunk-4AHR4KGA.js.map +1 -0
  43. package/dist/chunk-6HZGAIUE.js +1665 -0
  44. package/dist/chunk-6HZGAIUE.js.map +1 -0
  45. package/dist/chunk-7EWT3PV6.js +368 -0
  46. package/dist/chunk-7EWT3PV6.js.map +1 -0
  47. package/dist/{chunk-VYCTL62C.js → chunk-GZQSWAKD.js} +1 -1
  48. package/dist/chunk-GZQSWAKD.js.map +1 -0
  49. package/dist/chunk-JXXCTW5W.js +1392 -0
  50. package/dist/chunk-JXXCTW5W.js.map +1 -0
  51. package/dist/{chunk-YTAWBDO2.js → chunk-KADZ5PGG.js} +28 -2
  52. package/dist/chunk-KADZ5PGG.js.map +1 -0
  53. package/dist/{chunk-YKZME56C.js → chunk-KWADQ227.js} +3 -3
  54. package/dist/{chunk-YKZME56C.js.map → chunk-KWADQ227.js.map} +1 -1
  55. package/dist/{chunk-7ZXBPJZP.js → chunk-NEM5N6C6.js} +3902 -1457
  56. package/dist/chunk-NEM5N6C6.js.map +1 -0
  57. package/dist/{chunk-GW3EJ2GP.js → chunk-O7KANXC3.js} +86 -13
  58. package/dist/chunk-O7KANXC3.js.map +1 -0
  59. package/dist/{chunk-VUQZAB3O.js → chunk-OAKHWFSV.js} +28 -32
  60. package/dist/chunk-OAKHWFSV.js.map +1 -0
  61. package/dist/chunk-P7UWKORG.js +561 -0
  62. package/dist/chunk-P7UWKORG.js.map +1 -0
  63. package/dist/chunk-QGEIL4TR.js +195 -0
  64. package/dist/chunk-QGEIL4TR.js.map +1 -0
  65. package/dist/chunk-RJHCBZF7.js +270 -0
  66. package/dist/chunk-RJHCBZF7.js.map +1 -0
  67. package/dist/chunk-S3D75WSQ.js +340 -0
  68. package/dist/chunk-S3D75WSQ.js.map +1 -0
  69. package/dist/chunk-UM4ZXXJR.js +9 -0
  70. package/dist/chunk-UM4ZXXJR.js.map +1 -0
  71. package/dist/chunk-VPVMLM7Q.js +15 -0
  72. package/dist/chunk-VPVMLM7Q.js.map +1 -0
  73. package/dist/{chunk-C2H7HBNP.js → chunk-WVCJRSGJ.js} +119 -14
  74. package/dist/chunk-WVCJRSGJ.js.map +1 -0
  75. package/dist/chunk-XA7HVIHI.js +126 -0
  76. package/dist/chunk-XA7HVIHI.js.map +1 -0
  77. package/dist/{chunk-TX3EIENU.js → chunk-YDVPI7WT.js} +73 -2
  78. package/dist/chunk-YDVPI7WT.js.map +1 -0
  79. package/dist/chunk-YKIHNLWD.js +153 -0
  80. package/dist/chunk-YKIHNLWD.js.map +1 -0
  81. package/dist/chunk-ZDUBPV33.js +277 -0
  82. package/dist/chunk-ZDUBPV33.js.map +1 -0
  83. package/dist/client.d.ts +1065 -124
  84. package/dist/codex-realtime-controller.d.ts +13 -0
  85. package/dist/codex-realtime-controller.js +4 -2
  86. package/dist/codex-realtime-v3-wire.d.ts +3 -2
  87. package/dist/codex-realtime.d.ts +5 -1
  88. package/dist/company-brain.d.ts +1 -11
  89. package/dist/company-profile.d.ts +13 -0
  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/feedback.d.ts +23 -0
  102. package/dist/gateway-realtime-transport.js +1 -1
  103. package/dist/github-repositories.d.ts +10 -0
  104. package/dist/github-repositories.js +36 -0
  105. package/dist/github-repositories.js.map +1 -0
  106. package/dist/index.d.ts +64 -11
  107. package/dist/index.js +566 -141
  108. package/dist/index.js.map +1 -1
  109. package/dist/insights-usage.d.ts +33 -0
  110. package/dist/insights-usage.js +7 -0
  111. package/dist/insights-usage.js.map +1 -0
  112. package/dist/interaction.d.ts +103 -71
  113. package/dist/interaction.js +4 -2
  114. package/dist/knowledge.d.ts +7 -0
  115. package/dist/knowledge.js +20 -0
  116. package/dist/knowledge.js.map +1 -0
  117. package/dist/known-tools.d.ts +4 -0
  118. package/dist/message-links.d.ts +68 -0
  119. package/dist/model-context.d.ts +68 -0
  120. package/dist/model-display.d.ts +2 -0
  121. package/dist/model-display.js +17 -0
  122. package/dist/model-display.js.map +1 -0
  123. package/dist/model-picker-order.d.ts +1 -0
  124. package/dist/model-picker-order.js +10 -0
  125. package/dist/model-picker-order.js.map +1 -0
  126. package/dist/organization-integration-policy.d.ts +26 -0
  127. package/dist/organization-integration-policy.js +26 -0
  128. package/dist/organization-integration-policy.js.map +1 -0
  129. package/dist/pr-review-client.d.ts +1 -1
  130. package/dist/pr-review.d.ts +1 -1
  131. package/dist/pr-review.js.map +1 -1
  132. package/dist/preference-registry.d.ts +1 -1
  133. package/dist/prepared-mcp-setup.d.ts +5 -0
  134. package/dist/proxy.d.ts +13 -11
  135. package/dist/realtime.d.ts +4 -2
  136. package/dist/realtime.js +253 -7
  137. package/dist/realtime.js.map +1 -1
  138. package/dist/session-history-import.d.ts +22 -0
  139. package/dist/session-history-import.js +36 -0
  140. package/dist/session-history-import.js.map +1 -0
  141. package/dist/session-list-entries.d.ts +1 -0
  142. package/dist/session-list-entries.js +7 -0
  143. package/dist/session-list-entries.js.map +1 -0
  144. package/dist/session-message-search.d.ts +53 -0
  145. package/dist/session-proxy-client.d.ts +28 -0
  146. package/dist/session-proxy.d.ts +334 -0
  147. package/dist/session-proxy.js +24 -0
  148. package/dist/session-proxy.js.map +1 -0
  149. package/dist/session-titles.d.ts +2 -0
  150. package/dist/session-usage-limits.d.ts +10 -0
  151. package/dist/session-usage-limits.js +43 -0
  152. package/dist/session-usage-limits.js.map +1 -0
  153. package/dist/shared-catalog-loader.d.ts +34 -0
  154. package/dist/site-bridge-host.d.ts +112 -0
  155. package/dist/site-bridge-host.js +285 -0
  156. package/dist/site-bridge-host.js.map +1 -0
  157. package/dist/site-browser-entry.d.ts +1 -0
  158. package/dist/site-browser-runtime.gen.d.ts +1 -0
  159. package/dist/site-data.d.ts +178 -0
  160. package/dist/site-document.d.ts +5 -0
  161. package/dist/site-document.js +20 -0
  162. package/dist/site-document.js.map +1 -0
  163. package/dist/site-document.test.d.ts +1 -0
  164. package/dist/site-http.d.ts +17 -0
  165. package/dist/site-sql.d.ts +31 -0
  166. package/dist/site-tool-bridge.d.ts +57 -0
  167. package/dist/site.d.ts +182 -0
  168. package/dist/site.js +62 -0
  169. package/dist/site.js.map +1 -0
  170. package/dist/skills.d.ts +75 -0
  171. package/dist/sse.d.ts +1 -1
  172. package/dist/stream.d.ts +2 -0
  173. package/dist/tenant-workspaces.d.ts +47 -0
  174. package/dist/tenant-workspaces.js +8 -0
  175. package/dist/tenant-workspaces.js.map +1 -0
  176. package/dist/tool-auth.d.ts +87 -0
  177. package/dist/tool-auth.js +23 -0
  178. package/dist/tool-auth.js.map +1 -0
  179. package/dist/tool-display-metadata.d.ts +3 -0
  180. package/dist/tools-37DCTCNZ.js +12 -0
  181. package/dist/tools-37DCTCNZ.js.map +1 -0
  182. package/dist/tools.d.ts +81 -0
  183. package/dist/transcription.d.ts +1 -1
  184. package/dist/types.d.ts +2848 -573
  185. package/dist/usage-allowances.d.ts +36 -0
  186. package/dist/usage-allowances.js +80 -0
  187. package/dist/usage-allowances.js.map +1 -0
  188. package/dist/vault-types.d.ts +236 -0
  189. package/dist/vaults-api.d.ts +57 -0
  190. package/dist/workspace-artifacts.d.ts +47 -5
  191. package/dist/workspace-instruction-policies.d.ts +2 -2
  192. package/dist/workspace-integrations.d.ts +74 -0
  193. package/dist/workspace-integrations.js +65 -0
  194. package/dist/workspace-integrations.js.map +1 -0
  195. package/dist/workspace-state.d.ts +8 -71
  196. package/package.json +99 -5
  197. package/src/accounts.ts +18 -0
  198. package/src/adapters/express.ts +136 -0
  199. package/src/adapters/hono.ts +18 -0
  200. package/src/adapters/next.ts +42 -0
  201. package/src/allowance-refusal.ts +5 -0
  202. package/src/app-links.ts +117 -0
  203. package/src/artifact-catalog.ts +51 -0
  204. package/src/artifact-client.ts +40 -49
  205. package/src/artifacts.ts +1 -0
  206. package/src/automations-client.ts +8 -2
  207. package/src/azure-live-transport.ts +286 -0
  208. package/src/browser.ts +37 -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 +88 -0
  214. package/src/chat/openai.ts +439 -0
  215. package/src/chat/opengeni.ts +737 -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 +5822 -1847
  220. package/src/codex-realtime-controller.ts +163 -8
  221. package/src/codex-realtime-v3-wire.ts +4 -3
  222. package/src/codex-realtime-v3.ts +12 -3
  223. package/src/codex-realtime.ts +11 -3
  224. package/src/company-brain.ts +0 -40
  225. package/src/company-profile.ts +13 -0
  226. package/src/core.ts +20 -0
  227. package/src/deprecation.ts +149 -0
  228. package/src/document-authority-client.ts +104 -1
  229. package/src/editable-artifacts/controller.ts +36 -2
  230. package/src/editable-artifacts/index.ts +1 -0
  231. package/src/editable-artifacts/types.ts +29 -16
  232. package/src/embedding-client.ts +519 -0
  233. package/src/errors.ts +303 -4
  234. package/src/feedback.ts +20 -0
  235. package/src/gateway-realtime-transport.ts +3 -3
  236. package/src/github-repositories.ts +60 -0
  237. package/src/index.ts +611 -64
  238. package/src/insights-usage.ts +61 -0
  239. package/src/interaction.ts +274 -93
  240. package/src/knowledge.ts +72 -0
  241. package/src/known-tools.ts +279 -0
  242. package/src/message-links.ts +178 -0
  243. package/src/model-context.ts +113 -0
  244. package/src/model-display.ts +11 -0
  245. package/src/model-picker-order.ts +6 -0
  246. package/src/organization-integration-policy.ts +54 -0
  247. package/src/pr-review-client.ts +1 -1
  248. package/src/pr-review.ts +1 -1
  249. package/src/preference-registry.ts +2 -0
  250. package/src/prepared-mcp-setup.ts +123 -0
  251. package/src/proxy.ts +23 -12
  252. package/src/realtime.ts +16 -6
  253. package/src/session-history-import.ts +84 -0
  254. package/src/session-list-entries.ts +1 -0
  255. package/src/session-message-search.ts +47 -0
  256. package/src/session-proxy-client.ts +68 -0
  257. package/src/session-proxy.ts +2098 -0
  258. package/src/session-titles.ts +10 -0
  259. package/src/session-usage-limits.ts +71 -0
  260. package/src/shared-catalog-loader.ts +169 -0
  261. package/src/site-bridge-host.ts +422 -0
  262. package/src/site-browser-entry.ts +6 -0
  263. package/src/site-browser-runtime.gen.ts +2 -0
  264. package/src/site-data.ts +372 -0
  265. package/src/site-document.test.ts +64 -0
  266. package/src/site-document.ts +18 -0
  267. package/src/site-http.ts +171 -0
  268. package/src/site-sql.ts +153 -0
  269. package/src/site-tool-bridge.ts +401 -0
  270. package/src/site.ts +867 -0
  271. package/src/skills.ts +69 -0
  272. package/src/sse.ts +9 -3
  273. package/src/stream.ts +33 -10
  274. package/src/tenant-workspaces.ts +148 -0
  275. package/src/tool-auth.ts +301 -0
  276. package/src/tool-display-metadata.ts +27 -0
  277. package/src/tools.ts +452 -0
  278. package/src/transcription.ts +3 -0
  279. package/src/types.ts +3216 -581
  280. package/src/usage-allowances.ts +189 -0
  281. package/src/vault-types.ts +293 -0
  282. package/src/vaults-api.ts +288 -0
  283. package/src/workspace-artifacts.ts +55 -6
  284. package/src/workspace-instruction-policies.ts +2 -1
  285. package/src/workspace-integrations.ts +402 -0
  286. package/src/workspace-state.ts +8 -82
  287. package/dist/chunk-7ZXBPJZP.js.map +0 -1
  288. package/dist/chunk-C2H7HBNP.js.map +0 -1
  289. package/dist/chunk-C4DJPZRU.js +0 -119
  290. package/dist/chunk-C4DJPZRU.js.map +0 -1
  291. package/dist/chunk-GW3EJ2GP.js.map +0 -1
  292. package/dist/chunk-TX3EIENU.js.map +0 -1
  293. package/dist/chunk-VUQZAB3O.js.map +0 -1
  294. package/dist/chunk-VYCTL62C.js.map +0 -1
  295. package/dist/chunk-YTAWBDO2.js.map +0 -1
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ /** HTTP transport for the ordinary SDK. One response port per request keeps
2
+ * event streams incremental and cancellation independent of other requests. */
3
+ export declare const SITE_HTTP = "opengeni.site.http";
4
+ export declare const SITE_WORKSPACE = "site-host";
5
+ export type SiteHttpRequest = {
6
+ type: typeof SITE_HTTP;
7
+ requestId: string;
8
+ path: string;
9
+ method: string;
10
+ headers: [string, string][];
11
+ /** Text for JSON requests; bytes for Site Data file uploads. */
12
+ body?: string | ArrayBuffer;
13
+ };
14
+ export { siteSessionPath } from "@opengeni/contracts/site-session-http";
15
+ export declare function isSiteHttpRequest(value: unknown): value is SiteHttpRequest;
16
+ export declare function serveSiteHttp(message: SiteHttpRequest, port: MessagePort, fetchResponse: (request: SiteHttpRequest, signal: AbortSignal) => Promise<Response>, signal: AbortSignal): Promise<void>;
17
+ export declare function sitePortFetch(port: MessagePort, input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
@@ -0,0 +1,31 @@
1
+ export type OpenGeniSiteSqlErrorCode = "validation" | "not_found" | "forbidden"
2
+ /** This viewer may not do this on this Site (a role the Site's rules exclude). */
3
+ | "not_available_for_viewer" | "conflict" | "quota_exceeded" | "rate_limited" | "sql_error" | "unavailable" | "disabled" | "site_sql_unsupported" | "request_failed";
4
+ export declare class OpenGeniSiteSqlError extends Error {
5
+ readonly code: OpenGeniSiteSqlErrorCode;
6
+ readonly status: number;
7
+ readonly details: Record<string, unknown>;
8
+ constructor(code: OpenGeniSiteSqlErrorCode, message: string, status: number, details?: Record<string, unknown>);
9
+ }
10
+ /** A parameter value. Booleans bind as 1 and 0. */
11
+ export type OpenGeniSiteSqlValue = string | number | boolean | null;
12
+ export type OpenGeniSiteSqlResult<Row extends Record<string, unknown> = Record<string, unknown>> = {
13
+ columns: string[];
14
+ /** Rows keyed by column name; blobs come back as `{ $base64: string }`. */
15
+ rows: Row[];
16
+ /** True when the query's row or size limit cut the result short. */
17
+ truncated: boolean;
18
+ rowsRead: number;
19
+ rowsWritten: number;
20
+ };
21
+ export type OpenGeniSiteSql = {
22
+ /**
23
+ * Run the named query `name` with `params` (names without the colon). Do
24
+ * not pass `viewer` or any `viewer_*` parameter: the host binds them.
25
+ */
26
+ run<Row extends Record<string, unknown> = Record<string, unknown>>(name: string, params?: Record<string, OpenGeniSiteSqlValue>): Promise<OpenGeniSiteSqlResult<Row>>;
27
+ };
28
+ type SiteSqlFetch = (path: string, init: RequestInit) => Promise<Response>;
29
+ /** Build `site.sql` over a Site HTTP fetch; `ready` says whether the host serves the pinned Site. */
30
+ export declare function createOpenGeniSiteSql(fetchSite: SiteSqlFetch, ready: () => Promise<boolean>): OpenGeniSiteSql;
31
+ export {};
@@ -0,0 +1,57 @@
1
+ import { type SiteHttpRequest } from "./site-http.js";
2
+ import type { OpenGeniSiteToolCatalog } from "./site.js";
3
+ import type { OpenGeniWorkspaceTools } from "./tools.js";
4
+ import type { ToolGatewayCallRequest, ToolGatewayCallResponse, ToolGatewayIdentity, ToolGatewayResolveRequest, ToolGatewayResolvedTool, ToolGatewayInvokeRequest, ToolGatewayInvokeResponse } from "./types.js";
5
+ export type SiteToolCallRequest = ToolGatewayCallRequest & {
6
+ siteArtifactId: string;
7
+ siteVersionId: string;
8
+ };
9
+ export type SiteToolCaller = (input: {
10
+ workspaceId: string;
11
+ request: ToolGatewayCallRequest & Partial<Pick<SiteToolCallRequest, "siteArtifactId" | "siteVersionId">>;
12
+ signal: AbortSignal;
13
+ }) => Promise<ToolGatewayCallResponse>;
14
+ export type SiteToolBridge = {
15
+ resolve?: (request: ToolGatewayResolveRequest, options: {
16
+ signal: AbortSignal;
17
+ }) => Promise<ToolGatewayResolvedTool>;
18
+ invoke?: (request: ToolGatewayInvokeRequest, options: {
19
+ signal: AbortSignal;
20
+ }) => Promise<ToolGatewayInvokeResponse>;
21
+ fetch?: (request: SiteHttpRequest, signal: AbortSignal) => Promise<Response>;
22
+ /** The host serves Site Data for its pinned published Site through `fetch`. */
23
+ siteData?: boolean;
24
+ catalog: (options: {
25
+ signal: AbortSignal;
26
+ }) => Promise<OpenGeniSiteToolCatalog>;
27
+ call: (request: ToolGatewayCallRequest, options: {
28
+ signal: AbortSignal;
29
+ }) => Promise<ToolGatewayCallResponse>;
30
+ };
31
+ export type CreateSiteToolBridgeOptions = {
32
+ workspaceTools: Pick<OpenGeniWorkspaceTools, "$catalog"> & Partial<Pick<OpenGeniWorkspaceTools, "$targetProtocol" | "$resolve" | "$invoke" | "$manifest">>;
33
+ workspaceId: string;
34
+ callTool: SiteToolCaller;
35
+ isCatalogStale?: (error: unknown) => boolean;
36
+ /** Optional authenticated host transport for the host-bound workspace API.
37
+ * Omit to expose tools only. Site-provided authorization headers are never forwarded. */
38
+ fetchResponse?: (path: string, init: RequestInit) => Promise<Response>;
39
+ } & ({
40
+ artifactId: string;
41
+ siteVersionId: string;
42
+ requestedTools: readonly ToolGatewayIdentity[];
43
+ } | {
44
+ artifactId?: never;
45
+ siteVersionId?: never;
46
+ requestedTools?: never;
47
+ });
48
+ /** Host-side bridge for the opaque Site frame. Supply an authenticated transport;
49
+ * the server independently checks live viewer access and the exact Site version.
50
+ * Recreate on actor/version change. Never take these pinned fields from HTML.
51
+ *
52
+ * `fetch` forwards only the `SITE_OPERATIONS` allowlist (`siteSessionPath`);
53
+ * every other route is refused before a request is made. Each bridge is one
54
+ * frame: it mints a frame id, so a frame without a published Site reaches only
55
+ * the sessions it started. */
56
+ export declare function createSiteToolBridge(input: CreateSiteToolBridgeOptions): SiteToolBridge;
57
+ export declare function isSiteCatalogStaleError(error: unknown): boolean;
package/dist/site.d.ts ADDED
@@ -0,0 +1,182 @@
1
+ export { createSiteToolBridge, isSiteCatalogStaleError } from "./site-tool-bridge.js";
2
+ export type { SiteToolBridge, SiteToolCaller, SiteToolCallRequest, CreateSiteToolBridgeOptions, } from "./site-tool-bridge.js";
3
+ import { type OpenGeniWorkspaceTools } from "./tools.js";
4
+ import { OpenGeniClient } from "./client.js";
5
+ import { type OpenGeniSiteData, type OpenGeniSiteFiles } from "./site-data.js";
6
+ import { type OpenGeniSiteSql } from "./site-sql.js";
7
+ export { OpenGeniSiteSqlError, type OpenGeniSiteSql, type OpenGeniSiteSqlErrorCode, type OpenGeniSiteSqlResult, type OpenGeniSiteSqlValue, } from "./site-sql.js";
8
+ export { OpenGeniSiteDataError, SITE_DATA_PATH_PREFIX, type OpenGeniSiteData, type OpenGeniSiteDataCollection, type OpenGeniSiteDataErrorCode, type OpenGeniSiteDataFilter, type OpenGeniSiteDataListOptions, type OpenGeniSiteDataOperation, type OpenGeniSiteDataPage, type OpenGeniSiteDataRecord, type OpenGeniSiteDataRef, type OpenGeniSiteDataScalar, type OpenGeniSiteDataWriteResult, type OpenGeniSiteFile, type OpenGeniSiteFiles, } from "./site-data.js";
9
+ export { isSiteHttpRequest, serveSiteHttp, siteSessionPath, type SiteHttpRequest, } from "./site-http.js";
10
+ import type { SiteViewer, SiteViewerCapabilities } from "@opengeni/contracts";
11
+ import type { ToolGatewayCallRequest, ToolGatewayCallResponse, ToolGatewayCatalog, ToolGatewayDeclarationsResponse, ToolGatewayResolveRequest, ToolGatewayResolvedTool, ToolGatewayInvokeRequest, ToolGatewayInvokeResponse } from "./types.js";
12
+ export declare const OPENGENI_SITE_BRIDGE_VERSION: 2;
13
+ export declare const OPENGENI_SITE_BRIDGE_CONNECT: "opengeni.site.connect";
14
+ export declare const OPENGENI_SITE_BRIDGE_READY: "opengeni.site.ready";
15
+ export declare const OPENGENI_SITE_BRIDGE_REQUEST: "opengeni.site.request";
16
+ export declare const OPENGENI_SITE_BRIDGE_RESPONSE: "opengeni.site.response";
17
+ export declare const OPENGENI_SITE_BRIDGE_CANCEL: "opengeni.site.cancel";
18
+ export declare const OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL: "__opengeniSiteBridgeBootstrapV2";
19
+ export declare const OPENGENI_SITE_LOCAL_CODEMODE_PATH: "/__opengeni/site-tools";
20
+ /** Bridge request method that returns the viewer (advertised by `viewer: 1`). */
21
+ export declare const OPENGENI_SITE_BRIDGE_VIEWER_METHOD: "viewer";
22
+ /** Bridge request method that asks the host to sign the viewer in (advertised by `viewer: 1`). */
23
+ export declare const OPENGENI_SITE_BRIDGE_SIGN_IN_METHOD: "auth.signIn";
24
+ /**
25
+ * The person viewing a Site, as the host reports it. Guests of public
26
+ * published Sites have no name or email. `id` is stable per Site and is the
27
+ * Site Data owner principal; it is not an Opengeni subject id usable elsewhere.
28
+ */
29
+ export type OpenGeniSiteViewer = SiteViewer;
30
+ /**
31
+ * What the current viewer may do on this published Site, so a page can hide
32
+ * features instead of failing: `agent`, `workspaceTools` (workspace members
33
+ * only), `siteData` (`"guest"` when a collection's guest access applies),
34
+ * the Site SQL query audiences the viewer may call, and `viewAs` while a
35
+ * member previews the Site as a visitor. Anything refused at call time
36
+ * still answers with the error code `not_available_for_viewer`.
37
+ */
38
+ export type OpenGeniSiteCapabilities = SiteViewerCapabilities;
39
+ /** Result of `site.auth.signIn()`: `started` is true when the host began a sign-in navigation. */
40
+ export type OpenGeniSiteSignInResult = {
41
+ started: boolean;
42
+ };
43
+ export type OpenGeniSiteBridgeConnectMessage = {
44
+ type: typeof OPENGENI_SITE_BRIDGE_CONNECT;
45
+ version: typeof OPENGENI_SITE_BRIDGE_VERSION;
46
+ };
47
+ export type OpenGeniSiteBridgeReadyMessage = {
48
+ type: typeof OPENGENI_SITE_BRIDGE_READY;
49
+ version: typeof OPENGENI_SITE_BRIDGE_VERSION;
50
+ targetTools?: 1;
51
+ /** The host serves Site Data for this published Site over the Site HTTP channel. */
52
+ siteData?: 1;
53
+ /** The host answers the `viewer` and `auth.signIn` bridge methods. */
54
+ viewer?: 1;
55
+ };
56
+ /** Site-originated calls cannot carry host-only approval tokens or Site-version authority. */
57
+ export type OpenGeniSiteToolCallRequest = Omit<ToolGatewayCallRequest, "approvalToken" | "siteArtifactId" | "siteVersionId">;
58
+ /** Host-filtered catalog projection. Tenant routing context never enters Site code. */
59
+ export type OpenGeniSiteToolCatalog = Omit<ToolGatewayCatalog, "accountId" | "workspaceId">;
60
+ export type OpenGeniSiteWorkspaceTools = OpenGeniWorkspaceTools<OpenGeniSiteToolCatalog>;
61
+ export type OpenGeniSiteBridgeRequestMessage = {
62
+ type: typeof OPENGENI_SITE_BRIDGE_REQUEST;
63
+ version: typeof OPENGENI_SITE_BRIDGE_VERSION;
64
+ requestId: string;
65
+ } & ({
66
+ method: "catalog";
67
+ } | {
68
+ method: "call";
69
+ payload: OpenGeniSiteToolCallRequest;
70
+ } | {
71
+ method: "declarations";
72
+ } | {
73
+ method: "resolve";
74
+ payload: ToolGatewayResolveRequest;
75
+ } | {
76
+ method: "invoke";
77
+ payload: ToolGatewayInvokeRequest;
78
+ } | {
79
+ method: typeof OPENGENI_SITE_BRIDGE_VIEWER_METHOD;
80
+ } | {
81
+ method: typeof OPENGENI_SITE_BRIDGE_SIGN_IN_METHOD;
82
+ });
83
+ export type OpenGeniSiteBridgeCancelMessage = {
84
+ type: typeof OPENGENI_SITE_BRIDGE_CANCEL;
85
+ version: typeof OPENGENI_SITE_BRIDGE_VERSION;
86
+ requestId: string;
87
+ };
88
+ export type OpenGeniSiteBridgeResponseMessage = {
89
+ type: typeof OPENGENI_SITE_BRIDGE_RESPONSE;
90
+ version: typeof OPENGENI_SITE_BRIDGE_VERSION;
91
+ requestId: string;
92
+ } & ({
93
+ ok: true;
94
+ value: OpenGeniSiteToolCatalog | ToolGatewayCallResponse | ToolGatewayDeclarationsResponse | ToolGatewayResolvedTool | ToolGatewayInvokeResponse | OpenGeniSiteViewer | OpenGeniSiteSignInResult;
95
+ } | {
96
+ ok: false;
97
+ error: {
98
+ code: string;
99
+ message: string;
100
+ retryable: boolean;
101
+ outcomeUnknown?: boolean;
102
+ };
103
+ });
104
+ export type OpenGeniSiteClient = {
105
+ /** Ordinary SDK, including React session/composer methods and SSE streams. */
106
+ readonly client: OpenGeniClient;
107
+ /** Host-bound routing alias, not a credential or a caller-selected tenant. */
108
+ readonly workspaceId: string;
109
+ /** Workspace-bound typed facade. The parent host owns workspace identity and credentials. */
110
+ readonly tools: OpenGeniSiteWorkspaceTools;
111
+ /** Persistent collections of JSON records that belong to this published Site. */
112
+ readonly data: OpenGeniSiteData;
113
+ /** Files stored with this published Site. */
114
+ readonly files: OpenGeniSiteFiles;
115
+ /**
116
+ * The Site's optional SQL database: run the named queries its owner
117
+ * defined (`await site.sql.run("top_votes", { limit: 10 })`). Served by
118
+ * hosts bound to a published Site, like `data`; the owner turns it on.
119
+ */
120
+ readonly sql: OpenGeniSiteSql;
121
+ /**
122
+ * The person viewing this Site, resolved once from the host and cached for
123
+ * the life of the client (`await site.viewer`). In the console this is the
124
+ * signed-in workspace member; on a published Site it is the signed-in
125
+ * viewer or an anonymous guest (`kind: "guest"`, `signedIn: false`).
126
+ * Resolves `null` when the host does not report viewers (older hosts and
127
+ * local previews). A failed lookup is not cached; reading again retries.
128
+ */
129
+ readonly viewer: Promise<OpenGeniSiteViewer | null>;
130
+ /**
131
+ * What this viewer may do on the published Site (`await site.capabilities`),
132
+ * resolved once and cached like `viewer`. Resolves `null` when the host
133
+ * does not report it (the console, older hosts and local previews): treat
134
+ * null as "everything the Site declares", as for a workspace member.
135
+ */
136
+ readonly capabilities: Promise<OpenGeniSiteCapabilities | null>;
137
+ readonly auth: {
138
+ /**
139
+ * Ask the host to sign the viewer in. On a published Site the host
140
+ * navigates the whole page to sign-in and returns `{ started: true }`;
141
+ * the page reloads signed in afterwards. Resolves `{ started: false }`
142
+ * when the viewer is already signed in or the host has no sign-in.
143
+ */
144
+ signIn(): Promise<OpenGeniSiteSignInResult>;
145
+ };
146
+ close(): void;
147
+ };
148
+ export type OpenGeniSiteClientOptions = {
149
+ /** Explicit compatibility with hosts predating targeted tool calls; never an automatic fallback. */
150
+ toolGatewayMode?: "catalog" | "target";
151
+ /** Advanced embedding seam; ordinary Sites accept bootstrap only from their exact parent. */
152
+ parentWindow?: MessageEventSource;
153
+ /** Advanced embedding seam for listening to the host's document-bound bootstrap message. */
154
+ siteWindow?: Pick<Window, "parent" | "addEventListener" | "removeEventListener">;
155
+ /** Test/embedding seam for an already document-bound host bootstrap port. */
156
+ bootstrapPort?: MessagePort;
157
+ connectTimeoutMs?: number;
158
+ requestTimeoutMs?: number;
159
+ createMessageChannel?: () => MessageChannel;
160
+ /** Local-preview seam. Top-level pages use this same-origin Codemode proxy automatically. */
161
+ localCodemodePath?: string | false;
162
+ /** Test/embedding seam for local-preview requests. */
163
+ fetch?: typeof globalThis.fetch;
164
+ };
165
+ export declare class OpenGeniSiteBridgeError extends Error {
166
+ readonly code: string;
167
+ readonly retryable: boolean;
168
+ readonly outcomeUnknown: boolean;
169
+ constructor(code: string, message: string, retryable?: boolean, outcomeUnknown?: boolean);
170
+ }
171
+ /**
172
+ * Create the browser client used by a Site. Published iframes use the parent
173
+ * MessagePort; top-level sandbox previews use the same-origin Codemode adapter.
174
+ * Credentials remain in the selected host and never enter Site code.
175
+ */
176
+ export declare function createOpenGeniSiteClient(options?: OpenGeniSiteClientOptions): OpenGeniSiteClient;
177
+ export declare function isOpenGeniSiteBridgeConnectMessage(value: unknown): value is OpenGeniSiteBridgeConnectMessage;
178
+ export declare function isOpenGeniSiteBridgeRequestMessage(value: unknown): value is OpenGeniSiteBridgeRequestMessage;
179
+ export declare function isOpenGeniSiteBridgeCancelMessage(value: unknown): value is OpenGeniSiteBridgeCancelMessage;
180
+ /** Strip every host-only field before a call crosses the Site boundary. */
181
+ export declare function sanitizeOpenGeniSiteToolCallRequest(value: ToolGatewayCallRequest): OpenGeniSiteToolCallRequest;
182
+ export declare function sanitizeOpenGeniSiteToolInvokeRequest(value: ToolGatewayInvokeRequest): ToolGatewayInvokeRequest;
package/dist/site.js ADDED
@@ -0,0 +1,62 @@
1
+ import {
2
+ OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL,
3
+ OPENGENI_SITE_BRIDGE_CANCEL,
4
+ OPENGENI_SITE_BRIDGE_CONNECT,
5
+ OPENGENI_SITE_BRIDGE_READY,
6
+ OPENGENI_SITE_BRIDGE_REQUEST,
7
+ OPENGENI_SITE_BRIDGE_RESPONSE,
8
+ OPENGENI_SITE_BRIDGE_SIGN_IN_METHOD,
9
+ OPENGENI_SITE_BRIDGE_VERSION,
10
+ OPENGENI_SITE_BRIDGE_VIEWER_METHOD,
11
+ OPENGENI_SITE_LOCAL_CODEMODE_PATH,
12
+ OpenGeniSiteBridgeError,
13
+ OpenGeniSiteDataError,
14
+ OpenGeniSiteSqlError,
15
+ SITE_DATA_PATH_PREFIX,
16
+ createOpenGeniSiteClient,
17
+ createSiteToolBridge,
18
+ isOpenGeniSiteBridgeCancelMessage,
19
+ isOpenGeniSiteBridgeConnectMessage,
20
+ isOpenGeniSiteBridgeRequestMessage,
21
+ isSiteCatalogStaleError,
22
+ isSiteHttpRequest,
23
+ sanitizeOpenGeniSiteToolCallRequest,
24
+ sanitizeOpenGeniSiteToolInvokeRequest,
25
+ serveSiteHttp,
26
+ siteSessionPath
27
+ } from "./chunk-JXXCTW5W.js";
28
+ import "./chunk-P7UWKORG.js";
29
+ import "./chunk-NEM5N6C6.js";
30
+ import "./chunk-VPVMLM7Q.js";
31
+ import "./chunk-4AHR4KGA.js";
32
+ import "./chunk-KADZ5PGG.js";
33
+ import "./chunk-O7KANXC3.js";
34
+ import "./chunk-7EWT3PV6.js";
35
+ export {
36
+ OPENGENI_SITE_BRIDGE_BOOTSTRAP_GLOBAL,
37
+ OPENGENI_SITE_BRIDGE_CANCEL,
38
+ OPENGENI_SITE_BRIDGE_CONNECT,
39
+ OPENGENI_SITE_BRIDGE_READY,
40
+ OPENGENI_SITE_BRIDGE_REQUEST,
41
+ OPENGENI_SITE_BRIDGE_RESPONSE,
42
+ OPENGENI_SITE_BRIDGE_SIGN_IN_METHOD,
43
+ OPENGENI_SITE_BRIDGE_VERSION,
44
+ OPENGENI_SITE_BRIDGE_VIEWER_METHOD,
45
+ OPENGENI_SITE_LOCAL_CODEMODE_PATH,
46
+ OpenGeniSiteBridgeError,
47
+ OpenGeniSiteDataError,
48
+ OpenGeniSiteSqlError,
49
+ SITE_DATA_PATH_PREFIX,
50
+ createOpenGeniSiteClient,
51
+ createSiteToolBridge,
52
+ isOpenGeniSiteBridgeCancelMessage,
53
+ isOpenGeniSiteBridgeConnectMessage,
54
+ isOpenGeniSiteBridgeRequestMessage,
55
+ isSiteCatalogStaleError,
56
+ isSiteHttpRequest,
57
+ sanitizeOpenGeniSiteToolCallRequest,
58
+ sanitizeOpenGeniSiteToolInvokeRequest,
59
+ serveSiteHttp,
60
+ siteSessionPath
61
+ };
62
+ //# sourceMappingURL=site.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,75 @@
1
+ /** Public shared Skill folder/history shapes; no runtime contracts dependency. */
2
+ export type SkillFile = {
3
+ path: string;
4
+ content: string;
5
+ };
6
+ export type SkillScope = "workspace" | "organization" | "user";
7
+ export type SkillRecord = {
8
+ removalOperationId?: string | null;
9
+ activationMode: "workspace_managed" | "session_selected";
10
+ pendingRevisionIds: string[];
11
+ id: string;
12
+ stableKey: string;
13
+ scope: SkillScope;
14
+ scopeVersion: number;
15
+ status: string;
16
+ activeRevisionId: string | null;
17
+ revisionId: string | null;
18
+ title: string | null;
19
+ description: string | null;
20
+ contentHash: string | null;
21
+ files: SkillFile[];
22
+ source: {
23
+ pluginId: string;
24
+ facetKey: string;
25
+ skillFacetId: string;
26
+ } | null;
27
+ };
28
+ export type SkillSummary = Omit<SkillRecord, "files">;
29
+ export type SkillWriteReceipt = {
30
+ removed?: boolean | undefined;
31
+ operationId: string;
32
+ skillId: string;
33
+ revisionId: string;
34
+ outcome: "applied" | "pending" | "preserved";
35
+ pendingReason?: "approval" | "source_finalization" | undefined;
36
+ replayed: boolean;
37
+ decision?: "rejected" | undefined;
38
+ skillReview?: import("./types.js").SkillReviewReference | undefined;
39
+ };
40
+ export type SkillPublicationReceipt = SkillWriteReceipt & {
41
+ sourceOperationId: string;
42
+ activationEventId: string | null;
43
+ };
44
+ export type SkillSourceReleaseReceipt = {
45
+ skillId: string;
46
+ revisionId: string | null;
47
+ disposition: "deactivated" | "preserved" | "inactive";
48
+ eventId: string | null;
49
+ warning: string | null;
50
+ };
51
+ export type SaveWorkspaceSkillRequest = {
52
+ operationId: string;
53
+ skillId: string;
54
+ expectedRevisionId: string | null;
55
+ expectedScopeVersion: number;
56
+ scope?: SkillScope;
57
+ stableKey: string;
58
+ files: SkillFile[];
59
+ deletions?: string[];
60
+ reason: string;
61
+ };
62
+ export type ApplyWorkspaceSkillRevisionRequest = {
63
+ removalOperationId?: string;
64
+ operationId: string;
65
+ revisionId: string;
66
+ expectedRevisionId: string | null;
67
+ expectedScopeVersion: number;
68
+ reason: string;
69
+ };
70
+ export type RemoveWorkspaceSkillRequest = {
71
+ operationId: string;
72
+ expectedRevisionId: string | null;
73
+ expectedScopeVersion: number;
74
+ reason: string;
75
+ };
package/dist/sse.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Minimal incremental Server-Sent Events parser over a byte stream.
3
3
  *
4
- * Implements the parts of the SSE wire format OpenGeni uses: `id`, `event`,
4
+ * Implements the parts of the SSE wire format Opengeni uses: `id`, `event`,
5
5
  * and `data` fields, multi-line data, comment lines, and both LF and CRLF
6
6
  * line endings. Messages without any `data` (comments, id-only blocks) are
7
7
  * not emitted.
package/dist/stream.d.ts CHANGED
@@ -61,3 +61,5 @@ export declare function streamSessionEvents(transport: SessionEventStreamTranspo
61
61
  export declare function runBeforeLive(beforeLive: (() => void | Promise<void>) | undefined, timeoutMs: number, signal: AbortSignal | undefined): Promise<void>;
62
62
  export declare function jitteredDelay(delayMs: number, ratio: number): number;
63
63
  export declare function withStreamInactivityTimeout(stream: ReadableStream<Uint8Array>, timeoutMs: number, signal: AbortSignal | undefined): ReadableStream<Uint8Array>;
64
+ /** Trusted SSE coverage attached non-enumerably to a streamed event. */
65
+ export declare function sessionEventStreamCoveredThrough(event: SessionEvent): number | null;
@@ -0,0 +1,47 @@
1
+ import type { OpenGeniEmbeddingClient } from "./embedding-client.js";
2
+ import type { Permission } from "./types.js";
3
+ export type WorkspaceIdTarget = {
4
+ /**
5
+ * Your tenant id. With user isolation and no tenant, the user gets one
6
+ * workspace of their own, independent of any tenant.
7
+ */
8
+ tenant?: string | undefined;
9
+ user?: string | undefined;
10
+ /** External user identity source; defaults to the resolver's source. */
11
+ source?: string | undefined;
12
+ };
13
+ export type WorkspaceIdOptions = {
14
+ /**
15
+ * `tenant`: one workspace per tenant. `user`: a separate workspace for the
16
+ * user (per tenant when a tenant is given, otherwise one per user).
17
+ */
18
+ isolation: "tenant" | "user";
19
+ };
20
+ export type WorkspaceIdResolverOptions = {
21
+ /** The organization id, or a lazy lookup (for example derived from the API key). */
22
+ organizationId: string | (() => Promise<string>);
23
+ source: string;
24
+ /** Workspace display name; receives the tenant id, or the user id for a per-user workspace. */
25
+ workspaceName?: ((tenant: string) => string) | undefined;
26
+ /**
27
+ * Per-user workspaces only (user isolation): permissions for the one member
28
+ * this resolver adds explicitly, its owner. Replaces the defaults: workspace
29
+ * read, session create/read/control (including sending messages), file
30
+ * upload/read, and attaching the host's per-session MCP servers. No admin
31
+ * permissions are granted by default. Tenant workspaces rely on the API,
32
+ * which adds a missing member with those defaults on their first request.
33
+ * Existing grants are never changed here; change them with
34
+ * `updateExternalWorkspaceMember`. The organization API key must also allow
35
+ * the selected permissions.
36
+ */
37
+ memberPermissions?: readonly Permission[] | undefined;
38
+ };
39
+ /**
40
+ * Server-only workspace resolution using external workspace provisioning.
41
+ * Workspaces are created on first use and cached. A tenant workspace's members
42
+ * are added by the API on their first `asUser` request (the organization key
43
+ * needs `members:manage`). A per-user workspace stays single-user: the API
44
+ * never auto-admits anyone there, and this resolver adds its owner with a
45
+ * stable onboarding key, so retries never restore a revoked grant.
46
+ */
47
+ export declare function createWorkspaceIdResolver(client: Pick<OpenGeniEmbeddingClient, "ensureWorkspace" | "addExternalWorkspaceMember">, options: WorkspaceIdResolverOptions): (target: WorkspaceIdTarget, resolution: WorkspaceIdOptions) => Promise<string>;
@@ -0,0 +1,8 @@
1
+ import {
2
+ createWorkspaceIdResolver
3
+ } from "./chunk-XA7HVIHI.js";
4
+ import "./chunk-7EWT3PV6.js";
5
+ export {
6
+ createWorkspaceIdResolver
7
+ };
8
+ //# sourceMappingURL=tenant-workspaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Per-user credentials for a product's own MCP tool server.
3
+ *
4
+ * `createSessionProxyHandler({ toolServer })` mints a short-lived token for the
5
+ * user its `resolve` hook authenticated, attaches it to each session it creates,
6
+ * and refreshes it on every message, approval, and answer. The product's MCP
7
+ * endpoint calls {@link verifyToolRequest} on every request and scopes all data
8
+ * access to the returned identity, never to ids the model supplied.
9
+ *
10
+ * Wire format (for non-Node verifiers): an HS256 JWT in `Authorization: Bearer`,
11
+ * signed with the hex key from {@link deriveToolTokenKey} (`HMAC-SHA256(key =
12
+ * secret, message = "opengeni-tool-token:v1")`, where `secret` is
13
+ * `OPENGENI_API_KEY` unless configured). Give a non-Node verifier that derived
14
+ * key, never the organization key. Claims: `iss` = `"opengeni-session-proxy"`,
15
+ * `aud` = the tool server URL, `sub` = the external user id, `workspace_id`,
16
+ * `source`, optional `tenant`, `iat`, `exp`.
17
+ */
18
+ /** `iss` of every tool token. */
19
+ export declare const TOOL_TOKEN_ISSUER = "opengeni-session-proxy";
20
+ /** HMAC message used to derive the signing key from the secret. */
21
+ export declare const TOOL_TOKEN_KEY_LABEL = "opengeni-tool-token:v1";
22
+ /** Default token lifetime: 24 hours, refreshed on every message, approval, and answer. */
23
+ export declare const TOOL_TOKEN_DEFAULT_TTL_SECONDS: number;
24
+ /** Default `toolServer.url` and `verifyToolRequest` audience. */
25
+ export declare const TOOL_SERVER_URL_ENV = "OPENGENI_TOOL_SERVER_URL";
26
+ /** The user a verified tool request acts for. */
27
+ export type ToolRequestIdentity = {
28
+ /** External user id the session proxy's `resolve` hook authenticated. */
29
+ user: string;
30
+ /** Tenant from `resolve`, when it returned one. */
31
+ tenant?: string | undefined;
32
+ workspaceId: string;
33
+ /** External identity source (same as the proxy's `asUser` source). */
34
+ source: string;
35
+ expiresAt: Date;
36
+ };
37
+ export type VerifyToolRequestOptions = {
38
+ /** Signing secret. Defaults to `OPENGENI_API_KEY`; must match the proxy's. */
39
+ secret?: string | undefined;
40
+ /**
41
+ * Exact tool server URL the token must be issued for (the proxy's
42
+ * `toolServer.url`). Defaults to `OPENGENI_TOOL_SERVER_URL`.
43
+ */
44
+ audience?: string | undefined;
45
+ };
46
+ /** A Web `Request`, or a Node/Express request (`headers` plus `originalUrl`/`url`). */
47
+ export type ToolRequestLike = Request | {
48
+ headers: Record<string, string | string[] | undefined>;
49
+ originalUrl?: string | undefined;
50
+ url?: string | undefined;
51
+ };
52
+ /** Missing, expired, forged, or misdirected tool token. Respond with `status` (401). */
53
+ export declare class ToolRequestError extends Error {
54
+ readonly code: string;
55
+ readonly status = 401;
56
+ constructor(code: string);
57
+ /** A ready 401 response with a `WWW-Authenticate: Bearer` challenge. */
58
+ toResponse(): Response;
59
+ }
60
+ /**
61
+ * Verify the tool token on one MCP request and return who it acts for.
62
+ * Throws {@link ToolRequestError} (401) for every invalid token. Call it on
63
+ * every request, before any tool runs.
64
+ *
65
+ * ```ts
66
+ * const user = await verifyToolRequest(request); // { user, tenant, workspaceId }
67
+ * ```
68
+ */
69
+ export declare function verifyToolRequest(request: ToolRequestLike, options?: VerifyToolRequestOptions): Promise<ToolRequestIdentity>;
70
+ /** Mint one tool token. The session proxy calls this; products rarely need to. */
71
+ export declare function mintToolToken(input: {
72
+ /** Tool server URL; becomes `aud`. */
73
+ audience: string;
74
+ user: string;
75
+ tenant?: string | undefined;
76
+ workspaceId: string;
77
+ source: string;
78
+ secret?: string | undefined;
79
+ ttlSeconds?: number | undefined;
80
+ }): Promise<string>;
81
+ /**
82
+ * The hex HS256 key tool tokens are signed with. Give this (not the
83
+ * organization key) to a tool server written in Python, Ruby, Go, and so on.
84
+ */
85
+ export declare function deriveToolTokenKey(secret?: string): Promise<string>;
86
+ /** The configured secret, else `OPENGENI_API_KEY`. Throws when neither is set. */
87
+ export declare function resolveToolTokenSecret(secret: string | undefined): string;
@@ -0,0 +1,23 @@
1
+ import {
2
+ TOOL_SERVER_URL_ENV,
3
+ TOOL_TOKEN_DEFAULT_TTL_SECONDS,
4
+ TOOL_TOKEN_ISSUER,
5
+ TOOL_TOKEN_KEY_LABEL,
6
+ ToolRequestError,
7
+ deriveToolTokenKey,
8
+ mintToolToken,
9
+ resolveToolTokenSecret,
10
+ verifyToolRequest
11
+ } from "./chunk-QGEIL4TR.js";
12
+ export {
13
+ TOOL_SERVER_URL_ENV,
14
+ TOOL_TOKEN_DEFAULT_TTL_SECONDS,
15
+ TOOL_TOKEN_ISSUER,
16
+ TOOL_TOKEN_KEY_LABEL,
17
+ ToolRequestError,
18
+ deriveToolTokenKey,
19
+ mintToolToken,
20
+ resolveToolTokenSecret,
21
+ verifyToolRequest
22
+ };
23
+ //# sourceMappingURL=tool-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,3 @@
1
+ import type { ToolDisplayMetadata } from "@opengeni/contracts";
2
+ /** Browser/native-safe event projection; do not import server schema runtimes. */
3
+ export declare function parseToolDisplayMetadata(value: unknown): ToolDisplayMetadata | undefined;
@@ -0,0 +1,12 @@
1
+ import {
2
+ OpenGeniToolCallError,
3
+ OpenGeniToolReapprovalRequiredError,
4
+ OpenGeniToolsClient
5
+ } from "./chunk-P7UWKORG.js";
6
+ import "./chunk-7EWT3PV6.js";
7
+ export {
8
+ OpenGeniToolCallError,
9
+ OpenGeniToolReapprovalRequiredError,
10
+ OpenGeniToolsClient
11
+ };
12
+ //# sourceMappingURL=tools-37DCTCNZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}