Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/website/docs/api-reference/ai/classes/ai-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## AiPlugin

<GenerationInfo sourceFile="packages/ai/src/plugin.ts" sourceLine="38" packageName="@commandkit/ai" />
<GenerationInfo sourceFile="packages/ai/src/plugin.ts" sourceLine="39" packageName="@commandkit/ai" />



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: "Experimental_createConfig"
isDefaultIndex: false
generated: true
---

import MemberInfo from '@site/src/components/MemberInfo';
import GenerationInfo from '@site/src/components/GenerationInfo';
import MemberDescription from '@site/src/components/MemberDescription';

<!-- This file was generated from the CommandKit source. Do not modify. Instead, re-run the "docgen" script -->


## experimental_createConfig

<GenerationInfo sourceFile="packages/ai/src/utils.ts" sourceLine="37" packageName="@commandkit/ai" experimental="true" />

Generates AI config from a CommandKit command data.

```ts title="Signature"
function experimental_createConfig(command: CommandData): AiConfig
```
Parameters

### command

<MemberInfo kind="parameter" type={`<a href='/docs/next/api-reference/commandkit/types/command-data#commanddata'>CommandData</a>`} />

10 changes: 5 additions & 5 deletions apps/website/docs/api-reference/ai/interfaces/ai-config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import MemberDescription from '@site/src/components/MemberDescription';

## AiConfig

<GenerationInfo sourceFile="packages/ai/src/plugin.ts" sourceLine="19" packageName="@commandkit/ai" />
<GenerationInfo sourceFile="packages/ai/src/plugin.ts" sourceLine="20" packageName="@commandkit/ai" />

Represents the configuration options for the AI plugin scoped to a specific command.

```ts title="Signature"
interface AiConfig {
interface AiConfig<T extends ToolParameterType = ToolParameterType> {
description?: string;
parameters: any;
inputSchema: T;
}
```

