@opengeni/sdk 0.52.1 → 0.57.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 +61 -7
- package/dist/artifacts.js +5 -5
- package/dist/{chunk-V5F253OG.js → chunk-GU6JF75T.js} +6 -3
- package/dist/chunk-GU6JF75T.js.map +1 -0
- package/dist/{chunk-FRJFNDIR.js → chunk-HJ3HHUT5.js} +5 -1
- package/dist/chunk-HJ3HHUT5.js.map +1 -0
- package/dist/{chunk-KIHGPM7H.js → chunk-JDLDDRNE.js} +20 -14
- package/dist/chunk-JDLDDRNE.js.map +1 -0
- package/dist/{chunk-FHI4DFIG.js → chunk-JRPFWI6T.js} +2 -2
- package/dist/{chunk-ILQZR5N6.js → chunk-PKQ377ED.js} +693 -34
- package/dist/chunk-PKQ377ED.js.map +1 -0
- package/dist/{chunk-MZWTWOX6.js → chunk-ST5DDKJP.js} +327 -1
- package/dist/chunk-ST5DDKJP.js.map +1 -0
- package/dist/{chunk-DXDL7EEW.js → chunk-YKZME56C.js} +197 -113
- package/dist/chunk-YKZME56C.js.map +1 -0
- package/dist/client.d.ts +106 -16
- package/dist/codex-realtime-controller.d.ts +3 -0
- package/dist/codex-realtime-controller.js +2 -2
- package/dist/core.js +7 -7
- package/dist/desktop.d.ts +8 -0
- package/dist/editable-artifacts.js +4 -4
- package/dist/gateway-realtime-transport.d.ts +1 -0
- package/dist/gateway-realtime-transport.js +5 -3
- package/dist/index.d.ts +6 -2
- package/dist/index.js +68 -34
- package/dist/index.js.map +1 -1
- package/dist/interaction-revision-stream.d.ts +11 -0
- package/dist/interaction.d.ts +604 -5
- package/dist/interaction.js +27 -1
- package/dist/realtime.d.ts +3 -3
- package/dist/realtime.js +11 -7
- package/dist/realtime.js.map +1 -1
- package/dist/types.d.ts +267 -64
- package/dist/workspace-live-stream.d.ts +14 -0
- package/package.json +2 -2
- package/src/client.ts +861 -60
- package/src/codex-realtime-controller.ts +25 -7
- package/src/codex-realtime-lifecycle.ts +1 -0
- package/src/desktop.ts +11 -1
- package/src/errors.ts +16 -2
- package/src/gateway-realtime-transport.ts +252 -109
- package/src/index.ts +42 -13
- package/src/interaction-revision-stream.ts +117 -0
- package/src/interaction.ts +1049 -5
- package/src/realtime.ts +14 -4
- package/src/types.ts +336 -67
- package/src/workspace-live-stream.ts +137 -0
- package/dist/chunk-DXDL7EEW.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.map +0 -1
- /package/dist/{chunk-FHI4DFIG.js.map → chunk-JRPFWI6T.js.map} +0 -0
package/src/index.ts
CHANGED
|
@@ -96,7 +96,10 @@ export type {
|
|
|
96
96
|
CreateCodexRealtimeControllerOptions,
|
|
97
97
|
RealtimeControllerTransportStarter,
|
|
98
98
|
} from "./codex-realtime-controller";
|
|
99
|
-
export {
|
|
99
|
+
export {
|
|
100
|
+
createGatewayRealtimeTransportStarter,
|
|
101
|
+
createXaiSubscriptionRealtimeTransportStarter,
|
|
102
|
+
} from "./gateway-realtime-transport";
|
|
100
103
|
export { projectSessionRealtimeLifecycle } from "./codex-realtime-lifecycle";
|
|
101
104
|
export type { SessionRealtimeLifecycleProjection } from "./codex-realtime-lifecycle";
|
|
102
105
|
// Provider-neutral Browser/Computer resource client + bounded frame protocol.
|
|
@@ -130,6 +133,14 @@ export type {
|
|
|
130
133
|
} from "./stream";
|
|
131
134
|
export { streamWorkspaceControlEvents } from "./workspace-control-stream";
|
|
132
135
|
export type { WorkspaceControlStreamTransport } from "./workspace-control-stream";
|
|
136
|
+
export { streamWorkspaceInteractionRevisions } from "./interaction-revision-stream";
|
|
137
|
+
export type { WorkspaceInteractionRevisionStreamTransport } from "./interaction-revision-stream";
|
|
138
|
+
export { parseWorkspaceLiveEvent, streamWorkspaceLiveEvents } from "./workspace-live-stream";
|
|
139
|
+
export type {
|
|
140
|
+
WorkspaceLiveEvent,
|
|
141
|
+
WorkspaceLiveStreamOptions,
|
|
142
|
+
WorkspaceLiveStreamTransport,
|
|
143
|
+
} from "./workspace-live-stream";
|
|
133
144
|
export type {
|
|
134
145
|
CreateWorkspaceArtifactRequest,
|
|
135
146
|
PublishWorkspaceArtifactVersionRequest,
|
|
@@ -317,6 +328,8 @@ export type {
|
|
|
317
328
|
BillingEntitlementsResponse,
|
|
318
329
|
BillingMode,
|
|
319
330
|
BillingSummary,
|
|
331
|
+
ListManagedOrganizationMembershipsResponse,
|
|
332
|
+
ManagedOrganizationMembership,
|
|
320
333
|
BillingUsageResponse,
|
|
321
334
|
InsightsRange,
|
|
322
335
|
InsightsBillingPath,
|
|
@@ -394,6 +407,14 @@ export type {
|
|
|
394
407
|
CodexConnectionStatus,
|
|
395
408
|
CodexConnectStart,
|
|
396
409
|
CodexConnectPoll,
|
|
410
|
+
SuperGrokAccount,
|
|
411
|
+
SuperGrokAccountsResponse,
|
|
412
|
+
SuperGrokAccountScope,
|
|
413
|
+
SuperGrokAllocatorUpdate,
|
|
414
|
+
SuperGrokConnectionStatus,
|
|
415
|
+
SuperGrokConnectPoll,
|
|
416
|
+
SuperGrokConnectStart,
|
|
417
|
+
SuperGrokRotationSettings,
|
|
397
418
|
CodexFleetConfidence,
|
|
398
419
|
CodexFleetCacheState,
|
|
399
420
|
CodexFleetDecisionEventPayload,
|
|
@@ -449,7 +470,10 @@ export type {
|
|
|
449
470
|
CreateWorkspaceRequest,
|
|
450
471
|
DiscoverMcpCapabilitiesResponse,
|
|
451
472
|
InstallSkillRequest,
|
|
473
|
+
InstallLibrarySkillRequest,
|
|
452
474
|
InstalledSkill,
|
|
475
|
+
InstalledSkillSummary,
|
|
476
|
+
ListInstalledSkillsResponse,
|
|
453
477
|
Document,
|
|
454
478
|
DocumentAuthorityKind,
|
|
455
479
|
DocumentBase,
|
|
@@ -792,6 +816,10 @@ export type {
|
|
|
792
816
|
VariableSet,
|
|
793
817
|
VariableSetSecret,
|
|
794
818
|
VariableSetVariableMetadata,
|
|
819
|
+
Channel,
|
|
820
|
+
CreateChannelRequest,
|
|
821
|
+
UpdateChannelRequest,
|
|
822
|
+
UpdateSessionChannelRequest,
|
|
795
823
|
Rig,
|
|
796
824
|
RigVersion,
|
|
797
825
|
RigCheck,
|
|
@@ -811,30 +839,31 @@ export type {
|
|
|
811
839
|
PreviewSkillImportRequest,
|
|
812
840
|
ApiIntegrationAuthPreview,
|
|
813
841
|
ApiIntegrationInstallationSummary,
|
|
814
|
-
|
|
842
|
+
IntegrationDefinitionSummary,
|
|
815
843
|
ApiIntegrationPreview,
|
|
816
844
|
ApiIntegrationOAuthStartRequest,
|
|
817
845
|
ApiIntegrationProtocol,
|
|
818
|
-
|
|
846
|
+
IntegrationSource,
|
|
819
847
|
ApiIntegrationToolPreview,
|
|
820
848
|
ApiIntegrationUninstallPreview,
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
849
|
+
IntegrationFacetBindingSummary,
|
|
850
|
+
IntegrationFacetDefinitionSummary,
|
|
851
|
+
IntegrationFacetKind,
|
|
852
|
+
IntegrationFacetMutationResult,
|
|
853
|
+
IntegrationFacetRemovalResult,
|
|
854
|
+
IntegrationFacetStatus,
|
|
855
|
+
IntegrationInstanceFacetsResponse,
|
|
828
856
|
InstallApiIntegrationRequest,
|
|
829
857
|
InstalledApiIntegration,
|
|
830
|
-
|
|
858
|
+
ListIntegrationDefinitionsResponse,
|
|
831
859
|
ListApiIntegrationsResponse,
|
|
832
860
|
PreviewApiIntegrationRequest,
|
|
833
|
-
|
|
834
|
-
|
|
861
|
+
MutateIntegrationFacetRequest,
|
|
862
|
+
UpsertIntegrationFacetRequest,
|
|
835
863
|
SkillImportFileSummary,
|
|
836
864
|
SkillImportPreview,
|
|
837
865
|
SkillImportSource,
|
|
866
|
+
SkillInstallationSource,
|
|
838
867
|
SkillUninstallPreview,
|
|
839
868
|
UninstallSkillRequest,
|
|
840
869
|
UninstallSkillResult,
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { isAbortError, isRetryableStreamError, OpenGeniStreamError } from "./errors";
|
|
2
|
+
import type { WorkspaceInteractionRevisionEvent } from "./interaction";
|
|
3
|
+
import { parseSseStream } from "./sse";
|
|
4
|
+
import {
|
|
5
|
+
jitteredDelay,
|
|
6
|
+
runBeforeLive,
|
|
7
|
+
type StreamSessionEventsOptions,
|
|
8
|
+
withStreamInactivityTimeout,
|
|
9
|
+
} from "./stream";
|
|
10
|
+
|
|
11
|
+
export type WorkspaceInteractionRevisionStreamTransport = {
|
|
12
|
+
openStream: (
|
|
13
|
+
after: number,
|
|
14
|
+
signal: AbortSignal | undefined,
|
|
15
|
+
) => Promise<ReadableStream<Uint8Array>>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Reconnecting latest-revision stream. Revisions may skip because intermediate
|
|
20
|
+
* invalidations carry no independent evidence; every delivered value means
|
|
21
|
+
* "refetch any interaction resources older than this cursor".
|
|
22
|
+
*/
|
|
23
|
+
export async function* streamWorkspaceInteractionRevisions(
|
|
24
|
+
transport: WorkspaceInteractionRevisionStreamTransport,
|
|
25
|
+
options: StreamSessionEventsOptions = {},
|
|
26
|
+
): AsyncGenerator<WorkspaceInteractionRevisionEvent, void, void> {
|
|
27
|
+
const signal = options.signal;
|
|
28
|
+
const reconnect = options.reconnect ?? true;
|
|
29
|
+
const baseDelayMs = options.reconnectDelayMs ?? 500;
|
|
30
|
+
const maxDelayMs = options.maxReconnectDelayMs ?? 10_000;
|
|
31
|
+
const jitterRatio = options.reconnectJitterRatio ?? 0.2;
|
|
32
|
+
const beforeLiveTimeoutMs = options.beforeLiveTimeoutMs ?? 15_000;
|
|
33
|
+
const heartbeatTimeoutMs = options.heartbeatTimeoutMs ?? 45_000;
|
|
34
|
+
const maxAttempts = options.maxReconnectAttempts ?? Number.POSITIVE_INFINITY;
|
|
35
|
+
let cursor = options.after ?? 0;
|
|
36
|
+
let failures = 0;
|
|
37
|
+
let delayMs = baseDelayMs;
|
|
38
|
+
let everConnected = false;
|
|
39
|
+
|
|
40
|
+
for (;;) {
|
|
41
|
+
if (signal?.aborted) return;
|
|
42
|
+
options.onStateChange?.(everConnected || failures > 0 ? "reconnecting" : "connecting");
|
|
43
|
+
const cursorAtOpen = cursor;
|
|
44
|
+
try {
|
|
45
|
+
const body = await transport.openStream(cursor, signal);
|
|
46
|
+
everConnected = true;
|
|
47
|
+
failures = 0;
|
|
48
|
+
delayMs = baseDelayMs;
|
|
49
|
+
await runBeforeLive(options.beforeLive, beforeLiveTimeoutMs, signal);
|
|
50
|
+
options.onStateChange?.("live");
|
|
51
|
+
for await (const message of parseSseStream(
|
|
52
|
+
withStreamInactivityTimeout(body, heartbeatTimeoutMs, signal),
|
|
53
|
+
)) {
|
|
54
|
+
if (signal?.aborted) return;
|
|
55
|
+
const event = parseWorkspaceInteractionRevision(message.data);
|
|
56
|
+
if (!event || event.sequence <= cursor) continue;
|
|
57
|
+
cursor = event.sequence;
|
|
58
|
+
yield event;
|
|
59
|
+
}
|
|
60
|
+
if (!reconnect) return;
|
|
61
|
+
if (cursor === cursorAtOpen) await sleep(jitteredDelay(baseDelayMs, jitterRatio), signal);
|
|
62
|
+
continue;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (signal?.aborted || isAbortError(error)) return;
|
|
65
|
+
if (!reconnect || !isRetryableStreamError(error)) throw error;
|
|
66
|
+
failures += 1;
|
|
67
|
+
if (failures > maxAttempts) {
|
|
68
|
+
throw new OpenGeniStreamError(
|
|
69
|
+
`workspace interaction stream gave up after ${maxAttempts} reconnect attempts: ${
|
|
70
|
+
error instanceof Error ? error.message : String(error)
|
|
71
|
+
}`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
await sleep(jitteredDelay(delayMs, jitterRatio), signal);
|
|
76
|
+
delayMs = Math.min(Math.max(delayMs * 2, baseDelayMs), maxDelayMs);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function parseWorkspaceInteractionRevision(data: string): WorkspaceInteractionRevisionEvent | null {
|
|
81
|
+
let value: unknown;
|
|
82
|
+
try {
|
|
83
|
+
value = JSON.parse(data);
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
if (
|
|
88
|
+
!isRecord(value) ||
|
|
89
|
+
value.type !== "workspace.interaction.changed" ||
|
|
90
|
+
typeof value.workspaceId !== "string" ||
|
|
91
|
+
typeof value.sequence !== "number" ||
|
|
92
|
+
!Number.isSafeInteger(value.sequence) ||
|
|
93
|
+
value.sequence < 0 ||
|
|
94
|
+
value.revision !== value.sequence ||
|
|
95
|
+
typeof value.occurredAt !== "string"
|
|
96
|
+
) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return value as WorkspaceInteractionRevisionEvent;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
103
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function sleep(delayMs: number, signal: AbortSignal | undefined): Promise<void> {
|
|
107
|
+
if (signal?.aborted || delayMs <= 0) return;
|
|
108
|
+
await new Promise<void>((resolve) => {
|
|
109
|
+
const timer = setTimeout(done, delayMs);
|
|
110
|
+
function done() {
|
|
111
|
+
clearTimeout(timer);
|
|
112
|
+
signal?.removeEventListener("abort", done);
|
|
113
|
+
resolve();
|
|
114
|
+
}
|
|
115
|
+
signal?.addEventListener("abort", done, { once: true });
|
|
116
|
+
});
|
|
117
|
+
}
|