@neta-art/cohub 2.7.0 → 2.8.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.
@@ -1,1424 +1,7 @@
1
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";
2
+ import { $ as CheckpointDiffSummary, $n as SpaceFsUploadResponse, An as SpaceCreateResponse, At as LabelListItem, B as CanvasDocumentRecord, Bn as SpaceFsFileResponse, Cn as SpaceCommerceProduct, Cr as UserRulesResponse, Dn as SpaceConfigInput, Dt as LabelAssignmentRecord, Er as GenerationTaskResult, Fn as SpaceFsCreateUploadInput, Ft as MeResponse, G as Channel, Gn as SpaceFsReadFilesResponse, Gr as ChannelHealth, Gt as ReferenceAggregateGroupBy, Hn as SpaceFsPreparingFile, Ht as PromptTemplateCatalogResponse, In as SpaceFsCreateUploadResponse, It as ModelCatalogEntry, J as CheckpointDiffFileResponse, Jt as ReferenceKind, Kn as SpaceFsTreeResponse, Kt as ReferenceAggregateResponse, Lt as PatchResourceLabelsInput, Mn as SpaceEnvInput, Mt as LabelResourceType, Nn as SpaceFsCompleteUploadInput, On as SpaceConfigResponse, Or as ListGenerationModelsResponse, Ot as LabelItemsResponse, Pn as SpaceFsCompleteUploadResponse, Qr as RealtimePatchOperation, R as CanvasBootstrapResponse, Rt as PatchResourceLabelsResponse, Sn as SpaceCommerceOrder, Sr as UserProfile, Tr as CreateGenerationTaskResponse, Vn as SpaceFsMoveInput, W as CanvasTransactionInput, Wr as ChannelConfig, Xt as ReferenceQueryableType, Yt as ReferenceQueryResponse, _n as SpaceCheckpointDetailResponse, a as WebsocketClientOptions, an as SessionMessagesResponse, ar as SpaceModListItem, at as CreateSpacePromptInput, br as TaskRunDetailResponse, bt as GlobalSearchType, ci as ContentBlock, cn as SessionTurnResponse, cr as SpacePresenceSnapshot, dn as SessionTurnWindowResponse, dr as SpaceRecord, dt as CursorPageInfo, ei as SessionTurnPatchEvent, er as SpaceFsWriteFileInput, et as CheckpointRecord, fn as SessionTurnsPaginatedResponse, fr as SpaceRole, gr as SpaceSessionsResponse, in as SessionMessagesPaginatedResponse, jn as SpaceDefaultResponse, kn as SpaceConfigUpdateResponse, l as AcceptInvitationResponse, ln as SessionTurnSignedUrlsResponse, lt as CronJobRecord, mn as SpaceAccessPolicy, ni as MessageRecord, nt as CreateInvitationResponse, oi as SessionTurnRecord, on as SessionRecord, or as SpacePendingDiffFileResponse, ot as CreateSpacePromptResponse, qt as ReferenceDirection, r as WebsocketClient, ri as SessionForkRecord, rn as SessionMessageResponse, rr as SpaceMember, rt as CreateSpaceInput, s as WebsocketEventPayload, si as Usage, sn as SessionTurnIndexResponse, sr as SpacePendingDiffSummary, st as CreateSpaceSessionInput, ti as SpacePublicEndpoints, tr as SpaceInvitation, tt as CreateInvitationInput, un as SessionTurnStreamSnapshotResponse, ur as SpacePublicProfile, ut as CronJobUpdatePatch, vn as SpaceCommerceBenefit, vr as SpaceUsageResponse, vt as GlobalSearchResponse, wn as SpaceCommerceProductBenefitBinding, wr as CreateGenerationTaskRequest, xr as TaskRunRecord, xt as InvitationDetail, yn as SpaceCommerceBuyerProfile, z as CanvasCreateInput, zt as Permission } from "./websocket.js";
3
3
  import { a as VoiceInputCreateOptions } from "./voice-input.js";
4
4
 
