(tool: Tool, input: unknown)
| 173 | |
| 174 | // Create a custom canUseTool that only allows Edit for magic doc files |
| 175 | const canUseTool = async (tool: Tool, input: unknown) => { |
| 176 | if ( |
| 177 | tool.name === FILE_EDIT_TOOL_NAME && |
| 178 | typeof input === 'object' && |
| 179 | input !== null && |
| 180 | 'file_path' in input |
| 181 | ) { |
| 182 | const filePath = input.file_path |
| 183 | if (typeof filePath === 'string' && filePath === docInfo.path) { |
| 184 | return { behavior: 'allow' as const, updatedInput: input } |
| 185 | } |
| 186 | } |
| 187 | return { |
| 188 | behavior: 'deny' as const, |
| 189 | message: `only ${FILE_EDIT_TOOL_NAME} is allowed for ${docInfo.path}`, |
| 190 | decisionReason: { |
| 191 | type: 'other' as const, |
| 192 | reason: `only ${FILE_EDIT_TOOL_NAME} is allowed`, |
| 193 | }, |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | // Run Magic Docs update using runAgent with forked context |
| 198 | for await (const _message of runAgent({ |
no outgoing calls
no test coverage detected