| 1220 | // fields are picked explicitly rather than spread: a caller reading the view |
| 1221 | // gets the contract in `tool.ts` and nothing a plugin keeps for itself. |
| 1222 | const toolAnnotationsView = ( |
| 1223 | annotations: ToolAnnotations | undefined, |
| 1224 | ): ToolAnnotationsView | undefined => { |
| 1225 | if (!annotations) return undefined; |
| 1226 | const view: { |
| 1227 | requiresApproval?: boolean; |
| 1228 | approvalDescription?: string; |
| 1229 | mayElicit?: boolean; |
| 1230 | } = {}; |
| 1231 | if (typeof annotations.requiresApproval === "boolean") { |
| 1232 | view.requiresApproval = annotations.requiresApproval; |
| 1233 | } |
| 1234 | if (typeof annotations.approvalDescription === "string") { |
| 1235 | view.approvalDescription = annotations.approvalDescription; |
| 1236 | } |
| 1237 | if (typeof annotations.mayElicit === "boolean") view.mayElicit = annotations.mayElicit; |
| 1238 | return Object.keys(view).length > 0 ? ToolAnnotationsView.make(view) : undefined; |
| 1239 | }; |
| 1240 | |
| 1241 | // --------------------------------------------------------------------------- |
| 1242 | // Condition builders |