@opengeni/sdk 0.28.2 → 0.32.1
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 +28 -9
- package/dist/client.d.ts +643 -0
- package/dist/desktop.d.ts +71 -0
- package/dist/errors.d.ts +39 -0
- package/dist/index.d.ts +25 -4209
- package/dist/index.js +195 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp-output.d.ts +15 -0
- package/dist/preference-registry.d.ts +169 -0
- package/dist/proxy.d.ts +64 -0
- package/dist/sse.d.ts +14 -0
- package/dist/stream.d.ts +48 -0
- package/dist/terminal.d.ts +49 -0
- package/dist/transcription.d.ts +189 -0
- package/dist/types.d.ts +3221 -0
- package/dist/workspace-control-stream.d.ts +12 -0
- package/dist/workspace-instruction-policies.d.ts +98 -0
- package/dist/workspace-state.d.ts +122 -0
- package/package.json +3 -3
- package/src/client.ts +279 -2
- package/src/index.ts +67 -0
- package/src/preference-registry.ts +210 -0
- package/src/transcription.ts +16 -0
- package/src/types.ts +269 -13
- package/src/workspace-state.ts +134 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StreamSessionEventsOptions } from "./stream";
|
|
2
|
+
import type { WorkspaceControlEvent } from "./types";
|
|
3
|
+
export type WorkspaceControlStreamTransport = {
|
|
4
|
+
/** The server replays every durable event after the cursor before going live. */
|
|
5
|
+
openStream: (after: number, signal: AbortSignal | undefined) => Promise<ReadableStream<Uint8Array>>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Reconnecting workspace invalidation stream. Control revisions are monotonic
|
|
9
|
+
* but can begin above one after the one-way migration, so unlike conversation
|
|
10
|
+
* events this stream intentionally permits sparse sequence values.
|
|
11
|
+
*/
|
|
12
|
+
export declare function streamWorkspaceControlEvents(transport: WorkspaceControlStreamTransport, options?: StreamSessionEventsOptions): AsyncGenerator<WorkspaceControlEvent, void, void>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export type WorkspaceInstructionPolicyKind = "charter" | "policy";
|
|
2
|
+
export type WorkspaceInstructionPolicyScope = "global" | "role";
|
|
3
|
+
export type WorkspaceInstructionPolicyProvenanceSource = "human" | "onboarding" | "knowledge_proposal" | "legacy_import";
|
|
4
|
+
export type WorkspaceInstructionPolicyDraftProvenanceSource = Exclude<WorkspaceInstructionPolicyProvenanceSource, "legacy_import">;
|
|
5
|
+
export type WorkspaceInstructionPolicyActivationType = "activate" | "rollback";
|
|
6
|
+
export declare function normalizeWorkspaceInstructionPolicyRoleKey(value: string): string;
|
|
7
|
+
export type WorkspaceInstructionPolicyTarget = {
|
|
8
|
+
kind: WorkspaceInstructionPolicyKind;
|
|
9
|
+
scope: WorkspaceInstructionPolicyScope;
|
|
10
|
+
roleKey: string | null;
|
|
11
|
+
};
|
|
12
|
+
export type WorkspaceInstructionPolicyRevisionIdentity = {
|
|
13
|
+
id: string;
|
|
14
|
+
revision: number;
|
|
15
|
+
contentHash: string;
|
|
16
|
+
};
|
|
17
|
+
export type WorkspaceInstructionPolicyRevision = WorkspaceInstructionPolicyRevisionIdentity & WorkspaceInstructionPolicyTarget & {
|
|
18
|
+
accountId: string;
|
|
19
|
+
workspaceId: string;
|
|
20
|
+
content: string;
|
|
21
|
+
provenance: {
|
|
22
|
+
source: WorkspaceInstructionPolicyProvenanceSource;
|
|
23
|
+
sourceId: string | null;
|
|
24
|
+
};
|
|
25
|
+
supersedesRevisionId: string | null;
|
|
26
|
+
createdBySubjectId: string;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
};
|
|
29
|
+
export type WorkspaceInstructionPolicyHead = WorkspaceInstructionPolicyTarget & {
|
|
30
|
+
workspaceId: string;
|
|
31
|
+
revisionId: string;
|
|
32
|
+
revision: number;
|
|
33
|
+
contentHash: string;
|
|
34
|
+
activationVersion: number;
|
|
35
|
+
activatedAt: string;
|
|
36
|
+
};
|
|
37
|
+
export type WorkspaceInstructionPolicyActivationEvent = WorkspaceInstructionPolicyTarget & {
|
|
38
|
+
id: string;
|
|
39
|
+
accountId: string;
|
|
40
|
+
workspaceId: string;
|
|
41
|
+
type: WorkspaceInstructionPolicyActivationType;
|
|
42
|
+
activationVersion: number;
|
|
43
|
+
oldRevision: WorkspaceInstructionPolicyRevisionIdentity | null;
|
|
44
|
+
newRevision: WorkspaceInstructionPolicyRevisionIdentity;
|
|
45
|
+
actorSubjectId: string;
|
|
46
|
+
reason: string;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
};
|
|
49
|
+
export type CreateWorkspaceInstructionPolicyDraftRequest = WorkspaceInstructionPolicyTarget & {
|
|
50
|
+
content: string;
|
|
51
|
+
provenanceSource?: WorkspaceInstructionPolicyDraftProvenanceSource;
|
|
52
|
+
provenanceSourceId?: string | null;
|
|
53
|
+
supersedesRevisionId?: string | null;
|
|
54
|
+
};
|
|
55
|
+
export type ImportLegacyWorkspaceInstructionPolicyDraftRequest = {
|
|
56
|
+
supersedesRevisionId?: string | null;
|
|
57
|
+
};
|
|
58
|
+
export type WorkspaceInstructionPolicyListOptions = {
|
|
59
|
+
kind?: WorkspaceInstructionPolicyKind;
|
|
60
|
+
scope?: WorkspaceInstructionPolicyScope;
|
|
61
|
+
roleKey?: string;
|
|
62
|
+
afterRevision?: number;
|
|
63
|
+
limit?: number;
|
|
64
|
+
};
|
|
65
|
+
export type WorkspaceInstructionPolicyListResponse = {
|
|
66
|
+
revisions: WorkspaceInstructionPolicyRevision[];
|
|
67
|
+
activeHeads: WorkspaceInstructionPolicyHead[];
|
|
68
|
+
activationEvents: WorkspaceInstructionPolicyActivationEvent[];
|
|
69
|
+
nextAfterRevision: number | null;
|
|
70
|
+
};
|
|
71
|
+
export type WorkspaceInstructionPolicyDiffRequest = {
|
|
72
|
+
fromRevisionId: string;
|
|
73
|
+
toRevisionId: string;
|
|
74
|
+
};
|
|
75
|
+
export type WorkspaceInstructionPolicyDiffResponse = {
|
|
76
|
+
from: WorkspaceInstructionPolicyRevision;
|
|
77
|
+
to: WorkspaceInstructionPolicyRevision;
|
|
78
|
+
format: "unified";
|
|
79
|
+
diff: string;
|
|
80
|
+
};
|
|
81
|
+
export type ActivateWorkspaceInstructionPolicyRequest = {
|
|
82
|
+
expectedCurrentRevisionId: string | null;
|
|
83
|
+
reason: string;
|
|
84
|
+
};
|
|
85
|
+
export type RollbackWorkspaceInstructionPolicyRequest = {
|
|
86
|
+
targetRevisionId: string;
|
|
87
|
+
expectedCurrentRevisionId: string;
|
|
88
|
+
reason: string;
|
|
89
|
+
};
|
|
90
|
+
export type WorkspaceInstructionPolicyActivationResponse = {
|
|
91
|
+
head: WorkspaceInstructionPolicyHead;
|
|
92
|
+
event: WorkspaceInstructionPolicyActivationEvent;
|
|
93
|
+
};
|
|
94
|
+
export type WorkspaceInstructionPolicyConflictResponse = {
|
|
95
|
+
code: "WORKSPACE_INSTRUCTION_POLICY_CONFLICT";
|
|
96
|
+
message: string;
|
|
97
|
+
currentHead: WorkspaceInstructionPolicyHead | null;
|
|
98
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { WorkspaceInstructionPolicyKind, WorkspaceInstructionPolicyProvenanceSource, WorkspaceInstructionPolicyScope } from "./workspace-instruction-policies";
|
|
2
|
+
export type WorkspaceStateDocumentStatusCounts = {
|
|
3
|
+
queued: number;
|
|
4
|
+
indexing: number;
|
|
5
|
+
ready: number;
|
|
6
|
+
failed: number;
|
|
7
|
+
};
|
|
8
|
+
export type WorkspaceStateSourceKindCounts = {
|
|
9
|
+
manual_upload: number;
|
|
10
|
+
meeting_transcript: number;
|
|
11
|
+
repository: number;
|
|
12
|
+
email: number;
|
|
13
|
+
chat: number;
|
|
14
|
+
document: number;
|
|
15
|
+
web: number;
|
|
16
|
+
other: number;
|
|
17
|
+
};
|
|
18
|
+
export type WorkspaceStateMemoryStatusCounts = {
|
|
19
|
+
proposed: number;
|
|
20
|
+
approved: number;
|
|
21
|
+
rejected: number;
|
|
22
|
+
active: number;
|
|
23
|
+
superseded: number;
|
|
24
|
+
archived: number;
|
|
25
|
+
};
|
|
26
|
+
export type WorkspaceStateMemoryKindCounts = {
|
|
27
|
+
semantic: number;
|
|
28
|
+
episodic: number;
|
|
29
|
+
procedural: number;
|
|
30
|
+
decision: number;
|
|
31
|
+
preference: number;
|
|
32
|
+
};
|
|
33
|
+
export type WorkspaceStateGapCode = "no_document_bases" | "no_visible_documents" | "failed_documents" | "processing_documents" | "missing_topic_coverage" | "no_memory_records" | "pending_memory_review" | "partial_inventory";
|
|
34
|
+
export type WorkspaceStateResponse = {
|
|
35
|
+
workspaceId: string;
|
|
36
|
+
generatedAt: string;
|
|
37
|
+
truth: {
|
|
38
|
+
current: {
|
|
39
|
+
source: "read_time_projection";
|
|
40
|
+
capturedAt: string;
|
|
41
|
+
};
|
|
42
|
+
policySnapshot: {
|
|
43
|
+
status: "not_captured";
|
|
44
|
+
reason: "workspace_instruction_policy_snapshot_not_implemented";
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
policy: {
|
|
48
|
+
authority: "workspace_instruction_policy_heads";
|
|
49
|
+
activeHeads: Array<{
|
|
50
|
+
kind: WorkspaceInstructionPolicyKind;
|
|
51
|
+
scope: WorkspaceInstructionPolicyScope;
|
|
52
|
+
roleKey: string | null;
|
|
53
|
+
revisionId: string;
|
|
54
|
+
revision: number;
|
|
55
|
+
contentHash: string;
|
|
56
|
+
activationVersion: number;
|
|
57
|
+
activatedAt: string;
|
|
58
|
+
}>;
|
|
59
|
+
activeHeadsTruncated: boolean;
|
|
60
|
+
latestRevision: {
|
|
61
|
+
kind: WorkspaceInstructionPolicyKind;
|
|
62
|
+
scope: WorkspaceInstructionPolicyScope;
|
|
63
|
+
roleKey: string | null;
|
|
64
|
+
revisionId: string;
|
|
65
|
+
revision: number;
|
|
66
|
+
contentHash: string;
|
|
67
|
+
provenanceSource: WorkspaceInstructionPolicyProvenanceSource;
|
|
68
|
+
state: "active" | "inactive";
|
|
69
|
+
createdAt: string;
|
|
70
|
+
} | null;
|
|
71
|
+
legacyRuntime: {
|
|
72
|
+
source: "workspace_override" | "deployment_default";
|
|
73
|
+
workspaceOverrideConfigured: boolean;
|
|
74
|
+
};
|
|
75
|
+
runtimeComposition: {
|
|
76
|
+
status: "not_implemented";
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
knowledge: {
|
|
80
|
+
availability: "unavailable";
|
|
81
|
+
reason: "missing_permission";
|
|
82
|
+
requiredPermission: "documents:search";
|
|
83
|
+
} | {
|
|
84
|
+
availability: "available";
|
|
85
|
+
coverage: "complete" | "partial";
|
|
86
|
+
baseCount: number;
|
|
87
|
+
bases: Array<{
|
|
88
|
+
id: string;
|
|
89
|
+
name: string;
|
|
90
|
+
visibleDocumentCount: number;
|
|
91
|
+
statusCounts: WorkspaceStateDocumentStatusCounts;
|
|
92
|
+
latestUpdatedAt: string | null;
|
|
93
|
+
}>;
|
|
94
|
+
basesTruncated: boolean;
|
|
95
|
+
inspectedVisibleDocumentCount: number;
|
|
96
|
+
documentStatusCounts: WorkspaceStateDocumentStatusCounts;
|
|
97
|
+
sourceKindCounts: WorkspaceStateSourceKindCounts;
|
|
98
|
+
topics: Array<{
|
|
99
|
+
name: string;
|
|
100
|
+
documentCount: number;
|
|
101
|
+
}>;
|
|
102
|
+
topicsTruncated: boolean;
|
|
103
|
+
latestDocumentUpdatedAt: string | null;
|
|
104
|
+
memorySample: {
|
|
105
|
+
recordCount: number;
|
|
106
|
+
sampleLimit: 100;
|
|
107
|
+
limitReached: boolean;
|
|
108
|
+
statusCounts: WorkspaceStateMemoryStatusCounts;
|
|
109
|
+
kindCounts: WorkspaceStateMemoryKindCounts;
|
|
110
|
+
preferenceAuthority: {
|
|
111
|
+
kindCountSource: "knowledge_memories_legacy_observations";
|
|
112
|
+
activeAuthority: "structured_preference_registry";
|
|
113
|
+
};
|
|
114
|
+
latestUpdatedAt: string | null;
|
|
115
|
+
};
|
|
116
|
+
gaps: Array<{
|
|
117
|
+
code: WorkspaceStateGapCode;
|
|
118
|
+
severity: "info" | "warning";
|
|
119
|
+
relatedCount: number | null;
|
|
120
|
+
}>;
|
|
121
|
+
};
|
|
122
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.1",
|
|
4
4
|
"description": "Framework-agnostic TypeScript SDK for the OpenGeni API: typed client, session lifecycle, SSE event streaming with reconnect + replay-by-sequence, and proxy re-streaming helpers.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"provenance": true
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"typecheck": "
|
|
32
|
-
"build": "
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"build": "bun ../../scripts/build-typescript-package.ts",
|
|
33
33
|
"prepublishOnly": "bash ../../scripts/prepublish-guard"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
package/src/client.ts
CHANGED
|
@@ -29,6 +29,8 @@ import type {
|
|
|
29
29
|
CodexUsageMap,
|
|
30
30
|
BillingSummary,
|
|
31
31
|
BillingUsageResponse,
|
|
32
|
+
InsightsRange,
|
|
33
|
+
WorkspaceInsightsResponse,
|
|
32
34
|
CapabilityCatalogItem,
|
|
33
35
|
CapabilityCatalogResponse,
|
|
34
36
|
CapabilityInstallation,
|
|
@@ -92,6 +94,7 @@ import type {
|
|
|
92
94
|
SwapActiveSandboxResponse,
|
|
93
95
|
ListWorkspaceMembersResponse,
|
|
94
96
|
PackInstallation,
|
|
97
|
+
LatencyMode,
|
|
95
98
|
ReasoningEffort,
|
|
96
99
|
RetainedArtifactContent,
|
|
97
100
|
RetainedArtifactContentOptions,
|
|
@@ -169,6 +172,7 @@ import type {
|
|
|
169
172
|
PtyResizeRequest,
|
|
170
173
|
PtyCloseRequest,
|
|
171
174
|
ToolRef,
|
|
175
|
+
TranscribeAudioResponse,
|
|
172
176
|
UpdateConnectionRequest,
|
|
173
177
|
UpdateKnowledgeMemoryRequest,
|
|
174
178
|
UpdateScheduledTaskRequest,
|
|
@@ -210,6 +214,23 @@ import type {
|
|
|
210
214
|
WorkspaceInstructionPolicyListResponse,
|
|
211
215
|
WorkspaceInstructionPolicyRevision,
|
|
212
216
|
} from "./workspace-instruction-policies";
|
|
217
|
+
import type { WorkspaceStateResponse } from "./workspace-state";
|
|
218
|
+
import type {
|
|
219
|
+
ActivatePreferenceRegistryRevisionRequest,
|
|
220
|
+
ChangePreferenceRegistryScopeRequest,
|
|
221
|
+
CorrectPreferenceRegistryRequest,
|
|
222
|
+
CreatePreferenceRegistryProposalRequest,
|
|
223
|
+
DeactivatePreferenceRegistryRequest,
|
|
224
|
+
PreferenceRegistryDetailResponse,
|
|
225
|
+
PreferenceRegistryFullContent,
|
|
226
|
+
PreferenceRegistryListOptions,
|
|
227
|
+
PreferenceRegistryListResponse,
|
|
228
|
+
PreferenceRegistryMutationResponse,
|
|
229
|
+
PreferenceRegistryRecord,
|
|
230
|
+
PreferenceRegistrySnapshot,
|
|
231
|
+
RejectPreferenceRegistryProposalRequest,
|
|
232
|
+
SupersedePreferenceRegistryRequest,
|
|
233
|
+
} from "./preference-registry";
|
|
213
234
|
import {
|
|
214
235
|
OPENGENI_API_CONTRACT_HEADER,
|
|
215
236
|
OPENGENI_API_CONTRACT_REVISION,
|
|
@@ -248,7 +269,7 @@ export type OpenGeniClientOptions = {
|
|
|
248
269
|
fetch?: FetchLike;
|
|
249
270
|
};
|
|
250
271
|
|
|
251
|
-
/** Per-request cancellation for
|
|
272
|
+
/** Per-request cancellation for operations whose caller owns an AbortSignal. */
|
|
252
273
|
export type OpenGeniRequestOptions = {
|
|
253
274
|
signal?: AbortSignal | undefined;
|
|
254
275
|
};
|
|
@@ -261,6 +282,7 @@ export type SendMessageInput = {
|
|
|
261
282
|
tools?: ToolRef[];
|
|
262
283
|
model?: string;
|
|
263
284
|
reasoningEffort?: ReasoningEffort;
|
|
285
|
+
latencyMode?: LatencyMode;
|
|
264
286
|
clientEventId?: string;
|
|
265
287
|
controlEtag?: string;
|
|
266
288
|
expectedDraftRevision?: number;
|
|
@@ -274,6 +296,13 @@ export type SteerMessageResult = {
|
|
|
274
296
|
turn: SessionTurn;
|
|
275
297
|
};
|
|
276
298
|
|
|
299
|
+
export type TranscribeAudioInput = {
|
|
300
|
+
audio: Blob | File | Uint8Array;
|
|
301
|
+
mimeType: string;
|
|
302
|
+
durationSeconds?: number | undefined;
|
|
303
|
+
signal?: AbortSignal | undefined;
|
|
304
|
+
};
|
|
305
|
+
|
|
277
306
|
/**
|
|
278
307
|
* Typed client for the OpenGeni public API. Framework-agnostic: only needs
|
|
279
308
|
* WHATWG `fetch` + streams, so it runs in Node 18+, Bun, Deno, browsers, and
|
|
@@ -293,6 +322,60 @@ export class OpenGeniClient {
|
|
|
293
322
|
|
|
294
323
|
// --- Session lifecycle ---------------------------------------------------
|
|
295
324
|
|
|
325
|
+
/** Upload one ephemeral browser recording. This method never retries. */
|
|
326
|
+
async transcribeAudio(
|
|
327
|
+
workspaceId: string,
|
|
328
|
+
input: TranscribeAudioInput,
|
|
329
|
+
): Promise<TranscribeAudioResponse> {
|
|
330
|
+
const correlationId = crypto.randomUUID();
|
|
331
|
+
const form = new FormData();
|
|
332
|
+
const filename = filenameForAudioMimeType(input.mimeType);
|
|
333
|
+
const audio =
|
|
334
|
+
input.audio instanceof File
|
|
335
|
+
? input.audio
|
|
336
|
+
: input.audio instanceof Uint8Array
|
|
337
|
+
? new File([Uint8Array.from(input.audio)], filename, { type: input.mimeType })
|
|
338
|
+
: new File([input.audio], filename, { type: input.mimeType || input.audio.type });
|
|
339
|
+
form.append("audio", audio, filename);
|
|
340
|
+
form.append("mimeType", input.mimeType);
|
|
341
|
+
if (input.durationSeconds !== undefined) {
|
|
342
|
+
form.append("durationSeconds", String(input.durationSeconds));
|
|
343
|
+
}
|
|
344
|
+
let response: Response;
|
|
345
|
+
try {
|
|
346
|
+
response = await this.fetchImpl(this.url(`/v1/workspaces/${workspaceId}/transcriptions`), {
|
|
347
|
+
method: "POST",
|
|
348
|
+
headers: { ...this.headers(correlationId), Accept: "application/json" },
|
|
349
|
+
body: form,
|
|
350
|
+
...(input.signal ? { signal: input.signal } : {}),
|
|
351
|
+
});
|
|
352
|
+
} catch (error) {
|
|
353
|
+
if (input.signal?.aborted) throw error;
|
|
354
|
+
throw mutationTransportError(correlationId);
|
|
355
|
+
}
|
|
356
|
+
assertApiContractResponse(response);
|
|
357
|
+
if (!response.ok) throw await apiErrorFromResponse(response, { method: "POST", correlationId });
|
|
358
|
+
await assertJsonResponse(response, { method: "POST", correlationId });
|
|
359
|
+
let body: unknown;
|
|
360
|
+
try {
|
|
361
|
+
body = await response.json();
|
|
362
|
+
} catch {
|
|
363
|
+
throw new OpenGeniApiError(response.status, "Invalid transcription response.", {
|
|
364
|
+
code: "invalid_response",
|
|
365
|
+
mutation: true,
|
|
366
|
+
correlationId,
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
if (!isTranscribeAudioResponse(body)) {
|
|
370
|
+
throw new OpenGeniApiError(response.status, "Invalid transcription response.", {
|
|
371
|
+
code: "invalid_response",
|
|
372
|
+
mutation: true,
|
|
373
|
+
correlationId,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
return body;
|
|
377
|
+
}
|
|
378
|
+
|
|
296
379
|
async createSession(
|
|
297
380
|
workspaceId: string,
|
|
298
381
|
request: CreateSessionRequest,
|
|
@@ -482,7 +565,7 @@ export class OpenGeniClient {
|
|
|
482
565
|
async listTurns(
|
|
483
566
|
workspaceId: string,
|
|
484
567
|
sessionId: string,
|
|
485
|
-
options: { limit?: number } = {},
|
|
568
|
+
options: { limit?: number; latestStarted?: boolean } = {},
|
|
486
569
|
): Promise<SessionTurn[]> {
|
|
487
570
|
return await this.requestJson<SessionTurn[]>(
|
|
488
571
|
"GET",
|
|
@@ -490,10 +573,17 @@ export class OpenGeniClient {
|
|
|
490
573
|
undefined,
|
|
491
574
|
{
|
|
492
575
|
...(options.limit !== undefined ? { limit: String(options.limit) } : {}),
|
|
576
|
+
...(options.latestStarted ? { latestStarted: "1" } : {}),
|
|
493
577
|
},
|
|
494
578
|
);
|
|
495
579
|
}
|
|
496
580
|
|
|
581
|
+
/** Newest turn that durably emitted `turn.started`, or null before any admission. */
|
|
582
|
+
async getLatestStartedTurn(workspaceId: string, sessionId: string): Promise<SessionTurn | null> {
|
|
583
|
+
const turns = await this.listTurns(workspaceId, sessionId, { latestStarted: true });
|
|
584
|
+
return turns[0] ?? null;
|
|
585
|
+
}
|
|
586
|
+
|
|
497
587
|
// --- Bring-your-own-compute: Machines dashboard + metrics (M10) ------------
|
|
498
588
|
|
|
499
589
|
/**
|
|
@@ -1623,6 +1713,14 @@ export class OpenGeniClient {
|
|
|
1623
1713
|
return await this.requestJson<Workspace>("GET", `/v1/workspaces/${workspaceId}`);
|
|
1624
1714
|
}
|
|
1625
1715
|
|
|
1716
|
+
/** Read-time, secret-safe inventory of policy heads and visible workspace knowledge. */
|
|
1717
|
+
async getWorkspaceState(workspaceId: string): Promise<WorkspaceStateResponse> {
|
|
1718
|
+
return await this.requestJson<WorkspaceStateResponse>(
|
|
1719
|
+
"GET",
|
|
1720
|
+
`/v1/workspaces/${workspaceId}/workspace-state`,
|
|
1721
|
+
);
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1626
1724
|
async updateWorkspace(workspaceId: string, request: UpdateWorkspaceRequest): Promise<Workspace> {
|
|
1627
1725
|
return await this.requestJson<Workspace>("PATCH", `/v1/workspaces/${workspaceId}`, request);
|
|
1628
1726
|
}
|
|
@@ -1717,6 +1815,132 @@ export class OpenGeniClient {
|
|
|
1717
1815
|
);
|
|
1718
1816
|
}
|
|
1719
1817
|
|
|
1818
|
+
async listPreferenceRegistry(
|
|
1819
|
+
workspaceId: string,
|
|
1820
|
+
options: PreferenceRegistryListOptions = {},
|
|
1821
|
+
): Promise<PreferenceRegistryListResponse> {
|
|
1822
|
+
const params = new URLSearchParams();
|
|
1823
|
+
if (options.scope) params.set("scope", options.scope);
|
|
1824
|
+
if (options.status) params.set("status", options.status);
|
|
1825
|
+
if (options.limit !== undefined) params.set("limit", String(options.limit));
|
|
1826
|
+
const query = params.toString();
|
|
1827
|
+
return await this.requestJson<PreferenceRegistryListResponse>(
|
|
1828
|
+
"GET",
|
|
1829
|
+
`/v1/workspaces/${workspaceId}/preferences${query ? `?${query}` : ""}`,
|
|
1830
|
+
);
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
async getPreferenceRegistry(
|
|
1834
|
+
workspaceId: string,
|
|
1835
|
+
preferenceId: string,
|
|
1836
|
+
): Promise<PreferenceRegistryDetailResponse> {
|
|
1837
|
+
return await this.requestJson<PreferenceRegistryDetailResponse>(
|
|
1838
|
+
"GET",
|
|
1839
|
+
`/v1/workspaces/${workspaceId}/preferences/${encodeURIComponent(preferenceId)}`,
|
|
1840
|
+
);
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
async createPreferenceRegistryProposal(
|
|
1844
|
+
workspaceId: string,
|
|
1845
|
+
request: CreatePreferenceRegistryProposalRequest,
|
|
1846
|
+
): Promise<PreferenceRegistryRecord> {
|
|
1847
|
+
return await this.requestJson<PreferenceRegistryRecord>(
|
|
1848
|
+
"POST",
|
|
1849
|
+
`/v1/workspaces/${workspaceId}/preferences/proposals`,
|
|
1850
|
+
request,
|
|
1851
|
+
);
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
async activatePreferenceRegistryRevision(
|
|
1855
|
+
workspaceId: string,
|
|
1856
|
+
preferenceId: string,
|
|
1857
|
+
request: ActivatePreferenceRegistryRevisionRequest,
|
|
1858
|
+
): Promise<PreferenceRegistryMutationResponse> {
|
|
1859
|
+
return await this.requestJson<PreferenceRegistryMutationResponse>(
|
|
1860
|
+
"POST",
|
|
1861
|
+
`/v1/workspaces/${workspaceId}/preferences/${encodeURIComponent(preferenceId)}/activate`,
|
|
1862
|
+
request,
|
|
1863
|
+
);
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
async correctPreferenceRegistry(
|
|
1867
|
+
workspaceId: string,
|
|
1868
|
+
preferenceId: string,
|
|
1869
|
+
request: CorrectPreferenceRegistryRequest,
|
|
1870
|
+
): Promise<PreferenceRegistryMutationResponse> {
|
|
1871
|
+
return await this.requestJson<PreferenceRegistryMutationResponse>(
|
|
1872
|
+
"POST",
|
|
1873
|
+
`/v1/workspaces/${workspaceId}/preferences/${encodeURIComponent(preferenceId)}/correct`,
|
|
1874
|
+
request,
|
|
1875
|
+
);
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
async changePreferenceRegistryScope(
|
|
1879
|
+
workspaceId: string,
|
|
1880
|
+
preferenceId: string,
|
|
1881
|
+
request: ChangePreferenceRegistryScopeRequest,
|
|
1882
|
+
): Promise<PreferenceRegistryMutationResponse> {
|
|
1883
|
+
return await this.requestJson<PreferenceRegistryMutationResponse>(
|
|
1884
|
+
"POST",
|
|
1885
|
+
`/v1/workspaces/${workspaceId}/preferences/${encodeURIComponent(preferenceId)}/scope`,
|
|
1886
|
+
request,
|
|
1887
|
+
);
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
async deactivatePreferenceRegistry(
|
|
1891
|
+
workspaceId: string,
|
|
1892
|
+
preferenceId: string,
|
|
1893
|
+
request: DeactivatePreferenceRegistryRequest,
|
|
1894
|
+
): Promise<PreferenceRegistryMutationResponse> {
|
|
1895
|
+
return await this.requestJson<PreferenceRegistryMutationResponse>(
|
|
1896
|
+
"POST",
|
|
1897
|
+
`/v1/workspaces/${workspaceId}/preferences/${encodeURIComponent(preferenceId)}/deactivate`,
|
|
1898
|
+
request,
|
|
1899
|
+
);
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
async supersedePreferenceRegistry(
|
|
1903
|
+
workspaceId: string,
|
|
1904
|
+
preferenceId: string,
|
|
1905
|
+
request: SupersedePreferenceRegistryRequest,
|
|
1906
|
+
): Promise<PreferenceRegistryMutationResponse> {
|
|
1907
|
+
return await this.requestJson<PreferenceRegistryMutationResponse>(
|
|
1908
|
+
"POST",
|
|
1909
|
+
`/v1/workspaces/${workspaceId}/preferences/${encodeURIComponent(preferenceId)}/supersede`,
|
|
1910
|
+
request,
|
|
1911
|
+
);
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
async rejectPreferenceRegistryProposal(
|
|
1915
|
+
workspaceId: string,
|
|
1916
|
+
preferenceId: string,
|
|
1917
|
+
request: RejectPreferenceRegistryProposalRequest,
|
|
1918
|
+
): Promise<PreferenceRegistryMutationResponse> {
|
|
1919
|
+
return await this.requestJson<PreferenceRegistryMutationResponse>(
|
|
1920
|
+
"POST",
|
|
1921
|
+
`/v1/workspaces/${workspaceId}/preferences/${encodeURIComponent(preferenceId)}/reject`,
|
|
1922
|
+
request,
|
|
1923
|
+
);
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
async getPreferenceRegistrySummary(workspaceId: string): Promise<PreferenceRegistrySnapshot> {
|
|
1927
|
+
return await this.requestJson<PreferenceRegistrySnapshot>(
|
|
1928
|
+
"GET",
|
|
1929
|
+
`/v1/workspaces/${workspaceId}/preferences/summary`,
|
|
1930
|
+
);
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
async getPreferenceRegistryFullContent(
|
|
1934
|
+
workspaceId: string,
|
|
1935
|
+
retrievalHandle: string,
|
|
1936
|
+
): Promise<PreferenceRegistryFullContent> {
|
|
1937
|
+
return await this.requestJson<PreferenceRegistryFullContent>(
|
|
1938
|
+
"POST",
|
|
1939
|
+
`/v1/workspaces/${workspaceId}/preferences/full-content`,
|
|
1940
|
+
{ retrievalHandle },
|
|
1941
|
+
);
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1720
1944
|
/**
|
|
1721
1945
|
* Delete a workspace and everything in it. Refused (409) for the account's
|
|
1722
1946
|
* only workspace and while it still has a running session. Irreversible.
|
|
@@ -2627,11 +2851,14 @@ export class OpenGeniClient {
|
|
|
2627
2851
|
async startConnectionOAuth(
|
|
2628
2852
|
workspaceId: string,
|
|
2629
2853
|
request: OAuthStartRequest,
|
|
2854
|
+
options: OpenGeniRequestOptions = {},
|
|
2630
2855
|
): Promise<OAuthStartResponse> {
|
|
2631
2856
|
return await this.requestJson<OAuthStartResponse>(
|
|
2632
2857
|
"POST",
|
|
2633
2858
|
`/v1/workspaces/${workspaceId}/connections/oauth/start`,
|
|
2634
2859
|
request,
|
|
2860
|
+
{},
|
|
2861
|
+
options,
|
|
2635
2862
|
);
|
|
2636
2863
|
}
|
|
2637
2864
|
|
|
@@ -2734,6 +2961,26 @@ export class OpenGeniClient {
|
|
|
2734
2961
|
});
|
|
2735
2962
|
}
|
|
2736
2963
|
|
|
2964
|
+
async getWorkspaceInsights(
|
|
2965
|
+
workspaceId: string,
|
|
2966
|
+
options: {
|
|
2967
|
+
range?: InsightsRange;
|
|
2968
|
+
provider?: string;
|
|
2969
|
+
model?: string;
|
|
2970
|
+
} = {},
|
|
2971
|
+
): Promise<WorkspaceInsightsResponse> {
|
|
2972
|
+
return await this.requestJson<WorkspaceInsightsResponse>(
|
|
2973
|
+
"GET",
|
|
2974
|
+
`/v1/workspaces/${workspaceId}/insights`,
|
|
2975
|
+
undefined,
|
|
2976
|
+
{
|
|
2977
|
+
range: options.range ?? "week",
|
|
2978
|
+
...(options.provider !== undefined ? { provider: options.provider } : {}),
|
|
2979
|
+
...(options.model !== undefined ? { model: options.model } : {}),
|
|
2980
|
+
},
|
|
2981
|
+
);
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2737
2984
|
async getBillingEntitlements(
|
|
2738
2985
|
options: { accountId?: string } = {},
|
|
2739
2986
|
): Promise<BillingEntitlementsResponse> {
|
|
@@ -2993,6 +3240,36 @@ function assertApiContractResponse(response: Response): void {
|
|
|
2993
3240
|
}
|
|
2994
3241
|
}
|
|
2995
3242
|
|
|
3243
|
+
function isTranscribeAudioResponse(value: unknown): value is TranscribeAudioResponse {
|
|
3244
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
3245
|
+
const record = value as Record<string, unknown>;
|
|
3246
|
+
return (
|
|
3247
|
+
typeof record.text === "string" &&
|
|
3248
|
+
Array.isArray(record.languages) &&
|
|
3249
|
+
record.languages.every((language) => typeof language === "string")
|
|
3250
|
+
);
|
|
3251
|
+
}
|
|
3252
|
+
|
|
3253
|
+
function filenameForAudioMimeType(mimeType: string): string {
|
|
3254
|
+
const bare = mimeType.trim().toLowerCase().split(";")[0] ?? "audio/webm";
|
|
3255
|
+
switch (bare) {
|
|
3256
|
+
case "audio/mp4":
|
|
3257
|
+
case "audio/m4a":
|
|
3258
|
+
return "audio.mp4";
|
|
3259
|
+
case "audio/ogg":
|
|
3260
|
+
return "audio.ogg";
|
|
3261
|
+
case "audio/mpeg":
|
|
3262
|
+
case "audio/mp3":
|
|
3263
|
+
return "audio.mp3";
|
|
3264
|
+
case "audio/wav":
|
|
3265
|
+
case "audio/x-wav":
|
|
3266
|
+
return "audio.wav";
|
|
3267
|
+
case "audio/webm":
|
|
3268
|
+
default:
|
|
3269
|
+
return "audio.webm";
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
|
|
2996
3273
|
const API_ERROR_MAX_BYTES = 16 * 1024;
|
|
2997
3274
|
|
|
2998
3275
|
type ApiErrorRequestContext = {
|