(grants: AttachmentGrant)
| 95 | } |
| 96 | |
| 97 | function createAttachmentFileAccess(grants: AttachmentGrant): AttachmentFileAccess { |
| 98 | return { |
| 99 | async grantAttachments(attachments) { |
| 100 | for (const attachment of attachments) { |
| 101 | const attachmentPath = attachment.path.trim() |
| 102 | if (!attachmentPath || isExternalReference(attachmentPath)) continue |
| 103 | try { |
| 104 | const resolved = await realpath(attachmentPath) |
| 105 | const metadata = await stat(resolved) |
| 106 | if (metadata.isDirectory()) { |
| 107 | grants.directories.add(resolved) |
| 108 | } else if (metadata.isFile()) { |
| 109 | grants.files.add(resolved) |
| 110 | } |
| 111 | } catch { |
| 112 | // Invalid attachments are already rejected in the composer path; ignore stale paths here. |
| 113 | } |
| 114 | } |
| 115 | }, |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | export function createAttachmentFileTools(options: { cwd: string; autoResizeImages: boolean }): { |
| 120 | tools: ToolDefinition[] |
no outgoing calls
no test coverage detected