@neta-art/cohub 1.9.0 → 1.10.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.
Files changed (51) hide show
  1. package/README.md +6 -105
  2. package/dist/chunks/environment.js +33 -0
  3. package/dist/chunks/http.d.ts +1615 -0
  4. package/dist/chunks/http.js +1919 -0
  5. package/dist/chunks/websocket.d.ts +266 -0
  6. package/dist/chunks/websocket.js +655 -0
  7. package/dist/http.d.ts +3 -32
  8. package/dist/http.js +2 -48
  9. package/dist/index.d.ts +35 -14
  10. package/dist/index.js +105 -8
  11. package/dist/websocket.d.ts +2 -141
  12. package/dist/websocket.js +2 -628
  13. package/package.json +7 -7
  14. package/dist/apis/channels.d.ts +0 -13
  15. package/dist/apis/channels.js +0 -24
  16. package/dist/apis/cron-jobs.d.ts +0 -18
  17. package/dist/apis/cron-jobs.js +0 -25
  18. package/dist/apis/explore.d.ts +0 -9
  19. package/dist/apis/explore.js +0 -9
  20. package/dist/apis/generations.d.ts +0 -7
  21. package/dist/apis/generations.js +0 -13
  22. package/dist/apis/invitations.d.ts +0 -20
  23. package/dist/apis/invitations.js +0 -36
  24. package/dist/apis/models.d.ts +0 -10
  25. package/dist/apis/models.js +0 -13
  26. package/dist/apis/prompts.d.ts +0 -9
  27. package/dist/apis/prompts.js +0 -16
  28. package/dist/apis/search.d.ts +0 -10
  29. package/dist/apis/search.js +0 -14
  30. package/dist/apis/session-access.d.ts +0 -13
  31. package/dist/apis/session-access.js +0 -19
  32. package/dist/apis/spaces.d.ts +0 -371
  33. package/dist/apis/spaces.js +0 -766
  34. package/dist/apis/tasks.d.ts +0 -13
  35. package/dist/apis/tasks.js +0 -18
  36. package/dist/apis/user.d.ts +0 -27
  37. package/dist/apis/user.js +0 -71
  38. package/dist/client.d.ts +0 -33
  39. package/dist/client.js +0 -103
  40. package/dist/environment.d.ts +0 -22
  41. package/dist/environment.js +0 -37
  42. package/dist/realtime.d.ts +0 -2
  43. package/dist/realtime.js +0 -8
  44. package/dist/session-generation-stream.d.ts +0 -114
  45. package/dist/session-generation-stream.js +0 -514
  46. package/dist/session-patch-reducer.d.ts +0 -61
  47. package/dist/session-patch-reducer.js +0 -432
  48. package/dist/transport.d.ts +0 -40
  49. package/dist/transport.js +0 -78
  50. package/dist/types.d.ts +0 -535
  51. package/dist/types.js +0 -1