5
- //#region ../protocol/src/gateway/types.d.ts
6
- type ChannelModelConfig = {
7
- provider: string;
8
- id: string;
9
- };
10
- type BaseChannelConfig = {
11
- model?: ChannelModelConfig | null;
12
- };
13
- type DiscordChannelConfig = BaseChannelConfig & {
14
- inbound?: {
15
- requireMentionInGuild?: boolean;
16
- };
17
- outbound?: {
18
- showThinking?: boolean;
19
- showToolCalls?: boolean;
20
- };
21
- };
22
- type FeishuChannelConfig = BaseChannelConfig & {
23
- brand?: "feishu" | "lark";
24
- inbound?: {
25
- requireMentionInGroup?: boolean;
26
- };
27
- outbound?: {
28
- renderMode?: "card" | "post";
29
- showThinking?: boolean;
30
- showToolCalls?: boolean;
31
- };
32
- };
33
- type WeChatChannelConfig = BaseChannelConfig & {
34
- outbound?: {
35
- showIntermediateStatus?: boolean;
36
- };
37
- };
38
- type ChannelConfig = DiscordChannelConfig | FeishuChannelConfig | WeChatChannelConfig | (BaseChannelConfig & Record<string, unknown>);
39
- //#endregion
40
- //#region ../../node_modules/.pnpm/@neta-art+generation@0.1.10/node_modules/@neta-art/generation/dist/builtins-CWEB_GK4.d.ts
41
- //#region src/types.d.ts
42
- declare const MODEL_SCHEMA: "neta.generation.model.v1";
43
- type GenerationSource = {
44
- type: "url";
45
- url: string;
46
- } | {
47
- type: "base64";
48
- mediaType: string;
49
- data: string;
50
- };
51
- type GenerationContentBlockMeta = Record<string, unknown>;
52
- type GenerationContentBlock = {
53
- type: "text";
54
- text: string;
55
- meta?: GenerationContentBlockMeta;
56
- } | {
57
- type: "image";
58
- source: GenerationSource;
59
- meta?: GenerationContentBlockMeta;
60
- } | {
61
- type: "video";
62
- source: GenerationSource;
63
- meta?: GenerationContentBlockMeta;
64
- } | {
65
- type: "audio";
66
- source: GenerationSource;
67
- meta?: GenerationContentBlockMeta;
68
- };
69
- type GenerationContentSpec = {
70
- type: "text" | "image" | "video" | "audio";
71
- required?: boolean;
72
- min?: number;
73
- max?: number;
74
- sources?: Array<GenerationSource["type"]>;
75
- roles?: string[];
76
- roleRequired?: boolean;
77
- merge?: "newline" | "space" | "concat";
78
- meta?: Record<string, unknown>;
79
- description?: string;
80
- };
81
- type GenerationParameterSpec = {
82
- type: "string";
83
- optional?: boolean;
84
- default?: string;
85
- enum?: string[];
86
- description?: string;
87
- examples?: string[];
88
- } | {
89
- type: "number";
90
- optional?: boolean;
91
- default?: number;
92
- min?: number;
93
- max?: number;
94
- description?: string;
95
- examples?: number[];
96
- } | {
97
- type: "integer";
98
- optional?: boolean;
99
- default?: number;
100
- min?: number;
101
- max?: number;
102
- description?: string;
103
- examples?: number[];
104
- } | {
105
- type: "boolean";
106
- optional?: boolean;
107
- default?: boolean;
108
- description?: string;
109
- examples?: boolean[];
110
- };
111
- type GenerationMetaFieldSpec = GenerationParameterSpec | {
112
- type: "object";
113
- optional?: boolean;
114
- description?: string;
115
- };
116
- type GenerationMetaTaskVariantSpec = {
117
- description?: string;
118
- required?: string[];
119
- requiredContent?: Array<GenerationContentSpec["type"]>;
120
- sendTask?: boolean;
121
- };
122
- type GenerationMetaSpec = {
123
- fields?: Record<string, GenerationMetaFieldSpec>;
124
- taskField?: string;
125
- taskVariants?: Record<string, GenerationMetaTaskVariantSpec>;
126
- };
127
- type GenerationModelDeclaration = {
128
- schema: typeof MODEL_SCHEMA;
129
- model: string;
130
- title?: string;
131
- description?: string;
132
- allowUnknownParameters?: boolean;
133
- adapter: {
134
- type: string;
135
- } & Record<string, unknown>;
136
- content: {
137
- input: GenerationContentSpec[];
138
- };
139
- parameters?: Record<string, GenerationParameterSpec>;
140
- meta?: GenerationMetaSpec;
141
- examples?: Array<{
142
- title?: string;
143
- request: GenerateRequest;
144
- }>;
145
- };
146
- type GenerateRequest = {
147
- model: string;
148
- content: GenerationContentBlock[];
149
- parameters?: Record<string, unknown>;
150
- meta?: Record<string, unknown>; /** @deprecated Use meta. */
151
- metadata?: Record<string, unknown>;
152
- apiKey?: string;
153
- baseUrl?: string;
154
- };
155
- //#endregion
156
- //#region ../protocol/src/generation/policy.d.ts
157
- type GenerationPolicy = {
158
- version: 1;
159
- mode: "auto" | "limited";
160
- models?: GenerationModelPolicy[];
161
- };
162
- type GenerationModelPolicy = {
163
- model: string;
164
- /**
165
- * Generic constraints keyed by generation declaration parameter name.
166
- * Missing parameters are not restricted by policy.
167
- */
168
- parameters?: Record<string, GenerationParameterConstraint>;
169
- };
170
- type GenerationParameterConstraint = {
171
- kind: "enum";
172
- values: Array<string | number | boolean>;
173
- } | {
174
- kind: "number";
175
- min?: number;
176
- max?: number;
177
- values?: number[];
178
- } | {
179
- kind: "integer";
180
- min?: number;
181
- max?: number;
182
- values?: number[];
183
- } | {
184
- kind: "boolean";
185
- value?: boolean;
186
- };
187
- declare class GenerationPolicyError extends Error {
188
- constructor(message: string);
189
- }
190
- type EnvLike = Record<string, string | undefined>;
191
- type PublicDeclaration = Omit<GenerationModelDeclaration, "adapter">;
192
- declare function normalizeGenerationPolicy(value: unknown): GenerationPolicy | null;
193
- declare function encodeGenerationPolicy(policy: GenerationPolicy): string;
194
- declare function decodeGenerationPolicy(value: string): GenerationPolicy | null;
195
- declare function parseGenerationPolicyFromEnv(env: EnvLike): GenerationPolicy | null;
196
- declare function getAllowedGenerationModelIds(policy: GenerationPolicy | null): string[] | null;
197
- declare function findGenerationModelPolicy(policy: GenerationPolicy | null, model: string): GenerationModelPolicy | null;
198
- declare function assertGenerationRequestAllowedByPolicy(input: {
199
- policy: GenerationPolicy | null;
200
- model: string;
201
- parameters?: Record<string, unknown>;
202
- }): void;
203
- declare function filterGenerationDeclarationsByPolicy<T extends PublicDeclaration>(declarations: T[], policy: GenerationPolicy | null): T[];
204
- //#endregion
205
- //#region ../protocol/src/generation/index.d.ts
206
- declare const GENERATION_TASK_TYPE: "generation";
207
- type CreateGenerationTaskRequest = {
208
- spaceId: string;
209
- sessionId?: string | null;
210
- turnId?: string | null;
211
- model: string;
212
- content: GenerationContentBlock[];
213
- parameters?: Record<string, unknown>;
214
- meta?: Record<string, unknown>;
215
- };
216
- type CreateGenerationTaskResponse = {
217
- taskRunId: string;
218
- taskType: typeof GENERATION_TASK_TYPE;
219
- status: "pending";
220
- };
221
- type GenerationTaskResult = {
222
- model: string;
223
- output: GenerationContentBlock[];
224
- meta?: Record<string, unknown>;
225
- };
226
- type PublicGenerationDeclaration = Omit<GenerationModelDeclaration, "adapter">;
227
- type ListGenerationModelsResponse = {
228
- models: PublicGenerationDeclaration[];
229
- };
230
- //#endregion
231
- //#region src/types.d.ts
232
- type ApiError = {
233
- message: string;
234
- };
235
- type UserProfile = {
236
- userUuid: string;
237
- logtoUserId?: string;
238
- username: string | null;
239
- displayName: string;
240
- avatarUrl: string | null;
241
- syncedAt?: string;
242
- };
243
- type PublicUserProfile = {
244
- userUuid: string;
245
- username: string | null;
246
- displayName: string;
247
- avatarUrl: string | null;
248
- };
249
- type BatchUserProfilesResponse = {
250
- profiles: Record<string, PublicUserProfile>;
251
- missingUserUuids: string[];
252
- };
253
- type SpacePresenceUser = {
254
- userId: string;
255
- connectionCount: number;
256
- lastSeenAt: string;
257
- meta: Record<string, unknown> | null;
258
- metas: Record<string, unknown>[];
259
- profile: PublicUserProfile;
260
- };
261
- type SpacePresenceSnapshot = {
262
- spaceId: string;
263
- users: SpacePresenceUser[];
264
- updatedAt: string;
265
- };
266
- type MeResponse = {
267
- uuid: string;
268
- profile: UserProfile;
269
- email: string | null;
270
- };
271
- type BillingPluginStatus = {
272
- provider: "disabled" | "talesofai";
273
- configured: boolean;
274
- reason?: string;
275
- };
276
- type BillingCreditUnit = {
277
- tokenType: string;
278
- displayCurrency: "USD";
279
- displayUnit: string;
280
- unitToUsd: number;
281
- unitsPerUsd: number;
282
- usdDecimalPlaces: number;
283
- };
284
- type BillingCreditGrantStatus = {
285
- id: string;
286
- tokenType: string;
287
- benefitKey: string | null;
288
- benefitName: string | null;
289
- grantKind: string | null;
290
- sourceType: string | null;
291
- sourceId: string | null;
292
- status: string;
293
- availableNow: boolean | null;
294
- unavailableReasons: string[];
295
- remainingAmount: number;
296
- remainingAmountUsd: number;
297
- originalAmount: number | null;
298
- originalAmountUsd: number | null;
299
- consumedAmount: number | null;
300
- consumedAmountUsd: number | null;
301
- usageConsumedAmount: number | null;
302
- usageConsumedAmountUsd: number | null;
303
- settledOverageAmount: number | null;
304
- settledOverageAmountUsd: number | null;
305
- consumedPercent: number | null;
306
- effectiveAt: string | null;
307
- expiresAt: string | null;
308
- daysRemaining: number | null;
309
- createdAt: string;
310
- };
311
- type BillingCreditExpiryGroup = {
312
- key: "expired" | "lt_7d" | "lt_30d" | "gte_30d" | "never";
313
- remainingAmountUsd: number;
314
- grants: BillingCreditGrantStatus[];
315
- };
316
- type BillingCreditStatus = {
317
- netUsd: number;
318
- groups: BillingCreditExpiryGroup[];
319
- };
320
- type BillingProductKind = "plan" | "addon";
321
- type BillingProductBillingInterval = "monthly" | "quarterly" | "yearly" | "one_time" | "other";
322
- type BillingProductPricing = {
323
- amountMinor: number;
324
- amountUsd: number;
325
- compareAtAmountMinor: number | null;
326
- compareAtAmountUsd: number | null;
327
- discountLabel: string | null;
328
- discountRate: number | null;
329
- };
330
- type BillingProductDisplay = {
331
- description: string | null;
332
- benefits: string[];
333
- creditsAmount: number | null;
334
- validity: string | null;
335
- creditBenefits: BillingProductCreditBenefit[];
336
- };
337
- type BillingProductCreditBenefit = {
338
- key: string;
339
- name: string;
340
- tokenType: string;
341
- grantKind: string;
342
- scope: string;
343
- cycleAmount: number;
344
- cycleAmountUsd: number;
345
- periodAmount: number;
346
- periodAmountUsd: number;
347
- expiresInDays: number | null;
348
- };
349
- type BillingCatalogProduct = {
350
- id: string;
351
- key: string;
352
- name: string;
353
- description: string | null;
354
- status: string;
355
- visibility: string;
356
- billingType: string;
357
- billingPeriod: string;
358
- billingIntervalCount: number;
359
- currency: string;
360
- kind: BillingProductKind;
361
- interval: BillingProductBillingInterval;
362
- pricing: BillingProductPricing;
363
- display: BillingProductDisplay;
364
- isDefaultPlan: boolean;
365
- };
366
- type SpaceCommerceFeatureBenefit = {
367
- key: string;
368
- name: string;
369
- description: string | null;
370
- status: string;
371
- type: "feature";
372
- config: {
373
- type: "feature";
374
- metadata: Record<string, string | number | boolean>;
375
- };
376
- };
377
- type SpaceCommerceCreditsBenefit = {
378
- key: string;
379
- name: string;
380
- description: string | null;
381
- status: string;
382
- type: "credits";
383
- config: {
384
- type: "credits";
385
- amount: number;
386
- expiresInDays: number | null;
387
- };
388
- };
389
- type SpaceCommerceBenefit = SpaceCommerceFeatureBenefit | SpaceCommerceCreditsBenefit;
390
- type SpaceCommerceProductCreditBenefit = {
391
- key: string;
392
- name: string;
393
- amount: number;
394
- expiresInDays: number | null;
395
- };
396
- type SpaceCommerceProduct = {
397
- id: string;
398
- key: string;
399
- name: string;
400
- description: string | null;
401
- status: string;
402
- visibility: string;
403
- billingType: string;
404
- billingPeriod: string;
405
- billingIntervalCount: number;
406
- currency: string;
407
- kind: "addon";
408
- interval: "one_time";
409
- pricing: {
410
- amountMinor: number;
411
- amountUsd: number;
412
- compareAtAmountMinor: number | null;
413
- compareAtAmountUsd: number | null;
414
- discountLabel: string | null;
415
- discountRate: number | null;
416
- };
417
- display: {
418
- description: string | null;
419
- benefits: string[];
420
- creditsAmount: number | null;
421
- validity: string | null;
422
- creditBenefits: SpaceCommerceProductCreditBenefit[];
423
- };
424
- isDefaultPlan: boolean;
425
- };
426
- type SpaceCommerceProductBenefitBinding = {
427
- id: string | null;
428
- productKey: string;
429
- benefitKey: string;
430
- createdAt: string | null;
431
- };
432
- type SpaceCommerceBuyerProfile = {
433
- displayName: string;
434
- avatarUrl: string | null;
435
- };
436
- type SpaceCommerceOrder = {
437
- id: string;
438
- productKeySnapshot: string;
439
- productNameSnapshot: string;
440
- status: string;
441
- amountSnapshot: number;
442
- paidAmountSnapshot: number;
443
- createdAt: string;
444
- paidAt: string | null;
445
- buyerProfile: SpaceCommerceBuyerProfile | null;
446
- };
447
- type BillingSubscriptionSummary = {
448
- id: string;
449
- productKey: string | null;
450
- productName: string | null;
451
- status: string;
452
- currentPeriodStart: string | null;
453
- currentPeriodEnd: string | null;
454
- cancelAtPeriodEnd: boolean;
455
- };
456
- type BillingPaymentStatus = {
457
- available: boolean;
458
- reason: string | null;
459
- };
460
- type BillingCatalog = {
461
- userId: string;
462
- billing: BillingPluginStatus;
463
- payment: BillingPaymentStatus;
464
- products: BillingCatalogProduct[];
465
- plans: BillingCatalogProduct[];
466
- addons: BillingCatalogProduct[];
467
- currentSubscriptions: BillingSubscriptionSummary[];
468
- hasActiveSubscription: boolean;
469
- defaultPlanProductKey: string | null;
470
- };
471
- type BillingHistoryPagination = {
472
- hasMore: boolean;
473
- nextPage: number | null;
474
- };
475
- type BillingCheckoutActionState = {
476
- canPay: boolean;
477
- checkoutUrl: string | null;
478
- checkoutUsable: boolean;
479
- canCancelCheckout: boolean;
480
- canCancelAutoRenew: boolean;
481
- unavailableReason: string | null;
482
- };
483
- type BillingSubscriptionHistoryStatus = {
484
- id: string;
485
- externalUserId: string;
486
- productKey: string;
487
- productName: string;
488
- status: string;
489
- amountMinor: number;
490
- amountUsd: number;
491
- paidAmountMinor: number;
492
- paidAmountUsd: number;
493
- currency: string;
494
- billingPeriod: string;
495
- billingIntervalCount: number;
496
- currentPeriodStart: string | null;
497
- currentPeriodEnd: string | null;
498
- cancelAtPeriodEnd: boolean;
499
- canceledAt: string | null;
500
- checkoutExpiresAt: string | null;
501
- checkoutCanceledAt: string | null;
502
- checkoutExpiredAt: string | null;
503
- paymentConflictedAt: string | null;
504
- endedAt: string | null;
505
- createdAt: string;
506
- updatedAt: string;
507
- providerStatus: string | null;
508
- providerTerminal: boolean;
509
- checkoutStatus: string | null;
510
- actions: BillingCheckoutActionState;
511
- };
512
- type BillingSubscriptionHistoryList = {
513
- userId: string;
514
- billing: BillingPluginStatus;
515
- page: number;
516
- limit: number;
517
- items: BillingSubscriptionHistoryStatus[];
518
- pagination: BillingHistoryPagination;
519
- };
520
- type BillingCheckoutResult = {
521
- userId: string;
522
- billing: BillingPluginStatus;
523
- payment: BillingPaymentStatus;
524
- productKey: string;
525
- checkoutUrl: string | null;
526
- checkoutUsable: boolean;
527
- message: string | null;
528
- orderId: string | null;
529
- subscriptionId: string | null;
530
- reused: boolean;
531
- };
532
- type BillingRedemptionResult = {
533
- userId: string;
534
- billing: BillingPluginStatus;
535
- redeemed: boolean;
536
- message: string | null;
537
- redemptionRecordId: string | null;
538
- itemCount: number;
539
- };
540
- type BillingConversionIntent = {
541
- level: "soft" | "hard";
542
- reason: "negative_balance" | "negative_balance_limit_exceeded" | "feature_not_entitled";
543
- audience: "free" | "paid" | "unknown";
544
- preferredOfferKind: "plan" | "upgrade" | "addon" | "mixed";
545
- title: string;
546
- message: string;
547
- primaryAction: {
548
- label: string;
549
- action: "open_billing_conversion";
550
- };
551
- source: string;
552
- };
553
- type BillingAccessWarning = {
554
- status: "allowed_with_debt";
555
- balanceState: "negative";
556
- netUsd: number;
557
- hardNegativeLimitUsd: number;
558
- conversion: BillingConversionIntent;
559
- };
560
- type BillingBalanceActivityKind = "grant" | "usage" | "refund" | "expire" | "revoke" | "adjust";
561
- type BillingBalanceActivityStatus = "covered" | "overage" | "partial" | null;
562
- type BillingBalanceActivity = {
563
- id: string;
564
- kind: BillingBalanceActivityKind;
565
- tokenType: string;
566
- title: string;
567
- description: string | null;
568
- sourceType: string | null;
569
- sourceId: string | null;
570
- operationId: string | null;
571
- amountUsd: number;
572
- status: BillingBalanceActivityStatus;
573
- createdAt: string;
574
- };
575
- type BillingBalanceActivityList = {
576
- userId: string;
577
- billing: BillingPluginStatus;
578
- tokenType: string;
579
- unit: BillingCreditUnit;
580
- page: number;
581
- limit: number;
582
- items: BillingBalanceActivity[];
583
- pagination: BillingHistoryPagination;
584
- };
585
- type UserRulesResponse = {
586
- content: string;
587
- updatedAt: string | null;
588
- source: "config-space";
589
- path: string;
590
- };
591
- type SpaceFsEntry = {
592
- name: string;
593
- path: string;
594
- type: "file" | "dir" | "symlink";
595
- size: number;
596
- mimeType: string | null;
597
- mtimeMs: number;
598
- };
599
- type SpaceFsTreeResponse = {
600
- path: string;
601
- entries: SpaceFsEntry[];
602
- };
603
- type SpaceFsFileKind = "text" | "binary";
604
- type SpaceFsEncoding = "utf-8" | "base64";
605
- type SpaceFsFileResponse = {
606
- path: string;
607
- name: string;
608
- size: number;
609
- mimeType: string | null;
610
- mtimeMs: number;
611
- kind: SpaceFsFileKind;
612
- encoding: SpaceFsEncoding;
613
- content: string;
614
- delivery?: "inline" | "url";
615
- url?: string;
616
- };
617
- type SpaceFsReadFilesInput = {
618
- paths: string[];
619
- };
620
- type SpaceFsReadFilesError = {
621
- path: string;
622
- code: string;
623
- message: string;
624
- status: number;
625
- };
626
- type SpaceFsPreparingFile = {
627
- path: string;
628
- name: string;
629
- size: number;
630
- mimeType: string | null;
631
- mtimeMs: number;
632
- retryAfterMs: number;
633
- };
634
- type SpaceFsReadFilesResponse = {
635
- files: SpaceFsFileResponse[];
636
- preparing?: SpaceFsPreparingFile[];
637
- errors: SpaceFsReadFilesError[];
638
- };
639
- type SpaceFsWriteFileInput = {
640
- path: string;
641
- content: string;
642
- encoding: SpaceFsEncoding;
643
- };
644
- type SpaceFsMoveInput = {
645
- fromPath: string;
646
- toPath: string;
647
- };
648
- type SpaceFsUploadEntry = {
649
- path: string;
650
- name: string;
651
- size: number;
652
- mimeType: string | null;
653
- mtimeMs: number;
654
- };
655
- type SpaceFsUploadError = {
656
- name: string;
657
- code: "file_too_large" | "name_invalid" | "path_invalid" | "write_failed" | "object_missing";
658
- message: string;
659
- };
660
- type SpaceFsUploadResponse = {
661
- uploaded: SpaceFsUploadEntry[];
662
- errors: SpaceFsUploadError[];
663
- };
664
- type SpaceFsUploadPlanEntryInput = {
665
- id: string;
666
- name: string;
667
- relativePath: string;
668
- size: number;
669
- mimeType?: string | null;
670
- lastModified?: number;
671
- };
672
- type SpaceFsUploadDestination = {
673
- kind: "workspace";
674
- targetDir?: string;
675
- } | {
676
- kind: "sandbox_tmp";
677
- sessionId: string;
678
- };
679
- type SpaceFsCreateUploadInput = {
680
- destination: SpaceFsUploadDestination;
681
- entries: SpaceFsUploadPlanEntryInput[];
682
- };
683
- type SpaceFsUploadPlanEntry = {
684
- id: string;
685
- objectKey: string;
686
- uploadUrl: string;
687
- headers?: Record<string, string>;
688
- };
689
- type SpaceFsCreateUploadResponse = {
690
- uploadId: string;
691
- expiresAt: string;
692
- entries: SpaceFsUploadPlanEntry[];
693
- };
694
- type SpaceFsCompleteUploadInput = {
695
- entries: Array<{
696
- id: string;
697
- etag?: string | null;
698
- }>;
699
- };
700
- type SpaceFsCompleteUploadResponse = {
701
- ok: true;
702
- uploaded: SpaceFsUploadEntry[];
703
- };
704
- type SpaceFsUploadProgress = {
705
- phase: "queued" | "importing" | "done" | "failed";
706
- totalFiles: number;
707
- importedFiles: number;
708
- totalBytes: number;
709
- importedBytes: number;
710
- currentPath?: string;
711
- errors: SpaceFsUploadError[];
712
- };
713
- type SessionBindingRecord = SessionBindingRecord$1;
714
- type SessionRecord = SessionRecord$1 & {
715
- bindings?: SessionBindingRecord[];
716
- totalMessages?: number;
717
- totalToolCalls?: number;
718
- totalInputTokens?: number;
719
- totalOutputTokens?: number;
720
- totalCost?: string | number | null;
721
- };
722
- type JsonPrimitive = string | number | boolean | null;
723
- type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
724
- type JsonObject = {
725
- [key: string]: JsonValue;
726
- };
727
- type SpaceSandboxAutoDestroyPolicy = {
728
- mode: "idle";
729
- ttlSeconds: number;
730
- } | {
731
- mode: "never";
732
- };
733
- type SpaceSandboxProvider = "cloud" | "local";
734
- type SandboxSpecId = "standard" | "boost" | "ultra";
735
- type SpaceSandboxConfig = {
736
- provider?: SpaceSandboxProvider;
737
- autoDestroy: SpaceSandboxAutoDestroyPolicy;
738
- spec?: SandboxSpecId;
739
- appliedSpec?: SandboxSpecId | null;
740
- specPendingRestart?: boolean;
741
- allowedSpec?: SandboxSpecId;
742
- specs?: Record<string, unknown>;
743
- };
744
- type SpaceConfig = {
745
- sandbox?: SpaceSandboxConfig;
746
- };
747
- type SpacePublicProfile = {
748
- avatarUrl: string | null;
749
- };
750
- type SpaceMeta = JsonObject & {
751
- config?: SpaceConfig;
752
- extraEnv?: SpaceEnvInput[];
753
- publicProfile?: Partial<SpacePublicProfile> | null;
754
- };
755
- type SpaceRecord = {
756
- id: string;
757
- userUuid: string;
758
- name: string | null;
759
- slug: string | null;
760
- description: string | null;
761
- storageRepoName?: string | null;
762
- baseCheckpointId?: string | null;
763
- headCheckpointId?: string | null;
764
- title: string | null;
765
- status: string | null;
766
- meta: SpaceMeta | null;
767
- publicProfile?: SpacePublicProfile;
768
- createdAt: string;
769
- updatedAt: string;
770
- lastActivityAt?: string | null;
771
- channels?: {
772
- id: string;
773
- name: string | null;
774
- provider: string;
775
- status: string;
776
- }[];
777
- access?: SpaceAccess;
778
- accessLevel?: "minimal";
779
- ownerProfile?: Pick<UserProfile, "userUuid" | "username" | "displayName" | "avatarUrl"> | null;
780
- };
781
- type SpaceBootstrapSource = {
782
- type: "blank";
783
- } | {
784
- type: "git_repo";
785
- repoUrl?: string;
786
- ref?: string | null;
787
- } | {
788
- type: "checkpoint";
789
- checkpointId: string;
790
- };
791
- type SpaceConfigInput = {
792
- sandbox?: {
793
- provider?: SpaceSandboxProvider;
794
- autoDestroy?: SpaceSandboxAutoDestroyPolicy;
795
- spec?: SandboxSpecId;
796
- };
797
- };
798
- type CreateSpaceModInput = {
799
- modSpaceId: string;
800
- name?: string | null;
801
- mountSlug?: string | null;
802
- enabled?: boolean;
803
- };
804
- type CreateSpaceInput = {
805
- name?: string;
806
- slug?: string | null;
807
- description?: string | null;
808
- source?: string;
809
- extraEnv?: SpaceEnvInput[];
810
- channelBindings?: SpaceChannelBindingInput[];
811
- mods?: CreateSpaceModInput[];
812
- bootstrapSource?: SpaceBootstrapSource;
813
- config?: SpaceConfigInput;
814
- };
815
- type SpaceConfigResponse = {
816
- config: Required<Pick<SpaceConfig, "sandbox">>;
817
- };
818
- type SpaceConfigUpdateResponse = {
819
- space: SpaceRecord;
820
- sandbox?: {
821
- resized?: boolean;
822
- applying?: boolean;
823
- pendingRestart?: boolean;
824
- appliedSpec?: SandboxSpecId;
825
- skipped?: boolean;
826
- message?: string;
827
- };
828
- };
829
- type CanvasDocumentRecord = {
830
- id: string;
831
- spaceId: string;
832
- filePath: string;
833
- title: string;
834
- version: number;
835
- meta?: Record<string, unknown> | null;
836
- createdAt: string | null;
837
- updatedAt: string | null;
838
- deletedAt?: string | null;
839
- };
840
- type CanvasNodeRecord = {
841
- documentId: string;
842
- nodeId: string;
843
- type: string;
844
- parentId?: string | null;
845
- orderKey?: string | null;
846
- x: number;
847
- y: number;
848
- width: number;
849
- height: number;
850
- rotation: number;
851
- refKind?: string | null;
852
- refPath?: string | null;
853
- refUrl?: string | null;
854
- view: Record<string, unknown>;
855
- style: Record<string, unknown>;
856
- animation: Record<string, unknown>;
857
- data: Record<string, unknown>;
858
- version: number;
859
- createdAt: string | null;
860
- updatedAt: string | null;
861
- deletedAt?: string | null;
862
- };
863
- type CanvasNodeInput = Omit<CanvasNodeRecord, "documentId" | "version" | "createdAt" | "updatedAt" | "deletedAt">;
864
- type CanvasSemanticOp = {
865
- opId?: string;
866
- type: "node.create" | "node.patch" | "node.delete";
867
- payload: Record<string, unknown>;
868
- inverse?: Record<string, unknown>;
869
- };
870
- type CanvasTransactionInput = {
871
- txId: string;
872
- baseVersion?: number | null;
873
- clientId?: string | null;
874
- undoGroupId?: string | null;
875
- ops: CanvasSemanticOp[];
876
- };
877
- type CanvasCreateInput = {
878
- path: string;
879
- title?: string;
880
- nodes?: CanvasNodeInput[];
881
- };
882
- type CanvasBootstrapResponse = {
883
- document: CanvasDocumentRecord;
884
- nodes: CanvasNodeRecord[];
885
- };
886
- type SpaceCreateResponse = {
887
- space: SpaceRecord;
888
- taskRunId: string;
889
- };
890
- type SpaceDefaultResponse = {
891
- space: SpaceRecord | null;
892
- };
893
- type SpaceListItem = SpaceRecord;
894
- type SessionMessagesResponse = {
895
- session: SessionRecord;
896
- messages: MessageRecord[];
897
- };
898
- type SessionMessageResponse = {
899
- session: SessionRecord;
900
- message: MessageRecord;
901
- };
902
- type SessionMessagesPaginatedResponse = {
903
- session: SessionRecord;
904
- messages: MessageRecord[];
905
- hasMore: boolean;
906
- nextCursor: number | undefined;
907
- };
908
- type SessionTurnsPaginatedResponse = {
909
- session: SessionRecord;
910
- turns: SessionTurnRecord[];
911
- hasMore: boolean;
912
- nextCursor: number | undefined;
913
- };
914
- type SessionTurnIndexResponse = {
915
- session: SessionRecord;
916
- turns: SessionTurnIndexItem[];
917
- hasMore: boolean;
918
- nextCursor: number | undefined;
919
- };
920
- type SessionTurnWindowResponse = {
921
- session: SessionRecord;
922
- turns: SessionTurnRecord[];
923
- hasMoreOlder: boolean;
924
- hasMoreNewer: boolean;
925
- oldestCursor: number | undefined;
926
- newestCursor: number | undefined;
927
- anchorSequence: number | undefined;
928
- };
929
- type SessionTurnResponse = {
930
- session: SessionRecord;
931
- turn: SessionTurnRecord;
932
- billing?: BillingAccessWarning | null;
933
- };
934
- type SessionTurnSignedUrlsResponse = {
935
- urls: Record<string, string>;
936
- };
937
- type SessionTurnStreamSnapshotResponse = {
938
- snapshot: {
939
- version: 2;
940
- spaceId: string;
941
- sessionId: string;
942
- turnId: string | null;
943
- anchorUserMessageId: string | null;
944
- seq: number;
945
- current: {
946
- messageId: string | null;
947
- messageOrdinal: number | null;
948
- content: ContentBlock[];
949
- appendPath: string | null;
950
- };
951
- intermediateMessages: Array<{
952
- messageId: string | null;
953
- messageOrdinal: number | null;
954
- content: ContentBlock[];
955
- id?: string;
956
- sessionId?: string;
957
- role?: "user" | "assistant" | "system";
958
- text?: string | null;
959
- provider?: string | null;
960
- model?: string | null;
961
- stopReason?: string | null;
962
- errorMessage?: string | null;
963
- usage?: Usage | null;
964
- toolCallsObjectKey?: string | null;
965
- meta?: Record<string, unknown> | null;
966
- createdAt?: string;
967
- }>;
968
- lifecycle?: {
969
- phase: "llm_call_started";
970
- llmRound: number;
971
- provider: string | null;
972
- model: string | null;
973
- at: string;
974
- } | null;
975
- updatedAt: number;
976
- } | null;
977
- };
978
- type ModelCatalogEntry = {
979
- provider: string;
980
- id: string;
981
- model: Record<string, unknown>;
982
- };
983
- type PromptTemplateCatalogEntry = {
984
- name: string;
985
- description: string;
986
- argumentHint?: string;
987
- category?: string;
988
- scope: "platform" | "mod" | "user" | "project";
989
- };
990
- type PromptTemplateCatalogResponse = {
991
- prompts: PromptTemplateCatalogEntry[];
992
- };
993
- type Channel = {
994
- id: string;
995
- userUuid: string;
996
- provider: string;
997
- name: string;
998
- status: string;
999
- createdAt: string;
1000
- updatedAt: string;
1001
- boundSpace: {
1002
- id: string;
1003
- title: string | null;
1004
- status: string;
1005
- } | null;
1006
- };
1007
- type SpaceEnvInput = {
1008
- name: string;
1009
- value: string;
1010
- };
1011
- type SpaceChannelBindingInput = {
1012
- channelId: string;
1013
- config?: ChannelConfig | null;
1014
- };
1015
- type GlobalSearchType = "turn" | "session" | "space" | "label";
1016
- type GlobalSearchResult = {
1017
- type: GlobalSearchType;
1018
- id: string;
1019
- spaceId: string;
1020
- sessionId: string | null;
1021
- turnId: string | null;
1022
- sequence: number | null;
1023
- title: string;
1024
- excerpt?: string | null;
1025
- spaceName?: string | null;
1026
- sessionTitle?: string | null;
1027
- ownerProfile?: Pick<UserProfile, "userUuid" | "username" | "displayName" | "avatarUrl"> | null;
1028
- spaceProfile?: SpacePublicProfile | null;
1029
- matchedField: "userText" | "title" | "name" | "description" | "labelName" | "labelItemContent";
1030
- href: string;
1031
- score: number;
1032
- textScore: number;
1033
- recencyScore: number;
1034
- typePriorityScore: number;
1035
- membershipPriorityScore?: number;
1036
- labelRef?: string | null;
1037
- labelName?: string | null;
1038
- labelResourceType?: LabelResourceType | null;
1039
- labelResourceRef?: string | null;
1040
- updatedAt: string | null;
1041
- source: "remote";
1042
- };
1043
- type GlobalSearchResponse = {
1044
- items: GlobalSearchResult[];
1045
- query: string;
1046
- source: "remote";
1047
- degraded?: boolean;
1048
- };
1049
- type CreateSpaceSessionInput = {
1050
- title?: string | null;
1051
- source?: string | null;
1052
- labelRefs?: string[];
1053
- };
1054
- type SpaceSessionsResponse = {
1055
- sessions: SessionRecord[];
1056
- forks?: Array<SessionForkRecord & {
1057
- firstUserTextAfterFork?: string | null;
1058
- parentTitle?: string | null;
1059
- }>;
1060
- pageInfo?: {
1061
- hasMore: boolean;
1062
- nextCursor: string | null;
1063
- };
1064
- };
1065
- type PromptAccessMode = "read_only" | "full_access";
1066
- type CreateSpacePromptInput = {
1067
- sessionId?: string | null;
1068
- title?: string | null;
1069
- source?: string | null;
1070
- content: ContentBlock[];
1071
- model?: string | null;
1072
- provider?: string | null;
1073
- clientMessageId?: string | null;
1074
- generationPolicy?: GenerationPolicy | null;
1075
- intent?: "followup" | "steer" | "compact" | null;
1076
- accessMode?: PromptAccessMode | null;
1077
- env?: Record<string, string> | null;
1078
- labelRefs?: string[];
1079
- schedule?: {
1080
- mode?: "immediate";
1081
- } | {
1082
- mode: "delay";
1083
- delayMs: number;
1084
- } | {
1085
- mode: "at";
1086
- sendAt: string;
1087
- } | {
1088
- mode: "repeat";
1089
- cronExpression: string;
1090
- timezone: string;
1091
- };
1092
- };
1093
- type CreateSpacePromptResponse = (SessionTurnResponse & {
1094
- mode: "immediate";
1095
- }) | {
1096
- mode: "delay" | "at";
1097
- taskRunId: string;
1098
- scheduledAt: string;
1099
- sessionId: string | null;
1100
- } | {
1101
- mode: "repeat";
1102
- cronJobId: string;
1103
- nextRunAt: string;
1104
- timezone: string;
1105
- sessionId: string | null;
1106
- };
1107
- type CronJobPayload = Record<string, unknown>;
1108
- type SendMessageCronJobPayload = CronJobPayload & {
1109
- content: ContentBlock[];
1110
- clientMessageId?: string;
1111
- generationPolicy?: unknown;
1112
- intent?: "followup" | "steer" | string;
1113
- accessMode?: "read_only" | "full_access";
1114
- env?: Record<string, string> | null;
1115
- source?: string;
1116
- sessionId?: string;
1117
- title?: string;
1118
- model?: string;
1119
- provider?: string;
1120
- labelIds?: string[];
1121
- };
1122
- type CronJobUpdatePatch<TPayload extends CronJobPayload = CronJobPayload> = {
1123
- title?: string;
1124
- payload?: TPayload;
1125
- cronExpression?: string;
1126
- timezone?: string;
1127
- enabled?: boolean;
1128
- };
1129
- type CursorPageInfo = {
1130
- hasMore: boolean;
1131
- nextCursor: string | null;
1132
- };
1133
- type CronJobRecord<TPayload extends CronJobPayload = CronJobPayload> = {
1134
- id: string;
1135
- userUuid: string;
1136
- userProfile?: UserProfile;
1137
- title: string;
1138
- taskType: string;
1139
- payload: TPayload;
1140
- cronExpression: string;
1141
- timezone: string;
1142
- bullJobKey: string;
1143
- spaceId: string | null;
1144
- sessionId: string | null;
1145
- enabled: boolean;
1146
- createdAt: string;
1147
- updatedAt: string;
1148
- };
1149
- type TaskRunDetailResponse = {
1150
- run: TaskRunRecord;
1151
- progress: unknown;
1152
- };
1153
- type TaskRunRecord = {
1154
- id: string;
1155
- jobId: string;
1156
- cronJobId: string | null;
1157
- taskType: string;
1158
- status: "pending" | "running" | "completed" | "failed";
1159
- payload: unknown;
1160
- result: unknown;
1161
- errorMessage: string | null;
1162
- attemptCount: number;
1163
- spaceId: string | null;
1164
- sessionId: string | null;
1165
- turnId: string | null;
1166
- userUuid: string | null;
1167
- userProfile?: UserProfile;
1168
- scheduledAt: string | null;
1169
- startedAt: string | null;
1170
- finishedAt: string | null;
1171
- createdAt: string;
1172
- updatedAt: string;
1173
- };
1174
- type CheckpointRecord = {
1175
- id: string;
1176
- spaceId: string;
1177
- commitHash: string;
1178
- description: string;
1179
- parentCheckpointId: string | null;
1180
- rootCheckpointId?: string | null;
1181
- forkCount: number;
1182
- saveVersion?: number;
1183
- meta?: Record<string, unknown> | null;
1184
- createdAt: string;
1185
- };
1186
- type SpaceCheckpointDetailResponse = {
1187
- checkpoint: CheckpointRecord;
1188
- };
1189
- type SpaceRole = "host" | "builder" | "guest";
1190
- type SpaceMember = {
1191
- userId: string;
1192
- role: SpaceRole;
1193
- profile: UserProfile;
1194
- createdAt: string;
1195
- updatedAt: string;
1196
- };
1197
- type LabelScopeType = "space" | "user" | "org";
1198
- type LabelSource = "user" | "system";
1199
- type LabelResourceType = "session" | "checkpoint" | "file";
1200
- type LabelRecord = {
1201
- id: string;
1202
- scopeType: LabelScopeType;
1203
- scopeId: string;
1204
- name: string;
1205
- slug: string;
1206
- parentId: string | null;
1207
- depth: number;
1208
- source: LabelSource;
1209
- systemKey: string | null;
1210
- rank: number;
1211
- createdBy: string | null;
1212
- createdAt: string | null;
1213
- updatedAt: string | null;
1214
- };
1215
- type LabelListItem = LabelRecord & {
1216
- children?: LabelListItem[];
1217
- };
1218
- type LabelAssignmentRecord = {
1219
- id: string;
1220
- labelId: string;
1221
- scopeType: LabelScopeType;
1222
- scopeId: string;
1223
- resourceType: LabelResourceType;
1224
- resourceRef: string;
1225
- rank: number | null;
1226
- source: LabelSource;
1227
- createdBy: string | null;
1228
- meta: Record<string, unknown> | null;
1229
- createdAt: string | null;
1230
- updatedAt: string | null;
1231
- };
1232
- type LabelAssignmentListItem = LabelAssignmentRecord & {
1233
- href: string;
1234
- resource: {
1235
- title: string;
1236
- subtitle: string | null;
1237
- status: string | null;
1238
- } | null;
1239
- };
1240
- type LabelAssignmentPageInfo = {
1241
- hasMore: boolean;
1242
- nextCursor: string | null;
1243
- };
1244
- type PatchResourceLabelsInput = {
1245
- addLabelRefs?: string[];
1246
- removeLabelRefs?: string[];
1247
- };
1248
- type ResourceLabelsResponse = {
1249
- labels: LabelListItem[];
1250
- assignments: LabelAssignmentRecord[];
1251
- };
1252
- type PatchResourceLabelsResponse = ResourceLabelsResponse & {
1253
- changed: boolean;
1254
- };
1255
- type SpaceModListItem = {
1256
- id: string;
1257
- spaceId: string;
1258
- modSpaceId: string;
1259
- name: string | null;
1260
- mountSlug: string;
1261
- mountPath: string;
1262
- enabled: boolean;
1263
- sortOrder: number;
1264
- createdBy: string;
1265
- createdAt: string | null;
1266
- updatedAt: string | null;
1267
- modSpaceName: string | null;
1268
- modSpaceDescription: string | null;
1269
- };
1270
- /**
1271
- * Public-safe DTO for Explore spaces.
1272
- * Only contains fields safe for unauthenticated product rendering.
1273
- */
1274
- type ExploreSpaceItem = {
1275
- id: string;
1276
- slug: string | null;
1277
- title: string;
1278
- summary: string | null;
1279
- spaceUrl: string;
1280
- avatarUrl: string | null;
1281
- avatarAlt: string | null;
1282
- ownerDisplayName: string | null;
1283
- ownerAvatarUrl: string | null;
1284
- category: string | null;
1285
- tags: string[];
1286
- saveCount: number;
1287
- pinCount: number;
1288
- forkCount: number;
1289
- updatedAt: string | null;
1290
- accessLabel: "public" | "sign-in-required" | "unknown";
1291
- latestSaveLabel: string | null;
1292
- };
1293
- type ExploreSection = {
1294
- key: string;
1295
- title: string | null;
1296
- subtitle: string | null;
1297
- description: string | null;
1298
- spaces: ExploreSpaceItem[];
1299
- };
1300
- type ExploreSpacesResponse = {
1301
- sections: ExploreSection[];
1302
- spaces: ExploreSpaceItem[];
1303
- };
1304
- type Permission = "space.view" | "space.edit" | "space.label.view" | "space.label.manage" | "space.label.assign" | "session.view" | "session.edit" | "session.prompt.readonly" | "session.prompt.fullaccess" | "generation.create" | "file.view" | "file.view.filtered" | "file.edit" | "checkpoint.view" | "checkpoint.edit" | "member.view" | "member.manage" | "channel.view" | "channel.manage" | "cronjob.view" | "cronjob.manage" | "taskrun.view" | "sandbox.view" | "sandbox.manage" | "mod.view" | "mod.manage" | "user.space.list" | "user.session.list" | "user.usage.read";
1305
- type SpaceAccess = {
1306
- role: SpaceRole | null;
1307
- permissions: Permission[];
1308
- };
1309
- type SpaceAccessPolicy = {
1310
- signed_in_user: SpaceRole | null;
1311
- anonymous_user: SpaceRole | null;
1312
- };
1313
- type SpaceUsageHourlyStat = {
1314
- bucketStartAt: string;
1315
- totalTokens: number;
1316
- inputTokens: number;
1317
- outputTokens: number;
1318
- cacheReadTokens: number;
1319
- cacheWriteTokens: number;
1320
- costInput: number;
1321
- costOutput: number;
1322
- costCacheRead: number;
1323
- costCacheWrite: number;
1324
- costTotal: number;
1325
- requestCount: number;
1326
- successCount: number;
1327
- errorCount: number;
1328
- models: string[];
1329
- };
1330
- type SpaceUsageSummary = {
1331
- totalTokens: number;
1332
- inputTokens: number;
1333
- outputTokens: number;
1334
- cacheReadTokens: number;
1335
- cacheWriteTokens: number;
1336
- costInput: number;
1337
- costOutput: number;
1338
- costCacheRead: number;
1339
- costCacheWrite: number;
1340
- costTotal: number;
1341
- requestCount: number;
1342
- successCount: number;
1343
- errorCount: number;
1344
- };
1345
- type SpaceUsageResponse = {
1346
- hourly: SpaceUsageHourlyStat[];
1347
- summary: SpaceUsageSummary;
1348
- days: number;
1349
- };
1350
- type SpaceInvitation = {
1351
- token: string;
1352
- role: SpaceRole;
1353
- status: "active" | "revoked" | "exhausted";
1354
- useCount: number;
1355
- maxUses: number | null;
1356
- createdAt: string | null;
1357
- expiresInSeconds: number | null;
1358
- };
1359
- type CreateInvitationInput = {
1360
- role?: SpaceRole;
1361
- ttlSeconds?: number;
1362
- maxUses?: number;
1363
- };
1364
- type CreateInvitationResponse = {
1365
- token: string;
1366
- role: SpaceRole;
1367
- expiresAt: string;
1368
- maxUses: number | null;
1369
- };
1370
- type InvitationDetail = {
1371
- token: string;
1372
- spaceId: string;
1373
- spaceName: string;
1374
- role: SpaceRole;
1375
- expiresInSeconds: number | null;
1376
- };
1377
- type AcceptInvitationResponse = {
1378
- ok: true;
1379
- spaceId: string;
1380
- spaceName: string;
1381
- role: SpaceRole;
1382
- };
1383
- type ReferenceResourceType = "space" | "session" | "checkpoint" | "user" | "file" | "tool";
1384
- /**
1385
- * Resource types usable as a query `source`. Only these have an owning space to
1386
- * authorize against; user/file/tool appear only as reference targets.
1387
- */
1388
- type ReferenceQueryableType = "space" | "session" | "checkpoint";
1389
- type ReferenceKind = "session_fork" | "space_fork" | "checkpoint_fork" | "mention" | "tool_call" | "mod" | "participant";
1390
- type ReferenceDirection = "out" | "in" | "both";
1391
- type ReferenceRecord = {
1392
- kind: ReferenceKind;
1393
- sourceType: ReferenceResourceType;
1394
- sourceId: string;
1395
- sourceTurnId: string | null;
1396
- targetType: ReferenceResourceType;
1397
- targetId: string;
1398
- spaceId: string;
1399
- sessionId: string | null;
1400
- count: number;
1401
- createdAt: string;
1402
- updatedAt: string;
1403
- meta: Record<string, unknown> | null;
1404
- };
1405
- type ReferenceQueryResponse = {
1406
- source: string;
1407
- direction: ReferenceDirection;
1408
- references: ReferenceRecord[];
1409
- };
1410
- type ReferenceAggregateGroupBy = "kind" | "targetType" | "sourceType" | "day";
1411
- type ReferenceAggregateGroup = {
1412
- group: string;
1413
- references: number;
1414
- total: number;
1415
- };
1416
- type ReferenceAggregateResponse = {
1417
- space: string;
1418
- groupBy: ReferenceAggregateGroupBy;
1419
- groups: ReferenceAggregateGroup[];
1420
- };
1421
- //#endregion
1422
5
  //#region src/work-runtime.d.ts
