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