MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / createAttachmentFileAccess

Function createAttachmentFileAccess

desktop/runtime/attachment-file-tools.ts:97–117  ·  view source on GitHub ↗
(grants: AttachmentGrant)

Source from the content-addressed store, hash-verified

95}
96
97function 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
119export function createAttachmentFileTools(options: { cwd: string; autoResizeImages: boolean }): {
120 tools: ToolDefinition[]

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected