skydive-cli 0.1.0-beta.96 → 0.2.0-beta.421
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/CHANGELOG.md +68 -0
- package/README.md +187 -41
- package/dist/js/api-CDTKq_5Q.mjs +145 -0
- package/dist/js/bin.mjs +1558 -1292
- package/dist/js/{boot-DRWra2vY.mjs → boot-CQLDUeZ9.mjs} +4629 -1024
- package/dist/js/client-B3ZhhF7e.mjs +366 -0
- package/dist/js/client-CpEvH2Pq.mjs +169 -0
- package/dist/js/client-D6NAkL9e.mjs +6 -0
- package/dist/js/output-B4cW10Ph.mjs +27 -0
- package/dist/js/print-B6AO13SA.mjs +5 -0
- package/dist/js/print-DausK_KZ.mjs +484 -0
- package/dist/js/print-share-D7OSxvE2.mjs +41 -0
- package/dist/js/raw-pty-2_VA1kw_.mjs +5 -0
- package/dist/js/raw-pty-GAvxm2ol.mjs +99 -0
- package/dist/js/rest-COkLEZOB.mjs +4 -0
- package/dist/js/rest-CamHVOce.mjs +457 -0
- package/dist/js/theme-CuQhvqzN.mjs +990 -0
- package/dist/js/util-CeisaZVY.mjs +15 -0
- package/package.json +9 -3
- package/dist/js/print-CQ8b7JUC.mjs +0 -745
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { createParser } from "eventsource-parser";
|
|
4
|
+
|
|
5
|
+
//#region src/chat/api/rest.ts
|
|
6
|
+
var HttpError = class extends Error {
|
|
7
|
+
constructor(status, body) {
|
|
8
|
+
super(`HTTP ${status}: ${body.slice(0, 200)}`);
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.body = body;
|
|
11
|
+
this.name = "HttpError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const ERROR_DETAIL_MAX_BODY = 2e3;
|
|
15
|
+
/**
|
|
16
|
+
* Fullest renderable text for a thrown value. `HttpError.message` clips the
|
|
17
|
+
* response body to 200 chars (it flows into logs and one-line UIs); the
|
|
18
|
+
* transcript renders errors collapsed to a single line, so it can afford the
|
|
19
|
+
* whole body — capped with an explicit marker, never cut silently.
|
|
20
|
+
*/
|
|
21
|
+
function errorDetail(err) {
|
|
22
|
+
if (err instanceof HttpError) {
|
|
23
|
+
const body = err.body.length > ERROR_DETAIL_MAX_BODY ? `${err.body.slice(0, ERROR_DETAIL_MAX_BODY)}… (+${err.body.length - ERROR_DETAIL_MAX_BODY} chars)` : err.body;
|
|
24
|
+
return body ? `HTTP ${err.status}: ${body}` : `HTTP ${err.status}`;
|
|
25
|
+
}
|
|
26
|
+
return err instanceof Error ? err.message : String(err);
|
|
27
|
+
}
|
|
28
|
+
const MAX_STREAM_RECONNECTS = 5;
|
|
29
|
+
function createRestClient({ appUrl, sessionToken }) {
|
|
30
|
+
const baseHeaders = {
|
|
31
|
+
authorization: `Bearer ${sessionToken}`,
|
|
32
|
+
accept: "application/json"
|
|
33
|
+
};
|
|
34
|
+
async function get(path, schema) {
|
|
35
|
+
const res = await fetch(`${appUrl}${path}`, { headers: baseHeaders });
|
|
36
|
+
if (!res.ok) throw new HttpError(res.status, await res.text().catch(() => ""));
|
|
37
|
+
return schema.parse(await res.json());
|
|
38
|
+
}
|
|
39
|
+
async function post(path, body, schema, method = "POST") {
|
|
40
|
+
const res = await fetch(`${appUrl}${path}`, {
|
|
41
|
+
method,
|
|
42
|
+
headers: {
|
|
43
|
+
...baseHeaders,
|
|
44
|
+
"content-type": "application/json"
|
|
45
|
+
},
|
|
46
|
+
body: JSON.stringify(body)
|
|
47
|
+
});
|
|
48
|
+
if (!res.ok) throw new HttpError(res.status, await res.text().catch(() => ""));
|
|
49
|
+
return schema.parse(await res.json());
|
|
50
|
+
}
|
|
51
|
+
async function del(path) {
|
|
52
|
+
const res = await fetch(`${appUrl}${path}`, {
|
|
53
|
+
method: "DELETE",
|
|
54
|
+
headers: baseHeaders
|
|
55
|
+
});
|
|
56
|
+
if (!res.ok) throw new HttpError(res.status, await res.text().catch(() => ""));
|
|
57
|
+
}
|
|
58
|
+
const streamEvents = async ({ path, label, signal, onEvent }) => {
|
|
59
|
+
let lastEventId = null;
|
|
60
|
+
let finished = false;
|
|
61
|
+
let reconnects = 0;
|
|
62
|
+
for (;;) {
|
|
63
|
+
if (signal.aborted) return;
|
|
64
|
+
try {
|
|
65
|
+
const headers = {
|
|
66
|
+
authorization: `Bearer ${sessionToken}`,
|
|
67
|
+
accept: "text/event-stream"
|
|
68
|
+
};
|
|
69
|
+
if (lastEventId) headers["last-event-id"] = lastEventId;
|
|
70
|
+
const res = await fetch(`${appUrl}${path}`, {
|
|
71
|
+
headers,
|
|
72
|
+
signal
|
|
73
|
+
});
|
|
74
|
+
if (!res.ok || !res.body) throw new HttpError(res.status, await res.text().catch(() => ""));
|
|
75
|
+
reconnects = 0;
|
|
76
|
+
const parser = createParser({ onEvent: (message) => {
|
|
77
|
+
if (message.id) lastEventId = message.id;
|
|
78
|
+
if (message.event === "error") {
|
|
79
|
+
const { error } = streamErrorSchema.parse(JSON.parse(message.data));
|
|
80
|
+
throw new Error(error);
|
|
81
|
+
}
|
|
82
|
+
const event = runStreamEventSchema.parse(JSON.parse(message.data));
|
|
83
|
+
if (event.kind === "finished") finished = true;
|
|
84
|
+
onEvent(event.kind === "finished" ? {
|
|
85
|
+
...event,
|
|
86
|
+
error: event.error ?? null
|
|
87
|
+
} : event);
|
|
88
|
+
} });
|
|
89
|
+
const decoder = new TextDecoder();
|
|
90
|
+
const reader = res.body.getReader();
|
|
91
|
+
try {
|
|
92
|
+
for (;;) {
|
|
93
|
+
const { done, value } = await reader.read();
|
|
94
|
+
if (done) break;
|
|
95
|
+
parser.feed(decoder.decode(value, { stream: true }));
|
|
96
|
+
if (finished) return;
|
|
97
|
+
}
|
|
98
|
+
} finally {
|
|
99
|
+
try {
|
|
100
|
+
await reader.cancel();
|
|
101
|
+
} catch (_error) {}
|
|
102
|
+
}
|
|
103
|
+
} catch (err) {
|
|
104
|
+
if (signal.aborted) return;
|
|
105
|
+
if (err instanceof HttpError && err.status >= 400 && err.status < 500) throw err;
|
|
106
|
+
reconnects += 1;
|
|
107
|
+
if (reconnects > MAX_STREAM_RECONNECTS) throw err;
|
|
108
|
+
await sleep(Math.min(500 * 2 ** reconnects, 5e3));
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (finished) return;
|
|
112
|
+
reconnects += 1;
|
|
113
|
+
if (reconnects > MAX_STREAM_RECONNECTS) throw new Error(`${label} stream ended unexpectedly`);
|
|
114
|
+
await sleep(Math.min(500 * 2 ** reconnects, 5e3));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
return {
|
|
118
|
+
listAgents: async ({ scope, onPage }) => {
|
|
119
|
+
const all = [];
|
|
120
|
+
let cursor;
|
|
121
|
+
const maxAgents = 2e3;
|
|
122
|
+
do {
|
|
123
|
+
const params = new URLSearchParams({
|
|
124
|
+
limit: "100",
|
|
125
|
+
scope,
|
|
126
|
+
sort: "mine_first_usage",
|
|
127
|
+
includeStats: "false"
|
|
128
|
+
});
|
|
129
|
+
if (cursor) params.set("cursor", cursor);
|
|
130
|
+
const page = await get(`/api/v1/agents?${params.toString()}`, listAgentsResponseSchema);
|
|
131
|
+
all.push(...page.agents);
|
|
132
|
+
cursor = page.nextCursor ?? void 0;
|
|
133
|
+
onPage?.([...all]);
|
|
134
|
+
} while (cursor && all.length < maxAgents);
|
|
135
|
+
return all;
|
|
136
|
+
},
|
|
137
|
+
createAgent: async ({ name }) => {
|
|
138
|
+
const { agent } = await post("/api/v1/agents", { name }, createAgentResponseSchema);
|
|
139
|
+
return agent;
|
|
140
|
+
},
|
|
141
|
+
getConversation: async ({ conversationId }) => {
|
|
142
|
+
const { conversation } = await get(`/api/v1/conversations/${encodeURIComponent(conversationId)}`, getConversationResponseSchema);
|
|
143
|
+
return conversation;
|
|
144
|
+
},
|
|
145
|
+
listModels: async () => {
|
|
146
|
+
const { models } = await get("/api/v1/models", listModelsResponseSchema);
|
|
147
|
+
return models;
|
|
148
|
+
},
|
|
149
|
+
updateAgentModel: async ({ agentId, model }) => {
|
|
150
|
+
const { agent } = await post(`/api/v1/agents/${encodeURIComponent(agentId)}`, { model }, updateAgentResponseSchema, "PATCH");
|
|
151
|
+
return { model: agent.model ?? null };
|
|
152
|
+
},
|
|
153
|
+
listConversations: async ({ agentId, limit, channels, onPage }) => {
|
|
154
|
+
const all = [];
|
|
155
|
+
const maxConversations = limit ?? 5e3;
|
|
156
|
+
let cursor;
|
|
157
|
+
do {
|
|
158
|
+
const remaining = maxConversations - all.length;
|
|
159
|
+
const params = new URLSearchParams({
|
|
160
|
+
agentId,
|
|
161
|
+
includeTotal: "false"
|
|
162
|
+
});
|
|
163
|
+
params.set("limit", String(Math.min(remaining, 100)));
|
|
164
|
+
if (cursor) params.set("cursor", cursor);
|
|
165
|
+
for (const channel of channels ?? []) params.append("channels", channel);
|
|
166
|
+
const page = await get(`/api/v1/conversations?${params.toString()}`, listConversationsResponseSchema);
|
|
167
|
+
all.push(...page.conversations);
|
|
168
|
+
cursor = page.nextCursor ?? void 0;
|
|
169
|
+
onPage?.(limit ? all.slice(0, limit) : [...all]);
|
|
170
|
+
} while (cursor && all.length < maxConversations);
|
|
171
|
+
return limit ? all.slice(0, limit) : all;
|
|
172
|
+
},
|
|
173
|
+
listMessages: async ({ conversationId }) => {
|
|
174
|
+
const { messages } = await get(`/api/v1/conversations/${encodeURIComponent(conversationId)}/messages`, listMessagesResponseSchema);
|
|
175
|
+
return messages;
|
|
176
|
+
},
|
|
177
|
+
listWorkspaceFiles: async ({ agentId }) => {
|
|
178
|
+
const { files } = await get(`/api/v1/workspace-files?${new URLSearchParams({ agentId }).toString()}`, listWorkspaceFilesResponseSchema);
|
|
179
|
+
return files;
|
|
180
|
+
},
|
|
181
|
+
readWorkspaceFile: async ({ fileId, maxBytes = 512 * 1024 }) => {
|
|
182
|
+
const res = await fetch(`${appUrl}/api/v1/workspace-files/${encodeURIComponent(fileId)}/download?disposition=inline`, { headers: {
|
|
183
|
+
...baseHeaders,
|
|
184
|
+
Range: `bytes=0-${maxBytes}`
|
|
185
|
+
} });
|
|
186
|
+
if (!res.ok) throw new HttpError(res.status, await res.text().catch(() => ""));
|
|
187
|
+
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
188
|
+
const truncated = bytes.byteLength > maxBytes;
|
|
189
|
+
return {
|
|
190
|
+
text: new TextDecoder().decode(bytes.subarray(0, maxBytes)),
|
|
191
|
+
truncated
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
getRecap: async ({ conversationId }) => {
|
|
195
|
+
const { recap } = await get(`/api/v1/conversations/${encodeURIComponent(conversationId)}/recap`, recapResponseSchema);
|
|
196
|
+
return recap?.text ?? null;
|
|
197
|
+
},
|
|
198
|
+
uploadAttachment: async ({ agentId, fileName, mediaType, data }) => {
|
|
199
|
+
const size = data.byteLength;
|
|
200
|
+
const presign = await post("/api/v1/attachments/presign", {
|
|
201
|
+
agentId,
|
|
202
|
+
fileName,
|
|
203
|
+
mediaType,
|
|
204
|
+
size
|
|
205
|
+
}, presignResponseSchema);
|
|
206
|
+
const putRes = await fetch(presign.uploadUrl, {
|
|
207
|
+
method: "PUT",
|
|
208
|
+
headers: { "content-type": mediaType },
|
|
209
|
+
body: new Uint8Array(data)
|
|
210
|
+
});
|
|
211
|
+
if (!putRes.ok) throw new HttpError(putRes.status, await putRes.text().catch(() => ""));
|
|
212
|
+
const finalized = await post(`/api/v1/attachments/${encodeURIComponent(presign.id)}/finalize`, {
|
|
213
|
+
agentId,
|
|
214
|
+
fileName: presign.fileName,
|
|
215
|
+
mediaType: presign.mediaType,
|
|
216
|
+
size
|
|
217
|
+
}, finalizeResponseSchema);
|
|
218
|
+
return {
|
|
219
|
+
id: presign.id,
|
|
220
|
+
fileName: finalized.fileName,
|
|
221
|
+
mediaType: finalized.mediaType,
|
|
222
|
+
sizeBytes: finalized.sizeBytes ?? size
|
|
223
|
+
};
|
|
224
|
+
},
|
|
225
|
+
deleteConversation: async ({ conversationId }) => {
|
|
226
|
+
await del(`/api/v1/conversations/${encodeURIComponent(conversationId)}`);
|
|
227
|
+
},
|
|
228
|
+
sendMessage: async ({ clientSurface, ...input }) => post("/api/v1/chat/send", {
|
|
229
|
+
...input,
|
|
230
|
+
clientSurface
|
|
231
|
+
}, sendResultSchema),
|
|
232
|
+
cancelRun: async ({ runId }) => {
|
|
233
|
+
await post(`/api/v1/chat/runs/${encodeURIComponent(runId)}/cancel`, {}, z.object({ ok: z.boolean() }));
|
|
234
|
+
},
|
|
235
|
+
cancelSteer: async ({ directiveId }) => {
|
|
236
|
+
await post(`/api/v1/chat/steer/${encodeURIComponent(directiveId)}/cancel`, {}, z.object({ ok: z.boolean() }));
|
|
237
|
+
},
|
|
238
|
+
oauthConnect: async (input) => {
|
|
239
|
+
const { connectLink } = await post("/api/v1/oauth/connect", input, oauthConnectResponseSchema);
|
|
240
|
+
return { connectLink };
|
|
241
|
+
},
|
|
242
|
+
externalOauthConnect: async (input) => {
|
|
243
|
+
const { authorizationUrl } = await post("/api/v1/external-oauth/connect", input, externalOauthConnectResponseSchema);
|
|
244
|
+
return { authorizationUrl: authorizationUrl ?? null };
|
|
245
|
+
},
|
|
246
|
+
fulfillCredential: async ({ url, body }) => {
|
|
247
|
+
const target = new URL(url, appUrl).toString();
|
|
248
|
+
const res = await fetch(target, {
|
|
249
|
+
method: "POST",
|
|
250
|
+
headers: {
|
|
251
|
+
...baseHeaders,
|
|
252
|
+
"content-type": "application/json"
|
|
253
|
+
},
|
|
254
|
+
body: JSON.stringify(body)
|
|
255
|
+
});
|
|
256
|
+
if (!res.ok) throw new HttpError(res.status, await res.text().catch(() => ""));
|
|
257
|
+
},
|
|
258
|
+
streamRun: async ({ runId, signal, onEvent }) => streamEvents({
|
|
259
|
+
path: `/api/v1/chat/runs/${encodeURIComponent(runId)}/stream`,
|
|
260
|
+
label: "run",
|
|
261
|
+
signal,
|
|
262
|
+
onEvent
|
|
263
|
+
}),
|
|
264
|
+
streamMessage: async ({ messageId, signal, onEvent }) => streamEvents({
|
|
265
|
+
path: `/api/v1/chat/messages/${encodeURIComponent(messageId)}/stream`,
|
|
266
|
+
label: "message",
|
|
267
|
+
signal,
|
|
268
|
+
onEvent
|
|
269
|
+
}),
|
|
270
|
+
streamConversation: async ({ conversationId, signal, onEvent }) => {
|
|
271
|
+
let reconnects = 0;
|
|
272
|
+
for (;;) {
|
|
273
|
+
if (signal.aborted) return;
|
|
274
|
+
try {
|
|
275
|
+
const res = await fetch(`${appUrl}/api/v1/chat/conversations/${encodeURIComponent(conversationId)}/stream`, {
|
|
276
|
+
headers: {
|
|
277
|
+
authorization: `Bearer ${sessionToken}`,
|
|
278
|
+
accept: "text/event-stream"
|
|
279
|
+
},
|
|
280
|
+
signal
|
|
281
|
+
});
|
|
282
|
+
if (!res.ok || !res.body) throw new HttpError(res.status, await res.text().catch(() => ""));
|
|
283
|
+
reconnects = 0;
|
|
284
|
+
const parser = createParser({ onEvent: (message) => {
|
|
285
|
+
const parsed = conversationStreamEventSchema.safeParse(JSON.parse(message.data));
|
|
286
|
+
if (parsed.success) onEvent(parsed.data);
|
|
287
|
+
} });
|
|
288
|
+
const decoder = new TextDecoder();
|
|
289
|
+
const reader = res.body.getReader();
|
|
290
|
+
try {
|
|
291
|
+
for (;;) {
|
|
292
|
+
const { done, value } = await reader.read();
|
|
293
|
+
if (done) break;
|
|
294
|
+
parser.feed(decoder.decode(value, { stream: true }));
|
|
295
|
+
}
|
|
296
|
+
} finally {
|
|
297
|
+
try {
|
|
298
|
+
await reader.cancel();
|
|
299
|
+
} catch (_error) {}
|
|
300
|
+
}
|
|
301
|
+
} catch (err) {
|
|
302
|
+
if (signal.aborted) return;
|
|
303
|
+
if (err instanceof HttpError && err.status >= 400 && err.status < 500) throw err;
|
|
304
|
+
reconnects += 1;
|
|
305
|
+
if (reconnects > MAX_STREAM_RECONNECTS) throw err;
|
|
306
|
+
await sleep(Math.min(500 * 2 ** reconnects, 5e3));
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (signal.aborted) return;
|
|
310
|
+
reconnects += 1;
|
|
311
|
+
if (reconnects > MAX_STREAM_RECONNECTS) throw new Error("conversation stream ended unexpectedly");
|
|
312
|
+
await sleep(Math.min(500 * 2 ** reconnects, 5e3));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function sleep(ms) {
|
|
318
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
319
|
+
}
|
|
320
|
+
const agentSummarySchema = z.object({
|
|
321
|
+
id: z.string().uuid(),
|
|
322
|
+
name: z.string(),
|
|
323
|
+
slug: z.string().nullable().optional(),
|
|
324
|
+
title: z.string().nullable().optional(),
|
|
325
|
+
description: z.string().nullable().optional(),
|
|
326
|
+
createdAt: z.string(),
|
|
327
|
+
creatorName: z.string().nullable().optional(),
|
|
328
|
+
model: z.string().nullable().optional(),
|
|
329
|
+
modelLocked: z.boolean().optional()
|
|
330
|
+
});
|
|
331
|
+
const platformModelSchema = z.object({
|
|
332
|
+
id: z.string(),
|
|
333
|
+
displayName: z.string(),
|
|
334
|
+
providerDisplay: z.string().optional(),
|
|
335
|
+
reasoning: z.boolean().optional(),
|
|
336
|
+
compliant: z.boolean().optional()
|
|
337
|
+
}).passthrough();
|
|
338
|
+
const listModelsResponseSchema = z.object({ models: z.array(platformModelSchema) });
|
|
339
|
+
const updateAgentResponseSchema = z.object({ agent: z.object({ model: z.string().nullable().optional() }).passthrough() });
|
|
340
|
+
const listAgentsResponseSchema = z.object({
|
|
341
|
+
agents: z.array(agentSummarySchema),
|
|
342
|
+
nextCursor: z.string().nullable().optional(),
|
|
343
|
+
totalCount: z.number().nullable().optional()
|
|
344
|
+
});
|
|
345
|
+
const createAgentResponseSchema = z.object({ agent: agentSummarySchema });
|
|
346
|
+
const conversationSummarySchema = z.object({
|
|
347
|
+
id: z.string().uuid(),
|
|
348
|
+
title: z.string().nullable(),
|
|
349
|
+
createdAt: z.string(),
|
|
350
|
+
updatedAt: z.string(),
|
|
351
|
+
preview: z.string().nullable(),
|
|
352
|
+
channel: z.string().nullable(),
|
|
353
|
+
channelLabel: z.string().nullable(),
|
|
354
|
+
agent: z.object({
|
|
355
|
+
id: z.string().uuid(),
|
|
356
|
+
name: z.string(),
|
|
357
|
+
slug: z.string().nullable().optional(),
|
|
358
|
+
title: z.string().nullable().optional()
|
|
359
|
+
})
|
|
360
|
+
});
|
|
361
|
+
const conversationDetailSchema = z.object({
|
|
362
|
+
id: z.string().uuid(),
|
|
363
|
+
title: z.string().nullable(),
|
|
364
|
+
agentId: z.string().uuid(),
|
|
365
|
+
createdAt: z.string(),
|
|
366
|
+
updatedAt: z.string()
|
|
367
|
+
});
|
|
368
|
+
const getConversationResponseSchema = z.object({ conversation: conversationDetailSchema });
|
|
369
|
+
const listConversationsResponseSchema = z.object({
|
|
370
|
+
conversations: z.array(conversationSummarySchema),
|
|
371
|
+
nextCursor: z.string().nullable().optional(),
|
|
372
|
+
totalCount: z.number().optional()
|
|
373
|
+
});
|
|
374
|
+
const uiMessagePartSchema = z.union([
|
|
375
|
+
z.object({
|
|
376
|
+
type: z.literal("text"),
|
|
377
|
+
text: z.string()
|
|
378
|
+
}),
|
|
379
|
+
z.object({
|
|
380
|
+
type: z.literal("reasoning"),
|
|
381
|
+
text: z.string().optional()
|
|
382
|
+
}),
|
|
383
|
+
z.object({
|
|
384
|
+
type: z.literal("dynamic-tool"),
|
|
385
|
+
toolCallId: z.string(),
|
|
386
|
+
toolName: z.string(),
|
|
387
|
+
input: z.unknown().optional(),
|
|
388
|
+
output: z.unknown().optional(),
|
|
389
|
+
state: z.string().optional(),
|
|
390
|
+
errorText: z.string().optional()
|
|
391
|
+
}),
|
|
392
|
+
z.object({ type: z.string() }).passthrough()
|
|
393
|
+
]);
|
|
394
|
+
const uiMessageSchema = z.object({
|
|
395
|
+
id: z.string(),
|
|
396
|
+
role: z.string(),
|
|
397
|
+
parts: z.array(uiMessagePartSchema),
|
|
398
|
+
metadata: z.object({ custom: z.object({
|
|
399
|
+
agentId: z.string().nullish(),
|
|
400
|
+
agentName: z.string().nullish()
|
|
401
|
+
}).passthrough().optional() }).passthrough().optional()
|
|
402
|
+
});
|
|
403
|
+
const recapResponseSchema = z.object({ recap: z.object({ text: z.string() }).nullable() });
|
|
404
|
+
const listMessagesResponseSchema = z.object({ messages: z.array(uiMessageSchema) });
|
|
405
|
+
const workspaceFileSchema = z.object({
|
|
406
|
+
id: z.string(),
|
|
407
|
+
path: z.string(),
|
|
408
|
+
mediaType: z.string(),
|
|
409
|
+
sizeBytes: z.number(),
|
|
410
|
+
contentHash: z.string(),
|
|
411
|
+
updatedAt: z.string(),
|
|
412
|
+
shareUrl: z.string()
|
|
413
|
+
});
|
|
414
|
+
const listWorkspaceFilesResponseSchema = z.object({ files: z.array(workspaceFileSchema) });
|
|
415
|
+
const sendResultSchema = z.object({
|
|
416
|
+
runId: z.string(),
|
|
417
|
+
messageId: z.string().uuid().nullish(),
|
|
418
|
+
conversationId: z.string().uuid(),
|
|
419
|
+
isNewConversation: z.boolean(),
|
|
420
|
+
agentId: z.string().nullish(),
|
|
421
|
+
agentName: z.string().nullish(),
|
|
422
|
+
steered: z.boolean().optional(),
|
|
423
|
+
directive: z.object({ id: z.string() }).passthrough().optional()
|
|
424
|
+
});
|
|
425
|
+
const presignResponseSchema = z.object({
|
|
426
|
+
id: z.string(),
|
|
427
|
+
uploadUrl: z.string(),
|
|
428
|
+
fileName: z.string(),
|
|
429
|
+
mediaType: z.string()
|
|
430
|
+
});
|
|
431
|
+
const finalizeResponseSchema = z.object({
|
|
432
|
+
fileName: z.string(),
|
|
433
|
+
mediaType: z.string(),
|
|
434
|
+
sizeBytes: z.number().nullable().optional()
|
|
435
|
+
});
|
|
436
|
+
const oauthConnectResponseSchema = z.object({ connectLink: z.string() }).passthrough();
|
|
437
|
+
const externalOauthConnectResponseSchema = z.object({ authorizationUrl: z.string().optional() }).passthrough();
|
|
438
|
+
const runStreamEventSchema = z.union([z.object({
|
|
439
|
+
kind: z.literal("chunk"),
|
|
440
|
+
chunk: z.record(z.unknown())
|
|
441
|
+
}), z.object({
|
|
442
|
+
kind: z.literal("finished"),
|
|
443
|
+
status: z.string(),
|
|
444
|
+
error: z.string().nullish()
|
|
445
|
+
})]);
|
|
446
|
+
const streamErrorSchema = z.object({ error: z.string() });
|
|
447
|
+
const conversationStreamEventSchema = z.discriminatedUnion("kind", [z.object({
|
|
448
|
+
kind: z.literal("conversation"),
|
|
449
|
+
id: z.string(),
|
|
450
|
+
title: z.string().nullable()
|
|
451
|
+
}), z.object({
|
|
452
|
+
kind: z.literal("run"),
|
|
453
|
+
runId: z.string()
|
|
454
|
+
})]);
|
|
455
|
+
|
|
456
|
+
//#endregion
|
|
457
|
+
export { createRestClient as n, errorDetail as r, HttpError as t };
|