@copilotkit/shared 1.10.7-next.0 → 1.50.0-beta.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/CHANGELOG.md +0 -2
- package/dist/{chunk-2KQ6HEWZ.mjs → chunk-64DYJ27R.mjs} +9 -2
- package/dist/{chunk-2KQ6HEWZ.mjs.map → chunk-64DYJ27R.mjs.map} +1 -1
- package/dist/{chunk-52B7I5TP.mjs → chunk-CVD324AW.mjs} +2 -2
- package/dist/{chunk-52B7I5TP.mjs.map → chunk-CVD324AW.mjs.map} +1 -1
- package/dist/{chunk-OEFIQ3FN.mjs → chunk-FCQQEZUI.mjs} +2 -2
- package/dist/{chunk-OEFIQ3FN.mjs.map → chunk-FCQQEZUI.mjs.map} +1 -1
- package/dist/{chunk-GITYJWEP.mjs → chunk-JXRG6U6R.mjs} +2 -2
- package/dist/chunk-XEMZTHQZ.mjs +67 -0
- package/dist/chunk-XEMZTHQZ.mjs.map +1 -0
- package/dist/chunk-XTHC46M2.mjs +1 -0
- package/dist/chunk-XTHC46M2.mjs.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +74 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -4
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/index.mjs +2 -2
- package/dist/telemetry/scarf-client.js +1 -1
- package/dist/telemetry/scarf-client.js.map +1 -1
- package/dist/telemetry/scarf-client.mjs +1 -1
- package/dist/telemetry/telemetry-client.js +1 -1
- package/dist/telemetry/telemetry-client.js.map +1 -1
- package/dist/telemetry/telemetry-client.mjs +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/message.d.ts +3 -2
- package/dist/types/message.js.map +1 -1
- package/dist/utils/errors.js +1 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/errors.mjs +6 -4
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +74 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +11 -4
- package/dist/utils/json-schema.d.ts +2 -1
- package/dist/utils/json-schema.js +8 -0
- package/dist/utils/json-schema.js.map +1 -1
- package/dist/utils/json-schema.mjs +3 -1
- package/dist/utils/requests.d.ts +10 -0
- package/dist/utils/requests.js +91 -0
- package/dist/utils/requests.js.map +1 -0
- package/dist/utils/requests.mjs +7 -0
- package/dist/utils/requests.mjs.map +1 -0
- package/dist/utils/types.d.ts +20 -0
- package/dist/utils/types.js +19 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/types.mjs +2 -0
- package/dist/utils/types.mjs.map +1 -0
- package/package.json +1 -1
- package/src/types/message.ts +8 -1
- package/src/utils/index.ts +2 -0
- package/src/utils/json-schema.ts +6 -0
- package/src/utils/requests.ts +77 -0
- package/src/utils/types.ts +22 -0
- /package/dist/{chunk-GITYJWEP.mjs.map → chunk-JXRG6U6R.mjs.map} +0 -0
package/package.json
CHANGED
package/src/types/message.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type Role = agui.Role;
|
|
|
10
10
|
export type SystemMessage = agui.SystemMessage;
|
|
11
11
|
export type DeveloperMessage = agui.DeveloperMessage;
|
|
12
12
|
export type ToolCall = agui.ToolCall;
|
|
13
|
+
export type ActivityMessage = agui.ActivityMessage;
|
|
13
14
|
|
|
14
15
|
// Extended message types
|
|
15
16
|
export type ToolResult = agui.ToolMessage & {
|
|
@@ -27,4 +28,10 @@ export type UserMessage = agui.UserMessage & {
|
|
|
27
28
|
image?: ImageData;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
export type Message =
|
|
31
|
+
export type Message =
|
|
32
|
+
| AIMessage
|
|
33
|
+
| ToolResult
|
|
34
|
+
| UserMessage
|
|
35
|
+
| SystemMessage
|
|
36
|
+
| DeveloperMessage
|
|
37
|
+
| ActivityMessage;
|
package/src/utils/index.ts
CHANGED
|
@@ -2,7 +2,9 @@ export * from "./conditions";
|
|
|
2
2
|
export * from "./console-styling";
|
|
3
3
|
export * from "./errors";
|
|
4
4
|
export * from "./json-schema";
|
|
5
|
+
export * from "./types";
|
|
5
6
|
export * from "./random-id";
|
|
7
|
+
export * from "./requests";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Safely parses a JSON string into an object
|
package/src/utils/json-schema.ts
CHANGED
|
@@ -250,3 +250,9 @@ export function convertJsonSchemaToZodSchema(jsonSchema: any, required: boolean)
|
|
|
250
250
|
}
|
|
251
251
|
throw new Error("Invalid JSON schema");
|
|
252
252
|
}
|
|
253
|
+
|
|
254
|
+
export function getZodParameters<T extends [] | Parameter[] | undefined>(parameters: T): any {
|
|
255
|
+
if (!parameters) return z.object({});
|
|
256
|
+
const jsonParams = actionParametersToJsonSchema(parameters);
|
|
257
|
+
return convertJsonSchemaToZodSchema(jsonParams, true);
|
|
258
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safely read a Response/Request body with sensible defaults:
|
|
3
|
+
* - clones the response/request to avoid consuming the original response/request
|
|
4
|
+
* - Skips GET/HEAD
|
|
5
|
+
* - Tries JSON first regardless of content-type
|
|
6
|
+
* - Falls back to text and optionally parses when it "looks" like JSON
|
|
7
|
+
*/
|
|
8
|
+
export async function readBody<T extends Response | Request>(r: T): Promise<unknown> {
|
|
9
|
+
// skip GET/HEAD requests (unchanged)
|
|
10
|
+
const method = "method" in r ? r.method.toUpperCase() : undefined;
|
|
11
|
+
if (method === "GET" || method === "HEAD") {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// no body at all → undefined (unchanged)
|
|
16
|
+
if (!("body" in r) || r.body == null) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 1) try JSON (unchanged)
|
|
21
|
+
try {
|
|
22
|
+
return await r.clone().json();
|
|
23
|
+
} catch {
|
|
24
|
+
// 2) try text (unchanged + your whitespace/JSON-heuristic)
|
|
25
|
+
try {
|
|
26
|
+
const text = await r.clone().text();
|
|
27
|
+
const trimmed = text.trim();
|
|
28
|
+
|
|
29
|
+
if (trimmed.length === 0) return text;
|
|
30
|
+
|
|
31
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(trimmed);
|
|
34
|
+
} catch {
|
|
35
|
+
return text;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return text;
|
|
39
|
+
} catch {
|
|
40
|
+
// 3) FINAL FALLBACK: manual read that accepts string or bytes
|
|
41
|
+
try {
|
|
42
|
+
const c = r.clone();
|
|
43
|
+
const stream: ReadableStream | null = c.body ?? null;
|
|
44
|
+
if (!stream) return undefined;
|
|
45
|
+
|
|
46
|
+
const reader = stream.getReader();
|
|
47
|
+
const decoder = new TextDecoder();
|
|
48
|
+
let out = "";
|
|
49
|
+
|
|
50
|
+
while (true) {
|
|
51
|
+
const { done, value } = await reader.read();
|
|
52
|
+
if (done) break;
|
|
53
|
+
if (typeof value === "string") {
|
|
54
|
+
out += value; // accept string chunks
|
|
55
|
+
} else {
|
|
56
|
+
out += decoder.decode(value, { stream: true }); // bytes
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
out += decoder.decode(); // flush
|
|
60
|
+
|
|
61
|
+
const trimmed = out.trim();
|
|
62
|
+
if (trimmed.length === 0) return out;
|
|
63
|
+
|
|
64
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
65
|
+
try {
|
|
66
|
+
return JSON.parse(trimmed);
|
|
67
|
+
} catch {
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
} catch {
|
|
73
|
+
return undefined; // same "give up" behavior you had
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type MaybePromise<T> = T | PromiseLike<T>;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* More specific utility for records with at least one key
|
|
5
|
+
*/
|
|
6
|
+
export type NonEmptyRecord<T> =
|
|
7
|
+
T extends Record<string, unknown> ? (keyof T extends never ? never : T) : never;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Type representing an agent's basic information
|
|
11
|
+
*/
|
|
12
|
+
export interface AgentDescription {
|
|
13
|
+
name: string;
|
|
14
|
+
className: string;
|
|
15
|
+
description: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface RuntimeInfo {
|
|
19
|
+
version: string;
|
|
20
|
+
agents: Record<string, AgentDescription>;
|
|
21
|
+
audioFileTranscriptionEnabled: boolean;
|
|
22
|
+
}
|
|
File without changes
|