| 1234 | // fields are picked explicitly rather than spread: a caller reading the view |
| 1235 | // gets the contract in `tool.ts` and nothing a plugin keeps for itself. |
| 1236 | const toolAnnotationsView = ( |
| 1237 | annotations: ToolAnnotations | undefined, |
| 1238 | ): ToolAnnotationsView | undefined => { |
| 1239 | if (!annotations) return undefined; |
| 1240 | const view: { |
| 1241 | requiresApproval?: boolean; |
| 1242 | approvalDescription?: string; |
| 1243 | mayElicit?: boolean; |
| 1244 | } = {}; |
| 1245 | if (typeof annotations.requiresApproval === "boolean") { |
| 1246 | view.requiresApproval = annotations.requiresApproval; |
| 1247 | } |
| 1248 | if (typeof annotations.approvalDescription === "string") { |
| 1249 | view.approvalDescription = annotations.approvalDescription; |
| 1250 | } |
| 1251 | if (typeof annotations.mayElicit === "boolean") view.mayElicit = annotations.mayElicit; |
| 1252 | return Object.keys(view).length > 0 ? ToolAnnotationsView.make(view) : undefined; |
| 1253 | }; |
| 1254 | |
| 1255 | // --------------------------------------------------------------------------- |
| 1256 | // Condition builders |