@copilotkit/channels-discord 0.10.0 → 0.11.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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=built-in-tools-schema.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"built-in-tools-schema.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/built-in-tools-schema.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The `lookup_discord_user` parameter schema used to be a Zod object. It is
3
+ * now built by `singleStringParameterSchema` from `@copilotkit/channels-core`,
4
+ * so that `@copilotkit/channels-discord` declares no `zod` dependency (PE-30).
5
+ *
6
+ * These tests pin the two things the agent actually depends on, and they go
7
+ * through the real `channels-core` entry points rather than poking at
8
+ * `~standard` directly:
9
+ *
10
+ * - `toAgentToolDescriptors` — the JSON Schema the model is shown.
11
+ * - `parseToolArgs` — the validation a tool call is put through.
12
+ *
13
+ * They were written against the Zod implementation and passed unchanged after
14
+ * the migration, which is what makes them evidence that the descriptor did
15
+ * not move.
16
+ */
17
+ import { describe, it, expect } from "vitest";
18
+ import { toAgentToolDescriptors, parseToolArgs, } from "@copilotkit/channels-core";
19
+ import { lookupDiscordUserTool } from "../built-in-tools.js";
20
+ describe("lookup_discord_user parameter schema", () => {
21
+ it("emits the same JSON Schema the Zod object emitted", () => {
22
+ const [descriptor] = toAgentToolDescriptors([lookupDiscordUserTool]);
23
+ expect(descriptor).toBeDefined();
24
+ expect(descriptor?.name).toBe("lookup_discord_user");
25
+ // Captured from `zodToJsonSchema(z.object({query: z.string().min(1)
26
+ // .describe(...)}), {$refStrategy: "none"})` against zod 3.25.76 —
27
+ // the exact document this schema replaces.
28
+ expect(descriptor?.parameters).toEqual({
29
+ type: "object",
30
+ properties: {
31
+ query: {
32
+ type: "string",
33
+ minLength: 1,
34
+ description: "A name, display name, or handle to resolve.",
35
+ },
36
+ },
37
+ required: ["query"],
38
+ additionalProperties: false,
39
+ $schema: "http://json-schema.org/draft-07/schema#",
40
+ });
41
+ });
42
+ it("accepts a valid query", async () => {
43
+ const r = await parseToolArgs(lookupDiscordUserTool.parameters, {
44
+ query: "ada",
45
+ });
46
+ expect(r).toEqual({ ok: true, value: { query: "ada" } });
47
+ });
48
+ it("strips unknown keys instead of rejecting them, as z.object did", async () => {
49
+ const r = await parseToolArgs(lookupDiscordUserTool.parameters, {
50
+ query: "ada",
51
+ extra: "ignored",
52
+ });
53
+ expect(r).toEqual({ ok: true, value: { query: "ada" } });
54
+ });
55
+ it("rejects a missing query, naming the field in the error", async () => {
56
+ const r = await parseToolArgs(lookupDiscordUserTool.parameters, {});
57
+ expect(r.ok).toBe(false);
58
+ expect(r.ok === false && r.error).toContain("query");
59
+ });
60
+ it("rejects a non-string query", async () => {
61
+ const r = await parseToolArgs(lookupDiscordUserTool.parameters, {
62
+ query: 42,
63
+ });
64
+ expect(r.ok).toBe(false);
65
+ expect(r.ok === false && r.error).toContain("query");
66
+ });
67
+ it("rejects an empty query, which is what .min(1) guarded", async () => {
68
+ const r = await parseToolArgs(lookupDiscordUserTool.parameters, {
69
+ query: "",
70
+ });
71
+ expect(r.ok).toBe(false);
72
+ });
73
+ it("rejects a non-object argument payload", async () => {
74
+ const r = await parseToolArgs(lookupDiscordUserTool.parameters, null);
75
+ expect(r.ok).toBe(false);
76
+ });
77
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"built-in-tools.d.ts","sourceRoot":"","sources":["../src/built-in-tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,eAAO,MAAM,qBAAqB,EAAE,WAsBlC,CAAC;AAEH,eAAO,MAAM,mBAAmB,EAAE,WAAW,EAA4B,CAAC"}
1
+ {"version":3,"file":"built-in-tools.d.ts","sourceRoot":"","sources":["../src/built-in-tools.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAe7D,eAAO,MAAM,qBAAqB,EAAE,WAiBlC,CAAC;AAEH,eAAO,MAAM,mBAAmB,EAAE,WAAW,EAA4B,CAAC"}
@@ -1,15 +1,21 @@
1
- import { z } from "zod";
2
- import { defineChannelTool } from "@copilotkit/channels-core";
1
+ import { defineChannelTool, singleStringParameterSchema, } from "@copilotkit/channels-core";
2
+ /**
3
+ * Parameter schema for `lookup_discord_user`.
4
+ *
5
+ * Built by `singleStringParameterSchema` rather than by `z.object`, so that
6
+ * `@copilotkit/channels-discord` declares no `zod` range. See that helper for
7
+ * why the range was not free (PE-30). It emits the same JSON Schema document
8
+ * the Zod object emitted, so the descriptor the model is shown is unchanged.
9
+ */
10
+ const lookupSchema = singleStringParameterSchema({
11
+ name: "query",
12
+ description: "A name, display name, or handle to resolve.",
13
+ });
3
14
  export const lookupDiscordUserTool = defineChannelTool({
4
15
  name: "lookup_discord_user",
5
16
  description: "Resolve a person's name, display name, or handle to a Discord user id and a " +
6
17
  "ready-to-use <@id> mention.",
7
- parameters: z.object({
8
- query: z
9
- .string()
10
- .min(1)
11
- .describe("A name, display name, or handle to resolve."),
12
- }),
18
+ parameters: lookupSchema,
13
19
  async handler({ query }, { thread }) {
14
20
  let user;
15
21
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkit/channels-discord",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Discord PlatformAdapter for @copilotkit/channels.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -35,9 +35,8 @@
35
35
  "dependencies": {
36
36
  "@ag-ui/client": "0.0.59",
37
37
  "discord.js": "^14.16.0",
38
- "zod": "^3.25.76",
39
- "@copilotkit/channels-core": "^0.10.0",
40
- "@copilotkit/channels-ui": "^0.10.0"
38
+ "@copilotkit/channels-core": "^0.11.0",
39
+ "@copilotkit/channels-ui": "^0.11.0"
41
40
  },
42
41
  "devDependencies": {
43
42
  "@types/node": "^22.10.0",