@neta-art/cohub 1.17.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/http.d.ts +87 -237
- package/dist/chunks/http.js +6 -17
- package/dist/chunks/websocket.d.ts +233 -48
- package/dist/chunks/websocket.js +1 -1
- package/dist/http.d.ts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +232 -1
- package/package.json +2 -3
package/dist/chunks/http.d.ts
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import { a as WebsocketClientOptions, d as
|
|
1
|
+
import { S as CohubEnvironment, _ as SessionTurnIndexItem, a as WebsocketClientOptions, b as ContentBlock, d as SpacePublicEndpoints, f as MessageRecord, h as SessionRecord$1, l as RealtimePatchOperation, m as SessionForkRecord, p as SessionBindingRecord$1, r as WebsocketClient, s as WebsocketEventPayload, u as SessionTurnPatchEvent, v as SessionTurnRecord, y as Usage } from "./websocket.js";
|
|
2
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
3
|
//#region src/transport.d.ts
|
|
20
4
|
type Fetch = typeof globalThis.fetch;
|
|
21
5
|
type RequestInitWithFetch = RequestInit & {
|
|
@@ -58,167 +42,7 @@ declare class HttpTransport {
|
|
|
58
42
|
blob(path: string, init?: RequestInitWithFetch): Promise<Blob>;
|
|
59
43
|
}
|
|
60
44
|
//#endregion
|
|
61
|
-
//#region ../protocol/src/
|
|
62
|
-
type SessionTurnStatus = "queued" | "running" | "abort_requested" | "completed" | "failed" | "interrupted" | "merged" | "cancelled";
|
|
63
|
-
type SessionTurnIntent = "steer" | "followup";
|
|
64
|
-
type SessionTurnSummary = {
|
|
65
|
-
text?: string | null;
|
|
66
|
-
finishReason?: "completed" | "failed" | "interrupted" | "merged" | "cancelled";
|
|
67
|
-
reason?: "steer" | "abort" | "merge" | string;
|
|
68
|
-
continuedByTurnId?: string | null;
|
|
69
|
-
interruptedByTurnId?: string | null;
|
|
70
|
-
mergedIntoTurnId?: string | null;
|
|
71
|
-
};
|
|
72
|
-
type SessionTurnIntermediateIndex = {
|
|
73
|
-
version: 1;
|
|
74
|
-
messagesObjectKey: string | null;
|
|
75
|
-
messagesSizeBytes?: number | null;
|
|
76
|
-
toolCallsBaseObjectKey?: string | null;
|
|
77
|
-
};
|
|
78
|
-
type SessionTurnIntermediateSummary = {
|
|
79
|
-
messageCount: number;
|
|
80
|
-
toolCallCount: number;
|
|
81
|
-
usage?: Usage | null;
|
|
82
|
-
durationMs?: number | null;
|
|
83
|
-
lastMessageText?: string | null;
|
|
84
|
-
hasError?: boolean;
|
|
85
|
-
};
|
|
86
|
-
type SessionTurnIndexItem = {
|
|
87
|
-
id: string;
|
|
88
|
-
sessionId: string;
|
|
89
|
-
sourceSessionId?: string;
|
|
90
|
-
sourceTurnId?: string;
|
|
91
|
-
sequence: number;
|
|
92
|
-
status: SessionTurnStatus;
|
|
93
|
-
startedAt: string | null;
|
|
94
|
-
completedAt: string | null;
|
|
95
|
-
durationMs: number | null;
|
|
96
|
-
createdAt: string;
|
|
97
|
-
updatedAt: string;
|
|
98
|
-
userPreview: string | null;
|
|
99
|
-
assistantPreview: string | null;
|
|
100
|
-
provider: string | null;
|
|
101
|
-
model: string | null;
|
|
102
|
-
finalUsage: Usage | null;
|
|
103
|
-
totalUsage: Usage | null;
|
|
104
|
-
errorMessage: string | null;
|
|
105
|
-
};
|
|
106
|
-
type SessionTurnAuthorProfile = {
|
|
107
|
-
userUuid: string;
|
|
108
|
-
displayName: string;
|
|
109
|
-
avatarUrl: string | null;
|
|
110
|
-
};
|
|
111
|
-
type SessionTurnRecord = {
|
|
112
|
-
id: string;
|
|
113
|
-
sessionId: string;
|
|
114
|
-
sourceSessionId?: string;
|
|
115
|
-
sourceTurnId?: string;
|
|
116
|
-
userUuid: string | null;
|
|
117
|
-
sequence: number;
|
|
118
|
-
status: SessionTurnStatus;
|
|
119
|
-
intent: SessionTurnIntent;
|
|
120
|
-
userContent: ContentBlock[];
|
|
121
|
-
userText: string | null;
|
|
122
|
-
assistantContent: ContentBlock[] | null;
|
|
123
|
-
assistantText: string | null;
|
|
124
|
-
provider: string | null;
|
|
125
|
-
model: string | null;
|
|
126
|
-
stopReason: string | null;
|
|
127
|
-
errorMessage: string | null;
|
|
128
|
-
finalUsage: Usage | null;
|
|
129
|
-
totalUsage: Usage | null;
|
|
130
|
-
summary: SessionTurnSummary | null;
|
|
131
|
-
intermediateIndex: SessionTurnIntermediateIndex | null;
|
|
132
|
-
intermediateSummary: SessionTurnIntermediateSummary | null;
|
|
133
|
-
meta: Record<string, unknown> | null;
|
|
134
|
-
authorProfile?: SessionTurnAuthorProfile | null;
|
|
135
|
-
startedAt: string | null;
|
|
136
|
-
completedAt: string | null;
|
|
137
|
-
durationMs: number | null;
|
|
138
|
-
createdAt: string;
|
|
139
|
-
updatedAt: string;
|
|
140
|
-
};
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region ../protocol/src/model/session.d.ts
|
|
143
|
-
type SessionForkRecord = {
|
|
144
|
-
id: string;
|
|
145
|
-
spaceId: string;
|
|
146
|
-
parentSessionId: string;
|
|
147
|
-
childSessionId: string;
|
|
148
|
-
rootSessionId: string;
|
|
149
|
-
depth: number;
|
|
150
|
-
anchorSourceSessionId: string;
|
|
151
|
-
anchorTurnId: string;
|
|
152
|
-
anchorSequence: number;
|
|
153
|
-
ancestorSessionIds: string[];
|
|
154
|
-
sessionPath: string[];
|
|
155
|
-
createdBy: string | null;
|
|
156
|
-
createdAt: string;
|
|
157
|
-
};
|
|
158
|
-
type SessionTurnSegmentRecord = {
|
|
159
|
-
id: string;
|
|
160
|
-
sessionId: string;
|
|
161
|
-
ordinal: number;
|
|
162
|
-
sourceSessionId: string;
|
|
163
|
-
fromSequence: number;
|
|
164
|
-
toSequence: number | null;
|
|
165
|
-
createdAt: string;
|
|
166
|
-
};
|
|
167
|
-
type SessionBindingRecord$1 = {
|
|
168
|
-
id: string;
|
|
169
|
-
spaceId: string;
|
|
170
|
-
spaceSessionId: string;
|
|
171
|
-
spaceChannelId: string;
|
|
172
|
-
provider: string;
|
|
173
|
-
bindingKey: string;
|
|
174
|
-
externalChatId: string;
|
|
175
|
-
status: string | null;
|
|
176
|
-
meta: Record<string, unknown> | null;
|
|
177
|
-
createdAt: string;
|
|
178
|
-
updatedAt: string;
|
|
179
|
-
lastMessageAt: string | null;
|
|
180
|
-
};
|
|
181
|
-
type SessionRecord$1 = {
|
|
182
|
-
id: string;
|
|
183
|
-
spaceId: string;
|
|
184
|
-
title: string | null;
|
|
185
|
-
source: string | null;
|
|
186
|
-
status: string | null;
|
|
187
|
-
externalSessionId: string | null;
|
|
188
|
-
meta: Record<string, unknown> | null;
|
|
189
|
-
latestMessageText: string | null;
|
|
190
|
-
lastMessageAt: string | null;
|
|
191
|
-
lastMessageId: string | null;
|
|
192
|
-
createdAt: string;
|
|
193
|
-
updatedAt: string;
|
|
194
|
-
};
|
|
195
|
-
type MessageAuthorProfile = {
|
|
196
|
-
userUuid: string;
|
|
197
|
-
displayName: string;
|
|
198
|
-
avatarUrl: string | null;
|
|
199
|
-
};
|
|
200
|
-
type MessageRecord = {
|
|
201
|
-
id: string;
|
|
202
|
-
sessionId: string;
|
|
203
|
-
role: "user" | "assistant" | "system";
|
|
204
|
-
content: ContentBlock[];
|
|
205
|
-
text: string | null;
|
|
206
|
-
sequence: number;
|
|
207
|
-
provider: string | null;
|
|
208
|
-
model: string | null;
|
|
209
|
-
stopReason: string | null;
|
|
210
|
-
errorMessage: string | null;
|
|
211
|
-
usage: Usage | null;
|
|
212
|
-
meta: Record<string, unknown> | null;
|
|
213
|
-
authorUuid?: string | null;
|
|
214
|
-
authorProfile?: MessageAuthorProfile | null;
|
|
215
|
-
startedAt: string | null;
|
|
216
|
-
completedAt: string | null;
|
|
217
|
-
durationMs: number | null;
|
|
218
|
-
createdAt: string;
|
|
219
|
-
};
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region ../protocol/dist/gateway/types.d.ts
|
|
45
|
+
//#region ../protocol/src/gateway/types.d.ts
|
|
222
46
|
type DiscordChannelConfig = {
|
|
223
47
|
inbound?: {
|
|
224
48
|
requireMentionInGuild?: boolean;
|
|
@@ -336,10 +160,61 @@ type GenerateRequest = {
|
|
|
336
160
|
metadata?: Record<string, unknown>;
|
|
337
161
|
};
|
|
338
162
|
//#endregion
|
|
163
|
+
//#region ../protocol/src/generation/policy.d.ts
|
|
164
|
+
type GenerationPolicy = {
|
|
165
|
+
version: 1;
|
|
166
|
+
mode: "auto" | "limited";
|
|
167
|
+
models?: GenerationModelPolicy[];
|
|
168
|
+
};
|
|
169
|
+
type GenerationModelPolicy = {
|
|
170
|
+
model: string;
|
|
171
|
+
/**
|
|
172
|
+
* Generic constraints keyed by generation declaration parameter name.
|
|
173
|
+
* Missing parameters are not restricted by policy.
|
|
174
|
+
*/
|
|
175
|
+
parameters?: Record<string, GenerationParameterConstraint>;
|
|
176
|
+
};
|
|
177
|
+
type GenerationParameterConstraint = {
|
|
178
|
+
kind: "enum";
|
|
179
|
+
values: Array<string | number | boolean>;
|
|
180
|
+
} | {
|
|
181
|
+
kind: "number";
|
|
182
|
+
min?: number;
|
|
183
|
+
max?: number;
|
|
184
|
+
values?: number[];
|
|
185
|
+
} | {
|
|
186
|
+
kind: "integer";
|
|
187
|
+
min?: number;
|
|
188
|
+
max?: number;
|
|
189
|
+
values?: number[];
|
|
190
|
+
} | {
|
|
191
|
+
kind: "boolean";
|
|
192
|
+
value?: boolean;
|
|
193
|
+
};
|
|
194
|
+
declare class GenerationPolicyError extends Error {
|
|
195
|
+
constructor(message: string);
|
|
196
|
+
}
|
|
197
|
+
type EnvLike = Record<string, string | undefined>;
|
|
198
|
+
type PublicDeclaration = Omit<GenerationModelDeclaration, "adapter">;
|
|
199
|
+
declare function normalizeGenerationPolicy(value: unknown): GenerationPolicy | null;
|
|
200
|
+
declare function encodeGenerationPolicy(policy: GenerationPolicy): string;
|
|
201
|
+
declare function decodeGenerationPolicy(value: string): GenerationPolicy | null;
|
|
202
|
+
declare function parseGenerationPolicyFromEnv(env: EnvLike): GenerationPolicy | null;
|
|
203
|
+
declare function getAllowedGenerationModelIds(policy: GenerationPolicy | null): string[] | null;
|
|
204
|
+
declare function findGenerationModelPolicy(policy: GenerationPolicy | null, model: string): GenerationModelPolicy | null;
|
|
205
|
+
declare function assertGenerationRequestAllowedByPolicy(input: {
|
|
206
|
+
policy: GenerationPolicy | null;
|
|
207
|
+
model: string;
|
|
208
|
+
parameters?: Record<string, unknown>;
|
|
209
|
+
}): void;
|
|
210
|
+
declare function filterGenerationDeclarationsByPolicy<T extends PublicDeclaration>(declarations: T[], policy: GenerationPolicy | null): T[];
|
|
211
|
+
//#endregion
|
|
339
212
|
//#region ../protocol/src/generation/index.d.ts
|
|
340
213
|
declare const GENERATION_TASK_TYPE: "generation";
|
|
341
214
|
type CreateGenerationTaskRequest = {
|
|
342
215
|
spaceId: string;
|
|
216
|
+
sessionId?: string | null;
|
|
217
|
+
turnId?: string | null;
|
|
343
218
|
model: string;
|
|
344
219
|
content: GenerationContentBlock[];
|
|
345
220
|
parameters?: Record<string, unknown>;
|
|
@@ -605,10 +480,6 @@ type SpaceMeta = JsonObject & {
|
|
|
605
480
|
extraEnv?: SpaceEnvInput[];
|
|
606
481
|
publicProfile?: Partial<SpacePublicProfile> | null;
|
|
607
482
|
};
|
|
608
|
-
type SpaceGitInfo = {
|
|
609
|
-
giteaHost: string;
|
|
610
|
-
giteaUsername: string;
|
|
611
|
-
};
|
|
612
483
|
type SpaceRecord = {
|
|
613
484
|
id: string;
|
|
614
485
|
userUuid: string;
|
|
@@ -630,6 +501,7 @@ type SpaceRecord = {
|
|
|
630
501
|
provider: string;
|
|
631
502
|
status: string;
|
|
632
503
|
}[];
|
|
504
|
+
access?: SpaceAccess;
|
|
633
505
|
accessLevel?: "minimal";
|
|
634
506
|
ownerProfile?: Pick<UserProfile, "userUuid" | "username" | "displayName" | "avatarUrl"> | null;
|
|
635
507
|
};
|
|
@@ -795,6 +667,9 @@ type GlobalSearchResult = {
|
|
|
795
667
|
turnId: string | null;
|
|
796
668
|
sequence: number | null;
|
|
797
669
|
title: string;
|
|
670
|
+
excerpt?: string | null;
|
|
671
|
+
spaceName?: string | null;
|
|
672
|
+
sessionTitle?: string | null;
|
|
798
673
|
ownerProfile?: Pick<UserProfile, "userUuid" | "username" | "displayName" | "avatarUrl"> | null;
|
|
799
674
|
spaceProfile?: SpacePublicProfile | null;
|
|
800
675
|
matchedField: "userText" | "title" | "name" | "description";
|
|
@@ -824,13 +699,6 @@ type SpaceSessionsResponse = {
|
|
|
824
699
|
nextCursor: string | null;
|
|
825
700
|
};
|
|
826
701
|
};
|
|
827
|
-
type UserSshKey = {
|
|
828
|
-
id: string;
|
|
829
|
-
key: string;
|
|
830
|
-
title: string;
|
|
831
|
-
giteaKeyId: number;
|
|
832
|
-
createdAt: string;
|
|
833
|
-
};
|
|
834
702
|
type CreateSpacePromptInput = {
|
|
835
703
|
sessionId?: string | null;
|
|
836
704
|
title?: string | null;
|
|
@@ -838,6 +706,7 @@ type CreateSpacePromptInput = {
|
|
|
838
706
|
model?: string | null;
|
|
839
707
|
provider?: string | null;
|
|
840
708
|
clientMessageId?: string | null;
|
|
709
|
+
generationPolicy?: GenerationPolicy | null;
|
|
841
710
|
schedule?: {
|
|
842
711
|
mode?: "immediate";
|
|
843
712
|
} | {
|
|
@@ -852,20 +721,14 @@ type CreateSpacePromptInput = {
|
|
|
852
721
|
timezone: string;
|
|
853
722
|
};
|
|
854
723
|
};
|
|
855
|
-
type CreateSpacePromptResponse = {
|
|
856
|
-
ok: true;
|
|
724
|
+
type CreateSpacePromptResponse = (SessionTurnResponse & {
|
|
857
725
|
mode: "immediate";
|
|
858
|
-
|
|
859
|
-
userMessageId: string;
|
|
860
|
-
turnId: string;
|
|
861
|
-
} | {
|
|
862
|
-
ok: true;
|
|
726
|
+
}) | {
|
|
863
727
|
mode: "delay" | "at";
|
|
864
728
|
taskRunId: string;
|
|
865
729
|
scheduledAt: string;
|
|
866
730
|
sessionId: string | null;
|
|
867
731
|
} | {
|
|
868
|
-
ok: true;
|
|
869
732
|
mode: "repeat";
|
|
870
733
|
cronJobId: string;
|
|
871
734
|
nextRunAt: string;
|
|
@@ -904,6 +767,7 @@ type TaskRunRecord = {
|
|
|
904
767
|
attemptCount: number;
|
|
905
768
|
spaceId: string | null;
|
|
906
769
|
sessionId: string | null;
|
|
770
|
+
turnId: string | null;
|
|
907
771
|
userUuid: string | null;
|
|
908
772
|
scheduledAt: string | null;
|
|
909
773
|
startedAt: string | null;
|
|
@@ -969,22 +833,28 @@ type SpaceModListItem = {
|
|
|
969
833
|
modSpaceName: string | null;
|
|
970
834
|
modSpaceDescription: string | null;
|
|
971
835
|
};
|
|
836
|
+
/**
|
|
837
|
+
* Public-safe DTO for Explore spaces.
|
|
838
|
+
* Only contains fields safe for unauthenticated product rendering.
|
|
839
|
+
*/
|
|
972
840
|
type ExploreSpaceItem = {
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
841
|
+
id: string;
|
|
842
|
+
slug: string | null;
|
|
843
|
+
title: string;
|
|
844
|
+
summary: string | null;
|
|
845
|
+
spaceUrl: string;
|
|
846
|
+
avatarUrl: string | null;
|
|
847
|
+
avatarAlt: string | null;
|
|
848
|
+
ownerDisplayName: string | null;
|
|
849
|
+
ownerAvatarUrl: string | null;
|
|
850
|
+
category: string | null;
|
|
851
|
+
tags: string[];
|
|
852
|
+
saveCount: number;
|
|
853
|
+
pinCount: number;
|
|
854
|
+
forkCount: number;
|
|
855
|
+
updatedAt: string | null;
|
|
856
|
+
accessLabel: "public" | "sign-in-required" | "unknown";
|
|
857
|
+
latestSaveLabel: string | null;
|
|
988
858
|
};
|
|
989
859
|
type ExploreSection = {
|
|
990
860
|
key: string;
|
|
@@ -997,7 +867,7 @@ type ExploreSpacesResponse = {
|
|
|
997
867
|
sections: ExploreSection[];
|
|
998
868
|
spaces: ExploreSpaceItem[];
|
|
999
869
|
};
|
|
1000
|
-
type Permission = "space.view" | "space.edit" | "space.pin" | "session.view" | "session.edit" | "session.prompt.readonly" | "session.prompt.fullaccess" | "file.view" | "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";
|
|
870
|
+
type Permission = "space.view" | "space.edit" | "space.pin" | "session.view" | "session.edit" | "session.prompt.readonly" | "session.prompt.fullaccess" | "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";
|
|
1001
871
|
type SpaceAccess = {
|
|
1002
872
|
role: SpaceRole | null;
|
|
1003
873
|
permissions: Permission[];
|
|
@@ -1193,15 +1063,6 @@ declare class SessionAccessApi {
|
|
|
1193
1063
|
}>;
|
|
1194
1064
|
}
|
|
1195
1065
|
//#endregion
|
|
1196
|
-
//#region ../protocol/src/ports/index.d.ts
|
|
1197
|
-
type SpacePortStatus = "listening" | "closed";
|
|
1198
|
-
type SpacePublicEndpoint = {
|
|
1199
|
-
url: string;
|
|
1200
|
-
status?: SpacePortStatus | "unknown";
|
|
1201
|
-
observedAt?: number;
|
|
1202
|
-
};
|
|
1203
|
-
type SpacePublicEndpoints = Record<string, SpacePublicEndpoint>;
|
|
1204
|
-
//#endregion
|
|
1205
1066
|
//#region src/session-patch-reducer.d.ts
|
|
1206
1067
|
type SessionPatchStatus = "idle" | "pending" | "streaming" | "completed" | "failed" | "interrupted";
|
|
1207
1068
|
type SessionPatchState = {
|
|
@@ -1404,12 +1265,13 @@ type SessionSubscriptionHandlers = {
|
|
|
1404
1265
|
event?: (event: WebsocketEventPayload) => void;
|
|
1405
1266
|
};
|
|
1406
1267
|
type SessionEventName = "created" | "updated" | "turn.created" | "turn.patch" | "turn.updated" | "turn.finalized" | "turn.error" | "message.persisted";
|
|
1407
|
-
type SpaceEventName = SessionEventName | "ports.changed" | "task.created" | "task.updated" | "event";
|
|
1268
|
+
type SpaceEventName = SessionEventName | "fs.changed" | "ports.changed" | "task.created" | "task.updated" | "event";
|
|
1408
1269
|
type SessionSendMessageInput = {
|
|
1409
1270
|
content: ContentBlock[];
|
|
1410
1271
|
model?: string;
|
|
1411
1272
|
provider?: string;
|
|
1412
1273
|
clientMessageId?: string;
|
|
1274
|
+
generationPolicy?: GenerationPolicy | null;
|
|
1413
1275
|
};
|
|
1414
1276
|
declare class SpacesApi {
|
|
1415
1277
|
private readonly transport;
|
|
@@ -1477,11 +1339,7 @@ declare class SessionMessagesClient {
|
|
|
1477
1339
|
limit?: number;
|
|
1478
1340
|
direction?: "older" | "newer";
|
|
1479
1341
|
}, customFetch?: Fetch): Promise<SessionMessagesPaginatedResponse>;
|
|
1480
|
-
send(input: SessionSendMessageInput): Promise<
|
|
1481
|
-
ok: true;
|
|
1482
|
-
userMessageId: string;
|
|
1483
|
-
turnId: string;
|
|
1484
|
-
}>;
|
|
1342
|
+
send(input: SessionSendMessageInput): Promise<SessionTurnResponse>;
|
|
1485
1343
|
}
|
|
1486
1344
|
declare class SessionTurnsClient {
|
|
1487
1345
|
private readonly transport;
|
|
@@ -1822,14 +1680,6 @@ declare class UserApi {
|
|
|
1822
1680
|
getRules(customFetch?: Fetch): Promise<UserRulesResponse>;
|
|
1823
1681
|
setAuthToken(token: string): Promise<any>;
|
|
1824
1682
|
clearAuthToken(): Promise<null>;
|
|
1825
|
-
getSshKeys(customFetch?: Fetch): Promise<UserSshKey[]>;
|
|
1826
|
-
createSshKey(data: {
|
|
1827
|
-
key: string;
|
|
1828
|
-
title: string;
|
|
1829
|
-
}): Promise<UserSshKey>;
|
|
1830
|
-
deleteSshKey(id: string): Promise<{
|
|
1831
|
-
ok: true;
|
|
1832
|
-
}>;
|
|
1833
1683
|
}
|
|
1834
1684
|
//#endregion
|
|
1835
1685
|
//#region src/http.d.ts
|
|
@@ -1852,4 +1702,4 @@ declare class CohubHttpClient {
|
|
|
1852
1702
|
}
|
|
1853
1703
|
declare const createHttpClient: (options?: CohubClientOptions) => CohubHttpClient;
|
|
1854
1704
|
//#endregion
|
|
1855
|
-
export { CreateInvitationInput as $, SpaceFsReadFilesInput as $t, SessionPatchStatus as A,
|
|
1705
|
+
export { CreateInvitationInput as $, Fetch as $n, SpaceFsReadFilesInput as $t, SessionPatchStatus as A, UserProfile as An, SessionTurnWindowResponse as At, GenerationsApi as B, GenerationPolicyError as Bn, SpaceCreateResponse as Bt, SessionGenerationStreamClient as C, SpaceSandboxConfig as Cn, SessionMessagesPaginatedResponse as Ct, SessionPatchApplyResult as D, SpaceUsageSummary as Dn, SessionTurnResponse as Dt, SessionPatchApplyInput as E, SpaceUsageResponse as En, SessionTurnIndexResponse as Et, CreatePublicAssetUploadResponse as F, ListGenerationModelsResponse as Fn, SpaceChannelBindingInput as Ft, BillingCreditExpiryGroup as G, findGenerationModelPolicy as Gn, SpaceFsCreateUploadResponse as Gt, ChannelsApi as H, decodeGenerationPolicy as Hn, SpaceFsCompleteUploadInput as Ht, PublicAssetPurpose as I, PublicGenerationDeclaration as In, SpaceCheckpointDetailResponse as It, BillingCreditUnit as J, parseGenerationPolicyFromEnv as Jn, SpaceFsFileKind as Jt, BillingCreditGrantStatus as K, getAllowedGenerationModelIds as Kn, SpaceFsEncoding as Kt, PublicAssetsApi as L, GenerationModelPolicy as Ln, SpaceConfig as Lt, SessionAccessApi as M, CreateGenerationTaskRequest as Mn, SpaceAccess as Mt, SearchApi as N, CreateGenerationTaskResponse as Nn, SpaceAccessPolicy as Nt, SessionPatchReducer as O, TaskRunDetailResponse as On, SessionTurnSignedUrlsResponse as Ot, CreatePublicAssetUploadInput as P, GenerationTaskResult as Pn, SpaceBootstrapSource as Pt, CheckpointRecord as Q, CohubClientOptions as Qn, SpaceFsReadFilesError as Qt, PromptsApi as R, GenerationParameterConstraint as Rn, SpaceConfigInput as Rt, GenerationStreamTurnUpdatedEvent as S, SpaceSandboxAutoDestroyPolicy as Sn, SessionMessageResponse as St, parseAssistantMessageCommit as T, SpaceUsageHourlyStat as Tn, SessionRecord as Tt, AcceptInvitationResponse as U, encodeGenerationPolicy as Un, SpaceFsCompleteUploadResponse as Ut, CronJobsApi as V, assertGenerationRequestAllowedByPolicy as Vn, SpaceEnvInput as Vt, ApiError as W, filterGenerationDeclarationsByPolicy as Wn, SpaceFsCreateUploadInput as Wt, BillingPluginStatus as X, ChannelConfig as Xn, SpaceFsMoveInput as Xt, BillingOpenOverageStatus as Y, GenerationContentBlock as Yn, SpaceFsFileResponse as Yt, Channel as Z, DiscordChannelConfig as Zn, SpaceFsPreparingFile as Zt, GenerationStreamFinalizedEvent as _, SpaceMeta as _n, ModelCatalogEntry as _t, SessionEventName as a, SpaceFsUploadPlanEntry as an, CronJobRecord as at, GenerationStreamStateEvent as b, SpaceRecord as bn, PromptTemplateCatalogResponse as bt, SpaceClient as c, SpaceFsUploadResponse as cn, ExploreSpacesResponse as ct, WebSocketConnectionState as d, SpaceListItem as dn, GlobalSearchType as dt, SpaceFsReadFilesResponse as en, HttpError as er, CreateInvitationResponse as et, PublicInviteApi as f, SpaceMarkKind as fn, InvitationDetail as ft, GenerationStreamEvent as g, SpaceMember as gn, MeResponse as gt, GenerationStreamErrorEvent as h, SpaceMarkResourceType as hn, JsonValue as ht, TasksApi as i, SpaceFsUploadError as in, CreateSpacePromptResponse as it, createSessionPatchReducer as j, UserRulesResponse as jn, SessionTurnsPaginatedResponse as jt, SessionPatchState as k, TaskRunRecord as kn, SessionTurnStreamSnapshotResponse as kt, SpaceEventName as l, SpaceFsWriteFileInput as ln, GlobalSearchResponse as lt, GenerationStreamCommitEvent as m, SpaceMarkRecord as mn, JsonPrimitive as mt, createHttpClient as n, SpaceFsUploadDestination as nn, RawHttpResponse as nr, CreateSpaceModInput as nt, SessionSubscriptionHandlers as o, SpaceFsUploadPlanEntryInput as on, ExploreSection as ot, AssistantMessageCommit as p, SpaceMarkListItem as pn, JsonObject as pt, BillingCreditStatus as q, normalizeGenerationPolicy as qn, SpaceFsEntry as qt, UserApi as r, SpaceFsUploadEntry as rn, CreateSpacePromptInput as rt, SpaceChannelBindingRecord as s, SpaceFsUploadProgress as sn, ExploreSpaceItem as st, CohubHttpClient as t, SpaceFsTreeResponse as tn, HttpTransport as tr, CreateSpaceInput as tt, SpacesApi as u, SpaceInvitation as un, GlobalSearchResult as ut, GenerationStreamIntermediateMessage as v, SpaceModListItem as vn, Permission as vt, createSessionGenerationStreamClient as w, SpaceSessionsResponse as wn, SessionMessagesResponse as wt, GenerationStreamSubscriptionHandlers as x, SpaceRole as xn, SessionBindingRecord as xt, GenerationStreamOutOfSyncEvent as y, SpacePublicProfile as yn, PromptTemplateCatalogEntry as yt, ModelsApi as z, GenerationPolicy as zn, SpaceConfigResponse as zt };
|
package/dist/chunks/http.js
CHANGED
|
@@ -1265,7 +1265,8 @@ var SessionMessagesClient = class {
|
|
|
1265
1265
|
content: input.content,
|
|
1266
1266
|
model: input.model,
|
|
1267
1267
|
provider: input.provider,
|
|
1268
|
-
clientMessageId: input.clientMessageId
|
|
1268
|
+
clientMessageId: input.clientMessageId,
|
|
1269
|
+
generationPolicy: input.generationPolicy
|
|
1269
1270
|
})
|
|
1270
1271
|
});
|
|
1271
1272
|
}
|
|
@@ -1489,6 +1490,10 @@ var SpaceEventsApi = class {
|
|
|
1489
1490
|
handler(event);
|
|
1490
1491
|
return;
|
|
1491
1492
|
}
|
|
1493
|
+
if (type === "fs.changed" && event.type === "space.fs.changed") {
|
|
1494
|
+
handler(event);
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1492
1497
|
if (type === "ports.changed" && event.type === "space.ports.changed") {
|
|
1493
1498
|
handler(event);
|
|
1494
1499
|
return;
|
|
@@ -1858,22 +1863,6 @@ var UserApi = class {
|
|
|
1858
1863
|
this.clearStoredAuthToken?.();
|
|
1859
1864
|
return null;
|
|
1860
1865
|
}
|
|
1861
|
-
getSshKeys(customFetch) {
|
|
1862
|
-
return this.transport.request("/api/user/ssh-keys", {
|
|
1863
|
-
method: "GET",
|
|
1864
|
-
fetch: customFetch
|
|
1865
|
-
});
|
|
1866
|
-
}
|
|
1867
|
-
createSshKey(data) {
|
|
1868
|
-
return this.transport.request("/api/user/ssh-keys", {
|
|
1869
|
-
method: "POST",
|
|
1870
|
-
headers: { "Content-Type": "application/json" },
|
|
1871
|
-
body: JSON.stringify(data)
|
|
1872
|
-
});
|
|
1873
|
-
}
|
|
1874
|
-
deleteSshKey(id) {
|
|
1875
|
-
return this.transport.request(`/api/user/ssh-keys/${id}`, { method: "DELETE" });
|
|
1876
|
-
}
|
|
1877
1866
|
};
|
|
1878
1867
|
//#endregion
|
|
1879
1868
|
//#region src/http.ts
|
|
@@ -22,7 +22,238 @@ declare const resolveWebsocketUrl: (options?: {
|
|
|
22
22
|
env?: CohubEnvironment;
|
|
23
23
|
}) => string;
|
|
24
24
|
//#endregion
|
|
25
|
-
//#region ../protocol/
|
|
25
|
+
//#region ../protocol/src/core/content.d.ts
|
|
26
|
+
type ContentBlockMeta = Record<string, unknown>;
|
|
27
|
+
type ContentBlock = {
|
|
28
|
+
type: "text";
|
|
29
|
+
text: string;
|
|
30
|
+
_meta?: ContentBlockMeta;
|
|
31
|
+
} | {
|
|
32
|
+
type: "thinking";
|
|
33
|
+
thinking: string;
|
|
34
|
+
signature?: string;
|
|
35
|
+
_meta?: ContentBlockMeta;
|
|
36
|
+
} | {
|
|
37
|
+
type: "image";
|
|
38
|
+
source: {
|
|
39
|
+
type: "url";
|
|
40
|
+
url: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: "base64";
|
|
43
|
+
media_type: string;
|
|
44
|
+
data: string;
|
|
45
|
+
};
|
|
46
|
+
_meta?: ContentBlockMeta;
|
|
47
|
+
} | {
|
|
48
|
+
type: "shell_command";
|
|
49
|
+
command: string;
|
|
50
|
+
rawText: string;
|
|
51
|
+
_meta?: ContentBlockMeta;
|
|
52
|
+
} | {
|
|
53
|
+
type: "tool_use";
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
input: Record<string, unknown>;
|
|
57
|
+
_meta?: ContentBlockMeta;
|
|
58
|
+
} | {
|
|
59
|
+
type: "tool_result";
|
|
60
|
+
tool_use_id: string;
|
|
61
|
+
content: string | ContentBlock[];
|
|
62
|
+
is_error?: boolean;
|
|
63
|
+
_meta?: ContentBlockMeta;
|
|
64
|
+
} | {
|
|
65
|
+
type: "system_note";
|
|
66
|
+
note_type: "session_created" | "forked" | "compacted" | "info";
|
|
67
|
+
text: string;
|
|
68
|
+
_meta?: ContentBlockMeta;
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region ../protocol/src/core/usage.d.ts
|
|
72
|
+
type Usage = {
|
|
73
|
+
input?: number;
|
|
74
|
+
output?: number;
|
|
75
|
+
cacheRead?: number;
|
|
76
|
+
cacheWrite?: number;
|
|
77
|
+
totalTokens?: number;
|
|
78
|
+
cost?: {
|
|
79
|
+
input?: number;
|
|
80
|
+
output?: number;
|
|
81
|
+
cacheRead?: number;
|
|
82
|
+
cacheWrite?: number;
|
|
83
|
+
total?: number;
|
|
84
|
+
} | null;
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region ../protocol/src/model/turn.d.ts
|
|
88
|
+
type SessionTurnStatus = "queued" | "running" | "abort_requested" | "completed" | "failed" | "interrupted" | "merged" | "cancelled";
|
|
89
|
+
type SessionTurnIntent = "steer" | "followup";
|
|
90
|
+
type SessionTurnSummary = {
|
|
91
|
+
text?: string | null;
|
|
92
|
+
finishReason?: "completed" | "failed" | "interrupted" | "merged" | "cancelled";
|
|
93
|
+
reason?: "steer" | "abort" | "merge" | string;
|
|
94
|
+
continuedByTurnId?: string | null;
|
|
95
|
+
interruptedByTurnId?: string | null;
|
|
96
|
+
mergedIntoTurnId?: string | null;
|
|
97
|
+
};
|
|
98
|
+
type SessionTurnIntermediateIndex = {
|
|
99
|
+
version: 1;
|
|
100
|
+
messagesObjectKey: string | null;
|
|
101
|
+
messagesSizeBytes?: number | null;
|
|
102
|
+
toolCallsBaseObjectKey?: string | null;
|
|
103
|
+
};
|
|
104
|
+
type SessionTurnIntermediateSummary = {
|
|
105
|
+
messageCount: number;
|
|
106
|
+
toolCallCount: number;
|
|
107
|
+
usage?: Usage | null;
|
|
108
|
+
durationMs?: number | null;
|
|
109
|
+
lastMessageText?: string | null;
|
|
110
|
+
hasError?: boolean;
|
|
111
|
+
};
|
|
112
|
+
type SessionTurnIndexItem = {
|
|
113
|
+
id: string;
|
|
114
|
+
sessionId: string;
|
|
115
|
+
sourceSessionId?: string;
|
|
116
|
+
sourceTurnId?: string;
|
|
117
|
+
sequence: number;
|
|
118
|
+
status: SessionTurnStatus;
|
|
119
|
+
startedAt: string | null;
|
|
120
|
+
completedAt: string | null;
|
|
121
|
+
durationMs: number | null;
|
|
122
|
+
createdAt: string;
|
|
123
|
+
updatedAt: string;
|
|
124
|
+
userPreview: string | null;
|
|
125
|
+
assistantPreview: string | null;
|
|
126
|
+
provider: string | null;
|
|
127
|
+
model: string | null;
|
|
128
|
+
finalUsage: Usage | null;
|
|
129
|
+
totalUsage: Usage | null;
|
|
130
|
+
errorMessage: string | null;
|
|
131
|
+
};
|
|
132
|
+
type SessionTurnAuthorProfile = {
|
|
133
|
+
userUuid: string;
|
|
134
|
+
displayName: string;
|
|
135
|
+
avatarUrl: string | null;
|
|
136
|
+
};
|
|
137
|
+
type SessionTurnRecord = {
|
|
138
|
+
id: string;
|
|
139
|
+
sessionId: string;
|
|
140
|
+
sourceSessionId?: string;
|
|
141
|
+
sourceTurnId?: string;
|
|
142
|
+
userUuid: string | null;
|
|
143
|
+
sequence: number;
|
|
144
|
+
status: SessionTurnStatus;
|
|
145
|
+
intent: SessionTurnIntent;
|
|
146
|
+
userContent: ContentBlock[];
|
|
147
|
+
userText: string | null;
|
|
148
|
+
assistantContent: ContentBlock[] | null;
|
|
149
|
+
assistantText: string | null;
|
|
150
|
+
provider: string | null;
|
|
151
|
+
model: string | null;
|
|
152
|
+
stopReason: string | null;
|
|
153
|
+
errorMessage: string | null;
|
|
154
|
+
finalUsage: Usage | null;
|
|
155
|
+
totalUsage: Usage | null;
|
|
156
|
+
summary: SessionTurnSummary | null;
|
|
157
|
+
intermediateIndex: SessionTurnIntermediateIndex | null;
|
|
158
|
+
intermediateSummary: SessionTurnIntermediateSummary | null;
|
|
159
|
+
meta: Record<string, unknown> | null;
|
|
160
|
+
authorProfile?: SessionTurnAuthorProfile | null;
|
|
161
|
+
startedAt: string | null;
|
|
162
|
+
completedAt: string | null;
|
|
163
|
+
durationMs: number | null;
|
|
164
|
+
createdAt: string;
|
|
165
|
+
updatedAt: string;
|
|
166
|
+
};
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region ../protocol/src/model/session.d.ts
|
|
169
|
+
type SessionForkRecord = {
|
|
170
|
+
id: string;
|
|
171
|
+
spaceId: string;
|
|
172
|
+
parentSessionId: string;
|
|
173
|
+
childSessionId: string;
|
|
174
|
+
rootSessionId: string;
|
|
175
|
+
depth: number;
|
|
176
|
+
anchorSourceSessionId: string;
|
|
177
|
+
anchorTurnId: string;
|
|
178
|
+
anchorSequence: number;
|
|
179
|
+
ancestorSessionIds: string[];
|
|
180
|
+
sessionPath: string[];
|
|
181
|
+
createdBy: string | null;
|
|
182
|
+
createdAt: string;
|
|
183
|
+
};
|
|
184
|
+
type SessionTurnSegmentRecord = {
|
|
185
|
+
id: string;
|
|
186
|
+
sessionId: string;
|
|
187
|
+
ordinal: number;
|
|
188
|
+
sourceSessionId: string;
|
|
189
|
+
fromSequence: number;
|
|
190
|
+
toSequence: number | null;
|
|
191
|
+
createdAt: string;
|
|
192
|
+
};
|
|
193
|
+
type SessionBindingRecord = {
|
|
194
|
+
id: string;
|
|
195
|
+
spaceId: string;
|
|
196
|
+
spaceSessionId: string;
|
|
197
|
+
spaceChannelId: string;
|
|
198
|
+
provider: string;
|
|
199
|
+
bindingKey: string;
|
|
200
|
+
externalChatId: string;
|
|
201
|
+
status: string | null;
|
|
202
|
+
meta: Record<string, unknown> | null;
|
|
203
|
+
createdAt: string;
|
|
204
|
+
updatedAt: string;
|
|
205
|
+
lastMessageAt: string | null;
|
|
206
|
+
};
|
|
207
|
+
type SessionRecord = {
|
|
208
|
+
id: string;
|
|
209
|
+
spaceId: string;
|
|
210
|
+
title: string | null;
|
|
211
|
+
source: string | null;
|
|
212
|
+
status: string | null;
|
|
213
|
+
externalSessionId: string | null;
|
|
214
|
+
meta: Record<string, unknown> | null;
|
|
215
|
+
latestMessageText: string | null;
|
|
216
|
+
lastMessageAt: string | null;
|
|
217
|
+
lastMessageId: string | null;
|
|
218
|
+
createdAt: string;
|
|
219
|
+
updatedAt: string;
|
|
220
|
+
};
|
|
221
|
+
type MessageAuthorProfile = {
|
|
222
|
+
userUuid: string;
|
|
223
|
+
displayName: string;
|
|
224
|
+
avatarUrl: string | null;
|
|
225
|
+
};
|
|
226
|
+
type MessageRecord = {
|
|
227
|
+
id: string;
|
|
228
|
+
sessionId: string;
|
|
229
|
+
role: "user" | "assistant" | "system";
|
|
230
|
+
content: ContentBlock[];
|
|
231
|
+
text: string | null;
|
|
232
|
+
sequence: number;
|
|
233
|
+
provider: string | null;
|
|
234
|
+
model: string | null;
|
|
235
|
+
stopReason: string | null;
|
|
236
|
+
errorMessage: string | null;
|
|
237
|
+
usage: Usage | null;
|
|
238
|
+
meta: Record<string, unknown> | null;
|
|
239
|
+
authorUuid?: string | null;
|
|
240
|
+
authorProfile?: MessageAuthorProfile | null;
|
|
241
|
+
startedAt: string | null;
|
|
242
|
+
completedAt: string | null;
|
|
243
|
+
durationMs: number | null;
|
|
244
|
+
createdAt: string;
|
|
245
|
+
};
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region ../protocol/src/ports/index.d.ts
|
|
248
|
+
type SpacePortStatus = "listening" | "closed";
|
|
249
|
+
type SpacePublicEndpoint = {
|
|
250
|
+
url: string;
|
|
251
|
+
status?: SpacePortStatus | "unknown";
|
|
252
|
+
observedAt?: number;
|
|
253
|
+
};
|
|
254
|
+
type SpacePublicEndpoints = Record<string, SpacePublicEndpoint>;
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region ../protocol/src/realtime/types.d.ts
|
|
26
257
|
type RealtimeEnvelope = {
|
|
27
258
|
id: string;
|
|
28
259
|
timestamp: number;
|
|
@@ -78,52 +309,6 @@ type SessionTurnPatchEvent = {
|
|
|
78
309
|
};
|
|
79
310
|
};
|
|
80
311
|
//#endregion
|
|
81
|
-
//#region ../protocol/src/core/content.d.ts
|
|
82
|
-
type ContentBlockMeta = Record<string, unknown>;
|
|
83
|
-
type ContentBlock = {
|
|
84
|
-
type: "text";
|
|
85
|
-
text: string;
|
|
86
|
-
_meta?: ContentBlockMeta;
|
|
87
|
-
} | {
|
|
88
|
-
type: "thinking";
|
|
89
|
-
thinking: string;
|
|
90
|
-
signature?: string;
|
|
91
|
-
_meta?: ContentBlockMeta;
|
|
92
|
-
} | {
|
|
93
|
-
type: "image";
|
|
94
|
-
source: {
|
|
95
|
-
type: "url";
|
|
96
|
-
url: string;
|
|
97
|
-
} | {
|
|
98
|
-
type: "base64";
|
|
99
|
-
media_type: string;
|
|
100
|
-
data: string;
|
|
101
|
-
};
|
|
102
|
-
_meta?: ContentBlockMeta;
|
|
103
|
-
} | {
|
|
104
|
-
type: "shell_command";
|
|
105
|
-
command: string;
|
|
106
|
-
rawText: string;
|
|
107
|
-
_meta?: ContentBlockMeta;
|
|
108
|
-
} | {
|
|
109
|
-
type: "tool_use";
|
|
110
|
-
id: string;
|
|
111
|
-
name: string;
|
|
112
|
-
input: Record<string, unknown>;
|
|
113
|
-
_meta?: ContentBlockMeta;
|
|
114
|
-
} | {
|
|
115
|
-
type: "tool_result";
|
|
116
|
-
tool_use_id: string;
|
|
117
|
-
content: string | ContentBlock[];
|
|
118
|
-
is_error?: boolean;
|
|
119
|
-
_meta?: ContentBlockMeta;
|
|
120
|
-
} | {
|
|
121
|
-
type: "system_note";
|
|
122
|
-
note_type: "session_created" | "forked" | "compacted" | "info";
|
|
123
|
-
text: string;
|
|
124
|
-
_meta?: ContentBlockMeta;
|
|
125
|
-
};
|
|
126
|
-
//#endregion
|
|
127
312
|
//#region src/websocket.d.ts
|
|
128
313
|
type WebsocketEventPayload = ChannelEnvelope;
|
|
129
314
|
type WebSocketLike = {
|
|
@@ -266,4 +451,4 @@ declare class WebsocketClient {
|
|
|
266
451
|
}
|
|
267
452
|
declare const createWebsocketClient: (options?: WebsocketClientOptions) => WebsocketClient;
|
|
268
453
|
//#endregion
|
|
269
|
-
export { resolveCohubEnvironment as _, WebsocketClientOptions as a, createWebsocketClient as c,
|
|
454
|
+
export { normalizeBaseUrl as C, resolveWebsocketUrl as D, resolveCohubEnvironment as E, CohubEnvironment as S, resolveApiBaseUrl as T, SessionTurnIndexItem as _, WebsocketClientOptions as a, ContentBlock as b, createWebsocketClient as c, SpacePublicEndpoints as d, MessageRecord as f, SessionTurnSegmentRecord as g, SessionRecord as h, WebsocketClientEvents as i, RealtimePatchOperation as l, SessionForkRecord as m, WebSocketLike as n, WebsocketClientState as o, SessionBindingRecord as p, WebsocketClient as r, WebsocketEventPayload as s, WebSocketConstructor as t, SessionTurnPatchEvent as u, SessionTurnRecord as v, normalizeWebsocketUrl as w, COHUB_ENVIRONMENTS as x, Usage as y };
|
package/dist/chunks/websocket.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as resolveWebsocketUrl } from "./environment.js";
|
|
2
|
-
//#region ../protocol/
|
|
2
|
+
//#region ../protocol/src/realtime/types.ts
|
|
3
3
|
const WS_COMPACT_STREAM_CAPABILITY = "session.compact_stream.v1";
|
|
4
4
|
const getNonEmptyString = (value) => typeof value === "string" && value.trim() ? value : null;
|
|
5
5
|
const getSessionTurnPatchStreamKey = (input, options = {}) => {
|
package/dist/http.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $ as CreateInvitationInput, $t as SpaceFsReadFilesInput, An as
|
|
3
|
-
export { AcceptInvitationResponse, ApiError, BillingCreditExpiryGroup, BillingCreditGrantStatus, BillingCreditStatus, BillingCreditUnit, BillingOpenOverageStatus, BillingPluginStatus, Channel, ChannelConfig, CheckpointRecord, CohubClientOptions, CohubHttpClient, ContentBlock, CreateGenerationTaskRequest, CreateGenerationTaskResponse, CreateInvitationInput, CreateInvitationResponse, CreateSpaceInput, CreateSpaceModInput, CreateSpacePromptInput, CreateSpacePromptResponse, CronJobRecord, DiscordChannelConfig, ExploreSection, ExploreSpaceItem, ExploreSpacesResponse, Fetch, GenerationContentBlock, GenerationTaskResult, GlobalSearchResponse, GlobalSearchResult, GlobalSearchType, HttpError, HttpTransport, InvitationDetail, JsonObject, JsonPrimitive, JsonValue, ListGenerationModelsResponse, MeResponse, MessageRecord, ModelCatalogEntry, Permission, PromptTemplateCatalogEntry, PromptTemplateCatalogResponse, PublicGenerationDeclaration, SessionBindingRecord, SessionForkRecord, SessionMessageResponse, SessionMessagesPaginatedResponse, SessionMessagesResponse, SessionRecord, SessionTurnIndexItem, SessionTurnIndexResponse, SessionTurnRecord, SessionTurnResponse, SessionTurnSegmentRecord, SessionTurnSignedUrlsResponse, SessionTurnStreamSnapshotResponse, SessionTurnWindowResponse, SessionTurnsPaginatedResponse, SpaceAccess, SpaceAccessPolicy, SpaceBootstrapSource, SpaceChannelBindingInput, SpaceCheckpointDetailResponse, SpaceConfig, SpaceConfigInput, SpaceConfigResponse, SpaceCreateResponse, SpaceEnvInput, SpaceFsCompleteUploadInput, SpaceFsCompleteUploadResponse, SpaceFsCreateUploadInput, SpaceFsCreateUploadResponse, SpaceFsEncoding, SpaceFsEntry, SpaceFsFileKind, SpaceFsFileResponse, SpaceFsMoveInput, SpaceFsPreparingFile, SpaceFsReadFilesError, SpaceFsReadFilesInput, SpaceFsReadFilesResponse, SpaceFsTreeResponse, SpaceFsUploadDestination, SpaceFsUploadEntry, SpaceFsUploadError, SpaceFsUploadPlanEntry, SpaceFsUploadPlanEntryInput, SpaceFsUploadProgress, SpaceFsUploadResponse, SpaceFsWriteFileInput,
|
|
1
|
+
import { _ as SessionTurnIndexItem, b as ContentBlock, f as MessageRecord, g as SessionTurnSegmentRecord, m as SessionForkRecord, v as SessionTurnRecord } from "./chunks/websocket.js";
|
|
2
|
+
import { $ as CreateInvitationInput, $n as Fetch, $t as SpaceFsReadFilesInput, An as UserProfile, At as SessionTurnWindowResponse, Bt as SpaceCreateResponse, Cn as SpaceSandboxConfig, Ct as SessionMessagesPaginatedResponse, Dn as SpaceUsageSummary, Dt as SessionTurnResponse, En as SpaceUsageResponse, Et as SessionTurnIndexResponse, Fn as ListGenerationModelsResponse, Ft as SpaceChannelBindingInput, G as BillingCreditExpiryGroup, Gt as SpaceFsCreateUploadResponse, Ht as SpaceFsCompleteUploadInput, In as PublicGenerationDeclaration, It as SpaceCheckpointDetailResponse, J as BillingCreditUnit, Jt as SpaceFsFileKind, K as BillingCreditGrantStatus, Kt as SpaceFsEncoding, Lt as SpaceConfig, Mn as CreateGenerationTaskRequest, Mt as SpaceAccess, Nn as CreateGenerationTaskResponse, Nt as SpaceAccessPolicy, On as TaskRunDetailResponse, Ot as SessionTurnSignedUrlsResponse, Pn as GenerationTaskResult, Pt as SpaceBootstrapSource, Q as CheckpointRecord, Qn as CohubClientOptions, Qt as SpaceFsReadFilesError, Rt as SpaceConfigInput, Sn as SpaceSandboxAutoDestroyPolicy, St as SessionMessageResponse, Tn as SpaceUsageHourlyStat, Tt as SessionRecord, U as AcceptInvitationResponse, Ut as SpaceFsCompleteUploadResponse, Vt as SpaceEnvInput, W as ApiError, Wt as SpaceFsCreateUploadInput, X as BillingPluginStatus, Xn as ChannelConfig, Xt as SpaceFsMoveInput, Y as BillingOpenOverageStatus, Yn as GenerationContentBlock, Yt as SpaceFsFileResponse, Z as Channel, Zn as DiscordChannelConfig, Zt as SpaceFsPreparingFile, _n as SpaceMeta, _t as ModelCatalogEntry, an as SpaceFsUploadPlanEntry, at as CronJobRecord, bn as SpaceRecord, bt as PromptTemplateCatalogResponse, cn as SpaceFsUploadResponse, ct as ExploreSpacesResponse, dn as SpaceListItem, dt as GlobalSearchType, en as SpaceFsReadFilesResponse, er as HttpError, et as CreateInvitationResponse, fn as SpaceMarkKind, ft as InvitationDetail, gn as SpaceMember, gt as MeResponse, hn as SpaceMarkResourceType, ht as JsonValue, in as SpaceFsUploadError, it as CreateSpacePromptResponse, jn as UserRulesResponse, jt as SessionTurnsPaginatedResponse, kn as TaskRunRecord, kt as SessionTurnStreamSnapshotResponse, ln as SpaceFsWriteFileInput, lt as GlobalSearchResponse, mn as SpaceMarkRecord, mt as JsonPrimitive, n as createHttpClient, nn as SpaceFsUploadDestination, nt as CreateSpaceModInput, on as SpaceFsUploadPlanEntryInput, ot as ExploreSection, pn as SpaceMarkListItem, pt as JsonObject, q as BillingCreditStatus, qt as SpaceFsEntry, rn as SpaceFsUploadEntry, rt as CreateSpacePromptInput, sn as SpaceFsUploadProgress, st as ExploreSpaceItem, t as CohubHttpClient, tn as SpaceFsTreeResponse, tr as HttpTransport, tt as CreateSpaceInput, un as SpaceInvitation, ut as GlobalSearchResult, vn as SpaceModListItem, vt as Permission, wn as SpaceSessionsResponse, wt as SessionMessagesResponse, xn as SpaceRole, xt as SessionBindingRecord, yn as SpacePublicProfile, yt as PromptTemplateCatalogEntry, zn as GenerationPolicy, zt as SpaceConfigResponse } from "./chunks/http.js";
|
|
3
|
+
export { AcceptInvitationResponse, ApiError, BillingCreditExpiryGroup, BillingCreditGrantStatus, BillingCreditStatus, BillingCreditUnit, BillingOpenOverageStatus, BillingPluginStatus, Channel, type ChannelConfig, CheckpointRecord, type CohubClientOptions, CohubHttpClient, type ContentBlock, type CreateGenerationTaskRequest, type CreateGenerationTaskResponse, CreateInvitationInput, CreateInvitationResponse, CreateSpaceInput, CreateSpaceModInput, CreateSpacePromptInput, CreateSpacePromptResponse, CronJobRecord, type DiscordChannelConfig, ExploreSection, ExploreSpaceItem, ExploreSpacesResponse, type Fetch, type GenerationContentBlock, type GenerationPolicy, type GenerationTaskResult, GlobalSearchResponse, GlobalSearchResult, GlobalSearchType, HttpError, HttpTransport, InvitationDetail, JsonObject, JsonPrimitive, JsonValue, type ListGenerationModelsResponse, MeResponse, type MessageRecord, ModelCatalogEntry, Permission, PromptTemplateCatalogEntry, PromptTemplateCatalogResponse, type PublicGenerationDeclaration, SessionBindingRecord, type SessionForkRecord, SessionMessageResponse, SessionMessagesPaginatedResponse, SessionMessagesResponse, SessionRecord, type SessionTurnIndexItem, SessionTurnIndexResponse, type SessionTurnRecord, SessionTurnResponse, type SessionTurnSegmentRecord, SessionTurnSignedUrlsResponse, SessionTurnStreamSnapshotResponse, SessionTurnWindowResponse, SessionTurnsPaginatedResponse, SpaceAccess, SpaceAccessPolicy, SpaceBootstrapSource, SpaceChannelBindingInput, SpaceCheckpointDetailResponse, SpaceConfig, SpaceConfigInput, SpaceConfigResponse, SpaceCreateResponse, SpaceEnvInput, SpaceFsCompleteUploadInput, SpaceFsCompleteUploadResponse, SpaceFsCreateUploadInput, SpaceFsCreateUploadResponse, SpaceFsEncoding, SpaceFsEntry, SpaceFsFileKind, SpaceFsFileResponse, SpaceFsMoveInput, SpaceFsPreparingFile, SpaceFsReadFilesError, SpaceFsReadFilesInput, SpaceFsReadFilesResponse, SpaceFsTreeResponse, SpaceFsUploadDestination, SpaceFsUploadEntry, SpaceFsUploadError, SpaceFsUploadPlanEntry, SpaceFsUploadPlanEntryInput, SpaceFsUploadProgress, SpaceFsUploadResponse, SpaceFsWriteFileInput, SpaceInvitation, SpaceListItem, SpaceMarkKind, SpaceMarkListItem, SpaceMarkRecord, SpaceMarkResourceType, SpaceMember, SpaceMeta, SpaceModListItem, SpacePublicProfile, SpaceRecord, SpaceRole, SpaceSandboxAutoDestroyPolicy, SpaceSandboxConfig, SpaceSessionsResponse, SpaceUsageHourlyStat, SpaceUsageResponse, SpaceUsageSummary, TaskRunDetailResponse, TaskRunRecord, UserProfile, UserRulesResponse, createHttpClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $ as CreateInvitationInput, $t as SpaceFsReadFilesInput, A as SessionPatchStatus, An as
|
|
1
|
+
import { C as normalizeBaseUrl, D as resolveWebsocketUrl, E as resolveCohubEnvironment, S as CohubEnvironment, T as resolveApiBaseUrl, _ as SessionTurnIndexItem, b as ContentBlock, c as createWebsocketClient, f as MessageRecord, g as SessionTurnSegmentRecord, m as SessionForkRecord, r as WebsocketClient, v as SessionTurnRecord, w as normalizeWebsocketUrl, x as COHUB_ENVIRONMENTS } from "./chunks/websocket.js";
|
|
2
|
+
import { $ as CreateInvitationInput, $n as Fetch, $t as SpaceFsReadFilesInput, A as SessionPatchStatus, An as UserProfile, At as SessionTurnWindowResponse, B as GenerationsApi, Bn as GenerationPolicyError, Bt as SpaceCreateResponse, C as SessionGenerationStreamClient, Cn as SpaceSandboxConfig, Ct as SessionMessagesPaginatedResponse, D as SessionPatchApplyResult, Dn as SpaceUsageSummary, Dt as SessionTurnResponse, E as SessionPatchApplyInput, En as SpaceUsageResponse, Et as SessionTurnIndexResponse, F as CreatePublicAssetUploadResponse, Fn as ListGenerationModelsResponse, Ft as SpaceChannelBindingInput, G as BillingCreditExpiryGroup, Gn as findGenerationModelPolicy, Gt as SpaceFsCreateUploadResponse, H as ChannelsApi, Hn as decodeGenerationPolicy, Ht as SpaceFsCompleteUploadInput, I as PublicAssetPurpose, In as PublicGenerationDeclaration, It as SpaceCheckpointDetailResponse, J as BillingCreditUnit, Jn as parseGenerationPolicyFromEnv, Jt as SpaceFsFileKind, K as BillingCreditGrantStatus, Kn as getAllowedGenerationModelIds, Kt as SpaceFsEncoding, L as PublicAssetsApi, Ln as GenerationModelPolicy, Lt as SpaceConfig, M as SessionAccessApi, Mn as CreateGenerationTaskRequest, Mt as SpaceAccess, N as SearchApi, Nn as CreateGenerationTaskResponse, Nt as SpaceAccessPolicy, O as SessionPatchReducer, On as TaskRunDetailResponse, Ot as SessionTurnSignedUrlsResponse, P as CreatePublicAssetUploadInput, Pn as GenerationTaskResult, Pt as SpaceBootstrapSource, Q as CheckpointRecord, Qn as CohubClientOptions, Qt as SpaceFsReadFilesError, R as PromptsApi, Rn as GenerationParameterConstraint, Rt as SpaceConfigInput, S as GenerationStreamTurnUpdatedEvent, Sn as SpaceSandboxAutoDestroyPolicy, St as SessionMessageResponse, T as parseAssistantMessageCommit, Tn as SpaceUsageHourlyStat, Tt as SessionRecord, U as AcceptInvitationResponse, Un as encodeGenerationPolicy, Ut as SpaceFsCompleteUploadResponse, V as CronJobsApi, Vn as assertGenerationRequestAllowedByPolicy, Vt as SpaceEnvInput, W as ApiError, Wn as filterGenerationDeclarationsByPolicy, Wt as SpaceFsCreateUploadInput, X as BillingPluginStatus, Xn as ChannelConfig, Xt as SpaceFsMoveInput, Y as BillingOpenOverageStatus, Yn as GenerationContentBlock, Yt as SpaceFsFileResponse, Z as Channel, Zn as DiscordChannelConfig, Zt as SpaceFsPreparingFile, _ as GenerationStreamFinalizedEvent, _n as SpaceMeta, _t as ModelCatalogEntry, a as SessionEventName, an as SpaceFsUploadPlanEntry, at as CronJobRecord, b as GenerationStreamStateEvent, bn as SpaceRecord, bt as PromptTemplateCatalogResponse, c as SpaceClient, cn as SpaceFsUploadResponse, ct as ExploreSpacesResponse, d as WebSocketConnectionState, dn as SpaceListItem, dt as GlobalSearchType, en as SpaceFsReadFilesResponse, er as HttpError, et as CreateInvitationResponse, f as PublicInviteApi, fn as SpaceMarkKind, ft as InvitationDetail, g as GenerationStreamEvent, gn as SpaceMember, gt as MeResponse, h as GenerationStreamErrorEvent, hn as SpaceMarkResourceType, ht as JsonValue, i as TasksApi, in as SpaceFsUploadError, it as CreateSpacePromptResponse, j as createSessionPatchReducer, jn as UserRulesResponse, jt as SessionTurnsPaginatedResponse, k as SessionPatchState, kn as TaskRunRecord, kt as SessionTurnStreamSnapshotResponse, l as SpaceEventName, ln as SpaceFsWriteFileInput, lt as GlobalSearchResponse, m as GenerationStreamCommitEvent, mn as SpaceMarkRecord, mt as JsonPrimitive, n as createHttpClient, nn as SpaceFsUploadDestination, nr as RawHttpResponse, nt as CreateSpaceModInput, o as SessionSubscriptionHandlers, on as SpaceFsUploadPlanEntryInput, ot as ExploreSection, p as AssistantMessageCommit, pn as SpaceMarkListItem, pt as JsonObject, q as BillingCreditStatus, qn as normalizeGenerationPolicy, qt as SpaceFsEntry, r as UserApi, rn as SpaceFsUploadEntry, rt as CreateSpacePromptInput, s as SpaceChannelBindingRecord, sn as SpaceFsUploadProgress, st as ExploreSpaceItem, t as CohubHttpClient, tn as SpaceFsTreeResponse, tr as HttpTransport, tt as CreateSpaceInput, u as SpacesApi, un as SpaceInvitation, ut as GlobalSearchResult, v as GenerationStreamIntermediateMessage, vn as SpaceModListItem, vt as Permission, w as createSessionGenerationStreamClient, wn as SpaceSessionsResponse, wt as SessionMessagesResponse, x as GenerationStreamSubscriptionHandlers, xn as SpaceRole, xt as SessionBindingRecord, y as GenerationStreamOutOfSyncEvent, yn as SpacePublicProfile, yt as PromptTemplateCatalogEntry, z as ModelsApi, zn as GenerationPolicy, zt as SpaceConfigResponse } from "./chunks/http.js";
|
|
3
3
|
|
|
4
4
|
//#region src/apis/billing.d.ts
|
|
5
5
|
declare class BillingApi {
|
|
@@ -43,4 +43,4 @@ declare class CohubClient {
|
|
|
43
43
|
}
|
|
44
44
|
declare const createCohubClient: (options?: CohubClientOptions) => CohubClient;
|
|
45
45
|
//#endregion
|
|
46
|
-
export { AcceptInvitationResponse, ApiError, type AssistantMessageCommit, BillingApi, BillingCreditExpiryGroup, BillingCreditGrantStatus, BillingCreditStatus, BillingCreditUnit, BillingOpenOverageStatus, BillingPluginStatus, COHUB_ENVIRONMENTS, Channel, ChannelConfig, CheckpointRecord, CohubClient, type CohubClientOptions, type CohubEnvironment, CohubHttpClient, ContentBlock, CreateGenerationTaskRequest, CreateGenerationTaskResponse, CreateInvitationInput, CreateInvitationResponse, type CreatePublicAssetUploadInput, type CreatePublicAssetUploadResponse, CreateSpaceInput, CreateSpaceModInput, CreateSpacePromptInput, CreateSpacePromptResponse, CronJobRecord, DiscordChannelConfig, ExploreSection, ExploreSpaceItem, ExploreSpacesResponse, type Fetch, GenerationContentBlock, type GenerationStreamCommitEvent, type GenerationStreamErrorEvent, type GenerationStreamEvent, type GenerationStreamFinalizedEvent, type GenerationStreamIntermediateMessage, type GenerationStreamOutOfSyncEvent, type GenerationStreamStateEvent, type GenerationStreamSubscriptionHandlers, type GenerationStreamTurnUpdatedEvent, GenerationTaskResult, GlobalSearchResponse, GlobalSearchResult, GlobalSearchType, HttpError, InvitationDetail, JsonObject, JsonPrimitive, JsonValue, ListGenerationModelsResponse, MeResponse, MessageRecord, ModelCatalogEntry, Permission, PromptTemplateCatalogEntry, PromptTemplateCatalogResponse, type PublicAssetPurpose, PublicGenerationDeclaration, type RawHttpResponse, SessionBindingRecord, type SessionEventName, SessionForkRecord, SessionGenerationStreamClient, SessionMessageResponse, SessionMessagesPaginatedResponse, SessionMessagesResponse, type SessionPatchApplyInput, type SessionPatchApplyResult, SessionPatchReducer, type SessionPatchState, type SessionPatchStatus, SessionRecord, type SessionSubscriptionHandlers, SessionTurnIndexItem, SessionTurnIndexResponse, SessionTurnRecord, SessionTurnResponse, SessionTurnSegmentRecord, SessionTurnSignedUrlsResponse, SessionTurnStreamSnapshotResponse, SessionTurnWindowResponse, SessionTurnsPaginatedResponse, SpaceAccess, SpaceAccessPolicy, SpaceBootstrapSource, SpaceChannelBindingInput, type SpaceChannelBindingRecord, SpaceCheckpointDetailResponse, SpaceConfig, SpaceConfigInput, SpaceConfigResponse, SpaceCreateResponse, SpaceEnvInput, type SpaceEventName, SpaceFsCompleteUploadInput, SpaceFsCompleteUploadResponse, SpaceFsCreateUploadInput, SpaceFsCreateUploadResponse, SpaceFsEncoding, SpaceFsEntry, SpaceFsFileKind, SpaceFsFileResponse, SpaceFsMoveInput, SpaceFsPreparingFile, SpaceFsReadFilesError, SpaceFsReadFilesInput, SpaceFsReadFilesResponse, SpaceFsTreeResponse, SpaceFsUploadDestination, SpaceFsUploadEntry, SpaceFsUploadError, SpaceFsUploadPlanEntry, SpaceFsUploadPlanEntryInput, SpaceFsUploadProgress, SpaceFsUploadResponse, SpaceFsWriteFileInput,
|
|
46
|
+
export { AcceptInvitationResponse, ApiError, type AssistantMessageCommit, BillingApi, BillingCreditExpiryGroup, BillingCreditGrantStatus, BillingCreditStatus, BillingCreditUnit, BillingOpenOverageStatus, BillingPluginStatus, COHUB_ENVIRONMENTS, Channel, type ChannelConfig, CheckpointRecord, CohubClient, type CohubClientOptions, type CohubEnvironment, CohubHttpClient, type ContentBlock, type CreateGenerationTaskRequest, type CreateGenerationTaskResponse, CreateInvitationInput, CreateInvitationResponse, type CreatePublicAssetUploadInput, type CreatePublicAssetUploadResponse, CreateSpaceInput, CreateSpaceModInput, CreateSpacePromptInput, CreateSpacePromptResponse, CronJobRecord, type DiscordChannelConfig, ExploreSection, ExploreSpaceItem, ExploreSpacesResponse, type Fetch, type GenerationContentBlock, type GenerationModelPolicy, type GenerationParameterConstraint, type GenerationPolicy, GenerationPolicyError, type GenerationStreamCommitEvent, type GenerationStreamErrorEvent, type GenerationStreamEvent, type GenerationStreamFinalizedEvent, type GenerationStreamIntermediateMessage, type GenerationStreamOutOfSyncEvent, type GenerationStreamStateEvent, type GenerationStreamSubscriptionHandlers, type GenerationStreamTurnUpdatedEvent, type GenerationTaskResult, GlobalSearchResponse, GlobalSearchResult, GlobalSearchType, HttpError, InvitationDetail, JsonObject, JsonPrimitive, JsonValue, type ListGenerationModelsResponse, MeResponse, type MessageRecord, ModelCatalogEntry, Permission, PromptTemplateCatalogEntry, PromptTemplateCatalogResponse, type PublicAssetPurpose, type PublicGenerationDeclaration, type RawHttpResponse, SessionBindingRecord, type SessionEventName, type SessionForkRecord, SessionGenerationStreamClient, SessionMessageResponse, SessionMessagesPaginatedResponse, SessionMessagesResponse, type SessionPatchApplyInput, type SessionPatchApplyResult, SessionPatchReducer, type SessionPatchState, type SessionPatchStatus, SessionRecord, type SessionSubscriptionHandlers, type SessionTurnIndexItem, SessionTurnIndexResponse, type SessionTurnRecord, SessionTurnResponse, type SessionTurnSegmentRecord, SessionTurnSignedUrlsResponse, SessionTurnStreamSnapshotResponse, SessionTurnWindowResponse, SessionTurnsPaginatedResponse, SpaceAccess, SpaceAccessPolicy, SpaceBootstrapSource, SpaceChannelBindingInput, type SpaceChannelBindingRecord, SpaceCheckpointDetailResponse, SpaceConfig, SpaceConfigInput, SpaceConfigResponse, SpaceCreateResponse, SpaceEnvInput, type SpaceEventName, SpaceFsCompleteUploadInput, SpaceFsCompleteUploadResponse, SpaceFsCreateUploadInput, SpaceFsCreateUploadResponse, SpaceFsEncoding, SpaceFsEntry, SpaceFsFileKind, SpaceFsFileResponse, SpaceFsMoveInput, SpaceFsPreparingFile, SpaceFsReadFilesError, SpaceFsReadFilesInput, SpaceFsReadFilesResponse, SpaceFsTreeResponse, SpaceFsUploadDestination, SpaceFsUploadEntry, SpaceFsUploadError, SpaceFsUploadPlanEntry, SpaceFsUploadPlanEntryInput, SpaceFsUploadProgress, SpaceFsUploadResponse, SpaceFsWriteFileInput, SpaceInvitation, SpaceListItem, SpaceMarkKind, SpaceMarkListItem, SpaceMarkRecord, SpaceMarkResourceType, SpaceMember, SpaceMeta, SpaceModListItem, SpacePublicProfile, SpaceRecord, SpaceRole, SpaceSandboxAutoDestroyPolicy, SpaceSandboxConfig, SpaceSessionsResponse, SpaceUsageHourlyStat, SpaceUsageResponse, SpaceUsageSummary, TaskRunDetailResponse, TaskRunRecord, UserProfile, UserRulesResponse, type WebSocketConnectionState, WebsocketClient, assertGenerationRequestAllowedByPolicy, createCohubClient, createHttpClient, createSessionGenerationStreamClient, createSessionPatchReducer, createWebsocketClient, decodeGenerationPolicy, encodeGenerationPolicy, filterGenerationDeclarationsByPolicy, findGenerationModelPolicy, getAllowedGenerationModelIds, normalizeBaseUrl, normalizeGenerationPolicy, normalizeWebsocketUrl, parseAssistantMessageCommit, parseGenerationPolicyFromEnv, resolveApiBaseUrl, resolveCohubEnvironment, resolveWebsocketUrl };
|
package/dist/index.js
CHANGED
|
@@ -118,4 +118,235 @@ var CohubClient = class {
|
|
|
118
118
|
};
|
|
119
119
|
const createCohubClient = (options) => new CohubClient(options);
|
|
120
120
|
//#endregion
|
|
121
|
-
|
|
121
|
+
//#region ../protocol/src/generation/policy.ts
|
|
122
|
+
const GENERATION_POLICY_ENV_KEY = "COHUB_GENERATION_POLICY_B64";
|
|
123
|
+
var GenerationPolicyError = class extends Error {
|
|
124
|
+
constructor(message) {
|
|
125
|
+
super(message);
|
|
126
|
+
this.name = "GenerationPolicyError";
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
function isRecord(value) {
|
|
130
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
131
|
+
}
|
|
132
|
+
function isPrimitiveEnumValue(value) {
|
|
133
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
134
|
+
}
|
|
135
|
+
function normalizeConstraint(value) {
|
|
136
|
+
if (!isRecord(value) || typeof value.kind !== "string") return null;
|
|
137
|
+
if (value.kind === "enum") {
|
|
138
|
+
if (!Array.isArray(value.values) || value.values.length === 0 || !value.values.every(isPrimitiveEnumValue)) return null;
|
|
139
|
+
return {
|
|
140
|
+
kind: "enum",
|
|
141
|
+
values: value.values
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (value.kind === "number" || value.kind === "integer") {
|
|
145
|
+
const result = { kind: value.kind };
|
|
146
|
+
if (typeof value.min === "number" && Number.isFinite(value.min)) result.min = value.min;
|
|
147
|
+
if (typeof value.max === "number" && Number.isFinite(value.max)) result.max = value.max;
|
|
148
|
+
if (result.min !== void 0 && result.max !== void 0 && result.min > result.max) return null;
|
|
149
|
+
if (Array.isArray(value.values) && value.values.every((item) => typeof item === "number" && Number.isFinite(item))) {
|
|
150
|
+
if (value.kind === "integer" && !value.values.every(Number.isInteger)) return null;
|
|
151
|
+
const min = result.min;
|
|
152
|
+
const max = result.max;
|
|
153
|
+
if (min !== void 0 && value.values.some((item) => item < min)) return null;
|
|
154
|
+
if (max !== void 0 && value.values.some((item) => item > max)) return null;
|
|
155
|
+
result.values = value.values;
|
|
156
|
+
}
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
if (value.kind === "boolean") return typeof value.value === "boolean" ? {
|
|
160
|
+
kind: "boolean",
|
|
161
|
+
value: value.value
|
|
162
|
+
} : { kind: "boolean" };
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
function normalizeGenerationPolicy(value) {
|
|
166
|
+
if (!isRecord(value) || value.version !== 1) return null;
|
|
167
|
+
if (value.mode === "auto") return {
|
|
168
|
+
version: 1,
|
|
169
|
+
mode: "auto"
|
|
170
|
+
};
|
|
171
|
+
if (value.mode !== "limited" || !Array.isArray(value.models) || value.models.length === 0) return null;
|
|
172
|
+
const models = [];
|
|
173
|
+
for (const item of value.models) {
|
|
174
|
+
if (!isRecord(item) || typeof item.model !== "string" || !item.model.trim()) return null;
|
|
175
|
+
const modelPolicy = { model: item.model.trim() };
|
|
176
|
+
if (item.parameters !== void 0) {
|
|
177
|
+
if (!isRecord(item.parameters)) return null;
|
|
178
|
+
const parameters = {};
|
|
179
|
+
for (const [key, rawConstraint] of Object.entries(item.parameters)) {
|
|
180
|
+
if (!key.trim()) return null;
|
|
181
|
+
const constraint = normalizeConstraint(rawConstraint);
|
|
182
|
+
if (!constraint) return null;
|
|
183
|
+
parameters[key] = constraint;
|
|
184
|
+
}
|
|
185
|
+
if (Object.keys(parameters).length > 0) modelPolicy.parameters = parameters;
|
|
186
|
+
}
|
|
187
|
+
models.push(modelPolicy);
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
version: 1,
|
|
191
|
+
mode: "limited",
|
|
192
|
+
models
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function bytesToBase64(bytes) {
|
|
196
|
+
let binary = "";
|
|
197
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
198
|
+
return btoa(binary);
|
|
199
|
+
}
|
|
200
|
+
function base64ToBytes(value) {
|
|
201
|
+
const binary = atob(value);
|
|
202
|
+
const bytes = new Uint8Array(binary.length);
|
|
203
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
204
|
+
return bytes;
|
|
205
|
+
}
|
|
206
|
+
function toBase64Url(value) {
|
|
207
|
+
return bytesToBase64(new TextEncoder().encode(value)).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
208
|
+
}
|
|
209
|
+
function fromBase64Url(value) {
|
|
210
|
+
const base64 = value.replaceAll("-", "+").replaceAll("_", "/");
|
|
211
|
+
const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
|
|
212
|
+
return new TextDecoder().decode(base64ToBytes(padded));
|
|
213
|
+
}
|
|
214
|
+
function encodeGenerationPolicy(policy) {
|
|
215
|
+
return toBase64Url(JSON.stringify(policy));
|
|
216
|
+
}
|
|
217
|
+
function decodeGenerationPolicy(value) {
|
|
218
|
+
try {
|
|
219
|
+
return normalizeGenerationPolicy(JSON.parse(fromBase64Url(value)));
|
|
220
|
+
} catch {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function parseGenerationPolicyFromEnv(env) {
|
|
225
|
+
const value = env[GENERATION_POLICY_ENV_KEY]?.trim();
|
|
226
|
+
return value ? decodeGenerationPolicy(value) : null;
|
|
227
|
+
}
|
|
228
|
+
function getAllowedGenerationModelIds(policy) {
|
|
229
|
+
if (!policy || policy.mode === "auto") return null;
|
|
230
|
+
return [...new Set((policy.models ?? []).map((item) => item.model))];
|
|
231
|
+
}
|
|
232
|
+
function findGenerationModelPolicy(policy, model) {
|
|
233
|
+
if (!policy || policy.mode === "auto") return null;
|
|
234
|
+
return policy.models?.find((item) => item.model === model) ?? null;
|
|
235
|
+
}
|
|
236
|
+
function formatList(values) {
|
|
237
|
+
return values.map((value) => `- ${String(value)}`).join("\n");
|
|
238
|
+
}
|
|
239
|
+
function modelNotSupportedMessage(allowedModels) {
|
|
240
|
+
return [
|
|
241
|
+
"This turn supports the following generation models:",
|
|
242
|
+
"",
|
|
243
|
+
formatList(allowedModels),
|
|
244
|
+
"",
|
|
245
|
+
"Choose one of these models or update Generation settings in the Models panel."
|
|
246
|
+
].join("\n");
|
|
247
|
+
}
|
|
248
|
+
function valuesNotSupportedMessage(model, name, values, received) {
|
|
249
|
+
return [
|
|
250
|
+
`This turn supports selected values for ${model}.${name}:`,
|
|
251
|
+
"",
|
|
252
|
+
formatList(values),
|
|
253
|
+
"",
|
|
254
|
+
"Received:",
|
|
255
|
+
`- ${String(received)}`
|
|
256
|
+
].join("\n");
|
|
257
|
+
}
|
|
258
|
+
function rangeNotSupportedMessage(model, name, min, max, received) {
|
|
259
|
+
return [
|
|
260
|
+
`This turn supports ${model}.${name} in the range ${min !== void 0 && max !== void 0 ? `${min}–${max}` : min !== void 0 ? `at least ${min}` : `at most ${max}`}.`,
|
|
261
|
+
"",
|
|
262
|
+
"Received:",
|
|
263
|
+
`- ${String(received)}`
|
|
264
|
+
].join("\n");
|
|
265
|
+
}
|
|
266
|
+
function booleanNotSupportedMessage(model, name, expected, received) {
|
|
267
|
+
return [
|
|
268
|
+
`This turn supports ${model}.${name}=${String(expected)}.`,
|
|
269
|
+
"",
|
|
270
|
+
"Received:",
|
|
271
|
+
`- ${String(received)}`
|
|
272
|
+
].join("\n");
|
|
273
|
+
}
|
|
274
|
+
function sameEnumValue(a, b) {
|
|
275
|
+
return typeof a === typeof b && a === b;
|
|
276
|
+
}
|
|
277
|
+
function validateConstraint(input) {
|
|
278
|
+
const { model, name, value, constraint } = input;
|
|
279
|
+
if (constraint.kind === "enum") {
|
|
280
|
+
if (!constraint.values.some((item) => sameEnumValue(item, value))) throw new GenerationPolicyError(valuesNotSupportedMessage(model, name, constraint.values, value));
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (constraint.kind === "number" || constraint.kind === "integer") {
|
|
284
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new GenerationPolicyError(rangeNotSupportedMessage(model, name, constraint.min, constraint.max, value));
|
|
285
|
+
if (constraint.kind === "integer" && !Number.isInteger(value)) throw new GenerationPolicyError(rangeNotSupportedMessage(model, name, constraint.min, constraint.max, value));
|
|
286
|
+
if (constraint.values?.length && !constraint.values.includes(value)) throw new GenerationPolicyError(valuesNotSupportedMessage(model, name, constraint.values, value));
|
|
287
|
+
if (constraint.min !== void 0 && value < constraint.min) throw new GenerationPolicyError(rangeNotSupportedMessage(model, name, constraint.min, constraint.max, value));
|
|
288
|
+
if (constraint.max !== void 0 && value > constraint.max) throw new GenerationPolicyError(rangeNotSupportedMessage(model, name, constraint.min, constraint.max, value));
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (constraint.kind === "boolean" && constraint.value !== void 0 && value !== constraint.value) throw new GenerationPolicyError(booleanNotSupportedMessage(model, name, constraint.value, value));
|
|
292
|
+
}
|
|
293
|
+
function assertGenerationRequestAllowedByPolicy(input) {
|
|
294
|
+
const allowedModels = getAllowedGenerationModelIds(input.policy);
|
|
295
|
+
if (!allowedModels) return;
|
|
296
|
+
const modelPolicy = findGenerationModelPolicy(input.policy, input.model);
|
|
297
|
+
if (!modelPolicy) throw new GenerationPolicyError(modelNotSupportedMessage(allowedModels));
|
|
298
|
+
const parameters = input.parameters ?? {};
|
|
299
|
+
for (const [name, value] of Object.entries(parameters)) {
|
|
300
|
+
const constraint = modelPolicy.parameters?.[name];
|
|
301
|
+
if (!constraint) continue;
|
|
302
|
+
validateConstraint({
|
|
303
|
+
model: input.model,
|
|
304
|
+
name,
|
|
305
|
+
value,
|
|
306
|
+
constraint
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function cloneDeclaration(declaration) {
|
|
311
|
+
return {
|
|
312
|
+
...declaration,
|
|
313
|
+
content: {
|
|
314
|
+
...declaration.content,
|
|
315
|
+
input: [...declaration.content.input]
|
|
316
|
+
},
|
|
317
|
+
parameters: declaration.parameters ? Object.fromEntries(Object.entries(declaration.parameters).map(([key, value]) => [key, { ...value }])) : declaration.parameters,
|
|
318
|
+
examples: declaration.examples ? [...declaration.examples] : declaration.examples
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function narrowParameterSpec(spec, constraint) {
|
|
322
|
+
const next = { ...spec };
|
|
323
|
+
if (constraint.kind === "enum") {
|
|
324
|
+
if ("enum" in next && Array.isArray(next.enum)) next.enum = next.enum.filter((value) => constraint.values.some((allowed) => sameEnumValue(allowed, value)));
|
|
325
|
+
return next;
|
|
326
|
+
}
|
|
327
|
+
if (constraint.kind === "number" || constraint.kind === "integer") {
|
|
328
|
+
if ("min" in next && typeof next.min === "number" && constraint.min !== void 0) next.min = Math.max(next.min, constraint.min);
|
|
329
|
+
else if ("min" in next && constraint.min !== void 0) next.min = constraint.min;
|
|
330
|
+
if ("max" in next && typeof next.max === "number" && constraint.max !== void 0) next.max = Math.min(next.max, constraint.max);
|
|
331
|
+
else if ("max" in next && constraint.max !== void 0) next.max = constraint.max;
|
|
332
|
+
if (constraint.values?.length && "enum" in next && Array.isArray(next.enum)) next.enum = next.enum.filter((value) => constraint.values?.some((allowed) => sameEnumValue(allowed, value)));
|
|
333
|
+
}
|
|
334
|
+
return next;
|
|
335
|
+
}
|
|
336
|
+
function filterGenerationDeclarationsByPolicy(declarations, policy) {
|
|
337
|
+
const allowedModels = getAllowedGenerationModelIds(policy);
|
|
338
|
+
if (!allowedModels) return declarations;
|
|
339
|
+
const allowedSet = new Set(allowedModels);
|
|
340
|
+
return declarations.filter((declaration) => allowedSet.has(declaration.model)).map((declaration) => {
|
|
341
|
+
const cloned = cloneDeclaration(declaration);
|
|
342
|
+
const modelPolicy = findGenerationModelPolicy(policy, declaration.model);
|
|
343
|
+
if (!modelPolicy?.parameters || !cloned.parameters) return cloned;
|
|
344
|
+
for (const [name, constraint] of Object.entries(modelPolicy.parameters)) {
|
|
345
|
+
const spec = cloned.parameters[name];
|
|
346
|
+
if (spec) cloned.parameters[name] = narrowParameterSpec(spec, constraint);
|
|
347
|
+
}
|
|
348
|
+
return cloned;
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
//#endregion
|
|
352
|
+
export { BillingApi, COHUB_ENVIRONMENTS, CohubClient, CohubHttpClient, GenerationPolicyError, HttpError, SessionGenerationStreamClient, SessionPatchReducer, WebsocketClient, assertGenerationRequestAllowedByPolicy, createCohubClient, createHttpClient, createSessionGenerationStreamClient, createSessionPatchReducer, createWebsocketClient, decodeGenerationPolicy, encodeGenerationPolicy, filterGenerationDeclarationsByPolicy, findGenerationModelPolicy, getAllowedGenerationModelIds, normalizeBaseUrl, normalizeGenerationPolicy, normalizeWebsocketUrl, parseAssistantMessageCommit, parseGenerationPolicyFromEnv, resolveApiBaseUrl, resolveCohubEnvironment, resolveWebsocketUrl };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neta-art/cohub",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.1",
|
|
4
4
|
"description": "Cohub SDK for spaces, sessions, checkpoints, and realtime agent collaboration.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
@@ -47,9 +47,8 @@
|
|
|
47
47
|
"dist",
|
|
48
48
|
"README.md"
|
|
49
49
|
],
|
|
50
|
-
"dependencies": {},
|
|
51
50
|
"devDependencies": {
|
|
52
|
-
"tsdown": "^0.22.
|
|
51
|
+
"tsdown": "^0.22.1",
|
|
53
52
|
"typescript": "^6.0.3",
|
|
54
53
|
"@cohub/protocol": "2.0.0"
|
|
55
54
|
},
|