1423
6
  type WorkRuntimeContext = {
1424
7
  work: {
@@ -1481,23 +64,41 @@ declare class ParentBridgeTransport implements WorkRuntimeTransport {
1481
64
  */
1482
65
  declare class PopupBrokerTransport implements WorkRuntimeTransport {
1483
66
  private readonly brokerOrigin;
1484
- private readonly workId;
67
+ private readonly workId?;
68
+ private readonly getWorkId?;
1485
69
  constructor(config: {
1486
- brokerOrigin: string;
1487
- workId: string;
70
+ brokerOrigin: string; /** Explicit work id. When absent, {@link getWorkId} is used to resolve it. */
71
+ workId?: string;
72
+ /**
73
+ * Lazily resolves the work id at runtime (e.g. via the public
74
+ * `works.getBySlug` reverse lookup). Used in standalone deployments where
75
+ * the workId is not known at code-authoring time. The resolver is expected
76
+ * to cache its own result.
77
+ */
78
+ getWorkId?: () => Promise<string | null>;
1488
79
  });
80
+ private resolveWorkId;
1489
81
  request<T>(message: Record<string, unknown>, options?: WorkRuntimeRequestOptions): Promise<T | null>;
1490
82
  }
1491
83
  declare class WorkRuntimeApi {
1492
84
  private token;
1493
85
  private readonly transport;
1494
- private readonly tokenStorageKey;
1495
- private readonly scopesStorageKey;
86
+ private tokenStorageKey;
87
+ private scopesStorageKey;
88
+ private readonly workIdResolver?;
89
+ /** Ensures storage keys are resolved (via slug lookup) at most once. */
90
+ private storageKeysReady;
1496
91
  /** Scopes previously granted via requestAuthorization, retained so token
1497
92
  * refreshes can re-authorize (preserving viewerScopes) instead of falling
1498
93
  * back to a base session token that only carries workScopes. */
1499
94
  private authorizedScopes;
1500
- constructor(transport?: WorkRuntimeTransport, workId?: string);
95
+ constructor(transport?: WorkRuntimeTransport, workId?: string, workIdResolver?: WorkIdResolver);
96
+ /**
97
+ * Resolves the localStorage keys once the workId is known. When the workId is
98
+ * only available via slug reverse lookup, this performs the lookup on first
99
+ * use and then restores any cached token/scopes for that workId.
100
+ */
101
+ private ensureStorageKeys;
1501
102
  private readStoredToken;
1502
103
  private writeStoredToken;
1503
104
  private readStoredScopes;
@@ -1528,16 +129,40 @@ declare class WorkRuntimeApi {
1528
129
  */
1529
130
  type WorkRuntimeModeConfig = {
1530
131
  /** Explicit mode selection. When omitted, auto-detection is used. */mode?: "bridge" | "broker"; /** Cohub origin for the broker page (e.g. "https://cohub.run"). */
1531
- brokerOrigin?: string; /** The work's public id. Required for broker mode. */
132
+ brokerOrigin?: string;
133
+ /**
134
+ * The work's public id. Required for broker mode unless the slug triple
135
+ * below is supplied, in which case the id is resolved at runtime.
136
+ */
1532
137
  workId?: string;
1533
- };
138
+ /** Space owner's username. Used with {@link spaceSlug} + {@link workSlug} to
139
+ * resolve the workId at runtime via the public `works.getBySlug` API. */
140
+ ownerUsername?: string; /** Space slug. Part of the slug triple used for runtime workId resolution. */
141
+ spaceSlug?: string; /** Work slug. Part of the slug triple used for runtime workId resolution. */
142
+ workSlug?: string;
143
+ };
144
+ /** Lazily resolves a work's public id, e.g. via slug reverse lookup. */
145
+ type WorkIdResolver = () => Promise<string | null>;
146
+ /**
147
+ * Builds a memoized workId resolver that reverse-looks-up the workId from the
148
+ * public slug triple via `GET /api/works/by-slug/:username/:spaceSlug/:workSlug`.
149
+ * The endpoint is anonymous (no auth) for public works, so no token is needed.
150
+ * The result is cached; a failed lookup is not cached so it can be retried.
151
+ */
152
+ declare function createSlugWorkIdResolver(deps: {
153
+ apiBaseUrl: string;
154
+ fetch?: typeof globalThis.fetch;
155
+ ownerUsername: string;
156
+ spaceSlug: string;
157
+ workSlug: string;
158
+ }): WorkIdResolver;
1534
159
  /**
1535
160
  * Resolves the appropriate transport based on the work mode configuration.
1536
161
  * Auto-detection: inside an iframe → bridge; standalone with broker config →
1537
162
  * broker; otherwise → bridge (returns null for non-work contexts).
1538
163
  */
1539
- declare function resolveWorkTransport(config?: WorkRuntimeModeConfig): WorkRuntimeTransport;
1540
- declare const createWorkRuntime: (transport?: WorkRuntimeTransport, workId?: string) => WorkRuntimeApi;
164
+ declare function resolveWorkTransport(config?: WorkRuntimeModeConfig, workIdResolver?: WorkIdResolver): WorkRuntimeTransport;
165
+ declare const createWorkRuntime: (transport?: WorkRuntimeTransport, workId?: string, workIdResolver?: WorkIdResolver) => WorkRuntimeApi;
1541
166
  //#endregion
1542
167
  //#region src/transport.d.ts
1543
168
  type Fetch = typeof globalThis.fetch;
@@ -2036,6 +661,10 @@ declare class SpaceFilesApi {
2036
661
  constructor(transport: HttpTransport, spaceId: string);
2037
662
  list(path?: string, customFetch?: Fetch): Promise<SpaceFsTreeResponse>;
2038
663
  read(path: string, customFetch?: Fetch): Promise<SpaceFsFileResponse | SpaceFsPreparingFile>;
664
+ /** Pending workspace changes vs the space head checkpoint. */
665
+ diff(customFetch?: Fetch): Promise<SpacePendingDiffSummary>;
666
+ /** Per-file pending workspace diff vs the space head checkpoint. */
667
+ diffFile(path: string, customFetch?: Fetch): Promise<SpacePendingDiffFileResponse>;
2039
668
  readMany(paths: string[], customFetch?: Fetch): Promise<SpaceFsReadFilesResponse>;
2040
669
  /**
2041
670
  * Build a direct download URL. For private files, prefer `download()` so the
@@ -2237,6 +866,7 @@ type SpaceChannelBindingRecord = {
2237
866
  createdAt: string;
2238
867
  updatedAt: string;
2239
868
  } | null;
869
+ health?: ChannelHealth | null;
2240
870
  };
2241
871
  declare class SpaceChannelsApi {
2242
872
  private readonly transport;
@@ -2360,10 +990,7 @@ declare class SpaceLabelsApi {
2360
990
  listItems(labelRef: string, input?: {
2361
991
  limit?: number;
2362
992
  cursor?: string | null;
2363
- }): Promise<{
2364
- items: LabelAssignmentListItem[];
2365
- pageInfo: LabelAssignmentPageInfo;
2366
- }>;
993
+ }): Promise<LabelItemsResponse>;
2367
994
  attach(labelRef: string, input: {
2368
995
  resourceType: LabelResourceType;
2369
996
  resourceRef: string;
@@ -2491,11 +1118,24 @@ declare class SpaceCheckpointFilesApi {
2491
1118
  list(path?: string, customFetch?: Fetch): Promise<SpaceFsTreeResponse>;
2492
1119
  read(path: string, customFetch?: Fetch): Promise<SpaceFsFileResponse>;
2493
1120
  }
1121
+ declare class SpaceCheckpointDiffApi {
1122
+ private readonly transport;
1123
+ private readonly spaceId;
1124
+ private readonly checkpointId;
1125
+ constructor(transport: HttpTransport, spaceId: string, checkpointId: string);
1126
+ summary(options?: {
1127
+ base?: string | null;
1128
+ }, customFetch?: Fetch): Promise<CheckpointDiffSummary>;
1129
+ file(path: string, options?: {
1130
+ base?: string | null;
1131
+ }, customFetch?: Fetch): Promise<CheckpointDiffFileResponse>;
1132
+ }
2494
1133
  declare class SpaceCheckpointApi {
2495
1134
  private readonly transport;
2496
1135
  private readonly spaceId;
2497
1136
  readonly id: string;
2498
1137
  readonly files: SpaceCheckpointFilesApi;
1138
+ readonly diff: SpaceCheckpointDiffApi;
2499
1139
  constructor(transport: HttpTransport, spaceId: string, id: string);
2500
1140
  get(customFetch?: Fetch): Promise<SpaceCheckpointDetailResponse>;
2501
1141
  }
@@ -2854,4 +1494,4 @@ declare class CohubHttpClient {
2854
1494
  }
2855
1495
  declare const createHttpClient: (options?: CohubClientOptions) => CohubHttpClient;
2856
1496
  //#endregion
2857
- export { parseAssistantMessageCommit as $, normalizeGenerationPolicy as $i, PatchResourceLabelsInput as $n, SpaceFsEncoding as $r, BillingCreditStatus as $t, TasksApi as A, SpaceSessionsResponse as Ai, CronJobRecord as An, SpaceAccessPolicy as Ar, WorkRuntimeCheckoutState as At, GenerationStreamCommitEvent as B, GenerationTaskResult as Bi, JsonObject as Bn, SpaceCommerceProductBenefitBinding as Br, BatchUserProfilesResponse as Bt, WorkStatus as C, SpacePresenceUser as Ci, CreateInvitationResponse as Cn, SessionTurnIndexResponse as Cr, Fetch as Ct, WorkVisibility as D, SpaceSandboxAutoDestroyPolicy as Di, CreateSpacePromptResponse as Dn, SessionTurnWindowResponse as Dr, ParentBridgeTransport as Dt, WorkVersionRecord as E, SpaceRole as Ei, CreateSpacePromptInput as En, SessionTurnStreamSnapshotResponse as Er, RawHttpResponse as Et, SpaceEventName as F, TaskRunRecord as Fi, ExploreSpacesResponse as Fn, SpaceCommerceBuyerProfile as Fr, WorkRuntimeTransport as Ft, GenerationStreamLifecycleEvent as G, GenerationPolicy as Gi, LabelAssignmentRecord as Gn, SpaceConfigUpdateResponse as Gr, BillingBalanceActivityStatus as Gt, GenerationStreamEvent as H, PublicGenerationDeclaration as Hi, JsonValue as Hn, SpaceConfig as Hr, BillingBalanceActivity as Ht, SpacesApi as I, UserProfile as Ii, GlobalSearchResponse as In, SpaceCommerceCreditsBenefit as Ir, createWorkRuntime as It, GenerationStreamSubscribeOptions as J, decodeGenerationPolicy as Ji, LabelResourceType as Jn, SpaceEnvInput as Jr, BillingCheckoutActionState as Jt, GenerationStreamOutOfSyncEvent as K, GenerationPolicyError as Ki, LabelListItem as Kn, SpaceCreateResponse as Kr, BillingCatalog as Kt, WebSocketConnectionState as L, UserRulesResponse as Li, GlobalSearchResult as Ln, SpaceCommerceFeatureBenefit as Lr, resolveWorkTransport as Lt, SessionSubscriptionHandlers as M, SpaceUsageResponse as Mi, CursorPageInfo as Mn, SpaceChannelBindingInput as Mr, WorkRuntimeContext as Mt, SpaceChannelBindingRecord as N, SpaceUsageSummary as Ni, ExploreSection as Nn, SpaceCheckpointDetailResponse as Nr, WorkRuntimeModeConfig as Nt, WorksApi as O, SpaceSandboxConfig as Oi, CreateSpaceSessionInput as On, SessionTurnsPaginatedResponse as Or, PopupBrokerTransport as Ot, SpaceClient as P, TaskRunDetailResponse as Pi, ExploreSpaceItem as Pn, SpaceCommerceBenefit as Pr, WorkRuntimeRequestOptions as Pt, createSessionGenerationStreamClient as Q, getAllowedGenerationModelIds as Qi, ModelCatalogEntry as Qn, SpaceFsCreateUploadResponse as Qr, BillingCreditGrantStatus as Qt, PublicInviteApi as R, CreateGenerationTaskRequest as Ri, GlobalSearchType as Rn, SpaceCommerceOrder as Rr, AcceptInvitationResponse as Rt, WorkSessionResponse as S, SpacePresenceSnapshot as Si, CreateInvitationInput as Sn, SessionRecord as Sr, CohubClientOptions as St, WorkUpdateInput as T, SpaceRecord as Ti, CreateSpaceModInput as Tn, SessionTurnSignedUrlsResponse as Tr, HttpTransport as Tt, GenerationStreamFinalizedEvent as U, GenerationModelPolicy as Ui, LabelAssignmentListItem as Un, SpaceConfigInput as Ur, BillingBalanceActivityKind as Ut, GenerationStreamErrorEvent as V, ListGenerationModelsResponse as Vi, JsonPrimitive as Vn, SpaceCommerceProductCreditBenefit as Vr, BillingAccessWarning as Vt, GenerationStreamIntermediateMessage as W, GenerationParameterConstraint as Wi, LabelAssignmentPageInfo as Wn, SpaceConfigResponse as Wr, BillingBalanceActivityList as Wt, GenerationStreamTurnUpdatedEvent as X, filterGenerationDeclarationsByPolicy as Xi, LabelSource as Xn, SpaceFsCompleteUploadResponse as Xr, BillingConversionIntent as Xt, GenerationStreamSubscriptionHandlers as Y, encodeGenerationPolicy as Yi, LabelScopeType as Yn, SpaceFsCompleteUploadInput as Yr, BillingCheckoutResult as Yt, SessionGenerationStreamClient as Z, findGenerationModelPolicy as Zi, MeResponse as Zn, SpaceFsCreateUploadInput as Zr, BillingCreditExpiryGroup as Zt, WorkPresentationMeta as _, SpaceInvitation as _i, CanvasNodeRecord as _n, SendMessageCronJobPayload as _r, PromptsApi as _t, WorkCommerceCreditConsumeResponse as a, SpaceFsReadFilesError as ai, BillingProductCreditBenefit as an, PublicUserProfile as ar, createSessionPatchReducer as at, WorkRecord as b, SpaceMeta as bi, Channel as bn, SessionMessagesPaginatedResponse as br, CronJobsApi as bt, WorkCommerceEntitlementsResponse as c, SpaceFsTreeResponse as ci, BillingProductPricing as cn, ReferenceAggregateResponse as cr, ReferencesApi as ct, WorkCommercePurchaseResponse as d, SpaceFsUploadError as di, BillingSubscriptionHistoryStatus as dn, ReferenceQueryResponse as dr, CreatePublicAssetUploadResponse as dt, parseGenerationPolicyFromEnv as ea, SpaceFsEntry as ei, BillingCreditUnit as en, PatchResourceLabelsResponse as er, SessionPatchApplyInput as et, WorkAuthorizeResponse as f, SpaceFsUploadPlanEntry as fi, BillingSubscriptionSummary as fn, ReferenceQueryableType as fr, PublicAssetMimeType as ft, WorkMeta as g, SpaceFsWriteFileInput as gi, CanvasNodeInput as gn, SandboxSpecId as gr, UploadPublicAssetInput as gt, WorkGetResponse as h, SpaceFsUploadResponse as hi, CanvasDocumentRecord as hn, ResourceLabelsResponse as hr, UploadChatImageAttachmentInput as ht, WorkCommerceCheckoutStatus as i, SpaceFsPreparingFile as ii, BillingProductBillingInterval as in, PromptTemplateCatalogResponse as ir, SessionPatchStatus as it, SessionEventName as j, SpaceUsageHourlyStat as ji, CronJobUpdatePatch as jn, SpaceBootstrapSource as jr, WorkRuntimeCheckoutStatus as jt, UserApi as k, SpaceSandboxProvider as ki, CronJobPayload as kn, SpaceAccess as kr, WorkRuntimeApi as kt, WorkCommerceOrder as l, SpaceFsUploadDestination as li, BillingRedemptionResult as ln, ReferenceDirection as lr, SearchApi as lt, WorkDetailResponse as m, SpaceFsUploadProgress as mi, CanvasCreateInput as mn, ReferenceResourceType as mr, PublicAssetsApi as mt, createHttpClient as n, ChannelConfig as na, SpaceFsFileResponse as ni, BillingPaymentStatus as nn, PromptAccessMode as nr, SessionPatchReducer as nt, WorkCommerceCreditConsumeStatus as o, SpaceFsReadFilesInput as oi, BillingProductDisplay as on, ReferenceAggregateGroup as or, SessionAccessApi as ot, WorkCreateInput as p, SpaceFsUploadPlanEntryInput as pi, CanvasBootstrapResponse as pn, ReferenceRecord as pr, PublicAssetPurpose as pt, GenerationStreamStateEvent as q, assertGenerationRequestAllowedByPolicy as qi, LabelRecord as qn, SpaceDefaultResponse as qr, BillingCatalogProduct as qt, WorkCommerceApi as r, DiscordChannelConfig as ra, SpaceFsMoveInput as ri, BillingPluginStatus as rn, PromptTemplateCatalogEntry as rr, SessionPatchState as rt, WorkCommerceEntitlement as s, SpaceFsReadFilesResponse as si, BillingProductKind as sn, ReferenceAggregateGroupBy as sr, ReferenceResourceSelector as st, CohubHttpClient as t, GenerationContentBlock as ta, SpaceFsFileKind as ti, BillingHistoryPagination as tn, Permission as tr, SessionPatchApplyResult as tt, WorkCommerceProductResolveResponse as u, SpaceFsUploadEntry as ui, BillingSubscriptionHistoryList as un, ReferenceKind as ur, CreatePublicAssetUploadInput as ut, WorkPublicOwnerRecord as v, SpaceListItem as vi, CanvasSemanticOp as vn, SessionBindingRecord as vr, ModelsApi as vt, WorkTargetType as w, SpacePublicProfile as wi, CreateSpaceInput as wn, SessionTurnResponse as wr, HttpError as wt, WorkResolveResponse as x, SpaceModListItem as xi, CheckpointRecord as xn, SessionMessagesResponse as xr, ChannelsApi as xt, WorkPublicSpaceRecord as y, SpaceMember as yi, CanvasTransactionInput as yn, SessionMessageResponse as yr, GenerationsApi as yt, AssistantMessageCommit as z, CreateGenerationTaskResponse as zi, InvitationDetail as zn, SpaceCommerceProduct as zr, ApiError as zt };
1497
+ export { parseAssistantMessageCommit as $, TasksApi as A, WorkRuntimeApi as At, GenerationStreamCommitEvent as B, WorkStatus as C, Fetch as Ct, WorkVisibility as D, ParentBridgeTransport as Dt, WorkVersionRecord as E, RawHttpResponse as Et, SpaceEventName as F, WorkRuntimeRequestOptions as Ft, GenerationStreamLifecycleEvent as G, GenerationStreamEvent as H, SpacesApi as I, WorkRuntimeTransport as It, GenerationStreamSubscribeOptions as J, GenerationStreamOutOfSyncEvent as K, WebSocketConnectionState as L, createSlugWorkIdResolver as Lt, SessionSubscriptionHandlers as M, WorkRuntimeCheckoutStatus as Mt, SpaceChannelBindingRecord as N, WorkRuntimeContext as Nt, WorksApi as O, PopupBrokerTransport as Ot, SpaceClient as P, WorkRuntimeModeConfig as Pt, createSessionGenerationStreamClient as Q, PublicInviteApi as R, createWorkRuntime as Rt, WorkSessionResponse as S, CohubClientOptions as St, WorkUpdateInput as T, HttpTransport as Tt, GenerationStreamFinalizedEvent as U, GenerationStreamErrorEvent as V, GenerationStreamIntermediateMessage as W, GenerationStreamTurnUpdatedEvent as X, GenerationStreamSubscriptionHandlers as Y, SessionGenerationStreamClient as Z, WorkPresentationMeta as _, PromptsApi as _t, WorkCommerceCreditConsumeResponse as a, createSessionPatchReducer as at, WorkRecord as b, CronJobsApi as bt, WorkCommerceEntitlementsResponse as c, ReferencesApi as ct, WorkCommercePurchaseResponse as d, CreatePublicAssetUploadResponse as dt, SessionPatchApplyInput as et, WorkAuthorizeResponse as f, PublicAssetMimeType as ft, WorkMeta as g, UploadPublicAssetInput as gt, WorkGetResponse as h, UploadChatImageAttachmentInput as ht, WorkCommerceCheckoutStatus as i, SessionPatchStatus as it, SessionEventName as j, WorkRuntimeCheckoutState as jt, UserApi as k, WorkIdResolver as kt, WorkCommerceOrder as l, SearchApi as lt, WorkDetailResponse as m, PublicAssetsApi as mt, createHttpClient as n, SessionPatchReducer as nt, WorkCommerceCreditConsumeStatus as o, SessionAccessApi as ot, WorkCreateInput as p, PublicAssetPurpose as pt, GenerationStreamStateEvent as q, WorkCommerceApi as r, SessionPatchState as rt, WorkCommerceEntitlement as s, ReferenceResourceSelector as st, CohubHttpClient as t, SessionPatchApplyResult as tt, WorkCommerceProductResolveResponse as u, CreatePublicAssetUploadInput as ut, WorkPublicOwnerRecord as v, ModelsApi as vt, WorkTargetType as w, HttpError as wt, WorkResolveResponse as x, ChannelsApi as xt, WorkPublicSpaceRecord as y, GenerationsApi as yt, AssistantMessageCommit as z, resolveWorkTransport as zt };