@opengeni/sdk 0.52.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1078 -33
- 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-KIHGPM7H.js → chunk-2UXZUCEZ.js} +309 -46
- 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-FHI4DFIG.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-ILQZR5N6.js → chunk-FG3OO5LM.js} +3484 -750
- 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-DXDL7EEW.js → chunk-KWADQ227.js} +198 -114
- package/dist/chunk-KWADQ227.js.map +1 -0
- 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-MZWTWOX6.js → chunk-NC57YMUO.js} +447 -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-FRJFNDIR.js → chunk-YIKA2QT4.js} +37 -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 +843 -107
- package/dist/codex-realtime-controller.d.ts +6 -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 +28 -9
- package/dist/deprecation.d.ts +47 -0
- package/dist/desktop.d.ts +8 -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 +243 -124
- 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.d.ts +1 -0
- package/dist/gateway-realtime-transport.js +5 -3
- 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 -12
- package/dist/index.js +277 -126
- package/dist/index.js.map +1 -1
- package/dist/interaction-revision-stream.d.ts +11 -0
- package/dist/interaction.d.ts +687 -5
- package/dist/interaction.js +32 -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 +6 -4
- package/dist/realtime.js +10 -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 +3048 -406
- 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-live-stream.d.ts +14 -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 +5162 -792
- package/src/codex-realtime-controller.ts +260 -12
- package/src/codex-realtime-lifecycle.ts +1 -0
- 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/desktop.ts +11 -1
- 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 +185 -4
- package/src/feedback.ts +20 -0
- package/src/gateway-realtime-transport.ts +253 -110
- package/src/github-repositories.ts +60 -0
- package/src/index.ts +603 -54
- package/src/interaction-revision-stream.ts +117 -0
- package/src/interaction.ts +1367 -51
- 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 +15 -4
- 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 +3607 -493
- 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-live-stream.ts +137 -0
- package/src/workspace-state.ts +8 -82
- package/dist/chunk-DXDL7EEW.js.map +0 -1
- package/dist/chunk-FHI4DFIG.js.map +0 -1
- package/dist/chunk-FRJFNDIR.js.map +0 -1
- package/dist/chunk-ILQZR5N6.js.map +0 -1
- package/dist/chunk-KIHGPM7H.js.map +0 -1
- package/dist/chunk-MZWTWOX6.js.map +0 -1
- package/dist/chunk-V5F253OG.js +0 -116
- package/dist/chunk-V5F253OG.js.map +0 -1
- package/dist/chunk-VWE2QIVO.js.map +0 -1
package/src/codex-realtime-v3.ts
CHANGED
|
@@ -35,9 +35,10 @@ export const CODEX_REALTIME_V3_PENDING_MAX_ENTRIES = 256;
|
|
|
35
35
|
export const CODEX_REALTIME_V3_PENDING_MAX_BYTES = 16 * 1024 * 1024;
|
|
36
36
|
const REALTIME_DELEGATION_TRANSCRIPT_MAX_BYTES = 65_536;
|
|
37
37
|
const REALTIME_DELEGATION_INPUT_MAX_BYTES = 65_536;
|
|
38
|
+
const REALTIME_MODEL_CONTEXT_MAX_CHARACTERS = 32_768;
|
|
38
39
|
|
|
39
40
|
export type CodexRealtimeV3BridgeFatal = {
|
|
40
|
-
code: "pending_overflow";
|
|
41
|
+
code: "pending_overflow" | "replay_journal_failed";
|
|
41
42
|
message: string;
|
|
42
43
|
};
|
|
43
44
|
|
|
@@ -72,6 +73,19 @@ export type CodexRealtimeV3BridgeOptions = {
|
|
|
72
73
|
>;
|
|
73
74
|
sync(request: SyncSessionRealtimeLedgerRequest): Promise<SyncSessionRealtimeLedgerResponse>;
|
|
74
75
|
randomUUID?: (() => string) | undefined;
|
|
76
|
+
/** Model-visible application context captured once for each durable message-bearing entry. */
|
|
77
|
+
getModelContext?: (() => string | undefined) | undefined;
|
|
78
|
+
/** Controller-lifetime delegation identities shared across provider connection rotations. */
|
|
79
|
+
acceptedDelegationItemIds?: Set<string> | undefined;
|
|
80
|
+
/** Unsynced delegation snapshots retained exactly across provider connection rotations. */
|
|
81
|
+
pendingDelegations?: Map<string, SessionRealtimeInboundEntry> | undefined;
|
|
82
|
+
/** Persist exact delegation replay state before it becomes browser-reload-sensitive. */
|
|
83
|
+
onDelegationReplayStateChange?:
|
|
84
|
+
| ((state: {
|
|
85
|
+
acceptedDelegationItemIds: ReadonlySet<string>;
|
|
86
|
+
pendingDelegations: ReadonlyMap<string, SessionRealtimeInboundEntry>;
|
|
87
|
+
}) => void)
|
|
88
|
+
| undefined;
|
|
75
89
|
/** The controller installs its activation FIFO first, then enables this listener synchronously. */
|
|
76
90
|
listen?: boolean | undefined;
|
|
77
91
|
onSnapshot?: ((snapshot: CodexRealtimeV3BridgeSnapshot) => void) | undefined;
|
|
@@ -125,9 +139,32 @@ export function createCodexRealtimeV3Bridge(
|
|
|
125
139
|
const clientReceivedSequences = new Set<number>();
|
|
126
140
|
const sentSequences = new Set<number>();
|
|
127
141
|
const finalizedTurnIds = new Set<string>();
|
|
142
|
+
const acceptedDelegationItemIds = options.acceptedDelegationItemIds ?? new Set<string>();
|
|
143
|
+
const pendingDelegations = options.pendingDelegations ?? new Map();
|
|
144
|
+
const locallyQueuedDelegationItemIds = new Set<string>();
|
|
128
145
|
let transcriptSinceDelegation: FinalizedTranscript[] = [];
|
|
129
|
-
let pendingDelegationUserTranscript: {
|
|
146
|
+
let pendingDelegationUserTranscript: {
|
|
147
|
+
delegationItemId: string;
|
|
148
|
+
text: string;
|
|
149
|
+
} | null = null;
|
|
130
150
|
const randomUUID = options.randomUUID ?? defaultRandomUUID;
|
|
151
|
+
const currentModelContext = (): string | undefined => {
|
|
152
|
+
let context: string | undefined;
|
|
153
|
+
try {
|
|
154
|
+
context = options.getModelContext?.()?.trim();
|
|
155
|
+
} catch {
|
|
156
|
+
lastError =
|
|
157
|
+
"Realtime model context callback failed; the provider message continued without application context";
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
if (!context) return undefined;
|
|
161
|
+
if (context.length > REALTIME_MODEL_CONTEXT_MAX_CHARACTERS) {
|
|
162
|
+
lastError =
|
|
163
|
+
"Realtime model context exceeded the 32768-character limit; the provider message continued without application context";
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
return context;
|
|
167
|
+
};
|
|
131
168
|
|
|
132
169
|
const snapshot = (): CodexRealtimeV3BridgeSnapshot => ({
|
|
133
170
|
connectionId: options.connectionId,
|
|
@@ -148,9 +185,9 @@ export function createCodexRealtimeV3Bridge(
|
|
|
148
185
|
});
|
|
149
186
|
const publish = (): void => options.onSnapshot?.(snapshot());
|
|
150
187
|
|
|
151
|
-
const
|
|
188
|
+
const triggerFatalCode = (code: CodexRealtimeV3BridgeFatal["code"], message: string): void => {
|
|
152
189
|
if (closed || fatal) return;
|
|
153
|
-
fatal = { code
|
|
190
|
+
fatal = { code, message };
|
|
154
191
|
lastError = message;
|
|
155
192
|
publish();
|
|
156
193
|
try {
|
|
@@ -161,6 +198,10 @@ export function createCodexRealtimeV3Bridge(
|
|
|
161
198
|
}
|
|
162
199
|
};
|
|
163
200
|
|
|
201
|
+
const triggerFatal = (message: string): void => {
|
|
202
|
+
triggerFatalCode("pending_overflow", message);
|
|
203
|
+
};
|
|
204
|
+
|
|
164
205
|
const enqueue = (entry: SessionRealtimeInboundEntry): boolean => {
|
|
165
206
|
if (closed || sealed || fatal) return false;
|
|
166
207
|
const bytes = utf8ByteLength(JSON.stringify(entry));
|
|
@@ -177,6 +218,14 @@ export function createCodexRealtimeV3Bridge(
|
|
|
177
218
|
return true;
|
|
178
219
|
};
|
|
179
220
|
|
|
221
|
+
// Same-browser reload reconstructs this exact map from the persisted owner
|
|
222
|
+
// journal. Queue those first-frozen calls before listening to the replacement
|
|
223
|
+
// provider connection; startup proof or a duplicate call drives the normal
|
|
224
|
+
// flush path without resampling application context.
|
|
225
|
+
for (const [delegationItemId, entry] of pendingDelegations) {
|
|
226
|
+
if (enqueue(entry)) locallyQueuedDelegationItemIds.add(delegationItemId);
|
|
227
|
+
}
|
|
228
|
+
|
|
180
229
|
const hasWork = (): boolean =>
|
|
181
230
|
pendingInbound.length > 0 ||
|
|
182
231
|
(!providerStartedAccepted && providerStarted !== undefined) ||
|
|
@@ -213,7 +262,46 @@ export function createCodexRealtimeV3Bridge(
|
|
|
213
262
|
throw error;
|
|
214
263
|
}
|
|
215
264
|
|
|
265
|
+
const acceptedAfterSync = new Set(acceptedDelegationItemIds);
|
|
266
|
+
const pendingAfterSync = new Map(pendingDelegations);
|
|
267
|
+
let delegationReplayChanged = false;
|
|
268
|
+
for (const item of batch) {
|
|
269
|
+
if (item.entry.kind === "delegation_call" && item.entry.delegationItemId) {
|
|
270
|
+
delegationReplayChanged = true;
|
|
271
|
+
acceptedAfterSync.add(item.entry.delegationItemId);
|
|
272
|
+
if (pendingAfterSync.get(item.entry.delegationItemId) === item.entry) {
|
|
273
|
+
pendingAfterSync.delete(item.entry.delegationItemId);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (delegationReplayChanged) {
|
|
278
|
+
try {
|
|
279
|
+
options.onDelegationReplayStateChange?.({
|
|
280
|
+
acceptedDelegationItemIds: acceptedAfterSync,
|
|
281
|
+
pendingDelegations: pendingAfterSync,
|
|
282
|
+
});
|
|
283
|
+
} catch (error) {
|
|
284
|
+
// The server may already have admitted this exact batch. Keep it
|
|
285
|
+
// queued with the original operation identity and stop this bridge.
|
|
286
|
+
// Recovery can safely replay it because the prior pending journal
|
|
287
|
+
// state remains authoritative until the accepted transition writes.
|
|
288
|
+
pendingInbound = [...batch, ...pendingInbound];
|
|
289
|
+
triggerFatalCode(
|
|
290
|
+
"replay_journal_failed",
|
|
291
|
+
`Codex realtime delegation replay journal failed: ${safeError(error)}`,
|
|
292
|
+
);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
216
297
|
for (const item of batch) {
|
|
298
|
+
if (item.entry.kind === "delegation_call" && item.entry.delegationItemId) {
|
|
299
|
+
acceptedDelegationItemIds.add(item.entry.delegationItemId);
|
|
300
|
+
if (pendingDelegations.get(item.entry.delegationItemId) === item.entry) {
|
|
301
|
+
pendingDelegations.delete(item.entry.delegationItemId);
|
|
302
|
+
}
|
|
303
|
+
locallyQueuedDelegationItemIds.delete(item.entry.delegationItemId);
|
|
304
|
+
}
|
|
217
305
|
pendingInboundCount -= 1;
|
|
218
306
|
pendingInboundBytes -= item.bytes;
|
|
219
307
|
}
|
|
@@ -345,31 +433,67 @@ export function createCodexRealtimeV3Bridge(
|
|
|
345
433
|
// These events are provider UI deltas. `turn.done` is the single
|
|
346
434
|
// authoritative finalized transcript persisted below.
|
|
347
435
|
} else if (event.type === "delegation.created") {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
436
|
+
if (acceptedDelegationItemIds.has(event.delegationItemId)) {
|
|
437
|
+
ignoredEventCount += 1;
|
|
438
|
+
lastIgnoredEventType = event.type;
|
|
439
|
+
} else if (locallyQueuedDelegationItemIds.has(event.delegationItemId)) {
|
|
440
|
+
ignoredEventCount += 1;
|
|
441
|
+
lastIgnoredEventType = event.type;
|
|
442
|
+
durable = true;
|
|
443
|
+
} else {
|
|
444
|
+
let entry = pendingDelegations.get(event.delegationItemId);
|
|
445
|
+
if (!entry) {
|
|
446
|
+
const transcript = delegationTranscript(transcriptSinceDelegation, event.inputTranscript);
|
|
447
|
+
const coveredTurnIds = transcriptSinceDelegation.map((item) => item.turnId);
|
|
448
|
+
const modelContext = currentModelContext();
|
|
449
|
+
entry = {
|
|
450
|
+
operationId: randomUUID(),
|
|
451
|
+
kind: "delegation_call",
|
|
452
|
+
providerEventId: event.providerEventId,
|
|
453
|
+
delegationItemId: event.delegationItemId,
|
|
454
|
+
text: renderRealtimeDelegationInput(event.inputTranscript, transcript),
|
|
455
|
+
payload: {
|
|
456
|
+
offsetMs: event.offsetMs,
|
|
457
|
+
inputTranscript: event.inputTranscript,
|
|
458
|
+
transcriptFenceTurnIds: coveredTurnIds,
|
|
459
|
+
},
|
|
460
|
+
...(modelContext ? { modelContext } : {}),
|
|
461
|
+
};
|
|
462
|
+
pendingDelegations.set(event.delegationItemId, entry);
|
|
463
|
+
}
|
|
464
|
+
try {
|
|
465
|
+
options.onDelegationReplayStateChange?.({
|
|
466
|
+
acceptedDelegationItemIds,
|
|
467
|
+
pendingDelegations,
|
|
468
|
+
});
|
|
469
|
+
} catch (error) {
|
|
470
|
+
triggerFatalCode(
|
|
471
|
+
"replay_journal_failed",
|
|
472
|
+
`Codex realtime delegation replay journal failed: ${safeError(error)}`,
|
|
473
|
+
);
|
|
474
|
+
return Promise.resolve();
|
|
475
|
+
}
|
|
476
|
+
durable = enqueue(entry);
|
|
477
|
+
if (durable) {
|
|
478
|
+
locallyQueuedDelegationItemIds.add(event.delegationItemId);
|
|
479
|
+
activeDelegationId = event.delegationItemId;
|
|
480
|
+
const frozenInputTranscript =
|
|
481
|
+
typeof entry.payload.inputTranscript === "string"
|
|
482
|
+
? entry.payload.inputTranscript
|
|
483
|
+
: event.inputTranscript;
|
|
484
|
+
const alreadyFinalized = transcriptSinceDelegation.some(
|
|
485
|
+
(item) =>
|
|
486
|
+
item.role === "user" &&
|
|
487
|
+
normalizedTranscript(item.text) === normalizedTranscript(frozenInputTranscript),
|
|
488
|
+
);
|
|
489
|
+
pendingDelegationUserTranscript = alreadyFinalized
|
|
490
|
+
? null
|
|
491
|
+
: {
|
|
492
|
+
delegationItemId: event.delegationItemId,
|
|
493
|
+
text: frozenInputTranscript,
|
|
494
|
+
};
|
|
495
|
+
transcriptSinceDelegation = [];
|
|
496
|
+
}
|
|
373
497
|
}
|
|
374
498
|
} else if (event.type === "output_audio.delta") {
|
|
375
499
|
speaking = true;
|
|
@@ -383,7 +507,9 @@ export function createCodexRealtimeV3Bridge(
|
|
|
383
507
|
normalizedTranscript(pendingDelegationUserTranscript.text)
|
|
384
508
|
? pendingDelegationUserTranscript.delegationItemId
|
|
385
509
|
: null;
|
|
386
|
-
durable = enqueue(
|
|
510
|
+
durable = enqueue(
|
|
511
|
+
finalTranscript(randomUUID, event, coveredByDelegationItemId, currentModelContext()),
|
|
512
|
+
);
|
|
387
513
|
if (durable) {
|
|
388
514
|
finalizedTurnIds.add(event.turnId);
|
|
389
515
|
if (coveredByDelegationItemId) {
|
|
@@ -446,6 +572,7 @@ function finalTranscript(
|
|
|
446
572
|
randomUUID: () => string,
|
|
447
573
|
event: Extract<CodexRealtimeV3Event, { type: "turn.done" }>,
|
|
448
574
|
coveredByDelegationItemId: string | null,
|
|
575
|
+
modelContext: string | undefined,
|
|
449
576
|
): SessionRealtimeInboundEntry {
|
|
450
577
|
return {
|
|
451
578
|
operationId: randomUUID(),
|
|
@@ -456,6 +583,7 @@ function finalTranscript(
|
|
|
456
583
|
turnId: event.turnId,
|
|
457
584
|
...(coveredByDelegationItemId ? { coveredByDelegationItemId } : {}),
|
|
458
585
|
},
|
|
586
|
+
...(modelContext ? { modelContext } : {}),
|
|
459
587
|
};
|
|
460
588
|
}
|
|
461
589
|
|
|
@@ -539,7 +667,10 @@ function sendOutbound(events: RTCDataChannel, entry: SessionRealtimeLedgerEntry)
|
|
|
539
667
|
text,
|
|
540
668
|
channel: payloadChannel ?? "speakable",
|
|
541
669
|
})
|
|
542
|
-
: encodeCodexRealtimeV3SessionContextAppend({
|
|
670
|
+
: encodeCodexRealtimeV3SessionContextAppend({
|
|
671
|
+
text,
|
|
672
|
+
channel: payloadChannel,
|
|
673
|
+
});
|
|
543
674
|
for (const message of messages) events.send(JSON.stringify(message));
|
|
544
675
|
}
|
|
545
676
|
|
package/src/codex-realtime.ts
CHANGED
|
@@ -261,7 +261,7 @@ export async function startCodexRealtimeWebrtc(
|
|
|
261
261
|
);
|
|
262
262
|
throwIfAborted(options.signal);
|
|
263
263
|
if (answer.version !== "v3" || answer.model !== "gpt-live-1-boulder-alpha" || !answer.sdp) {
|
|
264
|
-
throw new Error("
|
|
264
|
+
throw new Error("Opengeni returned an incompatible Codex realtime answer");
|
|
265
265
|
}
|
|
266
266
|
await peerConnection.setRemoteDescription({
|
|
267
267
|
type: "answer",
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CompanyBrainContextReceiptPage as ContractCompanyBrainContextReceiptPage,
|
|
3
|
+
CompanyBrainKnowledgeProposalPage as ContractCompanyBrainKnowledgeProposalPage,
|
|
4
|
+
CompanyBrainOkfPackage as ContractCompanyBrainOkfPackage,
|
|
5
|
+
} from "@opengeni/contracts";
|
|
6
|
+
|
|
7
|
+
export type CompanyBrainOkfPackage = ContractCompanyBrainOkfPackage;
|
|
8
|
+
export type CompanyBrainContextReceiptPage = ContractCompanyBrainContextReceiptPage;
|
|
9
|
+
export type CompanyBrainKnowledgeProposalPage = ContractCompanyBrainKnowledgeProposalPage;
|
|
10
|
+
|
|
11
|
+
export type CompanyBrainContextReceiptListOptions = {
|
|
12
|
+
attemptId?: string;
|
|
13
|
+
cursor?: string;
|
|
14
|
+
limit?: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type CompanyBrainKnowledgeProposalListOptions = {
|
|
18
|
+
limit?: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type CompanyBrainInspectorTransport = {
|
|
22
|
+
requestJson<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function inspectorPath(workspaceId: string, suffix: string): string {
|
|
26
|
+
return `/v1/workspaces/${workspaceId}/company-brain/${suffix}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function listCompanyBrainContextReceipts(
|
|
30
|
+
client: CompanyBrainInspectorTransport,
|
|
31
|
+
workspaceId: string,
|
|
32
|
+
options: CompanyBrainContextReceiptListOptions = {},
|
|
33
|
+
): Promise<CompanyBrainContextReceiptPage> {
|
|
34
|
+
const params = new URLSearchParams();
|
|
35
|
+
if (options.attemptId) params.set("attemptId", options.attemptId);
|
|
36
|
+
if (options.cursor) params.set("cursor", options.cursor);
|
|
37
|
+
if (options.limit !== undefined) params.set("limit", String(options.limit));
|
|
38
|
+
const query = params.toString();
|
|
39
|
+
return client.requestJson(
|
|
40
|
+
"GET",
|
|
41
|
+
`${inspectorPath(workspaceId, "context-receipts")}${query ? `?${query}` : ""}`,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function listCompanyBrainKnowledgeProposals(
|
|
46
|
+
client: CompanyBrainInspectorTransport,
|
|
47
|
+
workspaceId: string,
|
|
48
|
+
options: CompanyBrainKnowledgeProposalListOptions = {},
|
|
49
|
+
): Promise<CompanyBrainKnowledgeProposalPage> {
|
|
50
|
+
const query =
|
|
51
|
+
options.limit === undefined ? "" : `?limit=${encodeURIComponent(String(options.limit))}`;
|
|
52
|
+
return client.requestJson("GET", `${inspectorPath(workspaceId, "knowledge-proposals")}${query}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type CompanyBrainOkfDownload = {
|
|
56
|
+
content: string;
|
|
57
|
+
contentType: string;
|
|
58
|
+
filename: string;
|
|
59
|
+
};
|
package/src/company-profile.ts
CHANGED
|
@@ -21,7 +21,10 @@ export type CompanyProfileRevision = CompanyProfileRevisionIdentity & {
|
|
|
21
21
|
accountId: string;
|
|
22
22
|
intent: "active" | "proposal";
|
|
23
23
|
profile: CompanyProfileContent;
|
|
24
|
-
provenance: {
|
|
24
|
+
provenance: {
|
|
25
|
+
source: "human" | "agent_admin" | "durable_learning" | "migration";
|
|
26
|
+
sourceId: string | null;
|
|
27
|
+
};
|
|
25
28
|
supersedesRevisionId: string | null;
|
|
26
29
|
createdBySubjectId: string;
|
|
27
30
|
createdAt: string;
|
|
@@ -79,6 +82,19 @@ export type CompanyProfileMutationResponse = {
|
|
|
79
82
|
head: CompanyProfileHead | null;
|
|
80
83
|
event: CompanyProfileActivationEvent | null;
|
|
81
84
|
};
|
|
85
|
+
export type CompanyProfileAgentPolicyMode = "off" | "suggest" | "automatic";
|
|
86
|
+
export type CompanyProfileAgentPolicy = {
|
|
87
|
+
organizationId: string;
|
|
88
|
+
mode: CompanyProfileAgentPolicyMode;
|
|
89
|
+
version: number;
|
|
90
|
+
updatedAt: string;
|
|
91
|
+
changed?: boolean;
|
|
92
|
+
};
|
|
93
|
+
export type UpdateCompanyProfileAgentPolicyRequest = {
|
|
94
|
+
mode: CompanyProfileAgentPolicyMode;
|
|
95
|
+
expectedVersion: number;
|
|
96
|
+
operationId: string;
|
|
97
|
+
};
|
|
82
98
|
export type CompanyProfileDiffRequest = { fromRevisionId: string; toRevisionId: string };
|
|
83
99
|
export type CompanyProfileDiffResponse = {
|
|
84
100
|
from: CompanyProfileRevision;
|
package/src/core.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
/** Backward-compatible non-artifact client surface. */
|
|
2
|
+
export { OpenGeniDocumentAuthorityClient as OpenGeniCoreClient } from "./document-authority-client";
|
|
3
|
+
export {
|
|
4
|
+
OpenGeniToolCallError,
|
|
5
|
+
OpenGeniToolReapprovalRequiredError,
|
|
6
|
+
OpenGeniToolsClient,
|
|
7
|
+
} from "./tools";
|
|
8
|
+
export type {
|
|
9
|
+
OpenGeniGeneratedTools,
|
|
10
|
+
OpenGeniDynamicToolNode,
|
|
11
|
+
OpenGeniToolCallOptions,
|
|
12
|
+
OpenGeniToolFunction,
|
|
13
|
+
OpenGeniToolsFacade,
|
|
14
|
+
OpenGeniWorkspaceTools,
|
|
15
|
+
} from "./tools";
|
|
2
16
|
export type {
|
|
3
17
|
FetchLike,
|
|
18
|
+
FetchResponse,
|
|
19
|
+
GetSessionOptions,
|
|
4
20
|
OpenGeniClientOptions,
|
|
5
21
|
OpenGeniRequestOptions,
|
|
6
22
|
SendMessageInput,
|
|
@@ -11,9 +27,15 @@ export type {
|
|
|
11
27
|
export {
|
|
12
28
|
OpenGeniApiContractMismatchError,
|
|
13
29
|
OpenGeniApiError,
|
|
30
|
+
OpenGeniSetupError,
|
|
31
|
+
OpenGeniSecureContextRequiredError,
|
|
14
32
|
OpenGeniSessionListCursorError,
|
|
15
33
|
OpenGeniStreamError,
|
|
34
|
+
formatErrorMessage,
|
|
16
35
|
isRetryableStreamError,
|
|
17
36
|
} from "./errors";
|
|
37
|
+
export type { OpenGeniSecureContextRequiredReason } from "./errors";
|
|
38
|
+
export { parseDeprecationNotice } from "./deprecation";
|
|
39
|
+
export type { OpenGeniDeprecationHandler, OpenGeniDeprecationNotice } from "./deprecation";
|
|
18
40
|
export { resolveWorkspaceVoiceInputEnabled } from "./transcription";
|
|
19
41
|
export { OPENGENI_API_CONTRACT_HEADER, OPENGENI_API_CONTRACT_REVISION } from "./types";
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deprecation notices advertised by the OpenGeni API.
|
|
3
|
+
*
|
|
4
|
+
* Per the public API compatibility policy, a route whose behaviour is scheduled
|
|
5
|
+
* for removal answers with the standard `Deprecation` (RFC 9745) and `Sunset`
|
|
6
|
+
* (RFC 8594) headers plus `Link: <notes>; rel="deprecation"`. The client
|
|
7
|
+
* surfaces them through `OpenGeniClientOptions.onDeprecation`, or by default
|
|
8
|
+
* as a one-time `console.warn` per route, so an integrator pinned to an older
|
|
9
|
+
* SDK learns about a removal well before it happens.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export type OpenGeniDeprecationNotice = {
|
|
13
|
+
/** Request method, upper case. */
|
|
14
|
+
method: string;
|
|
15
|
+
/** Request path with ids collapsed (`/v1/workspaces/:id/...`), stable per route. */
|
|
16
|
+
route: string;
|
|
17
|
+
/** Exact request path. */
|
|
18
|
+
path: string;
|
|
19
|
+
/** When the deprecation was announced, if the header carried a date. */
|
|
20
|
+
deprecatedAt: Date | null;
|
|
21
|
+
/** Earliest removal on the server, if advertised. */
|
|
22
|
+
sunset: Date | null;
|
|
23
|
+
/** Migration notes (`rel="deprecation"`), if advertised. */
|
|
24
|
+
link: string | null;
|
|
25
|
+
/** Replacement (`rel="successor-version"`), if advertised. */
|
|
26
|
+
successor: string | null;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** `false` silences notices; a function receives each route's notice once per client. */
|
|
30
|
+
export type OpenGeniDeprecationHandler = (notice: OpenGeniDeprecationNotice) => void;
|
|
31
|
+
|
|
32
|
+
type HeaderBag = { get(name: string): string | null };
|
|
33
|
+
|
|
34
|
+
const ID_SEGMENT =
|
|
35
|
+
/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|\d+|[A-Za-z0-9_-]{20,})$/i;
|
|
36
|
+
|
|
37
|
+
function routeKey(path: string): string {
|
|
38
|
+
return path
|
|
39
|
+
.split("/")
|
|
40
|
+
.map((segment) => (ID_SEGMENT.test(segment) ? ":id" : segment))
|
|
41
|
+
.join("/");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function parseDeprecationDate(value: string): Date | null {
|
|
45
|
+
const trimmed = value.trim();
|
|
46
|
+
// RFC 9745 structured date `@<unix seconds>`; older drafts used `true` or an HTTP-date.
|
|
47
|
+
const structured = /^@(-?\d+)$/.exec(trimmed);
|
|
48
|
+
if (structured) return new Date(Number(structured[1]) * 1000);
|
|
49
|
+
const parsed = Date.parse(trimmed);
|
|
50
|
+
return Number.isNaN(parsed) ? null : new Date(parsed);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function parseLinks(value: string | null): Map<string, string> {
|
|
54
|
+
const links = new Map<string, string>();
|
|
55
|
+
if (!value) return links;
|
|
56
|
+
for (const match of value.matchAll(/<([^>]*)>\s*((?:;\s*[^;,]+)*)/g)) {
|
|
57
|
+
const rel = /;\s*rel="?([^";,]+)"?/i.exec(match[2] ?? "")?.[1];
|
|
58
|
+
if (!rel) continue;
|
|
59
|
+
for (const name of rel.toLowerCase().split(/\s+/)) {
|
|
60
|
+
if (!links.has(name)) links.set(name, match[1]!);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return links;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Read a deprecation notice from response headers; `null` when none is advertised. */
|
|
67
|
+
export function parseDeprecationNotice(
|
|
68
|
+
method: string,
|
|
69
|
+
url: string,
|
|
70
|
+
headers: HeaderBag,
|
|
71
|
+
): OpenGeniDeprecationNotice | null {
|
|
72
|
+
const deprecation = headers.get("deprecation");
|
|
73
|
+
const sunsetHeader = headers.get("sunset");
|
|
74
|
+
if (!deprecation && !sunsetHeader) return null;
|
|
75
|
+
let path = url;
|
|
76
|
+
try {
|
|
77
|
+
path = new URL(url, "http://opengeni.invalid").pathname;
|
|
78
|
+
} catch {
|
|
79
|
+
// Keep the raw value; the notice is advisory.
|
|
80
|
+
}
|
|
81
|
+
const sunset = sunsetHeader ? Date.parse(sunsetHeader) : Number.NaN;
|
|
82
|
+
const links = parseLinks(headers.get("link"));
|
|
83
|
+
return {
|
|
84
|
+
method: method.toUpperCase(),
|
|
85
|
+
route: routeKey(path),
|
|
86
|
+
path,
|
|
87
|
+
deprecatedAt: deprecation ? parseDeprecationDate(deprecation) : null,
|
|
88
|
+
sunset: Number.isNaN(sunset) ? null : new Date(sunset),
|
|
89
|
+
link: links.get("deprecation") ?? links.get("sunset") ?? null,
|
|
90
|
+
successor: links.get("successor-version") ?? null,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const warnedRoutes = new Set<string>();
|
|
95
|
+
|
|
96
|
+
/** The default handler: one `console.warn` per route per process. */
|
|
97
|
+
export function warnDeprecationOnce(notice: OpenGeniDeprecationNotice): void {
|
|
98
|
+
const key = `${notice.method} ${notice.route}`;
|
|
99
|
+
if (warnedRoutes.has(key)) return;
|
|
100
|
+
warnedRoutes.add(key);
|
|
101
|
+
const sunset = notice.sunset ? ` and will be removed after ${notice.sunset.toISOString()}` : "";
|
|
102
|
+
const notes = notice.link ? ` Migration notes: ${notice.link}.` : "";
|
|
103
|
+
console.warn(
|
|
104
|
+
`[@opengeni/sdk] ${key} is deprecated${sunset}.${notes} Upgrade @opengeni/sdk, or pass onDeprecation to handle this notice.`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
type FetchFunction<R extends { headers: HeaderBag }> = (
|
|
109
|
+
input: string | URL | Request,
|
|
110
|
+
init?: RequestInit,
|
|
111
|
+
) => Promise<R>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Wrap a fetch implementation so every response is inspected for a deprecation
|
|
115
|
+
* notice. The handler runs at most once per route for this wrapper and never
|
|
116
|
+
* affects the request: a throwing handler is swallowed.
|
|
117
|
+
*/
|
|
118
|
+
export function withDeprecationNotices<R extends { headers: HeaderBag }>(
|
|
119
|
+
fetchImpl: FetchFunction<R>,
|
|
120
|
+
handler: OpenGeniDeprecationHandler | false | undefined,
|
|
121
|
+
): FetchFunction<R> {
|
|
122
|
+
if (handler === false) return fetchImpl;
|
|
123
|
+
const notify = handler ?? warnDeprecationOnce;
|
|
124
|
+
const seen = new Set<string>();
|
|
125
|
+
return async (input, init) => {
|
|
126
|
+
const response = await fetchImpl(input, init);
|
|
127
|
+
try {
|
|
128
|
+
const headers = response.headers;
|
|
129
|
+
if (headers && (headers.get("deprecation") || headers.get("sunset"))) {
|
|
130
|
+
const method =
|
|
131
|
+
init?.method ??
|
|
132
|
+
(typeof Request !== "undefined" && input instanceof Request ? input.method : "GET");
|
|
133
|
+
const url =
|
|
134
|
+
typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
135
|
+
const notice = parseDeprecationNotice(method, url, headers);
|
|
136
|
+
if (notice) {
|
|
137
|
+
const key = `${notice.method} ${notice.route}`;
|
|
138
|
+
if (!seen.has(key)) {
|
|
139
|
+
seen.add(key);
|
|
140
|
+
notify(notice);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
} catch {
|
|
145
|
+
// Deprecation notices are advisory and must never fail a request.
|
|
146
|
+
}
|
|
147
|
+
return response;
|
|
148
|
+
};
|
|
149
|
+
}
|
package/src/desktop.ts
CHANGED
|
@@ -71,13 +71,23 @@ export interface DesktopRfbLike {
|
|
|
71
71
|
type: "connect" | "disconnect" | "securityfailure",
|
|
72
72
|
cb: (e?: unknown) => void,
|
|
73
73
|
) => void;
|
|
74
|
+
/** Send clipboard text over the already-open RFB connection. */
|
|
75
|
+
clipboardPasteFrom?(text: string): void;
|
|
76
|
+
/** Send one RFB key event. A missing `down` emits a complete key press. */
|
|
77
|
+
sendKey?(keysym: number, code: string, down?: boolean): void;
|
|
78
|
+
/** Focus or release the RFB keyboard sink without reconnecting. */
|
|
79
|
+
focus?(options?: FocusOptions): void;
|
|
80
|
+
blur?(): void;
|
|
74
81
|
disconnect(): void;
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
export type DesktopRfbFactory = (
|
|
78
85
|
target: HTMLElement,
|
|
79
86
|
url: string,
|
|
80
|
-
opts: {
|
|
87
|
+
opts: {
|
|
88
|
+
credentials?: { password?: string | undefined } | undefined;
|
|
89
|
+
wsProtocols?: string[] | undefined;
|
|
90
|
+
},
|
|
81
91
|
) => DesktopRfbLike;
|
|
82
92
|
|
|
83
93
|
export type DesktopConnectionState =
|