From 3656d6a5e69eaabecf11bd51c2f6c672c8d9423d Mon Sep 17 00:00:00 2001 From: twlite <46562212+twlite@users.noreply.github.com> Date: Sun, 24 Aug 2025 10:26:49 +0545 Subject: [PATCH 1/2] feat!: ai sdk 5 --- apps/test-bot/package.json | 4 +- packages/ai/package.json | 6 +- packages/ai/src/plugin.ts | 31 ++- packages/ai/src/tools/common/index.ts | 12 +- .../ai/src/tools/get-available-commands.ts | 2 +- packages/ai/src/tools/get-channel-by-id.ts | 2 +- .../ai/src/tools/get-current-client-info.ts | 2 +- packages/ai/src/tools/get-guild-by-id.ts | 2 +- packages/ai/src/tools/get-user-by-id.ts | 2 +- packages/ai/src/types.ts | 2 +- pnpm-lock.yaml | 195 +++++++----------- 11 files changed, 110 insertions(+), 150 deletions(-) diff --git a/apps/test-bot/package.json b/apps/test-bot/package.json index f64bb21c..1ef7141f 100644 --- a/apps/test-bot/package.json +++ b/apps/test-bot/package.json @@ -10,7 +10,7 @@ "node": "node" }, "dependencies": { - "@ai-sdk/google": "^1.2.19", + "@ai-sdk/google": "^2.0.8", "@commandkit/ai": "workspace:*", "@commandkit/cache": "workspace:*", "@commandkit/devtools": "workspace:*", @@ -27,4 +27,4 @@ "@types/ms": "^2.1.0", "tsx": "^4.7.0" } -} +} \ No newline at end of file diff --git a/packages/ai/package.json b/packages/ai/package.json index ed7b1704..e4d3d6a9 100644 --- a/packages/ai/package.json +++ b/packages/ai/package.json @@ -35,7 +35,7 @@ "typescript": "catalog:build" }, "dependencies": { - "ai": "^4.3.16", - "zod": "^3.25.48" + "ai": "^5.0.22", + "zod": "^4.1.0" } -} +} \ No newline at end of file diff --git a/packages/ai/src/plugin.ts b/packages/ai/src/plugin.ts index f2c73032..37a9f8c2 100644 --- a/packages/ai/src/plugin.ts +++ b/packages/ai/src/plugin.ts @@ -3,15 +3,16 @@ import { AiPluginOptions, CommandTool } from './types'; import CommandKit, { getCommandKit, Logger } from 'commandkit'; import { AiContext } from './context'; import { Collection, Events, Message } from 'discord.js'; -import { tool, Tool, generateText } from 'ai'; +import { tool, Tool, generateText, stepCountIs, ModelMessage } from 'ai'; import { getAiWorkerContext, runInAiWorkerContext } from './ai-context-worker'; import { getAvailableCommands } from './tools/get-available-commands'; import { getChannelById } from './tools/get-channel-by-id'; import { getCurrentClientInfo } from './tools/get-current-client-info'; import { getGuildById } from './tools/get-guild-by-id'; import { getUserById } from './tools/get-user-by-id'; -import { AiMessage, getAIConfig } from './configure'; +import { getAIConfig } from './configure'; import { augmentCommandKit } from './augmentation'; +import { ToolParameterType } from './tools/common'; /** * Represents the configuration options for the AI plugin scoped to a specific command. @@ -24,7 +25,7 @@ export interface AiConfig { /** * A zod schema defining the parameters that the AI command accepts. */ - parameters: any; + inputSchema: ToolParameterType; } const defaultTools: Record = { @@ -99,11 +100,19 @@ export class AiPlugin extends RuntimePlugin { await runInAiWorkerContext(ctx, message, async () => { const systemPrompt = await prepareSystemPrompt(ctx, message); const prompt = await preparePrompt(ctx, message); - const { model, abortSignal, maxSteps, ...modelOptions } = - await selectAiModel(ctx, message); - - const promptOrMessage = - typeof prompt === 'string' ? { prompt } : { messages: prompt }; + const { + model, + abortSignal, + stopWhen, + prompt: _prompt, + ...modelOptions + } = await selectAiModel(ctx, message); + + const promptOrMessage = ( + typeof prompt === 'string' ? { prompt } : { messages: prompt } + ) as + | { prompt: string; messages: never } + | { messages: ModelMessage[]; prompt: never }; await onProcessingStart(ctx, message); @@ -112,7 +121,7 @@ export class AiPlugin extends RuntimePlugin { model, abortSignal: abortSignal ?? AbortSignal.timeout(60_000), system: systemPrompt, - maxSteps: maxSteps ?? 5, + stopWhen: stopWhen ?? stepCountIs(5), ...modelOptions, tools: { // Include built-in least significant tools if not disabled @@ -181,12 +190,12 @@ export class AiPlugin extends RuntimePlugin { const cmdTool = tool({ description, - parameters: cmd.data.aiConfig.parameters, + inputSchema: cmd.data.aiConfig.inputSchema, async execute(params) { const config = getAIConfig(); const ctx = getAiWorkerContext(); - ctx.ctx.setParams(params); + ctx.ctx.setParams(params as Record); try { const target = await commandkit.commandHandler.prepareCommandRun( diff --git a/packages/ai/src/tools/common/index.ts b/packages/ai/src/tools/common/index.ts index 69e1c3f7..e54108be 100644 --- a/packages/ai/src/tools/common/index.ts +++ b/packages/ai/src/tools/common/index.ts @@ -14,7 +14,7 @@ type Awaitable = T | Promise; * Type representing the parameters schema for AI tools. * Extracted from the first parameter of the `tool` function from the 'ai' library. */ -export type ToolParameterType = Parameters[0]['parameters']; +export type ToolParameterType = z.ZodType | Schema; /** * Utility type that infers the TypeScript type from a tool parameter schema. @@ -39,7 +39,7 @@ export interface CreateToolOptions { /** A human-readable description of what the tool does */ description: string; /** The parameter schema that defines the tool's input structure */ - parameters: T; + inputSchema: T; /** The function that executes when the tool is called */ execute: ToolExecuteFunction; } @@ -49,12 +49,12 @@ export interface CreateToolOptions { * @template T - The parameter schema type * @template R - The return type of the function * @param ctx - The AI context containing request and response information - * @param parameters - The validated parameters passed to the tool + * @param inputSchema - The validated inputSchema passed to the tool * @returns The result of the tool execution, which can be synchronous or asynchronous */ export type ToolExecuteFunction = ( ctx: AiContext, - parameters: InferParameters, + inputSchema: InferParameters, ) => Awaitable; /** @@ -92,11 +92,11 @@ export function createTool( const _tool = tool({ name: options.name, description: options.description, - parameters: options.parameters, + inputSchema: options.inputSchema, async execute(params) { const { ctx } = getAiWorkerContext(); - ctx.setParams(params); + ctx.setParams(params as Record); return options.execute(ctx, params as InferParameters); }, diff --git a/packages/ai/src/tools/get-available-commands.ts b/packages/ai/src/tools/get-available-commands.ts index 7963b1f5..16a23313 100644 --- a/packages/ai/src/tools/get-available-commands.ts +++ b/packages/ai/src/tools/get-available-commands.ts @@ -4,7 +4,7 @@ import { createTool } from './common'; export const getAvailableCommands = createTool({ description: 'Get a list of all available commands.', name: 'getAvailableCommands', - parameters: z.object({}), + inputSchema: z.object({}), execute(ctx, params) { const { commandkit } = ctx; diff --git a/packages/ai/src/tools/get-channel-by-id.ts b/packages/ai/src/tools/get-channel-by-id.ts index 36bea802..f8d479cd 100644 --- a/packages/ai/src/tools/get-channel-by-id.ts +++ b/packages/ai/src/tools/get-channel-by-id.ts @@ -5,7 +5,7 @@ import { Logger } from 'commandkit'; export const getChannelById = createTool({ description: 'Get a channel by its ID.', name: 'getChannelById', - parameters: z.object({ + inputSchema: z.object({ channelId: z.string().describe('The ID of the channel to retrieve.'), }), async execute(ctx, params) { diff --git a/packages/ai/src/tools/get-current-client-info.ts b/packages/ai/src/tools/get-current-client-info.ts index 7916904f..00052d91 100644 --- a/packages/ai/src/tools/get-current-client-info.ts +++ b/packages/ai/src/tools/get-current-client-info.ts @@ -4,7 +4,7 @@ import { createTool } from './common'; export const getCurrentClientInfo = createTool({ name: 'getCurrentClientInfo', description: 'Get information about the current discord bot user', - parameters: z.object({}), + inputSchema: z.object({}), execute: async (ctx, params) => { const { client } = ctx; const user = client.user; diff --git a/packages/ai/src/tools/get-guild-by-id.ts b/packages/ai/src/tools/get-guild-by-id.ts index 323e949d..051f4007 100644 --- a/packages/ai/src/tools/get-guild-by-id.ts +++ b/packages/ai/src/tools/get-guild-by-id.ts @@ -5,7 +5,7 @@ import { Logger } from 'commandkit'; export const getGuildById = createTool({ description: 'Get a guild by its ID.', name: 'getGuildById', - parameters: z.object({ + inputSchema: z.object({ guildId: z.string().describe('The ID of the guild to retrieve.'), }), async execute(ctx, params) { diff --git a/packages/ai/src/tools/get-user-by-id.ts b/packages/ai/src/tools/get-user-by-id.ts index 04fe0cda..a98975c1 100644 --- a/packages/ai/src/tools/get-user-by-id.ts +++ b/packages/ai/src/tools/get-user-by-id.ts @@ -5,7 +5,7 @@ import { Logger } from 'commandkit'; export const getUserById = createTool({ description: 'Get a user by their ID.', name: 'getUserById', - parameters: z.object({ + inputSchema: z.object({ userId: z.string().describe('The ID of the user to retrieve.'), }), async execute(ctx, params) { diff --git a/packages/ai/src/types.ts b/packages/ai/src/types.ts index d928db51..85cb361f 100644 --- a/packages/ai/src/types.ts +++ b/packages/ai/src/types.ts @@ -44,7 +44,7 @@ export interface AiPluginOptions {} * Extracts the AI configuration params. */ export type ExtractAiConfig> = - T extends AiConfig ? InferParameters : T; + T extends AiConfig ? InferParameters : T; /** * Represents the context in which an AI command is executed. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 954b9c2d..5d0256e9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -74,8 +74,8 @@ importers: apps/test-bot: dependencies: '@ai-sdk/google': - specifier: ^1.2.19 - version: 1.2.22(zod@3.25.76) + specifier: ^2.0.8 + version: 2.0.8(zod@3.25.76) '@commandkit/ai': specifier: workspace:* version: link:../../packages/ai @@ -187,11 +187,11 @@ importers: packages/ai: dependencies: ai: - specifier: ^4.3.16 - version: 4.3.19(react@19.1.1)(zod@3.25.76) + specifier: ^5.0.22 + version: 5.0.22(zod@4.1.0) zod: - specifier: ^3.25.48 - version: 3.25.76 + specifier: ^4.1.0 + version: 4.1.0 devDependencies: commandkit: specifier: workspace:* @@ -641,37 +641,27 @@ importers: packages: - '@ai-sdk/google@1.2.22': - resolution: {integrity: sha512-Ppxu3DIieF1G9pyQ5O1Z646GYR0gkC57YdBqXJ82qvCdhEhZHu0TWhmnOoeIWe2olSbuDeoOY+MfJrW8dzS3Hw==} + '@ai-sdk/gateway@1.0.11': + resolution: {integrity: sha512-ErwWS3sPOuWy42eE3AVxlKkTa1XjjKBEtNCOylVKMO5KNyz5qie8QVlLYbULOG56dtxX4zTKX3rQNJudplhcmQ==} engines: {node: '>=18'} peerDependencies: - zod: ^3.0.0 + zod: ^3.25.76 || ^4 - '@ai-sdk/provider-utils@2.2.8': - resolution: {integrity: sha512-fqhG+4sCVv8x7nFzYnFo19ryhAa3w096Kmc3hWxMQfW/TubPOmt3A6tYZhl4mUfQWWQMsuSkLrtjlWuXBVSGQA==} + '@ai-sdk/google@2.0.8': + resolution: {integrity: sha512-k+5SLtoV0qG4rSCxwWQ+/0qrJFXwYHQ1TcH4GyaP4X0qOuVS4NDtD8ymSu8ej0ejFluogtBfTLev7sbj2AnJzA==} engines: {node: '>=18'} peerDependencies: - zod: ^3.23.8 - - '@ai-sdk/provider@1.1.3': - resolution: {integrity: sha512-qZMxYJ0qqX/RfnuIaab+zp8UAeJn/ygXXAffR5I4N0n1IrvA6qBsjc8hXLmBiMV2zoXlifkacF7sEFnYnjBcqg==} - engines: {node: '>=18'} + zod: ^3.25.76 || ^4 - '@ai-sdk/react@1.2.12': - resolution: {integrity: sha512-jK1IZZ22evPZoQW3vlkZ7wvjYGYF+tRBKXtrcolduIkQ/m/sOAVcVeVDUDvh1T91xCnWCdUGCPZg2avZ90mv3g==} + '@ai-sdk/provider-utils@3.0.5': + resolution: {integrity: sha512-HliwB/yzufw3iwczbFVE2Fiwf1XqROB/I6ng8EKUsPM5+2wnIa8f4VbljZcDx+grhFrPV+PnRZH7zBqi8WZM7Q==} engines: {node: '>=18'} peerDependencies: - react: ^18 || ^19 || ^19.0.0-rc - zod: ^3.23.8 - peerDependenciesMeta: - zod: - optional: true + zod: ^3.25.76 || ^4 - '@ai-sdk/ui-utils@1.2.11': - resolution: {integrity: sha512-3zcwCc8ezzFlwp3ZD15wAPjf2Au4s3vAbKsXQVyhxODHcmu0iyPO2Eua6D/vicq/AUm/BAo60r97O6HU+EI0+w==} + '@ai-sdk/provider@2.0.0': + resolution: {integrity: sha512-6o7Y2SeO9vFKB8lArHXehNuusnpddKPk7xqL7T2/b+OvXMRIXUO1rR4wcv1hAFUAT9avGZshty3Wlua/XA7TvA==} engines: {node: '>=18'} - peerDependencies: - zod: ^3.23.8 '@algolia/autocomplete-core@1.17.9': resolution: {integrity: sha512-O7BxrpLDPJWWHv/DLA9DRFWs+iY1uOJZkqUwjS5HSZAGcl0hIVCQ97LTLewiZmZ402JYUrun+8NqFP+hCknlbQ==} @@ -1337,10 +1327,6 @@ packages: resolution: {integrity: sha512-LKYxD2CIfocUFNREQ1yk+dW+8OH8CRqmgatBZYXb+XhuObO8wsDpEoCNri5bKld9cnj8xukqZjxSX8p1YiRF8Q==} engines: {node: '>=6.9.0'} - '@babel/runtime@7.28.2': - resolution: {integrity: sha512-KHp2IflsnGywDjBWDkR9iEqiWSpc8GIi0lgTT3mOElT0PP1tG26P4tmFI2YvAdzgq9RGyoHZQEIEdZy6Ec5xCA==} - engines: {node: '>=6.9.0'} - '@babel/runtime@7.28.3': resolution: {integrity: sha512-9uIQ10o0WGdpP6GDhXcdOJPJuDgFtIDtN/9+ArJQ2NAfAmiuhTQdzkaTGR33v43GYS2UrSA0eX2pPPHoFVvpxA==} engines: {node: '>=6.9.0'} @@ -3329,6 +3315,9 @@ packages: '@slorber/remark-comment@1.0.0': resolution: {integrity: sha512-RCE24n7jsOj1M0UPvIQCHTe7fI0sFL4S2nwKVWwHyVr/wI/H8GosgsJGyhnsZoGFnD/P2hLf1mSbrrgSLN93NA==} + '@standard-schema/spec@1.0.0': + resolution: {integrity: sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==} + '@standard-schema/utils@0.3.0': resolution: {integrity: sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==} @@ -3828,9 +3817,6 @@ packages: '@types/deep-eql@4.0.2': resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} - '@types/diff-match-patch@1.0.36': - resolution: {integrity: sha512-xFdR6tkm0MWvBfO8xXCSsinYxHcqkQUlcHeSpMC2ukzOb6lwQAfDmW+Qt0AvlGd8HpsS28qKsB+oPeJn9I39jg==} - '@types/eslint-scope@3.7.7': resolution: {integrity: sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==} @@ -4202,15 +4188,11 @@ packages: resolution: {integrity: sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==} engines: {node: '>=8'} - ai@4.3.19: - resolution: {integrity: sha512-dIE2bfNpqHN3r6IINp9znguYdhIOheKW2LDigAMrgt/upT3B8eBGPSCblENvaZGoq+hxaN9fSMzjWpbqloP+7Q==} + ai@5.0.22: + resolution: {integrity: sha512-RZiYhj7Ux7hrLtXkHPcxzdiSZt4NOiC69O5AkNfMCsz3twwz/KRkl9ASptosoOsg833s5yRcTSdIu5z53Sl6Pw==} engines: {node: '>=18'} peerDependencies: - react: ^18 || ^19 || ^19.0.0-rc - zod: ^3.23.8 - peerDependenciesMeta: - react: - optional: true + zod: ^3.25.76 || ^4 ajv-formats@2.1.1: resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} @@ -5261,9 +5243,6 @@ packages: didyoumean@1.2.2: resolution: {integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==} - diff-match-patch@1.0.5: - resolution: {integrity: sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==} - diff@4.0.2: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} @@ -5591,6 +5570,10 @@ packages: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} + eventsource-parser@3.0.5: + resolution: {integrity: sha512-bSRG85ZrMdmWtm7qkF9He9TNRzc/Bm99gEJMaQoHJ9E6Kv9QBbsldh2oMj7iXmYNEAVvNgvv5vPorG6W+XtBhQ==} + engines: {node: '>=20.0.0'} + execa@5.1.1: resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} engines: {node: '>=10'} @@ -6453,11 +6436,6 @@ packages: engines: {node: '>=6'} hasBin: true - jsondiffpatch@0.6.0: - resolution: {integrity: sha512-3QItJOXp2AP1uv7waBkao5nCvhEv+QmJAd38Ybq7wNI74Q+BBmnLn4EDKz6yI9xGAIQoUF87qHt+kc1IVxB4zQ==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - jsonfile@6.1.0: resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} @@ -8369,9 +8347,6 @@ packages: resolution: {integrity: sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==} engines: {node: '>=4'} - secure-json-parse@2.7.0: - resolution: {integrity: sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==} - select-hose@2.0.0: resolution: {integrity: sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg==} @@ -8698,11 +8673,6 @@ packages: swap-case@1.1.2: resolution: {integrity: sha512-BAmWG6/bx8syfc6qXPprof3Mn5vQgf5dwdUNJhsNqU9WdPt5P+ES/wQ5bxfijy8zwZgZZHslC3iAsxsuQMCzJQ==} - swr@2.3.4: - resolution: {integrity: sha512-bYd2lrhc+VarcpkgWclcUi92wYCpOgMws9Sd1hG1ntAu0NEy+14CbotuFjshBU2kt9rYj9TSmDcybpxpeTU1fg==} - peerDependencies: - react: ^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 - tailwind-merge@3.3.1: resolution: {integrity: sha512-gBXpgUm/3rp1lMZZrM/w7D8GKqshif0zAymAhbCyIt8KMe+0v9DQ7cdYLR4FHH/cKpdTXb+A/tKKU3eolfsI+g==} @@ -8756,10 +8726,6 @@ packages: peerDependencies: tslib: ^2 - throttleit@2.1.0: - resolution: {integrity: sha512-nt6AMGKW1p/70DF/hGBdJB57B8Tspmbp5gfJ8ilhLnt7kkr2ye7hzD6NVG8GGErk2HWF34igrL2CXmNIkzKqKw==} - engines: {node: '>=18'} - through@2.3.8: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} @@ -9503,6 +9469,9 @@ packages: zod@3.25.76: resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==} + zod@4.1.0: + resolution: {integrity: sha512-UWxluYj2IDX9MHRXTMbB/2eeWrAMmmMSESM+MfT9MQw8U1qo9q5ASW08anoJh6AJ7pkt099fLdNFmfI+4aChHg==} + zustand@5.0.8: resolution: {integrity: sha512-gyPKpIaxY9XcO2vSMrLbiER7QMAMGOQZVRdJ6Zi782jkbzZygq5GI9nG8g+sMgitRtndwaBSl7uiqC49o1SSiw==} engines: {node: '>=12.20.0'} @@ -9526,39 +9495,37 @@ packages: snapshots: - '@ai-sdk/google@1.2.22(zod@3.25.76)': + '@ai-sdk/gateway@1.0.11(zod@4.1.0)': dependencies: - '@ai-sdk/provider': 1.1.3 - '@ai-sdk/provider-utils': 2.2.8(zod@3.25.76) - zod: 3.25.76 + '@ai-sdk/provider': 2.0.0 + '@ai-sdk/provider-utils': 3.0.5(zod@4.1.0) + zod: 4.1.0 - '@ai-sdk/provider-utils@2.2.8(zod@3.25.76)': + '@ai-sdk/google@2.0.8(zod@3.25.76)': dependencies: - '@ai-sdk/provider': 1.1.3 - nanoid: 3.3.11 - secure-json-parse: 2.7.0 + '@ai-sdk/provider': 2.0.0 + '@ai-sdk/provider-utils': 3.0.5(zod@3.25.76) zod: 3.25.76 - '@ai-sdk/provider@1.1.3': + '@ai-sdk/provider-utils@3.0.5(zod@3.25.76)': dependencies: - json-schema: 0.4.0 + '@ai-sdk/provider': 2.0.0 + '@standard-schema/spec': 1.0.0 + eventsource-parser: 3.0.5 + zod: 3.25.76 + zod-to-json-schema: 3.24.6(zod@3.25.76) - '@ai-sdk/react@1.2.12(react@19.1.1)(zod@3.25.76)': + '@ai-sdk/provider-utils@3.0.5(zod@4.1.0)': dependencies: - '@ai-sdk/provider-utils': 2.2.8(zod@3.25.76) - '@ai-sdk/ui-utils': 1.2.11(zod@3.25.76) - react: 19.1.1 - swr: 2.3.4(react@19.1.1) - throttleit: 2.1.0 - optionalDependencies: - zod: 3.25.76 + '@ai-sdk/provider': 2.0.0 + '@standard-schema/spec': 1.0.0 + eventsource-parser: 3.0.5 + zod: 4.1.0 + zod-to-json-schema: 3.24.6(zod@4.1.0) - '@ai-sdk/ui-utils@1.2.11(zod@3.25.76)': + '@ai-sdk/provider@2.0.0': dependencies: - '@ai-sdk/provider': 1.1.3 - '@ai-sdk/provider-utils': 2.2.8(zod@3.25.76) - zod: 3.25.76 - zod-to-json-schema: 3.24.6(zod@3.25.76) + json-schema: 0.4.0 '@algolia/autocomplete-core@1.17.9(@algolia/client-search@5.19.0)(algoliasearch@5.19.0)(search-insights@2.17.3)': dependencies: @@ -11040,8 +11007,6 @@ snapshots: dependencies: core-js-pure: 3.45.0 - '@babel/runtime@7.28.2': {} - '@babel/runtime@7.28.3': {} '@babel/template@7.27.2': @@ -11491,7 +11456,7 @@ snapshots: '@babel/preset-env': 7.27.2(@babel/core@7.28.0) '@babel/preset-react': 7.27.1(@babel/core@7.28.0) '@babel/preset-typescript': 7.27.1(@babel/core@7.28.0) - '@babel/runtime': 7.28.2 + '@babel/runtime': 7.28.3 '@babel/runtime-corejs3': 7.28.0 '@babel/traverse': 7.28.0 '@docusaurus/logger': 3.8.1 @@ -12042,7 +12007,7 @@ snapshots: '@docusaurus/react-loadable@6.0.0(react@19.1.1)': dependencies: - '@types/react': 19.1.8 + '@types/react': 19.1.11 react: 19.1.1 '@docusaurus/remark-plugin-npm2yarn@3.8.1': @@ -13483,6 +13448,8 @@ snapshots: micromark-util-character: 1.2.0 micromark-util-symbol: 1.1.0 + '@standard-schema/spec@1.0.0': {} + '@standard-schema/utils@0.3.0': {} '@svgr/babel-plugin-add-jsx-attribute@8.0.0(@babel/core@7.28.3)': @@ -14043,8 +14010,6 @@ snapshots: '@types/deep-eql@4.0.2': {} - '@types/diff-match-patch@1.0.36': {} - '@types/eslint-scope@3.7.7': dependencies: '@types/eslint': 9.6.1 @@ -14525,17 +14490,13 @@ snapshots: clean-stack: 2.2.0 indent-string: 4.0.0 - ai@4.3.19(react@19.1.1)(zod@3.25.76): + ai@5.0.22(zod@4.1.0): dependencies: - '@ai-sdk/provider': 1.1.3 - '@ai-sdk/provider-utils': 2.2.8(zod@3.25.76) - '@ai-sdk/react': 1.2.12(react@19.1.1)(zod@3.25.76) - '@ai-sdk/ui-utils': 1.2.11(zod@3.25.76) + '@ai-sdk/gateway': 1.0.11(zod@4.1.0) + '@ai-sdk/provider': 2.0.0 + '@ai-sdk/provider-utils': 3.0.5(zod@4.1.0) '@opentelemetry/api': 1.9.0 - jsondiffpatch: 0.6.0 - zod: 3.25.76 - optionalDependencies: - react: 19.1.1 + zod: 4.1.0 ajv-formats@2.1.1(ajv@8.17.1): optionalDependencies: @@ -15701,8 +15662,6 @@ snapshots: didyoumean@1.2.2: {} - diff-match-patch@1.0.5: {} - diff@4.0.2: {} diff@8.0.2: {} @@ -16115,6 +16074,8 @@ snapshots: events@3.3.0: {} + eventsource-parser@3.0.5: {} + execa@5.1.1: dependencies: cross-spawn: 7.0.6 @@ -16667,7 +16628,7 @@ snapshots: history@4.10.1: dependencies: - '@babel/runtime': 7.28.2 + '@babel/runtime': 7.28.3 loose-envify: 1.4.0 resolve-pathname: 3.0.0 tiny-invariant: 1.3.3 @@ -17131,12 +17092,6 @@ snapshots: json5@2.2.3: {} - jsondiffpatch@0.6.0: - dependencies: - '@types/diff-match-patch': 1.0.36 - chalk: 5.4.1 - diff-match-patch: 1.0.5 - jsonfile@6.1.0: dependencies: universalify: 2.0.1 @@ -19020,7 +18975,7 @@ snapshots: react-loadable-ssr-addon-v5-slorber@1.0.1(@docusaurus/react-loadable@6.0.0(react@19.1.1))(webpack@5.99.9(@swc/core@1.13.0)): dependencies: - '@babel/runtime': 7.28.2 + '@babel/runtime': 7.28.3 react-loadable: '@docusaurus/react-loadable@6.0.0(react@19.1.1)' webpack: 5.99.9(@swc/core@1.13.0) @@ -19056,13 +19011,13 @@ snapshots: react-router-config@5.1.1(react-router@5.3.4(react@19.1.1))(react@19.1.1): dependencies: - '@babel/runtime': 7.28.2 + '@babel/runtime': 7.28.3 react: 19.1.1 react-router: 5.3.4(react@19.1.1) react-router-dom@5.3.4(react@19.1.1): dependencies: - '@babel/runtime': 7.28.2 + '@babel/runtime': 7.28.3 history: 4.10.1 loose-envify: 1.4.0 prop-types: 15.8.1 @@ -19073,7 +19028,7 @@ snapshots: react-router@5.3.4(react@19.1.1): dependencies: - '@babel/runtime': 7.28.2 + '@babel/runtime': 7.28.3 history: 4.10.1 hoist-non-react-statics: 3.3.2 loose-envify: 1.4.0 @@ -19545,8 +19500,6 @@ snapshots: extend-shallow: 2.0.1 kind-of: 6.0.3 - secure-json-parse@2.7.0: {} - select-hose@2.0.0: {} selfsigned@2.4.1: @@ -19936,12 +19889,6 @@ snapshots: lower-case: 1.1.4 upper-case: 1.1.3 - swr@2.3.4(react@19.1.1): - dependencies: - dequal: 2.0.3 - react: 19.1.1 - use-sync-external-store: 1.5.0(react@19.1.1) - tailwind-merge@3.3.1: {} tailwindcss@3.4.17(ts-node@10.9.2(@swc/core@1.13.0)(@types/node@22.17.2)(typescript@5.9.2)): @@ -20014,8 +19961,6 @@ snapshots: dependencies: tslib: 2.8.1 - throttleit@2.1.0: {} - through@2.3.8: {} thunky@1.1.0: {} @@ -20767,8 +20712,14 @@ snapshots: dependencies: zod: 3.25.76 + zod-to-json-schema@3.24.6(zod@4.1.0): + dependencies: + zod: 4.1.0 + zod@3.25.76: {} + zod@4.1.0: {} + zustand@5.0.8(@types/react@19.1.11)(immer@9.0.21)(react@19.1.1)(use-sync-external-store@1.5.0(react@19.1.1)): optionalDependencies: '@types/react': 19.1.11 From fa709288609592b54686ffd670089b12f7abbadb Mon Sep 17 00:00:00 2001 From: twlite <46562212+twlite@users.noreply.github.com> Date: Sun, 24 Aug 2025 10:28:36 +0545 Subject: [PATCH 2/2] chore: deps --- apps/test-bot/package.json | 2 +- .../02-setup-commandkit.mdx | 3 +- .../02-command-options-autocomplete.mdx | 8 +-- .../02-commands/03-context-menu-commands.mdx | 5 +- .../guide/02-commands/05-after-function.mdx | 6 +- .../docs/guide/02-commands/07-middlewares.mdx | 8 +-- .../guide/03-events/01-discordjs-events.mdx | 13 +--- .../guide/04-jsx-components/01-using-jsx.mdx | 7 +-- .../01-action-row.mdx | 12 +--- .../02-discord-components-v1/02-button.mdx | 29 +++------ .../03-select-menu.mdx | 63 ++++--------------- .../02-discord-components-v1/04-modal.mdx | 12 +--- .../01-text-display.mdx | 4 +- .../03-discord-components-v2/02-container.mdx | 42 +++---------- .../03-media-gallery.mdx | 9 +-- .../03-discord-components-v2/04-separator.mdx | 10 +-- .../03-discord-components-v2/05-file.mdx | 4 +- .../05-official-plugins/01-commandkit-ai.mdx | 17 ++--- .../02-commandkit-analytics.mdx | 23 ++----- .../03-commandkit-cache.mdx | 16 ++--- .../05-commandkit-i18n.mdx | 10 +-- .../08-commandkit-tasks.mdx | 15 ++--- .../01-creating-runtime-plugin.mdx | 17 ++--- .../02-creating-compiler-plugin.mdx | 5 +- .../01-setup-commandkit-manually.mdx | 10 +-- .../08-advanced/03-sharding-your-bot.mdx | 17 ++--- .../09-useful-utilities/01-feature-flags.mdx | 36 +++-------- .../02-commandkit-ratelimit.mdx | 15 +---- .../04-commandkit-async-queue.mdx | 4 +- .../09-useful-utilities/05-commandkit-kv.mdx | 14 +---- .../06-commandkit-semaphore.mdx | 18 ++---- .../07-commandkit-queue.mdx | 16 +---- package.json | 10 +-- packages/ai/package.json | 2 +- pnpm-lock.yaml | 28 +++++---- 35 files changed, 133 insertions(+), 377 deletions(-) diff --git a/apps/test-bot/package.json b/apps/test-bot/package.json index 1ef7141f..8ee571c8 100644 --- a/apps/test-bot/package.json +++ b/apps/test-bot/package.json @@ -27,4 +27,4 @@ "@types/ms": "^2.1.0", "tsx": "^4.7.0" } -} \ No newline at end of file +} diff --git a/apps/website/docs/guide/01-getting-started/02-setup-commandkit.mdx b/apps/website/docs/guide/01-getting-started/02-setup-commandkit.mdx index 61385b82..25c7a724 100644 --- a/apps/website/docs/guide/01-getting-started/02-setup-commandkit.mdx +++ b/apps/website/docs/guide/01-getting-started/02-setup-commandkit.mdx @@ -1,7 +1,6 @@ --- title: Setup CommandKit -description: - Setup a new CommandKit project using the create-commandkit CLI +description: Setup a new CommandKit project using the create-commandkit CLI --- :::info diff --git a/apps/website/docs/guide/02-commands/02-command-options-autocomplete.mdx b/apps/website/docs/guide/02-commands/02-command-options-autocomplete.mdx index 7768b225..259f1689 100644 --- a/apps/website/docs/guide/02-commands/02-command-options-autocomplete.mdx +++ b/apps/website/docs/guide/02-commands/02-command-options-autocomplete.mdx @@ -47,9 +47,7 @@ const pets = Array.from({ length: 20 }, (_, i) => ({ value: `petId_${i}`, })); -export const autocomplete: AutocompleteCommand = async ({ - interaction, -}) => { +export const autocomplete: AutocompleteCommand = async ({ interaction }) => { try { // Get the input value of your autocomplete option const input = interaction.options.getString('name', false); @@ -69,9 +67,7 @@ export const autocomplete: AutocompleteCommand = async ({ } }; -export const chatInput: ChatInputCommand = async ({ - interaction, -}) => { +export const chatInput: ChatInputCommand = async ({ interaction }) => { const chosenPetId = interaction.options.getString('name', true); const chosenPet = pets.find((pet) => pet.value === chosenPetId); diff --git a/apps/website/docs/guide/02-commands/03-context-menu-commands.mdx b/apps/website/docs/guide/02-commands/03-context-menu-commands.mdx index a6a9eb53..9194aad0 100644 --- a/apps/website/docs/guide/02-commands/03-context-menu-commands.mdx +++ b/apps/website/docs/guide/02-commands/03-context-menu-commands.mdx @@ -20,10 +20,7 @@ understanding the nature of these context menu commands easier. ## Message context menu command ```ts title="src/app/commands/report-message.ts" -import type { - CommandData, - MessageContextMenuCommand, -} from 'commandkit'; +import type { CommandData, MessageContextMenuCommand } from 'commandkit'; import { MessageFlags } from 'discord.js'; export const command: CommandData = { diff --git a/apps/website/docs/guide/02-commands/05-after-function.mdx b/apps/website/docs/guide/02-commands/05-after-function.mdx index 5b8233d5..71571101 100644 --- a/apps/website/docs/guide/02-commands/05-after-function.mdx +++ b/apps/website/docs/guide/02-commands/05-after-function.mdx @@ -10,11 +10,7 @@ cleanup tasks. ## Usage ```ts title="src/app/commands/ping.ts" -import { - type CommandData, - type ChatInputCommand, - after, -} from 'commandkit'; +import { type CommandData, type ChatInputCommand, after } from 'commandkit'; export const command: CommandData = {}; diff --git a/apps/website/docs/guide/02-commands/07-middlewares.mdx b/apps/website/docs/guide/02-commands/07-middlewares.mdx index 6c22bb8a..d1466807 100644 --- a/apps/website/docs/guide/02-commands/07-middlewares.mdx +++ b/apps/website/docs/guide/02-commands/07-middlewares.mdx @@ -21,9 +21,7 @@ import { MiddlewareContext } from 'commandkit'; export function beforeExecute(ctx: MiddlewareContext) { // This function will be executed before the command is executed - console.log( - `User ${ctx.interaction.user.id} is about to execute a command`, - ); + console.log(`User ${ctx.interaction.user.id} is about to execute a command`); } export function afterExecute(ctx: MiddlewareContext) { @@ -68,9 +66,7 @@ import type { MiddlewareContext } from 'commandkit'; export function beforeExecute(ctx: MiddlewareContext) { // This middleware will run before any moderation command if (!ctx.interaction.member.permissions.has('KickMembers')) { - throw new Error( - 'You need moderation permissions to use this command', - ); + throw new Error('You need moderation permissions to use this command'); } } ``` diff --git a/apps/website/docs/guide/03-events/01-discordjs-events.mdx b/apps/website/docs/guide/03-events/01-discordjs-events.mdx index 8bb486e2..d6c974da 100644 --- a/apps/website/docs/guide/03-events/01-discordjs-events.mdx +++ b/apps/website/docs/guide/03-events/01-discordjs-events.mdx @@ -106,10 +106,7 @@ Some Discord.js events have multiple parameters, such as the ```ts title="src/app/events/messageUpdate/log-message-update.ts" import type { EventHandler } from 'commandkit'; -const handler: EventHandler<'messageUpdate'> = ( - oldMessage, - newMessage, -) => { +const handler: EventHandler<'messageUpdate'> = (oldMessage, newMessage) => { console.log( `Message from ${oldMessage.author?.username} updated: ${oldMessage.content} -> ${newMessage.content}`, ); @@ -135,9 +132,7 @@ const handler: EventHandler<'messageCreate'> = ( client, commandkit, ) => { - console.log( - `Message from ${message.author.username}: ${message.content}`, - ); + console.log(`Message from ${message.author.username}: ${message.content}`); }; export default handler; @@ -171,9 +166,7 @@ export default handler; import type { EventHandler } from 'commandkit'; const handler: EventHandler<'messageCreate'> = (message) => { - console.log( - `Message from ${message.author.username}: ${message.content}`, - ); + console.log(`Message from ${message.author.username}: ${message.content}`); }; export default handler; diff --git a/apps/website/docs/guide/04-jsx-components/01-using-jsx.mdx b/apps/website/docs/guide/04-jsx-components/01-using-jsx.mdx index 42899fcf..5b832d94 100644 --- a/apps/website/docs/guide/04-jsx-components/01-using-jsx.mdx +++ b/apps/website/docs/guide/04-jsx-components/01-using-jsx.mdx @@ -40,12 +40,7 @@ builders: ## Example usage ```tsx -import { - Container, - TextDisplay, - ActionRow, - Button, -} from 'commandkit'; +import { Container, TextDisplay, ActionRow, Button } from 'commandkit'; import { ButtonStyle } from 'discord.js'; const message = ( diff --git a/apps/website/docs/guide/04-jsx-components/02-discord-components-v1/01-action-row.mdx b/apps/website/docs/guide/04-jsx-components/02-discord-components-v1/01-action-row.mdx index 64cbe406..b284bb9e 100644 --- a/apps/website/docs/guide/04-jsx-components/02-discord-components-v1/01-action-row.mdx +++ b/apps/website/docs/guide/04-jsx-components/02-discord-components-v1/01-action-row.mdx @@ -10,9 +10,7 @@ components like buttons and select menus together in a single row. ```tsx title="src/app/commands/example.tsx" import { type ChatInputCommand, ActionRow, Button } from 'commandkit'; -export const chatInput: ChatInputCommand = async ({ - interaction, -}) => { +export const chatInput: ChatInputCommand = async ({ interaction }) => { const row = ( @@ -37,9 +35,7 @@ import { StringSelectMenuOption, } from 'commandkit'; -export const chatInput: ChatInputCommand = async ({ - interaction, -}) => { +export const chatInput: ChatInputCommand = async ({ interaction }) => { const row = ( @@ -65,9 +61,7 @@ components: import { type ChatInputCommand, ActionRow, Button } from 'commandkit'; import { ButtonStyle } from 'discord.js'; -export const chatInput: ChatInputCommand = async ({ - interaction, -}) => { +export const chatInput: ChatInputCommand = async ({ interaction }) => { const firstRow = ( @@ -36,9 +34,7 @@ Discord provides several button styles that you can import from the import { type ChatInputCommand, ActionRow, Button } from 'commandkit'; import { ButtonStyle } from 'discord.js'; -export const chatInput: ChatInputCommand = async ({ - interaction, -}) => { +export const chatInput: ChatInputCommand = async ({ interaction }) => { const buttons = (