@opengeni/sdk 0.57.0 → 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.
- package/README.md +1017 -26
- package/dist/accounts.d.ts +153 -0
- package/dist/accounts.js +307 -0
- package/dist/accounts.js.map +1 -0
- package/dist/adapters/express.d.ts +31 -0
- package/dist/adapters/express.js +87 -0
- package/dist/adapters/express.js.map +1 -0
- package/dist/adapters/hono.d.ts +16 -0
- package/dist/adapters/hono.js +8 -0
- package/dist/adapters/hono.js.map +1 -0
- package/dist/adapters/next.d.ts +29 -0
- package/dist/adapters/next.js +22 -0
- package/dist/adapters/next.js.map +1 -0
- package/dist/allowance-refusal.d.ts +2 -0
- package/dist/allowance-refusal.js +50 -0
- package/dist/allowance-refusal.js.map +1 -0
- package/dist/artifact-catalog.d.ts +31 -0
- package/dist/artifact-client.d.ts +23 -11
- package/dist/artifacts.d.ts +1 -1
- package/dist/artifacts.js +7 -5
- package/dist/automations-client.d.ts +17 -0
- package/dist/automations.d.ts +3 -0
- package/dist/automations.js +84 -0
- package/dist/automations.js.map +1 -0
- package/dist/browser.d.ts +11 -0
- package/dist/browser.js +47 -0
- package/dist/browser.js.map +1 -0
- package/dist/chat/fold.d.ts +75 -0
- package/dist/chat/handler.d.ts +41 -0
- package/dist/chat/http.d.ts +67 -0
- package/dist/chat/ids.d.ts +34 -0
- package/dist/chat/index.d.ts +9 -0
- package/dist/chat/index.js +1694 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/openai.d.ts +30 -0
- package/dist/chat/opengeni.d.ts +128 -0
- package/dist/chat/types.d.ts +207 -0
- package/dist/chat/vercel.d.ts +49 -0
- package/dist/chats.d.ts +8 -0
- package/dist/{chunk-JDLDDRNE.js → chunk-2UXZUCEZ.js} +291 -34
- package/dist/chunk-2UXZUCEZ.js.map +1 -0
- package/dist/chunk-4SMEOV3P.js +246 -0
- package/dist/chunk-4SMEOV3P.js.map +1 -0
- package/dist/{chunk-JRPFWI6T.js → chunk-AH5D5Q5V.js} +31 -35
- package/dist/chunk-AH5D5Q5V.js.map +1 -0
- package/dist/chunk-APXVSSSY.js +301 -0
- package/dist/chunk-APXVSSSY.js.map +1 -0
- package/dist/chunk-DUVIYER4.js +639 -0
- package/dist/chunk-DUVIYER4.js.map +1 -0
- package/dist/{chunk-PKQ377ED.js → chunk-FG3OO5LM.js} +2686 -611
- package/dist/chunk-FG3OO5LM.js.map +1 -0
- package/dist/chunk-GZYZT22T.js +260 -0
- package/dist/chunk-GZYZT22T.js.map +1 -0
- package/dist/chunk-HMGADJGZ.js +150 -0
- package/dist/chunk-HMGADJGZ.js.map +1 -0
- package/dist/{chunk-YKZME56C.js → chunk-KWADQ227.js} +3 -3
- package/dist/{chunk-YKZME56C.js.map → chunk-KWADQ227.js.map} +1 -1
- package/dist/chunk-LY2K6ELJ.js +126 -0
- package/dist/chunk-LY2K6ELJ.js.map +1 -0
- package/dist/chunk-MOTJYIYL.js +340 -0
- package/dist/chunk-MOTJYIYL.js.map +1 -0
- package/dist/{chunk-ST5DDKJP.js → chunk-NC57YMUO.js} +121 -3
- package/dist/chunk-NC57YMUO.js.map +1 -0
- package/dist/chunk-RWKB6YZG.js +1270 -0
- package/dist/chunk-RWKB6YZG.js.map +1 -0
- package/dist/chunk-U6CV2SXO.js +195 -0
- package/dist/chunk-U6CV2SXO.js.map +1 -0
- package/dist/chunk-UM4ZXXJR.js +9 -0
- package/dist/chunk-UM4ZXXJR.js.map +1 -0
- package/dist/chunk-V6GIY62B.js +229 -0
- package/dist/chunk-V6GIY62B.js.map +1 -0
- package/dist/chunk-WU6GQG25.js +268 -0
- package/dist/chunk-WU6GQG25.js.map +1 -0
- package/dist/{chunk-VWE2QIVO.js → chunk-XNG7YGR3.js} +23 -6
- package/dist/chunk-XNG7YGR3.js.map +1 -0
- package/dist/{chunk-HJ3HHUT5.js → chunk-YIKA2QT4.js} +33 -2
- package/dist/chunk-YIKA2QT4.js.map +1 -0
- package/dist/chunk-ZKPY6YAJ.js +135 -0
- package/dist/chunk-ZKPY6YAJ.js.map +1 -0
- package/dist/client.d.ts +740 -94
- package/dist/codex-realtime-controller.d.ts +3 -0
- package/dist/codex-realtime-controller.js +2 -2
- package/dist/codex-realtime-v3.d.ts +13 -2
- package/dist/company-brain.d.ts +22 -0
- package/dist/company-profile.d.ts +14 -1
- package/dist/core.d.ts +9 -3
- package/dist/core.js +25 -6
- package/dist/deprecation.d.ts +47 -0
- package/dist/document-authority-client.d.ts +51 -0
- package/dist/document-authority.d.ts +2 -0
- package/dist/document-authority.js +12 -0
- package/dist/document-authority.js.map +1 -0
- package/dist/editable-artifacts/browser-session.d.ts +7 -3
- package/dist/editable-artifacts/controller.d.ts +4 -1
- package/dist/editable-artifacts/errors.d.ts +1 -1
- package/dist/editable-artifacts/http-live-transport.d.ts +6 -2
- package/dist/editable-artifacts/index.d.ts +2 -0
- package/dist/editable-artifacts/open-failure.d.ts +9 -0
- package/dist/editable-artifacts/types.d.ts +6 -3
- package/dist/editable-artifacts/worker/kernel-adapter.d.ts +1 -1
- package/dist/editable-artifacts-worker.js +44 -17
- package/dist/editable-artifacts-worker.js.map +1 -1
- package/dist/editable-artifacts.js +240 -121
- package/dist/editable-artifacts.js.map +1 -1
- package/dist/embedding-client.d.ts +129 -0
- package/dist/errors.d.ts +36 -1
- package/dist/feedback.d.ts +23 -0
- package/dist/gateway-realtime-transport.js +1 -1
- package/dist/github-repositories.d.ts +10 -0
- package/dist/github-repositories.js +36 -0
- package/dist/github-repositories.js.map +1 -0
- package/dist/index.d.ts +56 -11
- package/dist/index.js +242 -125
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +84 -1
- package/dist/interaction.js +6 -1
- package/dist/knowledge.d.ts +7 -0
- package/dist/knowledge.js +20 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/message-links.d.ts +68 -0
- package/dist/model-context.d.ts +68 -0
- package/dist/model-display.d.ts +2 -0
- package/dist/model-display.js +15 -0
- package/dist/model-display.js.map +1 -0
- package/dist/model-picker-order.d.ts +1 -0
- package/dist/model-picker-order.js +10 -0
- package/dist/model-picker-order.js.map +1 -0
- package/dist/organization-integration-policy.d.ts +26 -0
- package/dist/organization-integration-policy.js +26 -0
- package/dist/organization-integration-policy.js.map +1 -0
- package/dist/organization-private-session-settings.d.ts +6 -0
- package/dist/organization-private-session-settings.js +22 -0
- package/dist/organization-private-session-settings.js.map +1 -0
- package/dist/organization-user-setup.d.ts +8 -0
- package/dist/organization-user-setup.js +16 -0
- package/dist/organization-user-setup.js.map +1 -0
- package/dist/pr-review-client.d.ts +16 -0
- package/dist/pr-review.d.ts +4 -0
- package/dist/pr-review.js +62 -0
- package/dist/pr-review.js.map +1 -0
- package/dist/preference-registry.d.ts +9 -1
- package/dist/proxy.d.ts +7 -5
- package/dist/realtime.d.ts +3 -1
- package/dist/realtime.js +6 -6
- package/dist/realtime.js.map +1 -1
- package/dist/retained-artifacts.d.ts +5 -1
- package/dist/session-history-import.d.ts +22 -0
- package/dist/session-history-import.js +36 -0
- package/dist/session-history-import.js.map +1 -0
- package/dist/session-list-entries.d.ts +1 -0
- package/dist/session-list-entries.js +7 -0
- package/dist/session-list-entries.js.map +1 -0
- package/dist/session-message-search.d.ts +53 -0
- package/dist/session-proxy-client.d.ts +24 -0
- package/dist/session-proxy.d.ts +245 -0
- package/dist/session-proxy.js +24 -0
- package/dist/session-proxy.js.map +1 -0
- package/dist/session-titles.d.ts +2 -0
- package/dist/site-browser-entry.d.ts +1 -0
- package/dist/site-browser-runtime.gen.d.ts +1 -0
- package/dist/site-document.d.ts +5 -0
- package/dist/site-document.js +20 -0
- package/dist/site-document.js.map +1 -0
- package/dist/site-document.test.d.ts +1 -0
- package/dist/site-http.d.ts +16 -0
- package/dist/site-tool-bridge.d.ts +44 -0
- package/dist/site.d.ts +101 -0
- package/dist/site.js +49 -0
- package/dist/site.js.map +1 -0
- package/dist/skills.d.ts +75 -0
- package/dist/stream.d.ts +2 -0
- package/dist/tenant-workspaces.d.ts +47 -0
- package/dist/tenant-workspaces.js +8 -0
- package/dist/tenant-workspaces.js.map +1 -0
- package/dist/tool-auth.d.ts +87 -0
- package/dist/tool-auth.js +23 -0
- package/dist/tool-auth.js.map +1 -0
- package/dist/tool-display-metadata.d.ts +3 -0
- package/dist/tools-FXBLUWAE.js +12 -0
- package/dist/tools-FXBLUWAE.js.map +1 -0
- package/dist/tools.d.ts +61 -0
- package/dist/types.d.ts +2863 -424
- package/dist/usage-allowances.d.ts +36 -0
- package/dist/usage-allowances.js +80 -0
- package/dist/usage-allowances.js.map +1 -0
- package/dist/workspace-artifacts.d.ts +33 -5
- package/dist/workspace-instruction-policies.d.ts +24 -2
- package/dist/workspace-integrations.d.ts +74 -0
- package/dist/workspace-integrations.js +65 -0
- package/dist/workspace-integrations.js.map +1 -0
- package/dist/workspace-learning.d.ts +124 -0
- package/dist/workspace-state.d.ts +8 -71
- package/package.json +108 -3
- package/src/accounts.ts +443 -0
- package/src/adapters/express.ts +136 -0
- package/src/adapters/hono.ts +18 -0
- package/src/adapters/next.ts +42 -0
- package/src/allowance-refusal.ts +5 -0
- package/src/artifact-catalog.ts +41 -0
- package/src/artifact-client.ts +43 -52
- package/src/artifacts.ts +7 -1
- package/src/automations-client.ts +124 -0
- package/src/automations.ts +15 -0
- package/src/browser.ts +54 -0
- package/src/chat/fold.ts +431 -0
- package/src/chat/handler.ts +240 -0
- package/src/chat/http.ts +257 -0
- package/src/chat/ids.ts +85 -0
- package/src/chat/index.ts +87 -0
- package/src/chat/openai.ts +439 -0
- package/src/chat/opengeni.ts +722 -0
- package/src/chat/types.ts +219 -0
- package/src/chat/vercel.ts +204 -0
- package/src/chats.ts +16 -0
- package/src/client.ts +4084 -515
- package/src/codex-realtime-controller.ts +235 -5
- package/src/codex-realtime-v3.ts +162 -31
- package/src/codex-realtime.ts +1 -1
- package/src/company-brain.ts +59 -0
- package/src/company-profile.ts +17 -1
- package/src/core.ts +23 -1
- package/src/deprecation.ts +149 -0
- package/src/document-authority-client.ts +219 -0
- package/src/document-authority.ts +17 -0
- package/src/editable-artifacts/browser-session.ts +36 -22
- package/src/editable-artifacts/controller.ts +102 -47
- package/src/editable-artifacts/errors.ts +2 -0
- package/src/editable-artifacts/http-live-transport.ts +62 -37
- package/src/editable-artifacts/index.ts +6 -0
- package/src/editable-artifacts/open-failure.ts +79 -0
- package/src/editable-artifacts/storage.ts +31 -40
- package/src/editable-artifacts/types.ts +6 -3
- package/src/editable-artifacts/worker/kernel-adapter.ts +23 -7
- package/src/editable-artifacts/worker/runtime.ts +26 -13
- package/src/editable-artifacts/worker/wire-codec.ts +23 -5
- package/src/embedding-client.ts +519 -0
- package/src/errors.ts +169 -2
- package/src/feedback.ts +20 -0
- package/src/gateway-realtime-transport.ts +3 -3
- package/src/github-repositories.ts +60 -0
- package/src/index.ts +561 -41
- package/src/interaction.ts +276 -4
- package/src/knowledge.ts +72 -0
- package/src/message-links.ts +178 -0
- package/src/model-context.ts +112 -0
- package/src/model-display.ts +10 -0
- package/src/model-picker-order.ts +6 -0
- package/src/organization-integration-policy.ts +54 -0
- package/src/organization-private-session-settings.ts +33 -0
- package/src/organization-user-setup.ts +31 -0
- package/src/pr-review-client.ts +92 -0
- package/src/pr-review.ts +17 -0
- package/src/preference-registry.ts +11 -0
- package/src/proxy.ts +17 -6
- package/src/realtime.ts +1 -0
- package/src/retained-artifacts.ts +101 -0
- package/src/session-history-import.ts +84 -0
- package/src/session-list-entries.ts +1 -0
- package/src/session-message-search.ts +47 -0
- package/src/session-proxy-client.ts +64 -0
- package/src/session-proxy.ts +1473 -0
- package/src/session-titles.ts +10 -0
- package/src/site-browser-entry.ts +6 -0
- package/src/site-browser-runtime.gen.ts +2 -0
- package/src/site-document.test.ts +64 -0
- package/src/site-document.ts +18 -0
- package/src/site-http.ts +162 -0
- package/src/site-tool-bridge.ts +146 -0
- package/src/site.ts +585 -0
- package/src/skills.ts +69 -0
- package/src/sse.ts +8 -2
- package/src/stream.ts +38 -4
- package/src/tenant-workspaces.ts +148 -0
- package/src/tool-auth.ts +301 -0
- package/src/tool-display-metadata.ts +19 -0
- package/src/tools.ts +396 -0
- package/src/types.ts +3346 -501
- package/src/usage-allowances.ts +189 -0
- package/src/workspace-artifacts.ts +40 -6
- package/src/workspace-instruction-policies.ts +26 -1
- package/src/workspace-integrations.ts +402 -0
- package/src/workspace-learning.ts +138 -0
- package/src/workspace-state.ts +8 -82
- package/dist/chunk-GU6JF75T.js +0 -119
- package/dist/chunk-GU6JF75T.js.map +0 -1
- package/dist/chunk-HJ3HHUT5.js.map +0 -1
- package/dist/chunk-JDLDDRNE.js.map +0 -1
- package/dist/chunk-JRPFWI6T.js.map +0 -1
- package/dist/chunk-PKQ377ED.js.map +0 -1
- package/dist/chunk-ST5DDKJP.js.map +0 -1
- package/dist/chunk-VWE2QIVO.js.map +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Literal Unicode case-insensitive substring. Whitespace is significant. */
|
|
2
|
+
export type SessionMessageSearchRequest = {
|
|
3
|
+
query: string;
|
|
4
|
+
sessionId?: string | undefined;
|
|
5
|
+
/** Workspace-only first hit per session; cannot combine with sessionId. */
|
|
6
|
+
groupBy?: "session" | undefined;
|
|
7
|
+
archiveStatus?: "active" | "archived" | "all" | undefined;
|
|
8
|
+
limit?: number | undefined;
|
|
9
|
+
cursor?: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
export type SessionMessageSearchMatch = {
|
|
12
|
+
sessionId: string;
|
|
13
|
+
sessionTitle: string | null;
|
|
14
|
+
eventId: string;
|
|
15
|
+
sequence: number;
|
|
16
|
+
turnId: string | null;
|
|
17
|
+
role: "user" | "assistant";
|
|
18
|
+
messageId: string | null;
|
|
19
|
+
/** Zero-based UTF-16 offset in the complete visible message. */
|
|
20
|
+
messageMatchOffset: number;
|
|
21
|
+
/** Zero-based UTF-16 offsets in text; matchEnd is exclusive. */
|
|
22
|
+
snippet: {
|
|
23
|
+
text: string;
|
|
24
|
+
matchStart: number;
|
|
25
|
+
matchEnd: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type SessionMessageSearchResponse = {
|
|
29
|
+
matches: SessionMessageSearchMatch[];
|
|
30
|
+
nextCursor: string | null;
|
|
31
|
+
/** Empty advancing pages are valid. Continue until false. */
|
|
32
|
+
hasMore: boolean;
|
|
33
|
+
/** Cumulative distinct messages visited in this live traversal. */
|
|
34
|
+
scannedMessages: number;
|
|
35
|
+
/** Cumulative matching messages, or session representatives with groupBy=session. */
|
|
36
|
+
matchedMessageCount: number;
|
|
37
|
+
/** Cumulative occurrences, or session representatives with groupBy=session. */
|
|
38
|
+
matchedOccurrenceCount: number;
|
|
39
|
+
/** True only on exhaustion. Concurrent mutations require a fresh traversal. */
|
|
40
|
+
countIsExact: boolean;
|
|
41
|
+
};
|
|
42
|
+
/** Exact selected event reference from a search match; no payload fields are read. */
|
|
43
|
+
export type SessionMessagePreviewReference = {
|
|
44
|
+
eventId: string;
|
|
45
|
+
sequence: number;
|
|
46
|
+
};
|
|
47
|
+
/** A complete visible message, or an explicit over-12,000-UTF-16-unit result. */
|
|
48
|
+
export type SessionMessagePreview = {
|
|
49
|
+
status: "available";
|
|
50
|
+
text: string;
|
|
51
|
+
} | {
|
|
52
|
+
status: "unavailable";
|
|
53
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { OpenGeniEmbeddingClient } from "./embedding-client.js";
|
|
2
|
+
import type { OpenGeniRequestOptions, FetchResponse } from "./client.js";
|
|
3
|
+
import type { AccessGrant } from "./types.js";
|
|
4
|
+
/** Maximum actual UTF-8 bytes forwarded for one embedded Site HTML response. */
|
|
5
|
+
export declare const SESSION_PROXY_SITE_HTML_MAX_BYTES: number;
|
|
6
|
+
/** A streaming Site download exceeded the host proxy's actual-byte ceiling. */
|
|
7
|
+
export declare class SessionProxySiteHtmlTooLargeError extends Error {
|
|
8
|
+
readonly code = "site_html_too_large";
|
|
9
|
+
readonly limitBytes: number;
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
12
|
+
/** Server-only effective grant read; never derive external authority from access/me snapshots. */
|
|
13
|
+
export declare function getSessionProxyWorkspaceGrant(client: Pick<OpenGeniEmbeddingClient, "requestJson">, workspaceId: string, options?: OpenGeniRequestOptions): Promise<AccessGrant>;
|
|
14
|
+
/** Exact association read. The API reauthorizes the source session on every call. */
|
|
15
|
+
export declare function getSessionProxyArtifactAssociation(client: Pick<OpenGeniEmbeddingClient, "requestJson">, workspaceId: string, sessionId: string, kind: "editable" | "site", artifactId: string, options?: OpenGeniRequestOptions): Promise<{
|
|
16
|
+
sessionId: string;
|
|
17
|
+
artifactId: string;
|
|
18
|
+
kind: "editable" | "site";
|
|
19
|
+
}>;
|
|
20
|
+
/** Authenticated response stream for the server proxy; does not buffer Site HTML. */
|
|
21
|
+
export declare function downloadSessionProxySiteHtml(client: Pick<OpenGeniEmbeddingClient, "requestJsonResponse">, workspaceId: string, artifactId: string, options: {
|
|
22
|
+
versionId: string;
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
}): Promise<FetchResponse>;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import type { OpenGeniEmbeddingClient } from "./embedding-client.js";
|
|
2
|
+
import { type Chats } from "./chats.js";
|
|
3
|
+
import type { WorkspaceIdOptions, WorkspaceIdTarget } from "./tenant-workspaces.js";
|
|
4
|
+
import type { CreateSessionRequest, SessionMcpCredentialUpdateInput } from "./types.js";
|
|
5
|
+
export { downloadSessionProxySiteHtml, getSessionProxyArtifactAssociation, getSessionProxyWorkspaceGrant, SESSION_PROXY_SITE_HTML_MAX_BYTES, SessionProxySiteHtmlTooLargeError, } from "./session-proxy-client.js";
|
|
6
|
+
/**
|
|
7
|
+
* Packaged same-origin backend for the React conversation surfaces.
|
|
8
|
+
*
|
|
9
|
+
* Mount the handler at a catch-all route (for example `/api/opengeni/*`) and
|
|
10
|
+
* point an unmodified browser `OpenGeniClient({ baseUrl: "/api/opengeni" })`
|
|
11
|
+
* at it. Every request is authenticated by the host's `resolve` hook, pinned
|
|
12
|
+
* to the resolved workspace, executed as the resolved external user through
|
|
13
|
+
* `asUser` (never the organization key's own service authority), and limited
|
|
14
|
+
* to the exact native routes `SessionConversation` and its hooks use. It is
|
|
15
|
+
* an explicit dispatcher, not an arbitrary upstream proxy.
|
|
16
|
+
*/
|
|
17
|
+
type ProxyClient = OpenGeniEmbeddingClient;
|
|
18
|
+
/** The `@opengeni/sdk/chat` `OpenGeni` facade, structurally. */
|
|
19
|
+
type ProxyFacade = {
|
|
20
|
+
readonly client: ProxyClient;
|
|
21
|
+
readonly source: string;
|
|
22
|
+
workspaceId(target: {
|
|
23
|
+
tenant: string;
|
|
24
|
+
}): Promise<string>;
|
|
25
|
+
workspaceIdFor?(target: WorkspaceIdTarget, options: WorkspaceIdOptions): Promise<string>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Who the authenticated request acts as, in your own ids. Never derive any of
|
|
29
|
+
* it from the request body or path. `{ user, tenant }`: one workspace per
|
|
30
|
+
* tenant. `{ user }`: one workspace per user. `{ user, workspaceId }`: your
|
|
31
|
+
* own workspace. Tenant and per-user mapping require the `OpenGeni` facade
|
|
32
|
+
* from `@opengeni/sdk/chat`; workspaces are created on first use and Opengeni
|
|
33
|
+
* adds the user on their first request.
|
|
34
|
+
*/
|
|
35
|
+
export type SessionProxyResolution = ({
|
|
36
|
+
workspaceId: string;
|
|
37
|
+
tenant?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
tenant: string;
|
|
40
|
+
workspaceId?: undefined;
|
|
41
|
+
} | {
|
|
42
|
+
tenant?: undefined;
|
|
43
|
+
workspaceId?: undefined;
|
|
44
|
+
}) & {
|
|
45
|
+
/** Host-authenticated external user id; every call runs through `asUser(user)`. */
|
|
46
|
+
user: string;
|
|
47
|
+
/** External identity source. Defaults to the facade's `source`, else `"default"`. */
|
|
48
|
+
source?: string | undefined;
|
|
49
|
+
};
|
|
50
|
+
/** Host auth hook: return the resolution, or a `Response` (for example 401) to reject. */
|
|
51
|
+
export type SessionProxyResolve = (request: Request) => Promise<SessionProxyResolution | Response> | SessionProxyResolution | Response;
|
|
52
|
+
export type SessionProxyContext = {
|
|
53
|
+
request: Request;
|
|
54
|
+
workspaceId: string;
|
|
55
|
+
user: string;
|
|
56
|
+
source: string;
|
|
57
|
+
/** The `asUser` client the proxy uses for this request. */
|
|
58
|
+
client: ProxyClient;
|
|
59
|
+
};
|
|
60
|
+
/** The only fields a browser may send when creating a session through the proxy. */
|
|
61
|
+
export type SessionProxyCreateInput = {
|
|
62
|
+
initialMessage: string;
|
|
63
|
+
/** Browser retry key; replay is scoped to the acting user by the API. */
|
|
64
|
+
idempotencyKey?: string | undefined;
|
|
65
|
+
};
|
|
66
|
+
/** Which browser action is about to forward a user message or response. */
|
|
67
|
+
export type SessionProxyMessageInput = {
|
|
68
|
+
/** Absent for `create`. */
|
|
69
|
+
sessionId?: string | undefined;
|
|
70
|
+
delivery: "create" | "send" | "steer" | "submit";
|
|
71
|
+
};
|
|
72
|
+
/** Server-side additions the host attaches to one forwarded user message or response. */
|
|
73
|
+
export type SessionProxyMessageExtras = {
|
|
74
|
+
/**
|
|
75
|
+
* Model-visible context for this message (current page, time zone, today's
|
|
76
|
+
* date). Placed before any context the browser sent. Not secret. Ignored for
|
|
77
|
+
* approval decisions and human-input responses, which are not new messages.
|
|
78
|
+
*/
|
|
79
|
+
modelContext?: string | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Header-only credential rotation for MCP servers already attached to the
|
|
82
|
+
* session (for example a fresh short-lived per-user bearer), applied
|
|
83
|
+
* atomically as the message or response is accepted. Ignored for `create`,
|
|
84
|
+
* where the `createSession` hook sets the initial headers.
|
|
85
|
+
*/
|
|
86
|
+
mcpCredentialUpdates?: SessionMcpCredentialUpdateInput[] | undefined;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Your product's own MCP tool server, attached to every session this proxy
|
|
90
|
+
* creates with a per-user bearer token. Verify it on every MCP request with
|
|
91
|
+
* `verifyToolRequest` from `@opengeni/sdk/tool-auth`. Tools always act as the
|
|
92
|
+
* chat's creator: in a shared chat, other members' messages do not change it.
|
|
93
|
+
*/
|
|
94
|
+
export type SessionProxyToolServer = {
|
|
95
|
+
/**
|
|
96
|
+
* Public HTTPS URL of your MCP endpoint, e.g. `https://app.example.com/api/mcp`.
|
|
97
|
+
* Defaults to `OPENGENI_TOOL_SERVER_URL`, which `verifyToolRequest` also reads.
|
|
98
|
+
*/
|
|
99
|
+
url?: string | undefined;
|
|
100
|
+
/** Session MCP server id (model-facing tool prefix). Defaults to `"app"`. */
|
|
101
|
+
id?: string | undefined;
|
|
102
|
+
/** Display name. */
|
|
103
|
+
name?: string | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Tools the user must approve before each call: list your write tools here
|
|
106
|
+
* (unprefixed MCP tool names), or `true` for every tool. Others run directly.
|
|
107
|
+
*/
|
|
108
|
+
approvals?: {
|
|
109
|
+
ask: string[] | true;
|
|
110
|
+
} | undefined;
|
|
111
|
+
/** Token signing secret. Defaults to `OPENGENI_API_KEY`; `verifyToolRequest` must use the same. */
|
|
112
|
+
secret?: string | undefined;
|
|
113
|
+
/** Token lifetime in seconds. Defaults to 24 hours; refreshed on every message, approval, and answer. */
|
|
114
|
+
ttlSeconds?: number | undefined;
|
|
115
|
+
};
|
|
116
|
+
export type SessionProxyHandlerOptions = {
|
|
117
|
+
/**
|
|
118
|
+
* Private (default) uses personal Knowledge and session-only reach; shared uses
|
|
119
|
+
* workspace Knowledge and reach. Isolated also gives each user their own tenant workspace.
|
|
120
|
+
*/
|
|
121
|
+
chats?: Chats | undefined;
|
|
122
|
+
/** Mandatory host auth hook, called on every request. */
|
|
123
|
+
resolve: SessionProxyResolve;
|
|
124
|
+
/**
|
|
125
|
+
* Host CSRF/session policy for non-GET requests. Without it the proxy only
|
|
126
|
+
* rejects `Sec-Fetch-Site: cross-site` mutations and requires JSON bodies;
|
|
127
|
+
* cookie-authenticated hosts should supply their existing CSRF check.
|
|
128
|
+
*/
|
|
129
|
+
authorizeMutation?: ((request: Request) => boolean | Promise<boolean>) | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Optional product-level session check (for example "this ticket's session
|
|
132
|
+
* belongs to this user"). OpenGeni still enforces membership and private
|
|
133
|
+
* visibility on every call.
|
|
134
|
+
*/
|
|
135
|
+
authorizeSession?: ((sessionId: string, context: SessionProxyContext) => boolean | Promise<boolean>) | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Server-controlled session creation. The browser supplies only
|
|
138
|
+
* {@link SessionProxyCreateInput}; this hook returns the complete create
|
|
139
|
+
* request (agent, tools, MCP servers, Skills, instructions, model policy). Omit it
|
|
140
|
+
* to disable browser-initiated creation entirely.
|
|
141
|
+
*/
|
|
142
|
+
createSession?: ((input: SessionProxyCreateInput, context: SessionProxyContext) => CreateSessionRequest | Response | Promise<CreateSessionRequest | Response>) | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* Called before every forwarded user message (send, steer, composer submit,
|
|
145
|
+
* and browser-started create), approval decision, and human-input response.
|
|
146
|
+
* Return server-owned `modelContext` (messages only) and MCP credential
|
|
147
|
+
* rotations, or a `Response` to reject the action.
|
|
148
|
+
*/
|
|
149
|
+
beforeForwardMessage?: ((input: SessionProxyMessageInput, context: SessionProxyContext) => SessionProxyMessageExtras | Response | undefined | Promise<SessionProxyMessageExtras | Response | undefined>) | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* Attach your product's MCP tool server to every session the `createSession`
|
|
152
|
+
* hook creates, authenticated as the resolved user. The proxy mints the
|
|
153
|
+
* token, adds the `mcpServers` entry (plus an eager ref when the hook lists
|
|
154
|
+
* explicit `tools`), and rotates the token on every send, steer, submit,
|
|
155
|
+
* approval decision, and human-input answer.
|
|
156
|
+
*/
|
|
157
|
+
toolServer?: SessionProxyToolServer | undefined;
|
|
158
|
+
/** Mount prefix, e.g. `/api/opengeni`. Defaults to everything before the first `/v1/`. */
|
|
159
|
+
basePath?: string | undefined;
|
|
160
|
+
/** Maximum JSON request body. Defaults to 1 MiB. */
|
|
161
|
+
maxBodyBytes?: number | undefined;
|
|
162
|
+
/** Expose composer file attachments (upload begin/complete, download URL). Defaults to true. */
|
|
163
|
+
files?: boolean | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Let the browser read a file from the session's sandbox (`POST .../fs/read`)
|
|
166
|
+
* so `sandbox:` links in agent replies can be downloaded. Only `path`,
|
|
167
|
+
* `encoding`, and `maxBytes` are forwarded; OpenGeni still requires the
|
|
168
|
+
* user's `files:read` permission on that session. Explicit opt-in, default
|
|
169
|
+
* false. Reads are confined to its working directory, including on Connected
|
|
170
|
+
* Machines; symlinked paths are refused.
|
|
171
|
+
*/
|
|
172
|
+
sandboxFiles?: boolean | undefined;
|
|
173
|
+
/**
|
|
174
|
+
* Serve the embedded artifact viewer and inline Site previews: reads of the
|
|
175
|
+
* editable artifacts and Sites a session produced, and live-ticket minting
|
|
176
|
+
* for the editor. Explicit opt-in, default false.
|
|
177
|
+
*
|
|
178
|
+
* Every request must name its session in the `x-opengeni-session-id` header
|
|
179
|
+
* (`SessionArtifactViewer` and `SessionConversation` do this). The proxy
|
|
180
|
+
* runs `authorizeSession`, then only forwards an artifact OpenGeni associates with
|
|
181
|
+
* that session, so the browser cannot open other workspace artifacts through
|
|
182
|
+
* it. Editing still requires the user's own `artifacts:publish` grant. Site
|
|
183
|
+
* tool calls are not proxied.
|
|
184
|
+
*
|
|
185
|
+
* The editor's live socket is ticket-authenticated and connects to OpenGeni
|
|
186
|
+
* directly; the ticket binds the source session and the API revalidates its
|
|
187
|
+
* authority while connected. `editableLiveUrl` overrides the derived URL.
|
|
188
|
+
* Site HTML streams with backpressure and cancellation, with a 25 MiB
|
|
189
|
+
* actual-byte ceiling (`SESSION_PROXY_SITE_HTML_MAX_BYTES`). Oversize streams
|
|
190
|
+
* fail with `SessionProxySiteHtmlTooLargeError` / `site_html_too_large`;
|
|
191
|
+
* headers cannot be replaced once streaming has begun.
|
|
192
|
+
*/
|
|
193
|
+
artifacts?: boolean | {
|
|
194
|
+
editableLiveUrl?: string | undefined;
|
|
195
|
+
} | undefined;
|
|
196
|
+
/**
|
|
197
|
+
* Chat list for `SessionList` / `OpenGeniChat` (`listSessionPage` only).
|
|
198
|
+
* `"mine"` (default) lists sessions the resolved user created; `"visible"`
|
|
199
|
+
* lists every session OpenGeni lets that user read in the workspace (shared
|
|
200
|
+
* chats included); `false` disables listing.
|
|
201
|
+
*/
|
|
202
|
+
sessionList?: "mine" | "visible" | false | undefined;
|
|
203
|
+
/** Let the user archive or restore their own chats. Defaults to true. */
|
|
204
|
+
archive?: boolean | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* Let the browser choose model, reasoning effort, and latency per message
|
|
207
|
+
* or draft (still limited by the workspace model catalog). When false those
|
|
208
|
+
* choices are removed from messages and draft saves. Saves use the actor's
|
|
209
|
+
* server-owned draft policy (initially the session defaults). Submit must repeat
|
|
210
|
+
* the saved policy unchanged as an integrity fence, not a new selection: the
|
|
211
|
+
* API atomically checks the saved revision/content or replays the original
|
|
212
|
+
* receipt. Hide the composer's model picker to match. Defaults to true.
|
|
213
|
+
* Pass `true` explicitly to also show end users the stock model picker
|
|
214
|
+
* (`SessionConversation`/`OpenGeniChat` hide it unless asked).
|
|
215
|
+
*/
|
|
216
|
+
modelSelection?: boolean | undefined;
|
|
217
|
+
/** SSE heartbeat interval. Defaults to 15 seconds. */
|
|
218
|
+
heartbeatMs?: number | undefined;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Create the packaged session proxy. Returns a web-standard
|
|
222
|
+
* `(Request) => Promise<Response>` for Next.js route handlers, Hono, Bun.serve,
|
|
223
|
+
* Cloudflare Workers, and similar hosts.
|
|
224
|
+
*/
|
|
225
|
+
export declare function createSessionProxyHandler(target: ProxyClient | ProxyFacade, options: SessionProxyHandlerOptions): (request: Request) => Promise<Response>;
|
|
226
|
+
/**
|
|
227
|
+
* The client-config `artifacts` capability a custom host proxy reports so
|
|
228
|
+
* `SessionArtifactViewer` can open editable artifacts: the live socket URL
|
|
229
|
+
* (ticket-authenticated, reached directly) and the proxied user's browser cache
|
|
230
|
+
* partition. `client` acts as that user (for example `asUser(...)`).
|
|
231
|
+
*/
|
|
232
|
+
export declare function artifactViewerCapability(input: {
|
|
233
|
+
client: Pick<ProxyClient, "getAccessContext" | "apiUrl"> & Partial<Pick<ProxyClient, "requestJson">>;
|
|
234
|
+
workspaceId: string;
|
|
235
|
+
/** Stable namespace of the host's user identities, mixed into the partition. */
|
|
236
|
+
source?: string | undefined;
|
|
237
|
+
editableLiveUrl?: string | undefined;
|
|
238
|
+
}): Promise<{
|
|
239
|
+
editableLiveUrl: string;
|
|
240
|
+
cachePartition: {
|
|
241
|
+
accountId: string;
|
|
242
|
+
principalId: string;
|
|
243
|
+
authorizationEpoch: string;
|
|
244
|
+
};
|
|
245
|
+
}>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SESSION_PROXY_SITE_HTML_MAX_BYTES,
|
|
3
|
+
SessionProxySiteHtmlTooLargeError,
|
|
4
|
+
artifactViewerCapability,
|
|
5
|
+
createSessionProxyHandler,
|
|
6
|
+
downloadSessionProxySiteHtml,
|
|
7
|
+
getSessionProxyArtifactAssociation,
|
|
8
|
+
getSessionProxyWorkspaceGrant
|
|
9
|
+
} from "./chunk-RWKB6YZG.js";
|
|
10
|
+
import "./chunk-UM4ZXXJR.js";
|
|
11
|
+
import "./chunk-U6CV2SXO.js";
|
|
12
|
+
import "./chunk-APXVSSSY.js";
|
|
13
|
+
import "./chunk-YIKA2QT4.js";
|
|
14
|
+
import "./chunk-V6GIY62B.js";
|
|
15
|
+
export {
|
|
16
|
+
SESSION_PROXY_SITE_HTML_MAX_BYTES,
|
|
17
|
+
SessionProxySiteHtmlTooLargeError,
|
|
18
|
+
artifactViewerCapability,
|
|
19
|
+
createSessionProxyHandler,
|
|
20
|
+
downloadSessionProxySiteHtml,
|
|
21
|
+
getSessionProxyArtifactAssociation,
|
|
22
|
+
getSessionProxyWorkspaceGrant
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=session-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { AUTOMATIC_SESSION_TITLE_FALLBACK, deriveAutomaticSessionTitlePreview, deriveSessionDisplayTitle, sessionTitleIsPending, } from "@opengeni/contracts/session-titles";
|
|
2
|
+
export type { SessionDisplayTitleInput, SessionDisplayTitleOptions, } from "@opengeni/contracts/session-titles";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|