@neta-art/cohub 1.21.0 → 1.23.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/chunks/environment.d.ts +32 -0
- package/dist/chunks/environment.js +18 -6
- package/dist/chunks/http.d.ts +108 -2
- package/dist/chunks/http.js +18 -1
- package/dist/chunks/voice-input.d.ts +94 -0
- package/dist/chunks/websocket.d.ts +297 -26
- package/dist/chunks/websocket.js +2 -2
- package/dist/http.d.ts +3 -3
- package/dist/index.d.ts +27 -3
- package/dist/index.js +36 -3
- package/dist/voice-input.d.ts +2 -0
- package/dist/voice-input.js +394 -0
- package/package.json +5 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/environment.d.ts
|
|
2
|
+
type CohubEnvironment = "prod" | "dev";
|
|
3
|
+
declare const COHUB_ENVIRONMENTS: {
|
|
4
|
+
readonly prod: {
|
|
5
|
+
readonly apiBaseUrl: "https://api.cohub.run";
|
|
6
|
+
readonly websocketUrl: "wss://gateway.cohub.run/ws";
|
|
7
|
+
readonly voiceInputWebsocketUrl: "wss://gateway.cohub.run/asr/ws";
|
|
8
|
+
};
|
|
9
|
+
readonly dev: {
|
|
10
|
+
readonly apiBaseUrl: "https://api-dev.cohub.run";
|
|
11
|
+
readonly websocketUrl: "wss://gateway-dev.cohub.run/ws";
|
|
12
|
+
readonly voiceInputWebsocketUrl: "wss://gateway-dev.cohub.run/asr/ws";
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
declare const resolveCohubEnvironment: (env?: CohubEnvironment) => CohubEnvironment;
|
|
16
|
+
declare const normalizeBaseUrl: (url: string) => string;
|
|
17
|
+
declare const normalizeWebsocketUrl: (input: string) => string;
|
|
18
|
+
declare const normalizeVoiceInputWebsocketUrl: (input: string) => string;
|
|
19
|
+
declare const resolveApiBaseUrl: (options?: {
|
|
20
|
+
baseUrl?: string;
|
|
21
|
+
env?: CohubEnvironment;
|
|
22
|
+
}) => string;
|
|
23
|
+
declare const resolveWebsocketUrl: (options?: {
|
|
24
|
+
url?: string;
|
|
25
|
+
env?: CohubEnvironment;
|
|
26
|
+
}) => string;
|
|
27
|
+
declare const resolveVoiceInputWebsocketUrl: (options?: {
|
|
28
|
+
url?: string;
|
|
29
|
+
env?: CohubEnvironment;
|
|
30
|
+
}) => string;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { normalizeWebsocketUrl as a, resolveVoiceInputWebsocketUrl as c, normalizeVoiceInputWebsocketUrl as i, resolveWebsocketUrl as l, CohubEnvironment as n, resolveApiBaseUrl as o, normalizeBaseUrl as r, resolveCohubEnvironment as s, COHUB_ENVIRONMENTS as t };
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
const COHUB_ENVIRONMENTS = {
|
|
3
3
|
prod: {
|
|
4
4
|
apiBaseUrl: "https://api.cohub.run",
|
|
5
|
-
websocketUrl: "wss://gateway.cohub.run/ws"
|
|
5
|
+
websocketUrl: "wss://gateway.cohub.run/ws",
|
|
6
|
+
voiceInputWebsocketUrl: "wss://gateway.cohub.run/asr/ws"
|
|
6
7
|
},
|
|
7
8
|
dev: {
|
|
8
9
|
apiBaseUrl: "https://api-dev.cohub.run",
|
|
9
|
-
websocketUrl: "wss://gateway-dev.cohub.run/ws"
|
|
10
|
+
websocketUrl: "wss://gateway-dev.cohub.run/ws",
|
|
11
|
+
voiceInputWebsocketUrl: "wss://gateway-dev.cohub.run/asr/ws"
|
|
10
12
|
}
|
|
11
13
|
};
|
|
12
14
|
const readRuntimeEnv = () => {
|
|
@@ -17,10 +19,16 @@ const resolveCohubEnvironment = (env) => {
|
|
|
17
19
|
return readRuntimeEnv() === "dev" ? "dev" : "prod";
|
|
18
20
|
};
|
|
19
21
|
const normalizeBaseUrl = (url) => url.trim().replace(/\/+$/, "");
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
const normalizeWebsocketPath = (input, path, replacePaths = []) => {
|
|
23
|
+
let withProtocol = normalizeBaseUrl(input).replace(/^http:/, "ws:").replace(/^https:/, "wss:");
|
|
24
|
+
for (const replacePath of replacePaths) if (withProtocol.endsWith(replacePath)) {
|
|
25
|
+
withProtocol = withProtocol.slice(0, -replacePath.length);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
return withProtocol.endsWith(path) ? withProtocol : `${withProtocol}${path}`;
|
|
23
29
|
};
|
|
30
|
+
const normalizeWebsocketUrl = (input) => normalizeWebsocketPath(input, "/ws", ["/asr/ws"]);
|
|
31
|
+
const normalizeVoiceInputWebsocketUrl = (input) => normalizeWebsocketPath(input, "/asr/ws", ["/ws"]);
|
|
24
32
|
const resolveApiBaseUrl = (options = {}) => {
|
|
25
33
|
if (options.baseUrl) return normalizeBaseUrl(options.baseUrl);
|
|
26
34
|
return COHUB_ENVIRONMENTS[resolveCohubEnvironment(options.env)].apiBaseUrl;
|
|
@@ -29,5 +37,9 @@ const resolveWebsocketUrl = (options = {}) => {
|
|
|
29
37
|
if (options.url) return normalizeWebsocketUrl(options.url);
|
|
30
38
|
return COHUB_ENVIRONMENTS[resolveCohubEnvironment(options.env)].websocketUrl;
|
|
31
39
|
};
|
|
40
|
+
const resolveVoiceInputWebsocketUrl = (options = {}) => {
|
|
41
|
+
if (options.url) return normalizeVoiceInputWebsocketUrl(options.url);
|
|
42
|
+
return COHUB_ENVIRONMENTS[resolveCohubEnvironment(options.env)].voiceInputWebsocketUrl;
|
|
43
|
+
};
|
|
32
44
|
//#endregion
|
|
33
|
-
export {
|
|
45
|
+
export { resolveApiBaseUrl as a, resolveWebsocketUrl as c, normalizeWebsocketUrl as i, normalizeBaseUrl as n, resolveCohubEnvironment as o, normalizeVoiceInputWebsocketUrl as r, resolveVoiceInputWebsocketUrl as s, COHUB_ENVIRONMENTS as t };
|
package/dist/chunks/http.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as CohubEnvironment } from "./environment.js";
|
|
2
|
+
import { C as ContentBlock, S as Usage, _ as SessionForkRecord, a as WebsocketClientOptions, b as SessionTurnIndexItem, d as RealtimePatchOperation, g as SessionBindingRecord$1, h as MessageRecord, m as SpacePublicEndpoints, p as SessionTurnPatchEvent, r as WebsocketClient, s as WebsocketEventPayload, v as SessionRecord$1, x as SessionTurnRecord } from "./websocket.js";
|
|
3
|
+
import { a as VoiceInputCreateOptions } from "./voice-input.js";
|
|
2
4
|
|
|
3
5
|
//#region src/transport.d.ts
|
|
4
6
|
type Fetch = typeof globalThis.fetch;
|
|
@@ -23,6 +25,7 @@ type CohubClientOptions = {
|
|
|
23
25
|
clearStoredAuthToken?: () => void;
|
|
24
26
|
fetch?: Fetch;
|
|
25
27
|
websocket?: WebsocketClientOptions;
|
|
28
|
+
voice?: VoiceInputCreateOptions;
|
|
26
29
|
};
|
|
27
30
|
declare class HttpError extends Error {
|
|
28
31
|
readonly status: number;
|
|
@@ -410,6 +413,90 @@ type BillingCatalog = {
|
|
|
410
413
|
hasActiveSubscription: boolean;
|
|
411
414
|
defaultPlanProductKey: string | null;
|
|
412
415
|
};
|
|
416
|
+
type BillingHistoryPagination = {
|
|
417
|
+
maxPage: number;
|
|
418
|
+
totalCount: number;
|
|
419
|
+
};
|
|
420
|
+
type BillingCheckoutActionState = {
|
|
421
|
+
canPay: boolean;
|
|
422
|
+
checkoutUrl: string | null;
|
|
423
|
+
checkoutUsable: boolean;
|
|
424
|
+
canCancelCheckout: boolean;
|
|
425
|
+
canCancelAutoRenew: boolean;
|
|
426
|
+
unavailableReason: string | null;
|
|
427
|
+
};
|
|
428
|
+
type BillingOrderStatus = {
|
|
429
|
+
id: string;
|
|
430
|
+
externalUserId: string;
|
|
431
|
+
productKey: string;
|
|
432
|
+
productName: string;
|
|
433
|
+
subscriptionId: string | null;
|
|
434
|
+
status: string;
|
|
435
|
+
billingReason: string;
|
|
436
|
+
amountMinor: number;
|
|
437
|
+
amountUsd: number;
|
|
438
|
+
paidAmountMinor: number;
|
|
439
|
+
paidAmountUsd: number;
|
|
440
|
+
currency: string;
|
|
441
|
+
refundedAmountMinor: number;
|
|
442
|
+
refundedAmountUsd: number;
|
|
443
|
+
fulfillmentSource: string;
|
|
444
|
+
checkoutExpiresAt: string | null;
|
|
445
|
+
paidAt: string | null;
|
|
446
|
+
checkoutCanceledAt: string | null;
|
|
447
|
+
checkoutExpiredAt: string | null;
|
|
448
|
+
paymentConflictedAt: string | null;
|
|
449
|
+
createdAt: string;
|
|
450
|
+
updatedAt: string;
|
|
451
|
+
providerStatus: string | null;
|
|
452
|
+
checkoutStatus: string | null;
|
|
453
|
+
actions: BillingCheckoutActionState;
|
|
454
|
+
};
|
|
455
|
+
type BillingOrderList = {
|
|
456
|
+
userId: string;
|
|
457
|
+
billing: BillingPluginStatus;
|
|
458
|
+
page: number;
|
|
459
|
+
limit: number;
|
|
460
|
+
items: BillingOrderStatus[];
|
|
461
|
+
pagination: BillingHistoryPagination;
|
|
462
|
+
};
|
|
463
|
+
type BillingSubscriptionHistoryStatus = {
|
|
464
|
+
id: string;
|
|
465
|
+
externalUserId: string;
|
|
466
|
+
productKey: string;
|
|
467
|
+
productName: string;
|
|
468
|
+
status: string;
|
|
469
|
+
amountMinor: number;
|
|
470
|
+
amountUsd: number;
|
|
471
|
+
paidAmountMinor: number;
|
|
472
|
+
paidAmountUsd: number;
|
|
473
|
+
currency: string;
|
|
474
|
+
billingPeriod: string;
|
|
475
|
+
billingIntervalCount: number;
|
|
476
|
+
currentPeriodStart: string | null;
|
|
477
|
+
currentPeriodEnd: string | null;
|
|
478
|
+
cancelAtPeriodEnd: boolean;
|
|
479
|
+
canceledAt: string | null;
|
|
480
|
+
checkoutExpiresAt: string | null;
|
|
481
|
+
checkoutCanceledAt: string | null;
|
|
482
|
+
checkoutExpiredAt: string | null;
|
|
483
|
+
paymentConflictedAt: string | null;
|
|
484
|
+
endedAt: string | null;
|
|
485
|
+
createdAt: string;
|
|
486
|
+
updatedAt: string;
|
|
487
|
+
providerStatus: string | null;
|
|
488
|
+
providerTerminal: boolean;
|
|
489
|
+
checkoutStatus: string | null;
|
|
490
|
+
actions: BillingCheckoutActionState;
|
|
491
|
+
};
|
|
492
|
+
type BillingSubscriptionHistoryList = {
|
|
493
|
+
userId: string;
|
|
494
|
+
billing: BillingPluginStatus;
|
|
495
|
+
page: number;
|
|
496
|
+
limit: number;
|
|
497
|
+
items: BillingSubscriptionHistoryStatus[];
|
|
498
|
+
pagination: BillingHistoryPagination;
|
|
499
|
+
};
|
|
413
500
|
type BillingCheckoutResult = {
|
|
414
501
|
userId: string;
|
|
415
502
|
billing: BillingPluginStatus;
|
|
@@ -850,6 +937,7 @@ type CreateSpacePromptInput = {
|
|
|
850
937
|
provider?: string | null;
|
|
851
938
|
clientMessageId?: string | null;
|
|
852
939
|
generationPolicy?: GenerationPolicy | null;
|
|
940
|
+
intent?: "followup" | "steer" | null;
|
|
853
941
|
accessMode?: PromptAccessMode | null;
|
|
854
942
|
labelRefs?: string[];
|
|
855
943
|
schedule?: {
|
|
@@ -1563,6 +1651,15 @@ declare class SessionClient {
|
|
|
1563
1651
|
rename(title: string | null, customFetch?: Fetch): Promise<{
|
|
1564
1652
|
session: SessionRecord;
|
|
1565
1653
|
}>;
|
|
1654
|
+
steerTurn(turnId: string, customFetch?: Fetch): Promise<{
|
|
1655
|
+
ok: true;
|
|
1656
|
+
turn: SessionTurnRecord;
|
|
1657
|
+
affectedTurns: SessionTurnRecord[];
|
|
1658
|
+
}>;
|
|
1659
|
+
cancelTurn(turnId: string, customFetch?: Fetch): Promise<{
|
|
1660
|
+
ok: true;
|
|
1661
|
+
turn: SessionTurnRecord;
|
|
1662
|
+
}>;
|
|
1566
1663
|
abort(optionsOrFetch?: {
|
|
1567
1664
|
turnId?: string | null;
|
|
1568
1665
|
} | Fetch, customFetch?: Fetch): Promise<{
|
|
@@ -1860,8 +1957,17 @@ declare class TasksApi {
|
|
|
1860
1957
|
list(filters?: {
|
|
1861
1958
|
cronJobId?: string;
|
|
1862
1959
|
spaceId?: string;
|
|
1960
|
+
sessionId?: string;
|
|
1961
|
+
taskType?: string;
|
|
1962
|
+
status?: "active" | TaskRunRecord["status"];
|
|
1963
|
+
limit?: number;
|
|
1964
|
+
cursor?: string;
|
|
1863
1965
|
}): Promise<{
|
|
1864
1966
|
runs: TaskRunRecord[];
|
|
1967
|
+
pageInfo?: {
|
|
1968
|
+
hasMore: boolean;
|
|
1969
|
+
nextCursor: string | null;
|
|
1970
|
+
};
|
|
1865
1971
|
}>;
|
|
1866
1972
|
}
|
|
1867
1973
|
//#endregion
|
|
@@ -1905,4 +2011,4 @@ declare class CohubHttpClient {
|
|
|
1905
2011
|
}
|
|
1906
2012
|
declare const createHttpClient: (options?: CohubClientOptions) => CohubHttpClient;
|
|
1907
2013
|
//#endregion
|
|
1908
|
-
export {
|
|
2014
|
+
export { BillingHistoryPagination as $, SpaceUsageResponse as $n, SessionMessageResponse as $t, SessionPatchStatus as A, SpaceFsReadFilesInput as An, GlobalSearchResponse as At, GenerationsApi as B, SpaceFsWriteFileInput as Bn, LabelListItem as Bt, SessionGenerationStreamClient as C, SpaceFsEncoding as Cn, ChannelConfig as Cr, CreateSpacePromptInput as Ct, SessionPatchApplyResult as D, SpaceFsMoveInput as Dn, HttpError as Dr, ExploreSection as Dt, SessionPatchApplyInput as E, SpaceFsFileResponse as En, Fetch as Er, CronJobRecord as Et, CreatePublicAssetUploadResponse as F, SpaceFsUploadError as Fn, JsonPrimitive as Ft, BillingCatalog as G, SpaceModListItem as Gn, MeResponse as Gt, ChannelsApi as H, SpaceListItem as Hn, LabelResourceType as Ht, PublicAssetPurpose as I, SpaceFsUploadPlanEntry as In, JsonValue as It, BillingCheckoutResult as J, SpaceRole as Jn, PromptAccessMode as Jt, BillingCatalogProduct as K, SpacePublicProfile as Kn, ModelCatalogEntry as Kt, PublicAssetsApi as L, SpaceFsUploadPlanEntryInput as Ln, LabelAssignmentListItem as Lt, SessionAccessApi as M, SpaceFsTreeResponse as Mn, GlobalSearchType as Mt, SearchApi as N, SpaceFsUploadDestination as Nn, InvitationDetail as Nt, SessionPatchReducer as O, SpaceFsPreparingFile as On, HttpTransport as Or, ExploreSpaceItem as Ot, CreatePublicAssetUploadInput as P, SpaceFsUploadEntry as Pn, JsonObject as Pt, BillingCreditUnit as Q, SpaceUsageHourlyStat as Qn, SessionBindingRecord as Qt, PromptsApi as R, SpaceFsUploadProgress as Rn, LabelAssignmentPageInfo as Rt, GenerationStreamTurnUpdatedEvent as S, SpaceFsCreateUploadResponse as Sn, GenerationContentBlock as Sr, CreateSpaceModInput as St, parseAssistantMessageCommit as T, SpaceFsFileKind as Tn, CohubClientOptions as Tr, CreateSpaceSessionInput as Tt, AcceptInvitationResponse as U, SpaceMember as Un, LabelScopeType as Ut, CronJobsApi as V, SpaceInvitation as Vn, LabelRecord as Vt, ApiError as W, SpaceMeta as Wn, LabelSource as Wt, BillingCreditGrantStatus as X, SpaceSandboxConfig as Xn, PromptTemplateCatalogResponse as Xt, BillingCreditExpiryGroup as Y, SpaceSandboxAutoDestroyPolicy as Yn, PromptTemplateCatalogEntry as Yt, BillingCreditStatus as Z, SpaceSessionsResponse as Zn, ResourceLabelsResponse as Zt, GenerationStreamFinalizedEvent as _, SpaceCreateResponse as _n, filterGenerationDeclarationsByPolicy as _r, Channel as _t, SessionEventName as a, SessionTurnSignedUrlsResponse as an, CreateGenerationTaskRequest as ar, BillingPluginStatus as at, GenerationStreamStateEvent as b, SpaceFsCompleteUploadResponse as bn, normalizeGenerationPolicy as br, CreateInvitationResponse as bt, SpaceClient as c, SessionTurnsPaginatedResponse as cn, ListGenerationModelsResponse as cr, BillingProductDisplay as ct, WebSocketConnectionState as d, SpaceBootstrapSource as dn, GenerationParameterConstraint as dr, BillingRedemptionResult as dt, SessionMessagesPaginatedResponse as en, SpaceUsageSummary as er, BillingOpenOverageList as et, PublicInviteApi as f, SpaceChannelBindingInput as fn, GenerationPolicy as fr, BillingSubscriptionHistoryList as ft, GenerationStreamEvent as g, SpaceConfigResponse as gn, encodeGenerationPolicy as gr, BillingUsageRecordStatus as gt, GenerationStreamErrorEvent as h, SpaceConfigInput as hn, decodeGenerationPolicy as hr, BillingUsageRecordList as ht, TasksApi as i, SessionTurnResponse as in, UserRulesResponse as ir, BillingPaymentStatus as it, createSessionPatchReducer as j, SpaceFsReadFilesResponse as jn, GlobalSearchResult as jt, SessionPatchState as k, SpaceFsReadFilesError as kn, RawHttpResponse as kr, ExploreSpacesResponse as kt, SpaceEventName as l, SpaceAccess as ln, PublicGenerationDeclaration as lr, BillingProductKind as lt, GenerationStreamCommitEvent as m, SpaceConfig as mn, assertGenerationRequestAllowedByPolicy as mr, BillingSubscriptionSummary as mt, createHttpClient as n, SessionRecord as nn, TaskRunRecord as nr, BillingOrderList as nt, SessionSubscriptionHandlers as o, SessionTurnStreamSnapshotResponse as on, CreateGenerationTaskResponse as or, BillingProductBillingInterval as ot, AssistantMessageCommit as p, SpaceCheckpointDetailResponse as pn, GenerationPolicyError as pr, BillingSubscriptionHistoryStatus as pt, BillingCheckoutActionState as q, SpaceRecord as qn, Permission as qt, UserApi as r, SessionTurnIndexResponse as rn, UserProfile as rr, BillingOrderStatus as rt, SpaceChannelBindingRecord as s, SessionTurnWindowResponse as sn, GenerationTaskResult as sr, BillingProductCreditBenefit as st, CohubHttpClient as t, SessionMessagesResponse as tn, TaskRunDetailResponse as tr, BillingOpenOverageStatus as tt, SpacesApi as u, SpaceAccessPolicy as un, GenerationModelPolicy as ur, BillingProductPricing as ut, GenerationStreamIntermediateMessage as v, SpaceEnvInput as vn, findGenerationModelPolicy as vr, CheckpointRecord as vt, createSessionGenerationStreamClient as w, SpaceFsEntry as wn, DiscordChannelConfig as wr, CreateSpacePromptResponse as wt, GenerationStreamSubscriptionHandlers as x, SpaceFsCreateUploadInput as xn, parseGenerationPolicyFromEnv as xr, CreateSpaceInput as xt, GenerationStreamOutOfSyncEvent as y, SpaceFsCompleteUploadInput as yn, getAllowedGenerationModelIds as yr, CreateInvitationInput as yt, ModelsApi as z, SpaceFsUploadResponse as zn, LabelAssignmentRecord as zt };
|
package/dist/chunks/http.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as resolveApiBaseUrl } from "./environment.js";
|
|
2
2
|
//#region src/apis/channels.ts
|
|
3
3
|
var ChannelsApi = class {
|
|
4
4
|
transport;
|
|
@@ -1412,6 +1412,18 @@ var SessionClient = class {
|
|
|
1412
1412
|
fetch: customFetch
|
|
1413
1413
|
});
|
|
1414
1414
|
}
|
|
1415
|
+
steerTurn(turnId, customFetch) {
|
|
1416
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/sessions/${this.id}/turns/${turnId}/steer`, {
|
|
1417
|
+
method: "POST",
|
|
1418
|
+
fetch: customFetch
|
|
1419
|
+
});
|
|
1420
|
+
}
|
|
1421
|
+
cancelTurn(turnId, customFetch) {
|
|
1422
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/sessions/${this.id}/turns/${turnId}/cancel`, {
|
|
1423
|
+
method: "POST",
|
|
1424
|
+
fetch: customFetch
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1415
1427
|
abort(optionsOrFetch, customFetch) {
|
|
1416
1428
|
const options = typeof optionsOrFetch === "function" ? void 0 : optionsOrFetch;
|
|
1417
1429
|
const fetch = typeof optionsOrFetch === "function" ? optionsOrFetch : customFetch;
|
|
@@ -1868,6 +1880,11 @@ var TasksApi = class {
|
|
|
1868
1880
|
const params = new URLSearchParams();
|
|
1869
1881
|
if (filters?.cronJobId) params.set("cronJobId", filters.cronJobId);
|
|
1870
1882
|
if (filters?.spaceId) params.set("spaceId", filters.spaceId);
|
|
1883
|
+
if (filters?.sessionId) params.set("sessionId", filters.sessionId);
|
|
1884
|
+
if (filters?.taskType) params.set("taskType", filters.taskType);
|
|
1885
|
+
if (filters?.status) params.set("status", filters.status);
|
|
1886
|
+
if (filters?.limit) params.set("limit", String(filters.limit));
|
|
1887
|
+
if (filters?.cursor) params.set("cursor", filters.cursor);
|
|
1871
1888
|
const query = params.toString();
|
|
1872
1889
|
return this.transport.request(`/api/tasks${query ? `?${query}` : ""}`);
|
|
1873
1890
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { n as CohubEnvironment } from "./environment.js";
|
|
2
|
+
|
|
3
|
+
//#region src/voice-input.d.ts
|
|
4
|
+
type VoiceInputEvent = {
|
|
5
|
+
type: string;
|
|
6
|
+
payload?: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
type VoiceInputCallbacks = {
|
|
9
|
+
onPartial?: (text: string) => void;
|
|
10
|
+
onFinal?: (text: string) => void;
|
|
11
|
+
onError?: (message: string) => void;
|
|
12
|
+
onDone?: () => void;
|
|
13
|
+
};
|
|
14
|
+
type VoiceInputClientOptions = {
|
|
15
|
+
env?: CohubEnvironment;
|
|
16
|
+
url?: string;
|
|
17
|
+
getAccessToken?: (options?: {
|
|
18
|
+
forceRefresh?: boolean;
|
|
19
|
+
}) => Promise<string | null> | string | null;
|
|
20
|
+
WebSocketImpl?: WebSocketConstructor;
|
|
21
|
+
connectionTimeoutMs?: number;
|
|
22
|
+
idleConnectionTimeoutMs?: number;
|
|
23
|
+
callbacks?: VoiceInputCallbacks;
|
|
24
|
+
};
|
|
25
|
+
type VoiceInputCreateOptions = Omit<VoiceInputClientOptions, "callbacks">;
|
|
26
|
+
type WebSocketLike = {
|
|
27
|
+
readonly readyState: number;
|
|
28
|
+
onopen: ((event: Event) => void) | null;
|
|
29
|
+
onmessage: ((event: MessageEvent) => void) | null;
|
|
30
|
+
onerror: ((event: Event) => void) | null;
|
|
31
|
+
onclose: ((event: CloseEvent) => void) | null;
|
|
32
|
+
send(data: string): void;
|
|
33
|
+
close(code?: number, reason?: string): void;
|
|
34
|
+
};
|
|
35
|
+
type WebSocketConstructor = new (url: string) => WebSocketLike;
|
|
36
|
+
declare class VoiceInputClient {
|
|
37
|
+
private readonly url;
|
|
38
|
+
private readonly getAccessToken?;
|
|
39
|
+
private readonly WebSocketImpl;
|
|
40
|
+
private readonly connectionTimeoutMs;
|
|
41
|
+
private readonly idleConnectionTimeoutMs;
|
|
42
|
+
private readonly callbacks;
|
|
43
|
+
private socket;
|
|
44
|
+
private stream;
|
|
45
|
+
private audioContext;
|
|
46
|
+
private processor;
|
|
47
|
+
private source;
|
|
48
|
+
private pendingSamples;
|
|
49
|
+
private pendingAudio;
|
|
50
|
+
private started;
|
|
51
|
+
private asrStarted;
|
|
52
|
+
private authenticated;
|
|
53
|
+
private intentionalClose;
|
|
54
|
+
private startPromise;
|
|
55
|
+
private socketOpenPromise;
|
|
56
|
+
private idleCloseTimer;
|
|
57
|
+
private authWaiter;
|
|
58
|
+
private asrStartWaiter;
|
|
59
|
+
constructor(options?: VoiceInputClientOptions);
|
|
60
|
+
start(): Promise<void>;
|
|
61
|
+
stop(): void;
|
|
62
|
+
cancel(): void;
|
|
63
|
+
close(): void;
|
|
64
|
+
private startInternal;
|
|
65
|
+
private withConnectionTimeout;
|
|
66
|
+
private ensureAuthenticatedSocket;
|
|
67
|
+
private ensureSocketOpen;
|
|
68
|
+
private authenticate;
|
|
69
|
+
private startAsrSession;
|
|
70
|
+
private createAuthWaiter;
|
|
71
|
+
private resolveAuthWaiter;
|
|
72
|
+
private rejectAuthWaiter;
|
|
73
|
+
private createAsrStartWaiter;
|
|
74
|
+
private resolveAsrStartWaiter;
|
|
75
|
+
private rejectAsrStartWaiter;
|
|
76
|
+
private closeWithError;
|
|
77
|
+
private setupAudio;
|
|
78
|
+
private sendAudio;
|
|
79
|
+
private flushPendingAudio;
|
|
80
|
+
private send;
|
|
81
|
+
private handleMessage;
|
|
82
|
+
private cleanupAudio;
|
|
83
|
+
private scheduleIdleClose;
|
|
84
|
+
private clearIdleCloseTimer;
|
|
85
|
+
private closeSocket;
|
|
86
|
+
}
|
|
87
|
+
declare class VoiceApi {
|
|
88
|
+
private readonly defaults;
|
|
89
|
+
constructor(defaults?: VoiceInputCreateOptions);
|
|
90
|
+
createInputClient(callbacks?: VoiceInputCallbacks, options?: VoiceInputCreateOptions): VoiceInputClient;
|
|
91
|
+
}
|
|
92
|
+
declare const createVoiceInputClient: (options?: VoiceInputClientOptions) => VoiceInputClient;
|
|
93
|
+
//#endregion
|
|
94
|
+
export { VoiceInputCreateOptions as a, WebSocketLike as c, VoiceInputClientOptions as i, createVoiceInputClient as l, VoiceInputCallbacks as n, VoiceInputEvent as o, VoiceInputClient as r, WebSocketConstructor as s, VoiceApi as t };
|