@opengeni/sdk 3.3.2 → 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 +7 -2
- package/dist/browser.js +27 -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-JUS2UYRP.js → chunk-NCU5OAN7.js} +27 -2
- package/dist/chunk-NCU5OAN7.js.map +1 -0
- package/dist/{chunk-YXQX7RQT.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-TRNI7KEO.js → chunk-S2NLS3ES.js} +3669 -1281
- 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-QT3KFVDP.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-C2H7HBNP.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-KKRO2VCP.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 +1068 -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 +7 -2
- package/dist/core.js +25 -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 +76 -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 +62 -11
- package/dist/index.js +557 -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/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/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 +2807 -583
- 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 +103 -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 +37 -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 +5697 -1833
- 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 +20 -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 +303 -4
- 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 +603 -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/model-picker-order.ts +6 -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 +3170 -582
- 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-C2H7HBNP.js.map +0 -1
- package/dist/chunk-C4DJPZRU.js +0 -119
- package/dist/chunk-C4DJPZRU.js.map +0 -1
- package/dist/chunk-JUS2UYRP.js.map +0 -1
- package/dist/chunk-KKRO2VCP.js.map +0 -1
- package/dist/chunk-QT3KFVDP.js.map +0 -1
- package/dist/chunk-TRNI7KEO.js.map +0 -1
- package/dist/chunk-VYCTL62C.js.map +0 -1
- package/dist/chunk-YXQX7RQT.js.map +0 -1
package/dist/browser.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/** Browser-console client. Optional SDK surfaces must not enter this eager graph. */
|
|
2
2
|
export { OpenGeniClient as OpenGeniBrowserClient } from "./client.js";
|
|
3
|
-
export type {
|
|
4
|
-
export {
|
|
3
|
+
export type { SessionMessageSearchRequest, SessionMessageSearchMatch, SessionMessageSearchResponse, SessionMessagePreview, SessionMessagePreviewReference, } from "./session-message-search.js";
|
|
4
|
+
export { OpenGeniToolCallError, OpenGeniToolReapprovalRequiredError, OpenGeniToolsClient, } from "./tools.js";
|
|
5
|
+
export type { OpenGeniGeneratedTools, OpenGeniDynamicToolNode, OpenGeniToolCallOptions, OpenGeniToolFunction, OpenGeniToolsFacade, OpenGeniWorkspaceTools, } from "./tools.js";
|
|
6
|
+
export type { FetchLike, FetchResponse, GetSessionOptions, OpenGeniClientOptions, OpenGeniRequestOptions, SendMessageInput, SteerMessageResult, TranscribeAudioInput, WorkspaceControlEventPage, } from "./client.js";
|
|
7
|
+
export { OpenGeniApiContractMismatchError, OpenGeniApiError, OpenGeniSetupError, OpenGeniAllowanceExhaustedError, OpenGeniSessionUsageLimitReachedError, OpenGeniSessionUsageLimitUnsupportedError, OpenGeniSecureContextRequiredError, OpenGeniSessionListCursorError, OpenGeniStreamError, formatErrorMessage, isRetryableStreamError, } from "./errors.js";
|
|
8
|
+
export type { OpenGeniSecureContextRequiredReason } from "./errors.js";
|
|
5
9
|
export { resolveWorkspaceVoiceInputEnabled } from "./transcription.js";
|
|
6
10
|
export { OPENGENI_API_CONTRACT_HEADER, OPENGENI_API_CONTRACT_REVISION } from "./types.js";
|
|
11
|
+
export type { ConnectorToolPermission, ConnectorToolPermissionEntry, ConnectorToolPermissionsResponse, UpdateConnectorToolPermissionsRequest, SessionMcpToolPermissionsResponse, UpdateSessionMcpToolPermissionsRequest, } from "./types.js";
|
package/dist/browser.js
CHANGED
|
@@ -1,29 +1,51 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveWorkspaceVoiceInputEnabled
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GZQSWAKD.js";
|
|
4
|
+
import {
|
|
5
|
+
OpenGeniToolCallError,
|
|
6
|
+
OpenGeniToolReapprovalRequiredError,
|
|
7
|
+
OpenGeniToolsClient
|
|
8
|
+
} from "./chunk-P7UWKORG.js";
|
|
4
9
|
import {
|
|
5
10
|
OpenGeniClient
|
|
6
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-S2NLS3ES.js";
|
|
12
|
+
import "./chunk-X5ITQVXE.js";
|
|
13
|
+
import "./chunk-4AHR4KGA.js";
|
|
7
14
|
import {
|
|
8
15
|
OPENGENI_API_CONTRACT_HEADER,
|
|
9
16
|
OPENGENI_API_CONTRACT_REVISION
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-NCU5OAN7.js";
|
|
18
|
+
import "./chunk-YJCHB7R3.js";
|
|
12
19
|
import {
|
|
20
|
+
OpenGeniAllowanceExhaustedError,
|
|
13
21
|
OpenGeniApiContractMismatchError,
|
|
14
22
|
OpenGeniApiError,
|
|
23
|
+
OpenGeniSecureContextRequiredError,
|
|
15
24
|
OpenGeniSessionListCursorError,
|
|
25
|
+
OpenGeniSessionUsageLimitReachedError,
|
|
26
|
+
OpenGeniSessionUsageLimitUnsupportedError,
|
|
27
|
+
OpenGeniSetupError,
|
|
16
28
|
OpenGeniStreamError,
|
|
29
|
+
formatErrorMessage,
|
|
17
30
|
isRetryableStreamError
|
|
18
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-7EWT3PV6.js";
|
|
19
32
|
export {
|
|
20
33
|
OPENGENI_API_CONTRACT_HEADER,
|
|
21
34
|
OPENGENI_API_CONTRACT_REVISION,
|
|
35
|
+
OpenGeniAllowanceExhaustedError,
|
|
22
36
|
OpenGeniApiContractMismatchError,
|
|
23
37
|
OpenGeniApiError,
|
|
24
38
|
OpenGeniClient as OpenGeniBrowserClient,
|
|
39
|
+
OpenGeniSecureContextRequiredError,
|
|
25
40
|
OpenGeniSessionListCursorError,
|
|
41
|
+
OpenGeniSessionUsageLimitReachedError,
|
|
42
|
+
OpenGeniSessionUsageLimitUnsupportedError,
|
|
43
|
+
OpenGeniSetupError,
|
|
26
44
|
OpenGeniStreamError,
|
|
45
|
+
OpenGeniToolCallError,
|
|
46
|
+
OpenGeniToolReapprovalRequiredError,
|
|
47
|
+
OpenGeniToolsClient,
|
|
48
|
+
formatErrorMessage,
|
|
27
49
|
isRetryableStreamError,
|
|
28
50
|
resolveWorkspaceVoiceInputEnabled
|
|
29
51
|
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { SessionEvent } from "../types.js";
|
|
2
|
+
import { OpenGeniChatError, type ChatChunk, type ChatPending, type ChatReply } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Event folding shared by `send`, `stream`, and every protocol adapter.
|
|
5
|
+
*
|
|
6
|
+
* One fold covers one logical turn: text deltas accumulate into message
|
|
7
|
+
* segments (a tool call closes the current segment, the completed event
|
|
8
|
+
* reconciles it), tool call/output pairs become tool chunks, and the turn
|
|
9
|
+
* settles on a terminal event or a human wait. Events that carry a different
|
|
10
|
+
* turn id than the expected one are ignored so a queued follow-up never ends
|
|
11
|
+
* early on the previous turn's settlement.
|
|
12
|
+
*
|
|
13
|
+
* A segment belongs to one provider message when events carry `messageId`: a
|
|
14
|
+
* delta for another message starts a new segment, and a completion reconciles
|
|
15
|
+
* only the segment of its own message. Completions may arrive after later
|
|
16
|
+
* messages already streamed, so matching by position would let one message's
|
|
17
|
+
* completion close another's segment and repeat its text.
|
|
18
|
+
*
|
|
19
|
+
* Commentary (`phase: "commentary"`) narrates the work, like a tool chunk, so
|
|
20
|
+
* it is held back from the reply text. Only a turn that settles without any
|
|
21
|
+
* answer text falls back to its latest commentary, emitted at settlement.
|
|
22
|
+
*/
|
|
23
|
+
export type ChatTurnTerminal = "completed" | "failed" | "cancelled" | "pending";
|
|
24
|
+
export type ChatFoldStep = {
|
|
25
|
+
chunks: ChatChunk[];
|
|
26
|
+
terminal: ChatTurnTerminal | null;
|
|
27
|
+
};
|
|
28
|
+
/** Incremental replay of unresolved requests, without retaining the event log. */
|
|
29
|
+
export declare class ChatPendingFold {
|
|
30
|
+
private readonly requests;
|
|
31
|
+
push(event: SessionEvent): void;
|
|
32
|
+
pending(now?: number): ChatPending[];
|
|
33
|
+
private put;
|
|
34
|
+
}
|
|
35
|
+
export declare class ChatTurnFold {
|
|
36
|
+
private readonly workspaceId;
|
|
37
|
+
private readonly sessionId;
|
|
38
|
+
readonly events: SessionEvent[];
|
|
39
|
+
turnId: string | null;
|
|
40
|
+
pending: ChatPending | null;
|
|
41
|
+
failure: SessionEvent | null;
|
|
42
|
+
private emptyFinalReply;
|
|
43
|
+
private readonly segments;
|
|
44
|
+
private readonly openTools;
|
|
45
|
+
constructor(workspaceId: string, sessionId: string, expectedTurnId: string | null);
|
|
46
|
+
get text(): string;
|
|
47
|
+
push(event: SessionEvent): ChatFoldStep;
|
|
48
|
+
reply(terminal: ChatTurnTerminal): ChatReply;
|
|
49
|
+
/** The error to throw for a `turn.failed` settlement. */
|
|
50
|
+
failureError(): OpenGeniChatError;
|
|
51
|
+
private messageDelta;
|
|
52
|
+
private messageCompleted;
|
|
53
|
+
private segmentOf;
|
|
54
|
+
/** Deltas that carried no identity, still streaming the text this completion names. */
|
|
55
|
+
private unidentifiedStreamingSegment;
|
|
56
|
+
private latestAnswer;
|
|
57
|
+
private findLastSegment;
|
|
58
|
+
/**
|
|
59
|
+
* Complete an answer segment. Only the newest answer can grow: a remainder
|
|
60
|
+
* for an earlier one would land after later text for append-only consumers.
|
|
61
|
+
*/
|
|
62
|
+
private extendAnswer;
|
|
63
|
+
private closeSegments;
|
|
64
|
+
/**
|
|
65
|
+
* Close the turn's text. A turn that produced commentary but no answer text
|
|
66
|
+
* (for example one that ends waiting for a worker) replies with its latest
|
|
67
|
+
* commentary rather than nothing.
|
|
68
|
+
*/
|
|
69
|
+
private settleSegments;
|
|
70
|
+
private startSegment;
|
|
71
|
+
}
|
|
72
|
+
export declare function approvalPending(payload: Record<string, unknown>): ChatPending | null;
|
|
73
|
+
export declare function humanInputPending(payload: Record<string, unknown>): ChatPending | null;
|
|
74
|
+
export declare function asRecord(value: unknown): Record<string, unknown>;
|
|
75
|
+
export declare function stringValue(value: unknown): string | undefined;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ChatResolve } from "./http.js";
|
|
2
|
+
import type { Opengeni } from "./opengeni.js";
|
|
3
|
+
import { type ChatChunk, type ChatRespondInput } from "./types.js";
|
|
4
|
+
export { CHAT_CONVERSATION_HEADER, type ChatResolution, type ChatResolve } from "./http.js";
|
|
5
|
+
export type ChatHandlerFormat = "native" | "vercel" | "openai-chat" | "openai-responses";
|
|
6
|
+
export type ChatHandlerOptions = {
|
|
7
|
+
/** Mandatory host auth hook; see {@link ChatResolve}. */
|
|
8
|
+
resolve: ChatResolve;
|
|
9
|
+
/** Default wire format; a request may override it with the format header. */
|
|
10
|
+
format?: ChatHandlerFormat | undefined;
|
|
11
|
+
/** Vercel format only: also emit Opengeni's own tool activity (see `UIMessageStreamOptions.toolParts`). */
|
|
12
|
+
toolParts?: boolean | undefined;
|
|
13
|
+
};
|
|
14
|
+
/** Per-request wire-format override header. */
|
|
15
|
+
export declare const CHAT_FORMAT_HEADER = "x-opengeni-chat-format";
|
|
16
|
+
/**
|
|
17
|
+
* One request handler for a product's chat endpoint. `POST` with `{ message }`
|
|
18
|
+
* streams the reply in the selected format; `POST .../respond` answers a
|
|
19
|
+
* pending approval or human-input request and streams the continuation;
|
|
20
|
+
* `GET` returns the conversation's history as JSON. Every other method is a
|
|
21
|
+
* 405. The conversation is the host's resolution, else the
|
|
22
|
+
* `x-opengeni-conversation` header, else the wire format's own field.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createChatHandler(og: Opengeni, options: ChatHandlerOptions): (request: Request) => Promise<Response>;
|
|
25
|
+
/** `POST { message }` -> native SSE of {@link ChatChunk} (`event: chunk`). */
|
|
26
|
+
export declare function handleNativeChatRequest(og: Opengeni, request: Request, resolve: ChatResolve): Promise<Response>;
|
|
27
|
+
/**
|
|
28
|
+
* `GET` -> `{ conversation, sessionId, created, messages, pending, status }`: the user and
|
|
29
|
+
* assistant text of the conversation so a client can restore it on reload
|
|
30
|
+
* (`messages` is empty and `created` false before the first message).
|
|
31
|
+
*/
|
|
32
|
+
export declare function handleNativeHistoryRequest(og: Opengeni, request: Request, resolve: ChatResolve): Promise<Response>;
|
|
33
|
+
/** `POST .../respond { requestId, decision | answers | skip }` -> native SSE of the continuation. */
|
|
34
|
+
export declare function handleNativeRespondRequest(og: Opengeni, request: Request, resolve: ChatResolve): Promise<Response>;
|
|
35
|
+
export declare function respondInputFromBody(body: Record<string, unknown> | null): ChatRespondInput | null;
|
|
36
|
+
/** Native wire format: `event: chunk` per {@link ChatChunk}, `event: error` on failure. */
|
|
37
|
+
export declare function chatChunksToSseBlocks(chunks: AsyncIterable<ChatChunk>): AsyncGenerator<string, void, void>;
|
|
38
|
+
export declare function chatChunksToSseStream(chunks: AsyncIterable<ChatChunk>, onCancel?: () => void): ReadableStream<Uint8Array>;
|
|
39
|
+
export declare function chatChunksToSseResponse(chunks: AsyncIterable<ChatChunk>): Response;
|
|
40
|
+
/** Browser-side reader for the native wire format. Throws {@link OpenGeniChatError} on `event: error`. */
|
|
41
|
+
export declare function parseChatChunkStream(stream: ReadableStream<Uint8Array>): AsyncGenerator<ChatChunk, void, void>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Opengeni } from "./opengeni.js";
|
|
2
|
+
import { type ChatImportedMessage, type ChatOptions } from "./types.js";
|
|
3
|
+
/** Internal HTTP plumbing shared by the native handler and the protocol adapters. */
|
|
4
|
+
/**
|
|
5
|
+
* Header a client uses to name the conversation it is on. Every handler reads
|
|
6
|
+
* the client conversation as: the host's resolution, else this header, else
|
|
7
|
+
* the protocol's own field.
|
|
8
|
+
*/
|
|
9
|
+
export declare const CHAT_CONVERSATION_HEADER = "x-opengeni-conversation";
|
|
10
|
+
/** What the host's auth hook returns: identity from the host, conversation optional per protocol. */
|
|
11
|
+
export type ChatResolution = Omit<ChatOptions, "conversation"> & {
|
|
12
|
+
conversation?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The host's authentication hook. It receives the raw request and returns the
|
|
16
|
+
* tenant/user/conversation the caller is allowed to use, or a `Response` to
|
|
17
|
+
* reject the request. Never derive tenant or user from the request body.
|
|
18
|
+
*/
|
|
19
|
+
export type ChatResolve = (request: Request) => Promise<ChatResolution | Response> | ChatResolution | Response;
|
|
20
|
+
export type ChatErrorSummary = {
|
|
21
|
+
status: number;
|
|
22
|
+
code: string;
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function jsonResponse(body: unknown, status?: number, headers?: HeadersInit): Response;
|
|
26
|
+
export declare function errorResponse(status: number, message: string, code: string): Response;
|
|
27
|
+
export declare function readJsonObject(request: Request): Promise<Record<string, unknown> | null>;
|
|
28
|
+
export declare function resolveChatRequest(request: Request, resolve: ChatResolve): Promise<{
|
|
29
|
+
resolution: ChatResolution;
|
|
30
|
+
response?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
response: Response;
|
|
33
|
+
}>;
|
|
34
|
+
/** The client-supplied conversation: the header, else the protocol's own field. */
|
|
35
|
+
export declare function clientConversation(request: Request, protocolField: unknown): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Open a chat from a resolution plus the conversation the client supplied.
|
|
38
|
+
* The host names the conversation, or the host names the user and the client
|
|
39
|
+
* conversation id is namespaced to that user; anything else is a 400, because
|
|
40
|
+
* an unscoped client id could address any conversation in the workspace.
|
|
41
|
+
*/
|
|
42
|
+
export declare function openResolvedChat(og: Opengeni, resolution: ChatResolution, clientConversationId: string | undefined): Promise<{
|
|
43
|
+
chat: Awaited<ReturnType<Opengeni["chat"]>>;
|
|
44
|
+
response?: undefined;
|
|
45
|
+
} | {
|
|
46
|
+
response: Response;
|
|
47
|
+
}>;
|
|
48
|
+
export declare function chatErrorSummary(error: unknown): ChatErrorSummary;
|
|
49
|
+
export declare function sseHeaders(extra?: Record<string, string>): Record<string, string>;
|
|
50
|
+
export declare function sseLine(data: string, event?: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Pull-based text-to-bytes stream over already-formatted SSE blocks. Upstream
|
|
53
|
+
* consumption follows downstream demand; cancelling fires `onCancel` so the
|
|
54
|
+
* producer can abort its Opengeni stream.
|
|
55
|
+
*/
|
|
56
|
+
export declare function sseByteStream(blocks: AsyncIterable<string>, onCancel?: () => void): ReadableStream<Uint8Array>;
|
|
57
|
+
/** Text from an OpenAI-style message content: a string or `[{ type, text }]` parts. */
|
|
58
|
+
export declare function messageContentText(content: unknown, partTypes: string[]): string | null;
|
|
59
|
+
/** The last user-role message's text from an OpenAI/Vercel-style `messages` array. */
|
|
60
|
+
export declare function lastUserMessageText(messages: unknown, partTypes: string[], partsField: "parts" | "content"): string | null;
|
|
61
|
+
/**
|
|
62
|
+
* Every user/assistant/system message before the last user message, as
|
|
63
|
+
* imported history for the first create. Items without a role or text
|
|
64
|
+
* (tool calls, files) are skipped.
|
|
65
|
+
*/
|
|
66
|
+
export declare function importedHistoryBefore(messages: unknown, partTypes: string[], partsField: "parts" | "content"): ChatImportedMessage[];
|
|
67
|
+
export declare function unixSeconds(): number;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic chat identities. A conversation id maps to exactly one
|
|
3
|
+
* session id per workspace, so any process can address the same session
|
|
4
|
+
* without storing a mapping, and a double-submitted create collapses through
|
|
5
|
+
* the idempotency key. The optional legacy label argument is retained only to
|
|
6
|
+
* reproduce historical addresses. New chat calls do not use it: authorization
|
|
7
|
+
* is independent of addressing, so collaborators can share a conversation.
|
|
8
|
+
*/
|
|
9
|
+
/** The end-user label a conversation is namespaced to: the product `source` plus the opaque user id. */
|
|
10
|
+
export type ChatUserLabel = {
|
|
11
|
+
source: string;
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
/** Fixed RFC 4122 namespace for chat session ids. Never change it. */
|
|
15
|
+
export declare const CHAT_SESSION_NAMESPACE = "7c1e6d3a-5b2f-4e8a-9d4c-0f3b6a8e2c17";
|
|
16
|
+
/** RFC 4122 version 5 (SHA-1) UUID of `name` inside `namespace`. */
|
|
17
|
+
export declare function uuidV5(name: string, namespace: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* The session id of `conversation` in `workspaceId`: RFC 4122 v5 of the JSON
|
|
20
|
+
* tuple `[workspaceId, conversation]`, or `[workspaceId, source, id, conversation]`
|
|
21
|
+
* when the conversation belongs to an end user. JSON encoding keeps the tuple
|
|
22
|
+
* unambiguous: an id containing `:` or any other delimiter can never make two
|
|
23
|
+
* different (user, conversation) pairs share a session.
|
|
24
|
+
*/
|
|
25
|
+
export declare function chatSessionId(workspaceId: string, conversation: string, user?: ChatUserLabel | undefined): Promise<string>;
|
|
26
|
+
/** The exact v5 name behind {@link chatSessionId}; exported for tests and audits. */
|
|
27
|
+
export declare function chatIdentityName(workspaceId: string, conversation: string, user?: ChatUserLabel | undefined): string;
|
|
28
|
+
/**
|
|
29
|
+
* The create idempotency key for a chat session: `chat:<sessionId>`. The
|
|
30
|
+
* session id already encodes the workspace, user label, and conversation as an
|
|
31
|
+
* unambiguous tuple, so the key inherits that and stays bounded.
|
|
32
|
+
*/
|
|
33
|
+
export declare function chatIdempotencyKey(sessionId: string): string;
|
|
34
|
+
export declare function isUuid(value: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { Chats } from "../chats.js";
|
|
2
|
+
export { OpenGeniSetupError } from "../errors.js";
|
|
3
|
+
export { Chat, DEFAULT_CHAT_SOURCE, DEFAULT_OPENGENI_BASE_URL, IMPORTED_HISTORY_MAX_CHARS, OpenGeni, Opengeni, formatImportedHistory, } from "./opengeni.js";
|
|
4
|
+
export { OpenGeniChatError, type ChatAgentAccess, type ChatChunk, type ChatImportedMessage, type ChatMemory, type ChatMessage, type ChatOptions, type ChatPending, type ChatReply, type ChatReplyStatus, type ChatRespondInput, type ChatSendOptions, type ChatSessionListOptions, type ChatSnapshot, type ChatTarget, type WorkspaceTarget, type ChatToolStatus, type OpenGeniOptions, } from "./types.js";
|
|
5
|
+
export { CHAT_SESSION_NAMESPACE, chatIdempotencyKey, chatIdentityName, chatSessionId, uuidV5, type ChatUserLabel, } from "./ids.js";
|
|
6
|
+
export { ChatTurnFold, approvalPending, humanInputPending, type ChatFoldStep, type ChatTurnTerminal, } from "./fold.js";
|
|
7
|
+
export { CHAT_CONVERSATION_HEADER, CHAT_FORMAT_HEADER, chatChunksToSseBlocks, chatChunksToSseResponse, chatChunksToSseStream, createChatHandler, handleNativeChatRequest, handleNativeHistoryRequest, handleNativeRespondRequest, parseChatChunkStream, respondInputFromBody, type ChatHandlerFormat, type ChatHandlerOptions, type ChatResolution, type ChatResolve, } from "./handler.js";
|
|
8
|
+
export { UI_MESSAGE_STREAM_HEADER, UI_MESSAGE_STREAM_VERSION, chatChunksToUIMessageStream, handleVercelChatRequest, lastUIMessageText, uiMessageStreamBlocks, uiMessageStreamParts, uiMessageStreamResponse, type UIMessageStreamOptions, } from "./vercel.js";
|
|
9
|
+
export { chatCompletionBlocks, chatCompletionObject, decodeResponseId, encodeResponseId, handleChatCompletionsRequest, handleResponsesRequest, responsesBlocks, responsesInputText, } from "./openai.js";
|