| 1110 | ): RegisteredPrompt; |
| 1111 | |
| 1112 | prompt(name: string, ...rest: unknown[]): RegisteredPrompt { |
| 1113 | if (this._registeredPrompts[name]) { |
| 1114 | throw new Error(`Prompt ${name} is already registered`); |
| 1115 | } |
| 1116 | |
| 1117 | let description: string | undefined; |
| 1118 | if (typeof rest[0] === 'string') { |
| 1119 | description = rest.shift() as string; |
| 1120 | } |
| 1121 | |
| 1122 | let argsSchema: PromptArgsRawShape | undefined; |
| 1123 | if (rest.length > 1) { |
| 1124 | argsSchema = rest.shift() as PromptArgsRawShape; |
| 1125 | } |
| 1126 | |
| 1127 | const cb = rest[0] as PromptCallback<PromptArgsRawShape | undefined>; |
| 1128 | const registeredPrompt = this._createRegisteredPrompt(name, undefined, description, argsSchema, cb); |
| 1129 | |
| 1130 | this.setPromptRequestHandlers(); |
| 1131 | this.sendPromptListChanged(); |
| 1132 | |
| 1133 | return registeredPrompt; |
| 1134 | } |
| 1135 | |
| 1136 | /** |
| 1137 | * Registers a prompt with a config object and callback. |