@opengeni/sdk 3.3.2-canary.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1007 -72
- 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/app-links.d.ts +42 -0
- package/dist/app-links.js +66 -0
- package/dist/app-links.js.map +1 -0
- package/dist/artifact-catalog.d.ts +40 -0
- package/dist/artifact-client.d.ts +20 -8
- package/dist/artifacts.d.ts +1 -1
- package/dist/artifacts.js +8 -6
- package/dist/automations.js +8 -2
- package/dist/automations.js.map +1 -1
- package/dist/azure-live-transport.d.ts +32 -0
- package/dist/browser.d.ts +6 -2
- package/dist/browser.js +25 -5
- 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 +1369 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/openai.d.ts +30 -0
- package/dist/chat/opengeni.d.ts +129 -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-4AHR4KGA.js +301 -0
- package/dist/chunk-4AHR4KGA.js.map +1 -0
- package/dist/chunk-6GYGMLX4.js +332 -0
- package/dist/chunk-6GYGMLX4.js.map +1 -0
- package/dist/chunk-7EWT3PV6.js +368 -0
- package/dist/chunk-7EWT3PV6.js.map +1 -0
- package/dist/chunk-FTWVVPR6.js +1665 -0
- package/dist/chunk-FTWVVPR6.js.map +1 -0
- package/dist/{chunk-VYCTL62C.js → chunk-GZQSWAKD.js} +1 -1
- package/dist/chunk-GZQSWAKD.js.map +1 -0
- package/dist/chunk-KGEABAID.js +71 -0
- package/dist/chunk-KGEABAID.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-E5BNEG2D.js → chunk-NCU5OAN7.js} +27 -2
- package/dist/chunk-NCU5OAN7.js.map +1 -0
- package/dist/{chunk-BESZFWMU.js → chunk-OI5YLASH.js} +73 -2
- package/dist/chunk-OI5YLASH.js.map +1 -0
- package/dist/chunk-OV3POE62.js +359 -0
- package/dist/chunk-OV3POE62.js.map +1 -0
- package/dist/chunk-P7UWKORG.js +561 -0
- package/dist/chunk-P7UWKORG.js.map +1 -0
- package/dist/chunk-QGEIL4TR.js +195 -0
- package/dist/chunk-QGEIL4TR.js.map +1 -0
- package/dist/{chunk-GY6RQPCG.js → chunk-S2NLS3ES.js} +3598 -1278
- package/dist/chunk-S2NLS3ES.js.map +1 -0
- package/dist/chunk-UM4ZXXJR.js +9 -0
- package/dist/chunk-UM4ZXXJR.js.map +1 -0
- package/dist/{chunk-TFCLHRZK.js → chunk-UME3X7CP.js} +28 -32
- package/dist/chunk-UME3X7CP.js.map +1 -0
- package/dist/chunk-VT4YM4XQ.js +210 -0
- package/dist/chunk-VT4YM4XQ.js.map +1 -0
- package/dist/chunk-WSYYXONG.js +1602 -0
- package/dist/chunk-WSYYXONG.js.map +1 -0
- package/dist/{chunk-6NEPJ7NC.js → chunk-WVCJRSGJ.js} +119 -14
- package/dist/chunk-WVCJRSGJ.js.map +1 -0
- package/dist/chunk-X5ITQVXE.js +15 -0
- package/dist/chunk-X5ITQVXE.js.map +1 -0
- package/dist/chunk-XA7HVIHI.js +126 -0
- package/dist/chunk-XA7HVIHI.js.map +1 -0
- package/dist/{chunk-QTBAMHEF.js → chunk-YJCHB7R3.js} +60 -12
- package/dist/chunk-YJCHB7R3.js.map +1 -0
- package/dist/chunk-YKIHNLWD.js +153 -0
- package/dist/chunk-YKIHNLWD.js.map +1 -0
- package/dist/chunk-ZDUBPV33.js +277 -0
- package/dist/chunk-ZDUBPV33.js.map +1 -0
- package/dist/client.d.ts +1056 -118
- package/dist/codex-realtime-controller.d.ts +13 -0
- package/dist/codex-realtime-controller.js +4 -2
- package/dist/codex-realtime-v3-wire.d.ts +3 -2
- package/dist/codex-realtime.d.ts +5 -1
- package/dist/company-brain.d.ts +1 -11
- package/dist/core.d.ts +6 -2
- package/dist/core.js +23 -6
- package/dist/deprecation.d.ts +47 -0
- package/dist/document-authority-client.d.ts +24 -2
- package/dist/document-authority.js +7 -5
- package/dist/editable-artifacts/index.d.ts +1 -1
- package/dist/editable-artifacts/types.d.ts +12 -2
- package/dist/editable-artifacts.js +19 -3
- package/dist/editable-artifacts.js.map +1 -1
- package/dist/embedding-client.d.ts +129 -0
- package/dist/errors.d.ts +64 -1
- package/dist/external-vault-receiver.d.ts +203 -0
- package/dist/external-vault-receiver.js +564 -0
- package/dist/external-vault-receiver.js.map +1 -0
- 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 +61 -11
- package/dist/index.js +555 -338
- package/dist/index.js.map +1 -1
- package/dist/insights-usage.d.ts +33 -0
- package/dist/insights-usage.js +7 -0
- package/dist/insights-usage.js.map +1 -0
- package/dist/interaction.d.ts +165 -71
- package/dist/interaction.js +2 -2
- package/dist/knowledge.d.ts +7 -0
- package/dist/knowledge.js +20 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/known-tools.d.ts +4 -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 +17 -0
- package/dist/model-display.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/pr-review-client.d.ts +1 -1
- package/dist/pr-review.d.ts +1 -1
- package/dist/pr-review.js.map +1 -1
- package/dist/preference-registry.d.ts +1 -1
- package/dist/prepared-mcp-setup.d.ts +5 -0
- package/dist/proxy.d.ts +13 -11
- package/dist/realtime.d.ts +1 -1
- package/dist/realtime.js +253 -7
- package/dist/realtime.js.map +1 -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 +28 -0
- package/dist/session-proxy.d.ts +334 -0
- package/dist/session-proxy.js +24 -0
- package/dist/session-proxy.js.map +1 -0
- package/dist/session-titles.d.ts +2 -28
- package/dist/session-usage-limits.d.ts +10 -0
- package/dist/session-usage-limits.js +43 -0
- package/dist/session-usage-limits.js.map +1 -0
- package/dist/shared-catalog-loader.d.ts +34 -0
- package/dist/site-ai.d.ts +35 -0
- package/dist/site-bridge-host.d.ts +112 -0
- package/dist/site-bridge-host.js +286 -0
- package/dist/site-bridge-host.js.map +1 -0
- package/dist/site-browser-entry.d.ts +1 -0
- package/dist/site-browser-runtime.gen.d.ts +1 -0
- package/dist/site-data.d.ts +178 -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 +17 -0
- package/dist/site-sql.d.ts +31 -0
- package/dist/site-tool-bridge.d.ts +57 -0
- package/dist/site.d.ts +186 -0
- package/dist/site.js +63 -0
- package/dist/site.js.map +1 -0
- package/dist/skills.d.ts +75 -0
- package/dist/sse.d.ts +1 -1
- 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-37DCTCNZ.js +12 -0
- package/dist/tools-37DCTCNZ.js.map +1 -0
- package/dist/tools.d.ts +81 -0
- package/dist/transcription.d.ts +1 -1
- package/dist/types.d.ts +2785 -592
- 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/vault-types.d.ts +324 -0
- package/dist/vaults-api.d.ts +65 -0
- package/dist/workspace-artifacts.d.ts +47 -5
- package/dist/workspace-instruction-policies.d.ts +2 -2
- package/dist/workspace-integrations.d.ts +74 -0
- package/dist/workspace-integrations.js +67 -0
- package/dist/workspace-integrations.js.map +1 -0
- package/dist/workspace-state.d.ts +8 -71
- package/package.json +99 -5
- 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/app-links.ts +117 -0
- package/src/artifact-catalog.ts +51 -0
- package/src/artifact-client.ts +40 -49
- package/src/artifacts.ts +1 -0
- package/src/automations-client.ts +8 -2
- package/src/azure-live-transport.ts +286 -0
- package/src/browser.ts +35 -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 +88 -0
- package/src/chat/openai.ts +439 -0
- package/src/chat/opengeni.ts +737 -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 +5595 -1847
- package/src/codex-realtime-controller.ts +163 -8
- package/src/codex-realtime-v3-wire.ts +4 -3
- package/src/codex-realtime-v3.ts +12 -3
- package/src/codex-realtime.ts +11 -3
- package/src/company-brain.ts +0 -40
- package/src/core.ts +18 -0
- package/src/deprecation.ts +149 -0
- package/src/document-authority-client.ts +104 -1
- package/src/editable-artifacts/controller.ts +36 -2
- package/src/editable-artifacts/index.ts +1 -0
- package/src/editable-artifacts/types.ts +29 -16
- package/src/embedding-client.ts +519 -0
- package/src/errors.ts +281 -5
- package/src/external-vault-receiver.ts +914 -0
- 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 +592 -65
- package/src/insights-usage.ts +64 -0
- package/src/interaction.ts +315 -93
- package/src/knowledge.ts +72 -0
- package/src/known-tools.ts +279 -0
- package/src/message-links.ts +178 -0
- package/src/model-context.ts +113 -0
- package/src/model-display.ts +11 -0
- package/src/organization-integration-policy.ts +54 -0
- package/src/pr-review-client.ts +1 -1
- package/src/pr-review.ts +1 -1
- package/src/preference-registry.ts +2 -0
- package/src/prepared-mcp-setup.ts +123 -0
- package/src/proxy.ts +23 -12
- package/src/realtime.ts +15 -6
- 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 +68 -0
- package/src/session-proxy.ts +2098 -0
- package/src/session-titles.ts +8 -82
- package/src/session-usage-limits.ts +71 -0
- package/src/shared-catalog-loader.ts +169 -0
- package/src/site-ai.ts +284 -0
- package/src/site-bridge-host.ts +422 -0
- package/src/site-browser-entry.ts +6 -0
- package/src/site-browser-runtime.gen.ts +2 -0
- package/src/site-data.ts +372 -0
- package/src/site-document.test.ts +64 -0
- package/src/site-document.ts +18 -0
- package/src/site-http.ts +171 -0
- package/src/site-sql.ts +153 -0
- package/src/site-tool-bridge.ts +401 -0
- package/src/site.ts +878 -0
- package/src/skills.ts +69 -0
- package/src/sse.ts +9 -3
- package/src/stream.ts +33 -10
- package/src/tenant-workspaces.ts +148 -0
- package/src/tool-auth.ts +301 -0
- package/src/tool-display-metadata.ts +27 -0
- package/src/tools.ts +452 -0
- package/src/transcription.ts +3 -0
- package/src/types.ts +3142 -594
- package/src/usage-allowances.ts +189 -0
- package/src/vault-types.ts +379 -0
- package/src/vaults-api.ts +339 -0
- package/src/workspace-artifacts.ts +55 -6
- package/src/workspace-instruction-policies.ts +2 -1
- package/src/workspace-integrations.ts +402 -0
- package/src/workspace-state.ts +8 -82
- package/dist/chunk-6NEPJ7NC.js.map +0 -1
- package/dist/chunk-BESZFWMU.js.map +0 -1
- package/dist/chunk-E5BNEG2D.js.map +0 -1
- package/dist/chunk-GY6RQPCG.js.map +0 -1
- package/dist/chunk-OO5LPTO7.js +0 -132
- package/dist/chunk-OO5LPTO7.js.map +0 -1
- package/dist/chunk-QTBAMHEF.js.map +0 -1
- package/dist/chunk-TFCLHRZK.js.map +0 -1
- package/dist/chunk-VYCTL62C.js.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { OpenGeniClient } from "./client";
|
|
2
|
+
|
|
3
|
+
export type OrganizationIntegrationPolicy = {
|
|
4
|
+
mode: "unrestricted" | "restricted";
|
|
5
|
+
allowedIntegrationKeys: string[];
|
|
6
|
+
revision: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type UpdateOrganizationIntegrationPolicyRequest = {
|
|
10
|
+
mode: "unrestricted" | "restricted";
|
|
11
|
+
allowedIntegrationKeys: string[];
|
|
12
|
+
expectedRevision: number;
|
|
13
|
+
operationId: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type PolicyClient = Pick<OpenGeniClient, "requestJson">;
|
|
17
|
+
|
|
18
|
+
export type OrganizationIntegrationCatalog = {
|
|
19
|
+
integrations: Array<{ key: string; label: string; kind: "curated" | "custom" }>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Discover stable policy identities; integrations must not guess provider identifiers. */
|
|
23
|
+
export async function getOrganizationIntegrationCatalog(
|
|
24
|
+
client: PolicyClient,
|
|
25
|
+
organizationId: string,
|
|
26
|
+
): Promise<OrganizationIntegrationCatalog> {
|
|
27
|
+
return client.requestJson(
|
|
28
|
+
"GET",
|
|
29
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/integration-policy/catalog`,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function getOrganizationIntegrationPolicy(
|
|
34
|
+
client: PolicyClient,
|
|
35
|
+
organizationId: string,
|
|
36
|
+
): Promise<OrganizationIntegrationPolicy> {
|
|
37
|
+
return client.requestJson(
|
|
38
|
+
"GET",
|
|
39
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/integration-policy`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Retain operationId and the exact request when reconciling an uncertain outcome. */
|
|
44
|
+
export async function updateOrganizationIntegrationPolicy(
|
|
45
|
+
client: PolicyClient,
|
|
46
|
+
organizationId: string,
|
|
47
|
+
request: UpdateOrganizationIntegrationPolicyRequest,
|
|
48
|
+
): Promise<OrganizationIntegrationPolicy> {
|
|
49
|
+
return client.requestJson(
|
|
50
|
+
"PUT",
|
|
51
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/integration-policy`,
|
|
52
|
+
request,
|
|
53
|
+
);
|
|
54
|
+
}
|
package/src/pr-review-client.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
|
|
13
13
|
export type OpenGeniPrReviewTransport = Pick<OpenGeniCoreClient, "requestJson" | "requestVoid">;
|
|
14
14
|
|
|
15
|
-
/** Optional
|
|
15
|
+
/** Optional Opengeni Review Bot API surface, isolated from the eager core client graph. */
|
|
16
16
|
export class OpenGeniPrReviewClient {
|
|
17
17
|
constructor(private readonly client: OpenGeniPrReviewTransport) {}
|
|
18
18
|
|
package/src/pr-review.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Optional
|
|
1
|
+
/** Optional Opengeni Review Bot API client; import this entry only where the capability is used. */
|
|
2
2
|
export { OpenGeniPrReviewClient } from "./pr-review-client";
|
|
3
3
|
export type { OpenGeniPrReviewTransport } from "./pr-review-client";
|
|
4
4
|
export type {
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CustomMcpSetupRequest,
|
|
3
|
+
PreparedMcpSetup,
|
|
4
|
+
} from "@opengeni/contracts/prepared-mcp-setup";
|
|
5
|
+
|
|
6
|
+
const record = (value: unknown): value is Record<string, unknown> =>
|
|
7
|
+
value !== null && typeof value === "object" && !Array.isArray(value);
|
|
8
|
+
const keys = (value: Record<string, unknown>, allowed: string[]) =>
|
|
9
|
+
Object.keys(value).every((key) => allowed.includes(key));
|
|
10
|
+
const text = (value: unknown, max: number, min = 1): value is string =>
|
|
11
|
+
typeof value === "string" && value.length >= min && value.length <= max;
|
|
12
|
+
const trimmedText = (value: unknown, max: number): value is string =>
|
|
13
|
+
typeof value === "string" && text(value.trim(), max);
|
|
14
|
+
const headerPart = (value: unknown): value is string =>
|
|
15
|
+
text(value, 16_384, 0) && !/[\r\n\0]/.test(value);
|
|
16
|
+
const fieldId = (value: unknown): value is string =>
|
|
17
|
+
typeof value === "string" && /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(value);
|
|
18
|
+
const endpoint = (value: unknown): value is string => {
|
|
19
|
+
if (!text(value, 2048)) return false;
|
|
20
|
+
try {
|
|
21
|
+
const url = new URL(value);
|
|
22
|
+
return url.protocol === "https:" && !url.username && !url.password && !url.search && !url.hash;
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** Browser/native-safe display projection. The API owns authoritative schema
|
|
29
|
+
* validation; parity tests keep this lightweight parser aligned without pulling
|
|
30
|
+
* schema runtimes into the SDK or replaying unknown fields into a secret form. */
|
|
31
|
+
export function parseCustomMcpSetupRequest(value: unknown): CustomMcpSetupRequest | null {
|
|
32
|
+
if (
|
|
33
|
+
!record(value) ||
|
|
34
|
+
!keys(value, ["kind", "name", "endpointUrl", "rationale", "ownership", "mcpSetup"]) ||
|
|
35
|
+
value.kind !== "mcp" ||
|
|
36
|
+
!trimmedText(value.name, 256) ||
|
|
37
|
+
!endpoint(value.endpointUrl) ||
|
|
38
|
+
!trimmedText(value.rationale, 2000)
|
|
39
|
+
)
|
|
40
|
+
return null;
|
|
41
|
+
const base = {
|
|
42
|
+
kind: "mcp" as const,
|
|
43
|
+
name: value.name.trim(),
|
|
44
|
+
endpointUrl: value.endpointUrl,
|
|
45
|
+
rationale: value.rationale.trim(),
|
|
46
|
+
};
|
|
47
|
+
if (value.ownership === undefined && value.mcpSetup === undefined) return base;
|
|
48
|
+
if (value.ownership !== "personal" && value.ownership !== "workspace") return null;
|
|
49
|
+
const setup = value.mcpSetup;
|
|
50
|
+
if (
|
|
51
|
+
!record(setup) ||
|
|
52
|
+
!keys(setup, ["name", "endpointUrl", "headers", "secretFields"]) ||
|
|
53
|
+
!trimmedText(setup.name, 256) ||
|
|
54
|
+
setup.name.trim() !== base.name ||
|
|
55
|
+
setup.endpointUrl !== base.endpointUrl ||
|
|
56
|
+
!Array.isArray(setup.headers) ||
|
|
57
|
+
setup.headers.length < 1 ||
|
|
58
|
+
setup.headers.length > 32 ||
|
|
59
|
+
!Array.isArray(setup.secretFields) ||
|
|
60
|
+
setup.secretFields.length > 32
|
|
61
|
+
)
|
|
62
|
+
return null;
|
|
63
|
+
const fields: PreparedMcpSetup["secretFields"] = [];
|
|
64
|
+
const fieldIds = new Set<string>();
|
|
65
|
+
for (const field of setup.secretFields) {
|
|
66
|
+
if (
|
|
67
|
+
!record(field) ||
|
|
68
|
+
!keys(field, ["id", "label"]) ||
|
|
69
|
+
!fieldId(field.id) ||
|
|
70
|
+
!trimmedText(field.label, 256) ||
|
|
71
|
+
fieldIds.has(field.id)
|
|
72
|
+
)
|
|
73
|
+
return null;
|
|
74
|
+
fieldIds.add(field.id);
|
|
75
|
+
fields.push({ id: field.id, label: field.label.trim() });
|
|
76
|
+
}
|
|
77
|
+
const headers: PreparedMcpSetup["headers"] = [];
|
|
78
|
+
const names = new Set<string>();
|
|
79
|
+
const used = new Set<string>();
|
|
80
|
+
for (const header of setup.headers) {
|
|
81
|
+
if (
|
|
82
|
+
!record(header) ||
|
|
83
|
+
!text(header.name, 256) ||
|
|
84
|
+
!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(header.name)
|
|
85
|
+
)
|
|
86
|
+
return null;
|
|
87
|
+
const name = header.name.toLowerCase();
|
|
88
|
+
if (names.has(name)) return null;
|
|
89
|
+
names.add(name);
|
|
90
|
+
if ("value" in header) {
|
|
91
|
+
if (
|
|
92
|
+
!keys(header, ["name", "value"]) ||
|
|
93
|
+
!headerPart(header.value) ||
|
|
94
|
+
!header.value ||
|
|
95
|
+
["authorization", "proxy-authorization", "cookie", "x-api-key", "api-key"].includes(name)
|
|
96
|
+
)
|
|
97
|
+
return null;
|
|
98
|
+
headers.push({ name: header.name, value: header.value });
|
|
99
|
+
} else {
|
|
100
|
+
if (
|
|
101
|
+
!keys(header, ["name", "secret", "prefix", "suffix"]) ||
|
|
102
|
+
!fieldId(header.secret) ||
|
|
103
|
+
!fieldIds.has(header.secret) ||
|
|
104
|
+
(header.prefix !== undefined && !headerPart(header.prefix)) ||
|
|
105
|
+
(header.suffix !== undefined && !headerPart(header.suffix))
|
|
106
|
+
)
|
|
107
|
+
return null;
|
|
108
|
+
used.add(header.secret);
|
|
109
|
+
headers.push({
|
|
110
|
+
name: header.name,
|
|
111
|
+
secret: header.secret,
|
|
112
|
+
...(header.prefix !== undefined ? { prefix: header.prefix as string } : {}),
|
|
113
|
+
...(header.suffix !== undefined ? { suffix: header.suffix as string } : {}),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (used.size !== fieldIds.size) return null;
|
|
118
|
+
return {
|
|
119
|
+
...base,
|
|
120
|
+
ownership: value.ownership,
|
|
121
|
+
mcpSetup: { name: base.name, endpointUrl: base.endpointUrl, headers, secretFields: fields },
|
|
122
|
+
};
|
|
123
|
+
}
|
package/src/proxy.ts
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
import type { OpenGeniClient } from "./client";
|
|
2
|
-
import type
|
|
2
|
+
import { sessionEventStreamCoveredThrough, type StreamSessionEventsOptions } from "./stream";
|
|
3
3
|
import type { SessionEvent } from "./types";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Proxy-through-your-own-API helpers.
|
|
7
7
|
*
|
|
8
|
-
* The intended pattern: a customer's server consumes the
|
|
8
|
+
* The intended pattern: a customer's server consumes the Opengeni event
|
|
9
9
|
* stream with its own API key (`client.streamEvents(...)`) and re-emits it to
|
|
10
|
-
* its browser clients over its own authenticated endpoint — the
|
|
10
|
+
* its browser clients over its own authenticated endpoint — the Opengeni key
|
|
11
11
|
* never reaches the browser. The re-emitted wire format is identical to
|
|
12
|
-
*
|
|
12
|
+
* Opengeni's own SSE stream (`id: <sequence>`, `event: <type>`,
|
|
13
13
|
* `data: <event JSON>`), so the browser side can consume it with this same
|
|
14
14
|
* SDK's streaming core (or a plain `EventSource`), including resume via
|
|
15
|
-
* `?after=` / `Last-Event-ID`.
|
|
15
|
+
* `?after=` / `Last-Event-ID`. An ordinary event uses its own sequence as the
|
|
16
|
+
* SSE `id`; a compact event uses the server-owned sequence it covers through.
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
|
-
/** Format one event
|
|
19
|
+
/** Format one event with the exact Opengeni data and resume-cursor semantics. */
|
|
19
20
|
export function formatSseEvent(event: SessionEvent): string {
|
|
20
|
-
|
|
21
|
+
const streamedCoverage = sessionEventStreamCoveredThrough(event);
|
|
22
|
+
const projectedCoverage = event.coveredThrough;
|
|
23
|
+
const coveredThrough =
|
|
24
|
+
streamedCoverage ??
|
|
25
|
+
(typeof projectedCoverage === "number" &&
|
|
26
|
+
Number.isSafeInteger(projectedCoverage) &&
|
|
27
|
+
projectedCoverage >= event.sequence
|
|
28
|
+
? projectedCoverage
|
|
29
|
+
: event.sequence);
|
|
30
|
+
return `id: ${coveredThrough}\nevent: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`;
|
|
21
31
|
}
|
|
22
32
|
|
|
23
33
|
export type SseReStreamOptions = {
|
|
@@ -28,7 +38,7 @@ export type SseReStreamOptions = {
|
|
|
28
38
|
heartbeatMs?: number;
|
|
29
39
|
/**
|
|
30
40
|
* Called when the downstream consumer cancels (e.g. the browser
|
|
31
|
-
* disconnected). Use it to abort the upstream
|
|
41
|
+
* disconnected). Use it to abort the upstream Opengeni stream — an async
|
|
32
42
|
* iterator that is mid-`await` cannot be interrupted by `return()` alone.
|
|
33
43
|
*/
|
|
34
44
|
onCancel?: () => void;
|
|
@@ -115,8 +125,9 @@ export function sessionEventsToSseResponse(
|
|
|
115
125
|
|
|
116
126
|
/**
|
|
117
127
|
* Read the resume cursor a reconnecting SSE client sent: the `after` query
|
|
118
|
-
* parameter, or the standard `Last-Event-ID` header
|
|
119
|
-
*
|
|
128
|
+
* parameter, or the standard `Last-Event-ID` header. Re-emitted streams set
|
|
129
|
+
* `id:` to the event sequence for ordinary events and the covered high-water
|
|
130
|
+
* sequence for compact events. Returns 0 (full replay) when absent.
|
|
120
131
|
*/
|
|
121
132
|
export function resumeSequenceFromRequest(request: Request): number {
|
|
122
133
|
const url = new URL(request.url);
|
|
@@ -136,12 +147,12 @@ export type ProxySessionEventStreamOptions = Omit<StreamSessionEventsOptions, "a
|
|
|
136
147
|
};
|
|
137
148
|
|
|
138
149
|
/**
|
|
139
|
-
* One-call proxy: consume the
|
|
150
|
+
* One-call proxy: consume the Opengeni stream server-side and return an SSE
|
|
140
151
|
* `Response` for your own browser clients. Works anywhere WHATWG `Response`
|
|
141
152
|
* is the handler return type (Hono, Next.js route handlers, Bun.serve,
|
|
142
153
|
* Cloudflare Workers, ...).
|
|
143
154
|
*
|
|
144
|
-
* The upstream
|
|
155
|
+
* The upstream Opengeni connection is torn down when the downstream client
|
|
145
156
|
* disconnects, and also when `options.signal` (e.g. the incoming request's
|
|
146
157
|
* signal) aborts.
|
|
147
158
|
*/
|
package/src/realtime.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createAzureLiveTransportStarter } from "./azure-live-transport";
|
|
1
2
|
/**
|
|
2
3
|
* Public, provider-neutral realtime browser SDK.
|
|
3
4
|
*
|
|
@@ -34,7 +35,7 @@ export type SessionRealtimeClientLike = CodexRealtimeControllerClient & {
|
|
|
34
35
|
): Promise<WorkspaceRealtimeModelCatalogResponse>;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
|
-
export type SessionRealtimeTransportKind = "codex" | "gateway" | "xai-subscription";
|
|
38
|
+
export type SessionRealtimeTransportKind = "codex" | "gateway" | "xai-subscription" | "azure-live";
|
|
38
39
|
|
|
39
40
|
/** Provider-neutral names for the existing, battle-tested controller projection. */
|
|
40
41
|
export type SessionRealtimeController = CodexRealtimeController;
|
|
@@ -57,6 +58,7 @@ export type CreateSessionRealtimeControllerOptions = Omit<
|
|
|
57
58
|
export function sessionRealtimeTransportKind(
|
|
58
59
|
model: SessionRealtimeModel,
|
|
59
60
|
): SessionRealtimeTransportKind {
|
|
61
|
+
if (model === "opengeni-azure/gpt-live-1") return "azure-live";
|
|
60
62
|
if (model === "gpt-live-1-boulder-alpha") return "codex";
|
|
61
63
|
if (model === "supergrok/grok-voice-think-fast-2.0") return "xai-subscription";
|
|
62
64
|
return "gateway";
|
|
@@ -74,11 +76,18 @@ export function createSessionRealtimeController(
|
|
|
74
76
|
return createCodexRealtimeController({
|
|
75
77
|
...options,
|
|
76
78
|
ownerStorageNamespace: sessionRealtimeOwnerStorageNamespace(options.model),
|
|
77
|
-
...(transport === "
|
|
78
|
-
? {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
...(transport === "azure-live"
|
|
80
|
+
? {
|
|
81
|
+
startTransport: createAzureLiveTransportStarter({
|
|
82
|
+
remoteAudio: options.remoteAudio,
|
|
83
|
+
createPeerConnection: options.createPeerConnection,
|
|
84
|
+
}),
|
|
85
|
+
}
|
|
86
|
+
: transport === "gateway"
|
|
87
|
+
? { startTransport: createGatewayRealtimeTransportStarter() }
|
|
88
|
+
: transport === "xai-subscription"
|
|
89
|
+
? { startTransport: createXaiSubscriptionRealtimeTransportStarter() }
|
|
90
|
+
: {}),
|
|
82
91
|
});
|
|
83
92
|
}
|
|
84
93
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { OpenGeniClient } from "./client";
|
|
2
|
+
import type {
|
|
3
|
+
AppendArchivedSessionEventsRequest,
|
|
4
|
+
AppendArchivedSessionEventsResponse,
|
|
5
|
+
ImportArchivedSessionRequest,
|
|
6
|
+
ImportArchivedSessionResponse,
|
|
7
|
+
} from "@opengeni/contracts";
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
ArchivedSessionImportEvent,
|
|
11
|
+
AppendArchivedSessionEventsRequest,
|
|
12
|
+
AppendArchivedSessionEventsResponse,
|
|
13
|
+
ImportArchivedSessionRequest,
|
|
14
|
+
ImportArchivedSessionResponse,
|
|
15
|
+
SessionImportedArchive,
|
|
16
|
+
} from "@opengeni/contracts";
|
|
17
|
+
|
|
18
|
+
type SessionHistoryImportClient = Pick<OpenGeniClient, "requestJson">;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Server-only migration of a read-only archive, not model-facing conversation
|
|
22
|
+
* history. Use an asUser client to preserve the verified creator/owner. Persist
|
|
23
|
+
* importId and retry the exact request after an uncertain outcome.
|
|
24
|
+
* Requires sessions:create in the authenticated actor's permissions.
|
|
25
|
+
*/
|
|
26
|
+
export function importArchivedSession(
|
|
27
|
+
client: SessionHistoryImportClient,
|
|
28
|
+
workspaceId: string,
|
|
29
|
+
request: ImportArchivedSessionRequest,
|
|
30
|
+
): Promise<ImportArchivedSessionResponse> {
|
|
31
|
+
return client.requestJson(
|
|
32
|
+
"POST",
|
|
33
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/session-imports`,
|
|
34
|
+
request,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Append historical events at the acknowledged nextOffset. Retrying the exact
|
|
40
|
+
* batchId, offset and events replays its receipt; conflicting reuse returns 409.
|
|
41
|
+
* Each request accepts at most 100 events / 1 MiB, with 256 KiB per event.
|
|
42
|
+
* Requires sessions:control and the same authenticated importer.
|
|
43
|
+
*/
|
|
44
|
+
export function appendArchivedSessionEvents(
|
|
45
|
+
client: SessionHistoryImportClient,
|
|
46
|
+
workspaceId: string,
|
|
47
|
+
importId: string,
|
|
48
|
+
request: AppendArchivedSessionEventsRequest,
|
|
49
|
+
): Promise<AppendArchivedSessionEventsResponse> {
|
|
50
|
+
return client.requestJson(
|
|
51
|
+
"POST",
|
|
52
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/session-imports/${encodeURIComponent(importId)}/events`,
|
|
53
|
+
request,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Import through an existing external tenant mapping; this does not onboard it. */
|
|
58
|
+
export function importExternalWorkspaceArchivedSession(
|
|
59
|
+
client: SessionHistoryImportClient,
|
|
60
|
+
source: string,
|
|
61
|
+
externalId: string,
|
|
62
|
+
request: ImportArchivedSessionRequest,
|
|
63
|
+
): Promise<ImportArchivedSessionResponse> {
|
|
64
|
+
return client.requestJson(
|
|
65
|
+
"POST",
|
|
66
|
+
`/v1/workspaces/external/${encodeURIComponent(source)}/${encodeURIComponent(externalId)}/session-imports`,
|
|
67
|
+
request,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Append to an archive through the same external tenant mapping and actor. */
|
|
72
|
+
export function appendExternalWorkspaceArchivedSessionEvents(
|
|
73
|
+
client: SessionHistoryImportClient,
|
|
74
|
+
source: string,
|
|
75
|
+
externalId: string,
|
|
76
|
+
importId: string,
|
|
77
|
+
request: AppendArchivedSessionEventsRequest,
|
|
78
|
+
): Promise<AppendArchivedSessionEventsResponse> {
|
|
79
|
+
return client.requestJson(
|
|
80
|
+
"POST",
|
|
81
|
+
`/v1/workspaces/external/${encodeURIComponent(source)}/${encodeURIComponent(externalId)}/session-imports/${encodeURIComponent(importId)}/events`,
|
|
82
|
+
request,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sessionListEntry } from "@opengeni/contracts/session-list-entries";
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
|
|
12
|
+
export type SessionMessageSearchMatch = {
|
|
13
|
+
sessionId: string;
|
|
14
|
+
sessionTitle: string | null;
|
|
15
|
+
eventId: string;
|
|
16
|
+
sequence: number;
|
|
17
|
+
turnId: string | null;
|
|
18
|
+
role: "user" | "assistant";
|
|
19
|
+
messageId: string | null;
|
|
20
|
+
/** Zero-based UTF-16 offset in the complete visible message. */
|
|
21
|
+
messageMatchOffset: number;
|
|
22
|
+
/** Zero-based UTF-16 offsets in text; matchEnd is exclusive. */
|
|
23
|
+
snippet: { text: string; matchStart: number; matchEnd: number };
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type SessionMessageSearchResponse = {
|
|
27
|
+
matches: SessionMessageSearchMatch[];
|
|
28
|
+
nextCursor: string | null;
|
|
29
|
+
/** Empty advancing pages are valid. Continue until false. */
|
|
30
|
+
hasMore: boolean;
|
|
31
|
+
/** Cumulative distinct messages visited in this live traversal. */
|
|
32
|
+
scannedMessages: number;
|
|
33
|
+
/** Cumulative matching messages, or session representatives with groupBy=session. */
|
|
34
|
+
matchedMessageCount: number;
|
|
35
|
+
/** Cumulative occurrences, or session representatives with groupBy=session. */
|
|
36
|
+
matchedOccurrenceCount: number;
|
|
37
|
+
/** True only on exhaustion. Concurrent mutations require a fresh traversal. */
|
|
38
|
+
countIsExact: boolean;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** Exact selected event reference from a search match; no payload fields are read. */
|
|
42
|
+
export type SessionMessagePreviewReference = { eventId: string; sequence: number };
|
|
43
|
+
|
|
44
|
+
/** A complete visible message, or an explicit over-12,000-UTF-16-unit result. */
|
|
45
|
+
export type SessionMessagePreview =
|
|
46
|
+
| { status: "available"; text: string }
|
|
47
|
+
| { status: "unavailable" };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { OpenGeniEmbeddingClient } from "./embedding-client";
|
|
2
|
+
import type { OpenGeniRequestOptions, FetchResponse } from "./client";
|
|
3
|
+
import type { AccessGrant } from "./types";
|
|
4
|
+
|
|
5
|
+
/** Maximum actual UTF-8 bytes forwarded for one embedded Site HTML response. */
|
|
6
|
+
export const SESSION_PROXY_SITE_HTML_MAX_BYTES = 25 * 1024 * 1024;
|
|
7
|
+
|
|
8
|
+
/** A streaming Site download exceeded the host proxy's actual-byte ceiling. */
|
|
9
|
+
export class SessionProxySiteHtmlTooLargeError extends Error {
|
|
10
|
+
readonly code = "site_html_too_large";
|
|
11
|
+
readonly limitBytes = SESSION_PROXY_SITE_HTML_MAX_BYTES;
|
|
12
|
+
|
|
13
|
+
constructor() {
|
|
14
|
+
super(`Site HTML exceeds the ${SESSION_PROXY_SITE_HTML_MAX_BYTES}-byte proxy limit.`);
|
|
15
|
+
this.name = "SessionProxySiteHtmlTooLargeError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Server-only effective grant read; never derive external authority from access/me snapshots. */
|
|
20
|
+
export function getSessionProxyWorkspaceGrant(
|
|
21
|
+
client: Pick<OpenGeniEmbeddingClient, "requestJson">,
|
|
22
|
+
workspaceId: string,
|
|
23
|
+
options: OpenGeniRequestOptions = {},
|
|
24
|
+
): Promise<AccessGrant> {
|
|
25
|
+
return client.requestJson(
|
|
26
|
+
"GET",
|
|
27
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/access/grant`,
|
|
28
|
+
undefined,
|
|
29
|
+
{},
|
|
30
|
+
options,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Exact association read. The API reauthorizes the source session on every
|
|
36
|
+
* call. `retained` proves a generated image or video, or a published sandbox
|
|
37
|
+
* file, originated in that session.
|
|
38
|
+
*/
|
|
39
|
+
export function getSessionProxyArtifactAssociation(
|
|
40
|
+
client: Pick<OpenGeniEmbeddingClient, "requestJson">,
|
|
41
|
+
workspaceId: string,
|
|
42
|
+
sessionId: string,
|
|
43
|
+
kind: "editable" | "site" | "retained",
|
|
44
|
+
artifactId: string,
|
|
45
|
+
options: OpenGeniRequestOptions = {},
|
|
46
|
+
): Promise<{ sessionId: string; artifactId: string; kind: "editable" | "site" | "retained" }> {
|
|
47
|
+
return client.requestJson(
|
|
48
|
+
"GET",
|
|
49
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/sessions/${encodeURIComponent(sessionId)}/artifact-associations/${encodeURIComponent(artifactId)}`,
|
|
50
|
+
undefined,
|
|
51
|
+
{ kind },
|
|
52
|
+
options,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Authenticated response stream for the server proxy; does not buffer Site HTML. */
|
|
57
|
+
export function downloadSessionProxySiteHtml(
|
|
58
|
+
client: Pick<OpenGeniEmbeddingClient, "requestJsonResponse">,
|
|
59
|
+
workspaceId: string,
|
|
60
|
+
artifactId: string,
|
|
61
|
+
options: { versionId: string; signal?: AbortSignal },
|
|
62
|
+
): Promise<FetchResponse> {
|
|
63
|
+
return client.requestJsonResponse(
|
|
64
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/published-artifacts/${encodeURIComponent(artifactId)}/html`,
|
|
65
|
+
{ versionId: options.versionId },
|
|
66
|
+
options,
|
|
67
|
+
);
|
|
68
|
+
}
|