@copilotkit/shared 1.55.0-next.9 → 1.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -1
- package/dist/a2ui-prompts.cjs +106 -0
- package/dist/a2ui-prompts.cjs.map +1 -0
- package/dist/a2ui-prompts.d.cts +20 -0
- package/dist/a2ui-prompts.d.cts.map +1 -0
- package/dist/a2ui-prompts.d.mts +20 -0
- package/dist/a2ui-prompts.d.mts.map +1 -0
- package/dist/a2ui-prompts.mjs +104 -0
- package/dist/a2ui-prompts.mjs.map +1 -0
- package/dist/attachments/types.d.cts +54 -0
- package/dist/attachments/types.d.cts.map +1 -0
- package/dist/attachments/types.d.mts +54 -0
- package/dist/attachments/types.d.mts.map +1 -0
- package/dist/attachments/utils.cjs +134 -0
- package/dist/attachments/utils.cjs.map +1 -0
- package/dist/attachments/utils.d.cts +42 -0
- package/dist/attachments/utils.d.cts.map +1 -0
- package/dist/attachments/utils.d.mts +42 -0
- package/dist/attachments/utils.d.mts.map +1 -0
- package/dist/attachments/utils.mjs +126 -0
- package/dist/attachments/utils.mjs.map +1 -0
- package/dist/index.cjs +29 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +20 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +19 -3
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +259 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/types/message.d.cts +15 -4
- package/dist/types/message.d.cts.map +1 -1
- package/dist/types/message.d.mts +15 -4
- package/dist/types/message.d.mts.map +1 -1
- package/dist/utils/types.cjs.map +1 -1
- package/dist/utils/types.d.cts +1 -0
- package/dist/utils/types.d.cts.map +1 -1
- package/dist/utils/types.d.mts +1 -0
- package/dist/utils/types.d.mts.map +1 -1
- package/dist/utils/types.mjs.map +1 -1
- package/package.json +33 -34
- package/src/a2ui-prompts.ts +101 -0
- package/src/attachments/__tests__/utils.test.ts +198 -0
- package/src/attachments/index.ts +19 -0
- package/src/attachments/types.ts +67 -0
- package/src/attachments/utils.ts +164 -0
- package/src/index.ts +43 -1
- package/src/types/__tests__/message.test.ts +62 -0
- package/src/types/message.ts +27 -3
- package/src/utils/types.ts +1 -0
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./utils";
|
|
|
3
3
|
export * from "./constants";
|
|
4
4
|
export * from "./telemetry";
|
|
5
5
|
export * from "./standard-schema";
|
|
6
|
+
export * from "./attachments";
|
|
6
7
|
|
|
7
8
|
export { logger } from "./logger";
|
|
8
9
|
export { finalizeRunEvents } from "./finalize-events";
|
|
@@ -16,4 +17,45 @@ export {
|
|
|
16
17
|
import * as packageJson from "../package.json";
|
|
17
18
|
export const COPILOTKIT_VERSION = packageJson.version;
|
|
18
19
|
|
|
19
|
-
export
|
|
20
|
+
// Re-export only types from license-verifier (types are erased at compile time,
|
|
21
|
+
// so they don't pull in the Node-only `crypto` dependency into client bundles).
|
|
22
|
+
// Server-side packages (e.g. @copilotkit/runtime) should import runtime functions
|
|
23
|
+
// like createLicenseChecker and getLicenseWarningHeader directly from
|
|
24
|
+
// @copilotkit/license-verifier.
|
|
25
|
+
export type {
|
|
26
|
+
LicenseContextValue,
|
|
27
|
+
LicenseChecker,
|
|
28
|
+
LicenseStatus,
|
|
29
|
+
LicensePayload,
|
|
30
|
+
LicenseFeatures,
|
|
31
|
+
LicenseTier,
|
|
32
|
+
LicenseOwner,
|
|
33
|
+
LicenseMode,
|
|
34
|
+
} from "@copilotkit/license-verifier";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Client-safe license context factory.
|
|
38
|
+
*
|
|
39
|
+
* When status is null (no token provided), all features return true
|
|
40
|
+
* (unlicensed = unrestricted, with branding). This is inlined here to
|
|
41
|
+
* avoid importing the full license-verifier bundle (which depends on
|
|
42
|
+
* Node's `crypto`) into browser bundles.
|
|
43
|
+
*/
|
|
44
|
+
export function createLicenseContextValue(status: null): {
|
|
45
|
+
status: null;
|
|
46
|
+
license: null;
|
|
47
|
+
checkFeature: (feature: string) => boolean;
|
|
48
|
+
getLimit: (feature: string) => number | null;
|
|
49
|
+
} {
|
|
50
|
+
return {
|
|
51
|
+
status: null,
|
|
52
|
+
license: null,
|
|
53
|
+
checkFeature: () => true,
|
|
54
|
+
getLimit: () => null,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
A2UI_DEFAULT_GENERATION_GUIDELINES,
|
|
60
|
+
A2UI_DEFAULT_DESIGN_GUIDELINES,
|
|
61
|
+
} from "./a2ui-prompts";
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import type {
|
|
3
|
+
UserMessage,
|
|
4
|
+
InputContent,
|
|
5
|
+
TextInputPart,
|
|
6
|
+
ImageInputPart,
|
|
7
|
+
AudioInputPart,
|
|
8
|
+
VideoInputPart,
|
|
9
|
+
DocumentInputPart,
|
|
10
|
+
InputContentSource,
|
|
11
|
+
InputContentDataSource,
|
|
12
|
+
InputContentUrlSource,
|
|
13
|
+
} from "../message";
|
|
14
|
+
|
|
15
|
+
describe("shared message types", () => {
|
|
16
|
+
it("UserMessage content accepts string", () => {
|
|
17
|
+
const msg: UserMessage = { id: "1", role: "user", content: "hello" };
|
|
18
|
+
expect(msg.content).toBe("hello");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("UserMessage content accepts InputContent[]", () => {
|
|
22
|
+
const msg: UserMessage = {
|
|
23
|
+
id: "1",
|
|
24
|
+
role: "user",
|
|
25
|
+
content: [
|
|
26
|
+
{ type: "text", text: "hello" },
|
|
27
|
+
{
|
|
28
|
+
type: "image",
|
|
29
|
+
source: { type: "data", value: "base64...", mimeType: "image/png" },
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
expect(Array.isArray(msg.content)).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("InputContent union covers all modalities", () => {
|
|
37
|
+
const parts: InputContent[] = [
|
|
38
|
+
{ type: "text", text: "hi" },
|
|
39
|
+
{
|
|
40
|
+
type: "image",
|
|
41
|
+
source: { type: "url", value: "https://example.com/img.png" },
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: "audio",
|
|
45
|
+
source: { type: "data", value: "base64...", mimeType: "audio/mp3" },
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: "video",
|
|
49
|
+
source: { type: "data", value: "base64...", mimeType: "video/mp4" },
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
type: "document",
|
|
53
|
+
source: {
|
|
54
|
+
type: "data",
|
|
55
|
+
value: "base64...",
|
|
56
|
+
mimeType: "application/pdf",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
expect(parts).toHaveLength(5);
|
|
61
|
+
});
|
|
62
|
+
});
|
package/src/types/message.ts
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import * as agui from "@ag-ui/core";
|
|
2
2
|
|
|
3
|
+
// Re-export AG-UI multimodal input types.
|
|
4
|
+
// Note: AG-UI names the text variant TextInputContent; we export it as TextInputPart for consistency.
|
|
5
|
+
export type {
|
|
6
|
+
InputContent,
|
|
7
|
+
InputContentSource,
|
|
8
|
+
InputContentDataSource,
|
|
9
|
+
InputContentUrlSource,
|
|
10
|
+
TextInputContent as TextInputPart,
|
|
11
|
+
ImageInputPart,
|
|
12
|
+
AudioInputPart,
|
|
13
|
+
VideoInputPart,
|
|
14
|
+
DocumentInputPart,
|
|
15
|
+
} from "@ag-ui/core";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `InputContentSource` from `@ag-ui/core` (re-exported from `@copilotkit/shared`) instead.
|
|
19
|
+
* `ImageData` only described base64 image payloads. `InputContentSource` supports
|
|
20
|
+
* data and URL sources for images, audio, video, and documents.
|
|
21
|
+
* See https://docs.copilotkit.ai/migration-guides/migrate-attachments
|
|
22
|
+
* @since 1.56.0
|
|
23
|
+
*/
|
|
3
24
|
export interface ImageData {
|
|
4
25
|
format: string;
|
|
5
26
|
bytes: string;
|
|
@@ -23,13 +44,16 @@ export type AIMessage = agui.AssistantMessage & {
|
|
|
23
44
|
generativeUIPosition?: "before" | "after";
|
|
24
45
|
agentName?: string;
|
|
25
46
|
state?: any;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use multimodal `content` array with `InputContent` parts instead.
|
|
49
|
+
* See https://docs.copilotkit.ai/migration-guides/migrate-attachments
|
|
50
|
+
* @since 1.56.0
|
|
51
|
+
*/
|
|
26
52
|
image?: ImageData;
|
|
27
53
|
runId?: string;
|
|
28
54
|
};
|
|
29
55
|
|
|
30
|
-
export type UserMessage = agui.UserMessage
|
|
31
|
-
image?: ImageData;
|
|
32
|
-
};
|
|
56
|
+
export type UserMessage = agui.UserMessage;
|
|
33
57
|
|
|
34
58
|
export type Message =
|
|
35
59
|
| AIMessage
|