@neta-art/cohub 2.0.0 → 2.2.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/http.d.ts +234 -2
- package/dist/chunks/http.js +117 -1
- package/dist/debugger.d.ts +4 -1
- package/dist/debugger.js +70 -2
- package/dist/http.d.ts +2 -2
- package/dist/http.js +1 -1
- package/dist/index.d.ts +56 -2
- package/dist/index.js +48 -2
- package/package.json +1 -1
package/dist/chunks/http.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ type CohubClientOptions = {
|
|
|
30
30
|
declare class HttpError extends Error {
|
|
31
31
|
readonly status: number;
|
|
32
32
|
readonly body: unknown;
|
|
33
|
+
readonly code: string | null;
|
|
33
34
|
constructor(message: string, status: number, body: unknown);
|
|
34
35
|
}
|
|
35
36
|
declare class HttpTransport {
|
|
@@ -399,6 +400,82 @@ type BillingCatalogProduct = {
|
|
|
399
400
|
display: BillingProductDisplay;
|
|
400
401
|
isDefaultPlan: boolean;
|
|
401
402
|
};
|
|
403
|
+
type SpaceCommerceFeatureBenefit = {
|
|
404
|
+
key: string;
|
|
405
|
+
name: string;
|
|
406
|
+
description: string | null;
|
|
407
|
+
status: string;
|
|
408
|
+
type: "feature";
|
|
409
|
+
config: {
|
|
410
|
+
type: "feature";
|
|
411
|
+
metadata: Record<string, string | number | boolean>;
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
type SpaceCommerceCreditsBenefit = {
|
|
415
|
+
key: string;
|
|
416
|
+
name: string;
|
|
417
|
+
description: string | null;
|
|
418
|
+
status: string;
|
|
419
|
+
type: "credits";
|
|
420
|
+
config: {
|
|
421
|
+
type: "credits";
|
|
422
|
+
amount: number;
|
|
423
|
+
expiresInDays: number | null;
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
type SpaceCommerceBenefit = SpaceCommerceFeatureBenefit | SpaceCommerceCreditsBenefit;
|
|
427
|
+
type SpaceCommerceProductCreditBenefit = {
|
|
428
|
+
key: string;
|
|
429
|
+
name: string;
|
|
430
|
+
amount: number;
|
|
431
|
+
expiresInDays: number | null;
|
|
432
|
+
};
|
|
433
|
+
type SpaceCommerceProduct = {
|
|
434
|
+
id: string;
|
|
435
|
+
key: string;
|
|
436
|
+
name: string;
|
|
437
|
+
description: string | null;
|
|
438
|
+
status: string;
|
|
439
|
+
visibility: string;
|
|
440
|
+
billingType: string;
|
|
441
|
+
billingPeriod: string;
|
|
442
|
+
billingIntervalCount: number;
|
|
443
|
+
currency: string;
|
|
444
|
+
kind: "addon";
|
|
445
|
+
interval: "one_time";
|
|
446
|
+
pricing: {
|
|
447
|
+
amountMinor: number;
|
|
448
|
+
amountUsd: number;
|
|
449
|
+
compareAtAmountMinor: number | null;
|
|
450
|
+
compareAtAmountUsd: number | null;
|
|
451
|
+
discountLabel: string | null;
|
|
452
|
+
discountRate: number | null;
|
|
453
|
+
};
|
|
454
|
+
display: {
|
|
455
|
+
description: string | null;
|
|
456
|
+
benefits: string[];
|
|
457
|
+
creditsAmount: number | null;
|
|
458
|
+
validity: string | null;
|
|
459
|
+
creditBenefits: SpaceCommerceProductCreditBenefit[];
|
|
460
|
+
};
|
|
461
|
+
isDefaultPlan: boolean;
|
|
462
|
+
};
|
|
463
|
+
type SpaceCommerceProductBenefitBinding = {
|
|
464
|
+
id: string | null;
|
|
465
|
+
productKey: string;
|
|
466
|
+
benefitKey: string;
|
|
467
|
+
createdAt: string | null;
|
|
468
|
+
};
|
|
469
|
+
type SpaceCommerceOrder = {
|
|
470
|
+
id: string;
|
|
471
|
+
productKeySnapshot: string;
|
|
472
|
+
productNameSnapshot: string;
|
|
473
|
+
status: string;
|
|
474
|
+
amountSnapshot: number;
|
|
475
|
+
paidAmountSnapshot: number;
|
|
476
|
+
createdAt: string;
|
|
477
|
+
paidAt: string | null;
|
|
478
|
+
};
|
|
402
479
|
type BillingSubscriptionSummary = {
|
|
403
480
|
id: string;
|
|
404
481
|
productKey: string | null;
|
|
@@ -494,7 +571,7 @@ type BillingRedemptionResult = {
|
|
|
494
571
|
};
|
|
495
572
|
type BillingConversionIntent = {
|
|
496
573
|
level: "soft" | "hard";
|
|
497
|
-
reason: "negative_balance" | "negative_balance_limit_exceeded";
|
|
574
|
+
reason: "negative_balance" | "negative_balance_limit_exceeded" | "feature_not_entitled";
|
|
498
575
|
audience: "free" | "paid" | "unknown";
|
|
499
576
|
preferredOfferKind: "plan" | "upgrade" | "addon" | "mixed";
|
|
500
577
|
title: string;
|
|
@@ -2074,6 +2151,92 @@ declare class SpaceLabelsApi {
|
|
|
2074
2151
|
assignments: LabelAssignmentRecord[];
|
|
2075
2152
|
}>;
|
|
2076
2153
|
}
|
|
2154
|
+
declare class SpaceCommerceApi {
|
|
2155
|
+
private readonly transport;
|
|
2156
|
+
private readonly spaceId;
|
|
2157
|
+
constructor(transport: HttpTransport, spaceId: string);
|
|
2158
|
+
setup(): Promise<{
|
|
2159
|
+
businessKey: string;
|
|
2160
|
+
}>;
|
|
2161
|
+
listProducts(): Promise<{
|
|
2162
|
+
products: SpaceCommerceProduct[];
|
|
2163
|
+
businessKey: string;
|
|
2164
|
+
}>;
|
|
2165
|
+
createProduct(input: {
|
|
2166
|
+
key?: string;
|
|
2167
|
+
name: string;
|
|
2168
|
+
description?: string;
|
|
2169
|
+
amountUsd: number;
|
|
2170
|
+
status?: "draft" | "active";
|
|
2171
|
+
visibility?: "public" | "private";
|
|
2172
|
+
}): Promise<{
|
|
2173
|
+
product: SpaceCommerceProduct;
|
|
2174
|
+
businessKey: string;
|
|
2175
|
+
}>;
|
|
2176
|
+
updateProduct(productKey: string, input: {
|
|
2177
|
+
name?: string;
|
|
2178
|
+
description?: string | null;
|
|
2179
|
+
status?: "draft" | "active" | "archived";
|
|
2180
|
+
visibility?: "public" | "private";
|
|
2181
|
+
}): Promise<{
|
|
2182
|
+
product: SpaceCommerceProduct;
|
|
2183
|
+
businessKey: string;
|
|
2184
|
+
}>;
|
|
2185
|
+
listBenefits(): Promise<{
|
|
2186
|
+
benefits: SpaceCommerceBenefit[];
|
|
2187
|
+
businessKey: string;
|
|
2188
|
+
}>;
|
|
2189
|
+
createBenefit(input: {
|
|
2190
|
+
key?: string;
|
|
2191
|
+
name: string;
|
|
2192
|
+
description?: string;
|
|
2193
|
+
type?: "feature" | "credits";
|
|
2194
|
+
metadata?: Record<string, string | number | boolean>;
|
|
2195
|
+
amount?: number;
|
|
2196
|
+
expiresInDays?: number;
|
|
2197
|
+
}): Promise<{
|
|
2198
|
+
benefit: SpaceCommerceBenefit;
|
|
2199
|
+
businessKey: string;
|
|
2200
|
+
}>;
|
|
2201
|
+
updateBenefit(benefitKey: string, input: {
|
|
2202
|
+
name?: string;
|
|
2203
|
+
description?: string | null;
|
|
2204
|
+
status?: "active" | "archived";
|
|
2205
|
+
metadata?: Record<string, string | number | boolean>;
|
|
2206
|
+
}): Promise<{
|
|
2207
|
+
benefit: SpaceCommerceBenefit;
|
|
2208
|
+
businessKey: string;
|
|
2209
|
+
}>;
|
|
2210
|
+
listProductBenefits(): Promise<{
|
|
2211
|
+
productBenefits: SpaceCommerceProductBenefitBinding[];
|
|
2212
|
+
businessKey: string;
|
|
2213
|
+
}>;
|
|
2214
|
+
bindProductBenefit(input: {
|
|
2215
|
+
productKey: string;
|
|
2216
|
+
benefitKey: string;
|
|
2217
|
+
}): Promise<{
|
|
2218
|
+
productBenefit: SpaceCommerceProductBenefitBinding;
|
|
2219
|
+
businessKey: string;
|
|
2220
|
+
}>;
|
|
2221
|
+
unbindProductBenefit(input: {
|
|
2222
|
+
productKey: string;
|
|
2223
|
+
benefitKey: string;
|
|
2224
|
+
}): Promise<{
|
|
2225
|
+
ok: true;
|
|
2226
|
+
businessKey: string;
|
|
2227
|
+
}>;
|
|
2228
|
+
listOrders(input?: {
|
|
2229
|
+
page?: number;
|
|
2230
|
+
limit?: number;
|
|
2231
|
+
}): Promise<{
|
|
2232
|
+
orders: SpaceCommerceOrder[];
|
|
2233
|
+
pagination: {
|
|
2234
|
+
hasMore: boolean;
|
|
2235
|
+
nextPage: number | null;
|
|
2236
|
+
};
|
|
2237
|
+
businessKey: string;
|
|
2238
|
+
}>;
|
|
2239
|
+
}
|
|
2077
2240
|
declare class SpaceCanvasApi {
|
|
2078
2241
|
private readonly transport;
|
|
2079
2242
|
private readonly spaceId;
|
|
@@ -2142,6 +2305,7 @@ declare class SpaceClient {
|
|
|
2142
2305
|
readonly invitations: SpaceInvitationsApi;
|
|
2143
2306
|
readonly labels: SpaceLabelsApi;
|
|
2144
2307
|
readonly canvas: SpaceCanvasApi;
|
|
2308
|
+
readonly commerce: SpaceCommerceApi;
|
|
2145
2309
|
constructor(id: string, transport: HttpTransport, websocketClient: WebsocketClient | null);
|
|
2146
2310
|
get(customFetch?: Fetch): Promise<SpaceRecord>;
|
|
2147
2311
|
prompt(input: CreateSpacePromptInput): Promise<CreateSpacePromptResponse>;
|
|
@@ -2361,6 +2525,73 @@ declare class WorksApi {
|
|
|
2361
2525
|
}): Promise<WorkAuthorizeResponse>;
|
|
2362
2526
|
}
|
|
2363
2527
|
//#endregion
|
|
2528
|
+
//#region src/apis/work-commerce.d.ts
|
|
2529
|
+
type WorkCommerceEntitlement = {
|
|
2530
|
+
benefitKey: string;
|
|
2531
|
+
enabled: boolean;
|
|
2532
|
+
metadata: Record<string, string | number | boolean>;
|
|
2533
|
+
};
|
|
2534
|
+
type WorkCommerceEntitlementsResponse = {
|
|
2535
|
+
entitlements: WorkCommerceEntitlement[];
|
|
2536
|
+
credits: {
|
|
2537
|
+
available: number;
|
|
2538
|
+
net: number;
|
|
2539
|
+
};
|
|
2540
|
+
businessKey: string;
|
|
2541
|
+
};
|
|
2542
|
+
type WorkCommerceCheckoutStatus = "success" | "failed" | "cancel" | null;
|
|
2543
|
+
type WorkCommerceProductResolveResponse = {
|
|
2544
|
+
products: SpaceCommerceProduct[];
|
|
2545
|
+
};
|
|
2546
|
+
type WorkCommerceCreditConsumeStatus = "consumed" | "insufficient" | "disabled";
|
|
2547
|
+
type WorkCommerceCreditConsumeResponse = {
|
|
2548
|
+
status: WorkCommerceCreditConsumeStatus;
|
|
2549
|
+
amount: number;
|
|
2550
|
+
remaining: number;
|
|
2551
|
+
shortfall: number | null;
|
|
2552
|
+
businessKey: string;
|
|
2553
|
+
};
|
|
2554
|
+
type WorkCommercePurchaseResponse = {
|
|
2555
|
+
checkout: {
|
|
2556
|
+
providerKey: string | null;
|
|
2557
|
+
checkoutUrl: string | null;
|
|
2558
|
+
checkoutUsable: boolean;
|
|
2559
|
+
status: string | null;
|
|
2560
|
+
message: string | null;
|
|
2561
|
+
orderId: string;
|
|
2562
|
+
productKey: string;
|
|
2563
|
+
};
|
|
2564
|
+
};
|
|
2565
|
+
type WorkCommerceOrder = {
|
|
2566
|
+
id: string;
|
|
2567
|
+
productKeySnapshot: string;
|
|
2568
|
+
productNameSnapshot: string;
|
|
2569
|
+
status: string;
|
|
2570
|
+
amountSnapshot: number;
|
|
2571
|
+
paidAmountSnapshot: number;
|
|
2572
|
+
createdAt: string;
|
|
2573
|
+
paidAt: string | null;
|
|
2574
|
+
};
|
|
2575
|
+
declare class WorkCommerceApi {
|
|
2576
|
+
private readonly transport;
|
|
2577
|
+
constructor(transport: HttpTransport);
|
|
2578
|
+
resolveProducts(workId: string, input: {
|
|
2579
|
+
productKeys: string[];
|
|
2580
|
+
}): Promise<WorkCommerceProductResolveResponse>;
|
|
2581
|
+
getEntitlements(workId: string): Promise<WorkCommerceEntitlementsResponse>;
|
|
2582
|
+
consumeCredits(workId: string, input: {
|
|
2583
|
+
amount: number;
|
|
2584
|
+
operationId: string;
|
|
2585
|
+
reason?: string;
|
|
2586
|
+
}): Promise<WorkCommerceCreditConsumeResponse>;
|
|
2587
|
+
purchase(workId: string, input: {
|
|
2588
|
+
productKey: string;
|
|
2589
|
+
}): Promise<WorkCommercePurchaseResponse>;
|
|
2590
|
+
getOrder(workId: string, orderId: string): Promise<{
|
|
2591
|
+
order: WorkCommerceOrder;
|
|
2592
|
+
}>;
|
|
2593
|
+
}
|
|
2594
|
+
//#endregion
|
|
2364
2595
|
//#region src/http.d.ts
|
|
2365
2596
|
declare class CohubHttpClient {
|
|
2366
2597
|
readonly spaces: SpacesApi;
|
|
@@ -2376,10 +2607,11 @@ declare class CohubHttpClient {
|
|
|
2376
2607
|
readonly cronJobs: CronJobsApi;
|
|
2377
2608
|
readonly invite: PublicInviteApi;
|
|
2378
2609
|
readonly works: WorksApi;
|
|
2610
|
+
readonly workCommerce: WorkCommerceApi;
|
|
2379
2611
|
private readonly transport;
|
|
2380
2612
|
constructor(options?: CohubClientOptions);
|
|
2381
2613
|
space(spaceId: string): SpaceClient;
|
|
2382
2614
|
}
|
|
2383
2615
|
declare const createHttpClient: (options?: CohubClientOptions) => CohubHttpClient;
|
|
2384
2616
|
//#endregion
|
|
2385
|
-
export {
|
|
2617
|
+
export { parseAssistantMessageCommit as $, SpaceAccess as $n, SpaceUsageResponse as $r, CanvasNodeRecord as $t, TasksApi as A, LabelResourceType as An, SpaceFsTreeResponse as Ar, BillingCheckoutActionState as At, GenerationStreamCommitEvent as B, ResourceLabelsResponse as Bn, SpaceListItem as Br, BillingProductBillingInterval as Bt, WorkStatus as C, ChannelConfig as Ci, JsonPrimitive as Cn, SpaceFsFileKind as Cr, BillingAccessWarning as Ct, WorkVisibility as D, HttpError as Di, LabelAssignmentRecord as Dn, SpaceFsReadFilesError as Dr, BillingBalanceActivityStatus as Dt, WorkVersionRecord as E, Fetch as Ei, LabelAssignmentPageInfo as En, SpaceFsPreparingFile as Er, BillingBalanceActivityList as Et, SpaceEventName as F, Permission as Fn, SpaceFsUploadPlanEntryInput as Fr, BillingCreditStatus as Ft, GenerationStreamLifecycleEvent as G, SessionMessagesResponse as Gn, SpacePresenceUser as Gr, BillingRedemptionResult as Gt, GenerationStreamEvent as H, SessionBindingRecord as Hn, SpaceMeta as Hr, BillingProductDisplay as Ht, SpacesApi as I, PromptAccessMode as In, SpaceFsUploadProgress as Ir, BillingCreditUnit as It, GenerationStreamSubscribeOptions as J, SessionTurnResponse as Jn, SpaceRole as Jr, BillingSubscriptionSummary as Jt, GenerationStreamOutOfSyncEvent as K, SessionRecord as Kn, SpacePublicProfile as Kr, BillingSubscriptionHistoryList as Kt, WebSocketConnectionState as L, PromptTemplateCatalogEntry as Ln, SpaceFsUploadResponse as Lr, BillingHistoryPagination as Lt, SessionSubscriptionHandlers as M, LabelSource as Mn, SpaceFsUploadEntry as Mr, BillingConversionIntent as Mt, SpaceChannelBindingRecord as N, MeResponse as Nn, SpaceFsUploadError as Nr, BillingCreditExpiryGroup as Nt, WorksApi as O, HttpTransport as Oi, LabelListItem as On, SpaceFsReadFilesInput as Or, BillingCatalog as Ot, SpaceClient as P, ModelCatalogEntry as Pn, SpaceFsUploadPlanEntry as Pr, BillingCreditGrantStatus as Pt, createSessionGenerationStreamClient as Q, SessionTurnsPaginatedResponse as Qn, SpaceUsageHourlyStat as Qr, CanvasNodeInput as Qt, PublicInviteApi as R, PromptTemplateCatalogResponse as Rn, SpaceFsWriteFileInput as Rr, BillingPaymentStatus as Rt, WorkSessionResponse as S, GenerationContentBlock as Si, JsonObject as Sn, SpaceFsEntry as Sr, BatchUserProfilesResponse as St, WorkUpdateInput as T, CohubClientOptions as Ti, LabelAssignmentListItem as Tn, SpaceFsMoveInput as Tr, BillingBalanceActivityKind as Tt, GenerationStreamFinalizedEvent as U, SessionMessageResponse as Un, SpaceModListItem as Ur, BillingProductKind as Ut, GenerationStreamErrorEvent as V, SendMessageCronJobPayload as Vn, SpaceMember as Vr, BillingProductCreditBenefit as Vt, GenerationStreamIntermediateMessage as W, SessionMessagesPaginatedResponse as Wn, SpacePresenceSnapshot as Wr, BillingProductPricing as Wt, GenerationStreamTurnUpdatedEvent as X, SessionTurnStreamSnapshotResponse as Xn, SpaceSandboxConfig as Xr, CanvasCreateInput as Xt, GenerationStreamSubscriptionHandlers as Y, SessionTurnSignedUrlsResponse as Yn, SpaceSandboxAutoDestroyPolicy as Yr, CanvasBootstrapResponse as Yt, SessionGenerationStreamClient as Z, SessionTurnWindowResponse as Zn, SpaceSessionsResponse as Zr, CanvasDocumentRecord as Zt, WorkPresentationMeta as _, filterGenerationDeclarationsByPolicy as _i, ExploreSpacesResponse as _n, SpaceFsCompleteUploadInput as _r, GenerationsApi as _t, WorkCommerceCreditConsumeResponse as a, CreateGenerationTaskRequest as ai, CreateInvitationResponse as an, SpaceCommerceCreditsBenefit as ar, createSessionPatchReducer as at, WorkRecord as b, normalizeGenerationPolicy as bi, GlobalSearchType as bn, SpaceFsCreateUploadResponse as br, AcceptInvitationResponse as bt, WorkCommerceEntitlementsResponse as c, ListGenerationModelsResponse as ci, CreateSpacePromptInput as cn, SpaceCommerceProduct as cr, CreatePublicAssetUploadInput as ct, WorkCommercePurchaseResponse as d, GenerationParameterConstraint as di, CronJobPayload as dn, SpaceConfig as dr, PublicAssetPurpose as dt, SpaceUsageSummary as ei, CanvasSemanticOp as en, SpaceAccessPolicy as er, SessionPatchApplyInput as et, WorkAuthorizeResponse as f, GenerationPolicy as fi, CronJobRecord as fn, SpaceConfigInput as fr, PublicAssetsApi as ft, WorkMeta as g, encodeGenerationPolicy as gi, ExploreSpaceItem as gn, SpaceEnvInput as gr, ModelsApi as gt, WorkGetResponse as h, decodeGenerationPolicy as hi, ExploreSection as hn, SpaceDefaultResponse as hr, PromptsApi as ht, WorkCommerceCheckoutStatus as i, UserRulesResponse as ii, CreateInvitationInput as in, SpaceCommerceBenefit as ir, SessionPatchStatus as it, SessionEventName as j, LabelScopeType as jn, SpaceFsUploadDestination as jr, BillingCheckoutResult as jt, UserApi as k, RawHttpResponse as ki, LabelRecord as kn, SpaceFsReadFilesResponse as kr, BillingCatalogProduct as kt, WorkCommerceOrder as l, PublicGenerationDeclaration as li, CreateSpacePromptResponse as ln, SpaceCommerceProductBenefitBinding as lr, CreatePublicAssetUploadResponse as lt, WorkDetailResponse as m, assertGenerationRequestAllowedByPolicy as mi, CursorPageInfo as mn, SpaceCreateResponse as mr, UploadPublicAssetInput as mt, createHttpClient as n, TaskRunRecord as ni, Channel as nn, SpaceChannelBindingInput as nr, SessionPatchReducer as nt, WorkCommerceCreditConsumeStatus as o, CreateGenerationTaskResponse as oi, CreateSpaceInput as on, SpaceCommerceFeatureBenefit as or, SessionAccessApi as ot, WorkCreateInput as p, GenerationPolicyError as pi, CronJobUpdatePatch as pn, SpaceConfigResponse as pr, UploadChatImageAttachmentInput as pt, GenerationStreamStateEvent as q, SessionTurnIndexResponse as qn, SpaceRecord as qr, BillingSubscriptionHistoryStatus as qt, WorkCommerceApi as r, UserProfile as ri, CheckpointRecord as rn, SpaceCheckpointDetailResponse as rr, SessionPatchState as rt, WorkCommerceEntitlement as s, GenerationTaskResult as si, CreateSpaceModInput as sn, SpaceCommerceOrder as sr, SearchApi as st, CohubHttpClient as t, TaskRunDetailResponse as ti, CanvasTransactionInput as tn, SpaceBootstrapSource as tr, SessionPatchApplyResult as tt, WorkCommerceProductResolveResponse as u, GenerationModelPolicy as ui, CreateSpaceSessionInput as un, SpaceCommerceProductCreditBenefit as ur, PublicAssetMimeType as ut, WorkPublicOwnerRecord as v, findGenerationModelPolicy as vi, GlobalSearchResponse as vn, SpaceFsCompleteUploadResponse as vr, CronJobsApi as vt, WorkTargetType as w, DiscordChannelConfig as wi, JsonValue as wn, SpaceFsFileResponse as wr, BillingBalanceActivity as wt, WorkResolveResponse as x, parseGenerationPolicyFromEnv as xi, InvitationDetail as xn, SpaceFsEncoding as xr, ApiError as xt, WorkPublicSpaceRecord as y, getAllowedGenerationModelIds as yi, GlobalSearchResult as yn, SpaceFsCreateUploadInput as yr, ChannelsApi as yt, AssistantMessageCommit as z, PublicUserProfile as zn, SpaceInvitation as zr, BillingPluginStatus as zt };
|
package/dist/chunks/http.js
CHANGED
|
@@ -278,14 +278,23 @@ const messageFromErrorBody = (body, fallback) => {
|
|
|
278
278
|
}
|
|
279
279
|
return fallback;
|
|
280
280
|
};
|
|
281
|
+
function errorCodeFromBody(body) {
|
|
282
|
+
if (!body || typeof body !== "object") return null;
|
|
283
|
+
const errorBody = body;
|
|
284
|
+
if (typeof errorBody.code === "string" && errorBody.code.trim()) return errorBody.code;
|
|
285
|
+
if (typeof errorBody.error?.code === "string" && errorBody.error.code.trim()) return errorBody.error.code;
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
281
288
|
var HttpError = class extends Error {
|
|
282
289
|
status;
|
|
283
290
|
body;
|
|
291
|
+
code;
|
|
284
292
|
constructor(message, status, body) {
|
|
285
293
|
super(message);
|
|
286
294
|
this.name = "HttpError";
|
|
287
295
|
this.status = status;
|
|
288
296
|
this.body = body;
|
|
297
|
+
this.code = errorCodeFromBody(body);
|
|
289
298
|
}
|
|
290
299
|
};
|
|
291
300
|
var HttpTransport = class {
|
|
@@ -2003,6 +2012,74 @@ var SpaceLabelsApi = class {
|
|
|
2003
2012
|
});
|
|
2004
2013
|
}
|
|
2005
2014
|
};
|
|
2015
|
+
var SpaceCommerceApi = class {
|
|
2016
|
+
transport;
|
|
2017
|
+
spaceId;
|
|
2018
|
+
constructor(transport, spaceId) {
|
|
2019
|
+
this.transport = transport;
|
|
2020
|
+
this.spaceId = spaceId;
|
|
2021
|
+
}
|
|
2022
|
+
setup() {
|
|
2023
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/commerce/setup`, { method: "POST" });
|
|
2024
|
+
}
|
|
2025
|
+
listProducts() {
|
|
2026
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/commerce/products`);
|
|
2027
|
+
}
|
|
2028
|
+
createProduct(input) {
|
|
2029
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/commerce/products`, {
|
|
2030
|
+
method: "POST",
|
|
2031
|
+
headers: { "Content-Type": "application/json" },
|
|
2032
|
+
body: JSON.stringify(input)
|
|
2033
|
+
});
|
|
2034
|
+
}
|
|
2035
|
+
updateProduct(productKey, input) {
|
|
2036
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/commerce/products/${encodeURIComponent(productKey)}`, {
|
|
2037
|
+
method: "PATCH",
|
|
2038
|
+
headers: { "Content-Type": "application/json" },
|
|
2039
|
+
body: JSON.stringify(input)
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
listBenefits() {
|
|
2043
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/commerce/benefits`);
|
|
2044
|
+
}
|
|
2045
|
+
createBenefit(input) {
|
|
2046
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/commerce/benefits`, {
|
|
2047
|
+
method: "POST",
|
|
2048
|
+
headers: { "Content-Type": "application/json" },
|
|
2049
|
+
body: JSON.stringify(input)
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
updateBenefit(benefitKey, input) {
|
|
2053
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/commerce/benefits/${encodeURIComponent(benefitKey)}`, {
|
|
2054
|
+
method: "PATCH",
|
|
2055
|
+
headers: { "Content-Type": "application/json" },
|
|
2056
|
+
body: JSON.stringify(input)
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
listProductBenefits() {
|
|
2060
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/commerce/product-benefits`);
|
|
2061
|
+
}
|
|
2062
|
+
bindProductBenefit(input) {
|
|
2063
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/commerce/product-benefits`, {
|
|
2064
|
+
method: "POST",
|
|
2065
|
+
headers: { "Content-Type": "application/json" },
|
|
2066
|
+
body: JSON.stringify(input)
|
|
2067
|
+
});
|
|
2068
|
+
}
|
|
2069
|
+
unbindProductBenefit(input) {
|
|
2070
|
+
const params = new URLSearchParams({
|
|
2071
|
+
productKey: input.productKey,
|
|
2072
|
+
benefitKey: input.benefitKey
|
|
2073
|
+
});
|
|
2074
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/commerce/product-benefits?${params.toString()}`, { method: "DELETE" });
|
|
2075
|
+
}
|
|
2076
|
+
listOrders(input) {
|
|
2077
|
+
const params = new URLSearchParams();
|
|
2078
|
+
if (input?.page) params.set("page", String(input.page));
|
|
2079
|
+
if (input?.limit) params.set("limit", String(input.limit));
|
|
2080
|
+
return this.transport.request(`/api/spaces/${this.spaceId}/commerce/orders${params.toString() ? `?${params.toString()}` : ""}`);
|
|
2081
|
+
}
|
|
2082
|
+
};
|
|
2006
2083
|
var SpaceCanvasApi = class {
|
|
2007
2084
|
transport;
|
|
2008
2085
|
spaceId;
|
|
@@ -2105,6 +2182,7 @@ var SpaceClient = class {
|
|
|
2105
2182
|
invitations;
|
|
2106
2183
|
labels;
|
|
2107
2184
|
canvas;
|
|
2185
|
+
commerce;
|
|
2108
2186
|
constructor(id, transport, websocketClient) {
|
|
2109
2187
|
this.id = id;
|
|
2110
2188
|
this.transport = transport;
|
|
@@ -2123,6 +2201,7 @@ var SpaceClient = class {
|
|
|
2123
2201
|
this.invitations = new SpaceInvitationsApi(transport, id);
|
|
2124
2202
|
this.labels = new SpaceLabelsApi(transport, id);
|
|
2125
2203
|
this.canvas = new SpaceCanvasApi(transport, id);
|
|
2204
|
+
this.commerce = new SpaceCommerceApi(transport, id);
|
|
2126
2205
|
}
|
|
2127
2206
|
get(customFetch) {
|
|
2128
2207
|
return this.transport.request(`/api/spaces/${this.id}`, { fetch: customFetch });
|
|
@@ -2356,6 +2435,41 @@ var WorksApi = class {
|
|
|
2356
2435
|
}
|
|
2357
2436
|
};
|
|
2358
2437
|
//#endregion
|
|
2438
|
+
//#region src/apis/work-commerce.ts
|
|
2439
|
+
var WorkCommerceApi = class {
|
|
2440
|
+
transport;
|
|
2441
|
+
constructor(transport) {
|
|
2442
|
+
this.transport = transport;
|
|
2443
|
+
}
|
|
2444
|
+
resolveProducts(workId, input) {
|
|
2445
|
+
return this.transport.request(`/api/works/${encodeURIComponent(workId)}/commerce/products/resolve`, {
|
|
2446
|
+
method: "POST",
|
|
2447
|
+
headers: { "Content-Type": "application/json" },
|
|
2448
|
+
body: JSON.stringify(input)
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2451
|
+
getEntitlements(workId) {
|
|
2452
|
+
return this.transport.request(`/api/works/${encodeURIComponent(workId)}/commerce/entitlements`);
|
|
2453
|
+
}
|
|
2454
|
+
consumeCredits(workId, input) {
|
|
2455
|
+
return this.transport.request(`/api/works/${encodeURIComponent(workId)}/commerce/credits/consume`, {
|
|
2456
|
+
method: "POST",
|
|
2457
|
+
headers: { "Content-Type": "application/json" },
|
|
2458
|
+
body: JSON.stringify(input)
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2461
|
+
purchase(workId, input) {
|
|
2462
|
+
return this.transport.request(`/api/works/${encodeURIComponent(workId)}/commerce/purchase`, {
|
|
2463
|
+
method: "POST",
|
|
2464
|
+
headers: { "Content-Type": "application/json" },
|
|
2465
|
+
body: JSON.stringify(input)
|
|
2466
|
+
});
|
|
2467
|
+
}
|
|
2468
|
+
getOrder(workId, orderId) {
|
|
2469
|
+
return this.transport.request(`/api/works/${encodeURIComponent(workId)}/commerce/orders/${encodeURIComponent(orderId)}`);
|
|
2470
|
+
}
|
|
2471
|
+
};
|
|
2472
|
+
//#endregion
|
|
2359
2473
|
//#region src/http.ts
|
|
2360
2474
|
var CohubHttpClient = class {
|
|
2361
2475
|
spaces;
|
|
@@ -2371,6 +2485,7 @@ var CohubHttpClient = class {
|
|
|
2371
2485
|
cronJobs;
|
|
2372
2486
|
invite;
|
|
2373
2487
|
works;
|
|
2488
|
+
workCommerce;
|
|
2374
2489
|
transport;
|
|
2375
2490
|
constructor(options = {}) {
|
|
2376
2491
|
const apiBaseUrl = resolveApiBaseUrl(options);
|
|
@@ -2388,6 +2503,7 @@ var CohubHttpClient = class {
|
|
|
2388
2503
|
this.cronJobs = new CronJobsApi(this.transport);
|
|
2389
2504
|
this.invite = new PublicInviteApi(this.transport);
|
|
2390
2505
|
this.works = new WorksApi(this.transport);
|
|
2506
|
+
this.workCommerce = new WorkCommerceApi(this.transport);
|
|
2391
2507
|
}
|
|
2392
2508
|
space(spaceId) {
|
|
2393
2509
|
return new SpaceClient(spaceId, this.transport, null);
|
|
@@ -2395,4 +2511,4 @@ var CohubHttpClient = class {
|
|
|
2395
2511
|
};
|
|
2396
2512
|
const createHttpClient = (options) => new CohubHttpClient(options);
|
|
2397
2513
|
//#endregion
|
|
2398
|
-
export {
|
|
2514
|
+
export { CronJobsApi as C, GenerationsApi as S, SessionAccessApi as _, UserApi as a, PromptsApi as b, SpacesApi as c, createSessionGenerationStreamClient as d, parseAssistantMessageCommit as f, HttpTransport as g, HttpError as h, WorksApi as i, PublicInviteApi as l, createSessionPatchReducer as m, createHttpClient as n, TasksApi as o, SessionPatchReducer as p, WorkCommerceApi as r, SpaceClient as s, CohubHttpClient as t, SessionGenerationStreamClient as u, SearchApi as v, ChannelsApi as w, ModelsApi as x, PublicAssetsApi as y };
|
package/dist/debugger.d.ts
CHANGED
|
@@ -194,5 +194,8 @@ declare function exportCohubDebugLog(): CohubDebugLogPackage;
|
|
|
194
194
|
declare function exportCohubDebugHar(): CohubDebugHar;
|
|
195
195
|
declare function clearCohubDebugLog(): void;
|
|
196
196
|
declare function stopCohubDebugger(): void;
|
|
197
|
+
declare function redactText(text: string): string;
|
|
198
|
+
declare function redactValue(value: SerializedValue, key?: string): SerializedValue;
|
|
199
|
+
declare function redactUrl(url: string): string;
|
|
197
200
|
//#endregion
|
|
198
|
-
export { CohubConsoleEntry, CohubConsoleLevel, CohubDebugHar, CohubDebugLogPackage, CohubDebuggerHandle, CohubDebuggerOptions, CohubNetworkEntry, CohubNetworkKind, CohubNetworkPhase, HarCohubMessage, HarContent, HarCookie, HarEntry, HarNameValuePair, HarPage, HarPostData, HarRequest, HarResponse, HarTimings, HarWebSocketMessage, SerializedValue, clearCohubDebugLog, exportCohubDebugHar, exportCohubDebugLog, startCohubDebugger, stopCohubDebugger };
|
|
201
|
+
export { CohubConsoleEntry, CohubConsoleLevel, CohubDebugHar, CohubDebugLogPackage, CohubDebuggerHandle, CohubDebuggerOptions, CohubNetworkEntry, CohubNetworkKind, CohubNetworkPhase, HarCohubMessage, HarContent, HarCookie, HarEntry, HarNameValuePair, HarPage, HarPostData, HarRequest, HarResponse, HarTimings, HarWebSocketMessage, SerializedValue, clearCohubDebugLog, exportCohubDebugHar, exportCohubDebugLog, redactText, redactUrl, redactValue, startCohubDebugger, stopCohubDebugger };
|
package/dist/debugger.js
CHANGED
|
@@ -817,7 +817,7 @@ function appendConsole(state, level, args) {
|
|
|
817
817
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
818
818
|
elapsedMs: Date.now() - state.startedAtMs,
|
|
819
819
|
level,
|
|
820
|
-
args: args.map((arg) => serializeValue(arg, state.options)),
|
|
820
|
+
args: args.map((arg) => redactValue(serializeValue(arg, state.options))),
|
|
821
821
|
stack: level === "trace" ? (/* @__PURE__ */ new Error()).stack : void 0
|
|
822
822
|
});
|
|
823
823
|
state.nextConsoleId += 1;
|
|
@@ -825,6 +825,8 @@ function appendConsole(state, level, args) {
|
|
|
825
825
|
function appendNetwork(state, entry) {
|
|
826
826
|
state.networkBuffer.push({
|
|
827
827
|
...entry,
|
|
828
|
+
url: redactUrl(entry.url),
|
|
829
|
+
payload: entry.payload === void 0 ? void 0 : redactValue(entry.payload),
|
|
828
830
|
id: state.nextNetworkId,
|
|
829
831
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
830
832
|
elapsedMs: Date.now() - state.startedAtMs
|
|
@@ -1123,6 +1125,72 @@ function shouldRedactHeader(key, options) {
|
|
|
1123
1125
|
const normalizedKey = key.toLowerCase();
|
|
1124
1126
|
return options.redactHeaders.some((header) => header.toLowerCase() === normalizedKey);
|
|
1125
1127
|
}
|
|
1128
|
+
/**
|
|
1129
|
+
* Content-level secret redaction.
|
|
1130
|
+
*
|
|
1131
|
+
* Header-based redaction (see {@link shouldRedactHeader}) only covers a fixed
|
|
1132
|
+
* list of HTTP header names. Tokens and secrets that travel inside request /
|
|
1133
|
+
* response bodies, WebSocket messages, EventSource lines, URL query strings or
|
|
1134
|
+
* console output would otherwise be persisted verbatim into the debug log and
|
|
1135
|
+
* HAR. The helpers below add a second layer that scrubs common secret shapes
|
|
1136
|
+
* — JWTs, known API-key prefixes (sk-, github_pat_, ghp_…, pat_), Bearer
|
|
1137
|
+
* tokens and sensitive JSON keys — from any text before it enters the ring
|
|
1138
|
+
* buffers, so both `exportCohubDebugLog` and `exportCohubDebugHar` stay safe.
|
|
1139
|
+
*/
|
|
1140
|
+
const SENSITIVE_KEY_NAMES = new Set([
|
|
1141
|
+
"token",
|
|
1142
|
+
"accesstoken",
|
|
1143
|
+
"access_token",
|
|
1144
|
+
"refreshtoken",
|
|
1145
|
+
"refresh_token",
|
|
1146
|
+
"authtoken",
|
|
1147
|
+
"auth_token",
|
|
1148
|
+
"apikey",
|
|
1149
|
+
"api_key",
|
|
1150
|
+
"apitoken",
|
|
1151
|
+
"api_token",
|
|
1152
|
+
"secret",
|
|
1153
|
+
"password",
|
|
1154
|
+
"passwd",
|
|
1155
|
+
"gittoken",
|
|
1156
|
+
"git_token",
|
|
1157
|
+
"authorization",
|
|
1158
|
+
"credential",
|
|
1159
|
+
"privatekey",
|
|
1160
|
+
"private_key"
|
|
1161
|
+
]);
|
|
1162
|
+
const SENSITIVE_KEY_PATTERN = /("(?:token|access[_-]?token|refresh[_-]?token|auth[_-]?token|api[_-]?key|api[_-]?token|secret|password|passwd|git[_-]?token|authorization|credential|private[_-]?key)"\s*:\s*")([^"]*)(")/gi;
|
|
1163
|
+
const JWT_PATTERN = /eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g;
|
|
1164
|
+
const BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._-]+/gi;
|
|
1165
|
+
const SECRET_PREFIX_PATTERN = /\b(?:sk-[A-Za-z0-9]{16,}|github_pat_[A-Za-z0-9_]{16,}|gh[pousr]_[A-Za-z0-9]{16,}|pat_[A-Za-z0-9_]{16,})/g;
|
|
1166
|
+
const REDACTION_HINT = /eyJ|sk-|pat_|gh[pousr]_|github_pat_|bearer|token|secret|password|passwd|apikey|api_key|authorization|credential|privatekey|private_key/i;
|
|
1167
|
+
function isSensitiveKey(key) {
|
|
1168
|
+
return SENSITIVE_KEY_NAMES.has(key.toLowerCase());
|
|
1169
|
+
}
|
|
1170
|
+
function redactText(text) {
|
|
1171
|
+
if (typeof text !== "string" || text.length === 0) return text;
|
|
1172
|
+
if (!REDACTION_HINT.test(text)) return text;
|
|
1173
|
+
let out = text;
|
|
1174
|
+
out = out.replace(SENSITIVE_KEY_PATTERN, "$1[redacted]$3");
|
|
1175
|
+
out = out.replace(BEARER_PATTERN, "Bearer [redacted]");
|
|
1176
|
+
out = out.replace(JWT_PATTERN, "[redacted jwt]");
|
|
1177
|
+
out = out.replace(SECRET_PREFIX_PATTERN, "[redacted token]");
|
|
1178
|
+
return out;
|
|
1179
|
+
}
|
|
1180
|
+
function redactValue(value, key) {
|
|
1181
|
+
if (typeof value === "string") return key !== void 0 && isSensitiveKey(key) ? "[redacted]" : redactText(value);
|
|
1182
|
+
if (Array.isArray(value)) return value.map((item) => redactValue(item));
|
|
1183
|
+
if (value !== null && typeof value === "object") {
|
|
1184
|
+
const out = {};
|
|
1185
|
+
for (const [k, v] of Object.entries(value)) out[k] = redactValue(v, k);
|
|
1186
|
+
return out;
|
|
1187
|
+
}
|
|
1188
|
+
return value;
|
|
1189
|
+
}
|
|
1190
|
+
function redactUrl(url) {
|
|
1191
|
+
if (typeof url !== "string" || url.indexOf("?") === -1) return url;
|
|
1192
|
+
return url.replace(/([?&])([^=&#?]*)=([^&#]*)/g, (match, sep, key) => isSensitiveKey(key) || /token|secret|pass|key|auth|credential/i.test(key) ? `${sep}${key}=[redacted]` : match);
|
|
1193
|
+
}
|
|
1126
1194
|
function truncateText(text, maxBytes) {
|
|
1127
1195
|
if (byteLength(text) <= maxBytes) return text;
|
|
1128
1196
|
let result = "";
|
|
@@ -1143,4 +1211,4 @@ function errorToString(error) {
|
|
|
1143
1211
|
return String(error);
|
|
1144
1212
|
}
|
|
1145
1213
|
//#endregion
|
|
1146
|
-
export { clearCohubDebugLog, exportCohubDebugHar, exportCohubDebugLog, startCohubDebugger, stopCohubDebugger };
|
|
1214
|
+
export { clearCohubDebugLog, exportCohubDebugHar, exportCohubDebugLog, redactText, redactUrl, redactValue, startCohubDebugger, stopCohubDebugger };
|
package/dist/http.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { C as ContentBlock, _ as SessionForkRecord, b as SessionTurnIndexItem, h as MessageRecord, x as SessionTurnRecord, y as SessionTurnSegmentRecord } from "./chunks/websocket.js";
|
|
2
|
-
import { $n as
|
|
3
|
-
export { AcceptInvitationResponse, ApiError, BatchUserProfilesResponse, BillingAccessWarning, BillingBalanceActivity, BillingBalanceActivityKind, BillingBalanceActivityList, BillingBalanceActivityStatus, BillingCatalog, BillingCatalogProduct, BillingCheckoutActionState, BillingCheckoutResult, BillingConversionIntent, BillingCreditExpiryGroup, BillingCreditGrantStatus, BillingCreditStatus, BillingCreditUnit, BillingHistoryPagination, BillingPaymentStatus, BillingPluginStatus, BillingProductBillingInterval, BillingProductCreditBenefit, BillingProductDisplay, BillingProductKind, BillingProductPricing, BillingRedemptionResult, BillingSubscriptionHistoryList, BillingSubscriptionHistoryStatus, BillingSubscriptionSummary, CanvasBootstrapResponse, CanvasCreateInput, CanvasDocumentRecord, CanvasNodeInput, CanvasNodeRecord, CanvasSemanticOp, CanvasTransactionInput, Channel, type ChannelConfig, CheckpointRecord, type CohubClientOptions, CohubHttpClient, type ContentBlock, type CreateGenerationTaskRequest, type CreateGenerationTaskResponse, CreateInvitationInput, CreateInvitationResponse, CreateSpaceInput, CreateSpaceModInput, CreateSpacePromptInput, CreateSpacePromptResponse, CreateSpaceSessionInput, CronJobPayload, CronJobRecord, CronJobUpdatePatch, CursorPageInfo, type DiscordChannelConfig, ExploreSection, ExploreSpaceItem, ExploreSpacesResponse, type Fetch, type GenerationContentBlock, type GenerationPolicy, type GenerationTaskResult, GlobalSearchResponse, GlobalSearchResult, GlobalSearchType, HttpError, HttpTransport, InvitationDetail, JsonObject, JsonPrimitive, JsonValue, LabelAssignmentListItem, LabelAssignmentPageInfo, LabelAssignmentRecord, LabelListItem, LabelRecord, LabelResourceType, LabelScopeType, LabelSource, type ListGenerationModelsResponse, MeResponse, type MessageRecord, ModelCatalogEntry, Permission, PromptAccessMode, PromptTemplateCatalogEntry, PromptTemplateCatalogResponse, type PublicGenerationDeclaration, PublicUserProfile, ResourceLabelsResponse, SendMessageCronJobPayload, SessionBindingRecord, type SessionForkRecord, SessionMessageResponse, SessionMessagesPaginatedResponse, SessionMessagesResponse, SessionRecord, type SessionTurnIndexItem, SessionTurnIndexResponse, type SessionTurnRecord, SessionTurnResponse, type SessionTurnSegmentRecord, SessionTurnSignedUrlsResponse, SessionTurnStreamSnapshotResponse, SessionTurnWindowResponse, SessionTurnsPaginatedResponse, SpaceAccess, SpaceAccessPolicy, SpaceBootstrapSource, SpaceChannelBindingInput, SpaceCheckpointDetailResponse, SpaceConfig, SpaceConfigInput, SpaceConfigResponse, SpaceCreateResponse, SpaceDefaultResponse, SpaceEnvInput, SpaceFsCompleteUploadInput, SpaceFsCompleteUploadResponse, SpaceFsCreateUploadInput, SpaceFsCreateUploadResponse, SpaceFsEncoding, SpaceFsEntry, SpaceFsFileKind, SpaceFsFileResponse, SpaceFsMoveInput, SpaceFsPreparingFile, SpaceFsReadFilesError, SpaceFsReadFilesInput, SpaceFsReadFilesResponse, SpaceFsTreeResponse, SpaceFsUploadDestination, SpaceFsUploadEntry, SpaceFsUploadError, SpaceFsUploadPlanEntry, SpaceFsUploadPlanEntryInput, SpaceFsUploadProgress, SpaceFsUploadResponse, SpaceFsWriteFileInput, SpaceInvitation, SpaceListItem, SpaceMember, SpaceMeta, SpaceModListItem, SpacePresenceSnapshot, SpacePresenceUser, SpacePublicProfile, SpaceRecord, SpaceRole, SpaceSandboxAutoDestroyPolicy, SpaceSandboxConfig, SpaceSessionsResponse, SpaceUsageHourlyStat, SpaceUsageResponse, SpaceUsageSummary, TaskRunDetailResponse, TaskRunRecord, UserProfile, UserRulesResponse, createHttpClient };
|
|
2
|
+
import { $n as SpaceAccess, $r as SpaceUsageResponse, $t as CanvasNodeRecord, An as LabelResourceType, Ar as SpaceFsTreeResponse, At as BillingCheckoutActionState, Bn as ResourceLabelsResponse, Br as SpaceListItem, Bt as BillingProductBillingInterval, Ci as ChannelConfig, Cn as JsonPrimitive, Cr as SpaceFsFileKind, Ct as BillingAccessWarning, Di as HttpError, Dn as LabelAssignmentRecord, Dr as SpaceFsReadFilesError, Dt as BillingBalanceActivityStatus, Ei as Fetch, En as LabelAssignmentPageInfo, Er as SpaceFsPreparingFile, Et as BillingBalanceActivityList, Fn as Permission, Fr as SpaceFsUploadPlanEntryInput, Ft as BillingCreditStatus, Gn as SessionMessagesResponse, Gr as SpacePresenceUser, Gt as BillingRedemptionResult, Hn as SessionBindingRecord, Hr as SpaceMeta, Ht as BillingProductDisplay, In as PromptAccessMode, Ir as SpaceFsUploadProgress, It as BillingCreditUnit, Jn as SessionTurnResponse, Jr as SpaceRole, Jt as BillingSubscriptionSummary, Kn as SessionRecord, Kr as SpacePublicProfile, Kt as BillingSubscriptionHistoryList, Ln as PromptTemplateCatalogEntry, Lr as SpaceFsUploadResponse, Lt as BillingHistoryPagination, Mn as LabelSource, Mr as SpaceFsUploadEntry, Mt as BillingConversionIntent, Nn as MeResponse, Nr as SpaceFsUploadError, Nt as BillingCreditExpiryGroup, Oi as HttpTransport, On as LabelListItem, Or as SpaceFsReadFilesInput, Ot as BillingCatalog, Pn as ModelCatalogEntry, Pr as SpaceFsUploadPlanEntry, Pt as BillingCreditGrantStatus, Qn as SessionTurnsPaginatedResponse, Qr as SpaceUsageHourlyStat, Qt as CanvasNodeInput, Rn as PromptTemplateCatalogResponse, Rr as SpaceFsWriteFileInput, Rt as BillingPaymentStatus, Si as GenerationContentBlock, Sn as JsonObject, Sr as SpaceFsEntry, St as BatchUserProfilesResponse, Ti as CohubClientOptions, Tn as LabelAssignmentListItem, Tr as SpaceFsMoveInput, Tt as BillingBalanceActivityKind, Un as SessionMessageResponse, Ur as SpaceModListItem, Ut as BillingProductKind, Vn as SendMessageCronJobPayload, Vr as SpaceMember, Vt as BillingProductCreditBenefit, Wn as SessionMessagesPaginatedResponse, Wr as SpacePresenceSnapshot, Wt as BillingProductPricing, Xn as SessionTurnStreamSnapshotResponse, Xr as SpaceSandboxConfig, Xt as CanvasCreateInput, Yn as SessionTurnSignedUrlsResponse, Yr as SpaceSandboxAutoDestroyPolicy, Yt as CanvasBootstrapResponse, Zn as SessionTurnWindowResponse, Zr as SpaceSessionsResponse, Zt as CanvasDocumentRecord, _n as ExploreSpacesResponse, _r as SpaceFsCompleteUploadInput, ai as CreateGenerationTaskRequest, an as CreateInvitationResponse, ar as SpaceCommerceCreditsBenefit, bn as GlobalSearchType, br as SpaceFsCreateUploadResponse, bt as AcceptInvitationResponse, ci as ListGenerationModelsResponse, cn as CreateSpacePromptInput, cr as SpaceCommerceProduct, dn as CronJobPayload, dr as SpaceConfig, ei as SpaceUsageSummary, en as CanvasSemanticOp, er as SpaceAccessPolicy, fi as GenerationPolicy, fn as CronJobRecord, fr as SpaceConfigInput, gn as ExploreSpaceItem, gr as SpaceEnvInput, hn as ExploreSection, hr as SpaceDefaultResponse, ii as UserRulesResponse, in as CreateInvitationInput, ir as SpaceCommerceBenefit, jn as LabelScopeType, jr as SpaceFsUploadDestination, jt as BillingCheckoutResult, kn as LabelRecord, kr as SpaceFsReadFilesResponse, kt as BillingCatalogProduct, li as PublicGenerationDeclaration, ln as CreateSpacePromptResponse, lr as SpaceCommerceProductBenefitBinding, mn as CursorPageInfo, mr as SpaceCreateResponse, n as createHttpClient, ni as TaskRunRecord, nn as Channel, nr as SpaceChannelBindingInput, oi as CreateGenerationTaskResponse, on as CreateSpaceInput, or as SpaceCommerceFeatureBenefit, pn as CronJobUpdatePatch, pr as SpaceConfigResponse, qn as SessionTurnIndexResponse, qr as SpaceRecord, qt as BillingSubscriptionHistoryStatus, ri as UserProfile, rn as CheckpointRecord, rr as SpaceCheckpointDetailResponse, si as GenerationTaskResult, sn as CreateSpaceModInput, sr as SpaceCommerceOrder, t as CohubHttpClient, ti as TaskRunDetailResponse, tn as CanvasTransactionInput, tr as SpaceBootstrapSource, un as CreateSpaceSessionInput, ur as SpaceCommerceProductCreditBenefit, vn as GlobalSearchResponse, vr as SpaceFsCompleteUploadResponse, wi as DiscordChannelConfig, wn as JsonValue, wr as SpaceFsFileResponse, wt as BillingBalanceActivity, xn as InvitationDetail, xr as SpaceFsEncoding, xt as ApiError, yn as GlobalSearchResult, yr as SpaceFsCreateUploadInput, zn as PublicUserProfile, zr as SpaceInvitation, zt as BillingPluginStatus } from "./chunks/http.js";
|
|
3
|
+
export { AcceptInvitationResponse, ApiError, BatchUserProfilesResponse, BillingAccessWarning, BillingBalanceActivity, BillingBalanceActivityKind, BillingBalanceActivityList, BillingBalanceActivityStatus, BillingCatalog, BillingCatalogProduct, BillingCheckoutActionState, BillingCheckoutResult, BillingConversionIntent, BillingCreditExpiryGroup, BillingCreditGrantStatus, BillingCreditStatus, BillingCreditUnit, BillingHistoryPagination, BillingPaymentStatus, BillingPluginStatus, BillingProductBillingInterval, BillingProductCreditBenefit, BillingProductDisplay, BillingProductKind, BillingProductPricing, BillingRedemptionResult, BillingSubscriptionHistoryList, BillingSubscriptionHistoryStatus, BillingSubscriptionSummary, CanvasBootstrapResponse, CanvasCreateInput, CanvasDocumentRecord, CanvasNodeInput, CanvasNodeRecord, CanvasSemanticOp, CanvasTransactionInput, Channel, type ChannelConfig, CheckpointRecord, type CohubClientOptions, CohubHttpClient, type ContentBlock, type CreateGenerationTaskRequest, type CreateGenerationTaskResponse, CreateInvitationInput, CreateInvitationResponse, CreateSpaceInput, CreateSpaceModInput, CreateSpacePromptInput, CreateSpacePromptResponse, CreateSpaceSessionInput, CronJobPayload, CronJobRecord, CronJobUpdatePatch, CursorPageInfo, type DiscordChannelConfig, ExploreSection, ExploreSpaceItem, ExploreSpacesResponse, type Fetch, type GenerationContentBlock, type GenerationPolicy, type GenerationTaskResult, GlobalSearchResponse, GlobalSearchResult, GlobalSearchType, HttpError, HttpTransport, InvitationDetail, JsonObject, JsonPrimitive, JsonValue, LabelAssignmentListItem, LabelAssignmentPageInfo, LabelAssignmentRecord, LabelListItem, LabelRecord, LabelResourceType, LabelScopeType, LabelSource, type ListGenerationModelsResponse, MeResponse, type MessageRecord, ModelCatalogEntry, Permission, PromptAccessMode, PromptTemplateCatalogEntry, PromptTemplateCatalogResponse, type PublicGenerationDeclaration, PublicUserProfile, ResourceLabelsResponse, SendMessageCronJobPayload, SessionBindingRecord, type SessionForkRecord, SessionMessageResponse, SessionMessagesPaginatedResponse, SessionMessagesResponse, SessionRecord, type SessionTurnIndexItem, SessionTurnIndexResponse, type SessionTurnRecord, SessionTurnResponse, type SessionTurnSegmentRecord, SessionTurnSignedUrlsResponse, SessionTurnStreamSnapshotResponse, SessionTurnWindowResponse, SessionTurnsPaginatedResponse, SpaceAccess, SpaceAccessPolicy, SpaceBootstrapSource, SpaceChannelBindingInput, SpaceCheckpointDetailResponse, SpaceCommerceBenefit, SpaceCommerceCreditsBenefit, SpaceCommerceFeatureBenefit, SpaceCommerceOrder, SpaceCommerceProduct, SpaceCommerceProductBenefitBinding, SpaceCommerceProductCreditBenefit, SpaceConfig, SpaceConfigInput, SpaceConfigResponse, SpaceCreateResponse, SpaceDefaultResponse, SpaceEnvInput, SpaceFsCompleteUploadInput, SpaceFsCompleteUploadResponse, SpaceFsCreateUploadInput, SpaceFsCreateUploadResponse, SpaceFsEncoding, SpaceFsEntry, SpaceFsFileKind, SpaceFsFileResponse, SpaceFsMoveInput, SpaceFsPreparingFile, SpaceFsReadFilesError, SpaceFsReadFilesInput, SpaceFsReadFilesResponse, SpaceFsTreeResponse, SpaceFsUploadDestination, SpaceFsUploadEntry, SpaceFsUploadError, SpaceFsUploadPlanEntry, SpaceFsUploadPlanEntryInput, SpaceFsUploadProgress, SpaceFsUploadResponse, SpaceFsWriteFileInput, SpaceInvitation, SpaceListItem, SpaceMember, SpaceMeta, SpaceModListItem, SpacePresenceSnapshot, SpacePresenceUser, SpacePublicProfile, SpaceRecord, SpaceRole, SpaceSandboxAutoDestroyPolicy, SpaceSandboxConfig, SpaceSessionsResponse, SpaceUsageHourlyStat, SpaceUsageResponse, SpaceUsageSummary, TaskRunDetailResponse, TaskRunRecord, UserProfile, UserRulesResponse, createHttpClient };
|
package/dist/http.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as HttpTransport, h as HttpError, n as createHttpClient, t as CohubHttpClient } from "./chunks/http.js";
|
|
2
2
|
export { CohubHttpClient, HttpError, HttpTransport, createHttpClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as normalizeWebsocketUrl, c as resolveVoiceInputWebsocketUrl, i as normalizeVoiceInputWebsocketUrl, l as resolveWebsocketUrl, n as CohubEnvironment, o as resolveApiBaseUrl, r as normalizeBaseUrl, s as resolveCohubEnvironment, t as COHUB_ENVIRONMENTS } from "./chunks/environment.js";
|
|
2
2
|
import { C as ContentBlock, _ as SessionForkRecord, b as SessionTurnIndexItem, c as createWebsocketClient, f as RealtimeServerEvent, h as MessageRecord, l as ChannelEnvelope, r as WebsocketClient, u as LabelAssignmentsUpdatedEvent, x as SessionTurnRecord, y as SessionTurnSegmentRecord } from "./chunks/websocket.js";
|
|
3
3
|
import { a as VoiceInputCreateOptions, i as VoiceInputClientOptions, l as createVoiceInputClient, n as VoiceInputCallbacks, o as VoiceInputEvent, r as VoiceInputClient, t as VoiceApi } from "./chunks/voice-input.js";
|
|
4
|
-
import { $ as
|
|
4
|
+
import { $ as parseAssistantMessageCommit, $n as SpaceAccess, $r as SpaceUsageResponse, $t as CanvasNodeRecord, A as TasksApi, An as LabelResourceType, Ar as SpaceFsTreeResponse, At as BillingCheckoutActionState, B as GenerationStreamCommitEvent, Bn as ResourceLabelsResponse, Br as SpaceListItem, Bt as BillingProductBillingInterval, C as WorkStatus, Ci as ChannelConfig, Cn as JsonPrimitive, Cr as SpaceFsFileKind, Ct as BillingAccessWarning, D as WorkVisibility, Di as HttpError, Dn as LabelAssignmentRecord, Dr as SpaceFsReadFilesError, Dt as BillingBalanceActivityStatus, E as WorkVersionRecord, Ei as Fetch, En as LabelAssignmentPageInfo, Er as SpaceFsPreparingFile, Et as BillingBalanceActivityList, F as SpaceEventName, Fn as Permission, Fr as SpaceFsUploadPlanEntryInput, Ft as BillingCreditStatus, G as GenerationStreamLifecycleEvent, Gn as SessionMessagesResponse, Gr as SpacePresenceUser, Gt as BillingRedemptionResult, H as GenerationStreamEvent, Hn as SessionBindingRecord, Hr as SpaceMeta, Ht as BillingProductDisplay, I as SpacesApi, In as PromptAccessMode, Ir as SpaceFsUploadProgress, It as BillingCreditUnit, J as GenerationStreamSubscribeOptions, Jn as SessionTurnResponse, Jr as SpaceRole, Jt as BillingSubscriptionSummary, K as GenerationStreamOutOfSyncEvent, Kn as SessionRecord, Kr as SpacePublicProfile, Kt as BillingSubscriptionHistoryList, L as WebSocketConnectionState, Ln as PromptTemplateCatalogEntry, Lr as SpaceFsUploadResponse, Lt as BillingHistoryPagination, M as SessionSubscriptionHandlers, Mn as LabelSource, Mr as SpaceFsUploadEntry, Mt as BillingConversionIntent, N as SpaceChannelBindingRecord, Nn as MeResponse, Nr as SpaceFsUploadError, Nt as BillingCreditExpiryGroup, O as WorksApi, Oi as HttpTransport, On as LabelListItem, Or as SpaceFsReadFilesInput, Ot as BillingCatalog, P as SpaceClient, Pn as ModelCatalogEntry, Pr as SpaceFsUploadPlanEntry, Pt as BillingCreditGrantStatus, Q as createSessionGenerationStreamClient, Qn as SessionTurnsPaginatedResponse, Qr as SpaceUsageHourlyStat, Qt as CanvasNodeInput, R as PublicInviteApi, Rn as PromptTemplateCatalogResponse, Rr as SpaceFsWriteFileInput, Rt as BillingPaymentStatus, S as WorkSessionResponse, Si as GenerationContentBlock, Sn as JsonObject, Sr as SpaceFsEntry, St as BatchUserProfilesResponse, T as WorkUpdateInput, Ti as CohubClientOptions, Tn as LabelAssignmentListItem, Tr as SpaceFsMoveInput, Tt as BillingBalanceActivityKind, U as GenerationStreamFinalizedEvent, Un as SessionMessageResponse, Ur as SpaceModListItem, Ut as BillingProductKind, V as GenerationStreamErrorEvent, Vn as SendMessageCronJobPayload, Vr as SpaceMember, Vt as BillingProductCreditBenefit, W as GenerationStreamIntermediateMessage, Wn as SessionMessagesPaginatedResponse, Wr as SpacePresenceSnapshot, Wt as BillingProductPricing, X as GenerationStreamTurnUpdatedEvent, Xn as SessionTurnStreamSnapshotResponse, Xr as SpaceSandboxConfig, Xt as CanvasCreateInput, Y as GenerationStreamSubscriptionHandlers, Yn as SessionTurnSignedUrlsResponse, Yr as SpaceSandboxAutoDestroyPolicy, Yt as CanvasBootstrapResponse, Z as SessionGenerationStreamClient, Zn as SessionTurnWindowResponse, Zr as SpaceSessionsResponse, Zt as CanvasDocumentRecord, _ as WorkPresentationMeta, _i as filterGenerationDeclarationsByPolicy, _n as ExploreSpacesResponse, _r as SpaceFsCompleteUploadInput, _t as GenerationsApi, a as WorkCommerceCreditConsumeResponse, ai as CreateGenerationTaskRequest, an as CreateInvitationResponse, ar as SpaceCommerceCreditsBenefit, at as createSessionPatchReducer, b as WorkRecord, bi as normalizeGenerationPolicy, bn as GlobalSearchType, br as SpaceFsCreateUploadResponse, bt as AcceptInvitationResponse, c as WorkCommerceEntitlementsResponse, ci as ListGenerationModelsResponse, cn as CreateSpacePromptInput, cr as SpaceCommerceProduct, ct as CreatePublicAssetUploadInput, d as WorkCommercePurchaseResponse, di as GenerationParameterConstraint, dn as CronJobPayload, dr as SpaceConfig, dt as PublicAssetPurpose, ei as SpaceUsageSummary, en as CanvasSemanticOp, er as SpaceAccessPolicy, et as SessionPatchApplyInput, f as WorkAuthorizeResponse, fi as GenerationPolicy, fn as CronJobRecord, fr as SpaceConfigInput, ft as PublicAssetsApi, g as WorkMeta, gi as encodeGenerationPolicy, gn as ExploreSpaceItem, gr as SpaceEnvInput, gt as ModelsApi, h as WorkGetResponse, hi as decodeGenerationPolicy, hn as ExploreSection, hr as SpaceDefaultResponse, ht as PromptsApi, i as WorkCommerceCheckoutStatus, ii as UserRulesResponse, in as CreateInvitationInput, ir as SpaceCommerceBenefit, it as SessionPatchStatus, j as SessionEventName, jn as LabelScopeType, jr as SpaceFsUploadDestination, jt as BillingCheckoutResult, k as UserApi, ki as RawHttpResponse, kn as LabelRecord, kr as SpaceFsReadFilesResponse, kt as BillingCatalogProduct, l as WorkCommerceOrder, li as PublicGenerationDeclaration, ln as CreateSpacePromptResponse, lr as SpaceCommerceProductBenefitBinding, lt as CreatePublicAssetUploadResponse, m as WorkDetailResponse, mi as assertGenerationRequestAllowedByPolicy, mn as CursorPageInfo, mr as SpaceCreateResponse, mt as UploadPublicAssetInput, n as createHttpClient, ni as TaskRunRecord, nn as Channel, nr as SpaceChannelBindingInput, nt as SessionPatchReducer, o as WorkCommerceCreditConsumeStatus, oi as CreateGenerationTaskResponse, on as CreateSpaceInput, or as SpaceCommerceFeatureBenefit, ot as SessionAccessApi, p as WorkCreateInput, pi as GenerationPolicyError, pn as CronJobUpdatePatch, pr as SpaceConfigResponse, pt as UploadChatImageAttachmentInput, q as GenerationStreamStateEvent, qn as SessionTurnIndexResponse, qr as SpaceRecord, qt as BillingSubscriptionHistoryStatus, r as WorkCommerceApi, ri as UserProfile, rn as CheckpointRecord, rr as SpaceCheckpointDetailResponse, rt as SessionPatchState, s as WorkCommerceEntitlement, si as GenerationTaskResult, sn as CreateSpaceModInput, sr as SpaceCommerceOrder, st as SearchApi, t as CohubHttpClient, ti as TaskRunDetailResponse, tn as CanvasTransactionInput, tr as SpaceBootstrapSource, tt as SessionPatchApplyResult, u as WorkCommerceProductResolveResponse, ui as GenerationModelPolicy, un as CreateSpaceSessionInput, ur as SpaceCommerceProductCreditBenefit, ut as PublicAssetMimeType, v as WorkPublicOwnerRecord, vi as findGenerationModelPolicy, vn as GlobalSearchResponse, vr as SpaceFsCompleteUploadResponse, vt as CronJobsApi, w as WorkTargetType, wi as DiscordChannelConfig, wn as JsonValue, wr as SpaceFsFileResponse, wt as BillingBalanceActivity, x as WorkResolveResponse, xi as parseGenerationPolicyFromEnv, xn as InvitationDetail, xr as SpaceFsEncoding, xt as ApiError, y as WorkPublicSpaceRecord, yi as getAllowedGenerationModelIds, yn as GlobalSearchResult, yr as SpaceFsCreateUploadInput, yt as ChannelsApi, z as AssistantMessageCommit, zn as PublicUserProfile, zr as SpaceInvitation, zt as BillingPluginStatus } from "./chunks/http.js";
|
|
5
5
|
|
|
6
6
|
//#region src/apis/billing.d.ts
|
|
7
7
|
declare class BillingApi {
|
|
@@ -72,6 +72,11 @@ type WorkRuntimeContext = {
|
|
|
72
72
|
viewerScopes: Permission[];
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
|
+
type WorkRuntimeCheckoutStatus = "success" | "failed" | "cancel" | null;
|
|
76
|
+
type WorkRuntimeCheckoutState = {
|
|
77
|
+
status: WorkRuntimeCheckoutStatus;
|
|
78
|
+
orderId: string | null;
|
|
79
|
+
};
|
|
75
80
|
declare class WorkRuntimeApi {
|
|
76
81
|
private token;
|
|
77
82
|
context(): Promise<WorkRuntimeContext | null>;
|
|
@@ -82,6 +87,18 @@ declare class WorkRuntimeApi {
|
|
|
82
87
|
scopes: Permission[];
|
|
83
88
|
reason?: string;
|
|
84
89
|
}): Promise<boolean>;
|
|
90
|
+
purchase(input: {
|
|
91
|
+
productKey: string;
|
|
92
|
+
}): Promise<{
|
|
93
|
+
providerKey: string | null;
|
|
94
|
+
checkoutUrl: string | null;
|
|
95
|
+
checkoutUsable: boolean;
|
|
96
|
+
status: string | null;
|
|
97
|
+
message: string | null;
|
|
98
|
+
orderId: string;
|
|
99
|
+
productKey: string;
|
|
100
|
+
} | null>;
|
|
101
|
+
checkoutState(): Promise<WorkRuntimeCheckoutState | null>;
|
|
85
102
|
}
|
|
86
103
|
declare const createWorkRuntime: () => WorkRuntimeApi;
|
|
87
104
|
//#endregion
|
|
@@ -120,6 +137,7 @@ declare class CohubClient {
|
|
|
120
137
|
readonly invite: PublicInviteApi;
|
|
121
138
|
readonly voice: VoiceApi;
|
|
122
139
|
readonly works: WorksApi;
|
|
140
|
+
readonly workCommerce: WorkCommerceApi;
|
|
123
141
|
private readonly transport;
|
|
124
142
|
private readonly websocketClient;
|
|
125
143
|
private readonly workRuntime;
|
|
@@ -131,9 +149,45 @@ declare class CohubClient {
|
|
|
131
149
|
reason?: string;
|
|
132
150
|
}) => Promise<boolean>;
|
|
133
151
|
};
|
|
152
|
+
readonly work: {
|
|
153
|
+
commerce: {
|
|
154
|
+
resolveProducts: (input: {
|
|
155
|
+
productKeys: string[];
|
|
156
|
+
}) => Promise<WorkCommerceProductResolveResponse>;
|
|
157
|
+
getEntitlements: () => Promise<WorkCommerceEntitlementsResponse>;
|
|
158
|
+
consumeCredits: (input: {
|
|
159
|
+
amount: number;
|
|
160
|
+
operationId: string;
|
|
161
|
+
reason?: string;
|
|
162
|
+
}) => Promise<WorkCommerceCreditConsumeResponse>;
|
|
163
|
+
purchase: (input: {
|
|
164
|
+
productKey: string;
|
|
165
|
+
}) => Promise<{
|
|
166
|
+
providerKey: string | null;
|
|
167
|
+
checkoutUrl: string | null;
|
|
168
|
+
checkoutUsable: boolean;
|
|
169
|
+
status: string | null;
|
|
170
|
+
message: string | null;
|
|
171
|
+
orderId: string;
|
|
172
|
+
productKey: string;
|
|
173
|
+
} | null>;
|
|
174
|
+
getCheckoutState: () => Promise<{
|
|
175
|
+
status: WorkCommerceCheckoutStatus;
|
|
176
|
+
orderId: string | null;
|
|
177
|
+
}>;
|
|
178
|
+
getOrder: (orderId: string) => Promise<{
|
|
179
|
+
order: WorkCommerceOrder;
|
|
180
|
+
}>;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
134
183
|
space(spaceId: string): SpaceClient;
|
|
135
184
|
onConnection(handler: (state: WebSocketConnectionState) => void): () => void;
|
|
136
185
|
}
|
|
137
186
|
declare const createCohubClient: (options?: CohubClientOptions) => CohubClient;
|
|
138
187
|
//#endregion
|
|
139
|
-
|
|
188
|
+
//#region src/http-error.d.ts
|
|
189
|
+
declare function isHttpErrorCode(error: unknown, code: string): error is HttpError & {
|
|
190
|
+
code: string;
|
|
191
|
+
};
|
|
192
|
+
//#endregion
|
|
193
|
+
export { AcceptInvitationResponse, ApiError, type AssistantMessageCommit, BatchUserProfilesResponse, BillingAccessWarning, BillingApi, BillingBalanceActivity, BillingBalanceActivityKind, BillingBalanceActivityList, BillingBalanceActivityStatus, BillingCatalog, BillingCatalogProduct, BillingCheckoutActionState, BillingCheckoutResult, BillingConversionIntent, BillingCreditExpiryGroup, BillingCreditGrantStatus, BillingCreditStatus, BillingCreditUnit, BillingHistoryPagination, BillingPaymentStatus, BillingPluginStatus, BillingProductBillingInterval, BillingProductCreditBenefit, BillingProductDisplay, BillingProductKind, BillingProductPricing, BillingRedemptionResult, BillingSubscriptionHistoryList, BillingSubscriptionHistoryStatus, BillingSubscriptionSummary, COHUB_ENVIRONMENTS, CanvasBootstrapResponse, CanvasCreateInput, CanvasDocumentRecord, CanvasNodeInput, CanvasNodeRecord, CanvasSemanticOp, CanvasTransactionInput, Channel, type ChannelConfig, type ChannelEnvelope, CheckpointRecord, CohubClient, type CohubClientOptions, type CohubEnvironment, CohubHttpClient, type ContentBlock, type CreateGenerationTaskRequest, type CreateGenerationTaskResponse, CreateInvitationInput, CreateInvitationResponse, type CreatePublicAssetUploadInput, type CreatePublicAssetUploadResponse, CreateSpaceInput, CreateSpaceModInput, CreateSpacePromptInput, CreateSpacePromptResponse, CreateSpaceSessionInput, CronJobPayload, CronJobRecord, CronJobUpdatePatch, CursorPageInfo, type DiscordChannelConfig, ExploreSection, ExploreSpaceItem, ExploreSpacesResponse, type Fetch, type GenerationContentBlock, type GenerationModelPolicy, type GenerationParameterConstraint, type GenerationPolicy, GenerationPolicyError, type GenerationStreamCommitEvent, type GenerationStreamErrorEvent, type GenerationStreamEvent, type GenerationStreamFinalizedEvent, type GenerationStreamIntermediateMessage, type GenerationStreamLifecycleEvent, type GenerationStreamOutOfSyncEvent, type GenerationStreamStateEvent, type GenerationStreamSubscribeOptions, type GenerationStreamSubscriptionHandlers, type GenerationStreamTurnUpdatedEvent, type GenerationTaskResult, GlobalSearchResponse, GlobalSearchResult, GlobalSearchType, HttpError, InvitationDetail, JsonObject, JsonPrimitive, JsonValue, LabelAssignmentListItem, LabelAssignmentPageInfo, LabelAssignmentRecord, type LabelAssignmentsUpdatedEvent, LabelListItem, LabelRecord, LabelResourceType, LabelScopeType, LabelSource, type ListGenerationModelsResponse, MeResponse, type MessageRecord, ModelCatalogEntry, Permission, PromptAccessMode, PromptTemplateCatalogEntry, PromptTemplateCatalogResponse, type PublicAssetMimeType, type PublicAssetPurpose, type PublicGenerationDeclaration, PublicUserProfile, type RawHttpResponse, type RealtimeServerEvent, ResourceLabelsResponse, SendMessageCronJobPayload, SessionBindingRecord, type SessionEventName, type SessionForkRecord, SessionGenerationStreamClient, SessionMessageResponse, SessionMessagesPaginatedResponse, SessionMessagesResponse, type SessionPatchApplyInput, type SessionPatchApplyResult, SessionPatchReducer, type SessionPatchState, type SessionPatchStatus, SessionRecord, type SessionSubscriptionHandlers, type SessionTurnIndexItem, SessionTurnIndexResponse, type SessionTurnRecord, SessionTurnResponse, type SessionTurnSegmentRecord, SessionTurnSignedUrlsResponse, SessionTurnStreamSnapshotResponse, SessionTurnWindowResponse, SessionTurnsPaginatedResponse, SpaceAccess, SpaceAccessPolicy, SpaceBootstrapSource, SpaceChannelBindingInput, type SpaceChannelBindingRecord, SpaceCheckpointDetailResponse, SpaceCommerceBenefit, SpaceCommerceCreditsBenefit, SpaceCommerceFeatureBenefit, SpaceCommerceOrder, SpaceCommerceProduct, SpaceCommerceProductBenefitBinding, SpaceCommerceProductCreditBenefit, SpaceConfig, SpaceConfigInput, SpaceConfigResponse, SpaceCreateResponse, SpaceDefaultResponse, SpaceEnvInput, type SpaceEventName, SpaceFsCompleteUploadInput, SpaceFsCompleteUploadResponse, SpaceFsCreateUploadInput, SpaceFsCreateUploadResponse, SpaceFsEncoding, SpaceFsEntry, SpaceFsFileKind, SpaceFsFileResponse, SpaceFsMoveInput, SpaceFsPreparingFile, SpaceFsReadFilesError, SpaceFsReadFilesInput, SpaceFsReadFilesResponse, SpaceFsTreeResponse, SpaceFsUploadDestination, SpaceFsUploadEntry, SpaceFsUploadError, SpaceFsUploadPlanEntry, SpaceFsUploadPlanEntryInput, SpaceFsUploadProgress, SpaceFsUploadResponse, SpaceFsWriteFileInput, SpaceInvitation, SpaceListItem, SpaceMember, SpaceMeta, SpaceModListItem, SpacePresenceSnapshot, SpacePresenceUser, SpacePublicProfile, SpaceRecord, SpaceRole, SpaceSandboxAutoDestroyPolicy, SpaceSandboxConfig, SpaceSessionsResponse, SpaceUsageHourlyStat, SpaceUsageResponse, SpaceUsageSummary, TaskRunDetailResponse, TaskRunRecord, type UploadChatImageAttachmentInput, type UploadPublicAssetInput, UserProfile, UserRulesResponse, UsersApi, VoiceApi, type VoiceInputCallbacks, VoiceInputClient, type VoiceInputClientOptions, type VoiceInputCreateOptions, type VoiceInputEvent, type WebSocketConnectionState, WebsocketClient, type WorkAuthorizeResponse, WorkCommerceApi, type WorkCommerceCheckoutStatus, type WorkCommerceCreditConsumeResponse, type WorkCommerceCreditConsumeStatus, type WorkCommerceEntitlement, type WorkCommerceEntitlementsResponse, type WorkCommerceOrder, type WorkCommerceProductResolveResponse, type WorkCommercePurchaseResponse, type WorkCreateInput, type WorkDetailResponse, type WorkGetResponse, type WorkMeta, type WorkPresentationMeta, type WorkPublicOwnerRecord, type WorkPublicSpaceRecord, type WorkRecord, type WorkResolveResponse, WorkRuntimeApi, type WorkRuntimeCheckoutState, type WorkRuntimeCheckoutStatus, type WorkRuntimeContext, type WorkSessionResponse, type WorkStatus, type WorkTargetType, type WorkUpdateInput, type WorkVersionRecord, type WorkVisibility, WorksApi, assertGenerationRequestAllowedByPolicy, createCohubClient, createHttpClient, createSessionGenerationStreamClient, createSessionPatchReducer, createVoiceInputClient, createWebsocketClient, createWorkRuntime, decodeGenerationPolicy, encodeGenerationPolicy, filterGenerationDeclarationsByPolicy, findGenerationModelPolicy, getAllowedGenerationModelIds, isHttpErrorCode, normalizeBaseUrl, normalizeGenerationPolicy, normalizeVoiceInputWebsocketUrl, normalizeWebsocketUrl, parseAssistantMessageCommit, parseGenerationPolicyFromEnv, resolveApiBaseUrl, resolveCohubEnvironment, resolveVoiceInputWebsocketUrl, resolveWebsocketUrl };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as CronJobsApi, S as GenerationsApi, _ as SessionAccessApi, a as UserApi, b as PromptsApi, c as SpacesApi, d as createSessionGenerationStreamClient, f as parseAssistantMessageCommit, g as HttpTransport, h as HttpError, i as WorksApi, l as PublicInviteApi, m as createSessionPatchReducer, n as createHttpClient, o as TasksApi, p as SessionPatchReducer, r as WorkCommerceApi, s as SpaceClient, t as CohubHttpClient, u as SessionGenerationStreamClient, v as SearchApi, w as ChannelsApi, x as ModelsApi, y as PublicAssetsApi } from "./chunks/http.js";
|
|
2
2
|
import { a as resolveApiBaseUrl, c as resolveWebsocketUrl, i as normalizeWebsocketUrl, n as normalizeBaseUrl, o as resolveCohubEnvironment, r as normalizeVoiceInputWebsocketUrl, s as resolveVoiceInputWebsocketUrl, t as COHUB_ENVIRONMENTS } from "./chunks/environment.js";
|
|
3
3
|
import { WebsocketClient, createWebsocketClient } from "./websocket.js";
|
|
4
4
|
import { VoiceApi, VoiceInputClient, createVoiceInputClient } from "./voice-input.js";
|
|
@@ -176,6 +176,15 @@ var WorkRuntimeApi = class {
|
|
|
176
176
|
this.token = response?.token ?? null;
|
|
177
177
|
return Boolean(this.token);
|
|
178
178
|
}
|
|
179
|
+
async purchase(input) {
|
|
180
|
+
return (await request({
|
|
181
|
+
type: "cohub.work.purchase",
|
|
182
|
+
productKey: input.productKey
|
|
183
|
+
}, 12e4))?.checkout ?? null;
|
|
184
|
+
}
|
|
185
|
+
async checkoutState() {
|
|
186
|
+
return await request({ type: "cohub.work.checkout-state" }, 8e3, 250) ?? null;
|
|
187
|
+
}
|
|
179
188
|
};
|
|
180
189
|
const createWorkRuntime = () => new WorkRuntimeApi();
|
|
181
190
|
//#endregion
|
|
@@ -198,6 +207,7 @@ var CohubClient = class {
|
|
|
198
207
|
invite;
|
|
199
208
|
voice;
|
|
200
209
|
works;
|
|
210
|
+
workCommerce;
|
|
201
211
|
transport;
|
|
202
212
|
websocketClient;
|
|
203
213
|
workRuntime;
|
|
@@ -242,11 +252,42 @@ var CohubClient = class {
|
|
|
242
252
|
this.explore = new ExploreApi(this.transport);
|
|
243
253
|
this.invite = new PublicInviteApi(this.transport);
|
|
244
254
|
this.works = new WorksApi(this.transport);
|
|
255
|
+
this.workCommerce = new WorkCommerceApi(this.transport);
|
|
245
256
|
}
|
|
246
257
|
context() {
|
|
247
258
|
return this.workRuntime.context();
|
|
248
259
|
}
|
|
249
260
|
auth = { request: (input) => this.workRuntime.requestAuthorization(input) };
|
|
261
|
+
work = { commerce: {
|
|
262
|
+
resolveProducts: async (input) => {
|
|
263
|
+
const context = await this.workRuntime.context();
|
|
264
|
+
if (!context?.work?.id) throw new Error("Work context is unavailable.");
|
|
265
|
+
return this.workCommerce.resolveProducts(context.work.id, input);
|
|
266
|
+
},
|
|
267
|
+
getEntitlements: async () => {
|
|
268
|
+
const context = await this.workRuntime.context();
|
|
269
|
+
if (!context?.work?.id) throw new Error("Work context is unavailable.");
|
|
270
|
+
return this.workCommerce.getEntitlements(context.work.id);
|
|
271
|
+
},
|
|
272
|
+
consumeCredits: async (input) => {
|
|
273
|
+
const context = await this.workRuntime.context();
|
|
274
|
+
if (!context?.work?.id) throw new Error("Work context is unavailable.");
|
|
275
|
+
return this.workCommerce.consumeCredits(context.work.id, input);
|
|
276
|
+
},
|
|
277
|
+
purchase: async (input) => this.workRuntime.purchase(input),
|
|
278
|
+
getCheckoutState: async () => {
|
|
279
|
+
const result = await this.workRuntime.checkoutState();
|
|
280
|
+
return {
|
|
281
|
+
status: result?.status ?? null,
|
|
282
|
+
orderId: result?.orderId ?? null
|
|
283
|
+
};
|
|
284
|
+
},
|
|
285
|
+
getOrder: async (orderId) => {
|
|
286
|
+
const context = await this.workRuntime.context();
|
|
287
|
+
if (!context?.work?.id) throw new Error("Work context is unavailable.");
|
|
288
|
+
return this.workCommerce.getOrder(context.work.id, orderId);
|
|
289
|
+
}
|
|
290
|
+
} };
|
|
250
291
|
space(spaceId) {
|
|
251
292
|
return new SpaceClient(spaceId, this.transport, this.websocketClient);
|
|
252
293
|
}
|
|
@@ -297,6 +338,11 @@ var CohubClient = class {
|
|
|
297
338
|
};
|
|
298
339
|
const createCohubClient = (options) => new CohubClient(options);
|
|
299
340
|
//#endregion
|
|
341
|
+
//#region src/http-error.ts
|
|
342
|
+
function isHttpErrorCode(error, code) {
|
|
343
|
+
return error instanceof HttpError && error.code === code;
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
300
346
|
//#region ../protocol/src/generation/policy.ts
|
|
301
347
|
const GENERATION_POLICY_ENV_KEY = "COHUB_GENERATION_POLICY_B64";
|
|
302
348
|
var GenerationPolicyError = class extends Error {
|
|
@@ -528,4 +574,4 @@ function filterGenerationDeclarationsByPolicy(declarations, policy) {
|
|
|
528
574
|
});
|
|
529
575
|
}
|
|
530
576
|
//#endregion
|
|
531
|
-
export { BillingApi, COHUB_ENVIRONMENTS, CohubClient, CohubHttpClient, GenerationPolicyError, HttpError, SessionGenerationStreamClient, SessionPatchReducer, UsersApi, VoiceApi, VoiceInputClient, WebsocketClient, WorkRuntimeApi, WorksApi, assertGenerationRequestAllowedByPolicy, createCohubClient, createHttpClient, createSessionGenerationStreamClient, createSessionPatchReducer, createVoiceInputClient, createWebsocketClient, createWorkRuntime, decodeGenerationPolicy, encodeGenerationPolicy, filterGenerationDeclarationsByPolicy, findGenerationModelPolicy, getAllowedGenerationModelIds, normalizeBaseUrl, normalizeGenerationPolicy, normalizeVoiceInputWebsocketUrl, normalizeWebsocketUrl, parseAssistantMessageCommit, parseGenerationPolicyFromEnv, resolveApiBaseUrl, resolveCohubEnvironment, resolveVoiceInputWebsocketUrl, resolveWebsocketUrl };
|
|
577
|
+
export { BillingApi, COHUB_ENVIRONMENTS, CohubClient, CohubHttpClient, GenerationPolicyError, HttpError, SessionGenerationStreamClient, SessionPatchReducer, UsersApi, VoiceApi, VoiceInputClient, WebsocketClient, WorkCommerceApi, WorkRuntimeApi, WorksApi, assertGenerationRequestAllowedByPolicy, createCohubClient, createHttpClient, createSessionGenerationStreamClient, createSessionPatchReducer, createVoiceInputClient, createWebsocketClient, createWorkRuntime, decodeGenerationPolicy, encodeGenerationPolicy, filterGenerationDeclarationsByPolicy, findGenerationModelPolicy, getAllowedGenerationModelIds, isHttpErrorCode, normalizeBaseUrl, normalizeGenerationPolicy, normalizeVoiceInputWebsocketUrl, normalizeWebsocketUrl, parseAssistantMessageCommit, parseGenerationPolicyFromEnv, resolveApiBaseUrl, resolveCohubEnvironment, resolveVoiceInputWebsocketUrl, resolveWebsocketUrl };
|