@@ -0,0 +1,1615 @@
1
+ import { a as WebsocketClientOptions, d as SessionTurnPatchEvent, l as ContentBlock, p as CohubEnvironment, r as WebsocketClient, s as WebsocketEventPayload, u as RealtimePatchOperation } from "./websocket.js";
2
+
3
+ //#region ../protocol/src/core/usage.d.ts
4
+ type Usage = {
5
+ input?: number;
6
+ output?: number;
7
+ cacheRead?: number;
8
+ cacheWrite?: number;
9
+ totalTokens?: number;
10
+ cost?: {
11
+ input?: number;
12
+ output?: number;
13
+ cacheRead?: number;
14
+ cacheWrite?: number;
15
+ total?: number;
16
+ } | null;
17
+ };
18
+ //#endregion
19
+ //#region src/transport.d.ts
20
+ type Fetch = typeof globalThis.fetch;
21
+ type RequestInitWithFetch = RequestInit & {
22
+ fetch?: Fetch;
23
+ };
24
+ type RawHttpResponse = {
25
+ response: Response;
26
+ blob(): Promise<Blob>;
27
+ arrayBuffer(): Promise<ArrayBuffer>;
28
+ text(): Promise<string>;
29
+ json(): Promise<unknown>;
30
+ };
31
+ type CohubClientOptions = {
32
+ env?: CohubEnvironment;
33
+ baseUrl?: string;
34
+ getAccessToken?: () => Promise<string | null> | string | null;
35
+ onUnauthorized?: () => Promise<void> | void;
36
+ setStoredAuthToken?: (token: string) => void;
37
+ clearStoredAuthToken?: () => void;
38
+ fetch?: Fetch;
39
+ websocket?: WebsocketClientOptions;
40
+ };
41
+ declare class HttpError extends Error {
42
+ readonly status: number;
43
+ readonly body: unknown;
44
+ constructor(message: string, status: number, body: unknown);
45
+ }
46
+ declare class HttpTransport {
47
+ private readonly baseUrl;
48
+ private readonly fetcher;
49
+ private readonly getAccessToken?;
50
+ private readonly onUnauthorized?;
51
+ constructor(options?: CohubClientOptions);
52
+ private withAuthorization;
53
+ private send;
54
+ request<T>(path: string, init?: RequestInitWithFetch): Promise<T>;
55
+ raw(path: string, init?: RequestInitWithFetch): Promise<RawHttpResponse>;
56
+ blob(path: string, init?: RequestInitWithFetch): Promise<Blob>;
57
+ }
58
+ //#endregion
59
+ //#region ../protocol/src/model/turn.d.ts
60
+ type SessionTurnStatus = "queued" | "running" | "abort_requested" | "completed" | "failed" | "interrupted" | "merged" | "cancelled";
61
+ type SessionTurnIntent = "steer" | "followup";
62
+ type SessionTurnSummary = {
63
+ text?: string | null;
64
+ finishReason?: "completed" | "failed" | "interrupted" | "merged" | "cancelled";
65
+ reason?: "steer" | "abort" | "merge" | string;
66
+ continuedByTurnId?: string | null;
67
+ interruptedByTurnId?: string | null;
68
+ mergedIntoTurnId?: string | null;
69
+ };
70
+ type SessionTurnIntermediateIndex = {
71
+ version: 1;
72
+ messagesObjectKey: string | null;
73
+ messagesSizeBytes?: number | null;
74
+ toolCallsBaseObjectKey?: string | null;
75
+ };
76
+ type SessionTurnIntermediateSummary = {
77
+ messageCount: number;
78
+ toolCallCount: number;
79
+ usage?: Usage | null;
80
+ lastMessageText?: string | null;
81
+ hasError?: boolean;
82
+ };
83
+ type SessionTurnIndexItem = {
84
+ id: string;
85
+ sessionId: string;
86
+ sourceSessionId?: string;
87
+ sourceTurnId?: string;
88
+ sequence: number;
89
+ status: SessionTurnStatus;
90
+ startedAt: string | null;
91
+ completedAt: string | null;
92
+ createdAt: string;
93
+ updatedAt: string;
94
+ userPreview: string | null;
95
+ assistantPreview: string | null;
96
+ provider: string | null;
97
+ model: string | null;
98
+ finalUsage: Usage | null;
99
+ totalUsage: Usage | null;
100
+ errorMessage: string | null;
101
+ };
102
+ type SessionTurnAuthorProfile = {
103
+ userUuid: string;
104
+ displayName: string;
105
+ avatarUrl: string | null;
106
+ };
107
+ type SessionTurnRecord = {
108
+ id: string;
109
+ sessionId: string;
110
+ sourceSessionId?: string;
111
+ sourceTurnId?: string;
112
+ userUuid: string | null;
113
+ sequence: number;
114
+ status: SessionTurnStatus;
115
+ intent: SessionTurnIntent;
116
+ userContent: ContentBlock[];
117
+ userText: string | null;
118
+ assistantContent: ContentBlock[] | null;
119
+ assistantText: string | null;
120
+ provider: string | null;
121
+ model: string | null;
122
+ stopReason: string | null;
123
+ errorMessage: string | null;
124
+ finalUsage: Usage | null;
125
+ totalUsage: Usage | null;
126
+ summary: SessionTurnSummary | null;
127
+ intermediateIndex: SessionTurnIntermediateIndex | null;
128
+ intermediateSummary: SessionTurnIntermediateSummary | null;
129
+ meta: Record<string, unknown> | null;
130
+ authorProfile?: SessionTurnAuthorProfile | null;
131
+ startedAt: string | null;
132
+ completedAt: string | null;
133
+ createdAt: string;
134
+ updatedAt: string;
135
+ };
136
+ //#endregion
137
+ //#region ../protocol/src/model/session.d.ts
138
+ type SessionForkRecord = {
139
+ id: string;
140
+ spaceId: string;
141
+ parentSessionId: string;
142
+ childSessionId: string;
143
+ rootSessionId: string;
144
+ depth: number;
145
+ anchorSourceSessionId: string;
146
+ anchorTurnId: string;
147
+ anchorSequence: number;
148
+ ancestorSessionIds: string[];
149
+ sessionPath: string[];
150
+ createdBy: string | null;
151
+ createdAt: string;
152
+ };
153
+ type SessionTurnSegmentRecord = {
154
+ id: string;
155
+ sessionId: string;
156
+ ordinal: number;
157
+ sourceSessionId: string;
158
+ fromSequence: number;
159
+ toSequence: number | null;
160
+ createdAt: string;
161
+ };
162
+ type SessionBindingRecord$1 = {
163
+ id: string;
164
+ spaceId: string;
165
+ spaceSessionId: string;
166
+ spaceChannelId: string;
167
+ provider: string;
168
+ bindingKey: string;
169
+ externalChatId: string;
170
+ status: string | null;
171
+ meta: Record<string, unknown> | null;
172
+ createdAt: string;
173
+ updatedAt: string;
174
+ lastMessageAt: string | null;
175
+ };
176
+ type SessionRecord$1 = {
177
+ id: string;
178
+ spaceId: string;
179
+ title: string | null;
180
+ source: string | null;
181
+ status: string | null;
182
+ externalSessionId: string | null;
183
+ meta: Record<string, unknown> | null;
184
+ latestMessageText: string | null;
185
+ lastMessageAt: string | null;
186
+ lastMessageId: string | null;
187
+ createdAt: string;
188
+ updatedAt: string;
189
+ };
190
+ type MessageAuthorProfile = {
191
+ userUuid: string;
192
+ displayName: string;
193
+ avatarUrl: string | null;
194
+ };
195
+ type MessageRecord = {
196
+ id: string;
197
+ sessionId: string;
198
+ role: "user" | "assistant" | "system";
199
+ content: ContentBlock[];
200
+ text: string | null;
201
+ sequence: number;
202
+ provider: string | null;
203
+ model: string | null;
204
+ stopReason: string | null;
205
+ errorMessage: string | null;
206
+ usage: Usage | null;
207
+ meta: Record<string, unknown> | null;
208
+ authorUuid?: string | null;
209
+ authorProfile?: MessageAuthorProfile | null;
210
+ createdAt: string;
211
+ };
212
+ //#endregion
213
+ //#region ../protocol/dist/gateway/types.d.ts
214
+ type DiscordChannelConfig = {
215
+ inbound?: {
216
+ requireMentionInGuild?: boolean;
217
+ };
218
+ outbound?: {
219
+ showThinking?: boolean;
220
+ showToolCalls?: boolean;
221
+ };
222
+ };
223
+ type FeishuChannelConfig = {
224
+ brand?: "feishu" | "lark";
225
+ inbound?: {
226
+ requireMentionInGroup?: boolean;
227
+ };
228
+ outbound?: {
229
+ renderMode?: "card" | "post";
230
+ showThinking?: boolean;
231
+ showToolCalls?: boolean;
232
+ };
233
+ };
234
+ type ChannelConfig = DiscordChannelConfig | FeishuChannelConfig | Record<string, unknown>;
235
+ //#endregion
236
+ //#region ../protocol/dist/generation/index.d.ts
237
+ type GenerationSource = {
238
+ type: "url";
239
+ url: string;
240
+ } | {
241
+ type: "base64";
242
+ media_type: string;
243
+ data: string;
244
+ } | {
245
+ type: "space_file";
246
+ space_id: string;
247
+ path: string;
248
+ };
249
+ type GenerationContentBlockMeta = Record<string, unknown>;
250
+ type GenerationContentBlock = {
251
+ type: "text";
252
+ text: string;
253
+ _meta?: GenerationContentBlockMeta;
254
+ } | {
255
+ type: "image";
256
+ source: GenerationSource;
257
+ _meta?: GenerationContentBlockMeta;
258
+ } | {
259
+ type: "video";
260
+ source: GenerationSource;
261
+ _meta?: GenerationContentBlockMeta;
262
+ } | {
263
+ type: "audio";
264
+ source: GenerationSource;
265
+ _meta?: GenerationContentBlockMeta;
266
+ };
267
+ type CreateGenerationRequest = {
268
+ model: string;
269
+ content: GenerationContentBlock[];
270
+ parameters?: Record<string, unknown>;
271
+ metadata?: Record<string, unknown>;
272
+ };
273
+ type GenerationStatus = "queued" | "running" | "succeeded" | "failed" | "cancelled";
274
+ type Generation = {
275
+ id: string;
276
+ status: GenerationStatus;
277
+ model: string;
278
+ input: GenerationContentBlock[];
279
+ output?: GenerationContentBlock[];
280
+ parameters?: Record<string, unknown>;
281
+ metadata?: Record<string, unknown>;
282
+ error?: {
283
+ code?: string;
284
+ message: string;
285
+ raw?: unknown;
286
+ };
287
+ created_at: string;
288
+ updated_at: string;
289
+ completed_at?: string;
290
+ };
291
+ type GenerationContentSpec = {
292
+ type: "text" | "image" | "video" | "audio";
293
+ required?: boolean;
294
+ min?: number;
295
+ max?: number;
296
+ sources?: Array<"url" | "base64" | "space_file">;
297
+ merge?: "newline" | "space" | "concat";
298
+ meta?: Record<string, unknown>;
299
+ description?: string;
300
+ };
301
+ type GenerationParameterSpec = {
302
+ type: "string";
303
+ optional?: boolean;
304
+ default?: string;
305
+ enum?: string[];
306
+ description?: string;
307
+ examples?: string[];
308
+ } | {
309
+ type: "number";
310
+ optional?: boolean;
311
+ default?: number;
312
+ min?: number;
313
+ max?: number;
314
+ description?: string;
315
+ examples?: number[];
316
+ } | {
317
+ type: "integer";
318
+ optional?: boolean;
319
+ default?: number;
320
+ min?: number;
321
+ max?: number;
322
+ description?: string;
323
+ examples?: number[];
324
+ } | {
325
+ type: "boolean";
326
+ optional?: boolean;
327
+ default?: boolean;
328
+ description?: string;
329
+ examples?: boolean[];
330
+ };
331
+ type GenerationDeclaration = {
332
+ schema: "cohub.generation.v1";
333
+ model: string;
334
+ title?: string;
335
+ description?: string;
336
+ adapter: {
337
+ type: string;
338
+ base_url: string;
339
+ api_key: string;
340
+ };
341
+ content: {
342
+ input: GenerationContentSpec[];
343
+ };
344
+ parameters?: Record<string, GenerationParameterSpec>;
345
+ examples?: Array<{
346
+ title?: string;
347
+ request: CreateGenerationRequest;
348
+ }>;
349
+ };
350
+ type PublicGenerationDeclaration = Omit<GenerationDeclaration, "adapter">;
351
+ type ListGenerationModelsResponse = {
352
+ models: PublicGenerationDeclaration[];
353
+ };
354
+ //#endregion
355
+ //#region src/types.d.ts
356
+ type ApiError = {
357
+ message: string;
358
+ };
359
+ type UserProfile = {
360
+ userUuid: string;
361
+ logtoUserId?: string;
362
+ displayName: string;
363
+ avatarUrl: string | null;
364
+ syncedAt?: string;
365
+ };
366
+ type MeResponse = {
367
+ uuid: string;
368
+ profile: UserProfile;
369
+ email: string | null;
370
+ };
371
+ type UserRulesResponse = {
372
+ content: string;
373
+ updatedAt: string | null;
374
+ source: "config-space";
375
+ path: string;
376
+ };
377
+ type SpaceFsEntry = {
378
+ name: string;
379
+ path: string;
380
+ type: "file" | "dir" | "symlink";
381
+ size: number;
382
+ mimeType: string | null;
383
+ mtimeMs: number;
384
+ };
385
+ type SpaceFsTreeResponse = {
386
+ path: string;
387
+ entries: SpaceFsEntry[];
388
+ };
389
+ type SpaceFsFileKind = "text" | "binary";
390
+ type SpaceFsEncoding = "utf-8" | "base64";
391
+ type SpaceFsFileResponse = {
392
+ path: string;
393
+ name: string;
394
+ size: number;
395
+ mimeType: string | null;
396
+ mtimeMs: number;
397
+ kind: SpaceFsFileKind;
398
+ encoding: SpaceFsEncoding;
399
+ content: string;
400
+ delivery?: "inline" | "url";
401
+ url?: string;
402
+ };
403
+ type SpaceFsReadFilesInput = {
404
+ paths: string[];
405
+ };
406
+ type SpaceFsReadFilesError = {
407
+ path: string;
408
+ code: string;
409
+ message: string;
410
+ status: number;
411
+ };
412
+ type SpaceFsPreparingFile = {
413
+ path: string;
414
+ name: string;
415
+ size: number;
416
+ mimeType: string | null;
417
+ mtimeMs: number;
418
+ retryAfterMs: number;
419
+ };
420
+ type SpaceFsReadFilesResponse = {
421
+ files: SpaceFsFileResponse[];
422
+ preparing?: SpaceFsPreparingFile[];
423
+ errors: SpaceFsReadFilesError[];
424
+ };
425
+ type SpaceFsWriteFileInput = {
426
+ path: string;
427
+ content: string;
428
+ encoding: SpaceFsEncoding;
429
+ };
430
+ type SpaceFsMoveInput = {
431
+ fromPath: string;
432
+ toPath: string;
433
+ };
434
+ type SpaceFsUploadEntry = {
435
+ path: string;
436
+ name: string;
437
+ size: number;
438
+ mimeType: string | null;
439
+ mtimeMs: number;
440
+ };
441
+ type SpaceFsUploadError = {
442
+ name: string;
443
+ code: "file_too_large" | "name_invalid" | "path_invalid" | "write_failed" | "object_missing";
444
+ message: string;
445
+ };
446
+ type SpaceFsUploadResponse = {
447
+ uploaded: SpaceFsUploadEntry[];
448
+ errors: SpaceFsUploadError[];
449
+ };
450
+ type SpaceFsUploadPlanEntryInput = {
451
+ id: string;
452
+ name: string;
453
+ relativePath: string;
454
+ size: number;
455
+ mimeType?: string | null;
456
+ lastModified?: number;
457
+ };
458
+ type SpaceFsCreateUploadInput = {
459
+ targetDir?: string;
460
+ entries: SpaceFsUploadPlanEntryInput[];
461
+ };
462
+ type SpaceFsUploadPlanEntry = {
463
+ id: string;
464
+ objectKey: string;
465
+ uploadUrl: string;
466
+ headers?: Record<string, string>;
467
+ };
468
+ type SpaceFsCreateUploadResponse = {
469
+ uploadId: string;
470
+ expiresAt: string;
471
+ entries: SpaceFsUploadPlanEntry[];
472
+ };
473
+ type SpaceFsCompleteUploadInput = {
474
+ entries: Array<{
475
+ id: string;
476
+ etag?: string | null;
477
+ }>;
478
+ };
479
+ type SpaceFsCompleteUploadResponse = {
480
+ ok: true;
481
+ taskRunId: string;
482
+ };
483
+ type SpaceFsUploadProgress = {
484
+ phase: "queued" | "importing" | "done" | "failed";
485
+ totalFiles: number;
486
+ importedFiles: number;
487
+ totalBytes: number;
488
+ importedBytes: number;
489
+ currentPath?: string;
490
+ errors: SpaceFsUploadError[];
491
+ };
492
+ type SessionBindingRecord = SessionBindingRecord$1;
493
+ type SessionRecord = SessionRecord$1 & {
494
+ bindings?: SessionBindingRecord[];
495
+ totalMessages?: number;
496
+ totalToolCalls?: number;
497
+ totalInputTokens?: number;
498
+ totalOutputTokens?: number;
499
+ totalCost?: string | number | null;
500
+ };
501
+ type SpaceGitInfo = {
502
+ giteaHost: string;
503
+ giteaUsername: string;
504
+ };
505
+ type SpaceRecord = {
506
+ id: string;
507
+ userUuid: string;
508
+ name: string | null;
509
+ description: string | null;
510
+ storageRepoName?: string | null;
511
+ baseCheckpointId?: string | null;
512
+ headCheckpointId?: string | null;
513
+ title: string | null;
514
+ status: string | null;
515
+ meta: Record<string, unknown> | null;
516
+ createdAt: string;
517
+ updatedAt: string;
518
+ channels?: {
519
+ id: string;
520
+ name: string | null;
521
+ provider: string;
522
+ status: string;
523
+ }[];
524
+ accessLevel?: "minimal";
525
+ ownerProfile?: Pick<UserProfile, "userUuid" | "displayName" | "avatarUrl"> | null;
526
+ gitInfo?: SpaceGitInfo | null;
527
+ };
528
+ type SpaceBootstrapSource = {
529
+ type: "blank";
530
+ } | {
531
+ type: "git_repo";
532
+ repoUrl?: string;
533
+ ref?: string | null;
534
+ } | {
535
+ type: "checkpoint";
536
+ checkpointId: string;
537
+ };
538
+ type SpaceCreateResponse = {
539
+ space: SpaceRecord;
540
+ taskRunId: string;
541
+ };
542
+ type SpaceListItem = SpaceRecord;
543
+ type SessionMessagesResponse = {
544
+ session: SessionRecord;
545
+ messages: MessageRecord[];
546
+ };
547
+ type SessionMessageResponse = {
548
+ session: SessionRecord;
549
+ message: MessageRecord;
550
+ };
551
+ type SessionMessagesPaginatedResponse = {
552
+ session: SessionRecord;
553
+ messages: MessageRecord[];
554
+ hasMore: boolean;
555
+ nextCursor: number | undefined;
556
+ };
557
+ type SessionTurnsPaginatedResponse = {
558
+ session: SessionRecord;
559
+ turns: SessionTurnRecord[];
560
+ hasMore: boolean;
561
+ nextCursor: number | undefined;
562
+ };
563
+ type SessionTurnIndexResponse = {
564
+ session: SessionRecord;
565
+ turns: SessionTurnIndexItem[];
566
+ hasMore: boolean;
567
+ nextCursor: number | undefined;
568
+ };
569
+ type SessionTurnWindowResponse = {
570
+ session: SessionRecord;
571
+ turns: SessionTurnRecord[];
572
+ hasMoreOlder: boolean;
573
+ hasMoreNewer: boolean;
574
+ oldestCursor: number | undefined;
575
+ newestCursor: number | undefined;
576
+ anchorSequence: number | undefined;
577
+ };
578
+ type SessionTurnResponse = {
579
+ session: SessionRecord;
580
+ turn: SessionTurnRecord;
581
+ };
582
+ type SessionTurnSignedUrlsResponse = {
583
+ urls: Record<string, string>;
584
+ };
585
+ type SessionTurnStreamSnapshotResponse = {
586
+ snapshot: {
587
+ version: 2;
588
+ spaceId: string;
589
+ sessionId: string;
590
+ turnId: string | null;
591
+ anchorUserMessageId: string | null;
592
+ seq: number;
593
+ current: {
594
+ messageId: string | null;
595
+ messageOrdinal: number | null;
596
+ content: ContentBlock[];
597
+ appendPath: string | null;
598
+ };
599
+ intermediateMessages: Array<{
600
+ messageId: string | null;
601
+ messageOrdinal: number | null;
602
+ content: ContentBlock[];
603
+ id?: string;
604
+ sessionId?: string;
605
+ role?: "user" | "assistant" | "system";
606
+ text?: string | null;
607
+ provider?: string | null;
608
+ model?: string | null;
609
+ stopReason?: string | null;
610
+ errorMessage?: string | null;
611
+ usage?: Usage | null;
612
+ toolCallsObjectKey?: string | null;
613
+ meta?: Record<string, unknown> | null;
614
+ createdAt?: string;
615
+ }>;
616
+ updatedAt: number;
617
+ } | null;
618
+ };
619
+ type ModelCatalogEntry = {
620
+ provider: string;
621
+ id: string;
622
+ model: Record<string, unknown>;
623
+ };
624
+ type PromptTemplateCatalogEntry = {
625
+ name: string;
626
+ description: string;
627
+ argumentHint?: string;
628
+ category?: string;
629
+ scope: "platform";
630
+ };
631
+ type PromptTemplateCatalogResponse = {
632
+ prompts: PromptTemplateCatalogEntry[];
633
+ };
634
+ type Channel = {
635
+ id: string;
636
+ userUuid: string;
637
+ provider: string;
638
+ name: string;
639
+ status: string;
640
+ createdAt: string;
641
+ updatedAt: string;
642
+ boundSpace: {
643
+ id: string;
644
+ title: string | null;
645
+ status: string;
646
+ } | null;
647
+ };
648
+ type SpaceEnvInput = {
649
+ name: string;
650
+ value: string;
651
+ };
652
+ type SpaceChannelBindingInput = {
653
+ channelId: string;
654
+ config?: ChannelConfig | null;
655
+ };
656
+ type GlobalSearchType = "turn" | "session" | "space";
657
+ type GlobalSearchResult = {
658
+ type: GlobalSearchType;
659
+ id: string;
660
+ spaceId: string;
661
+ sessionId: string | null;
662
+ turnId: string | null;
663
+ sequence: number | null;
664
+ title: string;
665
+ excerpt: string | null;
666
+ spaceName: string | null;
667
+ ownerProfile?: Pick<UserProfile, "userUuid" | "displayName" | "avatarUrl"> | null;
668
+ sessionTitle: string | null;
669
+ matchedField: "userText" | "title" | "name" | "description";
670
+ href: string;
671
+ score: number;
672
+ textScore: number;
673
+ recencyScore: number;
674
+ typePriorityScore: number;
675
+ membershipPriorityScore?: number;
676
+ updatedAt: string | null;
677
+ source: "remote";
678
+ };
679
+ type GlobalSearchResponse = {
680
+ items: GlobalSearchResult[];
681
+ query: string;
682
+ source: "remote";
683
+ degraded?: boolean;
684
+ };
685
+ type SpaceSessionsResponse = {
686
+ sessions: SessionRecord[];
687
+ forks?: Array<SessionForkRecord & {
688
+ firstUserTextAfterFork?: string | null;
689
+ parentTitle?: string | null;
690
+ }>;
691
+ pageInfo?: {
692
+ hasMore: boolean;
693
+ nextCursor: string | null;
694
+ };
695
+ };
696
+ type UserSshKey = {
697
+ id: string;
698
+ key: string;
699
+ title: string;
700
+ giteaKeyId: number;
701
+ createdAt: string;
702
+ };
703
+ type CreateSpacePromptInput = {
704
+ sessionId?: string | null;
705
+ title?: string | null;
706
+ content: ContentBlock[];
707
+ model?: string | null;
708
+ provider?: string | null;
709
+ clientMessageId?: string | null;
710
+ schedule?: {
711
+ mode?: "immediate";
712
+ } | {
713
+ mode: "delay";
714
+ delayMs: number;
715
+ } | {
716
+ mode: "at";
717
+ sendAt: string;
718
+ } | {
719
+ mode: "repeat";
720
+ cronExpression: string;
721
+ timezone: string;
722
+ };
723
+ };
724
+ type CreateSpacePromptResponse = {
725
+ ok: true;
726
+ mode: "immediate";
727
+ sessionId: string;
728
+ userMessageId: string;
729
+ turnId: string;
730
+ } | {
731
+ ok: true;
732
+ mode: "delay" | "at";
733
+ taskRunId: string;
734
+ scheduledAt: string;
735
+ sessionId: string | null;
736
+ } | {
737
+ ok: true;
738
+ mode: "repeat";
739
+ cronJobId: string;
740
+ nextRunAt: string;
741
+ timezone: string;
742
+ sessionId: string | null;
743
+ };
744
+ type CronJobRecord = {
745
+ id: string;
746
+ userUuid: string;
747
+ userProfile?: UserProfile;
748
+ title: string;
749
+ taskType: string;
750
+ payload: Record<string, unknown>;
751
+ cronExpression: string;
752
+ timezone: string;
753
+ bullJobKey: string;
754
+ spaceId: string | null;
755
+ sessionId: string | null;
756
+ enabled: boolean;
757
+ createdAt: string;
758
+ updatedAt: string;
759
+ };
760
+ type TaskRunDetailResponse = {
761
+ run: TaskRunRecord;
762
+ progress: unknown;
763
+ };
764
+ type TaskRunRecord = {
765
+ id: string;
766
+ jobId: string;
767
+ cronJobId: string | null;
768
+ taskType: string;
769
+ status: "pending" | "running" | "completed" | "failed";
770
+ payload: unknown;
771
+ result: unknown;
772
+ errorMessage: string | null;
773
+ attemptCount: number;
774
+ spaceId: string | null;
775
+ sessionId: string | null;
776
+ userUuid: string | null;
777
+ scheduledAt: string | null;
778
+ startedAt: string | null;
779
+ finishedAt: string | null;
780
+ createdAt: string;
781
+ updatedAt: string;
782
+ };
783
+ type CheckpointRecord = {
784
+ id: string;
785
+ spaceId: string;
786
+ commitHash: string;
787
+ description: string;
788
+ parentCheckpointId: string | null;
789
+ forkCount: number;
790
+ meta: Record<string, unknown> | null;
791
+ createdAt: string;
792
+ };
793
+ type SpaceCheckpointDetailResponse = {
794
+ checkpoint: CheckpointRecord;
795
+ };
796
+ type SpaceRole = "host" | "builder" | "guest";
797
+ type SpaceMember = {
798
+ userId: string;
799
+ role: SpaceRole;
800
+ profile: UserProfile;
801
+ createdAt: string;
802
+ updatedAt: string;
803
+ };
804
+ type SpaceMarkKind = "pin";
805
+ type SpaceMarkResourceType = "session" | "checkpoint" | "file";
806
+ type SpaceMarkRecord = {
807
+ id: string;
808
+ spaceId: string;
809
+ kind: SpaceMarkKind;
810
+ resourceType: SpaceMarkResourceType;
811
+ resourceRef: string;
812
+ label: string | null;
813
+ rank: number;
814
+ createdBy: string;
815
+ createdAt: string;
816
+ updatedAt: string;
817
+ };
818
+ type SpaceMarkListItem = SpaceMarkRecord & {
819
+ href: string;
820
+ resource: {
821
+ title: string;
822
+ subtitle: string | null;
823
+ status: string | null;
824
+ } | null;
825
+ };
826
+ type ExploreSpaceItem = {
827
+ space: SpaceRecord;
828
+ accessAudience: "anonymous" | "signed_in";
829
+ explore: {
830
+ rank: number;
831
+ category: string | null;
832
+ label: string | null;
833
+ };
834
+ latestCheckpoints: CheckpointRecord[];
835
+ stats: {
836
+ pinnedCount: number;
837
+ checkpointCount: number;
838
+ forkCount: number;
839
+ };
840
+ sandboxStatus: string | null;
841
+ };
842
+ type SpaceAccessPolicy = {
843
+ signed_in_user: SpaceRole | null;
844
+ anonymous_user: SpaceRole | null;
845
+ };
846
+ type SpaceUsageHourlyStat = {
847
+ bucketStartAt: string;
848
+ totalTokens: number;
849
+ inputTokens: number;
850
+ outputTokens: number;
851
+ cacheReadTokens: number;
852
+ cacheWriteTokens: number;
853
+ costInput: number;
854
+ costOutput: number;
855
+ costCacheRead: number;
856
+ costCacheWrite: number;
857
+ costTotal: number;
858
+ requestCount: number;
859
+ successCount: number;
860
+ errorCount: number;
861
+ models: string[];
862
+ };
863
+ type SpaceUsageSummary = {
864
+ totalTokens: number;
865
+ inputTokens: number;
866
+ outputTokens: number;
867
+ cacheReadTokens: number;
868
+ cacheWriteTokens: number;
869
+ costInput: number;
870
+ costOutput: number;
871
+ costCacheRead: number;
872
+ costCacheWrite: number;
873
+ costTotal: number;
874
+ requestCount: number;
875
+ successCount: number;
876
+ errorCount: number;
877
+ };
878
+ type SpaceUsageResponse = {
879
+ hourly: SpaceUsageHourlyStat[];
880
+ summary: SpaceUsageSummary;
881
+ days: number;
882
+ };
883
+ type SpaceInvitation = {
884
+ token: string;
885
+ role: SpaceRole;
886
+ status: "active" | "revoked" | "exhausted";
887
+ useCount: number;
888
+ maxUses: number | null;
889
+ createdAt: string | null;
890
+ expiresInSeconds: number | null;
891
+ };
892
+ type CreateInvitationInput = {
893
+ role?: SpaceRole;
894
+ ttlSeconds?: number;
895
+ maxUses?: number;
896
+ };
897
+ type CreateInvitationResponse = {
898
+ token: string;
899
+ role: SpaceRole;
900
+ expiresAt: string;
901
+ maxUses: number | null;
902
+ };
903
+ type InvitationDetail = {
904
+ token: string;
905
+ spaceId: string;
906
+ spaceName: string;
907
+ role: SpaceRole;
908
+ expiresInSeconds: number | null;
909
+ };
910
+ type AcceptInvitationResponse = {
911
+ ok: true;
912
+ spaceId: string;
913
+ spaceName: string;
914
+ role: SpaceRole;
915
+ };
916
+ //#endregion
917
+ //#region src/apis/channels.d.ts
918
+ declare class ChannelsApi {
919
+ private readonly transport;
920
+ constructor(transport: HttpTransport);
921
+ list(customFetch?: Fetch): Promise<Channel[]>;
922
+ create(data: {
923
+ provider: string;
924
+ name: string;
925
+ credentials: Record<string, unknown>;
926
+ }): Promise<unknown>;
927
+ delete(id: string): Promise<unknown>;
928
+ }
929
+ //#endregion
930
+ //#region src/apis/cron-jobs.d.ts
931
+ declare class CronJobsApi {
932
+ private readonly transport;
933
+ constructor(transport: HttpTransport);
934
+ list(spaceId?: string): Promise<{
935
+ jobs: CronJobRecord[];
936
+ }>;
937
+ delete(id: string): Promise<{
938
+ ok: true;
939
+ }>;
940
+ toggle(id: string, enabled: boolean): Promise<{
941
+ ok: true;
942
+ }>;
943
+ runs(cronJobId: string): Promise<{
944
+ runs: TaskRunRecord[];
945
+ }>;
946
+ }
947
+ //#endregion
948
+ //#region src/apis/generations.d.ts
949
+ declare class GenerationsApi {
950
+ private readonly transport;
951
+ constructor(transport: HttpTransport);
952
+ create(request: CreateGenerationRequest): Promise<Generation>;
953
+ }
954
+ //#endregion
955
+ //#region src/apis/models.d.ts
956
+ type ModelsCatalog = Record<string, ModelCatalogEntry[]>;
957
+ declare class ModelsApi {
958
+ private readonly transport;
959
+ constructor(transport: HttpTransport);
960
+ list(): Promise<ModelsCatalog>;
961
+ listMultimodal(): Promise<ListGenerationModelsResponse>;
962
+ }
963
+ //#endregion
964
+ //#region src/apis/prompts.d.ts
965
+ declare class PromptsApi {
966
+ private readonly transport;
967
+ constructor(transport: HttpTransport);
968
+ list(options?: {
969
+ spaceId?: string;
970
+ }, customFetch?: Fetch): Promise<PromptTemplateCatalogResponse>;
971
+ }
972
+ //#endregion
973
+ //#region src/apis/search.d.ts
974
+ declare class SearchApi {
975
+ private readonly transport;
976
+ constructor(transport: HttpTransport);
977
+ query(input: {
978
+ q: string;
979
+ limit?: number;
980
+ types?: GlobalSearchType[];
981
+ spaceId?: string;
982
+ }, customFetch?: Fetch): Promise<GlobalSearchResponse>;
983
+ }
984
+ //#endregion
985
+ //#region src/apis/session-access.d.ts
986
+ declare class SessionAccessApi {
987
+ private readonly transport;
988
+ constructor(transport: HttpTransport);
989
+ get(sessionId: string): Promise<SpaceAccessPolicy>;
990
+ set(sessionId: string, body: {
991
+ anonymous_user?: SpaceRole | null;
992
+ }): Promise<SpaceAccessPolicy>;
993
+ remove(sessionId: string): Promise<{
994
+ ok: true;
995
+ }>;
996
+ }
997
+ //#endregion
998
+ //#region ../protocol/src/ports/index.d.ts
999
+ type SpacePortStatus = "listening" | "closed";
1000
+ type SpacePublicEndpoint = {
1001
+ url: string;
1002
+ status?: SpacePortStatus | "unknown";
1003
+ observedAt?: number;
1004
+ };
1005
+ type SpacePublicEndpoints = Record<string, SpacePublicEndpoint>;
1006
+ //#endregion
1007
+ //#region src/session-patch-reducer.d.ts
1008
+ type SessionPatchStatus = "idle" | "pending" | "streaming" | "completed" | "failed" | "interrupted";
1009
+ type SessionPatchState = {
1010
+ spaceId: string | null;
1011
+ sessionId: string;
1012
+ status: SessionPatchStatus;
1013
+ contentBlocks: ContentBlock[];
1014
+ anchorUserMessageId: string | null;
1015
+ patchSeq: number;
1016
+ turnId: string | null;
1017
+ appendPath: string | null;
1018
+ };
1019
+ type SessionPatchApplyInput = {
1020
+ spaceId?: string | null;
1021
+ sessionId: string;
1022
+ turnId?: string | null;
1023
+ seq: number;
1024
+ baseSeq: number;
1025
+ ops: RealtimePatchOperation[];
1026
+ anchorUserMessageId?: string | null;
1027
+ };
1028
+ type SessionPatchApplyResult = {
1029
+ applied: true;
1030
+ state: SessionPatchState;
1031
+ } | {
1032
+ applied: false;
1033
+ reason: "duplicate" | "version_mismatch" | "invalid";
1034
+ state: SessionPatchState;
1035
+ };
1036
+ type SessionPatchSnapshotInput = SessionPatchKeyInput & {
1037
+ turnId?: string | null;
1038
+ seq: number;
1039
+ contentBlocks: ContentBlock[];
1040
+ anchorUserMessageId?: string | null;
1041
+ appendPath?: string | null;
1042
+ };
1043
+ type SessionPatchKeyInput = {
1044
+ spaceId?: string | null;
1045
+ sessionId: string;
1046
+ turnId?: string | null;
1047
+ };
1048
+ declare class SessionPatchReducer {
1049
+ private readonly states;
1050
+ private key;
1051
+ get(input: SessionPatchKeyInput): SessionPatchState;
1052
+ start(input: SessionPatchKeyInput): SessionPatchState;
1053
+ replaceTurnId(input: SessionPatchKeyInput & {
1054
+ nextTurnId: string | null;
1055
+ }): SessionPatchState;
1056
+ complete(input: SessionPatchKeyInput): SessionPatchState;
1057
+ fail(input: SessionPatchKeyInput): SessionPatchState;
1058
+ interrupt(input: SessionPatchKeyInput): SessionPatchState;
1059
+ reset(input: SessionPatchKeyInput): void;
1060
+ applySnapshot(input: SessionPatchSnapshotInput): SessionPatchApplyResult;
1061
+ resetAll(): void;
1062
+ applyEvent(event: SessionTurnPatchEvent): SessionPatchApplyResult;
1063
+ applyPatch(input: SessionPatchApplyInput): SessionPatchApplyResult;
1064
+ }
1065
+ declare const createSessionPatchReducer: () => SessionPatchReducer;
1066
+ //#endregion
1067
+ //#region src/session-generation-stream.d.ts
1068
+ type AssistantMessageCommit = {
1069
+ kind: "intermediate";
1070
+ message: MessageRecord;
1071
+ isFinal: false;
1072
+ } | {
1073
+ kind: "final";
1074
+ message: MessageRecord;
1075
+ isFinal: true;
1076
+ } | {
1077
+ kind: "error";
1078
+ message: MessageRecord;
1079
+ isFinal: true;
1080
+ } | {
1081
+ kind: "ignored";
1082
+ message: MessageRecord;
1083
+ isFinal: false;
1084
+ };
1085
+ type GenerationStreamIntermediateMessage = {
1086
+ id?: string;
1087
+ sessionId?: string;
1088
+ role?: "user" | "assistant" | "system";
1089
+ messageId: string | null;
1090
+ messageOrdinal: number | null;
1091
+ content: ContentBlock[];
1092
+ text?: string | null;
1093
+ provider?: string | null;
1094
+ model?: string | null;
1095
+ stopReason?: string | null;
1096
+ errorMessage?: string | null;
1097
+ usage?: Usage | null;
1098
+ toolCallsObjectKey?: string | null;
1099
+ meta?: Record<string, unknown> | null;
1100
+ createdAt?: string;
1101
+ };
1102
+ type GenerationStreamStateEvent = {
1103
+ type: "state";
1104
+ source: "snapshot" | "patch" | "progress";
1105
+ state: SessionPatchState;
1106
+ messageId: string | null;
1107
+ messageOrdinal: number | null;
1108
+ intermediateMessages: GenerationStreamIntermediateMessage[];
1109
+ rawEvent: WebsocketEventPayload;
1110
+ };
1111
+ type GenerationStreamCommitEvent = {
1112
+ type: "commit";
1113
+ commit: AssistantMessageCommit;
1114
+ rawEvent: WebsocketEventPayload;
1115
+ };
1116
+ type GenerationStreamFinalizedEvent = {
1117
+ type: "finalized";
1118
+ turn: SessionTurnRecord;
1119
+ rawEvent: WebsocketEventPayload;
1120
+ };
1121
+ type GenerationStreamTurnUpdatedEvent = {
1122
+ type: "turn_updated";
1123
+ turn: Partial<SessionTurnRecord>;
1124
+ rawEvent: WebsocketEventPayload;
1125
+ };
1126
+ type GenerationStreamErrorEvent = {
1127
+ type: "error";
1128
+ message: string;
1129
+ rawEvent: WebsocketEventPayload;
1130
+ };
1131
+ type GenerationStreamOutOfSyncEvent = {
1132
+ type: "out_of_sync";
1133
+ source: "snapshot" | "patch";
1134
+ reason: "duplicate" | "version_mismatch" | "invalid";
1135
+ state: SessionPatchState;
1136
+ rawEvent: WebsocketEventPayload;
1137
+ };
1138
+ type GenerationStreamEvent = GenerationStreamStateEvent | GenerationStreamCommitEvent | GenerationStreamFinalizedEvent | GenerationStreamTurnUpdatedEvent | GenerationStreamErrorEvent | GenerationStreamOutOfSyncEvent;
1139
+ type GenerationStreamSubscriptionHandlers = {
1140
+ event?: (event: GenerationStreamEvent) => void;
1141
+ state?: (event: GenerationStreamStateEvent) => void;
1142
+ commit?: (event: GenerationStreamCommitEvent) => void;
1143
+ finalized?: (event: GenerationStreamFinalizedEvent) => void;
1144
+ turnUpdated?: (event: GenerationStreamTurnUpdatedEvent) => void;
1145
+ error?: (event: GenerationStreamErrorEvent) => void;
1146
+ outOfSync?: (event: GenerationStreamOutOfSyncEvent) => void;
1147
+ };
1148
+ declare function parseAssistantMessageCommit(message: MessageRecord): AssistantMessageCommit;
1149
+ declare class SessionGenerationStreamClient {
1150
+ private readonly websocketClient;
1151
+ private readonly spaceId;
1152
+ private readonly sessionId;
1153
+ private readonly reducer;
1154
+ private messageId;
1155
+ private messageOrdinal;
1156
+ private intermediateMessages;
1157
+ private progressState;
1158
+ constructor(websocketClient: WebsocketClient | null, spaceId: string, sessionId: string);
1159
+ subscribe(handlers: GenerationStreamSubscriptionHandlers): () => void;
1160
+ private emit;
1161
+ private resetCurrentMessage;
1162
+ private appendCurrentMessage;
1163
+ private addIntermediateMessage;
1164
+ private handleAppliedState;
1165
+ private prepareMessageBoundary;
1166
+ private handleSnapshot;
1167
+ private handlePatch;
1168
+ private handleProgress;
1169
+ private handlePersisted;
1170
+ private handleFinalized;
1171
+ private handleEvent;
1172
+ }
1173
+ declare function createSessionGenerationStreamClient(input: {
1174
+ websocketClient: WebsocketClient | null;
1175
+ spaceId: string;
1176
+ sessionId: string;
1177
+ }): SessionGenerationStreamClient;
1178
+ //#endregion
1179
+ //#region src/apis/invitations.d.ts
1180
+ declare class SpaceInvitationsApi {
1181
+ private readonly transport;
1182
+ private readonly spaceId;
1183
+ constructor(transport: HttpTransport, spaceId: string);
1184
+ list(): Promise<{
1185
+ items: SpaceInvitation[];
1186
+ }>;
1187
+ create(input?: CreateInvitationInput): Promise<CreateInvitationResponse>;
1188
+ revoke(token: string): Promise<{
1189
+ ok: true;
1190
+ }>;
1191
+ }
1192
+ declare class PublicInviteApi {
1193
+ private readonly transport;
1194
+ constructor(transport: HttpTransport);
1195
+ get(token: string): Promise<InvitationDetail>;
1196
+ accept(token: string): Promise<AcceptInvitationResponse>;
1197
+ }
1198
+ //#endregion
1199
+ //#region src/apis/spaces.d.ts
1200
+ type SessionSubscriptionHandlers = {
1201
+ patch?: (event: WebsocketEventPayload) => void;
1202
+ /**
1203
+ * @deprecated Use `session.subscribeGeneration({ state })` for normalized
1204
+ * snapshot/patch/progress generation state.
1205
+ */
1206
+ patchState?: (result: SessionPatchApplyResult) => void; /** @deprecated Use `session.subscribeGeneration({ state })`. */
1207
+ snapshot?: (event: WebsocketEventPayload) => void; /** @deprecated Legacy progress events are normalized by `subscribeGeneration`. */
1208
+ progress?: (event: WebsocketEventPayload) => void; /** @deprecated Use `session.subscribeGeneration({ commit, finalized })`. */
1209
+ final?: (event: WebsocketEventPayload) => void;
1210
+ turnUpdated?: (event: WebsocketEventPayload) => void;
1211
+ turnFinalized?: (event: WebsocketEventPayload) => void;
1212
+ error?: (event: WebsocketEventPayload) => void;
1213
+ persisted?: (event: WebsocketEventPayload) => void;
1214
+ event?: (event: WebsocketEventPayload) => void;
1215
+ };
1216
+ type SessionEventName = "turn.patch" | "turn.snapshot" | "turn.progress" | "turn.final" | "turn.updated" | "turn.error" | "message.persisted";
1217
+ type SpaceEventName = SessionEventName | "ports.changed" | "event";
1218
+ type SessionSendMessageInput = {
1219
+ content: ContentBlock[];
1220
+ model?: string;
1221
+ provider?: string;
1222
+ clientMessageId?: string;
1223
+ };
1224
+ declare class SpacesApi {
1225
+ private readonly transport;
1226
+ constructor(transport: HttpTransport);
1227
+ list(customFetch?: Fetch): Promise<SpaceRecord[]>;
1228
+ get(spaceId: string, customFetch?: Fetch): Promise<SpaceRecord>;
1229
+ create(input?: {
1230
+ name?: string;
1231
+ description?: string;
1232
+ source?: string;
1233
+ extraEnv?: SpaceEnvInput[];
1234
+ channelBindings?: SpaceChannelBindingInput[];
1235
+ bootstrapSource?: SpaceBootstrapSource;
1236
+ }, headers?: Record<string, string>): Promise<SpaceCreateResponse>;
1237
+ }
1238
+ declare class SpaceFilesApi {
1239
+ private readonly transport;
1240
+ private readonly spaceId;
1241
+ constructor(transport: HttpTransport, spaceId: string);
1242
+ list(path?: string, customFetch?: Fetch): Promise<SpaceFsTreeResponse>;
1243
+ read(path: string, customFetch?: Fetch): Promise<SpaceFsFileResponse | SpaceFsPreparingFile>;
1244
+ readMany(paths: string[], customFetch?: Fetch): Promise<SpaceFsReadFilesResponse>;
1245
+ /**
1246
+ * Build a direct download URL. For private files, prefer `download()` so the
1247
+ * SDK can attach authorization headers.
1248
+ */
1249
+ getDownloadUrl(path: string): string;
1250
+ download(path: string, customFetch?: Fetch): Promise<{
1251
+ blob: Blob;
1252
+ filename: string;
1253
+ mimeType: string;
1254
+ }>;
1255
+ write(input: SpaceFsWriteFileInput): Promise<{
1256
+ ok: true;
1257
+ path: string;
1258
+ size: number;
1259
+ mtimeMs: number;
1260
+ }>;
1261
+ createDir(path: string): Promise<{
1262
+ ok: true;
1263
+ path: string;
1264
+ size: number;
1265
+ mtimeMs: number;
1266
+ }>;
1267
+ delete(path: string, recursive?: boolean): Promise<{
1268
+ ok: true;
1269
+ path: string;
1270
+ }>;
1271
+ move(input: SpaceFsMoveInput): Promise<{
1272
+ ok: true;
1273
+ fromPath: string;
1274
+ toPath: string;
1275
+ }>;
1276
+ upload(files: File[], dir?: string): Promise<SpaceFsUploadResponse>;
1277
+ createUpload(input: SpaceFsCreateUploadInput): Promise<SpaceFsCreateUploadResponse>;
1278
+ completeUpload(uploadId: string, input: SpaceFsCompleteUploadInput): Promise<SpaceFsCompleteUploadResponse>;
1279
+ }
1280
+ declare class SessionMessagesClient {
1281
+ private readonly transport;
1282
+ private readonly sessionId;
1283
+ private lastSentSignature;
1284
+ private lastSentSessionId;
1285
+ private lastSentAt;
1286
+ constructor(transport: HttpTransport, sessionId: string);
1287
+ list(customFetch?: Fetch): Promise<SessionMessagesResponse>;
1288
+ get(messageId: string, optionsOrFetch?: {
1289
+ detail?: "summary" | "full";
1290
+ } | Fetch, customFetch?: Fetch): Promise<SessionMessageResponse>;
1291
+ listPaginated(options?: {
1292
+ cursor?: number;
1293
+ limit?: number;
1294
+ direction?: "older" | "newer";
1295
+ }, customFetch?: Fetch): Promise<SessionMessagesPaginatedResponse>;
1296
+ send(input: SessionSendMessageInput): Promise<{
1297
+ ok: true;
1298
+ userMessageId: string;
1299
+ turnId: string;
1300
+ }>;
1301
+ }
1302
+ declare class SessionTurnsClient {
1303
+ private readonly transport;
1304
+ private readonly sessionId;
1305
+ constructor(transport: HttpTransport, sessionId: string);
1306
+ listPaginated(options?: {
1307
+ cursor?: number;
1308
+ limit?: number;
1309
+ direction?: "older" | "newer";
1310
+ }, customFetch?: Fetch): Promise<SessionTurnsPaginatedResponse>;
1311
+ index(options?: {
1312
+ cursor?: number;
1313
+ limit?: number;
1314
+ }, customFetch?: Fetch): Promise<SessionTurnIndexResponse>;
1315
+ window(options: {
1316
+ sequence?: number;
1317
+ turnId?: string;
1318
+ before?: number;
1319
+ after?: number;
1320
+ }, customFetch?: Fetch): Promise<SessionTurnWindowResponse>;
1321
+ streamSnapshot(customFetch?: Fetch): Promise<SessionTurnStreamSnapshotResponse>;
1322
+ get(turnId: string, customFetch?: Fetch): Promise<SessionTurnResponse>;
1323
+ signedUrls(turnId: string, objectKeys: string[]): Promise<SessionTurnSignedUrlsResponse>;
1324
+ }
1325
+ declare class SessionRealtimeClient {
1326
+ private readonly websocketClient;
1327
+ private readonly spaceId;
1328
+ private readonly sessionId;
1329
+ private readonly patchReducer;
1330
+ constructor(websocketClient: WebsocketClient | null, spaceId: string, sessionId: string);
1331
+ subscribe(handlers: SessionSubscriptionHandlers): () => void;
1332
+ on(type: SessionEventName, handler: (event: WebsocketEventPayload) => void): () => void;
1333
+ }
1334
+ declare class SessionClient {
1335
+ readonly spaceId: string;
1336
+ readonly id: string;
1337
+ private readonly transport;
1338
+ readonly messages: SessionMessagesClient;
1339
+ readonly turns: SessionTurnsClient;
1340
+ readonly realtime: SessionRealtimeClient;
1341
+ readonly generation: SessionGenerationStreamClient;
1342
+ constructor(spaceId: string, id: string, transport: HttpTransport, websocketClient: WebsocketClient | null);
1343
+ get(customFetch?: Fetch): Promise<{
1344
+ space: SpaceRecord;
1345
+ session: SessionRecord;
1346
+ }>;
1347
+ rename(title: string | null, customFetch?: Fetch): Promise<{
1348
+ session: SessionRecord;
1349
+ }>;
1350
+ abort(optionsOrFetch?: {
1351
+ turnId?: string | null;
1352
+ } | Fetch, customFetch?: Fetch): Promise<{
1353
+ ok: true;
1354
+ }>;
1355
+ turn(turnId: string): {
1356
+ fork: (input?: {
1357
+ title?: string | null;
1358
+ }) => Promise<{
1359
+ session: SessionRecord;
1360
+ fork: SessionForkRecord;
1361
+ }>;
1362
+ };
1363
+ subscribe(handlers: SessionSubscriptionHandlers): () => void;
1364
+ subscribeGeneration(handlers: GenerationStreamSubscriptionHandlers): () => void;
1365
+ on(type: SessionEventName, handler: (event: WebsocketEventPayload) => void): () => void;
1366
+ }
1367
+ declare class SpaceSessionsApi {
1368
+ private readonly transport;
1369
+ private readonly spaceId;
1370
+ private readonly websocketClient;
1371
+ constructor(transport: HttpTransport, spaceId: string, websocketClient: WebsocketClient | null);
1372
+ create(input?: {
1373
+ title?: string;
1374
+ source?: string;
1375
+ }): Promise<{
1376
+ ok: true;
1377
+ session: SessionRecord;
1378
+ }>;
1379
+ list(optionsOrFetch?: {
1380
+ limit?: number;
1381
+ cursor?: string | null;
1382
+ includeForks?: boolean;
1383
+ } | Fetch, customFetch?: Fetch): Promise<SpaceSessionsResponse>;
1384
+ byId(sessionId: string): SessionClient;
1385
+ }
1386
+ type WebSocketConnectionState = {
1387
+ state: "connecting" | "reconnecting" | "open" | "closed" | "error";
1388
+ willReconnect: boolean;
1389
+ connectionId?: string | null;
1390
+ attempt?: number;
1391
+ delayMs?: number;
1392
+ recoverable?: boolean;
1393
+ };
1394
+ declare class SpaceMembersApi {
1395
+ private readonly transport;
1396
+ private readonly spaceId;
1397
+ constructor(transport: HttpTransport, spaceId: string);
1398
+ list(): Promise<{
1399
+ items: SpaceMember[];
1400
+ }>;
1401
+ update(userId: string, role: SpaceRole): Promise<SpaceMember>;
1402
+ remove(userId: string): Promise<{
1403
+ ok: true;
1404
+ }>;
1405
+ }
1406
+ declare class SpaceAccessApi {
1407
+ private readonly transport;
1408
+ private readonly spaceId;
1409
+ constructor(transport: HttpTransport, spaceId: string);
1410
+ get(): Promise<SpaceAccessPolicy>;
1411
+ set(body: {
1412
+ signed_in_user?: SpaceRole | null;
1413
+ anonymous_user?: SpaceRole | null;
1414
+ }): Promise<SpaceAccessPolicy>;
1415
+ }
1416
+ declare class SpaceUsageApi {
1417
+ private readonly transport;
1418
+ private readonly spaceId;
1419
+ constructor(transport: HttpTransport, spaceId: string);
1420
+ get(days?: number, customFetch?: Fetch): Promise<SpaceUsageResponse>;
1421
+ }
1422
+ type SpaceChannelBindingRecord = {
1423
+ id: string;
1424
+ spaceId: string;
1425
+ channelId: string;
1426
+ config: Record<string, unknown> | null;
1427
+ createdAt: string;
1428
+ channel: {
1429
+ id: string;
1430
+ userUuid: string;
1431
+ provider: string;
1432
+ name: string;
1433
+ status: string;
1434
+ createdAt: string;
1435
+ updatedAt: string;
1436
+ } | null;
1437
+ };
1438
+ declare class SpaceChannelsApi {
1439
+ private readonly transport;
1440
+ private readonly spaceId;
1441
+ constructor(transport: HttpTransport, spaceId: string);
1442
+ list(): Promise<SpaceChannelBindingRecord[]>;
1443
+ bind(channelId: string, config?: Record<string, unknown> | null): Promise<SpaceChannelBindingRecord>;
1444
+ unbind(channelId: string): Promise<{
1445
+ ok: true;
1446
+ }>;
1447
+ }
1448
+ declare class SpaceEnvApi {
1449
+ private readonly transport;
1450
+ private readonly spaceId;
1451
+ constructor(transport: HttpTransport, spaceId: string);
1452
+ list(): Promise<{
1453
+ env: SpaceEnvInput[];
1454
+ }>;
1455
+ create(input: SpaceEnvInput): Promise<{
1456
+ env: SpaceEnvInput[];
1457
+ }>;
1458
+ update(name: string, value: string): Promise<{
1459
+ env: SpaceEnvInput[];
1460
+ }>;
1461
+ remove(name: string): Promise<{
1462
+ env: SpaceEnvInput[];
1463
+ }>;
1464
+ }
1465
+ type SpaceSandboxRecord = {
1466
+ status: string | null;
1467
+ podName?: string | null;
1468
+ desiredImage?: string | null;
1469
+ reportedImageVersion?: string | null;
1470
+ lastHeartbeatAt?: string | null;
1471
+ reportedAt?: string | null;
1472
+ meta?: Record<string, unknown> | null;
1473
+ };
1474
+ declare class SpaceSandboxApi {
1475
+ private readonly transport;
1476
+ private readonly spaceId;
1477
+ constructor(transport: HttpTransport, spaceId: string);
1478
+ get(): Promise<{
1479
+ sandbox: SpaceSandboxRecord | null;
1480
+ }>;
1481
+ ports(): Promise<{
1482
+ endpoints: SpacePublicEndpoints;
1483
+ }>;
1484
+ recreate(): Promise<{
1485
+ ok: boolean;
1486
+ status?: string;
1487
+ verified?: boolean;
1488
+ checks?: Record<string, boolean> | null;
1489
+ message?: string;
1490
+ }>;
1491
+ }
1492
+ declare class SpaceMarksApi {
1493
+ private readonly transport;
1494
+ private readonly spaceId;
1495
+ constructor(transport: HttpTransport, spaceId: string);
1496
+ list(kind?: SpaceMarkKind): Promise<{
1497
+ marks: SpaceMarkListItem[];
1498
+ }>;
1499
+ create(input: {
1500
+ kind?: SpaceMarkKind;
1501
+ resourceType: SpaceMarkResourceType;
1502
+ resourceRef: string;
1503
+ label?: string | null;
1504
+ }): Promise<{
1505
+ mark: SpaceMarkListItem;
1506
+ }>;
1507
+ delete(markId: string): Promise<{
1508
+ ok: true;
1509
+ }>;
1510
+ }
1511
+ declare class SpaceCheckpointsApi {
1512
+ private readonly transport;
1513
+ private readonly spaceId;
1514
+ constructor(transport: HttpTransport, spaceId: string);
1515
+ create(description?: string | null): Promise<{
1516
+ ok: true;
1517
+ taskRunId: string;
1518
+ }>;
1519
+ list(): Promise<{
1520
+ checkpoints: CheckpointRecord[];
1521
+ }>;
1522
+ get(checkpointId: string, customFetch?: Fetch): Promise<SpaceCheckpointDetailResponse>;
1523
+ }
1524
+ declare class SpaceClient {
1525
+ readonly id: string;
1526
+ private readonly transport;
1527
+ private readonly websocketClient;
1528
+ readonly files: SpaceFilesApi;
1529
+ readonly sessions: SpaceSessionsApi;
1530
+ readonly members: SpaceMembersApi;
1531
+ readonly access: SpaceAccessApi;
1532
+ readonly checkpoints: SpaceCheckpointsApi;
1533
+ readonly usage: SpaceUsageApi;
1534
+ readonly channels: SpaceChannelsApi;
1535
+ readonly env: SpaceEnvApi;
1536
+ readonly sandbox: SpaceSandboxApi;
1537
+ readonly invitations: SpaceInvitationsApi;
1538
+ readonly marks: SpaceMarksApi;
1539
+ constructor(id: string, transport: HttpTransport, websocketClient: WebsocketClient | null);
1540
+ get(customFetch?: Fetch): Promise<SpaceRecord>;
1541
+ prompt(input: CreateSpacePromptInput): Promise<CreateSpacePromptResponse>;
1542
+ rename(name: string): Promise<{
1543
+ space: SpaceRecord;
1544
+ }>;
1545
+ profile(body: {
1546
+ description?: string | null;
1547
+ pictureUrl?: string | null;
1548
+ }): Promise<{
1549
+ space: SpaceRecord;
1550
+ }>;
1551
+ session(sessionId: string): SessionClient;
1552
+ subscribe(handler: (event: WebsocketEventPayload) => void): () => void;
1553
+ on(type: SpaceEventName, handler: (event: WebsocketEventPayload) => void): () => void;
1554
+ }
1555
+ //#endregion
1556
+ //#region src/apis/tasks.d.ts
1557
+ declare class TasksApi {
1558
+ private readonly transport;
1559
+ constructor(transport: HttpTransport);
1560
+ get(taskRunId: string): Promise<TaskRunDetailResponse>;
1561
+ list(filters?: {
1562
+ cronJobId?: string;
1563
+ spaceId?: string;
1564
+ }): Promise<{
1565
+ runs: TaskRunRecord[];
1566
+ }>;
1567
+ }
1568
+ //#endregion
1569
+ //#region src/apis/user.d.ts
1570
+ declare class UserApi {
1571
+ private readonly transport;
1572
+ private readonly transportBaseUrl;
1573
+ private readonly setStoredAuthToken?;
1574
+ private readonly clearStoredAuthToken?;
1575
+ constructor(transport: HttpTransport, transportBaseUrl: string, setStoredAuthToken?: ((token: string) => void) | undefined, clearStoredAuthToken?: (() => void) | undefined);
1576
+ getMe(customFetch?: Fetch): Promise<MeResponse>;
1577
+ updateProfile(input: {
1578
+ displayName?: string;
1579
+ avatarUrl?: string | null;
1580
+ }): Promise<{
1581
+ profile: UserProfile;
1582
+ }>;
1583
+ getRules(customFetch?: Fetch): Promise<UserRulesResponse>;
1584
+ setAuthToken(token: string): Promise<any>;
1585
+ clearAuthToken(): Promise<null>;
1586
+ getSshKeys(customFetch?: Fetch): Promise<UserSshKey[]>;
1587
+ createSshKey(data: {
1588
+ key: string;
1589
+ title: string;
1590
+ }): Promise<UserSshKey>;
1591
+ deleteSshKey(id: string): Promise<{
1592
+ ok: true;
1593
+ }>;
1594
+ }
1595
+ //#endregion
1596
+ //#region src/http.d.ts
1597
+ declare class CohubHttpClient {
1598
+ readonly spaces: SpacesApi;
1599
+ readonly channels: ChannelsApi;
1600
+ readonly user: UserApi;
1601
+ readonly generations: GenerationsApi;
1602
+ readonly models: ModelsApi;
1603
+ readonly prompts: PromptsApi;
1604
+ readonly sessionAccess: SessionAccessApi;
1605
+ readonly search: SearchApi;
1606
+ readonly tasks: TasksApi;
1607
+ readonly cronJobs: CronJobsApi;
1608
+ readonly invite: PublicInviteApi;
1609
+ private readonly transport;
1610
+ constructor(options?: CohubClientOptions);
1611
+ space(spaceId: string): SpaceClient;
1612
+ }
1613
+ declare const createHttpClient: (options?: CohubClientOptions) => CohubHttpClient;
1614
+ //#endregion
1615
+ export { MeResponse as $, SpaceUsageResponse as $t, SessionPatchStatus as A, SpaceFsReadFilesError as At, ApiError as B, SpaceFsWriteFileInput as Bt, SessionGenerationStreamClient as C, SpaceFsCreateUploadResponse as Ct, SessionPatchApplyResult as D, SpaceFsFileResponse as Dt, SessionPatchApplyInput as E, SpaceFsFileKind as Et, ModelsApi as F, SpaceFsUploadError as Ft, CreateSpacePromptInput as G, SpaceMarkListItem as Gt, CheckpointRecord as H, SpaceInvitation as Ht, GenerationsApi as I, SpaceFsUploadPlanEntry as It, ExploreSpaceItem as J, SpaceMember as Jt, CreateSpacePromptResponse as K, SpaceMarkRecord as Kt, CronJobsApi as L, SpaceFsUploadPlanEntryInput as Lt, SessionAccessApi as M, SpaceFsReadFilesResponse as Mt, SearchApi as N, SpaceFsTreeResponse as Nt, SessionPatchReducer as O, SpaceFsMoveInput as Ot, PromptsApi as P, SpaceFsUploadEntry as Pt, InvitationDetail as Q, SpaceUsageHourlyStat as Qt, ChannelsApi as R, SpaceFsUploadProgress as Rt, GenerationStreamTurnUpdatedEvent as S, SpaceFsCreateUploadInput as St, parseAssistantMessageCommit as T, SpaceFsEntry as Tt, CreateInvitationInput as U, SpaceListItem as Ut, Channel as V, SpaceGitInfo as Vt, CreateInvitationResponse as W, SpaceMarkKind as Wt, GlobalSearchResult as X, SpaceRole as Xt, GlobalSearchResponse as Y, SpaceRecord as Yt, GlobalSearchType as Z, SpaceSessionsResponse as Zt, GenerationStreamFinalizedEvent as _, CohubClientOptions as _n, SpaceCheckpointDetailResponse as _t, SessionEventName as a, UserSshKey as an, SessionMessagesPaginatedResponse as at, GenerationStreamStateEvent as b, HttpTransport as bn, SpaceFsCompleteUploadInput as bt, SpaceClient as c, ListGenerationModelsResponse as cn, SessionTurnIndexResponse as ct, WebSocketConnectionState as d, DiscordChannelConfig as dn, SessionTurnStreamSnapshotResponse as dt, SpaceUsageSummary as en, ModelCatalogEntry as et, PublicInviteApi as f, MessageRecord as fn, SessionTurnWindowResponse as ft, GenerationStreamEvent as g, SessionTurnRecord as gn, SpaceChannelBindingInput as gt, GenerationStreamErrorEvent as h, SessionTurnIndexItem as hn, SpaceBootstrapSource as ht, TasksApi as i, UserRulesResponse as in, SessionMessageResponse as it, createSessionPatchReducer as j, SpaceFsReadFilesInput as jt, SessionPatchState as k, SpaceFsPreparingFile as kt, SpaceEventName as l, PublicGenerationDeclaration as ln, SessionTurnResponse as lt, GenerationStreamCommitEvent as m, SessionTurnSegmentRecord as mn, SpaceAccessPolicy as mt, createHttpClient as n, TaskRunRecord as nn, PromptTemplateCatalogResponse as nt, SessionSubscriptionHandlers as o, CreateGenerationRequest as on, SessionMessagesResponse as ot, AssistantMessageCommit as p, SessionForkRecord as pn, SessionTurnsPaginatedResponse as pt, CronJobRecord as q, SpaceMarkResourceType as qt, UserApi as r, UserProfile as rn, SessionBindingRecord as rt, SpaceChannelBindingRecord as s, Generation as sn, SessionRecord as st, CohubHttpClient as t, TaskRunDetailResponse as tn, PromptTemplateCatalogEntry as tt, SpacesApi as u, ChannelConfig as un, SessionTurnSignedUrlsResponse as ut, GenerationStreamIntermediateMessage as v, Fetch as vn, SpaceCreateResponse as vt, createSessionGenerationStreamClient as w, SpaceFsEncoding as wt, GenerationStreamSubscriptionHandlers as x, RawHttpResponse as xn, SpaceFsCompleteUploadResponse as xt, GenerationStreamOutOfSyncEvent as y, HttpError as yn, SpaceEnvInput as yt, AcceptInvitationResponse as z, SpaceFsUploadResponse as zt };