@opengeni/sdk 0.44.6 → 0.46.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/dist/{chunk-ONKUBP7A.js → chunk-QKV5OCLJ.js} +146 -1
- package/dist/chunk-QKV5OCLJ.js.map +1 -0
- package/dist/client.d.ts +35 -1
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +59 -0
- package/package.json +1 -1
- package/src/client.ts +252 -0
- package/src/types.ts +92 -0
- package/dist/chunk-ONKUBP7A.js.map +0 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SessionEventStreamTransport, type StreamSessionEventsOptions } from "./stream";
|
|
2
2
|
import { type WorkspaceControlStreamTransport } from "./workspace-control-stream";
|
|
3
|
-
import type { AccessContext, ActivateCodexRealtimeConnectionRequest, AddWorkspaceMemberRequest, ApiKey, BillingEntitlementsResponse, CodexAccount, CodexAccountsResponse, CodexAppsUpdate, CodexRotationSettings, CodexOverviewResponse, CodexAllocatorUpdate, CodexConnectionStatus, CodexRealtimeWebrtcRequest, CodexRealtimeWebrtcResponse, GatewayRealtimeConnectRequest, GatewayRealtimeConnectResponse, CodexConnectPoll, CodexConnectStart, CodexUsage, CodexUsageMap, BillingSummary, BillingUsageResponse, InsightsRange, WorkspaceInsightsResponse, BeginSessionRealtimeRequest, CapabilityCatalogItem, CapabilityCatalogResponse, CapabilityInstallation, AddDocumentRequest, CreateKnowledgeDropRequest, MoveDocumentRequest, ClientConfig, WorkspaceModelCatalogResponse, WorkspaceRealtimeModelCatalogResponse, ClientSessionEventInput, CompactSessionContextResult, ConnectionMetadata, CreateApiKeyRequest, CreateApiKeyResponse, CreateCapabilityCatalogItemRequest, CreateCheckoutRequest, CreateCheckoutResponse, OpenGeniSlackBotInstallRequest, OpenGeniSlackBotInstallStart, SlackReactionChannelListResponse, CreateConnectionRequest, CreateDocumentBaseRequest, CreateFileUploadRequest, CreateFileUploadResponse, CreateGitHubAppManifestRequest, CreateGitHubAppManifestResponse, CreateKnowledgeMemoryRequest, CreateScheduledTaskRequest, CreateSessionRequest, CreateSessionResponse, CreateVariableSetRequest, CreateRigRequest, CreateWorkspaceRequest, DeviceEnrollmentApproveResponse, DeviceEnrollmentDenyResponse, DeviceEnrollmentLookupResponse, MintEnrollTokenResponse, EndSessionRealtimeRequest, DiscoverMcpCapabilitiesResponse, Document, DocumentBase, DocumentSearchRequest, DocumentSearchResponse, EnableCapabilityRequest, EnablePackRequest, FileAsset, FileDownloadUrlResponse, GetPackResponse, GitHubAppInfo, GitHubRepositoriesResponse, GoogleDriveDisconnectRequest, GoogleDriveLifecycleActionRequest, KnowledgeMemory, KnowledgeMemorySearchRequest, ListPacksResponse, MachinesResponse, MetricSample, SwapActiveSandboxRequest, SwapActiveSandboxResponse, PackInstallation, LatencyMode, ReasoningEffort, RetainedArtifactContent, RetainedArtifactContentOptions, RetainedArtifactMetadata, RegisterCapabilityPackRequest, ResourceRef, ScheduledTask, ScheduledTaskRun, Session, SessionListResponse, UpdateSessionPinRequest, SessionEvent, SessionEventCompactResult, SessionEventCompactResultOptions, SessionEventListOptions, SessionEventPage, SessionGoal, SessionHumanInputRequest, SessionLineageResponse, SessionRealtimeMutationResponse, SyncSessionRealtimeLedgerRequest, SyncSessionRealtimeLedgerResponse, RenewSessionRealtimeRequest, SessionMcpCredentialUpdateInput, UpdateSessionMcpApprovalPolicyRequest, UpdateSessionMcpApprovalPolicyResponse, SessionQueueSnapshot, SessionQueueMutationResponse, ComposerDraft, DeleteSessionQueueItemRequest, EditSessionQueueItemRequest, MoveSessionQueueItemRequest, NewSessionDraft, SaveComposerDraftRequest, SaveNewSessionDraftRequest, SteerSessionQueueItemRequest, SessionControlResponse, WorkspaceInferenceControlResponse, WorkspaceControlEvent, SessionTurn, SubmitHumanInputResponseRequest, SessionCapabilities, AttachViewerRequest, AttachViewerResponse, AcknowledgeStreamRequest, AcknowledgeStreamResponse, ViewerHeartbeatRequest, ViewerHeartbeatResponse, FsListRequest, FsListResponse, FsReadRequest, FsReadResponse, FsWriteRequest, FsWriteResponse, FsDeleteRequest, FsDeleteResponse, FsMoveRequest, FsMoveResponse, FsMkdirRequest, FsMkdirResponse, GitStatusRequest, GitStatusResponse, GitDiffRequest, GitDiffResponse, GitLogRequest, GitLogResponse, GitShowRequest, GitShowResponse, GetWorkspaceCaptureResponse, GetWorkspaceCaptureFileResponse, TerminalExecRequest, TerminalExecResponse, PtyOpenRequest, PtyOpenResponse, PtyWriteRequest, PtyResizeRequest, PtyCloseRequest, ToolRef, TranscribeAudioResponse, UpdateConnectionRequest, UpdateKnowledgeMemoryRequest, UpdateScheduledTaskRequest, UpdateSessionGoalRequest, UpdateSessionRequest, UpdateSessionToolPolicyRequest, UpdateVariableSetRequest, UpdateRigRequest, UpdateWorkspaceMemberRequest, UpdateWorkspaceRequest, UpdateWorkspaceSettingsRequest, SetWorkspaceDefaultRigRequest, UploadFileInput, VariableSet, VariableSetVariableMetadata, Rig, RigVersion, RigChange, ProposeRigChangeRequest, WorkspaceMember, WorkspaceMemorySearchRequest, WorkspaceMemorySearchResponse, WorkspaceRegisteredPack, Workspace, OAuthStartRequest, OAuthStartResponse, SocialConnection, SocialOAuthStartRequest } from "./types";
|
|
3
|
+
import type { AccessContext, ActivateCodexRealtimeConnectionRequest, AddWorkspaceMemberRequest, ApiKey, BillingEntitlementsResponse, CodexAccount, CodexAccountsResponse, CodexAppsUpdate, CodexRotationSettings, CodexOverviewResponse, CodexAllocatorUpdate, CodexConnectionStatus, CodexRealtimeWebrtcRequest, CodexRealtimeWebrtcResponse, GatewayRealtimeConnectRequest, GatewayRealtimeConnectResponse, CodexConnectPoll, CodexConnectStart, CodexUsage, CodexUsageMap, BillingSummary, BillingUsageResponse, InsightsRange, WorkspaceInsightsResponse, BeginSessionRealtimeRequest, CapabilityCatalogItem, CapabilityCatalogResponse, CapabilityInstallation, AddDocumentRequest, CreateKnowledgeDropRequest, MoveDocumentRequest, ClientConfig, WorkspaceModelCatalogResponse, WorkspaceRealtimeModelCatalogResponse, ClientSessionEventInput, CompactSessionContextResult, ConnectionMetadata, CreateApiKeyRequest, CreateApiKeyResponse, CreateCapabilityCatalogItemRequest, CreateCheckoutRequest, CreateCheckoutResponse, OpenGeniSlackBotInstallRequest, OpenGeniSlackBotInstallStart, SlackReactionChannelListResponse, CreateConnectionRequest, CreateDocumentBaseRequest, CreateFileUploadRequest, CreateFileUploadResponse, CreateGitHubAppManifestRequest, CreateGitHubAppManifestResponse, CreateKnowledgeMemoryRequest, CreateScheduledTaskRequest, CreateSessionRequest, CreateSessionResponse, CreateVariableSetRequest, CreateRigRequest, CreateWorkspaceRequest, DeviceEnrollmentApproveResponse, DeviceEnrollmentDenyResponse, DeviceEnrollmentLookupResponse, MintEnrollTokenResponse, EndSessionRealtimeRequest, DiscoverMcpCapabilitiesResponse, Document, DocumentBase, DocumentSearchRequest, DocumentSearchResponse, EnableCapabilityRequest, EnablePackRequest, FileAsset, FileDownloadUrlResponse, GetPackResponse, GitHubAppInfo, GitHubRepositoriesResponse, GoogleDriveDisconnectRequest, GoogleDriveLifecycleActionRequest, KnowledgeMemory, KnowledgeMemorySearchRequest, ListPacksResponse, MachinesResponse, MetricSample, SwapActiveSandboxRequest, SwapActiveSandboxResponse, PackInstallation, LatencyMode, ReasoningEffort, RetainedArtifactContent, RetainedArtifactContentOptions, RetainedArtifactMetadata, RegisterCapabilityPackRequest, ResourceRef, ScheduledTask, ScheduledTaskRun, Session, SessionListResponse, UpdateSessionPinRequest, SessionEvent, SessionEventCompactResult, SessionEventCompactResultOptions, SessionEventListOptions, SessionEventPage, SessionGoal, SessionHumanInputRequest, SessionLineageResponse, SessionRealtimeMutationResponse, SyncSessionRealtimeLedgerRequest, SyncSessionRealtimeLedgerResponse, RenewSessionRealtimeRequest, SessionMcpCredentialUpdateInput, UpdateSessionMcpApprovalPolicyRequest, UpdateSessionMcpApprovalPolicyResponse, SessionQueueSnapshot, SessionQueueMutationResponse, ComposerDraft, DeleteSessionQueueItemRequest, EditSessionQueueItemRequest, MoveSessionQueueItemRequest, NewSessionDraft, SaveComposerDraftRequest, SaveNewSessionDraftRequest, SteerSessionQueueItemRequest, SessionControlResponse, WorkspaceInferenceControlResponse, WorkspaceControlEvent, SessionTurn, SubmitHumanInputResponseRequest, SessionCapabilities, AttachViewerRequest, AttachViewerResponse, AcknowledgeStreamRequest, AcknowledgeStreamResponse, ViewerHeartbeatRequest, ViewerHeartbeatResponse, FsListRequest, FsListResponse, FsReadRequest, FsReadResponse, FsWriteRequest, FsWriteResponse, FsDeleteRequest, FsDeleteResponse, FsMoveRequest, FsMoveResponse, FsMkdirRequest, FsMkdirResponse, GitStatusRequest, GitStatusResponse, GitDiffRequest, GitDiffResponse, GitLogRequest, GitLogResponse, GitShowRequest, GitShowResponse, GetWorkspaceCaptureResponse, GetWorkspaceCaptureFileResponse, TerminalExecRequest, TerminalExecResponse, PtyOpenRequest, PtyOpenResponse, PtyWriteRequest, PtyResizeRequest, PtyCloseRequest, ToolRef, TranscribeAudioResponse, TranscriptionRecordingListResponse, TranscriptionRecordingResponse, UploadTranscriptionRecordingChunkResponse, UpdateConnectionRequest, UpdateKnowledgeMemoryRequest, UpdateScheduledTaskRequest, UpdateSessionGoalRequest, UpdateSessionRequest, UpdateSessionToolPolicyRequest, UpdateVariableSetRequest, UpdateRigRequest, UpdateWorkspaceMemberRequest, UpdateWorkspaceRequest, UpdateWorkspaceSettingsRequest, SetWorkspaceDefaultRigRequest, UploadFileInput, VariableSet, VariableSetVariableMetadata, Rig, RigVersion, RigChange, ProposeRigChangeRequest, WorkspaceMember, WorkspaceMemorySearchRequest, WorkspaceMemorySearchResponse, WorkspaceRegisteredPack, Workspace, OAuthStartRequest, OAuthStartResponse, SocialConnection, SocialOAuthStartRequest } from "./types";
|
|
4
4
|
import type { ActivateWorkspaceInstructionPolicyRequest, CreateWorkspaceInstructionPolicyDraftRequest, CreateWorkspaceInstructionPolicyOnboardingProposalRequest, ImportLegacyWorkspaceInstructionPolicyDraftRequest, RollbackWorkspaceInstructionPolicyRequest, WorkspaceInstructionPolicyActivationResponse, WorkspaceInstructionPolicyDiffRequest, WorkspaceInstructionPolicyDiffResponse, WorkspaceInstructionPolicyListOptions, WorkspaceInstructionPolicyListResponse, WorkspaceInstructionPolicyOnboardingProposal, WorkspaceInstructionPolicyOnboardingProposalListOptions, WorkspaceInstructionPolicyOnboardingProposalListResponse, WorkspaceInstructionPolicyRevision } from "./workspace-instruction-policies";
|
|
5
5
|
import type { WorkspaceStateExportResponse, WorkspaceStateGetOptions, WorkspaceStateResponse } from "./workspace-state";
|
|
6
6
|
import type { ActivatePreferenceRegistryRevisionRequest, ChangePreferenceRegistryScopeRequest, CorrectPreferenceRegistryRequest, CreatePreferenceRegistryProposalRequest, DeactivatePreferenceRegistryRequest, PreferenceRegistryDetailResponse, PreferenceRegistryFullContent, PreferenceRegistryListOptions, PreferenceRegistryListResponse, PreferenceRegistryMutationResponse, PreferenceRegistryRecord, PreferenceRegistrySnapshot, RejectPreferenceRegistryProposalRequest, SupersedePreferenceRegistryRequest } from "./preference-registry";
|
|
@@ -51,6 +51,25 @@ export type TranscribeAudioInput = {
|
|
|
51
51
|
durationSeconds?: number | undefined;
|
|
52
52
|
signal?: AbortSignal | undefined;
|
|
53
53
|
};
|
|
54
|
+
export type CreateTranscriptionRecordingInput = {
|
|
55
|
+
recordingId: string;
|
|
56
|
+
mimeType: string;
|
|
57
|
+
signal?: AbortSignal | undefined;
|
|
58
|
+
};
|
|
59
|
+
export type UploadTranscriptionRecordingChunkInput = {
|
|
60
|
+
audio: Blob | File | Uint8Array;
|
|
61
|
+
mimeType: string;
|
|
62
|
+
sha256: string;
|
|
63
|
+
startMilliseconds: number;
|
|
64
|
+
durationMilliseconds: number;
|
|
65
|
+
signal?: AbortSignal | undefined;
|
|
66
|
+
};
|
|
67
|
+
export type FinalizeTranscriptionRecordingInput = {
|
|
68
|
+
chunkCount: number;
|
|
69
|
+
totalBytes: number;
|
|
70
|
+
totalDurationMilliseconds: number;
|
|
71
|
+
signal?: AbortSignal | undefined;
|
|
72
|
+
};
|
|
54
73
|
/**
|
|
55
74
|
* Typed client for the OpenGeni public API. Framework-agnostic: only needs
|
|
56
75
|
* WHATWG `fetch` + streams, so it runs in Node 18+, Bun, Deno, browsers, and
|
|
@@ -63,6 +82,21 @@ export declare class OpenGeniClient {
|
|
|
63
82
|
constructor(options: OpenGeniClientOptions);
|
|
64
83
|
/** Make one finalization attempt for a recording; callers may retry retained audio. */
|
|
65
84
|
transcribeAudio(workspaceId: string, input: TranscribeAudioInput): Promise<TranscribeAudioResponse>;
|
|
85
|
+
createTranscriptionRecording(workspaceId: string, input: CreateTranscriptionRecordingInput): Promise<TranscriptionRecordingResponse>;
|
|
86
|
+
getTranscriptionRecording(workspaceId: string, recordingId: string, options?: {
|
|
87
|
+
signal?: AbortSignal | undefined;
|
|
88
|
+
}): Promise<TranscriptionRecordingResponse>;
|
|
89
|
+
listTranscriptionRecordings(workspaceId: string, options?: {
|
|
90
|
+
signal?: AbortSignal | undefined;
|
|
91
|
+
}): Promise<TranscriptionRecordingListResponse>;
|
|
92
|
+
uploadTranscriptionRecordingChunk(workspaceId: string, recordingId: string, chunkNumber: number, input: UploadTranscriptionRecordingChunkInput): Promise<UploadTranscriptionRecordingChunkResponse>;
|
|
93
|
+
finalizeTranscriptionRecording(workspaceId: string, recordingId: string, input: FinalizeTranscriptionRecordingInput): Promise<TranscriptionRecordingResponse>;
|
|
94
|
+
processNextTranscriptionRecordingSegment(workspaceId: string, recordingId: string, options?: {
|
|
95
|
+
signal?: AbortSignal | undefined;
|
|
96
|
+
}): Promise<TranscriptionRecordingResponse>;
|
|
97
|
+
discardTranscriptionRecording(workspaceId: string, recordingId: string, options?: {
|
|
98
|
+
signal?: AbortSignal | undefined;
|
|
99
|
+
}): Promise<TranscriptionRecordingResponse>;
|
|
66
100
|
createSession(workspaceId: string, request: CreateSessionRequest): Promise<CreateSessionResponse>;
|
|
67
101
|
getNewSessionDraft(workspaceId: string): Promise<NewSessionDraft>;
|
|
68
102
|
saveNewSessionDraft(workspaceId: string, request: SaveNewSessionDraftRequest): Promise<NewSessionDraft>;
|
package/dist/core.js
CHANGED
package/dist/index.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1972,6 +1972,65 @@ export type ClientVoiceInputConfig = {
|
|
|
1972
1972
|
maxDurationSeconds: number;
|
|
1973
1973
|
maxSizeBytes: number;
|
|
1974
1974
|
acceptedMimeTypes: string[];
|
|
1975
|
+
resumable?: ClientResumableVoiceInputConfig | undefined;
|
|
1976
|
+
};
|
|
1977
|
+
export type ClientResumableVoiceInputConfig = {
|
|
1978
|
+
maxDurationSeconds: number;
|
|
1979
|
+
maxSizeBytes: number;
|
|
1980
|
+
maxChunkSizeBytes: number;
|
|
1981
|
+
providerSegmentSeconds: number;
|
|
1982
|
+
};
|
|
1983
|
+
export type TranscriptionRecordingErrorCode = "permission_denied" | "not_supported" | "network" | "provider" | "policy_blocked" | "timeout" | "cancelled" | "unavailable" | "too_large" | "invalid_audio" | "unknown";
|
|
1984
|
+
export type TranscriptionRecordingState = "uploading" | "segmenting" | "ready" | "transcribing" | "complete" | "failed" | "discarded";
|
|
1985
|
+
export type TranscriptionRecordingSegmentState = "preparing" | "pending" | "transcribing" | "complete" | "failed";
|
|
1986
|
+
export type TranscriptionRecordingSegment = {
|
|
1987
|
+
segmentNumber: number;
|
|
1988
|
+
state: TranscriptionRecordingSegmentState;
|
|
1989
|
+
startMilliseconds: number;
|
|
1990
|
+
durationMilliseconds: number;
|
|
1991
|
+
byteLength: number;
|
|
1992
|
+
errorCode: TranscriptionRecordingErrorCode | null;
|
|
1993
|
+
retryable: boolean;
|
|
1994
|
+
};
|
|
1995
|
+
export type TranscriptionRecording = {
|
|
1996
|
+
id: string;
|
|
1997
|
+
workspaceId: string;
|
|
1998
|
+
mimeType: string;
|
|
1999
|
+
state: TranscriptionRecordingState;
|
|
2000
|
+
nextChunkNumber: number;
|
|
2001
|
+
chunkCount: number;
|
|
2002
|
+
totalBytes: number;
|
|
2003
|
+
totalDurationMilliseconds: number;
|
|
2004
|
+
segmentCount: number;
|
|
2005
|
+
completedSegmentCount: number;
|
|
2006
|
+
transcriptText: string | null;
|
|
2007
|
+
languages: string[];
|
|
2008
|
+
errorCode: TranscriptionRecordingErrorCode | null;
|
|
2009
|
+
retryable: boolean;
|
|
2010
|
+
objectsCleaned: boolean;
|
|
2011
|
+
createdAt: string;
|
|
2012
|
+
updatedAt: string;
|
|
2013
|
+
expiresAt: string;
|
|
2014
|
+
};
|
|
2015
|
+
export type TranscriptionRecordingResponse = {
|
|
2016
|
+
recording: TranscriptionRecording;
|
|
2017
|
+
segments: TranscriptionRecordingSegment[];
|
|
2018
|
+
retryAfterMilliseconds?: number;
|
|
2019
|
+
};
|
|
2020
|
+
export type TranscriptionRecordingListResponse = {
|
|
2021
|
+
recordings: TranscriptionRecording[];
|
|
2022
|
+
};
|
|
2023
|
+
export type TranscriptionRecordingChunk = {
|
|
2024
|
+
chunkNumber: number;
|
|
2025
|
+
byteLength: number;
|
|
2026
|
+
sha256: string;
|
|
2027
|
+
startMilliseconds: number;
|
|
2028
|
+
durationMilliseconds: number;
|
|
2029
|
+
deduplicated: boolean;
|
|
2030
|
+
};
|
|
2031
|
+
export type UploadTranscriptionRecordingChunkResponse = {
|
|
2032
|
+
recording: TranscriptionRecording;
|
|
2033
|
+
chunk: TranscriptionRecordingChunk;
|
|
1975
2034
|
};
|
|
1976
2035
|
/** Response from POST /v1/workspaces/:workspaceId/transcriptions. */
|
|
1977
2036
|
export type TranscribeAudioResponse = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
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": {
|
package/src/client.ts
CHANGED
|
@@ -189,6 +189,9 @@ import type {
|
|
|
189
189
|
PtyCloseRequest,
|
|
190
190
|
ToolRef,
|
|
191
191
|
TranscribeAudioResponse,
|
|
192
|
+
TranscriptionRecordingListResponse,
|
|
193
|
+
TranscriptionRecordingResponse,
|
|
194
|
+
UploadTranscriptionRecordingChunkResponse,
|
|
192
195
|
UpdateConnectionRequest,
|
|
193
196
|
UpdateKnowledgeMemoryRequest,
|
|
194
197
|
UpdateScheduledTaskRequest,
|
|
@@ -329,6 +332,28 @@ export type TranscribeAudioInput = {
|
|
|
329
332
|
signal?: AbortSignal | undefined;
|
|
330
333
|
};
|
|
331
334
|
|
|
335
|
+
export type CreateTranscriptionRecordingInput = {
|
|
336
|
+
recordingId: string;
|
|
337
|
+
mimeType: string;
|
|
338
|
+
signal?: AbortSignal | undefined;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
export type UploadTranscriptionRecordingChunkInput = {
|
|
342
|
+
audio: Blob | File | Uint8Array;
|
|
343
|
+
mimeType: string;
|
|
344
|
+
sha256: string;
|
|
345
|
+
startMilliseconds: number;
|
|
346
|
+
durationMilliseconds: number;
|
|
347
|
+
signal?: AbortSignal | undefined;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
export type FinalizeTranscriptionRecordingInput = {
|
|
351
|
+
chunkCount: number;
|
|
352
|
+
totalBytes: number;
|
|
353
|
+
totalDurationMilliseconds: number;
|
|
354
|
+
signal?: AbortSignal | undefined;
|
|
355
|
+
};
|
|
356
|
+
|
|
332
357
|
/**
|
|
333
358
|
* Typed client for the OpenGeni public API. Framework-agnostic: only needs
|
|
334
359
|
* WHATWG `fetch` + streams, so it runs in Node 18+, Bun, Deno, browsers, and
|
|
@@ -402,6 +427,153 @@ export class OpenGeniClient {
|
|
|
402
427
|
return body;
|
|
403
428
|
}
|
|
404
429
|
|
|
430
|
+
async createTranscriptionRecording(
|
|
431
|
+
workspaceId: string,
|
|
432
|
+
input: CreateTranscriptionRecordingInput,
|
|
433
|
+
): Promise<TranscriptionRecordingResponse> {
|
|
434
|
+
return transcriptionRecordingResponse(
|
|
435
|
+
await this.requestJson<unknown>(
|
|
436
|
+
"POST",
|
|
437
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings`,
|
|
438
|
+
{ recordingId: input.recordingId, mimeType: input.mimeType },
|
|
439
|
+
{},
|
|
440
|
+
input.signal ? { signal: input.signal } : {},
|
|
441
|
+
),
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
async getTranscriptionRecording(
|
|
446
|
+
workspaceId: string,
|
|
447
|
+
recordingId: string,
|
|
448
|
+
options: { signal?: AbortSignal | undefined } = {},
|
|
449
|
+
): Promise<TranscriptionRecordingResponse> {
|
|
450
|
+
return transcriptionRecordingResponse(
|
|
451
|
+
await this.requestJson<unknown>(
|
|
452
|
+
"GET",
|
|
453
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings/${recordingId}`,
|
|
454
|
+
undefined,
|
|
455
|
+
{},
|
|
456
|
+
options.signal ? { signal: options.signal } : {},
|
|
457
|
+
),
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
async listTranscriptionRecordings(
|
|
462
|
+
workspaceId: string,
|
|
463
|
+
options: { signal?: AbortSignal | undefined } = {},
|
|
464
|
+
): Promise<TranscriptionRecordingListResponse> {
|
|
465
|
+
const body = await this.requestJson<unknown>(
|
|
466
|
+
"GET",
|
|
467
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings`,
|
|
468
|
+
undefined,
|
|
469
|
+
{},
|
|
470
|
+
options.signal ? { signal: options.signal } : {},
|
|
471
|
+
);
|
|
472
|
+
if (!isTranscriptionRecordingListResponse(body)) {
|
|
473
|
+
throw new OpenGeniApiError(502, "Invalid transcription recording list response.", {
|
|
474
|
+
code: "invalid_response",
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
return body;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
async uploadTranscriptionRecordingChunk(
|
|
481
|
+
workspaceId: string,
|
|
482
|
+
recordingId: string,
|
|
483
|
+
chunkNumber: number,
|
|
484
|
+
input: UploadTranscriptionRecordingChunkInput,
|
|
485
|
+
): Promise<UploadTranscriptionRecordingChunkResponse> {
|
|
486
|
+
const correlationId = crypto.randomUUID();
|
|
487
|
+
let response: Response;
|
|
488
|
+
try {
|
|
489
|
+
response = await this.fetchImpl(
|
|
490
|
+
this.url(
|
|
491
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings/${recordingId}/chunks/${chunkNumber}`,
|
|
492
|
+
),
|
|
493
|
+
{
|
|
494
|
+
method: "PUT",
|
|
495
|
+
headers: {
|
|
496
|
+
...this.headers(correlationId),
|
|
497
|
+
Accept: "application/json",
|
|
498
|
+
"Content-Type": input.mimeType,
|
|
499
|
+
"x-opengeni-chunk-sha256": input.sha256,
|
|
500
|
+
"x-opengeni-chunk-start-milliseconds": String(input.startMilliseconds),
|
|
501
|
+
"x-opengeni-chunk-duration-milliseconds": String(input.durationMilliseconds),
|
|
502
|
+
},
|
|
503
|
+
body: input.audio instanceof Uint8Array ? Uint8Array.from(input.audio) : input.audio,
|
|
504
|
+
...(input.signal ? { signal: input.signal } : {}),
|
|
505
|
+
},
|
|
506
|
+
);
|
|
507
|
+
} catch (error) {
|
|
508
|
+
if (input.signal?.aborted) throw error;
|
|
509
|
+
throw mutationTransportError(correlationId);
|
|
510
|
+
}
|
|
511
|
+
assertApiContractResponse(response);
|
|
512
|
+
if (!response.ok) throw await apiErrorFromResponse(response, { method: "PUT", correlationId });
|
|
513
|
+
await assertJsonResponse(response, { method: "PUT", correlationId });
|
|
514
|
+
const body = await response.json().catch(() => null);
|
|
515
|
+
if (!isUploadTranscriptionRecordingChunkResponse(body)) {
|
|
516
|
+
throw new OpenGeniApiError(response.status, "Invalid transcription chunk response.", {
|
|
517
|
+
code: "invalid_response",
|
|
518
|
+
mutation: true,
|
|
519
|
+
correlationId,
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
return body;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
async finalizeTranscriptionRecording(
|
|
526
|
+
workspaceId: string,
|
|
527
|
+
recordingId: string,
|
|
528
|
+
input: FinalizeTranscriptionRecordingInput,
|
|
529
|
+
): Promise<TranscriptionRecordingResponse> {
|
|
530
|
+
return transcriptionRecordingResponse(
|
|
531
|
+
await this.requestJson<unknown>(
|
|
532
|
+
"POST",
|
|
533
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings/${recordingId}/finalize`,
|
|
534
|
+
{
|
|
535
|
+
chunkCount: input.chunkCount,
|
|
536
|
+
totalBytes: input.totalBytes,
|
|
537
|
+
totalDurationMilliseconds: input.totalDurationMilliseconds,
|
|
538
|
+
},
|
|
539
|
+
{},
|
|
540
|
+
input.signal ? { signal: input.signal } : {},
|
|
541
|
+
),
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
async processNextTranscriptionRecordingSegment(
|
|
546
|
+
workspaceId: string,
|
|
547
|
+
recordingId: string,
|
|
548
|
+
options: { signal?: AbortSignal | undefined } = {},
|
|
549
|
+
): Promise<TranscriptionRecordingResponse> {
|
|
550
|
+
return transcriptionRecordingResponse(
|
|
551
|
+
await this.requestJson<unknown>(
|
|
552
|
+
"POST",
|
|
553
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings/${recordingId}/process-next`,
|
|
554
|
+
{},
|
|
555
|
+
{},
|
|
556
|
+
options.signal ? { signal: options.signal } : {},
|
|
557
|
+
),
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
async discardTranscriptionRecording(
|
|
562
|
+
workspaceId: string,
|
|
563
|
+
recordingId: string,
|
|
564
|
+
options: { signal?: AbortSignal | undefined } = {},
|
|
565
|
+
): Promise<TranscriptionRecordingResponse> {
|
|
566
|
+
return transcriptionRecordingResponse(
|
|
567
|
+
await this.requestJson<unknown>(
|
|
568
|
+
"DELETE",
|
|
569
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings/${recordingId}`,
|
|
570
|
+
undefined,
|
|
571
|
+
{},
|
|
572
|
+
options.signal ? { signal: options.signal } : {},
|
|
573
|
+
),
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
|
|
405
577
|
async createSession(
|
|
406
578
|
workspaceId: string,
|
|
407
579
|
request: CreateSessionRequest,
|
|
@@ -3595,6 +3767,86 @@ function isTranscribeAudioResponse(value: unknown): value is TranscribeAudioResp
|
|
|
3595
3767
|
);
|
|
3596
3768
|
}
|
|
3597
3769
|
|
|
3770
|
+
function isUploadTranscriptionRecordingChunkResponse(
|
|
3771
|
+
value: unknown,
|
|
3772
|
+
): value is UploadTranscriptionRecordingChunkResponse {
|
|
3773
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
3774
|
+
const record = value as Record<string, unknown>;
|
|
3775
|
+
if (!isTranscriptionRecordingResponse({ recording: record.recording, segments: [] })) {
|
|
3776
|
+
return false;
|
|
3777
|
+
}
|
|
3778
|
+
if (!record.chunk || typeof record.chunk !== "object" || Array.isArray(record.chunk)) {
|
|
3779
|
+
return false;
|
|
3780
|
+
}
|
|
3781
|
+
const chunk = record.chunk as Record<string, unknown>;
|
|
3782
|
+
return (
|
|
3783
|
+
typeof chunk.chunkNumber === "number" &&
|
|
3784
|
+
typeof chunk.byteLength === "number" &&
|
|
3785
|
+
typeof chunk.sha256 === "string" &&
|
|
3786
|
+
typeof chunk.startMilliseconds === "number" &&
|
|
3787
|
+
typeof chunk.durationMilliseconds === "number" &&
|
|
3788
|
+
typeof chunk.deduplicated === "boolean"
|
|
3789
|
+
);
|
|
3790
|
+
}
|
|
3791
|
+
|
|
3792
|
+
function isTranscriptionRecordingResponse(value: unknown): value is TranscriptionRecordingResponse {
|
|
3793
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
3794
|
+
const response = value as Record<string, unknown>;
|
|
3795
|
+
if (
|
|
3796
|
+
!response.recording ||
|
|
3797
|
+
typeof response.recording !== "object" ||
|
|
3798
|
+
Array.isArray(response.recording)
|
|
3799
|
+
) {
|
|
3800
|
+
return false;
|
|
3801
|
+
}
|
|
3802
|
+
const recording = response.recording as Record<string, unknown>;
|
|
3803
|
+
return (
|
|
3804
|
+
typeof recording.id === "string" &&
|
|
3805
|
+
typeof recording.workspaceId === "string" &&
|
|
3806
|
+
typeof recording.mimeType === "string" &&
|
|
3807
|
+
typeof recording.state === "string" &&
|
|
3808
|
+
typeof recording.nextChunkNumber === "number" &&
|
|
3809
|
+
typeof recording.chunkCount === "number" &&
|
|
3810
|
+
typeof recording.totalBytes === "number" &&
|
|
3811
|
+
typeof recording.totalDurationMilliseconds === "number" &&
|
|
3812
|
+
typeof recording.segmentCount === "number" &&
|
|
3813
|
+
typeof recording.completedSegmentCount === "number" &&
|
|
3814
|
+
(recording.transcriptText === null || typeof recording.transcriptText === "string") &&
|
|
3815
|
+
Array.isArray(recording.languages) &&
|
|
3816
|
+
(recording.errorCode === null || typeof recording.errorCode === "string") &&
|
|
3817
|
+
typeof recording.retryable === "boolean" &&
|
|
3818
|
+
typeof recording.objectsCleaned === "boolean" &&
|
|
3819
|
+
typeof recording.createdAt === "string" &&
|
|
3820
|
+
typeof recording.updatedAt === "string" &&
|
|
3821
|
+
typeof recording.expiresAt === "string" &&
|
|
3822
|
+
(response.retryAfterMilliseconds === undefined ||
|
|
3823
|
+
(typeof response.retryAfterMilliseconds === "number" &&
|
|
3824
|
+
Number.isInteger(response.retryAfterMilliseconds) &&
|
|
3825
|
+
response.retryAfterMilliseconds > 0 &&
|
|
3826
|
+
response.retryAfterMilliseconds <= 60_000)) &&
|
|
3827
|
+
Array.isArray(response.segments)
|
|
3828
|
+
);
|
|
3829
|
+
}
|
|
3830
|
+
|
|
3831
|
+
function transcriptionRecordingResponse(value: unknown): TranscriptionRecordingResponse {
|
|
3832
|
+
if (isTranscriptionRecordingResponse(value)) return value;
|
|
3833
|
+
throw new OpenGeniApiError(502, "Invalid transcription recording response.", {
|
|
3834
|
+
code: "invalid_response",
|
|
3835
|
+
});
|
|
3836
|
+
}
|
|
3837
|
+
|
|
3838
|
+
function isTranscriptionRecordingListResponse(
|
|
3839
|
+
value: unknown,
|
|
3840
|
+
): value is TranscriptionRecordingListResponse {
|
|
3841
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
3842
|
+
const recordings = (value as Record<string, unknown>).recordings;
|
|
3843
|
+
return (
|
|
3844
|
+
Array.isArray(recordings) &&
|
|
3845
|
+
recordings.length <= 50 &&
|
|
3846
|
+
recordings.every((recording) => isTranscriptionRecordingResponse({ recording, segments: [] }))
|
|
3847
|
+
);
|
|
3848
|
+
}
|
|
3849
|
+
|
|
3598
3850
|
function filenameForAudioMimeType(mimeType: string): string {
|
|
3599
3851
|
const bare = mimeType.trim().toLowerCase().split(";")[0] ?? "audio/webm";
|
|
3600
3852
|
switch (bare) {
|
package/src/types.ts
CHANGED
|
@@ -2568,6 +2568,98 @@ export type ClientVoiceInputConfig = {
|
|
|
2568
2568
|
maxDurationSeconds: number;
|
|
2569
2569
|
maxSizeBytes: number;
|
|
2570
2570
|
acceptedMimeTypes: string[];
|
|
2571
|
+
resumable?: ClientResumableVoiceInputConfig | undefined;
|
|
2572
|
+
};
|
|
2573
|
+
|
|
2574
|
+
export type ClientResumableVoiceInputConfig = {
|
|
2575
|
+
maxDurationSeconds: number;
|
|
2576
|
+
maxSizeBytes: number;
|
|
2577
|
+
maxChunkSizeBytes: number;
|
|
2578
|
+
providerSegmentSeconds: number;
|
|
2579
|
+
};
|
|
2580
|
+
|
|
2581
|
+
export type TranscriptionRecordingErrorCode =
|
|
2582
|
+
| "permission_denied"
|
|
2583
|
+
| "not_supported"
|
|
2584
|
+
| "network"
|
|
2585
|
+
| "provider"
|
|
2586
|
+
| "policy_blocked"
|
|
2587
|
+
| "timeout"
|
|
2588
|
+
| "cancelled"
|
|
2589
|
+
| "unavailable"
|
|
2590
|
+
| "too_large"
|
|
2591
|
+
| "invalid_audio"
|
|
2592
|
+
| "unknown";
|
|
2593
|
+
|
|
2594
|
+
export type TranscriptionRecordingState =
|
|
2595
|
+
| "uploading"
|
|
2596
|
+
| "segmenting"
|
|
2597
|
+
| "ready"
|
|
2598
|
+
| "transcribing"
|
|
2599
|
+
| "complete"
|
|
2600
|
+
| "failed"
|
|
2601
|
+
| "discarded";
|
|
2602
|
+
|
|
2603
|
+
export type TranscriptionRecordingSegmentState =
|
|
2604
|
+
| "preparing"
|
|
2605
|
+
| "pending"
|
|
2606
|
+
| "transcribing"
|
|
2607
|
+
| "complete"
|
|
2608
|
+
| "failed";
|
|
2609
|
+
|
|
2610
|
+
export type TranscriptionRecordingSegment = {
|
|
2611
|
+
segmentNumber: number;
|
|
2612
|
+
state: TranscriptionRecordingSegmentState;
|
|
2613
|
+
startMilliseconds: number;
|
|
2614
|
+
durationMilliseconds: number;
|
|
2615
|
+
byteLength: number;
|
|
2616
|
+
errorCode: TranscriptionRecordingErrorCode | null;
|
|
2617
|
+
retryable: boolean;
|
|
2618
|
+
};
|
|
2619
|
+
|
|
2620
|
+
export type TranscriptionRecording = {
|
|
2621
|
+
id: string;
|
|
2622
|
+
workspaceId: string;
|
|
2623
|
+
mimeType: string;
|
|
2624
|
+
state: TranscriptionRecordingState;
|
|
2625
|
+
nextChunkNumber: number;
|
|
2626
|
+
chunkCount: number;
|
|
2627
|
+
totalBytes: number;
|
|
2628
|
+
totalDurationMilliseconds: number;
|
|
2629
|
+
segmentCount: number;
|
|
2630
|
+
completedSegmentCount: number;
|
|
2631
|
+
transcriptText: string | null;
|
|
2632
|
+
languages: string[];
|
|
2633
|
+
errorCode: TranscriptionRecordingErrorCode | null;
|
|
2634
|
+
retryable: boolean;
|
|
2635
|
+
objectsCleaned: boolean;
|
|
2636
|
+
createdAt: string;
|
|
2637
|
+
updatedAt: string;
|
|
2638
|
+
expiresAt: string;
|
|
2639
|
+
};
|
|
2640
|
+
|
|
2641
|
+
export type TranscriptionRecordingResponse = {
|
|
2642
|
+
recording: TranscriptionRecording;
|
|
2643
|
+
segments: TranscriptionRecordingSegment[];
|
|
2644
|
+
retryAfterMilliseconds?: number;
|
|
2645
|
+
};
|
|
2646
|
+
|
|
2647
|
+
export type TranscriptionRecordingListResponse = {
|
|
2648
|
+
recordings: TranscriptionRecording[];
|
|
2649
|
+
};
|
|
2650
|
+
|
|
2651
|
+
export type TranscriptionRecordingChunk = {
|
|
2652
|
+
chunkNumber: number;
|
|
2653
|
+
byteLength: number;
|
|
2654
|
+
sha256: string;
|
|
2655
|
+
startMilliseconds: number;
|
|
2656
|
+
durationMilliseconds: number;
|
|
2657
|
+
deduplicated: boolean;
|
|
2658
|
+
};
|
|
2659
|
+
|
|
2660
|
+
export type UploadTranscriptionRecordingChunkResponse = {
|
|
2661
|
+
recording: TranscriptionRecording;
|
|
2662
|
+
chunk: TranscriptionRecordingChunk;
|
|
2571
2663
|
};
|
|
2572
2664
|
|
|
2573
2665
|
/** Response from POST /v1/workspaces/:workspaceId/transcriptions. */
|