Expand All @@ -31,9 +31,9 @@ interface AiConfig {
<MemberInfo kind="property" type={`string`} />

A description of the AI functionality provided by this command. If not given, the command's description will be used.
### parameters
### inputSchema

<MemberInfo kind="property" type={`any`} />
<MemberInfo kind="property" type={`T`} />

A zod schema defining the parameters that the AI command accepts.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## AiPluginOptions

<GenerationInfo sourceFile="packages/ai/src/types.ts" sourceLine="41" packageName="@commandkit/ai" />
<GenerationInfo sourceFile="packages/ai/src/types.ts" sourceLine="44" packageName="@commandkit/ai" />

Options for the AI plugin.

Expand Down
26 changes: 13 additions & 13 deletions apps/website/docs/api-reference/ai/interfaces/configure-ai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ interface ConfigureAI {
messageFilter?: MessageFilter;
selectAiModel: SelectAiModel;
prepareSystemPrompt?: (ctx: AiContext, message: Message) => Promise<string>;
preparePrompt?: (
ctx: AiContext,
message: Message,
preparePrompt?: (
ctx: AiContext,
message: Message,
) => Promise<string | AiMessage>;
onProcessingStart?: (ctx: AiContext, message: Message) => Promise<void>;
onProcessingFinish?: (ctx: AiContext, message: Message) => Promise<void>;
onResult?: (
ctx: AiContext,
message: Message,
result: AIGenerateResult,
onResult?: (
ctx: AiContext,
message: Message,
result: AIGenerateResult,
) => Promise<void>;
onError?: (ctx: AiContext, message: Message, error: Error) => Promise<void>;
}
Expand All @@ -49,24 +49,24 @@ Whether to disable the built-in tools. Default is false.

<MemberInfo kind="property" type={`<a href='/docs/next/api-reference/ai/types/message-filter#messagefilter'>MessageFilter</a>`} />

A filter function that determines whether a message should be processed by the AI.
A filter function that determines whether a message should be processed by the AI.
CommandKit invokes this function before processing the message.
### selectAiModel

<MemberInfo kind="property" type={`<a href='/docs/next/api-reference/ai/types/select-ai-model#selectaimodel'>SelectAiModel</a>`} />

A function that selects the AI model to use based on the message.
A function that selects the AI model to use based on the message.
This function should return a promise that resolves to an object containing the model and options.
### prepareSystemPrompt

<MemberInfo kind="property" type={`(ctx: <a href='/docs/next/api-reference/ai/classes/ai-context#aicontext'>AiContext</a>, message: Message) =&#62; Promise&#60;string&#62;`} />

A function that generates a system prompt based on the message.
This function should return a promise that resolves to a string containing the system prompt.
A function that generates a system prompt based on the message.
This function should return a promise that resolves to a string containing the system prompt.
If not provided, a default system prompt will be used.
### preparePrompt

<MemberInfo kind="property" type={`( ctx: <a href='/docs/next/api-reference/ai/classes/ai-context#aicontext'>AiContext</a>, message: Message, ) =&#62; Promise&#60;string | <a href='/docs/next/api-reference/ai/types/ai-message#aimessage'>AiMessage</a>&#62;`} />
<MemberInfo kind="property" type={`( ctx: <a href='/docs/next/api-reference/ai/classes/ai-context#aicontext'>AiContext</a>, message: Message, ) =&#62; Promise&#60;string | <a href='/docs/next/api-reference/ai/types/ai-message#aimessage'>AiMessage</a>&#62;`} />

A function that prepares the prompt for the AI model.
### onProcessingStart
Expand All @@ -81,7 +81,7 @@ A function that gets called when the AI starts processing a message.
A function that gets called when the AI finishes processing a message.
### onResult

<MemberInfo kind="property" type={`( ctx: <a href='/docs/next/api-reference/ai/classes/ai-context#aicontext'>AiContext</a>, message: Message, result: <a href='/docs/next/api-reference/ai/types/aigenerate-result#aigenerateresult'>AIGenerateResult</a>, ) =&#62; Promise&#60;void&#62;`} />
<MemberInfo kind="property" type={`( ctx: <a href='/docs/next/api-reference/ai/classes/ai-context#aicontext'>AiContext</a>, message: Message, result: <a href='/docs/next/api-reference/ai/types/aigenerate-result#aigenerateresult'>AIGenerateResult</a>, ) =&#62; Promise&#60;void&#62;`} />

A function that gets called upon receiving the result from the AI model.
### onError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Configuration options for creating an AI tool.
interface CreateToolOptions<T extends ToolParameterType, R = unknown> {
name: string;
description: string;
parameters: T;
inputSchema: T;
execute: ToolExecuteFunction<T, R>;
}
```
Expand All @@ -38,7 +38,7 @@ The unique name identifier for the tool
<MemberInfo kind="property" type={`string`} />

A human-readable description of what the tool does
### parameters
### inputSchema

<MemberInfo kind="property" type={`T`} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## AiCommandContext

<GenerationInfo sourceFile="packages/ai/src/types.ts" sourceLine="54" packageName="@commandkit/ai" />
<GenerationInfo sourceFile="packages/ai/src/types.ts" sourceLine="57" packageName="@commandkit/ai" />

Represents the context in which an AI command is executed.
It extends the MessageCommandContext to include AI-specific properties.
Expand Down
2 changes: 1 addition & 1 deletion apps/website/docs/api-reference/ai/types/ai-command.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## AiCommand

<GenerationInfo sourceFile="packages/ai/src/types.ts" sourceLine="62" packageName="@commandkit/ai" />
<GenerationInfo sourceFile="packages/ai/src/types.ts" sourceLine="65" packageName="@commandkit/ai" />

Represents a command that can be executed by the AI.

Expand Down
2 changes: 1 addition & 1 deletion apps/website/docs/api-reference/ai/types/command-tool.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## CommandTool

<GenerationInfo sourceFile="packages/ai/src/types.ts" sourceLine="35" packageName="@commandkit/ai" />
<GenerationInfo sourceFile="packages/ai/src/types.ts" sourceLine="38" packageName="@commandkit/ai" />



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import MemberDescription from '@site/src/components/MemberDescription';

## ExtractAiConfig

<GenerationInfo sourceFile="packages/ai/src/types.ts" sourceLine="46" packageName="@commandkit/ai" />
<GenerationInfo sourceFile="packages/ai/src/types.ts" sourceLine="49" packageName="@commandkit/ai" />

Extracts the AI configuration params.

```ts title="Signature"
type ExtractAiConfig<T extends Record<string, unknown>> = T extends AiConfig ? InferParameters<T['parameters']> : T
type ExtractAiConfig<T extends Record<string, unknown>> = T extends AiConfig ? InferParameters<T['inputSchema']> : T
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ import MemberDescription from '@site/src/components/MemberDescription';


```ts title="Signature"
type SelectAiModelResult = Parameters<typeof generateText>[0]
type SelectAiModelResult = Omit<
Parameters<typeof generateText>[0],
'messages' | 'prompt'
>
```
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ Type definition for a tool's execute function.
```ts title="Signature"
type ToolExecuteFunction<T extends ToolParameterType, R> = (
ctx: AiContext,
parameters: InferParameters<T>,
inputSchema: InferParameters<T>,
) => Awaitable<R>
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Type representing the parameters schema for AI tools.
Extracted from the first parameter of the `tool` function from the 'ai' library.

```ts title="Signature"
type ToolParameterType = Parameters<typeof tool>[0]['parameters']
type ToolParameterType = z.ZodType | Schema<any>
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ Context for managing cache operations within an async scope

```ts title="Signature"
interface CacheContext {
params: {
/** Custom name for the cache entry */
name?: string;
/** Time-to-live in milliseconds */
ttl?: number | null;
tags: Set<string>;
params: {
/** Custom name for the cache entry */
name?: string;
/** Time-to-live in milliseconds */
ttl?: number | null;
tags: Set<string>;
};
}
```
Expand All @@ -33,7 +33,7 @@ interface CacheContext {

### params

<MemberInfo kind="property" type={`{ /** Custom name for the <a href='/docs/next/api-reference/cache/functions/cache#cache'>cache</a> entry */ name?: string; /** Time-to-live in milliseconds */ ttl?: number | null; tags: Set&#60;string&#62;; }`} />
<MemberInfo kind="property" type={`{ /** Custom name for the <a href='/docs/next/api-reference/cache/functions/cache#cache'>cache</a> entry */ name?: string; /** Time-to-live in milliseconds */ ttl?: number | null; tags: Set&#60;string&#62;; }`} />



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## AppCommandHandler

<GenerationInfo sourceFile="packages/commandkit/src/app/handlers/AppCommandHandler.ts" sourceLine="149" packageName="commandkit" />
<GenerationInfo sourceFile="packages/commandkit/src/app/handlers/AppCommandHandler.ts" sourceLine="176" packageName="commandkit" />

Handles application commands for CommandKit, including loading, registration, and execution.
Manages both slash commands and message commands with middleware support.
Expand All @@ -35,6 +35,7 @@ class AppCommandHandler {
registerExternalLoadedMiddleware(data: LoadedMiddleware[]) => ;
registerExternalLoadedCommands(data: LoadedCommand[]) => ;
loadCommands() => ;
getMetadataFor(command: string) => CommandMetadata | null;
}
```

Expand Down Expand Up @@ -115,6 +116,11 @@ Registers externally loaded commands.
<MemberInfo kind="method" type={`() => `} />

Loads all commands and middleware from the router.
### getMetadataFor

<MemberInfo kind="method" type={`(command: string) => <a href='/docs/next/api-reference/commandkit/interfaces/command-metadata#commandmetadata'>CommandMetadata</a> | null`} />

Gets the metadata for a command.


</div>
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Handles registration of Discord application commands (slash commands, context me
```ts title="Signature"
class CommandRegistrar {
constructor(commandkit: CommandKit)
getCommandsData() => CommandData[];
getCommandsData() => (CommandData & { __metadata?: CommandMetadata })[];
register() => ;
updateGlobalCommands(commands: CommandData[]) => ;
updateGuildCommands(commands: CommandData[]) => ;
updateGlobalCommands(commands: (CommandData & { __metadata?: CommandMetadata })[]) => ;
updateGuildCommands(commands: (CommandData & { __metadata?: CommandMetadata })[]) => ;
}
```

Expand All @@ -36,7 +36,7 @@ class CommandRegistrar {
Creates an instance of CommandRegistrar.
### getCommandsData

<MemberInfo kind="method" type={`() => <a href='/docs/next/api-reference/commandkit/types/command-data#commanddata'>CommandData</a>[]`} />
<MemberInfo kind="method" type={`() => (<a href='/docs/next/api-reference/commandkit/types/command-data#commanddata'>CommandData</a> &#38; { __metadata?: <a href='/docs/next/api-reference/commandkit/interfaces/command-metadata#commandmetadata'>CommandMetadata</a> })[]`} />

Gets the commands data.
### register
Expand All @@ -46,12 +46,12 @@ Gets the commands data.
Registers loaded commands.
### updateGlobalCommands

<MemberInfo kind="method" type={`(commands: <a href='/docs/next/api-reference/commandkit/types/command-data#commanddata'>CommandData</a>[]) => `} />
<MemberInfo kind="method" type={`(commands: (<a href='/docs/next/api-reference/commandkit/types/command-data#commanddata'>CommandData</a> &#38; { __metadata?: <a href='/docs/next/api-reference/commandkit/interfaces/command-metadata#commandmetadata'>CommandMetadata</a> })[]) => `} />

Updates the global commands.
### updateGuildCommands

<MemberInfo kind="method" type={`(commands: <a href='/docs/next/api-reference/commandkit/types/command-data#commanddata'>CommandData</a>[]) => `} />
<MemberInfo kind="method" type={`(commands: (<a href='/docs/next/api-reference/commandkit/types/command-data#commanddata'>CommandData</a> &#38; { __metadata?: <a href='/docs/next/api-reference/commandkit/interfaces/command-metadata#commandmetadata'>CommandMetadata</a> })[]) => `} />

Updates the guild commands.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## AppCommandNative

<GenerationInfo sourceFile="packages/commandkit/src/app/handlers/AppCommandHandler.ts" sourceLine="39" packageName="commandkit" />
<GenerationInfo sourceFile="packages/commandkit/src/app/handlers/AppCommandHandler.ts" sourceLine="50" packageName="commandkit" />

Represents a native command structure used in CommandKit.
This structure includes the command definition and various handlers for different interaction types.
Expand All @@ -22,6 +22,8 @@ It can be used to define slash commands, context menu commands, and message comm
```ts title="Signature"
interface AppCommandNative {
command: CommandData | Record<string, any>;
generateMetadata?: CommandMetadataFunction;
metadata?: CommandMetadata;
chatInput?: (ctx: Context) => Awaitable<unknown>;
autocomplete?: (ctx: Context) => Awaitable<unknown>;
message?: (ctx: Context) => Awaitable<unknown>;
Expand All @@ -37,6 +39,16 @@ interface AppCommandNative {
<MemberInfo kind="property" type={`<a href='/docs/next/api-reference/commandkit/types/command-data#commanddata'>CommandData</a> | Record&#60;string, any&#62;`} />


### generateMetadata

<MemberInfo kind="property" type={`<a href='/docs/next/api-reference/commandkit/types/command-metadata-function#commandmetadatafunction'>CommandMetadataFunction</a>`} />


### metadata

<MemberInfo kind="property" type={`<a href='/docs/next/api-reference/commandkit/interfaces/command-metadata#commandmetadata'>CommandMetadata</a>`} />


### chatInput

<MemberInfo kind="property" type={`(ctx: <a href='/docs/next/api-reference/commandkit/classes/context#context'>Context</a>) =&#62; Awaitable&#60;unknown&#62;`} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## CommandContext

<GenerationInfo sourceFile="packages/commandkit/src/types.ts" sourceLine="27" packageName="commandkit" />
<GenerationInfo sourceFile="packages/commandkit/src/types.ts" sourceLine="29" packageName="commandkit" />

Represents a command context.

Expand Down
Loading