@neta-art/cohub 1.9.0 → 1.10.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/README.md +6 -105
- package/dist/chunks/environment.js +33 -0
- package/dist/chunks/http.d.ts +1615 -0
- package/dist/chunks/http.js +1919 -0
- package/dist/chunks/websocket.d.ts +266 -0
- package/dist/chunks/websocket.js +655 -0
- package/dist/debugger.d.ts +198 -0
- package/dist/debugger.js +1120 -0
- package/dist/http.d.ts +3 -32
- package/dist/http.js +2 -48
- package/dist/index.d.ts +35 -14
- package/dist/index.js +105 -8
- package/dist/websocket.d.ts +2 -141
- package/dist/websocket.js +2 -628
- package/package.json +11 -7
- package/dist/apis/channels.d.ts +0 -13
- package/dist/apis/channels.js +0 -24
- package/dist/apis/cron-jobs.d.ts +0 -18
- package/dist/apis/cron-jobs.js +0 -25
- package/dist/apis/explore.d.ts +0 -9
- package/dist/apis/explore.js +0 -9
- package/dist/apis/generations.d.ts +0 -7
- package/dist/apis/generations.js +0 -13
- package/dist/apis/invitations.d.ts +0 -20
- package/dist/apis/invitations.js +0 -36
- package/dist/apis/models.d.ts +0 -10
- package/dist/apis/models.js +0 -13
- package/dist/apis/prompts.d.ts +0 -9
- package/dist/apis/prompts.js +0 -16
- package/dist/apis/search.d.ts +0 -10
- package/dist/apis/search.js +0 -14
- package/dist/apis/session-access.d.ts +0 -13
- package/dist/apis/session-access.js +0 -19
- package/dist/apis/spaces.d.ts +0 -371
- package/dist/apis/spaces.js +0 -766
- package/dist/apis/tasks.d.ts +0 -13
- package/dist/apis/tasks.js +0 -18
- package/dist/apis/user.d.ts +0 -27
- package/dist/apis/user.js +0 -71
- package/dist/client.d.ts +0 -33
- package/dist/client.js +0 -103
- package/dist/environment.d.ts +0 -22
- package/dist/environment.js +0 -37
- package/dist/realtime.d.ts +0 -2
- package/dist/realtime.js +0 -8
- package/dist/session-generation-stream.d.ts +0 -114
- package/dist/session-generation-stream.js +0 -514
- package/dist/session-patch-reducer.d.ts +0 -61
- package/dist/session-patch-reducer.js +0 -432
- package/dist/transport.d.ts +0 -40
- package/dist/transport.js +0 -78
- package/dist/types.d.ts +0 -535
- package/dist/types.js +0 -1
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
//#region src/environment.d.ts
|
|
2
|
+
type CohubEnvironment = "prod" | "dev";
|
|
3
|
+
declare const COHUB_ENVIRONMENTS: {
|
|
4
|
+
readonly prod: {
|
|
5
|
+
readonly apiBaseUrl: "https://api.cohub.run";
|
|
6
|
+
readonly websocketUrl: "wss://gateway.cohub.run/ws";
|
|
7
|
+
};
|
|
8
|
+
readonly dev: {
|
|
9
|
+
readonly apiBaseUrl: "https://api-dev.cohub.run";
|
|
10
|
+
readonly websocketUrl: "wss://gateway-dev.cohub.run/ws";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
declare const resolveCohubEnvironment: (env?: CohubEnvironment) => CohubEnvironment;
|
|
14
|
+
declare const normalizeBaseUrl: (url: string) => string;
|
|
15
|
+
declare const normalizeWebsocketUrl: (input: string) => string;
|
|
16
|
+
declare const resolveApiBaseUrl: (options?: {
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
env?: CohubEnvironment;
|
|
19
|
+
}) => string;
|
|
20
|
+
declare const resolveWebsocketUrl: (options?: {
|
|
21
|
+
url?: string;
|
|
22
|
+
env?: CohubEnvironment;
|
|
23
|
+
}) => string;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region ../protocol/dist/realtime/types.d.ts
|
|
26
|
+
type RealtimeEnvelope = {
|
|
27
|
+
id: string;
|
|
28
|
+
timestamp: number;
|
|
29
|
+
domain: "system" | "session" | "space";
|
|
30
|
+
type: string;
|
|
31
|
+
requestId?: string | null;
|
|
32
|
+
spaceId?: string | null;
|
|
33
|
+
sessionId?: string | null;
|
|
34
|
+
payload: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
type ChannelEnvelope = RealtimeEnvelope;
|
|
37
|
+
type RealtimePatchOperation = {
|
|
38
|
+
o: "append";
|
|
39
|
+
p: string;
|
|
40
|
+
v: unknown;
|
|
41
|
+
} | {
|
|
42
|
+
o: "replace";
|
|
43
|
+
p: string;
|
|
44
|
+
v: unknown;
|
|
45
|
+
} | {
|
|
46
|
+
o: "add";
|
|
47
|
+
p: string;
|
|
48
|
+
v: unknown;
|
|
49
|
+
} | {
|
|
50
|
+
o: "merge";
|
|
51
|
+
p: string;
|
|
52
|
+
v: Record<string, unknown>;
|
|
53
|
+
} | {
|
|
54
|
+
o: "remove";
|
|
55
|
+
p: string;
|
|
56
|
+
} | {
|
|
57
|
+
v: unknown;
|
|
58
|
+
o?: undefined;
|
|
59
|
+
p?: undefined;
|
|
60
|
+
};
|
|
61
|
+
type SessionTurnPatchEvent = {
|
|
62
|
+
id: string;
|
|
63
|
+
timestamp: number;
|
|
64
|
+
domain: "session";
|
|
65
|
+
type: "session.turn.patch";
|
|
66
|
+
requestId?: string | null;
|
|
67
|
+
spaceId: string;
|
|
68
|
+
sessionId: string;
|
|
69
|
+
payload: {
|
|
70
|
+
turnId: string | null;
|
|
71
|
+
messageId: string | null;
|
|
72
|
+
messageOrdinal?: number | null;
|
|
73
|
+
sourceMessageId?: string | null;
|
|
74
|
+
anchorUserMessageId: string | null;
|
|
75
|
+
seq: number;
|
|
76
|
+
baseSeq: number;
|
|
77
|
+
ops: RealtimePatchOperation[];
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
//#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
|
+
//#region src/websocket.d.ts
|
|
128
|
+
type WebsocketEventPayload = ChannelEnvelope;
|
|
129
|
+
type WebSocketLike = {
|
|
130
|
+
readonly readyState: number;
|
|
131
|
+
onopen: ((event: Event) => void) | null;
|
|
132
|
+
onmessage: ((event: MessageEvent) => void) | null;
|
|
133
|
+
onerror: ((event: Event) => void) | null;
|
|
134
|
+
onclose: ((event: CloseEvent) => void) | null;
|
|
135
|
+
send(data: string): void;
|
|
136
|
+
close(code?: number, reason?: string): void;
|
|
137
|
+
};
|
|
138
|
+
type WebSocketConstructor = new (url: string) => WebSocketLike;
|
|
139
|
+
type WebsocketClientOptions = {
|
|
140
|
+
env?: CohubEnvironment;
|
|
141
|
+
url?: string;
|
|
142
|
+
autoReconnect?: boolean;
|
|
143
|
+
reconnectBaseDelayMs?: number;
|
|
144
|
+
reconnectMaxDelayMs?: number;
|
|
145
|
+
pingIntervalMs?: number;
|
|
146
|
+
pongTimeoutMs?: number;
|
|
147
|
+
debug?: boolean;
|
|
148
|
+
getAccessToken?: () => Promise<string | null> | string | null;
|
|
149
|
+
WebSocketImpl?: WebSocketConstructor;
|
|
150
|
+
};
|
|
151
|
+
type WebsocketClientState = "idle" | "connecting" | "reconnecting" | "open" | "closed";
|
|
152
|
+
type WebsocketClientEvents = {
|
|
153
|
+
connecting: {
|
|
154
|
+
isReconnect: boolean;
|
|
155
|
+
attempt: number;
|
|
156
|
+
};
|
|
157
|
+
reconnecting: {
|
|
158
|
+
attempt: number;
|
|
159
|
+
delayMs: number;
|
|
160
|
+
reason?: string;
|
|
161
|
+
code?: number;
|
|
162
|
+
};
|
|
163
|
+
open: {
|
|
164
|
+
connectionId?: string | null;
|
|
165
|
+
};
|
|
166
|
+
close: {
|
|
167
|
+
code: number;
|
|
168
|
+
reason: string;
|
|
169
|
+
willReconnect: boolean;
|
|
170
|
+
};
|
|
171
|
+
error: {
|
|
172
|
+
error: unknown;
|
|
173
|
+
recoverable: boolean;
|
|
174
|
+
};
|
|
175
|
+
event: WebsocketEventPayload;
|
|
176
|
+
ready: {
|
|
177
|
+
connectionId: string;
|
|
178
|
+
};
|
|
179
|
+
auth: {
|
|
180
|
+
connectionId: string;
|
|
181
|
+
user: Record<string, unknown>;
|
|
182
|
+
};
|
|
183
|
+
messageAccepted: {
|
|
184
|
+
requestId?: string | null;
|
|
185
|
+
clientMessageId?: string | null;
|
|
186
|
+
sessionId?: string | null;
|
|
187
|
+
spaceId?: string | null;
|
|
188
|
+
};
|
|
189
|
+
serverError: {
|
|
190
|
+
code?: string;
|
|
191
|
+
message?: string;
|
|
192
|
+
requestId?: string | null;
|
|
193
|
+
sessionId?: string | null;
|
|
194
|
+
spaceId?: string | null;
|
|
195
|
+
clientMessageId?: string | null;
|
|
196
|
+
};
|
|
197
|
+
pong: {
|
|
198
|
+
requestId?: string | null;
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
type EventHandler<T> = (payload: T) => void;
|
|
202
|
+
declare class WebsocketClient {
|
|
203
|
+
private readonly url;
|
|
204
|
+
private readonly autoReconnect;
|
|
205
|
+
private readonly reconnectBaseDelayMs;
|
|
206
|
+
private readonly reconnectMaxDelayMs;
|
|
207
|
+
private readonly pingIntervalMs;
|
|
208
|
+
private readonly pongTimeoutMs;
|
|
209
|
+
private readonly debug;
|
|
210
|
+
private readonly getAccessToken?;
|
|
211
|
+
private readonly WebSocketImpl;
|
|
212
|
+
private ws;
|
|
213
|
+
private pingTimer;
|
|
214
|
+
private reconnectTimer;
|
|
215
|
+
private reconnectTimerResolver;
|
|
216
|
+
private reconnectAttempt;
|
|
217
|
+
private manuallyClosed;
|
|
218
|
+
private connectPromise;
|
|
219
|
+
private authWaiter;
|
|
220
|
+
private awaitingPong;
|
|
221
|
+
private lastPingRequestId;
|
|
222
|
+
private pongDeadlineAt;
|
|
223
|
+
private readonly compactStreamContexts;
|
|
224
|
+
private readonly patchStreamBuffers;
|
|
225
|
+
state: WebsocketClientState;
|
|
226
|
+
connectionId: string | null;
|
|
227
|
+
private readonly listeners;
|
|
228
|
+
constructor(options?: WebsocketClientOptions);
|
|
229
|
+
on<K extends keyof WebsocketClientEvents>(type: K, handler: EventHandler<WebsocketClientEvents[K]>): () => void;
|
|
230
|
+
off<K extends keyof WebsocketClientEvents>(type: K, handler: EventHandler<WebsocketClientEvents[K]>): void;
|
|
231
|
+
private emit;
|
|
232
|
+
private log;
|
|
233
|
+
connect(): Promise<void>;
|
|
234
|
+
disconnect(code?: number, reason?: string): Promise<void>;
|
|
235
|
+
sendMessage(input: {
|
|
236
|
+
spaceId: string;
|
|
237
|
+
sessionId: string;
|
|
238
|
+
content: ContentBlock[];
|
|
239
|
+
clientMessageId?: string;
|
|
240
|
+
requestId?: string;
|
|
241
|
+
model?: string;
|
|
242
|
+
provider?: string;
|
|
243
|
+
}): Promise<void>;
|
|
244
|
+
ack(eventId?: string, requestId?: string): void;
|
|
245
|
+
ping(requestId?: string): void;
|
|
246
|
+
private ensureOpen;
|
|
247
|
+
private send;
|
|
248
|
+
private authenticate;
|
|
249
|
+
private createAuthWaiter;
|
|
250
|
+
private resolveAuthWaiter;
|
|
251
|
+
private rejectAuthWaiter;
|
|
252
|
+
private handleMessage;
|
|
253
|
+
private rememberCompactStreamContext;
|
|
254
|
+
private getPatchStreamBufferKey;
|
|
255
|
+
private handlePatchEnvelope;
|
|
256
|
+
private enforcePatchStreamBufferLimit;
|
|
257
|
+
private flushPatchStreamBuffer;
|
|
258
|
+
private handleCompactFrame;
|
|
259
|
+
private startPingLoop;
|
|
260
|
+
private stopPingLoop;
|
|
261
|
+
private clearReconnectTimer;
|
|
262
|
+
private scheduleReconnect;
|
|
263
|
+
}
|
|
264
|
+
declare const createWebsocketClient: (options?: WebsocketClientOptions) => WebsocketClient;
|
|
265
|
+
//#endregion
|
|
266
|
+
export { resolveCohubEnvironment as _, WebsocketClientOptions as a, createWebsocketClient as c, SessionTurnPatchEvent as d, COHUB_ENVIRONMENTS as f, resolveApiBaseUrl as g, normalizeWebsocketUrl as h, WebsocketClientEvents as i, ContentBlock as l, normalizeBaseUrl as m, WebSocketLike as n, WebsocketClientState as o, CohubEnvironment as p, WebsocketClient as r, WebsocketEventPayload as s, WebSocketConstructor as t, RealtimePatchOperation as u, resolveWebsocketUrl as v };
|